1 line
43 KiB
JSON
1 line
43 KiB
JSON
|
{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nvar _excluded = [\"disabled\", \"title\", \"children\", \"style\", \"className\"];\nimport classNames from 'classnames';\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport useMemo from \"rc-util/es/hooks/useMemo\";\nimport omit from \"rc-util/es/omit\";\nimport pickAttrs from \"rc-util/es/pickAttrs\";\nimport List from 'rc-virtual-list';\nimport * as React from 'react';\nimport { useEffect } from 'react';\nimport SelectContext from \"./SelectContext\";\nimport TransBtn from \"./TransBtn\";\nimport useBaseProps from \"./hooks/useBaseProps\";\nimport { isPlatformMac } from \"./utils/platformUtil\";\nimport { isValidCount } from \"./utils/valueUtil\";\n\n// export interface OptionListProps<OptionsType extends object[]> {\n\nfunction isTitleType(content) {\n return typeof content === 'string' || typeof content === 'number';\n}\n\n/**\n * Using virtual list of option display.\n * Will fallback to dom if use customize render.\n */\nvar OptionList = function OptionList(_, ref) {\n var _useBaseProps = useBaseProps(),\n prefixCls = _useBaseProps.prefixCls,\n id = _useBaseProps.id,\n open = _useBaseProps.open,\n multiple = _useBaseProps.multiple,\n mode = _useBaseProps.mode,\n searchValue = _useBaseProps.searchValue,\n toggleOpen = _useBaseProps.toggleOpen,\n notFoundContent = _useBaseProps.notFoundContent,\n onPopupScroll = _useBaseProps.onPopupScroll;\n var _React$useContext = React.useContext(SelectContext),\n maxCount = _React$useContext.maxCount,\n flattenOptions = _React$useContext.flattenOptions,\n onActiveValue = _React$useContext.onActiveValue,\n defaultActiveFirstOption = _React$useContext.defaultActiveFirstOption,\n onSelect = _React$useContext.onSelect,\n menuItemSelectedIcon = _React$useContext.menuItemSelectedIcon,\n rawValues = _React$useContext.rawValues,\n fieldNames = _React$useContext.fieldNames,\n virtual = _React$useContext.virtual,\n direction = _React$useContext.direction,\n listHeight = _React$useContext.listHeight,\n listItemHeight = _React$useContext.listItemHeight,\n optionRender = _React$useContext.optionRender;\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 });\n\n // =========================== List ===========================\n var listRef = React.useRef(null);\n var overMaxCount = React.useMemo(function () {\n return multiple && isValidCount(maxCount) && (rawValues === null || rawValues === void 0 ? void 0 : rawValues.size) >= maxCount;\n }, [multiple, maxCount, rawValues === null || rawValues === void 0 ? void 0 : rawValues.size]);\n var onListMouseDown = function onListMouseDown(event) {\n event.preventDefault();\n };\n var scrollIntoView = function scrollIntoView(args) {\n var _listRef$current;\n (_listRef$current = listRef.current) === null || _listRef$current === void 0 || _listRef$current.scrollTo(typeof args === 'number' ? {\n index: args\n } : args);\n };\n\n // ========================== Active ==========================\n var getEnabledActiveIndex = function getEnabledActiveIndex(index) {\n var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;\n var len = memoFlattenOptions.length;\n for (var i = 0; i < len; i += 1) {\n var current = (index + i * offset + len) % len;\n var _ref = memoFlattenOptions[current] || {},\n group = _ref.group,\n data = _ref.data;\n if (!group && !(data !== null && data !== void 0 && data.disabled) && !overMaxCo
|