@cngx/common 0.1.0-rc.0 → 0.1.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/cngx-common-a11y.mjs +24 -11
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +64 -48
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +45 -11
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +559 -38
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +1394 -160
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +1 -1
- package/package.json +3 -3
- package/stepper/README.md +16 -9
- package/theming/components/cngx-badge.css +1 -1
- package/theming/components/cngx-menu.css +1 -1
- package/types/cngx-common-a11y.d.ts +23 -2
- package/types/cngx-common-data.d.ts +46 -33
- package/types/cngx-common-interactive.d.ts +20 -2
- package/types/cngx-common-stepper.d.ts +604 -17
- package/types/cngx-common-tabs.d.ts +1363 -159
- package/tabs/README.md +0 -32
|
@@ -113,6 +113,18 @@ const CNGX_STEPPER_COMMIT_HANDLER_FACTORY = new InjectionToken('CngxStepperCommi
|
|
|
113
113
|
* @category common/stepper
|
|
114
114
|
*/
|
|
115
115
|
const STEPPER_DEFAULT_MOBILE_BREAKPOINT = '(max-width: 480px)';
|
|
116
|
+
/**
|
|
117
|
+
* Default per-step px thresholds for the `density: 'auto'` ladder. The
|
|
118
|
+
* literal lives on a single exported const so the runtime resolver, the
|
|
119
|
+
* config default, and any JSDoc cross-references stay in lockstep.
|
|
120
|
+
* Consumers override via {@link withStepperDensity}'s second argument.
|
|
121
|
+
*
|
|
122
|
+
* @category common/stepper
|
|
123
|
+
*/
|
|
124
|
+
const STEPPER_DEFAULT_DENSITY_BREAKPOINTS = {
|
|
125
|
+
compact: 120,
|
|
126
|
+
minimal: 64,
|
|
127
|
+
};
|
|
116
128
|
/** @internal */
|
|
117
129
|
const STEPPER_CONFIG_DEFAULTS = {
|
|
118
130
|
defaultOrientation: 'horizontal',
|
|
@@ -121,6 +133,11 @@ const STEPPER_CONFIG_DEFAULTS = {
|
|
|
121
133
|
routerSyncMode: 'fragment',
|
|
122
134
|
routerSyncParam: 'step',
|
|
123
135
|
skin: 'classic',
|
|
136
|
+
headerNavigation: 'visited',
|
|
137
|
+
groupCollapse: 'off',
|
|
138
|
+
groupCollapseSummary: 'progress',
|
|
139
|
+
density: 'comfortable',
|
|
140
|
+
densityBreakpoints: STEPPER_DEFAULT_DENSITY_BREAKPOINTS,
|
|
124
141
|
connectors: false,
|
|
125
142
|
mobileCollapse: 'text',
|
|
126
143
|
mobileBreakpoint: STEPPER_DEFAULT_MOBILE_BREAKPOINT,
|
|
@@ -280,6 +297,61 @@ function withStepperMobileIndicatorPosition(position) {
|
|
|
280
297
|
function withStepperMobileSwipe(enabled) {
|
|
281
298
|
return defineStepperConfigFeature((cfg) => ({ ...cfg, mobileSwipe: enabled }));
|
|
282
299
|
}
|
|
300
|
+
/**
|
|
301
|
+
* Set the app-wide default header-navigation policy for
|
|
302
|
+
* `<cngx-stepper>`. `'none'` renders inert label headers (footer-only
|
|
303
|
+
* navigation); `'visited'` (library default) keeps the headers as
|
|
304
|
+
* focusable buttons whose reachability folds into the `linear` axis.
|
|
305
|
+
* Per-instance `[headerNavigation]` Input still wins.
|
|
306
|
+
*
|
|
307
|
+
* @category common/stepper
|
|
308
|
+
*/
|
|
309
|
+
function withStepperHeaderNavigation(mode) {
|
|
310
|
+
return defineStepperConfigFeature((cfg) => ({ ...cfg, headerNavigation: mode }));
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Set the app-wide focus-driven group-collapse policy for grouped
|
|
314
|
+
* `<cngx-stepper>` flows. `'expand-active'` collapses every non-active
|
|
315
|
+
* `cngxStepGroup` branch to its header node and expands only the group
|
|
316
|
+
* holding the active step; `'off'` (library default) keeps the full
|
|
317
|
+
* strip. Orthogonal to the `mobileCollapse` axis. The Material twin
|
|
318
|
+
* ignores this setting.
|
|
319
|
+
*
|
|
320
|
+
* @category common/stepper
|
|
321
|
+
*/
|
|
322
|
+
function withStepperGroupCollapse(mode) {
|
|
323
|
+
return defineStepperConfigFeature((cfg) => ({ ...cfg, groupCollapse: mode }));
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Choose what a collapsed `cngxStepGroup` header shows beside its label
|
|
327
|
+
* under `groupCollapse: 'expand-active'`. `'progress'` (library default)
|
|
328
|
+
* shows completed/total steps; `'count'` the step count; `'status'` a
|
|
329
|
+
* status dot coloured by the group's rolled-up state; `'off'` the bare
|
|
330
|
+
* label. No effect unless `groupCollapse` is `'expand-active'`.
|
|
331
|
+
*
|
|
332
|
+
* @category common/stepper
|
|
333
|
+
*/
|
|
334
|
+
function withStepperGroupCollapseSummary(mode) {
|
|
335
|
+
return defineStepperConfigFeature((cfg) => ({ ...cfg, groupCollapseSummary: mode }));
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Set the app-wide space-driven density policy for the classic
|
|
339
|
+
* `<cngx-stepper>` strip. `'auto'` degrades labels on the strip's own
|
|
340
|
+
* container width (full -> compact -> minimal); `'comfortable'`
|
|
341
|
+
* (library default) keeps full labels at every width. The optional
|
|
342
|
+
* second argument overrides the per-step px thresholds (default
|
|
343
|
+
* {@link STEPPER_DEFAULT_DENSITY_BREAKPOINTS}). Orthogonal to the
|
|
344
|
+
* `mobileCollapse` axis; the Material twin ignores this setting.
|
|
345
|
+
*
|
|
346
|
+
* @category common/stepper
|
|
347
|
+
*/
|
|
348
|
+
function withStepperDensity(mode, breakpoints) {
|
|
349
|
+
return defineStepperConfigFeature((cfg) => ({
|
|
350
|
+
...cfg,
|
|
351
|
+
density: mode,
|
|
352
|
+
...(breakpoints ? { densityBreakpoints: breakpoints } : {}),
|
|
353
|
+
}));
|
|
354
|
+
}
|
|
283
355
|
/**
|
|
284
356
|
* Merge ARIA labels into the cascade. Keys not provided keep their
|
|
285
357
|
* library defaults; per-instance overrides on the stepper still win.
|
|
@@ -351,6 +423,20 @@ function withStepRejectionTemplate(template) {
|
|
|
351
423
|
templates: { ...cfg.templates, rejection: template },
|
|
352
424
|
}));
|
|
353
425
|
}
|
|
426
|
+
/**
|
|
427
|
+
* Override the default `*cngxStepError` template app-wide. The slot
|
|
428
|
+
* renders the per-step validation reason on the skins with a label area
|
|
429
|
+
* (classic / stripe-status-rich). Per-instance directive still wins;
|
|
430
|
+
* this moves the cascade middle tier.
|
|
431
|
+
*
|
|
432
|
+
* @category common/stepper
|
|
433
|
+
*/
|
|
434
|
+
function withStepErrorTemplate(template) {
|
|
435
|
+
return defineStepperConfigFeature((cfg) => ({
|
|
436
|
+
...cfg,
|
|
437
|
+
templates: { ...cfg.templates, stepError: template },
|
|
438
|
+
}));
|
|
439
|
+
}
|
|
354
440
|
/**
|
|
355
441
|
* Override the default `*cngxStepGroupHeader` template app-wide.
|
|
356
442
|
*
|
|
@@ -631,6 +717,67 @@ class CngxStepperPresenter {
|
|
|
631
717
|
const idx = this.clampedIndex();
|
|
632
718
|
return this.stepsOnly()[idx]?.id ?? null;
|
|
633
719
|
}, ...(ngDevMode ? [{ debugName: "activeStepId" }] : /* istanbul ignore next */ []));
|
|
720
|
+
/**
|
|
721
|
+
* {@inheritDoc CngxStepperHost.activeGroupId}
|
|
722
|
+
*
|
|
723
|
+
* Single derivation over `activeStepId` and `stepTree` - the root-level
|
|
724
|
+
* group whose subtree holds the active step, or `null` for a
|
|
725
|
+
* root-level active step (e.g. a trailing `Finish`). Walked once here;
|
|
726
|
+
* `CngxStepGroup.isCollapsed`, the strip `aria-expanded` binding, and
|
|
727
|
+
* `visibleStripNodes` read this rather than re-walking the tree.
|
|
728
|
+
*/
|
|
729
|
+
activeGroupId = computed(() => {
|
|
730
|
+
const activeId = this.activeStepId();
|
|
731
|
+
if (activeId === null) {
|
|
732
|
+
return null;
|
|
733
|
+
}
|
|
734
|
+
const subtreeHasActive = (node) => node.id === activeId || node.children.some(subtreeHasActive);
|
|
735
|
+
for (const root of this.stepTree()) {
|
|
736
|
+
if (root.kind === 'group' && subtreeHasActive(root)) {
|
|
737
|
+
return root.id;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
return null;
|
|
741
|
+
}, ...(ngDevMode ? [{ debugName: "activeGroupId" }] : /* istanbul ignore next */ []));
|
|
742
|
+
/**
|
|
743
|
+
* {@inheritDoc CngxStepperHost.visibleStripNodes}
|
|
744
|
+
*
|
|
745
|
+
* Flat strip projection honouring the focus-driven group-collapse
|
|
746
|
+
* policy. Under `'off'` it returns `flatSteps()` verbatim (same
|
|
747
|
+
* reference, so the `equal` short-circuits). Under `'expand-active'`
|
|
748
|
+
* every non-active root-level group's subtree is dropped, leaving the
|
|
749
|
+
* group header node alone - the active group and all root-level steps
|
|
750
|
+
* stay. Each retained node keeps its canonical `flatIndex` from
|
|
751
|
+
* `flatSteps`, so per-step state/announcement lookups are unaffected.
|
|
752
|
+
* Returns a fresh array, so it MUST carry `{ equal: flatStepsEqual }`
|
|
753
|
+
* or every re-emit cascades the strip `@for`.
|
|
754
|
+
*/
|
|
755
|
+
visibleStripNodes = computed(() => {
|
|
756
|
+
const flat = this.flatSteps();
|
|
757
|
+
if (this.config.groupCollapse !== 'expand-active') {
|
|
758
|
+
return flat;
|
|
759
|
+
}
|
|
760
|
+
const activeGroup = this.activeGroupId();
|
|
761
|
+
const collapsedRootIds = new Set(this.stepTree()
|
|
762
|
+
.filter((n) => n.kind === 'group' && n.children.length > 0 && n.id !== activeGroup)
|
|
763
|
+
.map((n) => n.id));
|
|
764
|
+
if (collapsedRootIds.size === 0) {
|
|
765
|
+
return flat;
|
|
766
|
+
}
|
|
767
|
+
const byId = new Map(flat.map((n) => [n.id, n]));
|
|
768
|
+
const rootAncestorId = (node) => {
|
|
769
|
+
let cur = node;
|
|
770
|
+
while (cur.parentId !== null) {
|
|
771
|
+
const parent = byId.get(cur.parentId);
|
|
772
|
+
if (!parent) {
|
|
773
|
+
break;
|
|
774
|
+
}
|
|
775
|
+
cur = parent;
|
|
776
|
+
}
|
|
777
|
+
return cur.id;
|
|
778
|
+
};
|
|
779
|
+
return flat.filter((node) => collapsedRootIds.has(node.id) || !collapsedRootIds.has(rootAncestorId(node)));
|
|
780
|
+
}, { ...(ngDevMode ? { debugName: "visibleStripNodes" } : /* istanbul ignore next */ {}), equal: flatStepsEqual });
|
|
634
781
|
commitState = this.commitController.state;
|
|
635
782
|
/**
|
|
636
783
|
* Next enabled step-only index after the active one, skipping
|
|
@@ -746,6 +893,7 @@ class CngxStepperPresenter {
|
|
|
746
893
|
disabled: entry.reg.disabled,
|
|
747
894
|
state: entry.reg.state,
|
|
748
895
|
errorAggregator: entry.reg.errorAggregator,
|
|
896
|
+
errorMessage: entry.reg.errorMessage,
|
|
749
897
|
children,
|
|
750
898
|
depth,
|
|
751
899
|
parentId: entry.parentId,
|
|
@@ -775,6 +923,24 @@ class CngxStepperPresenter {
|
|
|
775
923
|
.slice(this.activeStepIndex(), target)
|
|
776
924
|
.some((n) => n.state() !== 'success' && !n.disabled());
|
|
777
925
|
}
|
|
926
|
+
/**
|
|
927
|
+
* {@inheritDoc CngxStepperHost.canNavigateTo}
|
|
928
|
+
*
|
|
929
|
+
* Wraps the private {@link isLinearBlocked} predicate plus the
|
|
930
|
+
* per-step `disabled` check. The header-reachability contract surface;
|
|
931
|
+
* `isLinearBlocked` stays private so the organism reads this method,
|
|
932
|
+
* never the internal gate.
|
|
933
|
+
*/
|
|
934
|
+
canNavigateTo(index) {
|
|
935
|
+
const stepsOnly = this.stepsOnly();
|
|
936
|
+
if (index < 0 || index >= stepsOnly.length) {
|
|
937
|
+
return false;
|
|
938
|
+
}
|
|
939
|
+
if (stepsOnly[index].disabled()) {
|
|
940
|
+
return false;
|
|
941
|
+
}
|
|
942
|
+
return !this.isLinearBlocked(index);
|
|
943
|
+
}
|
|
778
944
|
select(index) {
|
|
779
945
|
const stepsOnly = this.stepsOnly();
|
|
780
946
|
if (stepsOnly.length === 0) {
|
|
@@ -918,7 +1084,7 @@ const CNGX_STEP_PANEL_HOST = new InjectionToken('CngxStepPanelHost');
|
|
|
918
1084
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/step-content.directive.ts
|
|
919
1085
|
* @since 0.1.0
|
|
920
1086
|
* @relatedTo CngxStep, CngxStepLabel
|
|
921
|
-
* <example-url>http://localhost:4200/#/ui/stepper/stepper-
|
|
1087
|
+
* <example-url>http://localhost:4200/#/ui/stepper/stepper-step-content/typed-lazy-panels</example-url>
|
|
922
1088
|
*/
|
|
923
1089
|
class CngxStepContent {
|
|
924
1090
|
templateRef = inject(TemplateRef);
|
|
@@ -979,7 +1145,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
979
1145
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/step.directive.ts
|
|
980
1146
|
* @since 0.1.0
|
|
981
1147
|
* @relatedTo CngxStepGroup, CngxStepperPresenter, CngxStepLabel, CngxStepContent
|
|
982
|
-
* <example-url>http://localhost:4200/#/ui/stepper/stepper-
|
|
1148
|
+
* <example-url>http://localhost:4200/#/ui/stepper/stepper-step-content/typed-lazy-panels</example-url>
|
|
983
1149
|
*/
|
|
984
1150
|
class CngxStep {
|
|
985
1151
|
id = input(nextUid('cngx-step'), ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
@@ -987,6 +1153,25 @@ class CngxStep {
|
|
|
987
1153
|
completed = input(false, ...(ngDevMode ? [{ debugName: "completed" }] : /* istanbul ignore next */ []));
|
|
988
1154
|
label = input('', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
989
1155
|
errorAggregator = input(undefined, ...(ngDevMode ? [{ debugName: "errorAggregator" }] : /* istanbul ignore next */ []));
|
|
1156
|
+
/**
|
|
1157
|
+
* Direct error flag for the common "this step is invalid" case - no
|
|
1158
|
+
* `errorAggregator` boilerplate required. `true` or a non-empty string
|
|
1159
|
+
* drives the error state; a string doubles as the inline message
|
|
1160
|
+
* (surfaced via the `*cngxStepError` slot and the mini-skin aggregate
|
|
1161
|
+
* line). `false` / `''` clear it. The aggregator stays the rich
|
|
1162
|
+
* multi-source forms path; the two channels compose (either errors).
|
|
1163
|
+
*/
|
|
1164
|
+
error = input(false, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
1165
|
+
/**
|
|
1166
|
+
* Resolved direct-error message: the `[error]` string when non-empty,
|
|
1167
|
+
* else `undefined`. Carried onto the registration / node so the error
|
|
1168
|
+
* slot + aggregate line can render it. `computed` over the input -
|
|
1169
|
+
* never written.
|
|
1170
|
+
*/
|
|
1171
|
+
errorMessage = computed(() => {
|
|
1172
|
+
const value = this.error();
|
|
1173
|
+
return typeof value === 'string' && value !== '' ? value : undefined;
|
|
1174
|
+
}, ...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
|
|
990
1175
|
labelSlot = contentChild(CngxStepLabel, ...(ngDevMode ? [{ debugName: "labelSlot" }] : /* istanbul ignore next */ []));
|
|
991
1176
|
contentSlot = contentChild(CngxStepContent, ...(ngDevMode ? [{ debugName: "contentSlot" }] : /* istanbul ignore next */ []));
|
|
992
1177
|
labelTemplate = this.labelSlot;
|
|
@@ -995,11 +1180,15 @@ class CngxStep {
|
|
|
995
1180
|
* Per-step status derived from inputs + aggregator. `linkedSignal`
|
|
996
1181
|
* with structural equal - never written via `effect`.
|
|
997
1182
|
*/
|
|
998
|
-
state = linkedSignal({ ...(ngDevMode ? { debugName: "state" } : /* istanbul ignore next */ {}), source: () =>
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
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
|
+
},
|
|
1003
1192
|
computation: ({ disabled, completed, errored }) => {
|
|
1004
1193
|
if (disabled) {
|
|
1005
1194
|
return 'disabled';
|
|
@@ -1029,11 +1218,12 @@ class CngxStep {
|
|
|
1029
1218
|
disabled: this.disabled,
|
|
1030
1219
|
state: this.state,
|
|
1031
1220
|
errorAggregator: this.errorAggregator,
|
|
1221
|
+
errorMessage: this.errorMessage,
|
|
1032
1222
|
});
|
|
1033
1223
|
inject(DestroyRef).onDestroy(() => host.unregister(stepId));
|
|
1034
1224
|
}
|
|
1035
1225
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStep, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1036
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxStep, isStandalone: true, selector: "[cngxStep]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, completed: { classPropertyName: "completed", publicName: "completed", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, errorAggregator: { classPropertyName: "errorAggregator", publicName: "errorAggregator", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "labelSlot", first: true, predicate: CngxStepLabel, descendants: true, isSignal: true }, { propertyName: "contentSlot", first: true, predicate: CngxStepContent, descendants: true, isSignal: true }], exportAs: ["cngxStep"], ngImport: i0 });
|
|
1226
|
+
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 });
|
|
1037
1227
|
}
|
|
1038
1228
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStep, decorators: [{
|
|
1039
1229
|
type: Directive,
|
|
@@ -1042,7 +1232,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1042
1232
|
exportAs: 'cngxStep',
|
|
1043
1233
|
standalone: true,
|
|
1044
1234
|
}]
|
|
1045
|
-
}], ctorParameters: () => [], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], completed: [{ type: i0.Input, args: [{ isSignal: true, alias: "completed", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], errorAggregator: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorAggregator", required: false }] }], labelSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxStepLabel), { isSignal: true }] }], contentSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxStepContent), { isSignal: true }] }] } });
|
|
1235
|
+
}], ctorParameters: () => [], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], completed: [{ type: i0.Input, args: [{ isSignal: true, alias: "completed", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], errorAggregator: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorAggregator", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }], labelSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxStepLabel), { isSignal: true }] }], contentSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxStepContent), { isSignal: true }] }] } });
|
|
1046
1236
|
|
|
1047
1237
|
/**
|
|
1048
1238
|
* Step-group atom. Registers with the root presenter as a `kind: 'group'`
|
|
@@ -1060,11 +1250,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1060
1250
|
* @since 0.1.0
|
|
1061
1251
|
* @relatedTo CngxStep, CngxStepperPresenter, CngxStepGroupHeader
|
|
1062
1252
|
* <example-url>http://localhost:4200/#/ui/stepper/stepper-hierarchical/group-nested-steps-trailing-root-step</example-url>
|
|
1253
|
+
* <example-url>http://localhost:4200/#/ui/stepper/stepper-hierarchical/expand-active-group-collapse</example-url>
|
|
1254
|
+
* <example-url>http://localhost:4200/#/ui/stepper/stepper-hierarchical/group-collapse-summary-count</example-url>
|
|
1063
1255
|
*/
|
|
1064
1256
|
class CngxStepGroup {
|
|
1065
1257
|
id = input(nextUid('cngx-step-group'), ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
1066
1258
|
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
1067
1259
|
label = input('', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
1260
|
+
config = injectStepperConfig();
|
|
1068
1261
|
// Local child registry - only feeds `aggregatedStatus` below.
|
|
1069
1262
|
// The presenter owns the canonical tree.
|
|
1070
1263
|
childRegistry = signal([], ...(ngDevMode ? [{ debugName: "childRegistry" }] : /* istanbul ignore next */ []));
|
|
@@ -1085,6 +1278,28 @@ class CngxStepGroup {
|
|
|
1085
1278
|
return 'idle';
|
|
1086
1279
|
}, { ...(ngDevMode ? { debugName: "aggregatedStatus" } : /* istanbul ignore next */ {}), equal: Object.is });
|
|
1087
1280
|
stepperHost = inject(CNGX_STEPPER_HOST, { optional: true });
|
|
1281
|
+
/**
|
|
1282
|
+
* `true` when this group's children are collapsed to the header node:
|
|
1283
|
+
* the focus-driven policy is `'expand-active'`, this group does not
|
|
1284
|
+
* hold the active step, and it has at least one child. Pure
|
|
1285
|
+
* `computed()` over the host's `activeGroupId` + the resolved policy -
|
|
1286
|
+
* never toggled in an event handler (Pillar 1).
|
|
1287
|
+
*
|
|
1288
|
+
* Consumer-readable via `exportAs: 'cngxStepGroup'` (e.g.
|
|
1289
|
+
* `#g="cngxStepGroup"` then `g.isCollapsed()`). The rendered strip
|
|
1290
|
+
* group header owns the reactive `aria-expanded` disclosure attribute
|
|
1291
|
+
* (`<cngx-stepper>` `groupAriaExpanded`); the projected `[cngxStepGroup]`
|
|
1292
|
+
* host element is not rendered in the strip, so it carries no ARIA.
|
|
1293
|
+
*/
|
|
1294
|
+
isCollapsed = computed(() => {
|
|
1295
|
+
if (this.config.groupCollapse !== 'expand-active') {
|
|
1296
|
+
return false;
|
|
1297
|
+
}
|
|
1298
|
+
if (this.childRegistry().length === 0) {
|
|
1299
|
+
return false;
|
|
1300
|
+
}
|
|
1301
|
+
return this.stepperHost?.activeGroupId() !== this.id();
|
|
1302
|
+
}, ...(ngDevMode ? [{ debugName: "isCollapsed" }] : /* istanbul ignore next */ []));
|
|
1088
1303
|
constructor() {
|
|
1089
1304
|
if (!this.stepperHost) {
|
|
1090
1305
|
throw new Error('CngxStepGroup: no enclosing CngxStepperPresenter found. ' +
|
|
@@ -1277,6 +1492,48 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1277
1492
|
}]
|
|
1278
1493
|
}] });
|
|
1279
1494
|
|
|
1495
|
+
/**
|
|
1496
|
+
* Slot directive for the per-step error-message template on
|
|
1497
|
+
* `<cngx-stepper>`. Discovered via `contentChild`; cascades through
|
|
1498
|
+
* `CNGX_STEPPER_CONFIG.templates.stepError` before falling back to the
|
|
1499
|
+
* built-in `{{ message }}` text. Mirrors {@link CngxStepRejection} so
|
|
1500
|
+
* consumer-authored templates read the same way across both channels.
|
|
1501
|
+
*
|
|
1502
|
+
* ```html
|
|
1503
|
+
* <cngx-stepper>
|
|
1504
|
+
* <ng-template cngxStepError let-message="message" let-errorLabels="errorLabels">
|
|
1505
|
+
* <strong>{{ message }}</strong>
|
|
1506
|
+
* @if (errorLabels.length > 1) {
|
|
1507
|
+
* <ul>
|
|
1508
|
+
* @for (label of errorLabels; track label) {
|
|
1509
|
+
* <li>{{ label }}</li>
|
|
1510
|
+
* }
|
|
1511
|
+
* </ul>
|
|
1512
|
+
* }
|
|
1513
|
+
* </ng-template>
|
|
1514
|
+
* </cngx-stepper>
|
|
1515
|
+
* ```
|
|
1516
|
+
*
|
|
1517
|
+
* @category common/stepper/slots
|
|
1518
|
+
* @wcag AA
|
|
1519
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/slots/step-error.directive.ts
|
|
1520
|
+
* @since 0.1.0
|
|
1521
|
+
* @relatedTo CngxStepRejection, CngxStepBadge, CngxStep
|
|
1522
|
+
*/
|
|
1523
|
+
class CngxStepError {
|
|
1524
|
+
templateRef = inject(TemplateRef);
|
|
1525
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepError, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1526
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxStepError, isStandalone: true, selector: "ng-template[cngxStepError]", exportAs: ["cngxStepError"], ngImport: i0 });
|
|
1527
|
+
}
|
|
1528
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepError, decorators: [{
|
|
1529
|
+
type: Directive,
|
|
1530
|
+
args: [{
|
|
1531
|
+
selector: 'ng-template[cngxStepError]',
|
|
1532
|
+
exportAs: 'cngxStepError',
|
|
1533
|
+
standalone: true,
|
|
1534
|
+
}]
|
|
1535
|
+
}] });
|
|
1536
|
+
|
|
1280
1537
|
/**
|
|
1281
1538
|
* Slot directive for the group-header template on `<cngx-stepper>`.
|
|
1282
1539
|
* Discovered via `contentChild`; cascades through
|
|
@@ -1377,7 +1634,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1377
1634
|
* @since 0.1.0
|
|
1378
1635
|
* @relatedTo CngxStepIndicator, CngxStepBadge, CngxStepBusySpinner, CngxStepRejection
|
|
1379
1636
|
* <example-url>http://localhost:4200/#/ui/stepper/dot-stepper/icon-dots-via-code-cngxdotstepperdot-code</example-url>
|
|
1380
|
-
* <example-url>http://localhost:4200/#/ui/stepper/dot-stepper/mobile-carousel</example-url>
|
|
1381
1637
|
*/
|
|
1382
1638
|
class CngxDotStepperDot {
|
|
1383
1639
|
templateRef = inject(TemplateRef);
|
|
@@ -1394,15 +1650,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1394
1650
|
}] });
|
|
1395
1651
|
|
|
1396
1652
|
/**
|
|
1397
|
-
* Wires the 3-stage template cascade for the
|
|
1398
|
-
*
|
|
1653
|
+
* Wires the 3-stage template cascade for the `<cngx-stepper>` skin
|
|
1654
|
+
* slots: per-instance directive > `CNGX_STEPPER_CONFIG.templates.<key>`
|
|
1399
1655
|
* > `null` (built-in default).
|
|
1400
1656
|
*
|
|
1401
|
-
* Pure
|
|
1657
|
+
* Pure - no DI, no side effects. Safe to call from a field-init
|
|
1402
1658
|
* block. Sibling of `createTabOverflowTemplateBindings` and the
|
|
1403
1659
|
* family-wide `createTemplateRegistry`.
|
|
1404
1660
|
*
|
|
1405
|
-
* Tabs has no parallel slot surface yet
|
|
1661
|
+
* Tabs has no parallel slot surface yet - see
|
|
1406
1662
|
* `stepper-accepted-debt §3` for the planned Phase-4 closure.
|
|
1407
1663
|
*
|
|
1408
1664
|
* @category common/stepper/slots
|
|
@@ -1421,6 +1677,9 @@ function createStepperTemplateBindings(opts) {
|
|
|
1421
1677
|
rejection: computed(() => opts.rejectionSlot()?.templateRef ??
|
|
1422
1678
|
opts.config.templates?.rejection ??
|
|
1423
1679
|
null),
|
|
1680
|
+
stepError: computed(() => opts.errorSlot?.()?.templateRef ??
|
|
1681
|
+
opts.config.templates?.stepError ??
|
|
1682
|
+
null),
|
|
1424
1683
|
groupHeader: computed(() => opts.groupHeaderSlot()?.templateRef ??
|
|
1425
1684
|
opts.config.templates?.groupHeader ??
|
|
1426
1685
|
null),
|
|
@@ -1572,7 +1831,7 @@ const STEPPER_I18N_DEFAULTS = {
|
|
|
1572
1831
|
stepHasErrors: (count) => `${count} error${count === 1 ? '' : 's'}`,
|
|
1573
1832
|
previousStep: 'Previous step',
|
|
1574
1833
|
nextStep: 'Next step',
|
|
1575
|
-
commitFailedRetry: 'Commit failed
|
|
1834
|
+
commitFailedRetry: 'Commit failed - retry?',
|
|
1576
1835
|
commitInFlight: 'Committing step…',
|
|
1577
1836
|
commitRolledBackTo: (originLabel) => `Reverted to step "${originLabel}".`,
|
|
1578
1837
|
stepRolledBackSuffix: 'This step was rolled back.',
|
|
@@ -1731,6 +1990,161 @@ function createStepperDisplayMode(mediaQuery, mobileCollapse, destroyRef) {
|
|
|
1731
1990
|
});
|
|
1732
1991
|
}
|
|
1733
1992
|
|
|
1993
|
+
/**
|
|
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.
|
|
2000
|
+
*/
|
|
2001
|
+
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();
|
|
2012
|
+
}
|
|
2013
|
+
/**
|
|
2014
|
+
* Resolves the classic strip's density rung from its own container
|
|
2015
|
+
* 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`.
|
|
2019
|
+
*
|
|
2020
|
+
* `'comfortable'` density short-circuits to `'full'` (no measurement
|
|
2021
|
+
* dependency). Before the first measurement (`width === 0`) and for an
|
|
2022
|
+
* empty strip the rung is `'full'`, so the strip never flashes
|
|
2023
|
+
* `'minimal'` on mount.
|
|
2024
|
+
*
|
|
2025
|
+
* @category common/stepper
|
|
2026
|
+
*/
|
|
2027
|
+
function createStripDensity(options) {
|
|
2028
|
+
const width = createElementWidthSignal(options.element, options.destroyRef);
|
|
2029
|
+
return computed(() => {
|
|
2030
|
+
if ((options.density() ?? 'comfortable') !== 'auto') {
|
|
2031
|
+
return 'full';
|
|
2032
|
+
}
|
|
2033
|
+
const count = options.stepCount();
|
|
2034
|
+
const measured = width();
|
|
2035
|
+
if (count === 0 || measured === 0) {
|
|
2036
|
+
return 'full';
|
|
2037
|
+
}
|
|
2038
|
+
const perStep = measured / count;
|
|
2039
|
+
const { compact, minimal } = options.breakpoints();
|
|
2040
|
+
if (perStep >= compact) {
|
|
2041
|
+
return 'full';
|
|
2042
|
+
}
|
|
2043
|
+
if (perStep >= minimal) {
|
|
2044
|
+
return 'compact';
|
|
2045
|
+
}
|
|
2046
|
+
return 'minimal';
|
|
2047
|
+
});
|
|
2048
|
+
}
|
|
2049
|
+
|
|
2050
|
+
/** Terminal-step totals for a group's subtree; reads each step `state()`. */
|
|
2051
|
+
function subtreeStats(node) {
|
|
2052
|
+
let total = 0;
|
|
2053
|
+
let completed = 0;
|
|
2054
|
+
const visit = (n) => {
|
|
2055
|
+
if (n.kind === 'step') {
|
|
2056
|
+
total++;
|
|
2057
|
+
if (n.state() === 'success') {
|
|
2058
|
+
completed++;
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
n.children.forEach(visit);
|
|
2062
|
+
};
|
|
2063
|
+
node.children.forEach(visit);
|
|
2064
|
+
return { total, completed };
|
|
2065
|
+
}
|
|
2066
|
+
/**
|
|
2067
|
+
* Builds the collapsed-group summary view. Level-2 helper so the
|
|
2068
|
+
* organism stays a thin renderer. `status` mode defers its SR phrasing
|
|
2069
|
+
* 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).
|
|
2072
|
+
*
|
|
2073
|
+
* @category common/stepper
|
|
2074
|
+
*/
|
|
2075
|
+
function createStepperGroupSummary(options) {
|
|
2076
|
+
const mode = computed(() => options.summaryMode() ?? 'progress', ...(ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []));
|
|
2077
|
+
const text = (node) => {
|
|
2078
|
+
const current = mode();
|
|
2079
|
+
if (current === 'off' || current === 'status' || !options.isCollapsed(node)) {
|
|
2080
|
+
return null;
|
|
2081
|
+
}
|
|
2082
|
+
const { total, completed } = subtreeStats(node);
|
|
2083
|
+
return current === 'count' ? String(total) : `${completed}/${total}`;
|
|
2084
|
+
};
|
|
2085
|
+
const showStatus = (node) => mode() === 'status' && options.isCollapsed(node);
|
|
2086
|
+
const srText = (node) => {
|
|
2087
|
+
const current = mode();
|
|
2088
|
+
if (current === 'off' || current === 'status' || !options.isCollapsed(node)) {
|
|
2089
|
+
return null;
|
|
2090
|
+
}
|
|
2091
|
+
const { total, completed } = subtreeStats(node);
|
|
2092
|
+
return current === 'count' ? `${total} steps` : `${completed} of ${total} steps complete`;
|
|
2093
|
+
};
|
|
2094
|
+
return { mode, text, showStatus, srText };
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2097
|
+
/**
|
|
2098
|
+
* Builds the collapsed-group pointer-navigation view. Level-2 helper so
|
|
2099
|
+
* the organism stays a thin renderer.
|
|
2100
|
+
*
|
|
2101
|
+
* Indices resolve against `flatSteps` (DFS order, live `flatIndex`) rather
|
|
2102
|
+
* than `group.children` - the flattener spreads group nodes but leaves
|
|
2103
|
+
* their `children` as the tree projection where every step still carries
|
|
2104
|
+
* the seeded `-1`. Each candidate is gated by `canNavigateTo` + `busy`
|
|
2105
|
+
* (mirroring the step-header reachability), so a linear-blocked leading
|
|
2106
|
+
* step is skipped to the first reachable one.
|
|
2107
|
+
*
|
|
2108
|
+
* @category common/stepper
|
|
2109
|
+
*/
|
|
2110
|
+
function createStepperGroupNavigation(options) {
|
|
2111
|
+
const { presenter } = options;
|
|
2112
|
+
const firstNavigableStepIndex = (group) => {
|
|
2113
|
+
const flat = presenter.flatSteps();
|
|
2114
|
+
const byId = new Map(flat.map((node) => [node.id, node]));
|
|
2115
|
+
const isInGroup = (node) => {
|
|
2116
|
+
let cur = node;
|
|
2117
|
+
while (cur && cur.parentId !== null) {
|
|
2118
|
+
if (cur.parentId === group.id) {
|
|
2119
|
+
return true;
|
|
2120
|
+
}
|
|
2121
|
+
cur = byId.get(cur.parentId);
|
|
2122
|
+
}
|
|
2123
|
+
return false;
|
|
2124
|
+
};
|
|
2125
|
+
for (const node of flat) {
|
|
2126
|
+
if (node.kind === 'step' &&
|
|
2127
|
+
isInGroup(node) &&
|
|
2128
|
+
presenter.canNavigateTo(node.flatIndex) &&
|
|
2129
|
+
!presenter.busy()) {
|
|
2130
|
+
return node.flatIndex;
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
return -1;
|
|
2134
|
+
};
|
|
2135
|
+
const isNavigable = (node) => options.navigationEnabled() &&
|
|
2136
|
+
options.isCollapsed(node) &&
|
|
2137
|
+
firstNavigableStepIndex(node) !== -1;
|
|
2138
|
+
const select = (node) => {
|
|
2139
|
+
if (!isNavigable(node)) {
|
|
2140
|
+
return;
|
|
2141
|
+
}
|
|
2142
|
+
presenter.select(firstNavigableStepIndex(node));
|
|
2143
|
+
};
|
|
2144
|
+
const isActive = (node) => node.kind === 'group' && presenter.activeGroupId() === node.id;
|
|
2145
|
+
return { isNavigable, select, isActive };
|
|
2146
|
+
}
|
|
2147
|
+
|
|
1734
2148
|
/**
|
|
1735
2149
|
* Level-2 helper resolving the three host-attribute cascades for
|
|
1736
2150
|
* `<cngx-stepper>` (skin / connectors / mobileIndicatorPosition). Keeps
|
|
@@ -1766,13 +2180,25 @@ function createStepperHostAttrs(inputs) {
|
|
|
1766
2180
|
*/
|
|
1767
2181
|
function createStepperStripKeyboardNav(options) {
|
|
1768
2182
|
const stepClass = options.stepClassName ?? 'cngx-stepper__step';
|
|
2183
|
+
const scheduleFocus = (focus) => {
|
|
2184
|
+
// After the next render when an injector is supplied (the strip may
|
|
2185
|
+
// re-render its node set on a group-boundary crossing); a microtask
|
|
2186
|
+
// otherwise. Either way the focus runs after the active-step signal
|
|
2187
|
+
// has settled, so the target button exists.
|
|
2188
|
+
if (options.injector) {
|
|
2189
|
+
afterNextRender(focus, { injector: options.injector });
|
|
2190
|
+
}
|
|
2191
|
+
else {
|
|
2192
|
+
queueMicrotask(focus);
|
|
2193
|
+
}
|
|
2194
|
+
};
|
|
1769
2195
|
const focusActive = () => {
|
|
1770
2196
|
const activeId = options.presenter.activeStepId();
|
|
1771
2197
|
if (!activeId) {
|
|
1772
2198
|
return;
|
|
1773
2199
|
}
|
|
1774
2200
|
const buttonId = options.stepButtonIdFor(activeId);
|
|
1775
|
-
|
|
2201
|
+
scheduleFocus(() => {
|
|
1776
2202
|
const el = options.hostElement.querySelector(`[id="${buttonId}"]`);
|
|
1777
2203
|
if (el instanceof HTMLElement) {
|
|
1778
2204
|
el.focus();
|
|
@@ -1780,6 +2206,9 @@ function createStepperStripKeyboardNav(options) {
|
|
|
1780
2206
|
});
|
|
1781
2207
|
};
|
|
1782
2208
|
return (event) => {
|
|
2209
|
+
if (options.enabled && !options.enabled()) {
|
|
2210
|
+
return;
|
|
2211
|
+
}
|
|
1783
2212
|
const target = event.target;
|
|
1784
2213
|
if (!target?.classList.contains(stepClass)) {
|
|
1785
2214
|
return;
|
|
@@ -1810,6 +2239,84 @@ function createStepperStripKeyboardNav(options) {
|
|
|
1810
2239
|
};
|
|
1811
2240
|
}
|
|
1812
2241
|
|
|
2242
|
+
/**
|
|
2243
|
+
* Build the shared {@link CngxStepperStateView} over a presenter host and its
|
|
2244
|
+
* step-only projection. Pure factory - `computed()` only, no injection
|
|
2245
|
+
* context required, so any skin can allocate it in a field initializer.
|
|
2246
|
+
*
|
|
2247
|
+
* @category common/stepper
|
|
2248
|
+
* @since 0.1.0
|
|
2249
|
+
* @relatedTo CngxStepperHost, createStepperSlotContextBuilders
|
|
2250
|
+
*/
|
|
2251
|
+
function createStepperStateView(inputs) {
|
|
2252
|
+
const { presenter, stepsOnly } = inputs;
|
|
2253
|
+
const statusOf = (node) => node.state();
|
|
2254
|
+
const isBusy = (node) => node.kind === 'step' &&
|
|
2255
|
+
presenter.commitState.status() === 'pending' &&
|
|
2256
|
+
presenter.intendedStepIndex() === node.flatIndex;
|
|
2257
|
+
const isRejected = (node) => node.kind === 'step' && node.flatIndex >= 0 && node.flatIndex === presenter.lastFailedIndex();
|
|
2258
|
+
const hasErrorBadge = (node) => {
|
|
2259
|
+
if (node.kind !== 'step') {
|
|
2260
|
+
return false;
|
|
2261
|
+
}
|
|
2262
|
+
if (node.state() === 'error') {
|
|
2263
|
+
return true;
|
|
2264
|
+
}
|
|
2265
|
+
return !!node.errorAggregator?.()?.shouldShow?.();
|
|
2266
|
+
};
|
|
2267
|
+
const hasError = (node) => hasErrorBadge(node) || isRejected(node);
|
|
2268
|
+
const erroredSteps = computed(() => stepsOnly().filter((node) => hasError(node)), ...(ngDevMode ? [{ debugName: "erroredSteps" }] : /* istanbul ignore next */ []));
|
|
2269
|
+
const errorCount = computed(() => erroredSteps().length, ...(ngDevMode ? [{ debugName: "errorCount" }] : /* istanbul ignore next */ []));
|
|
2270
|
+
const firstErrorIndex = computed(() => erroredSteps()[0]?.flatIndex ?? -1, ...(ngDevMode ? [{ debugName: "firstErrorIndex" }] : /* istanbul ignore next */ []));
|
|
2271
|
+
const hasAnyError = computed(() => errorCount() > 0, ...(ngDevMode ? [{ debugName: "hasAnyError" }] : /* istanbul ignore next */ []));
|
|
2272
|
+
return {
|
|
2273
|
+
statusOf,
|
|
2274
|
+
isBusy,
|
|
2275
|
+
isRejected,
|
|
2276
|
+
hasErrorBadge,
|
|
2277
|
+
hasError,
|
|
2278
|
+
errorCount,
|
|
2279
|
+
firstErrorIndex,
|
|
2280
|
+
hasAnyError,
|
|
2281
|
+
};
|
|
2282
|
+
}
|
|
2283
|
+
/**
|
|
2284
|
+
* Aggregate error phrase shared by the minimal skins (text / progress-bar)
|
|
2285
|
+
* and the classic mobile-collapse text branch. A single errored step names
|
|
2286
|
+
* itself (`"Payment: Errored"`); several collapse to the i18n count phrase
|
|
2287
|
+
* (`"2 errors"`). Returns `''` when no step errored - callers gate on
|
|
2288
|
+
* `view.hasAnyError()` so the empty string never reaches the DOM.
|
|
2289
|
+
*
|
|
2290
|
+
* The optional `messageOf` resolver lets callers surface a per-step
|
|
2291
|
+
* reason (a direct `[error]` string or the first aggregator label) in the
|
|
2292
|
+
* single-error case instead of the generic `errored` status word. When
|
|
2293
|
+
* omitted - or when it returns `undefined`/`''` - the helper produces
|
|
2294
|
+
* byte-identical output to the no-resolver form, so existing callers
|
|
2295
|
+
* (the classic mobile-collapse summary) are a guaranteed no-op.
|
|
2296
|
+
*
|
|
2297
|
+
* Pure helper - reads signals at call time, intended to be wrapped in the
|
|
2298
|
+
* caller's `computed()`.
|
|
2299
|
+
*
|
|
2300
|
+
* @category common/stepper
|
|
2301
|
+
* @since 0.1.0
|
|
2302
|
+
*/
|
|
2303
|
+
function resolveStepperErrorSummary(view, stepsOnly, i18n, messageOf) {
|
|
2304
|
+
const count = view.errorCount();
|
|
2305
|
+
if (count === 0) {
|
|
2306
|
+
return '';
|
|
2307
|
+
}
|
|
2308
|
+
if (count === 1) {
|
|
2309
|
+
const node = stepsOnly()[view.firstErrorIndex()];
|
|
2310
|
+
const custom = node ? messageOf?.(node) : undefined;
|
|
2311
|
+
if (custom !== undefined && custom !== '') {
|
|
2312
|
+
return custom;
|
|
2313
|
+
}
|
|
2314
|
+
const label = node?.label();
|
|
2315
|
+
return label ? `${label}: ${i18n.statusLabels.errored}` : i18n.statusLabels.errored;
|
|
2316
|
+
}
|
|
2317
|
+
return i18n.stepHasErrors(count);
|
|
2318
|
+
}
|
|
2319
|
+
|
|
1813
2320
|
/**
|
|
1814
2321
|
* Wrap a `(node) => TContext` builder so identical results return the
|
|
1815
2322
|
* same reference. Keyed by the node object via `WeakMap`, so step-list
|
|
@@ -1849,31 +2356,28 @@ function shallowEqual(a, b) {
|
|
|
1849
2356
|
return true;
|
|
1850
2357
|
}
|
|
1851
2358
|
/**
|
|
1852
|
-
* Bundle the
|
|
1853
|
-
* `isActive` / `isStepBusy` / `showRejection` / `showErrorBadge`
|
|
1854
|
-
* the organism's template reads. Lives at
|
|
1855
|
-
* organism stays a thin shell
|
|
2359
|
+
* Bundle the `*ContextFor` slot-context builders plus the small
|
|
2360
|
+
* `isActive` / `isStepBusy` / `showRejection` / `showErrorBadge` /
|
|
2361
|
+
* `showStepError` predicates the organism's template reads. Lives at
|
|
2362
|
+
* Level 2 so the `<cngx-stepper>` organism stays a thin shell.
|
|
1856
2363
|
*
|
|
1857
2364
|
* @internal
|
|
1858
2365
|
*/
|
|
1859
2366
|
function createStepperSlotContextBuilders(inputs) {
|
|
1860
|
-
const { presenter, stepsOnly } = inputs;
|
|
2367
|
+
const { presenter, stepsOnly, i18n } = inputs;
|
|
2368
|
+
// Single source for every per-step status / error / busy / rejection
|
|
2369
|
+
// derivation. The dot / text / progress-bar skins read the same view,
|
|
2370
|
+
// so the error contract stays identical across all four.
|
|
2371
|
+
const stateView = createStepperStateView({ presenter, stepsOnly });
|
|
1861
2372
|
const isActive = (node) => node.kind === 'step' && node.id === presenter.activeStepId();
|
|
1862
|
-
const isStepBusy =
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
return false;
|
|
1871
|
-
}
|
|
1872
|
-
if (node.state() === 'error') {
|
|
1873
|
-
return true;
|
|
1874
|
-
}
|
|
1875
|
-
return !!node.errorAggregator?.()?.shouldShow?.();
|
|
1876
|
-
};
|
|
2373
|
+
const isStepBusy = stateView.isBusy;
|
|
2374
|
+
const showRejection = stateView.isRejected;
|
|
2375
|
+
const showErrorBadge = stateView.hasErrorBadge;
|
|
2376
|
+
// Validation-channel gate for the per-step error message. Mirrors the
|
|
2377
|
+
// error badge (state === 'error' via [error] / aggregator); the commit
|
|
2378
|
+
// rejection keeps its own `showRejection` slot, so the two channels
|
|
2379
|
+
// stay distinct.
|
|
2380
|
+
const showStepError = stateView.hasErrorBadge;
|
|
1877
2381
|
// Memoize per-node so identical contexts return the same reference.
|
|
1878
2382
|
// *ngTemplateOutlet pays an ngOnChanges shallow comparison on its
|
|
1879
2383
|
// `context:` binding every CD pass; without this cache the outlet
|
|
@@ -1904,6 +2408,16 @@ function createStepperSlotContextBuilders(inputs) {
|
|
|
1904
2408
|
const originLabel = originIdx !== undefined ? stepsOnly()[originIdx]?.label() : undefined;
|
|
1905
2409
|
return { failedIndex, originLabel, node };
|
|
1906
2410
|
});
|
|
2411
|
+
const stepErrorContextFor = memoizeByNode((node) => {
|
|
2412
|
+
const aggregator = node.errorAggregator?.();
|
|
2413
|
+
const errorLabels = aggregator?.errorLabels?.() ?? [];
|
|
2414
|
+
const announcement = aggregator?.announcement?.() ?? '';
|
|
2415
|
+
// Resolution order: direct [error] string > first aggregator label >
|
|
2416
|
+
// i18n errored status phrase. Always non-empty so a bare
|
|
2417
|
+
// `{{ message }}` template renders a reason.
|
|
2418
|
+
const message = node.errorMessage?.() ?? errorLabels[0] ?? i18n.statusLabels.errored;
|
|
2419
|
+
return { node, message, errorLabels, announcement };
|
|
2420
|
+
});
|
|
1907
2421
|
const groupHeaderContextFor = memoizeByNode((node) => ({
|
|
1908
2422
|
group: node,
|
|
1909
2423
|
expanded: true,
|
|
@@ -1933,10 +2447,12 @@ function createStepperSlotContextBuilders(inputs) {
|
|
|
1933
2447
|
isStepBusy,
|
|
1934
2448
|
showRejection,
|
|
1935
2449
|
showErrorBadge,
|
|
2450
|
+
showStepError,
|
|
1936
2451
|
indicatorContextFor,
|
|
1937
2452
|
badgeContextFor,
|
|
1938
2453
|
busySpinnerContextFor,
|
|
1939
2454
|
rejectionContextFor,
|
|
2455
|
+
stepErrorContextFor,
|
|
1940
2456
|
groupHeaderContextFor,
|
|
1941
2457
|
stepLabelContextFor,
|
|
1942
2458
|
stepContentContextFor,
|
|
@@ -2404,8 +2920,10 @@ function createStepperHostProxy(supplier) {
|
|
|
2404
2920
|
stepTree: computed(() => supplier()?.stepTree() ?? EMPTY_NODES),
|
|
2405
2921
|
flatSteps: computed(() => supplier()?.flatSteps() ?? EMPTY_NODES),
|
|
2406
2922
|
stepsOnly: computed(() => supplier()?.stepsOnly() ?? EMPTY_NODES),
|
|
2923
|
+
visibleStripNodes: computed(() => supplier()?.visibleStripNodes() ?? EMPTY_NODES),
|
|
2407
2924
|
activeStepIndex: computed(() => supplier()?.activeStepIndex() ?? -1),
|
|
2408
2925
|
activeStepId: computed(() => supplier()?.activeStepId() ?? null),
|
|
2926
|
+
activeGroupId: computed(() => supplier()?.activeGroupId() ?? null),
|
|
2409
2927
|
linear: computed(() => supplier()?.linear() ?? false),
|
|
2410
2928
|
orientation: computed(() => supplier()?.orientation() ?? 'horizontal'),
|
|
2411
2929
|
intendedStepIndex: computed(() => supplier()?.intendedStepIndex()),
|
|
@@ -2434,6 +2952,9 @@ function createStepperHostProxy(supplier) {
|
|
|
2434
2952
|
current: computed(() => supplier()?.commitTransition.current() ?? 'idle'),
|
|
2435
2953
|
previous: computed(() => supplier()?.commitTransition.previous() ?? 'idle'),
|
|
2436
2954
|
},
|
|
2955
|
+
// Reachability predicate - neutral `false` when null so a header
|
|
2956
|
+
// over a missing host is never falsely navigable.
|
|
2957
|
+
canNavigateTo: (index) => supplier()?.canNavigateTo(index) ?? false,
|
|
2437
2958
|
// Methods forward; no-op when null.
|
|
2438
2959
|
select: (index) => supplier()?.select(index),
|
|
2439
2960
|
selectNext: () => supplier()?.selectNext(),
|
|
@@ -2535,7 +3056,7 @@ function provideCngxStepperAt(...features) {
|
|
|
2535
3056
|
*
|
|
2536
3057
|
* Level-2 directive-only logic for stepper / wizard flows. Ships the
|
|
2537
3058
|
* presenter brain, atom directives, host tokens, router-sync, config
|
|
2538
|
-
* cascade, and i18n. Zero `@Component`, zero `.html`, zero `.css`
|
|
3059
|
+
* cascade, and i18n. Zero `@Component`, zero `.html`, zero `.css` -
|
|
2539
3060
|
* those live in `@cngx/ui/stepper` (CNGX-standard skin) and
|
|
2540
3061
|
* `@cngx/ui/mat-stepper` (Material twin).
|
|
2541
3062
|
*/
|
|
@@ -2544,5 +3065,5 @@ function provideCngxStepperAt(...features) {
|
|
|
2544
3065
|
* Generated bundle index. Do not edit.
|
|
2545
3066
|
*/
|
|
2546
3067
|
|
|
2547
|
-
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, CngxStepGroup, CngxStepGroupHeader, CngxStepIndicator, CngxStepLabel, CngxStepRejection, CngxStepperComplete, CngxStepperCount, CngxStepperEmpty, CngxStepperNext, CngxStepperPresenter, CngxStepperPrevious, CngxStepperRouterSync, CngxStepperSwipeNav, STEPPER_DEFAULT_MOBILE_BREAKPOINT, createMobileViewportSignal, createStepperAnnouncementBuilders, createStepperCommitHandler, createStepperDisplayMode, createStepperHostAttrs, createStepperHostProxy, createStepperSlotContextBuilders, createStepperStripKeyboardNav, createStepperTemplateBindings, flatStepsEqual, injectStepperConfig, injectStepperI18n, provideCngxStepper, provideCngxStepperAt, provideStepperConfig, provideStepperConfigAt, provideStepperI18n, resolveStepperStatusLabel, withDotStepperDotTemplate, withStepBadgeTemplate, withStepBusySpinnerTemplate, withStepGroupHeaderTemplate, withStepIndicatorTemplate, withStepRejectionTemplate, withStepperAriaLabels, withStepperCommitMode, withStepperConnectors, withStepperDefaultOrientation, withStepperEmptyTemplate, withStepperFallbackLabels, withStepperI18nLabels, withStepperLinear, withStepperMobileBreakpoint, withStepperMobileCollapse, withStepperMobileIndicatorPosition, withStepperMobileSwipe, withStepperRouterSync, withStepperSkin };
|
|
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 };
|
|
2548
3069
|
//# sourceMappingURL=cngx-common-stepper.mjs.map
|