@db-ux/react-core-components 4.9.0 → 4.10.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.
- package/CHANGELOG.md +17 -1
- package/README.md +97 -35
- package/dist/components/accordion/accordion.js +102 -86
- package/dist/components/accordion/model.d.ts +2 -2
- package/dist/components/accordion/model.js +4 -2
- package/dist/components/accordion-item/accordion-item.d.ts +2 -1
- package/dist/components/accordion-item/accordion-item.js +89 -56
- package/dist/components/accordion-item/model.d.ts +5 -1
- package/dist/components/badge/badge.js +72 -32
- package/dist/components/badge/model.d.ts +1 -1
- package/dist/components/badge/model.js +12 -1
- package/dist/components/brand/brand.js +60 -13
- package/dist/components/brand/model.d.ts +1 -1
- package/dist/components/button/button.js +75 -21
- package/dist/components/button/model.d.ts +1 -1
- package/dist/components/button/model.js +13 -2
- package/dist/components/card/card.js +65 -15
- package/dist/components/card/model.d.ts +1 -1
- package/dist/components/card/model.js +8 -2
- package/dist/components/checkbox/checkbox.js +163 -157
- package/dist/components/checkbox/model.d.ts +1 -1
- package/dist/components/custom-button/custom-button.js +65 -10
- package/dist/components/custom-button/model.d.ts +2 -2
- package/dist/components/custom-select/custom-select.js +509 -727
- package/dist/components/custom-select/model.d.ts +4 -4
- package/dist/components/custom-select/model.js +8 -1
- package/dist/components/custom-select-dropdown/custom-select-dropdown.js +62 -11
- package/dist/components/custom-select-dropdown/model.d.ts +1 -1
- package/dist/components/custom-select-dropdown/model.js +8 -1
- package/dist/components/custom-select-form-field/custom-select-form-field.js +57 -10
- package/dist/components/custom-select-form-field/model.d.ts +1 -1
- package/dist/components/custom-select-list/custom-select-list.js +60 -11
- package/dist/components/custom-select-list/model.d.ts +1 -1
- package/dist/components/custom-select-list-item/custom-select-list-item.js +89 -32
- package/dist/components/custom-select-list-item/model.d.ts +1 -1
- package/dist/components/custom-select-list-item/model.js +4 -1
- package/dist/components/divider/divider.js +60 -10
- package/dist/components/divider/model.d.ts +1 -1
- package/dist/components/divider/model.js +4 -2
- package/dist/components/drawer/drawer.js +118 -97
- package/dist/components/drawer/model.d.ts +1 -1
- package/dist/components/drawer/model.js +14 -4
- package/dist/components/header/header.js +143 -65
- package/dist/components/header/model.d.ts +1 -1
- package/dist/components/icon/icon.js +61 -12
- package/dist/components/icon/model.d.ts +1 -1
- package/dist/components/icon/model.js +11 -1
- package/dist/components/infotext/infotext.js +62 -12
- package/dist/components/infotext/model.d.ts +1 -1
- package/dist/components/input/input.js +198 -167
- package/dist/components/input/model.d.ts +1 -1
- package/dist/components/input/model.js +21 -5
- package/dist/components/link/link.js +70 -12
- package/dist/components/link/model.d.ts +1 -1
- package/dist/components/link/model.js +8 -3
- package/dist/components/navigation/model.d.ts +1 -1
- package/dist/components/navigation/navigation.js +57 -11
- package/dist/components/navigation-item/model.d.ts +6 -2
- package/dist/components/navigation-item/navigation-item.js +117 -81
- package/dist/components/notification/model.d.ts +1 -1
- package/dist/components/notification/model.js +12 -3
- package/dist/components/notification/notification.js +100 -32
- package/dist/components/page/model.d.ts +1 -1
- package/dist/components/page/model.js +4 -2
- package/dist/components/page/page.js +74 -46
- package/dist/components/popover/model.d.ts +1 -1
- package/dist/components/popover/popover.js +126 -125
- package/dist/components/radio/model.d.ts +1 -1
- package/dist/components/radio/radio.js +124 -85
- package/dist/components/section/model.d.ts +1 -1
- package/dist/components/section/section.js +59 -10
- package/dist/components/select/model.d.ts +1 -1
- package/dist/components/select/select.js +188 -191
- package/dist/components/stack/model.d.ts +1 -1
- package/dist/components/stack/model.js +14 -4
- package/dist/components/stack/stack.js +63 -10
- package/dist/components/switch/model.d.ts +1 -1
- package/dist/components/switch/switch.js +182 -150
- package/dist/components/tab-item/model.d.ts +1 -1
- package/dist/components/tab-item/tab-item.js +105 -76
- package/dist/components/tab-list/model.d.ts +1 -1
- package/dist/components/tab-list/tab-list.js +60 -11
- package/dist/components/tab-panel/model.d.ts +1 -1
- package/dist/components/tab-panel/tab-panel.js +59 -13
- package/dist/components/tabs/model.d.ts +3 -3
- package/dist/components/tabs/model.js +4 -2
- package/dist/components/tabs/tabs.js +191 -178
- package/dist/components/tag/model.d.ts +1 -1
- package/dist/components/tag/model.js +4 -1
- package/dist/components/tag/tag.js +91 -32
- package/dist/components/textarea/model.d.ts +1 -1
- package/dist/components/textarea/model.js +13 -2
- package/dist/components/textarea/textarea.js +165 -150
- package/dist/components/tooltip/model.d.ts +1 -1
- package/dist/components/tooltip/model.js +4 -1
- package/dist/components/tooltip/tooltip.js +119 -115
- package/dist/index.js +64 -81
- package/dist/shared/constants.js +32 -94
- package/dist/shared/figma.d.ts +12 -6
- package/dist/shared/model.js +73 -22
- package/dist/utils/document-click-listener.js +26 -29
- package/dist/utils/document-scroll-listener.js +30 -38
- package/dist/utils/floating-components.js +107 -358
- package/dist/utils/form-components.js +34 -60
- package/dist/utils/index.js +49 -167
- package/dist/utils/navigation.js +68 -135
- package/dist/utils/react.js +10 -15
- package/package.json +11 -8
- package/dist/components/accordion/index.js +0 -1
- package/dist/components/accordion-item/index.js +0 -1
- package/dist/components/accordion-item/model.js +0 -1
- package/dist/components/badge/index.js +0 -1
- package/dist/components/brand/index.js +0 -1
- package/dist/components/brand/model.js +0 -1
- package/dist/components/button/index.js +0 -1
- package/dist/components/card/index.js +0 -1
- package/dist/components/checkbox/index.js +0 -1
- package/dist/components/checkbox/model.js +0 -1
- package/dist/components/custom-button/index.js +0 -1
- package/dist/components/custom-button/model.js +0 -1
- package/dist/components/custom-select/index.js +0 -1
- package/dist/components/custom-select-dropdown/index.js +0 -1
- package/dist/components/custom-select-form-field/index.js +0 -1
- package/dist/components/custom-select-form-field/model.js +0 -1
- package/dist/components/custom-select-list/index.js +0 -1
- package/dist/components/custom-select-list/model.js +0 -1
- package/dist/components/custom-select-list-item/index.js +0 -1
- package/dist/components/divider/index.js +0 -1
- package/dist/components/drawer/index.js +0 -1
- package/dist/components/header/index.js +0 -1
- package/dist/components/header/model.js +0 -1
- package/dist/components/icon/index.js +0 -1
- package/dist/components/infotext/index.js +0 -1
- package/dist/components/infotext/model.js +0 -1
- package/dist/components/input/index.js +0 -1
- package/dist/components/link/index.js +0 -1
- package/dist/components/navigation/index.js +0 -1
- package/dist/components/navigation/model.js +0 -1
- package/dist/components/navigation-item/index.js +0 -1
- package/dist/components/navigation-item/model.js +0 -1
- package/dist/components/notification/index.js +0 -1
- package/dist/components/page/index.js +0 -1
- package/dist/components/popover/index.js +0 -1
- package/dist/components/popover/model.js +0 -1
- package/dist/components/radio/index.js +0 -1
- package/dist/components/radio/model.js +0 -1
- package/dist/components/section/index.js +0 -1
- package/dist/components/section/model.js +0 -1
- package/dist/components/select/index.js +0 -1
- package/dist/components/select/model.js +0 -1
- package/dist/components/stack/index.js +0 -1
- package/dist/components/switch/index.js +0 -1
- package/dist/components/switch/model.js +0 -1
- package/dist/components/tab-item/index.js +0 -1
- package/dist/components/tab-item/model.js +0 -1
- package/dist/components/tab-list/index.js +0 -1
- package/dist/components/tab-list/model.js +0 -1
- package/dist/components/tab-panel/index.js +0 -1
- package/dist/components/tab-panel/model.js +0 -1
- package/dist/components/tabs/index.js +0 -1
- package/dist/components/tag/index.js +0 -1
- package/dist/components/textarea/index.js +0 -1
- package/dist/components/tooltip/index.js +0 -1
- package/dist/shared/examples/index.js +0 -4
- package/dist/shared/figma.js +0 -1
- package/dist/shared/showcase/show-code-link.js +0 -51
|
@@ -1,729 +1,511 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
var _a, _b;
|
|
509
|
-
if ((_a = props.id) !== null && _a !== void 0 ? _a : (_b = props.propOverrides) === null || _b === void 0 ? void 0 : _b.id) {
|
|
510
|
-
resetIds();
|
|
511
|
-
}
|
|
512
|
-
}, [props.id, (_a = props.propOverrides) === null || _a === void 0 ? void 0 : _a.id]);
|
|
513
|
-
useEffect(() => {
|
|
514
|
-
if (detailsRef.current) {
|
|
515
|
-
detailsRef.current.addEventListener("focusout", (event) => handleClose(event));
|
|
516
|
-
}
|
|
517
|
-
}, [detailsRef.current]);
|
|
518
|
-
useEffect(() => {
|
|
519
|
-
if (_id) {
|
|
520
|
-
const messageId = _id + DEFAULT_MESSAGE_ID_SUFFIX;
|
|
521
|
-
set_labelId(_id + DEFAULT_LABEL_ID_SUFFIX);
|
|
522
|
-
set_selectId(_id + DEFAULT_SELECT_ID_SUFFIX);
|
|
523
|
-
set_validMessageId(_id + DEFAULT_VALID_MESSAGE_ID_SUFFIX);
|
|
524
|
-
set_invalidMessageId(_id + DEFAULT_INVALID_MESSAGE_ID_SUFFIX);
|
|
525
|
-
set_placeholderId(_id + DEFAULT_PLACEHOLDER_ID_SUFFIX);
|
|
526
|
-
if (stringPropVisible(props.message, props.showMessage)) {
|
|
527
|
-
setDescById(messageId);
|
|
528
|
-
}
|
|
529
|
-
else {
|
|
530
|
-
setDescById();
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
}, [_id]);
|
|
534
|
-
useEffect(() => {
|
|
535
|
-
var _a;
|
|
536
|
-
if (detailsRef.current) {
|
|
537
|
-
const summary = detailsRef.current.querySelector("summary");
|
|
538
|
-
if (summary) {
|
|
539
|
-
summary.setAttribute("aria-describedby", (_a = props.ariaDescribedBy) !== null && _a !== void 0 ? _a : (_descByIds || ""));
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
}, [detailsRef.current, _descByIds]);
|
|
543
|
-
useEffect(() => {
|
|
544
|
-
if (props.showNoResults !== undefined) {
|
|
545
|
-
set_hasNoOptions(props.showNoResults);
|
|
546
|
-
}
|
|
547
|
-
else if (_options) {
|
|
548
|
-
set_hasNoOptions(_options.length === 0);
|
|
549
|
-
}
|
|
550
|
-
}, [props.showNoResults, props.showLoading, _options]);
|
|
551
|
-
useEffect(() => {
|
|
552
|
-
var _a;
|
|
553
|
-
setSelectAllEnabled(Boolean(props.multiple && ((_a = props.showSelectAll) !== null && _a !== void 0 ? _a : amountOptions > 5)));
|
|
554
|
-
}, [props.showSelectAll, amountOptions, props.multiple]);
|
|
555
|
-
useEffect(() => {
|
|
556
|
-
var _a;
|
|
557
|
-
setSearchEnabled((_a = props.showSearch) !== null && _a !== void 0 ? _a : amountOptions > 9);
|
|
558
|
-
}, [props.showSearch, amountOptions]);
|
|
559
|
-
useEffect(() => {
|
|
560
|
-
const v = props.values;
|
|
561
|
-
if (Array.isArray(v)) {
|
|
562
|
-
if (_values !== v) {
|
|
563
|
-
set_values(v);
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
else if (v == null && (_values === null || _values === void 0 ? void 0 : _values.length) !== 0) {
|
|
567
|
-
set_values([]);
|
|
568
|
-
}
|
|
569
|
-
}, [props.values]);
|
|
570
|
-
useEffect(() => {
|
|
571
|
-
if (selectRef.current) {
|
|
572
|
-
handleValidation();
|
|
573
|
-
}
|
|
574
|
-
}, [_values, selectRef.current]);
|
|
575
|
-
useEffect(() => {
|
|
576
|
-
if (selectRef.current) {
|
|
577
|
-
let controller = abortController;
|
|
578
|
-
if (!controller) {
|
|
579
|
-
controller = new AbortController();
|
|
580
|
-
setAbortController(controller);
|
|
581
|
-
}
|
|
582
|
-
const initialValues = props.values;
|
|
583
|
-
addResetEventListener(selectRef.current, () => {
|
|
584
|
-
const resetValue = initialValues
|
|
585
|
-
? initialValues
|
|
586
|
-
: selectRef.current.value
|
|
587
|
-
? [selectRef.current.value]
|
|
588
|
-
: [];
|
|
589
|
-
handleOptionSelected(resetValue);
|
|
590
|
-
handleValidation();
|
|
591
|
-
}, controller.signal);
|
|
592
|
-
}
|
|
593
|
-
}, [selectRef.current]);
|
|
594
|
-
useEffect(() => {
|
|
595
|
-
set_validity(props.validation);
|
|
596
|
-
}, [props.validation]);
|
|
597
|
-
useEffect(() => {
|
|
598
|
-
if ((_values === null || _values === void 0 ? void 0 : _values.length) === 0) {
|
|
599
|
-
setSelectAllChecked(false);
|
|
600
|
-
setSelectAllIndeterminate(false);
|
|
601
|
-
}
|
|
602
|
-
else if ((_values === null || _values === void 0 ? void 0 : _values.length) === amountOptions) {
|
|
603
|
-
setSelectAllIndeterminate(false);
|
|
604
|
-
setSelectAllChecked(true);
|
|
605
|
-
}
|
|
606
|
-
else if (_values) {
|
|
607
|
-
setSelectAllIndeterminate(true);
|
|
608
|
-
}
|
|
609
|
-
}, [_values, amountOptions]);
|
|
610
|
-
useEffect(() => {
|
|
611
|
-
var _a, _b;
|
|
612
|
-
set_options(props.options);
|
|
613
|
-
setAmountOptions((_b = (_a = props.options) === null || _a === void 0 ? void 0 : _a.filter((option) => !option.isGroupTitle).length) !== null && _b !== void 0 ? _b : 0);
|
|
614
|
-
}, [props.options]);
|
|
615
|
-
useEffect(() => {
|
|
616
|
-
set_searchValue(props.searchValue);
|
|
617
|
-
if (props.searchValue) {
|
|
618
|
-
const sValue = props.searchValue; // <- workaround for Angular
|
|
619
|
-
handleSearch(sValue);
|
|
620
|
-
}
|
|
621
|
-
}, [props.searchValue]);
|
|
622
|
-
useEffect(() => {
|
|
623
|
-
var _a, _b;
|
|
624
|
-
if ((_a = props.options) === null || _a === void 0 ? void 0 : _a.length) {
|
|
625
|
-
set_selectedOptions((_b = props.options) === null || _b === void 0 ? void 0 : _b.filter((option) => {
|
|
626
|
-
if (!option.value || !(_values === null || _values === void 0 ? void 0 : _values["includes"])) {
|
|
627
|
-
return false;
|
|
628
|
-
}
|
|
629
|
-
return !option.isGroupTitle && (_values === null || _values === void 0 ? void 0 : _values.includes(option.value));
|
|
630
|
-
}));
|
|
631
|
-
}
|
|
632
|
-
}, [props.options, _values]);
|
|
633
|
-
useEffect(() => {
|
|
634
|
-
if (props.selectedLabels) {
|
|
635
|
-
set_selectedLabels(props.selectedLabels);
|
|
636
|
-
return;
|
|
637
|
-
}
|
|
638
|
-
if (_selectedOptions === null || _selectedOptions === void 0 ? void 0 : _selectedOptions.length) {
|
|
639
|
-
if (props.transformSelectedLabels) {
|
|
640
|
-
// We need to add this to another ``const`` for Angular generated output to work
|
|
641
|
-
const selectedOptions = _selectedOptions;
|
|
642
|
-
const transformFn = props.transformSelectedLabels;
|
|
643
|
-
set_selectedLabels(transformFn(selectedOptions));
|
|
644
|
-
return;
|
|
645
|
-
}
|
|
646
|
-
if (props.selectedType === "amount") {
|
|
647
|
-
set_selectedLabels(props.amountText
|
|
648
|
-
? props.amountText
|
|
649
|
-
: `${_selectedOptions === null || _selectedOptions === void 0 ? void 0 : _selectedOptions.length} ${DEFAULT_SELECTED}`);
|
|
650
|
-
}
|
|
651
|
-
else {
|
|
652
|
-
set_selectedLabels(_selectedOptions === null || _selectedOptions === void 0 ? void 0 : _selectedOptions.map((option) => getOptionLabel(option)).join(", "));
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
else {
|
|
656
|
-
set_selectedLabels("");
|
|
657
|
-
}
|
|
658
|
-
}, [
|
|
659
|
-
_selectedOptions,
|
|
660
|
-
props.selectedType,
|
|
661
|
-
props.amountText,
|
|
662
|
-
props.selectedLabels,
|
|
663
|
-
props.transformSelectedLabels,
|
|
664
|
-
]);
|
|
665
|
-
useEffect(() => {
|
|
666
|
-
var _a;
|
|
667
|
-
if (props.onAmountChange) {
|
|
668
|
-
props.onAmountChange((_a = _selectedOptions === null || _selectedOptions === void 0 ? void 0 : _selectedOptions.length) !== null && _a !== void 0 ? _a : 0);
|
|
669
|
-
}
|
|
670
|
-
}, [_selectedOptions]);
|
|
671
|
-
useEffect(() => {
|
|
672
|
-
if (selectAllRef.current) {
|
|
673
|
-
selectAllRef.current.indeterminate = Boolean(selectAllIndeterminate);
|
|
674
|
-
}
|
|
675
|
-
}, [selectAllIndeterminate, selectAllRef.current]);
|
|
676
|
-
useEffect(() => {
|
|
677
|
-
var _a;
|
|
678
|
-
set_invalidMessage(props.invalidMessage ||
|
|
679
|
-
((_a = selectRef.current) === null || _a === void 0 ? void 0 : _a.validationMessage) ||
|
|
680
|
-
DEFAULT_INVALID_MESSAGE);
|
|
681
|
-
}, [selectRef.current, props.invalidMessage]);
|
|
682
|
-
useEffect(() => {
|
|
683
|
-
return () => {
|
|
684
|
-
abortController === null || abortController === void 0 ? void 0 : abortController.abort();
|
|
685
|
-
};
|
|
686
|
-
}, []);
|
|
687
|
-
return (React.createElement("div", Object.assign({ id: _id, ref: _ref }, filterPassingProps(props, ["data-icon-variant", "data-icon-variant-before", "data-icon-variant-after", "data-icon-weight", "data-icon-weight-before", "data-icon-weight-after", "data-interactive", "data-force-mobile", "data-color", "data-container-color", "data-bg-color", "data-on-bg-color", "data-color-scheme", "data-font-size", "data-headline-size", "data-divider", "data-focus", "data-font", "data-density", "onOptionSelected", "onAmountChange", "onDropdownToggle"]), getRootProps(props, ["data-icon-variant", "data-icon-variant-before", "data-icon-variant-after", "data-icon-weight", "data-icon-weight-before", "data-icon-weight-after", "data-interactive", "data-force-mobile", "data-color", "data-container-color", "data-bg-color", "data-on-bg-color", "data-color-scheme", "data-font-size", "data-headline-size", "data-divider", "data-focus", "data-font", "data-density"]), { className: cls("db-custom-select", props.className), "aria-invalid": _validity === "invalid", "data-custom-validity": _validity, "data-width": props.formFieldWidth, "data-variant": props.variant === "floating" &&
|
|
688
|
-
props.selectedType === "tag" &&
|
|
689
|
-
props.multiple
|
|
690
|
-
? "above"
|
|
691
|
-
: props.variant, "data-required": getBooleanAsString(props.required), "data-hide-asterisk": getHideProp(props.showRequiredAsterisk), "data-placement": props.placement, "data-selected-type": props.multiple ? props.selectedType : "text", "data-hide-label": getHideProp(props.showLabel), "data-icon": props.icon, "data-show-icon": getBooleanAsString(props.showIcon) }),
|
|
692
|
-
React.createElement("label", { id: _labelId }, (_b = props.label) !== null && _b !== void 0 ? _b : DEFAULT_LABEL,
|
|
693
|
-
React.createElement("select", { role: "none", hidden: true, id: _selectId, tabIndex: -1, ref: selectRef, form: props.form, name: props.name, "data-custom-validity": _validity, multiple: getBoolean(props.multiple, "multiple"), disabled: getBoolean(props.disabled, "disabled"), required: getBoolean(props.required, "required"), onChange: (event) => satisfyReact(event) }, ((_c = props.options) === null || _c === void 0 ? void 0 : _c.length) ? (React.createElement(React.Fragment, null, (_d = props.options) === null || _d === void 0 ? void 0 : _d.map((option) => (React.createElement("option", { disabled: option.disabled, value: option.value, key: getOptionKey(option, "native-select-option-") }, getOptionLabel(option)))))) : null)),
|
|
694
|
-
React.createElement("details", { ref: detailsRef, open: props.open, onToggle: (event) => handleDropdownToggle(event), onKeyDown: (event) => handleKeyboardPress(event) },
|
|
695
|
-
props.children,
|
|
696
|
-
props.options ? (React.createElement(React.Fragment, null,
|
|
697
|
-
React.createElement("summary", { className: "db-custom-select-form-field", id: _summaryId, "aria-disabled": getBooleanAsString(props.disabled), tabIndex: props.disabled ? -1 : undefined, "aria-labelledby": _labelId },
|
|
698
|
-
(_selectedLabels === null || _selectedLabels === void 0 ? void 0 : _selectedLabels.length) ? (React.createElement("span", { "data-visually-hidden": getBooleanAsString(props.selectedType === "tag"), id: _selectedLabelsId },
|
|
699
|
-
props.selectedPrefix ? (React.createElement("span", { "data-visually-hidden": "true" }, props.selectedPrefix)) : null,
|
|
700
|
-
_selectedLabels)) : null,
|
|
701
|
-
props.selectedType === "tag" ? (React.createElement("div", null, _selectedOptions === null || _selectedOptions === void 0 ? void 0 : _selectedOptions.map((option) => (React.createElement(DBTag, { emphasis: "strong", behavior: "removable", removeButton: getTagRemoveLabel(option), onRemove: (event) => handleTagRemove(option, event), key: getOptionKey(option, "tag-") }, getOptionLabel(option)))))) : null),
|
|
702
|
-
React.createElement(DBCustomSelectDropdown, { width: props.dropdownWidth },
|
|
703
|
-
searchEnabled ? (React.createElement("div", null,
|
|
704
|
-
React.createElement(DBInput, { type: "search", ref: searchInputRef, name: _id, form: _id, showLabel: false, value: _searchValue, label: (_e = props.searchLabel) !== null && _e !== void 0 ? _e : DEFAULT_LABEL, placeholder: (_f = props.searchPlaceholder) !== null && _f !== void 0 ? _f : props.searchLabel, ariaDescribedBy: _hasNoOptions || props.showLoading
|
|
705
|
-
? _infoTextId
|
|
706
|
-
: undefined, onInput: (event) => handleSearch(event) }))) : null,
|
|
707
|
-
_hasNoOptions || props.showLoading ? (React.createElement(DBInfotext, { id: _infoTextId, icon: props.showLoading ? "circular_arrows" : undefined, semantic: props.showLoading ? "informational" : "warning" }, (_g = (props.showLoading
|
|
708
|
-
? props.loadingText
|
|
709
|
-
: props.noResultsText)) !== null && _g !== void 0 ? _g : DEFAULT_MESSAGE)) : (React.createElement(React.Fragment, null,
|
|
710
|
-
React.createElement(React.Fragment, null,
|
|
711
|
-
selectAllEnabled ? (React.createElement("div", null,
|
|
712
|
-
React.createElement("div", { className: "db-checkbox db-custom-select-list-item" },
|
|
713
|
-
React.createElement("label", null,
|
|
714
|
-
React.createElement("input", { type: "checkbox", value: "select-all", ref: selectAllRef, form: _id, checked: selectAllChecked, onChange: (event) => handleSelectAll(event) }),
|
|
715
|
-
getSelectAllLabel())))) : null,
|
|
716
|
-
React.createElement(DBCustomSelectList, { multiple: getBoolean(props.multiple, "multiple"), label: (_j = (_h = props.listLabel) !== null && _h !== void 0 ? _h : props.label) !== null && _j !== void 0 ? _j : DEFAULT_LABEL }, _options === null || _options === void 0 ? void 0 : _options.map((option) => (React.createElement(DBCustomSelectListItem, { type: props.multiple ? "checkbox" : "radio", showDivider: option.showDivider, icon: option.icon, isGroupTitle: option.isGroupTitle, groupTitle: getOptionLabel(option), name: _id, checked: getOptionChecked(option.value), disabled: option.disabled, value: option.value, onChange: (event) => handleSelect(option.value), key: getOptionKey(option, "custom-select-list-item-") }, !option.isGroupTitle ? (React.createElement(React.Fragment, null, getOptionLabel(option))) : null))))))),
|
|
717
|
-
React.createElement("div", null,
|
|
718
|
-
React.createElement(DBButton, { variant: "ghost", width: "full", icon: "cross", size: "small", name: _id, form: _id, onClick: (event) => handleClose(undefined, true) }, (_k = props.mobileCloseButtonText) !== null && _k !== void 0 ? _k : DEFAULT_CLOSE_BUTTON))))) : null),
|
|
719
|
-
((_l = props.showClearSelection) !== null && _l !== void 0 ? _l : true) && (_values === null || _values === void 0 ? void 0 : _values.length) ? (React.createElement(DBButton, { icon: "cross", variant: "ghost", size: "small", noText: true, name: _id, form: _id, disabled: getBoolean(props.disabled, "disabled"), onClick: (event) => handleClearAll(event) },
|
|
720
|
-
props.clearSelectionText,
|
|
721
|
-
React.createElement(DBTooltip, { placement: "top" }, props.clearSelectionText))) : null,
|
|
722
|
-
React.createElement("span", { className: "db-custom-select-placeholder", "aria-hidden": getBooleanAsString(true), id: _placeholderId }, (_m = props.placeholder) !== null && _m !== void 0 ? _m : props.label),
|
|
723
|
-
stringPropVisible(props.message, props.showMessage) ? (React.createElement(DBInfotext, { size: "small", icon: props.messageIcon, id: _messageId }, props.message)) : null,
|
|
724
|
-
hasValidState() ? (React.createElement(DBInfotext, { size: "small", semantic: "successful", id: _validMessageId }, props.validMessage || DEFAULT_VALID_MESSAGE)) : null,
|
|
725
|
-
React.createElement(DBInfotext, { size: "small", semantic: "critical", id: _invalidMessageId }, _invalidMessage),
|
|
726
|
-
React.createElement("span", { "data-visually-hidden": "true", role: "status" }, _voiceOverFallback)));
|
|
2
|
+
import { filterPassingProps as e, getRootProps as t } from "../../utils/react.js";
|
|
3
|
+
import { cls as n, delay as r, getBoolean as i, getBooleanAsString as a, getHideProp as ee, getOptionKey as o, getSearchInput as te, hasVoiceOver as ne, stringPropVisible as s } from "../../utils/index.js";
|
|
4
|
+
import { DEFAULT_INVALID_MESSAGE_ID_SUFFIX as re, DEFAULT_LABEL_ID_SUFFIX as ie, DEFAULT_MESSAGE_ID_SUFFIX as ae, DEFAULT_PLACEHOLDER_ID_SUFFIX as c, DEFAULT_REMOVE as oe, DEFAULT_SELECTED as se, DEFAULT_SELECT_ID_SUFFIX as ce, DEFAULT_VALID_MESSAGE_ID_SUFFIX as le } from "../../shared/constants.js";
|
|
5
|
+
import ue from "../button/button.js";
|
|
6
|
+
import { addResetEventListener as de } from "../../utils/form-components.js";
|
|
7
|
+
import l from "../infotext/infotext.js";
|
|
8
|
+
import { DocumentClickListener as fe } from "../../utils/document-click-listener.js";
|
|
9
|
+
import { DocumentScrollListener as u } from "../../utils/document-scroll-listener.js";
|
|
10
|
+
import { handleFixedDropdown as pe } from "../../utils/floating-components.js";
|
|
11
|
+
import me from "../custom-select-dropdown/custom-select-dropdown.js";
|
|
12
|
+
import he from "../custom-select-list-item/custom-select-list-item.js";
|
|
13
|
+
import ge from "../custom-select-list/custom-select-list.js";
|
|
14
|
+
import _e from "../input/input.js";
|
|
15
|
+
import ve from "../tooltip/tooltip.js";
|
|
16
|
+
import ye from "../tag/tag.js";
|
|
17
|
+
import { forwardRef as d, useEffect as f, useId as be, useRef as p, useState as m } from "react";
|
|
18
|
+
import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
19
|
+
//#region src/components/custom-select/custom-select.tsx
|
|
20
|
+
function v(d, v) {
|
|
21
|
+
d = {
|
|
22
|
+
clearSelectionText: "Clear selection",
|
|
23
|
+
showClearSelection: !0,
|
|
24
|
+
...d
|
|
25
|
+
};
|
|
26
|
+
let xe = be(), Se = v || p(v), y = p(null), b = p(null), x = p(null), S = p(null), [C, Ce] = m(() => void 0), [w, we] = m(() => void 0), [T, E] = m(() => void 0), [D, O] = m(() => void 0), [k, A] = m(() => void 0), [Te, j] = m(() => void 0), [M, Ee] = m(() => void 0), [De, Oe] = m(() => void 0), [ke, Ae] = m(() => void 0), [je, Me] = m(() => void 0), [N, P] = m(() => "no-validation"), [Ne, Pe] = m(() => !1), [Fe, Ie] = m(() => void 0), [Le, Re] = m(() => void 0), [F, I] = m(() => ""), [L, ze] = m(() => void 0), [Be, R] = m(() => ""), [z, Ve] = m(() => []), [He, Ue] = m(() => !1), [We, Ge] = m(() => !1), [B, Ke] = m(() => 0), [V, H] = m(() => []), [U, W] = m(() => []), [qe, Je] = m(() => !1), [Ye, Xe] = m(() => void 0), [Ze, Qe] = m(() => 0), [$e, et] = m(() => void 0), [tt, nt] = m(() => void 0);
|
|
27
|
+
function rt(e) {
|
|
28
|
+
e?.target?.contains && e?.target?.contains(y.current) && q();
|
|
29
|
+
}
|
|
30
|
+
let [it, at] = m(() => void 0);
|
|
31
|
+
function ot() {
|
|
32
|
+
return !!(d.validMessage ?? d.validation === "valid");
|
|
33
|
+
}
|
|
34
|
+
function st() {
|
|
35
|
+
b.current && (b.current.value = lt()), !b.current?.validity.valid || d.validation === "invalid" ? (G(D), A(d.invalidMessage || b.current?.validationMessage || "TODO: Add an invalidMessage"), ne() && (R(k), r(() => R(""), 1e3)), Ne && P(d.validation ?? "invalid")) : ot() && b.current?.validity.valid && d.required ? (G(T), ne() && (R(d.validMessage ?? "TODO: Add a validMessage"), r(() => R(""), 1e3)), P(d.validation ?? "valid")) : s(d.message, d.showMessage) ? (G(w), P(d.validation ?? "no-validation")) : (G(ke), P(d.validation ?? "no-validation"));
|
|
36
|
+
}
|
|
37
|
+
function ct(e) {
|
|
38
|
+
d.onDropdownToggle && (e.stopPropagation(), d.onDropdownToggle(e)), e.target instanceof HTMLDetailsElement && e.target.open ? (Xe(new fe().addCallback((e) => gt(e))), et(new u().addCallback((e) => rt(e))), q(), tt?.observe(y.current), e.target.dataset.test || vt()) : (Ye && new fe().removeCallback(Ye), $e && new u().removeCallback($e), tt?.unobserve(y.current));
|
|
39
|
+
}
|
|
40
|
+
function lt() {
|
|
41
|
+
return V?.length ? V.at(0) ?? "" : "";
|
|
42
|
+
}
|
|
43
|
+
function G(e) {
|
|
44
|
+
let t = [];
|
|
45
|
+
e && t.push(e), L && F?.length && t.push(L), Re(t.join(" "));
|
|
46
|
+
}
|
|
47
|
+
function ut() {
|
|
48
|
+
return d.selectAllLabel ?? "LABEL SHOULD BE SET";
|
|
49
|
+
}
|
|
50
|
+
function K(e) {
|
|
51
|
+
return e.label ?? e.value?.toString() ?? "";
|
|
52
|
+
}
|
|
53
|
+
function dt(e) {
|
|
54
|
+
return e && V?.includes ? V?.includes(e) : !1;
|
|
55
|
+
}
|
|
56
|
+
function ft(e) {
|
|
57
|
+
let t = d.removeTagsTexts, n = d.options;
|
|
58
|
+
if (t && n) {
|
|
59
|
+
let r = n.findIndex((t) => t.value === e.value);
|
|
60
|
+
if (r >= 0 && r < t.length) return t[r];
|
|
61
|
+
}
|
|
62
|
+
return `${oe} ${K(e)}`;
|
|
63
|
+
}
|
|
64
|
+
function pt(e, t) {
|
|
65
|
+
t && t.stopPropagation(), X(e.value), Q();
|
|
66
|
+
}
|
|
67
|
+
function q() {
|
|
68
|
+
if (y.current) {
|
|
69
|
+
let e = y.current.querySelector("article");
|
|
70
|
+
e && r(() => {
|
|
71
|
+
pe(e, y.current, d.placement ?? "bottom");
|
|
72
|
+
}, 1);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function mt(e) {
|
|
76
|
+
if (y.current?.open) {
|
|
77
|
+
if (self.document) {
|
|
78
|
+
let t = self.document.activeElement;
|
|
79
|
+
if (t) if (t.getAttribute("type") === "checkbox" || t.getAttribute("type") === "radio") {
|
|
80
|
+
let n = t?.closest("li");
|
|
81
|
+
if (e.key === "ArrowDown" || e.key === "ArrowRight") {
|
|
82
|
+
let e = n?.nextElementSibling;
|
|
83
|
+
for (; e;) {
|
|
84
|
+
let t = e.querySelector("input");
|
|
85
|
+
if (t) {
|
|
86
|
+
t.focus();
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
e = e.nextElementSibling;
|
|
90
|
+
}
|
|
91
|
+
e || Z(t);
|
|
92
|
+
} else {
|
|
93
|
+
let e = n?.previousElementSibling;
|
|
94
|
+
for (; e;) {
|
|
95
|
+
let t = e.querySelector("input");
|
|
96
|
+
if (t) {
|
|
97
|
+
t.focus();
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
e = e.previousElementSibling;
|
|
101
|
+
}
|
|
102
|
+
if (!e) {
|
|
103
|
+
let e = y.current.querySelector("input[type=\"checkbox\"]");
|
|
104
|
+
if (e && e !== t) Z(t);
|
|
105
|
+
else {
|
|
106
|
+
let e = te(y.current);
|
|
107
|
+
if (e) r(() => {
|
|
108
|
+
e.focus();
|
|
109
|
+
}, 100);
|
|
110
|
+
else {
|
|
111
|
+
let e = Array.from(y.current?.querySelectorAll("input[type=\"checkbox\"],input[type=\"radio\"]"));
|
|
112
|
+
e.length && e.at(-1)?.focus();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
} else t.getAttribute("type") === "search" && (e.key === "ArrowUp" || e.key === "ArrowLeft") ? (J(void 0, !0), Q()) : Z(t);
|
|
118
|
+
}
|
|
119
|
+
} else (e.key === "ArrowDown" || e.key === "ArrowRight") && (q(), y.current && (y.current.open = !0), vt());
|
|
120
|
+
e.stopPropagation(), e.preventDefault();
|
|
121
|
+
}
|
|
122
|
+
function ht(e) {
|
|
123
|
+
if (e.stopPropagation(), e.key === "Escape" && y.current?.open) J(void 0, !0), Q();
|
|
124
|
+
else if (e.key === "Enter" && y.current?.open) {
|
|
125
|
+
if (self.document) {
|
|
126
|
+
let t = self.document.activeElement;
|
|
127
|
+
if (["checkbox", "radio"].includes(t.getAttribute("type") || "")) t.click(), e.preventDefault();
|
|
128
|
+
else if (t.getAttribute("type") === "search") {
|
|
129
|
+
let t = U?.find((e) => !e.isGroupTitle && !e.disabled);
|
|
130
|
+
t?.value && (X(t.value), e.preventDefault());
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
} else (e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "ArrowLeft" || e.key === "ArrowRight") && mt(e);
|
|
134
|
+
}
|
|
135
|
+
function J(e, t) {
|
|
136
|
+
if (y.current) {
|
|
137
|
+
if (t) y.current.open = !1, Q();
|
|
138
|
+
else if (y.current.open && e && e.relatedTarget) {
|
|
139
|
+
let t = e.relatedTarget;
|
|
140
|
+
!y.current.contains(t) && t.localName !== "dialog" && r(() => y.current.open = !1, 1);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function gt(e) {
|
|
145
|
+
if (e) {
|
|
146
|
+
let t = e.target;
|
|
147
|
+
y.current?.open && !y.current.contains(t) && (y.current.open = !1);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function Y(e) {
|
|
151
|
+
(/* @__PURE__ */ new Date()).getTime() - Ze < 200 || (H(e), Pe(!0), d.onOptionSelected && d.onOptionSelected(e ?? []), Qe((/* @__PURE__ */ new Date()).getTime()));
|
|
152
|
+
}
|
|
153
|
+
function X(e) {
|
|
154
|
+
e && (d.multiple ? V?.includes(e) ? Y(V.filter((t) => t !== e)) : Y([...V || [], e]) : (Y([e]), J(void 0, !0)));
|
|
155
|
+
}
|
|
156
|
+
function _t(e) {
|
|
157
|
+
if (e.stopPropagation(), V?.length === B) Y([]);
|
|
158
|
+
else {
|
|
159
|
+
let e = We && S.current ? S.current.value : void 0;
|
|
160
|
+
Y(d.options ? d.options.filter((t) => !t.isGroupTitle && (!e || t.value?.toLowerCase().includes(e.toLowerCase()))).map((e) => e.value ?? "") : []);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function Z(e) {
|
|
164
|
+
if (y.current) {
|
|
165
|
+
let t = Array.from(y.current.querySelectorAll("input[type=\"checkbox\"],input[type=\"radio\"]"));
|
|
166
|
+
if (t.length) {
|
|
167
|
+
let n = t.at(0), i = n === e && t.length > 1 ? t.at(1) : n;
|
|
168
|
+
i && r(() => {
|
|
169
|
+
i.focus();
|
|
170
|
+
}, 1);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function vt() {
|
|
175
|
+
if (y.current) {
|
|
176
|
+
let e = te(y.current);
|
|
177
|
+
e ? r(() => {
|
|
178
|
+
e.focus();
|
|
179
|
+
}, 1) : Z();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function yt(e) {
|
|
183
|
+
if (e === void 0) return;
|
|
184
|
+
let t;
|
|
185
|
+
if (typeof e == "string") t = e;
|
|
186
|
+
else {
|
|
187
|
+
let n = e;
|
|
188
|
+
n.stopPropagation(), d.onSearch && d.onSearch(n), t = n.target.value, at(t);
|
|
189
|
+
}
|
|
190
|
+
!d.options || !t || t.length === 0 ? W(d.options) : d.searchFilter ? W(d.options.filter((e) => d.searchFilter(e, t))) : W(d.options.filter((e) => !e.isGroupTitle && K(e).toLowerCase().includes(t.toLowerCase())));
|
|
191
|
+
}
|
|
192
|
+
function bt(e) {
|
|
193
|
+
e.stopPropagation(), Y([]), Q();
|
|
194
|
+
}
|
|
195
|
+
function Q() {
|
|
196
|
+
y.current && y.current.querySelector("summary")?.focus();
|
|
197
|
+
}
|
|
198
|
+
let [xt, St] = m(() => !1), [Ct, $] = m(() => !1);
|
|
199
|
+
function wt() {
|
|
200
|
+
let e = d.id ?? d.propOverrides?.id ?? `custom-select-${xe}`;
|
|
201
|
+
Ce(e), we(e + ae), E(e + le), O(e + re), j(e + ce), Ee(e + ie), Oe(e + "-summary"), Ae(e + c), ze(e + "-selected-labels"), Me(e + "-info");
|
|
202
|
+
}
|
|
203
|
+
function Tt(e) {
|
|
204
|
+
e.stopPropagation();
|
|
205
|
+
}
|
|
206
|
+
return f(() => {
|
|
207
|
+
wt(), A(d.invalidMessage || "TODO: Add an invalidMessage"), typeof window < "u" && "IntersectionObserver" in window && nt(new IntersectionObserver((e) => {
|
|
208
|
+
if (y.current) {
|
|
209
|
+
let t = e.find(({ target: e }) => e === y.current);
|
|
210
|
+
t && !t.isIntersecting && y.current.open && (y.current.open = !1);
|
|
211
|
+
}
|
|
212
|
+
}));
|
|
213
|
+
}, []), f(() => {
|
|
214
|
+
(d.id ?? d.propOverrides?.id) && wt();
|
|
215
|
+
}, [d.id, d.propOverrides?.id]), f(() => {
|
|
216
|
+
y.current && y.current.addEventListener("focusout", (e) => J(e));
|
|
217
|
+
}, [y.current]), f(() => {
|
|
218
|
+
if (C) {
|
|
219
|
+
let e = C + ae;
|
|
220
|
+
Ee(C + ie), j(C + ce), E(C + le), O(C + re), Ae(C + c), s(d.message, d.showMessage) ? G(e) : G();
|
|
221
|
+
}
|
|
222
|
+
}, [C]), f(() => {
|
|
223
|
+
if (y.current) {
|
|
224
|
+
let e = y.current.querySelector("summary");
|
|
225
|
+
e && e.setAttribute("aria-describedby", d.ariaDescribedBy ?? (Le || ""));
|
|
226
|
+
}
|
|
227
|
+
}, [y.current, Le]), f(() => {
|
|
228
|
+
d.showNoResults === void 0 ? U && Je(U.length === 0) : Je(d.showNoResults);
|
|
229
|
+
}, [
|
|
230
|
+
d.showNoResults,
|
|
231
|
+
d.showLoading,
|
|
232
|
+
U
|
|
233
|
+
]), f(() => {
|
|
234
|
+
Ue(!!(d.multiple && (d.showSelectAll ?? B > 5)));
|
|
235
|
+
}, [
|
|
236
|
+
d.showSelectAll,
|
|
237
|
+
B,
|
|
238
|
+
d.multiple
|
|
239
|
+
]), f(() => {
|
|
240
|
+
Ge(d.showSearch ?? B > 9);
|
|
241
|
+
}, [d.showSearch, B]), f(() => {
|
|
242
|
+
let e = d.values;
|
|
243
|
+
Array.isArray(e) ? V !== e && H(e) : e == null && V?.length !== 0 && H([]);
|
|
244
|
+
}, [d.values]), f(() => {
|
|
245
|
+
b.current && st();
|
|
246
|
+
}, [V, b.current]), f(() => {
|
|
247
|
+
if (b.current) {
|
|
248
|
+
let e = Fe;
|
|
249
|
+
e || (e = new AbortController(), Ie(e));
|
|
250
|
+
let t = d.values;
|
|
251
|
+
de(b.current, () => {
|
|
252
|
+
Y(t || (b.current.value ? [b.current.value] : [])), st();
|
|
253
|
+
}, e.signal);
|
|
254
|
+
}
|
|
255
|
+
}, [b.current]), f(() => {
|
|
256
|
+
P(d.validation);
|
|
257
|
+
}, [d.validation]), f(() => {
|
|
258
|
+
V?.length === 0 ? (St(!1), $(!1)) : V?.length === B ? ($(!1), St(!0)) : V && $(!0);
|
|
259
|
+
}, [V, B]), f(() => {
|
|
260
|
+
W(d.options), Ke(d.options?.filter((e) => !e.isGroupTitle).length ?? 0);
|
|
261
|
+
}, [d.options]), f(() => {
|
|
262
|
+
if (at(d.searchValue), d.searchValue) {
|
|
263
|
+
let e = d.searchValue;
|
|
264
|
+
yt(e);
|
|
265
|
+
}
|
|
266
|
+
}, [d.searchValue]), f(() => {
|
|
267
|
+
d.options?.length && Ve(d.options?.filter((e) => !e.value || !V?.includes ? !1 : !e.isGroupTitle && V?.includes(e.value)));
|
|
268
|
+
}, [d.options, V]), f(() => {
|
|
269
|
+
if (d.selectedLabels) {
|
|
270
|
+
I(d.selectedLabels);
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
if (z?.length) {
|
|
274
|
+
if (d.transformSelectedLabels) {
|
|
275
|
+
let e = z, t = d.transformSelectedLabels;
|
|
276
|
+
I(t(e));
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
d.selectedType === "amount" ? I(d.amountText ? d.amountText : `${z?.length} ${se}`) : I(z?.map((e) => K(e)).join(", "));
|
|
280
|
+
} else I("");
|
|
281
|
+
}, [
|
|
282
|
+
z,
|
|
283
|
+
d.selectedType,
|
|
284
|
+
d.amountText,
|
|
285
|
+
d.selectedLabels,
|
|
286
|
+
d.transformSelectedLabels
|
|
287
|
+
]), f(() => {
|
|
288
|
+
d.onAmountChange && d.onAmountChange(z?.length ?? 0);
|
|
289
|
+
}, [z]), f(() => {
|
|
290
|
+
x.current && (x.current.indeterminate = !!Ct);
|
|
291
|
+
}, [Ct, x.current]), f(() => {
|
|
292
|
+
A(d.invalidMessage || b.current?.validationMessage || "TODO: Add an invalidMessage");
|
|
293
|
+
}, [b.current, d.invalidMessage]), f(() => () => {
|
|
294
|
+
Fe?.abort();
|
|
295
|
+
}, []), /* @__PURE__ */ _("div", {
|
|
296
|
+
id: C,
|
|
297
|
+
ref: Se,
|
|
298
|
+
...e(d, [
|
|
299
|
+
"data-icon-variant",
|
|
300
|
+
"data-icon-variant-before",
|
|
301
|
+
"data-icon-variant-after",
|
|
302
|
+
"data-icon-weight",
|
|
303
|
+
"data-icon-weight-before",
|
|
304
|
+
"data-icon-weight-after",
|
|
305
|
+
"data-interactive",
|
|
306
|
+
"data-force-mobile",
|
|
307
|
+
"data-color",
|
|
308
|
+
"data-container-color",
|
|
309
|
+
"data-bg-color",
|
|
310
|
+
"data-on-bg-color",
|
|
311
|
+
"data-color-scheme",
|
|
312
|
+
"data-font-size",
|
|
313
|
+
"data-headline-size",
|
|
314
|
+
"data-divider",
|
|
315
|
+
"data-focus",
|
|
316
|
+
"data-font",
|
|
317
|
+
"data-density",
|
|
318
|
+
"onOptionSelected",
|
|
319
|
+
"onAmountChange",
|
|
320
|
+
"onDropdownToggle"
|
|
321
|
+
]),
|
|
322
|
+
...t(d, [
|
|
323
|
+
"data-icon-variant",
|
|
324
|
+
"data-icon-variant-before",
|
|
325
|
+
"data-icon-variant-after",
|
|
326
|
+
"data-icon-weight",
|
|
327
|
+
"data-icon-weight-before",
|
|
328
|
+
"data-icon-weight-after",
|
|
329
|
+
"data-interactive",
|
|
330
|
+
"data-force-mobile",
|
|
331
|
+
"data-color",
|
|
332
|
+
"data-container-color",
|
|
333
|
+
"data-bg-color",
|
|
334
|
+
"data-on-bg-color",
|
|
335
|
+
"data-color-scheme",
|
|
336
|
+
"data-font-size",
|
|
337
|
+
"data-headline-size",
|
|
338
|
+
"data-divider",
|
|
339
|
+
"data-focus",
|
|
340
|
+
"data-font",
|
|
341
|
+
"data-density"
|
|
342
|
+
]),
|
|
343
|
+
className: n("db-custom-select", d.className),
|
|
344
|
+
"aria-invalid": N === "invalid",
|
|
345
|
+
"data-custom-validity": N,
|
|
346
|
+
"data-width": d.formFieldWidth,
|
|
347
|
+
"data-variant": d.variant === "floating" && d.selectedType === "tag" && d.multiple ? "above" : d.variant,
|
|
348
|
+
"data-required": a(d.required),
|
|
349
|
+
"data-hide-asterisk": ee(d.showRequiredAsterisk),
|
|
350
|
+
"data-placement": d.placement,
|
|
351
|
+
"data-selected-type": d.multiple ? d.selectedType : "text",
|
|
352
|
+
"data-hide-label": ee(d.showLabel),
|
|
353
|
+
"data-icon": d.icon,
|
|
354
|
+
"data-show-icon": a(d.showIcon),
|
|
355
|
+
children: [
|
|
356
|
+
/* @__PURE__ */ _("label", {
|
|
357
|
+
id: M,
|
|
358
|
+
children: [d.label ?? "LABEL SHOULD BE SET", /* @__PURE__ */ g("select", {
|
|
359
|
+
role: "none",
|
|
360
|
+
hidden: !0,
|
|
361
|
+
id: Te,
|
|
362
|
+
tabIndex: -1,
|
|
363
|
+
ref: b,
|
|
364
|
+
form: d.form,
|
|
365
|
+
name: d.name,
|
|
366
|
+
"data-custom-validity": N,
|
|
367
|
+
multiple: i(d.multiple, "multiple"),
|
|
368
|
+
disabled: i(d.disabled, "disabled"),
|
|
369
|
+
required: i(d.required, "required"),
|
|
370
|
+
onChange: (e) => Tt(e),
|
|
371
|
+
children: d.options?.length ? /* @__PURE__ */ g(h, { children: d.options?.map((e) => /* @__PURE__ */ g("option", {
|
|
372
|
+
disabled: e.disabled,
|
|
373
|
+
value: e.value,
|
|
374
|
+
children: K(e)
|
|
375
|
+
}, o(e, "native-select-option-"))) }) : null
|
|
376
|
+
})]
|
|
377
|
+
}),
|
|
378
|
+
/* @__PURE__ */ _("details", {
|
|
379
|
+
ref: y,
|
|
380
|
+
open: d.open,
|
|
381
|
+
onToggle: (e) => ct(e),
|
|
382
|
+
onKeyDown: (e) => ht(e),
|
|
383
|
+
children: [d.children, d.options ? /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ _("summary", {
|
|
384
|
+
className: "db-custom-select-form-field",
|
|
385
|
+
id: De,
|
|
386
|
+
"aria-disabled": a(d.disabled),
|
|
387
|
+
tabIndex: d.disabled ? -1 : void 0,
|
|
388
|
+
"aria-labelledby": M,
|
|
389
|
+
children: [F?.length ? /* @__PURE__ */ _("span", {
|
|
390
|
+
"data-visually-hidden": a(d.selectedType === "tag"),
|
|
391
|
+
id: L,
|
|
392
|
+
children: [d.selectedPrefix ? /* @__PURE__ */ g("span", {
|
|
393
|
+
"data-visually-hidden": "true",
|
|
394
|
+
children: d.selectedPrefix
|
|
395
|
+
}) : null, F]
|
|
396
|
+
}) : null, d.selectedType === "tag" ? /* @__PURE__ */ g("div", { children: z?.map((e) => /* @__PURE__ */ g(ye, {
|
|
397
|
+
emphasis: "strong",
|
|
398
|
+
behavior: "removable",
|
|
399
|
+
removeButton: ft(e),
|
|
400
|
+
onRemove: (t) => pt(e, t),
|
|
401
|
+
children: K(e)
|
|
402
|
+
}, o(e, "tag-"))) }) : null]
|
|
403
|
+
}), /* @__PURE__ */ _(me, {
|
|
404
|
+
width: d.dropdownWidth,
|
|
405
|
+
children: [
|
|
406
|
+
We ? /* @__PURE__ */ g("div", { children: /* @__PURE__ */ g(_e, {
|
|
407
|
+
type: "search",
|
|
408
|
+
ref: S,
|
|
409
|
+
name: C,
|
|
410
|
+
form: C,
|
|
411
|
+
showLabel: !1,
|
|
412
|
+
value: it,
|
|
413
|
+
label: d.searchLabel ?? "LABEL SHOULD BE SET",
|
|
414
|
+
placeholder: d.searchPlaceholder ?? d.searchLabel,
|
|
415
|
+
ariaDescribedBy: qe || d.showLoading ? je : void 0,
|
|
416
|
+
onInput: (e) => yt(e)
|
|
417
|
+
}) }) : null,
|
|
418
|
+
qe || d.showLoading ? /* @__PURE__ */ g(l, {
|
|
419
|
+
id: je,
|
|
420
|
+
icon: d.showLoading ? "circular_arrows" : void 0,
|
|
421
|
+
semantic: d.showLoading ? "informational" : "warning",
|
|
422
|
+
children: (d.showLoading ? d.loadingText : d.noResultsText) ?? "MESSAGE SHOULD BE SET"
|
|
423
|
+
}) : /* @__PURE__ */ g(h, { children: /* @__PURE__ */ _(h, { children: [He ? /* @__PURE__ */ g("div", { children: /* @__PURE__ */ g("div", {
|
|
424
|
+
className: "db-checkbox db-custom-select-list-item",
|
|
425
|
+
children: /* @__PURE__ */ _("label", { children: [/* @__PURE__ */ g("input", {
|
|
426
|
+
type: "checkbox",
|
|
427
|
+
value: "select-all",
|
|
428
|
+
ref: x,
|
|
429
|
+
form: C,
|
|
430
|
+
checked: xt,
|
|
431
|
+
onChange: (e) => _t(e)
|
|
432
|
+
}), ut()] })
|
|
433
|
+
}) }) : null, /* @__PURE__ */ g(ge, {
|
|
434
|
+
multiple: i(d.multiple, "multiple"),
|
|
435
|
+
label: d.listLabel ?? d.label ?? "LABEL SHOULD BE SET",
|
|
436
|
+
children: U?.map((e) => /* @__PURE__ */ g(he, {
|
|
437
|
+
type: d.multiple ? "checkbox" : "radio",
|
|
438
|
+
showDivider: e.showDivider,
|
|
439
|
+
icon: e.icon,
|
|
440
|
+
isGroupTitle: e.isGroupTitle,
|
|
441
|
+
groupTitle: K(e),
|
|
442
|
+
name: C,
|
|
443
|
+
checked: dt(e.value),
|
|
444
|
+
disabled: e.disabled,
|
|
445
|
+
value: e.value,
|
|
446
|
+
onChange: (t) => X(e.value),
|
|
447
|
+
children: e.isGroupTitle ? null : /* @__PURE__ */ g(h, { children: K(e) })
|
|
448
|
+
}, o(e, "custom-select-list-item-")))
|
|
449
|
+
})] }) }),
|
|
450
|
+
/* @__PURE__ */ g("div", { children: /* @__PURE__ */ g(ue, {
|
|
451
|
+
variant: "ghost",
|
|
452
|
+
width: "full",
|
|
453
|
+
icon: "cross",
|
|
454
|
+
size: "small",
|
|
455
|
+
name: C,
|
|
456
|
+
form: C,
|
|
457
|
+
onClick: (e) => J(void 0, !0),
|
|
458
|
+
children: d.mobileCloseButtonText ?? "Close"
|
|
459
|
+
}) })
|
|
460
|
+
]
|
|
461
|
+
})] }) : null]
|
|
462
|
+
}),
|
|
463
|
+
(d.showClearSelection ?? !0) && V?.length ? /* @__PURE__ */ _(ue, {
|
|
464
|
+
icon: "cross",
|
|
465
|
+
variant: "ghost",
|
|
466
|
+
size: "small",
|
|
467
|
+
noText: !0,
|
|
468
|
+
name: C,
|
|
469
|
+
form: C,
|
|
470
|
+
disabled: i(d.disabled, "disabled"),
|
|
471
|
+
onClick: (e) => bt(e),
|
|
472
|
+
children: [d.clearSelectionText, /* @__PURE__ */ g(ve, {
|
|
473
|
+
placement: "top",
|
|
474
|
+
children: d.clearSelectionText
|
|
475
|
+
})]
|
|
476
|
+
}) : null,
|
|
477
|
+
/* @__PURE__ */ g("span", {
|
|
478
|
+
className: "db-custom-select-placeholder",
|
|
479
|
+
"aria-hidden": a(!0),
|
|
480
|
+
id: ke,
|
|
481
|
+
children: d.placeholder ?? d.label
|
|
482
|
+
}),
|
|
483
|
+
s(d.message, d.showMessage) ? /* @__PURE__ */ g(l, {
|
|
484
|
+
size: "small",
|
|
485
|
+
icon: d.messageIcon,
|
|
486
|
+
id: w,
|
|
487
|
+
children: d.message
|
|
488
|
+
}) : null,
|
|
489
|
+
ot() ? /* @__PURE__ */ g(l, {
|
|
490
|
+
size: "small",
|
|
491
|
+
semantic: "successful",
|
|
492
|
+
id: T,
|
|
493
|
+
children: d.validMessage || "TODO: Add a validMessage"
|
|
494
|
+
}) : null,
|
|
495
|
+
/* @__PURE__ */ g(l, {
|
|
496
|
+
size: "small",
|
|
497
|
+
semantic: "critical",
|
|
498
|
+
id: D,
|
|
499
|
+
children: k
|
|
500
|
+
}),
|
|
501
|
+
/* @__PURE__ */ g("span", {
|
|
502
|
+
"data-visually-hidden": "true",
|
|
503
|
+
role: "status",
|
|
504
|
+
children: Be
|
|
505
|
+
})
|
|
506
|
+
]
|
|
507
|
+
});
|
|
727
508
|
}
|
|
728
|
-
|
|
729
|
-
|
|
509
|
+
var xe = d(v);
|
|
510
|
+
//#endregion
|
|
511
|
+
export { xe as default };
|