1 line
6.6 KiB
JSON
1 line
6.6 KiB
JSON
|
{"ast":null,"code":"import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport { fillFieldNames } from \"rc-tree/es/utils/treeUtil\";\nconst RECORD_NONE = 0;\nconst RECORD_START = 1;\nconst RECORD_END = 2;\nfunction traverseNodesKey(treeData, callback, fieldNames) {\n const {\n key: fieldKey,\n children: fieldChildren\n } = fieldNames;\n function processNode(dataNode) {\n const key = dataNode[fieldKey];\n const children = dataNode[fieldChildren];\n if (callback(key, dataNode) !== false) {\n traverseNodesKey(children || [], callback, fieldNames);\n }\n }\n treeData.forEach(processNode);\n}\n/** 计算选中范围,只考虑expanded情况以优化性能 */\nexport function calcRangeKeys(_ref) {\n let {\n treeData,\n expandedKeys,\n startKey,\n endKey,\n fieldNames\n } = _ref;\n const keys = [];\n let record = RECORD_NONE;\n if (startKey && startKey === endKey) {\n return [startKey];\n }\n if (!startKey || !endKey) {\n return [];\n }\n function matchKey(key) {\n return key === startKey || key === endKey;\n }\n traverseNodesKey(treeData, key => {\n if (record === RECORD_END) {\n return false;\n }\n if (matchKey(key)) {\n // Match test\n keys.push(key);\n if (record === RECORD_NONE) {\n record = RECORD_START;\n } else if (record === RECORD_START) {\n record = RECORD_END;\n return false;\n }\n } else if (record === RECORD_START) {\n // Append selection\n keys.push(key);\n }\n return expandedKeys.includes(key);\n }, fillFieldNames(fieldNames));\n return keys;\n}\nexport function convertDirectoryKeysToNodes(treeData, keys, fieldNames) {\n const restKeys = _toConsumableArray(keys);\n const nodes = [];\n traverseNodesKey(treeData, (key, node) => {\n const index = restKeys.indexOf(key);\n if (index !== -1) {\n nodes.push(node);\n restKeys.splice(index, 1);\n }\n return !!restKeys.length;\n }, fillFieldNames(fieldNames));\n return nodes;\n}","map":{"version":3,"names":["_toConsumableArray","fillFieldNames","RECORD_NONE","RECORD_START","RECORD_END","traverseNodesKey","treeData","callback","fieldNames","key","fieldKey","children","fieldChildren","processNode","dataNode","forEach","calcRangeKeys","_ref","expandedKeys","startKey","endKey","keys","record","matchKey","push","includes","convertDirectoryKeysToNodes","restKeys","nodes","node","index","indexOf","splice","length"],"sources":["C:/Users/Аришина)/Desktop/promo/node_modules/antd/es/tree/utils/dictUtil.js"],"sourcesContent":["import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport { fillFieldNames } from \"rc-tree/es/utils/treeUtil\";\nconst RECORD_NONE = 0;\nconst RECORD_START = 1;\nconst RECORD_END = 2;\nfunction traverseNodesKey(treeData, callback, fieldNames) {\n const {\n key: fieldKey,\n children: fieldChildren\n } = fieldNames;\n function processNode(dataNode) {\n const key = dataNode[fieldKey];\n const children = dataNode[fieldChildren];\n if (callback(key, dataNode) !== false) {\n traverseNodesKey(children || [], callback, fieldNames);\n }\n }\n treeData.forEach(processNode);\n}\n/** 计算选中范围,只考虑expanded情况以优化性能 */\nexport function calcRangeKeys(_ref) {\n let {\n treeData,\n expandedKeys,\n startKey,\n endKey,\n fieldNames\n } = _ref;\n const keys = [];\n let record = RECORD_NONE;\n if (startKey && startKey === endKey) {\n return [startKey];\n }\n if (!startKey || !endKey) {\n return [];\n }\n function matchKey(key) {\n return key === startKey || key === endKey;\n }\n traverseNodesKey(treeData, key => {\n if (record === RECORD_END) {\n return false;\n }\n if (matchKey(key)) {\n // Match test\n keys.push(key);\n if (record === RECORD_NONE) {\n record = RECORD_START;\n } else if (record === RECORD_START) {\n record = RECORD_END;\n return false;\n }\n } else if (record === RECORD_STA
|