@rescui/select 0.15.1-RUI-280-Update-select-component-downshift-2f40ef205.67 → 0.15.2

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.
Files changed (87) hide show
  1. package/lib/_virtual/index.css.js +12 -12
  2. package/lib/common-prop-types.d.ts +14 -9
  3. package/lib/common-prop-types.js +3 -4
  4. package/lib/index.css +432 -808
  5. package/lib/index.d.ts +6 -4
  6. package/lib/index.js +3 -3
  7. package/lib/key-codes.d.ts +7 -0
  8. package/lib/key-codes.js +8 -0
  9. package/lib/parts/common-select.p.module.css.js +15 -0
  10. package/lib/parts/foldable.js +2 -1
  11. package/lib/parts/form-trigger-wrapper.d.ts +7 -7
  12. package/lib/parts/form-trigger-wrapper.js +34 -16
  13. package/lib/parts/form-trigger.p.module.css.js +15 -0
  14. package/lib/parts/multiselect.d.ts +86 -0
  15. package/lib/parts/multiselect.js +455 -0
  16. package/lib/parts/native-select.d.ts +36 -0
  17. package/lib/parts/native-select.js +255 -0
  18. package/lib/parts/native-select.p.module.css.js +9 -0
  19. package/lib/parts/throttle.d.ts +1 -0
  20. package/lib/parts/trigger.d.ts +37 -0
  21. package/lib/parts/trigger.js +255 -0
  22. package/lib/parts/trigger.p.module.css.js +31 -0
  23. package/lib/parts/use-observable-force-rerender.d.ts +2 -0
  24. package/lib/parts/use-observable-force-rerender.js +16 -0
  25. package/lib/public-api.p.css +309 -545
  26. package/lib/public-api.pcss +309 -545
  27. package/lib/select.d.ts +91 -27
  28. package/lib/select.js +351 -51
  29. package/lib/types.d.ts +4 -167
  30. package/lib/utils.d.ts +22 -0
  31. package/lib/utils.js +199 -0
  32. package/package.json +12 -12
  33. package/lib/constants.d.ts +0 -6
  34. package/lib/constants.js +0 -7
  35. package/lib/hooks/use-a11y.d.ts +0 -29
  36. package/lib/hooks/use-a11y.js +0 -53
  37. package/lib/hooks/use-focus.d.ts +0 -10
  38. package/lib/hooks/use-focus.js +0 -17
  39. package/lib/hooks/use-hover.d.ts +0 -10
  40. package/lib/hooks/use-hover.js +0 -17
  41. package/lib/hooks/use-label-focus.d.ts +0 -9
  42. package/lib/hooks/use-label-focus.js +0 -22
  43. package/lib/hooks/use-multi-handlers.d.ts +0 -11
  44. package/lib/hooks/use-multi-handlers.js +0 -48
  45. package/lib/hooks/use-options.d.ts +0 -13
  46. package/lib/hooks/use-options.js +0 -89
  47. package/lib/multiselect.d.ts +0 -3
  48. package/lib/multiselect.js +0 -312
  49. package/lib/native-select.d.ts +0 -4
  50. package/lib/native-select.js +0 -211
  51. package/lib/parts/hidden-select.d.ts +0 -13
  52. package/lib/parts/hidden-select.js +0 -45
  53. package/lib/parts/icons.d.ts +0 -17
  54. package/lib/parts/icons.js +0 -69
  55. package/lib/parts/list-box.d.ts +0 -11
  56. package/lib/parts/list-box.js +0 -116
  57. package/lib/parts/multi-trigger.d.ts +0 -12
  58. package/lib/parts/multi-trigger.js +0 -74
  59. package/lib/parts/native-select-options-with-groups.d.ts +0 -8
  60. package/lib/parts/native-select-options-with-groups.js +0 -76
  61. package/lib/select-basic.d.ts +0 -3
  62. package/lib/select-basic.js +0 -203
  63. package/lib/select-searchable.d.ts +0 -3
  64. package/lib/select-searchable.js +0 -250
  65. package/lib/styles/common.p.module.css.js +0 -31
  66. package/lib/styles/form-trigger.p.module.css.js +0 -15
  67. package/lib/styles/list-box.p.module.css.js +0 -14
  68. package/lib/utils/calculate-max-height-by-items.d.ts +0 -13
  69. package/lib/utils/calculate-max-height-by-items.js +0 -22
  70. package/lib/utils/get-empty-message.d.ts +0 -6
  71. package/lib/utils/get-empty-message.js +0 -32
  72. package/lib/utils/get-option-value.d.ts +0 -2
  73. package/lib/utils/get-option-value.js +0 -11
  74. package/lib/utils/get-real-items-cnt.d.ts +0 -2
  75. package/lib/utils/get-real-items-cnt.js +0 -19
  76. package/lib/utils/get-text-from-nodes.d.ts +0 -2
  77. package/lib/utils/get-text-from-nodes.js +0 -28
  78. package/lib/utils/is-option-a-group.d.ts +0 -2
  79. package/lib/utils/is-option-a-group.js +0 -5
  80. package/lib/utils/item-to-string.d.ts +0 -2
  81. package/lib/utils/item-to-string.js +0 -7
  82. package/lib/utils/merge-props.d.ts +0 -29
  83. package/lib/utils/merge-props.js +0 -106
  84. package/lib/utils/throttle.d.ts +0 -1
  85. /package/lib/{utils → parts}/throttle.js +0 -0
  86. /package/lib/{hooks → parts}/use-backward-compatible-id.d.ts +0 -0
  87. /package/lib/{hooks → parts}/use-backward-compatible-id.js +0 -0
@@ -0,0 +1,455 @@
1
+ "use client";
2
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
3
+ import React, { useState, useRef, useEffect, useMemo, useCallback } from 'react';
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
+ import { ErrorMessage } from '@rescui/form-field';
10
+ import { useThemeWithUndefined } from '@rescui/ui-contexts';
11
+ import CheckOutlineIcon from '../_virtual/check-outline.js';
12
+ import { useStrongMemo, getDefaultCursorIndex, isGroupsEmpty, getOptionValue, getMovedCursorIndex, shouldOpenSelect, isIndexMatchCursor, withoutGroupsLabel, getPlainOptionsFromGroups, getEmptyMessage, OptionGroupTypes, convertToOptionGroupsIfNeeded, calculateMaxHeight } from '../utils.js';
13
+ import { optionType, optionsGroupType, noOptionsMessageType } from '../common-prop-types.js';
14
+ import { ARROW_DOWN, ARROW_UP, ENTER, SPACE, TAB, ESCAPE, BACKSPACE } from '../key-codes.js';
15
+ import SelectTrigger from './trigger.js';
16
+ import FormTriggerWrapper from './form-trigger-wrapper.js';
17
+ import { useObservableForceRerender } from './use-observable-force-rerender.js';
18
+ import { useBackwardCompatibleId } from './use-backward-compatible-id.js';
19
+ import styles from './common-select.p.module.css.js'; // eslint-disable-next-line complexity
20
+
21
+ const Option = _ref => {
22
+ let {
23
+ selected,
24
+ cursorIndex,
25
+ item,
26
+ isSingleLine,
27
+ isLastItem,
28
+ highlightedItemRef,
29
+ handleHighlightIndex,
30
+ handleSelectIndex
31
+ } = _ref;
32
+
33
+ if (item.type === OptionGroupTypes.OPTION) {
34
+ const {
35
+ index,
36
+ label
37
+ } = item;
38
+ const value = getOptionValue(item);
39
+ const isItemSelected = Boolean(selected && selected.length && selected.some(s => value === getOptionValue(s)));
40
+ const isHighlighted = isIndexMatchCursor(cursorIndex, index);
41
+ const icon = isSingleLine && isItemSelected ? /*#__PURE__*/React.createElement(CheckOutlineIcon, {
42
+ className: styles.checkIcon,
43
+ "data-render-all-sizes": true
44
+ }) : null;
45
+ return /*#__PURE__*/React.createElement(MenuItem, {
46
+ selected: isItemSelected,
47
+ highlighted: isHighlighted,
48
+ ref: isHighlighted ? highlightedItemRef : null,
49
+ onMouseMove: () => handleHighlightIndex(index),
50
+ onClick: () => handleSelectIndex(index),
51
+ className: cn(isLastItem && styles.lastOption),
52
+ icon: icon
53
+ }, label);
54
+ }
55
+
56
+ if (item.type === OptionGroupTypes.DIVIDER) {
57
+ return /*#__PURE__*/React.createElement(Divider, {
58
+ className: styles.divider
59
+ });
60
+ }
61
+
62
+ if (item.type === OptionGroupTypes.HEADER) {
63
+ const {
64
+ label
65
+ } = item;
66
+ return /*#__PURE__*/React.createElement(GroupHeader, {
67
+ text: label
68
+ });
69
+ }
70
+
71
+ return null;
72
+ };
73
+
74
+ const getOptionKey = (item, i) => {
75
+ if (item.type === OptionGroupTypes.OPTION) {
76
+ const value = getOptionValue(item);
77
+ return `${value}_${item.index[0]}`;
78
+ } else if (item.type === OptionGroupTypes.DIVIDER) {
79
+ return `divider${i}`;
80
+ } else if (item.type === OptionGroupTypes.HEADER) {
81
+ return `header${i}`;
82
+ }
83
+
84
+ return null;
85
+ };
86
+
87
+ function filterSelected(groups, selected) {
88
+ const selectedValues = {};
89
+
90
+ if (selected) {
91
+ selected.forEach(s => {
92
+ selectedValues[getOptionValue(s)] = true;
93
+ });
94
+ }
95
+
96
+ return groups.map(g => {
97
+ let newOptions = [];
98
+
99
+ if (g.options) {
100
+ newOptions = g.options.filter(opt => !selectedValues[getOptionValue(opt)]);
101
+ }
102
+
103
+ return { ...g,
104
+ options: newOptions
105
+ };
106
+ });
107
+ }
108
+
109
+ const NativeSelectedOptions = _ref2 => {
110
+ let {
111
+ name,
112
+ selected
113
+ } = _ref2;
114
+
115
+ if (!selected || !Array.isArray(selected) || !selected.length) {
116
+ return /*#__PURE__*/React.createElement("input", {
117
+ type: "hidden",
118
+ name: name,
119
+ value: ""
120
+ });
121
+ }
122
+
123
+ return /*#__PURE__*/React.createElement(React.Fragment, null, selected.map(_ref3 => {
124
+ let {
125
+ value
126
+ } = _ref3;
127
+ return /*#__PURE__*/React.createElement("input", {
128
+ key: value,
129
+ type: "hidden",
130
+ name: name,
131
+ value: value
132
+ });
133
+ }));
134
+ };
135
+
136
+ const SIZE_STYLES = {
137
+ s: styles.sizeS,
138
+ m: styles.sizeM,
139
+ l: styles.sizeL
140
+ };
141
+ const MENU_SIZE_STYLES = {
142
+ s: styles.menuSizeS,
143
+ m: styles.menuSizeM,
144
+ l: styles.menuSizeL
145
+ }; // eslint-disable-next-line complexity
146
+
147
+ const Multiselect = _ref4 => {
148
+ let {
149
+ options,
150
+ size = 'm',
151
+ mode = 'classic',
152
+ theme: themeFromProps,
153
+ className = null,
154
+ id,
155
+ value = undefined,
156
+ onChange,
157
+ placeholder,
158
+ isSingleLine = false,
159
+ isClearable = false,
160
+ isLoading = false,
161
+ isDisabled = false,
162
+ noOptionsMessage,
163
+ error,
164
+ reserveErrorLine = false,
165
+ placement = 'bottom',
166
+ boldLabel = true,
167
+ ...restProps
168
+ } = _ref4;
169
+ const [triggerFormWrapperRef, setTriggerFormWrapperRef] = useState(null);
170
+ const dropdownRef = useRef(null);
171
+ const highlightedItemRef = useRef();
172
+ const theme = useThemeWithUndefined(themeFromProps);
173
+ const [isKeyboardNavigating, setIsKeyboardNavigating] = useState(false);
174
+ const skipScrollingRef = useRef(false);
175
+ const groups = useStrongMemo(() => convertToOptionGroupsIfNeeded(options), [options]);
176
+ const filteredGroups = useStrongMemo(() => {
177
+ if (isSingleLine) {
178
+ return groups;
179
+ }
180
+
181
+ return filterSelected(groups, value);
182
+ }, [isSingleLine, value, groups]);
183
+ const [menuIsOpen, setMenuIsOpen] = useState(false);
184
+ const [cursorIndex, setCursorIndex] = useState(() => getDefaultCursorIndex(filteredGroups));
185
+ useEffect(() => {
186
+ setCursorIndex(getDefaultCursorIndex(filteredGroups));
187
+ }, [filteredGroups, value]);
188
+ const isEmptyMenu = useMemo(() => isGroupsEmpty(filteredGroups), [filteredGroups]);
189
+ const handleSelectIndex = useCallback(index => {
190
+ const selectedOption = filteredGroups[index[0]].options[index[1]];
191
+ const selectedOptionValue = getOptionValue(selectedOption);
192
+ const optionAdded = !value.some(option => getOptionValue(option) === selectedOptionValue);
193
+ const newSelected = optionAdded ? [...value, selectedOption] : value.filter(option => getOptionValue(option) !== selectedOptionValue);
194
+
195
+ if (onChange) {
196
+ onChange(newSelected);
197
+ }
198
+
199
+ setMenuIsOpen(false);
200
+ setIsKeyboardNavigating(false);
201
+ }, [onChange, filteredGroups, value]);
202
+ useEffect(() => {
203
+ if (dropdownRef.current) {
204
+ dropdownRef.current.scheduleUpdate();
205
+ }
206
+ }, [value]);
207
+ const handleMouseMove = useCallback(() => setIsKeyboardNavigating(false), []);
208
+ useEffect(() => {
209
+ if (isKeyboardNavigating) {
210
+ document.addEventListener('mousemove', handleMouseMove);
211
+ }
212
+
213
+ return () => document.removeEventListener('mousemove', handleMouseMove);
214
+ }, [handleMouseMove, isKeyboardNavigating]);
215
+ useEffect(() => {
216
+ if (isKeyboardNavigating && highlightedItemRef.current) {
217
+ if (skipScrollingRef.current) {
218
+ skipScrollingRef.current = false;
219
+ } else {
220
+ let elementToScrollTo = highlightedItemRef.current;
221
+
222
+ if (cursorIndex[0] === 0 && cursorIndex[1] === 0) {
223
+ const groupHeader = highlightedItemRef.current.previousSibling;
224
+
225
+ if (groupHeader) {
226
+ elementToScrollTo = groupHeader;
227
+ }
228
+ }
229
+
230
+ scrollIntoView(elementToScrollTo, {
231
+ behavior: 'instant',
232
+ scrollMode: 'if-needed',
233
+ block: 'nearest',
234
+ inline: 'nearest'
235
+ });
236
+ }
237
+ }
238
+ }, [highlightedItemRef, cursorIndex, isKeyboardNavigating]);
239
+ const handleClose = useCallback(() => {
240
+ setMenuIsOpen(false);
241
+ setIsKeyboardNavigating(false);
242
+ }, []);
243
+ const handleKeyNavigation = useCallback( // eslint-disable-next-line complexity
244
+ e => {
245
+ if (e.key === ARROW_DOWN || e.key === ARROW_UP) {
246
+ const isDownDirection = e.key === ARROW_DOWN;
247
+ setCursorIndex(getMovedCursorIndex(filteredGroups, cursorIndex, isDownDirection));
248
+ setIsKeyboardNavigating(true);
249
+ e.preventDefault();
250
+ }
251
+
252
+ if (e.key === ENTER || e.key === SPACE) {
253
+ if (cursorIndex !== null) {
254
+ handleSelectIndex(cursorIndex);
255
+ } else {
256
+ handleClose();
257
+ }
258
+
259
+ e.preventDefault();
260
+ }
261
+
262
+ if (e.key === TAB) {
263
+ handleClose();
264
+ }
265
+ }, [filteredGroups, cursorIndex, handleClose, handleSelectIndex]);
266
+ const handleClick = useCallback(() => {
267
+ if (isDisabled) {
268
+ return;
269
+ }
270
+
271
+ setMenuIsOpen(currentMenuIsOpen => !currentMenuIsOpen);
272
+ }, [isDisabled]);
273
+ const handleClearClick = useCallback(() => {
274
+ setCursorIndex(getDefaultCursorIndex(groups));
275
+ setMenuIsOpen(false);
276
+
277
+ if (onChange) {
278
+ onChange([]);
279
+ }
280
+ }, [groups, onChange]); // eslint-disable-next-line complexity
281
+
282
+ const handleTriggerKeyDown = useCallback(e => {
283
+ if (e.key === ESCAPE) {
284
+ handleClose();
285
+ e.preventDefault();
286
+ }
287
+
288
+ if (isDisabled) {
289
+ return;
290
+ }
291
+
292
+ if (menuIsOpen) {
293
+ handleKeyNavigation(e);
294
+ } else {
295
+ const target = e.target;
296
+ const trigger = target.closest('[data-target="trigger"]');
297
+ const isTriggerTarget = trigger === target;
298
+
299
+ if (shouldOpenSelect(e.key, isTriggerTarget)) {
300
+ setMenuIsOpen(true);
301
+ setIsKeyboardNavigating(true);
302
+ skipScrollingRef.current = true;
303
+ trigger.focus();
304
+ e.preventDefault();
305
+ }
306
+
307
+ if (e.key === BACKSPACE && isClearable) {
308
+ handleClearClick();
309
+ trigger.focus();
310
+ e.preventDefault();
311
+ }
312
+ }
313
+ }, [handleClearClick, handleClose, handleKeyNavigation, isClearable, isDisabled, menuIsOpen]);
314
+ const handleUnselectClick = useCallback(unselectedOption => {
315
+ const unselectedOptionValue = getOptionValue(unselectedOption);
316
+ const newSelected = value.filter(option => getOptionValue(option) !== unselectedOptionValue);
317
+
318
+ if (onChange) {
319
+ onChange(newSelected);
320
+ }
321
+ }, [onChange, value]);
322
+ const handleHighlightIndex = useCallback(index => {
323
+ if (!isIndexMatchCursor(cursorIndex, index)) {
324
+ setCursorIndex(index);
325
+ }
326
+ }, [cursorIndex]); // We use invisible and "untouchable" dummy element to observe `size` changes from css to trigger force rerenders
327
+
328
+ const observableRef = useObservableForceRerender();
329
+ let sizeFromCss = null;
330
+
331
+ if (triggerFormWrapperRef && menuIsOpen) {
332
+ var _context;
333
+
334
+ // In theory this part of the code might cause issues with SSR.
335
+ // But in this specific context, because of checking ref "triggerFormWrapperRef",
336
+ // we are sure that the value will still be "null" on the first render.
337
+ // Therefore, the first render on the client will be the same as on the server.
338
+ // Also, there will be no layout shifts on the following renders because
339
+ // it's a dropdown-content and in most cases it opens only on-demand.
340
+ // In additional, we use "observable" el to watch size changes between rerenders (@media query case).
341
+ const triggerFormWrapperStyles = getComputedStyle(triggerFormWrapperRef);
342
+ const rawSizeFromCss = triggerFormWrapperStyles.getPropertyValue('--_rs-select-size');
343
+ sizeFromCss = _includesInstanceProperty(_context = ['s', 'm', 'l']).call(_context, rawSizeFromCss) ? rawSizeFromCss : null;
344
+ }
345
+
346
+ const actualSize = sizeFromCss || size;
347
+ const maxHeight = calculateMaxHeight(actualSize);
348
+ const withGroupsLabel = !withoutGroupsLabel(filteredGroups);
349
+ const uniqueId = `multiselect-${useBackwardCompatibleId()}`;
350
+ const errorId = `${id ? id : uniqueId}-error`;
351
+ return /*#__PURE__*/React.createElement(Dropdown, {
352
+ theme: theme,
353
+ onRequestClose: handleClose,
354
+ placement: placement,
355
+ mode: mode,
356
+ ref: dropdownRef,
357
+ cancelCloseAnimation: true,
358
+ minWidth: "trigger",
359
+ maxWidth: "trigger",
360
+ maxHeight: maxHeight,
361
+ leastMaxHeight: maxHeight,
362
+ disableFocusLock: true,
363
+ trigger: _ref5 => {
364
+ let {
365
+ ref
366
+ } = _ref5;
367
+ return /*#__PURE__*/React.createElement(FormTriggerWrapper, {
368
+ ref: setTriggerFormWrapperRef,
369
+ className: cn(className, SIZE_STYLES[size]),
370
+ id: id,
371
+ errorId: errorId,
372
+ theme: theme,
373
+ size: size,
374
+ disabled: isDisabled,
375
+ error: error,
376
+ reserveErrorLine: reserveErrorLine,
377
+ label: restProps.label,
378
+ note: restProps.note,
379
+ onKeyDown: handleTriggerKeyDown,
380
+ boldLabel: boldLabel,
381
+ role: "listbox",
382
+ "aria-errormessage": error ? errorId : undefined,
383
+ "aria-invalid": Boolean(error),
384
+ "aria-multiselectable": true
385
+ }, /*#__PURE__*/React.createElement("div", {
386
+ ref: observableRef,
387
+ className: styles.observable
388
+ }), restProps.name && /*#__PURE__*/React.createElement(NativeSelectedOptions, {
389
+ name: restProps.name,
390
+ selected: value
391
+ }), /*#__PURE__*/React.createElement(SelectTrigger, {
392
+ theme: theme,
393
+ mode: mode,
394
+ size: size,
395
+ isOpen: menuIsOpen,
396
+ triggerRef: ref,
397
+ selected: value,
398
+ placeholder: placeholder,
399
+ isClearable: isClearable,
400
+ isLoading: isLoading,
401
+ isDisabled: isDisabled,
402
+ isSingleLine: isSingleLine,
403
+ onClick: handleClick,
404
+ onClearClick: handleClearClick,
405
+ onItemClearClick: handleUnselectClick,
406
+ error: Boolean(error),
407
+ "data-target": "trigger"
408
+ }));
409
+ },
410
+ isOpen: menuIsOpen
411
+ }, /*#__PURE__*/React.createElement(Menu, {
412
+ "data-test": "option-list",
413
+ size: actualSize,
414
+ className: cn(styles.menu, withGroupsLabel && styles.withGroupsLabel, MENU_SIZE_STYLES[actualSize]),
415
+ disableCursor: isKeyboardNavigating,
416
+ iconPlacement: 'right',
417
+ enableKeyboardNavigation: false
418
+ }, !isEmptyMenu ? getPlainOptionsFromGroups(filteredGroups).map((item, i, collection) => /*#__PURE__*/React.createElement(Option, {
419
+ key: getOptionKey(item, i),
420
+ selected: value,
421
+ cursorIndex: cursorIndex,
422
+ item: item,
423
+ isSingleLine: isSingleLine,
424
+ isLastItem: i === collection.length - 1,
425
+ highlightedItemRef: highlightedItemRef,
426
+ handleSelectIndex: handleSelectIndex,
427
+ handleHighlightIndex: handleHighlightIndex
428
+ })) : /*#__PURE__*/React.createElement(MenuItem, {
429
+ disabled: true
430
+ }, getEmptyMessage(isLoading, false, noOptionsMessage))));
431
+ };
432
+
433
+ Multiselect.propTypes = {
434
+ className: PropTypes.string,
435
+ options: PropTypes.arrayOf(PropTypes.oneOfType([optionType, optionsGroupType])),
436
+ value: PropTypes.arrayOf(optionType),
437
+ onChange: PropTypes.func,
438
+ size: PropTypes.oneOf(['m', 's', 'l']),
439
+ mode: PropTypes.oneOf(['classic', 'rock']),
440
+ theme: PropTypes.oneOf(['light', 'dark']),
441
+ placeholder: PropTypes.string,
442
+ isSingleLine: PropTypes.bool,
443
+ isClearable: PropTypes.bool,
444
+ isDisabled: PropTypes.bool,
445
+ isLoading: PropTypes.bool,
446
+ error: ErrorMessage.propTypes.children,
447
+ label: PropTypes.node,
448
+ note: PropTypes.node,
449
+ id: PropTypes.string,
450
+ noOptionsMessage: noOptionsMessageType,
451
+ 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']),
452
+ name: PropTypes.string,
453
+ boldLabel: PropTypes.bool
454
+ };
455
+ export { Multiselect as default };
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import { Theme } from '@rescui/ui-contexts';
3
+ import type { NativeSelectOption, SelectSize, NativeSelectOptionOrGroup, NoOptionsMessage } from '../types';
4
+ export declare type TriggerFunc = (props: {
5
+ selectedLabel: string;
6
+ selectedValue: string;
7
+ placeholder: string;
8
+ hovered: boolean;
9
+ }) => React.ReactNode;
10
+ export declare type NativeSelectProps = {
11
+ options?: NativeSelectOptionOrGroup[];
12
+ size?: SelectSize;
13
+ theme?: Theme;
14
+ className?: string;
15
+ id?: string;
16
+ style?: object;
17
+ value: NativeSelectOption;
18
+ onChange?: (newValue: NativeSelectOption) => void;
19
+ placeholder?: string;
20
+ isLoading?: boolean;
21
+ isDisabled?: boolean;
22
+ trigger?: TriggerFunc;
23
+ label?: React.ReactNode;
24
+ note?: React.ReactNode;
25
+ error?: boolean | React.ReactNode;
26
+ /**
27
+ * If `true`, there will be reserved a space for a 1-line error message. Subsequent lines will be placed below normally.
28
+ * If `false`, there will be no reservation.
29
+ */
30
+ reserveErrorLine?: boolean;
31
+ noOptionsMessage?: NoOptionsMessage;
32
+ name?: string;
33
+ boldLabel?: boolean;
34
+ };
35
+ declare const NativeSelect: React.FC<NativeSelectProps>;
36
+ export default NativeSelect;