PromoCursed/node_modules/.cache/babel-loader/93b478bd4a6d51feb4b51d3d805e87e23496dfc666e1fa4c402ffbdfbb6db55c.json

1 line
28 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"import _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport { useContext } from '@rc-component/context';\nimport classNames from 'classnames';\nimport VirtualList from 'rc-virtual-list';\nimport * as React from 'react';\nimport Cell from \"../Cell\";\nimport TableContext, { responseImmutable } from \"../context/TableContext\";\nimport useFlattenRecords from \"../hooks/useFlattenRecords\";\nimport BodyLine from \"./BodyLine\";\nimport { GridContext, StaticContext } from \"./context\";\nvar Grid = /*#__PURE__*/React.forwardRef(function (props, ref) {\n var data = props.data,\n onScroll = props.onScroll;\n var _useContext = useContext(TableContext, ['flattenColumns', 'onColumnResize', 'getRowKey', 'prefixCls', 'expandedKeys', 'childrenColumnName', 'emptyNode', 'scrollX']),\n flattenColumns = _useContext.flattenColumns,\n onColumnResize = _useContext.onColumnResize,\n getRowKey = _useContext.getRowKey,\n expandedKeys = _useContext.expandedKeys,\n prefixCls = _useContext.prefixCls,\n childrenColumnName = _useContext.childrenColumnName,\n emptyNode = _useContext.emptyNode,\n scrollX = _useContext.scrollX;\n var _useContext2 = useContext(StaticContext),\n sticky = _useContext2.sticky,\n scrollY = _useContext2.scrollY,\n listItemHeight = _useContext2.listItemHeight,\n getComponent = _useContext2.getComponent,\n onTablePropScroll = _useContext2.onScroll;\n\n // =========================== Ref ============================\n var listRef = React.useRef();\n\n // =========================== Data ===========================\n var flattenData = useFlattenRecords(data, childrenColumnName, expandedKeys, getRowKey);\n\n // ========================== Column ==========================\n var columnsWidth = React.useMemo(function () {\n var total = 0;\n return flattenColumns.map(function (_ref) {\n var width = _ref.width,\n key = _ref.key;\n total += width;\n return [key, width, total];\n });\n }, [flattenColumns]);\n var columnsOffset = React.useMemo(function () {\n return columnsWidth.map(function (colWidth) {\n return colWidth[2];\n });\n }, [columnsWidth]);\n React.useEffect(function () {\n columnsWidth.forEach(function (_ref2) {\n var _ref3 = _slicedToArray(_ref2, 2),\n key = _ref3[0],\n width = _ref3[1];\n onColumnResize(key, width);\n });\n }, [columnsWidth]);\n\n // =========================== Ref ============================\n React.useImperativeHandle(ref, function () {\n var obj = {\n scrollTo: function scrollTo(config) {\n var _listRef$current;\n (_listRef$current = listRef.current) === null || _listRef$current === void 0 || _listRef$current.scrollTo(config);\n }\n };\n Object.defineProperty(obj, 'scrollLeft', {\n get: function get() {\n var _listRef$current2;\n return ((_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 ? void 0 : _listRef$current2.getScrollInfo().x) || 0;\n },\n set: function set(value) {\n var _listRef$current3;\n (_listRef$current3 = listRef.current) === null || _listRef$current3 === void 0 || _listRef$current3.scrollTo({\n left: value\n });\n }\n });\n return obj;\n });\n\n // ======================= Col/Row Span =======================\n var getRowSpan = function getRowSpan(column, index) {\n var _flattenData$index;\n var record = (_flattenData$index = flattenData[index]) === null || _flattenData$index === void 0 ? void 0 : _flattenData$index.record;\n var onCell = column.onCell;\n if (onCell) {\n var _cellProps$rowSpan;\n var cellProps = onCell(record, index);\n return (_cellProps$rowSpan = cellProps === null || cellProps === void 0 ? void 0 : cellProps.rowSpan) !== null && _cellProps$rowSpan !== void 0 ? _cellProps$rowSpan : 1;\n }\n return 1;\n };\n var extraRender = function extraRender(info) {\n var start =