@cngx/common 0.1.0-rc.0 → 0.1.0-rc.2
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/fesm2022/cngx-common-a11y.mjs +24 -11
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +64 -48
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +45 -11
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +559 -38
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +1394 -160
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +1 -1
- package/package.json +3 -3
- package/stepper/README.md +16 -9
- package/theming/components/cngx-badge.css +1 -1
- package/theming/components/cngx-menu.css +1 -1
- package/types/cngx-common-a11y.d.ts +23 -2
- package/types/cngx-common-data.d.ts +46 -33
- package/types/cngx-common-interactive.d.ts +20 -2
- package/types/cngx-common-stepper.d.ts +604 -17
- package/types/cngx-common-tabs.d.ts +1363 -159
- package/tabs/README.md +0 -32
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, model, input, inject,
|
|
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
|
-
import { isObservable } from 'rxjs';
|
|
5
|
+
import { isObservable, Observable } from 'rxjs';
|
|
6
6
|
import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
7
|
-
import { Router, NavigationEnd } from '@angular/router';
|
|
8
|
-
import { filter } from 'rxjs/operators';
|
|
7
|
+
import { Router, NavigationEnd, NavigationCancel, NavigationError } from '@angular/router';
|
|
8
|
+
import { filter, take } from 'rxjs/operators';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* DI fallback the presenter reads when its `[commitAction]` input is
|
|
12
|
+
* unbound. Directives compose via DI tokens, not by hand-binding
|
|
13
|
+
* another directive's input (Pillar 3). When a source is present and
|
|
14
|
+
* exposes a non-null `action()`, its `mode()` wins over the
|
|
15
|
+
* `[commitMode]` input.
|
|
16
|
+
*
|
|
17
|
+
* @category common/tabs
|
|
18
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/commit-action.token.ts
|
|
19
|
+
* @since 0.1.0
|
|
20
|
+
*/
|
|
21
|
+
const CNGX_TABS_COMMIT_ACTION = new InjectionToken('CngxTabsCommitAction');
|
|
9
22
|
|
|
10
23
|
/**
|
|
11
24
|
* Wraps a {@link CngxCommitController} with the action-shape adapter
|
|
@@ -88,10 +101,11 @@ function runTabsAction(action, fromIndex, toIndex, handlers) {
|
|
|
88
101
|
};
|
|
89
102
|
}
|
|
90
103
|
/**
|
|
91
|
-
* DI token for the commit-handler factory.
|
|
92
|
-
* {@link createTabsCommitHandler}.
|
|
93
|
-
*
|
|
94
|
-
* `
|
|
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`.
|
|
95
109
|
*
|
|
96
110
|
* @category common/tabs
|
|
97
111
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/commit-handler.ts
|
|
@@ -103,9 +117,11 @@ const CNGX_TABS_COMMIT_HANDLER_FACTORY = new InjectionToken('CngxTabsCommitHandl
|
|
|
103
117
|
});
|
|
104
118
|
|
|
105
119
|
/**
|
|
106
|
-
* DI token for the tab presenter's contract.
|
|
107
|
-
* `useExisting`; `CngxTab` injects to register; the organism injects
|
|
108
|
-
* to
|
|
120
|
+
* DI token for the tab presenter's contract. \
|
|
121
|
+
* Presenter provides via `useExisting`; `CngxTab` injects to register; the organism injects
|
|
122
|
+
* to drive the APG tablist keyboard model (automatic activation via
|
|
123
|
+
* `select()`, roving stop derived from `activeId`) through
|
|
124
|
+
* `createTabKeyboardNav`.
|
|
109
125
|
*
|
|
110
126
|
* @category common/tabs
|
|
111
127
|
* @wcag AA
|
|
@@ -115,15 +131,15 @@ const CNGX_TABS_COMMIT_HANDLER_FACTORY = new InjectionToken('CngxTabsCommitHandl
|
|
|
115
131
|
const CNGX_TAB_GROUP_HOST = new InjectionToken('CngxTabGroupHost');
|
|
116
132
|
|
|
117
133
|
/**
|
|
118
|
-
* Tab-group presenter - brain of every
|
|
119
|
-
* active-index model, the tab registry, orientation, loop policy,
|
|
120
|
-
* and the commit-controller lifecycle.
|
|
121
|
-
* {@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}
|
|
122
138
|
* so `<cngx-toast-on />` / `<cngx-banner-on />` compose without
|
|
123
139
|
* `[state]` wiring.
|
|
124
140
|
*
|
|
125
|
-
* **Layer:** `@cngx/common/tabs
|
|
126
|
-
* organisms compose via `hostDirectives`, consumers attach
|
|
141
|
+
* **Layer:** `@cngx/common/tabs`. \
|
|
142
|
+
* Directive-only - organisms compose via `hostDirectives`, consumers attach
|
|
127
143
|
* `[cngxTabGroup]` directly.
|
|
128
144
|
*
|
|
129
145
|
* @category common/tabs
|
|
@@ -139,20 +155,71 @@ class CngxTabGroupPresenter {
|
|
|
139
155
|
orientation = input('horizontal', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
140
156
|
loop = input(true, ...(ngDevMode ? [{ debugName: "loop" }] : /* istanbul ignore next */ []));
|
|
141
157
|
/**
|
|
142
|
-
* Async-commit action gating the transition.
|
|
143
|
-
* `select(...)` routes through {@link CngxTabsCommitHandler}; the
|
|
158
|
+
* Async-commit action gating the transition.
|
|
159
|
+
* When non-null, `select(...)` routes through {@link CngxTabsCommitHandler}; the
|
|
144
160
|
* action's resolution decides whether the change lands. Supersede
|
|
145
161
|
* semantics come from the commit-controller - a rapid second
|
|
146
162
|
* `select(...)` cancels the in-flight runner.
|
|
163
|
+
*
|
|
164
|
+
* @internal Two-field alias - bind the public `[commitAction]`; read
|
|
165
|
+
* the resolved {@link commitAction} computed (input ?? DI fallback).
|
|
147
166
|
*/
|
|
148
|
-
|
|
167
|
+
commitActionInput = input(null, { ...(ngDevMode ? { debugName: "commitActionInput" } : /* istanbul ignore next */ {}), alias: 'commitAction' });
|
|
149
168
|
/**
|
|
150
169
|
* Default `'optimistic'` - tab change is navigation, not a save,
|
|
151
170
|
* so eager visual feedback matches the user's mental model.
|
|
152
171
|
* Switch to `'pessimistic'` when the new tab must wait for the
|
|
153
172
|
* action to confirm.
|
|
173
|
+
*
|
|
174
|
+
* @internal Two-field alias - bind the public `[commitMode]`; read
|
|
175
|
+
* the resolved {@link commitMode} computed (DI fallback mode wins
|
|
176
|
+
* when a routed action is active).
|
|
177
|
+
*/
|
|
178
|
+
commitModeInput = input('optimistic', { ...(ngDevMode ? { debugName: "commitModeInput" } : /* istanbul ignore next */ {}), alias: 'commitMode' });
|
|
179
|
+
injector = inject(Injector);
|
|
180
|
+
// Resolved lazily, never in a field initialiser: a sync directive
|
|
181
|
+
// (e.g. [cngxTabsRouteSync]) provides CNGX_TABS_COMMIT_ACTION via
|
|
182
|
+
// useExisting and itself injects this presenter as its host, so
|
|
183
|
+
// eager injection here would close a construction cycle (NG0200).
|
|
184
|
+
// First read happens at select()/template time - after both
|
|
185
|
+
// directives exist. The source is static per element, so memoising
|
|
186
|
+
// the resolution is safe.
|
|
187
|
+
injectedActionSource;
|
|
188
|
+
resolveInjectedAction() {
|
|
189
|
+
if (this.injectedActionSource === undefined) {
|
|
190
|
+
this.injectedActionSource = this.injector.get(CNGX_TABS_COMMIT_ACTION, null);
|
|
191
|
+
}
|
|
192
|
+
return this.injectedActionSource;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Resolved commit-action: the `[commitAction]` input when bound, else
|
|
196
|
+
* the {@link CNGX_TABS_COMMIT_ACTION} DI fallback (routed path), else
|
|
197
|
+
* `null`. `select()` reads this.
|
|
198
|
+
*/
|
|
199
|
+
commitAction = computed(() => this.commitActionInput() ?? this.resolveInjectedAction()?.action() ?? null, ...(ngDevMode ? [{ debugName: "commitAction" }] : /* istanbul ignore next */ []));
|
|
200
|
+
/**
|
|
201
|
+
* Resolved commit mode. When the DI fallback supplies an active
|
|
202
|
+
* action its `mode` wins - the routed path pins `'pessimistic'` so a
|
|
203
|
+
* stray `[commitMode]="'optimistic'"` cannot break the
|
|
204
|
+
* route-follows-resolution invariant. Otherwise the `[commitMode]`
|
|
205
|
+
* input drives.
|
|
206
|
+
*/
|
|
207
|
+
commitMode = computed(() => {
|
|
208
|
+
const source = this.resolveInjectedAction();
|
|
209
|
+
return source?.action() ? source.mode() : this.commitModeInput();
|
|
210
|
+
}, ...(ngDevMode ? [{ debugName: "commitMode" }] : /* istanbul ignore next */ []));
|
|
211
|
+
/**
|
|
212
|
+
* Emitted when a tab's close affordance is activated (the close
|
|
213
|
+
* button or Delete/Backspace on the focused tab). The presenter has
|
|
214
|
+
* already moved the active index onto the surviving neighbour; the
|
|
215
|
+
* consumer removes the tab from its own data in the handler.
|
|
154
216
|
*/
|
|
155
|
-
|
|
217
|
+
tabClose = output();
|
|
218
|
+
/**
|
|
219
|
+
* Emitted when the add-tab affordance is activated. The consumer
|
|
220
|
+
* appends a tab to its own data; the presenter owns no creation logic.
|
|
221
|
+
*/
|
|
222
|
+
tabAdd = output();
|
|
156
223
|
genericFactory = inject(CNGX_COMMIT_CONTROLLER_FACTORY);
|
|
157
224
|
commitController = this.genericFactory();
|
|
158
225
|
commitHandler = inject(CNGX_TABS_COMMIT_HANDLER_FACTORY)({
|
|
@@ -323,8 +390,29 @@ class CngxTabGroupPresenter {
|
|
|
323
390
|
this.select(idx);
|
|
324
391
|
}
|
|
325
392
|
}
|
|
393
|
+
requestClose(id) {
|
|
394
|
+
const tabs = this.tabs();
|
|
395
|
+
const index = tabs.findIndex((h) => h.id === id);
|
|
396
|
+
if (index < 0) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
const active = this.clampedIndex();
|
|
400
|
+
// Only closing a tab BEFORE the active one needs a pre-emptive
|
|
401
|
+
// index shift: the active tab moves down one slot once the consumer
|
|
402
|
+
// removes the closed tab, so decrement to keep the same tab active.
|
|
403
|
+
// Closing the active tab (or one after it) needs no write -
|
|
404
|
+
// `clampedIndex` re-derives against the shorter array and lands on
|
|
405
|
+
// the next tab (or the new last when the closed tab was last).
|
|
406
|
+
if (index < active) {
|
|
407
|
+
this.activeIndex.set(active - 1);
|
|
408
|
+
}
|
|
409
|
+
this.tabClose.emit({ id, index });
|
|
410
|
+
}
|
|
411
|
+
requestAdd() {
|
|
412
|
+
this.tabAdd.emit();
|
|
413
|
+
}
|
|
326
414
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTabGroupPresenter, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
327
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxTabGroupPresenter, isStandalone: true, selector: "[cngxTabGroup]", inputs: { activeIndex: { classPropertyName: "activeIndex", publicName: "activeIndex", 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 },
|
|
415
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxTabGroupPresenter, isStandalone: true, selector: "[cngxTabGroup]", inputs: { activeIndex: { classPropertyName: "activeIndex", publicName: "activeIndex", 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 }, commitActionInput: { classPropertyName: "commitActionInput", publicName: "commitAction", isSignal: true, isRequired: false, transformFunction: null }, commitModeInput: { classPropertyName: "commitModeInput", publicName: "commitMode", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { activeIndex: "activeIndexChange", tabClose: "tabClose", tabAdd: "tabAdd" }, providers: [
|
|
328
416
|
{ provide: CNGX_TAB_GROUP_HOST, useExisting: CngxTabGroupPresenter },
|
|
329
417
|
{ provide: CNGX_STATEFUL, useExisting: CngxTabGroupPresenter },
|
|
330
418
|
], exportAs: ["cngxTabGroup"], ngImport: i0 });
|
|
@@ -340,19 +428,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
340
428
|
{ provide: CNGX_STATEFUL, useExisting: CngxTabGroupPresenter },
|
|
341
429
|
],
|
|
342
430
|
}]
|
|
343
|
-
}], propDecorators: { activeIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "activeIndex", required: false }] }, { type: i0.Output, args: ["activeIndexChange"] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], loop: [{ type: i0.Input, args: [{ isSignal: true, alias: "loop", required: false }] }],
|
|
431
|
+
}], propDecorators: { activeIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "activeIndex", required: false }] }, { type: i0.Output, args: ["activeIndexChange"] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], loop: [{ type: i0.Input, args: [{ isSignal: true, alias: "loop", required: false }] }], commitActionInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "commitAction", required: false }] }], commitModeInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "commitMode", required: false }] }], tabClose: [{ type: i0.Output, args: ["tabClose"] }], tabAdd: [{ type: i0.Output, args: ["tabAdd"] }] } });
|
|
344
432
|
/**
|
|
345
433
|
* Structural equality for the tab registry. Compares length and
|
|
346
|
-
* per-entry `id`, `disabled()`,
|
|
434
|
+
* per-entry `id`, `disabled()`, `label()`, `subLabel()`, and
|
|
435
|
+
* `closable()`.
|
|
347
436
|
*
|
|
348
|
-
* `errorAggregator`
|
|
349
|
-
* per-tab reference injected once,
|
|
350
|
-
*
|
|
351
|
-
*
|
|
437
|
+
* `errorAggregator`, `hasError`, and `errorMessage` are left out on
|
|
438
|
+
* purpose. The handle is a stable per-tab reference injected once, and
|
|
439
|
+
* the organism reads `tab.hasError()` / `tab.errorMessage()` reactively
|
|
440
|
+
* off that handle (not off array identity), so the badge + descriptor
|
|
441
|
+
* update on error-state changes without the registry array re-emitting.
|
|
442
|
+
* Comparing them here would push the memoisation burden onto consumers
|
|
443
|
+
* and break the structural-equal contract.
|
|
352
444
|
*
|
|
353
|
-
* Reading
|
|
354
|
-
*
|
|
355
|
-
* tracking context.
|
|
445
|
+
* Reading the signals here doesn't subscribe - the comparator runs
|
|
446
|
+
* synchronously inside `signal.set()`, outside any tracking context.
|
|
356
447
|
*
|
|
357
448
|
* @internal
|
|
358
449
|
*/
|
|
@@ -366,7 +457,9 @@ function tabsEqual(a, b) {
|
|
|
366
457
|
for (let i = 0; i < a.length; i++) {
|
|
367
458
|
if (a[i].id !== b[i].id ||
|
|
368
459
|
a[i].disabled() !== b[i].disabled() ||
|
|
369
|
-
a[i].label() !== b[i].label()
|
|
460
|
+
a[i].label() !== b[i].label() ||
|
|
461
|
+
a[i].subLabel() !== b[i].subLabel() ||
|
|
462
|
+
a[i].closable() !== b[i].closable()) {
|
|
370
463
|
return false;
|
|
371
464
|
}
|
|
372
465
|
}
|
|
@@ -374,8 +467,8 @@ function tabsEqual(a, b) {
|
|
|
374
467
|
}
|
|
375
468
|
|
|
376
469
|
/**
|
|
377
|
-
* DI token the organism provides via `useExisting
|
|
378
|
-
* 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
|
|
379
472
|
* instead of the concrete component class.
|
|
380
473
|
*
|
|
381
474
|
* @category common/tabs
|
|
@@ -386,13 +479,12 @@ function tabsEqual(a, b) {
|
|
|
386
479
|
const CNGX_TAB_PANEL_HOST = new InjectionToken('CngxTabPanelHost');
|
|
387
480
|
|
|
388
481
|
/**
|
|
389
|
-
* Structural slot directive marking the per-tab panel-body template.
|
|
482
|
+
* Structural slot directive marking the per-tab panel-body template. \
|
|
390
483
|
* Discovered by `<cngx-tab-group>` via `contentChild` on each
|
|
391
484
|
* `CngxTab` and projected into the matching `role="tabpanel"`.
|
|
392
485
|
*
|
|
393
486
|
* ```html
|
|
394
|
-
* <div cngxTab
|
|
395
|
-
* <ng-template cngxTabLabel>Settings</ng-template>
|
|
487
|
+
* <div cngxTab [label]="'Settings'">
|
|
396
488
|
* <ng-template cngxTabContent>
|
|
397
489
|
* <p>Settings panel body…</p>
|
|
398
490
|
* </ng-template>
|
|
@@ -404,14 +496,6 @@ const CNGX_TAB_PANEL_HOST = new InjectionToken('CngxTabPanelHost');
|
|
|
404
496
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/tab-content.directive.ts
|
|
405
497
|
* @since 0.1.0
|
|
406
498
|
* @relatedTo CngxTab, CngxTabLabel
|
|
407
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-commit-action/optimistic-pessimistic-commits-with-bridge-directives</example-url>
|
|
408
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-error-aggregation/per-tab-error-badges</example-url>
|
|
409
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-group-vertical/vertical-sidebar-tabs</example-url>
|
|
410
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-group/three-tab-navigation</example-url>
|
|
411
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-overflow/8-tabs-in-a-narrow-container</example-url>
|
|
412
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/custom-busy-spinner-via-code-cngxtabbusyspinner-code</example-url>
|
|
413
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/custom-error-badge-via-code-cngxtaberrorbadge-code</example-url>
|
|
414
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/rejection-decoration-via-code-cngxtabrejectionicon-code</example-url>
|
|
415
499
|
*/
|
|
416
500
|
class CngxTabContent {
|
|
417
501
|
templateRef = inject((TemplateRef));
|
|
@@ -428,14 +512,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
428
512
|
}] });
|
|
429
513
|
|
|
430
514
|
/**
|
|
431
|
-
* Structural slot directive marking the per-tab label template.
|
|
515
|
+
* Structural slot directive marking the per-tab label template. \
|
|
432
516
|
* Discovered by `<cngx-tab-group>` via `contentChild` on each
|
|
433
517
|
* `CngxTab` and projected into the tab strip.
|
|
434
518
|
*
|
|
435
519
|
* ```html
|
|
436
520
|
* <div cngxTab id="settings">
|
|
437
521
|
* <ng-template cngxTabLabel>Settings</ng-template>
|
|
438
|
-
*
|
|
522
|
+
* ... tab content ...
|
|
439
523
|
* </div>
|
|
440
524
|
* ```
|
|
441
525
|
*
|
|
@@ -444,8 +528,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
444
528
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/tab-label.directive.ts
|
|
445
529
|
* @since 0.1.0
|
|
446
530
|
* @relatedTo CngxTab, CngxTabContent
|
|
447
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-group-vertical/vertical-sidebar-tabs</example-url>
|
|
448
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-group/three-tab-navigation</example-url>
|
|
449
531
|
*/
|
|
450
532
|
class CngxTabLabel {
|
|
451
533
|
templateRef = inject((TemplateRef));
|
|
@@ -462,54 +544,156 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
462
544
|
}] });
|
|
463
545
|
|
|
464
546
|
/**
|
|
465
|
-
*
|
|
547
|
+
* Structural slot directive marking a tab's secondary label template. \
|
|
548
|
+
* Discovered by `<cngx-tab-group>` via `contentChild` on each
|
|
549
|
+
* `CngxTab` and rendered as a stacked second line under the primary
|
|
550
|
+
* label. \
|
|
551
|
+
*
|
|
552
|
+
* Per-tab content, mirroring `CngxTabLabel` - the convenience
|
|
553
|
+
* `[subLabel]` string input on `CngxTab` covers the plain-text case.
|
|
554
|
+
*
|
|
555
|
+
* ```html
|
|
556
|
+
* <div cngxTab id="bookmarks">
|
|
557
|
+
* <ng-template cngxTabLabel>Bookmarks</ng-template>
|
|
558
|
+
* <ng-template cngxTabSubLabel>45 saved</ng-template>
|
|
559
|
+
* <ng-template cngxTabContent>...</ng-template>
|
|
560
|
+
* </div>
|
|
561
|
+
* ```
|
|
562
|
+
*
|
|
563
|
+
* @category common/tabs/slots
|
|
564
|
+
* @wcag AA
|
|
565
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-sub-label.directive.ts
|
|
566
|
+
* @since 0.1.0
|
|
567
|
+
* @relatedTo CngxTab, CngxTabLabel, CngxTabContent
|
|
568
|
+
* <example-url>http://localhost:4200/#/ui/tabs/tab-sub-label/label-with-count</example-url>
|
|
569
|
+
*/
|
|
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
|
+
*/
|
|
575
|
+
templateRef = inject((TemplateRef));
|
|
576
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTabSubLabel, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
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 });
|
|
578
|
+
}
|
|
579
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTabSubLabel, decorators: [{
|
|
580
|
+
type: Directive,
|
|
581
|
+
args: [{
|
|
582
|
+
selector: 'ng-template[cngxTabSubLabel]',
|
|
583
|
+
exportAs: 'cngxTabSubLabel',
|
|
584
|
+
standalone: true,
|
|
585
|
+
}]
|
|
586
|
+
}] });
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Single-tab atom. \
|
|
590
|
+
* Registers with the enclosing presenter via
|
|
466
591
|
* {@link CNGX_TAB_GROUP_HOST} on construction; deregisters via
|
|
467
|
-
* {@link DestroyRef} on teardown.
|
|
592
|
+
* {@link DestroyRef} on teardown. \
|
|
593
|
+
* The presenter holds the atom's
|
|
468
594
|
* input signals by reference, so input changes propagate without
|
|
469
|
-
* re-registration.
|
|
595
|
+
* re-registration. \
|
|
596
|
+
* `labelTemplate` / `contentTemplate` are projected
|
|
470
597
|
* by the organism - the atom carries no rendering logic.
|
|
471
598
|
*
|
|
599
|
+
* ```html
|
|
600
|
+
* <div cngxTab [label]="'Settings'">
|
|
601
|
+
* ... content templates here ...
|
|
602
|
+
* </div>
|
|
603
|
+
* ```
|
|
472
604
|
* @category common/tabs
|
|
473
605
|
* @docsKind primary
|
|
474
606
|
* @wcag AA
|
|
475
607
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/tab.directive.ts
|
|
476
608
|
* @since 0.1.0
|
|
477
609
|
* @relatedTo CngxTabGroupPresenter, CngxTabLabel, CngxTabContent, CngxTabErrorBadge
|
|
478
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-commit-action/optimistic-pessimistic-commits-with-bridge-directives</example-url>
|
|
479
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-error-aggregation/per-tab-error-badges</example-url>
|
|
480
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-group-vertical/vertical-sidebar-tabs</example-url>
|
|
481
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-group/three-tab-navigation</example-url>
|
|
482
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-overflow/8-tabs-in-a-narrow-container</example-url>
|
|
483
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/custom-busy-spinner-via-code-cngxtabbusyspinner-code</example-url>
|
|
484
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/custom-error-badge-via-code-cngxtaberrorbadge-code</example-url>
|
|
485
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/rejection-decoration-via-code-cngxtabrejectionicon-code</example-url>
|
|
486
610
|
*/
|
|
487
611
|
class CngxTab {
|
|
488
612
|
id = input(nextUid('cngx-tab-'), ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
489
613
|
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
490
614
|
label = input(undefined, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
615
|
+
/**
|
|
616
|
+
* Optional secondary text line under the primary label (a count, a
|
|
617
|
+
* status word, a short detail). Convenience for the common text
|
|
618
|
+
* case, parallel to `[label]`; the `*cngxTabSubLabel` slot covers
|
|
619
|
+
* richer content. Folds into the tab's accessible name.
|
|
620
|
+
*/
|
|
621
|
+
subLabel = input(undefined, ...(ngDevMode ? [{ debugName: "subLabel" }] : /* istanbul ignore next */ []));
|
|
491
622
|
errorAggregator = input(undefined, ...(ngDevMode ? [{ debugName: "errorAggregator" }] : /* istanbul ignore next */ []));
|
|
623
|
+
/**
|
|
624
|
+
* Direct error flag for the common "this tab is invalid" case - no
|
|
625
|
+
* `errorAggregator` boilerplate required. `true` or a non-empty string
|
|
626
|
+
* drives the error state; a string doubles as the inline message
|
|
627
|
+
* (surfaced via the `*cngxTabErrorBadge` slot context). `false` / `''`
|
|
628
|
+
* clear it. The aggregator stays the rich multi-source forms path; the
|
|
629
|
+
* two channels compose (either errors). Mirrors `CngxStep.error`.
|
|
630
|
+
*/
|
|
631
|
+
error = input(false, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
632
|
+
/**
|
|
633
|
+
* Resolved direct-error message: the `[error]` string when non-empty,
|
|
634
|
+
* else `undefined`. Carried onto the registration handle so the error
|
|
635
|
+
* badge slot can render it. `computed` over the input - never written.
|
|
636
|
+
*/
|
|
637
|
+
errorMessage = computed(() => {
|
|
638
|
+
const value = this.error();
|
|
639
|
+
return typeof value === 'string' && value !== '' ? value : undefined;
|
|
640
|
+
}, ...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
|
|
641
|
+
/**
|
|
642
|
+
* Per-tab error fold driving the badge + SR descriptor. `true` when
|
|
643
|
+
* the direct `[error]` flag is set OR the optional aggregator wants to
|
|
644
|
+
* reveal (`shouldShow()` = `hasError` AND scope reveal-state). The
|
|
645
|
+
* aggregator arm reads `shouldShow`, not `hasError`, so deferred-reveal
|
|
646
|
+
* validation stays silent until revealed - the direct flag has no
|
|
647
|
+
* reveal concept (the consumer sets it when it wants it shown). A
|
|
648
|
+
* boolean, not a status enum: tabs carry no success/completed/disabled
|
|
649
|
+
* model (Pillar 3).
|
|
650
|
+
*/
|
|
651
|
+
hasError = computed(() => {
|
|
652
|
+
const directError = this.error();
|
|
653
|
+
return ((directError !== false && directError !== '') ||
|
|
654
|
+
(this.errorAggregator()?.shouldShow?.() ?? false));
|
|
655
|
+
}, { ...(ngDevMode ? { debugName: "hasError" } : /* istanbul ignore next */ {}), equal: Object.is });
|
|
656
|
+
/**
|
|
657
|
+
* Per-tab close-affordance override. `undefined` (default) inherits
|
|
658
|
+
* the group-level `[closable]` resolution; set `false` to pin this
|
|
659
|
+
* tab open inside a dismissable group, or `true` to make a single tab
|
|
660
|
+
* closable while the group default is off.
|
|
661
|
+
*/
|
|
662
|
+
closable = input(undefined, ...(ngDevMode ? [{ debugName: "closable" }] : /* istanbul ignore next */ []));
|
|
492
663
|
labelTemplate = contentChild(CngxTabLabel, ...(ngDevMode ? [{ debugName: "labelTemplate" }] : /* istanbul ignore next */ []));
|
|
664
|
+
subLabelTemplate = contentChild(CngxTabSubLabel, ...(ngDevMode ? [{ debugName: "subLabelTemplate" }] : /* istanbul ignore next */ []));
|
|
493
665
|
contentTemplate = contentChild(CngxTabContent, ...(ngDevMode ? [{ debugName: "contentTemplate" }] : /* istanbul ignore next */ []));
|
|
494
666
|
host = inject(CNGX_TAB_GROUP_HOST, { optional: true });
|
|
667
|
+
destroyRef = inject(DestroyRef);
|
|
495
668
|
/** `true` when the presenter's `activeId` equals this tab's id. */
|
|
496
669
|
selected = computed(() => this.host?.activeId() === this.id(), { ...(ngDevMode ? { debugName: "selected" } : /* istanbul ignore next */ {}), equal: Object.is });
|
|
497
670
|
constructor() {
|
|
498
671
|
if (!this.host) {
|
|
499
672
|
throw new Error('CngxTab: no enclosing CngxTabGroupPresenter found. Wrap the tab inside an element carrying [cngxTabGroup] (or place it inside <cngx-tab-group>).');
|
|
500
673
|
}
|
|
674
|
+
}
|
|
675
|
+
ngOnInit() {
|
|
676
|
+
// Register in ngOnInit, NOT the constructor: a dynamically-bound
|
|
677
|
+
// `[id]` (or `[label]`) signal input is not applied until the first
|
|
678
|
+
// change detection, so a constructor read would capture the default
|
|
679
|
+
// auto-id. The handle id is the stable key consumers map `(tabClose)`
|
|
680
|
+
// back to their data with, so it must reflect the bound `[id]`.
|
|
681
|
+
const host = this.host;
|
|
501
682
|
const tabId = this.id();
|
|
502
|
-
|
|
683
|
+
host.register({
|
|
503
684
|
id: tabId,
|
|
504
685
|
label: this.label,
|
|
686
|
+
subLabel: this.subLabel,
|
|
505
687
|
disabled: this.disabled,
|
|
506
688
|
errorAggregator: this.errorAggregator,
|
|
689
|
+
hasError: this.hasError,
|
|
690
|
+
errorMessage: this.errorMessage,
|
|
691
|
+
closable: this.closable,
|
|
507
692
|
});
|
|
508
|
-
|
|
509
|
-
inject(DestroyRef).onDestroy(() => host.unregister(tabId));
|
|
693
|
+
this.destroyRef.onDestroy(() => host.unregister(tabId));
|
|
510
694
|
}
|
|
511
695
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTab, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
512
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxTab, isStandalone: true, selector: "[cngxTab]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, errorAggregator: { classPropertyName: "errorAggregator", publicName: "errorAggregator", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "labelTemplate", first: true, predicate: CngxTabLabel, descendants: true, isSignal: true }, { propertyName: "contentTemplate", first: true, predicate: CngxTabContent, descendants: true, isSignal: true }], exportAs: ["cngxTab"], ngImport: i0 });
|
|
696
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxTab, isStandalone: true, selector: "[cngxTab]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, subLabel: { classPropertyName: "subLabel", publicName: "subLabel", isSignal: true, isRequired: false, transformFunction: null }, errorAggregator: { classPropertyName: "errorAggregator", publicName: "errorAggregator", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, closable: { classPropertyName: "closable", publicName: "closable", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "labelTemplate", first: true, predicate: CngxTabLabel, descendants: true, isSignal: true }, { propertyName: "subLabelTemplate", first: true, predicate: CngxTabSubLabel, descendants: true, isSignal: true }, { propertyName: "contentTemplate", first: true, predicate: CngxTabContent, descendants: true, isSignal: true }], exportAs: ["cngxTab"], ngImport: i0 });
|
|
513
697
|
}
|
|
514
698
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTab, decorators: [{
|
|
515
699
|
type: Directive,
|
|
@@ -518,19 +702,219 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
518
702
|
exportAs: 'cngxTab',
|
|
519
703
|
standalone: true,
|
|
520
704
|
}]
|
|
521
|
-
}], 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 }] }], errorAggregator: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorAggregator", required: false }] }], labelTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxTabLabel), { isSignal: true }] }], contentTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxTabContent), { isSignal: true }] }] } });
|
|
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 }] }] } });
|
|
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 }] }] } });
|
|
522
877
|
|
|
523
878
|
/**
|
|
524
|
-
*
|
|
525
|
-
*
|
|
879
|
+
* Single dev-warning both tab sync directives emit when `@angular/router`
|
|
880
|
+
* is not provided. Shared so the message stays identical across
|
|
881
|
+
* {@link CngxTabsFragmentSync} (deep-linking) and {@link CngxTabsRouteSync}
|
|
882
|
+
* (router-outlet); only the `enables` clause differs. The URL readers
|
|
883
|
+
* themselves stay separate - they target different surfaces (fragment /
|
|
884
|
+
* query-param vs route path) and must not converge.
|
|
885
|
+
*
|
|
886
|
+
* @internal
|
|
887
|
+
*/
|
|
888
|
+
function warnTabsRouterAbsent(directive, enables) {
|
|
889
|
+
console.warn(`${directive}: no Router available - directive is a no-op. ` +
|
|
890
|
+
`Provide @angular/router via provideRouter(...) to enable ${enables}.`);
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* URL deep-linking for tab groups. \
|
|
895
|
+
* Bidirectional sync between `activeId` and a URL fragment or query-param. Opt-in via
|
|
526
896
|
* `[cngxTabsFragmentSync]` on the presenter element.
|
|
527
897
|
*
|
|
528
898
|
* - `mode = 'fragment'` (default) → `#tab=settings`
|
|
529
899
|
* - `mode = 'queryParam'` with `paramName = 'tab'` → `?tab=settings`
|
|
530
900
|
*
|
|
531
901
|
* `Router` is optional - without it the directive logs a dev warning
|
|
532
|
-
* via `afterNextRender` and becomes a no-op.
|
|
533
|
-
* 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
|
+
* ```
|
|
534
918
|
*
|
|
535
919
|
* @category common/tabs
|
|
536
920
|
* @docsKind primary
|
|
@@ -546,10 +930,7 @@ class CngxTabsFragmentSync {
|
|
|
546
930
|
router = inject(Router, { optional: true });
|
|
547
931
|
constructor() {
|
|
548
932
|
if (!this.router) {
|
|
549
|
-
afterNextRender(() =>
|
|
550
|
-
console.warn('CngxTabsFragmentSync: no Router available - directive is a no-op. ' +
|
|
551
|
-
'Provide @angular/router via provideRouter(...) to enable deep-linking.');
|
|
552
|
-
});
|
|
933
|
+
afterNextRender(() => warnTabsRouterAbsent('CngxTabsFragmentSync', 'deep-linking'));
|
|
553
934
|
return;
|
|
554
935
|
}
|
|
555
936
|
const router = this.router;
|
|
@@ -625,12 +1006,262 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
625
1006
|
}]
|
|
626
1007
|
}], ctorParameters: () => [], propDecorators: { mode: [{ type: i0.Input, args: [{ isSignal: true, alias: "mode", required: false }] }], paramName: [{ type: i0.Input, args: [{ isSignal: true, alias: "paramName", required: false }] }] } });
|
|
627
1008
|
|
|
1009
|
+
/**
|
|
1010
|
+
* Default tab-to-route mapping: the tab id is the child segment.
|
|
1011
|
+
* Shared so the factory and `[cngxTabsRouteSync]` reference one
|
|
1012
|
+
* definition instead of inlining the closure twice.
|
|
1013
|
+
*
|
|
1014
|
+
* @internal
|
|
1015
|
+
*/
|
|
1016
|
+
const cngxDefaultTabRoute = (handle) => [handle.id];
|
|
1017
|
+
/**
|
|
1018
|
+
* Builds a {@link CngxTabsCommitAction} that gates a tab switch through
|
|
1019
|
+
* `@angular/router`. The action navigates to the target tab's route and
|
|
1020
|
+
* resolves on the router's own outcome:
|
|
1021
|
+
*
|
|
1022
|
+
* - `NavigationEnd` → `true` (commit the switch)
|
|
1023
|
+
* - `NavigationCancel` (a `CanDeactivate` guard blocked) → `false`
|
|
1024
|
+
* - `NavigationError` (guard/resolver threw) → `false`
|
|
1025
|
+
*
|
|
1026
|
+
* Routed tabs reuse the presenter's commit lifecycle verbatim - the
|
|
1027
|
+
* router navigation is simply the async op. \
|
|
1028
|
+
* In pessimistic mode the active tab follows the *resolved* route, so a cancelled guard keeps
|
|
1029
|
+
* the old tab with zero extra gate machinery. The events subscription
|
|
1030
|
+
* is opened *before* `navigate(...)` so a synchronously-resolving
|
|
1031
|
+
* navigation cannot emit before the action is listening; the commit
|
|
1032
|
+
* controller's `cancel()` unsubscribes on supersede.
|
|
1033
|
+
*
|
|
1034
|
+
* @category common/tabs
|
|
1035
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/router-commit.ts
|
|
1036
|
+
* @since 0.1.0
|
|
1037
|
+
*/
|
|
1038
|
+
function createTabRouterCommit(opts) {
|
|
1039
|
+
const routeFor = opts.routeFor ?? cngxDefaultTabRoute;
|
|
1040
|
+
return (_fromIndex, toIndex) => new Observable((subscriber) => {
|
|
1041
|
+
const target = opts.tabs()[toIndex];
|
|
1042
|
+
if (!target) {
|
|
1043
|
+
subscriber.next(false);
|
|
1044
|
+
subscriber.complete();
|
|
1045
|
+
return;
|
|
1046
|
+
}
|
|
1047
|
+
const sub = opts.router.events
|
|
1048
|
+
.pipe(filter((e) => e instanceof NavigationEnd ||
|
|
1049
|
+
e instanceof NavigationCancel ||
|
|
1050
|
+
e instanceof NavigationError), take(1))
|
|
1051
|
+
.subscribe((event) => {
|
|
1052
|
+
subscriber.next(event instanceof NavigationEnd);
|
|
1053
|
+
subscriber.complete();
|
|
1054
|
+
});
|
|
1055
|
+
// A rejected promise surfaces on the events stream as
|
|
1056
|
+
// NavigationError, so the subscription above is the single
|
|
1057
|
+
// resolution path; swallow the promise rejection to avoid an
|
|
1058
|
+
// unhandled-rejection warning.
|
|
1059
|
+
opts.router.navigate(routeFor(target)).catch(() => undefined);
|
|
1060
|
+
return () => sub.unsubscribe();
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
/**
|
|
1065
|
+
* Router-outlet integration for tab groups. \
|
|
1066
|
+
* Opt-in via `[cngxTabsRouteSync]` on the presenter element. Each tab is an
|
|
1067
|
+
* Angular child route whose component renders into a `<router-outlet>`;
|
|
1068
|
+
* switching tabs navigates, and a `CanDeactivate` guard can gate the
|
|
1069
|
+
* leave.
|
|
1070
|
+
*
|
|
1071
|
+
* Supplies the presenter's commit-action through the
|
|
1072
|
+
* {@link CNGX_TABS_COMMIT_ACTION} DI fallback (no consumer
|
|
1073
|
+
* `[commitAction]` hand-binding) and pins **pessimistic** mode so the
|
|
1074
|
+
* active tab follows the *resolved* route - a guard-cancelled switch
|
|
1075
|
+
* keeps the old tab. The routing gate reuses the presenter's commit
|
|
1076
|
+
* lifecycle verbatim; the router navigation is the async op.
|
|
1077
|
+
*
|
|
1078
|
+
* Seeds the active tab from the current URL on mount and reflects
|
|
1079
|
+
* external navigations (back/forward, direct URL) into `activeIndex`
|
|
1080
|
+
* *without* re-navigating - those writes bypass the commit-action,
|
|
1081
|
+
* since the router is already at the resolved route.
|
|
1082
|
+
*
|
|
1083
|
+
* `Router` is optional - without it the directive logs a single dev
|
|
1084
|
+
* warning via `afterNextRender`, exposes a null action, and becomes a
|
|
1085
|
+
* no-op. Mirrors {@link CngxTabsFragmentSync}; every `activeIndex`
|
|
1086
|
+
* write inside an effect sits in `untracked()`.
|
|
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
|
+
*
|
|
1145
|
+
* @category common/tabs
|
|
1146
|
+
* @docsKind primary
|
|
1147
|
+
* @wcag AA
|
|
1148
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/route-sync.directive.ts
|
|
1149
|
+
* @since 0.1.0
|
|
1150
|
+
* @relatedTo CngxTabGroupPresenter, CngxTabsFragmentSync, createTabRouterCommit, CngxTabNav, CngxTabLink
|
|
1151
|
+
*/
|
|
1152
|
+
class CngxTabsRouteSync {
|
|
1153
|
+
/**
|
|
1154
|
+
* Maps a tab handle to its router command array. Default
|
|
1155
|
+
* `(handle) => [handle.id]` - the tab id is the child segment.
|
|
1156
|
+
* Override for real route paths.
|
|
1157
|
+
*/
|
|
1158
|
+
routeFor = input(cngxDefaultTabRoute, ...(ngDevMode ? [{ debugName: "routeFor" }] : /* istanbul ignore next */ []));
|
|
1159
|
+
host = inject(CNGX_TAB_GROUP_HOST, { host: true });
|
|
1160
|
+
router = inject(Router, { optional: true });
|
|
1161
|
+
/**
|
|
1162
|
+
* Pessimistic-only - not exposed as an input. The route-sync owns the
|
|
1163
|
+
* mode so optimistic (show-then-revert) can never flash the target
|
|
1164
|
+
* tab before a `CanDeactivate` guard decides.
|
|
1165
|
+
*/
|
|
1166
|
+
mode = signal('pessimistic', ...(ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []));
|
|
1167
|
+
/**
|
|
1168
|
+
* Router commit-action read by the presenter via the DI fallback.
|
|
1169
|
+
* `null` when no `Router` is available (graceful no-op). Rebuilt only
|
|
1170
|
+
* when `routeFor` changes; the navigation gate itself is the async
|
|
1171
|
+
* op inside the action.
|
|
1172
|
+
*/
|
|
1173
|
+
action = computed(() => {
|
|
1174
|
+
const router = this.router;
|
|
1175
|
+
if (!router) {
|
|
1176
|
+
return null;
|
|
1177
|
+
}
|
|
1178
|
+
return createTabRouterCommit({
|
|
1179
|
+
router,
|
|
1180
|
+
tabs: this.host.tabs,
|
|
1181
|
+
routeFor: this.routeFor(),
|
|
1182
|
+
});
|
|
1183
|
+
}, ...(ngDevMode ? [{ debugName: "action" }] : /* istanbul ignore next */ []));
|
|
1184
|
+
constructor() {
|
|
1185
|
+
if (!this.router) {
|
|
1186
|
+
afterNextRender(() => warnTabsRouterAbsent('CngxTabsRouteSync', 'routed tabs'));
|
|
1187
|
+
return;
|
|
1188
|
+
}
|
|
1189
|
+
const router = this.router;
|
|
1190
|
+
const destroyRef = inject(DestroyRef);
|
|
1191
|
+
// Seed from the current URL once the registry has populated.
|
|
1192
|
+
afterNextRender(() => {
|
|
1193
|
+
untracked(() => this.reflectFromUrl(router));
|
|
1194
|
+
});
|
|
1195
|
+
const navEnd = toSignal(router.events.pipe(filter((e) => e instanceof NavigationEnd), takeUntilDestroyed(destroyRef)), { initialValue: null });
|
|
1196
|
+
effect(() => {
|
|
1197
|
+
const e = navEnd();
|
|
1198
|
+
if (!e) {
|
|
1199
|
+
return;
|
|
1200
|
+
}
|
|
1201
|
+
untracked(() => this.reflectFromUrl(router));
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
/**
|
|
1205
|
+
* Mirror the URL's active tab onto `activeIndex` without navigating.
|
|
1206
|
+
* Writing the index directly (not via `select()`) is the re-entry
|
|
1207
|
+
* guard: `select()` would re-run the commit-action and navigate to
|
|
1208
|
+
* the route the router is already on, leaving the commit pending
|
|
1209
|
+
* forever.
|
|
1210
|
+
*/
|
|
1211
|
+
reflectFromUrl(router) {
|
|
1212
|
+
const next = this.readActiveId(router);
|
|
1213
|
+
if (!next || next === this.host.activeId()) {
|
|
1214
|
+
return;
|
|
1215
|
+
}
|
|
1216
|
+
const index = this.host.tabs().findIndex((t) => t.id === next);
|
|
1217
|
+
if (index >= 0) {
|
|
1218
|
+
this.host.activeIndex.set(index);
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
/**
|
|
1222
|
+
* Find the tab whose route is the trailing segment(s) of the current
|
|
1223
|
+
* URL path. Anchors on position (a suffix match), not a loose
|
|
1224
|
+
* "appears anywhere" scan - a tab id that happens to equal an
|
|
1225
|
+
* unrelated parent segment cannot win. The path is taken before any
|
|
1226
|
+
* query/fragment. If two tabs produce the same trailing segment(s)
|
|
1227
|
+
* (only possible with a custom `routeFor` that collides), the first
|
|
1228
|
+
* registered tab wins - the default id-based mapping never collides.
|
|
1229
|
+
*/
|
|
1230
|
+
readActiveId(router) {
|
|
1231
|
+
const path = router.url.split(/[?#]/)[0];
|
|
1232
|
+
const segments = path.split('/').filter(Boolean);
|
|
1233
|
+
const routeFor = this.routeFor();
|
|
1234
|
+
for (const tab of this.host.tabs()) {
|
|
1235
|
+
const route = routeFor(tab).map((command) => String(command));
|
|
1236
|
+
if (route.length === 0 || route.length > segments.length) {
|
|
1237
|
+
continue;
|
|
1238
|
+
}
|
|
1239
|
+
const tail = segments.slice(-route.length);
|
|
1240
|
+
if (tail.every((segment, i) => segment === route[i])) {
|
|
1241
|
+
return tab.id;
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
return null;
|
|
1245
|
+
}
|
|
1246
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTabsRouteSync, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1247
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxTabsRouteSync, isStandalone: true, selector: "[cngxTabsRouteSync]", inputs: { routeFor: { classPropertyName: "routeFor", publicName: "routeFor", isSignal: true, isRequired: false, transformFunction: null } }, providers: [{ provide: CNGX_TABS_COMMIT_ACTION, useExisting: CngxTabsRouteSync }], exportAs: ["cngxTabsRouteSync"], ngImport: i0 });
|
|
1248
|
+
}
|
|
1249
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTabsRouteSync, decorators: [{
|
|
1250
|
+
type: Directive,
|
|
1251
|
+
args: [{
|
|
1252
|
+
selector: '[cngxTabsRouteSync]',
|
|
1253
|
+
exportAs: 'cngxTabsRouteSync',
|
|
1254
|
+
standalone: true,
|
|
1255
|
+
providers: [{ provide: CNGX_TABS_COMMIT_ACTION, useExisting: CngxTabsRouteSync }],
|
|
1256
|
+
}]
|
|
1257
|
+
}], ctorParameters: () => [], propDecorators: { routeFor: [{ type: i0.Input, args: [{ isSignal: true, alias: "routeFor", required: false }] }] } });
|
|
1258
|
+
|
|
628
1259
|
const TABS_CONFIG_DEFAULTS = {
|
|
629
1260
|
defaultOrientation: 'horizontal',
|
|
630
1261
|
defaultLoop: true,
|
|
631
1262
|
defaultCommitMode: 'optimistic',
|
|
632
|
-
|
|
633
|
-
|
|
1263
|
+
fragmentSyncMode: 'fragment',
|
|
1264
|
+
fragmentSyncParam: 'tab',
|
|
634
1265
|
ariaLabels: {
|
|
635
1266
|
tabsRegion: 'Tabs',
|
|
636
1267
|
},
|
|
@@ -646,8 +1277,8 @@ const TABS_CONFIG_DEFAULTS = {
|
|
|
646
1277
|
templates: {},
|
|
647
1278
|
};
|
|
648
1279
|
/**
|
|
649
|
-
* DI token for the resolved tabs config.
|
|
650
|
-
* 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}
|
|
651
1282
|
* (root) or {@link provideTabsConfigAt} (component scope).
|
|
652
1283
|
*
|
|
653
1284
|
* @category common/tabs
|
|
@@ -661,7 +1292,8 @@ const CNGX_TABS_CONFIG = new InjectionToken('CngxTabsConfig', {
|
|
|
661
1292
|
});
|
|
662
1293
|
/**
|
|
663
1294
|
* Internal helper that brands a config-mutator function with the
|
|
664
|
-
* `_target` discriminator.
|
|
1295
|
+
* `_target` discriminator. \
|
|
1296
|
+
* Every `with*` config feature returns one
|
|
665
1297
|
* of these.
|
|
666
1298
|
*
|
|
667
1299
|
* @internal
|
|
@@ -714,19 +1346,109 @@ function withTabsCommitMode(mode) {
|
|
|
714
1346
|
}));
|
|
715
1347
|
}
|
|
716
1348
|
/**
|
|
717
|
-
* Configure
|
|
718
|
-
* the
|
|
719
|
-
* the
|
|
1349
|
+
* Configure URL fragment / query-param deep-linking for the active tab
|
|
1350
|
+
* (the {@link CngxTabsFragmentSync} directive). \
|
|
1351
|
+
* `mode` chooses the URL surface (URL fragment or query parameter); `param` names the key
|
|
1352
|
+
* (default `'tab'`).
|
|
1353
|
+
*
|
|
1354
|
+
* Not to be confused with `[cngxTabsRouteSync]`, the router-outlet
|
|
1355
|
+
* integration - this feature configures fragment deep-linking only.
|
|
720
1356
|
*
|
|
721
1357
|
* @category common/tabs
|
|
722
1358
|
*/
|
|
723
|
-
function
|
|
1359
|
+
function withTabsFragmentSync(mode, param = 'tab') {
|
|
724
1360
|
return defineTabsConfigFeature((cfg) => ({
|
|
725
1361
|
...cfg,
|
|
726
|
-
|
|
727
|
-
|
|
1362
|
+
fragmentSyncMode: mode,
|
|
1363
|
+
fragmentSyncParam: param,
|
|
728
1364
|
}));
|
|
729
1365
|
}
|
|
1366
|
+
/**
|
|
1367
|
+
* @deprecated Use {@link withTabsFragmentSync}. "Router sync" collided
|
|
1368
|
+
* with the new `[cngxTabsRouteSync]` router-outlet directive; this
|
|
1369
|
+
* feature only ever configured fragment / query-param deep-linking. The
|
|
1370
|
+
* alias stays for one minor release before removal.
|
|
1371
|
+
*
|
|
1372
|
+
* @category common/tabs
|
|
1373
|
+
*/
|
|
1374
|
+
const withTabsRouterSync = withTabsFragmentSync;
|
|
1375
|
+
/**
|
|
1376
|
+
* Select the app-wide default visual skin for `<cngx-tab-group>`. \
|
|
1377
|
+
* Default `'line'`. Per-instance `[skin]` Input still wins; this moves
|
|
1378
|
+
* the cascade default. Structure, slots, ARIA, and keyboard behaviour
|
|
1379
|
+
* are identical across skins - only the `[data-skin]` host attribute
|
|
1380
|
+
* changes the CSS layer. The Material twin (`[cngxMatTabs]`) ignores it.
|
|
1381
|
+
*
|
|
1382
|
+
* @category common/tabs
|
|
1383
|
+
*/
|
|
1384
|
+
function withTabsSkin(skin) {
|
|
1385
|
+
return defineTabsConfigFeature((cfg) => ({ ...cfg, skin }));
|
|
1386
|
+
}
|
|
1387
|
+
/**
|
|
1388
|
+
* Set the app-wide default icon layout for `<cngx-tab-group>`. \
|
|
1389
|
+
* Default`'start'`. Per-instance `[iconLayout]` Input still wins. Orthogonal to
|
|
1390
|
+
* skin and orientation - only the `[data-icon-layout]` host attribute
|
|
1391
|
+
* changes.
|
|
1392
|
+
*
|
|
1393
|
+
* @category common/tabs
|
|
1394
|
+
*/
|
|
1395
|
+
function withTabsIconLayout(layout) {
|
|
1396
|
+
return defineTabsConfigFeature((cfg) => ({ ...cfg, iconLayout: layout }));
|
|
1397
|
+
}
|
|
1398
|
+
/**
|
|
1399
|
+
* Set the app-wide default panel render strategy for `<cngx-tab-group>`. \
|
|
1400
|
+
* Default `'eager'` (every panel's content rendered up front, toggled
|
|
1401
|
+
* via `[hidden]`). `'lazy'` keep-alives content after first activation;
|
|
1402
|
+
* `'lazy-destroy'` renders only the active panel's content. Per-instance
|
|
1403
|
+
* `[panelMode]` Input still wins. The panel `<div>` always stays in the
|
|
1404
|
+
* DOM regardless of mode (the `aria-controls` target).
|
|
1405
|
+
*
|
|
1406
|
+
* @category common/tabs
|
|
1407
|
+
*/
|
|
1408
|
+
function withTabsPanelMode(mode) {
|
|
1409
|
+
return defineTabsConfigFeature((cfg) => ({ ...cfg, panelMode: mode }));
|
|
1410
|
+
}
|
|
1411
|
+
/**
|
|
1412
|
+
* Set the app-wide default for stretching tabs to the full strip width
|
|
1413
|
+
* (horizontal only). \
|
|
1414
|
+
* Default `false`. Per-instance `[fitted]` Input still
|
|
1415
|
+
* wins. No effect under `orientation="vertical"`.
|
|
1416
|
+
*
|
|
1417
|
+
* @category common/tabs
|
|
1418
|
+
*/
|
|
1419
|
+
function withTabsFitted(fitted) {
|
|
1420
|
+
return defineTabsConfigFeature((cfg) => ({ ...cfg, fitted }));
|
|
1421
|
+
}
|
|
1422
|
+
/**
|
|
1423
|
+
* Set the app-wide default tab-cluster alignment (horizontal only). \
|
|
1424
|
+
* Default `'start'`. Per-instance `[tabAlign]` Input still wins. Ignored
|
|
1425
|
+
* under `orientation="vertical"` and when the group is `fitted`.
|
|
1426
|
+
*
|
|
1427
|
+
* @category common/tabs
|
|
1428
|
+
*/
|
|
1429
|
+
function withTabsAlign(align) {
|
|
1430
|
+
return defineTabsConfigFeature((cfg) => ({ ...cfg, tabAlign: align }));
|
|
1431
|
+
}
|
|
1432
|
+
/**
|
|
1433
|
+
* Set the app-wide default for whether tabs render a close affordance. \
|
|
1434
|
+
* Default `false`. Per-instance `[closable]` Input wins; a per-`CngxTab`
|
|
1435
|
+
* `[closable]` override wins over both.
|
|
1436
|
+
*
|
|
1437
|
+
* @category common/tabs
|
|
1438
|
+
*/
|
|
1439
|
+
function withTabsClosable(closable) {
|
|
1440
|
+
return defineTabsConfigFeature((cfg) => ({ ...cfg, closable }));
|
|
1441
|
+
}
|
|
1442
|
+
/**
|
|
1443
|
+
* Set the app-wide default for whether the group renders an add-tab
|
|
1444
|
+
* button. \
|
|
1445
|
+
* Default `false`. Per-instance `[addable]` Input wins.
|
|
1446
|
+
*
|
|
1447
|
+
* @category common/tabs
|
|
1448
|
+
*/
|
|
1449
|
+
function withTabsAddable(addable) {
|
|
1450
|
+
return defineTabsConfigFeature((cfg) => ({ ...cfg, addable }));
|
|
1451
|
+
}
|
|
730
1452
|
/**
|
|
731
1453
|
* Merge ARIA labels into the cascade. Keys not provided keep their
|
|
732
1454
|
* library defaults; per-instance overrides on the tab group still win.
|
|
@@ -776,14 +1498,16 @@ function withTabOverflowMaxDeferMs(ms) {
|
|
|
776
1498
|
}));
|
|
777
1499
|
}
|
|
778
1500
|
/**
|
|
779
|
-
* App-wide override for the More-button label. Middle tier;
|
|
1501
|
+
* App-wide override for the More-button label. Middle tier; \
|
|
780
1502
|
* per-instance `*cngxTabOverflowTrigger` still wins.
|
|
781
1503
|
*
|
|
782
1504
|
* ```ts
|
|
783
|
-
*
|
|
784
|
-
*
|
|
1505
|
+
* readonly moreTrigger = viewChild.required<TemplateRef<CngxTabOverflowTriggerContext>>(
|
|
1506
|
+
* 'moreTrigger',
|
|
1507
|
+
* { read: TemplateRef },
|
|
1508
|
+
* );
|
|
785
1509
|
*
|
|
786
|
-
* providers: [provideTabsConfig(withTabOverflowTriggerTemplate(this.moreTrigger))]
|
|
1510
|
+
* providers: [provideTabsConfig(withTabOverflowTriggerTemplate(this.moreTrigger()))]
|
|
787
1511
|
* ```
|
|
788
1512
|
*
|
|
789
1513
|
* @category common/tabs
|
|
@@ -795,7 +1519,7 @@ function withTabOverflowTriggerTemplate(template) {
|
|
|
795
1519
|
}));
|
|
796
1520
|
}
|
|
797
1521
|
/**
|
|
798
|
-
* App-wide override for each row inside the overflow popover.
|
|
1522
|
+
* App-wide override for each row inside the overflow popover. \
|
|
799
1523
|
* Middle tier; per-instance `*cngxTabOverflowItem` still wins.
|
|
800
1524
|
*
|
|
801
1525
|
* @category common/tabs
|
|
@@ -821,7 +1545,8 @@ function withTabErrorBadgeTemplate(template) {
|
|
|
821
1545
|
}
|
|
822
1546
|
/**
|
|
823
1547
|
* App-wide override for the rejection-icon decoration. Middle
|
|
824
|
-
* tier;
|
|
1548
|
+
* tier; \
|
|
1549
|
+
* per-instance `*cngxTabRejectionIcon` still wins. Sibling
|
|
825
1550
|
* of {@link withStepRejectionTemplate}.
|
|
826
1551
|
*
|
|
827
1552
|
* @category common/tabs
|
|
@@ -845,6 +1570,43 @@ function withTabBusySpinnerTemplate(template) {
|
|
|
845
1570
|
templates: { ...cfg.templates, busySpinner: template },
|
|
846
1571
|
}));
|
|
847
1572
|
}
|
|
1573
|
+
/**
|
|
1574
|
+
* App-wide override for the tab-icon slot. Middle tier of the 3-stage
|
|
1575
|
+
* cascade; per-instance `*cngxTabIcon` still wins. Sibling of
|
|
1576
|
+
* {@link withStepIndicatorTemplate}.
|
|
1577
|
+
*
|
|
1578
|
+
* @category common/tabs
|
|
1579
|
+
*/
|
|
1580
|
+
function withTabIconTemplate(template) {
|
|
1581
|
+
return defineTabsConfigFeature((cfg) => ({
|
|
1582
|
+
...cfg,
|
|
1583
|
+
templates: { ...cfg.templates, icon: template },
|
|
1584
|
+
}));
|
|
1585
|
+
}
|
|
1586
|
+
/**
|
|
1587
|
+
* App-wide override for a tab's close-button glyph. Middle tier;
|
|
1588
|
+
* per-instance `*cngxTabCloseIcon` still wins.
|
|
1589
|
+
*
|
|
1590
|
+
* @category common/tabs
|
|
1591
|
+
*/
|
|
1592
|
+
function withTabCloseIconTemplate(template) {
|
|
1593
|
+
return defineTabsConfigFeature((cfg) => ({
|
|
1594
|
+
...cfg,
|
|
1595
|
+
templates: { ...cfg.templates, closeIcon: template },
|
|
1596
|
+
}));
|
|
1597
|
+
}
|
|
1598
|
+
/**
|
|
1599
|
+
* App-wide override for the add-tab button glyph. Middle tier;
|
|
1600
|
+
* per-instance `*cngxTabAddIcon` still wins.
|
|
1601
|
+
*
|
|
1602
|
+
* @category common/tabs
|
|
1603
|
+
*/
|
|
1604
|
+
function withTabAddIconTemplate(template) {
|
|
1605
|
+
return defineTabsConfigFeature((cfg) => ({
|
|
1606
|
+
...cfg,
|
|
1607
|
+
templates: { ...cfg.templates, addIcon: template },
|
|
1608
|
+
}));
|
|
1609
|
+
}
|
|
848
1610
|
function resolveFeatures(features) {
|
|
849
1611
|
return features.reduce((cfg, feat) => feat(cfg), TABS_CONFIG_DEFAULTS);
|
|
850
1612
|
}
|
|
@@ -886,13 +1648,40 @@ function injectTabsConfig() {
|
|
|
886
1648
|
return inject(CNGX_TABS_CONFIG);
|
|
887
1649
|
}
|
|
888
1650
|
|
|
1651
|
+
/**
|
|
1652
|
+
* Helper resolving the host-attribute cascades for
|
|
1653
|
+
* `<cngx-tab-group>` (skin / iconLayout). Keeps the organism class
|
|
1654
|
+
* under the LOC guard while making the cascade pattern reusable. Sibling
|
|
1655
|
+
* shape to `createStepperHostAttrs`; the resolved-type unions differ per
|
|
1656
|
+
* family, so the helpers are siblings, not shared code.
|
|
1657
|
+
*
|
|
1658
|
+
* Each computed honors the cascade:
|
|
1659
|
+
* per-instance input wins over root config wins over library default. No
|
|
1660
|
+
* manual sync. The library defaults (`'line'` / `'start'`) live here,
|
|
1661
|
+
* not in `TABS_CONFIG_DEFAULTS` - mirroring the stepper.
|
|
1662
|
+
*
|
|
1663
|
+
* @internal
|
|
1664
|
+
*/
|
|
1665
|
+
function createTabsHostAttrs(inputs) {
|
|
1666
|
+
return {
|
|
1667
|
+
resolvedSkin: computed(() => inputs.skin() ?? inputs.config.skin ?? 'line'),
|
|
1668
|
+
resolvedIconLayout: computed(() => inputs.iconLayout() ?? inputs.config.iconLayout ?? 'start'),
|
|
1669
|
+
resolvedPanelMode: computed(() => inputs.panelMode() ?? inputs.config.panelMode ?? 'eager'),
|
|
1670
|
+
resolvedFitted: computed(() => inputs.fitted() ?? inputs.config.fitted ?? false),
|
|
1671
|
+
resolvedTabAlign: computed(() => inputs.tabAlign() ?? inputs.config.tabAlign ?? 'start'),
|
|
1672
|
+
};
|
|
1673
|
+
}
|
|
1674
|
+
|
|
889
1675
|
const TABS_I18N_DEFAULTS = {
|
|
890
1676
|
tabsLabel: 'Tabs',
|
|
891
1677
|
selectedTab: (label, position, count) => `Tab ${position} of ${count}: ${label}`,
|
|
1678
|
+
tabLabelWithDetail: (label, detail) => `${label}, ${detail}`,
|
|
892
1679
|
tabHasErrors: (count) => `${count} error${count === 1 ? '' : 's'}`,
|
|
893
1680
|
moreTabsLabel: (count) => `${count} more`,
|
|
894
1681
|
previousTab: 'Previous tab',
|
|
895
1682
|
nextTab: 'Next tab',
|
|
1683
|
+
closeTab: (label) => `Close "${label}"`,
|
|
1684
|
+
addTab: 'Add tab',
|
|
896
1685
|
commitFailedRetry: 'Tab change refused — retry?',
|
|
897
1686
|
commitInFlight: 'Switching tab…',
|
|
898
1687
|
commitRolledBackTo: (originLabel) => `Could not save changes — reverted to "${originLabel}".`,
|
|
@@ -989,12 +1778,15 @@ function partitionFeatures(features) {
|
|
|
989
1778
|
return { config, i18n };
|
|
990
1779
|
}
|
|
991
1780
|
/**
|
|
992
|
-
* Unified aggregator for tabs configuration.
|
|
993
|
-
* `_target` to {@link provideTabsConfig} and {@link provideTabsI18n}.
|
|
994
|
-
* Sibling to
|
|
995
|
-
*
|
|
996
|
-
* `
|
|
997
|
-
*
|
|
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.
|
|
998
1790
|
*
|
|
999
1791
|
* ```ts
|
|
1000
1792
|
* bootstrapApplication(AppComponent, {
|
|
@@ -1010,6 +1802,9 @@ function partitionFeatures(features) {
|
|
|
1010
1802
|
* ```
|
|
1011
1803
|
*
|
|
1012
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
|
|
1013
1808
|
*/
|
|
1014
1809
|
function provideCngxTabs(...features) {
|
|
1015
1810
|
const { config, i18n } = partitionFeatures(features);
|
|
@@ -1019,8 +1814,8 @@ function provideCngxTabs(...features) {
|
|
|
1019
1814
|
]);
|
|
1020
1815
|
}
|
|
1021
1816
|
/**
|
|
1022
|
-
* Component-scoped twin of {@link provideCngxTabs}.
|
|
1023
|
-
* `Provider[]` for `viewProviders`/`providers`; same dispatch
|
|
1817
|
+
* Component-scoped twin of {@link provideCngxTabs}. \
|
|
1818
|
+
* Returns `Provider[]` for `viewProviders`/`providers`; same dispatch
|
|
1024
1819
|
* semantics, different scope.
|
|
1025
1820
|
*
|
|
1026
1821
|
* ```ts
|
|
@@ -1035,6 +1830,9 @@ function provideCngxTabs(...features) {
|
|
|
1035
1830
|
* ```
|
|
1036
1831
|
*
|
|
1037
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
|
|
1038
1836
|
*/
|
|
1039
1837
|
function provideCngxTabsAt(...features) {
|
|
1040
1838
|
const { config, i18n } = partitionFeatures(features);
|
|
@@ -1045,7 +1843,7 @@ function provideCngxTabsAt(...features) {
|
|
|
1045
1843
|
}
|
|
1046
1844
|
|
|
1047
1845
|
/**
|
|
1048
|
-
* Default adapter for the cngx-native `<cngx-tab-group>` strip:
|
|
1846
|
+
* Default adapter for the cngx-native `<cngx-tab-group>` strip: \
|
|
1049
1847
|
* walks `host.closest('.cngx-tabs__strip-wrapper')` for the IO root,
|
|
1050
1848
|
* then `[id="${handle.id}-header"]` for each button.
|
|
1051
1849
|
*
|
|
@@ -1063,7 +1861,7 @@ function createCngxTabOverflowDefaultDomAdapter() {
|
|
|
1063
1861
|
};
|
|
1064
1862
|
}
|
|
1065
1863
|
/**
|
|
1066
|
-
* DI token for the overflow molecule's DOM-resolution strategy.
|
|
1864
|
+
* DI token for the overflow molecule's DOM-resolution strategy. \
|
|
1067
1865
|
* Override at directive `providers` or component `viewProviders` to
|
|
1068
1866
|
* swap in a Material, custom-skin, or test-double adapter without
|
|
1069
1867
|
* forking the molecule. Defaults to
|
|
@@ -1080,9 +1878,12 @@ const CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY = new InjectionToken('CngxTabOverflo
|
|
|
1080
1878
|
|
|
1081
1879
|
/**
|
|
1082
1880
|
* Bounded retry loop for DOM-anchoring patterns - shared
|
|
1083
|
-
* attempt-counter
|
|
1881
|
+
* attempt-counter and give-up and cancellation contract. \
|
|
1882
|
+
* Used by
|
|
1084
1883
|
* `<cngx-tab-overflow>`'s rAF strip-attach loop and `[cngxMatTabs]`'s
|
|
1085
|
-
* `afterNextRender` header-anchor loop.
|
|
1884
|
+
* `afterNextRender` header-anchor loop.
|
|
1885
|
+
*
|
|
1886
|
+
* Consumer-supplied scheduler
|
|
1086
1887
|
* lets different timing primitives flow through one counter.
|
|
1087
1888
|
*
|
|
1088
1889
|
* ```ts
|
|
@@ -1124,7 +1925,8 @@ function createDomAnchorRetry(options) {
|
|
|
1124
1925
|
// Swallow + terminal stop - covers the test-runner teardown
|
|
1125
1926
|
// race where a global (e.g. IntersectionObserver) is reset
|
|
1126
1927
|
// between schedule and fire, before consumer DestroyRef can
|
|
1127
|
-
// call cancel().
|
|
1928
|
+
// call cancel().
|
|
1929
|
+
// Production callback bugs still surface via
|
|
1128
1930
|
// their own console.error before they throw here.
|
|
1129
1931
|
stopped = true;
|
|
1130
1932
|
return;
|
|
@@ -1155,15 +1957,16 @@ function createDomAnchorRetry(options) {
|
|
|
1155
1957
|
};
|
|
1156
1958
|
}
|
|
1157
1959
|
/**
|
|
1158
|
-
* DI token for the DOM-anchor retry policy.
|
|
1159
|
-
* {@link createDomAnchorRetry}. Two real consumers today -
|
|
1960
|
+
* DI token for the DOM-anchor retry policy. \
|
|
1961
|
+
* Default {@link createDomAnchorRetry}. Two real consumers today -
|
|
1160
1962
|
* `<cngx-tab-overflow>`'s rAF strip-attach loop and
|
|
1161
1963
|
* `[cngxMatTabs]`'s `afterNextRender` header-anchor loop. Override
|
|
1162
1964
|
* via `providers` / `viewProviders` for retry-with-backoff,
|
|
1163
|
-
* telemetry on give-up, etc.
|
|
1164
|
-
*
|
|
1165
|
-
* `
|
|
1166
|
-
* `
|
|
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`.
|
|
1167
1970
|
*
|
|
1168
1971
|
* @category common/tabs/overflow
|
|
1169
1972
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/overflow/dom-anchor-retry.ts
|
|
@@ -1265,9 +2068,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1265
2068
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-error-badge.directive.ts
|
|
1266
2069
|
* @since 0.1.0
|
|
1267
2070
|
* @relatedTo CngxTabRejectionIcon, CngxTabBusySpinner, CngxTab
|
|
1268
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/custom-busy-spinner-via-code-cngxtabbusyspinner-code</example-url>
|
|
1269
2071
|
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/custom-error-badge-via-code-cngxtaberrorbadge-code</example-url>
|
|
1270
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/rejection-decoration-via-code-cngxtabrejectionicon-code</example-url>
|
|
1271
2072
|
*/
|
|
1272
2073
|
class CngxTabErrorBadge {
|
|
1273
2074
|
templateRef = inject(TemplateRef);
|
|
@@ -1309,8 +2110,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1309
2110
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-rejection-icon.directive.ts
|
|
1310
2111
|
* @since 0.1.0
|
|
1311
2112
|
* @relatedTo CngxTabErrorBadge, CngxTabBusySpinner, CngxTab
|
|
1312
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/custom-busy-spinner-via-code-cngxtabbusyspinner-code</example-url>
|
|
1313
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/custom-error-badge-via-code-cngxtaberrorbadge-code</example-url>
|
|
1314
2113
|
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/rejection-decoration-via-code-cngxtabrejectionicon-code</example-url>
|
|
1315
2114
|
*/
|
|
1316
2115
|
class CngxTabRejectionIcon {
|
|
@@ -1346,8 +2145,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1346
2145
|
* @since 0.1.0
|
|
1347
2146
|
* @relatedTo CngxTabErrorBadge, CngxTabRejectionIcon, CngxTab
|
|
1348
2147
|
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/custom-busy-spinner-via-code-cngxtabbusyspinner-code</example-url>
|
|
1349
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/custom-error-badge-via-code-cngxtaberrorbadge-code</example-url>
|
|
1350
|
-
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/rejection-decoration-via-code-cngxtabrejectionicon-code</example-url>
|
|
1351
2148
|
*/
|
|
1352
2149
|
class CngxTabBusySpinner {
|
|
1353
2150
|
templateRef = inject(TemplateRef);
|
|
@@ -1364,11 +2161,341 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1364
2161
|
}] });
|
|
1365
2162
|
|
|
1366
2163
|
/**
|
|
1367
|
-
*
|
|
1368
|
-
*
|
|
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).
|
|
2168
|
+
*
|
|
2169
|
+
* ```html
|
|
2170
|
+
* <ng-template cngxTabIcon let-active="active">
|
|
2171
|
+
* <cngx-icon [name]="active ? 'folder-open' : 'folder'" />
|
|
2172
|
+
* </ng-template>
|
|
2173
|
+
* ```
|
|
2174
|
+
*
|
|
2175
|
+
* @category common/tabs/slots
|
|
2176
|
+
* @wcag AA
|
|
2177
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-icon.directive.ts
|
|
2178
|
+
* @since 0.1.0
|
|
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>
|
|
2185
|
+
*/
|
|
2186
|
+
class CngxTabIcon {
|
|
2187
|
+
templateRef = inject(TemplateRef);
|
|
2188
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTabIcon, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2189
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxTabIcon, isStandalone: true, selector: "ng-template[cngxTabIcon]", exportAs: ["cngxTabIcon"], ngImport: i0 });
|
|
2190
|
+
}
|
|
2191
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTabIcon, decorators: [{
|
|
2192
|
+
type: Directive,
|
|
2193
|
+
args: [{
|
|
2194
|
+
selector: 'ng-template[cngxTabIcon]',
|
|
2195
|
+
exportAs: 'cngxTabIcon',
|
|
2196
|
+
standalone: true,
|
|
2197
|
+
}]
|
|
2198
|
+
}] });
|
|
2199
|
+
|
|
2200
|
+
/**
|
|
2201
|
+
* Structural slot for a tab's close-button glyph. 3-stage cascade:
|
|
2202
|
+
* per-instance directive > `CNGX_TABS_CONFIG.templates.closeIcon` >
|
|
2203
|
+
* `CNGX_TABS_GLYPHS.closeIcon`.
|
|
2204
|
+
*
|
|
2205
|
+
* ```html
|
|
2206
|
+
* <cngx-tab-group closable (tabClose)="remove($event.id)">
|
|
2207
|
+
* <ng-template cngxTabCloseIcon><cngx-icon name="close" /></ng-template>
|
|
2208
|
+
* ...
|
|
2209
|
+
* </cngx-tab-group>
|
|
2210
|
+
* ```
|
|
2211
|
+
*
|
|
2212
|
+
* @category common/tabs/slots
|
|
2213
|
+
* @wcag AA
|
|
2214
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-close-icon.directive.ts
|
|
2215
|
+
* @since 0.1.0
|
|
2216
|
+
* @relatedTo CngxTabAddIcon, CngxTabGroup
|
|
2217
|
+
* <example-url>http://localhost:4200/#/ui/tabs/tab-dismissable/dismissable-and-addable</example-url>
|
|
2218
|
+
*/
|
|
2219
|
+
class CngxTabCloseIcon {
|
|
2220
|
+
templateRef = inject(TemplateRef);
|
|
2221
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTabCloseIcon, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2222
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxTabCloseIcon, isStandalone: true, selector: "ng-template[cngxTabCloseIcon]", exportAs: ["cngxTabCloseIcon"], ngImport: i0 });
|
|
2223
|
+
}
|
|
2224
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTabCloseIcon, decorators: [{
|
|
2225
|
+
type: Directive,
|
|
2226
|
+
args: [{
|
|
2227
|
+
selector: 'ng-template[cngxTabCloseIcon]',
|
|
2228
|
+
exportAs: 'cngxTabCloseIcon',
|
|
2229
|
+
standalone: true,
|
|
2230
|
+
}]
|
|
2231
|
+
}] });
|
|
2232
|
+
|
|
2233
|
+
/**
|
|
2234
|
+
* Structural slot for the add-tab button glyph. 3-stage cascade:
|
|
2235
|
+
* per-instance directive > `CNGX_TABS_CONFIG.templates.addIcon` >
|
|
2236
|
+
* `CNGX_TABS_GLYPHS.addIcon`. The button owns its `aria-label`; the
|
|
2237
|
+
* template paints only the glyph, so its context is `void`.
|
|
2238
|
+
*
|
|
2239
|
+
* ```html
|
|
2240
|
+
* <cngx-tab-group addable (tabAdd)="add()">
|
|
2241
|
+
* <ng-template cngxTabAddIcon><cngx-icon name="plus" /></ng-template>
|
|
2242
|
+
* ...
|
|
2243
|
+
* </cngx-tab-group>
|
|
2244
|
+
* ```
|
|
2245
|
+
*
|
|
2246
|
+
* @category common/tabs/slots
|
|
2247
|
+
* @wcag AA
|
|
2248
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-add-icon.directive.ts
|
|
2249
|
+
* @since 0.1.0
|
|
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>
|
|
2253
|
+
*/
|
|
2254
|
+
class CngxTabAddIcon {
|
|
2255
|
+
templateRef = inject(TemplateRef);
|
|
2256
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTabAddIcon, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2257
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxTabAddIcon, isStandalone: true, selector: "ng-template[cngxTabAddIcon]", exportAs: ["cngxTabAddIcon"], ngImport: i0 });
|
|
2258
|
+
}
|
|
2259
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTabAddIcon, decorators: [{
|
|
2260
|
+
type: Directive,
|
|
2261
|
+
args: [{
|
|
2262
|
+
selector: 'ng-template[cngxTabAddIcon]',
|
|
2263
|
+
exportAs: 'cngxTabAddIcon',
|
|
2264
|
+
standalone: true,
|
|
2265
|
+
}]
|
|
2266
|
+
}] });
|
|
2267
|
+
|
|
2268
|
+
/**
|
|
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 -
|
|
2275
|
+
* `handleClose` only routes through the presenter's `requestClose`, which
|
|
2276
|
+
* moves the active index, and restores focus once the consumer's removal
|
|
2277
|
+
* has rendered.
|
|
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
|
+
*
|
|
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
|
|
2306
|
+
*/
|
|
2307
|
+
function createTabDismissals(opts) {
|
|
2308
|
+
const resolvedClosable = computed(() => opts.closable() ?? opts.config.closable ?? false, ...(ngDevMode ? [{ debugName: "resolvedClosable" }] : /* istanbul ignore next */ []));
|
|
2309
|
+
const resolvedAddable = computed(() => opts.addable() ?? opts.config.addable ?? false, ...(ngDevMode ? [{ debugName: "resolvedAddable" }] : /* istanbul ignore next */ []));
|
|
2310
|
+
const closeIconContextCache = new WeakMap();
|
|
2311
|
+
const isTabClosable = (tab) => tab.closable() ?? resolvedClosable();
|
|
2312
|
+
const handleClose = (tab, event) => {
|
|
2313
|
+
event?.stopPropagation();
|
|
2314
|
+
if (!isTabClosable(tab)) {
|
|
2315
|
+
return;
|
|
2316
|
+
}
|
|
2317
|
+
opts.host.requestClose(tab.id);
|
|
2318
|
+
// Restore focus once the consumer's removal has rendered: the new
|
|
2319
|
+
// active tab, then the add button, and finally the group element
|
|
2320
|
+
// itself (made programmatically focusable) so focus never falls to
|
|
2321
|
+
// `<body>` when the strip empties with no add button (APG).
|
|
2322
|
+
afterNextRender(() => {
|
|
2323
|
+
const active = opts.hostElement.querySelector('.cngx-tabs__tab[aria-selected="true"]');
|
|
2324
|
+
const add = opts.hostElement.querySelector('.cngx-tabs__add');
|
|
2325
|
+
const target = active ?? add;
|
|
2326
|
+
if (target) {
|
|
2327
|
+
target.focus();
|
|
2328
|
+
return;
|
|
2329
|
+
}
|
|
2330
|
+
opts.hostElement.tabIndex = -1;
|
|
2331
|
+
opts.hostElement.focus();
|
|
2332
|
+
}, { injector: opts.injector });
|
|
2333
|
+
};
|
|
2334
|
+
return {
|
|
2335
|
+
resolvedClosable,
|
|
2336
|
+
resolvedAddable,
|
|
2337
|
+
isTabClosable,
|
|
2338
|
+
closeButtonLabel: (tab) => opts.i18n.closeTab(tab.label() ?? ''),
|
|
2339
|
+
closeIconContextFor: (tab) => {
|
|
2340
|
+
let ctx = closeIconContextCache.get(tab);
|
|
2341
|
+
if (!ctx) {
|
|
2342
|
+
ctx = { tab };
|
|
2343
|
+
closeIconContextCache.set(tab, ctx);
|
|
2344
|
+
}
|
|
2345
|
+
return ctx;
|
|
2346
|
+
},
|
|
2347
|
+
handleClose,
|
|
2348
|
+
handleTabKeydown: (tab, event) => {
|
|
2349
|
+
if (event.key === 'Delete' && isTabClosable(tab)) {
|
|
2350
|
+
event.preventDefault();
|
|
2351
|
+
handleClose(tab);
|
|
2352
|
+
}
|
|
2353
|
+
},
|
|
2354
|
+
handleAdd: () => opts.host.requestAdd(),
|
|
2355
|
+
};
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
/**
|
|
2359
|
+
* Level-2 helper implementing the WAI-ARIA APG tabs keyboard model for
|
|
2360
|
+
* `<cngx-tab-group>` with **automatic activation**: an arrow press moves
|
|
2361
|
+
* focus AND activates the target tab in one step, so focus and selection
|
|
2362
|
+
* never diverge. Keeps the keyboard logic off the organism class (LOC
|
|
2363
|
+
* guard) and out of a competing roving-tabindex state machine.
|
|
2364
|
+
*
|
|
2365
|
+
* Pillar 1 (Ableitung statt Verwaltung): the tab stop is derived from the
|
|
2366
|
+
* presenter's `activeId`, not managed as a second index. Pillar 2
|
|
2367
|
+
* (Kommunikation): activation routes through `host.select()`, which owns
|
|
2368
|
+
* disabled-skip, loop, commit gating, and the live-region announcement -
|
|
2369
|
+
* the keyboard layer adds only focus movement (a DOM concern the
|
|
2370
|
+
* presenter, living in `@cngx/common`, must not own).
|
|
2371
|
+
*
|
|
2372
|
+
* Navigation always originates from the active tab: under automatic
|
|
2373
|
+
* activation the focused tab is always the active one, so the clamped
|
|
2374
|
+
* active index is the correct origin.
|
|
2375
|
+
*
|
|
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
|
|
2380
|
+
*/
|
|
2381
|
+
function createTabKeyboardNav(opts) {
|
|
2382
|
+
const clampedActive = () => {
|
|
2383
|
+
const len = opts.host.tabs().length;
|
|
2384
|
+
if (len === 0) {
|
|
2385
|
+
return 0;
|
|
2386
|
+
}
|
|
2387
|
+
return Math.max(0, Math.min(opts.host.activeIndex(), len - 1));
|
|
2388
|
+
};
|
|
2389
|
+
// Next enabled index in `direction`, honouring `loop`. Mirrors the
|
|
2390
|
+
// presenter's `selectNext`/`selectPrevious` geometry but returns the
|
|
2391
|
+
// resolved index so the caller can both activate and focus it.
|
|
2392
|
+
const step = (direction) => {
|
|
2393
|
+
const tabs = opts.host.tabs();
|
|
2394
|
+
const len = tabs.length;
|
|
2395
|
+
if (len === 0) {
|
|
2396
|
+
return null;
|
|
2397
|
+
}
|
|
2398
|
+
const loop = opts.host.loop();
|
|
2399
|
+
let idx = clampedActive() + direction;
|
|
2400
|
+
for (let i = 0; i < len; i++) {
|
|
2401
|
+
if (loop) {
|
|
2402
|
+
idx = ((idx % len) + len) % len;
|
|
2403
|
+
}
|
|
2404
|
+
else if (idx < 0 || idx >= len) {
|
|
2405
|
+
return null;
|
|
2406
|
+
}
|
|
2407
|
+
if (!tabs[idx].disabled()) {
|
|
2408
|
+
return idx;
|
|
2409
|
+
}
|
|
2410
|
+
idx += direction;
|
|
2411
|
+
}
|
|
2412
|
+
return null;
|
|
2413
|
+
};
|
|
2414
|
+
// First (direction 1) or last (direction -1) enabled tab, for Home/End.
|
|
2415
|
+
const edge = (direction) => {
|
|
2416
|
+
const tabs = opts.host.tabs();
|
|
2417
|
+
const len = tabs.length;
|
|
2418
|
+
if (direction === 1) {
|
|
2419
|
+
for (let i = 0; i < len; i++) {
|
|
2420
|
+
if (!tabs[i].disabled()) {
|
|
2421
|
+
return i;
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
else {
|
|
2426
|
+
for (let i = len - 1; i >= 0; i--) {
|
|
2427
|
+
if (!tabs[i].disabled()) {
|
|
2428
|
+
return i;
|
|
2429
|
+
}
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
return null;
|
|
2433
|
+
};
|
|
2434
|
+
// Focus the tab button for the tab at `index`, keyed off the stable
|
|
2435
|
+
// tab id (the rendered `data-tab-id`) rather than a positional
|
|
2436
|
+
// `.cngx-tabs__tab[index]` lookup - so a skin that reorders or wraps
|
|
2437
|
+
// the tab buttons can't misdirect keyboard focus. `[role="tab"]` is
|
|
2438
|
+
// the APG contract every skin must honour, so it survives a class
|
|
2439
|
+
// rename too. The button already exists regardless of pending CD, so
|
|
2440
|
+
// focus is immediate and never waits on the activation's render.
|
|
2441
|
+
const focusTabAt = (index) => {
|
|
2442
|
+
const id = opts.host.tabs()[index]?.id;
|
|
2443
|
+
if (id == null) {
|
|
2444
|
+
return;
|
|
2445
|
+
}
|
|
2446
|
+
const buttons = Array.from(opts.hostElement.querySelectorAll('[role="tab"]'));
|
|
2447
|
+
buttons.find((button) => button.getAttribute('data-tab-id') === id)?.focus();
|
|
2448
|
+
};
|
|
2449
|
+
return {
|
|
2450
|
+
tabTabindex: (tab) => (tab.id === opts.host.activeId() ? 0 : -1),
|
|
2451
|
+
handleKeydown: (event) => {
|
|
2452
|
+
const horizontal = opts.host.orientation() === 'horizontal';
|
|
2453
|
+
let target;
|
|
2454
|
+
switch (event.key) {
|
|
2455
|
+
case 'ArrowRight':
|
|
2456
|
+
target = horizontal ? step(1) : null;
|
|
2457
|
+
break;
|
|
2458
|
+
case 'ArrowLeft':
|
|
2459
|
+
target = horizontal ? step(-1) : null;
|
|
2460
|
+
break;
|
|
2461
|
+
case 'ArrowDown':
|
|
2462
|
+
target = horizontal ? null : step(1);
|
|
2463
|
+
break;
|
|
2464
|
+
case 'ArrowUp':
|
|
2465
|
+
target = horizontal ? null : step(-1);
|
|
2466
|
+
break;
|
|
2467
|
+
case 'Home':
|
|
2468
|
+
target = edge(1);
|
|
2469
|
+
break;
|
|
2470
|
+
case 'End':
|
|
2471
|
+
target = edge(-1);
|
|
2472
|
+
break;
|
|
2473
|
+
default:
|
|
2474
|
+
return;
|
|
2475
|
+
}
|
|
2476
|
+
if (target === null) {
|
|
2477
|
+
return;
|
|
2478
|
+
}
|
|
2479
|
+
event.preventDefault();
|
|
2480
|
+
// Automatic activation: select first (content + aria-selected +
|
|
2481
|
+
// announcement follow), then move focus to the same tab button.
|
|
2482
|
+
opts.host.select(target);
|
|
2483
|
+
focusTabAt(target);
|
|
2484
|
+
},
|
|
2485
|
+
};
|
|
2486
|
+
}
|
|
2487
|
+
|
|
2488
|
+
/**
|
|
2489
|
+
* Wires the 3-stage template cascade for the `<cngx-tab-group>` skin
|
|
2490
|
+
* slots (errorBadge / rejectionIcon / busySpinner / icon / closeIcon /
|
|
2491
|
+
* addIcon):
|
|
1369
2492
|
* per-instance directive >
|
|
1370
2493
|
* `CNGX_TABS_CONFIG.templates.<key>` >
|
|
1371
|
-
* `null
|
|
2494
|
+
* `null`.
|
|
2495
|
+
*
|
|
2496
|
+
* `null` means the organism renders its built-in default - a default
|
|
2497
|
+
* span for the state decorations, the `CNGX_TABS_GLYPHS` glyph for
|
|
2498
|
+
* `closeIcon` / `addIcon`, and nothing for `icon`.
|
|
1372
2499
|
*
|
|
1373
2500
|
* Pure — no DI, no side effects. Safe in field-init. Sibling to
|
|
1374
2501
|
* `createStepperTemplateBindings` and `createTabOverflowTemplateBindings`.
|
|
@@ -1377,26 +2504,36 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1377
2504
|
* Material owns the rendered tab-button chrome via its own MDC
|
|
1378
2505
|
* template, leaving no DOM seam. See `tabs-accepted-debt §9`.
|
|
1379
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
|
+
*
|
|
1380
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
|
|
1381
2522
|
*/
|
|
1382
2523
|
function createTabGroupTemplateBindings(opts) {
|
|
1383
2524
|
return {
|
|
1384
|
-
errorBadge: computed(() => opts.errorBadgeSlot()?.templateRef ??
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
busySpinner: computed(() => opts.busySpinnerSlot()?.templateRef ??
|
|
1391
|
-
opts.config.templates?.busySpinner ??
|
|
1392
|
-
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),
|
|
2528
|
+
icon: computed(() => opts.iconSlot()?.templateRef ?? opts.config.templates?.icon ?? null),
|
|
2529
|
+
closeIcon: computed(() => opts.closeIconSlot?.()?.templateRef ?? opts.config.templates?.closeIcon ?? null),
|
|
2530
|
+
addIcon: computed(() => opts.addIconSlot?.()?.templateRef ?? opts.config.templates?.addIcon ?? null),
|
|
1393
2531
|
};
|
|
1394
2532
|
}
|
|
1395
2533
|
|
|
1396
2534
|
// Single-consumer factory — staged under family-uniformity
|
|
1397
|
-
// (
|
|
1398
|
-
//
|
|
1399
|
-
// sibling debt closure.
|
|
2535
|
+
// (`createTabGroupTemplateBindings` and `CngxMatTabAggregatorContent`).
|
|
2536
|
+
// Re-eval on second consumer or sibling debt closure.
|
|
1400
2537
|
/**
|
|
1401
2538
|
* Pure factory bundling the `<cngx-tab-group>` AT-announcement +
|
|
1402
2539
|
* descriptor surfaces. Owns one internal `linkedSignal`
|
|
@@ -1404,7 +2541,29 @@ function createTabGroupTemplateBindings(opts) {
|
|
|
1404
2541
|
* lazy by `linkedSignal` semantics, so the organism reads
|
|
1405
2542
|
* `liveAnnouncement` once at construction to seed it.
|
|
1406
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
|
+
*
|
|
1407
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
|
|
1408
2567
|
*/
|
|
1409
2568
|
function createTabGroupAnnouncements(options) {
|
|
1410
2569
|
const { presenter, i18n, config, ariaLabel, ariaLabelledBy } = options;
|
|
@@ -1463,19 +2622,26 @@ function createTabGroupAnnouncements(options) {
|
|
|
1463
2622
|
return '';
|
|
1464
2623
|
}, ...(ngDevMode ? [{ debugName: "liveAnnouncement" }] : /* istanbul ignore next */ []));
|
|
1465
2624
|
function statusPhrase(tab) {
|
|
1466
|
-
|
|
1467
|
-
if (!aggregator?.shouldShow()) {
|
|
2625
|
+
if (!tab.hasError()) {
|
|
1468
2626
|
return '';
|
|
1469
2627
|
}
|
|
1470
|
-
const
|
|
2628
|
+
const aggregator = tab.errorAggregator();
|
|
2629
|
+
const announcement = aggregator?.announcement();
|
|
1471
2630
|
if (announcement) {
|
|
1472
2631
|
return announcement;
|
|
1473
2632
|
}
|
|
1474
|
-
|
|
2633
|
+
const directMessage = tab.errorMessage();
|
|
2634
|
+
if (directMessage) {
|
|
2635
|
+
return directMessage;
|
|
2636
|
+
}
|
|
2637
|
+
return i18n.tabHasErrors(aggregator?.errorCount() ?? 1);
|
|
1475
2638
|
}
|
|
1476
2639
|
function tabAriaLabel(tab, position) {
|
|
1477
2640
|
const tabs = presenter.tabs();
|
|
1478
|
-
|
|
2641
|
+
const label = tab.label() ?? '';
|
|
2642
|
+
const detail = tab.subLabel();
|
|
2643
|
+
const labelPart = detail ? i18n.tabLabelWithDetail(label, detail) : label;
|
|
2644
|
+
return i18n.selectedTab(labelPart, position, tabs.length);
|
|
1479
2645
|
}
|
|
1480
2646
|
// Eager seed — `linkedSignal` is lazy and the success arm doesn't
|
|
1481
2647
|
// touch the tracker at construction (commitTransition is `idle`),
|
|
@@ -1509,10 +2675,14 @@ const CNGX_TABS_GLYPHS = {
|
|
|
1509
2675
|
errorBadge: '!',
|
|
1510
2676
|
/** Default visual for `*cngxTabRejectionIcon` when no override is bound. */
|
|
1511
2677
|
rejectionIcon: '!',
|
|
2678
|
+
/** Default visual for a tab's close button when no override is bound. */
|
|
2679
|
+
closeIcon: '×',
|
|
2680
|
+
/** Default visual for the add-tab button when no override is bound. */
|
|
2681
|
+
addIcon: '+',
|
|
1512
2682
|
};
|
|
1513
2683
|
|
|
1514
2684
|
/**
|
|
1515
|
-
* 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. \
|
|
1516
2686
|
* Stable across CD passes so `aria-activedescendant` resolves to
|
|
1517
2687
|
* the same `<li>`. `-overflow-option` suffix avoids collision with
|
|
1518
2688
|
* the strip-button (`-header`) and per-tab descriptor (`-desc`).
|
|
@@ -1557,9 +2727,9 @@ function adItemsEqual(a, b) {
|
|
|
1557
2727
|
}
|
|
1558
2728
|
/**
|
|
1559
2729
|
* Wires the 3-stage template cascade for the overflow molecule's
|
|
1560
|
-
* two visible regions:
|
|
1561
|
-
* `CNGX_TABS_CONFIG.templates.overflow*` > built-in markup
|
|
1562
|
-
* (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`). \
|
|
1563
2733
|
*
|
|
1564
2734
|
* Pure - no DI, no side effects, no destroy hooks. Safe to call
|
|
1565
2735
|
* from a component's field-init block. Mirrors the select-family
|
|
@@ -1607,16 +2777,28 @@ function createTabOverflowTemplateBindings(opts) {
|
|
|
1607
2777
|
};
|
|
1608
2778
|
}
|
|
1609
2779
|
/**
|
|
1610
|
-
* Resets the AD highlight on popover close.
|
|
2780
|
+
* Resets the AD highlight on popover close. \
|
|
2781
|
+
* Keyboard-open paths
|
|
1611
2782
|
* (ArrowDown / End / typeahead on the closed trigger) set
|
|
1612
2783
|
* `activeIndex` via AD's own keydown listener before opening -
|
|
1613
2784
|
* unaffected. Mouse-open leaves `activeIndex === -1` so the popover
|
|
1614
|
-
* renders unhighlighted.
|
|
2785
|
+
* renders unhighlighted. \
|
|
2786
|
+
* Without this reset, the next open would
|
|
1615
2787
|
* inherit a stale index from the prior keyboard session.
|
|
1616
2788
|
*
|
|
1617
|
-
* 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.
|
|
1618
2799
|
*
|
|
1619
2800
|
* @category common/tabs/overflow
|
|
2801
|
+
* @wcag AA
|
|
1620
2802
|
*/
|
|
1621
2803
|
function createOverflowPopoverHighlightSync(popover, ad) {
|
|
1622
2804
|
effect(() => {
|
|
@@ -1629,12 +2811,13 @@ function createOverflowPopoverHighlightSync(popover, ad) {
|
|
|
1629
2811
|
});
|
|
1630
2812
|
}
|
|
1631
2813
|
/**
|
|
1632
|
-
* DI token for the overflow popover highlight-sync policy.
|
|
2814
|
+
* DI token for the overflow popover highlight-sync policy. \
|
|
1633
2815
|
* Default {@link createOverflowPopoverHighlightSync}. Override via
|
|
1634
2816
|
* `providers` / `viewProviders` for last-index preservation,
|
|
1635
|
-
* telemetry on close, custom highlight rules.
|
|
1636
|
-
*
|
|
1637
|
-
* `
|
|
2817
|
+
* telemetry on close, custom highlight rules. \
|
|
2818
|
+
* Symmetric to
|
|
2819
|
+
* - `CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY` and
|
|
2820
|
+
* - `CNGX_TABS_COMMIT_HANDLER_FACTORY`.
|
|
1638
2821
|
*
|
|
1639
2822
|
* @category common/tabs/overflow
|
|
1640
2823
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/overflow/overflow-template-cascade.ts
|
|
@@ -1652,13 +2835,41 @@ const DEFAULT_SCROLL_OPTIONS = {
|
|
|
1652
2835
|
};
|
|
1653
2836
|
/**
|
|
1654
2837
|
* Scroll-into-view effect for any strip-based organism (tabs,
|
|
1655
|
-
* stepper headers, future scrolling lists).
|
|
1656
|
-
* 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.
|
|
1657
2840
|
*
|
|
1658
|
-
* The DOM call sits in `untracked()` (only `activeId` is tracked).
|
|
2841
|
+
* The DOM call sits in `untracked()` (only `activeId` is tracked). \
|
|
1659
2842
|
* `scrollIntoView` is missing in jsdom - guarded with optional chain.
|
|
1660
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
|
+
*
|
|
1661
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
|
|
1662
2873
|
*/
|
|
1663
2874
|
function createOrganismScrollSync(opts) {
|
|
1664
2875
|
const { activeId, hostElement, scrollOptions, injector } = opts;
|
|
@@ -1677,15 +2888,37 @@ function createOrganismScrollSync(opts) {
|
|
|
1677
2888
|
});
|
|
1678
2889
|
}
|
|
1679
2890
|
/**
|
|
1680
|
-
* DI token for the active-item scroll-into-view policy.
|
|
1681
|
-
* {@link createOrganismScrollSync}
|
|
1682
|
-
*
|
|
1683
|
-
*
|
|
1684
|
-
*
|
|
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
|
+
* ```
|
|
1685
2916
|
*
|
|
1686
2917
|
* @category common/tabs/scroll-sync
|
|
2918
|
+
* @wcag AA
|
|
1687
2919
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/scroll-sync/organism-scroll-sync.ts
|
|
1688
2920
|
* @since 0.1.0
|
|
2921
|
+
* @relatedTo createOrganismScrollSync, CngxOrganismScrollSyncFactory
|
|
1689
2922
|
*/
|
|
1690
2923
|
const CNGX_ORGANISM_SCROLL_SYNC_FACTORY = new InjectionToken('CngxOrganismScrollSyncFactory', {
|
|
1691
2924
|
providedIn: 'root',
|
|
@@ -1730,11 +2963,12 @@ function createDirectiveByIdMap(opts) {
|
|
|
1730
2963
|
}, { equal: directiveMapEqual });
|
|
1731
2964
|
}
|
|
1732
2965
|
/**
|
|
1733
|
-
* DI token for the per-id directive-resolution policy.
|
|
1734
|
-
* {@link createDirectiveByIdMap}. Override for WeakMap resolution,
|
|
1735
|
-
* telemetry, or custom equality.
|
|
1736
|
-
*
|
|
1737
|
-
* `
|
|
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`.
|
|
1738
2972
|
*
|
|
1739
2973
|
* @category common/tabs/registry
|
|
1740
2974
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/registry/directive-by-id-map.ts
|
|
@@ -1753,5 +2987,5 @@ const CNGX_DIRECTIVE_BY_ID_MAP_FACTORY = new InjectionToken('CngxDirectiveByIdMa
|
|
|
1753
2987
|
* Generated bundle index. Do not edit.
|
|
1754
2988
|
*/
|
|
1755
2989
|
|
|
1756
|
-
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_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, CngxTabBusySpinner, CngxTabContent, CngxTabErrorBadge, CngxTabGroupPresenter, CngxTabLabel, CngxTabOverflowItem, CngxTabOverflowTrigger, CngxTabRejectionIcon, CngxTabsFragmentSync, createCngxTabOverflowDefaultDomAdapter, createDirectiveByIdMap, createDomAnchorRetry, createOrganismScrollSync, createOverflowPopoverHighlightSync, createTabGroupAnnouncements, createTabGroupTemplateBindings, createTabOverflowTemplateBindings, createTabsCommitHandler, injectTabsConfig, injectTabsI18n, provideCngxTabs, provideCngxTabsAt, provideTabsConfig, provideTabsConfigAt, provideTabsI18n, tabOverflowOptionId, withDefaultOrientation, withTabBusySpinnerTemplate, withTabErrorBadgeTemplate, withTabOverflowItemTemplate, withTabOverflowMaxDeferMs, withTabOverflowStabilizeMs, withTabOverflowTriggerTemplate, withTabRejectionIconTemplate, withTabsAriaLabels, withTabsCommitMode, withTabsDefaultOrientation, withTabsFallbackLabels, withTabsI18nLabels, withTabsRouterSync, withTabsRovingLoop };
|
|
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 };
|
|
1757
2991
|
//# sourceMappingURL=cngx-common-tabs.mjs.map
|