PromoCursed/node_modules/.cache/babel-loader/65f0ba7fb3f7da0930ce026acda0a583f32aa9be38e6cf6f0a6f8110cc58d434.json

1 line
20 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"\"use client\";\n\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nvar __rest = this && this.__rest || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\nimport * as React from 'react';\nimport FileOutlined from \"@ant-design/icons/es/icons/FileOutlined\";\nimport FolderOpenOutlined from \"@ant-design/icons/es/icons/FolderOpenOutlined\";\nimport FolderOutlined from \"@ant-design/icons/es/icons/FolderOutlined\";\nimport classNames from 'classnames';\nimport { conductExpandParent } from \"rc-tree/es/util\";\nimport { convertDataToEntities, convertTreeToData } from \"rc-tree/es/utils/treeUtil\";\nimport { ConfigContext } from '../config-provider';\nimport Tree from './Tree';\nimport { calcRangeKeys, convertDirectoryKeysToNodes } from './utils/dictUtil';\nfunction getIcon(props) {\n const {\n isLeaf,\n expanded\n } = props;\n if (isLeaf) {\n return /*#__PURE__*/React.createElement(FileOutlined, null);\n }\n return expanded ? /*#__PURE__*/React.createElement(FolderOpenOutlined, null) : /*#__PURE__*/React.createElement(FolderOutlined, null);\n}\nfunction getTreeData(_ref) {\n let {\n treeData,\n children\n } = _ref;\n return treeData || convertTreeToData(children);\n}\nconst DirectoryTree = (_a, ref) => {\n var {\n defaultExpandAll,\n defaultExpandParent,\n defaultExpandedKeys\n } = _a,\n props = __rest(_a, [\"defaultExpandAll\", \"defaultExpandParent\", \"defaultExpandedKeys\"]);\n // Shift click usage\n const lastSelectedKey = React.useRef();\n const cachedSelectedKeys = React.useRef();\n const getInitExpandedKeys = () => {\n const {\n keyEntities\n } = convertDataToEntities(getTreeData(props));\n let initExpandedKeys;\n // Expanded keys\n if (defaultExpandAll) {\n initExpandedKeys = Object.keys(keyEntities);\n } else if (defaultExpandParent) {\n initExpandedKeys = conductExpandParent(props.expandedKeys || defaultExpandedKeys || [], keyEntities);\n } else {\n initExpandedKeys = props.expandedKeys || defaultExpandedKeys || [];\n }\n return initExpandedKeys;\n };\n const [selectedKeys, setSelectedKeys] = React.useState(props.selectedKeys || props.defaultSelectedKeys || []);\n const [expandedKeys, setExpandedKeys] = React.useState(() => getInitExpandedKeys());\n React.useEffect(() => {\n if ('selectedKeys' in props) {\n setSelectedKeys(props.selectedKeys);\n }\n }, [props.selectedKeys]);\n React.useEffect(() => {\n if ('expandedKeys' in props) {\n setExpandedKeys(props.expandedKeys);\n }\n }, [props.expandedKeys]);\n const onExpand = (keys, info) => {\n var _a;\n if (!('expandedKeys' in props)) {\n setExpandedKeys(keys);\n }\n // Call origin function\n return (_a = props.onExpand) === null || _a === void 0 ? void 0 : _a.call(props, keys, info);\n };\n const onSelect = (keys, event) => {\n var _a;\n const {\n multiple,\n fieldNames\n } = props;\n const {\n node,\n nativeEvent\n } = event;\n const {\n key = ''\n } = node;\n const treeData = getTreeData(props);\n // const newState: DirectoryTreeState = {};\n // We need wrap this event since some value is not same\n const newEvent = Object.assign(Object.assign({}, event), {\n selected: true\n });\n // Windows / Mac single pick\n const ctrlPick = (nativeEvent === null || nativeEvent === void 0 ? void 0 : nativeEvent.ctrlKey) || (nativeEvent === null || nativeEvent === void 0 ? void 0 : nativeEvent.metaKey);\n const shiftPick = nativeEvent === null || nativeEvent === void 0 ? void 0 : nativeEvent.shiftKey;\n // Generate new selected keys\n let newSelecte