@rescui/select 0.14.4-RUI-286-Fix-tooltip-stacking-f4145b01.1 → 0.15.1-RUI-280-Update-select-component-026338d06.52

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