@nice2dev/ui-money 1.0.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/README.md +124 -0
- package/dist/catalog.d.ts +14 -0
- package/dist/components/NiceCreditCardInput.d.ts +26 -0
- package/dist/components/NiceCurrencyConverter.d.ts +26 -0
- package/dist/components/NiceCurrencySelector.d.ts +31 -0
- package/dist/components/NiceMoney.d.ts +30 -0
- package/dist/components/NiceMoneyInput.d.ts +43 -0
- package/dist/components/NicePaymentForm.d.ts +47 -0
- package/dist/components/NicePriceTag.d.ts +26 -0
- package/dist/creditCard.d.ts +24 -0
- package/dist/exchange.d.ts +81 -0
- package/dist/hooks.d.ts +42 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.mjs +1574 -0
- package/dist/money.d.ts +35 -0
- package/dist/processors.d.ts +84 -0
- package/dist/style.css +1 -0
- package/dist/types.d.ts +80 -0
- package/package.json +70 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,1574 @@
|
|
|
1
|
+
var Oe = Object.defineProperty;
|
|
2
|
+
var ke = (r, e, n) => e in r ? Oe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
|
|
3
|
+
var T = (r, e, n) => ke(r, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import Be, { useState as E, useRef as Te, useEffect as qe, useMemo as P, useCallback as R, forwardRef as te, useId as ye } from "react";
|
|
5
|
+
import { jsxs as N, jsx as i } from "react/jsx-runtime";
|
|
6
|
+
const se = [
|
|
7
|
+
// ── Majors ─────────────────────────────────────
|
|
8
|
+
{ code: "USD", numeric: 840, symbol: "$", name: "US Dollar", decimals: 2, symbolFirst: !0 },
|
|
9
|
+
{ code: "EUR", numeric: 978, symbol: "€", name: "Euro", decimals: 2, symbolFirst: !0 },
|
|
10
|
+
{
|
|
11
|
+
code: "GBP",
|
|
12
|
+
numeric: 826,
|
|
13
|
+
symbol: "£",
|
|
14
|
+
name: "Pound Sterling",
|
|
15
|
+
decimals: 2,
|
|
16
|
+
symbolFirst: !0
|
|
17
|
+
},
|
|
18
|
+
{ code: "JPY", numeric: 392, symbol: "¥", name: "Japanese Yen", decimals: 0, symbolFirst: !0 },
|
|
19
|
+
{ code: "CHF", numeric: 756, symbol: "Fr", name: "Swiss Franc", decimals: 2 },
|
|
20
|
+
{
|
|
21
|
+
code: "CAD",
|
|
22
|
+
numeric: 124,
|
|
23
|
+
symbol: "CA$",
|
|
24
|
+
name: "Canadian Dollar",
|
|
25
|
+
decimals: 2,
|
|
26
|
+
symbolFirst: !0
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
code: "AUD",
|
|
30
|
+
numeric: 36,
|
|
31
|
+
symbol: "A$",
|
|
32
|
+
name: "Australian Dollar",
|
|
33
|
+
decimals: 2,
|
|
34
|
+
symbolFirst: !0
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
code: "NZD",
|
|
38
|
+
numeric: 554,
|
|
39
|
+
symbol: "NZ$",
|
|
40
|
+
name: "New Zealand Dollar",
|
|
41
|
+
decimals: 2,
|
|
42
|
+
symbolFirst: !0
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
code: "CNY",
|
|
46
|
+
numeric: 156,
|
|
47
|
+
symbol: "¥",
|
|
48
|
+
name: "Chinese Yuan Renminbi",
|
|
49
|
+
decimals: 2,
|
|
50
|
+
symbolFirst: !0
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
code: "HKD",
|
|
54
|
+
numeric: 344,
|
|
55
|
+
symbol: "HK$",
|
|
56
|
+
name: "Hong Kong Dollar",
|
|
57
|
+
decimals: 2,
|
|
58
|
+
symbolFirst: !0
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
code: "SGD",
|
|
62
|
+
numeric: 702,
|
|
63
|
+
symbol: "S$",
|
|
64
|
+
name: "Singapore Dollar",
|
|
65
|
+
decimals: 2,
|
|
66
|
+
symbolFirst: !0
|
|
67
|
+
},
|
|
68
|
+
// ── Europe ─────────────────────────────────────
|
|
69
|
+
{ code: "PLN", numeric: 985, symbol: "zł", name: "Polish Złoty", decimals: 2 },
|
|
70
|
+
{ code: "CZK", numeric: 203, symbol: "Kč", name: "Czech Koruna", decimals: 2 },
|
|
71
|
+
{ code: "HUF", numeric: 348, symbol: "Ft", name: "Hungarian Forint", decimals: 2 },
|
|
72
|
+
{ code: "RON", numeric: 946, symbol: "lei", name: "Romanian Leu", decimals: 2 },
|
|
73
|
+
{ code: "BGN", numeric: 975, symbol: "лв", name: "Bulgarian Lev", decimals: 2 },
|
|
74
|
+
{ code: "HRK", numeric: 191, symbol: "kn", name: "Croatian Kuna", decimals: 2 },
|
|
75
|
+
{ code: "DKK", numeric: 208, symbol: "kr", name: "Danish Krone", decimals: 2 },
|
|
76
|
+
{ code: "SEK", numeric: 752, symbol: "kr", name: "Swedish Krona", decimals: 2 },
|
|
77
|
+
{ code: "NOK", numeric: 578, symbol: "kr", name: "Norwegian Krone", decimals: 2 },
|
|
78
|
+
{ code: "ISK", numeric: 352, symbol: "kr", name: "Icelandic Króna", decimals: 0 },
|
|
79
|
+
{ code: "RUB", numeric: 643, symbol: "₽", name: "Russian Ruble", decimals: 2 },
|
|
80
|
+
{ code: "UAH", numeric: 980, symbol: "₴", name: "Ukrainian Hryvnia", decimals: 2 },
|
|
81
|
+
{ code: "TRY", numeric: 949, symbol: "₺", name: "Turkish Lira", decimals: 2, symbolFirst: !0 },
|
|
82
|
+
// ── Americas ───────────────────────────────────
|
|
83
|
+
{
|
|
84
|
+
code: "MXN",
|
|
85
|
+
numeric: 484,
|
|
86
|
+
symbol: "Mex$",
|
|
87
|
+
name: "Mexican Peso",
|
|
88
|
+
decimals: 2,
|
|
89
|
+
symbolFirst: !0
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
code: "BRL",
|
|
93
|
+
numeric: 986,
|
|
94
|
+
symbol: "R$",
|
|
95
|
+
name: "Brazilian Real",
|
|
96
|
+
decimals: 2,
|
|
97
|
+
symbolFirst: !0
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
code: "ARS",
|
|
101
|
+
numeric: 32,
|
|
102
|
+
symbol: "AR$",
|
|
103
|
+
name: "Argentine Peso",
|
|
104
|
+
decimals: 2,
|
|
105
|
+
symbolFirst: !0
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
code: "CLP",
|
|
109
|
+
numeric: 152,
|
|
110
|
+
symbol: "CL$",
|
|
111
|
+
name: "Chilean Peso",
|
|
112
|
+
decimals: 0,
|
|
113
|
+
symbolFirst: !0
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
code: "COP",
|
|
117
|
+
numeric: 170,
|
|
118
|
+
symbol: "CO$",
|
|
119
|
+
name: "Colombian Peso",
|
|
120
|
+
decimals: 2,
|
|
121
|
+
symbolFirst: !0
|
|
122
|
+
},
|
|
123
|
+
{ code: "PEN", numeric: 604, symbol: "S/", name: "Peruvian Sol", decimals: 2, symbolFirst: !0 },
|
|
124
|
+
{
|
|
125
|
+
code: "UYU",
|
|
126
|
+
numeric: 858,
|
|
127
|
+
symbol: "$U",
|
|
128
|
+
name: "Uruguayan Peso",
|
|
129
|
+
decimals: 2,
|
|
130
|
+
symbolFirst: !0
|
|
131
|
+
},
|
|
132
|
+
// ── Asia & Pacific ─────────────────────────────
|
|
133
|
+
{ code: "INR", numeric: 356, symbol: "₹", name: "Indian Rupee", decimals: 2, symbolFirst: !0 },
|
|
134
|
+
{
|
|
135
|
+
code: "IDR",
|
|
136
|
+
numeric: 360,
|
|
137
|
+
symbol: "Rp",
|
|
138
|
+
name: "Indonesian Rupiah",
|
|
139
|
+
decimals: 2,
|
|
140
|
+
symbolFirst: !0
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
code: "KRW",
|
|
144
|
+
numeric: 410,
|
|
145
|
+
symbol: "₩",
|
|
146
|
+
name: "South Korean Won",
|
|
147
|
+
decimals: 0,
|
|
148
|
+
symbolFirst: !0
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
code: "MYR",
|
|
152
|
+
numeric: 458,
|
|
153
|
+
symbol: "RM",
|
|
154
|
+
name: "Malaysian Ringgit",
|
|
155
|
+
decimals: 2,
|
|
156
|
+
symbolFirst: !0
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
code: "PHP",
|
|
160
|
+
numeric: 608,
|
|
161
|
+
symbol: "₱",
|
|
162
|
+
name: "Philippine Peso",
|
|
163
|
+
decimals: 2,
|
|
164
|
+
symbolFirst: !0
|
|
165
|
+
},
|
|
166
|
+
{ code: "THB", numeric: 764, symbol: "฿", name: "Thai Baht", decimals: 2, symbolFirst: !0 },
|
|
167
|
+
{ code: "VND", numeric: 704, symbol: "₫", name: "Vietnamese Đồng", decimals: 0 },
|
|
168
|
+
{
|
|
169
|
+
code: "TWD",
|
|
170
|
+
numeric: 901,
|
|
171
|
+
symbol: "NT$",
|
|
172
|
+
name: "New Taiwan Dollar",
|
|
173
|
+
decimals: 2,
|
|
174
|
+
symbolFirst: !0
|
|
175
|
+
},
|
|
176
|
+
{ code: "PKR", numeric: 586, symbol: "₨", name: "Pakistani Rupee", decimals: 2 },
|
|
177
|
+
{ code: "BDT", numeric: 50, symbol: "৳", name: "Bangladeshi Taka", decimals: 2 },
|
|
178
|
+
{ code: "LKR", numeric: 144, symbol: "Rs", name: "Sri Lankan Rupee", decimals: 2 },
|
|
179
|
+
// ── Middle East & Africa ───────────────────────
|
|
180
|
+
{ code: "AED", numeric: 784, symbol: "د.إ", name: "UAE Dirham", decimals: 2 },
|
|
181
|
+
{ code: "SAR", numeric: 682, symbol: "ر.س", name: "Saudi Riyal", decimals: 2 },
|
|
182
|
+
{ code: "QAR", numeric: 634, symbol: "ر.ق", name: "Qatari Riyal", decimals: 2 },
|
|
183
|
+
{ code: "KWD", numeric: 414, symbol: "د.ك", name: "Kuwaiti Dinar", decimals: 3 },
|
|
184
|
+
{ code: "BHD", numeric: 48, symbol: ".د.ب", name: "Bahraini Dinar", decimals: 3 },
|
|
185
|
+
{ code: "OMR", numeric: 512, symbol: "ر.ع", name: "Omani Rial", decimals: 3 },
|
|
186
|
+
{ code: "JOD", numeric: 400, symbol: "د.أ", name: "Jordanian Dinar", decimals: 3 },
|
|
187
|
+
{
|
|
188
|
+
code: "ILS",
|
|
189
|
+
numeric: 376,
|
|
190
|
+
symbol: "₪",
|
|
191
|
+
name: "Israeli New Shekel",
|
|
192
|
+
decimals: 2,
|
|
193
|
+
symbolFirst: !0
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
code: "EGP",
|
|
197
|
+
numeric: 818,
|
|
198
|
+
symbol: "E£",
|
|
199
|
+
name: "Egyptian Pound",
|
|
200
|
+
decimals: 2,
|
|
201
|
+
symbolFirst: !0
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
code: "ZAR",
|
|
205
|
+
numeric: 710,
|
|
206
|
+
symbol: "R",
|
|
207
|
+
name: "South African Rand",
|
|
208
|
+
decimals: 2,
|
|
209
|
+
symbolFirst: !0
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
code: "NGN",
|
|
213
|
+
numeric: 566,
|
|
214
|
+
symbol: "₦",
|
|
215
|
+
name: "Nigerian Naira",
|
|
216
|
+
decimals: 2,
|
|
217
|
+
symbolFirst: !0
|
|
218
|
+
},
|
|
219
|
+
{ code: "KES", numeric: 404, symbol: "KSh", name: "Kenyan Shilling", decimals: 2 },
|
|
220
|
+
{ code: "GHS", numeric: 936, symbol: "₵", name: "Ghanaian Cedi", decimals: 2 },
|
|
221
|
+
{ code: "MAD", numeric: 504, symbol: "د.م.", name: "Moroccan Dirham", decimals: 2 },
|
|
222
|
+
{ code: "TND", numeric: 788, symbol: "د.ت", name: "Tunisian Dinar", decimals: 3 },
|
|
223
|
+
// ── Crypto (off-spec; common requests) ─────────
|
|
224
|
+
{ code: "BTC", numeric: 0, symbol: "₿", name: "Bitcoin", decimals: 8, symbolFirst: !0 },
|
|
225
|
+
{ code: "ETH", numeric: 0, symbol: "Ξ", name: "Ether", decimals: 8, symbolFirst: !0 },
|
|
226
|
+
{ code: "USDC", numeric: 0, symbol: "USDC", name: "USD Coin", decimals: 6 },
|
|
227
|
+
{ code: "USDT", numeric: 0, symbol: "USDT", name: "Tether", decimals: 6 }
|
|
228
|
+
], ve = new Map(se.map((r) => [r.code, r]));
|
|
229
|
+
function L(r) {
|
|
230
|
+
return ve.get(r.toUpperCase());
|
|
231
|
+
}
|
|
232
|
+
function fn(r) {
|
|
233
|
+
ve.set(r.code.toUpperCase(), r);
|
|
234
|
+
const e = se.findIndex((n) => n.code === r.code);
|
|
235
|
+
e >= 0 ? se[e] = r : se.push(r);
|
|
236
|
+
}
|
|
237
|
+
function re(r, e) {
|
|
238
|
+
const n = L(e), t = (n == null ? void 0 : n.decimals) ?? 2, c = Math.pow(10, t);
|
|
239
|
+
return { amount: (r < 0 ? -1 : 1) * Math.round(Math.abs(r) * c), currency: e.toUpperCase() };
|
|
240
|
+
}
|
|
241
|
+
function $e(r) {
|
|
242
|
+
const e = L(r.currency), n = (e == null ? void 0 : e.decimals) ?? 2;
|
|
243
|
+
return r.amount / Math.pow(10, n);
|
|
244
|
+
}
|
|
245
|
+
function Le(r, e) {
|
|
246
|
+
return r.currency.toUpperCase() === e.currency.toUpperCase();
|
|
247
|
+
}
|
|
248
|
+
function pe(r, e, n) {
|
|
249
|
+
if (!Le(r, e))
|
|
250
|
+
throw new Error(`Cannot ${n} different currencies: ${r.currency} vs ${e.currency}`);
|
|
251
|
+
}
|
|
252
|
+
function He(r, e) {
|
|
253
|
+
return pe(r, e, "add"), { amount: r.amount + e.amount, currency: r.currency };
|
|
254
|
+
}
|
|
255
|
+
function je(r, e) {
|
|
256
|
+
return pe(r, e, "subtract"), { amount: r.amount - e.amount, currency: r.currency };
|
|
257
|
+
}
|
|
258
|
+
function ze(r, e) {
|
|
259
|
+
return {
|
|
260
|
+
amount: (r.amount * e < 0 ? -1 : 1) * Math.round(Math.abs(r.amount * e)),
|
|
261
|
+
currency: r.currency
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
function bn(r, e) {
|
|
265
|
+
return pe(r, e, "compare"), r.amount - e.amount;
|
|
266
|
+
}
|
|
267
|
+
function _n(r) {
|
|
268
|
+
return r.amount === 0;
|
|
269
|
+
}
|
|
270
|
+
function Nn(r) {
|
|
271
|
+
return r.amount < 0;
|
|
272
|
+
}
|
|
273
|
+
function gn(r) {
|
|
274
|
+
return { amount: -r.amount, currency: r.currency };
|
|
275
|
+
}
|
|
276
|
+
function ee(r, e = {}) {
|
|
277
|
+
const n = L(r.currency), t = e.decimals ?? (n == null ? void 0 : n.decimals) ?? 2, c = r.amount / Math.pow(10, t);
|
|
278
|
+
try {
|
|
279
|
+
return new Intl.NumberFormat(e.locale, {
|
|
280
|
+
style: "currency",
|
|
281
|
+
currency: r.currency,
|
|
282
|
+
minimumFractionDigits: t,
|
|
283
|
+
maximumFractionDigits: t,
|
|
284
|
+
currencyDisplay: e.currencyDisplay ?? "symbol"
|
|
285
|
+
}).format(c);
|
|
286
|
+
} catch {
|
|
287
|
+
const a = (n == null ? void 0 : n.symbol) ?? r.currency, o = c.toFixed(t);
|
|
288
|
+
return n != null && n.symbolFirst ? `${a}${o}` : `${o} ${a}`;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
function Ye(r, e) {
|
|
292
|
+
if (!r)
|
|
293
|
+
return null;
|
|
294
|
+
let n = r.replace(/[^\d.,\-]/g, "").trim();
|
|
295
|
+
if (!n || n === "-")
|
|
296
|
+
return null;
|
|
297
|
+
const t = n.startsWith("-");
|
|
298
|
+
t && (n = n.slice(1));
|
|
299
|
+
const c = n.lastIndexOf("."), a = n.lastIndexOf(","), o = Math.max(c, a);
|
|
300
|
+
let u, l = "";
|
|
301
|
+
o === -1 ? u = n : (u = n.slice(0, o).replace(/[.,]/g, ""), l = n.slice(o + 1).replace(/[.,]/g, ""));
|
|
302
|
+
const s = `${u}.${l || "0"}`, y = parseFloat(s);
|
|
303
|
+
return Number.isFinite(y) ? re(t ? -y : y, e) : null;
|
|
304
|
+
}
|
|
305
|
+
function de(r) {
|
|
306
|
+
const e = (r || "").replace(/\D/g, "");
|
|
307
|
+
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";
|
|
308
|
+
}
|
|
309
|
+
function Se(r) {
|
|
310
|
+
const e = (r || "").replace(/\D/g, "");
|
|
311
|
+
if (e.length < 12 || e.length > 19)
|
|
312
|
+
return !1;
|
|
313
|
+
let n = 0, t = !1;
|
|
314
|
+
for (let c = e.length - 1; c >= 0; c--) {
|
|
315
|
+
let a = e.charCodeAt(c) - 48;
|
|
316
|
+
t && (a *= 2, a > 9 && (a -= 9)), n += a, t = !t;
|
|
317
|
+
}
|
|
318
|
+
return n % 10 === 0;
|
|
319
|
+
}
|
|
320
|
+
function Ge(r, e) {
|
|
321
|
+
const n = (r || "").replace(/\D/g, ""), t = e ?? de(n);
|
|
322
|
+
return t === "amex" ? [n.slice(0, 4), n.slice(4, 10), n.slice(10, 15)].filter(Boolean).join(" ") : t === "diners" ? [n.slice(0, 4), n.slice(4, 10), n.slice(10, 14)].filter(Boolean).join(" ") : (n.match(/.{1,4}/g) ?? []).join(" ").trim();
|
|
323
|
+
}
|
|
324
|
+
function wn(r, e) {
|
|
325
|
+
const n = (r || "").replace(/\D/g, "");
|
|
326
|
+
if (n.length < 4)
|
|
327
|
+
return n;
|
|
328
|
+
const t = n.slice(-4), c = "*".repeat(n.length - 4) + t, a = e ?? de(n);
|
|
329
|
+
return a === "amex" ? [c.slice(0, 4), c.slice(4, 10), c.slice(10, 15)].filter(Boolean).join(" ") : a === "diners" ? [c.slice(0, 4), c.slice(4, 10), c.slice(10, 14)].filter(Boolean).join(" ") : (c.match(/.{1,4}/g) ?? []).join(" ").trim();
|
|
330
|
+
}
|
|
331
|
+
function Ue(r) {
|
|
332
|
+
const e = (r || "").replace(/\D/g, "");
|
|
333
|
+
if (e.length < 3)
|
|
334
|
+
return null;
|
|
335
|
+
const n = e.slice(0, 2), t = e.length >= 4 ? e.slice(-2) : e.slice(2, 4), c = parseInt(n, 10);
|
|
336
|
+
return !Number.isFinite(c) || c < 1 || c > 12 ? null : `${n}/${t}`;
|
|
337
|
+
}
|
|
338
|
+
function xe(r, e = /* @__PURE__ */ new Date()) {
|
|
339
|
+
const n = Ue(r);
|
|
340
|
+
if (!n)
|
|
341
|
+
return !1;
|
|
342
|
+
const [t, c] = n.split("/"), a = parseInt(t, 10), o = 2e3 + parseInt(c, 10);
|
|
343
|
+
return new Date(o, a, 0, 23, 59, 59, 999).getTime() >= e.getTime();
|
|
344
|
+
}
|
|
345
|
+
function ie(r) {
|
|
346
|
+
return r === "amex" ? 4 : 3;
|
|
347
|
+
}
|
|
348
|
+
function we(r, e = {}) {
|
|
349
|
+
var s;
|
|
350
|
+
const n = {}, t = de(r.number), c = Se(r.number);
|
|
351
|
+
c || (n.number = "Invalid card number");
|
|
352
|
+
const a = xe(r.expiry, e.now);
|
|
353
|
+
a || (n.expiry = "Invalid or expired");
|
|
354
|
+
const u = (r.cvc || "").replace(/\D/g, "").length === ie(t);
|
|
355
|
+
u || (n.cvc = `CVC must be ${ie(t)} digits`);
|
|
356
|
+
const l = !e.requireHolder || (((s = r.holderName) == null ? void 0 : s.trim().length) ?? 0) >= 2;
|
|
357
|
+
return l || (n.holderName = "Cardholder name required"), {
|
|
358
|
+
brand: t,
|
|
359
|
+
numberValid: c,
|
|
360
|
+
expiryValid: a,
|
|
361
|
+
cvcValid: u,
|
|
362
|
+
holderValid: l,
|
|
363
|
+
isValid: c && a && u && l,
|
|
364
|
+
errors: n
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
class Dn {
|
|
368
|
+
constructor(e) {
|
|
369
|
+
T(this, "id", "static");
|
|
370
|
+
this.rates = e;
|
|
371
|
+
}
|
|
372
|
+
async getRate(e, n) {
|
|
373
|
+
const t = e.toUpperCase(), c = n.toUpperCase();
|
|
374
|
+
if (t === c)
|
|
375
|
+
return { base: t, quote: c, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
|
|
376
|
+
const a = this.rates.find((s) => s.base === t && s.quote === c);
|
|
377
|
+
if (a)
|
|
378
|
+
return a;
|
|
379
|
+
const o = this.rates.find((s) => s.base === c && s.quote === t);
|
|
380
|
+
if (o)
|
|
381
|
+
return { base: t, quote: c, rate: 1 / o.rate, asOf: o.asOf };
|
|
382
|
+
const u = this.rates.find((s) => s.base === t && s.quote === "USD") ?? this.rates.find((s) => s.base === "USD" && s.quote === t), l = this.rates.find((s) => s.base === "USD" && s.quote === c) ?? this.rates.find((s) => s.base === c && s.quote === "USD");
|
|
383
|
+
if (u && l) {
|
|
384
|
+
const s = u.base === "USD" ? 1 / u.rate : u.rate, y = l.base === "USD" ? l.rate : 1 / l.rate;
|
|
385
|
+
return {
|
|
386
|
+
base: t,
|
|
387
|
+
quote: c,
|
|
388
|
+
rate: s * y,
|
|
389
|
+
asOf: (/* @__PURE__ */ new Date()).toISOString()
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
throw new Error(`No FX rate for ${t}/${c}`);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
class he {
|
|
396
|
+
constructor(e = {}) {
|
|
397
|
+
T(this, "cache", /* @__PURE__ */ new Map());
|
|
398
|
+
T(this, "fetchImpl");
|
|
399
|
+
T(this, "ttl");
|
|
400
|
+
this.fetchImpl = e.fetchImpl ?? fetch, this.ttl = e.cacheTtl ?? 6e4;
|
|
401
|
+
}
|
|
402
|
+
cacheKey(e, n) {
|
|
403
|
+
return `${this.id}:${e.toUpperCase()}/${n.toUpperCase()}`;
|
|
404
|
+
}
|
|
405
|
+
getCached(e, n) {
|
|
406
|
+
const t = this.cacheKey(e, n), c = this.cache.get(t);
|
|
407
|
+
return c && c.expires > Date.now() ? c.rate : (c && this.cache.delete(t), null);
|
|
408
|
+
}
|
|
409
|
+
setCached(e) {
|
|
410
|
+
this.cache.set(this.cacheKey(e.base, e.quote), {
|
|
411
|
+
expires: Date.now() + this.ttl,
|
|
412
|
+
rate: e
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
class Cn extends he {
|
|
417
|
+
constructor(n = {}) {
|
|
418
|
+
super(n);
|
|
419
|
+
T(this, "id", "frankfurter");
|
|
420
|
+
}
|
|
421
|
+
async getRate(n, t) {
|
|
422
|
+
const c = n.toUpperCase(), a = t.toUpperCase();
|
|
423
|
+
if (c === a)
|
|
424
|
+
return { base: c, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
|
|
425
|
+
const o = this.getCached(c, a);
|
|
426
|
+
if (o)
|
|
427
|
+
return o;
|
|
428
|
+
const u = `https://api.frankfurter.app/latest?from=${c}&to=${a}`, l = await this.fetchImpl(u);
|
|
429
|
+
if (!l.ok)
|
|
430
|
+
throw new Error(`Frankfurter HTTP ${l.status}`);
|
|
431
|
+
const s = await l.json(), y = s.rates[a];
|
|
432
|
+
if (y == null)
|
|
433
|
+
throw new Error(`Frankfurter: no rate for ${c}/${a}`);
|
|
434
|
+
const h = { base: c, quote: a, rate: y, asOf: s.date };
|
|
435
|
+
return this.setCached(h), h;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
class vn extends he {
|
|
439
|
+
constructor(n, t = {}) {
|
|
440
|
+
super(t);
|
|
441
|
+
T(this, "id", "openexchangerates");
|
|
442
|
+
this.appId = n;
|
|
443
|
+
}
|
|
444
|
+
async getRate(n, t) {
|
|
445
|
+
const c = n.toUpperCase(), a = t.toUpperCase();
|
|
446
|
+
if (c === a)
|
|
447
|
+
return { base: c, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
|
|
448
|
+
const o = this.getCached(c, a);
|
|
449
|
+
if (o)
|
|
450
|
+
return o;
|
|
451
|
+
const u = `https://openexchangerates.org/api/latest.json?app_id=${this.appId}`, l = await this.fetchImpl(u);
|
|
452
|
+
if (!l.ok)
|
|
453
|
+
throw new Error(`OpenExchangeRates HTTP ${l.status}`);
|
|
454
|
+
const s = await l.json(), y = s.rates[c], h = s.rates[a];
|
|
455
|
+
if (y == null || h == null)
|
|
456
|
+
throw new Error(`OpenExchangeRates: missing rate for ${c} or ${a}`);
|
|
457
|
+
const m = {
|
|
458
|
+
base: c,
|
|
459
|
+
quote: a,
|
|
460
|
+
rate: h / y,
|
|
461
|
+
asOf: new Date(s.timestamp * 1e3).toISOString()
|
|
462
|
+
};
|
|
463
|
+
return this.setCached(m), m;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
class $n extends he {
|
|
467
|
+
constructor(n = {}) {
|
|
468
|
+
super(n);
|
|
469
|
+
T(this, "id", "exchangerate.host");
|
|
470
|
+
}
|
|
471
|
+
async getRate(n, t) {
|
|
472
|
+
var m;
|
|
473
|
+
const c = n.toUpperCase(), a = t.toUpperCase();
|
|
474
|
+
if (c === a)
|
|
475
|
+
return { base: c, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
|
|
476
|
+
const o = this.getCached(c, a);
|
|
477
|
+
if (o)
|
|
478
|
+
return o;
|
|
479
|
+
const u = `https://api.exchangerate.host/convert?from=${c}&to=${a}`, l = await this.fetchImpl(u);
|
|
480
|
+
if (!l.ok)
|
|
481
|
+
throw new Error(`exchangerate.host HTTP ${l.status}`);
|
|
482
|
+
const s = await l.json(), y = ((m = s.info) == null ? void 0 : m.rate) ?? s.result, h = { base: c, quote: a, rate: y, asOf: s.date };
|
|
483
|
+
return this.setCached(h), h;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
async function Ve(r, e, n) {
|
|
487
|
+
const t = e.toUpperCase();
|
|
488
|
+
if (r.currency.toUpperCase() === t)
|
|
489
|
+
return r;
|
|
490
|
+
const c = L(r.currency), a = L(t), o = (c == null ? void 0 : c.decimals) ?? 2, u = (a == null ? void 0 : a.decimals) ?? 2, { rate: l } = await n.getRate(r.currency, t), y = r.amount / Math.pow(10, o) * l;
|
|
491
|
+
return {
|
|
492
|
+
currency: t,
|
|
493
|
+
amount: Math.round(y * Math.pow(10, u))
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
class Ze {
|
|
497
|
+
constructor(e = {}) {
|
|
498
|
+
T(this, "id");
|
|
499
|
+
T(this, "name");
|
|
500
|
+
T(this, "supportedCurrencies");
|
|
501
|
+
T(this, "minimums");
|
|
502
|
+
T(this, "counter", 0);
|
|
503
|
+
this.id = e.id ?? "mock", this.name = e.name ?? "Mock Processor", this.supportedCurrencies = e.supportedCurrencies ?? "*";
|
|
504
|
+
}
|
|
505
|
+
newId(e) {
|
|
506
|
+
return this.counter += 1, `${e}_${Date.now().toString(36)}_${this.counter}`;
|
|
507
|
+
}
|
|
508
|
+
async authorize(e) {
|
|
509
|
+
return {
|
|
510
|
+
id: this.newId("auth"),
|
|
511
|
+
status: "authorized",
|
|
512
|
+
processor: this.id,
|
|
513
|
+
amount: e.amount,
|
|
514
|
+
raw: { mock: !0, request: e }
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
async capture(e, n) {
|
|
518
|
+
return {
|
|
519
|
+
id: e.replace("auth_", "cap_"),
|
|
520
|
+
status: "captured",
|
|
521
|
+
processor: this.id,
|
|
522
|
+
amount: n
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
async cancel(e) {
|
|
526
|
+
return { id: e, status: "cancelled", processor: this.id };
|
|
527
|
+
}
|
|
528
|
+
async refund(e, n) {
|
|
529
|
+
return {
|
|
530
|
+
id: e.replace(/^[a-z]+_/, "ref_"),
|
|
531
|
+
status: "refunded",
|
|
532
|
+
processor: this.id,
|
|
533
|
+
amount: n
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
function G(r, e, n, t, c) {
|
|
538
|
+
const a = (o) => {
|
|
539
|
+
const u = t == null ? void 0 : t[o];
|
|
540
|
+
return u || (async () => {
|
|
541
|
+
throw new Error(
|
|
542
|
+
`[ui-money] ${e} adapter is not wired. Pass an \`executor.${String(o)}\` implementation that calls the ${e} SDK.`
|
|
543
|
+
);
|
|
544
|
+
});
|
|
545
|
+
};
|
|
546
|
+
return {
|
|
547
|
+
id: r,
|
|
548
|
+
name: e,
|
|
549
|
+
supportedCurrencies: n,
|
|
550
|
+
minimums: c,
|
|
551
|
+
authorize: a("authorize"),
|
|
552
|
+
capture: a("capture"),
|
|
553
|
+
cancel: a("cancel"),
|
|
554
|
+
refund: a("refund")
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
function Je(r) {
|
|
558
|
+
return G("stripe", "Stripe", "*", r, {
|
|
559
|
+
USD: 50,
|
|
560
|
+
EUR: 50,
|
|
561
|
+
GBP: 30,
|
|
562
|
+
JPY: 50,
|
|
563
|
+
AUD: 50,
|
|
564
|
+
CAD: 50,
|
|
565
|
+
CHF: 50,
|
|
566
|
+
DKK: 250,
|
|
567
|
+
NOK: 300,
|
|
568
|
+
SEK: 300,
|
|
569
|
+
PLN: 200
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
function Qe(r) {
|
|
573
|
+
return G(
|
|
574
|
+
"paypal",
|
|
575
|
+
"PayPal",
|
|
576
|
+
[
|
|
577
|
+
"USD",
|
|
578
|
+
"EUR",
|
|
579
|
+
"GBP",
|
|
580
|
+
"AUD",
|
|
581
|
+
"CAD",
|
|
582
|
+
"JPY",
|
|
583
|
+
"CHF",
|
|
584
|
+
"NZD",
|
|
585
|
+
"SEK",
|
|
586
|
+
"NOK",
|
|
587
|
+
"DKK",
|
|
588
|
+
"PLN",
|
|
589
|
+
"CZK",
|
|
590
|
+
"HUF",
|
|
591
|
+
"BRL",
|
|
592
|
+
"MXN",
|
|
593
|
+
"HKD",
|
|
594
|
+
"SGD",
|
|
595
|
+
"TWD",
|
|
596
|
+
"THB",
|
|
597
|
+
"PHP",
|
|
598
|
+
"ILS"
|
|
599
|
+
],
|
|
600
|
+
r
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
function Xe(r) {
|
|
604
|
+
return G("adyen", "Adyen", "*", r);
|
|
605
|
+
}
|
|
606
|
+
function We(r) {
|
|
607
|
+
return G("square", "Square", ["USD", "CAD", "GBP", "AUD", "JPY", "EUR"], r);
|
|
608
|
+
}
|
|
609
|
+
function en(r) {
|
|
610
|
+
return G("mollie", "Mollie", "*", r);
|
|
611
|
+
}
|
|
612
|
+
function nn(r) {
|
|
613
|
+
return G("braintree", "Braintree", "*", r);
|
|
614
|
+
}
|
|
615
|
+
function rn(r) {
|
|
616
|
+
return G("razorpay", "Razorpay", ["INR", "USD", "EUR", "GBP", "AED"], r);
|
|
617
|
+
}
|
|
618
|
+
function tn(r) {
|
|
619
|
+
return G(
|
|
620
|
+
"payu",
|
|
621
|
+
"PayU",
|
|
622
|
+
["PLN", "EUR", "USD", "CZK", "HUF", "RON", "BGN", "TRY"],
|
|
623
|
+
r
|
|
624
|
+
);
|
|
625
|
+
}
|
|
626
|
+
function cn(r) {
|
|
627
|
+
return G("przelewy24", "Przelewy24", ["PLN", "EUR"], r);
|
|
628
|
+
}
|
|
629
|
+
function an(r) {
|
|
630
|
+
return G(
|
|
631
|
+
"klarna",
|
|
632
|
+
"Klarna",
|
|
633
|
+
["USD", "EUR", "GBP", "SEK", "NOK", "DKK", "CHF", "AUD", "CAD", "NZD", "PLN"],
|
|
634
|
+
r
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
function sn(r) {
|
|
638
|
+
return G(
|
|
639
|
+
"coinbase-commerce",
|
|
640
|
+
"Coinbase Commerce",
|
|
641
|
+
["BTC", "ETH", "USDC", "USDT", "USD", "EUR"],
|
|
642
|
+
r
|
|
643
|
+
);
|
|
644
|
+
}
|
|
645
|
+
const Sn = {
|
|
646
|
+
mock: () => new Ze(),
|
|
647
|
+
stripe: () => Je(),
|
|
648
|
+
paypal: () => Qe(),
|
|
649
|
+
adyen: () => Xe(),
|
|
650
|
+
square: () => We(),
|
|
651
|
+
mollie: () => en(),
|
|
652
|
+
braintree: () => nn(),
|
|
653
|
+
razorpay: () => rn(),
|
|
654
|
+
payu: () => tn(),
|
|
655
|
+
przelewy24: () => cn(),
|
|
656
|
+
klarna: () => an(),
|
|
657
|
+
"coinbase-commerce": () => sn()
|
|
658
|
+
};
|
|
659
|
+
function Un(r, e) {
|
|
660
|
+
const n = P(
|
|
661
|
+
() => "amount" in r ? r : re(
|
|
662
|
+
r.major,
|
|
663
|
+
r.currency
|
|
664
|
+
),
|
|
665
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
666
|
+
[]
|
|
667
|
+
), [t, c] = E(n), a = R(
|
|
668
|
+
(m) => c((d) => re(m, d.currency)),
|
|
669
|
+
[]
|
|
670
|
+
), o = R((m) => {
|
|
671
|
+
c((d) => ({ ...d, currency: m.toUpperCase() }));
|
|
672
|
+
}, []), u = R((m) => c((d) => He(d, m)), []), l = R(
|
|
673
|
+
(m) => c((d) => je(d, m)),
|
|
674
|
+
[]
|
|
675
|
+
), s = R(
|
|
676
|
+
(m) => c((d) => ze(d, m)),
|
|
677
|
+
[]
|
|
678
|
+
), y = P(() => ee(t, { locale: e }), [t, e]), h = P(() => $e(t), [t]);
|
|
679
|
+
return { money: t, setMoney: c, setMajor: a, setCurrency: o, add: u, subtract: l, scale: s, formatted: y, major: h };
|
|
680
|
+
}
|
|
681
|
+
function me(r, e, n) {
|
|
682
|
+
const [t, c] = E(null), [a, o] = E(null), [u, l] = E(!1), s = Te(0);
|
|
683
|
+
return qe(() => {
|
|
684
|
+
if (!r) {
|
|
685
|
+
c(null);
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
const y = ++s.current;
|
|
689
|
+
l(!0), o(null), Ve(r, e, n).then((h) => {
|
|
690
|
+
s.current === y && c(h);
|
|
691
|
+
}).catch((h) => {
|
|
692
|
+
s.current === y && (o(h instanceof Error ? h : new Error(String(h))), c(null));
|
|
693
|
+
}).finally(() => {
|
|
694
|
+
s.current === y && l(!1);
|
|
695
|
+
});
|
|
696
|
+
}, [r == null ? void 0 : r.amount, r == null ? void 0 : r.currency, e, n]), { converted: t, loading: u, error: a };
|
|
697
|
+
}
|
|
698
|
+
function on(r) {
|
|
699
|
+
const [e, n] = E("idle"), [t, c] = E(null), [a, o] = E(null), u = R(() => {
|
|
700
|
+
n("idle"), c(null), o(null);
|
|
701
|
+
}, []), l = R(
|
|
702
|
+
async (m) => {
|
|
703
|
+
n("authorizing"), o(null);
|
|
704
|
+
try {
|
|
705
|
+
const d = await r.authorize(m);
|
|
706
|
+
return c(d), n(d.status), d;
|
|
707
|
+
} catch (d) {
|
|
708
|
+
const b = d instanceof Error ? d : new Error(String(d));
|
|
709
|
+
throw o(b), n("failed"), b;
|
|
710
|
+
}
|
|
711
|
+
},
|
|
712
|
+
[r]
|
|
713
|
+
), s = R(
|
|
714
|
+
async (m, d) => {
|
|
715
|
+
const b = m ?? (t == null ? void 0 : t.id);
|
|
716
|
+
if (!b)
|
|
717
|
+
throw new Error("No authorization id to capture");
|
|
718
|
+
n("capturing");
|
|
719
|
+
try {
|
|
720
|
+
const _ = await r.capture(b, d);
|
|
721
|
+
return c(_), n(_.status), _;
|
|
722
|
+
} catch (_) {
|
|
723
|
+
const f = _ instanceof Error ? _ : new Error(String(_));
|
|
724
|
+
throw o(f), n("failed"), f;
|
|
725
|
+
}
|
|
726
|
+
},
|
|
727
|
+
[r, t == null ? void 0 : t.id]
|
|
728
|
+
), y = R(
|
|
729
|
+
async (m) => {
|
|
730
|
+
const d = m ?? (t == null ? void 0 : t.id);
|
|
731
|
+
if (!d)
|
|
732
|
+
throw new Error("No payment id to cancel");
|
|
733
|
+
const b = await r.cancel(d);
|
|
734
|
+
return c(b), n(b.status), b;
|
|
735
|
+
},
|
|
736
|
+
[r, t == null ? void 0 : t.id]
|
|
737
|
+
), h = R(
|
|
738
|
+
async (m, d) => {
|
|
739
|
+
const b = m ?? (t == null ? void 0 : t.id);
|
|
740
|
+
if (!b)
|
|
741
|
+
throw new Error("No payment id to refund");
|
|
742
|
+
const _ = await r.refund(b, d);
|
|
743
|
+
return c(_), n(_.status), _;
|
|
744
|
+
},
|
|
745
|
+
[r, t == null ? void 0 : t.id]
|
|
746
|
+
);
|
|
747
|
+
return { status: e, response: t, error: a, authorize: l, capture: s, cancel: y, refund: h, reset: u };
|
|
748
|
+
}
|
|
749
|
+
const De = te(function({
|
|
750
|
+
value: e,
|
|
751
|
+
amount: n,
|
|
752
|
+
currency: t,
|
|
753
|
+
locale: c,
|
|
754
|
+
display: a = "symbol",
|
|
755
|
+
highlightNegative: o = !0,
|
|
756
|
+
zeroPlaceholder: u,
|
|
757
|
+
convertTo: l,
|
|
758
|
+
exchangeProvider: s,
|
|
759
|
+
className: y,
|
|
760
|
+
style: h,
|
|
761
|
+
"aria-label": m
|
|
762
|
+
}, d) {
|
|
763
|
+
const b = P(() => {
|
|
764
|
+
if (e)
|
|
765
|
+
return e;
|
|
766
|
+
if (n != null && t) {
|
|
767
|
+
const I = L(t), F = (I == null ? void 0 : I.decimals) ?? 2;
|
|
768
|
+
return {
|
|
769
|
+
amount: Math.round(n * Math.pow(10, F)),
|
|
770
|
+
currency: t.toUpperCase()
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
return null;
|
|
774
|
+
}, [e, n, t]), _ = P(() => b ? b.amount === 0 && u != null ? u : ee(b, { locale: c, currencyDisplay: a }) : "", [b, c, a, u]), { converted: f } = me(
|
|
775
|
+
l && s ? b : null,
|
|
776
|
+
l ?? "",
|
|
777
|
+
s
|
|
778
|
+
);
|
|
779
|
+
if (!b)
|
|
780
|
+
return null;
|
|
781
|
+
const H = b.amount < 0, j = "nice-money" + (o && H ? " nice-money--negative" : "") + (y ? ` ${y}` : "");
|
|
782
|
+
return /* @__PURE__ */ N("span", { ref: d, className: j, style: h, "aria-label": m, children: [
|
|
783
|
+
/* @__PURE__ */ i("span", { className: "nice-money__value", children: _ }),
|
|
784
|
+
f && /* @__PURE__ */ N("span", { className: "nice-money__converted", "aria-label": `Converted to ${f.currency}`, children: [
|
|
785
|
+
" ≈ ",
|
|
786
|
+
ee(f, { locale: c })
|
|
787
|
+
] })
|
|
788
|
+
] });
|
|
789
|
+
}), xn = se.map((r) => r.code).sort(), Re = te(
|
|
790
|
+
function({
|
|
791
|
+
value: e,
|
|
792
|
+
onChange: n,
|
|
793
|
+
options: t = se,
|
|
794
|
+
recents: c = [],
|
|
795
|
+
searchable: a,
|
|
796
|
+
showCode: o = !0,
|
|
797
|
+
showSymbol: u = !0,
|
|
798
|
+
compact: l = !1,
|
|
799
|
+
disabled: s,
|
|
800
|
+
readOnly: y,
|
|
801
|
+
loading: h,
|
|
802
|
+
accessMode: m,
|
|
803
|
+
label: d,
|
|
804
|
+
helperText: b,
|
|
805
|
+
error: _,
|
|
806
|
+
required: f,
|
|
807
|
+
size: H = "md",
|
|
808
|
+
labelPlacement: j = "top",
|
|
809
|
+
labelWidth: I,
|
|
810
|
+
controlWidth: F,
|
|
811
|
+
className: Q,
|
|
812
|
+
style: X,
|
|
813
|
+
id: A,
|
|
814
|
+
name: M,
|
|
815
|
+
title: ne,
|
|
816
|
+
"data-testid": x,
|
|
817
|
+
"aria-label": V,
|
|
818
|
+
placeholder: O
|
|
819
|
+
}, v) {
|
|
820
|
+
if (m === "hidden")
|
|
821
|
+
return null;
|
|
822
|
+
const q = s || m === "disabled" || h, W = y || m === "readOnly", K = ye(), z = A ?? `nice-cs-${K}`, [Z, Y] = E(""), C = a ?? t.length > 8, D = P(() => {
|
|
823
|
+
if (!Z.trim())
|
|
824
|
+
return t;
|
|
825
|
+
const p = Z.trim().toLowerCase();
|
|
826
|
+
return t.filter(
|
|
827
|
+
(S) => S.code.toLowerCase().includes(p) || S.name.toLowerCase().includes(p) || S.symbol.toLowerCase().includes(p)
|
|
828
|
+
);
|
|
829
|
+
}, [t, Z]), $ = P(() => {
|
|
830
|
+
const p = /* @__PURE__ */ new Set();
|
|
831
|
+
return c.map((S) => L(S)).filter((S) => !!S && !p.has(S.code) && !!p.add(S.code));
|
|
832
|
+
}, [c]), B = R(
|
|
833
|
+
(p) => {
|
|
834
|
+
const S = p.target.value, oe = L(S);
|
|
835
|
+
oe && (n == null || n(S, oe));
|
|
836
|
+
},
|
|
837
|
+
[n]
|
|
838
|
+
), ce = (p) => {
|
|
839
|
+
if (l)
|
|
840
|
+
return `${u ? p.symbol + " " : ""}${p.code}`;
|
|
841
|
+
const S = [];
|
|
842
|
+
return u && S.push(p.symbol), o && S.push(p.code), S.push("—", p.name), S.join(" ");
|
|
843
|
+
}, g = `nice-currency-selector nice-currency-selector--${H} nice-currency-selector--label-${j}` + (l ? " nice-currency-selector--compact" : "") + (_ ? " nice-currency-selector--error" : "") + (q ? " nice-currency-selector--disabled" : "") + (Q ? ` ${Q}` : ""), w = j === "left" && I != null ? { width: typeof I == "number" ? `${I}px` : I, flex: "none" } : void 0, k = F != null ? {
|
|
844
|
+
width: typeof F == "number" ? `${F}px` : F,
|
|
845
|
+
flex: "none"
|
|
846
|
+
} : void 0;
|
|
847
|
+
return /* @__PURE__ */ N("div", { ref: v, className: g, style: X, title: ne, "data-testid": x, children: [
|
|
848
|
+
d && /* @__PURE__ */ N("label", { htmlFor: z, className: "nice-currency-selector__label", style: w, children: [
|
|
849
|
+
d,
|
|
850
|
+
f && /* @__PURE__ */ i("span", { className: "nice-currency-selector__required", "aria-hidden": !0, children: "*" })
|
|
851
|
+
] }),
|
|
852
|
+
/* @__PURE__ */ N("div", { className: "nice-currency-selector__inner", style: k, children: [
|
|
853
|
+
C && /* @__PURE__ */ i(
|
|
854
|
+
"input",
|
|
855
|
+
{
|
|
856
|
+
type: "search",
|
|
857
|
+
className: "nice-currency-selector__search",
|
|
858
|
+
placeholder: "Search currency…",
|
|
859
|
+
value: Z,
|
|
860
|
+
onChange: (p) => Y(p.target.value),
|
|
861
|
+
disabled: q || W,
|
|
862
|
+
"aria-label": "Search currency"
|
|
863
|
+
}
|
|
864
|
+
),
|
|
865
|
+
/* @__PURE__ */ N(
|
|
866
|
+
"select",
|
|
867
|
+
{
|
|
868
|
+
id: z,
|
|
869
|
+
name: M,
|
|
870
|
+
className: "nice-currency-selector__select",
|
|
871
|
+
value: e ?? "",
|
|
872
|
+
onChange: B,
|
|
873
|
+
disabled: q || W,
|
|
874
|
+
required: f,
|
|
875
|
+
"aria-invalid": !!_,
|
|
876
|
+
"aria-label": V ?? (typeof d == "string" ? d : "Currency"),
|
|
877
|
+
children: [
|
|
878
|
+
!e && /* @__PURE__ */ i("option", { value: "", children: O ?? "Select currency…" }),
|
|
879
|
+
$.length > 0 && /* @__PURE__ */ i("optgroup", { label: "Recent", children: $.map((p) => /* @__PURE__ */ i("option", { value: p.code, children: ce(p) }, `r-${p.code}`)) }),
|
|
880
|
+
/* @__PURE__ */ i("optgroup", { label: $.length > 0 ? "All" : "", children: D.map((p) => /* @__PURE__ */ i("option", { value: p.code, children: ce(p) }, p.code)) })
|
|
881
|
+
]
|
|
882
|
+
}
|
|
883
|
+
)
|
|
884
|
+
] }),
|
|
885
|
+
(_ || b) && /* @__PURE__ */ i(
|
|
886
|
+
"span",
|
|
887
|
+
{
|
|
888
|
+
className: _ ? "nice-currency-selector__error" : "nice-currency-selector__helper",
|
|
889
|
+
children: _ ?? b
|
|
890
|
+
}
|
|
891
|
+
)
|
|
892
|
+
] });
|
|
893
|
+
}
|
|
894
|
+
), Me = te(
|
|
895
|
+
function({
|
|
896
|
+
value: e,
|
|
897
|
+
onChange: n,
|
|
898
|
+
currency: t,
|
|
899
|
+
onCurrencyChange: c,
|
|
900
|
+
currencies: a,
|
|
901
|
+
hideCurrencySelector: o,
|
|
902
|
+
min: u,
|
|
903
|
+
max: l,
|
|
904
|
+
step: s,
|
|
905
|
+
locale: y,
|
|
906
|
+
placeholder: h,
|
|
907
|
+
label: m,
|
|
908
|
+
helperText: d,
|
|
909
|
+
error: b,
|
|
910
|
+
size: _ = "md",
|
|
911
|
+
disabled: f,
|
|
912
|
+
readOnly: H,
|
|
913
|
+
required: j,
|
|
914
|
+
loading: I,
|
|
915
|
+
accessMode: F,
|
|
916
|
+
labelPlacement: Q = "top",
|
|
917
|
+
errorPlacement: X = "bottom",
|
|
918
|
+
labelWidth: A,
|
|
919
|
+
controlWidth: M,
|
|
920
|
+
submitOnEnter: ne,
|
|
921
|
+
onSubmit: x,
|
|
922
|
+
showFormattedPreview: V = !0,
|
|
923
|
+
showSteppers: O = !1,
|
|
924
|
+
className: v,
|
|
925
|
+
style: q,
|
|
926
|
+
id: W,
|
|
927
|
+
name: K,
|
|
928
|
+
title: z,
|
|
929
|
+
"data-testid": Z,
|
|
930
|
+
onBlur: Y,
|
|
931
|
+
onFocus: C
|
|
932
|
+
}, D) {
|
|
933
|
+
const $ = f || F === "disabled" || I, B = H || F === "readOnly";
|
|
934
|
+
if (F === "hidden")
|
|
935
|
+
return null;
|
|
936
|
+
const ce = ye(), g = W ?? `nice-money-${ce}`, w = ((e == null ? void 0 : e.currency) ?? t ?? "USD").toUpperCase(), k = L(w), p = (k == null ? void 0 : k.decimals) ?? 2, S = s ?? 1 / Math.pow(10, p), [oe, le] = E(
|
|
937
|
+
() => e ? (e.amount / Math.pow(10, p)).toFixed(p) : ""
|
|
938
|
+
), [fe, be] = E(!1);
|
|
939
|
+
Be.useEffect(() => {
|
|
940
|
+
if (fe)
|
|
941
|
+
return;
|
|
942
|
+
if (e == null) {
|
|
943
|
+
le("");
|
|
944
|
+
return;
|
|
945
|
+
}
|
|
946
|
+
const U = L(e.currency), J = (U == null ? void 0 : U.decimals) ?? 2;
|
|
947
|
+
le((e.amount / Math.pow(10, J)).toFixed(J));
|
|
948
|
+
}, [e, fe]);
|
|
949
|
+
const _e = R(
|
|
950
|
+
(U) => {
|
|
951
|
+
const J = Ye(U, w);
|
|
952
|
+
if (!J) {
|
|
953
|
+
n == null || n(null);
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
const ue = J.amount / Math.pow(10, p);
|
|
957
|
+
if (u != null && ue < u) {
|
|
958
|
+
n == null || n(re(u, w));
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
if (l != null && ue > l) {
|
|
962
|
+
n == null || n(re(l, w));
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
n == null || n(J);
|
|
966
|
+
},
|
|
967
|
+
[w, p, u, l, n]
|
|
968
|
+
), Ee = R(
|
|
969
|
+
(U) => {
|
|
970
|
+
const J = U.target.value;
|
|
971
|
+
le(J), _e(J);
|
|
972
|
+
},
|
|
973
|
+
[_e]
|
|
974
|
+
), Ne = R(
|
|
975
|
+
(U) => {
|
|
976
|
+
const ue = (e ? e.amount / Math.pow(10, p) : 0) + U, Ke = Math.min(l ?? 1 / 0, Math.max(u ?? -1 / 0, ue));
|
|
977
|
+
n == null || n(re(Ke, w));
|
|
978
|
+
},
|
|
979
|
+
[e, p, u, l, w, n]
|
|
980
|
+
), ge = P(() => e ? ee(e, { locale: y }) : "", [e, y]), ae = typeof b == "string" ? b : void 0, Ie = `nice-money-input nice-money-input--${_} nice-money-input--label-${Q} nice-money-input--error-${X}` + (ae ? " nice-money-input--error" : "") + ($ ? " nice-money-input--disabled" : "") + (I ? " nice-money-input--loading" : "") + (v ? ` ${v}` : ""), Fe = (U) => {
|
|
981
|
+
ne && U.key === "Enter" && x && (U.preventDefault(), x());
|
|
982
|
+
}, Pe = Q === "left" && A != null ? { width: typeof A == "number" ? `${A}px` : A, flex: "none" } : void 0, Ae = M != null ? {
|
|
983
|
+
width: typeof M == "number" ? `${M}px` : M,
|
|
984
|
+
flex: "none"
|
|
985
|
+
} : void 0;
|
|
986
|
+
return /* @__PURE__ */ N("div", { ref: D, className: Ie, style: q, title: z, "data-testid": Z, children: [
|
|
987
|
+
m && /* @__PURE__ */ N("label", { htmlFor: g, className: "nice-money-input__label", style: Pe, children: [
|
|
988
|
+
m,
|
|
989
|
+
j && /* @__PURE__ */ i("span", { className: "nice-money-input__required", "aria-hidden": !0, children: "*" })
|
|
990
|
+
] }),
|
|
991
|
+
/* @__PURE__ */ N("div", { className: "nice-money-input__row", style: Ae, children: [
|
|
992
|
+
!o && /* @__PURE__ */ i(
|
|
993
|
+
Re,
|
|
994
|
+
{
|
|
995
|
+
value: w,
|
|
996
|
+
compact: !0,
|
|
997
|
+
options: a ? a.map(L).filter((U) => !!U) : void 0,
|
|
998
|
+
onChange: (U) => c == null ? void 0 : c(U),
|
|
999
|
+
disabled: $ || B,
|
|
1000
|
+
className: "nice-money-input__currency",
|
|
1001
|
+
"aria-label": "Currency"
|
|
1002
|
+
}
|
|
1003
|
+
),
|
|
1004
|
+
o && /* @__PURE__ */ i("span", { className: "nice-money-input__symbol", "aria-hidden": !0, children: (k == null ? void 0 : k.symbol) ?? w }),
|
|
1005
|
+
O && /* @__PURE__ */ i(
|
|
1006
|
+
"button",
|
|
1007
|
+
{
|
|
1008
|
+
type: "button",
|
|
1009
|
+
className: "nice-money-input__step nice-money-input__step--down",
|
|
1010
|
+
onClick: () => Ne(-S),
|
|
1011
|
+
disabled: $ || B || u != null && e != null && e.amount / Math.pow(10, p) <= u,
|
|
1012
|
+
"aria-label": "Decrease amount",
|
|
1013
|
+
tabIndex: -1,
|
|
1014
|
+
children: "−"
|
|
1015
|
+
}
|
|
1016
|
+
),
|
|
1017
|
+
/* @__PURE__ */ i(
|
|
1018
|
+
"input",
|
|
1019
|
+
{
|
|
1020
|
+
id: g,
|
|
1021
|
+
name: K,
|
|
1022
|
+
type: "text",
|
|
1023
|
+
inputMode: "decimal",
|
|
1024
|
+
autoComplete: "transaction-amount",
|
|
1025
|
+
className: "nice-money-input__amount",
|
|
1026
|
+
value: oe,
|
|
1027
|
+
onChange: Ee,
|
|
1028
|
+
onKeyDown: Fe,
|
|
1029
|
+
onFocus: (U) => {
|
|
1030
|
+
be(!0), C == null || C(U);
|
|
1031
|
+
},
|
|
1032
|
+
onBlur: (U) => {
|
|
1033
|
+
be(!1), e && le((e.amount / Math.pow(10, p)).toFixed(p)), Y == null || Y(U);
|
|
1034
|
+
},
|
|
1035
|
+
placeholder: h ?? `0${p > 0 ? "." + "0".repeat(p) : ""}`,
|
|
1036
|
+
disabled: $,
|
|
1037
|
+
readOnly: B,
|
|
1038
|
+
required: j,
|
|
1039
|
+
"aria-invalid": !!ae,
|
|
1040
|
+
"aria-describedby": ae || d ? `${g}-help` : void 0
|
|
1041
|
+
}
|
|
1042
|
+
),
|
|
1043
|
+
O && /* @__PURE__ */ i(
|
|
1044
|
+
"button",
|
|
1045
|
+
{
|
|
1046
|
+
type: "button",
|
|
1047
|
+
className: "nice-money-input__step nice-money-input__step--up",
|
|
1048
|
+
onClick: () => Ne(S),
|
|
1049
|
+
disabled: $ || B || l != null && e != null && e.amount / Math.pow(10, p) >= l,
|
|
1050
|
+
"aria-label": "Increase amount",
|
|
1051
|
+
tabIndex: -1,
|
|
1052
|
+
children: "+"
|
|
1053
|
+
}
|
|
1054
|
+
),
|
|
1055
|
+
I && /* @__PURE__ */ i("span", { className: "nice-money-input__spinner", "aria-hidden": !0, children: "⟳" })
|
|
1056
|
+
] }),
|
|
1057
|
+
V && ge && /* @__PURE__ */ i("span", { className: "nice-money-input__preview", "aria-live": "polite", children: ge }),
|
|
1058
|
+
(ae || d) && /* @__PURE__ */ i(
|
|
1059
|
+
"span",
|
|
1060
|
+
{
|
|
1061
|
+
id: `${g}-help`,
|
|
1062
|
+
className: ae ? "nice-money-input__error" : "nice-money-input__helper",
|
|
1063
|
+
children: ae ?? d
|
|
1064
|
+
}
|
|
1065
|
+
)
|
|
1066
|
+
] });
|
|
1067
|
+
}
|
|
1068
|
+
), ln = { number: "", expiry: "", cvc: "" }, un = te(
|
|
1069
|
+
function({
|
|
1070
|
+
value: e = ln,
|
|
1071
|
+
onChange: n,
|
|
1072
|
+
showHolderName: t = !0,
|
|
1073
|
+
requireHolderName: c,
|
|
1074
|
+
showPostalCode: a = !1,
|
|
1075
|
+
acceptedBrands: o,
|
|
1076
|
+
showBrandIcon: u = !0,
|
|
1077
|
+
size: l = "md",
|
|
1078
|
+
disabled: s,
|
|
1079
|
+
readOnly: y,
|
|
1080
|
+
loading: h,
|
|
1081
|
+
accessMode: m,
|
|
1082
|
+
label: d,
|
|
1083
|
+
helperText: b,
|
|
1084
|
+
error: _,
|
|
1085
|
+
required: f,
|
|
1086
|
+
className: H,
|
|
1087
|
+
style: j,
|
|
1088
|
+
id: I,
|
|
1089
|
+
title: F,
|
|
1090
|
+
"data-testid": Q
|
|
1091
|
+
}, X) {
|
|
1092
|
+
if (m === "hidden")
|
|
1093
|
+
return null;
|
|
1094
|
+
const A = s || m === "disabled" || h, M = y || m === "readOnly", ne = ye(), x = I ?? `nice-cc-${ne}`, [V, O] = E({
|
|
1095
|
+
number: !1,
|
|
1096
|
+
expiry: !1,
|
|
1097
|
+
cvc: !1,
|
|
1098
|
+
holder: !1,
|
|
1099
|
+
postal: !1
|
|
1100
|
+
}), v = P(() => de(e.number), [e.number]), q = P(
|
|
1101
|
+
() => we(e, { requireHolder: c ?? t }),
|
|
1102
|
+
[e, c, t]
|
|
1103
|
+
), W = !o || o.includes(v) || v === "unknown", K = R(
|
|
1104
|
+
(g) => {
|
|
1105
|
+
const w = { ...e, ...g }, k = we(w, { requireHolder: c ?? t });
|
|
1106
|
+
n == null || n(w, k);
|
|
1107
|
+
},
|
|
1108
|
+
[e, c, t, n]
|
|
1109
|
+
), z = R(
|
|
1110
|
+
(g) => {
|
|
1111
|
+
const w = g.target.value.replace(/\D/g, "").slice(0, 19);
|
|
1112
|
+
K({ number: w });
|
|
1113
|
+
},
|
|
1114
|
+
[K]
|
|
1115
|
+
), Z = R(
|
|
1116
|
+
(g) => {
|
|
1117
|
+
const w = g.target.value.replace(/\D/g, "").slice(0, 4);
|
|
1118
|
+
let k = w;
|
|
1119
|
+
w.length >= 3 ? k = `${w.slice(0, 2)}/${w.slice(2)}` : w.length === 2 && (k = `${w}/`), K({ expiry: k });
|
|
1120
|
+
},
|
|
1121
|
+
[K]
|
|
1122
|
+
), Y = R(
|
|
1123
|
+
(g) => {
|
|
1124
|
+
const w = g.target.value.replace(/\D/g, "").slice(0, ie(v));
|
|
1125
|
+
K({ cvc: w });
|
|
1126
|
+
},
|
|
1127
|
+
[v, K]
|
|
1128
|
+
), C = P(() => Ge(e.number, v), [e.number, v]), D = V.number && e.number.length > 0 && (Se(e.number) ? W ? void 0 : "Card brand not accepted" : q.errors.number), $ = V.expiry && e.expiry.length > 0 && !xe(e.expiry) ? q.errors.expiry : void 0, B = V.cvc && e.cvc.length > 0 && e.cvc.length !== ie(v) ? q.errors.cvc : void 0, ce = `nice-credit-card nice-credit-card--${l}` + (A ? " nice-credit-card--disabled" : "") + (h ? " nice-credit-card--loading" : "") + (_ ? " nice-credit-card--error" : "") + (H ? ` ${H}` : "");
|
|
1129
|
+
return /* @__PURE__ */ N("div", { ref: X, className: ce, style: j, title: F, "data-testid": Q, children: [
|
|
1130
|
+
d && /* @__PURE__ */ N("div", { className: "nice-credit-card__title", children: [
|
|
1131
|
+
d,
|
|
1132
|
+
f && /* @__PURE__ */ i("span", { className: "nice-credit-card__required", "aria-hidden": !0, children: "*" })
|
|
1133
|
+
] }),
|
|
1134
|
+
/* @__PURE__ */ i("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ N("label", { className: "nice-credit-card__field nice-credit-card__field--number", children: [
|
|
1135
|
+
/* @__PURE__ */ i("span", { className: "nice-credit-card__label", children: "Card number" }),
|
|
1136
|
+
/* @__PURE__ */ N("span", { className: "nice-credit-card__input-wrapper", children: [
|
|
1137
|
+
/* @__PURE__ */ i(
|
|
1138
|
+
"input",
|
|
1139
|
+
{
|
|
1140
|
+
id: `${x}-number`,
|
|
1141
|
+
type: "text",
|
|
1142
|
+
inputMode: "numeric",
|
|
1143
|
+
autoComplete: "cc-number",
|
|
1144
|
+
placeholder: v === "amex" ? "3782 822463 10005" : "1234 1234 1234 1234",
|
|
1145
|
+
value: C,
|
|
1146
|
+
onChange: z,
|
|
1147
|
+
onBlur: () => O((g) => ({ ...g, number: !0 })),
|
|
1148
|
+
disabled: A,
|
|
1149
|
+
readOnly: M,
|
|
1150
|
+
"aria-invalid": !!D,
|
|
1151
|
+
"aria-describedby": D ? `${x}-number-err` : void 0,
|
|
1152
|
+
className: "nice-credit-card__input",
|
|
1153
|
+
maxLength: v === "amex" ? 17 : 23
|
|
1154
|
+
}
|
|
1155
|
+
),
|
|
1156
|
+
u && /* @__PURE__ */ i(dn, { brand: v })
|
|
1157
|
+
] }),
|
|
1158
|
+
D && /* @__PURE__ */ i("span", { id: `${x}-number-err`, className: "nice-credit-card__error", children: D })
|
|
1159
|
+
] }) }),
|
|
1160
|
+
/* @__PURE__ */ N("div", { className: "nice-credit-card__row nice-credit-card__row--split", children: [
|
|
1161
|
+
/* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
|
|
1162
|
+
/* @__PURE__ */ i("span", { className: "nice-credit-card__label", children: "Expiry" }),
|
|
1163
|
+
/* @__PURE__ */ i(
|
|
1164
|
+
"input",
|
|
1165
|
+
{
|
|
1166
|
+
id: `${x}-expiry`,
|
|
1167
|
+
type: "text",
|
|
1168
|
+
inputMode: "numeric",
|
|
1169
|
+
autoComplete: "cc-exp",
|
|
1170
|
+
placeholder: "MM/YY",
|
|
1171
|
+
value: e.expiry,
|
|
1172
|
+
onChange: Z,
|
|
1173
|
+
onBlur: () => {
|
|
1174
|
+
O((w) => ({ ...w, expiry: !0 }));
|
|
1175
|
+
const g = Ue(e.expiry);
|
|
1176
|
+
g && g !== e.expiry && K({ expiry: g });
|
|
1177
|
+
},
|
|
1178
|
+
disabled: A,
|
|
1179
|
+
readOnly: M,
|
|
1180
|
+
"aria-invalid": !!$,
|
|
1181
|
+
"aria-describedby": $ ? `${x}-expiry-err` : void 0,
|
|
1182
|
+
className: "nice-credit-card__input",
|
|
1183
|
+
maxLength: 5
|
|
1184
|
+
}
|
|
1185
|
+
),
|
|
1186
|
+
$ && /* @__PURE__ */ i("span", { id: `${x}-expiry-err`, className: "nice-credit-card__error", children: $ })
|
|
1187
|
+
] }),
|
|
1188
|
+
/* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
|
|
1189
|
+
/* @__PURE__ */ i("span", { className: "nice-credit-card__label", children: v === "amex" ? "CID" : "CVC" }),
|
|
1190
|
+
/* @__PURE__ */ i(
|
|
1191
|
+
"input",
|
|
1192
|
+
{
|
|
1193
|
+
id: `${x}-cvc`,
|
|
1194
|
+
type: "text",
|
|
1195
|
+
inputMode: "numeric",
|
|
1196
|
+
autoComplete: "cc-csc",
|
|
1197
|
+
placeholder: "•".repeat(ie(v)),
|
|
1198
|
+
value: e.cvc,
|
|
1199
|
+
onChange: Y,
|
|
1200
|
+
onBlur: () => O((g) => ({ ...g, cvc: !0 })),
|
|
1201
|
+
disabled: A,
|
|
1202
|
+
readOnly: M,
|
|
1203
|
+
"aria-invalid": !!B,
|
|
1204
|
+
"aria-describedby": B ? `${x}-cvc-err` : void 0,
|
|
1205
|
+
className: "nice-credit-card__input",
|
|
1206
|
+
maxLength: ie(v)
|
|
1207
|
+
}
|
|
1208
|
+
),
|
|
1209
|
+
B && /* @__PURE__ */ i("span", { id: `${x}-cvc-err`, className: "nice-credit-card__error", children: B })
|
|
1210
|
+
] })
|
|
1211
|
+
] }),
|
|
1212
|
+
t && /* @__PURE__ */ i("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
|
|
1213
|
+
/* @__PURE__ */ i("span", { className: "nice-credit-card__label", children: "Cardholder name" }),
|
|
1214
|
+
/* @__PURE__ */ i(
|
|
1215
|
+
"input",
|
|
1216
|
+
{
|
|
1217
|
+
id: `${x}-holder`,
|
|
1218
|
+
type: "text",
|
|
1219
|
+
autoComplete: "cc-name",
|
|
1220
|
+
placeholder: "Jane Doe",
|
|
1221
|
+
value: e.holderName ?? "",
|
|
1222
|
+
onChange: (g) => K({ holderName: g.target.value }),
|
|
1223
|
+
onBlur: () => O((g) => ({ ...g, holder: !0 })),
|
|
1224
|
+
disabled: A,
|
|
1225
|
+
readOnly: M,
|
|
1226
|
+
className: "nice-credit-card__input",
|
|
1227
|
+
maxLength: 120
|
|
1228
|
+
}
|
|
1229
|
+
)
|
|
1230
|
+
] }) }),
|
|
1231
|
+
a && /* @__PURE__ */ i("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
|
|
1232
|
+
/* @__PURE__ */ i("span", { className: "nice-credit-card__label", children: "Postal code" }),
|
|
1233
|
+
/* @__PURE__ */ i(
|
|
1234
|
+
"input",
|
|
1235
|
+
{
|
|
1236
|
+
id: `${x}-postal`,
|
|
1237
|
+
type: "text",
|
|
1238
|
+
autoComplete: "postal-code",
|
|
1239
|
+
value: e.postalCode ?? "",
|
|
1240
|
+
onChange: (g) => K({ postalCode: g.target.value }),
|
|
1241
|
+
onBlur: () => O((g) => ({ ...g, postal: !0 })),
|
|
1242
|
+
disabled: A,
|
|
1243
|
+
readOnly: M,
|
|
1244
|
+
className: "nice-credit-card__input",
|
|
1245
|
+
maxLength: 16
|
|
1246
|
+
}
|
|
1247
|
+
)
|
|
1248
|
+
] }) }),
|
|
1249
|
+
(_ || b) && /* @__PURE__ */ i(
|
|
1250
|
+
"div",
|
|
1251
|
+
{
|
|
1252
|
+
className: _ ? "nice-credit-card__form-error" : "nice-credit-card__helper",
|
|
1253
|
+
role: _ ? "alert" : void 0,
|
|
1254
|
+
children: _ ?? b
|
|
1255
|
+
}
|
|
1256
|
+
)
|
|
1257
|
+
] });
|
|
1258
|
+
}
|
|
1259
|
+
), Ce = {
|
|
1260
|
+
visa: "VISA",
|
|
1261
|
+
mastercard: "MasterCard",
|
|
1262
|
+
amex: "AMEX",
|
|
1263
|
+
discover: "Discover",
|
|
1264
|
+
diners: "Diners",
|
|
1265
|
+
jcb: "JCB",
|
|
1266
|
+
unionpay: "UnionPay",
|
|
1267
|
+
maestro: "Maestro",
|
|
1268
|
+
mir: "MIR",
|
|
1269
|
+
elo: "Elo",
|
|
1270
|
+
hipercard: "Hipercard",
|
|
1271
|
+
unknown: ""
|
|
1272
|
+
};
|
|
1273
|
+
function dn({ brand: r }) {
|
|
1274
|
+
return r === "unknown" ? null : /* @__PURE__ */ i(
|
|
1275
|
+
"span",
|
|
1276
|
+
{
|
|
1277
|
+
className: `nice-credit-card__brand nice-credit-card__brand--${r}`,
|
|
1278
|
+
"aria-label": Ce[r],
|
|
1279
|
+
children: Ce[r]
|
|
1280
|
+
}
|
|
1281
|
+
);
|
|
1282
|
+
}
|
|
1283
|
+
const Rn = te(
|
|
1284
|
+
function({
|
|
1285
|
+
processor: e,
|
|
1286
|
+
amount: n,
|
|
1287
|
+
editableAmount: t,
|
|
1288
|
+
customer: c,
|
|
1289
|
+
currencies: a,
|
|
1290
|
+
description: o,
|
|
1291
|
+
metadata: u,
|
|
1292
|
+
autoCapture: l = !0,
|
|
1293
|
+
submitLabel: s = "Pay",
|
|
1294
|
+
onSuccess: y,
|
|
1295
|
+
onError: h,
|
|
1296
|
+
consents: m,
|
|
1297
|
+
className: d,
|
|
1298
|
+
style: b
|
|
1299
|
+
}, _) {
|
|
1300
|
+
const [f, H] = E(n), [j, I] = E(n.currency), [F, Q] = E({ number: "", expiry: "", cvc: "" }), [X, A] = E(null), [M, ne] = E(!1), [x, V] = E(null), O = on(e), v = P(() => e.supportedCurrencies === "*" ? !0 : e.supportedCurrencies.includes(f.currency.toUpperCase()), [e, f.currency]), q = P(() => {
|
|
1301
|
+
var D;
|
|
1302
|
+
const C = (D = e.minimums) == null ? void 0 : D[f.currency.toUpperCase()];
|
|
1303
|
+
return C == null || f.amount >= C;
|
|
1304
|
+
}, [e, f]), W = P(() => {
|
|
1305
|
+
var D;
|
|
1306
|
+
const C = (D = e.minimums) == null ? void 0 : D[f.currency.toUpperCase()];
|
|
1307
|
+
return C == null ? null : { amount: C, currency: f.currency };
|
|
1308
|
+
}, [e, f.currency]), K = !!(X != null && X.isValid), z = !M && v && q && K, Z = R(
|
|
1309
|
+
async (C) => {
|
|
1310
|
+
if (C.preventDefault(), !!z) {
|
|
1311
|
+
V(null), ne(!0);
|
|
1312
|
+
try {
|
|
1313
|
+
const D = {
|
|
1314
|
+
amount: f,
|
|
1315
|
+
card: F,
|
|
1316
|
+
customer: c,
|
|
1317
|
+
description: o,
|
|
1318
|
+
metadata: u,
|
|
1319
|
+
idempotencyKey: mn()
|
|
1320
|
+
}, $ = await O.authorize(D);
|
|
1321
|
+
if (l && $.status === "authorized") {
|
|
1322
|
+
const B = await O.capture($.id, f);
|
|
1323
|
+
y == null || y(B);
|
|
1324
|
+
} else
|
|
1325
|
+
y == null || y($);
|
|
1326
|
+
} catch (D) {
|
|
1327
|
+
const $ = D instanceof Error ? D : new Error(String(D));
|
|
1328
|
+
V($.message), h == null || h($);
|
|
1329
|
+
} finally {
|
|
1330
|
+
ne(!1);
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
},
|
|
1334
|
+
[
|
|
1335
|
+
z,
|
|
1336
|
+
f,
|
|
1337
|
+
F,
|
|
1338
|
+
c,
|
|
1339
|
+
o,
|
|
1340
|
+
u,
|
|
1341
|
+
l,
|
|
1342
|
+
O,
|
|
1343
|
+
y,
|
|
1344
|
+
h
|
|
1345
|
+
]
|
|
1346
|
+
), Y = L(f.currency);
|
|
1347
|
+
return /* @__PURE__ */ N(
|
|
1348
|
+
"form",
|
|
1349
|
+
{
|
|
1350
|
+
ref: _,
|
|
1351
|
+
className: "nice-payment-form" + (d ? ` ${d}` : ""),
|
|
1352
|
+
style: b,
|
|
1353
|
+
onSubmit: Z,
|
|
1354
|
+
"aria-busy": M,
|
|
1355
|
+
children: [
|
|
1356
|
+
/* @__PURE__ */ i("div", { className: "nice-payment-form__amount", children: t ? /* @__PURE__ */ i(
|
|
1357
|
+
Me,
|
|
1358
|
+
{
|
|
1359
|
+
label: "Amount",
|
|
1360
|
+
value: f,
|
|
1361
|
+
currency: j,
|
|
1362
|
+
currencies: a,
|
|
1363
|
+
onChange: (C) => C && H(C),
|
|
1364
|
+
onCurrencyChange: (C) => {
|
|
1365
|
+
I(C), H((D) => ({ ...D, currency: C }));
|
|
1366
|
+
},
|
|
1367
|
+
disabled: M,
|
|
1368
|
+
required: !0,
|
|
1369
|
+
showFormattedPreview: !0
|
|
1370
|
+
}
|
|
1371
|
+
) : /* @__PURE__ */ N("div", { className: "nice-payment-form__total", children: [
|
|
1372
|
+
/* @__PURE__ */ i("span", { className: "nice-payment-form__total-label", children: "Total" }),
|
|
1373
|
+
/* @__PURE__ */ i(De, { value: f })
|
|
1374
|
+
] }) }),
|
|
1375
|
+
o && /* @__PURE__ */ i("p", { className: "nice-payment-form__description", children: o }),
|
|
1376
|
+
/* @__PURE__ */ i("div", { className: "nice-payment-form__card", children: /* @__PURE__ */ i(
|
|
1377
|
+
un,
|
|
1378
|
+
{
|
|
1379
|
+
value: F,
|
|
1380
|
+
onChange: (C, D) => {
|
|
1381
|
+
Q(C), A(D);
|
|
1382
|
+
},
|
|
1383
|
+
disabled: M
|
|
1384
|
+
}
|
|
1385
|
+
) }),
|
|
1386
|
+
!v && /* @__PURE__ */ N("div", { className: "nice-payment-form__warning", role: "alert", children: [
|
|
1387
|
+
e.name,
|
|
1388
|
+
" does not accept ",
|
|
1389
|
+
(Y == null ? void 0 : Y.name) ?? f.currency,
|
|
1390
|
+
"."
|
|
1391
|
+
] }),
|
|
1392
|
+
!q && W && /* @__PURE__ */ N("div", { className: "nice-payment-form__warning", role: "alert", children: [
|
|
1393
|
+
"Minimum charge for ",
|
|
1394
|
+
e.name,
|
|
1395
|
+
" is ",
|
|
1396
|
+
/* @__PURE__ */ i(De, { value: W }),
|
|
1397
|
+
"."
|
|
1398
|
+
] }),
|
|
1399
|
+
m && /* @__PURE__ */ i("div", { className: "nice-payment-form__consents", children: m }),
|
|
1400
|
+
x && /* @__PURE__ */ i("div", { className: "nice-payment-form__error", role: "alert", children: x }),
|
|
1401
|
+
/* @__PURE__ */ i(
|
|
1402
|
+
"button",
|
|
1403
|
+
{
|
|
1404
|
+
type: "submit",
|
|
1405
|
+
className: "nice-payment-form__submit",
|
|
1406
|
+
disabled: !z,
|
|
1407
|
+
"aria-disabled": !z,
|
|
1408
|
+
children: M ? "Processing…" : s
|
|
1409
|
+
}
|
|
1410
|
+
),
|
|
1411
|
+
/* @__PURE__ */ N("p", { className: "nice-payment-form__processor", children: [
|
|
1412
|
+
"Secured by ",
|
|
1413
|
+
/* @__PURE__ */ i("strong", { children: e.name })
|
|
1414
|
+
] })
|
|
1415
|
+
]
|
|
1416
|
+
}
|
|
1417
|
+
);
|
|
1418
|
+
}
|
|
1419
|
+
);
|
|
1420
|
+
function mn() {
|
|
1421
|
+
return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `idem_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`;
|
|
1422
|
+
}
|
|
1423
|
+
const Mn = te(function({
|
|
1424
|
+
price: e,
|
|
1425
|
+
originalPrice: n,
|
|
1426
|
+
period: t,
|
|
1427
|
+
prefix: c,
|
|
1428
|
+
suffix: a,
|
|
1429
|
+
showDiscountBadge: o = !0,
|
|
1430
|
+
size: u = "md",
|
|
1431
|
+
locale: l,
|
|
1432
|
+
className: s,
|
|
1433
|
+
style: y
|
|
1434
|
+
}, h) {
|
|
1435
|
+
const m = n && n.currency === e.currency && n.amount > e.amount, d = P(() => !m || !n ? null : Math.round((n.amount - e.amount) / n.amount * 100), [m, n, e.amount]), b = `nice-price-tag nice-price-tag--${u}` + (s ? ` ${s}` : "");
|
|
1436
|
+
return /* @__PURE__ */ N("div", { ref: h, className: b, style: y, children: [
|
|
1437
|
+
c && /* @__PURE__ */ i("span", { className: "nice-price-tag__prefix", children: c }),
|
|
1438
|
+
/* @__PURE__ */ N("span", { className: "nice-price-tag__main", children: [
|
|
1439
|
+
/* @__PURE__ */ i("span", { className: "nice-price-tag__amount", children: ee(e, { locale: l }) }),
|
|
1440
|
+
t && /* @__PURE__ */ i("span", { className: "nice-price-tag__period", children: t })
|
|
1441
|
+
] }),
|
|
1442
|
+
m && n && /* @__PURE__ */ i("span", { className: "nice-price-tag__original", "aria-label": "Original price", children: /* @__PURE__ */ i("s", { children: ee(n, { locale: l }) }) }),
|
|
1443
|
+
m && o && d != null && d > 0 && /* @__PURE__ */ N("span", { className: "nice-price-tag__discount", "aria-label": `${d} percent off`, children: [
|
|
1444
|
+
"−",
|
|
1445
|
+
d,
|
|
1446
|
+
"%"
|
|
1447
|
+
] }),
|
|
1448
|
+
a && /* @__PURE__ */ i("span", { className: "nice-price-tag__suffix", children: a })
|
|
1449
|
+
] });
|
|
1450
|
+
}), En = te(
|
|
1451
|
+
function({
|
|
1452
|
+
source: e,
|
|
1453
|
+
onSourceChange: n,
|
|
1454
|
+
targetCurrency: t,
|
|
1455
|
+
onTargetCurrencyChange: c,
|
|
1456
|
+
provider: a,
|
|
1457
|
+
locale: o,
|
|
1458
|
+
showRateLine: u = !0,
|
|
1459
|
+
className: l,
|
|
1460
|
+
style: s
|
|
1461
|
+
}, y) {
|
|
1462
|
+
const { converted: h, loading: m, error: d } = me(e, t, a), b = P(
|
|
1463
|
+
() => ({ amount: Math.pow(10, 2), currency: e.currency }),
|
|
1464
|
+
[e.currency]
|
|
1465
|
+
), { converted: _ } = me(
|
|
1466
|
+
u ? b : null,
|
|
1467
|
+
t,
|
|
1468
|
+
a
|
|
1469
|
+
);
|
|
1470
|
+
return /* @__PURE__ */ N(
|
|
1471
|
+
"div",
|
|
1472
|
+
{
|
|
1473
|
+
ref: y,
|
|
1474
|
+
className: "nice-currency-converter" + (l ? ` ${l}` : ""),
|
|
1475
|
+
style: s,
|
|
1476
|
+
children: [
|
|
1477
|
+
/* @__PURE__ */ i("div", { className: "nice-currency-converter__row", children: /* @__PURE__ */ i(
|
|
1478
|
+
Me,
|
|
1479
|
+
{
|
|
1480
|
+
label: "From",
|
|
1481
|
+
value: e,
|
|
1482
|
+
onChange: (f) => f && n(f),
|
|
1483
|
+
currency: e.currency,
|
|
1484
|
+
onCurrencyChange: (f) => n({ ...e, currency: f }),
|
|
1485
|
+
showFormattedPreview: !1
|
|
1486
|
+
}
|
|
1487
|
+
) }),
|
|
1488
|
+
/* @__PURE__ */ N("div", { className: "nice-currency-converter__row", children: [
|
|
1489
|
+
/* @__PURE__ */ i("label", { className: "nice-currency-converter__label", children: "To" }),
|
|
1490
|
+
/* @__PURE__ */ N("div", { className: "nice-currency-converter__output", children: [
|
|
1491
|
+
/* @__PURE__ */ i(
|
|
1492
|
+
Re,
|
|
1493
|
+
{
|
|
1494
|
+
value: t,
|
|
1495
|
+
onChange: (f) => c(f),
|
|
1496
|
+
compact: !0
|
|
1497
|
+
}
|
|
1498
|
+
),
|
|
1499
|
+
/* @__PURE__ */ i("span", { className: "nice-currency-converter__amount", children: m ? "…" : d ? "—" : h ? ee(h, { locale: o }) : "" })
|
|
1500
|
+
] })
|
|
1501
|
+
] }),
|
|
1502
|
+
u && _ && /* @__PURE__ */ N("p", { className: "nice-currency-converter__rate", children: [
|
|
1503
|
+
"1 ",
|
|
1504
|
+
e.currency,
|
|
1505
|
+
" = ",
|
|
1506
|
+
ee(_, { locale: o }),
|
|
1507
|
+
" ",
|
|
1508
|
+
/* @__PURE__ */ N("span", { className: "nice-currency-converter__inverse", children: [
|
|
1509
|
+
"· 1 ",
|
|
1510
|
+
t,
|
|
1511
|
+
" =",
|
|
1512
|
+
" ",
|
|
1513
|
+
ee(re(1 / $e(_), e.currency), { locale: o })
|
|
1514
|
+
] })
|
|
1515
|
+
] }),
|
|
1516
|
+
d && /* @__PURE__ */ i("p", { className: "nice-currency-converter__error", role: "alert", children: d.message })
|
|
1517
|
+
]
|
|
1518
|
+
}
|
|
1519
|
+
);
|
|
1520
|
+
}
|
|
1521
|
+
);
|
|
1522
|
+
export {
|
|
1523
|
+
$n as ExchangeRateHostProvider,
|
|
1524
|
+
Cn as FrankfurterProvider,
|
|
1525
|
+
Ze as MockPaymentProcessor,
|
|
1526
|
+
se as NICE_CURRENCY_CATALOG,
|
|
1527
|
+
xn as NICE_CURRENCY_CODES,
|
|
1528
|
+
Sn as NICE_PAYMENT_PROCESSORS,
|
|
1529
|
+
un as NiceCreditCardInput,
|
|
1530
|
+
En as NiceCurrencyConverter,
|
|
1531
|
+
Re as NiceCurrencySelector,
|
|
1532
|
+
De as NiceMoney,
|
|
1533
|
+
Me as NiceMoneyInput,
|
|
1534
|
+
Rn as NicePaymentForm,
|
|
1535
|
+
Mn as NicePriceTag,
|
|
1536
|
+
vn as OpenExchangeRatesProvider,
|
|
1537
|
+
Dn as StaticExchangeRateProvider,
|
|
1538
|
+
He as addMoney,
|
|
1539
|
+
bn as compareMoney,
|
|
1540
|
+
Ve as convertMoney,
|
|
1541
|
+
de as detectCardBrand,
|
|
1542
|
+
ie as expectedCvcLength,
|
|
1543
|
+
L as findCurrency,
|
|
1544
|
+
Ge as formatCardNumber,
|
|
1545
|
+
ee as formatMoney,
|
|
1546
|
+
$e as fromMoney,
|
|
1547
|
+
xe as isExpiryValid,
|
|
1548
|
+
Nn as isNegative,
|
|
1549
|
+
_n as isZero,
|
|
1550
|
+
Se as luhnCheck,
|
|
1551
|
+
Xe as makeAdyenAdapter,
|
|
1552
|
+
nn as makeBraintreeAdapter,
|
|
1553
|
+
sn as makeCoinbaseCommerceAdapter,
|
|
1554
|
+
an as makeKlarnaAdapter,
|
|
1555
|
+
en as makeMollieAdapter,
|
|
1556
|
+
Qe as makePayPalAdapter,
|
|
1557
|
+
tn as makePayUAdapter,
|
|
1558
|
+
cn as makePrzelewy24Adapter,
|
|
1559
|
+
rn as makeRazorpayAdapter,
|
|
1560
|
+
We as makeSquareAdapter,
|
|
1561
|
+
Je as makeStripeAdapter,
|
|
1562
|
+
wn as maskCardNumber,
|
|
1563
|
+
ze as multiplyMoney,
|
|
1564
|
+
gn as negateMoney,
|
|
1565
|
+
Ue as normaliseExpiry,
|
|
1566
|
+
Ye as parseMoney,
|
|
1567
|
+
fn as registerCurrency,
|
|
1568
|
+
je as subtractMoney,
|
|
1569
|
+
re as toMoney,
|
|
1570
|
+
me as useNiceExchangeRate,
|
|
1571
|
+
Un as useNiceMoney,
|
|
1572
|
+
on as useNicePayment,
|
|
1573
|
+
we as validateCreditCard
|
|
1574
|
+
};
|