66fd1ea4defd62bdd00be93975deefa6.json
33.9 KB
{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport pickAttrs from \"rc-util/es/pickAttrs\";\nimport useMemo from \"rc-util/es/hooks/useMemo\";\nimport classNames from 'classnames';\nimport List from 'rc-virtual-list';\nimport TransBtn from './TransBtn';\n/**\n * Using virtual list of option display.\n * Will fallback to dom if use customize render.\n */\n\nvar OptionList = function OptionList(_ref, ref) {\n var prefixCls = _ref.prefixCls,\n id = _ref.id,\n flattenOptions = _ref.flattenOptions,\n childrenAsData = _ref.childrenAsData,\n values = _ref.values,\n searchValue = _ref.searchValue,\n multiple = _ref.multiple,\n defaultActiveFirstOption = _ref.defaultActiveFirstOption,\n height = _ref.height,\n itemHeight = _ref.itemHeight,\n notFoundContent = _ref.notFoundContent,\n open = _ref.open,\n menuItemSelectedIcon = _ref.menuItemSelectedIcon,\n virtual = _ref.virtual,\n onSelect = _ref.onSelect,\n onToggleOpen = _ref.onToggleOpen,\n onActiveValue = _ref.onActiveValue,\n onScroll = _ref.onScroll,\n onMouseEnter = _ref.onMouseEnter;\n var itemPrefixCls = \"\".concat(prefixCls, \"-item\");\n var memoFlattenOptions = useMemo(function () {\n return flattenOptions;\n }, [open, flattenOptions], function (prev, next) {\n return next[0] && prev[1] !== next[1];\n }); // =========================== List ===========================\n\n var listRef = React.useRef(null);\n\n var onListMouseDown = function onListMouseDown(event) {\n event.preventDefault();\n };\n\n var scrollIntoView = function scrollIntoView(index) {\n if (listRef.current) {\n listRef.current.scrollTo({\n index: index\n });\n }\n }; // ========================== Active ==========================\n\n\n var getEnabledActiveIndex = function getEnabledActiveIndex(index) {\n var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;\n var len = memoFlattenOptions.length;\n\n for (var i = 0; i < len; i += 1) {\n var current = (index + i * offset + len) % len;\n var _memoFlattenOptions$c = memoFlattenOptions[current],\n group = _memoFlattenOptions$c.group,\n data = _memoFlattenOptions$c.data;\n\n if (!group && !data.disabled) {\n return current;\n }\n }\n\n return -1;\n };\n\n var _React$useState = React.useState(function () {\n return getEnabledActiveIndex(0);\n }),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n activeIndex = _React$useState2[0],\n setActiveIndex = _React$useState2[1];\n\n var setActive = function setActive(index) {\n var fromKeyboard = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n setActiveIndex(index);\n var info = {\n source: fromKeyboard ? 'keyboard' : 'mouse'\n }; // Trigger active event\n\n var flattenItem = memoFlattenOptions[index];\n\n if (!flattenItem) {\n onActiveValue(null, -1, info);\n return;\n }\n\n onActiveValue(flattenItem.data.value, index, info);\n }; // Auto active first item when list length or searchValue changed\n\n\n React.useEffect(function () {\n setActive(defaultActiveFirstOption !== false ? getEnabledActiveIndex(0) : -1);\n }, [memoFlattenOptions.length, searchValue]); // Auto scroll to item position in single mode\n\n React.useEffect(function () {\n /**\n * React will skip `onChange` when component update.\n * `setActive` function will call root accessibility state update which makes re-render.\n * So we need to delay to let Input component trigger onChange first.\n */\n var timeoutId = setTimeout(function () {\n if (!multiple && open && values.size === 1) {\n var value = Array.from(values)[0];\n var index = memoFlattenOptions.findIndex(function (_ref2) {\n var data = _ref2.data;\n return data.value === value;\n });\n setActive(index);\n scrollIntoView(index);\n }\n }); // Force trigger scrollbar visible when open\n\n if (open) {\n var _listRef$current;\n\n (_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.scrollTo(undefined);\n }\n\n return function () {\n return clearTimeout(timeoutId);\n };\n }, [open]); // ========================== Values ==========================\n\n var onSelectValue = function onSelectValue(value) {\n if (value !== undefined) {\n onSelect(value, {\n selected: !values.has(value)\n });\n } // Single mode should always close by select\n\n\n if (!multiple) {\n onToggleOpen(false);\n }\n }; // ========================= Keyboard =========================\n\n\n React.useImperativeHandle(ref, function () {\n return {\n onKeyDown: function onKeyDown(event) {\n var which = event.which;\n\n switch (which) {\n // >>> Arrow keys\n case KeyCode.UP:\n case KeyCode.DOWN:\n {\n var offset = 0;\n\n if (which === KeyCode.UP) {\n offset = -1;\n } else if (which === KeyCode.DOWN) {\n offset = 1;\n }\n\n if (offset !== 0) {\n var nextActiveIndex = getEnabledActiveIndex(activeIndex + offset, offset);\n scrollIntoView(nextActiveIndex);\n setActive(nextActiveIndex, true);\n }\n\n break;\n }\n // >>> Select\n\n case KeyCode.ENTER:\n {\n // value\n var item = memoFlattenOptions[activeIndex];\n\n if (item && !item.data.disabled) {\n onSelectValue(item.data.value);\n } else {\n onSelectValue(undefined);\n }\n\n if (open) {\n event.preventDefault();\n }\n\n break;\n }\n // >>> Close\n\n case KeyCode.ESC:\n {\n onToggleOpen(false);\n }\n }\n },\n onKeyUp: function onKeyUp() {},\n scrollTo: function scrollTo(index) {\n scrollIntoView(index);\n }\n };\n }); // ========================== Render ==========================\n\n if (memoFlattenOptions.length === 0) {\n return React.createElement(\"div\", {\n role: \"listbox\",\n id: \"\".concat(id, \"_list\"),\n className: \"\".concat(itemPrefixCls, \"-empty\"),\n onMouseDown: onListMouseDown\n }, notFoundContent);\n }\n\n function renderItem(index) {\n var item = memoFlattenOptions[index];\n if (!item) return null;\n var itemData = item.data || {};\n var value = itemData.value,\n label = itemData.label,\n children = itemData.children;\n var attrs = pickAttrs(itemData, true);\n var mergedLabel = childrenAsData ? children : label;\n return item ? React.createElement(\"div\", Object.assign({\n \"aria-label\": typeof mergedLabel === 'string' ? mergedLabel : null\n }, attrs, {\n key: index,\n role: \"option\",\n id: \"\".concat(id, \"_list_\").concat(index),\n \"aria-selected\": values.has(value)\n }), value) : null;\n }\n\n return React.createElement(React.Fragment, null, React.createElement(\"div\", {\n role: \"listbox\",\n id: \"\".concat(id, \"_list\"),\n style: {\n height: 0,\n width: 0,\n overflow: 'hidden'\n }\n }, renderItem(activeIndex - 1), renderItem(activeIndex), renderItem(activeIndex + 1)), React.createElement(List, {\n itemKey: \"key\",\n ref: listRef,\n data: memoFlattenOptions,\n height: height,\n itemHeight: itemHeight,\n fullHeight: false,\n onMouseDown: onListMouseDown,\n onScroll: onScroll,\n virtual: virtual,\n onMouseEnter: onMouseEnter\n }, function (_ref3, itemIndex) {\n var _classNames;\n\n var group = _ref3.group,\n groupOption = _ref3.groupOption,\n data = _ref3.data;\n var label = data.label,\n key = data.key; // Group\n\n if (group) {\n return React.createElement(\"div\", {\n className: classNames(itemPrefixCls, \"\".concat(itemPrefixCls, \"-group\"))\n }, label !== undefined ? label : key);\n }\n\n var disabled = data.disabled,\n value = data.value,\n title = data.title,\n children = data.children,\n style = data.style,\n className = data.className,\n otherProps = _objectWithoutProperties(data, [\"disabled\", \"value\", \"title\", \"children\", \"style\", \"className\"]); // Option\n\n\n var selected = values.has(value);\n var optionPrefixCls = \"\".concat(itemPrefixCls, \"-option\");\n var optionClassName = classNames(itemPrefixCls, optionPrefixCls, className, (_classNames = {}, _defineProperty(_classNames, \"\".concat(optionPrefixCls, \"-grouped\"), groupOption), _defineProperty(_classNames, \"\".concat(optionPrefixCls, \"-active\"), activeIndex === itemIndex && !disabled), _defineProperty(_classNames, \"\".concat(optionPrefixCls, \"-disabled\"), disabled), _defineProperty(_classNames, \"\".concat(optionPrefixCls, \"-selected\"), selected), _classNames));\n var mergedLabel = childrenAsData ? children : label;\n var iconVisible = !menuItemSelectedIcon || typeof menuItemSelectedIcon === 'function' || selected;\n var content = mergedLabel || value; // https://github.com/ant-design/ant-design/issues/26717\n\n var optionTitle = typeof content === 'string' || typeof content === 'number' ? content.toString() : undefined;\n\n if (title !== undefined) {\n optionTitle = title;\n }\n\n return React.createElement(\"div\", Object.assign({}, otherProps, {\n \"aria-selected\": selected,\n className: optionClassName,\n title: optionTitle,\n onMouseMove: function onMouseMove() {\n if (activeIndex === itemIndex || disabled) {\n return;\n }\n\n setActive(itemIndex);\n },\n onClick: function onClick() {\n if (!disabled) {\n onSelectValue(value);\n }\n },\n style: style\n }), React.createElement(\"div\", {\n className: \"\".concat(optionPrefixCls, \"-content\")\n }, content), React.isValidElement(menuItemSelectedIcon) || selected, iconVisible && React.createElement(TransBtn, {\n className: \"\".concat(itemPrefixCls, \"-option-state\"),\n customizeIcon: menuItemSelectedIcon,\n customizeIconProps: {\n isSelected: selected\n }\n }, selected ? '✓' : null));\n }));\n};\n\nvar RefOptionList = React.forwardRef(OptionList);\nRefOptionList.displayName = 'OptionList';\nexport default RefOptionList;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-select/es/OptionList.js"],"names":["_defineProperty","_objectWithoutProperties","_slicedToArray","React","KeyCode","pickAttrs","useMemo","classNames","List","TransBtn","OptionList","_ref","ref","prefixCls","id","flattenOptions","childrenAsData","values","searchValue","multiple","defaultActiveFirstOption","height","itemHeight","notFoundContent","open","menuItemSelectedIcon","virtual","onSelect","onToggleOpen","onActiveValue","onScroll","onMouseEnter","itemPrefixCls","concat","memoFlattenOptions","prev","next","listRef","useRef","onListMouseDown","event","preventDefault","scrollIntoView","index","current","scrollTo","getEnabledActiveIndex","offset","arguments","length","undefined","len","i","_memoFlattenOptions$c","group","data","disabled","_React$useState","useState","_React$useState2","activeIndex","setActiveIndex","setActive","fromKeyboard","info","source","flattenItem","value","useEffect","timeoutId","setTimeout","size","Array","from","findIndex","_ref2","_listRef$current","clearTimeout","onSelectValue","selected","has","useImperativeHandle","onKeyDown","which","UP","DOWN","nextActiveIndex","ENTER","item","ESC","onKeyUp","createElement","role","className","onMouseDown","renderItem","itemData","label","children","attrs","mergedLabel","Object","assign","key","Fragment","style","width","overflow","itemKey","fullHeight","_ref3","itemIndex","_classNames","groupOption","title","otherProps","optionPrefixCls","optionClassName","iconVisible","content","optionTitle","toString","onMouseMove","onClick","isValidElement","customizeIcon","customizeIconProps","isSelected","RefOptionList","forwardRef","displayName"],"mappings":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G;AAGhHqG,MAAAA,kBAAkB,EAAE;AAClBC,QAAAA,UAAU,EAAEhD;AADM;AAH4F,KAA9B,EAMjFA,QAAQ,GAAG,GAAH,GAAS,IANgE,CAnB7E,CAAP;AA0BD,GA1EsF,CARhF,CAAP;AAmFD,CA/SD;;AAiTA,IAAIiD,aAAa,GAAG7H,KAAK,CAAC8H,UAAN,CAAiBvH,UAAjB,CAApB;AACAsH,aAAa,CAACE,WAAd,GAA4B,YAA5B;AACA,eAAeF,aAAf","sourcesContent":["import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport pickAttrs from \"rc-util/es/pickAttrs\";\nimport useMemo from \"rc-util/es/hooks/useMemo\";\nimport classNames from 'classnames';\nimport List from 'rc-virtual-list';\nimport TransBtn from './TransBtn';\n/**\n * Using virtual list of option display.\n * Will fallback to dom if use customize render.\n */\n\nvar OptionList = function OptionList(_ref, ref) {\n var prefixCls = _ref.prefixCls,\n id = _ref.id,\n flattenOptions = _ref.flattenOptions,\n childrenAsData = _ref.childrenAsData,\n values = _ref.values,\n searchValue = _ref.searchValue,\n multiple = _ref.multiple,\n defaultActiveFirstOption = _ref.defaultActiveFirstOption,\n height = _ref.height,\n itemHeight = _ref.itemHeight,\n notFoundContent = _ref.notFoundContent,\n open = _ref.open,\n menuItemSelectedIcon = _ref.menuItemSelectedIcon,\n virtual = _ref.virtual,\n onSelect = _ref.onSelect,\n onToggleOpen = _ref.onToggleOpen,\n onActiveValue = _ref.onActiveValue,\n onScroll = _ref.onScroll,\n onMouseEnter = _ref.onMouseEnter;\n var itemPrefixCls = \"\".concat(prefixCls, \"-item\");\n var memoFlattenOptions = useMemo(function () {\n return flattenOptions;\n }, [open, flattenOptions], function (prev, next) {\n return next[0] && prev[1] !== next[1];\n }); // =========================== List ===========================\n\n var listRef = React.useRef(null);\n\n var onListMouseDown = function onListMouseDown(event) {\n event.preventDefault();\n };\n\n var scrollIntoView = function scrollIntoView(index) {\n if (listRef.current) {\n listRef.current.scrollTo({\n index: index\n });\n }\n }; // ========================== Active ==========================\n\n\n var getEnabledActiveIndex = function getEnabledActiveIndex(index) {\n var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;\n var len = memoFlattenOptions.length;\n\n for (var i = 0; i < len; i += 1) {\n var current = (index + i * offset + len) % len;\n var _memoFlattenOptions$c = memoFlattenOptions[current],\n group = _memoFlattenOptions$c.group,\n data = _memoFlattenOptions$c.data;\n\n if (!group && !data.disabled) {\n return current;\n }\n }\n\n return -1;\n };\n\n var _React$useState = React.useState(function () {\n return getEnabledActiveIndex(0);\n }),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n activeIndex = _React$useState2[0],\n setActiveIndex = _React$useState2[1];\n\n var setActive = function setActive(index) {\n var fromKeyboard = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n setActiveIndex(index);\n var info = {\n source: fromKeyboard ? 'keyboard' : 'mouse'\n }; // Trigger active event\n\n var flattenItem = memoFlattenOptions[index];\n\n if (!flattenItem) {\n onActiveValue(null, -1, info);\n return;\n }\n\n onActiveValue(flattenItem.data.value, index, info);\n }; // Auto active first item when list length or searchValue changed\n\n\n React.useEffect(function () {\n setActive(defaultActiveFirstOption !== false ? getEnabledActiveIndex(0) : -1);\n }, [memoFlattenOptions.length, searchValue]); // Auto scroll to item position in single mode\n\n React.useEffect(function () {\n /**\n * React will skip `onChange` when component update.\n * `setActive` function will call root accessibility state update which makes re-render.\n * So we need to delay to let Input component trigger onChange first.\n */\n var timeoutId = setTimeout(function () {\n if (!multiple && open && values.size === 1) {\n var value = Array.from(values)[0];\n var index = memoFlattenOptions.findIndex(function (_ref2) {\n var data = _ref2.data;\n return data.value === value;\n });\n setActive(index);\n scrollIntoView(index);\n }\n }); // Force trigger scrollbar visible when open\n\n if (open) {\n var _listRef$current;\n\n (_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.scrollTo(undefined);\n }\n\n return function () {\n return clearTimeout(timeoutId);\n };\n }, [open]); // ========================== Values ==========================\n\n var onSelectValue = function onSelectValue(value) {\n if (value !== undefined) {\n onSelect(value, {\n selected: !values.has(value)\n });\n } // Single mode should always close by select\n\n\n if (!multiple) {\n onToggleOpen(false);\n }\n }; // ========================= Keyboard =========================\n\n\n React.useImperativeHandle(ref, function () {\n return {\n onKeyDown: function onKeyDown(event) {\n var which = event.which;\n\n switch (which) {\n // >>> Arrow keys\n case KeyCode.UP:\n case KeyCode.DOWN:\n {\n var offset = 0;\n\n if (which === KeyCode.UP) {\n offset = -1;\n } else if (which === KeyCode.DOWN) {\n offset = 1;\n }\n\n if (offset !== 0) {\n var nextActiveIndex = getEnabledActiveIndex(activeIndex + offset, offset);\n scrollIntoView(nextActiveIndex);\n setActive(nextActiveIndex, true);\n }\n\n break;\n }\n // >>> Select\n\n case KeyCode.ENTER:\n {\n // value\n var item = memoFlattenOptions[activeIndex];\n\n if (item && !item.data.disabled) {\n onSelectValue(item.data.value);\n } else {\n onSelectValue(undefined);\n }\n\n if (open) {\n event.preventDefault();\n }\n\n break;\n }\n // >>> Close\n\n case KeyCode.ESC:\n {\n onToggleOpen(false);\n }\n }\n },\n onKeyUp: function onKeyUp() {},\n scrollTo: function scrollTo(index) {\n scrollIntoView(index);\n }\n };\n }); // ========================== Render ==========================\n\n if (memoFlattenOptions.length === 0) {\n return React.createElement(\"div\", {\n role: \"listbox\",\n id: \"\".concat(id, \"_list\"),\n className: \"\".concat(itemPrefixCls, \"-empty\"),\n onMouseDown: onListMouseDown\n }, notFoundContent);\n }\n\n function renderItem(index) {\n var item = memoFlattenOptions[index];\n if (!item) return null;\n var itemData = item.data || {};\n var value = itemData.value,\n label = itemData.label,\n children = itemData.children;\n var attrs = pickAttrs(itemData, true);\n var mergedLabel = childrenAsData ? children : label;\n return item ? React.createElement(\"div\", Object.assign({\n \"aria-label\": typeof mergedLabel === 'string' ? mergedLabel : null\n }, attrs, {\n key: index,\n role: \"option\",\n id: \"\".concat(id, \"_list_\").concat(index),\n \"aria-selected\": values.has(value)\n }), value) : null;\n }\n\n return React.createElement(React.Fragment, null, React.createElement(\"div\", {\n role: \"listbox\",\n id: \"\".concat(id, \"_list\"),\n style: {\n height: 0,\n width: 0,\n overflow: 'hidden'\n }\n }, renderItem(activeIndex - 1), renderItem(activeIndex), renderItem(activeIndex + 1)), React.createElement(List, {\n itemKey: \"key\",\n ref: listRef,\n data: memoFlattenOptions,\n height: height,\n itemHeight: itemHeight,\n fullHeight: false,\n onMouseDown: onListMouseDown,\n onScroll: onScroll,\n virtual: virtual,\n onMouseEnter: onMouseEnter\n }, function (_ref3, itemIndex) {\n var _classNames;\n\n var group = _ref3.group,\n groupOption = _ref3.groupOption,\n data = _ref3.data;\n var label = data.label,\n key = data.key; // Group\n\n if (group) {\n return React.createElement(\"div\", {\n className: classNames(itemPrefixCls, \"\".concat(itemPrefixCls, \"-group\"))\n }, label !== undefined ? label : key);\n }\n\n var disabled = data.disabled,\n value = data.value,\n title = data.title,\n children = data.children,\n style = data.style,\n className = data.className,\n otherProps = _objectWithoutProperties(data, [\"disabled\", \"value\", \"title\", \"children\", \"style\", \"className\"]); // Option\n\n\n var selected = values.has(value);\n var optionPrefixCls = \"\".concat(itemPrefixCls, \"-option\");\n var optionClassName = classNames(itemPrefixCls, optionPrefixCls, className, (_classNames = {}, _defineProperty(_classNames, \"\".concat(optionPrefixCls, \"-grouped\"), groupOption), _defineProperty(_classNames, \"\".concat(optionPrefixCls, \"-active\"), activeIndex === itemIndex && !disabled), _defineProperty(_classNames, \"\".concat(optionPrefixCls, \"-disabled\"), disabled), _defineProperty(_classNames, \"\".concat(optionPrefixCls, \"-selected\"), selected), _classNames));\n var mergedLabel = childrenAsData ? children : label;\n var iconVisible = !menuItemSelectedIcon || typeof menuItemSelectedIcon === 'function' || selected;\n var content = mergedLabel || value; // https://github.com/ant-design/ant-design/issues/26717\n\n var optionTitle = typeof content === 'string' || typeof content === 'number' ? content.toString() : undefined;\n\n if (title !== undefined) {\n optionTitle = title;\n }\n\n return React.createElement(\"div\", Object.assign({}, otherProps, {\n \"aria-selected\": selected,\n className: optionClassName,\n title: optionTitle,\n onMouseMove: function onMouseMove() {\n if (activeIndex === itemIndex || disabled) {\n return;\n }\n\n setActive(itemIndex);\n },\n onClick: function onClick() {\n if (!disabled) {\n onSelectValue(value);\n }\n },\n style: style\n }), React.createElement(\"div\", {\n className: \"\".concat(optionPrefixCls, \"-content\")\n }, content), React.isValidElement(menuItemSelectedIcon) || selected, iconVisible && React.createElement(TransBtn, {\n className: \"\".concat(itemPrefixCls, \"-option-state\"),\n customizeIcon: menuItemSelectedIcon,\n customizeIconProps: {\n isSelected: selected\n }\n }, selected ? '✓' : null));\n }));\n};\n\nvar RefOptionList = React.forwardRef(OptionList);\nRefOptionList.displayName = 'OptionList';\nexport default RefOptionList;"]},"metadata":{},"sourceType":"module"}