@cngx/common 0.0.1-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.
- package/a11y/README.md +13 -16
- package/card/README.md +2 -21
- package/chart/README.md +5 -8
- package/data/README.md +45 -47
- package/dialog/README.md +12 -15
- package/display/README.md +5 -9
- package/fesm2022/cngx-common-a11y.mjs +164 -51
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-card.mjs +157 -69
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +389 -92
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +311 -151
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +167 -29
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +445 -110
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +2059 -435
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +188 -31
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-popover.mjs +711 -90
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +1479 -73
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +1144 -85
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +2 -2
- package/fesm2022/cngx-common.mjs.map +1 -1
- package/interactive/README.md +5 -5
- package/layout/README.md +2 -2
- package/package.json +7 -6
- package/popover/README.md +8 -34
- package/stepper/README.md +69 -8
- package/tabs/README.md +6 -6
- package/theming/components/cngx-async.css +74 -0
- package/theming/components/cngx-backdrop.css +73 -0
- package/theming/components/cngx-badge.css +340 -0
- package/theming/components/cngx-bottom-sheet.css +201 -0
- package/theming/components/cngx-button-toggle.css +99 -0
- package/theming/components/cngx-dialog.css +358 -0
- package/theming/components/cngx-divider.css +145 -0
- package/theming/components/cngx-listbox.css +220 -0
- package/theming/components/cngx-menu.css +371 -0
- package/theming/components/cngx-ripple.css +116 -0
- package/theming/components/cngx-tooltip.css +265 -0
- package/theming/system-tokens.css +24 -0
- package/types/cngx-common-a11y.d.ts +159 -38
- package/types/cngx-common-card.d.ts +137 -22
- package/types/cngx-common-chart.d.ts +337 -40
- package/types/cngx-common-data.d.ts +277 -45
- package/types/cngx-common-dialog.d.ts +162 -22
- package/types/cngx-common-display.d.ts +422 -78
- package/types/cngx-common-interactive.d.ts +1880 -305
- package/types/cngx-common-layout.d.ts +191 -28
- package/types/cngx-common-popover.d.ts +632 -87
- package/types/cngx-common-stepper.d.ts +1360 -45
- package/types/cngx-common-tabs.d.ts +1139 -56
- package/types/cngx-common.d.ts +1 -1
- package/README.md +0 -18
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, makeEnvironmentProviders, inject, model, input, computed, signal, Directive, TemplateRef, contentChild, linkedSignal, DestroyRef, output,
|
|
2
|
+
import { InjectionToken, makeEnvironmentProviders, inject, model, input, computed, signal, isDevMode, afterNextRender, Directive, TemplateRef, contentChild, linkedSignal, DestroyRef, output, effect, untracked, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
3
|
import { CNGX_COMMIT_CONTROLLER_FACTORY } from '@cngx/common/data';
|
|
4
|
-
import { createTransitionTracker, CNGX_STATEFUL, nextUid } from '@cngx/core/utils';
|
|
4
|
+
import { createTransitionTracker, CNGX_STATEFUL, nextUid, buildAsyncStateView } from '@cngx/core/utils';
|
|
5
5
|
import { isObservable } from 'rxjs';
|
|
6
6
|
import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
7
7
|
import { Router, NavigationEnd } from '@angular/router';
|
|
8
8
|
import { filter } from 'rxjs/operators';
|
|
9
|
+
import * as i1 from '@cngx/common/interactive';
|
|
10
|
+
import { CngxAsyncClick } from '@cngx/common/interactive';
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Build a stepper commit handler over an existing {@link CngxCommitController}.
|
|
12
14
|
* Resolves `Observable<boolean>` / `Promise<boolean>` / `boolean` returns into
|
|
13
15
|
* a unified `accept: boolean` outcome.
|
|
16
|
+
*
|
|
17
|
+
* @category common/stepper
|
|
14
18
|
*/
|
|
15
19
|
function createStepperCommitHandler(opts) {
|
|
16
20
|
const { controller } = opts;
|
|
@@ -27,6 +31,7 @@ function createStepperCommitHandler(opts) {
|
|
|
27
31
|
},
|
|
28
32
|
};
|
|
29
33
|
}
|
|
34
|
+
/** @internal */
|
|
30
35
|
function runStepperAction(action, fromIndex, toIndex, handlers) {
|
|
31
36
|
let cancelled = false;
|
|
32
37
|
let unsubscribe = null;
|
|
@@ -53,11 +58,15 @@ function runStepperAction(action, fromIndex, toIndex, handlers) {
|
|
|
53
58
|
}
|
|
54
59
|
catch (err) {
|
|
55
60
|
safeError(err);
|
|
56
|
-
return {
|
|
61
|
+
return {
|
|
62
|
+
cancel: () => {
|
|
63
|
+
cancelled = true;
|
|
64
|
+
},
|
|
65
|
+
};
|
|
57
66
|
}
|
|
58
67
|
if (isObservable(result)) {
|
|
59
68
|
// Synchronous Observables (`of(true)`) emit inside `.subscribe`
|
|
60
|
-
// before the assignment binds
|
|
69
|
+
// before the assignment binds - `sub` would be in TDZ. Declare
|
|
61
70
|
// the handle on a `let` first.
|
|
62
71
|
let sub = null;
|
|
63
72
|
sub = result.subscribe({
|
|
@@ -85,18 +94,39 @@ function runStepperAction(action, fromIndex, toIndex, handlers) {
|
|
|
85
94
|
/**
|
|
86
95
|
* DI token carrying the factory the presenter uses to allocate its commit
|
|
87
96
|
* handler. Symmetric to the select family's `CNGX_ARRAY_COMMIT_HANDLER_FACTORY`.
|
|
97
|
+
*
|
|
98
|
+
* @category common/stepper
|
|
99
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/commit-handler.ts
|
|
100
|
+
* @since 0.1.0
|
|
88
101
|
*/
|
|
89
102
|
const CNGX_STEPPER_COMMIT_HANDLER_FACTORY = new InjectionToken('CngxStepperCommitHandlerFactory', {
|
|
90
103
|
providedIn: 'root',
|
|
91
104
|
factory: () => createStepperCommitHandler,
|
|
92
105
|
});
|
|
93
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Default media query the mobile auto-collapse policy reacts to. The
|
|
109
|
+
* literal lives on a single exported const so the runtime, the config
|
|
110
|
+
* default, and any JSDoc cross-references stay in lockstep. Consumers
|
|
111
|
+
* override the query via {@link withStepperMobileBreakpoint}.
|
|
112
|
+
*
|
|
113
|
+
* @category common/stepper
|
|
114
|
+
*/
|
|
115
|
+
const STEPPER_DEFAULT_MOBILE_BREAKPOINT = '(max-width: 480px)';
|
|
116
|
+
/** @internal */
|
|
94
117
|
const STEPPER_CONFIG_DEFAULTS = {
|
|
95
118
|
defaultOrientation: 'horizontal',
|
|
96
119
|
defaultLinear: false,
|
|
97
120
|
defaultCommitMode: 'pessimistic',
|
|
98
121
|
routerSyncMode: 'fragment',
|
|
99
122
|
routerSyncParam: 'step',
|
|
123
|
+
skin: 'classic',
|
|
124
|
+
headerNavigation: 'visited',
|
|
125
|
+
connectors: false,
|
|
126
|
+
mobileCollapse: 'text',
|
|
127
|
+
mobileBreakpoint: STEPPER_DEFAULT_MOBILE_BREAKPOINT,
|
|
128
|
+
mobileIndicatorPosition: 'top',
|
|
129
|
+
mobileSwipe: true,
|
|
100
130
|
ariaLabels: {
|
|
101
131
|
stepperRegion: 'Stepper',
|
|
102
132
|
},
|
|
@@ -110,8 +140,16 @@ const STEPPER_CONFIG_DEFAULTS = {
|
|
|
110
140
|
* DI token for the resolved stepper config. `providedIn: 'root'` with
|
|
111
141
|
* library defaults; override via {@link provideStepperConfig} (root)
|
|
112
142
|
* or {@link provideStepperConfigAt} (component scope).
|
|
143
|
+
*
|
|
144
|
+
* @category common/stepper
|
|
145
|
+
* @wcag AA
|
|
146
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/stepper-config.ts
|
|
147
|
+
* @since 0.1.0
|
|
113
148
|
*/
|
|
114
|
-
const CNGX_STEPPER_CONFIG = new InjectionToken('CngxStepperConfig', {
|
|
149
|
+
const CNGX_STEPPER_CONFIG = new InjectionToken('CngxStepperConfig', {
|
|
150
|
+
providedIn: 'root',
|
|
151
|
+
factory: () => STEPPER_CONFIG_DEFAULTS,
|
|
152
|
+
});
|
|
115
153
|
/**
|
|
116
154
|
* Brands a config mutator with `_target: 'config'`. Every `with*`
|
|
117
155
|
* config feature returns one of these.
|
|
@@ -124,6 +162,8 @@ function defineStepperConfigFeature(fn) {
|
|
|
124
162
|
/**
|
|
125
163
|
* Override the default orientation. Per-instance `[orientation]`
|
|
126
164
|
* Input still wins; this only moves the cascade default.
|
|
165
|
+
*
|
|
166
|
+
* @category common/stepper
|
|
127
167
|
*/
|
|
128
168
|
function withStepperDefaultOrientation(orientation) {
|
|
129
169
|
return defineStepperConfigFeature((cfg) => ({
|
|
@@ -134,6 +174,8 @@ function withStepperDefaultOrientation(orientation) {
|
|
|
134
174
|
/**
|
|
135
175
|
* Override the default linear-progression setting. Per-instance
|
|
136
176
|
* `[linear]` Input still wins.
|
|
177
|
+
*
|
|
178
|
+
* @category common/stepper
|
|
137
179
|
*/
|
|
138
180
|
function withStepperLinear(linear) {
|
|
139
181
|
return defineStepperConfigFeature((cfg) => ({ ...cfg, defaultLinear: linear }));
|
|
@@ -143,6 +185,8 @@ function withStepperLinear(linear) {
|
|
|
143
185
|
* `'optimistic'` advances on action dispatch and rolls back on error;
|
|
144
186
|
* `'pessimistic'` waits for success. Per-instance `[commitMode]`
|
|
145
187
|
* Input still wins.
|
|
188
|
+
*
|
|
189
|
+
* @category common/stepper
|
|
146
190
|
*/
|
|
147
191
|
function withStepperCommitMode(mode) {
|
|
148
192
|
return defineStepperConfigFeature((cfg) => ({
|
|
@@ -154,6 +198,8 @@ function withStepperCommitMode(mode) {
|
|
|
154
198
|
* Configure router synchronisation for the active step. `mode` chooses
|
|
155
199
|
* the URL surface (URL fragment or query parameter); `param` names the
|
|
156
200
|
* key (default `'step'`).
|
|
201
|
+
*
|
|
202
|
+
* @category common/stepper
|
|
157
203
|
*/
|
|
158
204
|
function withStepperRouterSync(mode, param = 'step') {
|
|
159
205
|
return defineStepperConfigFeature((cfg) => ({
|
|
@@ -162,9 +208,96 @@ function withStepperRouterSync(mode, param = 'step') {
|
|
|
162
208
|
routerSyncParam: param,
|
|
163
209
|
}));
|
|
164
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Select the visual skin for the cngx-standard `<cngx-stepper>`. The
|
|
213
|
+
* default is `'classic'`. Per-instance `[skin]` Input still wins; this
|
|
214
|
+
* moves the cascade default. Structure, slots, ARIA, and keyboard
|
|
215
|
+
* behaviour are identical across skins - only the `[data-skin]` host
|
|
216
|
+
* attribute changes the CSS layer that paints the strip.
|
|
217
|
+
*
|
|
218
|
+
* @category common/stepper
|
|
219
|
+
*/
|
|
220
|
+
function withStepperSkin(skin) {
|
|
221
|
+
return defineStepperConfigFeature((cfg) => ({ ...cfg, skin }));
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Opt the classic `<cngx-stepper>` skin into the connector-rail
|
|
225
|
+
* presentation: a solid completed/upcoming rail between adjacent step
|
|
226
|
+
* indicators, horizontal and vertical, with per-segment coloring driven
|
|
227
|
+
* by the preceding step's `[data-state]`. The rule is double-scoped on
|
|
228
|
+
* `[data-skin='classic']`; the four other skins each ship their own
|
|
229
|
+
* inter-step decoration and ignore this flag. Per-instance
|
|
230
|
+
* `[connectors]` Input still wins.
|
|
231
|
+
*
|
|
232
|
+
* @category common/stepper
|
|
233
|
+
*/
|
|
234
|
+
function withStepperConnectors(on) {
|
|
235
|
+
return defineStepperConfigFeature((cfg) => ({ ...cfg, connectors: on }));
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Configure the mobile auto-collapse target for `<cngx-stepper>`. Under
|
|
239
|
+
* a narrow viewport (`max-width: 480px`), the classic strip swaps to
|
|
240
|
+
* the chosen variant - `'text'` (default) renders `<cngx-text-stepper>`,
|
|
241
|
+
* `'dots'` renders `<cngx-dot-stepper>`, `'off'` keeps the classic
|
|
242
|
+
* strip. The Material twin `<cngx-mat-stepper>` ignores this setting.
|
|
243
|
+
*
|
|
244
|
+
* @category common/stepper
|
|
245
|
+
*/
|
|
246
|
+
function withStepperMobileCollapse(mode) {
|
|
247
|
+
return defineStepperConfigFeature((cfg) => ({ ...cfg, mobileCollapse: mode }));
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Override the media query the mobile auto-collapse policy reacts to.
|
|
251
|
+
* Default `'(max-width: 480px)'`. Useful for tablet-tier consumers
|
|
252
|
+
* who want the collapse to engage at 768px or for design systems
|
|
253
|
+
* aligned with `--mat-sys-breakpoint-*` tokens.
|
|
254
|
+
*
|
|
255
|
+
* @category common/stepper
|
|
256
|
+
*/
|
|
257
|
+
function withStepperMobileBreakpoint(query) {
|
|
258
|
+
return defineStepperConfigFeature((cfg) => ({ ...cfg, mobileBreakpoint: query }));
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Set the app-wide default position of the mobile auto-collapse
|
|
262
|
+
* indicator relative to panel content. `'top'` keeps the indicator
|
|
263
|
+
* above (library default); `'bottom'` flips it below so panel content
|
|
264
|
+
* reads first and the navigation cue sits at thumb height. Per-
|
|
265
|
+
* instance `[mobileIndicatorPosition]` on `<cngx-stepper>` still
|
|
266
|
+
* wins.
|
|
267
|
+
*
|
|
268
|
+
* @category common/stepper
|
|
269
|
+
*/
|
|
270
|
+
function withStepperMobileIndicatorPosition(position) {
|
|
271
|
+
return defineStepperConfigFeature((cfg) => ({ ...cfg, mobileIndicatorPosition: position }));
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Toggle the built-in horizontal-swipe navigation on `<cngx-stepper>`
|
|
275
|
+
* in mobile-collapse mode. Default `true` - the `'dots'` and `'text'`
|
|
276
|
+
* variants read as carousels, so users expect to swipe. Per-instance
|
|
277
|
+
* `[mobileSwipe]` Input still wins; the classic strip is unaffected.
|
|
278
|
+
*
|
|
279
|
+
* @category common/stepper
|
|
280
|
+
*/
|
|
281
|
+
function withStepperMobileSwipe(enabled) {
|
|
282
|
+
return defineStepperConfigFeature((cfg) => ({ ...cfg, mobileSwipe: enabled }));
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Set the app-wide default header-navigation policy for
|
|
286
|
+
* `<cngx-stepper>`. `'none'` renders inert label headers (footer-only
|
|
287
|
+
* navigation); `'visited'` (library default) keeps the headers as
|
|
288
|
+
* focusable buttons whose reachability folds into the `linear` axis.
|
|
289
|
+
* Per-instance `[headerNavigation]` Input still wins.
|
|
290
|
+
*
|
|
291
|
+
* @category common/stepper
|
|
292
|
+
*/
|
|
293
|
+
function withStepperHeaderNavigation(mode) {
|
|
294
|
+
return defineStepperConfigFeature((cfg) => ({ ...cfg, headerNavigation: mode }));
|
|
295
|
+
}
|
|
165
296
|
/**
|
|
166
297
|
* Merge ARIA labels into the cascade. Keys not provided keep their
|
|
167
298
|
* library defaults; per-instance overrides on the stepper still win.
|
|
299
|
+
*
|
|
300
|
+
* @category common/stepper
|
|
168
301
|
*/
|
|
169
302
|
function withStepperAriaLabels(labels) {
|
|
170
303
|
return defineStepperConfigFeature((cfg) => ({
|
|
@@ -175,6 +308,8 @@ function withStepperAriaLabels(labels) {
|
|
|
175
308
|
/**
|
|
176
309
|
* Merge text fallback labels (button captions, error strings) into the
|
|
177
310
|
* cascade. Used when a slot directive is not present.
|
|
311
|
+
*
|
|
312
|
+
* @category common/stepper
|
|
178
313
|
*/
|
|
179
314
|
function withStepperFallbackLabels(labels) {
|
|
180
315
|
return defineStepperConfigFeature((cfg) => ({
|
|
@@ -186,6 +321,8 @@ function withStepperFallbackLabels(labels) {
|
|
|
186
321
|
* Override the default `*cngxStepIndicator` template app-wide.
|
|
187
322
|
* Per-instance directive still wins; this only moves the cascade
|
|
188
323
|
* middle tier.
|
|
324
|
+
*
|
|
325
|
+
* @category common/stepper
|
|
189
326
|
*/
|
|
190
327
|
function withStepIndicatorTemplate(template) {
|
|
191
328
|
return defineStepperConfigFeature((cfg) => ({
|
|
@@ -195,6 +332,8 @@ function withStepIndicatorTemplate(template) {
|
|
|
195
332
|
}
|
|
196
333
|
/**
|
|
197
334
|
* Override the default `*cngxStepBadge` template app-wide.
|
|
335
|
+
*
|
|
336
|
+
* @category common/stepper
|
|
198
337
|
*/
|
|
199
338
|
function withStepBadgeTemplate(template) {
|
|
200
339
|
return defineStepperConfigFeature((cfg) => ({
|
|
@@ -204,6 +343,8 @@ function withStepBadgeTemplate(template) {
|
|
|
204
343
|
}
|
|
205
344
|
/**
|
|
206
345
|
* Override the default `*cngxStepBusySpinner` template app-wide.
|
|
346
|
+
*
|
|
347
|
+
* @category common/stepper
|
|
207
348
|
*/
|
|
208
349
|
function withStepBusySpinnerTemplate(template) {
|
|
209
350
|
return defineStepperConfigFeature((cfg) => ({
|
|
@@ -214,6 +355,8 @@ function withStepBusySpinnerTemplate(template) {
|
|
|
214
355
|
/**
|
|
215
356
|
* Override the default `*cngxStepRejection` template app-wide.
|
|
216
357
|
* Symmetric with the upcoming tabs `cngxTabRejectionIcon` (Phase 4).
|
|
358
|
+
*
|
|
359
|
+
* @category common/stepper
|
|
217
360
|
*/
|
|
218
361
|
function withStepRejectionTemplate(template) {
|
|
219
362
|
return defineStepperConfigFeature((cfg) => ({
|
|
@@ -221,8 +364,24 @@ function withStepRejectionTemplate(template) {
|
|
|
221
364
|
templates: { ...cfg.templates, rejection: template },
|
|
222
365
|
}));
|
|
223
366
|
}
|
|
367
|
+
/**
|
|
368
|
+
* Override the default `*cngxStepError` template app-wide. The slot
|
|
369
|
+
* renders the per-step validation reason on the skins with a label area
|
|
370
|
+
* (classic / stripe-status-rich). Per-instance directive still wins;
|
|
371
|
+
* this moves the cascade middle tier.
|
|
372
|
+
*
|
|
373
|
+
* @category common/stepper
|
|
374
|
+
*/
|
|
375
|
+
function withStepErrorTemplate(template) {
|
|
376
|
+
return defineStepperConfigFeature((cfg) => ({
|
|
377
|
+
...cfg,
|
|
378
|
+
templates: { ...cfg.templates, stepError: template },
|
|
379
|
+
}));
|
|
380
|
+
}
|
|
224
381
|
/**
|
|
225
382
|
* Override the default `*cngxStepGroupHeader` template app-wide.
|
|
383
|
+
*
|
|
384
|
+
* @category common/stepper
|
|
226
385
|
*/
|
|
227
386
|
function withStepGroupHeaderTemplate(template) {
|
|
228
387
|
return defineStepperConfigFeature((cfg) => ({
|
|
@@ -232,6 +391,8 @@ function withStepGroupHeaderTemplate(template) {
|
|
|
232
391
|
}
|
|
233
392
|
/**
|
|
234
393
|
* Override the default `*cngxStepperEmpty` template app-wide.
|
|
394
|
+
*
|
|
395
|
+
* @category common/stepper
|
|
235
396
|
*/
|
|
236
397
|
function withStepperEmptyTemplate(template) {
|
|
237
398
|
return defineStepperConfigFeature((cfg) => ({
|
|
@@ -239,6 +400,21 @@ function withStepperEmptyTemplate(template) {
|
|
|
239
400
|
templates: { ...cfg.templates, empty: template },
|
|
240
401
|
}));
|
|
241
402
|
}
|
|
403
|
+
/**
|
|
404
|
+
* Override the default `*cngxDotStepperDot` template app-wide. The
|
|
405
|
+
* `<cngx-dot-stepper>` variant resolves the cascade per dot:
|
|
406
|
+
* per-instance directive > this feature > built-in empty body
|
|
407
|
+
* (the dot fill is painted by `.cngx-dot-stepper__dot` regardless).
|
|
408
|
+
*
|
|
409
|
+
* @category common/stepper
|
|
410
|
+
*/
|
|
411
|
+
function withDotStepperDotTemplate(template) {
|
|
412
|
+
return defineStepperConfigFeature((cfg) => ({
|
|
413
|
+
...cfg,
|
|
414
|
+
templates: { ...cfg.templates, dotStepperDot: template },
|
|
415
|
+
}));
|
|
416
|
+
}
|
|
417
|
+
/** @internal */
|
|
242
418
|
function resolveFeatures(features) {
|
|
243
419
|
return features.reduce((cfg, feat) => feat(cfg), STEPPER_CONFIG_DEFAULTS);
|
|
244
420
|
}
|
|
@@ -246,6 +422,8 @@ function resolveFeatures(features) {
|
|
|
246
422
|
* Root-level provider for the stepper config. Apply once in the
|
|
247
423
|
* application providers array. Sibling of `provideTabsConfig` /
|
|
248
424
|
* `provideSelectConfig`.
|
|
425
|
+
*
|
|
426
|
+
* @category common/stepper
|
|
249
427
|
*/
|
|
250
428
|
function provideStepperConfig(...features) {
|
|
251
429
|
return makeEnvironmentProviders([
|
|
@@ -254,7 +432,7 @@ function provideStepperConfig(...features) {
|
|
|
254
432
|
}
|
|
255
433
|
/**
|
|
256
434
|
* Component-scoped config override. Spread the returned `Provider[]`
|
|
257
|
-
* into `providers` or `viewProviders`
|
|
435
|
+
* into `providers` or `viewProviders` - `viewProviders` cannot accept
|
|
258
436
|
* opaque {@link EnvironmentProviders}, so the twin returns a list.
|
|
259
437
|
* Sibling of `provideTabsConfigAt`.
|
|
260
438
|
*
|
|
@@ -266,12 +444,16 @@ function provideStepperConfig(...features) {
|
|
|
266
444
|
* viewProviders: [...provideStepperConfigAt(withStepperLinear(true))],
|
|
267
445
|
* })
|
|
268
446
|
* ```
|
|
447
|
+
*
|
|
448
|
+
* @category common/stepper
|
|
269
449
|
*/
|
|
270
450
|
function provideStepperConfigAt(...features) {
|
|
271
451
|
return [{ provide: CNGX_STEPPER_CONFIG, useValue: resolveFeatures(features) }];
|
|
272
452
|
}
|
|
273
453
|
/**
|
|
274
454
|
* Inject the resolved stepper config in an injection context.
|
|
455
|
+
*
|
|
456
|
+
* @category common/stepper
|
|
275
457
|
*/
|
|
276
458
|
function injectStepperConfig() {
|
|
277
459
|
return inject(CNGX_STEPPER_CONFIG);
|
|
@@ -281,6 +463,11 @@ function injectStepperConfig() {
|
|
|
281
463
|
* DI token carrying the presenter's contract to atoms + organism shells.
|
|
282
464
|
* Atoms inject `optional: true` and either register here or fall through
|
|
283
465
|
* {@link CNGX_STEP_GROUP_HOST} when nested in a group.
|
|
466
|
+
*
|
|
467
|
+
* @category common/stepper
|
|
468
|
+
* @wcag AA
|
|
469
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/stepper-host.token.ts
|
|
470
|
+
* @since 0.1.0
|
|
284
471
|
*/
|
|
285
472
|
const CNGX_STEPPER_HOST = new InjectionToken('CngxStepperHost');
|
|
286
473
|
|
|
@@ -288,6 +475,8 @@ const CNGX_STEPPER_HOST = new InjectionToken('CngxStepperHost');
|
|
|
288
475
|
* DFS-flatten a step tree. Group nodes emit before their children;
|
|
289
476
|
* the consumer keys off `kind` to render a panel container vs. a
|
|
290
477
|
* group header.
|
|
478
|
+
*
|
|
479
|
+
* @internal
|
|
291
480
|
*/
|
|
292
481
|
function flattenStepTree(nodes) {
|
|
293
482
|
const out = [];
|
|
@@ -309,10 +498,12 @@ function flattenStepTree(nodes) {
|
|
|
309
498
|
return out;
|
|
310
499
|
}
|
|
311
500
|
/**
|
|
312
|
-
* Structural equality for the step-tree registry signal. Shape only
|
|
501
|
+
* Structural equality for the step-tree registry signal. Shape only -
|
|
313
502
|
* id, kind, depth, parentId, children length. Reactive fields
|
|
314
503
|
* (`label`, `disabled`, `state`, `errorAggregator`) are signals; their
|
|
315
504
|
* own subscribers track identity changes.
|
|
505
|
+
*
|
|
506
|
+
* @internal
|
|
316
507
|
*/
|
|
317
508
|
function stepTreeEqual(a, b) {
|
|
318
509
|
if (a === b) {
|
|
@@ -338,12 +529,14 @@ function stepTreeEqual(a, b) {
|
|
|
338
529
|
* a sibling is inserted) on top of the {@link stepTreeEqual} fields.
|
|
339
530
|
*
|
|
340
531
|
* Use only on projections where every step carries a real
|
|
341
|
-
* DFS-assigned `flatIndex` and `depth`
|
|
532
|
+
* DFS-assigned `flatIndex` and `depth` - for `-1` placeholders, use
|
|
342
533
|
* {@link stepNodesEqual}.
|
|
343
534
|
*
|
|
344
535
|
* @internal Exported from `public-api.ts` so the cngx-stepper and
|
|
345
536
|
* cngx-mat-stepper organisms share the comparator across the
|
|
346
537
|
* secondary-entry boundary (Sheriff forbids deep-relative imports).
|
|
538
|
+
*
|
|
539
|
+
* @category common/stepper
|
|
347
540
|
*/
|
|
348
541
|
function flatStepsEqual(a, b) {
|
|
349
542
|
if (a === b) {
|
|
@@ -363,9 +556,11 @@ function flatStepsEqual(a, b) {
|
|
|
363
556
|
return true;
|
|
364
557
|
}
|
|
365
558
|
/**
|
|
366
|
-
* Structural equality for any flat node array
|
|
559
|
+
* Structural equality for any flat node array - `id`, `kind`,
|
|
367
560
|
* `parentId` only, ignoring `flatIndex` and `depth`. Use for
|
|
368
561
|
* `CngxStepGroup.children` and other `-1`-placeholder projections.
|
|
562
|
+
*
|
|
563
|
+
* @internal
|
|
369
564
|
*/
|
|
370
565
|
function stepNodesEqual(a, b) {
|
|
371
566
|
if (a === b) {
|
|
@@ -375,9 +570,7 @@ function stepNodesEqual(a, b) {
|
|
|
375
570
|
return false;
|
|
376
571
|
}
|
|
377
572
|
for (let i = 0; i < a.length; i++) {
|
|
378
|
-
if (a[i].id !== b[i].id ||
|
|
379
|
-
a[i].kind !== b[i].kind ||
|
|
380
|
-
a[i].parentId !== b[i].parentId) {
|
|
573
|
+
if (a[i].id !== b[i].id || a[i].kind !== b[i].kind || a[i].parentId !== b[i].parentId) {
|
|
381
574
|
return false;
|
|
382
575
|
}
|
|
383
576
|
}
|
|
@@ -385,21 +578,29 @@ function stepNodesEqual(a, b) {
|
|
|
385
578
|
}
|
|
386
579
|
|
|
387
580
|
/**
|
|
388
|
-
* Stepper presenter
|
|
581
|
+
* Stepper presenter - the brain of every stepper / wizard flow.
|
|
389
582
|
* Holds the active-step model, registry, linear policy, orientation,
|
|
390
583
|
* and commit-controller lifecycle. Provides {@link CNGX_STEPPER_HOST}
|
|
391
584
|
* for atom registration and {@link CNGX_STATEFUL} so transition
|
|
392
585
|
* bridges (`<cngx-toast-on />`, `<cngx-banner-on />`) compose without
|
|
393
586
|
* explicit `[state]` wiring.
|
|
394
587
|
*
|
|
395
|
-
* Sheriff: common Level 2. Pure directive
|
|
588
|
+
* Sheriff: common Level 2. Pure directive - zero template, zero CSS.
|
|
396
589
|
* Level-4 organisms compose this via `hostDirectives`.
|
|
590
|
+
*
|
|
591
|
+
* @category common/stepper
|
|
592
|
+
* @docsKind primary
|
|
593
|
+
* @wcag AA
|
|
594
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/presenter.directive.ts
|
|
595
|
+
* @since 0.1.0
|
|
596
|
+
* @relatedTo CngxStep, CngxStepGroup, CngxStepperRouterSync, CNGX_STEPPER_HOST, CNGX_STEPPER_CONFIG
|
|
597
|
+
* <example-url>http://localhost:4200/#/ui/stepper/stepper-commit-action/pessimistic-optimistic-commits-with-bridge-directives</example-url>
|
|
397
598
|
*/
|
|
398
599
|
class CngxStepperPresenter {
|
|
399
600
|
config = injectStepperConfig();
|
|
400
601
|
activeStepIndex = model(0, ...(ngDevMode ? [{ debugName: "activeStepIndex" }] : /* istanbul ignore next */ []));
|
|
401
602
|
// Raw *Input slots default undefined so the cascade resolves through
|
|
402
|
-
// CNGX_STEPPER_CONFIG. Must stay public
|
|
603
|
+
// CNGX_STEPPER_CONFIG. Must stay public - the template type-checker
|
|
403
604
|
// rejects protected/private on hostDirective alias bindings.
|
|
404
605
|
linearInput = input(undefined, { ...(ngDevMode ? { debugName: "linearInput" } : /* istanbul ignore next */ {}), alias: 'linear' });
|
|
405
606
|
linear = computed(() => this.linearInput() ?? this.config.defaultLinear ?? false, ...(ngDevMode ? [{ debugName: "linear" }] : /* istanbul ignore next */ []));
|
|
@@ -422,11 +623,11 @@ class CngxStepperPresenter {
|
|
|
422
623
|
/**
|
|
423
624
|
* Reactive current/previous pair for the commit-state status. Skin
|
|
424
625
|
* sub-components mount a `<span cngxLiveRegion>` reading this
|
|
425
|
-
* tracker. Allocated once per presenter
|
|
626
|
+
* tracker. Allocated once per presenter - the underlying
|
|
426
627
|
* `linkedSignal` is shared across all consumers.
|
|
427
628
|
*/
|
|
428
629
|
commitTransition = createTransitionTracker(() => this.commitController.state.status());
|
|
429
|
-
// Persistence-of-error surface
|
|
630
|
+
// Persistence-of-error surface - see CngxStepperHost.lastFailedIndex
|
|
430
631
|
// / originIndexDuringCommit for the contract.
|
|
431
632
|
lastFailedIndexState = signal(undefined, ...(ngDevMode ? [{ debugName: "lastFailedIndexState" }] : /* istanbul ignore next */ []));
|
|
432
633
|
originIndexDuringCommitState = signal(undefined, ...(ngDevMode ? [{ debugName: "originIndexDuringCommitState" }] : /* istanbul ignore next */ []));
|
|
@@ -438,10 +639,10 @@ class CngxStepperPresenter {
|
|
|
438
639
|
stepTree = this.treeState.asReadonly();
|
|
439
640
|
flatSteps = computed(() => flattenStepTree(this.stepTree()), { ...(ngDevMode ? { debugName: "flatSteps" } : /* istanbul ignore next */ {}), equal: flatStepsEqual });
|
|
440
641
|
/**
|
|
441
|
-
* Step-only flat projection
|
|
642
|
+
* Step-only flat projection - terminal nodes in DFS order.
|
|
442
643
|
* Structural-equal via `flatStepsEqual` so downstream computeds
|
|
443
644
|
* don't cascade on shape-stable re-emits. Single source for every
|
|
444
|
-
* `select*` / `clamp` / `activeStepId` lookup
|
|
645
|
+
* `select*` / `clamp` / `activeStepId` lookup - never re-filter
|
|
445
646
|
* `flatSteps()`.
|
|
446
647
|
*/
|
|
447
648
|
stepsOnly = computed(() => this.flatSteps().filter((n) => n.kind === 'step'), { ...(ngDevMode ? { debugName: "stepsOnly" } : /* istanbul ignore next */ {}), equal: flatStepsEqual });
|
|
@@ -458,13 +659,75 @@ class CngxStepperPresenter {
|
|
|
458
659
|
return this.stepsOnly()[idx]?.id ?? null;
|
|
459
660
|
}, ...(ngDevMode ? [{ debugName: "activeStepId" }] : /* istanbul ignore next */ []));
|
|
460
661
|
commitState = this.commitController.state;
|
|
662
|
+
/**
|
|
663
|
+
* Next enabled step-only index after the active one, skipping
|
|
664
|
+
* disabled steps. Returns `stepsOnly().length` when no enabled step
|
|
665
|
+
* follows. Single source for `selectNext()` and the `canGoNext`
|
|
666
|
+
* bound - the traversal lives here, never re-walked at the call site.
|
|
667
|
+
*/
|
|
668
|
+
nextEnabledIndex = computed(() => {
|
|
669
|
+
const stepsOnly = this.stepsOnly();
|
|
670
|
+
let next = this.activeStepIndex() + 1;
|
|
671
|
+
while (next < stepsOnly.length && stepsOnly[next].disabled()) {
|
|
672
|
+
next++;
|
|
673
|
+
}
|
|
674
|
+
return next;
|
|
675
|
+
}, ...(ngDevMode ? [{ debugName: "nextEnabledIndex" }] : /* istanbul ignore next */ []));
|
|
676
|
+
/**
|
|
677
|
+
* Previous enabled step-only index before the active one, skipping
|
|
678
|
+
* disabled steps. Returns `-1` when no enabled step precedes. Single
|
|
679
|
+
* source for `selectPrevious()` and the `canGoPrevious` bound.
|
|
680
|
+
*/
|
|
681
|
+
previousEnabledIndex = computed(() => {
|
|
682
|
+
const stepsOnly = this.stepsOnly();
|
|
683
|
+
let prev = this.activeStepIndex() - 1;
|
|
684
|
+
while (prev >= 0 && stepsOnly[prev].disabled()) {
|
|
685
|
+
prev--;
|
|
686
|
+
}
|
|
687
|
+
return prev;
|
|
688
|
+
}, ...(ngDevMode ? [{ debugName: "previousEnabledIndex" }] : /* istanbul ignore next */ []));
|
|
689
|
+
/** {@inheritDoc CngxStepperHost.stepCount} */
|
|
690
|
+
stepCount = computed(() => this.stepsOnly().length, ...(ngDevMode ? [{ debugName: "stepCount" }] : /* istanbul ignore next */ []));
|
|
691
|
+
/** {@inheritDoc CngxStepperHost.isFirstStep} */
|
|
692
|
+
isFirstStep = computed(() => this.clampedIndex() <= 0, ...(ngDevMode ? [{ debugName: "isFirstStep" }] : /* istanbul ignore next */ []));
|
|
693
|
+
/** {@inheritDoc CngxStepperHost.isLastStep} */
|
|
694
|
+
isLastStep = computed(() => this.clampedIndex() >= this.stepCount() - 1, ...(ngDevMode ? [{ debugName: "isLastStep" }] : /* istanbul ignore next */ []));
|
|
695
|
+
/**
|
|
696
|
+
* {@inheritDoc CngxStepperHost.canGoNext}
|
|
697
|
+
*
|
|
698
|
+
* Derives from the same `nextEnabledIndex` + `isLinearBlocked`
|
|
699
|
+
* predicates `select()`/`selectNext()` enforce, so the affordance can
|
|
700
|
+
* never drift from the navigation it gates.
|
|
701
|
+
*/
|
|
702
|
+
canGoNext = computed(() => {
|
|
703
|
+
const next = this.nextEnabledIndex();
|
|
704
|
+
return next < this.stepCount() && !this.isLinearBlocked(next);
|
|
705
|
+
}, ...(ngDevMode ? [{ debugName: "canGoNext" }] : /* istanbul ignore next */ []));
|
|
706
|
+
/** {@inheritDoc CngxStepperHost.canGoPrevious} */
|
|
707
|
+
canGoPrevious = computed(() => this.previousEnabledIndex() >= 0, ...(ngDevMode ? [{ debugName: "canGoPrevious" }] : /* istanbul ignore next */ []));
|
|
708
|
+
/** {@inheritDoc CngxStepperHost.busy} */
|
|
709
|
+
busy = computed(() => this.commitState.status() === 'pending', ...(ngDevMode ? [{ debugName: "busy" }] : /* istanbul ignore next */ []));
|
|
710
|
+
/** {@inheritDoc CngxStepperHost.nextStepLabel} */
|
|
711
|
+
nextStepLabel = computed(() => this.stepsOnly()[this.nextEnabledIndex()]?.label(), ...(ngDevMode ? [{ debugName: "nextStepLabel" }] : /* istanbul ignore next */ []));
|
|
712
|
+
/** {@inheritDoc CngxStepperHost.previousStepLabel} */
|
|
713
|
+
previousStepLabel = computed(() => this.stepsOnly()[this.previousEnabledIndex()]?.label(), ...(ngDevMode ? [{ debugName: "previousStepLabel" }] : /* istanbul ignore next */ []));
|
|
714
|
+
constructor() {
|
|
715
|
+
if (isDevMode()) {
|
|
716
|
+
afterNextRender(() => {
|
|
717
|
+
const stepNodes = this.flatSteps().filter((n) => n.kind === 'step');
|
|
718
|
+
if (stepNodes.length > 6 && stepNodes.every((n) => n.parentId === null)) {
|
|
719
|
+
console.warn('[cngx-stepper] more than 6 steps at the same depth; consider wrapping logical groups in <cngx-step-group> for better UX');
|
|
720
|
+
}
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
}
|
|
461
724
|
// Flat id lookup; rebuilt into the hierarchical tree on each
|
|
462
725
|
// register/unregister.
|
|
463
726
|
registry = new Map();
|
|
464
727
|
insertionOrder = [];
|
|
465
728
|
register(handle, parentId = null) {
|
|
466
729
|
if (this.registry.has(handle.id)) {
|
|
467
|
-
// Idempotent re-register
|
|
730
|
+
// Idempotent re-register - replace the handle, keep the ordering slot.
|
|
468
731
|
const entry = this.registry.get(handle.id);
|
|
469
732
|
entry.reg = handle;
|
|
470
733
|
entry.parentId = parentId;
|
|
@@ -510,6 +773,7 @@ class CngxStepperPresenter {
|
|
|
510
773
|
disabled: entry.reg.disabled,
|
|
511
774
|
state: entry.reg.state,
|
|
512
775
|
errorAggregator: entry.reg.errorAggregator,
|
|
776
|
+
errorMessage: entry.reg.errorMessage,
|
|
513
777
|
children,
|
|
514
778
|
depth,
|
|
515
779
|
parentId: entry.parentId,
|
|
@@ -523,20 +787,48 @@ class CngxStepperPresenter {
|
|
|
523
787
|
clearLastFailed() {
|
|
524
788
|
this.lastFailedIndexState.set(undefined);
|
|
525
789
|
}
|
|
790
|
+
/**
|
|
791
|
+
* Linear-gate predicate: `true` when linear mode forbids advancing to
|
|
792
|
+
* `target` because an incomplete (non-`success`, non-disabled) step
|
|
793
|
+
* sits between the active index and `target`. The single home for the
|
|
794
|
+
* linear slice check - `select()` and the `canGoNext` bound both
|
|
795
|
+
* consume it so the gate can never drift between navigation and its
|
|
796
|
+
* affordance.
|
|
797
|
+
*/
|
|
798
|
+
isLinearBlocked(target) {
|
|
799
|
+
if (!this.linear() || target <= this.activeStepIndex()) {
|
|
800
|
+
return false;
|
|
801
|
+
}
|
|
802
|
+
return this.stepsOnly()
|
|
803
|
+
.slice(this.activeStepIndex(), target)
|
|
804
|
+
.some((n) => n.state() !== 'success' && !n.disabled());
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* {@inheritDoc CngxStepperHost.canNavigateTo}
|
|
808
|
+
*
|
|
809
|
+
* Wraps the private {@link isLinearBlocked} predicate plus the
|
|
810
|
+
* per-step `disabled` check. The header-reachability contract surface;
|
|
811
|
+
* `isLinearBlocked` stays private so the organism reads this method,
|
|
812
|
+
* never the internal gate.
|
|
813
|
+
*/
|
|
814
|
+
canNavigateTo(index) {
|
|
815
|
+
const stepsOnly = this.stepsOnly();
|
|
816
|
+
if (index < 0 || index >= stepsOnly.length) {
|
|
817
|
+
return false;
|
|
818
|
+
}
|
|
819
|
+
if (stepsOnly[index].disabled()) {
|
|
820
|
+
return false;
|
|
821
|
+
}
|
|
822
|
+
return !this.isLinearBlocked(index);
|
|
823
|
+
}
|
|
526
824
|
select(index) {
|
|
527
825
|
const stepsOnly = this.stepsOnly();
|
|
528
826
|
if (stepsOnly.length === 0) {
|
|
529
827
|
return;
|
|
530
828
|
}
|
|
531
829
|
const target = Math.max(0, Math.min(index, stepsOnly.length - 1));
|
|
532
|
-
if (this.
|
|
533
|
-
|
|
534
|
-
const blocking = stepsOnly
|
|
535
|
-
.slice(this.activeStepIndex(), target)
|
|
536
|
-
.find((n) => n.state() !== 'success' && !n.disabled());
|
|
537
|
-
if (blocking) {
|
|
538
|
-
return;
|
|
539
|
-
}
|
|
830
|
+
if (this.isLinearBlocked(target)) {
|
|
831
|
+
return;
|
|
540
832
|
}
|
|
541
833
|
if (stepsOnly[target].disabled()) {
|
|
542
834
|
return;
|
|
@@ -547,7 +839,7 @@ class CngxStepperPresenter {
|
|
|
547
839
|
}
|
|
548
840
|
const action = this.commitAction();
|
|
549
841
|
if (!action) {
|
|
550
|
-
// No-action fast path
|
|
842
|
+
// No-action fast path - sync move, no commit window opens, so
|
|
551
843
|
// `originIndexDuringCommit` stays untouched. Clear the rejection
|
|
552
844
|
// flag if the user re-picked a previously-failed target.
|
|
553
845
|
this.activeStepIndex.set(target);
|
|
@@ -558,7 +850,7 @@ class CngxStepperPresenter {
|
|
|
558
850
|
}
|
|
559
851
|
// Commit-gated transition. Pessimistic holds at `previous` until
|
|
560
852
|
// the action resolves; optimistic advances now and rolls back on
|
|
561
|
-
// rejection. Supersede comes from the lifted commit-controller
|
|
853
|
+
// rejection. Supersede comes from the lifted commit-controller -
|
|
562
854
|
// a rapid second select() cancels the in-flight runner.
|
|
563
855
|
//
|
|
564
856
|
// Capture the safe-harbour origin exactly once on commit-window
|
|
@@ -571,7 +863,7 @@ class CngxStepperPresenter {
|
|
|
571
863
|
}
|
|
572
864
|
this.commitHandler.beginTransition(previous, target, action, (accept) => {
|
|
573
865
|
if (accept) {
|
|
574
|
-
// Success
|
|
866
|
+
// Success - origin no longer needed; clear the rejection
|
|
575
867
|
// flag if the user re-picked the failed target.
|
|
576
868
|
this.originIndexDuringCommitState.set(undefined);
|
|
577
869
|
if (this.lastFailedIndexState() === target) {
|
|
@@ -582,7 +874,7 @@ class CngxStepperPresenter {
|
|
|
582
874
|
}
|
|
583
875
|
}
|
|
584
876
|
else {
|
|
585
|
-
// Reject
|
|
877
|
+
// Reject - flag the target; RETAIN the origin so
|
|
586
878
|
// `liveAnnouncement` can resolve the origin label for the
|
|
587
879
|
// rich rollback phrase. Optimistic rolls back; pessimistic
|
|
588
880
|
// never moved.
|
|
@@ -594,21 +886,13 @@ class CngxStepperPresenter {
|
|
|
594
886
|
});
|
|
595
887
|
}
|
|
596
888
|
selectNext() {
|
|
597
|
-
const
|
|
598
|
-
|
|
599
|
-
while (next < stepsOnly.length && stepsOnly[next].disabled()) {
|
|
600
|
-
next++;
|
|
601
|
-
}
|
|
602
|
-
if (next < stepsOnly.length) {
|
|
889
|
+
const next = this.nextEnabledIndex();
|
|
890
|
+
if (next < this.stepsOnly().length) {
|
|
603
891
|
this.select(next);
|
|
604
892
|
}
|
|
605
893
|
}
|
|
606
894
|
selectPrevious() {
|
|
607
|
-
const
|
|
608
|
-
let prev = this.activeStepIndex() - 1;
|
|
609
|
-
while (prev >= 0 && stepsOnly[prev].disabled()) {
|
|
610
|
-
prev--;
|
|
611
|
-
}
|
|
895
|
+
const prev = this.previousEnabledIndex();
|
|
612
896
|
if (prev >= 0) {
|
|
613
897
|
this.activeStepIndex.set(prev);
|
|
614
898
|
}
|
|
@@ -641,17 +925,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
641
925
|
{ provide: CNGX_STATEFUL, useExisting: CngxStepperPresenter },
|
|
642
926
|
],
|
|
643
927
|
}]
|
|
644
|
-
}], propDecorators: { activeStepIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "activeStepIndex", required: false }] }, { type: i0.Output, args: ["activeStepIndexChange"] }], linearInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "linear", required: false }] }], orientationInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], commitAction: [{ type: i0.Input, args: [{ isSignal: true, alias: "commitAction", required: false }] }], commitModeInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "commitMode", required: false }] }] } });
|
|
928
|
+
}], ctorParameters: () => [], propDecorators: { activeStepIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "activeStepIndex", required: false }] }, { type: i0.Output, args: ["activeStepIndexChange"] }], linearInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "linear", required: false }] }], orientationInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], commitAction: [{ type: i0.Input, args: [{ isSignal: true, alias: "commitAction", required: false }] }], commitModeInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "commitMode", required: false }] }] } });
|
|
645
929
|
|
|
646
930
|
/**
|
|
647
931
|
* DI token providing a `CngxStepGroup`'s contract to nested `CngxStep` atoms.
|
|
648
932
|
* Steps inject this `optional: true` and fall back to {@link CNGX_STEPPER_HOST}.
|
|
933
|
+
*
|
|
934
|
+
* @category common/stepper
|
|
935
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/step-group-host.token.ts
|
|
936
|
+
* @since 0.1.0
|
|
649
937
|
*/
|
|
650
938
|
const CNGX_STEP_GROUP_HOST = new InjectionToken('CngxStepGroupHost');
|
|
651
939
|
|
|
652
940
|
/**
|
|
653
941
|
* DI token providing the rendering-surface contract to organism shells
|
|
654
942
|
* (`<cngx-stepper>`, `<cngx-mat-stepper>`) and consumer-authored skins.
|
|
943
|
+
*
|
|
944
|
+
* @category common/stepper
|
|
945
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/step-panel-host.token.ts
|
|
946
|
+
* @since 0.1.0
|
|
655
947
|
*/
|
|
656
948
|
const CNGX_STEP_PANEL_HOST = new InjectionToken('CngxStepPanelHost');
|
|
657
949
|
|
|
@@ -666,6 +958,13 @@ const CNGX_STEP_PANEL_HOST = new InjectionToken('CngxStepPanelHost');
|
|
|
666
958
|
* <input [disabled]="busy">
|
|
667
959
|
* </ng-template>
|
|
668
960
|
* ```
|
|
961
|
+
*
|
|
962
|
+
* @category common/stepper
|
|
963
|
+
* @wcag AA
|
|
964
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/step-content.directive.ts
|
|
965
|
+
* @since 0.1.0
|
|
966
|
+
* @relatedTo CngxStep, CngxStepLabel
|
|
967
|
+
* <example-url>http://localhost:4200/#/ui/stepper/stepper-horizontal/three-step-wizard</example-url>
|
|
669
968
|
*/
|
|
670
969
|
class CngxStepContent {
|
|
671
970
|
templateRef = inject(TemplateRef);
|
|
@@ -691,6 +990,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
691
990
|
* {{ node.label() }}
|
|
692
991
|
* </ng-template>
|
|
693
992
|
* ```
|
|
993
|
+
*
|
|
994
|
+
* @category common/stepper
|
|
995
|
+
* @wcag AA
|
|
996
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/step-label.directive.ts
|
|
997
|
+
* @since 0.1.0
|
|
998
|
+
* @relatedTo CngxStep, CngxStepContent, CngxStepGroupHeader
|
|
999
|
+
* <example-url>http://localhost:4200/#/ui/stepper/stepper-custom-labels/mixing-code-label-code-input-with-code-cngxsteplabel-code-slot</example-url>
|
|
694
1000
|
*/
|
|
695
1001
|
class CngxStepLabel {
|
|
696
1002
|
templateRef = inject(TemplateRef);
|
|
@@ -706,12 +1012,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
706
1012
|
}] });
|
|
707
1013
|
|
|
708
1014
|
/**
|
|
709
|
-
* Single-step atom. Registers with the nearest host
|
|
1015
|
+
* Single-step atom. Registers with the nearest host - either a
|
|
710
1016
|
* `CngxStepGroup` ({@link CNGX_STEP_GROUP_HOST}) or the root
|
|
711
1017
|
* `CngxStepperPresenter` ({@link CNGX_STEPPER_HOST}).
|
|
712
1018
|
*
|
|
713
1019
|
* `state` is a `linkedSignal` over `[disabled]`, `[completed]`, and
|
|
714
1020
|
* the optional `[errorAggregator]`'s `hasError()`.
|
|
1021
|
+
*
|
|
1022
|
+
* @category common/stepper
|
|
1023
|
+
* @docsKind primary
|
|
1024
|
+
* @wcag AA
|
|
1025
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/step.directive.ts
|
|
1026
|
+
* @since 0.1.0
|
|
1027
|
+
* @relatedTo CngxStepGroup, CngxStepperPresenter, CngxStepLabel, CngxStepContent
|
|
1028
|
+
* <example-url>http://localhost:4200/#/ui/stepper/stepper-horizontal/three-step-wizard</example-url>
|
|
715
1029
|
*/
|
|
716
1030
|
class CngxStep {
|
|
717
1031
|
id = input(nextUid('cngx-step'), ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
@@ -719,19 +1033,42 @@ class CngxStep {
|
|
|
719
1033
|
completed = input(false, ...(ngDevMode ? [{ debugName: "completed" }] : /* istanbul ignore next */ []));
|
|
720
1034
|
label = input('', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
721
1035
|
errorAggregator = input(undefined, ...(ngDevMode ? [{ debugName: "errorAggregator" }] : /* istanbul ignore next */ []));
|
|
1036
|
+
/**
|
|
1037
|
+
* Direct error flag for the common "this step is invalid" case - no
|
|
1038
|
+
* `errorAggregator` boilerplate required. `true` or a non-empty string
|
|
1039
|
+
* drives the error state; a string doubles as the inline message
|
|
1040
|
+
* (surfaced via the `*cngxStepError` slot and the mini-skin aggregate
|
|
1041
|
+
* line). `false` / `''` clear it. The aggregator stays the rich
|
|
1042
|
+
* multi-source forms path; the two channels compose (either errors).
|
|
1043
|
+
*/
|
|
1044
|
+
error = input(false, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
1045
|
+
/**
|
|
1046
|
+
* Resolved direct-error message: the `[error]` string when non-empty,
|
|
1047
|
+
* else `undefined`. Carried onto the registration / node so the error
|
|
1048
|
+
* slot + aggregate line can render it. `computed` over the input -
|
|
1049
|
+
* never written.
|
|
1050
|
+
*/
|
|
1051
|
+
errorMessage = computed(() => {
|
|
1052
|
+
const value = this.error();
|
|
1053
|
+
return typeof value === 'string' && value !== '' ? value : undefined;
|
|
1054
|
+
}, ...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
|
|
722
1055
|
labelSlot = contentChild(CngxStepLabel, ...(ngDevMode ? [{ debugName: "labelSlot" }] : /* istanbul ignore next */ []));
|
|
723
1056
|
contentSlot = contentChild(CngxStepContent, ...(ngDevMode ? [{ debugName: "contentSlot" }] : /* istanbul ignore next */ []));
|
|
724
1057
|
labelTemplate = this.labelSlot;
|
|
725
1058
|
contentTemplate = this.contentSlot;
|
|
726
1059
|
/**
|
|
727
1060
|
* Per-step status derived from inputs + aggregator. `linkedSignal`
|
|
728
|
-
* with structural equal
|
|
1061
|
+
* with structural equal - never written via `effect`.
|
|
729
1062
|
*/
|
|
730
|
-
state = linkedSignal({ ...(ngDevMode ? { debugName: "state" } : /* istanbul ignore next */ {}), source: () =>
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
1063
|
+
state = linkedSignal({ ...(ngDevMode ? { debugName: "state" } : /* istanbul ignore next */ {}), source: () => {
|
|
1064
|
+
const directError = this.error();
|
|
1065
|
+
return {
|
|
1066
|
+
disabled: this.disabled(),
|
|
1067
|
+
completed: this.completed(),
|
|
1068
|
+
errored: (directError !== false && directError !== '') ||
|
|
1069
|
+
(this.errorAggregator()?.hasError?.() ?? false),
|
|
1070
|
+
};
|
|
1071
|
+
},
|
|
735
1072
|
computation: ({ disabled, completed, errored }) => {
|
|
736
1073
|
if (disabled) {
|
|
737
1074
|
return 'disabled';
|
|
@@ -750,7 +1087,6 @@ class CngxStep {
|
|
|
750
1087
|
const stepperHost = inject(CNGX_STEPPER_HOST, { optional: true });
|
|
751
1088
|
const host = groupHost ?? stepperHost;
|
|
752
1089
|
if (!host) {
|
|
753
|
-
// No enclosing presenter or group — atom can't register. Fail loud.
|
|
754
1090
|
throw new Error('CngxStep: no enclosing CngxStepperPresenter or CngxStepGroup found. ' +
|
|
755
1091
|
'Wrap the step inside an element carrying [cngxStepper] or [cngxStepGroup].');
|
|
756
1092
|
}
|
|
@@ -762,11 +1098,12 @@ class CngxStep {
|
|
|
762
1098
|
disabled: this.disabled,
|
|
763
1099
|
state: this.state,
|
|
764
1100
|
errorAggregator: this.errorAggregator,
|
|
1101
|
+
errorMessage: this.errorMessage,
|
|
765
1102
|
});
|
|
766
1103
|
inject(DestroyRef).onDestroy(() => host.unregister(stepId));
|
|
767
1104
|
}
|
|
768
1105
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStep, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
769
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxStep, isStandalone: true, selector: "[cngxStep]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, completed: { classPropertyName: "completed", publicName: "completed", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, errorAggregator: { classPropertyName: "errorAggregator", publicName: "errorAggregator", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "labelSlot", first: true, predicate: CngxStepLabel, descendants: true, isSignal: true }, { propertyName: "contentSlot", first: true, predicate: CngxStepContent, descendants: true, isSignal: true }], exportAs: ["cngxStep"], ngImport: i0 });
|
|
1106
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxStep, isStandalone: true, selector: "[cngxStep]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, completed: { classPropertyName: "completed", publicName: "completed", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, errorAggregator: { classPropertyName: "errorAggregator", publicName: "errorAggregator", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "labelSlot", first: true, predicate: CngxStepLabel, descendants: true, isSignal: true }, { propertyName: "contentSlot", first: true, predicate: CngxStepContent, descendants: true, isSignal: true }], exportAs: ["cngxStep"], ngImport: i0 });
|
|
770
1107
|
}
|
|
771
1108
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStep, decorators: [{
|
|
772
1109
|
type: Directive,
|
|
@@ -775,7 +1112,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
775
1112
|
exportAs: 'cngxStep',
|
|
776
1113
|
standalone: true,
|
|
777
1114
|
}]
|
|
778
|
-
}], ctorParameters: () => [], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], completed: [{ type: i0.Input, args: [{ isSignal: true, alias: "completed", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], errorAggregator: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorAggregator", required: false }] }], labelSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxStepLabel), { isSignal: true }] }], contentSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxStepContent), { isSignal: true }] }] } });
|
|
1115
|
+
}], ctorParameters: () => [], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], completed: [{ type: i0.Input, args: [{ isSignal: true, alias: "completed", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], errorAggregator: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorAggregator", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }], labelSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxStepLabel), { isSignal: true }] }], contentSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxStepContent), { isSignal: true }] }] } });
|
|
779
1116
|
|
|
780
1117
|
/**
|
|
781
1118
|
* Step-group atom. Registers with the root presenter as a `kind: 'group'`
|
|
@@ -785,12 +1122,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
785
1122
|
* `aggregatedStatus` rolls up child states: `error` if any errored,
|
|
786
1123
|
* `success` if all are success, `pending` if any is pending or busy,
|
|
787
1124
|
* otherwise `idle`.
|
|
1125
|
+
*
|
|
1126
|
+
* @category common/stepper
|
|
1127
|
+
* @docsKind primary
|
|
1128
|
+
* @wcag AA
|
|
1129
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/step-group.directive.ts
|
|
1130
|
+
* @since 0.1.0
|
|
1131
|
+
* @relatedTo CngxStep, CngxStepperPresenter, CngxStepGroupHeader
|
|
1132
|
+
* <example-url>http://localhost:4200/#/ui/stepper/stepper-hierarchical/group-nested-steps-trailing-root-step</example-url>
|
|
788
1133
|
*/
|
|
789
1134
|
class CngxStepGroup {
|
|
790
1135
|
id = input(nextUid('cngx-step-group'), ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
791
1136
|
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
792
1137
|
label = input('', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
793
|
-
// Local child registry
|
|
1138
|
+
// Local child registry - only feeds `aggregatedStatus` below.
|
|
794
1139
|
// The presenter owns the canonical tree.
|
|
795
1140
|
childRegistry = signal([], ...(ngDevMode ? [{ debugName: "childRegistry" }] : /* istanbul ignore next */ []));
|
|
796
1141
|
aggregatedStatus = computed(() => {
|
|
@@ -867,6 +1212,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
867
1212
|
* </ng-template>
|
|
868
1213
|
* </cngx-stepper>
|
|
869
1214
|
* ```
|
|
1215
|
+
*
|
|
1216
|
+
* @category common/stepper/slots
|
|
1217
|
+
* @wcag AA
|
|
1218
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/slots/step-indicator.directive.ts
|
|
1219
|
+
* @since 0.1.0
|
|
1220
|
+
* @relatedTo CngxStepBadge, CngxStepBusySpinner, CngxStepRejection, CngxStepGroupHeader
|
|
1221
|
+
* <example-url>http://localhost:4200/#/ui/stepper/stepper-slot-overrides/custom-indicator-glyph-via-code-cngxstepindicator-code</example-url>
|
|
1222
|
+
* <example-url>http://localhost:4200/#/ui/stepper/stepper-slot-overrides/cross-skin-indicator-override</example-url>
|
|
870
1223
|
*/
|
|
871
1224
|
class CngxStepIndicator {
|
|
872
1225
|
templateRef = inject(TemplateRef);
|
|
@@ -895,6 +1248,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
895
1248
|
* </ng-template>
|
|
896
1249
|
* </cngx-stepper>
|
|
897
1250
|
* ```
|
|
1251
|
+
*
|
|
1252
|
+
* @category common/stepper/slots
|
|
1253
|
+
* @wcag AA
|
|
1254
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/slots/step-badge.directive.ts
|
|
1255
|
+
* @since 0.1.0
|
|
1256
|
+
* @relatedTo CngxStepIndicator, CngxStepBusySpinner, CngxStepRejection
|
|
1257
|
+
* <example-url>http://localhost:4200/#/ui/stepper/stepper-slot-overrides/custom-error-badge-via-code-cngxstepbadge-code</example-url>
|
|
1258
|
+
* <example-url>http://localhost:4200/#/ui/stepper/stepper-error-aggregation/per-step-error-badges</example-url>
|
|
898
1259
|
*/
|
|
899
1260
|
class CngxStepBadge {
|
|
900
1261
|
templateRef = inject(TemplateRef);
|
|
@@ -923,6 +1284,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
923
1284
|
* </ng-template>
|
|
924
1285
|
* </cngx-stepper>
|
|
925
1286
|
* ```
|
|
1287
|
+
*
|
|
1288
|
+
* @category common/stepper/slots
|
|
1289
|
+
* @wcag AA
|
|
1290
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/slots/step-busy-spinner.directive.ts
|
|
1291
|
+
* @since 0.1.0
|
|
1292
|
+
* @relatedTo CngxStepIndicator, CngxStepBadge, CngxStepRejection
|
|
1293
|
+
* <example-url>http://localhost:4200/#/ui/stepper/stepper-slot-overrides/custom-busy-spinner-via-code-cngxstepbusyspinner-code</example-url>
|
|
926
1294
|
*/
|
|
927
1295
|
class CngxStepBusySpinner {
|
|
928
1296
|
templateRef = inject(TemplateRef);
|
|
@@ -957,6 +1325,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
957
1325
|
* </ng-template>
|
|
958
1326
|
* </cngx-stepper>
|
|
959
1327
|
* ```
|
|
1328
|
+
*
|
|
1329
|
+
* @category common/stepper/slots
|
|
1330
|
+
* @wcag AA
|
|
1331
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/slots/step-rejection.directive.ts
|
|
1332
|
+
* @since 0.1.0
|
|
1333
|
+
* @relatedTo CngxStepBadge, CngxStepIndicator, CngxStepBusySpinner
|
|
1334
|
+
* <example-url>http://localhost:4200/#/ui/stepper/stepper-slot-overrides/rejection-decoration-via-code-cngxsteprejection-code</example-url>
|
|
960
1335
|
*/
|
|
961
1336
|
class CngxStepRejection {
|
|
962
1337
|
templateRef = inject(TemplateRef);
|
|
@@ -972,6 +1347,48 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
972
1347
|
}]
|
|
973
1348
|
}] });
|
|
974
1349
|
|
|
1350
|
+
/**
|
|
1351
|
+
* Slot directive for the per-step error-message template on
|
|
1352
|
+
* `<cngx-stepper>`. Discovered via `contentChild`; cascades through
|
|
1353
|
+
* `CNGX_STEPPER_CONFIG.templates.stepError` before falling back to the
|
|
1354
|
+
* built-in `{{ message }}` text. Mirrors {@link CngxStepRejection} so
|
|
1355
|
+
* consumer-authored templates read the same way across both channels.
|
|
1356
|
+
*
|
|
1357
|
+
* ```html
|
|
1358
|
+
* <cngx-stepper>
|
|
1359
|
+
* <ng-template cngxStepError let-message="message" let-errorLabels="errorLabels">
|
|
1360
|
+
* <strong>{{ message }}</strong>
|
|
1361
|
+
* @if (errorLabels.length > 1) {
|
|
1362
|
+
* <ul>
|
|
1363
|
+
* @for (label of errorLabels; track label) {
|
|
1364
|
+
* <li>{{ label }}</li>
|
|
1365
|
+
* }
|
|
1366
|
+
* </ul>
|
|
1367
|
+
* }
|
|
1368
|
+
* </ng-template>
|
|
1369
|
+
* </cngx-stepper>
|
|
1370
|
+
* ```
|
|
1371
|
+
*
|
|
1372
|
+
* @category common/stepper/slots
|
|
1373
|
+
* @wcag AA
|
|
1374
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/slots/step-error.directive.ts
|
|
1375
|
+
* @since 0.1.0
|
|
1376
|
+
* @relatedTo CngxStepRejection, CngxStepBadge, CngxStep
|
|
1377
|
+
*/
|
|
1378
|
+
class CngxStepError {
|
|
1379
|
+
templateRef = inject(TemplateRef);
|
|
1380
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepError, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1381
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxStepError, isStandalone: true, selector: "ng-template[cngxStepError]", exportAs: ["cngxStepError"], ngImport: i0 });
|
|
1382
|
+
}
|
|
1383
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepError, decorators: [{
|
|
1384
|
+
type: Directive,
|
|
1385
|
+
args: [{
|
|
1386
|
+
selector: 'ng-template[cngxStepError]',
|
|
1387
|
+
exportAs: 'cngxStepError',
|
|
1388
|
+
standalone: true,
|
|
1389
|
+
}]
|
|
1390
|
+
}] });
|
|
1391
|
+
|
|
975
1392
|
/**
|
|
976
1393
|
* Slot directive for the group-header template on `<cngx-stepper>`.
|
|
977
1394
|
* Discovered via `contentChild`; cascades through
|
|
@@ -985,6 +1402,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
985
1402
|
* </ng-template>
|
|
986
1403
|
* </cngx-stepper>
|
|
987
1404
|
* ```
|
|
1405
|
+
*
|
|
1406
|
+
* @category common/stepper/slots
|
|
1407
|
+
* @wcag AA
|
|
1408
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/slots/step-group-header.directive.ts
|
|
1409
|
+
* @since 0.1.0
|
|
1410
|
+
* @relatedTo CngxStepGroup, CngxStepIndicator, CngxStepLabel
|
|
1411
|
+
* <example-url>http://localhost:4200/#/ui/stepper/stepper-slot-overrides/custom-group-header-via-code-cngxstepgroupheader-code</example-url>
|
|
988
1412
|
*/
|
|
989
1413
|
class CngxStepGroupHeader {
|
|
990
1414
|
templateRef = inject(TemplateRef);
|
|
@@ -1002,7 +1426,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1002
1426
|
|
|
1003
1427
|
/**
|
|
1004
1428
|
* Slot directive for the empty-state placeholder on `<cngx-stepper>`.
|
|
1005
|
-
* Rendered when `flatSteps()` is empty
|
|
1429
|
+
* Rendered when `flatSteps()` is empty - async-loading or
|
|
1006
1430
|
* server-driven step lists get a "no steps yet" landmark rather than
|
|
1007
1431
|
* a collapsed strip.
|
|
1008
1432
|
*
|
|
@@ -1017,6 +1441,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1017
1441
|
* </ng-template>
|
|
1018
1442
|
* </cngx-stepper>
|
|
1019
1443
|
* ```
|
|
1444
|
+
*
|
|
1445
|
+
* @category common/stepper/slots
|
|
1446
|
+
* @wcag AA
|
|
1447
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/slots/stepper-empty.directive.ts
|
|
1448
|
+
* @since 0.1.0
|
|
1449
|
+
* @relatedTo CngxStepIndicator, CngxStepGroupHeader
|
|
1450
|
+
* <example-url>http://localhost:4200/#/ui/stepper/stepper-slot-overrides/empty-state-placeholder-via-code-cngxstepperempty-code</example-url>
|
|
1020
1451
|
*/
|
|
1021
1452
|
class CngxStepperEmpty {
|
|
1022
1453
|
templateRef = inject(TemplateRef);
|
|
@@ -1033,16 +1464,60 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1033
1464
|
}] });
|
|
1034
1465
|
|
|
1035
1466
|
/**
|
|
1036
|
-
*
|
|
1037
|
-
*
|
|
1467
|
+
* Slot directive for the dot-body template on `<cngx-dot-stepper>`.
|
|
1468
|
+
* Discovered via `contentChild`; cascades through
|
|
1469
|
+
* `CNGX_STEPPER_CONFIG.templates.dotStepperDot` before falling back to
|
|
1470
|
+
* the built-in empty body (the span itself paints the dot fill via CSS).
|
|
1471
|
+
*
|
|
1472
|
+
* ```html
|
|
1473
|
+
* <cngx-dot-stepper [(activeStepIndex)]="active" aria-label="Carousel">
|
|
1474
|
+
* <ng-template cngxDotStepperDot let-index let-active="active" let-completed="completed">
|
|
1475
|
+
* @if (active) {
|
|
1476
|
+
* <svg viewBox="0 0 10 10" aria-hidden="true"><circle cx="5" cy="5" r="3" fill="currentColor" /></svg>
|
|
1477
|
+
* } @else if (completed) {
|
|
1478
|
+
* <svg viewBox="0 0 10 10" aria-hidden="true"><path d="M2 5l2 2 4-4" stroke="currentColor" fill="none" /></svg>
|
|
1479
|
+
* }
|
|
1480
|
+
* </ng-template>
|
|
1481
|
+
* <div cngxStep label="Slide 1"></div>
|
|
1482
|
+
* <div cngxStep label="Slide 2"></div>
|
|
1483
|
+
* </cngx-dot-stepper>
|
|
1484
|
+
* ```
|
|
1485
|
+
*
|
|
1486
|
+
* @category common/stepper/slots
|
|
1487
|
+
* @wcag AA
|
|
1488
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/slots/dot-stepper-dot.directive.ts
|
|
1489
|
+
* @since 0.1.0
|
|
1490
|
+
* @relatedTo CngxStepIndicator, CngxStepBadge, CngxStepBusySpinner, CngxStepRejection
|
|
1491
|
+
* <example-url>http://localhost:4200/#/ui/stepper/dot-stepper/icon-dots-via-code-cngxdotstepperdot-code</example-url>
|
|
1492
|
+
* <example-url>http://localhost:4200/#/ui/stepper/dot-stepper/mobile-carousel</example-url>
|
|
1493
|
+
*/
|
|
1494
|
+
class CngxDotStepperDot {
|
|
1495
|
+
templateRef = inject(TemplateRef);
|
|
1496
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDotStepperDot, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1497
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxDotStepperDot, isStandalone: true, selector: "ng-template[cngxDotStepperDot]", exportAs: ["cngxDotStepperDot"], ngImport: i0 });
|
|
1498
|
+
}
|
|
1499
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDotStepperDot, decorators: [{
|
|
1500
|
+
type: Directive,
|
|
1501
|
+
args: [{
|
|
1502
|
+
selector: 'ng-template[cngxDotStepperDot]',
|
|
1503
|
+
exportAs: 'cngxDotStepperDot',
|
|
1504
|
+
standalone: true,
|
|
1505
|
+
}]
|
|
1506
|
+
}] });
|
|
1507
|
+
|
|
1508
|
+
/**
|
|
1509
|
+
* Wires the 3-stage template cascade for the `<cngx-stepper>` skin
|
|
1510
|
+
* slots: per-instance directive > `CNGX_STEPPER_CONFIG.templates.<key>`
|
|
1038
1511
|
* > `null` (built-in default).
|
|
1039
1512
|
*
|
|
1040
|
-
* Pure
|
|
1513
|
+
* Pure - no DI, no side effects. Safe to call from a field-init
|
|
1041
1514
|
* block. Sibling of `createTabOverflowTemplateBindings` and the
|
|
1042
1515
|
* family-wide `createTemplateRegistry`.
|
|
1043
1516
|
*
|
|
1044
|
-
* Tabs has no parallel slot surface yet
|
|
1517
|
+
* Tabs has no parallel slot surface yet - see
|
|
1045
1518
|
* `stepper-accepted-debt §3` for the planned Phase-4 closure.
|
|
1519
|
+
*
|
|
1520
|
+
* @category common/stepper/slots
|
|
1046
1521
|
*/
|
|
1047
1522
|
function createStepperTemplateBindings(opts) {
|
|
1048
1523
|
return {
|
|
@@ -1058,6 +1533,9 @@ function createStepperTemplateBindings(opts) {
|
|
|
1058
1533
|
rejection: computed(() => opts.rejectionSlot()?.templateRef ??
|
|
1059
1534
|
opts.config.templates?.rejection ??
|
|
1060
1535
|
null),
|
|
1536
|
+
stepError: computed(() => opts.errorSlot?.()?.templateRef ??
|
|
1537
|
+
opts.config.templates?.stepError ??
|
|
1538
|
+
null),
|
|
1061
1539
|
groupHeader: computed(() => opts.groupHeaderSlot()?.templateRef ??
|
|
1062
1540
|
opts.config.templates?.groupHeader ??
|
|
1063
1541
|
null),
|
|
@@ -1079,6 +1557,9 @@ function createStepperTemplateBindings(opts) {
|
|
|
1079
1557
|
* `*cngxStep*` slots or `withStep*Template` features.
|
|
1080
1558
|
*
|
|
1081
1559
|
* @internal
|
|
1560
|
+
* @category common/stepper
|
|
1561
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/glyphs.ts
|
|
1562
|
+
* @since 0.1.0
|
|
1082
1563
|
*/
|
|
1083
1564
|
const CNGX_STEPPER_GLYPHS = {
|
|
1084
1565
|
/** Default visual for `*cngxStepBadge` when no override is bound. */
|
|
@@ -1095,8 +1576,16 @@ const CNGX_STEPPER_GLYPHS = {
|
|
|
1095
1576
|
* - `mode = 'fragment'` (default) → `#step=customer`
|
|
1096
1577
|
* - `mode = 'queryParam'` with `paramName = 'step'` → `?step=customer`
|
|
1097
1578
|
*
|
|
1098
|
-
* `Router` is optional
|
|
1579
|
+
* `Router` is optional - without `@angular/router` the directive
|
|
1099
1580
|
* dev-warns once and becomes a no-op.
|
|
1581
|
+
*
|
|
1582
|
+
* @category common/stepper
|
|
1583
|
+
* @docsKind primary
|
|
1584
|
+
* @wcag AA
|
|
1585
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/router-sync.directive.ts
|
|
1586
|
+
* @since 0.1.0
|
|
1587
|
+
* @relatedTo CngxStepperPresenter, CNGX_STEPPER_CONFIG
|
|
1588
|
+
* <example-url>http://localhost:4200/#/ui/stepper/stepper-router-sync/deep-linking-with-fragment-queryparam-modes</example-url>
|
|
1100
1589
|
*/
|
|
1101
1590
|
class CngxStepperRouterSync {
|
|
1102
1591
|
// Default undefined so the cascade resolves through CNGX_STEPPER_CONFIG.
|
|
@@ -1112,7 +1601,7 @@ class CngxStepperRouterSync {
|
|
|
1112
1601
|
constructor() {
|
|
1113
1602
|
if (!this.router) {
|
|
1114
1603
|
afterNextRender(() => {
|
|
1115
|
-
console.warn('CngxStepperRouterSync: no Router available
|
|
1604
|
+
console.warn('CngxStepperRouterSync: no Router available - directive is a no-op. ' +
|
|
1116
1605
|
'Provide @angular/router via provideRouter(...) to enable deep-linking.');
|
|
1117
1606
|
});
|
|
1118
1607
|
return;
|
|
@@ -1188,24 +1677,41 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1188
1677
|
}]
|
|
1189
1678
|
}], ctorParameters: () => [], propDecorators: { modeInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "mode", required: false }] }], paramNameInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "paramName", required: false }] }], syncError: [{ type: i0.Output, args: ["syncError"] }] } });
|
|
1190
1679
|
|
|
1680
|
+
/** @internal */
|
|
1191
1681
|
const STEPPER_I18N_DEFAULTS = {
|
|
1192
1682
|
stepperLabel: 'Stepper',
|
|
1683
|
+
stepIndicatorRoleDescription: 'Step indicator',
|
|
1193
1684
|
selectedStep: (label, position, count) => `Step ${position} of ${count}: ${label}`,
|
|
1194
1685
|
stepCompleted: 'Completed',
|
|
1195
1686
|
stepErrored: 'Has errors',
|
|
1196
1687
|
stepHasErrors: (count) => `${count} error${count === 1 ? '' : 's'}`,
|
|
1197
1688
|
previousStep: 'Previous step',
|
|
1198
1689
|
nextStep: 'Next step',
|
|
1199
|
-
commitFailedRetry: 'Commit failed
|
|
1690
|
+
commitFailedRetry: 'Commit failed - retry?',
|
|
1200
1691
|
commitInFlight: 'Committing step…',
|
|
1201
1692
|
commitRolledBackTo: (originLabel) => `Reverted to step "${originLabel}".`,
|
|
1202
1693
|
stepRolledBackSuffix: 'This step was rolled back.',
|
|
1694
|
+
statusLabels: {
|
|
1695
|
+
done: 'Done',
|
|
1696
|
+
inProgress: 'In progress',
|
|
1697
|
+
upNext: 'Up next',
|
|
1698
|
+
errored: 'Errored',
|
|
1699
|
+
},
|
|
1700
|
+
textStepperFormat: (current, total) => `Step ${current} of ${total}`,
|
|
1203
1701
|
};
|
|
1204
1702
|
/**
|
|
1205
1703
|
* DI token for the resolved stepper i18n bundle. `providedIn: 'root'`
|
|
1206
1704
|
* with English defaults.
|
|
1705
|
+
*
|
|
1706
|
+
* @category common/stepper/i18n
|
|
1707
|
+
* @wcag AA
|
|
1708
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/i18n/stepper-i18n.ts
|
|
1709
|
+
* @since 0.1.0
|
|
1207
1710
|
*/
|
|
1208
|
-
const CNGX_STEPPER_I18N = new InjectionToken('CngxStepperI18n', {
|
|
1711
|
+
const CNGX_STEPPER_I18N = new InjectionToken('CngxStepperI18n', {
|
|
1712
|
+
providedIn: 'root',
|
|
1713
|
+
factory: () => STEPPER_I18N_DEFAULTS,
|
|
1714
|
+
});
|
|
1209
1715
|
/**
|
|
1210
1716
|
* Brands an i18n mutator with `_target: 'i18n'`. Every `with*` i18n
|
|
1211
1717
|
* feature returns one of these.
|
|
@@ -1216,19 +1722,30 @@ function defineStepperI18nFeature(fn) {
|
|
|
1216
1722
|
return Object.assign(fn, { _target: 'i18n' });
|
|
1217
1723
|
}
|
|
1218
1724
|
/**
|
|
1219
|
-
* Override stepper i18n labels. Partial override
|
|
1220
|
-
* the English default.
|
|
1725
|
+
* Override stepper i18n labels. Partial override - unset keys keep
|
|
1726
|
+
* the English default. {@link CngxStepperStatusLabels} is merged
|
|
1727
|
+
* key-by-key so consumers can override one pill label without
|
|
1728
|
+
* restating the rest. Sibling of `withStepperAriaLabels` /
|
|
1221
1729
|
* `withStepperFallbackLabels`.
|
|
1730
|
+
*
|
|
1731
|
+
* @category common/stepper/i18n
|
|
1222
1732
|
*/
|
|
1223
1733
|
function withStepperI18nLabels(overrides) {
|
|
1224
|
-
return defineStepperI18nFeature((bundle) => ({
|
|
1734
|
+
return defineStepperI18nFeature((bundle) => ({
|
|
1735
|
+
...bundle,
|
|
1736
|
+
...overrides,
|
|
1737
|
+
statusLabels: overrides.statusLabels
|
|
1738
|
+
? { ...bundle.statusLabels, ...overrides.statusLabels }
|
|
1739
|
+
: bundle.statusLabels,
|
|
1740
|
+
}));
|
|
1225
1741
|
}
|
|
1742
|
+
/** @internal */
|
|
1226
1743
|
function resolveI18nFeatures(features) {
|
|
1227
1744
|
return features.reduce((bundle, feat) => feat(bundle), STEPPER_I18N_DEFAULTS);
|
|
1228
1745
|
}
|
|
1229
1746
|
/**
|
|
1230
1747
|
* Provider for the stepper i18n bundle. Compose `withStepperI18nLabels(...)`
|
|
1231
|
-
* (plus any future i18n `with*`)
|
|
1748
|
+
* (plus any future i18n `with*`) - unset keys fall back to English.
|
|
1232
1749
|
*
|
|
1233
1750
|
* ```ts
|
|
1234
1751
|
* bootstrapApplication(AppComponent, {
|
|
@@ -1239,6 +1756,8 @@ function resolveI18nFeatures(features) {
|
|
|
1239
1756
|
* ],
|
|
1240
1757
|
* });
|
|
1241
1758
|
* ```
|
|
1759
|
+
*
|
|
1760
|
+
* @category common/stepper/i18n
|
|
1242
1761
|
*/
|
|
1243
1762
|
function provideStepperI18n(...features) {
|
|
1244
1763
|
return {
|
|
@@ -1248,11 +1767,894 @@ function provideStepperI18n(...features) {
|
|
|
1248
1767
|
}
|
|
1249
1768
|
/**
|
|
1250
1769
|
* Inject the resolved stepper i18n bundle in an injection context.
|
|
1770
|
+
*
|
|
1771
|
+
* @category common/stepper/i18n
|
|
1251
1772
|
*/
|
|
1252
1773
|
function injectStepperI18n() {
|
|
1253
1774
|
return inject(CNGX_STEPPER_I18N);
|
|
1254
1775
|
}
|
|
1255
1776
|
|
|
1777
|
+
/**
|
|
1778
|
+
* Resolve the status-pill label for a step node against the resolved
|
|
1779
|
+
* i18n bundle. Used by skins that surface a per-step status pill
|
|
1780
|
+
* (e.g. `stripe-status-rich`). Pure factory - no injection context,
|
|
1781
|
+
* no signal graph involvement.
|
|
1782
|
+
*
|
|
1783
|
+
* Resolution order:
|
|
1784
|
+
* 1. `success` data-state -> `statusLabels.done`
|
|
1785
|
+
* 2. `error` data-state -> `statusLabels.errored`
|
|
1786
|
+
* 3. `aria-current="step"` -> `statusLabels.inProgress`
|
|
1787
|
+
* 4. otherwise -> `statusLabels.upNext`
|
|
1788
|
+
*
|
|
1789
|
+
* Group nodes (non-step) return an empty string.
|
|
1790
|
+
*
|
|
1791
|
+
* @category common/stepper
|
|
1792
|
+
*/
|
|
1793
|
+
function resolveStepperStatusLabel(node, i18n, isActive) {
|
|
1794
|
+
if (node.kind !== 'step') {
|
|
1795
|
+
return '';
|
|
1796
|
+
}
|
|
1797
|
+
const labels = i18n.statusLabels;
|
|
1798
|
+
const state = node.state();
|
|
1799
|
+
return state === 'success'
|
|
1800
|
+
? labels.done
|
|
1801
|
+
: state === 'error'
|
|
1802
|
+
? labels.errored
|
|
1803
|
+
: isActive
|
|
1804
|
+
? labels.inProgress
|
|
1805
|
+
: labels.upNext;
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
/**
|
|
1809
|
+
* Returns a reactive `Signal<boolean>` that reflects whether the host
|
|
1810
|
+
* window matches a CSS media query (e.g. `(max-width: 480px)`). Used by
|
|
1811
|
+
* `<cngx-stepper>` to drive its mobile auto-collapse template branch.
|
|
1812
|
+
*
|
|
1813
|
+
* In SSR / non-DOM environments the signal stays `false` and the
|
|
1814
|
+
* listener is never wired.
|
|
1815
|
+
*
|
|
1816
|
+
* @category common/stepper
|
|
1817
|
+
*/
|
|
1818
|
+
function createMobileViewportSignal(mediaQuery, destroyRef) {
|
|
1819
|
+
const matches = signal(false, ...(ngDevMode ? [{ debugName: "matches" }] : /* istanbul ignore next */ []));
|
|
1820
|
+
if (typeof globalThis.matchMedia !== 'function') {
|
|
1821
|
+
return matches.asReadonly();
|
|
1822
|
+
}
|
|
1823
|
+
const mql = globalThis.matchMedia(mediaQuery);
|
|
1824
|
+
matches.set(mql.matches);
|
|
1825
|
+
const listener = (event) => matches.set(event.matches);
|
|
1826
|
+
mql.addEventListener('change', listener);
|
|
1827
|
+
destroyRef.onDestroy(() => mql.removeEventListener('change', listener));
|
|
1828
|
+
return matches.asReadonly();
|
|
1829
|
+
}
|
|
1830
|
+
/**
|
|
1831
|
+
* Resolves the active stepper display mode by combining a viewport
|
|
1832
|
+
* media-query with the configured `mobileCollapse` policy.
|
|
1833
|
+
* `'classic'` keeps the full strip; `'text'` / `'dots'` swap to the
|
|
1834
|
+
* matching compact variant.
|
|
1835
|
+
*
|
|
1836
|
+
* @category common/stepper
|
|
1837
|
+
*/
|
|
1838
|
+
function createStepperDisplayMode(mediaQuery, mobileCollapse, destroyRef) {
|
|
1839
|
+
const viewport = createMobileViewportSignal(mediaQuery, destroyRef);
|
|
1840
|
+
return computed(() => {
|
|
1841
|
+
if (!viewport()) {
|
|
1842
|
+
return 'classic';
|
|
1843
|
+
}
|
|
1844
|
+
const mode = mobileCollapse() ?? 'text';
|
|
1845
|
+
return mode === 'off' ? 'classic' : mode;
|
|
1846
|
+
});
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
/**
|
|
1850
|
+
* Level-2 helper resolving the three host-attribute cascades for
|
|
1851
|
+
* `<cngx-stepper>` (skin / connectors / mobileIndicatorPosition). Keeps
|
|
1852
|
+
* the organism class under the LOC guard while making the cascade
|
|
1853
|
+
* pattern reusable for any future host-attr the strip surfaces.
|
|
1854
|
+
*
|
|
1855
|
+
* Each computed honors Pillar 1 (Ableitung statt Verwaltung): per-instance
|
|
1856
|
+
* input wins over root config wins over library default. No manual sync.
|
|
1857
|
+
*
|
|
1858
|
+
* @internal
|
|
1859
|
+
*/
|
|
1860
|
+
function createStepperHostAttrs(inputs) {
|
|
1861
|
+
return {
|
|
1862
|
+
resolvedSkin: computed(() => inputs.skin() ?? inputs.config.skin ?? 'classic'),
|
|
1863
|
+
resolvedConnectors: computed(() => inputs.connectors() ?? inputs.config.connectors ?? false),
|
|
1864
|
+
resolvedMobileIndicatorPosition: computed(() => inputs.mobileIndicatorPosition() ?? inputs.config.mobileIndicatorPosition ?? 'top'),
|
|
1865
|
+
};
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
/**
|
|
1869
|
+
* Builds the WAI-ARIA APG arrow-key handler for a stepper strip. The
|
|
1870
|
+
* composed `CngxRovingTabindex` cannot reach view-template step buttons
|
|
1871
|
+
* (its `contentChildren` query only sees projected content), so the
|
|
1872
|
+
* organism wires this factory's return value to its host `(keydown)`
|
|
1873
|
+
* binding to honour the documented keyboard contract.
|
|
1874
|
+
*
|
|
1875
|
+
* Horizontal orientation: ArrowLeft / ArrowRight navigate. Vertical:
|
|
1876
|
+
* ArrowUp / ArrowDown. Home / End jump to the first / last flat step
|
|
1877
|
+
* regardless of orientation. The presenter's `select*` methods enforce
|
|
1878
|
+
* linear-mode gating so callers do not duplicate that check here.
|
|
1879
|
+
*
|
|
1880
|
+
* @internal
|
|
1881
|
+
*/
|
|
1882
|
+
function createStepperStripKeyboardNav(options) {
|
|
1883
|
+
const stepClass = options.stepClassName ?? 'cngx-stepper__step';
|
|
1884
|
+
const focusActive = () => {
|
|
1885
|
+
const activeId = options.presenter.activeStepId();
|
|
1886
|
+
if (!activeId) {
|
|
1887
|
+
return;
|
|
1888
|
+
}
|
|
1889
|
+
const buttonId = options.stepButtonIdFor(activeId);
|
|
1890
|
+
queueMicrotask(() => {
|
|
1891
|
+
const el = options.hostElement.querySelector(`[id="${buttonId}"]`);
|
|
1892
|
+
if (el instanceof HTMLElement) {
|
|
1893
|
+
el.focus();
|
|
1894
|
+
}
|
|
1895
|
+
});
|
|
1896
|
+
};
|
|
1897
|
+
return (event) => {
|
|
1898
|
+
if (options.enabled && !options.enabled()) {
|
|
1899
|
+
return;
|
|
1900
|
+
}
|
|
1901
|
+
const target = event.target;
|
|
1902
|
+
if (!target?.classList.contains(stepClass)) {
|
|
1903
|
+
return;
|
|
1904
|
+
}
|
|
1905
|
+
const isHorizontal = options.presenter.orientation() === 'horizontal';
|
|
1906
|
+
const nextKey = isHorizontal ? 'ArrowRight' : 'ArrowDown';
|
|
1907
|
+
const prevKey = isHorizontal ? 'ArrowLeft' : 'ArrowUp';
|
|
1908
|
+
if (event.key === nextKey) {
|
|
1909
|
+
event.preventDefault();
|
|
1910
|
+
options.presenter.selectNext();
|
|
1911
|
+
focusActive();
|
|
1912
|
+
}
|
|
1913
|
+
else if (event.key === prevKey) {
|
|
1914
|
+
event.preventDefault();
|
|
1915
|
+
options.presenter.selectPrevious();
|
|
1916
|
+
focusActive();
|
|
1917
|
+
}
|
|
1918
|
+
else if (event.key === 'Home') {
|
|
1919
|
+
event.preventDefault();
|
|
1920
|
+
options.presenter.select(0);
|
|
1921
|
+
focusActive();
|
|
1922
|
+
}
|
|
1923
|
+
else if (event.key === 'End') {
|
|
1924
|
+
event.preventDefault();
|
|
1925
|
+
options.presenter.select(options.flatStepCount() - 1);
|
|
1926
|
+
focusActive();
|
|
1927
|
+
}
|
|
1928
|
+
};
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
/**
|
|
1932
|
+
* Build the shared {@link CngxStepperStateView} over a presenter host and its
|
|
1933
|
+
* step-only projection. Pure factory - `computed()` only, no injection
|
|
1934
|
+
* context required, so any skin can allocate it in a field initializer.
|
|
1935
|
+
*
|
|
1936
|
+
* @category common/stepper
|
|
1937
|
+
* @since 0.1.0
|
|
1938
|
+
* @relatedTo CngxStepperHost, createStepperSlotContextBuilders
|
|
1939
|
+
*/
|
|
1940
|
+
function createStepperStateView(inputs) {
|
|
1941
|
+
const { presenter, stepsOnly } = inputs;
|
|
1942
|
+
const statusOf = (node) => node.state();
|
|
1943
|
+
const isBusy = (node) => node.kind === 'step' &&
|
|
1944
|
+
presenter.commitState.status() === 'pending' &&
|
|
1945
|
+
presenter.intendedStepIndex() === node.flatIndex;
|
|
1946
|
+
const isRejected = (node) => node.kind === 'step' && node.flatIndex >= 0 && node.flatIndex === presenter.lastFailedIndex();
|
|
1947
|
+
const hasErrorBadge = (node) => {
|
|
1948
|
+
if (node.kind !== 'step') {
|
|
1949
|
+
return false;
|
|
1950
|
+
}
|
|
1951
|
+
if (node.state() === 'error') {
|
|
1952
|
+
return true;
|
|
1953
|
+
}
|
|
1954
|
+
return !!node.errorAggregator?.()?.shouldShow?.();
|
|
1955
|
+
};
|
|
1956
|
+
const hasError = (node) => hasErrorBadge(node) || isRejected(node);
|
|
1957
|
+
const erroredSteps = computed(() => stepsOnly().filter((node) => hasError(node)), ...(ngDevMode ? [{ debugName: "erroredSteps" }] : /* istanbul ignore next */ []));
|
|
1958
|
+
const errorCount = computed(() => erroredSteps().length, ...(ngDevMode ? [{ debugName: "errorCount" }] : /* istanbul ignore next */ []));
|
|
1959
|
+
const firstErrorIndex = computed(() => erroredSteps()[0]?.flatIndex ?? -1, ...(ngDevMode ? [{ debugName: "firstErrorIndex" }] : /* istanbul ignore next */ []));
|
|
1960
|
+
const hasAnyError = computed(() => errorCount() > 0, ...(ngDevMode ? [{ debugName: "hasAnyError" }] : /* istanbul ignore next */ []));
|
|
1961
|
+
return {
|
|
1962
|
+
statusOf,
|
|
1963
|
+
isBusy,
|
|
1964
|
+
isRejected,
|
|
1965
|
+
hasErrorBadge,
|
|
1966
|
+
hasError,
|
|
1967
|
+
errorCount,
|
|
1968
|
+
firstErrorIndex,
|
|
1969
|
+
hasAnyError,
|
|
1970
|
+
};
|
|
1971
|
+
}
|
|
1972
|
+
/**
|
|
1973
|
+
* Aggregate error phrase shared by the minimal skins (text / progress-bar)
|
|
1974
|
+
* and the classic mobile-collapse text branch. A single errored step names
|
|
1975
|
+
* itself (`"Payment: Errored"`); several collapse to the i18n count phrase
|
|
1976
|
+
* (`"2 errors"`). Returns `''` when no step errored - callers gate on
|
|
1977
|
+
* `view.hasAnyError()` so the empty string never reaches the DOM.
|
|
1978
|
+
*
|
|
1979
|
+
* The optional `messageOf` resolver lets callers surface a per-step
|
|
1980
|
+
* reason (a direct `[error]` string or the first aggregator label) in the
|
|
1981
|
+
* single-error case instead of the generic `errored` status word. When
|
|
1982
|
+
* omitted - or when it returns `undefined`/`''` - the helper produces
|
|
1983
|
+
* byte-identical output to the no-resolver form, so existing callers
|
|
1984
|
+
* (the classic mobile-collapse summary) are a guaranteed no-op.
|
|
1985
|
+
*
|
|
1986
|
+
* Pure helper - reads signals at call time, intended to be wrapped in the
|
|
1987
|
+
* caller's `computed()`.
|
|
1988
|
+
*
|
|
1989
|
+
* @category common/stepper
|
|
1990
|
+
* @since 0.1.0
|
|
1991
|
+
*/
|
|
1992
|
+
function resolveStepperErrorSummary(view, stepsOnly, i18n, messageOf) {
|
|
1993
|
+
const count = view.errorCount();
|
|
1994
|
+
if (count === 0) {
|
|
1995
|
+
return '';
|
|
1996
|
+
}
|
|
1997
|
+
if (count === 1) {
|
|
1998
|
+
const node = stepsOnly()[view.firstErrorIndex()];
|
|
1999
|
+
const custom = node ? messageOf?.(node) : undefined;
|
|
2000
|
+
if (custom !== undefined && custom !== '') {
|
|
2001
|
+
return custom;
|
|
2002
|
+
}
|
|
2003
|
+
const label = node?.label();
|
|
2004
|
+
return label ? `${label}: ${i18n.statusLabels.errored}` : i18n.statusLabels.errored;
|
|
2005
|
+
}
|
|
2006
|
+
return i18n.stepHasErrors(count);
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
/**
|
|
2010
|
+
* Wrap a `(node) => TContext` builder so identical results return the
|
|
2011
|
+
* same reference. Keyed by the node object via `WeakMap`, so step-list
|
|
2012
|
+
* re-emits drop stale entries automatically. The structural comparison
|
|
2013
|
+
* is shallow because every context shape is a flat object.
|
|
2014
|
+
*
|
|
2015
|
+
* @internal
|
|
2016
|
+
*/
|
|
2017
|
+
function memoizeByNode(build) {
|
|
2018
|
+
const cache = new WeakMap();
|
|
2019
|
+
return (node) => {
|
|
2020
|
+
const next = build(node);
|
|
2021
|
+
const prev = cache.get(node);
|
|
2022
|
+
if (prev !== undefined && shallowEqual(prev, next)) {
|
|
2023
|
+
return prev;
|
|
2024
|
+
}
|
|
2025
|
+
cache.set(node, next);
|
|
2026
|
+
return next;
|
|
2027
|
+
};
|
|
2028
|
+
}
|
|
2029
|
+
/** @internal */
|
|
2030
|
+
function shallowEqual(a, b) {
|
|
2031
|
+
if (a === b) {
|
|
2032
|
+
return true;
|
|
2033
|
+
}
|
|
2034
|
+
const keysA = Object.keys(a);
|
|
2035
|
+
if (keysA.length !== Object.keys(b).length) {
|
|
2036
|
+
return false;
|
|
2037
|
+
}
|
|
2038
|
+
const ra = a;
|
|
2039
|
+
const rb = b;
|
|
2040
|
+
for (const k of keysA) {
|
|
2041
|
+
if (ra[k] !== rb[k]) {
|
|
2042
|
+
return false;
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
return true;
|
|
2046
|
+
}
|
|
2047
|
+
/**
|
|
2048
|
+
* Bundle the `*ContextFor` slot-context builders plus the small
|
|
2049
|
+
* `isActive` / `isStepBusy` / `showRejection` / `showErrorBadge` /
|
|
2050
|
+
* `showStepError` predicates the organism's template reads. Lives at
|
|
2051
|
+
* Level 2 so the `<cngx-stepper>` organism stays a thin shell.
|
|
2052
|
+
*
|
|
2053
|
+
* @internal
|
|
2054
|
+
*/
|
|
2055
|
+
function createStepperSlotContextBuilders(inputs) {
|
|
2056
|
+
const { presenter, stepsOnly, i18n } = inputs;
|
|
2057
|
+
// Single source for every per-step status / error / busy / rejection
|
|
2058
|
+
// derivation. The dot / text / progress-bar skins read the same view,
|
|
2059
|
+
// so the error contract stays identical across all four.
|
|
2060
|
+
const stateView = createStepperStateView({ presenter, stepsOnly });
|
|
2061
|
+
const isActive = (node) => node.kind === 'step' && node.id === presenter.activeStepId();
|
|
2062
|
+
const isStepBusy = stateView.isBusy;
|
|
2063
|
+
const showRejection = stateView.isRejected;
|
|
2064
|
+
const showErrorBadge = stateView.hasErrorBadge;
|
|
2065
|
+
// Validation-channel gate for the per-step error message. Mirrors the
|
|
2066
|
+
// error badge (state === 'error' via [error] / aggregator); the commit
|
|
2067
|
+
// rejection keeps its own `showRejection` slot, so the two channels
|
|
2068
|
+
// stay distinct.
|
|
2069
|
+
const showStepError = stateView.hasErrorBadge;
|
|
2070
|
+
// Memoize per-node so identical contexts return the same reference.
|
|
2071
|
+
// *ngTemplateOutlet pays an ngOnChanges shallow comparison on its
|
|
2072
|
+
// `context:` binding every CD pass; without this cache the outlet
|
|
2073
|
+
// sees a fresh literal each tick and re-pushes context to the
|
|
2074
|
+
// embedded view even when no source signal changed. Cache keys are
|
|
2075
|
+
// the node objects themselves so the WeakMap evicts naturally with
|
|
2076
|
+
// step-list re-emits.
|
|
2077
|
+
const indicatorContextFor = memoizeByNode((node) => {
|
|
2078
|
+
const position = node.flatIndex + 1;
|
|
2079
|
+
return {
|
|
2080
|
+
$implicit: position,
|
|
2081
|
+
position,
|
|
2082
|
+
node,
|
|
2083
|
+
active: isActive(node),
|
|
2084
|
+
status: node.state(),
|
|
2085
|
+
busy: isStepBusy(node),
|
|
2086
|
+
};
|
|
2087
|
+
});
|
|
2088
|
+
const badgeContextFor = memoizeByNode((node) => {
|
|
2089
|
+
const aggregator = node.errorAggregator?.();
|
|
2090
|
+
const count = aggregator?.errorCount() ?? 0;
|
|
2091
|
+
return { count, node };
|
|
2092
|
+
});
|
|
2093
|
+
const busySpinnerContextFor = memoizeByNode((node) => ({ node }));
|
|
2094
|
+
const rejectionContextFor = memoizeByNode((node) => {
|
|
2095
|
+
const failedIndex = node.flatIndex;
|
|
2096
|
+
const originIdx = presenter.originIndexDuringCommit();
|
|
2097
|
+
const originLabel = originIdx !== undefined ? stepsOnly()[originIdx]?.label() : undefined;
|
|
2098
|
+
return { failedIndex, originLabel, node };
|
|
2099
|
+
});
|
|
2100
|
+
const stepErrorContextFor = memoizeByNode((node) => {
|
|
2101
|
+
const aggregator = node.errorAggregator?.();
|
|
2102
|
+
const errorLabels = aggregator?.errorLabels?.() ?? [];
|
|
2103
|
+
const announcement = aggregator?.announcement?.() ?? '';
|
|
2104
|
+
// Resolution order: direct [error] string > first aggregator label >
|
|
2105
|
+
// i18n errored status phrase. Always non-empty so a bare
|
|
2106
|
+
// `{{ message }}` template renders a reason.
|
|
2107
|
+
const message = node.errorMessage?.() ?? errorLabels[0] ?? i18n.statusLabels.errored;
|
|
2108
|
+
return { node, message, errorLabels, announcement };
|
|
2109
|
+
});
|
|
2110
|
+
const groupHeaderContextFor = memoizeByNode((node) => ({
|
|
2111
|
+
group: node,
|
|
2112
|
+
expanded: true,
|
|
2113
|
+
status: node.state(),
|
|
2114
|
+
}));
|
|
2115
|
+
const stepLabelContextFor = memoizeByNode((node) => ({
|
|
2116
|
+
node,
|
|
2117
|
+
index: node.flatIndex + 1,
|
|
2118
|
+
active: isActive(node),
|
|
2119
|
+
busy: isStepBusy(node),
|
|
2120
|
+
disabled: node.disabled(),
|
|
2121
|
+
}));
|
|
2122
|
+
// Independent builder + independent cache: content + label contexts
|
|
2123
|
+
// share a shape today but the slot directives are separate contracts
|
|
2124
|
+
// (CngxStepContentContext vs CngxStepLabelContext) and will diverge
|
|
2125
|
+
// when one side gains a field. Aliasing the function would couple
|
|
2126
|
+
// both call sites to that future divergence.
|
|
2127
|
+
const stepContentContextFor = memoizeByNode((node) => ({
|
|
2128
|
+
node,
|
|
2129
|
+
index: node.flatIndex + 1,
|
|
2130
|
+
active: isActive(node),
|
|
2131
|
+
busy: isStepBusy(node),
|
|
2132
|
+
disabled: node.disabled(),
|
|
2133
|
+
}));
|
|
2134
|
+
return {
|
|
2135
|
+
isActive,
|
|
2136
|
+
isStepBusy,
|
|
2137
|
+
showRejection,
|
|
2138
|
+
showErrorBadge,
|
|
2139
|
+
showStepError,
|
|
2140
|
+
indicatorContextFor,
|
|
2141
|
+
badgeContextFor,
|
|
2142
|
+
busySpinnerContextFor,
|
|
2143
|
+
rejectionContextFor,
|
|
2144
|
+
stepErrorContextFor,
|
|
2145
|
+
groupHeaderContextFor,
|
|
2146
|
+
stepLabelContextFor,
|
|
2147
|
+
stepContentContextFor,
|
|
2148
|
+
};
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2151
|
+
/**
|
|
2152
|
+
* Build the reactive SR-announcement surface for `<cngx-stepper>`.
|
|
2153
|
+
* Lives at Level 2 so the Level-4 organism stays a thin shell per
|
|
2154
|
+
* `reference_atomic_decompose`.
|
|
2155
|
+
*
|
|
2156
|
+
* @internal
|
|
2157
|
+
*/
|
|
2158
|
+
function createStepperAnnouncementBuilders(inputs) {
|
|
2159
|
+
const { presenter, stepsOnly, i18n } = inputs;
|
|
2160
|
+
const liveAnnouncement = computed(() => {
|
|
2161
|
+
const current = presenter.commitTransition.current();
|
|
2162
|
+
if (current === 'pending') {
|
|
2163
|
+
return i18n.commitInFlight;
|
|
2164
|
+
}
|
|
2165
|
+
if (current === 'error') {
|
|
2166
|
+
// Sync commit-handler errors collapse pending -> error in one signal
|
|
2167
|
+
// flush; tracker sees `previous === 'idle'`. Guard stays loose so
|
|
2168
|
+
// sync-rejection (`commitAction = () => false`) still announces.
|
|
2169
|
+
const failedIdx = presenter.lastFailedIndex();
|
|
2170
|
+
const originIdx = presenter.originIndexDuringCommit();
|
|
2171
|
+
if (failedIdx !== undefined && originIdx !== undefined) {
|
|
2172
|
+
const originLabel = stepsOnly()[originIdx]?.label();
|
|
2173
|
+
if (originLabel) {
|
|
2174
|
+
return i18n.commitRolledBackTo(originLabel);
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
return i18n.commitFailedRetry;
|
|
2178
|
+
}
|
|
2179
|
+
return '';
|
|
2180
|
+
}, ...(ngDevMode ? [{ debugName: "liveAnnouncement" }] : /* istanbul ignore next */ []));
|
|
2181
|
+
const statusPhrase = (node) => {
|
|
2182
|
+
const aggregator = node.errorAggregator?.();
|
|
2183
|
+
let base = aggregator?.shouldShow?.() ? (aggregator.announcement?.() ?? '') : '';
|
|
2184
|
+
if (!base && node.kind === 'step') {
|
|
2185
|
+
const idx = node.flatIndex;
|
|
2186
|
+
if (idx >= 0) {
|
|
2187
|
+
base = i18n.selectedStep(node.label(), idx + 1, stepsOnly().length);
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
if (!base) {
|
|
2191
|
+
return '';
|
|
2192
|
+
}
|
|
2193
|
+
return node.kind === 'step' && node.flatIndex === presenter.lastFailedIndex()
|
|
2194
|
+
? `${base} ${i18n.stepRolledBackSuffix}`
|
|
2195
|
+
: base;
|
|
2196
|
+
};
|
|
2197
|
+
const groupStatusPhrase = (node) => {
|
|
2198
|
+
const status = node.state();
|
|
2199
|
+
if (status === 'error') {
|
|
2200
|
+
return i18n.stepErrored;
|
|
2201
|
+
}
|
|
2202
|
+
if (status === 'success') {
|
|
2203
|
+
return i18n.stepCompleted;
|
|
2204
|
+
}
|
|
2205
|
+
return '';
|
|
2206
|
+
};
|
|
2207
|
+
return { liveAnnouncement, statusPhrase, groupStatusPhrase };
|
|
2208
|
+
}
|
|
2209
|
+
|
|
2210
|
+
/**
|
|
2211
|
+
* Routes a `CngxSwipe` gesture into the stepper presenter so the
|
|
2212
|
+
* organism's mobile-collapse panels gain swipe-driven navigation
|
|
2213
|
+
* without duplicating pointer handling. Applied via `hostDirectives`
|
|
2214
|
+
* on `<cngx-stepper>`; consumer-facing input `[mobileSwipe]` is
|
|
2215
|
+
* forwarded through the host metadata.
|
|
2216
|
+
*
|
|
2217
|
+
* Cascade for `swipeEnabled`: per-instance `[mobileSwipe]` ->
|
|
2218
|
+
* `CNGX_STEPPER_CONFIG.mobileSwipe` -> library default `true`.
|
|
2219
|
+
*
|
|
2220
|
+
* Direction routing is asymmetric, matching the presenter's existing
|
|
2221
|
+
* navigation surface: `left` -> `selectNext()` -> `select()` (linear
|
|
2222
|
+
* gate + commit window apply identically to a click); `right` ->
|
|
2223
|
+
* `selectPrevious()` (ungated direct back-move, same path as the
|
|
2224
|
+
* existing strip back-nav).
|
|
2225
|
+
*
|
|
2226
|
+
* @category common/stepper
|
|
2227
|
+
* @docsKind primary
|
|
2228
|
+
* @wcag AA
|
|
2229
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/swipe-nav.directive.ts
|
|
2230
|
+
* @since 0.1.0
|
|
2231
|
+
*/
|
|
2232
|
+
class CngxStepperSwipeNav {
|
|
2233
|
+
/**
|
|
2234
|
+
* Per-instance opt-out for the built-in swipe navigation. `undefined`
|
|
2235
|
+
* defers to the config cascade.
|
|
2236
|
+
*/
|
|
2237
|
+
mobileSwipe = input(undefined, ...(ngDevMode ? [{ debugName: "mobileSwipe" }] : /* istanbul ignore next */ []));
|
|
2238
|
+
host = inject(CNGX_STEPPER_HOST);
|
|
2239
|
+
config = injectStepperConfig();
|
|
2240
|
+
/** Resolved enabled flag (Input -> config -> default(true)). Boolean output, no `equal` fn required. */
|
|
2241
|
+
swipeEnabled = computed(() => this.mobileSwipe() ?? this.config.mobileSwipe ?? true, ...(ngDevMode ? [{ debugName: "swipeEnabled" }] : /* istanbul ignore next */ []));
|
|
2242
|
+
/**
|
|
2243
|
+
* Route a swipe direction into the presenter. `left` and `right`
|
|
2244
|
+
* map onto `selectNext` and `selectPrevious`; vertical directions
|
|
2245
|
+
* are ignored.
|
|
2246
|
+
*/
|
|
2247
|
+
handleSwipe(direction) {
|
|
2248
|
+
if (direction === 'left') {
|
|
2249
|
+
this.host.selectNext();
|
|
2250
|
+
}
|
|
2251
|
+
else if (direction === 'right') {
|
|
2252
|
+
this.host.selectPrevious();
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepperSwipeNav, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2256
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxStepperSwipeNav, isStandalone: true, selector: "[cngxStepperSwipeNav]", inputs: { mobileSwipe: { classPropertyName: "mobileSwipe", publicName: "mobileSwipe", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
|
|
2257
|
+
}
|
|
2258
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepperSwipeNav, decorators: [{
|
|
2259
|
+
type: Directive,
|
|
2260
|
+
args: [{
|
|
2261
|
+
selector: '[cngxStepperSwipeNav]',
|
|
2262
|
+
standalone: true,
|
|
2263
|
+
}]
|
|
2264
|
+
}], propDecorators: { mobileSwipe: [{ type: i0.Input, args: [{ isSignal: true, alias: "mobileSwipe", required: false }] }] } });
|
|
2265
|
+
|
|
2266
|
+
/**
|
|
2267
|
+
* Reusable progress-hint atom for any stepper organism. Renders the
|
|
2268
|
+
* resolved `CngxStepperI18n.textStepperFormat(current, total)` string
|
|
2269
|
+
* inside a `<span>` and pipes the value through an `aria-live` region
|
|
2270
|
+
* so screen readers announce step transitions.
|
|
2271
|
+
*
|
|
2272
|
+
* The text shape is fully owned by the i18n format function - drop the
|
|
2273
|
+
* atom inside any `<cngx-stepper>` / `<cngx-mat-stepper>` /
|
|
2274
|
+
* `<cngx-progress-bar-stepper>` tree and override the format upstream
|
|
2275
|
+
* to change every instance at once:
|
|
2276
|
+
*
|
|
2277
|
+
* ```ts
|
|
2278
|
+
* provideStepperI18n(withStepperI18nLabels({
|
|
2279
|
+
* textStepperFormat: (c, t) => `${c}/${t} complete`,
|
|
2280
|
+
* }));
|
|
2281
|
+
* ```
|
|
2282
|
+
*
|
|
2283
|
+
* Canonical shapes the atom supports without any markup changes:
|
|
2284
|
+
* - `Step N of M` (default)
|
|
2285
|
+
* - `N/M complete`
|
|
2286
|
+
* - `N/M`
|
|
2287
|
+
* - `Math.round(c/t * 100)%`
|
|
2288
|
+
* - any consumer-defined string the closure returns.
|
|
2289
|
+
*
|
|
2290
|
+
* `[live]="false"` opts the atom out of the `aria-live` region when
|
|
2291
|
+
* the caption sits next to another live region (e.g. a stepper that
|
|
2292
|
+
* already mounts its own live announcer) to prevent double announces.
|
|
2293
|
+
*
|
|
2294
|
+
* @category common/stepper
|
|
2295
|
+
* @docsKind primary
|
|
2296
|
+
* @since 0.1.0
|
|
2297
|
+
* @relatedTo CngxStepperHost, CngxStepperI18n
|
|
2298
|
+
* <example-url>http://localhost:4200/#/ui/stepper/stepper-count/multi-instance-format-overrides</example-url>
|
|
2299
|
+
*/
|
|
2300
|
+
class CngxStepperCount {
|
|
2301
|
+
/** When `true`, wraps the rendered string in an `aria-live="polite"` span. */
|
|
2302
|
+
live = input(true, ...(ngDevMode ? [{ debugName: "live" }] : /* istanbul ignore next */ []));
|
|
2303
|
+
/**
|
|
2304
|
+
* Per-instance format override. Receives `(current, total)` where
|
|
2305
|
+
* `current` is the 1-based active step position and `total` is
|
|
2306
|
+
* `host.stepsOnly().length`. When omitted, the resolved
|
|
2307
|
+
* `CngxStepperI18n.textStepperFormat` is used so two siblings can
|
|
2308
|
+
* each show a different shape inside the same stepper tree.
|
|
2309
|
+
*/
|
|
2310
|
+
format = input(undefined, ...(ngDevMode ? [{ debugName: "format" }] : /* istanbul ignore next */ []));
|
|
2311
|
+
/**
|
|
2312
|
+
* Explicit stepper-host reference. Set this when the atom sits
|
|
2313
|
+
* *outside* a `<cngx-stepper>` (e.g. in a sibling layout header)
|
|
2314
|
+
* by exporting the stepper as a template ref:
|
|
2315
|
+
* `<cngx-stepper #s="cngxStepper">` then `[host]="s.presenter"`.
|
|
2316
|
+
* When unset, the atom injects the ambient `CNGX_STEPPER_HOST` from
|
|
2317
|
+
* its DI tree. Accepts {@link CngxStepperCountHost} so a narrow stub
|
|
2318
|
+
* (active index + steps signal) also fits.
|
|
2319
|
+
*/
|
|
2320
|
+
host = input(null, ...(ngDevMode ? [{ debugName: "host" }] : /* istanbul ignore next */ []));
|
|
2321
|
+
injectedHost = inject(CNGX_STEPPER_HOST, { optional: true });
|
|
2322
|
+
i18n = injectStepperI18n();
|
|
2323
|
+
resolvedHost = computed(() => this.host() ?? this.injectedHost, ...(ngDevMode ? [{ debugName: "resolvedHost" }] : /* istanbul ignore next */ []));
|
|
2324
|
+
/** Resolved caption - reactive on activeStepIndex / stepsOnly / format / i18n. */
|
|
2325
|
+
label = computed(() => {
|
|
2326
|
+
const host = this.resolvedHost();
|
|
2327
|
+
if (!host) {
|
|
2328
|
+
return '';
|
|
2329
|
+
}
|
|
2330
|
+
const current = host.activeStepIndex() + 1;
|
|
2331
|
+
const total = host.stepsOnly().length;
|
|
2332
|
+
const fmt = this.format() ?? this.i18n.textStepperFormat;
|
|
2333
|
+
return fmt(current, total);
|
|
2334
|
+
}, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
2335
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepperCount, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2336
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxStepperCount, isStandalone: true, selector: "cngx-stepper-count", inputs: { live: { classPropertyName: "live", publicName: "live", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, host: { classPropertyName: "host", publicName: "host", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "cngx-stepper-count" }, ngImport: i0, template: '<span [attr.aria-live]="live() ? \'polite\' : null">{{ label() }}</span>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
2337
|
+
}
|
|
2338
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepperCount, decorators: [{
|
|
2339
|
+
type: Component,
|
|
2340
|
+
args: [{
|
|
2341
|
+
selector: 'cngx-stepper-count',
|
|
2342
|
+
standalone: true,
|
|
2343
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2344
|
+
encapsulation: ViewEncapsulation.None,
|
|
2345
|
+
template: '<span [attr.aria-live]="live() ? \'polite\' : null">{{ label() }}</span>',
|
|
2346
|
+
host: {
|
|
2347
|
+
class: 'cngx-stepper-count',
|
|
2348
|
+
},
|
|
2349
|
+
}]
|
|
2350
|
+
}], propDecorators: { live: [{ type: i0.Input, args: [{ isSignal: true, alias: "live", required: false }] }], format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }], host: [{ type: i0.Input, args: [{ isSignal: true, alias: "host", required: false }] }] } });
|
|
2351
|
+
|
|
2352
|
+
/**
|
|
2353
|
+
* Turns any clickable element into a stepper "Back" control. Resolves
|
|
2354
|
+
* its host the same way `CngxStepperCount` does - an explicit `[host]`
|
|
2355
|
+
* input (for placement outside the stepper tree) falling back to the
|
|
2356
|
+
* ambient {@link CNGX_STEPPER_HOST}.
|
|
2357
|
+
*
|
|
2358
|
+
* `(click)` retreats via `selectPrevious()`. The control disables itself
|
|
2359
|
+
* when there is no earlier step (`!canGoPrevious()`) OR while a commit is
|
|
2360
|
+
* in flight (`busy()`): `selectPrevious()` writes `activeStepIndex`
|
|
2361
|
+
* directly, bypassing the commit controller, so disabling it during an
|
|
2362
|
+
* in-flight forward commit prevents a navigate-mid-commit race. The gate
|
|
2363
|
+
* is the host's `canGoPrevious` bound - never re-derived from `stepsOnly`.
|
|
2364
|
+
*
|
|
2365
|
+
* Reflects the disabled state via `aria-disabled` only - never native
|
|
2366
|
+
* `disabled` - so the control stays focusable and AT-reachable; the
|
|
2367
|
+
* `handleClick` guard blocks the action while disabled.
|
|
2368
|
+
*
|
|
2369
|
+
* ```html
|
|
2370
|
+
* <button cngxStepperPrevious>Back</button>
|
|
2371
|
+
* ```
|
|
2372
|
+
*
|
|
2373
|
+
* @category common/stepper
|
|
2374
|
+
* @docsKind primary
|
|
2375
|
+
* @wcag AA
|
|
2376
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/controls/stepper-previous.directive.ts
|
|
2377
|
+
* @since 0.1.0
|
|
2378
|
+
* @relatedTo CngxStepperNext, CngxStepperComplete, CngxStepperHost
|
|
2379
|
+
*/
|
|
2380
|
+
class CngxStepperPrevious {
|
|
2381
|
+
/**
|
|
2382
|
+
* Explicit stepper-host reference for placement *outside* the stepper
|
|
2383
|
+
* tree (`[host]="s.presenter"`). When unset, the ambient
|
|
2384
|
+
* {@link CNGX_STEPPER_HOST} is injected.
|
|
2385
|
+
*/
|
|
2386
|
+
host = input(null, ...(ngDevMode ? [{ debugName: "host" }] : /* istanbul ignore next */ []));
|
|
2387
|
+
injectedHost = inject(CNGX_STEPPER_HOST, { optional: true });
|
|
2388
|
+
resolvedHost = computed(() => this.host() ?? this.injectedHost, ...(ngDevMode ? [{ debugName: "resolvedHost" }] : /* istanbul ignore next */ []));
|
|
2389
|
+
coPlacedAsyncClick = inject(CngxAsyncClick, { self: true, optional: true });
|
|
2390
|
+
constructor() {
|
|
2391
|
+
if (isDevMode() && this.coPlacedAsyncClick) {
|
|
2392
|
+
console.warn('CngxStepperPrevious: [cngxStepperPrevious] and [cngxAsyncClick] on the same element ' +
|
|
2393
|
+
'both gate aria-disabled. Use one or the other.');
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
/** `true` when retreat is unavailable: no earlier step or commit busy. */
|
|
2397
|
+
disabled = computed(() => {
|
|
2398
|
+
const host = this.resolvedHost();
|
|
2399
|
+
return !host || !host.canGoPrevious() || host.busy();
|
|
2400
|
+
}, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
2401
|
+
/** @internal */
|
|
2402
|
+
handleClick(event) {
|
|
2403
|
+
if (this.disabled()) {
|
|
2404
|
+
event.preventDefault();
|
|
2405
|
+
return;
|
|
2406
|
+
}
|
|
2407
|
+
this.resolvedHost()?.selectPrevious();
|
|
2408
|
+
}
|
|
2409
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepperPrevious, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2410
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxStepperPrevious, isStandalone: true, selector: "[cngxStepperPrevious]", inputs: { host: { classPropertyName: "host", publicName: "host", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "handleClick($event)" }, properties: { "attr.aria-disabled": "disabled() || null" } }, exportAs: ["cngxStepperPrevious"], ngImport: i0 });
|
|
2411
|
+
}
|
|
2412
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepperPrevious, decorators: [{
|
|
2413
|
+
type: Directive,
|
|
2414
|
+
args: [{
|
|
2415
|
+
selector: '[cngxStepperPrevious]',
|
|
2416
|
+
standalone: true,
|
|
2417
|
+
exportAs: 'cngxStepperPrevious',
|
|
2418
|
+
host: {
|
|
2419
|
+
'(click)': 'handleClick($event)',
|
|
2420
|
+
'[attr.aria-disabled]': 'disabled() || null',
|
|
2421
|
+
},
|
|
2422
|
+
}]
|
|
2423
|
+
}], ctorParameters: () => [], propDecorators: { host: [{ type: i0.Input, args: [{ isSignal: true, alias: "host", required: false }] }] } });
|
|
2424
|
+
|
|
2425
|
+
/**
|
|
2426
|
+
* Turns any clickable element into a stepper "Continue" control. Same
|
|
2427
|
+
* host resolution as `CngxStepperCount` - explicit `[host]` input
|
|
2428
|
+
* falling back to the ambient {@link CNGX_STEPPER_HOST}.
|
|
2429
|
+
*
|
|
2430
|
+
* `(click)` advances via `selectNext()`. A turnkey re-entrancy guard
|
|
2431
|
+
* disables the control when there is no enabled next step
|
|
2432
|
+
* (`!canGoNext()`) OR while a commit is in flight (`busy()`) - an opt-in
|
|
2433
|
+
* guard a consumer forgets is a silent double-commit (Pillar 2). The
|
|
2434
|
+
* gate reads the host's `canGoNext` bound, which derives from the same
|
|
2435
|
+
* `select()` predicates, so the affordance can never drift from the
|
|
2436
|
+
* navigation it triggers.
|
|
2437
|
+
*
|
|
2438
|
+
* Reflects the disabled state via `aria-disabled` only - never native
|
|
2439
|
+
* `disabled` (which would steal focus, so AT could not reach the control
|
|
2440
|
+
* to learn it is at-a-bound / busy) and never `aria-busy` (that is
|
|
2441
|
+
* `CngxAsyncStatus`'s sole responsibility). The `handleClick` guard
|
|
2442
|
+
* blocks the action while disabled. Co-placing `[cngxAsyncClick]` here
|
|
2443
|
+
* (which also gates `aria-disabled` and adds native `disabled`) warns in
|
|
2444
|
+
* dev mode.
|
|
2445
|
+
*
|
|
2446
|
+
* ```html
|
|
2447
|
+
* <button cngxStepperNext>Continue</button>
|
|
2448
|
+
* ```
|
|
2449
|
+
*
|
|
2450
|
+
* @category common/stepper
|
|
2451
|
+
* @docsKind primary
|
|
2452
|
+
* @wcag AA
|
|
2453
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/controls/stepper-next.directive.ts
|
|
2454
|
+
* @since 0.1.0
|
|
2455
|
+
* @relatedTo CngxStepperPrevious, CngxStepperComplete, CngxAsyncStatus, CngxStepperHost
|
|
2456
|
+
*/
|
|
2457
|
+
class CngxStepperNext {
|
|
2458
|
+
/**
|
|
2459
|
+
* Explicit stepper-host reference for placement *outside* the stepper
|
|
2460
|
+
* tree (`[host]="s.presenter"`). When unset, the ambient
|
|
2461
|
+
* {@link CNGX_STEPPER_HOST} is injected.
|
|
2462
|
+
*/
|
|
2463
|
+
host = input(null, ...(ngDevMode ? [{ debugName: "host" }] : /* istanbul ignore next */ []));
|
|
2464
|
+
injectedHost = inject(CNGX_STEPPER_HOST, { optional: true });
|
|
2465
|
+
resolvedHost = computed(() => this.host() ?? this.injectedHost, ...(ngDevMode ? [{ debugName: "resolvedHost" }] : /* istanbul ignore next */ []));
|
|
2466
|
+
coPlacedAsyncClick = inject(CngxAsyncClick, { self: true, optional: true });
|
|
2467
|
+
/** `true` when advancing is unavailable: no enabled next step or commit busy. */
|
|
2468
|
+
disabled = computed(() => {
|
|
2469
|
+
const host = this.resolvedHost();
|
|
2470
|
+
return !host || !host.canGoNext() || host.busy();
|
|
2471
|
+
}, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
2472
|
+
constructor() {
|
|
2473
|
+
if (isDevMode() && this.coPlacedAsyncClick) {
|
|
2474
|
+
console.warn('CngxStepperNext: [cngxStepperNext] and [cngxAsyncClick] on the same element ' +
|
|
2475
|
+
'both gate aria-disabled (and cngxAsyncClick adds native [disabled]). Use one or the other.');
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
/** @internal */
|
|
2479
|
+
handleClick(event) {
|
|
2480
|
+
if (this.disabled()) {
|
|
2481
|
+
event.preventDefault();
|
|
2482
|
+
return;
|
|
2483
|
+
}
|
|
2484
|
+
this.resolvedHost()?.selectNext();
|
|
2485
|
+
}
|
|
2486
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepperNext, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2487
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxStepperNext, isStandalone: true, selector: "[cngxStepperNext]", inputs: { host: { classPropertyName: "host", publicName: "host", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "handleClick($event)" }, properties: { "attr.aria-disabled": "disabled() || null" } }, exportAs: ["cngxStepperNext"], ngImport: i0 });
|
|
2488
|
+
}
|
|
2489
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepperNext, decorators: [{
|
|
2490
|
+
type: Directive,
|
|
2491
|
+
args: [{
|
|
2492
|
+
selector: '[cngxStepperNext]',
|
|
2493
|
+
standalone: true,
|
|
2494
|
+
exportAs: 'cngxStepperNext',
|
|
2495
|
+
host: {
|
|
2496
|
+
'(click)': 'handleClick($event)',
|
|
2497
|
+
'[attr.aria-disabled]': 'disabled() || null',
|
|
2498
|
+
},
|
|
2499
|
+
}]
|
|
2500
|
+
}], ctorParameters: () => [], propDecorators: { host: [{ type: i0.Input, args: [{ isSignal: true, alias: "host", required: false }] }] } });
|
|
2501
|
+
|
|
2502
|
+
/**
|
|
2503
|
+
* Turns any clickable element into a stepper "Finish" control. Unlike
|
|
2504
|
+
* `CngxStepperNext` (which *reflects* the commit state and advances),
|
|
2505
|
+
* the finish action *runs*: the directive composes `CngxAsyncClick` via
|
|
2506
|
+
* `hostDirectives`, so the runner owns the click lifecycle, `aria-busy`,
|
|
2507
|
+
* and the pending-disable exactly as it does on a standalone button. The
|
|
2508
|
+
* finish action is fed through the aliased `[cngxStepperComplete]` input.
|
|
2509
|
+
*
|
|
2510
|
+
* Resolves its host like the sibling controls - explicit `[host]` input
|
|
2511
|
+
* falling back to the ambient {@link CNGX_STEPPER_HOST}. {@link isActive}
|
|
2512
|
+
* exposes whether the active step is the last one, so a consumer renders
|
|
2513
|
+
* the finish control only on the final step. `(completed)` emits once
|
|
2514
|
+
* after the action resolves successfully.
|
|
2515
|
+
*
|
|
2516
|
+
* ```html
|
|
2517
|
+
* @if (s.presenter.isLastStep()) {
|
|
2518
|
+
* <button [cngxStepperComplete]="submit" (completed)="done()">Finish</button>
|
|
2519
|
+
* }
|
|
2520
|
+
* ```
|
|
2521
|
+
*
|
|
2522
|
+
* @category common/stepper
|
|
2523
|
+
* @docsKind primary
|
|
2524
|
+
* @wcag AA
|
|
2525
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/controls/stepper-complete.directive.ts
|
|
2526
|
+
* @since 0.1.0
|
|
2527
|
+
* @relatedTo CngxStepperNext, CngxStepperPrevious, CngxAsyncClick, CngxStepperHost
|
|
2528
|
+
*/
|
|
2529
|
+
class CngxStepperComplete {
|
|
2530
|
+
/**
|
|
2531
|
+
* Explicit stepper-host reference for placement *outside* the stepper
|
|
2532
|
+
* tree (`[host]="s.presenter"`). When unset, the ambient
|
|
2533
|
+
* {@link CNGX_STEPPER_HOST} is injected.
|
|
2534
|
+
*/
|
|
2535
|
+
host = input(null, ...(ngDevMode ? [{ debugName: "host" }] : /* istanbul ignore next */ []));
|
|
2536
|
+
/**
|
|
2537
|
+
* Emits once per `pending → success` transition of the finish action.
|
|
2538
|
+
* Does NOT re-emit when the `feedbackDuration` window resets the runner
|
|
2539
|
+
* back to idle - the transition tracker guards on the success edge only.
|
|
2540
|
+
*/
|
|
2541
|
+
completed = output();
|
|
2542
|
+
injectedHost = inject(CNGX_STEPPER_HOST, { optional: true });
|
|
2543
|
+
resolvedHost = computed(() => this.host() ?? this.injectedHost, ...(ngDevMode ? [{ debugName: "resolvedHost" }] : /* istanbul ignore next */ []));
|
|
2544
|
+
runner = inject(CngxAsyncClick, { host: true });
|
|
2545
|
+
/** `true` when the active step is the last one - the finish step. */
|
|
2546
|
+
isActive = computed(() => this.resolvedHost()?.isLastStep() ?? false, ...(ngDevMode ? [{ debugName: "isActive" }] : /* istanbul ignore next */ []));
|
|
2547
|
+
constructor() {
|
|
2548
|
+
const tracker = createTransitionTracker(() => this.runner.status());
|
|
2549
|
+
effect(() => {
|
|
2550
|
+
if (tracker.current() === 'success' && tracker.previous() !== 'success') {
|
|
2551
|
+
this.completed.emit();
|
|
2552
|
+
}
|
|
2553
|
+
});
|
|
2554
|
+
}
|
|
2555
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepperComplete, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2556
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxStepperComplete, isStandalone: true, selector: "[cngxStepperComplete]", inputs: { host: { classPropertyName: "host", publicName: "host", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { completed: "completed" }, exportAs: ["cngxStepperComplete"], hostDirectives: [{ directive: i1.CngxAsyncClick, inputs: ["cngxAsyncClick", "cngxStepperComplete", "feedbackDuration", "feedbackDuration", "enabled", "enabled", "succeededAnnouncement", "succeededAnnouncement", "failedAnnouncement", "failedAnnouncement"] }], ngImport: i0 });
|
|
2557
|
+
}
|
|
2558
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepperComplete, decorators: [{
|
|
2559
|
+
type: Directive,
|
|
2560
|
+
args: [{
|
|
2561
|
+
selector: '[cngxStepperComplete]',
|
|
2562
|
+
standalone: true,
|
|
2563
|
+
exportAs: 'cngxStepperComplete',
|
|
2564
|
+
hostDirectives: [
|
|
2565
|
+
{
|
|
2566
|
+
directive: CngxAsyncClick,
|
|
2567
|
+
inputs: [
|
|
2568
|
+
'cngxAsyncClick: cngxStepperComplete',
|
|
2569
|
+
'feedbackDuration',
|
|
2570
|
+
'enabled',
|
|
2571
|
+
'succeededAnnouncement',
|
|
2572
|
+
'failedAnnouncement',
|
|
2573
|
+
],
|
|
2574
|
+
},
|
|
2575
|
+
],
|
|
2576
|
+
}]
|
|
2577
|
+
}], ctorParameters: () => [], propDecorators: { host: [{ type: i0.Input, args: [{ isSignal: true, alias: "host", required: false }] }], completed: [{ type: i0.Output, args: ["completed"] }] } });
|
|
2578
|
+
|
|
2579
|
+
const EMPTY_NODES = Object.freeze([]);
|
|
2580
|
+
/**
|
|
2581
|
+
* Builds a live delegating {@link CngxStepperHost} proxy over a supplier
|
|
2582
|
+
* signal. Every signal member is a `computed()` reading
|
|
2583
|
+
* `supplier()?.<member>()`, every method forwards to
|
|
2584
|
+
* `supplier()?.<method>(...)`. This is the spelled-out shape for
|
|
2585
|
+
* re-providing an input-derived host through DI - you cannot
|
|
2586
|
+
* `useExisting` an `input()` value, so the footer provides this proxy
|
|
2587
|
+
* once and it tracks whichever host the supplier currently resolves.
|
|
2588
|
+
*
|
|
2589
|
+
* **Null-supplier neutral set (the disabled-by-default contract).** When
|
|
2590
|
+
* the supplier resolves `null` (a standalone footer with neither `[host]`
|
|
2591
|
+
* nor an ambient stepper), every navigation affordance must render
|
|
2592
|
+
* *inert*, never falsely enabled: `canGoPrevious` / `canGoNext` collapse
|
|
2593
|
+
* to `false` so Back / Next render disabled, and every method is a no-op.
|
|
2594
|
+
*
|
|
2595
|
+
* `create*` pure factory - no injection context required (`computed()`
|
|
2596
|
+
* only). Single consumer (the footer); the surface is load-bearing, not
|
|
2597
|
+
* speculative.
|
|
2598
|
+
*
|
|
2599
|
+
* @category common/stepper
|
|
2600
|
+
* @since 0.1.0
|
|
2601
|
+
* @relatedTo CngxStepperFooter, CngxStepperHost
|
|
2602
|
+
*/
|
|
2603
|
+
function createStepperHostProxy(supplier) {
|
|
2604
|
+
return {
|
|
2605
|
+
// Core projection / state - empty / out-of-range when null. The array
|
|
2606
|
+
// fallbacks return the shared frozen EMPTY_NODES reference, so no `equal`
|
|
2607
|
+
// fn is needed: the output is reference-stable across reads (either the
|
|
2608
|
+
// supplier's own structural-equal signal value, or this one constant).
|
|
2609
|
+
stepTree: computed(() => supplier()?.stepTree() ?? EMPTY_NODES),
|
|
2610
|
+
flatSteps: computed(() => supplier()?.flatSteps() ?? EMPTY_NODES),
|
|
2611
|
+
stepsOnly: computed(() => supplier()?.stepsOnly() ?? EMPTY_NODES),
|
|
2612
|
+
activeStepIndex: computed(() => supplier()?.activeStepIndex() ?? -1),
|
|
2613
|
+
activeStepId: computed(() => supplier()?.activeStepId() ?? null),
|
|
2614
|
+
linear: computed(() => supplier()?.linear() ?? false),
|
|
2615
|
+
orientation: computed(() => supplier()?.orientation() ?? 'horizontal'),
|
|
2616
|
+
intendedStepIndex: computed(() => supplier()?.intendedStepIndex()),
|
|
2617
|
+
lastFailedIndex: computed(() => supplier()?.lastFailedIndex()),
|
|
2618
|
+
originIndexDuringCommit: computed(() => supplier()?.originIndexDuringCommit()),
|
|
2619
|
+
// Bounds + labels - the safety-critical canGo* pair collapses to
|
|
2620
|
+
// `false` so a null host yields disabled Back / Next, never clickable.
|
|
2621
|
+
stepCount: computed(() => supplier()?.stepCount() ?? 0),
|
|
2622
|
+
isFirstStep: computed(() => supplier()?.isFirstStep() ?? true),
|
|
2623
|
+
isLastStep: computed(() => supplier()?.isLastStep() ?? true),
|
|
2624
|
+
canGoPrevious: computed(() => supplier()?.canGoPrevious() ?? false),
|
|
2625
|
+
canGoNext: computed(() => supplier()?.canGoNext() ?? false),
|
|
2626
|
+
busy: computed(() => supplier()?.busy() ?? false),
|
|
2627
|
+
nextStepLabel: computed(() => supplier()?.nextStepLabel()),
|
|
2628
|
+
previousStepLabel: computed(() => supplier()?.previousStepLabel()),
|
|
2629
|
+
// Composite members delegate their sub-signals, idle when null. The
|
|
2630
|
+
// proxy only forwards - the real tracker is the presenter's, so build
|
|
2631
|
+
// the static neutral shape rather than calling createTransitionTracker.
|
|
2632
|
+
commitState: buildAsyncStateView({
|
|
2633
|
+
status: computed(() => supplier()?.commitState.status() ?? 'idle'),
|
|
2634
|
+
data: computed(() => supplier()?.commitState.data()),
|
|
2635
|
+
error: computed(() => supplier()?.commitState.error()),
|
|
2636
|
+
lastUpdated: computed(() => supplier()?.commitState.lastUpdated()),
|
|
2637
|
+
}),
|
|
2638
|
+
commitTransition: {
|
|
2639
|
+
current: computed(() => supplier()?.commitTransition.current() ?? 'idle'),
|
|
2640
|
+
previous: computed(() => supplier()?.commitTransition.previous() ?? 'idle'),
|
|
2641
|
+
},
|
|
2642
|
+
// Reachability predicate - neutral `false` when null so a header
|
|
2643
|
+
// over a missing host is never falsely navigable.
|
|
2644
|
+
canNavigateTo: (index) => supplier()?.canNavigateTo(index) ?? false,
|
|
2645
|
+
// Methods forward; no-op when null.
|
|
2646
|
+
select: (index) => supplier()?.select(index),
|
|
2647
|
+
selectNext: () => supplier()?.selectNext(),
|
|
2648
|
+
selectPrevious: () => supplier()?.selectPrevious(),
|
|
2649
|
+
selectById: (id) => supplier()?.selectById(id),
|
|
2650
|
+
reset: () => supplier()?.reset(),
|
|
2651
|
+
clearLastFailed: () => supplier()?.clearLastFailed(),
|
|
2652
|
+
register: (handle, parentId) => supplier()?.register(handle, parentId),
|
|
2653
|
+
unregister: (id) => supplier()?.unregister(id),
|
|
2654
|
+
};
|
|
2655
|
+
}
|
|
2656
|
+
|
|
2657
|
+
/** @internal */
|
|
1256
2658
|
function partitionFeatures(features) {
|
|
1257
2659
|
const config = [];
|
|
1258
2660
|
const i18n = [];
|
|
@@ -1265,7 +2667,7 @@ function partitionFeatures(features) {
|
|
|
1265
2667
|
config.push(feat);
|
|
1266
2668
|
continue;
|
|
1267
2669
|
}
|
|
1268
|
-
// Unbranded feature
|
|
2670
|
+
// Unbranded feature - drop + dev-warn (mirrors `provideCngxTabs`).
|
|
1269
2671
|
if (isDevMode()) {
|
|
1270
2672
|
console.warn('[provideCngxStepper] Dropped feature without a `_target` ' +
|
|
1271
2673
|
'discriminator. Brand config-side mutators with ' +
|
|
@@ -1298,11 +2700,13 @@ function partitionFeatures(features) {
|
|
|
1298
2700
|
* ],
|
|
1299
2701
|
* });
|
|
1300
2702
|
* ```
|
|
2703
|
+
*
|
|
2704
|
+
* @category common/stepper
|
|
1301
2705
|
*/
|
|
1302
2706
|
function provideCngxStepper(...features) {
|
|
1303
2707
|
const { config, i18n } = partitionFeatures(features);
|
|
1304
2708
|
// `provideStepperConfig` returns EnvironmentProviders, `provideStepperI18n`
|
|
1305
|
-
// returns Provider
|
|
2709
|
+
// returns Provider - `makeEnvironmentProviders` takes both.
|
|
1306
2710
|
return makeEnvironmentProviders([
|
|
1307
2711
|
provideStepperConfig(...config),
|
|
1308
2712
|
...(i18n.length > 0 ? [provideStepperI18n(...i18n)] : []),
|
|
@@ -1310,7 +2714,7 @@ function provideCngxStepper(...features) {
|
|
|
1310
2714
|
}
|
|
1311
2715
|
/**
|
|
1312
2716
|
* Component-scoped twin of {@link provideCngxStepper}. Spread into
|
|
1313
|
-
* `viewProviders` or `providers`. Same dispatch semantics
|
|
2717
|
+
* `viewProviders` or `providers`. Same dispatch semantics - only the
|
|
1314
2718
|
* provider scope differs.
|
|
1315
2719
|
*
|
|
1316
2720
|
* ```ts
|
|
@@ -1323,6 +2727,8 @@ function provideCngxStepper(...features) {
|
|
|
1323
2727
|
* ],
|
|
1324
2728
|
* })
|
|
1325
2729
|
* ```
|
|
2730
|
+
*
|
|
2731
|
+
* @category common/stepper
|
|
1326
2732
|
*/
|
|
1327
2733
|
function provideCngxStepperAt(...features) {
|
|
1328
2734
|
const { config, i18n } = partitionFeatures(features);
|
|
@@ -1337,7 +2743,7 @@ function provideCngxStepperAt(...features) {
|
|
|
1337
2743
|
*
|
|
1338
2744
|
* Level-2 directive-only logic for stepper / wizard flows. Ships the
|
|
1339
2745
|
* presenter brain, atom directives, host tokens, router-sync, config
|
|
1340
|
-
* cascade, and i18n. Zero `@Component`, zero `.html`, zero `.css`
|
|
2746
|
+
* cascade, and i18n. Zero `@Component`, zero `.html`, zero `.css` -
|
|
1341
2747
|
* those live in `@cngx/ui/stepper` (CNGX-standard skin) and
|
|
1342
2748
|
* `@cngx/ui/mat-stepper` (Material twin).
|
|
1343
2749
|
*/
|
|
@@ -1346,5 +2752,5 @@ function provideCngxStepperAt(...features) {
|
|
|
1346
2752
|
* Generated bundle index. Do not edit.
|
|
1347
2753
|
*/
|
|
1348
2754
|
|
|
1349
|
-
export { CNGX_STEPPER_COMMIT_HANDLER_FACTORY, CNGX_STEPPER_CONFIG, CNGX_STEPPER_GLYPHS, CNGX_STEPPER_HOST, CNGX_STEPPER_I18N, CNGX_STEP_GROUP_HOST, CNGX_STEP_PANEL_HOST, CngxStep, CngxStepBadge, CngxStepBusySpinner, CngxStepContent, CngxStepGroup, CngxStepGroupHeader, CngxStepIndicator, CngxStepLabel, CngxStepRejection, CngxStepperEmpty, CngxStepperPresenter, CngxStepperRouterSync, createStepperCommitHandler, createStepperTemplateBindings, flatStepsEqual, injectStepperConfig, injectStepperI18n, provideCngxStepper, provideCngxStepperAt, provideStepperConfig, provideStepperConfigAt, provideStepperI18n, withStepBadgeTemplate, withStepBusySpinnerTemplate, withStepGroupHeaderTemplate, withStepIndicatorTemplate, withStepRejectionTemplate, withStepperAriaLabels, withStepperCommitMode, withStepperDefaultOrientation, withStepperEmptyTemplate, withStepperFallbackLabels, withStepperI18nLabels, withStepperLinear, withStepperRouterSync };
|
|
2755
|
+
export { CNGX_STEPPER_COMMIT_HANDLER_FACTORY, CNGX_STEPPER_CONFIG, CNGX_STEPPER_GLYPHS, CNGX_STEPPER_HOST, CNGX_STEPPER_I18N, CNGX_STEP_GROUP_HOST, CNGX_STEP_PANEL_HOST, CngxDotStepperDot, CngxStep, CngxStepBadge, CngxStepBusySpinner, CngxStepContent, CngxStepError, CngxStepGroup, CngxStepGroupHeader, CngxStepIndicator, CngxStepLabel, CngxStepRejection, CngxStepperComplete, CngxStepperCount, CngxStepperEmpty, CngxStepperNext, CngxStepperPresenter, CngxStepperPrevious, CngxStepperRouterSync, CngxStepperSwipeNav, STEPPER_DEFAULT_MOBILE_BREAKPOINT, createMobileViewportSignal, createStepperAnnouncementBuilders, createStepperCommitHandler, createStepperDisplayMode, createStepperHostAttrs, createStepperHostProxy, createStepperSlotContextBuilders, createStepperStateView, createStepperStripKeyboardNav, createStepperTemplateBindings, flatStepsEqual, injectStepperConfig, injectStepperI18n, provideCngxStepper, provideCngxStepperAt, provideStepperConfig, provideStepperConfigAt, provideStepperI18n, resolveStepperErrorSummary, resolveStepperStatusLabel, withDotStepperDotTemplate, withStepBadgeTemplate, withStepBusySpinnerTemplate, withStepErrorTemplate, withStepGroupHeaderTemplate, withStepIndicatorTemplate, withStepRejectionTemplate, withStepperAriaLabels, withStepperCommitMode, withStepperConnectors, withStepperDefaultOrientation, withStepperEmptyTemplate, withStepperFallbackLabels, withStepperHeaderNavigation, withStepperI18nLabels, withStepperLinear, withStepperMobileBreakpoint, withStepperMobileCollapse, withStepperMobileIndicatorPosition, withStepperMobileSwipe, withStepperRouterSync, withStepperSkin };
|
|
1350
2756
|
//# sourceMappingURL=cngx-common-stepper.mjs.map
|