@iress-oss/ids-mcp-server 6.0.0-alpha.1-canary-20251204033039-51f1bf8 → 6.0.0-alpha.2

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 (99) hide show
  1. package/generated/docs/components_components-alert-docs.md +1054 -0
  2. package/generated/docs/components_components-autocomplete-docs.md +3304 -0
  3. package/generated/docs/components_components-autocomplete-recipes-docs.md +98 -0
  4. package/generated/docs/components_components-badge-docs.md +312 -0
  5. package/generated/docs/components_components-button-docs.md +2339 -0
  6. package/generated/docs/components_components-buttongroup-docs.md +980 -0
  7. package/generated/docs/components_components-card-docs.md +1970 -0
  8. package/generated/docs/components_components-checkbox-docs.md +1083 -0
  9. package/generated/docs/components_components-checkboxgroup-docs.md +1597 -0
  10. package/generated/docs/components_components-checkboxgroup-recipes-docs.md +209 -0
  11. package/generated/docs/components_components-col-docs.md +755 -0
  12. package/generated/docs/components_components-container-docs.md +172 -0
  13. package/generated/docs/components_components-divider-docs.md +235 -0
  14. package/generated/docs/components_components-expander-docs.md +428 -0
  15. package/generated/docs/components_components-field-docs.md +3345 -0
  16. package/generated/docs/components_components-filter-docs.md +4091 -0
  17. package/generated/docs/components_components-hide-docs.md +450 -0
  18. package/generated/docs/components_components-icon-docs.md +1017 -0
  19. package/generated/docs/components_components-image-docs.md +168 -0
  20. package/generated/docs/components_components-inline-docs.md +1962 -0
  21. package/generated/docs/components_components-input-docs.md +1388 -0
  22. package/generated/docs/components_components-input-recipes-docs.md +349 -0
  23. package/generated/docs/components_components-inputcurrency-docs.md +636 -0
  24. package/generated/docs/components_components-inputcurrency-recipes-docs.md +208 -0
  25. package/generated/docs/components_components-introduction-docs.md +448 -0
  26. package/generated/docs/components_components-label-docs.md +229 -0
  27. package/generated/docs/components_components-link-docs.md +454 -0
  28. package/generated/docs/components_components-menu-docs.md +2219 -0
  29. package/generated/docs/components_components-menu-menuitem-docs.md +1455 -0
  30. package/generated/docs/components_components-modal-docs.md +2002 -0
  31. package/generated/docs/components_components-panel-docs.md +342 -0
  32. package/generated/docs/components_components-placeholder-docs.md +98 -0
  33. package/generated/docs/components_components-popover-docs.md +1631 -0
  34. package/generated/docs/components_components-popover-recipes-docs.md +537 -0
  35. package/generated/docs/components_components-progress-docs.md +128 -0
  36. package/generated/docs/components_components-provider-docs.md +123 -0
  37. package/generated/docs/components_components-radio-docs.md +499 -0
  38. package/generated/docs/components_components-radiogroup-docs.md +1573 -0
  39. package/generated/docs/components_components-readonly-docs.md +277 -0
  40. package/generated/docs/components_components-richselect-docs.md +6101 -0
  41. package/generated/docs/components_components-row-docs.md +2172 -0
  42. package/generated/docs/components_components-select-docs.md +1110 -0
  43. package/generated/docs/components_components-skeleton-docs.md +467 -0
  44. package/generated/docs/components_components-skeleton-recipes-docs.md +110 -0
  45. package/generated/docs/components_components-skiplink-docs.md +220 -0
  46. package/generated/docs/components_components-slideout-docs.md +1910 -0
  47. package/generated/docs/components_components-slider-docs.md +1284 -0
  48. package/generated/docs/components_components-spinner-docs.md +90 -0
  49. package/generated/docs/components_components-stack-docs.md +730 -0
  50. package/generated/docs/components_components-table-docs.md +4038 -0
  51. package/generated/docs/components_components-tabset-docs.md +955 -0
  52. package/generated/docs/components_components-tabset-tab-docs.md +342 -0
  53. package/generated/docs/components_components-tag-docs.md +410 -0
  54. package/generated/docs/components_components-text-docs.md +593 -0
  55. package/generated/docs/components_components-toaster-docs.md +451 -0
  56. package/generated/docs/components_components-toggle-docs.md +513 -0
  57. package/generated/docs/components_components-tooltip-docs.md +564 -0
  58. package/generated/docs/components_components-validationmessage-docs.md +608 -0
  59. package/generated/docs/components_contact-us-docs.md +9 -0
  60. package/generated/docs/components_foundations-accessibility-docs.md +33 -0
  61. package/generated/docs/components_foundations-consistency-docs.md +44 -0
  62. package/generated/docs/components_foundations-content-docs.md +18 -0
  63. package/generated/docs/components_foundations-introduction-docs.md +17 -0
  64. package/generated/docs/components_foundations-principles-docs.md +60 -0
  65. package/generated/docs/components_foundations-responsive-layout-docs.md +2692 -0
  66. package/generated/docs/components_foundations-user-experience-docs.md +53 -0
  67. package/generated/docs/components_foundations-visual-design-docs.md +39 -0
  68. package/generated/docs/components_foundations-z-index-stacking-docs.md +288 -0
  69. package/generated/docs/components_frequently-asked-questions-docs.md +44 -0
  70. package/generated/docs/components_get-started-develop-docs.md +47 -0
  71. package/generated/docs/components_get-started-using-storybook-docs.md +55 -0
  72. package/generated/docs/components_introduction-docs.md +85 -0
  73. package/generated/docs/components_patterns-form-docs.md +2454 -0
  74. package/generated/docs/components_patterns-form-recipes-docs.md +1597 -0
  75. package/generated/docs/components_patterns-introduction-docs.md +31 -0
  76. package/generated/docs/components_patterns-loading-docs.md +1908 -0
  77. package/generated/docs/components_patterns-shadow-docs.md +195 -0
  78. package/generated/docs/components_resources-code-katas-docs.md +25 -0
  79. package/generated/docs/components_resources-introduction-docs.md +28 -0
  80. package/generated/docs/components_resources-mcp-server-docs.md +23 -0
  81. package/generated/docs/components_resources-migration-guides-from-v4-to-v5-docs.md +250 -0
  82. package/generated/docs/components_styling-props-colour-docs.md +91 -0
  83. package/generated/docs/components_styling-props-elevation-docs.md +69 -0
  84. package/generated/docs/components_styling-props-radius-docs.md +63 -0
  85. package/generated/docs/components_styling-props-reference-docs.md +160 -0
  86. package/generated/docs/components_styling-props-screen-readers-docs.md +66 -0
  87. package/generated/docs/components_styling-props-sizing-docs.md +217 -0
  88. package/generated/docs/components_styling-props-spacing-docs.md +545 -0
  89. package/generated/docs/components_styling-props-typography-docs.md +66 -0
  90. package/generated/docs/components_versions-docs.md +14 -0
  91. package/generated/docs/guidelines.md +3083 -0
  92. package/generated/docs/introduction-docs.md +37 -0
  93. package/generated/docs/tokens_colour-docs.md +479 -0
  94. package/generated/docs/tokens_elevation-docs.md +39 -0
  95. package/generated/docs/tokens_introduction-docs.md +150 -0
  96. package/generated/docs/tokens_radius-docs.md +67 -0
  97. package/generated/docs/tokens_spacing-docs.md +87 -0
  98. package/generated/docs/tokens_typography-docs.md +305 -0
  99. package/package.json +3 -4
@@ -0,0 +1,3304 @@
1
+ Autocomplete
2
+ ============
3
+
4
+ Overview
5
+ --------
6
+
7
+ Autocomplete allow for users to fill in their input by providing suggestions as they type.
8
+
9
+ [](./iframe.html?id=components-autocomplete--default)
10
+
11
+ ```
12
+
13
+ <IressAutocomplete
14
+ options\={\[
15
+ {
16
+ label: 'Option 1'
17
+ },
18
+ {
19
+ label: 'Option 2'
20
+ },
21
+ {
22
+ label: 'Option 3'
23
+ },
24
+ {
25
+ label: 'Option 4'
26
+ },
27
+ {
28
+ label: 'Option 5'
29
+ }
30
+ \]}
31
+ popoverProps\={{
32
+ container: {}
33
+ }}
34
+ />
35
+
36
+ ```
37
+
38
+ Props
39
+ -----
40
+
41
+ | Name | Description | Default | Control |
42
+ | --- | --- | --- | --- |
43
+ | alwaysShowOnFocus |
44
+ Always shown on focus, even if the user has not interacted with the input.
45
+
46
+ boolean
47
+
48
+
49
+
50
+ | \- | Set boolean |
51
+ | append |
52
+
53
+ Append content.
54
+
55
+ ReactNode
56
+
57
+
58
+
59
+ |
60
+
61
+ <IressIcon />
62
+
63
+
64
+
65
+ | Set object |
66
+ | autoComplete |
67
+
68
+ |
69
+
70
+ 'off'
71
+
72
+ | Set object |
73
+ | autoSelect |
74
+
75
+ If true, the selected option becomes the value of the input when the autocomplete loses focus.
76
+
77
+ boolean
78
+
79
+
80
+
81
+ |
82
+
83
+ true
84
+
85
+ | Set boolean |
86
+ | clearable |
87
+
88
+ If `true`, then user can clear the value of the input.
89
+
90
+ boolean
91
+
92
+
93
+
94
+ |
95
+
96
+ true
97
+
98
+ | Set boolean |
99
+ | errorText |
100
+
101
+ Text to be displayed when the options function errors out. It is not used when the options are provided as an array.
102
+
103
+ ReactNode
104
+
105
+
106
+
107
+ |
108
+
109
+ <IressAlert />
110
+
111
+
112
+
113
+ | Set object |
114
+ | limitDesktop |
115
+
116
+ |
117
+
118
+ 12
119
+
120
+ | Set object |
121
+ | limitMobile |
122
+
123
+ |
124
+
125
+ 6
126
+
127
+ | Set object |
128
+ | noResultsText |
129
+
130
+ Text to be displayed when no results are found.
131
+
132
+ ReactNode
133
+
134
+
135
+
136
+ | \- | Set object |
137
+ | onChange |
138
+
139
+ Emitted when the user changes the input. The second and third arguments are only available when the options were selected from the `options` prop.
140
+
141
+ ( e?: SyntheticEvent<InputBaseElement>, value?: T, option?: LabelValueMeta, ) => void
142
+
143
+ | \- | \- |
144
+ | options |
145
+
146
+ array
147
+
148
+
149
+
150
+ | \- |
151
+
152
+ RAW
153
+
154
+ * options :
155
+
156
+ \[
157
+
158
+ * 0 :
159
+
160
+ {...} 1 key
161
+
162
+ * 1 :
163
+
164
+ {...} 1 key
165
+
166
+ * 2 :
167
+
168
+ {...} 1 key
169
+
170
+ * 3 :
171
+
172
+ {...} 1 key
173
+
174
+ * 4 :
175
+
176
+ {...} 1 key
177
+
178
+
179
+ \]
180
+
181
+
182
+
183
+
184
+ |
185
+ | popoverProps |
186
+
187
+ Customise the IressInputPopover props for your needs.
188
+
189
+ AutocompletePopoverProps
190
+
191
+
192
+
193
+ | { } |
194
+
195
+ RAW
196
+
197
+ popoverProps :
198
+
199
+ {
200
+
201
+ }
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+ |
210
+
211
+ Usage
212
+ -----
213
+
214
+ The `IressAutocomplete` element extends `IressInput` with additional functionality to provide suggestions to the user as they type.
215
+
216
+ There is no validation done between the suggestions and the input value. They are strictly suggestions to improve the user experience. If you would like to restrict the input to the suggestions, you can use `IressCombobox`.
217
+
218
+ ### Uncontrolled
219
+
220
+ The `defaultValue` prop can be used to set the initial value of the input. The value will be managed by the component.
221
+
222
+ [](./iframe.html?id=components-autocomplete--uncontrolled)
223
+
224
+ ```
225
+
226
+ <IressAutocomplete
227
+ defaultValue\="Option 1"
228
+ options\={\[
229
+ {
230
+ label: 'Option 1'
231
+ },
232
+ {
233
+ label: 'Option 2'
234
+ },
235
+ {
236
+ label: 'Option 3'
237
+ },
238
+ {
239
+ label: 'Option 4'
240
+ },
241
+ {
242
+ label: 'Option 5'
243
+ }
244
+ \]}
245
+ popoverProps\={{
246
+ container: {}
247
+ }}
248
+ />
249
+
250
+ ```
251
+
252
+ #### Props
253
+
254
+ | Name | Description | Default | Control |
255
+ | --- | --- | --- | --- |
256
+ | alwaysShowOnFocus |
257
+ Always shown on focus, even if the user has not interacted with the input.
258
+
259
+ boolean
260
+
261
+
262
+
263
+ | \- | Set boolean |
264
+ | append |
265
+
266
+ Append content.
267
+
268
+ ReactNode
269
+
270
+
271
+
272
+ |
273
+
274
+ <IressIcon />
275
+
276
+
277
+
278
+ | Set object |
279
+ | autoComplete |
280
+
281
+ |
282
+
283
+ 'off'
284
+
285
+ | Set object |
286
+ | autoSelect |
287
+
288
+ If true, the selected option becomes the value of the input when the autocomplete loses focus.
289
+
290
+ boolean
291
+
292
+
293
+
294
+ |
295
+
296
+ true
297
+
298
+ | Set boolean |
299
+ | clearable |
300
+
301
+ If `true`, then user can clear the value of the input.
302
+
303
+ boolean
304
+
305
+
306
+
307
+ |
308
+
309
+ true
310
+
311
+ | Set boolean |
312
+ | defaultValue |
313
+
314
+ string
315
+
316
+
317
+
318
+ | \- | Option 1 |
319
+ | errorText |
320
+
321
+ Text to be displayed when the options function errors out. It is not used when the options are provided as an array.
322
+
323
+ ReactNode
324
+
325
+
326
+
327
+ |
328
+
329
+ <IressAlert />
330
+
331
+
332
+
333
+ | Set object |
334
+ | limitDesktop |
335
+
336
+ |
337
+
338
+ 12
339
+
340
+ | Set object |
341
+ | limitMobile |
342
+
343
+ |
344
+
345
+ 6
346
+
347
+ | Set object |
348
+ | noResultsText |
349
+
350
+ Text to be displayed when no results are found.
351
+
352
+ ReactNode
353
+
354
+
355
+
356
+ | \- | Set object |
357
+ | onChange |
358
+
359
+ Emitted when the user changes the input. The second and third arguments are only available when the options were selected from the `options` prop.
360
+
361
+ ( e?: SyntheticEvent<InputBaseElement>, value?: T, option?: LabelValueMeta, ) => void
362
+
363
+ | \- | \- |
364
+ | options |
365
+
366
+ array
367
+
368
+
369
+
370
+ | \- |
371
+
372
+ RAW
373
+
374
+ * options :
375
+
376
+ \[
377
+
378
+ * 0 :
379
+
380
+ {...} 1 key
381
+
382
+ * 1 :
383
+
384
+ {...} 1 key
385
+
386
+ * 2 :
387
+
388
+ {...} 1 key
389
+
390
+ * 3 :
391
+
392
+ {...} 1 key
393
+
394
+ * 4 :
395
+
396
+ {...} 1 key
397
+
398
+
399
+ \]
400
+
401
+
402
+
403
+
404
+ |
405
+ | popoverProps |
406
+
407
+ Customise the IressInputPopover props for your needs.
408
+
409
+ AutocompletePopoverProps
410
+
411
+
412
+
413
+ | { } |
414
+
415
+ RAW
416
+
417
+ popoverProps :
418
+
419
+ {
420
+
421
+ }
422
+
423
+
424
+
425
+
426
+
427
+
428
+
429
+ |
430
+
431
+ ### Controlled
432
+
433
+ The `value` prop can be used to completely control the state of the component. Use the `onChange` and `onClear` props to sync your state with the component.
434
+
435
+ [](./iframe.html?id=components-autocomplete--controlled)
436
+
437
+ ```
438
+
439
+ import { IressAutocomplete, type IressAutocompleteProps } from '@iress-oss/ids-components';
440
+ import { useState } from 'react';
441
+ export const AutocompleteUsingState \= () \=> {
442
+ const \[value, setValue\] \= useState('Option 1');
443
+ return (
444
+ <IressAutocomplete
445
+ {...{
446
+ popoverProps: {
447
+ container: {},
448
+ },
449
+ options: \[
450
+ {
451
+ label: 'Option 1',
452
+ },
453
+ {
454
+ label: 'Option 2',
455
+ },
456
+ {
457
+ label: 'Option 3',
458
+ },
459
+ {
460
+ label: 'Option 4',
461
+ },
462
+ {
463
+ label: 'Option 5',
464
+ },
465
+ \],
466
+ }}
467
+ onChange\={(\_e, newValue) \=> setValue(newValue ?? '')}
468
+ onClear\={() \=> setValue('')}
469
+ value\={value}
470
+ />
471
+ );
472
+ };
473
+
474
+ ```
475
+
476
+ #### Props
477
+
478
+ | Name | Description | Default | Control |
479
+ | --- | --- | --- | --- |
480
+ | alwaysShowOnFocus |
481
+ Always shown on focus, even if the user has not interacted with the input.
482
+
483
+ boolean
484
+
485
+
486
+
487
+ | \- | Set boolean |
488
+ | append |
489
+
490
+ Append content.
491
+
492
+ ReactNode
493
+
494
+
495
+
496
+ |
497
+
498
+ <IressIcon />
499
+
500
+
501
+
502
+ | Set object |
503
+ | autoComplete |
504
+
505
+ |
506
+
507
+ 'off'
508
+
509
+ | Set object |
510
+ | autoSelect |
511
+
512
+ If true, the selected option becomes the value of the input when the autocomplete loses focus.
513
+
514
+ boolean
515
+
516
+
517
+
518
+ |
519
+
520
+ true
521
+
522
+ | Set boolean |
523
+ | clearable |
524
+
525
+ If `true`, then user can clear the value of the input.
526
+
527
+ boolean
528
+
529
+
530
+
531
+ |
532
+
533
+ true
534
+
535
+ | Set boolean |
536
+ | defaultValue |
537
+
538
+ \-
539
+
540
+ | \- | \- |
541
+ | errorText |
542
+
543
+ Text to be displayed when the options function errors out. It is not used when the options are provided as an array.
544
+
545
+ ReactNode
546
+
547
+
548
+
549
+ |
550
+
551
+ <IressAlert />
552
+
553
+
554
+
555
+ | Set object |
556
+ | limitDesktop |
557
+
558
+ |
559
+
560
+ 12
561
+
562
+ | Set object |
563
+ | limitMobile |
564
+
565
+ |
566
+
567
+ 6
568
+
569
+ | Set object |
570
+ | noResultsText |
571
+
572
+ Text to be displayed when no results are found.
573
+
574
+ ReactNode
575
+
576
+
577
+
578
+ | \- | Set object |
579
+ | onChange |
580
+
581
+ Emitted when the user changes the input. The second and third arguments are only available when the options were selected from the `options` prop.
582
+
583
+ ( e?: SyntheticEvent<InputBaseElement>, value?: T, option?: LabelValueMeta, ) => void
584
+
585
+ | \- | \- |
586
+ | options |
587
+
588
+ array
589
+
590
+
591
+
592
+ | \- |
593
+
594
+ RAW
595
+
596
+ * options :
597
+
598
+ \[
599
+
600
+ * 0 :
601
+
602
+ {...} 1 key
603
+
604
+ * 1 :
605
+
606
+ {...} 1 key
607
+
608
+ * 2 :
609
+
610
+ {...} 1 key
611
+
612
+ * 3 :
613
+
614
+ {...} 1 key
615
+
616
+ * 4 :
617
+
618
+ {...} 1 key
619
+
620
+
621
+ \]
622
+
623
+
624
+
625
+
626
+ |
627
+ | popoverProps |
628
+
629
+ Customise the IressInputPopover props for your needs.
630
+
631
+ AutocompletePopoverProps
632
+
633
+
634
+
635
+ | { } |
636
+
637
+ RAW
638
+
639
+ popoverProps :
640
+
641
+ {
642
+
643
+ }
644
+
645
+
646
+
647
+
648
+
649
+
650
+
651
+ |
652
+ | value |
653
+
654
+ \-
655
+
656
+ | \- | \- |
657
+
658
+ ### Providing suggestions
659
+
660
+ #### `options`
661
+
662
+ To use the suggestion functionality, you can provide an array of `LabelValueMeta[]` objects to the `options` prop.
663
+
664
+ **Note:** If `value` is provided on a suggestion item, it will be used (casted to a string) instead of the `label` key. This is useful when you want to display a different value to the user than what is used for filtering.
665
+
666
+ [](./iframe.html?id=components-autocomplete--options)
667
+
668
+ ```
669
+
670
+ <IressAutocomplete
671
+ options\={\[
672
+ {
673
+ label: 'Option 1'
674
+ },
675
+ {
676
+ label: 'Option 2'
677
+ },
678
+ {
679
+ label: 'Option 3'
680
+ },
681
+ {
682
+ label: 'Option 4'
683
+ },
684
+ {
685
+ label: 'Option 5'
686
+ }
687
+ \]}
688
+ popoverProps\={{
689
+ container: {}
690
+ }}
691
+ />
692
+
693
+ ```
694
+
695
+ #### Props
696
+
697
+ | Name | Description | Default | Control |
698
+ | --- | --- | --- | --- |
699
+ | alwaysShowOnFocus |
700
+ Always shown on focus, even if the user has not interacted with the input.
701
+
702
+ boolean
703
+
704
+
705
+
706
+ | \- | Set boolean |
707
+ | append |
708
+
709
+ Append content.
710
+
711
+ ReactNode
712
+
713
+
714
+
715
+ |
716
+
717
+ <IressIcon />
718
+
719
+
720
+
721
+ | Set object |
722
+ | autoComplete |
723
+
724
+ |
725
+
726
+ 'off'
727
+
728
+ | Set object |
729
+ | autoSelect |
730
+
731
+ If true, the selected option becomes the value of the input when the autocomplete loses focus.
732
+
733
+ boolean
734
+
735
+
736
+
737
+ |
738
+
739
+ true
740
+
741
+ | Set boolean |
742
+ | clearable |
743
+
744
+ If `true`, then user can clear the value of the input.
745
+
746
+ boolean
747
+
748
+
749
+
750
+ |
751
+
752
+ true
753
+
754
+ | Set boolean |
755
+ | errorText |
756
+
757
+ Text to be displayed when the options function errors out. It is not used when the options are provided as an array.
758
+
759
+ ReactNode
760
+
761
+
762
+
763
+ |
764
+
765
+ <IressAlert />
766
+
767
+
768
+
769
+ | Set object |
770
+ | limitDesktop |
771
+
772
+ |
773
+
774
+ 12
775
+
776
+ | Set object |
777
+ | limitMobile |
778
+
779
+ |
780
+
781
+ 6
782
+
783
+ | Set object |
784
+ | noResultsText |
785
+
786
+ Text to be displayed when no results are found.
787
+
788
+ ReactNode
789
+
790
+
791
+
792
+ | \- | Set object |
793
+ | onChange |
794
+
795
+ Emitted when the user changes the input. The second and third arguments are only available when the options were selected from the `options` prop.
796
+
797
+ ( e?: SyntheticEvent<InputBaseElement>, value?: T, option?: LabelValueMeta, ) => void
798
+
799
+ | \- | \- |
800
+ | options |
801
+
802
+ array
803
+
804
+
805
+
806
+ | \- |
807
+
808
+ RAW
809
+
810
+ * options :
811
+
812
+ \[
813
+
814
+ * 0 :
815
+
816
+ {...} 1 key
817
+
818
+ * 1 :
819
+
820
+ {...} 1 key
821
+
822
+ * 2 :
823
+
824
+ {...} 1 key
825
+
826
+ * 3 :
827
+
828
+ {...} 1 key
829
+
830
+ * 4 :
831
+
832
+ {...} 1 key
833
+
834
+
835
+ \]
836
+
837
+
838
+
839
+
840
+ |
841
+ | popoverProps |
842
+
843
+ Customise the IressInputPopover props for your needs.
844
+
845
+ AutocompletePopoverProps
846
+
847
+
848
+
849
+ | { } |
850
+
851
+ RAW
852
+
853
+ popoverProps :
854
+
855
+ {
856
+
857
+ }
858
+
859
+
860
+
861
+
862
+
863
+
864
+
865
+ |
866
+
867
+ #### Asynchronous `options`
868
+
869
+ If you would like to render suggestions from the server, you can pass a function to the `options` prop. It accepts a string parameter and returns a promise that resolves to an array of `LabelValueMeta[]` objects.
870
+
871
+ [](./iframe.html?id=components-autocomplete--async-options)
872
+
873
+ ```
874
+
875
+ import { IressAutocomplete, type IressAutocompleteProps } from '@iress-oss/ids-components';
876
+ interface StarWarsCharacter {
877
+ name: string;
878
+ gender: string;
879
+ }
880
+ interface StarWarsCharacterApi {
881
+ results: StarWarsCharacter\[\];
882
+ }
883
+ export const AutocompleteUsingAsync \= () \=> (
884
+ <IressAutocomplete
885
+ {...{
886
+ popoverProps: {
887
+ container: {},
888
+ },
889
+ placeholder: 'Search star wars characters, or type "error" to see the error text',
890
+ }}
891
+ options\={async (query: string) \=> {
892
+ if (query \=== 'error') {
893
+ throw new Error('This is an error');
894
+ }
895
+ const data \= await fetch(
896
+ \`https://swapi.py4e.com/api/people/?search=${query}\`,
897
+ ).then((response) \=> response.json() as Promise<StarWarsCharacterApi\>);
898
+ return data.results.map((character: StarWarsCharacter) \=> ({
899
+ label: character.name,
900
+ value: character.name,
901
+ meta: character.gender,
902
+ }));
903
+ }}
904
+ />
905
+ );
906
+
907
+ ```
908
+
909
+ #### Props
910
+
911
+ | Name | Description | Default | Control |
912
+ | --- | --- | --- | --- |
913
+ | alwaysShowOnFocus |
914
+ Always shown on focus, even if the user has not interacted with the input.
915
+
916
+ boolean
917
+
918
+
919
+
920
+ | \- | Set boolean |
921
+ | append |
922
+
923
+ Append content.
924
+
925
+ ReactNode
926
+
927
+
928
+
929
+ |
930
+
931
+ <IressIcon />
932
+
933
+
934
+
935
+ | Set object |
936
+ | autoComplete |
937
+
938
+ |
939
+
940
+ 'off'
941
+
942
+ | Set object |
943
+ | autoSelect |
944
+
945
+ If true, the selected option becomes the value of the input when the autocomplete loses focus.
946
+
947
+ boolean
948
+
949
+
950
+
951
+ |
952
+
953
+ true
954
+
955
+ | Set boolean |
956
+ | clearable |
957
+
958
+ If `true`, then user can clear the value of the input.
959
+
960
+ boolean
961
+
962
+
963
+
964
+ |
965
+
966
+ true
967
+
968
+ | Set boolean |
969
+ | errorText |
970
+
971
+ Text to be displayed when the options function errors out. It is not used when the options are provided as an array.
972
+
973
+ ReactNode
974
+
975
+
976
+
977
+ |
978
+
979
+ <IressAlert />
980
+
981
+
982
+
983
+ | Set object |
984
+ | limitDesktop |
985
+
986
+ |
987
+
988
+ 12
989
+
990
+ | Set object |
991
+ | limitMobile |
992
+
993
+ |
994
+
995
+ 6
996
+
997
+ | Set object |
998
+ | noResultsText |
999
+
1000
+ Text to be displayed when no results are found.
1001
+
1002
+ ReactNode
1003
+
1004
+
1005
+
1006
+ | \- | Set object |
1007
+ | onChange |
1008
+
1009
+ Emitted when the user changes the input. The second and third arguments are only available when the options were selected from the `options` prop.
1010
+
1011
+ ( e?: SyntheticEvent<InputBaseElement>, value?: T, option?: LabelValueMeta, ) => void
1012
+
1013
+ | \- | \- |
1014
+ | options |
1015
+
1016
+ \-
1017
+
1018
+ | \- | \- |
1019
+ | placeholder |
1020
+
1021
+ string
1022
+
1023
+
1024
+
1025
+ | \- | Search star wars characters, or type "error" to see the error text |
1026
+ | popoverProps |
1027
+
1028
+ Customise the IressInputPopover props for your needs.
1029
+
1030
+ AutocompletePopoverProps
1031
+
1032
+
1033
+
1034
+ | { } |
1035
+
1036
+ RAW
1037
+
1038
+ popoverProps :
1039
+
1040
+ {
1041
+
1042
+ }
1043
+
1044
+
1045
+
1046
+
1047
+
1048
+
1049
+
1050
+ |
1051
+
1052
+ #### Minimum search length for async options
1053
+
1054
+ When using asynchronous options, you can set a minimum number of characters required before triggering the search using the `minSearchLength` prop. This prevents unnecessary API calls and loading states for very short queries.
1055
+
1056
+ By default, async searches are triggered after 1 character. Setting a higher value (e.g., 3) means no search request will be made and no loading spinner will appear until the user types at least that many characters.
1057
+
1058
+ [](./iframe.html?id=components-autocomplete--async-options-min-search-length)
1059
+
1060
+ ```
1061
+
1062
+ import { IressAutocomplete, type IressAutocompleteProps } from '@iress-oss/ids-components';
1063
+ interface StarWarsCharacter {
1064
+ name: string;
1065
+ gender: string;
1066
+ }
1067
+ interface StarWarsCharacterApi {
1068
+ results: StarWarsCharacter\[\];
1069
+ }
1070
+ export const AutocompleteUsingAsync \= () \=> (
1071
+ <IressAutocomplete
1072
+ {...{
1073
+ popoverProps: {
1074
+ container: {},
1075
+ },
1076
+ minSearchLength: 3,
1077
+ }}
1078
+ options\={async (query: string) \=> {
1079
+ if (query \=== 'error') {
1080
+ throw new Error('This is an error');
1081
+ }
1082
+ const data \= await fetch(
1083
+ \`https://swapi.py4e.com/api/people/?search=${query}\`,
1084
+ ).then((response) \=> response.json() as Promise<StarWarsCharacterApi\>);
1085
+ return data.results.map((character: StarWarsCharacter) \=> ({
1086
+ label: character.name,
1087
+ value: character.name,
1088
+ meta: character.gender,
1089
+ }));
1090
+ }}
1091
+ />
1092
+ );
1093
+
1094
+ ```
1095
+
1096
+ #### Props
1097
+
1098
+ | Name | Description | Default | Control |
1099
+ | --- | --- | --- | --- |
1100
+ | alwaysShowOnFocus |
1101
+ Always shown on focus, even if the user has not interacted with the input.
1102
+
1103
+ boolean
1104
+
1105
+
1106
+
1107
+ | \- | Set boolean |
1108
+ | append |
1109
+
1110
+ Append content.
1111
+
1112
+ ReactNode
1113
+
1114
+
1115
+
1116
+ |
1117
+
1118
+ <IressIcon />
1119
+
1120
+
1121
+
1122
+ | Set object |
1123
+ | autoComplete |
1124
+
1125
+ |
1126
+
1127
+ 'off'
1128
+
1129
+ | Set object |
1130
+ | autoSelect |
1131
+
1132
+ If true, the selected option becomes the value of the input when the autocomplete loses focus.
1133
+
1134
+ boolean
1135
+
1136
+
1137
+
1138
+ |
1139
+
1140
+ true
1141
+
1142
+ | Set boolean |
1143
+ | clearable |
1144
+
1145
+ If `true`, then user can clear the value of the input.
1146
+
1147
+ boolean
1148
+
1149
+
1150
+
1151
+ |
1152
+
1153
+ true
1154
+
1155
+ | Set boolean |
1156
+ | errorText |
1157
+
1158
+ Text to be displayed when the options function errors out. It is not used when the options are provided as an array.
1159
+
1160
+ ReactNode
1161
+
1162
+
1163
+
1164
+ |
1165
+
1166
+ <IressAlert />
1167
+
1168
+
1169
+
1170
+ | Set object |
1171
+ | limitDesktop |
1172
+
1173
+ |
1174
+
1175
+ 12
1176
+
1177
+ | Set object |
1178
+ | limitMobile |
1179
+
1180
+ |
1181
+
1182
+ 6
1183
+
1184
+ | Set object |
1185
+ | minSearchLength |
1186
+
1187
+ number
1188
+
1189
+
1190
+
1191
+ | \- | |
1192
+ | noResultsText |
1193
+
1194
+ Text to be displayed when no results are found.
1195
+
1196
+ ReactNode
1197
+
1198
+
1199
+
1200
+ | \- | Set object |
1201
+ | onChange |
1202
+
1203
+ Emitted when the user changes the input. The second and third arguments are only available when the options were selected from the `options` prop.
1204
+
1205
+ ( e?: SyntheticEvent<InputBaseElement>, value?: T, option?: LabelValueMeta, ) => void
1206
+
1207
+ | \- | \- |
1208
+ | options |
1209
+
1210
+ \-
1211
+
1212
+ | \- | \- |
1213
+ | popoverProps |
1214
+
1215
+ Customise the IressInputPopover props for your needs.
1216
+
1217
+ AutocompletePopoverProps
1218
+
1219
+
1220
+
1221
+ | { } |
1222
+
1223
+ RAW
1224
+
1225
+ popoverProps :
1226
+
1227
+ {
1228
+
1229
+ }
1230
+
1231
+
1232
+
1233
+
1234
+
1235
+
1236
+
1237
+ |
1238
+
1239
+ #### `initialOptions`
1240
+
1241
+ If you want to provide initial options to the user, you can use the `initialOptions` prop. This is useful when you want to provide a list of options to the user before they start typing (eg. recommended search terms).
1242
+
1243
+ [](./iframe.html?id=components-autocomplete--initial-options)
1244
+
1245
+ ```
1246
+
1247
+ <IressAutocomplete
1248
+ initialOptions\={\[
1249
+ {
1250
+ label: 'Favourite option 1'
1251
+ },
1252
+ {
1253
+ label: 'Favourite option 2'
1254
+ },
1255
+ {
1256
+ label: 'Favourite option 3'
1257
+ }
1258
+ \]}
1259
+ options\={\[
1260
+ {
1261
+ label: 'Option 1'
1262
+ },
1263
+ {
1264
+ label: 'Option 2'
1265
+ },
1266
+ {
1267
+ label: 'Option 3'
1268
+ },
1269
+ {
1270
+ label: 'Option 4'
1271
+ },
1272
+ {
1273
+ label: 'Option 5'
1274
+ }
1275
+ \]}
1276
+ popoverProps\={{
1277
+ container: {}
1278
+ }}
1279
+ />
1280
+
1281
+ ```
1282
+
1283
+ #### Props
1284
+
1285
+ | Name | Description | Default | Control |
1286
+ | --- | --- | --- | --- |
1287
+ | alwaysShowOnFocus |
1288
+ Always shown on focus, even if the user has not interacted with the input.
1289
+
1290
+ boolean
1291
+
1292
+
1293
+
1294
+ | \- | Set boolean |
1295
+ | append |
1296
+
1297
+ Append content.
1298
+
1299
+ ReactNode
1300
+
1301
+
1302
+
1303
+ |
1304
+
1305
+ <IressIcon />
1306
+
1307
+
1308
+
1309
+ | Set object |
1310
+ | autoComplete |
1311
+
1312
+ |
1313
+
1314
+ 'off'
1315
+
1316
+ | Set object |
1317
+ | autoSelect |
1318
+
1319
+ If true, the selected option becomes the value of the input when the autocomplete loses focus.
1320
+
1321
+ boolean
1322
+
1323
+
1324
+
1325
+ |
1326
+
1327
+ true
1328
+
1329
+ | Set boolean |
1330
+ | clearable |
1331
+
1332
+ If `true`, then user can clear the value of the input.
1333
+
1334
+ boolean
1335
+
1336
+
1337
+
1338
+ |
1339
+
1340
+ true
1341
+
1342
+ | Set boolean |
1343
+ | errorText |
1344
+
1345
+ Text to be displayed when the options function errors out. It is not used when the options are provided as an array.
1346
+
1347
+ ReactNode
1348
+
1349
+
1350
+
1351
+ |
1352
+
1353
+ <IressAlert />
1354
+
1355
+
1356
+
1357
+ | Set object |
1358
+ | initialOptions |
1359
+
1360
+ array
1361
+
1362
+
1363
+
1364
+ | \- |
1365
+
1366
+ RAW
1367
+
1368
+ * initialOptions :
1369
+
1370
+ \[
1371
+
1372
+ * 0 :
1373
+
1374
+ {...} 1 key
1375
+
1376
+ * 1 :
1377
+
1378
+ {...} 1 key
1379
+
1380
+ * 2 :
1381
+
1382
+ {...} 1 key
1383
+
1384
+
1385
+ \]
1386
+
1387
+
1388
+
1389
+
1390
+ |
1391
+ | limitDesktop |
1392
+
1393
+ |
1394
+
1395
+ 12
1396
+
1397
+ | Set object |
1398
+ | limitMobile |
1399
+
1400
+ |
1401
+
1402
+ 6
1403
+
1404
+ | Set object |
1405
+ | noResultsText |
1406
+
1407
+ Text to be displayed when no results are found.
1408
+
1409
+ ReactNode
1410
+
1411
+
1412
+
1413
+ | \- | Set object |
1414
+ | onChange |
1415
+
1416
+ Emitted when the user changes the input. The second and third arguments are only available when the options were selected from the `options` prop.
1417
+
1418
+ ( e?: SyntheticEvent<InputBaseElement>, value?: T, option?: LabelValueMeta, ) => void
1419
+
1420
+ | \- | \- |
1421
+ | options |
1422
+
1423
+ array
1424
+
1425
+
1426
+
1427
+ | \- |
1428
+
1429
+ RAW
1430
+
1431
+ * options :
1432
+
1433
+ \[
1434
+
1435
+ * 0 :
1436
+
1437
+ {...} 1 key
1438
+
1439
+ * 1 :
1440
+
1441
+ {...} 1 key
1442
+
1443
+ * 2 :
1444
+
1445
+ {...} 1 key
1446
+
1447
+ * 3 :
1448
+
1449
+ {...} 1 key
1450
+
1451
+ * 4 :
1452
+
1453
+ {...} 1 key
1454
+
1455
+
1456
+ \]
1457
+
1458
+
1459
+
1460
+
1461
+ |
1462
+ | popoverProps |
1463
+
1464
+ Customise the IressInputPopover props for your needs.
1465
+
1466
+ AutocompletePopoverProps
1467
+
1468
+
1469
+
1470
+ | { } |
1471
+
1472
+ RAW
1473
+
1474
+ popoverProps :
1475
+
1476
+ {
1477
+
1478
+ }
1479
+
1480
+
1481
+
1482
+
1483
+
1484
+
1485
+
1486
+ |
1487
+
1488
+ Behaviour
1489
+ ---------
1490
+
1491
+ * As long as there is a single character in the input, the suggestions will be displayed in a popover. Unless `initialOptions` are provided where the popover will be displayed immediately on focus.
1492
+ * The popover will close when the input is empty, unless `initialOptions` are provided.
1493
+ * The suggestions will be filtered based on the input value.
1494
+ * Tapping on a suggestion with the mouse will change the input value to the selection and close the popover.
1495
+ * When the user presses the arrows keys while the input is focussed, suggestions will be highlighted, but focus remains on the input.
1496
+ * When the user presses the enter key while a suggestion is highlighted, the suggestion will be selected and the popover will close.
1497
+ * When the user presses the down key while the popover is closed, it will open the popover.
1498
+ * When the user pressed the up key while the first suggestion is highlighted, it will close the popover.
1499
+ * When the user tabs away while no suggestion is highlighted, the input will not be changed.
1500
+ * When the user tabs away while a suggestion is highlighted, the suggestion will be selected.
1501
+ * When the user tabs away while the popover is open, the popover will close.
1502
+
1503
+ Accessibility
1504
+ -------------
1505
+
1506
+ The autocomplete component follows the [WAI combobox pattern: List autocomplete with manual selection](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/#:~:text=List%20autocomplete%20with%20manual,value%20in%20the%20popup). An example of this pattern outside of IDS can be seen at [WAI-ARIA combobox example](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-autocomplete-list/).
1507
+
1508
+ There is a key difference:
1509
+
1510
+ * For better usability, virtual focus is used to highlight the suggestions inside the popover. This means focus remains on the input, but the suggestions are highlighted as if they are in focus, allowing the user to type and navigate the suggestions with the arrow keys.
1511
+ * To denote the highlighted suggestion to screen readers, the `aria-activedescendant` attribute is used.
1512
+
1513
+ Examples
1514
+ --------
1515
+
1516
+ ### `autoSelect`
1517
+
1518
+ The `autoSelect` prop will automatically select the highlighted option when the user blurs the autocomplete. This is set to true by default, but can be switched off.
1519
+
1520
+ [](./iframe.html?id=components-autocomplete--remove-auto-select)
1521
+
1522
+ ```
1523
+
1524
+ <IressAutocomplete
1525
+ autoSelect\={false}
1526
+ options\={\[
1527
+ {
1528
+ label: 'Option 1'
1529
+ },
1530
+ {
1531
+ label: 'Option 2'
1532
+ },
1533
+ {
1534
+ label: 'Option 3'
1535
+ },
1536
+ {
1537
+ label: 'Option 4'
1538
+ },
1539
+ {
1540
+ label: 'Option 5'
1541
+ }
1542
+ \]}
1543
+ placeholder\="Should no longer auto-select when an item is highlighted"
1544
+ popoverProps\={{
1545
+ container: {}
1546
+ }}
1547
+ />
1548
+
1549
+ ```
1550
+
1551
+ #### Props
1552
+
1553
+ | Name | Description | Default | Control |
1554
+ | --- | --- | --- | --- |
1555
+ | alwaysShowOnFocus |
1556
+ Always shown on focus, even if the user has not interacted with the input.
1557
+
1558
+ boolean
1559
+
1560
+
1561
+
1562
+ | \- | Set boolean |
1563
+ | append |
1564
+
1565
+ Append content.
1566
+
1567
+ ReactNode
1568
+
1569
+
1570
+
1571
+ |
1572
+
1573
+ <IressIcon />
1574
+
1575
+
1576
+
1577
+ | Set object |
1578
+ | autoComplete |
1579
+
1580
+ |
1581
+
1582
+ 'off'
1583
+
1584
+ | Set object |
1585
+ | autoSelect |
1586
+
1587
+ If true, the selected option becomes the value of the input when the autocomplete loses focus.
1588
+
1589
+ boolean
1590
+
1591
+
1592
+
1593
+ |
1594
+
1595
+ true
1596
+
1597
+ | FalseTrue |
1598
+ | clearable |
1599
+
1600
+ If `true`, then user can clear the value of the input.
1601
+
1602
+ boolean
1603
+
1604
+
1605
+
1606
+ |
1607
+
1608
+ true
1609
+
1610
+ | Set boolean |
1611
+ | errorText |
1612
+
1613
+ Text to be displayed when the options function errors out. It is not used when the options are provided as an array.
1614
+
1615
+ ReactNode
1616
+
1617
+
1618
+
1619
+ |
1620
+
1621
+ <IressAlert />
1622
+
1623
+
1624
+
1625
+ | Set object |
1626
+ | limitDesktop |
1627
+
1628
+ |
1629
+
1630
+ 12
1631
+
1632
+ | Set object |
1633
+ | limitMobile |
1634
+
1635
+ |
1636
+
1637
+ 6
1638
+
1639
+ | Set object |
1640
+ | noResultsText |
1641
+
1642
+ Text to be displayed when no results are found.
1643
+
1644
+ ReactNode
1645
+
1646
+
1647
+
1648
+ | \- | Set object |
1649
+ | onChange |
1650
+
1651
+ Emitted when the user changes the input. The second and third arguments are only available when the options were selected from the `options` prop.
1652
+
1653
+ ( e?: SyntheticEvent<InputBaseElement>, value?: T, option?: LabelValueMeta, ) => void
1654
+
1655
+ | \- | \- |
1656
+ | options |
1657
+
1658
+ array
1659
+
1660
+
1661
+
1662
+ | \- |
1663
+
1664
+ RAW
1665
+
1666
+ * options :
1667
+
1668
+ \[
1669
+
1670
+ * 0 :
1671
+
1672
+ {...} 1 key
1673
+
1674
+ * 1 :
1675
+
1676
+ {...} 1 key
1677
+
1678
+ * 2 :
1679
+
1680
+ {...} 1 key
1681
+
1682
+ * 3 :
1683
+
1684
+ {...} 1 key
1685
+
1686
+ * 4 :
1687
+
1688
+ {...} 1 key
1689
+
1690
+
1691
+ \]
1692
+
1693
+
1694
+
1695
+
1696
+ |
1697
+ | placeholder |
1698
+
1699
+ string
1700
+
1701
+
1702
+
1703
+ | \- | Should no longer auto-select when an item is highlighted |
1704
+ | popoverProps |
1705
+
1706
+ Customise the IressInputPopover props for your needs.
1707
+
1708
+ AutocompletePopoverProps
1709
+
1710
+
1711
+
1712
+ | { } |
1713
+
1714
+ RAW
1715
+
1716
+ popoverProps :
1717
+
1718
+ {
1719
+
1720
+ }
1721
+
1722
+
1723
+
1724
+
1725
+
1726
+
1727
+
1728
+ |
1729
+
1730
+ ### Input props
1731
+
1732
+ Autocomplete extends `IressInput`, hence it has the same properties as `IressInput`.
1733
+
1734
+ It does have some defaults to help with user experience. `append` automatically has a search icon, and `clearable` is set to true by default.
1735
+
1736
+ [](./iframe.html?id=components-autocomplete--input-props)
1737
+
1738
+ ```
1739
+
1740
+ <IressAutocomplete
1741
+ append\={<IressPopover activator\={<IressButton mode\="tertiary"\><IressIcon name\="cog" /></IressButton\>} align\="bottom-end" container\={document.body}\><IressPanel\>Some settings in here</IressPanel\></IressPopover\>}
1742
+ options\={\[
1743
+ {
1744
+ label: 'Option 1'
1745
+ },
1746
+ {
1747
+ label: 'Option 2'
1748
+ },
1749
+ {
1750
+ label: 'Option 3'
1751
+ },
1752
+ {
1753
+ label: 'Option 4'
1754
+ },
1755
+ {
1756
+ label: 'Option 5'
1757
+ }
1758
+ \]}
1759
+ popoverProps\={{
1760
+ container: {}
1761
+ }}
1762
+ prepend\={<IressIcon name\="search" />}
1763
+ width\="12"
1764
+ />
1765
+
1766
+ ```
1767
+
1768
+ #### Props
1769
+
1770
+ | Name | Description | Default | Control |
1771
+ | --- | --- | --- | --- |
1772
+ | alwaysShowOnFocus |
1773
+ Always shown on focus, even if the user has not interacted with the input.
1774
+
1775
+ boolean
1776
+
1777
+
1778
+
1779
+ | \- | Set boolean |
1780
+ | append |
1781
+
1782
+ Append content.
1783
+
1784
+ ReactNode
1785
+
1786
+
1787
+
1788
+ |
1789
+
1790
+ <IressIcon />
1791
+
1792
+
1793
+
1794
+ |
1795
+
1796
+ RAW
1797
+
1798
+ append :
1799
+
1800
+ {
1801
+
1802
+ * $$typeof : Symbol(react.transitional.element)
1803
+ * type :
1804
+
1805
+ {...} 3 keys
1806
+
1807
+ * key : null
1808
+ * props :
1809
+
1810
+ {...} 4 keys
1811
+
1812
+ * \_owner : null
1813
+ * \_store :
1814
+
1815
+ {...} 0 keys
1816
+
1817
+
1818
+ }
1819
+
1820
+
1821
+
1822
+
1823
+
1824
+
1825
+
1826
+ |
1827
+ | autoComplete |
1828
+
1829
+ |
1830
+
1831
+ 'off'
1832
+
1833
+ | Set object |
1834
+ | autoSelect |
1835
+
1836
+ If true, the selected option becomes the value of the input when the autocomplete loses focus.
1837
+
1838
+ boolean
1839
+
1840
+
1841
+
1842
+ |
1843
+
1844
+ true
1845
+
1846
+ | Set boolean |
1847
+ | clearable |
1848
+
1849
+ If `true`, then user can clear the value of the input.
1850
+
1851
+ boolean
1852
+
1853
+
1854
+
1855
+ |
1856
+
1857
+ true
1858
+
1859
+ | Set boolean |
1860
+ | errorText |
1861
+
1862
+ Text to be displayed when the options function errors out. It is not used when the options are provided as an array.
1863
+
1864
+ ReactNode
1865
+
1866
+
1867
+
1868
+ |
1869
+
1870
+ <IressAlert />
1871
+
1872
+
1873
+
1874
+ | Set object |
1875
+ | limitDesktop |
1876
+
1877
+ |
1878
+
1879
+ 12
1880
+
1881
+ | Set object |
1882
+ | limitMobile |
1883
+
1884
+ |
1885
+
1886
+ 6
1887
+
1888
+ | Set object |
1889
+ | noResultsText |
1890
+
1891
+ Text to be displayed when no results are found.
1892
+
1893
+ ReactNode
1894
+
1895
+
1896
+
1897
+ | \- | Set object |
1898
+ | onChange |
1899
+
1900
+ Emitted when the user changes the input. The second and third arguments are only available when the options were selected from the `options` prop.
1901
+
1902
+ ( e?: SyntheticEvent<InputBaseElement>, value?: T, option?: LabelValueMeta, ) => void
1903
+
1904
+ | \- | \- |
1905
+ | options |
1906
+
1907
+ array
1908
+
1909
+
1910
+
1911
+ | \- |
1912
+
1913
+ RAW
1914
+
1915
+ * options :
1916
+
1917
+ \[
1918
+
1919
+ * 0 :
1920
+
1921
+ {...} 1 key
1922
+
1923
+ * 1 :
1924
+
1925
+ {...} 1 key
1926
+
1927
+ * 2 :
1928
+
1929
+ {...} 1 key
1930
+
1931
+ * 3 :
1932
+
1933
+ {...} 1 key
1934
+
1935
+ * 4 :
1936
+
1937
+ {...} 1 key
1938
+
1939
+
1940
+ \]
1941
+
1942
+
1943
+
1944
+
1945
+ |
1946
+ | popoverProps |
1947
+
1948
+ Customise the IressInputPopover props for your needs.
1949
+
1950
+ AutocompletePopoverProps
1951
+
1952
+
1953
+
1954
+ | { } |
1955
+
1956
+ RAW
1957
+
1958
+ popoverProps :
1959
+
1960
+ {
1961
+
1962
+ }
1963
+
1964
+
1965
+
1966
+
1967
+
1968
+
1969
+
1970
+ |
1971
+ | prepend |
1972
+
1973
+ object
1974
+
1975
+
1976
+
1977
+ | \- |
1978
+
1979
+ RAW
1980
+
1981
+ prepend :
1982
+
1983
+ {
1984
+
1985
+ * $$typeof : Symbol(react.transitional.element)
1986
+ * type : ({ className, fixedWidth, flip, name, rotate, screenreaderText, set = "fal", spin, ...restProps }) => { const prefix = "fa-"; const classes = icon({ flip, rotate, spin }); return /\* @\_\_PURE\_\_ \*/ jsxDEV( styled.span, { role: "img", className: cx( classes, GlobalCSSClass.Icon, set, \`${prefix}${name}\`, fixedWidth && "fa-fw", className ), "aria-hidden": !screenreaderText && "true", "aria-label": screenreaderText, ...restProps }, void 0, false, { fileName: "/home/runner/work/design-system/design-system/packages/components/src/components/Icon/Icon.tsx", lineNumber: 67, columnNumber: 5 }, this ); }
1987
+ * key : null
1988
+ * props :
1989
+
1990
+ {...} 1 key
1991
+
1992
+ * \_owner : null
1993
+ * \_store :
1994
+
1995
+ {...} 0 keys
1996
+
1997
+
1998
+ }
1999
+
2000
+
2001
+
2002
+
2003
+
2004
+
2005
+
2006
+ |
2007
+ | width |
2008
+
2009
+ string
2010
+
2011
+
2012
+
2013
+ | \- | 12 |
2014
+
2015
+ ### No results
2016
+
2017
+ If you would like to show a message when there are no results, you can use the `noResultsText` prop. It accepts any React node.
2018
+
2019
+ [](./iframe.html?id=components-autocomplete--no-results-text)
2020
+
2021
+ ```
2022
+
2023
+ <IressAutocomplete
2024
+ noResultsText\={<IressPanel\>No results found</IressPanel\>}
2025
+ options\={\[
2026
+ {
2027
+ label: 'Option 1'
2028
+ },
2029
+ {
2030
+ label: 'Option 2'
2031
+ },
2032
+ {
2033
+ label: 'Option 3'
2034
+ },
2035
+ {
2036
+ label: 'Option 4'
2037
+ },
2038
+ {
2039
+ label: 'Option 5'
2040
+ }
2041
+ \]}
2042
+ placeholder\="Type &quot;no&quot; to see the no results text"
2043
+ popoverProps\={{
2044
+ container: {}
2045
+ }}
2046
+ />
2047
+
2048
+ ```
2049
+
2050
+ #### Props
2051
+
2052
+ | Name | Description | Default | Control |
2053
+ | --- | --- | --- | --- |
2054
+ | alwaysShowOnFocus |
2055
+ Always shown on focus, even if the user has not interacted with the input.
2056
+
2057
+ boolean
2058
+
2059
+
2060
+
2061
+ | \- | Set boolean |
2062
+ | append |
2063
+
2064
+ Append content.
2065
+
2066
+ ReactNode
2067
+
2068
+
2069
+
2070
+ |
2071
+
2072
+ <IressIcon />
2073
+
2074
+
2075
+
2076
+ | Set object |
2077
+ | autoComplete |
2078
+
2079
+ |
2080
+
2081
+ 'off'
2082
+
2083
+ | Set object |
2084
+ | autoSelect |
2085
+
2086
+ If true, the selected option becomes the value of the input when the autocomplete loses focus.
2087
+
2088
+ boolean
2089
+
2090
+
2091
+
2092
+ |
2093
+
2094
+ true
2095
+
2096
+ | Set boolean |
2097
+ | clearable |
2098
+
2099
+ If `true`, then user can clear the value of the input.
2100
+
2101
+ boolean
2102
+
2103
+
2104
+
2105
+ |
2106
+
2107
+ true
2108
+
2109
+ | Set boolean |
2110
+ | errorText |
2111
+
2112
+ Text to be displayed when the options function errors out. It is not used when the options are provided as an array.
2113
+
2114
+ ReactNode
2115
+
2116
+
2117
+
2118
+ |
2119
+
2120
+ <IressAlert />
2121
+
2122
+
2123
+
2124
+ | Set object |
2125
+ | limitDesktop |
2126
+
2127
+ |
2128
+
2129
+ 12
2130
+
2131
+ | Set object |
2132
+ | limitMobile |
2133
+
2134
+ |
2135
+
2136
+ 6
2137
+
2138
+ | Set object |
2139
+ | noResultsText |
2140
+
2141
+ Text to be displayed when no results are found.
2142
+
2143
+ ReactNode
2144
+
2145
+
2146
+
2147
+ | \- |
2148
+
2149
+ RAW
2150
+
2151
+ noResultsText :
2152
+
2153
+ {
2154
+
2155
+ * $$typeof : Symbol(react.transitional.element)
2156
+ * type : ({ className, ...restProps }) => /\* @\_\_PURE\_\_ \*/ jsxDEV(Component, { ...restProps, className: cx(className, GlobalCSSClass.Panel) }, void 0, false, { fileName: "/home/runner/work/design-system/design-system/packages/components/src/components/Panel/Panel.tsx", lineNumber: 26, columnNumber: 1 }, this)
2157
+ * key : null
2158
+ * props :
2159
+
2160
+ {...} 1 key
2161
+
2162
+ * \_owner : null
2163
+ * \_store :
2164
+
2165
+ {...} 0 keys
2166
+
2167
+
2168
+ }
2169
+
2170
+
2171
+
2172
+
2173
+
2174
+
2175
+
2176
+ |
2177
+ | onChange |
2178
+
2179
+ Emitted when the user changes the input. The second and third arguments are only available when the options were selected from the `options` prop.
2180
+
2181
+ ( e?: SyntheticEvent<InputBaseElement>, value?: T, option?: LabelValueMeta, ) => void
2182
+
2183
+ | \- | \- |
2184
+ | options |
2185
+
2186
+ array
2187
+
2188
+
2189
+
2190
+ | \- |
2191
+
2192
+ RAW
2193
+
2194
+ * options :
2195
+
2196
+ \[
2197
+
2198
+ * 0 :
2199
+
2200
+ {...} 1 key
2201
+
2202
+ * 1 :
2203
+
2204
+ {...} 1 key
2205
+
2206
+ * 2 :
2207
+
2208
+ {...} 1 key
2209
+
2210
+ * 3 :
2211
+
2212
+ {...} 1 key
2213
+
2214
+ * 4 :
2215
+
2216
+ {...} 1 key
2217
+
2218
+
2219
+ \]
2220
+
2221
+
2222
+
2223
+
2224
+ |
2225
+ | placeholder |
2226
+
2227
+ string
2228
+
2229
+
2230
+
2231
+ | \- | Type "no" to see the no results text |
2232
+ | popoverProps |
2233
+
2234
+ Customise the IressInputPopover props for your needs.
2235
+
2236
+ AutocompletePopoverProps
2237
+
2238
+
2239
+
2240
+ | { } |
2241
+
2242
+ RAW
2243
+
2244
+ popoverProps :
2245
+
2246
+ {
2247
+
2248
+ }
2249
+
2250
+
2251
+
2252
+
2253
+
2254
+
2255
+
2256
+ |
2257
+
2258
+ ### Popover props
2259
+
2260
+ Under the hood, autocomplete uses `IressInputPopover` to display the suggestions. It accepts `autoHighlight`, `align`, `className` and `displayMode`.
2261
+
2262
+ There are two additional props that autocomplete accepts to customise the popover: `append` and `prepend`. You can place additional content above or below the results using these props.
2263
+
2264
+ [](./iframe.html?id=components-autocomplete--popover-props)
2265
+
2266
+ ```
2267
+
2268
+ <IressAutocomplete
2269
+ options\={\[
2270
+ {
2271
+ label: 'Option 1'
2272
+ },
2273
+ {
2274
+ label: 'Option 2'
2275
+ },
2276
+ {
2277
+ label: 'Option 3'
2278
+ },
2279
+ {
2280
+ label: 'Option 4'
2281
+ },
2282
+ {
2283
+ label: 'Option 5'
2284
+ }
2285
+ \]}
2286
+ popoverProps\={{
2287
+ append: <IressPanel\><IressButton\>Add an option</IressButton\></IressPanel\>,
2288
+ container: {}
2289
+ }}
2290
+ />
2291
+
2292
+ ```
2293
+
2294
+ #### Props
2295
+
2296
+ | Name | Description | Default | Control |
2297
+ | --- | --- | --- | --- |
2298
+ | alwaysShowOnFocus |
2299
+ Always shown on focus, even if the user has not interacted with the input.
2300
+
2301
+ boolean
2302
+
2303
+
2304
+
2305
+ | \- | Set boolean |
2306
+ | append |
2307
+
2308
+ Append content.
2309
+
2310
+ ReactNode
2311
+
2312
+
2313
+
2314
+ |
2315
+
2316
+ <IressIcon />
2317
+
2318
+
2319
+
2320
+ | Set object |
2321
+ | autoComplete |
2322
+
2323
+ |
2324
+
2325
+ 'off'
2326
+
2327
+ | Set object |
2328
+ | autoSelect |
2329
+
2330
+ If true, the selected option becomes the value of the input when the autocomplete loses focus.
2331
+
2332
+ boolean
2333
+
2334
+
2335
+
2336
+ |
2337
+
2338
+ true
2339
+
2340
+ | Set boolean |
2341
+ | clearable |
2342
+
2343
+ If `true`, then user can clear the value of the input.
2344
+
2345
+ boolean
2346
+
2347
+
2348
+
2349
+ |
2350
+
2351
+ true
2352
+
2353
+ | Set boolean |
2354
+ | errorText |
2355
+
2356
+ Text to be displayed when the options function errors out. It is not used when the options are provided as an array.
2357
+
2358
+ ReactNode
2359
+
2360
+
2361
+
2362
+ |
2363
+
2364
+ <IressAlert />
2365
+
2366
+
2367
+
2368
+ | Set object |
2369
+ | limitDesktop |
2370
+
2371
+ |
2372
+
2373
+ 12
2374
+
2375
+ | Set object |
2376
+ | limitMobile |
2377
+
2378
+ |
2379
+
2380
+ 6
2381
+
2382
+ | Set object |
2383
+ | noResultsText |
2384
+
2385
+ Text to be displayed when no results are found.
2386
+
2387
+ ReactNode
2388
+
2389
+
2390
+
2391
+ | \- | Set object |
2392
+ | onChange |
2393
+
2394
+ Emitted when the user changes the input. The second and third arguments are only available when the options were selected from the `options` prop.
2395
+
2396
+ ( e?: SyntheticEvent<InputBaseElement>, value?: T, option?: LabelValueMeta, ) => void
2397
+
2398
+ | \- | \- |
2399
+ | options |
2400
+
2401
+ array
2402
+
2403
+
2404
+
2405
+ | \- |
2406
+
2407
+ RAW
2408
+
2409
+ * options :
2410
+
2411
+ \[
2412
+
2413
+ * 0 :
2414
+
2415
+ {...} 1 key
2416
+
2417
+ * 1 :
2418
+
2419
+ {...} 1 key
2420
+
2421
+ * 2 :
2422
+
2423
+ {...} 1 key
2424
+
2425
+ * 3 :
2426
+
2427
+ {...} 1 key
2428
+
2429
+ * 4 :
2430
+
2431
+ {...} 1 key
2432
+
2433
+
2434
+ \]
2435
+
2436
+
2437
+
2438
+
2439
+ |
2440
+ | popoverProps |
2441
+
2442
+ Customise the IressInputPopover props for your needs.
2443
+
2444
+ AutocompletePopoverProps
2445
+
2446
+
2447
+
2448
+ | { } |
2449
+
2450
+ RAW
2451
+
2452
+ popoverProps :
2453
+
2454
+ {
2455
+
2456
+ * append :
2457
+
2458
+ {...} 6 keys
2459
+
2460
+
2461
+ }
2462
+
2463
+
2464
+
2465
+
2466
+
2467
+
2468
+
2469
+ |
2470
+
2471
+ ### Debounce threshold
2472
+
2473
+ The `debounceThreshold` prop can be used to set the time in milliseconds to wait before making a request to the `options` function. This is useful when you want to prevent making too many requests to the server.
2474
+
2475
+ By default there is a debounce, but it can be removed by setting it to `0`.
2476
+
2477
+ [](./iframe.html?id=components-autocomplete--debounce-threshold)
2478
+
2479
+ ```
2480
+
2481
+ <IressAutocomplete
2482
+ debounceThreshold\={0}
2483
+ options\={\[
2484
+ {
2485
+ label: 'Option 1'
2486
+ },
2487
+ {
2488
+ label: 'Option 2'
2489
+ },
2490
+ {
2491
+ label: 'Option 3'
2492
+ },
2493
+ {
2494
+ label: 'Option 4'
2495
+ },
2496
+ {
2497
+ label: 'Option 5'
2498
+ }
2499
+ \]}
2500
+ placeholder\="Instant search!"
2501
+ popoverProps\={{
2502
+ container: {}
2503
+ }}
2504
+ />
2505
+
2506
+ ```
2507
+
2508
+ #### Props
2509
+
2510
+ | Name | Description | Default | Control |
2511
+ | --- | --- | --- | --- |
2512
+ | alwaysShowOnFocus |
2513
+ Always shown on focus, even if the user has not interacted with the input.
2514
+
2515
+ boolean
2516
+
2517
+
2518
+
2519
+ | \- | Set boolean |
2520
+ | append |
2521
+
2522
+ Append content.
2523
+
2524
+ ReactNode
2525
+
2526
+
2527
+
2528
+ |
2529
+
2530
+ <IressIcon />
2531
+
2532
+
2533
+
2534
+ | Set object |
2535
+ | autoComplete |
2536
+
2537
+ |
2538
+
2539
+ 'off'
2540
+
2541
+ | Set object |
2542
+ | autoSelect |
2543
+
2544
+ If true, the selected option becomes the value of the input when the autocomplete loses focus.
2545
+
2546
+ boolean
2547
+
2548
+
2549
+
2550
+ |
2551
+
2552
+ true
2553
+
2554
+ | Set boolean |
2555
+ | clearable |
2556
+
2557
+ If `true`, then user can clear the value of the input.
2558
+
2559
+ boolean
2560
+
2561
+
2562
+
2563
+ |
2564
+
2565
+ true
2566
+
2567
+ | Set boolean |
2568
+ | debounceThreshold |
2569
+
2570
+ number
2571
+
2572
+
2573
+
2574
+ | \- | |
2575
+ | errorText |
2576
+
2577
+ Text to be displayed when the options function errors out. It is not used when the options are provided as an array.
2578
+
2579
+ ReactNode
2580
+
2581
+
2582
+
2583
+ |
2584
+
2585
+ <IressAlert />
2586
+
2587
+
2588
+
2589
+ | Set object |
2590
+ | limitDesktop |
2591
+
2592
+ |
2593
+
2594
+ 12
2595
+
2596
+ | Set object |
2597
+ | limitMobile |
2598
+
2599
+ |
2600
+
2601
+ 6
2602
+
2603
+ | Set object |
2604
+ | noResultsText |
2605
+
2606
+ Text to be displayed when no results are found.
2607
+
2608
+ ReactNode
2609
+
2610
+
2611
+
2612
+ | \- | Set object |
2613
+ | onChange |
2614
+
2615
+ Emitted when the user changes the input. The second and third arguments are only available when the options were selected from the `options` prop.
2616
+
2617
+ ( e?: SyntheticEvent<InputBaseElement>, value?: T, option?: LabelValueMeta, ) => void
2618
+
2619
+ | \- | \- |
2620
+ | options |
2621
+
2622
+ array
2623
+
2624
+
2625
+
2626
+ | \- |
2627
+
2628
+ RAW
2629
+
2630
+ * options :
2631
+
2632
+ \[
2633
+
2634
+ * 0 :
2635
+
2636
+ {...} 1 key
2637
+
2638
+ * 1 :
2639
+
2640
+ {...} 1 key
2641
+
2642
+ * 2 :
2643
+
2644
+ {...} 1 key
2645
+
2646
+ * 3 :
2647
+
2648
+ {...} 1 key
2649
+
2650
+ * 4 :
2651
+
2652
+ {...} 1 key
2653
+
2654
+
2655
+ \]
2656
+
2657
+
2658
+
2659
+
2660
+ |
2661
+ | placeholder |
2662
+
2663
+ string
2664
+
2665
+
2666
+
2667
+ | \- | Instant search! |
2668
+ | popoverProps |
2669
+
2670
+ Customise the IressInputPopover props for your needs.
2671
+
2672
+ AutocompletePopoverProps
2673
+
2674
+
2675
+
2676
+ | { } |
2677
+
2678
+ RAW
2679
+
2680
+ popoverProps :
2681
+
2682
+ {
2683
+
2684
+ }
2685
+
2686
+
2687
+
2688
+
2689
+
2690
+
2691
+
2692
+ |
2693
+
2694
+ ### Result limits
2695
+
2696
+ You can limit the maximum amount of search results displayed in the suggestions by setting the `limitDesktop` prop. This defaults to 12.
2697
+
2698
+ On smaller screens (< 768px), the number of options is further reduced by using the `limitMobile` prop, which defaults to 6.
2699
+
2700
+ `limitMobile` works by filtering the search results that have been filtered by `limitDesktop`, so must be a smaller value. For example:
2701
+
2702
+ // 12 results on large screens, 6 on small screens (default values)
2703
+ <IressAutocomplete options\={...} />
2704
+ // 4 results on large screens, 3 on small screens
2705
+ <IressAutocomplete resultLimitDesktop\={4} resultLimitMobile\={3} options\={...} />
2706
+ // 4 results on all screens (resultLimitMobile > resultLimitDesktop so has no effect)
2707
+ <IressAutocomplete resultLimitDesktop\={4} resultLimitMobile\={5} options\={...} />
2708
+
2709
+ ```
2710
+
2711
+ The result limits will also affect the number of initial options displayed, if the `initialOptions` prop is set.
2712
+
2713
+ [](./iframe.html?id=components-autocomplete--result-limits)
2714
+
2715
+ **xl** breakpoint (1200px - 1499px)
2716
+
2717
+ ```
2718
+
2719
+ <IressStack gap\="md"\>
2720
+ <IressPanel\>
2721
+ <kn />
2722
+ </IressPanel\>
2723
+ <IressAutocomplete
2724
+ limitDesktop\={6}
2725
+ limitMobile\={3}
2726
+ options\={\[
2727
+ {
2728
+ label: 'Option 1'
2729
+ },
2730
+ {
2731
+ label: 'Option 2'
2732
+ },
2733
+ {
2734
+ label: 'Option 3'
2735
+ },
2736
+ {
2737
+ label: 'Option 4'
2738
+ },
2739
+ {
2740
+ label: 'Option 5'
2741
+ },
2742
+ {
2743
+ label: 'Option 6'
2744
+ },
2745
+ {
2746
+ label: 'Option 7'
2747
+ },
2748
+ {
2749
+ label: 'Option 8'
2750
+ },
2751
+ {
2752
+ label: 'Option 9'
2753
+ },
2754
+ {
2755
+ label: 'Option 10'
2756
+ },
2757
+ {
2758
+ label: 'Option 11'
2759
+ },
2760
+ {
2761
+ label: 'Option 12'
2762
+ },
2763
+ {
2764
+ label: 'Option 13'
2765
+ },
2766
+ {
2767
+ label: 'Option 14'
2768
+ },
2769
+ {
2770
+ label: 'Option 15'
2771
+ }
2772
+ \]}
2773
+ popoverProps\={{
2774
+ container: {}
2775
+ }}
2776
+ />
2777
+ </IressStack\>
2778
+
2779
+ ```
2780
+
2781
+ #### Props
2782
+
2783
+ | Name | Description | Default | Control |
2784
+ | --- | --- | --- | --- |
2785
+ | alwaysShowOnFocus |
2786
+ Always shown on focus, even if the user has not interacted with the input.
2787
+
2788
+ boolean
2789
+
2790
+
2791
+
2792
+ | \- | Set boolean |
2793
+ | append |
2794
+
2795
+ Append content.
2796
+
2797
+ ReactNode
2798
+
2799
+
2800
+
2801
+ |
2802
+
2803
+ <IressIcon />
2804
+
2805
+
2806
+
2807
+ | Set object |
2808
+ | autoComplete |
2809
+
2810
+ |
2811
+
2812
+ 'off'
2813
+
2814
+ | Set object |
2815
+ | autoSelect |
2816
+
2817
+ If true, the selected option becomes the value of the input when the autocomplete loses focus.
2818
+
2819
+ boolean
2820
+
2821
+
2822
+
2823
+ |
2824
+
2825
+ true
2826
+
2827
+ | Set boolean |
2828
+ | clearable |
2829
+
2830
+ If `true`, then user can clear the value of the input.
2831
+
2832
+ boolean
2833
+
2834
+
2835
+
2836
+ |
2837
+
2838
+ true
2839
+
2840
+ | Set boolean |
2841
+ | errorText |
2842
+
2843
+ Text to be displayed when the options function errors out. It is not used when the options are provided as an array.
2844
+
2845
+ ReactNode
2846
+
2847
+
2848
+
2849
+ |
2850
+
2851
+ <IressAlert />
2852
+
2853
+
2854
+
2855
+ | Set object |
2856
+ | limitDesktop |
2857
+
2858
+ number
2859
+
2860
+
2861
+
2862
+ |
2863
+
2864
+ 12
2865
+
2866
+ | |
2867
+ | limitMobile |
2868
+
2869
+ number
2870
+
2871
+
2872
+
2873
+ |
2874
+
2875
+ 6
2876
+
2877
+ | |
2878
+ | noResultsText |
2879
+
2880
+ Text to be displayed when no results are found.
2881
+
2882
+ ReactNode
2883
+
2884
+
2885
+
2886
+ | \- | Set object |
2887
+ | onChange |
2888
+
2889
+ Emitted when the user changes the input. The second and third arguments are only available when the options were selected from the `options` prop.
2890
+
2891
+ ( e?: SyntheticEvent<InputBaseElement>, value?: T, option?: LabelValueMeta, ) => void
2892
+
2893
+ | \- | \- |
2894
+ | options |
2895
+
2896
+ array
2897
+
2898
+
2899
+
2900
+ | \- |
2901
+
2902
+ RAW
2903
+
2904
+ * options :
2905
+
2906
+ \[
2907
+
2908
+ * 0 :
2909
+
2910
+ {...} 1 key
2911
+
2912
+ * 1 :
2913
+
2914
+ {...} 1 key
2915
+
2916
+ * 2 :
2917
+
2918
+ {...} 1 key
2919
+
2920
+ * 3 :
2921
+
2922
+ {...} 1 key
2923
+
2924
+ * 4 :
2925
+
2926
+ {...} 1 key
2927
+
2928
+ * 5 :
2929
+
2930
+ {...} 1 key
2931
+
2932
+ * 6 :
2933
+
2934
+ {...} 1 key
2935
+
2936
+ * 7 :
2937
+
2938
+ {...} 1 key
2939
+
2940
+ * 8 :
2941
+
2942
+ {...} 1 key
2943
+
2944
+ * 9 :
2945
+
2946
+ {...} 1 key
2947
+
2948
+ * 10 :
2949
+
2950
+ {...} 1 key
2951
+
2952
+ * 11 :
2953
+
2954
+ {...} 1 key
2955
+
2956
+ * 12 :
2957
+
2958
+ {...} 1 key
2959
+
2960
+ * 13 :
2961
+
2962
+ {...} 1 key
2963
+
2964
+ * 14 :
2965
+
2966
+ {...} 1 key
2967
+
2968
+
2969
+ \]
2970
+
2971
+
2972
+
2973
+
2974
+ |
2975
+ | popoverProps |
2976
+
2977
+ Customise the IressInputPopover props for your needs.
2978
+
2979
+ AutocompletePopoverProps
2980
+
2981
+
2982
+
2983
+ | { } |
2984
+
2985
+ RAW
2986
+
2987
+ popoverProps :
2988
+
2989
+ {
2990
+
2991
+ }
2992
+
2993
+
2994
+
2995
+
2996
+
2997
+
2998
+
2999
+ |
3000
+
3001
+ ### Read only
3002
+
3003
+ The `readOnly` prop can be set to `true` to prevent the user from changing the value of the autocomplete. This will change the input to a custom read-only style and the user will not be able to interact with the input.
3004
+
3005
+ If you need more control over the read-only state (for example, rendering a stylised version of the value), you can use the [`IressReadonly` component](?path=/docs/components-readonly--docs).
3006
+
3007
+ [](./iframe.html?id=components-autocomplete--read-only)
3008
+
3009
+ Option 1
3010
+
3011
+ ```
3012
+
3013
+ <IressAutocomplete
3014
+ defaultValue\="Option 1"
3015
+ options\={\[
3016
+ {
3017
+ label: 'Option 1'
3018
+ },
3019
+ {
3020
+ label: 'Option 2'
3021
+ },
3022
+ {
3023
+ label: 'Option 3'
3024
+ },
3025
+ {
3026
+ label: 'Option 4'
3027
+ },
3028
+ {
3029
+ label: 'Option 5'
3030
+ }
3031
+ \]}
3032
+ popoverProps\={{
3033
+ container: {}
3034
+ }}
3035
+ readOnly
3036
+ />
3037
+
3038
+ ```
3039
+
3040
+ #### Props
3041
+
3042
+ | Name | Description | Default | Control |
3043
+ | --- | --- | --- | --- |
3044
+ | alwaysShowOnFocus |
3045
+ Always shown on focus, even if the user has not interacted with the input.
3046
+
3047
+ boolean
3048
+
3049
+
3050
+
3051
+ | \- | Set boolean |
3052
+ | append |
3053
+
3054
+ Append content.
3055
+
3056
+ ReactNode
3057
+
3058
+
3059
+
3060
+ |
3061
+
3062
+ <IressIcon />
3063
+
3064
+
3065
+
3066
+ | Set object |
3067
+ | autoComplete |
3068
+
3069
+ |
3070
+
3071
+ 'off'
3072
+
3073
+ | Set object |
3074
+ | autoSelect |
3075
+
3076
+ If true, the selected option becomes the value of the input when the autocomplete loses focus.
3077
+
3078
+ boolean
3079
+
3080
+
3081
+
3082
+ |
3083
+
3084
+ true
3085
+
3086
+ | Set boolean |
3087
+ | clearable |
3088
+
3089
+ If `true`, then user can clear the value of the input.
3090
+
3091
+ boolean
3092
+
3093
+
3094
+
3095
+ |
3096
+
3097
+ true
3098
+
3099
+ | Set boolean |
3100
+ | defaultValue |
3101
+
3102
+ string
3103
+
3104
+
3105
+
3106
+ | \- | Option 1 |
3107
+ | errorText |
3108
+
3109
+ Text to be displayed when the options function errors out. It is not used when the options are provided as an array.
3110
+
3111
+ ReactNode
3112
+
3113
+
3114
+
3115
+ |
3116
+
3117
+ <IressAlert />
3118
+
3119
+
3120
+
3121
+ | Set object |
3122
+ | limitDesktop |
3123
+
3124
+ |
3125
+
3126
+ 12
3127
+
3128
+ | Set object |
3129
+ | limitMobile |
3130
+
3131
+ |
3132
+
3133
+ 6
3134
+
3135
+ | Set object |
3136
+ | noResultsText |
3137
+
3138
+ Text to be displayed when no results are found.
3139
+
3140
+ ReactNode
3141
+
3142
+
3143
+
3144
+ | \- | Set object |
3145
+ | onChange |
3146
+
3147
+ Emitted when the user changes the input. The second and third arguments are only available when the options were selected from the `options` prop.
3148
+
3149
+ ( e?: SyntheticEvent<InputBaseElement>, value?: T, option?: LabelValueMeta, ) => void
3150
+
3151
+ | \- | \- |
3152
+ | options |
3153
+
3154
+ array
3155
+
3156
+
3157
+
3158
+ | \- |
3159
+
3160
+ RAW
3161
+
3162
+ * options :
3163
+
3164
+ \[
3165
+
3166
+ * 0 :
3167
+
3168
+ {...} 1 key
3169
+
3170
+ * 1 :
3171
+
3172
+ {...} 1 key
3173
+
3174
+ * 2 :
3175
+
3176
+ {...} 1 key
3177
+
3178
+ * 3 :
3179
+
3180
+ {...} 1 key
3181
+
3182
+ * 4 :
3183
+
3184
+ {...} 1 key
3185
+
3186
+
3187
+ \]
3188
+
3189
+
3190
+
3191
+
3192
+ |
3193
+ | popoverProps |
3194
+
3195
+ Customise the IressInputPopover props for your needs.
3196
+
3197
+ AutocompletePopoverProps
3198
+
3199
+
3200
+
3201
+ | { } |
3202
+
3203
+ RAW
3204
+
3205
+ popoverProps :
3206
+
3207
+ {
3208
+
3209
+ }
3210
+
3211
+
3212
+
3213
+
3214
+
3215
+
3216
+
3217
+ |
3218
+ | readOnly |
3219
+
3220
+ boolean
3221
+
3222
+
3223
+
3224
+ | \- | FalseTrue |
3225
+
3226
+ Testing
3227
+ -------
3228
+
3229
+ To help you effectively test the autocomplete component, we have provided a few tips based on the behaviour of the component and our own experience.
3230
+
3231
+ **Note:** These are suggestions and not requirements. You should test the component in a way that best suits your use case.
3232
+
3233
+ ### Partial query matching
3234
+
3235
+ The suggestions are filtered based on the input value. If the input value only matches a part of the option, the input value is highlighted by a `<b />` tag in each option. You will need to account for this in your tests, either using an exact string match with a space to denote the highlighted value, or using a regex to match the string.
3236
+
3237
+ If you are using `meta`, `prepend` or `append` props in `LabelValueMeta`, you should also consider this in your search query for the option.
3238
+
3239
+ render(
3240
+ <IressAutocomplete
3241
+ options\={\[
3242
+ { label: 'Luke Skywalker', value: 'Luke Skywalker', meta: 'male' },
3243
+ \]}
3244
+ />,
3245
+ );
3246
+ const autocomplete \= screen.getByRole('combobox');
3247
+ await user.type(autocomplete, 'lu');
3248
+ // Exact string match with a space to denote the highlighted value
3249
+ const option \= await screen.findByRole('option', {
3250
+ name: 'Lu ke Skywalker male',
3251
+ });
3252
+ expect(option).toBeInTheDocument();
3253
+ // Using a regex to match the string
3254
+ const option \= await screen.findByRole('option', { name: /Skywalker/ });
3255
+ expect(option).toBeInTheDocument();
3256
+
3257
+ ```
3258
+
3259
+ ### Query for minimal characters
3260
+
3261
+ If you are testing if a specific option appears in the autocomplete that returns asynchronous `options`, it is recommended to use the shortest possible query to return the desired result. The longer the query, the longer it will take to see the results.
3262
+
3263
+ render(<IressAutocomplete options\={searchStarWarsCharacters} />);
3264
+ const autocomplete \= screen.getByRole('combobox');
3265
+ // DO: Use the shortest query to return the desired result
3266
+ await user.type(autocomplete, 'lu');
3267
+ const option \= await screen.findAllByRole('option');
3268
+ // DON'T: Use a long query to return the desired result
3269
+ await user.type(autocomplete, 'luke skywalker');
3270
+ const option \= await screen.findAllByRole('option');
3271
+
3272
+ ```
3273
+
3274
+ ### Use mocking when testing APIs
3275
+
3276
+ When testing the autocomplete component with asynchronous `options`, you should mock the API call to return a known set of results, rather than rely on a public prototyping API (eg. [https://swapi.py4e.com/](https://swapi.py4e.com/)). This will allow you to test the component in isolation without relying on the API to return the expected results, as well as reduce chance of flakiness due to timeouts in your tests.
3277
+
3278
+ We recommend using [Mock Service Worker](https://mswjs.io/) to mock the API calls in your tests.
3279
+
3280
+ // src/mocks/handlers.ts
3281
+ import { http, HttpResponse } from 'msw';
3282
+ export const handlers \= \[
3283
+ // Intercept "GET https://swapi.py4e.com/api/people" requests...
3284
+ http.get('https://swapi.py4e.com/api/people', () \=> {
3285
+ // ...and respond to them using this JSON response.
3286
+ return HttpResponse.json(\[
3287
+ { name: 'Luke Skywalker', gender: 'male' },
3288
+ { name: 'Leia Skywalker', gender: 'female' },
3289
+ \]);
3290
+ }),
3291
+ \];
3292
+ // src/mocks/node.js
3293
+ import { setupServer } from 'msw/node';
3294
+ import { handlers } from './handlers';
3295
+ export const server \= setupServer(...handlers);
3296
+ // src/CustomAutocomplete.test.tsx
3297
+ import { server } from './mocks/node';
3298
+ server.listen();
3299
+ render(<IressAutocomplete options\={searchStarWarsCharacters} />);
3300
+ const autocomplete \= screen.getByRole('combobox');
3301
+ await user.type(autocomplete, 'lu');
3302
+ const option \= await screen.findAllByRole('option');
3303
+
3304
+ ```