@daltonr/pathwrite-react 0.9.0 → 0.10.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/dist/index.css +86 -0
- package/dist/index.d.ts +56 -6
- package/dist/index.js +75 -37
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +146 -32
package/dist/index.css
CHANGED
|
@@ -285,6 +285,16 @@
|
|
|
285
285
|
content: ":";
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
+
/* ------------------------------------------------------------------ */
|
|
289
|
+
/* Blocking error (guard-level message, not field-attached) */
|
|
290
|
+
/* ------------------------------------------------------------------ */
|
|
291
|
+
.pw-shell__blocking-error {
|
|
292
|
+
margin: 0;
|
|
293
|
+
padding: 8px 16px;
|
|
294
|
+
font-size: 13px;
|
|
295
|
+
color: var(--pw-color-error);
|
|
296
|
+
}
|
|
297
|
+
|
|
288
298
|
/* ------------------------------------------------------------------ */
|
|
289
299
|
/* Warning messages */
|
|
290
300
|
/* ------------------------------------------------------------------ */
|
|
@@ -361,6 +371,7 @@
|
|
|
361
371
|
background: var(--pw-color-primary);
|
|
362
372
|
border-color: var(--pw-color-primary);
|
|
363
373
|
color: #fff;
|
|
374
|
+
position: relative;
|
|
364
375
|
}
|
|
365
376
|
|
|
366
377
|
.pw-shell__btn--next:hover:not(:disabled) {
|
|
@@ -368,6 +379,29 @@
|
|
|
368
379
|
border-color: #1d4ed8;
|
|
369
380
|
}
|
|
370
381
|
|
|
382
|
+
@keyframes pw-spin {
|
|
383
|
+
to { transform: rotate(360deg); }
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
.pw-shell__btn--next.pw-shell__btn--loading {
|
|
387
|
+
color: transparent;
|
|
388
|
+
pointer-events: none;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
.pw-shell__btn--next.pw-shell__btn--loading::after {
|
|
392
|
+
content: "";
|
|
393
|
+
position: absolute;
|
|
394
|
+
top: 50%;
|
|
395
|
+
left: 50%;
|
|
396
|
+
width: 14px;
|
|
397
|
+
height: 14px;
|
|
398
|
+
margin: -7px 0 0 -7px;
|
|
399
|
+
border: 2px solid rgba(255, 255, 255, 0.35);
|
|
400
|
+
border-top-color: #fff;
|
|
401
|
+
border-radius: 50%;
|
|
402
|
+
animation: pw-spin 0.6s linear infinite;
|
|
403
|
+
}
|
|
404
|
+
|
|
371
405
|
.pw-shell__btn--back {
|
|
372
406
|
background: transparent;
|
|
373
407
|
border-color: var(--pw-color-primary);
|
|
@@ -388,3 +422,55 @@
|
|
|
388
422
|
background: var(--pw-color-primary-light);
|
|
389
423
|
}
|
|
390
424
|
|
|
425
|
+
/* ------------------------------------------------------------------ */
|
|
426
|
+
/* Error panel — replaces footer when status === "error" */
|
|
427
|
+
/* ------------------------------------------------------------------ */
|
|
428
|
+
.pw-shell__error {
|
|
429
|
+
background: var(--pw-color-error-bg);
|
|
430
|
+
border: 1px solid var(--pw-color-error-border);
|
|
431
|
+
border-radius: var(--pw-shell-radius);
|
|
432
|
+
padding: 16px 20px;
|
|
433
|
+
display: flex;
|
|
434
|
+
flex-direction: column;
|
|
435
|
+
gap: 10px;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
.pw-shell__error-title {
|
|
439
|
+
font-size: 14px;
|
|
440
|
+
font-weight: 600;
|
|
441
|
+
color: var(--pw-color-error);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
.pw-shell__error-message {
|
|
445
|
+
font-size: 13px;
|
|
446
|
+
color: var(--pw-color-muted);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
.pw-shell__error-actions {
|
|
450
|
+
display: flex;
|
|
451
|
+
gap: 8px;
|
|
452
|
+
align-items: center;
|
|
453
|
+
margin-top: 2px;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.pw-shell__btn--retry {
|
|
457
|
+
background: var(--pw-color-error);
|
|
458
|
+
border-color: var(--pw-color-error);
|
|
459
|
+
color: #fff;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
.pw-shell__btn--retry:hover:not(:disabled) {
|
|
463
|
+
opacity: 0.9;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
.pw-shell__btn--suspend {
|
|
467
|
+
color: var(--pw-color-muted);
|
|
468
|
+
border-color: transparent;
|
|
469
|
+
background: transparent;
|
|
470
|
+
font-size: 13px;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
.pw-shell__btn--suspend:hover:not(:disabled) {
|
|
474
|
+
background: var(--pw-color-primary-light);
|
|
475
|
+
}
|
|
476
|
+
|
package/dist/index.d.ts
CHANGED
|
@@ -42,26 +42,54 @@ export interface UsePathReturn<TData extends PathData = PathData> {
|
|
|
42
42
|
* Use for "Start over" / retry flows without remounting the component.
|
|
43
43
|
*/
|
|
44
44
|
restart: () => void;
|
|
45
|
+
/**
|
|
46
|
+
* Re-runs the operation that set `snapshot.error`. Increments `snapshot.error.retryCount`
|
|
47
|
+
* on repeated failure so shells can escalate from "Try again" to "Come back later".
|
|
48
|
+
* No-op when there is no pending error.
|
|
49
|
+
*/
|
|
50
|
+
retry: () => void;
|
|
51
|
+
/**
|
|
52
|
+
* Pauses the path with intent to return. Emits a `suspended` event that the application
|
|
53
|
+
* listens for to dismiss the wizard UI. All state and data are preserved.
|
|
54
|
+
*/
|
|
55
|
+
suspend: () => void;
|
|
45
56
|
}
|
|
46
57
|
export type PathProviderProps = PropsWithChildren<{
|
|
47
58
|
/** Forwarded to the internal usePath hook. */
|
|
48
59
|
onEvent?: (event: PathEvent) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Services object passed through context to all step components.
|
|
62
|
+
* Step components access it via `usePathContext<TData, TServices>()`.
|
|
63
|
+
* Typed as `unknown` here so `PathProvider` stays non-generic — provide a
|
|
64
|
+
* typed services interface via the `TServices` type parameter on `usePathContext`.
|
|
65
|
+
*/
|
|
66
|
+
services?: unknown;
|
|
49
67
|
}>;
|
|
50
68
|
export declare function usePath<TData extends PathData = PathData>(options?: UsePathOptions): UsePathReturn<TData>;
|
|
51
69
|
/**
|
|
52
70
|
* Provides a single `usePath` instance to all descendants.
|
|
53
71
|
* Consume with `usePathContext()`.
|
|
54
72
|
*/
|
|
55
|
-
export declare function PathProvider({ children, onEvent }: PathProviderProps): ReactElement;
|
|
73
|
+
export declare function PathProvider({ children, onEvent, services }: PathProviderProps): ReactElement;
|
|
56
74
|
/**
|
|
57
|
-
* Access the nearest `PathProvider`'s path instance.
|
|
58
|
-
* Throws if used outside of a `<PathProvider>`.
|
|
75
|
+
* Access the nearest `PathProvider`'s path instance and optional services object.
|
|
76
|
+
* Throws if used outside of a `<PathProvider>` or `<PathShell>`.
|
|
77
|
+
*
|
|
78
|
+
* Both generics are type-level assertions, not runtime guarantees:
|
|
79
|
+
* - `TData` narrows `snapshot.data`
|
|
80
|
+
* - `TServices` types the `services` value — must match what was passed to `PathShell` or `PathProvider`
|
|
59
81
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```tsx
|
|
84
|
+
* function OfficeStep() {
|
|
85
|
+
* const { snapshot, services } = usePathContext<HiringData, HiringServices>();
|
|
86
|
+
* // services is typed as HiringServices
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
62
89
|
*/
|
|
63
|
-
export declare function usePathContext<TData extends PathData = PathData>(): Omit<UsePathReturn<TData>, "snapshot"> & {
|
|
90
|
+
export declare function usePathContext<TData extends PathData = PathData, TServices = unknown>(): Omit<UsePathReturn<TData>, "snapshot"> & {
|
|
64
91
|
snapshot: PathSnapshot<TData>;
|
|
92
|
+
services: TServices;
|
|
65
93
|
};
|
|
66
94
|
/**
|
|
67
95
|
* Binding helper for a single `<input>`, `<select>`, or `<textarea>` field.
|
|
@@ -116,6 +144,8 @@ export interface PathShellProps {
|
|
|
116
144
|
nextLabel?: string;
|
|
117
145
|
/** Label for the Complete button (shown on the last step). Defaults to `"Complete"`. */
|
|
118
146
|
completeLabel?: string;
|
|
147
|
+
/** Label shown on the Next/Complete button while an async operation is in progress. Defaults to `undefined` (button shows a CSS spinner but keeps its label). */
|
|
148
|
+
loadingLabel?: string;
|
|
119
149
|
/** Label for the Cancel button. Defaults to `"Cancel"`. */
|
|
120
150
|
cancelLabel?: string;
|
|
121
151
|
/** If true, hide the Cancel button. Defaults to `false`. */
|
|
@@ -150,6 +180,22 @@ export interface PathShellProps {
|
|
|
150
180
|
* - `"activeOnly"`: Only the active (sub-path) bar — root bar hidden.
|
|
151
181
|
*/
|
|
152
182
|
progressLayout?: ProgressLayout;
|
|
183
|
+
/**
|
|
184
|
+
* Services object passed through context to all step components.
|
|
185
|
+
* Step components access it via `usePathContext<TData, TServices>()`.
|
|
186
|
+
*
|
|
187
|
+
* The same services object that was passed to your path factory function
|
|
188
|
+
* should be passed here so step components can call service methods directly
|
|
189
|
+
* (e.g. parameterised queries that depend on mid-step user input).
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```tsx
|
|
193
|
+
* const svc = new LiveHiringServices();
|
|
194
|
+
* const path = createHiringPath(svc);
|
|
195
|
+
* <PathShell path={path} services={svc} steps={{ ... }} />
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
services?: unknown;
|
|
153
199
|
}
|
|
154
200
|
export interface PathShellHandle {
|
|
155
201
|
/** Restart the shell's current path with its original `initialData`, without unmounting. */
|
|
@@ -164,6 +210,10 @@ export interface PathShellActions {
|
|
|
164
210
|
setData: (key: string, value: unknown) => void;
|
|
165
211
|
/** Restart the shell's current path with its current `initialData`. */
|
|
166
212
|
restart: () => void;
|
|
213
|
+
/** Re-run the operation that set `snapshot.error`. See `PathEngine.retry()`. */
|
|
214
|
+
retry: () => void;
|
|
215
|
+
/** Pause with intent to return, preserving all state. Emits `suspended`. */
|
|
216
|
+
suspend: () => void;
|
|
167
217
|
}
|
|
168
218
|
/**
|
|
169
219
|
* Default UI shell that renders a progress indicator, step content, and navigation
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContext, createElement, forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useRef, useSyncExternalStore } from "react";
|
|
2
|
-
import { PathEngine } from "@daltonr/pathwrite-core";
|
|
2
|
+
import { PathEngine, formatFieldKey, errorPhaseMessage, } from "@daltonr/pathwrite-core";
|
|
3
3
|
// ---------------------------------------------------------------------------
|
|
4
4
|
// usePath hook
|
|
5
5
|
// ---------------------------------------------------------------------------
|
|
@@ -52,33 +52,44 @@ export function usePath(options) {
|
|
|
52
52
|
const setData = useCallback((key, value) => engine.setData(key, value), [engine]);
|
|
53
53
|
const resetStep = useCallback(() => engine.resetStep(), [engine]);
|
|
54
54
|
const restart = useCallback(() => engine.restart(), [engine]);
|
|
55
|
-
|
|
55
|
+
const retry = useCallback(() => engine.retry(), [engine]);
|
|
56
|
+
const suspend = useCallback(() => engine.suspend(), [engine]);
|
|
57
|
+
return { snapshot, start, startSubPath, next, previous, cancel, goToStep, goToStepChecked, setData, resetStep, restart, retry, suspend };
|
|
56
58
|
}
|
|
57
|
-
// ---------------------------------------------------------------------------
|
|
58
|
-
// Context + Provider
|
|
59
|
-
// ---------------------------------------------------------------------------
|
|
60
59
|
const PathContext = createContext(null);
|
|
61
60
|
/**
|
|
62
61
|
* Provides a single `usePath` instance to all descendants.
|
|
63
62
|
* Consume with `usePathContext()`.
|
|
64
63
|
*/
|
|
65
|
-
export function PathProvider({ children, onEvent }) {
|
|
64
|
+
export function PathProvider({ children, onEvent, services }) {
|
|
66
65
|
const path = usePath({ onEvent });
|
|
67
|
-
return createElement(PathContext.Provider, { value: path }, children);
|
|
66
|
+
return createElement(PathContext.Provider, { value: { path, services: services ?? null } }, children);
|
|
68
67
|
}
|
|
69
68
|
/**
|
|
70
|
-
* Access the nearest `PathProvider`'s path instance.
|
|
71
|
-
* Throws if used outside of a `<PathProvider>`.
|
|
69
|
+
* Access the nearest `PathProvider`'s path instance and optional services object.
|
|
70
|
+
* Throws if used outside of a `<PathProvider>` or `<PathShell>`.
|
|
71
|
+
*
|
|
72
|
+
* Both generics are type-level assertions, not runtime guarantees:
|
|
73
|
+
* - `TData` narrows `snapshot.data`
|
|
74
|
+
* - `TServices` types the `services` value — must match what was passed to `PathShell` or `PathProvider`
|
|
72
75
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```tsx
|
|
78
|
+
* function OfficeStep() {
|
|
79
|
+
* const { snapshot, services } = usePathContext<HiringData, HiringServices>();
|
|
80
|
+
* // services is typed as HiringServices
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
75
83
|
*/
|
|
76
84
|
export function usePathContext() {
|
|
77
85
|
const ctx = useContext(PathContext);
|
|
78
86
|
if (ctx === null) {
|
|
79
87
|
throw new Error("usePathContext must be used within a <PathProvider>.");
|
|
80
88
|
}
|
|
81
|
-
return
|
|
89
|
+
return {
|
|
90
|
+
...ctx.path,
|
|
91
|
+
services: ctx.services
|
|
92
|
+
};
|
|
82
93
|
}
|
|
83
94
|
// ---------------------------------------------------------------------------
|
|
84
95
|
// useField — input binding helper
|
|
@@ -115,14 +126,6 @@ export function useField(field) {
|
|
|
115
126
|
[field, setData]);
|
|
116
127
|
return { value: String(snapshot.data[field] ?? ""), onChange };
|
|
117
128
|
}
|
|
118
|
-
// ---------------------------------------------------------------------------
|
|
119
|
-
// Helpers
|
|
120
|
-
// ---------------------------------------------------------------------------
|
|
121
|
-
/** Converts a camelCase or lowercase field key to a display label.
|
|
122
|
-
* e.g. "firstName" → "First Name", "email" → "Email" */
|
|
123
|
-
function formatFieldKey(key) {
|
|
124
|
-
return key.replace(/([A-Z])/g, " $1").replace(/^./, c => c.toUpperCase()).trim();
|
|
125
|
-
}
|
|
126
129
|
/**
|
|
127
130
|
* Default UI shell that renders a progress indicator, step content, and navigation
|
|
128
131
|
* buttons. Pass a `steps` map to define per-step content.
|
|
@@ -139,7 +142,7 @@ function formatFieldKey(key) {
|
|
|
139
142
|
* />
|
|
140
143
|
* ```
|
|
141
144
|
*/
|
|
142
|
-
export const PathShell = forwardRef(function PathShell({ path: pathDef, engine: externalEngine, steps, initialData = {}, autoStart = true, onComplete, onCancel, onEvent, backLabel = "Previous", nextLabel = "Next", completeLabel = "Complete", cancelLabel = "Cancel", hideCancel = false, hideProgress = false, footerLayout = "auto", className, renderHeader, renderFooter, validationDisplay = "summary", progressLayout = "merged", }, ref) {
|
|
145
|
+
export const PathShell = forwardRef(function PathShell({ path: pathDef, engine: externalEngine, steps, initialData = {}, autoStart = true, onComplete, onCancel, onEvent, backLabel = "Previous", nextLabel = "Next", completeLabel = "Complete", loadingLabel, cancelLabel = "Cancel", hideCancel = false, hideProgress = false, footerLayout = "auto", className, renderHeader, renderFooter, validationDisplay = "summary", progressLayout = "merged", services, }, ref) {
|
|
143
146
|
const pathReturn = usePath({
|
|
144
147
|
engine: externalEngine,
|
|
145
148
|
onEvent(event) {
|
|
@@ -150,7 +153,7 @@ export const PathShell = forwardRef(function PathShell({ path: pathDef, engine:
|
|
|
150
153
|
onCancel?.(event.data);
|
|
151
154
|
}
|
|
152
155
|
});
|
|
153
|
-
const { snapshot, start, next, previous, cancel, goToStep, goToStepChecked, setData, restart } = pathReturn;
|
|
156
|
+
const { snapshot, start, next, previous, cancel, goToStep, goToStepChecked, setData, restart, retry, suspend } = pathReturn;
|
|
154
157
|
useImperativeHandle(ref, () => ({
|
|
155
158
|
restart: () => restart(),
|
|
156
159
|
}));
|
|
@@ -171,8 +174,9 @@ export const PathShell = forwardRef(function PathShell({ path: pathDef, engine:
|
|
|
171
174
|
const stepContent = snapshot
|
|
172
175
|
? ((snapshot.formId ? steps[snapshot.formId] : undefined) ?? steps[snapshot.stepId] ?? null)
|
|
173
176
|
: null;
|
|
177
|
+
const contextValue = { path: pathReturn, services: services ?? null };
|
|
174
178
|
if (!snapshot) {
|
|
175
|
-
return createElement(PathContext.Provider, { value:
|
|
179
|
+
return createElement(PathContext.Provider, { value: contextValue }, createElement("div", { className: cls("pw-shell", className) }, createElement("div", { className: "pw-shell__empty" }, createElement("p", null, "No active path."), !autoStart && createElement("button", {
|
|
176
180
|
type: "button",
|
|
177
181
|
className: "pw-shell__start-btn",
|
|
178
182
|
onClick: () => start(pathDef, initialData)
|
|
@@ -180,13 +184,15 @@ export const PathShell = forwardRef(function PathShell({ path: pathDef, engine:
|
|
|
180
184
|
}
|
|
181
185
|
const actions = {
|
|
182
186
|
next, previous, cancel, goToStep, goToStepChecked, setData,
|
|
183
|
-
restart: () => restart()
|
|
187
|
+
restart: () => restart(),
|
|
188
|
+
retry: () => retry(),
|
|
189
|
+
suspend: () => suspend(),
|
|
184
190
|
};
|
|
185
191
|
const showRoot = !hideProgress && !!snapshot.rootProgress && progressLayout !== "activeOnly";
|
|
186
192
|
const showActive = !hideProgress && (renderHeader
|
|
187
193
|
? true
|
|
188
194
|
: (snapshot.stepCount > 1 || snapshot.nestingLevel > 0) && progressLayout !== "rootOnly");
|
|
189
|
-
return createElement(PathContext.Provider, { value:
|
|
195
|
+
return createElement(PathContext.Provider, { value: contextValue }, createElement("div", { className: cls("pw-shell", progressLayout !== "merged" && `pw-shell--progress-${progressLayout}`, className) },
|
|
190
196
|
// Root progress — persistent top-level bar visible during sub-paths
|
|
191
197
|
showRoot && defaultRootProgress(snapshot.rootProgress),
|
|
192
198
|
// Header — progress indicator (active path)
|
|
@@ -199,12 +205,18 @@ export const PathShell = forwardRef(function PathShell({ path: pathDef, engine:
|
|
|
199
205
|
validationDisplay !== "inline" && snapshot.hasAttemptedNext && Object.keys(snapshot.fieldErrors).length > 0 && createElement("ul", { className: "pw-shell__validation" }, ...Object.entries(snapshot.fieldErrors).map(([key, msg]) => createElement("li", { key, className: "pw-shell__validation-item" }, key !== "_" && createElement("span", { className: "pw-shell__validation-label" }, formatFieldKey(key)), msg))),
|
|
200
206
|
// Warning messages — non-blocking, shown immediately (no hasAttemptedNext gate)
|
|
201
207
|
validationDisplay !== "inline" && Object.keys(snapshot.fieldWarnings).length > 0 && createElement("ul", { className: "pw-shell__warnings" }, ...Object.entries(snapshot.fieldWarnings).map(([key, msg]) => createElement("li", { key, className: "pw-shell__warnings-item" }, key !== "_" && createElement("span", { className: "pw-shell__warnings-label" }, formatFieldKey(key)), msg))),
|
|
202
|
-
//
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
+
// Blocking error — guard returned { allowed: false, reason }
|
|
209
|
+
validationDisplay !== "inline" && snapshot.hasAttemptedNext && snapshot.blockingError &&
|
|
210
|
+
createElement("p", { className: "pw-shell__blocking-error" }, snapshot.blockingError),
|
|
211
|
+
// Error panel — replaces footer when an async operation has failed
|
|
212
|
+
snapshot.status === "error" && snapshot.error
|
|
213
|
+
? defaultErrorPanel(snapshot, actions)
|
|
214
|
+
// Footer — navigation buttons
|
|
215
|
+
: renderFooter
|
|
216
|
+
? renderFooter(snapshot, actions)
|
|
217
|
+
: defaultFooter(snapshot, actions, {
|
|
218
|
+
backLabel, nextLabel, completeLabel, loadingLabel, cancelLabel, hideCancel, footerLayout
|
|
219
|
+
})));
|
|
208
220
|
});
|
|
209
221
|
// ---------------------------------------------------------------------------
|
|
210
222
|
// Root progress (compact top-level bar visible during sub-paths)
|
|
@@ -230,6 +242,30 @@ function defaultHeader(snapshot) {
|
|
|
230
242
|
style: { width: `${snapshot.progress * 100}%` }
|
|
231
243
|
})));
|
|
232
244
|
}
|
|
245
|
+
// ---------------------------------------------------------------------------
|
|
246
|
+
// Default error panel
|
|
247
|
+
// ---------------------------------------------------------------------------
|
|
248
|
+
function defaultErrorPanel(snapshot, actions) {
|
|
249
|
+
const { error, hasPersistence } = snapshot;
|
|
250
|
+
if (!error)
|
|
251
|
+
return createElement("div", null);
|
|
252
|
+
const escalated = error.retryCount >= 2;
|
|
253
|
+
const title = escalated ? "Still having trouble." : "Something went wrong.";
|
|
254
|
+
const phaseMsg = errorPhaseMessage(error.phase);
|
|
255
|
+
return createElement("div", { className: "pw-shell__error" }, createElement("div", { className: "pw-shell__error-title" }, title), createElement("div", { className: "pw-shell__error-message" }, phaseMsg, error.message && ` ${error.message}`), createElement("div", { className: "pw-shell__error-actions" }, !escalated && createElement("button", {
|
|
256
|
+
type: "button",
|
|
257
|
+
className: "pw-shell__btn pw-shell__btn--retry",
|
|
258
|
+
onClick: actions.retry
|
|
259
|
+
}, "Try again"), hasPersistence && createElement("button", {
|
|
260
|
+
type: "button",
|
|
261
|
+
className: cls("pw-shell__btn", escalated ? "pw-shell__btn--retry" : "pw-shell__btn--suspend"),
|
|
262
|
+
onClick: actions.suspend
|
|
263
|
+
}, "Save and come back later"), escalated && !hasPersistence && createElement("button", {
|
|
264
|
+
type: "button",
|
|
265
|
+
className: "pw-shell__btn pw-shell__btn--retry",
|
|
266
|
+
onClick: actions.retry
|
|
267
|
+
}, "Try again")));
|
|
268
|
+
}
|
|
233
269
|
function defaultFooter(snapshot, actions, labels) {
|
|
234
270
|
// Auto-detect layout: single-step top-level paths use "form", everything else uses "wizard"
|
|
235
271
|
const resolvedLayout = labels.footerLayout === "auto"
|
|
@@ -241,30 +277,32 @@ function defaultFooter(snapshot, actions, labels) {
|
|
|
241
277
|
isFormMode && !labels.hideCancel && createElement("button", {
|
|
242
278
|
type: "button",
|
|
243
279
|
className: "pw-shell__btn pw-shell__btn--cancel",
|
|
244
|
-
disabled: snapshot.
|
|
280
|
+
disabled: snapshot.status !== "idle",
|
|
245
281
|
onClick: actions.cancel
|
|
246
282
|
}, labels.cancelLabel),
|
|
247
283
|
// Wizard mode: Back on the left
|
|
248
284
|
!isFormMode && !snapshot.isFirstStep && createElement("button", {
|
|
249
285
|
type: "button",
|
|
250
286
|
className: "pw-shell__btn pw-shell__btn--back",
|
|
251
|
-
disabled: snapshot.
|
|
287
|
+
disabled: snapshot.status !== "idle" || !snapshot.canMovePrevious,
|
|
252
288
|
onClick: actions.previous
|
|
253
289
|
}, labels.backLabel)), createElement("div", { className: "pw-shell__footer-right" },
|
|
254
290
|
// Wizard mode: Cancel on the right
|
|
255
291
|
!isFormMode && !labels.hideCancel && createElement("button", {
|
|
256
292
|
type: "button",
|
|
257
293
|
className: "pw-shell__btn pw-shell__btn--cancel",
|
|
258
|
-
disabled: snapshot.
|
|
294
|
+
disabled: snapshot.status !== "idle",
|
|
259
295
|
onClick: actions.cancel
|
|
260
296
|
}, labels.cancelLabel),
|
|
261
297
|
// Both modes: Submit on the right
|
|
262
298
|
createElement("button", {
|
|
263
299
|
type: "button",
|
|
264
|
-
className: "pw-shell__btn pw-shell__btn--next",
|
|
265
|
-
disabled: snapshot.
|
|
300
|
+
className: cls("pw-shell__btn pw-shell__btn--next", snapshot.status !== "idle" && "pw-shell__btn--loading"),
|
|
301
|
+
disabled: snapshot.status !== "idle",
|
|
266
302
|
onClick: actions.next
|
|
267
|
-
}, snapshot.
|
|
303
|
+
}, snapshot.status !== "idle" && labels.loadingLabel
|
|
304
|
+
? labels.loadingLabel
|
|
305
|
+
: snapshot.isLastStep ? labels.completeLabel : labels.nextLabel)));
|
|
268
306
|
}
|
|
269
307
|
// ---------------------------------------------------------------------------
|
|
270
308
|
// Helpers
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,aAAa,EACb,UAAU,EACV,WAAW,EACX,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,MAAM,EACN,oBAAoB,EACrB,MAAM,OAAO,CAAC;AAEf,OAAO,EAGL,UAAU,EAKX,MAAM,yBAAyB,CAAC;AAwDjC,8EAA8E;AAC9E,eAAe;AACf,8EAA8E;AAE9E,MAAM,UAAU,OAAO,CAAoC,OAAwB;IACjF,2EAA2E;IAC3E,8EAA8E;IAC9E,MAAM,SAAS,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAClD,IAAI,SAAS,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAC/B,SAAS,CAAC,OAAO,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AC,MAAM,KAAK,MAAM;QACpC,OAAO,EAAE,OAAO,CAAC,MAAM;KACxB,EAAE,MAAM,CAAC,WAAW,CAAC;IACtB,kCAAkC;IAClC,aAAa,CAAC,QAAQ,EAAE;QACtB,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,GAAG,CAAC,mCAAmC,EAAE,QAAQ,CAAC,MAAM,KAAK,MAAM,IAAI,wBAAwB,CAAC;QAC3G,QAAQ,EAAE,QAAQ,CAAC,MAAM,KAAK,MAAM;QACpC,OAAO,EAAE,OAAO,CAAC,IAAI;KACtB,EAAE,QAAQ,CAAC,MAAM,KAAK,MAAM,IAAI,MAAM,CAAC,YAAY;QAChD,CAAC,CAAC,MAAM,CAAC,YAAY;QACrB,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CACrE,CACF,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E,SAAS,GAAG,CAAC,GAAG,KAA4C;IAC1D,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC;AAoBD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@daltonr/pathwrite-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "React adapter for @daltonr/pathwrite-core — hooks, context provider, and optional <PathShell> default UI.",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"react": ">=18.0.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@daltonr/pathwrite-core": "^0.
|
|
49
|
+
"@daltonr/pathwrite-core": "^0.10.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"react": "^18.3.1",
|
package/src/index.ts
CHANGED
|
@@ -17,7 +17,9 @@ import {
|
|
|
17
17
|
PathEvent,
|
|
18
18
|
PathSnapshot,
|
|
19
19
|
ProgressLayout,
|
|
20
|
-
RootProgress
|
|
20
|
+
RootProgress,
|
|
21
|
+
formatFieldKey,
|
|
22
|
+
errorPhaseMessage,
|
|
21
23
|
} from "@daltonr/pathwrite-core";
|
|
22
24
|
|
|
23
25
|
// ---------------------------------------------------------------------------
|
|
@@ -67,11 +69,29 @@ export interface UsePathReturn<TData extends PathData = PathData> {
|
|
|
67
69
|
* Use for "Start over" / retry flows without remounting the component.
|
|
68
70
|
*/
|
|
69
71
|
restart: () => void;
|
|
72
|
+
/**
|
|
73
|
+
* Re-runs the operation that set `snapshot.error`. Increments `snapshot.error.retryCount`
|
|
74
|
+
* on repeated failure so shells can escalate from "Try again" to "Come back later".
|
|
75
|
+
* No-op when there is no pending error.
|
|
76
|
+
*/
|
|
77
|
+
retry: () => void;
|
|
78
|
+
/**
|
|
79
|
+
* Pauses the path with intent to return. Emits a `suspended` event that the application
|
|
80
|
+
* listens for to dismiss the wizard UI. All state and data are preserved.
|
|
81
|
+
*/
|
|
82
|
+
suspend: () => void;
|
|
70
83
|
}
|
|
71
84
|
|
|
72
85
|
export type PathProviderProps = PropsWithChildren<{
|
|
73
86
|
/** Forwarded to the internal usePath hook. */
|
|
74
87
|
onEvent?: (event: PathEvent) => void;
|
|
88
|
+
/**
|
|
89
|
+
* Services object passed through context to all step components.
|
|
90
|
+
* Step components access it via `usePathContext<TData, TServices>()`.
|
|
91
|
+
* Typed as `unknown` here so `PathProvider` stays non-generic — provide a
|
|
92
|
+
* typed services interface via the `TServices` type parameter on `usePathContext`.
|
|
93
|
+
*/
|
|
94
|
+
services?: unknown;
|
|
75
95
|
}>;
|
|
76
96
|
|
|
77
97
|
// ---------------------------------------------------------------------------
|
|
@@ -160,37 +180,58 @@ export function usePath<TData extends PathData = PathData>(options?: UsePathOpti
|
|
|
160
180
|
|
|
161
181
|
const restart = useCallback(() => engine.restart(), [engine]);
|
|
162
182
|
|
|
163
|
-
|
|
183
|
+
const retry = useCallback(() => engine.retry(), [engine]);
|
|
184
|
+
|
|
185
|
+
const suspend = useCallback(() => engine.suspend(), [engine]);
|
|
186
|
+
|
|
187
|
+
return { snapshot, start, startSubPath, next, previous, cancel, goToStep, goToStepChecked, setData, resetStep, restart, retry, suspend };
|
|
164
188
|
}
|
|
165
189
|
|
|
166
190
|
// ---------------------------------------------------------------------------
|
|
167
191
|
// Context + Provider
|
|
168
192
|
// ---------------------------------------------------------------------------
|
|
169
193
|
|
|
170
|
-
|
|
194
|
+
interface PathContextValue {
|
|
195
|
+
path: UsePathReturn;
|
|
196
|
+
services: unknown;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const PathContext = createContext<PathContextValue | null>(null);
|
|
171
200
|
|
|
172
201
|
/**
|
|
173
202
|
* Provides a single `usePath` instance to all descendants.
|
|
174
203
|
* Consume with `usePathContext()`.
|
|
175
204
|
*/
|
|
176
|
-
export function PathProvider({ children, onEvent }: PathProviderProps): ReactElement {
|
|
205
|
+
export function PathProvider({ children, onEvent, services }: PathProviderProps): ReactElement {
|
|
177
206
|
const path = usePath({ onEvent });
|
|
178
|
-
return createElement(PathContext.Provider, { value: path }, children);
|
|
207
|
+
return createElement(PathContext.Provider, { value: { path, services: services ?? null } }, children);
|
|
179
208
|
}
|
|
180
209
|
|
|
181
210
|
/**
|
|
182
|
-
* Access the nearest `PathProvider`'s path instance.
|
|
183
|
-
* Throws if used outside of a `<PathProvider>`.
|
|
211
|
+
* Access the nearest `PathProvider`'s path instance and optional services object.
|
|
212
|
+
* Throws if used outside of a `<PathProvider>` or `<PathShell>`.
|
|
213
|
+
*
|
|
214
|
+
* Both generics are type-level assertions, not runtime guarantees:
|
|
215
|
+
* - `TData` narrows `snapshot.data`
|
|
216
|
+
* - `TServices` types the `services` value — must match what was passed to `PathShell` or `PathProvider`
|
|
184
217
|
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```tsx
|
|
220
|
+
* function OfficeStep() {
|
|
221
|
+
* const { snapshot, services } = usePathContext<HiringData, HiringServices>();
|
|
222
|
+
* // services is typed as HiringServices
|
|
223
|
+
* }
|
|
224
|
+
* ```
|
|
187
225
|
*/
|
|
188
|
-
export function usePathContext<TData extends PathData = PathData>(): Omit<UsePathReturn<TData>, "snapshot"> & { snapshot: PathSnapshot<TData
|
|
226
|
+
export function usePathContext<TData extends PathData = PathData, TServices = unknown>(): Omit<UsePathReturn<TData>, "snapshot"> & { snapshot: PathSnapshot<TData>; services: TServices } {
|
|
189
227
|
const ctx = useContext(PathContext);
|
|
190
228
|
if (ctx === null) {
|
|
191
229
|
throw new Error("usePathContext must be used within a <PathProvider>.");
|
|
192
230
|
}
|
|
193
|
-
return
|
|
231
|
+
return {
|
|
232
|
+
...(ctx.path as unknown as Omit<UsePathReturn<TData>, "snapshot"> & { snapshot: PathSnapshot<TData> }),
|
|
233
|
+
services: ctx.services as TServices
|
|
234
|
+
};
|
|
194
235
|
}
|
|
195
236
|
|
|
196
237
|
// ---------------------------------------------------------------------------
|
|
@@ -238,11 +279,6 @@ export function useField<TData extends PathData, K extends string & keyof TData>
|
|
|
238
279
|
// Helpers
|
|
239
280
|
// ---------------------------------------------------------------------------
|
|
240
281
|
|
|
241
|
-
/** Converts a camelCase or lowercase field key to a display label.
|
|
242
|
-
* e.g. "firstName" → "First Name", "email" → "Email" */
|
|
243
|
-
function formatFieldKey(key: string): string {
|
|
244
|
-
return key.replace(/([A-Z])/g, " $1").replace(/^./, c => c.toUpperCase()).trim();
|
|
245
|
-
}
|
|
246
282
|
|
|
247
283
|
// ---------------------------------------------------------------------------
|
|
248
284
|
// Default UI — PathShell
|
|
@@ -275,6 +311,8 @@ export interface PathShellProps {
|
|
|
275
311
|
nextLabel?: string;
|
|
276
312
|
/** Label for the Complete button (shown on the last step). Defaults to `"Complete"`. */
|
|
277
313
|
completeLabel?: string;
|
|
314
|
+
/** Label shown on the Next/Complete button while an async operation is in progress. Defaults to `undefined` (button shows a CSS spinner but keeps its label). */
|
|
315
|
+
loadingLabel?: string;
|
|
278
316
|
/** Label for the Cancel button. Defaults to `"Cancel"`. */
|
|
279
317
|
cancelLabel?: string;
|
|
280
318
|
/** If true, hide the Cancel button. Defaults to `false`. */
|
|
@@ -309,6 +347,22 @@ export interface PathShellProps {
|
|
|
309
347
|
* - `"activeOnly"`: Only the active (sub-path) bar — root bar hidden.
|
|
310
348
|
*/
|
|
311
349
|
progressLayout?: ProgressLayout;
|
|
350
|
+
/**
|
|
351
|
+
* Services object passed through context to all step components.
|
|
352
|
+
* Step components access it via `usePathContext<TData, TServices>()`.
|
|
353
|
+
*
|
|
354
|
+
* The same services object that was passed to your path factory function
|
|
355
|
+
* should be passed here so step components can call service methods directly
|
|
356
|
+
* (e.g. parameterised queries that depend on mid-step user input).
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* ```tsx
|
|
360
|
+
* const svc = new LiveHiringServices();
|
|
361
|
+
* const path = createHiringPath(svc);
|
|
362
|
+
* <PathShell path={path} services={svc} steps={{ ... }} />
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
365
|
+
services?: unknown;
|
|
312
366
|
}
|
|
313
367
|
|
|
314
368
|
export interface PathShellHandle {
|
|
@@ -325,6 +379,10 @@ export interface PathShellActions {
|
|
|
325
379
|
setData: (key: string, value: unknown) => void;
|
|
326
380
|
/** Restart the shell's current path with its current `initialData`. */
|
|
327
381
|
restart: () => void;
|
|
382
|
+
/** Re-run the operation that set `snapshot.error`. See `PathEngine.retry()`. */
|
|
383
|
+
retry: () => void;
|
|
384
|
+
/** Pause with intent to return, preserving all state. Emits `suspended`. */
|
|
385
|
+
suspend: () => void;
|
|
328
386
|
}
|
|
329
387
|
|
|
330
388
|
/**
|
|
@@ -355,6 +413,7 @@ export const PathShell = forwardRef<PathShellHandle, PathShellProps>(function Pa
|
|
|
355
413
|
backLabel = "Previous",
|
|
356
414
|
nextLabel = "Next",
|
|
357
415
|
completeLabel = "Complete",
|
|
416
|
+
loadingLabel,
|
|
358
417
|
cancelLabel = "Cancel",
|
|
359
418
|
hideCancel = false,
|
|
360
419
|
hideProgress = false,
|
|
@@ -364,6 +423,7 @@ export const PathShell = forwardRef<PathShellHandle, PathShellProps>(function Pa
|
|
|
364
423
|
renderFooter,
|
|
365
424
|
validationDisplay = "summary",
|
|
366
425
|
progressLayout = "merged",
|
|
426
|
+
services,
|
|
367
427
|
}: PathShellProps, ref): ReactElement {
|
|
368
428
|
const pathReturn = usePath({
|
|
369
429
|
engine: externalEngine,
|
|
@@ -374,7 +434,7 @@ export const PathShell = forwardRef<PathShellHandle, PathShellProps>(function Pa
|
|
|
374
434
|
}
|
|
375
435
|
});
|
|
376
436
|
|
|
377
|
-
const { snapshot, start, next, previous, cancel, goToStep, goToStepChecked, setData, restart } = pathReturn;
|
|
437
|
+
const { snapshot, start, next, previous, cancel, goToStep, goToStepChecked, setData, restart, retry, suspend } = pathReturn;
|
|
378
438
|
|
|
379
439
|
useImperativeHandle(ref, () => ({
|
|
380
440
|
restart: () => restart(),
|
|
@@ -399,8 +459,10 @@ export const PathShell = forwardRef<PathShellHandle, PathShellProps>(function Pa
|
|
|
399
459
|
? ((snapshot.formId ? steps[snapshot.formId] : undefined) ?? steps[snapshot.stepId] ?? null)
|
|
400
460
|
: null;
|
|
401
461
|
|
|
462
|
+
const contextValue: PathContextValue = { path: pathReturn, services: services ?? null };
|
|
463
|
+
|
|
402
464
|
if (!snapshot) {
|
|
403
|
-
return createElement(PathContext.Provider, { value:
|
|
465
|
+
return createElement(PathContext.Provider, { value: contextValue },
|
|
404
466
|
createElement("div", { className: cls("pw-shell", className) },
|
|
405
467
|
createElement("div", { className: "pw-shell__empty" },
|
|
406
468
|
createElement("p", null, "No active path."),
|
|
@@ -416,7 +478,9 @@ export const PathShell = forwardRef<PathShellHandle, PathShellProps>(function Pa
|
|
|
416
478
|
|
|
417
479
|
const actions: PathShellActions = {
|
|
418
480
|
next, previous, cancel, goToStep, goToStepChecked, setData,
|
|
419
|
-
restart: () => restart()
|
|
481
|
+
restart: () => restart(),
|
|
482
|
+
retry: () => retry(),
|
|
483
|
+
suspend: () => suspend(),
|
|
420
484
|
};
|
|
421
485
|
|
|
422
486
|
const showRoot = !hideProgress && !!snapshot.rootProgress && progressLayout !== "activeOnly";
|
|
@@ -424,7 +488,7 @@ export const PathShell = forwardRef<PathShellHandle, PathShellProps>(function Pa
|
|
|
424
488
|
? true
|
|
425
489
|
: (snapshot.stepCount > 1 || snapshot.nestingLevel > 0) && progressLayout !== "rootOnly");
|
|
426
490
|
|
|
427
|
-
return createElement(PathContext.Provider, { value:
|
|
491
|
+
return createElement(PathContext.Provider, { value: contextValue },
|
|
428
492
|
createElement("div", { className: cls("pw-shell", progressLayout !== "merged" && `pw-shell--progress-${progressLayout}`, className) },
|
|
429
493
|
// Root progress — persistent top-level bar visible during sub-paths
|
|
430
494
|
showRoot && defaultRootProgress(snapshot.rootProgress!),
|
|
@@ -452,12 +516,18 @@ export const PathShell = forwardRef<PathShellHandle, PathShellProps>(function Pa
|
|
|
452
516
|
)
|
|
453
517
|
)
|
|
454
518
|
),
|
|
455
|
-
//
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
519
|
+
// Blocking error — guard returned { allowed: false, reason }
|
|
520
|
+
validationDisplay !== "inline" && snapshot.hasAttemptedNext && snapshot.blockingError &&
|
|
521
|
+
createElement("p", { className: "pw-shell__blocking-error" }, snapshot.blockingError),
|
|
522
|
+
// Error panel — replaces footer when an async operation has failed
|
|
523
|
+
snapshot.status === "error" && snapshot.error
|
|
524
|
+
? defaultErrorPanel(snapshot, actions)
|
|
525
|
+
// Footer — navigation buttons
|
|
526
|
+
: renderFooter
|
|
527
|
+
? renderFooter(snapshot, actions)
|
|
528
|
+
: defaultFooter(snapshot, actions, {
|
|
529
|
+
backLabel, nextLabel, completeLabel, loadingLabel, cancelLabel, hideCancel, footerLayout
|
|
530
|
+
})
|
|
461
531
|
)
|
|
462
532
|
);
|
|
463
533
|
});
|
|
@@ -522,6 +592,47 @@ function defaultHeader(snapshot: PathSnapshot): ReactElement {
|
|
|
522
592
|
);
|
|
523
593
|
}
|
|
524
594
|
|
|
595
|
+
// ---------------------------------------------------------------------------
|
|
596
|
+
// Default error panel
|
|
597
|
+
// ---------------------------------------------------------------------------
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
function defaultErrorPanel(
|
|
601
|
+
snapshot: PathSnapshot,
|
|
602
|
+
actions: PathShellActions
|
|
603
|
+
): ReactElement {
|
|
604
|
+
const { error, hasPersistence } = snapshot;
|
|
605
|
+
if (!error) return createElement("div", null);
|
|
606
|
+
const escalated = error.retryCount >= 2;
|
|
607
|
+
const title = escalated ? "Still having trouble." : "Something went wrong.";
|
|
608
|
+
const phaseMsg = errorPhaseMessage(error.phase);
|
|
609
|
+
|
|
610
|
+
return createElement("div", { className: "pw-shell__error" },
|
|
611
|
+
createElement("div", { className: "pw-shell__error-title" }, title),
|
|
612
|
+
createElement("div", { className: "pw-shell__error-message" },
|
|
613
|
+
phaseMsg,
|
|
614
|
+
error.message && ` ${error.message}`
|
|
615
|
+
),
|
|
616
|
+
createElement("div", { className: "pw-shell__error-actions" },
|
|
617
|
+
!escalated && createElement("button", {
|
|
618
|
+
type: "button",
|
|
619
|
+
className: "pw-shell__btn pw-shell__btn--retry",
|
|
620
|
+
onClick: actions.retry
|
|
621
|
+
}, "Try again"),
|
|
622
|
+
hasPersistence && createElement("button", {
|
|
623
|
+
type: "button",
|
|
624
|
+
className: cls("pw-shell__btn", escalated ? "pw-shell__btn--retry" : "pw-shell__btn--suspend"),
|
|
625
|
+
onClick: actions.suspend
|
|
626
|
+
}, "Save and come back later"),
|
|
627
|
+
escalated && !hasPersistence && createElement("button", {
|
|
628
|
+
type: "button",
|
|
629
|
+
className: "pw-shell__btn pw-shell__btn--retry",
|
|
630
|
+
onClick: actions.retry
|
|
631
|
+
}, "Try again")
|
|
632
|
+
)
|
|
633
|
+
);
|
|
634
|
+
}
|
|
635
|
+
|
|
525
636
|
// ---------------------------------------------------------------------------
|
|
526
637
|
// Default footer (navigation buttons)
|
|
527
638
|
// ---------------------------------------------------------------------------
|
|
@@ -530,6 +641,7 @@ interface FooterLabels {
|
|
|
530
641
|
backLabel: string;
|
|
531
642
|
nextLabel: string;
|
|
532
643
|
completeLabel: string;
|
|
644
|
+
loadingLabel?: string;
|
|
533
645
|
cancelLabel: string;
|
|
534
646
|
hideCancel: boolean;
|
|
535
647
|
footerLayout: "wizard" | "form" | "auto";
|
|
@@ -553,14 +665,14 @@ function defaultFooter(
|
|
|
553
665
|
isFormMode && !labels.hideCancel && createElement("button", {
|
|
554
666
|
type: "button",
|
|
555
667
|
className: "pw-shell__btn pw-shell__btn--cancel",
|
|
556
|
-
disabled: snapshot.
|
|
668
|
+
disabled: snapshot.status !== "idle",
|
|
557
669
|
onClick: actions.cancel
|
|
558
670
|
}, labels.cancelLabel),
|
|
559
671
|
// Wizard mode: Back on the left
|
|
560
672
|
!isFormMode && !snapshot.isFirstStep && createElement("button", {
|
|
561
673
|
type: "button",
|
|
562
674
|
className: "pw-shell__btn pw-shell__btn--back",
|
|
563
|
-
disabled: snapshot.
|
|
675
|
+
disabled: snapshot.status !== "idle" || !snapshot.canMovePrevious,
|
|
564
676
|
onClick: actions.previous
|
|
565
677
|
}, labels.backLabel)
|
|
566
678
|
),
|
|
@@ -569,16 +681,18 @@ function defaultFooter(
|
|
|
569
681
|
!isFormMode && !labels.hideCancel && createElement("button", {
|
|
570
682
|
type: "button",
|
|
571
683
|
className: "pw-shell__btn pw-shell__btn--cancel",
|
|
572
|
-
disabled: snapshot.
|
|
684
|
+
disabled: snapshot.status !== "idle",
|
|
573
685
|
onClick: actions.cancel
|
|
574
686
|
}, labels.cancelLabel),
|
|
575
687
|
// Both modes: Submit on the right
|
|
576
688
|
createElement("button", {
|
|
577
689
|
type: "button",
|
|
578
|
-
className: "pw-shell__btn pw-shell__btn--next",
|
|
579
|
-
disabled: snapshot.
|
|
690
|
+
className: cls("pw-shell__btn pw-shell__btn--next", snapshot.status !== "idle" && "pw-shell__btn--loading"),
|
|
691
|
+
disabled: snapshot.status !== "idle",
|
|
580
692
|
onClick: actions.next
|
|
581
|
-
}, snapshot.
|
|
693
|
+
}, snapshot.status !== "idle" && labels.loadingLabel
|
|
694
|
+
? labels.loadingLabel
|
|
695
|
+
: snapshot.isLastStep ? labels.completeLabel : labels.nextLabel)
|
|
582
696
|
)
|
|
583
697
|
);
|
|
584
698
|
}
|