@verbb/formie-browser 1.0.11 → 1.0.13
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 +15 -0
- package/dist/chunks/{api-BYe9YPko.js → api-DqpfkZWL.js} +15 -2
- package/dist/chunks/{bpoint-C0VOftX9.js → bpoint-Dlq34XH1.js} +1 -1
- package/dist/chunks/{calculations-DERi2xaC.js → calculations-Dv3hYb8_.js} +1 -1
- package/dist/chunks/{conditions-65kBcFWW.js → conditions-CPH1snCx.js} +1 -1
- package/dist/chunks/{date-picker-5CA_-zGb.js → date-picker-F9BUBDSW.js} +3 -0
- package/dist/chunks/{dist-BdUy8m_p.js → dist-D6i-VNgM.js} +1 -1
- package/dist/chunks/{eway-CS6Y1Yvo.js → eway-D9_m8ooj.js} +1 -1
- package/dist/chunks/{go-cardless-BTPD668l.js → go-cardless-DAT3ZaQf.js} +1 -1
- package/dist/chunks/{mollie-CXgBwvo6.js → mollie-Bibhl67p.js} +1 -1
- package/dist/chunks/{moneris-B6oLu7nj.js → moneris-H2wSqk9h.js} +1 -1
- package/dist/chunks/opayo-CR0DtsLa.js +179 -0
- package/dist/chunks/{paddle-GRlsm5mm.js → paddle-DkvIxQdG.js} +1 -1
- package/dist/chunks/{password-validation-T0vDQPCr.js → password-validation-D06uH9va.js} +1 -1
- package/dist/chunks/{paypal-CdcZnf6r.js → paypal-CQpAF7Ua.js} +32 -31
- package/dist/chunks/{payway-CfmYOS__.js → payway-CwDkC7YZ.js} +1 -1
- package/dist/chunks/{signature-xz4QO7CR.js → signature-IOhuicje.js} +69 -47
- package/dist/chunks/{square-BY--5M-X.js → square-DwdcOI1G.js} +1 -1
- package/dist/chunks/{stripe-uusYjWty.js → stripe-DaoG2FT1.js} +1 -1
- package/dist/chunks/{text-limit-Bn18WrPU.js → text-limit-BGaY0jhI.js} +1 -1
- package/dist/css/theme/fields/_check-radio.css +3 -1
- package/dist/css/theme/fields/_signature.css +2 -1
- package/dist/css/theme/integrations/_opayo.css +9 -0
- package/dist/index.js +21 -19
- package/dist/js/core/create-formie-client.d.ts.map +1 -1
- package/dist/js/modules/fields/date-picker.d.ts.map +1 -1
- package/dist/js/modules/fields/signature.d.ts.map +1 -1
- package/dist/js/modules/payments/factories.d.ts +5 -1
- package/dist/js/modules/payments/factories.d.ts.map +1 -1
- package/dist/js/modules/payments/opayo.d.ts +17 -2
- package/dist/js/modules/payments/opayo.d.ts.map +1 -1
- package/dist/js/modules/payments/paypal.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/css/theme/fields/_check-radio.css +3 -1
- package/src/css/theme/fields/_signature.css +2 -1
- package/src/css/theme/integrations/_opayo.css +9 -0
- package/src/js/core/create-formie-client.ts +7 -0
- package/src/js/modules/fields/date-picker.ts +6 -0
- package/src/js/modules/fields/signature.ts +40 -2
- package/src/js/modules/payments/factories.ts +27 -2
- package/src/js/modules/payments/opayo.ts +256 -69
- package/src/js/modules/payments/paypal.ts +23 -3
- package/dist/chunks/opayo-DPUA5CKr.js +0 -113
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 1.0.13 - 2026-07-09
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- Fix Signature field canvas height preserving the stored PNG aspect ratio when restoring values or resizing, so signatures are not vertically stretched.
|
|
9
|
+
- Fix Date/Time calendar fields not using an existing input value as the Flatpickr default date on init.
|
|
10
|
+
- Fix false unload warnings after front-end form init by resetting dirty state once captcha/token hydration and field modules have settled.
|
|
11
|
+
|
|
12
|
+
## 1.0.12 - 2026-07-02
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- Add Opayo **Drop-in Checkout** support to the `opayo` payment module via `sagepayCheckout`, including iframe mount on field init, `tokenise()` on authorize, and merchant session key refresh on tokenisation failure. **Own Form** mode continues to use `sagepayOwnForm`.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
- Hide PayPal buttons after successful authorization so users are not prompted to pay again before submitting the form. Buttons are restored automatically when authorization is cleared after a failed submit.
|
|
19
|
+
|
|
5
20
|
## 1.0.11 - 2026-06-26
|
|
6
21
|
|
|
7
22
|
### Added
|
|
@@ -810,13 +810,26 @@ function Ie(e) {
|
|
|
810
810
|
}), t.abort(o.transport.errorMessage));
|
|
811
811
|
},
|
|
812
812
|
onAfterStage: async (t, r) => {
|
|
813
|
-
t.stage !== "dispatch" || !e.onAfterSubmit
|
|
813
|
+
if (!(t.stage !== "dispatch" || !e.onAfterSubmit) && !(!(await e.onAfterSubmit({
|
|
814
814
|
field: n.target,
|
|
815
815
|
services: s,
|
|
816
816
|
options: o,
|
|
817
817
|
provider: o.provider,
|
|
818
818
|
result: r
|
|
819
|
-
})
|
|
819
|
+
}))?.remount || !e.mount)) {
|
|
820
|
+
if (d && e.unmount) {
|
|
821
|
+
let t = await m();
|
|
822
|
+
await e.unmount({
|
|
823
|
+
api: t,
|
|
824
|
+
widget: d,
|
|
825
|
+
field: n.target,
|
|
826
|
+
services: s,
|
|
827
|
+
options: o,
|
|
828
|
+
provider: o.provider
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
d = null, await h();
|
|
832
|
+
}
|
|
820
833
|
}
|
|
821
834
|
};
|
|
822
835
|
}
|
|
@@ -2,7 +2,7 @@ import { t as e } from "./debug-BV0DvdHx.js";
|
|
|
2
2
|
import { r as t, t as n } from "./field-references.keys-58ZSTrCW.js";
|
|
3
3
|
import { n as r, r as i } from "./field-references.resolver-CHwn0G0L.js";
|
|
4
4
|
import { r as a, t as o } from "./shared-Bx9s0i0P.js";
|
|
5
|
-
import { c as s, i as c, r as l, s as u, t as d } from "./dist-
|
|
5
|
+
import { c as s, i as c, r as l, s as u, t as d } from "./dist-D6i-VNgM.js";
|
|
6
6
|
//#region src/js/utils/field-references.row-scope.ts
|
|
7
7
|
var f = new Set([
|
|
8
8
|
"first",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as e } from "./debug-BV0DvdHx.js";
|
|
2
2
|
import { t } from "./field-references.keys-58ZSTrCW.js";
|
|
3
3
|
import { n } from "./shared-Bx9s0i0P.js";
|
|
4
|
-
import { a as r, o as i } from "./dist-
|
|
4
|
+
import { a as r, o as i } from "./dist-D6i-VNgM.js";
|
|
5
5
|
//#region src/js/modules/fields/conditions/config.ts
|
|
6
6
|
var a = "[data-formie-conditions]";
|
|
7
7
|
function o(e) {
|
|
@@ -5269,6 +5269,9 @@ function H(e, t) {
|
|
|
5269
5269
|
s.mode = "range";
|
|
5270
5270
|
let e = i instanceof HTMLInputElement && i.value ? V(i.value) : null, t = o instanceof HTMLInputElement && o.value ? V(o.value) : null;
|
|
5271
5271
|
e && (s.defaultDate = t ? [e, t] : [e]);
|
|
5272
|
+
} else if (e.value) {
|
|
5273
|
+
let t = V(e.value);
|
|
5274
|
+
t && (s.defaultDate = t);
|
|
5272
5275
|
}
|
|
5273
5276
|
let l = {
|
|
5274
5277
|
...s,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region
|
|
1
|
+
//#region node_modules/@verbb/formie-core/dist/index.js
|
|
2
2
|
var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, i, o, s) => {
|
|
3
3
|
if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
|
|
4
4
|
get: ((e) => i[e]).bind(null, d),
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { s as e } from "./event-names-BCI2FLD8.js";
|
|
2
|
+
import { t } from "./api-DqpfkZWL.js";
|
|
3
|
+
import { t as n } from "./debug-BV0DvdHx.js";
|
|
4
|
+
import { r } from "./scripts-CbQ7agX3.js";
|
|
5
|
+
import { t as i } from "./styles-BfoIZwJp.js";
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/js/modules/payments/opayo.ts
|
|
8
|
+
i("opayo", ["@layer formie-theme{.formie-opayo-drop-in{box-sizing:border-box;width:100%;min-height:10rem}}"]);
|
|
9
|
+
var a = "FORMIE_OPAYO_SCRIPT", o = "https://live.opayo.eu.elavon.com/api/v1/js/sagepay.js", s = "https://sandbox.opayo.eu.elavon.com/api/v1/js/sagepay.js", c = "[data-formie-opayo-drop-in]", l = n("payments", "opayo"), u = e("opayo", "challenge"), d = "formie:payment:opayo:challenge:response";
|
|
10
|
+
function f(e) {
|
|
11
|
+
return e.checkoutMode === "dropIn";
|
|
12
|
+
}
|
|
13
|
+
async function p(e) {
|
|
14
|
+
let { form: t, handle: n, sessionToken: r, services: i } = e, a = new FormData();
|
|
15
|
+
a.append("action", "formie/payment-webhooks/process-callback"), a.append("merchantSessionKey", "true"), a.append("handle", n), a.append("sessionToken", r);
|
|
16
|
+
try {
|
|
17
|
+
let e = await fetch(t.action, {
|
|
18
|
+
method: "POST",
|
|
19
|
+
body: a
|
|
20
|
+
});
|
|
21
|
+
return e.status < 200 || e.status >= 300 ? (i.addError(`${e.status}: ${e.statusText}`), l.warn("Merchant session request failed.", {
|
|
22
|
+
status: e.status,
|
|
23
|
+
statusText: e.statusText
|
|
24
|
+
}), null) : (await e.json()).merchantSessionKey || (i.addError("Unable to get merchant session."), l.warn("merchantSessionKey missing in callback response."), null);
|
|
25
|
+
} catch {
|
|
26
|
+
return i.addError("Network error. Please try again."), l.warn("Network error requesting merchant session."), null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function m(e) {
|
|
30
|
+
return e.id ||= `formie-opayo-drop-in-${Math.random().toString(36).slice(2, 9)}`, e.id;
|
|
31
|
+
}
|
|
32
|
+
var h = t({
|
|
33
|
+
id: "opayo",
|
|
34
|
+
defaultRequiredInputSuffixes: ["opayoTokenId"],
|
|
35
|
+
load: async (e) => {
|
|
36
|
+
let { provider: t } = e.options, n = t.useSandbox ? s : o;
|
|
37
|
+
return await r(f(t) ? "sagepayCheckout" : "sagepayOwnForm", {
|
|
38
|
+
id: a,
|
|
39
|
+
src: n,
|
|
40
|
+
timeoutMs: 1e4
|
|
41
|
+
}), null;
|
|
42
|
+
},
|
|
43
|
+
mount: async ({ field: e, services: t, provider: n }) => {
|
|
44
|
+
if (!f(n)) return null;
|
|
45
|
+
let r = t.form, i = window.sagepayCheckout, a = e.querySelector(c);
|
|
46
|
+
if (!r?.action) return t.addError("Form action is missing."), l.warn("Missing form action before drop-in mount."), null;
|
|
47
|
+
if (!i) return t.addError("Opayo script failed to load."), l.warn("sagepayCheckout global not available."), null;
|
|
48
|
+
if (!a) return t.addError("Opayo drop-in container is missing."), l.warn("Drop-in container not found in payment field."), null;
|
|
49
|
+
let o = n.handle || "opayo", s = await p({
|
|
50
|
+
form: r,
|
|
51
|
+
handle: o,
|
|
52
|
+
sessionToken: n.sessionToken || "",
|
|
53
|
+
services: t
|
|
54
|
+
});
|
|
55
|
+
if (!s) return null;
|
|
56
|
+
let u = m(a), d = {
|
|
57
|
+
checkout: null,
|
|
58
|
+
merchantSessionKey: s,
|
|
59
|
+
pendingAuthorize: null,
|
|
60
|
+
retriedTokenise: !1
|
|
61
|
+
};
|
|
62
|
+
return d.checkout = i({
|
|
63
|
+
merchantSessionKey: s,
|
|
64
|
+
containerSelector: `#${u}`,
|
|
65
|
+
onTokenise: (e) => {
|
|
66
|
+
let i = d.pendingAuthorize;
|
|
67
|
+
if (d.pendingAuthorize = null, !i) {
|
|
68
|
+
l.warn("Drop-in tokenisation completed without a pending authorize step.");
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (e.success && e.cardIdentifier) {
|
|
72
|
+
t.updateInputs("opayoTokenId", e.cardIdentifier), t.updateInputs("opayoSessionKey", d.merchantSessionKey), l.log("Drop-in tokenization succeeded.", { hasCardIdentifier: !!e.cardIdentifier }), i(!0);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (!d.retriedTokenise) {
|
|
76
|
+
d.retriedTokenise = !0, p({
|
|
77
|
+
form: r,
|
|
78
|
+
handle: o,
|
|
79
|
+
sessionToken: n.sessionToken || "",
|
|
80
|
+
services: t
|
|
81
|
+
}).then((n) => {
|
|
82
|
+
if (!n) {
|
|
83
|
+
t.addError(e.errors?.[0]?.message || "Tokenization failed."), l.warn("Drop-in tokenization failed after session refresh.", e), i(!1);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
d.merchantSessionKey = n, d.pendingAuthorize = i, d.checkout.tokenise({ newMerchantSessionKey: n });
|
|
87
|
+
});
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
t.addError(e.errors?.[0]?.message || "Tokenization failed."), l.warn("Drop-in tokenization failed.", e), i(!1);
|
|
91
|
+
}
|
|
92
|
+
}), l.log("Drop-in checkout mounted.", { containerId: u }), d;
|
|
93
|
+
},
|
|
94
|
+
unmount: async ({ widget: e }) => {
|
|
95
|
+
e?.checkout?.destroy?.();
|
|
96
|
+
},
|
|
97
|
+
onBeforeAuthorize: async (e) => {
|
|
98
|
+
let { field: t, services: n, options: r, provider: i, widget: a } = e, o = i.handle || "opayo", s = n.form;
|
|
99
|
+
if (!s?.action) return n.addError("Form action is missing."), l.warn("Missing form action before authorize."), !1;
|
|
100
|
+
if (f(i)) return a ? (a.retriedTokenise = !1, new Promise((e) => {
|
|
101
|
+
a.pendingAuthorize = e, a.checkout.tokenise();
|
|
102
|
+
})) : (n.addError("Opayo drop-in checkout is not ready."), l.warn("Drop-in authorize requested before widget mount."), !1);
|
|
103
|
+
let c = window.sagepayOwnForm;
|
|
104
|
+
if (!c) return n.addError("Opayo script failed to load."), l.warn("sagepayOwnForm global not available."), !1;
|
|
105
|
+
let u = t.querySelector("[data-opayo-card=\"cardholder-name\"]")?.value ?? "", d = t.querySelector("[data-opayo-card=\"card-number\"]")?.value ?? "", m = t.querySelector("[data-opayo-card=\"expiry-date\"]")?.value ?? "", h = t.querySelector("[data-opayo-card=\"security-code\"]")?.value ?? "";
|
|
106
|
+
d = d.replace(/[\s/]/g, ""), m = m.replace(/[\s/]/g, "");
|
|
107
|
+
let g = await p({
|
|
108
|
+
form: s,
|
|
109
|
+
handle: o,
|
|
110
|
+
sessionToken: i.sessionToken || "",
|
|
111
|
+
services: n
|
|
112
|
+
});
|
|
113
|
+
return g ? new Promise((e) => {
|
|
114
|
+
c({ merchantSessionKey: g }).tokeniseCardDetails({
|
|
115
|
+
cardDetails: {
|
|
116
|
+
cardholderName: u,
|
|
117
|
+
cardNumber: d,
|
|
118
|
+
expiryDate: m,
|
|
119
|
+
securityCode: h
|
|
120
|
+
},
|
|
121
|
+
onTokenised: (t) => {
|
|
122
|
+
t.success && t.cardIdentifier ? (n.updateInputs("opayoTokenId", t.cardIdentifier), n.updateInputs("opayoSessionKey", g), l.log("Tokenization succeeded.", { hasCardIdentifier: !!t.cardIdentifier }), e(!0)) : (n.addError(t.errors?.[0]?.message || "Tokenization failed."), l.warn("Tokenization failed.", t), e(!1));
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}) : !1;
|
|
126
|
+
},
|
|
127
|
+
setup: async (e) => {
|
|
128
|
+
let { services: t } = e;
|
|
129
|
+
e.target;
|
|
130
|
+
let n = null, r = !1, i = () => {
|
|
131
|
+
n?.parentNode && n.parentNode.removeChild(n), n = null;
|
|
132
|
+
}, a = t.events.onForm(u, ((e) => {
|
|
133
|
+
let a = e.detail?.data;
|
|
134
|
+
if (!a?.acsUrl || !a?.creq) return;
|
|
135
|
+
r = !1, l.log("Received payment challenge event.", {
|
|
136
|
+
hasAcsUrl: !!a.acsUrl,
|
|
137
|
+
hasCreq: !!a.creq
|
|
138
|
+
});
|
|
139
|
+
let o = t.form?.querySelector("input[name*=\"opayoSessionKey\"]")?.value || "", s = document.createElement("div");
|
|
140
|
+
s.className = "formie-modal", s.id = `formie-opayo-dialog-${Math.random().toString(36).slice(2, 9)}`, s.innerHTML = "\n <div class=\"formie-modal-backdrop\" data-dialog-close></div>\n <div class=\"formie-modal-content\">\n <div class=\"formie-loading formie-loading-large\" style=\"--formie-loading-width: 3rem; --formie-loading-height: 3rem; top: 50%; margin-top: -1.5rem;\"></div>\n <iframe width=\"100%\" height=\"100%\" style=\"width: 100%; height: 100%; position: relative; z-index: 1;\"></iframe>\n </div>\n ";
|
|
141
|
+
let c = s.querySelector("iframe"), u = (e) => e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<"), d = a.returnUrl || a.redirectUrl || "", f = `<form action="${u(a.acsUrl)}" method="post">
|
|
142
|
+
<input type="hidden" name="creq" value="${u(a.creq || "")}" />
|
|
143
|
+
<input type="hidden" name="threeDSSessionData" value="${u(a.threeDSSessionData || "")}" />
|
|
144
|
+
<input type="hidden" name="MD" value="${u(o)}" />
|
|
145
|
+
<input type="hidden" name="TermUrl" value="${u(d)}" />
|
|
146
|
+
<input type="hidden" name="ThreeDSNotificationURL" value="${u(d)}" />
|
|
147
|
+
</form><script>document.forms[0].submit();<\/script>`;
|
|
148
|
+
i(), document.body.appendChild(s), n = s, c?.contentWindow && (c.contentWindow.document.open(), c.contentWindow.document.write(f), c.contentWindow.document.close());
|
|
149
|
+
})), o = (e) => {
|
|
150
|
+
if (e.data?.message === d) {
|
|
151
|
+
if (!n) {
|
|
152
|
+
l.log("Ignoring 3DS response without active dialog.");
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (r) {
|
|
156
|
+
l.warn("Ignoring duplicate 3DS response while processing.");
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (r = !0, l.log("Received payment challenge response message.", e.data?.value), i(), t.removeError(), e.data?.value?.error) {
|
|
160
|
+
t.addError(e.data.value.error.message), t.releaseSubmitLoading(), r = !1;
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
t.updateInputs("opayo3DSComplete", e.data.value?.transactionId ?? ""), t.triggerSubmit();
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
return window.addEventListener("message", o), { destroy: () => {
|
|
167
|
+
a(), window.removeEventListener("message", o), i(), r = !1;
|
|
168
|
+
} };
|
|
169
|
+
},
|
|
170
|
+
onAfterSubmit: async ({ services: e }) => {
|
|
171
|
+
e.updateInputs([
|
|
172
|
+
"opayoTokenId",
|
|
173
|
+
"opayoSessionKey",
|
|
174
|
+
"opayo3DSComplete"
|
|
175
|
+
], "");
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
//#endregion
|
|
179
|
+
export { h as opayoModule };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { s as e } from "./event-names-BCI2FLD8.js";
|
|
2
|
-
import { t } from "./api-
|
|
2
|
+
import { t } from "./api-DqpfkZWL.js";
|
|
3
3
|
import { r as n } from "./scripts-CbQ7agX3.js";
|
|
4
4
|
//#region src/js/modules/payments/paddle.ts
|
|
5
5
|
var r = "FORMIE_PADDLE_SCRIPT", i = e("paddle", "initialize"), a = t({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as e, i as t, l as n } from "./shared-Bx9s0i0P.js";
|
|
2
|
-
import { n as r } from "./dist-
|
|
2
|
+
import { n as r } from "./dist-D6i-VNgM.js";
|
|
3
3
|
//#region src/js/modules/fields/password-validation.ts
|
|
4
4
|
var i = "input[data-formie-password-input]", a = [
|
|
5
5
|
"passwordMinLength",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./api-
|
|
1
|
+
import { t as e } from "./api-DqpfkZWL.js";
|
|
2
2
|
import { r as t } from "./scripts-CbQ7agX3.js";
|
|
3
3
|
import { t as n } from "./styles-BfoIZwJp.js";
|
|
4
4
|
//#endregion
|
|
@@ -11,49 +11,52 @@ function i(e) {
|
|
|
11
11
|
return String(n[0]?.id || r[0]?.id || "").trim();
|
|
12
12
|
}
|
|
13
13
|
function a(e, t) {
|
|
14
|
+
e?.close && e.close(), t.removeAttribute("data-formie-paypal-rendered"), t.innerHTML = "";
|
|
15
|
+
}
|
|
16
|
+
function o(e, t) {
|
|
14
17
|
return `https://www.paypal.com/sdk/js?${[
|
|
15
18
|
"intent=authorize",
|
|
16
19
|
`currency=${encodeURIComponent(t)}`,
|
|
17
20
|
`client-id=${encodeURIComponent(e)}`
|
|
18
21
|
].join("&")}`;
|
|
19
22
|
}
|
|
20
|
-
var
|
|
23
|
+
var s = e({
|
|
21
24
|
id: "paypal",
|
|
22
25
|
defaultRequiredInputSuffixes: ["paypalOrderId", "paypalAuthId"],
|
|
23
26
|
load: async (e) => {
|
|
24
27
|
let { provider: n } = e.options, i = n.clientId;
|
|
25
28
|
return i?.trim() ? (await t("paypal", {
|
|
26
29
|
id: r,
|
|
27
|
-
src:
|
|
30
|
+
src: o(i, n.currency || "AUD")
|
|
28
31
|
}), window.paypal) : (console.error("[formie] Missing clientId for PayPal."), null);
|
|
29
32
|
},
|
|
30
33
|
mount: async (e) => {
|
|
31
|
-
let { api: t, field: n, services: r, options:
|
|
32
|
-
if (!
|
|
33
|
-
|
|
34
|
-
let
|
|
35
|
-
value:
|
|
34
|
+
let { api: t, field: n, services: r, options: o, provider: s } = e, c = n.querySelector("[data-formie-paypal-button]");
|
|
35
|
+
if (!c || !t || c.getAttribute("data-formie-paypal-rendered") === "true") return null;
|
|
36
|
+
c.innerHTML = "";
|
|
37
|
+
let l = !!s.useSandbox, u = r.resolveCurrency({
|
|
38
|
+
value: s.currency,
|
|
36
39
|
defaultCurrency: "AUD"
|
|
37
40
|
});
|
|
38
|
-
if (!
|
|
39
|
-
let
|
|
40
|
-
layout:
|
|
41
|
-
color:
|
|
42
|
-
shape:
|
|
43
|
-
label:
|
|
44
|
-
width:
|
|
45
|
-
height:
|
|
41
|
+
if (!u.ok) return r.addError("error" in u ? u.error : "Invalid PayPal currency."), null;
|
|
42
|
+
let d = u.value, f = {
|
|
43
|
+
layout: s.buttonLayout || "vertical",
|
|
44
|
+
color: s.buttonColor || "gold",
|
|
45
|
+
shape: s.buttonShape || "rect",
|
|
46
|
+
label: s.buttonLabel || "paypal",
|
|
47
|
+
width: s.buttonWidth || 250,
|
|
48
|
+
height: s.buttonHeight || 35
|
|
46
49
|
};
|
|
47
|
-
|
|
48
|
-
let
|
|
49
|
-
env:
|
|
50
|
-
style:
|
|
50
|
+
f.layout === "horizontal" && (f.tagline = s.buttonTagline ?? !0);
|
|
51
|
+
let p = null, m = {
|
|
52
|
+
env: l ? "sandbox" : "production",
|
|
53
|
+
style: f,
|
|
51
54
|
createOrder: (e, t) => {
|
|
52
55
|
r.removeError();
|
|
53
56
|
let n = r.resolveAmount({
|
|
54
|
-
type:
|
|
55
|
-
fixed:
|
|
56
|
-
variable:
|
|
57
|
+
type: s.amountType,
|
|
58
|
+
fixed: s.amountFixed,
|
|
59
|
+
variable: s.amountVariable
|
|
57
60
|
});
|
|
58
61
|
if (!n.ok) {
|
|
59
62
|
let e = "error" in n ? n.error : "Invalid PayPal amount.";
|
|
@@ -63,7 +66,7 @@ var o = e({
|
|
|
63
66
|
intent: "AUTHORIZE",
|
|
64
67
|
application_context: { user_action: "CONTINUE" },
|
|
65
68
|
purchase_units: [{ amount: {
|
|
66
|
-
currency_code:
|
|
69
|
+
currency_code: d,
|
|
67
70
|
value: String(n.value)
|
|
68
71
|
} }]
|
|
69
72
|
});
|
|
@@ -74,22 +77,20 @@ var o = e({
|
|
|
74
77
|
onApprove: async (e, t) => {
|
|
75
78
|
try {
|
|
76
79
|
let n = i(await t.order.authorize());
|
|
77
|
-
r.updateInputs("paypalOrderId", e.orderID), r.updateInputs("paypalAuthId", n || ""), n ? r.addSuccess("Payment authorized. Finalize the form to complete payment.") : r.addSuccess("PayPal approval received. Finalizing payment on submit.");
|
|
80
|
+
r.updateInputs("paypalOrderId", e.orderID), r.updateInputs("paypalAuthId", n || ""), n ? r.addSuccess("Payment authorized. Finalize the form to complete payment.") : r.addSuccess("PayPal approval received. Finalizing payment on submit."), a(p, c);
|
|
78
81
|
} catch {
|
|
79
82
|
r.addError("Unable to authorize payment. Please try again.");
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
|
-
},
|
|
83
|
-
return
|
|
85
|
+
}, h = t.Buttons(m);
|
|
86
|
+
return c.setAttribute("data-formie-paypal-rendered", "true"), p = h.render(c), p;
|
|
84
87
|
},
|
|
85
88
|
unmount: async (e) => {
|
|
86
89
|
e.widget?.close && e.widget.close();
|
|
87
90
|
let t = e.field.querySelector("[data-formie-paypal-button]");
|
|
88
91
|
t && (t.removeAttribute("data-formie-paypal-rendered"), t.innerHTML = "");
|
|
89
92
|
},
|
|
90
|
-
onAfterSubmit: async ({ services: e }) => {
|
|
91
|
-
e.updateInputs(["paypalOrderId", "paypalAuthId"], ""), e.removeSuccess(), e.removeError();
|
|
92
|
-
}
|
|
93
|
+
onAfterSubmit: async ({ services: e, result: t }) => (e.updateInputs(["paypalOrderId", "paypalAuthId"], ""), e.removeSuccess(), e.removeError(), !t?.ok || t?.nextPage ? { remount: !0 } : {})
|
|
93
94
|
});
|
|
94
95
|
//#endregion
|
|
95
|
-
export {
|
|
96
|
+
export { s as paypalModule };
|
|
@@ -386,7 +386,7 @@ var s = class e extends a {
|
|
|
386
386
|
a.setAttribute("r", s.toString()), a.setAttribute("cx", e.x.toString()), a.setAttribute("cy", e.y.toString()), a.setAttribute("fill", t), o.appendChild(a);
|
|
387
387
|
}), o.outerHTML;
|
|
388
388
|
}
|
|
389
|
-
}, c = "@layer formie-theme{[data-formie-field-type=signature] .formie-field-control{transition:border-color .15s,box-shadow .15s,background-color .15s;position:relative}[data-formie-field-type=signature] .formie-field-control:focus-within .formie-signature-canvas{border-color:var(--formie-focus-ring-border-color);box-shadow:var(--formie-shadow-focus)}.formie-field-has-error[data-formie-field-type=signature] .formie-signature-canvas{border-color:var(--formie-color-danger)}.formie-field-has-error[data-formie-field-type=signature] .formie-field-control:focus-within .formie-signature-canvas{box-shadow:var(--formie-shadow-danger-focus)}[data-formie-field-type=signature] .formie-signature-canvas{width:var(--formie-signature-width);height:var(--formie-signature-height);border:var(--formie-signature-border);background:var(--formie-signature-background);border-radius:var(--formie-signature-border-radius);touch-action:none;transition:border-color .15s,box-shadow .15s,background-color .15s;display:block}[data-formie-field-type=signature] .formie-signature-remove-button{top:var(--formie-signature-remove-button-top);right:var(--formie-signature-remove-button-right);transform:var(--formie-signature-remove-button-transform);font-size:0;line-height:0;position:absolute}[data-formie-field-type=signature] .formie-signature-pad{position:relative}[data-formie-field-type=signature] .formie-signature-message{padding:var(--formie-space-3);border:var(--formie-signature-border);border-radius:var(--formie-signature-border-radius);background:var(--formie-signature-background);color:var(--formie-color-text-muted);font-size:var(--formie-font-size-sm);line-height:var(--formie-line-height-base);margin:0}[data-formie-field-type=signature].formie-signature-has-message .formie-signature-canvas{display:none}}", l = "input[data-formie-signature-input]", u = "canvas[data-formie-signature-canvas]", d = "[data-formie-signature-clear]", f = "[data-formie-signature-message]", p = "signature", m = 20, h = 100, g = [
|
|
389
|
+
}, c = "@layer formie-theme{[data-formie-field-type=signature] .formie-field-control{transition:border-color .15s,box-shadow .15s,background-color .15s;position:relative}[data-formie-field-type=signature] .formie-field-control:focus-within .formie-signature-canvas{border-color:var(--formie-focus-ring-border-color);box-shadow:var(--formie-shadow-focus)}.formie-field-has-error[data-formie-field-type=signature] .formie-signature-canvas{border-color:var(--formie-color-danger)}.formie-field-has-error[data-formie-field-type=signature] .formie-field-control:focus-within .formie-signature-canvas{box-shadow:var(--formie-shadow-danger-focus)}[data-formie-field-type=signature] .formie-signature-canvas{width:var(--formie-signature-width);min-height:var(--formie-signature-height);border:var(--formie-signature-border);background:var(--formie-signature-background);border-radius:var(--formie-signature-border-radius);touch-action:none;height:auto;transition:border-color .15s,box-shadow .15s,background-color .15s;display:block}[data-formie-field-type=signature] .formie-signature-remove-button{top:var(--formie-signature-remove-button-top);right:var(--formie-signature-remove-button-right);transform:var(--formie-signature-remove-button-transform);font-size:0;line-height:0;position:absolute}[data-formie-field-type=signature] .formie-signature-pad{position:relative}[data-formie-field-type=signature] .formie-signature-message{padding:var(--formie-space-3);border:var(--formie-signature-border);border-radius:var(--formie-signature-border-radius);background:var(--formie-signature-background);color:var(--formie-color-text-muted);font-size:var(--formie-font-size-sm);line-height:var(--formie-line-height-base);margin:0}[data-formie-field-type=signature].formie-signature-has-message .formie-signature-canvas{display:none}}", l = "input[data-formie-signature-input]", u = "canvas[data-formie-signature-canvas]", d = "[data-formie-signature-clear]", f = "[data-formie-signature-message]", p = "signature", m = 20, h = 100, g = [
|
|
390
390
|
"hidden",
|
|
391
391
|
"data-formie-conditionally-hidden",
|
|
392
392
|
"data-formie-page-hidden",
|
|
@@ -436,85 +436,107 @@ function C(e, t) {
|
|
|
436
436
|
r && r.drawImage(n, 0, 0, e.width / t, e.height / t);
|
|
437
437
|
};
|
|
438
438
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
439
|
+
function w(e) {
|
|
440
|
+
return new Promise((t) => {
|
|
441
|
+
let n = new Image();
|
|
442
|
+
n.onload = () => {
|
|
443
|
+
t({
|
|
444
|
+
width: n.naturalWidth,
|
|
445
|
+
height: n.naturalHeight
|
|
446
|
+
});
|
|
447
|
+
}, n.onerror = () => t(null), n.src = e;
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
async function T(e, t) {
|
|
451
|
+
let n = await w(t);
|
|
452
|
+
if (!n?.width || !n?.height) return;
|
|
453
|
+
let { width: r } = _(e);
|
|
454
|
+
if (!(r > 0)) return;
|
|
455
|
+
let i = Math.max(1, Math.round(r * (n.height / n.width)));
|
|
456
|
+
e.style.height = `${i}px`;
|
|
457
|
+
}
|
|
458
|
+
async function E(e, t, n) {
|
|
459
|
+
if (n) {
|
|
460
|
+
await T(t, n);
|
|
461
|
+
try {
|
|
462
|
+
await e.fromDataURL(n);
|
|
463
|
+
} catch {
|
|
464
|
+
C(t, n);
|
|
465
|
+
}
|
|
444
466
|
}
|
|
445
467
|
}
|
|
446
|
-
function
|
|
468
|
+
function D(e, t, r, i, a, o) {
|
|
447
469
|
let c = b(t);
|
|
448
470
|
if (!v()) return x(t, i, c.noCanvas), () => {};
|
|
449
|
-
let l = parseFloat(o.penWeight || "2") || 2, u = i.parentElement instanceof HTMLElement ? i.parentElement : t, d = 0, f = null, y = !1, C = !1,
|
|
471
|
+
let l = parseFloat(o.penWeight || "2") || 2, u = i.parentElement instanceof HTMLElement ? i.parentElement : t, d = 0, f = null, y = !1, C = !1, w = new s(i, {
|
|
450
472
|
backgroundColor: o.backgroundColor || "rgba(255, 255, 255, 0)",
|
|
451
473
|
penColor: o.penColor || "#000000",
|
|
452
474
|
dotSize: l,
|
|
453
475
|
minWidth: l,
|
|
454
476
|
maxWidth: l
|
|
455
|
-
}),
|
|
477
|
+
}), D = () => {
|
|
456
478
|
f !== null && (window.clearTimeout(f), f = null);
|
|
457
|
-
}, D = () => {
|
|
458
|
-
y || (y = !0, C = !1, x(t, i, null), n(t, p, "init", { signature: T }));
|
|
459
479
|
}, O = () => {
|
|
480
|
+
y || (y = !0, C = !1, x(t, i, null), n(t, p, "init", { signature: w }));
|
|
481
|
+
}, k = () => {
|
|
460
482
|
y || C || (C = !0, x(t, i, c.initFailed));
|
|
461
|
-
},
|
|
462
|
-
let
|
|
463
|
-
|
|
464
|
-
let
|
|
465
|
-
if (!
|
|
466
|
-
let
|
|
467
|
-
return i.width =
|
|
468
|
-
},
|
|
483
|
+
}, A = async () => {
|
|
484
|
+
let e = r.value || (w.isEmpty() ? "" : w.toDataURL());
|
|
485
|
+
e && await T(i, e);
|
|
486
|
+
let { width: t, height: n } = _(i);
|
|
487
|
+
if (!(t > 0) || !(n > 0)) return !1;
|
|
488
|
+
let a = Math.max(window.devicePixelRatio || 1, 1), o = i.getContext("2d");
|
|
489
|
+
return o ? (i.width = t * a, i.height = n * a, o.setTransform(1, 0, 0, 1, 0, 0), o.scale(a, a), w.clear(), await E(w, i, e), O(), !0) : !1;
|
|
490
|
+
}, j = () => {
|
|
469
491
|
if (!(y || C)) {
|
|
470
492
|
if (d >= m) {
|
|
471
|
-
|
|
493
|
+
k();
|
|
472
494
|
return;
|
|
473
495
|
}
|
|
474
|
-
|
|
475
|
-
f = null, d += 1,
|
|
496
|
+
D(), f = window.setTimeout(() => {
|
|
497
|
+
f = null, d += 1, M();
|
|
476
498
|
}, h);
|
|
477
499
|
}
|
|
478
|
-
},
|
|
479
|
-
if (!await
|
|
480
|
-
|
|
500
|
+
}, M = async () => {
|
|
501
|
+
if (!await A()) {
|
|
502
|
+
j();
|
|
481
503
|
return;
|
|
482
504
|
}
|
|
483
|
-
|
|
484
|
-
},
|
|
505
|
+
D(), d = 0;
|
|
506
|
+
}, N = (e = 0) => {
|
|
485
507
|
window.setTimeout(() => {
|
|
486
508
|
window.requestAnimationFrame(() => {
|
|
487
|
-
|
|
509
|
+
M();
|
|
488
510
|
});
|
|
489
511
|
}, e);
|
|
490
|
-
}, N = () => {
|
|
491
|
-
S(t) && !y && (C = !1), M();
|
|
492
512
|
}, P = () => {
|
|
493
|
-
N();
|
|
513
|
+
S(t) && !y && (C = !1), N();
|
|
494
514
|
}, F = () => {
|
|
495
|
-
|
|
515
|
+
P();
|
|
496
516
|
}, I = () => {
|
|
497
|
-
S(t) && (d = 0, C = !1, N());
|
|
498
|
-
}, L =
|
|
499
|
-
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
}), z = (
|
|
517
|
+
S(t) && (d = 0, C = !1, N(100));
|
|
518
|
+
}, L = () => {
|
|
519
|
+
S(t) && (d = 0, C = !1, P());
|
|
520
|
+
}, R = typeof ResizeObserver > "u" ? null : new ResizeObserver(() => {
|
|
521
|
+
P();
|
|
522
|
+
}), z = new MutationObserver(() => {
|
|
523
|
+
L();
|
|
524
|
+
}), B = (e) => {
|
|
503
525
|
let t = r.value !== e;
|
|
504
526
|
r.value = e, t && (r.dispatchEvent(new Event("input", { bubbles: !0 })), r.dispatchEvent(new Event("change", { bubbles: !0 })));
|
|
505
|
-
}, B = () => {
|
|
506
|
-
z(T.isEmpty() ? "" : T.toDataURL());
|
|
507
527
|
}, V = () => {
|
|
508
|
-
|
|
528
|
+
B(w.isEmpty() ? "" : w.toDataURL());
|
|
529
|
+
}, H = () => {
|
|
530
|
+
w.clear(), B("");
|
|
509
531
|
};
|
|
510
|
-
return
|
|
532
|
+
return w.addEventListener("endStroke", V), window.addEventListener("resize", F), e.addEventListener("formie:page:navigate:after", I), R?.observe(u), z.observe(t, {
|
|
511
533
|
attributes: !0,
|
|
512
534
|
attributeFilter: [...g]
|
|
513
|
-
}),
|
|
514
|
-
|
|
535
|
+
}), N(), a && a.addEventListener("click", H), () => {
|
|
536
|
+
D(), w.removeEventListener("endStroke", V), window.removeEventListener("resize", F), e.removeEventListener("formie:page:navigate:after", I), R?.disconnect(), z.disconnect(), a && a.removeEventListener("click", H), w.clear();
|
|
515
537
|
};
|
|
516
538
|
}
|
|
517
|
-
var
|
|
539
|
+
var O = {
|
|
518
540
|
id: p,
|
|
519
541
|
kind: "field",
|
|
520
542
|
match: (e) => !!e.target.querySelector(u),
|
|
@@ -523,7 +545,7 @@ var E = {
|
|
|
523
545
|
if (!r) return;
|
|
524
546
|
let i = t(e).map((e) => {
|
|
525
547
|
let t = e.querySelector(l), i = e.querySelector(u), a = e.querySelector(d);
|
|
526
|
-
return !(t instanceof HTMLInputElement) || !(i instanceof HTMLCanvasElement) ? () => {} :
|
|
548
|
+
return !(t instanceof HTMLInputElement) || !(i instanceof HTMLCanvasElement) ? () => {} : D(r, e, t, i, a instanceof HTMLElement ? a : null, n);
|
|
527
549
|
});
|
|
528
550
|
return await e.emit("formie:module:signature:init", { count: i.length }), { destroy: () => {
|
|
529
551
|
i.forEach((e) => {
|
|
@@ -533,4 +555,4 @@ var E = {
|
|
|
533
555
|
}
|
|
534
556
|
};
|
|
535
557
|
//#endregion
|
|
536
|
-
export {
|
|
558
|
+
export { O as signatureModule };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { s as e } from "./event-names-BCI2FLD8.js";
|
|
2
|
-
import { t } from "./api-
|
|
2
|
+
import { t } from "./api-DqpfkZWL.js";
|
|
3
3
|
import { r as n, t as r } from "./theme-classes-Tv7q7ToE.js";
|
|
4
4
|
import { r as i } from "./scripts-CbQ7agX3.js";
|
|
5
5
|
import { t as a } from "./styles-BfoIZwJp.js";
|