@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.
Files changed (95) hide show
  1. package/lib/_virtual/index.css.js +12 -12
  2. package/lib/common-prop-types.d.ts +8 -14
  3. package/lib/common-prop-types.js +4 -3
  4. package/lib/constants.d.ts +6 -0
  5. package/lib/constants.js +7 -0
  6. package/lib/hooks/use-a11y.d.ts +30 -0
  7. package/lib/hooks/use-a11y.js +56 -0
  8. package/lib/hooks/use-actual-size-from-css.d.ts +10 -0
  9. package/lib/hooks/use-actual-size-from-css.js +27 -0
  10. package/lib/hooks/use-focus.d.ts +10 -0
  11. package/lib/hooks/use-focus.js +17 -0
  12. package/lib/hooks/use-hover.d.ts +10 -0
  13. package/lib/hooks/use-hover.js +17 -0
  14. package/lib/hooks/use-label-focus.d.ts +9 -0
  15. package/lib/hooks/use-label-focus.js +22 -0
  16. package/lib/hooks/use-multi-handlers.d.ts +11 -0
  17. package/lib/hooks/use-multi-handlers.js +44 -0
  18. package/lib/hooks/use-options.d.ts +14 -0
  19. package/lib/hooks/use-options.js +90 -0
  20. package/lib/hooks/use-primary-contrast-css-var-transfer.d.ts +11 -0
  21. package/lib/hooks/use-primary-contrast-css-var-transfer.js +29 -0
  22. package/lib/hooks/use-safe-id.d.ts +6 -0
  23. package/lib/hooks/use-safe-id.js +15 -0
  24. package/lib/index.css +713 -304
  25. package/lib/index.d.ts +4 -6
  26. package/lib/index.js +3 -3
  27. package/lib/multiselect.d.ts +3 -0
  28. package/lib/multiselect.js +308 -0
  29. package/lib/native-select.d.ts +4 -0
  30. package/lib/native-select.js +208 -0
  31. package/lib/parts/foldable.js +5 -7
  32. package/lib/parts/form-trigger-wrapper.d.ts +7 -7
  33. package/lib/parts/form-trigger-wrapper.js +16 -34
  34. package/lib/parts/hidden-select.d.ts +13 -0
  35. package/lib/parts/hidden-select.js +45 -0
  36. package/lib/parts/icons.d.ts +17 -0
  37. package/lib/parts/icons.js +69 -0
  38. package/lib/parts/list-box.d.ts +13 -0
  39. package/lib/parts/list-box.js +120 -0
  40. package/lib/parts/multi-trigger.d.ts +12 -0
  41. package/lib/parts/multi-trigger.js +70 -0
  42. package/lib/parts/native-select-options-with-groups.d.ts +8 -0
  43. package/lib/parts/native-select-options-with-groups.js +76 -0
  44. package/lib/parts/popup-content.d.ts +20 -0
  45. package/lib/parts/popup-content.js +68 -0
  46. package/lib/public-api.p.css +543 -307
  47. package/lib/public-api.pcss +543 -307
  48. package/lib/select-basic.d.ts +3 -0
  49. package/lib/select-basic.js +204 -0
  50. package/lib/select-searchable.d.ts +3 -0
  51. package/lib/select-searchable.js +245 -0
  52. package/lib/select.d.ts +27 -91
  53. package/lib/select.js +51 -351
  54. package/lib/styles/common.p.module.css.js +32 -0
  55. package/lib/styles/form-trigger.p.module.css.js +15 -0
  56. package/lib/styles/list-box.p.module.css.js +16 -0
  57. package/lib/types.d.ts +172 -4
  58. package/lib/utils/calculate-max-height-by-items.d.ts +13 -0
  59. package/lib/utils/calculate-max-height-by-items.js +22 -0
  60. package/lib/utils/get-empty-message.d.ts +6 -0
  61. package/lib/utils/get-empty-message.js +32 -0
  62. package/lib/utils/get-option-value.d.ts +2 -0
  63. package/lib/utils/get-option-value.js +11 -0
  64. package/lib/utils/get-real-items-cnt.d.ts +2 -0
  65. package/lib/utils/get-real-items-cnt.js +19 -0
  66. package/lib/utils/get-text-from-nodes.d.ts +2 -0
  67. package/lib/utils/get-text-from-nodes.js +26 -0
  68. package/lib/utils/is-option-a-group.d.ts +2 -0
  69. package/lib/utils/is-option-a-group.js +5 -0
  70. package/lib/utils/item-to-string.d.ts +2 -0
  71. package/lib/utils/item-to-string.js +7 -0
  72. package/lib/utils/merge-props.d.ts +19 -0
  73. package/lib/utils/merge-props.js +104 -0
  74. package/lib/utils/throttle.d.ts +1 -0
  75. package/package.json +8 -8
  76. package/lib/key-codes.d.ts +0 -7
  77. package/lib/key-codes.js +0 -8
  78. package/lib/parts/common-select.p.module.css.js +0 -15
  79. package/lib/parts/form-trigger.p.module.css.js +0 -15
  80. package/lib/parts/multiselect.d.ts +0 -86
  81. package/lib/parts/multiselect.js +0 -455
  82. package/lib/parts/native-select.d.ts +0 -36
  83. package/lib/parts/native-select.js +0 -257
  84. package/lib/parts/native-select.p.module.css.js +0 -9
  85. package/lib/parts/throttle.d.ts +0 -1
  86. package/lib/parts/trigger.d.ts +0 -37
  87. package/lib/parts/trigger.js +0 -255
  88. package/lib/parts/trigger.p.module.css.js +0 -31
  89. package/lib/parts/use-backward-compatible-id.d.ts +0 -4
  90. package/lib/parts/use-backward-compatible-id.js +0 -14
  91. package/lib/parts/use-observable-force-rerender.d.ts +0 -2
  92. package/lib/parts/use-observable-force-rerender.js +0 -16
  93. package/lib/utils.d.ts +0 -22
  94. package/lib/utils.js +0 -201
  95. /package/lib/{parts → utils}/throttle.js +0 -0
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import type { InnerSingleComponentProps } from './types';
3
+ export declare function SelectBasic({ options, value: selectedItem, onChange, error, label, note, size, mode, theme, placement, boldLabel, reserveErrorLine, maxVisibleItems, isClearable, isLoading, isDisabled, name, noOptionsMessage, className, id, style, placeholder, ...rest }: InnerSingleComponentProps): JSX.Element;
@@ -0,0 +1,204 @@
1
+ import React from 'react';
2
+ import cn from 'classnames';
3
+ import { useSelect } from 'downshift';
4
+ import scrollIntoView from 'scroll-into-view-if-needed';
5
+ import { useLabelFocus } from './hooks/use-label-focus.js';
6
+ import { useOptions } from './hooks/use-options.js';
7
+ import { useA11y } from './hooks/use-a11y.js';
8
+ import { Icons } from './parts/icons.js';
9
+ import { HiddenSelect } from './parts/hidden-select.js';
10
+ import { FormTriggerWrapper } from './parts/form-trigger-wrapper.js';
11
+ import { PopupContent } from './parts/popup-content.js';
12
+ import { getEmptyMessage } from './utils/get-empty-message.js';
13
+ import { mergeProps } from './utils/merge-props.js';
14
+ import { itemToString } from './utils/item-to-string.js';
15
+ import { getOptionValue } from './utils/get-option-value.js';
16
+ import { getRealItemsCnt } from './utils/get-real-items-cnt.js';
17
+ import styles from './styles/common.p.module.css.js'; // eslint-disable-next-line complexity
18
+
19
+ function SelectBasic(_ref) {
20
+ let {
21
+ options,
22
+ value: selectedItem,
23
+ onChange,
24
+ error,
25
+ label,
26
+ note,
27
+ size,
28
+ mode,
29
+ theme,
30
+ placement,
31
+ boldLabel,
32
+ reserveErrorLine,
33
+ maxVisibleItems,
34
+ isClearable,
35
+ isLoading,
36
+ isDisabled,
37
+ name,
38
+ noOptionsMessage,
39
+ className,
40
+ id,
41
+ style,
42
+ placeholder,
43
+ ...rest
44
+ } = _ref;
45
+ const triggerRef = React.useRef(null);
46
+ const dropdownRef = React.useRef(null);
47
+ const menuRef = React.useRef(null);
48
+ const {
49
+ flattenedOptions,
50
+ listBoxItems
51
+ } = useOptions(options);
52
+ const isListBoxEmpty = getRealItemsCnt(listBoxItems) === 0;
53
+ const hasValue = Boolean(selectedItem);
54
+ const selectedMap = selectedItem ? new Map([[getOptionValue(selectedItem), selectedItem]]) : new Map();
55
+ const {
56
+ fieldProps,
57
+ errorMessageProps,
58
+ descriptionProps,
59
+ baseId
60
+ } = useA11y({
61
+ prefix: 'select',
62
+ error,
63
+ description: note,
64
+ isDisabled
65
+ });
66
+ const {
67
+ isOpen,
68
+ getToggleButtonProps,
69
+ getLabelProps,
70
+ getMenuProps,
71
+ highlightedIndex,
72
+ getItemProps,
73
+ reset
74
+ } = useSelect({
75
+ items: flattenedOptions,
76
+ itemToString,
77
+ itemToKey: getOptionValue,
78
+ id: baseId,
79
+ selectedItem,
80
+ // defining our scroll behavior because on the first menu render the hook
81
+ // doesn't know menuRef and use page as the scroll boundary
82
+ scrollIntoView: (listItemEl, listEl) => {
83
+ scrollIntoView(listItemEl, {
84
+ scrollMode: 'if-needed',
85
+ block: 'nearest',
86
+ boundary: listEl ?? menuRef.current
87
+ });
88
+ },
89
+ onSelectedItemChange: _ref2 => {
90
+ let {
91
+ selectedItem: newSelectedItem
92
+ } = _ref2;
93
+ onChange?.(newSelectedItem);
94
+ },
95
+
96
+ isItemDisabled(item) {
97
+ return item && item.disabled;
98
+ }
99
+
100
+ });
101
+ const menuProps = getMenuProps({
102
+ ref: menuRef
103
+ }, {
104
+ suppressRefError: true
105
+ });
106
+ const triggerProps = getToggleButtonProps({
107
+ ref: triggerRef,
108
+ onKeyDown: event => {
109
+ // prevent default behavior of Downshift when pressing Ctrl
110
+ if (event.ctrlKey || event.metaKey) {
111
+ event.preventDownshiftDefault = true;
112
+ return;
113
+ } // backspace and backspace removing the last selected item (when popup is closed)
114
+
115
+
116
+ if (isClearable && !isOpen && (event.key === 'Backspace' || event.key === 'Delete')) {
117
+ reset();
118
+ }
119
+ },
120
+ // fix screen-reader focus on an opened popup with an empty list
121
+ ...(isOpen && isListBoxEmpty ? {
122
+ 'aria-activedescendant': menuProps.id
123
+ } : {})
124
+ });
125
+ const {
126
+ isFocusedByLabel,
127
+ labelClickProps,
128
+ triggerFocusProps: labelFocusForTriggerProps
129
+ } = useLabelFocus();
130
+ const emptyListMessage = getEmptyMessage({
131
+ isLoading,
132
+ isNothingFound: false,
133
+ noOptionsMessage
134
+ });
135
+ const listBoxState = {
136
+ selectedMap,
137
+ highlightedIndex,
138
+ getItemProps,
139
+ menuProps
140
+ };
141
+ return /*#__PURE__*/React.createElement(FormTriggerWrapper, {
142
+ theme: theme,
143
+ size: size,
144
+ disabled: isDisabled,
145
+ label: label,
146
+ labelProps: mergeProps(getLabelProps(), labelClickProps),
147
+ boldLabel: boldLabel,
148
+ error: error,
149
+ reserveErrorLine: reserveErrorLine,
150
+ errorMessageProps: errorMessageProps,
151
+ note: note,
152
+ descriptionProps: descriptionProps
153
+ }, /*#__PURE__*/React.createElement(HiddenSelect, {
154
+ name: name,
155
+ value: selectedItem,
156
+ isMultiple: false,
157
+ options: flattenedOptions
158
+ }), /*#__PURE__*/React.createElement(PopupContent, {
159
+ theme: theme,
160
+ size: size,
161
+ mode: mode,
162
+ dropdownRef: dropdownRef,
163
+ triggerRef: triggerRef,
164
+ placement: placement,
165
+ isOpen: isOpen,
166
+ listBoxState: listBoxState,
167
+ maxVisibleItems: maxVisibleItems,
168
+ emptyListMessage: emptyListMessage,
169
+ listBoxItems: listBoxItems,
170
+ trigger: _ref3 => {
171
+ let {
172
+ ref: triggerRefForDropdown
173
+ } = _ref3;
174
+ return /*#__PURE__*/React.createElement("div", {
175
+ className: styles.triggerContainer,
176
+ "data-open": isOpen,
177
+ "data-label-focused": isFocusedByLabel
178
+ }, /*#__PURE__*/React.createElement("div", { ...rest,
179
+ ...mergeProps(fieldProps, // aria-invalid & aria-describedby, rest are overridden by triggerProps
180
+ triggerProps, labelFocusForTriggerProps, {
181
+ ref: triggerRefForDropdown
182
+ }),
183
+ tabIndex: isDisabled ? undefined : 0,
184
+ className: styles.trigger,
185
+ "data-test": "select__trigger"
186
+ }, /*#__PURE__*/React.createElement("span", {
187
+ className: cn(styles.triggerText, !hasValue && styles.labelNotSelected),
188
+ "data-test": "select__trigger_content"
189
+ }, selectedItem?.label ?? placeholder), /*#__PURE__*/React.createElement(Icons, {
190
+ isLoading: isLoading,
191
+ canHaveClearIcon: isClearable && !isDisabled && hasValue,
192
+ onClear: () => {
193
+ reset();
194
+ triggerRef.current?.focus({
195
+ focusVisible: false
196
+ });
197
+ },
198
+ triggerId: triggerProps.id
199
+ })));
200
+ }
201
+ }));
202
+ }
203
+
204
+ export { SelectBasic };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { InnerSingleComponentProps } from './types';
3
+ export declare function SelectSearchable({ options, value: selectedItem, onChange, error, label, note, size, mode, theme, placement, boldLabel, reserveErrorLine, maxVisibleItems, isClearable, isLoading, isDisabled, name, noOptionsMessage, className, id, style, placeholder, ...rest }: InnerSingleComponentProps): JSX.Element;
@@ -0,0 +1,245 @@
1
+ import React, { useRef } from 'react';
2
+ import { useCombobox } from 'downshift';
3
+ import scrollIntoView from 'scroll-into-view-if-needed';
4
+ import { useLabelFocus } from './hooks/use-label-focus.js';
5
+ import { useOptions } from './hooks/use-options.js';
6
+ import { useA11y } from './hooks/use-a11y.js';
7
+ import { Icons } from './parts/icons.js';
8
+ import { HiddenSelect } from './parts/hidden-select.js';
9
+ import { FormTriggerWrapper } from './parts/form-trigger-wrapper.js';
10
+ import { PopupContent } from './parts/popup-content.js';
11
+ import { getEmptyMessage } from './utils/get-empty-message.js';
12
+ import { mergeProps } from './utils/merge-props.js';
13
+ import { itemToString } from './utils/item-to-string.js';
14
+ import { getOptionValue } from './utils/get-option-value.js';
15
+ import { getRealItemsCnt } from './utils/get-real-items-cnt.js';
16
+ import styles from './styles/common.p.module.css.js'; // eslint-disable-next-line complexity
17
+
18
+ function SelectSearchable(_ref) {
19
+ let {
20
+ options,
21
+ value: selectedItem,
22
+ onChange,
23
+ error,
24
+ label,
25
+ note,
26
+ size,
27
+ mode,
28
+ theme,
29
+ placement,
30
+ boldLabel,
31
+ reserveErrorLine,
32
+ maxVisibleItems,
33
+ isClearable,
34
+ isLoading,
35
+ isDisabled,
36
+ name,
37
+ noOptionsMessage,
38
+ className,
39
+ id,
40
+ style,
41
+ placeholder,
42
+ ...rest
43
+ } = _ref;
44
+ const inputRef = useRef(null);
45
+ const dropdownRef = useRef(null);
46
+ const menuRef = useRef(null);
47
+ const {
48
+ flattenedOptions,
49
+ listBoxItems,
50
+ setFilterString,
51
+ filterString
52
+ } = useOptions(options);
53
+ const isListBoxEmpty = getRealItemsCnt(listBoxItems) === 0;
54
+ const hasValue = Boolean(selectedItem);
55
+ const selectedMap = selectedItem ? new Map([[getOptionValue(selectedItem), selectedItem]]) : new Map();
56
+ const {
57
+ fieldProps,
58
+ errorMessageProps,
59
+ descriptionProps,
60
+ baseId,
61
+ labelProps
62
+ } = useA11y({
63
+ prefix: 'select',
64
+ error,
65
+ description: note,
66
+ fieldRef: inputRef,
67
+ isDisabled
68
+ });
69
+ const {
70
+ isOpen,
71
+ getToggleButtonProps,
72
+ getLabelProps,
73
+ getMenuProps,
74
+ getInputProps,
75
+ highlightedIndex,
76
+ getItemProps,
77
+ reset,
78
+ setInputValue
79
+ } = useCombobox({
80
+ onInputValueChange(_ref2) {
81
+ let {
82
+ inputValue,
83
+ type
84
+ } = _ref2;
85
+
86
+ if (type === useCombobox.stateChangeTypes.InputChange) {
87
+ setFilterString(inputValue);
88
+ }
89
+ },
90
+
91
+ items: flattenedOptions,
92
+ id: baseId,
93
+ itemToString,
94
+ itemToKey: getOptionValue,
95
+ selectedItem,
96
+ // defining our scroll behavior because on the first menu render the hook
97
+ // doesn't know menuRef and use page as the scroll boundary
98
+ scrollIntoView: (listItemEl, listEl) => {
99
+ scrollIntoView(listItemEl, {
100
+ scrollMode: 'if-needed',
101
+ block: 'nearest',
102
+ boundary: listEl ?? menuRef.current
103
+ });
104
+ },
105
+ onSelectedItemChange: _ref3 => {
106
+ let {
107
+ selectedItem: newSelectedItem
108
+ } = _ref3;
109
+ onChange?.(newSelectedItem);
110
+ },
111
+
112
+ isItemDisabled(item) {
113
+ return item && item.disabled;
114
+ },
115
+
116
+ onIsOpenChange(_ref4) {
117
+ let {
118
+ isOpen: newIsOpen,
119
+ selectedItem: newSelectedItem
120
+ } = _ref4;
121
+
122
+ if (newIsOpen) {
123
+ setFilterString('');
124
+ } else {
125
+ setInputValue(itemToString(newSelectedItem));
126
+ }
127
+ },
128
+
129
+ stateReducer(state, actionAndChanges) {
130
+ const {
131
+ changes,
132
+ type
133
+ } = actionAndChanges;
134
+
135
+ switch (type) {
136
+ case useCombobox.stateChangeTypes.InputKeyDownEscape:
137
+ if (!state.isOpen) {
138
+ return state;
139
+ }
140
+
141
+ return changes;
142
+
143
+ default:
144
+ return changes;
145
+ }
146
+ }
147
+
148
+ });
149
+ const menuProps = getMenuProps({
150
+ ref: menuRef
151
+ }, {
152
+ suppressRefError: true
153
+ });
154
+ const inputProps = getInputProps({
155
+ ref: inputRef,
156
+ // fix screen-reader focus on an opened popup with an empty list
157
+ ...(isOpen && isListBoxEmpty ? {
158
+ 'aria-activedescendant': menuProps.id
159
+ } : {})
160
+ });
161
+ const {
162
+ isFocusedByLabel,
163
+ labelClickProps,
164
+ triggerFocusProps: labelFocusForTriggerProps
165
+ } = useLabelFocus();
166
+ const emptyListMessage = getEmptyMessage({
167
+ isLoading,
168
+ isNothingFound: filterString.length > 0,
169
+ noOptionsMessage
170
+ });
171
+ const listBoxState = {
172
+ selectedMap,
173
+ highlightedIndex,
174
+ getItemProps,
175
+ menuProps
176
+ };
177
+ return /*#__PURE__*/React.createElement(FormTriggerWrapper, {
178
+ theme: theme,
179
+ size: size,
180
+ disabled: isDisabled,
181
+ label: label,
182
+ labelProps: mergeProps(labelProps, getLabelProps(), labelClickProps),
183
+ boldLabel: boldLabel,
184
+ error: error,
185
+ reserveErrorLine: reserveErrorLine,
186
+ errorMessageProps: errorMessageProps,
187
+ note: note,
188
+ descriptionProps: descriptionProps
189
+ }, /*#__PURE__*/React.createElement(HiddenSelect, {
190
+ name: name,
191
+ value: selectedItem,
192
+ isMultiple: false,
193
+ options: flattenedOptions
194
+ }), /*#__PURE__*/React.createElement(PopupContent, {
195
+ theme: theme,
196
+ size: size,
197
+ mode: mode,
198
+ dropdownRef: dropdownRef,
199
+ triggerRef: inputRef,
200
+ placement: placement,
201
+ isOpen: isOpen,
202
+ listBoxState: listBoxState,
203
+ maxVisibleItems: maxVisibleItems,
204
+ emptyListMessage: emptyListMessage,
205
+ listBoxItems: listBoxItems,
206
+ trigger: _ref5 => {
207
+ let {
208
+ ref: triggerRefForDropdown
209
+ } = _ref5;
210
+ return /*#__PURE__*/React.createElement("div", {
211
+ className: styles.triggerContainer,
212
+ "data-open": isOpen,
213
+ "data-label-focused": isFocusedByLabel
214
+ }, /*#__PURE__*/React.createElement("input", { ...rest,
215
+ ...mergeProps(fieldProps, // aria-invalid & aria-describedby, rest are overridden by inputProps,
216
+ inputProps, labelFocusForTriggerProps),
217
+ disabled: isDisabled ? true : undefined,
218
+ className: styles.searchInput,
219
+ placeholder: placeholder,
220
+ "data-test": "select__trigger_input"
221
+ }), /*#__PURE__*/React.createElement("div", {
222
+ role: "button",
223
+ ...mergeProps(getToggleButtonProps(), {
224
+ ref: triggerRefForDropdown,
225
+ onFocus: () => {
226
+ inputRef.current?.focus();
227
+ }
228
+ }),
229
+ tabIndex: undefined,
230
+ className: styles.trigger,
231
+ "data-test": "select__trigger"
232
+ }, /*#__PURE__*/React.createElement(Icons, {
233
+ isLoading: isLoading,
234
+ canHaveClearIcon: isClearable && !isDisabled && hasValue,
235
+ onClear: () => {
236
+ reset();
237
+ inputRef.current?.focus();
238
+ },
239
+ triggerId: inputProps.id
240
+ })));
241
+ }
242
+ }));
243
+ }
244
+
245
+ export { SelectSearchable };
package/lib/select.d.ts CHANGED
@@ -1,92 +1,28 @@
1
1
  import React from 'react';
2
- import { Theme } from '@rescui/ui-contexts';
3
- import type { SelectOption, NoOptionsMessage, SelectOptionOrGroup, SelectSize, SelectMode } from './types';
4
- export interface CustomTriggerOptions {
5
- selectedLabel?: string;
6
- selectedValue: string;
7
- placeholder?: string;
8
- hovered: boolean;
9
- }
10
- export interface SelectProps {
11
- /**
12
- * Additional class name
13
- */
14
- className?: string;
15
- id?: string;
16
- /**
17
- * Array of options or option groups
18
- */
19
- options: SelectOptionOrGroup[];
20
- /**
21
- * Is select supports clear the value
22
- */
23
- isClearable?: boolean;
24
- /**
25
- * Is select supports inplace filtering
26
- */
27
- isSearchable?: boolean;
28
- /**
29
- * Is select has been disabled
30
- */
31
- isDisabled?: boolean;
32
- /**
33
- * Is loader displayed inside select
34
- */
35
- isLoading?: boolean;
36
- /**
37
- * A hint to the user of what can be entered in the control
38
- */
39
- placeholder?: string;
40
- /**
41
- * Size
42
- */
43
- size?: SelectSize;
44
- /**
45
- * Appearance mode
46
- */
47
- mode?: SelectMode;
48
- /**
49
- * Appearance theme
50
- */
51
- theme?: Theme;
52
- /**
53
- * Value of the select
54
- */
55
- value: SelectOption;
56
- /**
57
- * Change value callback. `value => ...`
58
- */
59
- onChange?: (newValue: SelectOption) => void;
60
- /**
61
- * Error state flag or React.ReactNode (use with forms)
62
- */
63
- error?: boolean | React.ReactNode;
64
- /**
65
- * If `true`, there will be reserved a space for a 1-line error message. Subsequent lines will be placed below normally.
66
- * If `false`, there will be no reservation.
67
- */
68
- reserveErrorLine?: boolean;
69
- /**
70
- * Label element upper then Select element (use with forms)
71
- */
72
- label?: React.ReactNode;
73
- /**
74
- * Placement of dropdown element
75
- */
76
- 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';
77
- /**
78
- * Note element below then Select element (use with forms)
79
- */
80
- note?: React.ReactNode;
81
- /**
82
- * Text to display when there are no options
83
- */
84
- noOptionsMessage?: NoOptionsMessage;
85
- /**
86
- * Input name attribute
87
- */
88
- name?: string;
89
- boldLabel?: boolean;
90
- }
91
- declare const Select: React.FC<SelectProps>;
92
- export default Select;
2
+ import PropTypes from 'prop-types';
3
+ import type { SelectProps, SelectOption, SelectOptionOrGroup } from './types';
4
+ export declare const Select: {
5
+ ({ options, size, mode, theme: themeFromProps, className, style, value, onChange, placeholder, isClearable, isLoading, isDisabled, isSearchable, noOptionsMessage, error, placement, boldLabel, reserveErrorLine, note, maxVisibleItems, id, ...restProps }: SelectProps): JSX.Element;
6
+ propTypes: {
7
+ className: PropTypes.Requireable<string>;
8
+ style: PropTypes.Requireable<object>;
9
+ options: PropTypes.Validator<SelectOptionOrGroup[]>;
10
+ value: PropTypes.Validator<SelectOption>;
11
+ onChange: PropTypes.Requireable<(...args: any[]) => any>;
12
+ size: PropTypes.Requireable<string>;
13
+ mode: PropTypes.Requireable<string>;
14
+ theme: PropTypes.Requireable<string>;
15
+ placeholder: PropTypes.Requireable<string>;
16
+ isClearable: PropTypes.Requireable<boolean>;
17
+ isSearchable: PropTypes.Requireable<boolean>;
18
+ isDisabled: PropTypes.Requireable<boolean>;
19
+ isLoading: PropTypes.Requireable<boolean>;
20
+ error: React.Validator<React.ReactNode>;
21
+ label: PropTypes.Requireable<PropTypes.ReactNodeLike>;
22
+ id: PropTypes.Requireable<string>;
23
+ note: PropTypes.Requireable<PropTypes.ReactNodeLike>;
24
+ noOptionsMessage: PropTypes.Validator<import("./types").NoOptionsMessage>;
25
+ placement: PropTypes.Requireable<string>;
26
+ name: PropTypes.Requireable<string>;
27
+ };
28
+ };