@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.
package/stepper/README.md CHANGED
@@ -70,6 +70,30 @@ Per-instance override:
70
70
 
71
71
  Under 480px viewports the classic strip auto-collapses to `<cngx-text-stepper>` (default) or `<cngx-dot-stepper>`. Configure via `withStepperMobileCollapse('text' | 'dots' | 'off')`.
72
72
 
73
+ ## Density
74
+
75
+ `density` controls how the horizontal strip reacts to a narrow container. It defaults to `'comfortable'` (full labels, unchanged); `'auto'` arms a continuous, container-query-driven label budget.
76
+
77
+ ```ts
78
+ import { provideStepperConfig, withStepperDensity } from '@cngx/common/stepper';
79
+
80
+ bootstrapApplication(AppComponent, {
81
+ providers: [provideStepperConfig(withStepperDensity('auto'))],
82
+ });
83
+ ```
84
+
85
+ Under `'auto'` labels keep their full width as long as the strip has room; they only give way when it would otherwise overflow. Each step's shrink priority grows with its distance from the active step, so the furthest labels truncate first and the nearest stay readable longest. The active step has the lowest priority of all, so its label stays fully readable while the strip has room and only yields once its neighbours have collapsed to number-only. Because nothing is capped below the available width, space freed by a collapsed label is reused rather than left empty, and the strip clips instead of growing a horizontal scrollbar. The relayout is animated when the active step changes (`prefers-reduced-motion` short-circuits it); a resize reflows continuously without animation. Collapsed labels stay in the accessibility tree (clipped, never removed), so every step button keeps its accessible name. Each skin keeps its own treatment: skins with a numbered disc keep it visible as the label collapses; the fill-the-width tile skins (`path-chevron`, `pill-segment`) keep filling the strip but truncate progressively too; label-only skins with no number (`chips`, `breadcrumb`, `path-chevron`) truncate to a small readable stub.
86
+
87
+ Tune the model with custom properties:
88
+
89
+ | Property | Default | Effect |
90
+ |-|-|-|
91
+ | `--cngx-step-shrink-weight` | `20` | How strongly distance from the active step raises a non-active step's shrink priority. Larger keeps the active label full longer at the neighbours' expense. |
92
+ | `--cngx-step-active-label-max` | `60cqi` | Maximum active-label width (container units), so a long active label cannot squeeze the sequence out and the strip reflow on navigation stays bounded. |
93
+ | `--cngx-step-active-label-min` | `4rem` | Guaranteed minimum label width for the active step. |
94
+ | `--cngx-step-collapsed-min` | `3.25rem` | Minimum step width - the floor a collapsing step shrinks to, wide enough to keep its indicator. |
95
+ | `--cngx-step-collapsed-label-min` | `2ch` | Minimum label stub for non-active steps on label-only skins. |
96
+
73
97
  ## Progress-Bar Stepper
74
98
 
75
99
  `CngxProgressBarStepper` renders the active step ratio as a determinate `<cngx-progress>` bar. Thin Level-4 organism composing `CngxStepperPresenter` via `hostDirectives` plus the embedded `CngxProgress` primitive - no reinvented `<div role="progressbar">`. Material consumers inherit Material progress palette automatically via `@cngx/themes/material/feedback-theme`.
@@ -172,3 +196,77 @@ onSwipe(direction: SwipeDirection): void {
172
196
  Keyboard navigation (arrow keys, Home / End) is built into the indicator and needs no wiring; swipe is the touch counterpart you add yourself.
173
197
 
174
198
  **Caveat:** only wire swipe onto panels that are genuinely paged content (onboarding, galleries). Do not make a panel that holds real form fields swipe-navigable - a horizontal drag while editing inputs is ambiguous and fights native gestures. For form wizards, keep explicit Back / Next controls.
199
+
200
+ ## Header navigation
201
+
202
+ `headerNavigation` decides whether the step headers are controls or pure indicators. It is a two-value policy - `'none'` or `'visited'` - that folds into the existing `linear` axis instead of adding a third mode.
203
+
204
+ |Value|Headers|Reachability|
205
+ |-|-|-|
206
+ |`'none'`|Inert labels (no button, no roving, no click). The footer is the only navigation.|n/a - headers never navigate|
207
+ |`'visited'` (default)|Focusable buttons|Gated by `linear`|
208
+
209
+ With `'visited'`, the `linear` flag does the rest:
210
+
211
+ - `linear="false"` (the default): every enabled header is clickable - free navigation, the old behaviour.
212
+ - `linear="true"`: only already-visited (completed) steps are reachable; forward-incomplete headers carry `aria-disabled="true"` and stay focusable so the gate is announced, not a silent no-op.
213
+
214
+ There is no separate `'free'` value - "free" is just `headerNavigation="visited"` with `linear="false"`.
215
+
216
+ ```html
217
+ <!-- Footer-only wizard: headers are read-only indicators. -->
218
+ <cngx-stepper headerNavigation="none" [linear]="true" aria-label="Checkout">
219
+ <div cngxStep label="Cart"></div>
220
+ <div cngxStep label="Address"></div>
221
+ <div cngxStep label="Payment"></div>
222
+ <cngx-stepper-footer>
223
+ <button cngxStepperFooterStart cngxStepperPrevious>Back</button>
224
+ <button cngxStepperFooterEnd cngxStepperNext>Continue</button>
225
+ </cngx-stepper-footer>
226
+ </cngx-stepper>
227
+ ```
228
+
229
+ Set the app-wide default with `provideStepperConfig(withStepperHeaderNavigation('none'))`; the per-instance `[headerNavigation]` input wins over it.
230
+
231
+ While a commit is in flight (`commitAction` pending), the `'visited'` headers lock - they go `aria-disabled`, click and arrow-key navigation no-op - so the strip cannot supersede the pending transition. This matches the footer nav atoms (`cngxStepperPrevious` / `cngxStepperNext`), which disable on `busy()` too; the strip and the footer lock together during an async step.
232
+
233
+ ### Migration
234
+
235
+ The default is `'visited'`. For non-linear steppers (`linear="false"`, the default) this is identical to previous behaviour - every header stays clickable. **Linear steppers change:** headers that used to be clickable-but-blocked are now marked `aria-disabled` and only visited steps are reachable. If you relied on always-clickable headers under `linear="true"`, set `[linear]="false"` (or keep `headerNavigation="visited"` and gate completion yourself).
236
+
237
+ ## Error channels
238
+
239
+ A step can be flagged as in error through two independent channels. Both render the same error **state** on every skin (the indicator / badge / tile turns errored); the error **message** surfaces separately.
240
+
241
+ |Channel|How you flag it|Where the message appears|
242
+ |-|-|-|
243
+ |Validation|`[error]="true \| 'message'"` on `cngxStep`, or `[errorAggregator]` for multi-source forms|a row **below the strip** (every classic-style skin) via `*cngxStepError`; folded into the aggregate line on the `text` / `dot` / `progress-bar` mini variants|
244
+ |Commit / async|a `commitAction` that rejects (sets `lastFailedIndex`)|`*cngxStepRejection` decoration; `CngxToastOn` / `CngxBannerOn` transition bridges|
245
+
246
+ The message lives on its own row **below** the step strip, not inside a step. That is deliberate: a free-text message inside a horizontal (or column) strip item widens the shrink-to-fit step and tears the row; below the strip it has full width and wraps. The strip itself only ever carries the short state cue.
247
+
248
+ Only steps with a **real reason** show a message row - the bare `errored` state is already communicated by the indicator / badge, so a boolean `[error]="true"` adds no text-only noise. A reason is the direct `[error]` string or the first `errorAggregator` label.
249
+
250
+ The validation channel is the common case and needs no async machine. The simplest form is a single input:
251
+
252
+ ```html
253
+ <cngx-stepper aria-label="Payment">
254
+ <div cngxStep label="Card" [error]="cardInvalid() ? 'Card declined' : false"></div>
255
+ <div cngxStep label="Review"></div>
256
+ </cngx-stepper>
257
+ ```
258
+
259
+ `[error]="true"` puts the step in the error state (red indicator, no message); `[error]="'Card declined'"` does the same and supplies the message rendered below the strip. A string wins over an aggregator label, which wins over the i18n `errored` status word. No `<fieldset cngxErrorAggregator>` / `<input cngxErrorSource>` scaffolding is required to flag "this step is invalid" - the `errorAggregator` stays the path for genuine multi-source aggregation (per-source keys, labels, SR announcement).
260
+
261
+ Override the message presentation per instance with `*cngxStepError`, app-wide with `withStepErrorTemplate(...)`:
262
+
263
+ ```html
264
+ <cngx-stepper aria-label="Payment">
265
+ <div cngxStep label="Card" [error]="cardError()"></div>
266
+ <ng-template cngxStepError let-message="message">
267
+ <strong>{{ message }}</strong>
268
+ </ng-template>
269
+ </cngx-stepper>
270
+ ```
271
+
272
+ The commit / async channel is separate: a rejected `commitAction` decorates the rolled-back step (`*cngxStepRejection`) and flows its message through the `CngxToastOn` / `CngxBannerOn` transition bridges. The two channels never collide - validation owns `*cngxStepError`, commit owns `*cngxStepRejection`.
package/tabs/README.md CHANGED
@@ -22,6 +22,24 @@ Two pieces give the tab strip its character:
22
22
  - **Commit lifecycle.** Activating a tab can fire an async action. In optimistic mode the tab becomes active immediately and rolls back on error; in pessimistic mode it stays inactive until success. Per-tab busy and error markers ride the same channel.
23
23
  - **Overflow.** When tabs do not fit, the overflowing ones collapse into a "more" menu. Recompute is debounced through an `IntersectionObserver` so resize storms do not thrash the layout.
24
24
 
25
+ ## Skins
26
+
27
+ `[skin]` picks the visual treatment; it maps to a `[data-skin]` host attribute that selects a CSS scope. Structure, slots, ARIA, and keyboard behaviour are identical across every value - only the paint changes. Orthogonal to `[orientation]` (horizontal/vertical) and `[iconLayout]`.
28
+
29
+ |Skin|Look|
30
+ |-|-|
31
+ |`line`|Default. Primary underline ink-bar under the active tab.|
32
+ |`contained`|Square folder tabs; the active tab fuses with the panel into one box and carries a primary accent bar on its leading edge.|
33
+ |`segmented`|Tabs share a muted track; the active tab lifts onto a raised surface.|
34
+ |`pill`|Rounded solid fills; the active pill takes the primary fill.|
35
+ |`pill-outline`|Same pill shape, but the active tab is a tinted, outlined chip.|
36
+
37
+ ```html
38
+ <cngx-tab-group skin="segmented" orientation="vertical"> ... </cngx-tab-group>
39
+ ```
40
+
41
+ Set an app-wide default with `withTabsSkin()` (via `provideCngxTabs`). Colours and sizes are CSS custom properties (`--cngx-tab-*`) that chain to `--mat-sys-*` when a Material theme is present.
42
+
25
43
  ## Companion entries
26
44
 
27
45
  - **`@cngx/common/tabs`** - the headless brain, configuration cascade, slot directives.
@@ -1,127 +1,78 @@
1
- import * as i1 from '@cngx/common/stepper';
2
- import { CngxStepPanelHost, CngxStepNode, CngxStepLabelContext, CngxStepContentContext, CngxStepRegistration } from '@cngx/common/stepper';
1
+ import * as _cngx_common_stepper from '@cngx/common/stepper';
2
+ import { CngxStepRegistration } from '@cngx/common/stepper';
3
3
  import * as i0 from '@angular/core';
4
- import { Signal, TemplateRef, InjectionToken } from '@angular/core';
5
- import { MatStepper, MatStep } from '@angular/material/stepper';
4
+ import { InjectionToken } from '@angular/core';
5
+ import { MatStep } from '@angular/material/stepper';
6
6
 
7
7
  /**
8
- * Material-twin stepper organism. Wraps `<mat-stepper>` and shares
9
- * the `CngxStepperPresenter` brain with `<cngx-stepper>` - Material
10
- * consumers gain the commit-action lifecycle, router sync, and error
11
- * aggregation.
12
- *
13
- * Bidirectional sync between presenter and `MatStepper.selectedIndex`
14
- * runs in a single `effect()` with `untracked()` writes so neither
15
- * direction tracks the other.
16
- *
17
- * Material owns keyboard nav and focus on `MatStepperHeader`, so the
18
- * organism does NOT compose `CngxRovingTabindex` /
19
- * `CngxFocusRestore`. Group nodes flatten - `<mat-stepper>` does not
20
- * support nesting - with the depth preserved as a `data-step-depth`
21
- * hint on the rendered label.
22
- *
23
- * @playground Bridge instrumentation ./examples/bridge/bridge-example.component.ts
24
- *
25
- * @category ui/mat-stepper
26
- * @docsKind primary
27
- * @wcag AA
28
- * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-stepper/mat-stepper.component.ts
29
- * @since 0.1.0
30
- * @relatedTo CngxMatStepperBridge, CngxStepperPresenter, CngxStep
31
- * <example-url>http://localhost:4200/#/ui/stepper/stepper-footer/mat-stepper-footer</example-url>
32
- */
33
- declare class CngxMatStepper implements CngxStepPanelHost {
34
- protected readonly presenter: i1.CngxStepperHost;
35
- private readonly destroyRef;
36
- private readonly injector;
37
- protected readonly matStepper: Signal<MatStepper>;
38
- private readonly hostCdr;
39
- readonly flatSteps: Signal<readonly CngxStepNode[]>;
40
- readonly activeStepIndex: Signal<number>;
41
- readonly activeStepId: Signal<string | null>;
42
- private readonly stepDirectives;
43
- /**
44
- * Consumer-projected `<ng-template matStepperIcon>` templates,
45
- * forwarded into `MatStepper._iconOverrides` from the
46
- * `afterNextRender` patch below. `<ng-content>` projection cannot
47
- * reach Material's `@ContentChildren(MatStepperIcon)` - content-init
48
- * resolves the inner query before the wrapper's projection lands.
49
- * `_iconOverrides` is a Material-internal slot.
50
- */
51
- private readonly stepperIcons;
52
- /**
53
- * `Map<id, CngxStep>` so `labelTemplateFor` / `contentTemplateFor`
54
- * are O(1). Structural `equal` on the id-set + per-id directive
55
- * identity stops the map from cascading on shape-stable
56
- * `contentChildren` re-emits.
57
- */
58
- private readonly stepDirectiveById;
59
- /**
60
- * Step-only flat projection - `<mat-step>` does not nest, so
61
- * groups collapse into the same level. Memoised via
62
- * `flatStepsEqual` so consumers (`stepLabel`, panel `@for`,
63
- * `stepLabelContextFor`) don't re-walk on shape-stable
64
- * `flatSteps()` re-emits. Sibling-symmetric with
65
- * `CngxStepper.stepsOnly`.
66
- */
67
- protected readonly stepsOnly: Signal<readonly CngxStepNode[]>;
68
- /** Material orientation literal - narrows our `'horizontal'|'vertical'` to its own union. */
69
- protected readonly matOrientation: Signal<"horizontal" | "vertical">;
70
- protected stepIndexOf(node: CngxStepNode): number;
71
- /** Editability rule - non-linear lets every step click; linear only past completed. */
72
- protected isEditable(node: CngxStepNode): boolean;
73
- protected hasError(node: CngxStepNode): boolean;
74
- protected isCompleted(node: CngxStepNode): boolean;
75
- protected stepLabel(node: CngxStepNode): string;
76
- /** Group nodes carry a depth marker so the label can distinguish nested rows. */
77
- protected stepDepth(node: CngxStepNode): number;
78
- labelTemplateFor(id: string): TemplateRef<CngxStepLabelContext> | null;
79
- contentTemplateFor(id: string): TemplateRef<CngxStepContentContext> | null;
80
- /**
81
- * Per-node-id slot-context cache for `*cngxStepLabel` /
82
- * `*cngxStepContent`. Mutating fields in place preserves the
83
- * object reference, so `*ngTemplateOutlet`'s `Object.is` diff
84
- * short-circuits the embedded-view rebind; the embedded view's
85
- * `let-` bindings re-read the mutated fields on the next CD pass.
86
- * Stale ids are pruned by the constructor effect tied to
87
- * `presenter.flatSteps`.
88
- */
89
- private readonly stepLabelContextCache;
90
- /** Build the {@link CngxStepLabelContext} for the projected label template. */
91
- protected stepLabelContextFor(node: CngxStepNode): CngxStepLabelContext;
92
- /** Build the {@link CngxStepContentContext} for the projected content template. */
93
- protected stepContentContextFor(node: CngxStepNode): CngxStepContentContext;
94
- constructor();
95
- static ɵfac: i0.ɵɵFactoryDeclaration<CngxMatStepper, never>;
96
- static ɵcmp: i0.ɵɵComponentDeclaration<CngxMatStepper, "cngx-mat-stepper", ["cngxMatStepper"], {}, {}, ["stepDirectives", "stepperIcons"], ["cngx-stepper-footer, [cngxStepperFooter]"], true, [{ directive: typeof i1.CngxStepperPresenter; inputs: { "activeStepIndex": "activeStepIndex"; "linear": "linear"; "orientation": "orientation"; "commitAction": "commitAction"; "commitMode": "commitMode"; }; outputs: { "activeStepIndexChange": "activeStepIndexChange"; }; }]>;
97
- }
98
-
99
- /**
100
- * Attaches to an existing `<mat-stepper>` and bridges it to a
101
- * {@link CngxStepperPresenter} - consumers gain the commit-action
8
+ * The Material twin of the CNGX stepper: attach `cngxMatStepper` to a
9
+ * vanilla `<mat-stepper>` and it is bridged to a
10
+ * {@link CngxStepperPresenter}. \
11
+ * Consumers gain the commit-action
102
12
  * lifecycle, `CNGX_STATEFUL` (so `<cngx-toast-on />` /
103
- * `<cngx-banner-on />` compose as children), and the step-handle
104
- * registry from one attribute.
13
+ * `<cngx-banner-on />` compose as children), the shared
14
+ * `CNGX_STEPPER_HOST` contract (so a `<cngx-stepper-footer>` can drive
15
+ * Back / Next instead of Material's own buttons via
16
+ * `[host]="ref.presenter"`), and the step-handle registry - all from
17
+ * one attribute.
105
18
  *
106
- * Sibling-additive to `<cngx-mat-stepper>` (the thin-wrapper
107
- * organism in `@cngx/ui/mat-stepper`): the wrapper authors fresh
108
- * markup, this directive upgrades existing Material markup.
109
- * `exportAs` differs (`cngxMatStepperDirective`) to avoid colliding
110
- * with the wrapper's `cngxMatStepper`.
19
+ * This is the instrumentation pattern: Material owns the rendering and
20
+ * the consumer authors native `<mat-step>` markup; CNGX is the
21
+ * behaviour layer. Topology mirrors `[cngxMatTabs]`.
111
22
  *
112
- * Topology mirrors `[cngxMatTabs]`: Material is the host, cngx is
113
- * the instrumentation layer.
23
+ * Inputs/outputs are forwarded from {@link CngxStepperPresenter}:
24
+ * - `activeStepIndex` (two-way, with `activeStepIndexChange`),
25
+ * - `linear`,
26
+ * - `orientation`,
27
+ * - `commitAction`,
28
+ * - `commitMode`. \
29
+ * See the presenter for their semantics.
30
+ * ```html
31
+ * <mat-stepper
32
+ * cngxMatStepper
33
+ * #s="cngxMatStepper"
34
+ * [(activeStepIndex)]="active"
35
+ * [commitAction]="commitAction"
36
+ * [commitMode]="mode()"
37
+ * cngxToastOn
38
+ * [toastError]="'Step transition failed'"
39
+ * cngxBannerOn
40
+ * bannerId="stepper:commit-error"
41
+ * [bannerError]="'The server rejected the step change.'"
42
+ * aria-label="Account setup"
43
+ * >
44
+ * <mat-step label="Personal info">
45
+ * <p>Tell us who you are.</p>
46
+ * </mat-step>
47
+ * <mat-step
48
+ * label="Account"
49
+ * [hasError]="!accepted()"
50
+ * errorMessage="Accept the terms to continue"
51
+ * >
52
+ * <p>Choose your sign-in method.</p>
53
+ * </mat-step>
54
+ * <mat-step label="Confirm">
55
+ * <p>Review everything, then finish.</p>
56
+ * </mat-step>
57
+ * </mat-stepper>
58
+ * ```
59
+ * @playground Bridge instrumentation ./examples/bridge/bridge-example.component.ts
114
60
  *
115
61
  * @category ui/mat-stepper
116
62
  * @docsKind primary
117
63
  * @wcag AA
118
64
  * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-stepper/mat-stepper.directive.ts
119
65
  * @since 0.1.0
120
- * @relatedTo CngxMatStepper, CngxStepperPresenter, CngxMatTabs
66
+ * @relatedTo CngxStepper, CngxStepperPresenter, CngxMatTabs, CngxStepperFooter
121
67
  */
122
- declare class CngxMatStepperBridge {
68
+ declare class CngxMatStepper {
123
69
  private readonly matStepper;
124
- private readonly presenter;
70
+ /**
71
+ * Shared host contract. Public so a `<cngx-stepper-footer>` placed
72
+ * outside the `<mat-stepper>` can bind `[host]="ref.presenter"` (via
73
+ * `#ref="cngxMatStepper"`) and drive navigation.
74
+ */
75
+ readonly presenter: _cngx_common_stepper.CngxStepperHost;
125
76
  private readonly destroyRef;
126
77
  private readonly injector;
127
78
  private readonly matSteps;
@@ -129,8 +80,8 @@ declare class CngxMatStepperBridge {
129
80
  private readonly createHandle;
130
81
  constructor();
131
82
  private syncHandles;
132
- static ɵfac: i0.ɵɵFactoryDeclaration<CngxMatStepperBridge, never>;
133
- static ɵdir: i0.ɵɵDirectiveDeclaration<CngxMatStepperBridge, "[cngxMatStepper]", ["cngxMatStepperDirective"], {}, {}, ["matSteps"], never, true, [{ directive: typeof i1.CngxStepperPresenter; inputs: { "activeStepIndex": "activeStepIndex"; "linear": "linear"; "orientation": "orientation"; "commitAction": "commitAction"; "commitMode": "commitMode"; }; outputs: { "activeStepIndexChange": "activeStepIndexChange"; }; }]>;
83
+ static ɵfac: i0.ɵɵFactoryDeclaration<CngxMatStepper, never>;
84
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CngxMatStepper, "[cngxMatStepper]", ["cngxMatStepper"], {}, {}, ["matSteps"], never, true, [{ directive: typeof _cngx_common_stepper.CngxStepperPresenter; inputs: { "activeStepIndex": "activeStepIndex"; "linear": "linear"; "orientation": "orientation"; "commitAction": "commitAction"; "commitMode": "commitMode"; }; outputs: { "activeStepIndexChange": "activeStepIndexChange"; }; }]>;
134
85
  }
135
86
 
136
87
  /**
@@ -245,5 +196,5 @@ type CngxMatStepHandleFactory = typeof createMatStepHandle;
245
196
  */
246
197
  declare const CNGX_MAT_STEP_HANDLE_FACTORY: InjectionToken<typeof createMatStepHandle>;
247
198
 
248
- export { CNGX_MAT_STEP_HANDLE_FACTORY, CngxMatStepper, CngxMatStepperBridge, createMatStepHandle };
199
+ export { CNGX_MAT_STEP_HANDLE_FACTORY, CngxMatStepper, createMatStepHandle };
249
200
  export type { CngxMatStepHandleFactory };
@@ -1,7 +1,7 @@
1
- import * as _cngx_common_tabs from '@cngx/common/tabs';
1
+ import * as i1 from '@cngx/common/tabs';
2
2
  import { CngxTabHandle, CngxTabOverflowDomAdapter } from '@cngx/common/tabs';
3
3
  import * as i0 from '@angular/core';
4
- import { Signal, WritableSignal, InjectionToken, Injector, TemplateRef, EnvironmentProviders, Provider } from '@angular/core';
4
+ import { Signal, WritableSignal, InjectionToken, Injector, OnInit, TemplateRef, EnvironmentProviders, Provider } from '@angular/core';
5
5
  import { MatTab } from '@angular/material/tabs';
6
6
  import { CngxErrorAggregatorContract } from '@cngx/common/interactive';
7
7
  import { MatStepperIconContext } from '@angular/material/stepper';
@@ -21,6 +21,12 @@ interface CngxMatTabHandleSetup {
21
21
  /** Convenience mirror of `handle.disabled`. */
22
22
  readonly disabled: Signal<boolean>;
23
23
  readonly errorAggregator: WritableSignal<CngxErrorAggregatorContract | undefined>;
24
+ /**
25
+ * Direct invalid flag the `[cngxMatTabErrorFlag]` directive writes -
26
+ * `string | boolean`, mirroring `CngxTab.error`. Folds into the
27
+ * handle's `hasError` / `errorMessage` alongside the aggregator.
28
+ */
29
+ readonly directError: WritableSignal<string | boolean>;
24
30
  }
25
31
  /**
26
32
  * Translates a Material `MatTab` into a cngx {@link CngxTabHandle}
@@ -38,6 +44,9 @@ interface CngxMatTabHandleSetup {
38
44
  * `[cngxMatTabError]` writes its bound aggregator in and resets
39
45
  * on teardown. The handle exposes `.asReadonly()` to preserve the
40
46
  * `CngxTabHandle` contract.
47
+ * - `directError` - writable seeded at `false`;
48
+ * `[cngxMatTabErrorFlag]` writes its `string | boolean` value in
49
+ * and resets on teardown. Folds into `hasError` / `errorMessage`.
41
50
  *
42
51
  * @category ui/mat-tabs
43
52
  */
@@ -96,14 +105,14 @@ declare const CNGX_MAT_TAB_HANDLE_FACTORY: InjectionToken<typeof createMatTabHan
96
105
  */
97
106
  interface CngxMatTabsRegistryHost {
98
107
  /**
99
- * Returns the per-handle `errorAggregator` slot, or `undefined`
100
- * before the tab is registered. The `contentChildren(MatTab)`
101
- * query lands during content-init, so a same-microtask injection
102
- * from an attribute directive can race; consumers recover by
103
- * tracking `presenter.tabs()` and re-attempting on the next sync
104
- * tick.
108
+ * Returns the per-handle writable slots (`errorAggregator`,
109
+ * `directError`), or `undefined` before the tab is registered. The
110
+ * `contentChildren(MatTab)` query lands during content-init, so a
111
+ * same-microtask injection from an attribute directive can race;
112
+ * consumers recover by tracking `presenter.tabs()` and re-attempting
113
+ * on the next sync tick.
105
114
  */
106
- getHandleSetup(matTab: MatTab): Pick<CngxMatTabHandleSetup, 'errorAggregator'> | undefined;
115
+ getHandleSetup(matTab: MatTab): Pick<CngxMatTabHandleSetup, 'errorAggregator' | 'directError'> | undefined;
107
116
  }
108
117
  /**
109
118
  * DI token the {@link CngxMatTabsRegistry} directive provides via
@@ -148,7 +157,7 @@ declare class CngxMatTabsRegistry implements CngxMatTabsRegistryHost {
148
157
  private readonly matTabs;
149
158
  private readonly setupsByTab;
150
159
  constructor();
151
- getHandleSetup(matTab: MatTab): Pick<CngxMatTabHandleSetup, 'errorAggregator'> | undefined;
160
+ getHandleSetup(matTab: MatTab): Pick<CngxMatTabHandleSetup, 'errorAggregator' | 'directError'> | undefined;
152
161
  private syncHandles;
153
162
  static ɵfac: i0.ɵɵFactoryDeclaration<CngxMatTabsRegistry, never>;
154
163
  static ɵdir: i0.ɵɵDirectiveDeclaration<CngxMatTabsRegistry, "[cngxMatTabsRegistry]", ["cngxMatTabsRegistry"], {}, {}, ["matTabs"], never, true, never>;
@@ -178,7 +187,7 @@ declare class CngxMatTabsRegistry implements CngxMatTabsRegistryHost {
178
187
  * @wcag AA
179
188
  * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tabs.directive.ts
180
189
  * @since 0.1.0
181
- * @relatedTo CngxMatTabsRegistry, CngxMatTabError, CngxMatStepperBridge
190
+ * @relatedTo CngxMatTabsRegistry, CngxMatTabError, CngxMatStepper
182
191
  */
183
192
  declare class CngxMatTabs {
184
193
  private readonly matTabGroup;
@@ -206,7 +215,121 @@ declare class CngxMatTabs {
206
215
  */
207
216
  clearLastFailed(): void;
208
217
  static ɵfac: i0.ɵɵFactoryDeclaration<CngxMatTabs, never>;
209
- static ɵdir: i0.ɵɵDirectiveDeclaration<CngxMatTabs, "[cngxMatTabs]", ["cngxMatTabs"], {}, {}, ["aggregatorContentSlot", "rejectionContentSlot"], never, true, [{ directive: typeof _cngx_common_tabs.CngxTabGroupPresenter; inputs: { "activeIndex": "activeIndex"; "orientation": "orientation"; "loop": "loop"; "commitAction": "commitAction"; "commitMode": "commitMode"; }; outputs: { "activeIndexChange": "activeIndexChange"; }; }, { directive: typeof CngxMatTabsRegistry; inputs: {}; outputs: {}; }]>;
218
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CngxMatTabs, "[cngxMatTabs]", ["cngxMatTabs"], {}, {}, ["aggregatorContentSlot", "rejectionContentSlot"], never, true, [{ directive: typeof i1.CngxTabGroupPresenter; inputs: { "activeIndex": "activeIndex"; "orientation": "orientation"; "loop": "loop"; "commitAction": "commitAction"; "commitMode": "commitMode"; }; outputs: { "activeIndexChange": "activeIndexChange"; }; }, { directive: typeof CngxMatTabsRegistry; inputs: {}; outputs: {}; }]>;
219
+ }
220
+
221
+ /**
222
+ * Layers the cngx error / rejection / announcement layer onto
223
+ * Material's native router tabs (`<nav mat-tab-nav-bar>` /
224
+ * `<a mat-tab-link>` / `<mat-tab-nav-panel>`). The parallel bridge to
225
+ * {@link CngxMatTabs}: `MatTabNav` has no `MatTab` and no
226
+ * `selectedIndex`, so handles register per `<a mat-tab-link>` via
227
+ * {@link CngxMatTabLink}, and the decoration projectors target
228
+ * `.mat-mdc-tab-link` instead of `.mat-mdc-tab`.
229
+ *
230
+ * Gating is **native**: each link is a `routerLink`, so the router runs
231
+ * `CanDeactivate` directly and this directive installs no
232
+ * commit-action. The active index follows the route - add
233
+ * `[cngxTabsRouteSync]` to the same `<nav>` and give each
234
+ * `[cngxMatTabLink]` an `id` matching its route segment; route-sync
235
+ * reflects `NavigationEnd` onto `activeIndex` (its commit-action stays
236
+ * dormant because link clicks navigate natively, never through
237
+ * `presenter.select`). Ableitung statt Verwaltung - the route-active
238
+ * link is the single source of the active index.
239
+ *
240
+ * Composes {@link CngxTabGroupPresenter} via `hostDirectives` so the
241
+ * `CNGX_STATEFUL` producer, the `lastFailedIndex` rejection slot, and
242
+ * the live-region announcer come for free, identical to the cngx
243
+ * organism (Pillar 2 - same communication across skins).
244
+ *
245
+ * Decoration content-template slots (`*cngxMatTabRejectionContent` /
246
+ * `*cngxMatTabAggregatorContent`) are not forwarded on this bridge yet -
247
+ * the projectors render their built-in `cngx-sr-only` spans. The slot
248
+ * inputs that `[cngxMatTabs]` exposes are a deferred follow-up.
249
+ *
250
+ * @playground Native router tabs with a CanDeactivate guard ./examples/router-nav/router-nav.component.ts
251
+ *
252
+ * @category ui/mat-tabs
253
+ * @docsKind primary
254
+ * @wcag AA
255
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tab-nav.directive.ts
256
+ * @since 0.1.0
257
+ * @relatedTo CngxMatTabLink, CngxMatTabs, CngxTabsRouteSync
258
+ */
259
+ declare class CngxMatTabNav {
260
+ private readonly presenter;
261
+ private readonly destroyRef;
262
+ private readonly injector;
263
+ private readonly renderer;
264
+ private readonly hostEl;
265
+ private readonly i18n;
266
+ private readonly failedHandleId;
267
+ private readonly rejectionState;
268
+ private readonly aggregatedErrorTabs;
269
+ constructor();
270
+ /**
271
+ * Clears `presenter.lastFailedIndex`, dismissing the rejection
272
+ * decoration. Mirrors {@link CngxMatTabs.clearLastFailed} so a
273
+ * template ref (`#nav="cngxMatTabNav"`) is enough.
274
+ */
275
+ clearLastFailed(): void;
276
+ static ɵfac: i0.ɵɵFactoryDeclaration<CngxMatTabNav, never>;
277
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CngxMatTabNav, "[cngxMatTabNav]", ["cngxMatTabNav"], {}, {}, never, never, true, [{ directive: typeof i1.CngxTabGroupPresenter; inputs: {}; outputs: {}; }]>;
278
+ }
279
+
280
+ /**
281
+ * Registers an `<a mat-tab-link>` anchor as a {@link CngxTabHandle}
282
+ * with the enclosing {@link CngxMatTabNav} presenter. `mat-tab-nav-bar`
283
+ * has no `MatTab` to hang a handle on (the links are the tabs), so this
284
+ * per-link directive is the registration seam - symmetric with how
285
+ * `CngxTab` registers in the cngx-native path and how
286
+ * {@link CngxMatTabsRegistry} registers each `<mat-tab>`.
287
+ *
288
+ * Registration order follows DOM order (Angular instantiates content
289
+ * directives top-to-bottom), so the presenter's `tabs()` index aligns
290
+ * with `nav.querySelectorAll('.mat-mdc-tab-link')` - the index the
291
+ * decoration projectors correlate against.
292
+ *
293
+ * Gating is native: the link's `routerLink` runs `CanDeactivate`
294
+ * directly, so this directive installs no commit-action. The active
295
+ * index follows the route through `[cngxTabsRouteSync]` on the nav,
296
+ * which matches each handle's `id` (set to the route segment) against
297
+ * the URL.
298
+ *
299
+ * @category ui/mat-tabs
300
+ * @docsKind primary
301
+ * @wcag AA
302
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tab-link.directive.ts
303
+ * @since 0.1.0
304
+ * @relatedTo CngxMatTabNav, CngxMatTabs, CngxTab
305
+ */
306
+ declare class CngxMatTabLink implements OnInit {
307
+ private readonly matLink;
308
+ private readonly host;
309
+ private readonly destroyRef;
310
+ /**
311
+ * Handle id. Set it to the link's route segment so the nav's
312
+ * `[cngxTabsRouteSync]` reflects the active route onto this tab via
313
+ * the default `(h) => [h.id]` mapping. Defaults to a fresh uid when
314
+ * route-sync is not used.
315
+ */
316
+ readonly id: i0.InputSignal<string>;
317
+ /** Accessible label fed to the live-region announcer. */
318
+ readonly label: i0.InputSignal<string | undefined>;
319
+ /**
320
+ * Direct error flag for the link - `true` or a non-empty string marks
321
+ * it invalid (the string doubles as the message). Mirrors
322
+ * `CngxTab.error` and `[cngxMatTabErrorFlag]`.
323
+ */
324
+ readonly error: i0.InputSignal<string | boolean>;
325
+ /** Optional rich error aggregator for the link. */
326
+ readonly errorAggregator: i0.InputSignal<CngxErrorAggregatorContract | undefined>;
327
+ private readonly errorMessage;
328
+ private readonly hasError;
329
+ private readonly disabledState;
330
+ ngOnInit(): void;
331
+ static ɵfac: i0.ɵɵFactoryDeclaration<CngxMatTabLink, never>;
332
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CngxMatTabLink, "[cngxMatTabLink]", ["cngxMatTabLink"], { "id": { "alias": "id"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "error": { "alias": "error"; "required": false; "isSignal": true; }; "errorAggregator": { "alias": "errorAggregator"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
210
333
  }
211
334
 
212
335
  /**
@@ -248,6 +371,42 @@ declare class CngxMatTabError {
248
371
  static ɵdir: i0.ɵɵDirectiveDeclaration<CngxMatTabError, "[cngxMatTabError]", ["cngxMatTabError"], { "aggregator": { "alias": "cngxMatTabError"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
249
372
  }
250
373
 
374
+ /**
375
+ * Per-tab direct invalid flag for `[cngxMatTabs]` - the simple-case
376
+ * sibling to `[cngxMatTabError]`. Attach to a `<mat-tab>`; the bound
377
+ * `string | boolean` writes the per-handle `directError` slot, which
378
+ * folds into the handle's `hasError` / `errorMessage`. A non-empty
379
+ * string doubles as the SR descriptor message; `true` marks the tab
380
+ * invalid with no message; `false` / `''` clear it.
381
+ *
382
+ * Symmetric with `[cngxMatTabError]` (one directive, one
383
+ * responsibility - Pillar 3): the aggregator stays the rich
384
+ * multi-source path, this is the "this tab is invalid" marker that
385
+ * needs no aggregator boilerplate. A bare `cngxMatTabErrorFlag`
386
+ * attribute (no brackets) binds the empty string and is coerced to
387
+ * `true` so presence alone marks the tab invalid.
388
+ *
389
+ * Locates its target via {@link CNGX_MAT_TABS_REGISTRY_HOST}, tracks
390
+ * `presenter.tabs()` to recover from the content-init race, and
391
+ * clears the slot on destroy - exactly as {@link CngxMatTabError}.
392
+ *
393
+ * @category ui/mat-tabs
394
+ * @wcag AA
395
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/mat-tab-error-flag.directive.ts
396
+ * @since 0.1.0
397
+ * @relatedTo CngxMatTabs, CngxMatTabError, CngxMatTabsRegistry
398
+ */
399
+ declare class CngxMatTabErrorFlag {
400
+ private readonly matTab;
401
+ private readonly registry;
402
+ private readonly presenter;
403
+ private readonly destroyRef;
404
+ readonly error: i0.InputSignalWithTransform<string | boolean, string | boolean>;
405
+ constructor();
406
+ static ɵfac: i0.ɵɵFactoryDeclaration<CngxMatTabErrorFlag, never>;
407
+ static ɵdir: i0.ɵɵDirectiveDeclaration<CngxMatTabErrorFlag, "[cngxMatTabErrorFlag]", ["cngxMatTabErrorFlag"], { "error": { "alias": "cngxMatTabErrorFlag"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
408
+ }
409
+
251
410
  /**
252
411
  * Context passed to the `*cngxMatTabAggregatorContent` template.
253
412
  * Drives the SR-descriptor content rendered inside the
@@ -707,8 +866,11 @@ declare namespace MaterialPrivateSurfaces {
707
866
  * ```
708
867
  *
709
868
  * @category ui/mat-tabs
869
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-tabs/overflow/mat-tab-overflow-dom-adapter.ts
870
+ * @since 0.1.0
871
+ * @relatedTo CngxTabOverflow, CngxMatTabs, CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY
710
872
  */
711
873
  declare function createCngxMatTabOverflowDomAdapter(): CngxTabOverflowDomAdapter;
712
874
 
713
- 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 };
875
+ 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 };
714
876
  export type { CngxMatTabAggregatorContentContext, CngxMatTabHalfWiredSlotSink, CngxMatTabHandleFactory, CngxMatTabRejectionContentContext, CngxMatTabsConfig, CngxMatTabsConfigFeature, CngxMatTabsRegistryHost };