PromoCursed/node_modules/.cache/babel-loader/de0e4db06a4b690ee02582c07a455c9dc3db6f1d480d9a535214ec7442df3e81.json

1 line
12 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport pickAttrs from \"rc-util/es/pickAttrs\";\nimport Input from \"./Input\";\nimport { getTitle } from \"../utils/commonUtil\";\nvar SingleSelector = function SingleSelector(props) {\n var inputElement = props.inputElement,\n prefixCls = props.prefixCls,\n id = props.id,\n inputRef = props.inputRef,\n disabled = props.disabled,\n autoFocus = props.autoFocus,\n autoComplete = props.autoComplete,\n activeDescendantId = props.activeDescendantId,\n mode = props.mode,\n open = props.open,\n values = props.values,\n placeholder = props.placeholder,\n tabIndex = props.tabIndex,\n showSearch = props.showSearch,\n searchValue = props.searchValue,\n activeValue = props.activeValue,\n maxLength = props.maxLength,\n onInputKeyDown = props.onInputKeyDown,\n onInputMouseDown = props.onInputMouseDown,\n onInputChange = props.onInputChange,\n onInputPaste = props.onInputPaste,\n onInputCompositionStart = props.onInputCompositionStart,\n onInputCompositionEnd = props.onInputCompositionEnd,\n title = props.title;\n var _React$useState = React.useState(false),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n inputChanged = _React$useState2[0],\n setInputChanged = _React$useState2[1];\n var combobox = mode === 'combobox';\n var inputEditable = combobox || showSearch;\n var item = values[0];\n var inputValue = searchValue || '';\n if (combobox && activeValue && !inputChanged) {\n inputValue = activeValue;\n }\n React.useEffect(function () {\n if (combobox) {\n setInputChanged(false);\n }\n }, [combobox, activeValue]);\n\n // Not show text when closed expect combobox mode\n var hasTextInput = mode !== 'combobox' && !open && !showSearch ? false : !!inputValue;\n\n // Get title of selection item\n var selectionTitle = title === undefined ? getTitle(item) : title;\n var placeholderNode = React.useMemo(function () {\n if (item) {\n return null;\n }\n return /*#__PURE__*/React.createElement(\"span\", {\n className: \"\".concat(prefixCls, \"-selection-placeholder\"),\n style: hasTextInput ? {\n visibility: 'hidden'\n } : undefined\n }, placeholder);\n }, [item, hasTextInput, placeholder, prefixCls]);\n return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(\"span\", {\n className: \"\".concat(prefixCls, \"-selection-search\")\n }, /*#__PURE__*/React.createElement(Input, {\n ref: inputRef,\n prefixCls: prefixCls,\n id: id,\n open: open,\n inputElement: inputElement,\n disabled: disabled,\n autoFocus: autoFocus,\n autoComplete: autoComplete,\n editable: inputEditable,\n activeDescendantId: activeDescendantId,\n value: inputValue,\n onKeyDown: onInputKeyDown,\n onMouseDown: onInputMouseDown,\n onChange: function onChange(e) {\n setInputChanged(true);\n onInputChange(e);\n },\n onPaste: onInputPaste,\n onCompositionStart: onInputCompositionStart,\n onCompositionEnd: onInputCompositionEnd,\n tabIndex: tabIndex,\n attrs: pickAttrs(props, true),\n maxLength: combobox ? maxLength : undefined\n })), !combobox && item ? /*#__PURE__*/React.createElement(\"span\", {\n className: \"\".concat(prefixCls, \"-selection-item\"),\n title: selectionTitle\n // 当 Select 已经选中选项时,还需 selection 隐藏但留在原地占位\n // https://github.com/ant-design/ant-design/issues/27688\n // https://github.com/ant-design/ant-design/issues/41530\n ,\n\n style: hasTextInput ? {\n visibility: 'hidden'\n } : undefined\n }, item.label) : null, placeholderNode);\n};\nexport default SingleSelector;","map":{"version":3,"names":["_slicedToArray","React","pickAttrs","Input","getTitle","SingleSelector","props","inputElement","prefixCls","id","inputRef","disabled","autoFocus","autoComplete","activeDescendantId","mode","open","values","placeho