@cngx/common 0.0.1-rc.0 → 0.1.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +164 -51
- 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 +2059 -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 +1479 -73
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +1144 -85
- 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 +7 -6
- package/popover/README.md +8 -34
- package/stepper/README.md +69 -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 +159 -38
- 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 +1880 -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 +1360 -45
- package/types/cngx-common-tabs.d.ts +1139 -56
- 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' });
|
|
@@ -202,6 +229,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
202
229
|
}]
|
|
203
230
|
}], ctorParameters: () => [], propDecorators: { when: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxAutofocus", required: false }] }], delay: [{ type: i0.Input, args: [{ isSignal: true, alias: "autofocusDelay", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "autofocusOptions", required: false }] }] } });
|
|
204
231
|
|
|
232
|
+
/**
|
|
233
|
+
* CSS selector matching natively-focusable elements: links with an
|
|
234
|
+
* `href`, the enabled form controls, and anything with an explicit
|
|
235
|
+
* non-negative `tabindex`. Form controls carry `:not(:disabled)` because
|
|
236
|
+
* a disabled control is not in the tab order - without it a descendant
|
|
237
|
+
* probe would count a disabled button as focusable and a restore target
|
|
238
|
+
* could land on an unfocusable element. Single source of truth for "is
|
|
239
|
+
* this focusable" - the element-level {@link CngxFocusRestore} predicate
|
|
240
|
+
* matches against it, and descendant probes (e.g. "does this panel
|
|
241
|
+
* contain a focusable child?") query against it. Keeping one selector
|
|
242
|
+
* stops the two uses from drifting apart.
|
|
243
|
+
*
|
|
244
|
+
* @category common/a11y
|
|
245
|
+
* @since 0.1.0
|
|
246
|
+
*/
|
|
247
|
+
const CNGX_FOCUSABLE_SELECTOR = 'a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';
|
|
205
248
|
/**
|
|
206
249
|
* Stores the previously focused element and restores focus on destroy.
|
|
207
250
|
*
|
|
@@ -229,6 +272,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
229
272
|
* </div>
|
|
230
273
|
* <button #fallbackBtn>Fallback target</button>
|
|
231
274
|
* ```
|
|
275
|
+
*
|
|
276
|
+
* @category common/a11y
|
|
277
|
+
* @docsKind primary
|
|
278
|
+
* @wcag AA
|
|
279
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/focus-restore.directive.ts
|
|
280
|
+
* @since 0.1.0
|
|
281
|
+
* @relatedTo CngxAutofocus, CngxFocusTrap, CngxFocusVisible
|
|
282
|
+
* <example-url>http://localhost:4200/#/common/a11y/focus-restore/inline-details</example-url>
|
|
283
|
+
* <example-url>http://localhost:4200/#/common/a11y/focus-restore/panel-with-automatic-restore</example-url>
|
|
232
284
|
*/
|
|
233
285
|
class CngxFocusRestore {
|
|
234
286
|
/** Whether to restore focus when the host element is destroyed. */
|
|
@@ -275,7 +327,7 @@ class CngxFocusRestore {
|
|
|
275
327
|
*/
|
|
276
328
|
resolveTarget() {
|
|
277
329
|
const stored = this.storedElement();
|
|
278
|
-
// Skip body
|
|
330
|
+
// Skip body - it signals "nothing meaningful was focused", not a real restore target.
|
|
279
331
|
if (stored &&
|
|
280
332
|
stored !== this.doc.body &&
|
|
281
333
|
this.doc.contains(stored) &&
|
|
@@ -299,17 +351,14 @@ class CngxFocusRestore {
|
|
|
299
351
|
}
|
|
300
352
|
return null;
|
|
301
353
|
}
|
|
302
|
-
/**
|
|
354
|
+
/**
|
|
355
|
+
* Checks if an element is natively focusable (tabindex, links, form
|
|
356
|
+
* controls). Element-level predicate over the shared
|
|
357
|
+
* {@link CNGX_FOCUSABLE_SELECTOR}, so it never drifts from the
|
|
358
|
+
* descendant-query callers.
|
|
359
|
+
*/
|
|
303
360
|
isFocusable(el) {
|
|
304
|
-
|
|
305
|
-
return true;
|
|
306
|
-
}
|
|
307
|
-
const tag = el.tagName.toLowerCase();
|
|
308
|
-
return ((tag === 'a' && el.hasAttribute('href')) ||
|
|
309
|
-
tag === 'button' ||
|
|
310
|
-
tag === 'input' ||
|
|
311
|
-
tag === 'select' ||
|
|
312
|
-
tag === 'textarea');
|
|
361
|
+
return el.matches(CNGX_FOCUSABLE_SELECTOR);
|
|
313
362
|
}
|
|
314
363
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxFocusRestore, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
315
364
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxFocusRestore, isStandalone: true, selector: "[cngxFocusRestore]", inputs: { restoreOnDestroy: { classPropertyName: "restoreOnDestroy", publicName: "restoreOnDestroy", isSignal: true, isRequired: false, transformFunction: null }, fallback: { classPropertyName: "fallback", publicName: "fallback", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["cngxFocusRestore"], ngImport: i0 });
|
|
@@ -351,6 +400,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
351
400
|
* <a href="/settings">Settings</a>
|
|
352
401
|
* </nav>
|
|
353
402
|
* ```
|
|
403
|
+
*
|
|
404
|
+
* @category common/a11y
|
|
405
|
+
* @docsKind primary
|
|
406
|
+
* @wcag AA
|
|
407
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/focus-trap.directive.ts
|
|
408
|
+
* @since 0.1.0
|
|
409
|
+
* @relatedTo CngxAutofocus, CngxFocusRestore, CngxDialog
|
|
410
|
+
* <example-url>http://localhost:4200/#/common/a11y/focus-trap/modal-dialog</example-url>
|
|
411
|
+
* <example-url>http://localhost:4200/#/common/a11y/focus-trap/slide-out-drawer</example-url>
|
|
354
412
|
*/
|
|
355
413
|
class CngxFocusTrap {
|
|
356
414
|
/** Whether the focus trap is active. When `false`, Tab navigates normally. */
|
|
@@ -404,6 +462,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
404
462
|
* @if (fv.focusVisible()) { Focus ring visible }
|
|
405
463
|
* </button>
|
|
406
464
|
* ```
|
|
465
|
+
*
|
|
466
|
+
* @category common/a11y
|
|
467
|
+
* @docsKind primary
|
|
468
|
+
* @wcag AA
|
|
469
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/focus-visible.directive.ts
|
|
470
|
+
* @since 0.1.0
|
|
471
|
+
* @relatedTo CngxAutofocus, CngxFocusRestore, CngxFocusTrap
|
|
472
|
+
* <example-url>http://localhost:4200/#/common/a11y/focus-visible/form-fields-custom-focus-ring</example-url>
|
|
473
|
+
* <example-url>http://localhost:4200/#/common/a11y/focus-visible/keyboard-vs-pointer</example-url>
|
|
407
474
|
*/
|
|
408
475
|
class CngxFocusVisible {
|
|
409
476
|
focusVisibleState = signal(false, ...(ngDevMode ? [{ debugName: "focusVisibleState" }] : /* istanbul ignore next */ []));
|
|
@@ -452,6 +519,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
452
519
|
* <button cngxRovingItem>Three</button>
|
|
453
520
|
* </div>
|
|
454
521
|
* ```
|
|
522
|
+
*
|
|
523
|
+
* @category common/a11y
|
|
524
|
+
* @docsKind primary
|
|
525
|
+
* @wcag AA
|
|
526
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/roving/roving-tabindex.directive.ts
|
|
527
|
+
* @since 0.1.0
|
|
528
|
+
* @relatedTo CngxRovingTabindex, CngxButtonToggle
|
|
529
|
+
* <example-url>http://localhost:4200/#/common/a11y/roving-tabindex/horizontal-toolbar</example-url>
|
|
530
|
+
* <example-url>http://localhost:4200/#/common/a11y/roving-tabindex/vertical-menu</example-url>
|
|
455
531
|
*/
|
|
456
532
|
class CngxRovingItem {
|
|
457
533
|
/** @internal Reference used by the parent `CngxRovingTabindex` to set `tabindex`. */
|
|
@@ -476,7 +552,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
476
552
|
/**
|
|
477
553
|
* Implements the WAI-ARIA roving tabindex pattern for composite widgets.
|
|
478
554
|
*
|
|
479
|
-
* Only the active item in the group has `tabindex="0"`
|
|
555
|
+
* Only the active item in the group has `tabindex="0"` - all others get
|
|
480
556
|
* `tabindex="-1"`. Arrow keys move focus within the group; Tab leaves it.
|
|
481
557
|
* Home/End jump to first/last item.
|
|
482
558
|
*
|
|
@@ -519,10 +595,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
519
595
|
* }
|
|
520
596
|
* </div>
|
|
521
597
|
* ```
|
|
598
|
+
*
|
|
599
|
+
* @category common/a11y
|
|
600
|
+
* @docsKind primary
|
|
601
|
+
* @wcag AA
|
|
602
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/roving/roving-tabindex.directive.ts
|
|
603
|
+
* @since 0.1.0
|
|
604
|
+
* @relatedTo CngxRovingItem, CngxActiveDescendant
|
|
605
|
+
* <example-url>http://localhost:4200/#/common/a11y/roving-tabindex/horizontal-toolbar</example-url>
|
|
606
|
+
* <example-url>http://localhost:4200/#/common/a11y/roving-tabindex/vertical-menu</example-url>
|
|
522
607
|
*/
|
|
523
608
|
class CngxRovingTabindex {
|
|
524
|
-
/**
|
|
525
|
-
|
|
609
|
+
/**
|
|
610
|
+
* Arrow key navigation axis. `'both'` enables both horizontal and
|
|
611
|
+
* vertical arrows. Exposed as a `model` so composite hosts (e.g.
|
|
612
|
+
* `CngxRadioGroup`, where the keyboard axis must always be `'both'`
|
|
613
|
+
* per WAI-ARIA APG regardless of the cosmetic group orientation) can
|
|
614
|
+
* override it from their own constructor.
|
|
615
|
+
*/
|
|
616
|
+
orientation = model('horizontal', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
526
617
|
/** Whether navigation wraps from last to first and vice versa. */
|
|
527
618
|
loop = input(true, ...(ngDevMode ? [{ debugName: "loop" }] : /* istanbul ignore next */ []));
|
|
528
619
|
/** Index of the currently active (focusable) item. Supports two-way `[(activeIndex)]` binding. */
|
|
@@ -548,7 +639,6 @@ class CngxRovingTabindex {
|
|
|
548
639
|
pendingFocus = this.pendingFocusState.asReadonly();
|
|
549
640
|
constructor() {
|
|
550
641
|
afterNextRender(() => this.initialized.set(true));
|
|
551
|
-
// Sync tabindex on every items/activeIndex change: active = "0", others = "-1".
|
|
552
642
|
effect(() => {
|
|
553
643
|
if (!this.initialized()) {
|
|
554
644
|
return;
|
|
@@ -560,7 +650,7 @@ class CngxRovingTabindex {
|
|
|
560
650
|
// Virtual mode: match by data-cngx-recycle-index attribute
|
|
561
651
|
items.forEach((item) => {
|
|
562
652
|
const el = item.elementRef.nativeElement;
|
|
563
|
-
const idx = el.
|
|
653
|
+
const idx = el.dataset['cngxRecycleIndex'];
|
|
564
654
|
el.setAttribute('tabindex', idx != null && Number(idx) === active ? '0' : '-1');
|
|
565
655
|
});
|
|
566
656
|
}
|
|
@@ -582,7 +672,7 @@ class CngxRovingTabindex {
|
|
|
582
672
|
* Handles arrow-key, Home, and End navigation within the group.
|
|
583
673
|
* Prevents default scrolling on arrow keys.
|
|
584
674
|
*
|
|
585
|
-
* Unified handler
|
|
675
|
+
* Unified handler - delegates to virtual or contentChildren navigation
|
|
586
676
|
* based on whether `virtualCount` is set.
|
|
587
677
|
*/
|
|
588
678
|
handleKeyDown(event) {
|
|
@@ -642,7 +732,7 @@ class CngxRovingTabindex {
|
|
|
642
732
|
}
|
|
643
733
|
}
|
|
644
734
|
/**
|
|
645
|
-
* Finds the next index in virtual mode. No disabled-item skipping
|
|
735
|
+
* Finds the next index in virtual mode. No disabled-item skipping - can't check
|
|
646
736
|
* disabled state of items not in the DOM.
|
|
647
737
|
*/
|
|
648
738
|
findNextVirtual(current, total, direction) {
|
|
@@ -671,7 +761,7 @@ class CngxRovingTabindex {
|
|
|
671
761
|
}
|
|
672
762
|
/**
|
|
673
763
|
* Searches for the next enabled item starting from `current + direction`.
|
|
674
|
-
* Respects `loop`
|
|
764
|
+
* Respects `loop` - wraps around or stops at the boundary.
|
|
675
765
|
* Skips disabled items.
|
|
676
766
|
*/
|
|
677
767
|
findNext(current, items, direction) {
|
|
@@ -708,7 +798,7 @@ class CngxRovingTabindex {
|
|
|
708
798
|
return null;
|
|
709
799
|
}
|
|
710
800
|
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 });
|
|
801
|
+
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
802
|
}
|
|
713
803
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxRovingTabindex, decorators: [{
|
|
714
804
|
type: Directive,
|
|
@@ -720,7 +810,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
720
810
|
'(keydown)': 'handleKeyDown($event)',
|
|
721
811
|
},
|
|
722
812
|
}]
|
|
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 }] }] } });
|
|
813
|
+
}], 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
814
|
|
|
725
815
|
/**
|
|
726
816
|
* DI token for content-projected items that should register with the
|
|
@@ -733,49 +823,59 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
733
823
|
* ```
|
|
734
824
|
*
|
|
735
825
|
* The contained directive must expose `id`, `value`, `label`, and optionally
|
|
736
|
-
* `disabled` as signals
|
|
826
|
+
* `disabled` as signals - the AD reads them reactively.
|
|
827
|
+
*
|
|
828
|
+
* @category common/a11y
|
|
829
|
+
* @wcag AA
|
|
830
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/active-descendant/ad-item.token.ts
|
|
831
|
+
* @since 0.1.0
|
|
737
832
|
*/
|
|
738
833
|
const CNGX_AD_ITEM = new InjectionToken('CNGX_AD_ITEM');
|
|
739
834
|
|
|
740
835
|
/**
|
|
741
|
-
*
|
|
742
|
-
*
|
|
743
|
-
* option is communicated via `aria-activedescendant`.
|
|
836
|
+
* WAI-ARIA active-descendant pattern. Focus stays on the host; the active
|
|
837
|
+
* option is reported via `aria-activedescendant`.
|
|
744
838
|
*
|
|
745
839
|
* ### When to use this vs. `CngxRovingTabindex`
|
|
746
840
|
*
|
|
747
|
-
* - **Active-descendant** when focus
|
|
748
|
-
*
|
|
749
|
-
*
|
|
750
|
-
*
|
|
751
|
-
*
|
|
752
|
-
* tab list, grid cells). See `CngxRovingTabindex`.
|
|
841
|
+
* - **Active-descendant** when focus stays on one container (listbox, menu,
|
|
842
|
+
* combobox input) and items must not be tab-stops. Screen readers announce
|
|
843
|
+
* the referenced option while the focus ring stays on the host.
|
|
844
|
+
* - **Roving tabindex** when items themselves are tab-stops (toolbar, tab
|
|
845
|
+
* list, grid cells). See `CngxRovingTabindex`.
|
|
753
846
|
*
|
|
754
847
|
* ### Item registration
|
|
755
848
|
*
|
|
756
|
-
* Items register either by providing `CNGX_AD_ITEM` via `hostDirectives`
|
|
849
|
+
* Items register either by providing `CNGX_AD_ITEM` via `hostDirectives` /
|
|
757
850
|
* `providers`, or by passing a `Signal<ActiveDescendantItem[]>` through the
|
|
758
|
-
* `items` input. The
|
|
759
|
-
*
|
|
851
|
+
* `items` input. The `items` input wins when both are present; use it when
|
|
852
|
+
* items come from a dynamic data source.
|
|
760
853
|
*
|
|
761
854
|
* ### Virtualization
|
|
762
855
|
*
|
|
763
|
-
* When `virtualCount` is set, navigation
|
|
764
|
-
*
|
|
765
|
-
*
|
|
766
|
-
* `clearPendingHighlight()`.
|
|
856
|
+
* When `virtualCount` is set, navigation can address indices not currently
|
|
857
|
+
* in the DOM. `pendingHighlight` tells the consumer to scroll the missing
|
|
858
|
+
* item into view; the consumer calls `clearPendingHighlight()` afterwards.
|
|
767
859
|
*
|
|
768
860
|
* ### Material/CDK equivalent
|
|
769
861
|
*
|
|
770
|
-
*
|
|
771
|
-
*
|
|
772
|
-
*
|
|
862
|
+
* Same model as `cdk-listbox` and `mat-select`, without the visual shell and
|
|
863
|
+
* driven by signals instead of `ListKeyManager`.
|
|
864
|
+
*
|
|
865
|
+
* @category common/a11y
|
|
866
|
+
* @docsKind primary
|
|
867
|
+
* @wcag AA
|
|
868
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/active-descendant/active-descendant.directive.ts
|
|
869
|
+
* @since 0.1.0
|
|
870
|
+
* @relatedTo CngxRovingTabindex, CngxListbox, CngxMenu
|
|
871
|
+
* <example-url>http://localhost:4200/#/common/a11y/active-descendant/listbox-with-items-input</example-url>
|
|
872
|
+
* <example-url>http://localhost:4200/#/common/a11y/active-descendant/typeahead</example-url>
|
|
773
873
|
*/
|
|
774
874
|
class CngxActiveDescendant {
|
|
775
875
|
/**
|
|
776
876
|
* Optional explicit item list. When provided, takes precedence over items
|
|
777
877
|
* registered via `CNGX_AD_ITEM`. Useful for combobox-style consumers that
|
|
778
|
-
* drive the menu from a dynamic data source
|
|
878
|
+
* drive the menu from a dynamic data source - pass the unwrapped array
|
|
779
879
|
* (typically the result of a `computed()`), Angular's signal inputs make it
|
|
780
880
|
* reactive automatically.
|
|
781
881
|
*/
|
|
@@ -1148,6 +1248,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1148
1248
|
},
|
|
1149
1249
|
}]
|
|
1150
1250
|
}], 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 }] }] } });
|
|
1251
|
+
/** @internal */
|
|
1151
1252
|
function handleToItem(handle) {
|
|
1152
1253
|
return {
|
|
1153
1254
|
id: handle.id,
|
|
@@ -1156,14 +1257,17 @@ function handleToItem(handle) {
|
|
|
1156
1257
|
disabled: handle.disabled?.() ?? false,
|
|
1157
1258
|
};
|
|
1158
1259
|
}
|
|
1260
|
+
/** @internal */
|
|
1159
1261
|
function isPrintableChar(key) {
|
|
1160
1262
|
return key.length === 1 && /\S/.exec(key) !== null;
|
|
1161
1263
|
}
|
|
1162
1264
|
/**
|
|
1163
|
-
* True when the element would capture text input natively
|
|
1265
|
+
* True when the element would capture text input natively - a text
|
|
1164
1266
|
* `<input>`, `<textarea>`, or any `contenteditable` host. Read-only /
|
|
1165
1267
|
* button-type inputs (submit, radio, checkbox) are NOT editable; AD's
|
|
1166
1268
|
* keyboard navigation still applies when focus lands on them.
|
|
1269
|
+
*
|
|
1270
|
+
* @internal
|
|
1167
1271
|
*/
|
|
1168
1272
|
function isEditableTarget(el) {
|
|
1169
1273
|
if (el.isContentEditable) {
|
|
@@ -1187,6 +1291,7 @@ function isEditableTarget(el) {
|
|
|
1187
1291
|
}
|
|
1188
1292
|
return false;
|
|
1189
1293
|
}
|
|
1294
|
+
/** @internal */
|
|
1190
1295
|
function cssEscape(id) {
|
|
1191
1296
|
const api = globalThis.CSS;
|
|
1192
1297
|
if (api && typeof api.escape === 'function') {
|
|
@@ -1200,7 +1305,7 @@ function cssEscape(id) {
|
|
|
1200
1305
|
*
|
|
1201
1306
|
* Adds the `cngx-reduced-motion` CSS class to the host when the user prefers
|
|
1202
1307
|
* reduced motion. The `prefersReducedMotion()` signal updates live when the
|
|
1203
|
-
* OS preference changes
|
|
1308
|
+
* OS preference changes - use it in TypeScript to skip animations, disable
|
|
1204
1309
|
* auto-playing media, or choose between animated and instant transitions.
|
|
1205
1310
|
*
|
|
1206
1311
|
* Unlike a CSS-only `@media (prefers-reduced-motion: reduce)` approach, this
|
|
@@ -1219,6 +1324,14 @@ function cssEscape(id) {
|
|
|
1219
1324
|
* readonly rm = viewChild(CngxReducedMotion);
|
|
1220
1325
|
* readonly duration = computed(() => this.rm()?.prefersReducedMotion() ? 0 : 300);
|
|
1221
1326
|
* ```
|
|
1327
|
+
*
|
|
1328
|
+
* @category common/a11y
|
|
1329
|
+
* @docsKind primary
|
|
1330
|
+
* @wcag AA
|
|
1331
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/motion/reduced-motion.directive.ts
|
|
1332
|
+
* @since 0.1.0
|
|
1333
|
+
* <example-url>http://localhost:4200/#/common/a11y/reduced-motion/animation-toggle</example-url>
|
|
1334
|
+
* <example-url>http://localhost:4200/#/common/a11y/reduced-motion/toast-notifications-motion-aware</example-url>
|
|
1222
1335
|
*/
|
|
1223
1336
|
class CngxReducedMotion {
|
|
1224
1337
|
/** `true` when the user's OS is set to prefer reduced motion. Updates reactively. */
|
|
@@ -1256,5 +1369,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1256
1369
|
* Generated bundle index. Do not edit.
|
|
1257
1370
|
*/
|
|
1258
1371
|
|
|
1259
|
-
export { CNGX_AD_ITEM, CngxActiveDescendant, CngxAriaExpanded, CngxAutofocus, CngxFocusRestore, CngxFocusTrap, CngxFocusVisible, CngxLiveRegion, CngxReducedMotion, CngxRovingItem, CngxRovingTabindex };
|
|
1372
|
+
export { CNGX_AD_ITEM, CNGX_FOCUSABLE_SELECTOR, CngxActiveDescendant, CngxAriaExpanded, CngxAutofocus, CngxFocusRestore, CngxFocusTrap, CngxFocusVisible, CngxLiveRegion, CngxReducedMotion, CngxRovingItem, CngxRovingTabindex };
|
|
1260
1373
|
//# sourceMappingURL=cngx-common-a11y.mjs.map
|