@exhaustive-ui/mcp 0.0.0-stage → 3.0.0-alpha.1

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 (121) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +167 -2
  3. package/data/components/accordion.md +421 -0
  4. package/data/components/animateonscroll.md +163 -0
  5. package/data/components/autocomplete.md +1077 -0
  6. package/data/components/autofocus.md +38 -0
  7. package/data/components/avatar.md +417 -0
  8. package/data/components/badge.md +234 -0
  9. package/data/components/blockui.md +108 -0
  10. package/data/components/breadcrumb.md +178 -0
  11. package/data/components/button.md +774 -0
  12. package/data/components/card.md +138 -0
  13. package/data/components/carousel.md +440 -0
  14. package/data/components/cascadeselect.md +1387 -0
  15. package/data/components/chart.md +1178 -0
  16. package/data/components/checkbox.md +529 -0
  17. package/data/components/chip.md +180 -0
  18. package/data/components/colorpicker.md +301 -0
  19. package/data/components/confirmdialog.md +287 -0
  20. package/data/components/confirmpopup.md +417 -0
  21. package/data/components/contextmenu.md +491 -0
  22. package/data/components/dataview.md +600 -0
  23. package/data/components/datepicker.md +1262 -0
  24. package/data/components/dialog.md +622 -0
  25. package/data/components/divider.md +250 -0
  26. package/data/components/dock.md +500 -0
  27. package/data/components/dragdrop.md +285 -0
  28. package/data/components/drawer.md +510 -0
  29. package/data/components/dynamicdialog.md +109 -0
  30. package/data/components/editor.md +291 -0
  31. package/data/components/fieldset.md +182 -0
  32. package/data/components/fileupload.md +430 -0
  33. package/data/components/floatlabel.md +155 -0
  34. package/data/components/fluid.md +72 -0
  35. package/data/components/focustrap.md +65 -0
  36. package/data/components/galleria.md +627 -0
  37. package/data/components/iconfield.md +246 -0
  38. package/data/components/iftalabel.md +105 -0
  39. package/data/components/imagecompare.md +97 -0
  40. package/data/components/inplace.md +233 -0
  41. package/data/components/inputgroup.md +306 -0
  42. package/data/components/inputmask.md +518 -0
  43. package/data/components/inputnumber.md +675 -0
  44. package/data/components/inputotp.md +336 -0
  45. package/data/components/inputtext.md +488 -0
  46. package/data/components/keyfilter.md +85 -0
  47. package/data/components/knob.md +462 -0
  48. package/data/components/listbox.md +798 -0
  49. package/data/components/llms.md +28 -0
  50. package/data/components/megamenu.md +587 -0
  51. package/data/components/menu.md +483 -0
  52. package/data/components/menubar.md +462 -0
  53. package/data/components/message.md +449 -0
  54. package/data/components/metergroup.md +241 -0
  55. package/data/components/multiselect.md +1047 -0
  56. package/data/components/orderlist.md +342 -0
  57. package/data/components/organizationchart.md +197 -0
  58. package/data/components/overlay.md +217 -0
  59. package/data/components/paginator.md +314 -0
  60. package/data/components/panel.md +214 -0
  61. package/data/components/panelmenu.md +699 -0
  62. package/data/components/password.md +570 -0
  63. package/data/components/picklist.md +420 -0
  64. package/data/components/popover.md +378 -0
  65. package/data/components/progressbar.md +181 -0
  66. package/data/components/progressspinner.md +91 -0
  67. package/data/components/radiobutton.md +377 -0
  68. package/data/components/rating.md +312 -0
  69. package/data/components/ripple.md +89 -0
  70. package/data/components/scroller.md +122 -0
  71. package/data/components/scrollpanel.md +149 -0
  72. package/data/components/scrolltop.md +105 -0
  73. package/data/components/select.md +1206 -0
  74. package/data/components/selectbutton.md +356 -0
  75. package/data/components/skeleton.md +242 -0
  76. package/data/components/slider.md +337 -0
  77. package/data/components/speeddial.md +589 -0
  78. package/data/components/splitbutton.md +945 -0
  79. package/data/components/splitter.md +196 -0
  80. package/data/components/stepper.md +411 -0
  81. package/data/components/styleclass.md +126 -0
  82. package/data/components/table.md +4557 -0
  83. package/data/components/tabs.md +467 -0
  84. package/data/components/tag.md +200 -0
  85. package/data/components/terminal.md +118 -0
  86. package/data/components/textarea.md +416 -0
  87. package/data/components/tieredmenu.md +578 -0
  88. package/data/components/timeline.md +310 -0
  89. package/data/components/toast.md +596 -0
  90. package/data/components/togglebutton.md +356 -0
  91. package/data/components/toggleswitch.md +285 -0
  92. package/data/components/toolbar.md +182 -0
  93. package/data/components/tooltip.md +211 -0
  94. package/data/components/tree.md +746 -0
  95. package/data/components/treeselect.md +912 -0
  96. package/data/components/treetable.md +2814 -0
  97. package/data/components.json +43751 -0
  98. package/data/llms-full.txt +47433 -0
  99. package/data/llms.txt +121 -0
  100. package/data/manifest.json +46513 -0
  101. package/data/pages/accessibility.md +28 -0
  102. package/data/pages/animations.md +28 -0
  103. package/data/pages/configuration.md +210 -0
  104. package/data/pages/contribution.md +20 -0
  105. package/data/pages/customicons.md +20 -0
  106. package/data/pages/faq.md +20 -0
  107. package/data/pages/icons.md +66 -0
  108. package/data/pages/installation.md +71 -0
  109. package/data/pages/llms.md +61 -0
  110. package/data/pages/passthrough.md +32 -0
  111. package/data/pages/philosophy.md +28 -0
  112. package/data/pages/primeflex.md +20 -0
  113. package/data/pages/rtl.md +12 -0
  114. package/data/pages/styled.md +132 -0
  115. package/data/pages/tailwind.md +40 -0
  116. package/data/pages/unstyled.md +39 -0
  117. package/data/snapshot.json +9 -0
  118. package/dist/index.d.mts +448 -0
  119. package/dist/index.mjs +2501 -0
  120. package/dist/index.mjs.map +1 -0
  121. package/package.json +67 -3
@@ -0,0 +1,798 @@
1
+ # Angular Listbox Component
2
+
3
+ Listbox is used to select one or more values from a list of items.
4
+
5
+ ## Accessibility
6
+
7
+ Screen Reader Value to describe the component can be provided ariaLabelledBy or ariaLabel props. The list element has a listbox role with the aria-multiselectable attribute that sets to true when multiple selection is enabled. Each list item has an option role with aria-selected and aria-disabled as their attributes.
8
+
9
+ ## Basic
10
+
11
+ Listbox is used as a controlled component with ngModel property along with an options collection. Label and value of an option are defined with the optionLabel and optionValue properties respectively. Default property name for the optionLabel is label and value for the optionValue . If optionValue is omitted and the object has no value property, the object itself becomes the value of an option. Note that, when options are simple primitive values such as a string array, no optionLabel and optionValue would be necessary.
12
+
13
+ ```typescript
14
+ import { Component, OnInit } from '@angular/core';
15
+ import { FormsModule } from '@angular/forms';
16
+ import { ListboxModule } from '@exhaustive-ui/core/listbox';
17
+
18
+ interface City {
19
+ name: string;
20
+ code: string;
21
+ }
22
+
23
+ @Component({
24
+ template: `
25
+ <div class="card flex justify-center">
26
+ <p-listbox [options]="cities" [(ngModel)]="selectedCity" optionLabel="name" class="w-full md:w-56" />
27
+ </div>
28
+ `,
29
+ standalone: true,
30
+ imports: [ListboxModule, FormsModule]
31
+ })
32
+ export class ListboxBasicDemo implements OnInit {
33
+ cities!: City[];
34
+ selectedCity!: City;
35
+
36
+ ngOnInit() {
37
+ this.cities = [
38
+ { name: 'New York', code: 'NY' },
39
+ { name: 'Rome', code: 'RM' },
40
+ { name: 'London', code: 'LDN' },
41
+ { name: 'Istanbul', code: 'IST' },
42
+ { name: 'Paris', code: 'PRS' }
43
+ ];
44
+ }
45
+ }
46
+ ```
47
+
48
+ ## Checkbox
49
+
50
+ Listbox allows item selection using checkboxes.
51
+
52
+ ```typescript
53
+ import { Component, OnInit } from '@angular/core';
54
+ import { FormsModule } from '@angular/forms';
55
+ import { ListboxModule } from '@exhaustive-ui/core/listbox';
56
+
57
+ interface City {
58
+ name: string;
59
+ code: string;
60
+ }
61
+
62
+ @Component({
63
+ template: `
64
+ <div class="card flex justify-center">
65
+ <p-listbox [(ngModel)]="selectedCity" [options]="cities" [multiple]="true" [checkbox]="true" optionLabel="name" class="w-full md:w-56" />
66
+ </div>
67
+ `,
68
+ standalone: true,
69
+ imports: [ListboxModule, FormsModule]
70
+ })
71
+ export class ListboxCheckboxDemo implements OnInit {
72
+ cities!: City[];
73
+ selectedCity!: City;
74
+
75
+ ngOnInit() {
76
+ this.cities = [
77
+ { name: 'New York', code: 'NY' },
78
+ { name: 'Rome', code: 'RM' },
79
+ { name: 'London', code: 'LDN' },
80
+ { name: 'Istanbul', code: 'IST' },
81
+ { name: 'Paris', code: 'PRS' }
82
+ ];
83
+ }
84
+ }
85
+ ```
86
+
87
+ ## Checkmark
88
+
89
+ An alternative way to highlight the selected option is displaying a checkmark instead.
90
+
91
+ ```typescript
92
+ import { Component, OnInit } from '@angular/core';
93
+ import { FormsModule } from '@angular/forms';
94
+ import { ListboxModule } from '@exhaustive-ui/core/listbox';
95
+
96
+ interface City {
97
+ name: string;
98
+ code: string;
99
+ }
100
+
101
+ @Component({
102
+ template: `
103
+ <div class="card flex justify-center">
104
+ <p-listbox [(ngModel)]="selectedCity" [options]="cities" optionLabel="name" [checkmark]="true" [highlightOnSelect]="false" class="w-full md:w-56" />
105
+ </div>
106
+ `,
107
+ standalone: true,
108
+ imports: [ListboxModule, FormsModule]
109
+ })
110
+ export class ListboxCheckmarkDemo implements OnInit {
111
+ cities!: City[];
112
+ selectedCity!: City;
113
+
114
+ ngOnInit() {
115
+ this.cities = [
116
+ { name: 'New York', code: 'NY' },
117
+ { name: 'Rome', code: 'RM' },
118
+ { name: 'London', code: 'LDN' },
119
+ { name: 'Istanbul', code: 'IST' },
120
+ { name: 'Paris', code: 'PRS' }
121
+ ];
122
+ }
123
+ }
124
+ ```
125
+
126
+ ## Disabled
127
+
128
+ When disabled is present, the element cannot be edited and focused.
129
+
130
+ ```typescript
131
+ import { Component, OnInit } from '@angular/core';
132
+ import { FormsModule } from '@angular/forms';
133
+ import { ListboxModule } from '@exhaustive-ui/core/listbox';
134
+
135
+ interface City {
136
+ name: string;
137
+ code: string;
138
+ }
139
+
140
+ @Component({
141
+ template: `
142
+ <div class="card flex justify-center">
143
+ <p-listbox [options]="cities" [(ngModel)]="selectedCity" optionLabel="name" [disabled]="true" class="w-full md:w-56" />
144
+ </div>
145
+ `,
146
+ standalone: true,
147
+ imports: [ListboxModule, FormsModule]
148
+ })
149
+ export class ListboxDisabledDemo implements OnInit {
150
+ cities!: City[];
151
+ selectedCity!: City;
152
+
153
+ ngOnInit() {
154
+ this.cities = [
155
+ { name: 'New York', code: 'NY' },
156
+ { name: 'Rome', code: 'RM' },
157
+ { name: 'London', code: 'LDN' },
158
+ { name: 'Istanbul', code: 'IST' },
159
+ { name: 'Paris', code: 'PRS' }
160
+ ];
161
+ }
162
+ }
163
+ ```
164
+
165
+ ## dragdrop-doc
166
+
167
+ Items can be reordered using drag and drop by enabling dragdrop property. Depends on &#64;angular/cdk package.
168
+
169
+ ```typescript
170
+ import { Component, OnInit } from '@angular/core';
171
+ import { FormsModule } from '@angular/forms';
172
+ import { ListboxModule } from '@exhaustive-ui/core/listbox';
173
+
174
+ @Component({
175
+ template: `
176
+ <div class="card flex justify-center">
177
+ <p-listbox [options]="cities" [(ngModel)]="selectedCity" optionLabel="name" [dragdrop]="true" class="w-full md:w-56" />
178
+ </div>
179
+ `,
180
+ standalone: true,
181
+ imports: [ListboxModule, FormsModule]
182
+ })
183
+ export class ListboxDragdropDemo implements OnInit {
184
+ cities!: any[];
185
+ selectedCity!: any;
186
+
187
+ ngOnInit() {
188
+ this.cities = [
189
+ { name: 'New York', code: 'NY' },
190
+ { name: 'Rome', code: 'RM' },
191
+ { name: 'London', code: 'LDN' },
192
+ { name: 'Istanbul', code: 'IST' },
193
+ { name: 'Paris', code: 'PRS' }
194
+ ];
195
+ }
196
+ }
197
+ ```
198
+
199
+ ## Filter
200
+
201
+ ListBox provides built-in filtering that is enabled by adding the filter property.
202
+
203
+ ```typescript
204
+ import { Component, OnInit } from '@angular/core';
205
+ import { FormsModule } from '@angular/forms';
206
+ import { ListboxModule } from '@exhaustive-ui/core/listbox';
207
+
208
+ interface City {
209
+ name: string;
210
+ code: string;
211
+ }
212
+
213
+ @Component({
214
+ template: `
215
+ <div class="card flex justify-center">
216
+ <p-listbox [options]="cities" [(ngModel)]="selectedCity" optionLabel="name" [filter]="true" class="w-full md:w-56" />
217
+ </div>
218
+ `,
219
+ standalone: true,
220
+ imports: [ListboxModule, FormsModule]
221
+ })
222
+ export class ListboxFilterDemo implements OnInit {
223
+ cities!: City[];
224
+ selectedCity!: City;
225
+
226
+ ngOnInit() {
227
+ this.cities = [
228
+ { name: 'New York', code: 'NY' },
229
+ { name: 'Rome', code: 'RM' },
230
+ { name: 'London', code: 'LDN' },
231
+ { name: 'Istanbul', code: 'IST' },
232
+ { name: 'Paris', code: 'PRS' }
233
+ ];
234
+ }
235
+ }
236
+ ```
237
+
238
+ ## Group
239
+
240
+ Options can be grouped when a nested data structures is provided.
241
+
242
+ ```typescript
243
+ import { Component } from '@angular/core';
244
+ import { FormsModule } from '@angular/forms';
245
+ import { ListboxModule } from '@exhaustive-ui/core/listbox';
246
+ import { SelectItemGroup } from '@exhaustive-ui/core/api';
247
+ import { Country } from '@/domain/customer';
248
+
249
+ interface Country {
250
+ name: string;
251
+ code: string;
252
+ }
253
+
254
+ @Component({
255
+ template: `
256
+ <div class="card flex justify-center">
257
+ <p-listbox [options]="groupedCities" [group]="true" [(ngModel)]="selectedCountry" class="w-full md:w-56">
258
+ <ng-template let-group #group>
259
+ <div class="flex items-center">
260
+ <img src="https://exhaustive-ui.e-xiste.com/demo/flag/flag_placeholder.png" [class]="'mr-2 flag flag-' + group.value" style="width: 20px" />
261
+ <span>{{ group.label }}</span>
262
+ </div>
263
+ </ng-template>
264
+ </p-listbox>
265
+ </div>
266
+ `,
267
+ standalone: true,
268
+ imports: [ListboxModule, FormsModule]
269
+ })
270
+ export class ListboxGroupDemo {
271
+ groupedCities!: SelectItemGroup[];
272
+ selectedCountry!: Country;
273
+
274
+ constructor() {
275
+ this.groupedCities = [
276
+ {
277
+ label: 'Germany',
278
+ value: 'de',
279
+ items: [
280
+ { label: 'Berlin', value: 'Berlin' },
281
+ { label: 'Frankfurt', value: 'Frankfurt' },
282
+ { label: 'Hamburg', value: 'Hamburg' },
283
+ { label: 'Munich', value: 'Munich' }
284
+ ]
285
+ },
286
+ {
287
+ label: 'USA',
288
+ value: 'us',
289
+ items: [
290
+ { label: 'Chicago', value: 'Chicago' },
291
+ { label: 'Los Angeles', value: 'Los Angeles' },
292
+ { label: 'New York', value: 'New York' },
293
+ { label: 'San Francisco', value: 'San Francisco' }
294
+ ]
295
+ },
296
+ {
297
+ label: 'Japan',
298
+ value: 'jp',
299
+ items: [
300
+ { label: 'Kyoto', value: 'Kyoto' },
301
+ { label: 'Osaka', value: 'Osaka' },
302
+ { label: 'Tokyo', value: 'Tokyo' },
303
+ { label: 'Yokohama', value: 'Yokohama' }
304
+ ]
305
+ }
306
+ ];
307
+ }
308
+ }
309
+ ```
310
+
311
+ ## Invalid
312
+
313
+ The invalid state is applied using the ⁠invalid property to indicate failed validation, which can be integrated with Angular Forms.
314
+
315
+ ```typescript
316
+ import { Component, OnInit } from '@angular/core';
317
+ import { FormsModule } from '@angular/forms';
318
+ import { ListboxModule } from '@exhaustive-ui/core/listbox';
319
+
320
+ interface City {
321
+ name: string;
322
+ code: string;
323
+ }
324
+
325
+ @Component({
326
+ template: `
327
+ <div class="card flex justify-center">
328
+ <p-listbox [options]="cities" [(ngModel)]="selectedCity" optionLabel="name" class="w-full md:w-56" [invalid]="selectedCity === undefined" />
329
+ </div>
330
+ `,
331
+ standalone: true,
332
+ imports: [ListboxModule, FormsModule]
333
+ })
334
+ export class ListboxInvalidDemo implements OnInit {
335
+ cities!: City[];
336
+ selectedCity!: City;
337
+
338
+ ngOnInit() {
339
+ this.cities = [
340
+ { name: 'New York', code: 'NY' },
341
+ { name: 'Rome', code: 'RM' },
342
+ { name: 'London', code: 'LDN' },
343
+ { name: 'Istanbul', code: 'IST' },
344
+ { name: 'Paris', code: 'PRS' }
345
+ ];
346
+ }
347
+ }
348
+ ```
349
+
350
+ ## Multiple
351
+
352
+ ListBox allows choosing a single item by default, enable multiple property to choose more than one. When the optional metaKeySelection is present, behavior is changed in a way that selecting a new item requires meta key to be present.
353
+
354
+ ```typescript
355
+ import { Component, OnInit } from '@angular/core';
356
+ import { FormsModule } from '@angular/forms';
357
+ import { ListboxModule } from '@exhaustive-ui/core/listbox';
358
+
359
+ interface City {
360
+ name: string;
361
+ code: string;
362
+ }
363
+
364
+ @Component({
365
+ template: `
366
+ <div class="card flex justify-center">
367
+ <p-listbox [options]="cities" [(ngModel)]="selectedCities" optionLabel="name" [multiple]="true" [metaKeySelection]="false" class="w-full md:w-56" />
368
+ </div>
369
+ `,
370
+ standalone: true,
371
+ imports: [ListboxModule, FormsModule]
372
+ })
373
+ export class ListboxMultipleDemo implements OnInit {
374
+ cities!: City[];
375
+ selectedCities!: City[];
376
+
377
+ ngOnInit() {
378
+ this.cities = [
379
+ { name: 'New York', code: 'NY' },
380
+ { name: 'Rome', code: 'RM' },
381
+ { name: 'London', code: 'LDN' },
382
+ { name: 'Istanbul', code: 'IST' },
383
+ { name: 'Paris', code: 'PRS' }
384
+ ];
385
+ }
386
+ }
387
+ ```
388
+
389
+ ## reactiveforms-doc
390
+
391
+ Listbox can also be used with reactive forms. In this case, the formControlName property is used to bind the component to a form control.
392
+
393
+ ```typescript
394
+ import { Component, inject } from '@angular/core';
395
+ import { ReactiveFormsModule } from '@angular/forms';
396
+ import { ListboxModule } from '@exhaustive-ui/core/listbox';
397
+ import { MessageModule } from '@exhaustive-ui/core/message';
398
+ import { ToastModule } from '@exhaustive-ui/core/toast';
399
+ import { ButtonModule } from '@exhaustive-ui/core/button';
400
+ import { MessageService } from '@exhaustive-ui/core/api';
401
+
402
+ interface City {
403
+ name: string;
404
+ code: string;
405
+ }
406
+
407
+ @Component({
408
+ template: `
409
+ <p-toast />
410
+ <div class="card flex justify-center">
411
+ <form [formGroup]="exampleForm" (ngSubmit)="onSubmit()" class="flex flex-col gap-4 sm:w-56">
412
+ <div class="flex flex-col gap-1">
413
+ <p-listbox [options]="cities" formControlName="selectedCity" optionLabel="name" class="w-full md:w-56" [invalid]="isInvalid('selectedCity')" />
414
+ @if (isInvalid('selectedCity')) {
415
+ <p-message severity="error" size="small" variant="simple">City is required.</p-message>
416
+ }
417
+ </div>
418
+ <button pButton severity="secondary" type="submit"><span pButtonLabel>Submit</span></button>
419
+ </form>
420
+ </div>
421
+ `,
422
+ standalone: true,
423
+ imports: [ListboxModule, MessageModule, ToastModule, ButtonModule, ReactiveFormsModule]
424
+ })
425
+ export class ListboxReactiveformsDemo {
426
+ messageService = inject(MessageService);
427
+ exampleForm: FormGroup | undefined;
428
+ formSubmitted: boolean = false;
429
+ cities!: City[];
430
+
431
+ constructor() {
432
+ this.cities = [
433
+ { name: 'New York', code: 'NY' },
434
+ { name: 'Rome', code: 'RM' },
435
+ { name: 'London', code: 'LDN' },
436
+ { name: 'Istanbul', code: 'IST' },
437
+ { name: 'Paris', code: 'PRS' }
438
+ ];
439
+ this.exampleForm = this.fb.group({
440
+ selectedCity: ['', Validators.required]
441
+ });
442
+ }
443
+
444
+ onSubmit() {
445
+ this.formSubmitted = true;
446
+ if (this.exampleForm.valid) {
447
+ this.messageService.add({ severity: 'success', summary: 'Success', detail: 'Form is submitted', life: 3000 });
448
+ this.exampleForm.reset();
449
+ this.formSubmitted = false;
450
+ }
451
+ }
452
+
453
+ isInvalid(controlName: string) {
454
+ const control = this.exampleForm.get(controlName);
455
+ return control?.invalid && this.formSubmitted;
456
+ }
457
+ }
458
+ ```
459
+
460
+ ## Template
461
+
462
+ For custom content support define a template named item where the default local template variable refers to an option.
463
+
464
+ ```typescript
465
+ import { Component, OnInit } from '@angular/core';
466
+ import { FormsModule } from '@angular/forms';
467
+ import { ListboxModule } from '@exhaustive-ui/core/listbox';
468
+ import { Country } from '@/domain/customer';
469
+
470
+ interface Country {
471
+ name: string;
472
+ code: string;
473
+ }
474
+
475
+ @Component({
476
+ template: `
477
+ <div class="card flex justify-center">
478
+ <p-listbox [options]="countries" [(ngModel)]="selectedCountry" optionLabel="name" class="w-full md:w-56">
479
+ <ng-template #item let-country>
480
+ <div class="flex items-center gap-2">
481
+ <img src="https://exhaustive-ui.e-xiste.com/demo/flag/flag_placeholder.png" [class]="'flag flag-' + country.code.toLowerCase()" style="width: 18px" />
482
+ <div>{{ country.name }}</div>
483
+ </div>
484
+ </ng-template>
485
+ </p-listbox>
486
+ </div>
487
+ `,
488
+ standalone: true,
489
+ imports: [ListboxModule, FormsModule]
490
+ })
491
+ export class ListboxTemplateDemo implements OnInit {
492
+ countries!: Country[];
493
+ selectedCountry!: Country;
494
+
495
+ ngOnInit() {
496
+ this.countries = [
497
+ { name: 'Australia', code: 'AU' },
498
+ { name: 'Brazil', code: 'BR' },
499
+ { name: 'China', code: 'CN' },
500
+ { name: 'Egypt', code: 'EG' },
501
+ { name: 'France', code: 'FR' },
502
+ { name: 'Germany', code: 'DE' },
503
+ { name: 'India', code: 'IN' },
504
+ { name: 'Japan', code: 'JP' },
505
+ { name: 'Spain', code: 'ES' },
506
+ { name: 'United States', code: 'US' }
507
+ ];
508
+ }
509
+ }
510
+ ```
511
+
512
+ ## templatedrivenforms-doc
513
+
514
+ ```typescript
515
+ import { Component, OnInit, inject } from '@angular/core';
516
+ import { FormsModule } from '@angular/forms';
517
+ import { ListboxModule } from '@exhaustive-ui/core/listbox';
518
+ import { MessageModule } from '@exhaustive-ui/core/message';
519
+ import { ToastModule } from '@exhaustive-ui/core/toast';
520
+ import { ButtonModule } from '@exhaustive-ui/core/button';
521
+ import { MessageService } from '@exhaustive-ui/core/api';
522
+
523
+ interface City {
524
+ name: string;
525
+ code: string;
526
+ }
527
+
528
+ @Component({
529
+ template: `
530
+ <p-toast />
531
+ <div class="card flex justify-center">
532
+ <form #exampleForm="ngForm" (ngSubmit)="onSubmit(exampleForm)" class="flex justify-center flex-col gap-4 md:w-56">
533
+ <div class="flex flex-col gap-1">
534
+ <p-listbox #city="ngModel" [options]="cities" [(ngModel)]="selectedCity" optionLabel="name" class="w-full md:w-56" [invalid]="city.invalid && exampleForm.submitted" name="city" required />
535
+ @if (city.invalid && exampleForm.submitted) {
536
+ <p-message severity="error" size="small" variant="simple">City is required.</p-message>
537
+ }
538
+ </div>
539
+ <button pButton severity="secondary" type="submit"><span pButtonLabel>Submit</span></button>
540
+ </form>
541
+ </div>
542
+ `,
543
+ standalone: true,
544
+ imports: [ListboxModule, MessageModule, ToastModule, ButtonModule, FormsModule]
545
+ })
546
+ export class ListboxTemplatedrivenformsDemo implements OnInit {
547
+ messageService = inject(MessageService);
548
+ selectedCity!: City;
549
+ cities!: City[];
550
+
551
+ ngOnInit() {
552
+ this.cities = [
553
+ { name: 'New York', code: 'NY' },
554
+ { name: 'Rome', code: 'RM' },
555
+ { name: 'London', code: 'LDN' },
556
+ { name: 'Istanbul', code: 'IST' },
557
+ { name: 'Paris', code: 'PRS' }
558
+ ];
559
+ }
560
+
561
+ onSubmit(form: any) {
562
+ if (form.valid) {
563
+ this.messageService.add({ severity: 'success', summary: 'Success', detail: 'Form Submitted', life: 3000 });
564
+ form.resetForm();
565
+ }
566
+ }
567
+ }
568
+ ```
569
+
570
+ ## Virtual Scroll
571
+
572
+ VirtualScrolling is an efficient way of rendering the options by displaying a small subset of data in the viewport at any time. When dealing with huge number of options, it is suggested to enable VirtualScrolling to avoid performance issues. Usage is simple as setting virtualScroll property to true and defining virtualScrollItemSize to specify the height of an item.
573
+
574
+ ```typescript
575
+ import { Component } from '@angular/core';
576
+ import { FormsModule } from '@angular/forms';
577
+ import { ListboxModule } from '@exhaustive-ui/core/listbox';
578
+
579
+ @Component({
580
+ template: `
581
+ <div class="card flex justify-center">
582
+ <p-listbox
583
+ [options]="items"
584
+ [(ngModel)]="selectedItems"
585
+ [selectAll]="selectAll"
586
+ [filter]="true"
587
+ [checkbox]="true"
588
+ optionLabel="label"
589
+ [virtualScroll]="true"
590
+ [virtualScrollItemSize]="40"
591
+ [multiple]="true"
592
+ [metaKeySelection]="false"
593
+ (onSelectAllChange)="onSelectAllChange($event)"
594
+ (onChange)="onChange($event)"
595
+ scrollHeight="250px"
596
+ [striped]="true"
597
+ class="w-full md:w-56"
598
+ />
599
+ </div>
600
+ `,
601
+ standalone: true,
602
+ imports: [ListboxModule, FormsModule]
603
+ })
604
+ export class ListboxVirtualscrollDemo {
605
+ items: any = Array.from({ length: 100000 }, (_, i) => ({ label: `Item #${i}`, value: i }));
606
+ selectedItems!: any[];
607
+ selectAll: boolean = false;
608
+
609
+ onSelectAllChange(event) {
610
+ this.selectedItems = event.checked ? [...this.items] : [];
611
+ this.selectAll = event.checked;
612
+ }
613
+
614
+ onChange(event) {
615
+ const { value } = event;
616
+ if (value) this.selectAll = value.length === this.items.length;
617
+ }
618
+ }
619
+ ```
620
+
621
+ ## Listbox
622
+
623
+ ListBox is used to select one or more values from a list of items.
624
+
625
+ ### Props
626
+
627
+ | Name | Type | Default | Description |
628
+ |------|------|---------|-------------|
629
+ | dt | InputSignal<Object> | undefined | Defines scoped design tokens of the component. |
630
+ | unstyled | InputSignal<boolean> | undefined | Indicates whether the component should be rendered without styles. |
631
+ | pt | InputSignal<ListBoxPassThrough> | undefined | Used to pass attributes to DOM elements inside the component. |
632
+ | ptOptions | InputSignal<PassThroughOptions> | undefined | Used to configure passthrough(pt) options of the component. |
633
+ | required | InputSignalWithTransform<boolean, unknown> | false | There must be a value (if set). |
634
+ | invalid | InputSignalWithTransform<boolean, unknown> | false | When present, it specifies that the component should have invalid state style. |
635
+ | disabled | InputSignalWithTransform<boolean, unknown> | false | When present, it specifies that the component should have disabled state style. |
636
+ | name | InputSignal<string> | undefined | When present, it specifies that the name of the input. |
637
+ | id | InputSignal<string> | ... | Unique identifier of the component. |
638
+ | searchMessage | InputSignal<string> | '{0} results are available' | Text to display when the search is active. Defaults to global value in i18n translation configuration. |
639
+ | emptySelectionMessage | InputSignal<string> | 'No selected item' | Text to display when filtering does not return any results. Defaults to global value in i18n translation configuration. |
640
+ | selectionMessage | InputSignal<string> | '{0} items selected' | Text to be displayed in hidden accessible field when options are selected. Defaults to global value in i18n translation configuration. |
641
+ | autoOptionFocus | InputSignalWithTransform<boolean, unknown> | ... | Whether to focus on the first visible or selected element when the overlay panel is shown. |
642
+ | ariaLabel | InputSignal<string> | ... | Defines a string that labels the input for accessibility. |
643
+ | selectOnFocus | InputSignalWithTransform<boolean, unknown> | ... | When enabled, the focused option is selected. |
644
+ | searchLocale | InputSignalWithTransform<boolean, unknown> | ... | Locale to use in searching. The default locale is the host environment's current locale. |
645
+ | focusOnHover | InputSignalWithTransform<boolean, unknown> | ... | When enabled, the hovered option will be focused. |
646
+ | filterMessage | InputSignal<string> | ... | Text to display when filtering. |
647
+ | filterFields | InputSignal<any[]> | ... | Fields used when filtering the options, defaults to optionLabel. |
648
+ | lazy | InputSignalWithTransform<boolean, unknown> | ... | Defines if data is loaded and interacted with in lazy manner. |
649
+ | virtualScroll | InputSignalWithTransform<boolean, unknown> | ... | Whether the data should be loaded on demand during scroll. |
650
+ | virtualScrollItemSize | InputSignalWithTransform<number, unknown> | ... | Height of an item in the list for VirtualScrolling. |
651
+ | virtualScrollOptions | InputSignal<ScrollerOptions> | ... | Whether to use the scroller feature. The properties of scroller component can be used like an object in it. |
652
+ | scrollHeight | InputSignal<string> | ... | Height of the viewport in pixels, a scrollbar is defined if height of list exceeds this value. |
653
+ | tabindex | InputSignalWithTransform<number, unknown> | ... | Index of the element in tabbing order. |
654
+ | multiple | InputSignalWithTransform<boolean, unknown> | ... | When specified, allows selecting multiple values. |
655
+ | listStyle | InputSignal<{ [klass: string]: any }> | ... | Inline style of the list element. |
656
+ | listStyleClass | InputSignal<string> | ... | Style class of the list element. |
657
+ | readonly | InputSignalWithTransform<boolean, unknown> | ... | When present, it specifies that the element value cannot be changed. |
658
+ | checkbox | InputSignalWithTransform<boolean, unknown> | ... | When specified, allows selecting items with checkboxes. |
659
+ | filter | InputSignalWithTransform<boolean, unknown> | ... | When specified, displays a filter input at header. |
660
+ | filterBy | InputSignal<string> | ... | When filtering is enabled, filterBy decides which field or fields (comma separated) to search against. |
661
+ | filterMatchMode | InputSignal<string> | ... | Defines how the items are filtered. |
662
+ | filterLocale | InputSignal<string> | ... | Locale to use in filtering. The default locale is the host environment's current locale. |
663
+ | metaKeySelection | InputSignalWithTransform<boolean, unknown> | ... | Defines how multiple items can be selected, when true metaKey needs to be pressed to select or unselect an item and when set to false selection of each item can be toggled individually. On touch enabled devices, metaKeySelection is turned off automatically. |
664
+ | dataKey | InputSignal<string> | ... | A property to uniquely identify a value in options. |
665
+ | showToggleAll | InputSignalWithTransform<boolean, unknown> | ... | Whether header checkbox is shown in multiple mode. |
666
+ | optionLabel | InputSignal<string> | ... | Name of the label field of an option. |
667
+ | optionValue | InputSignal<string> | ... | Name of the value field of an option. |
668
+ | optionGroupChildren | InputSignal<string> | ... | Name of the options field of an option group. |
669
+ | optionGroupLabel | InputSignal<string> | ... | Name of the label field of an option group. |
670
+ | optionDisabled | InputSignal<string \| ((item: any) => boolean)> | ... | Name of the disabled field of an option or function to determine disabled state. |
671
+ | ariaFilterLabel | InputSignal<string> | ... | Defines a string that labels the filter input. |
672
+ | filterPlaceHolder | InputSignal<string> | ... | Defines placeholder of the filter input. |
673
+ | emptyFilterMessage | InputSignal<string> | ... | Text to display when filtering does not return any results. |
674
+ | emptyMessage | InputSignal<string> | ... | Text to display when there is no data. Defaults to global value in i18n translation configuration. |
675
+ | group | InputSignalWithTransform<boolean, unknown> | ... | Whether to display options as grouped when nested options are provided. |
676
+ | options | InputSignal<any[]> | ... | An array of selectitems to display as the available options. |
677
+ | filterValue | InputSignal<string> | ... | When specified, filter displays with this value. |
678
+ | selectAll | InputSignal<boolean> | ... | Whether all data is selected. |
679
+ | striped | InputSignalWithTransform<boolean, unknown> | false | Whether to displays rows with alternating colors. |
680
+ | highlightOnSelect | InputSignalWithTransform<boolean, unknown> | true | Whether the selected option will be add highlight class. |
681
+ | checkmark | InputSignalWithTransform<boolean, unknown> | false | Whether the selected option will be shown with a check mark. |
682
+ | dragdrop | InputSignalWithTransform<boolean, unknown> | ... | Whether to enable dragdrop based reordering. |
683
+ | dropListData | InputSignal<any[]> | ... | Array to use for CDK drop list data binding. When not provided, uses options array. |
684
+ | fluid | InputSignalWithTransform<boolean, unknown> | undefined | Spans 100% width of the container when enabled. |
685
+
686
+ ### Emits
687
+
688
+ | Name | Parameters | Description |
689
+ |------|------------|-------------|
690
+ | onChange | event: ListboxChangeEvent | Callback to invoke on value change. |
691
+ | onClick | event: ListboxClickEvent | Callback to invoke when option is clicked. |
692
+ | onDblClick | event: ListboxDoubleClickEvent | Callback to invoke when option is double clicked. |
693
+ | onFilter | event: ListboxFilterEvent | Callback to invoke when data is filtered. |
694
+ | onFocus | event: FocusEvent | Callback to invoke when component receives focus. |
695
+ | onBlur | event: FocusEvent | Callback to invoke when component loses focus. |
696
+ | onSelectAllChange | event: ListboxSelectAllChangeEvent | Callback to invoke when all data is selected. |
697
+ | onLazyLoad | event: ScrollerLazyLoadEvent | Emits on lazy load. |
698
+ | onDrop | value: CdkDragDrop<string[], string[], any | Emits on item is dropped. |
699
+
700
+ ### Templates
701
+
702
+ | Name | Type | Description |
703
+ |------|------|-------------|
704
+ | item | TemplateRef<ListboxItemTemplateContext<any>> | Custom item template. |
705
+ | group | TemplateRef<ListboxGroupTemplateContext<any>> | Custom group template. |
706
+ | header | TemplateRef<ListboxHeaderTemplateContext<any>> | Custom header template. |
707
+ | filter | TemplateRef<ListboxFilterTemplateContext> | Custom filter template. |
708
+ | footer | TemplateRef<ListboxFooterTemplateContext<any>> | Custom footer template. |
709
+ | emptyfilter | TemplateRef<void> | Custom empty filter message template. |
710
+ | empty | TemplateRef<void> | Custom empty message template. |
711
+ | filtericon | TemplateRef<void> | Custom filter icon template. |
712
+ | checkicon | TemplateRef<ListboxCheckIconTemplateContext> | Custom check icon template. |
713
+ | checkmark | TemplateRef<ListboxCheckmarkTemplateContext> | Custom checkmark icon template. |
714
+ | loader | TemplateRef<ListboxLoaderTemplateContext> | Custom loader template. |
715
+
716
+ ### Methods
717
+
718
+ | Name | Parameters | Return Type | Description |
719
+ |------|------------|-------------|-------------|
720
+ | updateModel | value: any, event: any | void | Updates the model value. |
721
+
722
+ ## Pass Through Options
723
+
724
+ | Name | Type | Description |
725
+ |------|------|-------------|
726
+ | root | PassThroughOption<HTMLDivElement, I> | Used to pass attributes to the root's DOM element. |
727
+ | header | PassThroughOption<HTMLDivElement, I> | Used to pass attributes to the header's DOM element. |
728
+ | pcCheckbox | any | Used to pass attributes to the Checkbox component. |
729
+ | pcFilterContainer | any | Used to pass attributes to the IconField component. |
730
+ | pcFilter | any | Used to pass attributes to the filter input's DOM element. |
731
+ | pcFilterIconContainer | any | Used to pass attributes to the InputIcon component. |
732
+ | filterIcon | PassThroughOption<SVGElement, I> | Used to pass attributes to the filter icon's DOM element. |
733
+ | hiddenFilterResult | PassThroughOption<HTMLSpanElement, I> | Used to pass attributes to the hidden filter result's DOM element. |
734
+ | listContainer | PassThroughOption<HTMLDivElement, I> | Used to pass attributes to the list container's DOM element. |
735
+ | virtualScroller | any | Used to pass attributes to the VirtualScroller component. |
736
+ | list | PassThroughOption<HTMLUListElement, I> | Used to pass attributes to the list's DOM element. |
737
+ | optionGroup | PassThroughOption<HTMLLIElement, I, ListBoxContext> | Used to pass attributes to the option group's DOM element. |
738
+ | option | PassThroughOption<HTMLLIElement, I, ListBoxContext> | Used to pass attributes to the option's DOM element. |
739
+ | optionCheckIcon | PassThroughOption<SVGElement, I> | Used to pass attributes to the option check icon's DOM element. |
740
+ | optionBlankIcon | PassThroughOption<SVGElement, I> | Used to pass attributes to the option blank icon's DOM element. |
741
+ | emptyMessage | PassThroughOption<HTMLLIElement, I> | Used to pass attributes to the empty message's DOM element. |
742
+ | hiddenEmptyMessage | PassThroughOption<HTMLSpanElement, I> | Used to pass attributes to the hidden empty message's DOM element. |
743
+ | hiddenSelectedMessage | PassThroughOption<HTMLSpanElement, I> | Used to pass attributes to the hidden selected message's DOM element. |
744
+ | hiddenFirstFocusableEl | PassThroughOption<HTMLSpanElement, I> | Used to pass attributes to the first hidden focusable element. |
745
+ | hiddenLastFocusableEl | PassThroughOption<HTMLSpanElement, I> | Used to pass attributes to the last hidden focusable element. |
746
+
747
+ ## Theming
748
+
749
+ ### CSS Classes
750
+
751
+ | Class | Description |
752
+ |-------|-------------|
753
+ | p-listbox | Class name of the root element |
754
+ | p-listbox-header | Class name of the header element |
755
+ | p-listbox-filter | Class name of the filter element |
756
+ | p-listbox-list-container | Class name of the list container element |
757
+ | p-listbox-list | Class name of the list element |
758
+ | p-listbox-option-group | Class name of the option group element |
759
+ | p-listbox-option | Class name of the option element |
760
+ | p-listbox-option-check-icon | Class name of the option check icon element |
761
+ | p-listbox-option-blank-icon | Class name of the option blank icon element |
762
+ | p-listbox-empty-message | Class name of the empty message element |
763
+
764
+ ### Design Tokens
765
+
766
+ | Token | CSS Variable | Description |
767
+ |-------|--------------|-------------|
768
+ | listbox.background | --p-listbox-background | Background of root |
769
+ | listbox.disabled.background | --p-listbox-disabled-background | Disabled background of root |
770
+ | listbox.border.color | --p-listbox-border-color | Border color of root |
771
+ | listbox.invalid.border.color | --p-listbox-invalid-border-color | Invalid border color of root |
772
+ | listbox.color | --p-listbox-color | Color of root |
773
+ | listbox.disabled.color | --p-listbox-disabled-color | Disabled color of root |
774
+ | listbox.shadow | --p-listbox-shadow | Shadow of root |
775
+ | listbox.border.radius | --p-listbox-border-radius | Border radius of root |
776
+ | listbox.transition.duration | --p-listbox-transition-duration | Transition duration of root |
777
+ | listbox.list.padding | --p-listbox-list-padding | Padding of list |
778
+ | listbox.list.gap | --p-listbox-list-gap | Gap of list |
779
+ | listbox.list.header.padding | --p-listbox-list-header-padding | Header padding of list |
780
+ | listbox.option.focus.background | --p-listbox-option-focus-background | Focus background of option |
781
+ | listbox.option.selected.background | --p-listbox-option-selected-background | Selected background of option |
782
+ | listbox.option.selected.focus.background | --p-listbox-option-selected-focus-background | Selected focus background of option |
783
+ | listbox.option.color | --p-listbox-option-color | Color of option |
784
+ | listbox.option.focus.color | --p-listbox-option-focus-color | Focus color of option |
785
+ | listbox.option.selected.color | --p-listbox-option-selected-color | Selected color of option |
786
+ | listbox.option.selected.focus.color | --p-listbox-option-selected-focus-color | Selected focus color of option |
787
+ | listbox.option.padding | --p-listbox-option-padding | Padding of option |
788
+ | listbox.option.border.radius | --p-listbox-option-border-radius | Border radius of option |
789
+ | listbox.option.striped.background | --p-listbox-option-striped-background | Striped background of option |
790
+ | listbox.option.group.background | --p-listbox-option-group-background | Background of option group |
791
+ | listbox.option.group.color | --p-listbox-option-group-color | Color of option group |
792
+ | listbox.option.group.font.weight | --p-listbox-option-group-font-weight | Font weight of option group |
793
+ | listbox.option.group.padding | --p-listbox-option-group-padding | Padding of option group |
794
+ | listbox.checkmark.color | --p-listbox-checkmark-color | Color of checkmark |
795
+ | listbox.checkmark.gutter.start | --p-listbox-checkmark-gutter-start | Gutter start of checkmark |
796
+ | listbox.checkmark.gutter.end | --p-listbox-checkmark-gutter-end | Gutter end of checkmark |
797
+ | listbox.empty.message.padding | --p-listbox-empty-message-padding | Padding of empty message |
798
+