"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
exports.useContainer = useContainer;
require("core-js/modules/es.array.iterator.js");
require("core-js/modules/web.dom-collections.iterator.js");
var _unstatedNext = require("unstated-next");
var _react = require("react");
var _useMergedState = _interopRequireDefault(require("rc-util/es/hooks/useMergedState"));
function useContainer(props = {}) {
  const actionRef = (0, _react.useRef)();
  const propsRef = (0, _react.useRef)();

  // 共享状态比较难，就放到这里了
  const [keyWords, setKeyWords] = (0, _react.useState)('');
  // 用于排序的数组
  const sortKeyColumns = (0, _react.useRef)([]);
  const [tableSize, setTableSize] = (0, _useMergedState.default)(props.size || 'large', {
    value: props.size,
    onChange: props.onSizeChange
  });
  const [columnsMap, setColumnsMap] = (0, _useMergedState.default)(props.columnsStateMap || {}, {
    value: props.columnsStateMap,
    onChange: props.onColumnsStateChange
  });
  return {
    action: actionRef,
    setAction: newAction => {
      actionRef.current = newAction;
    },
    sortKeyColumns,
    setSortKeyColumns: keys => {
      sortKeyColumns.current = keys;
    },
    propsRef,
    columnsMap,
    keyWords,
    setKeyWords: k => setKeyWords(k),
    setTableSize,
    tableSize,
    setColumnsMap
  };
}
const Container = (0, _unstatedNext.createContainer)(useContainer);
var _default = Container;
exports.default = _default;