@dekin_dev/react-checkout 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,37 +1,37 @@
1
- import { jsx as i, jsxs as g, Fragment as me } from "react/jsx-runtime";
2
- import { useRef as w, useEffect as b, useId as pe, useState as R, useMemo as G, useCallback as E } from "react";
3
- import { createPortal as ye } from "react-dom";
4
- const ve = {
1
+ import { jsx as i, jsxs as k, Fragment as Q } from "react/jsx-runtime";
2
+ import { useRef as L, useEffect as b, useId as be, useState as g, useMemo as Z, useCallback as E } from "react";
3
+ import { createPortal as we } from "react-dom";
4
+ const ge = {
5
5
  name: "hubtel",
6
6
  defaultTitle: "Complete Payment",
7
7
  supportsPostMessage: !1,
8
8
  iframeAllow: "payment *"
9
- }, ke = {
9
+ }, Le = {
10
10
  name: "moolre",
11
11
  defaultTitle: "Complete Payment",
12
12
  supportsPostMessage: !1,
13
13
  iframeAllow: "payment *"
14
- }, be = {
14
+ }, Te = {
15
15
  name: "payswitch",
16
16
  defaultTitle: "Complete Payment",
17
17
  supportsPostMessage: !1,
18
18
  iframeAllow: "payment *"
19
- }, _ = {
19
+ }, H = {
20
20
  name: "custom",
21
21
  defaultTitle: "Complete Payment",
22
22
  supportsPostMessage: !1
23
- }, ge = {
24
- hubtel: ve,
25
- moolre: ke,
26
- payswitch: be,
27
- custom: _
23
+ }, Re = {
24
+ hubtel: ge,
25
+ moolre: Le,
26
+ payswitch: Te,
27
+ custom: H
28
28
  };
29
- function we(e, o) {
29
+ function Ee(e, r) {
30
30
  let t;
31
- return e ? typeof e == "string" ? t = ge[e] ?? { ..._, name: e } : t = { ..._, ...e } : t = _, o ? { ...t, ...o } : t;
31
+ return e ? typeof e == "string" ? t = Re[e] ?? { ...H, name: e } : t = { ...H, ...e } : t = H, r ? { ...t, ...r } : t;
32
32
  }
33
- const Le = /* @__PURE__ */ new Set(["javascript:", "data:", "vbscript:", "file:", "blob:"]);
34
- function Te(e, o = {}) {
33
+ const Ne = /* @__PURE__ */ new Set(["javascript:", "data:", "vbscript:", "file:", "blob:"]);
34
+ function Pe(e, r = {}) {
35
35
  if (!e || typeof e != "string")
36
36
  return { valid: !1, reason: "A checkoutUrl is required." };
37
37
  let t;
@@ -40,13 +40,13 @@ function Te(e, o = {}) {
40
40
  } catch {
41
41
  return { valid: !1, reason: `"${e}" is not a valid URL.` };
42
42
  }
43
- return Le.has(t.protocol) ? { valid: !1, reason: `Unsafe URL protocol "${t.protocol}" is not allowed.` } : t.protocol !== "https:" && t.protocol !== "http:" ? { valid: !1, reason: `Unsupported URL protocol "${t.protocol}".` } : t.protocol === "http:" && !o.allowInsecureHttp ? {
43
+ return Ne.has(t.protocol) ? { valid: !1, reason: `Unsafe URL protocol "${t.protocol}" is not allowed.` } : t.protocol !== "https:" && t.protocol !== "http:" ? { valid: !1, reason: `Unsupported URL protocol "${t.protocol}".` } : t.protocol === "http:" && !r.allowInsecureHttp ? {
44
44
  valid: !1,
45
45
  reason: "checkoutUrl must use HTTPS. Pass allowInsecureHttp to override for local development only."
46
46
  } : { valid: !0 };
47
47
  }
48
- function Re(e, o) {
49
- return !o || o.length === 0 ? !1 : o.some((t) => {
48
+ function qe(e, r) {
49
+ return !r || r.length === 0 ? !1 : r.some((t) => {
50
50
  try {
51
51
  return new URL(t).origin === e;
52
52
  } catch {
@@ -54,47 +54,47 @@ function Re(e, o) {
54
54
  }
55
55
  });
56
56
  }
57
- function Ee(e, o) {
58
- return function(r) {
57
+ function Ae(e, r) {
58
+ return function(n) {
59
59
  if (!!e.allowedOrigins && e.allowedOrigins.length > 0) {
60
- if (!Re(r.origin, e.allowedOrigins)) return;
60
+ if (!qe(n.origin, e.allowedOrigins)) return;
61
61
  } else if (!e.supportsPostMessage)
62
62
  return;
63
63
  let a = null;
64
64
  if (e.messageHandler)
65
65
  try {
66
- a = e.messageHandler(r);
66
+ a = e.messageHandler(n);
67
67
  } catch {
68
68
  return;
69
69
  }
70
- else if (r.data && typeof r.data == "object") {
71
- const n = r.data;
70
+ else if (n.data && typeof n.data == "object") {
71
+ const c = n.data;
72
72
  a = {
73
- type: typeof n.type == "string" ? n.type : "message",
73
+ type: typeof c.type == "string" ? c.type : "message",
74
74
  provider: e.name,
75
- payload: r.data,
76
- origin: r.origin
75
+ payload: n.data,
76
+ origin: n.origin
77
77
  };
78
78
  }
79
- a && o({ ...a, origin: r.origin, raw: r });
79
+ a && r({ ...a, origin: n.origin, raw: n });
80
80
  };
81
81
  }
82
- const j = typeof window < "u" && typeof document < "u";
83
- function H(...e) {
82
+ const X = typeof window < "u" && typeof document < "u";
83
+ function S(...e) {
84
84
  return e.filter(Boolean).join(" ");
85
85
  }
86
- let A = 0, X = "", J = "";
87
- function Ae() {
88
- if (j) {
89
- if (A === 0) {
86
+ let P = 0, C = "", ee = "";
87
+ function xe() {
88
+ if (X) {
89
+ if (P === 0) {
90
90
  const e = window.innerWidth - document.documentElement.clientWidth;
91
- X = document.body.style.overflow, J = document.body.style.paddingRight, document.body.style.overflow = "hidden", e > 0 && (document.body.style.paddingRight = `${e}px`);
91
+ C = document.body.style.overflow, ee = document.body.style.paddingRight, document.body.style.overflow = "hidden", e > 0 && (document.body.style.paddingRight = `${e}px`);
92
92
  }
93
- A += 1;
93
+ P += 1;
94
94
  }
95
95
  }
96
- function Pe() {
97
- j && (A = Math.max(0, A - 1), A === 0 && (document.body.style.overflow = X, document.body.style.paddingRight = J));
96
+ function Ie() {
97
+ X && (P = Math.max(0, P - 1), P === 0 && (document.body.style.overflow = C, document.body.style.paddingRight = ee));
98
98
  }
99
99
  const De = [
100
100
  "a[href]",
@@ -105,102 +105,102 @@ const De = [
105
105
  "iframe",
106
106
  '[tabindex]:not([tabindex="-1"])'
107
107
  ].join(",");
108
- function z(e) {
108
+ function te(e) {
109
109
  return Array.from(e.querySelectorAll(De));
110
110
  }
111
- function Ne(e) {
111
+ function Ue(e) {
112
112
  return function(t) {
113
113
  if (t.key !== "Tab") return;
114
- const r = z(e);
115
- if (r.length === 0) {
114
+ const n = te(e);
115
+ if (n.length === 0) {
116
116
  t.preventDefault();
117
117
  return;
118
118
  }
119
- const c = r[0], a = r[r.length - 1], n = document.activeElement;
120
- t.shiftKey ? (n === c || !e.contains(n)) && (t.preventDefault(), a.focus()) : (n === a || !e.contains(n)) && (t.preventDefault(), c.focus());
119
+ const o = n[0], a = n[n.length - 1], c = document.activeElement;
120
+ t.shiftKey ? (c === o || !e.contains(c)) && (t.preventDefault(), a.focus()) : (c === a || !e.contains(c)) && (t.preventDefault(), o.focus());
121
121
  };
122
122
  }
123
- function M(e) {
123
+ function O(e) {
124
124
  return typeof e == "number" ? `${e}px` : e;
125
125
  }
126
- function xe({
126
+ function Me({
127
127
  id: e,
128
- title: o,
128
+ title: r,
129
129
  description: t,
130
- showCloseButton: r,
131
- closeOnOverlayClick: c,
130
+ showCloseButton: n,
131
+ closeOnOverlayClick: o,
132
132
  closeOnEscape: a,
133
- onClose: n,
134
- width: s,
135
- height: d,
136
- maxWidth: l,
137
- maxHeight: p,
138
- className: f,
139
- overlayClassName: k,
140
- theme: L,
141
- zIndex: P,
142
- children: O
133
+ onClose: c,
134
+ width: l,
135
+ height: f,
136
+ maxWidth: s,
137
+ maxHeight: y,
138
+ className: h,
139
+ overlayClassName: w,
140
+ theme: T,
141
+ zIndex: q,
142
+ children: $
143
143
  }) {
144
- const T = w(null), D = w(null);
144
+ const R = L(null), A = L(null);
145
145
  b(() => {
146
- Ae(), D.current = document.activeElement;
147
- const u = T.current;
148
- return u && (z(u)[0] ?? u).focus(), () => {
149
- var h, I;
150
- Pe(), (I = (h = D.current) == null ? void 0 : h.focus) == null || I.call(h);
146
+ xe(), A.current = document.activeElement;
147
+ const u = R.current;
148
+ return u && (te(u)[0] ?? u).focus(), () => {
149
+ var m, D;
150
+ Ie(), (D = (m = A.current) == null ? void 0 : m.focus) == null || D.call(m);
151
151
  };
152
152
  }, []), b(() => {
153
153
  if (!a) return;
154
- function u(h) {
155
- h.key === "Escape" && (h.stopPropagation(), n == null || n());
154
+ function u(m) {
155
+ m.key === "Escape" && (m.stopPropagation(), c == null || c());
156
156
  }
157
157
  return document.addEventListener("keydown", u), () => document.removeEventListener("keydown", u);
158
- }, [a, n]);
159
- function S(u) {
160
- u.key === "Tab" && T.current && Ne(T.current)(u.nativeEvent);
161
- }
158
+ }, [a, c]);
162
159
  function W(u) {
163
- c && u.target === u.currentTarget && (n == null || n());
160
+ u.key === "Tab" && R.current && Ue(R.current)(u.nativeEvent);
161
+ }
162
+ function B(u) {
163
+ o && u.target === u.currentTarget && (c == null || c());
164
164
  }
165
- const N = `${e}-title`, x = t ? `${e}-description` : void 0;
166
- return /* @__PURE__ */ i("div", { className: "vq-checkout-root", "data-theme": L, children: /* @__PURE__ */ i(
165
+ const x = `${e}-title`, I = t ? `${e}-description` : void 0;
166
+ return /* @__PURE__ */ i("div", { className: "vq-checkout-root", "data-theme": T, children: /* @__PURE__ */ i(
167
167
  "div",
168
168
  {
169
- className: H("vq-checkout-overlay", k),
170
- onMouseDown: W,
171
- style: P !== void 0 ? { zIndex: P } : void 0,
172
- children: /* @__PURE__ */ g(
169
+ className: S("vq-checkout-overlay", w),
170
+ onMouseDown: B,
171
+ style: q !== void 0 ? { zIndex: q } : void 0,
172
+ children: /* @__PURE__ */ k(
173
173
  "div",
174
174
  {
175
- ref: T,
175
+ ref: R,
176
176
  id: e,
177
177
  role: "dialog",
178
178
  "aria-modal": "true",
179
- "aria-labelledby": o ? N : void 0,
180
- "aria-label": o ? void 0 : "Checkout",
181
- "aria-describedby": x,
182
- className: H("vq-checkout-modal", f),
179
+ "aria-labelledby": r ? x : void 0,
180
+ "aria-label": r ? void 0 : "Checkout",
181
+ "aria-describedby": I,
182
+ className: S("vq-checkout-modal", h),
183
183
  style: {
184
- width: M(s),
185
- height: M(d),
186
- maxWidth: M(l),
187
- maxHeight: M(p)
184
+ width: O(l),
185
+ height: O(f),
186
+ maxWidth: O(s),
187
+ maxHeight: O(y)
188
188
  },
189
189
  tabIndex: -1,
190
- onKeyDown: S,
190
+ onKeyDown: W,
191
191
  children: [
192
- (o || t || r) && /* @__PURE__ */ g("div", { className: "vq-checkout-header", children: [
193
- /* @__PURE__ */ g("div", { className: "vq-checkout-heading", children: [
194
- o && /* @__PURE__ */ i("h2", { id: N, className: "vq-checkout-title", children: o }),
195
- t && /* @__PURE__ */ i("p", { id: x, className: "vq-checkout-description", children: t })
192
+ (r || t || n) && /* @__PURE__ */ k("div", { className: "vq-checkout-header", children: [
193
+ /* @__PURE__ */ k("div", { className: "vq-checkout-heading", children: [
194
+ r && /* @__PURE__ */ i("h2", { id: x, className: "vq-checkout-title", children: r }),
195
+ t && /* @__PURE__ */ i("p", { id: I, className: "vq-checkout-description", children: t })
196
196
  ] }),
197
- r && /* @__PURE__ */ i(
197
+ n && /* @__PURE__ */ i(
198
198
  "button",
199
199
  {
200
200
  type: "button",
201
201
  className: "vq-checkout-close",
202
202
  "aria-label": "Close checkout",
203
- onClick: () => n == null ? void 0 : n(),
203
+ onClick: () => c == null ? void 0 : c(),
204
204
  children: /* @__PURE__ */ i("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ i(
205
205
  "path",
206
206
  {
@@ -213,235 +213,265 @@ function xe({
213
213
  }
214
214
  )
215
215
  ] }),
216
- /* @__PURE__ */ i("div", { className: "vq-checkout-body", children: O })
216
+ /* @__PURE__ */ i("div", { className: "vq-checkout-body", children: $ })
217
217
  ]
218
218
  }
219
219
  )
220
220
  }
221
221
  ) });
222
222
  }
223
- function Ie({
223
+ function _e({
224
224
  src: e,
225
- title: o,
225
+ title: r,
226
226
  className: t,
227
- allow: r,
228
- sandbox: c,
227
+ allow: n,
228
+ sandbox: o,
229
229
  hidden: a,
230
- onLoad: n,
231
- onError: s
230
+ onLoad: c,
231
+ onError: l
232
232
  }) {
233
- const d = w(null), l = w(n), p = w(s);
234
- return l.current = n, p.current = s, b(() => {
235
- const f = d.current;
236
- if (!f) return;
237
- const k = () => l.current(), L = () => p.current();
238
- return f.addEventListener("load", k), f.addEventListener("error", L), () => {
239
- f.removeEventListener("load", k), f.removeEventListener("error", L);
233
+ const f = L(null), s = L(c), y = L(l);
234
+ return s.current = c, y.current = l, b(() => {
235
+ const h = f.current;
236
+ if (!h) return;
237
+ const w = () => s.current(), T = () => y.current();
238
+ return h.addEventListener("load", w), h.addEventListener("error", T), () => {
239
+ h.removeEventListener("load", w), h.removeEventListener("error", T);
240
240
  };
241
241
  }, [e]), /* @__PURE__ */ i(
242
242
  "iframe",
243
243
  {
244
- ref: d,
244
+ ref: f,
245
245
  src: e,
246
- title: o,
247
- className: H("vq-checkout-iframe", t),
248
- allow: r,
249
- sandbox: c,
246
+ title: r,
247
+ className: S("vq-checkout-iframe", t),
248
+ allow: n,
249
+ sandbox: o,
250
250
  style: a ? { position: "absolute", width: 0, height: 0, opacity: 0 } : void 0
251
251
  }
252
252
  );
253
253
  }
254
- function qe() {
255
- return /* @__PURE__ */ g("div", { className: "vq-checkout-state", role: "status", "aria-live": "polite", children: [
254
+ function Oe() {
255
+ return /* @__PURE__ */ k("div", { className: "vq-checkout-state", role: "status", "aria-live": "polite", children: [
256
256
  /* @__PURE__ */ i("div", { className: "vq-checkout-spinner", "aria-hidden": "true" }),
257
257
  /* @__PURE__ */ i("span", { children: "Loading secure checkout..." })
258
258
  ] });
259
259
  }
260
- function Ue({ error: e }) {
261
- return /* @__PURE__ */ g("div", { className: "vq-checkout-state", role: "alert", children: [
260
+ function He({ error: e }) {
261
+ return /* @__PURE__ */ k("div", { className: "vq-checkout-state", role: "alert", children: [
262
262
  /* @__PURE__ */ i("div", { className: "vq-checkout-error-icon", "aria-hidden": "true", children: "!" }),
263
263
  /* @__PURE__ */ i("p", { className: "vq-checkout-error-message", children: e.message })
264
264
  ] });
265
265
  }
266
- const Me = "min(95vw, 500px)", _e = "min(90vh, 750px)", He = "500px", Oe = "750px", Se = "payment *";
267
- function Q({
266
+ const Se = {
267
+ success: { icon: "✓", title: "Payment successful", tone: "success" },
268
+ failure: { icon: "✕", title: "Payment failed", tone: "failure" },
269
+ cancel: { icon: "↩", title: "Checkout cancelled", tone: "cancel" }
270
+ };
271
+ function $e({ result: e, onClose: r }) {
272
+ const t = Se[e.type];
273
+ return /* @__PURE__ */ k(
274
+ "div",
275
+ {
276
+ className: "vq-checkout-state",
277
+ role: e.type === "failure" ? "alert" : "status",
278
+ "aria-live": "polite",
279
+ children: [
280
+ /* @__PURE__ */ i("div", { className: `vq-checkout-result-icon vq-checkout-result-icon--${t.tone}`, "aria-hidden": "true", children: t.icon }),
281
+ /* @__PURE__ */ i("p", { className: "vq-checkout-error-message", children: t.title }),
282
+ /* @__PURE__ */ i("button", { type: "button", className: "vq-checkout-result-action", onClick: () => r == null ? void 0 : r(), children: "Close" })
283
+ ]
284
+ }
285
+ );
286
+ }
287
+ const We = "min(95vw, 500px)", Be = "min(90vh, 750px)", Fe = "500px", je = "750px", Ke = "payment *";
288
+ function re({
268
289
  open: e,
269
- checkoutUrl: o,
290
+ checkoutUrl: r,
270
291
  provider: t,
271
- providerConfig: r,
272
- onClose: c,
292
+ providerConfig: n,
293
+ onClose: o,
273
294
  onOpen: a,
274
- onLoad: n,
275
- onError: s,
276
- onMessage: d,
277
- onSuccess: l,
278
- onFailure: p,
279
- onCancel: f,
280
- title: k,
281
- description: L,
282
- showCloseButton: P = !0,
283
- closeOnOverlayClick: O = !0,
284
- closeOnEscape: T = !0,
285
- width: D = Me,
286
- height: S = _e,
287
- maxWidth: W = He,
288
- maxHeight: N = Oe,
289
- className: x,
295
+ onLoad: c,
296
+ onError: l,
297
+ onMessage: f,
298
+ onSuccess: s,
299
+ onFailure: y,
300
+ onCancel: h,
301
+ title: w,
302
+ description: T,
303
+ showCloseButton: q = !0,
304
+ closeOnOverlayClick: $ = !0,
305
+ closeOnEscape: R = !0,
306
+ width: A = We,
307
+ height: W = Be,
308
+ maxWidth: B = Fe,
309
+ maxHeight: x = je,
310
+ className: I,
290
311
  iframeClassName: u,
291
- overlayClassName: h,
292
- theme: I = "light",
293
- zIndex: Y,
294
- allow: Z,
295
- sandbox: C,
296
- loadingComponent: ee,
297
- errorComponent: $,
298
- allowInsecureHttp: K,
299
- id: te,
300
- children: re
312
+ overlayClassName: m,
313
+ theme: D = "light",
314
+ zIndex: ne,
315
+ allow: ce,
316
+ sandbox: ie,
317
+ loadingComponent: ae,
318
+ errorComponent: F,
319
+ resultComponent: j,
320
+ autoCloseDelay: K,
321
+ allowInsecureHttp: J,
322
+ id: oe,
323
+ children: le
301
324
  }) {
302
- const ne = pe(), oe = te ?? `vq-checkout-${ne}`, [ae, ie] = R(!1), [q, U] = R("loading"), [B, F] = R(null), V = w(!1), y = G(
303
- () => we(t, r),
325
+ const se = be(), ue = oe ?? `vq-checkout-${se}`, [de, fe] = g(!1), [U, M] = g("loading"), [V, G] = g(null), [N, _] = g(null), Y = L(!1), v = Z(
326
+ () => Ee(t, n),
304
327
  // eslint-disable-next-line react-hooks/exhaustive-deps
305
- [t, JSON.stringify(r ?? {})]
328
+ [t, JSON.stringify(n ?? {})]
306
329
  );
307
330
  b(() => {
308
- ie(!0);
331
+ fe(!0);
309
332
  }, []), b(() => {
310
- e && !V.current && (a == null || a()), V.current = e;
333
+ e && !Y.current && (a == null || a()), Y.current = e;
311
334
  }, [e]), b(() => {
312
335
  if (!e) return;
313
- const v = Te(o, { allowInsecureHttp: K });
314
- if (!v.valid) {
315
- const m = {
336
+ _(null);
337
+ const p = Pe(r, { allowInsecureHttp: J });
338
+ if (!p.valid) {
339
+ const d = {
316
340
  code: "INVALID_URL",
317
- message: v.reason ?? "The provided checkoutUrl is invalid.",
318
- provider: y.name
341
+ message: p.reason ?? "The provided checkoutUrl is invalid.",
342
+ provider: v.name
319
343
  };
320
- U("error"), F(m), s == null || s(m);
344
+ M("error"), G(d), l == null || l(d);
321
345
  return;
322
346
  }
323
- U("loading"), F(null);
324
- }, [e, o, K]), b(() => {
325
- if (!e || !j) return;
326
- const v = Ee(y, (m) => {
327
- d == null || d(m), m.type === "success" ? l == null || l(m) : m.type === "failure" ? p == null || p(m) : m.type === "cancel" && (f == null || f(m));
347
+ M("loading"), G(null);
348
+ }, [e, r, J]), b(() => {
349
+ if (!e || !X) return;
350
+ const p = Ae(v, (d) => {
351
+ f == null || f(d), d.type === "success" ? (_({ type: "success", message: d }), s == null || s(d)) : d.type === "failure" ? (_({ type: "failure", message: d }), y == null || y(d)) : d.type === "cancel" && (_({ type: "cancel", message: d }), h == null || h(d));
328
352
  });
329
- return window.addEventListener("message", v), () => window.removeEventListener("message", v);
330
- }, [e, y, d, l, p, f]);
331
- const ce = E(() => {
332
- U("loaded"), n == null || n();
333
- }, [n]), se = E(() => {
334
- const v = {
353
+ return window.addEventListener("message", p), () => window.removeEventListener("message", p);
354
+ }, [e, v, f, s, y, h]);
355
+ const he = E(() => {
356
+ M("loaded"), c == null || c();
357
+ }, [c]), me = E(() => {
358
+ const p = {
335
359
  code: "IFRAME_LOAD_ERROR",
336
360
  message: "The checkout page could not be loaded.",
337
- provider: y.name
361
+ provider: v.name
338
362
  };
339
- U("error"), F(v), s == null || s(v);
340
- }, [s, y.name]), le = E(() => {
341
- c == null || c();
342
- }, [c]);
343
- if (!e || !ae) return null;
344
- const ue = k ?? y.defaultTitle ?? "Checkout", de = Z ?? y.iframeAllow ?? Se, fe = C ?? y.iframeSandbox, he = /* @__PURE__ */ g(
345
- xe,
363
+ M("error"), G(p), l == null || l(p);
364
+ }, [l, v.name]), z = E(() => {
365
+ o == null || o();
366
+ }, [o]);
367
+ if (b(() => {
368
+ if (!N || K === void 0) return;
369
+ const p = setTimeout(() => o == null ? void 0 : o(), K);
370
+ return () => clearTimeout(p);
371
+ }, [N, K, o]), !e || !de) return null;
372
+ const pe = w ?? v.defaultTitle ?? "Checkout", ye = ce ?? v.iframeAllow ?? Ke, ve = ie ?? v.iframeSandbox, ke = /* @__PURE__ */ k(
373
+ Me,
346
374
  {
347
- id: oe,
348
- title: k ?? y.defaultTitle,
349
- description: L,
350
- showCloseButton: P,
351
- closeOnOverlayClick: O,
352
- closeOnEscape: T,
353
- onClose: le,
354
- width: D,
355
- height: S,
356
- maxWidth: W,
357
- maxHeight: N,
358
- className: x,
359
- overlayClassName: h,
360
- theme: I,
361
- zIndex: Y,
375
+ id: ue,
376
+ title: w ?? v.defaultTitle,
377
+ description: T,
378
+ showCloseButton: q,
379
+ closeOnOverlayClick: $,
380
+ closeOnEscape: R,
381
+ onClose: z,
382
+ width: A,
383
+ height: W,
384
+ maxWidth: B,
385
+ maxHeight: x,
386
+ className: I,
387
+ overlayClassName: m,
388
+ theme: D,
389
+ zIndex: ne,
362
390
  children: [
363
- q === "loading" && (ee ?? /* @__PURE__ */ i(qe, {})),
364
- q === "error" && B && (typeof $ == "function" ? $(B) : $ ?? /* @__PURE__ */ i(Ue, { error: B })),
365
- q !== "error" && /* @__PURE__ */ i(
366
- Ie,
367
- {
368
- src: o,
369
- title: ue,
370
- className: u,
371
- allow: de,
372
- sandbox: fe,
373
- hidden: q === "loading",
374
- onLoad: ce,
375
- onError: se
376
- }
377
- ),
378
- re
391
+ N ? typeof j == "function" ? j(N) : j ?? /* @__PURE__ */ i($e, { result: N, onClose: z }) : /* @__PURE__ */ k(Q, { children: [
392
+ U === "loading" && (ae ?? /* @__PURE__ */ i(Oe, {})),
393
+ U === "error" && V && (typeof F == "function" ? F(V) : F ?? /* @__PURE__ */ i(He, { error: V })),
394
+ U !== "error" && /* @__PURE__ */ i(
395
+ _e,
396
+ {
397
+ src: r,
398
+ title: pe,
399
+ className: u,
400
+ allow: ye,
401
+ sandbox: ve,
402
+ hidden: U === "loading",
403
+ onLoad: he,
404
+ onError: me
405
+ }
406
+ )
407
+ ] }),
408
+ le
379
409
  ]
380
410
  }
381
411
  );
382
- return ye(he, document.body);
412
+ return we(ke, document.body);
383
413
  }
384
- function Fe({
414
+ function Je({
385
415
  children: e,
386
- buttonClassName: o,
416
+ buttonClassName: r,
387
417
  buttonProps: t,
388
- onClose: r,
389
- ...c
418
+ onClose: n,
419
+ ...o
390
420
  }) {
391
- const [a, n] = R(!1);
392
- return /* @__PURE__ */ g(me, { children: [
421
+ const [a, c] = g(!1);
422
+ return /* @__PURE__ */ k(Q, { children: [
393
423
  /* @__PURE__ */ i(
394
424
  "button",
395
425
  {
396
426
  type: "button",
397
- className: H("vq-checkout-trigger", o),
398
- onClick: () => n(!0),
427
+ className: S("vq-checkout-trigger", r),
428
+ onClick: () => c(!0),
399
429
  ...t,
400
430
  children: e
401
431
  }
402
432
  ),
403
433
  /* @__PURE__ */ i(
404
- Q,
434
+ re,
405
435
  {
406
- ...c,
436
+ ...o,
407
437
  open: a,
408
438
  onClose: () => {
409
- n(!1), r == null || r();
439
+ c(!1), n == null || n();
410
440
  }
411
441
  }
412
442
  )
413
443
  ] });
414
444
  }
415
- function je(e) {
416
- const [o, t] = R(!1), [r, c] = R(null), a = w(e);
445
+ function Ye(e) {
446
+ const [r, t] = g(!1), [n, o] = g(null), a = L(e);
417
447
  a.current = e;
418
- const n = E((l) => {
419
- c({ ...a.current, ...l }), t(!0);
420
- }, []), s = E(() => t(!1), []), d = E(() => r ? /* @__PURE__ */ i(
421
- Q,
448
+ const c = E((s) => {
449
+ o({ ...a.current, ...s }), t(!0);
450
+ }, []), l = E(() => t(!1), []), f = E(() => n ? /* @__PURE__ */ i(
451
+ re,
422
452
  {
423
- ...r,
424
- open: o,
453
+ ...n,
454
+ open: r,
425
455
  onClose: () => {
426
- var l;
427
- (l = r.onClose) == null || l.call(r), t(!1);
456
+ var s;
457
+ (s = n.onClose) == null || s.call(n), t(!1);
428
458
  }
429
459
  }
430
- ) : null, [r, o]);
431
- return G(
432
- () => ({ openCheckout: n, closeCheckout: s, isOpen: o, CheckoutModal: d }),
433
- [n, s, o, d]
460
+ ) : null, [n, r]);
461
+ return Z(
462
+ () => ({ openCheckout: c, closeCheckout: l, isOpen: r, CheckoutModal: f }),
463
+ [c, l, r, f]
434
464
  );
435
465
  }
436
466
  export {
437
- Q as Checkout,
438
- Fe as CheckoutButton,
439
- _ as customProviderDefaults,
440
- ve as hubtelProvider,
441
- ke as moolreProvider,
442
- be as payswitchProvider,
443
- we as resolveProviderConfig,
444
- je as useCheckout,
445
- Te as validateCheckoutUrl
467
+ re as Checkout,
468
+ Je as CheckoutButton,
469
+ H as customProviderDefaults,
470
+ ge as hubtelProvider,
471
+ Le as moolreProvider,
472
+ Te as payswitchProvider,
473
+ Ee as resolveProviderConfig,
474
+ Ye as useCheckout,
475
+ Pe as validateCheckoutUrl
446
476
  };
447
477
  //# sourceMappingURL=index.mjs.map