cb23897ecefefdc5218783ef8edad18c.json
12.3 KB
{"ast":null,"code":"import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport * as React from 'react';\nimport toArray from \"rc-util/es/Children/toArray\";\nimport warning from \"rc-util/es/warning\";\nimport TreeNode from '../TreeNode';\nexport function convertChildrenToData(nodes) {\n return toArray(nodes).map(function (node) {\n if (! /*#__PURE__*/React.isValidElement(node) || !node.type) {\n return null;\n }\n\n var key = node.key,\n _node$props = node.props,\n children = _node$props.children,\n value = _node$props.value,\n restProps = _objectWithoutProperties(_node$props, [\"children\", \"value\"]);\n\n var data = _objectSpread({\n key: key,\n value: value\n }, restProps);\n\n var childData = convertChildrenToData(children);\n\n if (childData.length) {\n data.children = childData;\n }\n\n return data;\n }).filter(function (data) {\n return data;\n });\n}\nexport function fillLegacyProps(dataNode) {\n // Skip if not dataNode exist\n if (!dataNode) {\n return dataNode;\n }\n\n var cloneNode = _objectSpread({}, dataNode);\n\n if (!('props' in cloneNode)) {\n Object.defineProperty(cloneNode, 'props', {\n get: function get() {\n warning(false, 'New `rc-tree-select` not support return node instance as argument anymore. Please consider to remove `props` access.');\n return cloneNode;\n }\n });\n }\n\n return cloneNode;\n}\nexport function fillAdditionalInfo(extra, triggerValue, checkedValues, treeData, showPosition) {\n var triggerNode = null;\n var nodeList = null;\n\n function generateMap() {\n function dig(list) {\n var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0';\n var parentIncluded = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n return list.map(function (dataNode, index) {\n var pos = \"\".concat(level, \"-\").concat(index);\n var included = checkedValues.includes(dataNode.value);\n var children = dig(dataNode.children || [], pos, included);\n var node = /*#__PURE__*/React.createElement(TreeNode, Object.assign({}, dataNode), children.map(function (child) {\n return child.node;\n })); // Link with trigger node\n\n if (triggerValue === dataNode.value) {\n triggerNode = node;\n }\n\n if (included) {\n var checkedNode = {\n pos: pos,\n node: node,\n children: children\n };\n\n if (!parentIncluded) {\n nodeList.push(checkedNode);\n }\n\n return checkedNode;\n }\n\n return null;\n }).filter(function (node) {\n return node;\n });\n }\n\n if (!nodeList) {\n nodeList = [];\n dig(treeData); // Sort to keep the checked node length\n\n nodeList.sort(function (_ref, _ref2) {\n var val1 = _ref.node.props.value;\n var val2 = _ref2.node.props.value;\n var index1 = checkedValues.indexOf(val1);\n var index2 = checkedValues.indexOf(val2);\n return index1 - index2;\n });\n }\n }\n\n Object.defineProperty(extra, 'triggerNode', {\n get: function get() {\n warning(false, '`triggerNode` is deprecated. Please consider decoupling data with node.');\n generateMap();\n return triggerNode;\n }\n });\n Object.defineProperty(extra, 'allCheckedNodes', {\n get: function get() {\n warning(false, '`allCheckedNodes` is deprecated. Please consider decoupling data with node.');\n generateMap();\n\n if (showPosition) {\n return nodeList;\n }\n\n return nodeList.map(function (_ref3) {\n var node = _ref3.node;\n return node;\n });\n }\n });\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-tree-select/es/utils/legacyUtil.js"],"names":["_objectSpread","_objectWithoutProperties","React","toArray","warning","TreeNode","convertChildrenToData","nodes","map","node","isValidElement","type","key","_node$props","props","children","value","restProps","data","childData","length","filter","fillLegacyProps","dataNode","cloneNode","Object","defineProperty","get","fillAdditionalInfo","extra","triggerValue","checkedValues","treeData","showPosition","triggerNode","nodeList","generateMap","dig","list","level","arguments","undefined","parentIncluded","index","pos","concat","included","includes","createElement","assign","child","checkedNode","push","sort","_ref","_ref2","val1","val2","index1","indexOf","index2","_ref3"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,0CAA1B;AACA,OAAOC,wBAAP,MAAqC,oDAArC;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC,OAAP,MAAoB,6BAApB;AACA,OAAOC,OAAP,MAAoB,oBAApB;AACA,OAAOC,QAAP,MAAqB,aAArB;AACA,OAAO,SAASC,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ASA,GAAT,GAAe;AAClBvB,MAAAA,OAAO,CAAC,KAAD,EAAQ,yEAAR,CAAP;AACAgC,MAAAA,WAAW;AACX,aAAOF,WAAP;AACD;AALyC,GAA5C;AAOAT,EAAAA,MAAM,CAACC,cAAP,CAAsBG,KAAtB,EAA6B,iBAA7B,EAAgD;AAC9CF,IAAAA,GAAG,EAAE,SAASA,GAAT,GAAe;AAClBvB,MAAAA,OAAO,CAAC,KAAD,EAAQ,6EAAR,CAAP;AACAgC,MAAAA,WAAW;;AAEX,UAAIH,YAAJ,EAAkB;AAChB,eAAOE,QAAP;AACD;;AAED,aAAOA,QAAQ,CAAC3B,GAAT,CAAa,UAAUqD,KAAV,EAAiB;AACnC,YAAIpD,IAAI,GAAGoD,KAAK,CAACpD,IAAjB;AACA,eAAOA,IAAP;AACD,OAHM,CAAP;AAID;AAb6C,GAAhD;AAeD","sourcesContent":["import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport * as React from 'react';\nimport toArray from \"rc-util/es/Children/toArray\";\nimport warning from \"rc-util/es/warning\";\nimport TreeNode from '../TreeNode';\nexport function convertChildrenToData(nodes) {\n return toArray(nodes).map(function (node) {\n if (! /*#__PURE__*/React.isValidElement(node) || !node.type) {\n return null;\n }\n\n var key = node.key,\n _node$props = node.props,\n children = _node$props.children,\n value = _node$props.value,\n restProps = _objectWithoutProperties(_node$props, [\"children\", \"value\"]);\n\n var data = _objectSpread({\n key: key,\n value: value\n }, restProps);\n\n var childData = convertChildrenToData(children);\n\n if (childData.length) {\n data.children = childData;\n }\n\n return data;\n }).filter(function (data) {\n return data;\n });\n}\nexport function fillLegacyProps(dataNode) {\n // Skip if not dataNode exist\n if (!dataNode) {\n return dataNode;\n }\n\n var cloneNode = _objectSpread({}, dataNode);\n\n if (!('props' in cloneNode)) {\n Object.defineProperty(cloneNode, 'props', {\n get: function get() {\n warning(false, 'New `rc-tree-select` not support return node instance as argument anymore. Please consider to remove `props` access.');\n return cloneNode;\n }\n });\n }\n\n return cloneNode;\n}\nexport function fillAdditionalInfo(extra, triggerValue, checkedValues, treeData, showPosition) {\n var triggerNode = null;\n var nodeList = null;\n\n function generateMap() {\n function dig(list) {\n var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0';\n var parentIncluded = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n return list.map(function (dataNode, index) {\n var pos = \"\".concat(level, \"-\").concat(index);\n var included = checkedValues.includes(dataNode.value);\n var children = dig(dataNode.children || [], pos, included);\n var node = /*#__PURE__*/React.createElement(TreeNode, Object.assign({}, dataNode), children.map(function (child) {\n return child.node;\n })); // Link with trigger node\n\n if (triggerValue === dataNode.value) {\n triggerNode = node;\n }\n\n if (included) {\n var checkedNode = {\n pos: pos,\n node: node,\n children: children\n };\n\n if (!parentIncluded) {\n nodeList.push(checkedNode);\n }\n\n return checkedNode;\n }\n\n return null;\n }).filter(function (node) {\n return node;\n });\n }\n\n if (!nodeList) {\n nodeList = [];\n dig(treeData); // Sort to keep the checked node length\n\n nodeList.sort(function (_ref, _ref2) {\n var val1 = _ref.node.props.value;\n var val2 = _ref2.node.props.value;\n var index1 = checkedValues.indexOf(val1);\n var index2 = checkedValues.indexOf(val2);\n return index1 - index2;\n });\n }\n }\n\n Object.defineProperty(extra, 'triggerNode', {\n get: function get() {\n warning(false, '`triggerNode` is deprecated. Please consider decoupling data with node.');\n generateMap();\n return triggerNode;\n }\n });\n Object.defineProperty(extra, 'allCheckedNodes', {\n get: function get() {\n warning(false, '`allCheckedNodes` is deprecated. Please consider decoupling data with node.');\n generateMap();\n\n if (showPosition) {\n return nodeList;\n }\n\n return nodeList.map(function (_ref3) {\n var node = _ref3.node;\n return node;\n });\n }\n });\n}"]},"metadata":{},"sourceType":"module"}