@cngx/ui 0.1.0-rc.7 → 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.
Files changed (101) hide show
  1. package/README.md +0 -1
  2. package/a11y/README.md +11 -5
  3. package/accordion/README.md +4 -2
  4. package/breadcrumb/README.md +262 -0
  5. package/collection/README.md +6 -0
  6. package/command-palette/README.md +227 -0
  7. package/data-grid-accordion/README.md +76 -2
  8. package/feedback/README.md +40 -0
  9. package/fesm2022/cngx-ui-a11y.mjs +189 -57
  10. package/fesm2022/cngx-ui-a11y.mjs.map +1 -1
  11. package/fesm2022/cngx-ui-accordion.mjs +120 -36
  12. package/fesm2022/cngx-ui-accordion.mjs.map +1 -1
  13. package/fesm2022/cngx-ui-action-button.mjs +121 -56
  14. package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
  15. package/fesm2022/cngx-ui-breadcrumb.mjs +228 -108
  16. package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -1
  17. package/fesm2022/cngx-ui-chart-panel.mjs +180 -23
  18. package/fesm2022/cngx-ui-chart-panel.mjs.map +1 -1
  19. package/fesm2022/cngx-ui-collection.mjs +204 -62
  20. package/fesm2022/cngx-ui-collection.mjs.map +1 -1
  21. package/fesm2022/cngx-ui-command-palette.mjs +395 -119
  22. package/fesm2022/cngx-ui-command-palette.mjs.map +1 -1
  23. package/fesm2022/cngx-ui-context-menu.mjs +209 -40
  24. package/fesm2022/cngx-ui-context-menu.mjs.map +1 -1
  25. package/fesm2022/cngx-ui-data-grid-accordion.mjs +498 -101
  26. package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -1
  27. package/fesm2022/cngx-ui-empty-state.mjs +16 -6
  28. package/fesm2022/cngx-ui-empty-state.mjs.map +1 -1
  29. package/fesm2022/cngx-ui-feedback.mjs +1074 -460
  30. package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
  31. package/fesm2022/cngx-ui-mat-accordion.mjs +76 -7
  32. package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -1
  33. package/fesm2022/cngx-ui-mat-paginator.mjs +67 -24
  34. package/fesm2022/cngx-ui-mat-paginator.mjs.map +1 -1
  35. package/fesm2022/cngx-ui-mat-stepper.mjs +72 -47
  36. package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -1
  37. package/fesm2022/cngx-ui-mat-tabs.mjs +555 -204
  38. package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
  39. package/fesm2022/cngx-ui-overlay.mjs +69 -13
  40. package/fesm2022/cngx-ui-overlay.mjs.map +1 -1
  41. package/fesm2022/cngx-ui-paginator.mjs +553 -198
  42. package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
  43. package/fesm2022/cngx-ui-sidenav.mjs +344 -109
  44. package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
  45. package/fesm2022/cngx-ui-skeleton.mjs +4 -16
  46. package/fesm2022/cngx-ui-skeleton.mjs.map +1 -1
  47. package/fesm2022/cngx-ui-speak.mjs +107 -8
  48. package/fesm2022/cngx-ui-speak.mjs.map +1 -1
  49. package/fesm2022/cngx-ui-stat-card.mjs +146 -46
  50. package/fesm2022/cngx-ui-stat-card.mjs.map +1 -1
  51. package/fesm2022/cngx-ui-stepper.mjs +234 -99
  52. package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
  53. package/fesm2022/cngx-ui-tabs.mjs +88 -25
  54. package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
  55. package/fesm2022/cngx-ui-timeline.mjs +98 -23
  56. package/fesm2022/cngx-ui-timeline.mjs.map +1 -1
  57. package/fesm2022/cngx-ui-toc.mjs +101 -33
  58. package/fesm2022/cngx-ui-toc.mjs.map +1 -1
  59. package/fesm2022/cngx-ui.mjs +15 -20
  60. package/fesm2022/cngx-ui.mjs.map +1 -1
  61. package/mat-paginator/README.md +9 -2
  62. package/mat-tabs/README.md +30 -6
  63. package/mat-tabs/styles/mat-tabs.css +188 -42
  64. package/overlay/README.md +9 -4
  65. package/package.json +31 -7
  66. package/paginator/README.md +8 -4
  67. package/schematics/collection.json +9 -0
  68. package/schematics/ng-add/index.js +9 -0
  69. package/schematics/ng-add/schema.json +91 -0
  70. package/schematics/package.json +3 -0
  71. package/sidenav/README.md +33 -11
  72. package/speak/README.md +3 -2
  73. package/stepper/README.md +14 -2
  74. package/timeline/README.md +1 -1
  75. package/toc/README.md +4 -1
  76. package/types/cngx-ui-a11y.d.ts +121 -30
  77. package/types/cngx-ui-accordion.d.ts +100 -28
  78. package/types/cngx-ui-action-button.d.ts +44 -3
  79. package/types/cngx-ui-breadcrumb.d.ts +167 -60
  80. package/types/cngx-ui-chart-panel.d.ts +122 -18
  81. package/types/cngx-ui-collection.d.ts +157 -55
  82. package/types/cngx-ui-command-palette.d.ts +297 -183
  83. package/types/cngx-ui-context-menu.d.ts +140 -10
  84. package/types/cngx-ui-data-grid-accordion.d.ts +278 -39
  85. package/types/cngx-ui-empty-state.d.ts +9 -2
  86. package/types/cngx-ui-feedback.d.ts +605 -59
  87. package/types/cngx-ui-mat-accordion.d.ts +30 -1
  88. package/types/cngx-ui-mat-paginator.d.ts +37 -8
  89. package/types/cngx-ui-mat-stepper.d.ts +23 -11
  90. package/types/cngx-ui-mat-tabs.d.ts +250 -34
  91. package/types/cngx-ui-overlay.d.ts +56 -10
  92. package/types/cngx-ui-paginator.d.ts +425 -136
  93. package/types/cngx-ui-sidenav.d.ts +248 -74
  94. package/types/cngx-ui-skeleton.d.ts +6 -7
  95. package/types/cngx-ui-speak.d.ts +118 -5
  96. package/types/cngx-ui-stat-card.d.ts +117 -33
  97. package/types/cngx-ui-stepper.d.ts +88 -49
  98. package/types/cngx-ui-tabs.d.ts +6 -4
  99. package/types/cngx-ui-timeline.d.ts +35 -11
  100. package/types/cngx-ui-toc.d.ts +93 -16
  101. package/types/cngx-ui.d.ts +7 -4
@@ -1,14 +1,36 @@
1
1
  import * as i0 from '@angular/core';
2
- import { runInInjectionContext, effect, untracked, afterNextRender, isDevMode, computed, InjectionToken, makeEnvironmentProviders, inject, TemplateRef, Directive, signal, DestroyRef, EnvironmentInjector, contentChildren, createEnvironmentInjector, Injectable, Injector, Renderer2, ElementRef, ViewContainerRef, contentChild, input } from '@angular/core';
3
- import { MatTab, MatTabGroup, MatTabLink } from '@angular/material/tabs';
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, 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';
11
12
 
13
+ /**
14
+ * Default sink - gated on dev-mode. Production callers see no
15
+ * output; production telemetry lands only when a consumer overrides
16
+ * via `withHalfWiredSlotSink(fn)`.
17
+ *
18
+ * @internal - exported only for {@link CngxMatTabsConfig.halfWiredSlotSink}'s
19
+ * library default. Consumers should override via the config feature
20
+ * rather than reach for this reference directly.
21
+ */
22
+ const CNGX_DEFAULT_HALF_WIRED_SLOT_SINK = (missing) => {
23
+ if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
24
+ return;
25
+ }
26
+ cngxDevWarn('CNGX3006', '[cngxMatTabs] aggregator-content slot half-wired - ' +
27
+ `\`${missing}\` is missing while the other half is supplied. ` +
28
+ 'The decoration projector will silently fall back to the ' +
29
+ 'imperative `textContent` path, and the consumer-projected ' +
30
+ '`*cngxMatTabAggregatorContent` template will never render. ' +
31
+ 'Wire both halves on the [cngxMatTabs] directive (or neither).');
32
+ };
33
+
12
34
  /**
13
35
  * Centralised type façade and selector constants for every Angular
14
36
  * Material internal surface cngx Material-bridge code couples to.
@@ -72,7 +94,8 @@ var MaterialPrivateSurfaces;
72
94
  *
73
95
  * - {@link createMatTabRejectionDecoration} - mirrors
74
96
  * `presenter.lastFailedIndex` onto the matching `.mat-mdc-tab` as a
75
- * class flag plus a hidden `cngx-sr-only` descriptor span linked via
97
+ * class flag, a `data-reason` attribute, an `aria-hidden` glyph span
98
+ * and a hidden `cngx-sr-only` descriptor span linked via
76
99
  * `aria-describedby`. `aria-invalid` is intentionally absent: ARIA
77
100
  * 1.2 scopes it to form-field vocabulary, not `role="tab"`.
78
101
  * - {@link createMatTabAggregatorDecoration} - projects each handle's
@@ -127,13 +150,24 @@ function restoreAriaDescribedbyExceptToken(el, tokenToRemove, renderer, priorAri
127
150
  * resolution O(1) - no DOM rebuild when the origin label arrives
128
151
  * via a downstream `tabs()` re-emission.
129
152
  *
153
+ * Race recovery - when the effect fires before MatTabHeader has
154
+ * rendered the matching button (initial-render race), the failed id
155
+ * is NOT latched (a latched id would suppress every later attempt
156
+ * for the same failure) and a single `afterNextRender` retry is
157
+ * scheduled, bounded by `maxRetryAttempts` - same recovery shape as
158
+ * the aggregator projector.
159
+ *
130
160
  * @internal
131
161
  */
132
162
  function createMatTabRejectionDecoration(opts) {
133
163
  const buttonSelector = opts.buttonSelector ?? MaterialPrivateSurfaces.MAT_MDC_TAB_SELECTOR;
134
164
  const className = opts.className ?? 'cngx-mat-tab--error';
135
165
  const srOnlyClassName = opts.srOnlyClassName ?? 'cngx-sr-only';
166
+ const glyphClassName = opts.glyphClassName ?? 'cngx-mat-tab__rejection-icon';
136
167
  const descriptorIdSuffix = opts.descriptorIdSuffix ?? 'rejected';
168
+ const maxRetryAttempts = opts.maxRetryAttempts ?? 5;
169
+ let pendingRetry = false;
170
+ let retryAttempts = 0;
137
171
  // Slot path needs both halves; either alone degrades to imperative
138
172
  // textContent. No diagnostic - single in-package consumer always
139
173
  // passes both.
@@ -142,6 +176,9 @@ function createMatTabRejectionDecoration(opts) {
142
176
  // Cached across the projector's lifetime - reusing the same node
143
177
  // keeps AT-reader / observer references live across A→B→A flips.
144
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;
145
182
  let priorAriaDescribedby = null;
146
183
  // Pillar 1 - short-circuits structurally-identical re-emissions of
147
184
  // `failedHandleId` so a `tabs()` re-eval doesn't clobber the AT
@@ -170,6 +207,7 @@ function createMatTabRejectionDecoration(opts) {
170
207
  failedHandleId: handleId,
171
208
  originLabel: opts.originLabel?.(),
172
209
  fallbackText: text,
210
+ reason: opts.reason?.() ?? 'failed',
173
211
  };
174
212
  const view = vcr.createEmbeddedView(tpl, context, {
175
213
  injector: opts.injector,
@@ -189,6 +227,13 @@ function createMatTabRejectionDecoration(opts) {
189
227
  destroyEmbeddedView();
190
228
  opts.renderer.setProperty(span, 'textContent', text);
191
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
+ };
192
237
  const clearDecoration = () => {
193
238
  if (!decoratedEl || !cachedSpan) {
194
239
  return;
@@ -196,6 +241,10 @@ function createMatTabRejectionDecoration(opts) {
196
241
  const ownTokenId = cachedSpan.id;
197
242
  destroyEmbeddedView();
198
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
+ }
199
248
  opts.renderer.removeChild(decoratedEl, cachedSpan);
200
249
  // `cachedSpan` deliberately retained - reused on the next apply.
201
250
  restoreAriaDescribedbyExceptToken(decoratedEl, ownTokenId, opts.renderer, priorAriaDescribedby);
@@ -207,9 +256,20 @@ function createMatTabRejectionDecoration(opts) {
207
256
  const buttons = opts.hostEl.querySelectorAll(buttonSelector);
208
257
  const targetEl = buttons.item(failedIdx);
209
258
  if (!targetEl) {
210
- return;
259
+ return false;
211
260
  }
212
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);
213
273
  const spanId = `${handleId}-${descriptorIdSuffix}`;
214
274
  let span = cachedSpan;
215
275
  if (!span) {
@@ -233,6 +293,46 @@ function createMatTabRejectionDecoration(opts) {
233
293
  opts.renderer.setAttribute(targetEl, 'aria-describedby', tokens.join(' '));
234
294
  decoratedEl = targetEl;
235
295
  priorAriaDescribedby = prior;
296
+ return true;
297
+ };
298
+ const applyOrScheduleRetry = (id) => {
299
+ const idx = opts.failedIndex();
300
+ if (idx === undefined) {
301
+ clearDecoration();
302
+ lastAppliedId = null;
303
+ return;
304
+ }
305
+ if (applyDecorationAt(idx, id)) {
306
+ lastAppliedId = id;
307
+ retryAttempts = 0;
308
+ return;
309
+ }
310
+ // Initial-render race - the matching button is not stamped yet.
311
+ // The id is deliberately NOT latched (a latched id would
312
+ // short-circuit every later run for the same failure); retry
313
+ // once per render, bounded like the aggregator projector.
314
+ if (pendingRetry) {
315
+ return;
316
+ }
317
+ if (retryAttempts >= maxRetryAttempts) {
318
+ retryAttempts = 0;
319
+ const sink = opts.onMaxRetriesReached ??
320
+ (typeof ngDevMode !== 'undefined' && ngDevMode
321
+ ? defaultRetryCeilingWarn(maxRetryAttempts, 'rejection')
322
+ : noop);
323
+ sink();
324
+ return;
325
+ }
326
+ pendingRetry = true;
327
+ retryAttempts++;
328
+ afterNextRender(() => {
329
+ pendingRetry = false;
330
+ const current = opts.failedHandleId();
331
+ if (current === null || current === lastAppliedId) {
332
+ return;
333
+ }
334
+ applyOrScheduleRetry(current);
335
+ }, { injector: opts.injector });
236
336
  };
237
337
  runInInjectionContext(opts.injector, () => {
238
338
  effect(() => {
@@ -246,14 +346,19 @@ function createMatTabRejectionDecoration(opts) {
246
346
  lastAppliedId = null;
247
347
  return;
248
348
  }
249
- const idx = opts.failedIndex();
250
- if (idx === undefined) {
251
- clearDecoration();
252
- lastAppliedId = null;
349
+ applyOrScheduleRetry(id);
350
+ });
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) {
253
359
  return;
254
360
  }
255
- applyDecorationAt(idx, id);
256
- lastAppliedId = id;
361
+ writeReason(decoratedEl, cachedGlyph);
257
362
  });
258
363
  });
259
364
  // Live-text effect - tracks `descriptorText` plus the slot
@@ -303,8 +408,11 @@ function createMatTabAggregatorDecoration(opts) {
303
408
  // at runtime, so the signal has to come from a deliberate sink.
304
409
  if (!isFullyWired() && (opts.contentTemplate || opts.viewContainerRef)) {
305
410
  const missing = opts.contentTemplate ? 'viewContainerRef' : 'contentTemplate';
306
- const sink = opts.onHalfWiredSlot ?? defaultHalfWiredSlotWarn;
307
- sink(missing);
411
+ const sink = opts.onHalfWiredSlot ??
412
+ (typeof ngDevMode !== 'undefined' && ngDevMode
413
+ ? CNGX_DEFAULT_HALF_WIRED_SLOT_SINK
414
+ : undefined);
415
+ sink?.(missing);
308
416
  }
309
417
  const decorated = new Map();
310
418
  let pendingRetry = false;
@@ -427,7 +535,10 @@ function createMatTabAggregatorDecoration(opts) {
427
535
  }
428
536
  if (retryAttempts >= maxRetryAttempts) {
429
537
  retryAttempts = 0;
430
- const sink = opts.onMaxRetriesReached ?? defaultRetryCeilingWarn(maxRetryAttempts);
538
+ const sink = opts.onMaxRetriesReached ??
539
+ (typeof ngDevMode !== 'undefined' && ngDevMode
540
+ ? defaultRetryCeilingWarn(maxRetryAttempts, 'aggregator')
541
+ : noop);
431
542
  sink();
432
543
  return;
433
544
  }
@@ -456,35 +567,31 @@ function createMatTabAggregatorDecoration(opts) {
456
567
  }
457
568
  });
458
569
  }
459
- function defaultHalfWiredSlotWarn(missing) {
460
- if (!isDevMode()) {
461
- return;
570
+ const noop = () => undefined;
571
+ function defaultRetryCeilingWarn(max, decoration) {
572
+ if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
573
+ return noop;
462
574
  }
463
- console.warn('[cngxMatTabs] aggregator-content slot half-wired - ' +
464
- `\`${missing}\` is missing while the other half is supplied. ` +
465
- 'The decoration projector will silently fall back to the ' +
466
- 'imperative `textContent` path, and the consumer-projected ' +
467
- '`*cngxMatTabAggregatorContent` template will never render. ' +
468
- 'Wire both halves on the [cngxMatTabs] directive (or neither).');
469
- }
470
- function defaultRetryCeilingWarn(max) {
471
575
  return () => {
472
- if (!isDevMode()) {
473
- return;
474
- }
475
- console.warn('[cngxMatTabs] aggregator decoration retry ceiling reached ' +
576
+ cngxDevWarn('CNGX3005', `[cngxMatTabs] ${decoration} decoration retry ceiling reached ` +
476
577
  `(${max} attempts) - MatTabHeader did not render ` +
477
578
  '`.mat-mdc-tab` buttons within the expected window. Likely ' +
478
579
  'cause: Material upgrade broke the `.mat-mdc-tab` selector ' +
479
580
  'contract or a consumer-side render stall. ' +
480
- 'Bound aggregators may remain visually undecorated ' +
581
+ 'The decoration may remain visually missing ' +
481
582
  'until the next state change.');
482
583
  };
483
584
  }
484
585
 
485
586
  /**
486
- * Builds the reactive list of tabs whose bound error-aggregator wants
487
- * reveal, in registration (DOM) order. Feeds
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
488
595
  * {@link createMatTabAggregatorDecoration} for both the
489
596
  * `[cngxMatTabs]` (`<mat-tab-group>`) and `[cngxMatTabNav]`
490
597
  * (`<nav mat-tab-nav-bar>`) bridges - one body, two hosts (Pillar 3).
@@ -494,22 +601,36 @@ function defaultRetryCeilingWarn(max) {
494
601
  *
495
602
  * @internal
496
603
  */
497
- 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
+ };
498
618
  return computed(() => {
499
619
  const tabs = presenter.tabs();
500
620
  const acc = [];
501
621
  for (let i = 0; i < tabs.length; i++) {
502
622
  const handle = tabs[i];
503
- const aggregator = handle.errorAggregator();
504
- if (aggregator?.shouldShow()) {
505
- acc.push({
506
- idx: i,
507
- id: handle.id,
508
- announcement: aggregator.announcement(),
509
- count: aggregator.errorCount(),
510
- label: handle.label() ?? '',
511
- });
623
+ if (!handle.hasError()) {
624
+ continue;
512
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
+ });
513
634
  }
514
635
  return acc;
515
636
  }, {
@@ -531,27 +652,8 @@ function createAggregatedErrorTabs(presenter) {
531
652
  });
532
653
  }
533
654
 
534
- /**
535
- * Default sink - gated on dev-mode. Production callers see no
536
- * output; production telemetry lands only when a consumer overrides
537
- * via `withHalfWiredSlotSink(fn)`.
538
- *
539
- * @internal - exported only for {@link CngxMatTabsConfig.halfWiredSlotSink}'s
540
- * library default. Consumers should override via the config feature
541
- * rather than reach for this reference directly.
542
- */
543
- const CNGX_DEFAULT_HALF_WIRED_SLOT_SINK = (missing) => {
544
- if (!isDevMode()) {
545
- return;
546
- }
547
- console.warn('[cngxMatTabs] aggregator-content slot half-wired - ' +
548
- `\`${missing}\` is missing while the other half is supplied. ` +
549
- 'The decoration projector will silently fall back to the ' +
550
- 'imperative `textContent` path, and the consumer-projected ' +
551
- '`*cngxMatTabAggregatorContent` template will never render. ' +
552
- 'Wire both halves on the [cngxMatTabs] directive (or neither).');
553
- };
554
-
655
+ /** Production default for `halfWiredSlotSink`: one reference, so reads stay identical. */
656
+ const SILENT_HALF_WIRED_SLOT_SINK = () => undefined;
555
657
  /**
556
658
  * Library defaults for `[cngxMatTabs]`. Source of truth for every
557
659
  * key on {@link CngxMatTabsConfig}. Consumed by
@@ -561,7 +663,14 @@ const CNGX_DEFAULT_HALF_WIRED_SLOT_SINK = (missing) => {
561
663
  */
562
664
  const CNGX_MAT_TABS_CONFIG_DEFAULTS = {
563
665
  anchorMaxAttempts: 5,
564
- halfWiredSlotSink: CNGX_DEFAULT_HALF_WIRED_SLOT_SINK,
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
+ },
673
+ templates: {},
565
674
  };
566
675
  /**
567
676
  * DI token holding a partial {@link CngxMatTabsConfig}. Set via
@@ -596,10 +705,27 @@ function withAnchorRetryAttempts(n) {
596
705
  function withHalfWiredSlotSink(sink) {
597
706
  return feature({ halfWiredSlotSink: sink });
598
707
  }
708
+ /**
709
+ * App-wide override for the rejection SR-descriptor content. Middle
710
+ * tier; per-instance `*cngxMatTabRejectionContent` still wins.
711
+ * Sibling of {@link withTabRejectionIconTemplate} in the cngx-native
712
+ * family.
713
+ *
714
+ * @category ui/mat-tabs
715
+ */
716
+ function withMatTabRejectionTemplate(template) {
717
+ return feature({ templates: { rejection: template } });
718
+ }
599
719
  function mergeFeatures(features) {
600
720
  const merged = {};
601
721
  for (const f of features) {
602
- Object.assign(merged, f.config);
722
+ const { templates, ...rest } = f.config;
723
+ Object.assign(merged, rest);
724
+ if (templates) {
725
+ // Nested-merge so several template features compose instead of the
726
+ // last one overwriting the whole templates object.
727
+ merged.templates = { ...merged.templates, ...templates };
728
+ }
603
729
  }
604
730
  return merged;
605
731
  }
@@ -632,6 +758,11 @@ function provideMatTabsConfig(...features) {
632
758
  * `providers` or `viewProviders` (which cannot accept opaque
633
759
  * environment providers).
634
760
  *
761
+ * Merges over the outer config (via `skipSelf`), so a component-scope
762
+ * call refines the root {@link provideMatTabsConfig} instead of
763
+ * reverting its untouched keys to library defaults - only the keys
764
+ * the local features set are overridden for the subtree.
765
+ *
635
766
  * ```ts
636
767
  * @Component({
637
768
  * selector: 'app-tabs-page',
@@ -645,7 +776,22 @@ function provideMatTabsConfig(...features) {
645
776
  * @category ui/mat-tabs
646
777
  */
647
778
  function provideMatTabsConfigAt(...features) {
648
- return [{ provide: CNGX_MAT_TABS_CONFIG, useValue: mergeFeatures(features) }];
779
+ return [
780
+ {
781
+ provide: CNGX_MAT_TABS_CONFIG,
782
+ useFactory: () => {
783
+ const outer = inject(CNGX_MAT_TABS_CONFIG, { optional: true, skipSelf: true }) ?? {};
784
+ const local = mergeFeatures(features);
785
+ return {
786
+ ...outer,
787
+ ...local,
788
+ // Nested-merge so a local template feature refines the outer
789
+ // template set instead of replacing it wholesale.
790
+ templates: { ...outer.templates, ...local.templates },
791
+ };
792
+ },
793
+ },
794
+ ];
649
795
  }
650
796
  /**
651
797
  * Resolve the effective `[cngxMatTabs]` configuration for the current
@@ -664,6 +810,21 @@ function injectMatTabsConfig() {
664
810
  return {
665
811
  anchorMaxAttempts: user.anchorMaxAttempts ?? CNGX_MAT_TABS_CONFIG_DEFAULTS.anchorMaxAttempts,
666
812
  halfWiredSlotSink: user.halfWiredSlotSink ?? CNGX_MAT_TABS_CONFIG_DEFAULTS.halfWiredSlotSink,
813
+ templates: { ...CNGX_MAT_TABS_CONFIG_DEFAULTS.templates, ...user.templates },
814
+ };
815
+ }
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),
667
828
  };
668
829
  }
669
830
 
@@ -731,7 +892,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
731
892
  * Cascade resolution:
732
893
  * 1. Per-instance `*cngxMatTabRejectionContent` template wins
733
894
  * via `contentChild(CngxMatTabRejectionContent)`.
734
- * 2. Library default - imperative `Renderer2.createElement('span')`
895
+ * 2. `CNGX_MAT_TABS_CONFIG.templates.rejection` (app-wide middle
896
+ * tier, set via `withMatTabRejectionTemplate`).
897
+ * 3. Library default - imperative `Renderer2.createElement('span')`
735
898
  * with `textContent = fallbackText` (the resolved
736
899
  * `commitRolledBackTo(originLabel)` / `commitFailedRetry`
737
900
  * phrase from `injectTabsI18n()`).
@@ -793,8 +956,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
793
956
  * `untracked` - the announcer owns its own clear-then-set timer, so it
794
957
  * stays out of the effect's dependency graph.
795
958
  *
796
- * @internal - package-private helper for `[cngxMatTabs]`. Not
797
- * exported from `public-api.ts`.
959
+ * @internal - helper shared by the Material bridge directives
960
+ * (`[cngxMatTabs]`, `[cngxMatTabNav]`, `[cngxMatStepper]`). Exported
961
+ * `@internal` from the mat-tabs barrel for cross-entry consumption
962
+ * (the `MaterialPrivateSurfaces` pattern) - ng-packagr rejects
963
+ * relative-import file sharing between entry points.
798
964
  */
799
965
  function mountLiveRegionAnnouncer(opts) {
800
966
  const politeness = opts.politeness ?? 'polite';
@@ -812,15 +978,36 @@ function mountLiveRegionAnnouncer(opts) {
812
978
 
813
979
  /**
814
980
  * Build the {@link CngxMatTabRejectionState} bundle for a given
815
- * presenter + i18n pair. Two computeds share one source-walk
816
- * (`lastFailedIndex` → `originIndexDuringCommit` → `tabs[idx].label()`)
817
- * via Angular's signal memoisation - the second computed re-uses
818
- * the first's cached `originLabel` value, so the `tabs()` traversal
819
- * happens at most once per state change.
981
+ * presenter + i18n pair. `descriptorText` re-uses the cached
982
+ * `originLabel` walk (`lastFailedIndex` → `originIndexDuringCommit` →
983
+ * `tabs[idx].label()`). The live announcement walks the indices itself so
984
+ * they stay tracked while the label, which a consumer may translate, is
985
+ * read untracked.
820
986
  *
821
987
  * @internal
822
988
  */
823
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
+ }
1004
+ const failedHandleId = computed(() => {
1005
+ const idx = presenter.lastFailedIndex();
1006
+ if (idx === undefined) {
1007
+ return null;
1008
+ }
1009
+ return presenter.tabs()[idx]?.id ?? null;
1010
+ }, ...(ngDevMode ? [{ debugName: "failedHandleId" }] : /* istanbul ignore next */ []));
824
1011
  const originLabel = computed(() => {
825
1012
  const failedIdx = presenter.lastFailedIndex();
826
1013
  if (failedIdx === undefined) {
@@ -832,25 +1019,135 @@ function createRejectionState(presenter, i18n) {
832
1019
  }
833
1020
  return presenter.tabs()[originIdx]?.label() ?? undefined;
834
1021
  }, ...(ngDevMode ? [{ debugName: "originLabel" }] : /* istanbul ignore next */ []));
835
- const descriptorText = computed(() => {
1022
+ const reason = computed(() => {
836
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) {
837
1031
  return '';
838
1032
  }
839
- const label = originLabel();
840
- return label ? i18n.commitRolledBackTo(label) : i18n.commitFailedRetry;
1033
+ const copy = i18n();
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;
841
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
+ }
1055
+ // Feeds the live announcer: copy and the origin tab label (which a
1056
+ // consumer may translate) are read untracked so a language switch does
1057
+ // not re-announce; the next transition speaks the new language.
842
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
+ }
843
1066
  const current = presenter.commitTransition.current();
844
1067
  if (current === 'pending') {
845
- return i18n.commitInFlight;
1068
+ return untracked(() => i18n().commitInFlight);
846
1069
  }
847
1070
  if (current === 'error') {
848
- const label = originLabel();
849
- return label ? i18n.commitRolledBackTo(label) : i18n.commitFailedRetry;
1071
+ const failedIdx = presenter.lastFailedIndex();
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;
1075
+ return untracked(() => {
1076
+ const copy = i18n();
1077
+ const name = hasOrigin ? originName(originIdx, copy) : undefined;
1078
+ return name ? copy.commitRolledBackTo(name) : copy.commitFailedRetry;
1079
+ });
850
1080
  }
851
1081
  return '';
852
1082
  }, ...(ngDevMode ? [{ debugName: "liveAnnouncement" }] : /* istanbul ignore next */ []));
853
- return { originLabel, descriptorText, liveAnnouncement };
1083
+ return { failedHandleId, originLabel, reason, descriptorText, liveAnnouncement };
1084
+ }
1085
+
1086
+ /**
1087
+ * Create the order-aware registration seam. See the module JSDoc for
1088
+ * the contract.
1089
+ *
1090
+ * @internal
1091
+ */
1092
+ function createOrderedRegistrationSeam(options) {
1093
+ const entries = new Map();
1094
+ // Presenter-side registration order - the seam issued every
1095
+ // register() call, so this array IS the presenter's order.
1096
+ let registeredOrder = [];
1097
+ const sync = (items) => {
1098
+ const live = new Set(items);
1099
+ // Drop stale entries first so the order diff below only compares
1100
+ // survivors. Snapshot before iterating - deletes inside the body
1101
+ // must not collide with iterator state.
1102
+ for (const [item, entry] of Array.from(entries.entries())) {
1103
+ if (live.has(item)) {
1104
+ continue;
1105
+ }
1106
+ options.unregister(entry);
1107
+ options.dispose(entry);
1108
+ entries.delete(item);
1109
+ }
1110
+ registeredOrder = registeredOrder.filter((item) => entries.has(item));
1111
+ // Longest shared prefix stays registered as-is; everything after
1112
+ // it re-registers in query order. Append-only emissions keep
1113
+ // prefix === registeredOrder.length and cause zero churn.
1114
+ let prefix = 0;
1115
+ while (prefix < registeredOrder.length &&
1116
+ prefix < items.length &&
1117
+ registeredOrder[prefix] === items[prefix]) {
1118
+ prefix += 1;
1119
+ }
1120
+ for (let i = registeredOrder.length - 1; i >= prefix; i -= 1) {
1121
+ const entry = entries.get(registeredOrder[i]);
1122
+ if (entry !== undefined) {
1123
+ options.unregister(entry);
1124
+ }
1125
+ }
1126
+ registeredOrder.length = prefix;
1127
+ for (let i = prefix; i < items.length; i += 1) {
1128
+ const item = items[i];
1129
+ let entry = entries.get(item);
1130
+ if (entry === undefined) {
1131
+ entry = options.create(item);
1132
+ entries.set(item, entry);
1133
+ }
1134
+ options.register(entry);
1135
+ registeredOrder.push(item);
1136
+ }
1137
+ };
1138
+ const clear = () => {
1139
+ for (const entry of entries.values()) {
1140
+ options.unregister(entry);
1141
+ options.dispose(entry);
1142
+ }
1143
+ entries.clear();
1144
+ registeredOrder = [];
1145
+ };
1146
+ return {
1147
+ sync,
1148
+ get: (item) => entries.get(item),
1149
+ clear,
1150
+ };
854
1151
  }
855
1152
 
856
1153
  /**
@@ -994,11 +1291,20 @@ const CNGX_MAT_TABS_REGISTRY_HOST = new InjectionToken('CngxMatTabsRegistryHost'
994
1291
  * LOC guard and lets per-tab decoration directives reach the
995
1292
  * registry through a typed token.
996
1293
  *
997
- * Owns: `contentChildren(MatTab)` query, the `setupsByTab` map
998
- * (per-tab cngx setup paired with a child `EnvironmentInjector`
999
- * scoping the `_stateChanges` bridge), an `effect()` that diffs the
1000
- * MatTab list and (un)registers handles with `CNGX_TAB_GROUP_HOST`,
1001
- * and a `DestroyRef` cleanup that destroys every child injector.
1294
+ * Owns: `contentChildren(MatTab)` query, the order-aware
1295
+ * registration seam (per-tab cngx setup paired with a child
1296
+ * `EnvironmentInjector` scoping the `_stateChanges` bridge), an
1297
+ * `effect()` that mirrors the MatTab query order into
1298
+ * `CNGX_TAB_GROUP_HOST` on every emission, and a `DestroyRef`
1299
+ * cleanup that unregisters and destroys every entry.
1300
+ *
1301
+ * Order matters: the presenter registry appends new registrations,
1302
+ * but Material renders tabs at their DOM position - a mid-list
1303
+ * `<mat-tab>` insert must land at its query index, not at the tail,
1304
+ * or index-based selection, announcements and decorations target the
1305
+ * wrong tab. The shared seam re-registers the diverging suffix in
1306
+ * query order while keeping surviving handle instances (and their
1307
+ * child injectors) alive.
1002
1308
  *
1003
1309
  * Composition: `[cngxMatTabs]` declares this in `hostDirectives`;
1004
1310
  * both share the parent's `CngxTabGroupPresenter` and the same
@@ -1016,53 +1322,38 @@ class CngxMatTabsRegistry {
1016
1322
  destroyRef = inject(DestroyRef);
1017
1323
  envInjector = inject(EnvironmentInjector);
1018
1324
  createHandle = inject(CNGX_MAT_TAB_HANDLE_FACTORY);
1325
+ matTabGroup = inject(MatTabGroup, { self: true });
1019
1326
  matTabs = contentChildren(MatTab, { ...(ngDevMode ? { debugName: "matTabs" } : /* istanbul ignore next */ {}), descendants: true });
1020
- // Map (not WeakMap) so the diff loop in `syncHandles` can iterate
1021
- // to find removed tabs without a parallel `Set<MatTab>`. Entries
1022
- // are explicitly deleted when the matching MatTab leaves the
1023
- // children set, AND the map goes away on directive destroy.
1024
- setupsByTab = new Map();
1025
- constructor() {
1026
- effect(() => {
1027
- const tabs = this.matTabs();
1028
- untracked(() => this.syncHandles(tabs));
1029
- });
1030
- this.destroyRef.onDestroy(() => {
1031
- for (const entry of this.setupsByTab.values()) {
1032
- // Disposes the per-tab `toSignal(_stateChanges)` bridge.
1033
- entry.childInjector.destroy();
1034
- }
1035
- this.setupsByTab.clear();
1036
- });
1037
- }
1038
- getHandleSetup(matTab) {
1039
- return this.setupsByTab.get(matTab)?.setup;
1040
- }
1041
- syncHandles(tabs) {
1042
- const liveTabs = new Set(tabs);
1043
- for (const tab of tabs) {
1044
- if (this.setupsByTab.has(tab)) {
1045
- continue;
1046
- }
1327
+ seam = createOrderedRegistrationSeam({
1328
+ create: (tab) => {
1047
1329
  // Per-tab child injector scopes the `toSignal(_stateChanges)`
1048
1330
  // bridge inside createMatTabHandle - destroying it on tab
1049
1331
  // removal fires `takeUntilDestroyed`.
1050
1332
  const childInjector = createEnvironmentInjector([], this.envInjector);
1051
1333
  const idSeed = () => nextUid('cngx-mat-tab-');
1052
1334
  const setup = this.createHandle(tab, idSeed, childInjector);
1053
- this.setupsByTab.set(tab, { setup, childInjector });
1054
- this.presenter.register(setup.handle);
1055
- }
1056
- // Snapshot entries before the loop so multi-key deletes inside
1057
- // the body never collide with iterator state.
1058
- for (const [tab, entry] of Array.from(this.setupsByTab.entries())) {
1059
- if (liveTabs.has(tab)) {
1060
- continue;
1061
- }
1062
- entry.childInjector.destroy();
1063
- this.setupsByTab.delete(tab);
1064
- this.presenter.unregister(entry.setup.handle.id);
1065
- }
1335
+ return { setup, childInjector };
1336
+ },
1337
+ register: (entry) => this.presenter.register(entry.setup.handle),
1338
+ unregister: (entry) => this.presenter.unregister(entry.setup.handle.id, entry.setup.handle),
1339
+ dispose: (entry) => entry.childInjector.destroy(),
1340
+ });
1341
+ constructor() {
1342
+ effect(() => {
1343
+ // Ownership filter: `descendants: true` also surfaces MatTabs of
1344
+ // a tab-group nested inside one of OUR tabs' content. Each MatTab
1345
+ // carries its owning `_closestTabGroup` (see
1346
+ // MaterialPrivateSurfaces.ClosestTabGroupSource), so foreign tabs
1347
+ // are dropped before they can register with this presenter -
1348
+ // mirrors the mat-stepper/mat-accordion sibling filters.
1349
+ const tabs = this.matTabs().filter((tab) => tab._closestTabGroup ===
1350
+ this.matTabGroup);
1351
+ untracked(() => this.seam.sync(tabs));
1352
+ });
1353
+ this.destroyRef.onDestroy(() => this.seam.clear());
1354
+ }
1355
+ getHandleSetup(matTab) {
1356
+ return this.seam.get(matTab)?.setup;
1066
1357
  }
1067
1358
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabsRegistry, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1068
1359
  static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxMatTabsRegistry, isStandalone: true, selector: "[cngxMatTabsRegistry]", providers: [
@@ -1182,6 +1473,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1182
1473
  * `./decorations/`; this directive supplies their reactive triggers
1183
1474
  * and the delegators consumer templates call.
1184
1475
  *
1476
+ * **Inert on this bridge: `loop` and `orientation`.** Both are
1477
+ * forwarded so templates stay portable between `<cngx-tab-group>` and
1478
+ * the instrumented `<mat-tab-group>`, but Material owns the keyboard
1479
+ * interaction and the strip layout here - `loop` never changes
1480
+ * Material's Home/End/arrow behaviour, and `orientation` never
1481
+ * rotates the Material strip (use `<mat-tab-group headerPosition>` /
1482
+ * Material's own APIs for that). `orientation` still reaches the
1483
+ * cngx side through the overflow panel-host adapter; `loop` feeds
1484
+ * nothing Material does not already own. Deliberately kept in the
1485
+ * forwarded input set for template portability - removing them would
1486
+ * break `<cngx-tab-group>`-authored templates on paste.
1487
+ *
1185
1488
  * @playground Form error aggregation ./examples/form-errors/form-errors.component.ts
1186
1489
  *
1187
1490
  * @category ui/mat-tabs
@@ -1217,32 +1520,24 @@ class CngxMatTabs {
1217
1520
  injector: this.injector,
1218
1521
  });
1219
1522
  aggregatorContentSlot = contentChild(CngxMatTabAggregatorContent, ...(ngDevMode ? [{ debugName: "aggregatorContentSlot" }] : /* istanbul ignore next */ []));
1220
- aggregatorContentTemplate = computed(() => this.aggregatorContentSlot()?.templateRef ?? null, ...(ngDevMode ? [{ debugName: "aggregatorContentTemplate" }] : /* istanbul ignore next */ []));
1523
+ matTabsConfig = injectMatTabsConfig();
1221
1524
  rejectionContentSlot = contentChild(CngxMatTabRejectionContent, ...(ngDevMode ? [{ debugName: "rejectionContentSlot" }] : /* istanbul ignore next */ []));
1222
- rejectionContentTemplate = computed(() => this.rejectionContentSlot()?.templateRef ?? 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);
1223
1527
  i18n = injectTabsI18n();
1224
- // Identity equal on `string | null` - collapses `tabs()` re-emits
1225
- // that don't change the failed-target id.
1226
- failedHandleId = computed(() => {
1227
- const idx = this.presenter.lastFailedIndex();
1228
- if (idx === undefined) {
1229
- return null;
1230
- }
1231
- return this.presenter.tabs()[idx]?.id ?? null;
1232
- }, ...(ngDevMode ? [{ debugName: "failedHandleId" }] : /* istanbul ignore next */ []));
1233
- // Bundle shares one source-walk across descriptorText / originLabel
1234
- // / liveAnnouncement - pillar-2 phrasing parity with cngx-native.
1528
+ // Bundle shares one source-walk across failedHandleId /
1529
+ // descriptorText / originLabel / liveAnnouncement - pillar-2
1530
+ // phrasing parity with cngx-native.
1235
1531
  rejectionState = createRejectionState(this.presenter, this.i18n);
1236
1532
  // Shared with `[cngxMatTabNav]` - one body, two hosts (Pillar 3).
1237
1533
  // Structural equal lives in the factory so the projector doesn't
1238
1534
  // churn on no-op aggregator re-emissions.
1239
- aggregatedErrorTabs = createAggregatedErrorTabs(this.presenter);
1535
+ aggregatedErrorTabs = createAggregatedErrorTabs(this.presenter, this.i18n);
1240
1536
  constructor() {
1241
- const matTabsConfig = injectMatTabsConfig();
1537
+ const matTabsConfig = this.matTabsConfig;
1242
1538
  // Polite live region - attribute directive owns no template, so
1243
- // the helper attaches the span at document.body (CDK
1244
- // LiveAnnouncer convention) and mirrors `CngxLiveRegion`'s host
1245
- // bindings imperatively.
1539
+ // the helper forwards every non-empty announcement to the shared
1540
+ // root CngxLiveAnnouncer, which owns the persistent region pair.
1246
1541
  mountLiveRegionAnnouncer({
1247
1542
  announcement: this.rejectionState.liveAnnouncement,
1248
1543
  injector: this.injector,
@@ -1251,15 +1546,16 @@ class CngxMatTabs {
1251
1546
  // registration; the directive only supplies reactive triggers.
1252
1547
  createMatTabRejectionDecoration({
1253
1548
  hostEl: this.hostEl,
1254
- failedHandleId: this.failedHandleId,
1549
+ failedHandleId: this.rejectionState.failedHandleId,
1255
1550
  failedIndex: this.presenter.lastFailedIndex,
1256
1551
  descriptorText: this.rejectionState.descriptorText,
1257
1552
  renderer: this.renderer,
1258
1553
  injector: this.injector,
1259
1554
  destroyRef: this.destroyRef,
1260
- contentTemplate: this.rejectionContentTemplate,
1555
+ contentTemplate: this.decorationTemplates.rejection,
1261
1556
  viewContainerRef: this.viewContainerRef,
1262
1557
  originLabel: this.rejectionState.originLabel,
1558
+ reason: this.rejectionState.reason,
1263
1559
  });
1264
1560
  createMatTabAggregatorDecoration({
1265
1561
  hostEl: this.hostEl,
@@ -1267,7 +1563,7 @@ class CngxMatTabs {
1267
1563
  renderer: this.renderer,
1268
1564
  injector: this.injector,
1269
1565
  destroyRef: this.destroyRef,
1270
- contentTemplate: this.aggregatorContentTemplate,
1566
+ contentTemplate: this.decorationTemplates.aggregator,
1271
1567
  viewContainerRef: this.viewContainerRef,
1272
1568
  onHalfWiredSlot: matTabsConfig.halfWiredSlotSink,
1273
1569
  });
@@ -1297,8 +1593,8 @@ class CngxMatTabs {
1297
1593
  return () => undefined;
1298
1594
  },
1299
1595
  onGiveUp: () => {
1300
- if (isDevMode()) {
1301
- console.warn(`[CngxMatTabs] Could not anchor <cngx-tab-overflow> after ${anchorMaxAttempts} ` +
1596
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
1597
+ cngxDevWarn('CNGX3007', `[cngxMatTabs] could not anchor <cngx-tab-overflow> after ${anchorMaxAttempts} ` +
1302
1598
  'attempts - .mat-mdc-tab-header was not found inside the ' +
1303
1599
  'host. The More popover will fall back to a sibling-of-' +
1304
1600
  '<mat-tab-group> position; verify Material rendered the ' +
@@ -1322,14 +1618,21 @@ class CngxMatTabs {
1322
1618
  });
1323
1619
  // Routed (pessimistic) gate: a rejected switch holds `activeIndex` at
1324
1620
  // origin, so the presenter to Material mirror never fires and Material
1325
- // stays eager-advanced on the refused tab. Snap it back when the
1326
- // commit settles into an error. `status()` always transitions through
1327
- // `pending` first, so the `error` edge is observed even when the
1328
- // router cancels a microtask after `navigate()`.
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 */ []));
1329
1632
  effect(() => {
1330
- const status = this.presenter.commitState.status();
1633
+ const sequence = outcomeSequence();
1331
1634
  untracked(() => {
1332
- if (status === 'error') {
1635
+ if (sequence !== undefined) {
1333
1636
  sync.reconcile();
1334
1637
  }
1335
1638
  });
@@ -1423,17 +1726,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1423
1726
  * reflects `NavigationEnd` onto `activeIndex` (its commit-action stays
1424
1727
  * dormant because link clicks navigate natively, never through
1425
1728
  * `presenter.select`). Ableitung statt Verwaltung - the route-active
1426
- * link is the single source of the active index.
1729
+ * link is the single source of the active index. `activeIndex` /
1730
+ * `activeIndexChange` are forwarded from the presenter hostDirective,
1731
+ * so a consumer without route-sync can two-way bind the active link
1732
+ * the same way `[cngxMatTabs]` consumers do.
1733
+ *
1734
+ * Active-link changes speak: the shared nav announcement bundle
1735
+ * ({@link createTabNavAnnouncement}) feeds the landing link's label to
1736
+ * the shared live announcer - silent through the mount window, so a
1737
+ * deep link's initial active state is not announced as a change.
1427
1738
  *
1428
1739
  * Composes {@link CngxTabGroupPresenter} via `hostDirectives` so the
1429
1740
  * `CNGX_STATEFUL` producer, the `lastFailedIndex` rejection slot, and
1430
1741
  * the live-region announcer come for free, identical to the cngx
1431
1742
  * organism (Pillar 2 - same communication across skins).
1432
1743
  *
1433
- * Decoration content-template slots (`*cngxMatTabRejectionContent` /
1434
- * `*cngxMatTabAggregatorContent`) are not forwarded on this bridge yet -
1435
- * the projectors render their built-in `cngx-sr-only` spans. The slot
1436
- * inputs that `[cngxMatTabs]` exposes are a deferred follow-up.
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.
1437
1750
  *
1438
1751
  * @playground Native router tabs with a CanDeactivate guard ./examples/router-nav/router-nav.component.ts
1439
1752
  *
@@ -1443,6 +1756,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1443
1756
  * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tab-nav.directive.ts
1444
1757
  * @since 0.1.0
1445
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.
1446
1761
  */
1447
1762
  class CngxMatTabNav {
1448
1763
  presenter = inject(CNGX_TAB_GROUP_HOST);
@@ -1450,34 +1765,43 @@ class CngxMatTabNav {
1450
1765
  injector = inject(Injector);
1451
1766
  renderer = inject(Renderer2);
1452
1767
  hostEl = inject(ElementRef).nativeElement;
1768
+ viewContainerRef = inject(ViewContainerRef);
1769
+ matTabsConfig = injectMatTabsConfig();
1453
1770
  i18n = injectTabsI18n();
1454
- // Stable id of the rejected link, or null. Identity equal collapses
1455
- // tabs() re-emits that don't change the failed-target id.
1456
- failedHandleId = computed(() => {
1457
- const idx = this.presenter.lastFailedIndex();
1458
- if (idx === undefined) {
1459
- return null;
1460
- }
1461
- return this.presenter.tabs()[idx]?.id ?? null;
1462
- }, ...(ngDevMode ? [{ debugName: "failedHandleId" }] : /* istanbul ignore next */ []));
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);
1463
1774
  rejectionState = createRejectionState(this.presenter, this.i18n);
1464
- aggregatedErrorTabs = createAggregatedErrorTabs(this.presenter);
1775
+ aggregatedErrorTabs = createAggregatedErrorTabs(this.presenter, this.i18n);
1465
1776
  constructor() {
1466
1777
  mountLiveRegionAnnouncer({
1467
1778
  announcement: this.rejectionState.liveAnnouncement,
1468
1779
  injector: this.injector,
1469
1780
  });
1781
+ // Active-link landing announcement - same bundle as the cngx-native
1782
+ // <cngx-tab-nav>; the shared announcer coalesces both feeds into
1783
+ // one polite region.
1784
+ mountLiveRegionAnnouncer({
1785
+ announcement: createTabNavAnnouncement({
1786
+ presenter: this.presenter,
1787
+ injector: this.injector,
1788
+ }).liveAnnouncement,
1789
+ injector: this.injector,
1790
+ });
1470
1791
  // Same projector bodies as `[cngxMatTabs]`; only the per-tab element
1471
1792
  // selector differs (`.mat-mdc-tab-link` vs `.mat-mdc-tab`).
1472
1793
  createMatTabRejectionDecoration({
1473
1794
  hostEl: this.hostEl,
1474
- failedHandleId: this.failedHandleId,
1795
+ failedHandleId: this.rejectionState.failedHandleId,
1475
1796
  failedIndex: this.presenter.lastFailedIndex,
1476
1797
  descriptorText: this.rejectionState.descriptorText,
1477
1798
  renderer: this.renderer,
1478
1799
  injector: this.injector,
1479
1800
  destroyRef: this.destroyRef,
1801
+ contentTemplate: this.decorationTemplates.rejection,
1802
+ viewContainerRef: this.viewContainerRef,
1480
1803
  originLabel: this.rejectionState.originLabel,
1804
+ reason: this.rejectionState.reason,
1481
1805
  buttonSelector: '.mat-mdc-tab-link',
1482
1806
  });
1483
1807
  createMatTabAggregatorDecoration({
@@ -1486,6 +1810,9 @@ class CngxMatTabNav {
1486
1810
  renderer: this.renderer,
1487
1811
  injector: this.injector,
1488
1812
  destroyRef: this.destroyRef,
1813
+ contentTemplate: this.decorationTemplates.aggregator,
1814
+ viewContainerRef: this.viewContainerRef,
1815
+ onHalfWiredSlot: this.matTabsConfig.halfWiredSlotSink,
1489
1816
  buttonSelector: '.mat-mdc-tab-link',
1490
1817
  });
1491
1818
  }
@@ -1498,7 +1825,7 @@ class CngxMatTabNav {
1498
1825
  this.presenter.clearLastFailed();
1499
1826
  }
1500
1827
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabNav, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1501
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxMatTabNav, isStandalone: true, selector: "[cngxMatTabNav]", providers: [{ provide: CNGX_TAB_NAV_HOST, useValue: true }], exportAs: ["cngxMatTabNav"], hostDirectives: [{ directive: i1.CngxTabGroupPresenter }], ngImport: i0 });
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 });
1502
1829
  }
1503
1830
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabNav, decorators: [{
1504
1831
  type: Directive,
@@ -1509,9 +1836,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1509
1836
  // Presence-only marker: it tells a stacked [cngxTabsRouteSync] that its
1510
1837
  // links own subtrees, so the URL match is prefix rather than suffix.
1511
1838
  providers: [{ provide: CNGX_TAB_NAV_HOST, useValue: true }],
1512
- hostDirectives: [CngxTabGroupPresenter],
1839
+ hostDirectives: [
1840
+ {
1841
+ directive: CngxTabGroupPresenter,
1842
+ inputs: ['activeIndex'],
1843
+ outputs: ['activeIndexChange'],
1844
+ },
1845
+ ],
1513
1846
  }]
1514
- }], ctorParameters: () => [] });
1847
+ }], ctorParameters: () => [], propDecorators: { aggregatorContentSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxMatTabAggregatorContent), { isSignal: true }] }], rejectionContentSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxMatTabRejectionContent), { isSignal: true }] }] } });
1515
1848
 
1516
1849
  /**
1517
1850
  * Registers an `<a mat-tab-link>` anchor as a {@link CngxTabHandle}
@@ -1540,7 +1873,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1540
1873
  * @relatedTo CngxMatTabNav, CngxMatTabs, CngxTab
1541
1874
  */
1542
1875
  class CngxMatTabLink {
1543
- matLink = inject(MatTabLink, { self: true });
1544
1876
  host = inject(CNGX_TAB_GROUP_HOST);
1545
1877
  destroyRef = inject(DestroyRef);
1546
1878
  /**
@@ -1560,6 +1892,14 @@ class CngxMatTabLink {
1560
1892
  error = input(false, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
1561
1893
  /** Optional rich error aggregator for the link. */
1562
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 });
1563
1903
  errorMessage = computed(() => {
1564
1904
  const value = this.error();
1565
1905
  return typeof value === 'string' && value !== '' ? value : undefined;
@@ -1569,28 +1909,22 @@ class CngxMatTabLink {
1569
1909
  return ((direct !== false && direct !== '') ||
1570
1910
  (this.errorAggregator()?.shouldShow?.() ?? false));
1571
1911
  }, { ...(ngDevMode ? { debugName: "hasError" } : /* istanbul ignore next */ {}), equal: Object.is });
1572
- // Material's MatTabLink.disabled is a plain property, not a signal;
1573
- // nav links rarely toggle disabled at runtime, so snapshot it onto a
1574
- // signal at registration. A live binding would need a Material
1575
- // reactive surface MatTabLink does not expose.
1576
- disabledState = signal(false, ...(ngDevMode ? [{ debugName: "disabledState" }] : /* istanbul ignore next */ []));
1577
1912
  ngOnInit() {
1578
- this.disabledState.set(this.matLink.disabled);
1579
1913
  const handle = {
1580
1914
  id: this.id(),
1581
1915
  label: this.label,
1582
1916
  subLabel: signal(undefined),
1583
- disabled: this.disabledState.asReadonly(),
1917
+ disabled: this.disabled,
1584
1918
  errorAggregator: this.errorAggregator,
1585
1919
  hasError: this.hasError,
1586
1920
  errorMessage: this.errorMessage,
1587
1921
  closable: signal(undefined),
1588
1922
  };
1589
1923
  this.host.register(handle);
1590
- this.destroyRef.onDestroy(() => this.host.unregister(handle.id));
1924
+ this.destroyRef.onDestroy(() => this.host.unregister(handle.id, handle));
1591
1925
  }
1592
1926
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabLink, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1593
- 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 });
1594
1928
  }
1595
1929
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabLink, decorators: [{
1596
1930
  type: Directive,
@@ -1599,7 +1933,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1599
1933
  exportAs: 'cngxMatTabLink',
1600
1934
  standalone: true,
1601
1935
  }]
1602
- }], 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
+ }
1603
1958
 
1604
1959
  /**
1605
1960
  * Per-tab error-aggregator binding for `[cngxMatTabs]`. Attach to a
@@ -1630,11 +1985,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1630
1985
  * @relatedTo CngxMatTabs, CngxMatTabsRegistry, CngxMatTabRejectionContent
1631
1986
  */
1632
1987
  class CngxMatTabError {
1633
- matTab = inject(MatTab, { self: true });
1634
- registry = inject(CNGX_MAT_TABS_REGISTRY_HOST, {
1635
- host: true,
1636
- });
1637
- presenter = inject(CNGX_TAB_GROUP_HOST);
1988
+ target = injectMatTabErrorTarget('cngxMatTabError');
1638
1989
  destroyRef = inject(DestroyRef);
1639
1990
  aggregator = input(undefined, { ...(ngDevMode ? { debugName: "aggregator" } : /* istanbul ignore next */ {}), alias: 'cngxMatTabError',
1640
1991
  transform: (value) => (typeof value === 'string' ? undefined : value) });
@@ -1651,14 +2002,14 @@ class CngxMatTabError {
1651
2002
  // the effect re-fires once our `MatTab` is registered. The bare
1652
2003
  // read is intentional; full rationale lives in the effect's
1653
2004
  // opening comment above. Do NOT tag as dead code.
1654
- this.presenter.tabs();
2005
+ this.target.presenter.tabs();
1655
2006
  untracked(() => {
1656
- const setup = this.registry.getHandleSetup(this.matTab);
2007
+ const setup = this.target.registry.getHandleSetup(this.target.matTab);
1657
2008
  setup?.errorAggregator.set(aggregator);
1658
2009
  });
1659
2010
  });
1660
2011
  this.destroyRef.onDestroy(() => {
1661
- const setup = this.registry.getHandleSetup(this.matTab);
2012
+ const setup = this.target.registry.getHandleSetup(this.target.matTab);
1662
2013
  setup?.errorAggregator.set(undefined);
1663
2014
  });
1664
2015
  }
@@ -1680,7 +2031,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1680
2031
  * `string | boolean` writes the per-handle `directError` slot, which
1681
2032
  * folds into the handle's `hasError` / `errorMessage`. A non-empty
1682
2033
  * string doubles as the SR descriptor message; `true` marks the tab
1683
- * 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.
1684
2039
  *
1685
2040
  * Symmetric with `[cngxMatTabError]` (one directive, one
1686
2041
  * responsibility - Pillar 3): the aggregator stays the rich
@@ -1700,11 +2055,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1700
2055
  * @relatedTo CngxMatTabs, CngxMatTabError, CngxMatTabsRegistry
1701
2056
  */
1702
2057
  class CngxMatTabErrorFlag {
1703
- matTab = inject(MatTab, { self: true });
1704
- registry = inject(CNGX_MAT_TABS_REGISTRY_HOST, {
1705
- host: true,
1706
- });
1707
- presenter = inject(CNGX_TAB_GROUP_HOST);
2058
+ target = injectMatTabErrorTarget('cngxMatTabErrorFlag');
1708
2059
  destroyRef = inject(DestroyRef);
1709
2060
  error = input(false, { ...(ngDevMode ? { debugName: "error" } : /* istanbul ignore next */ {}), alias: 'cngxMatTabErrorFlag',
1710
2061
  transform: (value) => (value === '' ? true : value) });
@@ -1716,14 +2067,14 @@ class CngxMatTabErrorFlag {
1716
2067
  // effect once our handle is registered. `untracked` around the
1717
2068
  // write keeps the slot pump out of the reactive graph.
1718
2069
  const error = this.error();
1719
- this.presenter.tabs();
2070
+ this.target.presenter.tabs();
1720
2071
  untracked(() => {
1721
- const setup = this.registry.getHandleSetup(this.matTab);
2072
+ const setup = this.target.registry.getHandleSetup(this.target.matTab);
1722
2073
  setup?.directError.set(error);
1723
2074
  });
1724
2075
  });
1725
2076
  this.destroyRef.onDestroy(() => {
1726
- const setup = this.registry.getHandleSetup(this.matTab);
2077
+ const setup = this.target.registry.getHandleSetup(this.target.matTab);
1727
2078
  setup?.directError.set(false);
1728
2079
  });
1729
2080
  }
@@ -1749,5 +2100,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1749
2100
  * Generated bundle index. Do not edit.
1750
2101
  */
1751
2102
 
1752
- export { CNGX_MAT_TABS_CONFIG, CNGX_MAT_TABS_REGISTRY_HOST, CNGX_MAT_TAB_HANDLE_FACTORY, CngxMatTabAggregatorContent, CngxMatTabError, CngxMatTabErrorFlag, CngxMatTabLink, CngxMatTabNav, CngxMatTabRejectionContent, CngxMatTabs, CngxMatTabsRegistry, MaterialPrivateSurfaces, createCngxMatTabOverflowDomAdapter, createMatTabHandle, injectMatTabsConfig, provideMatTabsConfig, provideMatTabsConfigAt, withAnchorRetryAttempts, withHalfWiredSlotSink };
2103
+ export { CNGX_MAT_TABS_CONFIG, CNGX_MAT_TABS_CONFIG_DEFAULTS, CNGX_MAT_TABS_REGISTRY_HOST, CNGX_MAT_TAB_HANDLE_FACTORY, CngxMatTabAggregatorContent, CngxMatTabError, CngxMatTabErrorFlag, CngxMatTabLink, CngxMatTabNav, CngxMatTabRejectionContent, CngxMatTabs, CngxMatTabsRegistry, MaterialPrivateSurfaces, createCngxMatTabOverflowDomAdapter, createMatTabHandle, createOrderedRegistrationSeam, injectMatTabsConfig, mountLiveRegionAnnouncer, provideMatTabsConfig, provideMatTabsConfigAt, withAnchorRetryAttempts, withHalfWiredSlotSink, withMatTabRejectionTemplate };
1753
2104
  //# sourceMappingURL=cngx-ui-mat-tabs.mjs.map