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

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var helper = require('../../_chunks/dep-44e6bdf6.js');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var isFunction = require('lodash/isFunction');
var tdesignIconsVue = require('tdesign-icons-vue');
var utils_mixins = require('../../utils/mixins.js');
var configProvider_configReceiver = require('../../config-provider/config-receiver.js');
var table_primaryTableProps = require('../primary-table-props.js');
var config = require('../../config.js');
require('vue');
require('../../config-provider/zh_CN_config.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
var isFunction__default = /*#__PURE__*/_interopDefaultLegacy(isFunction);

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__default["default"](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 = utils_mixins["default"](configProvider_configReceiver["default"]("table")).extend({
  name: "".concat(config.prefix, "-expand-box"),
  props: {
    expanded: {
      type: Boolean,
      "default": false
    },
    row: {
      type: Object
    },
    rowIndex: {
      type: Number
    },
    expandIcon: table_primaryTableProps["default"].expandIcon
  },
  methods: {
    getDefaultIcon: function getDefaultIcon() {
      var h = this.$createElement;
      return isFunction__default["default"](this.global.expandIcon) ? this.global.expandIcon(this.$createElement) : h(tdesignIconsVue.ChevronRightCircleIcon);
    },
    getExpandIcon: function getExpandIcon(expanded) {
      var h = this.$createElement;
      var icon = isFunction__default["default"](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.helper([{}, buttonProps, {
      "class": "".concat(config.prefix, "-table__expand-box")
    }]), [icon]);
  }
});

exports["default"] = ExpandBox;
//# sourceMappingURL=expand-box.js.map
