'use strict';

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

var vue = require('vue');
require('../../../utils/index.js');
require('./config/index.js');
require('./components/header-search.vue.js');
require('./components/main-table.vue.js');
require('./components/pagination.vue.js');
var headerSearch = require('./config/header-search.js');
var table = require('./config/table.js');
var createNamespace = require('../../../utils/create-namespace.js');
var headerSearch_vue_vue_type_script_setup_true_lang = require('./components/header-search.vue2.js');
var mainTable_vue_vue_type_script_setup_true_lang = require('./components/main-table.vue2.js');
var pagination_vue_vue_type_script_setup_true_lang = require('./components/pagination.vue2.js');

"use strict";
var _sfc_main = /* @__PURE__ */ vue.defineComponent({
  ...{ name: "LlTable" },
  __name: "table",
  props: table.tableProps,
  setup(__props) {
    const props = __props;
    const originDataSource = vue.ref();
    const newNaTableptions = vue.ref({
      dataSource: [],
      columns: []
    });
    const contentType = vue.ref(headerSearch.ImenuSwitchType.TABLE);
    const headerSearchHeight = vue.ref(table.HEADER_SRARCH_HEIGHT);
    const tableRef = vue.ref();
    const bem = createNamespace.createNamespace("table");
    const handleChangeDataSource = (dataSource) => {
      newNaTableptions.value.dataSource = dataSource;
    };
    const handleSwitchMenuChange = (v) => {
      contentType.value = v;
    };
    const handleChangeHeaderSearch = (height) => {
      if (headerSearchHeight.value === height) return;
      headerSearchHeight.value = height;
    };
    vue.watch(
      () => props.tableProps,
      (newValue) => {
        if (newValue) {
          newNaTableptions.value = { ...newValue };
          originDataSource.value = [...newValue.dataSource];
          contentType.value = newNaTableptions.value.contentType;
        }
      },
      {
        deep: true,
        immediate: true
      }
    );
    vue.watch(
      () => [tableRef, headerSearchHeight],
      () => {
        if (tableRef.value) {
          const diffHeight = headerSearchHeight.value + 20 + table.PAGINATION_HEIGHT + 10;
          tableRef.value.style.height = `calc(100% - ${diffHeight}px)`;
        }
      },
      {
        immediate: true,
        deep: true
      }
    );
    vue.provide("contentType", contentType);
    return (_ctx, _cache) => {
      const _component_a_spin = vue.resolveComponent("a-spin");
      return vue.openBlock(), vue.createBlock(_component_a_spin, {
        spinning: props.loading,
        "wrapper-class-name": "ll-table-spin-wrapper"
      }, {
        default: vue.withCtx(() => [
          vue.createElementVNode(
            "div",
            {
              class: vue.normalizeClass(vue.unref(bem).b())
            },
            [
              vue.createCommentVNode(" \u5934\u90E8seach "),
              vue.createVNode(headerSearch_vue_vue_type_script_setup_true_lang.default, vue.mergeProps(_ctx.headerSearchProps, {
                "header-search-height": headerSearchHeight.value,
                onChange: handleSwitchMenuChange,
                onChangeHeaderSearch: handleChangeHeaderSearch
              }), {
                header: vue.withCtx(() => [
                  vue.renderSlot(_ctx.$slots, "header")
                ]),
                headerLeft: vue.withCtx(() => [
                  vue.renderSlot(_ctx.$slots, "headerLeft")
                ]),
                headerMiddle: vue.withCtx(() => [
                  vue.renderSlot(_ctx.$slots, "headerMiddle")
                ]),
                headerRight: vue.withCtx(() => [
                  vue.renderSlot(_ctx.$slots, "headerRight")
                ]),
                _: 3
                /* FORWARDED */
              }, 16, ["header-search-height"]),
              vue.createCommentVNode(" slot-content table\u548Ccard\u9ED8\u8BA4table "),
              vue.createElementVNode(
                "div",
                {
                  ref_key: "tableRef",
                  ref: tableRef,
                  class: vue.normalizeClass([
                    vue.unref(bem).m("fixed-height"),
                    !newNaTableptions.value.dataSource.length ? vue.unref(bem).m("empty") : ""
                  ])
                },
                [
                  vue.renderSlot(_ctx.$slots, contentType.value, {}, () => [
                    vue.createVNode(
                      mainTable_vue_vue_type_script_setup_true_lang.default,
                      vue.mergeProps(newNaTableptions.value, { onHandleChangeDataSource: handleChangeDataSource }),
                      vue.createSlots({
                        tableHeaderCell: vue.withCtx((slots) => [
                          vue.renderSlot(_ctx.$slots, "tableHeaderCell", vue.normalizeProps(vue.guardReactiveProps(slots)))
                        ]),
                        tableBodyCell: vue.withCtx((slots) => [
                          vue.renderSlot(_ctx.$slots, "tableBodyCell", vue.normalizeProps(vue.guardReactiveProps(slots)))
                        ]),
                        tableOperate: vue.withCtx((slots) => [
                          vue.renderSlot(_ctx.$slots, "tableOperate", vue.normalizeProps(vue.guardReactiveProps(slots)))
                        ]),
                        expandedTitle: vue.withCtx(() => [
                          vue.renderSlot(_ctx.$slots, "expandedTitle")
                        ]),
                        emptyText: vue.withCtx(() => [
                          vue.renderSlot(_ctx.$slots, "emptyText")
                        ]),
                        _: 2
                        /* DYNAMIC */
                      }, [
                        _ctx.$slots.expandedRow ? {
                          name: "expandedRow",
                          fn: vue.withCtx((slots) => [
                            vue.renderSlot(_ctx.$slots, "expandedRow", vue.normalizeProps(vue.guardReactiveProps(slots)))
                          ]),
                          key: "0"
                        } : void 0,
                        _ctx.$slots.customFilterDropdown ? {
                          name: "customFilterDropdown",
                          fn: vue.withCtx((slots) => [
                            vue.renderSlot(_ctx.$slots, "customFilterDropdown", vue.normalizeProps(vue.guardReactiveProps(slots)))
                          ]),
                          key: "1"
                        } : void 0,
                        _ctx.$slots.customFilterIcon ? {
                          name: "customFilterIcon",
                          fn: vue.withCtx((slots) => [
                            vue.renderSlot(_ctx.$slots, "customFilterIcon", vue.normalizeProps(vue.guardReactiveProps(slots)))
                          ]),
                          key: "2"
                        } : void 0,
                        _ctx.$slots.summary ? {
                          name: "summary",
                          fn: vue.withCtx((slots) => [
                            vue.renderSlot(_ctx.$slots, "summary", vue.normalizeProps(vue.guardReactiveProps(slots)))
                          ]),
                          key: "3"
                        } : void 0
                      ]),
                      1040
                      /* FULL_PROPS, DYNAMIC_SLOTS */
                    )
                  ])
                ],
                2
                /* CLASS */
              ),
              vue.createCommentVNode(" \u5E95\u90E8\u5206\u9875 "),
              newNaTableptions.value.dataSource.length && !newNaTableptions.value.hiddenPagination ? (vue.openBlock(), vue.createBlock(
                pagination_vue_vue_type_script_setup_true_lang.default,
                vue.normalizeProps(vue.mergeProps({ key: 0 }, _ctx.paginationProps)),
                null,
                16
                /* FULL_PROPS */
              )) : vue.createCommentVNode("v-if", true)
            ],
            2
            /* CLASS */
          )
        ]),
        _: 3
        /* FORWARDED */
      }, 8, ["spinning"]);
    };
  }
});

exports.default = _sfc_main;
//# sourceMappingURL=table.vue2.js.map
