@cngx/common 0.1.0-rc.6 → 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.
Files changed (72) hide show
  1. package/card/README.md +2 -1
  2. package/chart/README.md +85 -0
  3. package/command/README.md +157 -0
  4. package/data/README.md +33 -1
  5. package/dialog/README.md +23 -1
  6. package/fesm2022/cngx-common-a11y.mjs +356 -180
  7. package/fesm2022/cngx-common-a11y.mjs.map +1 -1
  8. package/fesm2022/cngx-common-audio.mjs +84 -42
  9. package/fesm2022/cngx-common-audio.mjs.map +1 -1
  10. package/fesm2022/cngx-common-card.mjs +311 -53
  11. package/fesm2022/cngx-common-card.mjs.map +1 -1
  12. package/fesm2022/cngx-common-chart.mjs +4360 -1625
  13. package/fesm2022/cngx-common-chart.mjs.map +1 -1
  14. package/fesm2022/cngx-common-command.mjs +171 -0
  15. package/fesm2022/cngx-common-command.mjs.map +1 -0
  16. package/fesm2022/cngx-common-data.mjs +1556 -616
  17. package/fesm2022/cngx-common-data.mjs.map +1 -1
  18. package/fesm2022/cngx-common-dialog.mjs +518 -112
  19. package/fesm2022/cngx-common-dialog.mjs.map +1 -1
  20. package/fesm2022/cngx-common-display.mjs +468 -87
  21. package/fesm2022/cngx-common-display.mjs.map +1 -1
  22. package/fesm2022/cngx-common-interactive.mjs +2725 -1303
  23. package/fesm2022/cngx-common-interactive.mjs.map +1 -1
  24. package/fesm2022/cngx-common-layout.mjs +943 -164
  25. package/fesm2022/cngx-common-layout.mjs.map +1 -1
  26. package/fesm2022/cngx-common-popover.mjs +769 -103
  27. package/fesm2022/cngx-common-popover.mjs.map +1 -1
  28. package/fesm2022/cngx-common-stepper.mjs +816 -348
  29. package/fesm2022/cngx-common-stepper.mjs.map +1 -1
  30. package/fesm2022/cngx-common-tabs.mjs +2330 -1554
  31. package/fesm2022/cngx-common-tabs.mjs.map +1 -1
  32. package/fesm2022/cngx-common-timeline.mjs +1170 -0
  33. package/fesm2022/cngx-common-timeline.mjs.map +1 -0
  34. package/fesm2022/cngx-common.mjs +2 -2
  35. package/fesm2022/cngx-common.mjs.map +1 -1
  36. package/interactive/README.md +15 -4
  37. package/layout/README.md +21 -1
  38. package/package.json +11 -1
  39. package/popover/README.md +18 -2
  40. package/stepper/README.md +7 -5
  41. package/theming/components/cngx-accordion.css +4 -1
  42. package/theming/components/cngx-backdrop.css +12 -0
  43. package/theming/components/cngx-badge.css +22 -0
  44. package/theming/components/cngx-bottom-sheet.css +14 -2
  45. package/theming/components/cngx-breadcrumb.css +8 -0
  46. package/theming/components/cngx-button-toggle.css +73 -5
  47. package/theming/components/cngx-data-grid.css +234 -1
  48. package/theming/components/cngx-dialog.css +25 -0
  49. package/theming/components/cngx-divider.css +12 -0
  50. package/theming/components/cngx-listbox.css +48 -12
  51. package/theming/components/cngx-menu.css +91 -15
  52. package/theming/components/cngx-popover.css +24 -0
  53. package/theming/components/cngx-recycler-placeholder.css +196 -0
  54. package/theming/components/cngx-ripple.css +2 -2
  55. package/theming/components/cngx-slider.css +32 -1
  56. package/theming/components/cngx-tooltip.css +23 -0
  57. package/timeline/README.md +155 -0
  58. package/types/cngx-common-a11y.d.ts +101 -31
  59. package/types/cngx-common-audio.d.ts +32 -32
  60. package/types/cngx-common-card.d.ts +211 -20
  61. package/types/cngx-common-chart.d.ts +1605 -169
  62. package/types/cngx-common-command.d.ts +190 -0
  63. package/types/cngx-common-data.d.ts +842 -163
  64. package/types/cngx-common-dialog.d.ts +372 -28
  65. package/types/cngx-common-display.d.ts +432 -148
  66. package/types/cngx-common-interactive.d.ts +1553 -370
  67. package/types/cngx-common-layout.d.ts +613 -27
  68. package/types/cngx-common-popover.d.ts +376 -36
  69. package/types/cngx-common-stepper.d.ts +414 -114
  70. package/types/cngx-common-tabs.d.ts +597 -72
  71. package/types/cngx-common-timeline.d.ts +1125 -0
  72. package/types/cngx-common.d.ts +1 -1
@@ -1,11 +1,15 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, makeEnvironmentProviders, inject, model, input, computed, signal, isDevMode, afterNextRender, Directive, TemplateRef, contentChild, linkedSignal, DestroyRef, output, effect, untracked, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
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 { createTransitionTracker, CNGX_STATEFUL, nextUid, buildAsyncStateView } from '@cngx/core/utils';
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';
12
+ import { injectContainerSize, createResizeSignal } from '@cngx/common/layout';
9
13
  import * as i1 from '@cngx/common/interactive';
10
14
  import { CngxAsyncClick } from '@cngx/common/interactive';
11
15
 
@@ -69,13 +73,38 @@ function runStepperAction(action, fromIndex, toIndex, handlers) {
69
73
  // before the assignment binds - `sub` would be in TDZ. Declare
70
74
  // the handle on a `let` first.
71
75
  let sub = null;
76
+ let done = false;
72
77
  sub = result.subscribe({
73
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;
74
86
  safeSuccess(accept);
75
87
  sub?.unsubscribe();
76
88
  },
77
- error: (err) => safeError(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
+ },
78
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
+ }
79
108
  unsubscribe = () => sub?.unsubscribe();
80
109
  }
81
110
  else if (result != null && typeof result.then === 'function') {
@@ -105,14 +134,152 @@ const CNGX_STEPPER_COMMIT_HANDLER_FACTORY = new InjectionToken('CngxStepperCommi
105
134
  });
106
135
 
107
136
  /**
108
- * Default media query the mobile auto-collapse policy reacts to. The
109
- * literal lives on a single exported const so the runtime, the config
110
- * default, and any JSDoc cross-references stay in lockstep. Consumers
111
- * override the query via {@link withStepperMobileBreakpoint}.
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.
112
139
  *
113
- * @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
114
265
  */
115
- const STEPPER_DEFAULT_MOBILE_BREAKPOINT = '(max-width: 480px)';
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
+
116
283
  /**
117
284
  * Default per-step px thresholds for the `density: 'auto'` ladder. The
118
285
  * literal lives on a single exported const so the runtime resolver, the
@@ -140,18 +307,19 @@ const STEPPER_CONFIG_DEFAULTS = {
140
307
  densityBreakpoints: STEPPER_DEFAULT_DENSITY_BREAKPOINTS,
141
308
  connectors: false,
142
309
  mobileCollapse: 'text',
143
- mobileBreakpoint: STEPPER_DEFAULT_MOBILE_BREAKPOINT,
144
310
  mobileIndicatorPosition: 'top',
145
311
  mobileSwipe: true,
146
312
  ariaLabels: {
147
- stepperRegion: 'Stepper',
313
+ stepperRegion: CNGX_STEPPER_LANGUAGE_EN.stepperRegion,
148
314
  },
149
315
  fallbackLabels: {
150
- groupRoleDescription: 'step group',
151
- stepRoleDescription: 'stepper',
316
+ groupRoleDescription: CNGX_STEPPER_LANGUAGE_EN.groupRoleDescription,
317
+ stepRoleDescription: CNGX_STEPPER_LANGUAGE_EN.stepRoleDescription,
152
318
  },
153
319
  templates: {},
154
320
  };
321
+ /** @internal - shared empty base, so label merges over an unset key memoize. */
322
+ const NO_LABELS = {};
155
323
  /**
156
324
  * DI token for the resolved stepper config. `providedIn: 'root'` with
157
325
  * library defaults; override via {@link provideStepperConfig} (root)
@@ -164,7 +332,7 @@ const STEPPER_CONFIG_DEFAULTS = {
164
332
  */
165
333
  const CNGX_STEPPER_CONFIG = new InjectionToken('CngxStepperConfig', {
166
334
  providedIn: 'root',
167
- factory: () => STEPPER_CONFIG_DEFAULTS,
335
+ factory: () => resolveFeatures([]),
168
336
  });
169
337
  /**
170
338
  * Brands a config mutator with `_target: 'config'`. Every `with*`
@@ -251,28 +419,18 @@ function withStepperConnectors(on) {
251
419
  return defineStepperConfigFeature((cfg) => ({ ...cfg, connectors: on }));
252
420
  }
253
421
  /**
254
- * Configure the mobile auto-collapse target for `<cngx-stepper>`. Under
255
- * a narrow viewport (`max-width: 480px`), the classic strip swaps to
256
- * the chosen variant - `'text'` (default) renders `<cngx-text-stepper>`,
257
- * `'dots'` renders `<cngx-dot-stepper>`, `'off'` keeps the classic
258
- * strip. The Material twin `<cngx-mat-stepper>` ignores this setting.
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.
259
428
  *
260
429
  * @category common/stepper
261
430
  */
262
431
  function withStepperMobileCollapse(mode) {
263
432
  return defineStepperConfigFeature((cfg) => ({ ...cfg, mobileCollapse: mode }));
264
433
  }
265
- /**
266
- * Override the media query the mobile auto-collapse policy reacts to.
267
- * Default `'(max-width: 480px)'`. Useful for tablet-tier consumers
268
- * who want the collapse to engage at 768px or for design systems
269
- * aligned with `--mat-sys-breakpoint-*` tokens.
270
- *
271
- * @category common/stepper
272
- */
273
- function withStepperMobileBreakpoint(query) {
274
- return defineStepperConfigFeature((cfg) => ({ ...cfg, mobileBreakpoint: query }));
275
- }
276
434
  /**
277
435
  * Set the app-wide default position of the mobile auto-collapse
278
436
  * indicator relative to panel content. `'top'` keeps the indicator
@@ -355,25 +513,28 @@ function withStepperDensity(mode, breakpoints) {
355
513
  /**
356
514
  * Merge ARIA labels into the cascade. Keys not provided keep their
357
515
  * library defaults; per-instance overrides on the stepper still win.
516
+ * Pass a `Signal` to switch the language at runtime.
358
517
  *
359
518
  * @category common/stepper
360
519
  */
361
520
  function withStepperAriaLabels(labels) {
362
521
  return defineStepperConfigFeature((cfg) => ({
363
522
  ...cfg,
364
- ariaLabels: { ...cfg.ariaLabels, ...labels },
523
+ ariaLabels: createOverrideMerge(cfg.ariaLabels ?? NO_LABELS, labels),
365
524
  }));
366
525
  }
367
526
  /**
368
- * Merge text fallback labels (button captions, error strings) into the
369
- * cascade. Used when a slot directive is not present.
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.
370
531
  *
371
532
  * @category common/stepper
372
533
  */
373
534
  function withStepperFallbackLabels(labels) {
374
535
  return defineStepperConfigFeature((cfg) => ({
375
536
  ...cfg,
376
- fallbackLabels: { ...cfg.fallbackLabels, ...labels },
537
+ fallbackLabels: createOverrideMerge(cfg.fallbackLabels ?? NO_LABELS, labels),
377
538
  }));
378
539
  }
379
540
  /**
@@ -473,9 +634,26 @@ function withDotStepperDotTemplate(template) {
473
634
  templates: { ...cfg.templates, dotStepperDot: template },
474
635
  }));
475
636
  }
476
- /** @internal */
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. */
477
655
  function resolveFeatures(features) {
478
- return features.reduce((cfg, feat) => feat(cfg), STEPPER_CONFIG_DEFAULTS);
656
+ return features.reduce((cfg, feat) => feat(cfg), stepperConfigDefaultsFromPack());
479
657
  }
480
658
  /**
481
659
  * Root-level provider for the stepper config. Apply once in the
@@ -486,7 +664,7 @@ function resolveFeatures(features) {
486
664
  */
487
665
  function provideStepperConfig(...features) {
488
666
  return makeEnvironmentProviders([
489
- { provide: CNGX_STEPPER_CONFIG, useValue: resolveFeatures(features) },
667
+ { provide: CNGX_STEPPER_CONFIG, useFactory: () => resolveFeatures(features) },
490
668
  ]);
491
669
  }
492
670
  /**
@@ -507,7 +685,7 @@ function provideStepperConfig(...features) {
507
685
  * @category common/stepper
508
686
  */
509
687
  function provideStepperConfigAt(...features) {
510
- return [{ provide: CNGX_STEPPER_CONFIG, useValue: resolveFeatures(features) }];
688
+ return [{ provide: CNGX_STEPPER_CONFIG, useFactory: () => resolveFeatures(features) }];
511
689
  }
512
690
  /**
513
691
  * Inject the resolved stepper config in an injection context.
@@ -588,8 +766,7 @@ function stepTreeEqual(a, b) {
588
766
  * a sibling is inserted) on top of the {@link stepTreeEqual} fields.
589
767
  *
590
768
  * Use only on projections where every step carries a real
591
- * DFS-assigned `flatIndex` and `depth` - for `-1` placeholders, use
592
- * {@link stepNodesEqual}.
769
+ * DFS-assigned `flatIndex` and `depth`.
593
770
  *
594
771
  * @internal Exported from `public-api.ts` so the cngx-stepper and
595
772
  * cngx-mat-stepper organisms share the comparator across the
@@ -614,27 +791,6 @@ function flatStepsEqual(a, b) {
614
791
  }
615
792
  return true;
616
793
  }
617
- /**
618
- * Structural equality for any flat node array - `id`, `kind`,
619
- * `parentId` only, ignoring `flatIndex` and `depth`. Use for
620
- * `CngxStepGroup.children` and other `-1`-placeholder projections.
621
- *
622
- * @internal
623
- */
624
- function stepNodesEqual(a, b) {
625
- if (a === b) {
626
- return true;
627
- }
628
- if (a.length !== b.length) {
629
- return false;
630
- }
631
- for (let i = 0; i < a.length; i++) {
632
- if (a[i].id !== b[i].id || a[i].kind !== b[i].kind || a[i].parentId !== b[i].parentId) {
633
- return false;
634
- }
635
- }
636
- return true;
637
- }
638
794
 
639
795
  /**
640
796
  * Stepper presenter - the brain of every stepper / wizard flow.
@@ -689,6 +845,13 @@ class CngxStepperPresenter {
689
845
  // Persistence-of-error surface - see CngxStepperHost.lastFailedIndex
690
846
  // / originIndexDuringCommit for the contract.
691
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;
692
855
  originIndexDuringCommitState = signal(undefined, ...(ngDevMode ? [{ debugName: "originIndexDuringCommitState" }] : /* istanbul ignore next */ []));
693
856
  /** {@inheritDoc CngxStepperHost.lastFailedIndex} */
694
857
  lastFailedIndex = this.lastFailedIndexState.asReadonly();
@@ -787,24 +950,24 @@ class CngxStepperPresenter {
787
950
  */
788
951
  nextEnabledIndex = computed(() => {
789
952
  const stepsOnly = this.stepsOnly();
790
- let next = this.activeStepIndex() + 1;
791
- while (next < stepsOnly.length && stepsOnly[next].disabled()) {
792
- next++;
793
- }
794
- return next;
953
+ return (resolveStepFrom(this.activeStepIndex(), 1, {
954
+ count: stepsOnly.length,
955
+ isDisabledAt: (i) => stepsOnly[i]?.disabled() ?? false,
956
+ }) ?? stepsOnly.length);
795
957
  }, ...(ngDevMode ? [{ debugName: "nextEnabledIndex" }] : /* istanbul ignore next */ []));
796
958
  /**
797
959
  * Previous enabled step-only index before the active one, skipping
798
- * disabled steps. Returns `-1` when no enabled step precedes. Single
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
799
963
  * source for `selectPrevious()` and the `canGoPrevious` bound.
800
964
  */
801
965
  previousEnabledIndex = computed(() => {
802
966
  const stepsOnly = this.stepsOnly();
803
- let prev = this.activeStepIndex() - 1;
804
- while (prev >= 0 && stepsOnly[prev].disabled()) {
805
- prev--;
806
- }
807
- return prev;
967
+ return (resolveStepFrom(Math.max(this.activeStepIndex(), 0), -1, {
968
+ count: stepsOnly.length,
969
+ isDisabledAt: (i) => stepsOnly[i]?.disabled() ?? false,
970
+ }) ?? -1);
808
971
  }, ...(ngDevMode ? [{ debugName: "previousEnabledIndex" }] : /* istanbul ignore next */ []));
809
972
  /** {@inheritDoc CngxStepperHost.stepCount} */
810
973
  stepCount = computed(() => this.stepsOnly().length, ...(ngDevMode ? [{ debugName: "stepCount" }] : /* istanbul ignore next */ []));
@@ -864,11 +1027,16 @@ class CngxStepperPresenter {
864
1027
  }
865
1028
  this.rebuildTree();
866
1029
  }
867
- unregister(id) {
1030
+ unregister(id, handle) {
868
1031
  const entry = this.registry.get(id);
869
1032
  if (!entry) {
870
1033
  return;
871
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
+ }
872
1040
  if (entry.parentId !== null) {
873
1041
  const parent = this.registry.get(entry.parentId);
874
1042
  if (parent) {
@@ -963,6 +1131,7 @@ class CngxStepperPresenter {
963
1131
  // `originIndexDuringCommit` stays untouched. Clear the rejection
964
1132
  // flag if the user re-picked a previously-failed target.
965
1133
  this.activeStepIndex.set(target);
1134
+ this.lastCommittedIndex = target;
966
1135
  if (this.lastFailedIndexState() === target) {
967
1136
  this.lastFailedIndexState.set(undefined);
968
1137
  }
@@ -975,8 +1144,15 @@ class CngxStepperPresenter {
975
1144
  //
976
1145
  // Capture the safe-harbour origin exactly once on commit-window
977
1146
  // open. Written ONLY on this path so a stale origin never lingers
978
- // into a non-commit navigation.
979
- this.originIndexDuringCommitState.set(previous);
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);
980
1156
  const mode = this.commitMode();
981
1157
  if (mode === 'optimistic') {
982
1158
  this.activeStepIndex.set(target);
@@ -985,6 +1161,7 @@ class CngxStepperPresenter {
985
1161
  if (accept) {
986
1162
  // Success - origin no longer needed; clear the rejection
987
1163
  // flag if the user re-picked the failed target.
1164
+ this.lastCommittedIndex = target;
988
1165
  this.originIndexDuringCommitState.set(undefined);
989
1166
  if (this.lastFailedIndexState() === target) {
990
1167
  this.lastFailedIndexState.set(undefined);
@@ -996,11 +1173,11 @@ class CngxStepperPresenter {
996
1173
  else {
997
1174
  // Reject - flag the target; RETAIN the origin so
998
1175
  // `liveAnnouncement` can resolve the origin label for the
999
- // rich rollback phrase. Optimistic rolls back; pessimistic
1000
- // never moved.
1176
+ // rich rollback phrase. Optimistic rolls back to the last
1177
+ // truly-committed index; pessimistic never moved off it.
1001
1178
  this.lastFailedIndexState.set(target);
1002
1179
  if (mode === 'optimistic') {
1003
- this.activeStepIndex.set(previous);
1180
+ this.activeStepIndex.set(origin);
1004
1181
  }
1005
1182
  }
1006
1183
  });
@@ -1011,9 +1188,18 @@ class CngxStepperPresenter {
1011
1188
  this.select(next);
1012
1189
  }
1013
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
+ */
1014
1197
  selectPrevious() {
1015
1198
  const prev = this.previousEnabledIndex();
1016
1199
  if (prev >= 0) {
1200
+ this.cancelAndSettleCommit();
1201
+ this.originIndexDuringCommitState.set(undefined);
1202
+ this.lastCommittedIndex = prev;
1017
1203
  this.activeStepIndex.set(prev);
1018
1204
  }
1019
1205
  }
@@ -1026,7 +1212,26 @@ class CngxStepperPresenter {
1026
1212
  }
1027
1213
  reset() {
1028
1214
  this.activeStepIndex.set(0);
1029
- this.commitController.cancel();
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
+ }
1030
1235
  }
1031
1236
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepperPresenter, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1032
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: [
@@ -1136,7 +1341,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1136
1341
  * `CngxStepGroup` ({@link CNGX_STEP_GROUP_HOST}) or the root
1137
1342
  * `CngxStepperPresenter` ({@link CNGX_STEPPER_HOST}).
1138
1343
  *
1139
- * `state` is a `linkedSignal` over `[disabled]`, `[completed]`, and
1344
+ * `state` is a pure `computed` over `[disabled]`, `[completed]`, and
1140
1345
  * the optional `[errorAggregator]`'s `hasError()`.
1141
1346
  *
1142
1347
  * @category common/stepper
@@ -1145,6 +1350,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1145
1350
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/step.directive.ts
1146
1351
  * @since 0.1.0
1147
1352
  * @relatedTo CngxStepGroup, CngxStepperPresenter, CngxStepLabel, CngxStepContent
1353
+ * @slot cngxStepLabel The step's own header label.
1354
+ * @slot cngxStepContent The step body, rendered lazily when the step activates.
1148
1355
  * <example-url>http://localhost:4200/#/ui/stepper/stepper-step-content/typed-lazy-panels</example-url>
1149
1356
  */
1150
1357
  class CngxStep {
@@ -1176,42 +1383,43 @@ class CngxStep {
1176
1383
  contentSlot = contentChild(CngxStepContent, ...(ngDevMode ? [{ debugName: "contentSlot" }] : /* istanbul ignore next */ []));
1177
1384
  labelTemplate = this.labelSlot;
1178
1385
  contentTemplate = this.contentSlot;
1179
- /**
1180
- * Per-step status derived from inputs + aggregator. `linkedSignal`
1181
- * with structural equal - never written via `effect`.
1182
- */
1183
- state = linkedSignal({ ...(ngDevMode ? { debugName: "state" } : /* istanbul ignore next */ {}), source: () => {
1184
- const directError = this.error();
1185
- return {
1186
- disabled: this.disabled(),
1187
- completed: this.completed(),
1188
- errored: (directError !== false && directError !== '') ||
1189
- (this.errorAggregator()?.hasError?.() ?? false),
1190
- };
1191
- },
1192
- computation: ({ disabled, completed, errored }) => {
1193
- if (disabled) {
1194
- return 'disabled';
1195
- }
1196
- if (errored) {
1197
- return 'error';
1198
- }
1199
- if (completed) {
1200
- return 'success';
1201
- }
1202
- return 'idle';
1203
- },
1204
- 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 */ []));
1402
+ groupHost = inject(CNGX_STEP_GROUP_HOST, { optional: true });
1403
+ stepperHost = inject(CNGX_STEPPER_HOST, { optional: true });
1404
+ destroyRef = inject(DestroyRef);
1205
1405
  constructor() {
1206
- const groupHost = inject(CNGX_STEP_GROUP_HOST, { optional: true });
1207
- const stepperHost = inject(CNGX_STEPPER_HOST, { optional: true });
1208
- const host = groupHost ?? stepperHost;
1209
- if (!host) {
1406
+ if (!this.groupHost && !this.stepperHost) {
1210
1407
  throw new Error('CngxStep: no enclosing CngxStepperPresenter or CngxStepGroup found. ' +
1211
1408
  'Wrap the step inside an element carrying [cngxStepper] or [cngxStepGroup].');
1212
1409
  }
1410
+ }
1411
+ ngOnInit() {
1412
+ // Register in ngOnInit, NOT the constructor: a bound `[id]` signal
1413
+ // input is not applied until the first change detection, so a
1414
+ // constructor read captures the default auto-id. The registered id is
1415
+ // the key the router-sync deep-link seed and consumers match against,
1416
+ // so it must reflect the bound `[id]`. ngOnInit still runs before the
1417
+ // host's ngAfterContentInit, so the seed's registry precondition holds;
1418
+ // and it fires ancestor-group-before-descendant-step in DOM order, so
1419
+ // the presenter's insertion-order tree is unchanged. Mirrors CngxTab.
1420
+ const host = this.groupHost ?? this.stepperHost;
1213
1421
  const stepId = this.id();
1214
- host.register({
1422
+ const handle = {
1215
1423
  id: stepId,
1216
1424
  kind: 'step',
1217
1425
  label: this.label,
@@ -1219,8 +1427,9 @@ class CngxStep {
1219
1427
  state: this.state,
1220
1428
  errorAggregator: this.errorAggregator,
1221
1429
  errorMessage: this.errorMessage,
1222
- });
1223
- inject(DestroyRef).onDestroy(() => host.unregister(stepId));
1430
+ };
1431
+ host.register(handle);
1432
+ this.destroyRef.onDestroy(() => host.unregister(stepId, handle));
1224
1433
  }
1225
1434
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStep, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1226
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 });
@@ -1269,7 +1478,10 @@ class CngxStepGroup {
1269
1478
  if (states.some((s) => s === 'error')) {
1270
1479
  return 'error';
1271
1480
  }
1272
- if (states.some((s) => s === 'pending' || s === 'busy')) {
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).
1273
1485
  return 'pending';
1274
1486
  }
1275
1487
  if (states.every((s) => s === 'success')) {
@@ -1278,6 +1490,14 @@ class CngxStepGroup {
1278
1490
  return 'idle';
1279
1491
  }, { ...(ngDevMode ? { debugName: "aggregatedStatus" } : /* istanbul ignore next */ {}), equal: Object.is });
1280
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
+ });
1500
+ destroyRef = inject(DestroyRef);
1281
1501
  /**
1282
1502
  * `true` when this group's children are collapsed to the header node:
1283
1503
  * the focus-driven policy is `'expand-active'`, this group does not
@@ -1305,25 +1525,36 @@ class CngxStepGroup {
1305
1525
  throw new Error('CngxStepGroup: no enclosing CngxStepperPresenter found. ' +
1306
1526
  'Wrap the group inside an element carrying [cngxStepper].');
1307
1527
  }
1528
+ }
1529
+ ngOnInit() {
1530
+ // Register in ngOnInit, not the constructor, so a bound `[id]` reaches
1531
+ // the registry (see CngxStep). A group MUST register before its child
1532
+ // steps or the presenter drops the orphaned children; ngOnInit fires an
1533
+ // ancestor group before its descendant steps, so that order holds, and
1534
+ // groups and steps share one lifecycle phase - keeping the presenter's
1535
+ // insertion-order tree identical to the previous constructor ordering.
1536
+ const registrationHost = this.parentGroupHost ?? this.stepperHost;
1308
1537
  const groupId = this.id();
1309
- this.stepperHost.register({
1538
+ const handle = {
1310
1539
  id: groupId,
1311
1540
  kind: 'group',
1312
1541
  label: this.label,
1313
1542
  disabled: this.disabled,
1314
1543
  state: this.aggregatedStatus,
1315
- });
1316
- const stepperHost = this.stepperHost;
1317
- inject(DestroyRef).onDestroy(() => stepperHost.unregister(groupId));
1544
+ };
1545
+ registrationHost.register(handle);
1546
+ this.destroyRef.onDestroy(() => registrationHost.unregister(groupId, handle));
1318
1547
  }
1319
1548
  register(handle) {
1320
1549
  this.childRegistry.update((cur) => [...cur, handle]);
1321
1550
  // Forward to the root with this group as parent so the tree shape is correct.
1322
1551
  this.stepperHost.register(handle, this.id());
1323
1552
  }
1324
- unregister(id) {
1325
- this.childRegistry.update((cur) => cur.filter((c) => c.id !== id));
1326
- this.stepperHost.unregister(id);
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);
1327
1558
  }
1328
1559
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1329
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 });
@@ -1733,6 +1964,9 @@ const CNGX_STEPPER_GLYPHS = {
1733
1964
  */
1734
1965
  class CngxStepperRouterSync {
1735
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.
1736
1970
  modeInput = input(undefined, { ...(ngDevMode ? { debugName: "modeInput" } : /* istanbul ignore next */ {}), alias: 'mode' });
1737
1971
  paramNameInput = input(undefined, { ...(ngDevMode ? { debugName: "paramNameInput" } : /* istanbul ignore next */ {}), alias: 'paramName' });
1738
1972
  config = injectStepperConfig();
@@ -1742,6 +1976,18 @@ class CngxStepperRouterSync {
1742
1976
  syncError = output();
1743
1977
  host = inject(CNGX_STEPPER_HOST, { host: true });
1744
1978
  router = inject(Router, { optional: true });
1979
+ /**
1980
+ * Latched once the URL seed has reached a registered step, so the
1981
+ * `afterNextRender` fallback cannot run it twice.
1982
+ *
1983
+ * The latch is load-bearing, not decorative: the seed goes through
1984
+ * `selectById` → `select()`, which opens a commit window. Under a
1985
+ * pessimistic commit `activeStepIndex` still holds the *previous* index
1986
+ * while the action is in flight, so the presenter's `target === previous`
1987
+ * bail does not catch the repeat - an unlatched fallback would fire the
1988
+ * consumer's commit-action a second time and supersede the first.
1989
+ */
1990
+ seeded = false;
1745
1991
  constructor() {
1746
1992
  if (!this.router) {
1747
1993
  afterNextRender(() => {
@@ -1751,36 +1997,16 @@ class CngxStepperRouterSync {
1751
1997
  return;
1752
1998
  }
1753
1999
  const router = this.router;
1754
- afterNextRender(() => {
1755
- const initial = this.mode() === 'fragment'
1756
- ? router.routerState.snapshot.root.fragment
1757
- : (router.routerState.snapshot.root.queryParamMap.get(this.paramName()) ?? null);
1758
- if (initial) {
1759
- const value = this.mode() === 'fragment' ? this.parseFragment(initial) : initial;
1760
- if (value) {
1761
- this.host.selectById(value);
1762
- }
1763
- }
1764
- });
2000
+ // Fallback seed for steps that register after content-init (a dynamic
2001
+ // @for over an async step list). Idempotent against the content-init
2002
+ // seed via the `seeded` latch.
2003
+ afterNextRender(() => this.seedFromUrl(router));
1765
2004
  effect(() => {
1766
2005
  const id = this.host.activeStepId();
1767
2006
  if (!id) {
1768
2007
  return;
1769
2008
  }
1770
- untracked(() => {
1771
- const navigation = this.mode() === 'fragment'
1772
- ? router.navigate([], {
1773
- fragment: `${this.paramName()}=${id}`,
1774
- queryParamsHandling: 'merge',
1775
- replaceUrl: true,
1776
- })
1777
- : router.navigate([], {
1778
- queryParams: { [this.paramName()]: id },
1779
- queryParamsHandling: 'merge',
1780
- replaceUrl: true,
1781
- });
1782
- navigation.catch?.((err) => this.syncError.emit(err));
1783
- });
2009
+ untracked(() => this.writeUrl(router, id));
1784
2010
  });
1785
2011
  const navEnd = toSignal(router.events.pipe(filter((e) => e instanceof NavigationEnd), takeUntilDestroyed(inject(DestroyRef))), { initialValue: null });
1786
2012
  effect(() => {
@@ -1789,22 +2015,93 @@ class CngxStepperRouterSync {
1789
2015
  return;
1790
2016
  }
1791
2017
  untracked(() => {
1792
- const next = this.mode() === 'fragment'
1793
- ? this.parseFragment(router.routerState.snapshot.root.fragment ?? '')
1794
- : (router.routerState.snapshot.root.queryParamMap.get(this.paramName()) ?? null);
2018
+ const next = this.readUrlValue(router);
1795
2019
  if (next && next !== this.host.activeStepId()) {
1796
2020
  this.host.selectById(next);
1797
2021
  }
1798
2022
  });
1799
2023
  });
1800
2024
  }
2025
+ /**
2026
+ * Seed from the URL before the stepper renders its panels. `CngxStep`
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.
2032
+ *
2033
+ * Own router guard: the constructor's early return does not stop
2034
+ * lifecycle hooks from running.
2035
+ */
2036
+ ngAfterContentInit() {
2037
+ if (!this.router) {
2038
+ return;
2039
+ }
2040
+ this.seedFromUrl(this.router);
2041
+ }
2042
+ seedFromUrl(router) {
2043
+ if (this.seeded) {
2044
+ return;
2045
+ }
2046
+ const initial = this.readUrlValue(router);
2047
+ if (!initial) {
2048
+ return;
2049
+ }
2050
+ // Only latch once the target is actually registered. A seed that found
2051
+ // no matching step leaves the fallback armed for steps that register
2052
+ // after content-init.
2053
+ if (!this.host.stepsOnly().some((n) => n.id === initial)) {
2054
+ return;
2055
+ }
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.
2062
+ untracked(() => this.host.selectById(initial));
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
+ }
2092
+ readUrlValue(router) {
2093
+ if (this.mode() === 'fragment') {
2094
+ return this.parseFragment(router.routerState.snapshot.root.fragment ?? '');
2095
+ }
2096
+ return router.routerState.snapshot.root.queryParamMap.get(this.paramName()) ?? null;
2097
+ }
1801
2098
  parseFragment(fragment) {
1802
2099
  const param = this.paramName();
1803
2100
  const segments = fragment.split('&');
1804
2101
  for (const seg of segments) {
1805
2102
  const [key, val] = seg.split('=');
1806
2103
  if (key === param && val) {
1807
- return val;
2104
+ return decodeURIComponent(val);
1808
2105
  }
1809
2106
  }
1810
2107
  return null;
@@ -1821,103 +2118,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1821
2118
  }]
1822
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"] }] } });
1823
2120
 
1824
- /** @internal */
1825
- const STEPPER_I18N_DEFAULTS = {
1826
- stepperLabel: 'Stepper',
1827
- stepIndicatorRoleDescription: 'Step indicator',
1828
- selectedStep: (label, position, count) => `Step ${position} of ${count}: ${label}`,
1829
- stepCompleted: 'Completed',
1830
- stepErrored: 'Has errors',
1831
- stepHasErrors: (count) => `${count} error${count === 1 ? '' : 's'}`,
1832
- previousStep: 'Previous step',
1833
- nextStep: 'Next step',
1834
- commitFailedRetry: 'Commit failed - retry?',
1835
- commitInFlight: 'Committing step…',
1836
- commitRolledBackTo: (originLabel) => `Reverted to step "${originLabel}".`,
1837
- stepRolledBackSuffix: 'This step was rolled back.',
1838
- statusLabels: {
1839
- done: 'Done',
1840
- inProgress: 'In progress',
1841
- upNext: 'Up next',
1842
- errored: 'Errored',
1843
- },
1844
- textStepperFormat: (current, total) => `Step ${current} of ${total}`,
1845
- };
1846
- /**
1847
- * DI token for the resolved stepper i18n bundle. `providedIn: 'root'`
1848
- * with English defaults.
1849
- *
1850
- * @category common/stepper/i18n
1851
- * @wcag AA
1852
- * @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/i18n/stepper-i18n.ts
1853
- * @since 0.1.0
1854
- */
1855
- const CNGX_STEPPER_I18N = new InjectionToken('CngxStepperI18n', {
1856
- providedIn: 'root',
1857
- factory: () => STEPPER_I18N_DEFAULTS,
1858
- });
1859
- /**
1860
- * Brands an i18n mutator with `_target: 'i18n'`. Every `with*` i18n
1861
- * feature returns one of these.
1862
- *
1863
- * @internal
1864
- */
1865
- function defineStepperI18nFeature(fn) {
1866
- return Object.assign(fn, { _target: 'i18n' });
1867
- }
1868
- /**
1869
- * Override stepper i18n labels. Partial override - unset keys keep
1870
- * the English default. {@link CngxStepperStatusLabels} is merged
1871
- * key-by-key so consumers can override one pill label without
1872
- * restating the rest. Sibling of `withStepperAriaLabels` /
1873
- * `withStepperFallbackLabels`.
1874
- *
1875
- * @category common/stepper/i18n
1876
- */
1877
- function withStepperI18nLabels(overrides) {
1878
- return defineStepperI18nFeature((bundle) => ({
1879
- ...bundle,
1880
- ...overrides,
1881
- statusLabels: overrides.statusLabels
1882
- ? { ...bundle.statusLabels, ...overrides.statusLabels }
1883
- : bundle.statusLabels,
1884
- }));
1885
- }
1886
- /** @internal */
1887
- function resolveI18nFeatures(features) {
1888
- return features.reduce((bundle, feat) => feat(bundle), STEPPER_I18N_DEFAULTS);
1889
- }
1890
- /**
1891
- * Provider for the stepper i18n bundle. Compose `withStepperI18nLabels(...)`
1892
- * (plus any future i18n `with*`) - unset keys fall back to English.
1893
- *
1894
- * ```ts
1895
- * bootstrapApplication(AppComponent, {
1896
- * providers: [
1897
- * provideStepperI18n(
1898
- * withStepperI18nLabels({ stepperLabel: 'Schrittfolge', previousStep: 'Vorheriger' }),
1899
- * ),
1900
- * ],
1901
- * });
1902
- * ```
1903
- *
1904
- * @category common/stepper/i18n
1905
- */
1906
- function provideStepperI18n(...features) {
1907
- return {
1908
- provide: CNGX_STEPPER_I18N,
1909
- useValue: resolveI18nFeatures(features),
1910
- };
1911
- }
1912
- /**
1913
- * Inject the resolved stepper i18n bundle in an injection context.
1914
- *
1915
- * @category common/stepper/i18n
1916
- */
1917
- function injectStepperI18n() {
1918
- return inject(CNGX_STEPPER_I18N);
1919
- }
1920
-
1921
2121
  /**
1922
2122
  * Resolve the status-pill label for a step node against the resolved
1923
2123
  * i18n bundle. Used by skins that surface a per-step status pill
@@ -1950,39 +2150,45 @@ function resolveStepperStatusLabel(node, i18n, isActive) {
1950
2150
  }
1951
2151
 
1952
2152
  /**
1953
- * Returns a reactive `Signal<boolean>` that reflects whether the host
1954
- * window matches a CSS media query (e.g. `(max-width: 480px)`). Used by
1955
- * `<cngx-stepper>` to drive its mobile auto-collapse template branch.
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.
1956
2161
  *
1957
- * In SSR / non-DOM environments the signal stays `false` and the
1958
- * listener is never wired.
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.
1959
2165
  *
2166
+ * @param host The `<cngx-stepper>` host element, which is its own container.
1960
2167
  * @category common/stepper
2168
+ * @relatedTo createStepperDisplayMode, injectContainerSize
1961
2169
  */
1962
- function createMobileViewportSignal(mediaQuery, destroyRef) {
1963
- const matches = signal(false, ...(ngDevMode ? [{ debugName: "matches" }] : /* istanbul ignore next */ []));
1964
- if (typeof globalThis.matchMedia !== 'function') {
1965
- return matches.asReadonly();
1966
- }
1967
- const mql = globalThis.matchMedia(mediaQuery);
1968
- matches.set(mql.matches);
1969
- const listener = (event) => matches.set(event.matches);
1970
- mql.addEventListener('change', listener);
1971
- destroyRef.onDestroy(() => mql.removeEventListener('change', listener));
1972
- return matches.asReadonly();
2170
+ function injectStepperCollapse(host) {
2171
+ const raw = injectContainerSize(host).property('--cngx-stepper-collapse', host, '::after');
2172
+ return computed(() => raw() === '1');
1973
2173
  }
1974
2174
  /**
1975
- * Resolves the active stepper display mode by combining a viewport
1976
- * media-query with the configured `mobileCollapse` policy.
1977
- * `'classic'` keeps the full strip; `'text'` / `'dots'` swap to the
1978
- * 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.
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`.
1979
2184
  *
2185
+ * @param collapsed `true` while the container sits below the collapse rung.
2186
+ * @param mobileCollapse The configured collapse policy, read lazily.
1980
2187
  * @category common/stepper
1981
2188
  */
1982
- function createStepperDisplayMode(mediaQuery, mobileCollapse, destroyRef) {
1983
- const viewport = createMobileViewportSignal(mediaQuery, destroyRef);
2189
+ function createStepperDisplayMode(collapsed, mobileCollapse) {
1984
2190
  return computed(() => {
1985
- if (!viewport()) {
2191
+ if (!collapsed()) {
1986
2192
  return 'classic';
1987
2193
  }
1988
2194
  const mode = mobileCollapse() ?? 'text';
@@ -1991,31 +2197,23 @@ function createStepperDisplayMode(mediaQuery, mobileCollapse, destroyRef) {
1991
2197
  }
1992
2198
 
1993
2199
  /**
1994
- * Tracks an element's content-box width as a reactive signal via the
1995
- * `ResizeObserver` API. Mirrors `createMobileViewportSignal`'s
1996
- * `matchMedia` wrapper: the API is wrapped directly (not via the
1997
- * `CngxResizeObserver` directive, which can only attach through
1998
- * `hostDirectives`). In SSR / non-DOM environments the signal stays
1999
- * `0` and no observer is wired.
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.
2000
2206
  */
2001
2207
  function createElementWidthSignal(element, destroyRef) {
2002
- const width = signal(0, ...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
2003
- if (typeof ResizeObserver !== 'function') {
2004
- return width.asReadonly();
2005
- }
2006
- const observer = new ResizeObserver((entries) => {
2007
- width.set(entries[0]?.contentRect.width ?? 0);
2008
- });
2009
- observer.observe(element);
2010
- destroyRef.onDestroy(() => observer.disconnect());
2011
- return width.asReadonly();
2208
+ const entry = createResizeSignal(element, 'content-box', destroyRef, globalThis);
2209
+ return computed(() => entry()?.contentRect.width ?? 0);
2012
2210
  }
2013
2211
  /**
2014
2212
  * Resolves the classic strip's density rung from its own container
2015
2213
  * width against the step count and two per-step px thresholds. Pure
2016
- * `create*` factory, sibling to `createStepperDisplayMode` - it owns a
2017
- * `ResizeObserver` the way the display-mode factory owns a
2018
- * `matchMedia` listener, and returns a single derived `Signal`.
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.
2019
2217
  *
2020
2218
  * `'comfortable'` density short-circuits to `'full'` (no measurement
2021
2219
  * dependency). Before the first measurement (`width === 0`) and for an
@@ -2067,8 +2265,8 @@ function subtreeStats(node) {
2067
2265
  * Builds the collapsed-group summary view. Level-2 helper so the
2068
2266
  * organism stays a thin renderer. `status` mode defers its SR phrasing
2069
2267
  * to the group's existing status-phrase span, so {@link srText} returns
2070
- * `null` there. English defaults (locale via the i18n cascade is a
2071
- * follow-up).
2268
+ * `null` there. SR phrases resolve through the `CngxStepperI18n` bundle
2269
+ * when passed; English defaults otherwise.
2072
2270
  *
2073
2271
  * @category common/stepper
2074
2272
  */
@@ -2080,7 +2278,10 @@ function createStepperGroupSummary(options) {
2080
2278
  return null;
2081
2279
  }
2082
2280
  const { total, completed } = subtreeStats(node);
2083
- return current === 'count' ? String(total) : `${completed}/${total}`;
2281
+ const i18n = options.i18n();
2282
+ return current === 'count'
2283
+ ? i18n.groupSummaryCountShort(total)
2284
+ : i18n.groupSummaryProgressShort(completed, total);
2084
2285
  };
2085
2286
  const showStatus = (node) => mode() === 'status' && options.isCollapsed(node);
2086
2287
  const srText = (node) => {
@@ -2089,7 +2290,10 @@ function createStepperGroupSummary(options) {
2089
2290
  return null;
2090
2291
  }
2091
2292
  const { total, completed } = subtreeStats(node);
2092
- return current === 'count' ? `${total} steps` : `${completed} of ${total} steps complete`;
2293
+ if (current === 'count') {
2294
+ return options.i18n().groupSummaryCount(total);
2295
+ }
2296
+ return options.i18n().groupSummaryProgress(completed, total);
2093
2297
  };
2094
2298
  return { mode, text, showStatus, srText };
2095
2299
  }
@@ -2163,6 +2367,25 @@ function createStepperHostAttrs(inputs) {
2163
2367
  resolvedMobileIndicatorPosition: computed(() => inputs.mobileIndicatorPosition() ?? inputs.config.mobileIndicatorPosition ?? 'top'),
2164
2368
  };
2165
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
+ }
2166
2389
 
2167
2390
  /**
2168
2391
  * Builds the WAI-ARIA APG arrow-key handler for a stepper strip. The
@@ -2193,11 +2416,22 @@ function createStepperStripKeyboardNav(options) {
2193
2416
  }
2194
2417
  };
2195
2418
  const focusActive = () => {
2196
- const activeId = options.presenter.activeStepId();
2197
- if (!activeId) {
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) {
2198
2432
  return;
2199
2433
  }
2200
- const buttonId = options.stepButtonIdFor(activeId);
2434
+ const buttonId = options.stepButtonIdFor(targetId);
2201
2435
  scheduleFocus(() => {
2202
2436
  const el = options.hostElement.querySelector(`[id="${buttonId}"]`);
2203
2437
  if (el instanceof HTMLElement) {
@@ -2214,27 +2448,50 @@ function createStepperStripKeyboardNav(options) {
2214
2448
  return;
2215
2449
  }
2216
2450
  const isHorizontal = options.presenter.orientation() === 'horizontal';
2217
- const nextKey = isHorizontal ? 'ArrowRight' : 'ArrowDown';
2218
- const prevKey = isHorizontal ? 'ArrowLeft' : 'ArrowUp';
2219
- if (event.key === nextKey) {
2451
+ // Horizontal: the inline arrows flip under rtl. Vertical: the block
2452
+ // arrows (ArrowUp/ArrowDown) never flip.
2453
+ const inlineStep = isHorizontal ? resolveInlineStep(event.key, options.direction()) : null;
2454
+ const isNext = inlineStep === 1 || (!isHorizontal && event.key === 'ArrowDown');
2455
+ const isPrev = inlineStep === -1 || (!isHorizontal && event.key === 'ArrowUp');
2456
+ if (isNext) {
2220
2457
  event.preventDefault();
2221
2458
  options.presenter.selectNext();
2222
2459
  focusActive();
2223
2460
  }
2224
- else if (event.key === prevKey) {
2461
+ else if (isPrev) {
2225
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
+ }
2226
2469
  options.presenter.selectPrevious();
2227
2470
  focusActive();
2228
2471
  }
2229
2472
  else if (event.key === 'Home') {
2230
2473
  event.preventDefault();
2231
- options.presenter.select(0);
2232
- focusActive();
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
+ }
2233
2483
  }
2234
2484
  else if (event.key === 'End') {
2235
2485
  event.preventDefault();
2236
- options.presenter.select(options.flatStepCount() - 1);
2237
- focusActive();
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
+ }
2238
2495
  }
2239
2496
  };
2240
2497
  }
@@ -2295,7 +2552,10 @@ function createStepperStateView(inputs) {
2295
2552
  * (the classic mobile-collapse summary) are a guaranteed no-op.
2296
2553
  *
2297
2554
  * Pure helper - reads signals at call time, intended to be wrapped in the
2298
- * 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.
2299
2559
  *
2300
2560
  * @category common/stepper
2301
2561
  * @since 0.1.0
@@ -2311,8 +2571,10 @@ function resolveStepperErrorSummary(view, stepsOnly, i18n, messageOf) {
2311
2571
  if (custom !== undefined && custom !== '') {
2312
2572
  return custom;
2313
2573
  }
2314
- const label = node?.label();
2315
- return label ? `${label}: ${i18n.statusLabels.errored}` : i18n.statusLabels.errored;
2574
+ const label = node ? untracked(node.label) : undefined;
2575
+ return label
2576
+ ? i18n.stepWithDetail(label, i18n.statusLabels.errored)
2577
+ : i18n.statusLabels.errored;
2316
2578
  }
2317
2579
  return i18n.stepHasErrors(count);
2318
2580
  }
@@ -2415,12 +2677,12 @@ function createStepperSlotContextBuilders(inputs) {
2415
2677
  // Resolution order: direct [error] string > first aggregator label >
2416
2678
  // i18n errored status phrase. Always non-empty so a bare
2417
2679
  // `{{ message }}` template renders a reason.
2418
- const message = node.errorMessage?.() ?? errorLabels[0] ?? i18n.statusLabels.errored;
2680
+ const message = node.errorMessage?.() ?? errorLabels[0] ?? i18n().statusLabels.errored;
2419
2681
  return { node, message, errorLabels, announcement };
2420
2682
  });
2421
2683
  const groupHeaderContextFor = memoizeByNode((node) => ({
2422
2684
  group: node,
2423
- expanded: true,
2685
+ expanded: !(inputs.isGroupCollapsed?.(node) ?? false),
2424
2686
  status: node.state(),
2425
2687
  }));
2426
2688
  const stepLabelContextFor = memoizeByNode((node) => ({
@@ -2467,11 +2729,32 @@ function createStepperSlotContextBuilders(inputs) {
2467
2729
  * @internal
2468
2730
  */
2469
2731
  function createStepperAnnouncementBuilders(inputs) {
2470
- const { presenter, stepsOnly, i18n } = inputs;
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.
2471
2736
  const liveAnnouncement = computed(() => {
2472
2737
  const current = presenter.commitTransition.current();
2473
2738
  if (current === 'pending') {
2474
- 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 '';
2475
2758
  }
2476
2759
  if (current === 'error') {
2477
2760
  // Sync commit-handler errors collapse pending -> error in one signal
@@ -2480,16 +2763,18 @@ function createStepperAnnouncementBuilders(inputs) {
2480
2763
  const failedIdx = presenter.lastFailedIndex();
2481
2764
  const originIdx = presenter.originIndexDuringCommit();
2482
2765
  if (failedIdx !== undefined && originIdx !== undefined) {
2483
- const originLabel = stepsOnly()[originIdx]?.label();
2766
+ const origin = stepsOnly()[originIdx];
2767
+ const originLabel = origin ? untracked(origin.label) : undefined;
2484
2768
  if (originLabel) {
2485
- return i18n.commitRolledBackTo(originLabel);
2769
+ return untracked(() => inputs.i18n().commitRolledBackTo(originLabel));
2486
2770
  }
2487
2771
  }
2488
- return i18n.commitFailedRetry;
2772
+ return untracked(() => inputs.i18n().commitFailedRetry);
2489
2773
  }
2490
2774
  return '';
2491
2775
  }, ...(ngDevMode ? [{ debugName: "liveAnnouncement" }] : /* istanbul ignore next */ []));
2492
2776
  const statusPhrase = (node) => {
2777
+ const i18n = inputs.i18n();
2493
2778
  const aggregator = node.errorAggregator?.();
2494
2779
  let base = aggregator?.shouldShow?.() ? (aggregator.announcement?.() ?? '') : '';
2495
2780
  if (!base && node.kind === 'step') {
@@ -2502,20 +2787,86 @@ function createStepperAnnouncementBuilders(inputs) {
2502
2787
  return '';
2503
2788
  }
2504
2789
  return node.kind === 'step' && node.flatIndex === presenter.lastFailedIndex()
2505
- ? `${base} ${i18n.stepRolledBackSuffix}`
2790
+ ? i18n.stepRolledBack(base)
2506
2791
  : base;
2507
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.
2508
2796
  const groupStatusPhrase = (node) => {
2797
+ const i18n = inputs.i18n();
2509
2798
  const status = node.state();
2510
2799
  if (status === 'error') {
2511
- return i18n.stepErrored;
2800
+ return i18n.statusLabels.errored;
2512
2801
  }
2513
2802
  if (status === 'success') {
2514
- return i18n.stepCompleted;
2803
+ return i18n.statusLabels.done;
2515
2804
  }
2516
2805
  return '';
2517
2806
  };
2518
- return { liveAnnouncement, statusPhrase, groupStatusPhrase };
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
+ };
2815
+ const descriptorId = (node) => `${node.id}-desc`;
2816
+ const describedBy = (node) => {
2817
+ const phrase = node.kind === 'step' ? headerStatusPhrase(node) : groupStatusPhrase(node);
2818
+ return phrase ? descriptorId(node) : null;
2819
+ };
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 };
2519
2870
  }
2520
2871
 
2521
2872
  /**
@@ -2529,10 +2880,10 @@ function createStepperAnnouncementBuilders(inputs) {
2529
2880
  * `CNGX_STEPPER_CONFIG.mobileSwipe` -> library default `true`.
2530
2881
  *
2531
2882
  * Direction routing is asymmetric, matching the presenter's existing
2532
- * navigation surface: `left` -> `selectNext()` -> `select()` (linear
2533
- * gate + commit window apply identically to a click); `right` ->
2534
- * `selectPrevious()` (ungated direct back-move, same path as the
2535
- * existing strip back-nav).
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.
2536
2887
  *
2537
2888
  * @category common/stepper
2538
2889
  * @docsKind primary
@@ -2548,18 +2899,29 @@ class CngxStepperSwipeNav {
2548
2899
  mobileSwipe = input(undefined, ...(ngDevMode ? [{ debugName: "mobileSwipe" }] : /* istanbul ignore next */ []));
2549
2900
  host = inject(CNGX_STEPPER_HOST);
2550
2901
  config = injectStepperConfig();
2902
+ direction = injectDirection();
2551
2903
  /** Resolved enabled flag (Input -> config -> default(true)). Boolean output, no `equal` fn required. */
2552
2904
  swipeEnabled = computed(() => this.mobileSwipe() ?? this.config.mobileSwipe ?? true, ...(ngDevMode ? [{ debugName: "swipeEnabled" }] : /* istanbul ignore next */ []));
2553
2905
  /**
2554
- * Route a swipe direction into the presenter. `left` and `right`
2555
- * map onto `selectNext` and `selectPrevious`; vertical directions
2556
- * are ignored.
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).
2557
2912
  */
2558
2913
  handleSwipe(direction) {
2559
- if (direction === 'left') {
2914
+ if (direction !== 'left' && direction !== 'right') {
2915
+ return;
2916
+ }
2917
+ const forward = direction === (this.direction() === 'rtl' ? 'right' : 'left');
2918
+ if (forward) {
2560
2919
  this.host.selectNext();
2561
2920
  }
2562
- else if (direction === 'right') {
2921
+ else {
2922
+ if (this.host.busy()) {
2923
+ return;
2924
+ }
2563
2925
  this.host.selectPrevious();
2564
2926
  }
2565
2927
  }
@@ -2609,7 +2971,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
2609
2971
  * <example-url>http://localhost:4200/#/ui/stepper/stepper-count/multi-instance-format-overrides</example-url>
2610
2972
  */
2611
2973
  class CngxStepperCount {
2612
- /** When `true`, wraps the rendered string in an `aria-live="polite"` span. */
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
+ */
2613
2979
  live = input(true, ...(ngDevMode ? [{ debugName: "live" }] : /* istanbul ignore next */ []));
2614
2980
  /**
2615
2981
  * Per-instance format override. Receives `(current, total)` where
@@ -2632,32 +2998,61 @@ class CngxStepperCount {
2632
2998
  injectedHost = inject(CNGX_STEPPER_HOST, { optional: true });
2633
2999
  i18n = injectStepperI18n();
2634
3000
  resolvedHost = computed(() => this.host() ?? this.injectedHost, ...(ngDevMode ? [{ debugName: "resolvedHost" }] : /* istanbul ignore next */ []));
2635
- /** Resolved caption - reactive on activeStepIndex / stepsOnly / format / i18n. */
2636
- label = computed(() => {
3001
+ /** 1-based active position and step total, or `null` while there is nothing to count. */
3002
+ position = computed(() => {
2637
3003
  const host = this.resolvedHost();
2638
3004
  if (!host) {
2639
- return '';
3005
+ return null;
2640
3006
  }
2641
- const current = host.activeStepIndex() + 1;
2642
3007
  const total = host.stepsOnly().length;
2643
- const fmt = this.format() ?? this.i18n.textStepperFormat;
2644
- return fmt(current, total);
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);
2645
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 */ []));
2646
3036
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepperCount, deps: [], target: i0.ɵɵFactoryTarget.Component });
2647
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxStepperCount, isStandalone: true, selector: "cngx-stepper-count", inputs: { live: { classPropertyName: "live", publicName: "live", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, host: { classPropertyName: "host", publicName: "host", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "cngx-stepper-count" }, ngImport: i0, template: '<span [attr.aria-live]="live() ? \'polite\' : null">{{ label() }}</span>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
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 });
2648
3044
  }
2649
3045
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepperCount, decorators: [{
2650
3046
  type: Component,
2651
- args: [{
2652
- selector: 'cngx-stepper-count',
2653
- standalone: true,
2654
- changeDetection: ChangeDetectionStrategy.OnPush,
2655
- encapsulation: ViewEncapsulation.None,
2656
- template: '<span [attr.aria-live]="live() ? \'polite\' : null">{{ label() }}</span>',
2657
- host: {
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: {
2658
3054
  class: 'cngx-stepper-count',
2659
- },
2660
- }]
3055
+ }, styles: [".cngx-stepper-count span{unicode-bidi:var(--cngx-stepper-count-bidi, isolate);direction:var(--cngx-stepper-count-direction, inherit)}\n"] }]
2661
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 }] }] } });
2662
3057
 
2663
3058
  /**
@@ -2698,7 +3093,41 @@ class CngxStepperPrevious {
2698
3093
  injectedHost = inject(CNGX_STEPPER_HOST, { optional: true });
2699
3094
  resolvedHost = computed(() => this.host() ?? this.injectedHost, ...(ngDevMode ? [{ debugName: "resolvedHost" }] : /* istanbul ignore next */ []));
2700
3095
  coPlacedAsyncClick = inject(CngxAsyncClick, { self: true, optional: true });
3096
+ elementRef = inject(ElementRef);
3097
+ i18n = injectStepperI18n();
2701
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
+ });
2702
3131
  if (isDevMode() && this.coPlacedAsyncClick) {
2703
3132
  console.warn('CngxStepperPrevious: [cngxStepperPrevious] and [cngxAsyncClick] on the same element ' +
2704
3133
  'both gate aria-disabled. Use one or the other.');
@@ -2775,15 +3204,49 @@ class CngxStepperNext {
2775
3204
  injectedHost = inject(CNGX_STEPPER_HOST, { optional: true });
2776
3205
  resolvedHost = computed(() => this.host() ?? this.injectedHost, ...(ngDevMode ? [{ debugName: "resolvedHost" }] : /* istanbul ignore next */ []));
2777
3206
  coPlacedAsyncClick = inject(CngxAsyncClick, { self: true, optional: true });
3207
+ elementRef = inject(ElementRef);
3208
+ i18n = injectStepperI18n();
2778
3209
  /** `true` when advancing is unavailable: no enabled next step or commit busy. */
2779
3210
  disabled = computed(() => {
2780
3211
  const host = this.resolvedHost();
2781
3212
  return !host || !host.canGoNext() || host.busy();
2782
3213
  }, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
2783
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
+ });
2784
3247
  if (isDevMode() && this.coPlacedAsyncClick) {
2785
3248
  console.warn('CngxStepperNext: [cngxStepperNext] and [cngxAsyncClick] on the same element ' +
2786
- 'both gate aria-disabled (and cngxAsyncClick adds native [disabled]). Use one or the other.');
3249
+ 'both gate aria-disabled. Use one or the other.');
2787
3250
  }
2788
3251
  }
2789
3252
  /** @internal */
@@ -2859,7 +3322,9 @@ class CngxStepperComplete {
2859
3322
  const tracker = createTransitionTracker(() => this.runner.status());
2860
3323
  effect(() => {
2861
3324
  if (tracker.current() === 'success' && tracker.previous() !== 'success') {
2862
- this.completed.emit();
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());
2863
3328
  }
2864
3329
  });
2865
3330
  }
@@ -2925,6 +3390,7 @@ function createStepperHostProxy(supplier) {
2925
3390
  activeStepId: computed(() => supplier()?.activeStepId() ?? null),
2926
3391
  activeGroupId: computed(() => supplier()?.activeGroupId() ?? null),
2927
3392
  linear: computed(() => supplier()?.linear() ?? false),
3393
+ commitMode: computed(() => supplier()?.commitMode?.() ?? 'pessimistic'),
2928
3394
  orientation: computed(() => supplier()?.orientation() ?? 'horizontal'),
2929
3395
  intendedStepIndex: computed(() => supplier()?.intendedStepIndex()),
2930
3396
  lastFailedIndex: computed(() => supplier()?.lastFailedIndex()),
@@ -3046,7 +3512,9 @@ function provideCngxStepper(...features) {
3046
3512
  function provideCngxStepperAt(...features) {
3047
3513
  const { config, i18n } = partitionFeatures(features);
3048
3514
  return [
3049
- ...provideStepperConfigAt(...config),
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) : []),
3050
3518
  ...(i18n.length > 0 ? [provideStepperI18n(...i18n)] : []),
3051
3519
  ];
3052
3520
  }
@@ -3065,5 +3533,5 @@ function provideCngxStepperAt(...features) {
3065
3533
  * Generated bundle index. Do not edit.
3066
3534
  */
3067
3535
 
3068
- 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, STEPPER_DEFAULT_MOBILE_BREAKPOINT, createMobileViewportSignal, createStepperAnnouncementBuilders, createStepperCommitHandler, createStepperDisplayMode, createStepperGroupNavigation, createStepperGroupSummary, createStepperHostAttrs, createStepperHostProxy, createStepperSlotContextBuilders, createStepperStateView, createStepperStripKeyboardNav, createStepperTemplateBindings, createStripDensity, flatStepsEqual, 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, withStepperMobileBreakpoint, withStepperMobileCollapse, withStepperMobileIndicatorPosition, withStepperMobileSwipe, withStepperRouterSync, withStepperSkin };
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 };
3069
3537
  //# sourceMappingURL=cngx-common-stepper.mjs.map