@verbb/formie-vue 1.0.13 → 1.0.15
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/CHANGELOG.md +24 -0
- package/README.md +1 -1
- package/dist/definition-form.d.ts +53 -41
- package/dist/definition-form.d.ts.map +1 -1
- package/dist/index.d.ts +53 -33
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +390 -304
- package/dist/{signature_pad-D-mX46zR.js → signature_pad-dbpVgfTh.js} +32 -18
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { FORMIE_HTML_EVENT_NAMES as e, createFormieClient as t } from "@verbb/formie-browser";
|
|
2
|
-
import { computed as
|
|
3
|
-
import {
|
|
1
|
+
import { FORMIE_HTML_EVENT_NAMES as e, createFormieClient as t, mountClientRenderedModules as n } from "@verbb/formie-browser";
|
|
2
|
+
import { computed as r, defineComponent as i, h as a, inject as o, onBeforeUnmount as s, onMounted as c, provide as l, ref as u, shallowRef as d, watch as f } from "vue";
|
|
3
|
+
import { CLIENT_FORM_EVENT_NAMES as p, clientActionAllowed as m, compositePartDefinitions as h, createClientFormInstance as g, createGraphqlClientTransport as _, createRepeaterRowValue as v, createRestClientTransport as y, getClientErrorAriaLive as b, getClientFieldErrorId as x, isCompositeField as S, isFileField as C, isKnownClientFieldType as w, isRepeatableField as ee, loadClientFormBootstrap as te, loadGraphqlClientFormBootstrap as ne, repeaterRowDefinitions as T } from "@verbb/formie-core";
|
|
4
4
|
//#region src/stable.ts
|
|
5
|
-
function
|
|
5
|
+
function E(e, t) {
|
|
6
6
|
if (e == null) return String(e);
|
|
7
7
|
if (typeof e == "string") return JSON.stringify(e);
|
|
8
8
|
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
9
9
|
if (typeof e == "function") return "[function]";
|
|
10
10
|
if (typeof File < "u" && e instanceof File) return `[file:${e.name}:${e.size}:${e.type}]`;
|
|
11
11
|
if (typeof Blob < "u" && e instanceof Blob) return `[blob:${e.size}:${e.type}]`;
|
|
12
|
-
if (Array.isArray(e)) return `[${e.map((e) =>
|
|
12
|
+
if (Array.isArray(e)) return `[${e.map((e) => E(e, t)).join(",")}]`;
|
|
13
13
|
if (typeof e == "object") {
|
|
14
14
|
if (t.has(e)) return "[circular]";
|
|
15
15
|
t.add(e);
|
|
16
|
-
let n = Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => `${JSON.stringify(e)}:${
|
|
16
|
+
let n = Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, n]) => `${JSON.stringify(e)}:${E(n, t)}`);
|
|
17
17
|
return t.delete(e), `{${n.join(",")}}`;
|
|
18
18
|
}
|
|
19
19
|
return JSON.stringify(String(e));
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
return
|
|
21
|
+
function D(e) {
|
|
22
|
+
return E(e, /* @__PURE__ */ new WeakSet());
|
|
23
23
|
}
|
|
24
24
|
//#endregion
|
|
25
25
|
//#region src/definition-form.ts
|
|
26
|
-
var
|
|
26
|
+
var O = Symbol("formie-definition-context"), k = {
|
|
27
27
|
field: {
|
|
28
28
|
type: Object,
|
|
29
29
|
required: !0
|
|
@@ -40,6 +40,14 @@ var T = Symbol("formie-definition-context"), E = {
|
|
|
40
40
|
type: String,
|
|
41
41
|
required: !0
|
|
42
42
|
},
|
|
43
|
+
errorId: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: ""
|
|
46
|
+
},
|
|
47
|
+
errorAriaLive: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: "polite"
|
|
50
|
+
},
|
|
43
51
|
disabled: {
|
|
44
52
|
type: Boolean,
|
|
45
53
|
default: !1
|
|
@@ -53,64 +61,70 @@ var T = Symbol("formie-definition-context"), E = {
|
|
|
53
61
|
required: !0
|
|
54
62
|
}
|
|
55
63
|
};
|
|
56
|
-
function
|
|
57
|
-
let e =
|
|
64
|
+
function A() {
|
|
65
|
+
let e = o(O);
|
|
58
66
|
if (!e) throw Error("Formie definition composables must be used within a client-rendered <FormieForm>.");
|
|
59
67
|
return e;
|
|
60
68
|
}
|
|
61
|
-
function
|
|
69
|
+
function j(e) {
|
|
62
70
|
return "definition" in e;
|
|
63
71
|
}
|
|
64
|
-
async function
|
|
65
|
-
return
|
|
72
|
+
async function re(e) {
|
|
73
|
+
return j(e) ? e.definition : e.transport === "graphql" ? ne({
|
|
66
74
|
endpoint: e.endpoint,
|
|
75
|
+
profile: e.profile,
|
|
67
76
|
formHandle: e.formHandle,
|
|
68
|
-
siteId: e.siteId
|
|
69
|
-
|
|
77
|
+
siteId: e.siteId,
|
|
78
|
+
query: e.query
|
|
79
|
+
}) : te({
|
|
70
80
|
endpoint: e.endpoint,
|
|
81
|
+
profile: e.profile,
|
|
71
82
|
formHandle: e.formHandle,
|
|
72
|
-
siteId: e.siteId
|
|
83
|
+
siteId: e.siteId,
|
|
84
|
+
query: e.query
|
|
73
85
|
});
|
|
74
86
|
}
|
|
75
|
-
function
|
|
76
|
-
let t =
|
|
87
|
+
function ie(e) {
|
|
88
|
+
let t = j(e) ? e.transport : {
|
|
77
89
|
type: e.transport,
|
|
78
90
|
endpoint: e.endpoint,
|
|
91
|
+
profile: e.profile,
|
|
79
92
|
formHandle: e.formHandle,
|
|
80
|
-
siteId: e.siteId
|
|
93
|
+
siteId: e.siteId,
|
|
94
|
+
query: e.query
|
|
81
95
|
};
|
|
82
|
-
return t.type === "graphql" ?
|
|
96
|
+
return t.type === "graphql" ? _(t) : y(t);
|
|
83
97
|
}
|
|
84
|
-
function
|
|
98
|
+
function ae(e) {
|
|
85
99
|
return e.pages.flatMap((e) => e.rows).flatMap((e) => e.fields);
|
|
86
100
|
}
|
|
87
|
-
function
|
|
88
|
-
if (
|
|
101
|
+
function M(e) {
|
|
102
|
+
if (w(e.type)) return e.type;
|
|
89
103
|
let t = typeof e.input.fieldKind == "string" ? e.input.fieldKind : null;
|
|
90
104
|
return t === "text" ? "single-line-text" : t === "textarea" ? "multi-line-text" : t === "boolean" ? "agree" : t === "file" ? "file" : e.type;
|
|
91
105
|
}
|
|
92
|
-
function
|
|
106
|
+
function N(e, t, n) {
|
|
93
107
|
let r = new Set(e.moduleRefs || []);
|
|
94
|
-
return t.modules.find((e) => r.has(e.
|
|
108
|
+
return t.modules.entries.find((e) => r.has(e.key) && e.moduleId === n) || null;
|
|
95
109
|
}
|
|
96
|
-
function
|
|
110
|
+
function P(e, t, n, r) {
|
|
97
111
|
if (!n) return null;
|
|
98
|
-
let
|
|
99
|
-
return
|
|
112
|
+
let i = e.slots.value[t];
|
|
113
|
+
return i ? a(i, {
|
|
100
114
|
slotKey: t,
|
|
101
115
|
attributes: r
|
|
102
116
|
}, { default: () => [n] }) : n;
|
|
103
117
|
}
|
|
104
|
-
var
|
|
118
|
+
var F = i({
|
|
105
119
|
name: "FormieVueDefaultErrorSummary",
|
|
106
120
|
props: { errors: {
|
|
107
121
|
type: Array,
|
|
108
122
|
required: !0
|
|
109
123
|
} },
|
|
110
124
|
setup(e) {
|
|
111
|
-
return () => e.errors.length === 0 ? null :
|
|
125
|
+
return () => e.errors.length === 0 ? null : a("div", { class: "formie-vue-errors" }, [a("ul", null, e.errors.map((e, t) => a("li", { key: `${e}:${t}` }, e)))]);
|
|
112
126
|
}
|
|
113
|
-
}),
|
|
127
|
+
}), I = i({
|
|
114
128
|
name: "FormieVueDefaultField",
|
|
115
129
|
props: {
|
|
116
130
|
field: {
|
|
@@ -120,27 +134,63 @@ var M = r({
|
|
|
120
134
|
errors: {
|
|
121
135
|
type: Array,
|
|
122
136
|
required: !0
|
|
137
|
+
},
|
|
138
|
+
errorId: {
|
|
139
|
+
type: String,
|
|
140
|
+
required: !0
|
|
141
|
+
},
|
|
142
|
+
errorAriaLive: {
|
|
143
|
+
type: String,
|
|
144
|
+
required: !0
|
|
123
145
|
}
|
|
124
146
|
},
|
|
125
147
|
setup(e, t) {
|
|
126
|
-
let n =
|
|
148
|
+
let n = A();
|
|
127
149
|
return () => {
|
|
128
150
|
let r = t.slots.default?.() || [];
|
|
129
|
-
return
|
|
151
|
+
return a("div", {
|
|
130
152
|
class: "formie-vue-field",
|
|
131
|
-
"data-field-
|
|
153
|
+
"data-formie-field-uid": e.field.uid,
|
|
154
|
+
"data-formie-field-handle": e.field.handle,
|
|
155
|
+
"data-formie-field-type": e.field.type
|
|
132
156
|
}, [
|
|
133
|
-
e.field.label ?
|
|
134
|
-
e.field.instructions ?
|
|
157
|
+
e.field.label ? P(n, "label", a("label", { class: "formie-vue-label" }, e.field.label), { class: "formie-vue-label" }) : null,
|
|
158
|
+
e.field.instructions ? P(n, "instructions", a("div", {
|
|
135
159
|
class: "formie-vue-description",
|
|
136
160
|
innerHTML: e.field.instructions
|
|
137
161
|
}), { class: "formie-vue-description" }) : null,
|
|
138
|
-
|
|
139
|
-
|
|
162
|
+
P(n, "input", a("div", { class: "formie-vue-input" }, r), { class: "formie-vue-input" }),
|
|
163
|
+
P(n, "errors", a("ul", {
|
|
164
|
+
id: e.errorId,
|
|
165
|
+
class: "formie-vue-field-errors",
|
|
166
|
+
style: e.errors.length === 0 ? { position: "absolute" } : void 0,
|
|
167
|
+
"data-formie-field-errors": !0,
|
|
168
|
+
"aria-live": e.errorAriaLive === "off" ? void 0 : e.errorAriaLive,
|
|
169
|
+
"aria-atomic": e.errorAriaLive === "off" ? void 0 : "true"
|
|
170
|
+
}, e.errors.map((e, t) => a("li", { key: `${e}:${t}` }, e))), {
|
|
171
|
+
id: e.errorId,
|
|
172
|
+
class: "formie-vue-field-errors",
|
|
173
|
+
style: e.errors.length === 0 ? { position: "absolute" } : void 0,
|
|
174
|
+
"data-formie-field-errors": !0,
|
|
175
|
+
"aria-live": e.errorAriaLive === "off" ? void 0 : e.errorAriaLive,
|
|
176
|
+
"aria-atomic": e.errorAriaLive === "off" ? void 0 : "true"
|
|
177
|
+
})
|
|
140
178
|
]);
|
|
141
179
|
};
|
|
142
180
|
}
|
|
143
|
-
}),
|
|
181
|
+
}), L = i({ setup(e, { slots: t }) {
|
|
182
|
+
let r = A(), i = u(null), o = !1, l;
|
|
183
|
+
return c(async () => {
|
|
184
|
+
let e = r.instance.value;
|
|
185
|
+
e.setBrowserModuleGuard(() => {
|
|
186
|
+
throw Error("Form features are still loading.");
|
|
187
|
+
});
|
|
188
|
+
let t = await n(i.value, e);
|
|
189
|
+
o ? t.destroy() : l = t;
|
|
190
|
+
}), s(() => {
|
|
191
|
+
o = !0, l?.destroy();
|
|
192
|
+
}), () => a("div", { ref: i }, t.default?.());
|
|
193
|
+
} }), R = i({
|
|
144
194
|
name: "FormieVueDefaultForm",
|
|
145
195
|
props: {
|
|
146
196
|
definition: {
|
|
@@ -165,16 +215,18 @@ var M = r({
|
|
|
165
215
|
}
|
|
166
216
|
},
|
|
167
217
|
setup(e, t) {
|
|
168
|
-
return () =>
|
|
218
|
+
return () => a("form", {
|
|
169
219
|
class: e.className,
|
|
170
|
-
onSubmit: (t) => {
|
|
171
|
-
t.preventDefault()
|
|
220
|
+
onSubmit: async (t) => {
|
|
221
|
+
t.preventDefault();
|
|
222
|
+
let n = t.currentTarget;
|
|
223
|
+
await e.onSubmit(), requestAnimationFrame(() => n.querySelector("[aria-invalid=\"true\"]")?.focus());
|
|
172
224
|
},
|
|
173
225
|
"data-formie-definition": e.definition.handle,
|
|
174
226
|
"data-formie-render-id": e.session.tokens.render
|
|
175
227
|
}, t.slots.default?.() || []);
|
|
176
228
|
}
|
|
177
|
-
}),
|
|
229
|
+
}), z = i({
|
|
178
230
|
name: "FormieVueDefaultPage",
|
|
179
231
|
props: {
|
|
180
232
|
page: {
|
|
@@ -187,56 +239,51 @@ var M = r({
|
|
|
187
239
|
}
|
|
188
240
|
},
|
|
189
241
|
setup(e, t) {
|
|
190
|
-
return () =>
|
|
242
|
+
return () => a("section", {
|
|
191
243
|
"data-page-id": e.page.id,
|
|
192
244
|
class: "formie-vue-page"
|
|
193
245
|
}, t.slots.default?.() || []);
|
|
194
246
|
}
|
|
195
|
-
}),
|
|
247
|
+
}), B = i({
|
|
196
248
|
name: "FormieVueSignatureFieldInput",
|
|
197
|
-
props:
|
|
249
|
+
props: k,
|
|
198
250
|
setup(e) {
|
|
199
|
-
let t =
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}), h = n(() => {
|
|
206
|
-
let e = f.value?.options;
|
|
207
|
-
return Number(e?.penWeight ?? 2) || 2;
|
|
208
|
-
}), g = n(() => typeof e.value == "string" ? e.value : ""), _ = !1, v = () => void 0, y = () => void 0;
|
|
209
|
-
return s(() => {
|
|
251
|
+
let t = A(), n = u(null), i = d(null), o = u(null), l = r(() => N(e.field, t.state.value?.definition || { modules: {
|
|
252
|
+
contractVersion: 2,
|
|
253
|
+
surface: "client-rendered",
|
|
254
|
+
entries: []
|
|
255
|
+
} }, "formie:signature")?.config), p = r(() => typeof l.value?.backgroundColor == "string" ? l.value.backgroundColor : "#ffffff"), m = r(() => typeof l.value?.penColor == "string" ? l.value.penColor : "#000000"), h = r(() => Number(l.value?.penWeight ?? 2) || 2), g = r(() => typeof e.value == "string" ? e.value : ""), _ = !1, v = () => void 0, y = () => void 0;
|
|
256
|
+
return c(() => {
|
|
210
257
|
(async () => {
|
|
211
258
|
try {
|
|
212
|
-
let t =
|
|
259
|
+
let t = n.value;
|
|
213
260
|
if (!t) return;
|
|
214
|
-
let { default:
|
|
261
|
+
let { default: r } = await import("./signature_pad-dbpVgfTh.js");
|
|
215
262
|
if (_) return;
|
|
216
|
-
let
|
|
263
|
+
let a = new r(t, {
|
|
217
264
|
backgroundColor: p.value,
|
|
218
265
|
penColor: m.value,
|
|
219
266
|
minWidth: h.value,
|
|
220
267
|
maxWidth: h.value
|
|
221
|
-
}),
|
|
268
|
+
}), s = () => {
|
|
222
269
|
let e = typeof window > "u" ? 1 : Math.max(window.devicePixelRatio || 1, 1), n = Math.max(1, Math.floor(t.clientWidth || 480)), r = t.getContext("2d");
|
|
223
|
-
t.width = n * e, t.height = 192 * e, t.style.height = "192px", r && (r.setTransform(1, 0, 0, 1, 0, 0), r.scale(e, e)),
|
|
224
|
-
},
|
|
225
|
-
e.setValue(
|
|
270
|
+
t.width = n * e, t.height = 192 * e, t.style.height = "192px", r && (r.setTransform(1, 0, 0, 1, 0, 0), r.scale(e, e)), a.clear();
|
|
271
|
+
}, c = () => {
|
|
272
|
+
e.setValue(a.isEmpty() ? "" : a.toDataURL());
|
|
226
273
|
};
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}, typeof window < "u" && (window.addEventListener("resize",
|
|
230
|
-
window.removeEventListener("resize",
|
|
231
|
-
}),
|
|
274
|
+
s(), a.addEventListener?.("endStroke", c), v = () => {
|
|
275
|
+
a.removeEventListener?.("endStroke", c);
|
|
276
|
+
}, typeof window < "u" && (window.addEventListener("resize", s), y = () => {
|
|
277
|
+
window.removeEventListener("resize", s);
|
|
278
|
+
}), i.value = a, o.value = null;
|
|
232
279
|
} catch (e) {
|
|
233
|
-
_ || (
|
|
280
|
+
_ || (o.value = e.message || "Unable to load signature support.");
|
|
234
281
|
}
|
|
235
282
|
})();
|
|
236
|
-
}),
|
|
237
|
-
_ = !0, v(), y(),
|
|
238
|
-
}),
|
|
239
|
-
let t =
|
|
283
|
+
}), s(() => {
|
|
284
|
+
_ = !0, v(), y(), i.value = null;
|
|
285
|
+
}), f(g, (e) => {
|
|
286
|
+
let t = i.value;
|
|
240
287
|
if (t) {
|
|
241
288
|
if (!e) {
|
|
242
289
|
t.isEmpty() || t.clear();
|
|
@@ -246,50 +293,50 @@ var M = r({
|
|
|
246
293
|
t.fromDataURL(e);
|
|
247
294
|
} catch {}
|
|
248
295
|
}
|
|
249
|
-
}, { immediate: !0 }), () =>
|
|
250
|
-
|
|
296
|
+
}, { immediate: !0 }), () => a("div", { class: "formie-vue-signature" }, [
|
|
297
|
+
a("canvas", {
|
|
251
298
|
key: "canvas",
|
|
252
|
-
ref:
|
|
299
|
+
ref: n,
|
|
253
300
|
"data-formie-signature-canvas": !0,
|
|
254
301
|
style: e.disabled ? { pointerEvents: "none" } : void 0
|
|
255
302
|
}),
|
|
256
|
-
|
|
303
|
+
a("button", {
|
|
257
304
|
key: "clear",
|
|
258
305
|
type: "button",
|
|
259
306
|
disabled: e.disabled,
|
|
260
307
|
"data-formie-signature-clear": !0,
|
|
261
308
|
onClick: () => {
|
|
262
|
-
|
|
309
|
+
i.value?.clear(), e.setValue("");
|
|
263
310
|
}
|
|
264
311
|
}, "Clear"),
|
|
265
|
-
|
|
312
|
+
o.value ? a("div", {
|
|
266
313
|
key: "error",
|
|
267
314
|
class: "formie-vue-unsupported"
|
|
268
|
-
},
|
|
315
|
+
}, o.value) : null
|
|
269
316
|
]);
|
|
270
317
|
}
|
|
271
|
-
}),
|
|
318
|
+
}), V = i({
|
|
272
319
|
name: "FormieVueCompositeFieldInput",
|
|
273
|
-
props:
|
|
320
|
+
props: k,
|
|
274
321
|
setup(e) {
|
|
275
|
-
let t =
|
|
322
|
+
let t = A();
|
|
276
323
|
return () => {
|
|
277
324
|
let n = t.state.value;
|
|
278
325
|
if (!n) return null;
|
|
279
|
-
let r =
|
|
280
|
-
return r.length === 0 ?
|
|
326
|
+
let r = h(e.field), i = e.value && typeof e.value == "object" ? e.value : {};
|
|
327
|
+
return r.length === 0 ? a("div", { class: "formie-vue-unsupported" }, `Unsupported field type: ${e.field.type}`) : a("div", { class: "formie-vue-name-grid" }, r.filter((e) => e.meta?.hidden !== !0).map((t) => {
|
|
281
328
|
let r = `${e.errorKey}.${t.handle}`;
|
|
282
|
-
return
|
|
329
|
+
return a(U, {
|
|
283
330
|
key: `${e.field.id}:${t.handle}`,
|
|
284
331
|
field: t,
|
|
285
|
-
value:
|
|
332
|
+
value: i[t.handle],
|
|
286
333
|
errors: n.errors.fields[r] || [],
|
|
287
334
|
errorKey: r,
|
|
288
335
|
disabled: e.disabled || t.meta?.disabled === !0,
|
|
289
336
|
hidden: !1,
|
|
290
337
|
setValue(n) {
|
|
291
338
|
e.setValue({
|
|
292
|
-
...
|
|
339
|
+
...i,
|
|
293
340
|
[t.handle]: n
|
|
294
341
|
});
|
|
295
342
|
}
|
|
@@ -297,78 +344,83 @@ var M = r({
|
|
|
297
344
|
}));
|
|
298
345
|
};
|
|
299
346
|
}
|
|
300
|
-
}),
|
|
347
|
+
}), H = i({
|
|
301
348
|
name: "FormieVueFileFieldInput",
|
|
302
|
-
props:
|
|
349
|
+
props: k,
|
|
303
350
|
setup(e) {
|
|
304
351
|
return () => {
|
|
305
|
-
let t = e.field.input, n = Array.isArray(e.value) ? e.value : [], r = t.multiple === !0,
|
|
306
|
-
return
|
|
352
|
+
let t = e.field.input, n = Array.isArray(e.value) ? e.value : [], r = t.multiple === !0, i = n.map((e, t) => e && typeof e == "object" && "name" in e && typeof e.name == "string" ? e.name : e && typeof e == "object" && "filename" in e && typeof e.filename == "string" ? e.filename : e && typeof e == "object" && "assetId" in e && typeof e.assetId == "number" ? `Asset #${e.assetId}` : `File ${t + 1}`);
|
|
353
|
+
return a("div", { class: "formie-vue-file" }, [a("input", {
|
|
307
354
|
key: "input",
|
|
308
355
|
type: "file",
|
|
356
|
+
...q(e.errors, e.errorId),
|
|
309
357
|
disabled: e.disabled,
|
|
310
358
|
multiple: r,
|
|
311
359
|
onChange: (t) => {
|
|
312
360
|
let n = t.target;
|
|
313
361
|
e.setValue(Array.from(n.files || []));
|
|
314
362
|
}
|
|
315
|
-
}),
|
|
363
|
+
}), i.length > 0 ? a("ul", {
|
|
316
364
|
key: "summary",
|
|
317
365
|
class: "formie-vue-field-errors"
|
|
318
|
-
},
|
|
366
|
+
}, i.map((e, t) => a("li", { key: `${e}:${t}` }, e))) : null]);
|
|
319
367
|
};
|
|
320
368
|
}
|
|
321
|
-
}),
|
|
369
|
+
}), U = i({
|
|
322
370
|
name: "FormieVueConfigFieldNode",
|
|
323
|
-
props:
|
|
371
|
+
props: k,
|
|
324
372
|
setup(e) {
|
|
325
|
-
let t =
|
|
373
|
+
let t = A();
|
|
326
374
|
return () => {
|
|
327
375
|
let n = t.state.value;
|
|
328
376
|
if (!n) return null;
|
|
329
377
|
let r = n.fieldStates[e.field.id]?.hidden === !0;
|
|
330
378
|
if (r) return null;
|
|
331
|
-
let
|
|
332
|
-
return
|
|
379
|
+
let i = M(e.field), o = t.fieldComponents.value[e.field.type] || t.fieldComponents.value[i] || oe, s = t.components.value.Field || I, c = x(n.session, e.errorKey), l = b(n.definition);
|
|
380
|
+
return a(s, {
|
|
333
381
|
field: e.field,
|
|
334
|
-
errors: e.errors
|
|
335
|
-
|
|
382
|
+
errors: e.errors,
|
|
383
|
+
errorId: c,
|
|
384
|
+
errorAriaLive: l
|
|
385
|
+
}, { default: () => [a(o, {
|
|
336
386
|
field: e.field,
|
|
337
387
|
value: e.value,
|
|
338
388
|
errors: e.errors,
|
|
339
389
|
errorKey: e.errorKey,
|
|
390
|
+
errorId: c,
|
|
391
|
+
errorAriaLive: l,
|
|
340
392
|
disabled: e.disabled,
|
|
341
393
|
hidden: r,
|
|
342
394
|
setValue: e.setValue
|
|
343
395
|
})] });
|
|
344
396
|
};
|
|
345
397
|
}
|
|
346
|
-
}),
|
|
398
|
+
}), W = i({
|
|
347
399
|
name: "FormieVueConfigField",
|
|
348
400
|
props: { field: {
|
|
349
401
|
type: Object,
|
|
350
402
|
required: !0
|
|
351
403
|
} },
|
|
352
404
|
setup(e) {
|
|
353
|
-
let t =
|
|
405
|
+
let t = A();
|
|
354
406
|
return () => {
|
|
355
407
|
let n = t.state.value, r = t.instance.value;
|
|
356
408
|
if (!n || !r) return null;
|
|
357
|
-
let
|
|
358
|
-
return
|
|
409
|
+
let i = n.fieldStates[e.field.id];
|
|
410
|
+
return a(U, {
|
|
359
411
|
field: e.field,
|
|
360
412
|
value: n.values[e.field.id],
|
|
361
413
|
errors: n.errors.fields[e.field.id] || [],
|
|
362
414
|
errorKey: e.field.id,
|
|
363
|
-
disabled:
|
|
364
|
-
hidden:
|
|
415
|
+
disabled: i?.disabled === !0,
|
|
416
|
+
hidden: i?.hidden === !0,
|
|
365
417
|
setValue(t) {
|
|
366
418
|
r.setValue(e.field.id, t);
|
|
367
419
|
}
|
|
368
420
|
});
|
|
369
421
|
};
|
|
370
422
|
}
|
|
371
|
-
}),
|
|
423
|
+
}), G = i({
|
|
372
424
|
name: "FormieVueConfigRow",
|
|
373
425
|
props: {
|
|
374
426
|
row: {
|
|
@@ -397,23 +449,23 @@ var M = r({
|
|
|
397
449
|
}
|
|
398
450
|
},
|
|
399
451
|
setup(e) {
|
|
400
|
-
let t =
|
|
452
|
+
let t = A();
|
|
401
453
|
return () => {
|
|
402
454
|
let n = t.state.value;
|
|
403
|
-
return n ?
|
|
404
|
-
if (!e.values || !e.setFieldValue) return
|
|
455
|
+
return n ? a("div", { class: "formie-vue-row" }, e.row.fields.map((t, r) => {
|
|
456
|
+
if (!e.values || !e.setFieldValue) return a(W, {
|
|
405
457
|
key: t.id || `${e.rowIndex}:${r}`,
|
|
406
458
|
field: t
|
|
407
459
|
});
|
|
408
|
-
let
|
|
409
|
-
return
|
|
460
|
+
let i = `${e.errorPrefix}.${t.handle}`;
|
|
461
|
+
return a(U, {
|
|
410
462
|
key: t.id || `${e.rowIndex}:${r}`,
|
|
411
463
|
field: t,
|
|
412
464
|
value: e.values[t.handle],
|
|
413
|
-
errors: n.errors.fields[
|
|
414
|
-
errorKey:
|
|
415
|
-
disabled: e.disabled === !0 || n.fieldStates[
|
|
416
|
-
hidden: n.fieldStates[
|
|
465
|
+
errors: n.errors.fields[i] || [],
|
|
466
|
+
errorKey: i,
|
|
467
|
+
disabled: e.disabled === !0 || n.fieldStates[i]?.disabled === !0,
|
|
468
|
+
hidden: n.fieldStates[i]?.hidden === !0,
|
|
417
469
|
setValue(n) {
|
|
418
470
|
e.setFieldValue?.(t, n);
|
|
419
471
|
}
|
|
@@ -421,26 +473,26 @@ var M = r({
|
|
|
421
473
|
})) : null;
|
|
422
474
|
};
|
|
423
475
|
}
|
|
424
|
-
}),
|
|
476
|
+
}), K = i({
|
|
425
477
|
name: "FormieVueRepeaterFieldInput",
|
|
426
|
-
props:
|
|
478
|
+
props: k,
|
|
427
479
|
setup(e) {
|
|
428
|
-
let t =
|
|
480
|
+
let t = A();
|
|
429
481
|
return () => {
|
|
430
482
|
let n = t.state.value;
|
|
431
483
|
if (!n) return null;
|
|
432
|
-
let r =
|
|
433
|
-
return r.length === 0 ?
|
|
484
|
+
let r = T(e.field), i = Array.isArray(e.value) ? e.value : [], o = e.field.input, s = Number(o.minRows ?? 0) || 0, c = Number(o.maxRows ?? 0) || 0, l = !e.disabled && (c <= 0 || i.length < c);
|
|
485
|
+
return r.length === 0 ? a("div", { class: "formie-vue-unsupported" }, "Unsupported repeater field.") : a("div", {
|
|
434
486
|
class: "formie-vue-repeater",
|
|
435
487
|
"data-formie-repeater-container": !0
|
|
436
488
|
}, [
|
|
437
|
-
...
|
|
489
|
+
...i.map((t, n) => {
|
|
438
490
|
let o = `${e.field.id}:${n}`;
|
|
439
|
-
return
|
|
491
|
+
return a("div", {
|
|
440
492
|
key: o,
|
|
441
493
|
class: "formie-vue-repeater-item",
|
|
442
494
|
"data-formie-repeater-item": !0
|
|
443
|
-
}, [...r.map((r, s) =>
|
|
495
|
+
}, [...r.map((r, s) => a(G, {
|
|
444
496
|
key: `${o}:${s}`,
|
|
445
497
|
row: r,
|
|
446
498
|
rowIndex: s,
|
|
@@ -448,82 +500,95 @@ var M = r({
|
|
|
448
500
|
errorPrefix: `${e.errorKey}.${n}`,
|
|
449
501
|
disabled: e.disabled,
|
|
450
502
|
setFieldValue(t, r) {
|
|
451
|
-
let
|
|
503
|
+
let a = i.map((e, i) => i === n ? {
|
|
452
504
|
...e,
|
|
453
505
|
[t.handle]: r
|
|
454
506
|
} : e);
|
|
455
|
-
e.setValue(
|
|
507
|
+
e.setValue(a);
|
|
456
508
|
}
|
|
457
|
-
})),
|
|
509
|
+
})), a("button", {
|
|
458
510
|
key: "remove",
|
|
459
511
|
type: "button",
|
|
460
|
-
disabled: e.disabled || s > 0 &&
|
|
512
|
+
disabled: e.disabled || s > 0 && i.length <= s,
|
|
461
513
|
"data-formie-repeater-remove": !0,
|
|
462
514
|
onClick: () => {
|
|
463
|
-
e.setValue(
|
|
515
|
+
e.setValue(i.filter((e, t) => t !== n));
|
|
464
516
|
}
|
|
465
517
|
}, "Remove")]);
|
|
466
518
|
}),
|
|
467
|
-
|
|
519
|
+
a("button", {
|
|
468
520
|
key: "add",
|
|
469
521
|
type: "button",
|
|
470
522
|
disabled: !l,
|
|
471
523
|
"data-formie-repeater-add": e.field.handle,
|
|
472
524
|
onClick: () => {
|
|
473
|
-
e.setValue([...
|
|
525
|
+
e.setValue([...i, v(e.field)]);
|
|
474
526
|
}
|
|
475
|
-
}, String(o.
|
|
476
|
-
n.errors.fields[e.errorKey] && n.errors.fields[e.errorKey].length > 0 ?
|
|
527
|
+
}, String(o.addRowLabel ?? "Add another row")),
|
|
528
|
+
n.errors.fields[e.errorKey] && n.errors.fields[e.errorKey].length > 0 ? a("ul", {
|
|
477
529
|
key: "errors",
|
|
478
530
|
class: "formie-vue-field-errors"
|
|
479
|
-
}, n.errors.fields[e.errorKey].map((e, t) =>
|
|
531
|
+
}, n.errors.fields[e.errorKey].map((e, t) => a("li", { key: `${e}:${t}` }, e))) : null
|
|
480
532
|
]);
|
|
481
533
|
};
|
|
482
534
|
}
|
|
483
535
|
});
|
|
484
|
-
function
|
|
485
|
-
|
|
486
|
-
|
|
536
|
+
function q(e, t) {
|
|
537
|
+
return e.length > 0 ? {
|
|
538
|
+
"aria-invalid": "true",
|
|
539
|
+
"aria-errormessage": t,
|
|
540
|
+
"aria-describedby": t
|
|
541
|
+
} : {};
|
|
542
|
+
}
|
|
543
|
+
function J(e, t, n, r, i = [], o = "") {
|
|
544
|
+
let s = e.input;
|
|
545
|
+
if (e.type === "multi-line-text") return a("textarea", {
|
|
546
|
+
"aria-label": e.label || e.handle,
|
|
547
|
+
...q(i, o),
|
|
487
548
|
value: typeof t == "string" ? t : "",
|
|
488
549
|
disabled: n,
|
|
489
|
-
placeholder: typeof
|
|
550
|
+
placeholder: typeof s.placeholder == "string" ? s.placeholder : void 0,
|
|
490
551
|
onInput: (e) => {
|
|
491
552
|
let t = e.target;
|
|
492
553
|
r(t.value);
|
|
493
554
|
}
|
|
494
555
|
});
|
|
495
556
|
if (e.type === "dropdown") {
|
|
496
|
-
let
|
|
497
|
-
return
|
|
498
|
-
|
|
557
|
+
let c = Array.isArray(s.options) ? s.options : [], l = s.multiple === !0;
|
|
558
|
+
return a("select", {
|
|
559
|
+
"aria-label": e.label || e.handle,
|
|
560
|
+
...q(i, o),
|
|
561
|
+
value: l ? void 0 : typeof t == "string" ? t : "",
|
|
499
562
|
disabled: n,
|
|
500
|
-
multiple:
|
|
563
|
+
multiple: l,
|
|
501
564
|
onChange: (e) => {
|
|
502
565
|
let t = e.target;
|
|
503
|
-
if (
|
|
566
|
+
if (l) {
|
|
504
567
|
r(Array.from(t.selectedOptions).map((e) => e.value));
|
|
505
568
|
return;
|
|
506
569
|
}
|
|
507
570
|
r(t.value);
|
|
508
571
|
}
|
|
509
|
-
},
|
|
572
|
+
}, c.map((t) => {
|
|
510
573
|
let n = String(t.value ?? "");
|
|
511
|
-
return
|
|
574
|
+
return a("option", {
|
|
512
575
|
key: `${e.id}:${n}`,
|
|
513
576
|
value: n,
|
|
514
577
|
disabled: t.disabled === !0
|
|
515
578
|
}, String(t.label ?? n));
|
|
516
579
|
}));
|
|
517
580
|
}
|
|
518
|
-
let
|
|
519
|
-
return
|
|
520
|
-
|
|
581
|
+
let c = typeof s.inputType == "string" ? s.inputType : e.type === "email" ? "email" : e.type === "phone" ? "tel" : e.type === "number" ? "number" : "text";
|
|
582
|
+
return a("input", {
|
|
583
|
+
"aria-label": e.label || e.handle,
|
|
584
|
+
...q(i, o),
|
|
585
|
+
type: c,
|
|
521
586
|
value: typeof t == "string" || typeof t == "number" ? String(t) : "",
|
|
522
587
|
disabled: n,
|
|
523
|
-
placeholder: typeof
|
|
588
|
+
placeholder: typeof s.placeholder == "string" ? s.placeholder : void 0,
|
|
524
589
|
onInput: (e) => {
|
|
525
590
|
let t = e.target;
|
|
526
|
-
if (
|
|
591
|
+
if (c === "number") {
|
|
527
592
|
let e = t.valueAsNumber;
|
|
528
593
|
r(Number.isFinite(e) ? e : "");
|
|
529
594
|
return;
|
|
@@ -532,134 +597,140 @@ function U(e, t, n, r) {
|
|
|
532
597
|
}
|
|
533
598
|
});
|
|
534
599
|
}
|
|
535
|
-
var
|
|
600
|
+
var oe = i({
|
|
536
601
|
name: "FormieVueDefaultFieldInput",
|
|
537
|
-
props:
|
|
602
|
+
props: k,
|
|
538
603
|
setup(e) {
|
|
539
604
|
return () => {
|
|
540
|
-
let t = e.field.input, n =
|
|
541
|
-
if (
|
|
542
|
-
if (
|
|
543
|
-
if (
|
|
544
|
-
if (n === "signature") return
|
|
545
|
-
if (n === "multi-line-text" || n === "dropdown") return
|
|
546
|
-
if (n === "radio")
|
|
547
|
-
let n =
|
|
548
|
-
return
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
e.
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
605
|
+
let t = e.field.input, n = M(e.field);
|
|
606
|
+
if (S(e.field)) return a(V, e);
|
|
607
|
+
if (ee(e.field)) return a(K, e);
|
|
608
|
+
if (C(e.field)) return a(H, e);
|
|
609
|
+
if (n === "signature") return a(B, e);
|
|
610
|
+
if (n === "multi-line-text" || n === "dropdown") return J(e.field, e.value, e.disabled, e.setValue, e.errors, e.errorId);
|
|
611
|
+
if (n === "radio") {
|
|
612
|
+
let n = Array.isArray(t.options) ? t.options : [];
|
|
613
|
+
return a("div", { class: "formie-vue-choices" }, n.map((t) => {
|
|
614
|
+
let n = String(t.value ?? ""), r = e.disabled || t.disabled === !0;
|
|
615
|
+
return a("label", { key: `${e.field.id}:${n}` }, [a("input", {
|
|
616
|
+
key: "input",
|
|
617
|
+
type: "radio",
|
|
618
|
+
...q(e.errors, e.errorId),
|
|
619
|
+
checked: e.value === n,
|
|
620
|
+
disabled: r,
|
|
621
|
+
onChange: () => {
|
|
622
|
+
e.setValue(n);
|
|
623
|
+
}
|
|
624
|
+
}), a("span", { key: "label" }, String(t.label ?? n))]);
|
|
625
|
+
}));
|
|
626
|
+
}
|
|
558
627
|
if (n === "checkboxes") {
|
|
559
628
|
let n = Array.isArray(t.options) ? t.options : [], r = Array.isArray(e.value) ? e.value.map((e) => String(e)) : [];
|
|
560
|
-
return
|
|
561
|
-
let n = String(t.value ?? ""),
|
|
562
|
-
return
|
|
629
|
+
return a("div", { class: "formie-vue-choices" }, n.map((t) => {
|
|
630
|
+
let n = String(t.value ?? ""), i = r.includes(n), o = e.disabled || t.disabled === !0;
|
|
631
|
+
return a("label", { key: `${e.field.id}:${n}` }, [a("input", {
|
|
563
632
|
key: "input",
|
|
564
633
|
type: "checkbox",
|
|
565
|
-
|
|
634
|
+
...q(e.errors, e.errorId),
|
|
635
|
+
checked: i,
|
|
566
636
|
disabled: o,
|
|
567
637
|
onChange: () => {
|
|
568
|
-
let t =
|
|
638
|
+
let t = i ? r.filter((e) => e !== n) : [...r, n];
|
|
569
639
|
e.setValue(t);
|
|
570
640
|
}
|
|
571
|
-
}),
|
|
641
|
+
}), a("span", { key: "label" }, String(t.label ?? n))]);
|
|
572
642
|
}));
|
|
573
643
|
}
|
|
574
644
|
if (n === "agree") {
|
|
575
645
|
let n = typeof t.descriptionHtml == "string" ? t.descriptionHtml : null;
|
|
576
|
-
return
|
|
646
|
+
return a("label", { class: "formie-vue-boolean" }, [a("input", {
|
|
577
647
|
key: "input",
|
|
578
648
|
type: "checkbox",
|
|
649
|
+
...q(e.errors, e.errorId),
|
|
579
650
|
checked: e.value === !0,
|
|
580
651
|
disabled: e.disabled,
|
|
581
652
|
onChange: (t) => {
|
|
582
653
|
let n = t.target;
|
|
583
654
|
e.setValue(n.checked);
|
|
584
655
|
}
|
|
585
|
-
}), n ?
|
|
656
|
+
}), n ? a("span", {
|
|
586
657
|
key: "description",
|
|
587
658
|
innerHTML: n
|
|
588
|
-
}) :
|
|
659
|
+
}) : a("span", { key: "description" }, e.field.label)]);
|
|
589
660
|
}
|
|
590
|
-
return
|
|
661
|
+
return w(n) ? J(e.field, e.value, e.disabled, e.setValue, e.errors, e.errorId) : a("div", { class: "formie-vue-unsupported" }, `Unsupported field type: ${String(e.field.meta?.fieldType ?? e.field.type)}`);
|
|
591
662
|
};
|
|
592
663
|
}
|
|
593
|
-
}),
|
|
664
|
+
}), se = i({
|
|
594
665
|
name: "FormieVueConfigPageActions",
|
|
595
666
|
setup() {
|
|
596
|
-
let e =
|
|
667
|
+
let e = A();
|
|
597
668
|
return () => {
|
|
598
669
|
let t = e.state.value, n = e.instance.value;
|
|
599
670
|
if (!t || !n) return null;
|
|
600
671
|
let r = t.definition.pages.find((e) => e.id === t.currentPageId);
|
|
601
672
|
if (!r) return null;
|
|
602
|
-
let
|
|
673
|
+
let i = [];
|
|
603
674
|
return r.actions.secondary.forEach((e) => {
|
|
604
|
-
|
|
675
|
+
i.push(a("button", {
|
|
605
676
|
key: e.type,
|
|
606
677
|
type: "button",
|
|
607
678
|
onClick: () => {
|
|
608
679
|
n.submit(e.type);
|
|
609
680
|
}
|
|
610
681
|
}, e.label));
|
|
611
|
-
}),
|
|
682
|
+
}), i.push(a("button", {
|
|
612
683
|
key: r.actions.primary.type,
|
|
613
|
-
type: "submit"
|
|
614
|
-
|
|
684
|
+
type: "submit",
|
|
685
|
+
disabled: !m(t)
|
|
686
|
+
}, r.actions.primary.label)), a("div", { class: "formie-page-actions" }, i);
|
|
615
687
|
};
|
|
616
688
|
}
|
|
617
|
-
}),
|
|
689
|
+
}), ce = i({
|
|
618
690
|
name: "FormieVueConfigRenderer",
|
|
619
691
|
props: { className: {
|
|
620
692
|
type: String,
|
|
621
693
|
default: void 0
|
|
622
694
|
} },
|
|
623
695
|
setup(e) {
|
|
624
|
-
let t =
|
|
696
|
+
let t = A();
|
|
625
697
|
return () => {
|
|
626
698
|
let n = t.instance.value, r = t.state.value;
|
|
627
699
|
if (!n || !r) return null;
|
|
628
|
-
let
|
|
629
|
-
return c ? i
|
|
700
|
+
let i = t.components.value.Form || R, o = t.components.value.Page || z, s = t.components.value.ErrorSummary || F, c = r.definition.pages.find((e) => e.id === r.currentPageId && r.pageStates[e.id]?.hidden !== !0) || r.definition.pages.find((e) => r.pageStates[e.id]?.hidden !== !0) || r.definition.pages[0], l = r.lastSubmitResult?.messages.error, u = !!l && !r.errors.form.includes(l);
|
|
701
|
+
return c ? a(i, {
|
|
630
702
|
definition: r.definition,
|
|
631
703
|
session: r.session,
|
|
632
704
|
state: r,
|
|
633
705
|
className: e.className,
|
|
634
|
-
onSubmit: () =>
|
|
635
|
-
n.submit();
|
|
636
|
-
}
|
|
706
|
+
onSubmit: () => n.submit()
|
|
637
707
|
}, { default: () => [
|
|
638
|
-
|
|
708
|
+
a(s, {
|
|
639
709
|
key: "errors",
|
|
640
710
|
errors: r.errors.form
|
|
641
711
|
}),
|
|
642
|
-
r.lastSubmitResult?.messages.notice ?
|
|
712
|
+
r.lastSubmitResult?.messages.notice ? a("div", {
|
|
643
713
|
key: "notice",
|
|
644
|
-
class: "formie-vue-notice"
|
|
645
|
-
|
|
646
|
-
|
|
714
|
+
class: "formie-vue-notice",
|
|
715
|
+
innerHTML: r.lastSubmitResult.messages.notice
|
|
716
|
+
}) : null,
|
|
717
|
+
u ? a("div", {
|
|
647
718
|
key: "error",
|
|
648
719
|
class: "formie-vue-error"
|
|
649
720
|
}, l) : null,
|
|
650
|
-
|
|
721
|
+
r.lastSubmitResult?.completion?.behavior === "message" && r.lastSubmitResult.completion.hideForm ? null : a(o, {
|
|
651
722
|
key: c.id,
|
|
652
723
|
page: c,
|
|
653
724
|
state: r
|
|
654
|
-
}, { default: () => [...c.rows.map((e, t) =>
|
|
725
|
+
}, { default: () => [...c.rows.map((e, t) => a(G, {
|
|
655
726
|
key: `${c.id}:${t}`,
|
|
656
727
|
row: e,
|
|
657
728
|
rowIndex: t
|
|
658
|
-
})),
|
|
729
|
+
})), a(se, { key: "actions" })] })
|
|
659
730
|
] }) : null;
|
|
660
731
|
};
|
|
661
732
|
}
|
|
662
|
-
}),
|
|
733
|
+
}), le = {
|
|
663
734
|
source: {
|
|
664
735
|
type: Object,
|
|
665
736
|
required: !0
|
|
@@ -721,12 +792,12 @@ var W = r({
|
|
|
721
792
|
default: void 0
|
|
722
793
|
}
|
|
723
794
|
};
|
|
724
|
-
function
|
|
795
|
+
function Y(e, t, ...n) {
|
|
725
796
|
e?.(...n), t && t !== e && t(...n);
|
|
726
797
|
}
|
|
727
|
-
var
|
|
798
|
+
var ue = i({
|
|
728
799
|
name: "FormieVueDefinitionFormView",
|
|
729
|
-
props:
|
|
800
|
+
props: le,
|
|
730
801
|
emits: [
|
|
731
802
|
"mount",
|
|
732
803
|
"ready",
|
|
@@ -740,44 +811,44 @@ var Y = r({
|
|
|
740
811
|
"event"
|
|
741
812
|
],
|
|
742
813
|
setup(e, { emit: t }) {
|
|
743
|
-
let
|
|
744
|
-
instance:
|
|
745
|
-
state:
|
|
746
|
-
components:
|
|
747
|
-
fieldComponents:
|
|
748
|
-
slots:
|
|
749
|
-
},
|
|
750
|
-
return
|
|
814
|
+
let n = d(null), i = d(null), o = u(null), s = {
|
|
815
|
+
instance: n,
|
|
816
|
+
state: i,
|
|
817
|
+
components: r(() => e.components || {}),
|
|
818
|
+
fieldComponents: r(() => e.fieldComponents || {}),
|
|
819
|
+
slots: r(() => e.slots || {})
|
|
820
|
+
}, c = r(() => D(e.source));
|
|
821
|
+
return l(O, s), f(c, (r, a, s) => {
|
|
751
822
|
let c = !1, l = () => void 0;
|
|
752
823
|
(async () => {
|
|
753
824
|
try {
|
|
754
|
-
let
|
|
755
|
-
envelope:
|
|
756
|
-
transport:
|
|
825
|
+
let r = await re(e.source), a = ie(e.source), s = g({
|
|
826
|
+
envelope: r,
|
|
827
|
+
transport: a
|
|
757
828
|
});
|
|
758
829
|
if (c) {
|
|
759
|
-
await
|
|
830
|
+
await s.destroy();
|
|
760
831
|
return;
|
|
761
832
|
}
|
|
762
|
-
o.value = null,
|
|
763
|
-
let
|
|
764
|
-
|
|
765
|
-
|
|
833
|
+
o.value = null, n.value = s, i.value = s.getState(), e.onMount?.(s), e.onReady?.(s), t("mount", s), t("ready", s);
|
|
834
|
+
let u = [
|
|
835
|
+
s.subscribe((e) => {
|
|
836
|
+
i.value = e;
|
|
766
837
|
}),
|
|
767
|
-
|
|
838
|
+
s.on("formie:submit:result", (n) => {
|
|
768
839
|
let r = n;
|
|
769
|
-
|
|
840
|
+
Y(e.onSubmitResult, e.onResult, r), t("result", r), t("submit-result", r), r.success ? (Y(e.onSubmitSuccess, e.onSuccess, r), t("success", r), t("submit-success", r)) : (Y(e.onSubmitError, e.onError, r), t("error", r), t("submit-error", r));
|
|
770
841
|
}),
|
|
771
|
-
...
|
|
842
|
+
...p.map((n) => s.on(n, (r) => {
|
|
772
843
|
let i = {
|
|
773
|
-
name:
|
|
774
|
-
payload:
|
|
844
|
+
name: n,
|
|
845
|
+
payload: r
|
|
775
846
|
};
|
|
776
847
|
e.onEvent?.(i), t("event", i);
|
|
777
848
|
}))
|
|
778
849
|
];
|
|
779
850
|
l = () => {
|
|
780
|
-
|
|
851
|
+
u.forEach((e) => e()), s.destroy(), n.value === s && (n.value = null, i.value = null), e.onUnmount?.(), t("unmount");
|
|
781
852
|
};
|
|
782
853
|
} catch (e) {
|
|
783
854
|
c || (o.value = e);
|
|
@@ -785,66 +856,67 @@ var Y = r({
|
|
|
785
856
|
})(), s(() => {
|
|
786
857
|
c = !0, l();
|
|
787
858
|
});
|
|
788
|
-
}, { immediate: !0 }), () => o.value ?
|
|
859
|
+
}, { immediate: !0 }), () => o.value ? a("div", { class: "formie-vue-error" }, o.value.message) : !n.value || !i.value ? a("div", { class: "formie-vue-loading" }, "Loading form...") : a(L, {}, { default: () => a(ce, { className: e.className }) });
|
|
789
860
|
}
|
|
790
861
|
});
|
|
791
|
-
function
|
|
792
|
-
let e =
|
|
862
|
+
function de() {
|
|
863
|
+
let e = A();
|
|
793
864
|
return {
|
|
794
|
-
definition:
|
|
795
|
-
session:
|
|
865
|
+
definition: r(() => e.state.value?.definition || null),
|
|
866
|
+
session: r(() => e.state.value?.session || null),
|
|
796
867
|
state: e.state,
|
|
797
868
|
instance: e.instance
|
|
798
869
|
};
|
|
799
870
|
}
|
|
800
|
-
function
|
|
801
|
-
let t =
|
|
871
|
+
function fe(e) {
|
|
872
|
+
let t = A(), n = r(() => {
|
|
802
873
|
let n = t.state.value?.definition;
|
|
803
|
-
return n &&
|
|
874
|
+
return n && ae(n).find((t) => t.id === e) || null;
|
|
804
875
|
});
|
|
805
876
|
return {
|
|
806
|
-
field:
|
|
807
|
-
value:
|
|
808
|
-
errors:
|
|
809
|
-
hidden:
|
|
810
|
-
disabled:
|
|
877
|
+
field: n,
|
|
878
|
+
value: r(() => t.state.value?.values[e]),
|
|
879
|
+
errors: r(() => t.state.value?.errors.fields[e] || []),
|
|
880
|
+
hidden: r(() => t.state.value?.fieldStates[e]?.hidden === !0),
|
|
881
|
+
disabled: r(() => t.state.value?.fieldStates[e]?.disabled === !0),
|
|
811
882
|
setValue(e) {
|
|
812
|
-
|
|
883
|
+
n.value && t.instance.value && t.instance.value.setValue(n.value.id, e);
|
|
813
884
|
}
|
|
814
885
|
};
|
|
815
886
|
}
|
|
816
|
-
function
|
|
817
|
-
let t =
|
|
887
|
+
function pe(e) {
|
|
888
|
+
let t = A();
|
|
818
889
|
return {
|
|
819
|
-
page:
|
|
820
|
-
isCurrent:
|
|
821
|
-
hidden:
|
|
890
|
+
page: r(() => t.state.value?.definition.pages.find((t) => t.id === e) || null),
|
|
891
|
+
isCurrent: r(() => t.state.value?.currentPageId === e),
|
|
892
|
+
hidden: r(() => t.state.value?.pageStates[e]?.hidden === !0)
|
|
822
893
|
};
|
|
823
894
|
}
|
|
824
|
-
function
|
|
825
|
-
return
|
|
895
|
+
function me() {
|
|
896
|
+
return A().instance;
|
|
826
897
|
}
|
|
827
|
-
function
|
|
828
|
-
let t =
|
|
829
|
-
return
|
|
898
|
+
function he(e) {
|
|
899
|
+
let t = A();
|
|
900
|
+
return r(() => t.slots.value[e] || null);
|
|
830
901
|
}
|
|
831
902
|
//#endregion
|
|
832
903
|
//#region src/index.ts
|
|
833
904
|
function X(e) {
|
|
834
905
|
return !!e && "payload" in e;
|
|
835
906
|
}
|
|
836
|
-
function
|
|
907
|
+
function Z(e) {
|
|
837
908
|
return "success" in e ? e.success : e.ok;
|
|
838
909
|
}
|
|
839
|
-
function
|
|
910
|
+
function Q(e, t, ...n) {
|
|
840
911
|
e?.(...n), t && t !== e && t(...n);
|
|
841
912
|
}
|
|
842
|
-
function
|
|
913
|
+
function ge(e) {
|
|
843
914
|
let t = e.transport;
|
|
844
915
|
if (!t && !X(e.source)) throw Error("`transport` is required for <FormieForm>.");
|
|
845
916
|
return {
|
|
846
917
|
mode: "server-rendered",
|
|
847
918
|
transport: t,
|
|
919
|
+
profile: e.profile,
|
|
848
920
|
endpoint: e.endpoint,
|
|
849
921
|
formHandle: e.formHandle,
|
|
850
922
|
payload: X(e.source) ? e.source.payload : void 0,
|
|
@@ -857,7 +929,7 @@ function de(e) {
|
|
|
857
929
|
themeConfig: e.themeConfig
|
|
858
930
|
};
|
|
859
931
|
}
|
|
860
|
-
function
|
|
932
|
+
function _e(e) {
|
|
861
933
|
if (e.source) return e.source;
|
|
862
934
|
let t = e.transport, n = e.endpoint, r = e.formHandle;
|
|
863
935
|
if (t !== "rest" && t !== "graphql") throw Error("Vue client-rendered forms require `transport=\"rest\"` or `transport=\"graphql\"`.");
|
|
@@ -866,18 +938,19 @@ function fe(e) {
|
|
|
866
938
|
transport: t,
|
|
867
939
|
endpoint: n,
|
|
868
940
|
formHandle: r,
|
|
869
|
-
siteId: e.siteId
|
|
941
|
+
siteId: e.siteId,
|
|
942
|
+
profile: e.profile
|
|
870
943
|
};
|
|
871
944
|
}
|
|
872
|
-
function
|
|
945
|
+
function ve() {
|
|
873
946
|
return t();
|
|
874
947
|
}
|
|
875
|
-
function
|
|
948
|
+
function $() {
|
|
876
949
|
return t();
|
|
877
950
|
}
|
|
878
|
-
function
|
|
879
|
-
let t =
|
|
880
|
-
return
|
|
951
|
+
function ye(e) {
|
|
952
|
+
let t = $(), n = u(null), i = d(null), a = u(null), o = r(() => D(e));
|
|
953
|
+
return f([n, o], ([n], r, o) => {
|
|
881
954
|
if (!n) return;
|
|
882
955
|
let s = !1, c = !1, l = async () => {
|
|
883
956
|
c || (c = !0, await t.unmount(n));
|
|
@@ -900,16 +973,16 @@ function $(e) {
|
|
|
900
973
|
s = !0, i.value = null, u.finally(l);
|
|
901
974
|
});
|
|
902
975
|
}, { immediate: !0 }), {
|
|
903
|
-
rootRef:
|
|
976
|
+
rootRef: n,
|
|
904
977
|
state: {
|
|
905
978
|
instance: i,
|
|
906
|
-
isMounted:
|
|
979
|
+
isMounted: r(() => !!i.value),
|
|
907
980
|
error: a
|
|
908
981
|
},
|
|
909
982
|
submit: async (e = "submit") => i.value ? i.value.submit(e) : null
|
|
910
983
|
};
|
|
911
984
|
}
|
|
912
|
-
var
|
|
985
|
+
var be = i({
|
|
913
986
|
name: "FormieVueHtmlFormView",
|
|
914
987
|
props: { options: {
|
|
915
988
|
type: Object,
|
|
@@ -927,44 +1000,48 @@ var me = r({
|
|
|
927
1000
|
"submit-error",
|
|
928
1001
|
"event"
|
|
929
1002
|
],
|
|
930
|
-
setup(
|
|
931
|
-
let o =
|
|
932
|
-
return
|
|
1003
|
+
setup(n, { emit: i }) {
|
|
1004
|
+
let o = u(null), s = t(), c = r(() => ge(n.options)), l = r(() => D(c.value));
|
|
1005
|
+
return f([o, l], ([t], r, a) => {
|
|
933
1006
|
if (!t) return;
|
|
934
1007
|
let o = !1, l = null, u = [], d = Promise.resolve().then(async () => {
|
|
935
|
-
let
|
|
1008
|
+
let r = await s.mount(t, c.value);
|
|
936
1009
|
if (o) {
|
|
937
1010
|
await s.unmount(t);
|
|
938
1011
|
return;
|
|
939
1012
|
}
|
|
940
|
-
l =
|
|
1013
|
+
l = r, n.options.onMount?.(r), n.options.onReady?.(r), i("mount", r), i("ready", r), u.push(r.on("formie:submit:result", (e) => {
|
|
941
1014
|
let t = e;
|
|
942
|
-
|
|
1015
|
+
Q(n.options.onSubmitResult, n.options.onResult, t), i("result", t), i("submit-result", t), Z(t) ? (Q(n.options.onSubmitSuccess, n.options.onSuccess, t), i("success", t), i("submit-success", t)) : (Q(n.options.onSubmitError, n.options.onError, t), i("error", t), i("submit-error", t));
|
|
943
1016
|
})), e.forEach((e) => {
|
|
944
|
-
u.push(
|
|
945
|
-
let
|
|
1017
|
+
u.push(r.on(e, (t) => {
|
|
1018
|
+
let r = {
|
|
946
1019
|
name: e,
|
|
947
1020
|
payload: t
|
|
948
1021
|
};
|
|
949
|
-
|
|
1022
|
+
n.options.onEvent?.(r), i("event", r);
|
|
950
1023
|
}));
|
|
951
1024
|
});
|
|
952
1025
|
});
|
|
953
|
-
|
|
1026
|
+
a(() => {
|
|
954
1027
|
o = !0, u.forEach((e) => e()), d.finally(async () => {
|
|
955
|
-
await s.unmount(t), l &&= (
|
|
1028
|
+
await s.unmount(t), l &&= (n.options.onUnmount?.(), i("unmount"), null);
|
|
956
1029
|
});
|
|
957
1030
|
});
|
|
958
|
-
}, { immediate: !0 }), () =>
|
|
1031
|
+
}, { immediate: !0 }), () => a("div", {
|
|
959
1032
|
ref: o,
|
|
960
|
-
class:
|
|
1033
|
+
class: n.options.className
|
|
961
1034
|
});
|
|
962
1035
|
}
|
|
963
|
-
}),
|
|
1036
|
+
}), xe = {
|
|
964
1037
|
source: {
|
|
965
1038
|
type: Object,
|
|
966
1039
|
default: void 0
|
|
967
1040
|
},
|
|
1041
|
+
profile: {
|
|
1042
|
+
type: String,
|
|
1043
|
+
default: "same-origin-browser"
|
|
1044
|
+
},
|
|
968
1045
|
transport: {
|
|
969
1046
|
type: String,
|
|
970
1047
|
default: void 0
|
|
@@ -1049,11 +1126,15 @@ var me = r({
|
|
|
1049
1126
|
type: Function,
|
|
1050
1127
|
default: void 0
|
|
1051
1128
|
}
|
|
1052
|
-
},
|
|
1129
|
+
}, Se = {
|
|
1053
1130
|
source: {
|
|
1054
1131
|
type: Object,
|
|
1055
1132
|
default: void 0
|
|
1056
1133
|
},
|
|
1134
|
+
profile: {
|
|
1135
|
+
type: String,
|
|
1136
|
+
default: "same-origin-browser"
|
|
1137
|
+
},
|
|
1057
1138
|
transport: {
|
|
1058
1139
|
type: String,
|
|
1059
1140
|
default: void 0
|
|
@@ -1126,9 +1207,9 @@ var me = r({
|
|
|
1126
1207
|
type: Function,
|
|
1127
1208
|
default: void 0
|
|
1128
1209
|
}
|
|
1129
|
-
},
|
|
1210
|
+
}, Ce = i({
|
|
1130
1211
|
name: "FormieVueForm",
|
|
1131
|
-
props:
|
|
1212
|
+
props: xe,
|
|
1132
1213
|
emits: [
|
|
1133
1214
|
"mount",
|
|
1134
1215
|
"ready",
|
|
@@ -1142,9 +1223,10 @@ var me = r({
|
|
|
1142
1223
|
"event"
|
|
1143
1224
|
],
|
|
1144
1225
|
setup(e, { emit: t }) {
|
|
1145
|
-
return () =>
|
|
1146
|
-
|
|
1226
|
+
return () => {
|
|
1227
|
+
let n = {
|
|
1147
1228
|
source: e.source,
|
|
1229
|
+
profile: e.profile,
|
|
1148
1230
|
transport: e.transport,
|
|
1149
1231
|
endpoint: e.endpoint,
|
|
1150
1232
|
formHandle: e.formHandle,
|
|
@@ -1166,22 +1248,25 @@ var me = r({
|
|
|
1166
1248
|
onSubmitSuccess: e.onSubmitSuccess,
|
|
1167
1249
|
onSubmitError: e.onSubmitError,
|
|
1168
1250
|
onEvent: e.onEvent
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1251
|
+
};
|
|
1252
|
+
return a(be, {
|
|
1253
|
+
options: n,
|
|
1254
|
+
onMount: (e) => t("mount", e),
|
|
1255
|
+
onReady: (e) => t("ready", e),
|
|
1256
|
+
onUnmount: () => t("unmount"),
|
|
1257
|
+
onResult: (e) => t("result", e),
|
|
1258
|
+
onSuccess: (e) => t("success", e),
|
|
1259
|
+
onError: (e) => t("error", e),
|
|
1260
|
+
onSubmitResult: (e) => t("submit-result", e),
|
|
1261
|
+
onSubmitSuccess: (e) => t("submit-success", e),
|
|
1262
|
+
onSubmitError: (e) => t("submit-error", e),
|
|
1263
|
+
onEvent: (e) => t("event", e)
|
|
1264
|
+
});
|
|
1265
|
+
};
|
|
1181
1266
|
}
|
|
1182
|
-
}),
|
|
1267
|
+
}), we = i({
|
|
1183
1268
|
name: "FormieVueClientForm",
|
|
1184
|
-
props:
|
|
1269
|
+
props: Se,
|
|
1185
1270
|
emits: [
|
|
1186
1271
|
"mount",
|
|
1187
1272
|
"ready",
|
|
@@ -1195,9 +1280,10 @@ var me = r({
|
|
|
1195
1280
|
"event"
|
|
1196
1281
|
],
|
|
1197
1282
|
setup(e, { emit: t }) {
|
|
1198
|
-
return () =>
|
|
1199
|
-
source:
|
|
1283
|
+
return () => a(ue, {
|
|
1284
|
+
source: _e({
|
|
1200
1285
|
source: e.source,
|
|
1286
|
+
profile: e.profile,
|
|
1201
1287
|
transport: e.transport,
|
|
1202
1288
|
endpoint: e.endpoint,
|
|
1203
1289
|
formHandle: e.formHandle,
|
|
@@ -1246,4 +1332,4 @@ var me = r({
|
|
|
1246
1332
|
}
|
|
1247
1333
|
});
|
|
1248
1334
|
//#endregion
|
|
1249
|
-
export {
|
|
1335
|
+
export { we as FormieClientForm, Ce as FormieForm, ve as createVueFormieClient, de as useFormie, $ as useFormieClient, fe as useFormieField, ye as useFormieHtml, me as useFormieInstance, pe as useFormiePage, he as useFormieSlot };
|