@cngx/ui 0.0.1-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +550 -0
  3. package/action-button/README.md +98 -0
  4. package/empty-state/README.md +103 -0
  5. package/feedback/README.md +33 -0
  6. package/fesm2022/cngx-ui-action-button.mjs +319 -0
  7. package/fesm2022/cngx-ui-action-button.mjs.map +1 -0
  8. package/fesm2022/cngx-ui-empty-state.mjs +138 -0
  9. package/fesm2022/cngx-ui-empty-state.mjs.map +1 -0
  10. package/fesm2022/cngx-ui-feedback.mjs +2962 -0
  11. package/fesm2022/cngx-ui-feedback.mjs.map +1 -0
  12. package/fesm2022/cngx-ui-layout.mjs +89 -0
  13. package/fesm2022/cngx-ui-layout.mjs.map +1 -0
  14. package/fesm2022/cngx-ui-mat-stepper.mjs +567 -0
  15. package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -0
  16. package/fesm2022/cngx-ui-mat-tabs.mjs +1405 -0
  17. package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -0
  18. package/fesm2022/cngx-ui-material.mjs +79 -0
  19. package/fesm2022/cngx-ui-material.mjs.map +1 -0
  20. package/fesm2022/cngx-ui-overlay.mjs +91 -0
  21. package/fesm2022/cngx-ui-overlay.mjs.map +1 -0
  22. package/fesm2022/cngx-ui-sidenav.mjs +521 -0
  23. package/fesm2022/cngx-ui-sidenav.mjs.map +1 -0
  24. package/fesm2022/cngx-ui-skeleton.mjs +158 -0
  25. package/fesm2022/cngx-ui-skeleton.mjs.map +1 -0
  26. package/fesm2022/cngx-ui-speak.mjs +112 -0
  27. package/fesm2022/cngx-ui-speak.mjs.map +1 -0
  28. package/fesm2022/cngx-ui-stepper.mjs +312 -0
  29. package/fesm2022/cngx-ui-stepper.mjs.map +1 -0
  30. package/fesm2022/cngx-ui-tabs.mjs +507 -0
  31. package/fesm2022/cngx-ui-tabs.mjs.map +1 -0
  32. package/fesm2022/cngx-ui.mjs +45 -0
  33. package/fesm2022/cngx-ui.mjs.map +1 -0
  34. package/layout/README.md +133 -0
  35. package/mat-stepper/README.md +34 -0
  36. package/mat-tabs/README.md +163 -0
  37. package/mat-tabs/styles/mat-tabs.css +233 -0
  38. package/material/README.md +90 -0
  39. package/overlay/README.md +99 -0
  40. package/package.json +98 -0
  41. package/sidenav/README.md +127 -0
  42. package/skeleton/README.md +98 -0
  43. package/speak/README.md +93 -0
  44. package/speak/speak-button-theme.scss +78 -0
  45. package/stepper/README.md +40 -0
  46. package/tabs/README.md +28 -0
  47. package/types/cngx-ui-action-button.d.ts +126 -0
  48. package/types/cngx-ui-empty-state.d.ts +41 -0
  49. package/types/cngx-ui-feedback.d.ts +1174 -0
  50. package/types/cngx-ui-layout.d.ts +56 -0
  51. package/types/cngx-ui-mat-stepper.d.ts +234 -0
  52. package/types/cngx-ui-mat-tabs.d.ts +664 -0
  53. package/types/cngx-ui-material.d.ts +36 -0
  54. package/types/cngx-ui-overlay.d.ts +57 -0
  55. package/types/cngx-ui-sidenav.d.ts +209 -0
  56. package/types/cngx-ui-skeleton.d.ts +97 -0
  57. package/types/cngx-ui-speak.d.ts +31 -0
  58. package/types/cngx-ui-stepper.d.ts +129 -0
  59. package/types/cngx-ui-tabs.d.ts +165 -0
  60. package/types/cngx-ui.d.ts +18 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cngx-ui-layout.mjs","sources":["../../../projects/ui/layout/stack.component.ts","../../../projects/ui/layout/grid.component.ts","../../../projects/ui/layout/public-api.ts","../../../projects/ui/layout/cngx-ui-layout.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';\n\n/** Main-axis direction for {@link CngxStack}. */\nexport type StackDirection = 'row' | 'column';\n/** Cross-axis alignment for {@link CngxStack}. */\nexport type StackAlign = 'start' | 'center' | 'end' | 'stretch';\n/** Spacing scale for {@link CngxStack}. Maps to `--cngx-gap-*` tokens. */\nexport type StackGap = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\nconst GAP_DEFAULTS: Record<StackGap, string> = {\n none: '0',\n xs: 'var(--cngx-gap-xs, 4px)',\n sm: 'var(--cngx-gap-sm, 8px)',\n md: 'var(--cngx-gap-md, 16px)',\n lg: 'var(--cngx-gap-lg, 24px)',\n xl: 'var(--cngx-gap-xl, 32px)',\n};\n\n/**\n * Composable flex-based stack layout component.\n *\n * Gap tokens use CSS custom properties (`--cngx-gap-xs` through `--cngx-gap-xl`)\n * with sensible fallback defaults. Override them at any scope to match your\n * application's spacing scale.\n *\n * <cngx-stack direction=\"row\" gap=\"md\" align=\"center\">\n * <div>Item 1</div>\n * <div>Item 2</div>\n * </cngx-stack>\n */\n@Component({\n selector: 'cngx-stack',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: '<ng-content />',\n styles: [\n `\n :host {\n display: flex;\n }\n `,\n ],\n host: {\n '[style.flex-direction]': 'direction()',\n '[style.align-items]': 'alignItems()',\n '[style.gap]': 'gapValue()',\n },\n})\nexport class CngxStack {\n /** Flex direction of the stack. */\n readonly direction = input<StackDirection>('column');\n /** Named spacing token between stack items. Resolves via `--cngx-gap-*` CSS custom properties. */\n readonly gap = input<StackGap>('md');\n /** Cross-axis alignment of stack items. */\n readonly align = input<StackAlign>('stretch');\n\n /** @internal */\n protected readonly alignItems = computed(() => {\n const alignValue = this.align();\n return alignValue === 'stretch' ? 'stretch' : `flex-${alignValue}`;\n });\n\n /** @internal */\n protected readonly gapValue = computed(() => GAP_DEFAULTS[this.gap()]);\n}\n","import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';\n\n/**\n * Composable CSS grid layout component.\n *\n * <cngx-grid columns=\"3\" gap=\"16px\">\n * <div>Cell 1</div>\n * <div>Cell 2</div>\n * </cngx-grid>\n */\n@Component({\n selector: 'cngx-grid',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: '<ng-content />',\n styles: [\n `\n :host {\n display: grid;\n }\n `,\n ],\n host: {\n '[style.grid-template-columns]': 'gridTemplateColumns()',\n '[style.gap]': 'gap()',\n },\n})\nexport class CngxGrid {\n /** Number of equal columns, or a custom `grid-template-columns` value. */\n readonly columns = input<number | string>(1);\n /** CSS gap between cells. */\n readonly gap = input('16px');\n\n /** @internal */\n protected readonly gridTemplateColumns = computed(() => {\n const cols = this.columns();\n return typeof cols === 'number' ? `repeat(${cols}, 1fr)` : cols;\n });\n}\n","/**\n * Public API Surface of @cngx/ui/layout\n * @module @cngx/ui/layout\n */\n\nexport * from './stack.component';\nexport * from './grid.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"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"}
@@ -0,0 +1,567 @@
1
+ import * as i2 from '@angular/common';
2
+ import { CommonModule } from '@angular/common';
3
+ 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';
7
+ 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';
11
+ import { nextUid } from '@cngx/core/utils';
12
+
13
+ /**
14
+ * Stepper-specific glue over {@link createMaterialBidirectionalSync}
15
+ * (`@cngx/common/data`). Both `<cngx-mat-stepper>` (Component) and
16
+ * `[cngxMatStepper]` (Directive) need to install the same
17
+ * presenter↔Material `selectedIndex` sync; the option-mapping body
18
+ * was identical at both call sites — same `presenterIndex`, same
19
+ * `readSelectedIndex` / `writeSelectedIndex` shape, same
20
+ * `selectedIndexChange.asObservable()` source, same
21
+ * `onMaterialSelection` write-back. This helper is the single entry
22
+ * point: each call site reduces to one line.
23
+ *
24
+ * Behaviour stays identical to the prior inline blocks — the helper
25
+ * is a pure shape-adapter, no policy. The underlying generic factory
26
+ * owns:
27
+ * - presenter→Material `effect()` with read-equality guard.
28
+ * - Material→presenter subscription with re-entrancy guard.
29
+ * - Material-eager-advance reconciliation
30
+ * (`tabs-accepted-debt §6` closure path; same code path applies
31
+ * here because Material's MDC click handler advances
32
+ * `selectedIndex` synchronously before the bidirectional sync sees
33
+ * the event).
34
+ * - `destroyRef` cleanup of both directions.
35
+ *
36
+ * Phase 7.2 of `mat-stepper-mat-tabs-hardening-plan` extracted this
37
+ * helper to close E-C12 + E-C13 (duplicated bidirectional-sync glue
38
+ * between the wrapper component and the instrumentation directive).
39
+ */
40
+ function createMatStepperBidirectionalSync(opts) {
41
+ createMaterialBidirectionalSync({
42
+ presenterIndex: opts.presenter.activeStepIndex,
43
+ readSelectedIndex: () => opts.matStepper.selectedIndex,
44
+ writeSelectedIndex: (i) => {
45
+ opts.matStepper.selectedIndex = i;
46
+ },
47
+ // `MatStepper.selectedIndexChange` already emits a plain index,
48
+ // so no `.pipe(map(e => e.selectedIndex))` adapter is needed —
49
+ // mirrors the `MatTabGroup.selectedIndexChange` shape used by
50
+ // `[cngxMatTabs]`.
51
+ selectionChange$: opts.matStepper.selectedIndexChange.asObservable(),
52
+ onMaterialSelection: (i) => opts.presenter.select(i),
53
+ injector: opts.injector,
54
+ destroyRef: opts.destroyRef,
55
+ });
56
+ }
57
+
58
+ /**
59
+ * Material-twin stepper organism. Wraps `<mat-stepper>` and shares
60
+ * the `CngxStepperPresenter` brain with `<cngx-stepper>` — Material
61
+ * consumers gain the commit-action lifecycle, router sync, and error
62
+ * aggregation.
63
+ *
64
+ * Bidirectional sync between presenter and `MatStepper.selectedIndex`
65
+ * runs in a single `effect()` with `untracked()` writes so neither
66
+ * direction tracks the other.
67
+ *
68
+ * Material owns keyboard nav and focus on `MatStepperHeader`, so the
69
+ * organism does NOT compose `CngxRovingTabindex` /
70
+ * `CngxFocusRestore`. Group nodes flatten — `<mat-stepper>` does not
71
+ * support nesting — with the depth preserved as a `data-step-depth`
72
+ * hint on the rendered label.
73
+ */
74
+ class CngxMatStepper {
75
+ presenter = inject(CNGX_STEPPER_HOST);
76
+ destroyRef = inject(DestroyRef);
77
+ injector = inject(Injector);
78
+ matStepper = viewChild.required(MatStepper);
79
+ // Host CD nudge after the `_iconOverrides` patch — Material reads
80
+ // the map into per-header `[iconOverrides]` bindings on the next
81
+ // CD pass, so the patch only takes effect once we mark the host
82
+ // view dirty.
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
+ * `tabs-accepted-debt §5`.
96
+ */
97
+ stepperIcons = contentChildren(MatStepperIcon, ...(ngDevMode ? [{ debugName: "stepperIcons" }] : /* istanbul ignore next */ []));
98
+ /**
99
+ * `Map<id, CngxStep>` so `labelTemplateFor` / `contentTemplateFor`
100
+ * are O(1). Structural `equal` on the id-set + per-id directive
101
+ * identity stops the map from cascading on shape-stable
102
+ * `contentChildren` re-emits.
103
+ */
104
+ stepDirectiveById = inject(CNGX_DIRECTIVE_BY_ID_MAP_FACTORY)({
105
+ source: this.stepDirectives,
106
+ });
107
+ /**
108
+ * Step-only flat projection — `<mat-step>` does not nest, so
109
+ * groups collapse into the same level. Memoised via
110
+ * `flatStepsEqual` so consumers (`stepLabel`, panel `@for`,
111
+ * `stepLabelContextFor`) don't re-walk on shape-stable
112
+ * `flatSteps()` re-emits. Sibling-symmetric with
113
+ * `CngxStepper.stepsOnly`.
114
+ */
115
+ stepsOnly = computed(() => this.presenter.flatSteps().filter((n) => n.kind === 'step'), { ...(ngDevMode ? { debugName: "stepsOnly" } : /* istanbul ignore next */ {}), equal: flatStepsEqual });
116
+ /** Material orientation literal — narrows our `'horizontal'|'vertical'` to its own union. */
117
+ matOrientation = computed(() => (this.presenter.orientation() === 'vertical' ? 'vertical' : 'horizontal'), ...(ngDevMode ? [{ debugName: "matOrientation" }] : /* istanbul ignore next */ []));
118
+ stepIndexOf(node) {
119
+ return node.flatIndex;
120
+ }
121
+ /** Editability rule — non-linear lets every step click; linear only past completed. */
122
+ isEditable(node) {
123
+ return !this.presenter.linear() || node.state() === 'success';
124
+ }
125
+ hasError(node) {
126
+ return node.state() === 'error';
127
+ }
128
+ isCompleted(node) {
129
+ return node.state() === 'success';
130
+ }
131
+ stepLabel(node) {
132
+ return node.label();
133
+ }
134
+ /** Group nodes carry a depth marker so the label can distinguish nested rows. */
135
+ stepDepth(node) {
136
+ return node.depth;
137
+ }
138
+ // Material twin honours only `*cngxStepLabel` / `*cngxStepContent`
139
+ // — the six other cngx slot directives are silently dropped because
140
+ // Material owns the indicator/badge/busy chrome. The override path
141
+ // is `<ng-template matStepperIcon>`. stepper-accepted-debt §4.
142
+ labelTemplateFor(id) {
143
+ return this.stepDirectiveById().get(id)?.labelTemplate()?.templateRef ?? null;
144
+ }
145
+ contentTemplateFor(id) {
146
+ return this.stepDirectiveById().get(id)?.contentTemplate()?.templateRef ?? null;
147
+ }
148
+ /**
149
+ * Per-node-id slot-context cache for `*cngxStepLabel` /
150
+ * `*cngxStepContent`. Mutating fields in place preserves the
151
+ * object reference, so `*ngTemplateOutlet`'s `Object.is` diff
152
+ * short-circuits the embedded-view rebind; the embedded view's
153
+ * `let-` bindings re-read the mutated fields on the next CD pass.
154
+ * Stale ids are pruned by the constructor effect tied to
155
+ * `presenter.flatSteps`.
156
+ */
157
+ stepLabelContextCache = new Map();
158
+ /** Build the {@link CngxStepLabelContext} for the projected label template. */
159
+ stepLabelContextFor(node) {
160
+ const flatStep = node.flatIndex;
161
+ const active = node.id === this.presenter.activeStepId();
162
+ const busy = this.presenter.commitState.status() === 'pending' &&
163
+ this.presenter.intendedStepIndex() === flatStep;
164
+ const disabled = node.disabled();
165
+ const existing = this.stepLabelContextCache.get(node.id);
166
+ if (!existing) {
167
+ const fresh = {
168
+ node,
169
+ index: flatStep + 1,
170
+ active,
171
+ busy,
172
+ disabled,
173
+ };
174
+ this.stepLabelContextCache.set(node.id, fresh);
175
+ return fresh;
176
+ }
177
+ // Mutate cached fields in place. `readonly` is a TS-only annotation;
178
+ // the cast removes it for the assignment without affecting the
179
+ // public consumer surface.
180
+ const mutable = existing;
181
+ mutable.node = node;
182
+ mutable.index = flatStep + 1;
183
+ mutable.active = active;
184
+ mutable.busy = busy;
185
+ mutable.disabled = disabled;
186
+ return existing;
187
+ }
188
+ /** Build the {@link CngxStepContentContext} for the projected content template. */
189
+ stepContentContextFor(node) {
190
+ return this.stepLabelContextFor(node);
191
+ }
192
+ constructor() {
193
+ // Prune stale `stepLabelContextCache` entries when the flat-step
194
+ // set changes shape — without this, removed node-ids leak their
195
+ // entries forever.
196
+ effect(() => {
197
+ const flat = this.presenter.flatSteps();
198
+ untracked(() => {
199
+ const liveIds = new Set();
200
+ for (const n of flat) {
201
+ liveIds.add(n.id);
202
+ }
203
+ for (const id of Array.from(this.stepLabelContextCache.keys())) {
204
+ if (!liveIds.has(id)) {
205
+ this.stepLabelContextCache.delete(id);
206
+ }
207
+ }
208
+ });
209
+ });
210
+ // `afterNextRender` — `viewChild.required(MatStepper)` isn't
211
+ // resolved until the view commits.
212
+ afterNextRender(() => {
213
+ const stepper = this.matStepper();
214
+ createMatStepperBidirectionalSync({
215
+ matStepper: stepper,
216
+ presenter: this.presenter,
217
+ injector: this.injector,
218
+ destroyRef: this.destroyRef,
219
+ });
220
+ // Forward consumer-projected `<ng-template matStepperIcon>` into
221
+ // `MatStepper._iconOverrides`. Direct `<ng-content>` projection
222
+ // never reaches Material's `@ContentChildren(MatStepperIcon)` —
223
+ // content-init resolves the inner queries before the wrapper's
224
+ // projection lands. Underscore reach typed via
225
+ // `MaterialPrivateSurfaces.IconOverrideHost`; tabs-accepted-debt §5.
226
+ // Dev-mode guard surfaces a Material rename/removal early.
227
+ const stepperRef = stepper;
228
+ const iconList = this.stepperIcons();
229
+ if (!stepperRef._iconOverrides) {
230
+ if (typeof ngDevMode !== 'undefined' && ngDevMode && iconList.length) {
231
+ console.warn('[CngxMatStepper] MatStepper._iconOverrides is missing — ' +
232
+ 'consumer-projected <ng-template matStepperIcon> templates ' +
233
+ 'will not flow through to Material. Likely cause: a ' +
234
+ 'Material upgrade renamed or removed the internal slot. ' +
235
+ 'See stepper-accepted-debt §4 for the closure mechanism.');
236
+ }
237
+ return;
238
+ }
239
+ for (const icon of iconList) {
240
+ stepperRef._iconOverrides[icon.name] = icon.templateRef;
241
+ }
242
+ // Material reads `_iconOverrides` into per-header bindings on
243
+ // the next CD pass — mark the host view dirty so Angular
244
+ // re-runs CD over `<mat-stepper>` and the patched map flows
245
+ // through. Touching `selectedIndex` would echo through
246
+ // `createMaterialBidirectionalSync`; `markForCheck` does not.
247
+ this.hostCdr.markForCheck();
248
+ });
249
+ }
250
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatStepper, deps: [], target: i0.ɵɵFactoryTarget.Component });
251
+ 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", 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 });
252
+ }
253
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatStepper, decorators: [{
254
+ type: Component,
255
+ args: [{ selector: 'cngx-mat-stepper', exportAs: 'cngxMatStepper', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [CommonModule, MatStepperModule], hostDirectives: [
256
+ {
257
+ directive: CngxStepperPresenter,
258
+ inputs: ['activeStepIndex', 'linear', 'orientation', 'commitAction', 'commitMode'],
259
+ outputs: ['activeStepIndexChange'],
260
+ },
261
+ ], 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" }]
262
+ }], 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 }] }] } });
263
+
264
+ /**
265
+ * Shared `signal(undefined)` constant used as the `errorAggregator`
266
+ * slot for every Material-instrumented step handle. The
267
+ * instrumentation path does not bind cngx error-aggregation per
268
+ * `MatStep` — Material's own visual error surface (driven by
269
+ * `MatStep.hasError` / `MatStep.optional`) stays authoritative — so
270
+ * per-step allocation of a writable signal would be dead capacity.
271
+ *
272
+ * @internal
273
+ */
274
+ const NO_ERROR_AGGREGATOR = signal(undefined).asReadonly();
275
+ /**
276
+ * Best-effort static-text extraction from a `<ng-template matStepLabel>`
277
+ * `TemplateRef`. Used as a label fallback when consumers project a
278
+ * template label without setting `MatStep.label` or
279
+ * `MatStep.ariaLabel` — without it the cngx-side label slot would
280
+ * be empty, leaving aria-label phrases that include the step label
281
+ * with a measurable gap on the Material variant. Static markup
282
+ * (`<ng-template matStepLabel>Review</ng-template>`) extracts cleanly
283
+ * via a detached embedded view; templates with dynamic interpolation
284
+ * fall through (the detached view's CD has no consumer-context
285
+ * bindings) and the caller's deterministic id-based fallback wins.
286
+ *
287
+ * Idempotent: never mutates the source template; the embedded view is
288
+ * created and destroyed inside one frame's worth of synchronous work.
289
+ *
290
+ * @internal
291
+ */
292
+ function readMatStepLabelTemplateText(template) {
293
+ try {
294
+ const view = template.createEmbeddedView({});
295
+ try {
296
+ view.detectChanges();
297
+ const text = view.rootNodes
298
+ .map((node) => node.textContent ?? '')
299
+ .join('')
300
+ .trim();
301
+ return text || undefined;
302
+ }
303
+ finally {
304
+ view.destroy();
305
+ }
306
+ }
307
+ catch {
308
+ return undefined;
309
+ }
310
+ }
311
+ /**
312
+ * Translates a Material `MatStep` into a cngx
313
+ * {@link CngxStepRegistration}.
314
+ *
315
+ * - `id` — always a fresh `idSeed()` value. Mirrors the tabs
316
+ * instrumentation handle: a label-keyed id would collide when
317
+ * two steps share a label.
318
+ * - `kind` — fixed at `'step'`. The instrumentation path does not
319
+ * project nested `<mat-step>` groups (Material's stepper has no
320
+ * group-of-steps concept; group-aware semantics belong to the
321
+ * `<cngx-stepper>` thin-wrapper organism).
322
+ * - `label` — snapshot signal resolved through a four-tier fallback at
323
+ * registration time so cngx-side phrases (announcements,
324
+ * `aria-label` composition, telemetry) never read empty when
325
+ * Material consumers project a `<ng-template matStepLabel>`:
326
+ * 1. `MatStep.label` when it is a plain string — the canonical
327
+ * shape and the only one that emits a runtime change Material
328
+ * itself observes.
329
+ * 2. `MatStep.ariaLabel` when the consumer set the input —
330
+ * designed exactly as the substitute for template labels.
331
+ * 3. Static-text read from `MatStep.stepLabel.template` via a
332
+ * throwaway detached `EmbeddedViewRef` ({@link readMatStepLabelTemplateText}).
333
+ * Captures literal `matStepLabel` markup; dynamic interpolation
334
+ * bails through to (4).
335
+ * 4. `Step <id>` — deterministic, derived from the cngx handle
336
+ * id. Always non-empty.
337
+ * Phase-2 limitation: runtime label changes do not propagate. CDK's
338
+ * `CdkStep` does not expose a `_stateChanges` Subject analogous to
339
+ * `MatTab._stateChanges`, so cngx cannot re-trigger the snapshot
340
+ * when Material flips the input later. Tracked under
341
+ * `stepper-accepted-debt §4` alongside the matStepperIcon
342
+ * forwarding limitations — both surface the same Material-internal
343
+ * coupling family typed in
344
+ * `MaterialPrivateSurfaces.CompletedOverrideSource` (see Phase 6.1).
345
+ * - `disabled` — fixed `false`. Material owns step gating via
346
+ * `linear` + `editable` + `completed`; surfacing a cngx-side
347
+ * `disabled` would duplicate Material's own click-time enforcement
348
+ * and is ignored by `<mat-stepper>` itself.
349
+ * - `state` — `computed()` over `MatStep.hasError` / `MatStep.completed`.
350
+ * `CdkStep.completed`'s getter reads `_completedOverride()` — a
351
+ * `WritableSignal<boolean | null>` typed in
352
+ * `MaterialPrivateSurfaces.CompletedOverrideSource`. The cngx
353
+ * computed transitively tracks that signal through the getter and
354
+ * re-fires whenever Material flips completion. `hasError` is a
355
+ * plain property setter on `CdkStep`, NOT a Signal — a `hasError`
356
+ * write that is not paired with a `completed` change does not
357
+ * re-trigger this computed. In practice Material wizards write the
358
+ * two together (`step.hasError = true; step.completed = false` in
359
+ * error-handler patterns and inside Material's own error-state
360
+ * matchers) so the limitation is benign for the documented usage
361
+ * pattern. Tracked under `stepper-accepted-debt §4` as the
362
+ * `_completedOverride` re-fire contract; the Re-Eval Trigger fires
363
+ * when Material exposes a public `_stateChanges`-equivalent Subject
364
+ * on `CdkStep` OR a consumer issue confirms an unpaired-`hasError`
365
+ * write reaches production.
366
+ * - `errorAggregator` — points at the shared
367
+ * {@link NO_ERROR_AGGREGATOR} constant.
368
+ */
369
+ function createMatStepHandle(matStep, idSeed) {
370
+ const id = idSeed();
371
+ const labelText = resolveStepLabel(matStep, id);
372
+ const label = signal(labelText).asReadonly();
373
+ const disabled = signal(false).asReadonly();
374
+ const state = computed(() => {
375
+ if (matStep.hasError) {
376
+ return 'error';
377
+ }
378
+ if (matStep.completed) {
379
+ return 'success';
380
+ }
381
+ return 'idle';
382
+ }, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
383
+ return {
384
+ handle: {
385
+ id,
386
+ kind: 'step',
387
+ label,
388
+ disabled,
389
+ state,
390
+ errorAggregator: NO_ERROR_AGGREGATOR,
391
+ },
392
+ };
393
+ }
394
+ /**
395
+ * Four-tier label fallback walked once at registration time. See the
396
+ * {@link createMatStepHandle} JSDoc for the full ladder rationale.
397
+ *
398
+ * @internal
399
+ */
400
+ function resolveStepLabel(matStep, id) {
401
+ const labelInput = matStep.label;
402
+ if (typeof labelInput === 'string' && labelInput.length > 0) {
403
+ return labelInput;
404
+ }
405
+ const ariaLabel = matStep.ariaLabel;
406
+ if (typeof ariaLabel === 'string' && ariaLabel.length > 0) {
407
+ return ariaLabel;
408
+ }
409
+ const tpl = matStep.stepLabel?.template;
410
+ if (tpl) {
411
+ const text = readMatStepLabelTemplateText(tpl);
412
+ if (text) {
413
+ return text;
414
+ }
415
+ }
416
+ return `Step ${id}`;
417
+ }
418
+ /**
419
+ * DI token fronting the per-step handle factory used by the
420
+ * `[cngxMatStepper]` instrumentation directive. Default is
421
+ * {@link createMatStepHandle}.
422
+ *
423
+ * Symmetric with the tabs sibling
424
+ * `CNGX_MAT_TAB_HANDLE_FACTORY` and with `CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY`
425
+ * — every Material-bridge logic block ships the same swap surface so
426
+ * consumers can layer telemetry, alternate id strategies, or
427
+ * test-environment id keying via `providers` / `viewProviders`
428
+ * without forking the directive.
429
+ *
430
+ * Override capability — the swap surface separates **handle shape**
431
+ * (factory body) from **id keying** (the supplied `idSeed` closure).
432
+ * The directive constructs `idSeed` as `() => nextUid('cngx-mat-step-')`
433
+ * and hands it to the factory as a default suggestion; an override is
434
+ * free to call it, ignore it, or replace it with a server-synced /
435
+ * deterministic-test / consumer-domain id strategy. Both axes are
436
+ * independently swappable from one DI seam.
437
+ *
438
+ * Tracked-debt: ships under family-uniformity staging (single
439
+ * in-package consumer today). See `stepper-accepted-debt §7`.
440
+ *
441
+ * ```ts
442
+ * providers: [
443
+ * {
444
+ * provide: CNGX_MAT_STEP_HANDLE_FACTORY,
445
+ * useValue: ((step, idSeed) => {
446
+ * const setup = createMatStepHandle(step, idSeed);
447
+ * reportStepRegistered(setup.handle.id);
448
+ * return setup;
449
+ * }) satisfies CngxMatStepHandleFactory,
450
+ * },
451
+ * ]
452
+ * ```
453
+ */
454
+ const CNGX_MAT_STEP_HANDLE_FACTORY = new InjectionToken('CNGX_MAT_STEP_HANDLE_FACTORY', {
455
+ providedIn: 'root',
456
+ factory: () => createMatStepHandle,
457
+ });
458
+
459
+ /**
460
+ * Attaches to an existing `<mat-stepper>` and bridges it to a
461
+ * {@link CngxStepperPresenter} — consumers gain the commit-action
462
+ * lifecycle, `CNGX_STATEFUL` (so `<cngx-toast-on />` /
463
+ * `<cngx-banner-on />` compose as children), and the step-handle
464
+ * registry from one attribute.
465
+ *
466
+ * Sibling-additive to `<cngx-mat-stepper>` (the thin-wrapper
467
+ * organism in `@cngx/ui/mat-stepper`): the wrapper authors fresh
468
+ * markup, this directive upgrades existing Material markup.
469
+ * `exportAs` differs (`cngxMatStepperDirective`) to avoid colliding
470
+ * with the wrapper's `cngxMatStepper`.
471
+ *
472
+ * Topology mirrors `[cngxMatTabs]`: Material is the host, cngx is
473
+ * the instrumentation layer. `stepper-accepted-debt §1`'s blocker
474
+ * applies to adoption, not this direction.
475
+ */
476
+ class CngxMatStepperBridge {
477
+ matStepper = inject(MatStepper, { self: true });
478
+ presenter = inject(CNGX_STEPPER_HOST);
479
+ destroyRef = inject(DestroyRef);
480
+ injector = inject(Injector);
481
+ matSteps = contentChildren(MatStep, { ...(ngDevMode ? { debugName: "matSteps" } : /* istanbul ignore next */ {}), descendants: true });
482
+ // Per-step registry — strong refs are bounded by the directive's
483
+ // lifetime; `Map` (not `WeakMap`) so the diff loop in
484
+ // `syncHandles` can iterate to find removed steps without a
485
+ // parallel `Set<MatStep>`.
486
+ setupsByStep = new Map();
487
+ createHandle = inject(CNGX_MAT_STEP_HANDLE_FACTORY);
488
+ constructor() {
489
+ effect(() => {
490
+ const steps = this.matSteps();
491
+ untracked(() => this.syncHandles(steps));
492
+ });
493
+ this.destroyRef.onDestroy(() => {
494
+ for (const setup of this.setupsByStep.values()) {
495
+ this.presenter.unregister(setup.handle.id);
496
+ }
497
+ this.setupsByStep.clear();
498
+ });
499
+ createMatStepperBidirectionalSync({
500
+ matStepper: this.matStepper,
501
+ presenter: this.presenter,
502
+ injector: this.injector,
503
+ destroyRef: this.destroyRef,
504
+ });
505
+ }
506
+ syncHandles(steps) {
507
+ const liveSteps = new Set(steps);
508
+ // Add: only fresh MatSteps get a setup + handle registration.
509
+ // Cached MatSteps survive untouched — no register-churn.
510
+ for (const step of steps) {
511
+ if (this.setupsByStep.has(step)) {
512
+ continue;
513
+ }
514
+ const setup = this.createHandle(step, () => nextUid('cngx-mat-step-'));
515
+ this.setupsByStep.set(step, setup);
516
+ this.presenter.register(setup.handle);
517
+ }
518
+ // Snapshot before iterating — defends against future edits that
519
+ // introduce non-current-key deletes inside the body.
520
+ for (const [step, setup] of Array.from(this.setupsByStep.entries())) {
521
+ if (liveSteps.has(step)) {
522
+ continue;
523
+ }
524
+ this.setupsByStep.delete(step);
525
+ this.presenter.unregister(setup.handle.id);
526
+ }
527
+ }
528
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatStepperBridge, deps: [], target: i0.ɵɵFactoryTarget.Directive });
529
+ 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 });
530
+ }
531
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatStepperBridge, decorators: [{
532
+ type: Directive,
533
+ args: [{
534
+ selector: '[cngxMatStepper]',
535
+ exportAs: 'cngxMatStepperDirective',
536
+ standalone: true,
537
+ hostDirectives: [
538
+ {
539
+ directive: CngxStepperPresenter,
540
+ inputs: [
541
+ 'activeStepIndex',
542
+ 'linear',
543
+ 'orientation',
544
+ 'commitAction',
545
+ 'commitMode',
546
+ ],
547
+ outputs: ['activeStepIndexChange'],
548
+ },
549
+ ],
550
+ }]
551
+ }], ctorParameters: () => [], propDecorators: { matSteps: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => MatStep), { ...{ descendants: true }, isSignal: true }] }] } });
552
+
553
+ /**
554
+ * Public API surface of `@cngx/ui/mat-stepper`.
555
+ *
556
+ * Material-twin organism for the cngx stepper family. Composes the same
557
+ * `CngxStepperPresenter` brain as `<cngx-stepper>` (in `@cngx/ui/stepper`)
558
+ * via `hostDirectives`, so commit-action lifecycle, router sync, and
559
+ * error aggregation all work identically against `<mat-stepper>`.
560
+ */
561
+
562
+ /**
563
+ * Generated bundle index. Do not edit.
564
+ */
565
+
566
+ export { CNGX_MAT_STEP_HANDLE_FACTORY, CngxMatStepper, CngxMatStepperBridge, createMatStepHandle };
567
+ //# sourceMappingURL=cngx-ui-mat-stepper.mjs.map