@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,27 +1,23 @@
1
- import * as i2 from '@angular/common';
2
- import { CommonModule } from '@angular/common';
3
1
  import * as i0 from '@angular/core';
4
- import { inject, DestroyRef, Injector, viewChild, ChangeDetectorRef, contentChildren, computed, effect, untracked, afterNextRender, ChangeDetectionStrategy, Component, signal, InjectionToken, Directive } from '@angular/core';
5
- import * as i3 from '@angular/material/stepper';
6
- import { MatStepper, MatStepperIcon, MatStepperModule, MatStep } from '@angular/material/stepper';
2
+ import { signal, computed, InjectionToken, inject, DestroyRef, Injector, contentChildren, effect, untracked, Directive } from '@angular/core';
3
+ import { MatStepper, MatStep } from '@angular/material/stepper';
7
4
  import * as i1 from '@cngx/common/stepper';
8
- import { CNGX_STEPPER_HOST, CngxStep, flatStepsEqual, CNGX_STEP_PANEL_HOST, CngxStepperPresenter } from '@cngx/common/stepper';
9
- import { createMaterialBidirectionalSync } from '@cngx/common/data';
10
- import { CNGX_DIRECTIVE_BY_ID_MAP_FACTORY } from '@cngx/common/tabs';
5
+ import { CNGX_STEPPER_HOST, CngxStepperPresenter } from '@cngx/common/stepper';
11
6
  import { nextUid } from '@cngx/core/utils';
7
+ import { createMaterialBidirectionalSync } from '@cngx/common/data';
12
8
 
13
9
  /**
14
10
  * Stepper-specific glue over {@link createMaterialBidirectionalSync}
15
11
  * (`@cngx/common/data`). Both `<cngx-mat-stepper>` (Component) and
16
12
  * `[cngxMatStepper]` (Directive) need to install the same
17
13
  * presenter↔Material `selectedIndex` sync; the option-mapping body
18
- * was identical at both call sites — same `presenterIndex`, same
14
+ * was identical at both call sites - same `presenterIndex`, same
19
15
  * `readSelectedIndex` / `writeSelectedIndex` shape, same
20
16
  * `selectedIndexChange.asObservable()` source, same
21
17
  * `onMaterialSelection` write-back. This helper is the single entry
22
18
  * point: each call site reduces to one line.
23
19
  *
24
- * Behaviour stays identical to the prior inline blocks — the helper
20
+ * Behaviour stays identical to the prior inline blocks - the helper
25
21
  * is a pure shape-adapter, no policy. The underlying generic factory
26
22
  * owns:
27
23
  * - presenter→Material `effect()` with read-equality guard.
@@ -30,6 +26,8 @@ import { nextUid } from '@cngx/core/utils';
30
26
  * handler advances `selectedIndex` synchronously before the
31
27
  * bidirectional sync sees the event).
32
28
  * - `destroyRef` cleanup of both directions.
29
+ *
30
+ * @internal
33
31
  */
34
32
  function createMatStepperBidirectionalSync(opts) {
35
33
  createMaterialBidirectionalSync({
@@ -38,7 +36,7 @@ function createMatStepperBidirectionalSync(opts) {
38
36
  writeSelectedIndex: (i) => {
39
37
  opts.matStepper.selectedIndex = i;
40
38
  },
41
- // `MatStepper.selectedIndexChange` emits a plain index — no adapter needed,
39
+ // `MatStepper.selectedIndexChange` emits a plain index - no adapter needed,
42
40
  // unlike `MatTabGroup.selectedIndexChange`.
43
41
  selectionChange$: opts.matStepper.selectedIndexChange.asObservable(),
44
42
  onMaterialSelection: (i) => opts.presenter.select(i),
@@ -47,202 +45,6 @@ function createMatStepperBidirectionalSync(opts) {
47
45
  });
48
46
  }
49
47
 
50
- /**
51
- * Material-twin stepper organism. Wraps `<mat-stepper>` and shares
52
- * the `CngxStepperPresenter` brain with `<cngx-stepper>` - Material
53
- * consumers gain the commit-action lifecycle, router sync, and error
54
- * aggregation.
55
- *
56
- * Bidirectional sync between presenter and `MatStepper.selectedIndex`
57
- * runs in a single `effect()` with `untracked()` writes so neither
58
- * direction tracks the other.
59
- *
60
- * Material owns keyboard nav and focus on `MatStepperHeader`, so the
61
- * organism does NOT compose `CngxRovingTabindex` /
62
- * `CngxFocusRestore`. Group nodes flatten - `<mat-stepper>` does not
63
- * support nesting - with the depth preserved as a `data-step-depth`
64
- * hint on the rendered label.
65
- *
66
- * @playground Bridge instrumentation ./examples/bridge/bridge-example.component.ts
67
- *
68
- * @category ui/mat-stepper
69
- * @docsKind primary
70
- * @wcag AA
71
- * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-stepper/mat-stepper.component.ts
72
- * @since 0.1.0
73
- * @relatedTo CngxMatStepperBridge, CngxStepperPresenter, CngxStep
74
- * <example-url>http://localhost:4200/#/ui/stepper/stepper-footer/mat-stepper-footer</example-url>
75
- */
76
- class CngxMatStepper {
77
- presenter = inject(CNGX_STEPPER_HOST);
78
- destroyRef = inject(DestroyRef);
79
- injector = inject(Injector);
80
- matStepper = viewChild.required(MatStepper);
81
- // Host CD nudge after the `_iconOverrides` patch - Material reads the map
82
- // into per-header `[iconOverrides]` bindings on the next CD pass.
83
- hostCdr = inject(ChangeDetectorRef);
84
- flatSteps = this.presenter.flatSteps;
85
- activeStepIndex = this.presenter.activeStepIndex;
86
- activeStepId = this.presenter.activeStepId;
87
- stepDirectives = contentChildren(CngxStep, { ...(ngDevMode ? { debugName: "stepDirectives" } : /* istanbul ignore next */ {}), descendants: true });
88
- /**
89
- * Consumer-projected `<ng-template matStepperIcon>` templates,
90
- * forwarded into `MatStepper._iconOverrides` from the
91
- * `afterNextRender` patch below. `<ng-content>` projection cannot
92
- * reach Material's `@ContentChildren(MatStepperIcon)` - content-init
93
- * resolves the inner query before the wrapper's projection lands.
94
- * `_iconOverrides` is a Material-internal slot.
95
- */
96
- stepperIcons = contentChildren(MatStepperIcon, ...(ngDevMode ? [{ debugName: "stepperIcons" }] : /* istanbul ignore next */ []));
97
- /**
98
- * `Map<id, CngxStep>` so `labelTemplateFor` / `contentTemplateFor`
99
- * are O(1). Structural `equal` on the id-set + per-id directive
100
- * identity stops the map from cascading on shape-stable
101
- * `contentChildren` re-emits.
102
- */
103
- stepDirectiveById = inject(CNGX_DIRECTIVE_BY_ID_MAP_FACTORY)({
104
- source: this.stepDirectives,
105
- });
106
- /**
107
- * Step-only flat projection - `<mat-step>` does not nest, so
108
- * groups collapse into the same level. Memoised via
109
- * `flatStepsEqual` so consumers (`stepLabel`, panel `@for`,
110
- * `stepLabelContextFor`) don't re-walk on shape-stable
111
- * `flatSteps()` re-emits. Sibling-symmetric with
112
- * `CngxStepper.stepsOnly`.
113
- */
114
- stepsOnly = computed(() => this.presenter.flatSteps().filter((n) => n.kind === 'step'), { ...(ngDevMode ? { debugName: "stepsOnly" } : /* istanbul ignore next */ {}), equal: flatStepsEqual });
115
- /** Material orientation literal - narrows our `'horizontal'|'vertical'` to its own union. */
116
- matOrientation = computed(() => this.presenter.orientation() === 'vertical' ? 'vertical' : 'horizontal', ...(ngDevMode ? [{ debugName: "matOrientation" }] : /* istanbul ignore next */ []));
117
- stepIndexOf(node) {
118
- return node.flatIndex;
119
- }
120
- /** Editability rule - non-linear lets every step click; linear only past completed. */
121
- isEditable(node) {
122
- return !this.presenter.linear() || node.state() === 'success';
123
- }
124
- hasError(node) {
125
- return node.state() === 'error';
126
- }
127
- isCompleted(node) {
128
- return node.state() === 'success';
129
- }
130
- stepLabel(node) {
131
- return node.label();
132
- }
133
- /** Group nodes carry a depth marker so the label can distinguish nested rows. */
134
- stepDepth(node) {
135
- return node.depth;
136
- }
137
- // Material twin honours only `*cngxStepLabel` / `*cngxStepContent`; Material
138
- // owns indicator/badge/busy chrome via `<ng-template matStepperIcon>`.
139
- labelTemplateFor(id) {
140
- return this.stepDirectiveById().get(id)?.labelTemplate()?.templateRef ?? null;
141
- }
142
- contentTemplateFor(id) {
143
- return this.stepDirectiveById().get(id)?.contentTemplate()?.templateRef ?? null;
144
- }
145
- /**
146
- * Per-node-id slot-context cache for `*cngxStepLabel` /
147
- * `*cngxStepContent`. Mutating fields in place preserves the
148
- * object reference, so `*ngTemplateOutlet`'s `Object.is` diff
149
- * short-circuits the embedded-view rebind; the embedded view's
150
- * `let-` bindings re-read the mutated fields on the next CD pass.
151
- * Stale ids are pruned by the constructor effect tied to
152
- * `presenter.flatSteps`.
153
- */
154
- stepLabelContextCache = new Map();
155
- /** Build the {@link CngxStepLabelContext} for the projected label template. */
156
- stepLabelContextFor(node) {
157
- const flatStep = node.flatIndex;
158
- const active = node.id === this.presenter.activeStepId();
159
- const busy = this.presenter.commitState.status() === 'pending' &&
160
- this.presenter.intendedStepIndex() === flatStep;
161
- const disabled = node.disabled();
162
- const existing = this.stepLabelContextCache.get(node.id);
163
- if (!existing) {
164
- const fresh = {
165
- node,
166
- index: flatStep + 1,
167
- active,
168
- busy,
169
- disabled,
170
- };
171
- this.stepLabelContextCache.set(node.id, fresh);
172
- return fresh;
173
- }
174
- const mutable = existing;
175
- mutable.node = node;
176
- mutable.index = flatStep + 1;
177
- mutable.active = active;
178
- mutable.busy = busy;
179
- mutable.disabled = disabled;
180
- return existing;
181
- }
182
- /** Build the {@link CngxStepContentContext} for the projected content template. */
183
- stepContentContextFor(node) {
184
- return this.stepLabelContextFor(node);
185
- }
186
- constructor() {
187
- // Prune stale `stepLabelContextCache` entries - removed node-ids would otherwise leak.
188
- effect(() => {
189
- const flat = this.presenter.flatSteps();
190
- untracked(() => {
191
- const liveIds = new Set();
192
- for (const n of flat) {
193
- liveIds.add(n.id);
194
- }
195
- for (const id of Array.from(this.stepLabelContextCache.keys())) {
196
- if (!liveIds.has(id)) {
197
- this.stepLabelContextCache.delete(id);
198
- }
199
- }
200
- });
201
- });
202
- // `viewChild.required(MatStepper)` isn't resolved until after the view commits.
203
- afterNextRender(() => {
204
- const stepper = this.matStepper();
205
- createMatStepperBidirectionalSync({
206
- matStepper: stepper,
207
- presenter: this.presenter,
208
- injector: this.injector,
209
- destroyRef: this.destroyRef,
210
- });
211
- // Forward into Material's internal `_iconOverrides` slot.
212
- const stepperRef = stepper;
213
- const iconList = this.stepperIcons();
214
- if (!stepperRef._iconOverrides) {
215
- if (typeof ngDevMode !== 'undefined' && ngDevMode && iconList.length) {
216
- console.warn('[CngxMatStepper] MatStepper._iconOverrides is missing - ' +
217
- 'consumer-projected <ng-template matStepperIcon> templates ' +
218
- 'will not flow through to Material. Likely cause: a ' +
219
- 'Material upgrade renamed or removed the internal slot. ' +
220
- 'See stepper-accepted-debt §4 for the closure mechanism.');
221
- }
222
- return;
223
- }
224
- for (const icon of iconList) {
225
- stepperRef._iconOverrides[icon.name] = icon.templateRef;
226
- }
227
- // `markForCheck` (not `selectedIndex`) - touching the index would echo
228
- // through `createMaterialBidirectionalSync`.
229
- this.hostCdr.markForCheck();
230
- });
231
- }
232
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatStepper, deps: [], target: i0.ɵɵFactoryTarget.Component });
233
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxMatStepper, isStandalone: true, selector: "cngx-mat-stepper", providers: [{ provide: CNGX_STEP_PANEL_HOST, useExisting: CngxMatStepper }], queries: [{ propertyName: "stepDirectives", predicate: CngxStep, descendants: true, isSignal: true }, { propertyName: "stepperIcons", predicate: MatStepperIcon, isSignal: true }], viewQueries: [{ propertyName: "matStepper", first: true, predicate: MatStepper, descendants: true, isSignal: true }], exportAs: ["cngxMatStepper"], hostDirectives: [{ directive: i1.CngxStepperPresenter, inputs: ["activeStepIndex", "activeStepIndex", "linear", "linear", "orientation", "orientation", "commitAction", "commitAction", "commitMode", "commitMode"], outputs: ["activeStepIndexChange", "activeStepIndexChange"] }], ngImport: i0, template: "<mat-stepper\n [orientation]=\"matOrientation()\"\n [linear]=\"presenter.linear()\"\n>\n @for (node of stepsOnly(); track node.id) {\n <mat-step\n [completed]=\"isCompleted(node)\"\n [hasError]=\"hasError(node)\"\n [editable]=\"isEditable(node)\"\n >\n <ng-template matStepLabel>\n @let labelTpl = labelTemplateFor(node.id);\n @if (labelTpl) {\n <ng-container\n *ngTemplateOutlet=\"labelTpl; context: stepLabelContextFor(node)\"\n ></ng-container>\n } @else {\n <span [attr.data-step-depth]=\"stepDepth(node)\">{{ stepLabel(node) }}</span>\n }\n </ng-template>\n @let contentTpl = contentTemplateFor(node.id);\n @if (contentTpl) {\n <ng-container\n *ngTemplateOutlet=\"contentTpl; context: stepContentContextFor(node)\"\n ></ng-container>\n }\n </mat-step>\n }\n</mat-stepper>\n\n<!-- Footer slot - instruments the Material twin via CNGX_STEPPER_HOST. -->\n<ng-content select=\"cngx-stepper-footer, [cngxStepperFooter]\"></ng-content>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: MatStepperModule }, { kind: "component", type: i3.MatStep, selector: "mat-step", inputs: ["color"], exportAs: ["matStep"] }, { kind: "directive", type: i3.MatStepLabel, selector: "[matStepLabel]" }, { kind: "component", type: i3.MatStepper, selector: "mat-stepper, mat-vertical-stepper, mat-horizontal-stepper, [matStepper]", inputs: ["disableRipple", "color", "labelPosition", "headerPosition", "headerPrefix", "animationDuration"], outputs: ["animationDone"], exportAs: ["matStepper", "matVerticalStepper", "matHorizontalStepper"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
234
- }
235
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatStepper, decorators: [{
236
- type: Component,
237
- args: [{ selector: 'cngx-mat-stepper', exportAs: 'cngxMatStepper', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [CommonModule, MatStepperModule], hostDirectives: [
238
- {
239
- directive: CngxStepperPresenter,
240
- inputs: ['activeStepIndex', 'linear', 'orientation', 'commitAction', 'commitMode'],
241
- outputs: ['activeStepIndexChange'],
242
- },
243
- ], providers: [{ provide: CNGX_STEP_PANEL_HOST, useExisting: CngxMatStepper }], template: "<mat-stepper\n [orientation]=\"matOrientation()\"\n [linear]=\"presenter.linear()\"\n>\n @for (node of stepsOnly(); track node.id) {\n <mat-step\n [completed]=\"isCompleted(node)\"\n [hasError]=\"hasError(node)\"\n [editable]=\"isEditable(node)\"\n >\n <ng-template matStepLabel>\n @let labelTpl = labelTemplateFor(node.id);\n @if (labelTpl) {\n <ng-container\n *ngTemplateOutlet=\"labelTpl; context: stepLabelContextFor(node)\"\n ></ng-container>\n } @else {\n <span [attr.data-step-depth]=\"stepDepth(node)\">{{ stepLabel(node) }}</span>\n }\n </ng-template>\n @let contentTpl = contentTemplateFor(node.id);\n @if (contentTpl) {\n <ng-container\n *ngTemplateOutlet=\"contentTpl; context: stepContentContextFor(node)\"\n ></ng-container>\n }\n </mat-step>\n }\n</mat-stepper>\n\n<!-- Footer slot - instruments the Material twin via CNGX_STEPPER_HOST. -->\n<ng-content select=\"cngx-stepper-footer, [cngxStepperFooter]\"></ng-content>\n" }]
244
- }], ctorParameters: () => [], propDecorators: { matStepper: [{ type: i0.ViewChild, args: [i0.forwardRef(() => MatStepper), { isSignal: true }] }], stepDirectives: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CngxStep), { ...{ descendants: true }, isSignal: true }] }], stepperIcons: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => MatStepperIcon), { isSignal: true }] }] } });
245
-
246
48
  /**
247
49
  * Shared `signal(undefined)` constant used as the `errorAggregator`
248
50
  * slot for every Material-instrumented step handle. The
@@ -437,30 +239,73 @@ const CNGX_MAT_STEP_HANDLE_FACTORY = new InjectionToken('CNGX_MAT_STEP_HANDLE_FA
437
239
  });
438
240
 
439
241
  /**
440
- * Attaches to an existing `<mat-stepper>` and bridges it to a
441
- * {@link CngxStepperPresenter} - consumers gain the commit-action
242
+ * The Material twin of the CNGX stepper: attach `cngxMatStepper` to a
243
+ * vanilla `<mat-stepper>` and it is bridged to a
244
+ * {@link CngxStepperPresenter}. \
245
+ * Consumers gain the commit-action
442
246
  * lifecycle, `CNGX_STATEFUL` (so `<cngx-toast-on />` /
443
- * `<cngx-banner-on />` compose as children), and the step-handle
444
- * registry from one attribute.
247
+ * `<cngx-banner-on />` compose as children), the shared
248
+ * `CNGX_STEPPER_HOST` contract (so a `<cngx-stepper-footer>` can drive
249
+ * Back / Next instead of Material's own buttons via
250
+ * `[host]="ref.presenter"`), and the step-handle registry - all from
251
+ * one attribute.
445
252
  *
446
- * Sibling-additive to `<cngx-mat-stepper>` (the thin-wrapper
447
- * organism in `@cngx/ui/mat-stepper`): the wrapper authors fresh
448
- * markup, this directive upgrades existing Material markup.
449
- * `exportAs` differs (`cngxMatStepperDirective`) to avoid colliding
450
- * with the wrapper's `cngxMatStepper`.
253
+ * This is the instrumentation pattern: Material owns the rendering and
254
+ * the consumer authors native `<mat-step>` markup; CNGX is the
255
+ * behaviour layer. Topology mirrors `[cngxMatTabs]`.
451
256
  *
452
- * Topology mirrors `[cngxMatTabs]`: Material is the host, cngx is
453
- * the instrumentation layer.
257
+ * Inputs/outputs are forwarded from {@link CngxStepperPresenter}:
258
+ * - `activeStepIndex` (two-way, with `activeStepIndexChange`),
259
+ * - `linear`,
260
+ * - `orientation`,
261
+ * - `commitAction`,
262
+ * - `commitMode`. \
263
+ * See the presenter for their semantics.
264
+ * ```html
265
+ * <mat-stepper
266
+ * cngxMatStepper
267
+ * #s="cngxMatStepper"
268
+ * [(activeStepIndex)]="active"
269
+ * [commitAction]="commitAction"
270
+ * [commitMode]="mode()"
271
+ * cngxToastOn
272
+ * [toastError]="'Step transition failed'"
273
+ * cngxBannerOn
274
+ * bannerId="stepper:commit-error"
275
+ * [bannerError]="'The server rejected the step change.'"
276
+ * aria-label="Account setup"
277
+ * >
278
+ * <mat-step label="Personal info">
279
+ * <p>Tell us who you are.</p>
280
+ * </mat-step>
281
+ * <mat-step
282
+ * label="Account"
283
+ * [hasError]="!accepted()"
284
+ * errorMessage="Accept the terms to continue"
285
+ * >
286
+ * <p>Choose your sign-in method.</p>
287
+ * </mat-step>
288
+ * <mat-step label="Confirm">
289
+ * <p>Review everything, then finish.</p>
290
+ * </mat-step>
291
+ * </mat-stepper>
292
+ * ```
293
+ * @playground Bridge instrumentation ./examples/bridge/bridge-example.component.ts
454
294
  *
455
295
  * @category ui/mat-stepper
456
296
  * @docsKind primary
457
297
  * @wcag AA
458
298
  * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-stepper/mat-stepper.directive.ts
459
299
  * @since 0.1.0
460
- * @relatedTo CngxMatStepper, CngxStepperPresenter, CngxMatTabs
300
+ * @relatedTo CngxStepper, CngxStepperPresenter, CngxMatTabs, CngxStepperFooter
461
301
  */
462
- class CngxMatStepperBridge {
302
+ class CngxMatStepper {
463
303
  matStepper = inject(MatStepper, { self: true });
304
+ /**
305
+ * Shared host contract. Public so a `<cngx-stepper-footer>` placed
306
+ * outside the `<mat-stepper>` can bind `[host]="ref.presenter"` (via
307
+ * `#ref="cngxMatStepper"`) and drive navigation.
308
+ */
464
309
  presenter = inject(CNGX_STEPPER_HOST);
465
310
  destroyRef = inject(DestroyRef);
466
311
  injector = inject(Injector);
@@ -506,14 +351,14 @@ class CngxMatStepperBridge {
506
351
  this.presenter.unregister(setup.handle.id);
507
352
  }
508
353
  }
509
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatStepperBridge, deps: [], target: i0.ɵɵFactoryTarget.Directive });
510
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxMatStepperBridge, isStandalone: true, selector: "[cngxMatStepper]", queries: [{ propertyName: "matSteps", predicate: MatStep, descendants: true, isSignal: true }], exportAs: ["cngxMatStepperDirective"], hostDirectives: [{ directive: i1.CngxStepperPresenter, inputs: ["activeStepIndex", "activeStepIndex", "linear", "linear", "orientation", "orientation", "commitAction", "commitAction", "commitMode", "commitMode"], outputs: ["activeStepIndexChange", "activeStepIndexChange"] }], ngImport: i0 });
354
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatStepper, deps: [], target: i0.ɵɵFactoryTarget.Directive });
355
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxMatStepper, isStandalone: true, selector: "[cngxMatStepper]", queries: [{ propertyName: "matSteps", predicate: MatStep, descendants: true, isSignal: true }], exportAs: ["cngxMatStepper"], hostDirectives: [{ directive: i1.CngxStepperPresenter, inputs: ["activeStepIndex", "activeStepIndex", "linear", "linear", "orientation", "orientation", "commitAction", "commitAction", "commitMode", "commitMode"], outputs: ["activeStepIndexChange", "activeStepIndexChange"] }], ngImport: i0 });
511
356
  }
512
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatStepperBridge, decorators: [{
357
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatStepper, decorators: [{
513
358
  type: Directive,
514
359
  args: [{
515
360
  selector: '[cngxMatStepper]',
516
- exportAs: 'cngxMatStepperDirective',
361
+ exportAs: 'cngxMatStepper',
517
362
  standalone: true,
518
363
  hostDirectives: [
519
364
  {
@@ -528,15 +373,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
528
373
  /**
529
374
  * Public API surface of `@cngx/ui/mat-stepper`.
530
375
  *
531
- * Material-twin organism for the cngx stepper family. Composes the same
532
- * `CngxStepperPresenter` brain as `<cngx-stepper>` (in `@cngx/ui/stepper`)
533
- * via `hostDirectives`, so commit-action lifecycle, router sync, and
534
- * error aggregation all work identically against `<mat-stepper>`.
376
+ * The Material twin of the cngx stepper family, shipped as the
377
+ * instrumentation directive `[cngxMatStepper]`: attach it to a vanilla
378
+ * `<mat-stepper>` and it composes the same `CngxStepperPresenter` brain
379
+ * as `<cngx-stepper>` (in `@cngx/ui/stepper`) via `hostDirectives`, so
380
+ * commit-action lifecycle, router sync, and error aggregation all work
381
+ * against Material's own markup. Mirrors `[cngxMatTabs]`.
535
382
  */
536
383
 
537
384
  /**
538
385
  * Generated bundle index. Do not edit.
539
386
  */
540
387
 
541
- export { CNGX_MAT_STEP_HANDLE_FACTORY, CngxMatStepper, CngxMatStepperBridge, createMatStepHandle };
388
+ export { CNGX_MAT_STEP_HANDLE_FACTORY, CngxMatStepper, createMatStepHandle };
542
389
  //# sourceMappingURL=cngx-ui-mat-stepper.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cngx-ui-mat-stepper.mjs","sources":["../../../projects/ui/mat-stepper/material-bridge/bidirectional-sync.ts","../../../projects/ui/mat-stepper/mat-stepper.component.ts","../../../projects/ui/mat-stepper/mat-stepper.component.html","../../../projects/ui/mat-stepper/material-bridge/handle.ts","../../../projects/ui/mat-stepper/mat-stepper.directive.ts","../../../projects/ui/mat-stepper/public-api.ts","../../../projects/ui/mat-stepper/cngx-ui-mat-stepper.ts"],"sourcesContent":["import type { DestroyRef, Injector } from '@angular/core';\nimport type { MatStepper } from '@angular/material/stepper';\n\nimport { createMaterialBidirectionalSync } from '@cngx/common/data';\nimport type { CngxStepperHost } from '@cngx/common/stepper';\n\n/**\n * Options for {@link createMatStepperBidirectionalSync}.\n */\nexport interface CngxMatStepperBidirectionalSyncOptions {\n /** Material stepper the helper bridges against. */\n readonly matStepper: MatStepper;\n /** cngx stepper presenter — write target for Material→presenter. */\n readonly presenter: CngxStepperHost;\n /** Injection context for the underlying `effect()` in `@cngx/common/data`. */\n readonly injector: Injector;\n /**\n * Destroy ref the underlying subscriber teardown attaches to.\n * Same lifetime as the host directive / component.\n */\n readonly destroyRef: DestroyRef;\n}\n\n/**\n * Stepper-specific glue over {@link createMaterialBidirectionalSync}\n * (`@cngx/common/data`). Both `<cngx-mat-stepper>` (Component) and\n * `[cngxMatStepper]` (Directive) need to install the same\n * presenter↔Material `selectedIndex` sync; the option-mapping body\n * was identical at both call sites — same `presenterIndex`, same\n * `readSelectedIndex` / `writeSelectedIndex` shape, same\n * `selectedIndexChange.asObservable()` source, same\n * `onMaterialSelection` write-back. This helper is the single entry\n * point: each call site reduces to one line.\n *\n * Behaviour stays identical to the prior inline blocks — the helper\n * is a pure shape-adapter, no policy. The underlying generic factory\n * owns:\n * - presenter→Material `effect()` with read-equality guard.\n * - Material→presenter subscription with re-entrancy guard.\n * - Material-eager-advance reconciliation (Material's MDC click\n * handler advances `selectedIndex` synchronously before the\n * bidirectional sync sees the event).\n * - `destroyRef` cleanup of both directions.\n */\nexport function createMatStepperBidirectionalSync(\n opts: CngxMatStepperBidirectionalSyncOptions,\n): void {\n createMaterialBidirectionalSync({\n presenterIndex: opts.presenter.activeStepIndex,\n readSelectedIndex: () => opts.matStepper.selectedIndex,\n writeSelectedIndex: (i) => {\n opts.matStepper.selectedIndex = i;\n },\n // `MatStepper.selectedIndexChange` emits a plain index — no adapter needed,\n // unlike `MatTabGroup.selectedIndexChange`.\n selectionChange$: opts.matStepper.selectedIndexChange.asObservable(),\n onMaterialSelection: (i) => opts.presenter.select(i),\n injector: opts.injector,\n destroyRef: opts.destroyRef,\n });\n}\n","import { CommonModule } from '@angular/common';\nimport {\n afterNextRender,\n ChangeDetectionStrategy,\n ChangeDetectorRef,\n Component,\n computed,\n contentChildren,\n DestroyRef,\n effect,\n inject,\n Injector,\n type Signal,\n type TemplateRef,\n untracked,\n viewChild,\n} from '@angular/core';\nimport { MatStepperModule, MatStepper, MatStepperIcon } from '@angular/material/stepper';\n\nimport {\n CNGX_STEP_PANEL_HOST,\n CngxStep,\n type CngxStepContentContext,\n type CngxStepLabelContext,\n CngxStepperPresenter,\n CNGX_STEPPER_HOST,\n flatStepsEqual,\n type CngxStepNode,\n type CngxStepPanelHost,\n} from '@cngx/common/stepper';\n\nimport { createMatStepperBidirectionalSync } from './material-bridge/bidirectional-sync';\nimport { CNGX_DIRECTIVE_BY_ID_MAP_FACTORY } from '@cngx/common/tabs';\nimport type { MaterialPrivateSurfaces } from '@cngx/ui/mat-tabs';\n\n/**\n * Material-twin stepper organism. Wraps `<mat-stepper>` and shares\n * the `CngxStepperPresenter` brain with `<cngx-stepper>` - Material\n * consumers gain the commit-action lifecycle, router sync, and error\n * aggregation.\n *\n * Bidirectional sync between presenter and `MatStepper.selectedIndex`\n * runs in a single `effect()` with `untracked()` writes so neither\n * direction tracks the other.\n *\n * Material owns keyboard nav and focus on `MatStepperHeader`, so the\n * organism does NOT compose `CngxRovingTabindex` /\n * `CngxFocusRestore`. Group nodes flatten - `<mat-stepper>` does not\n * support nesting - with the depth preserved as a `data-step-depth`\n * hint on the rendered label.\n *\n * @playground Bridge instrumentation ./examples/bridge/bridge-example.component.ts\n *\n * @category ui/mat-stepper\n * @docsKind primary\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-stepper/mat-stepper.component.ts\n * @since 0.1.0\n * @relatedTo CngxMatStepperBridge, CngxStepperPresenter, CngxStep\n * <example-url>http://localhost:4200/#/ui/stepper/stepper-footer/mat-stepper-footer</example-url>\n */\n@Component({\n selector: 'cngx-mat-stepper',\n exportAs: 'cngxMatStepper',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [CommonModule, MatStepperModule],\n hostDirectives: [\n {\n directive: CngxStepperPresenter,\n inputs: ['activeStepIndex', 'linear', 'orientation', 'commitAction', 'commitMode'],\n outputs: ['activeStepIndexChange'],\n },\n ],\n providers: [{ provide: CNGX_STEP_PANEL_HOST, useExisting: CngxMatStepper }],\n templateUrl: './mat-stepper.component.html',\n})\nexport class CngxMatStepper implements CngxStepPanelHost {\n protected readonly presenter = inject(CNGX_STEPPER_HOST);\n private readonly destroyRef = inject(DestroyRef);\n private readonly injector = inject(Injector);\n protected readonly matStepper = viewChild.required(MatStepper);\n // Host CD nudge after the `_iconOverrides` patch - Material reads the map\n // into per-header `[iconOverrides]` bindings on the next CD pass.\n private readonly hostCdr = inject(ChangeDetectorRef);\n\n readonly flatSteps: Signal<readonly CngxStepNode[]> = this.presenter.flatSteps;\n readonly activeStepIndex: Signal<number> = this.presenter.activeStepIndex;\n readonly activeStepId: Signal<string | null> = this.presenter.activeStepId;\n private readonly stepDirectives = contentChildren(CngxStep, { descendants: true });\n\n /**\n * Consumer-projected `<ng-template matStepperIcon>` templates,\n * forwarded into `MatStepper._iconOverrides` from the\n * `afterNextRender` patch below. `<ng-content>` projection cannot\n * reach Material's `@ContentChildren(MatStepperIcon)` - content-init\n * resolves the inner query before the wrapper's projection lands.\n * `_iconOverrides` is a Material-internal slot.\n */\n private readonly stepperIcons = contentChildren(MatStepperIcon);\n\n /**\n * `Map<id, CngxStep>` so `labelTemplateFor` / `contentTemplateFor`\n * are O(1). Structural `equal` on the id-set + per-id directive\n * identity stops the map from cascading on shape-stable\n * `contentChildren` re-emits.\n */\n private readonly stepDirectiveById = inject(CNGX_DIRECTIVE_BY_ID_MAP_FACTORY)({\n source: this.stepDirectives,\n });\n\n /**\n * Step-only flat projection - `<mat-step>` does not nest, so\n * groups collapse into the same level. Memoised via\n * `flatStepsEqual` so consumers (`stepLabel`, panel `@for`,\n * `stepLabelContextFor`) don't re-walk on shape-stable\n * `flatSteps()` re-emits. Sibling-symmetric with\n * `CngxStepper.stepsOnly`.\n */\n protected readonly stepsOnly: Signal<readonly CngxStepNode[]> = computed(\n () => this.presenter.flatSteps().filter((n) => n.kind === 'step'),\n { equal: flatStepsEqual },\n );\n\n /** Material orientation literal - narrows our `'horizontal'|'vertical'` to its own union. */\n protected readonly matOrientation = computed<'horizontal' | 'vertical'>(() =>\n this.presenter.orientation() === 'vertical' ? 'vertical' : 'horizontal',\n );\n\n protected stepIndexOf(node: CngxStepNode): number {\n return node.flatIndex;\n }\n\n /** Editability rule - non-linear lets every step click; linear only past completed. */\n protected isEditable(node: CngxStepNode): boolean {\n return !this.presenter.linear() || node.state() === 'success';\n }\n\n protected hasError(node: CngxStepNode): boolean {\n return node.state() === 'error';\n }\n\n protected isCompleted(node: CngxStepNode): boolean {\n return node.state() === 'success';\n }\n\n protected stepLabel(node: CngxStepNode): string {\n return node.label();\n }\n\n /** Group nodes carry a depth marker so the label can distinguish nested rows. */\n protected stepDepth(node: CngxStepNode): number {\n return node.depth;\n }\n\n // Material twin honours only `*cngxStepLabel` / `*cngxStepContent`; Material\n // owns indicator/badge/busy chrome via `<ng-template matStepperIcon>`.\n labelTemplateFor(id: string): TemplateRef<CngxStepLabelContext> | null {\n return this.stepDirectiveById().get(id)?.labelTemplate()?.templateRef ?? null;\n }\n\n contentTemplateFor(id: string): TemplateRef<CngxStepContentContext> | null {\n return this.stepDirectiveById().get(id)?.contentTemplate()?.templateRef ?? null;\n }\n\n /**\n * Per-node-id slot-context cache for `*cngxStepLabel` /\n * `*cngxStepContent`. Mutating fields in place preserves the\n * object reference, so `*ngTemplateOutlet`'s `Object.is` diff\n * short-circuits the embedded-view rebind; the embedded view's\n * `let-` bindings re-read the mutated fields on the next CD pass.\n * Stale ids are pruned by the constructor effect tied to\n * `presenter.flatSteps`.\n */\n private readonly stepLabelContextCache = new Map<string, CngxStepLabelContext>();\n\n /** Build the {@link CngxStepLabelContext} for the projected label template. */\n protected stepLabelContextFor(node: CngxStepNode): CngxStepLabelContext {\n const flatStep = node.flatIndex;\n const active = node.id === this.presenter.activeStepId();\n const busy =\n this.presenter.commitState.status() === 'pending' &&\n this.presenter.intendedStepIndex() === flatStep;\n const disabled = node.disabled();\n\n const existing = this.stepLabelContextCache.get(node.id);\n if (!existing) {\n const fresh: CngxStepLabelContext = {\n node,\n index: flatStep + 1,\n active,\n busy,\n disabled,\n };\n this.stepLabelContextCache.set(node.id, fresh);\n return fresh;\n }\n const mutable = existing as {\n -readonly [K in keyof CngxStepLabelContext]: CngxStepLabelContext[K];\n };\n mutable.node = node;\n mutable.index = flatStep + 1;\n mutable.active = active;\n mutable.busy = busy;\n mutable.disabled = disabled;\n return existing;\n }\n\n /** Build the {@link CngxStepContentContext} for the projected content template. */\n protected stepContentContextFor(node: CngxStepNode): CngxStepContentContext {\n return this.stepLabelContextFor(node);\n }\n\n constructor() {\n // Prune stale `stepLabelContextCache` entries - removed node-ids would otherwise leak.\n effect(() => {\n const flat = this.presenter.flatSteps();\n untracked(() => {\n const liveIds = new Set<string>();\n for (const n of flat) {\n liveIds.add(n.id);\n }\n for (const id of Array.from(this.stepLabelContextCache.keys())) {\n if (!liveIds.has(id)) {\n this.stepLabelContextCache.delete(id);\n }\n }\n });\n });\n\n // `viewChild.required(MatStepper)` isn't resolved until after the view commits.\n afterNextRender(() => {\n const stepper = this.matStepper();\n createMatStepperBidirectionalSync({\n matStepper: stepper,\n presenter: this.presenter,\n injector: this.injector,\n destroyRef: this.destroyRef,\n });\n\n // Forward into Material's internal `_iconOverrides` slot.\n const stepperRef = stepper as unknown as MaterialPrivateSurfaces.IconOverrideHost;\n const iconList = this.stepperIcons();\n if (!stepperRef._iconOverrides) {\n if (typeof ngDevMode !== 'undefined' && ngDevMode && iconList.length) {\n console.warn(\n '[CngxMatStepper] MatStepper._iconOverrides is missing - ' +\n 'consumer-projected <ng-template matStepperIcon> templates ' +\n 'will not flow through to Material. Likely cause: a ' +\n 'Material upgrade renamed or removed the internal slot. ' +\n 'See stepper-accepted-debt §4 for the closure mechanism.',\n );\n }\n return;\n }\n for (const icon of iconList) {\n stepperRef._iconOverrides[icon.name] = icon.templateRef;\n }\n // `markForCheck` (not `selectedIndex`) - touching the index would echo\n // through `createMaterialBidirectionalSync`.\n this.hostCdr.markForCheck();\n });\n }\n}\n","<mat-stepper\n [orientation]=\"matOrientation()\"\n [linear]=\"presenter.linear()\"\n>\n @for (node of stepsOnly(); track node.id) {\n <mat-step\n [completed]=\"isCompleted(node)\"\n [hasError]=\"hasError(node)\"\n [editable]=\"isEditable(node)\"\n >\n <ng-template matStepLabel>\n @let labelTpl = labelTemplateFor(node.id);\n @if (labelTpl) {\n <ng-container\n *ngTemplateOutlet=\"labelTpl; context: stepLabelContextFor(node)\"\n ></ng-container>\n } @else {\n <span [attr.data-step-depth]=\"stepDepth(node)\">{{ stepLabel(node) }}</span>\n }\n </ng-template>\n @let contentTpl = contentTemplateFor(node.id);\n @if (contentTpl) {\n <ng-container\n *ngTemplateOutlet=\"contentTpl; context: stepContentContextFor(node)\"\n ></ng-container>\n }\n </mat-step>\n }\n</mat-stepper>\n\n<!-- Footer slot - instruments the Material twin via CNGX_STEPPER_HOST. -->\n<ng-content select=\"cngx-stepper-footer, [cngxStepperFooter]\"></ng-content>\n","import { computed, InjectionToken, signal, type Signal, type TemplateRef } from '@angular/core';\nimport type { MatStep } from '@angular/material/stepper';\n\nimport type { CngxErrorAggregatorContract } from '@cngx/common/interactive';\nimport type { CngxStepRegistration, CngxStepStatus } from '@cngx/common/stepper';\n\n/**\n * Shared `signal(undefined)` constant used as the `errorAggregator`\n * slot for every Material-instrumented step handle. The\n * instrumentation path does not bind cngx error-aggregation per\n * `MatStep` - Material's own visual error surface (driven by\n * `MatStep.hasError` / `MatStep.optional`) stays authoritative - so\n * per-step allocation of a writable signal would be dead capacity.\n *\n * @internal\n */\nconst NO_ERROR_AGGREGATOR: Signal<CngxErrorAggregatorContract | undefined> = signal<\n CngxErrorAggregatorContract | undefined\n>(undefined).asReadonly();\n\n/**\n * Wiring bundle returned from {@link createMatStepHandle}. The\n * instrumentation directive holds the bundle in a `Map<MatStep,\n * Setup>` for diff-only registry churn; only `handle` is exposed to\n * the presenter.\n */\nexport interface CngxMatStepHandleSetup {\n readonly handle: CngxStepRegistration;\n}\n\n/**\n * Best-effort static-text extraction from a `<ng-template matStepLabel>`\n * `TemplateRef`. Used as a label fallback when consumers project a\n * template label without setting `MatStep.label` or\n * `MatStep.ariaLabel` - without it the cngx-side label slot would\n * be empty, leaving aria-label phrases that include the step label\n * with a measurable gap on the Material variant. Static markup\n * (`<ng-template matStepLabel>Review</ng-template>`) extracts cleanly\n * via a detached embedded view; templates with dynamic interpolation\n * fall through (the detached view's CD has no consumer-context\n * bindings) and the caller's deterministic id-based fallback wins.\n *\n * Idempotent: never mutates the source template; the embedded view is\n * created and destroyed inside one frame's worth of synchronous work.\n *\n * @internal\n */\nfunction readMatStepLabelTemplateText(template: TemplateRef<unknown>): string | undefined {\n try {\n const view = template.createEmbeddedView({});\n try {\n view.detectChanges();\n const text = view.rootNodes\n .map((node: Node) => node.textContent ?? '')\n .join('')\n .trim();\n return text || undefined;\n } finally {\n view.destroy();\n }\n } catch {\n return undefined;\n }\n}\n\n/**\n * Translates a Material `MatStep` into a cngx\n * {@link CngxStepRegistration}.\n *\n * - `id` - always a fresh `idSeed()` value. Mirrors the tabs\n * instrumentation handle: a label-keyed id would collide when\n * two steps share a label.\n * - `kind` - fixed at `'step'`. The instrumentation path does not\n * project nested `<mat-step>` groups (Material's stepper has no\n * group-of-steps concept; group-aware semantics belong to the\n * `<cngx-stepper>` thin-wrapper organism).\n * - `label` - snapshot signal resolved through a four-tier fallback at\n * registration time so cngx-side phrases (announcements,\n * `aria-label` composition, telemetry) never read empty when\n * Material consumers project a `<ng-template matStepLabel>`:\n * 1. `MatStep.label` when it is a plain string - the canonical\n * shape and the only one that emits a runtime change Material\n * itself observes.\n * 2. `MatStep.ariaLabel` when the consumer set the input -\n * designed exactly as the substitute for template labels.\n * 3. Static-text read from `MatStep.stepLabel.template` via a\n * throwaway detached `EmbeddedViewRef` ({@link readMatStepLabelTemplateText}).\n * Captures literal `matStepLabel` markup; dynamic interpolation\n * bails through to (4).\n * 4. `Step <id>` - deterministic, derived from the cngx handle\n * id. Always non-empty.\n * Documented limitation: runtime label changes do not propagate.\n * CDK's `CdkStep` does not expose a `_stateChanges` Subject\n * analogous to `MatTab._stateChanges`, so cngx cannot re-trigger\n * the snapshot when Material flips the input later. Surface the\n * same Material-internal coupling family typed in\n * `MaterialPrivateSurfaces.CompletedOverrideSource`.\n * - `disabled` - fixed `false`. Material owns step gating via\n * `linear` + `editable` + `completed`; surfacing a cngx-side\n * `disabled` would duplicate Material's own click-time enforcement\n * and is ignored by `<mat-stepper>` itself.\n * - `state` - `computed()` over `MatStep.hasError` / `MatStep.completed`.\n * `CdkStep.completed`'s getter reads `_completedOverride()` - a\n * `WritableSignal<boolean | null>` typed in\n * `MaterialPrivateSurfaces.CompletedOverrideSource`. The cngx\n * computed transitively tracks that signal through the getter and\n * re-fires whenever Material flips completion. `hasError` is a\n * plain property setter on `CdkStep`, NOT a Signal - a `hasError`\n * write that is not paired with a `completed` change does not\n * re-trigger this computed. In practice Material wizards write the\n * two together (`step.hasError = true; step.completed = false` in\n * error-handler patterns and inside Material's own error-state\n * matchers) so the limitation is benign for the documented usage\n * pattern.\n * - `errorAggregator` - points at the shared\n * {@link NO_ERROR_AGGREGATOR} constant.\n *\n * @category ui/mat-stepper\n */\nexport function createMatStepHandle(\n matStep: MatStep,\n idSeed: () => string,\n): CngxMatStepHandleSetup {\n const id = idSeed();\n const labelText = resolveStepLabel(matStep, id);\n const label = signal<string>(labelText).asReadonly();\n const disabled = signal<boolean>(false).asReadonly();\n const state = computed<CngxStepStatus>(() => {\n if (matStep.hasError) {\n return 'error';\n }\n if (matStep.completed) {\n return 'success';\n }\n return 'idle';\n });\n return {\n handle: {\n id,\n kind: 'step',\n label,\n disabled,\n state,\n errorAggregator: NO_ERROR_AGGREGATOR,\n },\n };\n}\n\n/**\n * Four-tier label fallback walked once at registration time. See the\n * {@link createMatStepHandle} JSDoc for the full ladder rationale.\n *\n * @internal\n */\nfunction resolveStepLabel(matStep: MatStep, id: string): string {\n const labelInput = matStep.label;\n if (typeof labelInput === 'string' && labelInput.length > 0) {\n return labelInput;\n }\n const ariaLabel = matStep.ariaLabel;\n if (typeof ariaLabel === 'string' && ariaLabel.length > 0) {\n return ariaLabel;\n }\n const tpl = matStep.stepLabel?.template;\n if (tpl) {\n const text = readMatStepLabelTemplateText(tpl);\n if (text) {\n return text;\n }\n }\n return `Step ${id}`;\n}\n\n/**\n * Factory signature for {@link createMatStepHandle}. The DI token\n * {@link CNGX_MAT_STEP_HANDLE_FACTORY} resolves to a function with\n * this exact shape - overrides match it identically.\n *\n * @category ui/mat-stepper\n */\nexport type CngxMatStepHandleFactory = typeof createMatStepHandle;\n\n/**\n * DI token fronting the per-step handle factory used by the\n * `[cngxMatStepper]` instrumentation directive. Default is\n * {@link createMatStepHandle}.\n *\n * Symmetric with the tabs sibling\n * `CNGX_MAT_TAB_HANDLE_FACTORY` and with `CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY`\n * - every Material-bridge logic block ships the same swap surface so\n * consumers can layer telemetry, alternate id strategies, or\n * test-environment id keying via `providers` / `viewProviders`\n * without forking the directive.\n *\n * Override capability - the swap surface separates **handle shape**\n * (factory body) from **id keying** (the supplied `idSeed` closure).\n * The directive constructs `idSeed` as `() => nextUid('cngx-mat-step-')`\n * and hands it to the factory as a default suggestion; an override is\n * free to call it, ignore it, or replace it with a server-synced /\n * deterministic-test / consumer-domain id strategy. Both axes are\n * independently swappable from one DI seam.\n *\n * ```ts\n * providers: [\n * {\n * provide: CNGX_MAT_STEP_HANDLE_FACTORY,\n * useValue: ((step, idSeed) => {\n * const setup = createMatStepHandle(step, idSeed);\n * reportStepRegistered(setup.handle.id);\n * return setup;\n * }) satisfies CngxMatStepHandleFactory,\n * },\n * ]\n * ```\n *\n * @category ui/mat-stepper\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-stepper/material-bridge/handle.ts\n * @since 0.1.0\n */\nexport const CNGX_MAT_STEP_HANDLE_FACTORY = new InjectionToken<CngxMatStepHandleFactory>(\n 'CNGX_MAT_STEP_HANDLE_FACTORY',\n {\n providedIn: 'root',\n factory: () => createMatStepHandle,\n },\n);\n","import {\n contentChildren,\n type DestroyRef,\n Directive,\n effect,\n inject,\n type Injector,\n untracked,\n DestroyRef as InjectableDestroyRef,\n Injector as InjectableInjector,\n} from '@angular/core';\nimport { MatStep, MatStepper } from '@angular/material/stepper';\n\nimport { CNGX_STEPPER_HOST, CngxStepperPresenter } from '@cngx/common/stepper';\nimport { nextUid } from '@cngx/core/utils';\n\nimport { createMatStepperBidirectionalSync } from './material-bridge/bidirectional-sync';\nimport {\n CNGX_MAT_STEP_HANDLE_FACTORY,\n type CngxMatStepHandleSetup,\n} from './material-bridge/handle';\n\n/**\n * Attaches to an existing `<mat-stepper>` and bridges it to a\n * {@link CngxStepperPresenter} - consumers gain the commit-action\n * lifecycle, `CNGX_STATEFUL` (so `<cngx-toast-on />` /\n * `<cngx-banner-on />` compose as children), and the step-handle\n * registry from one attribute.\n *\n * Sibling-additive to `<cngx-mat-stepper>` (the thin-wrapper\n * organism in `@cngx/ui/mat-stepper`): the wrapper authors fresh\n * markup, this directive upgrades existing Material markup.\n * `exportAs` differs (`cngxMatStepperDirective`) to avoid colliding\n * with the wrapper's `cngxMatStepper`.\n *\n * Topology mirrors `[cngxMatTabs]`: Material is the host, cngx is\n * the instrumentation layer.\n *\n * @category ui/mat-stepper\n * @docsKind primary\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-stepper/mat-stepper.directive.ts\n * @since 0.1.0\n * @relatedTo CngxMatStepper, CngxStepperPresenter, CngxMatTabs\n */\n@Directive({\n selector: '[cngxMatStepper]',\n exportAs: 'cngxMatStepperDirective',\n standalone: true,\n hostDirectives: [\n {\n directive: CngxStepperPresenter,\n inputs: ['activeStepIndex', 'linear', 'orientation', 'commitAction', 'commitMode'],\n outputs: ['activeStepIndexChange'],\n },\n ],\n})\nexport class CngxMatStepperBridge {\n private readonly matStepper = inject(MatStepper, { self: true });\n private readonly presenter = inject(CNGX_STEPPER_HOST);\n private readonly destroyRef: DestroyRef = inject(InjectableDestroyRef);\n private readonly injector: Injector = inject(InjectableInjector);\n\n private readonly matSteps = contentChildren(MatStep, { descendants: true });\n // Map not WeakMap - syncHandles needs to iterate to find removed steps.\n private readonly setupsByStep = new Map<MatStep, CngxMatStepHandleSetup>();\n private readonly createHandle = inject(CNGX_MAT_STEP_HANDLE_FACTORY);\n\n constructor() {\n effect(() => {\n const steps = this.matSteps();\n untracked(() => this.syncHandles(steps));\n });\n\n this.destroyRef.onDestroy(() => {\n for (const setup of this.setupsByStep.values()) {\n this.presenter.unregister(setup.handle.id);\n }\n this.setupsByStep.clear();\n });\n\n createMatStepperBidirectionalSync({\n matStepper: this.matStepper,\n presenter: this.presenter,\n injector: this.injector,\n destroyRef: this.destroyRef,\n });\n }\n\n private syncHandles(steps: readonly MatStep[]): void {\n const liveSteps = new Set<MatStep>(steps);\n\n // Only fresh MatSteps get registered; cached ones survive untouched.\n for (const step of steps) {\n if (this.setupsByStep.has(step)) {\n continue;\n }\n const setup = this.createHandle(step, () => nextUid('cngx-mat-step-'));\n this.setupsByStep.set(step, setup);\n this.presenter.register(setup.handle);\n }\n\n // Snapshot before iterating - guards against non-current-key deletes inside the body.\n for (const [step, setup] of Array.from(this.setupsByStep.entries())) {\n if (liveSteps.has(step)) {\n continue;\n }\n this.setupsByStep.delete(step);\n this.presenter.unregister(setup.handle.id);\n }\n }\n}\n","/**\n * Public API surface of `@cngx/ui/mat-stepper`.\n *\n * Material-twin organism for the cngx stepper family. Composes the same\n * `CngxStepperPresenter` brain as `<cngx-stepper>` (in `@cngx/ui/stepper`)\n * via `hostDirectives`, so commit-action lifecycle, router sync, and\n * error aggregation all work identically against `<mat-stepper>`.\n */\nexport { CngxMatStepper } from './mat-stepper.component';\nexport { CngxMatStepperBridge } from './mat-stepper.directive';\nexport {\n CNGX_MAT_STEP_HANDLE_FACTORY,\n createMatStepHandle,\n type CngxMatStepHandleFactory,\n} from './material-bridge/handle';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["InjectableDestroyRef","InjectableInjector"],"mappings":";;;;;;;;;;;;AAuBA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAU,iCAAiC,CAC/C,IAA4C,EAAA;AAE5C,IAAA,+BAA+B,CAAC;AAC9B,QAAA,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe;QAC9C,iBAAiB,EAAE,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa;AACtD,QAAA,kBAAkB,EAAE,CAAC,CAAC,KAAI;AACxB,YAAA,IAAI,CAAC,UAAU,CAAC,aAAa,GAAG,CAAC;QACnC,CAAC;;;QAGD,gBAAgB,EAAE,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,YAAY,EAAE;AACpE,QAAA,mBAAmB,EAAE,CAAC,CAAC,KAAK,IAAI,C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,CAAA;;2FANxC,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBAZhC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,kBAAkB;AAC5B,oBAAA,QAAQ,EAAE,yBAAyB;AACnC,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,cAAc,EAAE;AACd,wBAAA;AACE,4BAAA,SAAS,EAAE,oBAAoB;4BAC/B,MAAM,EAAE,CAAC,iBAAiB,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,CAAC;4BAClF,OAAO,EAAE,CAAC,uBAAuB,CAAC;AACnC,yBAAA;AACF,qBAAA;AACF,iBAAA;AAO6C,SAAA,CAAA,EAAA,cAAA,EAAA,MAAA,EAAA,EAAA,cAAA,EAAA,EAAA,QAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,eAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,UAAA,CAAA,MAAA,OAAO,CAAA,EAAA,EAAA,GAAE,EAAE,WAAW,EAAE,IAAI,EAAE,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AC/D5E;;;;;;;AAOG;;ACPH;;AAEG;;;;"}
1
+ {"version":3,"file":"cngx-ui-mat-stepper.mjs","sources":["../../../projects/ui/mat-stepper/material-bridge/bidirectional-sync.ts","../../../projects/ui/mat-stepper/material-bridge/handle.ts","../../../projects/ui/mat-stepper/mat-stepper.directive.ts","../../../projects/ui/mat-stepper/public-api.ts","../../../projects/ui/mat-stepper/cngx-ui-mat-stepper.ts"],"sourcesContent":["import type { DestroyRef, Injector } from '@angular/core';\nimport type { MatStepper } from '@angular/material/stepper';\n\nimport { createMaterialBidirectionalSync } from '@cngx/common/data';\nimport type { CngxStepperHost } from '@cngx/common/stepper';\n\n/**\n * Options for {@link createMatStepperBidirectionalSync}.\n *\n * @internal\n */\nexport interface CngxMatStepperBidirectionalSyncOptions {\n /** Material stepper the helper bridges against. */\n readonly matStepper: MatStepper;\n /** cngx stepper presenter - write target for Material→presenter. */\n readonly presenter: CngxStepperHost;\n /** Injection context for the underlying `effect()` in `@cngx/common/data`. */\n readonly injector: Injector;\n /**\n * Destroy ref the underlying subscriber teardown attaches to.\n * Same lifetime as the host directive / component.\n */\n readonly destroyRef: DestroyRef;\n}\n\n/**\n * Stepper-specific glue over {@link createMaterialBidirectionalSync}\n * (`@cngx/common/data`). Both `<cngx-mat-stepper>` (Component) and\n * `[cngxMatStepper]` (Directive) need to install the same\n * presenter↔Material `selectedIndex` sync; the option-mapping body\n * was identical at both call sites - same `presenterIndex`, same\n * `readSelectedIndex` / `writeSelectedIndex` shape, same\n * `selectedIndexChange.asObservable()` source, same\n * `onMaterialSelection` write-back. This helper is the single entry\n * point: each call site reduces to one line.\n *\n * Behaviour stays identical to the prior inline blocks - the helper\n * is a pure shape-adapter, no policy. The underlying generic factory\n * owns:\n * - presenter→Material `effect()` with read-equality guard.\n * - Material→presenter subscription with re-entrancy guard.\n * - Material-eager-advance reconciliation (Material's MDC click\n * handler advances `selectedIndex` synchronously before the\n * bidirectional sync sees the event).\n * - `destroyRef` cleanup of both directions.\n *\n * @internal\n */\nexport function createMatStepperBidirectionalSync(\n opts: CngxMatStepperBidirectionalSyncOptions,\n): void {\n createMaterialBidirectionalSync({\n presenterIndex: opts.presenter.activeStepIndex,\n readSelectedIndex: () => opts.matStepper.selectedIndex,\n writeSelectedIndex: (i) => {\n opts.matStepper.selectedIndex = i;\n },\n // `MatStepper.selectedIndexChange` emits a plain index - no adapter needed,\n // unlike `MatTabGroup.selectedIndexChange`.\n selectionChange$: opts.matStepper.selectedIndexChange.asObservable(),\n onMaterialSelection: (i) => opts.presenter.select(i),\n injector: opts.injector,\n destroyRef: opts.destroyRef,\n });\n}\n","import { computed, InjectionToken, signal, type Signal, type TemplateRef } from '@angular/core';\nimport type { MatStep } from '@angular/material/stepper';\n\nimport type { CngxErrorAggregatorContract } from '@cngx/common/interactive';\nimport type { CngxStepRegistration, CngxStepStatus } from '@cngx/common/stepper';\n\n/**\n * Shared `signal(undefined)` constant used as the `errorAggregator`\n * slot for every Material-instrumented step handle. The\n * instrumentation path does not bind cngx error-aggregation per\n * `MatStep` - Material's own visual error surface (driven by\n * `MatStep.hasError` / `MatStep.optional`) stays authoritative - so\n * per-step allocation of a writable signal would be dead capacity.\n *\n * @internal\n */\nconst NO_ERROR_AGGREGATOR: Signal<CngxErrorAggregatorContract | undefined> = signal<\n CngxErrorAggregatorContract | undefined\n>(undefined).asReadonly();\n\n/**\n * Wiring bundle returned from {@link createMatStepHandle}. The\n * instrumentation directive holds the bundle in a `Map<MatStep,\n * Setup>` for diff-only registry churn; only `handle` is exposed to\n * the presenter.\n */\nexport interface CngxMatStepHandleSetup {\n readonly handle: CngxStepRegistration;\n}\n\n/**\n * Best-effort static-text extraction from a `<ng-template matStepLabel>`\n * `TemplateRef`. Used as a label fallback when consumers project a\n * template label without setting `MatStep.label` or\n * `MatStep.ariaLabel` - without it the cngx-side label slot would\n * be empty, leaving aria-label phrases that include the step label\n * with a measurable gap on the Material variant. Static markup\n * (`<ng-template matStepLabel>Review</ng-template>`) extracts cleanly\n * via a detached embedded view; templates with dynamic interpolation\n * fall through (the detached view's CD has no consumer-context\n * bindings) and the caller's deterministic id-based fallback wins.\n *\n * Idempotent: never mutates the source template; the embedded view is\n * created and destroyed inside one frame's worth of synchronous work.\n *\n * @internal\n */\nfunction readMatStepLabelTemplateText(template: TemplateRef<unknown>): string | undefined {\n try {\n const view = template.createEmbeddedView({});\n try {\n view.detectChanges();\n const text = view.rootNodes\n .map((node: Node) => node.textContent ?? '')\n .join('')\n .trim();\n return text || undefined;\n } finally {\n view.destroy();\n }\n } catch {\n return undefined;\n }\n}\n\n/**\n * Translates a Material `MatStep` into a cngx\n * {@link CngxStepRegistration}.\n *\n * - `id` - always a fresh `idSeed()` value. Mirrors the tabs\n * instrumentation handle: a label-keyed id would collide when\n * two steps share a label.\n * - `kind` - fixed at `'step'`. The instrumentation path does not\n * project nested `<mat-step>` groups (Material's stepper has no\n * group-of-steps concept; group-aware semantics belong to the\n * `<cngx-stepper>` thin-wrapper organism).\n * - `label` - snapshot signal resolved through a four-tier fallback at\n * registration time so cngx-side phrases (announcements,\n * `aria-label` composition, telemetry) never read empty when\n * Material consumers project a `<ng-template matStepLabel>`:\n * 1. `MatStep.label` when it is a plain string - the canonical\n * shape and the only one that emits a runtime change Material\n * itself observes.\n * 2. `MatStep.ariaLabel` when the consumer set the input -\n * designed exactly as the substitute for template labels.\n * 3. Static-text read from `MatStep.stepLabel.template` via a\n * throwaway detached `EmbeddedViewRef` ({@link readMatStepLabelTemplateText}).\n * Captures literal `matStepLabel` markup; dynamic interpolation\n * bails through to (4).\n * 4. `Step <id>` - deterministic, derived from the cngx handle\n * id. Always non-empty.\n * Documented limitation: runtime label changes do not propagate.\n * CDK's `CdkStep` does not expose a `_stateChanges` Subject\n * analogous to `MatTab._stateChanges`, so cngx cannot re-trigger\n * the snapshot when Material flips the input later. Surface the\n * same Material-internal coupling family typed in\n * `MaterialPrivateSurfaces.CompletedOverrideSource`.\n * - `disabled` - fixed `false`. Material owns step gating via\n * `linear` + `editable` + `completed`; surfacing a cngx-side\n * `disabled` would duplicate Material's own click-time enforcement\n * and is ignored by `<mat-stepper>` itself.\n * - `state` - `computed()` over `MatStep.hasError` / `MatStep.completed`.\n * `CdkStep.completed`'s getter reads `_completedOverride()` - a\n * `WritableSignal<boolean | null>` typed in\n * `MaterialPrivateSurfaces.CompletedOverrideSource`. The cngx\n * computed transitively tracks that signal through the getter and\n * re-fires whenever Material flips completion. `hasError` is a\n * plain property setter on `CdkStep`, NOT a Signal - a `hasError`\n * write that is not paired with a `completed` change does not\n * re-trigger this computed. In practice Material wizards write the\n * two together (`step.hasError = true; step.completed = false` in\n * error-handler patterns and inside Material's own error-state\n * matchers) so the limitation is benign for the documented usage\n * pattern.\n * - `errorAggregator` - points at the shared\n * {@link NO_ERROR_AGGREGATOR} constant.\n *\n * @category ui/mat-stepper\n */\nexport function createMatStepHandle(\n matStep: MatStep,\n idSeed: () => string,\n): CngxMatStepHandleSetup {\n const id = idSeed();\n const labelText = resolveStepLabel(matStep, id);\n const label = signal<string>(labelText).asReadonly();\n const disabled = signal<boolean>(false).asReadonly();\n const state = computed<CngxStepStatus>(() => {\n if (matStep.hasError) {\n return 'error';\n }\n if (matStep.completed) {\n return 'success';\n }\n return 'idle';\n });\n return {\n handle: {\n id,\n kind: 'step',\n label,\n disabled,\n state,\n errorAggregator: NO_ERROR_AGGREGATOR,\n },\n };\n}\n\n/**\n * Four-tier label fallback walked once at registration time. See the\n * {@link createMatStepHandle} JSDoc for the full ladder rationale.\n *\n * @internal\n */\nfunction resolveStepLabel(matStep: MatStep, id: string): string {\n const labelInput = matStep.label;\n if (typeof labelInput === 'string' && labelInput.length > 0) {\n return labelInput;\n }\n const ariaLabel = matStep.ariaLabel;\n if (typeof ariaLabel === 'string' && ariaLabel.length > 0) {\n return ariaLabel;\n }\n const tpl = matStep.stepLabel?.template;\n if (tpl) {\n const text = readMatStepLabelTemplateText(tpl);\n if (text) {\n return text;\n }\n }\n return `Step ${id}`;\n}\n\n/**\n * Factory signature for {@link createMatStepHandle}. The DI token\n * {@link CNGX_MAT_STEP_HANDLE_FACTORY} resolves to a function with\n * this exact shape - overrides match it identically.\n *\n * @category ui/mat-stepper\n */\nexport type CngxMatStepHandleFactory = typeof createMatStepHandle;\n\n/**\n * DI token fronting the per-step handle factory used by the\n * `[cngxMatStepper]` instrumentation directive. Default is\n * {@link createMatStepHandle}.\n *\n * Symmetric with the tabs sibling\n * `CNGX_MAT_TAB_HANDLE_FACTORY` and with `CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY`\n * - every Material-bridge logic block ships the same swap surface so\n * consumers can layer telemetry, alternate id strategies, or\n * test-environment id keying via `providers` / `viewProviders`\n * without forking the directive.\n *\n * Override capability - the swap surface separates **handle shape**\n * (factory body) from **id keying** (the supplied `idSeed` closure).\n * The directive constructs `idSeed` as `() => nextUid('cngx-mat-step-')`\n * and hands it to the factory as a default suggestion; an override is\n * free to call it, ignore it, or replace it with a server-synced /\n * deterministic-test / consumer-domain id strategy. Both axes are\n * independently swappable from one DI seam.\n *\n * ```ts\n * providers: [\n * {\n * provide: CNGX_MAT_STEP_HANDLE_FACTORY,\n * useValue: ((step, idSeed) => {\n * const setup = createMatStepHandle(step, idSeed);\n * reportStepRegistered(setup.handle.id);\n * return setup;\n * }) satisfies CngxMatStepHandleFactory,\n * },\n * ]\n * ```\n *\n * @category ui/mat-stepper\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-stepper/material-bridge/handle.ts\n * @since 0.1.0\n */\nexport const CNGX_MAT_STEP_HANDLE_FACTORY = new InjectionToken<CngxMatStepHandleFactory>(\n 'CNGX_MAT_STEP_HANDLE_FACTORY',\n {\n providedIn: 'root',\n factory: () => createMatStepHandle,\n },\n);\n","import {\n contentChildren,\n type DestroyRef,\n Directive,\n effect,\n inject,\n type Injector,\n untracked,\n DestroyRef as InjectableDestroyRef,\n Injector as InjectableInjector,\n} from '@angular/core';\nimport { MatStep, MatStepper } from '@angular/material/stepper';\n\nimport { CNGX_STEPPER_HOST, CngxStepperPresenter } from '@cngx/common/stepper';\nimport { nextUid } from '@cngx/core/utils';\n\nimport { createMatStepperBidirectionalSync } from './material-bridge/bidirectional-sync';\nimport {\n CNGX_MAT_STEP_HANDLE_FACTORY,\n type CngxMatStepHandleSetup,\n} from './material-bridge/handle';\n\n/**\n * The Material twin of the CNGX stepper: attach `cngxMatStepper` to a\n * vanilla `<mat-stepper>` and it is bridged to a\n * {@link CngxStepperPresenter}. \\\n * Consumers gain the commit-action\n * lifecycle, `CNGX_STATEFUL` (so `<cngx-toast-on />` /\n * `<cngx-banner-on />` compose as children), the shared\n * `CNGX_STEPPER_HOST` contract (so a `<cngx-stepper-footer>` can drive\n * Back / Next instead of Material's own buttons via\n * `[host]=\"ref.presenter\"`), and the step-handle registry - all from\n * one attribute.\n *\n * This is the instrumentation pattern: Material owns the rendering and\n * the consumer authors native `<mat-step>` markup; CNGX is the\n * behaviour layer. Topology mirrors `[cngxMatTabs]`.\n *\n * Inputs/outputs are forwarded from {@link CngxStepperPresenter}:\n * - `activeStepIndex` (two-way, with `activeStepIndexChange`),\n * - `linear`,\n * - `orientation`,\n * - `commitAction`,\n * - `commitMode`. \\\n * See the presenter for their semantics.\n * ```html\n * <mat-stepper\n * cngxMatStepper\n * #s=\"cngxMatStepper\"\n * [(activeStepIndex)]=\"active\"\n * [commitAction]=\"commitAction\"\n * [commitMode]=\"mode()\"\n * cngxToastOn\n * [toastError]=\"'Step transition failed'\"\n * cngxBannerOn\n * bannerId=\"stepper:commit-error\"\n * [bannerError]=\"'The server rejected the step change.'\"\n * aria-label=\"Account setup\"\n * >\n * <mat-step label=\"Personal info\">\n * <p>Tell us who you are.</p>\n * </mat-step>\n * <mat-step\n * label=\"Account\"\n * [hasError]=\"!accepted()\"\n * errorMessage=\"Accept the terms to continue\"\n * >\n * <p>Choose your sign-in method.</p>\n * </mat-step>\n * <mat-step label=\"Confirm\">\n * <p>Review everything, then finish.</p>\n * </mat-step>\n * </mat-stepper>\n * ```\n * @playground Bridge instrumentation ./examples/bridge/bridge-example.component.ts\n *\n * @category ui/mat-stepper\n * @docsKind primary\n * @wcag AA\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-stepper/mat-stepper.directive.ts\n * @since 0.1.0\n * @relatedTo CngxStepper, CngxStepperPresenter, CngxMatTabs, CngxStepperFooter\n */\n@Directive({\n selector: '[cngxMatStepper]',\n exportAs: 'cngxMatStepper',\n standalone: true,\n hostDirectives: [\n {\n directive: CngxStepperPresenter,\n inputs: ['activeStepIndex', 'linear', 'orientation', 'commitAction', 'commitMode'],\n outputs: ['activeStepIndexChange'],\n },\n ],\n})\nexport class CngxMatStepper {\n private readonly matStepper = inject(MatStepper, { self: true });\n /**\n * Shared host contract. Public so a `<cngx-stepper-footer>` placed\n * outside the `<mat-stepper>` can bind `[host]=\"ref.presenter\"` (via\n * `#ref=\"cngxMatStepper\"`) and drive navigation.\n */\n readonly presenter = inject(CNGX_STEPPER_HOST);\n private readonly destroyRef: DestroyRef = inject(InjectableDestroyRef);\n private readonly injector: Injector = inject(InjectableInjector);\n\n private readonly matSteps = contentChildren(MatStep, { descendants: true });\n // Map not WeakMap - syncHandles needs to iterate to find removed steps.\n private readonly setupsByStep = new Map<MatStep, CngxMatStepHandleSetup>();\n private readonly createHandle = inject(CNGX_MAT_STEP_HANDLE_FACTORY);\n\n constructor() {\n effect(() => {\n const steps = this.matSteps();\n untracked(() => this.syncHandles(steps));\n });\n\n this.destroyRef.onDestroy(() => {\n for (const setup of this.setupsByStep.values()) {\n this.presenter.unregister(setup.handle.id);\n }\n this.setupsByStep.clear();\n });\n\n createMatStepperBidirectionalSync({\n matStepper: this.matStepper,\n presenter: this.presenter,\n injector: this.injector,\n destroyRef: this.destroyRef,\n });\n }\n\n private syncHandles(steps: readonly MatStep[]): void {\n const liveSteps = new Set<MatStep>(steps);\n\n // Only fresh MatSteps get registered; cached ones survive untouched.\n for (const step of steps) {\n if (this.setupsByStep.has(step)) {\n continue;\n }\n const setup = this.createHandle(step, () => nextUid('cngx-mat-step-'));\n this.setupsByStep.set(step, setup);\n this.presenter.register(setup.handle);\n }\n\n // Snapshot before iterating - guards against non-current-key deletes inside the body.\n for (const [step, setup] of Array.from(this.setupsByStep.entries())) {\n if (liveSteps.has(step)) {\n continue;\n }\n this.setupsByStep.delete(step);\n this.presenter.unregister(setup.handle.id);\n }\n }\n}\n","/**\n * Public API surface of `@cngx/ui/mat-stepper`.\n *\n * The Material twin of the cngx stepper family, shipped as the\n * instrumentation directive `[cngxMatStepper]`: attach it to a vanilla\n * `<mat-stepper>` and it composes the same `CngxStepperPresenter` brain\n * as `<cngx-stepper>` (in `@cngx/ui/stepper`) via `hostDirectives`, so\n * commit-action lifecycle, router sync, and error aggregation all work\n * against Material's own markup. Mirrors `[cngxMatTabs]`.\n */\nexport { CngxMatStepper } from './mat-stepper.directive';\nexport {\n CNGX_MAT_STEP_HANDLE_FACTORY,\n createMatStepHandle,\n type CngxMatStepHandleFactory,\n} from './material-bridge/handle';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["InjectableDestroyRef","InjectableInjector"],"mappings":";;;;;;;;AAyBA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAU,iCAAiC,CAC/C,IAA4C,EAAA;AAE5C,IAAA,+BAA+B,CAAC;AAC9B,QAAA,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe;QAC9C,iBAAiB,EAAE,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa;AACtD,QAAA,kBAAkB,EAAE,CAAC,CAAC,KAAI;AACxB,YAAA,IAAI,CAAC,UAAU,CAAC,aAAa,GAAG,CAAC;QACnC,CAAC;;;QAGD,gBAAgB,EAAE,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,YAAY,EAAE;AACpE,QAAA,mBAAmB,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QACpD,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,UAAU,EAAE,IAAI,CAAC,UAAU;AAC5B,KAAA,CAAC;AACJ;;AC1DA;;;;;;;;;AASG;AACH,MAAM,mBAAmB,GAAoD,MAAM,CAEjF,SAAS,CAAC,CAAC,UAAU,EAAE;AAYzB;;;;;;;;;;;;;;;;AAgBG;AACH,SAAS,4BAA4B,CAAC,QAA8B,EAAA;AAClE,IAAA,IAAI;QACF,MAAM,IAAI,GAAG,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;AAC5C,QAAA,IAAI;YACF,IAAI,CAAC,aAAa,EAAE;AACpB,YAAA,MAAM,IAAI,GAAG,IAAI,CAAC;iBACf,GAAG,CAAC,CAAC,IAAU,KAAK,IAAI,CAAC,WAAW,IAA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