@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.
@@ -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: o, id: s, innerHTML: m, textContent: r, attributes: c, styles: d, dataset: i, children: l, events: h } = e;
5
- if (o) {
6
- const u = Array.isArray(o) ? o : o.split(" ");
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 (s && (t.id = s), m && (t.innerHTML = m), r && (t.textContent = r), c)
10
- for (const [u, a] of Object.entries(c))
11
- a && t.setAttribute(u, a);
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, a] of Object.entries(d))
14
- t.style[u] = a;
15
- if (i)
16
- for (const [u, a] of Object.entries(i))
17
- t.dataset[u] = a;
18
- if (l && t.append(...l.filter(Boolean)), h)
19
- for (const [u, a] of Object.entries(h))
20
- t.addEventListener(u, a);
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 o of t) {
30
- const { styles: s, attributes: m, dataset: r, innerHTML: c, textContent: d, className: i } = e;
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 [l, h] of Object.entries(r))
39
- o.dataset[l] = h;
40
- if (c !== void 0 && (o.innerHTML = c), d !== void 0 && (o.textContent = d), i?.add) {
41
- const l = Array.isArray(i.add) ? i.add : [i.add];
42
- o.classList.add(...l);
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 (i?.remove) {
45
- const l = Array.isArray(i.remove) ? i.remove : [i.remove];
46
- o.classList.remove(...l);
44
+ if (s?.remove) {
45
+ const o = Array.isArray(s.remove) ? s.remove : [s.remove];
46
+ a.classList.remove(...o);
47
47
  }
48
- i?.toggle && (Array.isArray(i.toggle) ? i.toggle : [i.toggle]).forEach((h) => o.classList.toggle(h));
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: o = "medium", type: s = "button", className: m = "", variant: r = "primary" }) => {
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
- }), i = p("button", {
110
- className: `custom-button ${r} ${o} ${m}`,
109
+ }), s = p("button", {
110
+ className: `custom-button ${i} ${a} ${m}`,
111
111
  attributes: {
112
- type: s,
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
- }), l = (u = !1) => {
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 ? i.setAttribute("disabled", "true") : i.removeAttribute("disabled");
127
+ u ? s.setAttribute("disabled", "true") : s.removeAttribute("disabled");
128
128
  };
129
129
  return {
130
- element: i,
131
- setLoading: l,
130
+ element: s,
131
+ setLoading: o,
132
132
  setDisabled: h
133
133
  };
134
- }, oe = ({ content: n, position: e = "top", delay: t = 200, maxWidth: o = 250, className: s = "", id: m = "" }) => {
135
- var r = p("div", {
136
- className: `tooltip ${e} ${s}`,
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: `${o}px`
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 l = p("span", {
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
- r.dataset.show = "true", h();
159
- }, t) : (r.dataset.show = "true", h());
158
+ i.dataset.show = "true", h();
159
+ }, t) : (i.dataset.show = "true", h());
160
160
  },
161
161
  mouseleave: () => {
162
- c && clearTimeout(c), r.dataset.show = "false";
162
+ c && clearTimeout(c), i.dataset.show = "false";
163
163
  }
164
164
  }
165
165
  });
166
166
  function h() {
167
- if (!l || !r) return;
168
- const a = l.getBoundingClientRect(), v = r.getBoundingClientRect(), y = 8;
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 = a.top - v.height - y, g = a.left + a.width / 2 - v.width / 2;
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 = a.bottom + y, g = a.left + a.width / 2 - v.width / 2;
175
+ w = l.bottom + y, g = l.left + l.width / 2 - v.width / 2;
176
176
  break;
177
177
  case "left":
178
- w = a.top + a.height / 2 - v.height / 2, g = a.left - v.width - y;
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 = a.top + a.height / 2 - v.height / 2, g = a.right + y;
181
+ w = l.top + l.height / 2 - v.height / 2, g = l.right + y;
182
182
  break;
183
183
  default:
184
- w = a.top - v.height - y, g = a.left + a.width / 2 - v.width / 2;
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), r.style.top = `${w}px`, r.style.left = `${g}px`;
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
- l,
194
- r
193
+ o,
194
+ i
195
195
  ]
196
196
  });
197
197
  }, ae = (n) => {
198
198
  const e = {}, t = Object.values(n).every(
199
- (s) => !s || s.trim() === ""
200
- ), o = n.cardNumber?.replace(/\s/g, "");
201
- if (o ? /^\d{13,19}$/.test(o) || (e.cardNumber = "Card number must be 13-19 digits") : e.cardNumber = "Card number is required", !n.expiryDate)
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 s = n.expiryDate.replace(/\D/g, "");
205
- if (s.length < 4)
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(s.substring(0, 2), 10), r = parseInt(s.substring(2, 4), 10);
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(r) || r < 0 || r > 99)
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(), i = c.getMonth() + 1, l = Math.floor(d / 100) * 100, h = l + r, u = l + 100 + r;
215
- let a;
216
- h >= d && h <= d + 20 ? a = h : (u >= d && u <= d + 20, a = u), a < d || a === d && m < i ? e.expiryDate = "Card has expired" : a > d + 20 && (e.expiryDate = "Expiry year is too far in the future");
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(), o = Math.floor(t / 100) * 100;
230
- let s = o + e;
231
- return s >= t && s <= t + 20 || (s = o + 100 + e, s >= t && s <= t + 20) ? s : o + 100 + e;
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: o, type: s = "text", placeholder: m = "Enter value", tooltip: r = "", onChange: c }) => {
256
- const d = ["card", "expiry", "phone", "cvv", "zip"].includes(e) ? "numeric" : "", i = p("label", {
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 l = !1;
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: s,
269
+ type: r,
270
270
  inputMode: d,
271
- name: o
271
+ name: a
272
272
  },
273
273
  events: {
274
- input: a,
274
+ input: l,
275
275
  blur: v,
276
276
  keydown: (b) => {
277
- b.key === "Enter" && (l = !0);
277
+ b.key === "Enter" && (o = !0);
278
278
  }
279
279
  }
280
280
  });
281
- function a(b) {
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
- l = !0, c?.(u?.value || "");
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 = r ? p("div", {
292
+ }), w = i ? p("div", {
293
293
  className: "input-right-element",
294
294
  children: [
295
- oe({ content: r, id: t })
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
- i,
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 && l ? { add: "input-error" } : { remove: "input-error" }
332
+ className: b && o ? { add: "input-error" } : { remove: "input-error" }
333
333
  }), x({ element: N }, {
334
- dataset: { show: b && l ? "true" : "false" },
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: o = {}, body: s = null, ...m } = e;
343
+ const { method: t = "GET", headers: a = {}, body: r = null, ...m } = e;
344
344
  try {
345
- const r = {
345
+ const i = {
346
346
  method: t,
347
347
  headers: {
348
348
  Accept: "*/*",
349
349
  "Content-Type": "application/json",
350
- ...o
350
+ ...a
351
351
  },
352
352
  ...m
353
353
  };
354
- s && ["POST", "PUT", "PATCH", "DELETE"].includes(t.toUpperCase()) && (r.body = typeof s == "string" ? s : JSON.stringify(s));
355
- const c = await fetch(n, r), d = c.headers.get("content-type");
356
- let i;
357
- if (d?.includes("application/json") ? i = await c.json() : i = await c.text(), !c.ok) {
358
- const l = i;
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
- l?.message || `HTTP error! status: ${c.status}`
360
+ o?.message || `HTTP error! status: ${c.status}`
361
361
  );
362
362
  }
363
- return { data: i, error: null };
364
- } catch (r) {
365
- return { data: null, error: r instanceof Error ? r.message : "An error occurred" };
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: o = !1,
372
- showCloseBtn: s = !0
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(o) },
377
+ dataset: { show: String(a) },
378
378
  events: { click: () => h() }
379
- }), r = p("h3", {
379
+ }), i = p("h3", {
380
380
  textContent: n
381
381
  }), c = p("button", {
382
382
  className: "close-btn",
383
383
  innerHTML: "&times;",
384
- dataset: { show: String(s) },
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, r, c]
390
- }), i = p("div", {
389
+ children: [m, i, c]
390
+ }), s = p("div", {
391
391
  className: "modal-content",
392
392
  children: [e]
393
- }), l = p("dialog", {
393
+ }), o = p("dialog", {
394
394
  className: "custom-modal",
395
- children: [d, i],
395
+ children: [d, s],
396
396
  events: {
397
- cancel: (a) => {
398
- a.preventDefault(), h();
397
+ cancel: (l) => {
398
+ l.preventDefault(), h();
399
399
  }
400
400
  }
401
401
  }), h = () => {
402
- l.close(), t?.();
402
+ o.close(), t?.();
403
403
  };
404
404
  return {
405
- element: l,
406
- setModalVisibility: (a) => {
407
- a ? l.showModal() : l.close();
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: o = !1, onCallback: s = () => null }) => {
411
- const m = t ? "Enter Recipient Debit Card Details" : "Enter Your Debit Card Details", r = 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", i = `add-card-form-wrapper${t ? " recipient-form" : ""}`, l = {
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: a, setError: v } = $({
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, a, y, g]
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
- l[f] = H;
478
- const { isValid: I, errors: T } = ae(l);
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), s?.({ success: !1, error: C.error })) : (console.log("Request success:", C.data), B(!1), s?.({ success: !0, data: C.data }));
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>${r}</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: o ? "" : "non-modal-content",
526
+ className: a ? "" : "non-modal-content",
527
527
  children: [W(), Z()]
528
- }), R = o ? null : p("div", {
529
- className: `${i} non-modal`,
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 } = o ? ue({ title: m, children: Y() }) : { element: null, setModalVisibility: () => {
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: i,
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: o, onCallback: s }) {
558
- const { renderFormWithModal: m, nonModalForm: r, closeModal: c } = pe({
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: o,
563
- onCallback: s
562
+ isModal: a,
563
+ onCallback: r
564
564
  });
565
565
  return {
566
- mount(d) {
567
- const i = "className" in d ? document.querySelector(d.className) : "id" in d ? document.getElementById(d.id) : d.element;
568
- i && r && i.appendChild(r);
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
- m();
571
+ i();
572
572
  },
573
573
  destroy() {
574
- c();
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: o = !1,
583
- isOpen: s = !1,
584
- onCallback: m = () => null
582
+ beneficiaryCard: a = !1,
583
+ isOpen: r = !1,
584
+ onCallback: m = () => null,
585
+ onClose: i = () => null
585
586
  }) {
586
- const r = X(null);
587
+ const c = X(null);
587
588
  return ee(() => {
588
- let c = me({
589
+ let d = me({
589
590
  token: n,
590
591
  endpoint: e,
591
- beneficiaryCard: o,
592
+ beneficiaryCard: a,
592
593
  isModal: t,
593
- onCallback: m
594
+ onCallback: m,
595
+ onModalClose: i
594
596
  });
595
597
  if (t)
596
- s ? c.open() : c.destroy();
598
+ r ? d.open() : d.destroy();
597
599
  else {
598
- if (!r?.current) return;
599
- c.mount({ element: r.current });
600
+ if (!c?.current) return;
601
+ d.mount({ element: c.current });
600
602
  }
601
603
  return () => {
602
- c.destroy();
604
+ d.destroy();
603
605
  };
604
- }, [t, n, e, o, s]), t ? null : /* @__PURE__ */ Q("div", { ref: r });
606
+ }, [t, n, e, a, r]), t ? null : /* @__PURE__ */ Q("div", { ref: c });
605
607
  }
606
608
  export {
607
609
  ve as AddCard
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@test-glide/glide-payment",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.es.js",