1 line
23 KiB
JSON
1 line
23 KiB
JSON
|
{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport { useState } from 'react';\nimport classNames from 'classnames';\nimport pickAttrs from \"rc-util/es/pickAttrs\";\nimport Overflow from 'rc-overflow';\nimport TransBtn from \"../TransBtn\";\nimport Input from \"./Input\";\nimport useLayoutEffect from \"../hooks/useLayoutEffect\";\nimport { getTitle } from \"../utils/commonUtil\";\nfunction itemKey(value) {\n var _value$key;\n return (_value$key = value.key) !== null && _value$key !== void 0 ? _value$key : value.value;\n}\nvar onPreventMouseDown = function onPreventMouseDown(event) {\n event.preventDefault();\n event.stopPropagation();\n};\nvar SelectSelector = function SelectSelector(props) {\n var id = props.id,\n prefixCls = props.prefixCls,\n values = props.values,\n open = props.open,\n searchValue = props.searchValue,\n autoClearSearchValue = props.autoClearSearchValue,\n inputRef = props.inputRef,\n placeholder = props.placeholder,\n disabled = props.disabled,\n mode = props.mode,\n showSearch = props.showSearch,\n autoFocus = props.autoFocus,\n autoComplete = props.autoComplete,\n activeDescendantId = props.activeDescendantId,\n tabIndex = props.tabIndex,\n removeIcon = props.removeIcon,\n maxTagCount = props.maxTagCount,\n maxTagTextLength = props.maxTagTextLength,\n _props$maxTagPlacehol = props.maxTagPlaceholder,\n maxTagPlaceholder = _props$maxTagPlacehol === void 0 ? function (omittedValues) {\n return \"+ \".concat(omittedValues.length, \" ...\");\n } : _props$maxTagPlacehol,\n tagRender = props.tagRender,\n onToggleOpen = props.onToggleOpen,\n onRemove = props.onRemove,\n onInputChange = props.onInputChange,\n onInputPaste = props.onInputPaste,\n onInputKeyDown = props.onInputKeyDown,\n onInputMouseDown = props.onInputMouseDown,\n onInputCompositionStart = props.onInputCompositionStart,\n onInputCompositionEnd = props.onInputCompositionEnd;\n var measureRef = React.useRef(null);\n var _useState = useState(0),\n _useState2 = _slicedToArray(_useState, 2),\n inputWidth = _useState2[0],\n setInputWidth = _useState2[1];\n var _useState3 = useState(false),\n _useState4 = _slicedToArray(_useState3, 2),\n focused = _useState4[0],\n setFocused = _useState4[1];\n var selectionPrefixCls = \"\".concat(prefixCls, \"-selection\");\n\n // ===================== Search ======================\n var inputValue = open || mode === 'multiple' && autoClearSearchValue === false || mode === 'tags' ? searchValue : '';\n var inputEditable = mode === 'tags' || mode === 'multiple' && autoClearSearchValue === false || showSearch && (open || focused);\n\n // We measure width and set to the input immediately\n useLayoutEffect(function () {\n setInputWidth(measureRef.current.scrollWidth);\n }, [inputValue]);\n\n // ===================== Render ======================\n // >>> Render Selector Node. Includes Item & Rest\n var defaultRenderSelector = function defaultRenderSelector(item, content, itemDisabled, closable, onClose) {\n return /*#__PURE__*/React.createElement(\"span\", {\n title: getTitle(item),\n className: classNames(\"\".concat(selectionPrefixCls, \"-item\"), _defineProperty({}, \"\".concat(selectionPrefixCls, \"-item-disabled\"), itemDisabled))\n }, /*#__PURE__*/React.createElement(\"span\", {\n className: \"\".concat(selectionPrefixCls, \"-item-content\")\n }, content), closable && /*#__PURE__*/React.createElement(TransBtn, {\n className: \"\".concat(selectionPrefixCls, \"-item-remove\"),\n onMouseDown: onPreventMouseDown,\n onClick: onClose,\n customizeIcon: removeIcon\n }, \"\\xD7\"));\n };\n var customizeRenderSelector = function customizeRenderSelector(value, content, itemDisabled, closable, onClose, isMaxTag) {\n var onMouseDown = function onMouseDown(e) {\n onPreventMouseDown(e);
|