@coinbase/cds-mobile 8.28.2 → 8.30.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dts/alpha/combobox/Combobox.d.ts +73 -0
  3. package/dts/alpha/combobox/Combobox.d.ts.map +1 -0
  4. package/dts/alpha/combobox/DefaultComboboxControl.d.ts +20 -0
  5. package/dts/alpha/combobox/DefaultComboboxControl.d.ts.map +1 -0
  6. package/dts/alpha/select/DefaultSelectControl.d.ts +1 -0
  7. package/dts/alpha/select/DefaultSelectControl.d.ts.map +1 -1
  8. package/dts/alpha/select/DefaultSelectDropdown.d.ts.map +1 -1
  9. package/dts/alpha/select/types.d.ts +4 -1
  10. package/dts/alpha/select/types.d.ts.map +1 -1
  11. package/dts/alpha/select-chip/SelectChip.d.ts +12 -6
  12. package/dts/alpha/select-chip/SelectChip.d.ts.map +1 -1
  13. package/dts/alpha/select-chip/SelectChipControl.d.ts +1 -0
  14. package/dts/alpha/select-chip/SelectChipControl.d.ts.map +1 -1
  15. package/dts/alpha/tabbed-chips/TabbedChips.d.ts +5 -0
  16. package/dts/alpha/tabbed-chips/TabbedChips.d.ts.map +1 -1
  17. package/dts/chips/Chip.d.ts +1 -1
  18. package/dts/chips/Chip.d.ts.map +1 -1
  19. package/dts/chips/ChipProps.d.ts +1 -1
  20. package/dts/chips/ChipProps.d.ts.map +1 -1
  21. package/dts/chips/InputChip.d.ts +1 -1
  22. package/dts/chips/InputChip.d.ts.map +1 -1
  23. package/dts/chips/MediaChip.d.ts +1 -1
  24. package/dts/chips/MediaChip.d.ts.map +1 -1
  25. package/dts/hooks/useHorizontalScrollToTarget.d.ts +10 -0
  26. package/dts/hooks/useHorizontalScrollToTarget.d.ts.map +1 -1
  27. package/dts/overlays/drawer/Drawer.d.ts.map +1 -1
  28. package/dts/overlays/tray/Tray.d.ts +8 -0
  29. package/dts/overlays/tray/Tray.d.ts.map +1 -1
  30. package/esm/alpha/combobox/Combobox.js +194 -0
  31. package/esm/alpha/combobox/DefaultComboboxControl.js +80 -0
  32. package/esm/alpha/combobox/__stories__/Combobox.stories.js +1019 -0
  33. package/esm/alpha/select/DefaultSelectControl.js +25 -23
  34. package/esm/alpha/select/DefaultSelectDropdown.js +80 -75
  35. package/esm/alpha/select/__stories__/AlphaSelect.stories.js +24 -4
  36. package/esm/alpha/select-chip/SelectChip.js +8 -5
  37. package/esm/alpha/select-chip/SelectChipControl.js +6 -2
  38. package/esm/alpha/select-chip/__stories__/{SelectChip.stories.js → AlphaSelectChip.stories.js} +42 -0
  39. package/esm/alpha/tabbed-chips/TabbedChips.js +12 -5
  40. package/esm/alpha/tabbed-chips/__stories__/AlphaTabbedChips.stories.js +9 -1
  41. package/esm/buttons/__stories__/SlideButton.stories.js +11 -6
  42. package/esm/carousel/__stories__/Carousel.stories.js +5 -4
  43. package/esm/hooks/useHorizontalScrollToTarget.js +16 -5
  44. package/esm/overlays/drawer/Drawer.js +14 -3
  45. package/esm/overlays/tray/Tray.js +17 -5
  46. package/esm/visualizations/__stories__/ProgressCircle.stories.js +3 -3
  47. package/package.json +2 -2
@@ -0,0 +1,1019 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import { useRef, useState } from 'react';
3
+ import { useMultiSelect } from '@coinbase/cds-common/select/useMultiSelect';
4
+ import { Button } from '../../../buttons';
5
+ import { Example, ExampleScreen } from '../../../examples/ExampleScreen';
6
+ import { Icon } from '../../../icons/Icon';
7
+ import { VStack } from '../../../layout';
8
+ import { Text } from '../../../typography/Text';
9
+ import { Combobox } from '../Combobox';
10
+ import { DefaultComboboxControl } from '../DefaultComboboxControl';
11
+
12
+ // Basic option sets
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ const multiSelectOptions = [{
15
+ value: '1',
16
+ label: 'Option 1'
17
+ }, {
18
+ value: '2',
19
+ label: 'Option 2'
20
+ }, {
21
+ value: '3',
22
+ label: 'Option 3'
23
+ }, {
24
+ value: '4',
25
+ label: 'Option 4'
26
+ }, {
27
+ value: '5',
28
+ label: 'Option 5'
29
+ }, {
30
+ value: '6',
31
+ label: 'Option 6'
32
+ }, {
33
+ value: '7',
34
+ label: 'Option 7'
35
+ }, {
36
+ value: '8',
37
+ label: 'Option 8'
38
+ }, {
39
+ value: '9',
40
+ label: 'Option 9'
41
+ }, {
42
+ value: '10',
43
+ label: 'Option 10'
44
+ }, {
45
+ value: '11',
46
+ label: 'Option 11'
47
+ }, {
48
+ value: '12',
49
+ label: 'Option 12'
50
+ }, {
51
+ value: '13',
52
+ label: 'Option 13'
53
+ }, {
54
+ value: '14',
55
+ label: 'Option 14'
56
+ }, {
57
+ value: '15',
58
+ label: 'Option 15'
59
+ }, {
60
+ value: '16',
61
+ label: 'Option 16'
62
+ }, {
63
+ value: '17',
64
+ label: 'Option 17'
65
+ }, {
66
+ value: '18',
67
+ label: 'Option 18'
68
+ }, {
69
+ value: '19',
70
+ label: 'Option 19'
71
+ }, {
72
+ value: '20',
73
+ label: 'Option 20'
74
+ }];
75
+ const singleSelectOptions = [{
76
+ value: null,
77
+ label: 'Remove selection'
78
+ }, {
79
+ value: '1',
80
+ label: 'Option 1'
81
+ }, {
82
+ value: '2',
83
+ label: 'Option 2'
84
+ }, {
85
+ value: '3',
86
+ label: 'Option 3'
87
+ }];
88
+
89
+ // Rich option sets for various examples
90
+ const fruitOptions = [{
91
+ value: 'apple',
92
+ label: 'Apple'
93
+ }, {
94
+ value: 'banana',
95
+ label: 'Banana'
96
+ }, {
97
+ value: 'cherry',
98
+ label: 'Cherry'
99
+ }, {
100
+ value: 'date',
101
+ label: 'Date'
102
+ }, {
103
+ value: 'elderberry',
104
+ label: 'Elderberry'
105
+ }, {
106
+ value: 'fig',
107
+ label: 'Fig'
108
+ }, {
109
+ value: 'grape',
110
+ label: 'Grape'
111
+ }, {
112
+ value: 'honeydew',
113
+ label: 'Honeydew'
114
+ }, {
115
+ value: 'kiwi',
116
+ label: 'Kiwi'
117
+ }, {
118
+ value: 'lemon',
119
+ label: 'Lemon'
120
+ }];
121
+ const countryOptions = [{
122
+ value: 'us',
123
+ label: 'United States',
124
+ description: 'North America'
125
+ }, {
126
+ value: 'ca',
127
+ label: 'Canada',
128
+ description: 'North America'
129
+ }, {
130
+ value: 'mx',
131
+ label: 'Mexico',
132
+ description: 'North America'
133
+ }, {
134
+ value: 'uk',
135
+ label: 'United Kingdom',
136
+ description: 'Europe'
137
+ }, {
138
+ value: 'fr',
139
+ label: 'France',
140
+ description: 'Europe'
141
+ }, {
142
+ value: 'de',
143
+ label: 'Germany',
144
+ description: 'Europe'
145
+ }, {
146
+ value: 'jp',
147
+ label: 'Japan',
148
+ description: 'Asia'
149
+ }, {
150
+ value: 'cn',
151
+ label: 'China',
152
+ description: 'Asia'
153
+ }];
154
+ const cryptoOptions = [{
155
+ value: 'btc',
156
+ label: 'Bitcoin',
157
+ description: 'BTC • Digital Gold'
158
+ }, {
159
+ value: 'eth',
160
+ label: 'Ethereum',
161
+ description: 'ETH • Smart Contracts'
162
+ }, {
163
+ value: 'usdc',
164
+ label: 'USD Coin',
165
+ description: 'USDC • Stablecoin'
166
+ }, {
167
+ value: 'usdt',
168
+ label: 'Tether',
169
+ description: 'USDT • Stablecoin'
170
+ }, {
171
+ value: 'sol',
172
+ label: 'Solana',
173
+ description: 'SOL • High Performance'
174
+ }, {
175
+ value: 'ada',
176
+ label: 'Cardano',
177
+ description: 'ADA • Academic Approach'
178
+ }];
179
+ const teamOptions = [{
180
+ value: 'john',
181
+ label: 'John Smith',
182
+ description: 'Engineering'
183
+ }, {
184
+ value: 'jane',
185
+ label: 'Jane Doe',
186
+ description: 'Design'
187
+ }, {
188
+ value: 'bob',
189
+ label: 'Bob Johnson',
190
+ description: 'Product'
191
+ }, {
192
+ value: 'alice',
193
+ label: 'Alice Williams',
194
+ description: 'Engineering'
195
+ }, {
196
+ value: 'charlie',
197
+ label: 'Charlie Brown',
198
+ description: 'Marketing'
199
+ }];
200
+
201
+ // Example Components
202
+ const DefaultExample = () => {
203
+ const {
204
+ value,
205
+ onChange
206
+ } = useMultiSelect({
207
+ initialValue: ['1']
208
+ });
209
+ return /*#__PURE__*/_jsx(Combobox, {
210
+ label: "Multi Select",
211
+ onChange: onChange,
212
+ options: multiSelectOptions,
213
+ placeholder: "Search...",
214
+ type: "multi",
215
+ value: value
216
+ });
217
+ };
218
+ const SingleSelectExample = () => {
219
+ const [singleValue, setSingleValue] = useState(null);
220
+ return /*#__PURE__*/_jsx(Combobox, {
221
+ label: "Single Select",
222
+ onChange: setSingleValue,
223
+ options: singleSelectOptions,
224
+ placeholder: "Search...",
225
+ value: singleValue
226
+ });
227
+ };
228
+ const NoLabelExample = () => {
229
+ const {
230
+ value,
231
+ onChange
232
+ } = useMultiSelect({
233
+ initialValue: []
234
+ });
235
+ return /*#__PURE__*/_jsx(Combobox, {
236
+ onChange: onChange,
237
+ options: multiSelectOptions,
238
+ placeholder: "Search...",
239
+ type: "multi",
240
+ value: value
241
+ });
242
+ };
243
+ const InitialValuesExample = () => {
244
+ const {
245
+ value,
246
+ onChange
247
+ } = useMultiSelect({
248
+ initialValue: ['apple', 'banana', 'cherry']
249
+ });
250
+ return /*#__PURE__*/_jsx(Combobox, {
251
+ label: "Pre-selected fruits",
252
+ onChange: onChange,
253
+ options: fruitOptions,
254
+ placeholder: "Search fruits...",
255
+ type: "multi",
256
+ value: value
257
+ });
258
+ };
259
+ const ControlledSearchExample = () => {
260
+ const {
261
+ value,
262
+ onChange
263
+ } = useMultiSelect({
264
+ initialValue: []
265
+ });
266
+ const [searchText, setSearchText] = useState('');
267
+ return /*#__PURE__*/_jsxs(VStack, {
268
+ gap: 2,
269
+ children: [/*#__PURE__*/_jsxs(Text, {
270
+ color: "fgMuted",
271
+ children: ["Current search: \"", searchText, "\""]
272
+ }), /*#__PURE__*/_jsx(Combobox, {
273
+ label: "Controlled search",
274
+ onChange: onChange,
275
+ onSearch: setSearchText,
276
+ options: fruitOptions,
277
+ placeholder: "Type to search...",
278
+ searchText: searchText,
279
+ type: "multi",
280
+ value: value
281
+ }), /*#__PURE__*/_jsx(Button, {
282
+ compact: true,
283
+ onPress: () => setSearchText('apple'),
284
+ children: "Set search to \"apple\""
285
+ })]
286
+ });
287
+ };
288
+ const WithDescriptionsExample = () => {
289
+ const {
290
+ value,
291
+ onChange
292
+ } = useMultiSelect({
293
+ initialValue: []
294
+ });
295
+ return /*#__PURE__*/_jsx(Combobox, {
296
+ label: "Select countries",
297
+ onChange: onChange,
298
+ options: countryOptions,
299
+ placeholder: "Search countries...",
300
+ type: "multi",
301
+ value: value
302
+ });
303
+ };
304
+ const HideSearchInputExample = () => {
305
+ const {
306
+ value,
307
+ onChange
308
+ } = useMultiSelect({
309
+ initialValue: ['apple', 'banana', 'cherry']
310
+ });
311
+ return /*#__PURE__*/_jsx(Combobox, {
312
+ hideSearchInput: true,
313
+ label: "Hide search input",
314
+ onChange: onChange,
315
+ options: fruitOptions,
316
+ placeholder: "Search...",
317
+ type: "multi",
318
+ value: value
319
+ });
320
+ };
321
+ const CryptoAssetsExample = () => {
322
+ const {
323
+ value,
324
+ onChange
325
+ } = useMultiSelect({
326
+ initialValue: []
327
+ });
328
+ return /*#__PURE__*/_jsx(Combobox, {
329
+ label: "Select assets",
330
+ onChange: onChange,
331
+ options: cryptoOptions,
332
+ placeholder: "Search crypto...",
333
+ type: "multi",
334
+ value: value
335
+ });
336
+ };
337
+ const CustomFilterExample = () => {
338
+ const {
339
+ value,
340
+ onChange
341
+ } = useMultiSelect({
342
+ initialValue: []
343
+ });
344
+ const customFilterFunction = (options, searchText) => {
345
+ const search = searchText.toLowerCase();
346
+ return options.filter(option => {
347
+ const label = typeof option.label === 'string' ? option.label.toLowerCase() : '';
348
+ const description = typeof option.description === 'string' ? option.description.toLowerCase() : '';
349
+ return label.startsWith(search) || description.startsWith(search);
350
+ });
351
+ };
352
+ return /*#__PURE__*/_jsxs(VStack, {
353
+ gap: 2,
354
+ children: [/*#__PURE__*/_jsx(Text, {
355
+ color: "fgMuted",
356
+ fontSize: "caption",
357
+ children: "Only matches start of words"
358
+ }), /*#__PURE__*/_jsx(Combobox, {
359
+ filterFunction: customFilterFunction,
360
+ label: "Custom filter",
361
+ onChange: onChange,
362
+ options: cryptoOptions,
363
+ placeholder: "Type to filter...",
364
+ type: "multi",
365
+ value: value
366
+ })]
367
+ });
368
+ };
369
+ const DisabledExample = () => {
370
+ const {
371
+ value,
372
+ onChange
373
+ } = useMultiSelect({
374
+ initialValue: ['apple', 'banana']
375
+ });
376
+ return /*#__PURE__*/_jsx(Combobox, {
377
+ disabled: true,
378
+ label: "Disabled combobox",
379
+ onChange: onChange,
380
+ options: fruitOptions,
381
+ placeholder: "Cannot interact...",
382
+ type: "multi",
383
+ value: value
384
+ });
385
+ };
386
+ const CompactExample = () => {
387
+ const {
388
+ value,
389
+ onChange
390
+ } = useMultiSelect({
391
+ initialValue: []
392
+ });
393
+ return /*#__PURE__*/_jsx(Combobox, {
394
+ compact: true,
395
+ label: "Compact size",
396
+ onChange: onChange,
397
+ options: fruitOptions,
398
+ placeholder: "Compact combobox...",
399
+ type: "multi",
400
+ value: value
401
+ });
402
+ };
403
+ export const CompactSingleSelect = () => {
404
+ const [value, setValue] = useState(null);
405
+ return /*#__PURE__*/_jsx(VStack, {
406
+ gap: 4,
407
+ children: /*#__PURE__*/_jsx(Combobox, {
408
+ compact: true,
409
+ label: "Compact size",
410
+ onChange: setValue,
411
+ options: singleSelectOptions,
412
+ placeholder: "Compact combobox...",
413
+ type: "single",
414
+ value: value
415
+ })
416
+ });
417
+ };
418
+ const RegularSizeExample = () => {
419
+ const {
420
+ value,
421
+ onChange
422
+ } = useMultiSelect({
423
+ initialValue: []
424
+ });
425
+ return /*#__PURE__*/_jsx(Combobox, {
426
+ label: "Regular size",
427
+ onChange: onChange,
428
+ options: fruitOptions,
429
+ placeholder: "Regular combobox...",
430
+ type: "multi",
431
+ value: value
432
+ });
433
+ };
434
+ const HelperTextExample = () => {
435
+ const {
436
+ value,
437
+ onChange
438
+ } = useMultiSelect({
439
+ initialValue: []
440
+ });
441
+ return /*#__PURE__*/_jsx(Combobox, {
442
+ helperText: "Select up to 5 team members for this project",
443
+ label: "Team members",
444
+ onChange: onChange,
445
+ options: teamOptions,
446
+ placeholder: "Search team members...",
447
+ type: "multi",
448
+ value: value
449
+ });
450
+ };
451
+ const DefaultVariantExample = () => {
452
+ const {
453
+ value,
454
+ onChange
455
+ } = useMultiSelect({
456
+ initialValue: []
457
+ });
458
+ return /*#__PURE__*/_jsx(Combobox, {
459
+ label: "Default",
460
+ onChange: onChange,
461
+ options: fruitOptions,
462
+ placeholder: "Default style...",
463
+ type: "multi",
464
+ value: value
465
+ });
466
+ };
467
+ const PositiveVariantExample = () => {
468
+ const {
469
+ value,
470
+ onChange
471
+ } = useMultiSelect({
472
+ initialValue: []
473
+ });
474
+ return /*#__PURE__*/_jsx(Combobox, {
475
+ label: "Positive",
476
+ onChange: onChange,
477
+ options: fruitOptions,
478
+ placeholder: "Success style...",
479
+ type: "multi",
480
+ value: value,
481
+ variant: "positive"
482
+ });
483
+ };
484
+ const NegativeVariantExample = () => {
485
+ const {
486
+ value,
487
+ onChange
488
+ } = useMultiSelect({
489
+ initialValue: []
490
+ });
491
+ return /*#__PURE__*/_jsx(Combobox, {
492
+ label: "Negative",
493
+ onChange: onChange,
494
+ options: fruitOptions,
495
+ placeholder: "Error style...",
496
+ type: "multi",
497
+ value: value,
498
+ variant: "negative"
499
+ });
500
+ };
501
+ const PrimaryVariantExample = () => {
502
+ const {
503
+ value,
504
+ onChange
505
+ } = useMultiSelect({
506
+ initialValue: []
507
+ });
508
+ return /*#__PURE__*/_jsx(Combobox, {
509
+ label: "Primary",
510
+ onChange: onChange,
511
+ options: fruitOptions,
512
+ placeholder: "Primary style...",
513
+ type: "multi",
514
+ value: value,
515
+ variant: "primary"
516
+ });
517
+ };
518
+ const WithStartIconExample = () => {
519
+ const {
520
+ value,
521
+ onChange
522
+ } = useMultiSelect({
523
+ initialValue: []
524
+ });
525
+ return /*#__PURE__*/_jsx(Combobox, {
526
+ label: "With icon",
527
+ onChange: onChange,
528
+ options: cryptoOptions,
529
+ placeholder: "Search crypto...",
530
+ startNode: /*#__PURE__*/_jsx(Icon, {
531
+ name: "search",
532
+ size: "s"
533
+ }),
534
+ type: "multi",
535
+ value: value
536
+ });
537
+ };
538
+ const WithEndIconExample = () => {
539
+ const {
540
+ value,
541
+ onChange
542
+ } = useMultiSelect({
543
+ initialValue: []
544
+ });
545
+ return /*#__PURE__*/_jsx(Combobox, {
546
+ endNode: /*#__PURE__*/_jsx(Icon, {
547
+ name: "filter",
548
+ size: "s"
549
+ }),
550
+ label: "Custom end icon",
551
+ onChange: onChange,
552
+ options: fruitOptions,
553
+ placeholder: "Custom icon...",
554
+ type: "multi",
555
+ value: value
556
+ });
557
+ };
558
+ const MaxSelectedDisplayExample = () => {
559
+ const {
560
+ value,
561
+ onChange
562
+ } = useMultiSelect({
563
+ initialValue: ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape']
564
+ });
565
+ return /*#__PURE__*/_jsx(Combobox, {
566
+ label: "Limited display",
567
+ maxSelectedOptionsToShow: 3,
568
+ onChange: onChange,
569
+ options: fruitOptions,
570
+ placeholder: "Shows max 3 selections...",
571
+ type: "multi",
572
+ value: value
573
+ });
574
+ };
575
+ const HiddenOptionsLabelExample = () => {
576
+ const {
577
+ value,
578
+ onChange
579
+ } = useMultiSelect({
580
+ initialValue: ['us', 'ca', 'mx', 'uk', 'fr', 'de']
581
+ });
582
+ return /*#__PURE__*/_jsx(Combobox, {
583
+ hiddenSelectedOptionsLabel: "countries",
584
+ label: "Countries",
585
+ maxSelectedOptionsToShow: 3,
586
+ onChange: onChange,
587
+ options: countryOptions,
588
+ placeholder: "Select countries...",
589
+ type: "multi",
590
+ value: value
591
+ });
592
+ };
593
+ const SelectAllExample = () => {
594
+ const {
595
+ value,
596
+ onChange
597
+ } = useMultiSelect({
598
+ initialValue: []
599
+ });
600
+ return /*#__PURE__*/_jsx(Combobox, {
601
+ label: "With select all",
602
+ onChange: onChange,
603
+ options: fruitOptions,
604
+ placeholder: "Can select all...",
605
+ selectAllLabel: "Select all fruits",
606
+ type: "multi",
607
+ value: value
608
+ });
609
+ };
610
+ const ClearAllExample = () => {
611
+ const {
612
+ value,
613
+ onChange
614
+ } = useMultiSelect({
615
+ initialValue: ['apple', 'banana', 'cherry']
616
+ });
617
+ return /*#__PURE__*/_jsx(Combobox, {
618
+ clearAllLabel: "Clear selection",
619
+ label: "With clear all",
620
+ onChange: onChange,
621
+ options: fruitOptions,
622
+ placeholder: "Can clear all...",
623
+ type: "multi",
624
+ value: value
625
+ });
626
+ };
627
+ const EmptyOptionsExample = () => {
628
+ const {
629
+ value,
630
+ onChange
631
+ } = useMultiSelect({
632
+ initialValue: []
633
+ });
634
+ return /*#__PURE__*/_jsx(Combobox, {
635
+ emptyOptionsLabel: "No matching fruits found",
636
+ label: "Empty state",
637
+ onChange: onChange,
638
+ options: [],
639
+ placeholder: "No options available...",
640
+ type: "multi",
641
+ value: value
642
+ });
643
+ };
644
+ const DisabledOptionsExample = () => {
645
+ const {
646
+ value,
647
+ onChange
648
+ } = useMultiSelect({
649
+ initialValue: []
650
+ });
651
+ const mixedOptions = fruitOptions.map((option, index) => _extends({}, option, {
652
+ disabled: index % 3 === 0
653
+ }));
654
+ return /*#__PURE__*/_jsx(Combobox, {
655
+ label: "Mixed enabled/disabled",
656
+ onChange: onChange,
657
+ options: mixedOptions,
658
+ placeholder: "Some options disabled...",
659
+ type: "multi",
660
+ value: value
661
+ });
662
+ };
663
+ const LongListExample = () => {
664
+ const {
665
+ value,
666
+ onChange
667
+ } = useMultiSelect({
668
+ initialValue: []
669
+ });
670
+ const longOptions = Array.from({
671
+ length: 50
672
+ }, (_, i) => ({
673
+ value: "option" + i,
674
+ label: "Option " + (i + 1),
675
+ description: "Description for option " + (i + 1)
676
+ }));
677
+ return /*#__PURE__*/_jsx(Combobox, {
678
+ label: "Many options",
679
+ onChange: onChange,
680
+ options: longOptions,
681
+ placeholder: "Search from 50 options...",
682
+ type: "multi",
683
+ value: value
684
+ });
685
+ };
686
+ const ValueMonitoringExample = () => {
687
+ const {
688
+ value,
689
+ onChange
690
+ } = useMultiSelect({
691
+ initialValue: []
692
+ });
693
+ return /*#__PURE__*/_jsxs(VStack, {
694
+ gap: 3,
695
+ children: [/*#__PURE__*/_jsx(Combobox, {
696
+ label: "Monitor selections",
697
+ onChange: onChange,
698
+ options: fruitOptions,
699
+ placeholder: "Select to see values...",
700
+ type: "multi",
701
+ value: value
702
+ }), /*#__PURE__*/_jsxs(VStack, {
703
+ background: "bgSecondary",
704
+ borderRadius: 400,
705
+ gap: 2,
706
+ padding: 3,
707
+ children: [/*#__PURE__*/_jsx(Text, {
708
+ fontSize: "label1",
709
+ fontWeight: "label1",
710
+ children: "Selected values:"
711
+ }), /*#__PURE__*/_jsx(Text, {
712
+ color: "fgMuted",
713
+ fontSize: "caption",
714
+ children: value.length > 0 ? value.join(', ') : 'None selected'
715
+ })]
716
+ })]
717
+ });
718
+ };
719
+ const MultipleInstancesExample = () => {
720
+ const fruits = useMultiSelect({
721
+ initialValue: []
722
+ });
723
+ const countries = useMultiSelect({
724
+ initialValue: []
725
+ });
726
+ const crypto = useMultiSelect({
727
+ initialValue: []
728
+ });
729
+ return /*#__PURE__*/_jsxs(VStack, {
730
+ gap: 3,
731
+ children: [/*#__PURE__*/_jsx(Combobox, {
732
+ label: "Fruits",
733
+ onChange: fruits.onChange,
734
+ options: fruitOptions,
735
+ placeholder: "Select fruits...",
736
+ type: "multi",
737
+ value: fruits.value
738
+ }), /*#__PURE__*/_jsx(Combobox, {
739
+ label: "Countries",
740
+ onChange: countries.onChange,
741
+ options: countryOptions,
742
+ placeholder: "Select countries...",
743
+ type: "multi",
744
+ value: countries.value
745
+ }), /*#__PURE__*/_jsx(Combobox, {
746
+ label: "Cryptocurrencies",
747
+ onChange: crypto.onChange,
748
+ options: cryptoOptions,
749
+ placeholder: "Select crypto...",
750
+ type: "multi",
751
+ value: crypto.value
752
+ })]
753
+ });
754
+ };
755
+ const ImperativeRefExample = () => {
756
+ var _comboboxRef$current3;
757
+ const comboboxRef = useRef(null);
758
+ const {
759
+ value,
760
+ onChange
761
+ } = useMultiSelect({
762
+ initialValue: []
763
+ });
764
+ return /*#__PURE__*/_jsxs(VStack, {
765
+ gap: 3,
766
+ children: [/*#__PURE__*/_jsx(Button, {
767
+ compact: true,
768
+ onPress: () => {
769
+ var _comboboxRef$current;
770
+ return (_comboboxRef$current = comboboxRef.current) == null || _comboboxRef$current.setOpen == null ? void 0 : _comboboxRef$current.setOpen(true);
771
+ },
772
+ children: "Open"
773
+ }), /*#__PURE__*/_jsx(Button, {
774
+ compact: true,
775
+ onPress: () => {
776
+ var _comboboxRef$current2;
777
+ return (_comboboxRef$current2 = comboboxRef.current) == null || _comboboxRef$current2.setOpen == null ? void 0 : _comboboxRef$current2.setOpen(false);
778
+ },
779
+ children: "Close"
780
+ }), /*#__PURE__*/_jsx(Text, {
781
+ color: "fg",
782
+ children: (_comboboxRef$current3 = comboboxRef.current) != null && _comboboxRef$current3.open ? 'Open' : 'Closed'
783
+ }), /*#__PURE__*/_jsx(Combobox, {
784
+ ref: comboboxRef,
785
+ label: "Imperative ref",
786
+ onChange: onChange,
787
+ options: fruitOptions,
788
+ placeholder: "Select fruits...",
789
+ type: "multi",
790
+ value: value
791
+ })]
792
+ });
793
+ };
794
+ const OptionsWithAccessoryExample = () => {
795
+ const {
796
+ value,
797
+ onChange
798
+ } = useMultiSelect({
799
+ initialValue: []
800
+ });
801
+ const optionsWithAccessory = fruitOptions.slice(0, 5).map(option => _extends({}, option, {
802
+ accessory: /*#__PURE__*/_jsx(Icon, {
803
+ color: "fg",
804
+ name: "star"
805
+ })
806
+ }));
807
+ return /*#__PURE__*/_jsx(Combobox, {
808
+ label: "Options with accessory",
809
+ onChange: onChange,
810
+ options: optionsWithAccessory,
811
+ placeholder: "Select fruits...",
812
+ type: "multi",
813
+ value: value
814
+ });
815
+ };
816
+ const OptionsWithMediaExample = () => {
817
+ const {
818
+ value,
819
+ onChange
820
+ } = useMultiSelect({
821
+ initialValue: []
822
+ });
823
+ const optionsWithMedia = fruitOptions.slice(0, 5).map(option => _extends({}, option, {
824
+ media: /*#__PURE__*/_jsx(Icon, {
825
+ color: "fg",
826
+ name: "star"
827
+ })
828
+ }));
829
+ return /*#__PURE__*/_jsx(Combobox, {
830
+ label: "Options with media",
831
+ onChange: onChange,
832
+ options: optionsWithMedia,
833
+ placeholder: "Select fruits...",
834
+ type: "multi",
835
+ value: value
836
+ });
837
+ };
838
+ const DynamicOptionsExample = () => {
839
+ const {
840
+ value,
841
+ onChange
842
+ } = useMultiSelect({
843
+ initialValue: []
844
+ });
845
+ const [options, setOptions] = useState(fruitOptions.slice(0, 5));
846
+ const addOption = () => {
847
+ const remaining = fruitOptions.filter(fruit => !options.some(opt => opt.value === fruit.value));
848
+ if (remaining.length > 0) {
849
+ setOptions([...options, remaining[0]]);
850
+ }
851
+ };
852
+ return /*#__PURE__*/_jsxs(VStack, {
853
+ gap: 3,
854
+ children: [/*#__PURE__*/_jsx(Combobox, {
855
+ label: "Dynamic options",
856
+ onChange: onChange,
857
+ options: options,
858
+ placeholder: "Options can change...",
859
+ type: "multi",
860
+ value: value
861
+ }), /*#__PURE__*/_jsx(Button, {
862
+ compact: true,
863
+ onPress: addOption,
864
+ children: "Add more options"
865
+ })]
866
+ });
867
+ };
868
+ const CustomComponent = props => {
869
+ var _props$value$length, _props$value;
870
+ return /*#__PURE__*/_jsx(DefaultComboboxControl, _extends({}, props, {
871
+ searchText: "" + ((_props$value$length = (_props$value = props.value) == null ? void 0 : _props$value.length) != null ? _props$value$length : 0)
872
+ }));
873
+ };
874
+ const CustomControlExample = () => {
875
+ const {
876
+ value,
877
+ onChange
878
+ } = useMultiSelect({
879
+ initialValue: []
880
+ });
881
+ return /*#__PURE__*/_jsx(Combobox, {
882
+ ComboboxControlComponent: CustomComponent,
883
+ label: "Custom control - search field always shows the number of selected options",
884
+ onChange: onChange,
885
+ options: fruitOptions,
886
+ type: "multi",
887
+ value: value
888
+ });
889
+ };
890
+ const TestIdentifierExample = () => {
891
+ const {
892
+ value,
893
+ onChange
894
+ } = useMultiSelect({
895
+ initialValue: []
896
+ });
897
+ return /*#__PURE__*/_jsx(Combobox, {
898
+ label: "With test ID",
899
+ onChange: onChange,
900
+ options: fruitOptions,
901
+ placeholder: "Has test ID...",
902
+ testID: "fruit-combobox",
903
+ type: "multi",
904
+ value: value
905
+ });
906
+ };
907
+
908
+ // Main component with all examples
909
+ const Default = () => {
910
+ return /*#__PURE__*/_jsxs(ExampleScreen, {
911
+ children: [/*#__PURE__*/_jsx(Example, {
912
+ title: "Default",
913
+ children: /*#__PURE__*/_jsx(DefaultExample, {})
914
+ }), /*#__PURE__*/_jsx(Example, {
915
+ title: "Single Select",
916
+ children: /*#__PURE__*/_jsx(SingleSelectExample, {})
917
+ }), /*#__PURE__*/_jsx(Example, {
918
+ title: "No Label",
919
+ children: /*#__PURE__*/_jsx(NoLabelExample, {})
920
+ }), /*#__PURE__*/_jsx(Example, {
921
+ title: "Pre-selected values",
922
+ children: /*#__PURE__*/_jsx(InitialValuesExample, {})
923
+ }), /*#__PURE__*/_jsx(Example, {
924
+ title: "Controlled search",
925
+ children: /*#__PURE__*/_jsx(ControlledSearchExample, {})
926
+ }), /*#__PURE__*/_jsx(Example, {
927
+ title: "Options with descriptions",
928
+ children: /*#__PURE__*/_jsx(WithDescriptionsExample, {})
929
+ }), /*#__PURE__*/_jsx(Example, {
930
+ title: "Hide search input",
931
+ children: /*#__PURE__*/_jsx(HideSearchInputExample, {})
932
+ }), /*#__PURE__*/_jsx(Example, {
933
+ title: "Crypto assets",
934
+ children: /*#__PURE__*/_jsx(CryptoAssetsExample, {})
935
+ }), /*#__PURE__*/_jsx(Example, {
936
+ title: "Custom filter logic",
937
+ children: /*#__PURE__*/_jsx(CustomFilterExample, {})
938
+ }), /*#__PURE__*/_jsx(Example, {
939
+ title: "Disabled state",
940
+ children: /*#__PURE__*/_jsx(DisabledExample, {})
941
+ }), /*#__PURE__*/_jsx(Example, {
942
+ title: "Compact size",
943
+ children: /*#__PURE__*/_jsx(CompactExample, {})
944
+ }), /*#__PURE__*/_jsx(Example, {
945
+ title: "Compact single select",
946
+ children: /*#__PURE__*/_jsx(CompactSingleSelect, {})
947
+ }), /*#__PURE__*/_jsx(Example, {
948
+ title: "Regular size (for comparison)",
949
+ children: /*#__PURE__*/_jsx(RegularSizeExample, {})
950
+ }), /*#__PURE__*/_jsx(Example, {
951
+ title: "With helper text",
952
+ children: /*#__PURE__*/_jsx(HelperTextExample, {})
953
+ }), /*#__PURE__*/_jsx(Example, {
954
+ title: "Default variant",
955
+ children: /*#__PURE__*/_jsx(DefaultVariantExample, {})
956
+ }), /*#__PURE__*/_jsx(Example, {
957
+ title: "Positive variant",
958
+ children: /*#__PURE__*/_jsx(PositiveVariantExample, {})
959
+ }), /*#__PURE__*/_jsx(Example, {
960
+ title: "Negative variant",
961
+ children: /*#__PURE__*/_jsx(NegativeVariantExample, {})
962
+ }), /*#__PURE__*/_jsx(Example, {
963
+ title: "Primary variant",
964
+ children: /*#__PURE__*/_jsx(PrimaryVariantExample, {})
965
+ }), /*#__PURE__*/_jsx(Example, {
966
+ title: "With start icon",
967
+ children: /*#__PURE__*/_jsx(WithStartIconExample, {})
968
+ }), /*#__PURE__*/_jsx(Example, {
969
+ title: "With end icon",
970
+ children: /*#__PURE__*/_jsx(WithEndIconExample, {})
971
+ }), /*#__PURE__*/_jsx(Example, {
972
+ title: "Limited display (max 3)",
973
+ children: /*#__PURE__*/_jsx(MaxSelectedDisplayExample, {})
974
+ }), /*#__PURE__*/_jsx(Example, {
975
+ title: "Custom hidden label",
976
+ children: /*#__PURE__*/_jsx(HiddenOptionsLabelExample, {})
977
+ }), /*#__PURE__*/_jsx(Example, {
978
+ title: "With select all option",
979
+ children: /*#__PURE__*/_jsx(SelectAllExample, {})
980
+ }), /*#__PURE__*/_jsx(Example, {
981
+ title: "With clear all option",
982
+ children: /*#__PURE__*/_jsx(ClearAllExample, {})
983
+ }), /*#__PURE__*/_jsx(Example, {
984
+ title: "No options available",
985
+ children: /*#__PURE__*/_jsx(EmptyOptionsExample, {})
986
+ }), /*#__PURE__*/_jsx(Example, {
987
+ title: "Some disabled options",
988
+ children: /*#__PURE__*/_jsx(DisabledOptionsExample, {})
989
+ }), /*#__PURE__*/_jsx(Example, {
990
+ title: "Large dataset",
991
+ children: /*#__PURE__*/_jsx(LongListExample, {})
992
+ }), /*#__PURE__*/_jsx(Example, {
993
+ title: "Monitor selections",
994
+ children: /*#__PURE__*/_jsx(ValueMonitoringExample, {})
995
+ }), /*#__PURE__*/_jsx(Example, {
996
+ title: "Multiple comboboxes",
997
+ children: /*#__PURE__*/_jsx(MultipleInstancesExample, {})
998
+ }), /*#__PURE__*/_jsx(Example, {
999
+ title: "Imperative ref",
1000
+ children: /*#__PURE__*/_jsx(ImperativeRefExample, {})
1001
+ }), /*#__PURE__*/_jsx(Example, {
1002
+ title: "Options with accessory",
1003
+ children: /*#__PURE__*/_jsx(OptionsWithAccessoryExample, {})
1004
+ }), /*#__PURE__*/_jsx(Example, {
1005
+ title: "Options with media",
1006
+ children: /*#__PURE__*/_jsx(OptionsWithMediaExample, {})
1007
+ }), /*#__PURE__*/_jsx(Example, {
1008
+ title: "Dynamic options",
1009
+ children: /*#__PURE__*/_jsx(DynamicOptionsExample, {})
1010
+ }), /*#__PURE__*/_jsx(Example, {
1011
+ title: "Custom control",
1012
+ children: /*#__PURE__*/_jsx(CustomControlExample, {})
1013
+ }), /*#__PURE__*/_jsx(Example, {
1014
+ title: "With test ID",
1015
+ children: /*#__PURE__*/_jsx(TestIdentifierExample, {})
1016
+ })]
1017
+ });
1018
+ };
1019
+ export default Default;