@cngx/ui 0.1.0-rc.8 → 0.1.0-rc.9
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/command-palette/README.md +5 -2
- package/fesm2022/cngx-ui-accordion.mjs +19 -2
- package/fesm2022/cngx-ui-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-action-button.mjs +10 -7
- package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
- package/fesm2022/cngx-ui-breadcrumb.mjs +55 -15
- package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -1
- package/fesm2022/cngx-ui-collection.mjs +10 -0
- package/fesm2022/cngx-ui-collection.mjs.map +1 -1
- package/fesm2022/cngx-ui-command-palette.mjs +2 -2
- package/fesm2022/cngx-ui-command-palette.mjs.map +1 -1
- package/fesm2022/cngx-ui-context-menu.mjs +60 -6
- package/fesm2022/cngx-ui-context-menu.mjs.map +1 -1
- package/fesm2022/cngx-ui-data-grid-accordion.mjs +87 -7
- package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-feedback.mjs +63 -32
- package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-accordion.mjs +3 -2
- package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-tabs.mjs +264 -86
- package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-paginator.mjs +67 -21
- package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
- package/fesm2022/cngx-ui-sidenav.mjs +19 -5
- package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
- package/fesm2022/cngx-ui-stepper.mjs +65 -53
- package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
- package/fesm2022/cngx-ui-tabs.mjs +84 -25
- package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-timeline.mjs +28 -6
- package/fesm2022/cngx-ui-timeline.mjs.map +1 -1
- package/fesm2022/cngx-ui-toc.mjs +32 -8
- package/fesm2022/cngx-ui-toc.mjs.map +1 -1
- package/fesm2022/cngx-ui.mjs +1 -1
- package/mat-tabs/README.md +30 -6
- package/mat-tabs/styles/mat-tabs.css +180 -33
- package/package.json +31 -7
- package/schematics/collection.json +9 -0
- package/schematics/ng-add/index.js +9 -0
- package/schematics/ng-add/schema.json +91 -0
- package/schematics/package.json +3 -0
- package/stepper/README.md +1 -1
- package/types/cngx-ui-accordion.d.ts +9 -2
- package/types/cngx-ui-breadcrumb.d.ts +14 -3
- package/types/cngx-ui-collection.d.ts +10 -0
- package/types/cngx-ui-context-menu.d.ts +42 -4
- package/types/cngx-ui-data-grid-accordion.d.ts +4 -1
- package/types/cngx-ui-feedback.d.ts +11 -3
- package/types/cngx-ui-mat-accordion.d.ts +3 -2
- package/types/cngx-ui-mat-tabs.d.ts +44 -21
- package/types/cngx-ui-paginator.d.ts +22 -7
- package/types/cngx-ui-stepper.d.ts +23 -23
- package/types/cngx-ui-tabs.d.ts +4 -2
- package/types/cngx-ui-timeline.d.ts +12 -4
- package/types/cngx-ui-toc.d.ts +13 -3
|
@@ -1,10 +1,11 @@
|
|
|
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
|
-
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';
|
|
6
|
+
import { CNGX_TABS_GLYPHS, 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, CngxRuntimeError } from '@cngx/utils';
|
|
8
9
|
import { CngxLiveAnnouncer } from '@cngx/common/a11y';
|
|
9
10
|
import { nextUid } from '@cngx/core/utils';
|
|
10
11
|
import { toSignal } from '@angular/core/rxjs-interop';
|
|
@@ -19,10 +20,10 @@ import { toSignal } from '@angular/core/rxjs-interop';
|
|
|
19
20
|
* rather than reach for this reference directly.
|
|
20
21
|
*/
|
|
21
22
|
const CNGX_DEFAULT_HALF_WIRED_SLOT_SINK = (missing) => {
|
|
22
|
-
if (!
|
|
23
|
+
if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
|
|
23
24
|
return;
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
+
cngxDevWarn('CNGX3006', '[cngxMatTabs] aggregator-content slot half-wired - ' +
|
|
26
27
|
`\`${missing}\` is missing while the other half is supplied. ` +
|
|
27
28
|
'The decoration projector will silently fall back to the ' +
|
|
28
29
|
'imperative `textContent` path, and the consumer-projected ' +
|
|
@@ -93,7 +94,8 @@ var MaterialPrivateSurfaces;
|
|
|
93
94
|
*
|
|
94
95
|
* - {@link createMatTabRejectionDecoration} - mirrors
|
|
95
96
|
* `presenter.lastFailedIndex` onto the matching `.mat-mdc-tab` as a
|
|
96
|
-
* class flag
|
|
97
|
+
* class flag, a `data-reason` attribute, an `aria-hidden` glyph span
|
|
98
|
+
* and a hidden `cngx-sr-only` descriptor span linked via
|
|
97
99
|
* `aria-describedby`. `aria-invalid` is intentionally absent: ARIA
|
|
98
100
|
* 1.2 scopes it to form-field vocabulary, not `role="tab"`.
|
|
99
101
|
* - {@link createMatTabAggregatorDecoration} - projects each handle's
|
|
@@ -161,6 +163,7 @@ function createMatTabRejectionDecoration(opts) {
|
|
|
161
163
|
const buttonSelector = opts.buttonSelector ?? MaterialPrivateSurfaces.MAT_MDC_TAB_SELECTOR;
|
|
162
164
|
const className = opts.className ?? 'cngx-mat-tab--error';
|
|
163
165
|
const srOnlyClassName = opts.srOnlyClassName ?? 'cngx-sr-only';
|
|
166
|
+
const glyphClassName = opts.glyphClassName ?? 'cngx-mat-tab__rejection-icon';
|
|
164
167
|
const descriptorIdSuffix = opts.descriptorIdSuffix ?? 'rejected';
|
|
165
168
|
const maxRetryAttempts = opts.maxRetryAttempts ?? 5;
|
|
166
169
|
let pendingRetry = false;
|
|
@@ -173,6 +176,9 @@ function createMatTabRejectionDecoration(opts) {
|
|
|
173
176
|
// Cached across the projector's lifetime - reusing the same node
|
|
174
177
|
// keeps AT-reader / observer references live across A→B→A flips.
|
|
175
178
|
let cachedSpan = null;
|
|
179
|
+
// The visible glyph rides its own `aria-hidden` span: `::before` is
|
|
180
|
+
// Material's focus indicator, `::after` the has-errors badge.
|
|
181
|
+
let cachedGlyph = null;
|
|
176
182
|
let priorAriaDescribedby = null;
|
|
177
183
|
// Pillar 1 - short-circuits structurally-identical re-emissions of
|
|
178
184
|
// `failedHandleId` so a `tabs()` re-eval doesn't clobber the AT
|
|
@@ -201,6 +207,7 @@ function createMatTabRejectionDecoration(opts) {
|
|
|
201
207
|
failedHandleId: handleId,
|
|
202
208
|
originLabel: opts.originLabel?.(),
|
|
203
209
|
fallbackText: text,
|
|
210
|
+
reason: opts.reason?.() ?? 'failed',
|
|
204
211
|
};
|
|
205
212
|
const view = vcr.createEmbeddedView(tpl, context, {
|
|
206
213
|
injector: opts.injector,
|
|
@@ -220,6 +227,13 @@ function createMatTabRejectionDecoration(opts) {
|
|
|
220
227
|
destroyEmbeddedView();
|
|
221
228
|
opts.renderer.setProperty(span, 'textContent', text);
|
|
222
229
|
};
|
|
230
|
+
const currentReason = () => opts.reason?.() ?? 'failed';
|
|
231
|
+
const writeReason = (target, glyph) => {
|
|
232
|
+
const reason = currentReason();
|
|
233
|
+
opts.renderer.setAttribute(target, 'data-reason', reason);
|
|
234
|
+
opts.renderer.setAttribute(glyph, 'data-reason', reason);
|
|
235
|
+
opts.renderer.setProperty(glyph, 'textContent', reason === 'refused' ? CNGX_TABS_GLYPHS.refusedIcon : CNGX_TABS_GLYPHS.rejectionIcon);
|
|
236
|
+
};
|
|
223
237
|
const clearDecoration = () => {
|
|
224
238
|
if (!decoratedEl || !cachedSpan) {
|
|
225
239
|
return;
|
|
@@ -227,6 +241,10 @@ function createMatTabRejectionDecoration(opts) {
|
|
|
227
241
|
const ownTokenId = cachedSpan.id;
|
|
228
242
|
destroyEmbeddedView();
|
|
229
243
|
opts.renderer.removeClass(decoratedEl, className);
|
|
244
|
+
opts.renderer.removeAttribute(decoratedEl, 'data-reason');
|
|
245
|
+
if (cachedGlyph?.parentNode) {
|
|
246
|
+
opts.renderer.removeChild(cachedGlyph.parentNode, cachedGlyph);
|
|
247
|
+
}
|
|
230
248
|
opts.renderer.removeChild(decoratedEl, cachedSpan);
|
|
231
249
|
// `cachedSpan` deliberately retained - reused on the next apply.
|
|
232
250
|
restoreAriaDescribedbyExceptToken(decoratedEl, ownTokenId, opts.renderer, priorAriaDescribedby);
|
|
@@ -241,6 +259,17 @@ function createMatTabRejectionDecoration(opts) {
|
|
|
241
259
|
return false;
|
|
242
260
|
}
|
|
243
261
|
opts.renderer.addClass(targetEl, className);
|
|
262
|
+
let glyph = cachedGlyph;
|
|
263
|
+
if (!glyph) {
|
|
264
|
+
glyph = opts.renderer.createElement('span');
|
|
265
|
+
opts.renderer.addClass(glyph, glyphClassName);
|
|
266
|
+
opts.renderer.setAttribute(glyph, 'aria-hidden', 'true');
|
|
267
|
+
cachedGlyph = glyph;
|
|
268
|
+
}
|
|
269
|
+
writeReason(targetEl, glyph);
|
|
270
|
+
// On the tab itself: the disc is absolutely positioned at the tab's
|
|
271
|
+
// corner, and `.mdc-tab__content` is a positioning context of its own.
|
|
272
|
+
opts.renderer.appendChild(targetEl, glyph);
|
|
244
273
|
const spanId = `${handleId}-${descriptorIdSuffix}`;
|
|
245
274
|
let span = cachedSpan;
|
|
246
275
|
if (!span) {
|
|
@@ -288,7 +317,9 @@ function createMatTabRejectionDecoration(opts) {
|
|
|
288
317
|
if (retryAttempts >= maxRetryAttempts) {
|
|
289
318
|
retryAttempts = 0;
|
|
290
319
|
const sink = opts.onMaxRetriesReached ??
|
|
291
|
-
|
|
320
|
+
(typeof ngDevMode !== 'undefined' && ngDevMode
|
|
321
|
+
? defaultRetryCeilingWarn(maxRetryAttempts, 'rejection')
|
|
322
|
+
: noop);
|
|
292
323
|
sink();
|
|
293
324
|
return;
|
|
294
325
|
}
|
|
@@ -318,6 +349,18 @@ function createMatTabRejectionDecoration(opts) {
|
|
|
318
349
|
applyOrScheduleRetry(id);
|
|
319
350
|
});
|
|
320
351
|
});
|
|
352
|
+
// Reason effect - a refusal and a failure can follow each other on
|
|
353
|
+
// the same tab (same handle id, so the mount effect short-circuits);
|
|
354
|
+
// the attribute and the glyph follow the kind in place.
|
|
355
|
+
effect(() => {
|
|
356
|
+
currentReason();
|
|
357
|
+
untracked(() => {
|
|
358
|
+
if (decoratedEl === null || cachedGlyph === null) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
writeReason(decoratedEl, cachedGlyph);
|
|
362
|
+
});
|
|
363
|
+
});
|
|
321
364
|
// Live-text effect - tracks `descriptorText` plus the slot
|
|
322
365
|
// template (when wired) so a late-mounted template re-renders
|
|
323
366
|
// into the existing span. Mount-state checks live in untracked.
|
|
@@ -365,8 +408,11 @@ function createMatTabAggregatorDecoration(opts) {
|
|
|
365
408
|
// at runtime, so the signal has to come from a deliberate sink.
|
|
366
409
|
if (!isFullyWired() && (opts.contentTemplate || opts.viewContainerRef)) {
|
|
367
410
|
const missing = opts.contentTemplate ? 'viewContainerRef' : 'contentTemplate';
|
|
368
|
-
const sink = opts.onHalfWiredSlot ??
|
|
369
|
-
|
|
411
|
+
const sink = opts.onHalfWiredSlot ??
|
|
412
|
+
(typeof ngDevMode !== 'undefined' && ngDevMode
|
|
413
|
+
? CNGX_DEFAULT_HALF_WIRED_SLOT_SINK
|
|
414
|
+
: undefined);
|
|
415
|
+
sink?.(missing);
|
|
370
416
|
}
|
|
371
417
|
const decorated = new Map();
|
|
372
418
|
let pendingRetry = false;
|
|
@@ -489,7 +535,10 @@ function createMatTabAggregatorDecoration(opts) {
|
|
|
489
535
|
}
|
|
490
536
|
if (retryAttempts >= maxRetryAttempts) {
|
|
491
537
|
retryAttempts = 0;
|
|
492
|
-
const sink = opts.onMaxRetriesReached ??
|
|
538
|
+
const sink = opts.onMaxRetriesReached ??
|
|
539
|
+
(typeof ngDevMode !== 'undefined' && ngDevMode
|
|
540
|
+
? defaultRetryCeilingWarn(maxRetryAttempts, 'aggregator')
|
|
541
|
+
: noop);
|
|
493
542
|
sink();
|
|
494
543
|
return;
|
|
495
544
|
}
|
|
@@ -518,12 +567,13 @@ function createMatTabAggregatorDecoration(opts) {
|
|
|
518
567
|
}
|
|
519
568
|
});
|
|
520
569
|
}
|
|
570
|
+
const noop = () => undefined;
|
|
521
571
|
function defaultRetryCeilingWarn(max, decoration) {
|
|
572
|
+
if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
|
|
573
|
+
return noop;
|
|
574
|
+
}
|
|
522
575
|
return () => {
|
|
523
|
-
|
|
524
|
-
return;
|
|
525
|
-
}
|
|
526
|
-
console.warn(`[cngxMatTabs] ${decoration} decoration retry ceiling reached ` +
|
|
576
|
+
cngxDevWarn('CNGX3005', `[cngxMatTabs] ${decoration} decoration retry ceiling reached ` +
|
|
527
577
|
`(${max} attempts) - MatTabHeader did not render ` +
|
|
528
578
|
'`.mat-mdc-tab` buttons within the expected window. Likely ' +
|
|
529
579
|
'cause: Material upgrade broke the `.mat-mdc-tab` selector ' +
|
|
@@ -534,8 +584,14 @@ function defaultRetryCeilingWarn(max, decoration) {
|
|
|
534
584
|
}
|
|
535
585
|
|
|
536
586
|
/**
|
|
537
|
-
* Builds the reactive list of tabs
|
|
538
|
-
*
|
|
587
|
+
* Builds the reactive list of tabs in error, in registration (DOM)
|
|
588
|
+
* order. Gates on the handle's folded `hasError()` - the direct
|
|
589
|
+
* `[cngxMatTabErrorFlag]` / `[error]` flag OR the bound aggregator's
|
|
590
|
+
* reveal-gated `shouldShow()` - exactly as `<cngx-tab-group>` gates its
|
|
591
|
+
* badge, so a deferred-reveal aggregator stays silent until revealed.
|
|
592
|
+
* The descriptor phrase mirrors the native `statusPhrase` cascade:
|
|
593
|
+
* aggregator announcement, then the direct-error message, then
|
|
594
|
+
* `i18n.tabHasErrors(count)`. Feeds
|
|
539
595
|
* {@link createMatTabAggregatorDecoration} for both the
|
|
540
596
|
* `[cngxMatTabs]` (`<mat-tab-group>`) and `[cngxMatTabNav]`
|
|
541
597
|
* (`<nav mat-tab-nav-bar>`) bridges - one body, two hosts (Pillar 3).
|
|
@@ -545,22 +601,36 @@ function defaultRetryCeilingWarn(max, decoration) {
|
|
|
545
601
|
*
|
|
546
602
|
* @internal
|
|
547
603
|
*/
|
|
548
|
-
function createAggregatedErrorTabs(presenter) {
|
|
604
|
+
function createAggregatedErrorTabs(presenter, i18n) {
|
|
605
|
+
// Same cascade as the native `statusPhrase`: an empty announcement or
|
|
606
|
+
// message falls through, so a bare `true` flag still reads a phrase.
|
|
607
|
+
const descriptorPhrase = (handle, count) => {
|
|
608
|
+
const announcement = handle.errorAggregator()?.announcement();
|
|
609
|
+
if (announcement) {
|
|
610
|
+
return announcement;
|
|
611
|
+
}
|
|
612
|
+
const message = handle.errorMessage();
|
|
613
|
+
if (message) {
|
|
614
|
+
return message;
|
|
615
|
+
}
|
|
616
|
+
return i18n().tabHasErrors(count);
|
|
617
|
+
};
|
|
549
618
|
return computed(() => {
|
|
550
619
|
const tabs = presenter.tabs();
|
|
551
620
|
const acc = [];
|
|
552
621
|
for (let i = 0; i < tabs.length; i++) {
|
|
553
622
|
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
|
-
});
|
|
623
|
+
if (!handle.hasError()) {
|
|
624
|
+
continue;
|
|
563
625
|
}
|
|
626
|
+
const count = handle.errorAggregator()?.errorCount() ?? 1;
|
|
627
|
+
acc.push({
|
|
628
|
+
idx: i,
|
|
629
|
+
id: handle.id,
|
|
630
|
+
announcement: descriptorPhrase(handle, count),
|
|
631
|
+
count,
|
|
632
|
+
label: handle.label() ?? '',
|
|
633
|
+
});
|
|
564
634
|
}
|
|
565
635
|
return acc;
|
|
566
636
|
}, {
|
|
@@ -582,6 +652,8 @@ function createAggregatedErrorTabs(presenter) {
|
|
|
582
652
|
});
|
|
583
653
|
}
|
|
584
654
|
|
|
655
|
+
/** Production default for `halfWiredSlotSink`: one reference, so reads stay identical. */
|
|
656
|
+
const SILENT_HALF_WIRED_SLOT_SINK = () => undefined;
|
|
585
657
|
/**
|
|
586
658
|
* Library defaults for `[cngxMatTabs]`. Source of truth for every
|
|
587
659
|
* key on {@link CngxMatTabsConfig}. Consumed by
|
|
@@ -591,7 +663,13 @@ function createAggregatedErrorTabs(presenter) {
|
|
|
591
663
|
*/
|
|
592
664
|
const CNGX_MAT_TABS_CONFIG_DEFAULTS = {
|
|
593
665
|
anchorMaxAttempts: 5,
|
|
594
|
-
|
|
666
|
+
// A getter, so the guard is read when the config resolves, after Angular set
|
|
667
|
+
// `ngDevMode`; production folds it and drops the dev sink from the bundle.
|
|
668
|
+
get halfWiredSlotSink() {
|
|
669
|
+
return typeof ngDevMode !== 'undefined' && ngDevMode
|
|
670
|
+
? CNGX_DEFAULT_HALF_WIRED_SLOT_SINK
|
|
671
|
+
: SILENT_HALF_WIRED_SLOT_SINK;
|
|
672
|
+
},
|
|
595
673
|
templates: {},
|
|
596
674
|
};
|
|
597
675
|
/**
|
|
@@ -736,6 +814,20 @@ function injectMatTabsConfig() {
|
|
|
736
814
|
};
|
|
737
815
|
}
|
|
738
816
|
|
|
817
|
+
/**
|
|
818
|
+
* Resolve the decoration content slots of a Material tab bridge. The
|
|
819
|
+
* `contentChild` queries stay on each host (signal queries must be class
|
|
820
|
+
* fields); the resolution order is shared so both hosts agree.
|
|
821
|
+
*
|
|
822
|
+
* @internal
|
|
823
|
+
*/
|
|
824
|
+
function createDecorationTemplates(aggregatorSlot, rejectionSlot, config) {
|
|
825
|
+
return {
|
|
826
|
+
aggregator: computed(() => aggregatorSlot()?.templateRef ?? null),
|
|
827
|
+
rejection: computed(() => rejectionSlot()?.templateRef ?? config.templates?.rejection ?? null),
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
|
|
739
831
|
/**
|
|
740
832
|
* Structural slot directive marking the aggregator-descriptor
|
|
741
833
|
* template for `[cngxMatTabs]`. Discovered via `contentChild` on the
|
|
@@ -895,6 +987,20 @@ function mountLiveRegionAnnouncer(opts) {
|
|
|
895
987
|
* @internal
|
|
896
988
|
*/
|
|
897
989
|
function createRejectionState(presenter, i18n) {
|
|
990
|
+
// A label-less origin is named by its position, as on <cngx-tab-group>;
|
|
991
|
+
// undefined when no origin tab resolves - no origin index, or one past the
|
|
992
|
+
// end because the origin tab was removed meanwhile (the generic copy).
|
|
993
|
+
function originName(originIdx, copy) {
|
|
994
|
+
const origin = originIdx === undefined ? undefined : presenter.tabs()[originIdx];
|
|
995
|
+
if (!origin || originIdx === undefined) {
|
|
996
|
+
return undefined;
|
|
997
|
+
}
|
|
998
|
+
const label = origin.label();
|
|
999
|
+
if (label) {
|
|
1000
|
+
return label;
|
|
1001
|
+
}
|
|
1002
|
+
return copy.unlabeledTab(originIdx + 1);
|
|
1003
|
+
}
|
|
898
1004
|
const failedHandleId = computed(() => {
|
|
899
1005
|
const idx = presenter.lastFailedIndex();
|
|
900
1006
|
if (idx === undefined) {
|
|
@@ -913,35 +1019,68 @@ function createRejectionState(presenter, i18n) {
|
|
|
913
1019
|
}
|
|
914
1020
|
return presenter.tabs()[originIdx]?.label() ?? undefined;
|
|
915
1021
|
}, ...(ngDevMode ? [{ debugName: "originLabel" }] : /* istanbul ignore next */ []));
|
|
916
|
-
const
|
|
1022
|
+
const reason = computed(() => {
|
|
917
1023
|
if (presenter.lastFailedIndex() === undefined) {
|
|
1024
|
+
return undefined;
|
|
1025
|
+
}
|
|
1026
|
+
return presenter.lastOutcome()?.kind === 'refused' ? 'refused' : 'failed';
|
|
1027
|
+
}, ...(ngDevMode ? [{ debugName: "reason" }] : /* istanbul ignore next */ []));
|
|
1028
|
+
const descriptorText = computed(() => {
|
|
1029
|
+
const kind = reason();
|
|
1030
|
+
if (kind === undefined) {
|
|
918
1031
|
return '';
|
|
919
1032
|
}
|
|
920
|
-
const label = originLabel();
|
|
921
1033
|
const copy = i18n();
|
|
922
|
-
|
|
1034
|
+
const name = originName(presenter.originIndexDuringCommit(), copy);
|
|
1035
|
+
if (kind === 'refused') {
|
|
1036
|
+
return name ? copy.commitRefused(name) : copy.commitRefusedGeneric;
|
|
1037
|
+
}
|
|
1038
|
+
return name ? copy.commitRolledBackTo(name) : copy.commitFailedRetry;
|
|
923
1039
|
}, ...(ngDevMode ? [{ debugName: "descriptorText" }] : /* istanbul ignore next */ []));
|
|
1040
|
+
// A refusal leaves the commit status at 'idle', so no status edge can
|
|
1041
|
+
// voice it. Same lifecycle as the `<cngx-tab-group>` phrase: armed by a
|
|
1042
|
+
// new refused sequence, spent by the next commit activity, an
|
|
1043
|
+
// active-index move or a cleared outcome.
|
|
1044
|
+
const refusedPhrase = createRefusedPhrase({
|
|
1045
|
+
outcome: () => presenter.lastOutcome(),
|
|
1046
|
+
status: () => presenter.commitTransition.current(),
|
|
1047
|
+
activeIndex: () => presenter.activeIndex(),
|
|
1048
|
+
copy: refusedCopy,
|
|
1049
|
+
});
|
|
1050
|
+
function refusedCopy() {
|
|
1051
|
+
const copy = i18n();
|
|
1052
|
+
const name = originName(presenter.originIndexDuringCommit(), copy);
|
|
1053
|
+
return name ? copy.commitRefused(name) : copy.commitRefusedGeneric;
|
|
1054
|
+
}
|
|
924
1055
|
// Feeds the live announcer: copy and the origin tab label (which a
|
|
925
1056
|
// consumer may translate) are read untracked so a language switch does
|
|
926
1057
|
// not re-announce; the next transition speaks the new language.
|
|
927
1058
|
const liveAnnouncement = computed(() => {
|
|
1059
|
+
// Read the refused phrase EAGERLY: linkedSignal only observes the
|
|
1060
|
+
// snapshots it is read under, so a read behind the pending arm would
|
|
1061
|
+
// miss the status change that spends it.
|
|
1062
|
+
const refused = refusedPhrase();
|
|
1063
|
+
if (refused) {
|
|
1064
|
+
return refused;
|
|
1065
|
+
}
|
|
928
1066
|
const current = presenter.commitTransition.current();
|
|
929
1067
|
if (current === 'pending') {
|
|
930
1068
|
return untracked(() => i18n().commitInFlight);
|
|
931
1069
|
}
|
|
932
1070
|
if (current === 'error') {
|
|
933
1071
|
const failedIdx = presenter.lastFailedIndex();
|
|
934
|
-
const originIdx = presenter.originIndexDuringCommit();
|
|
935
|
-
|
|
936
|
-
const
|
|
1072
|
+
const originIdx = failedIdx === undefined ? undefined : presenter.originIndexDuringCommit();
|
|
1073
|
+
// The indices and the tab list stay tracked; the label is read untracked.
|
|
1074
|
+
const hasOrigin = originIdx !== undefined && presenter.tabs()[originIdx] !== undefined;
|
|
937
1075
|
return untracked(() => {
|
|
938
|
-
const
|
|
939
|
-
|
|
1076
|
+
const copy = i18n();
|
|
1077
|
+
const name = hasOrigin ? originName(originIdx, copy) : undefined;
|
|
1078
|
+
return name ? copy.commitRolledBackTo(name) : copy.commitFailedRetry;
|
|
940
1079
|
});
|
|
941
1080
|
}
|
|
942
1081
|
return '';
|
|
943
1082
|
}, ...(ngDevMode ? [{ debugName: "liveAnnouncement" }] : /* istanbul ignore next */ []));
|
|
944
|
-
return { failedHandleId, originLabel, descriptorText, liveAnnouncement };
|
|
1083
|
+
return { failedHandleId, originLabel, reason, descriptorText, liveAnnouncement };
|
|
945
1084
|
}
|
|
946
1085
|
|
|
947
1086
|
/**
|
|
@@ -1381,12 +1520,10 @@ class CngxMatTabs {
|
|
|
1381
1520
|
injector: this.injector,
|
|
1382
1521
|
});
|
|
1383
1522
|
aggregatorContentSlot = contentChild(CngxMatTabAggregatorContent, ...(ngDevMode ? [{ debugName: "aggregatorContentSlot" }] : /* istanbul ignore next */ []));
|
|
1384
|
-
aggregatorContentTemplate = computed(() => this.aggregatorContentSlot()?.templateRef ?? null, ...(ngDevMode ? [{ debugName: "aggregatorContentTemplate" }] : /* istanbul ignore next */ []));
|
|
1385
1523
|
matTabsConfig = injectMatTabsConfig();
|
|
1386
1524
|
rejectionContentSlot = contentChild(CngxMatTabRejectionContent, ...(ngDevMode ? [{ debugName: "rejectionContentSlot" }] : /* istanbul ignore next */ []));
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
null, ...(ngDevMode ? [{ debugName: "rejectionContentTemplate" }] : /* istanbul ignore next */ []));
|
|
1525
|
+
// Shared with `[cngxMatTabNav]`: one slot resolution order for both hosts.
|
|
1526
|
+
decorationTemplates = createDecorationTemplates(this.aggregatorContentSlot, this.rejectionContentSlot, this.matTabsConfig);
|
|
1390
1527
|
i18n = injectTabsI18n();
|
|
1391
1528
|
// Bundle shares one source-walk across failedHandleId /
|
|
1392
1529
|
// descriptorText / originLabel / liveAnnouncement - pillar-2
|
|
@@ -1395,7 +1532,7 @@ class CngxMatTabs {
|
|
|
1395
1532
|
// Shared with `[cngxMatTabNav]` - one body, two hosts (Pillar 3).
|
|
1396
1533
|
// Structural equal lives in the factory so the projector doesn't
|
|
1397
1534
|
// churn on no-op aggregator re-emissions.
|
|
1398
|
-
aggregatedErrorTabs = createAggregatedErrorTabs(this.presenter);
|
|
1535
|
+
aggregatedErrorTabs = createAggregatedErrorTabs(this.presenter, this.i18n);
|
|
1399
1536
|
constructor() {
|
|
1400
1537
|
const matTabsConfig = this.matTabsConfig;
|
|
1401
1538
|
// Polite live region - attribute directive owns no template, so
|
|
@@ -1415,9 +1552,10 @@ class CngxMatTabs {
|
|
|
1415
1552
|
renderer: this.renderer,
|
|
1416
1553
|
injector: this.injector,
|
|
1417
1554
|
destroyRef: this.destroyRef,
|
|
1418
|
-
contentTemplate: this.
|
|
1555
|
+
contentTemplate: this.decorationTemplates.rejection,
|
|
1419
1556
|
viewContainerRef: this.viewContainerRef,
|
|
1420
1557
|
originLabel: this.rejectionState.originLabel,
|
|
1558
|
+
reason: this.rejectionState.reason,
|
|
1421
1559
|
});
|
|
1422
1560
|
createMatTabAggregatorDecoration({
|
|
1423
1561
|
hostEl: this.hostEl,
|
|
@@ -1425,7 +1563,7 @@ class CngxMatTabs {
|
|
|
1425
1563
|
renderer: this.renderer,
|
|
1426
1564
|
injector: this.injector,
|
|
1427
1565
|
destroyRef: this.destroyRef,
|
|
1428
|
-
contentTemplate: this.
|
|
1566
|
+
contentTemplate: this.decorationTemplates.aggregator,
|
|
1429
1567
|
viewContainerRef: this.viewContainerRef,
|
|
1430
1568
|
onHalfWiredSlot: matTabsConfig.halfWiredSlotSink,
|
|
1431
1569
|
});
|
|
@@ -1455,8 +1593,8 @@ class CngxMatTabs {
|
|
|
1455
1593
|
return () => undefined;
|
|
1456
1594
|
},
|
|
1457
1595
|
onGiveUp: () => {
|
|
1458
|
-
if (
|
|
1459
|
-
|
|
1596
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
1597
|
+
cngxDevWarn('CNGX3007', `[cngxMatTabs] could not anchor <cngx-tab-overflow> after ${anchorMaxAttempts} ` +
|
|
1460
1598
|
'attempts - .mat-mdc-tab-header was not found inside the ' +
|
|
1461
1599
|
'host. The More popover will fall back to a sibling-of-' +
|
|
1462
1600
|
'<mat-tab-group> position; verify Material rendered the ' +
|
|
@@ -1480,14 +1618,21 @@ class CngxMatTabs {
|
|
|
1480
1618
|
});
|
|
1481
1619
|
// Routed (pessimistic) gate: a rejected switch holds `activeIndex` at
|
|
1482
1620
|
// origin, so the presenter to Material mirror never fires and Material
|
|
1483
|
-
// stays eager-advanced on the
|
|
1484
|
-
// commit settles
|
|
1485
|
-
//
|
|
1486
|
-
//
|
|
1621
|
+
// stays eager-advanced on the rejected tab. Snap it back when the
|
|
1622
|
+
// commit settles as refused or failed. Keyed on the outcome sequence,
|
|
1623
|
+
// not the status: a refusal settles to 'idle' and never reaches
|
|
1624
|
+
// 'error', while every failure through `select()` records a failed
|
|
1625
|
+
// outcome with a fresh sequence in the same flush as the 'error'
|
|
1626
|
+
// status, so the sequence edge covers both. One reconcile per settle:
|
|
1627
|
+
// a second write of the same index leaves a self-echo that Material
|
|
1628
|
+
// never emits and that would swallow the user's next pick of that
|
|
1629
|
+
// tab. A number compares with `Object.is`, so the close shift (index
|
|
1630
|
+
// moved, sequence copied) never re-runs it; `undefined` is ignored.
|
|
1631
|
+
const outcomeSequence = computed(() => this.presenter.lastOutcome()?.sequence, ...(ngDevMode ? [{ debugName: "outcomeSequence" }] : /* istanbul ignore next */ []));
|
|
1487
1632
|
effect(() => {
|
|
1488
|
-
const
|
|
1633
|
+
const sequence = outcomeSequence();
|
|
1489
1634
|
untracked(() => {
|
|
1490
|
-
if (
|
|
1635
|
+
if (sequence !== undefined) {
|
|
1491
1636
|
sync.reconcile();
|
|
1492
1637
|
}
|
|
1493
1638
|
});
|
|
@@ -1596,10 +1741,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1596
1741
|
* the live-region announcer come for free, identical to the cngx
|
|
1597
1742
|
* organism (Pillar 2 - same communication across skins).
|
|
1598
1743
|
*
|
|
1599
|
-
* Decoration content-template slots
|
|
1600
|
-
* `*
|
|
1601
|
-
*
|
|
1602
|
-
*
|
|
1744
|
+
* Decoration content-template slots resolve as on `[cngxMatTabs]`:
|
|
1745
|
+
* a projected `*cngxMatTabRejectionContent` wins over
|
|
1746
|
+
* `provideMatTabsConfig(withMatTabRejectionTemplate(...))`, and a
|
|
1747
|
+
* projected `*cngxMatTabAggregatorContent` replaces the aggregated error
|
|
1748
|
+
* summary; without either, the projectors render their built-in
|
|
1749
|
+
* `cngx-sr-only` text.
|
|
1603
1750
|
*
|
|
1604
1751
|
* @playground Native router tabs with a CanDeactivate guard ./examples/router-nav/router-nav.component.ts
|
|
1605
1752
|
*
|
|
@@ -1609,6 +1756,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1609
1756
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tab-nav.directive.ts
|
|
1610
1757
|
* @since 0.1.0
|
|
1611
1758
|
* @relatedTo CngxMatTabLink, CngxMatTabs, CngxTabsRouteSync
|
|
1759
|
+
* @slot cngxMatTabAggregatorContent Replaces the aggregated error summary projected into a Material tab.
|
|
1760
|
+
* @slot cngxMatTabRejectionContent Replaces the rejection notice on a rolled-back Material tab.
|
|
1612
1761
|
*/
|
|
1613
1762
|
class CngxMatTabNav {
|
|
1614
1763
|
presenter = inject(CNGX_TAB_GROUP_HOST);
|
|
@@ -1616,9 +1765,14 @@ class CngxMatTabNav {
|
|
|
1616
1765
|
injector = inject(Injector);
|
|
1617
1766
|
renderer = inject(Renderer2);
|
|
1618
1767
|
hostEl = inject(ElementRef).nativeElement;
|
|
1768
|
+
viewContainerRef = inject(ViewContainerRef);
|
|
1769
|
+
matTabsConfig = injectMatTabsConfig();
|
|
1619
1770
|
i18n = injectTabsI18n();
|
|
1771
|
+
aggregatorContentSlot = contentChild(CngxMatTabAggregatorContent, ...(ngDevMode ? [{ debugName: "aggregatorContentSlot" }] : /* istanbul ignore next */ []));
|
|
1772
|
+
rejectionContentSlot = contentChild(CngxMatTabRejectionContent, ...(ngDevMode ? [{ debugName: "rejectionContentSlot" }] : /* istanbul ignore next */ []));
|
|
1773
|
+
decorationTemplates = createDecorationTemplates(this.aggregatorContentSlot, this.rejectionContentSlot, this.matTabsConfig);
|
|
1620
1774
|
rejectionState = createRejectionState(this.presenter, this.i18n);
|
|
1621
|
-
aggregatedErrorTabs = createAggregatedErrorTabs(this.presenter);
|
|
1775
|
+
aggregatedErrorTabs = createAggregatedErrorTabs(this.presenter, this.i18n);
|
|
1622
1776
|
constructor() {
|
|
1623
1777
|
mountLiveRegionAnnouncer({
|
|
1624
1778
|
announcement: this.rejectionState.liveAnnouncement,
|
|
@@ -1644,7 +1798,10 @@ class CngxMatTabNav {
|
|
|
1644
1798
|
renderer: this.renderer,
|
|
1645
1799
|
injector: this.injector,
|
|
1646
1800
|
destroyRef: this.destroyRef,
|
|
1801
|
+
contentTemplate: this.decorationTemplates.rejection,
|
|
1802
|
+
viewContainerRef: this.viewContainerRef,
|
|
1647
1803
|
originLabel: this.rejectionState.originLabel,
|
|
1804
|
+
reason: this.rejectionState.reason,
|
|
1648
1805
|
buttonSelector: '.mat-mdc-tab-link',
|
|
1649
1806
|
});
|
|
1650
1807
|
createMatTabAggregatorDecoration({
|
|
@@ -1653,6 +1810,9 @@ class CngxMatTabNav {
|
|
|
1653
1810
|
renderer: this.renderer,
|
|
1654
1811
|
injector: this.injector,
|
|
1655
1812
|
destroyRef: this.destroyRef,
|
|
1813
|
+
contentTemplate: this.decorationTemplates.aggregator,
|
|
1814
|
+
viewContainerRef: this.viewContainerRef,
|
|
1815
|
+
onHalfWiredSlot: this.matTabsConfig.halfWiredSlotSink,
|
|
1656
1816
|
buttonSelector: '.mat-mdc-tab-link',
|
|
1657
1817
|
});
|
|
1658
1818
|
}
|
|
@@ -1665,7 +1825,7 @@ class CngxMatTabNav {
|
|
|
1665
1825
|
this.presenter.clearLastFailed();
|
|
1666
1826
|
}
|
|
1667
1827
|
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: "
|
|
1828
|
+
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
1829
|
}
|
|
1670
1830
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabNav, decorators: [{
|
|
1671
1831
|
type: Directive,
|
|
@@ -1684,7 +1844,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1684
1844
|
},
|
|
1685
1845
|
],
|
|
1686
1846
|
}]
|
|
1687
|
-
}], ctorParameters: () => [] });
|
|
1847
|
+
}], ctorParameters: () => [], propDecorators: { aggregatorContentSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxMatTabAggregatorContent), { isSignal: true }] }], rejectionContentSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxMatTabRejectionContent), { isSignal: true }] }] } });
|
|
1688
1848
|
|
|
1689
1849
|
/**
|
|
1690
1850
|
* Registers an `<a mat-tab-link>` anchor as a {@link CngxTabHandle}
|
|
@@ -1713,7 +1873,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1713
1873
|
* @relatedTo CngxMatTabNav, CngxMatTabs, CngxTab
|
|
1714
1874
|
*/
|
|
1715
1875
|
class CngxMatTabLink {
|
|
1716
|
-
matLink = inject(MatTabLink, { self: true });
|
|
1717
1876
|
host = inject(CNGX_TAB_GROUP_HOST);
|
|
1718
1877
|
destroyRef = inject(DestroyRef);
|
|
1719
1878
|
/**
|
|
@@ -1733,6 +1892,14 @@ class CngxMatTabLink {
|
|
|
1733
1892
|
error = input(false, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
1734
1893
|
/** Optional rich error aggregator for the link. */
|
|
1735
1894
|
errorAggregator = input(undefined, ...(ngDevMode ? [{ debugName: "errorAggregator" }] : /* istanbul ignore next */ []));
|
|
1895
|
+
/**
|
|
1896
|
+
* Disabled state of the link. Angular binds `[disabled]` to every
|
|
1897
|
+
* directive on the element that declares the input, so `MatTabLink`
|
|
1898
|
+
* and this directive read one template binding and the handle tracks
|
|
1899
|
+
* it live. An imperative write to the `MatTabLink` instance is not
|
|
1900
|
+
* seen; the template binding is the contract.
|
|
1901
|
+
*/
|
|
1902
|
+
disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
1736
1903
|
errorMessage = computed(() => {
|
|
1737
1904
|
const value = this.error();
|
|
1738
1905
|
return typeof value === 'string' && value !== '' ? value : undefined;
|
|
@@ -1742,18 +1909,12 @@ class CngxMatTabLink {
|
|
|
1742
1909
|
return ((direct !== false && direct !== '') ||
|
|
1743
1910
|
(this.errorAggregator()?.shouldShow?.() ?? false));
|
|
1744
1911
|
}, { ...(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
1912
|
ngOnInit() {
|
|
1751
|
-
this.disabledState.set(this.matLink.disabled);
|
|
1752
1913
|
const handle = {
|
|
1753
1914
|
id: this.id(),
|
|
1754
1915
|
label: this.label,
|
|
1755
1916
|
subLabel: signal(undefined),
|
|
1756
|
-
disabled: this.
|
|
1917
|
+
disabled: this.disabled,
|
|
1757
1918
|
errorAggregator: this.errorAggregator,
|
|
1758
1919
|
hasError: this.hasError,
|
|
1759
1920
|
errorMessage: this.errorMessage,
|
|
@@ -1763,7 +1924,7 @@ class CngxMatTabLink {
|
|
|
1763
1924
|
this.destroyRef.onDestroy(() => this.host.unregister(handle.id, handle));
|
|
1764
1925
|
}
|
|
1765
1926
|
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 });
|
|
1927
|
+
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
1928
|
}
|
|
1768
1929
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabLink, decorators: [{
|
|
1769
1930
|
type: Directive,
|
|
@@ -1772,7 +1933,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1772
1933
|
exportAs: 'cngxMatTabLink',
|
|
1773
1934
|
standalone: true,
|
|
1774
1935
|
}]
|
|
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 }] }] } });
|
|
1936
|
+
}], 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 }] }] } });
|
|
1937
|
+
|
|
1938
|
+
/**
|
|
1939
|
+
* Inject the `<mat-tab>` a per-tab error directive sits on, plus the registry
|
|
1940
|
+
* and presenter of the surrounding `<mat-tab-group cngxMatTabs>`. Throws a
|
|
1941
|
+
* `CngxRuntimeError` with code `CNGX3020` when either prerequisite is
|
|
1942
|
+
* missing, in development and production alike. `selector` names the
|
|
1943
|
+
* directive in the development message.
|
|
1944
|
+
*
|
|
1945
|
+
* @internal
|
|
1946
|
+
*/
|
|
1947
|
+
function injectMatTabErrorTarget(selector) {
|
|
1948
|
+
const matTab = inject(MatTab, { self: true, optional: true });
|
|
1949
|
+
const registry = inject(CNGX_MAT_TABS_REGISTRY_HOST, { host: true, optional: true });
|
|
1950
|
+
const presenter = inject(CNGX_TAB_GROUP_HOST, { optional: true });
|
|
1951
|
+
if (!matTab || !registry || !presenter) {
|
|
1952
|
+
throw new CngxRuntimeError('CNGX3020', typeof ngDevMode !== 'undefined' &&
|
|
1953
|
+
ngDevMode &&
|
|
1954
|
+
`[${selector}] must be placed on a <mat-tab> inside <mat-tab-group cngxMatTabs>.`);
|
|
1955
|
+
}
|
|
1956
|
+
return { matTab, registry, presenter };
|
|
1957
|
+
}
|
|
1776
1958
|
|
|
1777
1959
|
/**
|
|
1778
1960
|
* Per-tab error-aggregator binding for `[cngxMatTabs]`. Attach to a
|
|
@@ -1803,11 +1985,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1803
1985
|
* @relatedTo CngxMatTabs, CngxMatTabsRegistry, CngxMatTabRejectionContent
|
|
1804
1986
|
*/
|
|
1805
1987
|
class CngxMatTabError {
|
|
1806
|
-
|
|
1807
|
-
registry = inject(CNGX_MAT_TABS_REGISTRY_HOST, {
|
|
1808
|
-
host: true,
|
|
1809
|
-
});
|
|
1810
|
-
presenter = inject(CNGX_TAB_GROUP_HOST);
|
|
1988
|
+
target = injectMatTabErrorTarget('cngxMatTabError');
|
|
1811
1989
|
destroyRef = inject(DestroyRef);
|
|
1812
1990
|
aggregator = input(undefined, { ...(ngDevMode ? { debugName: "aggregator" } : /* istanbul ignore next */ {}), alias: 'cngxMatTabError',
|
|
1813
1991
|
transform: (value) => (typeof value === 'string' ? undefined : value) });
|
|
@@ -1824,14 +2002,14 @@ class CngxMatTabError {
|
|
|
1824
2002
|
// the effect re-fires once our `MatTab` is registered. The bare
|
|
1825
2003
|
// read is intentional; full rationale lives in the effect's
|
|
1826
2004
|
// opening comment above. Do NOT tag as dead code.
|
|
1827
|
-
this.presenter.tabs();
|
|
2005
|
+
this.target.presenter.tabs();
|
|
1828
2006
|
untracked(() => {
|
|
1829
|
-
const setup = this.registry.getHandleSetup(this.matTab);
|
|
2007
|
+
const setup = this.target.registry.getHandleSetup(this.target.matTab);
|
|
1830
2008
|
setup?.errorAggregator.set(aggregator);
|
|
1831
2009
|
});
|
|
1832
2010
|
});
|
|
1833
2011
|
this.destroyRef.onDestroy(() => {
|
|
1834
|
-
const setup = this.registry.getHandleSetup(this.matTab);
|
|
2012
|
+
const setup = this.target.registry.getHandleSetup(this.target.matTab);
|
|
1835
2013
|
setup?.errorAggregator.set(undefined);
|
|
1836
2014
|
});
|
|
1837
2015
|
}
|
|
@@ -1853,7 +2031,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1853
2031
|
* `string | boolean` writes the per-handle `directError` slot, which
|
|
1854
2032
|
* folds into the handle's `hasError` / `errorMessage`. A non-empty
|
|
1855
2033
|
* string doubles as the SR descriptor message; `true` marks the tab
|
|
1856
|
-
* invalid with no message; `false` / `''` clear it.
|
|
2034
|
+
* invalid with no message; `false` / `''` clear it. The folded state
|
|
2035
|
+
* drives the same header decoration as the aggregator: the
|
|
2036
|
+
* `cngx-mat-tab--has-errors` badge plus an SR-only descriptor span
|
|
2037
|
+
* referenced through `aria-describedby` (message, else the
|
|
2038
|
+
* `tabHasErrors` i18n phrase), removed again when the flag clears.
|
|
1857
2039
|
*
|
|
1858
2040
|
* Symmetric with `[cngxMatTabError]` (one directive, one
|
|
1859
2041
|
* responsibility - Pillar 3): the aggregator stays the rich
|
|
@@ -1873,11 +2055,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1873
2055
|
* @relatedTo CngxMatTabs, CngxMatTabError, CngxMatTabsRegistry
|
|
1874
2056
|
*/
|
|
1875
2057
|
class CngxMatTabErrorFlag {
|
|
1876
|
-
|
|
1877
|
-
registry = inject(CNGX_MAT_TABS_REGISTRY_HOST, {
|
|
1878
|
-
host: true,
|
|
1879
|
-
});
|
|
1880
|
-
presenter = inject(CNGX_TAB_GROUP_HOST);
|
|
2058
|
+
target = injectMatTabErrorTarget('cngxMatTabErrorFlag');
|
|
1881
2059
|
destroyRef = inject(DestroyRef);
|
|
1882
2060
|
error = input(false, { ...(ngDevMode ? { debugName: "error" } : /* istanbul ignore next */ {}), alias: 'cngxMatTabErrorFlag',
|
|
1883
2061
|
transform: (value) => (value === '' ? true : value) });
|
|
@@ -1889,14 +2067,14 @@ class CngxMatTabErrorFlag {
|
|
|
1889
2067
|
// effect once our handle is registered. `untracked` around the
|
|
1890
2068
|
// write keeps the slot pump out of the reactive graph.
|
|
1891
2069
|
const error = this.error();
|
|
1892
|
-
this.presenter.tabs();
|
|
2070
|
+
this.target.presenter.tabs();
|
|
1893
2071
|
untracked(() => {
|
|
1894
|
-
const setup = this.registry.getHandleSetup(this.matTab);
|
|
2072
|
+
const setup = this.target.registry.getHandleSetup(this.target.matTab);
|
|
1895
2073
|
setup?.directError.set(error);
|
|
1896
2074
|
});
|
|
1897
2075
|
});
|
|
1898
2076
|
this.destroyRef.onDestroy(() => {
|
|
1899
|
-
const setup = this.registry.getHandleSetup(this.matTab);
|
|
2077
|
+
const setup = this.target.registry.getHandleSetup(this.target.matTab);
|
|
1900
2078
|
setup?.directError.set(false);
|
|
1901
2079
|
});
|
|
1902
2080
|
}
|