@cngx/common 0.0.1-rc.0 → 0.1.0-rc.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/a11y/README.md +13 -16
- package/card/README.md +2 -21
- package/chart/README.md +5 -8
- package/data/README.md +45 -47
- package/dialog/README.md +12 -15
- package/display/README.md +5 -9
- package/fesm2022/cngx-common-a11y.mjs +140 -40
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-card.mjs +157 -69
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +389 -92
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +311 -151
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +167 -29
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +445 -110
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +2025 -435
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +188 -31
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-popover.mjs +711 -90
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +1258 -60
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +247 -41
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +2 -2
- package/fesm2022/cngx-common.mjs.map +1 -1
- package/interactive/README.md +5 -5
- package/layout/README.md +2 -2
- package/package.json +5 -4
- package/popover/README.md +8 -34
- package/stepper/README.md +49 -8
- package/tabs/README.md +6 -6
- package/theming/components/cngx-async.css +74 -0
- package/theming/components/cngx-backdrop.css +73 -0
- package/theming/components/cngx-badge.css +340 -0
- package/theming/components/cngx-bottom-sheet.css +201 -0
- package/theming/components/cngx-button-toggle.css +99 -0
- package/theming/components/cngx-dialog.css +358 -0
- package/theming/components/cngx-divider.css +145 -0
- package/theming/components/cngx-listbox.css +220 -0
- package/theming/components/cngx-menu.css +371 -0
- package/theming/components/cngx-ripple.css +116 -0
- package/theming/components/cngx-tooltip.css +265 -0
- package/theming/system-tokens.css +24 -0
- package/types/cngx-common-a11y.d.ts +136 -36
- package/types/cngx-common-card.d.ts +137 -22
- package/types/cngx-common-chart.d.ts +337 -40
- package/types/cngx-common-data.d.ts +277 -45
- package/types/cngx-common-dialog.d.ts +162 -22
- package/types/cngx-common-display.d.ts +422 -78
- package/types/cngx-common-interactive.d.ts +1862 -305
- package/types/cngx-common-layout.d.ts +191 -28
- package/types/cngx-common-popover.d.ts +632 -87
- package/types/cngx-common-stepper.d.ts +1110 -38
- package/types/cngx-common-tabs.d.ts +306 -32
- package/types/cngx-common.d.ts +1 -1
- package/README.md +0 -18
|
@@ -33,6 +33,15 @@ import { FocusTrapFactory } from '@angular/cdk/a11y';
|
|
|
33
33
|
* }
|
|
34
34
|
* }
|
|
35
35
|
* ```
|
|
36
|
+
*
|
|
37
|
+
* @category common/a11y
|
|
38
|
+
* @docsKind primary
|
|
39
|
+
* @wcag AA
|
|
40
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/aria/aria-expanded.directive.ts
|
|
41
|
+
* @since 0.1.0
|
|
42
|
+
* @relatedTo CngxLiveRegion, CngxExpandable, CngxDisclosure
|
|
43
|
+
* <example-url>http://localhost:4200/#/common/a11y/aria-expanded/accordion-multiple-panels</example-url>
|
|
44
|
+
* <example-url>http://localhost:4200/#/common/a11y/aria-expanded/disclosure-pattern</example-url>
|
|
36
45
|
*/
|
|
37
46
|
class CngxAriaExpanded {
|
|
38
47
|
/** Whether the controlled element is currently expanded. Sets `aria-expanded`. */
|
|
@@ -63,11 +72,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
63
72
|
* `assertive` announcements interrupt immediately. `off` disables announcements.
|
|
64
73
|
*
|
|
65
74
|
* Sets `role="alert"` for assertive regions and `role="status"` for polite regions
|
|
66
|
-
* via a host binding
|
|
75
|
+
* via a host binding - no manual attribute wiring needed.
|
|
67
76
|
*
|
|
68
77
|
* Unlike CDK's `LiveAnnouncer` service (which creates a hidden DOM element and
|
|
69
78
|
* requires imperative `announce()` calls), this directive decorates your own
|
|
70
|
-
* element declaratively
|
|
79
|
+
* element declaratively - the content you render IS the announcement.
|
|
71
80
|
*
|
|
72
81
|
* ### Status message
|
|
73
82
|
* ```html
|
|
@@ -83,13 +92,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
83
92
|
* {{ error() }}
|
|
84
93
|
* </div>
|
|
85
94
|
* ```
|
|
95
|
+
*
|
|
96
|
+
* @category common/a11y
|
|
97
|
+
* @docsKind primary
|
|
98
|
+
* @wcag AA
|
|
99
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/aria/live-region.directive.ts
|
|
100
|
+
* @since 0.1.0
|
|
101
|
+
* @relatedTo CngxAriaExpanded
|
|
102
|
+
* <example-url>http://localhost:4200/#/common/a11y/live-region/form-validation-assertive-error-announcements</example-url>
|
|
103
|
+
* <example-url>http://localhost:4200/#/common/a11y/live-region/polite-vs-assertive</example-url>
|
|
86
104
|
*/
|
|
87
105
|
class CngxLiveRegion {
|
|
88
106
|
/**
|
|
89
107
|
* Controls the urgency of announcements.
|
|
90
|
-
* - `'polite'`
|
|
91
|
-
* - `'assertive'`
|
|
92
|
-
* - `'off'`
|
|
108
|
+
* - `'polite'` - queued after current speech (default)
|
|
109
|
+
* - `'assertive'` - interrupts immediately
|
|
110
|
+
* - `'off'` - no announcements
|
|
93
111
|
*/
|
|
94
112
|
politeness = input('polite', ...(ngDevMode ? [{ debugName: "politeness" }] : /* istanbul ignore next */ []));
|
|
95
113
|
/** Whether the entire region should be announced as a whole. */
|
|
@@ -140,11 +158,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
140
158
|
* ```html
|
|
141
159
|
* <input cngxAutofocus [autofocusDelay]="200" />
|
|
142
160
|
* ```
|
|
161
|
+
*
|
|
162
|
+
* @category common/a11y
|
|
163
|
+
* @docsKind primary
|
|
164
|
+
* @wcag AA
|
|
165
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/autofocus.directive.ts
|
|
166
|
+
* @since 0.1.0
|
|
167
|
+
* @relatedTo CngxFocusRestore, CngxFocusTrap, CngxFocusVisible
|
|
168
|
+
* <example-url>http://localhost:4200/#/common/a11y/autofocus/conditional-focus</example-url>
|
|
169
|
+
* <example-url>http://localhost:4200/#/common/a11y/autofocus/focus-on-insert</example-url>
|
|
143
170
|
*/
|
|
144
171
|
class CngxAutofocus {
|
|
145
172
|
/** Whether to focus the element. Defaults to `true` (always focus on render). */
|
|
146
173
|
when = input(true, { ...(ngDevMode ? { debugName: "when" } : /* istanbul ignore next */ {}), alias: 'cngxAutofocus' });
|
|
147
|
-
/** Delay in ms before focusing
|
|
174
|
+
/** Delay in ms before focusing - useful when the element appears during a transition. */
|
|
148
175
|
delay = input(0, { ...(ngDevMode ? { debugName: "delay" } : /* istanbul ignore next */ {}), alias: 'autofocusDelay' });
|
|
149
176
|
/** `FocusOptions` passed to `element.focus()`. */
|
|
150
177
|
options = input({}, { ...(ngDevMode ? { debugName: "options" } : /* istanbul ignore next */ {}), alias: 'autofocusOptions' });
|
|
@@ -229,6 +256,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
229
256
|
* </div>
|
|
230
257
|
* <button #fallbackBtn>Fallback target</button>
|
|
231
258
|
* ```
|
|
259
|
+
*
|
|
260
|
+
* @category common/a11y
|
|
261
|
+
* @docsKind primary
|
|
262
|
+
* @wcag AA
|
|
263
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/focus-restore.directive.ts
|
|
264
|
+
* @since 0.1.0
|
|
265
|
+
* @relatedTo CngxAutofocus, CngxFocusTrap, CngxFocusVisible
|
|
266
|
+
* <example-url>http://localhost:4200/#/common/a11y/focus-restore/inline-details</example-url>
|
|
267
|
+
* <example-url>http://localhost:4200/#/common/a11y/focus-restore/panel-with-automatic-restore</example-url>
|
|
232
268
|
*/
|
|
233
269
|
class CngxFocusRestore {
|
|
234
270
|
/** Whether to restore focus when the host element is destroyed. */
|
|
@@ -275,7 +311,7 @@ class CngxFocusRestore {
|
|
|
275
311
|
*/
|
|
276
312
|
resolveTarget() {
|
|
277
313
|
const stored = this.storedElement();
|
|
278
|
-
// Skip body
|
|
314
|
+
// Skip body - it signals "nothing meaningful was focused", not a real restore target.
|
|
279
315
|
if (stored &&
|
|
280
316
|
stored !== this.doc.body &&
|
|
281
317
|
this.doc.contains(stored) &&
|
|
@@ -351,6 +387,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
351
387
|
* <a href="/settings">Settings</a>
|
|
352
388
|
* </nav>
|
|
353
389
|
* ```
|
|
390
|
+
*
|
|
391
|
+
* @category common/a11y
|
|
392
|
+
* @docsKind primary
|
|
393
|
+
* @wcag AA
|
|
394
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/focus-trap.directive.ts
|
|
395
|
+
* @since 0.1.0
|
|
396
|
+
* @relatedTo CngxAutofocus, CngxFocusRestore, CngxDialog
|
|
397
|
+
* <example-url>http://localhost:4200/#/common/a11y/focus-trap/modal-dialog</example-url>
|
|
398
|
+
* <example-url>http://localhost:4200/#/common/a11y/focus-trap/slide-out-drawer</example-url>
|
|
354
399
|
*/
|
|
355
400
|
class CngxFocusTrap {
|
|
356
401
|
/** Whether the focus trap is active. When `false`, Tab navigates normally. */
|
|
@@ -404,6 +449,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
404
449
|
* @if (fv.focusVisible()) { Focus ring visible }
|
|
405
450
|
* </button>
|
|
406
451
|
* ```
|
|
452
|
+
*
|
|
453
|
+
* @category common/a11y
|
|
454
|
+
* @docsKind primary
|
|
455
|
+
* @wcag AA
|
|
456
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/focus-visible.directive.ts
|
|
457
|
+
* @since 0.1.0
|
|
458
|
+
* @relatedTo CngxAutofocus, CngxFocusRestore, CngxFocusTrap
|
|
459
|
+
* <example-url>http://localhost:4200/#/common/a11y/focus-visible/form-fields-custom-focus-ring</example-url>
|
|
460
|
+
* <example-url>http://localhost:4200/#/common/a11y/focus-visible/keyboard-vs-pointer</example-url>
|
|
407
461
|
*/
|
|
408
462
|
class CngxFocusVisible {
|
|
409
463
|
focusVisibleState = signal(false, ...(ngDevMode ? [{ debugName: "focusVisibleState" }] : /* istanbul ignore next */ []));
|
|
@@ -452,6 +506,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
452
506
|
* <button cngxRovingItem>Three</button>
|
|
453
507
|
* </div>
|
|
454
508
|
* ```
|
|
509
|
+
*
|
|
510
|
+
* @category common/a11y
|
|
511
|
+
* @docsKind primary
|
|
512
|
+
* @wcag AA
|
|
513
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/roving/roving-tabindex.directive.ts
|
|
514
|
+
* @since 0.1.0
|
|
515
|
+
* @relatedTo CngxRovingTabindex, CngxButtonToggle
|
|
516
|
+
* <example-url>http://localhost:4200/#/common/a11y/roving-tabindex/horizontal-toolbar</example-url>
|
|
517
|
+
* <example-url>http://localhost:4200/#/common/a11y/roving-tabindex/vertical-menu</example-url>
|
|
455
518
|
*/
|
|
456
519
|
class CngxRovingItem {
|
|
457
520
|
/** @internal Reference used by the parent `CngxRovingTabindex` to set `tabindex`. */
|
|
@@ -476,7 +539,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
476
539
|
/**
|
|
477
540
|
* Implements the WAI-ARIA roving tabindex pattern for composite widgets.
|
|
478
541
|
*
|
|
479
|
-
* Only the active item in the group has `tabindex="0"`
|
|
542
|
+
* Only the active item in the group has `tabindex="0"` - all others get
|
|
480
543
|
* `tabindex="-1"`. Arrow keys move focus within the group; Tab leaves it.
|
|
481
544
|
* Home/End jump to first/last item.
|
|
482
545
|
*
|
|
@@ -519,10 +582,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
519
582
|
* }
|
|
520
583
|
* </div>
|
|
521
584
|
* ```
|
|
585
|
+
*
|
|
586
|
+
* @category common/a11y
|
|
587
|
+
* @docsKind primary
|
|
588
|
+
* @wcag AA
|
|
589
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/roving/roving-tabindex.directive.ts
|
|
590
|
+
* @since 0.1.0
|
|
591
|
+
* @relatedTo CngxRovingItem, CngxActiveDescendant
|
|
592
|
+
* <example-url>http://localhost:4200/#/common/a11y/roving-tabindex/horizontal-toolbar</example-url>
|
|
593
|
+
* <example-url>http://localhost:4200/#/common/a11y/roving-tabindex/vertical-menu</example-url>
|
|
522
594
|
*/
|
|
523
595
|
class CngxRovingTabindex {
|
|
524
|
-
/**
|
|
525
|
-
|
|
596
|
+
/**
|
|
597
|
+
* Arrow key navigation axis. `'both'` enables both horizontal and
|
|
598
|
+
* vertical arrows. Exposed as a `model` so composite hosts (e.g.
|
|
599
|
+
* `CngxRadioGroup`, where the keyboard axis must always be `'both'`
|
|
600
|
+
* per WAI-ARIA APG regardless of the cosmetic group orientation) can
|
|
601
|
+
* override it from their own constructor.
|
|
602
|
+
*/
|
|
603
|
+
orientation = model('horizontal', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
526
604
|
/** Whether navigation wraps from last to first and vice versa. */
|
|
527
605
|
loop = input(true, ...(ngDevMode ? [{ debugName: "loop" }] : /* istanbul ignore next */ []));
|
|
528
606
|
/** Index of the currently active (focusable) item. Supports two-way `[(activeIndex)]` binding. */
|
|
@@ -548,7 +626,6 @@ class CngxRovingTabindex {
|
|
|
548
626
|
pendingFocus = this.pendingFocusState.asReadonly();
|
|
549
627
|
constructor() {
|
|
550
628
|
afterNextRender(() => this.initialized.set(true));
|
|
551
|
-
// Sync tabindex on every items/activeIndex change: active = "0", others = "-1".
|
|
552
629
|
effect(() => {
|
|
553
630
|
if (!this.initialized()) {
|
|
554
631
|
return;
|
|
@@ -560,7 +637,7 @@ class CngxRovingTabindex {
|
|
|
560
637
|
// Virtual mode: match by data-cngx-recycle-index attribute
|
|
561
638
|
items.forEach((item) => {
|
|
562
639
|
const el = item.elementRef.nativeElement;
|
|
563
|
-
const idx = el.
|
|
640
|
+
const idx = el.dataset['cngxRecycleIndex'];
|
|
564
641
|
el.setAttribute('tabindex', idx != null && Number(idx) === active ? '0' : '-1');
|
|
565
642
|
});
|
|
566
643
|
}
|
|
@@ -582,7 +659,7 @@ class CngxRovingTabindex {
|
|
|
582
659
|
* Handles arrow-key, Home, and End navigation within the group.
|
|
583
660
|
* Prevents default scrolling on arrow keys.
|
|
584
661
|
*
|
|
585
|
-
* Unified handler
|
|
662
|
+
* Unified handler - delegates to virtual or contentChildren navigation
|
|
586
663
|
* based on whether `virtualCount` is set.
|
|
587
664
|
*/
|
|
588
665
|
handleKeyDown(event) {
|
|
@@ -642,7 +719,7 @@ class CngxRovingTabindex {
|
|
|
642
719
|
}
|
|
643
720
|
}
|
|
644
721
|
/**
|
|
645
|
-
* Finds the next index in virtual mode. No disabled-item skipping
|
|
722
|
+
* Finds the next index in virtual mode. No disabled-item skipping - can't check
|
|
646
723
|
* disabled state of items not in the DOM.
|
|
647
724
|
*/
|
|
648
725
|
findNextVirtual(current, total, direction) {
|
|
@@ -671,7 +748,7 @@ class CngxRovingTabindex {
|
|
|
671
748
|
}
|
|
672
749
|
/**
|
|
673
750
|
* Searches for the next enabled item starting from `current + direction`.
|
|
674
|
-
* Respects `loop`
|
|
751
|
+
* Respects `loop` - wraps around or stops at the boundary.
|
|
675
752
|
* Skips disabled items.
|
|
676
753
|
*/
|
|
677
754
|
findNext(current, items, direction) {
|
|
@@ -708,7 +785,7 @@ class CngxRovingTabindex {
|
|
|
708
785
|
return null;
|
|
709
786
|
}
|
|
710
787
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxRovingTabindex, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
711
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxRovingTabindex, isStandalone: true, selector: "[cngxRovingTabindex]", inputs: { orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, loop: { classPropertyName: "loop", publicName: "loop", isSignal: true, isRequired: false, transformFunction: null }, activeIndex: { classPropertyName: "activeIndex", publicName: "activeIndex", isSignal: true, isRequired: false, transformFunction: null }, virtualCount: { classPropertyName: "virtualCount", publicName: "virtualCount", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { activeIndex: "activeIndexChange" }, host: { listeners: { "keydown": "handleKeyDown($event)" } }, queries: [{ propertyName: "items", predicate: CngxRovingItem, isSignal: true }], exportAs: ["cngxRovingTabindex"], ngImport: i0 });
|
|
788
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxRovingTabindex, isStandalone: true, selector: "[cngxRovingTabindex]", inputs: { orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, loop: { classPropertyName: "loop", publicName: "loop", isSignal: true, isRequired: false, transformFunction: null }, activeIndex: { classPropertyName: "activeIndex", publicName: "activeIndex", isSignal: true, isRequired: false, transformFunction: null }, virtualCount: { classPropertyName: "virtualCount", publicName: "virtualCount", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { orientation: "orientationChange", activeIndex: "activeIndexChange" }, host: { listeners: { "keydown": "handleKeyDown($event)" } }, queries: [{ propertyName: "items", predicate: CngxRovingItem, isSignal: true }], exportAs: ["cngxRovingTabindex"], ngImport: i0 });
|
|
712
789
|
}
|
|
713
790
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxRovingTabindex, decorators: [{
|
|
714
791
|
type: Directive,
|
|
@@ -720,7 +797,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
720
797
|
'(keydown)': 'handleKeyDown($event)',
|
|
721
798
|
},
|
|
722
799
|
}]
|
|
723
|
-
}], ctorParameters: () => [], propDecorators: { orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], loop: [{ type: i0.Input, args: [{ isSignal: true, alias: "loop", required: false }] }], activeIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "activeIndex", required: false }] }, { type: i0.Output, args: ["activeIndexChange"] }], virtualCount: [{ type: i0.Input, args: [{ isSignal: true, alias: "virtualCount", required: false }] }], items: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CngxRovingItem), { isSignal: true }] }] } });
|
|
800
|
+
}], ctorParameters: () => [], propDecorators: { orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }, { type: i0.Output, args: ["orientationChange"] }], loop: [{ type: i0.Input, args: [{ isSignal: true, alias: "loop", required: false }] }], activeIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "activeIndex", required: false }] }, { type: i0.Output, args: ["activeIndexChange"] }], virtualCount: [{ type: i0.Input, args: [{ isSignal: true, alias: "virtualCount", required: false }] }], items: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CngxRovingItem), { isSignal: true }] }] } });
|
|
724
801
|
|
|
725
802
|
/**
|
|
726
803
|
* DI token for content-projected items that should register with the
|
|
@@ -733,49 +810,59 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
733
810
|
* ```
|
|
734
811
|
*
|
|
735
812
|
* The contained directive must expose `id`, `value`, `label`, and optionally
|
|
736
|
-
* `disabled` as signals
|
|
813
|
+
* `disabled` as signals - the AD reads them reactively.
|
|
814
|
+
*
|
|
815
|
+
* @category common/a11y
|
|
816
|
+
* @wcag AA
|
|
817
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/active-descendant/ad-item.token.ts
|
|
818
|
+
* @since 0.1.0
|
|
737
819
|
*/
|
|
738
820
|
const CNGX_AD_ITEM = new InjectionToken('CNGX_AD_ITEM');
|
|
739
821
|
|
|
740
822
|
/**
|
|
741
|
-
*
|
|
742
|
-
*
|
|
743
|
-
* option is communicated via `aria-activedescendant`.
|
|
823
|
+
* WAI-ARIA active-descendant pattern. Focus stays on the host; the active
|
|
824
|
+
* option is reported via `aria-activedescendant`.
|
|
744
825
|
*
|
|
745
826
|
* ### When to use this vs. `CngxRovingTabindex`
|
|
746
827
|
*
|
|
747
|
-
* - **Active-descendant** when focus
|
|
748
|
-
*
|
|
749
|
-
*
|
|
750
|
-
*
|
|
751
|
-
*
|
|
752
|
-
* tab list, grid cells). See `CngxRovingTabindex`.
|
|
828
|
+
* - **Active-descendant** when focus stays on one container (listbox, menu,
|
|
829
|
+
* combobox input) and items must not be tab-stops. Screen readers announce
|
|
830
|
+
* the referenced option while the focus ring stays on the host.
|
|
831
|
+
* - **Roving tabindex** when items themselves are tab-stops (toolbar, tab
|
|
832
|
+
* list, grid cells). See `CngxRovingTabindex`.
|
|
753
833
|
*
|
|
754
834
|
* ### Item registration
|
|
755
835
|
*
|
|
756
|
-
* Items register either by providing `CNGX_AD_ITEM` via `hostDirectives`
|
|
836
|
+
* Items register either by providing `CNGX_AD_ITEM` via `hostDirectives` /
|
|
757
837
|
* `providers`, or by passing a `Signal<ActiveDescendantItem[]>` through the
|
|
758
|
-
* `items` input. The
|
|
759
|
-
*
|
|
838
|
+
* `items` input. The `items` input wins when both are present; use it when
|
|
839
|
+
* items come from a dynamic data source.
|
|
760
840
|
*
|
|
761
841
|
* ### Virtualization
|
|
762
842
|
*
|
|
763
|
-
* When `virtualCount` is set, navigation
|
|
764
|
-
*
|
|
765
|
-
*
|
|
766
|
-
* `clearPendingHighlight()`.
|
|
843
|
+
* When `virtualCount` is set, navigation can address indices not currently
|
|
844
|
+
* in the DOM. `pendingHighlight` tells the consumer to scroll the missing
|
|
845
|
+
* item into view; the consumer calls `clearPendingHighlight()` afterwards.
|
|
767
846
|
*
|
|
768
847
|
* ### Material/CDK equivalent
|
|
769
848
|
*
|
|
770
|
-
*
|
|
771
|
-
*
|
|
772
|
-
*
|
|
849
|
+
* Same model as `cdk-listbox` and `mat-select`, without the visual shell and
|
|
850
|
+
* driven by signals instead of `ListKeyManager`.
|
|
851
|
+
*
|
|
852
|
+
* @category common/a11y
|
|
853
|
+
* @docsKind primary
|
|
854
|
+
* @wcag AA
|
|
855
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/active-descendant/active-descendant.directive.ts
|
|
856
|
+
* @since 0.1.0
|
|
857
|
+
* @relatedTo CngxRovingTabindex, CngxListbox, CngxMenu
|
|
858
|
+
* <example-url>http://localhost:4200/#/common/a11y/active-descendant/listbox-with-items-input</example-url>
|
|
859
|
+
* <example-url>http://localhost:4200/#/common/a11y/active-descendant/typeahead</example-url>
|
|
773
860
|
*/
|
|
774
861
|
class CngxActiveDescendant {
|
|
775
862
|
/**
|
|
776
863
|
* Optional explicit item list. When provided, takes precedence over items
|
|
777
864
|
* registered via `CNGX_AD_ITEM`. Useful for combobox-style consumers that
|
|
778
|
-
* drive the menu from a dynamic data source
|
|
865
|
+
* drive the menu from a dynamic data source - pass the unwrapped array
|
|
779
866
|
* (typically the result of a `computed()`), Angular's signal inputs make it
|
|
780
867
|
* reactive automatically.
|
|
781
868
|
*/
|
|
@@ -1148,6 +1235,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1148
1235
|
},
|
|
1149
1236
|
}]
|
|
1150
1237
|
}], ctorParameters: () => [], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], loop: [{ type: i0.Input, args: [{ isSignal: true, alias: "loop", required: false }] }], typeahead: [{ type: i0.Input, args: [{ isSignal: true, alias: "typeahead", required: false }] }], typeaheadDebounce: [{ type: i0.Input, args: [{ isSignal: true, alias: "typeaheadDebounce", required: false }] }], autoHighlightFirst: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoHighlightFirst", required: false }] }], skipDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "skipDisabled", required: false }] }], virtualCount: [{ type: i0.Input, args: [{ isSignal: true, alias: "virtualCount", required: false }] }], activated: [{ type: i0.Output, args: ["activated"] }], highlighted: [{ type: i0.Output, args: ["highlighted"] }], registered: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CNGX_AD_ITEM), { ...{ descendants: true }, isSignal: true }] }] } });
|
|
1238
|
+
/** @internal */
|
|
1151
1239
|
function handleToItem(handle) {
|
|
1152
1240
|
return {
|
|
1153
1241
|
id: handle.id,
|
|
@@ -1156,14 +1244,17 @@ function handleToItem(handle) {
|
|
|
1156
1244
|
disabled: handle.disabled?.() ?? false,
|
|
1157
1245
|
};
|
|
1158
1246
|
}
|
|
1247
|
+
/** @internal */
|
|
1159
1248
|
function isPrintableChar(key) {
|
|
1160
1249
|
return key.length === 1 && /\S/.exec(key) !== null;
|
|
1161
1250
|
}
|
|
1162
1251
|
/**
|
|
1163
|
-
* True when the element would capture text input natively
|
|
1252
|
+
* True when the element would capture text input natively - a text
|
|
1164
1253
|
* `<input>`, `<textarea>`, or any `contenteditable` host. Read-only /
|
|
1165
1254
|
* button-type inputs (submit, radio, checkbox) are NOT editable; AD's
|
|
1166
1255
|
* keyboard navigation still applies when focus lands on them.
|
|
1256
|
+
*
|
|
1257
|
+
* @internal
|
|
1167
1258
|
*/
|
|
1168
1259
|
function isEditableTarget(el) {
|
|
1169
1260
|
if (el.isContentEditable) {
|
|
@@ -1187,6 +1278,7 @@ function isEditableTarget(el) {
|
|
|
1187
1278
|
}
|
|
1188
1279
|
return false;
|
|
1189
1280
|
}
|
|
1281
|
+
/** @internal */
|
|
1190
1282
|
function cssEscape(id) {
|
|
1191
1283
|
const api = globalThis.CSS;
|
|
1192
1284
|
if (api && typeof api.escape === 'function') {
|
|
@@ -1200,7 +1292,7 @@ function cssEscape(id) {
|
|
|
1200
1292
|
*
|
|
1201
1293
|
* Adds the `cngx-reduced-motion` CSS class to the host when the user prefers
|
|
1202
1294
|
* reduced motion. The `prefersReducedMotion()` signal updates live when the
|
|
1203
|
-
* OS preference changes
|
|
1295
|
+
* OS preference changes - use it in TypeScript to skip animations, disable
|
|
1204
1296
|
* auto-playing media, or choose between animated and instant transitions.
|
|
1205
1297
|
*
|
|
1206
1298
|
* Unlike a CSS-only `@media (prefers-reduced-motion: reduce)` approach, this
|
|
@@ -1219,6 +1311,14 @@ function cssEscape(id) {
|
|
|
1219
1311
|
* readonly rm = viewChild(CngxReducedMotion);
|
|
1220
1312
|
* readonly duration = computed(() => this.rm()?.prefersReducedMotion() ? 0 : 300);
|
|
1221
1313
|
* ```
|
|
1314
|
+
*
|
|
1315
|
+
* @category common/a11y
|
|
1316
|
+
* @docsKind primary
|
|
1317
|
+
* @wcag AA
|
|
1318
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/motion/reduced-motion.directive.ts
|
|
1319
|
+
* @since 0.1.0
|
|
1320
|
+
* <example-url>http://localhost:4200/#/common/a11y/reduced-motion/animation-toggle</example-url>
|
|
1321
|
+
* <example-url>http://localhost:4200/#/common/a11y/reduced-motion/toast-notifications-motion-aware</example-url>
|
|
1222
1322
|
*/
|
|
1223
1323
|
class CngxReducedMotion {
|
|
1224
1324
|
/** `true` when the user's OS is set to prefer reduced motion. Updates reactively. */
|