@rescui/select 0.17.0 → 0.17.1-RUI-293-Update-menu-component-7a032357e.20

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 (51) hide show
  1. package/README.md +4 -2
  2. package/lib/_virtual/index.css.js +12 -12
  3. package/lib/common-prop-types.d.ts +29 -29
  4. package/lib/constants.d.ts +6 -6
  5. package/lib/hooks/use-a11y.d.ts +30 -30
  6. package/lib/hooks/use-actual-size-from-css.d.ts +10 -10
  7. package/lib/hooks/use-actual-size-from-css.js +1 -1
  8. package/lib/hooks/use-focus.d.ts +10 -10
  9. package/lib/hooks/use-hover.d.ts +10 -10
  10. package/lib/hooks/use-label-focus.d.ts +9 -9
  11. package/lib/hooks/use-multi-handlers.d.ts +11 -11
  12. package/lib/hooks/use-options.d.ts +13 -14
  13. package/lib/hooks/use-options.js +5 -5
  14. package/lib/hooks/use-primary-contrast-css-var-transfer.d.ts +11 -11
  15. package/lib/hooks/use-primary-contrast-css-var-transfer.js +2 -2
  16. package/lib/hooks/use-safe-id.d.ts +6 -6
  17. package/lib/index.css +189 -189
  18. package/lib/index.d.ts +4 -4
  19. package/lib/multiselect.d.ts +3 -3
  20. package/lib/multiselect.js +1 -0
  21. package/lib/native-select.d.ts +4 -4
  22. package/lib/parts/foldable.d.ts +34 -33
  23. package/lib/parts/form-trigger-wrapper.d.ts +34 -34
  24. package/lib/parts/hidden-select.d.ts +13 -13
  25. package/lib/parts/icons.d.ts +17 -17
  26. package/lib/parts/list-box.d.ts +13 -13
  27. package/lib/parts/multi-trigger.d.ts +12 -12
  28. package/lib/parts/native-select-options-with-groups.d.ts +8 -8
  29. package/lib/parts/popup-content.d.ts +20 -20
  30. package/lib/select-basic.d.ts +3 -3
  31. package/lib/select-searchable.d.ts +3 -3
  32. package/lib/select.d.ts +28 -28
  33. package/lib/styles/common.p.module.css.js +29 -29
  34. package/lib/styles/form-trigger.p.module.css.js +12 -12
  35. package/lib/styles/list-box.p.module.css.js +13 -13
  36. package/lib/types.d.ts +202 -202
  37. package/lib/utils/calculate-max-height-by-items.d.ts +13 -13
  38. package/lib/utils/calculate-max-height-by-items.js +11 -11
  39. package/lib/utils/get-empty-message.d.ts +6 -6
  40. package/lib/utils/get-option-value.d.ts +2 -2
  41. package/lib/utils/get-real-items-cnt.d.ts +2 -2
  42. package/lib/utils/get-text-from-nodes.d.ts +2 -2
  43. package/lib/utils/is-option-a-group.d.ts +2 -2
  44. package/lib/utils/item-to-string.d.ts +2 -2
  45. package/lib/utils/merge-props.d.ts +19 -19
  46. package/lib/utils/merge-props.js +17 -17
  47. package/lib/utils/throttle.d.ts +1 -1
  48. package/llm/components/multiselect.md +237 -0
  49. package/llm/components/select.md +549 -0
  50. package/llm/index.md +3 -0
  51. package/package.json +11 -10
@@ -0,0 +1,237 @@
1
+ # Multiselect
2
+
3
+ Multiselect is a control that allows users to select multiple options from a list.
4
+
5
+ ## Usage
6
+
7
+ ### Features showcase
8
+
9
+ #### Example:
10
+
11
+ You can control what has been selected through `value`/`onChange` props combination. The state represents the collection of options displayed in the select box. The empty state represents by `[]`.
12
+
13
+ ```tsx
14
+ import { useState } from 'react';
15
+ import { Multiselect } from '@rescui/select';
16
+
17
+ const options = [
18
+ { label: 'St. Petersburg', value: 'spb' },
19
+ { label: 'Moscow', value: 'msk' },
20
+ { label: 'Novosibirsk', value: 'nsk' },
21
+ { label: 'Prague', value: 'prg' },
22
+ { label: 'Boston', value: 'bos' },
23
+ { label: 'Munich', value: 'muc' }
24
+ ];
25
+
26
+ const MySelect = () => {
27
+ const [selected, setSelected] = useState([options[0], options[5]]);
28
+
29
+ return (
30
+ <div>
31
+ <span>Selected cities: </span>
32
+ <code>{JSON.stringify(selected)}</code>
33
+ <div style={{ maxWidth: '380px', marginTop: '24px' }}>
34
+ <Multiselect
35
+ options={options}
36
+ value={selected}
37
+ onChange={value => {
38
+ console.log('value', value);
39
+ setSelected(value);
40
+ }}
41
+ size="m"
42
+ placeholder="Сhoose your favorite cities..."
43
+ aria-label="Сhoose your favorite cities"
44
+ />
45
+ </div>
46
+ </div>
47
+ );
48
+ };
49
+
50
+ render(<MySelect />);
51
+ ```
52
+
53
+ #### SingleLine mode:
54
+
55
+ You can use the `isSingleLine` prop to limit from grow and force it to be always single line. In this case extra tags is hidden and display the count of hidden tags instead.
56
+
57
+ ```tsx
58
+ import { useState } from 'react';
59
+ import { Multiselect } from '@rescui/select';
60
+
61
+ const options = [
62
+ { label: 'Blue', value: 'blue' },
63
+ { label: 'Black', value: 'black' },
64
+ { label: 'Red', value: 'red' },
65
+ { label: 'Orange', value: 'orange' },
66
+ { label: 'Yellow', value: 'yellow' },
67
+ { label: 'White', value: 'white' }
68
+ ];
69
+
70
+ const MySelect = () => {
71
+ const [selected, setSelected] = useState([options[1], options[5]]);
72
+
73
+ return (
74
+ <div style={{ maxWidth: '380px' }}>
75
+ <Multiselect
76
+ className="clazz"
77
+ options={options}
78
+ value={selected}
79
+ onChange={value => setSelected(value)}
80
+ isSingleLine
81
+ size="m"
82
+ placeholder="Select colors..."
83
+ aria-label="Select colors"
84
+ />
85
+ </div>
86
+ );
87
+ };
88
+
89
+ render(<MySelect />);
90
+ ```
91
+
92
+ #### Contrast primary color
93
+
94
+ If your primary color background requires dark text color, use `--rs-select-contrast-primary` CSS variable.
95
+
96
+ ```tsx
97
+ import { useState } from 'react';
98
+ import { Multiselect } from '@rescui/select';
99
+
100
+ const options = [
101
+ { label: 'St. Petersburg', value: 'spb' },
102
+ { label: 'Moscow', value: 'msk' },
103
+ { label: 'Novosibirsk', value: 'nsk' },
104
+ { label: 'Prague', value: 'prg' },
105
+ { label: 'Boston', value: 'bos' },
106
+ { label: 'Munich', value: 'muc' }
107
+ ];
108
+
109
+ const MySelect = () => {
110
+ const [selected, setSelected] = useState([options[0], options[5]]);
111
+
112
+ return (
113
+ <div>
114
+ <span>Selected cities: </span>
115
+ <code>{JSON.stringify(selected)}</code>
116
+ <div
117
+ style={{ maxWidth: '380px', marginTop: '24px' }}
118
+ className="light-green-primary"
119
+ >
120
+ <Multiselect
121
+ options={options}
122
+ value={selected}
123
+ onChange={setSelected}
124
+ size="m"
125
+ className="select-with-contrast-primary"
126
+ placeholder="Сhoose your favorite cities..."
127
+ aria-label="Сhoose your favorite cities"
128
+ />
129
+ </div>
130
+ </div>
131
+ );
132
+ };
133
+
134
+ render(<MySelect />);
135
+ ```
136
+
137
+ ```postcss
138
+ .select-with-contrast-primary {
139
+ --rs-select-contrast-primary: 1;
140
+ }
141
+
142
+ .light-green-primary {
143
+ --rs-color-primary-light-theme: rgb(71, 224, 84);
144
+ --rs-color-primary-t-dim-light-theme: rgba(71, 224, 84, 0.8);
145
+ --rs-color-primary-t-fog-light-theme: rgba(71, 224, 84, 0.2);
146
+
147
+ --rs-color-primary-dark-theme: rgb(71, 224, 84);
148
+ --rs-color-primary-t-dim-dark-theme: rgba(71, 224, 84, 0.8);
149
+ --rs-color-primary-t-fog-dark-theme: rgba(71, 224, 84, 0.2);
150
+ }
151
+ ```
152
+
153
+ ## CSS Mixins API
154
+
155
+ #### `Multiselect` mixins
156
+
157
+ | Mixin name | Details |
158
+ | --- | --- |
159
+ | `rs-multiselect-size-s` | prop: `size`<br><br>value: `"s"` |
160
+ | `rs-multiselect-size-m` | prop: `size`<br><br>value: `"m"` |
161
+ | `rs-multiselect-size-l` | prop: `size`<br><br>value: `"l"` |
162
+
163
+ #### Demo
164
+
165
+ Resize the grey area below to see the effect.
166
+
167
+ You can use `@media` queries instead of `@container` queries:
168
+
169
+ ```tsx
170
+ import { useState } from 'react';
171
+ import { Multiselect } from '@rescui/select';
172
+
173
+ const options = [
174
+ { label: 'St. Petersburg', value: 'spb' },
175
+ { label: 'Moscow', value: 'msk' },
176
+ { label: 'Novosibirsk', value: 'nsk' },
177
+ { label: 'Prague', value: 'prg' },
178
+ { label: 'Boston', value: 'bos' },
179
+ { label: 'Munich', value: 'muc' }
180
+ ];
181
+
182
+ const MyMultiselect = ({ className }) => {
183
+ const [selected, setSelected] = useState([options[0], options[5]]);
184
+
185
+ return (
186
+ <div style={{ maxWidth: '380px' }}>
187
+ <Multiselect
188
+ options={options}
189
+ value={selected}
190
+ onChange={value => setSelected(value)}
191
+ size="m"
192
+ placeholder="Сhoose your favorite cities..."
193
+ aria-label="Choose your favorite cities"
194
+ className={className}
195
+ />
196
+ </div>
197
+ );
198
+ };
199
+
200
+ render(
201
+ <div className="preview-container">
202
+ <p style={{ position: 'absolute', right: 12, bottom: 12 }}>Resize me</p>
203
+ <MyMultiselect className="my-multiselect" />
204
+ </div>
205
+ );
206
+ ```
207
+
208
+ ```postcss
209
+ @import '@rescui/select/lib/public-api.p.css';
210
+
211
+ .preview-container {
212
+ position: relative;
213
+ container-type: inline-size;
214
+ resize: horizontal;
215
+ overflow: auto;
216
+ padding: 12px;
217
+ background-color: var(--rs-color-black-t5);
218
+ max-width: 800px;
219
+ }
220
+
221
+ .my-multiselect {
222
+ @container (max-width: 640px) {
223
+ @mixin rs-multiselect-size-l;
224
+ }
225
+ @container (max-width: 500px) {
226
+ @mixin rs-multiselect-size-s;
227
+ }
228
+ }
229
+ ```
230
+
231
+ #### `Select` CSS Vars
232
+
233
+ | Variable | Syntax | Description |
234
+ | --- | --- | --- |
235
+ | `--rs-select-contrast-primary` | `0 \| 1` | The flag whenever the current primary is contrast enough and highlighted text color should be inverted |
236
+
237
+ Check out [this example](/components/multiselect/#contrast-primary-color) for contrast primary.