1 line
30 KiB
JSON
1 line
30 KiB
JSON
|
{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nvar _excluded = [\"children\"],\n _excluded2 = [\"fixed\"];\nimport toArray from \"rc-util/es/Children/toArray\";\nimport warning from \"rc-util/es/warning\";\nimport * as React from 'react';\nimport { EXPAND_COLUMN } from \"../../constant\";\nimport { INTERNAL_COL_DEFINE } from \"../../utils/legacyUtil\";\nimport useWidthColumns from \"./useWidthColumns\";\nexport function convertChildrenToColumns(children) {\n return toArray(children).filter(function (node) {\n return /*#__PURE__*/React.isValidElement(node);\n }).map(function (_ref) {\n var key = _ref.key,\n props = _ref.props;\n var nodeChildren = props.children,\n restProps = _objectWithoutProperties(props, _excluded);\n var column = _objectSpread({\n key: key\n }, restProps);\n if (nodeChildren) {\n column.children = convertChildrenToColumns(nodeChildren);\n }\n return column;\n });\n}\nfunction filterHiddenColumns(columns) {\n return columns.filter(function (column) {\n return column && _typeof(column) === 'object' && !column.hidden;\n }).map(function (column) {\n var subColumns = column.children;\n if (subColumns && subColumns.length > 0) {\n return _objectSpread(_objectSpread({}, column), {}, {\n children: filterHiddenColumns(subColumns)\n });\n }\n return column;\n });\n}\nfunction flatColumns(columns) {\n var parentKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key';\n return columns.filter(function (column) {\n return column && _typeof(column) === 'object';\n }).reduce(function (list, column, index) {\n var fixed = column.fixed;\n // Convert `fixed='true'` to `fixed='left'` instead\n var parsedFixed = fixed === true ? 'left' : fixed;\n var mergedKey = \"\".concat(parentKey, \"-\").concat(index);\n var subColumns = column.children;\n if (subColumns && subColumns.length > 0) {\n return [].concat(_toConsumableArray(list), _toConsumableArray(flatColumns(subColumns, mergedKey).map(function (subColum) {\n return _objectSpread({\n fixed: parsedFixed\n }, subColum);\n })));\n }\n return [].concat(_toConsumableArray(list), [_objectSpread(_objectSpread({\n key: mergedKey\n }, column), {}, {\n fixed: parsedFixed\n })]);\n }, []);\n}\nfunction revertForRtl(columns) {\n return columns.map(function (column) {\n var fixed = column.fixed,\n restProps = _objectWithoutProperties(column, _excluded2);\n\n // Convert `fixed='left'` to `fixed='right'` instead\n var parsedFixed = fixed;\n if (fixed === 'left') {\n parsedFixed = 'right';\n } else if (fixed === 'right') {\n parsedFixed = 'left';\n }\n return _objectSpread({\n fixed: parsedFixed\n }, restProps);\n });\n}\n\n/**\n * Parse `columns` & `children` into `columns`.\n */\nfunction useColumns(_ref2, transformColumns) {\n var prefixCls = _ref2.prefixCls,\n columns = _ref2.columns,\n children = _ref2.children,\n expandable = _ref2.expandable,\n expandedKeys = _ref2.expandedKeys,\n columnTitle = _ref2.columnTitle,\n getRowKey = _ref2.getRowKey,\n onTriggerExpand = _ref2.onTriggerExpand,\n expandIcon = _ref2.expandIcon,\n rowExpandable = _ref2.rowExpandable,\n expandIconColumnIndex = _ref2.expandIconColumnIndex,\n direction = _ref2.direction,\n expandRowByClick = _ref2.expandRowByClick,\n columnWidth = _ref2.columnWidth,\n fixed = _ref2.fixed,\n scrollWidth = _ref2.scrollWidth,\n clientWidth = _ref2.clientWidth;\n var baseColumns = React.useMemo(function () {\n var newColumns
|