PromoCursed/node_modules/.cache/babel-loader/8e297146ba7b21b125d636bb77d61f2ccfb0d6b8a4833a6166c48fce6cb4341d.json

1 line
22 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"import warning from \"rc-util/es/warning\";\nimport getEntity from \"./keyUtil\";\nfunction removeFromCheckedKeys(halfCheckedKeys, checkedKeys) {\n var filteredKeys = new Set();\n halfCheckedKeys.forEach(function (key) {\n if (!checkedKeys.has(key)) {\n filteredKeys.add(key);\n }\n });\n return filteredKeys;\n}\nexport function isCheckDisabled(node) {\n var _ref = node || {},\n disabled = _ref.disabled,\n disableCheckbox = _ref.disableCheckbox,\n checkable = _ref.checkable;\n return !!(disabled || disableCheckbox) || checkable === false;\n}\n\n// Fill miss keys\nfunction fillConductCheck(keys, levelEntities, maxLevel, syntheticGetCheckDisabled) {\n var checkedKeys = new Set(keys);\n var halfCheckedKeys = new Set();\n\n // Add checked keys top to bottom\n for (var level = 0; level <= maxLevel; level += 1) {\n var entities = levelEntities.get(level) || new Set();\n entities.forEach(function (entity) {\n var key = entity.key,\n node = entity.node,\n _entity$children = entity.children,\n children = _entity$children === void 0 ? [] : _entity$children;\n if (checkedKeys.has(key) && !syntheticGetCheckDisabled(node)) {\n children.filter(function (childEntity) {\n return !syntheticGetCheckDisabled(childEntity.node);\n }).forEach(function (childEntity) {\n checkedKeys.add(childEntity.key);\n });\n }\n });\n }\n\n // Add checked keys from bottom to top\n var visitedKeys = new Set();\n for (var _level = maxLevel; _level >= 0; _level -= 1) {\n var _entities = levelEntities.get(_level) || new Set();\n _entities.forEach(function (entity) {\n var parent = entity.parent,\n node = entity.node;\n\n // Skip if no need to check\n if (syntheticGetCheckDisabled(node) || !entity.parent || visitedKeys.has(entity.parent.key)) {\n return;\n }\n\n // Skip if parent is disabled\n if (syntheticGetCheckDisabled(entity.parent.node)) {\n visitedKeys.add(parent.key);\n return;\n }\n var allChecked = true;\n var partialChecked = false;\n (parent.children || []).filter(function (childEntity) {\n return !syntheticGetCheckDisabled(childEntity.node);\n }).forEach(function (_ref2) {\n var key = _ref2.key;\n var checked = checkedKeys.has(key);\n if (allChecked && !checked) {\n allChecked = false;\n }\n if (!partialChecked && (checked || halfCheckedKeys.has(key))) {\n partialChecked = true;\n }\n });\n if (allChecked) {\n checkedKeys.add(parent.key);\n }\n if (partialChecked) {\n halfCheckedKeys.add(parent.key);\n }\n visitedKeys.add(parent.key);\n });\n }\n return {\n checkedKeys: Array.from(checkedKeys),\n halfCheckedKeys: Array.from(removeFromCheckedKeys(halfCheckedKeys, checkedKeys))\n };\n}\n\n// Remove useless key\nfunction cleanConductCheck(keys, halfKeys, levelEntities, maxLevel, syntheticGetCheckDisabled) {\n var checkedKeys = new Set(keys);\n var halfCheckedKeys = new Set(halfKeys);\n\n // Remove checked keys from top to bottom\n for (var level = 0; level <= maxLevel; level += 1) {\n var entities = levelEntities.get(level) || new Set();\n entities.forEach(function (entity) {\n var key = entity.key,\n node = entity.node,\n _entity$children2 = entity.children,\n children = _entity$children2 === void 0 ? [] : _entity$children2;\n if (!checkedKeys.has(key) && !halfCheckedKeys.has(key) && !syntheticGetCheckDisabled(node)) {\n children.filter(function (childEntity) {\n return !syntheticGetCheckDisabled(childEntity.node);\n }).forEach(function (childEntity) {\n checkedKeys.delete(childEntity.key);\n });\n }\n });\n }\n\n // Remove checked keys form bottom to top\n halfCheckedKeys = new Set();\n var visitedKeys = new Set();\n for (var _level2 = maxLevel; _level2 >= 0; _level2 -= 1) {\n var _entities2 = levelEntities.get(_