@rescui/select 0.12.5 → 0.13.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.
@@ -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_1bcjdbr_3",
3
+ "sizeM": "_sizeM_1bcjdbr_6",
4
+ "sizeL": "_sizeL_1bcjdbr_9",
5
+ "menu": "_menu_1bcjdbr_13",
6
+ "menuSizeS": "_menuSizeS_1bcjdbr_26",
7
+ "menuSizeM": "_menuSizeM_1bcjdbr_30",
8
+ "menuSizeL": "_menuSizeL_1bcjdbr_34",
9
+ "withGroupsLabel": "_withGroupsLabel_1bcjdbr_40",
10
+ "lastOption": "_lastOption_1bcjdbr_39",
11
+ "divider": "_divider_1bcjdbr_45",
12
+ "checkIcon": "_checkIcon_1bcjdbr_51",
13
+ "observable": "_observable_1bcjdbr_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_1ewks2a_7",
3
+ "themeDark": "_themeDark_1ewks2a_10",
4
+ "sizeS": "_sizeS_1ewks2a_14",
5
+ "sizeM": "_sizeM_1ewks2a_17",
6
+ "sizeL": "_sizeL_1ewks2a_20",
7
+ "main": "_main_1ewks2a_24",
8
+ "label": "_label_1ewks2a_28",
9
+ "errorMessage": "_errorMessage_1ewks2a_34",
10
+ "errorIcon": "_errorIcon_1ewks2a_45",
11
+ "note": "_note_1ewks2a_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_8r62c0_6",
3
+ "sizeM": "_sizeM_8r62c0_9",
4
+ "sizeL": "_sizeL_8r62c0_12",
5
+ "main": "_main_8r62c0_16",
6
+ "wrapper": "_wrapper_8r62c0_20",
7
+ "select": "_select_8r62c0_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,12 @@
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';
12
11
  import Foldable from './foldable.js';
13
12
  import styles from './trigger.p.module.css.js';
14
13
  const THEME_STYLES = {
@@ -23,111 +22,14 @@ const SIZE_STYLES = {
23
22
  const MODE_STYLES = {
24
23
  classic: styles.classic,
25
24
  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';
25
+ };
122
26
 
123
27
  const MultiselectOptions = _ref => {
124
28
  let {
125
29
  isSingleLine,
126
30
  selected,
127
- isThemeReversed,
128
31
  isDisabled,
129
- onItemClearClick,
130
- theme
32
+ onItemClearClick
131
33
  } = _ref;
132
34
  const selectedOptions = selected.map(s => {
133
35
  const key = s.value ? s.value : s.label;
@@ -138,22 +40,19 @@ const MultiselectOptions = _ref => {
138
40
  disabled: isDisabled,
139
41
  onRemoveClick: () => onItemClearClick(s),
140
42
  "data-rs-internal": 'select-trigger__removable-tag',
141
- wrap: !isSingleLine,
142
- theme: isThemeReversed ? reverseTheme(theme) : theme
43
+ wrap: !isSingleLine
143
44
  }, s.label);
144
45
  });
145
- const tagTheme = isThemeReversed ? reverseTheme(theme) : theme;
146
46
  return /*#__PURE__*/React.createElement("div", {
147
47
  className: styles.multi,
148
48
  "data-test": "multi"
149
49
  }, isSingleLine ? /*#__PURE__*/React.createElement(Foldable, {
150
50
  className: styles.tagsContainer,
151
51
  renderHiddenCounter: (n, ref) => /*#__PURE__*/React.createElement(Tag, {
152
- className: styles.tag,
52
+ className: cn(styles.tag, styles.filledTag),
153
53
  key: "+",
154
54
  ref: ref,
155
- "data-rs-internal": 'select-trigger__tag',
156
- ...presets[`filled-${tagTheme}`]
55
+ "data-rs-internal": 'select-trigger__tag'
157
56
  }, `+${n}`)
158
57
  }, selectedOptions) : /*#__PURE__*/React.createElement("div", {
159
58
  className: styles.tagsContainer
@@ -236,8 +135,100 @@ const ClearOrLoading = _ref3 => {
236
135
  } else {
237
136
  return null;
238
137
  }
239
- };
138
+ }; // eslint-disable-next-line complexity
139
+
140
+
141
+ const SelectTrigger = /*#__PURE__*/React.memo(props => {
142
+ const {
143
+ size,
144
+ mode,
145
+ theme: themeFromProps,
146
+ className,
147
+ triggerRef,
148
+ isOpen,
149
+ selected = null,
150
+ placeholder,
151
+ isClearable,
152
+ isLoading,
153
+ isDisabled,
154
+ isSingleLine,
155
+ searchInput,
156
+ isSearchable,
157
+ onClearClick,
158
+ onItemClearClick,
159
+ onSearchChange,
160
+ error,
161
+ ...restProps
162
+ } = props;
163
+ const theme = useThemeWithUndefined(themeFromProps);
164
+ const inputRef = useRef(null);
165
+ const [isSearchFocused, setIsSearchFocused] = useState(false);
166
+ const [isFocused, setIsFocused] = useState(false);
167
+ const [isSearchKeyFocused, setIsSearchKeyFocused] = useState(false);
168
+ const isMulti = selected ? Boolean(selected.length) : false;
169
+
170
+ const handleChange = event => {
171
+ const newValue = event.target.value;
172
+ onSearchChange(newValue);
173
+ };
174
+
175
+ const handleBlur = () => {
176
+ if (isSearchable && inputRef.current) {
177
+ setIsSearchFocused(false);
178
+ setIsSearchKeyFocused(false);
179
+ }
180
+ };
181
+
182
+ const handleFocus = e => {
183
+ if (isSearchable && inputRef.current) {
184
+ setIsSearchFocused(true);
185
+ const target = e.target;
186
+ setIsSearchKeyFocused(target.getAttribute('data-focus-method') === 'key');
187
+ }
188
+ };
240
189
 
190
+ return /*#__PURE__*/React.createElement("div", {
191
+ tabIndex: isSearchable || isDisabled ? -1 : 0,
192
+ 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),
193
+ onFocus: e => {
194
+ const target = e.target;
195
+ setIsFocused(target.getAttribute('data-focus-method') === 'key');
196
+ },
197
+ onBlur: () => setIsFocused(false),
198
+ ref: triggerRef,
199
+ "data-test": "select",
200
+ "data-rs-internal": 'select-trigger',
201
+ ...restProps
202
+ }, isMulti ? /*#__PURE__*/React.createElement(MultiselectOptions, {
203
+ selected: selected,
204
+ isDisabled: isDisabled,
205
+ isSingleLine: isSingleLine,
206
+ onItemClearClick: onItemClearClick
207
+ }) : /*#__PURE__*/React.createElement(SelectedOption, {
208
+ selected: selected,
209
+ placeholder: placeholder,
210
+ searchInput: searchInput,
211
+ isSearchable: isSearchable,
212
+ isDisabled: isDisabled,
213
+ inputRef: inputRef,
214
+ handleBlur: handleBlur,
215
+ handleFocus: handleFocus,
216
+ handleChange: handleChange
217
+ }), /*#__PURE__*/React.createElement("div", {
218
+ className: styles.iconsWrapper
219
+ }, /*#__PURE__*/React.createElement(ClearOrLoading, {
220
+ isLoading: isLoading,
221
+ isDisabled: isDisabled,
222
+ isClearable: isClearable,
223
+ onClearClick: onClearClick,
224
+ selected: selected
225
+ }), /*#__PURE__*/React.createElement(DownIcon, {
226
+ className: styles.toggle,
227
+ "data-test": "down-icon",
228
+ "data-render-all-sizes": true
229
+ })));
230
+ });
231
+ SelectTrigger.displayName = 'SelectTrigger';
241
232
  SelectTrigger.propTypes = {
242
233
  size: PropTypes.oneOf(['m', 's', 'l']),
243
234
  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_xqlygf_27",
3
+ "themeDark": "_themeDark_xqlygf_30",
4
+ "sizeS": "_sizeS_xqlygf_34",
5
+ "sizeM": "_sizeM_xqlygf_37",
6
+ "sizeL": "_sizeL_xqlygf_40",
7
+ "classic": "_classic_xqlygf_44",
8
+ "rock": "_rock_xqlygf_47",
9
+ "main": "_main_xqlygf_51",
10
+ "open": "_open_xqlygf_80",
11
+ "searchKeyFocused": "_searchKeyFocused_xqlygf_85",
12
+ "error": "_error_xqlygf_89",
13
+ "disabled": "_disabled_xqlygf_95",
14
+ "enabled": "_enabled_xqlygf_103",
15
+ "searchFocused": "_searchFocused_xqlygf_104",
16
+ "focused": "_focused_xqlygf_105",
17
+ "isMulti": "_isMulti_xqlygf_138",
18
+ "iconsWrapper": "_iconsWrapper_xqlygf_142",
19
+ "labelWrapper": "_labelWrapper_xqlygf_157",
20
+ "label": "_label_xqlygf_157",
21
+ "labelNotSelected": "_labelNotSelected_xqlygf_197",
22
+ "searchInput": "_searchInput_xqlygf_210",
23
+ "multi": "_multi_xqlygf_240",
24
+ "tagsContainer": "_tagsContainer_xqlygf_256",
25
+ "tag": "_tag_xqlygf_256",
26
+ "filledTag": "_filledTag_xqlygf_279",
27
+ "toggle": "_toggle_xqlygf_286",
28
+ "icon": "_icon_xqlygf_142",
29
+ "clearIcon": "_clearIcon_xqlygf_353"
29
30
  };
30
31
  export { styles as default };
package/lib/utils.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { Theme } from '@rescui/ui-contexts';
2
1
  import type { SelectOptionOrGroup, SelectOptionsGroup, NoOptionsMessage, SelectSize } from './types';
3
2
  import { Groups, Index, SelectOption } from './types';
4
3
  export declare function shouldOpenSelect(key: string, isTriggerTarget?: boolean): boolean;
@@ -6,7 +5,6 @@ export declare function getEmptyMessage(isLoading: boolean, isNothingFound: bool
6
5
  export declare function escapeRegex(str: string): string;
7
6
  export declare function convertToOptionGroupsIfNeeded(optionsOrGroups?: SelectOptionOrGroup[]): SelectOptionsGroup[];
8
7
  export declare const calculateMaxHeight: (size: SelectSize) => number;
9
- export declare const reverseTheme: (theme: Theme) => "light" | "dark";
10
8
  export declare function getOptionValue(option: SelectOption): string;
11
9
  export declare const OptionGroupTypes: {
12
10
  HEADER: string;
package/lib/utils.js CHANGED
@@ -82,10 +82,6 @@ const calculateMaxHeight = size => {
82
82
  return (Math.ceil(MAX_VISIBLE_ITEMS) + 0.5) * itemHeight;
83
83
  };
84
84
 
85
- const reverseTheme = theme => {
86
- return theme === 'dark' ? 'light' : 'dark';
87
- };
88
-
89
85
  function getOptionValue(option) {
90
86
  return typeof option.value === 'string' ? option.value : option.label;
91
87
  }
@@ -177,4 +173,4 @@ const isIndexMatchCursor = (cursorIndex, index) => {
177
173
 
178
174
  const withoutGroupsLabel = groups => groups.every(g => !g.label);
179
175
 
180
- export { OptionGroupTypes, calculateMaxHeight, convertToOptionGroupsIfNeeded, escapeRegex, getDefaultCursorIndex, getEmptyMessage, getMovedCursorIndex, getOptionValue, getPlainOptionsFromGroups, isGroupsEmpty, isIndexMatchCursor, reverseTheme, shouldOpenSelect, useStrongMemo, withoutGroupsLabel };
176
+ export { OptionGroupTypes, calculateMaxHeight, convertToOptionGroupsIfNeeded, escapeRegex, getDefaultCursorIndex, getEmptyMessage, getMovedCursorIndex, getOptionValue, getPlainOptionsFromGroups, 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.0",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "author": "JetBrains",
@@ -16,9 +16,9 @@
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",
19
+ "@rescui/dropdown": "^0.9.0",
20
+ "@rescui/menu": "^0.12.2",
21
+ "@rescui/tag": "^0.12.1",
22
22
  "@rescui/use-resize-observer": "^0.3.0",
23
23
  "classnames": "^2.2.6",
24
24
  "scroll-into-view-if-needed": "2.2.20"
@@ -29,10 +29,10 @@
29
29
  "react": ">=16.8.0 <20"
30
30
  },
31
31
  "devDependencies": {
32
- "@rescui/colors": "^0.2.11",
32
+ "@rescui/colors": "^0.2.12",
33
33
  "@rescui/scripts": "^0.5.1",
34
- "@rescui/typography": "^0.24.1",
35
- "@rescui/visual-regression": "^0.1.3",
34
+ "@rescui/typography": "^0.24.2",
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": "4c9832a9e5fc1fe7a9a0c863f73f7f14088e3fd5"
44
44
  }