@solspace/freeform-vue 0.1.17
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/LICENSE +22 -0
- package/README.md +61 -0
- package/dist/components/CaptchaHost.vue.d.ts +9 -0
- package/dist/components/ExtensionHost.vue.d.ts +23 -0
- package/dist/components/FieldRenderer.vue.d.ts +12 -0
- package/dist/components/FormLoader.vue.d.ts +12 -0
- package/dist/components/Freeform.vue.d.ts +24 -0
- package/dist/components/FreeformView.vue.d.ts +10 -0
- package/dist/composables/useFieldExtension.d.ts +3 -0
- package/dist/composables/useFreeform.d.ts +3 -0
- package/dist/index.css +2 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +1764 -0
- package/dist/index.js.map +1 -0
- package/dist/renderers/builtin/CalculationField.d.ts +23 -0
- package/dist/renderers/builtin/SignatureField.d.ts +23 -0
- package/dist/renderers/builtin/TableField.d.ts +23 -0
- package/dist/renderers/builtin/fields.d.ts +29 -0
- package/dist/renderers/builtin/index.d.ts +3 -0
- package/dist/renderers/builtin/wrappers.d.ts +825 -0
- package/dist/renderers/resolve.d.ts +3 -0
- package/dist/theme/defaultTheme.d.ts +3 -0
- package/dist/theme/mergeClassNames.d.ts +3 -0
- package/dist/theme/resolveThemeClassNames.d.ts +7 -0
- package/dist/theme/toBemModifier.d.ts +5 -0
- package/dist/types.d.ts +184 -0
- package/dist/utils/securityMeta.d.ts +2 -0
- package/dist/version.d.ts +2 -0
- package/package.json +55 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1764 @@
|
|
|
1
|
+
import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createTextVNode as o, createVNode as s, defineComponent as c, mergeProps as l, normalizeClass as u, normalizeProps as d, normalizeStyle as f, onMounted as p, onScopeDispose as m, onUnmounted as h, openBlock as g, reactive as _, ref as v, renderList as y, renderSlot as b, resolveComponent as x, resolveDynamicComponent as S, shallowRef as C, toDisplayString as w, toValue as ee, unref as T, watch as E, watchEffect as te, withCtx as D } from "vue";
|
|
2
|
+
import { canAddTableRow as O, canRemoveTableRow as k, collectExtensionSubmitMeta as ne, createFormState as A, createFreeformClient as re, emptyTableRow as j, evaluateCalculation as M, getCalculationConfig as N, getSignatureConfig as P, getTableConfig as F, isSignatureValueEmpty as I, normalizeTableRows as L, prepareSubmitValues as ie, resolveTableColumnOptions as R, runExtensionAfterSubmit as ae, runExtensionSetups as oe } from "@solspace/freeform-core";
|
|
3
|
+
//#region src/components/FormLoader.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var z = ["data-variant"], B = {
|
|
5
|
+
key: 0,
|
|
6
|
+
class: "ff-loader-skeleton",
|
|
7
|
+
"aria-hidden": "true"
|
|
8
|
+
}, V = {
|
|
9
|
+
key: 1,
|
|
10
|
+
class: "ff-loader-spinner",
|
|
11
|
+
"aria-hidden": "true"
|
|
12
|
+
}, se = { class: "ff-loader-message" }, ce = /*#__PURE__*/ ((e, t) => {
|
|
13
|
+
let n = e.__vccOpts || e;
|
|
14
|
+
for (let [e, r] of t) n[e] = r;
|
|
15
|
+
return n;
|
|
16
|
+
})(/* @__PURE__ */ c({
|
|
17
|
+
__name: "FormLoader",
|
|
18
|
+
props: {
|
|
19
|
+
message: { default: "Loading form…" },
|
|
20
|
+
loaderClass: { default: "ff-loader" },
|
|
21
|
+
variant: { default: "skeleton" }
|
|
22
|
+
},
|
|
23
|
+
setup(t) {
|
|
24
|
+
return (n, r) => (g(), i("div", {
|
|
25
|
+
role: "status",
|
|
26
|
+
"aria-live": "polite",
|
|
27
|
+
"aria-busy": "true",
|
|
28
|
+
"data-variant": t.variant,
|
|
29
|
+
class: u(["ff-loader-root", t.loaderClass])
|
|
30
|
+
}, [t.variant === "skeleton" ? (g(), i("div", B, [
|
|
31
|
+
r[0] ||= a("div", { class: "ff-loader-line ff-loader-line--title" }, null, -1),
|
|
32
|
+
(g(), i(e, null, y(3, (e) => a("div", {
|
|
33
|
+
key: e,
|
|
34
|
+
class: "ff-loader-field"
|
|
35
|
+
}, [a("div", {
|
|
36
|
+
class: "ff-loader-line ff-loader-line--label",
|
|
37
|
+
style: f({ animationDelay: `${e * .12}s` })
|
|
38
|
+
}, null, 4), a("div", {
|
|
39
|
+
class: "ff-loader-line ff-loader-line--input",
|
|
40
|
+
style: f({
|
|
41
|
+
width: e === 2 ? "62%" : "100%",
|
|
42
|
+
animationDelay: `${e * .12}s`
|
|
43
|
+
})
|
|
44
|
+
}, null, 4)])), 64)),
|
|
45
|
+
r[1] ||= a("div", {
|
|
46
|
+
class: "ff-loader-line ff-loader-line--button",
|
|
47
|
+
style: { animationDelay: "0.36s" }
|
|
48
|
+
}, null, -1)
|
|
49
|
+
])) : (g(), i("div", V)), a("p", se, w(t.message), 1)], 10, z));
|
|
50
|
+
}
|
|
51
|
+
}), [["__scopeId", "data-v-36bcdb81"]]), H = {
|
|
52
|
+
name: "default",
|
|
53
|
+
framework: "vue",
|
|
54
|
+
classNameStrategy: "merge",
|
|
55
|
+
classNames: {
|
|
56
|
+
form: "ff-form",
|
|
57
|
+
page: "ff-page",
|
|
58
|
+
row: "ff-row",
|
|
59
|
+
field: "ff-field",
|
|
60
|
+
fieldRequired: "ff-field--required",
|
|
61
|
+
fieldHidden: "ff-field--hidden",
|
|
62
|
+
fieldHasErrors: "ff-field--has-errors",
|
|
63
|
+
label: "ff-field__label",
|
|
64
|
+
instructions: "ff-field__instructions",
|
|
65
|
+
input: "ff-field__input",
|
|
66
|
+
content: "ff-field__content",
|
|
67
|
+
errors: "ff-field__errors",
|
|
68
|
+
error: "ff-field__error",
|
|
69
|
+
buttons: "ff-form__buttons",
|
|
70
|
+
button: "ff-button",
|
|
71
|
+
submitButton: "ff-button ff-button--submit",
|
|
72
|
+
nextButton: "ff-button ff-button--next",
|
|
73
|
+
backButton: "ff-button ff-button--back",
|
|
74
|
+
saveButton: "ff-button ff-button--save",
|
|
75
|
+
success: "ff-form__success"
|
|
76
|
+
},
|
|
77
|
+
defaults: {
|
|
78
|
+
renderLabels: !0,
|
|
79
|
+
renderInstructions: !0,
|
|
80
|
+
renderErrors: !0,
|
|
81
|
+
requiredIndicator: "*",
|
|
82
|
+
colorScheme: "system"
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
function U(e, t) {
|
|
86
|
+
if (!e && !t) return;
|
|
87
|
+
let n = /* @__PURE__ */ new Set([...Object.keys(e ?? {}), ...Object.keys(t ?? {})]), r = {};
|
|
88
|
+
for (let i of n) r[i] = {
|
|
89
|
+
...e?.[i],
|
|
90
|
+
...t?.[i]
|
|
91
|
+
};
|
|
92
|
+
return r;
|
|
93
|
+
}
|
|
94
|
+
function le(e = {}) {
|
|
95
|
+
let t = e.classNameStrategy ?? H.classNameStrategy, n = t !== "replace";
|
|
96
|
+
return {
|
|
97
|
+
...H,
|
|
98
|
+
...e,
|
|
99
|
+
classNameStrategy: t,
|
|
100
|
+
classNames: n ? {
|
|
101
|
+
...H.classNames,
|
|
102
|
+
...e.classNames
|
|
103
|
+
} : { ...e.classNames },
|
|
104
|
+
classNamesByType: U(n ? H.classNamesByType : void 0, e.classNamesByType),
|
|
105
|
+
defaults: {
|
|
106
|
+
...H.defaults,
|
|
107
|
+
...e.defaults
|
|
108
|
+
},
|
|
109
|
+
renderers: {
|
|
110
|
+
...H.renderers,
|
|
111
|
+
...e.renderers,
|
|
112
|
+
handles: {
|
|
113
|
+
...H.renderers?.handles,
|
|
114
|
+
...e.renderers?.handles
|
|
115
|
+
},
|
|
116
|
+
frontend: {
|
|
117
|
+
...H.renderers?.frontend,
|
|
118
|
+
...e.renderers?.frontend
|
|
119
|
+
},
|
|
120
|
+
types: {
|
|
121
|
+
...H.renderers?.types,
|
|
122
|
+
...e.renderers?.types
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/version.ts
|
|
129
|
+
var ue = "0.1.17", de = "@solspace/freeform-vue";
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region src/utils/securityMeta.ts
|
|
132
|
+
function fe(e) {
|
|
133
|
+
let t = {};
|
|
134
|
+
return e.security.honeypot?.name && (t.honeypot = {
|
|
135
|
+
name: e.security.honeypot.name,
|
|
136
|
+
value: ""
|
|
137
|
+
}), e.security.javascriptTest?.name && (t.javascriptTest = {
|
|
138
|
+
name: e.security.javascriptTest.name,
|
|
139
|
+
value: e.security.javascriptTest.value ?? ""
|
|
140
|
+
}), t;
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/composables/useFreeform.ts
|
|
144
|
+
function pe(e, t) {
|
|
145
|
+
return {
|
|
146
|
+
values: { ...e.values },
|
|
147
|
+
touched: { ...e.touched },
|
|
148
|
+
fieldErrors: { ...e.fieldErrors },
|
|
149
|
+
formErrors: [...e.formErrors],
|
|
150
|
+
pageErrors: [...e.pageErrors],
|
|
151
|
+
currentPageIndex: e.currentPageIndex,
|
|
152
|
+
visibilityVersion: t
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function me(e) {
|
|
156
|
+
let n = t(() => ee(e)), r = t(() => n.value.theme ?? H), i = t(() => n.value.renderers ?? {}), a = t(() => n.value.allowRawHtml ?? !1), o = C(null), s = C(null), c = C(/* @__PURE__ */ new Map()), l = C(/* @__PURE__ */ new Map()), u = C([]), d = v(0), f = v(null), p = v(n.value.manifest ?? null), h = v(!n.value.manifest), g = v(null), y = v(!1), b = v(!1), x = v(null), S = v({
|
|
157
|
+
values: {},
|
|
158
|
+
touched: {},
|
|
159
|
+
fieldErrors: {},
|
|
160
|
+
formErrors: [],
|
|
161
|
+
pageErrors: [],
|
|
162
|
+
currentPageIndex: 0,
|
|
163
|
+
visibilityVersion: 0
|
|
164
|
+
});
|
|
165
|
+
E(() => n.value.extensions, (e) => {
|
|
166
|
+
u.value = e ?? [];
|
|
167
|
+
}, { immediate: !0 });
|
|
168
|
+
function w() {
|
|
169
|
+
let e = s.value;
|
|
170
|
+
e && (d.value += 1, S.value = pe(e, d.value));
|
|
171
|
+
}
|
|
172
|
+
function T() {
|
|
173
|
+
o.value ||= re({
|
|
174
|
+
baseUrl: n.value.baseUrl,
|
|
175
|
+
clientVersion: n.value.clientVersion ?? "0.1.17",
|
|
176
|
+
fetch: n.value.fetch,
|
|
177
|
+
credentials: n.value.credentials
|
|
178
|
+
});
|
|
179
|
+
for (let e of u.value) o.value.extensions.register(e);
|
|
180
|
+
return o.value;
|
|
181
|
+
}
|
|
182
|
+
E(() => n.value.extensions, () => {
|
|
183
|
+
let e = T();
|
|
184
|
+
for (let t of u.value) e.extensions.register(t);
|
|
185
|
+
}), E(p, (e) => {
|
|
186
|
+
e && oe(u.value, { manifest: e });
|
|
187
|
+
}), E(() => [
|
|
188
|
+
n.value.handle,
|
|
189
|
+
n.value.profile,
|
|
190
|
+
n.value.properties,
|
|
191
|
+
n.value.manifest,
|
|
192
|
+
n.value.initialValues
|
|
193
|
+
], () => {
|
|
194
|
+
if (n.value.manifest) {
|
|
195
|
+
s.value = A({
|
|
196
|
+
manifest: n.value.manifest,
|
|
197
|
+
initialValues: n.value.initialValues,
|
|
198
|
+
draftToken: n.value.draftToken,
|
|
199
|
+
draftKey: n.value.draftKey
|
|
200
|
+
}), p.value = n.value.manifest, w(), h.value = !1;
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (!n.value.handle && !n.value.profile) {
|
|
204
|
+
g.value = /* @__PURE__ */ Error("Either handle, profile, or manifest is required."), h.value = !1;
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
let e = !1;
|
|
208
|
+
(async () => {
|
|
209
|
+
h.value = !0, g.value = null;
|
|
210
|
+
try {
|
|
211
|
+
let t = await T().loadManifest({
|
|
212
|
+
handle: n.value.handle,
|
|
213
|
+
profile: n.value.profile,
|
|
214
|
+
properties: n.value.properties
|
|
215
|
+
});
|
|
216
|
+
if (e) return;
|
|
217
|
+
s.value = A({
|
|
218
|
+
manifest: t,
|
|
219
|
+
initialValues: n.value.initialValues,
|
|
220
|
+
draftToken: n.value.draftToken,
|
|
221
|
+
draftKey: n.value.draftKey
|
|
222
|
+
}), p.value = t, w(), n.value.onManifestLoaded?.(t);
|
|
223
|
+
} catch (t) {
|
|
224
|
+
e || (g.value = t instanceof Error ? t : /* @__PURE__ */ Error("Failed to load manifest."));
|
|
225
|
+
} finally {
|
|
226
|
+
e || (h.value = !1);
|
|
227
|
+
}
|
|
228
|
+
})(), m(() => {
|
|
229
|
+
e = !0;
|
|
230
|
+
});
|
|
231
|
+
}, { immediate: !0 }), E(() => [n.value.draftToken, n.value.draftKey], () => {
|
|
232
|
+
let e = s.value;
|
|
233
|
+
e && (n.value.draftToken !== void 0 && (e.draftToken = n.value.draftToken ?? null), n.value.draftKey !== void 0 && (e.draftKey = n.value.draftKey ?? null));
|
|
234
|
+
});
|
|
235
|
+
function D(e, t) {
|
|
236
|
+
s.value?.setValue(e, t), w();
|
|
237
|
+
}
|
|
238
|
+
function O(e) {
|
|
239
|
+
return s.value?.getValue(e);
|
|
240
|
+
}
|
|
241
|
+
function k(e) {
|
|
242
|
+
return s.value?.isFieldVisible(e) ?? !1;
|
|
243
|
+
}
|
|
244
|
+
function j(e) {
|
|
245
|
+
return s.value?.isFieldEnabled(e) ?? !0;
|
|
246
|
+
}
|
|
247
|
+
function M(e) {
|
|
248
|
+
let t = s.value, n = p.value?.fields[e], r = t?.getValue(e);
|
|
249
|
+
return {
|
|
250
|
+
id: `freeform-${e}`,
|
|
251
|
+
name: e,
|
|
252
|
+
value: r ?? "",
|
|
253
|
+
onChange: (t) => {
|
|
254
|
+
let n = t.target;
|
|
255
|
+
D(e, n.value);
|
|
256
|
+
},
|
|
257
|
+
onBlur: () => {
|
|
258
|
+
let t = s.value;
|
|
259
|
+
t && (t.touched = {
|
|
260
|
+
...t.touched,
|
|
261
|
+
[e]: !0
|
|
262
|
+
}, w());
|
|
263
|
+
},
|
|
264
|
+
disabled: !j(e),
|
|
265
|
+
required: n?.required ?? !1,
|
|
266
|
+
placeholder: n?.placeholder ?? void 0,
|
|
267
|
+
"aria-invalid": (t?.fieldErrors[e]?.length ?? 0) > 0
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
async function N(e = "submit") {
|
|
271
|
+
let t = s.value, r = p.value;
|
|
272
|
+
if (!(!t || !r)) {
|
|
273
|
+
y.value = !0;
|
|
274
|
+
try {
|
|
275
|
+
let i = t.getValuesForSubmit(), { values: a, files: o } = ie(i, r.fields), s = {
|
|
276
|
+
...t.getSubmitContext(),
|
|
277
|
+
sourceUrl: typeof window < "u" ? window.location.href : void 0
|
|
278
|
+
}, c = fe(r), l = await ne(u.value, {
|
|
279
|
+
manifest: r,
|
|
280
|
+
intent: e,
|
|
281
|
+
values: a,
|
|
282
|
+
meta: c,
|
|
283
|
+
context: s,
|
|
284
|
+
baseUrl: n.value.baseUrl
|
|
285
|
+
}), d = await T().submit({
|
|
286
|
+
manifest: r,
|
|
287
|
+
request: {
|
|
288
|
+
values: a,
|
|
289
|
+
intent: e,
|
|
290
|
+
context: s,
|
|
291
|
+
meta: {
|
|
292
|
+
client: de,
|
|
293
|
+
clientVersion: n.value.clientVersion ?? "0.1.17",
|
|
294
|
+
...l
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
files: Object.keys(o).length > 0 ? o : void 0
|
|
298
|
+
});
|
|
299
|
+
return t.applySubmitResponse(d), w(), await ae(u.value, {
|
|
300
|
+
manifest: r,
|
|
301
|
+
intent: e,
|
|
302
|
+
response: d,
|
|
303
|
+
baseUrl: n.value.baseUrl
|
|
304
|
+
}), d.complete && (b.value = !0, x.value = d.message ?? r.settings.successMessage ?? "Thank you for your submission."), d.success ? n.value.onSuccess?.(d) : n.value.onError?.(d), d;
|
|
305
|
+
} catch (e) {
|
|
306
|
+
if (e instanceof Error && (e.name === "StripePaymentRedirectError" || e.name === "MolliePaymentRedirectError")) return;
|
|
307
|
+
let r = e instanceof Error ? e : /* @__PURE__ */ Error("Something went wrong while submitting the form.");
|
|
308
|
+
t && (t.formErrors = [r.message], t.fieldErrors = {}, t.pageErrors = [], w()), n.value.onError?.({
|
|
309
|
+
success: !1,
|
|
310
|
+
status: "error",
|
|
311
|
+
complete: !1,
|
|
312
|
+
errors: {
|
|
313
|
+
fields: {},
|
|
314
|
+
form: [r.message],
|
|
315
|
+
page: []
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
return;
|
|
319
|
+
} finally {
|
|
320
|
+
y.value = !1;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
let P = () => N("validate"), F = () => N("next"), I = () => N("back"), L = () => N("saveDraft");
|
|
325
|
+
E(() => [
|
|
326
|
+
p.value,
|
|
327
|
+
n.value.draftToken,
|
|
328
|
+
n.value.draftKey
|
|
329
|
+
], () => {
|
|
330
|
+
if (!p.value) return;
|
|
331
|
+
let e = n.value.draftToken, t = n.value.draftKey;
|
|
332
|
+
if (!e || !t) return;
|
|
333
|
+
let r = `${e}:${t}`;
|
|
334
|
+
f.value !== r && (f.value = r, N("validate"));
|
|
335
|
+
});
|
|
336
|
+
function R() {
|
|
337
|
+
p.value && (s.value = A({
|
|
338
|
+
manifest: p.value,
|
|
339
|
+
initialValues: n.value.initialValues,
|
|
340
|
+
draftToken: n.value.draftToken,
|
|
341
|
+
draftKey: n.value.draftKey
|
|
342
|
+
}), b.value = !1, x.value = null, w());
|
|
343
|
+
}
|
|
344
|
+
async function z(e) {
|
|
345
|
+
e?.preventDefault();
|
|
346
|
+
let t = p.value;
|
|
347
|
+
if (!t) return;
|
|
348
|
+
let n = t.layout.pages, r = n.length === 0 || S.value.currentPageIndex >= n.length - 1;
|
|
349
|
+
if (t.settings.multiPage && !r) {
|
|
350
|
+
await F();
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
await N("submit");
|
|
354
|
+
}
|
|
355
|
+
function B(e, t) {
|
|
356
|
+
let r = p.value;
|
|
357
|
+
if (!r) return () => {};
|
|
358
|
+
c.value.set(e, t);
|
|
359
|
+
let i = r.fields[e];
|
|
360
|
+
if (!i) return () => {
|
|
361
|
+
c.value.delete(e);
|
|
362
|
+
};
|
|
363
|
+
let a = !1, o = [];
|
|
364
|
+
return (async () => {
|
|
365
|
+
for (let c of u.value) {
|
|
366
|
+
if (c.supports && !c.supports(i) || !c.mount) continue;
|
|
367
|
+
let l = await c.mount({
|
|
368
|
+
manifest: r,
|
|
369
|
+
field: i,
|
|
370
|
+
element: t,
|
|
371
|
+
value: s.value?.getValue(e),
|
|
372
|
+
setValue: (t) => {
|
|
373
|
+
s.value?.setValue(e, t), w();
|
|
374
|
+
},
|
|
375
|
+
getValues: () => s.value?.getValuesForSubmit() ?? {},
|
|
376
|
+
baseUrl: n.value.baseUrl,
|
|
377
|
+
requestSubmit: () => {
|
|
378
|
+
N("submit");
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
if (a) {
|
|
382
|
+
typeof l == "function" && l();
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
typeof l == "function" && o.push(l);
|
|
386
|
+
}
|
|
387
|
+
})(), () => {
|
|
388
|
+
a = !0;
|
|
389
|
+
for (let e of o) e();
|
|
390
|
+
c.value.delete(e);
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
function V(e, t) {
|
|
394
|
+
let n = p.value;
|
|
395
|
+
if (!n) return () => {};
|
|
396
|
+
let r = !1, i = [];
|
|
397
|
+
(async () => {
|
|
398
|
+
for (let a of u.value) {
|
|
399
|
+
let o = await a.mountCaptcha?.({
|
|
400
|
+
manifest: n,
|
|
401
|
+
captcha: e,
|
|
402
|
+
element: t
|
|
403
|
+
});
|
|
404
|
+
if (r) {
|
|
405
|
+
typeof o == "function" && o();
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
typeof o == "function" && i.push(o);
|
|
409
|
+
}
|
|
410
|
+
})();
|
|
411
|
+
let a = () => {
|
|
412
|
+
r = !0;
|
|
413
|
+
for (let e of i) e();
|
|
414
|
+
l.value.delete(e.name);
|
|
415
|
+
};
|
|
416
|
+
return l.value.set(e.name, a), a;
|
|
417
|
+
}
|
|
418
|
+
let se = t(() => {
|
|
419
|
+
let e = p.value;
|
|
420
|
+
return e ? {
|
|
421
|
+
manifest: e,
|
|
422
|
+
values: S.value.values,
|
|
423
|
+
touched: S.value.touched,
|
|
424
|
+
fieldErrors: S.value.fieldErrors,
|
|
425
|
+
formErrors: S.value.formErrors,
|
|
426
|
+
pageErrors: S.value.pageErrors,
|
|
427
|
+
currentPageIndex: S.value.currentPageIndex,
|
|
428
|
+
isSubmitting: y.value,
|
|
429
|
+
isComplete: b.value,
|
|
430
|
+
successMessage: x.value,
|
|
431
|
+
setValue: D,
|
|
432
|
+
getValue: O,
|
|
433
|
+
isFieldVisible: k,
|
|
434
|
+
isFieldEnabled: j,
|
|
435
|
+
getFieldProps: M,
|
|
436
|
+
submit: N,
|
|
437
|
+
validate: P,
|
|
438
|
+
goNext: F,
|
|
439
|
+
goBack: I,
|
|
440
|
+
saveDraft: L,
|
|
441
|
+
reset: R,
|
|
442
|
+
handleSubmit: z,
|
|
443
|
+
mountFieldExtension: B,
|
|
444
|
+
mountCaptcha: V
|
|
445
|
+
} : null;
|
|
446
|
+
}), ce = {
|
|
447
|
+
values: {},
|
|
448
|
+
touched: {},
|
|
449
|
+
fieldErrors: {},
|
|
450
|
+
formErrors: [],
|
|
451
|
+
pageErrors: [],
|
|
452
|
+
currentPageIndex: 0,
|
|
453
|
+
isSubmitting: !1,
|
|
454
|
+
isComplete: !1,
|
|
455
|
+
successMessage: null,
|
|
456
|
+
setValue: D,
|
|
457
|
+
getValue: O,
|
|
458
|
+
isFieldVisible: k,
|
|
459
|
+
isFieldEnabled: j,
|
|
460
|
+
getFieldProps: M,
|
|
461
|
+
submit: N,
|
|
462
|
+
validate: P,
|
|
463
|
+
goNext: F,
|
|
464
|
+
goBack: I,
|
|
465
|
+
saveDraft: L,
|
|
466
|
+
reset: R,
|
|
467
|
+
handleSubmit: z,
|
|
468
|
+
mountFieldExtension: B,
|
|
469
|
+
mountCaptcha: V
|
|
470
|
+
}, U = _({});
|
|
471
|
+
return te(() => {
|
|
472
|
+
let e = se.value;
|
|
473
|
+
if (!e) {
|
|
474
|
+
Object.assign(U, {
|
|
475
|
+
loading: h.value,
|
|
476
|
+
error: g.value,
|
|
477
|
+
manifest: null,
|
|
478
|
+
theme: r.value,
|
|
479
|
+
renderers: i.value,
|
|
480
|
+
allowRawHtml: a.value,
|
|
481
|
+
...ce
|
|
482
|
+
});
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
Object.assign(U, {
|
|
486
|
+
...e,
|
|
487
|
+
loading: h.value,
|
|
488
|
+
error: g.value,
|
|
489
|
+
manifest: p.value,
|
|
490
|
+
theme: r.value,
|
|
491
|
+
renderers: i.value,
|
|
492
|
+
allowRawHtml: a.value
|
|
493
|
+
});
|
|
494
|
+
}), U;
|
|
495
|
+
}
|
|
496
|
+
//#endregion
|
|
497
|
+
//#region src/components/Freeform.vue?vue&type=script&setup=true&lang.ts
|
|
498
|
+
var he = { role: "alert" }, ge = /* @__PURE__ */ c({
|
|
499
|
+
__name: "Freeform",
|
|
500
|
+
props: {
|
|
501
|
+
handle: {},
|
|
502
|
+
profile: {},
|
|
503
|
+
properties: {},
|
|
504
|
+
baseUrl: {},
|
|
505
|
+
manifest: {},
|
|
506
|
+
initialValues: {},
|
|
507
|
+
draftToken: {},
|
|
508
|
+
draftKey: {},
|
|
509
|
+
clientVersion: {},
|
|
510
|
+
fetch: {},
|
|
511
|
+
credentials: {},
|
|
512
|
+
theme: {},
|
|
513
|
+
renderers: {},
|
|
514
|
+
extensions: {},
|
|
515
|
+
allowRawHtml: { type: Boolean },
|
|
516
|
+
onSuccess: { type: Function },
|
|
517
|
+
onError: { type: Function },
|
|
518
|
+
onManifestLoaded: { type: Function },
|
|
519
|
+
class: {},
|
|
520
|
+
loadingMessage: {}
|
|
521
|
+
},
|
|
522
|
+
setup(e) {
|
|
523
|
+
let i = e, o = me(() => i), c = t(() => o.manifest ? o : null);
|
|
524
|
+
return (t, l) => {
|
|
525
|
+
let d = x("FormLoader"), f = x("FreeformView");
|
|
526
|
+
return t.$slots.default ? b(t.$slots, "default", { form: T(o) }, void 0, void 0, 0) : T(o).loading ? b(t.$slots, "loading", {}, () => [s(d, { message: e.loadingMessage ?? "Loading form…" }, null, 8, ["message"])], void 0, 1) : T(o).error ? b(t.$slots, "error", { error: T(o).error }, () => [a("div", he, w(T(o).error.message), 1)], void 0, 2) : c.value ? (g(), n(f, {
|
|
527
|
+
key: 3,
|
|
528
|
+
form: c.value,
|
|
529
|
+
class: u(i.class)
|
|
530
|
+
}, null, 8, ["form", "class"])) : r("", !0);
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
//#endregion
|
|
535
|
+
//#region src/composables/useFieldExtension.ts
|
|
536
|
+
function _e(e, t) {
|
|
537
|
+
let n = v(null), r;
|
|
538
|
+
function i() {
|
|
539
|
+
r?.(), r = void 0;
|
|
540
|
+
let i = n.value;
|
|
541
|
+
!i || !e.frontend?.extension || t.isFieldVisible(e.handle) && (r = t.mountFieldExtension(e.handle, i));
|
|
542
|
+
}
|
|
543
|
+
return p(i), E(() => [
|
|
544
|
+
e.frontend?.extension,
|
|
545
|
+
e.handle,
|
|
546
|
+
t.isFieldVisible(e.handle)
|
|
547
|
+
], i), h(() => {
|
|
548
|
+
r?.();
|
|
549
|
+
}), n;
|
|
550
|
+
}
|
|
551
|
+
//#endregion
|
|
552
|
+
//#region src/components/ExtensionHost.vue?vue&type=script&setup=true&lang.ts
|
|
553
|
+
var ve = ["hidden"], W = /* @__PURE__ */ c({
|
|
554
|
+
__name: "ExtensionHost",
|
|
555
|
+
props: {
|
|
556
|
+
field: {},
|
|
557
|
+
form: {},
|
|
558
|
+
class: {},
|
|
559
|
+
dataAttr: {},
|
|
560
|
+
dataValue: {},
|
|
561
|
+
hidden: { type: Boolean }
|
|
562
|
+
},
|
|
563
|
+
setup(e) {
|
|
564
|
+
let t = e, n = _e(t.field, t.form);
|
|
565
|
+
function r(e) {
|
|
566
|
+
n.value = e ?? null;
|
|
567
|
+
}
|
|
568
|
+
return (n, a) => (g(), i("div", d({
|
|
569
|
+
ref: r,
|
|
570
|
+
class: t.class,
|
|
571
|
+
[e.dataAttr || ""]: e.dataValue ?? e.field.handle,
|
|
572
|
+
hidden: e.hidden || void 0
|
|
573
|
+
}), [b(n.$slots, "default")], 16, ve));
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
//#endregion
|
|
577
|
+
//#region src/renderers/builtin/fields.tsx
|
|
578
|
+
function G(e) {
|
|
579
|
+
let t = e.input;
|
|
580
|
+
return {
|
|
581
|
+
...t,
|
|
582
|
+
placeholder: t.placeholder ?? void 0
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
function ye(e) {
|
|
586
|
+
let t = G(e);
|
|
587
|
+
return s("input", l({
|
|
588
|
+
type: "text",
|
|
589
|
+
class: e.classNames.input
|
|
590
|
+
}, t), null);
|
|
591
|
+
}
|
|
592
|
+
function be(e) {
|
|
593
|
+
let t = G(e);
|
|
594
|
+
return s("input", l({
|
|
595
|
+
type: "url",
|
|
596
|
+
class: e.classNames.input
|
|
597
|
+
}, t), null);
|
|
598
|
+
}
|
|
599
|
+
function xe(e) {
|
|
600
|
+
let t = G(e), n = e.field.validation?.pattern || (e.field.frontend?.config?.pattern ?? void 0);
|
|
601
|
+
return s("input", l({
|
|
602
|
+
type: "text",
|
|
603
|
+
class: e.classNames.input,
|
|
604
|
+
pattern: n || void 0
|
|
605
|
+
}, t), null);
|
|
606
|
+
}
|
|
607
|
+
function Se(e) {
|
|
608
|
+
let t = G(e);
|
|
609
|
+
return s("input", l({
|
|
610
|
+
type: "password",
|
|
611
|
+
class: e.classNames.input
|
|
612
|
+
}, t), null);
|
|
613
|
+
}
|
|
614
|
+
function Ce(e) {
|
|
615
|
+
let t = G(e), n = e.field.frontend?.config?.targetType === "password" ? "password" : "text";
|
|
616
|
+
return s("input", l({
|
|
617
|
+
type: n,
|
|
618
|
+
class: e.classNames.input
|
|
619
|
+
}, t), null);
|
|
620
|
+
}
|
|
621
|
+
function we(e) {
|
|
622
|
+
let t = G(e);
|
|
623
|
+
return s("input", l({
|
|
624
|
+
type: "email",
|
|
625
|
+
class: e.classNames.input
|
|
626
|
+
}, t), null);
|
|
627
|
+
}
|
|
628
|
+
function Te(e) {
|
|
629
|
+
let t = G(e);
|
|
630
|
+
return s("input", l({
|
|
631
|
+
type: "number",
|
|
632
|
+
class: e.classNames.input
|
|
633
|
+
}, t), null);
|
|
634
|
+
}
|
|
635
|
+
function Ee(e) {
|
|
636
|
+
let t = G(e);
|
|
637
|
+
return s("input", l({
|
|
638
|
+
type: "tel",
|
|
639
|
+
class: e.classNames.input
|
|
640
|
+
}, t), null);
|
|
641
|
+
}
|
|
642
|
+
function De(e) {
|
|
643
|
+
let t = G(e);
|
|
644
|
+
return s("input", l({ type: "hidden" }, t), null);
|
|
645
|
+
}
|
|
646
|
+
function Oe(e) {
|
|
647
|
+
let t = G(e);
|
|
648
|
+
return s("textarea", l({
|
|
649
|
+
class: e.classNames.input,
|
|
650
|
+
rows: 4
|
|
651
|
+
}, t), null);
|
|
652
|
+
}
|
|
653
|
+
function K(e) {
|
|
654
|
+
let t = G(e), n = String(t.value ?? "");
|
|
655
|
+
return s("select", l({ class: e.classNames.input }, t, { value: n }), [e.field.placeholder ? s("option", { value: "" }, [e.field.placeholder]) : null, (e.field.options ?? []).map((e) => s("option", {
|
|
656
|
+
key: e.value,
|
|
657
|
+
value: e.value
|
|
658
|
+
}, [e.label]))]);
|
|
659
|
+
}
|
|
660
|
+
function ke(e) {
|
|
661
|
+
let t = G(e), n = Array.isArray(e.value) ? e.value.map(String) : e.value ? [String(e.value)] : [];
|
|
662
|
+
return s("select", {
|
|
663
|
+
class: e.classNames.input,
|
|
664
|
+
id: t.id,
|
|
665
|
+
name: t.name,
|
|
666
|
+
multiple: !0,
|
|
667
|
+
disabled: t.disabled,
|
|
668
|
+
"aria-invalid": t["aria-invalid"],
|
|
669
|
+
value: n,
|
|
670
|
+
onChange: (t) => {
|
|
671
|
+
let n = Array.from(t.target.selectedOptions).map((e) => e.value);
|
|
672
|
+
e.form.setValue(e.field.handle, n);
|
|
673
|
+
},
|
|
674
|
+
onBlur: t.onBlur
|
|
675
|
+
}, [(e.field.options ?? []).map((e) => s("option", {
|
|
676
|
+
key: e.value,
|
|
677
|
+
value: e.value
|
|
678
|
+
}, [e.label]))]);
|
|
679
|
+
}
|
|
680
|
+
function Ae(e) {
|
|
681
|
+
let t = G(e), n = t.value === "1" || e.value === !0 || t.value === "true";
|
|
682
|
+
return s("label", { class: e.classNames.optionLabel ?? e.classNames.input }, [s("input", {
|
|
683
|
+
type: "checkbox",
|
|
684
|
+
class: e.classNames.optionInput,
|
|
685
|
+
id: t.id,
|
|
686
|
+
name: t.name,
|
|
687
|
+
checked: n,
|
|
688
|
+
disabled: t.disabled,
|
|
689
|
+
"aria-invalid": t["aria-invalid"],
|
|
690
|
+
onChange: (t) => {
|
|
691
|
+
e.form.setValue(e.field.handle, t.target.checked ? "1" : "");
|
|
692
|
+
},
|
|
693
|
+
onBlur: t.onBlur
|
|
694
|
+
}, null), s("span", null, [e.field.label])]);
|
|
695
|
+
}
|
|
696
|
+
function je(e) {
|
|
697
|
+
let t = Array.isArray(e.value) ? e.value.map(String) : e.value ? [String(e.value)] : [];
|
|
698
|
+
return s("div", { class: e.classNames.input }, [(e.field.options ?? []).map((n) => s("label", {
|
|
699
|
+
key: n.value,
|
|
700
|
+
class: e.classNames.optionLabel
|
|
701
|
+
}, [s("input", {
|
|
702
|
+
type: "checkbox",
|
|
703
|
+
class: e.classNames.optionInput,
|
|
704
|
+
name: `${e.field.handle}[]`,
|
|
705
|
+
value: n.value,
|
|
706
|
+
checked: t.includes(n.value),
|
|
707
|
+
disabled: !e.form.isFieldEnabled(e.field.handle),
|
|
708
|
+
onChange: (r) => {
|
|
709
|
+
let i = new Set(t);
|
|
710
|
+
r.target.checked ? i.add(n.value) : i.delete(n.value), e.form.setValue(e.field.handle, [...i]);
|
|
711
|
+
}
|
|
712
|
+
}, null), s("span", null, [n.label])]))]);
|
|
713
|
+
}
|
|
714
|
+
function q(e) {
|
|
715
|
+
let t = String(e.value ?? "");
|
|
716
|
+
return s("div", {
|
|
717
|
+
class: e.classNames.input,
|
|
718
|
+
role: "radiogroup"
|
|
719
|
+
}, [(e.field.options ?? []).map((n) => s("label", {
|
|
720
|
+
key: n.value,
|
|
721
|
+
class: e.classNames.optionLabel
|
|
722
|
+
}, [s("input", {
|
|
723
|
+
type: "radio",
|
|
724
|
+
class: e.classNames.optionInput,
|
|
725
|
+
name: e.field.handle,
|
|
726
|
+
value: n.value,
|
|
727
|
+
checked: t === n.value,
|
|
728
|
+
disabled: !e.form.isFieldEnabled(e.field.handle),
|
|
729
|
+
onChange: () => e.form.setValue(e.field.handle, n.value)
|
|
730
|
+
}, null), s("span", null, [n.label])]))]);
|
|
731
|
+
}
|
|
732
|
+
function Me(e) {
|
|
733
|
+
let t = String(e.value ?? ""), n = e.field.frontend?.config?.legends ?? [];
|
|
734
|
+
return s("div", { class: e.classNames.input }, [s("div", {
|
|
735
|
+
role: "radiogroup",
|
|
736
|
+
style: {
|
|
737
|
+
display: "flex",
|
|
738
|
+
gap: "0.75rem"
|
|
739
|
+
}
|
|
740
|
+
}, [(e.field.options ?? []).map((n) => s("label", {
|
|
741
|
+
key: n.value,
|
|
742
|
+
class: e.classNames.optionLabel,
|
|
743
|
+
style: e.classNames.optionLabel ? void 0 : {
|
|
744
|
+
display: "flex",
|
|
745
|
+
flexDirection: "column",
|
|
746
|
+
alignItems: "center"
|
|
747
|
+
}
|
|
748
|
+
}, [s("input", {
|
|
749
|
+
type: "radio",
|
|
750
|
+
class: e.classNames.optionInput,
|
|
751
|
+
name: e.field.handle,
|
|
752
|
+
value: n.value,
|
|
753
|
+
checked: t === n.value,
|
|
754
|
+
disabled: !e.form.isFieldEnabled(e.field.handle),
|
|
755
|
+
onChange: () => e.form.setValue(e.field.handle, n.value)
|
|
756
|
+
}, null), s("span", null, [n.label || n.value])]))]), n.length > 0 ? s("div", { style: {
|
|
757
|
+
display: "flex",
|
|
758
|
+
justifyContent: "space-between",
|
|
759
|
+
marginTop: "0.5rem",
|
|
760
|
+
fontSize: "0.875rem"
|
|
761
|
+
} }, [n.map((e) => s("span", { key: e }, [e]))]) : null]);
|
|
762
|
+
}
|
|
763
|
+
function Ne(e) {
|
|
764
|
+
let t = String(e.value ?? ""), n = e.field.frontend?.config ?? {}, r = n.colorIdle || "#dddddd", i = n.colorSelected || "#ff7700";
|
|
765
|
+
return s("div", {
|
|
766
|
+
class: e.classNames.input,
|
|
767
|
+
role: "radiogroup"
|
|
768
|
+
}, [(e.field.options ?? []).map((n) => {
|
|
769
|
+
let a = Number(t) >= Number(n.value);
|
|
770
|
+
return s("label", {
|
|
771
|
+
key: n.value,
|
|
772
|
+
class: e.classNames.optionLabel,
|
|
773
|
+
style: {
|
|
774
|
+
cursor: "pointer",
|
|
775
|
+
color: a ? i : r,
|
|
776
|
+
fontSize: "1.5rem",
|
|
777
|
+
marginRight: "0.25rem"
|
|
778
|
+
}
|
|
779
|
+
}, [
|
|
780
|
+
s("input", {
|
|
781
|
+
type: "radio",
|
|
782
|
+
class: e.classNames.optionInput,
|
|
783
|
+
name: e.field.handle,
|
|
784
|
+
value: n.value,
|
|
785
|
+
checked: t === n.value,
|
|
786
|
+
disabled: !e.form.isFieldEnabled(e.field.handle),
|
|
787
|
+
onChange: () => e.form.setValue(e.field.handle, n.value),
|
|
788
|
+
style: {
|
|
789
|
+
position: "absolute",
|
|
790
|
+
opacity: 0,
|
|
791
|
+
pointerEvents: "none"
|
|
792
|
+
}
|
|
793
|
+
}, null),
|
|
794
|
+
s("span", { "aria-hidden": "true" }, [o("★")]),
|
|
795
|
+
s("span", { class: "ff-sr-only" }, [n.label])
|
|
796
|
+
]);
|
|
797
|
+
})]);
|
|
798
|
+
}
|
|
799
|
+
function Pe(e) {
|
|
800
|
+
let t = (e.field.frontend?.config?.cards ?? []) || [], n = Number(e.field.frontend?.config?.maxSelectedValues ?? 0), r = Array.isArray(e.value) ? e.value.map(String) : e.value ? [String(e.value)] : [], i = n === 1;
|
|
801
|
+
return s("div", {
|
|
802
|
+
class: e.classNames.input,
|
|
803
|
+
style: {
|
|
804
|
+
display: "grid",
|
|
805
|
+
gap: "0.75rem",
|
|
806
|
+
gridTemplateColumns: `repeat(${Math.min(Number(e.field.frontend?.config?.cardsPerRow ?? 3) || 3, 4)}, minmax(0, 1fr))`
|
|
807
|
+
}
|
|
808
|
+
}, [t.map((t) => {
|
|
809
|
+
let a = r.includes(t.value);
|
|
810
|
+
return s("label", {
|
|
811
|
+
key: t.value,
|
|
812
|
+
class: e.classNames.optionLabel,
|
|
813
|
+
style: e.classNames.optionLabel ? void 0 : {
|
|
814
|
+
border: a ? "2px solid currentColor" : "1px solid #ccc",
|
|
815
|
+
borderRadius: "0.5rem",
|
|
816
|
+
padding: "0.75rem",
|
|
817
|
+
cursor: "pointer"
|
|
818
|
+
}
|
|
819
|
+
}, [
|
|
820
|
+
s("input", {
|
|
821
|
+
type: i ? "radio" : "checkbox",
|
|
822
|
+
class: e.classNames.optionInput,
|
|
823
|
+
name: `${e.field.handle}${i ? "" : "[]"}`,
|
|
824
|
+
value: t.value,
|
|
825
|
+
checked: a,
|
|
826
|
+
disabled: !e.form.isFieldEnabled(e.field.handle),
|
|
827
|
+
onChange: (a) => {
|
|
828
|
+
if (i) {
|
|
829
|
+
e.form.setValue(e.field.handle, [t.value]);
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
832
|
+
let o = new Set(r);
|
|
833
|
+
if (a.target.checked) {
|
|
834
|
+
if (n > 0 && o.size >= n) return;
|
|
835
|
+
o.add(t.value);
|
|
836
|
+
} else o.delete(t.value);
|
|
837
|
+
e.form.setValue(e.field.handle, [...o]);
|
|
838
|
+
}
|
|
839
|
+
}, null),
|
|
840
|
+
t.imageUrl ? s("img", {
|
|
841
|
+
src: t.imageUrl,
|
|
842
|
+
alt: "",
|
|
843
|
+
style: {
|
|
844
|
+
width: "100%",
|
|
845
|
+
height: "auto",
|
|
846
|
+
display: "block",
|
|
847
|
+
marginBottom: "0.5rem"
|
|
848
|
+
}
|
|
849
|
+
}, null) : null,
|
|
850
|
+
s("strong", null, [t.label]),
|
|
851
|
+
t.description ? s("div", null, [t.description]) : null
|
|
852
|
+
]);
|
|
853
|
+
})]);
|
|
854
|
+
}
|
|
855
|
+
function J(e) {
|
|
856
|
+
let t = G(e), n = e.field.frontend?.config ?? {};
|
|
857
|
+
return s("input", {
|
|
858
|
+
type: "file",
|
|
859
|
+
class: e.classNames.input,
|
|
860
|
+
id: t.id,
|
|
861
|
+
name: t.name,
|
|
862
|
+
disabled: t.disabled,
|
|
863
|
+
"aria-invalid": t["aria-invalid"],
|
|
864
|
+
accept: n.accept || void 0,
|
|
865
|
+
multiple: !!(n.multiple ?? (n.maxFiles ?? 1) > 1),
|
|
866
|
+
onChange: (t) => {
|
|
867
|
+
let n = t.target.files;
|
|
868
|
+
if (!n || n.length === 0) {
|
|
869
|
+
e.form.setValue(e.field.handle, null);
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
e.form.setValue(e.field.handle, n.length === 1 ? n[0] : Array.from(n));
|
|
873
|
+
},
|
|
874
|
+
onBlur: t.onBlur
|
|
875
|
+
}, null);
|
|
876
|
+
}
|
|
877
|
+
function Fe(e) {
|
|
878
|
+
return s(W, {
|
|
879
|
+
field: e.field,
|
|
880
|
+
form: e.form,
|
|
881
|
+
class: e.classNames.input,
|
|
882
|
+
dataAttr: "data-freeform-file-dnd"
|
|
883
|
+
}, null);
|
|
884
|
+
}
|
|
885
|
+
function Ie(e) {
|
|
886
|
+
return s(W, {
|
|
887
|
+
field: e.field,
|
|
888
|
+
form: e.form,
|
|
889
|
+
class: e.classNames.input,
|
|
890
|
+
dataAttr: "data-freeform-stripe"
|
|
891
|
+
}, null);
|
|
892
|
+
}
|
|
893
|
+
function Le(e) {
|
|
894
|
+
return s(W, {
|
|
895
|
+
field: e.field,
|
|
896
|
+
form: e.form,
|
|
897
|
+
class: e.classNames.input,
|
|
898
|
+
dataAttr: "data-freeform-square"
|
|
899
|
+
}, null);
|
|
900
|
+
}
|
|
901
|
+
function Re(e) {
|
|
902
|
+
return s(W, {
|
|
903
|
+
field: e.field,
|
|
904
|
+
form: e.form,
|
|
905
|
+
class: e.classNames.input,
|
|
906
|
+
dataAttr: "data-freeform-paypal"
|
|
907
|
+
}, null);
|
|
908
|
+
}
|
|
909
|
+
function ze(e) {
|
|
910
|
+
return s(W, {
|
|
911
|
+
field: e.field,
|
|
912
|
+
form: e.form,
|
|
913
|
+
class: e.classNames.input,
|
|
914
|
+
dataAttr: "data-freeform-mollie",
|
|
915
|
+
hidden: !0
|
|
916
|
+
}, null);
|
|
917
|
+
}
|
|
918
|
+
function Y(e) {
|
|
919
|
+
let t = e.classNames.content ?? e.classNames.input ?? "ff-field__content", n = e.field.content?.rendered?.html?.trim();
|
|
920
|
+
return e.allowRawHtml && n ? s("div", {
|
|
921
|
+
class: t,
|
|
922
|
+
innerHTML: n
|
|
923
|
+
}, null) : e.field.instructions ? s("div", {
|
|
924
|
+
class: t,
|
|
925
|
+
role: "note"
|
|
926
|
+
}, [e.field.instructions]) : null;
|
|
927
|
+
}
|
|
928
|
+
function Be(e) {
|
|
929
|
+
let t = e.classNames.content ?? e.classNames.input ?? "ff-field__content", n = e.field.frontend?.config ?? {}, r = e.field.content?.image, i = r?.src || n.src, a = r?.srcset || n.srcset, o = r?.alt || n.alt || e.field.label || "";
|
|
930
|
+
return i ? s("img", {
|
|
931
|
+
class: t,
|
|
932
|
+
src: i,
|
|
933
|
+
srcset: a || void 0,
|
|
934
|
+
alt: o
|
|
935
|
+
}, null) : null;
|
|
936
|
+
}
|
|
937
|
+
function Ve(e) {
|
|
938
|
+
let t = G(e), n = e.field.frontend?.config ?? {}, r = n.useNativeTypes ? n.nativeInputType || "datetime-local" : "text";
|
|
939
|
+
return s(W, {
|
|
940
|
+
field: e.field,
|
|
941
|
+
form: e.form,
|
|
942
|
+
dataAttr: "data-freeform-datetime"
|
|
943
|
+
}, { default: () => [s("input", l({
|
|
944
|
+
type: r,
|
|
945
|
+
class: e.classNames.input,
|
|
946
|
+
"data-datepicker": "",
|
|
947
|
+
"data-datepicker-enabled": n.useDatepicker ? "1" : "0"
|
|
948
|
+
}, t), null)] });
|
|
949
|
+
}
|
|
950
|
+
function He(e) {
|
|
951
|
+
return s("div", {
|
|
952
|
+
class: e.classNames.input,
|
|
953
|
+
role: "alert"
|
|
954
|
+
}, [o("Unsupported field type: "), e.field.type]);
|
|
955
|
+
}
|
|
956
|
+
//#endregion
|
|
957
|
+
//#region src/renderers/builtin/CalculationField.tsx
|
|
958
|
+
var Ue = /* @__PURE__ */ c({
|
|
959
|
+
name: "CalculationFieldRenderer",
|
|
960
|
+
props: {
|
|
961
|
+
field: {
|
|
962
|
+
type: Object,
|
|
963
|
+
required: !0
|
|
964
|
+
},
|
|
965
|
+
form: {
|
|
966
|
+
type: Object,
|
|
967
|
+
required: !0
|
|
968
|
+
},
|
|
969
|
+
classNames: {
|
|
970
|
+
type: Object,
|
|
971
|
+
required: !0
|
|
972
|
+
},
|
|
973
|
+
value: { required: !0 }
|
|
974
|
+
},
|
|
975
|
+
setup(e) {
|
|
976
|
+
let t = N(e.field.frontend?.config), n = t.inputType ?? "regularTextInput", r = C(e.form.setValue);
|
|
977
|
+
return r.value = e.form.setValue, E(() => [
|
|
978
|
+
e.field.handle,
|
|
979
|
+
t.calculations,
|
|
980
|
+
t.decimalCount,
|
|
981
|
+
e.form.values
|
|
982
|
+
], () => {
|
|
983
|
+
let n = !1, i = t.calculations ?? "";
|
|
984
|
+
return (async () => {
|
|
985
|
+
let a = await M(i, e.form.values, t.decimalCount);
|
|
986
|
+
if (n) return;
|
|
987
|
+
let o = a == null ? "" : String(a), s = e.form.getValue(e.field.handle);
|
|
988
|
+
String(s ?? "") !== o && r.value(e.field.handle, o);
|
|
989
|
+
})(), () => {
|
|
990
|
+
n = !0;
|
|
991
|
+
};
|
|
992
|
+
}, {
|
|
993
|
+
immediate: !0,
|
|
994
|
+
deep: !0
|
|
995
|
+
}), () => {
|
|
996
|
+
let t = e.value == null || e.value === "" ? "" : String(e.value);
|
|
997
|
+
return n === "hidden" ? s("input", {
|
|
998
|
+
type: "hidden",
|
|
999
|
+
name: e.field.handle,
|
|
1000
|
+
value: t,
|
|
1001
|
+
readonly: !0
|
|
1002
|
+
}, null) : n === "plainText" ? s("div", { class: e.classNames.input }, [s("input", {
|
|
1003
|
+
type: "hidden",
|
|
1004
|
+
name: e.field.handle,
|
|
1005
|
+
value: t,
|
|
1006
|
+
readonly: !0
|
|
1007
|
+
}, null), s("p", {
|
|
1008
|
+
class: "ff-field__calculation-plain",
|
|
1009
|
+
"data-freeform-calculation": ""
|
|
1010
|
+
}, [t])]) : s("input", {
|
|
1011
|
+
class: e.classNames.input,
|
|
1012
|
+
type: "text",
|
|
1013
|
+
name: e.field.handle,
|
|
1014
|
+
id: `freeform-${e.field.handle}`,
|
|
1015
|
+
value: t,
|
|
1016
|
+
readonly: !0,
|
|
1017
|
+
"aria-readonly": "true"
|
|
1018
|
+
}, null);
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
}), We = /* @__PURE__ */ c({
|
|
1022
|
+
name: "SignatureFieldRenderer",
|
|
1023
|
+
props: {
|
|
1024
|
+
field: {
|
|
1025
|
+
type: Object,
|
|
1026
|
+
required: !0
|
|
1027
|
+
},
|
|
1028
|
+
form: {
|
|
1029
|
+
type: Object,
|
|
1030
|
+
required: !0
|
|
1031
|
+
},
|
|
1032
|
+
value: { required: !0 },
|
|
1033
|
+
classNames: {
|
|
1034
|
+
type: Object,
|
|
1035
|
+
required: !0
|
|
1036
|
+
}
|
|
1037
|
+
},
|
|
1038
|
+
setup(e) {
|
|
1039
|
+
let t = C(null), n = C(!1), r = v(!I(e.value)), i = P(e.field), a = i.width ?? 400, c = i.height ?? 100, l = e.form.isFieldEnabled(e.field.handle), u = i.penColor || "#000000", d = i.backgroundColor || "rgba(0,0,0,0)", f = i.borderColor || "#999999", m = i.penDotSize ?? 2.5;
|
|
1040
|
+
function g(e) {
|
|
1041
|
+
e.fillStyle = d, e.fillRect(0, 0, a, c);
|
|
1042
|
+
}
|
|
1043
|
+
function _() {
|
|
1044
|
+
let n = t.value;
|
|
1045
|
+
n && e.form.setValue(e.field.handle, n.toDataURL("image/png"));
|
|
1046
|
+
}
|
|
1047
|
+
function y() {
|
|
1048
|
+
let n = t.value, i = n?.getContext("2d");
|
|
1049
|
+
!n || !i || (i.clearRect(0, 0, a, c), g(i), r.value = !1, e.form.setValue(e.field.handle, ""));
|
|
1050
|
+
}
|
|
1051
|
+
function b() {
|
|
1052
|
+
let n = t.value;
|
|
1053
|
+
if (!n) return;
|
|
1054
|
+
let i = typeof window < "u" && window.devicePixelRatio || 1;
|
|
1055
|
+
n.width = Math.floor(a * i), n.height = Math.floor(c * i), n.style.width = `${a}px`, n.style.height = `${c}px`;
|
|
1056
|
+
let o = n.getContext("2d");
|
|
1057
|
+
if (o) {
|
|
1058
|
+
if (o.setTransform(i, 0, 0, i, 0, 0), g(o), o.strokeStyle = u, o.lineWidth = m, o.lineCap = "round", o.lineJoin = "round", typeof e.value == "string" && e.value.startsWith("data:")) {
|
|
1059
|
+
let t = new Image();
|
|
1060
|
+
t.onload = () => {
|
|
1061
|
+
o.drawImage(t, 0, 0, a, c), r.value = !I(e.value);
|
|
1062
|
+
}, t.src = e.value;
|
|
1063
|
+
} else r.value = !1;
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
p(b), E(() => [a, c], b), h(() => {
|
|
1067
|
+
n.value = !1;
|
|
1068
|
+
});
|
|
1069
|
+
function x(e) {
|
|
1070
|
+
let n = t.value;
|
|
1071
|
+
if (!n) return {
|
|
1072
|
+
x: 0,
|
|
1073
|
+
y: 0
|
|
1074
|
+
};
|
|
1075
|
+
let r = n.getBoundingClientRect();
|
|
1076
|
+
return {
|
|
1077
|
+
x: (e.clientX - r.left) / r.width * a,
|
|
1078
|
+
y: (e.clientY - r.top) / r.height * c
|
|
1079
|
+
};
|
|
1080
|
+
}
|
|
1081
|
+
function S() {
|
|
1082
|
+
n.value && (n.value = !1, _());
|
|
1083
|
+
}
|
|
1084
|
+
return () => s("div", {
|
|
1085
|
+
class: e.classNames.input,
|
|
1086
|
+
"data-freeform-signature": ""
|
|
1087
|
+
}, [s("canvas", {
|
|
1088
|
+
ref: t,
|
|
1089
|
+
width: a,
|
|
1090
|
+
height: c,
|
|
1091
|
+
style: {
|
|
1092
|
+
width: "100%",
|
|
1093
|
+
maxWidth: a,
|
|
1094
|
+
height: c,
|
|
1095
|
+
border: `1px solid ${f}`,
|
|
1096
|
+
touchAction: "none",
|
|
1097
|
+
cursor: l ? "crosshair" : "not-allowed",
|
|
1098
|
+
display: "block",
|
|
1099
|
+
backgroundColor: d
|
|
1100
|
+
},
|
|
1101
|
+
"aria-label": e.field.label,
|
|
1102
|
+
onPointerdown: (e) => {
|
|
1103
|
+
if (!l) return;
|
|
1104
|
+
let r = t.value, i = r?.getContext("2d");
|
|
1105
|
+
if (!i || !r) return;
|
|
1106
|
+
n.value = !0, r.setPointerCapture(e.pointerId), i.strokeStyle = u, i.lineWidth = m, i.lineCap = "round", i.lineJoin = "round";
|
|
1107
|
+
let { x: a, y: o } = x(e);
|
|
1108
|
+
i.beginPath(), i.moveTo(a, o);
|
|
1109
|
+
},
|
|
1110
|
+
onPointermove: (e) => {
|
|
1111
|
+
if (!n.value) return;
|
|
1112
|
+
let i = t.value?.getContext("2d");
|
|
1113
|
+
if (!i) return;
|
|
1114
|
+
let { x: a, y: o } = x(e);
|
|
1115
|
+
i.lineTo(a, o), i.stroke(), r.value = !0;
|
|
1116
|
+
},
|
|
1117
|
+
onPointerup: S,
|
|
1118
|
+
onPointercancel: S,
|
|
1119
|
+
onPointerleave: S
|
|
1120
|
+
}, null), i.showClearButton === !1 ? null : s("button", {
|
|
1121
|
+
type: "button",
|
|
1122
|
+
disabled: !r.value || !l,
|
|
1123
|
+
onClick: y
|
|
1124
|
+
}, [o("Clear")])]);
|
|
1125
|
+
}
|
|
1126
|
+
}), Ge = /* @__PURE__ */ c({
|
|
1127
|
+
name: "TableFieldRenderer",
|
|
1128
|
+
props: {
|
|
1129
|
+
field: {
|
|
1130
|
+
type: Object,
|
|
1131
|
+
required: !0
|
|
1132
|
+
},
|
|
1133
|
+
form: {
|
|
1134
|
+
type: Object,
|
|
1135
|
+
required: !0
|
|
1136
|
+
},
|
|
1137
|
+
value: { required: !0 },
|
|
1138
|
+
classNames: {
|
|
1139
|
+
type: Object,
|
|
1140
|
+
required: !0
|
|
1141
|
+
}
|
|
1142
|
+
},
|
|
1143
|
+
setup(e) {
|
|
1144
|
+
let n = t(() => F(e.field)), r = t(() => n.value.columns ?? []), i = t(() => e.form.isFieldEnabled(e.field.handle)), a = t(() => L(e.value, r.value, n.value)), o = C(!1);
|
|
1145
|
+
E(() => [e.field.handle, e.value], () => {
|
|
1146
|
+
o.value || (!Array.isArray(e.value) || e.value.length === 0) && (o.value = !0, e.form.setValue(e.field.handle, a.value));
|
|
1147
|
+
}, { immediate: !0 });
|
|
1148
|
+
let c = (t) => {
|
|
1149
|
+
e.form.setValue(e.field.handle, t);
|
|
1150
|
+
}, l = (e, t, n) => {
|
|
1151
|
+
let r = a.value.map((e) => [...e]);
|
|
1152
|
+
r[e][t] = n, c(r);
|
|
1153
|
+
};
|
|
1154
|
+
return () => {
|
|
1155
|
+
let t = a.value, o = r.value, u = n.value, d = i.value, f = O(t, u);
|
|
1156
|
+
return s("div", {
|
|
1157
|
+
class: e.classNames.input,
|
|
1158
|
+
"data-freeform-table": ""
|
|
1159
|
+
}, [s("table", { class: "ff-table" }, [s("thead", null, [s("tr", null, [o.map((e, t) => s("th", {
|
|
1160
|
+
key: `${e.label}-${t}`,
|
|
1161
|
+
class: e.required ? "is-required" : void 0,
|
|
1162
|
+
"data-column-required": e.required ? "true" : void 0
|
|
1163
|
+
}, [e.label])), s("th", null, null)])]), s("tbody", null, [t.map((n, r) => s("tr", { key: `row-${r}` }, [o.map((t, i) => {
|
|
1164
|
+
let a = n[i], o = R(t), c = `${r}-${i}`;
|
|
1165
|
+
if (t.type === "checkbox") return s("td", { key: c }, [s("input", {
|
|
1166
|
+
type: "checkbox",
|
|
1167
|
+
checked: !!a,
|
|
1168
|
+
disabled: !d,
|
|
1169
|
+
required: t.required || void 0,
|
|
1170
|
+
onChange: (e) => {
|
|
1171
|
+
l(r, i, e.target.checked ? "1" : "");
|
|
1172
|
+
}
|
|
1173
|
+
}, null)]);
|
|
1174
|
+
if (t.type === "select" || t.type === "dropdown") return s("td", { key: c }, [s("select", {
|
|
1175
|
+
value: String(a ?? ""),
|
|
1176
|
+
disabled: !d,
|
|
1177
|
+
required: t.required || void 0,
|
|
1178
|
+
onChange: (e) => {
|
|
1179
|
+
l(r, i, e.target.value);
|
|
1180
|
+
}
|
|
1181
|
+
}, [s("option", { value: "" }, [t.placeholder || "Select…"]), o.map((e) => s("option", {
|
|
1182
|
+
key: e.value,
|
|
1183
|
+
value: e.value
|
|
1184
|
+
}, [e.label]))])]);
|
|
1185
|
+
if (t.type === "radio") return s("td", { key: c }, [s("div", { class: "ff-table__radios" }, [o.map((t) => {
|
|
1186
|
+
let n = `${e.field.handle}-${r}-${i}-${t.value}`;
|
|
1187
|
+
return s("label", {
|
|
1188
|
+
key: t.value,
|
|
1189
|
+
for: n
|
|
1190
|
+
}, [
|
|
1191
|
+
s("input", {
|
|
1192
|
+
id: n,
|
|
1193
|
+
type: "radio",
|
|
1194
|
+
name: `${e.field.handle}[${r}][${i}]`,
|
|
1195
|
+
value: t.value,
|
|
1196
|
+
checked: String(a ?? "") === t.value,
|
|
1197
|
+
disabled: !d,
|
|
1198
|
+
onChange: () => {
|
|
1199
|
+
l(r, i, t.value);
|
|
1200
|
+
}
|
|
1201
|
+
}, null),
|
|
1202
|
+
" ",
|
|
1203
|
+
t.label
|
|
1204
|
+
]);
|
|
1205
|
+
})])]);
|
|
1206
|
+
if (t.type === "textarea") return s("td", { key: c }, [s("textarea", {
|
|
1207
|
+
value: String(a ?? ""),
|
|
1208
|
+
placeholder: t.placeholder,
|
|
1209
|
+
disabled: !d,
|
|
1210
|
+
required: t.required || void 0,
|
|
1211
|
+
onInput: (e) => {
|
|
1212
|
+
l(r, i, e.target.value);
|
|
1213
|
+
}
|
|
1214
|
+
}, null)]);
|
|
1215
|
+
if (t.type === "file") {
|
|
1216
|
+
let e = Array.isArray(a) ? a : [], n = Math.max(1, Number(t.metadata?.fileCount ?? 1));
|
|
1217
|
+
return s("td", { key: c }, [s("input", {
|
|
1218
|
+
type: "file",
|
|
1219
|
+
multiple: n > 1,
|
|
1220
|
+
disabled: !d,
|
|
1221
|
+
onChange: (e) => {
|
|
1222
|
+
let t = Array.from(e.target.files ?? []);
|
|
1223
|
+
l(r, i, n > 1 ? t : t.slice(0, 1));
|
|
1224
|
+
}
|
|
1225
|
+
}, null), e.length > 0 ? s("div", { class: "ff-table__file-names" }, [e.map((e) => s("span", { key: `${e.name}-${e.size}` }, [e.name]))]) : null]);
|
|
1226
|
+
}
|
|
1227
|
+
return s("td", { key: c }, [s("input", {
|
|
1228
|
+
type: t.type === "number" ? "number" : "text",
|
|
1229
|
+
value: String(a ?? ""),
|
|
1230
|
+
placeholder: t.placeholder,
|
|
1231
|
+
disabled: !d,
|
|
1232
|
+
required: t.required || void 0,
|
|
1233
|
+
onInput: (e) => {
|
|
1234
|
+
l(r, i, e.target.value);
|
|
1235
|
+
}
|
|
1236
|
+
}, null)]);
|
|
1237
|
+
}), s("td", null, [k(t, r, u) ? s("button", {
|
|
1238
|
+
type: "button",
|
|
1239
|
+
disabled: !d,
|
|
1240
|
+
onClick: () => {
|
|
1241
|
+
c(t.filter((e, t) => t !== r));
|
|
1242
|
+
}
|
|
1243
|
+
}, [u.removeButtonLabel || "Remove"]) : null])]))])]), f ? s("button", {
|
|
1244
|
+
type: "button",
|
|
1245
|
+
disabled: !d,
|
|
1246
|
+
onClick: () => c([...t, j(o)])
|
|
1247
|
+
}, [u.addButtonLabel || "Add"]) : null]);
|
|
1248
|
+
};
|
|
1249
|
+
}
|
|
1250
|
+
}), Ke = /* @__PURE__ */ c({
|
|
1251
|
+
name: "DefaultForm",
|
|
1252
|
+
props: {
|
|
1253
|
+
form: {
|
|
1254
|
+
type: Object,
|
|
1255
|
+
required: !0
|
|
1256
|
+
},
|
|
1257
|
+
class: {
|
|
1258
|
+
type: String,
|
|
1259
|
+
default: void 0
|
|
1260
|
+
},
|
|
1261
|
+
onSubmit: {
|
|
1262
|
+
type: Function,
|
|
1263
|
+
required: !0
|
|
1264
|
+
}
|
|
1265
|
+
},
|
|
1266
|
+
setup(e, { slots: t }) {
|
|
1267
|
+
return () => s("form", {
|
|
1268
|
+
class: e.class,
|
|
1269
|
+
onSubmit: e.onSubmit,
|
|
1270
|
+
novalidate: !0
|
|
1271
|
+
}, [t.default?.()]);
|
|
1272
|
+
}
|
|
1273
|
+
}), qe = /* @__PURE__ */ c({
|
|
1274
|
+
name: "DefaultPage",
|
|
1275
|
+
props: {
|
|
1276
|
+
form: {
|
|
1277
|
+
type: Object,
|
|
1278
|
+
required: !0
|
|
1279
|
+
},
|
|
1280
|
+
pageIndex: {
|
|
1281
|
+
type: Number,
|
|
1282
|
+
required: !0
|
|
1283
|
+
},
|
|
1284
|
+
class: {
|
|
1285
|
+
type: String,
|
|
1286
|
+
default: void 0
|
|
1287
|
+
}
|
|
1288
|
+
},
|
|
1289
|
+
setup(e, { slots: t }) {
|
|
1290
|
+
return () => s("div", { class: e.class }, [t.default?.()]);
|
|
1291
|
+
}
|
|
1292
|
+
}), Je = /* @__PURE__ */ c({
|
|
1293
|
+
name: "DefaultRow",
|
|
1294
|
+
props: { class: {
|
|
1295
|
+
type: String,
|
|
1296
|
+
default: void 0
|
|
1297
|
+
} },
|
|
1298
|
+
setup(e, { slots: t }) {
|
|
1299
|
+
return () => s("div", { class: e.class }, [t.default?.()]);
|
|
1300
|
+
}
|
|
1301
|
+
}), Ye = /* @__PURE__ */ c({
|
|
1302
|
+
name: "DefaultFieldWrapper",
|
|
1303
|
+
props: {
|
|
1304
|
+
field: {
|
|
1305
|
+
type: Object,
|
|
1306
|
+
required: !0
|
|
1307
|
+
},
|
|
1308
|
+
form: {
|
|
1309
|
+
type: Object,
|
|
1310
|
+
required: !0
|
|
1311
|
+
},
|
|
1312
|
+
class: {
|
|
1313
|
+
type: String,
|
|
1314
|
+
default: void 0
|
|
1315
|
+
}
|
|
1316
|
+
},
|
|
1317
|
+
setup(e, { slots: t }) {
|
|
1318
|
+
return () => {
|
|
1319
|
+
let n = e.field.type === "hidden" || e.field.type === "mollie" || e.field.frontend?.renderer === "payment.mollie" || e.field.frontend?.extension === "payment.mollie";
|
|
1320
|
+
return !e.form.isFieldVisible(e.field.handle) && !n ? null : s("div", {
|
|
1321
|
+
class: e.class,
|
|
1322
|
+
"data-freeform-field": e.field.handle,
|
|
1323
|
+
"data-field-container": e.field.handle,
|
|
1324
|
+
"data-field-type": e.field.type,
|
|
1325
|
+
hidden: !e.form.isFieldVisible(e.field.handle) || n
|
|
1326
|
+
}, [t.default?.()]);
|
|
1327
|
+
};
|
|
1328
|
+
}
|
|
1329
|
+
}), Xe = /* @__PURE__ */ c({
|
|
1330
|
+
name: "DefaultLabel",
|
|
1331
|
+
props: {
|
|
1332
|
+
field: {
|
|
1333
|
+
type: Object,
|
|
1334
|
+
required: !0
|
|
1335
|
+
},
|
|
1336
|
+
class: {
|
|
1337
|
+
type: String,
|
|
1338
|
+
default: void 0
|
|
1339
|
+
},
|
|
1340
|
+
requiredIndicator: {
|
|
1341
|
+
type: String,
|
|
1342
|
+
default: "*"
|
|
1343
|
+
}
|
|
1344
|
+
},
|
|
1345
|
+
setup(e) {
|
|
1346
|
+
return () => e.field.label ? s("label", {
|
|
1347
|
+
class: e.class,
|
|
1348
|
+
for: `freeform-${e.field.handle}`
|
|
1349
|
+
}, [e.field.label, e.field.required ? s("span", { "aria-hidden": "true" }, [o(" "), e.requiredIndicator]) : null]) : null;
|
|
1350
|
+
}
|
|
1351
|
+
}), Ze = /* @__PURE__ */ c({
|
|
1352
|
+
name: "DefaultInstructions",
|
|
1353
|
+
props: {
|
|
1354
|
+
field: {
|
|
1355
|
+
type: Object,
|
|
1356
|
+
required: !0
|
|
1357
|
+
},
|
|
1358
|
+
class: {
|
|
1359
|
+
type: String,
|
|
1360
|
+
default: void 0
|
|
1361
|
+
}
|
|
1362
|
+
},
|
|
1363
|
+
setup(e) {
|
|
1364
|
+
return () => e.field.instructions ? s("div", { class: e.class }, [e.field.instructions]) : null;
|
|
1365
|
+
}
|
|
1366
|
+
}), Qe = /* @__PURE__ */ c({
|
|
1367
|
+
name: "DefaultErrors",
|
|
1368
|
+
props: {
|
|
1369
|
+
errors: {
|
|
1370
|
+
type: Array,
|
|
1371
|
+
required: !0
|
|
1372
|
+
},
|
|
1373
|
+
class: {
|
|
1374
|
+
type: String,
|
|
1375
|
+
default: void 0
|
|
1376
|
+
},
|
|
1377
|
+
errorClass: {
|
|
1378
|
+
type: String,
|
|
1379
|
+
default: void 0
|
|
1380
|
+
}
|
|
1381
|
+
},
|
|
1382
|
+
setup(e) {
|
|
1383
|
+
return () => e.errors.length ? s("div", {
|
|
1384
|
+
class: e.class,
|
|
1385
|
+
role: "alert"
|
|
1386
|
+
}, [e.errors.map((t) => s("div", {
|
|
1387
|
+
key: t,
|
|
1388
|
+
class: e.errorClass
|
|
1389
|
+
}, [t]))]) : null;
|
|
1390
|
+
}
|
|
1391
|
+
}), $e = /* @__PURE__ */ c({
|
|
1392
|
+
name: "DefaultButtonRow",
|
|
1393
|
+
props: { class: {
|
|
1394
|
+
type: String,
|
|
1395
|
+
default: void 0
|
|
1396
|
+
} },
|
|
1397
|
+
setup(e, { slots: t }) {
|
|
1398
|
+
return () => s("div", { class: e.class }, [t.default?.()]);
|
|
1399
|
+
}
|
|
1400
|
+
});
|
|
1401
|
+
function X(e, t = "submit") {
|
|
1402
|
+
return /* @__PURE__ */ c({
|
|
1403
|
+
name: e,
|
|
1404
|
+
props: {
|
|
1405
|
+
label: {
|
|
1406
|
+
type: String,
|
|
1407
|
+
required: !0
|
|
1408
|
+
},
|
|
1409
|
+
class: {
|
|
1410
|
+
type: String,
|
|
1411
|
+
default: void 0
|
|
1412
|
+
},
|
|
1413
|
+
disabled: {
|
|
1414
|
+
type: Boolean,
|
|
1415
|
+
default: !1
|
|
1416
|
+
},
|
|
1417
|
+
type: {
|
|
1418
|
+
type: String,
|
|
1419
|
+
default: t
|
|
1420
|
+
},
|
|
1421
|
+
onClick: {
|
|
1422
|
+
type: Function,
|
|
1423
|
+
default: void 0
|
|
1424
|
+
}
|
|
1425
|
+
},
|
|
1426
|
+
setup(e) {
|
|
1427
|
+
return () => s("button", {
|
|
1428
|
+
type: e.type,
|
|
1429
|
+
class: e.class,
|
|
1430
|
+
disabled: e.disabled,
|
|
1431
|
+
onClick: e.onClick
|
|
1432
|
+
}, [e.label]);
|
|
1433
|
+
}
|
|
1434
|
+
});
|
|
1435
|
+
}
|
|
1436
|
+
var et = X("DefaultSubmitButton"), tt = X("DefaultNextButton", "button"), nt = X("DefaultBackButton", "button"), rt = X("DefaultSaveButton", "button"), it = /* @__PURE__ */ c({
|
|
1437
|
+
name: "DefaultSuccessMessage",
|
|
1438
|
+
props: {
|
|
1439
|
+
message: {
|
|
1440
|
+
type: String,
|
|
1441
|
+
required: !0
|
|
1442
|
+
},
|
|
1443
|
+
class: {
|
|
1444
|
+
type: String,
|
|
1445
|
+
default: void 0
|
|
1446
|
+
}
|
|
1447
|
+
},
|
|
1448
|
+
setup(e) {
|
|
1449
|
+
return () => s("div", {
|
|
1450
|
+
class: e.class,
|
|
1451
|
+
role: "status"
|
|
1452
|
+
}, [e.message]);
|
|
1453
|
+
}
|
|
1454
|
+
}), Z = {
|
|
1455
|
+
frontend: {
|
|
1456
|
+
text: ye,
|
|
1457
|
+
textarea: Oe,
|
|
1458
|
+
email: we,
|
|
1459
|
+
number: Te,
|
|
1460
|
+
phone: Ee,
|
|
1461
|
+
website: be,
|
|
1462
|
+
regex: xe,
|
|
1463
|
+
password: Se,
|
|
1464
|
+
confirm: Ce,
|
|
1465
|
+
hidden: De,
|
|
1466
|
+
dropdown: K,
|
|
1467
|
+
select: K,
|
|
1468
|
+
"multiple-select": ke,
|
|
1469
|
+
checkbox: Ae,
|
|
1470
|
+
checkboxes: je,
|
|
1471
|
+
radios: q,
|
|
1472
|
+
radio: q,
|
|
1473
|
+
"opinion-scale": Me,
|
|
1474
|
+
rating: Ne,
|
|
1475
|
+
cards: Pe,
|
|
1476
|
+
datetime: Ve,
|
|
1477
|
+
file: J,
|
|
1478
|
+
"file-upload": J,
|
|
1479
|
+
"file-dnd": Fe,
|
|
1480
|
+
html: Y,
|
|
1481
|
+
"rich-text": Y,
|
|
1482
|
+
image: Be,
|
|
1483
|
+
table: Ge,
|
|
1484
|
+
signature: We,
|
|
1485
|
+
calculation: Ue,
|
|
1486
|
+
"payment.stripe": Ie,
|
|
1487
|
+
"payment.square": Le,
|
|
1488
|
+
"payment.paypal": Re,
|
|
1489
|
+
"payment.mollie": ze
|
|
1490
|
+
},
|
|
1491
|
+
types: {
|
|
1492
|
+
text: ye,
|
|
1493
|
+
textarea: Oe,
|
|
1494
|
+
email: we,
|
|
1495
|
+
number: Te,
|
|
1496
|
+
phone: Ee,
|
|
1497
|
+
website: be,
|
|
1498
|
+
regex: xe,
|
|
1499
|
+
password: Se,
|
|
1500
|
+
confirm: Ce,
|
|
1501
|
+
hidden: De,
|
|
1502
|
+
select: K,
|
|
1503
|
+
dropdown: K,
|
|
1504
|
+
"multiple-select": ke,
|
|
1505
|
+
checkbox: Ae,
|
|
1506
|
+
checkboxes: je,
|
|
1507
|
+
radio: q,
|
|
1508
|
+
radios: q,
|
|
1509
|
+
radiobox: q,
|
|
1510
|
+
"opinion-scale": Me,
|
|
1511
|
+
rating: Ne,
|
|
1512
|
+
cards: Pe,
|
|
1513
|
+
datetime: Ve,
|
|
1514
|
+
file: J,
|
|
1515
|
+
"file-upload": J,
|
|
1516
|
+
"file-dnd": Fe,
|
|
1517
|
+
html: Y,
|
|
1518
|
+
"rich-text": Y,
|
|
1519
|
+
image: Be,
|
|
1520
|
+
table: Ge,
|
|
1521
|
+
signature: We,
|
|
1522
|
+
calculation: Ue,
|
|
1523
|
+
stripe: Ie,
|
|
1524
|
+
square: Le,
|
|
1525
|
+
paypal: Re,
|
|
1526
|
+
mollie: ze,
|
|
1527
|
+
_unsupported: He
|
|
1528
|
+
}
|
|
1529
|
+
}, at = {
|
|
1530
|
+
Form: Ke,
|
|
1531
|
+
Page: qe,
|
|
1532
|
+
Row: Je,
|
|
1533
|
+
FieldWrapper: Ye,
|
|
1534
|
+
Label: Xe,
|
|
1535
|
+
Instructions: Ze,
|
|
1536
|
+
Errors: Qe,
|
|
1537
|
+
ButtonRow: $e,
|
|
1538
|
+
SubmitButton: et,
|
|
1539
|
+
NextButton: tt,
|
|
1540
|
+
BackButton: nt,
|
|
1541
|
+
SaveButton: rt,
|
|
1542
|
+
SuccessMessage: it,
|
|
1543
|
+
UnsupportedField: He
|
|
1544
|
+
};
|
|
1545
|
+
//#endregion
|
|
1546
|
+
//#region src/theme/mergeClassNames.ts
|
|
1547
|
+
function Q(...e) {
|
|
1548
|
+
return e.filter((e) => typeof e == "string" && e.trim() !== "").join(" ").replace(/\s+/g, " ").trim() || void 0;
|
|
1549
|
+
}
|
|
1550
|
+
function ot(e, t, n) {
|
|
1551
|
+
return n ? !t || e === "replace" ? n : `${t} ${n}`.trim() : t;
|
|
1552
|
+
}
|
|
1553
|
+
//#endregion
|
|
1554
|
+
//#region src/theme/toBemModifier.ts
|
|
1555
|
+
function st(e) {
|
|
1556
|
+
return e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[_\s]+/g, "-").replace(/-+/g, "-").toLowerCase();
|
|
1557
|
+
}
|
|
1558
|
+
//#endregion
|
|
1559
|
+
//#region src/components/FreeformView.vue
|
|
1560
|
+
var ct = /* @__PURE__ */ c({
|
|
1561
|
+
__name: "FreeformView",
|
|
1562
|
+
props: {
|
|
1563
|
+
form: {},
|
|
1564
|
+
class: {}
|
|
1565
|
+
},
|
|
1566
|
+
setup(a) {
|
|
1567
|
+
let o = a, s = t(() => ({
|
|
1568
|
+
...at,
|
|
1569
|
+
...o.form.theme.renderers?.components
|
|
1570
|
+
})), c = t(() => o.form.theme.classNameStrategy ?? "merge"), l = t(() => o.form.theme.defaults?.colorScheme ?? "system"), d = t(() => Q(o.form.theme.classNames?.form, c.value === "merge" ? `ff-form--${st(o.form.manifest.form.handle)}` : void 0, c.value === "merge" && (l.value === "light" || l.value === "dark") ? `ff-form--${l.value}` : void 0, o.class)), f = t(() => o.form.manifest.layout.pages[o.form.currentPageIndex] ?? o.form.manifest.layout.pages[0] ?? {
|
|
1571
|
+
rows: [],
|
|
1572
|
+
buttons: {}
|
|
1573
|
+
}), p = t(() => o.form.manifest.layout.pages.length === 0 || o.form.currentPageIndex >= o.form.manifest.layout.pages.length - 1), m = t(() => o.form.currentPageIndex === 0);
|
|
1574
|
+
function h(e) {
|
|
1575
|
+
if (e.type === "image") {
|
|
1576
|
+
let t = e.frontend?.config ?? {};
|
|
1577
|
+
return !!(e.content?.image?.src || t.src);
|
|
1578
|
+
}
|
|
1579
|
+
if (e.type === "html" || e.type === "rich-text") {
|
|
1580
|
+
let t = e.content?.rendered?.html?.trim();
|
|
1581
|
+
return !!(o.form.allowRawHtml && t || e.instructions);
|
|
1582
|
+
}
|
|
1583
|
+
return !0;
|
|
1584
|
+
}
|
|
1585
|
+
function _(e) {
|
|
1586
|
+
o.form.handleSubmit(e);
|
|
1587
|
+
}
|
|
1588
|
+
return (t, o) => {
|
|
1589
|
+
let l = x("FieldRenderer"), v = x("CaptchaHost");
|
|
1590
|
+
return a.form.isComplete && a.form.successMessage ? (g(), n(S(s.value.SuccessMessage), {
|
|
1591
|
+
key: 0,
|
|
1592
|
+
message: a.form.successMessage,
|
|
1593
|
+
class: u(a.form.theme.classNames?.success)
|
|
1594
|
+
}, null, 8, ["message", "class"])) : (g(), n(S(s.value.Form), {
|
|
1595
|
+
key: 1,
|
|
1596
|
+
form: a.form,
|
|
1597
|
+
class: u(d.value),
|
|
1598
|
+
"on-submit": _
|
|
1599
|
+
}, {
|
|
1600
|
+
default: D(() => [
|
|
1601
|
+
a.form.formErrors.length > 0 ? (g(), n(S(s.value.Errors), {
|
|
1602
|
+
key: 0,
|
|
1603
|
+
errors: a.form.formErrors,
|
|
1604
|
+
class: u(a.form.theme.classNames?.errors),
|
|
1605
|
+
"error-class": a.form.theme.classNames?.error
|
|
1606
|
+
}, null, 8, [
|
|
1607
|
+
"errors",
|
|
1608
|
+
"class",
|
|
1609
|
+
"error-class"
|
|
1610
|
+
])) : r("", !0),
|
|
1611
|
+
(g(), n(S(s.value.Page), {
|
|
1612
|
+
form: a.form,
|
|
1613
|
+
"page-index": a.form.currentPageIndex,
|
|
1614
|
+
class: u(T(Q)(a.form.theme.classNames?.page, c.value === "merge" ? `ff-page--${a.form.currentPageIndex}` : void 0))
|
|
1615
|
+
}, {
|
|
1616
|
+
default: D(() => [(g(!0), i(e, null, y(f.value.rows, (t) => (g(), i(e, { key: t.uid }, [t.fields.filter((e) => {
|
|
1617
|
+
let t = a.form.manifest.fields[e];
|
|
1618
|
+
return t ? h(t) : !1;
|
|
1619
|
+
}).length > 0 ? (g(), n(S(s.value.Row), {
|
|
1620
|
+
key: 0,
|
|
1621
|
+
class: u(T(Q)(a.form.theme.classNames?.row, c.value === "merge" ? `ff-row--${t.fields.filter((e) => {
|
|
1622
|
+
let t = a.form.manifest.fields[e];
|
|
1623
|
+
return t ? h(t) : !1;
|
|
1624
|
+
}).length}-fields` : void 0))
|
|
1625
|
+
}, {
|
|
1626
|
+
default: D(() => [(g(!0), i(e, null, y(t.fields.filter((e) => {
|
|
1627
|
+
let t = a.form.manifest.fields[e];
|
|
1628
|
+
return t ? h(t) : !1;
|
|
1629
|
+
}), (e) => (g(), n(l, {
|
|
1630
|
+
key: e,
|
|
1631
|
+
field: a.form.manifest.fields[e],
|
|
1632
|
+
form: a.form,
|
|
1633
|
+
theme: a.form.theme,
|
|
1634
|
+
renderers: a.form.renderers,
|
|
1635
|
+
"allow-raw-html": a.form.allowRawHtml
|
|
1636
|
+
}, null, 8, [
|
|
1637
|
+
"field",
|
|
1638
|
+
"form",
|
|
1639
|
+
"theme",
|
|
1640
|
+
"renderers",
|
|
1641
|
+
"allow-raw-html"
|
|
1642
|
+
]))), 128))]),
|
|
1643
|
+
_: 2
|
|
1644
|
+
}, 1032, ["class"])) : r("", !0)], 64))), 128))]),
|
|
1645
|
+
_: 1
|
|
1646
|
+
}, 8, [
|
|
1647
|
+
"form",
|
|
1648
|
+
"page-index",
|
|
1649
|
+
"class"
|
|
1650
|
+
])),
|
|
1651
|
+
(g(!0), i(e, null, y(a.form.manifest.security.captchas ?? [], (e) => (g(), n(v, {
|
|
1652
|
+
key: e.name,
|
|
1653
|
+
form: a.form,
|
|
1654
|
+
captcha: e
|
|
1655
|
+
}, null, 8, ["form", "captcha"]))), 128)),
|
|
1656
|
+
(g(), n(S(s.value.ButtonRow), { class: u(a.form.theme.classNames?.buttons) }, {
|
|
1657
|
+
default: D(() => [
|
|
1658
|
+
!m.value && f.value.buttons?.back ? (g(), n(S(s.value.BackButton), {
|
|
1659
|
+
key: 0,
|
|
1660
|
+
label: f.value.buttons.back.label,
|
|
1661
|
+
class: u(a.form.theme.classNames?.backButton),
|
|
1662
|
+
disabled: a.form.isSubmitting,
|
|
1663
|
+
"on-click": () => void a.form.goBack()
|
|
1664
|
+
}, null, 40, [
|
|
1665
|
+
"label",
|
|
1666
|
+
"class",
|
|
1667
|
+
"disabled",
|
|
1668
|
+
"on-click"
|
|
1669
|
+
])) : r("", !0),
|
|
1670
|
+
a.form.manifest.settings.multiPage && !p.value && f.value.buttons?.submit ? (g(), n(S(s.value.NextButton), {
|
|
1671
|
+
key: 1,
|
|
1672
|
+
label: f.value.buttons.submit.label,
|
|
1673
|
+
class: u(a.form.theme.classNames?.nextButton),
|
|
1674
|
+
disabled: a.form.isSubmitting,
|
|
1675
|
+
"on-click": () => void a.form.goNext()
|
|
1676
|
+
}, null, 40, [
|
|
1677
|
+
"label",
|
|
1678
|
+
"class",
|
|
1679
|
+
"disabled",
|
|
1680
|
+
"on-click"
|
|
1681
|
+
])) : r("", !0),
|
|
1682
|
+
(!a.form.manifest.settings.multiPage || p.value) && f.value.buttons?.submit ? (g(), n(S(s.value.SubmitButton), {
|
|
1683
|
+
key: 2,
|
|
1684
|
+
label: f.value.buttons.submit.label,
|
|
1685
|
+
class: u(a.form.theme.classNames?.submitButton),
|
|
1686
|
+
disabled: a.form.isSubmitting
|
|
1687
|
+
}, null, 8, [
|
|
1688
|
+
"label",
|
|
1689
|
+
"class",
|
|
1690
|
+
"disabled"
|
|
1691
|
+
])) : r("", !0),
|
|
1692
|
+
f.value.buttons?.save ? (g(), n(S(s.value.SaveButton), {
|
|
1693
|
+
key: 3,
|
|
1694
|
+
label: f.value.buttons.save.label,
|
|
1695
|
+
class: u(a.form.theme.classNames?.saveButton),
|
|
1696
|
+
disabled: a.form.isSubmitting,
|
|
1697
|
+
"on-click": () => void a.form.saveDraft()
|
|
1698
|
+
}, null, 40, [
|
|
1699
|
+
"label",
|
|
1700
|
+
"class",
|
|
1701
|
+
"disabled",
|
|
1702
|
+
"on-click"
|
|
1703
|
+
])) : r("", !0)
|
|
1704
|
+
]),
|
|
1705
|
+
_: 1
|
|
1706
|
+
}, 8, ["class"]))
|
|
1707
|
+
]),
|
|
1708
|
+
_: 1
|
|
1709
|
+
}, 40, ["form", "class"]));
|
|
1710
|
+
};
|
|
1711
|
+
}
|
|
1712
|
+
});
|
|
1713
|
+
//#endregion
|
|
1714
|
+
//#region src/renderers/resolve.ts
|
|
1715
|
+
function lt(e, t, n) {
|
|
1716
|
+
let r = e.frontend?.renderer ?? "";
|
|
1717
|
+
return [
|
|
1718
|
+
t?.handles?.[e.handle],
|
|
1719
|
+
r ? t?.frontend?.[r] : void 0,
|
|
1720
|
+
t?.types?.[e.type],
|
|
1721
|
+
n?.renderers?.handles?.[e.handle],
|
|
1722
|
+
r ? n?.renderers?.frontend?.[r] : void 0,
|
|
1723
|
+
n?.renderers?.types?.[e.type],
|
|
1724
|
+
r ? Z.frontend[r] : void 0,
|
|
1725
|
+
r ? Z.types[r] : void 0,
|
|
1726
|
+
Z.types[e.type]
|
|
1727
|
+
].find((e) => !!e) ?? Z.types._unsupported;
|
|
1728
|
+
}
|
|
1729
|
+
//#endregion
|
|
1730
|
+
//#region src/theme/resolveThemeClassNames.ts
|
|
1731
|
+
var ut = /* @__PURE__ */ new Set([
|
|
1732
|
+
"checkbox",
|
|
1733
|
+
"checkboxes",
|
|
1734
|
+
"radio",
|
|
1735
|
+
"radios",
|
|
1736
|
+
"radiobox",
|
|
1737
|
+
"rating",
|
|
1738
|
+
"opinion-scale",
|
|
1739
|
+
"cards"
|
|
1740
|
+
]);
|
|
1741
|
+
function $(e, t) {
|
|
1742
|
+
return t ? {
|
|
1743
|
+
...e,
|
|
1744
|
+
...t
|
|
1745
|
+
} : e;
|
|
1746
|
+
}
|
|
1747
|
+
function dt(e, t, n = !1) {
|
|
1748
|
+
let r = e.classNamesByType, i = $({}, e.classNames);
|
|
1749
|
+
i = $(i, r?.[t.type]);
|
|
1750
|
+
let a = t.frontend?.renderer;
|
|
1751
|
+
a && (i = $(i, r?.[a]));
|
|
1752
|
+
let o = t.frontend?.extension;
|
|
1753
|
+
return o && (i = $(i, r?.[o])), n && i.inputError && (i = ut.has(t.type) ? {
|
|
1754
|
+
...i,
|
|
1755
|
+
optionInput: Q(i.optionInput, i.inputError)
|
|
1756
|
+
} : {
|
|
1757
|
+
...i,
|
|
1758
|
+
input: Q(i.input, i.inputError)
|
|
1759
|
+
}), i;
|
|
1760
|
+
}
|
|
1761
|
+
//#endregion
|
|
1762
|
+
export { de as CLIENT_NAME, ce as FormLoader, ge as Freeform, ct as FreeformView, ue as PACKAGE_VERSION, at as builtinComponents, Z as builtinRenderers, le as createTheme, H as defaultTheme, Q as joinClassNames, ot as mergeClassNames, lt as resolveFieldRenderer, dt as resolveThemeClassNames, st as toBemModifier, _e as useFieldExtension, me as useFreeform };
|
|
1763
|
+
|
|
1764
|
+
//# sourceMappingURL=index.js.map
|