@test-glide/glide-payment 0.0.3 → 0.0.5
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.cjs.js +16 -16
- package/dist/index.es.js +265 -264
- package/dist/index.umd.js +13 -13
- package/dist/native/native.cjs.js +1 -1
- package/dist/native/native.es.js +127 -124
- package/dist/react/react.cjs.js +15 -15
- package/dist/react/react.es.js +264 -263
- package/package.json +1 -1
package/dist/react/react.es.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
function p(
|
|
4
|
-
const
|
|
1
|
+
import { jsx as J } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as Q, useEffect as X } from "react";
|
|
3
|
+
function p(t, n = {}) {
|
|
4
|
+
const e = document.createElement(t), { className: a, id: i, innerHTML: m, textContent: l, attributes: r, styles: u, dataset: s, children: o, events: d } = n;
|
|
5
5
|
if (a) {
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const h = Array.isArray(a) ? a : a.split(" ");
|
|
7
|
+
e.classList.add(...h.filter(Boolean));
|
|
8
8
|
}
|
|
9
|
-
if (
|
|
10
|
-
for (const [
|
|
11
|
-
|
|
12
|
-
if (
|
|
13
|
-
for (const [
|
|
14
|
-
|
|
9
|
+
if (i && (e.id = i), m && (e.innerHTML = m), l && (e.textContent = l), r)
|
|
10
|
+
for (const [h, c] of Object.entries(r))
|
|
11
|
+
c && e.setAttribute(h, c);
|
|
12
|
+
if (u)
|
|
13
|
+
for (const [h, c] of Object.entries(u))
|
|
14
|
+
e.style[h] = c;
|
|
15
15
|
if (s)
|
|
16
|
-
for (const [
|
|
17
|
-
|
|
18
|
-
if (o &&
|
|
19
|
-
for (const [
|
|
20
|
-
|
|
21
|
-
return
|
|
16
|
+
for (const [h, c] of Object.entries(s))
|
|
17
|
+
e.dataset[h] = c;
|
|
18
|
+
if (o && e.append(...o.filter(Boolean)), d)
|
|
19
|
+
for (const [h, c] of Object.entries(d))
|
|
20
|
+
e.addEventListener(h, c);
|
|
21
|
+
return e;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
26
|
-
console.warn("updateElements: no elements found for",
|
|
23
|
+
function C(t, n) {
|
|
24
|
+
const e = "id" in t ? [document.getElementById(t.id)].filter(Boolean) : "className" in t ? Array.from(document.getElementsByClassName(t.className)) : [t.element];
|
|
25
|
+
if (!e.length) {
|
|
26
|
+
console.warn("updateElements: no elements found for", t);
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
for (const a of
|
|
30
|
-
const { styles:
|
|
31
|
-
if (r)
|
|
32
|
-
for (const [o, h] of Object.entries(r))
|
|
33
|
-
a.style[o] = h;
|
|
34
|
-
if (m)
|
|
35
|
-
for (const [o, h] of Object.entries(m))
|
|
36
|
-
a.setAttribute(o, h);
|
|
29
|
+
for (const a of e) {
|
|
30
|
+
const { styles: i, attributes: m, dataset: l, innerHTML: r, textContent: u, className: s } = n;
|
|
37
31
|
if (i)
|
|
38
|
-
for (const [o,
|
|
39
|
-
a.
|
|
40
|
-
if (
|
|
32
|
+
for (const [o, d] of Object.entries(i))
|
|
33
|
+
a.style[o] = d;
|
|
34
|
+
if (m)
|
|
35
|
+
for (const [o, d] of Object.entries(m))
|
|
36
|
+
a.setAttribute(o, d);
|
|
37
|
+
if (l)
|
|
38
|
+
for (const [o, d] of Object.entries(l))
|
|
39
|
+
a.dataset[o] = d;
|
|
40
|
+
if (r !== void 0 && (a.innerHTML = r), u !== void 0 && (a.textContent = u), s?.add) {
|
|
41
41
|
const o = Array.isArray(s.add) ? s.add : [s.add];
|
|
42
42
|
a.classList.add(...o);
|
|
43
43
|
}
|
|
@@ -45,10 +45,10 @@ function x(n, e) {
|
|
|
45
45
|
const o = Array.isArray(s.remove) ? s.remove : [s.remove];
|
|
46
46
|
a.classList.remove(...o);
|
|
47
47
|
}
|
|
48
|
-
s?.toggle && (Array.isArray(s.toggle) ? s.toggle : [s.toggle]).forEach((
|
|
48
|
+
s?.toggle && (Array.isArray(s.toggle) ? s.toggle : [s.toggle]).forEach((d) => a.classList.toggle(d));
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
const
|
|
51
|
+
const ee = `
|
|
52
52
|
<svg
|
|
53
53
|
xmlns="http://www.w3.org/2000/svg"
|
|
54
54
|
width="16"
|
|
@@ -63,7 +63,7 @@ const te = `
|
|
|
63
63
|
clip-rule="evenodd"
|
|
64
64
|
></path>
|
|
65
65
|
</svg>
|
|
66
|
-
`,
|
|
66
|
+
`, te = `
|
|
67
67
|
<svg
|
|
68
68
|
xmlns="http://www.w3.org/2000/svg"
|
|
69
69
|
width="16"
|
|
@@ -78,7 +78,7 @@ const te = `
|
|
|
78
78
|
>
|
|
79
79
|
<path d="M12 2v4M16.2 7.8l2.9-2.9M18 12h4M16.2 16.2l2.9 2.9M12 18v4M4.9 19.1l2.9-2.9M2 12h4M4.9 4.9l2.9 2.9"></path>
|
|
80
80
|
</svg>
|
|
81
|
-
`,
|
|
81
|
+
`, ne = `<svg
|
|
82
82
|
xmlns="http://www.w3.org/2000/svg"
|
|
83
83
|
width="20"
|
|
84
84
|
height="20"
|
|
@@ -95,45 +95,45 @@ const te = `
|
|
|
95
95
|
></path>
|
|
96
96
|
</svg>`, k = `
|
|
97
97
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 256 256"><path d="M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z"></path></svg>
|
|
98
|
-
`, se = ({ children:
|
|
99
|
-
const
|
|
98
|
+
`, se = ({ children: t, onClick: n, disabled: e = !1, size: a = "medium", type: i = "button", className: m = "", variant: l = "primary" }) => {
|
|
99
|
+
const r = p("span", {
|
|
100
100
|
className: "button-spinner",
|
|
101
|
-
innerHTML:
|
|
101
|
+
innerHTML: te,
|
|
102
102
|
dataset: { show: "false" }
|
|
103
|
-
}),
|
|
103
|
+
}), u = p("span", {
|
|
104
104
|
className: "button-label",
|
|
105
105
|
children: [
|
|
106
106
|
null
|
|
107
107
|
],
|
|
108
|
-
textContent:
|
|
108
|
+
textContent: t
|
|
109
109
|
}), s = p("button", {
|
|
110
|
-
className: `custom-button ${
|
|
110
|
+
className: `custom-button ${l} ${a} ${m}`,
|
|
111
111
|
attributes: {
|
|
112
|
-
type:
|
|
113
|
-
...
|
|
112
|
+
type: i,
|
|
113
|
+
...e ? { disabled: "true" } : {}
|
|
114
114
|
},
|
|
115
115
|
events: {
|
|
116
|
-
click:
|
|
116
|
+
click: n
|
|
117
117
|
},
|
|
118
118
|
children: [
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
r,
|
|
120
|
+
u
|
|
121
121
|
]
|
|
122
|
-
}), o = (
|
|
123
|
-
|
|
124
|
-
dataset: { show: String(
|
|
125
|
-
}), h
|
|
126
|
-
},
|
|
127
|
-
|
|
122
|
+
}), o = (h = !1) => {
|
|
123
|
+
C({ element: r }, {
|
|
124
|
+
dataset: { show: String(h) }
|
|
125
|
+
}), d(h);
|
|
126
|
+
}, d = (h = !1) => {
|
|
127
|
+
h ? s.setAttribute("disabled", "true") : s.removeAttribute("disabled");
|
|
128
128
|
};
|
|
129
129
|
return {
|
|
130
130
|
element: s,
|
|
131
131
|
setLoading: o,
|
|
132
|
-
setDisabled:
|
|
132
|
+
setDisabled: d
|
|
133
133
|
};
|
|
134
|
-
},
|
|
135
|
-
var
|
|
136
|
-
className: `tooltip ${
|
|
134
|
+
}, re = ({ content: t, position: n = "top", delay: e = 200, maxWidth: a = 250, className: i = "", id: m = "" }) => {
|
|
135
|
+
var l = p("div", {
|
|
136
|
+
className: `tooltip ${n} ${i}`,
|
|
137
137
|
styles: {
|
|
138
138
|
// top: `${tooltipPosition.top}px`,
|
|
139
139
|
// left: `${tooltipPosition.left}px`,
|
|
@@ -144,162 +144,165 @@ const te = `
|
|
|
144
144
|
},
|
|
145
145
|
dataset: { show: "false" },
|
|
146
146
|
innerHTML: `
|
|
147
|
-
<div class="tooltip-content">${
|
|
147
|
+
<div class="tooltip-content">${t}</div>
|
|
148
148
|
<div class="tooltip-arrow"></div>
|
|
149
149
|
`
|
|
150
150
|
});
|
|
151
|
-
let
|
|
151
|
+
let r = null;
|
|
152
152
|
var o = p("span", {
|
|
153
153
|
className: "tooltip-trigger",
|
|
154
154
|
innerHTML: k,
|
|
155
155
|
events: {
|
|
156
156
|
mouseenter: () => {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
},
|
|
157
|
+
e > 0 ? r = window.setTimeout(() => {
|
|
158
|
+
l.dataset.show = "true", d();
|
|
159
|
+
}, e) : (l.dataset.show = "true", d());
|
|
160
160
|
},
|
|
161
161
|
mouseleave: () => {
|
|
162
|
-
|
|
162
|
+
r && clearTimeout(r), l.dataset.show = "false";
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
});
|
|
166
|
-
function
|
|
167
|
-
if (!o || !
|
|
168
|
-
const
|
|
169
|
-
let
|
|
170
|
-
switch (
|
|
166
|
+
function d() {
|
|
167
|
+
if (!o || !l) return;
|
|
168
|
+
const c = o.getBoundingClientRect(), v = l.getBoundingClientRect(), b = 8;
|
|
169
|
+
let f, y;
|
|
170
|
+
switch (n) {
|
|
171
171
|
case "top":
|
|
172
|
-
|
|
172
|
+
f = c.top - v.height - b, y = c.left + c.width / 2 - v.width / 2;
|
|
173
173
|
break;
|
|
174
174
|
case "bottom":
|
|
175
|
-
|
|
175
|
+
f = c.bottom + b, y = c.left + c.width / 2 - v.width / 2;
|
|
176
176
|
break;
|
|
177
177
|
case "left":
|
|
178
|
-
|
|
178
|
+
f = c.top + c.height / 2 - v.height / 2, y = c.left - v.width - b;
|
|
179
179
|
break;
|
|
180
180
|
case "right":
|
|
181
|
-
|
|
181
|
+
f = c.top + c.height / 2 - v.height / 2, y = c.right + b;
|
|
182
182
|
break;
|
|
183
183
|
default:
|
|
184
|
-
|
|
184
|
+
f = c.top - v.height - b, y = c.left + c.width / 2 - v.width / 2;
|
|
185
185
|
}
|
|
186
|
-
const N = window.innerWidth,
|
|
187
|
-
|
|
186
|
+
const N = window.innerWidth, D = window.innerHeight;
|
|
187
|
+
y < 0 && (y = b), y + v.width > N && (y = N - v.width - b), f < 0 && (f = b), f + v.height > D && (f = D - v.height - b), l.style.top = `${f}px`, l.style.left = `${y}px`;
|
|
188
188
|
}
|
|
189
189
|
return p("div", {
|
|
190
190
|
className: "tooltip-wrapper",
|
|
191
191
|
id: `tooltip-${m}`,
|
|
192
192
|
children: [
|
|
193
193
|
o,
|
|
194
|
-
|
|
194
|
+
l
|
|
195
195
|
]
|
|
196
196
|
});
|
|
197
|
-
},
|
|
198
|
-
const e = {},
|
|
197
|
+
}, oe = (t, n = !1) => {
|
|
198
|
+
const e = {}, a = Object.values(t).every(
|
|
199
199
|
(r) => !r || r.trim() === ""
|
|
200
|
-
),
|
|
201
|
-
if (
|
|
200
|
+
), i = t.cardNumber?.replace(/\s/g, "");
|
|
201
|
+
if (i ? /^\d{13,19}$/.test(i) || (e.cardNumber = "Card number must be 13-19 digits") : e.cardNumber = "Card number is required", !t.expiryDate && !n)
|
|
202
202
|
e.expiryDate = "Expiry date is required";
|
|
203
|
-
else {
|
|
204
|
-
const r =
|
|
203
|
+
else if (t.expiryDate) {
|
|
204
|
+
const r = t.expiryDate.replace(/\D/g, "");
|
|
205
205
|
if (r.length < 4)
|
|
206
206
|
e.expiryDate = "Enter complete expiry date (MM/YY)";
|
|
207
207
|
else {
|
|
208
|
-
const
|
|
209
|
-
if (isNaN(
|
|
208
|
+
const u = parseInt(r.substring(0, 2), 10), s = parseInt(r.substring(2, 4), 10);
|
|
209
|
+
if (isNaN(u) || u < 1 || u > 12)
|
|
210
210
|
e.expiryDate = "Invalid month (must be 01-12)";
|
|
211
|
-
else if (isNaN(
|
|
211
|
+
else if (isNaN(s) || s < 0 || s > 99)
|
|
212
212
|
e.expiryDate = "Invalid year";
|
|
213
213
|
else {
|
|
214
|
-
const
|
|
215
|
-
let
|
|
216
|
-
|
|
214
|
+
const o = /* @__PURE__ */ new Date(), d = o.getFullYear(), h = o.getMonth() + 1, c = Math.floor(d / 100) * 100, v = c + s, b = c + 100 + s;
|
|
215
|
+
let f;
|
|
216
|
+
v >= d && v <= d + 20 ? f = v : (b >= d && b <= d + 20, f = b), f < d || f === d && u < h ? e.expiryDate = "Card has expired" : f > d + 20 && (e.expiryDate = "Expiry year is too far in the future");
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
-
|
|
220
|
+
const m = t.cvv.trim();
|
|
221
|
+
m && !/^\d{3,4}$/.test(m) && (e.cvv = "CVV must be 3 or 4 digits");
|
|
222
|
+
const l = t.zipCode.trim();
|
|
223
|
+
return l && !/^[A-Z0-9\s-]{3,10}$/i.test(l) && (e.zipCode = "Invalid ZIP code format"), {
|
|
221
224
|
isValid: Object.keys(e).length === 0,
|
|
222
225
|
errors: e,
|
|
223
|
-
isEmpty:
|
|
226
|
+
isEmpty: a
|
|
224
227
|
};
|
|
225
228
|
};
|
|
226
|
-
function
|
|
227
|
-
const
|
|
228
|
-
if (isNaN(
|
|
229
|
-
const
|
|
230
|
-
let
|
|
231
|
-
return
|
|
229
|
+
function ae(t) {
|
|
230
|
+
const n = parseInt(t, 10);
|
|
231
|
+
if (isNaN(n) || n < 0 || n > 99) return null;
|
|
232
|
+
const e = (/* @__PURE__ */ new Date()).getFullYear(), a = Math.floor(e / 100) * 100;
|
|
233
|
+
let i = a + n;
|
|
234
|
+
return i >= e && i <= e + 20 || (i = a + 100 + n, i >= e && i <= e + 20) ? i : a + 100 + n;
|
|
232
235
|
}
|
|
233
|
-
function V(
|
|
234
|
-
return
|
|
236
|
+
function V(t = "") {
|
|
237
|
+
return t.trim().replaceAll(/\s/g, "").replaceAll("-", "");
|
|
235
238
|
}
|
|
236
|
-
const
|
|
237
|
-
card: (
|
|
238
|
-
phone: (
|
|
239
|
-
const
|
|
240
|
-
return
|
|
239
|
+
const ie = {
|
|
240
|
+
card: (t) => t.replace(/\s+/g, "").replace(/[^0-9]/gi, "").substring(0, 16).match(/.{1,4}/g)?.join(" ") ?? "",
|
|
241
|
+
phone: (t) => {
|
|
242
|
+
const n = t.replace(/\D/g, "").substring(0, 10), e = n.match(/^(\d{3})(\d{3})(\d{4})$/);
|
|
243
|
+
return e ? `(${e[1]}) ${e[2]}-${e[3]}` : n;
|
|
241
244
|
},
|
|
242
|
-
expiry: (
|
|
243
|
-
const
|
|
244
|
-
return
|
|
245
|
+
expiry: (t) => {
|
|
246
|
+
const n = t.replace(/[^0-9/]/g, "");
|
|
247
|
+
return n.length <= 2 ? n : n.includes("/") ? n.substring(0, 5) : n.substring(0, 2) + "/" + n.substring(2, 4);
|
|
245
248
|
},
|
|
246
|
-
cvv: (
|
|
247
|
-
zip: (
|
|
248
|
-
const
|
|
249
|
-
return
|
|
249
|
+
cvv: (t) => t.replace(/\D/g, "").substring(0, 4),
|
|
250
|
+
zip: (t) => {
|
|
251
|
+
const n = t.replace(/\D/g, "").substring(0, 9);
|
|
252
|
+
return n.length > 5 ? `${n.substring(0, 5)}-${n.substring(5)}` : n;
|
|
250
253
|
}
|
|
251
254
|
};
|
|
252
|
-
function
|
|
253
|
-
return
|
|
255
|
+
function le(t, n) {
|
|
256
|
+
return n === "none" ? t : ie[n](t);
|
|
254
257
|
}
|
|
255
|
-
const $ = ({ label:
|
|
256
|
-
const
|
|
258
|
+
const $ = ({ label: t, maskType: n, id: e, name: a, type: i = "text", placeholder: m = "Enter value", tooltip: l = "", onChange: r }) => {
|
|
259
|
+
const u = ["card", "expiry", "phone", "cvv", "zip"].includes(n) ? "numeric" : "", s = p("label", {
|
|
257
260
|
className: "input-label",
|
|
258
|
-
innerHTML:
|
|
261
|
+
innerHTML: t,
|
|
259
262
|
attributes: {
|
|
260
|
-
for:
|
|
263
|
+
for: e
|
|
261
264
|
}
|
|
262
265
|
});
|
|
263
266
|
let o = !1;
|
|
264
|
-
const
|
|
265
|
-
id:
|
|
267
|
+
const h = p("input", {
|
|
268
|
+
id: e || "input-id",
|
|
266
269
|
className: "styled-input",
|
|
267
270
|
attributes: {
|
|
268
271
|
placeholder: m,
|
|
269
|
-
type:
|
|
270
|
-
inputMode:
|
|
272
|
+
type: i,
|
|
273
|
+
inputMode: u,
|
|
271
274
|
name: a
|
|
272
275
|
},
|
|
273
276
|
events: {
|
|
274
|
-
input:
|
|
277
|
+
input: c,
|
|
275
278
|
blur: v,
|
|
276
|
-
keydown: (
|
|
277
|
-
|
|
279
|
+
keydown: (w) => {
|
|
280
|
+
w.key === "Enter" && (o = !0);
|
|
278
281
|
}
|
|
279
282
|
}
|
|
280
283
|
});
|
|
281
|
-
function
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
+
function c(w) {
|
|
285
|
+
const T = n !== "none" ? le(w?.target?.value, n) : w?.target?.value;
|
|
286
|
+
h.value = T, r?.(T);
|
|
284
287
|
}
|
|
285
288
|
function v() {
|
|
286
|
-
o = !0,
|
|
289
|
+
o = !0, r?.(h?.value || "");
|
|
287
290
|
}
|
|
288
|
-
const
|
|
291
|
+
const b = p("div", {
|
|
289
292
|
className: "input-loader",
|
|
290
293
|
innerHTML: '<div class="loader"></div>',
|
|
291
294
|
dataset: { show: "false" }
|
|
292
|
-
}),
|
|
295
|
+
}), f = l ? p("div", {
|
|
293
296
|
className: "input-right-element",
|
|
294
297
|
children: [
|
|
295
|
-
|
|
298
|
+
re({ content: l, id: e })
|
|
296
299
|
]
|
|
297
|
-
}) : null,
|
|
300
|
+
}) : null, y = p("div", {
|
|
298
301
|
className: "input-wrapper",
|
|
299
302
|
children: [
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
+
h,
|
|
304
|
+
b,
|
|
305
|
+
f
|
|
303
306
|
]
|
|
304
307
|
}), N = p("div", {
|
|
305
308
|
className: "error-message",
|
|
@@ -314,36 +317,36 @@ const $ = ({ label: n, maskType: e, id: t, name: a, type: r = "text", placeholde
|
|
|
314
317
|
className: "custom-input-group",
|
|
315
318
|
children: [
|
|
316
319
|
s,
|
|
317
|
-
|
|
320
|
+
y,
|
|
318
321
|
N
|
|
319
322
|
]
|
|
320
323
|
}),
|
|
321
|
-
setLoading: (
|
|
322
|
-
|
|
323
|
-
dataset: { loading:
|
|
324
|
-
}),
|
|
325
|
-
attributes: { disabled:
|
|
326
|
-
}),
|
|
327
|
-
dataset: { show:
|
|
324
|
+
setLoading: (w) => {
|
|
325
|
+
C({ element: y }, {
|
|
326
|
+
dataset: { loading: w ? "true" : "false" }
|
|
327
|
+
}), C({ element: h }, {
|
|
328
|
+
attributes: { disabled: w ? "true" : "false" }
|
|
329
|
+
}), C({ element: b }, {
|
|
330
|
+
dataset: { show: w ? "true" : "false" }
|
|
328
331
|
});
|
|
329
332
|
},
|
|
330
|
-
setError: (
|
|
331
|
-
|
|
332
|
-
className:
|
|
333
|
-
}),
|
|
334
|
-
dataset: { show:
|
|
333
|
+
setError: (w = "") => {
|
|
334
|
+
C({ element: y }, {
|
|
335
|
+
className: w && o ? { add: "input-error" } : { remove: "input-error" }
|
|
336
|
+
}), C({ element: N }, {
|
|
337
|
+
dataset: { show: w && o ? "true" : "false" },
|
|
335
338
|
innerHTML: `
|
|
336
339
|
${k}
|
|
337
|
-
<span>${
|
|
340
|
+
<span>${w || ""}</span>
|
|
338
341
|
`
|
|
339
342
|
});
|
|
340
343
|
}
|
|
341
344
|
};
|
|
342
|
-
},
|
|
343
|
-
const { method:
|
|
345
|
+
}, ce = async (t, n = {}) => {
|
|
346
|
+
const { method: e = "GET", headers: a = {}, body: i = null, ...m } = n;
|
|
344
347
|
try {
|
|
345
|
-
const
|
|
346
|
-
method:
|
|
348
|
+
const l = {
|
|
349
|
+
method: e,
|
|
347
350
|
headers: {
|
|
348
351
|
Accept: "*/*",
|
|
349
352
|
"Content-Type": "application/json",
|
|
@@ -351,87 +354,87 @@ const $ = ({ label: n, maskType: e, id: t, name: a, type: r = "text", placeholde
|
|
|
351
354
|
},
|
|
352
355
|
...m
|
|
353
356
|
};
|
|
354
|
-
|
|
355
|
-
const
|
|
357
|
+
i && ["POST", "PUT", "PATCH", "DELETE"].includes(e.toUpperCase()) && (l.body = typeof i == "string" ? i : JSON.stringify(i));
|
|
358
|
+
const r = await fetch(t, l), u = r.headers.get("content-type");
|
|
356
359
|
let s;
|
|
357
|
-
if (
|
|
360
|
+
if (u?.includes("application/json") ? s = await r.json() : s = await r.text(), !r.ok) {
|
|
358
361
|
const o = s;
|
|
359
362
|
throw new Error(
|
|
360
|
-
o?.message || `HTTP error! status: ${
|
|
363
|
+
o?.message || `HTTP error! status: ${r.status}`
|
|
361
364
|
);
|
|
362
365
|
}
|
|
363
366
|
return { data: s, error: null };
|
|
364
|
-
} catch (
|
|
365
|
-
return { data: null, error:
|
|
367
|
+
} catch (l) {
|
|
368
|
+
return { data: null, error: l instanceof Error ? l.message : "An error occurred" };
|
|
366
369
|
}
|
|
367
|
-
},
|
|
368
|
-
title:
|
|
369
|
-
children:
|
|
370
|
-
onClose:
|
|
370
|
+
}, de = ({
|
|
371
|
+
title: t = "",
|
|
372
|
+
children: n,
|
|
373
|
+
onClose: e,
|
|
371
374
|
showBackBtn: a = !1,
|
|
372
|
-
showCloseBtn:
|
|
375
|
+
showCloseBtn: i = !0
|
|
373
376
|
}) => {
|
|
374
377
|
const m = p("button", {
|
|
375
378
|
className: "back-btn",
|
|
376
|
-
innerHTML:
|
|
379
|
+
innerHTML: ne,
|
|
377
380
|
dataset: { show: String(a) },
|
|
378
|
-
events: { click: () =>
|
|
379
|
-
}),
|
|
380
|
-
textContent:
|
|
381
|
-
}),
|
|
381
|
+
events: { click: () => d() }
|
|
382
|
+
}), l = p("h3", {
|
|
383
|
+
textContent: t
|
|
384
|
+
}), r = p("button", {
|
|
382
385
|
className: "close-btn",
|
|
383
386
|
innerHTML: "×",
|
|
384
|
-
dataset: { show: String(
|
|
387
|
+
dataset: { show: String(i) },
|
|
385
388
|
attributes: { "aria-label": "Close modal" },
|
|
386
|
-
events: { click: () =>
|
|
387
|
-
}),
|
|
389
|
+
events: { click: () => d() }
|
|
390
|
+
}), u = p("div", {
|
|
388
391
|
className: "modal-header",
|
|
389
|
-
children: [m,
|
|
392
|
+
children: [m, l, r]
|
|
390
393
|
}), s = p("div", {
|
|
391
394
|
className: "modal-content",
|
|
392
|
-
children: [
|
|
395
|
+
children: [n]
|
|
393
396
|
}), o = p("dialog", {
|
|
394
397
|
className: "custom-modal",
|
|
395
|
-
children: [
|
|
398
|
+
children: [u, s],
|
|
396
399
|
events: {
|
|
397
|
-
cancel: (
|
|
398
|
-
|
|
400
|
+
cancel: (c) => {
|
|
401
|
+
c.preventDefault(), d();
|
|
399
402
|
}
|
|
400
403
|
}
|
|
401
|
-
}),
|
|
402
|
-
o.close(),
|
|
404
|
+
}), d = () => {
|
|
405
|
+
o.close(), e?.();
|
|
403
406
|
};
|
|
404
407
|
return {
|
|
405
408
|
element: o,
|
|
406
|
-
setModalVisibility: (
|
|
407
|
-
|
|
409
|
+
setModalVisibility: (c) => {
|
|
410
|
+
c ? o.showModal() : o.close();
|
|
408
411
|
}
|
|
409
412
|
};
|
|
410
|
-
},
|
|
411
|
-
const m =
|
|
413
|
+
}, ue = ({ token: t, endpoint: n, beneficiaryCard: e = !1, isModal: a = !1, onCallback: i = () => null }) => {
|
|
414
|
+
const m = e ? "Enter Recipient Debit Card Details" : "Enter Your Debit Card Details", l = e ? "Enter the debit card details of the recipient you're sending funds to." : "Linking an external account allows you to send and receive money to your account.", r = e ? "Debit Card Number" : "Your Debit Card Number", u = e ? "Enter recipient's card number" : "Enter your card number", s = `add-card-form-wrapper${e ? " recipient-form" : ""}`, o = {
|
|
412
415
|
cardNumber: "",
|
|
413
416
|
expiryDate: "",
|
|
414
417
|
cvv: "",
|
|
415
418
|
zipCode: ""
|
|
416
|
-
}, { element:
|
|
417
|
-
label:
|
|
418
|
-
placeholder:
|
|
419
|
+
}, { element: d, setError: h } = $({
|
|
420
|
+
label: r,
|
|
421
|
+
placeholder: u,
|
|
419
422
|
id: "card-number-input",
|
|
420
423
|
name: "cardNumber",
|
|
421
424
|
maskType: "card",
|
|
422
|
-
onChange(
|
|
423
|
-
L("cardNumber",
|
|
425
|
+
onChange(g) {
|
|
426
|
+
L("cardNumber", g, h);
|
|
424
427
|
}
|
|
425
|
-
}), { element:
|
|
428
|
+
}), { element: c, setError: v } = $({
|
|
426
429
|
label: "Expiration Date",
|
|
427
430
|
placeholder: "MM/YY",
|
|
428
431
|
id: "expiry-input",
|
|
429
432
|
name: "expiryDate",
|
|
430
433
|
maskType: "expiry",
|
|
431
|
-
onChange(
|
|
432
|
-
L("expiryDate",
|
|
434
|
+
onChange(g) {
|
|
435
|
+
L("expiryDate", g, v);
|
|
433
436
|
}
|
|
434
|
-
}), { element:
|
|
437
|
+
}), { element: b, setError: f } = $({
|
|
435
438
|
label: "CVV",
|
|
436
439
|
placeholder: "3-Digit",
|
|
437
440
|
type: "number",
|
|
@@ -439,90 +442,88 @@ const $ = ({ label: n, maskType: e, id: t, name: a, type: r = "text", placeholde
|
|
|
439
442
|
id: "cvv-input",
|
|
440
443
|
name: "cvv",
|
|
441
444
|
tooltip: "A CVV is a 3-digit number on your debit card. You can find it on the back side of the card.",
|
|
442
|
-
onChange(
|
|
443
|
-
L("cvv",
|
|
445
|
+
onChange(g) {
|
|
446
|
+
L("cvv", g, f);
|
|
444
447
|
}
|
|
445
|
-
}), { element:
|
|
448
|
+
}), { element: y, setError: N } = $({
|
|
446
449
|
label: "ZIP Code",
|
|
447
|
-
placeholder:
|
|
450
|
+
placeholder: e ? "ZIP Code" : "Enter your ZIP Code",
|
|
448
451
|
id: "zip-input",
|
|
449
452
|
name: "zipCode",
|
|
450
453
|
maskType: "zip",
|
|
451
|
-
onChange(
|
|
452
|
-
L("zipCode",
|
|
454
|
+
onChange(g) {
|
|
455
|
+
L("zipCode", g, N);
|
|
453
456
|
}
|
|
454
|
-
}),
|
|
455
|
-
className:
|
|
456
|
-
children: [
|
|
457
|
+
}), D = p("div", {
|
|
458
|
+
className: e ? "input-sections" : "inputs",
|
|
459
|
+
children: [d, c, b, y]
|
|
457
460
|
}), A = p("p", {
|
|
458
461
|
className: "submit-error",
|
|
459
462
|
dataset: { show: "false" }
|
|
460
463
|
// innerHTML: `//icon`
|
|
461
|
-
}), { element: j, setDisabled:
|
|
464
|
+
}), { element: j, setDisabled: w, setLoading: T } = se({
|
|
462
465
|
children: "Link Card",
|
|
463
466
|
type: "submit",
|
|
464
467
|
disabled: !0
|
|
465
|
-
}),
|
|
466
|
-
|
|
467
|
-
dataset: { show: String(!!
|
|
468
|
+
}), S = (g = "") => {
|
|
469
|
+
C({ element: A }, {
|
|
470
|
+
dataset: { show: String(!!g) },
|
|
468
471
|
innerHTML: `
|
|
469
472
|
${k}
|
|
470
|
-
${
|
|
473
|
+
${g || ""}
|
|
471
474
|
`
|
|
472
475
|
});
|
|
473
|
-
}, B = (
|
|
474
|
-
|
|
476
|
+
}, B = (g = !0) => {
|
|
477
|
+
w(g), T(g);
|
|
475
478
|
};
|
|
476
|
-
function L(
|
|
477
|
-
o[
|
|
478
|
-
const { isValid: I, errors:
|
|
479
|
-
|
|
479
|
+
function L(g, H, E) {
|
|
480
|
+
o[g] = H;
|
|
481
|
+
const { isValid: I, errors: x } = oe(o, e);
|
|
482
|
+
x[g] ? E(x[g]) : E(""), w(!I);
|
|
480
483
|
}
|
|
481
484
|
const O = p("div", {
|
|
482
485
|
className: "submit-button-wrapper",
|
|
483
486
|
children: [A, j]
|
|
484
487
|
});
|
|
485
|
-
async function P(
|
|
486
|
-
|
|
487
|
-
const H = new FormData(
|
|
488
|
-
|
|
489
|
-
const
|
|
490
|
-
B(!0), z("");
|
|
491
|
-
const C = await de(e, {
|
|
488
|
+
async function P(g) {
|
|
489
|
+
g.preventDefault();
|
|
490
|
+
const H = new FormData(g.target), E = Object.fromEntries(H.entries()), I = E?.cardNumber ? V(E?.cardNumber) : null, x = E?.expiryDate || null, _ = E?.cvv ? V(E?.cvv) : null, G = E?.zipCode ? V(E?.zipCode) : null, K = x ? Number(x?.split("/")[0]) : null, U = x ? ae(x?.split("/")[1]) : null;
|
|
491
|
+
B(!0), S("");
|
|
492
|
+
const M = await ce(n, {
|
|
492
493
|
method: "POST",
|
|
493
494
|
body: {
|
|
494
|
-
token:
|
|
495
|
-
pan:
|
|
495
|
+
token: t,
|
|
496
|
+
pan: I,
|
|
496
497
|
expiry_month: K,
|
|
497
498
|
expiry_year: U,
|
|
498
|
-
cvv:
|
|
499
|
+
cvv: _,
|
|
499
500
|
address: {
|
|
500
|
-
postal_code:
|
|
501
|
+
postal_code: G
|
|
501
502
|
}
|
|
502
503
|
}
|
|
503
504
|
});
|
|
504
|
-
|
|
505
|
+
M.error ? (console.error("Request failed:", M.error), B(!1), S(M.error), i?.({ success: !1, error: M.error })) : (console.log("Request success:", M.data), B(!1), i?.({ success: !0, data: M.data }));
|
|
505
506
|
}
|
|
506
507
|
const Z = () => p("form", {
|
|
507
508
|
events: {
|
|
508
509
|
submit: P
|
|
509
510
|
},
|
|
510
511
|
children: [
|
|
511
|
-
|
|
512
|
+
D,
|
|
512
513
|
O
|
|
513
514
|
]
|
|
514
515
|
}), W = () => p("div", {
|
|
515
516
|
className: "form-title",
|
|
516
517
|
innerHTML: `
|
|
517
|
-
<p>${
|
|
518
|
+
<p>${l}</p>
|
|
518
519
|
|
|
519
520
|
<div>
|
|
520
|
-
${
|
|
521
|
+
${ee}
|
|
521
522
|
|
|
522
523
|
<span>Secured with 256-bit encryption</span>
|
|
523
524
|
</div>
|
|
524
525
|
`
|
|
525
|
-
}),
|
|
526
|
+
}), z = () => p("div", {
|
|
526
527
|
className: a ? "" : "non-modal-content",
|
|
527
528
|
children: [W(), Z()]
|
|
528
529
|
}), R = a ? null : p("div", {
|
|
@@ -536,75 +537,75 @@ const $ = ({ label: n, maskType: e, id: t, name: a, type: r = "text", placeholde
|
|
|
536
537
|
<span></span>
|
|
537
538
|
`
|
|
538
539
|
}),
|
|
539
|
-
|
|
540
|
+
z()
|
|
540
541
|
]
|
|
541
|
-
}), { element:
|
|
542
|
+
}), { element: Y, setModalVisibility: F } = a ? de({ title: m, children: z() }) : { element: null, setModalVisibility: () => {
|
|
542
543
|
} };
|
|
543
544
|
function q() {
|
|
544
|
-
|
|
545
|
+
Y && (document.body.appendChild(
|
|
545
546
|
p("div", {
|
|
546
547
|
className: s,
|
|
547
|
-
children: [
|
|
548
|
+
children: [Y]
|
|
548
549
|
})
|
|
549
|
-
),
|
|
550
|
+
), F(!0));
|
|
550
551
|
}
|
|
551
552
|
return {
|
|
552
553
|
renderFormWithModal: q,
|
|
553
554
|
nonModalForm: R,
|
|
554
|
-
closeModal: () =>
|
|
555
|
+
closeModal: () => F(!1)
|
|
555
556
|
};
|
|
556
557
|
};
|
|
557
|
-
function
|
|
558
|
-
const { renderFormWithModal:
|
|
559
|
-
token:
|
|
560
|
-
endpoint:
|
|
561
|
-
beneficiaryCard:
|
|
558
|
+
function pe({ token: t, endpoint: n, beneficiaryCard: e, isModal: a, onCallback: i, onModalClose: m }) {
|
|
559
|
+
const { renderFormWithModal: l, nonModalForm: r, closeModal: u } = ue({
|
|
560
|
+
token: t,
|
|
561
|
+
endpoint: n,
|
|
562
|
+
beneficiaryCard: e,
|
|
562
563
|
isModal: a,
|
|
563
|
-
onCallback:
|
|
564
|
+
onCallback: i
|
|
564
565
|
});
|
|
565
566
|
return {
|
|
566
567
|
mount(s) {
|
|
567
568
|
const o = "className" in s ? document.querySelector(s.className) : "id" in s ? document.getElementById(s.id) : s.element;
|
|
568
|
-
o &&
|
|
569
|
+
o && r && o.appendChild(r);
|
|
569
570
|
},
|
|
570
571
|
open() {
|
|
571
|
-
|
|
572
|
+
l();
|
|
572
573
|
},
|
|
573
574
|
destroy() {
|
|
574
|
-
|
|
575
|
+
u(), m?.();
|
|
575
576
|
}
|
|
576
577
|
};
|
|
577
578
|
}
|
|
578
|
-
function
|
|
579
|
-
token:
|
|
580
|
-
endpoint:
|
|
581
|
-
isModal:
|
|
579
|
+
function fe({
|
|
580
|
+
token: t,
|
|
581
|
+
endpoint: n,
|
|
582
|
+
isModal: e = !1,
|
|
582
583
|
beneficiaryCard: a = !1,
|
|
583
|
-
isOpen:
|
|
584
|
+
isOpen: i = !1,
|
|
584
585
|
onCallback: m = () => null,
|
|
585
|
-
onClose:
|
|
586
|
+
onClose: l = () => null
|
|
586
587
|
}) {
|
|
587
|
-
const
|
|
588
|
-
return
|
|
589
|
-
let
|
|
590
|
-
token:
|
|
591
|
-
endpoint:
|
|
588
|
+
const r = Q(null);
|
|
589
|
+
return X(() => {
|
|
590
|
+
let u = pe({
|
|
591
|
+
token: t,
|
|
592
|
+
endpoint: n,
|
|
592
593
|
beneficiaryCard: a,
|
|
593
|
-
isModal:
|
|
594
|
+
isModal: e,
|
|
594
595
|
onCallback: m,
|
|
595
|
-
onModalClose:
|
|
596
|
+
onModalClose: l
|
|
596
597
|
});
|
|
597
|
-
if (
|
|
598
|
-
|
|
598
|
+
if (e)
|
|
599
|
+
i ? u.open() : u.destroy();
|
|
599
600
|
else {
|
|
600
|
-
if (!
|
|
601
|
-
|
|
601
|
+
if (!r?.current) return;
|
|
602
|
+
u.mount({ element: r.current });
|
|
602
603
|
}
|
|
603
604
|
return () => {
|
|
604
|
-
|
|
605
|
+
u.destroy();
|
|
605
606
|
};
|
|
606
|
-
}, [t, n,
|
|
607
|
+
}, [e, t, n, a, i]), e ? null : /* @__PURE__ */ J("div", { ref: r });
|
|
607
608
|
}
|
|
608
609
|
export {
|
|
609
|
-
|
|
610
|
+
fe as AddCard
|
|
610
611
|
};
|