@cngx/ui 0.1.0-rc.0 → 0.1.0-rc.1

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.
@@ -1,6 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
- import { runInInjectionContext, effect, untracked, afterNextRender, isDevMode, InjectionToken, makeEnvironmentProviders, inject, TemplateRef, Directive, computed, signal, DestroyRef, EnvironmentInjector, contentChildren, createEnvironmentInjector, Injectable, Injector, Renderer2, ElementRef, ViewContainerRef, contentChild, input } from '@angular/core';
3
- import { MatTab, MatTabGroup } from '@angular/material/tabs';
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
4
  import { createMaterialBidirectionalSync } from '@cngx/common/data';
5
5
  import * as i1 from '@cngx/common/tabs';
6
6
  import { CNGX_TAB_GROUP_HOST, injectTabsI18n, CNGX_DOM_ANCHOR_RETRY_FACTORY, CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY, CNGX_TAB_PANEL_HOST, CngxTabGroupPresenter } from '@cngx/common/tabs';
@@ -482,6 +482,55 @@ function defaultRetryCeilingWarn(max) {
482
482
  };
483
483
  }
484
484
 
485
+ /**
486
+ * Builds the reactive list of tabs whose bound error-aggregator wants
487
+ * reveal, in registration (DOM) order. Feeds
488
+ * {@link createMatTabAggregatorDecoration} for both the
489
+ * `[cngxMatTabs]` (`<mat-tab-group>`) and `[cngxMatTabNav]`
490
+ * (`<nav mat-tab-nav-bar>`) bridges - one body, two hosts (Pillar 3).
491
+ *
492
+ * Structural `equal` drops re-runs whose entry list is shape-identical
493
+ * so the projector does not churn on no-op aggregator re-emissions.
494
+ *
495
+ * @internal
496
+ */
497
+ function createAggregatedErrorTabs(presenter) {
498
+ return computed(() => {
499
+ const tabs = presenter.tabs();
500
+ const acc = [];
501
+ for (let i = 0; i < tabs.length; i++) {
502
+ 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
+ });
512
+ }
513
+ }
514
+ return acc;
515
+ }, {
516
+ equal: (a, b) => {
517
+ if (a.length !== b.length) {
518
+ return false;
519
+ }
520
+ for (let i = 0; i < a.length; i++) {
521
+ if (a[i].idx !== b[i].idx ||
522
+ a[i].id !== b[i].id ||
523
+ a[i].announcement !== b[i].announcement ||
524
+ a[i].count !== b[i].count ||
525
+ a[i].label !== b[i].label) {
526
+ return false;
527
+ }
528
+ }
529
+ return true;
530
+ },
531
+ });
532
+ }
533
+
485
534
  /**
486
535
  * Default sink — gated on dev-mode. Production callers see no
487
536
  * output; production telemetry lands only when a consumer overrides
@@ -827,6 +876,9 @@ function createRejectionState(presenter, i18n) {
827
876
  * `[cngxMatTabError]` writes its bound aggregator in and resets
828
877
  * on teardown. The handle exposes `.asReadonly()` to preserve the
829
878
  * `CngxTabHandle` contract.
879
+ * - `directError` - writable seeded at `false`;
880
+ * `[cngxMatTabErrorFlag]` writes its `string | boolean` value in
881
+ * and resets on teardown. Folds into `hasError` / `errorMessage`.
830
882
  *
831
883
  * @category ui/mat-tabs
832
884
  */
@@ -853,6 +905,30 @@ function createMatTabHandle(matTab, idSeed, injector) {
853
905
  return matTab.disabled;
854
906
  }, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
855
907
  const errorAggregator = signal(undefined, ...(ngDevMode ? [{ debugName: "errorAggregator" }] : /* istanbul ignore next */ []));
908
+ // Direct invalid flag written by `[cngxMatTabErrorFlag]` - the
909
+ // Material-side author surface mirroring `CngxTab.error`.
910
+ const directError = signal(false, ...(ngDevMode ? [{ debugName: "directError" }] : /* istanbul ignore next */ []));
911
+ // Folded error state for the widened `CngxTabHandle` contract. Direct
912
+ // flag OR the aggregator's reveal-gated `shouldShow()` (so deferred-
913
+ // reveal validation stays silent until revealed).
914
+ const hasError = computed(() => {
915
+ const direct = directError();
916
+ return (direct !== false && direct !== '') || (errorAggregator()?.shouldShow?.() ?? false);
917
+ }, { ...(ngDevMode ? { debugName: "hasError" } : /* istanbul ignore next */ {}), equal: Object.is });
918
+ // Resolved direct-error message: the flag string when non-empty, else
919
+ // `undefined`. The aggregator carries its own announcement separately.
920
+ const errorMessage = computed(() => {
921
+ const direct = directError();
922
+ return typeof direct === 'string' && direct !== '' ? direct : undefined;
923
+ }, ...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
924
+ // Material owns its own tab lifecycle - the cngx dismissable/addable
925
+ // affordances are native-only by design, so the Material handle pins
926
+ // `closable` to `undefined` (group-default, never a close button).
927
+ const closable = signal(undefined, ...(ngDevMode ? [{ debugName: "closable" }] : /* istanbul ignore next */ []));
928
+ // Material owns its tab-button chrome (no DOM seam for a stacked
929
+ // second line), so the bridge pins `subLabel` to `undefined` - same
930
+ // native-only staging as `closable`.
931
+ const subLabel = signal(undefined, ...(ngDevMode ? [{ debugName: "subLabel" }] : /* istanbul ignore next */ []));
856
932
  // `nextUid` is process-wide monotonic, so `${id}-errors` descriptor
857
933
  // ids stay unique across coexisting `[cngxMatTabs]` instances.
858
934
  const id = idSeed();
@@ -860,12 +936,17 @@ function createMatTabHandle(matTab, idSeed, injector) {
860
936
  handle: {
861
937
  id,
862
938
  label,
939
+ subLabel: subLabel.asReadonly(),
863
940
  disabled,
864
941
  errorAggregator: errorAggregator.asReadonly(),
942
+ hasError,
943
+ errorMessage,
944
+ closable: closable.asReadonly(),
865
945
  },
866
946
  label,
867
947
  disabled,
868
948
  errorAggregator,
949
+ directError,
869
950
  };
870
951
  }
871
952
  /**
@@ -1112,7 +1193,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1112
1193
  * @wcag AA
1113
1194
  * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tabs.directive.ts
1114
1195
  * @since 0.1.0
1115
- * @relatedTo CngxMatTabsRegistry, CngxMatTabError, CngxMatStepperBridge
1196
+ * @relatedTo CngxMatTabsRegistry, CngxMatTabError, CngxMatStepper
1116
1197
  */
1117
1198
  class CngxMatTabs {
1118
1199
  matTabGroup = inject(MatTabGroup, { self: true });
@@ -1154,41 +1235,10 @@ class CngxMatTabs {
1154
1235
  // Bundle shares one source-walk across descriptorText / originLabel
1155
1236
  // / liveAnnouncement - pillar-2 phrasing parity with cngx-native.
1156
1237
  rejectionState = createRejectionState(this.presenter, this.i18n);
1157
- // Structural equal - drops re-runs whose entry list is shape-
1158
- // identical so the projector doesn't churn on no-op aggregator
1159
- // re-emissions.
1160
- aggregatedErrorTabs = computed(() => {
1161
- const tabs = this.presenter.tabs();
1162
- const acc = [];
1163
- for (let i = 0; i < tabs.length; i++) {
1164
- const handle = tabs[i];
1165
- const aggregator = handle.errorAggregator();
1166
- if (aggregator?.shouldShow()) {
1167
- acc.push({
1168
- idx: i,
1169
- id: handle.id,
1170
- announcement: aggregator.announcement(),
1171
- count: aggregator.errorCount(),
1172
- label: handle.label() ?? '',
1173
- });
1174
- }
1175
- }
1176
- return acc;
1177
- }, { ...(ngDevMode ? { debugName: "aggregatedErrorTabs" } : /* istanbul ignore next */ {}), equal: (a, b) => {
1178
- if (a.length !== b.length) {
1179
- return false;
1180
- }
1181
- for (let i = 0; i < a.length; i++) {
1182
- if (a[i].idx !== b[i].idx ||
1183
- a[i].id !== b[i].id ||
1184
- a[i].announcement !== b[i].announcement ||
1185
- a[i].count !== b[i].count ||
1186
- a[i].label !== b[i].label) {
1187
- return false;
1188
- }
1189
- }
1190
- return true;
1191
- } });
1238
+ // Shared with `[cngxMatTabNav]` - one body, two hosts (Pillar 3).
1239
+ // Structural equal lives in the factory so the projector doesn't
1240
+ // churn on no-op aggregator re-emissions.
1241
+ aggregatedErrorTabs = createAggregatedErrorTabs(this.presenter);
1192
1242
  constructor() {
1193
1243
  const matTabsConfig = injectMatTabsConfig();
1194
1244
  // Polite live region - attribute directive owns no template, so
@@ -1346,6 +1396,198 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1346
1396
  }]
1347
1397
  }], ctorParameters: () => [], propDecorators: { aggregatorContentSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxMatTabAggregatorContent), { isSignal: true }] }], rejectionContentSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxMatTabRejectionContent), { isSignal: true }] }] } });
1348
1398
 
1399
+ /**
1400
+ * Layers the cngx error / rejection / announcement layer onto
1401
+ * Material's native router tabs (`<nav mat-tab-nav-bar>` /
1402
+ * `<a mat-tab-link>` / `<mat-tab-nav-panel>`). The parallel bridge to
1403
+ * {@link CngxMatTabs}: `MatTabNav` has no `MatTab` and no
1404
+ * `selectedIndex`, so handles register per `<a mat-tab-link>` via
1405
+ * {@link CngxMatTabLink}, and the decoration projectors target
1406
+ * `.mat-mdc-tab-link` instead of `.mat-mdc-tab`.
1407
+ *
1408
+ * Gating is **native**: each link is a `routerLink`, so the router runs
1409
+ * `CanDeactivate` directly and this directive installs no
1410
+ * commit-action. The active index follows the route - add
1411
+ * `[cngxTabsRouteSync]` to the same `<nav>` and give each
1412
+ * `[cngxMatTabLink]` an `id` matching its route segment; route-sync
1413
+ * reflects `NavigationEnd` onto `activeIndex` (its commit-action stays
1414
+ * dormant because link clicks navigate natively, never through
1415
+ * `presenter.select`). Ableitung statt Verwaltung - the route-active
1416
+ * link is the single source of the active index.
1417
+ *
1418
+ * Composes {@link CngxTabGroupPresenter} via `hostDirectives` so the
1419
+ * `CNGX_STATEFUL` producer, the `lastFailedIndex` rejection slot, and
1420
+ * the live-region announcer come for free, identical to the cngx
1421
+ * organism (Pillar 2 - same communication across skins).
1422
+ *
1423
+ * Decoration content-template slots (`*cngxMatTabRejectionContent` /
1424
+ * `*cngxMatTabAggregatorContent`) are not forwarded on this bridge yet -
1425
+ * the projectors render their built-in `cngx-sr-only` spans. The slot
1426
+ * inputs that `[cngxMatTabs]` exposes are a deferred follow-up.
1427
+ *
1428
+ * @category ui/mat-tabs
1429
+ * @docsKind primary
1430
+ * @wcag AA
1431
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tab-nav.directive.ts
1432
+ * @since 0.1.0
1433
+ * @relatedTo CngxMatTabLink, CngxMatTabs, CngxTabsRouteSync
1434
+ */
1435
+ class CngxMatTabNav {
1436
+ presenter = inject(CNGX_TAB_GROUP_HOST);
1437
+ destroyRef = inject(DestroyRef);
1438
+ injector = inject(Injector);
1439
+ renderer = inject(Renderer2);
1440
+ hostEl = inject(ElementRef).nativeElement;
1441
+ i18n = injectTabsI18n();
1442
+ // Stable id of the rejected link, or null. Identity equal collapses
1443
+ // tabs() re-emits that don't change the failed-target id.
1444
+ failedHandleId = computed(() => {
1445
+ const idx = this.presenter.lastFailedIndex();
1446
+ if (idx === undefined) {
1447
+ return null;
1448
+ }
1449
+ return this.presenter.tabs()[idx]?.id ?? null;
1450
+ }, ...(ngDevMode ? [{ debugName: "failedHandleId" }] : /* istanbul ignore next */ []));
1451
+ rejectionState = createRejectionState(this.presenter, this.i18n);
1452
+ aggregatedErrorTabs = createAggregatedErrorTabs(this.presenter);
1453
+ constructor() {
1454
+ mountLiveRegionAnnouncer({
1455
+ announcement: this.rejectionState.liveAnnouncement,
1456
+ renderer: this.renderer,
1457
+ injector: this.injector,
1458
+ destroyRef: this.destroyRef,
1459
+ });
1460
+ // Same projector bodies as `[cngxMatTabs]`; only the per-tab element
1461
+ // selector differs (`.mat-mdc-tab-link` vs `.mat-mdc-tab`).
1462
+ createMatTabRejectionDecoration({
1463
+ hostEl: this.hostEl,
1464
+ failedHandleId: this.failedHandleId,
1465
+ failedIndex: this.presenter.lastFailedIndex,
1466
+ descriptorText: this.rejectionState.descriptorText,
1467
+ renderer: this.renderer,
1468
+ injector: this.injector,
1469
+ destroyRef: this.destroyRef,
1470
+ originLabel: this.rejectionState.originLabel,
1471
+ buttonSelector: '.mat-mdc-tab-link',
1472
+ });
1473
+ createMatTabAggregatorDecoration({
1474
+ hostEl: this.hostEl,
1475
+ errorTabs: this.aggregatedErrorTabs,
1476
+ renderer: this.renderer,
1477
+ injector: this.injector,
1478
+ destroyRef: this.destroyRef,
1479
+ buttonSelector: '.mat-mdc-tab-link',
1480
+ });
1481
+ }
1482
+ /**
1483
+ * Clears `presenter.lastFailedIndex`, dismissing the rejection
1484
+ * decoration. Mirrors {@link CngxMatTabs.clearLastFailed} so a
1485
+ * template ref (`#nav="cngxMatTabNav"`) is enough.
1486
+ */
1487
+ clearLastFailed() {
1488
+ this.presenter.clearLastFailed();
1489
+ }
1490
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabNav, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1491
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxMatTabNav, isStandalone: true, selector: "[cngxMatTabNav]", exportAs: ["cngxMatTabNav"], hostDirectives: [{ directive: i1.CngxTabGroupPresenter }], ngImport: i0 });
1492
+ }
1493
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabNav, decorators: [{
1494
+ type: Directive,
1495
+ args: [{
1496
+ selector: '[cngxMatTabNav]',
1497
+ exportAs: 'cngxMatTabNav',
1498
+ standalone: true,
1499
+ hostDirectives: [CngxTabGroupPresenter],
1500
+ }]
1501
+ }], ctorParameters: () => [] });
1502
+
1503
+ /**
1504
+ * Registers an `<a mat-tab-link>` anchor as a {@link CngxTabHandle}
1505
+ * with the enclosing {@link CngxMatTabNav} presenter. `mat-tab-nav-bar`
1506
+ * has no `MatTab` to hang a handle on (the links are the tabs), so this
1507
+ * per-link directive is the registration seam - symmetric with how
1508
+ * `CngxTab` registers in the cngx-native path and how
1509
+ * {@link CngxMatTabsRegistry} registers each `<mat-tab>`.
1510
+ *
1511
+ * Registration order follows DOM order (Angular instantiates content
1512
+ * directives top-to-bottom), so the presenter's `tabs()` index aligns
1513
+ * with `nav.querySelectorAll('.mat-mdc-tab-link')` - the index the
1514
+ * decoration projectors correlate against.
1515
+ *
1516
+ * Gating is native: the link's `routerLink` runs `CanDeactivate`
1517
+ * directly, so this directive installs no commit-action. The active
1518
+ * index follows the route through `[cngxTabsRouteSync]` on the nav,
1519
+ * which matches each handle's `id` (set to the route segment) against
1520
+ * the URL.
1521
+ *
1522
+ * @category ui/mat-tabs
1523
+ * @docsKind primary
1524
+ * @wcag AA
1525
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tab-link.directive.ts
1526
+ * @since 0.1.0
1527
+ * @relatedTo CngxMatTabNav, CngxMatTabs, CngxTab
1528
+ */
1529
+ class CngxMatTabLink {
1530
+ matLink = inject(MatTabLink, { self: true });
1531
+ host = inject(CNGX_TAB_GROUP_HOST);
1532
+ destroyRef = inject(DestroyRef);
1533
+ /**
1534
+ * Handle id. Set it to the link's route segment so the nav's
1535
+ * `[cngxTabsRouteSync]` reflects the active route onto this tab via
1536
+ * the default `(h) => [h.id]` mapping. Defaults to a fresh uid when
1537
+ * route-sync is not used.
1538
+ */
1539
+ id = input(nextUid('cngx-mat-tab-link-'), ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
1540
+ /** Accessible label fed to the live-region announcer. */
1541
+ label = input(undefined, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
1542
+ /**
1543
+ * Direct error flag for the link - `true` or a non-empty string marks
1544
+ * it invalid (the string doubles as the message). Mirrors
1545
+ * `CngxTab.error` and `[cngxMatTabErrorFlag]`.
1546
+ */
1547
+ error = input(false, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
1548
+ /** Optional rich error aggregator for the link. */
1549
+ errorAggregator = input(undefined, ...(ngDevMode ? [{ debugName: "errorAggregator" }] : /* istanbul ignore next */ []));
1550
+ errorMessage = computed(() => {
1551
+ const value = this.error();
1552
+ return typeof value === 'string' && value !== '' ? value : undefined;
1553
+ }, ...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
1554
+ hasError = computed(() => {
1555
+ const direct = this.error();
1556
+ return ((direct !== false && direct !== '') ||
1557
+ (this.errorAggregator()?.shouldShow?.() ?? false));
1558
+ }, { ...(ngDevMode ? { debugName: "hasError" } : /* istanbul ignore next */ {}), equal: Object.is });
1559
+ // Material's MatTabLink.disabled is a plain property, not a signal;
1560
+ // nav links rarely toggle disabled at runtime, so snapshot it onto a
1561
+ // signal at registration. A live binding would need a Material
1562
+ // reactive surface MatTabLink does not expose.
1563
+ disabledState = signal(false, ...(ngDevMode ? [{ debugName: "disabledState" }] : /* istanbul ignore next */ []));
1564
+ ngOnInit() {
1565
+ this.disabledState.set(this.matLink.disabled);
1566
+ const handle = {
1567
+ id: this.id(),
1568
+ label: this.label,
1569
+ subLabel: signal(undefined),
1570
+ disabled: this.disabledState.asReadonly(),
1571
+ errorAggregator: this.errorAggregator,
1572
+ hasError: this.hasError,
1573
+ errorMessage: this.errorMessage,
1574
+ closable: signal(undefined),
1575
+ };
1576
+ this.host.register(handle);
1577
+ this.destroyRef.onDestroy(() => this.host.unregister(handle.id));
1578
+ }
1579
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabLink, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1580
+ 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 });
1581
+ }
1582
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabLink, decorators: [{
1583
+ type: Directive,
1584
+ args: [{
1585
+ selector: '[cngxMatTabLink]',
1586
+ exportAs: 'cngxMatTabLink',
1587
+ standalone: true,
1588
+ }]
1589
+ }], 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 }] }] } });
1590
+
1349
1591
  /**
1350
1592
  * Per-tab error-aggregator binding for `[cngxMatTabs]`. Attach to a
1351
1593
  * `<mat-tab>`; the bound aggregator's `shouldShow()` projects onto
@@ -1419,6 +1661,71 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1419
1661
  }]
1420
1662
  }], ctorParameters: () => [], propDecorators: { aggregator: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxMatTabError", required: false }] }] } });
1421
1663
 
1664
+ /**
1665
+ * Per-tab direct invalid flag for `[cngxMatTabs]` - the simple-case
1666
+ * sibling to `[cngxMatTabError]`. Attach to a `<mat-tab>`; the bound
1667
+ * `string | boolean` writes the per-handle `directError` slot, which
1668
+ * folds into the handle's `hasError` / `errorMessage`. A non-empty
1669
+ * string doubles as the SR descriptor message; `true` marks the tab
1670
+ * invalid with no message; `false` / `''` clear it.
1671
+ *
1672
+ * Symmetric with `[cngxMatTabError]` (one directive, one
1673
+ * responsibility - Pillar 3): the aggregator stays the rich
1674
+ * multi-source path, this is the "this tab is invalid" marker that
1675
+ * needs no aggregator boilerplate. A bare `cngxMatTabErrorFlag`
1676
+ * attribute (no brackets) binds the empty string and is coerced to
1677
+ * `true` so presence alone marks the tab invalid.
1678
+ *
1679
+ * Locates its target via {@link CNGX_MAT_TABS_REGISTRY_HOST}, tracks
1680
+ * `presenter.tabs()` to recover from the content-init race, and
1681
+ * clears the slot on destroy - exactly as {@link CngxMatTabError}.
1682
+ *
1683
+ * @category ui/mat-tabs
1684
+ * @wcag AA
1685
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tab-error-flag.directive.ts
1686
+ * @since 0.1.0
1687
+ * @relatedTo CngxMatTabs, CngxMatTabError, CngxMatTabsRegistry
1688
+ */
1689
+ class CngxMatTabErrorFlag {
1690
+ matTab = inject(MatTab, { self: true });
1691
+ registry = inject(CNGX_MAT_TABS_REGISTRY_HOST, {
1692
+ host: true,
1693
+ });
1694
+ presenter = inject(CNGX_TAB_GROUP_HOST);
1695
+ destroyRef = inject(DestroyRef);
1696
+ error = input(false, { ...(ngDevMode ? { debugName: "error" } : /* istanbul ignore next */ {}), alias: 'cngxMatTabErrorFlag',
1697
+ transform: (value) => (value === '' ? true : value) });
1698
+ constructor() {
1699
+ effect(() => {
1700
+ // Same content-init race as `[cngxMatTabError]` - the registry's
1701
+ // `contentChildren(MatTab)` query and our injection land in the
1702
+ // same microtask, so tracking `presenter.tabs()` re-fires the
1703
+ // effect once our handle is registered. `untracked` around the
1704
+ // write keeps the slot pump out of the reactive graph.
1705
+ const error = this.error();
1706
+ this.presenter.tabs();
1707
+ untracked(() => {
1708
+ const setup = this.registry.getHandleSetup(this.matTab);
1709
+ setup?.directError.set(error);
1710
+ });
1711
+ });
1712
+ this.destroyRef.onDestroy(() => {
1713
+ const setup = this.registry.getHandleSetup(this.matTab);
1714
+ setup?.directError.set(false);
1715
+ });
1716
+ }
1717
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabErrorFlag, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1718
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxMatTabErrorFlag, isStandalone: true, selector: "[cngxMatTabErrorFlag]", inputs: { error: { classPropertyName: "error", publicName: "cngxMatTabErrorFlag", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["cngxMatTabErrorFlag"], ngImport: i0 });
1719
+ }
1720
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabErrorFlag, decorators: [{
1721
+ type: Directive,
1722
+ args: [{
1723
+ selector: '[cngxMatTabErrorFlag]',
1724
+ exportAs: 'cngxMatTabErrorFlag',
1725
+ standalone: true,
1726
+ }]
1727
+ }], ctorParameters: () => [], propDecorators: { error: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxMatTabErrorFlag", required: false }] }] } });
1728
+
1422
1729
  /**
1423
1730
  * @module @cngx/ui/mat-tabs
1424
1731
  *
@@ -1429,5 +1736,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1429
1736
  * Generated bundle index. Do not edit.
1430
1737
  */
1431
1738
 
1432
- export { CNGX_MAT_TABS_CONFIG, CNGX_MAT_TABS_REGISTRY_HOST, CNGX_MAT_TAB_HANDLE_FACTORY, CngxMatTabAggregatorContent, CngxMatTabError, CngxMatTabRejectionContent, CngxMatTabs, CngxMatTabsRegistry, MaterialPrivateSurfaces, createCngxMatTabOverflowDomAdapter, createMatTabHandle, injectMatTabsConfig, provideMatTabsConfig, provideMatTabsConfigAt, withAnchorRetryAttempts, withHalfWiredSlotSink };
1739
+ 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 };
1433
1740
  //# sourceMappingURL=cngx-ui-mat-tabs.mjs.map