@nice2dev/ui-money 1.1.7 → 1.1.10
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/CHANGELOG.md +59 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +337 -337
- package/dist/ui-money.css +1 -1
- package/package.json +3 -3
- package/dist/style.css +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var G = (t, e, r) =>
|
|
4
|
-
import
|
|
5
|
-
import { jsxs as h, jsx as c, Fragment as
|
|
6
|
-
import {
|
|
1
|
+
var We = Object.defineProperty;
|
|
2
|
+
var et = (t, e, r) => e in t ? We(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var G = (t, e, r) => et(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import tt, { useState as z, useRef as rt, useEffect as nt, useMemo as q, useCallback as j, forwardRef as ie, useId as be } from "react";
|
|
5
|
+
import { jsxs as h, jsx as c, Fragment as at } from "react/jsx-runtime";
|
|
6
|
+
import { NiceIcon as Ce, useControllableState as De, NiceTutorialButton as ct, resolveTutorial as it } from "@nice2dev/ui-core";
|
|
7
7
|
const he = [
|
|
8
8
|
// ── Majors ─────────────────────────────────────
|
|
9
9
|
{ code: "USD", numeric: 840, symbol: "$", name: "US Dollar", decimals: 2, symbolFirst: !0 },
|
|
@@ -226,12 +226,12 @@ const he = [
|
|
|
226
226
|
{ code: "ETH", numeric: 0, symbol: "Ξ", name: "Ether", decimals: 8, symbolFirst: !0 },
|
|
227
227
|
{ code: "USDC", numeric: 0, symbol: "USDC", name: "USD Coin", decimals: 6 },
|
|
228
228
|
{ code: "USDT", numeric: 0, symbol: "USDT", name: "Tether", decimals: 6 }
|
|
229
|
-
],
|
|
229
|
+
], Fe = new Map(he.map((t) => [t.code, t]));
|
|
230
230
|
function te(t) {
|
|
231
|
-
return
|
|
231
|
+
return Fe.get(t.toUpperCase());
|
|
232
232
|
}
|
|
233
|
-
function
|
|
234
|
-
|
|
233
|
+
function Xt(t) {
|
|
234
|
+
Fe.set(t.code.toUpperCase(), t);
|
|
235
235
|
const e = he.findIndex((r) => r.code === t.code);
|
|
236
236
|
e >= 0 ? he[e] = t : he.push(t);
|
|
237
237
|
}
|
|
@@ -239,39 +239,39 @@ function re(t, e) {
|
|
|
239
239
|
const r = te(e), a = (r == null ? void 0 : r.decimals) ?? 2, n = Math.pow(10, a);
|
|
240
240
|
return { amount: (t < 0 ? -1 : 1) * Math.round(Math.abs(t) * n), currency: e.toUpperCase() };
|
|
241
241
|
}
|
|
242
|
-
function
|
|
242
|
+
function Be(t) {
|
|
243
243
|
const e = te(t.currency), r = (e == null ? void 0 : e.decimals) ?? 2;
|
|
244
244
|
return t.amount / Math.pow(10, r);
|
|
245
245
|
}
|
|
246
|
-
function
|
|
246
|
+
function st(t, e) {
|
|
247
247
|
return t.currency.toUpperCase() === e.currency.toUpperCase();
|
|
248
248
|
}
|
|
249
|
-
function
|
|
250
|
-
if (!
|
|
249
|
+
function Ie(t, e, r) {
|
|
250
|
+
if (!st(t, e))
|
|
251
251
|
throw new Error(`Cannot ${r} different currencies: ${t.currency} vs ${e.currency}`);
|
|
252
252
|
}
|
|
253
253
|
function me(t, e) {
|
|
254
|
-
return
|
|
254
|
+
return Ie(t, e, "add"), { amount: t.amount + e.amount, currency: t.currency };
|
|
255
255
|
}
|
|
256
|
-
function
|
|
257
|
-
return
|
|
256
|
+
function ot(t, e) {
|
|
257
|
+
return Ie(t, e, "subtract"), { amount: t.amount - e.amount, currency: t.currency };
|
|
258
258
|
}
|
|
259
|
-
function
|
|
259
|
+
function Me(t, e) {
|
|
260
260
|
return {
|
|
261
261
|
amount: (t.amount * e < 0 ? -1 : 1) * Math.round(Math.abs(t.amount * e)),
|
|
262
262
|
currency: t.currency
|
|
263
263
|
};
|
|
264
264
|
}
|
|
265
|
-
function
|
|
266
|
-
return
|
|
265
|
+
function Qt(t, e) {
|
|
266
|
+
return Ie(t, e, "compare"), t.amount - e.amount;
|
|
267
267
|
}
|
|
268
|
-
function
|
|
268
|
+
function Vt(t) {
|
|
269
269
|
return t.amount === 0;
|
|
270
270
|
}
|
|
271
|
-
function
|
|
271
|
+
function Wt(t) {
|
|
272
272
|
return t.amount < 0;
|
|
273
273
|
}
|
|
274
|
-
function
|
|
274
|
+
function er(t) {
|
|
275
275
|
return { amount: -t.amount, currency: t.currency };
|
|
276
276
|
}
|
|
277
277
|
function ce(t, e = {}) {
|
|
@@ -289,7 +289,7 @@ function ce(t, e = {}) {
|
|
|
289
289
|
return r != null && r.symbolFirst ? `${i}${u}` : `${u} ${i}`;
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
|
-
function
|
|
292
|
+
function lt(t, e) {
|
|
293
293
|
if (!t)
|
|
294
294
|
return null;
|
|
295
295
|
let r = t.replace(/[^\d.,\-]/g, "").trim();
|
|
@@ -307,7 +307,7 @@ function Ne(t) {
|
|
|
307
307
|
const e = (t || "").replace(/\D/g, "");
|
|
308
308
|
return e ? /^4/.test(e) ? "visa" : /^(5[1-5]|2(2[2-9]|[3-6]\d|7[01]|720))/.test(e) ? "mastercard" : /^3[47]/.test(e) ? "amex" : /^(6011|65|64[4-9]|622(12[6-9]|1[3-9]\d|[2-8]\d\d|9[01]\d|92[0-5]))/.test(e) ? "discover" : /^3(0[0-5]|[68])/.test(e) ? "diners" : /^35(2[89]|[3-8])/.test(e) ? "jcb" : /^62/.test(e) ? "unionpay" : /^(50|5[6-9]|6[0-9])/.test(e) ? "maestro" : /^(2200|2201|2202|2203|2204)/.test(e) ? "mir" : /^(4011|4312|4389|4514|4576|5041|5066|5067|509|6277|6362|6363|650|6516|6550)/.test(e) ? "elo" : /^(606282|3841)/.test(e) ? "hipercard" : "unknown" : "unknown";
|
|
309
309
|
}
|
|
310
|
-
function
|
|
310
|
+
function Le(t) {
|
|
311
311
|
const e = (t || "").replace(/\D/g, "");
|
|
312
312
|
if (e.length < 12 || e.length > 19)
|
|
313
313
|
return !1;
|
|
@@ -318,18 +318,18 @@ function Be(t) {
|
|
|
318
318
|
}
|
|
319
319
|
return r % 10 === 0;
|
|
320
320
|
}
|
|
321
|
-
function
|
|
321
|
+
function dt(t, e) {
|
|
322
322
|
const r = (t || "").replace(/\D/g, ""), a = e ?? Ne(r);
|
|
323
323
|
return a === "amex" ? [r.slice(0, 4), r.slice(4, 10), r.slice(10, 15)].filter(Boolean).join(" ") : a === "diners" ? [r.slice(0, 4), r.slice(4, 10), r.slice(10, 14)].filter(Boolean).join(" ") : (r.match(/.{1,4}/g) ?? []).join(" ").trim();
|
|
324
324
|
}
|
|
325
|
-
function
|
|
325
|
+
function tr(t, e) {
|
|
326
326
|
const r = (t || "").replace(/\D/g, "");
|
|
327
327
|
if (r.length < 4)
|
|
328
328
|
return r;
|
|
329
329
|
const a = r.slice(-4), n = "*".repeat(r.length - 4) + a, i = e ?? Ne(r);
|
|
330
330
|
return i === "amex" ? [n.slice(0, 4), n.slice(4, 10), n.slice(10, 15)].filter(Boolean).join(" ") : i === "diners" ? [n.slice(0, 4), n.slice(4, 10), n.slice(10, 14)].filter(Boolean).join(" ") : (n.match(/.{1,4}/g) ?? []).join(" ").trim();
|
|
331
331
|
}
|
|
332
|
-
function
|
|
332
|
+
function ze(t) {
|
|
333
333
|
const e = (t || "").replace(/\D/g, "");
|
|
334
334
|
if (e.length < 3)
|
|
335
335
|
return null;
|
|
@@ -337,7 +337,7 @@ function Le(t) {
|
|
|
337
337
|
return !Number.isFinite(n) || n < 1 || n > 12 ? null : `${r}/${a}`;
|
|
338
338
|
}
|
|
339
339
|
function He(t, e = /* @__PURE__ */ new Date()) {
|
|
340
|
-
const r =
|
|
340
|
+
const r = ze(t);
|
|
341
341
|
if (!r)
|
|
342
342
|
return !1;
|
|
343
343
|
const [a, n] = r.split("/"), i = parseInt(a, 10), u = 2e3 + parseInt(n, 10);
|
|
@@ -346,9 +346,9 @@ function He(t, e = /* @__PURE__ */ new Date()) {
|
|
|
346
346
|
function ye(t) {
|
|
347
347
|
return t === "amex" ? 4 : 3;
|
|
348
348
|
}
|
|
349
|
-
function
|
|
349
|
+
function Te(t, e = {}) {
|
|
350
350
|
var l;
|
|
351
|
-
const r = {}, a = Ne(t.number), n =
|
|
351
|
+
const r = {}, a = Ne(t.number), n = Le(t.number);
|
|
352
352
|
n || (r.number = "Invalid card number");
|
|
353
353
|
const i = He(t.expiry, e.now);
|
|
354
354
|
i || (r.expiry = "Invalid or expired");
|
|
@@ -365,7 +365,7 @@ function Ee(t, e = {}) {
|
|
|
365
365
|
errors: r
|
|
366
366
|
};
|
|
367
367
|
}
|
|
368
|
-
class
|
|
368
|
+
class rr {
|
|
369
369
|
constructor(e) {
|
|
370
370
|
G(this, "id", "static");
|
|
371
371
|
this.rates = e;
|
|
@@ -414,7 +414,7 @@ class we {
|
|
|
414
414
|
});
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
|
-
class
|
|
417
|
+
class ut extends we {
|
|
418
418
|
constructor(r = {}) {
|
|
419
419
|
super(r);
|
|
420
420
|
G(this, "id", "frankfurter");
|
|
@@ -436,7 +436,7 @@ class dt extends we {
|
|
|
436
436
|
return this.setCached(v), v;
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
|
-
class
|
|
439
|
+
class mt extends we {
|
|
440
440
|
constructor(r, a = {}) {
|
|
441
441
|
super(a);
|
|
442
442
|
G(this, "id", "openexchangerates");
|
|
@@ -464,7 +464,7 @@ class ut extends we {
|
|
|
464
464
|
return this.setCached(y), y;
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
|
-
class
|
|
467
|
+
class pt extends we {
|
|
468
468
|
constructor(r = {}) {
|
|
469
469
|
super(r);
|
|
470
470
|
G(this, "id", "exchangerate.host");
|
|
@@ -484,7 +484,7 @@ class mt extends we {
|
|
|
484
484
|
return this.setCached(v), v;
|
|
485
485
|
}
|
|
486
486
|
}
|
|
487
|
-
class
|
|
487
|
+
class yt extends we {
|
|
488
488
|
constructor(r = {}) {
|
|
489
489
|
super(r);
|
|
490
490
|
G(this, "id", "nbp");
|
|
@@ -499,13 +499,13 @@ class pt extends we {
|
|
|
499
499
|
if (u)
|
|
500
500
|
return u;
|
|
501
501
|
const s = async (v) => {
|
|
502
|
-
var
|
|
502
|
+
var g;
|
|
503
503
|
if (v === "PLN")
|
|
504
504
|
return { rate: 1, date: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10) };
|
|
505
505
|
const y = `https://api.nbp.pl/api/exchangerates/rates/${this.table}/${v}/?format=json`, d = await this.fetchImpl(y);
|
|
506
506
|
if (!d.ok)
|
|
507
507
|
return null;
|
|
508
|
-
const f = (
|
|
508
|
+
const f = (g = (await d.json()).rates) == null ? void 0 : g[0];
|
|
509
509
|
return f ? { rate: f.mid ?? f.ask ?? 0, date: f.effectiveDate } : null;
|
|
510
510
|
}, o = await s(n), l = await s(i);
|
|
511
511
|
if (!o || !l || o.rate === 0)
|
|
@@ -519,20 +519,20 @@ class pt extends we {
|
|
|
519
519
|
return this.setCached(p), p;
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
|
-
class
|
|
522
|
+
class ht extends ut {
|
|
523
523
|
constructor() {
|
|
524
524
|
super(...arguments);
|
|
525
525
|
G(this, "id", "ecb");
|
|
526
526
|
}
|
|
527
527
|
}
|
|
528
|
-
class
|
|
528
|
+
class bt extends pt {
|
|
529
529
|
constructor() {
|
|
530
530
|
super(...arguments);
|
|
531
531
|
G(this, "id", "free-forex");
|
|
532
532
|
}
|
|
533
533
|
}
|
|
534
|
-
const
|
|
535
|
-
async function
|
|
534
|
+
const nr = (t = {}) => new yt(t), ar = (t = {}) => new ht(t), cr = (t) => new mt(t.apiKey, t), ir = (t = {}) => new bt(t);
|
|
535
|
+
async function ft(t, e, r) {
|
|
536
536
|
const a = e.toUpperCase();
|
|
537
537
|
if (t.currency.toUpperCase() === a)
|
|
538
538
|
return t;
|
|
@@ -542,7 +542,7 @@ async function bt(t, e, r) {
|
|
|
542
542
|
amount: Math.round(p * Math.pow(10, s))
|
|
543
543
|
};
|
|
544
544
|
}
|
|
545
|
-
class
|
|
545
|
+
class _t {
|
|
546
546
|
constructor(e = {}) {
|
|
547
547
|
G(this, "id");
|
|
548
548
|
G(this, "name");
|
|
@@ -603,7 +603,7 @@ function V(t, e, r, a, n) {
|
|
|
603
603
|
refund: i("refund")
|
|
604
604
|
};
|
|
605
605
|
}
|
|
606
|
-
function
|
|
606
|
+
function gt(t) {
|
|
607
607
|
return V("stripe", "Stripe", "*", t, {
|
|
608
608
|
USD: 50,
|
|
609
609
|
EUR: 50,
|
|
@@ -618,7 +618,7 @@ function _t(t) {
|
|
|
618
618
|
PLN: 200
|
|
619
619
|
});
|
|
620
620
|
}
|
|
621
|
-
function
|
|
621
|
+
function vt(t) {
|
|
622
622
|
return V(
|
|
623
623
|
"paypal",
|
|
624
624
|
"PayPal",
|
|
@@ -649,22 +649,22 @@ function gt(t) {
|
|
|
649
649
|
t
|
|
650
650
|
);
|
|
651
651
|
}
|
|
652
|
-
function
|
|
652
|
+
function Nt(t) {
|
|
653
653
|
return V("adyen", "Adyen", "*", t);
|
|
654
654
|
}
|
|
655
|
-
function
|
|
655
|
+
function wt(t) {
|
|
656
656
|
return V("square", "Square", ["USD", "CAD", "GBP", "AUD", "JPY", "EUR"], t);
|
|
657
657
|
}
|
|
658
|
-
function
|
|
658
|
+
function kt(t) {
|
|
659
659
|
return V("mollie", "Mollie", "*", t);
|
|
660
660
|
}
|
|
661
|
-
function
|
|
661
|
+
function Ct(t) {
|
|
662
662
|
return V("braintree", "Braintree", "*", t);
|
|
663
663
|
}
|
|
664
|
-
function
|
|
664
|
+
function Dt(t) {
|
|
665
665
|
return V("razorpay", "Razorpay", ["INR", "USD", "EUR", "GBP", "AED"], t);
|
|
666
666
|
}
|
|
667
|
-
function
|
|
667
|
+
function Mt(t) {
|
|
668
668
|
return V(
|
|
669
669
|
"payu",
|
|
670
670
|
"PayU",
|
|
@@ -672,20 +672,20 @@ function Dt(t) {
|
|
|
672
672
|
t
|
|
673
673
|
);
|
|
674
674
|
}
|
|
675
|
-
function
|
|
675
|
+
function Pt(t) {
|
|
676
676
|
return V("przelewy24", "Przelewy24", ["PLN", "EUR"], t);
|
|
677
677
|
}
|
|
678
|
-
function
|
|
678
|
+
function It(t = {}) {
|
|
679
679
|
return V("tpay", "Tpay", ["PLN", "EUR", "USD", "GBP"], t);
|
|
680
680
|
}
|
|
681
681
|
function St(t = {}) {
|
|
682
682
|
return V("autopay", "Autopay", ["PLN", "EUR", "USD", "GBP", "CZK"], t);
|
|
683
683
|
}
|
|
684
|
-
function
|
|
684
|
+
function $t(t = {}) {
|
|
685
685
|
const { acquirer: e = "native", ...r } = t;
|
|
686
686
|
return V(`blik:${e}`, `BLIK (${e})`, ["PLN"], r);
|
|
687
687
|
}
|
|
688
|
-
function
|
|
688
|
+
function xt(t) {
|
|
689
689
|
return V(
|
|
690
690
|
"klarna",
|
|
691
691
|
"Klarna",
|
|
@@ -693,7 +693,7 @@ function $t(t) {
|
|
|
693
693
|
t
|
|
694
694
|
);
|
|
695
695
|
}
|
|
696
|
-
function
|
|
696
|
+
function Rt(t) {
|
|
697
697
|
return V(
|
|
698
698
|
"coinbase-commerce",
|
|
699
699
|
"Coinbase Commerce",
|
|
@@ -701,31 +701,31 @@ function xt(t) {
|
|
|
701
701
|
t
|
|
702
702
|
);
|
|
703
703
|
}
|
|
704
|
-
const
|
|
705
|
-
mock: () => new
|
|
706
|
-
stripe: () =>
|
|
707
|
-
paypal: () =>
|
|
708
|
-
adyen: () =>
|
|
709
|
-
square: () =>
|
|
710
|
-
mollie: () =>
|
|
711
|
-
braintree: () =>
|
|
712
|
-
razorpay: () =>
|
|
713
|
-
payu: () =>
|
|
714
|
-
przelewy24: () =>
|
|
715
|
-
tpay: () =>
|
|
704
|
+
const Ut = {
|
|
705
|
+
mock: () => new _t(),
|
|
706
|
+
stripe: () => gt(),
|
|
707
|
+
paypal: () => vt(),
|
|
708
|
+
adyen: () => Nt(),
|
|
709
|
+
square: () => wt(),
|
|
710
|
+
mollie: () => kt(),
|
|
711
|
+
braintree: () => Ct(),
|
|
712
|
+
razorpay: () => Dt(),
|
|
713
|
+
payu: () => Mt(),
|
|
714
|
+
przelewy24: () => Pt(),
|
|
715
|
+
tpay: () => It(),
|
|
716
716
|
autopay: () => St(),
|
|
717
|
-
blik: () =>
|
|
718
|
-
klarna: () =>
|
|
719
|
-
"coinbase-commerce": () =>
|
|
717
|
+
blik: () => $t(),
|
|
718
|
+
klarna: () => xt(),
|
|
719
|
+
"coinbase-commerce": () => Rt()
|
|
720
720
|
};
|
|
721
|
-
function
|
|
722
|
-
const e =
|
|
721
|
+
function At(t) {
|
|
722
|
+
const e = Ut[t];
|
|
723
723
|
return e ? e().supportedCurrencies : "*";
|
|
724
724
|
}
|
|
725
|
-
function
|
|
725
|
+
function Et(t) {
|
|
726
726
|
return `/api/payments/${t}/webhook`;
|
|
727
727
|
}
|
|
728
|
-
const
|
|
728
|
+
const Tt = [
|
|
729
729
|
{
|
|
730
730
|
id: "stripe",
|
|
731
731
|
name: "Stripe",
|
|
@@ -937,21 +937,21 @@ const Et = [
|
|
|
937
937
|
hasTestMode: !0
|
|
938
938
|
}
|
|
939
939
|
], ve = Object.fromEntries(
|
|
940
|
-
|
|
940
|
+
Tt.map((t) => {
|
|
941
941
|
const { currencyKey: e, ...r } = t, a = {
|
|
942
942
|
...r,
|
|
943
|
-
supportedCurrencies:
|
|
944
|
-
webhookPath:
|
|
943
|
+
supportedCurrencies: At(e ?? t.id),
|
|
944
|
+
webhookPath: Et(t.id)
|
|
945
945
|
};
|
|
946
946
|
return [t.id, a];
|
|
947
947
|
})
|
|
948
|
-
),
|
|
948
|
+
), qt = Object.values(
|
|
949
949
|
ve
|
|
950
950
|
);
|
|
951
|
-
function
|
|
951
|
+
function sr(t) {
|
|
952
952
|
return ve[t];
|
|
953
953
|
}
|
|
954
|
-
function
|
|
954
|
+
function or(t, e) {
|
|
955
955
|
const r = q(
|
|
956
956
|
() => "amount" in t ? t : re(
|
|
957
957
|
t.major,
|
|
@@ -959,29 +959,29 @@ function sr(t, e) {
|
|
|
959
959
|
),
|
|
960
960
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
961
961
|
[]
|
|
962
|
-
), [a, n] =
|
|
962
|
+
), [a, n] = z(r), i = j(
|
|
963
963
|
(y) => n((d) => re(y, d.currency)),
|
|
964
964
|
[]
|
|
965
|
-
), u =
|
|
965
|
+
), u = j((y) => {
|
|
966
966
|
n((d) => ({ ...d, currency: y.toUpperCase() }));
|
|
967
|
-
}, []), s =
|
|
968
|
-
(y) => n((d) =>
|
|
967
|
+
}, []), s = j((y) => n((d) => me(d, y)), []), o = j(
|
|
968
|
+
(y) => n((d) => ot(d, y)),
|
|
969
969
|
[]
|
|
970
|
-
), l =
|
|
971
|
-
(y) => n((d) =>
|
|
970
|
+
), l = j(
|
|
971
|
+
(y) => n((d) => Me(d, y)),
|
|
972
972
|
[]
|
|
973
|
-
), p = q(() => ce(a, { locale: e }), [a, e]), v = q(() =>
|
|
973
|
+
), p = q(() => ce(a, { locale: e }), [a, e]), v = q(() => Be(a), [a]);
|
|
974
974
|
return { money: a, setMoney: n, setMajor: i, setCurrency: u, add: s, subtract: o, scale: l, formatted: p, major: v };
|
|
975
975
|
}
|
|
976
|
-
function
|
|
977
|
-
const [a, n] =
|
|
978
|
-
return
|
|
976
|
+
function Pe(t, e, r) {
|
|
977
|
+
const [a, n] = z(null), [i, u] = z(null), [s, o] = z(!1), l = rt(0);
|
|
978
|
+
return nt(() => {
|
|
979
979
|
if (!t) {
|
|
980
980
|
n(null);
|
|
981
981
|
return;
|
|
982
982
|
}
|
|
983
983
|
const p = ++l.current;
|
|
984
|
-
o(!0), u(null),
|
|
984
|
+
o(!0), u(null), ft(t, e, r).then((v) => {
|
|
985
985
|
l.current === p && n(v);
|
|
986
986
|
}).catch((v) => {
|
|
987
987
|
l.current === p && (u(v instanceof Error ? v : new Error(String(v))), n(null));
|
|
@@ -990,10 +990,10 @@ function Me(t, e, r) {
|
|
|
990
990
|
});
|
|
991
991
|
}, [t == null ? void 0 : t.amount, t == null ? void 0 : t.currency, e, r]), { converted: a, loading: s, error: i };
|
|
992
992
|
}
|
|
993
|
-
function
|
|
994
|
-
const [e, r] =
|
|
993
|
+
function Kt(t) {
|
|
994
|
+
const [e, r] = z("idle"), [a, n] = z(null), [i, u] = z(null), s = j(() => {
|
|
995
995
|
r("idle"), n(null), u(null);
|
|
996
|
-
}, []), o =
|
|
996
|
+
}, []), o = j(
|
|
997
997
|
async (y) => {
|
|
998
998
|
r("authorizing"), u(null);
|
|
999
999
|
try {
|
|
@@ -1005,7 +1005,7 @@ function qt(t) {
|
|
|
1005
1005
|
}
|
|
1006
1006
|
},
|
|
1007
1007
|
[t]
|
|
1008
|
-
), l =
|
|
1008
|
+
), l = j(
|
|
1009
1009
|
async (y, d) => {
|
|
1010
1010
|
const b = y ?? (a == null ? void 0 : a.id);
|
|
1011
1011
|
if (!b)
|
|
@@ -1015,12 +1015,12 @@ function qt(t) {
|
|
|
1015
1015
|
const f = await t.capture(b, d);
|
|
1016
1016
|
return n(f), r(f.status), f;
|
|
1017
1017
|
} catch (f) {
|
|
1018
|
-
const
|
|
1019
|
-
throw u(
|
|
1018
|
+
const g = f instanceof Error ? f : new Error(String(f));
|
|
1019
|
+
throw u(g), r("failed"), g;
|
|
1020
1020
|
}
|
|
1021
1021
|
},
|
|
1022
1022
|
[t, a == null ? void 0 : a.id]
|
|
1023
|
-
), p =
|
|
1023
|
+
), p = j(
|
|
1024
1024
|
async (y) => {
|
|
1025
1025
|
const d = y ?? (a == null ? void 0 : a.id);
|
|
1026
1026
|
if (!d)
|
|
@@ -1029,7 +1029,7 @@ function qt(t) {
|
|
|
1029
1029
|
return n(b), r(b.status), b;
|
|
1030
1030
|
},
|
|
1031
1031
|
[t, a == null ? void 0 : a.id]
|
|
1032
|
-
), v =
|
|
1032
|
+
), v = j(
|
|
1033
1033
|
async (y, d) => {
|
|
1034
1034
|
const b = y ?? (a == null ? void 0 : a.id);
|
|
1035
1035
|
if (!b)
|
|
@@ -1041,7 +1041,7 @@ function qt(t) {
|
|
|
1041
1041
|
);
|
|
1042
1042
|
return { status: e, response: a, error: i, authorize: o, capture: l, cancel: p, refund: v, reset: s };
|
|
1043
1043
|
}
|
|
1044
|
-
const
|
|
1044
|
+
const qe = ie(function({
|
|
1045
1045
|
value: e,
|
|
1046
1046
|
amount: r,
|
|
1047
1047
|
currency: a,
|
|
@@ -1066,22 +1066,22 @@ const Te = ie(function({
|
|
|
1066
1066
|
};
|
|
1067
1067
|
}
|
|
1068
1068
|
return null;
|
|
1069
|
-
}, [e, r, a]), f = q(() => b ? b.amount === 0 && s != null ? s : ce(b, { locale: n, currencyDisplay: i }) : "", [b, n, i, s]), { converted:
|
|
1069
|
+
}, [e, r, a]), f = q(() => b ? b.amount === 0 && s != null ? s : ce(b, { locale: n, currencyDisplay: i }) : "", [b, n, i, s]), { converted: g } = Pe(
|
|
1070
1070
|
o && l ? b : null,
|
|
1071
1071
|
o ?? "",
|
|
1072
1072
|
l
|
|
1073
1073
|
);
|
|
1074
1074
|
if (!b)
|
|
1075
1075
|
return null;
|
|
1076
|
-
const
|
|
1076
|
+
const _ = b.amount < 0, w = "nice-money" + (u && _ ? " nice-money--negative" : "") + (p ? ` ${p}` : "");
|
|
1077
1077
|
return /* @__PURE__ */ h("span", { ref: d, className: w, style: v, "aria-label": y, children: [
|
|
1078
1078
|
/* @__PURE__ */ c("span", { className: "nice-money__value", children: f }),
|
|
1079
|
-
|
|
1079
|
+
g && /* @__PURE__ */ h("span", { className: "nice-money__converted", "aria-label": `Converted to ${g.currency}`, children: [
|
|
1080
1080
|
" ≈ ",
|
|
1081
|
-
ce(
|
|
1081
|
+
ce(g, { locale: n })
|
|
1082
1082
|
] })
|
|
1083
1083
|
] });
|
|
1084
|
-
}),
|
|
1084
|
+
}), lr = he.map((t) => t.code).sort(), je = ie(
|
|
1085
1085
|
function({
|
|
1086
1086
|
value: e,
|
|
1087
1087
|
onChange: r,
|
|
@@ -1098,49 +1098,49 @@ const Te = ie(function({
|
|
|
1098
1098
|
label: d,
|
|
1099
1099
|
helperText: b,
|
|
1100
1100
|
error: f,
|
|
1101
|
-
required:
|
|
1102
|
-
size:
|
|
1101
|
+
required: g,
|
|
1102
|
+
size: _ = "md",
|
|
1103
1103
|
labelPlacement: w = "top",
|
|
1104
1104
|
labelWidth: N,
|
|
1105
1105
|
controlWidth: D,
|
|
1106
1106
|
className: x,
|
|
1107
1107
|
style: A,
|
|
1108
|
-
id:
|
|
1108
|
+
id: I,
|
|
1109
1109
|
name: M,
|
|
1110
1110
|
title: R,
|
|
1111
1111
|
"data-testid": X,
|
|
1112
1112
|
"aria-label": O,
|
|
1113
1113
|
placeholder: k
|
|
1114
1114
|
}, F) {
|
|
1115
|
-
const T = y === "hidden", Q = l || y === "disabled" || v, ne = p || y === "readOnly", B = be(), ae =
|
|
1115
|
+
const T = y === "hidden", Q = l || y === "disabled" || v, ne = p || y === "readOnly", B = be(), ae = I ?? `nice-cs-${B}`, [Z, U] = z(""), E = i ?? a.length > 8, Y = q(() => {
|
|
1116
1116
|
if (!Z.trim())
|
|
1117
1117
|
return a;
|
|
1118
1118
|
const P = Z.trim().toLowerCase();
|
|
1119
1119
|
return a.filter(
|
|
1120
|
-
(
|
|
1120
|
+
(S) => S.code.toLowerCase().includes(P) || S.name.toLowerCase().includes(P) || S.symbol.toLowerCase().includes(P)
|
|
1121
1121
|
);
|
|
1122
1122
|
}, [a, Z]), m = q(() => {
|
|
1123
1123
|
const P = /* @__PURE__ */ new Set();
|
|
1124
|
-
return n.map((
|
|
1125
|
-
}, [n]), L =
|
|
1124
|
+
return n.map((S) => te(S)).filter((S) => !!S && !P.has(S.code) && !!P.add(S.code));
|
|
1125
|
+
}, [n]), L = j(
|
|
1126
1126
|
(P) => {
|
|
1127
|
-
const
|
|
1128
|
-
oe && (r == null || r(
|
|
1127
|
+
const S = P.target.value, oe = te(S);
|
|
1128
|
+
oe && (r == null || r(S, oe));
|
|
1129
1129
|
},
|
|
1130
1130
|
[r]
|
|
1131
|
-
),
|
|
1131
|
+
), H = (P) => {
|
|
1132
1132
|
if (o)
|
|
1133
1133
|
return `${s ? P.symbol + " " : ""}${P.code}`;
|
|
1134
|
-
const
|
|
1135
|
-
return s &&
|
|
1136
|
-
}, C = `nice-currency-selector nice-currency-selector--${
|
|
1134
|
+
const S = [];
|
|
1135
|
+
return s && S.push(P.symbol), u && S.push(P.code), S.push("—", P.name), S.join(" ");
|
|
1136
|
+
}, C = `nice-currency-selector nice-currency-selector--${_} nice-currency-selector--label-${w}` + (o ? " nice-currency-selector--compact" : "") + (f ? " nice-currency-selector--error" : "") + (Q ? " nice-currency-selector--disabled" : "") + (x ? ` ${x}` : ""), K = w === "left" && N != null ? { width: typeof N == "number" ? `${N}px` : N, flex: "none" } : void 0, se = D != null ? {
|
|
1137
1137
|
width: typeof D == "number" ? `${D}px` : D,
|
|
1138
1138
|
flex: "none"
|
|
1139
1139
|
} : void 0;
|
|
1140
1140
|
return T ? null : /* @__PURE__ */ h("div", { ref: F, className: C, style: A, title: R, "data-testid": X, children: [
|
|
1141
1141
|
d && /* @__PURE__ */ h("label", { htmlFor: ae, className: "nice-currency-selector__label", style: K, children: [
|
|
1142
1142
|
d,
|
|
1143
|
-
|
|
1143
|
+
g && /* @__PURE__ */ c("span", { className: "nice-currency-selector__required", "aria-hidden": !0, children: "*" })
|
|
1144
1144
|
] }),
|
|
1145
1145
|
/* @__PURE__ */ h("div", { className: "nice-currency-selector__inner", style: se, children: [
|
|
1146
1146
|
E && /* @__PURE__ */ c(
|
|
@@ -1164,13 +1164,13 @@ const Te = ie(function({
|
|
|
1164
1164
|
value: e ?? "",
|
|
1165
1165
|
onChange: L,
|
|
1166
1166
|
disabled: Q || ne,
|
|
1167
|
-
required:
|
|
1167
|
+
required: g,
|
|
1168
1168
|
"aria-invalid": !!f,
|
|
1169
1169
|
"aria-label": O ?? (typeof d == "string" ? d : "Currency"),
|
|
1170
1170
|
children: [
|
|
1171
1171
|
!e && /* @__PURE__ */ c("option", { value: "", children: k ?? "Select currency…" }),
|
|
1172
|
-
m.length > 0 && /* @__PURE__ */ c("optgroup", { label: "Recent", children: m.map((P) => /* @__PURE__ */ c("option", { value: P.code, children:
|
|
1173
|
-
/* @__PURE__ */ c("optgroup", { label: m.length > 0 ? "All" : "", children: Y.map((P) => /* @__PURE__ */ c("option", { value: P.code, children:
|
|
1172
|
+
m.length > 0 && /* @__PURE__ */ c("optgroup", { label: "Recent", children: m.map((P) => /* @__PURE__ */ c("option", { value: P.code, children: H(P) }, `r-${P.code}`)) }),
|
|
1173
|
+
/* @__PURE__ */ c("optgroup", { label: m.length > 0 ? "All" : "", children: Y.map((P) => /* @__PURE__ */ c("option", { value: P.code, children: H(P) }, P.code)) })
|
|
1174
1174
|
]
|
|
1175
1175
|
}
|
|
1176
1176
|
)
|
|
@@ -1184,7 +1184,7 @@ const Te = ie(function({
|
|
|
1184
1184
|
)
|
|
1185
1185
|
] });
|
|
1186
1186
|
}
|
|
1187
|
-
),
|
|
1187
|
+
), Ye = ie(
|
|
1188
1188
|
function({
|
|
1189
1189
|
value: e,
|
|
1190
1190
|
onChange: r,
|
|
@@ -1201,14 +1201,14 @@ const Te = ie(function({
|
|
|
1201
1201
|
helperText: d,
|
|
1202
1202
|
error: b,
|
|
1203
1203
|
size: f = "md",
|
|
1204
|
-
disabled:
|
|
1205
|
-
readOnly:
|
|
1204
|
+
disabled: g,
|
|
1205
|
+
readOnly: _,
|
|
1206
1206
|
required: w,
|
|
1207
1207
|
loading: N,
|
|
1208
1208
|
accessMode: D,
|
|
1209
1209
|
labelPlacement: x = "top",
|
|
1210
1210
|
errorPlacement: A = "bottom",
|
|
1211
|
-
labelWidth:
|
|
1211
|
+
labelWidth: I,
|
|
1212
1212
|
controlWidth: M,
|
|
1213
1213
|
submitOnEnter: R,
|
|
1214
1214
|
onSubmit: X,
|
|
@@ -1226,10 +1226,10 @@ const Te = ie(function({
|
|
|
1226
1226
|
multiplierShortcuts: Y = !0,
|
|
1227
1227
|
onValidationError: m
|
|
1228
1228
|
}, L) {
|
|
1229
|
-
const
|
|
1229
|
+
const H = g || D === "disabled" || N, C = _ || D === "readOnly", K = D === "hidden", se = be(), P = Q ?? `nice-money-${se}`, S = ((e == null ? void 0 : e.currency) ?? a ?? "USD").toUpperCase(), oe = te(S), W = (oe == null ? void 0 : oe.decimals) ?? 2, Se = l ?? 1 / Math.pow(10, W), [ke, fe] = z(
|
|
1230
1230
|
() => e ? (e.amount / Math.pow(10, W)).toFixed(W) : ""
|
|
1231
|
-
), [_e,
|
|
1232
|
-
|
|
1231
|
+
), [_e, $e] = z(!1);
|
|
1232
|
+
tt.useEffect(() => {
|
|
1233
1233
|
if (_e)
|
|
1234
1234
|
return;
|
|
1235
1235
|
if (e == null) {
|
|
@@ -1239,21 +1239,21 @@ const Te = ie(function({
|
|
|
1239
1239
|
const $ = te(e.currency), J = ($ == null ? void 0 : $.decimals) ?? 2;
|
|
1240
1240
|
fe((e.amount / Math.pow(10, J)).toFixed(J));
|
|
1241
1241
|
}, [e, _e]);
|
|
1242
|
-
const
|
|
1242
|
+
const xe = j(
|
|
1243
1243
|
($) => {
|
|
1244
1244
|
let J = $;
|
|
1245
1245
|
if (Y) {
|
|
1246
1246
|
const de = $.trim().match(/^([+-]?\d+(?:[.,]\d+)?)\s*([kKmMbB])$/);
|
|
1247
1247
|
if (de) {
|
|
1248
|
-
const ue = de[2].toLowerCase() === "k" ? 1e3 : de[2].toLowerCase() === "m" ? 1e6 : 1e9,
|
|
1249
|
-
if (!Number.isFinite(
|
|
1248
|
+
const ue = de[2].toLowerCase() === "k" ? 1e3 : de[2].toLowerCase() === "m" ? 1e6 : 1e9, Ee = Number(de[1].replace(",", ".")) * ue;
|
|
1249
|
+
if (!Number.isFinite(Ee)) {
|
|
1250
1250
|
m == null || m(new Error("overflow"));
|
|
1251
1251
|
return;
|
|
1252
1252
|
}
|
|
1253
|
-
J = String(
|
|
1253
|
+
J = String(Ee);
|
|
1254
1254
|
}
|
|
1255
1255
|
}
|
|
1256
|
-
const ee =
|
|
1256
|
+
const ee = lt(J, S);
|
|
1257
1257
|
if (!ee) {
|
|
1258
1258
|
r == null || r(null);
|
|
1259
1259
|
return;
|
|
@@ -1264,28 +1264,28 @@ const Te = ie(function({
|
|
|
1264
1264
|
}
|
|
1265
1265
|
const le = ee.amount / Math.pow(10, W);
|
|
1266
1266
|
if (s != null && le < s) {
|
|
1267
|
-
m == null || m(new Error(`min: ${s}`)), r == null || r(re(s,
|
|
1267
|
+
m == null || m(new Error(`min: ${s}`)), r == null || r(re(s, S));
|
|
1268
1268
|
return;
|
|
1269
1269
|
}
|
|
1270
1270
|
if (o != null && le > o) {
|
|
1271
|
-
m == null || m(new Error(`max: ${o}`)), r == null || r(re(o,
|
|
1271
|
+
m == null || m(new Error(`max: ${o}`)), r == null || r(re(o, S));
|
|
1272
1272
|
return;
|
|
1273
1273
|
}
|
|
1274
1274
|
r == null || r(ee);
|
|
1275
1275
|
},
|
|
1276
|
-
[
|
|
1277
|
-
),
|
|
1276
|
+
[S, W, s, o, r, Y, m]
|
|
1277
|
+
), Ge = j(
|
|
1278
1278
|
($) => {
|
|
1279
1279
|
const J = $.target.value;
|
|
1280
|
-
fe(J),
|
|
1280
|
+
fe(J), xe(J);
|
|
1281
1281
|
},
|
|
1282
|
-
[
|
|
1283
|
-
),
|
|
1282
|
+
[xe]
|
|
1283
|
+
), Re = j(
|
|
1284
1284
|
($) => {
|
|
1285
1285
|
const ee = (e ? e.amount / Math.pow(10, W) : 0) + $, le = Math.min(o ?? 1 / 0, Math.max(s ?? -1 / 0, ee));
|
|
1286
|
-
r == null || r(re(le,
|
|
1286
|
+
r == null || r(re(le, S));
|
|
1287
1287
|
},
|
|
1288
|
-
[e, W, s, o,
|
|
1288
|
+
[e, W, s, o, S, r]
|
|
1289
1289
|
), ge = q(() => {
|
|
1290
1290
|
var $, J;
|
|
1291
1291
|
try {
|
|
@@ -1294,8 +1294,8 @@ const Te = ie(function({
|
|
|
1294
1294
|
} catch {
|
|
1295
1295
|
return { group: ",", decimal: "." };
|
|
1296
1296
|
}
|
|
1297
|
-
}, [p]),
|
|
1298
|
-
if (!
|
|
1297
|
+
}, [p]), Ue = E ?? !!ge.group, Ze = q(() => {
|
|
1298
|
+
if (!Ue || _e === !1)
|
|
1299
1299
|
return ke;
|
|
1300
1300
|
const $ = ge.decimal, J = ge.group, ee = ke.replace(
|
|
1301
1301
|
new RegExp(`[${J.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}]`, "g"),
|
|
@@ -1305,38 +1305,38 @@ const Te = ie(function({
|
|
|
1305
1305
|
return ee;
|
|
1306
1306
|
const ue = le.replace(/\B(?=(\d{3})+(?!\d))/g, J);
|
|
1307
1307
|
return de != null ? `${ue}${$}${de}` : ue;
|
|
1308
|
-
}, [ke, _e,
|
|
1308
|
+
}, [ke, _e, Ue, ge]), Ae = q(() => e ? ce(e, { locale: p }) : "", [e, p]), pe = typeof b == "string" ? b : void 0, Je = `nice-money-input nice-money-input--${f} nice-money-input--label-${x} nice-money-input--error-${A}` + (pe ? " nice-money-input--error" : "") + (H ? " nice-money-input--disabled" : "") + (N ? " nice-money-input--loading" : "") + (F ? ` ${F}` : ""), Xe = ($) => {
|
|
1309
1309
|
R && $.key === "Enter" && X && ($.preventDefault(), X());
|
|
1310
|
-
},
|
|
1310
|
+
}, Qe = x === "left" && I != null ? { width: typeof I == "number" ? `${I}px` : I, flex: "none" } : void 0, Ve = M != null ? {
|
|
1311
1311
|
width: typeof M == "number" ? `${M}px` : M,
|
|
1312
1312
|
flex: "none"
|
|
1313
1313
|
} : void 0;
|
|
1314
|
-
return K ? null : /* @__PURE__ */ h("div", { ref: L, className:
|
|
1315
|
-
y && /* @__PURE__ */ h("label", { htmlFor: P, className: "nice-money-input__label", style:
|
|
1314
|
+
return K ? null : /* @__PURE__ */ h("div", { ref: L, className: Je, style: T, title: B, "data-testid": ae, children: [
|
|
1315
|
+
y && /* @__PURE__ */ h("label", { htmlFor: P, className: "nice-money-input__label", style: Qe, children: [
|
|
1316
1316
|
y,
|
|
1317
1317
|
w && /* @__PURE__ */ c("span", { className: "nice-money-input__required", "aria-hidden": !0, children: "*" })
|
|
1318
1318
|
] }),
|
|
1319
|
-
/* @__PURE__ */ h("div", { className: "nice-money-input__row", style:
|
|
1319
|
+
/* @__PURE__ */ h("div", { className: "nice-money-input__row", style: Ve, children: [
|
|
1320
1320
|
!u && /* @__PURE__ */ c(
|
|
1321
1321
|
je,
|
|
1322
1322
|
{
|
|
1323
|
-
value:
|
|
1323
|
+
value: S,
|
|
1324
1324
|
compact: !0,
|
|
1325
1325
|
options: i ? i.map(te).filter(($) => !!$) : void 0,
|
|
1326
1326
|
onChange: ($) => n == null ? void 0 : n($),
|
|
1327
|
-
disabled:
|
|
1327
|
+
disabled: H || C,
|
|
1328
1328
|
className: "nice-money-input__currency",
|
|
1329
1329
|
"aria-label": "Currency"
|
|
1330
1330
|
}
|
|
1331
1331
|
),
|
|
1332
|
-
u && /* @__PURE__ */ c("span", { className: "nice-money-input__symbol", "aria-hidden": !0, children: (oe == null ? void 0 : oe.symbol) ??
|
|
1332
|
+
u && /* @__PURE__ */ c("span", { className: "nice-money-input__symbol", "aria-hidden": !0, children: (oe == null ? void 0 : oe.symbol) ?? S }),
|
|
1333
1333
|
k && /* @__PURE__ */ c(
|
|
1334
1334
|
"button",
|
|
1335
1335
|
{
|
|
1336
1336
|
type: "button",
|
|
1337
1337
|
className: "nice-money-input__step nice-money-input__step--down",
|
|
1338
|
-
onClick: () =>
|
|
1339
|
-
disabled:
|
|
1338
|
+
onClick: () => Re(-Se),
|
|
1339
|
+
disabled: H || C || s != null && e != null && e.amount / Math.pow(10, W) <= s,
|
|
1340
1340
|
"aria-label": "Decrease amount",
|
|
1341
1341
|
tabIndex: -1,
|
|
1342
1342
|
children: "−"
|
|
@@ -1351,17 +1351,17 @@ const Te = ie(function({
|
|
|
1351
1351
|
inputMode: "decimal",
|
|
1352
1352
|
autoComplete: "transaction-amount",
|
|
1353
1353
|
className: "nice-money-input__amount",
|
|
1354
|
-
value:
|
|
1355
|
-
onChange:
|
|
1356
|
-
onKeyDown:
|
|
1354
|
+
value: Ze,
|
|
1355
|
+
onChange: Ge,
|
|
1356
|
+
onKeyDown: Xe,
|
|
1357
1357
|
onFocus: ($) => {
|
|
1358
|
-
|
|
1358
|
+
$e(!0), U == null || U($);
|
|
1359
1359
|
},
|
|
1360
1360
|
onBlur: ($) => {
|
|
1361
|
-
|
|
1361
|
+
$e(!1), e && fe((e.amount / Math.pow(10, W)).toFixed(W)), Z == null || Z($);
|
|
1362
1362
|
},
|
|
1363
1363
|
placeholder: v ?? `0${W > 0 ? "." + "0".repeat(W) : ""}`,
|
|
1364
|
-
disabled:
|
|
1364
|
+
disabled: H,
|
|
1365
1365
|
readOnly: C,
|
|
1366
1366
|
required: w,
|
|
1367
1367
|
"aria-invalid": !!pe,
|
|
@@ -1373,16 +1373,16 @@ const Te = ie(function({
|
|
|
1373
1373
|
{
|
|
1374
1374
|
type: "button",
|
|
1375
1375
|
className: "nice-money-input__step nice-money-input__step--up",
|
|
1376
|
-
onClick: () =>
|
|
1377
|
-
disabled:
|
|
1376
|
+
onClick: () => Re(Se),
|
|
1377
|
+
disabled: H || C || o != null && e != null && e.amount / Math.pow(10, W) >= o,
|
|
1378
1378
|
"aria-label": "Increase amount",
|
|
1379
1379
|
tabIndex: -1,
|
|
1380
1380
|
children: "+"
|
|
1381
1381
|
}
|
|
1382
1382
|
),
|
|
1383
|
-
N && /* @__PURE__ */ c("span", { className: "nice-money-input__spinner", "aria-hidden": !0, children: "
|
|
1383
|
+
N && /* @__PURE__ */ c("span", { className: "nice-money-input__spinner", "aria-hidden": !0, children: /* @__PURE__ */ c(Ce, { name: "refresh", size: 14 }) })
|
|
1384
1384
|
] }),
|
|
1385
|
-
O &&
|
|
1385
|
+
O && Ae && /* @__PURE__ */ c("span", { className: "nice-money-input__preview", "aria-live": "polite", children: Ae }),
|
|
1386
1386
|
(pe || d) && /* @__PURE__ */ c(
|
|
1387
1387
|
"span",
|
|
1388
1388
|
{
|
|
@@ -1393,9 +1393,9 @@ const Te = ie(function({
|
|
|
1393
1393
|
)
|
|
1394
1394
|
] });
|
|
1395
1395
|
}
|
|
1396
|
-
),
|
|
1396
|
+
), Ot = { number: "", expiry: "", cvc: "" }, Ft = ie(
|
|
1397
1397
|
function({
|
|
1398
|
-
value: e =
|
|
1398
|
+
value: e = Ot,
|
|
1399
1399
|
onChange: r,
|
|
1400
1400
|
showHolderName: a = !0,
|
|
1401
1401
|
requireHolderName: n,
|
|
@@ -1410,52 +1410,52 @@ const Te = ie(function({
|
|
|
1410
1410
|
label: d,
|
|
1411
1411
|
helperText: b,
|
|
1412
1412
|
error: f,
|
|
1413
|
-
required:
|
|
1414
|
-
className:
|
|
1413
|
+
required: g,
|
|
1414
|
+
className: _,
|
|
1415
1415
|
style: w,
|
|
1416
1416
|
id: N,
|
|
1417
1417
|
title: D,
|
|
1418
1418
|
"data-testid": x
|
|
1419
1419
|
}, A) {
|
|
1420
|
-
const
|
|
1420
|
+
const I = y === "hidden", M = l || y === "disabled" || v, R = p || y === "readOnly", X = be(), O = N ?? `nice-cc-${X}`, [k, F] = z({
|
|
1421
1421
|
number: !1,
|
|
1422
1422
|
expiry: !1,
|
|
1423
1423
|
cvc: !1,
|
|
1424
1424
|
holder: !1,
|
|
1425
1425
|
postal: !1
|
|
1426
1426
|
}), T = q(() => Ne(e.number), [e.number]), Q = q(
|
|
1427
|
-
() =>
|
|
1427
|
+
() => Te(e, { requireHolder: n ?? a }),
|
|
1428
1428
|
[e, n, a]
|
|
1429
|
-
), ne = !u || u.includes(T) || T === "unknown", B =
|
|
1429
|
+
), ne = !u || u.includes(T) || T === "unknown", B = j(
|
|
1430
1430
|
(C) => {
|
|
1431
|
-
const K = { ...e, ...C }, se =
|
|
1431
|
+
const K = { ...e, ...C }, se = Te(K, { requireHolder: n ?? a });
|
|
1432
1432
|
r == null || r(K, se);
|
|
1433
1433
|
},
|
|
1434
1434
|
[e, n, a, r]
|
|
1435
|
-
), ae =
|
|
1435
|
+
), ae = j(
|
|
1436
1436
|
(C) => {
|
|
1437
1437
|
const K = C.target.value.replace(/\D/g, "").slice(0, 19);
|
|
1438
1438
|
B({ number: K });
|
|
1439
1439
|
},
|
|
1440
1440
|
[B]
|
|
1441
|
-
), Z =
|
|
1441
|
+
), Z = j(
|
|
1442
1442
|
(C) => {
|
|
1443
1443
|
const K = C.target.value.replace(/\D/g, "").slice(0, 4);
|
|
1444
1444
|
let se = K;
|
|
1445
1445
|
K.length >= 3 ? se = `${K.slice(0, 2)}/${K.slice(2)}` : K.length === 2 && (se = `${K}/`), B({ expiry: se });
|
|
1446
1446
|
},
|
|
1447
1447
|
[B]
|
|
1448
|
-
), U =
|
|
1448
|
+
), U = j(
|
|
1449
1449
|
(C) => {
|
|
1450
1450
|
const K = C.target.value.replace(/\D/g, "").slice(0, ye(T));
|
|
1451
1451
|
B({ cvc: K });
|
|
1452
1452
|
},
|
|
1453
1453
|
[T, B]
|
|
1454
|
-
), E = q(() =>
|
|
1455
|
-
return
|
|
1454
|
+
), E = q(() => dt(e.number, T), [e.number, T]), Y = k.number && e.number.length > 0 && (Le(e.number) ? ne ? void 0 : "Card brand not accepted" : Q.errors.number), m = k.expiry && e.expiry.length > 0 && !He(e.expiry) ? Q.errors.expiry : void 0, L = k.cvc && e.cvc.length > 0 && e.cvc.length !== ye(T) ? Q.errors.cvc : void 0, H = `nice-credit-card nice-credit-card--${o}` + (M ? " nice-credit-card--disabled" : "") + (v ? " nice-credit-card--loading" : "") + (f ? " nice-credit-card--error" : "") + (_ ? ` ${_}` : "");
|
|
1455
|
+
return I ? null : /* @__PURE__ */ h("div", { ref: A, className: H, style: w, title: D, "data-testid": x, children: [
|
|
1456
1456
|
d && /* @__PURE__ */ h("div", { className: "nice-credit-card__title", children: [
|
|
1457
1457
|
d,
|
|
1458
|
-
|
|
1458
|
+
g && /* @__PURE__ */ c("span", { className: "nice-credit-card__required", "aria-hidden": !0, children: "*" })
|
|
1459
1459
|
] }),
|
|
1460
1460
|
/* @__PURE__ */ c("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ h("label", { className: "nice-credit-card__field nice-credit-card__field--number", children: [
|
|
1461
1461
|
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: "Card number" }),
|
|
@@ -1479,7 +1479,7 @@ const Te = ie(function({
|
|
|
1479
1479
|
maxLength: T === "amex" ? 17 : 23
|
|
1480
1480
|
}
|
|
1481
1481
|
),
|
|
1482
|
-
s && /* @__PURE__ */ c(
|
|
1482
|
+
s && /* @__PURE__ */ c(Bt, { brand: T })
|
|
1483
1483
|
] }),
|
|
1484
1484
|
Y && /* @__PURE__ */ c("span", { id: `${O}-number-err`, className: "nice-credit-card__error", children: Y })
|
|
1485
1485
|
] }) }),
|
|
@@ -1498,7 +1498,7 @@ const Te = ie(function({
|
|
|
1498
1498
|
onChange: Z,
|
|
1499
1499
|
onBlur: () => {
|
|
1500
1500
|
F((K) => ({ ...K, expiry: !0 }));
|
|
1501
|
-
const C =
|
|
1501
|
+
const C = ze(e.expiry);
|
|
1502
1502
|
C && C !== e.expiry && B({ expiry: C });
|
|
1503
1503
|
},
|
|
1504
1504
|
disabled: M,
|
|
@@ -1582,7 +1582,7 @@ const Te = ie(function({
|
|
|
1582
1582
|
)
|
|
1583
1583
|
] });
|
|
1584
1584
|
}
|
|
1585
|
-
),
|
|
1585
|
+
), Ke = {
|
|
1586
1586
|
visa: "VISA",
|
|
1587
1587
|
mastercard: "MasterCard",
|
|
1588
1588
|
amex: "AMEX",
|
|
@@ -1596,17 +1596,17 @@ const Te = ie(function({
|
|
|
1596
1596
|
hipercard: "Hipercard",
|
|
1597
1597
|
unknown: ""
|
|
1598
1598
|
};
|
|
1599
|
-
function
|
|
1599
|
+
function Bt({ brand: t }) {
|
|
1600
1600
|
return t === "unknown" ? null : /* @__PURE__ */ c(
|
|
1601
1601
|
"span",
|
|
1602
1602
|
{
|
|
1603
1603
|
className: `nice-credit-card__brand nice-credit-card__brand--${t}`,
|
|
1604
|
-
"aria-label":
|
|
1605
|
-
children:
|
|
1604
|
+
"aria-label": Ke[t],
|
|
1605
|
+
children: Ke[t]
|
|
1606
1606
|
}
|
|
1607
1607
|
);
|
|
1608
1608
|
}
|
|
1609
|
-
const
|
|
1609
|
+
const dr = ie(
|
|
1610
1610
|
function({
|
|
1611
1611
|
processor: e,
|
|
1612
1612
|
amount: r,
|
|
@@ -1623,29 +1623,29 @@ const lr = ie(
|
|
|
1623
1623
|
className: d,
|
|
1624
1624
|
style: b
|
|
1625
1625
|
}, f) {
|
|
1626
|
-
const [
|
|
1626
|
+
const [g, _] = z(r), [w, N] = z(r.currency), [D, x] = z({ number: "", expiry: "", cvc: "" }), [A, I] = z(null), [M, R] = z(!1), [X, O] = z(null), k = Kt(e), F = q(() => e.supportedCurrencies === "*" ? !0 : e.supportedCurrencies.includes(g.currency.toUpperCase()), [e, g.currency]), T = q(() => {
|
|
1627
1627
|
var E;
|
|
1628
|
-
const U = (E = e.minimums) == null ? void 0 : E[
|
|
1629
|
-
return U == null ||
|
|
1630
|
-
}, [e,
|
|
1628
|
+
const U = (E = e.minimums) == null ? void 0 : E[g.currency.toUpperCase()];
|
|
1629
|
+
return U == null || g.amount >= U;
|
|
1630
|
+
}, [e, g]), Q = q(() => {
|
|
1631
1631
|
var E;
|
|
1632
|
-
const U = (E = e.minimums) == null ? void 0 : E[
|
|
1633
|
-
return U == null ? null : { amount: U, currency:
|
|
1634
|
-
}, [e,
|
|
1632
|
+
const U = (E = e.minimums) == null ? void 0 : E[g.currency.toUpperCase()];
|
|
1633
|
+
return U == null ? null : { amount: U, currency: g.currency };
|
|
1634
|
+
}, [e, g.currency]), ne = !!(A != null && A.isValid), B = !M && F && T && ne, ae = j(
|
|
1635
1635
|
async (U) => {
|
|
1636
1636
|
if (U.preventDefault(), !!B) {
|
|
1637
1637
|
O(null), R(!0);
|
|
1638
1638
|
try {
|
|
1639
1639
|
const E = {
|
|
1640
|
-
amount:
|
|
1640
|
+
amount: g,
|
|
1641
1641
|
card: D,
|
|
1642
1642
|
customer: n,
|
|
1643
1643
|
description: u,
|
|
1644
1644
|
metadata: s,
|
|
1645
|
-
idempotencyKey:
|
|
1645
|
+
idempotencyKey: Lt()
|
|
1646
1646
|
}, Y = await k.authorize(E);
|
|
1647
1647
|
if (o && Y.status === "authorized") {
|
|
1648
|
-
const m = await k.capture(Y.id,
|
|
1648
|
+
const m = await k.capture(Y.id, g);
|
|
1649
1649
|
p == null || p(m);
|
|
1650
1650
|
} else
|
|
1651
1651
|
p == null || p(Y);
|
|
@@ -1659,7 +1659,7 @@ const lr = ie(
|
|
|
1659
1659
|
},
|
|
1660
1660
|
[
|
|
1661
1661
|
B,
|
|
1662
|
-
|
|
1662
|
+
g,
|
|
1663
1663
|
D,
|
|
1664
1664
|
n,
|
|
1665
1665
|
u,
|
|
@@ -1669,7 +1669,7 @@ const lr = ie(
|
|
|
1669
1669
|
p,
|
|
1670
1670
|
v
|
|
1671
1671
|
]
|
|
1672
|
-
), Z = te(
|
|
1672
|
+
), Z = te(g.currency);
|
|
1673
1673
|
return /* @__PURE__ */ h(
|
|
1674
1674
|
"form",
|
|
1675
1675
|
{
|
|
@@ -1680,15 +1680,15 @@ const lr = ie(
|
|
|
1680
1680
|
"aria-busy": M,
|
|
1681
1681
|
children: [
|
|
1682
1682
|
/* @__PURE__ */ c("div", { className: "nice-payment-form__amount", children: a ? /* @__PURE__ */ c(
|
|
1683
|
-
|
|
1683
|
+
Ye,
|
|
1684
1684
|
{
|
|
1685
1685
|
label: "Amount",
|
|
1686
|
-
value:
|
|
1686
|
+
value: g,
|
|
1687
1687
|
currency: w,
|
|
1688
1688
|
currencies: i,
|
|
1689
|
-
onChange: (U) => U &&
|
|
1689
|
+
onChange: (U) => U && _(U),
|
|
1690
1690
|
onCurrencyChange: (U) => {
|
|
1691
|
-
N(U),
|
|
1691
|
+
N(U), _((E) => ({ ...E, currency: U }));
|
|
1692
1692
|
},
|
|
1693
1693
|
disabled: M,
|
|
1694
1694
|
required: !0,
|
|
@@ -1696,15 +1696,15 @@ const lr = ie(
|
|
|
1696
1696
|
}
|
|
1697
1697
|
) : /* @__PURE__ */ h("div", { className: "nice-payment-form__total", children: [
|
|
1698
1698
|
/* @__PURE__ */ c("span", { className: "nice-payment-form__total-label", children: "Total" }),
|
|
1699
|
-
/* @__PURE__ */ c(
|
|
1699
|
+
/* @__PURE__ */ c(qe, { value: g })
|
|
1700
1700
|
] }) }),
|
|
1701
1701
|
u && /* @__PURE__ */ c("p", { className: "nice-payment-form__description", children: u }),
|
|
1702
1702
|
/* @__PURE__ */ c("div", { className: "nice-payment-form__card", children: /* @__PURE__ */ c(
|
|
1703
|
-
|
|
1703
|
+
Ft,
|
|
1704
1704
|
{
|
|
1705
1705
|
value: D,
|
|
1706
1706
|
onChange: (U, E) => {
|
|
1707
|
-
x(U),
|
|
1707
|
+
x(U), I(E);
|
|
1708
1708
|
},
|
|
1709
1709
|
disabled: M
|
|
1710
1710
|
}
|
|
@@ -1712,14 +1712,14 @@ const lr = ie(
|
|
|
1712
1712
|
!F && /* @__PURE__ */ h("div", { className: "nice-payment-form__warning", role: "alert", children: [
|
|
1713
1713
|
e.name,
|
|
1714
1714
|
" does not accept ",
|
|
1715
|
-
(Z == null ? void 0 : Z.name) ??
|
|
1715
|
+
(Z == null ? void 0 : Z.name) ?? g.currency,
|
|
1716
1716
|
"."
|
|
1717
1717
|
] }),
|
|
1718
1718
|
!T && Q && /* @__PURE__ */ h("div", { className: "nice-payment-form__warning", role: "alert", children: [
|
|
1719
1719
|
"Minimum charge for ",
|
|
1720
1720
|
e.name,
|
|
1721
1721
|
" is ",
|
|
1722
|
-
/* @__PURE__ */ c(
|
|
1722
|
+
/* @__PURE__ */ c(qe, { value: Q }),
|
|
1723
1723
|
"."
|
|
1724
1724
|
] }),
|
|
1725
1725
|
y && /* @__PURE__ */ c("div", { className: "nice-payment-form__consents", children: y }),
|
|
@@ -1743,10 +1743,10 @@ const lr = ie(
|
|
|
1743
1743
|
);
|
|
1744
1744
|
}
|
|
1745
1745
|
);
|
|
1746
|
-
function
|
|
1746
|
+
function Lt() {
|
|
1747
1747
|
return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `idem_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`;
|
|
1748
1748
|
}
|
|
1749
|
-
const
|
|
1749
|
+
const ur = ie(function({
|
|
1750
1750
|
price: e,
|
|
1751
1751
|
originalPrice: r,
|
|
1752
1752
|
period: a,
|
|
@@ -1773,7 +1773,7 @@ const dr = ie(function({
|
|
|
1773
1773
|
] }),
|
|
1774
1774
|
i && /* @__PURE__ */ c("span", { className: "nice-price-tag__suffix", children: i })
|
|
1775
1775
|
] });
|
|
1776
|
-
}),
|
|
1776
|
+
}), zt = { amount: 0, currency: "USD" }, mr = ie(
|
|
1777
1777
|
function({
|
|
1778
1778
|
source: e,
|
|
1779
1779
|
defaultSource: r,
|
|
@@ -1787,22 +1787,22 @@ const dr = ie(function({
|
|
|
1787
1787
|
className: p,
|
|
1788
1788
|
style: v
|
|
1789
1789
|
}, y) {
|
|
1790
|
-
const [d, b] =
|
|
1790
|
+
const [d, b] = De({
|
|
1791
1791
|
value: e,
|
|
1792
1792
|
defaultValue: r,
|
|
1793
|
-
fallbackValue:
|
|
1793
|
+
fallbackValue: zt,
|
|
1794
1794
|
onChange: a,
|
|
1795
1795
|
componentName: "NiceCurrencyConverter"
|
|
1796
|
-
}), [f,
|
|
1796
|
+
}), [f, g] = De({
|
|
1797
1797
|
value: n,
|
|
1798
1798
|
defaultValue: i,
|
|
1799
1799
|
fallbackValue: d.currency,
|
|
1800
1800
|
onChange: u,
|
|
1801
1801
|
componentName: "NiceCurrencyConverter"
|
|
1802
|
-
}), { converted:
|
|
1802
|
+
}), { converted: _, loading: w, error: N } = Pe(d, f, s), D = q(
|
|
1803
1803
|
() => ({ amount: Math.pow(10, 2), currency: d.currency }),
|
|
1804
1804
|
[d.currency]
|
|
1805
|
-
), { converted: x } =
|
|
1805
|
+
), { converted: x } = Pe(
|
|
1806
1806
|
l ? D : null,
|
|
1807
1807
|
f,
|
|
1808
1808
|
s
|
|
@@ -1815,7 +1815,7 @@ const dr = ie(function({
|
|
|
1815
1815
|
style: v,
|
|
1816
1816
|
children: [
|
|
1817
1817
|
/* @__PURE__ */ c("div", { className: "nice-currency-converter__row", children: /* @__PURE__ */ c(
|
|
1818
|
-
|
|
1818
|
+
Ye,
|
|
1819
1819
|
{
|
|
1820
1820
|
label: "From",
|
|
1821
1821
|
value: d,
|
|
@@ -1832,11 +1832,11 @@ const dr = ie(function({
|
|
|
1832
1832
|
je,
|
|
1833
1833
|
{
|
|
1834
1834
|
value: f,
|
|
1835
|
-
onChange: (A) =>
|
|
1835
|
+
onChange: (A) => g(A),
|
|
1836
1836
|
compact: !0
|
|
1837
1837
|
}
|
|
1838
1838
|
),
|
|
1839
|
-
/* @__PURE__ */ c("span", { className: "nice-currency-converter__amount", children: w ? "…" : N ? "—" :
|
|
1839
|
+
/* @__PURE__ */ c("span", { className: "nice-currency-converter__amount", children: w ? "…" : N ? "—" : _ ? ce(_, { locale: o }) : "" })
|
|
1840
1840
|
] })
|
|
1841
1841
|
] }),
|
|
1842
1842
|
l && x && /* @__PURE__ */ h("p", { className: "nice-currency-converter__rate", children: [
|
|
@@ -1850,7 +1850,7 @@ const dr = ie(function({
|
|
|
1850
1850
|
f,
|
|
1851
1851
|
" =",
|
|
1852
1852
|
" ",
|
|
1853
|
-
ce(re(1 /
|
|
1853
|
+
ce(re(1 / Be(x), d.currency), { locale: o })
|
|
1854
1854
|
] })
|
|
1855
1855
|
] }),
|
|
1856
1856
|
N && /* @__PURE__ */ c("p", { className: "nice-currency-converter__error", role: "alert", children: N.message })
|
|
@@ -1859,10 +1859,10 @@ const dr = ie(function({
|
|
|
1859
1859
|
);
|
|
1860
1860
|
}
|
|
1861
1861
|
);
|
|
1862
|
-
function
|
|
1862
|
+
function Oe(t) {
|
|
1863
1863
|
return { amount: Math.round(t.amount), currency: t.currency };
|
|
1864
1864
|
}
|
|
1865
|
-
const
|
|
1865
|
+
const pr = ie(
|
|
1866
1866
|
function({
|
|
1867
1867
|
lines: e,
|
|
1868
1868
|
locale: r,
|
|
@@ -1885,31 +1885,31 @@ const mr = ie(
|
|
|
1885
1885
|
total: (s == null ? void 0 : s.total) ?? "Total"
|
|
1886
1886
|
}, b = q(() => {
|
|
1887
1887
|
if (a === "total") {
|
|
1888
|
-
const
|
|
1888
|
+
const _ = /* @__PURE__ */ new Map();
|
|
1889
1889
|
for (const N of e) {
|
|
1890
|
-
let D =
|
|
1891
|
-
D || (D = [],
|
|
1890
|
+
let D = _.get(N.vatRate);
|
|
1891
|
+
D || (D = [], _.set(N.vatRate, D)), D.push(N.netAmount);
|
|
1892
1892
|
}
|
|
1893
1893
|
const w = [];
|
|
1894
|
-
for (const [N, D] of
|
|
1895
|
-
const x = D.reduce((M, R) => me(M, R), re(0, D[0].currency)), A =
|
|
1896
|
-
w.push({ rate: N, net: x, vat: A, gross:
|
|
1894
|
+
for (const [N, D] of _) {
|
|
1895
|
+
const x = D.reduce((M, R) => me(M, R), re(0, D[0].currency)), A = Oe(Me(x, N)), I = me(x, A);
|
|
1896
|
+
w.push({ rate: N, net: x, vat: A, gross: I });
|
|
1897
1897
|
}
|
|
1898
1898
|
return w;
|
|
1899
1899
|
}
|
|
1900
|
-
return e.map((
|
|
1901
|
-
const w =
|
|
1902
|
-
return { label:
|
|
1900
|
+
return e.map((_) => {
|
|
1901
|
+
const w = Oe(Me(_.netAmount, _.vatRate)), N = me(_.netAmount, w);
|
|
1902
|
+
return { label: _.label, rate: _.vatRate, net: _.netAmount, vat: w, gross: N };
|
|
1903
1903
|
});
|
|
1904
1904
|
}, [e, a]), f = q(() => {
|
|
1905
1905
|
if (b.length === 0)
|
|
1906
1906
|
return null;
|
|
1907
|
-
const
|
|
1908
|
-
let w = re(0,
|
|
1907
|
+
const _ = b[0].net.currency;
|
|
1908
|
+
let w = re(0, _), N = re(0, _), D = re(0, _);
|
|
1909
1909
|
for (const x of b)
|
|
1910
1910
|
w = me(w, x.net), N = me(N, x.vat), D = me(D, x.gross);
|
|
1911
1911
|
return { net: w, vat: N, gross: D };
|
|
1912
|
-
}, [b]),
|
|
1912
|
+
}, [b]), g = (_) => ce(_, { locale: r });
|
|
1913
1913
|
return /* @__PURE__ */ h(
|
|
1914
1914
|
"table",
|
|
1915
1915
|
{
|
|
@@ -1921,34 +1921,34 @@ const mr = ie(
|
|
|
1921
1921
|
"aria-label": d.total,
|
|
1922
1922
|
children: [
|
|
1923
1923
|
/* @__PURE__ */ c("thead", { children: /* @__PURE__ */ h("tr", { children: [
|
|
1924
|
-
b.some((
|
|
1924
|
+
b.some((_) => _.label !== void 0) && /* @__PURE__ */ c("th", { scope: "col", children: d.label }),
|
|
1925
1925
|
!u && /* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__rate", children: d.rate }),
|
|
1926
1926
|
/* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__num", children: d.net }),
|
|
1927
1927
|
/* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__num", children: d.vat }),
|
|
1928
1928
|
/* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__num", children: d.gross })
|
|
1929
1929
|
] }) }),
|
|
1930
|
-
/* @__PURE__ */ c("tbody", { children: b.map((
|
|
1931
|
-
b.some((N) => N.label !== void 0) && /* @__PURE__ */ c("td", { children:
|
|
1930
|
+
/* @__PURE__ */ c("tbody", { children: b.map((_, w) => /* @__PURE__ */ h("tr", { children: [
|
|
1931
|
+
b.some((N) => N.label !== void 0) && /* @__PURE__ */ c("td", { children: _.label ?? "" }),
|
|
1932
1932
|
!u && /* @__PURE__ */ h("td", { className: "nice-tax-breakdown__rate", children: [
|
|
1933
|
-
(
|
|
1933
|
+
(_.rate * 100).toLocaleString(r, { maximumFractionDigits: 2 }),
|
|
1934
1934
|
"%"
|
|
1935
1935
|
] }),
|
|
1936
|
-
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: _
|
|
1937
|
-
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: _
|
|
1938
|
-
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: _
|
|
1939
|
-
] }, `${
|
|
1936
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: g(_.net) }),
|
|
1937
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: g(_.vat) }),
|
|
1938
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: g(_.gross) })
|
|
1939
|
+
] }, `${_.rate}-${w}`)) }),
|
|
1940
1940
|
n && f && /* @__PURE__ */ c("tfoot", { children: i && /* @__PURE__ */ h("tr", { className: "nice-tax-breakdown__totals", children: [
|
|
1941
|
-
b.some((
|
|
1942
|
-
!u && /* @__PURE__ */ c("td", {}),
|
|
1943
|
-
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children:
|
|
1944
|
-
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children:
|
|
1945
|
-
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children:
|
|
1941
|
+
b.some((_) => _.label !== void 0) && /* @__PURE__ */ c("td", { children: d.total }),
|
|
1942
|
+
!u && /* @__PURE__ */ c("td", { children: b.some((_) => _.label !== void 0) ? null : d.total }),
|
|
1943
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: g(f.net) }),
|
|
1944
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: g(f.vat) }),
|
|
1945
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: g(f.gross) })
|
|
1946
1946
|
] }) })
|
|
1947
1947
|
]
|
|
1948
1948
|
}
|
|
1949
1949
|
);
|
|
1950
1950
|
}
|
|
1951
|
-
),
|
|
1951
|
+
), yr = ie(
|
|
1952
1952
|
function(e, r) {
|
|
1953
1953
|
const {
|
|
1954
1954
|
methods: a,
|
|
@@ -1964,19 +1964,19 @@ const mr = ie(
|
|
|
1964
1964
|
style: d,
|
|
1965
1965
|
id: b,
|
|
1966
1966
|
accessMode: f,
|
|
1967
|
-
"data-testid":
|
|
1968
|
-
} = e,
|
|
1967
|
+
"data-testid": g
|
|
1968
|
+
} = e, _ = be(), w = p ?? `nice-pm-${_}`, N = q(() => {
|
|
1969
1969
|
if (!o)
|
|
1970
1970
|
return a;
|
|
1971
|
-
const
|
|
1971
|
+
const I = o.toUpperCase();
|
|
1972
1972
|
return a.filter(
|
|
1973
|
-
(M) => !M.currencies || M.currencies.map((R) => R.toUpperCase()).includes(
|
|
1973
|
+
(M) => !M.currencies || M.currencies.map((R) => R.toUpperCase()).includes(I)
|
|
1974
1974
|
);
|
|
1975
1975
|
}, [a, o]);
|
|
1976
1976
|
if (f === "hidden")
|
|
1977
1977
|
return null;
|
|
1978
1978
|
const D = v || f === "disabled" || f === "readOnly", x = `nice-payment-method-selector nice-payment-method-selector--${u}` + (y ? ` ${y}` : ""), A = u === "grid" ? { gridTemplateColumns: `repeat(${s}, minmax(0, 1fr))` } : void 0;
|
|
1979
|
-
return /* @__PURE__ */ h("div", { ref: r, id: b, className: x, style: d, "data-testid":
|
|
1979
|
+
return /* @__PURE__ */ h("div", { ref: r, id: b, className: x, style: d, "data-testid": g, children: [
|
|
1980
1980
|
l && /* @__PURE__ */ c("div", { className: "nice-payment-method-selector__label", children: l }),
|
|
1981
1981
|
/* @__PURE__ */ h(
|
|
1982
1982
|
"div",
|
|
@@ -1986,8 +1986,8 @@ const mr = ie(
|
|
|
1986
1986
|
role: "radiogroup",
|
|
1987
1987
|
"aria-label": l ?? "Payment method",
|
|
1988
1988
|
children: [
|
|
1989
|
-
N.map((
|
|
1990
|
-
const M =
|
|
1989
|
+
N.map((I) => {
|
|
1990
|
+
const M = I.id === n, R = D || I.disabled;
|
|
1991
1991
|
return /* @__PURE__ */ h(
|
|
1992
1992
|
"label",
|
|
1993
1993
|
{
|
|
@@ -1999,20 +1999,20 @@ const mr = ie(
|
|
|
1999
1999
|
type: "radio",
|
|
2000
2000
|
className: "nice-payment-method-selector__radio",
|
|
2001
2001
|
name: w,
|
|
2002
|
-
value:
|
|
2002
|
+
value: I.id,
|
|
2003
2003
|
checked: M,
|
|
2004
2004
|
disabled: R,
|
|
2005
|
-
onChange: () => i == null ? void 0 : i(
|
|
2005
|
+
onChange: () => i == null ? void 0 : i(I.id)
|
|
2006
2006
|
}
|
|
2007
2007
|
),
|
|
2008
|
-
|
|
2008
|
+
I.icon && /* @__PURE__ */ c("span", { className: "nice-payment-method-selector__icon", children: I.icon }),
|
|
2009
2009
|
/* @__PURE__ */ h("span", { className: "nice-payment-method-selector__text", children: [
|
|
2010
|
-
/* @__PURE__ */ c("span", { className: "nice-payment-method-selector__name", children:
|
|
2011
|
-
|
|
2010
|
+
/* @__PURE__ */ c("span", { className: "nice-payment-method-selector__name", children: I.label }),
|
|
2011
|
+
I.description && /* @__PURE__ */ c("span", { className: "nice-payment-method-selector__desc", children: I.description })
|
|
2012
2012
|
] })
|
|
2013
2013
|
]
|
|
2014
2014
|
},
|
|
2015
|
-
|
|
2015
|
+
I.id
|
|
2016
2016
|
);
|
|
2017
2017
|
}),
|
|
2018
2018
|
N.length === 0 && /* @__PURE__ */ c("div", { className: "nice-payment-method-selector__empty", children: "No methods available." })
|
|
@@ -2035,7 +2035,7 @@ const mr = ie(
|
|
|
2035
2035
|
mode: "test",
|
|
2036
2036
|
credentials: {},
|
|
2037
2037
|
enabledMethods: []
|
|
2038
|
-
},
|
|
2038
|
+
}, hr = ie(
|
|
2039
2039
|
function(e, r) {
|
|
2040
2040
|
const {
|
|
2041
2041
|
value: a,
|
|
@@ -2051,18 +2051,18 @@ const mr = ie(
|
|
|
2051
2051
|
className: d,
|
|
2052
2052
|
style: b,
|
|
2053
2053
|
id: f,
|
|
2054
|
-
accessMode:
|
|
2055
|
-
"data-testid":
|
|
2056
|
-
} = e, [w, N] =
|
|
2054
|
+
accessMode: g,
|
|
2055
|
+
"data-testid": _
|
|
2056
|
+
} = e, [w, N] = De({
|
|
2057
2057
|
value: a,
|
|
2058
2058
|
defaultValue: n,
|
|
2059
2059
|
fallbackValue: jt,
|
|
2060
2060
|
onChange: i,
|
|
2061
2061
|
componentName: "NicePaymentProviderConfig"
|
|
2062
|
-
}), D = be(), [x, A] =
|
|
2063
|
-
if (
|
|
2062
|
+
}), D = be(), [x, A] = z(/* @__PURE__ */ new Set()), [I, M] = z(!1), [R, X] = z(null), O = q(() => u ? u.map((m) => ve[m]).filter((m) => !!m) : qt, [u]), k = ve[w.providerId];
|
|
2063
|
+
if (g === "hidden")
|
|
2064
2064
|
return null;
|
|
2065
|
-
const F = p ||
|
|
2065
|
+
const F = p || g === "disabled" || g === "readOnly", T = (m) => {
|
|
2066
2066
|
X(null), A(/* @__PURE__ */ new Set()), N({ providerId: m, mode: w.mode, credentials: {}, enabledMethods: [] });
|
|
2067
2067
|
}, Q = (m, L) => {
|
|
2068
2068
|
N({ ...w, credentials: { ...w.credentials, [m]: L } });
|
|
@@ -2071,8 +2071,8 @@ const mr = ie(
|
|
|
2071
2071
|
L.has(m) ? L.delete(m) : L.add(m), N({ ...w, enabledMethods: [...L] });
|
|
2072
2072
|
}, B = (m) => {
|
|
2073
2073
|
A((L) => {
|
|
2074
|
-
const
|
|
2075
|
-
return
|
|
2074
|
+
const H = new Set(L);
|
|
2075
|
+
return H.has(m) ? H.delete(m) : H.add(m), H;
|
|
2076
2076
|
});
|
|
2077
2077
|
}, ae = async () => {
|
|
2078
2078
|
if (s) {
|
|
@@ -2088,8 +2088,8 @@ const mr = ie(
|
|
|
2088
2088
|
}, Z = k != null && k.webhookPath ? `${(l ?? "").replace(/\/$/, "")}${k.webhookPath}` : "", U = (k == null ? void 0 : k.supportedCurrencies) === "*" ? "All currencies" : ((k == null ? void 0 : k.supportedCurrencies) ?? []).join(", "), E = "nice-payment-provider-config" + (d ? ` ${d}` : ""), Y = ((k == null ? void 0 : k.credentials) ?? []).filter(
|
|
2089
2089
|
(m) => !m.testOnly || w.mode === "test"
|
|
2090
2090
|
);
|
|
2091
|
-
return /* @__PURE__ */ h("div", { ref: r, id: f, className: E, style: b, "data-testid":
|
|
2092
|
-
y && /* @__PURE__ */ c("div", { className: "nice-payment-provider-config__tutorial", children: /* @__PURE__ */ c(
|
|
2091
|
+
return /* @__PURE__ */ h("div", { ref: r, id: f, className: E, style: b, "data-testid": _, children: [
|
|
2092
|
+
y && /* @__PURE__ */ c("div", { className: "nice-payment-provider-config__tutorial", children: /* @__PURE__ */ c(ct, { steps: it(y, Ht) }) }),
|
|
2093
2093
|
/* @__PURE__ */ h("div", { className: "nice-payment-provider-config__row", children: [
|
|
2094
2094
|
/* @__PURE__ */ h("label", { className: "nice-payment-provider-config__field", children: [
|
|
2095
2095
|
/* @__PURE__ */ c("span", { className: "nice-payment-provider-config__field-label", children: "Provider" }),
|
|
@@ -2130,13 +2130,13 @@ const mr = ie(
|
|
|
2130
2130
|
)
|
|
2131
2131
|
] })
|
|
2132
2132
|
] }),
|
|
2133
|
-
k && /* @__PURE__ */ h(
|
|
2133
|
+
k && /* @__PURE__ */ h(at, { children: [
|
|
2134
2134
|
/* @__PURE__ */ h("div", { className: "nice-payment-provider-config__meta", children: [
|
|
2135
2135
|
/* @__PURE__ */ c("span", { className: "nice-payment-provider-config__badge", children: k.type }),
|
|
2136
2136
|
/* @__PURE__ */ c("span", { className: "nice-payment-provider-config__currencies", children: U })
|
|
2137
2137
|
] }),
|
|
2138
2138
|
/* @__PURE__ */ c("div", { className: "nice-payment-provider-config__credentials", children: Y.map((m) => {
|
|
2139
|
-
const L = `${D}-${m.key}`,
|
|
2139
|
+
const L = `${D}-${m.key}`, H = m.secret, C = x.has(m.key);
|
|
2140
2140
|
return /* @__PURE__ */ h("div", { className: "nice-payment-provider-config__field", children: [
|
|
2141
2141
|
/* @__PURE__ */ h("label", { className: "nice-payment-provider-config__field-label", htmlFor: L, children: [
|
|
2142
2142
|
m.label,
|
|
@@ -2147,15 +2147,15 @@ const mr = ie(
|
|
|
2147
2147
|
"input",
|
|
2148
2148
|
{
|
|
2149
2149
|
id: L,
|
|
2150
|
-
type:
|
|
2150
|
+
type: H && !C ? "password" : "text",
|
|
2151
2151
|
className: "nice-payment-provider-config__input",
|
|
2152
2152
|
value: w.credentials[m.key] ?? "",
|
|
2153
2153
|
readOnly: F,
|
|
2154
|
-
autoComplete:
|
|
2154
|
+
autoComplete: H ? "new-password" : "off",
|
|
2155
2155
|
onChange: (K) => Q(m.key, K.target.value)
|
|
2156
2156
|
}
|
|
2157
2157
|
),
|
|
2158
|
-
|
|
2158
|
+
H && /* @__PURE__ */ c(
|
|
2159
2159
|
"button",
|
|
2160
2160
|
{
|
|
2161
2161
|
type: "button",
|
|
@@ -2163,7 +2163,7 @@ const mr = ie(
|
|
|
2163
2163
|
onClick: () => B(m.key),
|
|
2164
2164
|
"aria-label": C ? "Hide" : "Reveal",
|
|
2165
2165
|
"aria-pressed": C,
|
|
2166
|
-
children: C ? "
|
|
2166
|
+
children: /* @__PURE__ */ c(Ce, { name: C ? "eye-off" : "eye", size: 14 })
|
|
2167
2167
|
}
|
|
2168
2168
|
)
|
|
2169
2169
|
] }),
|
|
@@ -2196,8 +2196,8 @@ const mr = ie(
|
|
|
2196
2196
|
type: "button",
|
|
2197
2197
|
className: "nice-payment-provider-config__test-btn",
|
|
2198
2198
|
onClick: () => void ae(),
|
|
2199
|
-
disabled: F ||
|
|
2200
|
-
children:
|
|
2199
|
+
disabled: F || I,
|
|
2200
|
+
children: I ? "Testing…" : v
|
|
2201
2201
|
}
|
|
2202
2202
|
),
|
|
2203
2203
|
R && /* @__PURE__ */ h(
|
|
@@ -2205,7 +2205,7 @@ const mr = ie(
|
|
|
2205
2205
|
{
|
|
2206
2206
|
className: "nice-payment-provider-config__test-result nice-payment-provider-config__test-result--" + (R.ok ? "ok" : "error"),
|
|
2207
2207
|
children: [
|
|
2208
|
-
R.ok ? "
|
|
2208
|
+
/* @__PURE__ */ c(Ce, { name: R.ok ? "check" : "close", size: 14 }),
|
|
2209
2209
|
" ",
|
|
2210
2210
|
R.message ?? (R.ok ? "OK" : "Failed")
|
|
2211
2211
|
]
|
|
@@ -2217,71 +2217,71 @@ const mr = ie(
|
|
|
2217
2217
|
}
|
|
2218
2218
|
);
|
|
2219
2219
|
export {
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2220
|
+
ht as EcbRatesProvider,
|
|
2221
|
+
pt as ExchangeRateHostProvider,
|
|
2222
|
+
ut as FrankfurterProvider,
|
|
2223
|
+
bt as FreeForexApiProvider,
|
|
2224
|
+
_t as MockPaymentProcessor,
|
|
2225
2225
|
he as NICE_CURRENCY_CATALOG,
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2226
|
+
lr as NICE_CURRENCY_CODES,
|
|
2227
|
+
Ut as NICE_PAYMENT_PROCESSORS,
|
|
2228
|
+
qt as NICE_PAYMENT_PROVIDER_LIST,
|
|
2229
2229
|
ve as NICE_PAYMENT_PROVIDER_PROFILES,
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2230
|
+
yt as NbpRatesProvider,
|
|
2231
|
+
Ft as NiceCreditCardInput,
|
|
2232
|
+
mr as NiceCurrencyConverter,
|
|
2233
2233
|
je as NiceCurrencySelector,
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2234
|
+
qe as NiceMoney,
|
|
2235
|
+
Ye as NiceMoneyInput,
|
|
2236
|
+
dr as NicePaymentForm,
|
|
2237
|
+
yr as NicePaymentMethodSelector,
|
|
2238
|
+
hr as NicePaymentProviderConfig,
|
|
2239
|
+
ur as NicePriceTag,
|
|
2240
|
+
pr as NiceTaxBreakdown,
|
|
2241
|
+
mt as OpenExchangeRatesProvider,
|
|
2242
|
+
rr as StaticExchangeRateProvider,
|
|
2243
2243
|
me as addMoney,
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2244
|
+
Qt as compareMoney,
|
|
2245
|
+
ft as convertMoney,
|
|
2246
|
+
ar as createEcbRatesProvider,
|
|
2247
|
+
ir as createFreeForexApiProvider,
|
|
2248
|
+
nr as createNbpRatesProvider,
|
|
2249
|
+
cr as createOpenExchangeRatesProvider,
|
|
2250
2250
|
Ne as detectCardBrand,
|
|
2251
2251
|
ye as expectedCvcLength,
|
|
2252
2252
|
te as findCurrency,
|
|
2253
|
-
|
|
2254
|
-
|
|
2253
|
+
sr as findPaymentProviderProfile,
|
|
2254
|
+
dt as formatCardNumber,
|
|
2255
2255
|
ce as formatMoney,
|
|
2256
|
-
|
|
2256
|
+
Be as fromMoney,
|
|
2257
2257
|
He as isExpiryValid,
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2258
|
+
Wt as isNegative,
|
|
2259
|
+
Vt as isZero,
|
|
2260
|
+
Le as luhnCheck,
|
|
2261
|
+
Nt as makeAdyenAdapter,
|
|
2262
2262
|
St as makeAutopayAdapter,
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2263
|
+
$t as makeBlikAdapter,
|
|
2264
|
+
Ct as makeBraintreeAdapter,
|
|
2265
|
+
Rt as makeCoinbaseCommerceAdapter,
|
|
2266
|
+
xt as makeKlarnaAdapter,
|
|
2267
|
+
kt as makeMollieAdapter,
|
|
2268
|
+
vt as makePayPalAdapter,
|
|
2269
|
+
Mt as makePayUAdapter,
|
|
2270
|
+
Pt as makePrzelewy24Adapter,
|
|
2271
|
+
Dt as makeRazorpayAdapter,
|
|
2272
|
+
wt as makeSquareAdapter,
|
|
2273
|
+
gt as makeStripeAdapter,
|
|
2274
|
+
It as makeTpayAdapter,
|
|
2275
|
+
tr as maskCardNumber,
|
|
2276
|
+
Me as multiplyMoney,
|
|
2277
|
+
er as negateMoney,
|
|
2278
|
+
ze as normaliseExpiry,
|
|
2279
|
+
lt as parseMoney,
|
|
2280
|
+
Xt as registerCurrency,
|
|
2281
|
+
ot as subtractMoney,
|
|
2282
2282
|
re as toMoney,
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2283
|
+
Pe as useNiceExchangeRate,
|
|
2284
|
+
or as useNiceMoney,
|
|
2285
|
+
Kt as useNicePayment,
|
|
2286
|
+
Te as validateCreditCard
|
|
2287
2287
|
};
|