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