policyengine-household-wizard 0.1.0 → 0.2.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 (53) hide show
  1. package/README.md +37 -2
  2. package/dist/WizardReviewList-DhLx8Bla.cjs +1 -0
  3. package/dist/WizardReviewList-oY1HqmLw.js +354 -0
  4. package/dist/index-B_OXaS4a.cjs +1 -0
  5. package/dist/index-DWM0giHt.js +220 -0
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.js +34 -28
  8. package/dist/primitives/WizardReviewList.d.ts +3 -2
  9. package/dist/primitives/WizardReviewList.d.ts.map +1 -1
  10. package/dist/primitives/index.d.ts +3 -1
  11. package/dist/primitives/index.d.ts.map +1 -1
  12. package/dist/primitives/types.d.ts +18 -0
  13. package/dist/primitives/types.d.ts.map +1 -1
  14. package/dist/primitives/useWizardStepFocus.d.ts +13 -0
  15. package/dist/primitives/useWizardStepFocus.d.ts.map +1 -0
  16. package/dist/primitives/useWizardSteps.d.ts +1 -1
  17. package/dist/primitives/useWizardSteps.d.ts.map +1 -1
  18. package/dist/primitives.cjs +1 -1
  19. package/dist/primitives.js +5 -4
  20. package/dist/us-household/adapters/v1Payload.d.ts +119 -3
  21. package/dist/us-household/adapters/v1Payload.d.ts.map +1 -1
  22. package/dist/us-household/amount.d.ts +8 -0
  23. package/dist/us-household/amount.d.ts.map +1 -0
  24. package/dist/us-household/index.d.ts +2 -1
  25. package/dist/us-household/index.d.ts.map +1 -1
  26. package/dist/us-household/normalize.d.ts.map +1 -1
  27. package/dist/us-household/serialize.d.ts.map +1 -1
  28. package/dist/us-household/tippedOccupations.d.ts +40 -0
  29. package/dist/us-household/tippedOccupations.d.ts.map +1 -0
  30. package/dist/us-household/types.d.ts +137 -4
  31. package/dist/us-household/types.d.ts.map +1 -1
  32. package/dist/us-household/validate.d.ts.map +1 -1
  33. package/dist/us-household-adapters.cjs +1 -1
  34. package/dist/us-household-adapters.js +3 -90
  35. package/dist/us-household.cjs +1 -1
  36. package/dist/us-household.js +346 -246
  37. package/package.json +4 -1
  38. package/src/primitives/WizardReviewList.tsx +35 -18
  39. package/src/primitives/index.ts +3 -0
  40. package/src/primitives/types.ts +20 -0
  41. package/src/primitives/useWizardStepFocus.ts +42 -0
  42. package/src/primitives/useWizardSteps.ts +181 -84
  43. package/src/styles.css +9 -0
  44. package/src/us-household/adapters/v1Payload.ts +211 -18
  45. package/src/us-household/amount.ts +10 -0
  46. package/src/us-household/index.ts +11 -0
  47. package/src/us-household/normalize.ts +79 -4
  48. package/src/us-household/serialize.ts +5 -1
  49. package/src/us-household/tippedOccupations.ts +145 -0
  50. package/src/us-household/types.ts +143 -4
  51. package/src/us-household/validate.ts +101 -4
  52. package/dist/WizardReviewList-De9RTK_4.js +0 -245
  53. package/dist/WizardReviewList-tfP9LcqU.cjs +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "policyengine-household-wizard",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Shared wizard primitives and US household draft contract for PolicyEngine apps.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -36,10 +36,12 @@
36
36
  "scripts": {
37
37
  "build": "vite build && tsc -p tsconfig.build.json --emitDeclarationOnly && tsx scripts/emit-subpath-types.ts",
38
38
  "test": "vitest run",
39
+ "test:live": "POLICYENGINE_LIVE_API=1 vitest run tests/us-household/v1Payload.live.test.ts",
39
40
  "test:watch": "vitest",
40
41
  "typecheck": "tsc --noEmit",
41
42
  "lint": "tsc --noEmit",
42
43
  "regenerate-counties": "tsx scripts/generate-counties.ts",
44
+ "regenerate-variable-graph": "tsx scripts/generate-variable-graph.ts",
43
45
  "prepublishOnly": "bun run build"
44
46
  },
45
47
  "sideEffects": [
@@ -57,6 +59,7 @@
57
59
  "@types/react": "^19.0.0",
58
60
  "@types/react-dom": "^19.0.0",
59
61
  "@vitejs/plugin-react": "^4.3.4",
62
+ "fast-check": "^4.10.2",
60
63
  "jsdom": "^25.0.1",
61
64
  "react": "^19.0.0",
62
65
  "react-dom": "^19.0.0",
@@ -1,26 +1,34 @@
1
- import type { HTMLAttributes, ReactNode } from 'react';
1
+ import { useId } from 'react';
2
+ import type { HTMLAttributes, MouseEvent, ReactNode } from 'react';
2
3
 
3
4
  export interface WizardReviewItem {
4
5
  id: string;
5
6
  label: ReactNode;
6
7
  value: ReactNode;
7
8
  missing?: boolean;
8
- onEdit?: () => void;
9
+ onEdit?: (event: MouseEvent<HTMLButtonElement>) => void;
9
10
  editLabel?: ReactNode;
11
+ editAriaLabel?: string;
10
12
  }
11
13
 
12
14
  export interface WizardReviewListProps extends HTMLAttributes<HTMLDivElement> {
13
15
  items: WizardReviewItem[];
14
16
  }
15
17
 
16
- export function WizardReviewList({ items, className, ...rest }: WizardReviewListProps) {
18
+ export function WizardReviewList({
19
+ items,
20
+ className,
21
+ ...rest
22
+ }: WizardReviewListProps) {
23
+ const listId = useId();
17
24
  return (
18
25
  <div
19
26
  className={['pe-wizard-review-list', className].filter(Boolean).join(' ')}
20
27
  role="list"
21
28
  {...rest}
22
29
  >
23
- {items.map((item) => {
30
+ {items.map((item, index) => {
31
+ const valueId = `${listId}-${index}-value`;
24
32
  const classes = ['pe-wizard-review-item'];
25
33
  if (item.missing) {
26
34
  classes.push('pe-wizard-review-item--missing');
@@ -29,8 +37,11 @@ export function WizardReviewList({ items, className, ...rest }: WizardReviewList
29
37
  const content = (
30
38
  <>
31
39
  <span className="pe-wizard-review-item-label">{item.label}</span>
32
- <span className="pe-wizard-review-item-value">
33
- {item.missing && (item.value === null || item.value === undefined || item.value === '')
40
+ <span id={valueId} className="pe-wizard-review-item-value">
41
+ {item.missing &&
42
+ (item.value === null ||
43
+ item.value === undefined ||
44
+ item.value === '')
34
45
  ? 'Missing'
35
46
  : item.value}
36
47
  </span>
@@ -51,21 +62,27 @@ export function WizardReviewList({ items, className, ...rest }: WizardReviewList
51
62
  }
52
63
 
53
64
  return (
54
- <button
65
+ <div
55
66
  key={item.id}
56
- type="button"
57
67
  role="listitem"
58
- className={classes.join(' ')}
59
- data-testid={`pe-wizard-review-${item.id}`}
60
- onClick={item.onEdit}
61
- aria-label={
62
- typeof item.label === 'string'
63
- ? `${item.editLabel ?? 'Edit'} ${item.label}`
64
- : undefined
65
- }
68
+ className="pe-wizard-review-listitem"
66
69
  >
67
- {content}
68
- </button>
70
+ <button
71
+ type="button"
72
+ className={classes.join(' ')}
73
+ data-testid={`pe-wizard-review-${item.id}`}
74
+ onClick={item.onEdit}
75
+ aria-describedby={valueId}
76
+ aria-label={
77
+ item.editAriaLabel ??
78
+ (typeof item.label === 'string'
79
+ ? `${item.editLabel ?? 'Edit'} ${item.label}`
80
+ : undefined)
81
+ }
82
+ >
83
+ {content}
84
+ </button>
85
+ </div>
69
86
  );
70
87
  })}
71
88
  </div>
@@ -1,4 +1,6 @@
1
1
  export { useWizardSteps } from './useWizardSteps';
2
+ export { useWizardStepFocus } from './useWizardStepFocus';
3
+ export type { UseWizardStepFocusOptions } from './useWizardStepFocus';
2
4
  export { WizardProgress } from './WizardProgress';
3
5
  export type { WizardProgressProps } from './WizardProgress';
4
6
  export { WizardOptionCard } from './WizardOptionCard';
@@ -12,4 +14,5 @@ export type {
12
14
  UseWizardStepsOptions,
13
15
  UseWizardStepsResult,
14
16
  WizardStepConfig,
17
+ WizardAdvanceRequest,
15
18
  } from './types';
@@ -1,8 +1,16 @@
1
+ import type { FormEvent, KeyboardEvent } from 'react';
2
+
1
3
  export interface WizardStepConfig<TState> {
2
4
  id: string;
3
5
  label: string;
4
6
  isComplete?: (state: TState) => boolean;
5
7
  isVisible?: (state: TState) => boolean;
8
+ autoAdvance?: boolean;
9
+ }
10
+
11
+ /** Create a new object for each explicit selection, alongside its state update. */
12
+ export interface WizardAdvanceRequest {
13
+ stepId: string;
6
14
  }
7
15
 
8
16
  export interface ResolvedWizardStep {
@@ -15,6 +23,9 @@ export interface UseWizardStepsOptions<TState> {
15
23
  state: TState;
16
24
  initialStepId?: string;
17
25
  onStepChange?: (stepId: string) => void;
26
+ onComplete?: () => void;
27
+ onInvalidStep?: (stepId: string) => void;
28
+ advanceRequest?: WizardAdvanceRequest | null;
18
29
  }
19
30
 
20
31
  export interface UseWizardStepsResult {
@@ -25,6 +36,15 @@ export interface UseWizardStepsResult {
25
36
  isFirstStep: boolean;
26
37
  isLastStep: boolean;
27
38
  canAdvance: boolean;
39
+ visitedStepIds: string[];
40
+ hasVisitedStep: (stepId: string) => boolean;
41
+ validationStepId: string | null;
42
+ validationAttempt: number;
43
+ clearValidation: () => void;
44
+ validateAll: () => boolean;
45
+ advance: () => void;
46
+ handleSubmit: (event: FormEvent<HTMLFormElement>) => void;
47
+ handleKeyDown: (event: KeyboardEvent<HTMLFormElement>) => void;
28
48
  goNext: () => void;
29
49
  goBack: () => void;
30
50
  goToStep: (stepId: string) => void;
@@ -0,0 +1,42 @@
1
+ import { useEffect, useRef } from 'react';
2
+
3
+ export interface UseWizardStepFocusOptions {
4
+ stepId: string | null;
5
+ hasError?: boolean;
6
+ errorRevision?: unknown;
7
+ preventScroll?: boolean;
8
+ onStepFocus?: () => void;
9
+ }
10
+
11
+ /** Consumers render the targets with tabIndex={-1} and own any scrolling layout. */
12
+ export function useWizardStepFocus({
13
+ stepId,
14
+ hasError = false,
15
+ errorRevision,
16
+ preventScroll = false,
17
+ onStepFocus,
18
+ }: UseWizardStepFocusOptions) {
19
+ const headingRef = useRef<HTMLHeadingElement>(null);
20
+ const errorRef = useRef<HTMLDivElement>(null);
21
+ const optionsRef = useRef({ preventScroll, onStepFocus });
22
+ useEffect(() => {
23
+ optionsRef.current = { preventScroll, onStepFocus };
24
+ }, [preventScroll, onStepFocus]);
25
+
26
+ useEffect(() => {
27
+ if (stepId === null || !headingRef.current) return;
28
+ headingRef.current.focus({
29
+ preventScroll: optionsRef.current.preventScroll,
30
+ });
31
+ optionsRef.current.onStepFocus?.();
32
+ }, [stepId]);
33
+
34
+ useEffect(() => {
35
+ if (hasError)
36
+ errorRef.current?.focus({
37
+ preventScroll: optionsRef.current.preventScroll,
38
+ });
39
+ }, [stepId, hasError, errorRevision]);
40
+
41
+ return { headingRef, errorRef };
42
+ }
@@ -6,142 +6,239 @@ import type {
6
6
  WizardStepConfig,
7
7
  } from './types';
8
8
 
9
- function resolveVisibleSteps<TState>(
10
- steps: ReadonlyArray<WizardStepConfig<TState>>,
11
- state: TState,
12
- ): WizardStepConfig<TState>[] {
13
- return steps.filter((step) => (step.isVisible ? step.isVisible(state) : true));
14
- }
15
-
16
- function toResolvedStep<TState>(step: WizardStepConfig<TState>): ResolvedWizardStep {
9
+ function toResolvedStep<TState>(
10
+ step: WizardStepConfig<TState>,
11
+ ): ResolvedWizardStep {
17
12
  return { id: step.id, label: step.label };
18
13
  }
19
14
 
20
15
  function pickInitialStepId<TState>(
21
- visibleSteps: WizardStepConfig<TState>[],
16
+ steps: WizardStepConfig<TState>[],
22
17
  preferredId: string | undefined,
23
18
  ): string | null {
24
- if (visibleSteps.length === 0) {
25
- return null;
26
- }
27
-
28
- if (preferredId && visibleSteps.some((step) => step.id === preferredId)) {
29
- return preferredId;
30
- }
31
-
32
- return visibleSteps[0].id;
19
+ return (
20
+ steps.find((step) => step.id === preferredId)?.id ?? steps[0]?.id ?? null
21
+ );
33
22
  }
34
23
 
35
- export function useWizardSteps<TState>(
36
- options: UseWizardStepsOptions<TState>,
37
- ): UseWizardStepsResult {
38
- const { steps, state, initialStepId, onStepChange } = options;
39
-
24
+ export function useWizardSteps<TState>({
25
+ steps,
26
+ state,
27
+ initialStepId,
28
+ onStepChange,
29
+ onComplete,
30
+ onInvalidStep,
31
+ advanceRequest,
32
+ }: UseWizardStepsOptions<TState>): UseWizardStepsResult {
40
33
  const visibleStepConfigs = useMemo(
41
- () => resolveVisibleSteps(steps, state),
34
+ () => steps.filter((step) => !step.isVisible || step.isVisible(state)),
42
35
  [steps, state],
43
36
  );
44
-
45
37
  const visibleSteps = useMemo(
46
38
  () => visibleStepConfigs.map(toResolvedStep),
47
39
  [visibleStepConfigs],
48
40
  );
49
-
50
- const initialResolvedId = useMemo(
51
- () => pickInitialStepId(visibleStepConfigs, initialStepId),
52
- // Only recompute when explicit initialStepId or the set of step ids changes.
53
- // eslint-disable-next-line react-hooks/exhaustive-deps
54
- [initialStepId],
41
+ const [currentStepId, setCurrentStepId] = useState(() =>
42
+ pickInitialStepId(visibleStepConfigs, initialStepId),
55
43
  );
56
-
57
- const [currentStepId, setCurrentStepId] = useState<string | null>(initialResolvedId);
58
-
59
- // If the visible set changes (e.g. a conditional step is hidden), keep the
60
- // currentStepId in sync. If the currently selected step is no longer visible,
61
- // fall back to the first visible step.
62
- useEffect(() => {
63
- if (visibleStepConfigs.length === 0) {
64
- if (currentStepId !== null) {
65
- setCurrentStepId(null);
44
+ const [visitedStepIds, setVisitedStepIds] = useState<string[]>(() =>
45
+ currentStepId === null ? [] : [currentStepId],
46
+ );
47
+ const [validationStepId, setValidationStepId] = useState<string | null>(null);
48
+ const [validationAttempt, setValidationAttempt] = useState(0);
49
+ const clearValidation = useCallback(() => setValidationStepId(null), []);
50
+
51
+ const navigate = useCallback(
52
+ (stepId: string | null) => {
53
+ setCurrentStepId(stepId);
54
+ if (stepId !== null) {
55
+ setVisitedStepIds((previous) =>
56
+ previous.includes(stepId) ? previous : [...previous, stepId],
57
+ );
66
58
  }
67
- return;
68
- }
59
+ clearValidation();
60
+ },
61
+ [clearValidation],
62
+ );
69
63
 
70
- const exists = visibleStepConfigs.some((step) => step.id === currentStepId);
71
- if (!exists) {
72
- setCurrentStepId(visibleStepConfigs[0].id);
64
+ useEffect(() => {
65
+ if (!visibleStepConfigs.some((step) => step.id === currentStepId)) {
66
+ navigate(visibleStepConfigs[0]?.id ?? null);
73
67
  }
74
- }, [visibleStepConfigs, currentStepId]);
68
+ }, [visibleStepConfigs, currentStepId, navigate]);
75
69
 
70
+ // Notify after a committed transition, never from a state updater that React
71
+ // may replay. Updating the callback alone must not announce another step.
76
72
  const onStepChangeRef = useRef(onStepChange);
77
73
  useEffect(() => {
78
74
  onStepChangeRef.current = onStepChange;
79
75
  }, [onStepChange]);
76
+ const previousStepId = useRef(currentStepId);
77
+ useEffect(() => {
78
+ if (previousStepId.current !== currentStepId) {
79
+ previousStepId.current = currentStepId;
80
+ if (currentStepId !== null) onStepChangeRef.current?.(currentStepId);
81
+ }
82
+ }, [currentStepId]);
80
83
 
81
- const setStepAndNotify = useCallback((stepId: string) => {
82
- setCurrentStepId((previous) => {
83
- if (previous === stepId) {
84
- return previous;
85
- }
86
- onStepChangeRef.current?.(stepId);
87
- return stepId;
88
- });
89
- }, []);
90
-
91
- const currentStepIndex = useMemo(
92
- () => visibleStepConfigs.findIndex((step) => step.id === currentStepId),
93
- [visibleStepConfigs, currentStepId],
84
+ const selectedStepIndex = visibleStepConfigs.findIndex(
85
+ (step) => step.id === currentStepId,
94
86
  );
95
-
96
- const currentStepConfig = currentStepIndex >= 0 ? visibleStepConfigs[currentStepIndex] : null;
97
- const currentStep = currentStepConfig ? toResolvedStep(currentStepConfig) : null;
98
-
87
+ // Expose the fallback during this render too: consumers may render the
88
+ // current question before the visibility effect commits its new ID.
89
+ const currentStepIndex =
90
+ selectedStepIndex >= 0
91
+ ? selectedStepIndex
92
+ : visibleStepConfigs.length > 0
93
+ ? 0
94
+ : -1;
95
+ const currentStepConfig = visibleStepConfigs[currentStepIndex] ?? null;
96
+ const currentStep = currentStepConfig
97
+ ? toResolvedStep(currentStepConfig)
98
+ : null;
99
99
  const totalSteps = visibleStepConfigs.length;
100
- const isFirstStep = currentStepIndex <= 0;
101
- const isLastStep = totalSteps === 0 ? true : currentStepIndex === totalSteps - 1;
102
-
100
+ const isLastStep = totalSteps === 0 || currentStepIndex === totalSteps - 1;
103
101
  const canAdvance = currentStepConfig?.isComplete
104
102
  ? currentStepConfig.isComplete(state)
105
103
  : true;
106
104
 
105
+ const invalid = useCallback(
106
+ (stepId: string) => {
107
+ navigate(stepId);
108
+ setValidationStepId(stepId);
109
+ setValidationAttempt((attempt) => attempt + 1);
110
+ onInvalidStep?.(stepId);
111
+ },
112
+ [navigate, onInvalidStep],
113
+ );
114
+
115
+ const validateAll = useCallback(() => {
116
+ const firstInvalid = visibleStepConfigs.find(
117
+ (step) => step.isComplete && !step.isComplete(state),
118
+ );
119
+ if (firstInvalid) {
120
+ invalid(firstInvalid.id);
121
+ return false;
122
+ }
123
+ clearValidation();
124
+ return true;
125
+ }, [visibleStepConfigs, state, invalid, clearValidation]);
126
+
107
127
  const goNext = useCallback(() => {
108
- if (currentStepIndex < 0 || currentStepIndex >= visibleStepConfigs.length - 1) {
128
+ if (!currentStepConfig || isLastStep) return;
129
+ if (!canAdvance) {
130
+ invalid(currentStepConfig.id);
109
131
  return;
110
132
  }
111
- setStepAndNotify(visibleStepConfigs[currentStepIndex + 1].id);
112
- }, [currentStepIndex, visibleStepConfigs, setStepAndNotify]);
133
+ navigate(visibleStepConfigs[currentStepIndex + 1].id);
134
+ }, [
135
+ currentStepConfig,
136
+ isLastStep,
137
+ canAdvance,
138
+ invalid,
139
+ navigate,
140
+ visibleStepConfigs,
141
+ currentStepIndex,
142
+ ]);
113
143
 
114
- const goBack = useCallback(() => {
115
- if (currentStepIndex <= 0) {
144
+ const advance = useCallback(() => {
145
+ if (!currentStepConfig) return;
146
+ if (!canAdvance) {
147
+ invalid(currentStepConfig.id);
116
148
  return;
117
149
  }
118
- setStepAndNotify(visibleStepConfigs[currentStepIndex - 1].id);
119
- }, [currentStepIndex, visibleStepConfigs, setStepAndNotify]);
150
+ if (isLastStep) {
151
+ if (validateAll()) onComplete?.();
152
+ } else {
153
+ goNext();
154
+ }
155
+ }, [
156
+ currentStepConfig,
157
+ canAdvance,
158
+ invalid,
159
+ isLastStep,
160
+ validateAll,
161
+ onComplete,
162
+ goNext,
163
+ ]);
164
+
165
+ // Selection and its state update arrive in the same committed render. Consume
166
+ // every request once, even when invalid or stale, so Back never replays it.
167
+ const consumedRequest =
168
+ useRef<UseWizardStepsOptions<TState>['advanceRequest']>(null);
169
+ useEffect(() => {
170
+ if (!advanceRequest || consumedRequest.current === advanceRequest) return;
171
+ consumedRequest.current = advanceRequest;
172
+ if (
173
+ currentStepConfig?.autoAdvance &&
174
+ advanceRequest.stepId === currentStepConfig.id
175
+ )
176
+ advance();
177
+ }, [advanceRequest, currentStepConfig, advance]);
178
+
179
+ const goBack = useCallback(() => {
180
+ clearValidation();
181
+ if (currentStepIndex > 0)
182
+ navigate(visibleStepConfigs[currentStepIndex - 1].id);
183
+ }, [clearValidation, currentStepIndex, navigate, visibleStepConfigs]);
120
184
 
121
185
  const goToStep = useCallback(
122
186
  (stepId: string) => {
123
- if (visibleStepConfigs.some((step) => step.id === stepId)) {
124
- setStepAndNotify(stepId);
125
- }
187
+ if (visibleStepConfigs.some((step) => step.id === stepId))
188
+ navigate(stepId);
126
189
  },
127
- [visibleStepConfigs, setStepAndNotify],
190
+ [visibleStepConfigs, navigate],
128
191
  );
129
192
 
130
193
  const reset = useCallback(() => {
131
- const fallback = pickInitialStepId(visibleStepConfigs, initialStepId);
132
- if (fallback) {
133
- setStepAndNotify(fallback);
134
- }
135
- }, [visibleStepConfigs, initialStepId, setStepAndNotify]);
194
+ const initial = pickInitialStepId(visibleStepConfigs, initialStepId);
195
+ navigate(initial);
196
+ setVisitedStepIds(initial === null ? [] : [initial]);
197
+ }, [visibleStepConfigs, initialStepId, navigate]);
198
+
199
+ const handleSubmit = useCallback<UseWizardStepsResult['handleSubmit']>(
200
+ (event) => {
201
+ event.preventDefault();
202
+ if (!currentStepConfig?.autoAdvance) advance();
203
+ },
204
+ [currentStepConfig, advance],
205
+ );
206
+
207
+ const handleKeyDown = useCallback<UseWizardStepsResult['handleKeyDown']>(
208
+ (event) => {
209
+ // Bubble after a combobox has handled selection. Native buttons retain Enter.
210
+ if (
211
+ currentStepConfig?.autoAdvance &&
212
+ event.key === 'Enter' &&
213
+ (event.target as HTMLElement).tagName === 'INPUT'
214
+ )
215
+ event.preventDefault();
216
+ },
217
+ [currentStepConfig],
218
+ );
219
+
220
+ const hasVisitedStep = useCallback(
221
+ (stepId: string) => visitedStepIds.includes(stepId),
222
+ [visitedStepIds],
223
+ );
136
224
 
137
225
  return {
138
226
  visibleSteps,
139
227
  currentStep,
140
228
  currentStepIndex,
141
229
  totalSteps,
142
- isFirstStep,
230
+ isFirstStep: currentStepIndex <= 0,
143
231
  isLastStep,
144
232
  canAdvance,
233
+ visitedStepIds,
234
+ hasVisitedStep,
235
+ validationStepId,
236
+ validationAttempt,
237
+ clearValidation,
238
+ validateAll,
239
+ advance,
240
+ handleSubmit,
241
+ handleKeyDown,
145
242
  goNext,
146
243
  goBack,
147
244
  goToStep,
package/src/styles.css CHANGED
@@ -157,6 +157,15 @@
157
157
  transition: border-color 0.15s ease;
158
158
  }
159
159
 
160
+ .pe-wizard-review-listitem {
161
+ min-width: 0;
162
+ }
163
+
164
+ .pe-wizard-review-listitem > .pe-wizard-review-item {
165
+ width: 100%;
166
+ height: 100%;
167
+ }
168
+
160
169
  .pe-wizard-review-item[role="listitem"]:not(button) {
161
170
  cursor: default;
162
171
  }