policyengine-household-wizard 0.1.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 (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +116 -0
  3. package/dist/WizardReviewList-De9RTK_4.js +245 -0
  4. package/dist/WizardReviewList-tfP9LcqU.cjs +1 -0
  5. package/dist/index.cjs +1 -0
  6. package/dist/index.d.ts +3 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +35 -0
  9. package/dist/primitives/WizardNavigation.d.ts +19 -0
  10. package/dist/primitives/WizardNavigation.d.ts.map +1 -0
  11. package/dist/primitives/WizardOptionCard.d.ts +9 -0
  12. package/dist/primitives/WizardOptionCard.d.ts.map +1 -0
  13. package/dist/primitives/WizardProgress.d.ts +8 -0
  14. package/dist/primitives/WizardProgress.d.ts.map +1 -0
  15. package/dist/primitives/WizardReviewList.d.ts +14 -0
  16. package/dist/primitives/WizardReviewList.d.ts.map +1 -0
  17. package/dist/primitives/index.d.ts +11 -0
  18. package/dist/primitives/index.d.ts.map +1 -0
  19. package/dist/primitives/types.d.ts +30 -0
  20. package/dist/primitives/types.d.ts.map +1 -0
  21. package/dist/primitives/useWizardSteps.d.ts +3 -0
  22. package/dist/primitives/useWizardSteps.d.ts.map +1 -0
  23. package/dist/primitives.cjs +1 -0
  24. package/dist/primitives.d.ts +1 -0
  25. package/dist/primitives.js +8 -0
  26. package/dist/us-household/adapters/index.d.ts +2 -0
  27. package/dist/us-household/adapters/index.d.ts.map +1 -0
  28. package/dist/us-household/adapters/v1Payload.d.ts +68 -0
  29. package/dist/us-household/adapters/v1Payload.d.ts.map +1 -0
  30. package/dist/us-household/counties.d.ts +25 -0
  31. package/dist/us-household/counties.d.ts.map +1 -0
  32. package/dist/us-household/draft.d.ts +28 -0
  33. package/dist/us-household/draft.d.ts.map +1 -0
  34. package/dist/us-household/index.d.ts +9 -0
  35. package/dist/us-household/index.d.ts.map +1 -0
  36. package/dist/us-household/normalize.d.ts +11 -0
  37. package/dist/us-household/normalize.d.ts.map +1 -0
  38. package/dist/us-household/serialize.d.ts +4 -0
  39. package/dist/us-household/serialize.d.ts.map +1 -0
  40. package/dist/us-household/states.d.ts +15 -0
  41. package/dist/us-household/states.d.ts.map +1 -0
  42. package/dist/us-household/types.d.ts +80 -0
  43. package/dist/us-household/types.d.ts.map +1 -0
  44. package/dist/us-household/validate.d.ts +13 -0
  45. package/dist/us-household/validate.d.ts.map +1 -0
  46. package/dist/us-household-adapters.cjs +1 -0
  47. package/dist/us-household-adapters.d.ts +1 -0
  48. package/dist/us-household-adapters.js +92 -0
  49. package/dist/us-household.cjs +1 -0
  50. package/dist/us-household.d.ts +1 -0
  51. package/dist/us-household.js +556 -0
  52. package/package.json +76 -0
  53. package/src/index.ts +2 -0
  54. package/src/primitives/WizardNavigation.tsx +85 -0
  55. package/src/primitives/WizardOptionCard.tsx +55 -0
  56. package/src/primitives/WizardProgress.tsx +50 -0
  57. package/src/primitives/WizardReviewList.tsx +73 -0
  58. package/src/primitives/index.ts +15 -0
  59. package/src/primitives/types.ts +32 -0
  60. package/src/primitives/useWizardSteps.ts +150 -0
  61. package/src/styles.css +183 -0
  62. package/src/us-household/adapters/index.ts +15 -0
  63. package/src/us-household/adapters/v1Payload.ts +213 -0
  64. package/src/us-household/counties.ts +96 -0
  65. package/src/us-household/data/counties-by-state.json +12802 -0
  66. package/src/us-household/draft.ts +130 -0
  67. package/src/us-household/index.ts +59 -0
  68. package/src/us-household/normalize.ts +251 -0
  69. package/src/us-household/serialize.ts +153 -0
  70. package/src/us-household/states.ts +168 -0
  71. package/src/us-household/types.ts +82 -0
  72. package/src/us-household/validate.ts +129 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 PolicyEngine
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,116 @@
1
+ # policyengine-household-wizard
2
+
3
+ Shared wizard primitives and a US household draft contract for PolicyEngine
4
+ apps (cliff-watch, Coverage Compass, app-v2, and standalone calculators).
5
+
6
+ The package ships two surfaces:
7
+
8
+ - **Wizard primitives** — copy-neutral React primitives for step state, progress,
9
+ navigation, option cards, and review screens. No household-specific code.
10
+ - **US household model** — a draft type that starts blank for state, age, and
11
+ marital status (issue #1044), validation rules, URL serialization,
12
+ state-filtered counties, and adapters to the PolicyEngine API V1 household
13
+ payload.
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ bun add policyengine-household-wizard
19
+ # or
20
+ npm install policyengine-household-wizard
21
+ ```
22
+
23
+ React 19 is a peer dependency.
24
+
25
+ If you want the default look, import the stylesheet once:
26
+
27
+ ```ts
28
+ import 'policyengine-household-wizard/styles.css';
29
+ ```
30
+
31
+ The CSS uses ui-kit CSS variables (`--primary`, `--border`, `--accent`, …) when
32
+ they're present, with safe fallbacks otherwise. Apps already on
33
+ `@policyengine/ui-kit` will inherit the teal theme automatically.
34
+
35
+ ## Quick start
36
+
37
+ ```tsx
38
+ import {
39
+ useWizardSteps,
40
+ WizardProgress,
41
+ WizardNavigation,
42
+ WizardOptionCard,
43
+ WizardReviewList,
44
+ createBlankDraft,
45
+ applyMaritalStatusChange,
46
+ validate,
47
+ toV1HouseholdPayload,
48
+ US_STATES,
49
+ getCountiesByState,
50
+ type USHouseholdDraft,
51
+ } from 'policyengine-household-wizard';
52
+
53
+ const steps = [
54
+ { id: 'location', label: 'Location', isComplete: (d: USHouseholdDraft) => !!d.state },
55
+ { id: 'marital', label: 'Marital status', isComplete: (d: USHouseholdDraft) => !!d.maritalStatus },
56
+ { id: 'review', label: 'Review' },
57
+ ];
58
+
59
+ function MyWizard() {
60
+ const [draft, setDraft] = useState(createBlankDraft());
61
+ const wizard = useWizardSteps({ steps, state: draft });
62
+
63
+ // ...render WizardProgress, step bodies, WizardNavigation
64
+ }
65
+ ```
66
+
67
+ See [`docs/api.md`](docs/api.md) for the full API and [`docs/migration.md`](docs/migration.md)
68
+ for migrating from each app's local wizard.
69
+
70
+ ## Design decisions
71
+
72
+ - **Marital status, not filing status.** The wizard asks users marital status
73
+ in plain English; apps derive filing status (single, head of household,
74
+ married filing jointly, …) in their own model adapters.
75
+ - **No defaults for state, age, or marital status.** `createBlankDraft()`
76
+ returns a draft with all three set to `null`/empty. The wizard explicitly
77
+ surfaces those fields rather than picking a quiet default like California or
78
+ age 30.
79
+ - **State-filtered counties.** Counties come from a bundled JSON generated
80
+ from PolicyEngine US metadata. Use `getCountiesByState('CA')` to get the
81
+ options for the chosen state. Refresh with `bun run regenerate-counties`.
82
+ - **Adapters, not a UI shell.** Apps render their own form layouts and pass
83
+ the draft through `validate()` and `toV1HouseholdPayload()` (or their own
84
+ app-specific adapter) at submit time.
85
+
86
+ ## Repository structure
87
+
88
+ ```
89
+ src/
90
+ primitives/ useWizardSteps, WizardProgress, WizardNavigation, …
91
+ us-household/ types, draft, validate, normalize, serialize, counties
92
+ adapters/ toV1HouseholdPayload — PolicyEngine API V1 envelope
93
+ data/ counties-by-state.json
94
+ tests/ vitest unit and round-trip tests
95
+ scripts/ generate-counties.ts
96
+ ```
97
+
98
+ ## Development
99
+
100
+ ```bash
101
+ bun install
102
+ bun run test
103
+ bun run typecheck
104
+ bun run build
105
+ ```
106
+
107
+ Changes follow the towncrier convention used by `@policyengine/ui-kit`. Add a
108
+ fragment in `changelog.d/` before opening a PR:
109
+
110
+ ```bash
111
+ echo "Describe your change." > changelog.d/your-branch.added.md
112
+ ```
113
+
114
+ Fragment types: `added` (minor), `changed` (patch), `fixed` (patch),
115
+ `removed` (minor), `breaking` (major). The release workflow on `main` bumps
116
+ the version, builds the changelog, publishes to npm, and commits the bump.
@@ -0,0 +1,245 @@
1
+ import { useMemo as N, useState as P, useEffect as W, useRef as R, useCallback as b } from "react";
2
+ import { jsxs as m, jsx as l, Fragment as V } from "react/jsx-runtime";
3
+ function C(r, s) {
4
+ return r.filter((a) => a.isVisible ? a.isVisible(s) : !0);
5
+ }
6
+ function S(r) {
7
+ return { id: r.id, label: r.label };
8
+ }
9
+ function B(r, s) {
10
+ return r.length === 0 ? null : s && r.some((a) => a.id === s) ? s : r[0].id;
11
+ }
12
+ function D(r) {
13
+ const { steps: s, state: a, initialStepId: i, onStepChange: t } = r, e = N(
14
+ () => C(s, a),
15
+ [s, a]
16
+ ), o = N(
17
+ () => e.map(S),
18
+ [e]
19
+ ), u = N(
20
+ () => B(e, i),
21
+ // Only recompute when explicit initialStepId or the set of step ids changes.
22
+ // eslint-disable-next-line react-hooks/exhaustive-deps
23
+ [i]
24
+ ), [c, d] = P(u);
25
+ W(() => {
26
+ if (e.length === 0) {
27
+ c !== null && d(null);
28
+ return;
29
+ }
30
+ e.some((w) => w.id === c) || d(e[0].id);
31
+ }, [e, c]);
32
+ const f = R(t);
33
+ W(() => {
34
+ f.current = t;
35
+ }, [t]);
36
+ const v = b((p) => {
37
+ d((w) => {
38
+ var k;
39
+ return w === p ? w : ((k = f.current) == null || k.call(f, p), p);
40
+ });
41
+ }, []), n = N(
42
+ () => e.findIndex((p) => p.id === c),
43
+ [e, c]
44
+ ), h = n >= 0 ? e[n] : null, x = h ? S(h) : null, z = e.length, g = n <= 0, y = z === 0 ? !0 : n === z - 1, j = h != null && h.isComplete ? h.isComplete(a) : !0, M = b(() => {
45
+ n < 0 || n >= e.length - 1 || v(e[n + 1].id);
46
+ }, [n, e, v]), $ = b(() => {
47
+ n <= 0 || v(e[n - 1].id);
48
+ }, [n, e, v]), E = b(
49
+ (p) => {
50
+ e.some((w) => w.id === p) && v(p);
51
+ },
52
+ [e, v]
53
+ ), I = b(() => {
54
+ const p = B(e, i);
55
+ p && v(p);
56
+ }, [e, i, v]);
57
+ return {
58
+ visibleSteps: o,
59
+ currentStep: x,
60
+ currentStepIndex: n,
61
+ totalSteps: z,
62
+ isFirstStep: g,
63
+ isLastStep: y,
64
+ canAdvance: j,
65
+ goNext: M,
66
+ goBack: $,
67
+ goToStep: E,
68
+ reset: I
69
+ };
70
+ }
71
+ function O({
72
+ totalSteps: r,
73
+ currentStepIndex: s,
74
+ currentStepLabel: a,
75
+ className: i,
76
+ ...t
77
+ }) {
78
+ const e = Math.max(r, 0), o = Math.max(0, Math.min(s, e - 1)), u = e > 0 ? (o + 1) / e * 100 : 0, c = e > 0 ? o + 1 : 0, d = { width: `${u}%` };
79
+ return /* @__PURE__ */ m(
80
+ "div",
81
+ {
82
+ role: "group",
83
+ "aria-label": t["aria-label"] ?? "Wizard progress",
84
+ className: ["pe-wizard-progress", i].filter(Boolean).join(" "),
85
+ ...t,
86
+ children: [
87
+ /* @__PURE__ */ m("div", { className: "pe-wizard-progress-topline", children: [
88
+ /* @__PURE__ */ m("span", { "data-testid": "pe-wizard-progress-step", children: [
89
+ "Step ",
90
+ c,
91
+ " of ",
92
+ e
93
+ ] }),
94
+ a ? /* @__PURE__ */ l("span", { "data-testid": "pe-wizard-progress-label", children: a }) : null
95
+ ] }),
96
+ /* @__PURE__ */ l(
97
+ "div",
98
+ {
99
+ className: "pe-wizard-progress-track",
100
+ role: "progressbar",
101
+ "aria-valuemin": 0,
102
+ "aria-valuemax": e,
103
+ "aria-valuenow": c,
104
+ "aria-valuetext": a,
105
+ children: /* @__PURE__ */ l("div", { className: "pe-wizard-progress-bar", style: d })
106
+ }
107
+ )
108
+ ]
109
+ }
110
+ );
111
+ }
112
+ function q({
113
+ selected: r = !1,
114
+ title: s,
115
+ description: a,
116
+ onSelect: i,
117
+ onClick: t,
118
+ className: e,
119
+ type: o,
120
+ disabled: u,
121
+ ...c
122
+ }) {
123
+ const d = ["pe-wizard-option-card"];
124
+ return r && d.push("pe-wizard-option-card--selected"), e && d.push(e), /* @__PURE__ */ m(
125
+ "button",
126
+ {
127
+ type: o ?? "button",
128
+ role: "radio",
129
+ "aria-checked": r,
130
+ "aria-disabled": u ? !0 : void 0,
131
+ disabled: u,
132
+ className: d.join(" "),
133
+ onClick: (f) => {
134
+ u || (t == null || t(f), f.defaultPrevented || i == null || i());
135
+ },
136
+ ...c,
137
+ children: [
138
+ /* @__PURE__ */ l("span", { className: "pe-wizard-option-card-title", children: s }),
139
+ a ? /* @__PURE__ */ l("span", { className: "pe-wizard-option-card-description", children: a }) : null
140
+ ]
141
+ }
142
+ );
143
+ }
144
+ function A({
145
+ canAdvance: r,
146
+ isFirstStep: s,
147
+ isLastStep: a,
148
+ backLabel: i = "Back",
149
+ continueLabel: t = "Continue",
150
+ submitLabel: e = "Submit",
151
+ busyLabel: o,
152
+ busy: u = !1,
153
+ onBack: c,
154
+ onContinue: d,
155
+ onSubmit: f,
156
+ leadingActions: v,
157
+ trailingActions: n,
158
+ hideBack: h = !1,
159
+ className: x,
160
+ ...z
161
+ }) {
162
+ const g = u || !r, y = u && o ? o : a ? e : t, j = () => {
163
+ g || (a ? f == null || f() : d == null || d());
164
+ };
165
+ return /* @__PURE__ */ m(
166
+ "div",
167
+ {
168
+ className: ["pe-wizard-nav", x].filter(Boolean).join(" "),
169
+ ...z,
170
+ children: [
171
+ v ? /* @__PURE__ */ l("div", { className: "pe-wizard-nav-leading", children: v }) : null,
172
+ h ? null : /* @__PURE__ */ l(
173
+ "button",
174
+ {
175
+ type: "button",
176
+ className: "pe-wizard-nav-back",
177
+ onClick: c,
178
+ disabled: s || u,
179
+ "aria-label": typeof i == "string" ? i : void 0,
180
+ children: i
181
+ }
182
+ ),
183
+ /* @__PURE__ */ l(
184
+ "button",
185
+ {
186
+ type: "button",
187
+ className: "pe-wizard-nav-primary",
188
+ onClick: j,
189
+ disabled: g,
190
+ "aria-disabled": g,
191
+ children: y
192
+ }
193
+ ),
194
+ n ? /* @__PURE__ */ l("div", { className: "pe-wizard-nav-trailing", children: n }) : null
195
+ ]
196
+ }
197
+ );
198
+ }
199
+ function G({ items: r, className: s, ...a }) {
200
+ return /* @__PURE__ */ l(
201
+ "div",
202
+ {
203
+ className: ["pe-wizard-review-list", s].filter(Boolean).join(" "),
204
+ role: "list",
205
+ ...a,
206
+ children: r.map((i) => {
207
+ const t = ["pe-wizard-review-item"];
208
+ i.missing && t.push("pe-wizard-review-item--missing");
209
+ const e = typeof i.onEdit == "function", o = /* @__PURE__ */ m(V, { children: [
210
+ /* @__PURE__ */ l("span", { className: "pe-wizard-review-item-label", children: i.label }),
211
+ /* @__PURE__ */ l("span", { className: "pe-wizard-review-item-value", children: i.missing && (i.value === null || i.value === void 0 || i.value === "") ? "Missing" : i.value })
212
+ ] });
213
+ return e ? /* @__PURE__ */ l(
214
+ "button",
215
+ {
216
+ type: "button",
217
+ role: "listitem",
218
+ className: t.join(" "),
219
+ "data-testid": `pe-wizard-review-${i.id}`,
220
+ onClick: i.onEdit,
221
+ "aria-label": typeof i.label == "string" ? `${i.editLabel ?? "Edit"} ${i.label}` : void 0,
222
+ children: o
223
+ },
224
+ i.id
225
+ ) : /* @__PURE__ */ l(
226
+ "div",
227
+ {
228
+ role: "listitem",
229
+ className: t.join(" "),
230
+ "data-testid": `pe-wizard-review-${i.id}`,
231
+ children: o
232
+ },
233
+ i.id
234
+ );
235
+ })
236
+ }
237
+ );
238
+ }
239
+ export {
240
+ A as W,
241
+ q as a,
242
+ O as b,
243
+ G as c,
244
+ D as u
245
+ };
@@ -0,0 +1 @@
1
+ "use strict";const o=require("react"),s=require("react/jsx-runtime");function B(r,t){return r.filter(a=>a.isVisible?a.isVisible(t):!0)}function k(r){return{id:r.id,label:r.label}}function y(r,t){return r.length===0?null:t&&r.some(a=>a.id===t)?t:r[0].id}function E(r){const{steps:t,state:a,initialStepId:i,onStepChange:n}=r,e=o.useMemo(()=>B(t,a),[t,a]),c=o.useMemo(()=>e.map(k),[e]),f=o.useMemo(()=>y(e,i),[i]),[u,d]=o.useState(f);o.useEffect(()=>{if(e.length===0){u!==null&&d(null);return}e.some(h=>h.id===u)||d(e[0].id)},[e,u]);const v=o.useRef(n);o.useEffect(()=>{v.current=n},[n]);const w=o.useCallback(p=>{d(h=>{var N;return h===p?h:((N=v.current)==null||N.call(v,p),p)})},[]),l=o.useMemo(()=>e.findIndex(p=>p.id===u),[e,u]),z=l>=0?e[l]:null,g=z?k(z):null,m=e.length,x=l<=0,j=m===0?!0:l===m-1,b=z!=null&&z.isComplete?z.isComplete(a):!0,W=o.useCallback(()=>{l<0||l>=e.length-1||w(e[l+1].id)},[l,e,w]),M=o.useCallback(()=>{l<=0||w(e[l-1].id)},[l,e,w]),C=o.useCallback(p=>{e.some(h=>h.id===p)&&w(p)},[e,w]),S=o.useCallback(()=>{const p=y(e,i);p&&w(p)},[e,i,w]);return{visibleSteps:c,currentStep:g,currentStepIndex:l,totalSteps:m,isFirstStep:x,isLastStep:j,canAdvance:b,goNext:W,goBack:M,goToStep:C,reset:S}}function R({totalSteps:r,currentStepIndex:t,currentStepLabel:a,className:i,...n}){const e=Math.max(r,0),c=Math.max(0,Math.min(t,e-1)),f=e>0?(c+1)/e*100:0,u=e>0?c+1:0,d={width:`${f}%`};return s.jsxs("div",{role:"group","aria-label":n["aria-label"]??"Wizard progress",className:["pe-wizard-progress",i].filter(Boolean).join(" "),...n,children:[s.jsxs("div",{className:"pe-wizard-progress-topline",children:[s.jsxs("span",{"data-testid":"pe-wizard-progress-step",children:["Step ",u," of ",e]}),a?s.jsx("span",{"data-testid":"pe-wizard-progress-label",children:a}):null]}),s.jsx("div",{className:"pe-wizard-progress-track",role:"progressbar","aria-valuemin":0,"aria-valuemax":e,"aria-valuenow":u,"aria-valuetext":a,children:s.jsx("div",{className:"pe-wizard-progress-bar",style:d})})]})}function $({selected:r=!1,title:t,description:a,onSelect:i,onClick:n,className:e,type:c,disabled:f,...u}){const d=["pe-wizard-option-card"];return r&&d.push("pe-wizard-option-card--selected"),e&&d.push(e),s.jsxs("button",{type:c??"button",role:"radio","aria-checked":r,"aria-disabled":f?!0:void 0,disabled:f,className:d.join(" "),onClick:v=>{f||(n==null||n(v),v.defaultPrevented||i==null||i())},...u,children:[s.jsx("span",{className:"pe-wizard-option-card-title",children:t}),a?s.jsx("span",{className:"pe-wizard-option-card-description",children:a}):null]})}function I({canAdvance:r,isFirstStep:t,isLastStep:a,backLabel:i="Back",continueLabel:n="Continue",submitLabel:e="Submit",busyLabel:c,busy:f=!1,onBack:u,onContinue:d,onSubmit:v,leadingActions:w,trailingActions:l,hideBack:z=!1,className:g,...m}){const x=f||!r,j=f&&c?c:a?e:n,b=()=>{x||(a?v==null||v():d==null||d())};return s.jsxs("div",{className:["pe-wizard-nav",g].filter(Boolean).join(" "),...m,children:[w?s.jsx("div",{className:"pe-wizard-nav-leading",children:w}):null,z?null:s.jsx("button",{type:"button",className:"pe-wizard-nav-back",onClick:u,disabled:t||f,"aria-label":typeof i=="string"?i:void 0,children:i}),s.jsx("button",{type:"button",className:"pe-wizard-nav-primary",onClick:b,disabled:x,"aria-disabled":x,children:j}),l?s.jsx("div",{className:"pe-wizard-nav-trailing",children:l}):null]})}function P({items:r,className:t,...a}){return s.jsx("div",{className:["pe-wizard-review-list",t].filter(Boolean).join(" "),role:"list",...a,children:r.map(i=>{const n=["pe-wizard-review-item"];i.missing&&n.push("pe-wizard-review-item--missing");const e=typeof i.onEdit=="function",c=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"pe-wizard-review-item-label",children:i.label}),s.jsx("span",{className:"pe-wizard-review-item-value",children:i.missing&&(i.value===null||i.value===void 0||i.value==="")?"Missing":i.value})]});return e?s.jsx("button",{type:"button",role:"listitem",className:n.join(" "),"data-testid":`pe-wizard-review-${i.id}`,onClick:i.onEdit,"aria-label":typeof i.label=="string"?`${i.editLabel??"Edit"} ${i.label}`:void 0,children:c},i.id):s.jsx("div",{role:"listitem",className:n.join(" "),"data-testid":`pe-wizard-review-${i.id}`,children:c},i.id)})})}exports.WizardNavigation=I;exports.WizardOptionCard=$;exports.WizardProgress=R;exports.WizardReviewList=P;exports.useWizardSteps=E;
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./WizardReviewList-tfP9LcqU.cjs"),e=require("./us-household.cjs"),a=require("./us-household-adapters.cjs");exports.WizardNavigation=t.WizardNavigation;exports.WizardOptionCard=t.WizardOptionCard;exports.WizardProgress=t.WizardProgress;exports.WizardReviewList=t.WizardReviewList;exports.useWizardSteps=t.useWizardSteps;exports.DEFAULT_HOUSEHOLD_YEAR=e.DEFAULT_HOUSEHOLD_YEAR;exports.US_STATES=e.US_STATES;exports.addPerson=e.addPerson;exports.applyMaritalStatusChange=e.applyMaritalStatusChange;exports.cloneDraft=e.cloneDraft;exports.createBlankDraft=e.createBlankDraft;exports.createPerson=e.createPerson;exports.deserializeDraft=e.deserializeDraft;exports.getAdults=e.getAdults;exports.getCountiesByState=e.getCountiesByState;exports.getCountyName=e.getCountyName;exports.getDependents=e.getDependents;exports.getStateFromZip=e.getStateFromZip;exports.getStateName=e.getStateName;exports.isComplete=e.isComplete;exports.isCountyCode=e.isCountyCode;exports.isUSStateCode=e.isUSStateCode;exports.normalizeLegacyDraft=e.normalizeLegacyDraft;exports.removePerson=e.removePerson;exports.resolveCountyCode=e.resolveCountyCode;exports.serializeDraft=e.serializeDraft;exports.updatePerson=e.updatePerson;exports.validate=e.validate;exports.toV1HouseholdPayload=a.toV1HouseholdPayload;exports.toV1HouseholdSituation=a.toV1HouseholdSituation;
@@ -0,0 +1,3 @@
1
+ export * from './primitives';
2
+ export * from './us-household';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,35 @@
1
+ import { W as t, a as o, b as r, c as s, u as i } from "./WizardReviewList-De9RTK_4.js";
2
+ import { DEFAULT_HOUSEHOLD_YEAR as n, US_STATES as l, addPerson as u, applyMaritalStatusChange as S, cloneDraft as p, createBlankDraft as g, createPerson as C, deserializeDraft as m, getAdults as f, getCountiesByState as z, getCountyName as D, getDependents as y, getStateFromZip as P, getStateName as W, isComplete as c, isCountyCode as v, isUSStateCode as A, normalizeLegacyDraft as E, removePerson as H, resolveCountyCode as L, serializeDraft as U, updatePerson as h, validate as x } from "./us-household.js";
3
+ import { toV1HouseholdPayload as O, toV1HouseholdSituation as T } from "./us-household-adapters.js";
4
+ export {
5
+ n as DEFAULT_HOUSEHOLD_YEAR,
6
+ l as US_STATES,
7
+ t as WizardNavigation,
8
+ o as WizardOptionCard,
9
+ r as WizardProgress,
10
+ s as WizardReviewList,
11
+ u as addPerson,
12
+ S as applyMaritalStatusChange,
13
+ p as cloneDraft,
14
+ g as createBlankDraft,
15
+ C as createPerson,
16
+ m as deserializeDraft,
17
+ f as getAdults,
18
+ z as getCountiesByState,
19
+ D as getCountyName,
20
+ y as getDependents,
21
+ P as getStateFromZip,
22
+ W as getStateName,
23
+ c as isComplete,
24
+ v as isCountyCode,
25
+ A as isUSStateCode,
26
+ E as normalizeLegacyDraft,
27
+ H as removePerson,
28
+ L as resolveCountyCode,
29
+ U as serializeDraft,
30
+ O as toV1HouseholdPayload,
31
+ T as toV1HouseholdSituation,
32
+ h as updatePerson,
33
+ i as useWizardSteps,
34
+ x as validate
35
+ };
@@ -0,0 +1,19 @@
1
+ import type { HTMLAttributes, ReactNode } from 'react';
2
+ export interface WizardNavigationProps extends HTMLAttributes<HTMLDivElement> {
3
+ canAdvance: boolean;
4
+ isFirstStep: boolean;
5
+ isLastStep: boolean;
6
+ backLabel?: ReactNode;
7
+ continueLabel?: ReactNode;
8
+ submitLabel?: ReactNode;
9
+ busyLabel?: ReactNode;
10
+ busy?: boolean;
11
+ onBack?: () => void;
12
+ onContinue?: () => void;
13
+ onSubmit?: () => void;
14
+ leadingActions?: ReactNode;
15
+ trailingActions?: ReactNode;
16
+ hideBack?: boolean;
17
+ }
18
+ export declare function WizardNavigation({ canAdvance, isFirstStep, isLastStep, backLabel, continueLabel, submitLabel, busyLabel, busy, onBack, onContinue, onSubmit, leadingActions, trailingActions, hideBack, className, ...rest }: WizardNavigationProps): import("react/jsx-runtime").JSX.Element;
19
+ //# sourceMappingURL=WizardNavigation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WizardNavigation.d.ts","sourceRoot":"","sources":["../../src/primitives/WizardNavigation.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,MAAM,WAAW,qBAAsB,SAAQ,cAAc,CAAC,cAAc,CAAC;IAC3E,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,UAAU,EACV,WAAW,EACX,UAAU,EACV,SAAkB,EAClB,aAA0B,EAC1B,WAAsB,EACtB,SAAS,EACT,IAAY,EACZ,MAAM,EACN,UAAU,EACV,QAAQ,EACR,cAAc,EACd,eAAe,EACf,QAAgB,EAChB,SAAS,EACT,GAAG,IAAI,EACR,EAAE,qBAAqB,2CAgDvB"}
@@ -0,0 +1,9 @@
1
+ import type { ButtonHTMLAttributes, ReactNode } from 'react';
2
+ export interface WizardOptionCardProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'title' | 'onSelect'> {
3
+ selected?: boolean;
4
+ title: ReactNode;
5
+ description?: ReactNode;
6
+ onSelect?: () => void;
7
+ }
8
+ export declare function WizardOptionCard({ selected, title, description, onSelect, onClick, className, type, disabled, ...rest }: WizardOptionCardProps): import("react/jsx-runtime").JSX.Element;
9
+ //# sourceMappingURL=WizardOptionCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WizardOptionCard.d.ts","sourceRoot":"","sources":["../../src/primitives/WizardOptionCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7D,MAAM,WAAW,qBACf,SAAQ,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAC3E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,QAAgB,EAChB,KAAK,EACL,WAAW,EACX,QAAQ,EACR,OAAO,EACP,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,qBAAqB,2CAkCvB"}
@@ -0,0 +1,8 @@
1
+ import type { HTMLAttributes } from 'react';
2
+ export interface WizardProgressProps extends HTMLAttributes<HTMLDivElement> {
3
+ totalSteps: number;
4
+ currentStepIndex: number;
5
+ currentStepLabel?: string;
6
+ }
7
+ export declare function WizardProgress({ totalSteps, currentStepIndex, currentStepLabel, className, ...rest }: WizardProgressProps): import("react/jsx-runtime").JSX.Element;
8
+ //# sourceMappingURL=WizardProgress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WizardProgress.d.ts","sourceRoot":"","sources":["../../src/primitives/WizardProgress.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,OAAO,CAAC;AAE3D,MAAM,WAAW,mBAAoB,SAAQ,cAAc,CAAC,cAAc,CAAC;IACzE,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,cAAc,CAAC,EAC7B,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,EACT,GAAG,IAAI,EACR,EAAE,mBAAmB,2CAmCrB"}
@@ -0,0 +1,14 @@
1
+ import type { HTMLAttributes, ReactNode } from 'react';
2
+ export interface WizardReviewItem {
3
+ id: string;
4
+ label: ReactNode;
5
+ value: ReactNode;
6
+ missing?: boolean;
7
+ onEdit?: () => void;
8
+ editLabel?: ReactNode;
9
+ }
10
+ export interface WizardReviewListProps extends HTMLAttributes<HTMLDivElement> {
11
+ items: WizardReviewItem[];
12
+ }
13
+ export declare function WizardReviewList({ items, className, ...rest }: WizardReviewListProps): import("react/jsx-runtime").JSX.Element;
14
+ //# sourceMappingURL=WizardReviewList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WizardReviewList.d.ts","sourceRoot":"","sources":["../../src/primitives/WizardReviewList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED,MAAM,WAAW,qBAAsB,SAAQ,cAAc,CAAC,cAAc,CAAC;IAC3E,KAAK,EAAE,gBAAgB,EAAE,CAAC;CAC3B;AAED,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,qBAAqB,2CAyDpF"}
@@ -0,0 +1,11 @@
1
+ export { useWizardSteps } from './useWizardSteps';
2
+ export { WizardProgress } from './WizardProgress';
3
+ export type { WizardProgressProps } from './WizardProgress';
4
+ export { WizardOptionCard } from './WizardOptionCard';
5
+ export type { WizardOptionCardProps } from './WizardOptionCard';
6
+ export { WizardNavigation } from './WizardNavigation';
7
+ export type { WizardNavigationProps } from './WizardNavigation';
8
+ export { WizardReviewList } from './WizardReviewList';
9
+ export type { WizardReviewItem, WizardReviewListProps } from './WizardReviewList';
10
+ export type { ResolvedWizardStep, UseWizardStepsOptions, UseWizardStepsResult, WizardStepConfig, } from './types';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/primitives/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAClF,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,30 @@
1
+ export interface WizardStepConfig<TState> {
2
+ id: string;
3
+ label: string;
4
+ isComplete?: (state: TState) => boolean;
5
+ isVisible?: (state: TState) => boolean;
6
+ }
7
+ export interface ResolvedWizardStep {
8
+ id: string;
9
+ label: string;
10
+ }
11
+ export interface UseWizardStepsOptions<TState> {
12
+ steps: ReadonlyArray<WizardStepConfig<TState>>;
13
+ state: TState;
14
+ initialStepId?: string;
15
+ onStepChange?: (stepId: string) => void;
16
+ }
17
+ export interface UseWizardStepsResult {
18
+ visibleSteps: ResolvedWizardStep[];
19
+ currentStep: ResolvedWizardStep | null;
20
+ currentStepIndex: number;
21
+ totalSteps: number;
22
+ isFirstStep: boolean;
23
+ isLastStep: boolean;
24
+ canAdvance: boolean;
25
+ goNext: () => void;
26
+ goBack: () => void;
27
+ goToStep: (stepId: string) => void;
28
+ reset: () => void;
29
+ }
30
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/primitives/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB,CAAC,MAAM;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACxC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;CACxC;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,qBAAqB,CAAC,MAAM;IAC3C,KAAK,EAAE,aAAa,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,kBAAkB,EAAE,CAAC;IACnC,WAAW,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACvC,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB"}
@@ -0,0 +1,3 @@
1
+ import type { UseWizardStepsOptions, UseWizardStepsResult } from './types';
2
+ export declare function useWizardSteps<TState>(options: UseWizardStepsOptions<TState>): UseWizardStepsResult;
3
+ //# sourceMappingURL=useWizardSteps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWizardSteps.d.ts","sourceRoot":"","sources":["../../src/primitives/useWizardSteps.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,qBAAqB,EACrB,oBAAoB,EAErB,MAAM,SAAS,CAAC;AA4BjB,wBAAgB,cAAc,CAAC,MAAM,EACnC,OAAO,EAAE,qBAAqB,CAAC,MAAM,CAAC,GACrC,oBAAoB,CAiHtB"}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./WizardReviewList-tfP9LcqU.cjs");exports.WizardNavigation=i.WizardNavigation;exports.WizardOptionCard=i.WizardOptionCard;exports.WizardProgress=i.WizardProgress;exports.WizardReviewList=i.WizardReviewList;exports.useWizardSteps=i.useWizardSteps;
@@ -0,0 +1 @@
1
+ export * from './primitives/index';
@@ -0,0 +1,8 @@
1
+ import { W as r, a as s, b as d, c as e, u as W } from "./WizardReviewList-De9RTK_4.js";
2
+ export {
3
+ r as WizardNavigation,
4
+ s as WizardOptionCard,
5
+ d as WizardProgress,
6
+ e as WizardReviewList,
7
+ W as useWizardSteps
8
+ };
@@ -0,0 +1,2 @@
1
+ export { toV1HouseholdPayload, toV1HouseholdSituation, type V1EntityCollection, type V1EntityRecord, type V1FieldValue, type V1GroupCollection, type V1GroupRecord, type V1HouseholdEnvelope, type V1HouseholdSituation, type V1PersonCollection, type V1PersonRecord, type V1ValueMap, type ToV1PayloadOptions, } from './v1Payload';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/us-household/adapters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC"}