@cngx/common 0.0.1-rc.0 → 0.1.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/a11y/README.md +13 -16
- package/card/README.md +2 -21
- package/chart/README.md +5 -8
- package/data/README.md +45 -47
- package/dialog/README.md +12 -15
- package/display/README.md +5 -9
- package/fesm2022/cngx-common-a11y.mjs +140 -40
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-card.mjs +157 -69
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +389 -92
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +311 -151
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +167 -29
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +445 -110
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +2025 -435
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +188 -31
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-popover.mjs +711 -90
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +1258 -60
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +247 -41
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +2 -2
- package/fesm2022/cngx-common.mjs.map +1 -1
- package/interactive/README.md +5 -5
- package/layout/README.md +2 -2
- package/package.json +5 -4
- package/popover/README.md +8 -34
- package/stepper/README.md +49 -8
- package/tabs/README.md +6 -6
- package/theming/components/cngx-async.css +74 -0
- package/theming/components/cngx-backdrop.css +73 -0
- package/theming/components/cngx-badge.css +340 -0
- package/theming/components/cngx-bottom-sheet.css +201 -0
- package/theming/components/cngx-button-toggle.css +99 -0
- package/theming/components/cngx-dialog.css +358 -0
- package/theming/components/cngx-divider.css +145 -0
- package/theming/components/cngx-listbox.css +220 -0
- package/theming/components/cngx-menu.css +371 -0
- package/theming/components/cngx-ripple.css +116 -0
- package/theming/components/cngx-tooltip.css +265 -0
- package/theming/system-tokens.css +24 -0
- package/types/cngx-common-a11y.d.ts +136 -36
- package/types/cngx-common-card.d.ts +137 -22
- package/types/cngx-common-chart.d.ts +337 -40
- package/types/cngx-common-data.d.ts +277 -45
- package/types/cngx-common-dialog.d.ts +162 -22
- package/types/cngx-common-display.d.ts +422 -78
- package/types/cngx-common-interactive.d.ts +1862 -305
- package/types/cngx-common-layout.d.ts +191 -28
- package/types/cngx-common-popover.d.ts +632 -87
- package/types/cngx-common-stepper.d.ts +1110 -38
- package/types/cngx-common-tabs.d.ts +306 -32
- package/types/cngx-common.d.ts +1 -1
- package/README.md +0 -18
|
@@ -11,6 +11,8 @@ import { filter } from 'rxjs/operators';
|
|
|
11
11
|
* Wraps a {@link CngxCommitController} with the action-shape adapter
|
|
12
12
|
* that collapses `Observable<boolean>` / `Promise<boolean>` /
|
|
13
13
|
* `boolean` returns into a single `accept: boolean` outcome.
|
|
14
|
+
*
|
|
15
|
+
* @category common/tabs
|
|
14
16
|
*/
|
|
15
17
|
function createTabsCommitHandler(opts) {
|
|
16
18
|
const { controller } = opts;
|
|
@@ -61,7 +63,7 @@ function runTabsAction(action, fromIndex, toIndex, handlers) {
|
|
|
61
63
|
}
|
|
62
64
|
if (isObservable(result)) {
|
|
63
65
|
// Synchronous Observables (`of(true)`) emit inside `.subscribe` before
|
|
64
|
-
// the assignment binds
|
|
66
|
+
// the assignment binds - close over a pre-declared `let` to avoid TDZ.
|
|
65
67
|
let sub = null;
|
|
66
68
|
sub = result.subscribe({
|
|
67
69
|
next: (accept) => {
|
|
@@ -72,8 +74,7 @@ function runTabsAction(action, fromIndex, toIndex, handlers) {
|
|
|
72
74
|
});
|
|
73
75
|
unsubscribe = () => sub?.unsubscribe();
|
|
74
76
|
}
|
|
75
|
-
else if (result != null &&
|
|
76
|
-
typeof result.then === 'function') {
|
|
77
|
+
else if (result != null && typeof result.then === 'function') {
|
|
77
78
|
result.then(safeSuccess, safeError);
|
|
78
79
|
}
|
|
79
80
|
else {
|
|
@@ -91,6 +92,10 @@ function runTabsAction(action, fromIndex, toIndex, handlers) {
|
|
|
91
92
|
* {@link createTabsCommitHandler}. Sibling to
|
|
92
93
|
* `CNGX_ARRAY_COMMIT_HANDLER_FACTORY` (select) and
|
|
93
94
|
* `CNGX_STEPPER_COMMIT_HANDLER_FACTORY`.
|
|
95
|
+
*
|
|
96
|
+
* @category common/tabs
|
|
97
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/commit-handler.ts
|
|
98
|
+
* @since 0.1.0
|
|
94
99
|
*/
|
|
95
100
|
const CNGX_TABS_COMMIT_HANDLER_FACTORY = new InjectionToken('CngxTabsCommitHandlerFactory', {
|
|
96
101
|
providedIn: 'root',
|
|
@@ -101,20 +106,33 @@ const CNGX_TABS_COMMIT_HANDLER_FACTORY = new InjectionToken('CngxTabsCommitHandl
|
|
|
101
106
|
* DI token for the tab presenter's contract. Presenter provides via
|
|
102
107
|
* `useExisting`; `CngxTab` injects to register; the organism injects
|
|
103
108
|
* to forward keyboard nav from `CngxRovingTabindex`.
|
|
109
|
+
*
|
|
110
|
+
* @category common/tabs
|
|
111
|
+
* @wcag AA
|
|
112
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/tab-group-host.token.ts
|
|
113
|
+
* @since 0.1.0
|
|
104
114
|
*/
|
|
105
115
|
const CNGX_TAB_GROUP_HOST = new InjectionToken('CngxTabGroupHost');
|
|
106
116
|
|
|
107
117
|
/**
|
|
108
|
-
* Tab-group presenter
|
|
118
|
+
* Tab-group presenter - brain of every cngx tab flow. Owns the
|
|
109
119
|
* active-index model, the tab registry, orientation, loop policy,
|
|
110
120
|
* and the commit-controller lifecycle. Provides
|
|
111
121
|
* {@link CNGX_TAB_GROUP_HOST} for atoms and {@link CNGX_STATEFUL}
|
|
112
122
|
* so `<cngx-toast-on />` / `<cngx-banner-on />` compose without
|
|
113
123
|
* `[state]` wiring.
|
|
114
124
|
*
|
|
115
|
-
* **Layer:** `@cngx/common/tabs` (Level 2). Directive-only
|
|
125
|
+
* **Layer:** `@cngx/common/tabs` (Level 2). Directive-only -
|
|
116
126
|
* organisms compose via `hostDirectives`, consumers attach
|
|
117
127
|
* `[cngxTabGroup]` directly.
|
|
128
|
+
*
|
|
129
|
+
* @category common/tabs
|
|
130
|
+
* @docsKind primary
|
|
131
|
+
* @wcag AA
|
|
132
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/presenter.directive.ts
|
|
133
|
+
* @since 0.1.0
|
|
134
|
+
* @relatedTo CngxTab, CngxTabContent, CngxTabLabel, CngxTabsFragmentSync
|
|
135
|
+
* <example-url>http://localhost:4200/#/ui/tabs/tab-commit-action/optimistic-pessimistic-commits-with-bridge-directives</example-url>
|
|
118
136
|
*/
|
|
119
137
|
class CngxTabGroupPresenter {
|
|
120
138
|
activeIndex = model(0, ...(ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []));
|
|
@@ -124,12 +142,12 @@ class CngxTabGroupPresenter {
|
|
|
124
142
|
* Async-commit action gating the transition. When non-null,
|
|
125
143
|
* `select(...)` routes through {@link CngxTabsCommitHandler}; the
|
|
126
144
|
* action's resolution decides whether the change lands. Supersede
|
|
127
|
-
* semantics come from the commit-controller
|
|
145
|
+
* semantics come from the commit-controller - a rapid second
|
|
128
146
|
* `select(...)` cancels the in-flight runner.
|
|
129
147
|
*/
|
|
130
148
|
commitAction = input(null, ...(ngDevMode ? [{ debugName: "commitAction" }] : /* istanbul ignore next */ []));
|
|
131
149
|
/**
|
|
132
|
-
* Default `'optimistic'`
|
|
150
|
+
* Default `'optimistic'` - tab change is navigation, not a save,
|
|
133
151
|
* so eager visual feedback matches the user's mental model.
|
|
134
152
|
* Switch to `'pessimistic'` when the new tab must wait for the
|
|
135
153
|
* action to confirm.
|
|
@@ -137,7 +155,9 @@ class CngxTabGroupPresenter {
|
|
|
137
155
|
commitMode = input('optimistic', ...(ngDevMode ? [{ debugName: "commitMode" }] : /* istanbul ignore next */ []));
|
|
138
156
|
genericFactory = inject(CNGX_COMMIT_CONTROLLER_FACTORY);
|
|
139
157
|
commitController = this.genericFactory();
|
|
140
|
-
commitHandler = inject(CNGX_TABS_COMMIT_HANDLER_FACTORY)({
|
|
158
|
+
commitHandler = inject(CNGX_TABS_COMMIT_HANDLER_FACTORY)({
|
|
159
|
+
controller: this.commitController,
|
|
160
|
+
});
|
|
141
161
|
/** Producer surface for the `CNGX_STATEFUL` bridge contract. */
|
|
142
162
|
state = this.commitController.state;
|
|
143
163
|
commitState = this.commitController.state;
|
|
@@ -154,7 +174,7 @@ class CngxTabGroupPresenter {
|
|
|
154
174
|
* the tracker's `linkedSignal` is allocated once per presenter.
|
|
155
175
|
*/
|
|
156
176
|
commitTransition = createTransitionTracker(() => this.commitController.state.status());
|
|
157
|
-
// Persistence-of-error surface
|
|
177
|
+
// Persistence-of-error surface - see `CngxTabGroupHost.lastFailedIndex`
|
|
158
178
|
// and `originIndexDuringCommit` for the contract.
|
|
159
179
|
lastFailedIndexState = signal(undefined, ...(ngDevMode ? [{ debugName: "lastFailedIndexState" }] : /* istanbul ignore next */ []));
|
|
160
180
|
originIndexDuringCommitState = signal(undefined, ...(ngDevMode ? [{ debugName: "originIndexDuringCommitState" }] : /* istanbul ignore next */ []));
|
|
@@ -209,7 +229,7 @@ class CngxTabGroupPresenter {
|
|
|
209
229
|
}
|
|
210
230
|
const action = this.commitAction();
|
|
211
231
|
if (!action) {
|
|
212
|
-
// No-action fast path
|
|
232
|
+
// No-action fast path - `originIndexDuringCommit` stays
|
|
213
233
|
// untouched, so a stale origin can never leak into the
|
|
214
234
|
// live-region announcement.
|
|
215
235
|
this.activeIndex.set(target);
|
|
@@ -218,7 +238,7 @@ class CngxTabGroupPresenter {
|
|
|
218
238
|
}
|
|
219
239
|
return;
|
|
220
240
|
}
|
|
221
|
-
// Open the commit window
|
|
241
|
+
// Open the commit window - origin is captured ONLY here so a
|
|
222
242
|
// stale value never lingers into a non-commit navigation.
|
|
223
243
|
this.originIndexDuringCommitState.set(previous);
|
|
224
244
|
const mode = this.commitMode();
|
|
@@ -227,7 +247,7 @@ class CngxTabGroupPresenter {
|
|
|
227
247
|
}
|
|
228
248
|
this.commitHandler.beginTransition(previous, target, action, (accept) => {
|
|
229
249
|
if (accept) {
|
|
230
|
-
// Window closes on success
|
|
250
|
+
// Window closes on success - origin label no longer needed;
|
|
231
251
|
// clear the rejection flag if the user re-picked the failed
|
|
232
252
|
// target successfully.
|
|
233
253
|
this.originIndexDuringCommitState.set(undefined);
|
|
@@ -239,7 +259,7 @@ class CngxTabGroupPresenter {
|
|
|
239
259
|
}
|
|
240
260
|
}
|
|
241
261
|
else {
|
|
242
|
-
// Reject
|
|
262
|
+
// Reject - flag the refused target; RETAIN the origin so
|
|
243
263
|
// the organism's `liveAnnouncement` computed can resolve
|
|
244
264
|
// the origin label for the rich rollback phrase. Optimistic
|
|
245
265
|
// rolls back; pessimistic never moved.
|
|
@@ -330,7 +350,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
330
350
|
* memoisation burden onto consumers and break the structural-equal
|
|
331
351
|
* contract.
|
|
332
352
|
*
|
|
333
|
-
* Reading `disabled()` and `label()` here doesn't subscribe
|
|
353
|
+
* Reading `disabled()` and `label()` here doesn't subscribe - the
|
|
334
354
|
* comparator runs synchronously inside `signal.set()`, outside any
|
|
335
355
|
* tracking context.
|
|
336
356
|
*
|
|
@@ -357,6 +377,11 @@ function tabsEqual(a, b) {
|
|
|
357
377
|
* DI token the organism provides via `useExisting`. The overflow
|
|
358
378
|
* molecule and consumer-authored skin sub-components inject this
|
|
359
379
|
* instead of the concrete component class.
|
|
380
|
+
*
|
|
381
|
+
* @category common/tabs
|
|
382
|
+
* @wcag AA
|
|
383
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/tab-panel-host.token.ts
|
|
384
|
+
* @since 0.1.0
|
|
360
385
|
*/
|
|
361
386
|
const CNGX_TAB_PANEL_HOST = new InjectionToken('CngxTabPanelHost');
|
|
362
387
|
|
|
@@ -373,6 +398,20 @@ const CNGX_TAB_PANEL_HOST = new InjectionToken('CngxTabPanelHost');
|
|
|
373
398
|
* </ng-template>
|
|
374
399
|
* </div>
|
|
375
400
|
* ```
|
|
401
|
+
*
|
|
402
|
+
* @category common/tabs
|
|
403
|
+
* @wcag AA
|
|
404
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/tab-content.directive.ts
|
|
405
|
+
* @since 0.1.0
|
|
406
|
+
* @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>
|
|
376
415
|
*/
|
|
377
416
|
class CngxTabContent {
|
|
378
417
|
templateRef = inject((TemplateRef));
|
|
@@ -399,6 +438,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
399
438
|
* <ng-template cngxTabContent>...</ng-template>
|
|
400
439
|
* </div>
|
|
401
440
|
* ```
|
|
441
|
+
*
|
|
442
|
+
* @category common/tabs
|
|
443
|
+
* @wcag AA
|
|
444
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/tab-label.directive.ts
|
|
445
|
+
* @since 0.1.0
|
|
446
|
+
* @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>
|
|
402
449
|
*/
|
|
403
450
|
class CngxTabLabel {
|
|
404
451
|
templateRef = inject((TemplateRef));
|
|
@@ -420,7 +467,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
420
467
|
* {@link DestroyRef} on teardown. The presenter holds the atom's
|
|
421
468
|
* input signals by reference, so input changes propagate without
|
|
422
469
|
* re-registration. `labelTemplate` / `contentTemplate` are projected
|
|
423
|
-
* by the organism
|
|
470
|
+
* by the organism - the atom carries no rendering logic.
|
|
471
|
+
*
|
|
472
|
+
* @category common/tabs
|
|
473
|
+
* @docsKind primary
|
|
474
|
+
* @wcag AA
|
|
475
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/tab.directive.ts
|
|
476
|
+
* @since 0.1.0
|
|
477
|
+
* @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>
|
|
424
486
|
*/
|
|
425
487
|
class CngxTab {
|
|
426
488
|
id = input(nextUid('cngx-tab-'), ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
@@ -466,9 +528,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
466
528
|
* - `mode = 'fragment'` (default) → `#tab=settings`
|
|
467
529
|
* - `mode = 'queryParam'` with `paramName = 'tab'` → `?tab=settings`
|
|
468
530
|
*
|
|
469
|
-
* `Router` is optional
|
|
531
|
+
* `Router` is optional - without it the directive logs a dev warning
|
|
470
532
|
* via `afterNextRender` and becomes a no-op. Every `router.navigate`
|
|
471
533
|
* and `host.selectById` inside the effects sits in `untracked()`.
|
|
534
|
+
*
|
|
535
|
+
* @category common/tabs
|
|
536
|
+
* @docsKind primary
|
|
537
|
+
* @wcag AA
|
|
538
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/router-sync.directive.ts
|
|
539
|
+
* @since 0.1.0
|
|
540
|
+
* @relatedTo CngxTabGroupPresenter, CngxTab
|
|
472
541
|
*/
|
|
473
542
|
class CngxTabsFragmentSync {
|
|
474
543
|
mode = input('fragment', ...(ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []));
|
|
@@ -478,7 +547,7 @@ class CngxTabsFragmentSync {
|
|
|
478
547
|
constructor() {
|
|
479
548
|
if (!this.router) {
|
|
480
549
|
afterNextRender(() => {
|
|
481
|
-
console.warn('CngxTabsFragmentSync: no Router available
|
|
550
|
+
console.warn('CngxTabsFragmentSync: no Router available - directive is a no-op. ' +
|
|
482
551
|
'Provide @angular/router via provideRouter(...) to enable deep-linking.');
|
|
483
552
|
});
|
|
484
553
|
return;
|
|
@@ -531,8 +600,7 @@ class CngxTabsFragmentSync {
|
|
|
531
600
|
const fragment = router.routerState.snapshot.root.fragment ?? '';
|
|
532
601
|
return this.parseFragment(fragment);
|
|
533
602
|
}
|
|
534
|
-
return
|
|
535
|
-
null);
|
|
603
|
+
return router.routerState.snapshot.root.queryParamMap.get(this.paramName()) ?? null;
|
|
536
604
|
}
|
|
537
605
|
parseFragment(fragment) {
|
|
538
606
|
const param = this.paramName();
|
|
@@ -567,7 +635,7 @@ const TABS_CONFIG_DEFAULTS = {
|
|
|
567
635
|
tabsRegion: 'Tabs',
|
|
568
636
|
},
|
|
569
637
|
fallbackLabels: {
|
|
570
|
-
// W3C ARIA tablist convention
|
|
638
|
+
// W3C ARIA tablist convention - kept distinct from
|
|
571
639
|
// `i18n.tabsLabel` so AT doesn't read the same string twice
|
|
572
640
|
// back-to-back across `aria-roledescription` and `aria-label`.
|
|
573
641
|
tabRoleDescription: 'tab list',
|
|
@@ -581,8 +649,16 @@ const TABS_CONFIG_DEFAULTS = {
|
|
|
581
649
|
* DI token for the resolved tabs config. `providedIn: 'root'` with
|
|
582
650
|
* the library defaults; override via {@link provideTabsConfig}
|
|
583
651
|
* (root) or {@link provideTabsConfigAt} (component scope).
|
|
652
|
+
*
|
|
653
|
+
* @category common/tabs
|
|
654
|
+
* @wcag AA
|
|
655
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/tabs-config.ts
|
|
656
|
+
* @since 0.1.0
|
|
584
657
|
*/
|
|
585
|
-
const CNGX_TABS_CONFIG = new InjectionToken('CngxTabsConfig', {
|
|
658
|
+
const CNGX_TABS_CONFIG = new InjectionToken('CngxTabsConfig', {
|
|
659
|
+
providedIn: 'root',
|
|
660
|
+
factory: () => TABS_CONFIG_DEFAULTS,
|
|
661
|
+
});
|
|
586
662
|
/**
|
|
587
663
|
* Internal helper that brands a config-mutator function with the
|
|
588
664
|
* `_target` discriminator. Every `with*` config feature returns one
|
|
@@ -596,6 +672,8 @@ function defineTabsConfigFeature(fn) {
|
|
|
596
672
|
/**
|
|
597
673
|
* Override the default orientation. Per-instance `[orientation]`
|
|
598
674
|
* still wins; this changes the cascade default only.
|
|
675
|
+
*
|
|
676
|
+
* @category common/tabs
|
|
599
677
|
*/
|
|
600
678
|
function withTabsDefaultOrientation(orientation) {
|
|
601
679
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -608,11 +686,15 @@ function withTabsDefaultOrientation(orientation) {
|
|
|
608
686
|
* collides with the stepper family's identical symbol when both libs
|
|
609
687
|
* are auto-imported. The alias stays for one minor release before
|
|
610
688
|
* removal.
|
|
689
|
+
*
|
|
690
|
+
* @category common/tabs
|
|
611
691
|
*/
|
|
612
692
|
const withDefaultOrientation = withTabsDefaultOrientation;
|
|
613
693
|
/**
|
|
614
694
|
* Override whether roving-tabindex navigation loops from last back to
|
|
615
695
|
* first (and vice versa). Per-instance `[loop]` Input still wins.
|
|
696
|
+
*
|
|
697
|
+
* @category common/tabs
|
|
616
698
|
*/
|
|
617
699
|
function withTabsRovingLoop(loop) {
|
|
618
700
|
return defineTabsConfigFeature((cfg) => ({ ...cfg, defaultLoop: loop }));
|
|
@@ -622,6 +704,8 @@ function withTabsRovingLoop(loop) {
|
|
|
622
704
|
* `'optimistic'` activates the tab on action dispatch and rolls back
|
|
623
705
|
* on error; `'pessimistic'` waits for success. Per-instance
|
|
624
706
|
* `[commitMode]` Input still wins.
|
|
707
|
+
*
|
|
708
|
+
* @category common/tabs
|
|
625
709
|
*/
|
|
626
710
|
function withTabsCommitMode(mode) {
|
|
627
711
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -633,6 +717,8 @@ function withTabsCommitMode(mode) {
|
|
|
633
717
|
* Configure router synchronisation for the active tab. `mode` chooses
|
|
634
718
|
* the URL surface (URL fragment or query parameter); `param` names
|
|
635
719
|
* the key (default `'tab'`).
|
|
720
|
+
*
|
|
721
|
+
* @category common/tabs
|
|
636
722
|
*/
|
|
637
723
|
function withTabsRouterSync(mode, param = 'tab') {
|
|
638
724
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -644,6 +730,8 @@ function withTabsRouterSync(mode, param = 'tab') {
|
|
|
644
730
|
/**
|
|
645
731
|
* Merge ARIA labels into the cascade. Keys not provided keep their
|
|
646
732
|
* library defaults; per-instance overrides on the tab group still win.
|
|
733
|
+
*
|
|
734
|
+
* @category common/tabs
|
|
647
735
|
*/
|
|
648
736
|
function withTabsAriaLabels(labels) {
|
|
649
737
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -654,6 +742,8 @@ function withTabsAriaLabels(labels) {
|
|
|
654
742
|
/**
|
|
655
743
|
* Merge text fallback labels (overflow trigger, busy / rejection text)
|
|
656
744
|
* into the cascade. Used when a slot directive is not present.
|
|
745
|
+
*
|
|
746
|
+
* @category common/tabs
|
|
657
747
|
*/
|
|
658
748
|
function withTabsFallbackLabels(labels) {
|
|
659
749
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -664,6 +754,8 @@ function withTabsFallbackLabels(labels) {
|
|
|
664
754
|
/**
|
|
665
755
|
* Override the IO-debounce window (ms). See
|
|
666
756
|
* {@link CngxTabsConfig.overflowStabilizeMs}.
|
|
757
|
+
*
|
|
758
|
+
* @category common/tabs
|
|
667
759
|
*/
|
|
668
760
|
function withTabOverflowStabilizeMs(ms) {
|
|
669
761
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -674,6 +766,8 @@ function withTabOverflowStabilizeMs(ms) {
|
|
|
674
766
|
/**
|
|
675
767
|
* Override the worst-case staleness ceiling on the visibility-map
|
|
676
768
|
* commit. See {@link CngxTabsConfig.overflowMaxDeferMs}.
|
|
769
|
+
*
|
|
770
|
+
* @category common/tabs
|
|
677
771
|
*/
|
|
678
772
|
function withTabOverflowMaxDeferMs(ms) {
|
|
679
773
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -691,6 +785,8 @@ function withTabOverflowMaxDeferMs(ms) {
|
|
|
691
785
|
*
|
|
692
786
|
* providers: [provideTabsConfig(withTabOverflowTriggerTemplate(this.moreTrigger))]
|
|
693
787
|
* ```
|
|
788
|
+
*
|
|
789
|
+
* @category common/tabs
|
|
694
790
|
*/
|
|
695
791
|
function withTabOverflowTriggerTemplate(template) {
|
|
696
792
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -701,6 +797,8 @@ function withTabOverflowTriggerTemplate(template) {
|
|
|
701
797
|
/**
|
|
702
798
|
* App-wide override for each row inside the overflow popover.
|
|
703
799
|
* Middle tier; per-instance `*cngxTabOverflowItem` still wins.
|
|
800
|
+
*
|
|
801
|
+
* @category common/tabs
|
|
704
802
|
*/
|
|
705
803
|
function withTabOverflowItemTemplate(template) {
|
|
706
804
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -712,6 +810,8 @@ function withTabOverflowItemTemplate(template) {
|
|
|
712
810
|
* App-wide override for the error-badge decoration. Middle tier;
|
|
713
811
|
* per-instance `*cngxTabErrorBadge` still wins. Sibling of the
|
|
714
812
|
* stepper family's `withStepBadgeTemplate`.
|
|
813
|
+
*
|
|
814
|
+
* @category common/tabs
|
|
715
815
|
*/
|
|
716
816
|
function withTabErrorBadgeTemplate(template) {
|
|
717
817
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -723,6 +823,8 @@ function withTabErrorBadgeTemplate(template) {
|
|
|
723
823
|
* App-wide override for the rejection-icon decoration. Middle
|
|
724
824
|
* tier; per-instance `*cngxTabRejectionIcon` still wins. Sibling
|
|
725
825
|
* of {@link withStepRejectionTemplate}.
|
|
826
|
+
*
|
|
827
|
+
* @category common/tabs
|
|
726
828
|
*/
|
|
727
829
|
function withTabRejectionIconTemplate(template) {
|
|
728
830
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -734,6 +836,8 @@ function withTabRejectionIconTemplate(template) {
|
|
|
734
836
|
* App-wide override for the commit-pending busy-spinner overlay.
|
|
735
837
|
* Middle tier; per-instance `*cngxTabBusySpinner` still wins.
|
|
736
838
|
* Sibling of {@link withStepBusySpinnerTemplate}.
|
|
839
|
+
*
|
|
840
|
+
* @category common/tabs
|
|
737
841
|
*/
|
|
738
842
|
function withTabBusySpinnerTemplate(template) {
|
|
739
843
|
return defineTabsConfigFeature((cfg) => ({
|
|
@@ -748,6 +852,8 @@ function resolveFeatures(features) {
|
|
|
748
852
|
* Root-level provider. Apply once in `bootstrapApplication` /
|
|
749
853
|
* `appConfig.providers`. Returns {@link EnvironmentProviders} per
|
|
750
854
|
* the canonical cngx config-cascade signature.
|
|
855
|
+
*
|
|
856
|
+
* @category common/tabs
|
|
751
857
|
*/
|
|
752
858
|
function provideTabsConfig(...features) {
|
|
753
859
|
return makeEnvironmentProviders([
|
|
@@ -765,12 +871,16 @@ function provideTabsConfig(...features) {
|
|
|
765
871
|
* viewProviders: [...provideTabsConfigAt(withTabsDefaultOrientation('vertical'))],
|
|
766
872
|
* })
|
|
767
873
|
* ```
|
|
874
|
+
*
|
|
875
|
+
* @category common/tabs
|
|
768
876
|
*/
|
|
769
877
|
function provideTabsConfigAt(...features) {
|
|
770
878
|
return [{ provide: CNGX_TABS_CONFIG, useValue: resolveFeatures(features) }];
|
|
771
879
|
}
|
|
772
880
|
/**
|
|
773
881
|
* Inject the resolved tabs config in an injection context.
|
|
882
|
+
*
|
|
883
|
+
* @category common/tabs
|
|
774
884
|
*/
|
|
775
885
|
function injectTabsConfig() {
|
|
776
886
|
return inject(CNGX_TABS_CONFIG);
|
|
@@ -790,8 +900,16 @@ const TABS_I18N_DEFAULTS = {
|
|
|
790
900
|
/**
|
|
791
901
|
* DI token for the tabs i18n bundle. `providedIn: 'root'` with
|
|
792
902
|
* English defaults.
|
|
903
|
+
*
|
|
904
|
+
* @category common/tabs/i18n
|
|
905
|
+
* @wcag AA
|
|
906
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/i18n/tabs-i18n.ts
|
|
907
|
+
* @since 0.1.0
|
|
793
908
|
*/
|
|
794
|
-
const CNGX_TABS_I18N = new InjectionToken('CngxTabsI18n', {
|
|
909
|
+
const CNGX_TABS_I18N = new InjectionToken('CngxTabsI18n', {
|
|
910
|
+
providedIn: 'root',
|
|
911
|
+
factory: () => TABS_I18N_DEFAULTS,
|
|
912
|
+
});
|
|
795
913
|
/**
|
|
796
914
|
* Brands an i18n-mutator with the `_target` discriminator.
|
|
797
915
|
*
|
|
@@ -801,10 +919,12 @@ function defineTabsI18nFeature(fn) {
|
|
|
801
919
|
return Object.assign(fn, { _target: 'i18n' });
|
|
802
920
|
}
|
|
803
921
|
/**
|
|
804
|
-
* Override i18n labels via a partial bundle
|
|
922
|
+
* Override i18n labels via a partial bundle - unset keys keep the
|
|
805
923
|
* English default. Same shape as `withTabsAriaLabels` /
|
|
806
924
|
* `withTabsFallbackLabels` so `provideCngxTabs` composes both
|
|
807
925
|
* surfaces uniformly.
|
|
926
|
+
*
|
|
927
|
+
* @category common/tabs/i18n
|
|
808
928
|
*/
|
|
809
929
|
function withTabsI18nLabels(overrides) {
|
|
810
930
|
return defineTabsI18nFeature((bundle) => ({ ...bundle, ...overrides }));
|
|
@@ -826,6 +946,8 @@ function resolveI18nFeatures(features) {
|
|
|
826
946
|
* ],
|
|
827
947
|
* });
|
|
828
948
|
* ```
|
|
949
|
+
*
|
|
950
|
+
* @category common/tabs/i18n
|
|
829
951
|
*/
|
|
830
952
|
function provideTabsI18n(...features) {
|
|
831
953
|
return {
|
|
@@ -835,6 +957,8 @@ function provideTabsI18n(...features) {
|
|
|
835
957
|
}
|
|
836
958
|
/**
|
|
837
959
|
* Inject the resolved tabs i18n bundle.
|
|
960
|
+
*
|
|
961
|
+
* @category common/tabs/i18n
|
|
838
962
|
*/
|
|
839
963
|
function injectTabsI18n() {
|
|
840
964
|
return inject(CNGX_TABS_I18N);
|
|
@@ -884,6 +1008,8 @@ function partitionFeatures(features) {
|
|
|
884
1008
|
* ],
|
|
885
1009
|
* });
|
|
886
1010
|
* ```
|
|
1011
|
+
*
|
|
1012
|
+
* @category common/tabs
|
|
887
1013
|
*/
|
|
888
1014
|
function provideCngxTabs(...features) {
|
|
889
1015
|
const { config, i18n } = partitionFeatures(features);
|
|
@@ -907,6 +1033,8 @@ function provideCngxTabs(...features) {
|
|
|
907
1033
|
* ],
|
|
908
1034
|
* })
|
|
909
1035
|
* ```
|
|
1036
|
+
*
|
|
1037
|
+
* @category common/tabs
|
|
910
1038
|
*/
|
|
911
1039
|
function provideCngxTabsAt(...features) {
|
|
912
1040
|
const { config, i18n } = partitionFeatures(features);
|
|
@@ -920,6 +1048,8 @@ function provideCngxTabsAt(...features) {
|
|
|
920
1048
|
* Default adapter for the cngx-native `<cngx-tab-group>` strip:
|
|
921
1049
|
* walks `host.closest('.cngx-tabs__strip-wrapper')` for the IO root,
|
|
922
1050
|
* then `[id="${handle.id}-header"]` for each button.
|
|
1051
|
+
*
|
|
1052
|
+
* @category common/tabs/overflow
|
|
923
1053
|
*/
|
|
924
1054
|
function createCngxTabOverflowDefaultDomAdapter() {
|
|
925
1055
|
return {
|
|
@@ -938,6 +1068,10 @@ function createCngxTabOverflowDefaultDomAdapter() {
|
|
|
938
1068
|
* swap in a Material, custom-skin, or test-double adapter without
|
|
939
1069
|
* forking the molecule. Defaults to
|
|
940
1070
|
* {@link createCngxTabOverflowDefaultDomAdapter}.
|
|
1071
|
+
*
|
|
1072
|
+
* @category common/tabs/overflow
|
|
1073
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/overflow/dom-adapter.ts
|
|
1074
|
+
* @since 0.1.0
|
|
941
1075
|
*/
|
|
942
1076
|
const CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY = new InjectionToken('CngxTabOverflowDomAdapterFactory', {
|
|
943
1077
|
providedIn: 'root',
|
|
@@ -945,7 +1079,7 @@ const CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY = new InjectionToken('CngxTabOverflo
|
|
|
945
1079
|
});
|
|
946
1080
|
|
|
947
1081
|
/**
|
|
948
|
-
* Bounded retry loop for DOM-anchoring patterns
|
|
1082
|
+
* Bounded retry loop for DOM-anchoring patterns - shared
|
|
949
1083
|
* attempt-counter + give-up + cancellation contract. Used by
|
|
950
1084
|
* `<cngx-tab-overflow>`'s rAF strip-attach loop and `[cngxMatTabs]`'s
|
|
951
1085
|
* `afterNextRender` header-anchor loop. Consumer-supplied scheduler
|
|
@@ -969,6 +1103,8 @@ const CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY = new InjectionToken('CngxTabOverflo
|
|
|
969
1103
|
* afterNextRender(() => retry.start());
|
|
970
1104
|
* destroyRef.onDestroy(() => retry.cancel());
|
|
971
1105
|
* ```
|
|
1106
|
+
*
|
|
1107
|
+
* @category common/tabs/overflow
|
|
972
1108
|
*/
|
|
973
1109
|
function createDomAnchorRetry(options) {
|
|
974
1110
|
let attempts = 0;
|
|
@@ -985,7 +1121,7 @@ function createDomAnchorRetry(options) {
|
|
|
985
1121
|
result = options.attempt();
|
|
986
1122
|
}
|
|
987
1123
|
catch {
|
|
988
|
-
// Swallow + terminal stop
|
|
1124
|
+
// Swallow + terminal stop - covers the test-runner teardown
|
|
989
1125
|
// race where a global (e.g. IntersectionObserver) is reset
|
|
990
1126
|
// between schedule and fire, before consumer DestroyRef can
|
|
991
1127
|
// call cancel(). Production callback bugs still surface via
|
|
@@ -1020,7 +1156,7 @@ function createDomAnchorRetry(options) {
|
|
|
1020
1156
|
}
|
|
1021
1157
|
/**
|
|
1022
1158
|
* DI token for the DOM-anchor retry policy. Default
|
|
1023
|
-
* {@link createDomAnchorRetry}. Two real consumers today
|
|
1159
|
+
* {@link createDomAnchorRetry}. Two real consumers today -
|
|
1024
1160
|
* `<cngx-tab-overflow>`'s rAF strip-attach loop and
|
|
1025
1161
|
* `[cngxMatTabs]`'s `afterNextRender` header-anchor loop. Override
|
|
1026
1162
|
* via `providers` / `viewProviders` for retry-with-backoff,
|
|
@@ -1028,6 +1164,10 @@ function createDomAnchorRetry(options) {
|
|
|
1028
1164
|
* `CNGX_OVERFLOW_POPOVER_HIGHLIGHT_FACTORY`,
|
|
1029
1165
|
* `CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY`, and
|
|
1030
1166
|
* `CNGX_TABS_COMMIT_HANDLER_FACTORY`.
|
|
1167
|
+
*
|
|
1168
|
+
* @category common/tabs/overflow
|
|
1169
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/overflow/dom-anchor-retry.ts
|
|
1170
|
+
* @since 0.1.0
|
|
1031
1171
|
*/
|
|
1032
1172
|
const CNGX_DOM_ANCHOR_RETRY_FACTORY = new InjectionToken('CngxDomAnchorRetryFactory', {
|
|
1033
1173
|
providedIn: 'root',
|
|
@@ -1047,6 +1187,12 @@ const CNGX_DOM_ANCHOR_RETRY_FACTORY = new InjectionToken('CngxDomAnchorRetryFact
|
|
|
1047
1187
|
* </ng-template>
|
|
1048
1188
|
* </cngx-tab-overflow>
|
|
1049
1189
|
* ```
|
|
1190
|
+
*
|
|
1191
|
+
* @category common/tabs/overflow
|
|
1192
|
+
* @wcag AA
|
|
1193
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/overflow/tab-overflow-trigger.directive.ts
|
|
1194
|
+
* @since 0.1.0
|
|
1195
|
+
* @relatedTo CngxTabOverflowItem, CngxTab
|
|
1050
1196
|
*/
|
|
1051
1197
|
class CngxTabOverflowTrigger {
|
|
1052
1198
|
templateRef = inject(TemplateRef);
|
|
@@ -1077,6 +1223,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1077
1223
|
* </ng-template>
|
|
1078
1224
|
* </cngx-tab-overflow>
|
|
1079
1225
|
* ```
|
|
1226
|
+
*
|
|
1227
|
+
* @category common/tabs/overflow
|
|
1228
|
+
* @wcag AA
|
|
1229
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/overflow/tab-overflow-item.directive.ts
|
|
1230
|
+
* @since 0.1.0
|
|
1231
|
+
* @relatedTo CngxTabOverflowTrigger, CngxTab
|
|
1080
1232
|
*/
|
|
1081
1233
|
class CngxTabOverflowItem {
|
|
1082
1234
|
templateRef = inject(TemplateRef);
|
|
@@ -1107,6 +1259,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1107
1259
|
* </ng-template>
|
|
1108
1260
|
* </cngx-tab-group>
|
|
1109
1261
|
* ```
|
|
1262
|
+
*
|
|
1263
|
+
* @category common/tabs/slots
|
|
1264
|
+
* @wcag AA
|
|
1265
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-error-badge.directive.ts
|
|
1266
|
+
* @since 0.1.0
|
|
1267
|
+
* @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
|
+
* <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>
|
|
1110
1271
|
*/
|
|
1111
1272
|
class CngxTabErrorBadge {
|
|
1112
1273
|
templateRef = inject(TemplateRef);
|
|
@@ -1142,6 +1303,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1142
1303
|
* </ng-template>
|
|
1143
1304
|
* </cngx-tab-group>
|
|
1144
1305
|
* ```
|
|
1306
|
+
*
|
|
1307
|
+
* @category common/tabs/slots
|
|
1308
|
+
* @wcag AA
|
|
1309
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-rejection-icon.directive.ts
|
|
1310
|
+
* @since 0.1.0
|
|
1311
|
+
* @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
|
+
* <example-url>http://localhost:4200/#/ui/tabs/tab-slot-overrides/rejection-decoration-via-code-cngxtabrejectionicon-code</example-url>
|
|
1145
1315
|
*/
|
|
1146
1316
|
class CngxTabRejectionIcon {
|
|
1147
1317
|
templateRef = inject(TemplateRef);
|
|
@@ -1169,6 +1339,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1169
1339
|
* </ng-template>
|
|
1170
1340
|
* </cngx-tab-group>
|
|
1171
1341
|
* ```
|
|
1342
|
+
*
|
|
1343
|
+
* @category common/tabs/slots
|
|
1344
|
+
* @wcag AA
|
|
1345
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/slots/tab-busy-spinner.directive.ts
|
|
1346
|
+
* @since 0.1.0
|
|
1347
|
+
* @relatedTo CngxTabErrorBadge, CngxTabRejectionIcon, CngxTab
|
|
1348
|
+
* <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>
|
|
1172
1351
|
*/
|
|
1173
1352
|
class CngxTabBusySpinner {
|
|
1174
1353
|
templateRef = inject(TemplateRef);
|
|
@@ -1197,6 +1376,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1197
1376
|
* Single-consumer today: `[cngxMatTabs]` does not consume this —
|
|
1198
1377
|
* Material owns the rendered tab-button chrome via its own MDC
|
|
1199
1378
|
* template, leaving no DOM seam. See `tabs-accepted-debt §9`.
|
|
1379
|
+
*
|
|
1380
|
+
* @category common/tabs/slots
|
|
1200
1381
|
*/
|
|
1201
1382
|
function createTabGroupTemplateBindings(opts) {
|
|
1202
1383
|
return {
|
|
@@ -1214,7 +1395,7 @@ function createTabGroupTemplateBindings(opts) {
|
|
|
1214
1395
|
|
|
1215
1396
|
// Single-consumer factory — staged under family-uniformity
|
|
1216
1397
|
// (tabs-accepted-debt §9, alongside `createTabGroupTemplateBindings`
|
|
1217
|
-
// and `CngxMatTabAggregatorContent`). Re-
|
|
1398
|
+
// and `CngxMatTabAggregatorContent`). Re-eval on second consumer or
|
|
1218
1399
|
// sibling debt closure.
|
|
1219
1400
|
/**
|
|
1220
1401
|
* Pure factory bundling the `<cngx-tab-group>` AT-announcement +
|
|
@@ -1222,6 +1403,8 @@ function createTabGroupTemplateBindings(opts) {
|
|
|
1222
1403
|
* (prior-active-index, drives the success-arm direction prefix) —
|
|
1223
1404
|
* lazy by `linkedSignal` semantics, so the organism reads
|
|
1224
1405
|
* `liveAnnouncement` once at construction to seed it.
|
|
1406
|
+
*
|
|
1407
|
+
* @category common/tabs/announcements
|
|
1225
1408
|
*/
|
|
1226
1409
|
function createTabGroupAnnouncements(options) {
|
|
1227
1410
|
const { presenter, i18n, config, ariaLabel, ariaLabelledBy } = options;
|
|
@@ -1233,9 +1416,9 @@ function createTabGroupAnnouncements(options) {
|
|
|
1233
1416
|
}
|
|
1234
1417
|
return ariaLabel() ?? config.ariaLabels?.tabsRegion ?? i18n.tabsLabel;
|
|
1235
1418
|
}, ...(ngDevMode ? [{ debugName: "resolvedAriaLabel" }] : /* istanbul ignore next */ []));
|
|
1236
|
-
// `prev?.source`
|
|
1237
|
-
//
|
|
1238
|
-
//
|
|
1419
|
+
// `prev?.source` = source value before the most recent change —
|
|
1420
|
+
// prior activeIndex without an `effect`-driven slot (Pillar 1).
|
|
1421
|
+
// Coalesce to current on first emission.
|
|
1239
1422
|
const priorActiveIndex = linkedSignal({ ...(ngDevMode ? { debugName: "priorActiveIndex" } : /* istanbul ignore next */ {}), source: () => presenter.activeIndex(),
|
|
1240
1423
|
computation: (curr, prev) => prev?.source ?? curr,
|
|
1241
1424
|
equal: Object.is });
|
|
@@ -1319,6 +1502,7 @@ function createTabGroupAnnouncements(options) {
|
|
|
1319
1502
|
* directives or `withTab*Template` config features.
|
|
1320
1503
|
*
|
|
1321
1504
|
* @internal
|
|
1505
|
+
* @category common/tabs
|
|
1322
1506
|
*/
|
|
1323
1507
|
const CNGX_TABS_GLYPHS = {
|
|
1324
1508
|
/** Default visual for `*cngxTabErrorBadge` when no override is bound. */
|
|
@@ -1332,24 +1516,30 @@ const CNGX_TABS_GLYPHS = {
|
|
|
1332
1516
|
* Stable across CD passes so `aria-activedescendant` resolves to
|
|
1333
1517
|
* the same `<li>`. `-overflow-option` suffix avoids collision with
|
|
1334
1518
|
* the strip-button (`-header`) and per-tab descriptor (`-desc`).
|
|
1519
|
+
*
|
|
1520
|
+
* @category common/tabs/overflow
|
|
1335
1521
|
*/
|
|
1336
1522
|
function tabOverflowOptionId(tab) {
|
|
1337
1523
|
return `${tab.id}-overflow-option`;
|
|
1338
1524
|
}
|
|
1339
1525
|
/**
|
|
1340
|
-
* Structural equal
|
|
1526
|
+
* Structural equal - same `count` + same `hiddenTabs` reference.
|
|
1341
1527
|
* The upstream `hiddenTabs` signal already uses `tabIdListEqual`,
|
|
1342
1528
|
* so this guard stops `ngTemplateOutlet` rebinding on shape-stable
|
|
1343
1529
|
* IO emissions.
|
|
1530
|
+
*
|
|
1531
|
+
* @internal
|
|
1344
1532
|
*/
|
|
1345
1533
|
function triggerContextEqual(a, b) {
|
|
1346
1534
|
return a.count === b.count && a.hiddenTabs === b.hiddenTabs;
|
|
1347
1535
|
}
|
|
1348
1536
|
/**
|
|
1349
|
-
* Structural equal
|
|
1537
|
+
* Structural equal - same length + per-index `id` and `disabled`.
|
|
1350
1538
|
* Without this, every IO emission yields fresh
|
|
1351
1539
|
* `ActiveDescendantItem[]` references and AD's `resolvedItems`
|
|
1352
1540
|
* cascade fires for an unchanged visible-tab set.
|
|
1541
|
+
*
|
|
1542
|
+
* @internal
|
|
1353
1543
|
*/
|
|
1354
1544
|
function adItemsEqual(a, b) {
|
|
1355
1545
|
if (a === b) {
|
|
@@ -1371,17 +1561,15 @@ function adItemsEqual(a, b) {
|
|
|
1371
1561
|
* `CNGX_TABS_CONFIG.templates.overflow*` > built-in markup
|
|
1372
1562
|
* (template-outlet returns `null`).
|
|
1373
1563
|
*
|
|
1374
|
-
* Pure
|
|
1564
|
+
* Pure - no DI, no side effects, no destroy hooks. Safe to call
|
|
1375
1565
|
* from a component's field-init block. Mirrors the select-family
|
|
1376
1566
|
* `createTemplateRegistry` pattern.
|
|
1567
|
+
*
|
|
1568
|
+
* @category common/tabs/overflow
|
|
1377
1569
|
*/
|
|
1378
1570
|
function createTabOverflowTemplateBindings(opts) {
|
|
1379
|
-
const triggerTemplate = computed(() => opts.triggerSlot()?.templateRef ??
|
|
1380
|
-
|
|
1381
|
-
null, ...(ngDevMode ? [{ debugName: "triggerTemplate" }] : /* istanbul ignore next */ []));
|
|
1382
|
-
const itemTemplate = computed(() => opts.itemSlot()?.templateRef ??
|
|
1383
|
-
opts.config.templates?.overflowItem ??
|
|
1384
|
-
null, ...(ngDevMode ? [{ debugName: "itemTemplate" }] : /* istanbul ignore next */ []));
|
|
1571
|
+
const triggerTemplate = computed(() => opts.triggerSlot()?.templateRef ?? opts.config.templates?.overflowTrigger ?? null, ...(ngDevMode ? [{ debugName: "triggerTemplate" }] : /* istanbul ignore next */ []));
|
|
1572
|
+
const itemTemplate = computed(() => opts.itemSlot()?.templateRef ?? opts.config.templates?.overflowItem ?? null, ...(ngDevMode ? [{ debugName: "itemTemplate" }] : /* istanbul ignore next */ []));
|
|
1385
1573
|
const triggerContext = computed(() => {
|
|
1386
1574
|
const count = opts.hiddenCount();
|
|
1387
1575
|
const hiddenTabs = opts.hiddenTabs();
|
|
@@ -1421,12 +1609,14 @@ function createTabOverflowTemplateBindings(opts) {
|
|
|
1421
1609
|
/**
|
|
1422
1610
|
* Resets the AD highlight on popover close. Keyboard-open paths
|
|
1423
1611
|
* (ArrowDown / End / typeahead on the closed trigger) set
|
|
1424
|
-
* `activeIndex` via AD's own keydown listener before opening
|
|
1612
|
+
* `activeIndex` via AD's own keydown listener before opening -
|
|
1425
1613
|
* unaffected. Mouse-open leaves `activeIndex === -1` so the popover
|
|
1426
1614
|
* renders unhighlighted. Without this reset, the next open would
|
|
1427
1615
|
* inherit a stale index from the prior keyboard session.
|
|
1428
1616
|
*
|
|
1429
1617
|
* Must run in injection context.
|
|
1618
|
+
*
|
|
1619
|
+
* @category common/tabs/overflow
|
|
1430
1620
|
*/
|
|
1431
1621
|
function createOverflowPopoverHighlightSync(popover, ad) {
|
|
1432
1622
|
effect(() => {
|
|
@@ -1445,6 +1635,10 @@ function createOverflowPopoverHighlightSync(popover, ad) {
|
|
|
1445
1635
|
* telemetry on close, custom highlight rules. Symmetric to
|
|
1446
1636
|
* `CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY` and
|
|
1447
1637
|
* `CNGX_TABS_COMMIT_HANDLER_FACTORY`.
|
|
1638
|
+
*
|
|
1639
|
+
* @category common/tabs/overflow
|
|
1640
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/overflow/overflow-template-cascade.ts
|
|
1641
|
+
* @since 0.1.0
|
|
1448
1642
|
*/
|
|
1449
1643
|
const CNGX_OVERFLOW_POPOVER_HIGHLIGHT_FACTORY = new InjectionToken('CngxOverflowPopoverHighlightSyncFactory', {
|
|
1450
1644
|
providedIn: 'root',
|
|
@@ -1462,7 +1656,9 @@ const DEFAULT_SCROLL_OPTIONS = {
|
|
|
1462
1656
|
* scrolls the matching `[id="<itemId>-header"]` into view.
|
|
1463
1657
|
*
|
|
1464
1658
|
* The DOM call sits in `untracked()` (only `activeId` is tracked).
|
|
1465
|
-
* `scrollIntoView` is missing in jsdom
|
|
1659
|
+
* `scrollIntoView` is missing in jsdom - guarded with optional chain.
|
|
1660
|
+
*
|
|
1661
|
+
* @category common/tabs/scroll-sync
|
|
1466
1662
|
*/
|
|
1467
1663
|
function createOrganismScrollSync(opts) {
|
|
1468
1664
|
const { activeId, hostElement, scrollOptions, injector } = opts;
|
|
@@ -1486,6 +1682,10 @@ function createOrganismScrollSync(opts) {
|
|
|
1486
1682
|
* custom selector, telemetry, or `prefers-reduced-motion` opt-out.
|
|
1487
1683
|
* Sibling to `CNGX_DOM_ANCHOR_RETRY_FACTORY` and
|
|
1488
1684
|
* `CNGX_OVERFLOW_POPOVER_HIGHLIGHT_FACTORY`.
|
|
1685
|
+
*
|
|
1686
|
+
* @category common/tabs/scroll-sync
|
|
1687
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/scroll-sync/organism-scroll-sync.ts
|
|
1688
|
+
* @since 0.1.0
|
|
1489
1689
|
*/
|
|
1490
1690
|
const CNGX_ORGANISM_SCROLL_SYNC_FACTORY = new InjectionToken('CngxOrganismScrollSyncFactory', {
|
|
1491
1691
|
providedIn: 'root',
|
|
@@ -1517,6 +1717,8 @@ function directiveMapEqual(a, b) {
|
|
|
1517
1717
|
* directives keyed by `id()`. Structural equal prevents cascade when
|
|
1518
1718
|
* `contentChildren` re-emits an unchanged child set. Shared by
|
|
1519
1719
|
* `<cngx-tab-group>`, `<cngx-stepper>`, and `<cngx-mat-stepper>`.
|
|
1720
|
+
*
|
|
1721
|
+
* @category common/tabs/registry
|
|
1520
1722
|
*/
|
|
1521
1723
|
function createDirectiveByIdMap(opts) {
|
|
1522
1724
|
return computed(() => {
|
|
@@ -1533,6 +1735,10 @@ function createDirectiveByIdMap(opts) {
|
|
|
1533
1735
|
* telemetry, or custom equality. Sibling to
|
|
1534
1736
|
* `CNGX_DOM_ANCHOR_RETRY_FACTORY` and
|
|
1535
1737
|
* `CNGX_ORGANISM_SCROLL_SYNC_FACTORY`.
|
|
1738
|
+
*
|
|
1739
|
+
* @category common/tabs/registry
|
|
1740
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/tabs/registry/directive-by-id-map.ts
|
|
1741
|
+
* @since 0.1.0
|
|
1536
1742
|
*/
|
|
1537
1743
|
const CNGX_DIRECTIVE_BY_ID_MAP_FACTORY = new InjectionToken('CngxDirectiveByIdMapFactory', {
|
|
1538
1744
|
providedIn: 'root',
|