@nice2dev/ui-money 1.3.7 → 1.3.9
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 +12 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +586 -569
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ var it = Object.defineProperty;
|
|
|
2
2
|
var st = (t, e, r) => e in t ? it(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
3
|
var Z = (t, e, r) => st(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
4
|
import ot, { useState as j, useRef as Re, useEffect as lt, useMemo as B, useCallback as Y, forwardRef as se, useId as Ne } from "react";
|
|
5
|
-
import { jsxs as
|
|
5
|
+
import { jsxs as f, jsx as c, Fragment as dt } from "react/jsx-runtime";
|
|
6
6
|
import { useNiceTranslation as oe, useEngage as ut, NiceIcon as ve, useControllableState as Ue, NiceTutorialButton as mt, resolveTutorial as pt } from "@nice2dev/ui-core";
|
|
7
7
|
const _e = [
|
|
8
8
|
// ── Majors ─────────────────────────────────────
|
|
@@ -300,8 +300,8 @@ function ft(t, e) {
|
|
|
300
300
|
const a = r.lastIndexOf("."), s = r.lastIndexOf(","), d = Math.max(a, s);
|
|
301
301
|
let i, o = "";
|
|
302
302
|
d === -1 ? i = r : (i = r.slice(0, d).replace(/[.,]/g, ""), o = r.slice(d + 1).replace(/[.,]/g, ""));
|
|
303
|
-
const l = `${i}.${o || "0"}`,
|
|
304
|
-
return Number.isFinite(
|
|
303
|
+
const l = `${i}.${o || "0"}`, p = parseFloat(l);
|
|
304
|
+
return Number.isFinite(p) ? ae(n ? -p : p, e) : null;
|
|
305
305
|
}
|
|
306
306
|
function Me(t) {
|
|
307
307
|
const e = (t || "").replace(/\D/g, "");
|
|
@@ -382,11 +382,11 @@ class ur {
|
|
|
382
382
|
return { base: n, quote: a, rate: 1 / d.rate, asOf: d.asOf };
|
|
383
383
|
const i = this.rates.find((l) => l.base === n && l.quote === "USD") ?? this.rates.find((l) => l.base === "USD" && l.quote === n), o = this.rates.find((l) => l.base === "USD" && l.quote === a) ?? this.rates.find((l) => l.base === a && l.quote === "USD");
|
|
384
384
|
if (i && o) {
|
|
385
|
-
const l = i.base === "USD" ? 1 / i.rate : i.rate,
|
|
385
|
+
const l = i.base === "USD" ? 1 / i.rate : i.rate, p = o.base === "USD" ? o.rate : 1 / o.rate;
|
|
386
386
|
return {
|
|
387
387
|
base: n,
|
|
388
388
|
quote: a,
|
|
389
|
-
rate: l *
|
|
389
|
+
rate: l * p,
|
|
390
390
|
asOf: (/* @__PURE__ */ new Date()).toISOString()
|
|
391
391
|
};
|
|
392
392
|
}
|
|
@@ -429,10 +429,10 @@ class _t extends Ie {
|
|
|
429
429
|
const i = `https://api.frankfurter.app/latest?from=${a}&to=${s}`, o = await this.fetchImpl(i);
|
|
430
430
|
if (!o.ok)
|
|
431
431
|
throw new Error(`Frankfurter HTTP ${o.status}`);
|
|
432
|
-
const l = await o.json(),
|
|
433
|
-
if (
|
|
432
|
+
const l = await o.json(), p = l.rates[s];
|
|
433
|
+
if (p == null)
|
|
434
434
|
throw new Error(`Frankfurter: no rate for ${a}/${s}`);
|
|
435
|
-
const N = { base: a, quote: s, rate:
|
|
435
|
+
const N = { base: a, quote: s, rate: p, asOf: l.date };
|
|
436
436
|
return this.setCached(N), N;
|
|
437
437
|
}
|
|
438
438
|
}
|
|
@@ -452,16 +452,16 @@ class gt extends Ie {
|
|
|
452
452
|
const i = `https://openexchangerates.org/api/latest.json?app_id=${this.appId}`, o = await this.fetchImpl(i);
|
|
453
453
|
if (!o.ok)
|
|
454
454
|
throw new Error(`OpenExchangeRates HTTP ${o.status}`);
|
|
455
|
-
const l = await o.json(),
|
|
456
|
-
if (
|
|
455
|
+
const l = await o.json(), p = l.rates[a], N = l.rates[s];
|
|
456
|
+
if (p == null || N == null)
|
|
457
457
|
throw new Error(`OpenExchangeRates: missing rate for ${a} or ${s}`);
|
|
458
|
-
const
|
|
458
|
+
const h = {
|
|
459
459
|
base: a,
|
|
460
460
|
quote: s,
|
|
461
|
-
rate: N /
|
|
461
|
+
rate: N / p,
|
|
462
462
|
asOf: new Date(l.timestamp * 1e3).toISOString()
|
|
463
463
|
};
|
|
464
|
-
return this.setCached(
|
|
464
|
+
return this.setCached(h), h;
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
467
|
class vt extends Ie {
|
|
@@ -470,7 +470,7 @@ class vt extends Ie {
|
|
|
470
470
|
Z(this, "id", "exchangerate.host");
|
|
471
471
|
}
|
|
472
472
|
async getRate(r, n) {
|
|
473
|
-
var
|
|
473
|
+
var h;
|
|
474
474
|
const a = r.toUpperCase(), s = n.toUpperCase();
|
|
475
475
|
if (a === s)
|
|
476
476
|
return { base: a, quote: s, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -480,7 +480,7 @@ class vt extends Ie {
|
|
|
480
480
|
const i = `https://api.exchangerate.host/convert?from=${a}&to=${s}`, o = await this.fetchImpl(i);
|
|
481
481
|
if (!o.ok)
|
|
482
482
|
throw new Error(`exchangerate.host HTTP ${o.status}`);
|
|
483
|
-
const l = await o.json(),
|
|
483
|
+
const l = await o.json(), p = ((h = l.info) == null ? void 0 : h.rate) ?? l.result, N = { base: a, quote: s, rate: p, asOf: l.date };
|
|
484
484
|
return this.setCached(N), N;
|
|
485
485
|
}
|
|
486
486
|
}
|
|
@@ -499,24 +499,24 @@ class Nt extends Ie {
|
|
|
499
499
|
if (d)
|
|
500
500
|
return d;
|
|
501
501
|
const i = async (N) => {
|
|
502
|
-
var
|
|
502
|
+
var _;
|
|
503
503
|
if (N === "PLN")
|
|
504
504
|
return { rate: 1, date: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10) };
|
|
505
|
-
const
|
|
505
|
+
const h = `https://api.nbp.pl/api/exchangerates/rates/${this.table}/${N}/?format=json`, u = await this.fetchImpl(h);
|
|
506
506
|
if (!u.ok)
|
|
507
507
|
return null;
|
|
508
|
-
const
|
|
509
|
-
return
|
|
508
|
+
const b = (_ = (await u.json()).rates) == null ? void 0 : _[0];
|
|
509
|
+
return b ? { rate: b.mid ?? b.ask ?? 0, date: b.effectiveDate } : null;
|
|
510
510
|
}, o = await i(a), l = await i(s);
|
|
511
511
|
if (!o || !l || o.rate === 0)
|
|
512
512
|
throw new Error(`NBP: missing rate for ${a} or ${s}`);
|
|
513
|
-
const
|
|
513
|
+
const p = {
|
|
514
514
|
base: a,
|
|
515
515
|
quote: s,
|
|
516
516
|
rate: o.rate / l.rate,
|
|
517
517
|
asOf: o.date
|
|
518
518
|
};
|
|
519
|
-
return this.setCached(
|
|
519
|
+
return this.setCached(p), p;
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
522
|
class wt extends _t {
|
|
@@ -536,10 +536,10 @@ async function Ct(t, e, r) {
|
|
|
536
536
|
const n = e.toUpperCase();
|
|
537
537
|
if (t.currency.toUpperCase() === n)
|
|
538
538
|
return t;
|
|
539
|
-
const a = te(t.currency), s = te(n), d = (a == null ? void 0 : a.decimals) ?? 2, i = (s == null ? void 0 : s.decimals) ?? 2, { rate: o } = await r.getRate(t.currency, n),
|
|
539
|
+
const a = te(t.currency), s = te(n), d = (a == null ? void 0 : a.decimals) ?? 2, i = (s == null ? void 0 : s.decimals) ?? 2, { rate: o } = await r.getRate(t.currency, n), p = t.amount / Math.pow(10, d) * o;
|
|
540
540
|
return {
|
|
541
541
|
currency: n,
|
|
542
|
-
amount: Math.round(
|
|
542
|
+
amount: Math.round(p * Math.pow(10, i))
|
|
543
543
|
};
|
|
544
544
|
}
|
|
545
545
|
class Dt {
|
|
@@ -583,7 +583,7 @@ class Dt {
|
|
|
583
583
|
};
|
|
584
584
|
}
|
|
585
585
|
}
|
|
586
|
-
function
|
|
586
|
+
function ee(t, e, r, n, a) {
|
|
587
587
|
const s = (d) => {
|
|
588
588
|
const i = n == null ? void 0 : n[d];
|
|
589
589
|
return i || (async () => {
|
|
@@ -604,7 +604,7 @@ function W(t, e, r, n, a) {
|
|
|
604
604
|
};
|
|
605
605
|
}
|
|
606
606
|
function Pt(t) {
|
|
607
|
-
return
|
|
607
|
+
return ee("stripe", "Stripe", "*", t, {
|
|
608
608
|
USD: 50,
|
|
609
609
|
EUR: 50,
|
|
610
610
|
GBP: 30,
|
|
@@ -619,7 +619,7 @@ function Pt(t) {
|
|
|
619
619
|
});
|
|
620
620
|
}
|
|
621
621
|
function Mt(t) {
|
|
622
|
-
return
|
|
622
|
+
return ee(
|
|
623
623
|
"paypal",
|
|
624
624
|
"PayPal",
|
|
625
625
|
[
|
|
@@ -650,22 +650,22 @@ function Mt(t) {
|
|
|
650
650
|
);
|
|
651
651
|
}
|
|
652
652
|
function It(t) {
|
|
653
|
-
return
|
|
653
|
+
return ee("adyen", "Adyen", "*", t);
|
|
654
654
|
}
|
|
655
655
|
function St(t) {
|
|
656
|
-
return
|
|
656
|
+
return ee("square", "Square", ["USD", "CAD", "GBP", "AUD", "JPY", "EUR"], t);
|
|
657
657
|
}
|
|
658
658
|
function $t(t) {
|
|
659
|
-
return
|
|
659
|
+
return ee("mollie", "Mollie", "*", t);
|
|
660
660
|
}
|
|
661
661
|
function xt(t) {
|
|
662
|
-
return
|
|
662
|
+
return ee("braintree", "Braintree", "*", t);
|
|
663
663
|
}
|
|
664
664
|
function Rt(t) {
|
|
665
|
-
return
|
|
665
|
+
return ee("razorpay", "Razorpay", ["INR", "USD", "EUR", "GBP", "AED"], t);
|
|
666
666
|
}
|
|
667
667
|
function Ut(t) {
|
|
668
|
-
return
|
|
668
|
+
return ee(
|
|
669
669
|
"payu",
|
|
670
670
|
"PayU",
|
|
671
671
|
["PLN", "EUR", "USD", "CZK", "HUF", "RON", "BGN", "TRY"],
|
|
@@ -673,20 +673,20 @@ function Ut(t) {
|
|
|
673
673
|
);
|
|
674
674
|
}
|
|
675
675
|
function At(t) {
|
|
676
|
-
return
|
|
676
|
+
return ee("przelewy24", "Przelewy24", ["PLN", "EUR"], t);
|
|
677
677
|
}
|
|
678
678
|
function Et(t = {}) {
|
|
679
|
-
return
|
|
679
|
+
return ee("tpay", "Tpay", ["PLN", "EUR", "USD", "GBP"], t);
|
|
680
680
|
}
|
|
681
681
|
function Tt(t = {}) {
|
|
682
|
-
return
|
|
682
|
+
return ee("autopay", "Autopay", ["PLN", "EUR", "USD", "GBP", "CZK"], t);
|
|
683
683
|
}
|
|
684
684
|
function Ft(t = {}) {
|
|
685
685
|
const { acquirer: e = "native", ...r } = t;
|
|
686
|
-
return
|
|
686
|
+
return ee(`blik:${e}`, `BLIK (${e})`, ["PLN"], r);
|
|
687
687
|
}
|
|
688
688
|
function Ot(t) {
|
|
689
|
-
return
|
|
689
|
+
return ee(
|
|
690
690
|
"klarna",
|
|
691
691
|
"Klarna",
|
|
692
692
|
["USD", "EUR", "GBP", "SEK", "NOK", "DKK", "CHF", "AUD", "CAD", "NZD", "PLN"],
|
|
@@ -694,7 +694,7 @@ function Ot(t) {
|
|
|
694
694
|
);
|
|
695
695
|
}
|
|
696
696
|
function qt(t) {
|
|
697
|
-
return
|
|
697
|
+
return ee(
|
|
698
698
|
"coinbase-commerce",
|
|
699
699
|
"Coinbase Commerce",
|
|
700
700
|
["BTC", "ETH", "USDC", "USDT", "USD", "EUR"],
|
|
@@ -960,86 +960,86 @@ function br(t, e) {
|
|
|
960
960
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
961
961
|
[]
|
|
962
962
|
), [n, a] = j(r), s = Y(
|
|
963
|
-
(
|
|
963
|
+
(h) => a((u) => ae(h, u.currency)),
|
|
964
964
|
[]
|
|
965
|
-
), d = Y((
|
|
966
|
-
a((u) => ({ ...u, currency:
|
|
967
|
-
}, []), i = Y((
|
|
968
|
-
(
|
|
965
|
+
), d = Y((h) => {
|
|
966
|
+
a((u) => ({ ...u, currency: h.toUpperCase() }));
|
|
967
|
+
}, []), i = Y((h) => a((u) => ye(u, h)), []), o = Y(
|
|
968
|
+
(h) => a((u) => ht(u, h)),
|
|
969
969
|
[]
|
|
970
970
|
), l = Y(
|
|
971
|
-
(
|
|
971
|
+
(h) => a((u) => Ae(u, h)),
|
|
972
972
|
[]
|
|
973
|
-
),
|
|
974
|
-
return { money: n, setMoney: a, setMajor: s, setCurrency: d, add: i, subtract: o, scale: l, formatted:
|
|
973
|
+
), p = B(() => ie(n, { locale: e }), [n, e]), N = B(() => Ge(n), [n]);
|
|
974
|
+
return { money: n, setMoney: a, setMajor: s, setCurrency: d, add: i, subtract: o, scale: l, formatted: p, major: N };
|
|
975
975
|
}
|
|
976
976
|
function Ee(t, e, r) {
|
|
977
|
-
const [n, a] = j(null), [s, d] = j(null), [i, o] = j(!1), l = Re(0),
|
|
977
|
+
const [n, a] = j(null), [s, d] = j(null), [i, o] = j(!1), l = Re(0), p = t == null ? void 0 : t.amount, N = t == null ? void 0 : t.currency;
|
|
978
978
|
return lt(() => {
|
|
979
|
-
if (
|
|
979
|
+
if (p === void 0 || N === void 0) {
|
|
980
980
|
a(null);
|
|
981
981
|
return;
|
|
982
982
|
}
|
|
983
|
-
const
|
|
984
|
-
o(!0), d(null), Ct({ amount:
|
|
985
|
-
l.current ===
|
|
983
|
+
const h = ++l.current;
|
|
984
|
+
o(!0), d(null), Ct({ amount: p, currency: N }, e, r).then((u) => {
|
|
985
|
+
l.current === h && a(u);
|
|
986
986
|
}).catch((u) => {
|
|
987
|
-
l.current ===
|
|
987
|
+
l.current === h && (d(u instanceof Error ? u : new Error(String(u))), a(null));
|
|
988
988
|
}).finally(() => {
|
|
989
|
-
l.current ===
|
|
989
|
+
l.current === h && o(!1);
|
|
990
990
|
});
|
|
991
|
-
}, [
|
|
991
|
+
}, [p, N, e, r]), { converted: n, loading: i, error: s };
|
|
992
992
|
}
|
|
993
993
|
function jt(t) {
|
|
994
994
|
const [e, r] = j("idle"), [n, a] = j(null), [s, d] = j(null), i = Y(() => {
|
|
995
995
|
r("idle"), a(null), d(null);
|
|
996
996
|
}, []), o = Y(
|
|
997
|
-
async (
|
|
997
|
+
async (h) => {
|
|
998
998
|
r("authorizing"), d(null);
|
|
999
999
|
try {
|
|
1000
|
-
const u = await t.authorize(
|
|
1000
|
+
const u = await t.authorize(h);
|
|
1001
1001
|
return a(u), r(u.status), u;
|
|
1002
1002
|
} catch (u) {
|
|
1003
|
-
const
|
|
1004
|
-
throw d(
|
|
1003
|
+
const g = u instanceof Error ? u : new Error(String(u));
|
|
1004
|
+
throw d(g), r("failed"), g;
|
|
1005
1005
|
}
|
|
1006
1006
|
},
|
|
1007
1007
|
[t]
|
|
1008
1008
|
), l = Y(
|
|
1009
|
-
async (
|
|
1010
|
-
const
|
|
1011
|
-
if (!
|
|
1009
|
+
async (h, u) => {
|
|
1010
|
+
const g = h ?? (n == null ? void 0 : n.id);
|
|
1011
|
+
if (!g)
|
|
1012
1012
|
throw new Error("No authorization id to capture");
|
|
1013
1013
|
r("capturing");
|
|
1014
1014
|
try {
|
|
1015
|
-
const
|
|
1016
|
-
return a(
|
|
1017
|
-
} catch (
|
|
1018
|
-
const
|
|
1019
|
-
throw d(
|
|
1015
|
+
const b = await t.capture(g, u);
|
|
1016
|
+
return a(b), r(b.status), b;
|
|
1017
|
+
} catch (b) {
|
|
1018
|
+
const _ = b instanceof Error ? b : new Error(String(b));
|
|
1019
|
+
throw d(_), r("failed"), _;
|
|
1020
1020
|
}
|
|
1021
1021
|
},
|
|
1022
1022
|
[t, n == null ? void 0 : n.id]
|
|
1023
|
-
),
|
|
1024
|
-
async (
|
|
1025
|
-
const u =
|
|
1023
|
+
), p = Y(
|
|
1024
|
+
async (h) => {
|
|
1025
|
+
const u = h ?? (n == null ? void 0 : n.id);
|
|
1026
1026
|
if (!u)
|
|
1027
1027
|
throw new Error("No payment id to cancel");
|
|
1028
|
-
const
|
|
1029
|
-
return a(
|
|
1028
|
+
const g = await t.cancel(u);
|
|
1029
|
+
return a(g), r(g.status), g;
|
|
1030
1030
|
},
|
|
1031
1031
|
[t, n == null ? void 0 : n.id]
|
|
1032
1032
|
), N = Y(
|
|
1033
|
-
async (
|
|
1034
|
-
const
|
|
1035
|
-
if (!
|
|
1033
|
+
async (h, u) => {
|
|
1034
|
+
const g = h ?? (n == null ? void 0 : n.id);
|
|
1035
|
+
if (!g)
|
|
1036
1036
|
throw new Error("No payment id to refund");
|
|
1037
|
-
const
|
|
1038
|
-
return a(
|
|
1037
|
+
const b = await t.refund(g, u);
|
|
1038
|
+
return a(b), r(b.status), b;
|
|
1039
1039
|
},
|
|
1040
1040
|
[t, n == null ? void 0 : n.id]
|
|
1041
1041
|
);
|
|
1042
|
-
return { status: e, response: n, error: s, authorize: o, capture: l, cancel:
|
|
1042
|
+
return { status: e, response: n, error: s, authorize: o, capture: l, cancel: p, refund: N, reset: i };
|
|
1043
1043
|
}
|
|
1044
1044
|
const ze = /* @__PURE__ */ se(
|
|
1045
1045
|
function({
|
|
@@ -1052,46 +1052,58 @@ const ze = /* @__PURE__ */ se(
|
|
|
1052
1052
|
zeroPlaceholder: i,
|
|
1053
1053
|
convertTo: o,
|
|
1054
1054
|
exchangeProvider: l,
|
|
1055
|
-
className:
|
|
1055
|
+
className: p,
|
|
1056
1056
|
style: N,
|
|
1057
|
-
"aria-label":
|
|
1058
|
-
|
|
1059
|
-
|
|
1057
|
+
"aria-label": h,
|
|
1058
|
+
testId: u,
|
|
1059
|
+
"data-testid": g
|
|
1060
|
+
}, b) {
|
|
1061
|
+
const { t: _ } = oe(), M = B(() => {
|
|
1060
1062
|
if (e)
|
|
1061
1063
|
return e;
|
|
1062
1064
|
if (r != null && n) {
|
|
1063
|
-
const
|
|
1065
|
+
const I = te(n), w = (I == null ? void 0 : I.decimals) ?? 2;
|
|
1064
1066
|
return {
|
|
1065
|
-
amount: Math.round(r * Math.pow(10,
|
|
1067
|
+
amount: Math.round(r * Math.pow(10, w)),
|
|
1066
1068
|
currency: n.toUpperCase()
|
|
1067
1069
|
};
|
|
1068
1070
|
}
|
|
1069
1071
|
return null;
|
|
1070
|
-
}, [e, r, n]),
|
|
1071
|
-
o && l ?
|
|
1072
|
+
}, [e, r, n]), D = B(() => M ? M.amount === 0 && i != null ? i : ie(M, { locale: a, currencyDisplay: s }) : "", [M, a, s, i]), { converted: v } = Ee(
|
|
1073
|
+
o && l ? M : null,
|
|
1072
1074
|
o ?? "",
|
|
1073
1075
|
l
|
|
1074
1076
|
);
|
|
1075
|
-
if (!
|
|
1077
|
+
if (!M)
|
|
1076
1078
|
return null;
|
|
1077
|
-
const
|
|
1078
|
-
return /* @__PURE__ */
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
),
|
|
1088
|
-
|
|
1089
|
-
"
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1079
|
+
const y = M.amount < 0, x = "nice-money" + (d && y ? " nice-money--negative" : "") + (p ? ` ${p}` : "");
|
|
1080
|
+
return /* @__PURE__ */ f(
|
|
1081
|
+
"span",
|
|
1082
|
+
{
|
|
1083
|
+
ref: b,
|
|
1084
|
+
className: x,
|
|
1085
|
+
style: N,
|
|
1086
|
+
"aria-label": h,
|
|
1087
|
+
"data-testid": g ?? u,
|
|
1088
|
+
children: [
|
|
1089
|
+
/* @__PURE__ */ c("span", { className: "nice-money__value", children: D }),
|
|
1090
|
+
v && /* @__PURE__ */ f(
|
|
1091
|
+
"span",
|
|
1092
|
+
{
|
|
1093
|
+
className: "nice-money__converted",
|
|
1094
|
+
"aria-label": _("money.convertedTo", "Converted to {currency}").replace(
|
|
1095
|
+
"{currency}",
|
|
1096
|
+
String(v.currency)
|
|
1097
|
+
),
|
|
1098
|
+
children: [
|
|
1099
|
+
" ≈ ",
|
|
1100
|
+
ie(v, { locale: a })
|
|
1101
|
+
]
|
|
1102
|
+
}
|
|
1103
|
+
)
|
|
1104
|
+
]
|
|
1105
|
+
}
|
|
1106
|
+
);
|
|
1095
1107
|
}
|
|
1096
1108
|
), _r = _e.map((t) => t.code).sort(), Qe = /* @__PURE__ */ se(function({
|
|
1097
1109
|
value: e,
|
|
@@ -1103,94 +1115,94 @@ const ze = /* @__PURE__ */ se(
|
|
|
1103
1115
|
showSymbol: i = !0,
|
|
1104
1116
|
compact: o = !1,
|
|
1105
1117
|
disabled: l,
|
|
1106
|
-
readOnly:
|
|
1118
|
+
readOnly: p,
|
|
1107
1119
|
loading: N,
|
|
1108
|
-
accessMode:
|
|
1120
|
+
accessMode: h,
|
|
1109
1121
|
label: u,
|
|
1110
|
-
helperText:
|
|
1111
|
-
error:
|
|
1112
|
-
required:
|
|
1113
|
-
size:
|
|
1114
|
-
labelPlacement:
|
|
1115
|
-
labelWidth:
|
|
1116
|
-
controlWidth:
|
|
1117
|
-
className:
|
|
1118
|
-
style:
|
|
1119
|
-
id:
|
|
1120
|
-
name:
|
|
1121
|
-
title:
|
|
1122
|
-
"data-testid":
|
|
1123
|
-
"aria-label":
|
|
1122
|
+
helperText: g,
|
|
1123
|
+
error: b,
|
|
1124
|
+
required: _,
|
|
1125
|
+
size: M = "md",
|
|
1126
|
+
labelPlacement: D = "top",
|
|
1127
|
+
labelWidth: v,
|
|
1128
|
+
controlWidth: y,
|
|
1129
|
+
className: x,
|
|
1130
|
+
style: I,
|
|
1131
|
+
id: w,
|
|
1132
|
+
name: S,
|
|
1133
|
+
title: F,
|
|
1134
|
+
"data-testid": R,
|
|
1135
|
+
"aria-label": X,
|
|
1124
1136
|
placeholder: A
|
|
1125
|
-
},
|
|
1126
|
-
const { t: T } = oe(), K =
|
|
1127
|
-
if (!
|
|
1137
|
+
}, $) {
|
|
1138
|
+
const { t: T } = oe(), K = h === "hidden", V = l || h === "disabled" || N, re = p || h === "readOnly", G = Ne(), Q = w ?? `nice-cs-${G}`, [W, ne] = j(""), O = s ?? n.length > 8, C = B(() => {
|
|
1139
|
+
if (!W.trim())
|
|
1128
1140
|
return n;
|
|
1129
|
-
const
|
|
1141
|
+
const U = W.trim().toLowerCase();
|
|
1130
1142
|
return n.filter(
|
|
1131
|
-
(
|
|
1143
|
+
(E) => E.code.toLowerCase().includes(U) || E.name.toLowerCase().includes(U) || E.symbol.toLowerCase().includes(U)
|
|
1132
1144
|
);
|
|
1133
|
-
}, [n,
|
|
1134
|
-
const
|
|
1135
|
-
return a.map((
|
|
1136
|
-
}, [a]),
|
|
1137
|
-
(
|
|
1138
|
-
const
|
|
1139
|
-
de && (r == null || r(
|
|
1145
|
+
}, [n, W]), m = B(() => {
|
|
1146
|
+
const U = /* @__PURE__ */ new Set();
|
|
1147
|
+
return a.map((E) => te(E)).filter((E) => !!E && !U.has(E.code) && !!U.add(E.code));
|
|
1148
|
+
}, [a]), q = Y(
|
|
1149
|
+
(U) => {
|
|
1150
|
+
const E = U.target.value, de = te(E);
|
|
1151
|
+
de && (r == null || r(E, de));
|
|
1140
1152
|
},
|
|
1141
1153
|
[r]
|
|
1142
|
-
), L = (
|
|
1154
|
+
), L = (U) => {
|
|
1143
1155
|
if (o)
|
|
1144
|
-
return `${i ?
|
|
1145
|
-
const
|
|
1146
|
-
return i &&
|
|
1147
|
-
},
|
|
1148
|
-
width: typeof
|
|
1156
|
+
return `${i ? U.symbol + " " : ""}${U.code}`;
|
|
1157
|
+
const E = [];
|
|
1158
|
+
return i && E.push(U.symbol), d && E.push(U.code), E.push("—", U.name), E.join(" ");
|
|
1159
|
+
}, P = `nice-currency-selector nice-currency-selector--${M} nice-currency-selector--label-${D}` + (o ? " nice-currency-selector--compact" : "") + (b ? " nice-currency-selector--error" : "") + (V ? " nice-currency-selector--disabled" : "") + (x ? ` ${x}` : ""), z = D === "left" && v != null ? { width: typeof v == "number" ? `${v}px` : v, flex: "none" } : void 0, le = y != null ? {
|
|
1160
|
+
width: typeof y == "number" ? `${y}px` : y,
|
|
1149
1161
|
flex: "none"
|
|
1150
1162
|
} : void 0;
|
|
1151
|
-
return K ? null : /* @__PURE__ */
|
|
1152
|
-
u && /* @__PURE__ */
|
|
1163
|
+
return K ? null : /* @__PURE__ */ f("div", { ref: $, className: P, style: I, title: F, "data-testid": R, children: [
|
|
1164
|
+
u && /* @__PURE__ */ f("label", { htmlFor: Q, className: "nice-currency-selector__label", style: z, children: [
|
|
1153
1165
|
u,
|
|
1154
|
-
|
|
1166
|
+
_ && /* @__PURE__ */ c("span", { className: "nice-currency-selector__required", "aria-hidden": !0, children: "*" })
|
|
1155
1167
|
] }),
|
|
1156
|
-
/* @__PURE__ */
|
|
1157
|
-
|
|
1168
|
+
/* @__PURE__ */ f("div", { className: "nice-currency-selector__inner", style: le, children: [
|
|
1169
|
+
O && /* @__PURE__ */ c(
|
|
1158
1170
|
"input",
|
|
1159
1171
|
{
|
|
1160
1172
|
type: "search",
|
|
1161
1173
|
className: "nice-currency-selector__search",
|
|
1162
1174
|
placeholder: T("currencySelector.searchCurrency", "Search currency…"),
|
|
1163
|
-
value:
|
|
1164
|
-
onChange: (
|
|
1165
|
-
disabled:
|
|
1175
|
+
value: W,
|
|
1176
|
+
onChange: (U) => ne(U.target.value),
|
|
1177
|
+
disabled: V || re,
|
|
1166
1178
|
"aria-label": T("currencySelector.searchCurrency2", "Search currency")
|
|
1167
1179
|
}
|
|
1168
1180
|
),
|
|
1169
|
-
/* @__PURE__ */
|
|
1181
|
+
/* @__PURE__ */ f(
|
|
1170
1182
|
"select",
|
|
1171
1183
|
{
|
|
1172
|
-
id:
|
|
1173
|
-
name:
|
|
1184
|
+
id: Q,
|
|
1185
|
+
name: S,
|
|
1174
1186
|
className: "nice-currency-selector__select",
|
|
1175
1187
|
value: e ?? "",
|
|
1176
|
-
onChange:
|
|
1177
|
-
disabled:
|
|
1178
|
-
required:
|
|
1179
|
-
"aria-invalid": !!
|
|
1180
|
-
"aria-label":
|
|
1188
|
+
onChange: q,
|
|
1189
|
+
disabled: V || re,
|
|
1190
|
+
required: _,
|
|
1191
|
+
"aria-invalid": !!b,
|
|
1192
|
+
"aria-label": X ?? (typeof u == "string" ? u : T("currencySelector.currency", "Currency")),
|
|
1181
1193
|
children: [
|
|
1182
1194
|
!e && /* @__PURE__ */ c("option", { value: "", children: A ?? T("currencySelector.selectCurrency", "Select currency…") }),
|
|
1183
|
-
|
|
1184
|
-
/* @__PURE__ */ c("optgroup", { label:
|
|
1195
|
+
m.length > 0 && /* @__PURE__ */ c("optgroup", { label: T("currencySelector.recent", "Recent"), children: m.map((U) => /* @__PURE__ */ c("option", { value: U.code, children: L(U) }, `r-${U.code}`)) }),
|
|
1196
|
+
/* @__PURE__ */ c("optgroup", { label: m.length > 0 ? T("currencySelector.all", "All") : "", children: C.map((U) => /* @__PURE__ */ c("option", { value: U.code, children: L(U) }, U.code)) })
|
|
1185
1197
|
]
|
|
1186
1198
|
}
|
|
1187
1199
|
)
|
|
1188
1200
|
] }),
|
|
1189
|
-
(
|
|
1201
|
+
(b || g) && /* @__PURE__ */ c(
|
|
1190
1202
|
"span",
|
|
1191
1203
|
{
|
|
1192
|
-
className:
|
|
1193
|
-
children:
|
|
1204
|
+
className: b ? "nice-currency-selector__error" : "nice-currency-selector__helper",
|
|
1205
|
+
children: b ?? g
|
|
1194
1206
|
}
|
|
1195
1207
|
)
|
|
1196
1208
|
] });
|
|
@@ -1205,38 +1217,38 @@ const ze = /* @__PURE__ */ se(
|
|
|
1205
1217
|
min: i,
|
|
1206
1218
|
max: o,
|
|
1207
1219
|
step: l,
|
|
1208
|
-
locale:
|
|
1220
|
+
locale: p,
|
|
1209
1221
|
placeholder: N,
|
|
1210
|
-
label:
|
|
1222
|
+
label: h,
|
|
1211
1223
|
helperText: u,
|
|
1212
|
-
error:
|
|
1213
|
-
size:
|
|
1214
|
-
disabled:
|
|
1215
|
-
readOnly:
|
|
1216
|
-
required:
|
|
1217
|
-
loading:
|
|
1218
|
-
accessMode:
|
|
1219
|
-
labelPlacement:
|
|
1220
|
-
errorPlacement:
|
|
1221
|
-
labelWidth:
|
|
1222
|
-
controlWidth:
|
|
1223
|
-
submitOnEnter:
|
|
1224
|
-
onSubmit:
|
|
1225
|
-
showFormattedPreview:
|
|
1224
|
+
error: g,
|
|
1225
|
+
size: b = "md",
|
|
1226
|
+
disabled: _,
|
|
1227
|
+
readOnly: M,
|
|
1228
|
+
required: D,
|
|
1229
|
+
loading: v,
|
|
1230
|
+
accessMode: y,
|
|
1231
|
+
labelPlacement: x = "top",
|
|
1232
|
+
errorPlacement: I = "bottom",
|
|
1233
|
+
labelWidth: w,
|
|
1234
|
+
controlWidth: S,
|
|
1235
|
+
submitOnEnter: F,
|
|
1236
|
+
onSubmit: R,
|
|
1237
|
+
showFormattedPreview: X = !0,
|
|
1226
1238
|
showSteppers: A = !1,
|
|
1227
|
-
className:
|
|
1239
|
+
className: $,
|
|
1228
1240
|
style: T,
|
|
1229
1241
|
id: K,
|
|
1230
|
-
name:
|
|
1242
|
+
name: V,
|
|
1231
1243
|
title: re,
|
|
1232
1244
|
"data-testid": G,
|
|
1233
|
-
onBlur:
|
|
1234
|
-
onFocus:
|
|
1245
|
+
onBlur: Q,
|
|
1246
|
+
onFocus: W,
|
|
1235
1247
|
liveGrouping: ne,
|
|
1236
|
-
multiplierShortcuts:
|
|
1248
|
+
multiplierShortcuts: O = !0,
|
|
1237
1249
|
onValidationError: C
|
|
1238
|
-
},
|
|
1239
|
-
const { t:
|
|
1250
|
+
}, m) {
|
|
1251
|
+
const { t: q } = oe(), L = _ || y === "disabled" || v, P = M || y === "readOnly", z = y === "hidden", le = Ne(), U = K ?? `nice-money-${le}`, E = ((e == null ? void 0 : e.currency) ?? n ?? "USD").toUpperCase(), de = te(E), J = (de == null ? void 0 : de.decimals) ?? 2, Se = l ?? 1 / Math.pow(10, J), [we, he] = j(
|
|
1240
1252
|
() => e ? (e.amount / Math.pow(10, J)).toFixed(J) : ""
|
|
1241
1253
|
), [ke, Fe] = j(!1);
|
|
1242
1254
|
ot.useEffect(() => {
|
|
@@ -1246,14 +1258,14 @@ const ze = /* @__PURE__ */ se(
|
|
|
1246
1258
|
he("");
|
|
1247
1259
|
return;
|
|
1248
1260
|
}
|
|
1249
|
-
const
|
|
1261
|
+
const k = te(e.currency), H = (k == null ? void 0 : k.decimals) ?? 2;
|
|
1250
1262
|
he((e.amount / Math.pow(10, H)).toFixed(H));
|
|
1251
1263
|
}, [e, ke]);
|
|
1252
1264
|
const Oe = Y(
|
|
1253
|
-
(
|
|
1254
|
-
let H =
|
|
1255
|
-
if (
|
|
1256
|
-
const ue =
|
|
1265
|
+
(k) => {
|
|
1266
|
+
let H = k;
|
|
1267
|
+
if (O) {
|
|
1268
|
+
const ue = k.trim().match(/^([+-]?\d+(?:[.,]\d+)?)\s*([kKmMbB])$/);
|
|
1257
1269
|
if (ue) {
|
|
1258
1270
|
const me = ue[2].toLowerCase() === "k" ? 1e3 : ue[2].toLowerCase() === "m" ? 1e6 : 1e9, Be = Number(ue[1].replace(",", ".")) * me;
|
|
1259
1271
|
if (!Number.isFinite(Be)) {
|
|
@@ -1263,7 +1275,7 @@ const ze = /* @__PURE__ */ se(
|
|
|
1263
1275
|
H = String(Be);
|
|
1264
1276
|
}
|
|
1265
1277
|
}
|
|
1266
|
-
const ce = ft(H,
|
|
1278
|
+
const ce = ft(H, E);
|
|
1267
1279
|
if (!ce) {
|
|
1268
1280
|
r == null || r(null);
|
|
1269
1281
|
return;
|
|
@@ -1274,102 +1286,102 @@ const ze = /* @__PURE__ */ se(
|
|
|
1274
1286
|
}
|
|
1275
1287
|
const pe = ce.amount / Math.pow(10, J);
|
|
1276
1288
|
if (i != null && pe < i) {
|
|
1277
|
-
C == null || C(new Error(`min: ${i}`)), r == null || r(ae(i,
|
|
1289
|
+
C == null || C(new Error(`min: ${i}`)), r == null || r(ae(i, E));
|
|
1278
1290
|
return;
|
|
1279
1291
|
}
|
|
1280
1292
|
if (o != null && pe > o) {
|
|
1281
|
-
C == null || C(new Error(`max: ${o}`)), r == null || r(ae(o,
|
|
1293
|
+
C == null || C(new Error(`max: ${o}`)), r == null || r(ae(o, E));
|
|
1282
1294
|
return;
|
|
1283
1295
|
}
|
|
1284
1296
|
r == null || r(ce);
|
|
1285
1297
|
},
|
|
1286
|
-
[
|
|
1298
|
+
[E, J, i, o, r, O, C]
|
|
1287
1299
|
), We = Y(
|
|
1288
|
-
(
|
|
1289
|
-
const H =
|
|
1300
|
+
(k) => {
|
|
1301
|
+
const H = k.target.value;
|
|
1290
1302
|
he(H), Oe(H);
|
|
1291
1303
|
},
|
|
1292
1304
|
[Oe]
|
|
1293
1305
|
), Ce = Y(
|
|
1294
|
-
(
|
|
1295
|
-
const H = Math.min(o ?? 1 / 0, Math.max(i ?? -1 / 0,
|
|
1296
|
-
he(H.toFixed(J)), r == null || r(ae(H,
|
|
1306
|
+
(k) => {
|
|
1307
|
+
const H = Math.min(o ?? 1 / 0, Math.max(i ?? -1 / 0, k));
|
|
1308
|
+
he(H.toFixed(J)), r == null || r(ae(H, E));
|
|
1297
1309
|
},
|
|
1298
|
-
[J, i, o,
|
|
1310
|
+
[J, i, o, E, r]
|
|
1299
1311
|
), $e = Y(
|
|
1300
|
-
(
|
|
1312
|
+
(k) => Ce((e ? e.amount / Math.pow(10, J) : 0) + k),
|
|
1301
1313
|
[e, J, Ce]
|
|
1302
|
-
), qe = Re(null), ge = Re(null), et = A && !L && !
|
|
1314
|
+
), qe = Re(null), ge = Re(null), et = A && !L && !P;
|
|
1303
1315
|
ut(qe, {
|
|
1304
1316
|
kind: A ? "value" : "text",
|
|
1305
|
-
disabled: L ||
|
|
1317
|
+
disabled: L || P,
|
|
1306
1318
|
restoreOnCancel: A,
|
|
1307
1319
|
onEngage: () => {
|
|
1308
1320
|
ge.current = { value: e ?? null, draft: we };
|
|
1309
1321
|
},
|
|
1310
|
-
onRelease: (
|
|
1311
|
-
|
|
1322
|
+
onRelease: (k) => {
|
|
1323
|
+
k && A && ge.current && (he(ge.current.draft), r == null || r(ge.current.value)), ge.current = null;
|
|
1312
1324
|
}
|
|
1313
1325
|
});
|
|
1314
1326
|
const De = B(() => {
|
|
1315
|
-
var
|
|
1327
|
+
var k, H;
|
|
1316
1328
|
try {
|
|
1317
|
-
const ce = new Intl.NumberFormat(
|
|
1329
|
+
const ce = new Intl.NumberFormat(p).formatToParts(12345.6), pe = ((k = ce.find((me) => me.type === "group")) == null ? void 0 : k.value) ?? ",", ue = ((H = ce.find((me) => me.type === "decimal")) == null ? void 0 : H.value) ?? ".";
|
|
1318
1330
|
return { group: pe, decimal: ue };
|
|
1319
1331
|
} catch {
|
|
1320
1332
|
return { group: ",", decimal: "." };
|
|
1321
1333
|
}
|
|
1322
|
-
}, [
|
|
1334
|
+
}, [p]), Ke = ne ?? !!De.group, tt = B(() => {
|
|
1323
1335
|
if (!Ke || ke === !1)
|
|
1324
1336
|
return we;
|
|
1325
|
-
const
|
|
1337
|
+
const k = De.decimal, H = De.group, ce = we.replace(
|
|
1326
1338
|
new RegExp(`[${H.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}]`, "g"),
|
|
1327
1339
|
""
|
|
1328
|
-
), [pe, ue] = ce.split(
|
|
1340
|
+
), [pe, ue] = ce.split(k);
|
|
1329
1341
|
if (!pe)
|
|
1330
1342
|
return ce;
|
|
1331
1343
|
const me = pe.replace(/\B(?=(\d{3})+(?!\d))/g, H);
|
|
1332
|
-
return ue != null ? `${me}${
|
|
1333
|
-
}, [we, ke, Ke, De]), xe = B(() => e ? ie(e, { locale:
|
|
1334
|
-
if (
|
|
1335
|
-
|
|
1344
|
+
return ue != null ? `${me}${k}${ue}` : me;
|
|
1345
|
+
}, [we, ke, Ke, De]), xe = B(() => e ? ie(e, { locale: p }) : "", [e, p]), fe = typeof g == "string" ? g : void 0, rt = `nice-money-input nice-money-input--${b} nice-money-input--label-${x} nice-money-input--error-${I}` + (fe ? " nice-money-input--error" : "") + (L ? " nice-money-input--disabled" : "") + (v ? " nice-money-input--loading" : "") + ($ ? ` ${$}` : ""), nt = (k) => {
|
|
1346
|
+
if (F && k.key === "Enter" && R) {
|
|
1347
|
+
k.preventDefault(), R();
|
|
1336
1348
|
return;
|
|
1337
1349
|
}
|
|
1338
1350
|
if (!et)
|
|
1339
1351
|
return;
|
|
1340
|
-
const H =
|
|
1341
|
-
H ? (
|
|
1342
|
-
}, at =
|
|
1343
|
-
width: typeof
|
|
1352
|
+
const H = k.key === "ArrowUp" ? 1 : k.key === "ArrowDown" ? -1 : k.key === "PageUp" ? 10 : k.key === "PageDown" ? -10 : 0;
|
|
1353
|
+
H ? (k.preventDefault(), $e(H * Se)) : k.key === "Home" && i != null ? (k.preventDefault(), Ce(i)) : k.key === "End" && o != null && (k.preventDefault(), Ce(o));
|
|
1354
|
+
}, at = x === "left" && w != null ? { width: typeof w == "number" ? `${w}px` : w, flex: "none" } : void 0, ct = S != null ? {
|
|
1355
|
+
width: typeof S == "number" ? `${S}px` : S,
|
|
1344
1356
|
flex: "none"
|
|
1345
1357
|
} : void 0;
|
|
1346
|
-
return z ? null : /* @__PURE__ */
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1358
|
+
return z ? null : /* @__PURE__ */ f("div", { ref: m, className: rt, style: T, title: re, "data-testid": G, children: [
|
|
1359
|
+
h && /* @__PURE__ */ f("label", { htmlFor: U, className: "nice-money-input__label", style: at, children: [
|
|
1360
|
+
h,
|
|
1361
|
+
D && /* @__PURE__ */ c("span", { className: "nice-money-input__required", "aria-hidden": !0, children: "*" })
|
|
1350
1362
|
] }),
|
|
1351
|
-
/* @__PURE__ */
|
|
1363
|
+
/* @__PURE__ */ f("div", { className: "nice-money-input__row", style: ct, children: [
|
|
1352
1364
|
!d && /* @__PURE__ */ c(
|
|
1353
1365
|
Qe,
|
|
1354
1366
|
{
|
|
1355
|
-
value:
|
|
1367
|
+
value: E,
|
|
1356
1368
|
compact: !0,
|
|
1357
|
-
options: s ? s.map(te).filter((
|
|
1358
|
-
onChange: (
|
|
1359
|
-
disabled: L ||
|
|
1369
|
+
options: s ? s.map(te).filter((k) => !!k) : void 0,
|
|
1370
|
+
onChange: (k) => a == null ? void 0 : a(k),
|
|
1371
|
+
disabled: L || P,
|
|
1360
1372
|
className: "nice-money-input__currency",
|
|
1361
|
-
"aria-label":
|
|
1373
|
+
"aria-label": q("moneyInput.currency", "Currency")
|
|
1362
1374
|
}
|
|
1363
1375
|
),
|
|
1364
|
-
d && /* @__PURE__ */ c("span", { className: "nice-money-input__symbol", "aria-hidden": !0, children: (de == null ? void 0 : de.symbol) ??
|
|
1376
|
+
d && /* @__PURE__ */ c("span", { className: "nice-money-input__symbol", "aria-hidden": !0, children: (de == null ? void 0 : de.symbol) ?? E }),
|
|
1365
1377
|
A && /* @__PURE__ */ c(
|
|
1366
1378
|
"button",
|
|
1367
1379
|
{
|
|
1368
1380
|
type: "button",
|
|
1369
1381
|
className: "nice-money-input__step nice-money-input__step--down",
|
|
1370
1382
|
onClick: () => $e(-Se),
|
|
1371
|
-
disabled: L ||
|
|
1372
|
-
"aria-label":
|
|
1383
|
+
disabled: L || P || i != null && e != null && e.amount / Math.pow(10, J) <= i,
|
|
1384
|
+
"aria-label": q("moneyInput.decreaseAmount", "Decrease amount"),
|
|
1373
1385
|
tabIndex: -1,
|
|
1374
1386
|
children: /* @__PURE__ */ c(ve, { name: "minus", size: 14 })
|
|
1375
1387
|
}
|
|
@@ -1378,8 +1390,8 @@ const ze = /* @__PURE__ */ se(
|
|
|
1378
1390
|
"input",
|
|
1379
1391
|
{
|
|
1380
1392
|
ref: qe,
|
|
1381
|
-
id:
|
|
1382
|
-
name:
|
|
1393
|
+
id: U,
|
|
1394
|
+
name: V,
|
|
1383
1395
|
type: "text",
|
|
1384
1396
|
inputMode: "decimal",
|
|
1385
1397
|
autoComplete: "transaction-amount",
|
|
@@ -1387,18 +1399,18 @@ const ze = /* @__PURE__ */ se(
|
|
|
1387
1399
|
value: tt,
|
|
1388
1400
|
onChange: We,
|
|
1389
1401
|
onKeyDown: nt,
|
|
1390
|
-
onFocus: (
|
|
1391
|
-
Fe(!0),
|
|
1402
|
+
onFocus: (k) => {
|
|
1403
|
+
Fe(!0), W == null || W(k);
|
|
1392
1404
|
},
|
|
1393
|
-
onBlur: (
|
|
1394
|
-
Fe(!1), e && he((e.amount / Math.pow(10, J)).toFixed(J)),
|
|
1405
|
+
onBlur: (k) => {
|
|
1406
|
+
Fe(!1), e && he((e.amount / Math.pow(10, J)).toFixed(J)), Q == null || Q(k);
|
|
1395
1407
|
},
|
|
1396
1408
|
placeholder: N ?? `0${J > 0 ? "." + "0".repeat(J) : ""}`,
|
|
1397
1409
|
disabled: L,
|
|
1398
|
-
readOnly:
|
|
1399
|
-
required:
|
|
1410
|
+
readOnly: P,
|
|
1411
|
+
required: D,
|
|
1400
1412
|
"aria-invalid": !!fe,
|
|
1401
|
-
"aria-describedby": fe || u ? `${
|
|
1413
|
+
"aria-describedby": fe || u ? `${U}-help` : void 0,
|
|
1402
1414
|
...A && {
|
|
1403
1415
|
role: "spinbutton",
|
|
1404
1416
|
"aria-valuenow": e ? e.amount / Math.pow(10, J) : void 0,
|
|
@@ -1414,19 +1426,19 @@ const ze = /* @__PURE__ */ se(
|
|
|
1414
1426
|
type: "button",
|
|
1415
1427
|
className: "nice-money-input__step nice-money-input__step--up",
|
|
1416
1428
|
onClick: () => $e(Se),
|
|
1417
|
-
disabled: L ||
|
|
1418
|
-
"aria-label":
|
|
1429
|
+
disabled: L || P || o != null && e != null && e.amount / Math.pow(10, J) >= o,
|
|
1430
|
+
"aria-label": q("moneyInput.increaseAmount", "Increase amount"),
|
|
1419
1431
|
tabIndex: -1,
|
|
1420
1432
|
children: /* @__PURE__ */ c(ve, { name: "plus", size: 14 })
|
|
1421
1433
|
}
|
|
1422
1434
|
),
|
|
1423
|
-
|
|
1435
|
+
v && /* @__PURE__ */ c("span", { className: "nice-money-input__spinner", "aria-hidden": !0, children: /* @__PURE__ */ c(ve, { name: "refresh", size: 14 }) })
|
|
1424
1436
|
] }),
|
|
1425
|
-
|
|
1437
|
+
X && xe && /* @__PURE__ */ c("span", { className: "nice-money-input__preview", "aria-live": "polite", children: xe }),
|
|
1426
1438
|
(fe || u) && /* @__PURE__ */ c(
|
|
1427
1439
|
"span",
|
|
1428
1440
|
{
|
|
1429
|
-
id: `${
|
|
1441
|
+
id: `${U}-help`,
|
|
1430
1442
|
className: fe ? "nice-money-input__error" : "nice-money-input__helper",
|
|
1431
1443
|
children: fe ?? u
|
|
1432
1444
|
}
|
|
@@ -1443,62 +1455,62 @@ const ze = /* @__PURE__ */ se(
|
|
|
1443
1455
|
showBrandIcon: i = !0,
|
|
1444
1456
|
size: o = "md",
|
|
1445
1457
|
disabled: l,
|
|
1446
|
-
readOnly:
|
|
1458
|
+
readOnly: p,
|
|
1447
1459
|
loading: N,
|
|
1448
|
-
accessMode:
|
|
1460
|
+
accessMode: h,
|
|
1449
1461
|
label: u,
|
|
1450
|
-
helperText:
|
|
1451
|
-
error:
|
|
1452
|
-
required:
|
|
1453
|
-
className:
|
|
1454
|
-
style:
|
|
1455
|
-
id:
|
|
1456
|
-
title:
|
|
1457
|
-
"data-testid":
|
|
1458
|
-
},
|
|
1459
|
-
const { t:
|
|
1462
|
+
helperText: g,
|
|
1463
|
+
error: b,
|
|
1464
|
+
required: _,
|
|
1465
|
+
className: M,
|
|
1466
|
+
style: D,
|
|
1467
|
+
id: v,
|
|
1468
|
+
title: y,
|
|
1469
|
+
"data-testid": x
|
|
1470
|
+
}, I) {
|
|
1471
|
+
const { t: w } = oe(), S = h === "hidden", F = l || h === "disabled" || N, R = p || h === "readOnly", X = Ne(), A = v ?? `nice-cc-${X}`, [$, T] = j({
|
|
1460
1472
|
number: !1,
|
|
1461
1473
|
expiry: !1,
|
|
1462
1474
|
cvc: !1,
|
|
1463
1475
|
holder: !1,
|
|
1464
1476
|
postal: !1
|
|
1465
|
-
}), K = B(() => Me(e.number), [e.number]),
|
|
1477
|
+
}), K = B(() => Me(e.number), [e.number]), V = B(
|
|
1466
1478
|
() => Le(e, { requireHolder: a ?? n }),
|
|
1467
1479
|
[e, a, n]
|
|
1468
1480
|
), re = !d || d.includes(K) || K === "unknown", G = Y(
|
|
1469
|
-
(
|
|
1470
|
-
const z = { ...e, ...
|
|
1481
|
+
(P) => {
|
|
1482
|
+
const z = { ...e, ...P }, le = Le(z, { requireHolder: a ?? n });
|
|
1471
1483
|
r == null || r(z, le);
|
|
1472
1484
|
},
|
|
1473
1485
|
[e, a, n, r]
|
|
1474
|
-
),
|
|
1475
|
-
(
|
|
1476
|
-
const z =
|
|
1486
|
+
), Q = Y(
|
|
1487
|
+
(P) => {
|
|
1488
|
+
const z = P.target.value.replace(/\D/g, "").slice(0, 19);
|
|
1477
1489
|
G({ number: z });
|
|
1478
1490
|
},
|
|
1479
1491
|
[G]
|
|
1480
|
-
),
|
|
1481
|
-
(
|
|
1482
|
-
const z =
|
|
1492
|
+
), W = Y(
|
|
1493
|
+
(P) => {
|
|
1494
|
+
const z = P.target.value.replace(/\D/g, "").slice(0, 4);
|
|
1483
1495
|
let le = z;
|
|
1484
1496
|
z.length >= 3 ? le = `${z.slice(0, 2)}/${z.slice(2)}` : z.length === 2 && (le = `${z}/`), G({ expiry: le });
|
|
1485
1497
|
},
|
|
1486
1498
|
[G]
|
|
1487
1499
|
), ne = Y(
|
|
1488
|
-
(
|
|
1489
|
-
const z =
|
|
1500
|
+
(P) => {
|
|
1501
|
+
const z = P.target.value.replace(/\D/g, "").slice(0, be(K));
|
|
1490
1502
|
G({ cvc: z });
|
|
1491
1503
|
},
|
|
1492
1504
|
[K, G]
|
|
1493
|
-
),
|
|
1494
|
-
return
|
|
1495
|
-
u && /* @__PURE__ */
|
|
1505
|
+
), O = B(() => bt(e.number, K), [e.number, K]), C = $.number && e.number.length > 0 && (Ze(e.number) ? re ? void 0 : "Card brand not accepted" : V.errors.number), m = $.expiry && e.expiry.length > 0 && !Xe(e.expiry) ? V.errors.expiry : void 0, q = $.cvc && e.cvc.length > 0 && e.cvc.length !== be(K) ? V.errors.cvc : void 0, L = `nice-credit-card nice-credit-card--${o}` + (F ? " nice-credit-card--disabled" : "") + (N ? " nice-credit-card--loading" : "") + (b ? " nice-credit-card--error" : "") + (M ? ` ${M}` : "");
|
|
1506
|
+
return S ? null : /* @__PURE__ */ f("div", { ref: I, className: L, style: D, title: y, "data-testid": x, children: [
|
|
1507
|
+
u && /* @__PURE__ */ f("div", { className: "nice-credit-card__title", children: [
|
|
1496
1508
|
u,
|
|
1497
|
-
|
|
1509
|
+
_ && /* @__PURE__ */ c("span", { className: "nice-credit-card__required", "aria-hidden": !0, children: "*" })
|
|
1498
1510
|
] }),
|
|
1499
|
-
/* @__PURE__ */ c("div", { className: "nice-credit-card__row", children: /* @__PURE__ */
|
|
1500
|
-
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children:
|
|
1501
|
-
/* @__PURE__ */
|
|
1511
|
+
/* @__PURE__ */ c("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ f("label", { className: "nice-credit-card__field nice-credit-card__field--number", children: [
|
|
1512
|
+
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: w("creditCardInput.cardNumber", "Card number") }),
|
|
1513
|
+
/* @__PURE__ */ f("span", { className: "nice-credit-card__input-wrapper", children: [
|
|
1502
1514
|
/* @__PURE__ */ c(
|
|
1503
1515
|
"input",
|
|
1504
1516
|
{
|
|
@@ -1507,11 +1519,11 @@ const ze = /* @__PURE__ */ se(
|
|
|
1507
1519
|
inputMode: "numeric",
|
|
1508
1520
|
autoComplete: "cc-number",
|
|
1509
1521
|
placeholder: K === "amex" ? "3782 822463 10005" : "1234 1234 1234 1234",
|
|
1510
|
-
value:
|
|
1511
|
-
onChange:
|
|
1512
|
-
onBlur: () => T((
|
|
1513
|
-
disabled:
|
|
1514
|
-
readOnly:
|
|
1522
|
+
value: O,
|
|
1523
|
+
onChange: Q,
|
|
1524
|
+
onBlur: () => T((P) => ({ ...P, number: !0 })),
|
|
1525
|
+
disabled: F,
|
|
1526
|
+
readOnly: R,
|
|
1515
1527
|
"aria-invalid": !!C,
|
|
1516
1528
|
"aria-describedby": C ? `${A}-number-err` : void 0,
|
|
1517
1529
|
className: "nice-credit-card__input",
|
|
@@ -1522,9 +1534,9 @@ const ze = /* @__PURE__ */ se(
|
|
|
1522
1534
|
] }),
|
|
1523
1535
|
C && /* @__PURE__ */ c("span", { id: `${A}-number-err`, className: "nice-credit-card__error", children: C })
|
|
1524
1536
|
] }) }),
|
|
1525
|
-
/* @__PURE__ */
|
|
1526
|
-
/* @__PURE__ */
|
|
1527
|
-
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children:
|
|
1537
|
+
/* @__PURE__ */ f("div", { className: "nice-credit-card__row nice-credit-card__row--split", children: [
|
|
1538
|
+
/* @__PURE__ */ f("label", { className: "nice-credit-card__field", children: [
|
|
1539
|
+
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: w("creditCardInput.expiry", "Expiry") }),
|
|
1528
1540
|
/* @__PURE__ */ c(
|
|
1529
1541
|
"input",
|
|
1530
1542
|
{
|
|
@@ -1532,26 +1544,26 @@ const ze = /* @__PURE__ */ se(
|
|
|
1532
1544
|
type: "text",
|
|
1533
1545
|
inputMode: "numeric",
|
|
1534
1546
|
autoComplete: "cc-exp",
|
|
1535
|
-
placeholder:
|
|
1547
|
+
placeholder: w("creditCardInput.mmYy", "MM/YY"),
|
|
1536
1548
|
value: e.expiry,
|
|
1537
|
-
onChange:
|
|
1549
|
+
onChange: W,
|
|
1538
1550
|
onBlur: () => {
|
|
1539
1551
|
T((z) => ({ ...z, expiry: !0 }));
|
|
1540
|
-
const
|
|
1541
|
-
|
|
1552
|
+
const P = Je(e.expiry);
|
|
1553
|
+
P && P !== e.expiry && G({ expiry: P });
|
|
1542
1554
|
},
|
|
1543
|
-
disabled:
|
|
1544
|
-
readOnly:
|
|
1545
|
-
"aria-invalid": !!
|
|
1546
|
-
"aria-describedby":
|
|
1555
|
+
disabled: F,
|
|
1556
|
+
readOnly: R,
|
|
1557
|
+
"aria-invalid": !!m,
|
|
1558
|
+
"aria-describedby": m ? `${A}-expiry-err` : void 0,
|
|
1547
1559
|
className: "nice-credit-card__input",
|
|
1548
1560
|
maxLength: 5
|
|
1549
1561
|
}
|
|
1550
1562
|
),
|
|
1551
|
-
|
|
1563
|
+
m && /* @__PURE__ */ c("span", { id: `${A}-expiry-err`, className: "nice-credit-card__error", children: m })
|
|
1552
1564
|
] }),
|
|
1553
|
-
/* @__PURE__ */
|
|
1554
|
-
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: K === "amex" ?
|
|
1565
|
+
/* @__PURE__ */ f("label", { className: "nice-credit-card__field", children: [
|
|
1566
|
+
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: K === "amex" ? w("creditCardInput.cid", "CID") : w("creditCardInput.cvc", "CVC") }),
|
|
1555
1567
|
/* @__PURE__ */ c(
|
|
1556
1568
|
"input",
|
|
1557
1569
|
{
|
|
@@ -1562,39 +1574,39 @@ const ze = /* @__PURE__ */ se(
|
|
|
1562
1574
|
placeholder: "•".repeat(be(K)),
|
|
1563
1575
|
value: e.cvc,
|
|
1564
1576
|
onChange: ne,
|
|
1565
|
-
onBlur: () => T((
|
|
1566
|
-
disabled:
|
|
1567
|
-
readOnly:
|
|
1568
|
-
"aria-invalid": !!
|
|
1569
|
-
"aria-describedby":
|
|
1577
|
+
onBlur: () => T((P) => ({ ...P, cvc: !0 })),
|
|
1578
|
+
disabled: F,
|
|
1579
|
+
readOnly: R,
|
|
1580
|
+
"aria-invalid": !!q,
|
|
1581
|
+
"aria-describedby": q ? `${A}-cvc-err` : void 0,
|
|
1570
1582
|
className: "nice-credit-card__input",
|
|
1571
1583
|
maxLength: be(K)
|
|
1572
1584
|
}
|
|
1573
1585
|
),
|
|
1574
|
-
|
|
1586
|
+
q && /* @__PURE__ */ c("span", { id: `${A}-cvc-err`, className: "nice-credit-card__error", children: q })
|
|
1575
1587
|
] })
|
|
1576
1588
|
] }),
|
|
1577
|
-
n && /* @__PURE__ */ c("div", { className: "nice-credit-card__row", children: /* @__PURE__ */
|
|
1578
|
-
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children:
|
|
1589
|
+
n && /* @__PURE__ */ c("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ f("label", { className: "nice-credit-card__field", children: [
|
|
1590
|
+
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: w("creditCardInput.cardholderName", "Cardholder name") }),
|
|
1579
1591
|
/* @__PURE__ */ c(
|
|
1580
1592
|
"input",
|
|
1581
1593
|
{
|
|
1582
1594
|
id: `${A}-holder`,
|
|
1583
1595
|
type: "text",
|
|
1584
1596
|
autoComplete: "cc-name",
|
|
1585
|
-
placeholder:
|
|
1597
|
+
placeholder: w("creditCardInput.janeDoe", "Jane Doe"),
|
|
1586
1598
|
value: e.holderName ?? "",
|
|
1587
|
-
onChange: (
|
|
1588
|
-
onBlur: () => T((
|
|
1589
|
-
disabled:
|
|
1590
|
-
readOnly:
|
|
1599
|
+
onChange: (P) => G({ holderName: P.target.value }),
|
|
1600
|
+
onBlur: () => T((P) => ({ ...P, holder: !0 })),
|
|
1601
|
+
disabled: F,
|
|
1602
|
+
readOnly: R,
|
|
1591
1603
|
className: "nice-credit-card__input",
|
|
1592
1604
|
maxLength: 120
|
|
1593
1605
|
}
|
|
1594
1606
|
)
|
|
1595
1607
|
] }) }),
|
|
1596
|
-
s && /* @__PURE__ */ c("div", { className: "nice-credit-card__row", children: /* @__PURE__ */
|
|
1597
|
-
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children:
|
|
1608
|
+
s && /* @__PURE__ */ c("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ f("label", { className: "nice-credit-card__field", children: [
|
|
1609
|
+
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: w("creditCardInput.postalCode", "Postal code") }),
|
|
1598
1610
|
/* @__PURE__ */ c(
|
|
1599
1611
|
"input",
|
|
1600
1612
|
{
|
|
@@ -1602,21 +1614,21 @@ const ze = /* @__PURE__ */ se(
|
|
|
1602
1614
|
type: "text",
|
|
1603
1615
|
autoComplete: "postal-code",
|
|
1604
1616
|
value: e.postalCode ?? "",
|
|
1605
|
-
onChange: (
|
|
1606
|
-
onBlur: () => T((
|
|
1607
|
-
disabled:
|
|
1608
|
-
readOnly:
|
|
1617
|
+
onChange: (P) => G({ postalCode: P.target.value }),
|
|
1618
|
+
onBlur: () => T((P) => ({ ...P, postal: !0 })),
|
|
1619
|
+
disabled: F,
|
|
1620
|
+
readOnly: R,
|
|
1609
1621
|
className: "nice-credit-card__input",
|
|
1610
1622
|
maxLength: 16
|
|
1611
1623
|
}
|
|
1612
1624
|
)
|
|
1613
1625
|
] }) }),
|
|
1614
|
-
(
|
|
1626
|
+
(b || g) && /* @__PURE__ */ c(
|
|
1615
1627
|
"div",
|
|
1616
1628
|
{
|
|
1617
|
-
className:
|
|
1618
|
-
role:
|
|
1619
|
-
children:
|
|
1629
|
+
className: b ? "nice-credit-card__form-error" : "nice-credit-card__helper",
|
|
1630
|
+
role: b ? "alert" : void 0,
|
|
1631
|
+
children: b ?? g
|
|
1620
1632
|
}
|
|
1621
1633
|
)
|
|
1622
1634
|
] });
|
|
@@ -1655,101 +1667,101 @@ const gr = /* @__PURE__ */ se(
|
|
|
1655
1667
|
metadata: i,
|
|
1656
1668
|
autoCapture: o = !0,
|
|
1657
1669
|
submitLabel: l,
|
|
1658
|
-
onSuccess:
|
|
1670
|
+
onSuccess: p,
|
|
1659
1671
|
onError: N,
|
|
1660
|
-
consents:
|
|
1672
|
+
consents: h,
|
|
1661
1673
|
className: u,
|
|
1662
|
-
style:
|
|
1663
|
-
},
|
|
1664
|
-
const { t:
|
|
1674
|
+
style: g
|
|
1675
|
+
}, b) {
|
|
1676
|
+
const { t: _ } = oe(), M = l ?? _("paymentForm.pay", "Pay"), [D, v] = j(r), [y, x] = j(r.currency), [I, w] = j({ number: "", expiry: "", cvc: "" }), [S, F] = j(null), [R, X] = j(!1), [A, $] = j(null), T = jt(e), K = B(() => e.supportedCurrencies === "*" ? !0 : e.supportedCurrencies.includes(D.currency.toUpperCase()), [e, D.currency]), V = B(() => {
|
|
1665
1677
|
var C;
|
|
1666
|
-
const
|
|
1667
|
-
return
|
|
1668
|
-
}, [e,
|
|
1678
|
+
const O = (C = e.minimums) == null ? void 0 : C[D.currency.toUpperCase()];
|
|
1679
|
+
return O == null || D.amount >= O;
|
|
1680
|
+
}, [e, D]), re = B(() => {
|
|
1669
1681
|
var C;
|
|
1670
|
-
const
|
|
1671
|
-
return
|
|
1672
|
-
}, [e,
|
|
1673
|
-
async (
|
|
1674
|
-
if (
|
|
1675
|
-
|
|
1682
|
+
const O = (C = e.minimums) == null ? void 0 : C[D.currency.toUpperCase()];
|
|
1683
|
+
return O == null ? null : { amount: O, currency: D.currency };
|
|
1684
|
+
}, [e, D.currency]), G = !!(S != null && S.isValid), Q = !R && K && V && G, W = Y(
|
|
1685
|
+
async (O) => {
|
|
1686
|
+
if (O.preventDefault(), !!Q) {
|
|
1687
|
+
$(null), X(!0);
|
|
1676
1688
|
try {
|
|
1677
1689
|
const C = {
|
|
1678
|
-
amount:
|
|
1679
|
-
card:
|
|
1690
|
+
amount: D,
|
|
1691
|
+
card: I,
|
|
1680
1692
|
customer: a,
|
|
1681
1693
|
description: d,
|
|
1682
1694
|
metadata: i,
|
|
1683
1695
|
idempotencyKey: Jt()
|
|
1684
|
-
},
|
|
1685
|
-
if (o &&
|
|
1686
|
-
const
|
|
1687
|
-
|
|
1696
|
+
}, m = await T.authorize(C);
|
|
1697
|
+
if (o && m.status === "authorized") {
|
|
1698
|
+
const q = await T.capture(m.id, D);
|
|
1699
|
+
p == null || p(q);
|
|
1688
1700
|
} else
|
|
1689
|
-
|
|
1701
|
+
p == null || p(m);
|
|
1690
1702
|
} catch (C) {
|
|
1691
|
-
const
|
|
1692
|
-
|
|
1703
|
+
const m = C instanceof Error ? C : new Error(String(C));
|
|
1704
|
+
$(m.message), N == null || N(m);
|
|
1693
1705
|
} finally {
|
|
1694
|
-
|
|
1706
|
+
X(!1);
|
|
1695
1707
|
}
|
|
1696
1708
|
}
|
|
1697
1709
|
},
|
|
1698
1710
|
[
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1711
|
+
Q,
|
|
1712
|
+
D,
|
|
1713
|
+
I,
|
|
1702
1714
|
a,
|
|
1703
1715
|
d,
|
|
1704
1716
|
i,
|
|
1705
1717
|
o,
|
|
1706
1718
|
T,
|
|
1707
|
-
|
|
1719
|
+
p,
|
|
1708
1720
|
N
|
|
1709
1721
|
]
|
|
1710
|
-
), ne = te(
|
|
1711
|
-
return /* @__PURE__ */
|
|
1722
|
+
), ne = te(D.currency);
|
|
1723
|
+
return /* @__PURE__ */ f(
|
|
1712
1724
|
"form",
|
|
1713
1725
|
{
|
|
1714
|
-
ref:
|
|
1726
|
+
ref: b,
|
|
1715
1727
|
className: "nice-payment-form" + (u ? ` ${u}` : ""),
|
|
1716
|
-
style:
|
|
1717
|
-
onSubmit:
|
|
1718
|
-
"aria-busy":
|
|
1728
|
+
style: g,
|
|
1729
|
+
onSubmit: W,
|
|
1730
|
+
"aria-busy": R,
|
|
1719
1731
|
children: [
|
|
1720
1732
|
/* @__PURE__ */ c("div", { className: "nice-payment-form__amount", children: n ? /* @__PURE__ */ c(
|
|
1721
1733
|
Ve,
|
|
1722
1734
|
{
|
|
1723
|
-
label:
|
|
1724
|
-
value:
|
|
1725
|
-
currency:
|
|
1735
|
+
label: _("paymentForm.amount", "Amount"),
|
|
1736
|
+
value: D,
|
|
1737
|
+
currency: y,
|
|
1726
1738
|
currencies: s,
|
|
1727
|
-
onChange: (
|
|
1728
|
-
onCurrencyChange: (
|
|
1729
|
-
|
|
1739
|
+
onChange: (O) => O && v(O),
|
|
1740
|
+
onCurrencyChange: (O) => {
|
|
1741
|
+
x(O), v((C) => ({ ...C, currency: O }));
|
|
1730
1742
|
},
|
|
1731
|
-
disabled:
|
|
1743
|
+
disabled: R,
|
|
1732
1744
|
required: !0,
|
|
1733
1745
|
showFormattedPreview: !0
|
|
1734
1746
|
}
|
|
1735
|
-
) : /* @__PURE__ */
|
|
1736
|
-
/* @__PURE__ */ c("span", { className: "nice-payment-form__total-label", children:
|
|
1737
|
-
/* @__PURE__ */ c(ze, { value:
|
|
1747
|
+
) : /* @__PURE__ */ f("div", { className: "nice-payment-form__total", children: [
|
|
1748
|
+
/* @__PURE__ */ c("span", { className: "nice-payment-form__total-label", children: _("paymentForm.total", "Total") }),
|
|
1749
|
+
/* @__PURE__ */ c(ze, { value: D })
|
|
1738
1750
|
] }) }),
|
|
1739
1751
|
d && /* @__PURE__ */ c("p", { className: "nice-payment-form__description", children: d }),
|
|
1740
1752
|
/* @__PURE__ */ c("div", { className: "nice-payment-form__card", children: /* @__PURE__ */ c(
|
|
1741
1753
|
Gt,
|
|
1742
1754
|
{
|
|
1743
|
-
value:
|
|
1744
|
-
onChange: (
|
|
1745
|
-
|
|
1755
|
+
value: I,
|
|
1756
|
+
onChange: (O, C) => {
|
|
1757
|
+
w(O), F(C);
|
|
1746
1758
|
},
|
|
1747
|
-
disabled:
|
|
1759
|
+
disabled: R
|
|
1748
1760
|
}
|
|
1749
1761
|
) }),
|
|
1750
|
-
!K && /* @__PURE__ */ c("div", { className: "nice-payment-form__warning", role: "alert", children:
|
|
1751
|
-
!
|
|
1752
|
-
|
|
1762
|
+
!K && /* @__PURE__ */ c("div", { className: "nice-payment-form__warning", role: "alert", children: _("paymentForm.doesNotAccept", "{provider} does not accept {currency}.").replace("{provider}", String(e.name)).replace("{currency}", String((ne == null ? void 0 : ne.name) ?? D.currency)) }),
|
|
1763
|
+
!V && re && /* @__PURE__ */ f("div", { className: "nice-payment-form__warning", role: "alert", children: [
|
|
1764
|
+
_("paymentForm.minimumChargeForIs", "Minimum charge for {name} is").replace(
|
|
1753
1765
|
"{name}",
|
|
1754
1766
|
String(e.name)
|
|
1755
1767
|
),
|
|
@@ -1757,20 +1769,20 @@ const gr = /* @__PURE__ */ se(
|
|
|
1757
1769
|
/* @__PURE__ */ c(ze, { value: re }),
|
|
1758
1770
|
"."
|
|
1759
1771
|
] }),
|
|
1760
|
-
|
|
1772
|
+
h && /* @__PURE__ */ c("div", { className: "nice-payment-form__consents", children: h }),
|
|
1761
1773
|
A && /* @__PURE__ */ c("div", { className: "nice-payment-form__error", role: "alert", children: A }),
|
|
1762
1774
|
/* @__PURE__ */ c(
|
|
1763
1775
|
"button",
|
|
1764
1776
|
{
|
|
1765
1777
|
type: "submit",
|
|
1766
1778
|
className: "nice-payment-form__submit",
|
|
1767
|
-
disabled: !
|
|
1768
|
-
"aria-disabled": !
|
|
1769
|
-
children:
|
|
1779
|
+
disabled: !Q,
|
|
1780
|
+
"aria-disabled": !Q,
|
|
1781
|
+
children: R ? _("paymentForm.processing", "Processing…") : M
|
|
1770
1782
|
}
|
|
1771
1783
|
),
|
|
1772
|
-
/* @__PURE__ */
|
|
1773
|
-
|
|
1784
|
+
/* @__PURE__ */ f("p", { className: "nice-payment-form__processor", children: [
|
|
1785
|
+
_("paymentForm.securedBy", "Secured by"),
|
|
1774
1786
|
" ",
|
|
1775
1787
|
/* @__PURE__ */ c("strong", { children: e.name })
|
|
1776
1788
|
] })
|
|
@@ -1793,31 +1805,33 @@ const vr = /* @__PURE__ */ se(
|
|
|
1793
1805
|
size: i = "md",
|
|
1794
1806
|
locale: o,
|
|
1795
1807
|
className: l,
|
|
1796
|
-
style:
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1808
|
+
style: p,
|
|
1809
|
+
testId: N,
|
|
1810
|
+
"data-testid": h
|
|
1811
|
+
}, u) {
|
|
1812
|
+
const { t: g } = oe(), b = r && r.currency === e.currency && r.amount > e.amount, _ = B(() => !b || !r ? null : Math.round((r.amount - e.amount) / r.amount * 100), [b, r, e.amount]), M = `nice-price-tag nice-price-tag--${i}` + (l ? ` ${l}` : "");
|
|
1813
|
+
return /* @__PURE__ */ f("div", { ref: u, className: M, style: p, "data-testid": h ?? N, children: [
|
|
1800
1814
|
a && /* @__PURE__ */ c("span", { className: "nice-price-tag__prefix", children: a }),
|
|
1801
|
-
/* @__PURE__ */
|
|
1815
|
+
/* @__PURE__ */ f("span", { className: "nice-price-tag__main", children: [
|
|
1802
1816
|
/* @__PURE__ */ c("span", { className: "nice-price-tag__amount", children: ie(e, { locale: o }) }),
|
|
1803
1817
|
n && /* @__PURE__ */ c("span", { className: "nice-price-tag__period", children: n })
|
|
1804
1818
|
] }),
|
|
1805
|
-
|
|
1819
|
+
b && r && /* @__PURE__ */ c(
|
|
1806
1820
|
"span",
|
|
1807
1821
|
{
|
|
1808
1822
|
className: "nice-price-tag__original",
|
|
1809
|
-
"aria-label":
|
|
1823
|
+
"aria-label": g("priceTag.originalPrice", "Original price"),
|
|
1810
1824
|
children: /* @__PURE__ */ c("s", { children: ie(r, { locale: o }) })
|
|
1811
1825
|
}
|
|
1812
1826
|
),
|
|
1813
|
-
|
|
1827
|
+
b && d && _ != null && _ > 0 && /* @__PURE__ */ f(
|
|
1814
1828
|
"span",
|
|
1815
1829
|
{
|
|
1816
1830
|
className: "nice-price-tag__discount",
|
|
1817
|
-
"aria-label":
|
|
1831
|
+
"aria-label": g("priceTag.percentOff", "{pct} percent off").replace("{pct}", String(_)),
|
|
1818
1832
|
children: [
|
|
1819
1833
|
"−",
|
|
1820
|
-
|
|
1834
|
+
_,
|
|
1821
1835
|
"%"
|
|
1822
1836
|
]
|
|
1823
1837
|
}
|
|
@@ -1835,76 +1849,76 @@ const vr = /* @__PURE__ */ se(
|
|
|
1835
1849
|
provider: i,
|
|
1836
1850
|
locale: o,
|
|
1837
1851
|
showRateLine: l = !0,
|
|
1838
|
-
className:
|
|
1852
|
+
className: p,
|
|
1839
1853
|
style: N
|
|
1840
|
-
},
|
|
1841
|
-
const { t: u } = oe(), [
|
|
1854
|
+
}, h) {
|
|
1855
|
+
const { t: u } = oe(), [g, b] = Ue({
|
|
1842
1856
|
value: e,
|
|
1843
1857
|
defaultValue: r,
|
|
1844
1858
|
fallbackValue: Xt,
|
|
1845
1859
|
onChange: n,
|
|
1846
1860
|
componentName: "NiceCurrencyConverter"
|
|
1847
|
-
}), [
|
|
1861
|
+
}), [_, M] = Ue({
|
|
1848
1862
|
value: a,
|
|
1849
1863
|
defaultValue: s,
|
|
1850
|
-
fallbackValue:
|
|
1864
|
+
fallbackValue: g.currency,
|
|
1851
1865
|
onChange: d,
|
|
1852
1866
|
componentName: "NiceCurrencyConverter"
|
|
1853
|
-
}), { converted:
|
|
1854
|
-
() => ({ amount: Math.pow(10, 2), currency:
|
|
1855
|
-
[
|
|
1856
|
-
), { converted:
|
|
1857
|
-
l ?
|
|
1858
|
-
|
|
1867
|
+
}), { converted: D, loading: v, error: y } = Ee(g, _, i), x = B(
|
|
1868
|
+
() => ({ amount: Math.pow(10, 2), currency: g.currency }),
|
|
1869
|
+
[g.currency]
|
|
1870
|
+
), { converted: I } = Ee(
|
|
1871
|
+
l ? x : null,
|
|
1872
|
+
_,
|
|
1859
1873
|
i
|
|
1860
1874
|
);
|
|
1861
|
-
return /* @__PURE__ */
|
|
1875
|
+
return /* @__PURE__ */ f(
|
|
1862
1876
|
"div",
|
|
1863
1877
|
{
|
|
1864
|
-
ref:
|
|
1865
|
-
className: "nice-currency-converter" + (
|
|
1878
|
+
ref: h,
|
|
1879
|
+
className: "nice-currency-converter" + (p ? ` ${p}` : ""),
|
|
1866
1880
|
style: N,
|
|
1867
1881
|
children: [
|
|
1868
1882
|
/* @__PURE__ */ c("div", { className: "nice-currency-converter__row", children: /* @__PURE__ */ c(
|
|
1869
1883
|
Ve,
|
|
1870
1884
|
{
|
|
1871
1885
|
label: u("currencyConverter.from", "From"),
|
|
1872
|
-
value:
|
|
1873
|
-
onChange: (
|
|
1874
|
-
currency:
|
|
1875
|
-
onCurrencyChange: (
|
|
1886
|
+
value: g,
|
|
1887
|
+
onChange: (w) => w && b(w),
|
|
1888
|
+
currency: g.currency,
|
|
1889
|
+
onCurrencyChange: (w) => b({ ...g, currency: w }),
|
|
1876
1890
|
showFormattedPreview: !1
|
|
1877
1891
|
}
|
|
1878
1892
|
) }),
|
|
1879
|
-
/* @__PURE__ */
|
|
1893
|
+
/* @__PURE__ */ f("div", { className: "nice-currency-converter__row", children: [
|
|
1880
1894
|
/* @__PURE__ */ c("label", { className: "nice-currency-converter__label", children: u("currencyConverter.to", "To") }),
|
|
1881
|
-
/* @__PURE__ */
|
|
1895
|
+
/* @__PURE__ */ f("div", { className: "nice-currency-converter__output", children: [
|
|
1882
1896
|
/* @__PURE__ */ c(
|
|
1883
1897
|
Qe,
|
|
1884
1898
|
{
|
|
1885
|
-
value:
|
|
1886
|
-
onChange: (
|
|
1899
|
+
value: _,
|
|
1900
|
+
onChange: (w) => M(w),
|
|
1887
1901
|
compact: !0
|
|
1888
1902
|
}
|
|
1889
1903
|
),
|
|
1890
|
-
/* @__PURE__ */ c("span", { className: "nice-currency-converter__amount", children:
|
|
1904
|
+
/* @__PURE__ */ c("span", { className: "nice-currency-converter__amount", children: v ? "…" : y ? "—" : D ? ie(D, { locale: o }) : "" })
|
|
1891
1905
|
] })
|
|
1892
1906
|
] }),
|
|
1893
|
-
l &&
|
|
1907
|
+
l && I && /* @__PURE__ */ f("p", { className: "nice-currency-converter__rate", children: [
|
|
1894
1908
|
"1 ",
|
|
1895
|
-
|
|
1909
|
+
g.currency,
|
|
1896
1910
|
" = ",
|
|
1897
|
-
ie(
|
|
1911
|
+
ie(I, { locale: o }),
|
|
1898
1912
|
" ",
|
|
1899
|
-
/* @__PURE__ */
|
|
1913
|
+
/* @__PURE__ */ f("span", { className: "nice-currency-converter__inverse", children: [
|
|
1900
1914
|
"· 1 ",
|
|
1901
|
-
|
|
1915
|
+
_,
|
|
1902
1916
|
" =",
|
|
1903
1917
|
" ",
|
|
1904
|
-
ie(ae(1 / Ge(
|
|
1918
|
+
ie(ae(1 / Ge(I), g.currency), { locale: o })
|
|
1905
1919
|
] })
|
|
1906
1920
|
] }),
|
|
1907
|
-
|
|
1921
|
+
y && /* @__PURE__ */ c("p", { className: "nice-currency-converter__error", role: "alert", children: y.message })
|
|
1908
1922
|
]
|
|
1909
1923
|
}
|
|
1910
1924
|
);
|
|
@@ -1923,76 +1937,79 @@ const wr = /* @__PURE__ */ se(
|
|
|
1923
1937
|
labels: i,
|
|
1924
1938
|
density: o = "comfortable",
|
|
1925
1939
|
className: l,
|
|
1926
|
-
style:
|
|
1927
|
-
id: N
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1940
|
+
style: p,
|
|
1941
|
+
id: N,
|
|
1942
|
+
testId: h,
|
|
1943
|
+
"data-testid": u
|
|
1944
|
+
}, g) {
|
|
1945
|
+
const { t: b } = oe(), _ = {
|
|
1946
|
+
label: (i == null ? void 0 : i.label) ?? b("taxBreakdown.item", "Item"),
|
|
1931
1947
|
rate: (i == null ? void 0 : i.rate) ?? "VAT",
|
|
1932
1948
|
net: (i == null ? void 0 : i.net) ?? "Net",
|
|
1933
1949
|
vat: (i == null ? void 0 : i.vat) ?? "Tax",
|
|
1934
1950
|
gross: (i == null ? void 0 : i.gross) ?? "Gross",
|
|
1935
1951
|
total: (i == null ? void 0 : i.total) ?? "Total"
|
|
1936
|
-
},
|
|
1952
|
+
}, M = B(() => {
|
|
1937
1953
|
if (n === "total") {
|
|
1938
|
-
const
|
|
1939
|
-
for (const
|
|
1940
|
-
let
|
|
1941
|
-
|
|
1954
|
+
const y = /* @__PURE__ */ new Map();
|
|
1955
|
+
for (const I of e) {
|
|
1956
|
+
let w = y.get(I.vatRate);
|
|
1957
|
+
w || (w = [], y.set(I.vatRate, w)), w.push(I.netAmount);
|
|
1942
1958
|
}
|
|
1943
|
-
const
|
|
1944
|
-
for (const [
|
|
1945
|
-
const
|
|
1946
|
-
|
|
1959
|
+
const x = [];
|
|
1960
|
+
for (const [I, w] of y) {
|
|
1961
|
+
const S = w.reduce((X, A) => ye(X, A), ae(0, w[0].currency)), F = je(Ae(S, I)), R = ye(S, F);
|
|
1962
|
+
x.push({ rate: I, net: S, vat: F, gross: R });
|
|
1947
1963
|
}
|
|
1948
|
-
return
|
|
1964
|
+
return x;
|
|
1949
1965
|
}
|
|
1950
|
-
return e.map((
|
|
1951
|
-
const
|
|
1952
|
-
return { label:
|
|
1966
|
+
return e.map((y) => {
|
|
1967
|
+
const x = je(Ae(y.netAmount, y.vatRate)), I = ye(y.netAmount, x);
|
|
1968
|
+
return { label: y.label, rate: y.vatRate, net: y.netAmount, vat: x, gross: I };
|
|
1953
1969
|
});
|
|
1954
|
-
}, [e, n]),
|
|
1955
|
-
if (
|
|
1970
|
+
}, [e, n]), D = B(() => {
|
|
1971
|
+
if (M.length === 0)
|
|
1956
1972
|
return null;
|
|
1957
|
-
const
|
|
1958
|
-
let
|
|
1959
|
-
for (const
|
|
1960
|
-
|
|
1961
|
-
return { net:
|
|
1962
|
-
}, [
|
|
1963
|
-
return /* @__PURE__ */
|
|
1973
|
+
const y = M[0].net.currency;
|
|
1974
|
+
let x = ae(0, y), I = ae(0, y), w = ae(0, y);
|
|
1975
|
+
for (const S of M)
|
|
1976
|
+
x = ye(x, S.net), I = ye(I, S.vat), w = ye(w, S.gross);
|
|
1977
|
+
return { net: x, vat: I, gross: w };
|
|
1978
|
+
}, [M]), v = (y) => ie(y, { locale: r });
|
|
1979
|
+
return /* @__PURE__ */ f(
|
|
1964
1980
|
"table",
|
|
1965
1981
|
{
|
|
1966
|
-
ref:
|
|
1982
|
+
ref: g,
|
|
1967
1983
|
id: N,
|
|
1968
1984
|
className: `nice-tax-breakdown nice-tax-breakdown--${o} ${l ?? ""}`,
|
|
1969
|
-
style:
|
|
1985
|
+
style: p,
|
|
1970
1986
|
role: "table",
|
|
1971
|
-
"aria-label":
|
|
1987
|
+
"aria-label": _.total,
|
|
1988
|
+
"data-testid": u ?? h,
|
|
1972
1989
|
children: [
|
|
1973
|
-
/* @__PURE__ */ c("thead", { children: /* @__PURE__ */
|
|
1974
|
-
|
|
1975
|
-
!d && /* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__rate", children:
|
|
1976
|
-
/* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__num", children:
|
|
1977
|
-
/* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__num", children:
|
|
1978
|
-
/* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__num", children:
|
|
1990
|
+
/* @__PURE__ */ c("thead", { children: /* @__PURE__ */ f("tr", { children: [
|
|
1991
|
+
M.some((y) => y.label !== void 0) && /* @__PURE__ */ c("th", { scope: "col", children: _.label }),
|
|
1992
|
+
!d && /* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__rate", children: _.rate }),
|
|
1993
|
+
/* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__num", children: _.net }),
|
|
1994
|
+
/* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__num", children: _.vat }),
|
|
1995
|
+
/* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__num", children: _.gross })
|
|
1979
1996
|
] }) }),
|
|
1980
|
-
/* @__PURE__ */ c("tbody", { children:
|
|
1981
|
-
|
|
1982
|
-
!d && /* @__PURE__ */
|
|
1983
|
-
(
|
|
1997
|
+
/* @__PURE__ */ c("tbody", { children: M.map((y, x) => /* @__PURE__ */ f("tr", { children: [
|
|
1998
|
+
M.some((I) => I.label !== void 0) && /* @__PURE__ */ c("td", { children: y.label ?? "" }),
|
|
1999
|
+
!d && /* @__PURE__ */ f("td", { className: "nice-tax-breakdown__rate", children: [
|
|
2000
|
+
(y.rate * 100).toLocaleString(r, { maximumFractionDigits: 2 }),
|
|
1984
2001
|
"%"
|
|
1985
2002
|
] }),
|
|
1986
|
-
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children:
|
|
1987
|
-
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children:
|
|
1988
|
-
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children:
|
|
1989
|
-
] }, `${
|
|
1990
|
-
a &&
|
|
1991
|
-
|
|
1992
|
-
!d && /* @__PURE__ */ c("td", { children:
|
|
1993
|
-
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children:
|
|
1994
|
-
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children:
|
|
1995
|
-
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children:
|
|
2003
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: v(y.net) }),
|
|
2004
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: v(y.vat) }),
|
|
2005
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: v(y.gross) })
|
|
2006
|
+
] }, `${y.rate}-${x}`)) }),
|
|
2007
|
+
a && D && /* @__PURE__ */ c("tfoot", { children: s && /* @__PURE__ */ f("tr", { className: "nice-tax-breakdown__totals", children: [
|
|
2008
|
+
M.some((y) => y.label !== void 0) && /* @__PURE__ */ c("td", { children: _.total }),
|
|
2009
|
+
!d && /* @__PURE__ */ c("td", { children: M.some((y) => y.label !== void 0) ? null : _.total }),
|
|
2010
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: v(D.net) }),
|
|
2011
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: v(D.vat) }),
|
|
2012
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: v(D.gross) })
|
|
1996
2013
|
] }) })
|
|
1997
2014
|
]
|
|
1998
2015
|
}
|
|
@@ -2006,65 +2023,65 @@ const wr = /* @__PURE__ */ se(
|
|
|
2006
2023
|
layout: i = "list",
|
|
2007
2024
|
columns: o = 2,
|
|
2008
2025
|
currency: l,
|
|
2009
|
-
label:
|
|
2026
|
+
label: p,
|
|
2010
2027
|
name: N,
|
|
2011
|
-
readOnly:
|
|
2028
|
+
readOnly: h = !1,
|
|
2012
2029
|
className: u,
|
|
2013
|
-
style:
|
|
2014
|
-
id:
|
|
2015
|
-
accessMode:
|
|
2016
|
-
"data-testid":
|
|
2017
|
-
} = e,
|
|
2030
|
+
style: g,
|
|
2031
|
+
id: b,
|
|
2032
|
+
accessMode: _,
|
|
2033
|
+
"data-testid": M
|
|
2034
|
+
} = e, D = Ne(), v = N ?? `nice-pm-${D}`, y = B(() => {
|
|
2018
2035
|
if (!l)
|
|
2019
2036
|
return a;
|
|
2020
|
-
const
|
|
2037
|
+
const S = l.toUpperCase();
|
|
2021
2038
|
return a.filter(
|
|
2022
|
-
(
|
|
2039
|
+
(F) => !F.currencies || F.currencies.map((R) => R.toUpperCase()).includes(S)
|
|
2023
2040
|
);
|
|
2024
2041
|
}, [a, l]);
|
|
2025
|
-
if (
|
|
2042
|
+
if (_ === "hidden")
|
|
2026
2043
|
return null;
|
|
2027
|
-
const
|
|
2028
|
-
return /* @__PURE__ */
|
|
2029
|
-
|
|
2030
|
-
/* @__PURE__ */
|
|
2044
|
+
const x = h || _ === "disabled" || _ === "readOnly", I = `nice-payment-method-selector nice-payment-method-selector--${i}` + (u ? ` ${u}` : ""), w = i === "grid" ? { gridTemplateColumns: `repeat(${o}, minmax(0, 1fr))` } : void 0;
|
|
2045
|
+
return /* @__PURE__ */ f("div", { ref: r, id: b, className: I, style: g, "data-testid": M, children: [
|
|
2046
|
+
p && /* @__PURE__ */ c("div", { className: "nice-payment-method-selector__label", children: p }),
|
|
2047
|
+
/* @__PURE__ */ f(
|
|
2031
2048
|
"div",
|
|
2032
2049
|
{
|
|
2033
2050
|
className: "nice-payment-method-selector__options",
|
|
2034
|
-
style:
|
|
2051
|
+
style: w,
|
|
2035
2052
|
role: "radiogroup",
|
|
2036
|
-
"aria-label":
|
|
2053
|
+
"aria-label": p ?? n("paymentMethodSelector.paymentMethod", "Payment method"),
|
|
2037
2054
|
children: [
|
|
2038
|
-
|
|
2039
|
-
const
|
|
2040
|
-
return /* @__PURE__ */
|
|
2055
|
+
y.map((S) => {
|
|
2056
|
+
const F = S.id === s, R = x || S.disabled;
|
|
2057
|
+
return /* @__PURE__ */ f(
|
|
2041
2058
|
"label",
|
|
2042
2059
|
{
|
|
2043
|
-
className: "nice-payment-method-selector__option" + (
|
|
2060
|
+
className: "nice-payment-method-selector__option" + (F ? " nice-payment-method-selector__option--selected" : "") + (R ? " nice-payment-method-selector__option--disabled" : ""),
|
|
2044
2061
|
children: [
|
|
2045
2062
|
/* @__PURE__ */ c(
|
|
2046
2063
|
"input",
|
|
2047
2064
|
{
|
|
2048
2065
|
type: "radio",
|
|
2049
2066
|
className: "nice-payment-method-selector__radio",
|
|
2050
|
-
name:
|
|
2051
|
-
value:
|
|
2052
|
-
checked:
|
|
2053
|
-
disabled:
|
|
2054
|
-
onChange: () => d == null ? void 0 : d(
|
|
2067
|
+
name: v,
|
|
2068
|
+
value: S.id,
|
|
2069
|
+
checked: F,
|
|
2070
|
+
disabled: R,
|
|
2071
|
+
onChange: () => d == null ? void 0 : d(S.id)
|
|
2055
2072
|
}
|
|
2056
2073
|
),
|
|
2057
|
-
|
|
2058
|
-
/* @__PURE__ */
|
|
2059
|
-
/* @__PURE__ */ c("span", { className: "nice-payment-method-selector__name", children:
|
|
2060
|
-
|
|
2074
|
+
S.icon && /* @__PURE__ */ c("span", { className: "nice-payment-method-selector__icon", children: S.icon }),
|
|
2075
|
+
/* @__PURE__ */ f("span", { className: "nice-payment-method-selector__text", children: [
|
|
2076
|
+
/* @__PURE__ */ c("span", { className: "nice-payment-method-selector__name", children: S.label }),
|
|
2077
|
+
S.description && /* @__PURE__ */ c("span", { className: "nice-payment-method-selector__desc", children: S.description })
|
|
2061
2078
|
] })
|
|
2062
2079
|
]
|
|
2063
2080
|
},
|
|
2064
|
-
|
|
2081
|
+
S.id
|
|
2065
2082
|
);
|
|
2066
2083
|
}),
|
|
2067
|
-
|
|
2084
|
+
y.length === 0 && /* @__PURE__ */ c("div", { className: "nice-payment-method-selector__empty", children: n("paymentMethodSelector.noMethodsAvailable", "No methods available.") })
|
|
2068
2085
|
]
|
|
2069
2086
|
}
|
|
2070
2087
|
)
|
|
@@ -2091,70 +2108,70 @@ const wr = /* @__PURE__ */ se(
|
|
|
2091
2108
|
providers: i,
|
|
2092
2109
|
onTestConnection: o,
|
|
2093
2110
|
showWebhookUrl: l = !0,
|
|
2094
|
-
baseUrl:
|
|
2111
|
+
baseUrl: p,
|
|
2095
2112
|
readOnly: N = !1,
|
|
2096
|
-
testLabel:
|
|
2113
|
+
testLabel: h = n("paymentProviderConfig.testConnection", "Test connection"),
|
|
2097
2114
|
tutorial: u,
|
|
2098
|
-
className:
|
|
2099
|
-
style:
|
|
2100
|
-
id:
|
|
2101
|
-
accessMode:
|
|
2102
|
-
"data-testid":
|
|
2103
|
-
} = e, [
|
|
2115
|
+
className: g,
|
|
2116
|
+
style: b,
|
|
2117
|
+
id: _,
|
|
2118
|
+
accessMode: M,
|
|
2119
|
+
"data-testid": D
|
|
2120
|
+
} = e, [v, y] = Ue({
|
|
2104
2121
|
value: a,
|
|
2105
2122
|
defaultValue: s,
|
|
2106
2123
|
fallbackValue: er,
|
|
2107
2124
|
onChange: d,
|
|
2108
2125
|
componentName: "NicePaymentProviderConfig"
|
|
2109
|
-
}),
|
|
2110
|
-
if (
|
|
2126
|
+
}), x = Ne(), [I, w] = j(/* @__PURE__ */ new Set()), [S, F] = j(!1), [R, X] = j(null), A = B(() => i ? i.map((m) => Pe[m]).filter((m) => !!m) : Ht, [i]), $ = Pe[v.providerId];
|
|
2127
|
+
if (M === "hidden")
|
|
2111
2128
|
return null;
|
|
2112
|
-
const T = N ||
|
|
2113
|
-
|
|
2114
|
-
},
|
|
2115
|
-
|
|
2116
|
-
}, re = (
|
|
2117
|
-
const
|
|
2118
|
-
|
|
2119
|
-
}, G = (
|
|
2120
|
-
|
|
2121
|
-
const L = new Set(
|
|
2122
|
-
return L.has(
|
|
2129
|
+
const T = N || M === "disabled" || M === "readOnly", K = (m) => {
|
|
2130
|
+
X(null), w(/* @__PURE__ */ new Set()), y({ providerId: m, mode: v.mode, credentials: {}, enabledMethods: [] });
|
|
2131
|
+
}, V = (m, q) => {
|
|
2132
|
+
y({ ...v, credentials: { ...v.credentials, [m]: q } });
|
|
2133
|
+
}, re = (m) => {
|
|
2134
|
+
const q = new Set(v.enabledMethods ?? []);
|
|
2135
|
+
q.has(m) ? q.delete(m) : q.add(m), y({ ...v, enabledMethods: [...q] });
|
|
2136
|
+
}, G = (m) => {
|
|
2137
|
+
w((q) => {
|
|
2138
|
+
const L = new Set(q);
|
|
2139
|
+
return L.has(m) ? L.delete(m) : L.add(m), L;
|
|
2123
2140
|
});
|
|
2124
|
-
},
|
|
2141
|
+
}, Q = async () => {
|
|
2125
2142
|
if (o) {
|
|
2126
|
-
|
|
2143
|
+
F(!0), X(null);
|
|
2127
2144
|
try {
|
|
2128
|
-
|
|
2129
|
-
} catch (
|
|
2130
|
-
|
|
2145
|
+
X(await o(v));
|
|
2146
|
+
} catch (m) {
|
|
2147
|
+
X({ ok: !1, message: m instanceof Error ? m.message : String(m) });
|
|
2131
2148
|
} finally {
|
|
2132
|
-
|
|
2149
|
+
F(!1);
|
|
2133
2150
|
}
|
|
2134
2151
|
}
|
|
2135
|
-
},
|
|
2136
|
-
(
|
|
2152
|
+
}, W = $ != null && $.webhookPath ? `${(p ?? "").replace(/\/$/, "")}${$.webhookPath}` : "", ne = ($ == null ? void 0 : $.supportedCurrencies) === "*" ? n("paymentProviderConfig.allCurrencies", "All currencies") : (($ == null ? void 0 : $.supportedCurrencies) ?? []).join(", "), O = "nice-payment-provider-config" + (g ? ` ${g}` : ""), C = (($ == null ? void 0 : $.credentials) ?? []).filter(
|
|
2153
|
+
(m) => !m.testOnly || v.mode === "test"
|
|
2137
2154
|
);
|
|
2138
|
-
return /* @__PURE__ */
|
|
2155
|
+
return /* @__PURE__ */ f("div", { ref: r, id: _, className: O, style: b, "data-testid": D, children: [
|
|
2139
2156
|
u && /* @__PURE__ */ c("div", { className: "nice-payment-provider-config__tutorial", children: /* @__PURE__ */ c(mt, { steps: pt(u, Wt) }) }),
|
|
2140
|
-
/* @__PURE__ */
|
|
2141
|
-
/* @__PURE__ */
|
|
2157
|
+
/* @__PURE__ */ f("div", { className: "nice-payment-provider-config__row", children: [
|
|
2158
|
+
/* @__PURE__ */ f("label", { className: "nice-payment-provider-config__field", children: [
|
|
2142
2159
|
/* @__PURE__ */ c("span", { className: "nice-payment-provider-config__field-label", children: n("paymentProviderConfig.provider", "Provider") }),
|
|
2143
|
-
/* @__PURE__ */
|
|
2160
|
+
/* @__PURE__ */ f(
|
|
2144
2161
|
"select",
|
|
2145
2162
|
{
|
|
2146
2163
|
className: "nice-payment-provider-config__select",
|
|
2147
|
-
value:
|
|
2164
|
+
value: v.providerId,
|
|
2148
2165
|
disabled: T,
|
|
2149
|
-
onChange: (
|
|
2166
|
+
onChange: (m) => K(m.target.value),
|
|
2150
2167
|
children: [
|
|
2151
2168
|
/* @__PURE__ */ c("option", { value: "", children: n("paymentProviderConfig.selectProvider", "— select provider —") }),
|
|
2152
|
-
A.map((
|
|
2169
|
+
A.map((m) => /* @__PURE__ */ c("option", { value: m.id, children: m.name }, m.id))
|
|
2153
2170
|
]
|
|
2154
2171
|
}
|
|
2155
2172
|
)
|
|
2156
2173
|
] }),
|
|
2157
|
-
(
|
|
2174
|
+
($ == null ? void 0 : $.hasTestMode) && /* @__PURE__ */ f(
|
|
2158
2175
|
"div",
|
|
2159
2176
|
{
|
|
2160
2177
|
className: "nice-payment-provider-config__mode",
|
|
@@ -2165,8 +2182,8 @@ const wr = /* @__PURE__ */ se(
|
|
|
2165
2182
|
"button",
|
|
2166
2183
|
{
|
|
2167
2184
|
type: "button",
|
|
2168
|
-
className: "nice-payment-provider-config__mode-btn" + (
|
|
2169
|
-
onClick: () =>
|
|
2185
|
+
className: "nice-payment-provider-config__mode-btn" + (v.mode === "test" ? " nice-payment-provider-config__mode-btn--active" : ""),
|
|
2186
|
+
onClick: () => y({ ...v, mode: "test" }),
|
|
2170
2187
|
disabled: T,
|
|
2171
2188
|
children: n("paymentProviderConfig.test", "Test")
|
|
2172
2189
|
}
|
|
@@ -2175,8 +2192,8 @@ const wr = /* @__PURE__ */ se(
|
|
|
2175
2192
|
"button",
|
|
2176
2193
|
{
|
|
2177
2194
|
type: "button",
|
|
2178
|
-
className: "nice-payment-provider-config__mode-btn" + (
|
|
2179
|
-
onClick: () =>
|
|
2195
|
+
className: "nice-payment-provider-config__mode-btn" + (v.mode === "live" ? " nice-payment-provider-config__mode-btn--active" : ""),
|
|
2196
|
+
onClick: () => y({ ...v, mode: "live" }),
|
|
2180
2197
|
disabled: T,
|
|
2181
2198
|
children: n("paymentProviderConfig.live", "Live")
|
|
2182
2199
|
}
|
|
@@ -2185,29 +2202,29 @@ const wr = /* @__PURE__ */ se(
|
|
|
2185
2202
|
}
|
|
2186
2203
|
)
|
|
2187
2204
|
] }),
|
|
2188
|
-
|
|
2189
|
-
/* @__PURE__ */
|
|
2190
|
-
/* @__PURE__ */ c("span", { className: "nice-payment-provider-config__badge", children:
|
|
2205
|
+
$ && /* @__PURE__ */ f(dt, { children: [
|
|
2206
|
+
/* @__PURE__ */ f("div", { className: "nice-payment-provider-config__meta", children: [
|
|
2207
|
+
/* @__PURE__ */ c("span", { className: "nice-payment-provider-config__badge", children: $.type }),
|
|
2191
2208
|
/* @__PURE__ */ c("span", { className: "nice-payment-provider-config__currencies", children: ne })
|
|
2192
2209
|
] }),
|
|
2193
|
-
/* @__PURE__ */ c("div", { className: "nice-payment-provider-config__credentials", children: C.map((
|
|
2194
|
-
const
|
|
2195
|
-
return /* @__PURE__ */
|
|
2196
|
-
/* @__PURE__ */
|
|
2197
|
-
|
|
2198
|
-
|
|
2210
|
+
/* @__PURE__ */ c("div", { className: "nice-payment-provider-config__credentials", children: C.map((m) => {
|
|
2211
|
+
const q = `${x}-${m.key}`, L = m.secret, P = I.has(m.key);
|
|
2212
|
+
return /* @__PURE__ */ f("div", { className: "nice-payment-provider-config__field", children: [
|
|
2213
|
+
/* @__PURE__ */ f("label", { className: "nice-payment-provider-config__field-label", htmlFor: q, children: [
|
|
2214
|
+
m.label,
|
|
2215
|
+
m.required && /* @__PURE__ */ c("span", { className: "nice-payment-provider-config__required", children: " *" })
|
|
2199
2216
|
] }),
|
|
2200
|
-
/* @__PURE__ */
|
|
2217
|
+
/* @__PURE__ */ f("div", { className: "nice-payment-provider-config__input-wrap", children: [
|
|
2201
2218
|
/* @__PURE__ */ c(
|
|
2202
2219
|
"input",
|
|
2203
2220
|
{
|
|
2204
|
-
id:
|
|
2205
|
-
type: L && !
|
|
2221
|
+
id: q,
|
|
2222
|
+
type: L && !P ? "password" : "text",
|
|
2206
2223
|
className: "nice-payment-provider-config__input",
|
|
2207
|
-
value:
|
|
2224
|
+
value: v.credentials[m.key] ?? "",
|
|
2208
2225
|
readOnly: T,
|
|
2209
2226
|
autoComplete: L ? "new-password" : "off",
|
|
2210
|
-
onChange: (z) =>
|
|
2227
|
+
onChange: (z) => V(m.key, z.target.value)
|
|
2211
2228
|
}
|
|
2212
2229
|
),
|
|
2213
2230
|
L && /* @__PURE__ */ c(
|
|
@@ -2215,54 +2232,54 @@ const wr = /* @__PURE__ */ se(
|
|
|
2215
2232
|
{
|
|
2216
2233
|
type: "button",
|
|
2217
2234
|
className: "nice-payment-provider-config__reveal",
|
|
2218
|
-
onClick: () => G(
|
|
2219
|
-
"aria-label":
|
|
2220
|
-
"aria-pressed":
|
|
2221
|
-
children: /* @__PURE__ */ c(ve, { name:
|
|
2235
|
+
onClick: () => G(m.key),
|
|
2236
|
+
"aria-label": P ? n("paymentProviderConfig.hide", "Hide") : n("paymentProviderConfig.reveal", "Reveal"),
|
|
2237
|
+
"aria-pressed": P,
|
|
2238
|
+
children: /* @__PURE__ */ c(ve, { name: P ? "eye-off" : "eye", size: 14 })
|
|
2222
2239
|
}
|
|
2223
2240
|
)
|
|
2224
2241
|
] }),
|
|
2225
|
-
|
|
2226
|
-
] },
|
|
2242
|
+
m.help && /* @__PURE__ */ c("span", { className: "nice-payment-provider-config__help", children: m.help })
|
|
2243
|
+
] }, m.key);
|
|
2227
2244
|
}) }),
|
|
2228
|
-
|
|
2245
|
+
$.supportedMethods && $.supportedMethods.length > 0 && /* @__PURE__ */ f("div", { className: "nice-payment-provider-config__methods", children: [
|
|
2229
2246
|
/* @__PURE__ */ c("span", { className: "nice-payment-provider-config__field-label", children: n("paymentProviderConfig.enabledMethods", "Enabled methods") }),
|
|
2230
|
-
/* @__PURE__ */ c("div", { className: "nice-payment-provider-config__method-list", children:
|
|
2247
|
+
/* @__PURE__ */ c("div", { className: "nice-payment-provider-config__method-list", children: $.supportedMethods.map((m) => /* @__PURE__ */ f("label", { className: "nice-payment-provider-config__method", children: [
|
|
2231
2248
|
/* @__PURE__ */ c(
|
|
2232
2249
|
"input",
|
|
2233
2250
|
{
|
|
2234
2251
|
type: "checkbox",
|
|
2235
|
-
checked: (
|
|
2252
|
+
checked: (v.enabledMethods ?? []).includes(m),
|
|
2236
2253
|
disabled: T,
|
|
2237
|
-
onChange: () => re(
|
|
2254
|
+
onChange: () => re(m)
|
|
2238
2255
|
}
|
|
2239
2256
|
),
|
|
2240
|
-
|
|
2241
|
-
] },
|
|
2257
|
+
m
|
|
2258
|
+
] }, m)) })
|
|
2242
2259
|
] }),
|
|
2243
|
-
l &&
|
|
2260
|
+
l && $.webhookPath && /* @__PURE__ */ f("div", { className: "nice-payment-provider-config__field", children: [
|
|
2244
2261
|
/* @__PURE__ */ c("span", { className: "nice-payment-provider-config__field-label", children: n("paymentProviderConfig.webhookUrl", "Webhook URL") }),
|
|
2245
|
-
/* @__PURE__ */ c("code", { className: "nice-payment-provider-config__webhook", children:
|
|
2262
|
+
/* @__PURE__ */ c("code", { className: "nice-payment-provider-config__webhook", children: W })
|
|
2246
2263
|
] }),
|
|
2247
|
-
o && /* @__PURE__ */
|
|
2264
|
+
o && /* @__PURE__ */ f("div", { className: "nice-payment-provider-config__test", children: [
|
|
2248
2265
|
/* @__PURE__ */ c(
|
|
2249
2266
|
"button",
|
|
2250
2267
|
{
|
|
2251
2268
|
type: "button",
|
|
2252
2269
|
className: "nice-payment-provider-config__test-btn",
|
|
2253
|
-
onClick: () => void
|
|
2254
|
-
disabled: T ||
|
|
2255
|
-
children:
|
|
2270
|
+
onClick: () => void Q(),
|
|
2271
|
+
disabled: T || S,
|
|
2272
|
+
children: S ? n("paymentProviderConfig.testing", "Testing…") : h
|
|
2256
2273
|
}
|
|
2257
2274
|
),
|
|
2258
|
-
|
|
2275
|
+
R && /* @__PURE__ */ f(
|
|
2259
2276
|
"span",
|
|
2260
2277
|
{
|
|
2261
|
-
className: "nice-payment-provider-config__test-result nice-payment-provider-config__test-result--" + (
|
|
2278
|
+
className: "nice-payment-provider-config__test-result nice-payment-provider-config__test-result--" + (R.ok ? "ok" : "error"),
|
|
2262
2279
|
children: [
|
|
2263
|
-
/* @__PURE__ */ c(ve, { name:
|
|
2280
|
+
/* @__PURE__ */ c(ve, { name: R.ok ? "check" : "close", size: 14 }),
|
|
2264
2281
|
" ",
|
|
2265
|
-
|
|
2282
|
+
R.message ?? (R.ok ? n("paymentProviderConfig.ok", "OK") : n("paymentProviderConfig.failed", "Failed"))
|
|
2266
2283
|
]
|
|
2267
2284
|
}
|
|
2268
2285
|
)
|