@rescui/select 0.12.5 → 0.13.1-RUI-270-Update-select-options-label-types-b99bd91c.3

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.
@@ -1,15 +1,15 @@
1
1
  var styles = {
2
- "sizeS": "_sizeS_1dbhsd6_3",
3
- "sizeM": "_sizeM_1dbhsd6_6",
4
- "sizeL": "_sizeL_1dbhsd6_9",
5
- "menu": "_menu_1dbhsd6_13",
6
- "menuSizeS": "_menuSizeS_1dbhsd6_26",
7
- "menuSizeM": "_menuSizeM_1dbhsd6_30",
8
- "menuSizeL": "_menuSizeL_1dbhsd6_34",
9
- "withGroupsLabel": "_withGroupsLabel_1dbhsd6_40",
10
- "lastOption": "_lastOption_1dbhsd6_39",
11
- "divider": "_divider_1dbhsd6_45",
12
- "checkIcon": "_checkIcon_1dbhsd6_51",
13
- "observable": "_observable_1dbhsd6_56"
2
+ "sizeS": "_sizeS_3ddtgz_3",
3
+ "sizeM": "_sizeM_3ddtgz_6",
4
+ "sizeL": "_sizeL_3ddtgz_9",
5
+ "menu": "_menu_3ddtgz_13",
6
+ "menuSizeS": "_menuSizeS_3ddtgz_26",
7
+ "menuSizeM": "_menuSizeM_3ddtgz_30",
8
+ "menuSizeL": "_menuSizeL_3ddtgz_34",
9
+ "withGroupsLabel": "_withGroupsLabel_3ddtgz_40",
10
+ "lastOption": "_lastOption_3ddtgz_39",
11
+ "divider": "_divider_3ddtgz_45",
12
+ "checkIcon": "_checkIcon_3ddtgz_51",
13
+ "observable": "_observable_3ddtgz_56"
14
14
  };
15
15
  export { styles as default };
@@ -1,13 +1,13 @@
1
1
  var styles = {
2
- "themeLight": "_themeLight_jhe1hb_7",
3
- "themeDark": "_themeDark_jhe1hb_10",
4
- "sizeS": "_sizeS_jhe1hb_14",
5
- "sizeM": "_sizeM_jhe1hb_17",
6
- "sizeL": "_sizeL_jhe1hb_20",
7
- "main": "_main_jhe1hb_24",
8
- "label": "_label_jhe1hb_28",
9
- "errorMessage": "_errorMessage_jhe1hb_34",
10
- "errorIcon": "_errorIcon_jhe1hb_45",
11
- "note": "_note_jhe1hb_50"
2
+ "themeLight": "_themeLight_1ea9p06_7",
3
+ "themeDark": "_themeDark_1ea9p06_10",
4
+ "sizeS": "_sizeS_1ea9p06_14",
5
+ "sizeM": "_sizeM_1ea9p06_17",
6
+ "sizeL": "_sizeL_1ea9p06_20",
7
+ "main": "_main_1ea9p06_24",
8
+ "label": "_label_1ea9p06_28",
9
+ "errorMessage": "_errorMessage_1ea9p06_34",
10
+ "errorIcon": "_errorIcon_1ea9p06_45",
11
+ "note": "_note_1ea9p06_50"
12
12
  };
13
13
  export { styles as default };
@@ -1,9 +1,9 @@
1
1
  var styles = {
2
- "sizeS": "_sizeS_1ir5zjx_6",
3
- "sizeM": "_sizeM_1ir5zjx_9",
4
- "sizeL": "_sizeL_1ir5zjx_12",
5
- "main": "_main_1ir5zjx_16",
6
- "wrapper": "_wrapper_1ir5zjx_20",
7
- "select": "_select_1ir5zjx_24"
2
+ "sizeS": "_sizeS_4q9tzo_6",
3
+ "sizeM": "_sizeM_4q9tzo_9",
4
+ "sizeL": "_sizeL_4q9tzo_12",
5
+ "main": "_main_4q9tzo_16",
6
+ "wrapper": "_wrapper_4q9tzo_20",
7
+ "select": "_select_4q9tzo_24"
8
8
  };
9
9
  export { styles as default };
@@ -22,7 +22,6 @@ declare type SelectTriggerPropsOwn = {
22
22
  error?: boolean;
23
23
  };
24
24
  export declare type SelectTriggerProps = SelectTriggerPropsOwn & Omit<HTMLAttributes<HTMLDivElement>, keyof SelectTriggerPropsOwn>;
25
- declare const SelectTrigger: React.FC<SelectTriggerProps>;
26
25
  export declare type SelectedOptionProps = {
27
26
  selected: SelectOption;
28
27
  searchInput?: string;
@@ -34,4 +33,5 @@ export declare type SelectedOptionProps = {
34
33
  handleFocus: React.FocusEventHandler<HTMLInputElement>;
35
34
  handleChange: React.ChangeEventHandler<HTMLInputElement>;
36
35
  };
36
+ declare const SelectTrigger: React.FC<SelectTriggerProps>;
37
37
  export default SelectTrigger;
@@ -2,13 +2,13 @@
2
2
  import React, { useRef, useState } from 'react';
3
3
  import cn from 'classnames';
4
4
  import PropTypes from 'prop-types';
5
- import { RemovableTag, Tag, presets } from '@rescui/tag';
5
+ import { RemovableTag, Tag } from '@rescui/tag';
6
6
  import { useThemeWithUndefined } from '@rescui/ui-contexts';
7
7
  import DownIcon from '../_virtual/down.js';
8
8
  import CloseIcon from '../_virtual/close.js';
9
9
  import LoadingIcon from '../_virtual/loading.js';
10
10
  import { optionType } from '../common-prop-types.js';
11
- import { reverseTheme } from '../utils.js';
11
+ import { getOptionValue } from '../utils.js';
12
12
  import Foldable from './foldable.js';
13
13
  import styles from './trigger.p.module.css.js';
14
14
  const THEME_STYLES = {
@@ -23,114 +23,17 @@ const SIZE_STYLES = {
23
23
  const MODE_STYLES = {
24
24
  classic: styles.classic,
25
25
  rock: styles.rock
26
- }; // eslint-disable-next-line complexity
27
-
28
- const SelectTrigger = /*#__PURE__*/React.memo(props => {
29
- const {
30
- size,
31
- mode,
32
- theme: themeFromProps,
33
- className,
34
- triggerRef,
35
- isOpen,
36
- selected = null,
37
- placeholder,
38
- isClearable,
39
- isLoading,
40
- isDisabled,
41
- isSingleLine,
42
- searchInput,
43
- isSearchable,
44
- onClearClick,
45
- onItemClearClick,
46
- onSearchChange,
47
- error,
48
- ...restProps
49
- } = props;
50
- const theme = useThemeWithUndefined(themeFromProps);
51
- const inputRef = useRef(null);
52
- const [isSearchFocused, setIsSearchFocused] = useState(false);
53
- const [isFocused, setIsFocused] = useState(false);
54
- const [isSearchKeyFocused, setIsSearchKeyFocused] = useState(false);
55
- const isMulti = selected ? Boolean(selected.length) : false;
56
-
57
- const handleChange = event => {
58
- const newValue = event.target.value;
59
- onSearchChange(newValue);
60
- };
61
-
62
- const handleBlur = () => {
63
- if (isSearchable && inputRef.current) {
64
- setIsSearchFocused(false);
65
- setIsSearchKeyFocused(false);
66
- }
67
- };
68
-
69
- const handleFocus = e => {
70
- if (isSearchable && inputRef.current) {
71
- setIsSearchFocused(true);
72
- const target = e.target;
73
- setIsSearchKeyFocused(target.getAttribute('data-focus-method') === 'key');
74
- }
75
- };
76
-
77
- const isThemeReversed = mode === 'rock' && (isSearchFocused || isFocused || isOpen);
78
- return /*#__PURE__*/React.createElement("div", {
79
- tabIndex: isSearchable || isDisabled ? -1 : 0,
80
- 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),
81
- onFocus: e => {
82
- const target = e.target;
83
- setIsFocused(target.getAttribute('data-focus-method') === 'key');
84
- },
85
- onBlur: () => setIsFocused(false),
86
- ref: triggerRef,
87
- "data-test": "select",
88
- "data-rs-internal": 'select-trigger',
89
- ...restProps
90
- }, isMulti ? /*#__PURE__*/React.createElement(MultiselectOptions, {
91
- selected: selected,
92
- isDisabled: isDisabled,
93
- isSingleLine: isSingleLine,
94
- onItemClearClick: onItemClearClick,
95
- theme: theme,
96
- isThemeReversed: isThemeReversed
97
- }) : /*#__PURE__*/React.createElement(SelectedOption, {
98
- selected: selected,
99
- placeholder: placeholder,
100
- searchInput: searchInput,
101
- isSearchable: isSearchable,
102
- isDisabled: isDisabled,
103
- inputRef: inputRef,
104
- handleBlur: handleBlur,
105
- handleFocus: handleFocus,
106
- handleChange: handleChange
107
- }), /*#__PURE__*/React.createElement("div", {
108
- className: styles.iconsWrapper
109
- }, /*#__PURE__*/React.createElement(ClearOrLoading, {
110
- isLoading: isLoading,
111
- isDisabled: isDisabled,
112
- isClearable: isClearable,
113
- onClearClick: onClearClick,
114
- selected: selected
115
- }), /*#__PURE__*/React.createElement(DownIcon, {
116
- className: styles.toggle,
117
- "data-test": "down-icon",
118
- "data-render-all-sizes": true
119
- })));
120
- });
121
- SelectTrigger.displayName = 'SelectTrigger';
26
+ };
122
27
 
123
28
  const MultiselectOptions = _ref => {
124
29
  let {
125
30
  isSingleLine,
126
31
  selected,
127
- isThemeReversed,
128
32
  isDisabled,
129
- onItemClearClick,
130
- theme
33
+ onItemClearClick
131
34
  } = _ref;
132
35
  const selectedOptions = selected.map(s => {
133
- const key = s.value ? s.value : s.label;
36
+ const key = getOptionValue(s);
134
37
  return /*#__PURE__*/React.createElement(RemovableTag, {
135
38
  key: key,
136
39
  "data-test": `selected-tag-${key}`,
@@ -138,22 +41,19 @@ const MultiselectOptions = _ref => {
138
41
  disabled: isDisabled,
139
42
  onRemoveClick: () => onItemClearClick(s),
140
43
  "data-rs-internal": 'select-trigger__removable-tag',
141
- wrap: !isSingleLine,
142
- theme: isThemeReversed ? reverseTheme(theme) : theme
44
+ wrap: !isSingleLine
143
45
  }, s.label);
144
46
  });
145
- const tagTheme = isThemeReversed ? reverseTheme(theme) : theme;
146
47
  return /*#__PURE__*/React.createElement("div", {
147
48
  className: styles.multi,
148
49
  "data-test": "multi"
149
50
  }, isSingleLine ? /*#__PURE__*/React.createElement(Foldable, {
150
51
  className: styles.tagsContainer,
151
52
  renderHiddenCounter: (n, ref) => /*#__PURE__*/React.createElement(Tag, {
152
- className: styles.tag,
53
+ className: cn(styles.tag, styles.filledTag),
153
54
  key: "+",
154
55
  ref: ref,
155
- "data-rs-internal": 'select-trigger__tag',
156
- ...presets[`filled-${tagTheme}`]
56
+ "data-rs-internal": 'select-trigger__tag'
157
57
  }, `+${n}`)
158
58
  }, selectedOptions) : /*#__PURE__*/React.createElement("div", {
159
59
  className: styles.tagsContainer
@@ -236,8 +136,100 @@ const ClearOrLoading = _ref3 => {
236
136
  } else {
237
137
  return null;
238
138
  }
239
- };
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
+ };
240
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(DownIcon, {
227
+ className: styles.toggle,
228
+ "data-test": "down-icon",
229
+ "data-render-all-sizes": true
230
+ })));
231
+ });
232
+ SelectTrigger.displayName = 'SelectTrigger';
241
233
  SelectTrigger.propTypes = {
242
234
  size: PropTypes.oneOf(['m', 's', 'l']),
243
235
  mode: PropTypes.oneOf(['classic', 'rock']),
@@ -1,30 +1,31 @@
1
1
  var styles = {
2
- "themeLight": "_themeLight_1m1udjp_27",
3
- "themeDark": "_themeDark_1m1udjp_30",
4
- "sizeS": "_sizeS_1m1udjp_34",
5
- "sizeM": "_sizeM_1m1udjp_37",
6
- "sizeL": "_sizeL_1m1udjp_40",
7
- "classic": "_classic_1m1udjp_44",
8
- "rock": "_rock_1m1udjp_47",
9
- "main": "_main_1m1udjp_51",
10
- "open": "_open_1m1udjp_73",
11
- "focused": "_focused_1m1udjp_77",
12
- "searchFocused": "_searchFocused_1m1udjp_78",
13
- "error": "_error_1m1udjp_80",
14
- "searchKeyFocused": "_searchKeyFocused_1m1udjp_85",
15
- "enabled": "_enabled_1m1udjp_89",
16
- "disabled": "_disabled_1m1udjp_95",
17
- "isMulti": "_isMulti_1m1udjp_125",
18
- "iconsWrapper": "_iconsWrapper_1m1udjp_143",
19
- "labelWrapper": "_labelWrapper_1m1udjp_168",
20
- "label": "_label_1m1udjp_168",
21
- "labelNotSelected": "_labelNotSelected_1m1udjp_218",
22
- "searchInput": "_searchInput_1m1udjp_231",
23
- "multi": "_multi_1m1udjp_271",
24
- "tagsContainer": "_tagsContainer_1m1udjp_291",
25
- "tag": "_tag_1m1udjp_291",
26
- "toggle": "_toggle_1m1udjp_313",
27
- "icon": "_icon_1m1udjp_143",
28
- "clearIcon": "_clearIcon_1m1udjp_380"
2
+ "themeLight": "_themeLight_pvn8q3_27",
3
+ "themeDark": "_themeDark_pvn8q3_30",
4
+ "sizeS": "_sizeS_pvn8q3_34",
5
+ "sizeM": "_sizeM_pvn8q3_37",
6
+ "sizeL": "_sizeL_pvn8q3_40",
7
+ "classic": "_classic_pvn8q3_44",
8
+ "rock": "_rock_pvn8q3_47",
9
+ "main": "_main_pvn8q3_51",
10
+ "open": "_open_pvn8q3_80",
11
+ "searchKeyFocused": "_searchKeyFocused_pvn8q3_85",
12
+ "error": "_error_pvn8q3_89",
13
+ "disabled": "_disabled_pvn8q3_95",
14
+ "enabled": "_enabled_pvn8q3_103",
15
+ "searchFocused": "_searchFocused_pvn8q3_104",
16
+ "focused": "_focused_pvn8q3_105",
17
+ "isMulti": "_isMulti_pvn8q3_138",
18
+ "iconsWrapper": "_iconsWrapper_pvn8q3_142",
19
+ "labelWrapper": "_labelWrapper_pvn8q3_157",
20
+ "label": "_label_pvn8q3_157",
21
+ "labelNotSelected": "_labelNotSelected_pvn8q3_197",
22
+ "searchInput": "_searchInput_pvn8q3_210",
23
+ "multi": "_multi_pvn8q3_240",
24
+ "tagsContainer": "_tagsContainer_pvn8q3_256",
25
+ "tag": "_tag_pvn8q3_256",
26
+ "filledTag": "_filledTag_pvn8q3_279",
27
+ "toggle": "_toggle_pvn8q3_286",
28
+ "icon": "_icon_pvn8q3_142",
29
+ "clearIcon": "_clearIcon_pvn8q3_353"
29
30
  };
30
31
  export { styles as default };
package/lib/select.js CHANGED
@@ -11,7 +11,7 @@ import SelectTrigger from './parts/trigger.js';
11
11
  import FormTriggerWrapper from './parts/form-trigger-wrapper.js';
12
12
  import { useObservableForceRerender } from './parts/use-observable-force-rerender.js';
13
13
  import { optionType, optionsGroupType, noOptionsMessageConfigType } from './common-prop-types.js';
14
- import { useStrongMemo, getDefaultCursorIndex, isGroupsEmpty, getMovedCursorIndex, shouldOpenSelect, isIndexMatchCursor, withoutGroupsLabel, getPlainOptionsFromGroups, getEmptyMessage, OptionGroupTypes, getOptionValue, convertToOptionGroupsIfNeeded, escapeRegex, calculateMaxHeight } from './utils.js';
14
+ import { useStrongMemo, getDefaultCursorIndex, isGroupsEmpty, getMovedCursorIndex, shouldOpenSelect, isIndexMatchCursor, withoutGroupsLabel, getPlainOptionsFromGroups, getEmptyMessage, OptionGroupTypes, getOptionValue, convertToOptionGroupsIfNeeded, escapeRegex, getTextFromNodes, calculateMaxHeight } from './utils.js';
15
15
  import { ARROW_DOWN, ARROW_UP, ENTER, SPACE, TAB, ESCAPE, BACKSPACE } from './key-codes.js';
16
16
  import styles from './parts/common-select.p.module.css.js'; // eslint-disable-next-line complexity
17
17
 
@@ -125,7 +125,7 @@ const Select = _ref2 => {
125
125
  let {
126
126
  label
127
127
  } = _ref3;
128
- return filter.test(label);
128
+ return filter.test(getTextFromNodes(label));
129
129
  })
130
130
  }));
131
131
  }, [searchString, groups]);
package/lib/types.d.ts CHANGED
@@ -1,11 +1,12 @@
1
+ import React from 'react';
1
2
  export declare type SelectSize = 'l' | 'm' | 's';
2
3
  export declare type SelectMode = 'classic' | 'rock';
3
4
  export declare type SelectOption = {
4
- label: string;
5
+ label: React.ReactNode;
5
6
  value?: string;
6
7
  };
7
8
  export declare type SelectOptionsGroup = {
8
- label?: string;
9
+ label?: React.ReactNode;
9
10
  options: SelectOption[];
10
11
  };
11
12
  export declare type SelectOptionOrGroup = SelectOption | SelectOptionsGroup;
@@ -18,7 +19,7 @@ export declare type NativeSelectOption = {
18
19
  export declare type NativeSelectOptionsGroup = {
19
20
  label?: string;
20
21
  disabled?: boolean;
21
- options: SelectOption[];
22
+ options: NativeSelectOption[];
22
23
  };
23
24
  export declare type NativeSelectOptionOrGroup = NativeSelectOption | NativeSelectOptionsGroup;
24
25
  export declare type NativeSelectOptions = NativeSelectOptionOrGroup[];
package/lib/utils.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { Theme } from '@rescui/ui-contexts';
1
+ import React from 'react';
2
2
  import type { SelectOptionOrGroup, SelectOptionsGroup, NoOptionsMessage, SelectSize } from './types';
3
3
  import { Groups, Index, SelectOption } from './types';
4
+ export declare const getTextFromNodes: (node: React.ReactNode, depth?: number) => string;
4
5
  export declare function shouldOpenSelect(key: string, isTriggerTarget?: boolean): boolean;
5
6
  export declare function getEmptyMessage(isLoading: boolean, isNothingFound: boolean, noOptionsMessage: NoOptionsMessage): string;
6
7
  export declare function escapeRegex(str: string): string;
7
8
  export declare function convertToOptionGroupsIfNeeded(optionsOrGroups?: SelectOptionOrGroup[]): SelectOptionsGroup[];
8
9
  export declare const calculateMaxHeight: (size: SelectSize) => number;
9
- export declare const reverseTheme: (theme: Theme) => "light" | "dark";
10
10
  export declare function getOptionValue(option: SelectOption): string;
11
11
  export declare const OptionGroupTypes: {
12
12
  HEADER: string;
package/lib/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- import { useRef } from 'react';
1
+ import React, { useRef } from 'react';
2
2
  import { ARROW_DOWN, ARROW_UP, SPACE, ENTER } from './key-codes.js';
3
3
  const DEFAULT_NO_OPTIONS_MESSAGES = {
4
4
  noOptions: 'No options',
@@ -12,6 +12,31 @@ const ITEM_HEIGHT_BY_SIZE = {
12
12
  l: 52
13
13
  };
14
14
 
15
+ const getTextFromNodes = function (node) {
16
+ var _node$type;
17
+
18
+ let depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
19
+
20
+ if (typeof node === 'string' || typeof node === 'number') {
21
+ return node.toString();
22
+ }
23
+
24
+ if (depth > 15) {
25
+ console.warn('Max depth reached while getting text from nodes');
26
+ return '';
27
+ }
28
+
29
+ if (Array.isArray(node)) {
30
+ return node.map(n => getTextFromNodes(n, depth + 1)).join('');
31
+ }
32
+
33
+ if ( /*#__PURE__*/React.isValidElement(node) && (node === null || node === void 0 || (_node$type = node.type) === null || _node$type === void 0 ? void 0 : _node$type.toLowerCase()) !== 'svg') {
34
+ return getTextFromNodes(node.props.children, depth + 1);
35
+ }
36
+
37
+ return '';
38
+ };
39
+
15
40
  const isOptionsGroup = optionOrGroup => typeof optionOrGroup.options !== 'undefined';
16
41
 
17
42
  function shouldOpenSelect(key) {
@@ -82,12 +107,8 @@ const calculateMaxHeight = size => {
82
107
  return (Math.ceil(MAX_VISIBLE_ITEMS) + 0.5) * itemHeight;
83
108
  };
84
109
 
85
- const reverseTheme = theme => {
86
- return theme === 'dark' ? 'light' : 'dark';
87
- };
88
-
89
110
  function getOptionValue(option) {
90
- return typeof option.value === 'string' ? option.value : option.label;
111
+ return typeof option.value === 'string' ? option.value : getTextFromNodes(option.label);
91
112
  }
92
113
 
93
114
  const OptionGroupTypes = {
@@ -177,4 +198,4 @@ const isIndexMatchCursor = (cursorIndex, index) => {
177
198
 
178
199
  const withoutGroupsLabel = groups => groups.every(g => !g.label);
179
200
 
180
- export { OptionGroupTypes, calculateMaxHeight, convertToOptionGroupsIfNeeded, escapeRegex, getDefaultCursorIndex, getEmptyMessage, getMovedCursorIndex, getOptionValue, getPlainOptionsFromGroups, isGroupsEmpty, isIndexMatchCursor, reverseTheme, shouldOpenSelect, useStrongMemo, withoutGroupsLabel };
201
+ export { OptionGroupTypes, calculateMaxHeight, convertToOptionGroupsIfNeeded, escapeRegex, getDefaultCursorIndex, getEmptyMessage, getMovedCursorIndex, getOptionValue, getPlainOptionsFromGroups, getTextFromNodes, isGroupsEmpty, isIndexMatchCursor, shouldOpenSelect, useStrongMemo, withoutGroupsLabel };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rescui/select",
3
- "version": "0.12.5",
3
+ "version": "0.13.1-RUI-270-Update-select-options-label-types-b99bd91c.3+b99bd91c",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "author": "JetBrains",
@@ -16,10 +16,10 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@babel/runtime-corejs3": "^7.26.0",
19
- "@rescui/dropdown": "^0.8.4",
20
- "@rescui/menu": "^0.12.1",
21
- "@rescui/tag": "^0.12.0",
22
- "@rescui/use-resize-observer": "^0.3.0",
19
+ "@rescui/dropdown": "0.9.1-RUI-270-Update-select-options-label-types-b99bd91c.3+b99bd91c",
20
+ "@rescui/menu": "0.12.3-RUI-270-Update-select-options-label-types-b99bd91c.3+b99bd91c",
21
+ "@rescui/tag": "0.12.2-RUI-270-Update-select-options-label-types-b99bd91c.3+b99bd91c",
22
+ "@rescui/use-resize-observer": "0.3.1-RUI-270-Update-select-options-label-types-b99bd91c.49+b99bd91c",
23
23
  "classnames": "^2.2.6",
24
24
  "scroll-into-view-if-needed": "2.2.20"
25
25
  },
@@ -29,10 +29,10 @@
29
29
  "react": ">=16.8.0 <20"
30
30
  },
31
31
  "devDependencies": {
32
- "@rescui/colors": "^0.2.11",
33
- "@rescui/scripts": "^0.5.1",
34
- "@rescui/typography": "^0.24.1",
35
- "@rescui/visual-regression": "^0.1.3",
32
+ "@rescui/colors": "0.2.13-RUI-270-Update-select-options-label-types-b99bd91c.3+b99bd91c",
33
+ "@rescui/scripts": "0.5.1",
34
+ "@rescui/typography": "0.24.3-RUI-270-Update-select-options-label-types-b99bd91c.3+b99bd91c",
35
+ "@rescui/visual-regression": "0.1.4",
36
36
  "sniffr": "^1.2.0"
37
37
  },
38
38
  "scripts": {
@@ -40,5 +40,5 @@
40
40
  "build-pcss-api": "rescui-scripts build-pcss-api --file public-api.p.css"
41
41
  },
42
42
  "nx": {},
43
- "gitHead": "3f57184bd5ba6bc008d8bec7b4a76dbb231b3920"
43
+ "gitHead": "b99bd91c4c5319fed687fdfa123e195ccc8275ba"
44
44
  }