/**
 * tdesign v0.32.0
 * (c) 2021 tdesign
 * @license MIT
 */

import { h as helper } from '../../_chunks/dep-42d5c87e.js';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import isFunction from 'lodash/isFunction';
import { ChevronRightCircleIcon } from 'tdesign-icons-vue';
import mixins from '../../utils/mixins.js';
import getConfigReceiverMixins from '../../config-provider/config-receiver.js';
import primaryTableProps from '../primary-table-props.js';
import { prefix } from '../../config.js';
import 'vue';
import '../../config-provider/zh_CN_config.js';
import '../../config-provider/type.js';

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var ExpandBox = mixins(getConfigReceiverMixins("table")).extend({
  name: "".concat(prefix, "-expand-box"),
  props: {
    expanded: {
      type: Boolean,
      "default": false
    },
    row: {
      type: Object
    },
    rowIndex: {
      type: Number
    },
    expandIcon: primaryTableProps.expandIcon
  },
  methods: {
    getDefaultIcon: function getDefaultIcon() {
      var h = this.$createElement;
      return isFunction(this.global.expandIcon) ? this.global.expandIcon(this.$createElement) : h(ChevronRightCircleIcon);
    },
    getExpandIcon: function getExpandIcon(expanded) {
      var h = this.$createElement;
      var icon = isFunction(this.expandIcon) ? this.expandIcon(this.$createElement, {
        row: this.row,
        index: this.rowIndex
      }) : this.getDefaultIcon();
      var style = {
        transition: "all .2s",
        display: "flex",
        "align-items": "center"
      };

      if (expanded) {
        style.transform = "rotate(90deg)";
      }

      if (!icon) return false;
      return h("span", {
        "style": style
      }, [icon]);
    }
  },
  render: function render() {
    var h = arguments[0];
    var expanded = this.expanded,
        $listeners = this.$listeners;
    var buttonProps = {
      on: _objectSpread({}, $listeners)
    };
    var icon = this.getExpandIcon(expanded);
    if (!icon) return null;
    return h("span", helper([{}, buttonProps, {
      "class": "".concat(prefix, "-table__expand-box")
    }]), [icon]);
  }
});

export { ExpandBox as default };
//# sourceMappingURL=expand-box.js.map
