policyengine-household-wizard 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -5
- package/dist/WizardReviewList-DhLx8Bla.cjs +1 -0
- package/dist/WizardReviewList-oY1HqmLw.js +354 -0
- package/dist/index-B_OXaS4a.cjs +1 -0
- package/dist/index-CIL8FXNR.cjs +1 -0
- package/dist/index-DWM0giHt.js +220 -0
- package/dist/index-fgLnXugs.js +225 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +34 -28
- package/dist/primitives/WizardReviewList.d.ts +3 -2
- package/dist/primitives/WizardReviewList.d.ts.map +1 -1
- package/dist/primitives/index.d.ts +12 -10
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/types.d.ts +18 -0
- package/dist/primitives/types.d.ts.map +1 -1
- package/dist/primitives/useWizardStepFocus.d.ts +13 -0
- package/dist/primitives/useWizardStepFocus.d.ts.map +1 -0
- package/dist/primitives/useWizardSteps.d.ts +2 -2
- package/dist/primitives/useWizardSteps.d.ts.map +1 -1
- package/dist/primitives.cjs +1 -1
- package/dist/primitives.d.ts +1 -1
- package/dist/primitives.js +5 -4
- package/dist/uk-household/adapters/householdImpactRequest.d.ts +91 -0
- package/dist/uk-household/adapters/householdImpactRequest.d.ts.map +1 -0
- package/dist/uk-household/adapters/index.d.ts +2 -0
- package/dist/uk-household/adapters/index.d.ts.map +1 -0
- package/dist/uk-household/children.d.ts +18 -0
- package/dist/uk-household/children.d.ts.map +1 -0
- package/dist/uk-household/codes.d.ts +22 -0
- package/dist/uk-household/codes.d.ts.map +1 -0
- package/dist/uk-household/defaults.d.ts +56 -0
- package/dist/uk-household/defaults.d.ts.map +1 -0
- package/dist/uk-household/draft.d.ts +37 -0
- package/dist/uk-household/draft.d.ts.map +1 -0
- package/dist/uk-household/index.d.ts +10 -0
- package/dist/uk-household/index.d.ts.map +1 -0
- package/dist/uk-household/serialize.d.ts +4 -0
- package/dist/uk-household/serialize.d.ts.map +1 -0
- package/dist/uk-household/statePension.d.ts +42 -0
- package/dist/uk-household/statePension.d.ts.map +1 -0
- package/dist/uk-household/types.d.ts +134 -0
- package/dist/uk-household/types.d.ts.map +1 -0
- package/dist/uk-household/validate.d.ts +59 -0
- package/dist/uk-household/validate.d.ts.map +1 -0
- package/dist/uk-household-adapters.cjs +1 -0
- package/dist/uk-household-adapters.d.ts +1 -0
- package/dist/uk-household-adapters.js +5 -0
- package/dist/uk-household.cjs +1 -0
- package/dist/uk-household.d.ts +1 -0
- package/dist/uk-household.js +220 -0
- package/dist/us-household/adapters/index.d.ts +1 -1
- package/dist/us-household/adapters/v1Payload.d.ts +119 -3
- package/dist/us-household/adapters/v1Payload.d.ts.map +1 -1
- package/dist/us-household/amount.d.ts +8 -0
- package/dist/us-household/amount.d.ts.map +1 -0
- package/dist/us-household/draft.d.ts +1 -1
- package/dist/us-household/index.d.ts +9 -8
- package/dist/us-household/index.d.ts.map +1 -1
- package/dist/us-household/normalize.d.ts +1 -1
- package/dist/us-household/normalize.d.ts.map +1 -1
- package/dist/us-household/serialize.d.ts +1 -1
- package/dist/us-household/serialize.d.ts.map +1 -1
- package/dist/us-household/tippedOccupations.d.ts +40 -0
- package/dist/us-household/tippedOccupations.d.ts.map +1 -0
- package/dist/us-household/types.d.ts +138 -18
- package/dist/us-household/types.d.ts.map +1 -1
- package/dist/us-household/validate.d.ts +1 -1
- package/dist/us-household/validate.d.ts.map +1 -1
- package/dist/us-household-adapters.cjs +1 -1
- package/dist/us-household-adapters.d.ts +1 -1
- package/dist/us-household-adapters.js +3 -90
- package/dist/us-household.cjs +1 -1
- package/dist/us-household.d.ts +1 -1
- package/dist/us-household.js +346 -246
- package/dist/validation.d.ts +16 -0
- package/dist/validation.d.ts.map +1 -0
- package/package.json +16 -2
- package/src/primitives/WizardReviewList.tsx +35 -18
- package/src/primitives/index.ts +3 -0
- package/src/primitives/types.ts +20 -0
- package/src/primitives/useWizardStepFocus.ts +42 -0
- package/src/primitives/useWizardSteps.ts +181 -84
- package/src/styles.css +9 -0
- package/src/uk-household/adapters/householdImpactRequest.ts +164 -0
- package/src/uk-household/adapters/index.ts +9 -0
- package/src/uk-household/children.ts +23 -0
- package/src/uk-household/codes.ts +67 -0
- package/src/uk-household/defaults.ts +101 -0
- package/src/uk-household/draft.ts +138 -0
- package/src/uk-household/index.ts +75 -0
- package/src/uk-household/serialize.ts +189 -0
- package/src/uk-household/statePension.ts +69 -0
- package/src/uk-household/types.ts +159 -0
- package/src/uk-household/validate.ts +190 -0
- package/src/us-household/adapters/v1Payload.ts +211 -18
- package/src/us-household/amount.ts +10 -0
- package/src/us-household/index.ts +11 -0
- package/src/us-household/normalize.ts +79 -4
- package/src/us-household/serialize.ts +5 -1
- package/src/us-household/tippedOccupations.ts +145 -0
- package/src/us-household/types.ts +144 -15
- package/src/us-household/validate.ts +101 -4
- package/src/validation.ts +12 -0
- package/dist/WizardReviewList-De9RTK_4.js +0 -245
- package/dist/WizardReviewList-tfP9LcqU.cjs +0 -1
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
const V = 0, O = {
|
|
2
|
+
1: "Beverage and food service",
|
|
3
|
+
2: "Entertainment and events",
|
|
4
|
+
3: "Hospitality and guest services",
|
|
5
|
+
4: "Home services",
|
|
6
|
+
5: "Personal services",
|
|
7
|
+
6: "Personal appearance and wellness",
|
|
8
|
+
7: "Recreation and instruction",
|
|
9
|
+
8: "Transportation and delivery"
|
|
10
|
+
}, P = [
|
|
11
|
+
[101, "Bartenders"],
|
|
12
|
+
[102, "Wait staff"],
|
|
13
|
+
[103, "Food or beverage servers, non-restaurant"],
|
|
14
|
+
[104, "Dining room and cafeteria attendants and bartender helpers"],
|
|
15
|
+
[105, "Chefs and cooks"],
|
|
16
|
+
[106, "Food preparation workers"],
|
|
17
|
+
[107, "Fast food and counter workers"],
|
|
18
|
+
[108, "Dishwashers"],
|
|
19
|
+
[109, "Host staff, restaurant, lounge, and coffee shop"],
|
|
20
|
+
[110, "Bakers"],
|
|
21
|
+
[201, "Gambling dealers"],
|
|
22
|
+
[202, "Gambling change persons and booth cashiers"],
|
|
23
|
+
[203, "Gambling cage workers"],
|
|
24
|
+
[204, "Gambling and sports book writers and runners"],
|
|
25
|
+
[205, "Dancers"],
|
|
26
|
+
[206, "Musicians and singers"],
|
|
27
|
+
[207, "Disc jockeys, except radio"],
|
|
28
|
+
[208, "Entertainers and performers"],
|
|
29
|
+
[209, "Digital content creators"],
|
|
30
|
+
[210, "Ushers, lobby attendants, and ticket takers"],
|
|
31
|
+
[211, "Locker room, coatroom, and dressing room attendants"],
|
|
32
|
+
[301, "Baggage porters and bellhops"],
|
|
33
|
+
[302, "Concierges"],
|
|
34
|
+
[303, "Hotel, motel, and resort desk clerks"],
|
|
35
|
+
[304, "Maids and housekeeping cleaners"],
|
|
36
|
+
[401, "Home maintenance and repair workers"],
|
|
37
|
+
[402, "Home landscaping and groundskeeping workers"],
|
|
38
|
+
[403, "Home electricians"],
|
|
39
|
+
[404, "Home plumbers"],
|
|
40
|
+
[405, "Home heating and air conditioning mechanics and installers"],
|
|
41
|
+
[406, "Home appliance installers and repairers"],
|
|
42
|
+
[407, "Home cleaning service workers"],
|
|
43
|
+
[408, "Locksmiths"],
|
|
44
|
+
[409, "Roadside assistance workers"],
|
|
45
|
+
[501, "Personal care and service workers"],
|
|
46
|
+
[502, "Private event planners"],
|
|
47
|
+
[503, "Private event and portrait photographers"],
|
|
48
|
+
[504, "Private event videographers"],
|
|
49
|
+
[505, "Event officiants"],
|
|
50
|
+
[506, "Pet and show animal caretakers"],
|
|
51
|
+
[507, "Tutors"],
|
|
52
|
+
[508, "Nannies and babysitters"],
|
|
53
|
+
[509, "Visual artists"],
|
|
54
|
+
[510, "Floral designers"],
|
|
55
|
+
[601, "Skincare specialists"],
|
|
56
|
+
[602, "Massage therapists"],
|
|
57
|
+
[603, "Barbers, hairdressers, hairstylists, and cosmetologists"],
|
|
58
|
+
[604, "Shampooers"],
|
|
59
|
+
[605, "Manicurists and pedicurists"],
|
|
60
|
+
[606, "Eyebrow and eyelash technicians"],
|
|
61
|
+
[607, "Makeup artists"],
|
|
62
|
+
[608, "Exercise trainers and group fitness instructors"],
|
|
63
|
+
[609, "Tattoo artists and piercers"],
|
|
64
|
+
[610, "Tailors"],
|
|
65
|
+
[611, "Shoe and leather workers and repairers"],
|
|
66
|
+
[701, "Golf caddies"],
|
|
67
|
+
[702, "Self-enrichment teachers"],
|
|
68
|
+
[703, "Recreational and tour pilots"],
|
|
69
|
+
[704, "Tour guides"],
|
|
70
|
+
[705, "Travel guides"],
|
|
71
|
+
[706, "Sports and recreation instructors"],
|
|
72
|
+
[801, "Parking and valet attendants"],
|
|
73
|
+
[802, "Taxi and rideshare drivers and chauffeurs"],
|
|
74
|
+
[803, "Shuttle drivers"],
|
|
75
|
+
[804, "Goods delivery people"],
|
|
76
|
+
[805, "Personal vehicle and equipment cleaners"],
|
|
77
|
+
[806, "Private and charter bus drivers"],
|
|
78
|
+
[807, "Water taxi operators and charter boat workers"],
|
|
79
|
+
[808, "Rickshaw, pedicab, and carriage drivers"],
|
|
80
|
+
[809, "Home movers"],
|
|
81
|
+
[810, "Gas pump attendant"]
|
|
82
|
+
], k = P.map(
|
|
83
|
+
([e, n]) => ({ code: e, label: n, category: O[Math.floor(e / 100)] })
|
|
84
|
+
), y = new Map(k.map((e) => [e.code, e]));
|
|
85
|
+
function F(e) {
|
|
86
|
+
return y.get(e);
|
|
87
|
+
}
|
|
88
|
+
function C(e) {
|
|
89
|
+
return typeof e == "number" && y.has(e);
|
|
90
|
+
}
|
|
91
|
+
function S(e) {
|
|
92
|
+
const n = typeof e == "string" && /^\s*\d+\s*$/.test(e) ? Number(e) : e;
|
|
93
|
+
return n === 0 ? 0 : C(n) ? n : void 0;
|
|
94
|
+
}
|
|
95
|
+
function f(e) {
|
|
96
|
+
const n = typeof e == "string" && e.trim() !== "" ? Number(e) : e;
|
|
97
|
+
return typeof n == "number" && Number.isFinite(n) ? n : void 0;
|
|
98
|
+
}
|
|
99
|
+
const U = {
|
|
100
|
+
household: "household",
|
|
101
|
+
family: "family",
|
|
102
|
+
taxUnit: "tax_unit",
|
|
103
|
+
spmUnit: "spm_unit",
|
|
104
|
+
maritalUnit: "marital_unit"
|
|
105
|
+
}, x = {
|
|
106
|
+
household: "your household",
|
|
107
|
+
family: "your family",
|
|
108
|
+
taxUnit: "your tax unit",
|
|
109
|
+
spmUnit: "your household",
|
|
110
|
+
// app-v2 uses the same label for SPM unit
|
|
111
|
+
maritalUnit: "your marital unit"
|
|
112
|
+
}, w = {
|
|
113
|
+
isDisabled: "is_disabled",
|
|
114
|
+
isBlind: "is_blind",
|
|
115
|
+
isFullTimeStudent: "is_full_time_college_student",
|
|
116
|
+
isPregnant: "is_pregnant",
|
|
117
|
+
needsCare: "is_incapable_of_self_care"
|
|
118
|
+
}, N = 18, D = "takes_up_ssi_if_eligible", v = {
|
|
119
|
+
employmentIncome: "employment_income",
|
|
120
|
+
tipIncome: "tip_income",
|
|
121
|
+
selfEmploymentIncome: "self_employment_income",
|
|
122
|
+
socialSecurityIncome: "social_security_retirement",
|
|
123
|
+
ssiAmount: "ssi",
|
|
124
|
+
ssdiAmount: "social_security_disability",
|
|
125
|
+
pensionIncome: "taxable_private_pension_income",
|
|
126
|
+
publicPensionIncome: "taxable_public_pension_income",
|
|
127
|
+
privatePensionIncome: "taxable_private_pension_income",
|
|
128
|
+
dividendIncome: "qualified_dividend_income",
|
|
129
|
+
nonQualifiedDividendIncome: "non_qualified_dividend_income",
|
|
130
|
+
shortTermCapitalGains: "short_term_capital_gains",
|
|
131
|
+
longTermCapitalGains: "long_term_capital_gains",
|
|
132
|
+
taxableInterestIncome: "taxable_interest_income",
|
|
133
|
+
rentalIncome: "rental_income",
|
|
134
|
+
unemploymentCompensation: "unemployment_compensation",
|
|
135
|
+
childSupportReceived: "child_support_received",
|
|
136
|
+
miscellaneousIncome: "miscellaneous_income"
|
|
137
|
+
}, H = {
|
|
138
|
+
tipIncome: "employment_income"
|
|
139
|
+
}, R = {
|
|
140
|
+
charitableCashDonations: "charitable_cash_donations",
|
|
141
|
+
mortgageInterest: "home_mortgage_interest",
|
|
142
|
+
realEstateTaxes: "real_estate_taxes"
|
|
143
|
+
}, B = "treasury_tipped_occupation_code", G = [
|
|
144
|
+
...Object.entries(v),
|
|
145
|
+
...Object.entries(H),
|
|
146
|
+
...Object.entries(R)
|
|
147
|
+
];
|
|
148
|
+
function a(e, n) {
|
|
149
|
+
return { [e]: n };
|
|
150
|
+
}
|
|
151
|
+
function L(e, n) {
|
|
152
|
+
var r;
|
|
153
|
+
const i = {};
|
|
154
|
+
e.age !== null && e.age !== void 0 && (i.age = a(n, e.age)), i.is_tax_unit_dependent = a(n, e.kind === "dependent");
|
|
155
|
+
const p = f(e.age), _ = p !== void 0 && p < N;
|
|
156
|
+
for (const [s, c] of Object.entries(w)) {
|
|
157
|
+
const l = e[s];
|
|
158
|
+
s === "isFullTimeStudent" && _ || typeof l == "boolean" && (i[c] = a(n, l));
|
|
159
|
+
}
|
|
160
|
+
for (const [s, c] of G) {
|
|
161
|
+
const l = f(e[s]);
|
|
162
|
+
if (l !== void 0 && s !== "ssiAmount") {
|
|
163
|
+
const d = (r = i[c]) == null ? void 0 : r[n], m = typeof d == "number" ? d + l : l;
|
|
164
|
+
i[c] = a(n, m);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const o = S(e.tippedOccupationCode);
|
|
168
|
+
return o !== void 0 && (i[B] = a(n, o)), i;
|
|
169
|
+
}
|
|
170
|
+
function M(e, n = {}) {
|
|
171
|
+
const { groupKeyStyle: i = "short", includeMaritalUnit: p = !1, label: _ = null } = n, o = i === "verbose" ? x : U, r = String(e.year), s = e.people.map((t) => t.id), c = e.people.map((t) => f(t.ssiAmount)), l = c.every((t) => t !== void 0) && c.some((t) => t !== 0), d = {};
|
|
172
|
+
e.people.forEach((t, u) => {
|
|
173
|
+
const h = L(t, r), g = c[u];
|
|
174
|
+
g === 0 && (h[D] = a(r, !1)), l && g !== void 0 && (h[v.ssiAmount] = a(r, g)), d[t.id] = h;
|
|
175
|
+
});
|
|
176
|
+
const m = {
|
|
177
|
+
members: [...s]
|
|
178
|
+
};
|
|
179
|
+
e.state && (m.state_name = a(r, e.state)), e.county && (m.county = a(r, e.county));
|
|
180
|
+
const T = {
|
|
181
|
+
[o.family]: { members: [...s] }
|
|
182
|
+
}, I = {
|
|
183
|
+
[o.taxUnit]: { members: [...s] }
|
|
184
|
+
}, E = {
|
|
185
|
+
[o.spmUnit]: { members: [...s] }
|
|
186
|
+
}, A = {
|
|
187
|
+
[o.household]: m
|
|
188
|
+
}, b = {};
|
|
189
|
+
if (p) {
|
|
190
|
+
const t = e.people.filter((u) => u.kind === "adult");
|
|
191
|
+
b[o.maritalUnit] = {
|
|
192
|
+
members: t.slice(0, 2).map((u) => u.id)
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
return {
|
|
196
|
+
country_id: "us",
|
|
197
|
+
label: _,
|
|
198
|
+
data: {
|
|
199
|
+
people: d,
|
|
200
|
+
families: T,
|
|
201
|
+
marital_units: b,
|
|
202
|
+
tax_units: I,
|
|
203
|
+
spm_units: E,
|
|
204
|
+
households: A
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function K(e, n = {}) {
|
|
209
|
+
return M(e, n).data;
|
|
210
|
+
}
|
|
211
|
+
export {
|
|
212
|
+
V as N,
|
|
213
|
+
k as T,
|
|
214
|
+
S as a,
|
|
215
|
+
M as b,
|
|
216
|
+
K as c,
|
|
217
|
+
F as g,
|
|
218
|
+
C as i,
|
|
219
|
+
f as t
|
|
220
|
+
};
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
const U = [
|
|
2
|
+
{ code: "NORTH_EAST", name: "North East" },
|
|
3
|
+
{ code: "NORTH_WEST", name: "North West" },
|
|
4
|
+
{ code: "YORKSHIRE", name: "Yorkshire and the Humber" },
|
|
5
|
+
{ code: "EAST_MIDLANDS", name: "East Midlands" },
|
|
6
|
+
{ code: "WEST_MIDLANDS", name: "West Midlands" },
|
|
7
|
+
{ code: "EAST_OF_ENGLAND", name: "East of England" },
|
|
8
|
+
{ code: "LONDON", name: "London" },
|
|
9
|
+
{ code: "SOUTH_EAST", name: "South East" },
|
|
10
|
+
{ code: "SOUTH_WEST", name: "South West" },
|
|
11
|
+
{ code: "WALES", name: "Wales" },
|
|
12
|
+
{ code: "SCOTLAND", name: "Scotland" },
|
|
13
|
+
{ code: "NORTHERN_IRELAND", name: "Northern Ireland" }
|
|
14
|
+
], C = [
|
|
15
|
+
"RENT_PRIVATELY",
|
|
16
|
+
"RENT_FROM_COUNCIL",
|
|
17
|
+
"RENT_FROM_HA",
|
|
18
|
+
"OWNED_WITH_MORTGAGE",
|
|
19
|
+
"OWNED_OUTRIGHT"
|
|
20
|
+
], $ = ["RENT_PRIVATELY", "RENT_FROM_COUNCIL", "RENT_FROM_HA"], v = [
|
|
21
|
+
"NONE",
|
|
22
|
+
"PLAN_1",
|
|
23
|
+
"PLAN_2",
|
|
24
|
+
"PLAN_4",
|
|
25
|
+
"PLAN_5",
|
|
26
|
+
"POSTGRADUATE"
|
|
27
|
+
], D = ["A", "B", "C", "D", "E", "F", "G", "H", "I"], A = (e, a) => typeof a == "string" && e.includes(a), Y = (e) => A(
|
|
28
|
+
U.map((a) => a.code),
|
|
29
|
+
e
|
|
30
|
+
), w = (e) => A(C, e), H = (e) => A(v, e), K = (e) => A(D, e), P = (e) => A($, e);
|
|
31
|
+
function Z(e) {
|
|
32
|
+
var a;
|
|
33
|
+
return ((a = U.find((r) => r.code === e)) == null ? void 0 : a.name) ?? e;
|
|
34
|
+
}
|
|
35
|
+
const ee = 2026, ne = 34200, te = "£34,200 is the UK median salary in April 2026 (ONS Annual Survey of Hours and Earnings, provisional).", I = {
|
|
36
|
+
NORTH_EAST: 790,
|
|
37
|
+
NORTH_WEST: 975,
|
|
38
|
+
YORKSHIRE: 869,
|
|
39
|
+
EAST_MIDLANDS: 928,
|
|
40
|
+
WEST_MIDLANDS: 983,
|
|
41
|
+
EAST_OF_ENGLAND: 1298,
|
|
42
|
+
LONDON: 2338,
|
|
43
|
+
SOUTH_EAST: 1438,
|
|
44
|
+
SOUTH_WEST: 1251,
|
|
45
|
+
WALES: 848,
|
|
46
|
+
SCOTLAND: 1011,
|
|
47
|
+
NORTHERN_IRELAND: 879
|
|
48
|
+
}, k = 1406, oe = (e) => e === "NORTHERN_IRELAND" ? "July 2026" : "September 2026";
|
|
49
|
+
function F(e) {
|
|
50
|
+
return typeof e == "string" && Object.prototype.hasOwnProperty.call(I, e) ? I[e] : k;
|
|
51
|
+
}
|
|
52
|
+
const W = {
|
|
53
|
+
petrol: 620,
|
|
54
|
+
diesel: 340,
|
|
55
|
+
electricity: 1040
|
|
56
|
+
}, ie = {
|
|
57
|
+
salary: {
|
|
58
|
+
statistic: "Median gross annual pay, all employee jobs, UK, April 2026 (provisional): £34,229",
|
|
59
|
+
publication: "ONS, Annual Survey of Hours and Earnings 2026, Table 6.7a",
|
|
60
|
+
url: "https://www.ons.gov.uk/employmentandlabourmarket/peopleinwork/earningsandworkinghours/datasets/agegroupashetable6"
|
|
61
|
+
},
|
|
62
|
+
rent: {
|
|
63
|
+
statistic: "Average monthly private rent by region, September 2026 (Northern Ireland: July 2026)",
|
|
64
|
+
publication: "ONS, Price Index of Private Rents, published 21 October 2026",
|
|
65
|
+
url: "https://www.ons.gov.uk/economy/inflationandpriceindices/datasets/priceindexofprivaterentsukmonthlypricestatistics"
|
|
66
|
+
},
|
|
67
|
+
spending: {
|
|
68
|
+
statistic: "Average weekly household spending on petrol, diesel and electricity, FYE 2025",
|
|
69
|
+
publication: "ONS, Family Spending in the UK, FYE 2025, Workbook 1, Table A1",
|
|
70
|
+
url: "https://www.ons.gov.uk/peoplepopulationandcommunity/personalandhouseholdfinances/expenditure/datasets/familyspendingworkbook1detailedexpenditureandtrends"
|
|
71
|
+
}
|
|
72
|
+
}, L = {
|
|
73
|
+
years: {
|
|
74
|
+
2026: { state_pension_age: 66, full_new_state_pension: 12547.6 },
|
|
75
|
+
2027: { state_pension_age: 67, full_new_state_pension: 13036.97 },
|
|
76
|
+
2028: { state_pension_age: 67, full_new_state_pension: 13362.92 },
|
|
77
|
+
2029: { state_pension_age: 67, full_new_state_pension: 13696.98 },
|
|
78
|
+
2030: { state_pension_age: 67, full_new_state_pension: 14039.42 },
|
|
79
|
+
2031: { state_pension_age: 67, full_new_state_pension: 14390.39 }
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
function G(e, a = L) {
|
|
83
|
+
const r = Object.keys(a.years).map(Number).sort((n, c) => n - c), p = r.find((n) => n >= e) ?? r[r.length - 1], m = a.years[String(p)];
|
|
84
|
+
return { age: m.state_pension_age, full: m.full_new_state_pension };
|
|
85
|
+
}
|
|
86
|
+
function E(e, a, r = L) {
|
|
87
|
+
return e >= G(a, r).age;
|
|
88
|
+
}
|
|
89
|
+
const S = (e) => typeof e == "number" && Number.isFinite(e), f = 19, M = 16, q = "Children are 0 to 19. Someone aged 20 or over is not a dependant for Child Benefit or Universal Credit, so leave them out.", B = (e) => e >= M && e <= f, se = 5, b = {
|
|
90
|
+
adultAge: { min: 16, max: 100 },
|
|
91
|
+
childAge: { min: 0, max: f },
|
|
92
|
+
maxChildren: 10,
|
|
93
|
+
/** Incomes and salary sacrifice. */
|
|
94
|
+
maxAmount: 1e7,
|
|
95
|
+
maxMonthlyRent: 1e5,
|
|
96
|
+
maxMonthlyChildcare: 1e4,
|
|
97
|
+
/** Petrol, diesel and electricity. */
|
|
98
|
+
maxSpending: 1e5,
|
|
99
|
+
maxStatePension: 1e5
|
|
100
|
+
}, j = [2026, 2027, 2028, 2029, 2030, 2031], h = (e) => typeof e == "number" && Number.isInteger(e), V = (e) => typeof e == "number" && Number.isFinite(e), J = (e) => `£${e.toLocaleString("en-GB")}`;
|
|
101
|
+
function z(e, a) {
|
|
102
|
+
var N, T, R;
|
|
103
|
+
const { year: r, years: p = j, statePension: m } = a, n = b, c = [], i = (t, s, o) => c.push({ code: t, path: s, message: o });
|
|
104
|
+
(!h(r) || !p.includes(r)) && i("year.unsupported", "year", `${String(r)} is not a year this calculation covers.`), !h(e.salaryYear) || !p.includes(e.salaryYear) ? i("salaryYear.unsupported", "salaryYear", `Salaries cannot be entered for ${String(e.salaryYear)}.`) : h(r) && e.salaryYear > r && i(
|
|
105
|
+
"salaryYear.afterYear",
|
|
106
|
+
"salaryYear",
|
|
107
|
+
`Salaries are entered for ${e.salaryYear}, after ${r}; they can only be grown forward.`
|
|
108
|
+
);
|
|
109
|
+
const g = (t, s, o, u) => {
|
|
110
|
+
o == null ? i(`${t}.required`, t, `${s} is required.`) : u(o) || i(`${t}.invalid`, t, `Unknown ${s.toLowerCase()} "${String(o)}".`);
|
|
111
|
+
};
|
|
112
|
+
g("region", "Region", e.region, Y), g("tenure", "Housing", e.tenure, w), g("councilTaxBand", "Council Tax band", e.councilTaxBand, K), typeof e.claimsUniversalCredit != "boolean" && i("claimsUniversalCredit.required", "claimsUniversalCredit", "Whether the household claims Universal Credit is required.");
|
|
113
|
+
const l = (t, s, o, u, { optional: x = !1 } = {}) => {
|
|
114
|
+
o == null ? x || i(`${t}.required`, t, `${s} is required.`) : V(o) ? o < 0 ? i(`${t}.negative`, t, `${s} cannot be negative.`) : o > u && i(`${t}.tooLarge`, t, `${s} cannot be more than ${J(u)}.`) : i(`${t}.notANumber`, t, `${s} must be a number.`);
|
|
115
|
+
}, _ = (t, s, o) => {
|
|
116
|
+
o == null ? i(`${t}.required`, t, `${s} is required.`) : h(o) ? (o < n.adultAge.min || o > n.adultAge.max) && i(`${t}.outOfRange`, t, `${s} must be from ${n.adultAge.min} to ${n.adultAge.max}.`) : i(`${t}.notWhole`, t, `${s} must be a whole number of years.`);
|
|
117
|
+
}, { head: d, partner: y } = e;
|
|
118
|
+
_("head.age", "Your age", d.age), l("head.employmentIncome", "Your salary", d.employmentIncome, n.maxAmount), l("head.privatePensionIncome", "Your private pension", d.privatePensionIncome, n.maxAmount, {
|
|
119
|
+
optional: !0
|
|
120
|
+
}), l("head.dividendIncome", "Dividends", d.dividendIncome, n.maxAmount), l("head.savingsInterestIncome", "Savings interest", d.savingsInterestIncome, n.maxAmount), l("head.propertyIncome", "Property income", d.propertyIncome, n.maxAmount), l(
|
|
121
|
+
"head.salarySacrificePensionContributions",
|
|
122
|
+
"Salary sacrifice",
|
|
123
|
+
d.salarySacrificePensionContributions,
|
|
124
|
+
n.maxAmount
|
|
125
|
+
), H(d.studentLoanPlan) || i("head.studentLoanPlan.invalid", "head.studentLoanPlan", `Unknown student loan plan "${String(d.studentLoanPlan)}".`), S(d.statePension) && E(d.age, r, m) && l("head.statePension", "Your State Pension", d.statePension, n.maxStatePension), e.hasPartner && (_("partner.age", "Your partner's age", y.age), l("partner.employmentIncome", "Your partner's salary", y.employmentIncome, n.maxAmount), l(
|
|
126
|
+
"partner.privatePensionIncome",
|
|
127
|
+
"Your partner's private pension",
|
|
128
|
+
y.privatePensionIncome,
|
|
129
|
+
n.maxAmount,
|
|
130
|
+
{ optional: !0 }
|
|
131
|
+
), S(y.statePension) && E(y.age, r, m) && l("partner.statePension", "Your partner's State Pension", y.statePension, n.maxStatePension)), e.children.length > n.maxChildren && i("children.tooMany", "children", `At most ${n.maxChildren} children can be entered.`);
|
|
132
|
+
for (let t = 0; t < e.children.length; t++) {
|
|
133
|
+
const s = e.children[t];
|
|
134
|
+
if (s == null) {
|
|
135
|
+
i(`children[${t}].required`, `children[${t}]`, `Child ${t + 1}'s details are missing.`);
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
const o = `children[${t}].age`, u = `Child ${t + 1}'s age`;
|
|
139
|
+
s.age === null || s.age === void 0 ? i(`${o}.required`, o, `${u} is required.`) : h(s.age) ? s.age < n.childAge.min ? i(`${o}.negative`, o, `${u} cannot be negative.`) : s.age > n.childAge.max && i(`${o}.tooOld`, o, q) : i(`${o}.notWhole`, o, `${u} must be a whole number of years.`);
|
|
140
|
+
}
|
|
141
|
+
return P(e.tenure) && l("monthlyRent", "Rent", e.monthlyRent, n.maxMonthlyRent, { optional: !0 }), e.children.length > 0 && l("monthlyChildcare", "Childcare", e.monthlyChildcare, n.maxMonthlyChildcare), l("spending.petrol", "Petrol spending", (N = e.spending) == null ? void 0 : N.petrol, n.maxSpending), l("spending.diesel", "Diesel spending", (T = e.spending) == null ? void 0 : T.diesel, n.maxSpending), l("spending.electricity", "Electricity spending", (R = e.spending) == null ? void 0 : R.electricity, n.maxSpending, {
|
|
142
|
+
optional: !0
|
|
143
|
+
}), c.length === 0 ? { ok: !0, issues: [] } : { ok: !1, issues: c };
|
|
144
|
+
}
|
|
145
|
+
function ae(e, a) {
|
|
146
|
+
return z(e, a).ok;
|
|
147
|
+
}
|
|
148
|
+
const { adultAge: O } = b, X = (e) => typeof e == "number" && Number.isInteger(e) && e >= O.min && e <= O.max;
|
|
149
|
+
function re(e, { year: a, policies: r, include: p = [], statePension: m }) {
|
|
150
|
+
const { head: n, partner: c, hasPartner: i } = e, g = e.children.map(
|
|
151
|
+
(_) => B(_.age) ? { age: _.age, in_education: _.inEducation !== !1 } : { age: _.age }
|
|
152
|
+
), l = P(e.tenure);
|
|
153
|
+
return {
|
|
154
|
+
year: a,
|
|
155
|
+
policies: [...r],
|
|
156
|
+
household: {
|
|
157
|
+
age: n.age,
|
|
158
|
+
employment_income: n.employmentIncome,
|
|
159
|
+
has_partner: !!i,
|
|
160
|
+
...i || X(c.age) ? { partner_age: c.age } : {},
|
|
161
|
+
partner_employment_income: i ? c.employmentIncome : 0,
|
|
162
|
+
children: g,
|
|
163
|
+
region: e.region,
|
|
164
|
+
claims_universal_credit: !!e.claimsUniversalCredit,
|
|
165
|
+
tenure: e.tenure,
|
|
166
|
+
monthly_rent: l ? Q(e) : 0,
|
|
167
|
+
dividend_income: n.dividendIncome,
|
|
168
|
+
savings_interest_income: n.savingsInterestIncome,
|
|
169
|
+
private_pension_income: n.privatePensionIncome ?? 0,
|
|
170
|
+
partner_private_pension_income: i ? c.privatePensionIncome ?? 0 : 0,
|
|
171
|
+
property_income: n.propertyIncome,
|
|
172
|
+
petrol_spending: e.spending.petrol,
|
|
173
|
+
diesel_spending: e.spending.diesel,
|
|
174
|
+
electricity_spending: e.spending.electricity ?? W.electricity,
|
|
175
|
+
salary_sacrifice_pension_contributions: n.salarySacrificePensionContributions,
|
|
176
|
+
student_loan_plan: n.studentLoanPlan,
|
|
177
|
+
council_tax_band: e.councilTaxBand,
|
|
178
|
+
monthly_childcare: g.length ? e.monthlyChildcare : 0,
|
|
179
|
+
salary_year: e.salaryYear,
|
|
180
|
+
...S(n.statePension) && E(n.age, a, m) ? { state_pension: n.statePension } : {},
|
|
181
|
+
...i && S(c.statePension) && E(c.age, a, m) ? { partner_state_pension: c.statePension } : {}
|
|
182
|
+
},
|
|
183
|
+
include: [...p]
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
function Q(e) {
|
|
187
|
+
return typeof e.monthlyRent == "number" && Number.isFinite(e.monthlyRent) ? e.monthlyRent : F(e.region);
|
|
188
|
+
}
|
|
189
|
+
export {
|
|
190
|
+
w as A,
|
|
191
|
+
Q as B,
|
|
192
|
+
F as C,
|
|
193
|
+
oe as D,
|
|
194
|
+
S as E,
|
|
195
|
+
G as F,
|
|
196
|
+
re as G,
|
|
197
|
+
z as H,
|
|
198
|
+
k as U,
|
|
199
|
+
q as a,
|
|
200
|
+
D as b,
|
|
201
|
+
ne as c,
|
|
202
|
+
te as d,
|
|
203
|
+
ie as e,
|
|
204
|
+
W as f,
|
|
205
|
+
b as g,
|
|
206
|
+
se as h,
|
|
207
|
+
f as i,
|
|
208
|
+
j,
|
|
209
|
+
I as k,
|
|
210
|
+
U as l,
|
|
211
|
+
$ as m,
|
|
212
|
+
ee as n,
|
|
213
|
+
L as o,
|
|
214
|
+
v as p,
|
|
215
|
+
C as q,
|
|
216
|
+
M as r,
|
|
217
|
+
B as s,
|
|
218
|
+
E as t,
|
|
219
|
+
Z as u,
|
|
220
|
+
ae as v,
|
|
221
|
+
P as w,
|
|
222
|
+
K as x,
|
|
223
|
+
Y as y,
|
|
224
|
+
H as z
|
|
225
|
+
};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./WizardReviewList-DhLx8Bla.cjs"),e=require("./us-household.cjs"),t=require("./index-B_OXaS4a.cjs");exports.WizardNavigation=a.WizardNavigation;exports.WizardOptionCard=a.WizardOptionCard;exports.WizardProgress=a.WizardProgress;exports.WizardReviewList=a.WizardReviewList;exports.useWizardStepFocus=a.useWizardStepFocus;exports.useWizardSteps=a.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.NOT_A_TIPPED_OCCUPATION=t.NOT_A_TIPPED_OCCUPATION;exports.TIPPED_OCCUPATIONS=t.TIPPED_OCCUPATIONS;exports.getTippedOccupation=t.getTippedOccupation;exports.isTippedOccupationCode=t.isTippedOccupationCode;exports.toTippedOccupationCode=t.toTippedOccupationCode;exports.toV1HouseholdPayload=t.toV1HouseholdPayload;exports.toV1HouseholdSituation=t.toV1HouseholdSituation;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './primitives';
|
|
2
|
-
export * from './us-household';
|
|
1
|
+
export * from './primitives.js';
|
|
2
|
+
export * from './us-household.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,35 +1,41 @@
|
|
|
1
|
-
import { W as t, a as o, b as
|
|
2
|
-
import { DEFAULT_HOUSEHOLD_YEAR as n, US_STATES as
|
|
3
|
-
import {
|
|
1
|
+
import { W as t, a as o, b as s, c as i, u as r, d } from "./WizardReviewList-oY1HqmLw.js";
|
|
2
|
+
import { DEFAULT_HOUSEHOLD_YEAR as n, US_STATES as u, addPerson as C, applyMaritalStatusChange as l, cloneDraft as S, createBlankDraft as c, createPerson as g, deserializeDraft as P, getAdults as T, getCountiesByState as O, getCountyName as D, getDependents as m, getStateFromZip as z, getStateName as f, isComplete as y, isCountyCode as A, isUSStateCode as N, normalizeLegacyDraft as W, removePerson as _, resolveCountyCode as E, serializeDraft as U, updatePerson as v, validate as H } from "./us-household.js";
|
|
3
|
+
import { N as L, T as h, g as x, i as F, a as b, b as B, c as R } from "./index-DWM0giHt.js";
|
|
4
4
|
export {
|
|
5
5
|
n as DEFAULT_HOUSEHOLD_YEAR,
|
|
6
|
-
|
|
6
|
+
L as NOT_A_TIPPED_OCCUPATION,
|
|
7
|
+
h as TIPPED_OCCUPATIONS,
|
|
8
|
+
u as US_STATES,
|
|
7
9
|
t as WizardNavigation,
|
|
8
10
|
o as WizardOptionCard,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
s as WizardProgress,
|
|
12
|
+
i as WizardReviewList,
|
|
13
|
+
C as addPerson,
|
|
14
|
+
l as applyMaritalStatusChange,
|
|
15
|
+
S as cloneDraft,
|
|
16
|
+
c as createBlankDraft,
|
|
17
|
+
g as createPerson,
|
|
18
|
+
P as deserializeDraft,
|
|
19
|
+
T as getAdults,
|
|
20
|
+
O as getCountiesByState,
|
|
19
21
|
D as getCountyName,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
A as
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
m as getDependents,
|
|
23
|
+
z as getStateFromZip,
|
|
24
|
+
f as getStateName,
|
|
25
|
+
x as getTippedOccupation,
|
|
26
|
+
y as isComplete,
|
|
27
|
+
A as isCountyCode,
|
|
28
|
+
F as isTippedOccupationCode,
|
|
29
|
+
N as isUSStateCode,
|
|
30
|
+
W as normalizeLegacyDraft,
|
|
31
|
+
_ as removePerson,
|
|
32
|
+
E as resolveCountyCode,
|
|
29
33
|
U as serializeDraft,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
b as toTippedOccupationCode,
|
|
35
|
+
B as toV1HouseholdPayload,
|
|
36
|
+
R as toV1HouseholdSituation,
|
|
37
|
+
v as updatePerson,
|
|
38
|
+
r as useWizardStepFocus,
|
|
39
|
+
d as useWizardSteps,
|
|
40
|
+
H as validate
|
|
35
41
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { HTMLAttributes, ReactNode } from 'react';
|
|
1
|
+
import type { HTMLAttributes, MouseEvent, ReactNode } from 'react';
|
|
2
2
|
export interface WizardReviewItem {
|
|
3
3
|
id: string;
|
|
4
4
|
label: ReactNode;
|
|
5
5
|
value: ReactNode;
|
|
6
6
|
missing?: boolean;
|
|
7
|
-
onEdit?: () => void;
|
|
7
|
+
onEdit?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
8
8
|
editLabel?: ReactNode;
|
|
9
|
+
editAriaLabel?: string;
|
|
9
10
|
}
|
|
10
11
|
export interface WizardReviewListProps extends HTMLAttributes<HTMLDivElement> {
|
|
11
12
|
items: WizardReviewItem[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WizardReviewList.d.ts","sourceRoot":"","sources":["../../src/primitives/WizardReviewList.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WizardReviewList.d.ts","sourceRoot":"","sources":["../../src/primitives/WizardReviewList.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEnE,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,CAAC,KAAK,EAAE,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IACxD,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,qBAAsB,SAAQ,cAAc,CAAC,cAAc,CAAC;IAC3E,KAAK,EAAE,gBAAgB,EAAE,CAAC;CAC3B;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,SAAS,EACT,GAAG,IAAI,EACR,EAAE,qBAAqB,2CAoEvB"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
export { useWizardSteps } from './useWizardSteps';
|
|
2
|
-
export {
|
|
3
|
-
export type {
|
|
4
|
-
export {
|
|
5
|
-
export type {
|
|
6
|
-
export {
|
|
7
|
-
export type {
|
|
8
|
-
export {
|
|
9
|
-
export type {
|
|
10
|
-
export
|
|
1
|
+
export { useWizardSteps } from './useWizardSteps.js';
|
|
2
|
+
export { useWizardStepFocus } from './useWizardStepFocus.js';
|
|
3
|
+
export type { UseWizardStepFocusOptions } from './useWizardStepFocus.js';
|
|
4
|
+
export { WizardProgress } from './WizardProgress.js';
|
|
5
|
+
export type { WizardProgressProps } from './WizardProgress.js';
|
|
6
|
+
export { WizardOptionCard } from './WizardOptionCard.js';
|
|
7
|
+
export type { WizardOptionCardProps } from './WizardOptionCard.js';
|
|
8
|
+
export { WizardNavigation } from './WizardNavigation.js';
|
|
9
|
+
export type { WizardNavigationProps } from './WizardNavigation.js';
|
|
10
|
+
export { WizardReviewList } from './WizardReviewList.js';
|
|
11
|
+
export type { WizardReviewItem, WizardReviewListProps } from './WizardReviewList.js';
|
|
12
|
+
export type { ResolvedWizardStep, UseWizardStepsOptions, UseWizardStepsResult, WizardStepConfig, WizardAdvanceRequest, } from './types.js';
|
|
11
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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,
|
|
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,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACtE,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,EAChB,oBAAoB,GACrB,MAAM,SAAS,CAAC"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import type { FormEvent, KeyboardEvent } from 'react';
|
|
1
2
|
export interface WizardStepConfig<TState> {
|
|
2
3
|
id: string;
|
|
3
4
|
label: string;
|
|
4
5
|
isComplete?: (state: TState) => boolean;
|
|
5
6
|
isVisible?: (state: TState) => boolean;
|
|
7
|
+
autoAdvance?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** Create a new object for each explicit selection, alongside its state update. */
|
|
10
|
+
export interface WizardAdvanceRequest {
|
|
11
|
+
stepId: string;
|
|
6
12
|
}
|
|
7
13
|
export interface ResolvedWizardStep {
|
|
8
14
|
id: string;
|
|
@@ -13,6 +19,9 @@ export interface UseWizardStepsOptions<TState> {
|
|
|
13
19
|
state: TState;
|
|
14
20
|
initialStepId?: string;
|
|
15
21
|
onStepChange?: (stepId: string) => void;
|
|
22
|
+
onComplete?: () => void;
|
|
23
|
+
onInvalidStep?: (stepId: string) => void;
|
|
24
|
+
advanceRequest?: WizardAdvanceRequest | null;
|
|
16
25
|
}
|
|
17
26
|
export interface UseWizardStepsResult {
|
|
18
27
|
visibleSteps: ResolvedWizardStep[];
|
|
@@ -22,6 +31,15 @@ export interface UseWizardStepsResult {
|
|
|
22
31
|
isFirstStep: boolean;
|
|
23
32
|
isLastStep: boolean;
|
|
24
33
|
canAdvance: boolean;
|
|
34
|
+
visitedStepIds: string[];
|
|
35
|
+
hasVisitedStep: (stepId: string) => boolean;
|
|
36
|
+
validationStepId: string | null;
|
|
37
|
+
validationAttempt: number;
|
|
38
|
+
clearValidation: () => void;
|
|
39
|
+
validateAll: () => boolean;
|
|
40
|
+
advance: () => void;
|
|
41
|
+
handleSubmit: (event: FormEvent<HTMLFormElement>) => void;
|
|
42
|
+
handleKeyDown: (event: KeyboardEvent<HTMLFormElement>) => void;
|
|
25
43
|
goNext: () => void;
|
|
26
44
|
goBack: () => void;
|
|
27
45
|
goToStep: (stepId: string) => void;
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/primitives/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtD,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;IACvC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,mFAAmF;AACnF,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;CAChB;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;IACxC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,cAAc,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;CAC9C;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,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IAC5C,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,OAAO,CAAC;IAC3B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;IAC1D,aAAa,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;IAC/D,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,13 @@
|
|
|
1
|
+
export interface UseWizardStepFocusOptions {
|
|
2
|
+
stepId: string | null;
|
|
3
|
+
hasError?: boolean;
|
|
4
|
+
errorRevision?: unknown;
|
|
5
|
+
preventScroll?: boolean;
|
|
6
|
+
onStepFocus?: () => void;
|
|
7
|
+
}
|
|
8
|
+
/** Consumers render the targets with tabIndex={-1} and own any scrolling layout. */
|
|
9
|
+
export declare function useWizardStepFocus({ stepId, hasError, errorRevision, preventScroll, onStepFocus, }: UseWizardStepFocusOptions): {
|
|
10
|
+
headingRef: import("react").RefObject<HTMLHeadingElement | null>;
|
|
11
|
+
errorRef: import("react").RefObject<HTMLDivElement | null>;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=useWizardStepFocus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWizardStepFocus.d.ts","sourceRoot":"","sources":["../../src/primitives/useWizardStepFocus.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,oFAAoF;AACpF,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,QAAgB,EAChB,aAAa,EACb,aAAqB,EACrB,WAAW,GACZ,EAAE,yBAAyB;;;EAwB3B"}
|