@test-glide/glide-payment 0.0.2 → 0.0.3
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/README.md +233 -0
- package/dist/index.cjs.js +9 -9
- package/dist/index.es.js +153 -153
- package/dist/index.umd.js +9 -9
- package/dist/react/react.cjs.js +9 -9
- package/dist/react/react.es.js +147 -145
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
function
|
|
2
|
-
const t = document.createElement(n), { className: l, id:
|
|
1
|
+
function u(n, e = {}) {
|
|
2
|
+
const t = document.createElement(n), { className: l, id: a, innerHTML: h, textContent: i, attributes: c, styles: p, dataset: s, children: r, events: m } = e;
|
|
3
3
|
if (l) {
|
|
4
|
-
const
|
|
5
|
-
t.classList.add(...
|
|
4
|
+
const d = Array.isArray(l) ? l : l.split(" ");
|
|
5
|
+
t.classList.add(...d.filter(Boolean));
|
|
6
6
|
}
|
|
7
|
-
if (
|
|
8
|
-
for (const [
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
for (const [
|
|
12
|
-
t.style[
|
|
13
|
-
if (
|
|
14
|
-
for (const [
|
|
15
|
-
t.dataset[
|
|
16
|
-
if (
|
|
17
|
-
for (const [
|
|
18
|
-
t.addEventListener(
|
|
7
|
+
if (a && (t.id = a), h && (t.innerHTML = h), i && (t.textContent = i), c)
|
|
8
|
+
for (const [d, o] of Object.entries(c))
|
|
9
|
+
o && t.setAttribute(d, o);
|
|
10
|
+
if (p)
|
|
11
|
+
for (const [d, o] of Object.entries(p))
|
|
12
|
+
t.style[d] = o;
|
|
13
|
+
if (s)
|
|
14
|
+
for (const [d, o] of Object.entries(s))
|
|
15
|
+
t.dataset[d] = o;
|
|
16
|
+
if (r && t.append(...r.filter(Boolean)), m)
|
|
17
|
+
for (const [d, o] of Object.entries(m))
|
|
18
|
+
t.addEventListener(d, o);
|
|
19
19
|
return t;
|
|
20
20
|
}
|
|
21
21
|
function x(n, e) {
|
|
@@ -25,25 +25,25 @@ function x(n, e) {
|
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
27
|
for (const l of t) {
|
|
28
|
-
const { styles:
|
|
29
|
-
if (
|
|
30
|
-
for (const [
|
|
31
|
-
l.style[
|
|
28
|
+
const { styles: a, attributes: h, dataset: i, innerHTML: c, textContent: p, className: s } = e;
|
|
29
|
+
if (a)
|
|
30
|
+
for (const [r, m] of Object.entries(a))
|
|
31
|
+
l.style[r] = m;
|
|
32
32
|
if (h)
|
|
33
|
-
for (const [
|
|
34
|
-
l.setAttribute(
|
|
35
|
-
if (
|
|
36
|
-
for (const [
|
|
37
|
-
l.dataset[
|
|
38
|
-
if (c !== void 0 && (l.innerHTML = c),
|
|
39
|
-
const
|
|
40
|
-
l.classList.add(...
|
|
33
|
+
for (const [r, m] of Object.entries(h))
|
|
34
|
+
l.setAttribute(r, m);
|
|
35
|
+
if (i)
|
|
36
|
+
for (const [r, m] of Object.entries(i))
|
|
37
|
+
l.dataset[r] = m;
|
|
38
|
+
if (c !== void 0 && (l.innerHTML = c), p !== void 0 && (l.textContent = p), s?.add) {
|
|
39
|
+
const r = Array.isArray(s.add) ? s.add : [s.add];
|
|
40
|
+
l.classList.add(...r);
|
|
41
41
|
}
|
|
42
|
-
if (
|
|
43
|
-
const
|
|
44
|
-
l.classList.remove(...
|
|
42
|
+
if (s?.remove) {
|
|
43
|
+
const r = Array.isArray(s.remove) ? s.remove : [s.remove];
|
|
44
|
+
l.classList.remove(...r);
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
s?.toggle && (Array.isArray(s.toggle) ? s.toggle : [s.toggle]).forEach((m) => l.classList.toggle(m));
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
const Q = `
|
|
@@ -93,21 +93,21 @@ const Q = `
|
|
|
93
93
|
></path>
|
|
94
94
|
</svg>`, k = `
|
|
95
95
|
<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>
|
|
96
|
-
`, te = ({ children: n, onClick: e, disabled: t = !1, size: l = "medium", type:
|
|
97
|
-
const c =
|
|
96
|
+
`, te = ({ children: n, onClick: e, disabled: t = !1, size: l = "medium", type: a = "button", className: h = "", variant: i = "primary" }) => {
|
|
97
|
+
const c = u("span", {
|
|
98
98
|
className: "button-spinner",
|
|
99
99
|
innerHTML: X,
|
|
100
100
|
dataset: { show: "false" }
|
|
101
|
-
}),
|
|
101
|
+
}), p = u("span", {
|
|
102
102
|
className: "button-label",
|
|
103
103
|
children: [
|
|
104
104
|
null
|
|
105
105
|
],
|
|
106
106
|
textContent: n
|
|
107
|
-
}),
|
|
108
|
-
className: `custom-button ${
|
|
107
|
+
}), s = u("button", {
|
|
108
|
+
className: `custom-button ${i} ${l} ${h}`,
|
|
109
109
|
attributes: {
|
|
110
|
-
type:
|
|
110
|
+
type: a,
|
|
111
111
|
...t ? { disabled: "true" } : {}
|
|
112
112
|
},
|
|
113
113
|
events: {
|
|
@@ -115,23 +115,23 @@ const Q = `
|
|
|
115
115
|
},
|
|
116
116
|
children: [
|
|
117
117
|
c,
|
|
118
|
-
|
|
118
|
+
p
|
|
119
119
|
]
|
|
120
|
-
}),
|
|
120
|
+
}), r = (d = !1) => {
|
|
121
121
|
x({ element: c }, {
|
|
122
|
-
dataset: { show: String(
|
|
123
|
-
}), m(
|
|
124
|
-
}, m = (
|
|
125
|
-
|
|
122
|
+
dataset: { show: String(d) }
|
|
123
|
+
}), m(d);
|
|
124
|
+
}, m = (d = !1) => {
|
|
125
|
+
d ? s.setAttribute("disabled", "true") : s.removeAttribute("disabled");
|
|
126
126
|
};
|
|
127
127
|
return {
|
|
128
|
-
element:
|
|
129
|
-
setLoading:
|
|
128
|
+
element: s,
|
|
129
|
+
setLoading: r,
|
|
130
130
|
setDisabled: m
|
|
131
131
|
};
|
|
132
|
-
}, ne = ({ content: n, position: e = "top", delay: t = 200, maxWidth: l = 250, className:
|
|
133
|
-
var
|
|
134
|
-
className: `tooltip ${e} ${
|
|
132
|
+
}, ne = ({ content: n, position: e = "top", delay: t = 200, maxWidth: l = 250, className: a = "", id: h = "" }) => {
|
|
133
|
+
var i = u("div", {
|
|
134
|
+
className: `tooltip ${e} ${a}`,
|
|
135
135
|
styles: {
|
|
136
136
|
// top: `${tooltipPosition.top}px`,
|
|
137
137
|
// left: `${tooltipPosition.left}px`,
|
|
@@ -147,71 +147,71 @@ const Q = `
|
|
|
147
147
|
`
|
|
148
148
|
});
|
|
149
149
|
let c = null;
|
|
150
|
-
var
|
|
150
|
+
var r = u("span", {
|
|
151
151
|
className: "tooltip-trigger",
|
|
152
152
|
innerHTML: k,
|
|
153
153
|
events: {
|
|
154
154
|
mouseenter: () => {
|
|
155
155
|
t > 0 ? c = window.setTimeout(() => {
|
|
156
|
-
|
|
157
|
-
}, t) : (
|
|
156
|
+
i.dataset.show = "true", m();
|
|
157
|
+
}, t) : (i.dataset.show = "true", m());
|
|
158
158
|
},
|
|
159
159
|
mouseleave: () => {
|
|
160
|
-
c && clearTimeout(c),
|
|
160
|
+
c && clearTimeout(c), i.dataset.show = "false";
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
});
|
|
164
164
|
function m() {
|
|
165
|
-
if (!
|
|
166
|
-
const
|
|
165
|
+
if (!r || !i) return;
|
|
166
|
+
const o = r.getBoundingClientRect(), v = i.getBoundingClientRect(), y = 8;
|
|
167
167
|
let w, g;
|
|
168
168
|
switch (e) {
|
|
169
169
|
case "top":
|
|
170
|
-
w =
|
|
170
|
+
w = o.top - v.height - y, g = o.left + o.width / 2 - v.width / 2;
|
|
171
171
|
break;
|
|
172
172
|
case "bottom":
|
|
173
|
-
w =
|
|
173
|
+
w = o.bottom + y, g = o.left + o.width / 2 - v.width / 2;
|
|
174
174
|
break;
|
|
175
175
|
case "left":
|
|
176
|
-
w =
|
|
176
|
+
w = o.top + o.height / 2 - v.height / 2, g = o.left - v.width - y;
|
|
177
177
|
break;
|
|
178
178
|
case "right":
|
|
179
|
-
w =
|
|
179
|
+
w = o.top + o.height / 2 - v.height / 2, g = o.right + y;
|
|
180
180
|
break;
|
|
181
181
|
default:
|
|
182
|
-
w =
|
|
182
|
+
w = o.top - v.height - y, g = o.left + o.width / 2 - v.width / 2;
|
|
183
183
|
}
|
|
184
184
|
const N = window.innerWidth, M = window.innerHeight;
|
|
185
|
-
g < 0 && (g = y), g + v.width > N && (g = N - v.width - y), w < 0 && (w = y), w + v.height > M && (w = M - v.height - y),
|
|
185
|
+
g < 0 && (g = y), g + v.width > N && (g = N - v.width - y), w < 0 && (w = y), w + v.height > M && (w = M - v.height - y), i.style.top = `${w}px`, i.style.left = `${g}px`;
|
|
186
186
|
}
|
|
187
|
-
return
|
|
187
|
+
return u("div", {
|
|
188
188
|
className: "tooltip-wrapper",
|
|
189
189
|
id: `tooltip-${h}`,
|
|
190
190
|
children: [
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
r,
|
|
192
|
+
i
|
|
193
193
|
]
|
|
194
194
|
});
|
|
195
195
|
}, se = (n) => {
|
|
196
196
|
const e = {}, t = Object.values(n).every(
|
|
197
|
-
(
|
|
197
|
+
(a) => !a || a.trim() === ""
|
|
198
198
|
), l = n.cardNumber?.replace(/\s/g, "");
|
|
199
199
|
if (l ? /^\d{13,19}$/.test(l) || (e.cardNumber = "Card number must be 13-19 digits") : e.cardNumber = "Card number is required", !n.expiryDate)
|
|
200
200
|
e.expiryDate = "Expiry date is required";
|
|
201
201
|
else {
|
|
202
|
-
const
|
|
203
|
-
if (
|
|
202
|
+
const a = n.expiryDate.replace(/\D/g, "");
|
|
203
|
+
if (a.length < 4)
|
|
204
204
|
e.expiryDate = "Enter complete expiry date (MM/YY)";
|
|
205
205
|
else {
|
|
206
|
-
const h = parseInt(
|
|
206
|
+
const h = parseInt(a.substring(0, 2), 10), i = parseInt(a.substring(2, 4), 10);
|
|
207
207
|
if (isNaN(h) || h < 1 || h > 12)
|
|
208
208
|
e.expiryDate = "Invalid month (must be 01-12)";
|
|
209
|
-
else if (isNaN(
|
|
209
|
+
else if (isNaN(i) || i < 0 || i > 99)
|
|
210
210
|
e.expiryDate = "Invalid year";
|
|
211
211
|
else {
|
|
212
|
-
const c = /* @__PURE__ */ new Date(),
|
|
213
|
-
let
|
|
214
|
-
m >=
|
|
212
|
+
const c = /* @__PURE__ */ new Date(), p = c.getFullYear(), s = c.getMonth() + 1, r = Math.floor(p / 100) * 100, m = r + i, d = r + 100 + i;
|
|
213
|
+
let o;
|
|
214
|
+
m >= p && m <= p + 20 ? o = m : (d >= p && d <= p + 20, o = d), o < p || o === p && h < s ? e.expiryDate = "Card has expired" : o > p + 20 && (e.expiryDate = "Expiry year is too far in the future");
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
}
|
|
@@ -225,8 +225,8 @@ function re(n) {
|
|
|
225
225
|
const e = parseInt(n, 10);
|
|
226
226
|
if (isNaN(e) || e < 0 || e > 99) return null;
|
|
227
227
|
const t = (/* @__PURE__ */ new Date()).getFullYear(), l = Math.floor(t / 100) * 100;
|
|
228
|
-
let
|
|
229
|
-
return
|
|
228
|
+
let a = l + e;
|
|
229
|
+
return a >= t && a <= t + 20 || (a = l + 100 + e, a >= t && a <= t + 20) ? a : l + 100 + e;
|
|
230
230
|
}
|
|
231
231
|
function V(n = "") {
|
|
232
232
|
return n.trim().replaceAll(/\s/g, "").replaceAll("-", "");
|
|
@@ -250,56 +250,56 @@ const oe = {
|
|
|
250
250
|
function ae(n, e) {
|
|
251
251
|
return e === "none" ? n : oe[e](n);
|
|
252
252
|
}
|
|
253
|
-
const $ = ({ label: n, maskType: e, id: t, name: l, type:
|
|
254
|
-
const
|
|
253
|
+
const $ = ({ label: n, maskType: e, id: t, name: l, type: a = "text", placeholder: h = "Enter value", tooltip: i = "", onChange: c }) => {
|
|
254
|
+
const p = ["card", "expiry", "phone", "cvv", "zip"].includes(e) ? "numeric" : "", s = u("label", {
|
|
255
255
|
className: "input-label",
|
|
256
256
|
innerHTML: n,
|
|
257
257
|
attributes: {
|
|
258
258
|
for: t
|
|
259
259
|
}
|
|
260
260
|
});
|
|
261
|
-
let
|
|
262
|
-
const
|
|
261
|
+
let r = !1;
|
|
262
|
+
const d = u("input", {
|
|
263
263
|
id: t || "input-id",
|
|
264
264
|
className: "styled-input",
|
|
265
265
|
attributes: {
|
|
266
266
|
placeholder: h,
|
|
267
|
-
type:
|
|
268
|
-
inputMode:
|
|
267
|
+
type: a,
|
|
268
|
+
inputMode: p,
|
|
269
269
|
name: l
|
|
270
270
|
},
|
|
271
271
|
events: {
|
|
272
|
-
input:
|
|
272
|
+
input: o,
|
|
273
273
|
blur: v,
|
|
274
274
|
keydown: (b) => {
|
|
275
|
-
b.key === "Enter" && (
|
|
275
|
+
b.key === "Enter" && (r = !0);
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
278
|
});
|
|
279
|
-
function
|
|
279
|
+
function o(b) {
|
|
280
280
|
const D = e !== "none" ? ae(b?.target?.value, e) : b?.target?.value;
|
|
281
|
-
|
|
281
|
+
d.value = D, c?.(D);
|
|
282
282
|
}
|
|
283
283
|
function v() {
|
|
284
|
-
|
|
284
|
+
r = !0, c?.(d?.value || "");
|
|
285
285
|
}
|
|
286
|
-
const y =
|
|
286
|
+
const y = u("div", {
|
|
287
287
|
className: "input-loader",
|
|
288
288
|
innerHTML: '<div class="loader"></div>',
|
|
289
289
|
dataset: { show: "false" }
|
|
290
|
-
}), w =
|
|
290
|
+
}), w = i ? u("div", {
|
|
291
291
|
className: "input-right-element",
|
|
292
292
|
children: [
|
|
293
|
-
ne({ content:
|
|
293
|
+
ne({ content: i, id: t })
|
|
294
294
|
]
|
|
295
|
-
}) : null, g =
|
|
295
|
+
}) : null, g = u("div", {
|
|
296
296
|
className: "input-wrapper",
|
|
297
297
|
children: [
|
|
298
|
-
|
|
298
|
+
d,
|
|
299
299
|
y,
|
|
300
300
|
w
|
|
301
301
|
]
|
|
302
|
-
}), N =
|
|
302
|
+
}), N = u("div", {
|
|
303
303
|
className: "error-message",
|
|
304
304
|
dataset: { show: "false" },
|
|
305
305
|
innerHTML: `
|
|
@@ -308,10 +308,10 @@ const $ = ({ label: n, maskType: e, id: t, name: l, type: r = "text", placeholde
|
|
|
308
308
|
`
|
|
309
309
|
});
|
|
310
310
|
return {
|
|
311
|
-
element:
|
|
311
|
+
element: u("div", {
|
|
312
312
|
className: "custom-input-group",
|
|
313
313
|
children: [
|
|
314
|
-
|
|
314
|
+
s,
|
|
315
315
|
g,
|
|
316
316
|
N
|
|
317
317
|
]
|
|
@@ -319,7 +319,7 @@ const $ = ({ label: n, maskType: e, id: t, name: l, type: r = "text", placeholde
|
|
|
319
319
|
setLoading: (b) => {
|
|
320
320
|
x({ element: g }, {
|
|
321
321
|
dataset: { loading: b ? "true" : "false" }
|
|
322
|
-
}), x({ element:
|
|
322
|
+
}), x({ element: d }, {
|
|
323
323
|
attributes: { disabled: b ? "true" : "false" }
|
|
324
324
|
}), x({ element: y }, {
|
|
325
325
|
dataset: { show: b ? "true" : "false" }
|
|
@@ -327,9 +327,9 @@ const $ = ({ label: n, maskType: e, id: t, name: l, type: r = "text", placeholde
|
|
|
327
327
|
},
|
|
328
328
|
setError: (b = "") => {
|
|
329
329
|
x({ element: g }, {
|
|
330
|
-
className: b &&
|
|
330
|
+
className: b && r ? { add: "input-error" } : { remove: "input-error" }
|
|
331
331
|
}), x({ element: N }, {
|
|
332
|
-
dataset: { show: b &&
|
|
332
|
+
dataset: { show: b && r ? "true" : "false" },
|
|
333
333
|
innerHTML: `
|
|
334
334
|
${k}
|
|
335
335
|
<span>${b || ""}</span>
|
|
@@ -338,9 +338,9 @@ const $ = ({ label: n, maskType: e, id: t, name: l, type: r = "text", placeholde
|
|
|
338
338
|
}
|
|
339
339
|
};
|
|
340
340
|
}, ie = async (n, e = {}) => {
|
|
341
|
-
const { method: t = "GET", headers: l = {}, body:
|
|
341
|
+
const { method: t = "GET", headers: l = {}, body: a = null, ...h } = e;
|
|
342
342
|
try {
|
|
343
|
-
const
|
|
343
|
+
const i = {
|
|
344
344
|
method: t,
|
|
345
345
|
headers: {
|
|
346
346
|
Accept: "*/*",
|
|
@@ -349,78 +349,78 @@ const $ = ({ label: n, maskType: e, id: t, name: l, type: r = "text", placeholde
|
|
|
349
349
|
},
|
|
350
350
|
...h
|
|
351
351
|
};
|
|
352
|
-
|
|
353
|
-
const c = await fetch(n,
|
|
354
|
-
let
|
|
355
|
-
if (
|
|
356
|
-
const
|
|
352
|
+
a && ["POST", "PUT", "PATCH", "DELETE"].includes(t.toUpperCase()) && (i.body = typeof a == "string" ? a : JSON.stringify(a));
|
|
353
|
+
const c = await fetch(n, i), p = c.headers.get("content-type");
|
|
354
|
+
let s;
|
|
355
|
+
if (p?.includes("application/json") ? s = await c.json() : s = await c.text(), !c.ok) {
|
|
356
|
+
const r = s;
|
|
357
357
|
throw new Error(
|
|
358
|
-
|
|
358
|
+
r?.message || `HTTP error! status: ${c.status}`
|
|
359
359
|
);
|
|
360
360
|
}
|
|
361
|
-
return { data:
|
|
362
|
-
} catch (
|
|
363
|
-
return { data: null, error:
|
|
361
|
+
return { data: s, error: null };
|
|
362
|
+
} catch (i) {
|
|
363
|
+
return { data: null, error: i instanceof Error ? i.message : "An error occurred" };
|
|
364
364
|
}
|
|
365
365
|
}, le = ({
|
|
366
366
|
title: n = "",
|
|
367
367
|
children: e,
|
|
368
368
|
onClose: t,
|
|
369
369
|
showBackBtn: l = !1,
|
|
370
|
-
showCloseBtn:
|
|
370
|
+
showCloseBtn: a = !0
|
|
371
371
|
}) => {
|
|
372
|
-
const h =
|
|
372
|
+
const h = u("button", {
|
|
373
373
|
className: "back-btn",
|
|
374
374
|
innerHTML: ee,
|
|
375
375
|
dataset: { show: String(l) },
|
|
376
376
|
events: { click: () => m() }
|
|
377
|
-
}),
|
|
377
|
+
}), i = u("h3", {
|
|
378
378
|
textContent: n
|
|
379
|
-
}), c =
|
|
379
|
+
}), c = u("button", {
|
|
380
380
|
className: "close-btn",
|
|
381
381
|
innerHTML: "×",
|
|
382
|
-
dataset: { show: String(
|
|
382
|
+
dataset: { show: String(a) },
|
|
383
383
|
attributes: { "aria-label": "Close modal" },
|
|
384
384
|
events: { click: () => m() }
|
|
385
|
-
}),
|
|
385
|
+
}), p = u("div", {
|
|
386
386
|
className: "modal-header",
|
|
387
|
-
children: [h,
|
|
388
|
-
}),
|
|
387
|
+
children: [h, i, c]
|
|
388
|
+
}), s = u("div", {
|
|
389
389
|
className: "modal-content",
|
|
390
390
|
children: [e]
|
|
391
|
-
}),
|
|
391
|
+
}), r = u("dialog", {
|
|
392
392
|
className: "custom-modal",
|
|
393
|
-
children: [
|
|
393
|
+
children: [p, s],
|
|
394
394
|
events: {
|
|
395
|
-
cancel: (
|
|
396
|
-
|
|
395
|
+
cancel: (o) => {
|
|
396
|
+
o.preventDefault(), m();
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
}), m = () => {
|
|
400
|
-
|
|
400
|
+
r.close(), t?.();
|
|
401
401
|
};
|
|
402
402
|
return {
|
|
403
|
-
element:
|
|
404
|
-
setModalVisibility: (
|
|
405
|
-
|
|
403
|
+
element: r,
|
|
404
|
+
setModalVisibility: (o) => {
|
|
405
|
+
o ? r.showModal() : r.close();
|
|
406
406
|
}
|
|
407
407
|
};
|
|
408
|
-
}, ce = ({ token: n, endpoint: e, beneficiaryCard: t = !1, isModal: l = !1, onCallback:
|
|
409
|
-
const h = t ? "Enter Recipient Debit Card Details" : "Enter Your Debit Card Details",
|
|
408
|
+
}, ce = ({ token: n, endpoint: e, beneficiaryCard: t = !1, isModal: l = !1, onCallback: a = () => null }) => {
|
|
409
|
+
const h = t ? "Enter Recipient Debit Card Details" : "Enter Your Debit Card Details", i = t ? "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.", c = t ? "Debit Card Number" : "Your Debit Card Number", p = t ? "Enter recipient's card number" : "Enter your card number", s = `add-card-form-wrapper${t ? " recipient-form" : ""}`, r = {
|
|
410
410
|
cardNumber: "",
|
|
411
411
|
expiryDate: "",
|
|
412
412
|
cvv: "",
|
|
413
413
|
zipCode: ""
|
|
414
|
-
}, { element: m, setError:
|
|
414
|
+
}, { element: m, setError: d } = $({
|
|
415
415
|
label: c,
|
|
416
|
-
placeholder:
|
|
416
|
+
placeholder: p,
|
|
417
417
|
id: "card-number-input",
|
|
418
418
|
name: "cardNumber",
|
|
419
419
|
maskType: "card",
|
|
420
420
|
onChange(f) {
|
|
421
|
-
L("cardNumber", f,
|
|
421
|
+
L("cardNumber", f, d);
|
|
422
422
|
}
|
|
423
|
-
}), { element:
|
|
423
|
+
}), { element: o, setError: v } = $({
|
|
424
424
|
label: "Expiration Date",
|
|
425
425
|
placeholder: "MM/YY",
|
|
426
426
|
id: "expiry-input",
|
|
@@ -449,10 +449,10 @@ const $ = ({ label: n, maskType: e, id: t, name: l, type: r = "text", placeholde
|
|
|
449
449
|
onChange(f) {
|
|
450
450
|
L("zipCode", f, N);
|
|
451
451
|
}
|
|
452
|
-
}), M =
|
|
452
|
+
}), M = u("div", {
|
|
453
453
|
className: t ? "input-sections" : "inputs",
|
|
454
|
-
children: [m,
|
|
455
|
-
}), A =
|
|
454
|
+
children: [m, o, y, g]
|
|
455
|
+
}), A = u("p", {
|
|
456
456
|
className: "submit-error",
|
|
457
457
|
dataset: { show: "false" }
|
|
458
458
|
// innerHTML: `//icon`
|
|
@@ -472,11 +472,11 @@ const $ = ({ label: n, maskType: e, id: t, name: l, type: r = "text", placeholde
|
|
|
472
472
|
b(f), D(f);
|
|
473
473
|
};
|
|
474
474
|
function L(f, H, E) {
|
|
475
|
-
|
|
476
|
-
const { isValid: I, errors: T } = se(
|
|
475
|
+
r[f] = H;
|
|
476
|
+
const { isValid: I, errors: T } = se(r);
|
|
477
477
|
T[f] ? E(T[f]) : E(""), b(!I);
|
|
478
478
|
}
|
|
479
|
-
const O =
|
|
479
|
+
const O = u("div", {
|
|
480
480
|
className: "submit-button-wrapper",
|
|
481
481
|
children: [A, j]
|
|
482
482
|
});
|
|
@@ -499,9 +499,9 @@ const $ = ({ label: n, maskType: e, id: t, name: l, type: r = "text", placeholde
|
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
501
|
});
|
|
502
|
-
C.error ? (console.error("Request failed:", C.error), B(!1), z(C.error),
|
|
502
|
+
C.error ? (console.error("Request failed:", C.error), B(!1), z(C.error), a?.({ success: !1, error: C.error })) : (console.log("Request success:", C.data), B(!1), a?.({ success: !0, data: C.data }));
|
|
503
503
|
}
|
|
504
|
-
const Z = () =>
|
|
504
|
+
const Z = () => u("form", {
|
|
505
505
|
events: {
|
|
506
506
|
submit: P
|
|
507
507
|
},
|
|
@@ -509,10 +509,10 @@ const $ = ({ label: n, maskType: e, id: t, name: l, type: r = "text", placeholde
|
|
|
509
509
|
M,
|
|
510
510
|
O
|
|
511
511
|
]
|
|
512
|
-
}), W = () =>
|
|
512
|
+
}), W = () => u("div", {
|
|
513
513
|
className: "form-title",
|
|
514
514
|
innerHTML: `
|
|
515
|
-
<p>${
|
|
515
|
+
<p>${i}</p>
|
|
516
516
|
|
|
517
517
|
<div>
|
|
518
518
|
${Q}
|
|
@@ -520,13 +520,13 @@ const $ = ({ label: n, maskType: e, id: t, name: l, type: r = "text", placeholde
|
|
|
520
520
|
<span>Secured with 256-bit encryption</span>
|
|
521
521
|
</div>
|
|
522
522
|
`
|
|
523
|
-
}), Y = () =>
|
|
523
|
+
}), Y = () => u("div", {
|
|
524
524
|
className: l ? "" : "non-modal-content",
|
|
525
525
|
children: [W(), Z()]
|
|
526
|
-
}), q = l ? null :
|
|
527
|
-
className: `${
|
|
526
|
+
}), q = l ? null : u("div", {
|
|
527
|
+
className: `${s} non-modal`,
|
|
528
528
|
children: [
|
|
529
|
-
|
|
529
|
+
u("div", {
|
|
530
530
|
className: "non-modal-header",
|
|
531
531
|
innerHTML: `
|
|
532
532
|
<span></span>
|
|
@@ -540,8 +540,8 @@ const $ = ({ label: n, maskType: e, id: t, name: l, type: r = "text", placeholde
|
|
|
540
540
|
} };
|
|
541
541
|
function R() {
|
|
542
542
|
F && (document.body.appendChild(
|
|
543
|
-
|
|
544
|
-
className:
|
|
543
|
+
u("div", {
|
|
544
|
+
className: s,
|
|
545
545
|
children: [F]
|
|
546
546
|
})
|
|
547
547
|
), S(!0));
|
|
@@ -552,24 +552,24 @@ const $ = ({ label: n, maskType: e, id: t, name: l, type: r = "text", placeholde
|
|
|
552
552
|
closeModal: () => S(!1)
|
|
553
553
|
};
|
|
554
554
|
};
|
|
555
|
-
function de({ token: n, endpoint: e, beneficiaryCard: t, isModal: l, onCallback:
|
|
556
|
-
const { renderFormWithModal:
|
|
555
|
+
function de({ token: n, endpoint: e, beneficiaryCard: t, isModal: l, onCallback: a, onModalClose: h }) {
|
|
556
|
+
const { renderFormWithModal: i, nonModalForm: c, closeModal: p } = ce({
|
|
557
557
|
token: n,
|
|
558
558
|
endpoint: e,
|
|
559
559
|
beneficiaryCard: t,
|
|
560
560
|
isModal: l,
|
|
561
|
-
onCallback:
|
|
561
|
+
onCallback: a
|
|
562
562
|
});
|
|
563
563
|
return {
|
|
564
|
-
mount(
|
|
565
|
-
const
|
|
566
|
-
|
|
564
|
+
mount(s) {
|
|
565
|
+
const r = "className" in s ? document.querySelector(s.className) : "id" in s ? document.getElementById(s.id) : s.element;
|
|
566
|
+
r && c && r.appendChild(c);
|
|
567
567
|
},
|
|
568
568
|
open() {
|
|
569
|
-
|
|
569
|
+
i();
|
|
570
570
|
},
|
|
571
571
|
destroy() {
|
|
572
|
-
|
|
572
|
+
p(), h?.();
|
|
573
573
|
}
|
|
574
574
|
};
|
|
575
575
|
}
|