(props)
| 39 | }; |
| 40 | |
| 41 | const SelectSelector: React.FC<SelectorProps> = (props) => { |
| 42 | const { |
| 43 | id, |
| 44 | prefixCls, |
| 45 | |
| 46 | values, |
| 47 | open, |
| 48 | searchValue, |
| 49 | autoClearSearchValue, |
| 50 | inputRef, |
| 51 | placeholder, |
| 52 | disabled, |
| 53 | mode, |
| 54 | showSearch, |
| 55 | autoFocus, |
| 56 | autoComplete, |
| 57 | activeDescendantId, |
| 58 | tabIndex, |
| 59 | |
| 60 | removeIcon, |
| 61 | |
| 62 | maxTagCount, |
| 63 | maxTagTextLength, |
| 64 | maxTagPlaceholder = (omittedValues: DisplayValueType[]) => `+ ${omittedValues.length} ...`, |
| 65 | tagRender, |
| 66 | onToggleOpen, |
| 67 | |
| 68 | onRemove, |
| 69 | onInputChange, |
| 70 | onInputPaste, |
| 71 | onInputKeyDown, |
| 72 | onInputMouseDown, |
| 73 | onInputCompositionStart, |
| 74 | onInputCompositionEnd, |
| 75 | onInputBlur, |
| 76 | } = props; |
| 77 | |
| 78 | const measureRef = React.useRef<HTMLSpanElement>(null); |
| 79 | const [inputWidth, setInputWidth] = useState(0); |
| 80 | const [focused, setFocused] = useState(false); |
| 81 | |
| 82 | const selectionPrefixCls = `${prefixCls}-selection`; |
| 83 | |
| 84 | // ===================== Search ====================== |
| 85 | const inputValue = |
| 86 | open || (mode === 'multiple' && autoClearSearchValue === false) || mode === 'tags' |
| 87 | ? searchValue |
| 88 | : ''; |
| 89 | const inputEditable: boolean = |
| 90 | mode === 'tags' || |
| 91 | (mode === 'multiple' && autoClearSearchValue === false) || |
| 92 | (showSearch && (open || focused)); |
| 93 | |
| 94 | // We measure width and set to the input immediately |
| 95 | useLayoutEffect(() => { |
| 96 | setInputWidth(measureRef.current.scrollWidth); |
| 97 | }, [inputValue]); |
| 98 |
nothing calls this directly
no test coverage detected
searching dependent graphs…