@cngx/ui 0.0.1-rc.0 → 0.1.0-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.
- package/README.md +22 -48
- package/action-button/README.md +9 -11
- package/empty-state/README.md +11 -26
- package/feedback/README.md +3 -3
- package/fesm2022/cngx-ui-action-button.mjs +30 -26
- package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
- package/fesm2022/cngx-ui-empty-state.mjs +26 -21
- package/fesm2022/cngx-ui-empty-state.mjs.map +1 -1
- package/fesm2022/cngx-ui-feedback.mjs +498 -261
- package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
- package/fesm2022/cngx-ui-layout.mjs +32 -5
- package/fesm2022/cngx-ui-layout.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-stepper.mjs +79 -104
- package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-tabs.mjs +111 -83
- package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-material.mjs +14 -3
- package/fesm2022/cngx-ui-material.mjs.map +1 -1
- package/fesm2022/cngx-ui-overlay.mjs +22 -3
- package/fesm2022/cngx-ui-overlay.mjs.map +1 -1
- package/fesm2022/cngx-ui-sidenav.mjs +107 -28
- package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
- package/fesm2022/cngx-ui-skeleton.mjs +61 -20
- package/fesm2022/cngx-ui-skeleton.mjs.map +1 -1
- package/fesm2022/cngx-ui-speak.mjs +14 -5
- package/fesm2022/cngx-ui-speak.mjs.map +1 -1
- package/fesm2022/cngx-ui-stepper.mjs +484 -161
- package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
- package/fesm2022/cngx-ui-tabs.mjs +75 -39
- package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui.mjs +2 -1
- package/fesm2022/cngx-ui.mjs.map +1 -1
- package/layout/README.md +9 -44
- package/mat-stepper/README.md +7 -10
- package/mat-tabs/README.md +13 -13
- package/mat-tabs/styles/mat-tabs.css +339 -213
- package/material/README.md +19 -19
- package/overlay/README.md +11 -11
- package/package.json +5 -4
- package/sidenav/README.md +4 -19
- package/skeleton/README.md +3 -17
- package/speak/README.md +15 -15
- package/stepper/README.md +139 -5
- package/tabs/README.md +4 -4
- package/theming/system-tokens.css +29 -0
- package/types/cngx-ui-action-button.d.ts +28 -13
- package/types/cngx-ui-empty-state.d.ts +21 -9
- package/types/cngx-ui-feedback.d.ts +437 -121
- package/types/cngx-ui-layout.d.ts +38 -8
- package/types/cngx-ui-mat-stepper.d.ts +58 -43
- package/types/cngx-ui-mat-tabs.d.ts +122 -72
- package/types/cngx-ui-material.d.ts +12 -1
- package/types/cngx-ui-overlay.d.ts +25 -4
- package/types/cngx-ui-sidenav.d.ts +106 -12
- package/types/cngx-ui-skeleton.d.ts +62 -8
- package/types/cngx-ui-speak.d.ts +10 -2
- package/types/cngx-ui-stepper.d.ts +280 -56
- package/types/cngx-ui-tabs.d.ts +38 -10
- package/types/cngx-ui.d.ts +1 -0
- package/speak/speak-button-theme.scss +0 -78
|
@@ -20,6 +20,12 @@ const GAP_DEFAULTS = {
|
|
|
20
20
|
* <div>Item 1</div>
|
|
21
21
|
* <div>Item 2</div>
|
|
22
22
|
* </cngx-stack>
|
|
23
|
+
*
|
|
24
|
+
* @category ui/layout
|
|
25
|
+
* @docsKind primary
|
|
26
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/layout/stack.component.ts
|
|
27
|
+
* @since 0.1.0
|
|
28
|
+
* @relatedTo CngxGrid
|
|
23
29
|
*/
|
|
24
30
|
class CngxStack {
|
|
25
31
|
/** Flex direction of the stack. */
|
|
@@ -49,15 +55,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
49
55
|
|
|
50
56
|
/**
|
|
51
57
|
* Composable CSS grid layout component.
|
|
58
|
+
``` html
|
|
59
|
+
<cngx-grid columns="3" gap="16px">
|
|
60
|
+
<div>Cell 1</div>
|
|
61
|
+
<div>Cell 2</div>
|
|
62
|
+
</cngx-grid>
|
|
63
|
+
```
|
|
64
|
+
* `columns` accepts either a positive integer for the
|
|
65
|
+
* `repeat(N, 1fr)` shortcut or any `grid-template-columns` value
|
|
66
|
+
* (`"200px 1fr"`, `"repeat(auto-fit, minmax(120px, 1fr))"`).
|
|
67
|
+
* Bare attribute syntax works for both forms: `columns="3"` and
|
|
68
|
+
* `[columns]="3"` produce identical output.
|
|
52
69
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
70
|
+
* @category ui/layout
|
|
71
|
+
* @docsKind primary
|
|
72
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/layout/grid.component.ts
|
|
73
|
+
* @since 0.1.0
|
|
74
|
+
* @relatedTo CngxStack
|
|
57
75
|
*/
|
|
58
76
|
class CngxGrid {
|
|
59
77
|
/** Number of equal columns, or a custom `grid-template-columns` value. */
|
|
60
|
-
columns = input(1, ...(ngDevMode ?
|
|
78
|
+
columns = input(1, { ...(ngDevMode ? { debugName: "columns" } : /* istanbul ignore next */ {}), transform: coerceColumns });
|
|
61
79
|
/** CSS gap between cells. */
|
|
62
80
|
gap = input('16px', ...(ngDevMode ? [{ debugName: "gap" }] : /* istanbul ignore next */ []));
|
|
63
81
|
/** @internal */
|
|
@@ -75,6 +93,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
75
93
|
'[style.gap]': 'gap()',
|
|
76
94
|
}, styles: [":host{display:grid}\n"] }]
|
|
77
95
|
}], propDecorators: { columns: [{ type: i0.Input, args: [{ isSignal: true, alias: "columns", required: false }] }], gap: [{ type: i0.Input, args: [{ isSignal: true, alias: "gap", required: false }] }] } });
|
|
96
|
+
// Bare integer attribute (`columns="3"`) coerces to a number so the
|
|
97
|
+
// `repeat(N, 1fr)` branch fires; anything else is a track-list string
|
|
98
|
+
// (`"200px 1fr"`) and passes through to `grid-template-columns`.
|
|
99
|
+
function coerceColumns(value) {
|
|
100
|
+
if (typeof value === 'number') {
|
|
101
|
+
return value;
|
|
102
|
+
}
|
|
103
|
+
return /^\d+$/.test(value) ? Number(value) : value;
|
|
104
|
+
}
|
|
78
105
|
|
|
79
106
|
/**
|
|
80
107
|
* Public API Surface of @cngx/ui/layout
|
|
@@ -1 +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
|
|
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/**\n * Main-axis direction for {@link CngxStack}.\n *\n * @category ui/layout\n */\nexport type StackDirection = 'row' | 'column';\n/**\n * Cross-axis alignment for {@link CngxStack}.\n *\n * @category ui/layout\n */\nexport type StackAlign = 'start' | 'center' | 'end' | 'stretch';\n/**\n * Spacing scale for {@link CngxStack}. Maps to `--cngx-gap-*` tokens.\n *\n * @category ui/layout\n */\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 * @category ui/layout\n * @docsKind primary\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/layout/stack.component.ts\n * @since 0.1.0\n * @relatedTo CngxGrid\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 ``` html\n <cngx-grid columns=\"3\" gap=\"16px\">\n <div>Cell 1</div>\n <div>Cell 2</div>\n </cngx-grid>\n ```\n * `columns` accepts either a positive integer for the\n * `repeat(N, 1fr)` shortcut or any `grid-template-columns` value\n * (`\"200px 1fr\"`, `\"repeat(auto-fit, minmax(120px, 1fr))\"`).\n * Bare attribute syntax works for both forms: `columns=\"3\"` and\n * `[columns]=\"3\"` produce identical output.\n *\n * @category ui/layout\n * @docsKind primary\n * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/layout/grid.component.ts\n * @since 0.1.0\n * @relatedTo CngxStack\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, number | string>(1, {\n transform: coerceColumns,\n });\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// Bare integer attribute (`columns=\"3\"`) coerces to a number so the\n// `repeat(N, 1fr)` branch fires; anything else is a track-list string\n// (`\"200px 1fr\"`) and passes through to `grid-template-columns`.\nfunction coerceColumns(value: number | string): number | string {\n if (typeof value === 'number') {\n return value;\n }\n return /^\\d+$/.test(value) ? Number(value) : value;\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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"}
|
|
@@ -26,16 +26,10 @@ import { nextUid } from '@cngx/core/utils';
|
|
|
26
26
|
* owns:
|
|
27
27
|
* - presenter→Material `effect()` with read-equality guard.
|
|
28
28
|
* - Material→presenter subscription with re-entrancy guard.
|
|
29
|
-
* - Material-eager-advance reconciliation
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* `selectedIndex` synchronously before the bidirectional sync sees
|
|
33
|
-
* the event).
|
|
29
|
+
* - Material-eager-advance reconciliation (Material's MDC click
|
|
30
|
+
* handler advances `selectedIndex` synchronously before the
|
|
31
|
+
* bidirectional sync sees the event).
|
|
34
32
|
* - `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
33
|
*/
|
|
40
34
|
function createMatStepperBidirectionalSync(opts) {
|
|
41
35
|
createMaterialBidirectionalSync({
|
|
@@ -44,10 +38,8 @@ function createMatStepperBidirectionalSync(opts) {
|
|
|
44
38
|
writeSelectedIndex: (i) => {
|
|
45
39
|
opts.matStepper.selectedIndex = i;
|
|
46
40
|
},
|
|
47
|
-
// `MatStepper.selectedIndexChange`
|
|
48
|
-
//
|
|
49
|
-
// mirrors the `MatTabGroup.selectedIndexChange` shape used by
|
|
50
|
-
// `[cngxMatTabs]`.
|
|
41
|
+
// `MatStepper.selectedIndexChange` emits a plain index — no adapter needed,
|
|
42
|
+
// unlike `MatTabGroup.selectedIndexChange`.
|
|
51
43
|
selectionChange$: opts.matStepper.selectedIndexChange.asObservable(),
|
|
52
44
|
onMaterialSelection: (i) => opts.presenter.select(i),
|
|
53
45
|
injector: opts.injector,
|
|
@@ -57,7 +49,7 @@ function createMatStepperBidirectionalSync(opts) {
|
|
|
57
49
|
|
|
58
50
|
/**
|
|
59
51
|
* Material-twin stepper organism. Wraps `<mat-stepper>` and shares
|
|
60
|
-
* the `CngxStepperPresenter` brain with `<cngx-stepper>`
|
|
52
|
+
* the `CngxStepperPresenter` brain with `<cngx-stepper>` - Material
|
|
61
53
|
* consumers gain the commit-action lifecycle, router sync, and error
|
|
62
54
|
* aggregation.
|
|
63
55
|
*
|
|
@@ -67,19 +59,27 @@ function createMatStepperBidirectionalSync(opts) {
|
|
|
67
59
|
*
|
|
68
60
|
* Material owns keyboard nav and focus on `MatStepperHeader`, so the
|
|
69
61
|
* organism does NOT compose `CngxRovingTabindex` /
|
|
70
|
-
* `CngxFocusRestore`. Group nodes flatten
|
|
71
|
-
* support nesting
|
|
62
|
+
* `CngxFocusRestore`. Group nodes flatten - `<mat-stepper>` does not
|
|
63
|
+
* support nesting - with the depth preserved as a `data-step-depth`
|
|
72
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>
|
|
73
75
|
*/
|
|
74
76
|
class CngxMatStepper {
|
|
75
77
|
presenter = inject(CNGX_STEPPER_HOST);
|
|
76
78
|
destroyRef = inject(DestroyRef);
|
|
77
79
|
injector = inject(Injector);
|
|
78
80
|
matStepper = viewChild.required(MatStepper);
|
|
79
|
-
// Host CD nudge after the `_iconOverrides` patch
|
|
80
|
-
//
|
|
81
|
-
// CD pass, so the patch only takes effect once we mark the host
|
|
82
|
-
// view dirty.
|
|
81
|
+
// Host CD nudge after the `_iconOverrides` patch - Material reads the map
|
|
82
|
+
// into per-header `[iconOverrides]` bindings on the next CD pass.
|
|
83
83
|
hostCdr = inject(ChangeDetectorRef);
|
|
84
84
|
flatSteps = this.presenter.flatSteps;
|
|
85
85
|
activeStepIndex = this.presenter.activeStepIndex;
|
|
@@ -89,10 +89,9 @@ class CngxMatStepper {
|
|
|
89
89
|
* Consumer-projected `<ng-template matStepperIcon>` templates,
|
|
90
90
|
* forwarded into `MatStepper._iconOverrides` from the
|
|
91
91
|
* `afterNextRender` patch below. `<ng-content>` projection cannot
|
|
92
|
-
* reach Material's `@ContentChildren(MatStepperIcon)`
|
|
92
|
+
* reach Material's `@ContentChildren(MatStepperIcon)` - content-init
|
|
93
93
|
* resolves the inner query before the wrapper's projection lands.
|
|
94
|
-
* `_iconOverrides` is a Material-internal slot
|
|
95
|
-
* `tabs-accepted-debt §5`.
|
|
94
|
+
* `_iconOverrides` is a Material-internal slot.
|
|
96
95
|
*/
|
|
97
96
|
stepperIcons = contentChildren(MatStepperIcon, ...(ngDevMode ? [{ debugName: "stepperIcons" }] : /* istanbul ignore next */ []));
|
|
98
97
|
/**
|
|
@@ -105,7 +104,7 @@ class CngxMatStepper {
|
|
|
105
104
|
source: this.stepDirectives,
|
|
106
105
|
});
|
|
107
106
|
/**
|
|
108
|
-
* Step-only flat projection
|
|
107
|
+
* Step-only flat projection - `<mat-step>` does not nest, so
|
|
109
108
|
* groups collapse into the same level. Memoised via
|
|
110
109
|
* `flatStepsEqual` so consumers (`stepLabel`, panel `@for`,
|
|
111
110
|
* `stepLabelContextFor`) don't re-walk on shape-stable
|
|
@@ -113,12 +112,12 @@ class CngxMatStepper {
|
|
|
113
112
|
* `CngxStepper.stepsOnly`.
|
|
114
113
|
*/
|
|
115
114
|
stepsOnly = computed(() => this.presenter.flatSteps().filter((n) => n.kind === 'step'), { ...(ngDevMode ? { debugName: "stepsOnly" } : /* istanbul ignore next */ {}), equal: flatStepsEqual });
|
|
116
|
-
/** Material orientation literal
|
|
117
|
-
matOrientation = computed(() =>
|
|
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 */ []));
|
|
118
117
|
stepIndexOf(node) {
|
|
119
118
|
return node.flatIndex;
|
|
120
119
|
}
|
|
121
|
-
/** Editability rule
|
|
120
|
+
/** Editability rule - non-linear lets every step click; linear only past completed. */
|
|
122
121
|
isEditable(node) {
|
|
123
122
|
return !this.presenter.linear() || node.state() === 'success';
|
|
124
123
|
}
|
|
@@ -135,10 +134,8 @@ class CngxMatStepper {
|
|
|
135
134
|
stepDepth(node) {
|
|
136
135
|
return node.depth;
|
|
137
136
|
}
|
|
138
|
-
// Material twin honours only `*cngxStepLabel` / `*cngxStepContent
|
|
139
|
-
//
|
|
140
|
-
// Material owns the indicator/badge/busy chrome. The override path
|
|
141
|
-
// is `<ng-template matStepperIcon>`. stepper-accepted-debt §4.
|
|
137
|
+
// Material twin honours only `*cngxStepLabel` / `*cngxStepContent`; Material
|
|
138
|
+
// owns indicator/badge/busy chrome via `<ng-template matStepperIcon>`.
|
|
142
139
|
labelTemplateFor(id) {
|
|
143
140
|
return this.stepDirectiveById().get(id)?.labelTemplate()?.templateRef ?? null;
|
|
144
141
|
}
|
|
@@ -174,9 +171,6 @@ class CngxMatStepper {
|
|
|
174
171
|
this.stepLabelContextCache.set(node.id, fresh);
|
|
175
172
|
return fresh;
|
|
176
173
|
}
|
|
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
174
|
const mutable = existing;
|
|
181
175
|
mutable.node = node;
|
|
182
176
|
mutable.index = flatStep + 1;
|
|
@@ -190,9 +184,7 @@ class CngxMatStepper {
|
|
|
190
184
|
return this.stepLabelContextFor(node);
|
|
191
185
|
}
|
|
192
186
|
constructor() {
|
|
193
|
-
// Prune stale `stepLabelContextCache` entries
|
|
194
|
-
// set changes shape — without this, removed node-ids leak their
|
|
195
|
-
// entries forever.
|
|
187
|
+
// Prune stale `stepLabelContextCache` entries - removed node-ids would otherwise leak.
|
|
196
188
|
effect(() => {
|
|
197
189
|
const flat = this.presenter.flatSteps();
|
|
198
190
|
untracked(() => {
|
|
@@ -207,8 +199,7 @@ class CngxMatStepper {
|
|
|
207
199
|
}
|
|
208
200
|
});
|
|
209
201
|
});
|
|
210
|
-
// `
|
|
211
|
-
// resolved until the view commits.
|
|
202
|
+
// `viewChild.required(MatStepper)` isn't resolved until after the view commits.
|
|
212
203
|
afterNextRender(() => {
|
|
213
204
|
const stepper = this.matStepper();
|
|
214
205
|
createMatStepperBidirectionalSync({
|
|
@@ -217,18 +208,12 @@ class CngxMatStepper {
|
|
|
217
208
|
injector: this.injector,
|
|
218
209
|
destroyRef: this.destroyRef,
|
|
219
210
|
});
|
|
220
|
-
// Forward
|
|
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.
|
|
211
|
+
// Forward into Material's internal `_iconOverrides` slot.
|
|
227
212
|
const stepperRef = stepper;
|
|
228
213
|
const iconList = this.stepperIcons();
|
|
229
214
|
if (!stepperRef._iconOverrides) {
|
|
230
215
|
if (typeof ngDevMode !== 'undefined' && ngDevMode && iconList.length) {
|
|
231
|
-
console.warn('[CngxMatStepper] MatStepper._iconOverrides is missing
|
|
216
|
+
console.warn('[CngxMatStepper] MatStepper._iconOverrides is missing - ' +
|
|
232
217
|
'consumer-projected <ng-template matStepperIcon> templates ' +
|
|
233
218
|
'will not flow through to Material. Likely cause: a ' +
|
|
234
219
|
'Material upgrade renamed or removed the internal slot. ' +
|
|
@@ -239,16 +224,13 @@ class CngxMatStepper {
|
|
|
239
224
|
for (const icon of iconList) {
|
|
240
225
|
stepperRef._iconOverrides[icon.name] = icon.templateRef;
|
|
241
226
|
}
|
|
242
|
-
//
|
|
243
|
-
//
|
|
244
|
-
// re-runs CD over `<mat-stepper>` and the patched map flows
|
|
245
|
-
// through. Touching `selectedIndex` would echo through
|
|
246
|
-
// `createMaterialBidirectionalSync`; `markForCheck` does not.
|
|
227
|
+
// `markForCheck` (not `selectedIndex`) - touching the index would echo
|
|
228
|
+
// through `createMaterialBidirectionalSync`.
|
|
247
229
|
this.hostCdr.markForCheck();
|
|
248
230
|
});
|
|
249
231
|
}
|
|
250
232
|
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 });
|
|
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 });
|
|
252
234
|
}
|
|
253
235
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMatStepper, decorators: [{
|
|
254
236
|
type: Component,
|
|
@@ -258,15 +240,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
258
240
|
inputs: ['activeStepIndex', 'linear', 'orientation', 'commitAction', 'commitMode'],
|
|
259
241
|
outputs: ['activeStepIndexChange'],
|
|
260
242
|
},
|
|
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" }]
|
|
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" }]
|
|
262
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 }] }] } });
|
|
263
245
|
|
|
264
246
|
/**
|
|
265
247
|
* Shared `signal(undefined)` constant used as the `errorAggregator`
|
|
266
248
|
* slot for every Material-instrumented step handle. The
|
|
267
249
|
* instrumentation path does not bind cngx error-aggregation per
|
|
268
|
-
* `MatStep`
|
|
269
|
-
* `MatStep.hasError` / `MatStep.optional`) stays authoritative
|
|
250
|
+
* `MatStep` - Material's own visual error surface (driven by
|
|
251
|
+
* `MatStep.hasError` / `MatStep.optional`) stays authoritative - so
|
|
270
252
|
* per-step allocation of a writable signal would be dead capacity.
|
|
271
253
|
*
|
|
272
254
|
* @internal
|
|
@@ -276,7 +258,7 @@ const NO_ERROR_AGGREGATOR = signal(undefined).asReadonly();
|
|
|
276
258
|
* Best-effort static-text extraction from a `<ng-template matStepLabel>`
|
|
277
259
|
* `TemplateRef`. Used as a label fallback when consumers project a
|
|
278
260
|
* template label without setting `MatStep.label` or
|
|
279
|
-
* `MatStep.ariaLabel`
|
|
261
|
+
* `MatStep.ariaLabel` - without it the cngx-side label slot would
|
|
280
262
|
* be empty, leaving aria-label phrases that include the step label
|
|
281
263
|
* with a measurable gap on the Material variant. Static markup
|
|
282
264
|
* (`<ng-template matStepLabel>Review</ng-template>`) extracts cleanly
|
|
@@ -312,59 +294,55 @@ function readMatStepLabelTemplateText(template) {
|
|
|
312
294
|
* Translates a Material `MatStep` into a cngx
|
|
313
295
|
* {@link CngxStepRegistration}.
|
|
314
296
|
*
|
|
315
|
-
* - `id`
|
|
297
|
+
* - `id` - always a fresh `idSeed()` value. Mirrors the tabs
|
|
316
298
|
* instrumentation handle: a label-keyed id would collide when
|
|
317
299
|
* two steps share a label.
|
|
318
|
-
* - `kind`
|
|
300
|
+
* - `kind` - fixed at `'step'`. The instrumentation path does not
|
|
319
301
|
* project nested `<mat-step>` groups (Material's stepper has no
|
|
320
302
|
* group-of-steps concept; group-aware semantics belong to the
|
|
321
303
|
* `<cngx-stepper>` thin-wrapper organism).
|
|
322
|
-
* - `label`
|
|
304
|
+
* - `label` - snapshot signal resolved through a four-tier fallback at
|
|
323
305
|
* registration time so cngx-side phrases (announcements,
|
|
324
306
|
* `aria-label` composition, telemetry) never read empty when
|
|
325
307
|
* Material consumers project a `<ng-template matStepLabel>`:
|
|
326
|
-
* 1. `MatStep.label` when it is a plain string
|
|
308
|
+
* 1. `MatStep.label` when it is a plain string - the canonical
|
|
327
309
|
* shape and the only one that emits a runtime change Material
|
|
328
310
|
* itself observes.
|
|
329
|
-
* 2. `MatStep.ariaLabel` when the consumer set the input
|
|
311
|
+
* 2. `MatStep.ariaLabel` when the consumer set the input -
|
|
330
312
|
* designed exactly as the substitute for template labels.
|
|
331
313
|
* 3. Static-text read from `MatStep.stepLabel.template` via a
|
|
332
314
|
* throwaway detached `EmbeddedViewRef` ({@link readMatStepLabelTemplateText}).
|
|
333
315
|
* Captures literal `matStepLabel` markup; dynamic interpolation
|
|
334
316
|
* bails through to (4).
|
|
335
|
-
* 4. `Step <id>`
|
|
317
|
+
* 4. `Step <id>` - deterministic, derived from the cngx handle
|
|
336
318
|
* id. Always non-empty.
|
|
337
|
-
*
|
|
338
|
-
* `CdkStep` does not expose a `_stateChanges` Subject
|
|
339
|
-
* `MatTab._stateChanges`, so cngx cannot re-trigger
|
|
340
|
-
* when Material flips the input later.
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
* `MaterialPrivateSurfaces.CompletedOverrideSource` (see Phase 6.1).
|
|
345
|
-
* - `disabled` — fixed `false`. Material owns step gating via
|
|
319
|
+
* Documented limitation: runtime label changes do not propagate.
|
|
320
|
+
* CDK's `CdkStep` does not expose a `_stateChanges` Subject
|
|
321
|
+
* analogous to `MatTab._stateChanges`, so cngx cannot re-trigger
|
|
322
|
+
* the snapshot when Material flips the input later. Surface the
|
|
323
|
+
* same Material-internal coupling family typed in
|
|
324
|
+
* `MaterialPrivateSurfaces.CompletedOverrideSource`.
|
|
325
|
+
* - `disabled` - fixed `false`. Material owns step gating via
|
|
346
326
|
* `linear` + `editable` + `completed`; surfacing a cngx-side
|
|
347
327
|
* `disabled` would duplicate Material's own click-time enforcement
|
|
348
328
|
* and is ignored by `<mat-stepper>` itself.
|
|
349
|
-
* - `state`
|
|
350
|
-
* `CdkStep.completed`'s getter reads `_completedOverride()`
|
|
329
|
+
* - `state` - `computed()` over `MatStep.hasError` / `MatStep.completed`.
|
|
330
|
+
* `CdkStep.completed`'s getter reads `_completedOverride()` - a
|
|
351
331
|
* `WritableSignal<boolean | null>` typed in
|
|
352
332
|
* `MaterialPrivateSurfaces.CompletedOverrideSource`. The cngx
|
|
353
333
|
* computed transitively tracks that signal through the getter and
|
|
354
334
|
* re-fires whenever Material flips completion. `hasError` is a
|
|
355
|
-
* plain property setter on `CdkStep`, NOT a Signal
|
|
335
|
+
* plain property setter on `CdkStep`, NOT a Signal - a `hasError`
|
|
356
336
|
* write that is not paired with a `completed` change does not
|
|
357
337
|
* re-trigger this computed. In practice Material wizards write the
|
|
358
338
|
* two together (`step.hasError = true; step.completed = false` in
|
|
359
339
|
* error-handler patterns and inside Material's own error-state
|
|
360
340
|
* matchers) so the limitation is benign for the documented usage
|
|
361
|
-
* pattern.
|
|
362
|
-
*
|
|
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
|
|
341
|
+
* pattern.
|
|
342
|
+
* - `errorAggregator` - points at the shared
|
|
367
343
|
* {@link NO_ERROR_AGGREGATOR} constant.
|
|
344
|
+
*
|
|
345
|
+
* @category ui/mat-stepper
|
|
368
346
|
*/
|
|
369
347
|
function createMatStepHandle(matStep, idSeed) {
|
|
370
348
|
const id = idSeed();
|
|
@@ -422,12 +400,12 @@ function resolveStepLabel(matStep, id) {
|
|
|
422
400
|
*
|
|
423
401
|
* Symmetric with the tabs sibling
|
|
424
402
|
* `CNGX_MAT_TAB_HANDLE_FACTORY` and with `CNGX_TAB_OVERFLOW_DOM_ADAPTER_FACTORY`
|
|
425
|
-
*
|
|
403
|
+
* - every Material-bridge logic block ships the same swap surface so
|
|
426
404
|
* consumers can layer telemetry, alternate id strategies, or
|
|
427
405
|
* test-environment id keying via `providers` / `viewProviders`
|
|
428
406
|
* without forking the directive.
|
|
429
407
|
*
|
|
430
|
-
* Override capability
|
|
408
|
+
* Override capability - the swap surface separates **handle shape**
|
|
431
409
|
* (factory body) from **id keying** (the supplied `idSeed` closure).
|
|
432
410
|
* The directive constructs `idSeed` as `() => nextUid('cngx-mat-step-')`
|
|
433
411
|
* and hands it to the factory as a default suggestion; an override is
|
|
@@ -435,9 +413,6 @@ function resolveStepLabel(matStep, id) {
|
|
|
435
413
|
* deterministic-test / consumer-domain id strategy. Both axes are
|
|
436
414
|
* independently swappable from one DI seam.
|
|
437
415
|
*
|
|
438
|
-
* Tracked-debt: ships under family-uniformity staging (single
|
|
439
|
-
* in-package consumer today). See `stepper-accepted-debt §7`.
|
|
440
|
-
*
|
|
441
416
|
* ```ts
|
|
442
417
|
* providers: [
|
|
443
418
|
* {
|
|
@@ -450,6 +425,11 @@ function resolveStepLabel(matStep, id) {
|
|
|
450
425
|
* },
|
|
451
426
|
* ]
|
|
452
427
|
* ```
|
|
428
|
+
*
|
|
429
|
+
* @category ui/mat-stepper
|
|
430
|
+
* @wcag AA
|
|
431
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-stepper/material-bridge/handle.ts
|
|
432
|
+
* @since 0.1.0
|
|
453
433
|
*/
|
|
454
434
|
const CNGX_MAT_STEP_HANDLE_FACTORY = new InjectionToken('CNGX_MAT_STEP_HANDLE_FACTORY', {
|
|
455
435
|
providedIn: 'root',
|
|
@@ -458,7 +438,7 @@ const CNGX_MAT_STEP_HANDLE_FACTORY = new InjectionToken('CNGX_MAT_STEP_HANDLE_FA
|
|
|
458
438
|
|
|
459
439
|
/**
|
|
460
440
|
* Attaches to an existing `<mat-stepper>` and bridges it to a
|
|
461
|
-
* {@link CngxStepperPresenter}
|
|
441
|
+
* {@link CngxStepperPresenter} - consumers gain the commit-action
|
|
462
442
|
* lifecycle, `CNGX_STATEFUL` (so `<cngx-toast-on />` /
|
|
463
443
|
* `<cngx-banner-on />` compose as children), and the step-handle
|
|
464
444
|
* registry from one attribute.
|
|
@@ -470,8 +450,14 @@ const CNGX_MAT_STEP_HANDLE_FACTORY = new InjectionToken('CNGX_MAT_STEP_HANDLE_FA
|
|
|
470
450
|
* with the wrapper's `cngxMatStepper`.
|
|
471
451
|
*
|
|
472
452
|
* Topology mirrors `[cngxMatTabs]`: Material is the host, cngx is
|
|
473
|
-
* the instrumentation layer.
|
|
474
|
-
*
|
|
453
|
+
* the instrumentation layer.
|
|
454
|
+
*
|
|
455
|
+
* @category ui/mat-stepper
|
|
456
|
+
* @docsKind primary
|
|
457
|
+
* @wcag AA
|
|
458
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/mat-stepper/mat-stepper.directive.ts
|
|
459
|
+
* @since 0.1.0
|
|
460
|
+
* @relatedTo CngxMatStepper, CngxStepperPresenter, CngxMatTabs
|
|
475
461
|
*/
|
|
476
462
|
class CngxMatStepperBridge {
|
|
477
463
|
matStepper = inject(MatStepper, { self: true });
|
|
@@ -479,10 +465,7 @@ class CngxMatStepperBridge {
|
|
|
479
465
|
destroyRef = inject(DestroyRef);
|
|
480
466
|
injector = inject(Injector);
|
|
481
467
|
matSteps = contentChildren(MatStep, { ...(ngDevMode ? { debugName: "matSteps" } : /* istanbul ignore next */ {}), descendants: true });
|
|
482
|
-
//
|
|
483
|
-
// lifetime; `Map` (not `WeakMap`) so the diff loop in
|
|
484
|
-
// `syncHandles` can iterate to find removed steps without a
|
|
485
|
-
// parallel `Set<MatStep>`.
|
|
468
|
+
// Map not WeakMap - syncHandles needs to iterate to find removed steps.
|
|
486
469
|
setupsByStep = new Map();
|
|
487
470
|
createHandle = inject(CNGX_MAT_STEP_HANDLE_FACTORY);
|
|
488
471
|
constructor() {
|
|
@@ -505,8 +488,7 @@ class CngxMatStepperBridge {
|
|
|
505
488
|
}
|
|
506
489
|
syncHandles(steps) {
|
|
507
490
|
const liveSteps = new Set(steps);
|
|
508
|
-
//
|
|
509
|
-
// Cached MatSteps survive untouched — no register-churn.
|
|
491
|
+
// Only fresh MatSteps get registered; cached ones survive untouched.
|
|
510
492
|
for (const step of steps) {
|
|
511
493
|
if (this.setupsByStep.has(step)) {
|
|
512
494
|
continue;
|
|
@@ -515,8 +497,7 @@ class CngxMatStepperBridge {
|
|
|
515
497
|
this.setupsByStep.set(step, setup);
|
|
516
498
|
this.presenter.register(setup.handle);
|
|
517
499
|
}
|
|
518
|
-
// Snapshot before iterating
|
|
519
|
-
// introduce non-current-key deletes inside the body.
|
|
500
|
+
// Snapshot before iterating - guards against non-current-key deletes inside the body.
|
|
520
501
|
for (const [step, setup] of Array.from(this.setupsByStep.entries())) {
|
|
521
502
|
if (liveSteps.has(step)) {
|
|
522
503
|
continue;
|
|
@@ -537,13 +518,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
537
518
|
hostDirectives: [
|
|
538
519
|
{
|
|
539
520
|
directive: CngxStepperPresenter,
|
|
540
|
-
inputs: [
|
|
541
|
-
'activeStepIndex',
|
|
542
|
-
'linear',
|
|
543
|
-
'orientation',
|
|
544
|
-
'commitAction',
|
|
545
|
-
'commitMode',
|
|
546
|
-
],
|
|
521
|
+
inputs: ['activeStepIndex', 'linear', 'orientation', 'commitAction', 'commitMode'],
|
|
547
522
|
outputs: ['activeStepIndexChange'],
|
|
548
523
|
},
|
|
549
524
|
],
|