@cngx/common 0.1.0-rc.7 → 0.1.0-rc.8
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/data/README.md +10 -1
- package/dialog/README.md +23 -1
- package/fesm2022/cngx-common-a11y.mjs +125 -111
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-audio.mjs +47 -5
- package/fesm2022/cngx-common-audio.mjs.map +1 -1
- package/fesm2022/cngx-common-card.mjs +300 -46
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +1176 -453
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-command.mjs +37 -10
- package/fesm2022/cngx-common-command.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +1318 -469
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +151 -14
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +340 -73
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +1744 -952
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +841 -114
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-popover.mjs +350 -60
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +727 -317
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +1601 -1243
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common-timeline.mjs +137 -53
- 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 +21 -1
- package/package.json +3 -3
- package/popover/README.md +18 -2
- package/stepper/README.md +6 -4
- 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.css +24 -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 +42 -18
- package/types/cngx-common-card.d.ts +201 -17
- package/types/cngx-common-chart.d.ts +343 -47
- package/types/cngx-common-command.d.ts +31 -8
- package/types/cngx-common-data.d.ts +581 -68
- package/types/cngx-common-dialog.d.ts +158 -3
- package/types/cngx-common-display.d.ts +356 -142
- package/types/cngx-common-interactive.d.ts +859 -210
- package/types/cngx-common-layout.d.ts +567 -28
- package/types/cngx-common-popover.d.ts +262 -39
- package/types/cngx-common-stepper.d.ts +366 -116
- package/types/cngx-common-tabs.d.ts +214 -50
- package/types/cngx-common-timeline.d.ts +82 -16
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken,
|
|
2
|
+
import { InjectionToken, inject, computed, makeEnvironmentProviders, model, input, signal, isDevMode, afterNextRender, Directive, TemplateRef, contentChild, DestroyRef, output, effect, untracked, ViewEncapsulation, ChangeDetectionStrategy, Component, ElementRef, afterEveryRender, afterRenderEffect } from '@angular/core';
|
|
3
3
|
import { CNGX_COMMIT_CONTROLLER_FACTORY } from '@cngx/common/data';
|
|
4
|
-
import {
|
|
4
|
+
import { resolveStepFrom, resolveInlineStep, resolveBoundaryStep, injectDirection } from '@cngx/core';
|
|
5
|
+
import { createNestedOverrideMerge, createOverrideMerge, createTransitionTracker, CNGX_STATEFUL, nextUid, coerceSignal, buildAsyncStateView } from '@cngx/core/utils';
|
|
5
6
|
import { isObservable } from 'rxjs';
|
|
7
|
+
import { recordEqual } from '@cngx/utils';
|
|
8
|
+
import { formatMessage, createNestedLanguageSection, createSectionBundle } from '@cngx/core/i18n';
|
|
6
9
|
import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
7
10
|
import { Router, NavigationEnd } from '@angular/router';
|
|
8
11
|
import { filter } from 'rxjs/operators';
|
|
9
|
-
import {
|
|
12
|
+
import { injectContainerSize, createResizeSignal } from '@cngx/common/layout';
|
|
10
13
|
import * as i1 from '@cngx/common/interactive';
|
|
11
14
|
import { CngxAsyncClick } from '@cngx/common/interactive';
|
|
12
15
|
|
|
@@ -70,13 +73,38 @@ function runStepperAction(action, fromIndex, toIndex, handlers) {
|
|
|
70
73
|
// before the assignment binds - `sub` would be in TDZ. Declare
|
|
71
74
|
// the handle on a `let` first.
|
|
72
75
|
let sub = null;
|
|
76
|
+
let done = false;
|
|
73
77
|
sub = result.subscribe({
|
|
74
78
|
next: (accept) => {
|
|
79
|
+
if (done) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
// Done-latch, not just unsubscribe: a synchronous emission fires
|
|
83
|
+
// while `sub` is still null, so a non-completing source would
|
|
84
|
+
// otherwise stay live and re-resolve on its next emission.
|
|
85
|
+
done = true;
|
|
75
86
|
safeSuccess(accept);
|
|
76
87
|
sub?.unsubscribe();
|
|
77
88
|
},
|
|
78
|
-
error: (err) =>
|
|
89
|
+
error: (err) => {
|
|
90
|
+
if (done) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
safeError(err);
|
|
94
|
+
},
|
|
95
|
+
complete: () => {
|
|
96
|
+
// EMPTY-style sources complete without emitting; without this arm
|
|
97
|
+
// the commit stays 'pending' forever and busy() latches true.
|
|
98
|
+
if (!done) {
|
|
99
|
+
safeError(new Error('Stepper commitAction completed without emitting'));
|
|
100
|
+
}
|
|
101
|
+
},
|
|
79
102
|
});
|
|
103
|
+
if (done) {
|
|
104
|
+
// The in-next unsubscribe was a no-op for a sync emission; close
|
|
105
|
+
// the still-live subscription now that `sub` is bound.
|
|
106
|
+
sub.unsubscribe();
|
|
107
|
+
}
|
|
80
108
|
unsubscribe = () => sub?.unsubscribe();
|
|
81
109
|
}
|
|
82
110
|
else if (result != null && typeof result.then === 'function') {
|
|
@@ -106,14 +134,152 @@ const CNGX_STEPPER_COMMIT_HANDLER_FACTORY = new InjectionToken('CngxStepperCommi
|
|
|
106
134
|
});
|
|
107
135
|
|
|
108
136
|
/**
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* default, and any JSDoc cross-references stay in lockstep. Consumers
|
|
112
|
-
* override the query via {@link withStepperMobileBreakpoint}.
|
|
137
|
+
* The English stepper section: the single source of the stepper's English
|
|
138
|
+
* copy. `CNGX_STEPPER_I18N` and the `CNGX_STEPPER_CONFIG` labels default to it.
|
|
113
139
|
*
|
|
114
|
-
* @category common/stepper
|
|
140
|
+
* @category common/stepper/i18n
|
|
141
|
+
* @since 0.1.0
|
|
142
|
+
* @relatedTo CNGX_STEPPER_I18N
|
|
143
|
+
*/
|
|
144
|
+
const CNGX_STEPPER_LANGUAGE_EN = {
|
|
145
|
+
stepperRegion: 'Steps',
|
|
146
|
+
stepperLabel: 'Steps',
|
|
147
|
+
stepRoleDescription: 'stepper',
|
|
148
|
+
stepIndicatorRoleDescription: 'step indicator',
|
|
149
|
+
groupRoleDescription: 'step group',
|
|
150
|
+
selectedStep: 'Step {position} of {count}: {label}',
|
|
151
|
+
stepWithDetail: '{step}: {detail}',
|
|
152
|
+
stepHasErrors: { one: '{count} error', other: '{count} errors' },
|
|
153
|
+
previousStep: 'Previous step',
|
|
154
|
+
nextStep: 'Next step',
|
|
155
|
+
commitFailedRetry: 'Could not save step - retry?',
|
|
156
|
+
commitInFlight: 'Saving step…',
|
|
157
|
+
commitRolledBackTo: 'Reverted to step "{origin}".',
|
|
158
|
+
stepRolledBack: '{base} This step was rolled back.',
|
|
159
|
+
statusLabels: {
|
|
160
|
+
done: 'Done',
|
|
161
|
+
inProgress: 'In progress',
|
|
162
|
+
upNext: 'Up next',
|
|
163
|
+
errored: 'Errored',
|
|
164
|
+
},
|
|
165
|
+
textStepperFormat: 'Step {current} of {count}',
|
|
166
|
+
groupSummaryCount: { one: '{count} step', other: '{count} steps' },
|
|
167
|
+
groupSummaryProgress: {
|
|
168
|
+
one: '{completed} of {count} step complete',
|
|
169
|
+
other: '{completed} of {count} steps complete',
|
|
170
|
+
},
|
|
171
|
+
groupSummaryCountShort: '{count}',
|
|
172
|
+
groupSummaryProgressShort: '{completed}/{count}',
|
|
173
|
+
stepFallbackLabel: 'Step {id}',
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
/** @internal Turns a stepper section into the token's keys for a locale. */
|
|
177
|
+
function stepperBundleFrom(section, locale) {
|
|
178
|
+
return {
|
|
179
|
+
stepperLabel: section.stepperLabel,
|
|
180
|
+
stepIndicatorRoleDescription: section.stepIndicatorRoleDescription,
|
|
181
|
+
groupRoleDescription: section.groupRoleDescription,
|
|
182
|
+
selectedStep: (label, position, count) => formatMessage(section.selectedStep, { label, position, count }, locale),
|
|
183
|
+
stepWithDetail: (step, detail) => formatMessage(section.stepWithDetail, { step, detail }, locale),
|
|
184
|
+
stepHasErrors: (count) => formatMessage(section.stepHasErrors, { count }, locale),
|
|
185
|
+
previousStep: section.previousStep,
|
|
186
|
+
nextStep: section.nextStep,
|
|
187
|
+
commitFailedRetry: section.commitFailedRetry,
|
|
188
|
+
commitInFlight: section.commitInFlight,
|
|
189
|
+
commitRolledBackTo: (origin) => formatMessage(section.commitRolledBackTo, { origin }, locale),
|
|
190
|
+
stepRolledBack: (base) => formatMessage(section.stepRolledBack, { base }, locale),
|
|
191
|
+
statusLabels: section.statusLabels,
|
|
192
|
+
textStepperFormat: (current, count) => formatMessage(section.textStepperFormat, { current, count }, locale),
|
|
193
|
+
groupSummaryCount: (count) => formatMessage(section.groupSummaryCount, { count }, locale),
|
|
194
|
+
groupSummaryProgress: (completed, count) => formatMessage(section.groupSummaryProgress, { completed, count }, locale),
|
|
195
|
+
groupSummaryCountShort: (count) => formatMessage(section.groupSummaryCountShort, { count }, locale),
|
|
196
|
+
groupSummaryProgressShort: (completed, count) => formatMessage(section.groupSummaryProgressShort, { completed, count }, locale),
|
|
197
|
+
stepFallbackLabel: (id) => formatMessage(section.stepFallbackLabel, { id }, locale),
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* @internal The English stepper section with the active pack's stepper
|
|
202
|
+
* section on top. Feeds both `CNGX_STEPPER_I18N` and the
|
|
203
|
+
* `CNGX_STEPPER_CONFIG` labels.
|
|
204
|
+
*/
|
|
205
|
+
const injectStepperLanguage = createNestedLanguageSection('stepper', CNGX_STEPPER_LANGUAGE_EN, 'statusLabels');
|
|
206
|
+
/** @internal Builds and reads the token, formatted for the reading locale. */
|
|
207
|
+
const stepperBundle = createSectionBundle({
|
|
208
|
+
section: injectStepperLanguage,
|
|
209
|
+
toBundle: stepperBundleFrom,
|
|
210
|
+
});
|
|
211
|
+
/**
|
|
212
|
+
* DI token for the resolved stepper i18n bundle, as a `Signal` so a
|
|
213
|
+
* runtime language switch re-renders every label it feeds.
|
|
214
|
+
* `providedIn: 'root'`: the stepper section of the active language pack over
|
|
215
|
+
* the English defaults, formatted for the app locale. Provide it through
|
|
216
|
+
* {@link provideStepperI18n}; a `{ provide, useValue }` entry must supply a
|
|
217
|
+
* `Signal<CngxStepperI18n>`.
|
|
218
|
+
*
|
|
219
|
+
* @category common/stepper/i18n
|
|
220
|
+
* @wcag AA
|
|
221
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/i18n/stepper-i18n.ts
|
|
222
|
+
* @since 0.1.0
|
|
223
|
+
*/
|
|
224
|
+
const CNGX_STEPPER_I18N = new InjectionToken('CngxStepperI18n', {
|
|
225
|
+
providedIn: 'root',
|
|
226
|
+
factory: () => stepperBundle.build(),
|
|
227
|
+
});
|
|
228
|
+
/**
|
|
229
|
+
* Brands an i18n mutator with `_target: 'i18n'`. Every `with*` i18n
|
|
230
|
+
* feature returns one of these.
|
|
231
|
+
*
|
|
232
|
+
* @internal
|
|
233
|
+
*/
|
|
234
|
+
function defineStepperI18nFeature(fn) {
|
|
235
|
+
return Object.assign(fn, { _target: 'i18n' });
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Override stepper i18n labels. Partial override - unset keys keep
|
|
239
|
+
* the language pack's copy, or the English default. {@link CngxStepperStatusLabels} is merged
|
|
240
|
+
* key-by-key so consumers can override one pill label without
|
|
241
|
+
* restating the rest. Pass a `Signal` to switch the language at runtime.
|
|
242
|
+
* Sibling of `withStepperAriaLabels` / `withStepperFallbackLabels`.
|
|
243
|
+
*
|
|
244
|
+
* @category common/stepper/i18n
|
|
245
|
+
*/
|
|
246
|
+
function withStepperI18nLabels(overrides) {
|
|
247
|
+
return defineStepperI18nFeature((bundle) => createNestedOverrideMerge(bundle, overrides, 'statusLabels'));
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Provider for the stepper i18n bundle. Compose `withStepperI18nLabels(...)`
|
|
251
|
+
* (plus any future i18n `with*`) - unset keys fall back to the language
|
|
252
|
+
* pack, then English. The features apply on top of the active pack.
|
|
253
|
+
*
|
|
254
|
+
* ```ts
|
|
255
|
+
* bootstrapApplication(AppComponent, {
|
|
256
|
+
* providers: [
|
|
257
|
+
* provideStepperI18n(
|
|
258
|
+
* withStepperI18nLabels({ stepperLabel: 'Schrittfolge', previousStep: 'Vorheriger' }),
|
|
259
|
+
* ),
|
|
260
|
+
* ],
|
|
261
|
+
* });
|
|
262
|
+
* ```
|
|
263
|
+
*
|
|
264
|
+
* @category common/stepper/i18n
|
|
115
265
|
*/
|
|
116
|
-
|
|
266
|
+
function provideStepperI18n(...features) {
|
|
267
|
+
return {
|
|
268
|
+
provide: CNGX_STEPPER_I18N,
|
|
269
|
+
useFactory: () => stepperBundle.build(features),
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Inject the resolved stepper i18n bundle in an injection context. Read it
|
|
274
|
+
* inside a `computed()`, template or handler so a language switch reaches
|
|
275
|
+
* the label.
|
|
276
|
+
*
|
|
277
|
+
* @category common/stepper/i18n
|
|
278
|
+
*/
|
|
279
|
+
function injectStepperI18n() {
|
|
280
|
+
return stepperBundle.resolve(inject(CNGX_STEPPER_I18N));
|
|
281
|
+
}
|
|
282
|
+
|
|
117
283
|
/**
|
|
118
284
|
* Default per-step px thresholds for the `density: 'auto'` ladder. The
|
|
119
285
|
* literal lives on a single exported const so the runtime resolver, the
|
|
@@ -141,18 +307,19 @@ const STEPPER_CONFIG_DEFAULTS = {
|
|
|
141
307
|
densityBreakpoints: STEPPER_DEFAULT_DENSITY_BREAKPOINTS,
|
|
142
308
|
connectors: false,
|
|
143
309
|
mobileCollapse: 'text',
|
|
144
|
-
mobileBreakpoint: STEPPER_DEFAULT_MOBILE_BREAKPOINT,
|
|
145
310
|
mobileIndicatorPosition: 'top',
|
|
146
311
|
mobileSwipe: true,
|
|
147
312
|
ariaLabels: {
|
|
148
|
-
stepperRegion:
|
|
313
|
+
stepperRegion: CNGX_STEPPER_LANGUAGE_EN.stepperRegion,
|
|
149
314
|
},
|
|
150
315
|
fallbackLabels: {
|
|
151
|
-
groupRoleDescription:
|
|
152
|
-
stepRoleDescription:
|
|
316
|
+
groupRoleDescription: CNGX_STEPPER_LANGUAGE_EN.groupRoleDescription,
|
|
317
|
+
stepRoleDescription: CNGX_STEPPER_LANGUAGE_EN.stepRoleDescription,
|
|
153
318
|
},
|
|
154
319
|
templates: {},
|
|
155
320
|
};
|
|
321
|
+
/** @internal - shared empty base, so label merges over an unset key memoize. */
|
|
322
|
+
const NO_LABELS = {};
|
|
156
323
|
/**
|
|
157
324
|
* DI token for the resolved stepper config. `providedIn: 'root'` with
|
|
158
325
|
* library defaults; override via {@link provideStepperConfig} (root)
|
|
@@ -165,7 +332,7 @@ const STEPPER_CONFIG_DEFAULTS = {
|
|
|
165
332
|
*/
|
|
166
333
|
const CNGX_STEPPER_CONFIG = new InjectionToken('CngxStepperConfig', {
|
|
167
334
|
providedIn: 'root',
|
|
168
|
-
factory: () =>
|
|
335
|
+
factory: () => resolveFeatures([]),
|
|
169
336
|
});
|
|
170
337
|
/**
|
|
171
338
|
* Brands a config mutator with `_target: 'config'`. Every `with*`
|
|
@@ -252,28 +419,18 @@ function withStepperConnectors(on) {
|
|
|
252
419
|
return defineStepperConfigFeature((cfg) => ({ ...cfg, connectors: on }));
|
|
253
420
|
}
|
|
254
421
|
/**
|
|
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
|
|
422
|
+
* Configure the mobile auto-collapse target for `<cngx-stepper>`. Below
|
|
423
|
+
* `30rem` of the stepper's own container width, the classic strip swaps
|
|
424
|
+
* to the chosen variant - `'text'` (default) renders
|
|
425
|
+
* `<cngx-text-stepper>`, `'dots'` renders `<cngx-dot-stepper>`, `'off'`
|
|
426
|
+
* keeps the classic strip. The Material twin `<cngx-mat-stepper>` ignores
|
|
427
|
+
* this setting.
|
|
260
428
|
*
|
|
261
429
|
* @category common/stepper
|
|
262
430
|
*/
|
|
263
431
|
function withStepperMobileCollapse(mode) {
|
|
264
432
|
return defineStepperConfigFeature((cfg) => ({ ...cfg, mobileCollapse: mode }));
|
|
265
433
|
}
|
|
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
434
|
/**
|
|
278
435
|
* Set the app-wide default position of the mobile auto-collapse
|
|
279
436
|
* indicator relative to panel content. `'top'` keeps the indicator
|
|
@@ -356,25 +513,28 @@ function withStepperDensity(mode, breakpoints) {
|
|
|
356
513
|
/**
|
|
357
514
|
* Merge ARIA labels into the cascade. Keys not provided keep their
|
|
358
515
|
* library defaults; per-instance overrides on the stepper still win.
|
|
516
|
+
* Pass a `Signal` to switch the language at runtime.
|
|
359
517
|
*
|
|
360
518
|
* @category common/stepper
|
|
361
519
|
*/
|
|
362
520
|
function withStepperAriaLabels(labels) {
|
|
363
521
|
return defineStepperConfigFeature((cfg) => ({
|
|
364
522
|
...cfg,
|
|
365
|
-
ariaLabels:
|
|
523
|
+
ariaLabels: createOverrideMerge(cfg.ariaLabels ?? NO_LABELS, labels),
|
|
366
524
|
}));
|
|
367
525
|
}
|
|
368
526
|
/**
|
|
369
|
-
* Merge
|
|
370
|
-
*
|
|
527
|
+
* Merge fallback role descriptions (`groupRoleDescription` /
|
|
528
|
+
* `stepRoleDescription`) into the cascade. These feed the strip's
|
|
529
|
+
* `aria-roledescription` attributes when the consumer supplies none.
|
|
530
|
+
* Pass a `Signal` to switch the language at runtime.
|
|
371
531
|
*
|
|
372
532
|
* @category common/stepper
|
|
373
533
|
*/
|
|
374
534
|
function withStepperFallbackLabels(labels) {
|
|
375
535
|
return defineStepperConfigFeature((cfg) => ({
|
|
376
536
|
...cfg,
|
|
377
|
-
fallbackLabels:
|
|
537
|
+
fallbackLabels: createOverrideMerge(cfg.fallbackLabels ?? NO_LABELS, labels),
|
|
378
538
|
}));
|
|
379
539
|
}
|
|
380
540
|
/**
|
|
@@ -474,9 +634,26 @@ function withDotStepperDotTemplate(template) {
|
|
|
474
634
|
templates: { ...cfg.templates, dotStepperDot: template },
|
|
475
635
|
}));
|
|
476
636
|
}
|
|
477
|
-
/**
|
|
637
|
+
/**
|
|
638
|
+
* @internal The defaults with the copy keys read from the stepper section of
|
|
639
|
+
* the active language pack. Runs in an injection context.
|
|
640
|
+
*/
|
|
641
|
+
function stepperConfigDefaultsFromPack() {
|
|
642
|
+
const language = injectStepperLanguage();
|
|
643
|
+
return {
|
|
644
|
+
...STEPPER_CONFIG_DEFAULTS,
|
|
645
|
+
ariaLabels: computed(() => ({ stepperRegion: language().stepperRegion }), {
|
|
646
|
+
equal: recordEqual,
|
|
647
|
+
}),
|
|
648
|
+
fallbackLabels: computed(() => ({
|
|
649
|
+
groupRoleDescription: language().groupRoleDescription,
|
|
650
|
+
stepRoleDescription: language().stepRoleDescription,
|
|
651
|
+
}), { equal: recordEqual }),
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
/** @internal Runs in an injection context; features apply on top of the pack. */
|
|
478
655
|
function resolveFeatures(features) {
|
|
479
|
-
return features.reduce((cfg, feat) => feat(cfg),
|
|
656
|
+
return features.reduce((cfg, feat) => feat(cfg), stepperConfigDefaultsFromPack());
|
|
480
657
|
}
|
|
481
658
|
/**
|
|
482
659
|
* Root-level provider for the stepper config. Apply once in the
|
|
@@ -487,7 +664,7 @@ function resolveFeatures(features) {
|
|
|
487
664
|
*/
|
|
488
665
|
function provideStepperConfig(...features) {
|
|
489
666
|
return makeEnvironmentProviders([
|
|
490
|
-
{ provide: CNGX_STEPPER_CONFIG,
|
|
667
|
+
{ provide: CNGX_STEPPER_CONFIG, useFactory: () => resolveFeatures(features) },
|
|
491
668
|
]);
|
|
492
669
|
}
|
|
493
670
|
/**
|
|
@@ -508,7 +685,7 @@ function provideStepperConfig(...features) {
|
|
|
508
685
|
* @category common/stepper
|
|
509
686
|
*/
|
|
510
687
|
function provideStepperConfigAt(...features) {
|
|
511
|
-
return [{ provide: CNGX_STEPPER_CONFIG,
|
|
688
|
+
return [{ provide: CNGX_STEPPER_CONFIG, useFactory: () => resolveFeatures(features) }];
|
|
512
689
|
}
|
|
513
690
|
/**
|
|
514
691
|
* Inject the resolved stepper config in an injection context.
|
|
@@ -589,8 +766,7 @@ function stepTreeEqual(a, b) {
|
|
|
589
766
|
* a sibling is inserted) on top of the {@link stepTreeEqual} fields.
|
|
590
767
|
*
|
|
591
768
|
* Use only on projections where every step carries a real
|
|
592
|
-
* DFS-assigned `flatIndex` and `depth
|
|
593
|
-
* {@link stepNodesEqual}.
|
|
769
|
+
* DFS-assigned `flatIndex` and `depth`.
|
|
594
770
|
*
|
|
595
771
|
* @internal Exported from `public-api.ts` so the cngx-stepper and
|
|
596
772
|
* cngx-mat-stepper organisms share the comparator across the
|
|
@@ -615,27 +791,6 @@ function flatStepsEqual(a, b) {
|
|
|
615
791
|
}
|
|
616
792
|
return true;
|
|
617
793
|
}
|
|
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
794
|
|
|
640
795
|
/**
|
|
641
796
|
* Stepper presenter - the brain of every stepper / wizard flow.
|
|
@@ -690,6 +845,13 @@ class CngxStepperPresenter {
|
|
|
690
845
|
// Persistence-of-error surface - see CngxStepperHost.lastFailedIndex
|
|
691
846
|
// / originIndexDuringCommit for the contract.
|
|
692
847
|
lastFailedIndexState = signal(undefined, ...(ngDevMode ? [{ debugName: "lastFailedIndexState" }] : /* istanbul ignore next */ []));
|
|
848
|
+
// Last index a commit actually landed on (or a sync/back move settled
|
|
849
|
+
// on). Rollback + origin resolution use this instead of the per-call
|
|
850
|
+
// `previous`: a rapid second select() supersedes the first while
|
|
851
|
+
// `previous` already points at the never-committed optimistic index,
|
|
852
|
+
// and rolling back there would strand the user mid-air. Plain field -
|
|
853
|
+
// read only inside handlers, never rendered.
|
|
854
|
+
lastCommittedIndex;
|
|
693
855
|
originIndexDuringCommitState = signal(undefined, ...(ngDevMode ? [{ debugName: "originIndexDuringCommitState" }] : /* istanbul ignore next */ []));
|
|
694
856
|
/** {@inheritDoc CngxStepperHost.lastFailedIndex} */
|
|
695
857
|
lastFailedIndex = this.lastFailedIndexState.asReadonly();
|
|
@@ -788,24 +950,24 @@ class CngxStepperPresenter {
|
|
|
788
950
|
*/
|
|
789
951
|
nextEnabledIndex = computed(() => {
|
|
790
952
|
const stepsOnly = this.stepsOnly();
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
}
|
|
795
|
-
return next;
|
|
953
|
+
return (resolveStepFrom(this.activeStepIndex(), 1, {
|
|
954
|
+
count: stepsOnly.length,
|
|
955
|
+
isDisabledAt: (i) => stepsOnly[i]?.disabled() ?? false,
|
|
956
|
+
}) ?? stepsOnly.length);
|
|
796
957
|
}, ...(ngDevMode ? [{ debugName: "nextEnabledIndex" }] : /* istanbul ignore next */ []));
|
|
797
958
|
/**
|
|
798
959
|
* Previous enabled step-only index before the active one, skipping
|
|
799
|
-
* disabled steps. Returns `-1` when no enabled step precedes
|
|
960
|
+
* disabled steps. Returns `-1` when no enabled step precedes - also for
|
|
961
|
+
* a stale out-of-range active index (consumer-writable model), which
|
|
962
|
+
* must resolve to "none" instead of wrapping or throwing. Single
|
|
800
963
|
* source for `selectPrevious()` and the `canGoPrevious` bound.
|
|
801
964
|
*/
|
|
802
965
|
previousEnabledIndex = computed(() => {
|
|
803
966
|
const stepsOnly = this.stepsOnly();
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
}
|
|
808
|
-
return prev;
|
|
967
|
+
return (resolveStepFrom(Math.max(this.activeStepIndex(), 0), -1, {
|
|
968
|
+
count: stepsOnly.length,
|
|
969
|
+
isDisabledAt: (i) => stepsOnly[i]?.disabled() ?? false,
|
|
970
|
+
}) ?? -1);
|
|
809
971
|
}, ...(ngDevMode ? [{ debugName: "previousEnabledIndex" }] : /* istanbul ignore next */ []));
|
|
810
972
|
/** {@inheritDoc CngxStepperHost.stepCount} */
|
|
811
973
|
stepCount = computed(() => this.stepsOnly().length, ...(ngDevMode ? [{ debugName: "stepCount" }] : /* istanbul ignore next */ []));
|
|
@@ -865,11 +1027,16 @@ class CngxStepperPresenter {
|
|
|
865
1027
|
}
|
|
866
1028
|
this.rebuildTree();
|
|
867
1029
|
}
|
|
868
|
-
unregister(id) {
|
|
1030
|
+
unregister(id, handle) {
|
|
869
1031
|
const entry = this.registry.get(id);
|
|
870
1032
|
if (!entry) {
|
|
871
1033
|
return;
|
|
872
1034
|
}
|
|
1035
|
+
// Instance guard: after an idempotent re-register replaced the stored
|
|
1036
|
+
// handle, the superseded instance's destroy is a no-op.
|
|
1037
|
+
if (handle !== undefined && entry.reg !== handle) {
|
|
1038
|
+
return;
|
|
1039
|
+
}
|
|
873
1040
|
if (entry.parentId !== null) {
|
|
874
1041
|
const parent = this.registry.get(entry.parentId);
|
|
875
1042
|
if (parent) {
|
|
@@ -964,6 +1131,7 @@ class CngxStepperPresenter {
|
|
|
964
1131
|
// `originIndexDuringCommit` stays untouched. Clear the rejection
|
|
965
1132
|
// flag if the user re-picked a previously-failed target.
|
|
966
1133
|
this.activeStepIndex.set(target);
|
|
1134
|
+
this.lastCommittedIndex = target;
|
|
967
1135
|
if (this.lastFailedIndexState() === target) {
|
|
968
1136
|
this.lastFailedIndexState.set(undefined);
|
|
969
1137
|
}
|
|
@@ -976,8 +1144,15 @@ class CngxStepperPresenter {
|
|
|
976
1144
|
//
|
|
977
1145
|
// Capture the safe-harbour origin exactly once on commit-window
|
|
978
1146
|
// open. Written ONLY on this path so a stale origin never lingers
|
|
979
|
-
// into a non-commit navigation.
|
|
980
|
-
|
|
1147
|
+
// into a non-commit navigation. The origin is the last TRULY
|
|
1148
|
+
// committed index, not `previous`: under a superseded optimistic
|
|
1149
|
+
// commit `previous` is the never-committed optimistic position.
|
|
1150
|
+
const origin = this.lastCommittedIndex ?? previous;
|
|
1151
|
+
// Record the origin as truly committed on window open: for the first
|
|
1152
|
+
// window `previous` IS the settled start position; for a superseding
|
|
1153
|
+
// select the field already holds the real one (idempotent).
|
|
1154
|
+
this.lastCommittedIndex = origin;
|
|
1155
|
+
this.originIndexDuringCommitState.set(origin);
|
|
981
1156
|
const mode = this.commitMode();
|
|
982
1157
|
if (mode === 'optimistic') {
|
|
983
1158
|
this.activeStepIndex.set(target);
|
|
@@ -986,6 +1161,7 @@ class CngxStepperPresenter {
|
|
|
986
1161
|
if (accept) {
|
|
987
1162
|
// Success - origin no longer needed; clear the rejection
|
|
988
1163
|
// flag if the user re-picked the failed target.
|
|
1164
|
+
this.lastCommittedIndex = target;
|
|
989
1165
|
this.originIndexDuringCommitState.set(undefined);
|
|
990
1166
|
if (this.lastFailedIndexState() === target) {
|
|
991
1167
|
this.lastFailedIndexState.set(undefined);
|
|
@@ -997,11 +1173,11 @@ class CngxStepperPresenter {
|
|
|
997
1173
|
else {
|
|
998
1174
|
// Reject - flag the target; RETAIN the origin so
|
|
999
1175
|
// `liveAnnouncement` can resolve the origin label for the
|
|
1000
|
-
// rich rollback phrase. Optimistic rolls back
|
|
1001
|
-
// never moved.
|
|
1176
|
+
// rich rollback phrase. Optimistic rolls back to the last
|
|
1177
|
+
// truly-committed index; pessimistic never moved off it.
|
|
1002
1178
|
this.lastFailedIndexState.set(target);
|
|
1003
1179
|
if (mode === 'optimistic') {
|
|
1004
|
-
this.activeStepIndex.set(
|
|
1180
|
+
this.activeStepIndex.set(origin);
|
|
1005
1181
|
}
|
|
1006
1182
|
}
|
|
1007
1183
|
});
|
|
@@ -1012,9 +1188,18 @@ class CngxStepperPresenter {
|
|
|
1012
1188
|
this.select(next);
|
|
1013
1189
|
}
|
|
1014
1190
|
}
|
|
1191
|
+
/**
|
|
1192
|
+
* Ungated back-move. Supersedes an in-flight commit: the runner is
|
|
1193
|
+
* canceled and the commit state settles to idle, so `busy` cannot
|
|
1194
|
+
* latch and a late resolve cannot yank the user forward off the step
|
|
1195
|
+
* they explicitly returned to.
|
|
1196
|
+
*/
|
|
1015
1197
|
selectPrevious() {
|
|
1016
1198
|
const prev = this.previousEnabledIndex();
|
|
1017
1199
|
if (prev >= 0) {
|
|
1200
|
+
this.cancelAndSettleCommit();
|
|
1201
|
+
this.originIndexDuringCommitState.set(undefined);
|
|
1202
|
+
this.lastCommittedIndex = prev;
|
|
1018
1203
|
this.activeStepIndex.set(prev);
|
|
1019
1204
|
}
|
|
1020
1205
|
}
|
|
@@ -1027,7 +1212,26 @@ class CngxStepperPresenter {
|
|
|
1027
1212
|
}
|
|
1028
1213
|
reset() {
|
|
1029
1214
|
this.activeStepIndex.set(0);
|
|
1030
|
-
this.
|
|
1215
|
+
this.lastCommittedIndex = 0;
|
|
1216
|
+
this.originIndexDuringCommitState.set(undefined);
|
|
1217
|
+
this.lastFailedIndexState.set(undefined);
|
|
1218
|
+
// Settle mid-commit resets to idle - the surface lives on, so a
|
|
1219
|
+
// dangling 'pending' would latch busy() forever.
|
|
1220
|
+
this.cancelAndSettleCommit();
|
|
1221
|
+
}
|
|
1222
|
+
/**
|
|
1223
|
+
* Cancels the in-flight commit and settles the state to idle. The
|
|
1224
|
+
* settle option is load-bearing here - a custom
|
|
1225
|
+
* `CNGX_COMMIT_CONTROLLER_FACTORY` implementation that ignores it
|
|
1226
|
+
* leaves `busy` latched, which is invisible until a user backs out
|
|
1227
|
+
* mid-commit; the dev-mode probe surfaces that immediately.
|
|
1228
|
+
*/
|
|
1229
|
+
cancelAndSettleCommit() {
|
|
1230
|
+
this.commitController.cancel({ settle: true });
|
|
1231
|
+
if (isDevMode() && this.commitState.status() === 'pending') {
|
|
1232
|
+
console.warn('[cngxStepper] the commit controller ignored cancel({ settle: true }) - busy stays ' +
|
|
1233
|
+
'latched. Honor the settle option in your CNGX_COMMIT_CONTROLLER_FACTORY override.');
|
|
1234
|
+
}
|
|
1031
1235
|
}
|
|
1032
1236
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepperPresenter, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1033
1237
|
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 +1341,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1137
1341
|
* `CngxStepGroup` ({@link CNGX_STEP_GROUP_HOST}) or the root
|
|
1138
1342
|
* `CngxStepperPresenter` ({@link CNGX_STEPPER_HOST}).
|
|
1139
1343
|
*
|
|
1140
|
-
* `state` is a `
|
|
1344
|
+
* `state` is a pure `computed` over `[disabled]`, `[completed]`, and
|
|
1141
1345
|
* the optional `[errorAggregator]`'s `hasError()`.
|
|
1142
1346
|
*
|
|
1143
1347
|
* @category common/stepper
|
|
@@ -1179,32 +1383,22 @@ class CngxStep {
|
|
|
1179
1383
|
contentSlot = contentChild(CngxStepContent, ...(ngDevMode ? [{ debugName: "contentSlot" }] : /* istanbul ignore next */ []));
|
|
1180
1384
|
labelTemplate = this.labelSlot;
|
|
1181
1385
|
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 });
|
|
1386
|
+
/** Per-step status derived from inputs + aggregator - never written. */
|
|
1387
|
+
state = computed(() => {
|
|
1388
|
+
if (this.disabled()) {
|
|
1389
|
+
return 'disabled';
|
|
1390
|
+
}
|
|
1391
|
+
const directError = this.error();
|
|
1392
|
+
const errored = (directError !== false && directError !== '') ||
|
|
1393
|
+
(this.errorAggregator()?.hasError?.() ?? false);
|
|
1394
|
+
if (errored) {
|
|
1395
|
+
return 'error';
|
|
1396
|
+
}
|
|
1397
|
+
if (this.completed()) {
|
|
1398
|
+
return 'success';
|
|
1399
|
+
}
|
|
1400
|
+
return 'idle';
|
|
1401
|
+
}, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
1208
1402
|
groupHost = inject(CNGX_STEP_GROUP_HOST, { optional: true });
|
|
1209
1403
|
stepperHost = inject(CNGX_STEPPER_HOST, { optional: true });
|
|
1210
1404
|
destroyRef = inject(DestroyRef);
|
|
@@ -1225,7 +1419,7 @@ class CngxStep {
|
|
|
1225
1419
|
// the presenter's insertion-order tree is unchanged. Mirrors CngxTab.
|
|
1226
1420
|
const host = this.groupHost ?? this.stepperHost;
|
|
1227
1421
|
const stepId = this.id();
|
|
1228
|
-
|
|
1422
|
+
const handle = {
|
|
1229
1423
|
id: stepId,
|
|
1230
1424
|
kind: 'step',
|
|
1231
1425
|
label: this.label,
|
|
@@ -1233,8 +1427,9 @@ class CngxStep {
|
|
|
1233
1427
|
state: this.state,
|
|
1234
1428
|
errorAggregator: this.errorAggregator,
|
|
1235
1429
|
errorMessage: this.errorMessage,
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1430
|
+
};
|
|
1431
|
+
host.register(handle);
|
|
1432
|
+
this.destroyRef.onDestroy(() => host.unregister(stepId, handle));
|
|
1238
1433
|
}
|
|
1239
1434
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStep, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1240
1435
|
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 +1478,10 @@ class CngxStepGroup {
|
|
|
1283
1478
|
if (states.some((s) => s === 'error')) {
|
|
1284
1479
|
return 'error';
|
|
1285
1480
|
}
|
|
1286
|
-
if (states.some((s) => s === 'pending'
|
|
1481
|
+
if (states.some((s) => s === 'pending')) {
|
|
1482
|
+
// 'pending' can only come from a nested group's own rollup; leaf
|
|
1483
|
+
// steps never produce it ('busy' is a per-step presenter concern,
|
|
1484
|
+
// not a step state, so no 'busy' arm exists here).
|
|
1287
1485
|
return 'pending';
|
|
1288
1486
|
}
|
|
1289
1487
|
if (states.every((s) => s === 'success')) {
|
|
@@ -1292,6 +1490,13 @@ class CngxStepGroup {
|
|
|
1292
1490
|
return 'idle';
|
|
1293
1491
|
}, { ...(ngDevMode ? { debugName: "aggregatedStatus" } : /* istanbul ignore next */ {}), equal: Object.is });
|
|
1294
1492
|
stepperHost = inject(CNGX_STEPPER_HOST, { optional: true });
|
|
1493
|
+
// A group nested inside another group must register through its parent
|
|
1494
|
+
// (skipSelf past our own CNGX_STEP_GROUP_HOST provider), or it would
|
|
1495
|
+
// silently register as a root and flatten the tree.
|
|
1496
|
+
parentGroupHost = inject(CNGX_STEP_GROUP_HOST, {
|
|
1497
|
+
optional: true,
|
|
1498
|
+
skipSelf: true,
|
|
1499
|
+
});
|
|
1295
1500
|
destroyRef = inject(DestroyRef);
|
|
1296
1501
|
/**
|
|
1297
1502
|
* `true` when this group's children are collapsed to the header node:
|
|
@@ -1328,25 +1533,28 @@ class CngxStepGroup {
|
|
|
1328
1533
|
// ancestor group before its descendant steps, so that order holds, and
|
|
1329
1534
|
// groups and steps share one lifecycle phase - keeping the presenter's
|
|
1330
1535
|
// insertion-order tree identical to the previous constructor ordering.
|
|
1331
|
-
const
|
|
1536
|
+
const registrationHost = this.parentGroupHost ?? this.stepperHost;
|
|
1332
1537
|
const groupId = this.id();
|
|
1333
|
-
|
|
1538
|
+
const handle = {
|
|
1334
1539
|
id: groupId,
|
|
1335
1540
|
kind: 'group',
|
|
1336
1541
|
label: this.label,
|
|
1337
1542
|
disabled: this.disabled,
|
|
1338
1543
|
state: this.aggregatedStatus,
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1544
|
+
};
|
|
1545
|
+
registrationHost.register(handle);
|
|
1546
|
+
this.destroyRef.onDestroy(() => registrationHost.unregister(groupId, handle));
|
|
1341
1547
|
}
|
|
1342
1548
|
register(handle) {
|
|
1343
1549
|
this.childRegistry.update((cur) => [...cur, handle]);
|
|
1344
1550
|
// Forward to the root with this group as parent so the tree shape is correct.
|
|
1345
1551
|
this.stepperHost.register(handle, this.id());
|
|
1346
1552
|
}
|
|
1347
|
-
unregister(id) {
|
|
1348
|
-
|
|
1349
|
-
|
|
1553
|
+
unregister(id, handle) {
|
|
1554
|
+
// Same instance guard as the presenter: only evict the exact handle
|
|
1555
|
+
// (or fall back to id-keyed removal for handle-less callers).
|
|
1556
|
+
this.childRegistry.update((cur) => cur.filter((c) => (handle !== undefined ? c !== handle : c.id !== id)));
|
|
1557
|
+
this.stepperHost.unregister(id, handle);
|
|
1350
1558
|
}
|
|
1351
1559
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1352
1560
|
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 });
|
|
@@ -1756,6 +1964,9 @@ const CNGX_STEPPER_GLYPHS = {
|
|
|
1756
1964
|
*/
|
|
1757
1965
|
class CngxStepperRouterSync {
|
|
1758
1966
|
// Default undefined so the cascade resolves through CNGX_STEPPER_CONFIG.
|
|
1967
|
+
// Init-only: the seed and the write effect capture the resolved mode /
|
|
1968
|
+
// param on their first run; changing either after init leaves the old
|
|
1969
|
+
// URL key behind. Rebuild the directive to change them.
|
|
1759
1970
|
modeInput = input(undefined, { ...(ngDevMode ? { debugName: "modeInput" } : /* istanbul ignore next */ {}), alias: 'mode' });
|
|
1760
1971
|
paramNameInput = input(undefined, { ...(ngDevMode ? { debugName: "paramNameInput" } : /* istanbul ignore next */ {}), alias: 'paramName' });
|
|
1761
1972
|
config = injectStepperConfig();
|
|
@@ -1795,20 +2006,7 @@ class CngxStepperRouterSync {
|
|
|
1795
2006
|
if (!id) {
|
|
1796
2007
|
return;
|
|
1797
2008
|
}
|
|
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
|
-
});
|
|
2009
|
+
untracked(() => this.writeUrl(router, id));
|
|
1812
2010
|
});
|
|
1813
2011
|
const navEnd = toSignal(router.events.pipe(filter((e) => e instanceof NavigationEnd), takeUntilDestroyed(inject(DestroyRef))), { initialValue: null });
|
|
1814
2012
|
effect(() => {
|
|
@@ -1826,10 +2024,11 @@ class CngxStepperRouterSync {
|
|
|
1826
2024
|
}
|
|
1827
2025
|
/**
|
|
1828
2026
|
* Seed from the URL before the stepper renders its panels. `CngxStep`
|
|
1829
|
-
* registers in
|
|
1830
|
-
*
|
|
1831
|
-
*
|
|
1832
|
-
*
|
|
2027
|
+
* registers in `ngOnInit` (so a bound `[id]` reaches the registry), which
|
|
2028
|
+
* runs before the host's `ngAfterContentInit` - the registry is populated
|
|
2029
|
+
* by the time this runs, and the host view has not rendered yet, which is
|
|
2030
|
+
* what keeps a `panelMode="lazy"` default step from counting its first
|
|
2031
|
+
* render as a first activation on a deep link that named another step.
|
|
1833
2032
|
*
|
|
1834
2033
|
* Own router guard: the constructor's early return does not stop
|
|
1835
2034
|
* lifecycle hooks from running.
|
|
@@ -1855,8 +2054,41 @@ class CngxStepperRouterSync {
|
|
|
1855
2054
|
return;
|
|
1856
2055
|
}
|
|
1857
2056
|
this.seeded = true;
|
|
2057
|
+
// No explicit URL correction on a refused (linear-blocked / disabled)
|
|
2058
|
+
// seed: the activeStepId write effect's first run flushes AFTER this
|
|
2059
|
+
// content-init hook and unconditionally reflects the ACTUAL active id
|
|
2060
|
+
// into the URL, so a refused deep link is rewritten on the same tick.
|
|
2061
|
+
// The refused-seed spec pins that guarantee.
|
|
1858
2062
|
untracked(() => this.host.selectById(initial));
|
|
1859
2063
|
}
|
|
2064
|
+
/**
|
|
2065
|
+
* Reflect `id` into the URL. Fragment mode re-serializes the existing
|
|
2066
|
+
* fragment params so foreign state (`#foo=1&step=x`) survives the
|
|
2067
|
+
* write; values are URI-encoded symmetric to {@link parseFragment}.
|
|
2068
|
+
*/
|
|
2069
|
+
writeUrl(router, id) {
|
|
2070
|
+
const navigation = this.mode() === 'fragment'
|
|
2071
|
+
? router.navigate([], {
|
|
2072
|
+
fragment: this.serializeFragment(router, id),
|
|
2073
|
+
queryParamsHandling: 'merge',
|
|
2074
|
+
replaceUrl: true,
|
|
2075
|
+
})
|
|
2076
|
+
: router.navigate([], {
|
|
2077
|
+
queryParams: { [this.paramName()]: id },
|
|
2078
|
+
queryParamsHandling: 'merge',
|
|
2079
|
+
replaceUrl: true,
|
|
2080
|
+
});
|
|
2081
|
+
navigation.catch?.((err) => this.syncError.emit(err));
|
|
2082
|
+
}
|
|
2083
|
+
serializeFragment(router, id) {
|
|
2084
|
+
const param = this.paramName();
|
|
2085
|
+
const current = router.routerState.snapshot.root.fragment ?? '';
|
|
2086
|
+
const segments = current
|
|
2087
|
+
.split('&')
|
|
2088
|
+
.filter((seg) => seg !== '' && seg.split('=')[0] !== param);
|
|
2089
|
+
segments.push(`${param}=${encodeURIComponent(id)}`);
|
|
2090
|
+
return segments.join('&');
|
|
2091
|
+
}
|
|
1860
2092
|
readUrlValue(router) {
|
|
1861
2093
|
if (this.mode() === 'fragment') {
|
|
1862
2094
|
return this.parseFragment(router.routerState.snapshot.root.fragment ?? '');
|
|
@@ -1869,7 +2101,7 @@ class CngxStepperRouterSync {
|
|
|
1869
2101
|
for (const seg of segments) {
|
|
1870
2102
|
const [key, val] = seg.split('=');
|
|
1871
2103
|
if (key === param && val) {
|
|
1872
|
-
return val;
|
|
2104
|
+
return decodeURIComponent(val);
|
|
1873
2105
|
}
|
|
1874
2106
|
}
|
|
1875
2107
|
return null;
|
|
@@ -1886,103 +2118,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1886
2118
|
}]
|
|
1887
2119
|
}], 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
2120
|
|
|
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
2121
|
/**
|
|
1987
2122
|
* Resolve the status-pill label for a step node against the resolved
|
|
1988
2123
|
* i18n bundle. Used by skins that surface a per-step status pill
|
|
@@ -2015,31 +2150,45 @@ function resolveStepperStatusLabel(node, i18n, isActive) {
|
|
|
2015
2150
|
}
|
|
2016
2151
|
|
|
2017
2152
|
/**
|
|
2018
|
-
*
|
|
2019
|
-
*
|
|
2020
|
-
*
|
|
2153
|
+
* Reads the stepper's collapse flag off its own container.
|
|
2154
|
+
*
|
|
2155
|
+
* The threshold is a `@container` rule in `stepper-base.css` writing
|
|
2156
|
+
* `--cngx-stepper-collapse` onto `.cngx-stepper::after`. It lands on the
|
|
2157
|
+
* pseudo-element because a container query cannot style its own container,
|
|
2158
|
+
* and the query container for a pseudo-element is selected from its
|
|
2159
|
+
* originating element's inclusive ancestors. Nothing here parses a width, so
|
|
2160
|
+
* a consumer re-aims the collapse with a plain CSS rule.
|
|
2021
2161
|
*
|
|
2022
|
-
*
|
|
2023
|
-
*
|
|
2024
|
-
* from
|
|
2162
|
+
* Requires an injection context - it observes through `injectContainerSize`,
|
|
2163
|
+
* so the observer is scoped to the caller's `DestroyRef`. A field initialiser
|
|
2164
|
+
* on the stepper component is one; a bare call from a lifecycle hook is not.
|
|
2025
2165
|
*
|
|
2166
|
+
* @param host The `<cngx-stepper>` host element, which is its own container.
|
|
2026
2167
|
* @category common/stepper
|
|
2168
|
+
* @relatedTo createStepperDisplayMode, injectContainerSize
|
|
2027
2169
|
*/
|
|
2028
|
-
function
|
|
2029
|
-
|
|
2170
|
+
function injectStepperCollapse(host) {
|
|
2171
|
+
const raw = injectContainerSize(host).property('--cngx-stepper-collapse', host, '::after');
|
|
2172
|
+
return computed(() => raw() === '1');
|
|
2030
2173
|
}
|
|
2031
2174
|
/**
|
|
2032
|
-
* Resolves the active stepper display mode by combining
|
|
2033
|
-
*
|
|
2034
|
-
* `'classic'` keeps the full strip; `'text'` /
|
|
2035
|
-
* matching compact variant
|
|
2175
|
+
* Resolves the active stepper display mode by combining the collapse *signal*
|
|
2176
|
+
* - whether the stepper's own container is narrow - with the configured
|
|
2177
|
+
* `mobileCollapse` policy. `'classic'` keeps the full strip; `'text'` /
|
|
2178
|
+
* `'dots'` swap to the matching compact variant, `'off'` stays classic at any
|
|
2179
|
+
* width.
|
|
2036
2180
|
*
|
|
2181
|
+
* The factory takes no DOM API and holds no threshold: *where* the collapse
|
|
2182
|
+
* happens is a `@container` rule in the stepper stylesheet, *what* it collapses
|
|
2183
|
+
* into is this policy. See `core-concepts/responsive-by-default.md`.
|
|
2184
|
+
*
|
|
2185
|
+
* @param collapsed `true` while the container sits below the collapse rung.
|
|
2186
|
+
* @param mobileCollapse The configured collapse policy, read lazily.
|
|
2037
2187
|
* @category common/stepper
|
|
2038
2188
|
*/
|
|
2039
|
-
function createStepperDisplayMode(
|
|
2040
|
-
const viewport = createMobileViewportSignal(mediaQuery, destroyRef);
|
|
2189
|
+
function createStepperDisplayMode(collapsed, mobileCollapse) {
|
|
2041
2190
|
return computed(() => {
|
|
2042
|
-
if (!
|
|
2191
|
+
if (!collapsed()) {
|
|
2043
2192
|
return 'classic';
|
|
2044
2193
|
}
|
|
2045
2194
|
const mode = mobileCollapse() ?? 'text';
|
|
@@ -2048,31 +2197,23 @@ function createStepperDisplayMode(mediaQuery, mobileCollapse, destroyRef) {
|
|
|
2048
2197
|
}
|
|
2049
2198
|
|
|
2050
2199
|
/**
|
|
2051
|
-
* Tracks an element's content-box width as a reactive signal
|
|
2052
|
-
* `
|
|
2053
|
-
* `
|
|
2054
|
-
* `
|
|
2055
|
-
*
|
|
2056
|
-
*
|
|
2200
|
+
* Tracks an element's content-box width as a reactive signal, over the shared
|
|
2201
|
+
* resize kernel (`createResizeSignal`) rather than a hand-rolled
|
|
2202
|
+
* `ResizeObserver`. Not the `CngxResizeObserver` directive - that can only
|
|
2203
|
+
* attach through `hostDirectives`, and this factory is called from a field
|
|
2204
|
+
* initialiser. In SSR / non-DOM environments the signal stays `0` and no
|
|
2205
|
+
* observer is wired.
|
|
2057
2206
|
*/
|
|
2058
2207
|
function createElementWidthSignal(element, destroyRef) {
|
|
2059
|
-
const
|
|
2060
|
-
|
|
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();
|
|
2208
|
+
const entry = createResizeSignal(element, 'content-box', destroyRef, globalThis);
|
|
2209
|
+
return computed(() => entry()?.contentRect.width ?? 0);
|
|
2069
2210
|
}
|
|
2070
2211
|
/**
|
|
2071
2212
|
* Resolves the classic strip's density rung from its own container
|
|
2072
2213
|
* width against the step count and two per-step px thresholds. Pure
|
|
2073
|
-
* `create*` factory, sibling to `createStepperDisplayMode` -
|
|
2074
|
-
*
|
|
2075
|
-
* `
|
|
2214
|
+
* `create*` factory, sibling to `createStepperDisplayMode` - both derive
|
|
2215
|
+
* a rung from the space the stepper was given and return a single
|
|
2216
|
+
* `Signal`; this one measures, the other reads what CSS resolved.
|
|
2076
2217
|
*
|
|
2077
2218
|
* `'comfortable'` density short-circuits to `'full'` (no measurement
|
|
2078
2219
|
* dependency). Before the first measurement (`width === 0`) and for an
|
|
@@ -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
|
}
|
|
@@ -2355,7 +2552,10 @@ function createStepperStateView(inputs) {
|
|
|
2355
2552
|
* (the classic mobile-collapse summary) are a guaranteed no-op.
|
|
2356
2553
|
*
|
|
2357
2554
|
* Pure helper - reads signals at call time, intended to be wrapped in the
|
|
2358
|
-
* caller's `computed()`.
|
|
2555
|
+
* caller's `computed()`. The phrase feeds live regions, so the step label
|
|
2556
|
+
* is read untracked: a label that follows a language switch must not
|
|
2557
|
+
* re-announce the line. Pass the i18n bundle as an untracked snapshot for
|
|
2558
|
+
* the same reason.
|
|
2359
2559
|
*
|
|
2360
2560
|
* @category common/stepper
|
|
2361
2561
|
* @since 0.1.0
|
|
@@ -2371,8 +2571,10 @@ function resolveStepperErrorSummary(view, stepsOnly, i18n, messageOf) {
|
|
|
2371
2571
|
if (custom !== undefined && custom !== '') {
|
|
2372
2572
|
return custom;
|
|
2373
2573
|
}
|
|
2374
|
-
const label = node
|
|
2375
|
-
return label
|
|
2574
|
+
const label = node ? untracked(node.label) : undefined;
|
|
2575
|
+
return label
|
|
2576
|
+
? i18n.stepWithDetail(label, i18n.statusLabels.errored)
|
|
2577
|
+
: i18n.statusLabels.errored;
|
|
2376
2578
|
}
|
|
2377
2579
|
return i18n.stepHasErrors(count);
|
|
2378
2580
|
}
|
|
@@ -2475,12 +2677,12 @@ function createStepperSlotContextBuilders(inputs) {
|
|
|
2475
2677
|
// Resolution order: direct [error] string > first aggregator label >
|
|
2476
2678
|
// i18n errored status phrase. Always non-empty so a bare
|
|
2477
2679
|
// `{{ message }}` template renders a reason.
|
|
2478
|
-
const message = node.errorMessage?.() ?? errorLabels[0] ?? i18n.statusLabels.errored;
|
|
2680
|
+
const message = node.errorMessage?.() ?? errorLabels[0] ?? i18n().statusLabels.errored;
|
|
2479
2681
|
return { node, message, errorLabels, announcement };
|
|
2480
2682
|
});
|
|
2481
2683
|
const groupHeaderContextFor = memoizeByNode((node) => ({
|
|
2482
2684
|
group: node,
|
|
2483
|
-
expanded:
|
|
2685
|
+
expanded: !(inputs.isGroupCollapsed?.(node) ?? false),
|
|
2484
2686
|
status: node.state(),
|
|
2485
2687
|
}));
|
|
2486
2688
|
const stepLabelContextFor = memoizeByNode((node) => ({
|
|
@@ -2527,11 +2729,32 @@ function createStepperSlotContextBuilders(inputs) {
|
|
|
2527
2729
|
* @internal
|
|
2528
2730
|
*/
|
|
2529
2731
|
function createStepperAnnouncementBuilders(inputs) {
|
|
2530
|
-
const { presenter, stepsOnly
|
|
2732
|
+
const { presenter, stepsOnly } = inputs;
|
|
2733
|
+
// The live region reads copy untracked: a language switch must not
|
|
2734
|
+
// re-speak the last phrase. The next commit transition speaks the new
|
|
2735
|
+
// language.
|
|
2531
2736
|
const liveAnnouncement = computed(() => {
|
|
2532
2737
|
const current = presenter.commitTransition.current();
|
|
2533
2738
|
if (current === 'pending') {
|
|
2534
|
-
return i18n.commitInFlight;
|
|
2739
|
+
return untracked(() => inputs.i18n().commitInFlight);
|
|
2740
|
+
}
|
|
2741
|
+
if (current === 'success' &&
|
|
2742
|
+
presenter.commitTransition.previous() === 'pending' &&
|
|
2743
|
+
(presenter.commitMode?.() ?? 'pessimistic') === 'pessimistic') {
|
|
2744
|
+
// Announce where the commit landed - without this arm a pessimistic
|
|
2745
|
+
// accept moves the step silently (the pending phrase just goes quiet).
|
|
2746
|
+
// Pessimistic only: an optimistic accept already moved (and thereby
|
|
2747
|
+
// announced) the step at dispatch - repeating it here would
|
|
2748
|
+
// double-announce a position the SR user already reached.
|
|
2749
|
+
const landed = presenter.stepsOnly()[presenter.activeStepIndex()];
|
|
2750
|
+
if (landed) {
|
|
2751
|
+
// A step label can itself derive from copy (the Material bridge's
|
|
2752
|
+
// `Step <id>` fallback), so it is read untracked too.
|
|
2753
|
+
const label = untracked(landed.label);
|
|
2754
|
+
const count = presenter.stepsOnly().length;
|
|
2755
|
+
return untracked(() => inputs.i18n().selectedStep(label, landed.flatIndex + 1, count));
|
|
2756
|
+
}
|
|
2757
|
+
return '';
|
|
2535
2758
|
}
|
|
2536
2759
|
if (current === 'error') {
|
|
2537
2760
|
// Sync commit-handler errors collapse pending -> error in one signal
|
|
@@ -2540,16 +2763,18 @@ function createStepperAnnouncementBuilders(inputs) {
|
|
|
2540
2763
|
const failedIdx = presenter.lastFailedIndex();
|
|
2541
2764
|
const originIdx = presenter.originIndexDuringCommit();
|
|
2542
2765
|
if (failedIdx !== undefined && originIdx !== undefined) {
|
|
2543
|
-
const
|
|
2766
|
+
const origin = stepsOnly()[originIdx];
|
|
2767
|
+
const originLabel = origin ? untracked(origin.label) : undefined;
|
|
2544
2768
|
if (originLabel) {
|
|
2545
|
-
return i18n.commitRolledBackTo(originLabel);
|
|
2769
|
+
return untracked(() => inputs.i18n().commitRolledBackTo(originLabel));
|
|
2546
2770
|
}
|
|
2547
2771
|
}
|
|
2548
|
-
return i18n.commitFailedRetry;
|
|
2772
|
+
return untracked(() => inputs.i18n().commitFailedRetry);
|
|
2549
2773
|
}
|
|
2550
2774
|
return '';
|
|
2551
2775
|
}, ...(ngDevMode ? [{ debugName: "liveAnnouncement" }] : /* istanbul ignore next */ []));
|
|
2552
2776
|
const statusPhrase = (node) => {
|
|
2777
|
+
const i18n = inputs.i18n();
|
|
2553
2778
|
const aggregator = node.errorAggregator?.();
|
|
2554
2779
|
let base = aggregator?.shouldShow?.() ? (aggregator.announcement?.() ?? '') : '';
|
|
2555
2780
|
if (!base && node.kind === 'step') {
|
|
@@ -2562,25 +2787,86 @@ function createStepperAnnouncementBuilders(inputs) {
|
|
|
2562
2787
|
return '';
|
|
2563
2788
|
}
|
|
2564
2789
|
return node.kind === 'step' && node.flatIndex === presenter.lastFailedIndex()
|
|
2565
|
-
?
|
|
2790
|
+
? i18n.stepRolledBack(base)
|
|
2566
2791
|
: base;
|
|
2567
2792
|
};
|
|
2793
|
+
// Converged on `statusLabels` - the same phrase map the status pill
|
|
2794
|
+
// (resolveStepperStatusLabel) renders, so a group's SR description can
|
|
2795
|
+
// never disagree with its visible pill.
|
|
2568
2796
|
const groupStatusPhrase = (node) => {
|
|
2797
|
+
const i18n = inputs.i18n();
|
|
2569
2798
|
const status = node.state();
|
|
2570
2799
|
if (status === 'error') {
|
|
2571
|
-
return i18n.
|
|
2800
|
+
return i18n.statusLabels.errored;
|
|
2572
2801
|
}
|
|
2573
2802
|
if (status === 'success') {
|
|
2574
|
-
return i18n.
|
|
2803
|
+
return i18n.statusLabels.done;
|
|
2575
2804
|
}
|
|
2576
2805
|
return '';
|
|
2577
2806
|
};
|
|
2807
|
+
const headerStatusPhrase = (node) => {
|
|
2808
|
+
const phrase = statusPhrase(node);
|
|
2809
|
+
const status = glyphStatus(node, inputs.i18n());
|
|
2810
|
+
if (!status) {
|
|
2811
|
+
return phrase;
|
|
2812
|
+
}
|
|
2813
|
+
return phrase ? inputs.i18n().stepWithDetail(phrase, status) : status;
|
|
2814
|
+
};
|
|
2578
2815
|
const descriptorId = (node) => `${node.id}-desc`;
|
|
2579
2816
|
const describedBy = (node) => {
|
|
2580
|
-
const phrase = node.kind === 'step' ?
|
|
2817
|
+
const phrase = node.kind === 'step' ? headerStatusPhrase(node) : groupStatusPhrase(node);
|
|
2581
2818
|
return phrase ? descriptorId(node) : null;
|
|
2582
2819
|
};
|
|
2583
|
-
return {
|
|
2820
|
+
return {
|
|
2821
|
+
liveAnnouncement,
|
|
2822
|
+
statusPhrase,
|
|
2823
|
+
headerStatusPhrase,
|
|
2824
|
+
groupStatusPhrase,
|
|
2825
|
+
descriptorId,
|
|
2826
|
+
describedBy,
|
|
2827
|
+
};
|
|
2828
|
+
}
|
|
2829
|
+
/** The status word behind a skin's done / errored glyph, or `''`. */
|
|
2830
|
+
function glyphStatus(node, i18n) {
|
|
2831
|
+
const state = node.state();
|
|
2832
|
+
if (state === 'error') {
|
|
2833
|
+
return i18n.statusLabels.errored;
|
|
2834
|
+
}
|
|
2835
|
+
return state === 'success' ? i18n.statusLabels.done : '';
|
|
2836
|
+
}
|
|
2837
|
+
/**
|
|
2838
|
+
* Build the mode-aware panel ref surface. The dots branch always
|
|
2839
|
+
* renders one dot per step; the classic strip only renders headers the
|
|
2840
|
+
* group-collapse policy exposes; the text branch has no header element
|
|
2841
|
+
* at all. A panel must never reference an id that is not in the DOM -
|
|
2842
|
+
* a dangling IDREF names the region as empty - so header-less panels
|
|
2843
|
+
* self-name via `aria-label` and drop the describedby reference (the
|
|
2844
|
+
* classic descriptor spans live inside the strip headers; the
|
|
2845
|
+
* collapsed branches mount theirs inside the panel).
|
|
2846
|
+
*
|
|
2847
|
+
* @internal
|
|
2848
|
+
*/
|
|
2849
|
+
function createStepperPanelRefs(inputs) {
|
|
2850
|
+
const { displayMode, visibleStripNodes, headerIdFor, describedByFor } = inputs;
|
|
2851
|
+
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)) });
|
|
2852
|
+
const labelledBy = (node) => {
|
|
2853
|
+
const mode = displayMode();
|
|
2854
|
+
if (mode === 'text') {
|
|
2855
|
+
return null;
|
|
2856
|
+
}
|
|
2857
|
+
if (mode === 'dots') {
|
|
2858
|
+
return headerIdFor(node);
|
|
2859
|
+
}
|
|
2860
|
+
return renderedHeaderIds().has(node.id) ? headerIdFor(node) : null;
|
|
2861
|
+
};
|
|
2862
|
+
const ariaLabel = (node) => (labelledBy(node) ? null : node.label());
|
|
2863
|
+
const describedBy = (node) => {
|
|
2864
|
+
if (displayMode() === 'classic' && !renderedHeaderIds().has(node.id)) {
|
|
2865
|
+
return null;
|
|
2866
|
+
}
|
|
2867
|
+
return describedByFor(node);
|
|
2868
|
+
};
|
|
2869
|
+
return { labelledBy, ariaLabel, describedBy };
|
|
2584
2870
|
}
|
|
2585
2871
|
|
|
2586
2872
|
/**
|
|
@@ -2594,10 +2880,10 @@ function createStepperAnnouncementBuilders(inputs) {
|
|
|
2594
2880
|
* `CNGX_STEPPER_CONFIG.mobileSwipe` -> library default `true`.
|
|
2595
2881
|
*
|
|
2596
2882
|
* Direction routing is asymmetric, matching the presenter's existing
|
|
2597
|
-
* navigation surface: `left`
|
|
2598
|
-
*
|
|
2599
|
-
*
|
|
2600
|
-
*
|
|
2883
|
+
* navigation surface: the forward swipe (`left` under `ltr`, `right`
|
|
2884
|
+
* under `rtl`) -> `selectNext()` -> `select()` (linear gate + commit
|
|
2885
|
+
* window apply identically to a click); the back swipe ->
|
|
2886
|
+
* `selectPrevious()`, gated on `busy()` like the strip back-arrow.
|
|
2601
2887
|
*
|
|
2602
2888
|
* @category common/stepper
|
|
2603
2889
|
* @docsKind primary
|
|
@@ -2613,18 +2899,29 @@ class CngxStepperSwipeNav {
|
|
|
2613
2899
|
mobileSwipe = input(undefined, ...(ngDevMode ? [{ debugName: "mobileSwipe" }] : /* istanbul ignore next */ []));
|
|
2614
2900
|
host = inject(CNGX_STEPPER_HOST);
|
|
2615
2901
|
config = injectStepperConfig();
|
|
2902
|
+
direction = injectDirection();
|
|
2616
2903
|
/** Resolved enabled flag (Input -> config -> default(true)). Boolean output, no `equal` fn required. */
|
|
2617
2904
|
swipeEnabled = computed(() => this.mobileSwipe() ?? this.config.mobileSwipe ?? true, ...(ngDevMode ? [{ debugName: "swipeEnabled" }] : /* istanbul ignore next */ []));
|
|
2618
2905
|
/**
|
|
2619
|
-
* Route a swipe direction into the presenter.
|
|
2620
|
-
*
|
|
2621
|
-
*
|
|
2906
|
+
* Route a swipe direction into the presenter. The inline mapping
|
|
2907
|
+
* resolves against the document direction like the keyboard path:
|
|
2908
|
+
* under `ltr` a left swipe advances; under `rtl` the roles flip.
|
|
2909
|
+
* Vertical directions are ignored. The back path waits while a
|
|
2910
|
+
* commit is in flight - a stray gesture must not supersede it (the
|
|
2911
|
+
* programmatic `selectPrevious()` cancels deliberately).
|
|
2622
2912
|
*/
|
|
2623
2913
|
handleSwipe(direction) {
|
|
2624
|
-
if (direction
|
|
2914
|
+
if (direction !== 'left' && direction !== 'right') {
|
|
2915
|
+
return;
|
|
2916
|
+
}
|
|
2917
|
+
const forward = direction === (this.direction() === 'rtl' ? 'right' : 'left');
|
|
2918
|
+
if (forward) {
|
|
2625
2919
|
this.host.selectNext();
|
|
2626
2920
|
}
|
|
2627
|
-
else
|
|
2921
|
+
else {
|
|
2922
|
+
if (this.host.busy()) {
|
|
2923
|
+
return;
|
|
2924
|
+
}
|
|
2628
2925
|
this.host.selectPrevious();
|
|
2629
2926
|
}
|
|
2630
2927
|
}
|
|
@@ -2674,7 +2971,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2674
2971
|
* <example-url>http://localhost:4200/#/ui/stepper/stepper-count/multi-instance-format-overrides</example-url>
|
|
2675
2972
|
*/
|
|
2676
2973
|
class CngxStepperCount {
|
|
2677
|
-
/**
|
|
2974
|
+
/**
|
|
2975
|
+
* When `true`, wraps the rendered string in an `aria-live="polite"` span.
|
|
2976
|
+
* Set it once per instance: toggling it swaps the span, and the region
|
|
2977
|
+
* content present at that moment is not announced.
|
|
2978
|
+
*/
|
|
2678
2979
|
live = input(true, ...(ngDevMode ? [{ debugName: "live" }] : /* istanbul ignore next */ []));
|
|
2679
2980
|
/**
|
|
2680
2981
|
* Per-instance format override. Receives `(current, total)` where
|
|
@@ -2697,25 +2998,61 @@ class CngxStepperCount {
|
|
|
2697
2998
|
injectedHost = inject(CNGX_STEPPER_HOST, { optional: true });
|
|
2698
2999
|
i18n = injectStepperI18n();
|
|
2699
3000
|
resolvedHost = computed(() => this.host() ?? this.injectedHost, ...(ngDevMode ? [{ debugName: "resolvedHost" }] : /* istanbul ignore next */ []));
|
|
2700
|
-
/**
|
|
2701
|
-
|
|
3001
|
+
/** 1-based active position and step total, or `null` while there is nothing to count. */
|
|
3002
|
+
position = computed(() => {
|
|
2702
3003
|
const host = this.resolvedHost();
|
|
2703
3004
|
if (!host) {
|
|
2704
|
-
return
|
|
3005
|
+
return null;
|
|
2705
3006
|
}
|
|
2706
|
-
const current = host.activeStepIndex() + 1;
|
|
2707
3007
|
const total = host.stepsOnly().length;
|
|
2708
|
-
|
|
2709
|
-
|
|
3008
|
+
if (total === 0) {
|
|
3009
|
+
return null;
|
|
3010
|
+
}
|
|
3011
|
+
// Clamp against the live total - a transiently out-of-range active
|
|
3012
|
+
// index (steps removed at runtime) must not render "Step 5 of 3".
|
|
3013
|
+
const current = Math.min(Math.max(host.activeStepIndex() + 1, 1), total);
|
|
3014
|
+
return { current, total };
|
|
3015
|
+
}, { ...(ngDevMode ? { debugName: "position" } : /* istanbul ignore next */ {}), equal: (a, b) => a?.current === b?.current && a?.total === b?.total });
|
|
3016
|
+
/** Resolved caption - reactive on activeStepIndex / stepsOnly / format / i18n. */
|
|
3017
|
+
label = computed(() => {
|
|
3018
|
+
const position = this.position();
|
|
3019
|
+
if (!position) {
|
|
3020
|
+
return '';
|
|
3021
|
+
}
|
|
3022
|
+
const fmt = this.format() ?? this.i18n().textStepperFormat;
|
|
3023
|
+
return fmt(position.current, position.total);
|
|
2710
3024
|
}, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
3025
|
+
/**
|
|
3026
|
+
* {@link label} for the live span: the bundle and a consumer `format`
|
|
3027
|
+
* (which may itself be language-dependent) are read untracked.
|
|
3028
|
+
*/
|
|
3029
|
+
liveLabel = computed(() => {
|
|
3030
|
+
const position = this.position();
|
|
3031
|
+
if (!position) {
|
|
3032
|
+
return '';
|
|
3033
|
+
}
|
|
3034
|
+
return untracked(() => (this.format() ?? this.i18n().textStepperFormat)(position.current, position.total));
|
|
3035
|
+
}, ...(ngDevMode ? [{ debugName: "liveLabel" }] : /* istanbul ignore next */ []));
|
|
2711
3036
|
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.
|
|
3037
|
+
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: `
|
|
3038
|
+
@if (live()) {
|
|
3039
|
+
<span aria-live="polite">{{ liveLabel() }}</span>
|
|
3040
|
+
} @else {
|
|
3041
|
+
<span>{{ label() }}</span>
|
|
3042
|
+
}
|
|
3043
|
+
`, 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
3044
|
}
|
|
2714
3045
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepperCount, decorators: [{
|
|
2715
3046
|
type: Component,
|
|
2716
|
-
args: [{ selector: 'cngx-stepper-count', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template:
|
|
3047
|
+
args: [{ selector: 'cngx-stepper-count', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: `
|
|
3048
|
+
@if (live()) {
|
|
3049
|
+
<span aria-live="polite">{{ liveLabel() }}</span>
|
|
3050
|
+
} @else {
|
|
3051
|
+
<span>{{ label() }}</span>
|
|
3052
|
+
}
|
|
3053
|
+
`, host: {
|
|
2717
3054
|
class: 'cngx-stepper-count',
|
|
2718
|
-
}, styles: [".cngx-stepper-count span{unicode-bidi:var(--cngx-stepper-count-bidi, isolate);direction:var(--cngx-stepper-count-direction,
|
|
3055
|
+
}, styles: [".cngx-stepper-count span{unicode-bidi:var(--cngx-stepper-count-bidi, isolate);direction:var(--cngx-stepper-count-direction, inherit)}\n"] }]
|
|
2719
3056
|
}], 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
3057
|
|
|
2721
3058
|
/**
|
|
@@ -2756,7 +3093,41 @@ class CngxStepperPrevious {
|
|
|
2756
3093
|
injectedHost = inject(CNGX_STEPPER_HOST, { optional: true });
|
|
2757
3094
|
resolvedHost = computed(() => this.host() ?? this.injectedHost, ...(ngDevMode ? [{ debugName: "resolvedHost" }] : /* istanbul ignore next */ []));
|
|
2758
3095
|
coPlacedAsyncClick = inject(CngxAsyncClick, { self: true, optional: true });
|
|
3096
|
+
elementRef = inject(ElementRef);
|
|
3097
|
+
i18n = injectStepperI18n();
|
|
2759
3098
|
constructor() {
|
|
3099
|
+
// Fallback accessible name for icon-only hosts: while the element
|
|
3100
|
+
// renders no text and the consumer supplied no label of their own,
|
|
3101
|
+
// the i18n `previousStep` phrase fills the gap. Re-checked after every
|
|
3102
|
+
// render (cheap string read) so a late-arriving visible label wins
|
|
3103
|
+
// again - a forced aria-label over visible text would break
|
|
3104
|
+
// label-in-name (WCAG 2.5.3). The data flag marks ownership so a
|
|
3105
|
+
// consumer-authored aria-label is never touched.
|
|
3106
|
+
afterEveryRender(() => {
|
|
3107
|
+
const el = this.elementRef.nativeElement;
|
|
3108
|
+
const ownsFallback = el.hasAttribute('data-cngx-label-fallback');
|
|
3109
|
+
const consumerLabelled = (!ownsFallback && el.hasAttribute('aria-label')) || el.hasAttribute('aria-labelledby');
|
|
3110
|
+
if (consumerLabelled) {
|
|
3111
|
+
return;
|
|
3112
|
+
}
|
|
3113
|
+
const hasText = (el.textContent ?? '').trim() !== '';
|
|
3114
|
+
if (hasText && ownsFallback) {
|
|
3115
|
+
el.removeAttribute('aria-label');
|
|
3116
|
+
el.removeAttribute('data-cngx-label-fallback');
|
|
3117
|
+
}
|
|
3118
|
+
else if (!hasText && !ownsFallback) {
|
|
3119
|
+
el.setAttribute('aria-label', this.i18n().previousStep);
|
|
3120
|
+
el.setAttribute('data-cngx-label-fallback', '');
|
|
3121
|
+
}
|
|
3122
|
+
});
|
|
3123
|
+
// A language switch re-labels a fallback this directive owns.
|
|
3124
|
+
afterRenderEffect(() => {
|
|
3125
|
+
const label = this.i18n().previousStep;
|
|
3126
|
+
const el = this.elementRef.nativeElement;
|
|
3127
|
+
if (el.hasAttribute('data-cngx-label-fallback')) {
|
|
3128
|
+
el.setAttribute('aria-label', label);
|
|
3129
|
+
}
|
|
3130
|
+
});
|
|
2760
3131
|
if (isDevMode() && this.coPlacedAsyncClick) {
|
|
2761
3132
|
console.warn('CngxStepperPrevious: [cngxStepperPrevious] and [cngxAsyncClick] on the same element ' +
|
|
2762
3133
|
'both gate aria-disabled. Use one or the other.');
|
|
@@ -2833,15 +3204,49 @@ class CngxStepperNext {
|
|
|
2833
3204
|
injectedHost = inject(CNGX_STEPPER_HOST, { optional: true });
|
|
2834
3205
|
resolvedHost = computed(() => this.host() ?? this.injectedHost, ...(ngDevMode ? [{ debugName: "resolvedHost" }] : /* istanbul ignore next */ []));
|
|
2835
3206
|
coPlacedAsyncClick = inject(CngxAsyncClick, { self: true, optional: true });
|
|
3207
|
+
elementRef = inject(ElementRef);
|
|
3208
|
+
i18n = injectStepperI18n();
|
|
2836
3209
|
/** `true` when advancing is unavailable: no enabled next step or commit busy. */
|
|
2837
3210
|
disabled = computed(() => {
|
|
2838
3211
|
const host = this.resolvedHost();
|
|
2839
3212
|
return !host || !host.canGoNext() || host.busy();
|
|
2840
3213
|
}, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
2841
3214
|
constructor() {
|
|
3215
|
+
// Fallback accessible name for icon-only hosts: while the element
|
|
3216
|
+
// renders no text and the consumer supplied no label of their own,
|
|
3217
|
+
// the i18n `nextStep` phrase fills the gap. Re-checked after every
|
|
3218
|
+
// render (cheap string read) so a late-arriving visible label wins
|
|
3219
|
+
// again - a forced aria-label over visible text would break
|
|
3220
|
+
// label-in-name (WCAG 2.5.3). The data flag marks ownership so a
|
|
3221
|
+
// consumer-authored aria-label is never touched.
|
|
3222
|
+
afterEveryRender(() => {
|
|
3223
|
+
const el = this.elementRef.nativeElement;
|
|
3224
|
+
const ownsFallback = el.hasAttribute('data-cngx-label-fallback');
|
|
3225
|
+
const consumerLabelled = (!ownsFallback && el.hasAttribute('aria-label')) || el.hasAttribute('aria-labelledby');
|
|
3226
|
+
if (consumerLabelled) {
|
|
3227
|
+
return;
|
|
3228
|
+
}
|
|
3229
|
+
const hasText = (el.textContent ?? '').trim() !== '';
|
|
3230
|
+
if (hasText && ownsFallback) {
|
|
3231
|
+
el.removeAttribute('aria-label');
|
|
3232
|
+
el.removeAttribute('data-cngx-label-fallback');
|
|
3233
|
+
}
|
|
3234
|
+
else if (!hasText && !ownsFallback) {
|
|
3235
|
+
el.setAttribute('aria-label', this.i18n().nextStep);
|
|
3236
|
+
el.setAttribute('data-cngx-label-fallback', '');
|
|
3237
|
+
}
|
|
3238
|
+
});
|
|
3239
|
+
// A language switch re-labels a fallback this directive owns.
|
|
3240
|
+
afterRenderEffect(() => {
|
|
3241
|
+
const label = this.i18n().nextStep;
|
|
3242
|
+
const el = this.elementRef.nativeElement;
|
|
3243
|
+
if (el.hasAttribute('data-cngx-label-fallback')) {
|
|
3244
|
+
el.setAttribute('aria-label', label);
|
|
3245
|
+
}
|
|
3246
|
+
});
|
|
2842
3247
|
if (isDevMode() && this.coPlacedAsyncClick) {
|
|
2843
3248
|
console.warn('CngxStepperNext: [cngxStepperNext] and [cngxAsyncClick] on the same element ' +
|
|
2844
|
-
'both gate aria-disabled
|
|
3249
|
+
'both gate aria-disabled. Use one or the other.');
|
|
2845
3250
|
}
|
|
2846
3251
|
}
|
|
2847
3252
|
/** @internal */
|
|
@@ -2917,7 +3322,9 @@ class CngxStepperComplete {
|
|
|
2917
3322
|
const tracker = createTransitionTracker(() => this.runner.status());
|
|
2918
3323
|
effect(() => {
|
|
2919
3324
|
if (tracker.current() === 'success' && tracker.previous() !== 'success') {
|
|
2920
|
-
|
|
3325
|
+
// Consumer handlers run outside the tracking context so their
|
|
3326
|
+
// ambient signal reads cannot widen this effect's dep graph.
|
|
3327
|
+
untracked(() => this.completed.emit());
|
|
2921
3328
|
}
|
|
2922
3329
|
});
|
|
2923
3330
|
}
|
|
@@ -2983,6 +3390,7 @@ function createStepperHostProxy(supplier) {
|
|
|
2983
3390
|
activeStepId: computed(() => supplier()?.activeStepId() ?? null),
|
|
2984
3391
|
activeGroupId: computed(() => supplier()?.activeGroupId() ?? null),
|
|
2985
3392
|
linear: computed(() => supplier()?.linear() ?? false),
|
|
3393
|
+
commitMode: computed(() => supplier()?.commitMode?.() ?? 'pessimistic'),
|
|
2986
3394
|
orientation: computed(() => supplier()?.orientation() ?? 'horizontal'),
|
|
2987
3395
|
intendedStepIndex: computed(() => supplier()?.intendedStepIndex()),
|
|
2988
3396
|
lastFailedIndex: computed(() => supplier()?.lastFailedIndex()),
|
|
@@ -3104,7 +3512,9 @@ function provideCngxStepper(...features) {
|
|
|
3104
3512
|
function provideCngxStepperAt(...features) {
|
|
3105
3513
|
const { config, i18n } = partitionFeatures(features);
|
|
3106
3514
|
return [
|
|
3107
|
-
|
|
3515
|
+
// Gate like i18n: an i18n-only call must not plant an empty config
|
|
3516
|
+
// at this injector level and shadow an app-wide provideStepperConfig.
|
|
3517
|
+
...(config.length > 0 ? provideStepperConfigAt(...config) : []),
|
|
3108
3518
|
...(i18n.length > 0 ? [provideStepperI18n(...i18n)] : []),
|
|
3109
3519
|
];
|
|
3110
3520
|
}
|
|
@@ -3123,5 +3533,5 @@ function provideCngxStepperAt(...features) {
|
|
|
3123
3533
|
* Generated bundle index. Do not edit.
|
|
3124
3534
|
*/
|
|
3125
3535
|
|
|
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, STEPPER_DEFAULT_DENSITY_BREAKPOINTS,
|
|
3536
|
+
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, STEPPER_DEFAULT_DENSITY_BREAKPOINTS, createStepperAccname, createStepperAnnouncementBuilders, createStepperCommitHandler, createStepperDisplayMode, createStepperGroupNavigation, createStepperGroupSummary, createStepperHostAttrs, createStepperHostProxy, createStepperPanelRefs, createStepperSlotContextBuilders, createStepperStateView, createStepperStripKeyboardNav, createStepperTemplateBindings, createStripDensity, 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
3537
|
//# sourceMappingURL=cngx-common-stepper.mjs.map
|