12ad002507f49efabddc7203e3c2894f.json
28 KB
{"ast":null,"code":"import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport useMemo from \"rc-util/es/hooks/useMemo\";\nimport Tree from 'rc-tree';\nimport { SelectContext } from './Context';\nimport useKeyValueMapping from './hooks/useKeyValueMapping';\nimport useKeyValueMap from './hooks/useKeyValueMap';\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};\n\nvar OptionList = function OptionList(props, ref) {\n var prefixCls = props.prefixCls,\n height = props.height,\n itemHeight = props.itemHeight,\n virtual = props.virtual,\n options = props.options,\n flattenOptions = props.flattenOptions,\n multiple = props.multiple,\n searchValue = props.searchValue,\n onSelect = props.onSelect,\n onToggleOpen = props.onToggleOpen,\n open = props.open,\n notFoundContent = props.notFoundContent,\n onMouseEnter = props.onMouseEnter;\n\n var _React$useContext = React.useContext(SelectContext),\n checkable = _React$useContext.checkable,\n checkedKeys = _React$useContext.checkedKeys,\n halfCheckedKeys = _React$useContext.halfCheckedKeys,\n treeExpandedKeys = _React$useContext.treeExpandedKeys,\n treeDefaultExpandAll = _React$useContext.treeDefaultExpandAll,\n treeDefaultExpandedKeys = _React$useContext.treeDefaultExpandedKeys,\n onTreeExpand = _React$useContext.onTreeExpand,\n treeIcon = _React$useContext.treeIcon,\n showTreeIcon = _React$useContext.showTreeIcon,\n switcherIcon = _React$useContext.switcherIcon,\n treeLine = _React$useContext.treeLine,\n treeNodeFilterProp = _React$useContext.treeNodeFilterProp,\n loadData = _React$useContext.loadData,\n treeLoadedKeys = _React$useContext.treeLoadedKeys,\n treeMotion = _React$useContext.treeMotion,\n onTreeLoad = _React$useContext.onTreeLoad;\n\n var treeRef = React.useRef();\n var memoOptions = useMemo(function () {\n return options;\n }, [open, options], function (prev, next) {\n return next[0] && prev[1] !== next[1];\n });\n\n var _useKeyValueMap = useKeyValueMap(flattenOptions),\n _useKeyValueMap2 = _slicedToArray(_useKeyValueMap, 2),\n cacheKeyMap = _useKeyValueMap2[0],\n cacheValueMap = _useKeyValueMap2[1];\n\n var _useKeyValueMapping = useKeyValueMapping(cacheKeyMap, cacheValueMap),\n _useKeyValueMapping2 = _slicedToArray(_useKeyValueMapping, 2),\n getEntityByKey = _useKeyValueMapping2[0],\n getEntityByValue = _useKeyValueMapping2[1]; // ========================== Values ==========================\n\n\n var valueKeys = React.useMemo(function () {\n return checkedKeys.map(function (val) {\n var entity = getEntityByValue(val);\n return entity ? entity.key : null;\n });\n }, [checkedKeys]);\n var mergedCheckedKeys = React.useMemo(function () {\n if (!checkable) {\n return null;\n }\n\n return {\n checked: valueKeys,\n halfChecked: halfCheckedKeys\n };\n }, [valueKeys, halfCheckedKeys, checkable]); // ========================== Scroll ==========================\n\n React.useEffect(function () {\n // Single mode should scroll to current key\n if (open && !multiple && valueKeys.length) {\n var _treeRef$current;\n\n (_treeRef$current = treeRef.current) === null || _treeRef$current === void 0 ? void 0 : _treeRef$current.scrollTo({\n key: valueKeys[0]\n });\n }\n }, [open]); // ========================== Search ==========================\n\n var lowerSearchValue = String(searchValue).toLowerCase();\n\n var filterTreeNode = function filterTreeNode(treeNode) {\n if (!lowerSearchValue) {\n return false;\n }\n\n return String(treeNode[treeNodeFilterProp]).toLowerCase().includes(lowerSearchValue);\n }; // =========================== Keys ===========================\n\n\n var _React$useState = React.useState(treeDefaultExpandedKeys),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n expandedKeys = _React$useState2[0],\n setExpandedKeys = _React$useState2[1];\n\n var _React$useState3 = React.useState(null),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n searchExpandedKeys = _React$useState4[0],\n setSearchExpandedKeys = _React$useState4[1];\n\n var mergedExpandedKeys = React.useMemo(function () {\n if (treeExpandedKeys) {\n return _toConsumableArray(treeExpandedKeys);\n }\n\n return searchValue ? searchExpandedKeys : expandedKeys;\n }, [expandedKeys, searchExpandedKeys, lowerSearchValue, treeExpandedKeys]);\n React.useEffect(function () {\n if (searchValue) {\n setSearchExpandedKeys(flattenOptions.map(function (o) {\n return o.key;\n }));\n }\n }, [searchValue]);\n\n var onInternalExpand = function onInternalExpand(keys) {\n setExpandedKeys(keys);\n setSearchExpandedKeys(keys);\n\n if (onTreeExpand) {\n onTreeExpand(keys);\n }\n }; // ========================== Events ==========================\n\n\n var onListMouseDown = function onListMouseDown(event) {\n event.preventDefault();\n };\n\n var onInternalSelect = function onInternalSelect(_, _ref) {\n var key = _ref.node.key;\n var entity = getEntityByKey(key, checkable ? 'checkbox' : 'select');\n\n if (entity !== null) {\n onSelect(entity.data.value, {\n selected: !checkedKeys.includes(entity.data.value)\n });\n }\n\n if (!multiple) {\n onToggleOpen(false);\n }\n }; // ========================= Keyboard =========================\n\n\n var _React$useState5 = React.useState(null),\n _React$useState6 = _slicedToArray(_React$useState5, 2),\n activeKey = _React$useState6[0],\n setActiveKey = _React$useState6[1];\n\n var activeEntity = getEntityByKey(activeKey);\n React.useImperativeHandle(ref, function () {\n return {\n onKeyDown: function onKeyDown(event) {\n var _treeRef$current2;\n\n var which = event.which;\n\n switch (which) {\n // >>> Arrow keys\n case KeyCode.UP:\n case KeyCode.DOWN:\n case KeyCode.LEFT:\n case KeyCode.RIGHT:\n (_treeRef$current2 = treeRef.current) === null || _treeRef$current2 === void 0 ? void 0 : _treeRef$current2.onKeyDown(event);\n break;\n // >>> Select item\n\n case KeyCode.ENTER:\n {\n if (activeEntity !== null) {\n onInternalSelect(null, {\n node: {\n key: activeKey\n },\n selected: !checkedKeys.includes(activeEntity.data.value)\n });\n }\n\n break;\n }\n // >>> Close\n\n case KeyCode.ESC:\n {\n onToggleOpen(false);\n }\n }\n },\n onKeyUp: function onKeyUp() {}\n };\n }); // ========================== Render ==========================\n\n if (memoOptions.length === 0) {\n return /*#__PURE__*/React.createElement(\"div\", {\n role: \"listbox\",\n className: \"\".concat(prefixCls, \"-empty\"),\n onMouseDown: onListMouseDown\n }, notFoundContent);\n }\n\n var treeProps = {};\n\n if (treeLoadedKeys) {\n treeProps.loadedKeys = treeLoadedKeys;\n }\n\n if (mergedExpandedKeys) {\n treeProps.expandedKeys = mergedExpandedKeys;\n }\n\n return /*#__PURE__*/React.createElement(\"div\", {\n onMouseDown: onListMouseDown,\n onMouseEnter: onMouseEnter\n }, activeEntity && open && /*#__PURE__*/React.createElement(\"span\", {\n style: HIDDEN_STYLE,\n \"aria-live\": \"assertive\"\n }, activeEntity.data.value), /*#__PURE__*/React.createElement(Tree, Object.assign({\n ref: treeRef,\n focusable: false,\n prefixCls: \"\".concat(prefixCls, \"-tree\"),\n treeData: memoOptions,\n height: height,\n itemHeight: itemHeight,\n virtual: virtual,\n multiple: multiple,\n icon: treeIcon,\n showIcon: showTreeIcon,\n switcherIcon: switcherIcon,\n showLine: treeLine,\n loadData: searchValue ? null : loadData,\n motion: treeMotion,\n // We handle keys by out instead tree self\n checkable: checkable,\n checkStrictly: true,\n checkedKeys: mergedCheckedKeys,\n selectedKeys: !checkable ? valueKeys : [],\n defaultExpandAll: treeDefaultExpandAll\n }, treeProps, {\n // Proxy event out\n onActiveChange: setActiveKey,\n onSelect: onInternalSelect,\n onCheck: onInternalSelect,\n onExpand: onInternalExpand,\n onLoad: onTreeLoad,\n filterTreeNode: filterTreeNode\n })));\n};\n\nvar RefOptionList = /*#__PURE__*/React.forwardRef(OptionList);\nRefOptionList.displayName = 'OptionList';\nexport default RefOptionList;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-tree-select/es/OptionList.js"],"names":["_toConsumableArray","_slicedToArray","React","KeyCode","useMemo","Tree","SelectContext","useKeyValueMapping","useKeyValueMap","HIDDEN_STYLE","width","height","display","overflow","opacity","border","padding","margin","OptionList","props","ref","prefixCls","itemHeight","virtual","options","flattenOptions","multiple","searchValue","onSelect","onToggleOpen","open","notFoundContent","onMouseEnter","_React$useContext","useContext","checkable","checkedKeys","halfCheckedKeys","treeExpandedKeys","treeDefaultExpandAll","treeDefaultExpandedKeys","onTreeExpand","treeIcon","showTreeIcon","switcherIcon","treeLine","treeNodeFilterProp","loadData","treeLoadedKeys","treeMotion","onTreeLoad","treeRef","useRef","memoOptions","prev","next","_useKeyValueMap","_useKeyValueMap2","cacheKeyMap","cacheValueMap","_useKeyValueMapping","_useKeyValueMapping2","getEntityByKey","getEntityByValue","valueKeys","map","val","entity","key","mergedCheckedKeys","checked","halfChecked","useEffect","length","_treeRef$current","current","scrollTo","lowerSearchValue","String","toLowerCase","filterTreeNode","treeNode","includes","_React$useState","useState","_React$useState2","expandedKeys","setExpandedKeys","_React$useState3","_React$useState4","searchExpandedKeys","setSearchExpandedKeys","mergedExpandedKeys","o","onInternalExpand","keys","onListMouseDown","event","preventDefault","onInternalSelect","_","_ref","node","data","value","selected","_React$useState5","_React$useState6","activeKey","setActiveKey","activeEntity","useImperativeHandle","onKeyDown","_treeRef$current2","which","UP","DOWN","LEFT","RIGHT","ENTER","ESC","onKeyUp","createElement","role","className","concat","onMouseDown","treeProps","loadedKeys","style","Object","assign","focusable","treeData","icon","showIcon","showLine","motion","checkStrictly","selectedKeys","defaultExpandAll","onActiveChange","onCheck","onExpand","onLoad","RefOptionList","forwardRef","displayName"],"mappings":"AAAA,OAAOA,kBAAP,MAA+B,8CAA/B;AACA,OAAOC,cAAP,MAA2B,0CAA3B;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC,OAAP,MAAoB,oBAApB;AACA,OAAOC,OAAP,MAAoB,0BAApB;AACA,OAAOC,IAAP,MAAiB,SAAjB;AACA,SAASC,aAAT,QAA8B,WAA9B;AACA,OAAOC,kBAAP,MAA+B,4BAA/B;AACA,OAAOC,cAAP,MAA2B,wBAA3B;AACA,IAAIC,YAAY,GAAG;AACjBC,EAAAA,KAAK,EAAE,CADU;AAEjBC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E5F,QAT0E;AAUhF6F,IAAAA,QAAQ,EAAE5F,YAVsE;AAWhFC,IAAAA,YAAY,EAAEA,YAXkE;AAYhF4F,IAAAA,QAAQ,EAAE3F,QAZsE;AAahFE,IAAAA,QAAQ,EAAEpB,WAAW,GAAG,IAAH,GAAUoB,QAbiD;AAchF0F,IAAAA,MAAM,EAAExF,UAdwE;AAehF;AACAd,IAAAA,SAAS,EAAEA,SAhBqE;AAiBhFuG,IAAAA,aAAa,EAAE,IAjBiE;AAkBhFtG,IAAAA,WAAW,EAAEiC,iBAlBmE;AAmBhFsE,IAAAA,YAAY,EAAE,CAACxG,SAAD,GAAa6B,SAAb,GAAyB,EAnByC;AAoBhF4E,IAAAA,gBAAgB,EAAErG;AApB8D,GAAd,EAqBjEwF,SArBiE,EAqBtD;AACZ;AACAc,IAAAA,cAAc,EAAEhC,YAFJ;AAGZjF,IAAAA,QAAQ,EAAEuE,gBAHE;AAIZ2C,IAAAA,OAAO,EAAE3C,gBAJG;AAKZ4C,IAAAA,QAAQ,EAAEjD,gBALE;AAMZkD,IAAAA,MAAM,EAAE9F,UANI;AAOZ8B,IAAAA,cAAc,EAAEA;AAPJ,GArBsD,CAA1B,CANtB,CAApB;AAoCD,CAvPD;;AAyPA,IAAIiE,aAAa,GAAG,aAAa/I,KAAK,CAACgJ,UAAN,CAAiBhI,UAAjB,CAAjC;AACA+H,aAAa,CAACE,WAAd,GAA4B,YAA5B;AACA,eAAeF,aAAf","sourcesContent":["import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport useMemo from \"rc-util/es/hooks/useMemo\";\nimport Tree from 'rc-tree';\nimport { SelectContext } from './Context';\nimport useKeyValueMapping from './hooks/useKeyValueMapping';\nimport useKeyValueMap from './hooks/useKeyValueMap';\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};\n\nvar OptionList = function OptionList(props, ref) {\n var prefixCls = props.prefixCls,\n height = props.height,\n itemHeight = props.itemHeight,\n virtual = props.virtual,\n options = props.options,\n flattenOptions = props.flattenOptions,\n multiple = props.multiple,\n searchValue = props.searchValue,\n onSelect = props.onSelect,\n onToggleOpen = props.onToggleOpen,\n open = props.open,\n notFoundContent = props.notFoundContent,\n onMouseEnter = props.onMouseEnter;\n\n var _React$useContext = React.useContext(SelectContext),\n checkable = _React$useContext.checkable,\n checkedKeys = _React$useContext.checkedKeys,\n halfCheckedKeys = _React$useContext.halfCheckedKeys,\n treeExpandedKeys = _React$useContext.treeExpandedKeys,\n treeDefaultExpandAll = _React$useContext.treeDefaultExpandAll,\n treeDefaultExpandedKeys = _React$useContext.treeDefaultExpandedKeys,\n onTreeExpand = _React$useContext.onTreeExpand,\n treeIcon = _React$useContext.treeIcon,\n showTreeIcon = _React$useContext.showTreeIcon,\n switcherIcon = _React$useContext.switcherIcon,\n treeLine = _React$useContext.treeLine,\n treeNodeFilterProp = _React$useContext.treeNodeFilterProp,\n loadData = _React$useContext.loadData,\n treeLoadedKeys = _React$useContext.treeLoadedKeys,\n treeMotion = _React$useContext.treeMotion,\n onTreeLoad = _React$useContext.onTreeLoad;\n\n var treeRef = React.useRef();\n var memoOptions = useMemo(function () {\n return options;\n }, [open, options], function (prev, next) {\n return next[0] && prev[1] !== next[1];\n });\n\n var _useKeyValueMap = useKeyValueMap(flattenOptions),\n _useKeyValueMap2 = _slicedToArray(_useKeyValueMap, 2),\n cacheKeyMap = _useKeyValueMap2[0],\n cacheValueMap = _useKeyValueMap2[1];\n\n var _useKeyValueMapping = useKeyValueMapping(cacheKeyMap, cacheValueMap),\n _useKeyValueMapping2 = _slicedToArray(_useKeyValueMapping, 2),\n getEntityByKey = _useKeyValueMapping2[0],\n getEntityByValue = _useKeyValueMapping2[1]; // ========================== Values ==========================\n\n\n var valueKeys = React.useMemo(function () {\n return checkedKeys.map(function (val) {\n var entity = getEntityByValue(val);\n return entity ? entity.key : null;\n });\n }, [checkedKeys]);\n var mergedCheckedKeys = React.useMemo(function () {\n if (!checkable) {\n return null;\n }\n\n return {\n checked: valueKeys,\n halfChecked: halfCheckedKeys\n };\n }, [valueKeys, halfCheckedKeys, checkable]); // ========================== Scroll ==========================\n\n React.useEffect(function () {\n // Single mode should scroll to current key\n if (open && !multiple && valueKeys.length) {\n var _treeRef$current;\n\n (_treeRef$current = treeRef.current) === null || _treeRef$current === void 0 ? void 0 : _treeRef$current.scrollTo({\n key: valueKeys[0]\n });\n }\n }, [open]); // ========================== Search ==========================\n\n var lowerSearchValue = String(searchValue).toLowerCase();\n\n var filterTreeNode = function filterTreeNode(treeNode) {\n if (!lowerSearchValue) {\n return false;\n }\n\n return String(treeNode[treeNodeFilterProp]).toLowerCase().includes(lowerSearchValue);\n }; // =========================== Keys ===========================\n\n\n var _React$useState = React.useState(treeDefaultExpandedKeys),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n expandedKeys = _React$useState2[0],\n setExpandedKeys = _React$useState2[1];\n\n var _React$useState3 = React.useState(null),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n searchExpandedKeys = _React$useState4[0],\n setSearchExpandedKeys = _React$useState4[1];\n\n var mergedExpandedKeys = React.useMemo(function () {\n if (treeExpandedKeys) {\n return _toConsumableArray(treeExpandedKeys);\n }\n\n return searchValue ? searchExpandedKeys : expandedKeys;\n }, [expandedKeys, searchExpandedKeys, lowerSearchValue, treeExpandedKeys]);\n React.useEffect(function () {\n if (searchValue) {\n setSearchExpandedKeys(flattenOptions.map(function (o) {\n return o.key;\n }));\n }\n }, [searchValue]);\n\n var onInternalExpand = function onInternalExpand(keys) {\n setExpandedKeys(keys);\n setSearchExpandedKeys(keys);\n\n if (onTreeExpand) {\n onTreeExpand(keys);\n }\n }; // ========================== Events ==========================\n\n\n var onListMouseDown = function onListMouseDown(event) {\n event.preventDefault();\n };\n\n var onInternalSelect = function onInternalSelect(_, _ref) {\n var key = _ref.node.key;\n var entity = getEntityByKey(key, checkable ? 'checkbox' : 'select');\n\n if (entity !== null) {\n onSelect(entity.data.value, {\n selected: !checkedKeys.includes(entity.data.value)\n });\n }\n\n if (!multiple) {\n onToggleOpen(false);\n }\n }; // ========================= Keyboard =========================\n\n\n var _React$useState5 = React.useState(null),\n _React$useState6 = _slicedToArray(_React$useState5, 2),\n activeKey = _React$useState6[0],\n setActiveKey = _React$useState6[1];\n\n var activeEntity = getEntityByKey(activeKey);\n React.useImperativeHandle(ref, function () {\n return {\n onKeyDown: function onKeyDown(event) {\n var _treeRef$current2;\n\n var which = event.which;\n\n switch (which) {\n // >>> Arrow keys\n case KeyCode.UP:\n case KeyCode.DOWN:\n case KeyCode.LEFT:\n case KeyCode.RIGHT:\n (_treeRef$current2 = treeRef.current) === null || _treeRef$current2 === void 0 ? void 0 : _treeRef$current2.onKeyDown(event);\n break;\n // >>> Select item\n\n case KeyCode.ENTER:\n {\n if (activeEntity !== null) {\n onInternalSelect(null, {\n node: {\n key: activeKey\n },\n selected: !checkedKeys.includes(activeEntity.data.value)\n });\n }\n\n break;\n }\n // >>> Close\n\n case KeyCode.ESC:\n {\n onToggleOpen(false);\n }\n }\n },\n onKeyUp: function onKeyUp() {}\n };\n }); // ========================== Render ==========================\n\n if (memoOptions.length === 0) {\n return /*#__PURE__*/React.createElement(\"div\", {\n role: \"listbox\",\n className: \"\".concat(prefixCls, \"-empty\"),\n onMouseDown: onListMouseDown\n }, notFoundContent);\n }\n\n var treeProps = {};\n\n if (treeLoadedKeys) {\n treeProps.loadedKeys = treeLoadedKeys;\n }\n\n if (mergedExpandedKeys) {\n treeProps.expandedKeys = mergedExpandedKeys;\n }\n\n return /*#__PURE__*/React.createElement(\"div\", {\n onMouseDown: onListMouseDown,\n onMouseEnter: onMouseEnter\n }, activeEntity && open && /*#__PURE__*/React.createElement(\"span\", {\n style: HIDDEN_STYLE,\n \"aria-live\": \"assertive\"\n }, activeEntity.data.value), /*#__PURE__*/React.createElement(Tree, Object.assign({\n ref: treeRef,\n focusable: false,\n prefixCls: \"\".concat(prefixCls, \"-tree\"),\n treeData: memoOptions,\n height: height,\n itemHeight: itemHeight,\n virtual: virtual,\n multiple: multiple,\n icon: treeIcon,\n showIcon: showTreeIcon,\n switcherIcon: switcherIcon,\n showLine: treeLine,\n loadData: searchValue ? null : loadData,\n motion: treeMotion,\n // We handle keys by out instead tree self\n checkable: checkable,\n checkStrictly: true,\n checkedKeys: mergedCheckedKeys,\n selectedKeys: !checkable ? valueKeys : [],\n defaultExpandAll: treeDefaultExpandAll\n }, treeProps, {\n // Proxy event out\n onActiveChange: setActiveKey,\n onSelect: onInternalSelect,\n onCheck: onInternalSelect,\n onExpand: onInternalExpand,\n onLoad: onTreeLoad,\n filterTreeNode: filterTreeNode\n })));\n};\n\nvar RefOptionList = /*#__PURE__*/React.forwardRef(OptionList);\nRefOptionList.displayName = 'OptionList';\nexport default RefOptionList;"]},"metadata":{},"sourceType":"module"}