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

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
  /**
@@ -1036,6 +1117,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1036
1117
  * ```
1037
1118
  *
1038
1119
  * @category ui/mat-tabs
1120
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/overflow/mat-tab-overflow-dom-adapter.ts
1121
+ * @since 0.1.0
1122
+ * @relatedTo CngxTabOverflow, CngxMatTabs, CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY
1039
1123
  */
1040
1124
  function createCngxMatTabOverflowDomAdapter() {
1041
1125
  return {
@@ -1112,7 +1196,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1112
1196
  * @wcag AA
1113
1197
  * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tabs.directive.ts
1114
1198
  * @since 0.1.0
1115
- * @relatedTo CngxMatTabsRegistry, CngxMatTabError, CngxMatStepperBridge
1199
+ * @relatedTo CngxMatTabsRegistry, CngxMatTabError, CngxMatStepper
1116
1200
  */
1117
1201
  class CngxMatTabs {
1118
1202
  matTabGroup = inject(MatTabGroup, { self: true });
@@ -1154,41 +1238,10 @@ class CngxMatTabs {
1154
1238
  // Bundle shares one source-walk across descriptorText / originLabel
1155
1239
  // / liveAnnouncement - pillar-2 phrasing parity with cngx-native.
1156
1240
  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
- } });
1241
+ // Shared with `[cngxMatTabNav]` - one body, two hosts (Pillar 3).
1242
+ // Structural equal lives in the factory so the projector doesn't
1243
+ // churn on no-op aggregator re-emissions.
1244
+ aggregatedErrorTabs = createAggregatedErrorTabs(this.presenter);
1192
1245
  constructor() {
1193
1246
  const matTabsConfig = injectMatTabsConfig();
1194
1247
  // Polite live region - attribute directive owns no template, so
@@ -1263,7 +1316,7 @@ class CngxMatTabs {
1263
1316
  });
1264
1317
  afterNextRender(() => anchorRetry.start());
1265
1318
  this.destroyRef.onDestroy(() => anchorRetry.cancel());
1266
- createMaterialBidirectionalSync({
1319
+ const sync = createMaterialBidirectionalSync({
1267
1320
  presenterIndex: this.presenter.activeIndex,
1268
1321
  readSelectedIndex: () => this.matTabGroup.selectedIndex ?? 0,
1269
1322
  writeSelectedIndex: (i) => {
@@ -1274,6 +1327,20 @@ class CngxMatTabs {
1274
1327
  injector: this.injector,
1275
1328
  destroyRef: this.destroyRef,
1276
1329
  });
1330
+ // Routed (pessimistic) gate: a rejected switch holds `activeIndex` at
1331
+ // origin, so the presenter to Material mirror never fires and Material
1332
+ // stays eager-advanced on the refused tab. Snap it back when the
1333
+ // commit settles into an error. `status()` always transitions through
1334
+ // `pending` first, so the `error` edge is observed even when the
1335
+ // router cancels a microtask after `navigate()`.
1336
+ effect(() => {
1337
+ const status = this.presenter.commitState.status();
1338
+ untracked(() => {
1339
+ if (status === 'error') {
1340
+ sync.reconcile();
1341
+ }
1342
+ });
1343
+ });
1277
1344
  }
1278
1345
  /**
1279
1346
  * Clears `presenter.lastFailedIndex`, dismissing the rejection
@@ -1346,6 +1413,200 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1346
1413
  }]
1347
1414
  }], ctorParameters: () => [], propDecorators: { aggregatorContentSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxMatTabAggregatorContent), { isSignal: true }] }], rejectionContentSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxMatTabRejectionContent), { isSignal: true }] }] } });
1348
1415
 
1416
+ /**
1417
+ * Layers the cngx error / rejection / announcement layer onto
1418
+ * Material's native router tabs (`<nav mat-tab-nav-bar>` /
1419
+ * `<a mat-tab-link>` / `<mat-tab-nav-panel>`). The parallel bridge to
1420
+ * {@link CngxMatTabs}: `MatTabNav` has no `MatTab` and no
1421
+ * `selectedIndex`, so handles register per `<a mat-tab-link>` via
1422
+ * {@link CngxMatTabLink}, and the decoration projectors target
1423
+ * `.mat-mdc-tab-link` instead of `.mat-mdc-tab`.
1424
+ *
1425
+ * Gating is **native**: each link is a `routerLink`, so the router runs
1426
+ * `CanDeactivate` directly and this directive installs no
1427
+ * commit-action. The active index follows the route - add
1428
+ * `[cngxTabsRouteSync]` to the same `<nav>` and give each
1429
+ * `[cngxMatTabLink]` an `id` matching its route segment; route-sync
1430
+ * reflects `NavigationEnd` onto `activeIndex` (its commit-action stays
1431
+ * dormant because link clicks navigate natively, never through
1432
+ * `presenter.select`). Ableitung statt Verwaltung - the route-active
1433
+ * link is the single source of the active index.
1434
+ *
1435
+ * Composes {@link CngxTabGroupPresenter} via `hostDirectives` so the
1436
+ * `CNGX_STATEFUL` producer, the `lastFailedIndex` rejection slot, and
1437
+ * the live-region announcer come for free, identical to the cngx
1438
+ * organism (Pillar 2 - same communication across skins).
1439
+ *
1440
+ * Decoration content-template slots (`*cngxMatTabRejectionContent` /
1441
+ * `*cngxMatTabAggregatorContent`) are not forwarded on this bridge yet -
1442
+ * the projectors render their built-in `cngx-sr-only` spans. The slot
1443
+ * inputs that `[cngxMatTabs]` exposes are a deferred follow-up.
1444
+ *
1445
+ * @playground Native router tabs with a CanDeactivate guard ./examples/router-nav/router-nav.component.ts
1446
+ *
1447
+ * @category ui/mat-tabs
1448
+ * @docsKind primary
1449
+ * @wcag AA
1450
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tab-nav.directive.ts
1451
+ * @since 0.1.0
1452
+ * @relatedTo CngxMatTabLink, CngxMatTabs, CngxTabsRouteSync
1453
+ */
1454
+ class CngxMatTabNav {
1455
+ presenter = inject(CNGX_TAB_GROUP_HOST);
1456
+ destroyRef = inject(DestroyRef);
1457
+ injector = inject(Injector);
1458
+ renderer = inject(Renderer2);
1459
+ hostEl = inject(ElementRef).nativeElement;
1460
+ i18n = injectTabsI18n();
1461
+ // Stable id of the rejected link, or null. Identity equal collapses
1462
+ // tabs() re-emits that don't change the failed-target id.
1463
+ failedHandleId = computed(() => {
1464
+ const idx = this.presenter.lastFailedIndex();
1465
+ if (idx === undefined) {
1466
+ return null;
1467
+ }
1468
+ return this.presenter.tabs()[idx]?.id ?? null;
1469
+ }, ...(ngDevMode ? [{ debugName: "failedHandleId" }] : /* istanbul ignore next */ []));
1470
+ rejectionState = createRejectionState(this.presenter, this.i18n);
1471
+ aggregatedErrorTabs = createAggregatedErrorTabs(this.presenter);
1472
+ constructor() {
1473
+ mountLiveRegionAnnouncer({
1474
+ announcement: this.rejectionState.liveAnnouncement,
1475
+ renderer: this.renderer,
1476
+ injector: this.injector,
1477
+ destroyRef: this.destroyRef,
1478
+ });
1479
+ // Same projector bodies as `[cngxMatTabs]`; only the per-tab element
1480
+ // selector differs (`.mat-mdc-tab-link` vs `.mat-mdc-tab`).
1481
+ createMatTabRejectionDecoration({
1482
+ hostEl: this.hostEl,
1483
+ failedHandleId: this.failedHandleId,
1484
+ failedIndex: this.presenter.lastFailedIndex,
1485
+ descriptorText: this.rejectionState.descriptorText,
1486
+ renderer: this.renderer,
1487
+ injector: this.injector,
1488
+ destroyRef: this.destroyRef,
1489
+ originLabel: this.rejectionState.originLabel,
1490
+ buttonSelector: '.mat-mdc-tab-link',
1491
+ });
1492
+ createMatTabAggregatorDecoration({
1493
+ hostEl: this.hostEl,
1494
+ errorTabs: this.aggregatedErrorTabs,
1495
+ renderer: this.renderer,
1496
+ injector: this.injector,
1497
+ destroyRef: this.destroyRef,
1498
+ buttonSelector: '.mat-mdc-tab-link',
1499
+ });
1500
+ }
1501
+ /**
1502
+ * Clears `presenter.lastFailedIndex`, dismissing the rejection
1503
+ * decoration. Mirrors {@link CngxMatTabs.clearLastFailed} so a
1504
+ * template ref (`#nav="cngxMatTabNav"`) is enough.
1505
+ */
1506
+ clearLastFailed() {
1507
+ this.presenter.clearLastFailed();
1508
+ }
1509
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabNav, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1510
+ 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 });
1511
+ }
1512
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabNav, decorators: [{
1513
+ type: Directive,
1514
+ args: [{
1515
+ selector: '[cngxMatTabNav]',
1516
+ exportAs: 'cngxMatTabNav',
1517
+ standalone: true,
1518
+ hostDirectives: [CngxTabGroupPresenter],
1519
+ }]
1520
+ }], ctorParameters: () => [] });
1521
+
1522
+ /**
1523
+ * Registers an `<a mat-tab-link>` anchor as a {@link CngxTabHandle}
1524
+ * with the enclosing {@link CngxMatTabNav} presenter. `mat-tab-nav-bar`
1525
+ * has no `MatTab` to hang a handle on (the links are the tabs), so this
1526
+ * per-link directive is the registration seam - symmetric with how
1527
+ * `CngxTab` registers in the cngx-native path and how
1528
+ * {@link CngxMatTabsRegistry} registers each `<mat-tab>`.
1529
+ *
1530
+ * Registration order follows DOM order (Angular instantiates content
1531
+ * directives top-to-bottom), so the presenter's `tabs()` index aligns
1532
+ * with `nav.querySelectorAll('.mat-mdc-tab-link')` - the index the
1533
+ * decoration projectors correlate against.
1534
+ *
1535
+ * Gating is native: the link's `routerLink` runs `CanDeactivate`
1536
+ * directly, so this directive installs no commit-action. The active
1537
+ * index follows the route through `[cngxTabsRouteSync]` on the nav,
1538
+ * which matches each handle's `id` (set to the route segment) against
1539
+ * the URL.
1540
+ *
1541
+ * @category ui/mat-tabs
1542
+ * @docsKind primary
1543
+ * @wcag AA
1544
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tab-link.directive.ts
1545
+ * @since 0.1.0
1546
+ * @relatedTo CngxMatTabNav, CngxMatTabs, CngxTab
1547
+ */
1548
+ class CngxMatTabLink {
1549
+ matLink = inject(MatTabLink, { self: true });
1550
+ host = inject(CNGX_TAB_GROUP_HOST);
1551
+ destroyRef = inject(DestroyRef);
1552
+ /**
1553
+ * Handle id. Set it to the link's route segment so the nav's
1554
+ * `[cngxTabsRouteSync]` reflects the active route onto this tab via
1555
+ * the default `(h) => [h.id]` mapping. Defaults to a fresh uid when
1556
+ * route-sync is not used.
1557
+ */
1558
+ id = input(nextUid('cngx-mat-tab-link-'), ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
1559
+ /** Accessible label fed to the live-region announcer. */
1560
+ label = input(undefined, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
1561
+ /**
1562
+ * Direct error flag for the link - `true` or a non-empty string marks
1563
+ * it invalid (the string doubles as the message). Mirrors
1564
+ * `CngxTab.error` and `[cngxMatTabErrorFlag]`.
1565
+ */
1566
+ error = input(false, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
1567
+ /** Optional rich error aggregator for the link. */
1568
+ errorAggregator = input(undefined, ...(ngDevMode ? [{ debugName: "errorAggregator" }] : /* istanbul ignore next */ []));
1569
+ errorMessage = computed(() => {
1570
+ const value = this.error();
1571
+ return typeof value === 'string' && value !== '' ? value : undefined;
1572
+ }, ...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
1573
+ hasError = computed(() => {
1574
+ const direct = this.error();
1575
+ return ((direct !== false && direct !== '') ||
1576
+ (this.errorAggregator()?.shouldShow?.() ?? false));
1577
+ }, { ...(ngDevMode ? { debugName: "hasError" } : /* istanbul ignore next */ {}), equal: Object.is });
1578
+ // Material's MatTabLink.disabled is a plain property, not a signal;
1579
+ // nav links rarely toggle disabled at runtime, so snapshot it onto a
1580
+ // signal at registration. A live binding would need a Material
1581
+ // reactive surface MatTabLink does not expose.
1582
+ disabledState = signal(false, ...(ngDevMode ? [{ debugName: "disabledState" }] : /* istanbul ignore next */ []));
1583
+ ngOnInit() {
1584
+ this.disabledState.set(this.matLink.disabled);
1585
+ const handle = {
1586
+ id: this.id(),
1587
+ label: this.label,
1588
+ subLabel: signal(undefined),
1589
+ disabled: this.disabledState.asReadonly(),
1590
+ errorAggregator: this.errorAggregator,
1591
+ hasError: this.hasError,
1592
+ errorMessage: this.errorMessage,
1593
+ closable: signal(undefined),
1594
+ };
1595
+ this.host.register(handle);
1596
+ this.destroyRef.onDestroy(() => this.host.unregister(handle.id));
1597
+ }
1598
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabLink, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1599
+ 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 });
1600
+ }
1601
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabLink, decorators: [{
1602
+ type: Directive,
1603
+ args: [{
1604
+ selector: '[cngxMatTabLink]',
1605
+ exportAs: 'cngxMatTabLink',
1606
+ standalone: true,
1607
+ }]
1608
+ }], 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 }] }] } });
1609
+
1349
1610
  /**
1350
1611
  * Per-tab error-aggregator binding for `[cngxMatTabs]`. Attach to a
1351
1612
  * `<mat-tab>`; the bound aggregator's `shouldShow()` projects onto
@@ -1419,6 +1680,71 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1419
1680
  }]
1420
1681
  }], ctorParameters: () => [], propDecorators: { aggregator: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxMatTabError", required: false }] }] } });
1421
1682
 
1683
+ /**
1684
+ * Per-tab direct invalid flag for `[cngxMatTabs]` - the simple-case
1685
+ * sibling to `[cngxMatTabError]`. Attach to a `<mat-tab>`; the bound
1686
+ * `string | boolean` writes the per-handle `directError` slot, which
1687
+ * folds into the handle's `hasError` / `errorMessage`. A non-empty
1688
+ * string doubles as the SR descriptor message; `true` marks the tab
1689
+ * invalid with no message; `false` / `''` clear it.
1690
+ *
1691
+ * Symmetric with `[cngxMatTabError]` (one directive, one
1692
+ * responsibility - Pillar 3): the aggregator stays the rich
1693
+ * multi-source path, this is the "this tab is invalid" marker that
1694
+ * needs no aggregator boilerplate. A bare `cngxMatTabErrorFlag`
1695
+ * attribute (no brackets) binds the empty string and is coerced to
1696
+ * `true` so presence alone marks the tab invalid.
1697
+ *
1698
+ * Locates its target via {@link CNGX_MAT_TABS_REGISTRY_HOST}, tracks
1699
+ * `presenter.tabs()` to recover from the content-init race, and
1700
+ * clears the slot on destroy - exactly as {@link CngxMatTabError}.
1701
+ *
1702
+ * @category ui/mat-tabs
1703
+ * @wcag AA
1704
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tab-error-flag.directive.ts
1705
+ * @since 0.1.0
1706
+ * @relatedTo CngxMatTabs, CngxMatTabError, CngxMatTabsRegistry
1707
+ */
1708
+ class CngxMatTabErrorFlag {
1709
+ matTab = inject(MatTab, { self: true });
1710
+ registry = inject(CNGX_MAT_TABS_REGISTRY_HOST, {
1711
+ host: true,
1712
+ });
1713
+ presenter = inject(CNGX_TAB_GROUP_HOST);
1714
+ destroyRef = inject(DestroyRef);
1715
+ error = input(false, { ...(ngDevMode ? { debugName: "error" } : /* istanbul ignore next */ {}), alias: 'cngxMatTabErrorFlag',
1716
+ transform: (value) => (value === '' ? true : value) });
1717
+ constructor() {
1718
+ effect(() => {
1719
+ // Same content-init race as `[cngxMatTabError]` - the registry's
1720
+ // `contentChildren(MatTab)` query and our injection land in the
1721
+ // same microtask, so tracking `presenter.tabs()` re-fires the
1722
+ // effect once our handle is registered. `untracked` around the
1723
+ // write keeps the slot pump out of the reactive graph.
1724
+ const error = this.error();
1725
+ this.presenter.tabs();
1726
+ untracked(() => {
1727
+ const setup = this.registry.getHandleSetup(this.matTab);
1728
+ setup?.directError.set(error);
1729
+ });
1730
+ });
1731
+ this.destroyRef.onDestroy(() => {
1732
+ const setup = this.registry.getHandleSetup(this.matTab);
1733
+ setup?.directError.set(false);
1734
+ });
1735
+ }
1736
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabErrorFlag, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1737
+ 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 });
1738
+ }
1739
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatTabErrorFlag, decorators: [{
1740
+ type: Directive,
1741
+ args: [{
1742
+ selector: '[cngxMatTabErrorFlag]',
1743
+ exportAs: 'cngxMatTabErrorFlag',
1744
+ standalone: true,
1745
+ }]
1746
+ }], ctorParameters: () => [], propDecorators: { error: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxMatTabErrorFlag", required: false }] }] } });
1747
+
1422
1748
  /**
1423
1749
  * @module @cngx/ui/mat-tabs
1424
1750
  *
@@ -1429,5 +1755,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1429
1755
  * Generated bundle index. Do not edit.
1430
1756
  */
1431
1757
 
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 };
1758
+ 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
1759
  //# sourceMappingURL=cngx-ui-mat-tabs.mjs.map