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