@rescui/select 0.15.0 → 0.15.1-RUI-280-Update-select-component-e516591ed.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_virtual/index.css.js +12 -12
- package/lib/common-prop-types.d.ts +9 -14
- package/lib/common-prop-types.js +4 -3
- package/lib/constants.d.ts +7 -0
- package/lib/constants.js +8 -0
- package/lib/hooks/use-css-context-transfer.d.ts +14 -0
- package/lib/hooks/use-css-context-transfer.js +40 -0
- package/lib/hooks/use-label-focus.d.ts +11 -0
- package/lib/hooks/use-label-focus.js +28 -0
- package/lib/hooks/use-multi-option-serialization.d.ts +10 -0
- package/lib/hooks/use-multi-option-serialization.js +82 -0
- package/lib/hooks/use-option-serialization.d.ts +10 -0
- package/lib/hooks/use-option-serialization.js +59 -0
- package/lib/index.css +2004 -837
- package/lib/index.d.ts +4 -6
- package/lib/index.js +3 -3
- package/lib/multiselect.d.ts +29 -0
- package/lib/multiselect.js +239 -0
- package/lib/native-select.d.ts +4 -0
- package/lib/native-select.js +182 -0
- package/lib/parts/foldable.js +5 -7
- package/lib/parts/form-trigger-wrapper.d.ts +7 -7
- package/lib/parts/form-trigger-wrapper.js +16 -34
- package/lib/parts/icons.d.ts +17 -0
- package/lib/parts/icons.js +75 -0
- package/lib/parts/list-box.d.ts +19 -0
- package/lib/parts/list-box.js +146 -0
- package/lib/parts/multi-trigger.d.ts +11 -0
- package/lib/parts/multi-trigger.js +62 -0
- package/lib/parts/native-select-options-with-groups.d.ts +8 -0
- package/lib/parts/native-select-options-with-groups.js +76 -0
- package/lib/parts/native-select-trigger.d.ts +18 -0
- package/lib/parts/native-select-trigger.js +54 -0
- package/lib/parts/popover.d.ts +12 -0
- package/lib/parts/popover.js +62 -0
- package/lib/parts/popup-content.d.ts +19 -0
- package/lib/parts/popup-content.js +76 -0
- package/lib/public-api.p.css +486 -444
- package/lib/public-api.pcss +486 -444
- package/lib/select-basic.d.ts +3 -0
- package/lib/select-basic.js +143 -0
- package/lib/select-searchable.d.ts +3 -0
- package/lib/select-searchable.js +168 -0
- package/lib/select.d.ts +27 -91
- package/lib/select.js +53 -360
- package/lib/styles/common.p.module.css.js +27 -0
- package/lib/styles/form-trigger.p.module.css.js +15 -0
- package/lib/styles/list-box.p.module.css.js +16 -0
- package/lib/styles/native-select-trigger.p.module.css.js +17 -0
- package/lib/styles/native-select.p.module.css.js +9 -0
- package/lib/styles/popover.p.module.css.js +10 -0
- package/lib/types.d.ts +167 -4
- package/lib/utils/calculate-max-height-by-items.d.ts +13 -0
- package/lib/utils/calculate-max-height-by-items.js +22 -0
- package/lib/utils/convert-options.d.ts +3 -0
- package/lib/utils/convert-options.js +52 -0
- package/lib/utils/convert-placement.d.ts +3 -0
- package/lib/utils/convert-placement.js +22 -0
- package/lib/utils/css-vars-utils.d.ts +3 -0
- package/lib/utils/css-vars-utils.js +20 -0
- package/lib/utils/get-empty-message.d.ts +6 -0
- package/lib/utils/get-empty-message.js +32 -0
- package/lib/utils/get-option-value.d.ts +2 -0
- package/lib/utils/get-option-value.js +11 -0
- package/lib/utils/get-real-items-cnt.d.ts +2 -0
- package/lib/utils/get-real-items-cnt.js +21 -0
- package/lib/utils/get-text-from-nodes.d.ts +2 -0
- package/lib/utils/get-text-from-nodes.js +28 -0
- package/lib/utils/is-option-a-group.d.ts +2 -0
- package/lib/utils/is-option-a-group.js +5 -0
- package/lib/utils/throttle.d.ts +1 -0
- package/package.json +11 -12
- package/lib/key-codes.d.ts +0 -7
- package/lib/key-codes.js +0 -8
- package/lib/parts/common-select.p.module.css.js +0 -15
- package/lib/parts/form-trigger.p.module.css.js +0 -15
- package/lib/parts/multiselect.d.ts +0 -86
- package/lib/parts/multiselect.js +0 -455
- package/lib/parts/native-select.d.ts +0 -36
- package/lib/parts/native-select.js +0 -257
- package/lib/parts/native-select.p.module.css.js +0 -9
- package/lib/parts/throttle.d.ts +0 -1
- package/lib/parts/trigger.d.ts +0 -37
- package/lib/parts/trigger.js +0 -255
- package/lib/parts/trigger.p.module.css.js +0 -31
- package/lib/parts/use-backward-compatible-id.d.ts +0 -4
- package/lib/parts/use-backward-compatible-id.js +0 -14
- package/lib/utils.d.ts +0 -22
- package/lib/utils.js +0 -201
- /package/lib/{parts → hooks}/use-observable-force-rerender.d.ts +0 -0
- /package/lib/{parts → hooks}/use-observable-force-rerender.js +0 -0
- /package/lib/{parts → utils}/throttle.js +0 -0
package/lib/select.js
CHANGED
|
@@ -1,103 +1,25 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useThemeWithUndefined } from '@rescui/ui-contexts';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
-
import cn from 'classnames';
|
|
6
|
-
import scrollIntoView from 'scroll-into-view-if-needed';
|
|
7
|
-
import { Dropdown } from '@rescui/dropdown';
|
|
8
|
-
import { Menu, MenuItem, Divider, GroupHeader } from '@rescui/menu';
|
|
9
5
|
import { ErrorMessage } from '@rescui/form-field';
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const Option = _ref => {
|
|
21
|
-
let {
|
|
22
|
-
selected,
|
|
23
|
-
cursorIndex,
|
|
24
|
-
item,
|
|
25
|
-
isLastItem,
|
|
26
|
-
highlightedItemRef,
|
|
27
|
-
handleSelectIndex,
|
|
28
|
-
handleHighlightIndex
|
|
29
|
-
} = _ref;
|
|
30
|
-
|
|
31
|
-
if (item.type === OptionGroupTypes.OPTION) {
|
|
32
|
-
const {
|
|
33
|
-
index,
|
|
34
|
-
label
|
|
35
|
-
} = item;
|
|
36
|
-
const value = getOptionValue(item);
|
|
37
|
-
const isSelected = selected && value === getOptionValue(selected);
|
|
38
|
-
const isHighlighted = isIndexMatchCursor(cursorIndex, index);
|
|
39
|
-
return /*#__PURE__*/React.createElement(MenuItem, {
|
|
40
|
-
selected: isSelected,
|
|
41
|
-
highlighted: isHighlighted,
|
|
42
|
-
ref: isHighlighted ? highlightedItemRef : null,
|
|
43
|
-
onMouseMove: () => handleHighlightIndex(index),
|
|
44
|
-
onClick: () => handleSelectIndex(index),
|
|
45
|
-
className: cn(isLastItem && styles.lastOption),
|
|
46
|
-
"data-test": ['select-menu-item', isHighlighted && 'select-menu-item-highlighted', isSelected && 'select-menu-item-selected'].filter(Boolean).join(' ')
|
|
47
|
-
}, label);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (item.type === OptionGroupTypes.DIVIDER) {
|
|
51
|
-
return /*#__PURE__*/React.createElement(Divider, {
|
|
52
|
-
className: styles.divider
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (item.type === OptionGroupTypes.HEADER) {
|
|
57
|
-
const {
|
|
58
|
-
label
|
|
59
|
-
} = item;
|
|
60
|
-
return /*#__PURE__*/React.createElement(GroupHeader, {
|
|
61
|
-
text: label
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return null;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const getOptionKey = (item, i) => {
|
|
69
|
-
if (item.type === OptionGroupTypes.OPTION) {
|
|
70
|
-
const value = getOptionValue(item);
|
|
71
|
-
return `${value}_${item.index[0]}`;
|
|
72
|
-
} else if (item.type === OptionGroupTypes.DIVIDER) {
|
|
73
|
-
return `divider${i}`;
|
|
74
|
-
} else if (item.type === OptionGroupTypes.HEADER) {
|
|
75
|
-
return `header${i}`;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return null;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const SIZE_STYLES = {
|
|
82
|
-
s: styles.sizeS,
|
|
83
|
-
m: styles.sizeM,
|
|
84
|
-
l: styles.sizeL
|
|
85
|
-
};
|
|
86
|
-
const MENU_SIZE_STYLES = {
|
|
87
|
-
s: styles.menuSizeS,
|
|
88
|
-
m: styles.menuSizeM,
|
|
89
|
-
l: styles.menuSizeL
|
|
90
|
-
}; // eslint-disable-next-line complexity
|
|
91
|
-
|
|
92
|
-
const Select = _ref2 => {
|
|
6
|
+
import { optionType, optionsGroupType, noOptionsMessageType } from './common-prop-types.js';
|
|
7
|
+
import { useOptionSerialization } from './hooks/use-option-serialization.js';
|
|
8
|
+
import { convertOptions } from './utils/convert-options.js';
|
|
9
|
+
import { convertPlacement } from './utils/convert-placement.js';
|
|
10
|
+
import { getOptionValue } from './utils/get-option-value.js';
|
|
11
|
+
import { SelectBasic } from './select-basic.js';
|
|
12
|
+
import { SelectSearchable } from './select-searchable.js';
|
|
13
|
+
|
|
14
|
+
const Select = _ref => {
|
|
93
15
|
let {
|
|
94
|
-
options,
|
|
16
|
+
options = [],
|
|
95
17
|
size = 'm',
|
|
96
18
|
mode = 'classic',
|
|
97
19
|
theme: themeFromProps,
|
|
98
|
-
className
|
|
99
|
-
|
|
100
|
-
value
|
|
20
|
+
className,
|
|
21
|
+
style,
|
|
22
|
+
value,
|
|
101
23
|
onChange,
|
|
102
24
|
placeholder,
|
|
103
25
|
isClearable = false,
|
|
@@ -109,278 +31,49 @@ const Select = _ref2 => {
|
|
|
109
31
|
placement = 'bottom',
|
|
110
32
|
boldLabel = true,
|
|
111
33
|
reserveErrorLine = false,
|
|
34
|
+
note,
|
|
35
|
+
maxVisibleItems = 5,
|
|
112
36
|
...restProps
|
|
113
|
-
} =
|
|
114
|
-
const [triggerFormWrapperRef, setTriggerFormWrapperRef] = useState(null);
|
|
37
|
+
} = _ref;
|
|
115
38
|
const theme = useThemeWithUndefined(themeFromProps);
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const [cursorIndex, setCursorIndex] = useState(() => getDefaultCursorIndex(filteredGroups));
|
|
139
|
-
useEffect(() => {
|
|
140
|
-
setCursorIndex(getDefaultCursorIndex(filteredGroups));
|
|
141
|
-
|
|
142
|
-
if (searchString !== '') {
|
|
143
|
-
setMenuIsOpen(true);
|
|
144
|
-
}
|
|
145
|
-
}, [searchString, filteredGroups]);
|
|
146
|
-
const isEmptyMenu = useMemo(() => isGroupsEmpty(filteredGroups), [filteredGroups]);
|
|
147
|
-
const handleSelectIndex = useCallback(index => {
|
|
148
|
-
const [grpIndex, optIndex] = index;
|
|
149
|
-
const selectedOption = filteredGroups[grpIndex].options[optIndex];
|
|
150
|
-
setMenuIsOpen(false);
|
|
151
|
-
setSearchString('');
|
|
152
|
-
setIsKeyboardNavigating(false);
|
|
153
|
-
|
|
154
|
-
if (onChange) {
|
|
155
|
-
onChange(selectedOption);
|
|
156
|
-
}
|
|
157
|
-
}, [onChange, filteredGroups]);
|
|
158
|
-
useEffect(() => {
|
|
159
|
-
if (dropdownRef.current) {
|
|
160
|
-
dropdownRef.current.scheduleUpdate();
|
|
161
|
-
}
|
|
162
|
-
}, [searchString]);
|
|
163
|
-
const handleMouseMove = useCallback(() => setIsKeyboardNavigating(false), []);
|
|
164
|
-
useEffect(() => {
|
|
165
|
-
if (isKeyboardNavigating) {
|
|
166
|
-
document.addEventListener('mousemove', handleMouseMove);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return () => document.removeEventListener('mousemove', handleMouseMove);
|
|
170
|
-
}, [handleMouseMove, isKeyboardNavigating]);
|
|
171
|
-
useEffect(() => {
|
|
172
|
-
if (isKeyboardNavigating && highlightedItemRef.current) {
|
|
173
|
-
if (skipScrollingRef.current) {
|
|
174
|
-
skipScrollingRef.current = false;
|
|
175
|
-
} else {
|
|
176
|
-
let elementToScrollTo = highlightedItemRef.current;
|
|
177
|
-
|
|
178
|
-
if (cursorIndex[0] === 0 && cursorIndex[1] === 0) {
|
|
179
|
-
const groupHeader = highlightedItemRef.current.previousSibling;
|
|
180
|
-
|
|
181
|
-
if (groupHeader) {
|
|
182
|
-
elementToScrollTo = groupHeader;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
scrollIntoView(elementToScrollTo, {
|
|
187
|
-
behavior: 'instant',
|
|
188
|
-
scrollMode: 'if-needed',
|
|
189
|
-
block: 'nearest',
|
|
190
|
-
inline: 'nearest'
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}, [highlightedItemRef, cursorIndex, isKeyboardNavigating]);
|
|
195
|
-
const handleClose = useCallback(() => {
|
|
196
|
-
setSearchString('');
|
|
197
|
-
setMenuIsOpen(false);
|
|
198
|
-
setIsKeyboardNavigating(false);
|
|
199
|
-
}, []);
|
|
200
|
-
const handleKeyNavigation = useCallback( // eslint-disable-next-line complexity
|
|
201
|
-
e => {
|
|
202
|
-
if (e.key === ARROW_DOWN || e.key === ARROW_UP) {
|
|
203
|
-
const isDownDirection = e.key === ARROW_DOWN;
|
|
204
|
-
setCursorIndex(getMovedCursorIndex(filteredGroups, cursorIndex, isDownDirection));
|
|
205
|
-
setIsKeyboardNavigating(true);
|
|
206
|
-
e.preventDefault();
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (e.key === ENTER || !isSearchable && e.key === SPACE) {
|
|
210
|
-
if (cursorIndex !== null) {
|
|
211
|
-
handleSelectIndex(cursorIndex);
|
|
212
|
-
} else {
|
|
213
|
-
handleClose();
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
e.preventDefault();
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
if (e.key === TAB) {
|
|
220
|
-
handleClose();
|
|
221
|
-
}
|
|
222
|
-
}, [filteredGroups, cursorIndex, handleClose, handleSelectIndex, isSearchable]);
|
|
223
|
-
const handleClick = useCallback(() => {
|
|
224
|
-
if (isDisabled) {
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
setMenuIsOpen(currentMenuIsOpen => !currentMenuIsOpen);
|
|
229
|
-
setSearchString('');
|
|
230
|
-
}, [isDisabled]);
|
|
231
|
-
const handleSearchInputChange = useCallback(searchValue => setSearchString(searchValue), []);
|
|
232
|
-
const handleClearClick = useCallback(() => {
|
|
233
|
-
setCursorIndex(getDefaultCursorIndex(filteredGroups));
|
|
234
|
-
setMenuIsOpen(false);
|
|
235
|
-
|
|
236
|
-
if (onChange) {
|
|
237
|
-
onChange(null);
|
|
238
|
-
}
|
|
239
|
-
}, [filteredGroups, onChange]);
|
|
240
|
-
const handleTriggerKeyDown = useCallback(e => {
|
|
241
|
-
if (e.key === ESCAPE) {
|
|
242
|
-
handleClose();
|
|
243
|
-
e.preventDefault();
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if (isDisabled) {
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
if (menuIsOpen) {
|
|
251
|
-
handleKeyNavigation(e);
|
|
252
|
-
} else {
|
|
253
|
-
const target = e.target;
|
|
254
|
-
const trigger = target.closest('[data-target="trigger"]');
|
|
255
|
-
const isTriggerTarget = trigger === target;
|
|
256
|
-
|
|
257
|
-
if (shouldOpenSelect(e.key, isTriggerTarget)) {
|
|
258
|
-
setMenuIsOpen(true);
|
|
259
|
-
setSearchString('');
|
|
260
|
-
setIsKeyboardNavigating(true);
|
|
261
|
-
skipScrollingRef.current = true;
|
|
262
|
-
trigger.focus();
|
|
263
|
-
e.preventDefault();
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
if (e.key === BACKSPACE && isClearable) {
|
|
267
|
-
handleClearClick();
|
|
268
|
-
trigger.focus();
|
|
269
|
-
e.preventDefault();
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}, [menuIsOpen, isDisabled, isClearable, handleClose, handleClearClick, handleKeyNavigation]);
|
|
273
|
-
const handleHighlightIndex = useCallback(index => {
|
|
274
|
-
if (!isIndexMatchCursor(cursorIndex, index)) {
|
|
275
|
-
setCursorIndex(index);
|
|
276
|
-
}
|
|
277
|
-
}, [cursorIndex]); // We use invisible and "untouchable" dummy element to observe `size` changes from css to trigger force rerenders
|
|
278
|
-
|
|
279
|
-
const observableRef = useObservableForceRerender();
|
|
280
|
-
let sizeFromCss = null;
|
|
281
|
-
|
|
282
|
-
if (triggerFormWrapperRef && menuIsOpen) {
|
|
283
|
-
var _context;
|
|
284
|
-
|
|
285
|
-
// In theory this part of the code might cause issues with SSR.
|
|
286
|
-
// But in this specific context, because of checking ref "triggerFormWrapperRef",
|
|
287
|
-
// we are sure that the value will still be "null" on the first render.
|
|
288
|
-
// Therefore, the first render on the client will be the same as on the server.
|
|
289
|
-
// Also, there will be no layout shifts on the following renders because
|
|
290
|
-
// it's a dropdown-content and in most cases it opens only on-demand.
|
|
291
|
-
// In additional, we use "observable" el to watch size changes between rerenders (@media query case).
|
|
292
|
-
const triggerFormWrapperStyles = getComputedStyle(triggerFormWrapperRef);
|
|
293
|
-
const rawSizeFromCss = triggerFormWrapperStyles.getPropertyValue('--_rs-select-size');
|
|
294
|
-
sizeFromCss = _includesInstanceProperty(_context = ['s', 'm', 'l']).call(_context, rawSizeFromCss) ? rawSizeFromCss : null;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
const actualSize = sizeFromCss || size;
|
|
298
|
-
const maxHeight = calculateMaxHeight(actualSize);
|
|
299
|
-
const withGroupsLabel = !withoutGroupsLabel(filteredGroups);
|
|
300
|
-
const uniqueId = `select-${useBackwardCompatibleId()}`;
|
|
301
|
-
const errorId = `${id ? id : uniqueId}-error`;
|
|
302
|
-
return /*#__PURE__*/React.createElement(Dropdown, {
|
|
303
|
-
theme: theme,
|
|
304
|
-
onRequestClose: handleClose,
|
|
305
|
-
placement: placement,
|
|
39
|
+
const {
|
|
40
|
+
selectedKey,
|
|
41
|
+
findOptionByKey,
|
|
42
|
+
virtualOption
|
|
43
|
+
} = useOptionSerialization(options, value);
|
|
44
|
+
|
|
45
|
+
const handleSelectionChange = key => {
|
|
46
|
+
const option = findOptionByKey(key);
|
|
47
|
+
onChange === null || onChange === void 0 || onChange(option);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const InnerSingleComponent = isSearchable ? SelectSearchable : SelectBasic;
|
|
51
|
+
return /*#__PURE__*/React.createElement(InnerSingleComponent, { ...restProps,
|
|
52
|
+
isDisabled: isDisabled,
|
|
53
|
+
value: selectedKey,
|
|
54
|
+
onChange: handleSelectionChange,
|
|
55
|
+
placeholder: placeholder,
|
|
56
|
+
isClearable: isClearable,
|
|
57
|
+
isLoading: isLoading,
|
|
58
|
+
className: className,
|
|
59
|
+
style: style,
|
|
60
|
+
size: size,
|
|
306
61
|
mode: mode,
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
} = _ref4;
|
|
318
|
-
return /*#__PURE__*/React.createElement(FormTriggerWrapper, {
|
|
319
|
-
ref: setTriggerFormWrapperRef,
|
|
320
|
-
className: cn(className, SIZE_STYLES[size]),
|
|
321
|
-
id: id,
|
|
322
|
-
errorId: errorId,
|
|
323
|
-
theme: theme,
|
|
324
|
-
size: size,
|
|
325
|
-
disabled: isDisabled,
|
|
326
|
-
error: error,
|
|
327
|
-
reserveErrorLine: reserveErrorLine,
|
|
328
|
-
label: restProps.label,
|
|
329
|
-
note: restProps.note,
|
|
330
|
-
onKeyDown: handleTriggerKeyDown,
|
|
331
|
-
boldLabel: boldLabel,
|
|
332
|
-
role: "listbox",
|
|
333
|
-
"aria-errormessage": error ? errorId : undefined,
|
|
334
|
-
"aria-invalid": Boolean(error)
|
|
335
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
336
|
-
ref: observableRef,
|
|
337
|
-
className: styles.observable
|
|
338
|
-
}), restProps.name && /*#__PURE__*/React.createElement("input", {
|
|
339
|
-
type: "hidden",
|
|
340
|
-
name: restProps.name,
|
|
341
|
-
value: value && value.value || ''
|
|
342
|
-
}), /*#__PURE__*/React.createElement(SelectTrigger, {
|
|
343
|
-
theme: theme,
|
|
344
|
-
mode: mode,
|
|
345
|
-
size: size,
|
|
346
|
-
isOpen: menuIsOpen,
|
|
347
|
-
triggerRef: ref,
|
|
348
|
-
selected: value,
|
|
349
|
-
placeholder: placeholder,
|
|
350
|
-
isClearable: isClearable,
|
|
351
|
-
isLoading: isLoading,
|
|
352
|
-
isDisabled: isDisabled,
|
|
353
|
-
searchInput: searchString,
|
|
354
|
-
isSearchable: isSearchable,
|
|
355
|
-
onSearchChange: handleSearchInputChange,
|
|
356
|
-
onClick: handleClick,
|
|
357
|
-
onClearClick: handleClearClick,
|
|
358
|
-
error: Boolean(error),
|
|
359
|
-
"data-target": "trigger"
|
|
360
|
-
}));
|
|
361
|
-
},
|
|
362
|
-
isOpen: menuIsOpen
|
|
363
|
-
}, /*#__PURE__*/React.createElement(Menu, {
|
|
364
|
-
size: actualSize,
|
|
365
|
-
disableCursor: isKeyboardNavigating,
|
|
366
|
-
className: cn(styles.menu, withGroupsLabel && styles.withGroupsLabel, MENU_SIZE_STYLES[actualSize]),
|
|
367
|
-
enableKeyboardNavigation: false
|
|
368
|
-
}, !isEmptyMenu ? getPlainOptionsFromGroups(filteredGroups).map((item, i, collection) => /*#__PURE__*/React.createElement(Option, {
|
|
369
|
-
item: item,
|
|
370
|
-
isLastItem: i === collection.length - 1,
|
|
371
|
-
key: getOptionKey(item, i),
|
|
372
|
-
selected: value,
|
|
373
|
-
cursorIndex: cursorIndex,
|
|
374
|
-
highlightedItemRef: highlightedItemRef,
|
|
375
|
-
handleSelectIndex: handleSelectIndex,
|
|
376
|
-
handleHighlightIndex: handleHighlightIndex
|
|
377
|
-
})) : /*#__PURE__*/React.createElement(MenuItem, {
|
|
378
|
-
disabled: true
|
|
379
|
-
}, getEmptyMessage(isLoading, isSearchable && searchString.length > 0, noOptionsMessage))));
|
|
62
|
+
theme: theme,
|
|
63
|
+
errorMessage: error,
|
|
64
|
+
placement: convertPlacement(placement),
|
|
65
|
+
boldLabel: boldLabel,
|
|
66
|
+
reserveErrorLine: reserveErrorLine,
|
|
67
|
+
description: note,
|
|
68
|
+
noOptionsMessage: noOptionsMessage,
|
|
69
|
+
maxVisibleItems: maxVisibleItems,
|
|
70
|
+
disabledKeys: virtualOption ? [getOptionValue(virtualOption)] : []
|
|
71
|
+
}, convertOptions(options, [virtualOption].filter(Boolean)));
|
|
380
72
|
};
|
|
381
73
|
|
|
382
74
|
Select.propTypes = {
|
|
383
75
|
className: PropTypes.string,
|
|
76
|
+
style: PropTypes.object,
|
|
384
77
|
options: PropTypes.oneOfType([PropTypes.arrayOf(optionType), PropTypes.arrayOf(optionsGroupType)]),
|
|
385
78
|
value: optionType,
|
|
386
79
|
onChange: PropTypes.func,
|
|
@@ -396,8 +89,8 @@ Select.propTypes = {
|
|
|
396
89
|
label: PropTypes.node,
|
|
397
90
|
id: PropTypes.string,
|
|
398
91
|
note: PropTypes.node,
|
|
399
|
-
noOptionsMessage:
|
|
92
|
+
noOptionsMessage: noOptionsMessageType,
|
|
400
93
|
placement: PropTypes.oneOf(['auto-start', 'auto', 'auto-end', 'top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start']),
|
|
401
94
|
name: PropTypes.string
|
|
402
95
|
};
|
|
403
|
-
export { Select
|
|
96
|
+
export { Select };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var styles = {
|
|
2
|
+
"themeLight": "_themeLight_60u4bs_6",
|
|
3
|
+
"themeDark": "_themeDark_60u4bs_9",
|
|
4
|
+
"sizeS": "_sizeS_60u4bs_13",
|
|
5
|
+
"sizeM": "_sizeM_60u4bs_16",
|
|
6
|
+
"sizeL": "_sizeL_60u4bs_19",
|
|
7
|
+
"classic": "_classic_60u4bs_23",
|
|
8
|
+
"rock": "_rock_60u4bs_26",
|
|
9
|
+
"root": "_root_60u4bs_30",
|
|
10
|
+
"trigger": "_trigger_60u4bs_36",
|
|
11
|
+
"error": "_error_60u4bs_69",
|
|
12
|
+
"enabled": "_enabled_60u4bs_74",
|
|
13
|
+
"disabled": "_disabled_60u4bs_78",
|
|
14
|
+
"canBeMultiline": "_canBeMultiline_60u4bs_119",
|
|
15
|
+
"iconsWrapper": "_iconsWrapper_60u4bs_123",
|
|
16
|
+
"triggerText": "_triggerText_60u4bs_138",
|
|
17
|
+
"searchInput": "_searchInput_60u4bs_144",
|
|
18
|
+
"labelNotSelected": "_labelNotSelected_60u4bs_188",
|
|
19
|
+
"multi": "_multi_60u4bs_202",
|
|
20
|
+
"tagsContainer": "_tagsContainer_60u4bs_218",
|
|
21
|
+
"tag": "_tag_60u4bs_218",
|
|
22
|
+
"filledTag": "_filledTag_60u4bs_240",
|
|
23
|
+
"toggle": "_toggle_60u4bs_248",
|
|
24
|
+
"icon": "_icon_60u4bs_123",
|
|
25
|
+
"clearIcon": "_clearIcon_60u4bs_315"
|
|
26
|
+
};
|
|
27
|
+
export { styles as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var styles = {
|
|
2
|
+
"themeLight": "_themeLight_1k683lb_6",
|
|
3
|
+
"themeDark": "_themeDark_1k683lb_9",
|
|
4
|
+
"sizeS": "_sizeS_1k683lb_13",
|
|
5
|
+
"sizeM": "_sizeM_1k683lb_16",
|
|
6
|
+
"sizeL": "_sizeL_1k683lb_19",
|
|
7
|
+
"main": "_main_1k683lb_23",
|
|
8
|
+
"label": "_label_1k683lb_27",
|
|
9
|
+
"disabled": "_disabled_1k683lb_33",
|
|
10
|
+
"footer": "_footer_1k683lb_38",
|
|
11
|
+
"errorMessage": "_errorMessage_1k683lb_45",
|
|
12
|
+
"error": "_error_1k683lb_45",
|
|
13
|
+
"note": "_note_1k683lb_54"
|
|
14
|
+
};
|
|
15
|
+
export { styles as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var styles = {
|
|
2
|
+
"sizeS": "_sizeS_57zbb_6",
|
|
3
|
+
"sizeM": "_sizeM_57zbb_9",
|
|
4
|
+
"sizeL": "_sizeL_57zbb_12",
|
|
5
|
+
"modeClassic": "_modeClassic_57zbb_16",
|
|
6
|
+
"modeRock": "_modeRock_57zbb_19",
|
|
7
|
+
"listBox": "_listBox_57zbb_23",
|
|
8
|
+
"item": "_item_57zbb_36",
|
|
9
|
+
"selected": "_selected_57zbb_82",
|
|
10
|
+
"disabled": "_disabled_57zbb_93",
|
|
11
|
+
"checkIcon": "_checkIcon_57zbb_100",
|
|
12
|
+
"visible": "_visible_57zbb_107",
|
|
13
|
+
"divider": "_divider_57zbb_114",
|
|
14
|
+
"groupHeader": "_groupHeader_57zbb_128"
|
|
15
|
+
};
|
|
16
|
+
export { styles as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var styles = {
|
|
2
|
+
"themeLight": "_themeLight_1lf70g_6",
|
|
3
|
+
"themeDark": "_themeDark_1lf70g_9",
|
|
4
|
+
"sizeS": "_sizeS_1lf70g_13",
|
|
5
|
+
"sizeM": "_sizeM_1lf70g_16",
|
|
6
|
+
"sizeL": "_sizeL_1lf70g_19",
|
|
7
|
+
"trigger": "_trigger_1lf70g_23",
|
|
8
|
+
"error": "_error_1lf70g_61",
|
|
9
|
+
"enabled": "_enabled_1lf70g_66",
|
|
10
|
+
"disabled": "_disabled_1lf70g_70",
|
|
11
|
+
"iconsWrapper": "_iconsWrapper_1lf70g_103",
|
|
12
|
+
"triggerText": "_triggerText_1lf70g_118",
|
|
13
|
+
"labelNotSelected": "_labelNotSelected_1lf70g_144",
|
|
14
|
+
"toggle": "_toggle_1lf70g_155",
|
|
15
|
+
"icon": "_icon_1lf70g_103"
|
|
16
|
+
};
|
|
17
|
+
export { styles as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var styles = {
|
|
2
|
+
"classic": "_classic_17wpqx_32",
|
|
3
|
+
"rock": "_rock_17wpqx_35",
|
|
4
|
+
"popover": "_popover_17wpqx_39",
|
|
5
|
+
"contentWrapper": "_contentWrapper_17wpqx_46",
|
|
6
|
+
"fadeInBottomToTop": "_fadeInBottomToTop_17wpqx_1",
|
|
7
|
+
"fadeInTopToBottom": "_fadeInTopToBottom_17wpqx_1",
|
|
8
|
+
"observable": "_observable_17wpqx_62"
|
|
9
|
+
};
|
|
10
|
+
export { styles as default };
|