@cngx/common 0.1.0-rc.7 → 0.1.0-rc.8
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/card/README.md +2 -1
- package/data/README.md +10 -1
- package/dialog/README.md +23 -1
- package/fesm2022/cngx-common-a11y.mjs +125 -111
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-audio.mjs +47 -5
- package/fesm2022/cngx-common-audio.mjs.map +1 -1
- package/fesm2022/cngx-common-card.mjs +300 -46
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +1176 -453
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-command.mjs +37 -10
- package/fesm2022/cngx-common-command.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +1318 -469
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +151 -14
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +340 -73
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +1744 -952
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +841 -114
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-popover.mjs +350 -60
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +727 -317
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +1601 -1243
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common-timeline.mjs +137 -53
- package/fesm2022/cngx-common-timeline.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +1 -1
- package/interactive/README.md +15 -4
- package/layout/README.md +21 -1
- package/package.json +3 -3
- package/popover/README.md +18 -2
- package/stepper/README.md +6 -4
- package/theming/components/cngx-accordion.css +1 -1
- package/theming/components/cngx-backdrop.css +12 -0
- package/theming/components/cngx-button-toggle.css +29 -3
- package/theming/components/cngx-data-grid.css +168 -1
- package/theming/components/cngx-dialog.css +13 -0
- package/theming/components/cngx-listbox.css +21 -12
- package/theming/components/cngx-menu.css +56 -16
- package/theming/components/cngx-popover.css +24 -0
- package/theming/components/cngx-recycler-placeholder.css +196 -0
- package/theming/components/cngx-ripple.css +1 -1
- package/theming/components/cngx-slider.css +32 -1
- package/theming/components/cngx-tooltip.css +12 -0
- package/timeline/README.md +155 -0
- package/types/cngx-common-a11y.d.ts +42 -18
- package/types/cngx-common-card.d.ts +201 -17
- package/types/cngx-common-chart.d.ts +343 -47
- package/types/cngx-common-command.d.ts +31 -8
- package/types/cngx-common-data.d.ts +581 -68
- package/types/cngx-common-dialog.d.ts +158 -3
- package/types/cngx-common-display.d.ts +356 -142
- package/types/cngx-common-interactive.d.ts +859 -210
- package/types/cngx-common-layout.d.ts +567 -28
- package/types/cngx-common-popover.d.ts +262 -39
- package/types/cngx-common-stepper.d.ts +366 -116
- package/types/cngx-common-tabs.d.ts +214 -50
- package/types/cngx-common-timeline.d.ts +82 -16
package/card/README.md
CHANGED
|
@@ -45,11 +45,12 @@ export class ExampleComponent {
|
|
|
45
45
|
## Accessibility
|
|
46
46
|
|
|
47
47
|
- **ARIA roles:** `role="article"` (default), `role="button"`, or `role="link"` based on `as` input
|
|
48
|
+
- **Link navigation:** `as="link"` + `[href]` navigates on activation - internal URLs through the app `Router` when provided, otherwise `window.location.assign`. The host is not a native anchor, so modifier-click/new-tab affordances do not apply
|
|
48
49
|
- **Keyboard interaction:**
|
|
49
50
|
- `Enter` / `Space`: Activate interactive cards (button/link)
|
|
50
51
|
- `Arrow Left/Right`: Navigate cards in grid (CngxRovingTabindex)
|
|
51
52
|
- `Home` / `End`: Jump to first/last card in grid
|
|
52
|
-
- **Screen reader:** `aria-busy` when loading; live region announces "Loading", "Selected", "Deselected" state changes; `aria-describedby` points to disabled reason explanation
|
|
53
|
+
- **Screen reader:** `aria-busy` when loading; live region announces "Loading", "Selected", "Deselected" state changes (English defaults, translated by the `card` section of the language pack, `provideCngxI18n` from `@cngx/core/i18n`, and overridable per key via `provideCardI18n(withCardI18nLabels({ ... }))`); `aria-describedby` points to disabled reason explanation
|
|
53
54
|
- **Focus management:** Interactive cards get `tabindex="0"` when standalone; CngxCardGrid's roving tabindex manages focus among cards
|
|
54
55
|
|
|
55
56
|
## Composition
|
package/data/README.md
CHANGED
|
@@ -593,6 +593,13 @@ export class ResidentApi {
|
|
|
593
593
|
### Component
|
|
594
594
|
|
|
595
595
|
```typescript
|
|
596
|
+
import { CngxAsyncContainer, CngxAsyncSkeletonTpl, CngxAsyncContentTpl,
|
|
597
|
+
CngxAsyncEmptyTpl, CngxAsyncErrorTpl, CngxAlert, CngxToast } from '@cngx/ui/feedback';
|
|
598
|
+
import { CngxCardGrid, CngxCard, CngxCardHeader, CngxCardBody,
|
|
599
|
+
CngxCardFooter, CngxCardSkeleton } from '@cngx/common/card';
|
|
600
|
+
import { CngxActionButton } from '@cngx/ui/action-button';
|
|
601
|
+
import { CngxEmptyState } from '@cngx/ui/empty-state';
|
|
602
|
+
|
|
596
603
|
@Component({
|
|
597
604
|
selector: 'app-resident-list',
|
|
598
605
|
template: `
|
|
@@ -834,7 +841,9 @@ The paginator accepts `[state]` and blocks navigation while busy:
|
|
|
834
841
|
|
|
835
842
|
## CngxFileDrop - Upload State
|
|
836
843
|
|
|
837
|
-
The file drop accepts `[state]` for upload lifecycle feedback
|
|
844
|
+
The file drop accepts `[state]` for upload lifecycle feedback
|
|
845
|
+
(`CngxFileDrop` ships in `@cngx/forms/input`; `cngx-progress` and
|
|
846
|
+
`cngx-alert` in `@cngx/ui/feedback`):
|
|
838
847
|
|
|
839
848
|
```html
|
|
840
849
|
<div cngxFileDrop #drop="cngxFileDrop"
|
package/dialog/README.md
CHANGED
|
@@ -68,11 +68,33 @@ The dialog system is built around the native `<dialog>` element, which is the on
|
|
|
68
68
|
|
|
69
69
|
- **`aria-labelledby` and `aria-describedby` are wired automatically** from `[cngxDialogTitle]` and `[cngxDialogDescription]` content children. Place them in the template; the linkage is reactive.
|
|
70
70
|
- **Title announcement.** When a modal dialog transitions to `'open'`, the title text is announced through a polite live region. Screen-reader users hear the dialog purpose without an explicit `aria-live` element.
|
|
71
|
-
- **Icon-only close buttons**
|
|
71
|
+
- **Icon-only close buttons** fall back to a library-supplied name. `CngxDialogClose` sets `aria-label` only when the trigger carries no text of its own and no `aria-label` from the consumer - an explicit label always wins.
|
|
72
72
|
- **Multi-step content** - wizards, tabbed dialogs, paginated forms - is the consumer's responsibility. The dialog moves focus once on open. After that, calling `.focus()` on the first element of the new step is on you.
|
|
73
73
|
- **Error state.** Bind `[error]` to apply `aria-invalid="true"` and the `cngx-dialog--error` class. Pair with a `cngx-form-errors` block (or any `role="alert"` region) inside the dialog for WCAG-compliant form-error announcements.
|
|
74
74
|
- **Reduced motion.** The theme honors `prefers-reduced-motion: reduce` - open and close transitions disable themselves automatically.
|
|
75
75
|
|
|
76
|
+
### Localising the built-in strings
|
|
77
|
+
|
|
78
|
+
To translate the whole app, set a language pack with `provideCngxI18n(withPack(...))` from `@cngx/core/i18n` (see the localisation guide); `provideDialogConfig` overrides single keys on top of the `dialog` section.
|
|
79
|
+
|
|
80
|
+
Five strings the dialog family renders on its own behalf are English by
|
|
81
|
+
default and overridable as one bundle:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
provideDialogConfig(
|
|
85
|
+
withDialogLabels({
|
|
86
|
+
close: 'Dialog schließen',
|
|
87
|
+
errorFallback: 'Ein Fehler ist aufgetreten',
|
|
88
|
+
dragHandle: 'Dialog verschieben',
|
|
89
|
+
dragHandleRoleDescription: 'verschiebbar',
|
|
90
|
+
dragInstructions: 'Pfeiltasten bewegen den Dialog, Shift für größere Schritte',
|
|
91
|
+
}),
|
|
92
|
+
)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Unset keys keep their English default. `provideDialogConfigAt(...)` in a
|
|
96
|
+
component's `viewProviders` scopes the override to that subtree.
|
|
97
|
+
|
|
76
98
|
## See also
|
|
77
99
|
|
|
78
100
|
- Directive selectors, signals, methods, inputs, and CSS custom properties in the **API** tab of the generated docs.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, Directive, inject, PLATFORM_ID, Injectable, ElementRef, Injector, DestroyRef, afterNextRender, effect, signal, computed, model, contentChildren,
|
|
2
|
+
import { input, Directive, inject, PLATFORM_ID, Injectable, ElementRef, Injector, DestroyRef, afterNextRender, effect, signal, computed, untracked, model, contentChildren, InjectionToken, output } from '@angular/core';
|
|
3
3
|
import { DOCUMENT, isPlatformBrowser } from '@angular/common';
|
|
4
4
|
import { FocusTrapFactory } from '@angular/cdk/a11y';
|
|
5
|
-
import { injectDirection, resolveInlineStep } from '@cngx/core';
|
|
6
|
-
import { createMediaQuerySignal } from '@cngx/core/utils';
|
|
5
|
+
import { injectDirection, resolveInlineStep, resolveStepFrom, resolveBoundaryStep } from '@cngx/core';
|
|
6
|
+
import { injectLocale, createTypeaheadMatcher, createMediaQuerySignal } from '@cngx/core/utils';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Manages `aria-expanded` and optionally `aria-controls` on the host element.
|
|
@@ -37,7 +37,6 @@ import { createMediaQuerySignal } from '@cngx/core/utils';
|
|
|
37
37
|
* ```
|
|
38
38
|
*
|
|
39
39
|
* @category common/a11y
|
|
40
|
-
* @docsKind primary
|
|
41
40
|
* @wcag AA
|
|
42
41
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/aria/aria-expanded.directive.ts
|
|
43
42
|
* @since 0.1.0
|
|
@@ -96,7 +95,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
96
95
|
* ```
|
|
97
96
|
*
|
|
98
97
|
* @category common/a11y
|
|
99
|
-
* @docsKind primary
|
|
100
98
|
* @wcag AA
|
|
101
99
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/aria/live-region.directive.ts
|
|
102
100
|
* @since 0.1.0
|
|
@@ -164,7 +162,6 @@ const CLEAR_DELAY_MS = 16;
|
|
|
164
162
|
* ```
|
|
165
163
|
*
|
|
166
164
|
* @category common/a11y
|
|
167
|
-
* @docsKind primary
|
|
168
165
|
* @wcag AA
|
|
169
166
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/aria/live-announcer.ts
|
|
170
167
|
* @since 0.1.0
|
|
@@ -281,7 +278,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
281
278
|
* ```
|
|
282
279
|
*
|
|
283
280
|
* @category common/a11y
|
|
284
|
-
* @docsKind primary
|
|
285
281
|
* @wcag AA
|
|
286
282
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/autofocus.directive.ts
|
|
287
283
|
* @since 0.1.0
|
|
@@ -330,7 +326,14 @@ class CngxAutofocus {
|
|
|
330
326
|
}
|
|
331
327
|
}
|
|
332
328
|
applyFocus() {
|
|
333
|
-
this.el.nativeElement
|
|
329
|
+
const el = this.el.nativeElement;
|
|
330
|
+
// A delayed schedule can outlive its trigger: the condition may have
|
|
331
|
+
// flipped off or the element may have left the DOM. Re-check both so a
|
|
332
|
+
// stale timer cannot steal focus from wherever it moved meanwhile.
|
|
333
|
+
if (!this.when() || !el.isConnected) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
el.focus(this.options());
|
|
334
337
|
}
|
|
335
338
|
clearPending() {
|
|
336
339
|
if (this.pendingTimer !== null) {
|
|
@@ -374,7 +377,9 @@ const CNGX_FOCUSABLE_SELECTOR = 'a[href], button:not(:disabled), input:not(:disa
|
|
|
374
377
|
* `document.activeElement` at initialization time and restores it when the
|
|
375
378
|
* host element is destroyed.
|
|
376
379
|
*
|
|
377
|
-
* Fallback chain: stored element → provided fallback → nearest focusable ancestor
|
|
380
|
+
* Fallback chain: stored element → provided fallback → nearest focusable ancestor.
|
|
381
|
+
* When none resolves, focus is left where the browser put it - `<body>` is
|
|
382
|
+
* deliberately never a restore target.
|
|
378
383
|
*
|
|
379
384
|
* ### Panel that restores focus on close
|
|
380
385
|
* ```html
|
|
@@ -395,7 +400,6 @@ const CNGX_FOCUSABLE_SELECTOR = 'a[href], button:not(:disabled), input:not(:disa
|
|
|
395
400
|
* ```
|
|
396
401
|
*
|
|
397
402
|
* @category common/a11y
|
|
398
|
-
* @docsKind primary
|
|
399
403
|
* @wcag AA
|
|
400
404
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/focus-restore.directive.ts
|
|
401
405
|
* @since 0.1.0
|
|
@@ -504,6 +508,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
504
508
|
* The CDK's imperative `create()` / `destroy()` / `enabled` setter lifecycle
|
|
505
509
|
* is handled internally via `effect()` and `DestroyRef`.
|
|
506
510
|
*
|
|
511
|
+
* **Nesting:** traps do not coordinate with each other. When traps nest
|
|
512
|
+
* (dialog over drawer), enable only the innermost one and drive each
|
|
513
|
+
* `enabled` from your layering state - two simultaneously enabled traps
|
|
514
|
+
* fight over Tab. `CngxDialogStack` already does this for stacked dialogs.
|
|
515
|
+
*
|
|
507
516
|
* ### Modal dialog
|
|
508
517
|
* ```html
|
|
509
518
|
* <div cngxFocusTrap [enabled]="isOpen()" [autoFocus]="true"
|
|
@@ -536,18 +545,27 @@ class CngxFocusTrap {
|
|
|
536
545
|
enabled = input(false, ...(ngDevMode ? [{ debugName: "enabled" }] : /* istanbul ignore next */ []));
|
|
537
546
|
/** Whether to auto-focus the first tabbable element when the trap activates. */
|
|
538
547
|
autoFocus = input(true, ...(ngDevMode ? [{ debugName: "autoFocus" }] : /* istanbul ignore next */ []));
|
|
539
|
-
/**
|
|
548
|
+
/**
|
|
549
|
+
* Readable alias of `enabled` for `exportAs` consumers
|
|
550
|
+
* (`trap.isActive()` reads better than re-binding the input).
|
|
551
|
+
*/
|
|
540
552
|
isActive = computed(() => this.enabled(), ...(ngDevMode ? [{ debugName: "isActive" }] : /* istanbul ignore next */ []));
|
|
541
553
|
trap;
|
|
542
554
|
constructor() {
|
|
543
555
|
const el = inject((ElementRef));
|
|
544
556
|
this.trap = inject(FocusTrapFactory).create(el.nativeElement);
|
|
557
|
+
// Track ONLY enabled: with autoFocus inside the tracked zone, flipping
|
|
558
|
+
// [autoFocus] while the trap is active would re-run the effect and yank
|
|
559
|
+
// focus back to the first tabbable element. The CDK calls are service
|
|
560
|
+
// work, not dependencies.
|
|
545
561
|
effect(() => {
|
|
546
562
|
const enabled = this.enabled();
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
563
|
+
untracked(() => {
|
|
564
|
+
this.trap.enabled = enabled;
|
|
565
|
+
if (enabled && this.autoFocus()) {
|
|
566
|
+
void this.trap.focusFirstTabbableElementWhenReady();
|
|
567
|
+
}
|
|
568
|
+
});
|
|
551
569
|
});
|
|
552
570
|
inject(DestroyRef).onDestroy(() => this.trap.destroy());
|
|
553
571
|
}
|
|
@@ -585,7 +603,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
585
603
|
* ```
|
|
586
604
|
*
|
|
587
605
|
* @category common/a11y
|
|
588
|
-
* @docsKind primary
|
|
589
606
|
* @wcag AA
|
|
590
607
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/focus-visible.directive.ts
|
|
591
608
|
* @since 0.1.0
|
|
@@ -594,11 +611,50 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
594
611
|
* <example-url>http://localhost:4200/#/common/a11y/focus-visible/keyboard-vs-pointer</example-url>
|
|
595
612
|
*/
|
|
596
613
|
class CngxFocusVisible {
|
|
614
|
+
doc = inject(DOCUMENT);
|
|
597
615
|
focusVisibleState = signal(false, ...(ngDevMode ? [{ debugName: "focusVisibleState" }] : /* istanbul ignore next */ []));
|
|
598
616
|
/** `true` when focus was initiated via keyboard (not pointer). */
|
|
599
617
|
focusVisible = this.focusVisibleState.asReadonly();
|
|
600
|
-
/** @internal Cleared on `focusin` after being set by `pointerdown`. */
|
|
601
618
|
pointerActive = false;
|
|
619
|
+
pointerClearTimer = null;
|
|
620
|
+
schedulePointerClear = () => {
|
|
621
|
+
// One macrotask of grace: on touch, the compat mousedown and the focusin
|
|
622
|
+
// fire AFTER pointerup, so a synchronous clear here would misread a tap
|
|
623
|
+
// as keyboard focus. The deferred clear runs after the whole tap
|
|
624
|
+
// sequence settled.
|
|
625
|
+
if (this.pointerClearTimer !== null) {
|
|
626
|
+
clearTimeout(this.pointerClearTimer);
|
|
627
|
+
}
|
|
628
|
+
this.pointerClearTimer = setTimeout(() => {
|
|
629
|
+
this.pointerActive = false;
|
|
630
|
+
this.pointerClearTimer = null;
|
|
631
|
+
}, 0);
|
|
632
|
+
};
|
|
633
|
+
constructor() {
|
|
634
|
+
inject(DestroyRef).onDestroy(() => {
|
|
635
|
+
this.doc.removeEventListener('pointerup', this.schedulePointerClear, true);
|
|
636
|
+
if (this.pointerClearTimer !== null) {
|
|
637
|
+
clearTimeout(this.pointerClearTimer);
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
/** @internal Arms the pointer flag for the imminent focusin. */
|
|
642
|
+
handlePointerDown() {
|
|
643
|
+
// A pending clear from the previous release must not fire mid-press.
|
|
644
|
+
if (this.pointerClearTimer !== null) {
|
|
645
|
+
clearTimeout(this.pointerClearTimer);
|
|
646
|
+
this.pointerClearTimer = null;
|
|
647
|
+
}
|
|
648
|
+
this.pointerActive = true;
|
|
649
|
+
// The flag must not outlive the click: a pointerdown that never focuses
|
|
650
|
+
// (disabled child, text selection, drag released off-host) would
|
|
651
|
+
// otherwise suppress the ring on the NEXT keyboard Tab-in. Document-level
|
|
652
|
+
// capture catches the release wherever it lands.
|
|
653
|
+
this.doc.addEventListener('pointerup', this.schedulePointerClear, {
|
|
654
|
+
once: true,
|
|
655
|
+
capture: true,
|
|
656
|
+
});
|
|
657
|
+
}
|
|
602
658
|
/** @internal Sets focus-visible state; clears pointer flag. */
|
|
603
659
|
handleFocus() {
|
|
604
660
|
this.focusVisibleState.set(!this.pointerActive);
|
|
@@ -609,7 +665,7 @@ class CngxFocusVisible {
|
|
|
609
665
|
this.focusVisibleState.set(false);
|
|
610
666
|
}
|
|
611
667
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxFocusVisible, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
612
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxFocusVisible, isStandalone: true, selector: "[cngxFocusVisible]", host: { listeners: { "pointerdown": "
|
|
668
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxFocusVisible, isStandalone: true, selector: "[cngxFocusVisible]", host: { listeners: { "pointerdown": "handlePointerDown()", "focusin": "handleFocus()", "focusout": "handleBlur()" }, properties: { "class.cngx-focus-visible": "focusVisible()" } }, exportAs: ["cngxFocusVisible"], ngImport: i0 });
|
|
613
669
|
}
|
|
614
670
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxFocusVisible, decorators: [{
|
|
615
671
|
type: Directive,
|
|
@@ -618,13 +674,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
618
674
|
exportAs: 'cngxFocusVisible',
|
|
619
675
|
standalone: true,
|
|
620
676
|
host: {
|
|
621
|
-
'(pointerdown)': '
|
|
677
|
+
'(pointerdown)': 'handlePointerDown()',
|
|
622
678
|
'(focusin)': 'handleFocus()',
|
|
623
679
|
'(focusout)': 'handleBlur()',
|
|
624
680
|
'[class.cngx-focus-visible]': 'focusVisible()',
|
|
625
681
|
},
|
|
626
682
|
}]
|
|
627
|
-
}] });
|
|
683
|
+
}], ctorParameters: () => [] });
|
|
628
684
|
|
|
629
685
|
/**
|
|
630
686
|
* Marker directive for items managed by `CngxRovingTabindex`.
|
|
@@ -642,7 +698,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
642
698
|
* ```
|
|
643
699
|
*
|
|
644
700
|
* @category common/a11y
|
|
645
|
-
* @docsKind primary
|
|
646
701
|
* @wcag AA
|
|
647
702
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/roving/roving-tabindex.directive.ts
|
|
648
703
|
* @since 0.1.0
|
|
@@ -941,20 +996,11 @@ class CngxRovingTabindex {
|
|
|
941
996
|
}
|
|
942
997
|
/**
|
|
943
998
|
* Finds the next index in virtual mode. No disabled-item skipping - can't check
|
|
944
|
-
* disabled state of items not in the DOM
|
|
999
|
+
* disabled state of items not in the DOM (the resolver treats every index as
|
|
1000
|
+
* enabled when no `isDisabledAt` is supplied).
|
|
945
1001
|
*/
|
|
946
1002
|
findNextVirtual(current, total, direction) {
|
|
947
|
-
|
|
948
|
-
return null;
|
|
949
|
-
}
|
|
950
|
-
const idx = current + direction;
|
|
951
|
-
if (this.loop()) {
|
|
952
|
-
return ((idx % total) + total) % total;
|
|
953
|
-
}
|
|
954
|
-
if (idx < 0 || idx >= total) {
|
|
955
|
-
return null;
|
|
956
|
-
}
|
|
957
|
-
return idx;
|
|
1003
|
+
return resolveStepFrom(current, direction, { count: total, loop: this.loop() });
|
|
958
1004
|
}
|
|
959
1005
|
enabledItems() {
|
|
960
1006
|
return this.items().filter((item) => !item.disabled());
|
|
@@ -973,37 +1019,23 @@ class CngxRovingTabindex {
|
|
|
973
1019
|
* Skips disabled items.
|
|
974
1020
|
*/
|
|
975
1021
|
findNext(current, items, direction) {
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
const loop = this.loop();
|
|
982
|
-
for (let i = 0; i < len; i++) {
|
|
983
|
-
if (loop) {
|
|
984
|
-
idx = ((idx % len) + len) % len;
|
|
985
|
-
}
|
|
986
|
-
else if (idx < 0 || idx >= len) {
|
|
987
|
-
return null;
|
|
988
|
-
}
|
|
989
|
-
if (!items[idx].disabled()) {
|
|
990
|
-
return idx;
|
|
991
|
-
}
|
|
992
|
-
idx += direction;
|
|
993
|
-
}
|
|
994
|
-
return null;
|
|
1022
|
+
return resolveStepFrom(current, direction, {
|
|
1023
|
+
count: items.length,
|
|
1024
|
+
loop: this.loop(),
|
|
1025
|
+
isDisabledAt: (i) => items[i].disabled(),
|
|
1026
|
+
});
|
|
995
1027
|
}
|
|
996
1028
|
findFirst(items) {
|
|
997
|
-
|
|
998
|
-
|
|
1029
|
+
return resolveBoundaryStep(1, {
|
|
1030
|
+
count: items.length,
|
|
1031
|
+
isDisabledAt: (i) => items[i].disabled(),
|
|
1032
|
+
});
|
|
999
1033
|
}
|
|
1000
1034
|
findLast(items) {
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
}
|
|
1006
|
-
return null;
|
|
1035
|
+
return resolveBoundaryStep(-1, {
|
|
1036
|
+
count: items.length,
|
|
1037
|
+
isDisabledAt: (i) => items[i].disabled(),
|
|
1038
|
+
});
|
|
1007
1039
|
}
|
|
1008
1040
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxRovingTabindex, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1009
1041
|
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)", "focusin": "handleFocusIn($event)" } }, queries: [{ propertyName: "items", predicate: CngxRovingItem, isSignal: true }], exportAs: ["cngxRovingTabindex"], ngImport: i0 });
|
|
@@ -1122,7 +1154,17 @@ class CngxActiveDescendant {
|
|
|
1122
1154
|
activated = output();
|
|
1123
1155
|
/** Emitted whenever the highlighted item changes. */
|
|
1124
1156
|
highlighted = output();
|
|
1157
|
+
/**
|
|
1158
|
+
* Emitted when a typeahead query finds no match in the rendered window.
|
|
1159
|
+
* Carries the resolved query term (lowercased; a repeated single letter
|
|
1160
|
+
* collapses to that letter per the APG cycle rule). The rendered window
|
|
1161
|
+
* is AD's whole search space - hosts whose real item space is larger
|
|
1162
|
+
* (collapsed tree branches, virtualized rows outside the window) listen
|
|
1163
|
+
* here to resolve the miss themselves.
|
|
1164
|
+
*/
|
|
1165
|
+
typeaheadMissed = output();
|
|
1125
1166
|
hostEl = inject((ElementRef));
|
|
1167
|
+
locale = injectLocale();
|
|
1126
1168
|
registered = contentChildren(CNGX_AD_ITEM, { ...(ngDevMode ? { debugName: "registered" } : /* istanbul ignore next */ {}), descendants: true });
|
|
1127
1169
|
/** Document writing direction - flips the horizontal-arrow steps under `rtl` (APG). */
|
|
1128
1170
|
direction = injectDirection();
|
|
@@ -1396,7 +1438,8 @@ class CngxActiveDescendant {
|
|
|
1396
1438
|
this.handleTypeahead(ch);
|
|
1397
1439
|
}
|
|
1398
1440
|
handleTypeahead(ch) {
|
|
1399
|
-
const
|
|
1441
|
+
const locale = this.locale();
|
|
1442
|
+
const next = this.typeaheadBuffer() + ch.toLocaleLowerCase(locale);
|
|
1400
1443
|
this.typeaheadBuffer.set(next);
|
|
1401
1444
|
if (this.typeaheadTimer !== null) {
|
|
1402
1445
|
clearTimeout(this.typeaheadTimer);
|
|
@@ -1410,80 +1453,52 @@ class CngxActiveDescendant {
|
|
|
1410
1453
|
const items = this.resolvedItems();
|
|
1411
1454
|
const skip = this.skipDisabled();
|
|
1412
1455
|
const count = items.length;
|
|
1413
|
-
if (count === 0) {
|
|
1414
|
-
return;
|
|
1415
|
-
}
|
|
1416
|
-
const windowOffset = this.windowOffset();
|
|
1417
|
-
const activeRel = this.activeIndexState() < 0 ? -1 : this.activeIndexState() - windowOffset;
|
|
1418
1456
|
// APG cycle: a single-character query (including a repeated letter, whose
|
|
1419
1457
|
// buffer collapses back to that letter) searches AFTER the active item so
|
|
1420
1458
|
// each press advances through the matches. A genuine multi-character query
|
|
1421
1459
|
// keeps matching the current item first.
|
|
1422
1460
|
const sameChar = next.length > 1 && [...next].every((c) => c === next[0]);
|
|
1423
1461
|
const term = sameChar ? next[0] : next;
|
|
1462
|
+
if (count === 0) {
|
|
1463
|
+
this.typeaheadMissed.emit(term);
|
|
1464
|
+
return;
|
|
1465
|
+
}
|
|
1466
|
+
const windowOffset = this.windowOffset();
|
|
1467
|
+
const activeRel = this.activeIndexState() < 0 ? -1 : this.activeIndexState() - windowOffset;
|
|
1424
1468
|
const cycles = term.length === 1;
|
|
1425
1469
|
const startRel = cycles ? activeRel + 1 : Math.max(0, activeRel);
|
|
1470
|
+
const matches = createTypeaheadMatcher(term, locale);
|
|
1426
1471
|
for (let step = 0; step < count; step++) {
|
|
1427
1472
|
const rel = (((startRel + step) % count) + count) % count;
|
|
1428
1473
|
const candidate = items[rel];
|
|
1429
1474
|
if (skip && candidate.disabled) {
|
|
1430
1475
|
continue;
|
|
1431
1476
|
}
|
|
1432
|
-
if (candidate.label
|
|
1477
|
+
if (matches(candidate.label, candidate)) {
|
|
1433
1478
|
this.activeIndexState.set(rel + windowOffset);
|
|
1434
1479
|
return;
|
|
1435
1480
|
}
|
|
1436
1481
|
}
|
|
1482
|
+
this.typeaheadMissed.emit(term);
|
|
1437
1483
|
}
|
|
1438
1484
|
findFrom(current, direction) {
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
const loop = this.loop();
|
|
1445
|
-
let idx = current < 0 ? (direction === 1 ? -1 : total) : current;
|
|
1446
|
-
for (let step = 0; step < total; step++) {
|
|
1447
|
-
idx += direction;
|
|
1448
|
-
if (idx < 0 || idx >= total) {
|
|
1449
|
-
if (!loop) {
|
|
1450
|
-
return null;
|
|
1451
|
-
}
|
|
1452
|
-
idx = ((idx % total) + total) % total;
|
|
1453
|
-
}
|
|
1454
|
-
if (!skip || !this.isDisabledAt(idx)) {
|
|
1455
|
-
return idx;
|
|
1456
|
-
}
|
|
1457
|
-
}
|
|
1458
|
-
return null;
|
|
1485
|
+
return resolveStepFrom(current, direction, {
|
|
1486
|
+
count: this.totalCount(),
|
|
1487
|
+
loop: this.loop(),
|
|
1488
|
+
isDisabledAt: this.skipDisabled() ? (i) => this.isDisabledAt(i) : undefined,
|
|
1489
|
+
});
|
|
1459
1490
|
}
|
|
1460
1491
|
/**
|
|
1461
1492
|
* First/last navigable absolute index. Spans the full virtual range - End
|
|
1462
1493
|
* targets `totalCount - 1` even when that item is not rendered (it surfaces
|
|
1463
1494
|
* as `pendingHighlight`); unrendered items count as enabled because their
|
|
1464
|
-
* disabled state is unknowable.
|
|
1495
|
+
* disabled state is unknowable (`isDisabledAt` resolves them to `false`).
|
|
1465
1496
|
*/
|
|
1466
1497
|
findBoundary(direction) {
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
}
|
|
1471
|
-
const skip = this.skipDisabled();
|
|
1472
|
-
if (direction === 1) {
|
|
1473
|
-
for (let i = 0; i < total; i++) {
|
|
1474
|
-
if (!skip || !this.isDisabledAt(i)) {
|
|
1475
|
-
return i;
|
|
1476
|
-
}
|
|
1477
|
-
}
|
|
1478
|
-
}
|
|
1479
|
-
else {
|
|
1480
|
-
for (let i = total - 1; i >= 0; i--) {
|
|
1481
|
-
if (!skip || !this.isDisabledAt(i)) {
|
|
1482
|
-
return i;
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
}
|
|
1486
|
-
return null;
|
|
1498
|
+
return resolveBoundaryStep(direction, {
|
|
1499
|
+
count: this.totalCount(),
|
|
1500
|
+
isDisabledAt: this.skipDisabled() ? (i) => this.isDisabledAt(i) : undefined,
|
|
1501
|
+
});
|
|
1487
1502
|
}
|
|
1488
1503
|
totalCount() {
|
|
1489
1504
|
const vc = this.virtualCount();
|
|
@@ -1525,7 +1540,7 @@ class CngxActiveDescendant {
|
|
|
1525
1540
|
}
|
|
1526
1541
|
}
|
|
1527
1542
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxActiveDescendant, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1528
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxActiveDescendant, isStandalone: true, selector: "[cngxActiveDescendant]", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, loop: { classPropertyName: "loop", publicName: "loop", isSignal: true, isRequired: false, transformFunction: null }, typeahead: { classPropertyName: "typeahead", publicName: "typeahead", isSignal: true, isRequired: false, transformFunction: null }, typeaheadDebounce: { classPropertyName: "typeaheadDebounce", publicName: "typeaheadDebounce", isSignal: true, isRequired: false, transformFunction: null }, autoHighlightFirst: { classPropertyName: "autoHighlightFirst", publicName: "autoHighlightFirst", isSignal: true, isRequired: false, transformFunction: null }, skipDisabled: { classPropertyName: "skipDisabled", publicName: "skipDisabled", isSignal: true, isRequired: false, transformFunction: null }, virtualCount: { classPropertyName: "virtualCount", publicName: "virtualCount", isSignal: true, isRequired: false, transformFunction: null }, windowStart: { classPropertyName: "windowStart", publicName: "windowStart", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { activated: "activated", highlighted: "highlighted" }, host: { listeners: { "keydown": "handleKeydown($event)" }, properties: { "attr.aria-activedescendant": "activeId()" } }, queries: [{ propertyName: "registered", predicate: CNGX_AD_ITEM, descendants: true, isSignal: true }], exportAs: ["cngxActiveDescendant"], ngImport: i0 });
|
|
1543
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxActiveDescendant, isStandalone: true, selector: "[cngxActiveDescendant]", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, loop: { classPropertyName: "loop", publicName: "loop", isSignal: true, isRequired: false, transformFunction: null }, typeahead: { classPropertyName: "typeahead", publicName: "typeahead", isSignal: true, isRequired: false, transformFunction: null }, typeaheadDebounce: { classPropertyName: "typeaheadDebounce", publicName: "typeaheadDebounce", isSignal: true, isRequired: false, transformFunction: null }, autoHighlightFirst: { classPropertyName: "autoHighlightFirst", publicName: "autoHighlightFirst", isSignal: true, isRequired: false, transformFunction: null }, skipDisabled: { classPropertyName: "skipDisabled", publicName: "skipDisabled", isSignal: true, isRequired: false, transformFunction: null }, virtualCount: { classPropertyName: "virtualCount", publicName: "virtualCount", isSignal: true, isRequired: false, transformFunction: null }, windowStart: { classPropertyName: "windowStart", publicName: "windowStart", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { activated: "activated", highlighted: "highlighted", typeaheadMissed: "typeaheadMissed" }, host: { listeners: { "keydown": "handleKeydown($event)" }, properties: { "attr.aria-activedescendant": "activeId()" } }, queries: [{ propertyName: "registered", predicate: CNGX_AD_ITEM, descendants: true, isSignal: true }], exportAs: ["cngxActiveDescendant"], ngImport: i0 });
|
|
1529
1544
|
}
|
|
1530
1545
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxActiveDescendant, decorators: [{
|
|
1531
1546
|
type: Directive,
|
|
@@ -1538,7 +1553,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1538
1553
|
'(keydown)': 'handleKeydown($event)',
|
|
1539
1554
|
},
|
|
1540
1555
|
}]
|
|
1541
|
-
}], 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 }] }], windowStart: [{ type: i0.Input, args: [{ isSignal: true, alias: "windowStart", 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 }] }] } });
|
|
1556
|
+
}], 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 }] }], windowStart: [{ type: i0.Input, args: [{ isSignal: true, alias: "windowStart", required: false }] }], activated: [{ type: i0.Output, args: ["activated"] }], highlighted: [{ type: i0.Output, args: ["highlighted"] }], typeaheadMissed: [{ type: i0.Output, args: ["typeaheadMissed"] }], registered: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CNGX_AD_ITEM), { ...{ descendants: true }, isSignal: true }] }] } });
|
|
1542
1557
|
/** @internal */
|
|
1543
1558
|
function handleToItem(handle) {
|
|
1544
1559
|
return {
|
|
@@ -1617,7 +1632,6 @@ function cssEscape(id) {
|
|
|
1617
1632
|
* ```
|
|
1618
1633
|
*
|
|
1619
1634
|
* @category common/a11y
|
|
1620
|
-
* @docsKind primary
|
|
1621
1635
|
* @wcag AA
|
|
1622
1636
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/motion/reduced-motion.directive.ts
|
|
1623
1637
|
* @since 0.1.0
|