772e945b315c1b5b7a004f5eef53f060.json
19.8 KB
{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport * as React from 'react';\nimport warning from \"rc-util/es/warning\";\nimport toArray from \"rc-util/es/Children/toArray\";\nimport { INTERNAL_COL_DEFINE } from '../utils/legacyUtil';\nexport function convertChildrenToColumns(children) {\n return toArray(children).filter(function (node) {\n return React.isValidElement(node);\n }).map(function (_ref) {\n var key = _ref.key,\n props = _ref.props;\n\n var nodeChildren = props.children,\n restProps = _objectWithoutProperties(props, [\"children\"]);\n\n var column = _objectSpread({\n key: key\n }, restProps);\n\n if (nodeChildren) {\n column.children = convertChildrenToColumns(nodeChildren);\n }\n\n return column;\n });\n}\n\nfunction flatColumns(columns) {\n return columns.reduce(function (list, column) {\n var fixed = column.fixed; // Convert `fixed='true'` to `fixed='left'` instead\n\n var parsedFixed = fixed === true ? 'left' : fixed;\n var subColumns = column.children;\n\n if (subColumns && subColumns.length > 0) {\n return [].concat(_toConsumableArray(list), _toConsumableArray(flatColumns(subColumns).map(function (subColum) {\n return _objectSpread({\n fixed: parsedFixed\n }, subColum);\n })));\n }\n\n return [].concat(_toConsumableArray(list), [_objectSpread(_objectSpread({}, column), {}, {\n fixed: parsedFixed\n })]);\n }, []);\n}\n\nfunction warningFixed(flattenColumns) {\n var allFixLeft = true;\n\n for (var i = 0; i < flattenColumns.length; i += 1) {\n var col = flattenColumns[i];\n\n if (allFixLeft && col.fixed !== 'left') {\n allFixLeft = false;\n } else if (!allFixLeft && col.fixed === 'left') {\n warning(false, \"Index \".concat(i - 1, \" of `columns` missing `fixed='left'` prop.\"));\n break;\n }\n }\n\n var allFixRight = true;\n\n for (var _i = flattenColumns.length - 1; _i >= 0; _i -= 1) {\n var _col = flattenColumns[_i];\n\n if (allFixRight && _col.fixed !== 'right') {\n allFixRight = false;\n } else if (!allFixRight && _col.fixed === 'right') {\n warning(false, \"Index \".concat(_i + 1, \" of `columns` missing `fixed='right'` prop.\"));\n break;\n }\n }\n}\n\nfunction revertForRtl(columns) {\n return columns.map(function (column) {\n var fixed = column.fixed,\n restProps = _objectWithoutProperties(column, [\"fixed\"]); // Convert `fixed='left'` to `fixed='right'` instead\n\n\n var parsedFixed = fixed;\n\n if (fixed === 'left') {\n parsedFixed = 'right';\n } else if (fixed === 'right') {\n parsedFixed = 'left';\n }\n\n return _objectSpread({\n fixed: parsedFixed\n }, restProps);\n });\n}\n/**\n * Parse `columns` & `children` into `columns`.\n */\n\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 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 var baseColumns = React.useMemo(function () {\n return columns || convertChildrenToColumns(children);\n }, [columns, children]); // Add expand column\n\n var withExpandColumns = React.useMemo(function () {\n if (expandable) {\n var _expandColumn;\n\n var expandColIndex = expandIconColumnIndex || 0;\n var prevColumn = baseColumns[expandColIndex];\n var expandColumn = (_expandColumn = {}, _defineProperty(_expandColumn, INTERNAL_COL_DEFINE, {\n className: \"\".concat(prefixCls, \"-expand-icon-col\")\n }), _defineProperty(_expandColumn, \"title\", ''), _defineProperty(_expandColumn, \"fixed\", prevColumn ? prevColumn.fixed : null), _defineProperty(_expandColumn, \"className\", \"\".concat(prefixCls, \"-row-expand-icon-cell\")), _defineProperty(_expandColumn, \"render\", function render(_, record, index) {\n var rowKey = getRowKey(record, index);\n var expanded = expandedKeys.has(rowKey);\n var recordExpandable = rowExpandable ? rowExpandable(record) : true;\n var icon = expandIcon({\n prefixCls: prefixCls,\n expanded: expanded,\n expandable: recordExpandable,\n record: record,\n onExpand: onTriggerExpand\n });\n\n if (expandRowByClick) {\n return React.createElement(\"span\", {\n onClick: function onClick(e) {\n return e.stopPropagation();\n }\n }, icon);\n }\n\n return icon;\n }), _expandColumn); // Insert expand column in the target position\n\n var cloneColumns = baseColumns.slice();\n\n if (expandColIndex >= 0) {\n cloneColumns.splice(expandColIndex, 0, expandColumn);\n }\n\n return cloneColumns;\n }\n\n return baseColumns;\n }, [expandable, baseColumns, getRowKey, expandedKeys, expandIcon, direction]);\n var mergedColumns = React.useMemo(function () {\n var finalColumns = withExpandColumns;\n\n if (transformColumns) {\n finalColumns = transformColumns(finalColumns);\n } // Always provides at least one column for table display\n\n\n if (!finalColumns.length) {\n finalColumns = [{\n render: function render() {\n return null;\n }\n }];\n }\n\n return finalColumns;\n }, [transformColumns, withExpandColumns, direction]);\n var flattenColumns = React.useMemo(function () {\n if (direction === 'rtl') {\n return revertForRtl(flatColumns(mergedColumns));\n }\n\n return flatColumns(mergedColumns);\n }, [mergedColumns, direction]); // Only check out of production since it's waste for each render\n\n if (process.env.NODE_ENV !== 'production') {\n warningFixed(flattenColumns);\n }\n\n return [mergedColumns, flattenColumns];\n}\n\nexport default useColumns;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-table/es/hooks/useColumns.js"],"names":["_defineProperty","_toConsumableArray","_objectSpread","_objectWithoutProperties","React","warning","toArray","INTERNAL_COL_DEFINE","convertChildrenToColumns","children","filter","node","isValidElement","map","_ref","key","props","nodeChildren","restProps","column","flatColumns","columns","reduce","list","fixed","parsedFixed","subColumns","length","concat","subColum","warningFixed","flattenColumns","allFixLeft","i","col","allFixRight","_i","_col","revertForRtl","useColumns","_ref2","transformColumns","prefixCls","expandable","expandedKeys","getRowKey","onTriggerExpand","expandIcon","rowExpandable","expandIconColumnIndex","direction","expandRowByClick","baseColumns","useMemo","withExpandColumns","_expandColumn","expandColIndex","prevColumn","expandColumn","className","render","_","record","index","rowKey","expanded","has","recordExpandable","icon","onExpand","createElement","onClick","e","stopPropagation","cloneColumns","slice","splice","mergedColumns","finalColumns","process","env","NODE_ENV"],"mappings":"AAAA,OAAOA,eAAP,MAA4B,2CAA5B;AACA,OAAOC,kBAAP,MAA+B,8CAA/B;AACA,OAAOC,aAAP,MAA0B,0CAA1B;AACA,OAAOC,wBAAP,MAAqC,oDAArC;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC,OAAP,MAAoB,oBAApB;AACA,OAAOC,OAAP,MAAoB,6BAApB;AACA,SAASC,mBAAT,QAAoC,qBAApC;AACA,OAAO,SAASC,wBAAT,CAAkCC,QAAlC,EAA4C;AACjD,SAAOH,OAAO,CAACG,QAAD,CAAP,CAAkBC,MAAlB,CAAyB,UAAUC,IAAV,EAAgB;AAC9C,WAAOP,KAAK,CAACQ,cAAN,CAAqBD,IAArB,CAAP;AACD,GAFM,EAEJE,GAFI,CAEA,UAAUC,IAAV,EAAgB;AACrB,QAAIC,GAAG,GAAGD,IAAI,CAACC,GAAf;AAAA,QACIC,KAAK,GAAGF,IAAI,CAACE,KADjB;;AAGA,QAAIC,YAAY,GAAGD,KAAK,CAACP,QAAzB;AAAA,QACIS,SAAS,GAAGf,wBAAwB,CAACa,KAAD,EAAQ,CAAC,UAAD,CAAR,CADxC;;AAGA,QAAIG,MAAM,GAAGjB,aAAa,CAAC;AACzBa,MAAAA,GAAG,EAAEA;AADoB,KAAD,EAEvBG,SAFuB,CAA1B;;AAIA,QAAID,YAAJ,EAAkB;AAChBE,MAAAA,MAAM,CAACV,QAAP,GAAkBD,wBAAwB,CAACS,YAAD,CAA1C;AACD;;AAED,WAAOE,MAAP;AACD,GAlBM,CAAP;AAmBD;;AAED,SAASC,WAAT,CAAqBC,OAArB,EAA8B;AAC5B,SAAOA,OAAO,CAACC,MAAR,CAA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/helpers/esm/defineProperty\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport * as React from 'react';\nimport warning from \"rc-util/es/warning\";\nimport toArray from \"rc-util/es/Children/toArray\";\nimport { INTERNAL_COL_DEFINE } from '../utils/legacyUtil';\nexport function convertChildrenToColumns(children) {\n return toArray(children).filter(function (node) {\n return React.isValidElement(node);\n }).map(function (_ref) {\n var key = _ref.key,\n props = _ref.props;\n\n var nodeChildren = props.children,\n restProps = _objectWithoutProperties(props, [\"children\"]);\n\n var column = _objectSpread({\n key: key\n }, restProps);\n\n if (nodeChildren) {\n column.children = convertChildrenToColumns(nodeChildren);\n }\n\n return column;\n });\n}\n\nfunction flatColumns(columns) {\n return columns.reduce(function (list, column) {\n var fixed = column.fixed; // Convert `fixed='true'` to `fixed='left'` instead\n\n var parsedFixed = fixed === true ? 'left' : fixed;\n var subColumns = column.children;\n\n if (subColumns && subColumns.length > 0) {\n return [].concat(_toConsumableArray(list), _toConsumableArray(flatColumns(subColumns).map(function (subColum) {\n return _objectSpread({\n fixed: parsedFixed\n }, subColum);\n })));\n }\n\n return [].concat(_toConsumableArray(list), [_objectSpread(_objectSpread({}, column), {}, {\n fixed: parsedFixed\n })]);\n }, []);\n}\n\nfunction warningFixed(flattenColumns) {\n var allFixLeft = true;\n\n for (var i = 0; i < flattenColumns.length; i += 1) {\n var col = flattenColumns[i];\n\n if (allFixLeft && col.fixed !== 'left') {\n allFixLeft = false;\n } else if (!allFixLeft && col.fixed === 'left') {\n warning(false, \"Index \".concat(i - 1, \" of `columns` missing `fixed='left'` prop.\"));\n break;\n }\n }\n\n var allFixRight = true;\n\n for (var _i = flattenColumns.length - 1; _i >= 0; _i -= 1) {\n var _col = flattenColumns[_i];\n\n if (allFixRight && _col.fixed !== 'right') {\n allFixRight = false;\n } else if (!allFixRight && _col.fixed === 'right') {\n warning(false, \"Index \".concat(_i + 1, \" of `columns` missing `fixed='right'` prop.\"));\n break;\n }\n }\n}\n\nfunction revertForRtl(columns) {\n return columns.map(function (column) {\n var fixed = column.fixed,\n restProps = _objectWithoutProperties(column, [\"fixed\"]); // Convert `fixed='left'` to `fixed='right'` instead\n\n\n var parsedFixed = fixed;\n\n if (fixed === 'left') {\n parsedFixed = 'right';\n } else if (fixed === 'right') {\n parsedFixed = 'left';\n }\n\n return _objectSpread({\n fixed: parsedFixed\n }, restProps);\n });\n}\n/**\n * Parse `columns` & `children` into `columns`.\n */\n\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 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 var baseColumns = React.useMemo(function () {\n return columns || convertChildrenToColumns(children);\n }, [columns, children]); // Add expand column\n\n var withExpandColumns = React.useMemo(function () {\n if (expandable) {\n var _expandColumn;\n\n var expandColIndex = expandIconColumnIndex || 0;\n var prevColumn = baseColumns[expandColIndex];\n var expandColumn = (_expandColumn = {}, _defineProperty(_expandColumn, INTERNAL_COL_DEFINE, {\n className: \"\".concat(prefixCls, \"-expand-icon-col\")\n }), _defineProperty(_expandColumn, \"title\", ''), _defineProperty(_expandColumn, \"fixed\", prevColumn ? prevColumn.fixed : null), _defineProperty(_expandColumn, \"className\", \"\".concat(prefixCls, \"-row-expand-icon-cell\")), _defineProperty(_expandColumn, \"render\", function render(_, record, index) {\n var rowKey = getRowKey(record, index);\n var expanded = expandedKeys.has(rowKey);\n var recordExpandable = rowExpandable ? rowExpandable(record) : true;\n var icon = expandIcon({\n prefixCls: prefixCls,\n expanded: expanded,\n expandable: recordExpandable,\n record: record,\n onExpand: onTriggerExpand\n });\n\n if (expandRowByClick) {\n return React.createElement(\"span\", {\n onClick: function onClick(e) {\n return e.stopPropagation();\n }\n }, icon);\n }\n\n return icon;\n }), _expandColumn); // Insert expand column in the target position\n\n var cloneColumns = baseColumns.slice();\n\n if (expandColIndex >= 0) {\n cloneColumns.splice(expandColIndex, 0, expandColumn);\n }\n\n return cloneColumns;\n }\n\n return baseColumns;\n }, [expandable, baseColumns, getRowKey, expandedKeys, expandIcon, direction]);\n var mergedColumns = React.useMemo(function () {\n var finalColumns = withExpandColumns;\n\n if (transformColumns) {\n finalColumns = transformColumns(finalColumns);\n } // Always provides at least one column for table display\n\n\n if (!finalColumns.length) {\n finalColumns = [{\n render: function render() {\n return null;\n }\n }];\n }\n\n return finalColumns;\n }, [transformColumns, withExpandColumns, direction]);\n var flattenColumns = React.useMemo(function () {\n if (direction === 'rtl') {\n return revertForRtl(flatColumns(mergedColumns));\n }\n\n return flatColumns(mergedColumns);\n }, [mergedColumns, direction]); // Only check out of production since it's waste for each render\n\n if (process.env.NODE_ENV !== 'production') {\n warningFixed(flattenColumns);\n }\n\n return [mergedColumns, flattenColumns];\n}\n\nexport default useColumns;"]},"metadata":{},"sourceType":"module"}