quirk-ui 0.1.152 → 0.1.154
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-Rqe3qF_t.js → FormField-D1m8xWkL.js} +82 -82
- package/dist/FormField-DU5sh1Fk.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 +1 -1
- package/dist/next/utils/blockRenderers.cjs +1 -1
- package/dist/next/utils/blockRenderers.mjs +52 -30
- package/dist/next.d.ts +1 -1
- package/package.json +1 -1
- package/dist/FormField-fg7Q2UyZ.cjs +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
-
import { Input as
|
|
2
|
+
import { Input as g } from "./core/components/Input/index.mjs";
|
|
3
3
|
import { Textarea as T } from "./core/components/Textarea/index.mjs";
|
|
4
|
-
import { Select as
|
|
5
|
-
import { Checkbox as
|
|
4
|
+
import { Select as m } from "./core/components/Select/index.mjs";
|
|
5
|
+
import { Checkbox as h } from "./core/components/Checkbox/index.mjs";
|
|
6
6
|
import { Radio as W } from "./core/components/Radio/index.mjs";
|
|
7
|
-
import { Fieldset as
|
|
8
|
-
import { DatePicker as
|
|
9
|
-
import { Range as
|
|
10
|
-
import './FormField.css';const L = "
|
|
7
|
+
import { Fieldset as p } from "./core/components/Fieldset/index.mjs";
|
|
8
|
+
import { DatePicker as f } from "./core/components/DatePicker/index.mjs";
|
|
9
|
+
import { Range as k } from "./core/components/Range/index.mjs";
|
|
10
|
+
import './FormField.css';const L = "_formBlock_1nwvd_1", C = "_container_1nwvd_7", F = "_formInner_1nwvd_20", y = "_maxWidthSm_1nwvd_26", B = "_maxWidthMd_1nwvd_29", q = "_maxWidthLg_1nwvd_32", S = "_maxWidthFull_1nwvd_35", H = "_heading_1nwvd_41", G = "_eyebrow_1nwvd_47", M = "_title_1nwvd_51", $ = "_progress_1nwvd_57", I = "_progressHeader_1nwvd_63", D = "_stepLabel_1nwvd_69", O = "_stepCount_1nwvd_75", V = "_stepDescription_1nwvd_80", P = "_fields_1nwvd_88", R = "_fieldFull_1nwvd_95", j = "_fieldHalf_1nwvd_99", N = "_fieldThird_1nwvd_107", z = "_actions_1nwvd_117", A = "_submitButton_1nwvd_124", E = "_success_1nwvd_130", J = "_errorBanner_1nwvd_145", u = {
|
|
11
11
|
formBlock: L,
|
|
12
12
|
container: C,
|
|
13
13
|
formInner: F,
|
|
@@ -32,37 +32,37 @@ import './FormField.css';const L = "_formBlock_b7mbf_1", C = "_container_b7mbf_7
|
|
|
32
32
|
success: E,
|
|
33
33
|
errorBanner: J
|
|
34
34
|
};
|
|
35
|
-
function
|
|
36
|
-
return (e ?? []).map((
|
|
37
|
-
label:
|
|
38
|
-
value:
|
|
39
|
-
disabled:
|
|
35
|
+
function i(e) {
|
|
36
|
+
return (e ?? []).map((n) => ({
|
|
37
|
+
label: n.label,
|
|
38
|
+
value: n.value.current,
|
|
39
|
+
disabled: n.disabled
|
|
40
40
|
}));
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
return (e ?? []).map((
|
|
44
|
-
label:
|
|
45
|
-
options:
|
|
46
|
-
label:
|
|
47
|
-
value:
|
|
48
|
-
disabled:
|
|
42
|
+
function _(e) {
|
|
43
|
+
return (e ?? []).map((n) => ({
|
|
44
|
+
label: n.label,
|
|
45
|
+
options: n.options.map((a) => ({
|
|
46
|
+
label: a.label,
|
|
47
|
+
value: a.value.current,
|
|
48
|
+
disabled: a.disabled
|
|
49
49
|
}))
|
|
50
50
|
}));
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
const
|
|
54
|
-
full:
|
|
55
|
-
half:
|
|
56
|
-
third:
|
|
57
|
-
}[e.width ?? "full"],
|
|
58
|
-
id:
|
|
59
|
-
name:
|
|
52
|
+
function re({ field: e, value: n, error: a, onChange: o }) {
|
|
53
|
+
const r = e.name.current, b = {
|
|
54
|
+
full: u.fieldFull,
|
|
55
|
+
half: u.fieldHalf,
|
|
56
|
+
third: u.fieldThird
|
|
57
|
+
}[e.width ?? "full"], d = {
|
|
58
|
+
id: r,
|
|
59
|
+
name: r,
|
|
60
60
|
label: e.label,
|
|
61
61
|
required: e.required,
|
|
62
62
|
disabled: e.disabled,
|
|
63
63
|
helperText: e.helperText,
|
|
64
|
-
error:
|
|
65
|
-
},
|
|
64
|
+
error: a
|
|
65
|
+
}, c = () => {
|
|
66
66
|
switch (e.fieldType) {
|
|
67
67
|
// ── Text-based inputs ──────────────────────────────────────────────
|
|
68
68
|
case "text":
|
|
@@ -71,16 +71,16 @@ function ae({ field: e, value: r, error: n, onChange: o }) {
|
|
|
71
71
|
case "number":
|
|
72
72
|
case "url":
|
|
73
73
|
return /* @__PURE__ */ s(
|
|
74
|
-
|
|
74
|
+
g,
|
|
75
75
|
{
|
|
76
|
-
...
|
|
76
|
+
...d,
|
|
77
77
|
type: e.fieldType === "phone" ? "tel" : e.fieldType,
|
|
78
78
|
placeholder: e.placeholder,
|
|
79
|
-
value:
|
|
79
|
+
value: n ?? "",
|
|
80
80
|
minLength: e.minLength,
|
|
81
81
|
maxLength: e.maxLength,
|
|
82
82
|
fullWidth: !0,
|
|
83
|
-
onChange: (t) => o(
|
|
83
|
+
onChange: (t) => o(r, t.target.value)
|
|
84
84
|
}
|
|
85
85
|
);
|
|
86
86
|
// ── Textarea ───────────────────────────────────────────────────────
|
|
@@ -88,76 +88,76 @@ function ae({ field: e, value: r, error: n, onChange: o }) {
|
|
|
88
88
|
return /* @__PURE__ */ s(
|
|
89
89
|
T,
|
|
90
90
|
{
|
|
91
|
-
...
|
|
91
|
+
...d,
|
|
92
92
|
placeholder: e.placeholder,
|
|
93
|
-
value:
|
|
93
|
+
value: n ?? "",
|
|
94
94
|
rows: e.rows ?? 4,
|
|
95
95
|
maxLength: e.maxLength,
|
|
96
96
|
showCharCount: e.showCharCount,
|
|
97
97
|
fullWidth: !0,
|
|
98
|
-
onChange: (t) => o(
|
|
98
|
+
onChange: (t) => o(r, t.target.value)
|
|
99
99
|
}
|
|
100
100
|
);
|
|
101
101
|
// ── Select ─────────────────────────────────────────────────────────
|
|
102
102
|
case "select": {
|
|
103
|
-
const t = e.useOptionGroups ?
|
|
103
|
+
const t = e.useOptionGroups ? _(e.optionGroups) : i(e.options);
|
|
104
104
|
return /* @__PURE__ */ s(
|
|
105
|
-
|
|
105
|
+
m,
|
|
106
106
|
{
|
|
107
|
-
...
|
|
107
|
+
...d,
|
|
108
108
|
placeholder: e.placeholder,
|
|
109
109
|
options: t,
|
|
110
|
-
value:
|
|
110
|
+
value: n ?? "",
|
|
111
111
|
fullWidth: !0,
|
|
112
|
-
onChange: (l) => o(
|
|
112
|
+
onChange: (l) => o(r, l.target.value)
|
|
113
113
|
}
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
116
|
// ── Multi-select ───────────────────────────────────────────────────
|
|
117
117
|
case "multiselect": {
|
|
118
|
-
const t = e.useOptionGroups ?
|
|
118
|
+
const t = e.useOptionGroups ? _(e.optionGroups) : i(e.options);
|
|
119
119
|
return /* @__PURE__ */ s(
|
|
120
|
-
|
|
120
|
+
m,
|
|
121
121
|
{
|
|
122
|
-
...
|
|
122
|
+
...d,
|
|
123
123
|
multiple: !0,
|
|
124
124
|
options: t,
|
|
125
|
-
value:
|
|
125
|
+
value: n ?? [],
|
|
126
126
|
showSelectedCount: !0,
|
|
127
|
-
onChange: (l) => o(
|
|
127
|
+
onChange: (l) => o(r, l)
|
|
128
128
|
}
|
|
129
129
|
);
|
|
130
130
|
}
|
|
131
131
|
// ── Single checkbox ────────────────────────────────────────────────
|
|
132
132
|
case "checkbox":
|
|
133
133
|
return /* @__PURE__ */ s(
|
|
134
|
-
|
|
134
|
+
h,
|
|
135
135
|
{
|
|
136
|
-
id:
|
|
137
|
-
name:
|
|
136
|
+
id: d.id,
|
|
137
|
+
name: d.name,
|
|
138
138
|
label: e.label,
|
|
139
139
|
required: e.required,
|
|
140
140
|
disabled: e.disabled,
|
|
141
|
-
helperText:
|
|
142
|
-
error: !!
|
|
143
|
-
checked:
|
|
144
|
-
onChange: (t) => o(
|
|
141
|
+
helperText: a ?? e.helperText,
|
|
142
|
+
error: !!a,
|
|
143
|
+
checked: n ?? !1,
|
|
144
|
+
onChange: (t) => o(r, t.target.checked)
|
|
145
145
|
}
|
|
146
146
|
);
|
|
147
147
|
// ── Checkbox group ─────────────────────────────────────────────────
|
|
148
148
|
case "checkboxGroup": {
|
|
149
|
-
const t =
|
|
150
|
-
return /* @__PURE__ */ s(
|
|
151
|
-
|
|
149
|
+
const t = n ?? [];
|
|
150
|
+
return /* @__PURE__ */ s(p, { legend: e.label, error: !!a, helperText: a, children: i(e.options).map((l) => /* @__PURE__ */ s(
|
|
151
|
+
h,
|
|
152
152
|
{
|
|
153
|
-
id: `${
|
|
154
|
-
name: `${
|
|
153
|
+
id: `${r}-${l.value}`,
|
|
154
|
+
name: `${r}[]`,
|
|
155
155
|
label: l.label,
|
|
156
156
|
checked: t.includes(l.value),
|
|
157
157
|
disabled: l.disabled || e.disabled,
|
|
158
|
-
onChange: (
|
|
159
|
-
const
|
|
160
|
-
o(
|
|
158
|
+
onChange: (v) => {
|
|
159
|
+
const x = v.target.checked ? [...t, l.value] : t.filter((w) => w !== l.value);
|
|
160
|
+
o(r, x);
|
|
161
161
|
}
|
|
162
162
|
},
|
|
163
163
|
l.value
|
|
@@ -165,50 +165,50 @@ function ae({ field: e, value: r, error: n, onChange: o }) {
|
|
|
165
165
|
}
|
|
166
166
|
// ── Radio group ────────────────────────────────────────────────────
|
|
167
167
|
case "radio":
|
|
168
|
-
return /* @__PURE__ */ s(
|
|
168
|
+
return /* @__PURE__ */ s(p, { legend: e.label, error: !!a, helperText: a, children: i(e.options).map((t) => /* @__PURE__ */ s(
|
|
169
169
|
W,
|
|
170
170
|
{
|
|
171
|
-
id: `${
|
|
172
|
-
name:
|
|
171
|
+
id: `${r}-${t.value}`,
|
|
172
|
+
name: r,
|
|
173
173
|
value: t.value,
|
|
174
174
|
label: t.label,
|
|
175
|
-
checked:
|
|
175
|
+
checked: n === t.value,
|
|
176
176
|
disabled: t.disabled || e.disabled,
|
|
177
177
|
required: e.required,
|
|
178
|
-
onChange: () => o(
|
|
178
|
+
onChange: () => o(r, t.value)
|
|
179
179
|
},
|
|
180
180
|
t.value
|
|
181
181
|
)) });
|
|
182
182
|
// ── Date picker ────────────────────────────────────────────────────
|
|
183
183
|
case "date":
|
|
184
184
|
return /* @__PURE__ */ s(
|
|
185
|
-
|
|
185
|
+
f,
|
|
186
186
|
{
|
|
187
|
-
id:
|
|
188
|
-
name:
|
|
187
|
+
id: d.id,
|
|
188
|
+
name: d.name,
|
|
189
189
|
label: e.label,
|
|
190
190
|
required: e.required,
|
|
191
191
|
disabled: e.disabled,
|
|
192
|
-
helperText:
|
|
193
|
-
error: !!
|
|
194
|
-
value:
|
|
195
|
-
onChange: (t) => o(
|
|
192
|
+
helperText: a ?? e.helperText,
|
|
193
|
+
error: !!a,
|
|
194
|
+
value: n ?? null,
|
|
195
|
+
onChange: (t) => o(r, t)
|
|
196
196
|
}
|
|
197
197
|
);
|
|
198
198
|
// ── Range ──────────────────────────────────────────────────────────
|
|
199
199
|
case "range":
|
|
200
200
|
return /* @__PURE__ */ s(
|
|
201
|
-
|
|
201
|
+
k,
|
|
202
202
|
{
|
|
203
|
-
...
|
|
204
|
-
value:
|
|
203
|
+
...d,
|
|
204
|
+
value: n ?? e.rangeMin ?? 0,
|
|
205
205
|
min: e.rangeMin ?? 0,
|
|
206
206
|
max: e.rangeMax ?? 100,
|
|
207
207
|
step: e.rangeStep ?? 1,
|
|
208
208
|
valuePrefix: e.rangeValuePrefix,
|
|
209
209
|
valueSuffix: e.rangeValueSuffix,
|
|
210
210
|
showValue: !0,
|
|
211
|
-
onChange: (t) => o(
|
|
211
|
+
onChange: (t) => o(r, t)
|
|
212
212
|
}
|
|
213
213
|
);
|
|
214
214
|
// ── Hidden ─────────────────────────────────────────────────────────
|
|
@@ -217,17 +217,17 @@ function ae({ field: e, value: r, error: n, onChange: o }) {
|
|
|
217
217
|
"input",
|
|
218
218
|
{
|
|
219
219
|
type: "hidden",
|
|
220
|
-
name:
|
|
221
|
-
value:
|
|
220
|
+
name: r,
|
|
221
|
+
value: n ?? e.hiddenValue ?? ""
|
|
222
222
|
}
|
|
223
223
|
);
|
|
224
224
|
default:
|
|
225
225
|
return null;
|
|
226
226
|
}
|
|
227
227
|
};
|
|
228
|
-
return e.fieldType === "hidden" ?
|
|
228
|
+
return e.fieldType === "hidden" ? c() : /* @__PURE__ */ s("div", { className: `${b}`, children: c() });
|
|
229
229
|
}
|
|
230
230
|
export {
|
|
231
|
-
|
|
232
|
-
|
|
231
|
+
re as F,
|
|
232
|
+
u as s
|
|
233
233
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require('./FormField.css');const a=require("react/jsx-runtime"),g=require("./core/components/Input/index.cjs"),q=require("./core/components/Textarea/index.cjs"),_=require("./core/components/Select/index.cjs"),h=require("./core/components/Checkbox/index.cjs"),T=require("./core/components/Radio/index.cjs"),p=require("./core/components/Fieldset/index.cjs"),k=require("./core/components/DatePicker/index.cjs"),W=require("./core/components/Range/index.cjs"),F="_formBlock_1nwvd_1",j="_container_1nwvd_7",C="_formInner_1nwvd_20",L="_maxWidthSm_1nwvd_26",y="_maxWidthMd_1nwvd_29",S="_maxWidthLg_1nwvd_32",B="_maxWidthFull_1nwvd_35",$="_heading_1nwvd_41",H="_eyebrow_1nwvd_47",G="_title_1nwvd_51",I="_progress_1nwvd_57",M="_progressHeader_1nwvd_63",D="_stepLabel_1nwvd_69",O="_stepCount_1nwvd_75",P="_stepDescription_1nwvd_80",R="_fields_1nwvd_88",V="_fieldFull_1nwvd_95",f="_fieldHalf_1nwvd_99",N="_fieldThird_1nwvd_107",z="_actions_1nwvd_117",A="_submitButton_1nwvd_124",E="_success_1nwvd_130",J="_errorBanner_1nwvd_145",i={formBlock:F,container:j,formInner:C,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 d(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 K({field:e,value:t,error:s,onChange:l}){const r=e.name.current,x={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},u=()=>{switch(e.fieldType){case"text":case"email":case"phone":case"number":case"url":return a.jsx(g.Input,{...c,type:e.fieldType==="phone"?"tel":e.fieldType,placeholder:e.placeholder,value:t??"",minLength:e.minLength,maxLength:e.maxLength,fullWidth:!0,onChange:n=>l(r,n.target.value)});case"textarea":return a.jsx(q.Textarea,{...c,placeholder:e.placeholder,value:t??"",rows:e.rows??4,maxLength:e.maxLength,showCharCount:e.showCharCount,fullWidth:!0,onChange:n=>l(r,n.target.value)});case"select":{const n=e.useOptionGroups?m(e.optionGroups):d(e.options);return a.jsx(_.Select,{...c,placeholder:e.placeholder,options:n,value:t??"",fullWidth:!0,onChange:o=>l(r,o.target.value)})}case"multiselect":{const n=e.useOptionGroups?m(e.optionGroups):d(e.options);return a.jsx(_.Select,{...c,multiple:!0,options:n,value:t??[],showSelectedCount:!0,onChange:o=>l(r,o)})}case"checkbox":return a.jsx(h.Checkbox,{id:c.id,name:c.name,label:e.label,required:e.required,disabled:e.disabled,helperText:s??e.helperText,error:!!s,checked:t??!1,onChange:n=>l(r,n.target.checked)});case"checkboxGroup":{const n=t??[];return a.jsx(p.Fieldset,{legend:e.label,error:!!s,helperText:s,children:d(e.options).map(o=>a.jsx(h.Checkbox,{id:`${r}-${o.value}`,name:`${r}[]`,label:o.label,checked:n.includes(o.value),disabled:o.disabled||e.disabled,onChange:b=>{const v=b.target.checked?[...n,o.value]:n.filter(w=>w!==o.value);l(r,v)}},o.value))})}case"radio":return a.jsx(p.Fieldset,{legend:e.label,error:!!s,helperText:s,children:d(e.options).map(n=>a.jsx(T.Radio,{id:`${r}-${n.value}`,name:r,value:n.value,label:n.label,checked:t===n.value,disabled:n.disabled||e.disabled,required:e.required,onChange:()=>l(r,n.value)},n.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:t??null,onChange:n=>l(r,n)});case"range":return a.jsx(W.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:n=>l(r,n)});case"hidden":return a.jsx("input",{type:"hidden",name:r,value:t??e.hiddenValue??""});default:return null}};return e.fieldType==="hidden"?u():a.jsx("div",{className:`${x}`,children:u()})}exports.FormField=K;exports.styles=i;
|
package/dist/FormField.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._formBlock_1nwvd_1{width:100%;padding-top:var(--spacing-xl);padding-bottom:var(--spacing-xl)}._container_1nwvd_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_1nwvd_20{width:100%;margin-left:auto;margin-right:auto}._maxWidthSm_1nwvd_26{max-width:480px}._maxWidthMd_1nwvd_29{max-width:640px}._maxWidthLg_1nwvd_32{max-width:800px}._maxWidthFull_1nwvd_35{max-width:100%}._heading_1nwvd_41{display:flex;flex-direction:column;gap:var(--spacing-sm)}._eyebrow_1nwvd_47{font-weight:var(--font-weight-bold)}._title_1nwvd_51{text-wrap:balance}._progress_1nwvd_57{display:flex;flex-direction:column;gap:var(--spacing-sm)}._progressHeader_1nwvd_63{display:flex;justify-content:space-between;align-items:center}._stepLabel_1nwvd_69{font-weight:var(--font-weight-semibold);font-size:var(--font-size-md);color:var(--color-text-primary)}._stepCount_1nwvd_75{font-size:var(--font-size-sm);color:var(--color-secondary-50)}._stepDescription_1nwvd_80{color:var(--color-secondary-75);font-size:var(--font-size-md);margin:0}._fields_1nwvd_88{display:flex;flex-wrap:wrap;gap:var(--spacing-md)}._fieldFull_1nwvd_95{width:100%}._fieldHalf_1nwvd_99{width:calc(50% - var(--spacing-md) / 2)}@media (max-width: 767px){._fieldHalf_1nwvd_99{width:100%}}._fieldThird_1nwvd_107{width:calc(33.333% - var(--spacing-md) * 2 / 3)}@media (max-width: 767px){._fieldThird_1nwvd_107{width:100%}}._actions_1nwvd_117{display:flex;align-items:center;gap:var(--spacing-md);padding-top:var(--spacing-sm)}._submitButton_1nwvd_124{margin-left:auto}._success_1nwvd_130{display:flex;flex-direction:column;align-items:flex-start;gap:var(--spacing-lg);padding:var(--spacing-md) 0 0}._success_1nwvd_130 p{color:var(--color-states-success-bg);font-weight:var(--font-weight-semibold)}._errorBanner_1nwvd_145{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
|
@@ -1569,7 +1569,7 @@ declare type RangeSize = "sm" | "md" | "lg";
|
|
|
1569
1569
|
* <HeroBlock {...section} renderCallToAction={renderCallToAction} />
|
|
1570
1570
|
* <ContentBlock {...section} renderCallToAction={renderCallToAction} />
|
|
1571
1571
|
*/
|
|
1572
|
-
export declare function renderCallToAction({ alignment, spacing,
|
|
1572
|
+
export declare function renderCallToAction({ alignment, spacing, items, className, }: RenderCallToActionProps_3): default_2.ReactElement | null;
|
|
1573
1573
|
|
|
1574
1574
|
export { RenderCallToActionProps }
|
|
1575
1575
|
|
|
@@ -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-DU5sh1Fk.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-D1m8xWkL.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"),u=require("react"),U=require("../../../core/components/Form/index.cjs"),E=require("../../../index-0SVQqhAg.cjs"),V=require("../../../core/components/ProgressBar/index.cjs"),W=require("../../hooks/useStyleClasses.cjs"),s=require("../../../FormField-
|
|
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-0SVQqhAg.cjs"),V=require("../../../core/components/ProgressBar/index.cjs"),W=require("../../hooks/useStyleClasses.cjs"),s=require("../../../FormField-DU5sh1Fk.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:S,submitLabel:h="Submit",nextLabel:C="Next",backLabel:T="Back",successMessage:F="Thank you! Your submission has been received.",errorMessage:p="Something went wrong. Please try again.",styleOptions:R,renderRichText:n,onSubmit:v}){const j=W.useStyleClasses(R??{}),N={sm:s.styles.maxWidthSm,md:s.styles.maxWidthMd,lg:s.styles.maxWidthLg,full:s.styles.maxWidthFull}[B],g=u.useMemo(()=>_.buildInitialValues(S),[]),[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=S.length,k=y>1,f=m===y-1,$=(m+1)/y*100,a=S[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:p}})}},[a.fields,i,v,p]);return o!=null&&o.success?e.jsx("section",{id:r,className:`${s.styles.formBlock} ${j}`,children:e.jsx("div",{className:`${s.styles.formInner} ${N}`,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} ${j}`,children:e.jsx("div",{className:`${s.styles.formInner} ${N}`,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}))]}),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??p}),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;
|
|
@@ -4,7 +4,7 @@ import { Form as M } from "../../../core/components/Form/index.mjs";
|
|
|
4
4
|
import { B as y } from "../../../index-aWdsapYP.js";
|
|
5
5
|
import { ProgressBar as G } from "../../../core/components/ProgressBar/index.mjs";
|
|
6
6
|
import { useStyleClasses as X } from "../../hooks/useStyleClasses.mjs";
|
|
7
|
-
import { s, F as z } from "../../../FormField-
|
|
7
|
+
import { s, F as z } from "../../../FormField-D1m8xWkL.js";
|
|
8
8
|
import { buildInitialValues as H, validateStep as B } from "./validate.mjs";
|
|
9
9
|
function Y(r, e) {
|
|
10
10
|
switch (e.type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),i=require("../ui/PortableTextRenderer/index.cjs"),u=require("../ui/CallToAction/index.cjs"),d=require("../../index-0SVQqhAg.cjs");function f(n){return n.flatMap(t=>t.children??[]).map(t=>t.text??"").join("")}function x({blocks:n,className:t,textOverride:e,animateText:o}){return n!=null&&n.length?l.jsx(i.RichText,{blocks:n,className:t,textOverride:e,animateText:o}):null}function h({alignment:n,spacing:t,items:e,className:o}){if(!(e!=null&&e.length))return null;const c=e.filter(r=>r.type==="modal"),a=e.filter(r=>r.type!=="modal");return l.jsxs(l.Fragment,{children:[a.length>0&&l.jsx(u.CallToAction,{alignment:n,items:a,className:o,spacing:t}),c.map(r=>l.jsx(g,{item:r},r._key??r.label))]})}function g({item:n}){var e,o;return n.formReference||((e=n.modalContent)==null?void 0:e.length)?l.jsx(d.Button,{as:"modal",variant:n.variant??"primary",icon:n.icon,iconAlignment:n.iconAlignment??"right",modalPayload:{heading:(o=n.formReference)==null?void 0:o.heading,formReference:n.formReference,modalContent:n.modalContent},children:n.label??"Open"}):null}exports.extractText=f;exports.renderCallToAction=h;exports.renderRichText=x;
|
|
@@ -1,45 +1,67 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { RichText as
|
|
3
|
-
import { CallToAction as
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { jsx as a, jsxs as c, Fragment as i } from "react/jsx-runtime";
|
|
2
|
+
import { RichText as d } from "../ui/PortableTextRenderer/index.mjs";
|
|
3
|
+
import { CallToAction as u } from "../ui/CallToAction/index.mjs";
|
|
4
|
+
import { B as h } from "../../index-aWdsapYP.js";
|
|
5
|
+
function R(n) {
|
|
6
|
+
return n.flatMap((e) => e.children ?? []).map((e) => e.text ?? "").join("");
|
|
6
7
|
}
|
|
7
|
-
function
|
|
8
|
-
blocks:
|
|
9
|
-
className:
|
|
10
|
-
textOverride:
|
|
11
|
-
animateText:
|
|
8
|
+
function y({
|
|
9
|
+
blocks: n,
|
|
10
|
+
className: e,
|
|
11
|
+
textOverride: r,
|
|
12
|
+
animateText: o
|
|
12
13
|
}) {
|
|
13
|
-
return
|
|
14
|
-
|
|
14
|
+
return n != null && n.length ? /* @__PURE__ */ a(
|
|
15
|
+
d,
|
|
15
16
|
{
|
|
16
|
-
blocks:
|
|
17
|
-
className:
|
|
18
|
-
textOverride:
|
|
19
|
-
animateText:
|
|
17
|
+
blocks: n,
|
|
18
|
+
className: e,
|
|
19
|
+
textOverride: r,
|
|
20
|
+
animateText: o
|
|
20
21
|
}
|
|
21
22
|
) : null;
|
|
22
23
|
}
|
|
23
24
|
function T({
|
|
24
|
-
alignment:
|
|
25
|
-
spacing:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
className: u
|
|
25
|
+
alignment: n,
|
|
26
|
+
spacing: e,
|
|
27
|
+
items: r,
|
|
28
|
+
className: o
|
|
29
29
|
}) {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
if (!(r != null && r.length)) return null;
|
|
31
|
+
const f = r.filter((t) => t.type === "modal"), l = r.filter((t) => t.type !== "modal");
|
|
32
|
+
return /* @__PURE__ */ c(i, { children: [
|
|
33
|
+
l.length > 0 && /* @__PURE__ */ a(
|
|
34
|
+
u,
|
|
35
|
+
{
|
|
36
|
+
alignment: n,
|
|
37
|
+
items: l,
|
|
38
|
+
className: o,
|
|
39
|
+
spacing: e
|
|
40
|
+
}
|
|
41
|
+
),
|
|
42
|
+
f.map((t) => /* @__PURE__ */ a(m, { item: t }, t._key ?? t.label))
|
|
43
|
+
] });
|
|
44
|
+
}
|
|
45
|
+
function m({ item: n }) {
|
|
46
|
+
var r, o;
|
|
47
|
+
return n.formReference || ((r = n.modalContent) == null ? void 0 : r.length) ? /* @__PURE__ */ a(
|
|
48
|
+
h,
|
|
32
49
|
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
50
|
+
as: "modal",
|
|
51
|
+
variant: n.variant ?? "primary",
|
|
52
|
+
icon: n.icon,
|
|
53
|
+
iconAlignment: n.iconAlignment ?? "right",
|
|
54
|
+
modalPayload: {
|
|
55
|
+
heading: (o = n.formReference) == null ? void 0 : o.heading,
|
|
56
|
+
formReference: n.formReference,
|
|
57
|
+
modalContent: n.modalContent
|
|
58
|
+
},
|
|
59
|
+
children: n.label ?? "Open"
|
|
38
60
|
}
|
|
39
61
|
) : null;
|
|
40
62
|
}
|
|
41
63
|
export {
|
|
42
|
-
|
|
64
|
+
R as extractText,
|
|
43
65
|
T as renderCallToAction,
|
|
44
|
-
|
|
66
|
+
y as renderRichText
|
|
45
67
|
};
|
package/dist/next.d.ts
CHANGED
|
@@ -266,7 +266,7 @@ export { QuoteBlockProps }
|
|
|
266
266
|
* <HeroBlock {...section} renderCallToAction={renderCallToAction} />
|
|
267
267
|
* <ContentBlock {...section} renderCallToAction={renderCallToAction} />
|
|
268
268
|
*/
|
|
269
|
-
export declare function renderCallToAction({ alignment, spacing,
|
|
269
|
+
export declare function renderCallToAction({ alignment, spacing, items, className, }: RenderCallToActionProps_2): default_2.ReactElement | null;
|
|
270
270
|
|
|
271
271
|
/**
|
|
272
272
|
* Drop-in `renderRichText` prop for all QuirkUI blocks.
|
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"),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;
|