6ab5db961407b9f24cf467fe4a93d3c1.json 10.8 KB
{"ast":null,"code":"import * as React from 'react';\nimport BodyRow from './BodyRow';\nimport TableContext from '../context/TableContext';\nimport ExpandedRow from './ExpandedRow';\nimport BodyContext from '../context/BodyContext';\nimport { getColumnsKey } from '../utils/valueUtil';\nimport ResizeContext from '../context/ResizeContext';\nimport MeasureCell from './MeasureCell';\n\nfunction Body(_ref) {\n  var data = _ref.data,\n      getRowKey = _ref.getRowKey,\n      measureColumnWidth = _ref.measureColumnWidth,\n      expandedKeys = _ref.expandedKeys,\n      onRow = _ref.onRow,\n      rowExpandable = _ref.rowExpandable,\n      emptyNode = _ref.emptyNode,\n      childrenColumnName = _ref.childrenColumnName;\n\n  var _React$useContext = React.useContext(ResizeContext),\n      onColumnResize = _React$useContext.onColumnResize;\n\n  var _React$useContext2 = React.useContext(TableContext),\n      prefixCls = _React$useContext2.prefixCls,\n      getComponent = _React$useContext2.getComponent;\n\n  var _React$useContext3 = React.useContext(BodyContext),\n      fixHeader = _React$useContext3.fixHeader,\n      horizonScroll = _React$useContext3.horizonScroll,\n      flattenColumns = _React$useContext3.flattenColumns,\n      componentWidth = _React$useContext3.componentWidth;\n\n  return React.useMemo(function () {\n    var WrapperComponent = getComponent(['body', 'wrapper'], 'tbody');\n    var trComponent = getComponent(['body', 'row'], 'tr');\n    var tdComponent = getComponent(['body', 'cell'], 'td');\n    var rows;\n\n    if (data.length) {\n      rows = data.map(function (record, index) {\n        var key = getRowKey(record, index);\n        return React.createElement(BodyRow, {\n          key: key,\n          rowKey: key,\n          record: record,\n          recordKey: key,\n          index: index,\n          rowComponent: trComponent,\n          cellComponent: tdComponent,\n          expandedKeys: expandedKeys,\n          onRow: onRow,\n          getRowKey: getRowKey,\n          rowExpandable: rowExpandable,\n          childrenColumnName: childrenColumnName\n        });\n      });\n    } else {\n      rows = React.createElement(ExpandedRow, {\n        expanded: true,\n        className: \"\".concat(prefixCls, \"-placeholder\"),\n        prefixCls: prefixCls,\n        fixHeader: fixHeader,\n        fixColumn: horizonScroll,\n        horizonScroll: horizonScroll,\n        component: trComponent,\n        componentWidth: componentWidth,\n        cellComponent: tdComponent,\n        colSpan: flattenColumns.length\n      }, emptyNode);\n    }\n\n    var columnsKey = getColumnsKey(flattenColumns);\n    return React.createElement(WrapperComponent, {\n      className: \"\".concat(prefixCls, \"-tbody\")\n    }, measureColumnWidth && React.createElement(\"tr\", {\n      \"aria-hidden\": \"true\",\n      className: \"\".concat(prefixCls, \"-measure-row\"),\n      style: {\n        height: 0,\n        fontSize: 0\n      }\n    }, columnsKey.map(function (columnKey) {\n      return React.createElement(MeasureCell, {\n        key: columnKey,\n        columnKey: columnKey,\n        onColumnResize: onColumnResize\n      });\n    })), rows);\n  }, [data, prefixCls, onRow, measureColumnWidth, expandedKeys, getRowKey, getComponent, componentWidth, emptyNode, flattenColumns]);\n}\n\nvar MemoBody = React.memo(Body);\nMemoBody.displayName = 'Body';\nexport default MemoBody;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-table/es/Body/index.js"],"names":["React","BodyRow","TableContext","ExpandedRow","BodyContext","getColumnsKey","ResizeContext","MeasureCell","Body","_ref","data","getRowKey","measureColumnWidth","expandedKeys","onRow","rowExpandable","emptyNode","childrenColumnName","_React$useContext","useContext","onColumnResize","_React$useContext2","prefixCls","getComponent","_React$useContext3","fixHeader","horizonScroll","flattenColumns","componentWidth","useMemo","WrapperComponent","trComponent","tdComponent","rows","length","map","record","index","key","createElement","rowKey","recordKey","rowComponent","cellComponent","expanded","className","concat","fixColumn","component","colSpan","columnsKey","style","height","fontSize","columnKey","MemoBody","memo","displayName"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,OAAOC,YAAP,MAAyB,yBAAzB;AACA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,WAAP,MAAwB,wBAAxB;AACA,SAASC,aAAT,QAA8B,oB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ent":["import * as React from 'react';\nimport BodyRow from './BodyRow';\nimport TableContext from '../context/TableContext';\nimport ExpandedRow from './ExpandedRow';\nimport BodyContext from '../context/BodyContext';\nimport { getColumnsKey } from '../utils/valueUtil';\nimport ResizeContext from '../context/ResizeContext';\nimport MeasureCell from './MeasureCell';\n\nfunction Body(_ref) {\n  var data = _ref.data,\n      getRowKey = _ref.getRowKey,\n      measureColumnWidth = _ref.measureColumnWidth,\n      expandedKeys = _ref.expandedKeys,\n      onRow = _ref.onRow,\n      rowExpandable = _ref.rowExpandable,\n      emptyNode = _ref.emptyNode,\n      childrenColumnName = _ref.childrenColumnName;\n\n  var _React$useContext = React.useContext(ResizeContext),\n      onColumnResize = _React$useContext.onColumnResize;\n\n  var _React$useContext2 = React.useContext(TableContext),\n      prefixCls = _React$useContext2.prefixCls,\n      getComponent = _React$useContext2.getComponent;\n\n  var _React$useContext3 = React.useContext(BodyContext),\n      fixHeader = _React$useContext3.fixHeader,\n      horizonScroll = _React$useContext3.horizonScroll,\n      flattenColumns = _React$useContext3.flattenColumns,\n      componentWidth = _React$useContext3.componentWidth;\n\n  return React.useMemo(function () {\n    var WrapperComponent = getComponent(['body', 'wrapper'], 'tbody');\n    var trComponent = getComponent(['body', 'row'], 'tr');\n    var tdComponent = getComponent(['body', 'cell'], 'td');\n    var rows;\n\n    if (data.length) {\n      rows = data.map(function (record, index) {\n        var key = getRowKey(record, index);\n        return React.createElement(BodyRow, {\n          key: key,\n          rowKey: key,\n          record: record,\n          recordKey: key,\n          index: index,\n          rowComponent: trComponent,\n          cellComponent: tdComponent,\n          expandedKeys: expandedKeys,\n          onRow: onRow,\n          getRowKey: getRowKey,\n          rowExpandable: rowExpandable,\n          childrenColumnName: childrenColumnName\n        });\n      });\n    } else {\n      rows = React.createElement(ExpandedRow, {\n        expanded: true,\n        className: \"\".concat(prefixCls, \"-placeholder\"),\n        prefixCls: prefixCls,\n        fixHeader: fixHeader,\n        fixColumn: horizonScroll,\n        horizonScroll: horizonScroll,\n        component: trComponent,\n        componentWidth: componentWidth,\n        cellComponent: tdComponent,\n        colSpan: flattenColumns.length\n      }, emptyNode);\n    }\n\n    var columnsKey = getColumnsKey(flattenColumns);\n    return React.createElement(WrapperComponent, {\n      className: \"\".concat(prefixCls, \"-tbody\")\n    }, measureColumnWidth && React.createElement(\"tr\", {\n      \"aria-hidden\": \"true\",\n      className: \"\".concat(prefixCls, \"-measure-row\"),\n      style: {\n        height: 0,\n        fontSize: 0\n      }\n    }, columnsKey.map(function (columnKey) {\n      return React.createElement(MeasureCell, {\n        key: columnKey,\n        columnKey: columnKey,\n        onColumnResize: onColumnResize\n      });\n    })), rows);\n  }, [data, prefixCls, onRow, measureColumnWidth, expandedKeys, getRowKey, getComponent, componentWidth, emptyNode, flattenColumns]);\n}\n\nvar MemoBody = React.memo(Body);\nMemoBody.displayName = 'Body';\nexport default MemoBody;"]},"metadata":{},"sourceType":"module"}