@rescui/select 0.15.1 → 0.15.2-RUI-291-Update-next-js-to-the-latest-version-8f54dec0a.66

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 (96) hide show
  1. package/lib/_virtual/index.css.js +12 -12
  2. package/lib/common-prop-types.d.ts +29 -35
  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 +13 -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 +714 -305
  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 +309 -0
  29. package/lib/native-select.d.ts +4 -0
  30. package/lib/native-select.js +208 -0
  31. package/lib/parts/foldable.d.ts +34 -33
  32. package/lib/parts/foldable.js +5 -7
  33. package/lib/parts/form-trigger-wrapper.d.ts +34 -34
  34. package/lib/parts/form-trigger-wrapper.js +16 -34
  35. package/lib/parts/hidden-select.d.ts +13 -0
  36. package/lib/parts/hidden-select.js +45 -0
  37. package/lib/parts/icons.d.ts +17 -0
  38. package/lib/parts/icons.js +69 -0
  39. package/lib/parts/list-box.d.ts +13 -0
  40. package/lib/parts/list-box.js +120 -0
  41. package/lib/parts/multi-trigger.d.ts +12 -0
  42. package/lib/parts/multi-trigger.js +70 -0
  43. package/lib/parts/native-select-options-with-groups.d.ts +8 -0
  44. package/lib/parts/native-select-options-with-groups.js +76 -0
  45. package/lib/parts/popup-content.d.ts +20 -0
  46. package/lib/parts/popup-content.js +68 -0
  47. package/lib/public-api.p.css +543 -307
  48. package/lib/public-api.pcss +543 -307
  49. package/lib/select-basic.d.ts +3 -0
  50. package/lib/select-basic.js +204 -0
  51. package/lib/select-searchable.d.ts +3 -0
  52. package/lib/select-searchable.js +245 -0
  53. package/lib/select.d.ts +28 -92
  54. package/lib/select.js +51 -351
  55. package/lib/styles/common.p.module.css.js +32 -0
  56. package/lib/styles/form-trigger.p.module.css.js +15 -0
  57. package/lib/styles/list-box.p.module.css.js +16 -0
  58. package/lib/types.d.ts +202 -34
  59. package/lib/utils/calculate-max-height-by-items.d.ts +13 -0
  60. package/lib/utils/calculate-max-height-by-items.js +22 -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 +19 -0
  67. package/lib/utils/get-text-from-nodes.d.ts +2 -0
  68. package/lib/utils/get-text-from-nodes.js +26 -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/item-to-string.d.ts +2 -0
  72. package/lib/utils/item-to-string.js +7 -0
  73. package/lib/utils/merge-props.d.ts +19 -0
  74. package/lib/utils/merge-props.js +104 -0
  75. package/lib/utils/throttle.d.ts +1 -0
  76. package/package.json +12 -12
  77. package/lib/key-codes.d.ts +0 -7
  78. package/lib/key-codes.js +0 -8
  79. package/lib/parts/common-select.p.module.css.js +0 -15
  80. package/lib/parts/form-trigger.p.module.css.js +0 -15
  81. package/lib/parts/multiselect.d.ts +0 -86
  82. package/lib/parts/multiselect.js +0 -455
  83. package/lib/parts/native-select.d.ts +0 -36
  84. package/lib/parts/native-select.js +0 -257
  85. package/lib/parts/native-select.p.module.css.js +0 -9
  86. package/lib/parts/throttle.d.ts +0 -1
  87. package/lib/parts/trigger.d.ts +0 -37
  88. package/lib/parts/trigger.js +0 -255
  89. package/lib/parts/trigger.p.module.css.js +0 -31
  90. package/lib/parts/use-backward-compatible-id.d.ts +0 -4
  91. package/lib/parts/use-backward-compatible-id.js +0 -14
  92. package/lib/parts/use-observable-force-rerender.d.ts +0 -2
  93. package/lib/parts/use-observable-force-rerender.js +0 -16
  94. package/lib/utils.d.ts +0 -22
  95. package/lib/utils.js +0 -201
  96. /package/lib/{parts → utils}/throttle.js +0 -0
@@ -1,257 +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
- var _group$options;
104
-
105
- const group = optionOrGroup;
106
- (_group$options = group.options) === null || _group$options === void 0 || _group$options.forEach(checkOption);
107
- } else {
108
- checkOption(optionOrGroup);
109
- }
110
- });
111
- return result;
112
- }
113
-
114
- function getNoOptionsMessage(noOptionsMessage, isLoading) {
115
- const {
116
- noOptions,
117
- loading
118
- } = isString(noOptionsMessage) ? { ...DEFAULT_NO_OPTIONS_MESSAGES,
119
- noOptions: noOptionsMessage
120
- } : { ...DEFAULT_NO_OPTIONS_MESSAGES,
121
- ...noOptionsMessage
122
- };
123
-
124
- if (isLoading) {
125
- return loading;
126
- } else {
127
- return noOptions;
128
- }
129
- }
130
-
131
- const SIZE_STYLES = {
132
- s: styles.sizeS,
133
- m: styles.sizeM,
134
- l: styles.sizeL
135
- }; // eslint-disable-next-line complexity
136
-
137
- const NativeSelect = _ref6 => {
138
- let {
139
- options = [],
140
- size = 'm',
141
- theme: themeFromProps,
142
- className = null,
143
- id,
144
- style,
145
- value = undefined,
146
- onChange,
147
- placeholder,
148
- isLoading = false,
149
- isDisabled = false,
150
- trigger,
151
- label,
152
- note,
153
- error,
154
- reserveErrorLine = false,
155
- noOptionsMessage,
156
- name,
157
- boldLabel = true
158
- } = _ref6;
159
- const theme = useThemeWithUndefined(themeFromProps);
160
- const [hovered, setHovered] = useState(false);
161
-
162
- const handleChange = event => {
163
- const newValue = event.target.value;
164
- const selectedOption = findSelectedOption(options, newValue);
165
-
166
- if (onChange) {
167
- onChange(selectedOption);
168
- }
169
- };
170
-
171
- const optionList = /*#__PURE__*/React.createElement(OptionsWithGroups, {
172
- optionsWithGroups: placeholder !== null ? [{
173
- value: PLACEHOLDER_VALUE,
174
- label: options.length > 0 ? placeholder : getNoOptionsMessage(noOptionsMessage, isLoading),
175
- disabled: true
176
- }, ...options] : options
177
- });
178
-
179
- let _trigger;
180
-
181
- if (trigger) {
182
- _trigger = trigger({
183
- selectedLabel: value === null || value === void 0 ? void 0 : value.label,
184
- selectedValue: value === null || value === void 0 ? void 0 : value.value,
185
- placeholder,
186
- hovered
187
- });
188
- } else {
189
- _trigger = /*#__PURE__*/React.createElement(SelectTrigger, {
190
- theme: theme,
191
- size: size,
192
- isOpen: false,
193
- selected: value,
194
- placeholder: placeholder,
195
- searchInput: "",
196
- isClearable: false,
197
- isLoading: isLoading,
198
- isDisabled: isDisabled,
199
- error: Boolean(error)
200
- });
201
- }
202
-
203
- const currentId = `native-select-${useBackwardCompatibleId()}`;
204
- const errorId = `${id ? id : currentId}-error`;
205
- return /*#__PURE__*/React.createElement(FormTriggerWrapper, {
206
- className: cn(className, styles.main, SIZE_STYLES[size]),
207
- id: id,
208
- theme: theme,
209
- size: size,
210
- disabled: isDisabled,
211
- error: error,
212
- errorId: errorId,
213
- reserveErrorLine: reserveErrorLine,
214
- label: label,
215
- note: note,
216
- onKeyDown: () => false,
217
- boldLabel: boldLabel
218
- }, /*#__PURE__*/React.createElement("div", {
219
- className: styles.wrapper,
220
- onMouseEnter: () => setHovered(true),
221
- onMouseLeave: () => setHovered(false),
222
- style: style,
223
- "data-test": "native-select"
224
- }, _trigger, /*#__PURE__*/React.createElement("select", {
225
- "data-test": "native-select_select",
226
- "data-rs-internal": 'select-native__select',
227
- className: styles.select,
228
- disabled: isDisabled ? true : undefined,
229
- onChange: handleChange,
230
- name: name,
231
- value: (value === null || value === void 0 ? void 0 : value.label) !== '' ? value === null || value === void 0 ? void 0 : value.value : PLACEHOLDER_VALUE,
232
- "aria-errormessage": error ? errorId : undefined,
233
- "aria-invalid": Boolean(error)
234
- }, optionList)));
235
- };
236
-
237
- NativeSelect.propTypes = {
238
- className: PropTypes.string,
239
- id: PropTypes.string,
240
- options: PropTypes.arrayOf(PropTypes.oneOfType([nativeOptionType, nativeOptionsGroupType])),
241
- value: nativeOptionType,
242
- onChange: PropTypes.func,
243
- size: PropTypes.oneOf(['m', 's', 'l']),
244
- theme: PropTypes.oneOf(['light', 'dark']),
245
- placeholder: PropTypes.string,
246
- isDisabled: PropTypes.bool,
247
- isLoading: PropTypes.bool,
248
- trigger: PropTypes.func,
249
- error: ErrorMessage.propTypes.children,
250
- label: PropTypes.node,
251
- note: PropTypes.node,
252
- noOptionsMessage: noOptionsMessageType,
253
- style: PropTypes.object,
254
- name: PropTypes.string,
255
- boldLabel: PropTypes.bool
256
- };
257
- export { NativeSelect as default };
@@ -1,9 +0,0 @@
1
- var styles = {
2
- "sizeS": "_sizeS_15yzite_6",
3
- "sizeM": "_sizeM_15yzite_9",
4
- "sizeL": "_sizeL_15yzite_12",
5
- "main": "_main_15yzite_16",
6
- "wrapper": "_wrapper_15yzite_20",
7
- "select": "_select_15yzite_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_5pagp_6",
3
- "themeDark": "_themeDark_5pagp_9",
4
- "sizeS": "_sizeS_5pagp_13",
5
- "sizeM": "_sizeM_5pagp_16",
6
- "sizeL": "_sizeL_5pagp_19",
7
- "classic": "_classic_5pagp_23",
8
- "rock": "_rock_5pagp_26",
9
- "main": "_main_5pagp_30",
10
- "open": "_open_5pagp_60",
11
- "searchKeyFocused": "_searchKeyFocused_5pagp_65",
12
- "error": "_error_5pagp_69",
13
- "disabled": "_disabled_5pagp_75",
14
- "enabled": "_enabled_5pagp_83",
15
- "searchFocused": "_searchFocused_5pagp_84",
16
- "focused": "_focused_5pagp_85",
17
- "isMulti": "_isMulti_5pagp_118",
18
- "iconsWrapper": "_iconsWrapper_5pagp_122",
19
- "labelWrapper": "_labelWrapper_5pagp_137",
20
- "label": "_label_5pagp_137",
21
- "labelNotSelected": "_labelNotSelected_5pagp_177",
22
- "searchInput": "_searchInput_5pagp_190",
23
- "multi": "_multi_5pagp_220",
24
- "tagsContainer": "_tagsContainer_5pagp_236",
25
- "tag": "_tag_5pagp_236",
26
- "filledTag": "_filledTag_5pagp_259",
27
- "toggle": "_toggle_5pagp_266",
28
- "icon": "_icon_5pagp_122",
29
- "clearIcon": "_clearIcon_5pagp_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;