@cngx/ui 0.1.0-rc.8 → 0.3.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/README.md +118 -59
- package/action-button/README.md +170 -53
- package/breadcrumb/README.md +5 -6
- package/collection/README.md +1 -1
- package/command-palette/README.md +9 -5
- package/data-grid-accordion/README.md +1 -1
- package/empty-state/README.md +2 -3
- package/feedback/README.md +1 -1
- package/fesm2022/cngx-ui-a11y.mjs +13 -23
- package/fesm2022/cngx-ui-a11y.mjs.map +1 -1
- package/fesm2022/cngx-ui-accordion.mjs +55 -60
- package/fesm2022/cngx-ui-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-action-button.mjs +220 -339
- package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
- package/fesm2022/cngx-ui-breadcrumb.mjs +100 -80
- package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -1
- package/fesm2022/cngx-ui-chart-panel.mjs +18 -31
- package/fesm2022/cngx-ui-chart-panel.mjs.map +1 -1
- package/fesm2022/cngx-ui-collection.mjs +28 -34
- package/fesm2022/cngx-ui-collection.mjs.map +1 -1
- package/fesm2022/cngx-ui-command-palette.mjs +29 -51
- package/fesm2022/cngx-ui-command-palette.mjs.map +1 -1
- package/fesm2022/cngx-ui-context-menu.mjs +138 -89
- package/fesm2022/cngx-ui-context-menu.mjs.map +1 -1
- package/fesm2022/cngx-ui-data-grid-accordion.mjs +135 -77
- package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-empty-state.mjs +17 -44
- package/fesm2022/cngx-ui-empty-state.mjs.map +1 -1
- package/fesm2022/cngx-ui-feedback.mjs +648 -495
- package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
- package/fesm2022/cngx-ui-layout.mjs +17 -13
- package/fesm2022/cngx-ui-layout.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-accordion.mjs +6 -7
- package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-paginator.mjs +5 -9
- package/fesm2022/cngx-ui-mat-paginator.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-stepper.mjs +6 -9
- package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-tabs.mjs +315 -134
- package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-nav-rail.mjs +440 -0
- package/fesm2022/cngx-ui-nav-rail.mjs.map +1 -0
- package/fesm2022/cngx-ui-overlay.mjs +9 -10
- package/fesm2022/cngx-ui-overlay.mjs.map +1 -1
- package/fesm2022/cngx-ui-paginator.mjs +212 -188
- package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
- package/fesm2022/cngx-ui-sidenav.mjs +872 -721
- package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
- package/fesm2022/cngx-ui-skeleton.mjs +17 -19
- package/fesm2022/cngx-ui-skeleton.mjs.map +1 -1
- package/fesm2022/cngx-ui-speak.mjs +21 -74
- package/fesm2022/cngx-ui-speak.mjs.map +1 -1
- package/fesm2022/cngx-ui-stat-card.mjs +39 -62
- package/fesm2022/cngx-ui-stat-card.mjs.map +1 -1
- package/fesm2022/cngx-ui-stepper.mjs +259 -130
- package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
- package/fesm2022/cngx-ui-tabs.mjs +148 -50
- package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-timeline.mjs +48 -32
- package/fesm2022/cngx-ui-timeline.mjs.map +1 -1
- package/fesm2022/cngx-ui-toc.mjs +59 -48
- package/fesm2022/cngx-ui-toc.mjs.map +1 -1
- package/fesm2022/cngx-ui.mjs +5 -5
- package/fesm2022/cngx-ui.mjs.map +1 -1
- package/mat-tabs/README.md +57 -19
- package/mat-tabs/styles/mat-tabs.css +285 -163
- package/nav-rail/README.md +325 -0
- package/package.json +37 -8
- package/paginator/README.md +10 -0
- package/schematics/collection.json +9 -0
- package/schematics/ng-add/index.js +9 -0
- package/schematics/ng-add/schema.json +96 -0
- package/schematics/package.json +3 -0
- package/sidenav/README.md +150 -55
- package/skeleton/README.md +1 -1
- package/speak/README.md +1 -2
- package/stepper/README.md +20 -5
- package/tabs/README.md +13 -0
- package/timeline/README.md +1 -1
- package/toc/README.md +1 -1
- package/types/cngx-ui-a11y.d.ts +20 -38
- package/types/cngx-ui-accordion.d.ts +46 -71
- package/types/cngx-ui-action-button.d.ts +113 -151
- package/types/cngx-ui-breadcrumb.d.ts +60 -85
- package/types/cngx-ui-chart-panel.d.ts +22 -40
- package/types/cngx-ui-collection.d.ts +30 -43
- package/types/cngx-ui-command-palette.d.ts +40 -64
- package/types/cngx-ui-context-menu.d.ts +109 -48
- package/types/cngx-ui-data-grid-accordion.d.ts +50 -75
- package/types/cngx-ui-empty-state.d.ts +18 -8
- package/types/cngx-ui-feedback.d.ts +275 -292
- package/types/cngx-ui-layout.d.ts +4 -12
- package/types/cngx-ui-mat-accordion.d.ts +5 -5
- package/types/cngx-ui-mat-paginator.d.ts +4 -10
- package/types/cngx-ui-mat-stepper.d.ts +5 -10
- package/types/cngx-ui-mat-tabs.d.ts +86 -89
- package/types/cngx-ui-nav-rail.d.ts +416 -0
- package/types/cngx-ui-overlay.d.ts +4 -13
- package/types/cngx-ui-paginator.d.ts +186 -161
- package/types/cngx-ui-sidenav.d.ts +557 -437
- package/types/cngx-ui-skeleton.d.ts +7 -13
- package/types/cngx-ui-speak.d.ts +40 -24
- package/types/cngx-ui-stat-card.d.ts +45 -36
- package/types/cngx-ui-stepper.d.ts +205 -84
- package/types/cngx-ui-tabs.d.ts +104 -28
- package/types/cngx-ui-timeline.d.ts +31 -51
- package/types/cngx-ui-toc.d.ts +43 -54
- package/types/cngx-ui.d.ts +1 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
3
|
-
import { MatTabGroup, MatTab
|
|
4
|
-
import { createMaterialBidirectionalSync } from '@cngx/common/data';
|
|
2
|
+
import { afterNextRender, runInInjectionContext, effect, untracked, computed, InjectionToken, makeEnvironmentProviders, inject, TemplateRef, Directive, signal, DestroyRef, EnvironmentInjector, contentChildren, createEnvironmentInjector, Injectable, Injector, Renderer2, ElementRef, ViewContainerRef, contentChild, input, booleanAttribute } from '@angular/core';
|
|
3
|
+
import { MatTabGroup, MatTab } from '@angular/material/tabs';
|
|
4
|
+
import { createRefusedPhrase, createMaterialBidirectionalSync } from '@cngx/common/data';
|
|
5
5
|
import * as i1 from '@cngx/common/tabs';
|
|
6
6
|
import { CNGX_TAB_GROUP_HOST, injectTabsI18n, CNGX_DOM_ANCHOR_RETRY_FACTORY, CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY, CNGX_TAB_PANEL_HOST, CngxTabGroupPresenter, createTabNavAnnouncement, CNGX_TAB_NAV_HOST } from '@cngx/common/tabs';
|
|
7
7
|
import { CngxTabOverflow } from '@cngx/ui/tabs';
|
|
8
|
+
import { cngxDevWarn, CNGX_ICON_BAN, CNGX_ICON_ALERT, CngxRuntimeError } from '@cngx/utils';
|
|
9
|
+
import { createIconSvgElement } from '@cngx/common/display';
|
|
8
10
|
import { CngxLiveAnnouncer } from '@cngx/common/a11y';
|
|
9
11
|
import { nextUid } from '@cngx/core/utils';
|
|
10
12
|
import { toSignal } from '@angular/core/rxjs-interop';
|
|
@@ -19,10 +21,10 @@ import { toSignal } from '@angular/core/rxjs-interop';
|
|
|
19
21
|
* rather than reach for this reference directly.
|
|
20
22
|
*/
|
|
21
23
|
const CNGX_DEFAULT_HALF_WIRED_SLOT_SINK = (missing) => {
|
|
22
|
-
if (!
|
|
24
|
+
if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
|
|
23
25
|
return;
|
|
24
26
|
}
|
|
25
|
-
|
|
27
|
+
cngxDevWarn('CNGX3006', '[cngxMatTabs] aggregator-content slot half-wired - ' +
|
|
26
28
|
`\`${missing}\` is missing while the other half is supplied. ` +
|
|
27
29
|
'The decoration projector will silently fall back to the ' +
|
|
28
30
|
'imperative `textContent` path, and the consumer-projected ' +
|
|
@@ -52,8 +54,6 @@ const CNGX_DEFAULT_HALF_WIRED_SLOT_SINK = (missing) => {
|
|
|
52
54
|
* grouped name through ESLint's `@typescript-eslint` type resolver
|
|
53
55
|
* - a flat `export * as` re-export from `public-api.ts` does not
|
|
54
56
|
* resolve nested members through the path-alias.
|
|
55
|
-
*
|
|
56
|
-
* @category ui/mat-tabs
|
|
57
57
|
*/
|
|
58
58
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
59
59
|
var MaterialPrivateSurfaces;
|
|
@@ -93,12 +93,14 @@ var MaterialPrivateSurfaces;
|
|
|
93
93
|
*
|
|
94
94
|
* - {@link createMatTabRejectionDecoration} - mirrors
|
|
95
95
|
* `presenter.lastFailedIndex` onto the matching `.mat-mdc-tab` as a
|
|
96
|
-
* class flag
|
|
96
|
+
* class flag, a `data-reason` attribute, an `aria-hidden` glyph span
|
|
97
|
+
* and a hidden `cngx-sr-only` descriptor span linked via
|
|
97
98
|
* `aria-describedby`. `aria-invalid` is intentionally absent: ARIA
|
|
98
99
|
* 1.2 scopes it to form-field vocabulary, not `role="tab"`.
|
|
99
100
|
* - {@link createMatTabAggregatorDecoration} - projects each handle's
|
|
100
|
-
* `shouldShow()` flag onto the matching button as a class
|
|
101
|
-
* descriptor span
|
|
101
|
+
* `shouldShow()` flag onto the matching button as a class, an
|
|
102
|
+
* `aria-hidden` alert icon and a descriptor span, same
|
|
103
|
+
* `aria-describedby` token-append pattern.
|
|
102
104
|
*
|
|
103
105
|
* Distinct descriptor-id suffixes (`-rejected` vs `-errors`) let both
|
|
104
106
|
* projectors stack on the same target without collision; the shared
|
|
@@ -136,6 +138,17 @@ function restoreAriaDescribedbyExceptToken(el, tokenToRemove, renderer, priorAri
|
|
|
136
138
|
}
|
|
137
139
|
renderer.setAttribute(el, 'aria-describedby', remaining.join(' '));
|
|
138
140
|
}
|
|
141
|
+
/** Class of the `<svg>` the projectors build from the shared icon data. */
|
|
142
|
+
const ICON_SVG_CLASS = 'cngx-mat-tab__icon-svg';
|
|
143
|
+
/** @internal */
|
|
144
|
+
function createIconGlyph(renderer, className, icon) {
|
|
145
|
+
const span = renderer.createElement('span');
|
|
146
|
+
renderer.addClass(span, className);
|
|
147
|
+
renderer.setAttribute(span, 'aria-hidden', 'true');
|
|
148
|
+
const svg = createIconSvgElement(renderer, icon, ICON_SVG_CLASS);
|
|
149
|
+
renderer.appendChild(span, svg.element);
|
|
150
|
+
return { span, icon: svg };
|
|
151
|
+
}
|
|
139
152
|
/**
|
|
140
153
|
* Mounts the sticky-rejection decoration projector. Class +
|
|
141
154
|
* descriptor span follow `failedHandleId` reactively; cleared on
|
|
@@ -161,6 +174,7 @@ function createMatTabRejectionDecoration(opts) {
|
|
|
161
174
|
const buttonSelector = opts.buttonSelector ?? MaterialPrivateSurfaces.MAT_MDC_TAB_SELECTOR;
|
|
162
175
|
const className = opts.className ?? 'cngx-mat-tab--error';
|
|
163
176
|
const srOnlyClassName = opts.srOnlyClassName ?? 'cngx-sr-only';
|
|
177
|
+
const glyphClassName = opts.glyphClassName ?? 'cngx-mat-tab__rejection-icon';
|
|
164
178
|
const descriptorIdSuffix = opts.descriptorIdSuffix ?? 'rejected';
|
|
165
179
|
const maxRetryAttempts = opts.maxRetryAttempts ?? 5;
|
|
166
180
|
let pendingRetry = false;
|
|
@@ -173,6 +187,9 @@ function createMatTabRejectionDecoration(opts) {
|
|
|
173
187
|
// Cached across the projector's lifetime - reusing the same node
|
|
174
188
|
// keeps AT-reader / observer references live across A→B→A flips.
|
|
175
189
|
let cachedSpan = null;
|
|
190
|
+
// The visible glyph rides its own `aria-hidden` span, built once; a
|
|
191
|
+
// kind change rewrites its path in place.
|
|
192
|
+
let cachedGlyph = null;
|
|
176
193
|
let priorAriaDescribedby = null;
|
|
177
194
|
// Pillar 1 - short-circuits structurally-identical re-emissions of
|
|
178
195
|
// `failedHandleId` so a `tabs()` re-eval doesn't clobber the AT
|
|
@@ -201,6 +218,7 @@ function createMatTabRejectionDecoration(opts) {
|
|
|
201
218
|
failedHandleId: handleId,
|
|
202
219
|
originLabel: opts.originLabel?.(),
|
|
203
220
|
fallbackText: text,
|
|
221
|
+
reason: opts.reason?.() ?? 'failed',
|
|
204
222
|
};
|
|
205
223
|
const view = vcr.createEmbeddedView(tpl, context, {
|
|
206
224
|
injector: opts.injector,
|
|
@@ -220,6 +238,13 @@ function createMatTabRejectionDecoration(opts) {
|
|
|
220
238
|
destroyEmbeddedView();
|
|
221
239
|
opts.renderer.setProperty(span, 'textContent', text);
|
|
222
240
|
};
|
|
241
|
+
const currentReason = () => opts.reason?.() ?? 'failed';
|
|
242
|
+
const writeReason = (target, glyph) => {
|
|
243
|
+
const reason = currentReason();
|
|
244
|
+
opts.renderer.setAttribute(target, 'data-reason', reason);
|
|
245
|
+
opts.renderer.setAttribute(glyph.span, 'data-reason', reason);
|
|
246
|
+
glyph.icon.setIcon(reason === 'refused' ? CNGX_ICON_BAN : CNGX_ICON_ALERT);
|
|
247
|
+
};
|
|
223
248
|
const clearDecoration = () => {
|
|
224
249
|
if (!decoratedEl || !cachedSpan) {
|
|
225
250
|
return;
|
|
@@ -227,6 +252,10 @@ function createMatTabRejectionDecoration(opts) {
|
|
|
227
252
|
const ownTokenId = cachedSpan.id;
|
|
228
253
|
destroyEmbeddedView();
|
|
229
254
|
opts.renderer.removeClass(decoratedEl, className);
|
|
255
|
+
opts.renderer.removeAttribute(decoratedEl, 'data-reason');
|
|
256
|
+
if (cachedGlyph?.span.parentNode) {
|
|
257
|
+
opts.renderer.removeChild(cachedGlyph.span.parentNode, cachedGlyph.span);
|
|
258
|
+
}
|
|
230
259
|
opts.renderer.removeChild(decoratedEl, cachedSpan);
|
|
231
260
|
// `cachedSpan` deliberately retained - reused on the next apply.
|
|
232
261
|
restoreAriaDescribedbyExceptToken(decoratedEl, ownTokenId, opts.renderer, priorAriaDescribedby);
|
|
@@ -241,6 +270,12 @@ function createMatTabRejectionDecoration(opts) {
|
|
|
241
270
|
return false;
|
|
242
271
|
}
|
|
243
272
|
opts.renderer.addClass(targetEl, className);
|
|
273
|
+
const glyph = cachedGlyph ?? createIconGlyph(opts.renderer, glyphClassName, CNGX_ICON_ALERT);
|
|
274
|
+
cachedGlyph = glyph;
|
|
275
|
+
writeReason(targetEl, glyph);
|
|
276
|
+
// On the tab itself, a flex item after `.mdc-tab__content`, so the
|
|
277
|
+
// icon follows the label.
|
|
278
|
+
opts.renderer.appendChild(targetEl, glyph.span);
|
|
244
279
|
const spanId = `${handleId}-${descriptorIdSuffix}`;
|
|
245
280
|
let span = cachedSpan;
|
|
246
281
|
if (!span) {
|
|
@@ -288,7 +323,9 @@ function createMatTabRejectionDecoration(opts) {
|
|
|
288
323
|
if (retryAttempts >= maxRetryAttempts) {
|
|
289
324
|
retryAttempts = 0;
|
|
290
325
|
const sink = opts.onMaxRetriesReached ??
|
|
291
|
-
|
|
326
|
+
(typeof ngDevMode !== 'undefined' && ngDevMode
|
|
327
|
+
? defaultRetryCeilingWarn(maxRetryAttempts, 'rejection')
|
|
328
|
+
: noop);
|
|
292
329
|
sink();
|
|
293
330
|
return;
|
|
294
331
|
}
|
|
@@ -318,6 +355,18 @@ function createMatTabRejectionDecoration(opts) {
|
|
|
318
355
|
applyOrScheduleRetry(id);
|
|
319
356
|
});
|
|
320
357
|
});
|
|
358
|
+
// Reason effect - a refusal and a failure can follow each other on
|
|
359
|
+
// the same tab (same handle id, so the mount effect short-circuits);
|
|
360
|
+
// the attribute and the glyph follow the kind in place.
|
|
361
|
+
effect(() => {
|
|
362
|
+
currentReason();
|
|
363
|
+
untracked(() => {
|
|
364
|
+
if (decoratedEl === null || cachedGlyph === null) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
writeReason(decoratedEl, cachedGlyph);
|
|
368
|
+
});
|
|
369
|
+
});
|
|
321
370
|
// Live-text effect - tracks `descriptorText` plus the slot
|
|
322
371
|
// template (when wired) so a late-mounted template re-renders
|
|
323
372
|
// into the existing span. Mount-state checks live in untracked.
|
|
@@ -342,7 +391,7 @@ function createMatTabRejectionDecoration(opts) {
|
|
|
342
391
|
opts.destroyRef.onDestroy(clearDecoration);
|
|
343
392
|
}
|
|
344
393
|
/**
|
|
345
|
-
* Mounts the per-tab aggregator decoration projector. Class
|
|
394
|
+
* Mounts the per-tab aggregator decoration projector. Class, alert icon,
|
|
346
395
|
* descriptor span + `aria-describedby` token follow `errorTabs`
|
|
347
396
|
* reactively; pruned on entry drop and on directive destroy.
|
|
348
397
|
*
|
|
@@ -356,6 +405,7 @@ function createMatTabAggregatorDecoration(opts) {
|
|
|
356
405
|
const buttonSelector = opts.buttonSelector ?? MaterialPrivateSurfaces.MAT_MDC_TAB_SELECTOR;
|
|
357
406
|
const className = opts.className ?? 'cngx-mat-tab--has-errors';
|
|
358
407
|
const srOnlyClassName = opts.srOnlyClassName ?? 'cngx-sr-only';
|
|
408
|
+
const badgeClassName = opts.badgeClassName ?? 'cngx-mat-tab__error-badge';
|
|
359
409
|
const maxRetryAttempts = opts.maxRetryAttempts ?? 5;
|
|
360
410
|
// Slot path needs both halves; either alone degrades to imperative
|
|
361
411
|
// textContent. Re-evaluated per fire so a lazy-mounted template
|
|
@@ -365,8 +415,11 @@ function createMatTabAggregatorDecoration(opts) {
|
|
|
365
415
|
// at runtime, so the signal has to come from a deliberate sink.
|
|
366
416
|
if (!isFullyWired() && (opts.contentTemplate || opts.viewContainerRef)) {
|
|
367
417
|
const missing = opts.contentTemplate ? 'viewContainerRef' : 'contentTemplate';
|
|
368
|
-
const sink = opts.onHalfWiredSlot ??
|
|
369
|
-
|
|
418
|
+
const sink = opts.onHalfWiredSlot ??
|
|
419
|
+
(typeof ngDevMode !== 'undefined' && ngDevMode
|
|
420
|
+
? CNGX_DEFAULT_HALF_WIRED_SLOT_SINK
|
|
421
|
+
: undefined);
|
|
422
|
+
sink?.(missing);
|
|
370
423
|
}
|
|
371
424
|
const decorated = new Map();
|
|
372
425
|
let pendingRetry = false;
|
|
@@ -415,12 +468,16 @@ function createMatTabAggregatorDecoration(opts) {
|
|
|
415
468
|
const ownTokenId = entry.descriptorSpan.id;
|
|
416
469
|
destroyEmbeddedView(entry);
|
|
417
470
|
opts.renderer.removeClass(entry.el, className);
|
|
471
|
+
opts.renderer.removeChild(entry.el, entry.badge);
|
|
418
472
|
opts.renderer.removeChild(entry.el, entry.descriptorSpan);
|
|
419
473
|
restoreAriaDescribedbyExceptToken(entry.el, ownTokenId, opts.renderer, entry.priorAriaDescribedby);
|
|
420
474
|
decorated.delete(id);
|
|
421
475
|
};
|
|
422
476
|
const applyDecoration = (targetEl, entry) => {
|
|
423
477
|
opts.renderer.addClass(targetEl, className);
|
|
478
|
+
// A flex item after `.mdc-tab__content`, so the icon follows the label.
|
|
479
|
+
const badge = createIconGlyph(opts.renderer, badgeClassName, CNGX_ICON_ALERT);
|
|
480
|
+
opts.renderer.appendChild(targetEl, badge.span);
|
|
424
481
|
const spanId = `${entry.id}-errors`;
|
|
425
482
|
const descriptorSpan = opts.renderer.createElement('span');
|
|
426
483
|
opts.renderer.addClass(descriptorSpan, srOnlyClassName);
|
|
@@ -437,7 +494,7 @@ function createMatTabAggregatorDecoration(opts) {
|
|
|
437
494
|
tokens.push(spanId);
|
|
438
495
|
}
|
|
439
496
|
opts.renderer.setAttribute(targetEl, 'aria-describedby', tokens.join(' '));
|
|
440
|
-
const decoratedEntry = { el: targetEl, descriptorSpan, priorAriaDescribedby };
|
|
497
|
+
const decoratedEntry = { el: targetEl, descriptorSpan, badge: badge.span, priorAriaDescribedby };
|
|
441
498
|
writeDescriptorContent(decoratedEntry, entry.announcement, {
|
|
442
499
|
count: entry.count,
|
|
443
500
|
label: entry.label,
|
|
@@ -489,7 +546,10 @@ function createMatTabAggregatorDecoration(opts) {
|
|
|
489
546
|
}
|
|
490
547
|
if (retryAttempts >= maxRetryAttempts) {
|
|
491
548
|
retryAttempts = 0;
|
|
492
|
-
const sink = opts.onMaxRetriesReached ??
|
|
549
|
+
const sink = opts.onMaxRetriesReached ??
|
|
550
|
+
(typeof ngDevMode !== 'undefined' && ngDevMode
|
|
551
|
+
? defaultRetryCeilingWarn(maxRetryAttempts, 'aggregator')
|
|
552
|
+
: noop);
|
|
493
553
|
sink();
|
|
494
554
|
return;
|
|
495
555
|
}
|
|
@@ -518,12 +578,13 @@ function createMatTabAggregatorDecoration(opts) {
|
|
|
518
578
|
}
|
|
519
579
|
});
|
|
520
580
|
}
|
|
581
|
+
const noop = () => undefined;
|
|
521
582
|
function defaultRetryCeilingWarn(max, decoration) {
|
|
583
|
+
if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
|
|
584
|
+
return noop;
|
|
585
|
+
}
|
|
522
586
|
return () => {
|
|
523
|
-
|
|
524
|
-
return;
|
|
525
|
-
}
|
|
526
|
-
console.warn(`[cngxMatTabs] ${decoration} decoration retry ceiling reached ` +
|
|
587
|
+
cngxDevWarn('CNGX3005', `[cngxMatTabs] ${decoration} decoration retry ceiling reached ` +
|
|
527
588
|
`(${max} attempts) - MatTabHeader did not render ` +
|
|
528
589
|
'`.mat-mdc-tab` buttons within the expected window. Likely ' +
|
|
529
590
|
'cause: Material upgrade broke the `.mat-mdc-tab` selector ' +
|
|
@@ -534,8 +595,14 @@ function defaultRetryCeilingWarn(max, decoration) {
|
|
|
534
595
|
}
|
|
535
596
|
|
|
536
597
|
/**
|
|
537
|
-
* Builds the reactive list of tabs
|
|
538
|
-
*
|
|
598
|
+
* Builds the reactive list of tabs in error, in registration (DOM)
|
|
599
|
+
* order. Gates on the handle's folded `hasError()` - the direct
|
|
600
|
+
* `[cngxMatTabErrorFlag]` / `[error]` flag OR the bound aggregator's
|
|
601
|
+
* reveal-gated `shouldShow()` - exactly as `<cngx-tab-group>` gates its
|
|
602
|
+
* badge, so a deferred-reveal aggregator stays silent until revealed.
|
|
603
|
+
* The descriptor phrase mirrors the native `statusPhrase` cascade:
|
|
604
|
+
* aggregator announcement, then the direct-error message, then
|
|
605
|
+
* `i18n.tabHasErrors(count)`. Feeds
|
|
539
606
|
* {@link createMatTabAggregatorDecoration} for both the
|
|
540
607
|
* `[cngxMatTabs]` (`<mat-tab-group>`) and `[cngxMatTabNav]`
|
|
541
608
|
* (`<nav mat-tab-nav-bar>`) bridges - one body, two hosts (Pillar 3).
|
|
@@ -545,22 +612,36 @@ function defaultRetryCeilingWarn(max, decoration) {
|
|
|
545
612
|
*
|
|
546
613
|
* @internal
|
|
547
614
|
*/
|
|
548
|
-
function createAggregatedErrorTabs(presenter) {
|
|
615
|
+
function createAggregatedErrorTabs(presenter, i18n) {
|
|
616
|
+
// Same cascade as the native `statusPhrase`: an empty announcement or
|
|
617
|
+
// message falls through, so a bare `true` flag still reads a phrase.
|
|
618
|
+
const descriptorPhrase = (handle, count) => {
|
|
619
|
+
const announcement = handle.errorAggregator()?.announcement();
|
|
620
|
+
if (announcement) {
|
|
621
|
+
return announcement;
|
|
622
|
+
}
|
|
623
|
+
const message = handle.errorMessage();
|
|
624
|
+
if (message) {
|
|
625
|
+
return message;
|
|
626
|
+
}
|
|
627
|
+
return i18n().tabHasErrors(count);
|
|
628
|
+
};
|
|
549
629
|
return computed(() => {
|
|
550
630
|
const tabs = presenter.tabs();
|
|
551
631
|
const acc = [];
|
|
552
632
|
for (let i = 0; i < tabs.length; i++) {
|
|
553
633
|
const handle = tabs[i];
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
acc.push({
|
|
557
|
-
idx: i,
|
|
558
|
-
id: handle.id,
|
|
559
|
-
announcement: aggregator.announcement(),
|
|
560
|
-
count: aggregator.errorCount(),
|
|
561
|
-
label: handle.label() ?? '',
|
|
562
|
-
});
|
|
634
|
+
if (!handle.hasError()) {
|
|
635
|
+
continue;
|
|
563
636
|
}
|
|
637
|
+
const count = handle.errorAggregator()?.errorCount() ?? 1;
|
|
638
|
+
acc.push({
|
|
639
|
+
idx: i,
|
|
640
|
+
id: handle.id,
|
|
641
|
+
announcement: descriptorPhrase(handle, count),
|
|
642
|
+
count,
|
|
643
|
+
label: handle.label() ?? '',
|
|
644
|
+
});
|
|
564
645
|
}
|
|
565
646
|
return acc;
|
|
566
647
|
}, {
|
|
@@ -582,6 +663,8 @@ function createAggregatedErrorTabs(presenter) {
|
|
|
582
663
|
});
|
|
583
664
|
}
|
|
584
665
|
|
|
666
|
+
/** Production default for `halfWiredSlotSink`: one reference, so reads stay identical. */
|
|
667
|
+
const SILENT_HALF_WIRED_SLOT_SINK = () => undefined;
|
|
585
668
|
/**
|
|
586
669
|
* Library defaults for `[cngxMatTabs]`. Source of truth for every
|
|
587
670
|
* key on {@link CngxMatTabsConfig}. Consumed by
|
|
@@ -591,7 +674,13 @@ function createAggregatedErrorTabs(presenter) {
|
|
|
591
674
|
*/
|
|
592
675
|
const CNGX_MAT_TABS_CONFIG_DEFAULTS = {
|
|
593
676
|
anchorMaxAttempts: 5,
|
|
594
|
-
|
|
677
|
+
// A getter, so the guard is read when the config resolves, after Angular set
|
|
678
|
+
// `ngDevMode`; production folds it and drops the dev sink from the bundle.
|
|
679
|
+
get halfWiredSlotSink() {
|
|
680
|
+
return typeof ngDevMode !== 'undefined' && ngDevMode
|
|
681
|
+
? CNGX_DEFAULT_HALF_WIRED_SLOT_SINK
|
|
682
|
+
: SILENT_HALF_WIRED_SLOT_SINK;
|
|
683
|
+
},
|
|
595
684
|
templates: {},
|
|
596
685
|
};
|
|
597
686
|
/**
|
|
@@ -601,9 +690,8 @@ const CNGX_MAT_TABS_CONFIG_DEFAULTS = {
|
|
|
601
690
|
* {@link injectMatTabsConfig}, which merges with the library
|
|
602
691
|
* defaults so callers never see `undefined`.
|
|
603
692
|
*
|
|
604
|
-
* @category ui/mat-tabs
|
|
605
693
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tabs-config.ts
|
|
606
|
-
* @since 0.
|
|
694
|
+
* @since 0.3.0
|
|
607
695
|
*/
|
|
608
696
|
const CNGX_MAT_TABS_CONFIG = new InjectionToken('CngxMatTabsConfig');
|
|
609
697
|
function feature(config) {
|
|
@@ -612,8 +700,6 @@ function feature(config) {
|
|
|
612
700
|
/**
|
|
613
701
|
* Cap on the `[cngxMatTabs]` overflow-anchor retry loop.
|
|
614
702
|
* See {@link CngxMatTabsConfig.anchorMaxAttempts} for default + rationale.
|
|
615
|
-
*
|
|
616
|
-
* @category ui/mat-tabs
|
|
617
703
|
*/
|
|
618
704
|
function withAnchorRetryAttempts(n) {
|
|
619
705
|
return feature({ anchorMaxAttempts: n });
|
|
@@ -621,8 +707,6 @@ function withAnchorRetryAttempts(n) {
|
|
|
621
707
|
/**
|
|
622
708
|
* Override the half-wired-slot diagnostic sink.
|
|
623
709
|
* See {@link CngxMatTabsConfig.halfWiredSlotSink}.
|
|
624
|
-
*
|
|
625
|
-
* @category ui/mat-tabs
|
|
626
710
|
*/
|
|
627
711
|
function withHalfWiredSlotSink(sink) {
|
|
628
712
|
return feature({ halfWiredSlotSink: sink });
|
|
@@ -632,8 +716,6 @@ function withHalfWiredSlotSink(sink) {
|
|
|
632
716
|
* tier; per-instance `*cngxMatTabRejectionContent` still wins.
|
|
633
717
|
* Sibling of {@link withTabRejectionIconTemplate} in the cngx-native
|
|
634
718
|
* family.
|
|
635
|
-
*
|
|
636
|
-
* @category ui/mat-tabs
|
|
637
719
|
*/
|
|
638
720
|
function withMatTabRejectionTemplate(template) {
|
|
639
721
|
return feature({ templates: { rejection: template } });
|
|
@@ -666,8 +748,6 @@ function mergeFeatures(features) {
|
|
|
666
748
|
* ],
|
|
667
749
|
* });
|
|
668
750
|
* ```
|
|
669
|
-
*
|
|
670
|
-
* @category ui/mat-tabs
|
|
671
751
|
*/
|
|
672
752
|
function provideMatTabsConfig(...features) {
|
|
673
753
|
return makeEnvironmentProviders([
|
|
@@ -694,8 +774,6 @@ function provideMatTabsConfig(...features) {
|
|
|
694
774
|
* ...
|
|
695
775
|
* })
|
|
696
776
|
* ```
|
|
697
|
-
*
|
|
698
|
-
* @category ui/mat-tabs
|
|
699
777
|
*/
|
|
700
778
|
function provideMatTabsConfigAt(...features) {
|
|
701
779
|
return [
|
|
@@ -724,8 +802,6 @@ function provideMatTabsConfigAt(...features) {
|
|
|
724
802
|
* 1. `CNGX_MAT_TABS_CONFIG` value (set via
|
|
725
803
|
* {@link provideMatTabsConfig} / {@link provideMatTabsConfigAt}).
|
|
726
804
|
* 2. {@link CNGX_MAT_TABS_CONFIG_DEFAULTS} (library default).
|
|
727
|
-
*
|
|
728
|
-
* @category ui/mat-tabs
|
|
729
805
|
*/
|
|
730
806
|
function injectMatTabsConfig() {
|
|
731
807
|
const user = inject(CNGX_MAT_TABS_CONFIG, { optional: true }) ?? {};
|
|
@@ -736,6 +812,20 @@ function injectMatTabsConfig() {
|
|
|
736
812
|
};
|
|
737
813
|
}
|
|
738
814
|
|
|
815
|
+
/**
|
|
816
|
+
* Resolve the decoration content slots of a Material tab bridge. The
|
|
817
|
+
* `contentChild` queries stay on each host (signal queries must be class
|
|
818
|
+
* fields); the resolution order is shared so both hosts agree.
|
|
819
|
+
*
|
|
820
|
+
* @internal
|
|
821
|
+
*/
|
|
822
|
+
function createDecorationTemplates(aggregatorSlot, rejectionSlot, config) {
|
|
823
|
+
return {
|
|
824
|
+
aggregator: computed(() => aggregatorSlot()?.templateRef ?? null),
|
|
825
|
+
rejection: computed(() => rejectionSlot()?.templateRef ?? config.templates?.rejection ?? null),
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
|
|
739
829
|
/**
|
|
740
830
|
* Structural slot directive marking the aggregator-descriptor
|
|
741
831
|
* template for `[cngxMatTabs]`. Discovered via `contentChild` on the
|
|
@@ -765,10 +855,9 @@ function injectMatTabsConfig() {
|
|
|
765
855
|
* </mat-tab-group>
|
|
766
856
|
* ```
|
|
767
857
|
*
|
|
768
|
-
* @category ui/mat-tabs
|
|
769
858
|
* @wcag AA
|
|
770
859
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/decorations/mat-tab-aggregator-content.directive.ts
|
|
771
|
-
* @since 0.
|
|
860
|
+
* @since 0.3.0
|
|
772
861
|
* @relatedTo CngxMatTabs, CngxMatTabError, CngxMatTabRejectionContent
|
|
773
862
|
*/
|
|
774
863
|
class CngxMatTabAggregatorContent {
|
|
@@ -825,10 +914,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
825
914
|
* </mat-tab-group>
|
|
826
915
|
* ```
|
|
827
916
|
*
|
|
828
|
-
* @category ui/mat-tabs
|
|
829
917
|
* @wcag AA
|
|
830
918
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/decorations/mat-tab-rejection-content.directive.ts
|
|
831
|
-
* @since 0.
|
|
919
|
+
* @since 0.3.0
|
|
832
920
|
* @relatedTo CngxMatTabs, CngxMatTabAggregatorContent, CngxMatTabError
|
|
833
921
|
*/
|
|
834
922
|
class CngxMatTabRejectionContent {
|
|
@@ -895,6 +983,20 @@ function mountLiveRegionAnnouncer(opts) {
|
|
|
895
983
|
* @internal
|
|
896
984
|
*/
|
|
897
985
|
function createRejectionState(presenter, i18n) {
|
|
986
|
+
// A label-less origin is named by its position, as on <cngx-tab-group>;
|
|
987
|
+
// undefined when no origin tab resolves - no origin index, or one past the
|
|
988
|
+
// end because the origin tab was removed meanwhile (the generic copy).
|
|
989
|
+
function originName(originIdx, copy) {
|
|
990
|
+
const origin = originIdx === undefined ? undefined : presenter.tabs()[originIdx];
|
|
991
|
+
if (!origin || originIdx === undefined) {
|
|
992
|
+
return undefined;
|
|
993
|
+
}
|
|
994
|
+
const label = origin.label();
|
|
995
|
+
if (label) {
|
|
996
|
+
return label;
|
|
997
|
+
}
|
|
998
|
+
return copy.unlabeledTab(originIdx + 1);
|
|
999
|
+
}
|
|
898
1000
|
const failedHandleId = computed(() => {
|
|
899
1001
|
const idx = presenter.lastFailedIndex();
|
|
900
1002
|
if (idx === undefined) {
|
|
@@ -913,35 +1015,68 @@ function createRejectionState(presenter, i18n) {
|
|
|
913
1015
|
}
|
|
914
1016
|
return presenter.tabs()[originIdx]?.label() ?? undefined;
|
|
915
1017
|
}, ...(ngDevMode ? [{ debugName: "originLabel" }] : /* istanbul ignore next */ []));
|
|
916
|
-
const
|
|
1018
|
+
const reason = computed(() => {
|
|
917
1019
|
if (presenter.lastFailedIndex() === undefined) {
|
|
1020
|
+
return undefined;
|
|
1021
|
+
}
|
|
1022
|
+
return presenter.lastOutcome()?.kind === 'refused' ? 'refused' : 'failed';
|
|
1023
|
+
}, ...(ngDevMode ? [{ debugName: "reason" }] : /* istanbul ignore next */ []));
|
|
1024
|
+
const descriptorText = computed(() => {
|
|
1025
|
+
const kind = reason();
|
|
1026
|
+
if (kind === undefined) {
|
|
918
1027
|
return '';
|
|
919
1028
|
}
|
|
920
|
-
const label = originLabel();
|
|
921
1029
|
const copy = i18n();
|
|
922
|
-
|
|
1030
|
+
const name = originName(presenter.originIndexDuringCommit(), copy);
|
|
1031
|
+
if (kind === 'refused') {
|
|
1032
|
+
return name ? copy.commitRefused(name) : copy.commitRefusedGeneric;
|
|
1033
|
+
}
|
|
1034
|
+
return name ? copy.commitRolledBackTo(name) : copy.commitFailedRetry;
|
|
923
1035
|
}, ...(ngDevMode ? [{ debugName: "descriptorText" }] : /* istanbul ignore next */ []));
|
|
1036
|
+
// A refusal leaves the commit status at 'idle', so no status edge can
|
|
1037
|
+
// voice it. Same lifecycle as the `<cngx-tab-group>` phrase: armed by a
|
|
1038
|
+
// new refused sequence, spent by the next commit activity, an
|
|
1039
|
+
// active-index move or a cleared outcome.
|
|
1040
|
+
const refusedPhrase = createRefusedPhrase({
|
|
1041
|
+
outcome: () => presenter.lastOutcome(),
|
|
1042
|
+
status: () => presenter.commitTransition.current(),
|
|
1043
|
+
activeIndex: () => presenter.activeIndex(),
|
|
1044
|
+
copy: refusedCopy,
|
|
1045
|
+
});
|
|
1046
|
+
function refusedCopy() {
|
|
1047
|
+
const copy = i18n();
|
|
1048
|
+
const name = originName(presenter.originIndexDuringCommit(), copy);
|
|
1049
|
+
return name ? copy.commitRefused(name) : copy.commitRefusedGeneric;
|
|
1050
|
+
}
|
|
924
1051
|
// Feeds the live announcer: copy and the origin tab label (which a
|
|
925
1052
|
// consumer may translate) are read untracked so a language switch does
|
|
926
1053
|
// not re-announce; the next transition speaks the new language.
|
|
927
1054
|
const liveAnnouncement = computed(() => {
|
|
1055
|
+
// Read the refused phrase EAGERLY: linkedSignal only observes the
|
|
1056
|
+
// snapshots it is read under, so a read behind the pending arm would
|
|
1057
|
+
// miss the status change that spends it.
|
|
1058
|
+
const refused = refusedPhrase();
|
|
1059
|
+
if (refused) {
|
|
1060
|
+
return refused;
|
|
1061
|
+
}
|
|
928
1062
|
const current = presenter.commitTransition.current();
|
|
929
1063
|
if (current === 'pending') {
|
|
930
1064
|
return untracked(() => i18n().commitInFlight);
|
|
931
1065
|
}
|
|
932
1066
|
if (current === 'error') {
|
|
933
1067
|
const failedIdx = presenter.lastFailedIndex();
|
|
934
|
-
const originIdx = presenter.originIndexDuringCommit();
|
|
935
|
-
|
|
936
|
-
const
|
|
1068
|
+
const originIdx = failedIdx === undefined ? undefined : presenter.originIndexDuringCommit();
|
|
1069
|
+
// The indices and the tab list stay tracked; the label is read untracked.
|
|
1070
|
+
const hasOrigin = originIdx !== undefined && presenter.tabs()[originIdx] !== undefined;
|
|
937
1071
|
return untracked(() => {
|
|
938
|
-
const
|
|
939
|
-
|
|
1072
|
+
const copy = i18n();
|
|
1073
|
+
const name = hasOrigin ? originName(originIdx, copy) : undefined;
|
|
1074
|
+
return name ? copy.commitRolledBackTo(name) : copy.commitFailedRetry;
|
|
940
1075
|
});
|
|
941
1076
|
}
|
|
942
1077
|
return '';
|
|
943
1078
|
}, ...(ngDevMode ? [{ debugName: "liveAnnouncement" }] : /* istanbul ignore next */ []));
|
|
944
|
-
return { failedHandleId, originLabel, descriptorText, liveAnnouncement };
|
|
1079
|
+
return { failedHandleId, originLabel, reason, descriptorText, liveAnnouncement };
|
|
945
1080
|
}
|
|
946
1081
|
|
|
947
1082
|
/**
|
|
@@ -1030,8 +1165,6 @@ function createOrderedRegistrationSeam(options) {
|
|
|
1030
1165
|
* - `directError` - writable seeded at `false`;
|
|
1031
1166
|
* `[cngxMatTabErrorFlag]` writes its `string | boolean` value in
|
|
1032
1167
|
* and resets on teardown. Folds into `hasError` / `errorMessage`.
|
|
1033
|
-
*
|
|
1034
|
-
* @category ui/mat-tabs
|
|
1035
1168
|
*/
|
|
1036
1169
|
function createMatTabHandle(matTab, idSeed, injector) {
|
|
1037
1170
|
// Typed local - anchors `MaterialPrivateSurfaces.StateChangeSource`
|
|
@@ -1124,10 +1257,9 @@ function createMatTabHandle(matTab, idSeed, injector) {
|
|
|
1124
1257
|
* ]
|
|
1125
1258
|
* ```
|
|
1126
1259
|
*
|
|
1127
|
-
* @category ui/mat-tabs
|
|
1128
1260
|
* @wcag AA
|
|
1129
1261
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/material-bridge/handle.ts
|
|
1130
|
-
* @since 0.
|
|
1262
|
+
* @since 0.3.0
|
|
1131
1263
|
*/
|
|
1132
1264
|
const CNGX_MAT_TAB_HANDLE_FACTORY = new InjectionToken('CNGX_MAT_TAB_HANDLE_FACTORY', {
|
|
1133
1265
|
providedIn: 'root',
|
|
@@ -1140,10 +1272,9 @@ const CNGX_MAT_TAB_HANDLE_FACTORY = new InjectionToken('CNGX_MAT_TAB_HANDLE_FACT
|
|
|
1140
1272
|
* `{ host: true }` to reach per-handle slots without walking the
|
|
1141
1273
|
* concrete registry class.
|
|
1142
1274
|
*
|
|
1143
|
-
* @category ui/mat-tabs
|
|
1144
1275
|
* @wcag AA
|
|
1145
1276
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tabs-registry.directive.ts
|
|
1146
|
-
* @since 0.
|
|
1277
|
+
* @since 0.3.0
|
|
1147
1278
|
*/
|
|
1148
1279
|
const CNGX_MAT_TABS_REGISTRY_HOST = new InjectionToken('CngxMatTabsRegistryHost');
|
|
1149
1280
|
/**
|
|
@@ -1171,11 +1302,9 @@ const CNGX_MAT_TABS_REGISTRY_HOST = new InjectionToken('CngxMatTabsRegistryHost'
|
|
|
1171
1302
|
* both share the parent's `CngxTabGroupPresenter` and the same
|
|
1172
1303
|
* `<mat-tab-group>` content-children scope.
|
|
1173
1304
|
*
|
|
1174
|
-
* @category ui/mat-tabs
|
|
1175
|
-
* @docsKind primary
|
|
1176
1305
|
* @wcag AA
|
|
1177
1306
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tabs-registry.directive.ts
|
|
1178
|
-
* @since 0.
|
|
1307
|
+
* @since 0.3.0
|
|
1179
1308
|
* @relatedTo CngxMatTabs, CngxMatTabError, CNGX_MAT_TABS_REGISTRY_HOST
|
|
1180
1309
|
*/
|
|
1181
1310
|
class CngxMatTabsRegistry {
|
|
@@ -1213,6 +1342,12 @@ class CngxMatTabsRegistry {
|
|
|
1213
1342
|
});
|
|
1214
1343
|
this.destroyRef.onDestroy(() => this.seam.clear());
|
|
1215
1344
|
}
|
|
1345
|
+
/**
|
|
1346
|
+
* Returns the writable `errorAggregator` and `directError` slots of the given `<mat-tab>`, or
|
|
1347
|
+
* `undefined` while the tab is not registered yet. Implements `CngxMatTabsRegistryHost`, which
|
|
1348
|
+
* `CngxMatTabError` and `CngxMatTabErrorFlag` call to write their value and to reset it on
|
|
1349
|
+
* destroy.
|
|
1350
|
+
*/
|
|
1216
1351
|
getHandleSetup(matTab) {
|
|
1217
1352
|
return this.seam.get(matTab)?.setup;
|
|
1218
1353
|
}
|
|
@@ -1261,9 +1396,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1261
1396
|
* ]
|
|
1262
1397
|
* ```
|
|
1263
1398
|
*
|
|
1264
|
-
* @category ui/mat-tabs
|
|
1265
1399
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/overflow/mat-tab-overflow-dom-adapter.ts
|
|
1266
|
-
* @since 0.
|
|
1400
|
+
* @since 0.3.0
|
|
1267
1401
|
* @relatedTo CngxTabOverflow, CngxMatTabs, CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY
|
|
1268
1402
|
*/
|
|
1269
1403
|
function createCngxMatTabOverflowDomAdapter() {
|
|
@@ -1348,14 +1482,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1348
1482
|
*
|
|
1349
1483
|
* @playground Form error aggregation ./examples/form-errors/form-errors.component.ts
|
|
1350
1484
|
*
|
|
1351
|
-
* @category ui/mat-tabs
|
|
1352
|
-
* @docsKind primary
|
|
1353
1485
|
* @wcag AA
|
|
1354
1486
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tabs.directive.ts
|
|
1355
|
-
* @since 0.
|
|
1487
|
+
* @since 0.3.0
|
|
1356
1488
|
* @relatedTo CngxMatTabsRegistry, CngxMatTabError, CngxMatStepper
|
|
1357
1489
|
* @slot cngxMatTabAggregatorContent Replaces the aggregated error summary projected into a Material tab.
|
|
1358
1490
|
* @slot cngxMatTabRejectionContent Replaces the rejection notice on a rolled-back Material tab.
|
|
1491
|
+
* @axis level organism
|
|
1359
1492
|
*/
|
|
1360
1493
|
class CngxMatTabs {
|
|
1361
1494
|
matTabGroup = inject(MatTabGroup, { self: true });
|
|
@@ -1381,12 +1514,10 @@ class CngxMatTabs {
|
|
|
1381
1514
|
injector: this.injector,
|
|
1382
1515
|
});
|
|
1383
1516
|
aggregatorContentSlot = contentChild(CngxMatTabAggregatorContent, ...(ngDevMode ? [{ debugName: "aggregatorContentSlot" }] : /* istanbul ignore next */ []));
|
|
1384
|
-
aggregatorContentTemplate = computed(() => this.aggregatorContentSlot()?.templateRef ?? null, ...(ngDevMode ? [{ debugName: "aggregatorContentTemplate" }] : /* istanbul ignore next */ []));
|
|
1385
1517
|
matTabsConfig = injectMatTabsConfig();
|
|
1386
1518
|
rejectionContentSlot = contentChild(CngxMatTabRejectionContent, ...(ngDevMode ? [{ debugName: "rejectionContentSlot" }] : /* istanbul ignore next */ []));
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
null, ...(ngDevMode ? [{ debugName: "rejectionContentTemplate" }] : /* istanbul ignore next */ []));
|
|
1519
|
+
// Shared with `[cngxMatTabNav]`: one slot resolution order for both hosts.
|
|
1520
|
+
decorationTemplates = createDecorationTemplates(this.aggregatorContentSlot, this.rejectionContentSlot, this.matTabsConfig);
|
|
1390
1521
|
i18n = injectTabsI18n();
|
|
1391
1522
|
// Bundle shares one source-walk across failedHandleId /
|
|
1392
1523
|
// descriptorText / originLabel / liveAnnouncement - pillar-2
|
|
@@ -1395,7 +1526,7 @@ class CngxMatTabs {
|
|
|
1395
1526
|
// Shared with `[cngxMatTabNav]` - one body, two hosts (Pillar 3).
|
|
1396
1527
|
// Structural equal lives in the factory so the projector doesn't
|
|
1397
1528
|
// churn on no-op aggregator re-emissions.
|
|
1398
|
-
aggregatedErrorTabs = createAggregatedErrorTabs(this.presenter);
|
|
1529
|
+
aggregatedErrorTabs = createAggregatedErrorTabs(this.presenter, this.i18n);
|
|
1399
1530
|
constructor() {
|
|
1400
1531
|
const matTabsConfig = this.matTabsConfig;
|
|
1401
1532
|
// Polite live region - attribute directive owns no template, so
|
|
@@ -1415,9 +1546,10 @@ class CngxMatTabs {
|
|
|
1415
1546
|
renderer: this.renderer,
|
|
1416
1547
|
injector: this.injector,
|
|
1417
1548
|
destroyRef: this.destroyRef,
|
|
1418
|
-
contentTemplate: this.
|
|
1549
|
+
contentTemplate: this.decorationTemplates.rejection,
|
|
1419
1550
|
viewContainerRef: this.viewContainerRef,
|
|
1420
1551
|
originLabel: this.rejectionState.originLabel,
|
|
1552
|
+
reason: this.rejectionState.reason,
|
|
1421
1553
|
});
|
|
1422
1554
|
createMatTabAggregatorDecoration({
|
|
1423
1555
|
hostEl: this.hostEl,
|
|
@@ -1425,7 +1557,7 @@ class CngxMatTabs {
|
|
|
1425
1557
|
renderer: this.renderer,
|
|
1426
1558
|
injector: this.injector,
|
|
1427
1559
|
destroyRef: this.destroyRef,
|
|
1428
|
-
contentTemplate: this.
|
|
1560
|
+
contentTemplate: this.decorationTemplates.aggregator,
|
|
1429
1561
|
viewContainerRef: this.viewContainerRef,
|
|
1430
1562
|
onHalfWiredSlot: matTabsConfig.halfWiredSlotSink,
|
|
1431
1563
|
});
|
|
@@ -1455,8 +1587,8 @@ class CngxMatTabs {
|
|
|
1455
1587
|
return () => undefined;
|
|
1456
1588
|
},
|
|
1457
1589
|
onGiveUp: () => {
|
|
1458
|
-
if (
|
|
1459
|
-
|
|
1590
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
1591
|
+
cngxDevWarn('CNGX3007', `[cngxMatTabs] could not anchor <cngx-tab-overflow> after ${anchorMaxAttempts} ` +
|
|
1460
1592
|
'attempts - .mat-mdc-tab-header was not found inside the ' +
|
|
1461
1593
|
'host. The More popover will fall back to a sibling-of-' +
|
|
1462
1594
|
'<mat-tab-group> position; verify Material rendered the ' +
|
|
@@ -1480,14 +1612,21 @@ class CngxMatTabs {
|
|
|
1480
1612
|
});
|
|
1481
1613
|
// Routed (pessimistic) gate: a rejected switch holds `activeIndex` at
|
|
1482
1614
|
// origin, so the presenter to Material mirror never fires and Material
|
|
1483
|
-
// stays eager-advanced on the
|
|
1484
|
-
// commit settles
|
|
1485
|
-
//
|
|
1486
|
-
//
|
|
1615
|
+
// stays eager-advanced on the rejected tab. Snap it back when the
|
|
1616
|
+
// commit settles as refused or failed. Keyed on the outcome sequence,
|
|
1617
|
+
// not the status: a refusal settles to 'idle' and never reaches
|
|
1618
|
+
// 'error', while every failure through `select()` records a failed
|
|
1619
|
+
// outcome with a fresh sequence in the same flush as the 'error'
|
|
1620
|
+
// status, so the sequence edge covers both. One reconcile per settle:
|
|
1621
|
+
// a second write of the same index leaves a self-echo that Material
|
|
1622
|
+
// never emits and that would swallow the user's next pick of that
|
|
1623
|
+
// tab. A number compares with `Object.is`, so the close shift (index
|
|
1624
|
+
// moved, sequence copied) never re-runs it; `undefined` is ignored.
|
|
1625
|
+
const outcomeSequence = computed(() => this.presenter.lastOutcome()?.sequence, ...(ngDevMode ? [{ debugName: "outcomeSequence" }] : /* istanbul ignore next */ []));
|
|
1487
1626
|
effect(() => {
|
|
1488
|
-
const
|
|
1627
|
+
const sequence = outcomeSequence();
|
|
1489
1628
|
untracked(() => {
|
|
1490
|
-
if (
|
|
1629
|
+
if (sequence !== undefined) {
|
|
1491
1630
|
sync.reconcile();
|
|
1492
1631
|
}
|
|
1493
1632
|
});
|
|
@@ -1596,19 +1735,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1596
1735
|
* the live-region announcer come for free, identical to the cngx
|
|
1597
1736
|
* organism (Pillar 2 - same communication across skins).
|
|
1598
1737
|
*
|
|
1599
|
-
* Decoration content-template slots
|
|
1600
|
-
* `*
|
|
1601
|
-
*
|
|
1602
|
-
*
|
|
1738
|
+
* Decoration content-template slots resolve as on `[cngxMatTabs]`:
|
|
1739
|
+
* a projected `*cngxMatTabRejectionContent` wins over
|
|
1740
|
+
* `provideMatTabsConfig(withMatTabRejectionTemplate(...))`, and a
|
|
1741
|
+
* projected `*cngxMatTabAggregatorContent` replaces the aggregated error
|
|
1742
|
+
* summary; without either, the projectors render their built-in
|
|
1743
|
+
* `cngx-sr-only` text.
|
|
1603
1744
|
*
|
|
1604
1745
|
* @playground Native router tabs with a CanDeactivate guard ./examples/router-nav/router-nav.component.ts
|
|
1605
1746
|
*
|
|
1606
|
-
* @category ui/mat-tabs
|
|
1607
|
-
* @docsKind primary
|
|
1608
1747
|
* @wcag AA
|
|
1609
1748
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tab-nav.directive.ts
|
|
1610
|
-
* @since 0.
|
|
1749
|
+
* @since 0.3.0
|
|
1611
1750
|
* @relatedTo CngxMatTabLink, CngxMatTabs, CngxTabsRouteSync
|
|
1751
|
+
* @slot cngxMatTabAggregatorContent Replaces the aggregated error summary projected into a Material tab.
|
|
1752
|
+
* @slot cngxMatTabRejectionContent Replaces the rejection notice on a rolled-back Material tab.
|
|
1753
|
+
* @axis level organism
|
|
1612
1754
|
*/
|
|
1613
1755
|
class CngxMatTabNav {
|
|
1614
1756
|
presenter = inject(CNGX_TAB_GROUP_HOST);
|
|
@@ -1616,9 +1758,14 @@ class CngxMatTabNav {
|
|
|
1616
1758
|
injector = inject(Injector);
|
|
1617
1759
|
renderer = inject(Renderer2);
|
|
1618
1760
|
hostEl = inject(ElementRef).nativeElement;
|
|
1761
|
+
viewContainerRef = inject(ViewContainerRef);
|
|
1762
|
+
matTabsConfig = injectMatTabsConfig();
|
|
1619
1763
|
i18n = injectTabsI18n();
|
|
1764
|
+
aggregatorContentSlot = contentChild(CngxMatTabAggregatorContent, ...(ngDevMode ? [{ debugName: "aggregatorContentSlot" }] : /* istanbul ignore next */ []));
|
|
1765
|
+
rejectionContentSlot = contentChild(CngxMatTabRejectionContent, ...(ngDevMode ? [{ debugName: "rejectionContentSlot" }] : /* istanbul ignore next */ []));
|
|
1766
|
+
decorationTemplates = createDecorationTemplates(this.aggregatorContentSlot, this.rejectionContentSlot, this.matTabsConfig);
|
|
1620
1767
|
rejectionState = createRejectionState(this.presenter, this.i18n);
|
|
1621
|
-
aggregatedErrorTabs = createAggregatedErrorTabs(this.presenter);
|
|
1768
|
+
aggregatedErrorTabs = createAggregatedErrorTabs(this.presenter, this.i18n);
|
|
1622
1769
|
constructor() {
|
|
1623
1770
|
mountLiveRegionAnnouncer({
|
|
1624
1771
|
announcement: this.rejectionState.liveAnnouncement,
|
|
@@ -1644,7 +1791,10 @@ class CngxMatTabNav {
|
|
|
1644
1791
|
renderer: this.renderer,
|
|
1645
1792
|
injector: this.injector,
|
|
1646
1793
|
destroyRef: this.destroyRef,
|
|
1794
|
+
contentTemplate: this.decorationTemplates.rejection,
|
|
1795
|
+
viewContainerRef: this.viewContainerRef,
|
|
1647
1796
|
originLabel: this.rejectionState.originLabel,
|
|
1797
|
+
reason: this.rejectionState.reason,
|
|
1648
1798
|
buttonSelector: '.mat-mdc-tab-link',
|
|
1649
1799
|
});
|
|
1650
1800
|
createMatTabAggregatorDecoration({
|
|
@@ -1653,6 +1803,9 @@ class CngxMatTabNav {
|
|
|
1653
1803
|
renderer: this.renderer,
|
|
1654
1804
|
injector: this.injector,
|
|
1655
1805
|
destroyRef: this.destroyRef,
|
|
1806
|
+
contentTemplate: this.decorationTemplates.aggregator,
|
|
1807
|
+
viewContainerRef: this.viewContainerRef,
|
|
1808
|
+
onHalfWiredSlot: this.matTabsConfig.halfWiredSlotSink,
|
|
1656
1809
|
buttonSelector: '.mat-mdc-tab-link',
|
|
1657
1810
|
});
|
|
1658
1811
|
}
|
|
@@ -1665,7 +1818,7 @@ class CngxMatTabNav {
|
|
|
1665
1818
|
this.presenter.clearLastFailed();
|
|
1666
1819
|
}
|
|
1667
1820
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabNav, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1668
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "
|
|
1821
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxMatTabNav, isStandalone: true, selector: "[cngxMatTabNav]", providers: [{ provide: CNGX_TAB_NAV_HOST, useValue: true }], queries: [{ propertyName: "aggregatorContentSlot", first: true, predicate: CngxMatTabAggregatorContent, descendants: true, isSignal: true }, { propertyName: "rejectionContentSlot", first: true, predicate: CngxMatTabRejectionContent, descendants: true, isSignal: true }], exportAs: ["cngxMatTabNav"], hostDirectives: [{ directive: i1.CngxTabGroupPresenter, inputs: ["activeIndex", "activeIndex"], outputs: ["activeIndexChange", "activeIndexChange"] }], ngImport: i0 });
|
|
1669
1822
|
}
|
|
1670
1823
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabNav, decorators: [{
|
|
1671
1824
|
type: Directive,
|
|
@@ -1684,7 +1837,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1684
1837
|
},
|
|
1685
1838
|
],
|
|
1686
1839
|
}]
|
|
1687
|
-
}], ctorParameters: () => [] });
|
|
1840
|
+
}], ctorParameters: () => [], propDecorators: { aggregatorContentSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxMatTabAggregatorContent), { isSignal: true }] }], rejectionContentSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxMatTabRejectionContent), { isSignal: true }] }] } });
|
|
1688
1841
|
|
|
1689
1842
|
/**
|
|
1690
1843
|
* Registers an `<a mat-tab-link>` anchor as a {@link CngxTabHandle}
|
|
@@ -1705,15 +1858,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1705
1858
|
* which matches each handle's `id` (set to the route segment) against
|
|
1706
1859
|
* the URL.
|
|
1707
1860
|
*
|
|
1708
|
-
* @category ui/mat-tabs
|
|
1709
|
-
* @docsKind primary
|
|
1710
1861
|
* @wcag AA
|
|
1711
1862
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tab-link.directive.ts
|
|
1712
|
-
* @since 0.
|
|
1863
|
+
* @since 0.3.0
|
|
1713
1864
|
* @relatedTo CngxMatTabNav, CngxMatTabs, CngxTab
|
|
1714
1865
|
*/
|
|
1715
1866
|
class CngxMatTabLink {
|
|
1716
|
-
matLink = inject(MatTabLink, { self: true });
|
|
1717
1867
|
host = inject(CNGX_TAB_GROUP_HOST);
|
|
1718
1868
|
destroyRef = inject(DestroyRef);
|
|
1719
1869
|
/**
|
|
@@ -1733,6 +1883,14 @@ class CngxMatTabLink {
|
|
|
1733
1883
|
error = input(false, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
1734
1884
|
/** Optional rich error aggregator for the link. */
|
|
1735
1885
|
errorAggregator = input(undefined, ...(ngDevMode ? [{ debugName: "errorAggregator" }] : /* istanbul ignore next */ []));
|
|
1886
|
+
/**
|
|
1887
|
+
* Disabled state of the link. Angular binds `[disabled]` to every
|
|
1888
|
+
* directive on the element that declares the input, so `MatTabLink`
|
|
1889
|
+
* and this directive read one template binding and the handle tracks
|
|
1890
|
+
* it live. An imperative write to the `MatTabLink` instance is not
|
|
1891
|
+
* seen; the template binding is the contract.
|
|
1892
|
+
*/
|
|
1893
|
+
disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
1736
1894
|
errorMessage = computed(() => {
|
|
1737
1895
|
const value = this.error();
|
|
1738
1896
|
return typeof value === 'string' && value !== '' ? value : undefined;
|
|
@@ -1742,18 +1900,12 @@ class CngxMatTabLink {
|
|
|
1742
1900
|
return ((direct !== false && direct !== '') ||
|
|
1743
1901
|
(this.errorAggregator()?.shouldShow?.() ?? false));
|
|
1744
1902
|
}, { ...(ngDevMode ? { debugName: "hasError" } : /* istanbul ignore next */ {}), equal: Object.is });
|
|
1745
|
-
// Material's MatTabLink.disabled is a plain property, not a signal;
|
|
1746
|
-
// nav links rarely toggle disabled at runtime, so snapshot it onto a
|
|
1747
|
-
// signal at registration. A live binding would need a Material
|
|
1748
|
-
// reactive surface MatTabLink does not expose.
|
|
1749
|
-
disabledState = signal(false, ...(ngDevMode ? [{ debugName: "disabledState" }] : /* istanbul ignore next */ []));
|
|
1750
1903
|
ngOnInit() {
|
|
1751
|
-
this.disabledState.set(this.matLink.disabled);
|
|
1752
1904
|
const handle = {
|
|
1753
1905
|
id: this.id(),
|
|
1754
1906
|
label: this.label,
|
|
1755
1907
|
subLabel: signal(undefined),
|
|
1756
|
-
disabled: this.
|
|
1908
|
+
disabled: this.disabled,
|
|
1757
1909
|
errorAggregator: this.errorAggregator,
|
|
1758
1910
|
hasError: this.hasError,
|
|
1759
1911
|
errorMessage: this.errorMessage,
|
|
@@ -1763,7 +1915,7 @@ class CngxMatTabLink {
|
|
|
1763
1915
|
this.destroyRef.onDestroy(() => this.host.unregister(handle.id, handle));
|
|
1764
1916
|
}
|
|
1765
1917
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabLink, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1766
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxMatTabLink, isStandalone: true, selector: "[cngxMatTabLink]", 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 } }, exportAs: ["cngxMatTabLink"], ngImport: i0 });
|
|
1918
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxMatTabLink, isStandalone: true, selector: "[cngxMatTabLink]", 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 }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["cngxMatTabLink"], ngImport: i0 });
|
|
1767
1919
|
}
|
|
1768
1920
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabLink, decorators: [{
|
|
1769
1921
|
type: Directive,
|
|
@@ -1772,7 +1924,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1772
1924
|
exportAs: 'cngxMatTabLink',
|
|
1773
1925
|
standalone: true,
|
|
1774
1926
|
}]
|
|
1775
|
-
}], 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 }] }] } });
|
|
1927
|
+
}], 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 }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }] } });
|
|
1928
|
+
|
|
1929
|
+
/**
|
|
1930
|
+
* Inject the `<mat-tab>` a per-tab error directive sits on, plus the registry
|
|
1931
|
+
* and presenter of the surrounding `<mat-tab-group cngxMatTabs>`. Throws a
|
|
1932
|
+
* `CngxRuntimeError` with code `CNGX3020` when either prerequisite is
|
|
1933
|
+
* missing, in development and production alike. `selector` names the
|
|
1934
|
+
* directive in the development message.
|
|
1935
|
+
*
|
|
1936
|
+
* @internal
|
|
1937
|
+
*/
|
|
1938
|
+
function injectMatTabErrorTarget(selector) {
|
|
1939
|
+
const matTab = inject(MatTab, { self: true, optional: true });
|
|
1940
|
+
const registry = inject(CNGX_MAT_TABS_REGISTRY_HOST, { host: true, optional: true });
|
|
1941
|
+
const presenter = inject(CNGX_TAB_GROUP_HOST, { optional: true });
|
|
1942
|
+
if (!matTab || !registry || !presenter) {
|
|
1943
|
+
throw new CngxRuntimeError('CNGX3020', typeof ngDevMode !== 'undefined' &&
|
|
1944
|
+
ngDevMode &&
|
|
1945
|
+
`[${selector}] must be placed on a <mat-tab> inside <mat-tab-group cngxMatTabs>.`);
|
|
1946
|
+
}
|
|
1947
|
+
return { matTab, registry, presenter };
|
|
1948
|
+
}
|
|
1776
1949
|
|
|
1777
1950
|
/**
|
|
1778
1951
|
* Per-tab error-aggregator binding for `[cngxMatTabs]`. Attach to a
|
|
@@ -1796,19 +1969,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1796
1969
|
* the slot so an `*ngIf`-toggled binding returns to the
|
|
1797
1970
|
* no-aggregator default.
|
|
1798
1971
|
*
|
|
1799
|
-
* @category ui/mat-tabs
|
|
1800
1972
|
* @wcag AA
|
|
1801
1973
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tab-error.directive.ts
|
|
1802
|
-
* @since 0.
|
|
1974
|
+
* @since 0.3.0
|
|
1803
1975
|
* @relatedTo CngxMatTabs, CngxMatTabsRegistry, CngxMatTabRejectionContent
|
|
1804
1976
|
*/
|
|
1805
1977
|
class CngxMatTabError {
|
|
1806
|
-
|
|
1807
|
-
registry = inject(CNGX_MAT_TABS_REGISTRY_HOST, {
|
|
1808
|
-
host: true,
|
|
1809
|
-
});
|
|
1810
|
-
presenter = inject(CNGX_TAB_GROUP_HOST);
|
|
1978
|
+
target = injectMatTabErrorTarget('cngxMatTabError');
|
|
1811
1979
|
destroyRef = inject(DestroyRef);
|
|
1980
|
+
/**
|
|
1981
|
+
* Error aggregator for this tab, bound as `[cngxMatTabError]`. Its `shouldShow()` decides
|
|
1982
|
+
* whether the tab header shows the error badge, and it is written into the tab's aggregator
|
|
1983
|
+
* slot in the registry. A string value (the bare attribute) and `undefined` both mean no
|
|
1984
|
+
* aggregator, and the slot is reset to `undefined` when the directive is destroyed.
|
|
1985
|
+
*/
|
|
1812
1986
|
aggregator = input(undefined, { ...(ngDevMode ? { debugName: "aggregator" } : /* istanbul ignore next */ {}), alias: 'cngxMatTabError',
|
|
1813
1987
|
transform: (value) => (typeof value === 'string' ? undefined : value) });
|
|
1814
1988
|
constructor() {
|
|
@@ -1824,14 +1998,14 @@ class CngxMatTabError {
|
|
|
1824
1998
|
// the effect re-fires once our `MatTab` is registered. The bare
|
|
1825
1999
|
// read is intentional; full rationale lives in the effect's
|
|
1826
2000
|
// opening comment above. Do NOT tag as dead code.
|
|
1827
|
-
this.presenter.tabs();
|
|
2001
|
+
this.target.presenter.tabs();
|
|
1828
2002
|
untracked(() => {
|
|
1829
|
-
const setup = this.registry.getHandleSetup(this.matTab);
|
|
2003
|
+
const setup = this.target.registry.getHandleSetup(this.target.matTab);
|
|
1830
2004
|
setup?.errorAggregator.set(aggregator);
|
|
1831
2005
|
});
|
|
1832
2006
|
});
|
|
1833
2007
|
this.destroyRef.onDestroy(() => {
|
|
1834
|
-
const setup = this.registry.getHandleSetup(this.matTab);
|
|
2008
|
+
const setup = this.target.registry.getHandleSetup(this.target.matTab);
|
|
1835
2009
|
setup?.errorAggregator.set(undefined);
|
|
1836
2010
|
});
|
|
1837
2011
|
}
|
|
@@ -1853,7 +2027,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1853
2027
|
* `string | boolean` writes the per-handle `directError` slot, which
|
|
1854
2028
|
* folds into the handle's `hasError` / `errorMessage`. A non-empty
|
|
1855
2029
|
* string doubles as the SR descriptor message; `true` marks the tab
|
|
1856
|
-
* invalid with no message; `false`
|
|
2030
|
+
* invalid with no message; `false` clears it. The folded state
|
|
2031
|
+
* drives the same header decoration as the aggregator: the
|
|
2032
|
+
* `cngx-mat-tab--has-errors` badge plus an SR-only descriptor span
|
|
2033
|
+
* referenced through `aria-describedby` (message, else the
|
|
2034
|
+
* `tabHasErrors` i18n phrase), removed again when the flag clears.
|
|
1857
2035
|
*
|
|
1858
2036
|
* Symmetric with `[cngxMatTabError]` (one directive, one
|
|
1859
2037
|
* responsibility - Pillar 3): the aggregator stays the rich
|
|
@@ -1866,19 +2044,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1866
2044
|
* `presenter.tabs()` to recover from the content-init race, and
|
|
1867
2045
|
* clears the slot on destroy - exactly as {@link CngxMatTabError}.
|
|
1868
2046
|
*
|
|
1869
|
-
* @category ui/mat-tabs
|
|
1870
2047
|
* @wcag AA
|
|
1871
2048
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tab-error-flag.directive.ts
|
|
1872
|
-
* @since 0.
|
|
2049
|
+
* @since 0.3.0
|
|
1873
2050
|
* @relatedTo CngxMatTabs, CngxMatTabError, CngxMatTabsRegistry
|
|
2051
|
+
* @axis level atom
|
|
1874
2052
|
*/
|
|
1875
2053
|
class CngxMatTabErrorFlag {
|
|
1876
|
-
|
|
1877
|
-
registry = inject(CNGX_MAT_TABS_REGISTRY_HOST, {
|
|
1878
|
-
host: true,
|
|
1879
|
-
});
|
|
1880
|
-
presenter = inject(CNGX_TAB_GROUP_HOST);
|
|
2054
|
+
target = injectMatTabErrorTarget('cngxMatTabErrorFlag');
|
|
1881
2055
|
destroyRef = inject(DestroyRef);
|
|
2056
|
+
/**
|
|
2057
|
+
* Direct invalid flag for this tab, bound as `[cngxMatTabErrorFlag]`. `true` marks the tab
|
|
2058
|
+
* invalid, a non-empty string also serves as the screen-reader message, and `false` (the
|
|
2059
|
+
* default) clears the flag. The empty string (the bare attribute) is coerced to `true`. The
|
|
2060
|
+
* value is written into the tab's direct-error slot in the registry, which is reset to `false`
|
|
2061
|
+
* when the directive is destroyed.
|
|
2062
|
+
*/
|
|
1882
2063
|
error = input(false, { ...(ngDevMode ? { debugName: "error" } : /* istanbul ignore next */ {}), alias: 'cngxMatTabErrorFlag',
|
|
1883
2064
|
transform: (value) => (value === '' ? true : value) });
|
|
1884
2065
|
constructor() {
|
|
@@ -1889,14 +2070,14 @@ class CngxMatTabErrorFlag {
|
|
|
1889
2070
|
// effect once our handle is registered. `untracked` around the
|
|
1890
2071
|
// write keeps the slot pump out of the reactive graph.
|
|
1891
2072
|
const error = this.error();
|
|
1892
|
-
this.presenter.tabs();
|
|
2073
|
+
this.target.presenter.tabs();
|
|
1893
2074
|
untracked(() => {
|
|
1894
|
-
const setup = this.registry.getHandleSetup(this.matTab);
|
|
2075
|
+
const setup = this.target.registry.getHandleSetup(this.target.matTab);
|
|
1895
2076
|
setup?.directError.set(error);
|
|
1896
2077
|
});
|
|
1897
2078
|
});
|
|
1898
2079
|
this.destroyRef.onDestroy(() => {
|
|
1899
|
-
const setup = this.registry.getHandleSetup(this.matTab);
|
|
2080
|
+
const setup = this.target.registry.getHandleSetup(this.target.matTab);
|
|
1900
2081
|
setup?.directError.set(false);
|
|
1901
2082
|
});
|
|
1902
2083
|
}
|
|
@@ -1913,7 +2094,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1913
2094
|
}], ctorParameters: () => [], propDecorators: { error: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxMatTabErrorFlag", required: false }] }] } });
|
|
1914
2095
|
|
|
1915
2096
|
/**
|
|
1916
|
-
* @module
|
|
2097
|
+
* @module `@cngx/ui/mat-tabs`
|
|
1917
2098
|
*
|
|
1918
2099
|
* Material instrumentation directive for `<mat-tab-group>`.
|
|
1919
2100
|
*/
|