quirk-ui 0.1.180 → 0.1.181
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-LSFCBISi.cjs +1 -0
- package/dist/{FormField-CWdr56Tp.js → FormField-oa2piuZf.js} +60 -60
- package/dist/FormField.css +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 +1 -1
- package/package.json +1 -1
- package/dist/FormField-Cy_aF1xz.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require('./FormField.css');const s=require("react/jsx-runtime"),q=require("./core/components/Input/index.cjs"),T=require("./core/components/Textarea/index.cjs"),_=require("./core/components/Select/index.cjs"),h=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_1taaa_1",C="_container_1taaa_7",w="_formInner_1taaa_20",L="_maxWidthSm_1taaa_26",y="_maxWidthMd_1taaa_29",S="_maxWidthLg_1taaa_32",B="_maxWidthFull_1taaa_35",$="_heading_1taaa_41",H="_eyebrow_1taaa_47",G="_title_1taaa_51",I="_disclaimer_1taaa_55",M="_progress_1taaa_61",D="_progressHeader_1taaa_67",O="_stepLabel_1taaa_73",P="_stepCount_1taaa_79",R="_stepDescription_1taaa_84",V="_fields_1taaa_92",f="_fieldFull_1taaa_99",N="_fieldHalf_1taaa_103",z="_fieldThird_1taaa_111",A="_actions_1taaa_121",E="_submitButton_1taaa_128",J="_success_1taaa_134",K="_errorBanner_1taaa_149",u={formBlock:j,container:C,formInner:w,maxWidthSm:L,maxWidthMd:y,maxWidthLg:S,maxWidthFull:B,heading:$,eyebrow:H,title:G,disclaimer:I,progress:M,progressHeader:D,stepLabel:O,stepCount:P,stepDescription:R,fields:V,fieldFull:f,fieldHalf:N,fieldThird:z,actions:A,submitButton:E,success:J,errorBanner:K};function i(e){return(e??[]).map(t=>({label:t.label,value:t.value.current,disabled:t.disabled}))}function m(e){return(e??[]).map(t=>({label:t.label,options:t.options.map(r=>({label:r.label,value:r.value.current,disabled:r.disabled}))}))}function Q({field:e,value:t,error:r,onChange:l}){const n=e.name.current,x={full:u.fieldFull,half:u.fieldHalf,third:u.fieldThird}[e.width??"full"],c={id:n,name:n,label:e.label,required:e.required,disabled:e.disabled,helperText:e.helperText,error:r},d=()=>{switch(e.fieldType){case"text":case"email":case"phone":case"number":case"url":return s.jsx(q.Input,{...c,type:e.fieldType==="phone"?"tel":e.fieldType,placeholder:e.placeholder,value:t??"",minLength:e.minLength,maxLength:e.maxLength,fullWidth:!0,onChange:a=>l(n,a.target.value)});case"textarea":return s.jsx(T.Textarea,{...c,placeholder:e.placeholder,value:t??"",rows:e.rows??4,maxLength:e.maxLength,showCharCount:e.showCharCount,fullWidth:!0,onChange:a=>l(n,a.target.value)});case"select":{const a=e.useOptionGroups?m(e.optionGroups):i(e.options);return s.jsx(_.Select,{...c,placeholder:e.placeholder,options:a,value:t??"",fullWidth:!0,onChange:o=>l(n,o.target.value)})}case"multiselect":{const a=e.useOptionGroups?m(e.optionGroups):i(e.options);return s.jsx(_.Select,{...c,multiple:!0,options:a,value:t??[],showSelectedCount:!0,onChange:o=>l(n,o)})}case"checkbox":return s.jsx(h.Checkbox,{id:c.id,name:c.name,label:e.label,required:e.required,disabled:e.disabled,helperText:r??e.helperText,error:!!r,checked:t??!1,onChange:a=>l(n,a.target.checked)});case"checkboxGroup":{const a=t??[];return s.jsx(p.Fieldset,{legend:e.label,error:!!r,helperText:r,children:i(e.options).map(o=>s.jsx(h.Checkbox,{id:`${n}-${o.value}`,name:`${n}[]`,label:o.label,checked:a.includes(o.value),disabled:o.disabled||e.disabled,onChange:b=>{const g=b.target.checked?[...a,o.value]:a.filter(v=>v!==o.value);l(n,g)}},o.value))})}case"radio":return s.jsx(p.Fieldset,{legend:e.label,error:!!r,helperText:r,children:i(e.options).map(a=>s.jsx(k.Radio,{id:`${n}-${a.value}`,name:n,value:a.value,label:a.label,checked:t===a.value,disabled:a.disabled||e.disabled,required:e.required,onChange:()=>l(n,a.value)},a.value))});case"date":return s.jsx(W.DatePicker,{id:c.id,name:c.name,label:e.label,required:e.required,disabled:e.disabled,helperText:r??e.helperText,error:!!r,value:t??null,onChange:a=>l(n,a)});case"range":return s.jsx(F.Range,{...c,value:t??e.rangeMin??0,min:e.rangeMin??0,max:e.rangeMax??100,step:e.rangeStep??1,valuePrefix:e.rangeValuePrefix,valueSuffix:e.rangeValueSuffix,showValue:!0,onChange:a=>l(n,a)});case"hidden":return s.jsx("input",{type:"hidden",name:n,value:t??e.hiddenValue??""});default:return null}};return e.fieldType==="hidden"?d():s.jsx("div",{className:`${x}`,children:d()})}exports.FormField=Q;exports.styles=u;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
-
import { Input as
|
|
3
|
-
import { Textarea as
|
|
2
|
+
import { Input as T } from "./core/components/Input/index.mjs";
|
|
3
|
+
import { Textarea as W } from "./core/components/Textarea/index.mjs";
|
|
4
4
|
import { Select as m } from "./core/components/Select/index.mjs";
|
|
5
5
|
import { Checkbox as _ } from "./core/components/Checkbox/index.mjs";
|
|
6
|
-
import { Radio as
|
|
6
|
+
import { Radio as f } 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
|
|
11
|
-
formBlock:
|
|
12
|
-
container:
|
|
13
|
-
formInner:
|
|
14
|
-
maxWidthSm:
|
|
15
|
-
maxWidthMd:
|
|
16
|
-
maxWidthLg:
|
|
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_1taaa_1", C = "_container_1taaa_7", F = "_formInner_1taaa_20", y = "_maxWidthSm_1taaa_26", B = "_maxWidthMd_1taaa_29", q = "_maxWidthLg_1taaa_32", S = "_maxWidthFull_1taaa_35", H = "_heading_1taaa_41", G = "_eyebrow_1taaa_47", M = "_title_1taaa_51", $ = "_disclaimer_1taaa_55", I = "_progress_1taaa_61", D = "_progressHeader_1taaa_67", O = "_stepLabel_1taaa_73", V = "_stepCount_1taaa_79", P = "_stepDescription_1taaa_84", R = "_fields_1taaa_92", j = "_fieldFull_1taaa_99", N = "_fieldHalf_1taaa_103", z = "_fieldThird_1taaa_111", A = "_actions_1taaa_121", E = "_submitButton_1taaa_128", J = "_success_1taaa_134", K = "_errorBanner_1taaa_149", u = {
|
|
11
|
+
formBlock: L,
|
|
12
|
+
container: C,
|
|
13
|
+
formInner: F,
|
|
14
|
+
maxWidthSm: y,
|
|
15
|
+
maxWidthMd: B,
|
|
16
|
+
maxWidthLg: q,
|
|
17
17
|
maxWidthFull: S,
|
|
18
18
|
heading: H,
|
|
19
19
|
eyebrow: G,
|
|
@@ -33,7 +33,7 @@ import './FormField.css';const w = "_formBlock_8cqr5_1", L = "_container_8cqr5_7
|
|
|
33
33
|
success: J,
|
|
34
34
|
errorBanner: K
|
|
35
35
|
};
|
|
36
|
-
function
|
|
36
|
+
function c(e) {
|
|
37
37
|
return (e ?? []).map((t) => ({
|
|
38
38
|
label: t.label,
|
|
39
39
|
value: t.value.current,
|
|
@@ -50,14 +50,14 @@ function p(e) {
|
|
|
50
50
|
}))
|
|
51
51
|
}));
|
|
52
52
|
}
|
|
53
|
-
function ne({ field: e, value: t, error: n, onChange:
|
|
54
|
-
const
|
|
53
|
+
function ne({ field: e, value: t, error: n, onChange: o }) {
|
|
54
|
+
const r = e.name.current, b = {
|
|
55
55
|
full: u.fieldFull,
|
|
56
56
|
half: u.fieldHalf,
|
|
57
57
|
third: u.fieldThird
|
|
58
|
-
}[e.width ?? "full"],
|
|
59
|
-
id:
|
|
60
|
-
name:
|
|
58
|
+
}[e.width ?? "full"], i = {
|
|
59
|
+
id: r,
|
|
60
|
+
name: r,
|
|
61
61
|
label: e.label,
|
|
62
62
|
required: e.required,
|
|
63
63
|
disabled: e.disabled,
|
|
@@ -72,60 +72,60 @@ function ne({ field: e, value: t, error: n, onChange: c }) {
|
|
|
72
72
|
case "number":
|
|
73
73
|
case "url":
|
|
74
74
|
return /* @__PURE__ */ s(
|
|
75
|
-
|
|
75
|
+
T,
|
|
76
76
|
{
|
|
77
|
-
...
|
|
77
|
+
...i,
|
|
78
78
|
type: e.fieldType === "phone" ? "tel" : e.fieldType,
|
|
79
79
|
placeholder: e.placeholder,
|
|
80
80
|
value: t ?? "",
|
|
81
81
|
minLength: e.minLength,
|
|
82
82
|
maxLength: e.maxLength,
|
|
83
83
|
fullWidth: !0,
|
|
84
|
-
onChange: (
|
|
84
|
+
onChange: (a) => o(r, a.target.value)
|
|
85
85
|
}
|
|
86
86
|
);
|
|
87
87
|
// ── Textarea ───────────────────────────────────────────────────────
|
|
88
88
|
case "textarea":
|
|
89
89
|
return /* @__PURE__ */ s(
|
|
90
|
-
|
|
90
|
+
W,
|
|
91
91
|
{
|
|
92
|
-
...
|
|
92
|
+
...i,
|
|
93
93
|
placeholder: e.placeholder,
|
|
94
94
|
value: t ?? "",
|
|
95
95
|
rows: e.rows ?? 4,
|
|
96
96
|
maxLength: e.maxLength,
|
|
97
97
|
showCharCount: e.showCharCount,
|
|
98
98
|
fullWidth: !0,
|
|
99
|
-
onChange: (
|
|
99
|
+
onChange: (a) => o(r, a.target.value)
|
|
100
100
|
}
|
|
101
101
|
);
|
|
102
102
|
// ── Select ─────────────────────────────────────────────────────────
|
|
103
103
|
case "select": {
|
|
104
|
-
const
|
|
104
|
+
const a = e.useOptionGroups ? p(e.optionGroups) : c(e.options);
|
|
105
105
|
return /* @__PURE__ */ s(
|
|
106
106
|
m,
|
|
107
107
|
{
|
|
108
|
-
...
|
|
108
|
+
...i,
|
|
109
109
|
placeholder: e.placeholder,
|
|
110
|
-
options:
|
|
110
|
+
options: a,
|
|
111
111
|
value: t ?? "",
|
|
112
112
|
fullWidth: !0,
|
|
113
|
-
onChange: (l) =>
|
|
113
|
+
onChange: (l) => o(r, l.target.value)
|
|
114
114
|
}
|
|
115
115
|
);
|
|
116
116
|
}
|
|
117
117
|
// ── Multi-select ───────────────────────────────────────────────────
|
|
118
118
|
case "multiselect": {
|
|
119
|
-
const
|
|
119
|
+
const a = e.useOptionGroups ? p(e.optionGroups) : c(e.options);
|
|
120
120
|
return /* @__PURE__ */ s(
|
|
121
121
|
m,
|
|
122
122
|
{
|
|
123
|
-
...
|
|
123
|
+
...i,
|
|
124
124
|
multiple: !0,
|
|
125
|
-
options:
|
|
125
|
+
options: a,
|
|
126
126
|
value: t ?? [],
|
|
127
127
|
showSelectedCount: !0,
|
|
128
|
-
onChange: (l) =>
|
|
128
|
+
onChange: (l) => o(r, l)
|
|
129
129
|
}
|
|
130
130
|
);
|
|
131
131
|
}
|
|
@@ -134,31 +134,31 @@ function ne({ field: e, value: t, error: n, onChange: c }) {
|
|
|
134
134
|
return /* @__PURE__ */ s(
|
|
135
135
|
_,
|
|
136
136
|
{
|
|
137
|
-
id:
|
|
138
|
-
name:
|
|
137
|
+
id: i.id,
|
|
138
|
+
name: i.name,
|
|
139
139
|
label: e.label,
|
|
140
140
|
required: e.required,
|
|
141
141
|
disabled: e.disabled,
|
|
142
142
|
helperText: n ?? e.helperText,
|
|
143
143
|
error: !!n,
|
|
144
144
|
checked: t ?? !1,
|
|
145
|
-
onChange: (
|
|
145
|
+
onChange: (a) => o(r, a.target.checked)
|
|
146
146
|
}
|
|
147
147
|
);
|
|
148
148
|
// ── Checkbox group ─────────────────────────────────────────────────
|
|
149
149
|
case "checkboxGroup": {
|
|
150
|
-
const
|
|
151
|
-
return /* @__PURE__ */ s(h, { legend: e.label, error: !!n, helperText: n, children:
|
|
150
|
+
const a = t ?? [];
|
|
151
|
+
return /* @__PURE__ */ s(h, { legend: e.label, error: !!n, helperText: n, children: c(e.options).map((l) => /* @__PURE__ */ s(
|
|
152
152
|
_,
|
|
153
153
|
{
|
|
154
|
-
id: `${
|
|
155
|
-
name: `${
|
|
154
|
+
id: `${r}-${l.value}`,
|
|
155
|
+
name: `${r}[]`,
|
|
156
156
|
label: l.label,
|
|
157
|
-
checked:
|
|
157
|
+
checked: a.includes(l.value),
|
|
158
158
|
disabled: l.disabled || e.disabled,
|
|
159
159
|
onChange: (x) => {
|
|
160
|
-
const g = x.target.checked ? [...
|
|
161
|
-
|
|
160
|
+
const g = x.target.checked ? [...a, l.value] : a.filter((v) => v !== l.value);
|
|
161
|
+
o(r, g);
|
|
162
162
|
}
|
|
163
163
|
},
|
|
164
164
|
l.value
|
|
@@ -166,42 +166,42 @@ function ne({ field: e, value: t, error: n, onChange: c }) {
|
|
|
166
166
|
}
|
|
167
167
|
// ── Radio group ────────────────────────────────────────────────────
|
|
168
168
|
case "radio":
|
|
169
|
-
return /* @__PURE__ */ s(h, { legend: e.label, error: !!n, helperText: n, children:
|
|
170
|
-
|
|
169
|
+
return /* @__PURE__ */ s(h, { legend: e.label, error: !!n, helperText: n, children: c(e.options).map((a) => /* @__PURE__ */ s(
|
|
170
|
+
f,
|
|
171
171
|
{
|
|
172
|
-
id: `${
|
|
173
|
-
name:
|
|
174
|
-
value:
|
|
175
|
-
label:
|
|
176
|
-
checked: t ===
|
|
177
|
-
disabled:
|
|
172
|
+
id: `${r}-${a.value}`,
|
|
173
|
+
name: r,
|
|
174
|
+
value: a.value,
|
|
175
|
+
label: a.label,
|
|
176
|
+
checked: t === a.value,
|
|
177
|
+
disabled: a.disabled || e.disabled,
|
|
178
178
|
required: e.required,
|
|
179
|
-
onChange: () =>
|
|
179
|
+
onChange: () => o(r, a.value)
|
|
180
180
|
},
|
|
181
|
-
|
|
181
|
+
a.value
|
|
182
182
|
)) });
|
|
183
183
|
// ── Date picker ────────────────────────────────────────────────────
|
|
184
184
|
case "date":
|
|
185
185
|
return /* @__PURE__ */ s(
|
|
186
|
-
|
|
186
|
+
k,
|
|
187
187
|
{
|
|
188
|
-
id:
|
|
189
|
-
name:
|
|
188
|
+
id: i.id,
|
|
189
|
+
name: i.name,
|
|
190
190
|
label: e.label,
|
|
191
191
|
required: e.required,
|
|
192
192
|
disabled: e.disabled,
|
|
193
193
|
helperText: n ?? e.helperText,
|
|
194
194
|
error: !!n,
|
|
195
195
|
value: t ?? null,
|
|
196
|
-
onChange: (
|
|
196
|
+
onChange: (a) => o(r, a)
|
|
197
197
|
}
|
|
198
198
|
);
|
|
199
199
|
// ── Range ──────────────────────────────────────────────────────────
|
|
200
200
|
case "range":
|
|
201
201
|
return /* @__PURE__ */ s(
|
|
202
|
-
|
|
202
|
+
w,
|
|
203
203
|
{
|
|
204
|
-
...
|
|
204
|
+
...i,
|
|
205
205
|
value: t ?? e.rangeMin ?? 0,
|
|
206
206
|
min: e.rangeMin ?? 0,
|
|
207
207
|
max: e.rangeMax ?? 100,
|
|
@@ -209,7 +209,7 @@ function ne({ field: e, value: t, error: n, onChange: c }) {
|
|
|
209
209
|
valuePrefix: e.rangeValuePrefix,
|
|
210
210
|
valueSuffix: e.rangeValueSuffix,
|
|
211
211
|
showValue: !0,
|
|
212
|
-
onChange: (
|
|
212
|
+
onChange: (a) => o(r, a)
|
|
213
213
|
}
|
|
214
214
|
);
|
|
215
215
|
// ── Hidden ─────────────────────────────────────────────────────────
|
|
@@ -218,7 +218,7 @@ function ne({ field: e, value: t, error: n, onChange: c }) {
|
|
|
218
218
|
"input",
|
|
219
219
|
{
|
|
220
220
|
type: "hidden",
|
|
221
|
-
name:
|
|
221
|
+
name: r,
|
|
222
222
|
value: t ?? e.hiddenValue ?? ""
|
|
223
223
|
}
|
|
224
224
|
);
|
package/dist/FormField.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._formBlock_1taaa_1{width:100%;padding-top:var(--spacing-xl);padding-bottom:var(--spacing-xl)}._container_1taaa_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_1taaa_20{width:100%;margin-left:auto;margin-right:auto}._maxWidthSm_1taaa_26{max-width:480px}._maxWidthMd_1taaa_29{max-width:640px}._maxWidthLg_1taaa_32{max-width:800px}._maxWidthFull_1taaa_35{max-width:100%}._heading_1taaa_41{display:flex;flex-direction:column;gap:var(--spacing-sm)}._eyebrow_1taaa_47{font-weight:var(--font-weight-bold)}._title_1taaa_51{text-wrap:balance}._disclaimer_1taaa_55{font-size:var(--font-size-sm)}._progress_1taaa_61{display:flex;flex-direction:column;gap:var(--spacing-sm)}._progressHeader_1taaa_67{display:flex;justify-content:space-between;align-items:center}._stepLabel_1taaa_73{font-weight:var(--font-weight-semibold);font-size:var(--font-size-md);color:var(--color-text-primary)}._stepCount_1taaa_79{font-size:var(--font-size-sm);color:var(--color-secondary-50)}._stepDescription_1taaa_84{color:var(--color-secondary-75);font-size:var(--font-size-md);margin:0}._fields_1taaa_92{display:flex;flex-wrap:wrap;gap:var(--spacing-md)}._fieldFull_1taaa_99{width:100%}._fieldHalf_1taaa_103{width:calc(50% - var(--spacing-md) / 2)}@media (max-width: 767px){._fieldHalf_1taaa_103{width:100%}}._fieldThird_1taaa_111{width:calc(33.333% - var(--spacing-md) * 2 / 3)}@media (max-width: 767px){._fieldThird_1taaa_111{width:100%}}._actions_1taaa_121{display:flex;align-items:center;gap:var(--spacing-md);padding-top:var(--spacing-sm)}._submitButton_1taaa_128{margin-left:auto}._success_1taaa_134{display:flex;flex-direction:column;align-items:flex-start;gap:var(--spacing-lg);padding:var(--spacing-md) 0 0}._success_1taaa_134 p{color:var(--color-states-success-bg);font-weight:var(--font-weight-semibold)}._errorBanner_1taaa_149{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)}.split ._container_1taaa_7{flex-direction:row;gap:3rem}.split ._heading_1taaa_41,.split form{flex:.5}@media (max-width: 767px){.split ._container_1taaa_7{flex-direction:column-reverse}.split ._heading_1taaa_41,.split form{flex:1}}
|
|
@@ -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-LSFCBISi.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-oa2piuZf.js";
|
|
11
11
|
export {
|
|
12
12
|
l as FormField
|
|
13
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),i=require("react"),W=require("../../../core/components/Form/index.cjs"),E=require("../../../index-0SVQqhAg.cjs"),M=require("../../../core/components/ProgressBar/index.cjs"),A=require("../../hooks/useStyleClasses.cjs"),e=require("../../../FormField-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),i=require("react"),W=require("../../../core/components/Form/index.cjs"),E=require("../../../index-0SVQqhAg.cjs"),M=require("../../../core/components/ProgressBar/index.cjs"),A=require("../../hooks/useStyleClasses.cjs"),e=require("../../../FormField-LSFCBISi.cjs"),_=require("./validate.cjs");function D(r,s){switch(s.type){case"SET_VALUE":return{...r,values:{...r.values,[s.name]:s.value},errors:{...r.errors,[s.name]:""}};case"SET_ERRORS":return{...r,errors:s.errors};case"CLEAR_ERROR":return{...r,errors:{...r.errors,[s.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:s.value};case"SET_RESULT":return{...r,submitResult:s.result,isSubmitting:!1};case"RESET":return{...r,currentStep:0,errors:{},submitResult:null,isSubmitting:!1};default:return r}}function G({id:r,heading:s,layout:B="vertical",maxWidth:x="md",steps:S,submitLabel:C="Submit",nextLabel:F="Next",backLabel:L="Back",successMessage:P="Thank you! Your submission has been received.",errorMessage:p="Something went wrong. Please try again.",styleOptions:$,renderRichText:c,onSubmit:v}){const N=A.useStyleClasses($??{}),j={sm:e.styles.maxWidthSm,md:e.styles.maxWidthMd,lg:e.styles.maxWidthLg,full:e.styles.maxWidthFull}[x],q=i.useMemo(()=>_.buildInitialValues(S),[]),[w,o]=i.useReducer(D,{values:q,errors:{},currentStep:0,isSubmitting:!1,submitResult:null}),{values:u,errors:T,currentStep:m,isSubmitting:b,submitResult:n}=w,y=S.length,k=y>1,f=m===y-1,I=(m+1)/y*100,a=S[m],O=i.useCallback((l,d)=>{o({type:"SET_VALUE",name:l,value:d})},[]),U=i.useCallback(()=>{const l=_.validateStep(a.fields,u);if(Object.keys(l).length>0){o({type:"SET_ERRORS",errors:l});return}o({type:"NEXT_STEP"})},[a.fields,u]),V=i.useCallback(()=>{o({type:"PREV_STEP"})},[]),R=i.useCallback(async()=>{const l=_.validateStep(a.fields,u);if(Object.keys(l).length>0){o({type:"SET_ERRORS",errors:l});return}o({type:"SET_SUBMITTING",value:!0});try{const d=await v(u);o({type:"SET_RESULT",result:d})}catch{o({type:"SET_RESULT",result:{success:!1,message:p}})}},[a.fields,u,v,p]);return n!=null&&n.success?t.jsx("section",{id:r,className:`${e.styles.formBlock} ${N}`,children:t.jsx("div",{className:`${e.styles.formInner} ${j}`,children:t.jsx("div",{className:e.styles.container,children:t.jsxs("div",{className:e.styles.success,children:[t.jsx("p",{children:n.message??P}),t.jsx(E.Button,{as:"button",variant:"secondary",onClick:()=>o({type:"RESET"}),children:"Submit another response"})]})})})}):t.jsx("section",{id:r,className:`${e.styles.formBlock} ${N}`,children:t.jsx("div",{className:`${e.styles.formInner} ${j}`,children:t.jsxs("div",{className:e.styles.container,children:[((s==null?void 0:s.title)||(s==null?void 0:s.description))&&t.jsxs("div",{className:e.styles.heading,children:[s.eyebrow&&(c==null?void 0:c({blocks:s.eyebrow,className:e.styles.eyebrow})),s.title&&(c==null?void 0:c({blocks:s.title,className:e.styles.title})),s.description&&(c==null?void 0:c({blocks:s.description}))]}),k&&t.jsxs("div",{className:e.styles.progress,children:[t.jsxs("div",{className:e.styles.progressHeader,children:[t.jsx("span",{className:e.styles.stepLabel,children:a.title}),t.jsxs("span",{className:e.styles.stepCount,children:[m+1," / ",y]})]}),t.jsx(M.ProgressBar,{progress:I,variant:"primary",size:"sm",showLabel:!1})]}),a.description&&t.jsx("p",{className:e.styles.stepDescription,children:a.description}),n&&!n.success&&t.jsx("div",{className:e.styles.errorBanner,role:"alert",children:n.message??p}),t.jsxs(W.Form,{layout:B,noValidate:!0,onSubmit:l=>{l.preventDefault(),f?R():U()},children:[t.jsx("div",{className:e.styles.fields,children:a.fields.map(l=>t.jsx(e.FormField,{field:l,value:u[l.name.current],error:T[l.name.current],onChange:O},l._key))}),(s==null?void 0:s.disclaimer)&&(c==null?void 0:c({blocks:s==null?void 0:s.disclaimer,className:e.styles.disclaimer})),t.jsxs("div",{className:e.styles.actions,children:[k&&m>0&&t.jsx(E.Button,{as:"button",type:"button",variant:"secondary",onClick:V,disabled:b,children:L}),t.jsx(E.Button,{as:"button",type:"submit",variant:"primary",disabled:b,className:e.styles.submitButton,children:b?"Submitting…":f?C:F})]})]})]})})})}exports.FormBlock=G;
|
|
@@ -4,7 +4,7 @@ import { Form as X } from "../../../core/components/Form/index.mjs";
|
|
|
4
4
|
import { B as d } from "../../../index-aWdsapYP.js";
|
|
5
5
|
import { ProgressBar as z } from "../../../core/components/ProgressBar/index.mjs";
|
|
6
6
|
import { useStyleClasses as H } from "../../hooks/useStyleClasses.mjs";
|
|
7
|
-
import { s as r, F as Y } from "../../../FormField-
|
|
7
|
+
import { s as r, F as Y } from "../../../FormField-oa2piuZf.js";
|
|
8
8
|
import { buildInitialValues as h, validateStep as L } from "./validate.mjs";
|
|
9
9
|
function q(e, s) {
|
|
10
10
|
switch (s.type) {
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";require('./FormField.css');const a=require("react/jsx-runtime"),v=require("./core/components/Input/index.cjs"),T=require("./core/components/Textarea/index.cjs"),_=require("./core/components/Select/index.cjs"),h=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_8cqr5_1",C="_container_8cqr5_7",w="_formInner_8cqr5_20",L="_maxWidthSm_8cqr5_26",y="_maxWidthMd_8cqr5_29",S="_maxWidthLg_8cqr5_32",B="_maxWidthFull_8cqr5_35",$="_heading_8cqr5_41",H="_eyebrow_8cqr5_47",G="_title_8cqr5_51",I="_disclaimer_8cqr5_55",M="_progress_8cqr5_61",D="_progressHeader_8cqr5_67",O="_stepLabel_8cqr5_73",P="_stepCount_8cqr5_79",R="_stepDescription_8cqr5_84",V="_fields_8cqr5_92",f="_fieldFull_8cqr5_99",N="_fieldHalf_8cqr5_103",z="_fieldThird_8cqr5_111",A="_actions_8cqr5_121",E="_submitButton_8cqr5_128",J="_success_8cqr5_134",K="_errorBanner_8cqr5_149",u={formBlock:j,container:C,formInner:w,maxWidthSm:L,maxWidthMd:y,maxWidthLg:S,maxWidthFull:B,heading:$,eyebrow:H,title:G,disclaimer:I,progress:M,progressHeader:D,stepLabel:O,stepCount:P,stepDescription:R,fields:V,fieldFull:f,fieldHalf:N,fieldThird:z,actions:A,submitButton:E,success:J,errorBanner:K};function i(e){return(e??[]).map(t=>({label:t.label,value:t.value.current,disabled:t.disabled}))}function m(e){return(e??[]).map(t=>({label:t.label,options:t.options.map(s=>({label:s.label,value:s.value.current,disabled:s.disabled}))}))}function Q({field:e,value:t,error:s,onChange:o}){const n=e.name.current,x={full:u.fieldFull,half:u.fieldHalf,third:u.fieldThird}[e.width??"full"],l={id:n,name:n,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,{...l,type:e.fieldType==="phone"?"tel":e.fieldType,placeholder:e.placeholder,value:t??"",minLength:e.minLength,maxLength:e.maxLength,fullWidth:!0,onChange:r=>o(n,r.target.value)});case"textarea":return a.jsx(T.Textarea,{...l,placeholder:e.placeholder,value:t??"",rows:e.rows??4,maxLength:e.maxLength,showCharCount:e.showCharCount,fullWidth:!0,onChange:r=>o(n,r.target.value)});case"select":{const r=e.useOptionGroups?m(e.optionGroups):i(e.options);return a.jsx(_.Select,{...l,placeholder:e.placeholder,options:r,value:t??"",fullWidth:!0,onChange:c=>o(n,c.target.value)})}case"multiselect":{const r=e.useOptionGroups?m(e.optionGroups):i(e.options);return a.jsx(_.Select,{...l,multiple:!0,options:r,value:t??[],showSelectedCount:!0,onChange:c=>o(n,c)})}case"checkbox":return a.jsx(h.Checkbox,{id:l.id,name:l.name,label:e.label,required:e.required,disabled:e.disabled,helperText:s??e.helperText,error:!!s,checked:t??!1,onChange:r=>o(n,r.target.checked)});case"checkboxGroup":{const r=t??[];return a.jsx(p.Fieldset,{legend:e.label,error:!!s,helperText:s,children:i(e.options).map(c=>a.jsx(h.Checkbox,{id:`${n}-${c.value}`,name:`${n}[]`,label:c.label,checked:r.includes(c.value),disabled:c.disabled||e.disabled,onChange:b=>{const q=b.target.checked?[...r,c.value]:r.filter(g=>g!==c.value);o(n,q)}},c.value))})}case"radio":return a.jsx(p.Fieldset,{legend:e.label,error:!!s,helperText:s,children:i(e.options).map(r=>a.jsx(k.Radio,{id:`${n}-${r.value}`,name:n,value:r.value,label:r.label,checked:t===r.value,disabled:r.disabled||e.disabled,required:e.required,onChange:()=>o(n,r.value)},r.value))});case"date":return a.jsx(W.DatePicker,{id:l.id,name:l.name,label:e.label,required:e.required,disabled:e.disabled,helperText:s??e.helperText,error:!!s,value:t??null,onChange:r=>o(n,r)});case"range":return a.jsx(F.Range,{...l,value:t??e.rangeMin??0,min:e.rangeMin??0,max:e.rangeMax??100,step:e.rangeStep??1,valuePrefix:e.rangeValuePrefix,valueSuffix:e.rangeValueSuffix,showValue:!0,onChange:r=>o(n,r)});case"hidden":return a.jsx("input",{type:"hidden",name:n,value:t??e.hiddenValue??""});default:return null}};return e.fieldType==="hidden"?d():a.jsx("div",{className:`${x}`,children:d()})}exports.FormField=Q;exports.styles=u;
|