@cngx/common 0.1.0-rc.7 → 0.1.0-rc.9
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/card/README.md +2 -1
- package/command/README.md +29 -0
- package/data/README.md +15 -3
- package/dialog/README.md +23 -1
- package/fesm2022/cngx-common-a11y.mjs +517 -184
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-audio.mjs +62 -17
- package/fesm2022/cngx-common-audio.mjs.map +1 -1
- package/fesm2022/cngx-common-card.mjs +301 -46
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +1221 -479
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-command.mjs +97 -16
- package/fesm2022/cngx-common-command.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +1496 -499
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +236 -61
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +364 -93
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +2040 -1046
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +955 -125
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-popover.mjs +1293 -89
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +997 -453
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +1794 -1265
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common-timeline.mjs +151 -61
- package/fesm2022/cngx-common-timeline.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +1 -1
- package/interactive/README.md +15 -4
- package/layout/README.md +37 -1
- package/package.json +20 -7
- package/popover/README.md +58 -2
- package/schematics/collection.json +9 -0
- package/schematics/ng-add/index.js +9 -0
- package/schematics/ng-add/schema.json +91 -0
- package/schematics/package.json +3 -0
- package/stepper/README.md +11 -8
- package/theming/components/cngx-accordion.css +1 -1
- package/theming/components/cngx-backdrop.css +12 -0
- package/theming/components/cngx-button-toggle.css +29 -3
- package/theming/components/cngx-data-grid.css +168 -1
- package/theming/components/cngx-dialog.css +13 -0
- package/theming/components/cngx-listbox.css +21 -12
- package/theming/components/cngx-menu.css +56 -16
- package/theming/components/cngx-popover-sheet.css +402 -0
- package/theming/components/cngx-popover.css +28 -0
- package/theming/components/cngx-recycler-placeholder.css +196 -0
- package/theming/components/cngx-ripple.css +1 -1
- package/theming/components/cngx-slider.css +32 -1
- package/theming/components/cngx-tooltip.css +12 -0
- package/timeline/README.md +155 -0
- package/types/cngx-common-a11y.d.ts +205 -28
- package/types/cngx-common-card.d.ts +201 -17
- package/types/cngx-common-chart.d.ts +345 -48
- package/types/cngx-common-command.d.ts +50 -10
- package/types/cngx-common-data.d.ts +743 -92
- package/types/cngx-common-dialog.d.ts +161 -10
- package/types/cngx-common-display.d.ts +356 -142
- package/types/cngx-common-interactive.d.ts +910 -226
- package/types/cngx-common-layout.d.ts +603 -32
- package/types/cngx-common-popover.d.ts +612 -49
- package/types/cngx-common-stepper.d.ts +526 -237
- package/types/cngx-common-tabs.d.ts +358 -75
- package/types/cngx-common-timeline.d.ts +108 -22
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken,
|
|
3
|
-
import { CNGX_COMMIT_CONTROLLER_FACTORY } from '@cngx/common/data';
|
|
4
|
-
import {
|
|
2
|
+
import { InjectionToken, inject, computed, makeEnvironmentProviders, model, input, signal, afterNextRender, Directive, TemplateRef, contentChild, DestroyRef, output, effect, untracked, ViewEncapsulation, ChangeDetectionStrategy, Component, ElementRef, afterEveryRender, afterRenderEffect } from '@angular/core';
|
|
3
|
+
import { CNGX_COMMIT_CONTROLLER_FACTORY, createRefusedPhrase } from '@cngx/common/data';
|
|
4
|
+
import { resolveStepFrom, resolveInlineStep, resolveBoundaryStep, injectDirection } from '@cngx/core';
|
|
5
|
+
import { createNestedOverrideMerge, createOverrideMerge, createTransitionTracker, CNGX_STATEFUL, nextUid, coerceSignal, buildAsyncStateView } from '@cngx/core/utils';
|
|
6
|
+
import { CngxRuntimeError, recordEqual, cngxDevWarn, arrayEqual } from '@cngx/utils';
|
|
5
7
|
import { isObservable } from 'rxjs';
|
|
8
|
+
import { formatMessage, createNestedLanguageSection, createSectionBundle } from '@cngx/core/i18n';
|
|
6
9
|
import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
7
|
-
import { Router, NavigationEnd } from '@angular/router';
|
|
10
|
+
import { Router, ActivatedRoute, NavigationEnd } from '@angular/router';
|
|
8
11
|
import { filter } from 'rxjs/operators';
|
|
9
|
-
import {
|
|
12
|
+
import { injectContainerSize } from '@cngx/common/layout';
|
|
10
13
|
import * as i1 from '@cngx/common/interactive';
|
|
11
14
|
import { CngxAsyncClick } from '@cngx/common/interactive';
|
|
12
15
|
|
|
13
16
|
/**
|
|
14
17
|
* Build a stepper commit handler over an existing {@link CngxCommitController}.
|
|
15
18
|
* Resolves `Observable<boolean>` / `Promise<boolean>` / `boolean` returns into
|
|
16
|
-
*
|
|
19
|
+
* one {@link CngxStepperCommitResolution}: `true` accepts, `false` refuses
|
|
20
|
+
* (the controller settles to `'idle'` and stores no error), a throw fails.
|
|
17
21
|
*
|
|
18
22
|
* @category common/stepper
|
|
19
23
|
*/
|
|
@@ -23,8 +27,9 @@ function createStepperCommitHandler(opts) {
|
|
|
23
27
|
isCommitting: controller.isCommitting,
|
|
24
28
|
beginTransition(fromIndex, toIndex, action, onResolve) {
|
|
25
29
|
controller.begin((handlers) => runStepperAction(action, fromIndex, toIndex, handlers), toIndex, fromIndex, {
|
|
26
|
-
onSuccess: () => onResolve(
|
|
27
|
-
onError: () => onResolve(
|
|
30
|
+
onSuccess: () => onResolve('accepted'),
|
|
31
|
+
onError: () => onResolve('failed'),
|
|
32
|
+
onRefused: () => onResolve('refused'),
|
|
28
33
|
});
|
|
29
34
|
},
|
|
30
35
|
cancel() {
|
|
@@ -44,7 +49,7 @@ function runStepperAction(action, fromIndex, toIndex, handlers) {
|
|
|
44
49
|
handlers.onSuccess(toIndex);
|
|
45
50
|
}
|
|
46
51
|
else {
|
|
47
|
-
handlers.
|
|
52
|
+
handlers.onRefused();
|
|
48
53
|
}
|
|
49
54
|
};
|
|
50
55
|
const safeError = (err) => {
|
|
@@ -70,13 +75,40 @@ function runStepperAction(action, fromIndex, toIndex, handlers) {
|
|
|
70
75
|
// before the assignment binds - `sub` would be in TDZ. Declare
|
|
71
76
|
// the handle on a `let` first.
|
|
72
77
|
let sub = null;
|
|
78
|
+
let done = false;
|
|
73
79
|
sub = result.subscribe({
|
|
74
80
|
next: (accept) => {
|
|
81
|
+
if (done) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// Done-latch, not just unsubscribe: a synchronous emission fires
|
|
85
|
+
// while `sub` is still null, so a non-completing source would
|
|
86
|
+
// otherwise stay live and re-resolve on its next emission.
|
|
87
|
+
done = true;
|
|
75
88
|
safeSuccess(accept);
|
|
76
89
|
sub?.unsubscribe();
|
|
77
90
|
},
|
|
78
|
-
error: (err) =>
|
|
91
|
+
error: (err) => {
|
|
92
|
+
if (done) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
safeError(err);
|
|
96
|
+
},
|
|
97
|
+
complete: () => {
|
|
98
|
+
// EMPTY-style sources complete without emitting; without this arm
|
|
99
|
+
// the commit stays 'pending' forever and busy() latches true.
|
|
100
|
+
if (!done) {
|
|
101
|
+
safeError(new CngxRuntimeError('CNGX1059', typeof ngDevMode !== 'undefined' &&
|
|
102
|
+
ngDevMode &&
|
|
103
|
+
'[cngxStepper] commitAction completed without emitting true or false.'));
|
|
104
|
+
}
|
|
105
|
+
},
|
|
79
106
|
});
|
|
107
|
+
if (done) {
|
|
108
|
+
// The in-next unsubscribe was a no-op for a sync emission; close
|
|
109
|
+
// the still-live subscription now that `sub` is bound.
|
|
110
|
+
sub.unsubscribe();
|
|
111
|
+
}
|
|
80
112
|
unsubscribe = () => sub?.unsubscribe();
|
|
81
113
|
}
|
|
82
114
|
else if (result != null && typeof result.then === 'function') {
|
|
@@ -106,26 +138,159 @@ const CNGX_STEPPER_COMMIT_HANDLER_FACTORY = new InjectionToken('CngxStepperCommi
|
|
|
106
138
|
});
|
|
107
139
|
|
|
108
140
|
/**
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* default, and any JSDoc cross-references stay in lockstep. Consumers
|
|
112
|
-
* override the query via {@link withStepperMobileBreakpoint}.
|
|
141
|
+
* The English stepper section: the single source of the stepper's English
|
|
142
|
+
* copy. `CNGX_STEPPER_I18N` and the `CNGX_STEPPER_CONFIG` labels default to it.
|
|
113
143
|
*
|
|
114
|
-
* @category common/stepper
|
|
144
|
+
* @category common/stepper/i18n
|
|
145
|
+
* @since 0.1.0
|
|
146
|
+
* @relatedTo CNGX_STEPPER_I18N
|
|
147
|
+
*/
|
|
148
|
+
const CNGX_STEPPER_LANGUAGE_EN = {
|
|
149
|
+
stepperRegion: 'Steps',
|
|
150
|
+
stepperLabel: 'Steps',
|
|
151
|
+
stepRoleDescription: 'stepper',
|
|
152
|
+
stepIndicatorRoleDescription: 'step indicator',
|
|
153
|
+
groupRoleDescription: 'step group',
|
|
154
|
+
selectedStep: 'Step {position} of {count}: {label}',
|
|
155
|
+
stepWithDetail: '{step}: {detail}',
|
|
156
|
+
stepHasErrors: { one: '{count} error', other: '{count} errors' },
|
|
157
|
+
previousStep: 'Previous step',
|
|
158
|
+
nextStep: 'Next step',
|
|
159
|
+
commitFailedRetry: 'Could not save step - retry?',
|
|
160
|
+
commitInFlight: 'Saving step…',
|
|
161
|
+
commitRolledBackTo: 'Reverted to step "{origin}".',
|
|
162
|
+
stepRolledBack: '{base} This step was rolled back.',
|
|
163
|
+
commitRefused: 'Step change not allowed - stayed on step "{origin}".',
|
|
164
|
+
commitRefusedGeneric: 'Step change not allowed.',
|
|
165
|
+
stepRefused: '{base} This step change was not allowed.',
|
|
166
|
+
statusLabels: {
|
|
167
|
+
done: 'Done',
|
|
168
|
+
inProgress: 'In progress',
|
|
169
|
+
upNext: 'Up next',
|
|
170
|
+
errored: 'Errored',
|
|
171
|
+
refused: 'Not allowed',
|
|
172
|
+
},
|
|
173
|
+
textStepperFormat: 'Step {current} of {count}',
|
|
174
|
+
groupSummaryCount: { one: '{count} step', other: '{count} steps' },
|
|
175
|
+
groupSummaryProgress: {
|
|
176
|
+
one: '{completed} of {count} step complete',
|
|
177
|
+
other: '{completed} of {count} steps complete',
|
|
178
|
+
},
|
|
179
|
+
groupSummaryCountShort: '{count}',
|
|
180
|
+
groupSummaryProgressShort: '{completed}/{count}',
|
|
181
|
+
stepFallbackLabel: 'Step {id}',
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
/** @internal Turns a stepper section into the token's keys for a locale. */
|
|
185
|
+
function stepperBundleFrom(section, locale) {
|
|
186
|
+
return {
|
|
187
|
+
stepperLabel: section.stepperLabel,
|
|
188
|
+
stepIndicatorRoleDescription: section.stepIndicatorRoleDescription,
|
|
189
|
+
groupRoleDescription: section.groupRoleDescription,
|
|
190
|
+
selectedStep: (label, position, count) => formatMessage(section.selectedStep, { label, position, count }, locale),
|
|
191
|
+
stepWithDetail: (step, detail) => formatMessage(section.stepWithDetail, { step, detail }, locale),
|
|
192
|
+
stepHasErrors: (count) => formatMessage(section.stepHasErrors, { count }, locale),
|
|
193
|
+
previousStep: section.previousStep,
|
|
194
|
+
nextStep: section.nextStep,
|
|
195
|
+
commitFailedRetry: section.commitFailedRetry,
|
|
196
|
+
commitInFlight: section.commitInFlight,
|
|
197
|
+
commitRolledBackTo: (origin) => formatMessage(section.commitRolledBackTo, { origin }, locale),
|
|
198
|
+
stepRolledBack: (base) => formatMessage(section.stepRolledBack, { base }, locale),
|
|
199
|
+
commitRefused: (origin) => formatMessage(section.commitRefused, { origin }, locale),
|
|
200
|
+
commitRefusedGeneric: section.commitRefusedGeneric,
|
|
201
|
+
stepRefused: (base) => formatMessage(section.stepRefused, { base }, locale),
|
|
202
|
+
statusLabels: section.statusLabels,
|
|
203
|
+
textStepperFormat: (current, count) => formatMessage(section.textStepperFormat, { current, count }, locale),
|
|
204
|
+
groupSummaryCount: (count) => formatMessage(section.groupSummaryCount, { count }, locale),
|
|
205
|
+
groupSummaryProgress: (completed, count) => formatMessage(section.groupSummaryProgress, { completed, count }, locale),
|
|
206
|
+
groupSummaryCountShort: (count) => formatMessage(section.groupSummaryCountShort, { count }, locale),
|
|
207
|
+
groupSummaryProgressShort: (completed, count) => formatMessage(section.groupSummaryProgressShort, { completed, count }, locale),
|
|
208
|
+
stepFallbackLabel: (id) => formatMessage(section.stepFallbackLabel, { id }, locale),
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* @internal The English stepper section with the active pack's stepper
|
|
213
|
+
* section on top. Feeds both `CNGX_STEPPER_I18N` and the
|
|
214
|
+
* `CNGX_STEPPER_CONFIG` labels.
|
|
115
215
|
*/
|
|
116
|
-
const
|
|
216
|
+
const injectStepperLanguage = createNestedLanguageSection('stepper', CNGX_STEPPER_LANGUAGE_EN, 'statusLabels');
|
|
217
|
+
/** @internal Builds and reads the token, formatted for the reading locale. */
|
|
218
|
+
const stepperBundle = createSectionBundle({
|
|
219
|
+
section: injectStepperLanguage,
|
|
220
|
+
toBundle: stepperBundleFrom,
|
|
221
|
+
});
|
|
117
222
|
/**
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
223
|
+
* DI token for the resolved stepper i18n bundle, as a `Signal` so a
|
|
224
|
+
* runtime language switch re-renders every label it feeds.
|
|
225
|
+
* `providedIn: 'root'`: the stepper section of the active language pack over
|
|
226
|
+
* the English defaults, formatted for the app locale. Provide it through
|
|
227
|
+
* {@link provideStepperI18n}; a `{ provide, useValue }` entry must supply a
|
|
228
|
+
* `Signal<CngxStepperI18n>`.
|
|
122
229
|
*
|
|
123
|
-
* @category common/stepper
|
|
230
|
+
* @category common/stepper/i18n
|
|
231
|
+
* @wcag AA
|
|
232
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/i18n/stepper-i18n.ts
|
|
233
|
+
* @since 0.1.0
|
|
124
234
|
*/
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
};
|
|
235
|
+
const CNGX_STEPPER_I18N = new InjectionToken('CngxStepperI18n', {
|
|
236
|
+
providedIn: 'root',
|
|
237
|
+
factory: () => stepperBundle.build(),
|
|
238
|
+
});
|
|
239
|
+
/**
|
|
240
|
+
* Brands an i18n mutator with `_target: 'i18n'`. Every `with*` i18n
|
|
241
|
+
* feature returns one of these.
|
|
242
|
+
*
|
|
243
|
+
* @internal
|
|
244
|
+
*/
|
|
245
|
+
function defineStepperI18nFeature(fn) {
|
|
246
|
+
return Object.assign(fn, { _target: 'i18n' });
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Override stepper i18n labels. Partial override - unset keys keep
|
|
250
|
+
* the language pack's copy, or the English default. {@link CngxStepperStatusLabels} is merged
|
|
251
|
+
* key-by-key so consumers can override one pill label without
|
|
252
|
+
* restating the rest. Pass a `Signal` to switch the language at runtime.
|
|
253
|
+
* Sibling of `withStepperAriaLabels` / `withStepperFallbackLabels`.
|
|
254
|
+
*
|
|
255
|
+
* @category common/stepper/i18n
|
|
256
|
+
*/
|
|
257
|
+
function withStepperI18nLabels(overrides) {
|
|
258
|
+
return defineStepperI18nFeature((bundle) => createNestedOverrideMerge(bundle, overrides, 'statusLabels'));
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Provider for the stepper i18n bundle. Compose `withStepperI18nLabels(...)`
|
|
262
|
+
* (plus any future i18n `with*`) - unset keys fall back to the language
|
|
263
|
+
* pack, then English. The features apply on top of the active pack.
|
|
264
|
+
*
|
|
265
|
+
* ```ts
|
|
266
|
+
* bootstrapApplication(AppComponent, {
|
|
267
|
+
* providers: [
|
|
268
|
+
* provideStepperI18n(
|
|
269
|
+
* withStepperI18nLabels({ stepperLabel: 'Schrittfolge', previousStep: 'Vorheriger' }),
|
|
270
|
+
* ),
|
|
271
|
+
* ],
|
|
272
|
+
* });
|
|
273
|
+
* ```
|
|
274
|
+
*
|
|
275
|
+
* @category common/stepper/i18n
|
|
276
|
+
*/
|
|
277
|
+
function provideStepperI18n(...features) {
|
|
278
|
+
return {
|
|
279
|
+
provide: CNGX_STEPPER_I18N,
|
|
280
|
+
useFactory: () => stepperBundle.build(features),
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Inject the resolved stepper i18n bundle in an injection context. Read it
|
|
285
|
+
* inside a `computed()`, template or handler so a language switch reaches
|
|
286
|
+
* the label.
|
|
287
|
+
*
|
|
288
|
+
* @category common/stepper/i18n
|
|
289
|
+
*/
|
|
290
|
+
function injectStepperI18n() {
|
|
291
|
+
return stepperBundle.resolve(inject(CNGX_STEPPER_I18N));
|
|
292
|
+
}
|
|
293
|
+
|
|
129
294
|
/** @internal */
|
|
130
295
|
const STEPPER_CONFIG_DEFAULTS = {
|
|
131
296
|
defaultOrientation: 'horizontal',
|
|
@@ -138,21 +303,21 @@ const STEPPER_CONFIG_DEFAULTS = {
|
|
|
138
303
|
groupCollapse: 'off',
|
|
139
304
|
groupCollapseSummary: 'progress',
|
|
140
305
|
density: 'comfortable',
|
|
141
|
-
densityBreakpoints: STEPPER_DEFAULT_DENSITY_BREAKPOINTS,
|
|
142
306
|
connectors: false,
|
|
143
307
|
mobileCollapse: 'text',
|
|
144
|
-
mobileBreakpoint: STEPPER_DEFAULT_MOBILE_BREAKPOINT,
|
|
145
308
|
mobileIndicatorPosition: 'top',
|
|
146
309
|
mobileSwipe: true,
|
|
147
310
|
ariaLabels: {
|
|
148
|
-
stepperRegion:
|
|
311
|
+
stepperRegion: CNGX_STEPPER_LANGUAGE_EN.stepperRegion,
|
|
149
312
|
},
|
|
150
313
|
fallbackLabels: {
|
|
151
|
-
groupRoleDescription:
|
|
152
|
-
stepRoleDescription:
|
|
314
|
+
groupRoleDescription: CNGX_STEPPER_LANGUAGE_EN.groupRoleDescription,
|
|
315
|
+
stepRoleDescription: CNGX_STEPPER_LANGUAGE_EN.stepRoleDescription,
|
|
153
316
|
},
|
|
154
317
|
templates: {},
|
|
155
318
|
};
|
|
319
|
+
/** @internal - shared empty base, so label merges over an unset key memoize. */
|
|
320
|
+
const NO_LABELS = {};
|
|
156
321
|
/**
|
|
157
322
|
* DI token for the resolved stepper config. `providedIn: 'root'` with
|
|
158
323
|
* library defaults; override via {@link provideStepperConfig} (root)
|
|
@@ -165,7 +330,7 @@ const STEPPER_CONFIG_DEFAULTS = {
|
|
|
165
330
|
*/
|
|
166
331
|
const CNGX_STEPPER_CONFIG = new InjectionToken('CngxStepperConfig', {
|
|
167
332
|
providedIn: 'root',
|
|
168
|
-
factory: () =>
|
|
333
|
+
factory: () => resolveFeatures([]),
|
|
169
334
|
});
|
|
170
335
|
/**
|
|
171
336
|
* Brands a config mutator with `_target: 'config'`. Every `with*`
|
|
@@ -252,28 +417,18 @@ function withStepperConnectors(on) {
|
|
|
252
417
|
return defineStepperConfigFeature((cfg) => ({ ...cfg, connectors: on }));
|
|
253
418
|
}
|
|
254
419
|
/**
|
|
255
|
-
* Configure the mobile auto-collapse target for `<cngx-stepper>`.
|
|
256
|
-
*
|
|
257
|
-
* the chosen variant - `'text'` (default) renders
|
|
258
|
-
* `'dots'` renders `<cngx-dot-stepper>`, `'off'`
|
|
259
|
-
* strip. The Material twin `<cngx-mat-stepper>` ignores
|
|
420
|
+
* Configure the mobile auto-collapse target for `<cngx-stepper>`. Below
|
|
421
|
+
* `30rem` of the stepper's own container width, the classic strip swaps
|
|
422
|
+
* to the chosen variant - `'text'` (default) renders
|
|
423
|
+
* `<cngx-text-stepper>`, `'dots'` renders `<cngx-dot-stepper>`, `'off'`
|
|
424
|
+
* keeps the classic strip. The Material twin `<cngx-mat-stepper>` ignores
|
|
425
|
+
* this setting.
|
|
260
426
|
*
|
|
261
427
|
* @category common/stepper
|
|
262
428
|
*/
|
|
263
429
|
function withStepperMobileCollapse(mode) {
|
|
264
430
|
return defineStepperConfigFeature((cfg) => ({ ...cfg, mobileCollapse: mode }));
|
|
265
431
|
}
|
|
266
|
-
/**
|
|
267
|
-
* Override the media query the mobile auto-collapse policy reacts to.
|
|
268
|
-
* Default `'(max-width: 480px)'`. Useful for tablet-tier consumers
|
|
269
|
-
* who want the collapse to engage at 768px or for design systems
|
|
270
|
-
* aligned with `--mat-sys-breakpoint-*` tokens.
|
|
271
|
-
*
|
|
272
|
-
* @category common/stepper
|
|
273
|
-
*/
|
|
274
|
-
function withStepperMobileBreakpoint(query) {
|
|
275
|
-
return defineStepperConfigFeature((cfg) => ({ ...cfg, mobileBreakpoint: query }));
|
|
276
|
-
}
|
|
277
432
|
/**
|
|
278
433
|
* Set the app-wide default position of the mobile auto-collapse
|
|
279
434
|
* indicator relative to panel content. `'top'` keeps the indicator
|
|
@@ -337,44 +492,43 @@ function withStepperGroupCollapseSummary(mode) {
|
|
|
337
492
|
}
|
|
338
493
|
/**
|
|
339
494
|
* Set the app-wide space-driven density policy for the classic
|
|
340
|
-
* `<cngx-stepper>` strip. `'auto'`
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
495
|
+
* `<cngx-stepper>` strip. `'auto'` sets `[data-density-auto]`, under
|
|
496
|
+
* which the labels shrink in flow within a cqi budget (the step furthest
|
|
497
|
+
* from the active one gives way first) instead of overflowing the strip;
|
|
498
|
+
* `'comfortable'` (library default) keeps full labels at every width.
|
|
499
|
+
* Orthogonal to the `mobileCollapse` axis; the Material twin ignores this
|
|
500
|
+
* setting.
|
|
346
501
|
*
|
|
347
502
|
* @category common/stepper
|
|
348
503
|
*/
|
|
349
|
-
function withStepperDensity(mode
|
|
350
|
-
return defineStepperConfigFeature((cfg) => ({
|
|
351
|
-
...cfg,
|
|
352
|
-
density: mode,
|
|
353
|
-
...(breakpoints ? { densityBreakpoints: breakpoints } : {}),
|
|
354
|
-
}));
|
|
504
|
+
function withStepperDensity(mode) {
|
|
505
|
+
return defineStepperConfigFeature((cfg) => ({ ...cfg, density: mode }));
|
|
355
506
|
}
|
|
356
507
|
/**
|
|
357
508
|
* Merge ARIA labels into the cascade. Keys not provided keep their
|
|
358
509
|
* library defaults; per-instance overrides on the stepper still win.
|
|
510
|
+
* Pass a `Signal` to switch the language at runtime.
|
|
359
511
|
*
|
|
360
512
|
* @category common/stepper
|
|
361
513
|
*/
|
|
362
514
|
function withStepperAriaLabels(labels) {
|
|
363
515
|
return defineStepperConfigFeature((cfg) => ({
|
|
364
516
|
...cfg,
|
|
365
|
-
ariaLabels:
|
|
517
|
+
ariaLabels: createOverrideMerge(cfg.ariaLabels ?? NO_LABELS, labels),
|
|
366
518
|
}));
|
|
367
519
|
}
|
|
368
520
|
/**
|
|
369
|
-
* Merge
|
|
370
|
-
*
|
|
521
|
+
* Merge fallback role descriptions (`groupRoleDescription` /
|
|
522
|
+
* `stepRoleDescription`) into the cascade. These feed the strip's
|
|
523
|
+
* `aria-roledescription` attributes when the consumer supplies none.
|
|
524
|
+
* Pass a `Signal` to switch the language at runtime.
|
|
371
525
|
*
|
|
372
526
|
* @category common/stepper
|
|
373
527
|
*/
|
|
374
528
|
function withStepperFallbackLabels(labels) {
|
|
375
529
|
return defineStepperConfigFeature((cfg) => ({
|
|
376
530
|
...cfg,
|
|
377
|
-
fallbackLabels:
|
|
531
|
+
fallbackLabels: createOverrideMerge(cfg.fallbackLabels ?? NO_LABELS, labels),
|
|
378
532
|
}));
|
|
379
533
|
}
|
|
380
534
|
/**
|
|
@@ -461,10 +615,11 @@ function withStepperEmptyTemplate(template) {
|
|
|
461
615
|
}));
|
|
462
616
|
}
|
|
463
617
|
/**
|
|
464
|
-
* Override the default `*cngxDotStepperDot` template app-wide.
|
|
465
|
-
* `<cngx-dot-stepper>`
|
|
466
|
-
*
|
|
467
|
-
* (the dot fill is painted by
|
|
618
|
+
* Override the default `*cngxDotStepperDot` template app-wide. Both dot
|
|
619
|
+
* hosts resolve the cascade per dot - `<cngx-dot-stepper>` and the dots
|
|
620
|
+
* mobile-collapse branch of `<cngx-stepper>`: per-instance directive >
|
|
621
|
+
* this feature > built-in empty body (the dot fill is painted by the dot
|
|
622
|
+
* element's CSS regardless).
|
|
468
623
|
*
|
|
469
624
|
* @category common/stepper
|
|
470
625
|
*/
|
|
@@ -474,9 +629,26 @@ function withDotStepperDotTemplate(template) {
|
|
|
474
629
|
templates: { ...cfg.templates, dotStepperDot: template },
|
|
475
630
|
}));
|
|
476
631
|
}
|
|
477
|
-
/**
|
|
632
|
+
/**
|
|
633
|
+
* @internal The defaults with the copy keys read from the stepper section of
|
|
634
|
+
* the active language pack. Runs in an injection context.
|
|
635
|
+
*/
|
|
636
|
+
function stepperConfigDefaultsFromPack() {
|
|
637
|
+
const language = injectStepperLanguage();
|
|
638
|
+
return {
|
|
639
|
+
...STEPPER_CONFIG_DEFAULTS,
|
|
640
|
+
ariaLabels: computed(() => ({ stepperRegion: language().stepperRegion }), {
|
|
641
|
+
equal: recordEqual,
|
|
642
|
+
}),
|
|
643
|
+
fallbackLabels: computed(() => ({
|
|
644
|
+
groupRoleDescription: language().groupRoleDescription,
|
|
645
|
+
stepRoleDescription: language().stepRoleDescription,
|
|
646
|
+
}), { equal: recordEqual }),
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
/** @internal Runs in an injection context; features apply on top of the pack. */
|
|
478
650
|
function resolveFeatures(features) {
|
|
479
|
-
return features.reduce((cfg, feat) => feat(cfg),
|
|
651
|
+
return features.reduce((cfg, feat) => feat(cfg), stepperConfigDefaultsFromPack());
|
|
480
652
|
}
|
|
481
653
|
/**
|
|
482
654
|
* Root-level provider for the stepper config. Apply once in the
|
|
@@ -487,7 +659,7 @@ function resolveFeatures(features) {
|
|
|
487
659
|
*/
|
|
488
660
|
function provideStepperConfig(...features) {
|
|
489
661
|
return makeEnvironmentProviders([
|
|
490
|
-
{ provide: CNGX_STEPPER_CONFIG,
|
|
662
|
+
{ provide: CNGX_STEPPER_CONFIG, useFactory: () => resolveFeatures(features) },
|
|
491
663
|
]);
|
|
492
664
|
}
|
|
493
665
|
/**
|
|
@@ -508,7 +680,7 @@ function provideStepperConfig(...features) {
|
|
|
508
680
|
* @category common/stepper
|
|
509
681
|
*/
|
|
510
682
|
function provideStepperConfigAt(...features) {
|
|
511
|
-
return [{ provide: CNGX_STEPPER_CONFIG,
|
|
683
|
+
return [{ provide: CNGX_STEPPER_CONFIG, useFactory: () => resolveFeatures(features) }];
|
|
512
684
|
}
|
|
513
685
|
/**
|
|
514
686
|
* Inject the resolved stepper config in an injection context.
|
|
@@ -530,6 +702,25 @@ function injectStepperConfig() {
|
|
|
530
702
|
* @since 0.1.0
|
|
531
703
|
*/
|
|
532
704
|
const CNGX_STEPPER_HOST = new InjectionToken('CngxStepperHost');
|
|
705
|
+
/**
|
|
706
|
+
* Inject the {@link CNGX_STEPPER_HOST} for a stepper add-on directive.
|
|
707
|
+
* Throws a `CngxRuntimeError` with code `CNGX1055` when no stepper presenter
|
|
708
|
+
* is found, in development and production alike. With `host: true` the
|
|
709
|
+
* lookup stops at the declaring template's host, so the presenter has to sit
|
|
710
|
+
* on the same element or an ancestor in the same template. `selector` names
|
|
711
|
+
* the add-on in the development message.
|
|
712
|
+
*
|
|
713
|
+
* @internal
|
|
714
|
+
*/
|
|
715
|
+
function injectStepperHost(selector, options) {
|
|
716
|
+
const stepper = inject(CNGX_STEPPER_HOST, { host: options.host, optional: true });
|
|
717
|
+
if (!stepper) {
|
|
718
|
+
throw new CngxRuntimeError('CNGX1055', typeof ngDevMode !== 'undefined' &&
|
|
719
|
+
ngDevMode &&
|
|
720
|
+
`[${selector}] must be placed on or inside an element with [cngxStepper], such as <cngx-stepper>.`);
|
|
721
|
+
}
|
|
722
|
+
return stepper;
|
|
723
|
+
}
|
|
533
724
|
|
|
534
725
|
/**
|
|
535
726
|
* DFS-flatten a step tree. Group nodes emit before their children;
|
|
@@ -589,8 +780,7 @@ function stepTreeEqual(a, b) {
|
|
|
589
780
|
* a sibling is inserted) on top of the {@link stepTreeEqual} fields.
|
|
590
781
|
*
|
|
591
782
|
* Use only on projections where every step carries a real
|
|
592
|
-
* DFS-assigned `flatIndex` and `depth
|
|
593
|
-
* {@link stepNodesEqual}.
|
|
783
|
+
* DFS-assigned `flatIndex` and `depth`.
|
|
594
784
|
*
|
|
595
785
|
* @internal Exported from `public-api.ts` so the cngx-stepper and
|
|
596
786
|
* cngx-mat-stepper organisms share the comparator across the
|
|
@@ -615,27 +805,6 @@ function flatStepsEqual(a, b) {
|
|
|
615
805
|
}
|
|
616
806
|
return true;
|
|
617
807
|
}
|
|
618
|
-
/**
|
|
619
|
-
* Structural equality for any flat node array - `id`, `kind`,
|
|
620
|
-
* `parentId` only, ignoring `flatIndex` and `depth`. Use for
|
|
621
|
-
* `CngxStepGroup.children` and other `-1`-placeholder projections.
|
|
622
|
-
*
|
|
623
|
-
* @internal
|
|
624
|
-
*/
|
|
625
|
-
function stepNodesEqual(a, b) {
|
|
626
|
-
if (a === b) {
|
|
627
|
-
return true;
|
|
628
|
-
}
|
|
629
|
-
if (a.length !== b.length) {
|
|
630
|
-
return false;
|
|
631
|
-
}
|
|
632
|
-
for (let i = 0; i < a.length; i++) {
|
|
633
|
-
if (a[i].id !== b[i].id || a[i].kind !== b[i].kind || a[i].parentId !== b[i].parentId) {
|
|
634
|
-
return false;
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
return true;
|
|
638
|
-
}
|
|
639
808
|
|
|
640
809
|
/**
|
|
641
810
|
* Stepper presenter - the brain of every stepper / wizard flow.
|
|
@@ -687,12 +856,31 @@ class CngxStepperPresenter {
|
|
|
687
856
|
* `linkedSignal` is shared across all consumers.
|
|
688
857
|
*/
|
|
689
858
|
commitTransition = createTransitionTracker(() => this.commitController.state.status());
|
|
690
|
-
// Persistence-of-
|
|
691
|
-
// / originIndexDuringCommit for the contract.
|
|
692
|
-
|
|
859
|
+
// Persistence-of-rejection surface - see CngxStepperHost.lastOutcome /
|
|
860
|
+
// lastFailedIndex / originIndexDuringCommit for the contract. Two
|
|
861
|
+
// event sources, never synced: the settle record and the sequence whose
|
|
862
|
+
// visual marker was cleared. lastFailedIndex derives from both, so
|
|
863
|
+
// clearing the marker never touches the announcement record.
|
|
864
|
+
lastOutcomeState = signal(undefined, ...(ngDevMode ? [{ debugName: "lastOutcomeState" }] : /* istanbul ignore next */ []));
|
|
865
|
+
clearedSequenceState = signal(undefined, ...(ngDevMode ? [{ debugName: "clearedSequenceState" }] : /* istanbul ignore next */ []));
|
|
866
|
+
// Bumped once per settled refusal or failure. Plain field - only read
|
|
867
|
+
// inside the resolve handler.
|
|
868
|
+
outcomeSequence = 0;
|
|
869
|
+
// Last index a commit actually landed on (or a sync/back move settled
|
|
870
|
+
// on). Rollback + origin resolution use this instead of the per-call
|
|
871
|
+
// `previous`: a rapid second select() supersedes the first while
|
|
872
|
+
// `previous` already points at the never-committed optimistic index,
|
|
873
|
+
// and rolling back there would strand the user mid-air. Plain field -
|
|
874
|
+
// read only inside handlers, never rendered.
|
|
875
|
+
lastCommittedIndex;
|
|
693
876
|
originIndexDuringCommitState = signal(undefined, ...(ngDevMode ? [{ debugName: "originIndexDuringCommitState" }] : /* istanbul ignore next */ []));
|
|
877
|
+
/** {@inheritDoc CngxStepperHost.lastOutcome} */
|
|
878
|
+
lastOutcome = this.lastOutcomeState.asReadonly();
|
|
694
879
|
/** {@inheritDoc CngxStepperHost.lastFailedIndex} */
|
|
695
|
-
lastFailedIndex =
|
|
880
|
+
lastFailedIndex = computed(() => {
|
|
881
|
+
const outcome = this.lastOutcomeState();
|
|
882
|
+
return outcome && outcome.sequence !== this.clearedSequenceState() ? outcome.index : undefined;
|
|
883
|
+
}, ...(ngDevMode ? [{ debugName: "lastFailedIndex" }] : /* istanbul ignore next */ []));
|
|
696
884
|
/** {@inheritDoc CngxStepperHost.originIndexDuringCommit} */
|
|
697
885
|
originIndexDuringCommit = this.originIndexDuringCommitState.asReadonly();
|
|
698
886
|
treeState = signal([], { ...(ngDevMode ? { debugName: "treeState" } : /* istanbul ignore next */ {}), equal: stepTreeEqual });
|
|
@@ -788,24 +976,24 @@ class CngxStepperPresenter {
|
|
|
788
976
|
*/
|
|
789
977
|
nextEnabledIndex = computed(() => {
|
|
790
978
|
const stepsOnly = this.stepsOnly();
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
}
|
|
795
|
-
return next;
|
|
979
|
+
return (resolveStepFrom(this.activeStepIndex(), 1, {
|
|
980
|
+
count: stepsOnly.length,
|
|
981
|
+
isDisabledAt: (i) => stepsOnly[i]?.disabled() ?? false,
|
|
982
|
+
}) ?? stepsOnly.length);
|
|
796
983
|
}, ...(ngDevMode ? [{ debugName: "nextEnabledIndex" }] : /* istanbul ignore next */ []));
|
|
797
984
|
/**
|
|
798
985
|
* Previous enabled step-only index before the active one, skipping
|
|
799
|
-
* disabled steps. Returns `-1` when no enabled step precedes
|
|
986
|
+
* disabled steps. Returns `-1` when no enabled step precedes - also for
|
|
987
|
+
* a stale out-of-range active index (consumer-writable model), which
|
|
988
|
+
* must resolve to "none" instead of wrapping or throwing. Single
|
|
800
989
|
* source for `selectPrevious()` and the `canGoPrevious` bound.
|
|
801
990
|
*/
|
|
802
991
|
previousEnabledIndex = computed(() => {
|
|
803
992
|
const stepsOnly = this.stepsOnly();
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
}
|
|
808
|
-
return prev;
|
|
993
|
+
return (resolveStepFrom(Math.max(this.activeStepIndex(), 0), -1, {
|
|
994
|
+
count: stepsOnly.length,
|
|
995
|
+
isDisabledAt: (i) => stepsOnly[i]?.disabled() ?? false,
|
|
996
|
+
}) ?? -1);
|
|
809
997
|
}, ...(ngDevMode ? [{ debugName: "previousEnabledIndex" }] : /* istanbul ignore next */ []));
|
|
810
998
|
/** {@inheritDoc CngxStepperHost.stepCount} */
|
|
811
999
|
stepCount = computed(() => this.stepsOnly().length, ...(ngDevMode ? [{ debugName: "stepCount" }] : /* istanbul ignore next */ []));
|
|
@@ -833,11 +1021,11 @@ class CngxStepperPresenter {
|
|
|
833
1021
|
/** {@inheritDoc CngxStepperHost.previousStepLabel} */
|
|
834
1022
|
previousStepLabel = computed(() => this.stepsOnly()[this.previousEnabledIndex()]?.label(), ...(ngDevMode ? [{ debugName: "previousStepLabel" }] : /* istanbul ignore next */ []));
|
|
835
1023
|
constructor() {
|
|
836
|
-
if (
|
|
1024
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
837
1025
|
afterNextRender(() => {
|
|
838
1026
|
const stepNodes = this.flatSteps().filter((n) => n.kind === 'step');
|
|
839
1027
|
if (stepNodes.length > 6 && stepNodes.every((n) => n.parentId === null)) {
|
|
840
|
-
|
|
1028
|
+
cngxDevWarn('CNGX1039', '[cngxStepper] more than 6 steps and none inside a [cngxStepGroup]; consider wrapping logical groups of steps in [cngxStepGroup] for better UX');
|
|
841
1029
|
}
|
|
842
1030
|
});
|
|
843
1031
|
}
|
|
@@ -865,11 +1053,16 @@ class CngxStepperPresenter {
|
|
|
865
1053
|
}
|
|
866
1054
|
this.rebuildTree();
|
|
867
1055
|
}
|
|
868
|
-
unregister(id) {
|
|
1056
|
+
unregister(id, handle) {
|
|
869
1057
|
const entry = this.registry.get(id);
|
|
870
1058
|
if (!entry) {
|
|
871
1059
|
return;
|
|
872
1060
|
}
|
|
1061
|
+
// Instance guard: after an idempotent re-register replaced the stored
|
|
1062
|
+
// handle, the superseded instance's destroy is a no-op.
|
|
1063
|
+
if (handle !== undefined && entry.reg !== handle) {
|
|
1064
|
+
return;
|
|
1065
|
+
}
|
|
873
1066
|
if (entry.parentId !== null) {
|
|
874
1067
|
const parent = this.registry.get(entry.parentId);
|
|
875
1068
|
if (parent) {
|
|
@@ -906,7 +1099,7 @@ class CngxStepperPresenter {
|
|
|
906
1099
|
}
|
|
907
1100
|
/** {@inheritDoc CngxStepperHost.clearLastFailed} */
|
|
908
1101
|
clearLastFailed() {
|
|
909
|
-
this.
|
|
1102
|
+
this.clearedSequenceState.set(this.lastOutcomeState()?.sequence);
|
|
910
1103
|
}
|
|
911
1104
|
/**
|
|
912
1105
|
* Linear-gate predicate: `true` when linear mode forbids advancing to
|
|
@@ -964,8 +1157,9 @@ class CngxStepperPresenter {
|
|
|
964
1157
|
// `originIndexDuringCommit` stays untouched. Clear the rejection
|
|
965
1158
|
// flag if the user re-picked a previously-failed target.
|
|
966
1159
|
this.activeStepIndex.set(target);
|
|
967
|
-
|
|
968
|
-
|
|
1160
|
+
this.lastCommittedIndex = target;
|
|
1161
|
+
if (this.lastFailedIndex() === target) {
|
|
1162
|
+
this.clearLastFailed();
|
|
969
1163
|
}
|
|
970
1164
|
return;
|
|
971
1165
|
}
|
|
@@ -976,33 +1170,44 @@ class CngxStepperPresenter {
|
|
|
976
1170
|
//
|
|
977
1171
|
// Capture the safe-harbour origin exactly once on commit-window
|
|
978
1172
|
// open. Written ONLY on this path so a stale origin never lingers
|
|
979
|
-
// into a non-commit navigation.
|
|
980
|
-
|
|
1173
|
+
// into a non-commit navigation. The origin is the last TRULY
|
|
1174
|
+
// committed index, not `previous`: under a superseded optimistic
|
|
1175
|
+
// commit `previous` is the never-committed optimistic position.
|
|
1176
|
+
const origin = this.lastCommittedIndex ?? previous;
|
|
1177
|
+
// Record the origin as truly committed on window open: for the first
|
|
1178
|
+
// window `previous` IS the settled start position; for a superseding
|
|
1179
|
+
// select the field already holds the real one (idempotent).
|
|
1180
|
+
this.lastCommittedIndex = origin;
|
|
1181
|
+
this.originIndexDuringCommitState.set(origin);
|
|
981
1182
|
const mode = this.commitMode();
|
|
982
1183
|
if (mode === 'optimistic') {
|
|
983
1184
|
this.activeStepIndex.set(target);
|
|
984
1185
|
}
|
|
985
|
-
this.commitHandler.beginTransition(previous, target, action, (
|
|
986
|
-
if (
|
|
1186
|
+
this.commitHandler.beginTransition(previous, target, action, (outcome) => {
|
|
1187
|
+
if (outcome === 'accepted') {
|
|
987
1188
|
// Success - origin no longer needed; clear the rejection
|
|
988
|
-
//
|
|
1189
|
+
// marker if the user re-picked the rejected target.
|
|
1190
|
+
this.lastCommittedIndex = target;
|
|
989
1191
|
this.originIndexDuringCommitState.set(undefined);
|
|
990
|
-
if (this.
|
|
991
|
-
this.
|
|
1192
|
+
if (this.lastFailedIndex() === target) {
|
|
1193
|
+
this.clearLastFailed();
|
|
992
1194
|
}
|
|
993
1195
|
if (mode === 'pessimistic') {
|
|
994
1196
|
this.activeStepIndex.set(target);
|
|
995
1197
|
}
|
|
1198
|
+
return;
|
|
996
1199
|
}
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1200
|
+
// Refused or failed - record the outcome on the target; RETAIN the
|
|
1201
|
+
// origin so `liveAnnouncement` can resolve the origin label for
|
|
1202
|
+
// the rich phrase. Both kinds roll back: optimistic returns to the
|
|
1203
|
+
// last truly-committed index, pessimistic never moved off it.
|
|
1204
|
+
this.lastOutcomeState.set({
|
|
1205
|
+
kind: outcome,
|
|
1206
|
+
index: target,
|
|
1207
|
+
sequence: ++this.outcomeSequence,
|
|
1208
|
+
});
|
|
1209
|
+
if (mode === 'optimistic') {
|
|
1210
|
+
this.activeStepIndex.set(origin);
|
|
1006
1211
|
}
|
|
1007
1212
|
});
|
|
1008
1213
|
}
|
|
@@ -1012,9 +1217,18 @@ class CngxStepperPresenter {
|
|
|
1012
1217
|
this.select(next);
|
|
1013
1218
|
}
|
|
1014
1219
|
}
|
|
1220
|
+
/**
|
|
1221
|
+
* Ungated back-move. Supersedes an in-flight commit: the runner is
|
|
1222
|
+
* canceled and the commit state settles to idle, so `busy` cannot
|
|
1223
|
+
* latch and a late resolve cannot yank the user forward off the step
|
|
1224
|
+
* they explicitly returned to.
|
|
1225
|
+
*/
|
|
1015
1226
|
selectPrevious() {
|
|
1016
1227
|
const prev = this.previousEnabledIndex();
|
|
1017
1228
|
if (prev >= 0) {
|
|
1229
|
+
this.cancelAndSettleCommit();
|
|
1230
|
+
this.originIndexDuringCommitState.set(undefined);
|
|
1231
|
+
this.lastCommittedIndex = prev;
|
|
1018
1232
|
this.activeStepIndex.set(prev);
|
|
1019
1233
|
}
|
|
1020
1234
|
}
|
|
@@ -1027,7 +1241,27 @@ class CngxStepperPresenter {
|
|
|
1027
1241
|
}
|
|
1028
1242
|
reset() {
|
|
1029
1243
|
this.activeStepIndex.set(0);
|
|
1030
|
-
this.
|
|
1244
|
+
this.lastCommittedIndex = 0;
|
|
1245
|
+
this.originIndexDuringCommitState.set(undefined);
|
|
1246
|
+
this.lastOutcomeState.set(undefined);
|
|
1247
|
+
this.clearedSequenceState.set(undefined);
|
|
1248
|
+
// Settle mid-commit resets to idle - the surface lives on, so a
|
|
1249
|
+
// dangling 'pending' would latch busy() forever.
|
|
1250
|
+
this.cancelAndSettleCommit();
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
* Cancels the in-flight commit and settles the state to idle. The
|
|
1254
|
+
* settle option is load-bearing here - a custom
|
|
1255
|
+
* `CNGX_COMMIT_CONTROLLER_FACTORY` implementation that ignores it
|
|
1256
|
+
* leaves `busy` latched, which is invisible until a user backs out
|
|
1257
|
+
* mid-commit; the dev-mode probe surfaces that immediately.
|
|
1258
|
+
*/
|
|
1259
|
+
cancelAndSettleCommit() {
|
|
1260
|
+
this.commitController.cancel({ settle: true });
|
|
1261
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode && this.commitState.status() === 'pending') {
|
|
1262
|
+
cngxDevWarn('CNGX1040', '[cngxStepper] the commit controller ignored cancel({ settle: true }) - busy stays ' +
|
|
1263
|
+
'latched. Honor the settle option in your CNGX_COMMIT_CONTROLLER_FACTORY override.');
|
|
1264
|
+
}
|
|
1031
1265
|
}
|
|
1032
1266
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepperPresenter, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1033
1267
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxStepperPresenter, isStandalone: true, selector: "[cngxStepper]", inputs: { activeStepIndex: { classPropertyName: "activeStepIndex", publicName: "activeStepIndex", isSignal: true, isRequired: false, transformFunction: null }, linearInput: { classPropertyName: "linearInput", publicName: "linear", isSignal: true, isRequired: false, transformFunction: null }, orientationInput: { classPropertyName: "orientationInput", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, commitAction: { classPropertyName: "commitAction", publicName: "commitAction", isSignal: true, isRequired: false, transformFunction: null }, commitModeInput: { classPropertyName: "commitModeInput", publicName: "commitMode", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { activeStepIndex: "activeStepIndexChange" }, providers: [
|
|
@@ -1137,7 +1371,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1137
1371
|
* `CngxStepGroup` ({@link CNGX_STEP_GROUP_HOST}) or the root
|
|
1138
1372
|
* `CngxStepperPresenter` ({@link CNGX_STEPPER_HOST}).
|
|
1139
1373
|
*
|
|
1140
|
-
* `state` is a `
|
|
1374
|
+
* `state` is a pure `computed` over `[disabled]`, `[completed]`, and
|
|
1141
1375
|
* the optional `[errorAggregator]`'s `hasError()`.
|
|
1142
1376
|
*
|
|
1143
1377
|
* @category common/stepper
|
|
@@ -1179,39 +1413,31 @@ class CngxStep {
|
|
|
1179
1413
|
contentSlot = contentChild(CngxStepContent, ...(ngDevMode ? [{ debugName: "contentSlot" }] : /* istanbul ignore next */ []));
|
|
1180
1414
|
labelTemplate = this.labelSlot;
|
|
1181
1415
|
contentTemplate = this.contentSlot;
|
|
1182
|
-
/**
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
}
|
|
1199
|
-
if (errored) {
|
|
1200
|
-
return 'error';
|
|
1201
|
-
}
|
|
1202
|
-
if (completed) {
|
|
1203
|
-
return 'success';
|
|
1204
|
-
}
|
|
1205
|
-
return 'idle';
|
|
1206
|
-
},
|
|
1207
|
-
equal: Object.is });
|
|
1416
|
+
/** Per-step status derived from inputs + aggregator - never written. */
|
|
1417
|
+
state = computed(() => {
|
|
1418
|
+
if (this.disabled()) {
|
|
1419
|
+
return 'disabled';
|
|
1420
|
+
}
|
|
1421
|
+
const directError = this.error();
|
|
1422
|
+
const errored = (directError !== false && directError !== '') ||
|
|
1423
|
+
(this.errorAggregator()?.hasError?.() ?? false);
|
|
1424
|
+
if (errored) {
|
|
1425
|
+
return 'error';
|
|
1426
|
+
}
|
|
1427
|
+
if (this.completed()) {
|
|
1428
|
+
return 'success';
|
|
1429
|
+
}
|
|
1430
|
+
return 'idle';
|
|
1431
|
+
}, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
1208
1432
|
groupHost = inject(CNGX_STEP_GROUP_HOST, { optional: true });
|
|
1209
1433
|
stepperHost = inject(CNGX_STEPPER_HOST, { optional: true });
|
|
1210
1434
|
destroyRef = inject(DestroyRef);
|
|
1211
1435
|
constructor() {
|
|
1212
1436
|
if (!this.groupHost && !this.stepperHost) {
|
|
1213
|
-
throw new
|
|
1214
|
-
|
|
1437
|
+
throw new CngxRuntimeError('CNGX1046', typeof ngDevMode !== 'undefined' &&
|
|
1438
|
+
ngDevMode &&
|
|
1439
|
+
'[cngxStep] must be placed inside an element with [cngxStepper], such as ' +
|
|
1440
|
+
'<cngx-stepper>, directly or through a [cngxStepGroup] inside it.');
|
|
1215
1441
|
}
|
|
1216
1442
|
}
|
|
1217
1443
|
ngOnInit() {
|
|
@@ -1225,7 +1451,7 @@ class CngxStep {
|
|
|
1225
1451
|
// the presenter's insertion-order tree is unchanged. Mirrors CngxTab.
|
|
1226
1452
|
const host = this.groupHost ?? this.stepperHost;
|
|
1227
1453
|
const stepId = this.id();
|
|
1228
|
-
|
|
1454
|
+
const handle = {
|
|
1229
1455
|
id: stepId,
|
|
1230
1456
|
kind: 'step',
|
|
1231
1457
|
label: this.label,
|
|
@@ -1233,8 +1459,9 @@ class CngxStep {
|
|
|
1233
1459
|
state: this.state,
|
|
1234
1460
|
errorAggregator: this.errorAggregator,
|
|
1235
1461
|
errorMessage: this.errorMessage,
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1462
|
+
};
|
|
1463
|
+
host.register(handle);
|
|
1464
|
+
this.destroyRef.onDestroy(() => host.unregister(stepId, handle));
|
|
1238
1465
|
}
|
|
1239
1466
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStep, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1240
1467
|
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 });
|
|
@@ -1283,7 +1510,10 @@ class CngxStepGroup {
|
|
|
1283
1510
|
if (states.some((s) => s === 'error')) {
|
|
1284
1511
|
return 'error';
|
|
1285
1512
|
}
|
|
1286
|
-
if (states.some((s) => s === 'pending'
|
|
1513
|
+
if (states.some((s) => s === 'pending')) {
|
|
1514
|
+
// 'pending' can only come from a nested group's own rollup; leaf
|
|
1515
|
+
// steps never produce it ('busy' is a per-step presenter concern,
|
|
1516
|
+
// not a step state, so no 'busy' arm exists here).
|
|
1287
1517
|
return 'pending';
|
|
1288
1518
|
}
|
|
1289
1519
|
if (states.every((s) => s === 'success')) {
|
|
@@ -1292,6 +1522,13 @@ class CngxStepGroup {
|
|
|
1292
1522
|
return 'idle';
|
|
1293
1523
|
}, { ...(ngDevMode ? { debugName: "aggregatedStatus" } : /* istanbul ignore next */ {}), equal: Object.is });
|
|
1294
1524
|
stepperHost = inject(CNGX_STEPPER_HOST, { optional: true });
|
|
1525
|
+
// A group nested inside another group must register through its parent
|
|
1526
|
+
// (skipSelf past our own CNGX_STEP_GROUP_HOST provider), or it would
|
|
1527
|
+
// silently register as a root and flatten the tree.
|
|
1528
|
+
parentGroupHost = inject(CNGX_STEP_GROUP_HOST, {
|
|
1529
|
+
optional: true,
|
|
1530
|
+
skipSelf: true,
|
|
1531
|
+
});
|
|
1295
1532
|
destroyRef = inject(DestroyRef);
|
|
1296
1533
|
/**
|
|
1297
1534
|
* `true` when this group's children are collapsed to the header node:
|
|
@@ -1317,8 +1554,10 @@ class CngxStepGroup {
|
|
|
1317
1554
|
}, ...(ngDevMode ? [{ debugName: "isCollapsed" }] : /* istanbul ignore next */ []));
|
|
1318
1555
|
constructor() {
|
|
1319
1556
|
if (!this.stepperHost) {
|
|
1320
|
-
throw new
|
|
1321
|
-
|
|
1557
|
+
throw new CngxRuntimeError('CNGX1047', typeof ngDevMode !== 'undefined' &&
|
|
1558
|
+
ngDevMode &&
|
|
1559
|
+
'[cngxStepGroup] must be placed inside an element with [cngxStepper], ' +
|
|
1560
|
+
'such as <cngx-stepper>.');
|
|
1322
1561
|
}
|
|
1323
1562
|
}
|
|
1324
1563
|
ngOnInit() {
|
|
@@ -1328,25 +1567,28 @@ class CngxStepGroup {
|
|
|
1328
1567
|
// ancestor group before its descendant steps, so that order holds, and
|
|
1329
1568
|
// groups and steps share one lifecycle phase - keeping the presenter's
|
|
1330
1569
|
// insertion-order tree identical to the previous constructor ordering.
|
|
1331
|
-
const
|
|
1570
|
+
const registrationHost = this.parentGroupHost ?? this.stepperHost;
|
|
1332
1571
|
const groupId = this.id();
|
|
1333
|
-
|
|
1572
|
+
const handle = {
|
|
1334
1573
|
id: groupId,
|
|
1335
1574
|
kind: 'group',
|
|
1336
1575
|
label: this.label,
|
|
1337
1576
|
disabled: this.disabled,
|
|
1338
1577
|
state: this.aggregatedStatus,
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1578
|
+
};
|
|
1579
|
+
registrationHost.register(handle);
|
|
1580
|
+
this.destroyRef.onDestroy(() => registrationHost.unregister(groupId, handle));
|
|
1341
1581
|
}
|
|
1342
1582
|
register(handle) {
|
|
1343
1583
|
this.childRegistry.update((cur) => [...cur, handle]);
|
|
1344
1584
|
// Forward to the root with this group as parent so the tree shape is correct.
|
|
1345
1585
|
this.stepperHost.register(handle, this.id());
|
|
1346
1586
|
}
|
|
1347
|
-
unregister(id) {
|
|
1348
|
-
|
|
1349
|
-
|
|
1587
|
+
unregister(id, handle) {
|
|
1588
|
+
// Same instance guard as the presenter: only evict the exact handle
|
|
1589
|
+
// (or fall back to id-keyed removal for handle-less callers).
|
|
1590
|
+
this.childRegistry.update((cur) => cur.filter((c) => (handle !== undefined ? c !== handle : c.id !== id)));
|
|
1591
|
+
this.stepperHost.unregister(id, handle);
|
|
1350
1592
|
}
|
|
1351
1593
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1352
1594
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxStepGroup, isStandalone: true, selector: "[cngxStepGroup]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null } }, providers: [{ provide: CNGX_STEP_GROUP_HOST, useExisting: CngxStepGroup }], exportAs: ["cngxStepGroup"], ngImport: i0 });
|
|
@@ -1632,7 +1874,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1632
1874
|
}] });
|
|
1633
1875
|
|
|
1634
1876
|
/**
|
|
1635
|
-
* Slot directive for the dot-body template on `<cngx-dot-stepper
|
|
1877
|
+
* Slot directive for the dot-body template on `<cngx-dot-stepper>` and on
|
|
1878
|
+
* `<cngx-stepper>` (dots mobile-collapse branch, `mobileCollapse: 'dots'`).
|
|
1636
1879
|
* Discovered via `contentChild`; cascades through
|
|
1637
1880
|
* `CNGX_STEPPER_CONFIG.templates.dotStepperDot` before falling back to
|
|
1638
1881
|
* the built-in empty body (the span itself paints the dot fill via CSS).
|
|
@@ -1709,6 +1952,9 @@ function createStepperTemplateBindings(opts) {
|
|
|
1709
1952
|
empty: computed(() => opts.emptySlot()?.templateRef ??
|
|
1710
1953
|
opts.config.templates?.empty ??
|
|
1711
1954
|
null),
|
|
1955
|
+
dot: computed(() => opts.dotSlot?.()?.templateRef ??
|
|
1956
|
+
opts.config.templates?.dotStepperDot ??
|
|
1957
|
+
null),
|
|
1712
1958
|
};
|
|
1713
1959
|
}
|
|
1714
1960
|
|
|
@@ -1731,8 +1977,14 @@ function createStepperTemplateBindings(opts) {
|
|
|
1731
1977
|
const CNGX_STEPPER_GLYPHS = {
|
|
1732
1978
|
/** Default visual for `*cngxStepBadge` when no override is bound. */
|
|
1733
1979
|
errorBadge: '!',
|
|
1734
|
-
/** Default visual for `*cngxStepRejection` when no override is bound. */
|
|
1980
|
+
/** Default visual for `*cngxStepRejection` on a failed commit when no override is bound. */
|
|
1735
1981
|
rejectionIcon: '!',
|
|
1982
|
+
/**
|
|
1983
|
+
* Default visual for `*cngxStepRejection` on a refused commit (the action
|
|
1984
|
+
* answered `false`). A distinct glyph, so a refusal never differs from a
|
|
1985
|
+
* failure by colour alone (WCAG 1.4.1).
|
|
1986
|
+
*/
|
|
1987
|
+
refusedIcon: '\u2298',
|
|
1736
1988
|
};
|
|
1737
1989
|
|
|
1738
1990
|
/**
|
|
@@ -1756,6 +2008,9 @@ const CNGX_STEPPER_GLYPHS = {
|
|
|
1756
2008
|
*/
|
|
1757
2009
|
class CngxStepperRouterSync {
|
|
1758
2010
|
// Default undefined so the cascade resolves through CNGX_STEPPER_CONFIG.
|
|
2011
|
+
// Init-only: the seed and the write effect capture the resolved mode /
|
|
2012
|
+
// param on their first run; changing either after init leaves the old
|
|
2013
|
+
// URL key behind. Rebuild the directive to change them.
|
|
1759
2014
|
modeInput = input(undefined, { ...(ngDevMode ? { debugName: "modeInput" } : /* istanbul ignore next */ {}), alias: 'mode' });
|
|
1760
2015
|
paramNameInput = input(undefined, { ...(ngDevMode ? { debugName: "paramNameInput" } : /* istanbul ignore next */ {}), alias: 'paramName' });
|
|
1761
2016
|
config = injectStepperConfig();
|
|
@@ -1763,7 +2018,7 @@ class CngxStepperRouterSync {
|
|
|
1763
2018
|
paramName = computed(() => this.paramNameInput() ?? this.config.routerSyncParam ?? 'step', ...(ngDevMode ? [{ debugName: "paramName" }] : /* istanbul ignore next */ []));
|
|
1764
2019
|
/** Emits when a `router.navigate` rejection is observed. */
|
|
1765
2020
|
syncError = output();
|
|
1766
|
-
host =
|
|
2021
|
+
host = injectStepperHost('cngxStepperRouterSync', { host: true });
|
|
1767
2022
|
router = inject(Router, { optional: true });
|
|
1768
2023
|
/**
|
|
1769
2024
|
* Latched once the URL seed has reached a registered step, so the
|
|
@@ -1778,11 +2033,16 @@ class CngxStepperRouterSync {
|
|
|
1778
2033
|
*/
|
|
1779
2034
|
seeded = false;
|
|
1780
2035
|
constructor() {
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
2036
|
+
// Router is providedIn: 'root' and resolves without provideRouter(...);
|
|
2037
|
+
// ActivatedRoute does not, so it is the "router is set up" signal.
|
|
2038
|
+
const route = inject(ActivatedRoute, { optional: true });
|
|
2039
|
+
if (!this.router || !route) {
|
|
2040
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
2041
|
+
afterNextRender(() => {
|
|
2042
|
+
cngxDevWarn('CNGX1031', '[cngxStepperRouterSync] no Router / ActivatedRoute available - the URL sync is a no-op. ' +
|
|
2043
|
+
'Provide @angular/router via provideRouter(...) to enable deep-linking.');
|
|
2044
|
+
});
|
|
2045
|
+
}
|
|
1786
2046
|
return;
|
|
1787
2047
|
}
|
|
1788
2048
|
const router = this.router;
|
|
@@ -1795,20 +2055,7 @@ class CngxStepperRouterSync {
|
|
|
1795
2055
|
if (!id) {
|
|
1796
2056
|
return;
|
|
1797
2057
|
}
|
|
1798
|
-
untracked(() =>
|
|
1799
|
-
const navigation = this.mode() === 'fragment'
|
|
1800
|
-
? router.navigate([], {
|
|
1801
|
-
fragment: `${this.paramName()}=${id}`,
|
|
1802
|
-
queryParamsHandling: 'merge',
|
|
1803
|
-
replaceUrl: true,
|
|
1804
|
-
})
|
|
1805
|
-
: router.navigate([], {
|
|
1806
|
-
queryParams: { [this.paramName()]: id },
|
|
1807
|
-
queryParamsHandling: 'merge',
|
|
1808
|
-
replaceUrl: true,
|
|
1809
|
-
});
|
|
1810
|
-
navigation.catch?.((err) => this.syncError.emit(err));
|
|
1811
|
-
});
|
|
2058
|
+
untracked(() => this.writeUrl(router, id));
|
|
1812
2059
|
});
|
|
1813
2060
|
const navEnd = toSignal(router.events.pipe(filter((e) => e instanceof NavigationEnd), takeUntilDestroyed(inject(DestroyRef))), { initialValue: null });
|
|
1814
2061
|
effect(() => {
|
|
@@ -1826,10 +2073,11 @@ class CngxStepperRouterSync {
|
|
|
1826
2073
|
}
|
|
1827
2074
|
/**
|
|
1828
2075
|
* Seed from the URL before the stepper renders its panels. `CngxStep`
|
|
1829
|
-
* registers in
|
|
1830
|
-
*
|
|
1831
|
-
*
|
|
1832
|
-
*
|
|
2076
|
+
* registers in `ngOnInit` (so a bound `[id]` reaches the registry), which
|
|
2077
|
+
* runs before the host's `ngAfterContentInit` - the registry is populated
|
|
2078
|
+
* by the time this runs, and the host view has not rendered yet, which is
|
|
2079
|
+
* what keeps a `panelMode="lazy"` default step from counting its first
|
|
2080
|
+
* render as a first activation on a deep link that named another step.
|
|
1833
2081
|
*
|
|
1834
2082
|
* Own router guard: the constructor's early return does not stop
|
|
1835
2083
|
* lifecycle hooks from running.
|
|
@@ -1855,8 +2103,41 @@ class CngxStepperRouterSync {
|
|
|
1855
2103
|
return;
|
|
1856
2104
|
}
|
|
1857
2105
|
this.seeded = true;
|
|
2106
|
+
// No explicit URL correction on a refused (linear-blocked / disabled)
|
|
2107
|
+
// seed: the activeStepId write effect's first run flushes AFTER this
|
|
2108
|
+
// content-init hook and unconditionally reflects the ACTUAL active id
|
|
2109
|
+
// into the URL, so a refused deep link is rewritten on the same tick.
|
|
2110
|
+
// The refused-seed spec pins that guarantee.
|
|
1858
2111
|
untracked(() => this.host.selectById(initial));
|
|
1859
2112
|
}
|
|
2113
|
+
/**
|
|
2114
|
+
* Reflect `id` into the URL. Fragment mode re-serializes the existing
|
|
2115
|
+
* fragment params so foreign state (`#foo=1&step=x`) survives the
|
|
2116
|
+
* write; values are URI-encoded symmetric to {@link parseFragment}.
|
|
2117
|
+
*/
|
|
2118
|
+
writeUrl(router, id) {
|
|
2119
|
+
const navigation = this.mode() === 'fragment'
|
|
2120
|
+
? router.navigate([], {
|
|
2121
|
+
fragment: this.serializeFragment(router, id),
|
|
2122
|
+
queryParamsHandling: 'merge',
|
|
2123
|
+
replaceUrl: true,
|
|
2124
|
+
})
|
|
2125
|
+
: router.navigate([], {
|
|
2126
|
+
queryParams: { [this.paramName()]: id },
|
|
2127
|
+
queryParamsHandling: 'merge',
|
|
2128
|
+
replaceUrl: true,
|
|
2129
|
+
});
|
|
2130
|
+
navigation.catch?.((err) => this.syncError.emit(err));
|
|
2131
|
+
}
|
|
2132
|
+
serializeFragment(router, id) {
|
|
2133
|
+
const param = this.paramName();
|
|
2134
|
+
const current = router.routerState.snapshot.root.fragment ?? '';
|
|
2135
|
+
const segments = current
|
|
2136
|
+
.split('&')
|
|
2137
|
+
.filter((seg) => seg !== '' && seg.split('=')[0] !== param);
|
|
2138
|
+
segments.push(`${param}=${encodeURIComponent(id)}`);
|
|
2139
|
+
return segments.join('&');
|
|
2140
|
+
}
|
|
1860
2141
|
readUrlValue(router) {
|
|
1861
2142
|
if (this.mode() === 'fragment') {
|
|
1862
2143
|
return this.parseFragment(router.routerState.snapshot.root.fragment ?? '');
|
|
@@ -1869,7 +2150,7 @@ class CngxStepperRouterSync {
|
|
|
1869
2150
|
for (const seg of segments) {
|
|
1870
2151
|
const [key, val] = seg.split('=');
|
|
1871
2152
|
if (key === param && val) {
|
|
1872
|
-
return val;
|
|
2153
|
+
return decodeURIComponent(val);
|
|
1873
2154
|
}
|
|
1874
2155
|
}
|
|
1875
2156
|
return null;
|
|
@@ -1886,103 +2167,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1886
2167
|
}]
|
|
1887
2168
|
}], 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"] }] } });
|
|
1888
2169
|
|
|
1889
|
-
/** @internal */
|
|
1890
|
-
const STEPPER_I18N_DEFAULTS = {
|
|
1891
|
-
stepperLabel: 'Stepper',
|
|
1892
|
-
stepIndicatorRoleDescription: 'Step indicator',
|
|
1893
|
-
selectedStep: (label, position, count) => `Step ${position} of ${count}: ${label}`,
|
|
1894
|
-
stepCompleted: 'Completed',
|
|
1895
|
-
stepErrored: 'Has errors',
|
|
1896
|
-
stepHasErrors: (count) => `${count} error${count === 1 ? '' : 's'}`,
|
|
1897
|
-
previousStep: 'Previous step',
|
|
1898
|
-
nextStep: 'Next step',
|
|
1899
|
-
commitFailedRetry: 'Commit failed - retry?',
|
|
1900
|
-
commitInFlight: 'Committing step…',
|
|
1901
|
-
commitRolledBackTo: (originLabel) => `Reverted to step "${originLabel}".`,
|
|
1902
|
-
stepRolledBackSuffix: 'This step was rolled back.',
|
|
1903
|
-
statusLabels: {
|
|
1904
|
-
done: 'Done',
|
|
1905
|
-
inProgress: 'In progress',
|
|
1906
|
-
upNext: 'Up next',
|
|
1907
|
-
errored: 'Errored',
|
|
1908
|
-
},
|
|
1909
|
-
textStepperFormat: (current, total) => `Step ${current} of ${total}`,
|
|
1910
|
-
};
|
|
1911
|
-
/**
|
|
1912
|
-
* DI token for the resolved stepper i18n bundle. `providedIn: 'root'`
|
|
1913
|
-
* with English defaults.
|
|
1914
|
-
*
|
|
1915
|
-
* @category common/stepper/i18n
|
|
1916
|
-
* @wcag AA
|
|
1917
|
-
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/i18n/stepper-i18n.ts
|
|
1918
|
-
* @since 0.1.0
|
|
1919
|
-
*/
|
|
1920
|
-
const CNGX_STEPPER_I18N = new InjectionToken('CngxStepperI18n', {
|
|
1921
|
-
providedIn: 'root',
|
|
1922
|
-
factory: () => STEPPER_I18N_DEFAULTS,
|
|
1923
|
-
});
|
|
1924
|
-
/**
|
|
1925
|
-
* Brands an i18n mutator with `_target: 'i18n'`. Every `with*` i18n
|
|
1926
|
-
* feature returns one of these.
|
|
1927
|
-
*
|
|
1928
|
-
* @internal
|
|
1929
|
-
*/
|
|
1930
|
-
function defineStepperI18nFeature(fn) {
|
|
1931
|
-
return Object.assign(fn, { _target: 'i18n' });
|
|
1932
|
-
}
|
|
1933
|
-
/**
|
|
1934
|
-
* Override stepper i18n labels. Partial override - unset keys keep
|
|
1935
|
-
* the English default. {@link CngxStepperStatusLabels} is merged
|
|
1936
|
-
* key-by-key so consumers can override one pill label without
|
|
1937
|
-
* restating the rest. Sibling of `withStepperAriaLabels` /
|
|
1938
|
-
* `withStepperFallbackLabels`.
|
|
1939
|
-
*
|
|
1940
|
-
* @category common/stepper/i18n
|
|
1941
|
-
*/
|
|
1942
|
-
function withStepperI18nLabels(overrides) {
|
|
1943
|
-
return defineStepperI18nFeature((bundle) => ({
|
|
1944
|
-
...bundle,
|
|
1945
|
-
...overrides,
|
|
1946
|
-
statusLabels: overrides.statusLabels
|
|
1947
|
-
? { ...bundle.statusLabels, ...overrides.statusLabels }
|
|
1948
|
-
: bundle.statusLabels,
|
|
1949
|
-
}));
|
|
1950
|
-
}
|
|
1951
|
-
/** @internal */
|
|
1952
|
-
function resolveI18nFeatures(features) {
|
|
1953
|
-
return features.reduce((bundle, feat) => feat(bundle), STEPPER_I18N_DEFAULTS);
|
|
1954
|
-
}
|
|
1955
|
-
/**
|
|
1956
|
-
* Provider for the stepper i18n bundle. Compose `withStepperI18nLabels(...)`
|
|
1957
|
-
* (plus any future i18n `with*`) - unset keys fall back to English.
|
|
1958
|
-
*
|
|
1959
|
-
* ```ts
|
|
1960
|
-
* bootstrapApplication(AppComponent, {
|
|
1961
|
-
* providers: [
|
|
1962
|
-
* provideStepperI18n(
|
|
1963
|
-
* withStepperI18nLabels({ stepperLabel: 'Schrittfolge', previousStep: 'Vorheriger' }),
|
|
1964
|
-
* ),
|
|
1965
|
-
* ],
|
|
1966
|
-
* });
|
|
1967
|
-
* ```
|
|
1968
|
-
*
|
|
1969
|
-
* @category common/stepper/i18n
|
|
1970
|
-
*/
|
|
1971
|
-
function provideStepperI18n(...features) {
|
|
1972
|
-
return {
|
|
1973
|
-
provide: CNGX_STEPPER_I18N,
|
|
1974
|
-
useValue: resolveI18nFeatures(features),
|
|
1975
|
-
};
|
|
1976
|
-
}
|
|
1977
|
-
/**
|
|
1978
|
-
* Inject the resolved stepper i18n bundle in an injection context.
|
|
1979
|
-
*
|
|
1980
|
-
* @category common/stepper/i18n
|
|
1981
|
-
*/
|
|
1982
|
-
function injectStepperI18n() {
|
|
1983
|
-
return inject(CNGX_STEPPER_I18N);
|
|
1984
|
-
}
|
|
1985
|
-
|
|
1986
2170
|
/**
|
|
1987
2171
|
* Resolve the status-pill label for a step node against the resolved
|
|
1988
2172
|
* i18n bundle. Used by skins that surface a per-step status pill
|
|
@@ -2015,31 +2199,45 @@ function resolveStepperStatusLabel(node, i18n, isActive) {
|
|
|
2015
2199
|
}
|
|
2016
2200
|
|
|
2017
2201
|
/**
|
|
2018
|
-
*
|
|
2019
|
-
*
|
|
2020
|
-
*
|
|
2202
|
+
* Reads the stepper's collapse flag off its own container.
|
|
2203
|
+
*
|
|
2204
|
+
* The threshold is a `@container` rule in `stepper-base.css` writing
|
|
2205
|
+
* `--cngx-stepper-collapse` onto `.cngx-stepper::after`. It lands on the
|
|
2206
|
+
* pseudo-element because a container query cannot style its own container,
|
|
2207
|
+
* and the query container for a pseudo-element is selected from its
|
|
2208
|
+
* originating element's inclusive ancestors. Nothing here parses a width, so
|
|
2209
|
+
* a consumer re-aims the collapse with a plain CSS rule.
|
|
2021
2210
|
*
|
|
2022
|
-
*
|
|
2023
|
-
*
|
|
2024
|
-
* from
|
|
2211
|
+
* Requires an injection context - it observes through `injectContainerSize`,
|
|
2212
|
+
* so the observer is scoped to the caller's `DestroyRef`. A field initialiser
|
|
2213
|
+
* on the stepper component is one; a bare call from a lifecycle hook is not.
|
|
2025
2214
|
*
|
|
2215
|
+
* @param host The `<cngx-stepper>` host element, which is its own container.
|
|
2026
2216
|
* @category common/stepper
|
|
2217
|
+
* @relatedTo createStepperDisplayMode, injectContainerSize
|
|
2027
2218
|
*/
|
|
2028
|
-
function
|
|
2029
|
-
|
|
2219
|
+
function injectStepperCollapse(host) {
|
|
2220
|
+
const raw = injectContainerSize(host).property('--cngx-stepper-collapse', host, '::after');
|
|
2221
|
+
return computed(() => raw() === '1');
|
|
2030
2222
|
}
|
|
2031
2223
|
/**
|
|
2032
|
-
* Resolves the active stepper display mode by combining
|
|
2033
|
-
*
|
|
2034
|
-
* `'classic'` keeps the full strip; `'text'` /
|
|
2035
|
-
* matching compact variant
|
|
2224
|
+
* Resolves the active stepper display mode by combining the collapse *signal*
|
|
2225
|
+
* - whether the stepper's own container is narrow - with the configured
|
|
2226
|
+
* `mobileCollapse` policy. `'classic'` keeps the full strip; `'text'` /
|
|
2227
|
+
* `'dots'` swap to the matching compact variant, `'off'` stays classic at any
|
|
2228
|
+
* width.
|
|
2229
|
+
*
|
|
2230
|
+
* The factory takes no DOM API and holds no threshold: *where* the collapse
|
|
2231
|
+
* happens is a `@container` rule in the stepper stylesheet, *what* it collapses
|
|
2232
|
+
* into is this policy. See `core-concepts/responsive-by-default.md`.
|
|
2036
2233
|
*
|
|
2234
|
+
* @param collapsed `true` while the container sits below the collapse rung.
|
|
2235
|
+
* @param mobileCollapse The configured collapse policy, read lazily.
|
|
2037
2236
|
* @category common/stepper
|
|
2038
2237
|
*/
|
|
2039
|
-
function createStepperDisplayMode(
|
|
2040
|
-
const viewport = createMobileViewportSignal(mediaQuery, destroyRef);
|
|
2238
|
+
function createStepperDisplayMode(collapsed, mobileCollapse) {
|
|
2041
2239
|
return computed(() => {
|
|
2042
|
-
if (!
|
|
2240
|
+
if (!collapsed()) {
|
|
2043
2241
|
return 'classic';
|
|
2044
2242
|
}
|
|
2045
2243
|
const mode = mobileCollapse() ?? 'text';
|
|
@@ -2047,63 +2245,6 @@ function createStepperDisplayMode(mediaQuery, mobileCollapse, destroyRef) {
|
|
|
2047
2245
|
});
|
|
2048
2246
|
}
|
|
2049
2247
|
|
|
2050
|
-
/**
|
|
2051
|
-
* Tracks an element's content-box width as a reactive signal via the
|
|
2052
|
-
* `ResizeObserver` API. Mirrors `createMobileViewportSignal`'s
|
|
2053
|
-
* `matchMedia` wrapper: the API is wrapped directly (not via the
|
|
2054
|
-
* `CngxResizeObserver` directive, which can only attach through
|
|
2055
|
-
* `hostDirectives`). In SSR / non-DOM environments the signal stays
|
|
2056
|
-
* `0` and no observer is wired.
|
|
2057
|
-
*/
|
|
2058
|
-
function createElementWidthSignal(element, destroyRef) {
|
|
2059
|
-
const width = signal(0, ...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
|
|
2060
|
-
if (typeof ResizeObserver !== 'function') {
|
|
2061
|
-
return width.asReadonly();
|
|
2062
|
-
}
|
|
2063
|
-
const observer = new ResizeObserver((entries) => {
|
|
2064
|
-
width.set(entries[0]?.contentRect.width ?? 0);
|
|
2065
|
-
});
|
|
2066
|
-
observer.observe(element);
|
|
2067
|
-
destroyRef.onDestroy(() => observer.disconnect());
|
|
2068
|
-
return width.asReadonly();
|
|
2069
|
-
}
|
|
2070
|
-
/**
|
|
2071
|
-
* Resolves the classic strip's density rung from its own container
|
|
2072
|
-
* width against the step count and two per-step px thresholds. Pure
|
|
2073
|
-
* `create*` factory, sibling to `createStepperDisplayMode` - it owns a
|
|
2074
|
-
* `ResizeObserver` the way the display-mode factory owns a
|
|
2075
|
-
* `matchMedia` listener, and returns a single derived `Signal`.
|
|
2076
|
-
*
|
|
2077
|
-
* `'comfortable'` density short-circuits to `'full'` (no measurement
|
|
2078
|
-
* dependency). Before the first measurement (`width === 0`) and for an
|
|
2079
|
-
* empty strip the rung is `'full'`, so the strip never flashes
|
|
2080
|
-
* `'minimal'` on mount.
|
|
2081
|
-
*
|
|
2082
|
-
* @category common/stepper
|
|
2083
|
-
*/
|
|
2084
|
-
function createStripDensity(options) {
|
|
2085
|
-
const width = createElementWidthSignal(options.element, options.destroyRef);
|
|
2086
|
-
return computed(() => {
|
|
2087
|
-
if ((options.density() ?? 'comfortable') !== 'auto') {
|
|
2088
|
-
return 'full';
|
|
2089
|
-
}
|
|
2090
|
-
const count = options.stepCount();
|
|
2091
|
-
const measured = width();
|
|
2092
|
-
if (count === 0 || measured === 0) {
|
|
2093
|
-
return 'full';
|
|
2094
|
-
}
|
|
2095
|
-
const perStep = measured / count;
|
|
2096
|
-
const { compact, minimal } = options.breakpoints();
|
|
2097
|
-
if (perStep >= compact) {
|
|
2098
|
-
return 'full';
|
|
2099
|
-
}
|
|
2100
|
-
if (perStep >= minimal) {
|
|
2101
|
-
return 'compact';
|
|
2102
|
-
}
|
|
2103
|
-
return 'minimal';
|
|
2104
|
-
});
|
|
2105
|
-
}
|
|
2106
|
-
|
|
2107
2248
|
/** Terminal-step totals for a group's subtree; reads each step `state()`. */
|
|
2108
2249
|
function subtreeStats(node) {
|
|
2109
2250
|
let total = 0;
|
|
@@ -2124,8 +2265,8 @@ function subtreeStats(node) {
|
|
|
2124
2265
|
* Builds the collapsed-group summary view. Level-2 helper so the
|
|
2125
2266
|
* organism stays a thin renderer. `status` mode defers its SR phrasing
|
|
2126
2267
|
* to the group's existing status-phrase span, so {@link srText} returns
|
|
2127
|
-
* `null` there.
|
|
2128
|
-
*
|
|
2268
|
+
* `null` there. SR phrases resolve through the `CngxStepperI18n` bundle
|
|
2269
|
+
* when passed; English defaults otherwise.
|
|
2129
2270
|
*
|
|
2130
2271
|
* @category common/stepper
|
|
2131
2272
|
*/
|
|
@@ -2137,7 +2278,10 @@ function createStepperGroupSummary(options) {
|
|
|
2137
2278
|
return null;
|
|
2138
2279
|
}
|
|
2139
2280
|
const { total, completed } = subtreeStats(node);
|
|
2140
|
-
|
|
2281
|
+
const i18n = options.i18n();
|
|
2282
|
+
return current === 'count'
|
|
2283
|
+
? i18n.groupSummaryCountShort(total)
|
|
2284
|
+
: i18n.groupSummaryProgressShort(completed, total);
|
|
2141
2285
|
};
|
|
2142
2286
|
const showStatus = (node) => mode() === 'status' && options.isCollapsed(node);
|
|
2143
2287
|
const srText = (node) => {
|
|
@@ -2146,7 +2290,10 @@ function createStepperGroupSummary(options) {
|
|
|
2146
2290
|
return null;
|
|
2147
2291
|
}
|
|
2148
2292
|
const { total, completed } = subtreeStats(node);
|
|
2149
|
-
|
|
2293
|
+
if (current === 'count') {
|
|
2294
|
+
return options.i18n().groupSummaryCount(total);
|
|
2295
|
+
}
|
|
2296
|
+
return options.i18n().groupSummaryProgress(completed, total);
|
|
2150
2297
|
};
|
|
2151
2298
|
return { mode, text, showStatus, srText };
|
|
2152
2299
|
}
|
|
@@ -2220,6 +2367,25 @@ function createStepperHostAttrs(inputs) {
|
|
|
2220
2367
|
resolvedMobileIndicatorPosition: computed(() => inputs.mobileIndicatorPosition() ?? inputs.config.mobileIndicatorPosition ?? 'top'),
|
|
2221
2368
|
};
|
|
2222
2369
|
}
|
|
2370
|
+
/**
|
|
2371
|
+
* Shared `aria-label` cascade for every stepper organism host
|
|
2372
|
+
* (`<cngx-stepper>` and the compact variants): a bound
|
|
2373
|
+
* `aria-labelledby` trumps and nulls the label out; otherwise the
|
|
2374
|
+
* per-instance input wins over `ariaLabels.stepperRegion` wins over
|
|
2375
|
+
* `i18n.stepperLabel`. One source so the variants cannot drift from
|
|
2376
|
+
* the parent's naming behaviour.
|
|
2377
|
+
*
|
|
2378
|
+
* @internal
|
|
2379
|
+
*/
|
|
2380
|
+
function createStepperAccname(inputs) {
|
|
2381
|
+
const ariaLabels = coerceSignal(inputs.config.ariaLabels);
|
|
2382
|
+
return computed(() => {
|
|
2383
|
+
if (inputs.ariaLabelledBy()) {
|
|
2384
|
+
return null; // labelledby trumps label
|
|
2385
|
+
}
|
|
2386
|
+
return inputs.ariaLabel() ?? ariaLabels()?.stepperRegion ?? inputs.i18n().stepperLabel;
|
|
2387
|
+
});
|
|
2388
|
+
}
|
|
2223
2389
|
|
|
2224
2390
|
/**
|
|
2225
2391
|
* Builds the WAI-ARIA APG arrow-key handler for a stepper strip. The
|
|
@@ -2250,11 +2416,22 @@ function createStepperStripKeyboardNav(options) {
|
|
|
2250
2416
|
}
|
|
2251
2417
|
};
|
|
2252
2418
|
const focusActive = () => {
|
|
2253
|
-
|
|
2254
|
-
|
|
2419
|
+
// Focus the INTENDED target only while the commit is actually in
|
|
2420
|
+
// flight (pessimistic mode holds activeStepId at the origin until
|
|
2421
|
+
// the action settles). The controller retains intendedValue after a
|
|
2422
|
+
// rejection for the commit-error surface, so an unguarded read
|
|
2423
|
+
// would teleport focus to the refused step on any later no-op key.
|
|
2424
|
+
const intendedIdx = options.presenter.busy()
|
|
2425
|
+
? options.presenter.intendedStepIndex()
|
|
2426
|
+
: undefined;
|
|
2427
|
+
const intendedId = intendedIdx !== undefined
|
|
2428
|
+
? (options.presenter.stepsOnly()[intendedIdx]?.id ?? null)
|
|
2429
|
+
: null;
|
|
2430
|
+
const targetId = intendedId ?? options.presenter.activeStepId();
|
|
2431
|
+
if (!targetId) {
|
|
2255
2432
|
return;
|
|
2256
2433
|
}
|
|
2257
|
-
const buttonId = options.stepButtonIdFor(
|
|
2434
|
+
const buttonId = options.stepButtonIdFor(targetId);
|
|
2258
2435
|
scheduleFocus(() => {
|
|
2259
2436
|
const el = options.hostElement.querySelector(`[id="${buttonId}"]`);
|
|
2260
2437
|
if (el instanceof HTMLElement) {
|
|
@@ -2283,18 +2460,38 @@ function createStepperStripKeyboardNav(options) {
|
|
|
2283
2460
|
}
|
|
2284
2461
|
else if (isPrev) {
|
|
2285
2462
|
event.preventDefault();
|
|
2463
|
+
// A stray back-arrow must not supersede an in-flight commit - the
|
|
2464
|
+
// programmatic selectPrevious() cancels deliberately; the gesture
|
|
2465
|
+
// path waits.
|
|
2466
|
+
if (options.presenter.busy()) {
|
|
2467
|
+
return;
|
|
2468
|
+
}
|
|
2286
2469
|
options.presenter.selectPrevious();
|
|
2287
2470
|
focusActive();
|
|
2288
2471
|
}
|
|
2289
2472
|
else if (event.key === 'Home') {
|
|
2290
2473
|
event.preventDefault();
|
|
2291
|
-
options.presenter.
|
|
2292
|
-
|
|
2474
|
+
const stepsOnly = options.presenter.stepsOnly();
|
|
2475
|
+
const first = resolveBoundaryStep(1, {
|
|
2476
|
+
count: stepsOnly.length,
|
|
2477
|
+
isDisabledAt: (i) => stepsOnly[i].disabled(),
|
|
2478
|
+
});
|
|
2479
|
+
if (first !== null) {
|
|
2480
|
+
options.presenter.select(first);
|
|
2481
|
+
focusActive();
|
|
2482
|
+
}
|
|
2293
2483
|
}
|
|
2294
2484
|
else if (event.key === 'End') {
|
|
2295
2485
|
event.preventDefault();
|
|
2296
|
-
options.presenter.
|
|
2297
|
-
|
|
2486
|
+
const stepsOnly = options.presenter.stepsOnly();
|
|
2487
|
+
const last = resolveBoundaryStep(-1, {
|
|
2488
|
+
count: stepsOnly.length,
|
|
2489
|
+
isDisabledAt: (i) => stepsOnly[i].disabled(),
|
|
2490
|
+
});
|
|
2491
|
+
if (last !== null) {
|
|
2492
|
+
options.presenter.select(last);
|
|
2493
|
+
focusActive();
|
|
2494
|
+
}
|
|
2298
2495
|
}
|
|
2299
2496
|
};
|
|
2300
2497
|
}
|
|
@@ -2324,57 +2521,106 @@ function createStepperStateView(inputs) {
|
|
|
2324
2521
|
}
|
|
2325
2522
|
return !!node.errorAggregator?.()?.shouldShow?.();
|
|
2326
2523
|
};
|
|
2327
|
-
const
|
|
2328
|
-
const
|
|
2524
|
+
const isRefused = (node) => isRejected(node) && presenter.lastOutcome()?.kind === 'refused';
|
|
2525
|
+
const rejectionReason = (node) => {
|
|
2526
|
+
if (!isRejected(node)) {
|
|
2527
|
+
return null;
|
|
2528
|
+
}
|
|
2529
|
+
return isRefused(node) ? 'refused' : 'failed';
|
|
2530
|
+
};
|
|
2531
|
+
const hasErrorMarker = (node) => hasErrorBadge(node) || isRejected(node);
|
|
2532
|
+
const hasError = (node) => hasErrorBadge(node) || (isRejected(node) && !isRefused(node));
|
|
2533
|
+
const erroredSteps = computed(() => stepsOnly().filter((node) => hasError(node)), { ...(ngDevMode ? { debugName: "erroredSteps" } : /* istanbul ignore next */ {}), equal: arrayEqual });
|
|
2329
2534
|
const errorCount = computed(() => erroredSteps().length, ...(ngDevMode ? [{ debugName: "errorCount" }] : /* istanbul ignore next */ []));
|
|
2330
2535
|
const firstErrorIndex = computed(() => erroredSteps()[0]?.flatIndex ?? -1, ...(ngDevMode ? [{ debugName: "firstErrorIndex" }] : /* istanbul ignore next */ []));
|
|
2331
2536
|
const hasAnyError = computed(() => errorCount() > 0, ...(ngDevMode ? [{ debugName: "hasAnyError" }] : /* istanbul ignore next */ []));
|
|
2537
|
+
const markedSteps = computed(() => stepsOnly().filter((node) => hasErrorMarker(node)), { ...(ngDevMode ? { debugName: "markedSteps" } : /* istanbul ignore next */ {}), equal: arrayEqual });
|
|
2538
|
+
const errorMarkerCount = computed(() => markedSteps().length, ...(ngDevMode ? [{ debugName: "errorMarkerCount" }] : /* istanbul ignore next */ []));
|
|
2539
|
+
const firstErrorMarkerIndex = computed(() => markedSteps()[0]?.flatIndex ?? -1, ...(ngDevMode ? [{ debugName: "firstErrorMarkerIndex" }] : /* istanbul ignore next */ []));
|
|
2540
|
+
const hasAnyErrorMarker = computed(() => errorMarkerCount() > 0, ...(ngDevMode ? [{ debugName: "hasAnyErrorMarker" }] : /* istanbul ignore next */ []));
|
|
2541
|
+
const refusalOnly = computed(() => hasAnyErrorMarker() && !hasAnyError(), ...(ngDevMode ? [{ debugName: "refusalOnly" }] : /* istanbul ignore next */ []));
|
|
2332
2542
|
return {
|
|
2333
2543
|
statusOf,
|
|
2334
2544
|
isBusy,
|
|
2335
2545
|
isRejected,
|
|
2546
|
+
isRefused,
|
|
2547
|
+
rejectionReason,
|
|
2336
2548
|
hasErrorBadge,
|
|
2549
|
+
hasErrorMarker,
|
|
2337
2550
|
hasError,
|
|
2338
2551
|
errorCount,
|
|
2339
2552
|
firstErrorIndex,
|
|
2340
2553
|
hasAnyError,
|
|
2554
|
+
errorMarkerCount,
|
|
2555
|
+
firstErrorMarkerIndex,
|
|
2556
|
+
hasAnyErrorMarker,
|
|
2557
|
+
refusalOnly,
|
|
2341
2558
|
};
|
|
2342
2559
|
}
|
|
2343
2560
|
/**
|
|
2344
2561
|
* Aggregate error phrase shared by the minimal skins (text / progress-bar)
|
|
2345
|
-
* and the classic mobile-collapse text branch.
|
|
2346
|
-
*
|
|
2347
|
-
*
|
|
2348
|
-
*
|
|
2562
|
+
* and the classic mobile-collapse text branch. Walks the marked steps
|
|
2563
|
+
* ({@link CngxStepperStateView.hasErrorMarker}). A single marked step names
|
|
2564
|
+
* itself with the word of its kind: `"Payment: Errored"` (or the custom
|
|
2565
|
+
* reason) for an error, `"Payment: Not allowed"` for a refused step change;
|
|
2566
|
+
* several failed steps collapse to the i18n count phrase (`"2 errors"`),
|
|
2567
|
+
* which never counts a refusal. Returns `''`
|
|
2568
|
+
* when no step is marked, so the error line stays quiet.
|
|
2349
2569
|
*
|
|
2350
2570
|
* The optional `messageOf` resolver lets callers surface a per-step
|
|
2351
2571
|
* reason (a direct `[error]` string or the first aggregator label) in the
|
|
2352
|
-
* single-error case instead of the generic `errored` status word.
|
|
2572
|
+
* single-error case instead of the generic `errored` status word. The
|
|
2573
|
+
* reason is still prefixed with the step label (`"Payment: Card declined"`),
|
|
2574
|
+
* because the summary line stays visible while another step is active and
|
|
2575
|
+
* a bare reason would read as belonging to the active step. When
|
|
2353
2576
|
* omitted - or when it returns `undefined`/`''` - the helper produces
|
|
2354
2577
|
* byte-identical output to the no-resolver form, so existing callers
|
|
2355
2578
|
* (the classic mobile-collapse summary) are a guaranteed no-op.
|
|
2356
2579
|
*
|
|
2357
2580
|
* Pure helper - reads signals at call time, intended to be wrapped in the
|
|
2358
|
-
* caller's `computed()`.
|
|
2581
|
+
* caller's `computed()`. The phrase feeds live regions, so the step label
|
|
2582
|
+
* is read untracked: a label that follows a language switch must not
|
|
2583
|
+
* re-announce the line. Pass the i18n bundle as an untracked snapshot for
|
|
2584
|
+
* the same reason.
|
|
2359
2585
|
*
|
|
2360
2586
|
* @category common/stepper
|
|
2361
2587
|
* @since 0.1.0
|
|
2362
2588
|
*/
|
|
2363
2589
|
function resolveStepperErrorSummary(view, stepsOnly, i18n, messageOf) {
|
|
2364
|
-
const count = view.
|
|
2590
|
+
const count = view.errorMarkerCount();
|
|
2365
2591
|
if (count === 0) {
|
|
2366
2592
|
return '';
|
|
2367
2593
|
}
|
|
2368
2594
|
if (count === 1) {
|
|
2369
|
-
|
|
2370
|
-
const custom = node ? messageOf?.(node) : undefined;
|
|
2371
|
-
if (custom !== undefined && custom !== '') {
|
|
2372
|
-
return custom;
|
|
2373
|
-
}
|
|
2374
|
-
const label = node?.label();
|
|
2375
|
-
return label ? `${label}: ${i18n.statusLabels.errored}` : i18n.statusLabels.errored;
|
|
2595
|
+
return singleStepPhrase(view, stepsOnly()[view.firstErrorMarkerIndex()], i18n, messageOf);
|
|
2376
2596
|
}
|
|
2377
|
-
|
|
2597
|
+
// A refusal is not an error: the count phrase counts failed steps only. One
|
|
2598
|
+
// error beside a refused step names that error; the refusal keeps its own
|
|
2599
|
+
// marker and announcement.
|
|
2600
|
+
const errors = view.errorCount();
|
|
2601
|
+
if (errors > 1) {
|
|
2602
|
+
return i18n.stepHasErrors(errors);
|
|
2603
|
+
}
|
|
2604
|
+
const index = errors === 1 ? view.firstErrorIndex() : view.firstErrorMarkerIndex();
|
|
2605
|
+
return singleStepPhrase(view, stepsOnly()[index], i18n, messageOf);
|
|
2606
|
+
}
|
|
2607
|
+
/** @internal `"<label>: <detail>"` for one marked step. */
|
|
2608
|
+
function singleStepPhrase(view, node, i18n, messageOf) {
|
|
2609
|
+
const detail = node ? summaryDetail(view, node, i18n, messageOf) : i18n.statusLabels.errored;
|
|
2610
|
+
const label = node ? untracked(node.label) : undefined;
|
|
2611
|
+
return label ? i18n.stepWithDetail(label, detail) : detail;
|
|
2612
|
+
}
|
|
2613
|
+
/**
|
|
2614
|
+
* @internal The word for one marked step: a validation error keeps its
|
|
2615
|
+
* reason, a refused-only step reads the refused word.
|
|
2616
|
+
*/
|
|
2617
|
+
function summaryDetail(view, node, i18n, messageOf) {
|
|
2618
|
+
const refusedOnly = view.isRefused(node) && !view.hasErrorBadge(node);
|
|
2619
|
+
if (refusedOnly) {
|
|
2620
|
+
return i18n.statusLabels.refused;
|
|
2621
|
+
}
|
|
2622
|
+
const custom = messageOf?.(node);
|
|
2623
|
+
return custom !== undefined && custom !== '' ? custom : i18n.statusLabels.errored;
|
|
2378
2624
|
}
|
|
2379
2625
|
|
|
2380
2626
|
/**
|
|
@@ -2466,7 +2712,8 @@ function createStepperSlotContextBuilders(inputs) {
|
|
|
2466
2712
|
const failedIndex = node.flatIndex;
|
|
2467
2713
|
const originIdx = presenter.originIndexDuringCommit();
|
|
2468
2714
|
const originLabel = originIdx !== undefined ? stepsOnly()[originIdx]?.label() : undefined;
|
|
2469
|
-
|
|
2715
|
+
const reason = stateView.isRefused(node) ? 'refused' : 'failed';
|
|
2716
|
+
return { failedIndex, originLabel, node, reason };
|
|
2470
2717
|
});
|
|
2471
2718
|
const stepErrorContextFor = memoizeByNode((node) => {
|
|
2472
2719
|
const aggregator = node.errorAggregator?.();
|
|
@@ -2475,12 +2722,12 @@ function createStepperSlotContextBuilders(inputs) {
|
|
|
2475
2722
|
// Resolution order: direct [error] string > first aggregator label >
|
|
2476
2723
|
// i18n errored status phrase. Always non-empty so a bare
|
|
2477
2724
|
// `{{ message }}` template renders a reason.
|
|
2478
|
-
const message = node.errorMessage?.() ?? errorLabels[0] ?? i18n.statusLabels.errored;
|
|
2725
|
+
const message = node.errorMessage?.() ?? errorLabels[0] ?? i18n().statusLabels.errored;
|
|
2479
2726
|
return { node, message, errorLabels, announcement };
|
|
2480
2727
|
});
|
|
2481
2728
|
const groupHeaderContextFor = memoizeByNode((node) => ({
|
|
2482
2729
|
group: node,
|
|
2483
|
-
expanded:
|
|
2730
|
+
expanded: !(inputs.isGroupCollapsed?.(node) ?? false),
|
|
2484
2731
|
status: node.state(),
|
|
2485
2732
|
}));
|
|
2486
2733
|
const stepLabelContextFor = memoizeByNode((node) => ({
|
|
@@ -2502,6 +2749,21 @@ function createStepperSlotContextBuilders(inputs) {
|
|
|
2502
2749
|
busy: isStepBusy(node),
|
|
2503
2750
|
disabled: node.disabled(),
|
|
2504
2751
|
}));
|
|
2752
|
+
// One pass per step-list change, so a dot reads its index in O(1)
|
|
2753
|
+
// instead of scanning the list on every change-detection pass.
|
|
2754
|
+
const stepIndexByNode = computed(() => new Map(stepsOnly().map((node, index) => [node, index])), ...(ngDevMode ? [{ debugName: "stepIndexByNode" }] : /* istanbul ignore next */ []));
|
|
2755
|
+
// Same fields as <cngx-dot-stepper>: index in the step-only projection,
|
|
2756
|
+
// completed = before the active step.
|
|
2757
|
+
const dotContextFor = memoizeByNode((node) => {
|
|
2758
|
+
const index = stepIndexByNode().get(node) ?? -1;
|
|
2759
|
+
return {
|
|
2760
|
+
$implicit: index,
|
|
2761
|
+
index,
|
|
2762
|
+
node,
|
|
2763
|
+
active: isActive(node),
|
|
2764
|
+
completed: index < presenter.activeStepIndex(),
|
|
2765
|
+
};
|
|
2766
|
+
});
|
|
2505
2767
|
return {
|
|
2506
2768
|
isActive,
|
|
2507
2769
|
isStepBusy,
|
|
@@ -2516,6 +2778,7 @@ function createStepperSlotContextBuilders(inputs) {
|
|
|
2516
2778
|
groupHeaderContextFor,
|
|
2517
2779
|
stepLabelContextFor,
|
|
2518
2780
|
stepContentContextFor,
|
|
2781
|
+
dotContextFor,
|
|
2519
2782
|
};
|
|
2520
2783
|
}
|
|
2521
2784
|
|
|
@@ -2527,29 +2790,78 @@ function createStepperSlotContextBuilders(inputs) {
|
|
|
2527
2790
|
* @internal
|
|
2528
2791
|
*/
|
|
2529
2792
|
function createStepperAnnouncementBuilders(inputs) {
|
|
2530
|
-
const { presenter, stepsOnly
|
|
2793
|
+
const { presenter, stepsOnly } = inputs;
|
|
2794
|
+
// A refusal leaves the commit status at 'idle', so no status edge can
|
|
2795
|
+
// voice it. The phrase arms on each new refused outcome (a new
|
|
2796
|
+
// sequence) and is spent by the next commit activity, a step move or a
|
|
2797
|
+
// cleared outcome (reset). Arm wins over spend in the same flush, so an
|
|
2798
|
+
// optimistic rollback that moves the step still arms.
|
|
2799
|
+
const refusedPhrase = createRefusedPhrase({
|
|
2800
|
+
outcome: () => presenter.lastOutcome(),
|
|
2801
|
+
status: () => presenter.commitTransition.current(),
|
|
2802
|
+
activeIndex: () => presenter.activeStepIndex(),
|
|
2803
|
+
copy: refusedCopy,
|
|
2804
|
+
});
|
|
2805
|
+
function refusedCopy() {
|
|
2806
|
+
const originIdx = presenter.originIndexDuringCommit();
|
|
2807
|
+
const origin = originIdx !== undefined ? stepsOnly()[originIdx] : undefined;
|
|
2808
|
+
const originLabel = origin?.label();
|
|
2809
|
+
const i18n = inputs.i18n();
|
|
2810
|
+
return originLabel ? i18n.commitRefused(originLabel) : i18n.commitRefusedGeneric;
|
|
2811
|
+
}
|
|
2812
|
+
// The live region reads copy untracked: a language switch must not
|
|
2813
|
+
// re-speak the last phrase. The next commit transition speaks the new
|
|
2814
|
+
// language.
|
|
2531
2815
|
const liveAnnouncement = computed(() => {
|
|
2816
|
+
// Read the refused phrase EAGERLY: linkedSignal only observes the
|
|
2817
|
+
// snapshots it is read under, so a read behind the pending arm would
|
|
2818
|
+
// miss the status change that spends it.
|
|
2819
|
+
const refused = refusedPhrase();
|
|
2820
|
+
if (refused) {
|
|
2821
|
+
return refused;
|
|
2822
|
+
}
|
|
2532
2823
|
const current = presenter.commitTransition.current();
|
|
2533
2824
|
if (current === 'pending') {
|
|
2534
|
-
return i18n.commitInFlight;
|
|
2825
|
+
return untracked(() => inputs.i18n().commitInFlight);
|
|
2826
|
+
}
|
|
2827
|
+
if (current === 'success' &&
|
|
2828
|
+
presenter.commitTransition.previous() === 'pending' &&
|
|
2829
|
+
(presenter.commitMode?.() ?? 'pessimistic') === 'pessimistic') {
|
|
2830
|
+
// Announce where the commit landed - without this arm a pessimistic
|
|
2831
|
+
// accept moves the step silently (the pending phrase just goes quiet).
|
|
2832
|
+
// Pessimistic only: an optimistic accept already moved (and thereby
|
|
2833
|
+
// announced) the step at dispatch - repeating it here would
|
|
2834
|
+
// double-announce a position the SR user already reached.
|
|
2835
|
+
const landed = presenter.stepsOnly()[presenter.activeStepIndex()];
|
|
2836
|
+
if (landed) {
|
|
2837
|
+
// A step label can itself derive from copy (the Material bridge's
|
|
2838
|
+
// `Step <id>` fallback), so it is read untracked too.
|
|
2839
|
+
const label = untracked(landed.label);
|
|
2840
|
+
const count = presenter.stepsOnly().length;
|
|
2841
|
+
return untracked(() => inputs.i18n().selectedStep(label, landed.flatIndex + 1, count));
|
|
2842
|
+
}
|
|
2843
|
+
return '';
|
|
2535
2844
|
}
|
|
2536
2845
|
if (current === 'error') {
|
|
2537
|
-
// Sync commit-handler
|
|
2538
|
-
// flush; tracker sees `previous === 'idle'`. Guard stays loose so
|
|
2539
|
-
//
|
|
2846
|
+
// Sync commit-handler failures collapse pending -> error in one signal
|
|
2847
|
+
// flush; tracker sees `previous === 'idle'`. Guard stays loose so a
|
|
2848
|
+
// synchronously throwing `commitAction` still announces. A `false`
|
|
2849
|
+
// answer never reaches this arm: it settles to 'idle' as a refusal.
|
|
2540
2850
|
const failedIdx = presenter.lastFailedIndex();
|
|
2541
2851
|
const originIdx = presenter.originIndexDuringCommit();
|
|
2542
2852
|
if (failedIdx !== undefined && originIdx !== undefined) {
|
|
2543
|
-
const
|
|
2853
|
+
const origin = stepsOnly()[originIdx];
|
|
2854
|
+
const originLabel = origin ? untracked(origin.label) : undefined;
|
|
2544
2855
|
if (originLabel) {
|
|
2545
|
-
return i18n.commitRolledBackTo(originLabel);
|
|
2856
|
+
return untracked(() => inputs.i18n().commitRolledBackTo(originLabel));
|
|
2546
2857
|
}
|
|
2547
2858
|
}
|
|
2548
|
-
return i18n.commitFailedRetry;
|
|
2859
|
+
return untracked(() => inputs.i18n().commitFailedRetry);
|
|
2549
2860
|
}
|
|
2550
2861
|
return '';
|
|
2551
2862
|
}, ...(ngDevMode ? [{ debugName: "liveAnnouncement" }] : /* istanbul ignore next */ []));
|
|
2552
2863
|
const statusPhrase = (node) => {
|
|
2864
|
+
const i18n = inputs.i18n();
|
|
2553
2865
|
const aggregator = node.errorAggregator?.();
|
|
2554
2866
|
let base = aggregator?.shouldShow?.() ? (aggregator.announcement?.() ?? '') : '';
|
|
2555
2867
|
if (!base && node.kind === 'step') {
|
|
@@ -2561,26 +2873,90 @@ function createStepperAnnouncementBuilders(inputs) {
|
|
|
2561
2873
|
if (!base) {
|
|
2562
2874
|
return '';
|
|
2563
2875
|
}
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2876
|
+
if (node.kind !== 'step' || node.flatIndex !== presenter.lastFailedIndex()) {
|
|
2877
|
+
return base;
|
|
2878
|
+
}
|
|
2879
|
+
return presenter.lastOutcome()?.kind === 'refused'
|
|
2880
|
+
? i18n.stepRefused(base)
|
|
2881
|
+
: i18n.stepRolledBack(base);
|
|
2567
2882
|
};
|
|
2883
|
+
// Converged on `statusLabels` - the same phrase map the status pill
|
|
2884
|
+
// (resolveStepperStatusLabel) renders, so a group's SR description can
|
|
2885
|
+
// never disagree with its visible pill.
|
|
2568
2886
|
const groupStatusPhrase = (node) => {
|
|
2887
|
+
const i18n = inputs.i18n();
|
|
2569
2888
|
const status = node.state();
|
|
2570
2889
|
if (status === 'error') {
|
|
2571
|
-
return i18n.
|
|
2890
|
+
return i18n.statusLabels.errored;
|
|
2572
2891
|
}
|
|
2573
2892
|
if (status === 'success') {
|
|
2574
|
-
return i18n.
|
|
2893
|
+
return i18n.statusLabels.done;
|
|
2575
2894
|
}
|
|
2576
2895
|
return '';
|
|
2577
2896
|
};
|
|
2897
|
+
const headerStatusPhrase = (node) => {
|
|
2898
|
+
const phrase = statusPhrase(node);
|
|
2899
|
+
const status = glyphStatus(node, inputs.i18n());
|
|
2900
|
+
if (!status) {
|
|
2901
|
+
return phrase;
|
|
2902
|
+
}
|
|
2903
|
+
return phrase ? inputs.i18n().stepWithDetail(phrase, status) : status;
|
|
2904
|
+
};
|
|
2578
2905
|
const descriptorId = (node) => `${node.id}-desc`;
|
|
2579
2906
|
const describedBy = (node) => {
|
|
2580
|
-
const phrase = node.kind === 'step' ?
|
|
2907
|
+
const phrase = node.kind === 'step' ? headerStatusPhrase(node) : groupStatusPhrase(node);
|
|
2581
2908
|
return phrase ? descriptorId(node) : null;
|
|
2582
2909
|
};
|
|
2583
|
-
return {
|
|
2910
|
+
return {
|
|
2911
|
+
liveAnnouncement,
|
|
2912
|
+
statusPhrase,
|
|
2913
|
+
headerStatusPhrase,
|
|
2914
|
+
groupStatusPhrase,
|
|
2915
|
+
descriptorId,
|
|
2916
|
+
describedBy,
|
|
2917
|
+
};
|
|
2918
|
+
}
|
|
2919
|
+
/** The status word behind a skin's done / errored glyph, or `''`. */
|
|
2920
|
+
function glyphStatus(node, i18n) {
|
|
2921
|
+
const state = node.state();
|
|
2922
|
+
if (state === 'error') {
|
|
2923
|
+
return i18n.statusLabels.errored;
|
|
2924
|
+
}
|
|
2925
|
+
return state === 'success' ? i18n.statusLabels.done : '';
|
|
2926
|
+
}
|
|
2927
|
+
/**
|
|
2928
|
+
* Build the mode-aware panel ref surface. The dots branch always
|
|
2929
|
+
* renders one dot per step; the classic strip only renders headers the
|
|
2930
|
+
* group-collapse policy exposes; the text branch has no header element
|
|
2931
|
+
* at all. A panel must never reference an id that is not in the DOM -
|
|
2932
|
+
* a dangling IDREF names the region as empty - so header-less panels
|
|
2933
|
+
* self-name via `aria-label` and drop the describedby reference (the
|
|
2934
|
+
* classic descriptor spans live inside the strip headers; the
|
|
2935
|
+
* collapsed branches mount theirs inside the panel).
|
|
2936
|
+
*
|
|
2937
|
+
* @internal
|
|
2938
|
+
*/
|
|
2939
|
+
function createStepperPanelRefs(inputs) {
|
|
2940
|
+
const { displayMode, visibleStripNodes, headerIdFor, describedByFor } = inputs;
|
|
2941
|
+
const renderedHeaderIds = computed(() => new Set(visibleStripNodes().map((node) => node.id)), { ...(ngDevMode ? { debugName: "renderedHeaderIds" } : /* istanbul ignore next */ {}), equal: (a, b) => a.size === b.size && [...a].every((id) => b.has(id)) });
|
|
2942
|
+
const labelledBy = (node) => {
|
|
2943
|
+
const mode = displayMode();
|
|
2944
|
+
if (mode === 'text') {
|
|
2945
|
+
return null;
|
|
2946
|
+
}
|
|
2947
|
+
if (mode === 'dots') {
|
|
2948
|
+
return headerIdFor(node);
|
|
2949
|
+
}
|
|
2950
|
+
return renderedHeaderIds().has(node.id) ? headerIdFor(node) : null;
|
|
2951
|
+
};
|
|
2952
|
+
const ariaLabel = (node) => (labelledBy(node) ? null : node.label());
|
|
2953
|
+
const describedBy = (node) => {
|
|
2954
|
+
if (displayMode() === 'classic' && !renderedHeaderIds().has(node.id)) {
|
|
2955
|
+
return null;
|
|
2956
|
+
}
|
|
2957
|
+
return describedByFor(node);
|
|
2958
|
+
};
|
|
2959
|
+
return { labelledBy, ariaLabel, describedBy };
|
|
2584
2960
|
}
|
|
2585
2961
|
|
|
2586
2962
|
/**
|
|
@@ -2594,10 +2970,10 @@ function createStepperAnnouncementBuilders(inputs) {
|
|
|
2594
2970
|
* `CNGX_STEPPER_CONFIG.mobileSwipe` -> library default `true`.
|
|
2595
2971
|
*
|
|
2596
2972
|
* Direction routing is asymmetric, matching the presenter's existing
|
|
2597
|
-
* navigation surface: `left`
|
|
2598
|
-
*
|
|
2599
|
-
*
|
|
2600
|
-
*
|
|
2973
|
+
* navigation surface: the forward swipe (`left` under `ltr`, `right`
|
|
2974
|
+
* under `rtl`) -> `selectNext()` -> `select()` (linear gate + commit
|
|
2975
|
+
* window apply identically to a click); the back swipe ->
|
|
2976
|
+
* `selectPrevious()`, gated on `busy()` like the strip back-arrow.
|
|
2601
2977
|
*
|
|
2602
2978
|
* @category common/stepper
|
|
2603
2979
|
* @docsKind primary
|
|
@@ -2611,20 +2987,31 @@ class CngxStepperSwipeNav {
|
|
|
2611
2987
|
* defers to the config cascade.
|
|
2612
2988
|
*/
|
|
2613
2989
|
mobileSwipe = input(undefined, ...(ngDevMode ? [{ debugName: "mobileSwipe" }] : /* istanbul ignore next */ []));
|
|
2614
|
-
host =
|
|
2990
|
+
host = injectStepperHost('cngxStepperSwipeNav', { host: false });
|
|
2615
2991
|
config = injectStepperConfig();
|
|
2992
|
+
direction = injectDirection();
|
|
2616
2993
|
/** Resolved enabled flag (Input -> config -> default(true)). Boolean output, no `equal` fn required. */
|
|
2617
2994
|
swipeEnabled = computed(() => this.mobileSwipe() ?? this.config.mobileSwipe ?? true, ...(ngDevMode ? [{ debugName: "swipeEnabled" }] : /* istanbul ignore next */ []));
|
|
2618
2995
|
/**
|
|
2619
|
-
* Route a swipe direction into the presenter.
|
|
2620
|
-
*
|
|
2621
|
-
*
|
|
2996
|
+
* Route a swipe direction into the presenter. The inline mapping
|
|
2997
|
+
* resolves against the document direction like the keyboard path:
|
|
2998
|
+
* under `ltr` a left swipe advances; under `rtl` the roles flip.
|
|
2999
|
+
* Vertical directions are ignored. The back path waits while a
|
|
3000
|
+
* commit is in flight - a stray gesture must not supersede it (the
|
|
3001
|
+
* programmatic `selectPrevious()` cancels deliberately).
|
|
2622
3002
|
*/
|
|
2623
3003
|
handleSwipe(direction) {
|
|
2624
|
-
if (direction
|
|
3004
|
+
if (direction !== 'left' && direction !== 'right') {
|
|
3005
|
+
return;
|
|
3006
|
+
}
|
|
3007
|
+
const forward = direction === (this.direction() === 'rtl' ? 'right' : 'left');
|
|
3008
|
+
if (forward) {
|
|
2625
3009
|
this.host.selectNext();
|
|
2626
3010
|
}
|
|
2627
|
-
else
|
|
3011
|
+
else {
|
|
3012
|
+
if (this.host.busy()) {
|
|
3013
|
+
return;
|
|
3014
|
+
}
|
|
2628
3015
|
this.host.selectPrevious();
|
|
2629
3016
|
}
|
|
2630
3017
|
}
|
|
@@ -2639,6 +3026,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2639
3026
|
}]
|
|
2640
3027
|
}], propDecorators: { mobileSwipe: [{ type: i0.Input, args: [{ isSignal: true, alias: "mobileSwipe", required: false }] }] } });
|
|
2641
3028
|
|
|
3029
|
+
/**
|
|
3030
|
+
* Dev-warning for a stepper control (`[cngxStepperNext]`,
|
|
3031
|
+
* `[cngxStepperPrevious]`, `[cngxStepperComplete]`, `<cngx-stepper-count>`)
|
|
3032
|
+
* that has neither a bound `[host]` nor an ambient stepper presenter. Such a
|
|
3033
|
+
* control stays disabled or empty for good, so it warns once per instance
|
|
3034
|
+
* after the first render, when the `[host]` binding has settled. Call it from
|
|
3035
|
+
* an injection context.
|
|
3036
|
+
*
|
|
3037
|
+
* @internal
|
|
3038
|
+
*/
|
|
3039
|
+
function warnStepperControlUnhosted(selector, host) {
|
|
3040
|
+
if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
|
|
3041
|
+
return;
|
|
3042
|
+
}
|
|
3043
|
+
afterNextRender(() => {
|
|
3044
|
+
if (host()) {
|
|
3045
|
+
return;
|
|
3046
|
+
}
|
|
3047
|
+
cngxDevWarn('CNGX1056', `[${selector}] has no stepper. Place it inside a stepper, or bind [host] to the ` +
|
|
3048
|
+
`stepper's presenter when it sits outside.`);
|
|
3049
|
+
});
|
|
3050
|
+
}
|
|
3051
|
+
|
|
2642
3052
|
/**
|
|
2643
3053
|
* Reusable progress-hint atom for any stepper organism. Renders the
|
|
2644
3054
|
* resolved `CngxStepperI18n.textStepperFormat(current, total)` string
|
|
@@ -2674,7 +3084,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2674
3084
|
* <example-url>http://localhost:4200/#/ui/stepper/stepper-count/multi-instance-format-overrides</example-url>
|
|
2675
3085
|
*/
|
|
2676
3086
|
class CngxStepperCount {
|
|
2677
|
-
/**
|
|
3087
|
+
/**
|
|
3088
|
+
* When `true`, wraps the rendered string in an `aria-live="polite"` span.
|
|
3089
|
+
* Set it once per instance: toggling it swaps the span, and the region
|
|
3090
|
+
* content present at that moment is not announced.
|
|
3091
|
+
*/
|
|
2678
3092
|
live = input(true, ...(ngDevMode ? [{ debugName: "live" }] : /* istanbul ignore next */ []));
|
|
2679
3093
|
/**
|
|
2680
3094
|
* Per-instance format override. Receives `(current, total)` where
|
|
@@ -2697,26 +3111,67 @@ class CngxStepperCount {
|
|
|
2697
3111
|
injectedHost = inject(CNGX_STEPPER_HOST, { optional: true });
|
|
2698
3112
|
i18n = injectStepperI18n();
|
|
2699
3113
|
resolvedHost = computed(() => this.host() ?? this.injectedHost, ...(ngDevMode ? [{ debugName: "resolvedHost" }] : /* istanbul ignore next */ []));
|
|
2700
|
-
/**
|
|
2701
|
-
|
|
3114
|
+
/** 1-based active position and step total, or `null` while there is nothing to count. */
|
|
3115
|
+
position = computed(() => {
|
|
2702
3116
|
const host = this.resolvedHost();
|
|
2703
3117
|
if (!host) {
|
|
2704
|
-
return
|
|
3118
|
+
return null;
|
|
2705
3119
|
}
|
|
2706
|
-
const current = host.activeStepIndex() + 1;
|
|
2707
3120
|
const total = host.stepsOnly().length;
|
|
2708
|
-
|
|
2709
|
-
|
|
3121
|
+
if (total === 0) {
|
|
3122
|
+
return null;
|
|
3123
|
+
}
|
|
3124
|
+
// Clamp against the live total - a transiently out-of-range active
|
|
3125
|
+
// index (steps removed at runtime) must not render "Step 5 of 3".
|
|
3126
|
+
const current = Math.min(Math.max(host.activeStepIndex() + 1, 1), total);
|
|
3127
|
+
return { current, total };
|
|
3128
|
+
}, { ...(ngDevMode ? { debugName: "position" } : /* istanbul ignore next */ {}), equal: (a, b) => a?.current === b?.current && a?.total === b?.total });
|
|
3129
|
+
/** Resolved caption - reactive on activeStepIndex / stepsOnly / format / i18n. */
|
|
3130
|
+
label = computed(() => {
|
|
3131
|
+
const position = this.position();
|
|
3132
|
+
if (!position) {
|
|
3133
|
+
return '';
|
|
3134
|
+
}
|
|
3135
|
+
const fmt = this.format() ?? this.i18n().textStepperFormat;
|
|
3136
|
+
return fmt(position.current, position.total);
|
|
2710
3137
|
}, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
3138
|
+
/**
|
|
3139
|
+
* {@link label} for the live span: the bundle and a consumer `format`
|
|
3140
|
+
* (which may itself be language-dependent) are read untracked.
|
|
3141
|
+
*/
|
|
3142
|
+
liveLabel = computed(() => {
|
|
3143
|
+
const position = this.position();
|
|
3144
|
+
if (!position) {
|
|
3145
|
+
return '';
|
|
3146
|
+
}
|
|
3147
|
+
return untracked(() => (this.format() ?? this.i18n().textStepperFormat)(position.current, position.total));
|
|
3148
|
+
}, ...(ngDevMode ? [{ debugName: "liveLabel" }] : /* istanbul ignore next */ []));
|
|
3149
|
+
constructor() {
|
|
3150
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
3151
|
+
warnStepperControlUnhosted('cngx-stepper-count', this.resolvedHost);
|
|
3152
|
+
}
|
|
3153
|
+
}
|
|
2711
3154
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepperCount, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2712
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.
|
|
3155
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.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: `
|
|
3156
|
+
@if (live()) {
|
|
3157
|
+
<span aria-live="polite">{{ liveLabel() }}</span>
|
|
3158
|
+
} @else {
|
|
3159
|
+
<span>{{ label() }}</span>
|
|
3160
|
+
}
|
|
3161
|
+
`, isInline: true, styles: [".cngx-stepper-count span{unicode-bidi:var(--cngx-stepper-count-bidi, isolate);direction:var(--cngx-stepper-count-direction, inherit)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
2713
3162
|
}
|
|
2714
3163
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepperCount, decorators: [{
|
|
2715
3164
|
type: Component,
|
|
2716
|
-
args: [{ selector: 'cngx-stepper-count', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template:
|
|
3165
|
+
args: [{ selector: 'cngx-stepper-count', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: `
|
|
3166
|
+
@if (live()) {
|
|
3167
|
+
<span aria-live="polite">{{ liveLabel() }}</span>
|
|
3168
|
+
} @else {
|
|
3169
|
+
<span>{{ label() }}</span>
|
|
3170
|
+
}
|
|
3171
|
+
`, host: {
|
|
2717
3172
|
class: 'cngx-stepper-count',
|
|
2718
|
-
}, styles: [".cngx-stepper-count span{unicode-bidi:var(--cngx-stepper-count-bidi, isolate);direction:var(--cngx-stepper-count-direction,
|
|
2719
|
-
}], 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 }] }] } });
|
|
3173
|
+
}, styles: [".cngx-stepper-count span{unicode-bidi:var(--cngx-stepper-count-bidi, isolate);direction:var(--cngx-stepper-count-direction, inherit)}\n"] }]
|
|
3174
|
+
}], ctorParameters: () => [], 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 }] }] } });
|
|
2720
3175
|
|
|
2721
3176
|
/**
|
|
2722
3177
|
* Turns any clickable element into a stepper "Back" control. Resolves
|
|
@@ -2756,9 +3211,46 @@ class CngxStepperPrevious {
|
|
|
2756
3211
|
injectedHost = inject(CNGX_STEPPER_HOST, { optional: true });
|
|
2757
3212
|
resolvedHost = computed(() => this.host() ?? this.injectedHost, ...(ngDevMode ? [{ debugName: "resolvedHost" }] : /* istanbul ignore next */ []));
|
|
2758
3213
|
coPlacedAsyncClick = inject(CngxAsyncClick, { self: true, optional: true });
|
|
3214
|
+
elementRef = inject(ElementRef);
|
|
3215
|
+
i18n = injectStepperI18n();
|
|
2759
3216
|
constructor() {
|
|
2760
|
-
if (
|
|
2761
|
-
|
|
3217
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
3218
|
+
warnStepperControlUnhosted('cngxStepperPrevious', this.resolvedHost);
|
|
3219
|
+
}
|
|
3220
|
+
// Fallback accessible name for icon-only hosts: while the element
|
|
3221
|
+
// renders no text and the consumer supplied no label of their own,
|
|
3222
|
+
// the i18n `previousStep` phrase fills the gap. Re-checked after every
|
|
3223
|
+
// render (cheap string read) so a late-arriving visible label wins
|
|
3224
|
+
// again - a forced aria-label over visible text would break
|
|
3225
|
+
// label-in-name (WCAG 2.5.3). The data flag marks ownership so a
|
|
3226
|
+
// consumer-authored aria-label is never touched.
|
|
3227
|
+
afterEveryRender(() => {
|
|
3228
|
+
const el = this.elementRef.nativeElement;
|
|
3229
|
+
const ownsFallback = el.hasAttribute('data-cngx-label-fallback');
|
|
3230
|
+
const consumerLabelled = (!ownsFallback && el.hasAttribute('aria-label')) || el.hasAttribute('aria-labelledby');
|
|
3231
|
+
if (consumerLabelled) {
|
|
3232
|
+
return;
|
|
3233
|
+
}
|
|
3234
|
+
const hasText = (el.textContent ?? '').trim() !== '';
|
|
3235
|
+
if (hasText && ownsFallback) {
|
|
3236
|
+
el.removeAttribute('aria-label');
|
|
3237
|
+
el.removeAttribute('data-cngx-label-fallback');
|
|
3238
|
+
}
|
|
3239
|
+
else if (!hasText && !ownsFallback) {
|
|
3240
|
+
el.setAttribute('aria-label', this.i18n().previousStep);
|
|
3241
|
+
el.setAttribute('data-cngx-label-fallback', '');
|
|
3242
|
+
}
|
|
3243
|
+
});
|
|
3244
|
+
// A language switch re-labels a fallback this directive owns.
|
|
3245
|
+
afterRenderEffect(() => {
|
|
3246
|
+
const label = this.i18n().previousStep;
|
|
3247
|
+
const el = this.elementRef.nativeElement;
|
|
3248
|
+
if (el.hasAttribute('data-cngx-label-fallback')) {
|
|
3249
|
+
el.setAttribute('aria-label', label);
|
|
3250
|
+
}
|
|
3251
|
+
});
|
|
3252
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode && this.coPlacedAsyncClick) {
|
|
3253
|
+
cngxDevWarn('CNGX1038', '[cngxStepperPrevious] and [cngxAsyncClick] on the same element ' +
|
|
2762
3254
|
'both gate aria-disabled. Use one or the other.');
|
|
2763
3255
|
}
|
|
2764
3256
|
}
|
|
@@ -2833,15 +3325,52 @@ class CngxStepperNext {
|
|
|
2833
3325
|
injectedHost = inject(CNGX_STEPPER_HOST, { optional: true });
|
|
2834
3326
|
resolvedHost = computed(() => this.host() ?? this.injectedHost, ...(ngDevMode ? [{ debugName: "resolvedHost" }] : /* istanbul ignore next */ []));
|
|
2835
3327
|
coPlacedAsyncClick = inject(CngxAsyncClick, { self: true, optional: true });
|
|
3328
|
+
elementRef = inject(ElementRef);
|
|
3329
|
+
i18n = injectStepperI18n();
|
|
2836
3330
|
/** `true` when advancing is unavailable: no enabled next step or commit busy. */
|
|
2837
3331
|
disabled = computed(() => {
|
|
2838
3332
|
const host = this.resolvedHost();
|
|
2839
3333
|
return !host || !host.canGoNext() || host.busy();
|
|
2840
3334
|
}, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
2841
3335
|
constructor() {
|
|
2842
|
-
if (
|
|
2843
|
-
|
|
2844
|
-
|
|
3336
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
3337
|
+
warnStepperControlUnhosted('cngxStepperNext', this.resolvedHost);
|
|
3338
|
+
}
|
|
3339
|
+
// Fallback accessible name for icon-only hosts: while the element
|
|
3340
|
+
// renders no text and the consumer supplied no label of their own,
|
|
3341
|
+
// the i18n `nextStep` phrase fills the gap. Re-checked after every
|
|
3342
|
+
// render (cheap string read) so a late-arriving visible label wins
|
|
3343
|
+
// again - a forced aria-label over visible text would break
|
|
3344
|
+
// label-in-name (WCAG 2.5.3). The data flag marks ownership so a
|
|
3345
|
+
// consumer-authored aria-label is never touched.
|
|
3346
|
+
afterEveryRender(() => {
|
|
3347
|
+
const el = this.elementRef.nativeElement;
|
|
3348
|
+
const ownsFallback = el.hasAttribute('data-cngx-label-fallback');
|
|
3349
|
+
const consumerLabelled = (!ownsFallback && el.hasAttribute('aria-label')) || el.hasAttribute('aria-labelledby');
|
|
3350
|
+
if (consumerLabelled) {
|
|
3351
|
+
return;
|
|
3352
|
+
}
|
|
3353
|
+
const hasText = (el.textContent ?? '').trim() !== '';
|
|
3354
|
+
if (hasText && ownsFallback) {
|
|
3355
|
+
el.removeAttribute('aria-label');
|
|
3356
|
+
el.removeAttribute('data-cngx-label-fallback');
|
|
3357
|
+
}
|
|
3358
|
+
else if (!hasText && !ownsFallback) {
|
|
3359
|
+
el.setAttribute('aria-label', this.i18n().nextStep);
|
|
3360
|
+
el.setAttribute('data-cngx-label-fallback', '');
|
|
3361
|
+
}
|
|
3362
|
+
});
|
|
3363
|
+
// A language switch re-labels a fallback this directive owns.
|
|
3364
|
+
afterRenderEffect(() => {
|
|
3365
|
+
const label = this.i18n().nextStep;
|
|
3366
|
+
const el = this.elementRef.nativeElement;
|
|
3367
|
+
if (el.hasAttribute('data-cngx-label-fallback')) {
|
|
3368
|
+
el.setAttribute('aria-label', label);
|
|
3369
|
+
}
|
|
3370
|
+
});
|
|
3371
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode && this.coPlacedAsyncClick) {
|
|
3372
|
+
cngxDevWarn('CNGX1038', '[cngxStepperNext] and [cngxAsyncClick] on the same element ' +
|
|
3373
|
+
'both gate aria-disabled. Use one or the other.');
|
|
2845
3374
|
}
|
|
2846
3375
|
}
|
|
2847
3376
|
/** @internal */
|
|
@@ -2914,10 +3443,15 @@ class CngxStepperComplete {
|
|
|
2914
3443
|
/** `true` when the active step is the last one - the finish step. */
|
|
2915
3444
|
isActive = computed(() => this.resolvedHost()?.isLastStep() ?? false, ...(ngDevMode ? [{ debugName: "isActive" }] : /* istanbul ignore next */ []));
|
|
2916
3445
|
constructor() {
|
|
3446
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
3447
|
+
warnStepperControlUnhosted('cngxStepperComplete', this.resolvedHost);
|
|
3448
|
+
}
|
|
2917
3449
|
const tracker = createTransitionTracker(() => this.runner.status());
|
|
2918
3450
|
effect(() => {
|
|
2919
3451
|
if (tracker.current() === 'success' && tracker.previous() !== 'success') {
|
|
2920
|
-
|
|
3452
|
+
// Consumer handlers run outside the tracking context so their
|
|
3453
|
+
// ambient signal reads cannot widen this effect's dep graph.
|
|
3454
|
+
untracked(() => this.completed.emit());
|
|
2921
3455
|
}
|
|
2922
3456
|
});
|
|
2923
3457
|
}
|
|
@@ -2983,8 +3517,10 @@ function createStepperHostProxy(supplier) {
|
|
|
2983
3517
|
activeStepId: computed(() => supplier()?.activeStepId() ?? null),
|
|
2984
3518
|
activeGroupId: computed(() => supplier()?.activeGroupId() ?? null),
|
|
2985
3519
|
linear: computed(() => supplier()?.linear() ?? false),
|
|
3520
|
+
commitMode: computed(() => supplier()?.commitMode?.() ?? 'pessimistic'),
|
|
2986
3521
|
orientation: computed(() => supplier()?.orientation() ?? 'horizontal'),
|
|
2987
3522
|
intendedStepIndex: computed(() => supplier()?.intendedStepIndex()),
|
|
3523
|
+
lastOutcome: computed(() => supplier()?.lastOutcome()),
|
|
2988
3524
|
lastFailedIndex: computed(() => supplier()?.lastFailedIndex()),
|
|
2989
3525
|
originIndexDuringCommit: computed(() => supplier()?.originIndexDuringCommit()),
|
|
2990
3526
|
// Bounds + labels - the safety-critical canGo* pair collapses to
|
|
@@ -3026,7 +3562,7 @@ function createStepperHostProxy(supplier) {
|
|
|
3026
3562
|
}
|
|
3027
3563
|
|
|
3028
3564
|
/** @internal */
|
|
3029
|
-
function partitionFeatures(features) {
|
|
3565
|
+
function partitionFeatures(features, caller) {
|
|
3030
3566
|
const config = [];
|
|
3031
3567
|
const i18n = [];
|
|
3032
3568
|
for (const feat of features) {
|
|
@@ -3039,11 +3575,17 @@ function partitionFeatures(features) {
|
|
|
3039
3575
|
continue;
|
|
3040
3576
|
}
|
|
3041
3577
|
// Unbranded feature - drop + dev-warn (mirrors `provideCngxTabs`).
|
|
3042
|
-
if (
|
|
3043
|
-
|
|
3044
|
-
'
|
|
3045
|
-
|
|
3046
|
-
|
|
3578
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
3579
|
+
if (caller === 'provideCngxStepperAt') {
|
|
3580
|
+
cngxDevWarn('CNGX1041', 'provideCngxStepperAt(): dropped feature without a `_target` ' +
|
|
3581
|
+
'discriminator. Pass config through the `with*` helpers of @cngx/common/stepper ' +
|
|
3582
|
+
'and labels through `withStepperI18nLabels(...)`.');
|
|
3583
|
+
}
|
|
3584
|
+
else {
|
|
3585
|
+
cngxDevWarn('CNGX1041', 'provideCngxStepper(): dropped feature without a `_target` ' +
|
|
3586
|
+
'discriminator. Pass config through the `with*` helpers of @cngx/common/stepper ' +
|
|
3587
|
+
'and labels through `withStepperI18nLabels(...)`.');
|
|
3588
|
+
}
|
|
3047
3589
|
}
|
|
3048
3590
|
}
|
|
3049
3591
|
return { config, i18n };
|
|
@@ -3075,7 +3617,7 @@ function partitionFeatures(features) {
|
|
|
3075
3617
|
* @category common/stepper
|
|
3076
3618
|
*/
|
|
3077
3619
|
function provideCngxStepper(...features) {
|
|
3078
|
-
const { config, i18n } = partitionFeatures(features);
|
|
3620
|
+
const { config, i18n } = partitionFeatures(features, 'provideCngxStepper');
|
|
3079
3621
|
// `provideStepperConfig` returns EnvironmentProviders, `provideStepperI18n`
|
|
3080
3622
|
// returns Provider - `makeEnvironmentProviders` takes both.
|
|
3081
3623
|
return makeEnvironmentProviders([
|
|
@@ -3102,9 +3644,11 @@ function provideCngxStepper(...features) {
|
|
|
3102
3644
|
* @category common/stepper
|
|
3103
3645
|
*/
|
|
3104
3646
|
function provideCngxStepperAt(...features) {
|
|
3105
|
-
const { config, i18n } = partitionFeatures(features);
|
|
3647
|
+
const { config, i18n } = partitionFeatures(features, 'provideCngxStepperAt');
|
|
3106
3648
|
return [
|
|
3107
|
-
|
|
3649
|
+
// Gate like i18n: an i18n-only call must not plant an empty config
|
|
3650
|
+
// at this injector level and shadow an app-wide provideStepperConfig.
|
|
3651
|
+
...(config.length > 0 ? provideStepperConfigAt(...config) : []),
|
|
3108
3652
|
...(i18n.length > 0 ? [provideStepperI18n(...i18n)] : []),
|
|
3109
3653
|
];
|
|
3110
3654
|
}
|
|
@@ -3123,5 +3667,5 @@ function provideCngxStepperAt(...features) {
|
|
|
3123
3667
|
* Generated bundle index. Do not edit.
|
|
3124
3668
|
*/
|
|
3125
3669
|
|
|
3126
|
-
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,
|
|
3670
|
+
export { CNGX_STEPPER_COMMIT_HANDLER_FACTORY, CNGX_STEPPER_CONFIG, CNGX_STEPPER_GLYPHS, CNGX_STEPPER_HOST, CNGX_STEPPER_I18N, CNGX_STEPPER_LANGUAGE_EN, 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, createStepperAccname, createStepperAnnouncementBuilders, createStepperCommitHandler, createStepperDisplayMode, createStepperGroupNavigation, createStepperGroupSummary, createStepperHostAttrs, createStepperHostProxy, createStepperPanelRefs, createStepperSlotContextBuilders, createStepperStateView, createStepperStripKeyboardNav, createStepperTemplateBindings, flatStepsEqual, injectStepperCollapse, injectStepperConfig, injectStepperI18n, provideCngxStepper, provideCngxStepperAt, provideStepperConfig, provideStepperConfigAt, provideStepperI18n, resolveStepperErrorSummary, resolveStepperStatusLabel, withDotStepperDotTemplate, withStepBadgeTemplate, withStepBusySpinnerTemplate, withStepErrorTemplate, withStepGroupHeaderTemplate, withStepIndicatorTemplate, withStepRejectionTemplate, withStepperAriaLabels, withStepperCommitMode, withStepperConnectors, withStepperDefaultOrientation, withStepperDensity, withStepperEmptyTemplate, withStepperFallbackLabels, withStepperGroupCollapse, withStepperGroupCollapseSummary, withStepperHeaderNavigation, withStepperI18nLabels, withStepperLinear, withStepperMobileCollapse, withStepperMobileIndicatorPosition, withStepperMobileSwipe, withStepperRouterSync, withStepperSkin };
|
|
3127
3671
|
//# sourceMappingURL=cngx-common-stepper.mjs.map
|