quirk-ui 0.1.76 → 0.1.77
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-CtUZKmKE.cjs +1 -0
- package/dist/{FormField-BO1hKjUb.js → FormField-J7D8joVl.js} +86 -81
- package/dist/FormField.css +1 -1
- package/dist/FormField.css.d.ts +23 -18
- 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/FormField-wfYSN1Vd.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require('./FormField.css');const a=require("react/jsx-runtime"),q=require("./core/components/Input/index.cjs"),T=require("./core/components/Textarea/index.cjs"),h=require("./core/components/Select/index.cjs"),_=require("./core/components/Checkbox/index.cjs"),k=require("./core/components/Radio/index.cjs"),p=require("./core/components/Fieldset/index.cjs"),W=require("./core/components/DatePicker/index.cjs"),F=require("./core/components/Range/index.cjs"),j="_formBlock_cu3uh_1",C="_container_cu3uh_7",w="_formInner_cu3uh_20",L="_maxWidthSm_cu3uh_24",y="_maxWidthMd_cu3uh_27",S="_maxWidthLg_cu3uh_30",B="_maxWidthFull_cu3uh_33",$="_heading_cu3uh_39",H="_eyebrow_cu3uh_45",G="_title_cu3uh_49",I="_progress_cu3uh_55",M="_progressHeader_cu3uh_61",D="_stepLabel_cu3uh_67",O="_stepCount_cu3uh_73",P="_stepDescription_cu3uh_78",R="_fields_cu3uh_86",V="_fieldFull_cu3uh_93",f="_fieldHalf_cu3uh_97",N="_fieldThird_cu3uh_105",z="_actions_cu3uh_115",A="_submitButton_cu3uh_122",E="_success_cu3uh_128",J="_errorBanner_cu3uh_141",i={formBlock:j,container:C,formInner:w,maxWidthSm:L,maxWidthMd:y,maxWidthLg:S,maxWidthFull:B,heading:$,eyebrow:H,title:G,progress:I,progressHeader:M,stepLabel:D,stepCount:O,stepDescription:P,fields:R,fieldFull:V,fieldHalf:f,fieldThird:N,actions:z,submitButton:A,success:E,errorBanner:J};function l(e){return(e??[]).map(n=>({label:n.label,value:n.value.current,disabled:n.disabled}))}function m(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:c}){const r=e.name.current,x={full:i.fieldFull,half:i.fieldHalf,third:i.fieldThird}[e.width??"full"],o={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(q.Input,{...o,type:e.fieldType==="phone"?"tel":e.fieldType,placeholder:e.placeholder,value:n??"",minLength:e.minLength,maxLength:e.maxLength,fullWidth:!0,onChange:t=>c(r,t.target.value)});case"textarea":return a.jsx(T.Textarea,{...o,placeholder:e.placeholder,value:n??"",rows:e.rows??4,maxLength:e.maxLength,showCharCount:e.showCharCount,fullWidth:!0,onChange:t=>c(r,t.target.value)});case"select":{const t=e.useOptionGroups?m(e.optionGroups):l(e.options);return a.jsx(h.Select,{...o,placeholder:e.placeholder,options:t,value:n??"",fullWidth:!0,onChange:u=>c(r,u.target.value)})}case"multiselect":{const t=e.useOptionGroups?m(e.optionGroups):l(e.options);return a.jsx(h.Select,{...o,multiple:!0,options:t,value:n??[],showSelectedCount:!0,onChange:u=>c(r,u)})}case"checkbox":return a.jsx(_.Checkbox,{id:o.id,name:o.name,label:e.label,required:e.required,disabled:e.disabled,helperText:s??e.helperText,error:!!s,checked:n??!1,onChange:t=>c(r,t.target.checked)});case"checkboxGroup":{const t=n??[];return a.jsx(p.Fieldset,{legend:e.label,error:!!s,helperText:s,children:l(e.options).map(u=>a.jsx(_.Checkbox,{id:`${r}-${u.value}`,name:`${r}[]`,label:u.label,checked:t.includes(u.value),disabled:u.disabled||e.disabled,onChange:b=>{const g=b.target.checked?[...t,u.value]:t.filter(v=>v!==u.value);c(r,g)}},u.value))})}case"radio":return a.jsx(p.Fieldset,{legend:e.label,error:!!s,helperText:s,children:l(e.options).map(t=>a.jsx(k.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:()=>c(r,t.value)},t.value))});case"date":return a.jsx(W.DatePicker,{id:o.id,name:o.name,label:e.label,required:e.required,disabled:e.disabled,helperText:s??e.helperText,error:!!s,value:n??null,onChange:t=>c(r,t)});case"range":return a.jsx(F.Range,{...o,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=>c(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:`${x}`,children:d()})}exports.FormField=K;exports.styles=i;
|
|
@@ -1,31 +1,36 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Input as
|
|
3
|
-
import { Textarea as
|
|
4
|
-
import { Select as
|
|
5
|
-
import { Checkbox as
|
|
6
|
-
import { Radio as
|
|
7
|
-
import { Fieldset as
|
|
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
|
-
|
|
1
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
2
|
+
import { Input as T } from "./core/components/Input/index.mjs";
|
|
3
|
+
import { Textarea as W } from "./core/components/Textarea/index.mjs";
|
|
4
|
+
import { Select as d } from "./core/components/Select/index.mjs";
|
|
5
|
+
import { Checkbox as m } from "./core/components/Checkbox/index.mjs";
|
|
6
|
+
import { Radio as f } from "./core/components/Radio/index.mjs";
|
|
7
|
+
import { Fieldset as p } from "./core/components/Fieldset/index.mjs";
|
|
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_cu3uh_1", C = "_container_cu3uh_7", F = "_formInner_cu3uh_20", y = "_maxWidthSm_cu3uh_24", B = "_maxWidthMd_cu3uh_27", q = "_maxWidthLg_cu3uh_30", S = "_maxWidthFull_cu3uh_33", H = "_heading_cu3uh_39", G = "_eyebrow_cu3uh_45", M = "_title_cu3uh_49", $ = "_progress_cu3uh_55", I = "_progressHeader_cu3uh_61", D = "_stepLabel_cu3uh_67", O = "_stepCount_cu3uh_73", V = "_stepDescription_cu3uh_78", P = "_fields_cu3uh_86", R = "_fieldFull_cu3uh_93", j = "_fieldHalf_cu3uh_97", N = "_fieldThird_cu3uh_105", z = "_actions_cu3uh_115", A = "_submitButton_cu3uh_122", E = "_success_cu3uh_128", J = "_errorBanner_cu3uh_141", i = {
|
|
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
35
|
function c(e) {
|
|
31
36
|
return (e ?? []).map((r) => ({
|
|
@@ -34,7 +39,7 @@ function c(e) {
|
|
|
34
39
|
disabled: r.disabled
|
|
35
40
|
}));
|
|
36
41
|
}
|
|
37
|
-
function
|
|
42
|
+
function _(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
|
|
48
|
-
const a = e.name.current,
|
|
52
|
+
function ae({ field: e, value: r, error: n, onChange: l }) {
|
|
53
|
+
const a = e.name.current, b = {
|
|
49
54
|
full: i.fieldFull,
|
|
50
55
|
half: i.fieldHalf,
|
|
51
56
|
third: i.fieldThird
|
|
52
|
-
}[e.width ?? "full"],
|
|
57
|
+
}[e.width ?? "full"], o = {
|
|
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
|
+
}, h = () => {
|
|
61
66
|
switch (e.fieldType) {
|
|
62
67
|
// ── Text-based inputs ──────────────────────────────────────────────
|
|
63
68
|
case "text":
|
|
@@ -65,103 +70,103 @@ function Y({ field: e, value: r, error: n, onChange: o }) {
|
|
|
65
70
|
case "phone":
|
|
66
71
|
case "number":
|
|
67
72
|
case "url":
|
|
68
|
-
return /* @__PURE__ */
|
|
69
|
-
|
|
73
|
+
return /* @__PURE__ */ u(
|
|
74
|
+
T,
|
|
70
75
|
{
|
|
71
|
-
...
|
|
76
|
+
...o,
|
|
72
77
|
type: e.fieldType === "phone" ? "tel" : e.fieldType,
|
|
73
78
|
placeholder: e.placeholder,
|
|
74
79
|
value: r ?? "",
|
|
75
80
|
minLength: e.minLength,
|
|
76
81
|
maxLength: e.maxLength,
|
|
77
82
|
fullWidth: !0,
|
|
78
|
-
onChange: (t) =>
|
|
83
|
+
onChange: (t) => l(a, t.target.value)
|
|
79
84
|
}
|
|
80
85
|
);
|
|
81
86
|
// ── Textarea ───────────────────────────────────────────────────────
|
|
82
87
|
case "textarea":
|
|
83
|
-
return /* @__PURE__ */
|
|
84
|
-
|
|
88
|
+
return /* @__PURE__ */ u(
|
|
89
|
+
W,
|
|
85
90
|
{
|
|
86
|
-
...
|
|
91
|
+
...o,
|
|
87
92
|
placeholder: e.placeholder,
|
|
88
93
|
value: r ?? "",
|
|
89
94
|
rows: e.rows ?? 4,
|
|
90
95
|
maxLength: e.maxLength,
|
|
91
96
|
showCharCount: e.showCharCount,
|
|
92
97
|
fullWidth: !0,
|
|
93
|
-
onChange: (t) =>
|
|
98
|
+
onChange: (t) => l(a, t.target.value)
|
|
94
99
|
}
|
|
95
100
|
);
|
|
96
101
|
// ── Select ─────────────────────────────────────────────────────────
|
|
97
102
|
case "select": {
|
|
98
|
-
const t = e.useOptionGroups ?
|
|
99
|
-
return /* @__PURE__ */
|
|
100
|
-
|
|
103
|
+
const t = e.useOptionGroups ? _(e.optionGroups) : c(e.options);
|
|
104
|
+
return /* @__PURE__ */ u(
|
|
105
|
+
d,
|
|
101
106
|
{
|
|
102
|
-
...
|
|
107
|
+
...o,
|
|
103
108
|
placeholder: e.placeholder,
|
|
104
109
|
options: t,
|
|
105
110
|
value: r ?? "",
|
|
106
111
|
fullWidth: !0,
|
|
107
|
-
onChange: (
|
|
112
|
+
onChange: (s) => l(a, s.target.value)
|
|
108
113
|
}
|
|
109
114
|
);
|
|
110
115
|
}
|
|
111
116
|
// ── Multi-select ───────────────────────────────────────────────────
|
|
112
117
|
case "multiselect": {
|
|
113
|
-
const t = e.useOptionGroups ?
|
|
114
|
-
return /* @__PURE__ */
|
|
115
|
-
|
|
118
|
+
const t = e.useOptionGroups ? _(e.optionGroups) : c(e.options);
|
|
119
|
+
return /* @__PURE__ */ u(
|
|
120
|
+
d,
|
|
116
121
|
{
|
|
117
|
-
...
|
|
122
|
+
...o,
|
|
118
123
|
multiple: !0,
|
|
119
124
|
options: t,
|
|
120
125
|
value: r ?? [],
|
|
121
126
|
showSelectedCount: !0,
|
|
122
|
-
onChange: (
|
|
127
|
+
onChange: (s) => l(a, s)
|
|
123
128
|
}
|
|
124
129
|
);
|
|
125
130
|
}
|
|
126
131
|
// ── Single checkbox ────────────────────────────────────────────────
|
|
127
132
|
case "checkbox":
|
|
128
|
-
return /* @__PURE__ */
|
|
129
|
-
|
|
133
|
+
return /* @__PURE__ */ u(
|
|
134
|
+
m,
|
|
130
135
|
{
|
|
131
|
-
id:
|
|
132
|
-
name:
|
|
136
|
+
id: o.id,
|
|
137
|
+
name: o.name,
|
|
133
138
|
label: e.label,
|
|
134
139
|
required: e.required,
|
|
135
140
|
disabled: e.disabled,
|
|
136
141
|
helperText: n ?? e.helperText,
|
|
137
142
|
error: !!n,
|
|
138
143
|
checked: r ?? !1,
|
|
139
|
-
onChange: (t) =>
|
|
144
|
+
onChange: (t) => l(a, t.target.checked)
|
|
140
145
|
}
|
|
141
146
|
);
|
|
142
147
|
// ── Checkbox group ─────────────────────────────────────────────────
|
|
143
148
|
case "checkboxGroup": {
|
|
144
149
|
const t = r ?? [];
|
|
145
|
-
return /* @__PURE__ */
|
|
146
|
-
|
|
150
|
+
return /* @__PURE__ */ u(p, { legend: e.label, error: !!n, helperText: n, children: c(e.options).map((s) => /* @__PURE__ */ u(
|
|
151
|
+
m,
|
|
147
152
|
{
|
|
148
|
-
id: `${a}-${
|
|
153
|
+
id: `${a}-${s.value}`,
|
|
149
154
|
name: `${a}[]`,
|
|
150
|
-
label:
|
|
151
|
-
checked: t.includes(
|
|
152
|
-
disabled:
|
|
153
|
-
onChange: (
|
|
154
|
-
const
|
|
155
|
-
|
|
155
|
+
label: s.label,
|
|
156
|
+
checked: t.includes(s.value),
|
|
157
|
+
disabled: s.disabled || e.disabled,
|
|
158
|
+
onChange: (x) => {
|
|
159
|
+
const g = x.target.checked ? [...t, s.value] : t.filter((v) => v !== s.value);
|
|
160
|
+
l(a, g);
|
|
156
161
|
}
|
|
157
162
|
},
|
|
158
|
-
|
|
163
|
+
s.value
|
|
159
164
|
)) });
|
|
160
165
|
}
|
|
161
166
|
// ── Radio group ────────────────────────────────────────────────────
|
|
162
167
|
case "radio":
|
|
163
|
-
return /* @__PURE__ */
|
|
164
|
-
|
|
168
|
+
return /* @__PURE__ */ u(p, { legend: e.label, error: !!n, helperText: n, children: c(e.options).map((t) => /* @__PURE__ */ u(
|
|
169
|
+
f,
|
|
165
170
|
{
|
|
166
171
|
id: `${a}-${t.value}`,
|
|
167
172
|
name: a,
|
|
@@ -170,32 +175,32 @@ function Y({ field: e, value: r, error: n, onChange: o }) {
|
|
|
170
175
|
checked: r === t.value,
|
|
171
176
|
disabled: t.disabled || e.disabled,
|
|
172
177
|
required: e.required,
|
|
173
|
-
onChange: () =>
|
|
178
|
+
onChange: () => l(a, t.value)
|
|
174
179
|
},
|
|
175
180
|
t.value
|
|
176
181
|
)) });
|
|
177
182
|
// ── Date picker ────────────────────────────────────────────────────
|
|
178
183
|
case "date":
|
|
179
|
-
return /* @__PURE__ */
|
|
180
|
-
|
|
184
|
+
return /* @__PURE__ */ u(
|
|
185
|
+
k,
|
|
181
186
|
{
|
|
182
|
-
id:
|
|
183
|
-
name:
|
|
187
|
+
id: o.id,
|
|
188
|
+
name: o.name,
|
|
184
189
|
label: e.label,
|
|
185
190
|
required: e.required,
|
|
186
191
|
disabled: e.disabled,
|
|
187
192
|
helperText: n ?? e.helperText,
|
|
188
193
|
error: !!n,
|
|
189
194
|
value: r ?? null,
|
|
190
|
-
onChange: (t) =>
|
|
195
|
+
onChange: (t) => l(a, t)
|
|
191
196
|
}
|
|
192
197
|
);
|
|
193
198
|
// ── Range ──────────────────────────────────────────────────────────
|
|
194
199
|
case "range":
|
|
195
|
-
return /* @__PURE__ */
|
|
196
|
-
|
|
200
|
+
return /* @__PURE__ */ u(
|
|
201
|
+
w,
|
|
197
202
|
{
|
|
198
|
-
...
|
|
203
|
+
...o,
|
|
199
204
|
value: r ?? e.rangeMin ?? 0,
|
|
200
205
|
min: e.rangeMin ?? 0,
|
|
201
206
|
max: e.rangeMax ?? 100,
|
|
@@ -203,12 +208,12 @@ function Y({ field: e, value: r, error: n, onChange: o }) {
|
|
|
203
208
|
valuePrefix: e.rangeValuePrefix,
|
|
204
209
|
valueSuffix: e.rangeValueSuffix,
|
|
205
210
|
showValue: !0,
|
|
206
|
-
onChange: (t) =>
|
|
211
|
+
onChange: (t) => l(a, t)
|
|
207
212
|
}
|
|
208
213
|
);
|
|
209
214
|
// ── Hidden ─────────────────────────────────────────────────────────
|
|
210
215
|
case "hidden":
|
|
211
|
-
return /* @__PURE__ */
|
|
216
|
+
return /* @__PURE__ */ u(
|
|
212
217
|
"input",
|
|
213
218
|
{
|
|
214
219
|
type: "hidden",
|
|
@@ -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" ? h() : /* @__PURE__ */ u("div", { className: `${b}`, children: h() });
|
|
224
229
|
}
|
|
225
230
|
export {
|
|
226
|
-
|
|
231
|
+
ae as F,
|
|
227
232
|
i as s
|
|
228
233
|
};
|
package/dist/FormField.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._formBlock_cu3uh_1{width:100%;padding-top:var(--spacing-xl);padding-bottom:var(--spacing-xl)}._container_cu3uh_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_cu3uh_20{width:100%}._maxWidthSm_cu3uh_24{max-width:480px}._maxWidthMd_cu3uh_27{max-width:640px}._maxWidthLg_cu3uh_30{max-width:800px}._maxWidthFull_cu3uh_33{max-width:100%}._heading_cu3uh_39{display:flex;flex-direction:column;gap:var(--spacing-sm)}._eyebrow_cu3uh_45{font-weight:var(--font-weight-bold)}._title_cu3uh_49{text-wrap:balance}._progress_cu3uh_55{display:flex;flex-direction:column;gap:var(--spacing-sm)}._progressHeader_cu3uh_61{display:flex;justify-content:space-between;align-items:center}._stepLabel_cu3uh_67{font-weight:var(--font-weight-semibold);font-size:var(--font-size-md);color:var(--color-text-primary)}._stepCount_cu3uh_73{font-size:var(--font-size-sm);color:var(--color-secondary-50)}._stepDescription_cu3uh_78{color:var(--color-secondary-75);font-size:var(--font-size-md);margin:0}._fields_cu3uh_86{display:flex;flex-wrap:wrap;gap:var(--spacing-md)}._fieldFull_cu3uh_93{width:100%}._fieldHalf_cu3uh_97{width:calc(50% - var(--spacing-md) / 2)}@media (max-width: 767px){._fieldHalf_cu3uh_97{width:100%}}._fieldThird_cu3uh_105{width:calc(33.333% - var(--spacing-md) * 2 / 3)}@media (max-width: 767px){._fieldThird_cu3uh_105{width:100%}}._actions_cu3uh_115{display:flex;align-items:center;gap:var(--spacing-md);padding-top:var(--spacing-sm)}._submitButton_cu3uh_122{margin-left:auto}._success_cu3uh_128{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_cu3uh_141{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/FormField.css.d.ts
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
declare const styles: {
|
|
2
|
-
readonly "
|
|
3
|
-
readonly "
|
|
4
|
-
readonly "
|
|
5
|
-
readonly "
|
|
6
|
-
readonly "
|
|
7
|
-
readonly "
|
|
8
|
-
readonly "
|
|
9
|
-
readonly "
|
|
10
|
-
readonly "
|
|
11
|
-
readonly "
|
|
12
|
-
readonly "
|
|
13
|
-
readonly "
|
|
14
|
-
readonly "
|
|
15
|
-
readonly "
|
|
16
|
-
readonly "
|
|
17
|
-
readonly "
|
|
18
|
-
readonly "
|
|
19
|
-
readonly "
|
|
2
|
+
readonly "_actions_cu3uh_115": string;
|
|
3
|
+
readonly "_container_cu3uh_7": string;
|
|
4
|
+
readonly "_errorBanner_cu3uh_141": string;
|
|
5
|
+
readonly "_eyebrow_cu3uh_45": string;
|
|
6
|
+
readonly "_fieldFull_cu3uh_93": string;
|
|
7
|
+
readonly "_fieldHalf_cu3uh_97": string;
|
|
8
|
+
readonly "_fieldThird_cu3uh_105": string;
|
|
9
|
+
readonly "_fields_cu3uh_86": string;
|
|
10
|
+
readonly "_formBlock_cu3uh_1": string;
|
|
11
|
+
readonly "_formInner_cu3uh_20": string;
|
|
12
|
+
readonly "_heading_cu3uh_39": string;
|
|
13
|
+
readonly "_maxWidthFull_cu3uh_33": string;
|
|
14
|
+
readonly "_maxWidthLg_cu3uh_30": string;
|
|
15
|
+
readonly "_maxWidthMd_cu3uh_27": string;
|
|
16
|
+
readonly "_maxWidthSm_cu3uh_24": string;
|
|
17
|
+
readonly "_progressHeader_cu3uh_61": string;
|
|
18
|
+
readonly "_progress_cu3uh_55": string;
|
|
19
|
+
readonly "_stepCount_cu3uh_73": string;
|
|
20
|
+
readonly "_stepDescription_cu3uh_78": string;
|
|
21
|
+
readonly "_stepLabel_cu3uh_67": string;
|
|
22
|
+
readonly "_submitButton_cu3uh_122": string;
|
|
23
|
+
readonly "_success_cu3uh_128": string;
|
|
24
|
+
readonly "_title_cu3uh_49": string;
|
|
20
25
|
};
|
|
21
26
|
export = styles;
|
|
22
27
|
|
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-CtUZKmKE.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-J7D8joVl.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-CtUZKmKE.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-J7D8joVl.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
|
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";require('./FormField.css');const a=require("react/jsx-runtime"),w=require("./core/components/Input/index.cjs"),v=require("./core/components/Textarea/index.cjs"),_=require("./core/components/Select/index.cjs"),p=require("./core/components/Checkbox/index.cjs"),z=require("./core/components/Radio/index.cjs"),g=require("./core/components/Fieldset/index.cjs"),T=require("./core/components/DatePicker/index.cjs"),k=require("./core/components/Range/index.cjs"),j="_formBlock_wgqzg_1",C="_container_wgqzg_7",y="_heading_wgqzg_20",F="_eyebrow_wgqzg_26",B="_title_wgqzg_30",L="_progress_wgqzg_36",$="_progressHeader_wgqzg_42",H="_stepLabel_wgqzg_48",S="_stepCount_wgqzg_54",G="_stepDescription_wgqzg_59",D="_fields_wgqzg_67",O="_fieldFull_wgqzg_74",P="_fieldHalf_wgqzg_78",R="_fieldThird_wgqzg_86",V="_actions_wgqzg_96",I="_submitButton_wgqzg_103",M="_success_wgqzg_109",W="_errorBanner_wgqzg_122",i={formBlock:j,container:C,heading:y,eyebrow:F,title:B,progress:L,progressHeader:$,stepLabel:H,stepCount:S,stepDescription:G,fields:D,fieldFull:O,fieldHalf:P,fieldThird:R,actions:V,submitButton:I,success:M,errorBanner:W};function u(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 N({field:e,value:n,error:s,onChange:l}){const r=e.name.current,b={full:i.fieldFull,half:i.fieldHalf,third:i.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(w.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(v.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):u(e.options);return a.jsx(_.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):u(e.options);return a.jsx(_.Select,{...c,multiple:!0,options:t,value:n??[],showSelectedCount:!0,onChange:o=>l(r,o)})}case"checkbox":return a.jsx(p.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(g.Fieldset,{legend:e.label,error:!!s,helperText:s,children:u(e.options).map(o=>a.jsx(p.Checkbox,{id:`${r}-${o.value}`,name:`${r}[]`,label:o.label,checked:t.includes(o.value),disabled:o.disabled||e.disabled,onChange:x=>{const m=x.target.checked?[...t,o.value]:t.filter(q=>q!==o.value);l(r,m)}},o.value))})}case"radio":return a.jsx(g.Fieldset,{legend:e.label,error:!!s,helperText:s,children:u(e.options).map(t=>a.jsx(z.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(T.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(k.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:`${b}`,children:d()})}exports.FormField=N;exports.styles=i;
|