@cngx/common 0.1.0-rc.1 → 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-data.mjs +64 -48
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +318 -5
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +532 -151
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +1 -1
- package/package.json +2 -2
- package/stepper/README.md +0 -13
- package/types/cngx-common-data.d.ts +46 -33
- package/types/cngx-common-stepper.d.ts +350 -6
- package/types/cngx-common-tabs.d.ts +586 -191
- 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',
|
|
@@ -122,6 +134,10 @@ const STEPPER_CONFIG_DEFAULTS = {
|
|
|
122
134
|
routerSyncParam: 'step',
|
|
123
135
|
skin: 'classic',
|
|
124
136
|
headerNavigation: 'visited',
|
|
137
|
+
groupCollapse: 'off',
|
|
138
|
+
groupCollapseSummary: 'progress',
|
|
139
|
+
density: 'comfortable',
|
|
140
|
+
densityBreakpoints: STEPPER_DEFAULT_DENSITY_BREAKPOINTS,
|
|
125
141
|
connectors: false,
|
|
126
142
|
mobileCollapse: 'text',
|
|
127
143
|
mobileBreakpoint: STEPPER_DEFAULT_MOBILE_BREAKPOINT,
|
|
@@ -293,6 +309,49 @@ function withStepperMobileSwipe(enabled) {
|
|
|
293
309
|
function withStepperHeaderNavigation(mode) {
|
|
294
310
|
return defineStepperConfigFeature((cfg) => ({ ...cfg, headerNavigation: mode }));
|
|
295
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
|
+
}
|
|
296
355
|
/**
|
|
297
356
|
* Merge ARIA labels into the cascade. Keys not provided keep their
|
|
298
357
|
* library defaults; per-instance overrides on the stepper still win.
|
|
@@ -658,6 +717,67 @@ class CngxStepperPresenter {
|
|
|
658
717
|
const idx = this.clampedIndex();
|
|
659
718
|
return this.stepsOnly()[idx]?.id ?? null;
|
|
660
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 });
|
|
661
781
|
commitState = this.commitController.state;
|
|
662
782
|
/**
|
|
663
783
|
* Next enabled step-only index after the active one, skipping
|
|
@@ -964,7 +1084,7 @@ const CNGX_STEP_PANEL_HOST = new InjectionToken('CngxStepPanelHost');
|
|
|
964
1084
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/step-content.directive.ts
|
|
965
1085
|
* @since 0.1.0
|
|
966
1086
|
* @relatedTo CngxStep, CngxStepLabel
|
|
967
|
-
* <example-url>http://localhost:4200/#/ui/stepper/stepper-
|
|
1087
|
+
* <example-url>http://localhost:4200/#/ui/stepper/stepper-step-content/typed-lazy-panels</example-url>
|
|
968
1088
|
*/
|
|
969
1089
|
class CngxStepContent {
|
|
970
1090
|
templateRef = inject(TemplateRef);
|
|
@@ -1025,7 +1145,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1025
1145
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/step.directive.ts
|
|
1026
1146
|
* @since 0.1.0
|
|
1027
1147
|
* @relatedTo CngxStepGroup, CngxStepperPresenter, CngxStepLabel, CngxStepContent
|
|
1028
|
-
* <example-url>http://localhost:4200/#/ui/stepper/stepper-
|
|
1148
|
+
* <example-url>http://localhost:4200/#/ui/stepper/stepper-step-content/typed-lazy-panels</example-url>
|
|
1029
1149
|
*/
|
|
1030
1150
|
class CngxStep {
|
|
1031
1151
|
id = input(nextUid('cngx-step'), ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
@@ -1130,11 +1250,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1130
1250
|
* @since 0.1.0
|
|
1131
1251
|
* @relatedTo CngxStep, CngxStepperPresenter, CngxStepGroupHeader
|
|
1132
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>
|
|
1133
1255
|
*/
|
|
1134
1256
|
class CngxStepGroup {
|
|
1135
1257
|
id = input(nextUid('cngx-step-group'), ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
1136
1258
|
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
1137
1259
|
label = input('', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
1260
|
+
config = injectStepperConfig();
|
|
1138
1261
|
// Local child registry - only feeds `aggregatedStatus` below.
|
|
1139
1262
|
// The presenter owns the canonical tree.
|
|
1140
1263
|
childRegistry = signal([], ...(ngDevMode ? [{ debugName: "childRegistry" }] : /* istanbul ignore next */ []));
|
|
@@ -1155,6 +1278,28 @@ class CngxStepGroup {
|
|
|
1155
1278
|
return 'idle';
|
|
1156
1279
|
}, { ...(ngDevMode ? { debugName: "aggregatedStatus" } : /* istanbul ignore next */ {}), equal: Object.is });
|
|
1157
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 */ []));
|
|
1158
1303
|
constructor() {
|
|
1159
1304
|
if (!this.stepperHost) {
|
|
1160
1305
|
throw new Error('CngxStepGroup: no enclosing CngxStepperPresenter found. ' +
|
|
@@ -1489,7 +1634,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1489
1634
|
* @since 0.1.0
|
|
1490
1635
|
* @relatedTo CngxStepIndicator, CngxStepBadge, CngxStepBusySpinner, CngxStepRejection
|
|
1491
1636
|
* <example-url>http://localhost:4200/#/ui/stepper/dot-stepper/icon-dots-via-code-cngxdotstepperdot-code</example-url>
|
|
1492
|
-
* <example-url>http://localhost:4200/#/ui/stepper/dot-stepper/mobile-carousel</example-url>
|
|
1493
1637
|
*/
|
|
1494
1638
|
class CngxDotStepperDot {
|
|
1495
1639
|
templateRef = inject(TemplateRef);
|
|
@@ -1846,6 +1990,161 @@ function createStepperDisplayMode(mediaQuery, mobileCollapse, destroyRef) {
|
|
|
1846
1990
|
});
|
|
1847
1991
|
}
|
|
1848
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
|
+
|
|
1849
2148
|
/**
|
|
1850
2149
|
* Level-2 helper resolving the three host-attribute cascades for
|
|
1851
2150
|
* `<cngx-stepper>` (skin / connectors / mobileIndicatorPosition). Keeps
|
|
@@ -1881,13 +2180,25 @@ function createStepperHostAttrs(inputs) {
|
|
|
1881
2180
|
*/
|
|
1882
2181
|
function createStepperStripKeyboardNav(options) {
|
|
1883
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
|
+
};
|
|
1884
2195
|
const focusActive = () => {
|
|
1885
2196
|
const activeId = options.presenter.activeStepId();
|
|
1886
2197
|
if (!activeId) {
|
|
1887
2198
|
return;
|
|
1888
2199
|
}
|
|
1889
2200
|
const buttonId = options.stepButtonIdFor(activeId);
|
|
1890
|
-
|
|
2201
|
+
scheduleFocus(() => {
|
|
1891
2202
|
const el = options.hostElement.querySelector(`[id="${buttonId}"]`);
|
|
1892
2203
|
if (el instanceof HTMLElement) {
|
|
1893
2204
|
el.focus();
|
|
@@ -2609,8 +2920,10 @@ function createStepperHostProxy(supplier) {
|
|
|
2609
2920
|
stepTree: computed(() => supplier()?.stepTree() ?? EMPTY_NODES),
|
|
2610
2921
|
flatSteps: computed(() => supplier()?.flatSteps() ?? EMPTY_NODES),
|
|
2611
2922
|
stepsOnly: computed(() => supplier()?.stepsOnly() ?? EMPTY_NODES),
|
|
2923
|
+
visibleStripNodes: computed(() => supplier()?.visibleStripNodes() ?? EMPTY_NODES),
|
|
2612
2924
|
activeStepIndex: computed(() => supplier()?.activeStepIndex() ?? -1),
|
|
2613
2925
|
activeStepId: computed(() => supplier()?.activeStepId() ?? null),
|
|
2926
|
+
activeGroupId: computed(() => supplier()?.activeGroupId() ?? null),
|
|
2614
2927
|
linear: computed(() => supplier()?.linear() ?? false),
|
|
2615
2928
|
orientation: computed(() => supplier()?.orientation() ?? 'horizontal'),
|
|
2616
2929
|
intendedStepIndex: computed(() => supplier()?.intendedStepIndex()),
|
|
@@ -2752,5 +3065,5 @@ function provideCngxStepperAt(...features) {
|
|
|
2752
3065
|
* Generated bundle index. Do not edit.
|
|
2753
3066
|
*/
|
|
2754
3067
|
|
|
2755
|
-
export { CNGX_STEPPER_COMMIT_HANDLER_FACTORY, CNGX_STEPPER_CONFIG, CNGX_STEPPER_GLYPHS, CNGX_STEPPER_HOST, CNGX_STEPPER_I18N, CNGX_STEP_GROUP_HOST, CNGX_STEP_PANEL_HOST, CngxDotStepperDot, CngxStep, CngxStepBadge, CngxStepBusySpinner, CngxStepContent, CngxStepError, CngxStepGroup, CngxStepGroupHeader, CngxStepIndicator, CngxStepLabel, CngxStepRejection, CngxStepperComplete, CngxStepperCount, CngxStepperEmpty, CngxStepperNext, CngxStepperPresenter, CngxStepperPrevious, CngxStepperRouterSync, CngxStepperSwipeNav, STEPPER_DEFAULT_MOBILE_BREAKPOINT, createMobileViewportSignal, createStepperAnnouncementBuilders, createStepperCommitHandler, createStepperDisplayMode, createStepperHostAttrs, createStepperHostProxy, createStepperSlotContextBuilders, createStepperStateView, createStepperStripKeyboardNav, createStepperTemplateBindings, flatStepsEqual, injectStepperConfig, injectStepperI18n, provideCngxStepper, provideCngxStepperAt, provideStepperConfig, provideStepperConfigAt, provideStepperI18n, resolveStepperErrorSummary, resolveStepperStatusLabel, withDotStepperDotTemplate, withStepBadgeTemplate, withStepBusySpinnerTemplate, withStepErrorTemplate, withStepGroupHeaderTemplate, withStepIndicatorTemplate, withStepRejectionTemplate, withStepperAriaLabels, withStepperCommitMode, withStepperConnectors, withStepperDefaultOrientation, withStepperEmptyTemplate, withStepperFallbackLabels, withStepperHeaderNavigation, withStepperI18nLabels, withStepperLinear, withStepperMobileBreakpoint, withStepperMobileCollapse, withStepperMobileIndicatorPosition, withStepperMobileSwipe, withStepperRouterSync, withStepperSkin };
|
|
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 };
|
|
2756
3069
|
//# sourceMappingURL=cngx-common-stepper.mjs.map
|