5ae97bd2cd05de27a86c6ece8251f44e.json
22.9 KB
{"ast":null,"code":"import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport Cell from '../Cell';\nimport TableContext from '../context/TableContext';\nimport BodyContext from '../context/BodyContext';\nimport { getColumnsKey } from '../utils/valueUtil';\nimport ExpandedRow from './ExpandedRow';\n\nfunction BodyRow(props) {\n var className = props.className,\n style = props.style,\n record = props.record,\n index = props.index,\n rowKey = props.rowKey,\n getRowKey = props.getRowKey,\n rowExpandable = props.rowExpandable,\n expandedKeys = props.expandedKeys,\n onRow = props.onRow,\n _props$indent = props.indent,\n indent = _props$indent === void 0 ? 0 : _props$indent,\n RowComponent = props.rowComponent,\n cellComponent = props.cellComponent,\n childrenColumnName = props.childrenColumnName;\n\n var _React$useContext = React.useContext(TableContext),\n prefixCls = _React$useContext.prefixCls,\n fixedInfoList = _React$useContext.fixedInfoList;\n\n var _React$useContext2 = React.useContext(BodyContext),\n fixHeader = _React$useContext2.fixHeader,\n fixColumn = _React$useContext2.fixColumn,\n horizonScroll = _React$useContext2.horizonScroll,\n componentWidth = _React$useContext2.componentWidth,\n flattenColumns = _React$useContext2.flattenColumns,\n expandableType = _React$useContext2.expandableType,\n expandRowByClick = _React$useContext2.expandRowByClick,\n onTriggerExpand = _React$useContext2.onTriggerExpand,\n rowClassName = _React$useContext2.rowClassName,\n expandedRowClassName = _React$useContext2.expandedRowClassName,\n indentSize = _React$useContext2.indentSize,\n expandIcon = _React$useContext2.expandIcon,\n expandedRowRender = _React$useContext2.expandedRowRender,\n expandIconColumnIndex = _React$useContext2.expandIconColumnIndex;\n\n var _React$useState = React.useState(false),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n expandRended = _React$useState2[0],\n setExpandRended = _React$useState2[1];\n\n var expanded = expandedKeys && expandedKeys.has(props.recordKey);\n React.useEffect(function () {\n if (expanded) {\n setExpandRended(true);\n }\n }, [expanded]);\n var rowSupportExpand = expandableType === 'row' && (!rowExpandable || rowExpandable(record)); // Only when row is not expandable and `children` exist in record\n\n var nestExpandable = expandableType === 'nest';\n var hasNestChildren = childrenColumnName && record && record[childrenColumnName];\n var mergedExpandable = rowSupportExpand || nestExpandable; // =========================== onRow ===========================\n\n var additionalProps;\n\n if (onRow) {\n additionalProps = onRow(record, index);\n }\n\n var onClick = function onClick(event) {\n if (expandRowByClick && mergedExpandable) {\n onTriggerExpand(record, event);\n }\n\n if (additionalProps && additionalProps.onClick) {\n var _additionalProps;\n\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n (_additionalProps = additionalProps).onClick.apply(_additionalProps, [event].concat(args));\n }\n }; // ======================== Base tr row ========================\n\n\n var computeRowClassName;\n\n if (typeof rowClassName === 'string') {\n computeRowClassName = rowClassName;\n } else if (typeof rowClassName === 'function') {\n computeRowClassName = rowClassName(record, index, indent);\n }\n\n var columnsKey = getColumnsKey(flattenColumns);\n var baseRowNode = React.createElement(RowComponent, Object.assign({}, additionalProps, {\n \"data-row-key\": rowKey,\n className: classNames(className, \"\".concat(prefixCls, \"-row\"), \"\".concat(prefixCls, \"-row-level-\").concat(indent), computeRowClassName, additionalProps && additionalProps.className),\n style: _objectSpread(_objectSpread({}, style), additionalProps ? additionalProps.style : null),\n onClick: onClick\n }), flattenColumns.map(function (column, colIndex) {\n var render = column.render,\n dataIndex = column.dataIndex,\n columnClassName = column.className;\n var key = columnsKey[colIndex];\n var fixedInfo = fixedInfoList[colIndex]; // ============= Used for nest expandable =============\n\n var appendCellNode;\n\n if (colIndex === (expandIconColumnIndex || 0) && nestExpandable) {\n appendCellNode = React.createElement(React.Fragment, null, React.createElement(\"span\", {\n style: {\n paddingLeft: \"\".concat(indentSize * indent, \"px\")\n },\n className: \"\".concat(prefixCls, \"-row-indent indent-level-\").concat(indent)\n }), expandIcon({\n prefixCls: prefixCls,\n expanded: expanded,\n expandable: hasNestChildren,\n record: record,\n onExpand: onTriggerExpand\n }));\n }\n\n var additionalCellProps;\n\n if (column.onCell) {\n additionalCellProps = column.onCell(record, index);\n }\n\n return React.createElement(Cell, Object.assign({\n className: columnClassName,\n ellipsis: column.ellipsis,\n align: column.align,\n component: cellComponent,\n prefixCls: prefixCls,\n key: key,\n record: record,\n index: index,\n dataIndex: dataIndex,\n render: render,\n shouldCellUpdate: column.shouldCellUpdate\n }, fixedInfo, {\n appendNode: appendCellNode,\n additionalProps: additionalCellProps\n }));\n })); // ======================== Expand Row =========================\n\n var expandRowNode;\n\n if (rowSupportExpand && (expandRended || expanded)) {\n var expandContent = expandedRowRender(record, index, indent + 1, expanded);\n var computedExpandedRowClassName = expandedRowClassName && expandedRowClassName(record, index, indent);\n expandRowNode = React.createElement(ExpandedRow, {\n expanded: expanded,\n className: classNames(\"\".concat(prefixCls, \"-expanded-row\"), \"\".concat(prefixCls, \"-expanded-row-level-\").concat(indent + 1), computedExpandedRowClassName),\n prefixCls: prefixCls,\n fixHeader: fixHeader,\n fixColumn: fixColumn,\n horizonScroll: horizonScroll,\n component: RowComponent,\n componentWidth: componentWidth,\n cellComponent: cellComponent,\n colSpan: flattenColumns.length\n }, expandContent);\n } // ========================= Nest Row ==========================\n\n\n var nestRowNode;\n\n if (hasNestChildren && expanded) {\n nestRowNode = (record[childrenColumnName] || []).map(function (subRecord, subIndex) {\n var subKey = getRowKey(subRecord, subIndex);\n return React.createElement(BodyRow, Object.assign({}, props, {\n key: subKey,\n rowKey: subKey,\n record: subRecord,\n recordKey: subKey,\n index: subIndex,\n indent: indent + 1\n }));\n });\n }\n\n return React.createElement(React.Fragment, null, baseRowNode, expandRowNode, nestRowNode);\n}\n\nBodyRow.displayName = 'BodyRow';\nexport default BodyRow;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-table/es/Body/BodyRow.js"],"names":["_objectSpread","_slicedToArray","React","classNames","Cell","TableContext","BodyContext","getColumnsKey","ExpandedRow","BodyRow","props","className","style","record","index","rowKey","getRowKey","rowExpandable","expandedKeys","onRow","_props$indent","indent","RowComponent","rowComponent","cellComponent","childrenColumnName","_React$useContext","useContext","prefixCls","fixedInfoList","_React$useContext2","fixHeader","fixColumn","horizonScroll","componentWidth","flattenColumns","expandableType","expandRowByClick","onTriggerExpand","rowClassName","expandedRowClassName","indentSize","expandIcon","expandedRowRender","expandIconColumnIndex","_React$useState","useState","_React$useState2","expandRended","setExpandRended","expanded","has","recordKey","useEffect","rowSupportExpand","nestExpandable","hasNestChildren","mergedExpandable","additionalProps","onClick","event","_additionalProps","_len","arguments","length","args","Array","_key","apply","concat","computeRowClassName","columnsKey","baseRowNode","createElement","Object","assign","map","column","colIndex","render","dataIndex","columnClassName","key","fixedInfo","appendCellNode","Fragment","paddingLeft","expandable","onExpand","additionalCellProps","onCell","ellipsis","align","component","shouldCellUpdate","appendNode","expandRowNode","expandContent","computedExpandedRowClassName","colSpan","nestRowNode","subRecord","subIndex","subKey","displayName"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,0CAA1B;AACA,OAAOC,cAAP,MAA2B,0CAA3B;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,IAAP,MAAiB,SAAjB;AACA,OAAOC,YAAP,MAAyB,yBAAzB;AACA,OAAOC,WAAP,MAAwB,wBAAxB;AACA,SAASC,aAAT,QAA8B,oBAA9B;AACA,OAAOC,WAAP,MAAwB,eAAxB;;AAEA,SAASC,OAAT,CAAiBC,KAAjB,EAAwB;AACtB,MAAIC,SAAS,GAAGD,KAAK,CAACC,SAAtB;AAAA,MACIC,KAAK,GAAGF,KAAK,CAACE,KADlB;AAAA,MAEIC,MAAM,GAAGH,KAAK,CAACG,MAFnB;AAAA,MAGIC,KAAK,GAAGJ,KAAK,CAACI,KAHlB;AAAA,MAIIC,MAAM,GAAGL,K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HmD;AAI3DjD,QAAAA,SAAS,EAAEmD,MAJgD;AAK3DzF,QAAAA,KAAK,EAAEwF,QALoD;AAM3DjF,QAAAA,MAAM,EAAEA,MAAM,GAAG;AAN0C,OAAzB,CAA7B,CAAP;AAQD,KAVa,CAAd;AAWD;;AAED,SAAOnB,KAAK,CAACuE,aAAN,CAAoBvE,KAAK,CAACmF,QAA1B,EAAoC,IAApC,EAA0Cb,WAA1C,EAAuDwB,aAAvD,EAAsEI,WAAtE,CAAP;AACD;;AAED3F,OAAO,CAAC+F,WAAR,GAAsB,SAAtB;AACA,eAAe/F,OAAf","sourcesContent":["import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport Cell from '../Cell';\nimport TableContext from '../context/TableContext';\nimport BodyContext from '../context/BodyContext';\nimport { getColumnsKey } from '../utils/valueUtil';\nimport ExpandedRow from './ExpandedRow';\n\nfunction BodyRow(props) {\n var className = props.className,\n style = props.style,\n record = props.record,\n index = props.index,\n rowKey = props.rowKey,\n getRowKey = props.getRowKey,\n rowExpandable = props.rowExpandable,\n expandedKeys = props.expandedKeys,\n onRow = props.onRow,\n _props$indent = props.indent,\n indent = _props$indent === void 0 ? 0 : _props$indent,\n RowComponent = props.rowComponent,\n cellComponent = props.cellComponent,\n childrenColumnName = props.childrenColumnName;\n\n var _React$useContext = React.useContext(TableContext),\n prefixCls = _React$useContext.prefixCls,\n fixedInfoList = _React$useContext.fixedInfoList;\n\n var _React$useContext2 = React.useContext(BodyContext),\n fixHeader = _React$useContext2.fixHeader,\n fixColumn = _React$useContext2.fixColumn,\n horizonScroll = _React$useContext2.horizonScroll,\n componentWidth = _React$useContext2.componentWidth,\n flattenColumns = _React$useContext2.flattenColumns,\n expandableType = _React$useContext2.expandableType,\n expandRowByClick = _React$useContext2.expandRowByClick,\n onTriggerExpand = _React$useContext2.onTriggerExpand,\n rowClassName = _React$useContext2.rowClassName,\n expandedRowClassName = _React$useContext2.expandedRowClassName,\n indentSize = _React$useContext2.indentSize,\n expandIcon = _React$useContext2.expandIcon,\n expandedRowRender = _React$useContext2.expandedRowRender,\n expandIconColumnIndex = _React$useContext2.expandIconColumnIndex;\n\n var _React$useState = React.useState(false),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n expandRended = _React$useState2[0],\n setExpandRended = _React$useState2[1];\n\n var expanded = expandedKeys && expandedKeys.has(props.recordKey);\n React.useEffect(function () {\n if (expanded) {\n setExpandRended(true);\n }\n }, [expanded]);\n var rowSupportExpand = expandableType === 'row' && (!rowExpandable || rowExpandable(record)); // Only when row is not expandable and `children` exist in record\n\n var nestExpandable = expandableType === 'nest';\n var hasNestChildren = childrenColumnName && record && record[childrenColumnName];\n var mergedExpandable = rowSupportExpand || nestExpandable; // =========================== onRow ===========================\n\n var additionalProps;\n\n if (onRow) {\n additionalProps = onRow(record, index);\n }\n\n var onClick = function onClick(event) {\n if (expandRowByClick && mergedExpandable) {\n onTriggerExpand(record, event);\n }\n\n if (additionalProps && additionalProps.onClick) {\n var _additionalProps;\n\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n (_additionalProps = additionalProps).onClick.apply(_additionalProps, [event].concat(args));\n }\n }; // ======================== Base tr row ========================\n\n\n var computeRowClassName;\n\n if (typeof rowClassName === 'string') {\n computeRowClassName = rowClassName;\n } else if (typeof rowClassName === 'function') {\n computeRowClassName = rowClassName(record, index, indent);\n }\n\n var columnsKey = getColumnsKey(flattenColumns);\n var baseRowNode = React.createElement(RowComponent, Object.assign({}, additionalProps, {\n \"data-row-key\": rowKey,\n className: classNames(className, \"\".concat(prefixCls, \"-row\"), \"\".concat(prefixCls, \"-row-level-\").concat(indent), computeRowClassName, additionalProps && additionalProps.className),\n style: _objectSpread(_objectSpread({}, style), additionalProps ? additionalProps.style : null),\n onClick: onClick\n }), flattenColumns.map(function (column, colIndex) {\n var render = column.render,\n dataIndex = column.dataIndex,\n columnClassName = column.className;\n var key = columnsKey[colIndex];\n var fixedInfo = fixedInfoList[colIndex]; // ============= Used for nest expandable =============\n\n var appendCellNode;\n\n if (colIndex === (expandIconColumnIndex || 0) && nestExpandable) {\n appendCellNode = React.createElement(React.Fragment, null, React.createElement(\"span\", {\n style: {\n paddingLeft: \"\".concat(indentSize * indent, \"px\")\n },\n className: \"\".concat(prefixCls, \"-row-indent indent-level-\").concat(indent)\n }), expandIcon({\n prefixCls: prefixCls,\n expanded: expanded,\n expandable: hasNestChildren,\n record: record,\n onExpand: onTriggerExpand\n }));\n }\n\n var additionalCellProps;\n\n if (column.onCell) {\n additionalCellProps = column.onCell(record, index);\n }\n\n return React.createElement(Cell, Object.assign({\n className: columnClassName,\n ellipsis: column.ellipsis,\n align: column.align,\n component: cellComponent,\n prefixCls: prefixCls,\n key: key,\n record: record,\n index: index,\n dataIndex: dataIndex,\n render: render,\n shouldCellUpdate: column.shouldCellUpdate\n }, fixedInfo, {\n appendNode: appendCellNode,\n additionalProps: additionalCellProps\n }));\n })); // ======================== Expand Row =========================\n\n var expandRowNode;\n\n if (rowSupportExpand && (expandRended || expanded)) {\n var expandContent = expandedRowRender(record, index, indent + 1, expanded);\n var computedExpandedRowClassName = expandedRowClassName && expandedRowClassName(record, index, indent);\n expandRowNode = React.createElement(ExpandedRow, {\n expanded: expanded,\n className: classNames(\"\".concat(prefixCls, \"-expanded-row\"), \"\".concat(prefixCls, \"-expanded-row-level-\").concat(indent + 1), computedExpandedRowClassName),\n prefixCls: prefixCls,\n fixHeader: fixHeader,\n fixColumn: fixColumn,\n horizonScroll: horizonScroll,\n component: RowComponent,\n componentWidth: componentWidth,\n cellComponent: cellComponent,\n colSpan: flattenColumns.length\n }, expandContent);\n } // ========================= Nest Row ==========================\n\n\n var nestRowNode;\n\n if (hasNestChildren && expanded) {\n nestRowNode = (record[childrenColumnName] || []).map(function (subRecord, subIndex) {\n var subKey = getRowKey(subRecord, subIndex);\n return React.createElement(BodyRow, Object.assign({}, props, {\n key: subKey,\n rowKey: subKey,\n record: subRecord,\n recordKey: subKey,\n index: subIndex,\n indent: indent + 1\n }));\n });\n }\n\n return React.createElement(React.Fragment, null, baseRowNode, expandRowNode, nestRowNode);\n}\n\nBodyRow.displayName = 'BodyRow';\nexport default BodyRow;"]},"metadata":{},"sourceType":"module"}