@cngx/common 0.1.0-rc.0 → 0.1.0-rc.1
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-interactive.mjs +45 -11
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +242 -34
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +900 -47
- 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 +20 -0
- 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-interactive.d.ts +20 -2
- package/types/cngx-common-stepper.d.ts +256 -13
- package/types/cngx-common-tabs.d.ts +832 -23
|
@@ -121,6 +121,7 @@ const STEPPER_CONFIG_DEFAULTS = {
|
|
|
121
121
|
routerSyncMode: 'fragment',
|
|
122
122
|
routerSyncParam: 'step',
|
|
123
123
|
skin: 'classic',
|
|
124
|
+
headerNavigation: 'visited',
|
|
124
125
|
connectors: false,
|
|
125
126
|
mobileCollapse: 'text',
|
|
126
127
|
mobileBreakpoint: STEPPER_DEFAULT_MOBILE_BREAKPOINT,
|
|
@@ -280,6 +281,18 @@ function withStepperMobileIndicatorPosition(position) {
|
|
|
280
281
|
function withStepperMobileSwipe(enabled) {
|
|
281
282
|
return defineStepperConfigFeature((cfg) => ({ ...cfg, mobileSwipe: enabled }));
|
|
282
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* Set the app-wide default header-navigation policy for
|
|
286
|
+
* `<cngx-stepper>`. `'none'` renders inert label headers (footer-only
|
|
287
|
+
* navigation); `'visited'` (library default) keeps the headers as
|
|
288
|
+
* focusable buttons whose reachability folds into the `linear` axis.
|
|
289
|
+
* Per-instance `[headerNavigation]` Input still wins.
|
|
290
|
+
*
|
|
291
|
+
* @category common/stepper
|
|
292
|
+
*/
|
|
293
|
+
function withStepperHeaderNavigation(mode) {
|
|
294
|
+
return defineStepperConfigFeature((cfg) => ({ ...cfg, headerNavigation: mode }));
|
|
295
|
+
}
|
|
283
296
|
/**
|
|
284
297
|
* Merge ARIA labels into the cascade. Keys not provided keep their
|
|
285
298
|
* library defaults; per-instance overrides on the stepper still win.
|
|
@@ -351,6 +364,20 @@ function withStepRejectionTemplate(template) {
|
|
|
351
364
|
templates: { ...cfg.templates, rejection: template },
|
|
352
365
|
}));
|
|
353
366
|
}
|
|
367
|
+
/**
|
|
368
|
+
* Override the default `*cngxStepError` template app-wide. The slot
|
|
369
|
+
* renders the per-step validation reason on the skins with a label area
|
|
370
|
+
* (classic / stripe-status-rich). Per-instance directive still wins;
|
|
371
|
+
* this moves the cascade middle tier.
|
|
372
|
+
*
|
|
373
|
+
* @category common/stepper
|
|
374
|
+
*/
|
|
375
|
+
function withStepErrorTemplate(template) {
|
|
376
|
+
return defineStepperConfigFeature((cfg) => ({
|
|
377
|
+
...cfg,
|
|
378
|
+
templates: { ...cfg.templates, stepError: template },
|
|
379
|
+
}));
|
|
380
|
+
}
|
|
354
381
|
/**
|
|
355
382
|
* Override the default `*cngxStepGroupHeader` template app-wide.
|
|
356
383
|
*
|
|
@@ -746,6 +773,7 @@ class CngxStepperPresenter {
|
|
|
746
773
|
disabled: entry.reg.disabled,
|
|
747
774
|
state: entry.reg.state,
|
|
748
775
|
errorAggregator: entry.reg.errorAggregator,
|
|
776
|
+
errorMessage: entry.reg.errorMessage,
|
|
749
777
|
children,
|
|
750
778
|
depth,
|
|
751
779
|
parentId: entry.parentId,
|
|
@@ -775,6 +803,24 @@ class CngxStepperPresenter {
|
|
|
775
803
|
.slice(this.activeStepIndex(), target)
|
|
776
804
|
.some((n) => n.state() !== 'success' && !n.disabled());
|
|
777
805
|
}
|
|
806
|
+
/**
|
|
807
|
+
* {@inheritDoc CngxStepperHost.canNavigateTo}
|
|
808
|
+
*
|
|
809
|
+
* Wraps the private {@link isLinearBlocked} predicate plus the
|
|
810
|
+
* per-step `disabled` check. The header-reachability contract surface;
|
|
811
|
+
* `isLinearBlocked` stays private so the organism reads this method,
|
|
812
|
+
* never the internal gate.
|
|
813
|
+
*/
|
|
814
|
+
canNavigateTo(index) {
|
|
815
|
+
const stepsOnly = this.stepsOnly();
|
|
816
|
+
if (index < 0 || index >= stepsOnly.length) {
|
|
817
|
+
return false;
|
|
818
|
+
}
|
|
819
|
+
if (stepsOnly[index].disabled()) {
|
|
820
|
+
return false;
|
|
821
|
+
}
|
|
822
|
+
return !this.isLinearBlocked(index);
|
|
823
|
+
}
|
|
778
824
|
select(index) {
|
|
779
825
|
const stepsOnly = this.stepsOnly();
|
|
780
826
|
if (stepsOnly.length === 0) {
|
|
@@ -987,6 +1033,25 @@ class CngxStep {
|
|
|
987
1033
|
completed = input(false, ...(ngDevMode ? [{ debugName: "completed" }] : /* istanbul ignore next */ []));
|
|
988
1034
|
label = input('', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
989
1035
|
errorAggregator = input(undefined, ...(ngDevMode ? [{ debugName: "errorAggregator" }] : /* istanbul ignore next */ []));
|
|
1036
|
+
/**
|
|
1037
|
+
* Direct error flag for the common "this step is invalid" case - no
|
|
1038
|
+
* `errorAggregator` boilerplate required. `true` or a non-empty string
|
|
1039
|
+
* drives the error state; a string doubles as the inline message
|
|
1040
|
+
* (surfaced via the `*cngxStepError` slot and the mini-skin aggregate
|
|
1041
|
+
* line). `false` / `''` clear it. The aggregator stays the rich
|
|
1042
|
+
* multi-source forms path; the two channels compose (either errors).
|
|
1043
|
+
*/
|
|
1044
|
+
error = input(false, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
1045
|
+
/**
|
|
1046
|
+
* Resolved direct-error message: the `[error]` string when non-empty,
|
|
1047
|
+
* else `undefined`. Carried onto the registration / node so the error
|
|
1048
|
+
* slot + aggregate line can render it. `computed` over the input -
|
|
1049
|
+
* never written.
|
|
1050
|
+
*/
|
|
1051
|
+
errorMessage = computed(() => {
|
|
1052
|
+
const value = this.error();
|
|
1053
|
+
return typeof value === 'string' && value !== '' ? value : undefined;
|
|
1054
|
+
}, ...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
|
|
990
1055
|
labelSlot = contentChild(CngxStepLabel, ...(ngDevMode ? [{ debugName: "labelSlot" }] : /* istanbul ignore next */ []));
|
|
991
1056
|
contentSlot = contentChild(CngxStepContent, ...(ngDevMode ? [{ debugName: "contentSlot" }] : /* istanbul ignore next */ []));
|
|
992
1057
|
labelTemplate = this.labelSlot;
|
|
@@ -995,11 +1060,15 @@ class CngxStep {
|
|
|
995
1060
|
* Per-step status derived from inputs + aggregator. `linkedSignal`
|
|
996
1061
|
* with structural equal - never written via `effect`.
|
|
997
1062
|
*/
|
|
998
|
-
state = linkedSignal({ ...(ngDevMode ? { debugName: "state" } : /* istanbul ignore next */ {}), source: () =>
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1063
|
+
state = linkedSignal({ ...(ngDevMode ? { debugName: "state" } : /* istanbul ignore next */ {}), source: () => {
|
|
1064
|
+
const directError = this.error();
|
|
1065
|
+
return {
|
|
1066
|
+
disabled: this.disabled(),
|
|
1067
|
+
completed: this.completed(),
|
|
1068
|
+
errored: (directError !== false && directError !== '') ||
|
|
1069
|
+
(this.errorAggregator()?.hasError?.() ?? false),
|
|
1070
|
+
};
|
|
1071
|
+
},
|
|
1003
1072
|
computation: ({ disabled, completed, errored }) => {
|
|
1004
1073
|
if (disabled) {
|
|
1005
1074
|
return 'disabled';
|
|
@@ -1029,11 +1098,12 @@ class CngxStep {
|
|
|
1029
1098
|
disabled: this.disabled,
|
|
1030
1099
|
state: this.state,
|
|
1031
1100
|
errorAggregator: this.errorAggregator,
|
|
1101
|
+
errorMessage: this.errorMessage,
|
|
1032
1102
|
});
|
|
1033
1103
|
inject(DestroyRef).onDestroy(() => host.unregister(stepId));
|
|
1034
1104
|
}
|
|
1035
1105
|
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 });
|
|
1106
|
+
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
1107
|
}
|
|
1038
1108
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStep, decorators: [{
|
|
1039
1109
|
type: Directive,
|
|
@@ -1042,7 +1112,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1042
1112
|
exportAs: 'cngxStep',
|
|
1043
1113
|
standalone: true,
|
|
1044
1114
|
}]
|
|
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 }] }] } });
|
|
1115
|
+
}], 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
1116
|
|
|
1047
1117
|
/**
|
|
1048
1118
|
* Step-group atom. Registers with the root presenter as a `kind: 'group'`
|
|
@@ -1277,6 +1347,48 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1277
1347
|
}]
|
|
1278
1348
|
}] });
|
|
1279
1349
|
|
|
1350
|
+
/**
|
|
1351
|
+
* Slot directive for the per-step error-message template on
|
|
1352
|
+
* `<cngx-stepper>`. Discovered via `contentChild`; cascades through
|
|
1353
|
+
* `CNGX_STEPPER_CONFIG.templates.stepError` before falling back to the
|
|
1354
|
+
* built-in `{{ message }}` text. Mirrors {@link CngxStepRejection} so
|
|
1355
|
+
* consumer-authored templates read the same way across both channels.
|
|
1356
|
+
*
|
|
1357
|
+
* ```html
|
|
1358
|
+
* <cngx-stepper>
|
|
1359
|
+
* <ng-template cngxStepError let-message="message" let-errorLabels="errorLabels">
|
|
1360
|
+
* <strong>{{ message }}</strong>
|
|
1361
|
+
* @if (errorLabels.length > 1) {
|
|
1362
|
+
* <ul>
|
|
1363
|
+
* @for (label of errorLabels; track label) {
|
|
1364
|
+
* <li>{{ label }}</li>
|
|
1365
|
+
* }
|
|
1366
|
+
* </ul>
|
|
1367
|
+
* }
|
|
1368
|
+
* </ng-template>
|
|
1369
|
+
* </cngx-stepper>
|
|
1370
|
+
* ```
|
|
1371
|
+
*
|
|
1372
|
+
* @category common/stepper/slots
|
|
1373
|
+
* @wcag AA
|
|
1374
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/stepper/slots/step-error.directive.ts
|
|
1375
|
+
* @since 0.1.0
|
|
1376
|
+
* @relatedTo CngxStepRejection, CngxStepBadge, CngxStep
|
|
1377
|
+
*/
|
|
1378
|
+
class CngxStepError {
|
|
1379
|
+
templateRef = inject(TemplateRef);
|
|
1380
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepError, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1381
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxStepError, isStandalone: true, selector: "ng-template[cngxStepError]", exportAs: ["cngxStepError"], ngImport: i0 });
|
|
1382
|
+
}
|
|
1383
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStepError, decorators: [{
|
|
1384
|
+
type: Directive,
|
|
1385
|
+
args: [{
|
|
1386
|
+
selector: 'ng-template[cngxStepError]',
|
|
1387
|
+
exportAs: 'cngxStepError',
|
|
1388
|
+
standalone: true,
|
|
1389
|
+
}]
|
|
1390
|
+
}] });
|
|
1391
|
+
|
|
1280
1392
|
/**
|
|
1281
1393
|
* Slot directive for the group-header template on `<cngx-stepper>`.
|
|
1282
1394
|
* Discovered via `contentChild`; cascades through
|
|
@@ -1394,15 +1506,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1394
1506
|
}] });
|
|
1395
1507
|
|
|
1396
1508
|
/**
|
|
1397
|
-
* Wires the 3-stage template cascade for the
|
|
1398
|
-
*
|
|
1509
|
+
* Wires the 3-stage template cascade for the `<cngx-stepper>` skin
|
|
1510
|
+
* slots: per-instance directive > `CNGX_STEPPER_CONFIG.templates.<key>`
|
|
1399
1511
|
* > `null` (built-in default).
|
|
1400
1512
|
*
|
|
1401
|
-
* Pure
|
|
1513
|
+
* Pure - no DI, no side effects. Safe to call from a field-init
|
|
1402
1514
|
* block. Sibling of `createTabOverflowTemplateBindings` and the
|
|
1403
1515
|
* family-wide `createTemplateRegistry`.
|
|
1404
1516
|
*
|
|
1405
|
-
* Tabs has no parallel slot surface yet
|
|
1517
|
+
* Tabs has no parallel slot surface yet - see
|
|
1406
1518
|
* `stepper-accepted-debt §3` for the planned Phase-4 closure.
|
|
1407
1519
|
*
|
|
1408
1520
|
* @category common/stepper/slots
|
|
@@ -1421,6 +1533,9 @@ function createStepperTemplateBindings(opts) {
|
|
|
1421
1533
|
rejection: computed(() => opts.rejectionSlot()?.templateRef ??
|
|
1422
1534
|
opts.config.templates?.rejection ??
|
|
1423
1535
|
null),
|
|
1536
|
+
stepError: computed(() => opts.errorSlot?.()?.templateRef ??
|
|
1537
|
+
opts.config.templates?.stepError ??
|
|
1538
|
+
null),
|
|
1424
1539
|
groupHeader: computed(() => opts.groupHeaderSlot()?.templateRef ??
|
|
1425
1540
|
opts.config.templates?.groupHeader ??
|
|
1426
1541
|
null),
|
|
@@ -1572,7 +1687,7 @@ const STEPPER_I18N_DEFAULTS = {
|
|
|
1572
1687
|
stepHasErrors: (count) => `${count} error${count === 1 ? '' : 's'}`,
|
|
1573
1688
|
previousStep: 'Previous step',
|
|
1574
1689
|
nextStep: 'Next step',
|
|
1575
|
-
commitFailedRetry: 'Commit failed
|
|
1690
|
+
commitFailedRetry: 'Commit failed - retry?',
|
|
1576
1691
|
commitInFlight: 'Committing step…',
|
|
1577
1692
|
commitRolledBackTo: (originLabel) => `Reverted to step "${originLabel}".`,
|
|
1578
1693
|
stepRolledBackSuffix: 'This step was rolled back.',
|
|
@@ -1780,6 +1895,9 @@ function createStepperStripKeyboardNav(options) {
|
|
|
1780
1895
|
});
|
|
1781
1896
|
};
|
|
1782
1897
|
return (event) => {
|
|
1898
|
+
if (options.enabled && !options.enabled()) {
|
|
1899
|
+
return;
|
|
1900
|
+
}
|
|
1783
1901
|
const target = event.target;
|
|
1784
1902
|
if (!target?.classList.contains(stepClass)) {
|
|
1785
1903
|
return;
|
|
@@ -1810,6 +1928,84 @@ function createStepperStripKeyboardNav(options) {
|
|
|
1810
1928
|
};
|
|
1811
1929
|
}
|
|
1812
1930
|
|
|
1931
|
+
/**
|
|
1932
|
+
* Build the shared {@link CngxStepperStateView} over a presenter host and its
|
|
1933
|
+
* step-only projection. Pure factory - `computed()` only, no injection
|
|
1934
|
+
* context required, so any skin can allocate it in a field initializer.
|
|
1935
|
+
*
|
|
1936
|
+
* @category common/stepper
|
|
1937
|
+
* @since 0.1.0
|
|
1938
|
+
* @relatedTo CngxStepperHost, createStepperSlotContextBuilders
|
|
1939
|
+
*/
|
|
1940
|
+
function createStepperStateView(inputs) {
|
|
1941
|
+
const { presenter, stepsOnly } = inputs;
|
|
1942
|
+
const statusOf = (node) => node.state();
|
|
1943
|
+
const isBusy = (node) => node.kind === 'step' &&
|
|
1944
|
+
presenter.commitState.status() === 'pending' &&
|
|
1945
|
+
presenter.intendedStepIndex() === node.flatIndex;
|
|
1946
|
+
const isRejected = (node) => node.kind === 'step' && node.flatIndex >= 0 && node.flatIndex === presenter.lastFailedIndex();
|
|
1947
|
+
const hasErrorBadge = (node) => {
|
|
1948
|
+
if (node.kind !== 'step') {
|
|
1949
|
+
return false;
|
|
1950
|
+
}
|
|
1951
|
+
if (node.state() === 'error') {
|
|
1952
|
+
return true;
|
|
1953
|
+
}
|
|
1954
|
+
return !!node.errorAggregator?.()?.shouldShow?.();
|
|
1955
|
+
};
|
|
1956
|
+
const hasError = (node) => hasErrorBadge(node) || isRejected(node);
|
|
1957
|
+
const erroredSteps = computed(() => stepsOnly().filter((node) => hasError(node)), ...(ngDevMode ? [{ debugName: "erroredSteps" }] : /* istanbul ignore next */ []));
|
|
1958
|
+
const errorCount = computed(() => erroredSteps().length, ...(ngDevMode ? [{ debugName: "errorCount" }] : /* istanbul ignore next */ []));
|
|
1959
|
+
const firstErrorIndex = computed(() => erroredSteps()[0]?.flatIndex ?? -1, ...(ngDevMode ? [{ debugName: "firstErrorIndex" }] : /* istanbul ignore next */ []));
|
|
1960
|
+
const hasAnyError = computed(() => errorCount() > 0, ...(ngDevMode ? [{ debugName: "hasAnyError" }] : /* istanbul ignore next */ []));
|
|
1961
|
+
return {
|
|
1962
|
+
statusOf,
|
|
1963
|
+
isBusy,
|
|
1964
|
+
isRejected,
|
|
1965
|
+
hasErrorBadge,
|
|
1966
|
+
hasError,
|
|
1967
|
+
errorCount,
|
|
1968
|
+
firstErrorIndex,
|
|
1969
|
+
hasAnyError,
|
|
1970
|
+
};
|
|
1971
|
+
}
|
|
1972
|
+
/**
|
|
1973
|
+
* Aggregate error phrase shared by the minimal skins (text / progress-bar)
|
|
1974
|
+
* and the classic mobile-collapse text branch. A single errored step names
|
|
1975
|
+
* itself (`"Payment: Errored"`); several collapse to the i18n count phrase
|
|
1976
|
+
* (`"2 errors"`). Returns `''` when no step errored - callers gate on
|
|
1977
|
+
* `view.hasAnyError()` so the empty string never reaches the DOM.
|
|
1978
|
+
*
|
|
1979
|
+
* The optional `messageOf` resolver lets callers surface a per-step
|
|
1980
|
+
* reason (a direct `[error]` string or the first aggregator label) in the
|
|
1981
|
+
* single-error case instead of the generic `errored` status word. When
|
|
1982
|
+
* omitted - or when it returns `undefined`/`''` - the helper produces
|
|
1983
|
+
* byte-identical output to the no-resolver form, so existing callers
|
|
1984
|
+
* (the classic mobile-collapse summary) are a guaranteed no-op.
|
|
1985
|
+
*
|
|
1986
|
+
* Pure helper - reads signals at call time, intended to be wrapped in the
|
|
1987
|
+
* caller's `computed()`.
|
|
1988
|
+
*
|
|
1989
|
+
* @category common/stepper
|
|
1990
|
+
* @since 0.1.0
|
|
1991
|
+
*/
|
|
1992
|
+
function resolveStepperErrorSummary(view, stepsOnly, i18n, messageOf) {
|
|
1993
|
+
const count = view.errorCount();
|
|
1994
|
+
if (count === 0) {
|
|
1995
|
+
return '';
|
|
1996
|
+
}
|
|
1997
|
+
if (count === 1) {
|
|
1998
|
+
const node = stepsOnly()[view.firstErrorIndex()];
|
|
1999
|
+
const custom = node ? messageOf?.(node) : undefined;
|
|
2000
|
+
if (custom !== undefined && custom !== '') {
|
|
2001
|
+
return custom;
|
|
2002
|
+
}
|
|
2003
|
+
const label = node?.label();
|
|
2004
|
+
return label ? `${label}: ${i18n.statusLabels.errored}` : i18n.statusLabels.errored;
|
|
2005
|
+
}
|
|
2006
|
+
return i18n.stepHasErrors(count);
|
|
2007
|
+
}
|
|
2008
|
+
|
|
1813
2009
|
/**
|
|
1814
2010
|
* Wrap a `(node) => TContext` builder so identical results return the
|
|
1815
2011
|
* same reference. Keyed by the node object via `WeakMap`, so step-list
|
|
@@ -1849,31 +2045,28 @@ function shallowEqual(a, b) {
|
|
|
1849
2045
|
return true;
|
|
1850
2046
|
}
|
|
1851
2047
|
/**
|
|
1852
|
-
* Bundle the
|
|
1853
|
-
* `isActive` / `isStepBusy` / `showRejection` / `showErrorBadge`
|
|
1854
|
-
* the organism's template reads. Lives at
|
|
1855
|
-
* organism stays a thin shell
|
|
2048
|
+
* Bundle the `*ContextFor` slot-context builders plus the small
|
|
2049
|
+
* `isActive` / `isStepBusy` / `showRejection` / `showErrorBadge` /
|
|
2050
|
+
* `showStepError` predicates the organism's template reads. Lives at
|
|
2051
|
+
* Level 2 so the `<cngx-stepper>` organism stays a thin shell.
|
|
1856
2052
|
*
|
|
1857
2053
|
* @internal
|
|
1858
2054
|
*/
|
|
1859
2055
|
function createStepperSlotContextBuilders(inputs) {
|
|
1860
|
-
const { presenter, stepsOnly } = inputs;
|
|
2056
|
+
const { presenter, stepsOnly, i18n } = inputs;
|
|
2057
|
+
// Single source for every per-step status / error / busy / rejection
|
|
2058
|
+
// derivation. The dot / text / progress-bar skins read the same view,
|
|
2059
|
+
// so the error contract stays identical across all four.
|
|
2060
|
+
const stateView = createStepperStateView({ presenter, stepsOnly });
|
|
1861
2061
|
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
|
-
};
|
|
2062
|
+
const isStepBusy = stateView.isBusy;
|
|
2063
|
+
const showRejection = stateView.isRejected;
|
|
2064
|
+
const showErrorBadge = stateView.hasErrorBadge;
|
|
2065
|
+
// Validation-channel gate for the per-step error message. Mirrors the
|
|
2066
|
+
// error badge (state === 'error' via [error] / aggregator); the commit
|
|
2067
|
+
// rejection keeps its own `showRejection` slot, so the two channels
|
|
2068
|
+
// stay distinct.
|
|
2069
|
+
const showStepError = stateView.hasErrorBadge;
|
|
1877
2070
|
// Memoize per-node so identical contexts return the same reference.
|
|
1878
2071
|
// *ngTemplateOutlet pays an ngOnChanges shallow comparison on its
|
|
1879
2072
|
// `context:` binding every CD pass; without this cache the outlet
|
|
@@ -1904,6 +2097,16 @@ function createStepperSlotContextBuilders(inputs) {
|
|
|
1904
2097
|
const originLabel = originIdx !== undefined ? stepsOnly()[originIdx]?.label() : undefined;
|
|
1905
2098
|
return { failedIndex, originLabel, node };
|
|
1906
2099
|
});
|
|
2100
|
+
const stepErrorContextFor = memoizeByNode((node) => {
|
|
2101
|
+
const aggregator = node.errorAggregator?.();
|
|
2102
|
+
const errorLabels = aggregator?.errorLabels?.() ?? [];
|
|
2103
|
+
const announcement = aggregator?.announcement?.() ?? '';
|
|
2104
|
+
// Resolution order: direct [error] string > first aggregator label >
|
|
2105
|
+
// i18n errored status phrase. Always non-empty so a bare
|
|
2106
|
+
// `{{ message }}` template renders a reason.
|
|
2107
|
+
const message = node.errorMessage?.() ?? errorLabels[0] ?? i18n.statusLabels.errored;
|
|
2108
|
+
return { node, message, errorLabels, announcement };
|
|
2109
|
+
});
|
|
1907
2110
|
const groupHeaderContextFor = memoizeByNode((node) => ({
|
|
1908
2111
|
group: node,
|
|
1909
2112
|
expanded: true,
|
|
@@ -1933,10 +2136,12 @@ function createStepperSlotContextBuilders(inputs) {
|
|
|
1933
2136
|
isStepBusy,
|
|
1934
2137
|
showRejection,
|
|
1935
2138
|
showErrorBadge,
|
|
2139
|
+
showStepError,
|
|
1936
2140
|
indicatorContextFor,
|
|
1937
2141
|
badgeContextFor,
|
|
1938
2142
|
busySpinnerContextFor,
|
|
1939
2143
|
rejectionContextFor,
|
|
2144
|
+
stepErrorContextFor,
|
|
1940
2145
|
groupHeaderContextFor,
|
|
1941
2146
|
stepLabelContextFor,
|
|
1942
2147
|
stepContentContextFor,
|
|
@@ -2434,6 +2639,9 @@ function createStepperHostProxy(supplier) {
|
|
|
2434
2639
|
current: computed(() => supplier()?.commitTransition.current() ?? 'idle'),
|
|
2435
2640
|
previous: computed(() => supplier()?.commitTransition.previous() ?? 'idle'),
|
|
2436
2641
|
},
|
|
2642
|
+
// Reachability predicate - neutral `false` when null so a header
|
|
2643
|
+
// over a missing host is never falsely navigable.
|
|
2644
|
+
canNavigateTo: (index) => supplier()?.canNavigateTo(index) ?? false,
|
|
2437
2645
|
// Methods forward; no-op when null.
|
|
2438
2646
|
select: (index) => supplier()?.select(index),
|
|
2439
2647
|
selectNext: () => supplier()?.selectNext(),
|
|
@@ -2535,7 +2743,7 @@ function provideCngxStepperAt(...features) {
|
|
|
2535
2743
|
*
|
|
2536
2744
|
* Level-2 directive-only logic for stepper / wizard flows. Ships the
|
|
2537
2745
|
* presenter brain, atom directives, host tokens, router-sync, config
|
|
2538
|
-
* cascade, and i18n. Zero `@Component`, zero `.html`, zero `.css`
|
|
2746
|
+
* cascade, and i18n. Zero `@Component`, zero `.html`, zero `.css` -
|
|
2539
2747
|
* those live in `@cngx/ui/stepper` (CNGX-standard skin) and
|
|
2540
2748
|
* `@cngx/ui/mat-stepper` (Material twin).
|
|
2541
2749
|
*/
|
|
@@ -2544,5 +2752,5 @@ function provideCngxStepperAt(...features) {
|
|
|
2544
2752
|
* Generated bundle index. Do not edit.
|
|
2545
2753
|
*/
|
|
2546
2754
|
|
|
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 };
|
|
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 };
|
|
2548
2756
|
//# sourceMappingURL=cngx-common-stepper.mjs.map
|