@rescui/select 0.15.1 → 0.16.0
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 +8 -14
- package/lib/common-prop-types.js +4 -3
- package/lib/constants.d.ts +6 -0
- package/lib/constants.js +7 -0
- package/lib/hooks/use-a11y.d.ts +30 -0
- package/lib/hooks/use-a11y.js +56 -0
- package/lib/hooks/use-actual-size-from-css.d.ts +10 -0
- package/lib/hooks/use-actual-size-from-css.js +27 -0
- package/lib/hooks/use-focus.d.ts +10 -0
- package/lib/hooks/use-focus.js +17 -0
- package/lib/hooks/use-hover.d.ts +10 -0
- package/lib/hooks/use-hover.js +17 -0
- package/lib/hooks/use-label-focus.d.ts +9 -0
- package/lib/hooks/use-label-focus.js +22 -0
- package/lib/hooks/use-multi-handlers.d.ts +11 -0
- package/lib/hooks/use-multi-handlers.js +44 -0
- package/lib/hooks/use-options.d.ts +14 -0
- package/lib/hooks/use-options.js +90 -0
- package/lib/hooks/use-primary-contrast-css-var-transfer.d.ts +11 -0
- package/lib/hooks/use-primary-contrast-css-var-transfer.js +29 -0
- package/lib/hooks/use-safe-id.d.ts +6 -0
- package/lib/hooks/use-safe-id.js +15 -0
- package/lib/index.css +713 -304
- package/lib/index.d.ts +4 -6
- package/lib/index.js +3 -3
- package/lib/multiselect.d.ts +3 -0
- package/lib/multiselect.js +308 -0
- package/lib/native-select.d.ts +4 -0
- package/lib/native-select.js +208 -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/hidden-select.d.ts +13 -0
- package/lib/parts/hidden-select.js +45 -0
- package/lib/parts/icons.d.ts +17 -0
- package/lib/parts/icons.js +69 -0
- package/lib/parts/list-box.d.ts +13 -0
- package/lib/parts/list-box.js +120 -0
- package/lib/parts/multi-trigger.d.ts +12 -0
- package/lib/parts/multi-trigger.js +70 -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/popup-content.d.ts +20 -0
- package/lib/parts/popup-content.js +68 -0
- package/lib/public-api.p.css +543 -307
- package/lib/public-api.pcss +543 -307
- package/lib/select-basic.d.ts +3 -0
- package/lib/select-basic.js +204 -0
- package/lib/select-searchable.d.ts +3 -0
- package/lib/select-searchable.js +245 -0
- package/lib/select.d.ts +27 -91
- package/lib/select.js +51 -351
- package/lib/styles/common.p.module.css.js +32 -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/types.d.ts +172 -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/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 +19 -0
- package/lib/utils/get-text-from-nodes.d.ts +2 -0
- package/lib/utils/get-text-from-nodes.js +26 -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/item-to-string.d.ts +2 -0
- package/lib/utils/item-to-string.js +7 -0
- package/lib/utils/merge-props.d.ts +19 -0
- package/lib/utils/merge-props.js +104 -0
- package/lib/utils/throttle.d.ts +1 -0
- package/package.json +8 -8
- 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/parts/use-observable-force-rerender.d.ts +0 -2
- package/lib/parts/use-observable-force-rerender.js +0 -16
- package/lib/utils.d.ts +0 -22
- package/lib/utils.js +0 -201
- /package/lib/{parts → utils}/throttle.js +0 -0
package/lib/select.js
CHANGED
|
@@ -1,103 +1,36 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
import React, { useState, useRef, useEffect, useMemo, useCallback } from 'react';
|
|
2
|
+
import React from 'react';
|
|
4
3
|
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
4
|
import { ErrorMessage } from '@rescui/form-field';
|
|
5
|
+
import cn from 'classnames';
|
|
10
6
|
import { useThemeWithUndefined } from '@rescui/ui-contexts';
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import styles from './parts/common-select.p.module.css.js'; // eslint-disable-next-line complexity
|
|
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;
|
|
7
|
+
import { optionType, optionsGroupType, noOptionsMessageType } from './common-prop-types.js';
|
|
8
|
+
import { SelectBasic } from './select-basic.js';
|
|
9
|
+
import { SelectSearchable } from './select-searchable.js';
|
|
10
|
+
import styles from './styles/common.p.module.css.js';
|
|
11
|
+
const THEME_STYLES = {
|
|
12
|
+
light: styles.themeLight,
|
|
13
|
+
dark: styles.themeDark
|
|
79
14
|
};
|
|
80
|
-
|
|
81
15
|
const SIZE_STYLES = {
|
|
82
16
|
s: styles.sizeS,
|
|
83
17
|
m: styles.sizeM,
|
|
84
18
|
l: styles.sizeL
|
|
85
19
|
};
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}; // eslint-disable-next-line complexity
|
|
20
|
+
const MODE_STYLES = {
|
|
21
|
+
classic: styles.classic,
|
|
22
|
+
rock: styles.rock
|
|
23
|
+
};
|
|
91
24
|
|
|
92
|
-
const Select =
|
|
25
|
+
const Select = _ref => {
|
|
93
26
|
let {
|
|
94
|
-
options,
|
|
27
|
+
options = [],
|
|
95
28
|
size = 'm',
|
|
96
29
|
mode = 'classic',
|
|
97
30
|
theme: themeFromProps,
|
|
98
|
-
className
|
|
99
|
-
|
|
100
|
-
value
|
|
31
|
+
className,
|
|
32
|
+
style,
|
|
33
|
+
value,
|
|
101
34
|
onChange,
|
|
102
35
|
placeholder,
|
|
103
36
|
isClearable = false,
|
|
@@ -109,278 +42,45 @@ const Select = _ref2 => {
|
|
|
109
42
|
placement = 'bottom',
|
|
110
43
|
boldLabel = true,
|
|
111
44
|
reserveErrorLine = false,
|
|
45
|
+
note,
|
|
46
|
+
maxVisibleItems = 5,
|
|
47
|
+
id,
|
|
112
48
|
...restProps
|
|
113
|
-
} =
|
|
114
|
-
const [triggerFormWrapperRef, setTriggerFormWrapperRef] = useState(null);
|
|
49
|
+
} = _ref;
|
|
115
50
|
const theme = useThemeWithUndefined(themeFromProps);
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const filter = new RegExp(`(?:^|\\s)${escapeRegex(searchString)}`, 'i');
|
|
128
|
-
return groups.map(g => ({ ...g,
|
|
129
|
-
options: g.options.filter(_ref3 => {
|
|
130
|
-
let {
|
|
131
|
-
label
|
|
132
|
-
} = _ref3;
|
|
133
|
-
return filter.test(getTextFromNodes(label));
|
|
134
|
-
})
|
|
135
|
-
}));
|
|
136
|
-
}, [searchString, groups]);
|
|
137
|
-
const [menuIsOpen, setMenuIsOpen] = useState(false);
|
|
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, {
|
|
51
|
+
const InnerSingleComponent = isSearchable ? SelectSearchable : SelectBasic;
|
|
52
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: cn(className, styles.root, THEME_STYLES[theme], SIZE_STYLES[size], MODE_STYLES[mode], isDisabled ? styles.disabled : styles.enabled, Boolean(error) && styles.error, isSearchable && styles.searchable),
|
|
54
|
+
id: id,
|
|
55
|
+
style: style,
|
|
56
|
+
"data-test": "select"
|
|
57
|
+
}, /*#__PURE__*/React.createElement(InnerSingleComponent, { ...restProps,
|
|
58
|
+
options: options,
|
|
59
|
+
size: size,
|
|
60
|
+
mode: mode,
|
|
303
61
|
theme: theme,
|
|
304
|
-
|
|
62
|
+
className: className,
|
|
63
|
+
id: id,
|
|
64
|
+
style: style,
|
|
65
|
+
value: value,
|
|
66
|
+
onChange: onChange,
|
|
67
|
+
placeholder: placeholder,
|
|
68
|
+
isClearable: isClearable,
|
|
69
|
+
isLoading: isLoading,
|
|
70
|
+
isDisabled: isDisabled,
|
|
71
|
+
noOptionsMessage: noOptionsMessage,
|
|
72
|
+
error: error,
|
|
305
73
|
placement: placement,
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
maxHeight: maxHeight,
|
|
312
|
-
leastMaxHeight: maxHeight,
|
|
313
|
-
disableFocusLock: true,
|
|
314
|
-
trigger: _ref4 => {
|
|
315
|
-
let {
|
|
316
|
-
ref
|
|
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))));
|
|
74
|
+
boldLabel: boldLabel,
|
|
75
|
+
reserveErrorLine: reserveErrorLine,
|
|
76
|
+
note: note,
|
|
77
|
+
maxVisibleItems: maxVisibleItems
|
|
78
|
+
}));
|
|
380
79
|
};
|
|
381
80
|
|
|
382
81
|
Select.propTypes = {
|
|
383
82
|
className: PropTypes.string,
|
|
83
|
+
style: PropTypes.object,
|
|
384
84
|
options: PropTypes.oneOfType([PropTypes.arrayOf(optionType), PropTypes.arrayOf(optionsGroupType)]),
|
|
385
85
|
value: optionType,
|
|
386
86
|
onChange: PropTypes.func,
|
|
@@ -396,8 +96,8 @@ Select.propTypes = {
|
|
|
396
96
|
label: PropTypes.node,
|
|
397
97
|
id: PropTypes.string,
|
|
398
98
|
note: PropTypes.node,
|
|
399
|
-
noOptionsMessage:
|
|
99
|
+
noOptionsMessage: noOptionsMessageType,
|
|
400
100
|
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
101
|
name: PropTypes.string
|
|
402
102
|
};
|
|
403
|
-
export { Select
|
|
103
|
+
export { Select };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var styles = {
|
|
2
|
+
"themeLight": "_themeLight_dcuztf_6",
|
|
3
|
+
"themeDark": "_themeDark_dcuztf_9",
|
|
4
|
+
"sizeS": "_sizeS_dcuztf_13",
|
|
5
|
+
"sizeM": "_sizeM_dcuztf_16",
|
|
6
|
+
"sizeL": "_sizeL_dcuztf_19",
|
|
7
|
+
"classic": "_classic_dcuztf_23",
|
|
8
|
+
"rock": "_rock_dcuztf_26",
|
|
9
|
+
"root": "_root_dcuztf_30",
|
|
10
|
+
"triggerContainer": "_triggerContainer_dcuztf_36",
|
|
11
|
+
"disabled": "_disabled_dcuztf_41",
|
|
12
|
+
"trigger": "_trigger_dcuztf_36",
|
|
13
|
+
"error": "_error_dcuztf_78",
|
|
14
|
+
"enabled": "_enabled_dcuztf_83",
|
|
15
|
+
"searchable": "_searchable_dcuztf_98",
|
|
16
|
+
"canBeMultiline": "_canBeMultiline_dcuztf_125",
|
|
17
|
+
"triggerText": "_triggerText_dcuztf_129",
|
|
18
|
+
"searchInput": "_searchInput_dcuztf_130",
|
|
19
|
+
"labelNotSelected": "_labelNotSelected_dcuztf_161",
|
|
20
|
+
"multi": "_multi_dcuztf_217",
|
|
21
|
+
"tagsContainer": "_tagsContainer_dcuztf_234",
|
|
22
|
+
"tag": "_tag_dcuztf_234",
|
|
23
|
+
"filledTag": "_filledTag_dcuztf_256",
|
|
24
|
+
"iconsWrapper": "_iconsWrapper_dcuztf_264",
|
|
25
|
+
"toggle": "_toggle_dcuztf_282",
|
|
26
|
+
"icon": "_icon_dcuztf_264",
|
|
27
|
+
"clearIcon": "_clearIcon_dcuztf_356",
|
|
28
|
+
"visuallyHidden": "_visuallyHidden_dcuztf_416",
|
|
29
|
+
"select": "_select_dcuztf_433",
|
|
30
|
+
"observable": "_observable_dcuztf_455"
|
|
31
|
+
};
|
|
32
|
+
export { styles as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var styles = {
|
|
2
|
+
"themeLight": "_themeLight_11y6l6t_6",
|
|
3
|
+
"themeDark": "_themeDark_11y6l6t_9",
|
|
4
|
+
"sizeS": "_sizeS_11y6l6t_13",
|
|
5
|
+
"sizeM": "_sizeM_11y6l6t_16",
|
|
6
|
+
"sizeL": "_sizeL_11y6l6t_19",
|
|
7
|
+
"main": "_main_11y6l6t_23",
|
|
8
|
+
"label": "_label_11y6l6t_27",
|
|
9
|
+
"disabled": "_disabled_11y6l6t_33",
|
|
10
|
+
"footer": "_footer_11y6l6t_38",
|
|
11
|
+
"errorMessage": "_errorMessage_11y6l6t_45",
|
|
12
|
+
"error": "_error_11y6l6t_45",
|
|
13
|
+
"note": "_note_11y6l6t_54"
|
|
14
|
+
};
|
|
15
|
+
export { styles as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var styles = {
|
|
2
|
+
"sizeS": "_sizeS_7r600n_6",
|
|
3
|
+
"sizeM": "_sizeM_7r600n_9",
|
|
4
|
+
"sizeL": "_sizeL_7r600n_12",
|
|
5
|
+
"classic": "_classic_7r600n_16",
|
|
6
|
+
"rock": "_rock_7r600n_19",
|
|
7
|
+
"listBox": "_listBox_7r600n_23",
|
|
8
|
+
"item": "_item_7r600n_39",
|
|
9
|
+
"selected": "_selected_7r600n_77",
|
|
10
|
+
"disabled": "_disabled_7r600n_91",
|
|
11
|
+
"checkIcon": "_checkIcon_7r600n_98",
|
|
12
|
+
"visible": "_visible_7r600n_105",
|
|
13
|
+
"divider": "_divider_7r600n_112",
|
|
14
|
+
"groupHeader": "_groupHeader_7r600n_126"
|
|
15
|
+
};
|
|
16
|
+
export { styles as default };
|