quirk-ui 0.1.76 → 0.1.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{FormField-BO1hKjUb.js → FormField-Rqe3qF_t.js} +67 -62
- package/dist/FormField-fg7Q2UyZ.cjs +1 -0
- package/dist/FormField.css +1 -1
- package/dist/main.d.ts +1 -1
- package/dist/next/blocks/FormBlock/FormField.cjs +1 -1
- package/dist/next/blocks/FormBlock/FormField.mjs +1 -1
- package/dist/next/blocks/FormBlock/index.cjs +1 -1
- package/dist/next/blocks/FormBlock/index.mjs +106 -99
- package/dist/next.d.ts +1 -1
- package/package.json +1 -1
- package/dist/AccordionItem.css.d.ts +0 -13
- package/dist/CategoryFilters.css.d.ts +0 -31
- package/dist/FormField-wfYSN1Vd.cjs +0 -1
- package/dist/FormField.css.d.ts +0 -22
- package/dist/HeroSubComponents.css.d.ts +0 -30
- package/dist/NavLink.css.d.ts +0 -72
- package/dist/index.css.d.ts +0 -1
- package/dist/index10.css.d.ts +0 -7
- package/dist/index11.css.d.ts +0 -26
- package/dist/index12.css.d.ts +0 -24
- package/dist/index13.css.d.ts +0 -33
- package/dist/index14.css.d.ts +0 -10
- package/dist/index15.css.d.ts +0 -18
- package/dist/index16.css.d.ts +0 -38
- package/dist/index17.css.d.ts +0 -16
- package/dist/index18.css.d.ts +0 -14
- package/dist/index19.css.d.ts +0 -17
- package/dist/index2.css.d.ts +0 -9
- package/dist/index20.css.d.ts +0 -13
- package/dist/index21.css.d.ts +0 -25
- package/dist/index22.css.d.ts +0 -5
- package/dist/index23.css.d.ts +0 -19
- package/dist/index24.css.d.ts +0 -21
- package/dist/index25.css.d.ts +0 -16
- package/dist/index26.css.d.ts +0 -10
- package/dist/index27.css.d.ts +0 -18
- package/dist/index28.css.d.ts +0 -16
- package/dist/index29.css.d.ts +0 -10
- package/dist/index3.css.d.ts +0 -12
- package/dist/index30.css.d.ts +0 -19
- package/dist/index31.css.d.ts +0 -15
- package/dist/index32.css.d.ts +0 -22
- package/dist/index33.css.d.ts +0 -15
- package/dist/index34.css.d.ts +0 -14
- package/dist/index35.css.d.ts +0 -23
- package/dist/index36.css.d.ts +0 -14
- package/dist/index37.css.d.ts +0 -18
- package/dist/index38.css.d.ts +0 -21
- package/dist/index39.css.d.ts +0 -20
- package/dist/index4.css.d.ts +0 -10
- package/dist/index40.css.d.ts +0 -17
- package/dist/index41.css.d.ts +0 -14
- package/dist/index42.css.d.ts +0 -22
- package/dist/index43.css.d.ts +0 -35
- package/dist/index44.css.d.ts +0 -13
- package/dist/index45.css.d.ts +0 -23
- package/dist/index46.css.d.ts +0 -12
- package/dist/index47.css.d.ts +0 -19
- package/dist/index48.css.d.ts +0 -20
- package/dist/index49.css.d.ts +0 -20
- package/dist/index5.css.d.ts +0 -22
- package/dist/index50.css.d.ts +0 -27
- package/dist/index51.css.d.ts +0 -17
- package/dist/index52.css.d.ts +0 -11
- package/dist/index53.css.d.ts +0 -12
- package/dist/index54.css.d.ts +0 -14
- package/dist/index55.css.d.ts +0 -20
- package/dist/index56.css.d.ts +0 -25
- package/dist/index57.css.d.ts +0 -13
- package/dist/index58.css.d.ts +0 -12
- package/dist/index59.css.d.ts +0 -20
- package/dist/index6.css.d.ts +0 -19
- package/dist/index60.css.d.ts +0 -20
- package/dist/index61.css.d.ts +0 -18
- package/dist/index62.css.d.ts +0 -22
- package/dist/index63.css.d.ts +0 -28
- package/dist/index64.css.d.ts +0 -26
- package/dist/index65.css.d.ts +0 -19
- package/dist/index7.css.d.ts +0 -40
- package/dist/index8.css.d.ts +0 -32
- package/dist/index9.css.d.ts +0 -9
- package/dist/styles.css.d.ts +0 -1
- package/dist/tokens.css.d.ts +0 -1
|
@@ -1,40 +1,45 @@
|
|
|
1
1
|
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
-
import { Input as
|
|
3
|
-
import { Textarea as
|
|
4
|
-
import { Select as
|
|
5
|
-
import { Checkbox as
|
|
6
|
-
import { Radio as
|
|
2
|
+
import { Input as v } from "./core/components/Input/index.mjs";
|
|
3
|
+
import { Textarea as T } from "./core/components/Textarea/index.mjs";
|
|
4
|
+
import { Select as b } from "./core/components/Select/index.mjs";
|
|
5
|
+
import { Checkbox as d } from "./core/components/Checkbox/index.mjs";
|
|
6
|
+
import { Radio as W } from "./core/components/Radio/index.mjs";
|
|
7
7
|
import { Fieldset as h } from "./core/components/Fieldset/index.mjs";
|
|
8
|
-
import { DatePicker as
|
|
9
|
-
import { Range as
|
|
10
|
-
import './FormField.css';const C = "
|
|
11
|
-
formBlock:
|
|
12
|
-
container:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
8
|
+
import { DatePicker as k } from "./core/components/DatePicker/index.mjs";
|
|
9
|
+
import { Range as w } from "./core/components/Range/index.mjs";
|
|
10
|
+
import './FormField.css';const L = "_formBlock_b7mbf_1", C = "_container_b7mbf_7", F = "_formInner_b7mbf_20", y = "_maxWidthSm_b7mbf_26", B = "_maxWidthMd_b7mbf_29", q = "_maxWidthLg_b7mbf_32", S = "_maxWidthFull_b7mbf_35", H = "_heading_b7mbf_41", G = "_eyebrow_b7mbf_47", M = "_title_b7mbf_51", $ = "_progress_b7mbf_57", I = "_progressHeader_b7mbf_63", D = "_stepLabel_b7mbf_69", O = "_stepCount_b7mbf_75", V = "_stepDescription_b7mbf_80", P = "_fields_b7mbf_88", R = "_fieldFull_b7mbf_95", j = "_fieldHalf_b7mbf_99", N = "_fieldThird_b7mbf_107", z = "_actions_b7mbf_117", A = "_submitButton_b7mbf_124", E = "_success_b7mbf_130", J = "_errorBanner_b7mbf_143", c = {
|
|
11
|
+
formBlock: L,
|
|
12
|
+
container: C,
|
|
13
|
+
formInner: F,
|
|
14
|
+
maxWidthSm: y,
|
|
15
|
+
maxWidthMd: B,
|
|
16
|
+
maxWidthLg: q,
|
|
17
|
+
maxWidthFull: S,
|
|
18
|
+
heading: H,
|
|
19
|
+
eyebrow: G,
|
|
20
|
+
title: M,
|
|
21
|
+
progress: $,
|
|
22
|
+
progressHeader: I,
|
|
23
|
+
stepLabel: D,
|
|
24
|
+
stepCount: O,
|
|
25
|
+
stepDescription: V,
|
|
26
|
+
fields: P,
|
|
27
|
+
fieldFull: R,
|
|
28
|
+
fieldHalf: j,
|
|
29
|
+
fieldThird: N,
|
|
30
|
+
actions: z,
|
|
31
|
+
submitButton: A,
|
|
32
|
+
success: E,
|
|
33
|
+
errorBanner: J
|
|
29
34
|
};
|
|
30
|
-
function
|
|
35
|
+
function u(e) {
|
|
31
36
|
return (e ?? []).map((r) => ({
|
|
32
37
|
label: r.label,
|
|
33
38
|
value: r.value.current,
|
|
34
39
|
disabled: r.disabled
|
|
35
40
|
}));
|
|
36
41
|
}
|
|
37
|
-
function
|
|
42
|
+
function p(e) {
|
|
38
43
|
return (e ?? []).map((r) => ({
|
|
39
44
|
label: r.label,
|
|
40
45
|
options: r.options.map((n) => ({
|
|
@@ -44,12 +49,12 @@ function m(e) {
|
|
|
44
49
|
}))
|
|
45
50
|
}));
|
|
46
51
|
}
|
|
47
|
-
function
|
|
52
|
+
function ae({ field: e, value: r, error: n, onChange: o }) {
|
|
48
53
|
const a = e.name.current, _ = {
|
|
49
|
-
full:
|
|
50
|
-
half:
|
|
51
|
-
third:
|
|
52
|
-
}[e.width ?? "full"],
|
|
54
|
+
full: c.fieldFull,
|
|
55
|
+
half: c.fieldHalf,
|
|
56
|
+
third: c.fieldThird
|
|
57
|
+
}[e.width ?? "full"], i = {
|
|
53
58
|
id: a,
|
|
54
59
|
name: a,
|
|
55
60
|
label: e.label,
|
|
@@ -57,7 +62,7 @@ function Y({ field: e, value: r, error: n, onChange: o }) {
|
|
|
57
62
|
disabled: e.disabled,
|
|
58
63
|
helperText: e.helperText,
|
|
59
64
|
error: n
|
|
60
|
-
},
|
|
65
|
+
}, m = () => {
|
|
61
66
|
switch (e.fieldType) {
|
|
62
67
|
// ── Text-based inputs ──────────────────────────────────────────────
|
|
63
68
|
case "text":
|
|
@@ -66,9 +71,9 @@ function Y({ field: e, value: r, error: n, onChange: o }) {
|
|
|
66
71
|
case "number":
|
|
67
72
|
case "url":
|
|
68
73
|
return /* @__PURE__ */ s(
|
|
69
|
-
|
|
74
|
+
v,
|
|
70
75
|
{
|
|
71
|
-
...
|
|
76
|
+
...i,
|
|
72
77
|
type: e.fieldType === "phone" ? "tel" : e.fieldType,
|
|
73
78
|
placeholder: e.placeholder,
|
|
74
79
|
value: r ?? "",
|
|
@@ -81,9 +86,9 @@ function Y({ field: e, value: r, error: n, onChange: o }) {
|
|
|
81
86
|
// ── Textarea ───────────────────────────────────────────────────────
|
|
82
87
|
case "textarea":
|
|
83
88
|
return /* @__PURE__ */ s(
|
|
84
|
-
|
|
89
|
+
T,
|
|
85
90
|
{
|
|
86
|
-
...
|
|
91
|
+
...i,
|
|
87
92
|
placeholder: e.placeholder,
|
|
88
93
|
value: r ?? "",
|
|
89
94
|
rows: e.rows ?? 4,
|
|
@@ -95,11 +100,11 @@ function Y({ field: e, value: r, error: n, onChange: o }) {
|
|
|
95
100
|
);
|
|
96
101
|
// ── Select ─────────────────────────────────────────────────────────
|
|
97
102
|
case "select": {
|
|
98
|
-
const t = e.useOptionGroups ?
|
|
103
|
+
const t = e.useOptionGroups ? p(e.optionGroups) : u(e.options);
|
|
99
104
|
return /* @__PURE__ */ s(
|
|
100
|
-
|
|
105
|
+
b,
|
|
101
106
|
{
|
|
102
|
-
...
|
|
107
|
+
...i,
|
|
103
108
|
placeholder: e.placeholder,
|
|
104
109
|
options: t,
|
|
105
110
|
value: r ?? "",
|
|
@@ -110,11 +115,11 @@ function Y({ field: e, value: r, error: n, onChange: o }) {
|
|
|
110
115
|
}
|
|
111
116
|
// ── Multi-select ───────────────────────────────────────────────────
|
|
112
117
|
case "multiselect": {
|
|
113
|
-
const t = e.useOptionGroups ?
|
|
118
|
+
const t = e.useOptionGroups ? p(e.optionGroups) : u(e.options);
|
|
114
119
|
return /* @__PURE__ */ s(
|
|
115
|
-
|
|
120
|
+
b,
|
|
116
121
|
{
|
|
117
|
-
...
|
|
122
|
+
...i,
|
|
118
123
|
multiple: !0,
|
|
119
124
|
options: t,
|
|
120
125
|
value: r ?? [],
|
|
@@ -126,10 +131,10 @@ function Y({ field: e, value: r, error: n, onChange: o }) {
|
|
|
126
131
|
// ── Single checkbox ────────────────────────────────────────────────
|
|
127
132
|
case "checkbox":
|
|
128
133
|
return /* @__PURE__ */ s(
|
|
129
|
-
|
|
134
|
+
d,
|
|
130
135
|
{
|
|
131
|
-
id:
|
|
132
|
-
name:
|
|
136
|
+
id: i.id,
|
|
137
|
+
name: i.name,
|
|
133
138
|
label: e.label,
|
|
134
139
|
required: e.required,
|
|
135
140
|
disabled: e.disabled,
|
|
@@ -142,17 +147,17 @@ function Y({ field: e, value: r, error: n, onChange: o }) {
|
|
|
142
147
|
// ── Checkbox group ─────────────────────────────────────────────────
|
|
143
148
|
case "checkboxGroup": {
|
|
144
149
|
const t = r ?? [];
|
|
145
|
-
return /* @__PURE__ */ s(h, { legend: e.label, error: !!n, helperText: n, children:
|
|
146
|
-
|
|
150
|
+
return /* @__PURE__ */ s(h, { legend: e.label, error: !!n, helperText: n, children: u(e.options).map((l) => /* @__PURE__ */ s(
|
|
151
|
+
d,
|
|
147
152
|
{
|
|
148
153
|
id: `${a}-${l.value}`,
|
|
149
154
|
name: `${a}[]`,
|
|
150
155
|
label: l.label,
|
|
151
156
|
checked: t.includes(l.value),
|
|
152
157
|
disabled: l.disabled || e.disabled,
|
|
153
|
-
onChange: (
|
|
154
|
-
const
|
|
155
|
-
o(a,
|
|
158
|
+
onChange: (x) => {
|
|
159
|
+
const f = x.target.checked ? [...t, l.value] : t.filter((g) => g !== l.value);
|
|
160
|
+
o(a, f);
|
|
156
161
|
}
|
|
157
162
|
},
|
|
158
163
|
l.value
|
|
@@ -160,8 +165,8 @@ function Y({ field: e, value: r, error: n, onChange: o }) {
|
|
|
160
165
|
}
|
|
161
166
|
// ── Radio group ────────────────────────────────────────────────────
|
|
162
167
|
case "radio":
|
|
163
|
-
return /* @__PURE__ */ s(h, { legend: e.label, error: !!n, helperText: n, children:
|
|
164
|
-
|
|
168
|
+
return /* @__PURE__ */ s(h, { legend: e.label, error: !!n, helperText: n, children: u(e.options).map((t) => /* @__PURE__ */ s(
|
|
169
|
+
W,
|
|
165
170
|
{
|
|
166
171
|
id: `${a}-${t.value}`,
|
|
167
172
|
name: a,
|
|
@@ -177,10 +182,10 @@ function Y({ field: e, value: r, error: n, onChange: o }) {
|
|
|
177
182
|
// ── Date picker ────────────────────────────────────────────────────
|
|
178
183
|
case "date":
|
|
179
184
|
return /* @__PURE__ */ s(
|
|
180
|
-
|
|
185
|
+
k,
|
|
181
186
|
{
|
|
182
|
-
id:
|
|
183
|
-
name:
|
|
187
|
+
id: i.id,
|
|
188
|
+
name: i.name,
|
|
184
189
|
label: e.label,
|
|
185
190
|
required: e.required,
|
|
186
191
|
disabled: e.disabled,
|
|
@@ -193,9 +198,9 @@ function Y({ field: e, value: r, error: n, onChange: o }) {
|
|
|
193
198
|
// ── Range ──────────────────────────────────────────────────────────
|
|
194
199
|
case "range":
|
|
195
200
|
return /* @__PURE__ */ s(
|
|
196
|
-
|
|
201
|
+
w,
|
|
197
202
|
{
|
|
198
|
-
...
|
|
203
|
+
...i,
|
|
199
204
|
value: r ?? e.rangeMin ?? 0,
|
|
200
205
|
min: e.rangeMin ?? 0,
|
|
201
206
|
max: e.rangeMax ?? 100,
|
|
@@ -220,9 +225,9 @@ function Y({ field: e, value: r, error: n, onChange: o }) {
|
|
|
220
225
|
return null;
|
|
221
226
|
}
|
|
222
227
|
};
|
|
223
|
-
return e.fieldType === "hidden" ?
|
|
228
|
+
return e.fieldType === "hidden" ? m() : /* @__PURE__ */ s("div", { className: `${_}`, children: m() });
|
|
224
229
|
}
|
|
225
230
|
export {
|
|
226
|
-
|
|
227
|
-
|
|
231
|
+
ae as F,
|
|
232
|
+
c as s
|
|
228
233
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require('./FormField.css');const a=require("react/jsx-runtime"),v=require("./core/components/Input/index.cjs"),q=require("./core/components/Textarea/index.cjs"),b=require("./core/components/Select/index.cjs"),_=require("./core/components/Checkbox/index.cjs"),T=require("./core/components/Radio/index.cjs"),m=require("./core/components/Fieldset/index.cjs"),k=require("./core/components/DatePicker/index.cjs"),W=require("./core/components/Range/index.cjs"),F="_formBlock_b7mbf_1",j="_container_b7mbf_7",C="_formInner_b7mbf_20",w="_maxWidthSm_b7mbf_26",L="_maxWidthMd_b7mbf_29",y="_maxWidthLg_b7mbf_32",S="_maxWidthFull_b7mbf_35",B="_heading_b7mbf_41",$="_eyebrow_b7mbf_47",H="_title_b7mbf_51",G="_progress_b7mbf_57",I="_progressHeader_b7mbf_63",M="_stepLabel_b7mbf_69",D="_stepCount_b7mbf_75",O="_stepDescription_b7mbf_80",P="_fields_b7mbf_88",R="_fieldFull_b7mbf_95",V="_fieldHalf_b7mbf_99",N="_fieldThird_b7mbf_107",z="_actions_b7mbf_117",A="_submitButton_b7mbf_124",E="_success_b7mbf_130",J="_errorBanner_b7mbf_143",u={formBlock:F,container:j,formInner:C,maxWidthSm:w,maxWidthMd:L,maxWidthLg:y,maxWidthFull:S,heading:B,eyebrow:$,title:H,progress:G,progressHeader:I,stepLabel:M,stepCount:D,stepDescription:O,fields:P,fieldFull:R,fieldHalf:V,fieldThird:N,actions:z,submitButton:A,success:E,errorBanner:J};function i(e){return(e??[]).map(n=>({label:n.label,value:n.value.current,disabled:n.disabled}))}function h(e){return(e??[]).map(n=>({label:n.label,options:n.options.map(s=>({label:s.label,value:s.value.current,disabled:s.disabled}))}))}function K({field:e,value:n,error:s,onChange:l}){const r=e.name.current,p={full:u.fieldFull,half:u.fieldHalf,third:u.fieldThird}[e.width??"full"],c={id:r,name:r,label:e.label,required:e.required,disabled:e.disabled,helperText:e.helperText,error:s},d=()=>{switch(e.fieldType){case"text":case"email":case"phone":case"number":case"url":return a.jsx(v.Input,{...c,type:e.fieldType==="phone"?"tel":e.fieldType,placeholder:e.placeholder,value:n??"",minLength:e.minLength,maxLength:e.maxLength,fullWidth:!0,onChange:t=>l(r,t.target.value)});case"textarea":return a.jsx(q.Textarea,{...c,placeholder:e.placeholder,value:n??"",rows:e.rows??4,maxLength:e.maxLength,showCharCount:e.showCharCount,fullWidth:!0,onChange:t=>l(r,t.target.value)});case"select":{const t=e.useOptionGroups?h(e.optionGroups):i(e.options);return a.jsx(b.Select,{...c,placeholder:e.placeholder,options:t,value:n??"",fullWidth:!0,onChange:o=>l(r,o.target.value)})}case"multiselect":{const t=e.useOptionGroups?h(e.optionGroups):i(e.options);return a.jsx(b.Select,{...c,multiple:!0,options:t,value:n??[],showSelectedCount:!0,onChange:o=>l(r,o)})}case"checkbox":return a.jsx(_.Checkbox,{id:c.id,name:c.name,label:e.label,required:e.required,disabled:e.disabled,helperText:s??e.helperText,error:!!s,checked:n??!1,onChange:t=>l(r,t.target.checked)});case"checkboxGroup":{const t=n??[];return a.jsx(m.Fieldset,{legend:e.label,error:!!s,helperText:s,children:i(e.options).map(o=>a.jsx(_.Checkbox,{id:`${r}-${o.value}`,name:`${r}[]`,label:o.label,checked:t.includes(o.value),disabled:o.disabled||e.disabled,onChange:x=>{const g=x.target.checked?[...t,o.value]:t.filter(f=>f!==o.value);l(r,g)}},o.value))})}case"radio":return a.jsx(m.Fieldset,{legend:e.label,error:!!s,helperText:s,children:i(e.options).map(t=>a.jsx(T.Radio,{id:`${r}-${t.value}`,name:r,value:t.value,label:t.label,checked:n===t.value,disabled:t.disabled||e.disabled,required:e.required,onChange:()=>l(r,t.value)},t.value))});case"date":return a.jsx(k.DatePicker,{id:c.id,name:c.name,label:e.label,required:e.required,disabled:e.disabled,helperText:s??e.helperText,error:!!s,value:n??null,onChange:t=>l(r,t)});case"range":return a.jsx(W.Range,{...c,value:n??e.rangeMin??0,min:e.rangeMin??0,max:e.rangeMax??100,step:e.rangeStep??1,valuePrefix:e.rangeValuePrefix,valueSuffix:e.rangeValueSuffix,showValue:!0,onChange:t=>l(r,t)});case"hidden":return a.jsx("input",{type:"hidden",name:r,value:n??e.hiddenValue??""});default:return null}};return e.fieldType==="hidden"?d():a.jsx("div",{className:`${p}`,children:d()})}exports.FormField=K;exports.styles=u;
|
package/dist/FormField.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._formBlock_b7mbf_1{width:100%;padding-top:var(--spacing-xl);padding-bottom:var(--spacing-xl)}._container_b7mbf_7{width:100%;max-width:var(--layout-width, 1250px);margin:0 auto;padding-left:var(--spacing-md);padding-right:var(--spacing-md);display:flex;flex-direction:column;gap:var(--spacing-lg)}._formInner_b7mbf_20{width:100%;margin-left:auto;margin-right:auto}._maxWidthSm_b7mbf_26{max-width:480px}._maxWidthMd_b7mbf_29{max-width:640px}._maxWidthLg_b7mbf_32{max-width:800px}._maxWidthFull_b7mbf_35{max-width:100%}._heading_b7mbf_41{display:flex;flex-direction:column;gap:var(--spacing-sm)}._eyebrow_b7mbf_47{font-weight:var(--font-weight-bold)}._title_b7mbf_51{text-wrap:balance}._progress_b7mbf_57{display:flex;flex-direction:column;gap:var(--spacing-sm)}._progressHeader_b7mbf_63{display:flex;justify-content:space-between;align-items:center}._stepLabel_b7mbf_69{font-weight:var(--font-weight-semibold);font-size:var(--font-size-md);color:var(--color-text-primary)}._stepCount_b7mbf_75{font-size:var(--font-size-sm);color:var(--color-secondary-50)}._stepDescription_b7mbf_80{color:var(--color-secondary-75);font-size:var(--font-size-md);margin:0}._fields_b7mbf_88{display:flex;flex-wrap:wrap;gap:var(--spacing-md)}._fieldFull_b7mbf_95{width:100%}._fieldHalf_b7mbf_99{width:calc(50% - var(--spacing-md) / 2)}@media (max-width: 767px){._fieldHalf_b7mbf_99{width:100%}}._fieldThird_b7mbf_107{width:calc(33.333% - var(--spacing-md) * 2 / 3)}@media (max-width: 767px){._fieldThird_b7mbf_107{width:100%}}._actions_b7mbf_117{display:flex;align-items:center;gap:var(--spacing-md);padding-top:var(--spacing-sm)}._submitButton_b7mbf_124{margin-left:auto}._success_b7mbf_130{display:flex;flex-direction:column;align-items:flex-start;gap:var(--spacing-lg);padding:var(--spacing-xl);background-color:var(--color-states-success-bg);color:var(--color-states-success-text);border-radius:var(--radius-md)}._errorBanner_b7mbf_143{padding:var(--spacing-md);background-color:var(--color-states-error-bg);color:var(--color-states-error-text);border-radius:var(--radius-md);font-size:var(--font-size-sm)}
|
package/dist/main.d.ts
CHANGED
|
@@ -663,7 +663,7 @@ declare type FooterUtilityItem = {
|
|
|
663
663
|
|
|
664
664
|
export declare function Form({ method, action, encType, target, noValidate, layout, spacing, maxWidth, fullWidth, className, style, children, onSubmit, onChange, onReset, ...restProps }: FormProps): JSX.Element;
|
|
665
665
|
|
|
666
|
-
export declare function FormBlock({ id, heading, layout, steps, submitLabel, nextLabel, backLabel, successMessage, errorMessage, styleOptions, renderRichText, onSubmit, }: FormBlockProps_2): JSX.Element;
|
|
666
|
+
export declare function FormBlock({ id, heading, layout, maxWidth, steps, submitLabel, nextLabel, backLabel, successMessage, errorMessage, styleOptions, renderRichText, onSubmit, }: FormBlockProps_2): JSX.Element;
|
|
667
667
|
|
|
668
668
|
export { FormBlockProps }
|
|
669
669
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");require("../../../core/components/Input/index.cjs");require("../../../core/components/Textarea/index.cjs");require("../../../core/components/Select/index.cjs");require("../../../core/components/Checkbox/index.cjs");require("../../../core/components/Radio/index.cjs");require("../../../core/components/Fieldset/index.cjs");require("../../../core/components/DatePicker/index.cjs");require("../../../core/components/Range/index.cjs");const e=require("../../../FormField-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");require("../../../core/components/Input/index.cjs");require("../../../core/components/Textarea/index.cjs");require("../../../core/components/Select/index.cjs");require("../../../core/components/Checkbox/index.cjs");require("../../../core/components/Radio/index.cjs");require("../../../core/components/Fieldset/index.cjs");require("../../../core/components/DatePicker/index.cjs");require("../../../core/components/Range/index.cjs");const e=require("../../../FormField-fg7Q2UyZ.cjs");exports.FormField=e.FormField;
|
|
@@ -7,7 +7,7 @@ import "../../../core/components/Radio/index.mjs";
|
|
|
7
7
|
import "../../../core/components/Fieldset/index.mjs";
|
|
8
8
|
import "../../../core/components/DatePicker/index.mjs";
|
|
9
9
|
import "../../../core/components/Range/index.mjs";
|
|
10
|
-
import { F as l } from "../../../FormField-
|
|
10
|
+
import { F as l } from "../../../FormField-Rqe3qF_t.js";
|
|
11
11
|
export {
|
|
12
12
|
l as FormField
|
|
13
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("react"),U=require("../../../core/components/Form/index.cjs"),E=require("../../../index-hPJqlEOh.cjs"),V=require("../../../core/components/ProgressBar/index.cjs"),W=require("../../hooks/useStyleClasses.cjs"),s=require("../../../FormField-fg7Q2UyZ.cjs"),_=require("./validate.cjs");function M(r,t){switch(t.type){case"SET_VALUE":return{...r,values:{...r.values,[t.name]:t.value},errors:{...r.errors,[t.name]:""}};case"SET_ERRORS":return{...r,errors:t.errors};case"CLEAR_ERROR":return{...r,errors:{...r.errors,[t.name]:""}};case"NEXT_STEP":return{...r,currentStep:r.currentStep+1,errors:{}};case"PREV_STEP":return{...r,currentStep:r.currentStep-1,errors:{}};case"SET_SUBMITTING":return{...r,isSubmitting:t.value};case"SET_RESULT":return{...r,submitResult:t.result,isSubmitting:!1};case"RESET":return{...r,currentStep:0,errors:{},submitResult:null,isSubmitting:!1};default:return r}}function A({id:r,heading:t,layout:x="vertical",maxWidth:B="md",steps:p,submitLabel:h="Submit",nextLabel:C="Next",backLabel:T="Back",successMessage:F="Thank you! Your submission has been received.",errorMessage:S="Something went wrong. Please try again.",styleOptions:R,renderRichText:n,onSubmit:v}){const N=W.useStyleClasses(R??{}),j={sm:s.styles.maxWidthSm,md:s.styles.maxWidthMd,lg:s.styles.maxWidthLg,full:s.styles.maxWidthFull}[B],g=u.useMemo(()=>_.buildInitialValues(p),[]),[L,c]=u.useReducer(M,{values:g,errors:{},currentStep:0,isSubmitting:!1,submitResult:null}),{values:i,errors:P,currentStep:m,isSubmitting:d,submitResult:o}=L,y=p.length,k=y>1,f=m===y-1,$=(m+1)/y*100,a=p[m],q=u.useCallback((l,b)=>{c({type:"SET_VALUE",name:l,value:b})},[]),w=u.useCallback(()=>{const l=_.validateStep(a.fields,i);if(Object.keys(l).length>0){c({type:"SET_ERRORS",errors:l});return}c({type:"NEXT_STEP"})},[a.fields,i]),I=u.useCallback(()=>{c({type:"PREV_STEP"})},[]),O=u.useCallback(async()=>{const l=_.validateStep(a.fields,i);if(Object.keys(l).length>0){c({type:"SET_ERRORS",errors:l});return}c({type:"SET_SUBMITTING",value:!0});try{const b=await v(i);c({type:"SET_RESULT",result:b})}catch{c({type:"SET_RESULT",result:{success:!1,message:S}})}},[a.fields,i,v,S]);return o!=null&&o.success?e.jsx("section",{id:r,className:`${s.styles.formBlock} ${N}`,children:e.jsx("div",{className:`${s.styles.formInner} ${j}`,children:e.jsx("div",{className:s.styles.container,children:e.jsxs("div",{className:s.styles.success,children:[e.jsx("p",{children:o.message??F}),e.jsx(E.Button,{as:"button",variant:"secondary",onClick:()=>c({type:"RESET"}),children:"Submit another response"})]})})})}):e.jsx("section",{id:r,className:`${s.styles.formBlock} ${N}`,children:e.jsx("div",{className:`${s.styles.formInner} ${j}`,children:e.jsxs("div",{className:s.styles.container,children:[((t==null?void 0:t.title)||(t==null?void 0:t.description))&&e.jsxs("div",{className:s.styles.heading,children:[t.eyebrow&&(n==null?void 0:n({blocks:t.eyebrow,className:s.styles.eyebrow})),t.title&&(n==null?void 0:n({blocks:t.title,className:s.styles.title})),t.description&&(n==null?void 0:n({blocks:t.description,className:s.styles.description}))]}),k&&e.jsxs("div",{className:s.styles.progress,children:[e.jsxs("div",{className:s.styles.progressHeader,children:[e.jsx("span",{className:s.styles.stepLabel,children:a.title}),e.jsxs("span",{className:s.styles.stepCount,children:[m+1," / ",y]})]}),e.jsx(V.ProgressBar,{progress:$,variant:"primary",size:"sm",showLabel:!1})]}),a.description&&e.jsx("p",{className:s.styles.stepDescription,children:a.description}),o&&!o.success&&e.jsx("div",{className:s.styles.errorBanner,role:"alert",children:o.message??S}),e.jsxs(U.Form,{layout:x,noValidate:!0,onSubmit:l=>{l.preventDefault(),f?O():w()},children:[e.jsx("div",{className:s.styles.fields,children:a.fields.map(l=>e.jsx(s.FormField,{field:l,value:i[l.name.current],error:P[l.name.current],onChange:q},l._key))}),e.jsxs("div",{className:s.styles.actions,children:[k&&m>0&&e.jsx(E.Button,{as:"button",type:"button",variant:"secondary",onClick:I,disabled:d,children:T}),e.jsx(E.Button,{as:"button",type:"submit",variant:"primary",disabled:d,className:s.styles.submitButton,children:d?"Submitting…":f?h:C})]})]})]})})})}exports.FormBlock=A;
|
|
@@ -1,192 +1,199 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { Form as
|
|
4
|
-
import { B as
|
|
1
|
+
import { jsx as t, jsxs as o } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as A, useReducer as D, useCallback as S } from "react";
|
|
3
|
+
import { Form as M } from "../../../core/components/Form/index.mjs";
|
|
4
|
+
import { B as y } from "../../../index-paelIj6o.js";
|
|
5
5
|
import { ProgressBar as G } from "../../../core/components/ProgressBar/index.mjs";
|
|
6
|
-
import { useStyleClasses as
|
|
7
|
-
import { s
|
|
8
|
-
import { buildInitialValues as
|
|
9
|
-
function
|
|
10
|
-
switch (
|
|
6
|
+
import { useStyleClasses as X } from "../../hooks/useStyleClasses.mjs";
|
|
7
|
+
import { s, F as z } from "../../../FormField-Rqe3qF_t.js";
|
|
8
|
+
import { buildInitialValues as H, validateStep as B } from "./validate.mjs";
|
|
9
|
+
function Y(r, e) {
|
|
10
|
+
switch (e.type) {
|
|
11
11
|
case "SET_VALUE":
|
|
12
12
|
return {
|
|
13
|
-
...
|
|
14
|
-
values: { ...
|
|
15
|
-
errors: { ...
|
|
13
|
+
...r,
|
|
14
|
+
values: { ...r.values, [e.name]: e.value },
|
|
15
|
+
errors: { ...r.errors, [e.name]: "" }
|
|
16
16
|
};
|
|
17
17
|
case "SET_ERRORS":
|
|
18
|
-
return { ...
|
|
18
|
+
return { ...r, errors: e.errors };
|
|
19
19
|
case "CLEAR_ERROR":
|
|
20
20
|
return {
|
|
21
|
-
...
|
|
22
|
-
errors: { ...
|
|
21
|
+
...r,
|
|
22
|
+
errors: { ...r.errors, [e.name]: "" }
|
|
23
23
|
};
|
|
24
24
|
case "NEXT_STEP":
|
|
25
|
-
return { ...
|
|
25
|
+
return { ...r, currentStep: r.currentStep + 1, errors: {} };
|
|
26
26
|
case "PREV_STEP":
|
|
27
|
-
return { ...
|
|
27
|
+
return { ...r, currentStep: r.currentStep - 1, errors: {} };
|
|
28
28
|
case "SET_SUBMITTING":
|
|
29
|
-
return { ...
|
|
29
|
+
return { ...r, isSubmitting: e.value };
|
|
30
30
|
case "SET_RESULT":
|
|
31
|
-
return { ...
|
|
31
|
+
return { ...r, submitResult: e.result, isSubmitting: !1 };
|
|
32
32
|
case "RESET":
|
|
33
33
|
return {
|
|
34
|
-
...
|
|
34
|
+
...r,
|
|
35
35
|
currentStep: 0,
|
|
36
36
|
errors: {},
|
|
37
37
|
submitResult: null,
|
|
38
38
|
isSubmitting: !1
|
|
39
39
|
};
|
|
40
40
|
default:
|
|
41
|
-
return
|
|
41
|
+
return r;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
id:
|
|
46
|
-
heading:
|
|
44
|
+
function rs({
|
|
45
|
+
id: r,
|
|
46
|
+
heading: e,
|
|
47
47
|
layout: T = "vertical",
|
|
48
|
-
|
|
48
|
+
maxWidth: L = "md",
|
|
49
|
+
steps: d,
|
|
49
50
|
submitLabel: R = "Submit",
|
|
50
|
-
nextLabel:
|
|
51
|
-
backLabel:
|
|
52
|
-
successMessage:
|
|
53
|
-
errorMessage:
|
|
54
|
-
styleOptions:
|
|
51
|
+
nextLabel: C = "Next",
|
|
52
|
+
backLabel: w = "Back",
|
|
53
|
+
successMessage: P = "Thank you! Your submission has been received.",
|
|
54
|
+
errorMessage: E = "Something went wrong. Please try again.",
|
|
55
|
+
styleOptions: $,
|
|
55
56
|
renderRichText: a,
|
|
56
57
|
onSubmit: v
|
|
57
58
|
}) {
|
|
58
|
-
const N =
|
|
59
|
-
|
|
59
|
+
const N = X($ ?? {}), _ = {
|
|
60
|
+
sm: s.maxWidthSm,
|
|
61
|
+
md: s.maxWidthMd,
|
|
62
|
+
lg: s.maxWidthLg,
|
|
63
|
+
full: s.maxWidthFull
|
|
64
|
+
}[L], g = A(
|
|
65
|
+
() => H(d),
|
|
60
66
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
67
|
[]
|
|
62
|
-
), [
|
|
63
|
-
values:
|
|
68
|
+
), [I, n] = D(Y, {
|
|
69
|
+
values: g,
|
|
64
70
|
errors: {},
|
|
65
71
|
currentStep: 0,
|
|
66
72
|
isSubmitting: !1,
|
|
67
73
|
submitResult: null
|
|
68
|
-
}), { values: u, errors:
|
|
69
|
-
|
|
70
|
-
}, []),
|
|
71
|
-
const
|
|
72
|
-
if (Object.keys(
|
|
73
|
-
|
|
74
|
+
}), { values: u, errors: U, currentStep: m, isSubmitting: b, submitResult: i } = I, p = d.length, h = p > 1, k = m === p - 1, V = (m + 1) / p * 100, c = d[m], F = S((l, f) => {
|
|
75
|
+
n({ type: "SET_VALUE", name: l, value: f });
|
|
76
|
+
}, []), O = S(() => {
|
|
77
|
+
const l = B(c.fields, u);
|
|
78
|
+
if (Object.keys(l).length > 0) {
|
|
79
|
+
n({ type: "SET_ERRORS", errors: l });
|
|
74
80
|
return;
|
|
75
81
|
}
|
|
76
|
-
|
|
77
|
-
}, [
|
|
78
|
-
|
|
82
|
+
n({ type: "NEXT_STEP" });
|
|
83
|
+
}, [c.fields, u]), W = S(() => {
|
|
84
|
+
n({ type: "PREV_STEP" });
|
|
79
85
|
}, []), j = S(async () => {
|
|
80
|
-
const
|
|
81
|
-
if (Object.keys(
|
|
82
|
-
|
|
86
|
+
const l = B(c.fields, u);
|
|
87
|
+
if (Object.keys(l).length > 0) {
|
|
88
|
+
n({ type: "SET_ERRORS", errors: l });
|
|
83
89
|
return;
|
|
84
90
|
}
|
|
85
|
-
|
|
91
|
+
n({ type: "SET_SUBMITTING", value: !0 });
|
|
86
92
|
try {
|
|
87
|
-
const
|
|
88
|
-
|
|
93
|
+
const f = await v(u);
|
|
94
|
+
n({ type: "SET_RESULT", result: f });
|
|
89
95
|
} catch {
|
|
90
|
-
|
|
96
|
+
n({
|
|
91
97
|
type: "SET_RESULT",
|
|
92
|
-
result: { success: !1, message:
|
|
98
|
+
result: { success: !1, message: E }
|
|
93
99
|
});
|
|
94
100
|
}
|
|
95
|
-
}, [
|
|
96
|
-
return i != null && i.success ? /* @__PURE__ */
|
|
97
|
-
/* @__PURE__ */
|
|
98
|
-
/* @__PURE__ */
|
|
99
|
-
|
|
101
|
+
}, [c.fields, u, v, E]);
|
|
102
|
+
return i != null && i.success ? /* @__PURE__ */ t("section", { id: r, className: `${s.formBlock} ${N}`, children: /* @__PURE__ */ t("div", { className: `${s.formInner} ${_}`, children: /* @__PURE__ */ t("div", { className: s.container, children: /* @__PURE__ */ o("div", { className: s.success, children: [
|
|
103
|
+
/* @__PURE__ */ t("p", { children: i.message ?? P }),
|
|
104
|
+
/* @__PURE__ */ t(
|
|
105
|
+
y,
|
|
100
106
|
{
|
|
101
107
|
as: "button",
|
|
102
108
|
variant: "secondary",
|
|
103
|
-
onClick: () =>
|
|
109
|
+
onClick: () => n({ type: "RESET" }),
|
|
104
110
|
children: "Submit another response"
|
|
105
111
|
}
|
|
106
112
|
)
|
|
107
|
-
] }) }) }) : /* @__PURE__ */
|
|
108
|
-
((
|
|
109
|
-
|
|
110
|
-
blocks:
|
|
111
|
-
className:
|
|
113
|
+
] }) }) }) }) : /* @__PURE__ */ t("section", { id: r, className: `${s.formBlock} ${N}`, children: /* @__PURE__ */ t("div", { className: `${s.formInner} ${_}`, children: /* @__PURE__ */ o("div", { className: s.container, children: [
|
|
114
|
+
((e == null ? void 0 : e.title) || (e == null ? void 0 : e.description)) && /* @__PURE__ */ o("div", { className: s.heading, children: [
|
|
115
|
+
e.eyebrow && (a == null ? void 0 : a({
|
|
116
|
+
blocks: e.eyebrow,
|
|
117
|
+
className: s.eyebrow
|
|
112
118
|
})),
|
|
113
|
-
|
|
114
|
-
blocks:
|
|
115
|
-
className:
|
|
119
|
+
e.title && (a == null ? void 0 : a({
|
|
120
|
+
blocks: e.title,
|
|
121
|
+
className: s.title
|
|
116
122
|
})),
|
|
117
|
-
|
|
118
|
-
blocks:
|
|
123
|
+
e.description && (a == null ? void 0 : a({
|
|
124
|
+
blocks: e.description,
|
|
125
|
+
className: s.description
|
|
119
126
|
}))
|
|
120
127
|
] }),
|
|
121
|
-
|
|
122
|
-
/* @__PURE__ */
|
|
123
|
-
/* @__PURE__ */
|
|
124
|
-
/* @__PURE__ */
|
|
128
|
+
h && /* @__PURE__ */ o("div", { className: s.progress, children: [
|
|
129
|
+
/* @__PURE__ */ o("div", { className: s.progressHeader, children: [
|
|
130
|
+
/* @__PURE__ */ t("span", { className: s.stepLabel, children: c.title }),
|
|
131
|
+
/* @__PURE__ */ o("span", { className: s.stepCount, children: [
|
|
125
132
|
m + 1,
|
|
126
133
|
" / ",
|
|
127
134
|
p
|
|
128
135
|
] })
|
|
129
136
|
] }),
|
|
130
|
-
/* @__PURE__ */
|
|
137
|
+
/* @__PURE__ */ t(
|
|
131
138
|
G,
|
|
132
139
|
{
|
|
133
|
-
progress:
|
|
140
|
+
progress: V,
|
|
134
141
|
variant: "primary",
|
|
135
142
|
size: "sm",
|
|
136
143
|
showLabel: !1
|
|
137
144
|
}
|
|
138
145
|
)
|
|
139
146
|
] }),
|
|
140
|
-
|
|
141
|
-
i && !i.success && /* @__PURE__ */
|
|
142
|
-
/* @__PURE__ */
|
|
143
|
-
|
|
147
|
+
c.description && /* @__PURE__ */ t("p", { className: s.stepDescription, children: c.description }),
|
|
148
|
+
i && !i.success && /* @__PURE__ */ t("div", { className: s.errorBanner, role: "alert", children: i.message ?? E }),
|
|
149
|
+
/* @__PURE__ */ o(
|
|
150
|
+
M,
|
|
144
151
|
{
|
|
145
152
|
layout: T,
|
|
146
153
|
noValidate: !0,
|
|
147
|
-
onSubmit: (
|
|
148
|
-
|
|
154
|
+
onSubmit: (l) => {
|
|
155
|
+
l.preventDefault(), k ? j() : O();
|
|
149
156
|
},
|
|
150
157
|
children: [
|
|
151
|
-
/* @__PURE__ */
|
|
152
|
-
|
|
158
|
+
/* @__PURE__ */ t("div", { className: s.fields, children: c.fields.map((l) => /* @__PURE__ */ t(
|
|
159
|
+
z,
|
|
153
160
|
{
|
|
154
|
-
field:
|
|
155
|
-
value: u[
|
|
156
|
-
error:
|
|
157
|
-
onChange:
|
|
161
|
+
field: l,
|
|
162
|
+
value: u[l.name.current],
|
|
163
|
+
error: U[l.name.current],
|
|
164
|
+
onChange: F
|
|
158
165
|
},
|
|
159
|
-
|
|
166
|
+
l._key
|
|
160
167
|
)) }),
|
|
161
|
-
/* @__PURE__ */
|
|
162
|
-
|
|
163
|
-
|
|
168
|
+
/* @__PURE__ */ o("div", { className: s.actions, children: [
|
|
169
|
+
h && m > 0 && /* @__PURE__ */ t(
|
|
170
|
+
y,
|
|
164
171
|
{
|
|
165
172
|
as: "button",
|
|
166
173
|
type: "button",
|
|
167
174
|
variant: "secondary",
|
|
168
|
-
onClick:
|
|
169
|
-
disabled:
|
|
170
|
-
children:
|
|
175
|
+
onClick: W,
|
|
176
|
+
disabled: b,
|
|
177
|
+
children: w
|
|
171
178
|
}
|
|
172
179
|
),
|
|
173
|
-
/* @__PURE__ */
|
|
174
|
-
|
|
180
|
+
/* @__PURE__ */ t(
|
|
181
|
+
y,
|
|
175
182
|
{
|
|
176
183
|
as: "button",
|
|
177
184
|
type: "submit",
|
|
178
185
|
variant: "primary",
|
|
179
|
-
disabled:
|
|
180
|
-
className:
|
|
181
|
-
children:
|
|
186
|
+
disabled: b,
|
|
187
|
+
className: s.submitButton,
|
|
188
|
+
children: b ? "Submitting…" : k ? R : C
|
|
182
189
|
}
|
|
183
190
|
)
|
|
184
191
|
] })
|
|
185
192
|
]
|
|
186
193
|
}
|
|
187
194
|
)
|
|
188
|
-
] }) });
|
|
195
|
+
] }) }) });
|
|
189
196
|
}
|
|
190
197
|
export {
|
|
191
|
-
|
|
198
|
+
rs as FormBlock
|
|
192
199
|
};
|
package/dist/next.d.ts
CHANGED
|
@@ -168,7 +168,7 @@ export declare function FeaturedDocumentsBlock({ heading, selectionMode, layout,
|
|
|
168
168
|
|
|
169
169
|
export { FeaturedDocumentsBlockProps }
|
|
170
170
|
|
|
171
|
-
export declare function FormBlock({ id, heading, layout, steps, submitLabel, nextLabel, backLabel, successMessage, errorMessage, styleOptions, renderRichText, onSubmit, }: FormBlockProps_2): JSX.Element;
|
|
171
|
+
export declare function FormBlock({ id, heading, layout, maxWidth, steps, submitLabel, nextLabel, backLabel, successMessage, errorMessage, styleOptions, renderRichText, onSubmit, }: FormBlockProps_2): JSX.Element;
|
|
172
172
|
|
|
173
173
|
export { FormBlockProps }
|
|
174
174
|
|