react-animated-select 0.3.1 → 0.3.6
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.
- package/README.md +31 -49
- package/demo/package-lock.json +5 -5
- package/demo/package.json +3 -2
- package/demo/src/App.tsx +56 -43
- package/demo/src/rac.css +6 -25
- package/dist/index.cjs.js +6 -6
- package/dist/index.css +1 -1
- package/dist/index.es.js +911 -769
- package/index.d.ts +10 -1
- package/package.json +1 -1
- package/src/index.js +1 -0
- package/src/optgroup.jsx +36 -0
- package/src/option.jsx +29 -13
- package/src/options.jsx +11 -11
- package/src/select.css +39 -2
- package/src/select.jsx +203 -263
- package/src/selectContext.js +1 -1
- package/src/selectJSX.jsx +148 -0
- package/src/slideDown.jsx +36 -0
- package/src/useSelect.jsx +83 -118
- package/src/useSelectLogic.jsx +184 -139
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
A lightweight, high-performance, and fully customizable Select component for React. Featuring smooth CSS animations, accessible keyboard navigation, and flexible option rendering.
|
|
4
4
|
|
|
5
5
|
**Try it out:**
|
|
6
|
+
|
|
6
7
|
[](https://l1nway.github.io/react-animated-select/)
|
|
7
8
|
|
|
8
9
|
## Features
|
|
@@ -130,12 +131,21 @@ function App() {
|
|
|
130
131
|
|
|
131
132
|
| Prop | Type | Description |
|
|
132
133
|
|------|------|-------------|
|
|
133
|
-
| `id` | `string` | Optional unique ID (generated automatically if not provided). value may be used instead of id (lower priority)|
|
|
134
|
+
| `id` | `string` | Optional unique ID (generated automatically if not provided). value may be used instead of id (lower priority). |
|
|
134
135
|
| `disabled` | `boolean` | If true, this option cannot be selected or highlighted. |
|
|
135
136
|
| `className` | `string` | Custom class for individual option styling. |
|
|
136
137
|
|
|
137
138
|
---
|
|
138
139
|
|
|
140
|
+
### `<OptGroup />`
|
|
141
|
+
|
|
142
|
+
| Prop | Type | Description |
|
|
143
|
+
|------|------|-------------|
|
|
144
|
+
| `id` | `string` | Optional unique ID (generated automatically if not provided). value may be used instead of id (lower priority). |
|
|
145
|
+
| `name` | `string` | OptGroup title. label may be used instead of id (lower priority). |
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
139
149
|
## Keyboard Support
|
|
140
150
|
|
|
141
151
|
| Key | Action |
|
|
@@ -210,6 +220,14 @@ The component uses CSS variables for deep styling. These are based on system col
|
|
|
210
220
|
| `--rac-option-min-height` | `1em` | Minimum option height. |
|
|
211
221
|
| `--rac-invalid-option-color` | `color-mix(...)` | Text color for invalid options. |
|
|
212
222
|
| `--rac-warning-option-color` | `color-mix(...)` | Text color for warning/caution options. |
|
|
223
|
+
| **Group Headers** | | |
|
|
224
|
+
| `--rac-group-header-font-size` | `1.25em` | Font size of the group header label. |
|
|
225
|
+
| `--rac-group-header-font-weight` | `bold` | Font weight of the group header text. |
|
|
226
|
+
| `--rac-group-header-min-height` | `1em` | Minimum height of the group header item. |
|
|
227
|
+
| `--rac-group-header-padding` | `0.5em` | Internal padding for the group header. |
|
|
228
|
+
| `--rac-group-arrow-height` | `1em` | Height of the group expand/collapse arrow icon. |
|
|
229
|
+
| `--rac-group-arrow-width` | `1em` | Width of the group expand/collapse arrow icon. |
|
|
230
|
+
| `--rac-group-arrow-padding` | `1px 0 2px` | Padding applied to the group arrow icon. |
|
|
213
231
|
|
|
214
232
|
---
|
|
215
233
|
|
|
@@ -247,59 +265,23 @@ The select and its options react to internal states by applying the following cl
|
|
|
247
265
|
- `.rac-invalid-option`: Applied to items that are not valid data types (e.g., functions).
|
|
248
266
|
- `.rac-true-option`: Specialized styling when the option's raw value is exactly `true`.
|
|
249
267
|
- `.rac-false-option`: Specialized styling when the option's raw value is exactly `false`.
|
|
268
|
+
#### Group Header States (applied to group-related elements)
|
|
269
|
+
- `.rac-group-header`: Base class for the group header container.
|
|
270
|
+
- `.rac-group-title-text`: Applied to the text/label inside the group header.
|
|
271
|
+
- `.rac-group-arrow-wrapper`: Wrapper class for the group expand/collapse arrow icon.
|
|
250
272
|
|
|
251
273
|
#### Trigger States
|
|
252
274
|
- `.rac-select-arrow-wrapper.--open`: Applied to the arrow icon when the dropdown is expanded.
|
|
253
275
|
|
|
254
276
|
## Change log
|
|
255
|
-
### 0.3.
|
|
256
|
-
|
|
257
|
-
-
|
|
258
|
-
|
|
259
|
-
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
- **
|
|
263
|
-
- Added `loadMore` mechanism for infinite or paginated option lists.
|
|
264
|
-
- Automatic loading when scrolling near the end of the list.
|
|
265
|
-
- Automatic loading when navigating with keyboard near the last options.
|
|
266
|
-
- **Demo preview**
|
|
267
|
-
- Added an interactive demo showcasing all Select component features.
|
|
268
|
-
----------
|
|
269
|
-
### Improvements
|
|
270
|
-
- **Keyboard navigation**
|
|
271
|
-
- Navigation behaves predictably with infinite loading enabled.
|
|
272
|
-
- **Options handling**
|
|
273
|
-
- Extended support for options passed both via props and JSX.
|
|
274
|
-
- Improved internal merging logic for mixed option sources.
|
|
275
|
-
- **Focus management**
|
|
276
|
-
- Removed unnecessary focus on the options list container.
|
|
277
|
-
- Improved overall keyboard navigation flow.
|
|
278
|
-
- **Visual consistency**
|
|
279
|
-
- Improved layout stability and rendering consistency across option states.
|
|
280
|
-
----------
|
|
281
|
-
### Fixes
|
|
282
|
-
- **Object value matching**
|
|
283
|
-
- Fixed an issue where the Select could not correctly find the selected option when it was passed as an object.
|
|
284
|
-
- Selection matching now works correctly using reference comparison and structural analysis.
|
|
285
|
-
- **Opacity rendering**
|
|
286
|
-
- Fixed incorrect opacity handling for various option states.
|
|
287
|
-
- **JSX identifier validation**
|
|
288
|
-
- Fixed an issue where passing an empty `id` to `<Option id="" />` caused the option text to be lost.
|
|
289
|
-
- The parser now prioritizes any available meaningful content.
|
|
290
|
-
- **Focus issues**
|
|
291
|
-
- Fixed extra and unintended focus being applied to the options list on open.
|
|
292
|
-
----------
|
|
293
|
-
### Styling & UI
|
|
294
|
-
- **UI stability**
|
|
295
|
-
- Added `--rac-option-min-height` CSS variable to prevent layout breaking when option content is smaller than others.
|
|
296
|
-
- **Loading indication**
|
|
297
|
-
- Added `.rac-loading-option` class for styling loading items.
|
|
298
|
-
- Added `--rac-loading-option-opacity` CSS variable to control loading state transparency.
|
|
299
|
-
----------
|
|
300
|
-
### Accessibility
|
|
301
|
-
- Improved keyboard interaction consistency.
|
|
302
|
-
- Prevented non-interactive (loading) options from being focusable or selectable.
|
|
277
|
+
### 0.3.5
|
|
278
|
+
### New Features
|
|
279
|
+
- **Hierarchical Grouping Engine**: Added full support for nested options using a flat-array normalization technique. This allows for clear visual separation of categories with zero performance overhead.
|
|
280
|
+
- **Smart "SlideDown" Groups**: Implemented collapsible group headers with smooth animations.
|
|
281
|
+
- _Self-Aware UI:_ Group arrows now automatically hide if a group contains no items, providing a cleaner look for empty categories.
|
|
282
|
+
- **Flexible Data Normalization**: The logic now seamlessly handles `Arrays`, `Objects` (maps), and `JSX` children simultaneously.
|
|
283
|
+
### Bug Fixes
|
|
284
|
+
- **Dynamic Load Button Toggle**: Fixed a critical bug where the "Load More" button's visibility wouldn't update dynamically. The component now correctly reacts to real-time changes in the `loadButton` and `hasMore` props.
|
|
303
285
|
|
|
304
286
|
## License
|
|
305
287
|
|
package/demo/package-lock.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@fortawesome/react-fontawesome": "^3.1.1",
|
|
14
14
|
"framer-motion": "^12.27.5",
|
|
15
15
|
"react": "^19.2.0",
|
|
16
|
-
"react-animated-select": "^0.3.
|
|
16
|
+
"react-animated-select": "^0.3.1",
|
|
17
17
|
"react-dom": "^19.2.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"eslint-plugin-react-refresh": "^0.4.24",
|
|
27
27
|
"gh-pages": "^6.3.0",
|
|
28
28
|
"globals": "^16.5.0",
|
|
29
|
-
"vite": "npm:rolldown-vite
|
|
29
|
+
"vite": "npm:rolldown-vite@^7.2.5"
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"node_modules/@babel/code-frame": {
|
|
@@ -2911,9 +2911,9 @@
|
|
|
2911
2911
|
}
|
|
2912
2912
|
},
|
|
2913
2913
|
"node_modules/react-animated-select": {
|
|
2914
|
-
"version": "0.3.
|
|
2915
|
-
"resolved": "https://registry.npmjs.org/react-animated-select/-/react-animated-select-0.3.
|
|
2916
|
-
"integrity": "sha512-
|
|
2914
|
+
"version": "0.3.1",
|
|
2915
|
+
"resolved": "https://registry.npmjs.org/react-animated-select/-/react-animated-select-0.3.1.tgz",
|
|
2916
|
+
"integrity": "sha512-NqAuuLImpRt0eLs94SFmLyOujn1NNKZ8v0f1xQhKJvvjsY7qkc0oyegqt8KZrn0Z3ypqoyOnEsLOo5cFyAQXhg==",
|
|
2917
2917
|
"license": "MIT",
|
|
2918
2918
|
"dependencies": {
|
|
2919
2919
|
"react-transition-group": "^4.4.5"
|
package/demo/package.json
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite",
|
|
8
8
|
"build": "vite build",
|
|
9
|
+
"predeploy": "npm run build",
|
|
9
10
|
"deploy": "gh-pages -d dist",
|
|
10
11
|
"lint": "eslint .",
|
|
11
12
|
"preview": "vite preview"
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
"@fortawesome/react-fontawesome": "^3.1.1",
|
|
17
18
|
"framer-motion": "^12.27.5",
|
|
18
19
|
"react": "^19.2.0",
|
|
19
|
-
"react-animated-select": "^0.3.
|
|
20
|
+
"react-animated-select": "^0.3.1",
|
|
20
21
|
"react-dom": "^19.2.0"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
"eslint-plugin-react-refresh": "^0.4.24",
|
|
30
31
|
"gh-pages": "^6.3.0",
|
|
31
32
|
"globals": "^16.5.0",
|
|
32
|
-
"vite": "npm:rolldown-vite
|
|
33
|
+
"vite": "npm:rolldown-vite@^7.2.5"
|
|
33
34
|
},
|
|
34
35
|
"overrides": {
|
|
35
36
|
"vite": "npm:rolldown-vite@7.2.5"
|
package/demo/src/App.tsx
CHANGED
|
@@ -38,19 +38,61 @@ function App() {
|
|
|
38
38
|
const [offset, setOffset] = useState<number>(2)
|
|
39
39
|
const [animateOpacity, setAnimateOpacity] = useState<boolean>(true)
|
|
40
40
|
const [alwaysOpen, setAlwaysOpen] = useState<boolean>(false)
|
|
41
|
+
const [hasMore, setHasMore] = useState<boolean>(false)
|
|
42
|
+
const [loadButton, setLoadButton] = useState<boolean>(false)
|
|
43
|
+
const [loadButtonText, setLoadButtonText] = useState<string>('Load more')
|
|
44
|
+
const [loadMoreText, setLoadMoreText] = useState<string>('Loading')
|
|
45
|
+
const [loadOffset, setLoadOffset] = useState<number>(100)
|
|
46
|
+
const [loadAhead, setLoadAhead] = useState<number>(3)
|
|
41
47
|
|
|
42
48
|
type SettingItem = {
|
|
43
49
|
label: string
|
|
44
|
-
state: boolean
|
|
45
|
-
|
|
50
|
+
state: number | boolean
|
|
51
|
+
default?: number
|
|
52
|
+
min?: number
|
|
53
|
+
max?: number
|
|
54
|
+
step?: number
|
|
55
|
+
unit?: string
|
|
56
|
+
setState: (value: number | boolean) => void
|
|
46
57
|
}
|
|
47
58
|
|
|
59
|
+
const ranges: SettingItem[] = [
|
|
60
|
+
{label: 'duration', default: 300, min: 0, max: 1000, step: 50, unit: 'ms', state: duration, setState: setDuration},
|
|
61
|
+
{label: 'offset', default: 3, min: 0, max: 25, step: 1, unit: 'px', state: offset, setState: setOffset},
|
|
62
|
+
{label: 'loadAhead', default: 3, min: 0, max: 15, step: 1, unit: 'options', state: loadAhead, setState: setLoadAhead},
|
|
63
|
+
{label: 'loadOffset', default: 100, min: 0, max: 1000, step: 50, unit: 'px', state: loadOffset, setState: setLoadOffset}
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
const renderRanges: JSX.Element[] = ranges.map((item) => (
|
|
67
|
+
<label
|
|
68
|
+
className='rac-range-label'
|
|
69
|
+
key={item.label}
|
|
70
|
+
>
|
|
71
|
+
<span
|
|
72
|
+
className='rac-prop-span'
|
|
73
|
+
>
|
|
74
|
+
{item.label}: {item.state ?? item.default}{item.unit}
|
|
75
|
+
</span>
|
|
76
|
+
<input
|
|
77
|
+
className='rac-range-input'
|
|
78
|
+
type='range'
|
|
79
|
+
min={item.min}
|
|
80
|
+
max={item.max}
|
|
81
|
+
step={item.step}
|
|
82
|
+
value={item.state ?? item.default}
|
|
83
|
+
onChange={(e) => item.setState(Number(e.target.value))}
|
|
84
|
+
/>
|
|
85
|
+
</label>
|
|
86
|
+
))
|
|
87
|
+
|
|
48
88
|
const settings: SettingItem[] = [
|
|
49
89
|
{label: 'loading', state: loading, setState: setLoading},
|
|
50
90
|
{label: 'disabled', state: disabled, setState: setDisabled},
|
|
51
91
|
{label: 'error', state: error, setState: setError},
|
|
52
92
|
{label: 'alwaysOpen', state: alwaysOpen, setState: setAlwaysOpen},
|
|
53
|
-
{label: 'animateOpacity', state: animateOpacity, setState: setAnimateOpacity}
|
|
93
|
+
{label: 'animateOpacity', state: animateOpacity, setState: setAnimateOpacity},
|
|
94
|
+
{label: 'hasMore', state: hasMore, setState: setHasMore},
|
|
95
|
+
{label: 'loadButton', state: loadButton, setState: setLoadButton}
|
|
54
96
|
]
|
|
55
97
|
|
|
56
98
|
const renderSettings: JSX.Element[] = settings.map((item) => (
|
|
@@ -80,6 +122,8 @@ function App() {
|
|
|
80
122
|
{label: 'loadingText', value: loadingText, setValue: setLoadingText},
|
|
81
123
|
{label: 'errorText', value: errorText, setValue: setErrorText},
|
|
82
124
|
{label: 'disabledText', value: disabledText, setValue: setDisabledText},
|
|
125
|
+
{label: 'loadButtonText', value: loadButtonText, setValue: setLoadButtonText},
|
|
126
|
+
{label: 'loadMoreText', value: loadMoreText, setValue: setLoadMoreText}
|
|
83
127
|
]
|
|
84
128
|
|
|
85
129
|
const renderTextSettings: JSX.Element[] = textSettings.map((item) => (
|
|
@@ -144,6 +188,7 @@ function App() {
|
|
|
144
188
|
|
|
145
189
|
const renderOptionList = options.map((element, index) =>
|
|
146
190
|
<motion.div
|
|
191
|
+
key={index}
|
|
147
192
|
tabIndex={0}
|
|
148
193
|
className='rac-option-demo'
|
|
149
194
|
style={{
|
|
@@ -231,43 +276,7 @@ function App() {
|
|
|
231
276
|
Select states
|
|
232
277
|
</h2>
|
|
233
278
|
{renderSettings}
|
|
234
|
-
|
|
235
|
-
className='rac-range-label'
|
|
236
|
-
>
|
|
237
|
-
<span
|
|
238
|
-
className='rac-prop-span'
|
|
239
|
-
>
|
|
240
|
-
duration: {duration ?? 300}ms
|
|
241
|
-
</span>
|
|
242
|
-
<input
|
|
243
|
-
className='rac-range-input'
|
|
244
|
-
type='range'
|
|
245
|
-
min={0}
|
|
246
|
-
max={1000}
|
|
247
|
-
step={50}
|
|
248
|
-
value={duration ?? 300}
|
|
249
|
-
onChange={(e) => setDuration(Number(e.target.value))}
|
|
250
|
-
/>
|
|
251
|
-
</label>
|
|
252
|
-
<label
|
|
253
|
-
className='rac-range-label'
|
|
254
|
-
>
|
|
255
|
-
<span
|
|
256
|
-
className='rac-prop-span'
|
|
257
|
-
>
|
|
258
|
-
offset: {offset}px
|
|
259
|
-
</span>
|
|
260
|
-
<input
|
|
261
|
-
className='rac-range-input'
|
|
262
|
-
type='range'
|
|
263
|
-
min={0}
|
|
264
|
-
max={25}
|
|
265
|
-
step={1}
|
|
266
|
-
value={offset ?? 3}
|
|
267
|
-
onChange={(e) => setOffset(Number(e.target.value))}
|
|
268
|
-
/>
|
|
269
|
-
</label>
|
|
270
|
-
|
|
279
|
+
{renderRanges}
|
|
271
280
|
<label
|
|
272
281
|
className='rac-prop-label'
|
|
273
282
|
>
|
|
@@ -311,9 +320,13 @@ function App() {
|
|
|
311
320
|
react-animated-select overview
|
|
312
321
|
</h3>
|
|
313
322
|
<Select
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
323
|
+
loadMore={() => alert('subload triggered')}
|
|
324
|
+
hasMore={hasMore}
|
|
325
|
+
loadButton={loadButton}
|
|
326
|
+
loadButtonText={loadButtonText}
|
|
327
|
+
loadMoreText={loadMoreText}
|
|
328
|
+
loadOffset={loadOffset}
|
|
329
|
+
loadAhead={loadAhead}
|
|
317
330
|
className='rac-demo-select'
|
|
318
331
|
loading={loading}
|
|
319
332
|
error={error}
|
package/demo/src/rac.css
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
@font-face {
|
|
2
|
-
font-family: 'E-Ukraine';
|
|
3
|
-
src: url('./fonts/e-Ukraine/E-Ukraine-Regular.otf') format('opentype');
|
|
4
|
-
font-weight: 400;
|
|
5
|
-
font-style: normal;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
@font-face {
|
|
9
|
-
font-family: 'E-Ukraine';
|
|
10
|
-
src: url('./fonts/e-Ukraine/E-Ukraine-Bold.otf') format('opentype');
|
|
11
|
-
font-weight: 700;
|
|
12
|
-
font-style: normal;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
1
|
:root {
|
|
16
2
|
--def-white: white;
|
|
17
3
|
--blck-bc: #151515;
|
|
@@ -48,7 +34,6 @@
|
|
|
48
34
|
scroll-behavior: smooth;
|
|
49
35
|
height: 100%;
|
|
50
36
|
margin: 0;
|
|
51
|
-
font-family: 'E-Ukraine', sans-serif;
|
|
52
37
|
}
|
|
53
38
|
|
|
54
39
|
#root {
|
|
@@ -59,10 +44,6 @@
|
|
|
59
44
|
display: none;
|
|
60
45
|
}
|
|
61
46
|
|
|
62
|
-
:root {
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
47
|
*::-webkit-scrollbar {
|
|
67
48
|
width: 6px;
|
|
68
49
|
height: 6px;
|
|
@@ -392,17 +373,17 @@
|
|
|
392
373
|
}
|
|
393
374
|
}
|
|
394
375
|
|
|
395
|
-
/* .rac-select-wrapper>.slideDown-enter-done {
|
|
396
|
-
overflow: visible !important;
|
|
397
|
-
} */
|
|
398
|
-
|
|
399
376
|
.rac-visual {
|
|
400
377
|
background-color: #17181e;
|
|
401
378
|
border-left: 1px solid #33353e;
|
|
402
379
|
border-right: 1px solid #33353e;
|
|
403
380
|
padding: 1.25vw;
|
|
404
381
|
min-width: 33%;
|
|
405
|
-
|
|
382
|
+
overflow-y: auto;
|
|
383
|
+
overflow-x: hidden;
|
|
384
|
+
scrollbar-gutter: stable;
|
|
385
|
+
height: 0;
|
|
386
|
+
min-height: 100%;
|
|
406
387
|
|
|
407
388
|
@media (max-width: 1024px) {
|
|
408
389
|
border: none;
|
|
@@ -478,7 +459,7 @@
|
|
|
478
459
|
font-size: 1.5vw;
|
|
479
460
|
transition: 300ms border;
|
|
480
461
|
|
|
481
|
-
|
|
462
|
+
&::placeholder {
|
|
482
463
|
color: gray;
|
|
483
464
|
}
|
|
484
465
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const n=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const n=require("react"),je=require("react-transition-group");var he={exports:{}},de={};var we;function Ve(){if(we)return de;we=1;var t=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function a(i,g,u){var h=null;if(u!==void 0&&(h=""+u),g.key!==void 0&&(h=""+g.key),"key"in g){u={};for(var j in g)j!=="key"&&(u[j]=g[j])}else u=g;return g=u.ref,{$$typeof:t,type:i,key:h,ref:g!==void 0?g:null,props:u}}return de.Fragment=s,de.jsx=a,de.jsxs=a,de}var ge={};var _e;function ze(){return _e||(_e=1,process.env.NODE_ENV!=="production"&&(function(){function t(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===z?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case k:return"Fragment";case D:return"Profiler";case M:return"StrictMode";case J:return"Suspense";case U:return"SuspenseList";case v:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case F:return"Portal";case d:return e.displayName||"Context";case W:return(e._context.displayName||"Context")+".Consumer";case Y:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return r=e.displayName||null,r!==null?r:t(e.type)||"Memo";case p:r=e._payload,e=e._init;try{return t(e(r))}catch{}}return null}function s(e){return""+e}function a(e){try{s(e);var r=!1}catch{r=!0}if(r){r=console;var o=r.error,c=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return o.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",c),s(e)}}function i(e){if(e===k)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===p)return"<...>";try{var r=t(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function g(){var e=A.A;return e===null?null:e.getOwner()}function u(){return Error("react-stack-top-frame")}function h(e){if(H.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function j(e,r){function o(){X||(X=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}o.isReactWarning=!0,Object.defineProperty(e,"key",{get:o,configurable:!0})}function b(){var e=t(this.type);return O[e]||(O[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function E(e,r,o,c,S,w){var x=o.ref;return e={$$typeof:$,type:e,key:r,props:o,_owner:c},(x!==void 0?x:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:b}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:S}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:w}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function P(e,r,o,c,S,w){var x=r.children;if(x!==void 0)if(c)if(L(x)){for(c=0;c<x.length;c++)T(x[c]);Object.freeze&&Object.freeze(x)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else T(x);if(H.call(r,"key")){x=t(e);var N=Object.keys(r).filter(function(m){return m!=="key"});c=0<N.length?"{key: someKey, "+N.join(": ..., ")+": ...}":"{key: someKey}",K[x+c]||(N=0<N.length?"{"+N.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,o,g,$,g),T[g+o]=!0)}if(g=null,r!==void 0&&(u(r),g=""+r),y(s)&&(u(s.key),g=""+s.key),"key"in s){r={};for(var L in s)L!=="key"&&(r[L]=s[L])}else r=s;return g&&_(r,typeof e=="function"?e.displayName||e.name||"Unknown":e),N(e,g,r,p(),m,w)}function z(e){F(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===Y&&(e._payload.status==="fulfilled"?F(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function F(e){return typeof e=="object"&&e!==null&&e.$$typeof===R}var C=n,R=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),V=Symbol.for("react.consumer"),f=Symbol.for("react.context"),D=Symbol.for("react.forward_ref"),G=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),Y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),j=Symbol.for("react.client.reference"),O=C.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,v=Object.prototype.hasOwnProperty,U=Array.isArray,J=console.createTask?console.createTask:function(){return null};C={react_stack_bottom_frame:function(e){return e()}};var X,Z={},i=C.react_stack_bottom_frame.bind(C,d)(),x=J(a(d)),T={};te.Fragment=S,te.jsx=function(e,s,r){var o=1e4>O.recentlyCreatedOwnerStacks++;return q(e,s,r,!1,o?Error("react-stack-top-frame"):i,o?J(a(e)):x)},te.jsxs=function(e,s,r){var o=1e4>O.recentlyCreatedOwnerStacks++;return q(e,s,r,!0,o?Error("react-stack-top-frame"):i,o?J(a(e)):x)}})()),te}var Ee;function Pe(){return Ee||(Ee=1,process.env.NODE_ENV==="production"?ne.exports=Ce():ne.exports=Ae()),ne.exports}var h=Pe();const Ie=({className:t="",...l})=>h.jsx("svg",{className:t,role:"button","aria-label":"Clear selection",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512",width:"1em",height:"1em",fill:"currentColor",...l,children:h.jsx("path",{d:"M310.6 361.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L160 301.3 54.6 406.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L114.7 256 9.4 150.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 210.7 265.4 105.4c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3L205.3 256l105.3 105.4z"})}),Oe=({className:t="",...l})=>h.jsx("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em",fill:"currentColor",...l,children:h.jsx("path",{d:"M34.9 289.5l175.9-175.8c9.4-9.4 24.6-9.4 33.9 0L420.1 289.5c15.1 15.1 4.4 41-17 41H51.9c-21.4 0-32.1-25.9-17-41z"})}),me=n.createContext(null),le=(t,l="invalid-option",u="")=>{const a=u?u.replace(/:/g,""):"";if(typeof t!="string"||!t.trim())return a?`${l}-${a}`:`${l}-${Math.random().toString(36).slice(2,8)}`;const p=t.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").replace(/\s+/g,"-").replace(/[^\p{L}\p{N}-]+/gu,"").toLowerCase();return p?p||`${l}-${Math.random().toString(36).slice(2,8)}`:a?`${l}-${a}`:`${l}-${Math.random().toString(36).slice(2,8)}`};function Le({disabled:t,isOpen:l,setIsOpen:u,options:a,selectOption:p,selected:d,hasMore:y,loadMore:_,loadButton:E,loadButtonText:N,setLoadingTitle:q,loadOffset:z,loadAhead:F}){const C=n.useRef(!1),R=n.useRef(0),[k,S]=n.useState(-1),A=n.useRef(!1),P=n.useRef(a?.length||0);n.useEffect(()=>{a&&a.length!==P.current&&(A.current=!1,P.current=a.length,E&&q(N))},[a]);const V=n.useCallback(()=>{!y||A.current||(A.current=!0,_())},[y,_]),f=n.useCallback(b=>{if(E||!y||A.current)return;const{scrollTop:j,scrollHeight:O,clientHeight:v}=b.currentTarget,U=z;O-j<=v+U&&V()},[E,y,V]);n.useEffect(()=>{if(!E&&l&&y&&k>=0){const b=F;k>=a.length-b&&V()}},[E,k,l,y,a.length,V]),n.useEffect(()=>{const b=()=>{R.current=Date.now()};return window.addEventListener("focus",b),()=>window.removeEventListener("focus",b)},[]),n.useEffect(()=>{if(l){if(k>=0&&k<a.length)return;let b=-1;if(d){const j=a.findIndex(O=>O.id===d.id&&!O.disabled);j>=0&&(b=j)}b===-1&&(b=a.findIndex(j=>!j.disabled)),S(b)}else S(-1)},[l,a]);const D=n.useCallback(b=>{b.currentTarget.contains(b.relatedTarget)||u(!1)},[u]),G=n.useCallback(()=>{t||document.hidden||Date.now()-R.current<100||l||(u(!0),C.current=!0,setTimeout(()=>{C.current=!1},200))},[t,l,u]),I=n.useCallback(b=>{t||b.target.closest&&b.target.closest(".rac-select-cancel")||C.current||u(!l)},[t,l,u]),M=(b,j)=>{const O=J=>J&&!J.disabled&&!J.loading;if(!a.some(O))return-1;let v=b,U=0;do{if(v+=j,v>=a.length){if(y&&!E)return b;v=0}if(v<0){if(y&&!E)return b;v=a.length-1}U++}while(!O(a[v])&&U<=a.length);return v},Y=n.useCallback(b=>{if(!t)switch(b.key){case"Enter":case" ":b.preventDefault(),l?k!==-1&&a[k]&&p(a[k],b):u(!0);break;case"Escape":b.preventDefault(),u(!1);break;case"ArrowDown":b.preventDefault(),l?S(j=>M(j,1)):u(!0);break;case"ArrowUp":b.preventDefault(),l?S(j=>M(j,-1)):u(!0);break;case"Tab":l&&u(!1);break}},[t,l,u,k,a,p]);return n.useMemo(()=>({handleBlur:D,handleFocus:G,handleToggle:I,handleKeyDown:Y,highlightedIndex:k,setHighlightedIndex:S,handleListScroll:f}),[D,G,I,Y,k,S])}function De({options:t=[],jsxOptions:l=[],value:u,defaultValue:a=void 0,onChange:p,disabled:d=!1,loading:y=!1,error:_=!1,placeholder:E="Choose option",emptyText:N="No options",disabledText:q="Disabled",loadingText:z="Loading",errorText:F="Failed to load",disabledOption:C="Disabled option",emptyOption:R="Empty option",invalidOption:k="Invalid option",setVisibility:S,hasMore:A,loadButton:P,setLoadingTitle:V,loadingTitle:f,loadMoreText:D,loadMore:G,childrenFirst:I}){const M=n.useId(),Y=u!==void 0,[b,j]=n.useState(null),O=i=>!i||typeof i!="object"||Array.isArray(i)?!1:"id"in i||"value"in i||"name"in i||"label"in i||"disabled"in i,v=n.useMemo(()=>{const i=[],x=(r,o,m)=>{let w=m?.id??m?.value??o??r;if(typeof o=="function"){i.push({key:`invalid-${i.length}`,value:o,userId:null,disabled:!0,invalid:!0,label:k,original:m});return}if(o===""){i.push({key:`empty-str-${i.length}`,value:"",userId:null,disabled:!0,label:R,original:m});return}if(o==null){i.push({key:`empty-${i.length}`,value:null,userId:null,disabled:!0,label:R,original:m});return}if(typeof o=="number"||typeof o=="boolean"){i.push({key:`${typeof o}-${o}-${i.length}`,value:o,userId:w,label:String(o),original:m});return}else i.push({key:r??`opt-${i.length}`,value:o,userId:w,label:String(o??r),original:m})};Array.isArray(t)?t.forEach((r,o)=>{if(r&&typeof r=="object"&&Object.keys(r).length===1&&r.disabled===!0)i.push({key:`dis-${o}`,value:null,userId:null,disabled:!0,label:C,original:r});else if(O(r)){const m=r.id??(typeof r.value!="object"?r.value:r.label??r.name??r.value);let w=r.name||r.label||r.id||r.value;if(w==null||w===""){const L=Object.entries(r).find(([H,Q])=>H!=="disabled"&&Q!==null&&Q!==void 0&&Q!=="");L&&(w=L[1])}const g=w==null||w==="",$=g?R:String(w);i.push({key:r.id??r.value??r.name??`opt-${o}`,value:r.value!==void 0?r.value:r.id!==void 0?r.id:r,userId:m,disabled:g||!!r.disabled,label:$,original:r})}else r&&typeof r=="object"&&!Array.isArray(r)?Object.entries(r).forEach(([m,w])=>x(m,w,w)):x(r,r,r)}):typeof t=="object"&&t!==null&&Object.entries(t).forEach(([r,o])=>x(r,o,o));const T=i.map((r,o)=>({id:`${M}-opt-${o}`,userId:r.userId,name:String(r.label),raw:r.value,original:r.original,disabled:r.disabled,invalid:r.invalid,type:typeof r.value=="boolean"?"boolean":"normal"})),e=l.map((r,o)=>{const m=r.value===null||r.value===void 0,w=r.label===null||r.label===void 0||r.label==="",g=m&&w;return{...r,id:`jsx-${M.replace(/:/g,"")}-${r.id}-${o}`,userId:r.id,raw:r.value,original:r.value,name:g?R:r.label,disabled:r.disabled||g,type:typeof r.value=="boolean"?"boolean":"normal"}}),s=I?[...e,...T]:[...T,...e];if(A&&P){const r=f===D;s.push({id:"special-load-more-id",name:f,loadMore:!0,loading:r,type:"special"})}return s},[t,l,M,R,C,A,P,f,D]),U=n.useCallback(i=>{if(i==null)return null;const x=v.find(T=>T.original===i||T.raw===i);if(x)return x.id;if(typeof i=="object")try{const T=JSON.stringify(i),e=v.find(s=>s.original&&typeof s.original=="object"&&JSON.stringify(s.original)===T);if(e)return e.id}catch{}return v.find(T=>T.userId===i)?.id??null},[v]);n.useEffect(()=>{const i=Y?u:a,x=v.find(e=>e.id===b);x&&(x.original===i||x.raw===i||x.userId===i)||j(U(i))},[u,a,Y,v,U]);const J=n.useMemo(()=>v.find(i=>i.id===b)??null,[b,v]),X=n.useCallback((i,x)=>{if(i.disabled||i.loadMore){x?.stopPropagation(),x?.preventDefault(),f!==D&&(V(D),G());return}j(i.id),p?.(i.original,i.userId),S(!1)},[p,S]),Z=n.useCallback(()=>{j(null),p?.(null,null)},[p]);return{normalizedOptions:v,selected:J,selectOption:X,clear:Z,hasOptions:v.length>0,active:!_&&!y&&!d&&v.length>0,selectedValue:u??a,placeholder:E,emptyText:N,disabledText:q,loadingText:z,errorText:F,disabledOption:C,emptyOption:R,invalidOption:k,disabled:d,loading:y,error:_}}function Fe({visibility:t,children:l,selectRef:u,onAnimationDone:a,unmount:p=!0,duration:d,easing:y,offset:_,animateOpacity:E}){const N=n.useRef(null),[q,z]=n.useState(0);n.useEffect(()=>{if(!u?.current)return;z(u.current.offsetHeight);const D=new ResizeObserver(G=>{for(let I of G)z(I.target.offsetHeight)});return D.observe(u.current),()=>D.disconnect()},[u]);const F=`height ${d}ms ${y}${E?`, opacity ${d}ms ${y}`:""}`,C={position:"absolute",top:`calc(100% + ${_}px)`,left:"0",width:"100%",overflow:"hidden",marginTop:"2px",zIndex:"1",height:t?"auto":"0px",opacity:E?t?1:0:1,pointerEvents:t?"all":"none",visibility:q?"visible":"hidden"},R=n.useCallback(()=>{const f=N.current;f&&(f.style.height="0px",E&&(f.style.opacity="0"),f.style.transition="")},[E]),k=n.useCallback(()=>{const f=N.current;f&&(f.style.transition=F,f.style.height=`${f.scrollHeight}px`,E&&(f.style.opacity="1"))},[F,E]),S=n.useCallback(()=>{const f=N.current;f&&(f.style.height="auto",f.style.transition="",a&&a())},[a]),A=n.useCallback(()=>{const f=N.current;f&&(f.style.height=`${f.scrollHeight}px`,E&&(f.style.opacity="1"),f.offsetHeight,f.style.transition=F)},[F,E]),P=n.useCallback(()=>{const f=N.current;f&&(f.style.height="0px",E&&(f.style.opacity="0"))},[E]),V=n.useCallback(()=>{const f=N.current;f&&(f.style.transition="")},[]);return h.jsx(xe.CSSTransition,{in:t,timeout:d,classNames:"rac-options",unmountOnExit:p,nodeRef:N,onEnter:R,onEntering:k,onEntered:S,onExit:A,onExiting:P,onExited:V,children:h.jsx("div",{ref:N,className:"rac-options",style:C,children:l})})}const Ye=n.memo(Fe,(t,l)=>t.visibility===l.visibility&&t.duration===l.duration&&t.easing===l.easing&&t.offset===l.offset&&t.animateOpacity===l.animateOpacity&&t.selectRef===l.selectRef&&t.children===l.children);function se({visibility:t,children:l,duration:u=300,unmount:a,style:p}){const d=n.useRef(null);return h.jsx(xe.CSSTransition,{in:t,timeout:u,classNames:"rac-slide-left",unmountOnExit:!0,nodeRef:d,onEnter:()=>d.current.style.width="0px",onEntering:()=>d.current.style.width=d.current.scrollWidth+"px",onEntered:()=>d.current.style.width="auto",onExit:()=>d.current.style.width=d.current.scrollWidth+"px",onExiting:()=>d.current.style.width="0px",onExited:()=>a?.(),children:h.jsx("div",{ref:d,style:{...p,overflow:"hidden",transition:`width ${u}ms ease`},children:l})})}const ve=(t,l)=>{if(!t)return null;if(typeof t=="string")return h.jsx("img",{src:t,...l,alt:""});if(n.isValidElement(t))return n.cloneElement(t,l);if(typeof t=="function"||typeof t=="object"&&t.$$typeof){const u=t;return h.jsx(u,{...l})}return null},Ve=n.forwardRef(({unmount:t,children:l,renderedDropdown:u,visibility:a,ownBehavior:p=!1,alwaysOpen:d=!1,duration:y=300,easing:_="ease-out",offset:E=2,animateOpacity:N=!0,style:q={},className:z="",ArrowIcon:F=Oe,ClearIcon:C=Ie,hasMore:R=!1,loadMore:k=()=>{},loadButton:S=!1,loadButtonText:A="Load more",loadMoreText:P="Loading",loadOffset:V=100,loadAhead:f=3,childrenFirst:D=!1,...G},I)=>{const[M,Y]=n.useState(S?A:P);n.useEffect(()=>{Y(S?A:P)},[S,A,P]);const b=n.useId(),j=n.useMemo(()=>b.replace(/:/g,""),[b]),[O,v]=n.useState([]),U=n.useCallback(c=>{v(W=>[...W,c])},[]),J=n.useCallback(c=>{v(W=>W.filter(B=>B.id!==c))},[]),X=n.useRef(null);n.useEffect(()=>{I&&(typeof I=="function"?I(X.current):I.current=X.current)},[I]),n.useImperativeHandle(I,()=>X.current);const[Z,i]=n.useState(!1),x=n.useMemo(()=>d?!0:p?!!a:Z,[d,p,a,Z]),T=n.useCallback(c=>{d||p||i(W=>typeof c=="function"?c(W):c)},[d,p]),{normalizedOptions:e,selected:s,selectOption:r,clear:o,hasOptions:m,active:w,selectedValue:g,disabled:$,loading:L,error:H,placeholder:Q,invalidOption:je,emptyText:ie,disabledText:oe,loadingText:ce,errorText:ue}=De({...G,setVisibility:T,jsxOptions:O,hasMore:R,loadButton:S,loadingTitle:M,loadMore:k,loadMoreText:P,setLoadingTitle:Y,childrenFirst:D}),{handleListScroll:we,handleBlur:Se,handleFocus:ke,handleToggle:Re,handleKeyDown:_e,highlightedIndex:ee,setHighlightedIndex:Te}=Le({setLoadingTitle:Y,loadButton:S,loadButtonText:A,hasMore:R,loadMore:k,disabled:$,isOpen:x,setIsOpen:T,options:e,selectOption:r,selected:s,loadOffset:V,loadAhead:f}),[fe,de]=n.useState(!1);n.useEffect(()=>{x||de(!1)},[x]),n.useEffect(()=>{(H||$||L||!m)&&T(!1)},[H,$,L,m]),n.useEffect(()=>{if(x&&fe&&ee!==-1){const c=e[ee];if(c){const W=`opt-${j}-${le(c.id)}`,B=document.getElementById(W);B&&B.scrollIntoView({block:"nearest"})}}},[ee,x,fe,e,j]);const ge=g!=null&&!(Array.isArray(g)&&g.length===0)&&!(typeof g=="object"&&Object.keys(g).length===0),be=n.useMemo(()=>{if(H)return ue;if(L)return ce;if($)return oe;if(s)return s.jsx??s.name;if(ge){const c=e.find(W=>W.raw===g);return c?c.name:typeof g=="object"&&g!==null?g.name??g.label??"Selected Object":String(g)}return m?Q:ie},[$,L,H,m,s,g,Q,ue,ce,oe,ie]),$e=`${j}-listbox`,Ne=n.useMemo(()=>e?.map((c,W)=>{const B=`opt-${j}-${le(c.id)}`;let K="rac-select-option";return c.className&&(K+=` ${c.className}`),s?.id===c.id&&(K+=" rac-selected"),W===ee&&(K+=" rac-highlighted"),(c.disabled||c.loading)&&(K+=" rac-disabled-option"),c.invalid&&(K+=" rac-invalid-option"),c.loadMore&&M==P&&(K+=" rac-loading-option"),typeof c.raw=="boolean"&&(K+=c.raw?" rac-true-option":" rac-false-option"),c.name==je&&(K+=" rac-invalid-option"),h.jsxs("div",{className:K,onClick:he=>{if(c.loading){he.stopPropagation();return}r(c,he)},onMouseEnter:()=>!c.disabled&&!c.loading&&Te(W),id:B,role:"option","aria-selected":s?.id===c.id,"aria-disabled":c.disabled||c.loading,"data-loading":c.loading,children:[c.jsx??c.name,c.loading&&h.jsxs("span",{className:"rac-loading-dots",children:[h.jsx("i",{}),h.jsx("i",{}),h.jsx("i",{})]})]},c.id)}),[e,r,j,s,ee]);return h.jsxs(me.Provider,{value:{registerOption:U,unregisterOption:J},children:[l,u,h.jsxs("div",{style:{"--rac-duration":`${y}ms`,...q},className:`rac-select
|
|
7
|
-
${
|
|
8
|
-
${!
|
|
9
|
-
${
|
|
10
|
-
${H?"rac-error-style":""}`,tabIndex:w?0:-1,ref:X,role:"combobox","aria-haspopup":"listbox","aria-expanded":x,"aria-controls":$e,"aria-label":Q,"aria-disabled":$||!m,...w&&{onBlur:Se,onFocus:ke,onClick:Re,onKeyDown:_e},children:[h.jsxs("div",{className:`rac-select-title ${!H&&!L&&s?.type=="boolean"?s.raw?"rac-true-option":"rac-false-option":""}`,children:[h.jsx("span",{className:"rac-title-text",children:be},be),h.jsx(se,{visibility:L&&!H,duration:y,children:h.jsxs("span",{className:"rac-loading-dots",children:[h.jsx("i",{}),h.jsx("i",{}),h.jsx("i",{})]})})]}),h.jsxs("div",{className:"rac-select-buttons",children:[h.jsx(se,{visibility:ge&&m&&!$&&!L&&!H,duration:y,style:{display:"grid"},children:ve(C,{className:"rac-select-cancel",onMouseDown:c=>{c.preventDefault(),c.stopPropagation()},onClick:o})}),h.jsx(se,{visibility:w,duration:y,style:{display:"grid"},children:h.jsx("span",{className:`rac-select-arrow-wrapper ${x?"--open":""}`,children:ve(F,{className:"rac-select-arrow-wrapper"})})})]}),h.jsx(Ye,{visibility:x,selectRef:X,onAnimationDone:()=>de(!0),unmount:t,duration:y,easing:_,offset:E,animateOpacity:N,children:h.jsxs("div",{onScroll:we,tabIndex:"-1",className:"rac-select-list",role:"listbox","aria-label":"Options",children:[Ne,!S&&R?h.jsxs("div",{onClick:c=>c.stopPropagation(),onMouseEnter:c=>c.preventDefault(),className:"rac-select-option rac-disabled-option rac-loading-option",children:[h.jsx("span",{className:"rac-loading-option-title",children:"Loading"}),h.jsxs("span",{className:"rac-loading-dots",children:[h.jsx("i",{}),h.jsx("i",{}),h.jsx("i",{})]})]}):null]})})]})]})}),ae=t=>t?typeof t=="string"||typeof t=="number"?String(t):Array.isArray(t)?t.map(ae).join(" ").replace(/\s+/g," ").trim():n.isValidElement(t)?ae(t.props.children):"":"";function He({value:t,id:l,className:u,children:a,disabled:p}){const d=n.useContext(me);return n.useEffect(()=>{if(!d)return;const y=ae(a),_=typeof a=="string"&&a!==""?a:y||String(t??l??""),E={id:String(l??le(String(y))),value:t!==void 0?t:y,label:_,jsx:a,className:u,disabled:!!p};return d.registerOption(E),()=>d.unregisterOption(E.id)},[l,t,a,u,p]),null}exports.Option=He;exports.Select=Ve;
|
|
6
|
+
<%s key={someKey} {...props} />`,c,x,N,x),K[x+c]=!0)}if(x=null,o!==void 0&&(a(o),x=""+o),h(r)&&(a(r.key),x=""+r.key),"key"in r){o={};for(var l in r)l!=="key"&&(o[l]=r[l])}else o=r;return x&&j(o,typeof e=="function"?e.displayName||e.name||"Unknown":e),E(e,x,o,g(),S,w)}function T(e){_(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===p&&(e._payload.status==="fulfilled"?_(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function _(e){return typeof e=="object"&&e!==null&&e.$$typeof===$}var R=n,$=Symbol.for("react.transitional.element"),F=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),M=Symbol.for("react.strict_mode"),D=Symbol.for("react.profiler"),W=Symbol.for("react.consumer"),d=Symbol.for("react.context"),Y=Symbol.for("react.forward_ref"),J=Symbol.for("react.suspense"),U=Symbol.for("react.suspense_list"),V=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),z=Symbol.for("react.client.reference"),A=R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H=Object.prototype.hasOwnProperty,L=Array.isArray,B=console.createTask?console.createTask:function(){return null};R={react_stack_bottom_frame:function(e){return e()}};var X,O={},ee=R.react_stack_bottom_frame.bind(R,u)(),se=B(i(u)),K={};ge.Fragment=k,ge.jsx=function(e,r,o){var c=1e4>A.recentlyCreatedOwnerStacks++;return P(e,r,o,!1,c?Error("react-stack-top-frame"):ee,c?B(i(e)):se)},ge.jsxs=function(e,r,o){var c=1e4>A.recentlyCreatedOwnerStacks++;return P(e,r,o,!0,c?Error("react-stack-top-frame"):ee,c?B(i(e)):se)}})()),ge}var $e;function We(){return $e||($e=1,process.env.NODE_ENV==="production"?he.exports=Ve():he.exports=ze()),he.exports}var f=We();const Je=({className:t="",...s})=>f.jsx("svg",{className:t,role:"button","aria-label":"Clear selection",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512",width:"1em",height:"1em",fill:"currentColor",...s,children:f.jsx("path",{d:"M310.6 361.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L160 301.3 54.6 406.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L114.7 256 9.4 150.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 210.7 265.4 105.4c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3L205.3 256l105.3 105.4z"})}),Ue=({className:t="",...s})=>f.jsx("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em",fill:"currentColor",...s,children:f.jsx("path",{d:"M34.9 289.5l175.9-175.8c9.4-9.4 24.6-9.4 33.9 0L420.1 289.5c15.1 15.1 4.4 41-17 41H51.9c-21.4 0-32.1-25.9-17-41z"})}),ye=(t,s="invalid-option",a="")=>{const i=a?a.replace(/:/g,""):"";if(typeof t!="string"||!t.trim())return i?`${s}-${i}`:`${s}-${Math.random().toString(36).slice(2,8)}`;const g=t.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").replace(/\s+/g,"-").replace(/[^\p{L}\p{N}-]+/gu,"").toLowerCase();return g?g||`${s}-${Math.random().toString(36).slice(2,8)}`:i?`${s}-${i}`:`${s}-${Math.random().toString(36).slice(2,8)}`},Se=n.createContext(null);function qe({visibility:t,children:s,selectRef:a,onAnimationDone:i,unmount:g=!0,duration:u,easing:h,offset:j,animateOpacity:b}){const E=n.useRef(null),[P,T]=n.useState(0);n.useEffect(()=>{if(!a?.current)return;T(a.current.offsetHeight);const Y=new ResizeObserver(J=>{for(let U of J)T(U.target.offsetHeight)});return Y.observe(a.current),()=>Y.disconnect()},[a]);const _=`height ${u}ms ${h}${b?`, opacity ${u}ms ${h}`:""}`,R={position:"absolute",top:`calc(100% + ${j}px)`,left:"0",width:"100%",overflow:"hidden",marginTop:"2px",zIndex:"1",height:t?"auto":"0px",opacity:b?t?1:0:1,pointerEvents:t?"all":"none",visibility:P?"visible":"hidden"},$=n.useCallback(()=>{const d=E.current;d&&(d.style.height="0px",b&&(d.style.opacity="0"),d.style.transition="")},[b]),F=n.useCallback(()=>{const d=E.current;d&&(d.style.transition=_,d.style.height=`${d.scrollHeight}px`,b&&(d.style.opacity="1"))},[_,b]),k=n.useCallback(()=>{const d=E.current;d&&(d.style.height="auto",d.style.transition="",i&&i())},[i]),M=n.useCallback(()=>{const d=E.current;d&&(d.style.height=`${d.scrollHeight}px`,b&&(d.style.opacity="1"),d.offsetHeight,d.style.transition=_)},[_,b]),D=n.useCallback(()=>{const d=E.current;d&&(d.style.height="0px",b&&(d.style.opacity="0"))},[b]),W=n.useCallback(()=>{const d=E.current;d&&(d.style.transition="")},[]);return f.jsx(je.CSSTransition,{in:t,timeout:u,classNames:"rac-options",unmountOnExit:g,nodeRef:E,onEnter:$,onEntering:F,onEntered:k,onExit:M,onExiting:D,onExited:W,children:f.jsx("div",{ref:E,className:"rac-options",style:R,children:s})})}const Xe=n.memo(qe,(t,s)=>t.visibility===s.visibility&&t.duration===s.duration&&t.easing===s.easing&&t.offset===s.offset&&t.animateOpacity===s.animateOpacity&&t.selectRef===s.selectRef&&t.children===s.children);function be({visibility:t,children:s,duration:a=300,unmount:i,style:g}){const u=n.useRef(null);return f.jsx(je.CSSTransition,{in:t,timeout:a,classNames:"rac-slide-left",unmountOnExit:!0,nodeRef:u,onEnter:()=>u.current.style.width="0px",onEntering:()=>u.current.style.width=u.current.scrollWidth+"px",onEntered:()=>u.current.style.width="auto",onExit:()=>u.current.style.width=u.current.scrollWidth+"px",onExiting:()=>u.current.style.width="0px",onExited:()=>i?.(),children:f.jsx("div",{ref:u,style:{...g,overflow:"hidden",transition:`width ${a}ms ease`},children:s})})}const Ke=n.memo(({selectRef:t,selectId:s,renderOptions:a,selected:i,title:g,visibility:u,active:h,hasOptions:j,hasActualValue:b,disabled:E,loading:P,error:T,registerOption:_,unregisterOption:R,handleBlur:$,handleFocus:F,handleToggle:k,handleKeyDown:M,handleListScroll:D,setAnimationFinished:W,clear:d,children:Y,renderedDropdown:J,placeholder:U,className:V,style:p,duration:v,easing:z,offset:A,animateOpacity:H,unmount:L,ArrowIcon:B,ClearIcon:X,renderIcon:O,hasMore:ee,loadButton:se})=>f.jsxs(Se.Provider,{value:{registerOption:_,unregisterOption:R},children:[Y,J,f.jsxs("div",{ref:t,style:{"--rac-duration":`${v}ms`,...p},className:`rac-select
|
|
7
|
+
${V}
|
|
8
|
+
${!j||E?"rac-disabled-style":""}
|
|
9
|
+
${P?"rac-loading-style":""}
|
|
10
|
+
${T?"rac-error-style":""}`,tabIndex:h?0:-1,role:"combobox","aria-haspopup":"listbox","aria-expanded":u,"aria-controls":`${s}-listbox`,"aria-label":U,"aria-disabled":E||!j,...h&&{onBlur:$,onFocus:F,onClick:k,onKeyDown:M},children:[f.jsxs("div",{className:`rac-select-title ${!T&&!P&&i?.type==="boolean"?i.raw?"rac-true-option":"rac-false-option":""}`,children:[f.jsx("span",{className:"rac-title-text",children:g},g),f.jsx(be,{visibility:P&&!T,duration:v,children:f.jsxs("span",{className:"rac-loading-dots",children:[f.jsx("i",{}),f.jsx("i",{}),f.jsx("i",{})]})})]}),f.jsxs("div",{className:"rac-select-buttons",children:[f.jsx(be,{visibility:b&&j&&!E&&!P&&!T,duration:v,style:{display:"grid"},children:O(X,{className:"rac-select-cancel",onMouseDown:K=>{K.preventDefault(),K.stopPropagation()},onClick:d})}),f.jsx(be,{visibility:h,duration:v,style:{display:"grid"},children:f.jsx("span",{className:`rac-select-arrow-wrapper ${u?"--open":""}`,children:O(B,{className:"rac-select-arrow-wrapper"})})})]}),f.jsx(Xe,{visibility:u,selectRef:t,onAnimationDone:()=>W(!0),unmount:L,duration:v,easing:z,offset:A,animateOpacity:H,children:f.jsxs("div",{onScroll:D,tabIndex:"-1",className:"rac-select-list",role:"listbox","aria-label":"Options",children:[a,!se&&ee&&f.jsxs("div",{className:"rac-select-option rac-disabled-option rac-loading-option",onClick:K=>K.stopPropagation(),children:[f.jsx("span",{className:"rac-loading-option-title",children:"Loading"}),f.jsxs("span",{className:"rac-loading-dots",children:[f.jsx("i",{}),f.jsx("i",{}),f.jsx("i",{})]})]})]})})]})]}));function Ze({disabled:t,open:s,setOpen:a,options:i=[],selectOption:g,selected:u,hasMore:h,loadMore:j,loadButton:b,loadButtonText:E,setLoadingTitle:P,loadOffset:T,loadAhead:_}){const R=n.useRef(!1),$=n.useRef(0),F=n.useRef(!1),[k,M]=n.useState(-1);n.useEffect(()=>{F.current=!1,b&&P(E)},[i.length,h,b,E,P]);const D=n.useCallback(()=>{!h||F.current||(F.current=!0,j())},[h,j]),W=n.useCallback(p=>{if(b||!h||F.current)return;const{scrollTop:v,scrollHeight:z,clientHeight:A}=p.currentTarget;z-v<=A+T&&D()},[b,h,T,D]);n.useEffect(()=>{!b&&s&&h&&k>=i.length-_&&D()},[k,s,h,i.length,_,b,D]),n.useEffect(()=>{const p=()=>{$.current=Date.now()};return window.addEventListener("focus",p),()=>window.removeEventListener("focus",p)},[]),n.useEffect(()=>{if(!s){M(-1);return}if(k>=0&&k<i.length)return;let p=-1;u&&(p=i.findIndex(v=>v.id===u.id&&!v.disabled)),p===-1&&(p=i.findIndex(v=>!v.disabled)),M(p)},[s,i,u]);const d=n.useCallback((p,v)=>{const z=L=>L&&!L.disabled&&!L.loading,A=i.length;if(A===0)return-1;let H=p;for(let L=0;L<A;L++){if(H=(H+v+A)%A,!b&&h&&(v>0&&H===0||v<0&&H===A-1))return p;if(z(i[H]))return H}return p},[i,h,b]),Y=n.useCallback(p=>{p.currentTarget.contains(p.relatedTarget)||a(!1)},[a]),J=n.useCallback(()=>{t||document.hidden||Date.now()-$.current<100||s||(a(!0),R.current=!0,setTimeout(()=>{R.current=!1},200))},[t,s,a]),U=n.useCallback(p=>{t||p.target.closest(".rac-select-cancel")||R.current||a(!s)},[t,s,a]),V=n.useCallback(p=>{if(!t)switch(p.key){case"Enter":case" ":p.preventDefault(),s?k!==-1&&i[k]&&g(i[k],p):a(!0);break;case"Escape":p.preventDefault(),a(!1);break;case"ArrowDown":p.preventDefault(),s?M(v=>d(v,1)):a(!0);break;case"ArrowUp":p.preventDefault(),s?M(v=>d(v,-1)):a(!0);break;case"Tab":s&&a(!1);break}},[t,s,a,k,i,g,d]);return n.useMemo(()=>({handleBlur:Y,handleFocus:J,handleToggle:U,handleKeyDown:V,highlightedIndex:k,setHighlightedIndex:M,handleListScroll:W}),[Y,J,U,V,k,W])}const Qe=["group","disabled","options","items","children"],Ce=["name","label","id","value"];function Be({options:t=[],jsxOptions:s=[],value:a,defaultValue:i=void 0,onChange:g,disabled:u=!1,loading:h=!1,error:j=!1,placeholder:b="Choose option",emptyText:E="No options",disabledText:P="Disabled",loadingText:T="Loading",errorText:_="Failed to load",disabledOption:R="Disabled option",emptyOption:$="Empty option",invalidOption:F="Invalid option",setVisibility:k,hasMore:M,loadButton:D,setLoadingTitle:W,loadingTitle:d,loadMoreText:Y,loadMore:J,childrenFirst:U}){const V=n.useId(),p=a!==void 0,[v,z]=n.useState(null),A=n.useCallback((r,o=!1)=>{const c=Ce.find(w=>r[w]!==void 0&&r[w]!==null&&r[w]!=="");if(c)return String(r[c]);const S=Object.entries(r).find(([w,x])=>!Qe.includes(w)&&x!=null&&x!=="");return S?String(S[1]):o},[]),H=n.useCallback((r,o,c="normal",S=null,w=!1)=>{let x="",N=r,l=w,m=null,G=S;return r==null||r===""?{id:`${V}-${c}-${o}`,userId:null,name:$,raw:null,disabled:!0,type:"normal",group:G}:typeof r=="function"?{id:`${V}-inv-${o}`,userId:null,name:F,raw:r,disabled:!0,invalid:!0,type:"normal",group:G}:(typeof r=="object"&&!Array.isArray(r)?(G||(G=r.group||null),l=l||!!r.disabled,m=r.id??r.value??r.name??r.label,N=r.value!==void 0?r.value:r.id!==void 0?r.id:r,x=A(r,l?R:$),x===$&&!l&&(l=!0)):(x=String(r),m=r,N=r),{id:`${V}-${c}-${o}`,userId:m,name:x,raw:N,original:r,disabled:l,type:typeof N=="boolean"?"boolean":"normal",group:G})},[V,$,F,R,A]),[L,B]=n.useState(new Set),X=n.useCallback(r=>{B(o=>{const c=new Set(o);return c.has(r)?c.delete(r):c.add(r),c})},[]),O=n.useMemo(()=>{const r=[],o=(l,m,G=null,Z=!1)=>{if(l&&typeof l=="object"&&!Array.isArray(l)&&"options"in l){const re=A(l,"Empty group",!0),ie=Z||!!l.disabled,Q=l.options;Array.isArray(Q)?Q.forEach((ce,ae)=>o(ce,`${m}-${ae}`,re,ie)):Q&&typeof Q=="object"?Object.entries(Q).forEach(([ce,ae],pe)=>o(ae,`${m}-${pe}`,re,ie)):o(Q,`${m}-0`,re,ie);return}if(l&&typeof l=="object"&&!Array.isArray(l)&&!Ce.some(re=>re in l)&&!("group"in l)){Object.entries(l).forEach(([re,ie],Q)=>{r.push(H(ie,`${m}-${Q}`,"normal",G,Z))});return}r.push(H(l,m,"normal",G,Z))};Array.isArray(t)&&t.forEach((l,m)=>o(l,m));const c=s.map(l=>{if(l.isGroupMarker)return{...l,type:"group-marker"};const m=(l.value==null||l.value==="")&&!l.label;return{...l,id:`jsx-${l.id}`,userId:l.id,raw:l.value,original:l.value,name:m?$:l.label,disabled:!!l.disabled||m,type:typeof l.value=="boolean"?"boolean":"normal",group:l.group||null}}),S=U?[...c,...r]:[...r,...c],w=[],x=new Map,N=[];return S.forEach(l=>{if(!l.group)N.push({type:"item",data:l});else if(x.has(l.group)||(x.set(l.group,[]),N.push({type:"group",name:l.group})),!l.isGroupMarker){const m=L.has(l.group);x.get(l.group).push({...l,hidden:!m})}}),N.forEach((l,m)=>{if(l.type==="item")w.push(l.data);else{const G=L.has(l.name);w.push({id:`group-header-${l.name}-${m}`,name:l.name,disabled:!1,groupHeader:!0,expanded:G,type:"group"});const Z=x.get(l.name);w.push(...Z)}}),M&&D&&w.push({id:"special-load-more-id",name:d,loadMore:!0,loading:d===Y,type:"special"}),w},[t,s,V,H,U,M,D,d,Y,E,$,A]),ee=n.useCallback(r=>{if(r==null)return null;const o=O.find(c=>c.original===r||c.raw===r||c.userId===r);if(o)return o.id;if(typeof r=="object")try{const c=JSON.stringify(r);return O.find(S=>S.original&&typeof S.original=="object"&&JSON.stringify(S.original)===c)?.id??null}catch{return null}return null},[O]);n.useEffect(()=>{const r=p?a:i,o=O.find(S=>S.id===v);o&&(o.original===r||o.raw===r||o.userId===r)||z(ee(r))},[a,i,p,O,ee,v]);const se=n.useMemo(()=>O.find(r=>r.id===v)??null,[v,O]),K=n.useCallback((r,o)=>{if(r.groupHeader){o?.stopPropagation(),o?.preventDefault(),X(r.name);return}if(r.disabled||r.loadMore){o?.stopPropagation(),o?.preventDefault(),r.loadMore&&(W(Y),J());return}z(r.id),g?.(r.original,r.userId),k(!1)},[g,k,J,Y,W]),e=n.useCallback(()=>{z(null),g?.(null,null)},[g]);return{normalizedOptions:O,selected:se,selectOption:K,clear:e,hasOptions:O.length>0,active:!j&&!h&&!u&&O.length>0,selectedValue:a??i,placeholder:b,emptyText:E,disabledText:P,loadingText:T,errorText:_,disabledOption:R,emptyOption:$,invalidOption:F,disabled:u,loading:h,error:j,expandedGroups:L,toggleGroup:X,visibleOptions:O.filter(r=>!r.hidden)}}function er({visibility:t,children:s,duration:a=300}){const i=n.useRef(null);return f.jsx(je.CSSTransition,{in:t,timeout:300,classNames:"slideDown",unmountOnExit:!0,nodeRef:i,onEnter:()=>i.current.style.height="0px",onEntering:()=>i.current.style.height=i.current.scrollHeight+"px",onEntered:()=>i.current.style.height="auto",onExit:()=>i.current.style.height=i.current.scrollHeight+"px",onExiting:()=>i.current.style.height="0px",children:f.jsx("div",{ref:i,style:{overflow:"hidden",transition:`height ${a}ms ease`,paddingLeft:"1em"},className:"slideDown-enter-done",tabIndex:-1,children:s})})}const Te=(t,s)=>{if(!t)return null;if(typeof t=="string")return f.jsx("img",{src:t,...s,alt:""});if(n.isValidElement(t))return n.cloneElement(t,s);if(typeof t=="function"||typeof t=="object"&&t.$$typeof){const a=t;return f.jsx(a,{...s})}return null},rr=(t,s,a,i,g,u,h)=>t.groupHeader?"rac-select-option rac-group-option":["rac-select-option",t.className,i===t.id&&"rac-selected",s===a&&"rac-highlighted",(t.disabled||t.loading)&&"rac-disabled-option",(t.invalid||t.name===h)&&"rac-invalid-option",t.loadMore&&g===u&&"rac-loading-option",typeof t.raw=="boolean"&&(t.raw?"rac-true-option":"rac-false-option")].filter(Boolean).join(" "),tr=n.forwardRef(({unmount:t,children:s,renderedDropdown:a,visibility:i,ownBehavior:g=!1,alwaysOpen:u=!1,duration:h=300,easing:j="ease-out",offset:b=2,animateOpacity:E=!0,style:P={},className:T="",ArrowIcon:_=Ue,ClearIcon:R=Je,hasMore:$=!1,loadMore:F=()=>{console.warn("loadMore not implemented")},loadButton:k=!1,loadButtonText:M="Load more",loadMoreText:D="Loading",loadOffset:W=100,loadAhead:d=3,childrenFirst:Y=!1,...J},U)=>{const V=n.useId(),p=n.useMemo(()=>V.replace(/:/g,""),[V]),[v,z]=n.useState([]),[A,H]=n.useState(!1),[L,B]=n.useState(k?M:D),[X,O]=n.useState(!1),ee=n.useRef(null),se=n.useCallback(C=>{z(I=>{const q=I.findIndex(te=>te.id===C.id);if(q!==-1){const te=I[q];if(te.label===C.label&&te.value===C.value&&te.disabled===C.disabled&&te.group===C.group)return I;const ue=[...I];return ue[q]=C,ue}return[...I,C]})},[]),K=n.useCallback(C=>{z(I=>{const q=I.filter(te=>te.id!==C);return q.length===I.length?I:q})},[]),e=u?!0:g?!!i:A,r=n.useCallback(C=>{u||g||H(C)},[u,g]),o=Be({...J,setVisibility:r,jsxOptions:v,hasMore:$,loadButton:k,loadingTitle:L,loadMore:F,loadMoreText:D,setLoadingTitle:B,childrenFirst:Y}),{normalizedOptions:c,selected:S,selectOption:w,clear:x,hasOptions:N,active:l,selectedValue:m,disabled:G,loading:Z,error:le,placeholder:re,invalidOption:ie,emptyText:Q,disabledText:ce,loadingText:ae,errorText:pe,expandedGroups:me}=o,Ae=Ze({setLoadingTitle:B,loadButton:k,loadButtonText:M,hasMore:$,loadMore:F,disabled:G,open:e,setOpen:r,options:c,selectOption:w,selected:S,loadOffset:W,loadAhead:d}),{handleListScroll:Oe,handleBlur:Pe,handleFocus:De,handleToggle:Le,handleKeyDown:Fe,highlightedIndex:oe,setHighlightedIndex:xe}=Ae;n.useImperativeHandle(U,()=>ee.current),n.useEffect(()=>{e||O(!1)},[e]),n.useEffect(()=>{(le||G||Z||!N)&&r(!1)},[le,G,Z,N,r]),n.useEffect(()=>{if(e&&X&&oe!==-1){const C=c[oe];C&&document.getElementById(`opt-${p}-${ye(C.id)}`)?.scrollIntoView({block:"nearest"})}},[oe,e,X,c,p]);const Ee=n.useMemo(()=>m!=null&&!(Array.isArray(m)&&m.length===0)&&!(typeof m=="object"&&Object.keys(m).length===0),[m]),Me=n.useMemo(()=>{if(le)return pe;if(Z)return ae;if(G)return ce;if(S)return S.jsx??S.name;if(Ee){const C=c.find(I=>I.raw===m);return C?C.name:typeof m=="object"&&m!==null?m.name??m.label??"Selected Object":String(m)}return N?re:Q},[G,Z,le,N,S,m,re,pe,ae,ce,Q,Ee,c]),He=n.useMemo(()=>{const C=[];let I=[],q=null;const te=c.reduce((y,ne)=>(ne.group&&(y[ne.group]=(y[ne.group]||0)+1),y),{}),ue=y=>{y===null||I.length===0||(C.push(f.jsx(er,{visibility:me.has(y),children:I},`slide-${y}`)),I=[])},ke=(y,ne)=>f.jsxs("div",{id:`opt-${p}-${ye(y.id)}`,role:"option","aria-selected":S?.id===y.id,"aria-disabled":y.disabled||y.loading,className:rr(y,ne,oe,S?.id,L,D,ie),onClick:fe=>!y.loading&&w(y,fe),onMouseEnter:()=>!y.disabled&&!y.loading&&xe(ne),children:[y.jsx??y.name,y.loading&&f.jsxs("span",{className:"rac-loading-dots",children:[f.jsx("i",{}),f.jsx("i",{}),f.jsx("i",{})]})]},y.id);return c.forEach((y,ne)=>{const fe=y.groupHeader,Re=!!y.group;if((fe||!Re&&q!==null)&&(ue(q),fe||(q=null)),fe){q=y.name;const Ge=me.has(y.name),Ie=te[y.name]>0;C.push(f.jsxs("div",{className:"rac-group-header",onClick:Ye=>w(y,Ye),children:[f.jsx("span",{className:"rac-group-title-text",children:y.name}),f.jsx(be,{visibility:Ie,duration:h,style:{display:"grid"},children:f.jsx("span",{className:`rac-group-arrow-wrapper ${Ge?"--open":""}`,children:Te(_,{className:"rac-select-arrow-wrapper"})})})]},y.id))}else Re?I.push(ke(y,ne)):C.push(ke(y,ne))}),ue(q),C},[c,w,p,S,oe,L,D,ie,xe,me,_]);return f.jsx(Ke,{selectRef:ee,selectId:p,renderIcon:Te,normalizedOptions:c,renderOptions:He,selected:S,title:Me,visibility:e,active:l,hasOptions:N,hasActualValue:Ee,highlightedIndex:oe,animationFinished:X,disabled:G,loading:Z,error:le,setVisibility:r,setHighlightedIndex:xe,setAnimationFinished:O,handleBlur:Pe,handleFocus:De,handleToggle:Le,handleKeyDown:Fe,handleListScroll:Oe,selectOption:w,clear:x,registerOption:se,unregisterOption:K,children:s,renderedDropdown:a,placeholder:re,className:T,style:P,duration:h,easing:j,offset:b,animateOpacity:E,unmount:t,ArrowIcon:_,ClearIcon:R,hasMore:$,loadButton:k})}),Ne=n.createContext(null);function nr({children:t,name:s,label:a,value:i,id:g,emptyGroupText:u="Empty group"}){const h=n.useContext(Se),j=n.useMemo(()=>{const E=s??a??i??g;return E!=null&&E!==""?String(E):u},[s,a,i,g,u]),b=n.useMemo(()=>`group-marker-${ye(j)}`,[j]);return n.useEffect(()=>{if(!h)return;const E={id:b,group:j,isGroupMarker:!0,disabled:!0};return h.registerOption(E),()=>h.unregisterOption(b)},[h.registerOption,h.unregisterOption,b,j]),f.jsx(Ne.Provider,{value:j,children:t})}const ve=t=>t?typeof t=="string"||typeof t=="number"?String(t):Array.isArray(t)?t.map(ve).join(" ").replace(/\s+/g," ").trim():n.isValidElement(t)?ve(t.props.children):"":"";function sr({value:t,id:s,className:a,children:i,disabled:g,group:u}){const h=n.useContext(Se),j=n.useContext(Ne),b=h?.registerOption,E=h?.unregisterOption,P=n.useId(),T=n.useMemo(()=>s?String(s):P.replace(/:/g,""),[s,P]);return n.useEffect(()=>{if(!b)return;const _=ve(i);let R="";return typeof i=="string"&&i!==""?R=i:_?R=_:t!=null&&(R=String(t)),b({id:T,value:t!==void 0?t:_,label:R,jsx:i,className:a,disabled:!!g,group:u||j||null}),()=>E(T)},[T,t,i,a,g,u,j,b,E]),null}exports.OptGroup=nr;exports.Option=sr;exports.Select=tr;
|
package/dist/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@media(prefers-reduced-motion:reduce){.rac-select{--rac-duration: 1ms}}.rac-select{--rac-duration-fast: calc(var(--rac-duration) * .5);--rac-duration-base: var(--rac-duration);--rac-duration-slow: calc(var(--rac-duration) * 1.3);--rac-base-red: #e7000b;--rac-base-green: #4caf50;--rac-base-yellow: #ffc107;--rac-select-background: color-mix(in srgb, Canvas 98%, CanvasText 2%);--rac-select-color: CanvasText;--rac-select-border: 2px solid color-mix(in srgb, Canvas 98%, CanvasText 2%);--rac-select-border-error: 2px solid color-mix(in srgb, var(--rac-base-red), CanvasText 15%);--rac-select-height: 2em;--rac-select-padding: 0em .5em;--rac-disabled-opacity: .75;--rac-title-anim-shift: 4px;--rac-title-anim-entry-ease: cubic-bezier(.34, 1.56, .64, 1);--rac-dots-height: 3px;--rac-dots-width: 3px;--rac-dots-color: currentColor;--rac-dots-gap: 3px;--rac-dots-padding-left: .25em;--rac-dots-align: end;--rac-dots-animation-duration: 1.4s;--rac-dots-animation-delay-1: 0s;--rac-dots-animation-delay-2: .2s;--rac-dots-animation-delay-3: .4s;--rac-arrow-height: 1em;--rac-arrow-width: 1em;--rac-arrow-padding: 1px 0 2px;--rac-cancel-height: .9em;--rac-cancel-width: .9em;--rac-scroll-color: color-mix(in srgb, CanvasText 10%, Canvas);--rac-scroll-track: color-mix(in srgb, CanvasText 5%, Canvas);--rac-scroll-padding-top: .5em;--rac-scroll-padding-bottom: .5em;--rac-option-hover: color-mix(in srgb, CanvasText 6%, Canvas);--rac-option-highlight: color-mix(in srgb, CanvasText 10%, Canvas);--rac-option-selected: color-mix(in srgb, CanvasText 14%, Canvas);--rac-list-background: color-mix(in srgb, Canvas 98%, CanvasText 2%);--rac-list-color: CanvasText;--rac-list-max-height: 250px;--rac-option-padding: .5em;--rac-option-min-height: 1em;--rac-disabled-option-color: color-mix(in srgb, GrayText, CanvasText 20%);--rac-invalid-option-color: color-mix(in srgb, var(--rac-base-red), CanvasText 10%);--rac-true-option-color: color-mix(in srgb, var(--rac-base-green), CanvasText 10%);--rac-false-option-color: color-mix(in srgb, var(--rac-base-red), CanvasText 10%);--rac-warning-option-color: color-mix(in srgb, var(--rac-base-yellow), CanvasText 10%);--rac-
|
|
1
|
+
@media(prefers-reduced-motion:reduce){.rac-select{--rac-duration: 1ms}}.rac-select{--rac-duration-fast: calc(var(--rac-duration) * .5);--rac-duration-base: var(--rac-duration);--rac-duration-slow: calc(var(--rac-duration) * 1.3);--rac-base-red: #e7000b;--rac-base-green: #4caf50;--rac-base-yellow: #ffc107;--rac-select-background: color-mix(in srgb, Canvas 98%, CanvasText 2%);--rac-select-color: CanvasText;--rac-select-border: 2px solid color-mix(in srgb, Canvas 98%, CanvasText 2%);--rac-select-border-error: 2px solid color-mix(in srgb, var(--rac-base-red), CanvasText 15%);--rac-select-height: 2em;--rac-select-padding: 0em .5em;--rac-disabled-opacity: .75;--rac-title-anim-shift: 4px;--rac-title-anim-entry-ease: cubic-bezier(.34, 1.56, .64, 1);--rac-dots-height: 3px;--rac-dots-width: 3px;--rac-dots-color: currentColor;--rac-dots-gap: 3px;--rac-dots-padding-left: .25em;--rac-dots-align: end;--rac-dots-animation-duration: 1.4s;--rac-dots-animation-delay-1: 0s;--rac-dots-animation-delay-2: .2s;--rac-dots-animation-delay-3: .4s;--rac-arrow-height: 1em;--rac-arrow-width: 1em;--rac-arrow-padding: 1px 0 2px;--rac-cancel-height: .9em;--rac-cancel-width: .9em;--rac-scroll-color: color-mix(in srgb, CanvasText 10%, Canvas);--rac-scroll-track: color-mix(in srgb, CanvasText 5%, Canvas);--rac-scroll-padding-top: .5em;--rac-scroll-padding-bottom: .5em;--rac-option-hover: color-mix(in srgb, CanvasText 6%, Canvas);--rac-option-highlight: color-mix(in srgb, CanvasText 10%, Canvas);--rac-option-selected: color-mix(in srgb, CanvasText 14%, Canvas);--rac-list-background: color-mix(in srgb, Canvas 98%, CanvasText 2%);--rac-list-color: CanvasText;--rac-list-max-height: 250px;--rac-option-padding: .5em;--rac-option-min-height: 1em;--rac-disabled-option-color: color-mix(in srgb, GrayText, CanvasText 20%);--rac-invalid-option-color: color-mix(in srgb, var(--rac-base-red), CanvasText 10%);--rac-true-option-color: color-mix(in srgb, var(--rac-base-green), CanvasText 10%);--rac-false-option-color: color-mix(in srgb, var(--rac-base-red), CanvasText 10%);--rac-warning-option-color: color-mix(in srgb, var(--rac-base-yellow), CanvasText 10%);--rac-group-header-font-size: 1.25em;--rac-group-header-font-weight: bold;--rac-group-header-min-height: 1em;--rac-group-header-padding: .5em;--rac-group-arrow-height: 1em;--rac-group-arrow-width: 1em;--rac-group-arrow-padding: 1px 0 2px;background:var(--rac-select-background);padding:var(--rac-select-padding);border:var(--rac-select-border);color:var(--rac-select-color);height:var(--rac-select-height);transition:border-color var(--rac-duration-base);justify-content:space-between;box-sizing:border-box;position:relative;cursor:pointer;display:flex}.rac-loading-style,.rac-disabled-style{opacity:var(--rac-disabled-opacity);transition:border-color var(--rac-duration-base),filter var(--rac-duration-base),opacity var(--rac-duration-base);cursor:wait}.rac-disabled-style{cursor:not-allowed}.rac-error-style{border:var(--rac-select-border-error);cursor:help}.rac-select-title{display:flex;align-items:center}.rac-title-text{display:block;animation:rac-fade-in var(--rac-duration-base) var(--rac-title-anim-entry-ease)}@keyframes rac-fade-in{0%{opacity:0;transform:translateY(var(--rac-title-anim-shift))}to{opacity:1;transform:translateY(0)}}.rac-loading-dots{display:inline-flex;gap:var(--rac-dots-gap);padding-left:var(--rac-dots-padding-left);align-items:var(--rac-dots-align)}.rac-loading-dots i{width:var(--rac-dots-height);height:var(--rac-dots-width);background:var(--rac-dots-color);border-radius:50%;animation:blink var(--rac-dots-animation-duration) infinite both}.rac-loading-dots i:nth-child(1){animation-delay:var(--rac-dots-animation-delay-1)}.rac-loading-dots i:nth-child(2){animation-delay:var(--rac-dots-animation-delay-2)}.rac-loading-dots i:nth-child(3){animation-delay:var(--rac-dots-animation-delay-3)}@keyframes blink{0%{opacity:.2}20%{opacity:1}to{opacity:.2}}.rac-select-buttons{display:flex;align-items:center}.rac-select-cancel{height:var(--rac-cancel-height);width:var(--rac-cancel-width);transition:opacity var(--rac-duration-fast),border-color var(--rac-duration-fast)}.rac-select-arrow-wrapper{display:block;height:var(--rac-arrow-height);width:var(--rac-arrow-width);padding:var(--rac-arrow-padding);will-change:transform;transition:transform var(--rac-duration-base) cubic-bezier(.4,0,.2,1),padding var(--rac-duration-fast);transform-origin:50% 50%;transform:translateZ(0)}.rac-select-arrow-wrapper.--open{transform:rotate(180deg)}.rac-select-arrow,.rac-select-cancel{object-fit:contain}.rac-select-list{background-color:var(--rac-list-background);color:var(--rac-list-color);max-height:var(--rac-list-max-height);overflow-y:auto;scrollbar-color:var(--rac-scroll-color) var(--rac-scroll-track);scrollbar-width:thin;scrollbar-gutter:stable;scroll-behavior:smooth;scroll-padding-top:var(--rac-scroll-padding-top);scroll-padding-bottom:var(--rac-scroll-padding-bottom);z-index:1;transition:border-color var(--rac-duration-fast),background-color var(--rac-duration-fast),opacity var(--rac-duration-base)}.rac-select-option{min-height:var(--rac-option-min-height);padding:var(--rac-option-padding);transition:background-color var(--rac-duration-fast) cubic-bezier(.4,0,.2,1)}.rac-select-option:not(.rac-disabled-option):not(.rac-group-option):hover{background-color:var(--rac-option-hover)}.rac-select-option.rac-highlighted{background-color:var(--rac-option-highlight)}.rac-select-option.rac-selected,.rac-select-option.rac-selected.rac-highlighted{background-color:var(--rac-option-selected)}.rac-disabled-option{cursor:not-allowed;color:var(--rac-disabled-option-color)}.rac-invalid-option{color:var(--rac-invalid-option-color)}.rac-true-option{color:var(--rac-true-option-color)}.rac-false-option{color:var(--rac-false-option-color)}.rac-loading-option{cursor:wait}.rac-group-header{cursor:pointer;min-height:var(--rac-group-header-min-height);padding:var(--rac-group-header-padding);transition:background-color var(--rac-duration-fast) cubic-bezier(.4,0,.2,1);display:flex;justify-content:space-between;align-items:center;font-weight:var(--rac-group-header-font-weight);font-size:var(--rac-group-header-font-size)}.rac-group-arrow-wrapper{display:block;height:var(--rac-group-arrow-height);width:var(--rac-group-arrow-width);padding:var(--rac-group-arrow-padding);will-change:transform;transition:transform var(--rac-duration-base) cubic-bezier(.4,0,.2,1),padding var(--rac-duration-fast);transform-origin:50% 50%;transform:translateZ(0)}.rac-group-arrow-wrapper.--open{transform:rotate(180deg)}
|