@daltonr/pathwrite-angular 0.10.1 → 0.12.0
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/README.md +92 -6
- package/dist/index.css +25 -0
- package/dist/index.d.ts +28 -7
- package/dist/index.js +19 -8
- package/dist/index.js.map +1 -1
- package/dist/shell.d.ts +60 -10
- package/dist/shell.js +245 -132
- package/dist/shell.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +32 -13
- package/src/shell.ts +163 -76
package/README.md
CHANGED
|
@@ -113,6 +113,7 @@ export class MyWizardComponent { }
|
|
|
113
113
|
| `setData(key, value)` | Update a single data field. Type-safe when `TData` is specified. |
|
|
114
114
|
| `startSubPath(definition, data?, meta?)` | Push a sub-path. `meta` is returned to `onSubPathComplete`/`onSubPathCancel`. |
|
|
115
115
|
| `adoptEngine(engine)` | Adopt an externally-managed `PathEngine` (e.g. from `restoreOrStart()`). |
|
|
116
|
+
| `validate()` | Set `snapshot().hasValidated` without navigating. Triggers all inline field errors simultaneously. Used to validate all tabs in a nested shell at once. |
|
|
116
117
|
|
|
117
118
|
## `<pw-shell>` inputs/outputs
|
|
118
119
|
|
|
@@ -128,13 +129,16 @@ Step content is provided via `<ng-template pwStep="stepId">` directives inside `
|
|
|
128
129
|
| `autoStart` | `boolean` | `true` | Start the path on `ngOnInit`. Ignored when `engine` is provided. |
|
|
129
130
|
| `validationDisplay` | `"summary" \| "inline" \| "both"` | `"summary"` | Where `fieldErrors` are rendered. Use `"inline"` so step components render their own errors. |
|
|
130
131
|
| `loadingLabel` | `string` | — | Label shown while the path is navigating. |
|
|
131
|
-
| `
|
|
132
|
+
| `layout` | `"wizard" \| "form" \| "auto" \| "tabs"` | `"auto"` | `"wizard"`: Back on left, Cancel+Submit on right. `"form"`: Cancel on left, Submit on right, no Back. `"tabs"`: No progress header or footer — for tabbed interfaces. `"auto"` picks `"form"` for single-step paths. |
|
|
132
133
|
| `hideProgress` | `boolean` | `false` | Hide the progress indicator. Also hidden automatically for single-step paths. |
|
|
133
134
|
| `backLabel` | `string` | `"Previous"` | Previous button label. |
|
|
134
135
|
| `nextLabel` | `string` | `"Next"` | Next button label. |
|
|
135
136
|
| `completeLabel` | `string` | `"Complete"` | Complete button label (last step). |
|
|
136
137
|
| `cancelLabel` | `string` | `"Cancel"` | Cancel button label. |
|
|
137
138
|
| `hideCancel` | `boolean` | `false` | Hide the Cancel button. |
|
|
139
|
+
| `services` | `unknown` | `null` | Arbitrary services object available to step components via `usePathContext<TData, TServices>().services`. |
|
|
140
|
+
| `validateWhen` | `boolean` | `false` | When it becomes `true`, calls `validate()` on the engine. Bind to the outer snapshot's `hasAttemptedNext` when this shell is nested inside a step of an outer shell. |
|
|
141
|
+
| `restoreKey` | `string` | — | When set, the shell automatically saves its full state (data + active step) into the nearest outer `<pw-shell>`'s data under this key on every change, and restores from it on remount. No-op on a top-level shell. |
|
|
138
142
|
|
|
139
143
|
### Outputs
|
|
140
144
|
|
|
@@ -144,21 +148,103 @@ Step content is provided via `<ng-template pwStep="stepId">` directives inside `
|
|
|
144
148
|
| `(cancel)` | `PathData` | Emitted when the path is cancelled. |
|
|
145
149
|
| `(event)` | `PathEvent` | Emitted for every engine event. |
|
|
146
150
|
|
|
147
|
-
|
|
151
|
+
### Completion content
|
|
148
152
|
|
|
149
|
-
`
|
|
153
|
+
When `completionBehaviour` is `"stayOnFinal"` (the default), `<pw-shell>` renders a completion panel once `snapshot.status === "completed"`. Use the `[pwShellCompletion]` directive to replace the default "All done." panel with a custom template. The template receives the completed snapshot as its implicit context:
|
|
150
154
|
|
|
151
155
|
```typescript
|
|
152
|
-
import {
|
|
156
|
+
import { PathShellCompletionDirective } from "@daltonr/pathwrite-angular/shell";
|
|
157
|
+
|
|
158
|
+
@Component({
|
|
159
|
+
imports: [PathShellComponent, PathStepDirective, PathShellCompletionDirective],
|
|
160
|
+
template: `
|
|
161
|
+
<pw-shell [path]="path" [initialData]="{ name: '' }">
|
|
162
|
+
<ng-template pwShellCompletion let-s>
|
|
163
|
+
<div class="done-panel">
|
|
164
|
+
<h2>Thanks, {{ s.data.name }}!</h2>
|
|
165
|
+
<button (click)="facade.restart()">Start over</button>
|
|
166
|
+
</div>
|
|
167
|
+
</ng-template>
|
|
168
|
+
<ng-template pwStep="details"><app-details-form /></ng-template>
|
|
169
|
+
</pw-shell>
|
|
170
|
+
`
|
|
171
|
+
})
|
|
172
|
+
export class MyWizardComponent {
|
|
173
|
+
protected readonly path = myPath;
|
|
174
|
+
protected readonly facade = usePathContext();
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## `usePathContext()`
|
|
179
|
+
|
|
180
|
+
`usePathContext()` is the preferred API for step components and forms rendered inside `<pw-shell>`. It resolves the `PathFacade` from the nearest injector in the tree and returns a signal-based interface typed with optional `TData` and `TServices` generics — no `providers: [PathFacade]` needed in step components.
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
import { usePathContext } from "@daltonr/pathwrite-angular";
|
|
153
184
|
|
|
154
185
|
export class DetailsStepComponent {
|
|
155
|
-
protected readonly path =
|
|
186
|
+
protected readonly path = usePathContext<ApplicationData>();
|
|
156
187
|
// path.snapshot() — Signal<PathSnapshot | null>
|
|
157
188
|
// path.setData(key, value) — type-safe with TData
|
|
158
189
|
// path.next(), path.previous(), path.cancel(), etc.
|
|
190
|
+
// path.validate() — trigger inline errors on all steps simultaneously
|
|
191
|
+
// path.services — typed as TServices
|
|
159
192
|
}
|
|
160
193
|
```
|
|
161
194
|
|
|
195
|
+
### Passing services to step components
|
|
196
|
+
|
|
197
|
+
Use the `[services]` input on `<pw-shell>` to provide shared dependencies (API clients, feature flags, etc.) to all step components without prop-drilling:
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
// In the wizard host component:
|
|
201
|
+
@Component({
|
|
202
|
+
template: `
|
|
203
|
+
<pw-shell [path]="path" [services]="svc">
|
|
204
|
+
<ng-template pwStep="details"><app-details /></ng-template>
|
|
205
|
+
</pw-shell>
|
|
206
|
+
`
|
|
207
|
+
})
|
|
208
|
+
export class WizardComponent {
|
|
209
|
+
protected readonly svc: HiringServices = { api: inject(HiringApi) };
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// In a step component:
|
|
213
|
+
export class DetailsStepComponent {
|
|
214
|
+
protected readonly path = usePathContext<HiringData, HiringServices>();
|
|
215
|
+
// this.path.services — typed as HiringServices
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Nested shells and `validateWhen`
|
|
220
|
+
|
|
221
|
+
When `<pw-shell>` is nested inside a step of an outer shell, bind `[validateWhen]` to the outer snapshot's `hasAttemptedNext`. This triggers `validate()` on the inner engine when the outer shell's user attempts to proceed, surfacing all inner field errors at once:
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
@Component({
|
|
225
|
+
selector: "app-contact-step",
|
|
226
|
+
standalone: true,
|
|
227
|
+
imports: [PathShellComponent, PathStepDirective],
|
|
228
|
+
template: `
|
|
229
|
+
<pw-shell
|
|
230
|
+
[path]="contactTabsPath"
|
|
231
|
+
[layout]="'tabs'"
|
|
232
|
+
[validateWhen]="outerSnap()?.hasAttemptedNext ?? false"
|
|
233
|
+
>
|
|
234
|
+
<ng-template pwStep="name"><app-name-tab /></ng-template>
|
|
235
|
+
<ng-template pwStep="address"><app-address-tab /></ng-template>
|
|
236
|
+
</pw-shell>
|
|
237
|
+
`
|
|
238
|
+
})
|
|
239
|
+
export class ContactStepComponent {
|
|
240
|
+
protected readonly outerPath = usePathContext<ApplicationData>();
|
|
241
|
+
protected readonly outerSnap = this.outerPath.snapshot;
|
|
242
|
+
protected readonly contactTabsPath = contactTabsPath;
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
> **Do NOT add `providers: [PathFacade]` to step components.** Doing so creates a second, disconnected `PathFacade` instance scoped to that component — `snapshot()` will always be `null` inside it. `usePathContext()` resolves the shell's instance automatically via DI; no extra provider needed.
|
|
247
|
+
|
|
162
248
|
## Further reading
|
|
163
249
|
|
|
164
250
|
- [Angular getting started guide](../../docs/getting-started/frameworks/angular.md)
|
|
@@ -167,4 +253,4 @@ export class DetailsStepComponent {
|
|
|
167
253
|
|
|
168
254
|
---
|
|
169
255
|
|
|
170
|
-
|
|
256
|
+
© 2026 Devjoy Ltd. MIT License.
|
package/dist/index.css
CHANGED
|
@@ -77,6 +77,31 @@
|
|
|
77
77
|
font-size: 14px;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
/* ------------------------------------------------------------------ */
|
|
81
|
+
/* Completion panel */
|
|
82
|
+
/* ------------------------------------------------------------------ */
|
|
83
|
+
.pw-shell__completion {
|
|
84
|
+
text-align: center;
|
|
85
|
+
padding: 40px 16px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.pw-shell__completion-message {
|
|
89
|
+
font-size: 18px;
|
|
90
|
+
font-weight: 600;
|
|
91
|
+
color: var(--pw-color-text);
|
|
92
|
+
margin: 0 0 20px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.pw-shell__completion-restart {
|
|
96
|
+
border: 1px solid var(--pw-color-btn-border);
|
|
97
|
+
background: var(--pw-color-btn-bg);
|
|
98
|
+
color: var(--pw-color-text);
|
|
99
|
+
padding: var(--pw-btn-padding);
|
|
100
|
+
border-radius: var(--pw-btn-radius);
|
|
101
|
+
cursor: pointer;
|
|
102
|
+
font-size: 14px;
|
|
103
|
+
}
|
|
104
|
+
|
|
80
105
|
/* ------------------------------------------------------------------ */
|
|
81
106
|
/* Root progress — persistent top-level bar visible during sub-paths */
|
|
82
107
|
/* ------------------------------------------------------------------ */
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,12 @@ export declare class PathFacade<TData extends PathData = PathData> implements On
|
|
|
22
22
|
private readonly _events$;
|
|
23
23
|
private _unsubscribeFromEngine;
|
|
24
24
|
private readonly _stateSignal;
|
|
25
|
+
/**
|
|
26
|
+
* Arbitrary services object passed via `[services]` on `<pw-shell>`.
|
|
27
|
+
* Read it in step components via `usePathContext<TData, TServices>().services`.
|
|
28
|
+
* Set directly by `PathShellComponent` — do not set this manually.
|
|
29
|
+
*/
|
|
30
|
+
services: unknown;
|
|
25
31
|
readonly state$: Observable<PathSnapshot<TData> | null>;
|
|
26
32
|
readonly events$: Observable<PathEvent>;
|
|
27
33
|
/** Signal version of state$. Updates on every path state change. Requires Angular 16+. */
|
|
@@ -63,11 +69,16 @@ export declare class PathFacade<TData extends PathData = PathData> implements On
|
|
|
63
69
|
/** Reset the current step's data to what it was when the step was entered.
|
|
64
70
|
* Useful for "Clear" or "Reset" buttons that undo changes within a step. */
|
|
65
71
|
resetStep(): Promise<void>;
|
|
66
|
-
goToStep(stepId: string
|
|
72
|
+
goToStep(stepId: string, options?: {
|
|
73
|
+
validateOnLeave?: boolean;
|
|
74
|
+
}): Promise<void>;
|
|
67
75
|
/** Jump to a step by ID, checking the current step's canMoveNext (forward) or
|
|
68
76
|
* canMovePrevious (backward) guard first. Navigation is blocked if the guard
|
|
69
77
|
* returns false. Throws if the step ID does not exist. */
|
|
70
|
-
goToStepChecked(stepId: string
|
|
78
|
+
goToStepChecked(stepId: string, options?: {
|
|
79
|
+
validateOnLeave?: boolean;
|
|
80
|
+
}): Promise<void>;
|
|
81
|
+
validate(): void;
|
|
71
82
|
snapshot(): PathSnapshot<TData> | null;
|
|
72
83
|
static ɵfac: i0.ɵɵFactoryDeclaration<PathFacade<any>, never>;
|
|
73
84
|
static ɵprov: i0.ɵɵInjectableDeclaration<PathFacade<any>>;
|
|
@@ -77,7 +88,7 @@ export declare class PathFacade<TData extends PathData = PathData> implements On
|
|
|
77
88
|
* path state and strongly-typed navigation actions. Mirrors React's `usePathContext()`
|
|
78
89
|
* return type for consistency across adapters.
|
|
79
90
|
*/
|
|
80
|
-
export interface UsePathContextReturn<TData extends PathData = PathData> {
|
|
91
|
+
export interface UsePathContextReturn<TData extends PathData = PathData, TServices = unknown> {
|
|
81
92
|
/** Current path snapshot as a signal. Returns `null` when no path is active. */
|
|
82
93
|
snapshot: Signal<PathSnapshot<TData> | null>;
|
|
83
94
|
/** Start (or restart) a path. */
|
|
@@ -94,10 +105,14 @@ export interface UsePathContextReturn<TData extends PathData = PathData> {
|
|
|
94
105
|
setData: <K extends string & keyof TData>(key: K, value: TData[K]) => Promise<void>;
|
|
95
106
|
/** Reset the current step's data to what it was when the step was entered. */
|
|
96
107
|
resetStep: () => Promise<void>;
|
|
97
|
-
/** Jump to a step by ID without checking guards. */
|
|
98
|
-
goToStep: (stepId: string
|
|
108
|
+
/** Jump to a step by ID without checking guards. Pass `{ validateOnLeave: true }` to mark the departing step as attempted before navigating. */
|
|
109
|
+
goToStep: (stepId: string, options?: {
|
|
110
|
+
validateOnLeave?: boolean;
|
|
111
|
+
}) => Promise<void>;
|
|
99
112
|
/** Jump to a step by ID, checking guards first. */
|
|
100
|
-
goToStepChecked: (stepId: string
|
|
113
|
+
goToStepChecked: (stepId: string, options?: {
|
|
114
|
+
validateOnLeave?: boolean;
|
|
115
|
+
}) => Promise<void>;
|
|
101
116
|
/**
|
|
102
117
|
* Tears down any active path and immediately starts the given path fresh.
|
|
103
118
|
* Use for "Start over" / retry flows.
|
|
@@ -107,6 +122,12 @@ export interface UsePathContextReturn<TData extends PathData = PathData> {
|
|
|
107
122
|
retry: () => Promise<void>;
|
|
108
123
|
/** Pause with intent to return, preserving all state. Emits `suspended`. */
|
|
109
124
|
suspend: () => Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* The services object passed to the nearest `<pw-shell>` via `[services]`.
|
|
127
|
+
* Typed as `TServices` — pass your services interface as the second generic:
|
|
128
|
+
* `usePathContext<MyData, MyServices>().services`.
|
|
129
|
+
*/
|
|
130
|
+
services: TServices;
|
|
110
131
|
}
|
|
111
132
|
/**
|
|
112
133
|
* Access the nearest `PathFacade`'s path instance for use in Angular step components.
|
|
@@ -144,7 +165,7 @@ export interface UsePathContextReturn<TData extends PathData = PathData> {
|
|
|
144
165
|
*
|
|
145
166
|
* @throws Error if PathFacade is not provided in the injector tree
|
|
146
167
|
*/
|
|
147
|
-
export declare function usePathContext<TData extends PathData = PathData>(): UsePathContextReturn<TData>;
|
|
168
|
+
export declare function usePathContext<TData extends PathData = PathData, TServices = unknown>(): UsePathContextReturn<TData, TServices>;
|
|
148
169
|
/**
|
|
149
170
|
* Minimal interface describing what syncFormGroup needs from an Angular
|
|
150
171
|
* FormGroup. Typed as a duck interface so that @angular/forms is not a
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,12 @@ export class PathFacade {
|
|
|
23
23
|
this._events$ = new Subject();
|
|
24
24
|
this._unsubscribeFromEngine = () => { };
|
|
25
25
|
this._stateSignal = signal(null);
|
|
26
|
+
/**
|
|
27
|
+
* Arbitrary services object passed via `[services]` on `<pw-shell>`.
|
|
28
|
+
* Read it in step components via `usePathContext<TData, TServices>().services`.
|
|
29
|
+
* Set directly by `PathShellComponent` — do not set this manually.
|
|
30
|
+
*/
|
|
31
|
+
this.services = null;
|
|
26
32
|
this.state$ = this._state$.asObservable();
|
|
27
33
|
this.events$ = this._events$.asObservable();
|
|
28
34
|
/** Signal version of state$. Updates on every path state change. Requires Angular 16+. */
|
|
@@ -61,8 +67,9 @@ export class PathFacade {
|
|
|
61
67
|
this._stateSignal.set(event.snapshot);
|
|
62
68
|
}
|
|
63
69
|
else if (event.type === "completed" || event.type === "cancelled") {
|
|
64
|
-
|
|
65
|
-
this.
|
|
70
|
+
const snap = engine.snapshot();
|
|
71
|
+
this._state$.next(snap);
|
|
72
|
+
this._stateSignal.set(snap);
|
|
66
73
|
}
|
|
67
74
|
});
|
|
68
75
|
}
|
|
@@ -111,14 +118,17 @@ export class PathFacade {
|
|
|
111
118
|
resetStep() {
|
|
112
119
|
return this._engine.resetStep();
|
|
113
120
|
}
|
|
114
|
-
goToStep(stepId) {
|
|
115
|
-
return this._engine.goToStep(stepId);
|
|
121
|
+
goToStep(stepId, options) {
|
|
122
|
+
return this._engine.goToStep(stepId, options);
|
|
116
123
|
}
|
|
117
124
|
/** Jump to a step by ID, checking the current step's canMoveNext (forward) or
|
|
118
125
|
* canMovePrevious (backward) guard first. Navigation is blocked if the guard
|
|
119
126
|
* returns false. Throws if the step ID does not exist. */
|
|
120
|
-
goToStepChecked(stepId) {
|
|
121
|
-
return this._engine.goToStepChecked(stepId);
|
|
127
|
+
goToStepChecked(stepId, options) {
|
|
128
|
+
return this._engine.goToStepChecked(stepId, options);
|
|
129
|
+
}
|
|
130
|
+
validate() {
|
|
131
|
+
this._engine.validate();
|
|
122
132
|
}
|
|
123
133
|
snapshot() {
|
|
124
134
|
return this._state$.getValue();
|
|
@@ -180,11 +190,12 @@ export function usePathContext() {
|
|
|
180
190
|
cancel: () => facade.cancel(),
|
|
181
191
|
setData: (key, value) => facade.setData(key, value),
|
|
182
192
|
resetStep: () => facade.resetStep(),
|
|
183
|
-
goToStep: (stepId) => facade.goToStep(stepId),
|
|
184
|
-
goToStepChecked: (stepId) => facade.goToStepChecked(stepId),
|
|
193
|
+
goToStep: (stepId, options) => facade.goToStep(stepId, options),
|
|
194
|
+
goToStepChecked: (stepId, options) => facade.goToStepChecked(stepId, options),
|
|
185
195
|
restart: () => facade.restart(),
|
|
186
196
|
retry: () => facade.retry(),
|
|
187
197
|
suspend: () => facade.suspend(),
|
|
198
|
+
services: facade.services,
|
|
188
199
|
};
|
|
189
200
|
}
|
|
190
201
|
/**
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAyB,MAAM,EAAU,MAAM,EAAE,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAc,OAAO,EAAE,MAAM,MAAM,CAAC;AAC5D,OAAO,EAGL,UAAU,EAGX,MAAM,yBAAyB,CAAC;;AAEjC;;;;;;;;;;;;;GAaG;AAEH,MAAM,OAAO,UAAU;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AC,MAAM,CAAC,OAAO,EAAE;QAC/B,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE;QAC3B,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE;QAC/B,QAAQ,EAAE,MAAM,CAAC,QAAqB;KACvC,CAAC;AACJ,CAAC;AAoBD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAyB,EACzB,SAAwB,EACxB,UAAuB;IAEvB,MAAM,UAAU,GAAG,MAA8B,CAAC;IAElD,SAAS,WAAW;QAClB,IAAI,UAAU,CAAC,QAAQ,EAAE,KAAK,IAAI;YAAE,OAAO,CAAC,mCAAmC;QAC/E,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;YACnE,KAAK,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,yEAAyE;IACzE,WAAW,EAAE,CAAC;IAEd,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;IAE3E,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC;IACjD,UAAU,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC/B,OAAO,OAAO,CAAC;AACjB,CAAC;AAgBD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/shell.d.ts
CHANGED
|
@@ -11,8 +11,12 @@ export interface PathShellActions {
|
|
|
11
11
|
next: () => Promise<void>;
|
|
12
12
|
previous: () => Promise<void>;
|
|
13
13
|
cancel: () => Promise<void>;
|
|
14
|
-
goToStep: (stepId: string
|
|
15
|
-
|
|
14
|
+
goToStep: (stepId: string, options?: {
|
|
15
|
+
validateOnLeave?: boolean;
|
|
16
|
+
}) => Promise<void>;
|
|
17
|
+
goToStepChecked: (stepId: string, options?: {
|
|
18
|
+
validateOnLeave?: boolean;
|
|
19
|
+
}) => Promise<void>;
|
|
16
20
|
setData: (key: string, value: unknown) => Promise<void>;
|
|
17
21
|
/** Restart the shell's current path with its current `initialData`. */
|
|
18
22
|
restart: () => Promise<void>;
|
|
@@ -89,6 +93,30 @@ export declare class PathShellFooterDirective {
|
|
|
89
93
|
static ɵfac: i0.ɵɵFactoryDeclaration<PathShellFooterDirective, never>;
|
|
90
94
|
static ɵdir: i0.ɵɵDirectiveDeclaration<PathShellFooterDirective, "[pwShellFooter]", never, {}, {}, never, never, true, never>;
|
|
91
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Replaces the default completion panel inside `<pw-shell>` when
|
|
98
|
+
* `snapshot.status === "completed"` (`completionBehaviour: "stayOnFinal"`).
|
|
99
|
+
* The template receives the current `PathSnapshot` as the implicit context.
|
|
100
|
+
*
|
|
101
|
+
* ```html
|
|
102
|
+
* <pw-shell [path]="myPath">
|
|
103
|
+
* <ng-template pwShellCompletion let-s>
|
|
104
|
+
* <my-completion-screen [data]="s.data" />
|
|
105
|
+
* </ng-template>
|
|
106
|
+
* <ng-template pwStep="details"><app-details-form /></ng-template>
|
|
107
|
+
* </pw-shell>
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export declare class PathShellCompletionDirective {
|
|
111
|
+
readonly templateRef: TemplateRef<{
|
|
112
|
+
$implicit: PathSnapshot;
|
|
113
|
+
}>;
|
|
114
|
+
constructor(templateRef: TemplateRef<{
|
|
115
|
+
$implicit: PathSnapshot;
|
|
116
|
+
}>);
|
|
117
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PathShellCompletionDirective, never>;
|
|
118
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<PathShellCompletionDirective, "[pwShellCompletion]", never, {}, {}, never, never, true, never>;
|
|
119
|
+
}
|
|
92
120
|
/**
|
|
93
121
|
* Default UI shell component. Renders a progress indicator, step content,
|
|
94
122
|
* and navigation buttons.
|
|
@@ -118,8 +146,14 @@ export declare class PathShellComponent implements OnInit, OnChanges, OnDestroy
|
|
|
118
146
|
* ```
|
|
119
147
|
*/
|
|
120
148
|
engine?: PathEngine;
|
|
121
|
-
/** Initial data merged into the path engine on start. */
|
|
149
|
+
/** Initial data merged into the path engine on start. Used on first visit; overridden by stored snapshot when `restoreKey` is set. */
|
|
122
150
|
initialData: PathData;
|
|
151
|
+
/**
|
|
152
|
+
* When set, this shell automatically saves its state into the nearest outer `pw-shell`'s
|
|
153
|
+
* data under this key on every change, and restores from that stored state on remount.
|
|
154
|
+
* No-op when used on a top-level shell with no outer `pw-shell` ancestor.
|
|
155
|
+
*/
|
|
156
|
+
restoreKey?: string;
|
|
123
157
|
/** Start the path automatically on ngOnInit. Set to false to call doStart() manually. */
|
|
124
158
|
autoStart: boolean;
|
|
125
159
|
/** Label for the Back navigation button. */
|
|
@@ -136,13 +170,24 @@ export declare class PathShellComponent implements OnInit, OnChanges, OnDestroy
|
|
|
136
170
|
hideCancel: boolean;
|
|
137
171
|
/** Hide the step progress indicator in the header. Also hidden automatically when the path has only one step. */
|
|
138
172
|
hideProgress: boolean;
|
|
173
|
+
/** Hide the footer (navigation buttons). The error panel is still shown on async failure regardless of this input. */
|
|
174
|
+
hideFooter: boolean;
|
|
175
|
+
/** When true, calls `validate()` on the facade so all steps show inline errors simultaneously. Useful when this shell is nested inside a step of an outer shell: bind to the outer snapshot's `hasAttemptedNext`. */
|
|
176
|
+
validateWhen: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Arbitrary services object made available to all step components via
|
|
179
|
+
* `usePathContext<TData, TServices>().services`. Pass API clients, feature
|
|
180
|
+
* flags, or any shared dependency without prop-drilling through each step.
|
|
181
|
+
*/
|
|
182
|
+
services: unknown;
|
|
139
183
|
/**
|
|
140
|
-
*
|
|
184
|
+
* Shell layout mode:
|
|
141
185
|
* - "auto" (default): Uses "form" for single-step top-level paths, "wizard" otherwise.
|
|
142
|
-
* - "wizard": Back button on left, Cancel and Submit together on right.
|
|
143
|
-
* - "form": Cancel on left, Submit alone on right. Back button never shown.
|
|
186
|
+
* - "wizard": Progress header + Back button on left, Cancel and Submit together on right.
|
|
187
|
+
* - "form": Progress header + Cancel on left, Submit alone on right. Back button never shown.
|
|
188
|
+
* - "tabs": No progress header, no footer. Use for tabbed interfaces with a custom tab bar inside the step body.
|
|
144
189
|
*/
|
|
145
|
-
|
|
190
|
+
layout: "wizard" | "form" | "auto" | "tabs";
|
|
146
191
|
/**
|
|
147
192
|
* Controls whether the shell renders its auto-generated field-error summary box.
|
|
148
193
|
* - `"summary"` (default): Shell renders the labeled error list below the step body.
|
|
@@ -164,10 +209,13 @@ export declare class PathShellComponent implements OnInit, OnChanges, OnDestroy
|
|
|
164
209
|
stepDirectives: QueryList<PathStepDirective>;
|
|
165
210
|
customHeader?: PathShellHeaderDirective;
|
|
166
211
|
customFooter?: PathShellFooterDirective;
|
|
212
|
+
customCompletion?: PathShellCompletionDirective;
|
|
167
213
|
readonly facade: PathFacade<PathData>;
|
|
168
214
|
/** The shell's own component-level injector. Passed to ngTemplateOutlet so that
|
|
169
215
|
* step components can resolve PathFacade (provided by this shell) via inject(). */
|
|
170
216
|
protected readonly shellInjector: Injector;
|
|
217
|
+
/** Outer shell's PathFacade — present when this shell is nested inside another pw-shell. */
|
|
218
|
+
private readonly outerFacade;
|
|
171
219
|
started: boolean;
|
|
172
220
|
/** Navigation actions passed to custom `pwShellFooter` templates. */
|
|
173
221
|
protected readonly shellActions: PathShellActions;
|
|
@@ -190,10 +238,12 @@ export declare class PathShellComponent implements OnInit, OnChanges, OnDestroy
|
|
|
190
238
|
protected fieldEntries(s: PathSnapshot): [string, string][];
|
|
191
239
|
/** Returns Object.entries(s.fieldWarnings) for use in *ngFor. */
|
|
192
240
|
protected warningEntries(s: PathSnapshot): [string, string][];
|
|
193
|
-
|
|
194
|
-
|
|
241
|
+
get effectiveHideProgress(): boolean;
|
|
242
|
+
get effectiveHideFooter(): boolean;
|
|
243
|
+
/** Resolves "auto"/"tabs" layout to "wizard" or "form" for footer button arrangement. */
|
|
244
|
+
protected getResolvedLayout(s: PathSnapshot): "wizard" | "form";
|
|
195
245
|
protected errorPhaseMessage: typeof errorPhaseMessage;
|
|
196
246
|
protected formatFieldKey: typeof formatFieldKey;
|
|
197
247
|
static ɵfac: i0.ɵɵFactoryDeclaration<PathShellComponent, never>;
|
|
198
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<PathShellComponent, "pw-shell", never, { "path": { "alias": "path"; "required": false; }; "engine": { "alias": "engine"; "required": false; }; "initialData": { "alias": "initialData"; "required": false; }; "autoStart": { "alias": "autoStart"; "required": false; }; "backLabel": { "alias": "backLabel"; "required": false; }; "nextLabel": { "alias": "nextLabel"; "required": false; }; "completeLabel": { "alias": "completeLabel"; "required": false; }; "loadingLabel": { "alias": "loadingLabel"; "required": false; }; "cancelLabel": { "alias": "cancelLabel"; "required": false; }; "hideCancel": { "alias": "hideCancel"; "required": false; }; "hideProgress": { "alias": "hideProgress"; "required": false; }; "
|
|
248
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<PathShellComponent, "pw-shell", never, { "path": { "alias": "path"; "required": false; }; "engine": { "alias": "engine"; "required": false; }; "initialData": { "alias": "initialData"; "required": false; }; "restoreKey": { "alias": "restoreKey"; "required": false; }; "autoStart": { "alias": "autoStart"; "required": false; }; "backLabel": { "alias": "backLabel"; "required": false; }; "nextLabel": { "alias": "nextLabel"; "required": false; }; "completeLabel": { "alias": "completeLabel"; "required": false; }; "loadingLabel": { "alias": "loadingLabel"; "required": false; }; "cancelLabel": { "alias": "cancelLabel"; "required": false; }; "hideCancel": { "alias": "hideCancel"; "required": false; }; "hideProgress": { "alias": "hideProgress"; "required": false; }; "hideFooter": { "alias": "hideFooter"; "required": false; }; "validateWhen": { "alias": "validateWhen"; "required": false; }; "services": { "alias": "services"; "required": false; }; "layout": { "alias": "layout"; "required": false; }; "validationDisplay": { "alias": "validationDisplay"; "required": false; }; "progressLayout": { "alias": "progressLayout"; "required": false; }; }, { "complete": "complete"; "cancel": "cancel"; "event": "event"; }, ["customHeader", "customFooter", "customCompletion", "stepDirectives"], never, true, never>;
|
|
199
249
|
}
|