@rescui/select 0.15.2 → 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 +1 -2
  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 +6 -6
  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 -255
  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 -199
  95. /package/lib/{parts → utils}/throttle.js +0 -0
@@ -1,255 +0,0 @@
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 };
@@ -1,9 +0,0 @@
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 };
@@ -1 +0,0 @@
1
- export declare function throttle<A extends unknown[], R extends unknown>(func: (...args: A) => R, wait: number): (...args: A) => R;
@@ -1,37 +0,0 @@
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;
@@ -1,255 +0,0 @@
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 };
@@ -1,31 +0,0 @@
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 };
@@ -1,4 +0,0 @@
1
- export declare const useBackwardCompatibleId: {
2
- (): string | number;
3
- counter: number;
4
- };
@@ -1,14 +0,0 @@
1
- import React, { useRef } from 'react';
2
-
3
- const useBackwardCompatibleId = () => {
4
- const id = useRef(null);
5
-
6
- if (id.current === null) {
7
- id.current = useBackwardCompatibleId.counter++;
8
- }
9
-
10
- return (React.useId ? React.useId : () => id.current)();
11
- };
12
-
13
- useBackwardCompatibleId.counter = 0;
14
- export { useBackwardCompatibleId };
@@ -1,2 +0,0 @@
1
- /// <reference types="react" />
2
- export declare const useObservableForceRerender: () => import("react").MutableRefObject<HTMLDivElement>;
@@ -1,16 +0,0 @@
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 };
package/lib/utils.d.ts DELETED
@@ -1,22 +0,0 @@
1
- import React from 'react';
2
- import type { SelectOptionOrGroup, SelectOptionsGroup, NoOptionsMessage, SelectSize } from './types';
3
- import { Groups, Index, SelectOption } from './types';
4
- export declare const getTextFromNodes: (node: React.ReactNode, depth?: number) => string;
5
- export declare function shouldOpenSelect(key: string, isTriggerTarget?: boolean): boolean;
6
- export declare function getEmptyMessage(isLoading: boolean, isNothingFound: boolean, noOptionsMessage: NoOptionsMessage): string;
7
- export declare function escapeRegex(str: string): string;
8
- export declare function convertToOptionGroupsIfNeeded(optionsOrGroups?: SelectOptionOrGroup[]): SelectOptionsGroup[];
9
- export declare const calculateMaxHeight: (size: SelectSize) => number;
10
- export declare function getOptionValue(option: SelectOption): string;
11
- export declare const OptionGroupTypes: {
12
- HEADER: string;
13
- OPTION: string;
14
- DIVIDER: string;
15
- };
16
- export declare const getDefaultCursorIndex: (groups: Groups) => Index;
17
- export declare const getPlainOptionsFromGroups: (groups: Groups) => any[];
18
- export declare function isGroupsEmpty(groups: Groups): boolean;
19
- export declare function useStrongMemo<T>(callback: () => T, deps: unknown[]): T;
20
- export declare function getMovedCursorIndex(groups: Groups, currentCursorIndex: Index, isDownDirection: boolean): Index;
21
- export declare const isIndexMatchCursor: (cursorIndex: Index, index: Index) => boolean;
22
- export declare const withoutGroupsLabel: (groups: Groups) => boolean;