@aliaksei-raketski/pi-angular-developer 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +44 -0
  2. package/overlays/angular-developer/references/docs-helpers.md +36 -0
  3. package/overlays/angular-developer/scripts/get-best-practices.mjs +268 -0
  4. package/overlays/angular-developer/scripts/search-documentation.mjs +396 -0
  5. package/package.json +41 -0
  6. package/scripts/sync-angular-skill.mjs +307 -0
  7. package/skills/angular-developer/SKILL.md +133 -0
  8. package/skills/angular-developer/UPSTREAM.md +9 -0
  9. package/skills/angular-developer/data/best-practices.md +56 -0
  10. package/skills/angular-developer/references/angular-animations.md +160 -0
  11. package/skills/angular-developer/references/angular-aria.md +597 -0
  12. package/skills/angular-developer/references/cli.md +86 -0
  13. package/skills/angular-developer/references/component-harnesses.md +57 -0
  14. package/skills/angular-developer/references/component-styling.md +91 -0
  15. package/skills/angular-developer/references/components.md +117 -0
  16. package/skills/angular-developer/references/creating-services.md +97 -0
  17. package/skills/angular-developer/references/data-resolvers.md +69 -0
  18. package/skills/angular-developer/references/define-routes.md +67 -0
  19. package/skills/angular-developer/references/defining-providers.md +72 -0
  20. package/skills/angular-developer/references/di-fundamentals.md +118 -0
  21. package/skills/angular-developer/references/docs-helpers.md +36 -0
  22. package/skills/angular-developer/references/e2e-testing.md +66 -0
  23. package/skills/angular-developer/references/effects.md +83 -0
  24. package/skills/angular-developer/references/environment-configuration.md +132 -0
  25. package/skills/angular-developer/references/hierarchical-injectors.md +43 -0
  26. package/skills/angular-developer/references/host-elements.md +80 -0
  27. package/skills/angular-developer/references/injection-context.md +63 -0
  28. package/skills/angular-developer/references/inputs.md +101 -0
  29. package/skills/angular-developer/references/linked-signal.md +59 -0
  30. package/skills/angular-developer/references/loading-strategies.md +61 -0
  31. package/skills/angular-developer/references/migrations.md +30 -0
  32. package/skills/angular-developer/references/navigate-to-routes.md +69 -0
  33. package/skills/angular-developer/references/outputs.md +86 -0
  34. package/skills/angular-developer/references/reactive-forms.md +118 -0
  35. package/skills/angular-developer/references/rendering-strategies.md +44 -0
  36. package/skills/angular-developer/references/resource.md +74 -0
  37. package/skills/angular-developer/references/route-animations.md +56 -0
  38. package/skills/angular-developer/references/route-guards.md +52 -0
  39. package/skills/angular-developer/references/router-lifecycle.md +45 -0
  40. package/skills/angular-developer/references/router-testing.md +87 -0
  41. package/skills/angular-developer/references/show-routes-with-outlets.md +68 -0
  42. package/skills/angular-developer/references/signal-forms.md +907 -0
  43. package/skills/angular-developer/references/signals-overview.md +94 -0
  44. package/skills/angular-developer/references/tailwind-css.md +69 -0
  45. package/skills/angular-developer/references/template-driven-forms.md +114 -0
  46. package/skills/angular-developer/references/testing-fundamentals.md +63 -0
  47. package/skills/angular-developer/scripts/get-best-practices.mjs +268 -0
  48. package/skills/angular-developer/scripts/search-documentation.mjs +396 -0
@@ -0,0 +1,597 @@
1
+ # Angular Aria
2
+
3
+ Angular Aria (`@angular/aria`) is a collection of headless, accessible directives that implement common WAI-ARIA patterns. These directives handle keyboard interactions, ARIA attributes, focus management, and screen reader support.
4
+
5
+ **As an AI Agent, your role is to provide the HTML structure and CSS styling**, while the directives handle the complex accessibility logic.
6
+
7
+ ## Styling Headless Components
8
+
9
+ Because Angular Aria components are headless, they do not come with default styles. You **must** use CSS to style different states based on the ARIA attributes or structural classes the directives automatically apply.
10
+
11
+ Common ARIA attributes to target in CSS:
12
+
13
+ - `[aria-expanded="true"]` / `[aria-expanded="false"]`
14
+ - `[aria-selected="true"]`
15
+ - `[aria-disabled="true"]`
16
+ - `[aria-current="page"]` (for navigation)
17
+
18
+ ---
19
+
20
+ **CRITICAL**: Before using this package, it must be installed via the package manager. Confirm that it has been installed in the project. Use `npm install @angular/aria` to install if necessary.
21
+
22
+ ## 1. Accordion
23
+
24
+ Organizes related content into expandable/collapsible sections.
25
+
26
+ **Usage:** The Accordion is a layout component designed to organize content into logical groups that users can expand one at a time to reduce scrolling on content-heavy pages. Use it for FAQs, long forms, or progressive disclosure of information, but avoid it for primary navigation or scenarios where users must view multiple sections of content simultaneously.
27
+
28
+ **Imports:** `import { AccordionContent, AccordionGroup, AccordionPanel, AccordionTrigger } from '@angular/aria/accordion';`
29
+
30
+ **Directives:** `ngAccordionGroup`, `ngAccordionTrigger`, `ngAccordionPanel`, `ngAccordionContent` (for lazy loading).
31
+
32
+ ```ts
33
+ @Component({
34
+ selector: 'app-cmp',
35
+ imports: [AccordionContent, AccordionGroup, AccordionPanel, AccordionTrigger],
36
+ template: `...`,
37
+ styles: [],
38
+ })
39
+ export class App {
40
+ protected readonly title = signal('angular-app');
41
+ }
42
+ ```
43
+
44
+ ```html
45
+ <div ngAccordionGroup [multiExpandable]="false">
46
+ <div class="accordion-item">
47
+ <button ngAccordionTrigger [panel]="panel1" class="accordion-header">
48
+ Section 1
49
+ <span class="icon">▼</span>
50
+ </button>
51
+ <div ngAccordionPanel #panel1="ngAccordionPanel" class="accordion-panel">
52
+ <ng-template ngAccordionContent>
53
+ <p>Lazy loaded content here.</p>
54
+ </ng-template>
55
+ </div>
56
+ </div>
57
+ </div>
58
+ ```
59
+
60
+ **Styling Strategy:**
61
+ Target the `[aria-expanded]` attribute on the trigger to rotate icons, and style the panel visibility.
62
+
63
+ ```css
64
+ .accordion-header[aria-expanded='true'] .icon {
65
+ transform: rotate(180deg);
66
+ }
67
+
68
+ /* The panel directive handles DOM removal, but you can style the transition */
69
+ .accordion-panel {
70
+ padding: 1rem;
71
+ border-top: 1px solid #ccc;
72
+ }
73
+ ```
74
+
75
+ ---
76
+
77
+ ## 2. Listbox
78
+
79
+ A foundational directive for displaying a list of options. Used for visible selection lists (not dropdowns).
80
+
81
+ **Usage:** Visible selectable lists (single or multi-select).
82
+
83
+ **Imports:** `import {Listbox, Option} from '@angular/aria/listbox';`
84
+
85
+ **Directives:** `ngListbox`, `ngOption`.
86
+
87
+ ```ts
88
+ @Component({
89
+ selector: 'app-cmp',
90
+ imports: [Listbox, Option],
91
+ template: `...`,
92
+ styles: [],
93
+ })
94
+ export class App {
95
+ protected readonly title = signal('angular-app');
96
+ }
97
+ ```
98
+
99
+ ```html
100
+ <!-- horizontal or vertical orientation -->
101
+ <ul ngListbox [(value)]="selectedItems" orientation="horizontal" [multi]="true">
102
+ <li ngOption value="apple" class="option">Apple</li>
103
+ <li ngOption value="banana" class="option">Banana</li>
104
+ </ul>
105
+ ```
106
+
107
+ **Styling Strategy:**
108
+ Target `[aria-selected="true"]` for selected state and `:focus-visible` or `[data-active]` for the focused item (Angular Aria uses roving tabindex or activedescendant).
109
+
110
+ ```css
111
+ .option {
112
+ padding: 8px;
113
+ cursor: pointer;
114
+ }
115
+ .option[aria-selected='true'] {
116
+ background: #e0f7fa;
117
+ font-weight: bold;
118
+ }
119
+ /* Focus state managed by aria */
120
+ .option:focus-visible {
121
+ outline: 2px solid blue;
122
+ }
123
+ ```
124
+
125
+ ---
126
+
127
+ ## 3. Combobox, Select, and Multiselect
128
+
129
+ These patterns combine the `ngCombobox` directive (applied directly to the trigger/combobox element) with a popup containing an `ngListbox` widget.
130
+
131
+ - **Combobox (Autocomplete)**: Applied to an `<input ngCombobox>` element. Ideal when typing filters the list.
132
+ - **Select**: Applied to a focusable wrapper like a `<div ngCombobox>` or `<button ngCombobox>` element. Users select from a list of options.
133
+ - **Multiselect**: A Combobox or Select paired with a multi-select `ngListbox`.
134
+
135
+ **Imports:**
136
+
137
+ ```ts
138
+ import {Combobox, ComboboxPopup, ComboboxWidget} from '@angular/aria/combobox';
139
+ import {Listbox, Option} from '@angular/aria/listbox';
140
+ ```
141
+
142
+ **Directives:** `ngCombobox`, `ngComboboxPopup`, `ngComboboxWidget`, `ngListbox`, `ngOption`.
143
+
144
+ ```html
145
+ <!-- Example 1: Standard Autocomplete -->
146
+ <div>
147
+ <input
148
+ ngCombobox
149
+ #combobox="ngCombobox"
150
+ [(value)]="searchString"
151
+ [(expanded)]="isExpanded"
152
+ placeholder="Search options..."
153
+ class="select-trigger"
154
+ />
155
+
156
+ <ng-template ngComboboxPopup [combobox]="combobox">
157
+ <ul
158
+ ngComboboxWidget
159
+ ngListbox
160
+ #listbox="ngListbox"
161
+ [(value)]="selectedValue"
162
+ [activeDescendant]="listbox.activeDescendant()"
163
+ class="dropdown-menu"
164
+ >
165
+ <li ngOption value="option1" label="Option 1" class="option">Option 1</li>
166
+ <li ngOption value="option2" label="Option 2" class="option">Option 2</li>
167
+ </ul>
168
+ </ng-template>
169
+ </div>
170
+
171
+ <!-- Example 2: Select Component (Applied directly to a div trigger) -->
172
+ <div ngCombobox #select="ngCombobox" [(expanded)]="selectExpanded" class="select-trigger">
173
+ <span class="select-text">{{ selectedValue() ?? 'Choose an option' }}</span>
174
+ <span class="icon">▼</span>
175
+ </div>
176
+
177
+ <ng-template ngComboboxPopup [combobox]="select">
178
+ <ul
179
+ ngComboboxWidget
180
+ ngListbox
181
+ #selectListbox="ngListbox"
182
+ [(value)]="selectedValues"
183
+ [activeDescendant]="selectListbox.activeDescendant()"
184
+ (click)="onCommit()"
185
+ (keydown.enter)="onCommit()"
186
+ class="dropdown-menu"
187
+ >
188
+ <li ngOption value="option1" label="Option 1" class="option">Option 1</li>
189
+ <li ngOption value="option2" label="Option 2" class="option">Option 2</li>
190
+ </ul>
191
+ </ng-template>
192
+ ```
193
+
194
+ **Styling Strategy:**
195
+ Style the popup container to look like a dropdown floating above content (often paired with CDK Overlay).
196
+
197
+ ```css
198
+ .select-trigger {
199
+ width: 200px;
200
+ padding: 8px;
201
+ text-align: left;
202
+ }
203
+ .dropdown-menu {
204
+ list-style: none;
205
+ padding: 0;
206
+ margin: 0;
207
+ border: 1px solid #ccc;
208
+ background: white;
209
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
210
+ }
211
+ ```
212
+
213
+ ---
214
+
215
+ ## 4. Menu and Menubar
216
+
217
+ For actions, commands, and context menus (not for form selection).
218
+
219
+ **Usage:** The Menubar is a high-level navigation pattern designed for building desktop-style application command bars (e.g., File, Edit, View) that stay persistent across an interface. It is best utilized for organizing complex commands into logical top-level categories with full horizontal keyboard support, but it should be avoided for simple standalone action lists or mobile-first layouts where horizontal space is constrained.
220
+
221
+ **Imports:** `import {MenuBar, Menu, MenuContent, MenuItem, MenuTrigger} from '@angular/aria/menu';`
222
+
223
+ **Directives:** `ngMenuBar`, `ngMenu`, `ngMenuItem`, `ngMenuTrigger`, `ngMenuContent`.
224
+
225
+ ```html
226
+ <!-- Menubar Example -->
227
+ <div ngMenuBar class="menubar">
228
+ <div ngMenuItem value="file" [submenu]="fileMenu" class="menubar-item">File</div>
229
+ <div ngMenuItem value="edit" [submenu]="editMenu" class="menubar-item">Edit</div>
230
+ </div>
231
+
232
+ <div ngMenu #fileMenu="ngMenu" class="menu">
233
+ <ng-template ngMenuContent>
234
+ <div ngMenuItem value="new">New</div>
235
+ <div ngMenuItem value="open">Open</div>
236
+ </ng-template>
237
+ </div>
238
+
239
+ <div ngMenu #editMenu="ngMenu" class="menu">
240
+ <ng-template ngMenuContent>
241
+ <div ngMenuItem value="cut">Cut</div>
242
+ <div ngMenuItem value="copy">Copy</div>
243
+ </ng-template>
244
+ </div>
245
+ ```
246
+
247
+ **Styling Strategy:**
248
+ Use flexbox for the menubar. Hide/show submenus based on the trigger's state.
249
+
250
+ ```css
251
+ .menubar {
252
+ display: flex;
253
+ gap: 10px;
254
+ list-style: none;
255
+ padding: 0;
256
+ }
257
+ .menu {
258
+ background: white;
259
+ border: 1px solid #ccc;
260
+ padding: 5px 0;
261
+ }
262
+ .menu li {
263
+ padding: 5px 15px;
264
+ cursor: pointer;
265
+ }
266
+ ```
267
+
268
+ ---
269
+
270
+ ## 5. Tabs
271
+
272
+ Layered content sections where only one panel is visible.
273
+
274
+ **Usage:** The Tabs component is used to organize related content into distinct, navigable sections, allowing users to switch between categories or views without leaving the page. It is ideal for settings panels, multi-topic documentation, or dashboards, but should be avoided for sequential workflows (steppers) or when navigation involves more than 7–8 sections.
275
+
276
+ **Imports:** `import {Tab, Tabs, TabList, TabPanel, TabContent} from '@angular/aria/tabs';`
277
+
278
+ **Directives:** `ngTabs`, `ngTabList`, `ngTab`, `ngTabPanel`, `ngTabContent`.
279
+
280
+ ```html
281
+ <div ngTabs>
282
+ <ul ngTabList [(selectedTab)]="selectedTabValue" class="tab-list">
283
+ <li ngTab value="profile" class="tab-btn">Profile</li>
284
+ <li ngTab value="security" class="tab-btn">Security</li>
285
+ </ul>
286
+
287
+ <div ngTabPanel value="profile" class="tab-panel">
288
+ <ng-template ngTabContent>Profile Settings</ng-template>
289
+ </div>
290
+ <div ngTabPanel value="security" class="tab-panel">
291
+ <ng-template ngTabContent>Security Settings</ng-template>
292
+ </div>
293
+ </div>
294
+ ```
295
+
296
+ **Styling Strategy:**
297
+ Target `[aria-selected="true"]` on the tab buttons.
298
+
299
+ ```css
300
+ .tab-list {
301
+ display: flex;
302
+ border-bottom: 2px solid #ccc;
303
+ list-style: none;
304
+ padding: 0;
305
+ }
306
+ .tab-btn {
307
+ padding: 10px 20px;
308
+ cursor: pointer;
309
+ border-bottom: 2px solid transparent;
310
+ }
311
+ .tab-btn[aria-selected='true'] {
312
+ border-bottom-color: blue;
313
+ font-weight: bold;
314
+ }
315
+ .tab-panel {
316
+ padding: 20px;
317
+ }
318
+ ```
319
+
320
+ ---
321
+
322
+ ## 6. Toolbar
323
+
324
+ Groups related controls (like text formatting).
325
+
326
+ **Usage:** The Toolbar is an organizational component designed to group frequently accessed, related controls into a single logical container. It is best used to enhance keyboard efficiency (via arrow-key navigation) and visual structure for workflows requiring repeated actions, such as text formatting or media controls.
327
+
328
+ **Imports:** `import {Toolbar, ToolbarWidget, ToolbarWidgetGroup} from '@angular/aria/toolbar';`
329
+
330
+ **Directives:** `ngToolbar`, `ngToolbarWidget`, `ngToolbarWidgetGroup`.
331
+
332
+ ```html
333
+ <div ngToolbar class="toolbar">
334
+ <div ngToolbarWidgetGroup [multi]="true" role="group" aria-label="Formatting">
335
+ <button ngToolbarWidget value="bold" class="tool-btn">B</button>
336
+ <button ngToolbarWidget value="italic" class="tool-btn">I</button>
337
+ </div>
338
+ </div>
339
+ ```
340
+
341
+ **Styling Strategy:**
342
+ Target `[aria-pressed="true"]` (for toggle buttons) or `[aria-checked="true"]` (for radio groups) within the toolbar.
343
+
344
+ ```css
345
+ .toolbar {
346
+ display: flex;
347
+ gap: 5px;
348
+ padding: 8px;
349
+ background: #f5f5f5;
350
+ }
351
+ .tool-btn {
352
+ padding: 5px 10px;
353
+ border: 1px solid #ccc;
354
+ }
355
+ .tool-btn[aria-pressed='true'],
356
+ .tool-btn[aria-checked='true'] {
357
+ background: #ddd;
358
+ }
359
+ ```
360
+
361
+ ---
362
+
363
+ ## 7. Tree
364
+
365
+ Displays hierarchical data (file systems, nested nav).
366
+
367
+ **Usage:** The Tree component is designed for navigating and displaying deeply nested, hierarchical data structures like file systems, organization charts, or complex site architectures. It should be used specifically for multi-level relationships where users need to expand or collapse branches, but it should be avoided for flat lists, data tables, or simple selection menus.
368
+
369
+ **Imports:** `import {Tree, TreeItem, TreeItemGroup} from '@angular/aria/tree';`
370
+
371
+ **Directives:** `ngTree`, `ngTreeItem`, `ngTreeItemGroup`.
372
+
373
+ ```html
374
+ <ul ngTree #tree="ngTree" [(value)]="selectedValues" class="tree">
375
+ <li ngTreeItem [parent]="tree" value="documents" #docsItem="ngTreeItem">
376
+ <span class="tree-label">Documents</span>
377
+ <ul role="group">
378
+ <ng-template ngTreeItemGroup [ownedBy]="docsItem" #docsGroup="ngTreeItemGroup">
379
+ <li ngTreeItem [parent]="docsGroup" value="resume">Resume.pdf</li>
380
+ <li ngTreeItem [parent]="docsGroup" value="cover-letter">CoverLetter.pdf</li>
381
+ </ng-template>
382
+ </ul>
383
+ </li>
384
+ </ul>
385
+ ```
386
+
387
+ **Styling Strategy:**
388
+ Target `[aria-expanded]` to show/hide children or rotate chevron icons. Use `padding-left` on nested groups to show hierarchy.
389
+
390
+ ```css
391
+ .tree,
392
+ .tree-group {
393
+ list-style: none;
394
+ padding-left: 20px;
395
+ }
396
+ .tree-label::before {
397
+ content: '▶ ';
398
+ display: inline-block;
399
+ transition: transform 0.2s;
400
+ }
401
+ li[aria-expanded='true'] > .tree-label::before {
402
+ transform: rotate(90deg);
403
+ }
404
+ ```
405
+
406
+ ## 8. Grid
407
+
408
+ A two-dimensional interactive collection of cells enabling navigation via arrow keys.
409
+
410
+ **Usage:** Data tables, calendars, spreadsheets, and layout patterns for interactive elements.
411
+ **Directives:** `ngGrid`, `ngGridRow`, `ngGridCell`, `ngGridCellWidget`.
412
+
413
+ ```html
414
+ <table ngGrid [multi]="true" [enableSelection]="true" class="grid-table">
415
+ <tr ngGridRow>
416
+ <th ngGridCell role="columnheader">Name</th>
417
+ <th ngGridCell role="columnheader">Status</th>
418
+ </tr>
419
+ <tr ngGridRow>
420
+ <td ngGridCell>Project A</td>
421
+ <td ngGridCell [(selected)]="isSelected">
422
+ <button ngGridCellWidget (activated)="onActivate()">Active</button>
423
+ </td>
424
+ </tr>
425
+ </table>
426
+ ```
427
+
428
+ **Styling Strategy:**
429
+ Target `[aria-selected="true"]` for selected cells and `:focus-visible` for the active cell (roving tabindex) or `[aria-activedescendant]` on the container.
430
+
431
+ ```css
432
+ .grid-table {
433
+ border-collapse: collapse;
434
+ }
435
+ [ngGridCell] {
436
+ padding: 8px;
437
+ border: 1px solid #ddd;
438
+ }
439
+ [ngGridCell][aria-selected='true'] {
440
+ background: #e3f2fd;
441
+ }
442
+ /* Focus state managed by roving tabindex */
443
+ [ngGridCell]:focus-visible {
444
+ outline: 2px solid #2196f3;
445
+ outline-offset: -2px;
446
+ }
447
+ ```
448
+
449
+ ## 9. Testing with Component Harnesses
450
+
451
+ Angular Aria provides standard Component Harnesses (based on `@angular/cdk/testing`) to make unit testing clean, robust, and decoupled from DOM structural details.
452
+
453
+ **Imports:**
454
+
455
+ ```ts
456
+ import {HarnessLoader} from '@angular/cdk/testing';
457
+ import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
458
+ import {AccordionGroupHarness, AccordionHarness} from '@angular/aria/accordion/testing';
459
+ import {ListboxHarness, ListboxOptionHarness} from '@angular/aria/listbox/testing';
460
+ ```
461
+
462
+ ### Example: Testing an Accordion with Harnesses
463
+
464
+ ```ts
465
+ describe('MyAccordionComponent', () => {
466
+ let fixture: ComponentFixture<MyAccordionComponent>;
467
+ let loader: HarnessLoader;
468
+
469
+ beforeEach(async () => {
470
+ fixture = TestBed.createComponent(MyAccordionComponent);
471
+ await fixture.whenStable();
472
+ loader = TestbedHarnessEnvironment.loader(fixture);
473
+ });
474
+
475
+ it('should expand accordion on toggle', async () => {
476
+ // Get the harness by its trigger title
477
+ const accordion = await loader.getHarness(AccordionHarness.with({title: 'Section 1'}));
478
+
479
+ expect(await accordion.isExpanded()).toBeFalse();
480
+
481
+ // Expand the accordion
482
+ await accordion.expand();
483
+
484
+ expect(await accordion.isExpanded()).toBeTrue();
485
+ });
486
+ });
487
+ ```
488
+
489
+ ## 10. Integration with Signal Forms
490
+
491
+ Because Angular Aria directives leverage Angular's modern `model()` signals for managing interactive values, they integrate **out-of-the-box** with Angular's new Signal Forms (`@angular/forms/signals`).
492
+
493
+ The `[formField]` directive automatically detects directives like `ngCombobox` or `ngListbox` as custom form controls because they expose a `value` model.
494
+
495
+ **Imports:**
496
+
497
+ ```ts
498
+ import {form, schema, required} from '@angular/forms/signals';
499
+ import {Combobox, ComboboxPopup, ComboboxWidget} from '@angular/aria/combobox';
500
+ import {Listbox, Option} from '@angular/aria/listbox';
501
+ ```
502
+
503
+ ### Example 1: Autocomplete Combobox inside a Form
504
+
505
+ Given a form model defined in your component:
506
+
507
+ ```ts
508
+ protected readonly citySignal = signal({name: '', city: ''});
509
+ protected readonly myForm = form(this.citySignal, schema(f => {
510
+ required(f.city);
511
+ }));
512
+ ```
513
+
514
+ You bind it directly using `[formField]`:
515
+
516
+ ```html
517
+ <div>
518
+ <label for="city-input">Choose your city:</label>
519
+ <input
520
+ id="city-input"
521
+ ngCombobox
522
+ #combobox="ngCombobox"
523
+ [formField]="myForm.city"
524
+ [(expanded)]="isExpanded"
525
+ placeholder="Search cities..."
526
+ />
527
+
528
+ <ng-template ngComboboxPopup [combobox]="combobox">
529
+ <ul
530
+ ngComboboxWidget
531
+ ngListbox
532
+ #listbox="ngListbox"
533
+ [(value)]="selectedValue"
534
+ [activeDescendant]="listbox.activeDescendant()"
535
+ class="dropdown-menu"
536
+ >
537
+ <li ngOption value="sfo" label="San Francisco">San Francisco</li>
538
+ <li ngOption value="nyc" label="New York">New York</li>
539
+ </ul>
540
+ </ng-template>
541
+ </div>
542
+ ```
543
+
544
+ ### Example 2: Select Component inside a Form
545
+
546
+ Apply `ngCombobox` directly to a focusable `div` trigger and bind to `[formField]`:
547
+
548
+ ```html
549
+ <div>
550
+ <label for="city-select">Choose your city:</label>
551
+ <div
552
+ id="city-select"
553
+ ngCombobox
554
+ #select="ngCombobox"
555
+ [formField]="myForm.city"
556
+ [(expanded)]="isExpanded"
557
+ class="select-trigger"
558
+ >
559
+ <span class="select-text">{{ myForm.city.value() || 'Choose your city' }}</span>
560
+ <span class="icon">▼</span>
561
+ </div>
562
+
563
+ <ng-template ngComboboxPopup [combobox]="select">
564
+ <ul
565
+ ngComboboxWidget
566
+ ngListbox
567
+ #selectListbox="ngListbox"
568
+ [(value)]="selectedValues"
569
+ [activeDescendant]="selectListbox.activeDescendant()"
570
+ (click)="onCommit()"
571
+ (keydown.enter)="onCommit()"
572
+ class="dropdown-menu"
573
+ >
574
+ <li ngOption value="sfo" label="San Francisco">San Francisco</li>
575
+ <li ngOption value="nyc" label="New York">New York</li>
576
+ </ul>
577
+ </ng-template>
578
+ </div>
579
+ ```
580
+
581
+ ### Example 3: Standalone Listbox (Multi-select) inside a Form
582
+
583
+ You can bind a multi-selectable Listbox directly to a form array:
584
+
585
+ ```html
586
+ <ul ngListbox [formField]="myForm.interests" [multi]="true" class="interest-list">
587
+ <li ngOption value="sports">Sports</li>
588
+ <li ngOption value="music">Music</li>
589
+ <li ngOption value="tech">Technology</li>
590
+ </ul>
591
+ ```
592
+
593
+ ## General Rules for Agents
594
+
595
+ 1. **Never use native HTML elements like `<select>`** when asked to implement these specific Aria patterns. Use the `ng*` directives.
596
+ 2. **Handle CSS manually**: Remember that `Angular Aria` does NOT provide styles. You must write the CSS, targeting the native ARIA attributes (`aria-expanded`, `aria-selected`, etc.) that the directives automatically toggle.
597
+ 3. **Lazy Loading**: Always use the provided structural directives (`ngAccordionContent`, `ngTabContent`, `ngMenuContent`, `ngComboboxPopup`, `ngTreeItemGroup`) inside `ng-template` for heavy content panels or nested groups to ensure they are lazily rendered.
@@ -0,0 +1,86 @@
1
+ # Angular CLI Guide for Agents
2
+
3
+ The Angular CLI (`ng`) is the primary tool for managing an Angular workspace. Always prefer CLI commands over manual file creation or generic `npm` commands when modifying project structure or adding Angular-specific dependencies.
4
+
5
+ ## 1. Managing Dependencies
6
+
7
+ **ALWAYS use `ng add` for Angular libraries** instead of `npm install`. `ng add` installs the package AND runs initialization schematics (e.g., configuring `angular.json`, updating root providers).
8
+
9
+ ```bash
10
+ ng add @angular/material
11
+ ng add tailwindcss
12
+ ng add @angular/fire
13
+ ```
14
+
15
+ To update the application and its dependencies (which automatically runs code migrations):
16
+
17
+ ```bash
18
+ ng update @angular/core@<latest or specific version> @angular/cli<latest or specific version>
19
+ ```
20
+
21
+ ## 2. Generating Code (`ng generate` or `ng g`)
22
+
23
+ Always use the CLI to generate code to ensure it adheres to Angular standards and updates necessary configuration files automatically.
24
+
25
+ | Target | Command | Notes |
26
+ | :----------- | :-------------------- | :--------------------------------------------------------------------------------------------- |
27
+ | Component | `ng g c path/to/name` | Generates a component. Use `--inline-style` (`-s`) or `--inline-template` (`-t`) if requested. |
28
+ | Service | `ng g s path/to/name` | Generates an `@Service` service. |
29
+ | Directive | `ng g d path/to/name` | Generates a directive. |
30
+ | Pipe | `ng g p path/to/name` | Generates a pipe. |
31
+ | Guard | `ng g g path/to/name` | Generates a functional route guard. |
32
+ | Environments | `ng g environments` | Scaffolds `src/environments/` and updates `angular.json` with file replacements. |
33
+
34
+ _Note: There is no command to generate a single route definition. Generate a component, then manually add it to the `Routes` array in `app.routes.ts`._
35
+
36
+ ## 3. Development Server & Proxying
37
+
38
+ Start the local development server with hot-module replacement (HMR):
39
+
40
+ ```bash
41
+ ng serve
42
+ ```
43
+
44
+ ### Backend API Proxying
45
+
46
+ To proxy API requests during development (e.g., rerouting `/api` to a local Node server):
47
+
48
+ 1. Create `src/proxy.conf.json`:
49
+ ```json
50
+ {
51
+ "/api/**": {"target": "http://localhost:3000", "secure": false}
52
+ }
53
+ ```
54
+ 2. Update `angular.json` under the `serve` target:
55
+ ```json
56
+ "serve": {
57
+ "builder": "@angular/build:dev-server",
58
+ "options": { "proxyConfig": "src/proxy.conf.json" }
59
+ }
60
+ ```
61
+
62
+ ## 4. Building the Application
63
+
64
+ Compile the application into an output directory (default: `dist/<project-name>/browser`). Modern Angular uses the `@angular/build:application` builder (esbuild-based).
65
+
66
+ ```bash
67
+ ng build
68
+ ```
69
+
70
+ - `ng build` defaults to the production configuration, which enables Ahead-of-Time (AOT) compilation, minification, and tree-shaking.
71
+ - Target specific configurations defined in `angular.json` using `--configuration`: `ng build --configuration=staging`.
72
+
73
+ ## 5. Testing
74
+
75
+ - **Unit Tests**: Run `ng test` to execute unit tests via the configured test runner (e.g., Karma or Vitest).
76
+ - **End-to-End (E2E)**: Run `ng e2e`. If no E2E framework is configured, the CLI will prompt to install one (Cypress, Playwright, Puppeteer, etc.).
77
+
78
+ ## 6. Deployment
79
+
80
+ To deploy an application, you must first add a deployment builder, then run the deploy command:
81
+
82
+ ```bash
83
+ # Example for Firebase
84
+ ng add @angular/fire
85
+ ng deploy
86
+ ```