1 line
29 KiB
JSON
1 line
29 KiB
JSON
|
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport { useBaseProps } from 'rc-select';\nimport Tree from 'rc-tree';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport useMemo from \"rc-util/es/hooks/useMemo\";\nimport * as React from 'react';\nimport LegacyContext from \"./LegacyContext\";\nimport TreeSelectContext from \"./TreeSelectContext\";\nimport { getAllKeys, isCheckDisabled } from \"./utils/valueUtil\";\nvar HIDDEN_STYLE = {\n width: 0,\n height: 0,\n display: 'flex',\n overflow: 'hidden',\n opacity: 0,\n border: 0,\n padding: 0,\n margin: 0\n};\nvar OptionList = function OptionList(_, ref) {\n var _useBaseProps = useBaseProps(),\n prefixCls = _useBaseProps.prefixCls,\n multiple = _useBaseProps.multiple,\n searchValue = _useBaseProps.searchValue,\n toggleOpen = _useBaseProps.toggleOpen,\n open = _useBaseProps.open,\n notFoundContent = _useBaseProps.notFoundContent;\n var _React$useContext = React.useContext(TreeSelectContext),\n virtual = _React$useContext.virtual,\n listHeight = _React$useContext.listHeight,\n listItemHeight = _React$useContext.listItemHeight,\n listItemScrollOffset = _React$useContext.listItemScrollOffset,\n treeData = _React$useContext.treeData,\n fieldNames = _React$useContext.fieldNames,\n onSelect = _React$useContext.onSelect,\n dropdownMatchSelectWidth = _React$useContext.dropdownMatchSelectWidth,\n treeExpandAction = _React$useContext.treeExpandAction,\n treeTitleRender = _React$useContext.treeTitleRender,\n onPopupScroll = _React$useContext.onPopupScroll;\n var _React$useContext2 = React.useContext(LegacyContext),\n checkable = _React$useContext2.checkable,\n checkedKeys = _React$useContext2.checkedKeys,\n halfCheckedKeys = _React$useContext2.halfCheckedKeys,\n treeExpandedKeys = _React$useContext2.treeExpandedKeys,\n treeDefaultExpandAll = _React$useContext2.treeDefaultExpandAll,\n treeDefaultExpandedKeys = _React$useContext2.treeDefaultExpandedKeys,\n onTreeExpand = _React$useContext2.onTreeExpand,\n treeIcon = _React$useContext2.treeIcon,\n showTreeIcon = _React$useContext2.showTreeIcon,\n switcherIcon = _React$useContext2.switcherIcon,\n treeLine = _React$useContext2.treeLine,\n treeNodeFilterProp = _React$useContext2.treeNodeFilterProp,\n loadData = _React$useContext2.loadData,\n treeLoadedKeys = _React$useContext2.treeLoadedKeys,\n treeMotion = _React$useContext2.treeMotion,\n onTreeLoad = _React$useContext2.onTreeLoad,\n keyEntities = _React$useContext2.keyEntities;\n var treeRef = React.useRef();\n var memoTreeData = useMemo(function () {\n return treeData;\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [open, treeData], function (prev, next) {\n return next[0] && prev[1] !== next[1];\n });\n\n // ========================== Active ==========================\n var _React$useState = React.useState(null),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n activeKey = _React$useState2[0],\n setActiveKey = _React$useState2[1];\n var activeEntity = keyEntities[activeKey];\n\n // ========================== Values ==========================\n var mergedCheckedKeys = React.useMemo(function () {\n if (!checkable) {\n return null;\n }\n return {\n checked: checkedKeys,\n halfChecked: halfCheckedKeys\n };\n }, [checkable, checkedKeys, halfCheckedKeys]);\n\n // ========================== Scroll ==========================\n React.useEffect(function () {\n // Single mode should scroll to current key\n if (open && !multiple && checkedKeys.length) {\n var _treeRef$current;\n (_treeRef$current = treeRef.current) === null || _treeRef$current === void 0 || _treeRef$current.scrollTo({\n key: checkedKeys[0]\n });\n setActiveKey(checkedKeys[0]);\n }\n // eslint-disable-next-line r
|