@phillips/seldon 1.205.2 → 1.207.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.
Files changed (34) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +88 -79
  3. package/dist/patterns/CountryPicker/CountryPickerTrigger.js +39 -33
  4. package/dist/patterns/PhoneNumberInput/PhoneNumberInput.js +51 -47
  5. package/dist/patterns/PhoneNumberInput/PhoneNumberInput.stories.d.ts +1 -1
  6. package/dist/patterns/ProgressWizard/ProgressWizard.d.ts +25 -0
  7. package/dist/patterns/ProgressWizard/ProgressWizard.js +78 -0
  8. package/dist/patterns/ProgressWizard/ProgressWizard.stories.d.ts +469 -0
  9. package/dist/patterns/ProgressWizard/ProgressWizard.test.d.ts +1 -0
  10. package/dist/patterns/ProgressWizard/components/ProgressWizardFooter.d.ts +35 -0
  11. package/dist/patterns/ProgressWizard/components/ProgressWizardFooter.js +56 -0
  12. package/dist/patterns/ProgressWizard/components/ProgressWizardFooter.test.d.ts +1 -0
  13. package/dist/patterns/ProgressWizard/hooks/useHistoryManagement.d.ts +28 -0
  14. package/dist/patterns/ProgressWizard/hooks/useHistoryManagement.js +24 -0
  15. package/dist/patterns/ProgressWizard/hooks/useHistoryManagement.test.d.ts +1 -0
  16. package/dist/patterns/ProgressWizard/index.d.ts +4 -0
  17. package/dist/patterns/ProgressWizard/types.d.ts +133 -0
  18. package/dist/patterns/ProgressWizard/types.js +17 -0
  19. package/dist/patterns/ProgressWizard/utils.d.ts +6 -0
  20. package/dist/patterns/ProgressWizard/utils.js +16 -0
  21. package/dist/patterns/ProgressWizard/utils.test.d.ts +1 -0
  22. package/dist/providers/SeldonProvider/utils.d.ts +1 -1
  23. package/dist/scss/componentStyles.scss +1 -0
  24. package/dist/scss/components/ComboBox/_combobox.scss +2 -2
  25. package/dist/scss/components/ComposedModal/_composedModal.scss +10 -0
  26. package/dist/scss/components/ProgressIndicator/_progressIndicator.scss +4 -0
  27. package/dist/scss/components/TextArea/_textArea.scss +2 -2
  28. package/dist/scss/patterns/CountryPicker/_countryPickerTrigger.scss +14 -13
  29. package/dist/scss/patterns/PhoneNumberInput/_phoneNumberInput.scss +19 -24
  30. package/dist/scss/patterns/ProgressWizard/_progressWizard.scss +83 -0
  31. package/dist/utils/index.d.ts +1 -1
  32. package/dist/utils/index.js +1 -1
  33. package/dist/utils/staticContent.test.d.ts +1 -0
  34. package/package.json +1 -2
@@ -0,0 +1,78 @@
1
+ import { jsxs as j, jsx as s } from "react/jsx-runtime";
2
+ import { forwardRef as B, useState as q, useCallback as E, useMemo as d, Children as R } from "react";
3
+ import { LoadingState as l } from "./types.js";
4
+ import { useHistoryManagement as T } from "./hooks/useHistoryManagement.js";
5
+ import { getCommonProps as Y } from "../../utils/index.js";
6
+ import { ProgressWizardFooter as D } from "./components/ProgressWizardFooter.js";
7
+ import G from "../../components/ProgressIndicator/ProgressIndicator.js";
8
+ import { isControlled as c, getLabelsFromChildren as J, wrapChildren as K } from "./utils.js";
9
+ const O = B((g, f) => {
10
+ const {
11
+ customHeader: S,
12
+ hideNavigation: a,
13
+ hideProgressIndicator: h,
14
+ isEnableHistoryManagement: p = !1,
15
+ currentStepIndex: r,
16
+ defaultStepIndex: I,
17
+ shouldAllowContinue: x = !0,
18
+ loadingState: C = l.Idle,
19
+ buttonLabels: b,
20
+ onBack: P,
21
+ onCancel: w,
22
+ onContinue: v,
23
+ onFormSubmit: y,
24
+ children: z,
25
+ ...W
26
+ } = g, { className: o, ...N } = Y(W, "ProgressWizard");
27
+ let i = I;
28
+ i !== void 0 && r !== void 0 && (console.warn(
29
+ "ProgressWizard: Both defaultStepIndex and currentStepIndex props are provided. defaultStepIndex will be ignored."
30
+ ), i = void 0);
31
+ const [m, H] = q(i ?? 0), u = E(
32
+ (A) => {
33
+ !a && !c(r) && H(A);
34
+ },
35
+ [a, r]
36
+ ), e = d(
37
+ () => r ?? m,
38
+ [r, m]
39
+ );
40
+ p && c(r) && console.warn(
41
+ "ProgressWizard: History management is disabled in controlled mode (currentStepIndex prop). To enable history management, remove the currentStepIndex prop. You may also import and use the useHistoryManagement hook directly in your controlling component."
42
+ );
43
+ const t = R.toArray(z), L = d(() => J(t), [t]), _ = d(
44
+ () => K(t, e, o),
45
+ [t, e, o]
46
+ ), n = t.length;
47
+ (!t || n === 0) && console.warn(
48
+ "ProgressWizard: No children provided. At least one child is required to render steps, two for normal behavior."
49
+ ), t[e] || console.warn(`ProgressWizard: currentStepIndex ${e} is out of bounds (0 to ${n - 1})`), T({
50
+ enabled: !c(r) && p,
51
+ currentStepIndex: e,
52
+ stepCount: n,
53
+ setCurrentStepIndex: u
54
+ });
55
+ const F = e === 0, M = e === n - 1, $ = _, k = {
56
+ setCurrentStepIndex: u,
57
+ isFirstStep: F,
58
+ isLastStep: M,
59
+ baseClassName: o,
60
+ shouldAllowContinue: x,
61
+ isLoading: [l.Loading, l.Submitting].includes(C),
62
+ labels: b,
63
+ onContinue: v,
64
+ onBack: P,
65
+ onCancel: w,
66
+ onFormSubmit: y
67
+ };
68
+ return /* @__PURE__ */ j("section", { ...N, className: o, ref: f, "aria-label": "Progress Wizard", children: [
69
+ S,
70
+ h ? null : /* @__PURE__ */ s(G, { totalSteps: n, currentStep: e + 1, labels: L }),
71
+ /* @__PURE__ */ s("div", { className: `${o}__content`, children: $ }),
72
+ a ? null : /* @__PURE__ */ s("div", { className: `${o}__footer`, children: /* @__PURE__ */ s(D, { ...k }) })
73
+ ] });
74
+ });
75
+ O.displayName = "ProgressWizard";
76
+ export {
77
+ O as default
78
+ };
@@ -0,0 +1,469 @@
1
+ import { ProgressWizardProps } from './ProgressWizard';
2
+ import { ArgTypes } from '@storybook/react';
3
+ declare const meta: {
4
+ title: string;
5
+ component: import('react').ForwardRefExoticComponent<ProgressWizardProps & {
6
+ children?: import('react').ReactNode | undefined;
7
+ } & import('react').RefAttributes<HTMLDivElement>>;
8
+ };
9
+ export default meta;
10
+ export declare const BasicWizard: {
11
+ (): import("react/jsx-runtime").JSX.Element;
12
+ argTypes: {
13
+ readonly customHeader: {
14
+ readonly control: {
15
+ readonly type: "text";
16
+ };
17
+ };
18
+ readonly hideNavigation: {
19
+ readonly control: {
20
+ readonly type: "boolean";
21
+ };
22
+ };
23
+ readonly hideProgressIndicator: {
24
+ readonly control: {
25
+ readonly type: "boolean";
26
+ };
27
+ };
28
+ readonly isEnableHistoryManagement: {
29
+ readonly control: {
30
+ readonly type: "boolean";
31
+ };
32
+ };
33
+ readonly currentStepIndex: {
34
+ readonly control: {
35
+ readonly type: "number";
36
+ };
37
+ };
38
+ readonly defaultStepIndex: {
39
+ readonly control: {
40
+ readonly type: "number";
41
+ };
42
+ };
43
+ readonly shouldAllowContinue: {
44
+ readonly control: {
45
+ readonly type: "boolean";
46
+ };
47
+ };
48
+ readonly loadingState: {
49
+ readonly control: {
50
+ readonly type: "select";
51
+ };
52
+ readonly options: readonly ["idle", "submitting", "loading"];
53
+ };
54
+ readonly buttonLabels: {
55
+ readonly control: {
56
+ readonly type: "object";
57
+ };
58
+ readonly description: "Object of button labels. Keys are start / cancel / back / continue / submit";
59
+ };
60
+ readonly onContinue: {
61
+ readonly action: "onContinue";
62
+ };
63
+ readonly onBack: {
64
+ readonly action: "onBack";
65
+ };
66
+ readonly onCancel: {
67
+ readonly action: "onCancel";
68
+ };
69
+ readonly onFormSubmit: {
70
+ readonly action: "onFormSubmit";
71
+ };
72
+ };
73
+ };
74
+ export declare const ValidationWizardWithOnBack: {
75
+ (): import("react/jsx-runtime").JSX.Element;
76
+ storyName: string;
77
+ argTypes: {
78
+ readonly customHeader: {
79
+ readonly control: {
80
+ readonly type: "text";
81
+ };
82
+ };
83
+ readonly hideNavigation: {
84
+ readonly control: {
85
+ readonly type: "boolean";
86
+ };
87
+ };
88
+ readonly hideProgressIndicator: {
89
+ readonly control: {
90
+ readonly type: "boolean";
91
+ };
92
+ };
93
+ readonly isEnableHistoryManagement: {
94
+ readonly control: {
95
+ readonly type: "boolean";
96
+ };
97
+ };
98
+ readonly currentStepIndex: {
99
+ readonly control: {
100
+ readonly type: "number";
101
+ };
102
+ };
103
+ readonly defaultStepIndex: {
104
+ readonly control: {
105
+ readonly type: "number";
106
+ };
107
+ };
108
+ readonly shouldAllowContinue: {
109
+ readonly control: {
110
+ readonly type: "boolean";
111
+ };
112
+ };
113
+ readonly loadingState: {
114
+ readonly control: {
115
+ readonly type: "select";
116
+ };
117
+ readonly options: readonly ["idle", "submitting", "loading"];
118
+ };
119
+ readonly buttonLabels: {
120
+ readonly control: {
121
+ readonly type: "object";
122
+ };
123
+ readonly description: "Object of button labels. Keys are start / cancel / back / continue / submit";
124
+ };
125
+ readonly onContinue: {
126
+ readonly action: "onContinue";
127
+ };
128
+ readonly onBack: {
129
+ readonly action: "onBack";
130
+ };
131
+ readonly onCancel: {
132
+ readonly action: "onCancel";
133
+ };
134
+ readonly onFormSubmit: {
135
+ readonly action: "onFormSubmit";
136
+ };
137
+ };
138
+ };
139
+ export declare const AsyncValidationWizardWithAllCallbacks: {
140
+ (): import("react/jsx-runtime").JSX.Element;
141
+ argTypes: {
142
+ readonly customHeader: {
143
+ readonly control: {
144
+ readonly type: "text";
145
+ };
146
+ };
147
+ readonly hideNavigation: {
148
+ readonly control: {
149
+ readonly type: "boolean";
150
+ };
151
+ };
152
+ readonly hideProgressIndicator: {
153
+ readonly control: {
154
+ readonly type: "boolean";
155
+ };
156
+ };
157
+ readonly isEnableHistoryManagement: {
158
+ readonly control: {
159
+ readonly type: "boolean";
160
+ };
161
+ };
162
+ readonly currentStepIndex: {
163
+ readonly control: {
164
+ readonly type: "number";
165
+ };
166
+ };
167
+ readonly defaultStepIndex: {
168
+ readonly control: {
169
+ readonly type: "number";
170
+ };
171
+ };
172
+ readonly shouldAllowContinue: {
173
+ readonly control: {
174
+ readonly type: "boolean";
175
+ };
176
+ };
177
+ readonly loadingState: {
178
+ readonly control: {
179
+ readonly type: "select";
180
+ };
181
+ readonly options: readonly ["idle", "submitting", "loading"];
182
+ };
183
+ readonly buttonLabels: {
184
+ readonly control: {
185
+ readonly type: "object";
186
+ };
187
+ readonly description: "Object of button labels. Keys are start / cancel / back / continue / submit";
188
+ };
189
+ readonly onContinue: {
190
+ readonly action: "onContinue";
191
+ };
192
+ readonly onBack: {
193
+ readonly action: "onBack";
194
+ };
195
+ readonly onCancel: {
196
+ readonly action: "onCancel";
197
+ };
198
+ readonly onFormSubmit: {
199
+ readonly action: "onFormSubmit";
200
+ };
201
+ };
202
+ };
203
+ export declare const ShouldAllowContinue: {
204
+ (): import("react/jsx-runtime").JSX.Element;
205
+ argTypes: {
206
+ readonly customHeader: {
207
+ readonly control: {
208
+ readonly type: "text";
209
+ };
210
+ };
211
+ readonly hideNavigation: {
212
+ readonly control: {
213
+ readonly type: "boolean";
214
+ };
215
+ };
216
+ readonly hideProgressIndicator: {
217
+ readonly control: {
218
+ readonly type: "boolean";
219
+ };
220
+ };
221
+ readonly isEnableHistoryManagement: {
222
+ readonly control: {
223
+ readonly type: "boolean";
224
+ };
225
+ };
226
+ readonly currentStepIndex: {
227
+ readonly control: {
228
+ readonly type: "number";
229
+ };
230
+ };
231
+ readonly defaultStepIndex: {
232
+ readonly control: {
233
+ readonly type: "number";
234
+ };
235
+ };
236
+ readonly shouldAllowContinue: {
237
+ readonly control: {
238
+ readonly type: "boolean";
239
+ };
240
+ };
241
+ readonly loadingState: {
242
+ readonly control: {
243
+ readonly type: "select";
244
+ };
245
+ readonly options: readonly ["idle", "submitting", "loading"];
246
+ };
247
+ readonly buttonLabels: {
248
+ readonly control: {
249
+ readonly type: "object";
250
+ };
251
+ readonly description: "Object of button labels. Keys are start / cancel / back / continue / submit";
252
+ };
253
+ readonly onContinue: {
254
+ readonly action: "onContinue";
255
+ };
256
+ readonly onBack: {
257
+ readonly action: "onBack";
258
+ };
259
+ readonly onCancel: {
260
+ readonly action: "onCancel";
261
+ };
262
+ readonly onFormSubmit: {
263
+ readonly action: "onFormSubmit";
264
+ };
265
+ };
266
+ };
267
+ export declare const ExternalStepControlWizard: {
268
+ (): import("react/jsx-runtime").JSX.Element;
269
+ argTypes: {
270
+ readonly customHeader: {
271
+ readonly control: {
272
+ readonly type: "text";
273
+ };
274
+ };
275
+ readonly hideNavigation: {
276
+ readonly control: {
277
+ readonly type: "boolean";
278
+ };
279
+ };
280
+ readonly hideProgressIndicator: {
281
+ readonly control: {
282
+ readonly type: "boolean";
283
+ };
284
+ };
285
+ readonly isEnableHistoryManagement: {
286
+ readonly control: {
287
+ readonly type: "boolean";
288
+ };
289
+ };
290
+ readonly currentStepIndex: {
291
+ readonly control: {
292
+ readonly type: "number";
293
+ };
294
+ };
295
+ readonly defaultStepIndex: {
296
+ readonly control: {
297
+ readonly type: "number";
298
+ };
299
+ };
300
+ readonly shouldAllowContinue: {
301
+ readonly control: {
302
+ readonly type: "boolean";
303
+ };
304
+ };
305
+ readonly loadingState: {
306
+ readonly control: {
307
+ readonly type: "select";
308
+ };
309
+ readonly options: readonly ["idle", "submitting", "loading"];
310
+ };
311
+ readonly buttonLabels: {
312
+ readonly control: {
313
+ readonly type: "object";
314
+ };
315
+ readonly description: "Object of button labels. Keys are start / cancel / back / continue / submit";
316
+ };
317
+ readonly onContinue: {
318
+ readonly action: "onContinue";
319
+ };
320
+ readonly onBack: {
321
+ readonly action: "onBack";
322
+ };
323
+ readonly onCancel: {
324
+ readonly action: "onCancel";
325
+ };
326
+ readonly onFormSubmit: {
327
+ readonly action: "onFormSubmit";
328
+ };
329
+ };
330
+ };
331
+ export declare const TraditionalFormWizard: {
332
+ (): import("react/jsx-runtime").JSX.Element;
333
+ argTypes: {
334
+ readonly customHeader: {
335
+ readonly control: {
336
+ readonly type: "text";
337
+ };
338
+ };
339
+ readonly hideNavigation: {
340
+ readonly control: {
341
+ readonly type: "boolean";
342
+ };
343
+ };
344
+ readonly hideProgressIndicator: {
345
+ readonly control: {
346
+ readonly type: "boolean";
347
+ };
348
+ };
349
+ readonly isEnableHistoryManagement: {
350
+ readonly control: {
351
+ readonly type: "boolean";
352
+ };
353
+ };
354
+ readonly currentStepIndex: {
355
+ readonly control: {
356
+ readonly type: "number";
357
+ };
358
+ };
359
+ readonly defaultStepIndex: {
360
+ readonly control: {
361
+ readonly type: "number";
362
+ };
363
+ };
364
+ readonly shouldAllowContinue: {
365
+ readonly control: {
366
+ readonly type: "boolean";
367
+ };
368
+ };
369
+ readonly loadingState: {
370
+ readonly control: {
371
+ readonly type: "select";
372
+ };
373
+ readonly options: readonly ["idle", "submitting", "loading"];
374
+ };
375
+ readonly buttonLabels: {
376
+ readonly control: {
377
+ readonly type: "object";
378
+ };
379
+ readonly description: "Object of button labels. Keys are start / cancel / back / continue / submit";
380
+ };
381
+ readonly onContinue: {
382
+ readonly action: "onContinue";
383
+ };
384
+ readonly onBack: {
385
+ readonly action: "onBack";
386
+ };
387
+ readonly onCancel: {
388
+ readonly action: "onCancel";
389
+ };
390
+ readonly onFormSubmit: {
391
+ readonly action: "onFormSubmit";
392
+ };
393
+ };
394
+ };
395
+ export declare const MobileFormStory: {
396
+ (): import("react/jsx-runtime").JSX.Element;
397
+ storyName: string;
398
+ parameters: {
399
+ viewport: {
400
+ defaultViewport: string;
401
+ };
402
+ };
403
+ argTypes: {
404
+ readonly customHeader: {
405
+ readonly control: {
406
+ readonly type: "text";
407
+ };
408
+ };
409
+ readonly hideNavigation: {
410
+ readonly control: {
411
+ readonly type: "boolean";
412
+ };
413
+ };
414
+ readonly hideProgressIndicator: {
415
+ readonly control: {
416
+ readonly type: "boolean";
417
+ };
418
+ };
419
+ readonly isEnableHistoryManagement: {
420
+ readonly control: {
421
+ readonly type: "boolean";
422
+ };
423
+ };
424
+ readonly currentStepIndex: {
425
+ readonly control: {
426
+ readonly type: "number";
427
+ };
428
+ };
429
+ readonly defaultStepIndex: {
430
+ readonly control: {
431
+ readonly type: "number";
432
+ };
433
+ };
434
+ readonly shouldAllowContinue: {
435
+ readonly control: {
436
+ readonly type: "boolean";
437
+ };
438
+ };
439
+ readonly loadingState: {
440
+ readonly control: {
441
+ readonly type: "select";
442
+ };
443
+ readonly options: readonly ["idle", "submitting", "loading"];
444
+ };
445
+ readonly buttonLabels: {
446
+ readonly control: {
447
+ readonly type: "object";
448
+ };
449
+ readonly description: "Object of button labels. Keys are start / cancel / back / continue / submit";
450
+ };
451
+ readonly onContinue: {
452
+ readonly action: "onContinue";
453
+ };
454
+ readonly onBack: {
455
+ readonly action: "onBack";
456
+ };
457
+ readonly onCancel: {
458
+ readonly action: "onCancel";
459
+ };
460
+ readonly onFormSubmit: {
461
+ readonly action: "onFormSubmit";
462
+ };
463
+ };
464
+ };
465
+ export declare const Playground: {
466
+ render: (props: ProgressWizardProps) => JSX.Element;
467
+ args: ProgressWizardProps;
468
+ argTypes: ArgTypes;
469
+ };
@@ -0,0 +1,35 @@
1
+ import { FC } from 'react';
2
+ import { SetCurrentStepIndex, CallbackProps, ButtonLabels } from '../types';
3
+ /**
4
+ * Props for the ProgressWizard Footer component. Controls navigation and button states.
5
+ * @property setCurrentStepIndex - Setter used for relative step moves
6
+ * @property isFirstStep - True if this is the first step (renders Cancel instead of Back)
7
+ * @property toFirstStep - Jump helper to go directly to the first step
8
+ * @property isLastStep - True if this is the last step (renders Submit instead of Continue)
9
+ * @property toLastStep - Jump helper to go directly to the last step
10
+ * @property baseClassName - Base class for styling overrides
11
+ * @property labels - Button labels for navigation (see ButtonLabels)
12
+ * @property shouldAllowContinue - Whether the primary button should be enabled (e.g. validation passed)
13
+ * @property isLoading - Whether a loading/submitting state should be shown (disables buttons and shows loader on primary)
14
+ * Inherits navigation callbacks from CallbackProps (onCancel, onBack, onContinue, onFormSubmit)
15
+ */
16
+ export interface ProgressWizardFooterProps extends CallbackProps {
17
+ setCurrentStepIndex: SetCurrentStepIndex;
18
+ isFirstStep: boolean;
19
+ isLastStep: boolean;
20
+ baseClassName?: string;
21
+ labels?: ButtonLabels;
22
+ shouldAllowContinue: boolean;
23
+ isLoading: boolean;
24
+ }
25
+ /**
26
+ * Footer component for ProgressWizard. Renders navigation buttons (Back/Cancel, Continue/Submit) and handles their states.
27
+ *
28
+ * This is the default navigation footer for the ProgressWizard. It will call the appropriate handler props when buttons are clicked.
29
+ * It can be disabled by passing `hideNavigation` to the main ProgressWizard component, in case you'd like to use a custom nav solution.
30
+ *
31
+ * @param props - ProgressWizardFooterProps
32
+ * @returns ReactElement with navigation buttons
33
+ */
34
+ export declare const ProgressWizardFooter: FC<ProgressWizardFooterProps>;
35
+ export default ProgressWizardFooter;
@@ -0,0 +1,56 @@
1
+ import { jsxs as O, Fragment as P, jsx as i } from "react/jsx-runtime";
2
+ import f from "../../../components/Button/Button.js";
3
+ import { ButtonVariants as b } from "../../../components/Button/types.js";
4
+ import _ from "../../../components/Loader/Loader.js";
5
+ import { DefaultButtonLabels as $ } from "../types.js";
6
+ const A = ({
7
+ setCurrentStepIndex: d,
8
+ isFirstStep: e,
9
+ isLastStep: o,
10
+ baseClassName: s = "progress-wizard-footer",
11
+ labels: u,
12
+ shouldAllowContinue: y,
13
+ isLoading: c,
14
+ onBack: p,
15
+ onCancel: k,
16
+ onContinue: v,
17
+ onFormSubmit: g
18
+ }) => {
19
+ const t = ({ fn: r, distance: n = 0 }) => async (j) => {
20
+ (r ? await Promise.resolve(r(j)) : void 0) !== !1 && n && d((z) => z + n);
21
+ }, a = {
22
+ ...Object.fromEntries(Object.entries($).map(([r, n]) => [r.toLowerCase(), n])),
23
+ ...u
24
+ }, l = e ? a.cancel : a.back, w = t(e ? { fn: k, distance: 0 } : { fn: p, distance: -1 }), m = o ? a.submit : e ? a.start : a.continue, C = t(o ? { fn: g } : { fn: v, distance: 1 });
25
+ return /* @__PURE__ */ O(P, { children: [
26
+ /* @__PURE__ */ i(
27
+ f,
28
+ {
29
+ variant: b.secondary,
30
+ type: "button",
31
+ className: `${s}__btn`,
32
+ "aria-label": `Progress Wizard: ${l}`,
33
+ onClick: async (r) => await w(r),
34
+ children: l
35
+ }
36
+ ),
37
+ /* @__PURE__ */ i(
38
+ f,
39
+ {
40
+ variant: b.primary,
41
+ type: o ? "submit" : "button",
42
+ className: `${s}__btn`,
43
+ "aria-label": `Progress Wizard: ${m}`,
44
+ onClick: async (r) => {
45
+ o || r.preventDefault(), await C(r);
46
+ },
47
+ isDisabled: !y || c,
48
+ children: c ? /* @__PURE__ */ i(_, {}) : m
49
+ }
50
+ )
51
+ ] });
52
+ };
53
+ export {
54
+ A as ProgressWizardFooter,
55
+ A as default
56
+ };
@@ -0,0 +1,28 @@
1
+ import { SetCurrentStepIndex } from '../types';
2
+ /**
3
+ * Hook to manage browser history state for a multi-step wizard.
4
+ *
5
+ * This hook (when enabled) pushes a new history entry whenever the user advances
6
+ * to a later step, and listens for `popstate` events so the wizard can respond
7
+ * to back/forward navigation by restoring the step index from history state.
8
+ *
9
+ * Notes:
10
+ * - Only numeric step indices within [0, stepsLength) are accepted from history state.
11
+ * - History entries are only pushed when `enabled` is true and the current
12
+ * step index is greater than the previous one (i.e. moving forward).
13
+ *
14
+ * @param params - Configuration object for the hook
15
+ * @param params.enabled - When false, the hook is inert (does not push or listen).
16
+ * @param params.currentStepIndex - The current step index of the wizard. When this
17
+ * value increases the hook will push a new history state (if enabled).
18
+ * @param params.stepCount - Total number of steps in the wizard. Used to validate
19
+ * indices read from history state before applying them via `setCurrentStepIndex`.
20
+ * @param params.setCurrentStepIndex - Setter callback used to update the current
21
+ * step index when a valid index is found in the popstate event state.
22
+ */
23
+ export declare const useHistoryManagement: ({ enabled, currentStepIndex, stepCount, setCurrentStepIndex, }: {
24
+ enabled: boolean;
25
+ currentStepIndex: number;
26
+ stepCount: number;
27
+ setCurrentStepIndex: SetCurrentStepIndex;
28
+ }) => void;
@@ -0,0 +1,24 @@
1
+ import { useRef as f, useEffect as a } from "react";
2
+ const c = ({
3
+ enabled: o,
4
+ currentStepIndex: e,
5
+ stepCount: s,
6
+ setCurrentStepIndex: i
7
+ }) => {
8
+ const n = f(0);
9
+ a(() => {
10
+ o && (e > n.current && window.history.pushState({ step: e }, "", window.location.pathname + window.location.search), n.current = e);
11
+ }, [e, o]), a(() => {
12
+ if (!o) return;
13
+ const r = (p) => {
14
+ const t = p.state;
15
+ t && typeof t.step == "number" && t.step >= 0 && t.step < s && i(t.step);
16
+ };
17
+ return window.addEventListener("popstate", r), () => {
18
+ window.removeEventListener("popstate", r);
19
+ };
20
+ }, [o, s, i]);
21
+ };
22
+ export {
23
+ c as useHistoryManagement
24
+ };