@exhaustive-ui/mcp 0.0.0-stage → 22.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +167 -2
- package/data/components/accordion.md +421 -0
- package/data/components/animateonscroll.md +163 -0
- package/data/components/autocomplete.md +1077 -0
- package/data/components/autofocus.md +38 -0
- package/data/components/avatar.md +417 -0
- package/data/components/badge.md +234 -0
- package/data/components/blockui.md +108 -0
- package/data/components/breadcrumb.md +178 -0
- package/data/components/button.md +774 -0
- package/data/components/card.md +138 -0
- package/data/components/carousel.md +440 -0
- package/data/components/cascadeselect.md +1387 -0
- package/data/components/chart.md +1178 -0
- package/data/components/checkbox.md +529 -0
- package/data/components/chip.md +180 -0
- package/data/components/colorpicker.md +301 -0
- package/data/components/confirmdialog.md +287 -0
- package/data/components/confirmpopup.md +417 -0
- package/data/components/contextmenu.md +491 -0
- package/data/components/dataview.md +600 -0
- package/data/components/datepicker.md +1262 -0
- package/data/components/dialog.md +622 -0
- package/data/components/divider.md +250 -0
- package/data/components/dock.md +500 -0
- package/data/components/dragdrop.md +285 -0
- package/data/components/drawer.md +510 -0
- package/data/components/dynamicdialog.md +109 -0
- package/data/components/editor.md +291 -0
- package/data/components/fieldset.md +182 -0
- package/data/components/fileupload.md +430 -0
- package/data/components/floatlabel.md +155 -0
- package/data/components/fluid.md +72 -0
- package/data/components/focustrap.md +65 -0
- package/data/components/galleria.md +627 -0
- package/data/components/iconfield.md +246 -0
- package/data/components/iftalabel.md +105 -0
- package/data/components/imagecompare.md +97 -0
- package/data/components/inplace.md +233 -0
- package/data/components/inputgroup.md +306 -0
- package/data/components/inputmask.md +518 -0
- package/data/components/inputnumber.md +675 -0
- package/data/components/inputotp.md +336 -0
- package/data/components/inputtext.md +488 -0
- package/data/components/keyfilter.md +85 -0
- package/data/components/knob.md +462 -0
- package/data/components/listbox.md +798 -0
- package/data/components/llms.md +28 -0
- package/data/components/megamenu.md +587 -0
- package/data/components/menu.md +483 -0
- package/data/components/menubar.md +462 -0
- package/data/components/message.md +449 -0
- package/data/components/metergroup.md +241 -0
- package/data/components/multiselect.md +1047 -0
- package/data/components/orderlist.md +342 -0
- package/data/components/organizationchart.md +197 -0
- package/data/components/overlay.md +217 -0
- package/data/components/paginator.md +314 -0
- package/data/components/panel.md +214 -0
- package/data/components/panelmenu.md +699 -0
- package/data/components/password.md +570 -0
- package/data/components/picklist.md +420 -0
- package/data/components/popover.md +378 -0
- package/data/components/progressbar.md +181 -0
- package/data/components/progressspinner.md +91 -0
- package/data/components/radiobutton.md +377 -0
- package/data/components/rating.md +312 -0
- package/data/components/ripple.md +89 -0
- package/data/components/scroller.md +122 -0
- package/data/components/scrollpanel.md +149 -0
- package/data/components/scrolltop.md +105 -0
- package/data/components/select.md +1206 -0
- package/data/components/selectbutton.md +356 -0
- package/data/components/skeleton.md +242 -0
- package/data/components/slider.md +337 -0
- package/data/components/speeddial.md +589 -0
- package/data/components/splitbutton.md +945 -0
- package/data/components/splitter.md +196 -0
- package/data/components/stepper.md +411 -0
- package/data/components/styleclass.md +126 -0
- package/data/components/table.md +4557 -0
- package/data/components/tabs.md +467 -0
- package/data/components/tag.md +200 -0
- package/data/components/terminal.md +118 -0
- package/data/components/textarea.md +416 -0
- package/data/components/tieredmenu.md +578 -0
- package/data/components/timeline.md +310 -0
- package/data/components/toast.md +596 -0
- package/data/components/togglebutton.md +356 -0
- package/data/components/toggleswitch.md +285 -0
- package/data/components/toolbar.md +182 -0
- package/data/components/tooltip.md +211 -0
- package/data/components/tree.md +746 -0
- package/data/components/treeselect.md +912 -0
- package/data/components/treetable.md +2814 -0
- package/data/components.json +43751 -0
- package/data/llms-full.txt +47433 -0
- package/data/llms.txt +121 -0
- package/data/manifest.json +46513 -0
- package/data/pages/accessibility.md +28 -0
- package/data/pages/animations.md +28 -0
- package/data/pages/configuration.md +210 -0
- package/data/pages/contribution.md +20 -0
- package/data/pages/customicons.md +20 -0
- package/data/pages/faq.md +20 -0
- package/data/pages/icons.md +66 -0
- package/data/pages/installation.md +71 -0
- package/data/pages/llms.md +61 -0
- package/data/pages/passthrough.md +32 -0
- package/data/pages/philosophy.md +28 -0
- package/data/pages/primeflex.md +20 -0
- package/data/pages/rtl.md +12 -0
- package/data/pages/styled.md +132 -0
- package/data/pages/tailwind.md +40 -0
- package/data/pages/unstyled.md +39 -0
- package/data/snapshot.json +9 -0
- package/dist/index.d.mts +448 -0
- package/dist/index.mjs +2501 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +67 -3
|
@@ -0,0 +1,1077 @@
|
|
|
1
|
+
# Angular AutoComplete Component
|
|
2
|
+
|
|
3
|
+
AutoComplete is an input component that provides real-time suggestions when being typed.
|
|
4
|
+
|
|
5
|
+
## Accessibility
|
|
6
|
+
|
|
7
|
+
Screen Reader Value to describe the component can either be provided via label tag combined with inputId prop or using ariaLabelledBy , ariaLabel props. The input element has combobox role in addition to aria-autocomplete , aria-haspopup and aria-expanded attributes. The relation between the input and the popup is created with aria-controls and aria-activedescendant attribute is used to instruct screen reader which option to read during keyboard navigation within the popup list. In multiple mode, chip list uses listbox role whereas each chip has the option role with aria-label set to the label of the chip. The popup list has an id that refers to the aria-controls attribute of the input element and uses listbox as the role. Each list item has option role and an id to match the aria-activedescendant of the input element.
|
|
8
|
+
|
|
9
|
+
## advanced-chips-doc
|
|
10
|
+
|
|
11
|
+
This example demonstrates an advanced use case with templating, object handling, dropdown, and multiple mode.
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Component, OnInit, inject, signal } from '@angular/core';
|
|
15
|
+
import { FormsModule } from '@angular/forms';
|
|
16
|
+
import { AutoCompleteModule } from '@exhaustive-ui/core/autocomplete';
|
|
17
|
+
import { ProductService } from '@/service/productservice';
|
|
18
|
+
import { Product } from '@/domain/product';
|
|
19
|
+
|
|
20
|
+
@Component({
|
|
21
|
+
template: `
|
|
22
|
+
<div class="card">
|
|
23
|
+
<p-autocomplete
|
|
24
|
+
[(ngModel)]="selectedProducts"
|
|
25
|
+
[suggestions]="filteredProducts"
|
|
26
|
+
(completeMethod)="filterProducts($event)"
|
|
27
|
+
inputId="advanced-chips"
|
|
28
|
+
[multiple]="true"
|
|
29
|
+
[fluid]="true"
|
|
30
|
+
[typeahead]="false"
|
|
31
|
+
[dropdown]="true"
|
|
32
|
+
[optionLabel]="getProductLabel"
|
|
33
|
+
[optionValue]="getProductValue"
|
|
34
|
+
placeholder="Add products"
|
|
35
|
+
>
|
|
36
|
+
<ng-template let-product #item>
|
|
37
|
+
<div class="flex flex-wrap p-1 items-center gap-4 w-full">
|
|
38
|
+
<img class="w-12 shrink-0 rounded" src="https://exhaustive-ui.e-xiste.com/demo/product/{{ product.image }}" [alt]="product.name" />
|
|
39
|
+
<div class="flex-1 flex flex-col">
|
|
40
|
+
<span class="font-medium text-sm">{{ product.name }}</span>
|
|
41
|
+
<span class="text-sm text-surface-500 dark:text-surface-400">{{ product.category }}</span>
|
|
42
|
+
</div>
|
|
43
|
+
<span class="font-bold sm:ml-8">\${{ product.price }}</span>
|
|
44
|
+
</div>
|
|
45
|
+
</ng-template>
|
|
46
|
+
<ng-template let-value #selecteditem>
|
|
47
|
+
@if (value.price) {
|
|
48
|
+
<div class="flex align-items-center gap-2">
|
|
49
|
+
<span class="font-semibold">{{ value.name }}</span>
|
|
50
|
+
<span class="text-primary text-sm font-bold">\${{ value.price }}</span>
|
|
51
|
+
</div>
|
|
52
|
+
} @else {
|
|
53
|
+
<span class="font-semibold">{{ value }}</span>
|
|
54
|
+
}
|
|
55
|
+
</ng-template>
|
|
56
|
+
</p-autocomplete>
|
|
57
|
+
</div>
|
|
58
|
+
`,
|
|
59
|
+
standalone: true,
|
|
60
|
+
imports: [AutoCompleteModule, FormsModule],
|
|
61
|
+
providers: [ProductService]
|
|
62
|
+
})
|
|
63
|
+
export class AutocompleteAdvancedChipsDemo implements OnInit {
|
|
64
|
+
private productService = inject(ProductService);
|
|
65
|
+
products = signal<Product[]>([]);
|
|
66
|
+
|
|
67
|
+
ngOnInit() {
|
|
68
|
+
this.productService.getProductsSmall().then((data) => this.products.set(data));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
filterProducts(event: any) {
|
|
72
|
+
let filtered: Product[] = [];
|
|
73
|
+
let query = event.query;
|
|
74
|
+
|
|
75
|
+
for (let i = 0; i < this.products().length; i++) {
|
|
76
|
+
let product = this.products()[i];
|
|
77
|
+
if (product.name?.toLowerCase().indexOf(query.toLowerCase()) == 0) {
|
|
78
|
+
filtered.push(product);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
this.filteredProducts = filtered;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
getProductLabel(product: any): string {
|
|
86
|
+
if (typeof product === 'string') {
|
|
87
|
+
return product;
|
|
88
|
+
}
|
|
89
|
+
return product?.name || '';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
getProductValue(product: any): any {
|
|
93
|
+
if (typeof product === 'string') {
|
|
94
|
+
return { name: product, custom: true };
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
id: product.id,
|
|
98
|
+
name: product.name,
|
|
99
|
+
price: product.price,
|
|
100
|
+
quantity: product.quantity
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## basic-chips-doc
|
|
107
|
+
|
|
108
|
+
With multiple enabled, the AutoComplete component behaves like a chips or tags input. Use addOnBlur , addOnTab , and separator properties to customize the keystroke behavior for adding items.
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
import { Component } from '@angular/core';
|
|
112
|
+
import { FormsModule } from '@angular/forms';
|
|
113
|
+
import { AutoCompleteModule } from '@exhaustive-ui/core/autocomplete';
|
|
114
|
+
|
|
115
|
+
@Component({
|
|
116
|
+
template: `
|
|
117
|
+
<div class="card">
|
|
118
|
+
<label for="chips-blur" class="font-bold mb-2 block">With Add On Blur</label>
|
|
119
|
+
<p-autocomplete [(ngModel)]="valueBlur" inputId="chips-blur" multiple fluid [typeahead]="false" [addOnBlur]="true" placeholder="Type and click outside to add..." />
|
|
120
|
+
<label for="chips-tab" class="font-bold mt-8 mb-2 block">With Add On Tab</label>
|
|
121
|
+
<p-autocomplete [(ngModel)]="valueTab" inputId="chips-tab" multiple fluid [typeahead]="false" [addOnTab]="true" placeholder="Type and press Tab to add..." />
|
|
122
|
+
<label for="chips-separator" class="font-bold mt-8 mb-2 block">With Separator (Comma)</label>
|
|
123
|
+
<p-autocomplete [(ngModel)]="valueSeparator" inputId="chips-separator" multiple fluid [typeahead]="false" separator="," placeholder="Type items separated by comma..." />
|
|
124
|
+
<label for="chips-combined" class="font-bold mt-8 mb-2 block">Combined Features</label>
|
|
125
|
+
<p-autocomplete [(ngModel)]="valueCombined" inputId="chips-combined" multiple fluid [typeahead]="false" [addOnBlur]="true" [addOnTab]="true" separator="," placeholder="Use Tab, Blur, or Comma to add items..." />
|
|
126
|
+
</div>
|
|
127
|
+
`,
|
|
128
|
+
standalone: true,
|
|
129
|
+
imports: [AutoCompleteModule, FormsModule]
|
|
130
|
+
})
|
|
131
|
+
export class AutocompleteBasicChipsDemo {
|
|
132
|
+
valueBlur: any[] = [];
|
|
133
|
+
valueTab: any[] = [];
|
|
134
|
+
valueSeparator: any[] = [];
|
|
135
|
+
valueCombined: any[] = [];
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Basic
|
|
140
|
+
|
|
141
|
+
AutoComplete uses ngModel for two-way binding, requires a list of suggestions and a completeMethod to query for the results. The completeMethod gets the query text as event.query property and should update the suggestions with the search results.
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
import { Component } from '@angular/core';
|
|
145
|
+
import { FormsModule } from '@angular/forms';
|
|
146
|
+
import { AutoCompleteModule } from '@exhaustive-ui/core/autocomplete';
|
|
147
|
+
|
|
148
|
+
interface AutoCompleteCompleteEvent {
|
|
149
|
+
originalEvent: Event;
|
|
150
|
+
query: string;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@Component({
|
|
154
|
+
template: `
|
|
155
|
+
<div class="card flex justify-center">
|
|
156
|
+
<p-autocomplete [(ngModel)]="value" [suggestions]="items" (completeMethod)="search($event)" />
|
|
157
|
+
</div>
|
|
158
|
+
`,
|
|
159
|
+
standalone: true,
|
|
160
|
+
imports: [AutoCompleteModule, FormsModule]
|
|
161
|
+
})
|
|
162
|
+
export class AutocompleteBasicDemo {
|
|
163
|
+
items: any[] = [];
|
|
164
|
+
value: any;
|
|
165
|
+
|
|
166
|
+
search(event: AutoCompleteCompleteEvent) {
|
|
167
|
+
this.items = [...Array(10).keys()].map((item) => event.query + '-' + item);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## clear-icon-doc
|
|
173
|
+
|
|
174
|
+
When showClear is enabled, a clear icon is displayed to clear the value.
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
import { Component } from '@angular/core';
|
|
178
|
+
import { FormsModule } from '@angular/forms';
|
|
179
|
+
import { AutoCompleteModule } from '@exhaustive-ui/core/autocomplete';
|
|
180
|
+
|
|
181
|
+
interface AutoCompleteCompleteEvent {
|
|
182
|
+
originalEvent: Event;
|
|
183
|
+
query: string;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
@Component({
|
|
187
|
+
template: `
|
|
188
|
+
<div class="card flex justify-center">
|
|
189
|
+
<p-autocomplete [(ngModel)]="value" [suggestions]="items" (completeMethod)="search($event)" [showClear]="true" inputStyleClass="w-56" />
|
|
190
|
+
</div>
|
|
191
|
+
`,
|
|
192
|
+
standalone: true,
|
|
193
|
+
imports: [AutoCompleteModule, FormsModule]
|
|
194
|
+
})
|
|
195
|
+
export class AutocompleteClearIconDemo {
|
|
196
|
+
items: any[] = [];
|
|
197
|
+
value: any;
|
|
198
|
+
|
|
199
|
+
search(event: AutoCompleteCompleteEvent) {
|
|
200
|
+
this.items = [...Array(10).keys()].map((item) => event.query + '-' + item);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Disabled
|
|
206
|
+
|
|
207
|
+
When disabled is present, the element cannot be edited and focused.
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
import { Component } from '@angular/core';
|
|
211
|
+
import { FormsModule } from '@angular/forms';
|
|
212
|
+
import { AutoCompleteModule } from '@exhaustive-ui/core/autocomplete';
|
|
213
|
+
|
|
214
|
+
interface AutoCompleteCompleteEvent {
|
|
215
|
+
originalEvent: Event;
|
|
216
|
+
query: string;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
@Component({
|
|
220
|
+
template: `
|
|
221
|
+
<div class="card flex justify-center">
|
|
222
|
+
<p-autocomplete [(ngModel)]="selectedItem" [suggestions]="suggestions" placeholder="Disabled" (completeMethod)="search($event)" [disabled]="true" />
|
|
223
|
+
</div>
|
|
224
|
+
`,
|
|
225
|
+
standalone: true,
|
|
226
|
+
imports: [AutoCompleteModule, FormsModule]
|
|
227
|
+
})
|
|
228
|
+
export class AutocompleteDisabledDemo {
|
|
229
|
+
items: any[] | undefined;
|
|
230
|
+
selectedItem: any;
|
|
231
|
+
suggestions: any[] | undefined;
|
|
232
|
+
|
|
233
|
+
search(event: AutoCompleteCompleteEvent) {
|
|
234
|
+
this.suggestions = [...Array(10).keys()].map((item) => event.query + '-' + item);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Dropdown
|
|
240
|
+
|
|
241
|
+
Enabling dropdown property displays a button next to the input field where click behavior of the button is defined using dropdownMode property that takes blank or current as possible values. blank is the default mode to send a query with an empty string whereas current setting sends a query with the current value of the input.
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
import { Component } from '@angular/core';
|
|
245
|
+
import { FormsModule } from '@angular/forms';
|
|
246
|
+
import { AutoCompleteModule } from '@exhaustive-ui/core/autocomplete';
|
|
247
|
+
|
|
248
|
+
interface AutoCompleteCompleteEvent {
|
|
249
|
+
originalEvent: Event;
|
|
250
|
+
query: string;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
@Component({
|
|
254
|
+
template: `
|
|
255
|
+
<div class="card flex justify-center">
|
|
256
|
+
<p-autocomplete [(ngModel)]="value" [dropdown]="true" [suggestions]="items" (completeMethod)="search($event)" />
|
|
257
|
+
</div>
|
|
258
|
+
`,
|
|
259
|
+
standalone: true,
|
|
260
|
+
imports: [AutoCompleteModule, FormsModule]
|
|
261
|
+
})
|
|
262
|
+
export class AutocompleteDropdownDemo {
|
|
263
|
+
items: any[] | undefined;
|
|
264
|
+
value: any;
|
|
265
|
+
|
|
266
|
+
search(event: AutoCompleteCompleteEvent) {
|
|
267
|
+
let _items = [...Array(10).keys()];
|
|
268
|
+
|
|
269
|
+
this.items = event.query ? [...Array(10).keys()].map((item) => event.query + '-' + item) : _items;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## Filled
|
|
275
|
+
|
|
276
|
+
Specify the variant property as filled to display the component with a higher visual emphasis than the default outlined style.
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
import { Component } from '@angular/core';
|
|
280
|
+
import { FormsModule } from '@angular/forms';
|
|
281
|
+
import { AutoCompleteModule } from '@exhaustive-ui/core/autocomplete';
|
|
282
|
+
|
|
283
|
+
interface AutoCompleteCompleteEvent {
|
|
284
|
+
originalEvent: Event;
|
|
285
|
+
query: string;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
@Component({
|
|
289
|
+
template: `
|
|
290
|
+
<div class="card flex justify-center">
|
|
291
|
+
<p-autocomplete [(ngModel)]="selectedItem" [suggestions]="suggestions" (completeMethod)="search($event)" variant="filled" />
|
|
292
|
+
</div>
|
|
293
|
+
`,
|
|
294
|
+
standalone: true,
|
|
295
|
+
imports: [AutoCompleteModule, FormsModule]
|
|
296
|
+
})
|
|
297
|
+
export class AutocompleteFilledDemo {
|
|
298
|
+
items: any[] | undefined;
|
|
299
|
+
selectedItem: any;
|
|
300
|
+
suggestions: any[] | undefined;
|
|
301
|
+
|
|
302
|
+
search(event: AutoCompleteCompleteEvent) {
|
|
303
|
+
this.suggestions = [...Array(10).keys()].map((item) => event.query + '-' + item);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
## float-label-doc
|
|
309
|
+
|
|
310
|
+
A floating label appears on top of the input field when focused. Visit FloatLabel documentation for more information.
|
|
311
|
+
|
|
312
|
+
```typescript
|
|
313
|
+
import { Component } from '@angular/core';
|
|
314
|
+
import { FormsModule } from '@angular/forms';
|
|
315
|
+
import { AutoCompleteModule } from '@exhaustive-ui/core/autocomplete';
|
|
316
|
+
import { FloatLabelModule } from '@exhaustive-ui/core/floatlabel';
|
|
317
|
+
|
|
318
|
+
interface AutoCompleteCompleteEvent {
|
|
319
|
+
originalEvent: Event;
|
|
320
|
+
query: string;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
@Component({
|
|
324
|
+
template: `
|
|
325
|
+
<div class="card flex flex-wrap justify-center items-end gap-4">
|
|
326
|
+
<p-floatlabel>
|
|
327
|
+
<p-autocomplete [(ngModel)]="value1" [suggestions]="items" (completeMethod)="search($event)" inputId="over_label" />
|
|
328
|
+
<label for="over_label">Over Label</label>
|
|
329
|
+
</p-floatlabel>
|
|
330
|
+
<p-floatlabel variant="in">
|
|
331
|
+
<p-autocomplete [(ngModel)]="value2" [suggestions]="items" (completeMethod)="search($event)" inputId="in_label" />
|
|
332
|
+
<label for="in_label">In Label</label>
|
|
333
|
+
</p-floatlabel>
|
|
334
|
+
<p-floatlabel variant="on">
|
|
335
|
+
<p-autocomplete [(ngModel)]="value3" [suggestions]="items" (completeMethod)="search($event)" inputId="on_label" />
|
|
336
|
+
<label for="on_label">On Label</label>
|
|
337
|
+
</p-floatlabel>
|
|
338
|
+
</div>
|
|
339
|
+
`,
|
|
340
|
+
standalone: true,
|
|
341
|
+
imports: [AutoCompleteModule, FloatLabelModule, FormsModule]
|
|
342
|
+
})
|
|
343
|
+
export class AutocompleteFloatLabelDemo {
|
|
344
|
+
value1: string | undefined;
|
|
345
|
+
value2: string | undefined;
|
|
346
|
+
value3: string | undefined;
|
|
347
|
+
items: any[] | undefined;
|
|
348
|
+
|
|
349
|
+
search(event: AutoCompleteCompleteEvent) {
|
|
350
|
+
this.items = [...Array(10).keys()].map((item) => event.query + '-' + item);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
## Fluid
|
|
356
|
+
|
|
357
|
+
The fluid prop makes the component take up the full width of its container when set to true.
|
|
358
|
+
|
|
359
|
+
```typescript
|
|
360
|
+
import { Component } from '@angular/core';
|
|
361
|
+
import { FormsModule } from '@angular/forms';
|
|
362
|
+
import { AutoCompleteModule } from '@exhaustive-ui/core/autocomplete';
|
|
363
|
+
|
|
364
|
+
interface AutoCompleteCompleteEvent {
|
|
365
|
+
originalEvent: Event;
|
|
366
|
+
query: string;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
@Component({
|
|
370
|
+
template: `
|
|
371
|
+
<div class="card">
|
|
372
|
+
<p-autocomplete [(ngModel)]="value" [suggestions]="items" (completeMethod)="search($event)" fluid />
|
|
373
|
+
</div>
|
|
374
|
+
`,
|
|
375
|
+
standalone: true,
|
|
376
|
+
imports: [AutoCompleteModule, FormsModule]
|
|
377
|
+
})
|
|
378
|
+
export class AutocompleteFluidDemo {
|
|
379
|
+
items: any[] = [];
|
|
380
|
+
value: any;
|
|
381
|
+
|
|
382
|
+
search(event: AutoCompleteCompleteEvent) {
|
|
383
|
+
this.items = [...Array(10).keys()].map((item) => event.query + '-' + item);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
## force-selection-doc
|
|
389
|
+
|
|
390
|
+
ForceSelection mode validates the manual input to check whether it also exists in the suggestions list, if not the input value is cleared to make sure the value passed to the model is always one of the suggestions.
|
|
391
|
+
|
|
392
|
+
```typescript
|
|
393
|
+
import { Component, OnInit, inject } from '@angular/core';
|
|
394
|
+
import { FormsModule } from '@angular/forms';
|
|
395
|
+
import { AutoCompleteModule } from '@exhaustive-ui/core/autocomplete';
|
|
396
|
+
import { CountryService } from '@/service/countryservice';
|
|
397
|
+
|
|
398
|
+
interface AutoCompleteCompleteEvent {
|
|
399
|
+
originalEvent: Event;
|
|
400
|
+
query: string;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
@Component({
|
|
404
|
+
template: `
|
|
405
|
+
<div class="card flex justify-center">
|
|
406
|
+
<p-autocomplete [(ngModel)]="selectedCountry" [forceSelection]="true" [suggestions]="filteredCountries" (completeMethod)="filterCountry($event)" optionLabel="name" />
|
|
407
|
+
</div>
|
|
408
|
+
`,
|
|
409
|
+
standalone: true,
|
|
410
|
+
imports: [AutoCompleteModule, FormsModule],
|
|
411
|
+
providers: [CountryService]
|
|
412
|
+
})
|
|
413
|
+
export class AutocompleteForceSelectionDemo implements OnInit {
|
|
414
|
+
private countryService = inject(CountryService);
|
|
415
|
+
countries: any[] | undefined;
|
|
416
|
+
selectedCountry: any;
|
|
417
|
+
filteredCountries: any[] | undefined;
|
|
418
|
+
|
|
419
|
+
ngOnInit() {
|
|
420
|
+
this.countryService.getCountries().then((countries) => {
|
|
421
|
+
this.countries = countries;
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
filterCountry(event: AutoCompleteCompleteEvent) {
|
|
426
|
+
let filtered: any[] = [];
|
|
427
|
+
let query = event.query;
|
|
428
|
+
|
|
429
|
+
for (let i = 0; i < (this.countries as any[]).length; i++) {
|
|
430
|
+
let country = (this.countries as any[])[i];
|
|
431
|
+
if (country.name.toLowerCase().indexOf(query.toLowerCase()) == 0) {
|
|
432
|
+
filtered.push(country);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
this.filteredCountries = filtered;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
## Group
|
|
442
|
+
|
|
443
|
+
Option grouping is enabled when group property is set to true . group template is available to customize the option groups. All templates get the option instance as the default local template variable.
|
|
444
|
+
|
|
445
|
+
```typescript
|
|
446
|
+
import { Component, OnInit } from '@angular/core';
|
|
447
|
+
import { FormsModule } from '@angular/forms';
|
|
448
|
+
import { AutoCompleteModule } from '@exhaustive-ui/core/autocomplete';
|
|
449
|
+
import { SelectItemGroup, FilterService } from '@exhaustive-ui/core/api';
|
|
450
|
+
|
|
451
|
+
interface AutoCompleteCompleteEvent {
|
|
452
|
+
originalEvent: Event;
|
|
453
|
+
query: string;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
@Component({
|
|
457
|
+
template: `
|
|
458
|
+
<div class="card flex justify-center">
|
|
459
|
+
<p-autocomplete [(ngModel)]="selectedCity" [group]="true" [suggestions]="filteredGroups" (completeMethod)="filterGroupedCity($event)" placeholder="Hint: type 'a'">
|
|
460
|
+
<ng-template let-group #group>
|
|
461
|
+
<div class="flex items-center">
|
|
462
|
+
<img src="https://exhaustive-ui.e-xiste.com/demo/flag/flag_placeholder.png" [class]="'mr-2 flag flag-' + group.value" style="width: 20px" />
|
|
463
|
+
<span>{{ group.label }}</span>
|
|
464
|
+
</div>
|
|
465
|
+
</ng-template>
|
|
466
|
+
</p-autocomplete>
|
|
467
|
+
</div>
|
|
468
|
+
`,
|
|
469
|
+
standalone: true,
|
|
470
|
+
imports: [AutoCompleteModule, FormsModule]
|
|
471
|
+
})
|
|
472
|
+
export class AutocompleteGroupDemo implements OnInit {
|
|
473
|
+
selectedCity: any;
|
|
474
|
+
filteredGroups: any[] | undefined;
|
|
475
|
+
groupedCities: SelectItemGroup[] | undefined;
|
|
476
|
+
|
|
477
|
+
ngOnInit() {
|
|
478
|
+
this.groupedCities = [
|
|
479
|
+
{
|
|
480
|
+
label: 'Germany',
|
|
481
|
+
value: 'de',
|
|
482
|
+
items: [
|
|
483
|
+
{ label: 'Berlin', value: 'Berlin' },
|
|
484
|
+
{ label: 'Frankfurt', value: 'Frankfurt' },
|
|
485
|
+
{ label: 'Hamburg', value: 'Hamburg' },
|
|
486
|
+
{ label: 'Munich', value: 'Munich' }
|
|
487
|
+
]
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
label: 'USA',
|
|
491
|
+
value: 'us',
|
|
492
|
+
items: [
|
|
493
|
+
{ label: 'Chicago', value: 'Chicago' },
|
|
494
|
+
{ label: 'Los Angeles', value: 'Los Angeles' },
|
|
495
|
+
{ label: 'New York', value: 'New York' },
|
|
496
|
+
{ label: 'San Francisco', value: 'San Francisco' }
|
|
497
|
+
]
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
label: 'Japan',
|
|
501
|
+
value: 'jp',
|
|
502
|
+
items: [
|
|
503
|
+
{ label: 'Kyoto', value: 'Kyoto' },
|
|
504
|
+
{ label: 'Osaka', value: 'Osaka' },
|
|
505
|
+
{ label: 'Tokyo', value: 'Tokyo' },
|
|
506
|
+
{ label: 'Yokohama', value: 'Yokohama' }
|
|
507
|
+
]
|
|
508
|
+
}
|
|
509
|
+
];
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
filterGroupedCity(event: AutoCompleteCompleteEvent) {
|
|
513
|
+
let query = event.query;
|
|
514
|
+
let filteredGroups = [];
|
|
515
|
+
|
|
516
|
+
for (let optgroup of this.groupedCities as SelectItemGroup[]) {
|
|
517
|
+
let filteredSubOptions = this.filterService.filter(optgroup.items, ['label'], query, 'contains');
|
|
518
|
+
if (filteredSubOptions && filteredSubOptions.length) {
|
|
519
|
+
filteredGroups.push({
|
|
520
|
+
label: optgroup.label,
|
|
521
|
+
value: optgroup.value,
|
|
522
|
+
items: filteredSubOptions
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
this.filteredGroups = filteredGroups;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
## ifta-label-doc
|
|
533
|
+
|
|
534
|
+
IftaLabel is used to create infield top aligned labels. Visit IftaLabel documentation for more information.
|
|
535
|
+
|
|
536
|
+
```typescript
|
|
537
|
+
import { Component } from '@angular/core';
|
|
538
|
+
import { FormsModule } from '@angular/forms';
|
|
539
|
+
import { AutoCompleteModule } from '@exhaustive-ui/core/autocomplete';
|
|
540
|
+
import { IftaLabelModule } from '@exhaustive-ui/core/iftalabel';
|
|
541
|
+
|
|
542
|
+
interface AutoCompleteCompleteEvent {
|
|
543
|
+
originalEvent: Event;
|
|
544
|
+
query: string;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
@Component({
|
|
548
|
+
template: `
|
|
549
|
+
<div class="card flex justify-center">
|
|
550
|
+
<p-iftalabel>
|
|
551
|
+
<p-autocomplete [(ngModel)]="value" [suggestions]="items" (completeMethod)="search($event)" inputId="ac" />
|
|
552
|
+
<label for="ac">Identifier</label>
|
|
553
|
+
</p-iftalabel>
|
|
554
|
+
</div>
|
|
555
|
+
`,
|
|
556
|
+
standalone: true,
|
|
557
|
+
imports: [AutoCompleteModule, IftaLabelModule, FormsModule]
|
|
558
|
+
})
|
|
559
|
+
export class AutocompleteIftaLabelDemo {
|
|
560
|
+
items: any[] | undefined;
|
|
561
|
+
value: any;
|
|
562
|
+
|
|
563
|
+
search(event: AutoCompleteCompleteEvent) {
|
|
564
|
+
this.items = [...Array(10).keys()].map((item) => event.query + '-' + item);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
## Invalid
|
|
570
|
+
|
|
571
|
+
The invalid state is applied using the invalid property to indicate failed validation, which can be integrated with Angular Forms.
|
|
572
|
+
|
|
573
|
+
```typescript
|
|
574
|
+
import { Component } from '@angular/core';
|
|
575
|
+
import { FormsModule } from '@angular/forms';
|
|
576
|
+
import { AutoCompleteModule } from '@exhaustive-ui/core/autocomplete';
|
|
577
|
+
|
|
578
|
+
interface AutoCompleteCompleteEvent {
|
|
579
|
+
originalEvent: Event;
|
|
580
|
+
query: string;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
@Component({
|
|
584
|
+
template: `
|
|
585
|
+
<div class="card flex flex-wrap justify-center gap-4">
|
|
586
|
+
<p-autocomplete [(ngModel)]="value1" [suggestions]="suggestions" [invalid]="!value1" (completeMethod)="search($event)" placeholder="Code" />
|
|
587
|
+
<p-autocomplete [(ngModel)]="value2" [suggestions]="suggestions" [invalid]="!value2" (completeMethod)="search($event)" variant="filled" placeholder="Code" />
|
|
588
|
+
</div>
|
|
589
|
+
`,
|
|
590
|
+
standalone: true,
|
|
591
|
+
imports: [AutoCompleteModule, FormsModule]
|
|
592
|
+
})
|
|
593
|
+
export class AutocompleteInvalidDemo {
|
|
594
|
+
value1: any;
|
|
595
|
+
value2: any;
|
|
596
|
+
suggestions: any[] | undefined;
|
|
597
|
+
|
|
598
|
+
search(event: AutoCompleteCompleteEvent) {
|
|
599
|
+
this.suggestions = [...Array(10).keys()].map((item) => event.query + '-' + item);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
## Multiple
|
|
605
|
+
|
|
606
|
+
Enable multiple selection mode using the multiple property to allow users to select more than one value from the autocomplete. When enabled, the value reference must be an array.
|
|
607
|
+
|
|
608
|
+
```typescript
|
|
609
|
+
import { Component } from '@angular/core';
|
|
610
|
+
import { FormsModule } from '@angular/forms';
|
|
611
|
+
import { AutoCompleteModule } from '@exhaustive-ui/core/autocomplete';
|
|
612
|
+
|
|
613
|
+
interface AutoCompleteCompleteEvent {
|
|
614
|
+
originalEvent: Event;
|
|
615
|
+
query: string;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
@Component({
|
|
619
|
+
template: `
|
|
620
|
+
<div class="card">
|
|
621
|
+
<label for="multiple-ac-1" class="font-bold mb-2 block">With Typeahead</label>
|
|
622
|
+
<p-autocomplete [(ngModel)]="value1" inputId="multiple-ac-1" multiple fluid [suggestions]="items" (completeMethod)="search($event)" />
|
|
623
|
+
<label for="multiple-ac-2" class="font-bold mt-8 mb-2 block">Without Typeahead</label>
|
|
624
|
+
<p-autocomplete [(ngModel)]="value2" inputId="multiple-ac-2" multiple fluid (completeMethod)="search($event)" [typeahead]="false" />
|
|
625
|
+
</div>
|
|
626
|
+
`,
|
|
627
|
+
standalone: true,
|
|
628
|
+
imports: [AutoCompleteModule, FormsModule]
|
|
629
|
+
})
|
|
630
|
+
export class AutocompleteMultipleDemo {
|
|
631
|
+
value1: any[] | undefined;
|
|
632
|
+
value2: any[] | undefined;
|
|
633
|
+
items: any[] | undefined;
|
|
634
|
+
|
|
635
|
+
search(event: AutoCompleteCompleteEvent) {
|
|
636
|
+
this.items = [...Array(10).keys()].map((item) => event.query + '-' + item);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
## Objects
|
|
642
|
+
|
|
643
|
+
AutoComplete can also work with objects using the optionLabel property that defines the label to display as a suggestion. The value passed to the model would still be the object instance of a suggestion. Here is an example with a Country object that has name and code fields such as {name: "United States", code:"USA"} .
|
|
644
|
+
|
|
645
|
+
```typescript
|
|
646
|
+
import { Component, OnInit, inject } from '@angular/core';
|
|
647
|
+
import { FormsModule } from '@angular/forms';
|
|
648
|
+
import { AutoCompleteModule } from '@exhaustive-ui/core/autocomplete';
|
|
649
|
+
import { CountryService } from '@/service/countryservice';
|
|
650
|
+
import { Country } from '@/domain/customer';
|
|
651
|
+
|
|
652
|
+
interface AutoCompleteCompleteEvent {
|
|
653
|
+
originalEvent: Event;
|
|
654
|
+
query: string;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
@Component({
|
|
658
|
+
template: `
|
|
659
|
+
<div class="card flex justify-center">
|
|
660
|
+
<p-autocomplete [(ngModel)]="selectedCountry" [suggestions]="filteredCountries" (completeMethod)="filterCountry($event)" optionLabel="name" />
|
|
661
|
+
</div>
|
|
662
|
+
`,
|
|
663
|
+
standalone: true,
|
|
664
|
+
imports: [AutoCompleteModule, FormsModule],
|
|
665
|
+
providers: [CountryService]
|
|
666
|
+
})
|
|
667
|
+
export class AutocompleteObjectsDemo implements OnInit {
|
|
668
|
+
private countryService = inject(CountryService);
|
|
669
|
+
countries: any[] | undefined;
|
|
670
|
+
selectedCountry: any;
|
|
671
|
+
filteredCountries: any[] | undefined;
|
|
672
|
+
|
|
673
|
+
ngOnInit() {
|
|
674
|
+
this.countryService.getCountries().then((countries) => {
|
|
675
|
+
this.countries = countries;
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
filterCountry(event: AutoCompleteCompleteEvent) {
|
|
680
|
+
let filtered: any[] = [];
|
|
681
|
+
let query = event.query;
|
|
682
|
+
|
|
683
|
+
for (let i = 0; i < (this.countries as any[]).length; i++) {
|
|
684
|
+
let country = (this.countries as any[])[i];
|
|
685
|
+
if (country.name.toLowerCase().indexOf(query.toLowerCase()) == 0) {
|
|
686
|
+
filtered.push(country);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
this.filteredCountries = filtered;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
## reactive-forms-doc
|
|
696
|
+
|
|
697
|
+
AutoComplete can also be used with reactive forms. In this case, the formControlName property is used to bind the component to a form control.
|
|
698
|
+
|
|
699
|
+
```typescript
|
|
700
|
+
import { Component, inject } from '@angular/core';
|
|
701
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
702
|
+
import { AutoCompleteModule } from '@exhaustive-ui/core/autocomplete';
|
|
703
|
+
import { MessageModule } from '@exhaustive-ui/core/message';
|
|
704
|
+
import { ToastModule } from '@exhaustive-ui/core/toast';
|
|
705
|
+
import { ButtonModule } from '@exhaustive-ui/core/button';
|
|
706
|
+
import { MessageService } from '@exhaustive-ui/core/api';
|
|
707
|
+
|
|
708
|
+
interface AutoCompleteCompleteEvent {
|
|
709
|
+
originalEvent: Event;
|
|
710
|
+
query: string;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
@Component({
|
|
714
|
+
template: `
|
|
715
|
+
<p-toast />
|
|
716
|
+
<div class="card flex justify-center">
|
|
717
|
+
<form [formGroup]="exampleForm" (ngSubmit)="onSubmit()" class="flex justify-center flex-col gap-4 md:w-56">
|
|
718
|
+
<div class="flex flex-col gap-1">
|
|
719
|
+
<p-autocomplete formControlName="value" [suggestions]="items" [invalid]="isInvalid('value')" (completeMethod)="search($event)" fluid />
|
|
720
|
+
@if (isInvalid('value')) {
|
|
721
|
+
<p-message severity="error" size="small" variant="simple">Value is required.</p-message>
|
|
722
|
+
}
|
|
723
|
+
</div>
|
|
724
|
+
<button pButton severity="secondary" type="submit"><span pButtonLabel>Submit</span></button>
|
|
725
|
+
</form>
|
|
726
|
+
</div>
|
|
727
|
+
`,
|
|
728
|
+
standalone: true,
|
|
729
|
+
imports: [AutoCompleteModule, MessageModule, ToastModule, ButtonModule, ReactiveFormsModule]
|
|
730
|
+
})
|
|
731
|
+
export class AutocompleteReactiveFormsDemo {
|
|
732
|
+
messageService = inject(MessageService);
|
|
733
|
+
items: any[] | undefined;
|
|
734
|
+
exampleForm: FormGroup | undefined;
|
|
735
|
+
formSubmitted: boolean = false;
|
|
736
|
+
|
|
737
|
+
constructor() {
|
|
738
|
+
this.exampleForm = this.fb.group({
|
|
739
|
+
value: ['', Validators.required]
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
search(event: AutoCompleteCompleteEvent) {
|
|
744
|
+
this.items = [...Array(10).keys()].map((item) => event.query + '-' + item);
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
onSubmit() {
|
|
748
|
+
this.formSubmitted = true;
|
|
749
|
+
if (this.exampleForm.valid) {
|
|
750
|
+
this.messageService.add({ severity: 'success', summary: 'Success', detail: 'Form is submitted', life: 3000 });
|
|
751
|
+
this.exampleForm.reset();
|
|
752
|
+
this.formSubmitted = false;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
isInvalid(controlName: string) {
|
|
757
|
+
const control = this.exampleForm.get(controlName);
|
|
758
|
+
return control?.invalid && (control.touched || this.formSubmitted);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
```
|
|
762
|
+
|
|
763
|
+
## Sizes
|
|
764
|
+
|
|
765
|
+
AutoComplete provides small and large sizes as alternatives to the base.
|
|
766
|
+
|
|
767
|
+
```typescript
|
|
768
|
+
import { Component } from '@angular/core';
|
|
769
|
+
import { FormsModule } from '@angular/forms';
|
|
770
|
+
import { AutoCompleteModule } from '@exhaustive-ui/core/autocomplete';
|
|
771
|
+
|
|
772
|
+
@Component({
|
|
773
|
+
template: `
|
|
774
|
+
<div class="card flex flex-col items-center gap-4">
|
|
775
|
+
<p-autocomplete [(ngModel)]="value1" [suggestions]="items" (completeMethod)="search()" size="small" placeholder="Small" dropdown />
|
|
776
|
+
<p-autocomplete [(ngModel)]="value2" [suggestions]="items" (completeMethod)="search()" placeholder="Normal" dropdown />
|
|
777
|
+
<p-autocomplete [(ngModel)]="value3" [suggestions]="items" (completeMethod)="search()" size="large" placeholder="Large" dropdown />
|
|
778
|
+
</div>
|
|
779
|
+
`,
|
|
780
|
+
standalone: true,
|
|
781
|
+
imports: [AutoCompleteModule, FormsModule]
|
|
782
|
+
})
|
|
783
|
+
export class AutocompleteSizesDemo {
|
|
784
|
+
items: any[] | undefined;
|
|
785
|
+
value1: any;
|
|
786
|
+
value2: any;
|
|
787
|
+
value3: any;
|
|
788
|
+
|
|
789
|
+
search() {
|
|
790
|
+
this.items = [];
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
```
|
|
794
|
+
|
|
795
|
+
## Template
|
|
796
|
+
|
|
797
|
+
AutoComplete offers multiple templates for customization through templating.
|
|
798
|
+
|
|
799
|
+
```typescript
|
|
800
|
+
import { Component, OnInit, inject } from '@angular/core';
|
|
801
|
+
import { FormsModule } from '@angular/forms';
|
|
802
|
+
import { AutoCompleteModule } from '@exhaustive-ui/core/autocomplete';
|
|
803
|
+
import { ButtonModule } from '@exhaustive-ui/core/button';
|
|
804
|
+
import { CountryService } from '@/service/countryservice';
|
|
805
|
+
|
|
806
|
+
interface AutoCompleteCompleteEvent {
|
|
807
|
+
originalEvent: Event;
|
|
808
|
+
query: string;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
@Component({
|
|
812
|
+
template: `
|
|
813
|
+
<div class="card flex justify-center">
|
|
814
|
+
<p-autocomplete [(ngModel)]="selectedCountryAdvanced" [suggestions]="filteredCountries" (completeMethod)="filterCountry($event)" optionLabel="name">
|
|
815
|
+
<ng-template let-country #item>
|
|
816
|
+
<div class="flex items-center gap-2">
|
|
817
|
+
<img src="https://exhaustive-ui.e-xiste.com/demo/flag/flag_placeholder.png" [class]="'flag flag-' + country.code.toLowerCase()" style="width: 18px" />
|
|
818
|
+
<div>{{ country.name }}</div>
|
|
819
|
+
</div>
|
|
820
|
+
</ng-template>
|
|
821
|
+
<ng-template #header>
|
|
822
|
+
<div class="font-medium px-3 py-2">Available Countries</div>
|
|
823
|
+
</ng-template>
|
|
824
|
+
<ng-template #footer>
|
|
825
|
+
<div class="px-3 py-3">
|
|
826
|
+
<p-button label="Add New" fluid severity="secondary" text size="small" icon="pi pi-plus" />
|
|
827
|
+
</div>
|
|
828
|
+
</ng-template>
|
|
829
|
+
</p-autocomplete>
|
|
830
|
+
</div>
|
|
831
|
+
`,
|
|
832
|
+
standalone: true,
|
|
833
|
+
imports: [AutoCompleteModule, ButtonModule, FormsModule],
|
|
834
|
+
providers: [CountryService]
|
|
835
|
+
})
|
|
836
|
+
export class AutocompleteTemplateDemo implements OnInit {
|
|
837
|
+
private countryService = inject(CountryService);
|
|
838
|
+
countries: any[] | undefined;
|
|
839
|
+
selectedCountryAdvanced: any[] | undefined;
|
|
840
|
+
filteredCountries: any[] | undefined;
|
|
841
|
+
|
|
842
|
+
ngOnInit() {
|
|
843
|
+
this.countryService.getCountries().then((countries) => {
|
|
844
|
+
this.countries = countries;
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
filterCountry(event: AutoCompleteCompleteEvent) {
|
|
849
|
+
let filtered: any[] = [];
|
|
850
|
+
let query = event.query;
|
|
851
|
+
|
|
852
|
+
for (let i = 0; i < (this.countries as any[]).length; i++) {
|
|
853
|
+
let country = (this.countries as any[])[i];
|
|
854
|
+
if (country.name.toLowerCase().indexOf(query.toLowerCase()) == 0) {
|
|
855
|
+
filtered.push(country);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
this.filteredCountries = filtered;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
```
|
|
862
|
+
|
|
863
|
+
## template-driven-forms-doc
|
|
864
|
+
|
|
865
|
+
```typescript
|
|
866
|
+
import { Component, inject } from '@angular/core';
|
|
867
|
+
import { FormsModule } from '@angular/forms';
|
|
868
|
+
import { AutoCompleteModule } from '@exhaustive-ui/core/autocomplete';
|
|
869
|
+
import { MessageModule } from '@exhaustive-ui/core/message';
|
|
870
|
+
import { ToastModule } from '@exhaustive-ui/core/toast';
|
|
871
|
+
import { ButtonModule } from '@exhaustive-ui/core/button';
|
|
872
|
+
import { MessageService } from '@exhaustive-ui/core/api';
|
|
873
|
+
|
|
874
|
+
@Component({
|
|
875
|
+
template: `
|
|
876
|
+
<p-toast />
|
|
877
|
+
<div class="card flex justify-center">
|
|
878
|
+
<form #exampleForm="ngForm" (ngSubmit)="onSubmit(exampleForm)" class="flex justify-center flex-col gap-4 md:w-56">
|
|
879
|
+
<div class="flex flex-col gap-1">
|
|
880
|
+
<p-autocomplete #val="ngModel" [(ngModel)]="value" [suggestions]="items" [invalid]="val.invalid && (val.touched || exampleForm.submitted)" name="val" (completeMethod)="search($event)" required fluid />
|
|
881
|
+
@if (val.invalid && (val.touched || exampleForm.submitted)) {
|
|
882
|
+
<p-message severity="error" size="small" variant="simple">Value is required.</p-message>
|
|
883
|
+
}
|
|
884
|
+
</div>
|
|
885
|
+
<button pButton severity="secondary" type="submit"><span pButtonLabel>Submit</span></button>
|
|
886
|
+
</form>
|
|
887
|
+
</div>
|
|
888
|
+
`,
|
|
889
|
+
standalone: true,
|
|
890
|
+
imports: [AutoCompleteModule, MessageModule, ToastModule, ButtonModule, FormsModule]
|
|
891
|
+
})
|
|
892
|
+
export class AutocompleteTemplateDrivenFormsDemo {
|
|
893
|
+
messageService = inject(MessageService);
|
|
894
|
+
items: any[] = [];
|
|
895
|
+
value: any;
|
|
896
|
+
|
|
897
|
+
search(event: AutoCompleteCompleteEvent) {
|
|
898
|
+
this.items = [...Array(10).keys()].map((item) => event.query + '-' + item);
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
onSubmit(form: any) {
|
|
902
|
+
if (form.valid) {
|
|
903
|
+
this.messageService.add({ severity: 'success', summary: 'Success', detail: 'Form Submitted', life: 3000 });
|
|
904
|
+
form.resetForm();
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
```
|
|
909
|
+
|
|
910
|
+
## virtual-scroll-doc
|
|
911
|
+
|
|
912
|
+
Virtual scrolling 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 virtual scrolling to avoid performance issues. Usage is simple as setting virtualScroll property to true and defining virtualScrollItemSize to specify the height of an item.
|
|
913
|
+
|
|
914
|
+
```typescript
|
|
915
|
+
import { Component, OnInit } from '@angular/core';
|
|
916
|
+
import { FormsModule } from '@angular/forms';
|
|
917
|
+
import { AutoCompleteModule } from '@exhaustive-ui/core/autocomplete';
|
|
918
|
+
|
|
919
|
+
interface AutoCompleteCompleteEvent {
|
|
920
|
+
originalEvent: Event;
|
|
921
|
+
query: string;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
@Component({
|
|
925
|
+
template: `
|
|
926
|
+
<div class="card flex justify-center">
|
|
927
|
+
<p-autocomplete [(ngModel)]="selectedItem" [virtualScroll]="true" [suggestions]="filteredItems" [virtualScrollItemSize]="34" (completeMethod)="filterItems($event)" optionLabel="label" [dropdown]="true" />
|
|
928
|
+
</div>
|
|
929
|
+
`,
|
|
930
|
+
standalone: true,
|
|
931
|
+
imports: [AutoCompleteModule, FormsModule]
|
|
932
|
+
})
|
|
933
|
+
export class AutocompleteVirtualScrollDemo implements OnInit {
|
|
934
|
+
selectedItem: any;
|
|
935
|
+
filteredItems: any[] | undefined;
|
|
936
|
+
items: any[] | undefined;
|
|
937
|
+
|
|
938
|
+
ngOnInit() {
|
|
939
|
+
this.items = [];
|
|
940
|
+
for (let i = 0; i < 10000; i++) {
|
|
941
|
+
this.items.push({ label: 'Item ' + i, value: 'Item ' + i });
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
filterItems(event: AutoCompleteCompleteEvent) {
|
|
946
|
+
//in a real application, make a request to a remote url with the query and return filtered results, for demo we filter at client side
|
|
947
|
+
let filtered: any[] = [];
|
|
948
|
+
let query = event.query;
|
|
949
|
+
|
|
950
|
+
for (let i = 0; i < (this.items as any[]).length; i++) {
|
|
951
|
+
let item = (this.items as any[])[i];
|
|
952
|
+
if (item.label.toLowerCase().indexOf(query.toLowerCase()) == 0) {
|
|
953
|
+
filtered.push(item);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
this.filteredItems = filtered;
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
```
|
|
961
|
+
|
|
962
|
+
## Pass Through Options
|
|
963
|
+
|
|
964
|
+
| Name | Type | Description |
|
|
965
|
+
|------|------|-------------|
|
|
966
|
+
| host | PassThroughOption<HTMLElement, I> | Used to pass attributes to the host's DOM element. |
|
|
967
|
+
| root | PassThroughOption<HTMLElement, I> | Used to pass attributes to the root's DOM element. |
|
|
968
|
+
| pcInputText | InputTextPassThrough | Used to pass attributes to the InputText component. |
|
|
969
|
+
| inputMultiple | PassThroughOption<HTMLUListElement, I> | Used to pass attributes to the input multiple's DOM element. |
|
|
970
|
+
| chipItem | PassThroughOption<HTMLLIElement, I> | Used to pass attributes to the chip item's DOM element. |
|
|
971
|
+
| pcChip | ChipPassThrough | Used to pass attributes to the Chip component. |
|
|
972
|
+
| chipIcon | PassThroughOption<HTMLSpanElement, I> | Used to pass attributes to the chip icon's DOM element. |
|
|
973
|
+
| inputChip | PassThroughOption<HTMLLIElement, I> | Used to pass attributes to the input chip's DOM element. |
|
|
974
|
+
| clearIcon | PassThroughOption<SVGElement, I> | Used to pass attributes to the clear icon's DOM element. |
|
|
975
|
+
| loader | PassThroughOption<SVGElement, I> | Used to pass attributes to the loader's DOM element. |
|
|
976
|
+
| dropdown | PassThroughOption<HTMLButtonElement, I> | Used to pass attributes to the dropdown button's DOM element. |
|
|
977
|
+
| pcOverlay | OverlayPassThrough | Used to pass attributes to the Overlay component. |
|
|
978
|
+
| overlay | PassThroughOption<HTMLDivElement, I> | Used to pass attributes to the overlay's DOM element. |
|
|
979
|
+
| listContainer | PassThroughOption<HTMLDivElement, I> | Used to pass attributes to the list container's DOM element. |
|
|
980
|
+
| pcScroller | VirtualScrollerPassThrough | Used to pass attributes to the Scroller component. |
|
|
981
|
+
| list | PassThroughOption<HTMLUListElement, I> | Used to pass attributes to the list's DOM element. |
|
|
982
|
+
| optionGroup | PassThroughOption<HTMLLIElement, I> | Used to pass attributes to the option group's DOM element. |
|
|
983
|
+
| option | PassThroughOption<HTMLLIElement, I> | Used to pass attributes to the option's DOM element. |
|
|
984
|
+
| emptyMessage | PassThroughOption<HTMLLIElement, I> | Used to pass attributes to the empty message's DOM element. |
|
|
985
|
+
|
|
986
|
+
## Theming
|
|
987
|
+
|
|
988
|
+
### CSS Classes
|
|
989
|
+
|
|
990
|
+
| Class | Description |
|
|
991
|
+
|-------|-------------|
|
|
992
|
+
| p-autocomplete | Class name of the root element |
|
|
993
|
+
| p-autocomplete-input | Class name of the input element |
|
|
994
|
+
| p-autocomplete-input-multiple | Class name of the input multiple element |
|
|
995
|
+
| p-autocomplete-chip-item | Class name of the chip item element |
|
|
996
|
+
| p-autocomplete-chip | Class name of the chip element |
|
|
997
|
+
| p-autocomplete-chip-icon | Class name of the chip icon element |
|
|
998
|
+
| p-autocomplete-input-chip | Class name of the input chip element |
|
|
999
|
+
| p-autocomplete-loader | Class name of the loader element |
|
|
1000
|
+
| p-autocomplete-dropdown | Class name of the dropdown element |
|
|
1001
|
+
| p-autocomplete-overlay | Class name of the panel element |
|
|
1002
|
+
| p-autocomplete-list | Class name of the list element |
|
|
1003
|
+
| p-autocomplete-option-group | Class name of the option group element |
|
|
1004
|
+
| p-autocomplete-option | Class name of the option element |
|
|
1005
|
+
| p-autocomplete-empty-message | Class name of the empty message element |
|
|
1006
|
+
| p-autocomplete-clear-icon | Class name of the clear icon |
|
|
1007
|
+
|
|
1008
|
+
### Design Tokens
|
|
1009
|
+
|
|
1010
|
+
| Token | CSS Variable | Description |
|
|
1011
|
+
|-------|--------------|-------------|
|
|
1012
|
+
| autocomplete.background | --p-autocomplete-background | Background of root |
|
|
1013
|
+
| autocomplete.disabled.background | --p-autocomplete-disabled-background | Disabled background of root |
|
|
1014
|
+
| autocomplete.filled.background | --p-autocomplete-filled-background | Filled background of root |
|
|
1015
|
+
| autocomplete.filled.hover.background | --p-autocomplete-filled-hover-background | Filled hover background of root |
|
|
1016
|
+
| autocomplete.filled.focus.background | --p-autocomplete-filled-focus-background | Filled focus background of root |
|
|
1017
|
+
| autocomplete.border.color | --p-autocomplete-border-color | Border color of root |
|
|
1018
|
+
| autocomplete.hover.border.color | --p-autocomplete-hover-border-color | Hover border color of root |
|
|
1019
|
+
| autocomplete.focus.border.color | --p-autocomplete-focus-border-color | Focus border color of root |
|
|
1020
|
+
| autocomplete.invalid.border.color | --p-autocomplete-invalid-border-color | Invalid border color of root |
|
|
1021
|
+
| autocomplete.color | --p-autocomplete-color | Color of root |
|
|
1022
|
+
| autocomplete.disabled.color | --p-autocomplete-disabled-color | Disabled color of root |
|
|
1023
|
+
| autocomplete.placeholder.color | --p-autocomplete-placeholder-color | Placeholder color of root |
|
|
1024
|
+
| autocomplete.invalid.placeholder.color | --p-autocomplete-invalid-placeholder-color | Invalid placeholder color of root |
|
|
1025
|
+
| autocomplete.shadow | --p-autocomplete-shadow | Shadow of root |
|
|
1026
|
+
| autocomplete.padding.x | --p-autocomplete-padding-x | Padding x of root |
|
|
1027
|
+
| autocomplete.padding.y | --p-autocomplete-padding-y | Padding y of root |
|
|
1028
|
+
| autocomplete.border.radius | --p-autocomplete-border-radius | Border radius of root |
|
|
1029
|
+
| autocomplete.focus.ring.width | --p-autocomplete-focus-ring-width | Focus ring width of root |
|
|
1030
|
+
| autocomplete.focus.ring.style | --p-autocomplete-focus-ring-style | Focus ring style of root |
|
|
1031
|
+
| autocomplete.focus.ring.color | --p-autocomplete-focus-ring-color | Focus ring color of root |
|
|
1032
|
+
| autocomplete.focus.ring.offset | --p-autocomplete-focus-ring-offset | Focus ring offset of root |
|
|
1033
|
+
| autocomplete.focus.ring.shadow | --p-autocomplete-focus-ring-shadow | Focus ring shadow of root |
|
|
1034
|
+
| autocomplete.transition.duration | --p-autocomplete-transition-duration | Transition duration of root |
|
|
1035
|
+
| autocomplete.overlay.background | --p-autocomplete-overlay-background | Background of overlay |
|
|
1036
|
+
| autocomplete.overlay.border.color | --p-autocomplete-overlay-border-color | Border color of overlay |
|
|
1037
|
+
| autocomplete.overlay.border.radius | --p-autocomplete-overlay-border-radius | Border radius of overlay |
|
|
1038
|
+
| autocomplete.overlay.color | --p-autocomplete-overlay-color | Color of overlay |
|
|
1039
|
+
| autocomplete.overlay.shadow | --p-autocomplete-overlay-shadow | Shadow of overlay |
|
|
1040
|
+
| autocomplete.list.padding | --p-autocomplete-list-padding | Padding of list |
|
|
1041
|
+
| autocomplete.list.gap | --p-autocomplete-list-gap | Gap of list |
|
|
1042
|
+
| autocomplete.option.focus.background | --p-autocomplete-option-focus-background | Focus background of option |
|
|
1043
|
+
| autocomplete.option.selected.background | --p-autocomplete-option-selected-background | Selected background of option |
|
|
1044
|
+
| autocomplete.option.selected.focus.background | --p-autocomplete-option-selected-focus-background | Selected focus background of option |
|
|
1045
|
+
| autocomplete.option.color | --p-autocomplete-option-color | Color of option |
|
|
1046
|
+
| autocomplete.option.focus.color | --p-autocomplete-option-focus-color | Focus color of option |
|
|
1047
|
+
| autocomplete.option.selected.color | --p-autocomplete-option-selected-color | Selected color of option |
|
|
1048
|
+
| autocomplete.option.selected.focus.color | --p-autocomplete-option-selected-focus-color | Selected focus color of option |
|
|
1049
|
+
| autocomplete.option.padding | --p-autocomplete-option-padding | Padding of option |
|
|
1050
|
+
| autocomplete.option.border.radius | --p-autocomplete-option-border-radius | Border radius of option |
|
|
1051
|
+
| autocomplete.option.group.background | --p-autocomplete-option-group-background | Background of option group |
|
|
1052
|
+
| autocomplete.option.group.color | --p-autocomplete-option-group-color | Color of option group |
|
|
1053
|
+
| autocomplete.option.group.font.weight | --p-autocomplete-option-group-font-weight | Font weight of option group |
|
|
1054
|
+
| autocomplete.option.group.padding | --p-autocomplete-option-group-padding | Padding of option group |
|
|
1055
|
+
| autocomplete.dropdown.width | --p-autocomplete-dropdown-width | Width of dropdown |
|
|
1056
|
+
| autocomplete.dropdown.sm.width | --p-autocomplete-dropdown-sm-width | Sm width of dropdown |
|
|
1057
|
+
| autocomplete.dropdown.lg.width | --p-autocomplete-dropdown-lg-width | Lg width of dropdown |
|
|
1058
|
+
| autocomplete.dropdown.border.color | --p-autocomplete-dropdown-border-color | Border color of dropdown |
|
|
1059
|
+
| autocomplete.dropdown.hover.border.color | --p-autocomplete-dropdown-hover-border-color | Hover border color of dropdown |
|
|
1060
|
+
| autocomplete.dropdown.active.border.color | --p-autocomplete-dropdown-active-border-color | Active border color of dropdown |
|
|
1061
|
+
| autocomplete.dropdown.border.radius | --p-autocomplete-dropdown-border-radius | Border radius of dropdown |
|
|
1062
|
+
| autocomplete.dropdown.focus.ring.width | --p-autocomplete-dropdown-focus-ring-width | Focus ring width of dropdown |
|
|
1063
|
+
| autocomplete.dropdown.focus.ring.style | --p-autocomplete-dropdown-focus-ring-style | Focus ring style of dropdown |
|
|
1064
|
+
| autocomplete.dropdown.focus.ring.color | --p-autocomplete-dropdown-focus-ring-color | Focus ring color of dropdown |
|
|
1065
|
+
| autocomplete.dropdown.focus.ring.offset | --p-autocomplete-dropdown-focus-ring-offset | Focus ring offset of dropdown |
|
|
1066
|
+
| autocomplete.dropdown.focus.ring.shadow | --p-autocomplete-dropdown-focus-ring-shadow | Focus ring shadow of dropdown |
|
|
1067
|
+
| autocomplete.dropdown.background | --p-autocomplete-dropdown-background | Background of dropdown |
|
|
1068
|
+
| autocomplete.dropdown.hover.background | --p-autocomplete-dropdown-hover-background | Hover background of dropdown |
|
|
1069
|
+
| autocomplete.dropdown.active.background | --p-autocomplete-dropdown-active-background | Active background of dropdown |
|
|
1070
|
+
| autocomplete.dropdown.color | --p-autocomplete-dropdown-color | Color of dropdown |
|
|
1071
|
+
| autocomplete.dropdown.hover.color | --p-autocomplete-dropdown-hover-color | Hover color of dropdown |
|
|
1072
|
+
| autocomplete.dropdown.active.color | --p-autocomplete-dropdown-active-color | Active color of dropdown |
|
|
1073
|
+
| autocomplete.chip.border.radius | --p-autocomplete-chip-border-radius | Border radius of chip |
|
|
1074
|
+
| autocomplete.chip.focus.background | --p-autocomplete-chip-focus-background | Focus background of chip |
|
|
1075
|
+
| autocomplete.chip.focus.color | --p-autocomplete-chip-focus-color | Focus color of chip |
|
|
1076
|
+
| autocomplete.empty.message.padding | --p-autocomplete-empty-message-padding | Padding of empty message |
|
|
1077
|
+
|