"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
require("core-js/modules/es.regexp.exec.js");
require("core-js/modules/es.array.iterator.js");
require("core-js/modules/web.dom-collections.iterator.js");
require("core-js/modules/es.promise.js");
require("core-js/modules/es.array.sort.js");
require("core-js/modules/es.array.reduce.js");
var _react = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _omit = _interopRequireDefault(require("omit.js"));
var _table = _interopRequireDefault(require("../table"));
var _configProvider = _interopRequireDefault(require("../config-provider"));
var _form = _interopRequireDefault(require("../form"));
var _card = _interopRequireDefault(require("../card"));
var _spin = _interopRequireDefault(require("../spin"));
var _wauProvider = require("../wau-provider");
var _utils = require("../utils");
var _wauErrorBoundary = _interopRequireDefault(require("../wau-error-boundary"));
var _useFetchData = _interopRequireDefault(require("./useFetchData"));
var _container = _interopRequireDefault(require("./container"));
var _ToolBar = _interopRequireDefault(require("./ToolBar"));
var _Alert = _interopRequireDefault(require("./Alert"));
var _FormSearch = _interopRequireDefault(require("./FormSearch"));
var _Dropdown = _interopRequireDefault(require("./Dropdown"));
var _ListToolBar = _interopRequireDefault(require("./ListToolBar"));
var _ResizableTitle = _interopRequireDefault(require("./ResizableTitle"));
var _utils2 = require("./utils");
var _throttle = _interopRequireDefault(require("lodash/throttle"));
var _jsxRuntime = require("react/jsx-runtime");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const isBordered = (borderType, border) => {
  if (border === undefined) {
    return false;
  }
  // debugger
  if (typeof border === 'boolean') {
    return border;
  }
  return border[borderType];
};

/**
 * 🏆 Use Ant Design Table like a Pro! 更快 更好 更方便
 *
 * @param props
 */
const ProTable = props => {
  var _props$revalidateOnFo, _props$expandable, _props$columns, _props$editable2;
  const {
    cardBordered,
    request,
    className: propsClassName,
    params = {},
    defaultData,
    headerTitle,
    postData,
    pagination: propsPagination,
    actionRef: propsActionRef,
    columns: propsColumns = [],
    toolBarRender,
    onLoad,
    onRequestError,
    style,
    cardProps,
    tableStyle,
    tableClassName,
    // eslint-disable-next-line
    columnsStateMap,
    // eslint-disable-next-line
    onColumnsStateChange,
    options,
    search,
    onLoadingChange,
    rowSelection: propsRowSelection = false,
    beforeSearchSubmit = searchParams => searchParams,
    tableAlertRender,
    defaultClassName,
    formRef: propRef,
    type = 'table',
    columnEmptyText = '-',
    toolbar,
    rowKey,
    manualRequest,
    polling,
    onChange,
    ghostToolbar = true,
    columnResizable,
    components,
    ...rest
  } = props;
  const actionRef = (0, _react.useRef)();
  const {
    getPrefixCls
  } = (0, _react.useContext)(_configProvider.default.ConfigContext);
  const defaultFormRef = (0, _react.useRef)();
  const formRef = propRef || defaultFormRef;
  (0, _react.useEffect)(() => {
    if (typeof propsActionRef === 'function' && actionRef.current) {
      propsActionRef(actionRef.current);
    }
  }, [propsActionRef]);
  const [selectedRowKeys, setSelectedRowKeys] = (0, _utils.useMountMergeState)([], {
    value: propsRowSelection ? propsRowSelection.selectedRowKeys : undefined
  });
  const [selectedRows, setSelectedRows] = (0, _utils.useMountMergeState)([]);
  const setSelectedRowsAndKey = (0, _react.useCallback)((keys, rows) => {
    setSelectedRowKeys(keys);
    setSelectedRows(rows);
  }, [setSelectedRowKeys, setSelectedRows]);
  const [formSearch, setFormSearch] = (0, _utils.useMountMergeState)(() => {
    // 如果手动模式，或者 search 不存在的时候设置为 undefined
    // undefined 就不会触发首次加载
    if (manualRequest || search !== false) {
      return undefined;
    }
    return {};
  });
  const [proFilter, setProFilter] = (0, _utils.useMountMergeState)({});
  const [proSort, setProSort] = (0, _utils.useMountMergeState)({});

  /** 获取 table 的 dom ref */
  const rootRef = (0, _react.useRef)(null);
  const intl = (0, _wauProvider.useIntl)();

  /** 需要初始化 不然默认可能报错 这里取了 defaultCurrent 和 current 为了保证不会重复刷新 */
  const fetchPagination = typeof propsPagination === 'object' ? propsPagination : {
    defaultCurrent: 1,
    defaultPageSize: 20,
    pageSize: 20,
    current: 1
  };

  // ============================ useFetchData ============================
  const fetchData = (0, _react.useMemo)(() => {
    if (!request) return undefined;
    return async pageParams => {
      const actionParams = {
        ...(pageParams || {}),
        ...formSearch,
        ...params
      };

      // eslint-disable-next-line no-underscore-dangle
      delete actionParams._timestamp;
      const response = await request(actionParams, proSort, proFilter);
      return response;
    };
  }, [formSearch, params, proFilter, proSort, request]);
  const action = (0, _useFetchData.default)(fetchData, defaultData, {
    pageInfo: propsPagination === false ? false : fetchPagination,
    loading: props.loading,
    dataSource: props.dataSource,
    onDataSourceChange: props.onDataSourceChange,
    onLoad,
    onLoadingChange,
    onRequestError,
    postData,
    revalidateOnFocus: (_props$revalidateOnFo = props.revalidateOnFocus) !== null && _props$revalidateOnFo !== void 0 ? _props$revalidateOnFo : false,
    manual: formSearch === undefined,
    polling,
    effects: [(0, _utils.safeJSONStringify)(params), (0, _utils.safeJSONStringify)(formSearch), (0, _utils.safeJSONStringify)(proFilter), (0, _utils.safeJSONStringify)(proSort)],
    debounceTime: props.debounceTime,
    onPageInfoChange: pageInfo => {
      var _propsPagination$onCh, _propsPagination$onSh;
      if (type === 'list' || !propsPagination || !fetchData) return;

      // 总是触发一下 onChange 和  onShowSizeChange
      // 目前只有 List 和 Table 支持分页, List 有分页的时候打断 Table 的分页
      propsPagination === null || propsPagination === void 0 || (_propsPagination$onCh = propsPagination.onChange) === null || _propsPagination$onCh === void 0 ? void 0 : _propsPagination$onCh.call(propsPagination, pageInfo.current, pageInfo.pageSize);
      propsPagination === null || propsPagination === void 0 || (_propsPagination$onSh = propsPagination.onShowSizeChange) === null || _propsPagination$onSh === void 0 ? void 0 : _propsPagination$onSh.call(propsPagination, pageInfo.current, pageInfo.pageSize);
    }
  });
  // ============================ END ============================

  /** 默认聚焦的时候重新请求数据，这样可以保证数据都是最新的。 */
  (0, _react.useEffect)(() => {
    var _props$form;
    // 手动模式和 request 为空都不生效
    if (props.manualRequest || !props.request || props.revalidateOnFocus === false || (_props$form = props.form) !== null && _props$form !== void 0 && _props$form.ignoreRules) return;

    // 聚焦时重新请求事件
    const visibilitychange = () => {
      if (document.visibilityState === 'visible') action.reload();
    };
    document.addEventListener('visibilitychange', visibilitychange);
    return () => document.removeEventListener('visibilitychange', visibilitychange);
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);

  /** 页面编辑的计算 */
  const pagination = (0, _react.useMemo)(() => (0, _utils2.mergePagination)(propsPagination, {
    ...action.pageInfo,
    setPageInfo: ({
      pageSize,
      current
    }) => {
      // pageSize 发生改变，并且你不是在第一页，切回到第一页
      // 这样可以防止出现 跳转到一个空的数据页的问题
      if (pageSize !== action.pageInfo.pageSize &&
      // 当前页码
      action.pageInfo.current !== 1) {
        action.setDataSource([]);
        requestAnimationFrame(() => {
          action.setPageInfo({
            pageSize,
            current: 1
          });
          const onChangeArgs = [...argsRef.current];
          const [changePagination, filters, sorter, extra] = onChangeArgs;
          changePagination.current = 1;
          changePagination.pageSize = pageSize;
          if (propsPagination && propsPagination.onChange) {
            propsPagination.onChange(1, pageSize);
          }
          if (onChange) {
            onChange(changePagination, filters, sorter, extra);
          }
        });
      }
      action.setPageInfo({
        pageSize,
        current
      });
    }
  }, intl), [propsPagination, action, intl, onChange]);

  // eslint-disable-next-line
  const counter = _container.default.useContainer();

  /** 清空所有的选中项 */
  const onCleanSelected = (0, _react.useCallback)(() => {
    if (propsRowSelection && propsRowSelection.onChange) {
      propsRowSelection.onChange([], [], {
        type: 'none'
      });
    }
    setSelectedRowsAndKey([], []);
  }, [propsRowSelection, setSelectedRowsAndKey]);
  counter.setAction(actionRef.current);
  counter.propsRef.current = props;

  // ============================ RowKey ============================
  const getRowKey = _react.default.useMemo(() => {
    if (typeof rowKey === 'function') {
      return rowKey;
    }
    return (record, index) => {
      var _ref;
      return (_ref = record === null || record === void 0 ? void 0 : record[rowKey]) !== null && _ref !== void 0 ? _ref : index;
    };
  }, [rowKey]);

  /** 可编辑行的相关配置 */
  const editableUtils = (0, _utils.useEditableArray)({
    ...props.editable,
    getRowKey,
    childrenColumnName: (_props$expandable = props.expandable) === null || _props$expandable === void 0 ? void 0 : _props$expandable.childrenColumnName,
    dataSource: action.dataSource || [],
    setDataSource: data => {
      var _props$editable, _props$editable$onVal;
      (_props$editable = props.editable) === null || _props$editable === void 0 || (_props$editable$onVal = _props$editable.onValuesChange) === null || _props$editable$onVal === void 0 ? void 0 : _props$editable$onVal.call(_props$editable, undefined, data);
      action.setDataSource(data);
    }
  });

  /** 绑定 action */
  (0, _utils2.useActionType)(actionRef, action, {
    fullScreen: () => {
      if (!rootRef.current || !document.fullscreenEnabled) {
        return;
      }
      if (document.fullscreenElement) {
        document.exitFullscreen();
      } else {
        rootRef.current.requestFullscreen();
      }
    },
    onCleanSelected: () => {
      // 清空选中行
      onCleanSelected();
    },
    resetAll: () => {
      var _formRef$current;
      // 清空选中行
      onCleanSelected();
      // 清空筛选
      setProFilter({});
      // 清空排序
      setProSort({});
      // 清空 toolbar 搜索
      counter.setKeyWords(undefined);
      // 重置页码
      action.setPageInfo({
        current: 1
      });

      // 重置表单
      formRef === null || formRef === void 0 || (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.resetFields();
      setFormSearch({});
    },
    editableUtils
  });
  if (propsActionRef) {
    // @ts-ignore
    propsActionRef.current = actionRef.current;
  }
  /** 绑定 action ref */
  (0, _react.useImperativeHandle)(propsActionRef, () => {
    return actionRef.current;
  },
  // eslint-disable-next-line react-hooks/exhaustive-deps
  [editableUtils.editableKeys.join(',')]);

  // ---------- 列计算相关 start  -----------------
  const tableColumn = (0, _react.useMemo)(() => {
    return (0, _utils2.genColumnList)({
      columns: propsColumns,
      map: counter.columnsMap,
      counter,
      columnEmptyText,
      type,
      editableUtils
    }).sort((0, _utils2.tableColumnSort)(counter.columnsMap));
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [propsColumns, counter, columnEmptyText, type, editableUtils.editableKeys.join(',')]);

  /** Table Column 变化的时候更新一下，这个参数将会用于渲染 */
  (0, _utils.useDeepCompareEffect)(() => {
    if (tableColumn && tableColumn.length > 0) {
      // 重新生成key的字符串用于排序
      const columnKeys = tableColumn.map(item => (0, _utils2.genColumnKey)(item.key, item.index));
      counter.setSortKeyColumns(columnKeys);
    }
  }, [tableColumn]);
  const [columnWidth, setColumnWidth] = (0, _react.useState)({});
  const resizeHandlerGetter = (0, _react.useMemo)(() => {
    return index => {
      return (0, _throttle.default)((e, {
        size
      }) => {
        setColumnWidth(prev => ({
          ...prev,
          [index]: size.width
        }));
      }, 300);
    };
  }, []);
  const columns = (0, _react.useMemo)(() => {
    return tableColumn.filter(item => {
      // 删掉不应该显示的
      const columnKey = (0, _utils2.genColumnKey)(item.key, item.index);
      const config = counter.columnsMap[columnKey];
      if (config && config.show === false) {
        return false;
      }
      return true;
    }).map((item, index) => {
      const width = columnWidth[index] || item.width;
      const resizeOnHeaderCell = column => {
        var _item$onHeaderCell;
        return {
          ...((_item$onHeaderCell = item.onHeaderCell) === null || _item$onHeaderCell === void 0 ? void 0 : _item$onHeaderCell.call(item, column)),
          width,
          onResize: resizeHandlerGetter(index)
        };
      };
      return {
        ...item,
        width,
        onHeaderCell: columnResizable ? resizeOnHeaderCell : item.onHeaderCell
      };
    });
  }, [counter.columnsMap, tableColumn, resizeHandlerGetter, columnWidth, columnResizable]);

  // ---------- 列计算相关 end-----------------

  /** 同步 Pagination，支持受控的 页码 和 pageSize */
  (0, _utils.useDeepCompareEffect)(() => {
    const {
      pageInfo
    } = action;
    const {
      current = pageInfo.current,
      pageSize = pageInfo.pageSize
    } = propsPagination || {};
    if (propsPagination && (current || pageSize) && (pageSize !== pageInfo.pageSize || current !== pageInfo.current)) {
      action.setPageInfo({
        pageSize: pageSize || pageInfo.pageSize,
        current: current || pageInfo.current
      });
    }
  }, [propsPagination && propsPagination.pageSize, propsPagination && propsPagination.current]);

  /** 行选择相关的问题 */
  const rowSelection = {
    selectedRowKeys,
    ...propsRowSelection,
    onChange: (keys, rows, info) => {
      if (propsRowSelection && propsRowSelection.onChange) {
        propsRowSelection.onChange(keys, rows, info);
      }
      setSelectedRowsAndKey(keys, rows);
    }
  };
  /** 查询表单相关的配置 */
  const searchNode = (0, _react.useMemo)(() => {
    if (search === false && type !== 'form') {
      return null;
    }
    const onSubmit = (value, firstLoad) => {
      if (type !== 'form') {
        // 只传入 pagination 中的 current 和 pageSize 参数
        const pageInfo = pagination ? (0, _utils.omitUndefined)({
          current: pagination.current,
          pageSize: pagination.pageSize
        }) : {};
        const submitParams = {
          ...value,
          _timestamp: Date.now(),
          ...pageInfo
        };
        const omitParams = (0, _omit.default)(beforeSearchSubmit(submitParams), Object.keys(pageInfo));
        setFormSearch(omitParams);
        if (!firstLoad) {
          // back first page
          action.setPageInfo({
            current: 1
          });
        }
      }
      // 不是第一次提交就不触发，第一次提交是 js 触发的
      // 为了解决 https://github.com/ant-design/pro-components/issues/579
      if (props.onSubmit && !firstLoad) {
        props.onSubmit(value);
      }
    };
    const onReset = value => {
      var _props$onReset;
      const pageInfo = pagination ? (0, _utils.omitUndefined)({
        current: pagination.current,
        pageSize: pagination.pageSize
      }) : {};
      const omitParams = (0, _omit.default)(beforeSearchSubmit({
        ...value,
        ...pageInfo
      }), Object.keys(pageInfo));
      setFormSearch(omitParams);
      // back first page
      action.setPageInfo({
        current: 1
      });
      (_props$onReset = props.onReset) === null || _props$onReset === void 0 ? void 0 : _props$onReset.call(props);
    };
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormSearch.default, {
      submitButtonLoading: !!action.loading,
      columns: propsColumns,
      type: type,
      formRef: formRef,
      onSubmit: onSubmit,
      manualRequest: manualRequest,
      onReset: onReset,
      dateFormatter: rest.dateFormatter,
      search: search,
      form: rest.form,
      bordered: isBordered('search', cardBordered)
    });
  }, [action, beforeSearchSubmit, cardBordered, formRef, manualRequest, pagination, props, propsColumns, rest.dateFormatter, rest.form, search, setFormSearch, type]);

  // 用于缓存 onChange 以及 pagination.onChange 的参数
  const argsRef = (0, _react.useRef)([]);

  /** 是不是 LightFilter, LightFilter 有一些特殊的处理 */
  const isLightFilter = search !== false && (search === null || search === void 0 ? void 0 : search.filterType) === 'light';

  // eslint-disable-next-line react-hooks/exhaustive-deps
  const lightForm = (0, _react.useMemo)(() => isLightFilter ? searchNode : null, [isLightFilter, searchNode]);
  const className = (0, _classnames.default)(defaultClassName, propsClassName);
  const toolbarDom = (0, _react.useMemo)(() => {
    // 不展示 toolbar
    if (toolBarRender === false) {
      return null;
    }
    if (options === false && !headerTitle && !toolBarRender && !toolbar && !isLightFilter) {
      return null;
    }
    /** 根据表单类型的不同决定是否生成 toolbarProps */
    const toolbarProps = isLightFilter ? {
      filter: lightForm,
      ...toolbar
    } : toolbar;
    const onSearch = keyword => {
      if (!options || !options.search) {
        return;
      }
      const {
        name = 'keyword'
      } = options.search === true ? {} : options.search;

      // 查询的时候的回到第一页
      action.setPageInfo({
        current: 1
      });
      setFormSearch((0, _utils.omitUndefined)({
        ...formSearch,
        _timestamp: Date.now(),
        [name]: keyword
      }));
    };
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToolBar.default, {
      columns: tableColumn,
      options: options,
      headerTitle: headerTitle,
      action: actionRef,
      onSearch: onSearch,
      selectedRows: selectedRows,
      selectedRowKeys: selectedRowKeys,
      toolBarRender: toolBarRender,
      toolbar: toolbarProps
    });
  }, [action, formSearch, headerTitle, isLightFilter, lightForm, options, selectedRowKeys, selectedRows, setFormSearch, tableColumn, toolBarRender, toolbar]);

  /** 内置的多选操作栏 */
  const alertDom = propsRowSelection !== false && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
    selectedRowKeys: selectedRowKeys,
    selectedRows: selectedRows,
    onCleanSelected: onCleanSelected,
    alertOptionRender: rest.tableAlertOptionRender,
    alertInfoRender: tableAlertRender
  });

  /** 如果所有列中的 filters=true| undefined 说明是用的是本地筛选 任何一列配置 filters=false，就能绕过这个判断 */
  const useLocaleFilter = propsColumns.every(column => column.filters === true && column.onFilter === true || column.filters === undefined && column.onFilter === undefined);
  const editableDataSource = () => {
    const {
      options: newLineOptions,
      defaultValue: row
    } = editableUtils.newLineRecord || {};
    if ((newLineOptions === null || newLineOptions === void 0 ? void 0 : newLineOptions.position) === 'top') {
      return [row, ...action.dataSource];
    }
    // 如果有分页的功能，我们加到这一页的末尾
    if (pagination && pagination !== null && pagination !== void 0 && pagination.current && pagination !== null && pagination !== void 0 && pagination.pageSize) {
      return [...action.dataSource].splice((pagination === null || pagination === void 0 ? void 0 : pagination.current) * (pagination === null || pagination === void 0 ? void 0 : pagination.pageSize) - 1, 0, row);
    }
    return [...action.dataSource, row];
  };
  const tableComponents = (0, _react.useMemo)(() => {
    return {
      ...components,
      header: {
        ...(components === null || components === void 0 ? void 0 : components.header),
        cell: columnResizable ? _ResizableTitle.default : undefined
      }
    };
  }, [columnResizable, components]);
  const getTableProps = () => ({
    ...rest,
    size: counter.tableSize,
    rowSelection: propsRowSelection === false ? undefined : rowSelection,
    className: tableClassName,
    style: tableStyle,
    columns,
    loading: action.loading,
    dataSource: editableUtils.newLineRecord ? editableDataSource() : action.dataSource,
    pagination,
    onChange: (changePagination, filters, sorter, extra) => {
      argsRef.current = [changePagination, filters, sorter, extra];
      if (onChange) {
        onChange(changePagination, filters, sorter, extra);
      }
      if (!useLocaleFilter) {
        setProFilter((0, _utils.omitUndefined)(filters));
      }

      // 制造筛选的数据
      // 制造一个排序的数据
      if (Array.isArray(sorter)) {
        const data = sorter.reduce((pre, value) => ({
          ...pre,
          [`${value.field}`]: value.order
        }), {});
        setProSort((0, _utils.omitUndefined)(data));
      } else {
        setProSort((0, _utils.omitUndefined)({
          [`${sorter.field}`]: sorter.order
        }));
      }
    },
    components: tableComponents
  });

  /** 如果有 ellipsis ，设置 tableLayout 为 fixed */
  const tableLayout = (_props$columns = props.columns) !== null && _props$columns !== void 0 && _props$columns.some(item => item.ellipsis) ? 'fixed' : 'auto';

  /** 默认的 table dom，如果是编辑模式，外面还要包个 form */
  const baseTableDom = action.dataSource !== undefined || manualRequest ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_form.default, {
    component: false,
    form: (_props$editable2 = props.editable) === null || _props$editable2 === void 0 ? void 0 : _props$editable2.form,
    onValuesChange: editableUtils.onValuesChange,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_table.default, {
      ...getTableProps(),
      rowKey: rowKey,
      tableLayout: tableLayout
    })
  }, "table") : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    style: {
      display: 'flex',
      justifyContent: 'center',
      alignItems: 'center',
      padding: 50
    },
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_spin.default, {
      size: "large"
    })
  });

  /** 自定义的 render */
  const tableDom = props.tableViewRender ? props.tableViewRender({
    ...getTableProps(),
    rowSelection
  }, baseTableDom) : baseTableDom;

  /** Table 区域的 dom，为了方便 render */
  const tableAreaDom = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
    children: [ghostToolbar ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: `${getPrefixCls('pro-table')}-ghost-toolbar`,
      children: toolbarDom
    }) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_card.default, {
      bordered: isBordered('table', cardBordered),
      style: {
        height: '100%'
      },
      bodyStyle: {
        paddingTop: ghostToolbar || searchNode && !toolbarDom ? undefined : 0,
        paddingBottom: pagination === false ? undefined : 0
      },
      ...cardProps,
      children: [!ghostToolbar ? toolbarDom : null, alertDom, tableDom]
    })]
  });
  const renderTable = () => {
    if (props.tableRender) {
      return props.tableRender(props, tableAreaDom, {
        toolbar: toolbarDom || undefined,
        alert: alertDom || undefined,
        table: tableDom || undefined
      });
    }
    return tableAreaDom;
  };
  const proTableDom = /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
    className: (0, _classnames.default)(className, {
      [`${className}-polling`]: action.pollingLoading
    }),
    id: "ant-design-pro-table",
    style: style,
    ref: rootRef,
    children: [isLightFilter ? null : searchNode, type !== 'form' && props.tableExtraRender && action.dataSource && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: `${className}-extra`,
      children: props.tableExtraRender(props, action.dataSource)
    }), type !== 'form' && renderTable()]
  });

  // 如果不需要的全屏，ConfigProvider 没有意义
  if (!options || !(options !== null && options !== void 0 && options.fullScreen)) {
    return proTableDom;
  }
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_configProvider.default, {
    getPopupContainer: () => rootRef.current || document.body,
    children: proTableDom
  });
};

/**
 * 🏆 Use Ant Design Table like a Pro! 更快 更好 更方便
 *
 * @param props
 */
const WauTable = props => {
  const {
    getPrefixCls
  } = (0, _react.useContext)(_configProvider.default.ConfigContext);
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_container.default.Provider, {
    initialState: props,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_wauProvider.ConfigProviderWrap, {
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_wauErrorBoundary.default, {
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ProTable, {
          defaultClassName: getPrefixCls('pro-table'),
          ...props
        })
      })
    })
  });
};
WauTable.TableDropdown = _Dropdown.default;
WauTable.ListToolBar = _ListToolBar.default;
WauTable.FormSearch = _FormSearch.default;
var _default = WauTable;
exports.default = _default;