1 |
- {"ast":null,"code":"import { useContext } from '@rc-component/context';\nimport * as React from 'react';\nimport PerfContext from \"../context/PerfContext\";\nimport TableContext, { responseImmutable } from \"../context/TableContext\";\nimport useFlattenRecords from \"../hooks/useFlattenRecords\";\nimport devRenderTimes from \"../hooks/useRenderTimes\";\nimport { getColumnsKey } from \"../utils/valueUtil\";\nimport BodyRow from \"./BodyRow\";\nimport ExpandedRow from \"./ExpandedRow\";\nimport MeasureRow from \"./MeasureRow\";\nfunction Body(props) {\n if (process.env.NODE_ENV !== 'production') {\n devRenderTimes(props);\n }\n var data = props.data,\n measureColumnWidth = props.measureColumnWidth;\n var _useContext = useContext(TableContext, ['prefixCls', 'getComponent', 'onColumnResize', 'flattenColumns', 'getRowKey', 'expandedKeys', 'childrenColumnName', 'emptyNode', 'expandedRowOffset', 'fixedInfoList', 'colWidths']),\n prefixCls = _useContext.prefixCls,\n getComponent = _useContext.getComponent,\n onColumnResize = _useContext.onColumnResize,\n flattenColumns = _useContext.flattenColumns,\n getRowKey = _useContext.getRowKey,\n expandedKeys = _useContext.expandedKeys,\n childrenColumnName = _useContext.childrenColumnName,\n emptyNode = _useContext.emptyNode,\n _useContext$expandedR = _useContext.expandedRowOffset,\n expandedRowOffset = _useContext$expandedR === void 0 ? 0 : _useContext$expandedR,\n colWidths = _useContext.colWidths;\n var flattenData = useFlattenRecords(data, childrenColumnName, expandedKeys, getRowKey);\n var rowKeys = React.useMemo(function () {\n return flattenData.map(function (item) {\n return item.rowKey;\n });\n }, [flattenData]);\n\n // =================== Performance ====================\n var perfRef = React.useRef({\n renderWithProps: false\n });\n\n // ===================== Expanded =====================\n // `expandedRowOffset` data is same for all the rows.\n // Let's calc on Body side to save performance.\n var expandedRowInfo = React.useMemo(function () {\n var expandedColSpan = flattenColumns.length - expandedRowOffset;\n var expandedStickyStart = 0;\n for (var i = 0; i < expandedRowOffset; i += 1) {\n expandedStickyStart += colWidths[i] || 0;\n }\n return {\n offset: expandedRowOffset,\n colSpan: expandedColSpan,\n sticky: expandedStickyStart\n };\n }, [flattenColumns.length, expandedRowOffset, colWidths]);\n\n // ====================== Render ======================\n var WrapperComponent = getComponent(['body', 'wrapper'], 'tbody');\n var trComponent = getComponent(['body', 'row'], 'tr');\n var tdComponent = getComponent(['body', 'cell'], 'td');\n var thComponent = getComponent(['body', 'cell'], 'th');\n var rows;\n if (data.length) {\n rows = flattenData.map(function (item, idx) {\n var record = item.record,\n indent = item.indent,\n renderIndex = item.index,\n rowKey = item.rowKey;\n return /*#__PURE__*/React.createElement(BodyRow, {\n key: rowKey,\n rowKey: rowKey,\n rowKeys: rowKeys,\n record: record,\n index: idx,\n renderIndex: renderIndex,\n rowComponent: trComponent,\n cellComponent: tdComponent,\n scopeCellComponent: thComponent,\n indent: indent\n // Expanded row info\n ,\n\n expandedRowInfo: expandedRowInfo\n });\n });\n } else {\n rows = /*#__PURE__*/React.createElement(ExpandedRow, {\n expanded: true,\n className: \"\".concat(prefixCls, \"-placeholder\"),\n prefixCls: prefixCls,\n component: trComponent,\n cellComponent: tdComponent,\n colSpan: flattenColumns.length,\n isEmpty: true\n }, emptyNode);\n }\n var columnsKey = getColumnsKey(flattenColumns);\n return /*#__PURE__*/React.createElement(PerfContext.Provider, {\n value: perfRef.current\n }, /*#__PURE__*/React.createElement(WrapperComponent, {\n className: \"\".concat(prefixCls, \"-tbody\")\n }, measureColumnWidth && /*#__PURE__*/React.createElement(MeasureRow, {\n prefixCls: prefixCls,\n columnsKey: columnsKey,\n onColumnResize: onColumnResize,\n columns: flattenColumns\n }), rows));\n}\nif (process.env.NODE_ENV !== 'production') {\n Body.displayName = 'Body';\n}\nexport default responseImmutable(Body);","map":{"version":3,"names":["useContext","React","PerfContext","TableContext","responseImmutable","useFlattenRecords","devRenderTimes","getColumnsKey","BodyRow","ExpandedRow","MeasureRow","Body","props","process","env","NODE_ENV","data","measureColumnWidth","_useContext","prefixCls","getComponent","onColumnResize","flattenColumns","getRowKey","expandedKeys","childrenColumnName","emptyNode","_useContext$expandedR","expandedRowOffset","colWidths","flattenData","rowKeys","useMemo","map","item","rowKey","perfRef","useRef","renderWithProps","expandedRowInfo","expandedColSpan","length","expandedStickyStart","i","offset","colSpan","sticky","WrapperComponent","trComponent","tdComponent","thComponent","rows","idx","record","indent","renderIndex","index","createElement","key","rowComponent","cellComponent","scopeCellComponent","expanded","className","concat","component","isEmpty","columnsKey","Provider","value","current","columns","displayName"],"sources":["/Users/max_liu/max_liu/company/tools_auto_pt/node_modules/rc-table/es/Body/index.js"],"sourcesContent":["import { useContext } from '@rc-component/context';\nimport * as React from 'react';\nimport PerfContext from \"../context/PerfContext\";\nimport TableContext, { responseImmutable } from \"../context/TableContext\";\nimport useFlattenRecords from \"../hooks/useFlattenRecords\";\nimport devRenderTimes from \"../hooks/useRenderTimes\";\nimport { getColumnsKey } from \"../utils/valueUtil\";\nimport BodyRow from \"./BodyRow\";\nimport ExpandedRow from \"./ExpandedRow\";\nimport MeasureRow from \"./MeasureRow\";\nfunction Body(props) {\n if (process.env.NODE_ENV !== 'production') {\n devRenderTimes(props);\n }\n var data = props.data,\n measureColumnWidth = props.measureColumnWidth;\n var _useContext = useContext(TableContext, ['prefixCls', 'getComponent', 'onColumnResize', 'flattenColumns', 'getRowKey', 'expandedKeys', 'childrenColumnName', 'emptyNode', 'expandedRowOffset', 'fixedInfoList', 'colWidths']),\n prefixCls = _useContext.prefixCls,\n getComponent = _useContext.getComponent,\n onColumnResize = _useContext.onColumnResize,\n flattenColumns = _useContext.flattenColumns,\n getRowKey = _useContext.getRowKey,\n expandedKeys = _useContext.expandedKeys,\n childrenColumnName = _useContext.childrenColumnName,\n emptyNode = _useContext.emptyNode,\n _useContext$expandedR = _useContext.expandedRowOffset,\n expandedRowOffset = _useContext$expandedR === void 0 ? 0 : _useContext$expandedR,\n colWidths = _useContext.colWidths;\n var flattenData = useFlattenRecords(data, childrenColumnName, expandedKeys, getRowKey);\n var rowKeys = React.useMemo(function () {\n return flattenData.map(function (item) {\n return item.rowKey;\n });\n }, [flattenData]);\n\n // =================== Performance ====================\n var perfRef = React.useRef({\n renderWithProps: false\n });\n\n // ===================== Expanded =====================\n // `expandedRowOffset` data is same for all the rows.\n // Let's calc on Body side to save performance.\n var expandedRowInfo = React.useMemo(function () {\n var expandedColSpan = flattenColumns.length - expandedRowOffset;\n var expandedStickyStart = 0;\n for (var i = 0; i < expandedRowOffset; i += 1) {\n expandedStickyStart += colWidths[i] || 0;\n }\n return {\n offset: expandedRowOffset,\n colSpan: expandedColSpan,\n sticky: expandedStickyStart\n };\n }, [flattenColumns.length, expandedRowOffset, colWidths]);\n\n // ====================== Render ======================\n var WrapperComponent = getComponent(['body', 'wrapper'], 'tbody');\n var trComponent = getComponent(['body', 'row'], 'tr');\n var tdComponent = getComponent(['body', 'cell'], 'td');\n var thComponent = getComponent(['body', 'cell'], 'th');\n var rows;\n if (data.length) {\n rows = flattenData.map(function (item, idx) {\n var record = item.record,\n indent = item.indent,\n renderIndex = item.index,\n rowKey = item.rowKey;\n return /*#__PURE__*/React.createElement(BodyRow, {\n key: rowKey,\n rowKey: rowKey,\n rowKeys: rowKeys,\n record: record,\n index: idx,\n renderIndex: renderIndex,\n rowComponent: trComponent,\n cellComponent: tdComponent,\n scopeCellComponent: thComponent,\n indent: indent\n // Expanded row info\n ,\n expandedRowInfo: expandedRowInfo\n });\n });\n } else {\n rows = /*#__PURE__*/React.createElement(ExpandedRow, {\n expanded: true,\n className: \"\".concat(prefixCls, \"-placeholder\"),\n prefixCls: prefixCls,\n component: trComponent,\n cellComponent: tdComponent,\n colSpan: flattenColumns.length,\n isEmpty: true\n }, emptyNode);\n }\n var columnsKey = getColumnsKey(flattenColumns);\n return /*#__PURE__*/React.createElement(PerfContext.Provider, {\n value: perfRef.current\n }, /*#__PURE__*/React.createElement(WrapperComponent, {\n className: \"\".concat(prefixCls, \"-tbody\")\n }, measureColumnWidth && /*#__PURE__*/React.createElement(MeasureRow, {\n prefixCls: prefixCls,\n columnsKey: columnsKey,\n onColumnResize: onColumnResize,\n columns: flattenColumns\n }), rows));\n}\nif (process.env.NODE_ENV !== 'production') {\n Body.displayName = 'Body';\n}\nexport default responseImmutable(Body);"],"mappings":"AAAA,SAASA,UAAU,QAAQ,uBAAuB;AAClD,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,OAAOC,WAAW,MAAM,wBAAwB;AAChD,OAAOC,YAAY,IAAIC,iBAAiB,QAAQ,yBAAyB;AACzE,OAAOC,iBAAiB,MAAM,4BAA4B;AAC1D,OAAOC,cAAc,MAAM,yBAAyB;AACpD,SAASC,aAAa,QAAQ,oBAAoB;AAClD,OAAOC,OAAO,MAAM,WAAW;AAC/B,OAAOC,WAAW,MAAM,eAAe;AACvC,OAAOC,UAAU,MAAM,cAAc;AACrC,SAASC,IAAIA,CAACC,KAAK,EAAE;EACnB,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzCT,cAAc,CAACM,KAAK,CAAC;EACvB;EACA,IAAII,IAAI,GAAGJ,KAAK,CAACI,IAAI;IACnBC,kBAAkB,GAAGL,KAAK,CAACK,kBAAkB;EAC/C,IAAIC,WAAW,GAAGlB,UAAU,CAACG,YAAY,EAAE,CAAC,WAAW,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,cAAc,EAAE,oBAAoB,EAAE,WAAW,EAAE,mBAAmB,EAAE,eAAe,EAAE,WAAW,CAAC,CAAC;IAC9NgB,SAAS,GAAGD,WAAW,CAACC,SAAS;IACjCC,YAAY,GAAGF,WAAW,CAACE,YAAY;IACvCC,cAAc,GAAGH,WAAW,CAACG,cAAc;IAC3CC,cAAc,GAAGJ,WAAW,CAACI,cAAc;IAC3CC,SAAS,GAAGL,WAAW,CAACK,SAAS;IACjCC,YAAY,GAAGN,WAAW,CAACM,YAAY;IACvCC,kBAAkB,GAAGP,WAAW,CAACO,kBAAkB;IACnDC,SAAS,GAAGR,WAAW,CAACQ,SAAS;IACjCC,qBAAqB,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