@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,255 @@
1
+ "use client";
2
+ import React, { useState } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import cn from 'classnames';
5
+ import { useThemeWithUndefined } from '@rescui/ui-contexts';
6
+ import { ErrorMessage } from '@rescui/form-field';
7
+ import { nativeOptionType, nativeOptionsGroupType, noOptionsMessageType } from '../common-prop-types.js';
8
+ import SelectTrigger from './trigger.js';
9
+ import FormTriggerWrapper from './form-trigger-wrapper.js';
10
+ import { useBackwardCompatibleId } from './use-backward-compatible-id.js';
11
+ import styles from './native-select.p.module.css.js';
12
+ const DEFAULT_NO_OPTIONS_MESSAGES = {
13
+ noOptions: 'No options',
14
+ loading: 'Loading...'
15
+ };
16
+ const PLACEHOLDER_VALUE = '__placeholder__';
17
+
18
+ function isString(s) {
19
+ return Object.prototype.toString.call(s) === '[object String]';
20
+ }
21
+
22
+ const isOptionsGroup = optionOrGroup => typeof optionOrGroup.options !== 'undefined';
23
+
24
+ const collectOptionGroupValues = options => options.map(_ref => {
25
+ let {
26
+ value
27
+ } = _ref;
28
+ return value;
29
+ }).join('-');
30
+
31
+ const Option = _ref2 => {
32
+ let {
33
+ value,
34
+ label,
35
+ disabled = false
36
+ } = _ref2;
37
+ return /*#__PURE__*/React.createElement("option", {
38
+ value: value,
39
+ disabled: disabled
40
+ }, label);
41
+ };
42
+
43
+ const OptionGroup = _ref3 => {
44
+ let {
45
+ options = [],
46
+ label = '',
47
+ disabled = false
48
+ } = _ref3;
49
+ return /*#__PURE__*/React.createElement("optgroup", {
50
+ label: label,
51
+ disabled: disabled
52
+ }, options.map(_ref4 => {
53
+ let {
54
+ value,
55
+ label: optionLabel,
56
+ disabled: optionDisabled
57
+ } = _ref4;
58
+ return /*#__PURE__*/React.createElement(Option, {
59
+ key: value,
60
+ value: value,
61
+ label: optionLabel,
62
+ disabled: optionDisabled
63
+ });
64
+ }));
65
+ };
66
+
67
+ const OptionsWithGroups = _ref5 => {
68
+ let {
69
+ optionsWithGroups
70
+ } = _ref5;
71
+ return /*#__PURE__*/React.createElement(React.Fragment, null, optionsWithGroups.map(optionOrGroup => {
72
+ if (isOptionsGroup(optionOrGroup)) {
73
+ const group = optionOrGroup;
74
+ return /*#__PURE__*/React.createElement(OptionGroup, {
75
+ key: `group--${group.label}--${collectOptionGroupValues(group.options)}`,
76
+ options: group.options,
77
+ disabled: group.disabled,
78
+ label: group.label
79
+ });
80
+ }
81
+
82
+ const option = optionOrGroup;
83
+ return /*#__PURE__*/React.createElement(Option, {
84
+ key: option.value,
85
+ value: option.value,
86
+ label: optionOrGroup.label,
87
+ disabled: optionOrGroup.disabled
88
+ });
89
+ }));
90
+ };
91
+
92
+ function findSelectedOption(options, selectedValue) {
93
+ let result = null;
94
+
95
+ const checkOption = option => {
96
+ if (result === null || option.value === selectedValue) {
97
+ result = option;
98
+ }
99
+ };
100
+
101
+ options.forEach(optionOrGroup => {
102
+ if (isOptionsGroup(optionOrGroup)) {
103
+ const group = optionOrGroup;
104
+ group.options?.forEach(checkOption);
105
+ } else {
106
+ checkOption(optionOrGroup);
107
+ }
108
+ });
109
+ return result;
110
+ }
111
+
112
+ function getNoOptionsMessage(noOptionsMessage, isLoading) {
113
+ const {
114
+ noOptions,
115
+ loading
116
+ } = isString(noOptionsMessage) ? { ...DEFAULT_NO_OPTIONS_MESSAGES,
117
+ noOptions: noOptionsMessage
118
+ } : { ...DEFAULT_NO_OPTIONS_MESSAGES,
119
+ ...noOptionsMessage
120
+ };
121
+
122
+ if (isLoading) {
123
+ return loading;
124
+ } else {
125
+ return noOptions;
126
+ }
127
+ }
128
+
129
+ const SIZE_STYLES = {
130
+ s: styles.sizeS,
131
+ m: styles.sizeM,
132
+ l: styles.sizeL
133
+ }; // eslint-disable-next-line complexity
134
+
135
+ const NativeSelect = _ref6 => {
136
+ let {
137
+ options = [],
138
+ size = 'm',
139
+ theme: themeFromProps,
140
+ className = null,
141
+ id,
142
+ style,
143
+ value = undefined,
144
+ onChange,
145
+ placeholder,
146
+ isLoading = false,
147
+ isDisabled = false,
148
+ trigger,
149
+ label,
150
+ note,
151
+ error,
152
+ reserveErrorLine = false,
153
+ noOptionsMessage,
154
+ name,
155
+ boldLabel = true
156
+ } = _ref6;
157
+ const theme = useThemeWithUndefined(themeFromProps);
158
+ const [hovered, setHovered] = useState(false);
159
+
160
+ const handleChange = event => {
161
+ const newValue = event.target.value;
162
+ const selectedOption = findSelectedOption(options, newValue);
163
+
164
+ if (onChange) {
165
+ onChange(selectedOption);
166
+ }
167
+ };
168
+
169
+ const optionList = /*#__PURE__*/React.createElement(OptionsWithGroups, {
170
+ optionsWithGroups: placeholder !== null ? [{
171
+ value: PLACEHOLDER_VALUE,
172
+ label: options.length > 0 ? placeholder : getNoOptionsMessage(noOptionsMessage, isLoading),
173
+ disabled: true
174
+ }, ...options] : options
175
+ });
176
+
177
+ let _trigger;
178
+
179
+ if (trigger) {
180
+ _trigger = trigger({
181
+ selectedLabel: value?.label,
182
+ selectedValue: value?.value,
183
+ placeholder,
184
+ hovered
185
+ });
186
+ } else {
187
+ _trigger = /*#__PURE__*/React.createElement(SelectTrigger, {
188
+ theme: theme,
189
+ size: size,
190
+ isOpen: false,
191
+ selected: value,
192
+ placeholder: placeholder,
193
+ searchInput: "",
194
+ isClearable: false,
195
+ isLoading: isLoading,
196
+ isDisabled: isDisabled,
197
+ error: Boolean(error)
198
+ });
199
+ }
200
+
201
+ const currentId = `native-select-${useBackwardCompatibleId()}`;
202
+ const errorId = `${id ? id : currentId}-error`;
203
+ return /*#__PURE__*/React.createElement(FormTriggerWrapper, {
204
+ className: cn(className, styles.main, SIZE_STYLES[size]),
205
+ id: id,
206
+ theme: theme,
207
+ size: size,
208
+ disabled: isDisabled,
209
+ error: error,
210
+ errorId: errorId,
211
+ reserveErrorLine: reserveErrorLine,
212
+ label: label,
213
+ note: note,
214
+ onKeyDown: () => false,
215
+ boldLabel: boldLabel
216
+ }, /*#__PURE__*/React.createElement("div", {
217
+ className: styles.wrapper,
218
+ onMouseEnter: () => setHovered(true),
219
+ onMouseLeave: () => setHovered(false),
220
+ style: style,
221
+ "data-test": "native-select"
222
+ }, _trigger, /*#__PURE__*/React.createElement("select", {
223
+ "data-test": "native-select_select",
224
+ "data-rs-internal": 'select-native__select',
225
+ className: styles.select,
226
+ disabled: isDisabled ? true : undefined,
227
+ onChange: handleChange,
228
+ name: name,
229
+ value: value?.label !== '' ? value?.value : PLACEHOLDER_VALUE,
230
+ "aria-errormessage": error ? errorId : undefined,
231
+ "aria-invalid": Boolean(error)
232
+ }, optionList)));
233
+ };
234
+
235
+ NativeSelect.propTypes = {
236
+ className: PropTypes.string,
237
+ id: PropTypes.string,
238
+ options: PropTypes.arrayOf(PropTypes.oneOfType([nativeOptionType, nativeOptionsGroupType])),
239
+ value: nativeOptionType,
240
+ onChange: PropTypes.func,
241
+ size: PropTypes.oneOf(['m', 's', 'l']),
242
+ theme: PropTypes.oneOf(['light', 'dark']),
243
+ placeholder: PropTypes.string,
244
+ isDisabled: PropTypes.bool,
245
+ isLoading: PropTypes.bool,
246
+ trigger: PropTypes.func,
247
+ error: ErrorMessage.propTypes.children,
248
+ label: PropTypes.node,
249
+ note: PropTypes.node,
250
+ noOptionsMessage: noOptionsMessageType,
251
+ style: PropTypes.object,
252
+ name: PropTypes.string,
253
+ boldLabel: PropTypes.bool
254
+ };
255
+ export { NativeSelect as default };
@@ -0,0 +1,9 @@
1
+ var styles = {
2
+ "sizeS": "_sizeS_1jac8uu_6",
3
+ "sizeM": "_sizeM_1jac8uu_9",
4
+ "sizeL": "_sizeL_1jac8uu_12",
5
+ "main": "_main_1jac8uu_16",
6
+ "wrapper": "_wrapper_1jac8uu_20",
7
+ "select": "_select_1jac8uu_24"
8
+ };
9
+ export { styles as default };
@@ -0,0 +1 @@
1
+ export declare function throttle<A extends unknown[], R extends unknown>(func: (...args: A) => R, wait: number): (...args: A) => R;
@@ -0,0 +1,37 @@
1
+ import React, { HTMLAttributes } from 'react';
2
+ import { Theme } from '@rescui/ui-contexts';
3
+ import type { SelectOption, SelectSize, SelectMode } from '../types';
4
+ declare type SelectTriggerPropsOwn = {
5
+ size: SelectSize;
6
+ mode?: SelectMode;
7
+ theme?: Theme;
8
+ className?: string;
9
+ triggerRef?: React.Ref<HTMLDivElement>;
10
+ isOpen?: boolean;
11
+ selected?: unknown;
12
+ placeholder?: string;
13
+ isClearable?: boolean;
14
+ isLoading?: boolean;
15
+ isDisabled?: boolean;
16
+ isSingleLine?: boolean;
17
+ searchInput?: string;
18
+ isSearchable?: boolean;
19
+ onClearClick?: () => void;
20
+ onItemClearClick?: (s: SelectOption) => void;
21
+ onSearchChange?: (newValue: string) => void;
22
+ error?: boolean;
23
+ };
24
+ export declare type SelectTriggerProps = SelectTriggerPropsOwn & Omit<HTMLAttributes<HTMLDivElement>, keyof SelectTriggerPropsOwn>;
25
+ export declare type SelectedOptionProps = {
26
+ selected: SelectOption;
27
+ searchInput?: string;
28
+ placeholder?: string;
29
+ isSearchable?: boolean;
30
+ isDisabled?: boolean;
31
+ inputRef: React.Ref<HTMLInputElement>;
32
+ handleBlur: React.FocusEventHandler<HTMLInputElement>;
33
+ handleFocus: React.FocusEventHandler<HTMLInputElement>;
34
+ handleChange: React.ChangeEventHandler<HTMLInputElement>;
35
+ };
36
+ declare const SelectTrigger: React.FC<SelectTriggerProps>;
37
+ export default SelectTrigger;
@@ -0,0 +1,255 @@
1
+ "use client";
2
+ import React, { useRef, useState } from 'react';
3
+ import cn from 'classnames';
4
+ import PropTypes from 'prop-types';
5
+ import { RemovableTag, Tag } from '@rescui/tag';
6
+ import { useThemeWithUndefined } from '@rescui/ui-contexts';
7
+ import DownOutlineIcon from '../_virtual/down-outline.js';
8
+ import CloseOutlineIcon from '../_virtual/close-outline.js';
9
+ import LoadingOutlineIcon from '../_virtual/loading-outline.js';
10
+ import { optionType } from '../common-prop-types.js';
11
+ import { getOptionValue } from '../utils.js';
12
+ import Foldable from './foldable.js';
13
+ import styles from './trigger.p.module.css.js';
14
+ const THEME_STYLES = {
15
+ light: styles.themeLight,
16
+ dark: styles.themeDark
17
+ };
18
+ const SIZE_STYLES = {
19
+ s: styles.sizeS,
20
+ m: styles.sizeM,
21
+ l: styles.sizeL
22
+ };
23
+ const MODE_STYLES = {
24
+ classic: styles.classic,
25
+ rock: styles.rock
26
+ };
27
+
28
+ const MultiselectOptions = _ref => {
29
+ let {
30
+ isSingleLine,
31
+ selected,
32
+ isDisabled,
33
+ onItemClearClick
34
+ } = _ref;
35
+ const selectedOptions = selected.map(s => {
36
+ const key = getOptionValue(s);
37
+ return /*#__PURE__*/React.createElement(RemovableTag, {
38
+ key: key,
39
+ "data-test": `selected-tag-${key}`,
40
+ className: styles.tag,
41
+ disabled: isDisabled,
42
+ onRemoveClick: () => onItemClearClick(s),
43
+ "data-rs-internal": 'select-trigger__removable-tag',
44
+ wrap: !isSingleLine
45
+ }, s.label);
46
+ });
47
+ return /*#__PURE__*/React.createElement("div", {
48
+ className: styles.multi,
49
+ "data-test": "multi"
50
+ }, isSingleLine ? /*#__PURE__*/React.createElement(Foldable, {
51
+ className: styles.tagsContainer,
52
+ renderHiddenCounter: (n, ref) => /*#__PURE__*/React.createElement(Tag, {
53
+ className: cn(styles.tag, styles.filledTag),
54
+ key: "+",
55
+ ref: ref,
56
+ "data-rs-internal": 'select-trigger__tag'
57
+ }, `+${n}`)
58
+ }, selectedOptions) : /*#__PURE__*/React.createElement("div", {
59
+ className: styles.tagsContainer
60
+ }, selectedOptions));
61
+ };
62
+
63
+ function isSelectedEmpty(selected) {
64
+ if (Array.isArray(selected)) {
65
+ return selected.length === 0;
66
+ } else {
67
+ return !selected;
68
+ }
69
+ } // eslint-disable-next-line complexity
70
+
71
+
72
+ const SelectedOption = _ref2 => {
73
+ let {
74
+ selected,
75
+ searchInput = '',
76
+ placeholder = '',
77
+ isSearchable,
78
+ isDisabled,
79
+ inputRef,
80
+ handleBlur,
81
+ handleFocus,
82
+ handleChange
83
+ } = _ref2;
84
+ return /*#__PURE__*/React.createElement("div", {
85
+ className: styles.labelWrapper
86
+ }, /*#__PURE__*/React.createElement("div", {
87
+ className: cn(styles.label, isSelectedEmpty(selected) && styles.labelNotSelected),
88
+ "data-test": "select-content"
89
+ }, searchInput === '' ? selected && selected.label ? selected.label : placeholder : ''), isSearchable && !isDisabled && /*#__PURE__*/React.createElement("input", {
90
+ ref: inputRef,
91
+ tabIndex: isSearchable ? 0 : -1,
92
+ onBlur: handleBlur,
93
+ onFocus: handleFocus,
94
+ className: styles.searchInput,
95
+ autoCapitalize: "none",
96
+ autoComplete: "off",
97
+ autoCorrect: "off",
98
+ spellCheck: "false",
99
+ type: "text",
100
+ value: searchInput,
101
+ onChange: handleChange,
102
+ "data-test": "search-input"
103
+ }));
104
+ };
105
+
106
+ const ClearOrLoading = _ref3 => {
107
+ let {
108
+ isClearable,
109
+ isLoading,
110
+ isDisabled,
111
+ onClearClick,
112
+ selected
113
+ } = _ref3;
114
+
115
+ if (isLoading) {
116
+ return /*#__PURE__*/React.createElement(LoadingOutlineIcon, {
117
+ style: {
118
+ pointerEvents: 'none'
119
+ },
120
+ className: styles.icon,
121
+ "data-test": "loading-icon",
122
+ "data-render-all-sizes": true
123
+ });
124
+ } else if (isClearable && !isDisabled && !isSelectedEmpty(selected)) {
125
+ return /*#__PURE__*/React.createElement("button", {
126
+ type: "button",
127
+ className: cn(styles.icon, styles.clearIcon),
128
+ "data-test": "clear-icon",
129
+ onClick: e => {
130
+ e.stopPropagation();
131
+ onClearClick();
132
+ }
133
+ }, /*#__PURE__*/React.createElement(CloseOutlineIcon, {
134
+ "data-render-all-sizes": true
135
+ }));
136
+ } else {
137
+ return null;
138
+ }
139
+ }; // eslint-disable-next-line complexity
140
+
141
+
142
+ const SelectTrigger = /*#__PURE__*/React.memo(props => {
143
+ const {
144
+ size,
145
+ mode,
146
+ theme: themeFromProps,
147
+ className,
148
+ triggerRef,
149
+ isOpen,
150
+ selected = null,
151
+ placeholder,
152
+ isClearable,
153
+ isLoading,
154
+ isDisabled,
155
+ isSingleLine,
156
+ searchInput,
157
+ isSearchable,
158
+ onClearClick,
159
+ onItemClearClick,
160
+ onSearchChange,
161
+ error,
162
+ ...restProps
163
+ } = props;
164
+ const theme = useThemeWithUndefined(themeFromProps);
165
+ const inputRef = useRef(null);
166
+ const [isSearchFocused, setIsSearchFocused] = useState(false);
167
+ const [isFocused, setIsFocused] = useState(false);
168
+ const [isSearchKeyFocused, setIsSearchKeyFocused] = useState(false);
169
+ const isMulti = selected ? Boolean(selected.length) : false;
170
+
171
+ const handleChange = event => {
172
+ const newValue = event.target.value;
173
+ onSearchChange(newValue);
174
+ };
175
+
176
+ const handleBlur = () => {
177
+ if (isSearchable && inputRef.current) {
178
+ setIsSearchFocused(false);
179
+ setIsSearchKeyFocused(false);
180
+ }
181
+ };
182
+
183
+ const handleFocus = e => {
184
+ if (isSearchable && inputRef.current) {
185
+ setIsSearchFocused(true);
186
+ const target = e.target;
187
+ setIsSearchKeyFocused(target.getAttribute('data-focus-method') === 'key');
188
+ }
189
+ };
190
+
191
+ return /*#__PURE__*/React.createElement("div", {
192
+ tabIndex: isSearchable || isDisabled ? -1 : 0,
193
+ className: cn(styles.main, SIZE_STYLES[size], MODE_STYLES[mode], THEME_STYLES[theme], isMulti && styles.isMulti, isSearchFocused && styles.searchFocused, isSearchKeyFocused && styles.searchKeyFocused, isOpen && styles.open, isDisabled ? styles.disabled : styles.enabled, Boolean(error) && styles.error, isFocused && styles.focused, className),
194
+ onFocus: e => {
195
+ const target = e.target;
196
+ setIsFocused(target.getAttribute('data-focus-method') === 'key');
197
+ },
198
+ onBlur: () => setIsFocused(false),
199
+ ref: triggerRef,
200
+ "data-test": "select",
201
+ "data-rs-internal": 'select-trigger',
202
+ ...restProps
203
+ }, isMulti ? /*#__PURE__*/React.createElement(MultiselectOptions, {
204
+ selected: selected,
205
+ isDisabled: isDisabled,
206
+ isSingleLine: isSingleLine,
207
+ onItemClearClick: onItemClearClick
208
+ }) : /*#__PURE__*/React.createElement(SelectedOption, {
209
+ selected: selected,
210
+ placeholder: placeholder,
211
+ searchInput: searchInput,
212
+ isSearchable: isSearchable,
213
+ isDisabled: isDisabled,
214
+ inputRef: inputRef,
215
+ handleBlur: handleBlur,
216
+ handleFocus: handleFocus,
217
+ handleChange: handleChange
218
+ }), /*#__PURE__*/React.createElement("div", {
219
+ className: styles.iconsWrapper
220
+ }, /*#__PURE__*/React.createElement(ClearOrLoading, {
221
+ isLoading: isLoading,
222
+ isDisabled: isDisabled,
223
+ isClearable: isClearable,
224
+ onClearClick: onClearClick,
225
+ selected: selected
226
+ }), /*#__PURE__*/React.createElement(DownOutlineIcon, {
227
+ className: styles.toggle,
228
+ "data-test": "down-icon",
229
+ "data-render-all-sizes": true
230
+ })));
231
+ });
232
+ SelectTrigger.displayName = 'SelectTrigger';
233
+ SelectTrigger.propTypes = {
234
+ size: PropTypes.oneOf(['m', 's', 'l']),
235
+ mode: PropTypes.oneOf(['classic', 'rock']),
236
+ theme: PropTypes.oneOf(['light', 'dark']),
237
+ className: PropTypes.string,
238
+ isOpen: PropTypes.bool,
239
+ selected: PropTypes.oneOfType([optionType, PropTypes.arrayOf(optionType)]),
240
+ placeholder: PropTypes.string,
241
+ isClearable: PropTypes.bool,
242
+ isLoading: PropTypes.bool,
243
+ isDisabled: PropTypes.bool,
244
+ isSearchable: PropTypes.bool,
245
+ isSingleLine: PropTypes.bool,
246
+ onClearClick: PropTypes.func,
247
+ onItemClearClick: PropTypes.func,
248
+ onSearchChange: PropTypes.func,
249
+ error: PropTypes.bool,
250
+ triggerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
251
+ current: PropTypes.any
252
+ })]),
253
+ searchInput: PropTypes.string
254
+ };
255
+ export { SelectTrigger as default };
@@ -0,0 +1,31 @@
1
+ var styles = {
2
+ "themeLight": "_themeLight_1tjfs31_6",
3
+ "themeDark": "_themeDark_1tjfs31_9",
4
+ "sizeS": "_sizeS_1tjfs31_13",
5
+ "sizeM": "_sizeM_1tjfs31_16",
6
+ "sizeL": "_sizeL_1tjfs31_19",
7
+ "classic": "_classic_1tjfs31_23",
8
+ "rock": "_rock_1tjfs31_26",
9
+ "main": "_main_1tjfs31_30",
10
+ "open": "_open_1tjfs31_60",
11
+ "searchKeyFocused": "_searchKeyFocused_1tjfs31_65",
12
+ "error": "_error_1tjfs31_69",
13
+ "disabled": "_disabled_1tjfs31_75",
14
+ "enabled": "_enabled_1tjfs31_83",
15
+ "searchFocused": "_searchFocused_1tjfs31_84",
16
+ "focused": "_focused_1tjfs31_85",
17
+ "isMulti": "_isMulti_1tjfs31_118",
18
+ "iconsWrapper": "_iconsWrapper_1tjfs31_122",
19
+ "labelWrapper": "_labelWrapper_1tjfs31_137",
20
+ "label": "_label_1tjfs31_137",
21
+ "labelNotSelected": "_labelNotSelected_1tjfs31_177",
22
+ "searchInput": "_searchInput_1tjfs31_190",
23
+ "multi": "_multi_1tjfs31_220",
24
+ "tagsContainer": "_tagsContainer_1tjfs31_236",
25
+ "tag": "_tag_1tjfs31_236",
26
+ "filledTag": "_filledTag_1tjfs31_259",
27
+ "toggle": "_toggle_1tjfs31_266",
28
+ "icon": "_icon_1tjfs31_122",
29
+ "clearIcon": "_clearIcon_1tjfs31_333"
30
+ };
31
+ export { styles as default };
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const useObservableForceRerender: () => import("react").MutableRefObject<HTMLDivElement>;
@@ -0,0 +1,16 @@
1
+ import { useRef, useState } from 'react';
2
+ import { useResizeObserver } from '@rescui/use-resize-observer';
3
+
4
+ const useObservableForceRerender = () => {
5
+ const observableRef = useRef(null);
6
+ const [, setDummyState] = useState(false);
7
+ useResizeObserver(observableRef, () => {
8
+ //force rerender
9
+ setDummyState(s => !s);
10
+ }, {
11
+ ignoreFirstCall: true
12
+ });
13
+ return observableRef;
14
+ };
15
+
16
+ export { useObservableForceRerender };