@cngx/common 0.1.0-rc.1 → 0.1.0-rc.3
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/data/README.md +10 -3
- package/fesm2022/cngx-common-data.mjs +379 -57
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +318 -5
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +532 -151
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +1 -1
- package/package.json +2 -2
- package/stepper/README.md +0 -13
- package/types/cngx-common-data.d.ts +446 -41
- package/types/cngx-common-stepper.d.ts +350 -6
- package/types/cngx-common-tabs.d.ts +586 -191
- package/tabs/README.md +0 -32
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, model, input, inject, Injector, computed, output, signal, Directive, TemplateRef, contentChild, DestroyRef,
|
|
2
|
+
import { InjectionToken, model, input, inject, Injector, computed, output, signal, Directive, TemplateRef, contentChild, DestroyRef, Renderer2, ElementRef, effect, afterNextRender, untracked, makeEnvironmentProviders, isDevMode, linkedSignal, runInInjectionContext } from '@angular/core';
|
|
3
3
|
import { CNGX_COMMIT_CONTROLLER_FACTORY } from '@cngx/common/data';
|
|
4
4
|
import { createTransitionTracker, CNGX_STATEFUL, nextUid } from '@cngx/core/utils';
|
|
5
5
|
import { isObservable, Observable } from 'rxjs';
|
|
@@ -101,10 +101,11 @@ function runTabsAction(action, fromIndex, toIndex, handlers) {
|
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
|
-
* DI token for the commit-handler factory.
|
|
105
|
-
* {@link createTabsCommitHandler}.
|
|
106
|
-
*
|
|
107
|
-
* `
|
|
104
|
+
* DI token for the commit-handler factory. \
|
|
105
|
+
* Defaults to {@link createTabsCommitHandler}. \
|
|
106
|
+
* Sibling to
|
|
107
|
+
* - `CNGX_ARRAY_COMMIT_HANDLER_FACTORY` (select) and
|
|
108
|
+
* - `CNGX_STEPPER_COMMIT_HANDLER_FACTORY`.
|
|
108
109
|
*
|
|
109
110
|
* @category common/tabs
|
|
110
111
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/commit-handler.ts
|
|
@@ -116,8 +117,8 @@ const CNGX_TABS_COMMIT_HANDLER_FACTORY = new InjectionToken('CngxTabsCommitHandl
|
|
|
116
117
|
});
|
|
117
118
|
|
|
118
119
|
/**
|
|
119
|
-
* DI token for the tab presenter's contract.
|
|
120
|
-
* `useExisting`; `CngxTab` injects to register; the organism injects
|
|
120
|
+
* DI token for the tab presenter's contract. \
|
|
121
|
+
* Presenter provides via `useExisting`; `CngxTab` injects to register; the organism injects
|
|
121
122
|
* to drive the APG tablist keyboard model (automatic activation via
|
|
122
123
|
* `select()`, roving stop derived from `activeId`) through
|
|
123
124
|
* `createTabKeyboardNav`.
|
|
@@ -130,15 +131,15 @@ const CNGX_TABS_COMMIT_HANDLER_FACTORY = new InjectionToken('CngxTabsCommitHandl
|
|
|
130
131
|
const CNGX_TAB_GROUP_HOST = new InjectionToken('CngxTabGroupHost');
|
|
131
132
|
|
|
132
133
|
/**
|
|
133
|
-
* Tab-group presenter - brain of every
|
|
134
|
-
* active-index model, the tab registry, orientation, loop policy,
|
|
135
|
-
* and the commit-controller lifecycle.
|
|
136
|
-
* {@link CNGX_TAB_GROUP_HOST} for atoms and {@link CNGX_STATEFUL}
|
|
134
|
+
* Tab-group presenter - brain of every CNGX tab flow. \
|
|
135
|
+
* Owns the active-index model, the tab registry, orientation, loop policy,
|
|
136
|
+
* and the commit-controller lifecycle. \
|
|
137
|
+
* Provides {@link CNGX_TAB_GROUP_HOST} for atoms and {@link CNGX_STATEFUL}
|
|
137
138
|
* so `<cngx-toast-on />` / `<cngx-banner-on />` compose without
|
|
138
139
|
* `[state]` wiring.
|
|
139
140
|
*
|
|
140
|
-
* **Layer:** `@cngx/common/tabs
|
|
141
|
-
* organisms compose via `hostDirectives`, consumers attach
|
|
141
|
+
* **Layer:** `@cngx/common/tabs`. \
|
|
142
|
+
* Directive-only - organisms compose via `hostDirectives`, consumers attach
|
|
142
143
|
* `[cngxTabGroup]` directly.
|
|
143
144
|
*
|
|
144
145
|
* @category common/tabs
|
|
@@ -154,8 +155,8 @@ class CngxTabGroupPresenter {
|
|
|
154
155
|
orientation = input('horizontal', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
155
156
|
loop = input(true, ...(ngDevMode ? [{ debugName: "loop" }] : /* istanbul ignore next */ []));
|
|
156
157
|
/**
|
|
157
|
-
* Async-commit action gating the transition.
|
|
158
|
-
* `select(...)` routes through {@link CngxTabsCommitHandler}; the
|
|
158
|
+
* Async-commit action gating the transition.
|
|
159
|
+
* When non-null, `select(...)` routes through {@link CngxTabsCommitHandler}; the
|
|
159
160
|
* action's resolution decides whether the change lands. Supersede
|
|
160
161
|
* semantics come from the commit-controller - a rapid second
|
|
161
162
|
* `select(...)` cancels the in-flight runner.
|
|
@@ -466,8 +467,8 @@ function tabsEqual(a, b) {
|
|
|
466
467
|
}
|
|
467
468
|
|
|
468
469
|
/**
|
|
469
|
-
* DI token the organism provides via `useExisting
|
|
470
|
-
* molecule and consumer-authored skin sub-components inject this
|
|
470
|
+
* DI token the organism provides via `useExisting`.\
|
|
471
|
+
* The overflow molecule and consumer-authored skin sub-components inject this
|
|
471
472
|
* instead of the concrete component class.
|
|
472
473
|
*
|
|
473
474
|
* @category common/tabs
|
|
@@ -478,13 +479,12 @@ function tabsEqual(a, b) {
|
|
|
478
479
|
const CNGX_TAB_PANEL_HOST = new InjectionToken('CngxTabPanelHost');
|
|
479
480
|
|
|
480
481
|
/**
|
|
481
|
-
* Structural slot directive marking the per-tab panel-body template.
|
|
482
|
+
* Structural slot directive marking the per-tab panel-body template. \
|
|
482
483
|
* Discovered by `<cngx-tab-group>` via `contentChild` on each
|
|
483
484
|
* `CngxTab` and projected into the matching `role="tabpanel"`.
|
|
484
485
|
*
|
|
485
486
|
* ```html
|
|
486
|
-
* <div cngxTab
|
|
487
|
-
* <ng-template cngxTabLabel>Settings</ng-template>
|
|
487
|
+
* <div cngxTab [label]="'Settings'">
|
|
488
488
|
* <ng-template cngxTabContent>
|
|
489
489
|
* <p>Settings panel body…</p>
|
|
490
490
|
* </ng-template>
|
|
@@ -496,14 +496,6 @@ const CNGX_TAB_PANEL_HOST = new InjectionToken('CngxTabPanelHost');
|
|
|
496
496
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/tab-content.directive.ts
|
|
497
497
|
* @since 0.1.0
|
|
498
498
|
* @relatedTo CngxTab, CngxTabLabel
|
|
499
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-commit-action/optimistic-pessimistic-commits-with-bridge-directives</example-url>
|
|
500
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-error-aggregation/per-tab-error-badges</example-url>
|
|
501
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-group-vertical/vertical-sidebar-tabs</example-url>
|
|
502
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-group/three-tab-navigation</example-url>
|
|
503
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-overflow/8-tabs-in-a-narrow-container</example-url>
|
|
504
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/custom-busy-spinner-via-code-cngxtabbusyspinner-code</example-url>
|
|
505
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/custom-error-badge-via-code-cngxtaberrorbadge-code</example-url>
|
|
506
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/rejection-decoration-via-code-cngxtabrejectionicon-code</example-url>
|
|
507
499
|
*/
|
|
508
500
|
class CngxTabContent {
|
|
509
501
|
templateRef = inject((TemplateRef));
|
|
@@ -520,14 +512,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
520
512
|
}] });
|
|
521
513
|
|
|
522
514
|
/**
|
|
523
|
-
* Structural slot directive marking the per-tab label template.
|
|
515
|
+
* Structural slot directive marking the per-tab label template. \
|
|
524
516
|
* Discovered by `<cngx-tab-group>` via `contentChild` on each
|
|
525
517
|
* `CngxTab` and projected into the tab strip.
|
|
526
518
|
*
|
|
527
519
|
* ```html
|
|
528
520
|
* <div cngxTab id="settings">
|
|
529
521
|
* <ng-template cngxTabLabel>Settings</ng-template>
|
|
530
|
-
*
|
|
522
|
+
* ... tab content ...
|
|
531
523
|
* </div>
|
|
532
524
|
* ```
|
|
533
525
|
*
|
|
@@ -536,8 +528,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
536
528
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/tab-label.directive.ts
|
|
537
529
|
* @since 0.1.0
|
|
538
530
|
* @relatedTo CngxTab, CngxTabContent
|
|
539
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-group-vertical/vertical-sidebar-tabs</example-url>
|
|
540
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-group/three-tab-navigation</example-url>
|
|
541
531
|
*/
|
|
542
532
|
class CngxTabLabel {
|
|
543
533
|
templateRef = inject((TemplateRef));
|
|
@@ -554,10 +544,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
554
544
|
}] });
|
|
555
545
|
|
|
556
546
|
/**
|
|
557
|
-
* Structural slot directive marking a tab's secondary label template.
|
|
547
|
+
* Structural slot directive marking a tab's secondary label template. \
|
|
558
548
|
* Discovered by `<cngx-tab-group>` via `contentChild` on each
|
|
559
549
|
* `CngxTab` and rendered as a stacked second line under the primary
|
|
560
|
-
* label.
|
|
550
|
+
* label. \
|
|
551
|
+
*
|
|
552
|
+
* Per-tab content, mirroring `CngxTabLabel` - the convenience
|
|
561
553
|
* `[subLabel]` string input on `CngxTab` covers the plain-text case.
|
|
562
554
|
*
|
|
563
555
|
* ```html
|
|
@@ -568,7 +560,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
568
560
|
* </div>
|
|
569
561
|
* ```
|
|
570
562
|
*
|
|
571
|
-
* @category common/tabs
|
|
563
|
+
* @category common/tabs/slots
|
|
572
564
|
* @wcag AA
|
|
573
565
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-sub-label.directive.ts
|
|
574
566
|
* @since 0.1.0
|
|
@@ -576,6 +568,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
576
568
|
* <example-url>http://localhost:4200/#/ui/tabs/tab-sub-label/label-with-count</example-url>
|
|
577
569
|
*/
|
|
578
570
|
class CngxTabSubLabel {
|
|
571
|
+
/**
|
|
572
|
+
* The captured `<ng-template>`, projected by `<cngx-tab-group>` as the
|
|
573
|
+
* tab's secondary label line under the primary label.
|
|
574
|
+
*/
|
|
579
575
|
templateRef = inject((TemplateRef));
|
|
580
576
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTabSubLabel, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
581
577
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxTabSubLabel, isStandalone: true, selector: "ng-template[cngxTabSubLabel]", exportAs: ["cngxTabSubLabel"], ngImport: i0 });
|
|
@@ -590,27 +586,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
590
586
|
}] });
|
|
591
587
|
|
|
592
588
|
/**
|
|
593
|
-
* Single-tab atom.
|
|
589
|
+
* Single-tab atom. \
|
|
590
|
+
* Registers with the enclosing presenter via
|
|
594
591
|
* {@link CNGX_TAB_GROUP_HOST} on construction; deregisters via
|
|
595
|
-
* {@link DestroyRef} on teardown.
|
|
592
|
+
* {@link DestroyRef} on teardown. \
|
|
593
|
+
* The presenter holds the atom's
|
|
596
594
|
* input signals by reference, so input changes propagate without
|
|
597
|
-
* re-registration.
|
|
595
|
+
* re-registration. \
|
|
596
|
+
* `labelTemplate` / `contentTemplate` are projected
|
|
598
597
|
* by the organism - the atom carries no rendering logic.
|
|
599
598
|
*
|
|
599
|
+
* ```html
|
|
600
|
+
* <div cngxTab [label]="'Settings'">
|
|
601
|
+
* ... content templates here ...
|
|
602
|
+
* </div>
|
|
603
|
+
* ```
|
|
600
604
|
* @category common/tabs
|
|
601
605
|
* @docsKind primary
|
|
602
606
|
* @wcag AA
|
|
603
607
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/tab.directive.ts
|
|
604
608
|
* @since 0.1.0
|
|
605
609
|
* @relatedTo CngxTabGroupPresenter, CngxTabLabel, CngxTabContent, CngxTabErrorBadge
|
|
606
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-commit-action/optimistic-pessimistic-commits-with-bridge-directives</example-url>
|
|
607
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-error-aggregation/per-tab-error-badges</example-url>
|
|
608
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-group-vertical/vertical-sidebar-tabs</example-url>
|
|
609
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-group/three-tab-navigation</example-url>
|
|
610
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-overflow/8-tabs-in-a-narrow-container</example-url>
|
|
611
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/custom-busy-spinner-via-code-cngxtabbusyspinner-code</example-url>
|
|
612
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/custom-error-badge-via-code-cngxtaberrorbadge-code</example-url>
|
|
613
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/rejection-decoration-via-code-cngxtabrejectionicon-code</example-url>
|
|
614
610
|
*/
|
|
615
611
|
class CngxTab {
|
|
616
612
|
id = input(nextUid('cngx-tab-'), ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
@@ -708,6 +704,177 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
708
704
|
}]
|
|
709
705
|
}], ctorParameters: () => [], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], subLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "subLabel", required: false }] }], errorAggregator: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorAggregator", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }], closable: [{ type: i0.Input, args: [{ isSignal: true, alias: "closable", required: false }] }], labelTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxTabLabel), { isSignal: true }] }], subLabelTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxTabSubLabel), { isSignal: true }] }], contentTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxTabContent), { isSignal: true }] }] } });
|
|
710
706
|
|
|
707
|
+
/**
|
|
708
|
+
* Turns a consumer `<a routerLink>` into a registered {@link CngxTabHandle}
|
|
709
|
+
* inside a {@link CngxTabNav}. \
|
|
710
|
+
* Native parallel of {@link CngxMatTabLink}: in a
|
|
711
|
+
* navigation bar the link IS the tab, so this per-anchor directive is the
|
|
712
|
+
* registration seam - symmetric with how `CngxTab` registers each `[cngxTab]`.
|
|
713
|
+
*
|
|
714
|
+
* Carries no rendering and no click handler. Navigation is the native
|
|
715
|
+
* `routerLink` (middle-click, open-in-new-tab and the hover URL all work),
|
|
716
|
+
* gating is the link's own `CanDeactivate`, and the active marker comes from
|
|
717
|
+
* the route: `[cngxTabsRouteSync]` on the nav reflects `NavigationEnd` onto the
|
|
718
|
+
* presenter's `activeId`, which this link matches against its own `id`. \
|
|
719
|
+
* There is no `select()` call - invoking it would re-enter the commit path the
|
|
720
|
+
* routed-nav model deliberately keeps dormant.
|
|
721
|
+
*
|
|
722
|
+
* **Error communication is reactive:** `aria-invalid` plus the
|
|
723
|
+
* `--error` skin glyph signal the state, and an injected screen-reader
|
|
724
|
+
* descriptor span (referenced by a permanent `aria-describedby`) carries the
|
|
725
|
+
* direct `[error]` message string so assistive tech reads *why* the link is
|
|
726
|
+
* invalid.
|
|
727
|
+
*
|
|
728
|
+
* ```html
|
|
729
|
+
* <cngx-tab-nav cngxTabsRouteSync>
|
|
730
|
+
* <a cngxTabLink id="overview" routerLink="overview">Overview</a>
|
|
731
|
+
* <a cngxTabLink id="profile" routerLink="profile" [error]="profileInvalid">Profile</a>
|
|
732
|
+
* </cngx-tab-nav>
|
|
733
|
+
* ```
|
|
734
|
+
*
|
|
735
|
+
* @category common/tabs
|
|
736
|
+
* @docsKind primary
|
|
737
|
+
* @wcag AA
|
|
738
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/tab-link.directive.ts
|
|
739
|
+
* @since 0.1.0
|
|
740
|
+
* @relatedTo CngxTabNav, CngxTabsRouteSync, CngxTab, CngxMatTabLink
|
|
741
|
+
*/
|
|
742
|
+
class CngxTabLink {
|
|
743
|
+
host = inject(CNGX_TAB_GROUP_HOST, { optional: true });
|
|
744
|
+
destroyRef = inject(DestroyRef);
|
|
745
|
+
renderer = inject(Renderer2);
|
|
746
|
+
hostEl = inject(ElementRef).nativeElement;
|
|
747
|
+
/**
|
|
748
|
+
* Handle id. Set it to the link's route segment so the nav's
|
|
749
|
+
* `[cngxTabsRouteSync]` reflects the active route onto this link via the
|
|
750
|
+
* default `(h) => [h.id]` mapping. Defaults to a fresh uid when route-sync
|
|
751
|
+
* is not used.
|
|
752
|
+
*/
|
|
753
|
+
id = input(nextUid('cngx-tab-link-'), ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
754
|
+
/** Accessible label fed to the nav's live-region announcer. */
|
|
755
|
+
label = input(undefined, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
756
|
+
/**
|
|
757
|
+
* Direct error flag for the link - `true` or a non-empty string marks it
|
|
758
|
+
* invalid (the string doubles as the message). Mirrors `CngxTab.error`.
|
|
759
|
+
*/
|
|
760
|
+
error = input(false, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
761
|
+
/** Optional rich error aggregator for the link. */
|
|
762
|
+
errorAggregator = input(undefined, ...(ngDevMode ? [{ debugName: "errorAggregator" }] : /* istanbul ignore next */ []));
|
|
763
|
+
/**
|
|
764
|
+
* Resolved direct-error message: the `[error]` string when non-empty, else
|
|
765
|
+
* `undefined`. Carried onto the registration handle by reference.
|
|
766
|
+
* `computed` over the input - never written.
|
|
767
|
+
*/
|
|
768
|
+
errorMessage = computed(() => {
|
|
769
|
+
const value = this.error();
|
|
770
|
+
return typeof value === 'string' && value !== '' ? value : undefined;
|
|
771
|
+
}, ...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
|
|
772
|
+
/**
|
|
773
|
+
* Per-link error fold driving `aria-invalid` and the `--error` class.
|
|
774
|
+
* `true` when the direct `[error]` flag is set OR the optional aggregator
|
|
775
|
+
* wants to reveal (`shouldShow()`, so deferred-reveal validation stays
|
|
776
|
+
* silent until revealed). Mirrors `CngxTab.hasError`.
|
|
777
|
+
*/
|
|
778
|
+
hasError = computed(() => {
|
|
779
|
+
const direct = this.error();
|
|
780
|
+
return ((direct !== false && direct !== '') || (this.errorAggregator()?.shouldShow?.() ?? false));
|
|
781
|
+
}, { ...(ngDevMode ? { debugName: "hasError" } : /* istanbul ignore next */ {}), equal: Object.is });
|
|
782
|
+
/** `true` when the presenter's `activeId` equals this link's id. */
|
|
783
|
+
selected = computed(() => this.host?.activeId() === this.id(), { ...(ngDevMode ? { debugName: "selected" } : /* istanbul ignore next */ {}), equal: Object.is });
|
|
784
|
+
/**
|
|
785
|
+
* Id of the injected SR error-message descriptor. Always referenced by the
|
|
786
|
+
* `aria-describedby` host binding (Pillar 2 - the id is permanent; the
|
|
787
|
+
* span's content and `aria-hidden` toggle, never the id itself).
|
|
788
|
+
*/
|
|
789
|
+
descriptorId = computed(() => `${this.id()}-desc`, ...(ngDevMode ? [{ debugName: "descriptorId" }] : /* istanbul ignore next */ []));
|
|
790
|
+
/** The injected descriptor `<span>`, created in {@link ngOnInit}. */
|
|
791
|
+
descriptorEl = null;
|
|
792
|
+
constructor() {
|
|
793
|
+
if (!this.host) {
|
|
794
|
+
throw new Error('CngxTabLink: no enclosing CngxTabGroupPresenter found. Wrap the link inside <cngx-tab-nav> (or an element carrying [cngxTabGroup]).');
|
|
795
|
+
}
|
|
796
|
+
// Mirror the direct-error message into the describedby span. DOM side
|
|
797
|
+
// effect only - no signal writes. Guards until the span exists (created
|
|
798
|
+
// in ngOnInit); errorMessage / descriptorId changes re-run it after.
|
|
799
|
+
effect(() => {
|
|
800
|
+
const el = this.descriptorEl;
|
|
801
|
+
if (el) {
|
|
802
|
+
this.syncDescriptor(el);
|
|
803
|
+
}
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
ngOnInit() {
|
|
807
|
+
// Register in ngOnInit, NOT the constructor: a dynamically-bound `[id]`
|
|
808
|
+
// signal input is not applied until the first change detection, so a
|
|
809
|
+
// constructor read would capture the default auto-id. The handle id is the
|
|
810
|
+
// stable key the nav's route-sync matches the URL segment against.
|
|
811
|
+
const host = this.host;
|
|
812
|
+
const handle = {
|
|
813
|
+
id: this.id(),
|
|
814
|
+
label: this.label,
|
|
815
|
+
subLabel: signal(undefined),
|
|
816
|
+
disabled: signal(false),
|
|
817
|
+
errorAggregator: this.errorAggregator,
|
|
818
|
+
hasError: this.hasError,
|
|
819
|
+
errorMessage: this.errorMessage,
|
|
820
|
+
closable: signal(undefined),
|
|
821
|
+
};
|
|
822
|
+
host.register(handle);
|
|
823
|
+
// Inject the SR error-message descriptor as a SIBLING of the anchor: a
|
|
824
|
+
// child span would fold into the link's accessible name, so it lives
|
|
825
|
+
// beside it and is reached only via the aria-describedby id.
|
|
826
|
+
const descriptor = this.renderer.createElement('span');
|
|
827
|
+
this.renderer.addClass(descriptor, 'cngx-sr-only');
|
|
828
|
+
const parent = this.renderer.parentNode(this.hostEl);
|
|
829
|
+
if (parent) {
|
|
830
|
+
this.renderer.insertBefore(parent, descriptor, this.renderer.nextSibling(this.hostEl));
|
|
831
|
+
}
|
|
832
|
+
this.descriptorEl = descriptor;
|
|
833
|
+
this.syncDescriptor(descriptor);
|
|
834
|
+
this.destroyRef.onDestroy(() => {
|
|
835
|
+
host.unregister(handle.id);
|
|
836
|
+
if (parent) {
|
|
837
|
+
this.renderer.removeChild(parent, descriptor);
|
|
838
|
+
}
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
* Write the current direct-error message into the descriptor span and
|
|
843
|
+
* toggle its `aria-hidden` so a clear link exposes no description. Keeps
|
|
844
|
+
* the span id in sync with {@link descriptorId} (read here so the effect
|
|
845
|
+
* tracks an id change too).
|
|
846
|
+
*/
|
|
847
|
+
syncDescriptor(el) {
|
|
848
|
+
this.renderer.setAttribute(el, 'id', this.descriptorId());
|
|
849
|
+
const message = this.errorMessage() ?? '';
|
|
850
|
+
this.renderer.setProperty(el, 'textContent', message);
|
|
851
|
+
if (message) {
|
|
852
|
+
this.renderer.removeAttribute(el, 'aria-hidden');
|
|
853
|
+
}
|
|
854
|
+
else {
|
|
855
|
+
this.renderer.setAttribute(el, 'aria-hidden', 'true');
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTabLink, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
859
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxTabLink, isStandalone: true, selector: "[cngxTabLink]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, errorAggregator: { classPropertyName: "errorAggregator", publicName: "errorAggregator", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.aria-current": "selected() ? 'page' : null", "attr.aria-invalid": "hasError() ? 'true' : null", "attr.aria-describedby": "descriptorId()", "class.cngx-tab-nav__link--active": "selected()", "class.cngx-tab-nav__link--error": "hasError()" }, classAttribute: "cngx-tab-nav__link" }, exportAs: ["cngxTabLink"], ngImport: i0 });
|
|
860
|
+
}
|
|
861
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTabLink, decorators: [{
|
|
862
|
+
type: Directive,
|
|
863
|
+
args: [{
|
|
864
|
+
selector: '[cngxTabLink]',
|
|
865
|
+
exportAs: 'cngxTabLink',
|
|
866
|
+
standalone: true,
|
|
867
|
+
host: {
|
|
868
|
+
class: 'cngx-tab-nav__link',
|
|
869
|
+
'[attr.aria-current]': "selected() ? 'page' : null",
|
|
870
|
+
'[attr.aria-invalid]': "hasError() ? 'true' : null",
|
|
871
|
+
'[attr.aria-describedby]': 'descriptorId()',
|
|
872
|
+
'[class.cngx-tab-nav__link--active]': 'selected()',
|
|
873
|
+
'[class.cngx-tab-nav__link--error]': 'hasError()',
|
|
874
|
+
},
|
|
875
|
+
}]
|
|
876
|
+
}], ctorParameters: () => [], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }], errorAggregator: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorAggregator", required: false }] }] } });
|
|
877
|
+
|
|
711
878
|
/**
|
|
712
879
|
* Single dev-warning both tab sync directives emit when `@angular/router`
|
|
713
880
|
* is not provided. Shared so the message stays identical across
|
|
@@ -724,16 +891,30 @@ function warnTabsRouterAbsent(directive, enables) {
|
|
|
724
891
|
}
|
|
725
892
|
|
|
726
893
|
/**
|
|
727
|
-
* URL deep-linking for tab groups.
|
|
728
|
-
* `activeId` and a URL fragment or query-param. Opt-in via
|
|
894
|
+
* URL deep-linking for tab groups. \
|
|
895
|
+
* Bidirectional sync between `activeId` and a URL fragment or query-param. Opt-in via
|
|
729
896
|
* `[cngxTabsFragmentSync]` on the presenter element.
|
|
730
897
|
*
|
|
731
898
|
* - `mode = 'fragment'` (default) → `#tab=settings`
|
|
732
899
|
* - `mode = 'queryParam'` with `paramName = 'tab'` → `?tab=settings`
|
|
733
900
|
*
|
|
734
901
|
* `Router` is optional - without it the directive logs a dev warning
|
|
735
|
-
* via `afterNextRender` and becomes a no-op.
|
|
736
|
-
* and `host.selectById` inside the effects sits in `untracked()`.
|
|
902
|
+
* via `afterNextRender` and becomes a no-op. \
|
|
903
|
+
* Every `router.navigate` and `host.selectById` inside the effects sits in `untracked()`.
|
|
904
|
+
*
|
|
905
|
+
* ```html
|
|
906
|
+
* <!-- Default fragment mode: the active tab reflects to #tab=<id>, and a
|
|
907
|
+
* deep link like /account#tab=settings selects that tab on load. -->
|
|
908
|
+
* <cngx-tab-group cngxTabsFragmentSync>
|
|
909
|
+
* <div cngxTab id="overview" label="Overview"></div>
|
|
910
|
+
* <div cngxTab id="settings" label="Settings"></div>
|
|
911
|
+
* </cngx-tab-group>
|
|
912
|
+
*
|
|
913
|
+
* <!-- Query-param mode with a custom name -> ?section=settings -->
|
|
914
|
+
* <cngx-tab-group cngxTabsFragmentSync mode="queryParam" paramName="section">
|
|
915
|
+
* <!-- ...tabs... -->
|
|
916
|
+
* </cngx-tab-group>
|
|
917
|
+
* ```
|
|
737
918
|
*
|
|
738
919
|
* @category common/tabs
|
|
739
920
|
* @docsKind primary
|
|
@@ -843,8 +1024,8 @@ const cngxDefaultTabRoute = (handle) => [handle.id];
|
|
|
843
1024
|
* - `NavigationError` (guard/resolver threw) → `false`
|
|
844
1025
|
*
|
|
845
1026
|
* Routed tabs reuse the presenter's commit lifecycle verbatim - the
|
|
846
|
-
* router navigation is simply the async op.
|
|
847
|
-
* active tab follows the *resolved* route, so a cancelled guard keeps
|
|
1027
|
+
* router navigation is simply the async op. \
|
|
1028
|
+
* In pessimistic mode the active tab follows the *resolved* route, so a cancelled guard keeps
|
|
848
1029
|
* the old tab with zero extra gate machinery. The events subscription
|
|
849
1030
|
* is opened *before* `navigate(...)` so a synchronously-resolving
|
|
850
1031
|
* navigation cannot emit before the action is listening; the commit
|
|
@@ -881,8 +1062,8 @@ function createTabRouterCommit(opts) {
|
|
|
881
1062
|
}
|
|
882
1063
|
|
|
883
1064
|
/**
|
|
884
|
-
* Router-outlet integration for tab groups.
|
|
885
|
-
* `[cngxTabsRouteSync]` on the presenter element. Each tab is an
|
|
1065
|
+
* Router-outlet integration for tab groups. \
|
|
1066
|
+
* Opt-in via `[cngxTabsRouteSync]` on the presenter element. Each tab is an
|
|
886
1067
|
* Angular child route whose component renders into a `<router-outlet>`;
|
|
887
1068
|
* switching tabs navigates, and a `CanDeactivate` guard can gate the
|
|
888
1069
|
* leave.
|
|
@@ -904,12 +1085,69 @@ function createTabRouterCommit(opts) {
|
|
|
904
1085
|
* no-op. Mirrors {@link CngxTabsFragmentSync}; every `activeIndex`
|
|
905
1086
|
* write inside an effect sits in `untracked()`.
|
|
906
1087
|
*
|
|
1088
|
+
* **The mental model.** It turns the tab group into the router's view
|
|
1089
|
+
* switcher: the tabs choose *which child route* renders in the
|
|
1090
|
+
* `<router-outlet>`, not which inline template shows. \
|
|
1091
|
+
* Concretely, a Settings page with Profile / Security / Billing tabs then gets, for
|
|
1092
|
+
* free: each tab its own URL (`/settings/profile`) so a refresh or a
|
|
1093
|
+
* shared link stays on the tab; browser back/forward between tabs;
|
|
1094
|
+
* `Billing` lazy-loading its chunk only when first opened; and `Profile`
|
|
1095
|
+
* blocking the switch via a `CanDeactivate` guard while its form is
|
|
1096
|
+
* dirty - all while keeping the `role="tab"` keyboard and ARIA model.
|
|
1097
|
+
*
|
|
1098
|
+
* **Use it when** each tab's content is a real Angular route - a lazy
|
|
1099
|
+
* chunk, a resolver, or a `CanActivate` / `CanDeactivate` guard -
|
|
1100
|
+
* rendered into a `<router-outlet>`, and you want browser back/forward
|
|
1101
|
+
* and deep links to move between tabs while the route's own guard gates
|
|
1102
|
+
* the switch (e.g. an unsaved-changes prompt on leave). \
|
|
1103
|
+
* If the tabs are purely visual, use a plain `<cngx-tab-group>` with no sync directive;
|
|
1104
|
+
* if you only want the active tab reflected in the URL while content
|
|
1105
|
+
* stays inline, use {@link CngxTabsFragmentSync}.
|
|
1106
|
+
*
|
|
1107
|
+
* **What this is not.** \
|
|
1108
|
+
* Not a per-tab `routerLink`: \
|
|
1109
|
+
* the tabs stay `role="tab"` buttons and the directive drives `router.navigate`
|
|
1110
|
+
* centrally through the commit lifecycle, so there are no anchors, no
|
|
1111
|
+
* `href`, and no native open-in-new-tab / middle-click / copy-link. \
|
|
1112
|
+
* For real link semantics (right-click, ctrl-click) reach for the CNGX
|
|
1113
|
+
* `<cngx-tab-nav>` and `<a cngx-tab-link routerLink>` variant
|
|
1114
|
+
* instead. \
|
|
1115
|
+
* Not URL deep-linking either - that is {@link CngxTabsFragmentSync} (a `#tab=` fragment or `?tab=`
|
|
1116
|
+
* query-param); this directive renders child route *components* into a
|
|
1117
|
+
* `<router-outlet>`. \
|
|
1118
|
+
* And not optimistic: the active tab moves only once
|
|
1119
|
+
* the route resolves, so a `CanDeactivate` guard can cancel the switch.
|
|
1120
|
+
*
|
|
1121
|
+
* ```ts
|
|
1122
|
+
* // Each tab is a child route; the editor guards its own exit.
|
|
1123
|
+
* const ROUTES: Routes = [
|
|
1124
|
+
* { path: '', pathMatch: 'full', redirectTo: 'editor' },
|
|
1125
|
+
* { path: 'editor', component: EditorPage, canDeactivate: [unsavedChangesGuard] },
|
|
1126
|
+
* { path: 'preview', component: PreviewPage },
|
|
1127
|
+
* { path: 'settings', component: SettingsPage },
|
|
1128
|
+
* ];
|
|
1129
|
+
* ```
|
|
1130
|
+
*
|
|
1131
|
+
* ```html
|
|
1132
|
+
* <!-- Tab ids match the child segments (default routeFor = (h) => [h.id]).
|
|
1133
|
+
* Switching a tab navigates; the guard gates leaving the editor;
|
|
1134
|
+
* back/forward and /account/settings deep links move the active tab. -->
|
|
1135
|
+
* <cngx-tab-group cngxTabsRouteSync aria-label="Account">
|
|
1136
|
+
* <div cngxTab id="editor" label="Editor"></div>
|
|
1137
|
+
* <div cngxTab id="preview" label="Preview"></div>
|
|
1138
|
+
* <div cngxTab id="settings" label="Settings"></div>
|
|
1139
|
+
* </cngx-tab-group>
|
|
1140
|
+
*
|
|
1141
|
+
* <!-- The active tab's routed component renders here. -->
|
|
1142
|
+
* <router-outlet></router-outlet>
|
|
1143
|
+
* ```
|
|
1144
|
+
*
|
|
907
1145
|
* @category common/tabs
|
|
908
1146
|
* @docsKind primary
|
|
909
1147
|
* @wcag AA
|
|
910
1148
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/route-sync.directive.ts
|
|
911
1149
|
* @since 0.1.0
|
|
912
|
-
* @relatedTo CngxTabGroupPresenter, CngxTabsFragmentSync, createTabRouterCommit
|
|
1150
|
+
* @relatedTo CngxTabGroupPresenter, CngxTabsFragmentSync, createTabRouterCommit, CngxTabNav, CngxTabLink
|
|
913
1151
|
*/
|
|
914
1152
|
class CngxTabsRouteSync {
|
|
915
1153
|
/**
|
|
@@ -1039,8 +1277,8 @@ const TABS_CONFIG_DEFAULTS = {
|
|
|
1039
1277
|
templates: {},
|
|
1040
1278
|
};
|
|
1041
1279
|
/**
|
|
1042
|
-
* DI token for the resolved tabs config.
|
|
1043
|
-
* the library defaults; override via {@link provideTabsConfig}
|
|
1280
|
+
* DI token for the resolved tabs config. \
|
|
1281
|
+
* `providedIn: 'root'` with the library defaults; override via {@link provideTabsConfig}
|
|
1044
1282
|
* (root) or {@link provideTabsConfigAt} (component scope).
|
|
1045
1283
|
*
|
|
1046
1284
|
* @category common/tabs
|
|
@@ -1054,7 +1292,8 @@ const CNGX_TABS_CONFIG = new InjectionToken('CngxTabsConfig', {
|
|
|
1054
1292
|
});
|
|
1055
1293
|
/**
|
|
1056
1294
|
* Internal helper that brands a config-mutator function with the
|
|
1057
|
-
* `_target` discriminator.
|
|
1295
|
+
* `_target` discriminator. \
|
|
1296
|
+
* Every `with*` config feature returns one
|
|
1058
1297
|
* of these.
|
|
1059
1298
|
*
|
|
1060
1299
|
* @internal
|
|
@@ -1108,8 +1347,8 @@ function withTabsCommitMode(mode) {
|
|
|
1108
1347
|
}
|
|
1109
1348
|
/**
|
|
1110
1349
|
* Configure URL fragment / query-param deep-linking for the active tab
|
|
1111
|
-
* (the {@link CngxTabsFragmentSync} directive).
|
|
1112
|
-
* surface (URL fragment or query parameter); `param` names the key
|
|
1350
|
+
* (the {@link CngxTabsFragmentSync} directive). \
|
|
1351
|
+
* `mode` chooses the URL surface (URL fragment or query parameter); `param` names the key
|
|
1113
1352
|
* (default `'tab'`).
|
|
1114
1353
|
*
|
|
1115
1354
|
* Not to be confused with `[cngxTabsRouteSync]`, the router-outlet
|
|
@@ -1134,7 +1373,7 @@ function withTabsFragmentSync(mode, param = 'tab') {
|
|
|
1134
1373
|
*/
|
|
1135
1374
|
const withTabsRouterSync = withTabsFragmentSync;
|
|
1136
1375
|
/**
|
|
1137
|
-
* Select the app-wide default visual skin for `<cngx-tab-group>`.
|
|
1376
|
+
* Select the app-wide default visual skin for `<cngx-tab-group>`. \
|
|
1138
1377
|
* Default `'line'`. Per-instance `[skin]` Input still wins; this moves
|
|
1139
1378
|
* the cascade default. Structure, slots, ARIA, and keyboard behaviour
|
|
1140
1379
|
* are identical across skins - only the `[data-skin]` host attribute
|
|
@@ -1146,8 +1385,8 @@ function withTabsSkin(skin) {
|
|
|
1146
1385
|
return defineTabsConfigFeature((cfg) => ({ ...cfg, skin }));
|
|
1147
1386
|
}
|
|
1148
1387
|
/**
|
|
1149
|
-
* Set the app-wide default icon layout for `<cngx-tab-group>`.
|
|
1150
|
-
* `'start'`. Per-instance `[iconLayout]` Input still wins. Orthogonal to
|
|
1388
|
+
* Set the app-wide default icon layout for `<cngx-tab-group>`. \
|
|
1389
|
+
* Default`'start'`. Per-instance `[iconLayout]` Input still wins. Orthogonal to
|
|
1151
1390
|
* skin and orientation - only the `[data-icon-layout]` host attribute
|
|
1152
1391
|
* changes.
|
|
1153
1392
|
*
|
|
@@ -1157,7 +1396,7 @@ function withTabsIconLayout(layout) {
|
|
|
1157
1396
|
return defineTabsConfigFeature((cfg) => ({ ...cfg, iconLayout: layout }));
|
|
1158
1397
|
}
|
|
1159
1398
|
/**
|
|
1160
|
-
* Set the app-wide default panel render strategy for `<cngx-tab-group>`.
|
|
1399
|
+
* Set the app-wide default panel render strategy for `<cngx-tab-group>`. \
|
|
1161
1400
|
* Default `'eager'` (every panel's content rendered up front, toggled
|
|
1162
1401
|
* via `[hidden]`). `'lazy'` keep-alives content after first activation;
|
|
1163
1402
|
* `'lazy-destroy'` renders only the active panel's content. Per-instance
|
|
@@ -1171,7 +1410,8 @@ function withTabsPanelMode(mode) {
|
|
|
1171
1410
|
}
|
|
1172
1411
|
/**
|
|
1173
1412
|
* Set the app-wide default for stretching tabs to the full strip width
|
|
1174
|
-
* (horizontal only).
|
|
1413
|
+
* (horizontal only). \
|
|
1414
|
+
* Default `false`. Per-instance `[fitted]` Input still
|
|
1175
1415
|
* wins. No effect under `orientation="vertical"`.
|
|
1176
1416
|
*
|
|
1177
1417
|
* @category common/tabs
|
|
@@ -1180,7 +1420,7 @@ function withTabsFitted(fitted) {
|
|
|
1180
1420
|
return defineTabsConfigFeature((cfg) => ({ ...cfg, fitted }));
|
|
1181
1421
|
}
|
|
1182
1422
|
/**
|
|
1183
|
-
* Set the app-wide default tab-cluster alignment (horizontal only).
|
|
1423
|
+
* Set the app-wide default tab-cluster alignment (horizontal only). \
|
|
1184
1424
|
* Default `'start'`. Per-instance `[tabAlign]` Input still wins. Ignored
|
|
1185
1425
|
* under `orientation="vertical"` and when the group is `fitted`.
|
|
1186
1426
|
*
|
|
@@ -1190,7 +1430,7 @@ function withTabsAlign(align) {
|
|
|
1190
1430
|
return defineTabsConfigFeature((cfg) => ({ ...cfg, tabAlign: align }));
|
|
1191
1431
|
}
|
|
1192
1432
|
/**
|
|
1193
|
-
* Set the app-wide default for whether tabs render a close affordance.
|
|
1433
|
+
* Set the app-wide default for whether tabs render a close affordance. \
|
|
1194
1434
|
* Default `false`. Per-instance `[closable]` Input wins; a per-`CngxTab`
|
|
1195
1435
|
* `[closable]` override wins over both.
|
|
1196
1436
|
*
|
|
@@ -1201,7 +1441,8 @@ function withTabsClosable(closable) {
|
|
|
1201
1441
|
}
|
|
1202
1442
|
/**
|
|
1203
1443
|
* Set the app-wide default for whether the group renders an add-tab
|
|
1204
|
-
* button.
|
|
1444
|
+
* button. \
|
|
1445
|
+
* Default `false`. Per-instance `[addable]` Input wins.
|
|
1205
1446
|
*
|
|
1206
1447
|
* @category common/tabs
|
|
1207
1448
|
*/
|
|
@@ -1257,14 +1498,16 @@ function withTabOverflowMaxDeferMs(ms) {
|
|
|
1257
1498
|
}));
|
|
1258
1499
|
}
|
|
1259
1500
|
/**
|
|
1260
|
-
* App-wide override for the More-button label. Middle tier;
|
|
1501
|
+
* App-wide override for the More-button label. Middle tier; \
|
|
1261
1502
|
* per-instance `*cngxTabOverflowTrigger` still wins.
|
|
1262
1503
|
*
|
|
1263
1504
|
* ```ts
|
|
1264
|
-
*
|
|
1265
|
-
*
|
|
1505
|
+
* readonly moreTrigger = viewChild.required<TemplateRef<CngxTabOverflowTriggerContext>>(
|
|
1506
|
+
* 'moreTrigger',
|
|
1507
|
+
* { read: TemplateRef },
|
|
1508
|
+
* );
|
|
1266
1509
|
*
|
|
1267
|
-
* providers: [provideTabsConfig(withTabOverflowTriggerTemplate(this.moreTrigger))]
|
|
1510
|
+
* providers: [provideTabsConfig(withTabOverflowTriggerTemplate(this.moreTrigger()))]
|
|
1268
1511
|
* ```
|
|
1269
1512
|
*
|
|
1270
1513
|
* @category common/tabs
|
|
@@ -1276,7 +1519,7 @@ function withTabOverflowTriggerTemplate(template) {
|
|
|
1276
1519
|
}));
|
|
1277
1520
|
}
|
|
1278
1521
|
/**
|
|
1279
|
-
* App-wide override for each row inside the overflow popover.
|
|
1522
|
+
* App-wide override for each row inside the overflow popover. \
|
|
1280
1523
|
* Middle tier; per-instance `*cngxTabOverflowItem` still wins.
|
|
1281
1524
|
*
|
|
1282
1525
|
* @category common/tabs
|
|
@@ -1302,7 +1545,8 @@ function withTabErrorBadgeTemplate(template) {
|
|
|
1302
1545
|
}
|
|
1303
1546
|
/**
|
|
1304
1547
|
* App-wide override for the rejection-icon decoration. Middle
|
|
1305
|
-
* tier;
|
|
1548
|
+
* tier; \
|
|
1549
|
+
* per-instance `*cngxTabRejectionIcon` still wins. Sibling
|
|
1306
1550
|
* of {@link withStepRejectionTemplate}.
|
|
1307
1551
|
*
|
|
1308
1552
|
* @category common/tabs
|
|
@@ -1405,13 +1649,13 @@ function injectTabsConfig() {
|
|
|
1405
1649
|
}
|
|
1406
1650
|
|
|
1407
1651
|
/**
|
|
1408
|
-
*
|
|
1652
|
+
* Helper resolving the host-attribute cascades for
|
|
1409
1653
|
* `<cngx-tab-group>` (skin / iconLayout). Keeps the organism class
|
|
1410
1654
|
* under the LOC guard while making the cascade pattern reusable. Sibling
|
|
1411
1655
|
* shape to `createStepperHostAttrs`; the resolved-type unions differ per
|
|
1412
1656
|
* family, so the helpers are siblings, not shared code.
|
|
1413
1657
|
*
|
|
1414
|
-
* Each computed honors
|
|
1658
|
+
* Each computed honors the cascade:
|
|
1415
1659
|
* per-instance input wins over root config wins over library default. No
|
|
1416
1660
|
* manual sync. The library defaults (`'line'` / `'start'`) live here,
|
|
1417
1661
|
* not in `TABS_CONFIG_DEFAULTS` - mirroring the stepper.
|
|
@@ -1534,12 +1778,15 @@ function partitionFeatures(features) {
|
|
|
1534
1778
|
return { config, i18n };
|
|
1535
1779
|
}
|
|
1536
1780
|
/**
|
|
1537
|
-
* Unified aggregator for tabs configuration.
|
|
1538
|
-
* `_target` to {@link provideTabsConfig} and {@link provideTabsI18n}.
|
|
1539
|
-
* Sibling to
|
|
1540
|
-
*
|
|
1541
|
-
* `
|
|
1542
|
-
*
|
|
1781
|
+
* Unified aggregator for tabs configuration. \
|
|
1782
|
+
* Routes features by `_target` to {@link provideTabsConfig} and {@link provideTabsI18n}. \
|
|
1783
|
+
* Sibling to
|
|
1784
|
+
* - `provideCngxMenu` and
|
|
1785
|
+
* - `provideCngxSelect`;
|
|
1786
|
+
* apply once in the app providers array. \
|
|
1787
|
+
* Returns {@link EnvironmentProviders}; for
|
|
1788
|
+
* - `viewProviders` use {@link provideCngxTabsAt} — opaque
|
|
1789
|
+
* - `EnvironmentProviders` cannot live there.
|
|
1543
1790
|
*
|
|
1544
1791
|
* ```ts
|
|
1545
1792
|
* bootstrapApplication(AppComponent, {
|
|
@@ -1555,6 +1802,9 @@ function partitionFeatures(features) {
|
|
|
1555
1802
|
* ```
|
|
1556
1803
|
*
|
|
1557
1804
|
* @category common/tabs
|
|
1805
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/provide-cngx-tabs.ts
|
|
1806
|
+
* @since 0.1.0
|
|
1807
|
+
* @relatedTo CngxTabGroup, CngxTabsConfig, provideCngxTabsAt
|
|
1558
1808
|
*/
|
|
1559
1809
|
function provideCngxTabs(...features) {
|
|
1560
1810
|
const { config, i18n } = partitionFeatures(features);
|
|
@@ -1564,8 +1814,8 @@ function provideCngxTabs(...features) {
|
|
|
1564
1814
|
]);
|
|
1565
1815
|
}
|
|
1566
1816
|
/**
|
|
1567
|
-
* Component-scoped twin of {@link provideCngxTabs}.
|
|
1568
|
-
* `Provider[]` for `viewProviders`/`providers`; same dispatch
|
|
1817
|
+
* Component-scoped twin of {@link provideCngxTabs}. \
|
|
1818
|
+
* Returns `Provider[]` for `viewProviders`/`providers`; same dispatch
|
|
1569
1819
|
* semantics, different scope.
|
|
1570
1820
|
*
|
|
1571
1821
|
* ```ts
|
|
@@ -1580,6 +1830,9 @@ function provideCngxTabs(...features) {
|
|
|
1580
1830
|
* ```
|
|
1581
1831
|
*
|
|
1582
1832
|
* @category common/tabs
|
|
1833
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/provide-cngx-tabs.ts
|
|
1834
|
+
* @since 0.1.0
|
|
1835
|
+
* @relatedTo CngxTabGroup, CngxTabsConfig, provideCngxTabs
|
|
1583
1836
|
*/
|
|
1584
1837
|
function provideCngxTabsAt(...features) {
|
|
1585
1838
|
const { config, i18n } = partitionFeatures(features);
|
|
@@ -1590,7 +1843,7 @@ function provideCngxTabsAt(...features) {
|
|
|
1590
1843
|
}
|
|
1591
1844
|
|
|
1592
1845
|
/**
|
|
1593
|
-
* Default adapter for the cngx-native `<cngx-tab-group>` strip:
|
|
1846
|
+
* Default adapter for the cngx-native `<cngx-tab-group>` strip: \
|
|
1594
1847
|
* walks `host.closest('.cngx-tabs__strip-wrapper')` for the IO root,
|
|
1595
1848
|
* then `[id="${handle.id}-header"]` for each button.
|
|
1596
1849
|
*
|
|
@@ -1608,7 +1861,7 @@ function createCngxTabOverflowDefaultDomAdapter() {
|
|
|
1608
1861
|
};
|
|
1609
1862
|
}
|
|
1610
1863
|
/**
|
|
1611
|
-
* DI token for the overflow molecule's DOM-resolution strategy.
|
|
1864
|
+
* DI token for the overflow molecule's DOM-resolution strategy. \
|
|
1612
1865
|
* Override at directive `providers` or component `viewProviders` to
|
|
1613
1866
|
* swap in a Material, custom-skin, or test-double adapter without
|
|
1614
1867
|
* forking the molecule. Defaults to
|
|
@@ -1625,9 +1878,12 @@ const CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY = new InjectionToken('CngxTabOverflo
|
|
|
1625
1878
|
|
|
1626
1879
|
/**
|
|
1627
1880
|
* Bounded retry loop for DOM-anchoring patterns - shared
|
|
1628
|
-
* attempt-counter
|
|
1881
|
+
* attempt-counter and give-up and cancellation contract. \
|
|
1882
|
+
* Used by
|
|
1629
1883
|
* `<cngx-tab-overflow>`'s rAF strip-attach loop and `[cngxMatTabs]`'s
|
|
1630
|
-
* `afterNextRender` header-anchor loop.
|
|
1884
|
+
* `afterNextRender` header-anchor loop.
|
|
1885
|
+
*
|
|
1886
|
+
* Consumer-supplied scheduler
|
|
1631
1887
|
* lets different timing primitives flow through one counter.
|
|
1632
1888
|
*
|
|
1633
1889
|
* ```ts
|
|
@@ -1669,7 +1925,8 @@ function createDomAnchorRetry(options) {
|
|
|
1669
1925
|
// Swallow + terminal stop - covers the test-runner teardown
|
|
1670
1926
|
// race where a global (e.g. IntersectionObserver) is reset
|
|
1671
1927
|
// between schedule and fire, before consumer DestroyRef can
|
|
1672
|
-
// call cancel().
|
|
1928
|
+
// call cancel().
|
|
1929
|
+
// Production callback bugs still surface via
|
|
1673
1930
|
// their own console.error before they throw here.
|
|
1674
1931
|
stopped = true;
|
|
1675
1932
|
return;
|
|
@@ -1700,15 +1957,16 @@ function createDomAnchorRetry(options) {
|
|
|
1700
1957
|
};
|
|
1701
1958
|
}
|
|
1702
1959
|
/**
|
|
1703
|
-
* DI token for the DOM-anchor retry policy.
|
|
1704
|
-
* {@link createDomAnchorRetry}. Two real consumers today -
|
|
1960
|
+
* DI token for the DOM-anchor retry policy. \
|
|
1961
|
+
* Default {@link createDomAnchorRetry}. Two real consumers today -
|
|
1705
1962
|
* `<cngx-tab-overflow>`'s rAF strip-attach loop and
|
|
1706
1963
|
* `[cngxMatTabs]`'s `afterNextRender` header-anchor loop. Override
|
|
1707
1964
|
* via `providers` / `viewProviders` for retry-with-backoff,
|
|
1708
|
-
* telemetry on give-up, etc.
|
|
1709
|
-
*
|
|
1710
|
-
* `
|
|
1711
|
-
* `
|
|
1965
|
+
* telemetry on give-up, etc. \
|
|
1966
|
+
* Symmetric to
|
|
1967
|
+
* - `CNGX_OVERFLOW_POPOVER_HIGHLIGHT_FACTORY`,
|
|
1968
|
+
* - `CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY`, and
|
|
1969
|
+
* - `CNGX_TABS_COMMIT_HANDLER_FACTORY`.
|
|
1712
1970
|
*
|
|
1713
1971
|
* @category common/tabs/overflow
|
|
1714
1972
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/overflow/dom-anchor-retry.ts
|
|
@@ -1810,9 +2068,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1810
2068
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-error-badge.directive.ts
|
|
1811
2069
|
* @since 0.1.0
|
|
1812
2070
|
* @relatedTo CngxTabRejectionIcon, CngxTabBusySpinner, CngxTab
|
|
1813
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/custom-busy-spinner-via-code-cngxtabbusyspinner-code</example-url>
|
|
1814
2071
|
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/custom-error-badge-via-code-cngxtaberrorbadge-code</example-url>
|
|
1815
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/rejection-decoration-via-code-cngxtabrejectionicon-code</example-url>
|
|
1816
2072
|
*/
|
|
1817
2073
|
class CngxTabErrorBadge {
|
|
1818
2074
|
templateRef = inject(TemplateRef);
|
|
@@ -1854,8 +2110,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1854
2110
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-rejection-icon.directive.ts
|
|
1855
2111
|
* @since 0.1.0
|
|
1856
2112
|
* @relatedTo CngxTabErrorBadge, CngxTabBusySpinner, CngxTab
|
|
1857
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/custom-busy-spinner-via-code-cngxtabbusyspinner-code</example-url>
|
|
1858
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/custom-error-badge-via-code-cngxtaberrorbadge-code</example-url>
|
|
1859
2113
|
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/rejection-decoration-via-code-cngxtabrejectionicon-code</example-url>
|
|
1860
2114
|
*/
|
|
1861
2115
|
class CngxTabRejectionIcon {
|
|
@@ -1891,8 +2145,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1891
2145
|
* @since 0.1.0
|
|
1892
2146
|
* @relatedTo CngxTabErrorBadge, CngxTabRejectionIcon, CngxTab
|
|
1893
2147
|
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/custom-busy-spinner-via-code-cngxtabbusyspinner-code</example-url>
|
|
1894
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/custom-error-badge-via-code-cngxtaberrorbadge-code</example-url>
|
|
1895
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/rejection-decoration-via-code-cngxtabrejectionicon-code</example-url>
|
|
1896
2148
|
*/
|
|
1897
2149
|
class CngxTabBusySpinner {
|
|
1898
2150
|
templateRef = inject(TemplateRef);
|
|
@@ -1909,17 +2161,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1909
2161
|
}] });
|
|
1910
2162
|
|
|
1911
2163
|
/**
|
|
1912
|
-
* Structural slot for the tab-icon template.
|
|
1913
|
-
* per-tab context (stepper-slot parity), not a per-`CngxTab` input
|
|
1914
|
-
* 3-stage cascade:
|
|
1915
|
-
* `CNGX_TABS_CONFIG.templates.icon` > none (no icon rendered).
|
|
2164
|
+
* Structural slot for the tab-icon template. \
|
|
2165
|
+
* One group-level slot with per-tab context (stepper-slot parity), not a per-`CngxTab` input.\
|
|
2166
|
+
* 3-stage cascade:
|
|
2167
|
+
* per-instance directive > `CNGX_TABS_CONFIG.templates.icon` > none (no icon rendered).
|
|
1916
2168
|
*
|
|
1917
2169
|
* ```html
|
|
1918
|
-
* <
|
|
1919
|
-
* <
|
|
1920
|
-
*
|
|
1921
|
-
* </ng-template>
|
|
1922
|
-
* </cngx-tab-group>
|
|
2170
|
+
* <ng-template cngxTabIcon let-active="active">
|
|
2171
|
+
* <cngx-icon [name]="active ? 'folder-open' : 'folder'" />
|
|
2172
|
+
* </ng-template>
|
|
1923
2173
|
* ```
|
|
1924
2174
|
*
|
|
1925
2175
|
* @category common/tabs/slots
|
|
@@ -1927,6 +2177,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1927
2177
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-icon.directive.ts
|
|
1928
2178
|
* @since 0.1.0
|
|
1929
2179
|
* @relatedTo CngxTabErrorBadge, CngxTab, CngxTabGroup
|
|
2180
|
+
* <example-url>http://localhost:4200/#/ui/tabs/tab-icons/icon-end</example-url>
|
|
2181
|
+
* <example-url>http://localhost:4200/#/ui/tabs/tab-icons/icon-only</example-url>
|
|
2182
|
+
* <example-url>http://localhost:4200/#/ui/tabs/tab-icons/icon-start</example-url>
|
|
2183
|
+
* <example-url>http://localhost:4200/#/ui/tabs/tab-icons/icon-top</example-url>
|
|
2184
|
+
* <example-url>http://localhost:4200/#/ui/tabs/tab-icons/icon-vertical-sidebar</example-url>
|
|
1930
2185
|
*/
|
|
1931
2186
|
class CngxTabIcon {
|
|
1932
2187
|
templateRef = inject(TemplateRef);
|
|
@@ -1959,6 +2214,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1959
2214
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-close-icon.directive.ts
|
|
1960
2215
|
* @since 0.1.0
|
|
1961
2216
|
* @relatedTo CngxTabAddIcon, CngxTabGroup
|
|
2217
|
+
* <example-url>http://localhost:4200/#/ui/tabs/tab-dismissable/dismissable-and-addable</example-url>
|
|
1962
2218
|
*/
|
|
1963
2219
|
class CngxTabCloseIcon {
|
|
1964
2220
|
templateRef = inject(TemplateRef);
|
|
@@ -1992,6 +2248,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1992
2248
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-add-icon.directive.ts
|
|
1993
2249
|
* @since 0.1.0
|
|
1994
2250
|
* @relatedTo CngxTabCloseIcon, CngxTabGroup
|
|
2251
|
+
* <example-url>http://localhost:4200/#/ui/tabs/tab-dismissable/dismissable-and-addable</example-url>
|
|
2252
|
+
* <example-url>http://localhost:4200/#/ui/tabs/tab-group/addable-tabs</example-url>
|
|
1995
2253
|
*/
|
|
1996
2254
|
class CngxTabAddIcon {
|
|
1997
2255
|
templateRef = inject(TemplateRef);
|
|
@@ -2008,15 +2266,43 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2008
2266
|
}] });
|
|
2009
2267
|
|
|
2010
2268
|
/**
|
|
2011
|
-
*
|
|
2012
|
-
* `<cngx-tab-group>`.
|
|
2013
|
-
*
|
|
2014
|
-
*
|
|
2269
|
+
* Helper resolving the dismissable/addable affordances for
|
|
2270
|
+
* `<cngx-tab-group>`. \
|
|
2271
|
+
* Keeps the close/add cascade + interaction off the
|
|
2272
|
+
* organism class (LOC guard). \
|
|
2273
|
+
* Each cascade is one `computed()`.
|
|
2274
|
+
* The actual tab removal is the consumer's -
|
|
2015
2275
|
* `handleClose` only routes through the presenter's `requestClose`, which
|
|
2016
2276
|
* moves the active index, and restores focus once the consumer's removal
|
|
2017
2277
|
* has rendered.
|
|
2018
2278
|
*
|
|
2279
|
+
* ```ts
|
|
2280
|
+
* // The organism builds it once from field-init; the template reads it.
|
|
2281
|
+
* protected readonly dismiss = createTabDismissals({
|
|
2282
|
+
* host: this.host, // CNGX_TAB_GROUP_HOST
|
|
2283
|
+
* config: this.config, // injectTabsConfig()
|
|
2284
|
+
* i18n: this.i18n, // injectTabsI18n()
|
|
2285
|
+
* closable: this.closable, // input<boolean | undefined>('closable')
|
|
2286
|
+
* addable: this.addable, // input<boolean | undefined>('addable')
|
|
2287
|
+
* hostElement: this.hostElement,
|
|
2288
|
+
* injector: this.injector,
|
|
2289
|
+
* });
|
|
2290
|
+
*
|
|
2291
|
+
* // Per-tab close affordance, read from the header template:
|
|
2292
|
+
* dismiss.isTabClosable(tab); // per-tab override > group resolution
|
|
2293
|
+
* dismiss.closeButtonLabel(tab); // i18n accessible name for the close button
|
|
2294
|
+
* dismiss.handleClose(tab, clickEvent); // routes through presenter.requestClose, restores focus
|
|
2295
|
+
* dismiss.handleTabKeydown(tab, keyEvent); // Delete on a focused closable tab closes it (APG)
|
|
2296
|
+
*
|
|
2297
|
+
* // Group-level add affordance:
|
|
2298
|
+
* dismiss.resolvedAddable(); // input ?? config ?? false
|
|
2299
|
+
* dismiss.handleAdd(); // routes through presenter.requestAdd
|
|
2300
|
+
* ```
|
|
2301
|
+
*
|
|
2019
2302
|
* @category common/tabs
|
|
2303
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/dismissals/tab-dismissals.ts
|
|
2304
|
+
* @since 0.1.0
|
|
2305
|
+
* @relatedTo CngxTabGroup, CngxTabCloseIcon, CngxTabAddIcon
|
|
2020
2306
|
*/
|
|
2021
2307
|
function createTabDismissals(opts) {
|
|
2022
2308
|
const resolvedClosable = computed(() => opts.closable() ?? opts.config.closable ?? false, ...(ngDevMode ? [{ debugName: "resolvedClosable" }] : /* istanbul ignore next */ []));
|
|
@@ -2088,6 +2374,9 @@ function createTabDismissals(opts) {
|
|
|
2088
2374
|
* active index is the correct origin.
|
|
2089
2375
|
*
|
|
2090
2376
|
* @category common/tabs
|
|
2377
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/keyboard/tab-keyboard-nav.ts
|
|
2378
|
+
* @since 0.1.0
|
|
2379
|
+
* @relatedTo CngxTabGroupPresenter, CngxTabGroup, createTabGroupAnnouncements
|
|
2091
2380
|
*/
|
|
2092
2381
|
function createTabKeyboardNav(opts) {
|
|
2093
2382
|
const clampedActive = () => {
|
|
@@ -2215,23 +2504,29 @@ function createTabKeyboardNav(opts) {
|
|
|
2215
2504
|
* Material owns the rendered tab-button chrome via its own MDC
|
|
2216
2505
|
* template, leaving no DOM seam. See `tabs-accepted-debt §9`.
|
|
2217
2506
|
*
|
|
2507
|
+
* **UX / a11y**
|
|
2508
|
+
* - The cascade is presentation-only; the accessibility contract is
|
|
2509
|
+
* invariant under it. Overriding a slot never strips its accessible
|
|
2510
|
+
* default (fallthrough to a built-in or the organism default).
|
|
2511
|
+
* - The screen-reader channel (descriptor / `aria-busy` / live region)
|
|
2512
|
+
* lives on the organism, not the slot template, so swapping a decoration
|
|
2513
|
+
* template changes only the visual.
|
|
2514
|
+
* - An unbound `icon` slot resolves to nothing, which is correct - the
|
|
2515
|
+
* icon is decorative and the label carries the accessible name.
|
|
2516
|
+
*
|
|
2218
2517
|
* @category common/tabs/slots
|
|
2518
|
+
* @wcag AA
|
|
2519
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-group-template-cascade.ts
|
|
2520
|
+
* @since 0.1.0
|
|
2521
|
+
* @relatedTo CngxTabGroup, CngxTabErrorBadge, CngxTabBusySpinner, CngxTabRejectionIcon
|
|
2219
2522
|
*/
|
|
2220
2523
|
function createTabGroupTemplateBindings(opts) {
|
|
2221
2524
|
return {
|
|
2222
|
-
errorBadge: computed(() => opts.errorBadgeSlot()?.templateRef ??
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
rejectionIcon: computed(() => opts.rejectionIconSlot()?.templateRef ??
|
|
2226
|
-
opts.config.templates?.rejectionIcon ??
|
|
2227
|
-
null),
|
|
2228
|
-
busySpinner: computed(() => opts.busySpinnerSlot()?.templateRef ??
|
|
2229
|
-
opts.config.templates?.busySpinner ??
|
|
2230
|
-
null),
|
|
2525
|
+
errorBadge: computed(() => opts.errorBadgeSlot()?.templateRef ?? opts.config.templates?.errorBadge ?? null),
|
|
2526
|
+
rejectionIcon: computed(() => opts.rejectionIconSlot()?.templateRef ?? opts.config.templates?.rejectionIcon ?? null),
|
|
2527
|
+
busySpinner: computed(() => opts.busySpinnerSlot()?.templateRef ?? opts.config.templates?.busySpinner ?? null),
|
|
2231
2528
|
icon: computed(() => opts.iconSlot()?.templateRef ?? opts.config.templates?.icon ?? null),
|
|
2232
|
-
closeIcon: computed(() => opts.closeIconSlot?.()?.templateRef ??
|
|
2233
|
-
opts.config.templates?.closeIcon ??
|
|
2234
|
-
null),
|
|
2529
|
+
closeIcon: computed(() => opts.closeIconSlot?.()?.templateRef ?? opts.config.templates?.closeIcon ?? null),
|
|
2235
2530
|
addIcon: computed(() => opts.addIconSlot?.()?.templateRef ?? opts.config.templates?.addIcon ?? null),
|
|
2236
2531
|
};
|
|
2237
2532
|
}
|
|
@@ -2246,7 +2541,29 @@ function createTabGroupTemplateBindings(opts) {
|
|
|
2246
2541
|
* lazy by `linkedSignal` semantics, so the organism reads
|
|
2247
2542
|
* `liveAnnouncement` once at construction to seed it.
|
|
2248
2543
|
*
|
|
2544
|
+
* **UX / a11y**
|
|
2545
|
+
* - The live region is declarative, never imperative: `liveAnnouncement`
|
|
2546
|
+
* is a signal the polite region renders, empty between transitions so
|
|
2547
|
+
* AT stays silent on no-op ticks.
|
|
2548
|
+
* - Direction is spoken on every change: a move carries a previous/next
|
|
2549
|
+
* prefix plus the landing tab; a rollback announces the safe-harbour tab
|
|
2550
|
+
* or a retry, so the outcome is never silent.
|
|
2551
|
+
* - Accessible names carry position ("Tab 2 of 5: Settings") so AT does
|
|
2552
|
+
* not infer it from tablist enumeration.
|
|
2553
|
+
* - Role descriptions stay distinct from the label: the tablist
|
|
2554
|
+
* `aria-roledescription` is separate from the region `aria-label`, so AT
|
|
2555
|
+
* never reads the same word twice.
|
|
2556
|
+
* - `aria-label` and `aria-labelledby` stay mutually exclusive
|
|
2557
|
+
* (`resolvedAriaLabel` returns `null` when labelledby is bound).
|
|
2558
|
+
* - The per-tab descriptor is ARIA-by-value: the `cngx-sr-only` span is
|
|
2559
|
+
* always in the DOM; `statusPhrase` only fills its content, keeping the
|
|
2560
|
+
* `aria-describedby` reference stable.
|
|
2561
|
+
*
|
|
2249
2562
|
* @category common/tabs/announcements
|
|
2563
|
+
* @wcag AA
|
|
2564
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/announcements/tab-group-announcements.ts
|
|
2565
|
+
* @since 0.1.0
|
|
2566
|
+
* @relatedTo CngxTabGroup, CngxLiveRegion, createTabKeyboardNav
|
|
2250
2567
|
*/
|
|
2251
2568
|
function createTabGroupAnnouncements(options) {
|
|
2252
2569
|
const { presenter, i18n, config, ariaLabel, ariaLabelledBy } = options;
|
|
@@ -2365,7 +2682,7 @@ const CNGX_TABS_GLYPHS = {
|
|
|
2365
2682
|
};
|
|
2366
2683
|
|
|
2367
2684
|
/**
|
|
2368
|
-
* DOM `id` for a hidden-tab option row in the overflow listbox.
|
|
2685
|
+
* DOM `id` for a hidden-tab option row in the overflow listbox. \
|
|
2369
2686
|
* Stable across CD passes so `aria-activedescendant` resolves to
|
|
2370
2687
|
* the same `<li>`. `-overflow-option` suffix avoids collision with
|
|
2371
2688
|
* the strip-button (`-header`) and per-tab descriptor (`-desc`).
|
|
@@ -2410,9 +2727,9 @@ function adItemsEqual(a, b) {
|
|
|
2410
2727
|
}
|
|
2411
2728
|
/**
|
|
2412
2729
|
* Wires the 3-stage template cascade for the overflow molecule's
|
|
2413
|
-
* two visible regions:
|
|
2414
|
-
* `CNGX_TABS_CONFIG.templates.overflow*` > built-in markup
|
|
2415
|
-
* (template-outlet returns `null`).
|
|
2730
|
+
* two visible regions: \
|
|
2731
|
+
* per-instance directive > `CNGX_TABS_CONFIG.templates.overflow*` > built-in markup
|
|
2732
|
+
* (template-outlet returns `null`). \
|
|
2416
2733
|
*
|
|
2417
2734
|
* Pure - no DI, no side effects, no destroy hooks. Safe to call
|
|
2418
2735
|
* from a component's field-init block. Mirrors the select-family
|
|
@@ -2460,16 +2777,28 @@ function createTabOverflowTemplateBindings(opts) {
|
|
|
2460
2777
|
};
|
|
2461
2778
|
}
|
|
2462
2779
|
/**
|
|
2463
|
-
* Resets the AD highlight on popover close.
|
|
2780
|
+
* Resets the AD highlight on popover close. \
|
|
2781
|
+
* Keyboard-open paths
|
|
2464
2782
|
* (ArrowDown / End / typeahead on the closed trigger) set
|
|
2465
2783
|
* `activeIndex` via AD's own keydown listener before opening -
|
|
2466
2784
|
* unaffected. Mouse-open leaves `activeIndex === -1` so the popover
|
|
2467
|
-
* renders unhighlighted.
|
|
2785
|
+
* renders unhighlighted. \
|
|
2786
|
+
* Without this reset, the next open would
|
|
2468
2787
|
* inherit a stale index from the prior keyboard session.
|
|
2469
2788
|
*
|
|
2470
|
-
* Must run in injection context
|
|
2789
|
+
* **Must run in injection context.**
|
|
2790
|
+
*
|
|
2791
|
+
* ### UX / a11y
|
|
2792
|
+
* - Closing the popover resets the highlight, so a keyboard session never
|
|
2793
|
+
* leaves a stale `aria-activedescendant` for the next open.
|
|
2794
|
+
* - Each row has a stable descendant id (`tabOverflowOptionId`), so the SR
|
|
2795
|
+
* focus reference never dangles across re-renders.
|
|
2796
|
+
* - Highlight is virtual focus, not DOM focus: keyboard nav moves
|
|
2797
|
+
* `aria-activedescendant` while real focus stays on the trigger (APG
|
|
2798
|
+
* menu-button); the rows are never tab stops.
|
|
2471
2799
|
*
|
|
2472
2800
|
* @category common/tabs/overflow
|
|
2801
|
+
* @wcag AA
|
|
2473
2802
|
*/
|
|
2474
2803
|
function createOverflowPopoverHighlightSync(popover, ad) {
|
|
2475
2804
|
effect(() => {
|
|
@@ -2482,12 +2811,13 @@ function createOverflowPopoverHighlightSync(popover, ad) {
|
|
|
2482
2811
|
});
|
|
2483
2812
|
}
|
|
2484
2813
|
/**
|
|
2485
|
-
* DI token for the overflow popover highlight-sync policy.
|
|
2814
|
+
* DI token for the overflow popover highlight-sync policy. \
|
|
2486
2815
|
* Default {@link createOverflowPopoverHighlightSync}. Override via
|
|
2487
2816
|
* `providers` / `viewProviders` for last-index preservation,
|
|
2488
|
-
* telemetry on close, custom highlight rules.
|
|
2489
|
-
*
|
|
2490
|
-
* `
|
|
2817
|
+
* telemetry on close, custom highlight rules. \
|
|
2818
|
+
* Symmetric to
|
|
2819
|
+
* - `CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY` and
|
|
2820
|
+
* - `CNGX_TABS_COMMIT_HANDLER_FACTORY`.
|
|
2491
2821
|
*
|
|
2492
2822
|
* @category common/tabs/overflow
|
|
2493
2823
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/overflow/overflow-template-cascade.ts
|
|
@@ -2505,13 +2835,41 @@ const DEFAULT_SCROLL_OPTIONS = {
|
|
|
2505
2835
|
};
|
|
2506
2836
|
/**
|
|
2507
2837
|
* Scroll-into-view effect for any strip-based organism (tabs,
|
|
2508
|
-
* stepper headers, future scrolling lists).
|
|
2509
|
-
* scrolls the matching `[id="<itemId>-header"]` into view.
|
|
2838
|
+
* stepper headers, future scrolling lists). \
|
|
2839
|
+
* Tracks `activeId` and scrolls the matching `[id="<itemId>-header"]` into view.
|
|
2510
2840
|
*
|
|
2511
|
-
* The DOM call sits in `untracked()` (only `activeId` is tracked).
|
|
2841
|
+
* The DOM call sits in `untracked()` (only `activeId` is tracked). \
|
|
2512
2842
|
* `scrollIntoView` is missing in jsdom - guarded with optional chain.
|
|
2513
2843
|
*
|
|
2844
|
+
* ### UX / a11y
|
|
2845
|
+
* - The active tab is never stranded off-screen: when activation moves to
|
|
2846
|
+
* a tab clipped by overflow (keyboard arrow, deep link, programmatic
|
|
2847
|
+
* select), its header scrolls into view, so the focused and selected
|
|
2848
|
+
* tab is always visible (WCAG 2.4.7 Focus Visible).
|
|
2849
|
+
* - Pairs with the overflow surface: picking a hidden tab from the "More"
|
|
2850
|
+
* popover scrolls it back into the strip, and the overflow recompute
|
|
2851
|
+
* then self-trims - keyboard navigation and the overflow list stay in
|
|
2852
|
+
* sync.
|
|
2853
|
+
* - Motion is overridable for reduced motion: the default is smooth-center
|
|
2854
|
+
* along the inline axis; pass `scrollOptions` (e.g. `behavior: 'auto'`)
|
|
2855
|
+
* to honour `prefers-reduced-motion` or to scroll vertically.
|
|
2856
|
+
*
|
|
2857
|
+
* ```ts
|
|
2858
|
+
* // Install once from the organism's field-init (needs an injection context).
|
|
2859
|
+
* createOrganismScrollSync({
|
|
2860
|
+
* activeId: this.presenter.activeId, // Signal<string | null>
|
|
2861
|
+
* hostElement: this.hostElement, // holds the [id="<tabId>-header"] buttons
|
|
2862
|
+
* injector: this.injector,
|
|
2863
|
+
* // scrollOptions omitted -> smooth-center; override for reduced motion:
|
|
2864
|
+
* // scrollOptions: { behavior: 'auto' },
|
|
2865
|
+
* });
|
|
2866
|
+
* ```
|
|
2867
|
+
*
|
|
2514
2868
|
* @category common/tabs/scroll-sync
|
|
2869
|
+
* @wcag AA
|
|
2870
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/scroll-sync/organism-scroll-sync.ts
|
|
2871
|
+
* @since 0.1.0
|
|
2872
|
+
* @relatedTo CngxTabGroup, CngxTabOverflow, CNGX_ORGANISM_SCROLL_SYNC_FACTORY
|
|
2515
2873
|
*/
|
|
2516
2874
|
function createOrganismScrollSync(opts) {
|
|
2517
2875
|
const { activeId, hostElement, scrollOptions, injector } = opts;
|
|
@@ -2530,15 +2888,37 @@ function createOrganismScrollSync(opts) {
|
|
|
2530
2888
|
});
|
|
2531
2889
|
}
|
|
2532
2890
|
/**
|
|
2533
|
-
* DI token for the active-item scroll-into-view policy.
|
|
2534
|
-
* {@link createOrganismScrollSync}
|
|
2535
|
-
*
|
|
2536
|
-
*
|
|
2537
|
-
*
|
|
2891
|
+
* DI token for the active-item scroll-into-view policy. \
|
|
2892
|
+
* The default, {@link createOrganismScrollSync}, scrolls the active tab's header into
|
|
2893
|
+
* view on every `activeId` change. \
|
|
2894
|
+
* Override the whole policy to swap the
|
|
2895
|
+
* scroll behaviour, target a different selector, add telemetry, opt out
|
|
2896
|
+
* of motion, or disable it entirely.
|
|
2897
|
+
*
|
|
2898
|
+
* Provided in root with the default factory, so consumers override only
|
|
2899
|
+
* when they need to. \
|
|
2900
|
+
*
|
|
2901
|
+
* Sibling to
|
|
2902
|
+
* - `CNGX_DOM_ANCHOR_RETRY_FACTORY` and
|
|
2903
|
+
* - `CNGX_OVERFLOW_POPOVER_HIGHLIGHT_FACTORY`.
|
|
2904
|
+
*
|
|
2905
|
+
* ```ts
|
|
2906
|
+
* // Honour prefers-reduced-motion app-wide:
|
|
2907
|
+
* providers: [
|
|
2908
|
+
* {
|
|
2909
|
+
* provide: CNGX_ORGANISM_SCROLL_SYNC_FACTORY,
|
|
2910
|
+
* useValue: (opts) =>
|
|
2911
|
+
* createOrganismScrollSync({ ...opts, scrollOptions: { behavior: 'auto' } }),
|
|
2912
|
+
* },
|
|
2913
|
+
* ];
|
|
2914
|
+
* // Or disable scroll-into-view entirely: useValue: () => {}
|
|
2915
|
+
* ```
|
|
2538
2916
|
*
|
|
2539
2917
|
* @category common/tabs/scroll-sync
|
|
2918
|
+
* @wcag AA
|
|
2540
2919
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/scroll-sync/organism-scroll-sync.ts
|
|
2541
2920
|
* @since 0.1.0
|
|
2921
|
+
* @relatedTo createOrganismScrollSync, CngxOrganismScrollSyncFactory
|
|
2542
2922
|
*/
|
|
2543
2923
|
const CNGX_ORGANISM_SCROLL_SYNC_FACTORY = new InjectionToken('CngxOrganismScrollSyncFactory', {
|
|
2544
2924
|
providedIn: 'root',
|
|
@@ -2583,11 +2963,12 @@ function createDirectiveByIdMap(opts) {
|
|
|
2583
2963
|
}, { equal: directiveMapEqual });
|
|
2584
2964
|
}
|
|
2585
2965
|
/**
|
|
2586
|
-
* DI token for the per-id directive-resolution policy.
|
|
2587
|
-
* {@link createDirectiveByIdMap}. Override for WeakMap resolution,
|
|
2588
|
-
* telemetry, or custom equality.
|
|
2589
|
-
*
|
|
2590
|
-
* `
|
|
2966
|
+
* DI token for the per-id directive-resolution policy. \
|
|
2967
|
+
* Defaults to {@link createDirectiveByIdMap}. Override for WeakMap resolution,
|
|
2968
|
+
* telemetry, or custom equality. \
|
|
2969
|
+
* Sibling to
|
|
2970
|
+
* - `CNGX_DOM_ANCHOR_RETRY_FACTORY` and
|
|
2971
|
+
* - `CNGX_ORGANISM_SCROLL_SYNC_FACTORY`.
|
|
2591
2972
|
*
|
|
2592
2973
|
* @category common/tabs/registry
|
|
2593
2974
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/registry/directive-by-id-map.ts
|
|
@@ -2606,5 +2987,5 @@ const CNGX_DIRECTIVE_BY_ID_MAP_FACTORY = new InjectionToken('CngxDirectiveByIdMa
|
|
|
2606
2987
|
* Generated bundle index. Do not edit.
|
|
2607
2988
|
*/
|
|
2608
2989
|
|
|
2609
|
-
export { CNGX_DIRECTIVE_BY_ID_MAP_FACTORY, CNGX_DOM_ANCHOR_RETRY_FACTORY, CNGX_ORGANISM_SCROLL_SYNC_FACTORY, CNGX_OVERFLOW_POPOVER_HIGHLIGHT_FACTORY, CNGX_TABS_COMMIT_ACTION, CNGX_TABS_COMMIT_HANDLER_FACTORY, CNGX_TABS_CONFIG, CNGX_TABS_GLYPHS, CNGX_TABS_I18N, CNGX_TAB_GROUP_HOST, CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY, CNGX_TAB_PANEL_HOST, CngxTab, CngxTabAddIcon, CngxTabBusySpinner, CngxTabCloseIcon, CngxTabContent, CngxTabErrorBadge, CngxTabGroupPresenter, CngxTabIcon, CngxTabLabel, CngxTabOverflowItem, CngxTabOverflowTrigger, CngxTabRejectionIcon, CngxTabSubLabel, CngxTabsFragmentSync, CngxTabsRouteSync, createCngxTabOverflowDefaultDomAdapter, createDirectiveByIdMap, createDomAnchorRetry, createOrganismScrollSync, createOverflowPopoverHighlightSync, createTabDismissals, createTabGroupAnnouncements, createTabGroupTemplateBindings, createTabKeyboardNav, createTabOverflowTemplateBindings, createTabRouterCommit, createTabsCommitHandler, createTabsHostAttrs, injectTabsConfig, injectTabsI18n, provideCngxTabs, provideCngxTabsAt, provideTabsConfig, provideTabsConfigAt, provideTabsI18n, tabOverflowOptionId, withDefaultOrientation, withTabAddIconTemplate, withTabBusySpinnerTemplate, withTabCloseIconTemplate, withTabErrorBadgeTemplate, withTabIconTemplate, withTabOverflowItemTemplate, withTabOverflowMaxDeferMs, withTabOverflowStabilizeMs, withTabOverflowTriggerTemplate, withTabRejectionIconTemplate, withTabsAddable, withTabsAlign, withTabsAriaLabels, withTabsClosable, withTabsCommitMode, withTabsDefaultOrientation, withTabsFallbackLabels, withTabsFitted, withTabsFragmentSync, withTabsI18nLabels, withTabsIconLayout, withTabsPanelMode, withTabsRouterSync, withTabsRovingLoop, withTabsSkin };
|
|
2990
|
+
export { CNGX_DIRECTIVE_BY_ID_MAP_FACTORY, CNGX_DOM_ANCHOR_RETRY_FACTORY, CNGX_ORGANISM_SCROLL_SYNC_FACTORY, CNGX_OVERFLOW_POPOVER_HIGHLIGHT_FACTORY, CNGX_TABS_COMMIT_ACTION, CNGX_TABS_COMMIT_HANDLER_FACTORY, CNGX_TABS_CONFIG, CNGX_TABS_GLYPHS, CNGX_TABS_I18N, CNGX_TAB_GROUP_HOST, CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY, CNGX_TAB_PANEL_HOST, CngxTab, CngxTabAddIcon, CngxTabBusySpinner, CngxTabCloseIcon, CngxTabContent, CngxTabErrorBadge, CngxTabGroupPresenter, CngxTabIcon, CngxTabLabel, CngxTabLink, CngxTabOverflowItem, CngxTabOverflowTrigger, CngxTabRejectionIcon, CngxTabSubLabel, CngxTabsFragmentSync, CngxTabsRouteSync, createCngxTabOverflowDefaultDomAdapter, createDirectiveByIdMap, createDomAnchorRetry, createOrganismScrollSync, createOverflowPopoverHighlightSync, createTabDismissals, createTabGroupAnnouncements, createTabGroupTemplateBindings, createTabKeyboardNav, createTabOverflowTemplateBindings, createTabRouterCommit, createTabsCommitHandler, createTabsHostAttrs, injectTabsConfig, injectTabsI18n, provideCngxTabs, provideCngxTabsAt, provideTabsConfig, provideTabsConfigAt, provideTabsI18n, tabOverflowOptionId, withDefaultOrientation, withTabAddIconTemplate, withTabBusySpinnerTemplate, withTabCloseIconTemplate, withTabErrorBadgeTemplate, withTabIconTemplate, withTabOverflowItemTemplate, withTabOverflowMaxDeferMs, withTabOverflowStabilizeMs, withTabOverflowTriggerTemplate, withTabRejectionIconTemplate, withTabsAddable, withTabsAlign, withTabsAriaLabels, withTabsClosable, withTabsCommitMode, withTabsDefaultOrientation, withTabsFallbackLabels, withTabsFitted, withTabsFragmentSync, withTabsI18nLabels, withTabsIconLayout, withTabsPanelMode, withTabsRouterSync, withTabsRovingLoop, withTabsSkin };
|
|
2610
2991
|
//# sourceMappingURL=cngx-common-tabs.mjs.map
|