/**
 * ldesign v0.3.13
 * (c) 2023 ldesign
 * @license MIT
 */

'use strict';

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

var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var vue = require('vue');
var table_baseTableProps = require('./base-table-props.js');
var table_primaryTableProps = require('./primary-table-props.js');
var table_enhancedTableProps = require('./enhanced-table-props.js');
var table_primaryTable = require('./primary-table.js');
var table_hooks_useTreeData = require('./hooks/useTreeData.js');
var table_hooks_useTreeSelect = require('./hooks/useTreeSelect.js');
require('lodash/get');
require('lodash/omit');
require('../hooks/tnode.js');
require('lodash/isFunction');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../utils/render-tnode.js');
require('lodash/isEmpty');
require('lodash/isString');
require('lodash/isObject');
require('./base-table.js');
require('lodash/pick');
require('../hooks/useVirtualScrollNew.js');
require('@babel/runtime/helpers/toConsumableArray');
require('@babel/runtime/helpers/slicedToArray');
require('../hooks/useResizeObserver.js');
require('../loading/index.js');
require('../utils/withInstall.js');
require('../loading/directive.js');
require('../loading/plugin.js');
require('../utils/dom.js');
require('../_chunks/dep-f4db2590.js');
require('lodash/isArray');
require('../utils/easing.js');
require('../hooks/useConfig.js');
require('../config-provider/useConfig.js');
require('lodash/cloneDeep');
require('../config-provider/context.js');
require('lodash/mergeWith');
require('lodash/merge');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('dayjs');
require('../loading/loading.js');
require('../hooks/useTeleport.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../_common/js/loading/circle-adapter.js');
require('../_common/js/utils/set-style.js');
require('../_common/js/utils/helper.js');
require('lodash/isNull');
require('lodash/isUndefined');
require('lodash/isNumber');
require('../affix/index.js');
require('../affix/affix.js');
require('@babel/runtime/helpers/asyncToGenerator');
require('@babel/runtime/regenerator');
require('../affix/props.js');
require('./hooks/useTableHeader.js');
require('./ellipsis.js');
require('lodash/debounce');
require('../tooltip/index.js');
require('../tooltip/tooltip.js');
require('../popup/props.js');
require('../popup/index.js');
require('../popup/popup.js');
require('@popperjs/core');
require('../hooks/useVModel.js');
require('../popup/container.js');
require('../tooltip/util.js');
require('../tooltip/props.js');
require('./hooks/useClassName.js');
require('./hooks/useMultiHeader.js');
require('./hooks/useColumnResize.js');
require('./hooks/useFixed.js');
require('../_common/js/log/log.js');
require('../_common/js/utils/getScrollbarWidth.js');
require('./hooks/usePagination.js');
require('../pagination/index.js');
require('../pagination/pagination.js');
require('lodash/isNaN');
require('@ldesign/icons-vue-next');
require('../hooks/useGlobalIcon.js');
require('../input-number/index.js');
require('../input-number/input-number.js');
require('../button/index.js');
require('../button/button.js');
require('../hooks/useRipple.js');
require('../utils/set-style.js');
require('../hooks/useKeepAnimation.js');
require('../form/hooks.js');
require('../button/props.js');
require('../input/index.js');
require('../input/input.js');
require('../input/props.js');
require('../input/useInput.js');
require('../form/const.js');
require('../input/useLengthLimit.js');
require('../input/useInputEventHandler.js');
require('../input/useInputWidth.js');
require('../input/input-group.js');
require('../input/input-group-props.js');
require('../input-number/props.js');
require('../input-number/useInputNumber.js');
require('../hooks/useCommonClassName.js');
require('../_common/js/input-number/number.js');
require('lodash/isNil');
require('../_common/js/input-number/large-number.js');
require('../select/index.js');
require('../select/select.js');
require('lodash/intersection');
require('../common-components/fake-arrow.js');
require('../select-input/index.js');
require('../select-input/select-input.js');
require('../select-input/props.js');
require('../select-input/useSingle.js');
require('../hooks/useDefaultValue.js');
require('../select-input/useMultiple.js');
require('../tag-input/index.js');
require('../tag-input/tag-input.js');
require('../tag-input/props.js');
require('../tag-input/hooks/useTagScroll.js');
require('../tag-input/useTagList.js');
require('../tag/index.js');
require('../tag/tag.js');
require('../tag/props.js');
require('../tag/check-tag.js');
require('../tag/check-tag-props.js');
require('../tag-input/hooks/useHover.js');
require('../tag-input/hooks/useDragSorter.js');
require('../select-input/useOverlayInnerStyle.js');
require('../select/props.js');
require('../select/select-panel.js');
require('../select/option.js');
require('../checkbox/index.js');
require('../checkbox/checkbox.js');
require('../checkbox/props.js');
require('../checkbox/constants.js');
require('../checkbox/group.js');
require('../hooks/slot.js');
require('../checkbox/checkbox-group-props.js');
require('../select/option-props.js');
require('../select/helper.js');
require('../select/optionGroup.js');
require('../select/option-group-props.js');
require('../select/hooks/usePanelVirtualScroll.js');
require('../hooks/useVirtualScroll.js');
require('../select/hooks/useSelectOptions.js');
require('../input-adornment/index.js');
require('../input-adornment/input-adornment.js');
require('../input-adornment/props.js');
require('../pagination/props.js');
require('../pagination/usePaginationClasses.js');
require('../pagination/useMoreAction.js');
require('../pagination/pagination-mini.js');
require('../pagination/pagination-mini-props.js');
require('./hooks/useAffix.js');
require('./tbody.js');
require('./tr.js');
require('lodash/upperFirst');
require('./utils.js');
require('./hooks/useLazyLoad.js');
require('../_common/js/utils/observe.js');
require('./hooks/useRowspanAndColspan.js');
require('./hooks/useStyle.js');
require('./thead.js');
require('./tfoot.js');
require('./hooks/useColumnController.js');
require('../dialog/plugin.js');
require('../dialog/dialog.js');
require('../hooks/useDestroyOnClose.js');
require('../dialog/stack.js');
require('../dialog/hooks.js');
require('../dialog/props.js');
require('./hooks/useRowExpand.js');
require('./hooks/useRowSelect.js');
require('../_common/js/table/utils.js');
require('../radio/index.js');
require('../radio/radio.js');
require('../utils/helper.js');
require('../radio/constants.js');
require('../radio/props.js');
require('../radio/group.js');
require('../radio/radio-group-props.js');
require('../radio/useKeyboard.js');
require('../radio/radio-button.js');
require('./hooks/useSorter.js');
require('./sorter-button.js');
require('./hooks/useFilter.js');
require('./filter-controller.js');
require('./hooks/useDragSort.js');
require('sortablejs');
require('../_common/js/utils/swapDragArrayElement.js');
require('./hooks/useAsyncLoading.js');
require('./editable-cell.js');
require('lodash/set');
require('../form/form-model.js');
require('lodash/isBoolean');
require('./hooks/useEditableRow.js');
require('../_common/js/table/tree-store.js');
require('@babel/runtime/helpers/classCallCheck');
require('@babel/runtime/helpers/createClass');

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

var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);

var _excluded = ["store", "dataSource", "formatTreeColumn", "swapData"];
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 _EnhancedTable = vue.defineComponent({
  name: "TEnhancedTable",
  props: _objectSpread(_objectSpread(_objectSpread({}, table_baseTableProps["default"]), table_primaryTableProps["default"]), table_enhancedTableProps["default"]),
  setup: function setup(props, context) {
    var primaryTableRef = vue.ref(null);
    var _useTreeData = table_hooks_useTreeData["default"](props, context),
      store = _useTreeData.store,
      dataSource = _useTreeData.dataSource,
      formatTreeColumn = _useTreeData.formatTreeColumn,
      swapData = _useTreeData.swapData,
      treeInstanceFunctions = _objectWithoutProperties__default["default"](_useTreeData, _excluded);
    var treeDataMap = vue.ref(store.value.treeDataMap);
    var _useTreeSelect = table_hooks_useTreeSelect["default"](props, treeDataMap),
      tIndeterminateSelectedRowKeys = _useTreeSelect.tIndeterminateSelectedRowKeys,
      onInnerSelectChange = _useTreeSelect.onInnerSelectChange;
    var getColumns = function getColumns(columns) {
      var arr = [];
      for (var i = 0, len = columns.length; i < len; i++) {
        var _item$children, _item$children2;
        var item = _objectSpread({}, columns[i]);
        item = formatTreeColumn(item);
        if ((_item$children = item.children) !== null && _item$children !== void 0 && _item$children.length) item.children = getColumns(item.children);
        if (!item.children || (_item$children2 = item.children) !== null && _item$children2 !== void 0 && _item$children2.length) arr.push(item);
      }
      return arr;
    };
    var tColumns = vue.computed(function () {
      var isTreeData = !props.tree || !Object.keys(props.tree).length;
      return isTreeData ? props.columns : getColumns(props.columns);
    });
    var onDragSortChange = function onDragSortChange(params) {
      var _props$onDragSort;
      if (props.beforeDragSort && !props.beforeDragSort(params)) return;
      swapData({
        current: params.current,
        target: params.target,
        currentIndex: params.currentIndex,
        targetIndex: params.targetIndex
      });
      (_props$onDragSort = props.onDragSort) === null || _props$onDragSort === void 0 ? void 0 : _props$onDragSort.call(props, params);
    };
    var onEnhancedTableRowClick = function onEnhancedTableRowClick(p) {
      var _props$tree, _props$onRowClick;
      if ((_props$tree = props.tree) !== null && _props$tree !== void 0 && _props$tree.expandTreeNodeOnClick) {
        treeInstanceFunctions.toggleExpandData({
          row: p.row,
          rowIndex: p.index
        }, "row-click");
      }
      (_props$onRowClick = props.onRowClick) === null || _props$onRowClick === void 0 ? void 0 : _props$onRowClick.call(props, p);
    };
    context.expose(_objectSpread(_objectSpread({
      store: store.value,
      dataSource: dataSource.value
    }, treeInstanceFunctions), {}, {
      primaryTableRef: primaryTableRef,
      validateRowData: function validateRowData(rowValue) {
        primaryTableRef.value.validateRowData(rowValue);
      },
      validateTableData: function validateTableData() {
        primaryTableRef.value.validateTableData();
      },
      clearValidateData: function clearValidateData() {
        primaryTableRef.value.clearValidateData();
      },
      refreshTable: function refreshTable() {
        primaryTableRef.value.refreshTable();
      },
      scrollToElement: function scrollToElement(data) {
        primaryTableRef.value.scrollToElement(data);
      }
    }));
    return function () {
      var _props$tree2;
      var _getCurrentInstance = vue.getCurrentInstance(),
        vnode = _getCurrentInstance.vnode;
      var enhancedProps = _objectSpread(_objectSpread({}, vnode.props), {}, {
        rowKey: props.rowKey || "id",
        data: dataSource.value,
        columns: tColumns.value,
        indeterminateSelectedRowKeys: tIndeterminateSelectedRowKeys.value,
        disableDataPage: Boolean(props.tree && Object.keys(props.tree).length),
        onSelectChange: onInnerSelectChange,
        onDragSort: onDragSortChange
      });
      if ((_props$tree2 = props.tree) !== null && _props$tree2 !== void 0 && _props$tree2.expandTreeNodeOnClick) enhancedProps.onRowClick = onEnhancedTableRowClick;
      return vue.createVNode(table_primaryTable["default"], vue.mergeProps(enhancedProps, {
        "ref": primaryTableRef
      }), context.slots);
    };
  }
});

exports["default"] = _EnhancedTable;
//# sourceMappingURL=enhanced-table.js.map
