7ea0d04b41175b8f6776049391d98f8a.json
29.4 KB
{"ast":null,"code":"import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport toArray from \"rc-util/es/Children/toArray\";\nimport warning from \"rc-util/es/warning\";\nimport { getPosition, isTreeNode } from '../util';\nexport function getKey(key, pos) {\n if (key !== null && key !== undefined) {\n return key;\n }\n\n return pos;\n}\n/**\n * Warning if TreeNode do not provides key\n */\n\nexport function warningWithoutKey() {\n var treeData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var keys = new Map();\n\n function dig(list) {\n var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';\n (list || []).forEach(function (treeNode) {\n var key = treeNode.key,\n children = treeNode.children;\n warning(key !== null && key !== undefined, \"Tree node must have a certain key: [\".concat(path).concat(key, \"]\"));\n var recordKey = String(key);\n warning(!keys.has(recordKey) || key === null || key === undefined, \"Same 'key' exist in the Tree: \".concat(recordKey));\n keys.set(recordKey, true);\n dig(children, \"\".concat(path).concat(recordKey, \" > \"));\n });\n }\n\n dig(treeData);\n}\n/**\n * Convert `children` of Tree into `treeData` structure.\n */\n\nexport function convertTreeToData(rootNodes) {\n function dig(node) {\n var treeNodes = toArray(node);\n return treeNodes.map(function (treeNode) {\n // Filter invalidate node\n if (!isTreeNode(treeNode)) {\n warning(!treeNode, 'Tree/TreeNode can only accept TreeNode as children.');\n return null;\n }\n\n var key = treeNode.key;\n\n var _treeNode$props = treeNode.props,\n children = _treeNode$props.children,\n rest = _objectWithoutProperties(_treeNode$props, [\"children\"]);\n\n var dataNode = _objectSpread({\n key: key\n }, rest);\n\n var parsedChildren = dig(children);\n\n if (parsedChildren.length) {\n dataNode.children = parsedChildren;\n }\n\n return dataNode;\n }).filter(function (dataNode) {\n return dataNode;\n });\n }\n\n return dig(rootNodes);\n}\n/**\n * Flat nest tree data into flatten list. This is used for virtual list render.\n * @param treeNodeList Origin data node list\n * @param expandedKeys\n * need expanded keys, provides `true` means all expanded (used in `rc-tree-select`).\n */\n\nexport function flattenTreeData() {\n var treeNodeList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var expandedKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n var expandedKeySet = new Set(expandedKeys === true ? [] : expandedKeys);\n var flattenList = [];\n\n function dig(list) {\n var parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n return list.map(function (treeNode, index) {\n var pos = getPosition(parent ? parent.pos : '0', index);\n var mergedKey = getKey(treeNode.key, pos); // Add FlattenDataNode into list\n\n var flattenNode = _objectSpread(_objectSpread({}, treeNode), {}, {\n parent: parent,\n pos: pos,\n children: null,\n data: treeNode,\n isStart: [].concat(_toConsumableArray(parent ? parent.isStart : []), [index === 0]),\n isEnd: [].concat(_toConsumableArray(parent ? parent.isEnd : []), [index === list.length - 1])\n });\n\n flattenList.push(flattenNode); // Loop treeNode children\n\n if (expandedKeys === true || expandedKeySet.has(mergedKey)) {\n flattenNode.children = dig(treeNode.children || [], flattenNode);\n } else {\n flattenNode.children = [];\n }\n\n return flattenNode;\n });\n }\n\n dig(treeNodeList);\n return flattenList;\n}\n/**\n * Traverse all the data by `treeData`.\n * Please not use it out of the `rc-tree` since we may refactor this code.\n */\n\nexport function traverseDataNodes(dataNodes, callback, externalGetKey) {\n var syntheticGetKey;\n\n if (externalGetKey) {\n if (typeof externalGetKey === 'string') {\n syntheticGetKey = function syntheticGetKey(node) {\n return node[externalGetKey];\n };\n } else if (typeof externalGetKey === 'function') {\n syntheticGetKey = function syntheticGetKey(node) {\n return externalGetKey(node);\n };\n }\n } else {\n syntheticGetKey = function syntheticGetKey(node, pos) {\n return getKey(node.key, pos);\n };\n }\n\n function processNode(node, index, parent) {\n var children = node ? node.children : dataNodes;\n var pos = node ? getPosition(parent.pos, index) : '0'; // Process node if is not root\n\n if (node) {\n var key = syntheticGetKey(node, pos);\n var data = {\n node: node,\n index: index,\n pos: pos,\n key: key,\n parentPos: parent.node ? parent.pos : null,\n level: parent.level + 1\n };\n callback(data);\n } // Process children node\n\n\n if (children) {\n children.forEach(function (subNode, subIndex) {\n processNode(subNode, subIndex, {\n node: node,\n pos: pos,\n level: parent ? parent.level + 1 : -1\n });\n });\n }\n }\n\n processNode(null);\n}\n/**\n * Convert `treeData` into entity records.\n */\n\nexport function convertDataToEntities(dataNodes) {\n var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},\n initWrapper = _ref.initWrapper,\n processEntity = _ref.processEntity,\n onProcessFinished = _ref.onProcessFinished;\n\n var externalGetKey = arguments.length > 2 ? arguments[2] : undefined;\n var posEntities = {};\n var keyEntities = {};\n var wrapper = {\n posEntities: posEntities,\n keyEntities: keyEntities\n };\n\n if (initWrapper) {\n wrapper = initWrapper(wrapper) || wrapper;\n }\n\n traverseDataNodes(dataNodes, function (item) {\n var node = item.node,\n index = item.index,\n pos = item.pos,\n key = item.key,\n parentPos = item.parentPos,\n level = item.level;\n var entity = {\n node: node,\n index: index,\n key: key,\n pos: pos,\n level: level\n };\n var mergedKey = getKey(key, pos);\n posEntities[pos] = entity;\n keyEntities[mergedKey] = entity; // Fill children\n\n entity.parent = posEntities[parentPos];\n\n if (entity.parent) {\n entity.parent.children = entity.parent.children || [];\n entity.parent.children.push(entity);\n }\n\n if (processEntity) {\n processEntity(entity, wrapper);\n }\n }, externalGetKey);\n\n if (onProcessFinished) {\n onProcessFinished(wrapper);\n }\n\n return wrapper;\n}\n/**\n * Get TreeNode props with Tree props.\n */\n\nexport function getTreeNodeProps(key, _ref2) {\n var expandedKeys = _ref2.expandedKeys,\n selectedKeys = _ref2.selectedKeys,\n loadedKeys = _ref2.loadedKeys,\n loadingKeys = _ref2.loadingKeys,\n checkedKeys = _ref2.checkedKeys,\n halfCheckedKeys = _ref2.halfCheckedKeys,\n dragOverNodeKey = _ref2.dragOverNodeKey,\n dropPosition = _ref2.dropPosition,\n keyEntities = _ref2.keyEntities;\n var entity = keyEntities[key];\n var treeNodeProps = {\n eventKey: key,\n expanded: expandedKeys.indexOf(key) !== -1,\n selected: selectedKeys.indexOf(key) !== -1,\n loaded: loadedKeys.indexOf(key) !== -1,\n loading: loadingKeys.indexOf(key) !== -1,\n checked: checkedKeys.indexOf(key) !== -1,\n halfChecked: halfCheckedKeys.indexOf(key) !== -1,\n pos: String(entity ? entity.pos : ''),\n // [Legacy] Drag props\n // Since the interaction of drag is changed, the semantic of the props are\n // not accuracy, I think it should be finally removed\n dragOver: dragOverNodeKey === key && dropPosition === 0,\n dragOverGapTop: dragOverNodeKey === key && dropPosition === -1,\n dragOverGapBottom: dragOverNodeKey === key && dropPosition === 1\n };\n return treeNodeProps;\n}\nexport function convertNodePropsToEventData(props) {\n var data = props.data,\n expanded = props.expanded,\n selected = props.selected,\n checked = props.checked,\n loaded = props.loaded,\n loading = props.loading,\n halfChecked = props.halfChecked,\n dragOver = props.dragOver,\n dragOverGapTop = props.dragOverGapTop,\n dragOverGapBottom = props.dragOverGapBottom,\n pos = props.pos,\n active = props.active;\n\n var eventData = _objectSpread(_objectSpread({}, data), {}, {\n expanded: expanded,\n selected: selected,\n checked: checked,\n loaded: loaded,\n loading: loading,\n halfChecked: halfChecked,\n dragOver: dragOver,\n dragOverGapTop: dragOverGapTop,\n dragOverGapBottom: dragOverGapBottom,\n pos: pos,\n active: active\n });\n\n if (!('props' in eventData)) {\n Object.defineProperty(eventData, 'props', {\n get: function get() {\n warning(false, 'Second param return from event is node data instead of TreeNode instance. Please read value directly instead of reading from `props`.');\n return props;\n }\n });\n }\n\n return eventData;\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-tree/es/utils/treeUtil.js"],"names":["_toConsumableArray","_objectSpread","_objectWithoutProperties","toArray","warning","getPosition","isTreeNode","getKey","key","pos","undefined","warningWithoutKey","treeData","arguments","length","keys","Map","dig","list","path","forEach","treeNode","children","concat","recordKey","String","has","set","convertTreeToData","rootNodes","node","treeNodes","map","_treeNode$props","props","rest","dataNode","parsedChildren","filter","flattenTreeData","treeNodeList","expandedKeys","expandedKeySet","Set","flattenList","parent","index","mergedKey","flattenNode","data","isStart","isEnd","push","traverseDataNodes","dataNodes","callback","externalGetKey","syntheticGetKey","processNode","parentPos","level","subNode","subIndex","convertDataToEntities","_ref","initWrapper","processEntity","onProcessFinished","posEntities","keyEntities","wrapper","item","entity","getTreeNodeProps","_ref2","selectedKeys","loadedKeys","loadingKeys","checkedKeys","halfCheckedKeys","dragOverNodeKey","dropPosition","treeNodeProps","eventKey","expanded","indexOf","selected","loaded","loading","checked","halfChecked","dragOver","dragOverGapTop","dragOverGapBottom","convertNodePropsToEventData","active","eventData","Object","defineProperty","get"],"mappings":"AAAA,OAAOA,kBAAP,MAA+B,8CAA/B;AACA,OAAOC,aAAP,MAA0B,0CAA1B;AACA,OAAOC,wBAAP,MAAqC,oDAArC;AACA,OAAOC,OAAP,MAAoB,6BAApB;AACA,OAAOC,OAAP,MAAoB,oBAApB;AACA,SAASC,WAAT,EAAsBC,UAAtB,QAAwC,SAAxC;AACA,OAAO,SAASC,MAAT,CAAgBC,GAAhB,EAAqBC,GAArB,EAA0B;AAC/B,MAAID,GAAG,KAAK,IAAR,IAAgBA,GAAG,KAAKE,SAA5B,EAAuC;AACrC,WAAOF,GAAP;AACD;;AAED,SAAOC,GAAP;AACD;AACD;AACA;AACA;;AAEA,OAAO,SAASE,iBAAT,GAA6B;AAClC,MAAIC,QAAQ,GAAGC,SAAS,CAACC,MAAV,GAAmB,CAAnB,IAAwBD,SAAS,CAAC,CAAD,CAAT,KAAiBH,SAAzC,GAAqDG,SAAS,CAAC,CAAD,CAA9D,GAAoE,EAAnF;AACA,MAAIE,IAAI,GAAG,IAAIC,GAAJ,EAAX;;AAEA,WAASC,GAAT,CAAaC,IAAb,EAAmB;AACjB,QAAIC,IAAI,GAAGN,SAAS,CAACC,MA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9B;AAAA,MAUIpF,GAAG,GAAGyB,KAAK,CAACzB,GAVhB;AAAA,MAWIsF,MAAM,GAAG7D,KAAK,CAAC6D,MAXnB;;AAaA,MAAIC,SAAS,GAAG/F,aAAa,CAACA,aAAa,CAAC,EAAD,EAAKgD,IAAL,CAAd,EAA0B,EAA1B,EAA8B;AACzDmC,IAAAA,QAAQ,EAAEA,QAD+C;AAEzDE,IAAAA,QAAQ,EAAEA,QAF+C;AAGzDG,IAAAA,OAAO,EAAEA,OAHgD;AAIzDF,IAAAA,MAAM,EAAEA,MAJiD;AAKzDC,IAAAA,OAAO,EAAEA,OALgD;AAMzDE,IAAAA,WAAW,EAAEA,WAN4C;AAOzDC,IAAAA,QAAQ,EAAEA,QAP+C;AAQzDC,IAAAA,cAAc,EAAEA,cARyC;AASzDC,IAAAA,iBAAiB,EAAEA,iBATsC;AAUzDpF,IAAAA,GAAG,EAAEA,GAVoD;AAWzDsF,IAAAA,MAAM,EAAEA;AAXiD,GAA9B,CAA7B;;AAcA,MAAI,EAAE,WAAWC,SAAb,CAAJ,EAA6B;AAC3BC,IAAAA,MAAM,CAACC,cAAP,CAAsBF,SAAtB,EAAiC,OAAjC,EAA0C;AACxCG,MAAAA,GAAG,EAAE,SAASA,GAAT,GAAe;AAClB/F,QAAAA,OAAO,CAAC,KAAD,EAAQ,uIAAR,CAAP;AACA,eAAO8B,KAAP;AACD;AAJuC,KAA1C;AAMD;;AAED,SAAO8D,SAAP;AACD","sourcesContent":["import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport toArray from \"rc-util/es/Children/toArray\";\nimport warning from \"rc-util/es/warning\";\nimport { getPosition, isTreeNode } from '../util';\nexport function getKey(key, pos) {\n if (key !== null && key !== undefined) {\n return key;\n }\n\n return pos;\n}\n/**\n * Warning if TreeNode do not provides key\n */\n\nexport function warningWithoutKey() {\n var treeData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var keys = new Map();\n\n function dig(list) {\n var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';\n (list || []).forEach(function (treeNode) {\n var key = treeNode.key,\n children = treeNode.children;\n warning(key !== null && key !== undefined, \"Tree node must have a certain key: [\".concat(path).concat(key, \"]\"));\n var recordKey = String(key);\n warning(!keys.has(recordKey) || key === null || key === undefined, \"Same 'key' exist in the Tree: \".concat(recordKey));\n keys.set(recordKey, true);\n dig(children, \"\".concat(path).concat(recordKey, \" > \"));\n });\n }\n\n dig(treeData);\n}\n/**\n * Convert `children` of Tree into `treeData` structure.\n */\n\nexport function convertTreeToData(rootNodes) {\n function dig(node) {\n var treeNodes = toArray(node);\n return treeNodes.map(function (treeNode) {\n // Filter invalidate node\n if (!isTreeNode(treeNode)) {\n warning(!treeNode, 'Tree/TreeNode can only accept TreeNode as children.');\n return null;\n }\n\n var key = treeNode.key;\n\n var _treeNode$props = treeNode.props,\n children = _treeNode$props.children,\n rest = _objectWithoutProperties(_treeNode$props, [\"children\"]);\n\n var dataNode = _objectSpread({\n key: key\n }, rest);\n\n var parsedChildren = dig(children);\n\n if (parsedChildren.length) {\n dataNode.children = parsedChildren;\n }\n\n return dataNode;\n }).filter(function (dataNode) {\n return dataNode;\n });\n }\n\n return dig(rootNodes);\n}\n/**\n * Flat nest tree data into flatten list. This is used for virtual list render.\n * @param treeNodeList Origin data node list\n * @param expandedKeys\n * need expanded keys, provides `true` means all expanded (used in `rc-tree-select`).\n */\n\nexport function flattenTreeData() {\n var treeNodeList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var expandedKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n var expandedKeySet = new Set(expandedKeys === true ? [] : expandedKeys);\n var flattenList = [];\n\n function dig(list) {\n var parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n return list.map(function (treeNode, index) {\n var pos = getPosition(parent ? parent.pos : '0', index);\n var mergedKey = getKey(treeNode.key, pos); // Add FlattenDataNode into list\n\n var flattenNode = _objectSpread(_objectSpread({}, treeNode), {}, {\n parent: parent,\n pos: pos,\n children: null,\n data: treeNode,\n isStart: [].concat(_toConsumableArray(parent ? parent.isStart : []), [index === 0]),\n isEnd: [].concat(_toConsumableArray(parent ? parent.isEnd : []), [index === list.length - 1])\n });\n\n flattenList.push(flattenNode); // Loop treeNode children\n\n if (expandedKeys === true || expandedKeySet.has(mergedKey)) {\n flattenNode.children = dig(treeNode.children || [], flattenNode);\n } else {\n flattenNode.children = [];\n }\n\n return flattenNode;\n });\n }\n\n dig(treeNodeList);\n return flattenList;\n}\n/**\n * Traverse all the data by `treeData`.\n * Please not use it out of the `rc-tree` since we may refactor this code.\n */\n\nexport function traverseDataNodes(dataNodes, callback, externalGetKey) {\n var syntheticGetKey;\n\n if (externalGetKey) {\n if (typeof externalGetKey === 'string') {\n syntheticGetKey = function syntheticGetKey(node) {\n return node[externalGetKey];\n };\n } else if (typeof externalGetKey === 'function') {\n syntheticGetKey = function syntheticGetKey(node) {\n return externalGetKey(node);\n };\n }\n } else {\n syntheticGetKey = function syntheticGetKey(node, pos) {\n return getKey(node.key, pos);\n };\n }\n\n function processNode(node, index, parent) {\n var children = node ? node.children : dataNodes;\n var pos = node ? getPosition(parent.pos, index) : '0'; // Process node if is not root\n\n if (node) {\n var key = syntheticGetKey(node, pos);\n var data = {\n node: node,\n index: index,\n pos: pos,\n key: key,\n parentPos: parent.node ? parent.pos : null,\n level: parent.level + 1\n };\n callback(data);\n } // Process children node\n\n\n if (children) {\n children.forEach(function (subNode, subIndex) {\n processNode(subNode, subIndex, {\n node: node,\n pos: pos,\n level: parent ? parent.level + 1 : -1\n });\n });\n }\n }\n\n processNode(null);\n}\n/**\n * Convert `treeData` into entity records.\n */\n\nexport function convertDataToEntities(dataNodes) {\n var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},\n initWrapper = _ref.initWrapper,\n processEntity = _ref.processEntity,\n onProcessFinished = _ref.onProcessFinished;\n\n var externalGetKey = arguments.length > 2 ? arguments[2] : undefined;\n var posEntities = {};\n var keyEntities = {};\n var wrapper = {\n posEntities: posEntities,\n keyEntities: keyEntities\n };\n\n if (initWrapper) {\n wrapper = initWrapper(wrapper) || wrapper;\n }\n\n traverseDataNodes(dataNodes, function (item) {\n var node = item.node,\n index = item.index,\n pos = item.pos,\n key = item.key,\n parentPos = item.parentPos,\n level = item.level;\n var entity = {\n node: node,\n index: index,\n key: key,\n pos: pos,\n level: level\n };\n var mergedKey = getKey(key, pos);\n posEntities[pos] = entity;\n keyEntities[mergedKey] = entity; // Fill children\n\n entity.parent = posEntities[parentPos];\n\n if (entity.parent) {\n entity.parent.children = entity.parent.children || [];\n entity.parent.children.push(entity);\n }\n\n if (processEntity) {\n processEntity(entity, wrapper);\n }\n }, externalGetKey);\n\n if (onProcessFinished) {\n onProcessFinished(wrapper);\n }\n\n return wrapper;\n}\n/**\n * Get TreeNode props with Tree props.\n */\n\nexport function getTreeNodeProps(key, _ref2) {\n var expandedKeys = _ref2.expandedKeys,\n selectedKeys = _ref2.selectedKeys,\n loadedKeys = _ref2.loadedKeys,\n loadingKeys = _ref2.loadingKeys,\n checkedKeys = _ref2.checkedKeys,\n halfCheckedKeys = _ref2.halfCheckedKeys,\n dragOverNodeKey = _ref2.dragOverNodeKey,\n dropPosition = _ref2.dropPosition,\n keyEntities = _ref2.keyEntities;\n var entity = keyEntities[key];\n var treeNodeProps = {\n eventKey: key,\n expanded: expandedKeys.indexOf(key) !== -1,\n selected: selectedKeys.indexOf(key) !== -1,\n loaded: loadedKeys.indexOf(key) !== -1,\n loading: loadingKeys.indexOf(key) !== -1,\n checked: checkedKeys.indexOf(key) !== -1,\n halfChecked: halfCheckedKeys.indexOf(key) !== -1,\n pos: String(entity ? entity.pos : ''),\n // [Legacy] Drag props\n // Since the interaction of drag is changed, the semantic of the props are\n // not accuracy, I think it should be finally removed\n dragOver: dragOverNodeKey === key && dropPosition === 0,\n dragOverGapTop: dragOverNodeKey === key && dropPosition === -1,\n dragOverGapBottom: dragOverNodeKey === key && dropPosition === 1\n };\n return treeNodeProps;\n}\nexport function convertNodePropsToEventData(props) {\n var data = props.data,\n expanded = props.expanded,\n selected = props.selected,\n checked = props.checked,\n loaded = props.loaded,\n loading = props.loading,\n halfChecked = props.halfChecked,\n dragOver = props.dragOver,\n dragOverGapTop = props.dragOverGapTop,\n dragOverGapBottom = props.dragOverGapBottom,\n pos = props.pos,\n active = props.active;\n\n var eventData = _objectSpread(_objectSpread({}, data), {}, {\n expanded: expanded,\n selected: selected,\n checked: checked,\n loaded: loaded,\n loading: loading,\n halfChecked: halfChecked,\n dragOver: dragOver,\n dragOverGapTop: dragOverGapTop,\n dragOverGapBottom: dragOverGapBottom,\n pos: pos,\n active: active\n });\n\n if (!('props' in eventData)) {\n Object.defineProperty(eventData, 'props', {\n get: function get() {\n warning(false, 'Second param return from event is node data instead of TreeNode instance. Please read value directly instead of reading from `props`.');\n return props;\n }\n });\n }\n\n return eventData;\n}"]},"metadata":{},"sourceType":"module"}