@blocklet/payment-react 1.14.21 → 1.14.22
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/es/checkout/donate.d.ts +2 -1
- package/es/checkout/donate.js +9 -10
- package/es/checkout/form.d.ts +1 -1
- package/es/checkout/form.js +23 -1
- package/es/checkout/table.d.ts +1 -1
- package/es/checkout/table.js +8 -1
- package/es/components/blockchain/tx.js +2 -1
- package/es/components/country-select.d.ts +16 -0
- package/es/components/country-select.js +82 -0
- package/es/components/input.d.ts +21 -21
- package/es/components/input.js +43 -42
- package/es/components/livemode.js +1 -0
- package/es/components/pricing-table.js +0 -2
- package/es/components/status.js +2 -3
- package/es/components/table.d.ts +2 -0
- package/es/components/table.js +186 -0
- package/es/contexts/payment.d.ts +2 -0
- package/es/contexts/payment.js +5 -2
- package/es/history/invoice/list.d.ts +3 -1
- package/es/history/invoice/list.js +215 -48
- package/es/hooks/mobile.d.ts +4 -0
- package/es/hooks/mobile.js +10 -0
- package/es/index.d.ts +5 -1
- package/es/index.js +7 -1
- package/es/libs/util.d.ts +15 -2
- package/es/libs/util.js +92 -28
- package/es/locales/en.js +22 -7
- package/es/locales/index.d.ts +0 -1
- package/es/locales/index.js +10 -1
- package/es/locales/zh.js +21 -6
- package/es/payment/error.js +2 -2
- package/es/payment/footer.js +1 -1
- package/es/payment/form/address.d.ts +9 -2
- package/es/payment/form/address.js +69 -69
- package/es/payment/form/currency.js +39 -25
- package/es/payment/form/index.d.ts +1 -1
- package/es/payment/form/index.js +83 -81
- package/es/payment/form/phone.js +15 -51
- package/es/payment/index.d.ts +1 -10
- package/es/payment/index.js +274 -219
- package/es/payment/product-card.js +4 -4
- package/es/payment/product-donation.js +7 -2
- package/es/payment/product-item.d.ts +2 -2
- package/es/payment/product-item.js +120 -81
- package/es/payment/summary.js +188 -118
- package/es/theme/index.css +240 -0
- package/es/theme/index.d.ts +9 -0
- package/es/theme/index.js +243 -0
- package/es/theme/typography.d.ts +2 -0
- package/es/theme/typography.js +53 -0
- package/es/types/index.d.ts +11 -0
- package/lib/checkout/donate.d.ts +2 -1
- package/lib/checkout/donate.js +14 -2
- package/lib/checkout/form.d.ts +1 -1
- package/lib/checkout/form.js +22 -1
- package/lib/checkout/table.d.ts +1 -1
- package/lib/checkout/table.js +14 -1
- package/lib/components/blockchain/tx.js +4 -1
- package/lib/components/country-select.d.ts +16 -0
- package/lib/components/country-select.js +115 -0
- package/lib/components/input.d.ts +21 -21
- package/lib/components/input.js +21 -12
- package/lib/components/livemode.js +1 -0
- package/lib/components/pricing-table.js +0 -2
- package/lib/components/status.js +2 -3
- package/lib/components/table.d.ts +2 -0
- package/lib/components/table.js +220 -0
- package/lib/contexts/payment.d.ts +2 -0
- package/lib/contexts/payment.js +4 -1
- package/lib/history/invoice/list.d.ts +3 -1
- package/lib/history/invoice/list.js +290 -62
- package/lib/hooks/mobile.d.ts +4 -0
- package/lib/hooks/mobile.js +17 -0
- package/lib/index.d.ts +5 -1
- package/lib/index.js +36 -0
- package/lib/libs/util.d.ts +15 -2
- package/lib/libs/util.js +115 -37
- package/lib/locales/en.js +22 -7
- package/lib/locales/index.d.ts +0 -1
- package/lib/locales/index.js +14 -3
- package/lib/locales/zh.js +21 -6
- package/lib/payment/error.js +5 -1
- package/lib/payment/footer.js +1 -1
- package/lib/payment/form/address.d.ts +9 -2
- package/lib/payment/form/address.js +67 -59
- package/lib/payment/form/currency.js +31 -24
- package/lib/payment/form/index.d.ts +1 -1
- package/lib/payment/form/index.js +92 -93
- package/lib/payment/form/phone.js +11 -59
- package/lib/payment/index.d.ts +1 -10
- package/lib/payment/index.js +291 -219
- package/lib/payment/product-card.js +5 -4
- package/lib/payment/product-donation.js +9 -2
- package/lib/payment/product-item.d.ts +2 -2
- package/lib/payment/product-item.js +38 -19
- package/lib/payment/summary.js +219 -127
- package/lib/theme/index.css +240 -0
- package/lib/theme/index.d.ts +9 -0
- package/lib/theme/index.js +259 -0
- package/lib/theme/typography.d.ts +2 -0
- package/lib/theme/typography.js +59 -0
- package/lib/types/index.d.ts +11 -0
- package/package.json +14 -11
- package/src/checkout/donate.tsx +16 -10
- package/src/checkout/form.tsx +23 -0
- package/src/checkout/table.tsx +13 -1
- package/src/components/blockchain/tx.tsx +2 -1
- package/src/components/country-select.tsx +93 -0
- package/src/components/input.tsx +49 -46
- package/src/components/livemode.tsx +1 -0
- package/src/components/pricing-table.tsx +0 -2
- package/src/components/status.tsx +1 -2
- package/src/components/table.tsx +200 -0
- package/src/contexts/payment.tsx +6 -1
- package/src/history/invoice/list.tsx +254 -49
- package/src/hooks/mobile.ts +13 -0
- package/src/index.ts +7 -0
- package/src/libs/util.ts +120 -31
- package/src/locales/en.tsx +18 -4
- package/src/locales/index.tsx +10 -3
- package/src/locales/zh.tsx +17 -3
- package/src/payment/error.tsx +2 -2
- package/src/payment/footer.tsx +1 -1
- package/src/payment/form/address.tsx +56 -47
- package/src/payment/form/currency.tsx +29 -23
- package/src/payment/form/index.tsx +89 -76
- package/src/payment/form/phone.tsx +14 -51
- package/src/payment/index.tsx +294 -242
- package/src/payment/product-card.tsx +4 -4
- package/src/payment/product-donation.tsx +7 -3
- package/src/payment/product-item.tsx +49 -20
- package/src/payment/summary.tsx +191 -108
- package/src/theme/index.css +240 -0
- package/src/theme/index.tsx +250 -0
- package/src/theme/typography.ts +56 -0
- package/src/types/index.ts +12 -0
package/es/locales/en.js
CHANGED
|
@@ -60,7 +60,7 @@ export default flat({
|
|
|
60
60
|
continue: "Continue",
|
|
61
61
|
qty: "Qty {count}",
|
|
62
62
|
each: "{unit} each",
|
|
63
|
-
trial: "Free for {count}
|
|
63
|
+
trial: "Free for {count} day{count > 1 ? 's' : ''}",
|
|
64
64
|
billed: "billed {rule}",
|
|
65
65
|
metered: "based on usage",
|
|
66
66
|
hour: "hour",
|
|
@@ -109,10 +109,12 @@ export default flat({
|
|
|
109
109
|
subscription: "View subscription",
|
|
110
110
|
invoice: "View invoice"
|
|
111
111
|
},
|
|
112
|
+
paymentRequired: "Payment Required",
|
|
112
113
|
staking: {
|
|
113
114
|
title: "Staking Required",
|
|
114
115
|
tooltip: "Staking is used to ensure that future invoices can be paid normally. Revoking the staking from DID Wallet means canceling the subscription."
|
|
115
116
|
},
|
|
117
|
+
stakingConfirm: "In this payment, the staked amount is separate from the product cost.",
|
|
116
118
|
donation: {
|
|
117
119
|
between: "Please enter an amount between {min} and {max}.",
|
|
118
120
|
custom: "Custom Amount",
|
|
@@ -129,7 +131,9 @@ export default flat({
|
|
|
129
131
|
sub1: "Subscribe to {name}",
|
|
130
132
|
sub2: "Subscribe to {name} and {count} more",
|
|
131
133
|
then: "Then {subscription} {recurring}",
|
|
132
|
-
|
|
134
|
+
meteredThen: "Then {recurring} based on usage",
|
|
135
|
+
metered: "{recurring} based on usage",
|
|
136
|
+
free: "{count} day{count > 1 ? 's' : ''} free",
|
|
133
137
|
least: "continue with at least",
|
|
134
138
|
completed: {
|
|
135
139
|
payment: "Thanks for your purchase",
|
|
@@ -138,7 +142,7 @@ export default flat({
|
|
|
138
142
|
donate: "Thanks for your support",
|
|
139
143
|
tip: "A payment to {payee} has been completed. You can view the details of this payment in your account."
|
|
140
144
|
},
|
|
141
|
-
confirm: "
|
|
145
|
+
confirm: "Confirming allows {payee} to charge or reduce your staking. You can cancel or revoke staking anytime.",
|
|
142
146
|
required: "Required",
|
|
143
147
|
invalid: "Invalid",
|
|
144
148
|
billing: {
|
|
@@ -178,13 +182,17 @@ export default flat({
|
|
|
178
182
|
emptyItems: {
|
|
179
183
|
title: "Nothing to show here",
|
|
180
184
|
description: "Seems this checkoutSession is not configured properly"
|
|
181
|
-
}
|
|
185
|
+
},
|
|
186
|
+
orderSummary: "Order Summary",
|
|
187
|
+
paymentDetails: "Payment Details",
|
|
188
|
+
productListTotal: "Includes {total} items"
|
|
182
189
|
},
|
|
183
190
|
customer: {
|
|
184
191
|
payments: "Payment History",
|
|
185
192
|
invoices: "Invoice History",
|
|
186
193
|
details: "Details",
|
|
187
194
|
summary: "Summary",
|
|
195
|
+
specifics: "Specifics",
|
|
188
196
|
update: "Update Information",
|
|
189
197
|
empty: "Seems you do not have any subscriptions or payments here",
|
|
190
198
|
cancel: {
|
|
@@ -259,13 +267,17 @@ export default flat({
|
|
|
259
267
|
renewSuccess: "You have successfully renewed the subscription",
|
|
260
268
|
renewError: "Failed to renew the subscription",
|
|
261
269
|
empty: "There are no invoices",
|
|
262
|
-
next: "No invoices yet, next invoice will be generated on {date}"
|
|
270
|
+
next: "No invoices yet, next invoice will be generated on {date}",
|
|
271
|
+
invoiceNumber: "Invoice Number",
|
|
272
|
+
emptyList: "No Invoice"
|
|
263
273
|
},
|
|
264
274
|
payment: {
|
|
265
|
-
empty: "There are no payments"
|
|
275
|
+
empty: "There are no payments",
|
|
276
|
+
emptyList: "No Payment"
|
|
266
277
|
},
|
|
267
278
|
refund: {
|
|
268
|
-
empty: "There are no refunds"
|
|
279
|
+
empty: "There are no refunds",
|
|
280
|
+
emptyList: "No Refund"
|
|
269
281
|
},
|
|
270
282
|
subscriptions: {
|
|
271
283
|
plan: "Plan",
|
|
@@ -298,5 +310,8 @@ export default flat({
|
|
|
298
310
|
[RefundType.refund]: "Refund",
|
|
299
311
|
[RefundType.stakeReturn]: "Stake Return"
|
|
300
312
|
}
|
|
313
|
+
},
|
|
314
|
+
empty: {
|
|
315
|
+
records: "No matching records found"
|
|
301
316
|
}
|
|
302
317
|
});
|
package/es/locales/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ export declare const translations: {
|
|
|
2
2
|
zh: any;
|
|
3
3
|
en: any;
|
|
4
4
|
};
|
|
5
|
-
export declare const replace: (template: string, data?: Record<string, any>) => string;
|
|
6
5
|
export declare const createTranslator: ({ fallbackLocale }: {
|
|
7
6
|
fallbackLocale?: string | undefined;
|
|
8
7
|
}, langs?: any) => (key: string, locale?: string, data?: Record<string, any>) => string;
|
package/es/locales/index.js
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
import { template } from "lodash";
|
|
1
2
|
import en from "./en.js";
|
|
2
3
|
import zh from "./zh.js";
|
|
3
4
|
export const translations = {
|
|
4
5
|
zh,
|
|
5
6
|
en
|
|
6
7
|
};
|
|
7
|
-
|
|
8
|
+
const replace = (t2, data = {}) => {
|
|
9
|
+
try {
|
|
10
|
+
const compiled = template(t2, { interpolate: /{([\s\S]+?)}/g, escape: /{([\s\S]+?)}/g });
|
|
11
|
+
return compiled(data);
|
|
12
|
+
} catch (e) {
|
|
13
|
+
console.error(`Error evaluating template: ${t2}`, e);
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
16
|
+
};
|
|
8
17
|
export const createTranslator = ({ fallbackLocale = "en" }, langs = translations) => {
|
|
9
18
|
return (key, locale = fallbackLocale, data = {}) => {
|
|
10
19
|
if (!langs[locale] || !langs[locale][key]) {
|
package/es/locales/zh.js
CHANGED
|
@@ -109,10 +109,12 @@ export default flat({
|
|
|
109
109
|
subscription: "\u67E5\u770B\u8BA2\u9605",
|
|
110
110
|
invoice: "\u67E5\u770B\u8D26\u5355"
|
|
111
111
|
},
|
|
112
|
+
paymentRequired: "\u652F\u4ED8\u6570\u91CF",
|
|
112
113
|
staking: {
|
|
113
114
|
title: "\u8D28\u62BC\u6570\u91CF",
|
|
114
115
|
tooltip: "\u8D28\u62BC\u76F8\u5F53\u4E8E\u4FDD\u8BC1\u91D1\uFF0C\u7528\u4E8E\u786E\u4FDD\u672A\u6765\u7684\u8D26\u5355\u80FD\u591F\u6B63\u5E38\u6263\u6B3E\uFF0C\u5982\u679C\u4F60\u4ECE DID Wallet \u64A4\u9500\u8D28\u62BC\uFF0C\u8BA2\u9605\u4E5F\u4F1A\u88AB\u53D6\u6D88\u3002"
|
|
115
116
|
},
|
|
117
|
+
stakingConfirm: "\u5728\u6B64\u652F\u4ED8\u4E2D\uFF0C\u8D28\u62BC\u91D1\u989D\u4E0E\u4EA7\u54C1\u8D39\u7528\u5206\u5F00",
|
|
116
118
|
donation: {
|
|
117
119
|
between: "\u91D1\u989D\u5FC5\u987B\u5927\u4E8E {min} \u4E14\u5C0F\u4E8E {max}",
|
|
118
120
|
custom: "\u8F93\u5165\u91D1\u989D",
|
|
@@ -129,7 +131,9 @@ export default flat({
|
|
|
129
131
|
sub1: "\u8BA2\u9605 {name}",
|
|
130
132
|
sub2: "\u8BA2\u9605 {name} \u7B49{count}\u4E2A\u4EA7\u54C1",
|
|
131
133
|
then: "\u7136\u540E {subscription} {recurring}",
|
|
132
|
-
|
|
134
|
+
meteredThen: "\u7136\u540E{recurring}\u6309\u7528\u91CF\u8BA1\u8D39",
|
|
135
|
+
metered: "{recurring}\u6309\u7528\u91CF\u8BA1\u8D39",
|
|
136
|
+
free: "\u514D\u8D39\u8BD5\u7528 {count} \u5929",
|
|
133
137
|
least: "\u81F3\u5C11",
|
|
134
138
|
completed: {
|
|
135
139
|
payment: "\u611F\u8C22\u60A8\u7684\u8D2D\u4E70",
|
|
@@ -138,7 +142,7 @@ export default flat({
|
|
|
138
142
|
donate: "\u611F\u8C22\u60A8\u7684\u652F\u6301",
|
|
139
143
|
tip: "\u5411{payee}\u7684\u4ED8\u6B3E\u5DF2\u5B8C\u6210\u3002\u60A8\u53EF\u4EE5\u5728\u60A8\u7684\u8D26\u6237\u4E2D\u67E5\u770B\u6B64\u4ED8\u6B3E\u7684\u8BE6\u7EC6\u4FE1\u606F\u3002"
|
|
140
144
|
},
|
|
141
|
-
confirm: "\
|
|
145
|
+
confirm: "\u786E\u8BA4\u5141\u8BB8{payee}\u5BF9\u60A8\u7684\u8D26\u6237\u8FDB\u884C\u4ED8\u6B3E\u6216\u8005\u7F5A\u6CA1\u60A8\u7684\u8D28\u62BC\u3002\u60A8\u968F\u65F6\u53EF\u4EE5\u53D6\u6D88\u60A8\u7684\u8BA2\u9605\uFF0C\u6216\u8005\u64A4\u9500\u8D28\u62BC\u3002",
|
|
142
146
|
required: "\u5FC5\u586B\u9879",
|
|
143
147
|
invalid: "\u65E0\u6548",
|
|
144
148
|
billing: {
|
|
@@ -178,13 +182,17 @@ export default flat({
|
|
|
178
182
|
emptyItems: {
|
|
179
183
|
title: "\u6CA1\u6709\u4EFB\u4F55\u8D2D\u4E70\u9879\u76EE",
|
|
180
184
|
description: "\u53EF\u80FD\u8FD9\u4E2A\u4ED8\u6B3E\u94FE\u63A5\u6CA1\u6709\u6B63\u786E\u914D\u7F6E"
|
|
181
|
-
}
|
|
185
|
+
},
|
|
186
|
+
orderSummary: "\u8BA2\u5355\u6982\u89C8",
|
|
187
|
+
paymentDetails: "\u652F\u4ED8\u4FE1\u606F",
|
|
188
|
+
productListTotal: "\u5305\u62EC {total} \u9879"
|
|
182
189
|
},
|
|
183
190
|
customer: {
|
|
184
191
|
payments: "\u652F\u4ED8\u5386\u53F2",
|
|
185
192
|
invoices: "\u8D26\u5355\u5386\u53F2",
|
|
186
193
|
details: "\u8D26\u6237\u8BE6\u60C5",
|
|
187
194
|
summary: "\u8BA1\u8D39\u6458\u8981",
|
|
195
|
+
specifics: "\u5177\u4F53\u4FE1\u606F",
|
|
188
196
|
update: "\u66F4\u65B0\u5BA2\u6237\u4FE1\u606F",
|
|
189
197
|
empty: "\u770B\u8D77\u6765\u60A8\u5728\u8FD9\u91CC\u6CA1\u6709\u4EFB\u4F55\u8BA2\u9605\u6216\u652F\u4ED8",
|
|
190
198
|
cancel: {
|
|
@@ -259,13 +267,17 @@ export default flat({
|
|
|
259
267
|
renewSuccess: "\u8BA2\u9605\u6062\u590D\u6210\u529F",
|
|
260
268
|
renewError: "\u8BA2\u9605\u6062\u590D\u5931\u8D25",
|
|
261
269
|
empty: "\u6CA1\u6709\u4EFB\u4F55\u8D26\u5355",
|
|
262
|
-
next: "\u8FD8\u6CA1\u6709\u8D26\u5355\uFF0C\u4E0B\u6B21\u8D26\u5355\u5C06\u5728 {date} \u751F\u6210"
|
|
270
|
+
next: "\u8FD8\u6CA1\u6709\u8D26\u5355\uFF0C\u4E0B\u6B21\u8D26\u5355\u5C06\u5728 {date} \u751F\u6210",
|
|
271
|
+
invoiceNumber: "\u8D26\u5355\u7F16\u53F7",
|
|
272
|
+
emptyList: "\u6CA1\u6709\u8D26\u5355"
|
|
263
273
|
},
|
|
264
274
|
payment: {
|
|
265
|
-
empty: "\u6CA1\u6709\u652F\u4ED8\u8BB0\u5F55"
|
|
275
|
+
empty: "\u6CA1\u6709\u652F\u4ED8\u8BB0\u5F55",
|
|
276
|
+
emptyList: "\u6CA1\u6709\u652F\u4ED8\u8BB0\u5F55"
|
|
266
277
|
},
|
|
267
278
|
refund: {
|
|
268
|
-
empty: "\u6CA1\u6709\u9000\u6B3E\u8BB0\u5F55"
|
|
279
|
+
empty: "\u6CA1\u6709\u9000\u6B3E\u8BB0\u5F55",
|
|
280
|
+
emptyList: "\u6CA1\u6709\u9000\u6B3E\u8BB0\u5F55"
|
|
269
281
|
},
|
|
270
282
|
subscriptions: {
|
|
271
283
|
plan: "\u8BA2\u9605",
|
|
@@ -298,5 +310,8 @@ export default flat({
|
|
|
298
310
|
[RefundType.refund]: "\u9000\u6B3E",
|
|
299
311
|
[RefundType.stakeReturn]: "\u9000\u62BC\u91D1"
|
|
300
312
|
}
|
|
313
|
+
},
|
|
314
|
+
empty: {
|
|
315
|
+
records: "\u6CA1\u6709\u627E\u5230\u5339\u914D\u7684\u8BB0\u5F55"
|
|
301
316
|
}
|
|
302
317
|
});
|
package/es/payment/error.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Button, Link, Stack, Typography } from "@mui/material";
|
|
|
3
3
|
function getHeightStyle(mode) {
|
|
4
4
|
switch (mode) {
|
|
5
5
|
case "standalone":
|
|
6
|
-
return { height: "100vh" };
|
|
6
|
+
return { height: "100vh", maxHeight: "100%" };
|
|
7
7
|
default:
|
|
8
8
|
return { height: "auto", minHeight: 200 };
|
|
9
9
|
}
|
|
@@ -13,7 +13,7 @@ export default function PaymentError({ title, description, button, mode }) {
|
|
|
13
13
|
return /* @__PURE__ */ jsx(Stack, { sx: heightStyle, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsxs(Stack, { sx: { width: "280px" }, direction: "column", alignItems: "center", justifyContent: "center", children: [
|
|
14
14
|
/* @__PURE__ */ jsx(Typography, { variant: "h5", sx: { mb: 2 }, children: title }),
|
|
15
15
|
/* @__PURE__ */ jsx(Typography, { variant: "body1", sx: { mb: 2, textAlign: "center" }, children: description }),
|
|
16
|
-
/* @__PURE__ */ jsx(Button, { variant: "text", size: "small", component: Link, href: window.blocklet?.appUrl, children: button })
|
|
16
|
+
/* @__PURE__ */ jsx(Button, { variant: "text", size: "small", sx: { color: "text.link" }, component: Link, href: window.blocklet?.appUrl, children: button })
|
|
17
17
|
] }) });
|
|
18
18
|
}
|
|
19
19
|
PaymentError.defaultProps = {
|
package/es/payment/footer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Typography } from "@mui/material";
|
|
3
3
|
export default function CheckoutFooter({ ...props }) {
|
|
4
|
-
return /* @__PURE__ */ jsxs(Typography, { color: "text.
|
|
4
|
+
return /* @__PURE__ */ jsxs(Typography, { color: "text.lighter", fontSize: 12, ...props, children: [
|
|
5
5
|
"Powered by",
|
|
6
6
|
" ",
|
|
7
7
|
/* @__PURE__ */ jsx(Typography, { component: "span", sx: { fontWeight: "bold", fontSize: 12 }, children: "ArcBlock" })
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { SxProps } from '@mui/material';
|
|
2
3
|
type Props = {
|
|
3
4
|
mode: string;
|
|
4
5
|
stripe: boolean;
|
|
6
|
+
sx?: SxProps;
|
|
5
7
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
declare function AddressForm({ mode, stripe, sx }: Props): import("react").JSX.Element | null;
|
|
9
|
+
declare namespace AddressForm {
|
|
10
|
+
var defaultProps: {
|
|
11
|
+
sx: {};
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export default AddressForm;
|
|
@@ -1,49 +1,50 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
3
|
-
import { Fade,
|
|
3
|
+
import { Fade, FormLabel, InputAdornment, Stack } from "@mui/material";
|
|
4
4
|
import { Controller, useFormContext } from "react-hook-form";
|
|
5
|
-
import { CountrySelector } from "react-international-phone";
|
|
6
5
|
import FormInput from "../../components/input.js";
|
|
7
|
-
|
|
6
|
+
import CountrySelect from "../../components/country-select.js";
|
|
7
|
+
AddressForm.defaultProps = {
|
|
8
|
+
sx: {}
|
|
9
|
+
};
|
|
10
|
+
export default function AddressForm({ mode, stripe, sx = {} }) {
|
|
8
11
|
const { t } = useLocaleContext();
|
|
9
|
-
const { control
|
|
12
|
+
const { control } = useFormContext();
|
|
10
13
|
if (mode === "required") {
|
|
11
|
-
return /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { className: "cko-payment-address cko-payment-form", children: [
|
|
12
|
-
/* @__PURE__ */ jsx(
|
|
14
|
+
return /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { className: "cko-payment-address cko-payment-form", sx, children: [
|
|
15
|
+
/* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t(`payment.checkout.billing.${mode}`) }),
|
|
13
16
|
/* @__PURE__ */ jsxs(Stack, { direction: "column", className: "cko-payment-form", spacing: 0, children: [
|
|
14
|
-
/* @__PURE__ */
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
/* @__PURE__ */ jsx(Stack, { direction: "row", spacing: 0, children: /* @__PURE__ */ jsx(
|
|
18
|
+
FormInput,
|
|
19
|
+
{
|
|
20
|
+
name: "billing_address.postal_code",
|
|
21
|
+
rules: { required: t("payment.checkout.required") },
|
|
22
|
+
errorPosition: "right",
|
|
23
|
+
variant: "outlined",
|
|
24
|
+
placeholder: t("payment.checkout.billing.postal_code"),
|
|
25
|
+
InputProps: {
|
|
26
|
+
startAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx(
|
|
27
|
+
Controller,
|
|
22
28
|
{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
name: "billing_address.country",
|
|
30
|
+
control,
|
|
31
|
+
render: ({ field }) => /* @__PURE__ */ jsx(
|
|
32
|
+
CountrySelect,
|
|
33
|
+
{
|
|
34
|
+
...field,
|
|
35
|
+
sx: {
|
|
36
|
+
"&.Mui-focused .MuiOutlinedInput-notchedOutline": {
|
|
37
|
+
borderColor: "transparent"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
)
|
|
32
42
|
}
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
),
|
|
36
|
-
/* @__PURE__ */ jsx(
|
|
37
|
-
FormInput,
|
|
38
|
-
{
|
|
39
|
-
name: "billing_address.postal_code",
|
|
40
|
-
rules: { required: t("payment.checkout.required") },
|
|
41
|
-
errorPosition: "right",
|
|
42
|
-
variant: "outlined",
|
|
43
|
-
placeholder: t("payment.checkout.billing.postal_code")
|
|
43
|
+
) })
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
}
|
|
46
|
+
) }),
|
|
47
|
+
/* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t("payment.checkout.billing.state") }),
|
|
47
48
|
/* @__PURE__ */ jsx(
|
|
48
49
|
FormInput,
|
|
49
50
|
{
|
|
@@ -54,6 +55,7 @@ export default function AddressForm({ mode, stripe }) {
|
|
|
54
55
|
placeholder: t("payment.checkout.billing.state")
|
|
55
56
|
}
|
|
56
57
|
),
|
|
58
|
+
/* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t("payment.checkout.billing.line1") }),
|
|
57
59
|
/* @__PURE__ */ jsx(
|
|
58
60
|
FormInput,
|
|
59
61
|
{
|
|
@@ -64,6 +66,7 @@ export default function AddressForm({ mode, stripe }) {
|
|
|
64
66
|
placeholder: t("payment.checkout.billing.line1")
|
|
65
67
|
}
|
|
66
68
|
),
|
|
69
|
+
/* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t("payment.checkout.billing.city") }),
|
|
67
70
|
/* @__PURE__ */ jsx(
|
|
68
71
|
FormInput,
|
|
69
72
|
{
|
|
@@ -78,42 +81,39 @@ export default function AddressForm({ mode, stripe }) {
|
|
|
78
81
|
] }) });
|
|
79
82
|
}
|
|
80
83
|
if (stripe) {
|
|
81
|
-
return /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { className: "cko-payment-address cko-payment-form", children: [
|
|
82
|
-
/* @__PURE__ */ jsx(
|
|
83
|
-
/* @__PURE__ */ jsx(Stack, { direction: "column", className: "cko-payment-form", spacing: 0, children: /* @__PURE__ */
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
return /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { className: "cko-payment-address cko-payment-form", sx, children: [
|
|
85
|
+
/* @__PURE__ */ jsx(FormLabel, { className: "base-label", children: t(`payment.checkout.billing.${mode}`) }),
|
|
86
|
+
/* @__PURE__ */ jsx(Stack, { direction: "column", className: "cko-payment-form", spacing: 0, children: /* @__PURE__ */ jsx(Stack, { direction: "row", spacing: 0, children: /* @__PURE__ */ jsx(
|
|
87
|
+
FormInput,
|
|
88
|
+
{
|
|
89
|
+
name: "billing_address.postal_code",
|
|
90
|
+
rules: { required: t("payment.checkout.required") },
|
|
91
|
+
errorPosition: "right",
|
|
92
|
+
variant: "outlined",
|
|
93
|
+
placeholder: t("payment.checkout.billing.postal_code"),
|
|
94
|
+
wrapperStyle: { height: "40px" },
|
|
95
|
+
InputProps: {
|
|
96
|
+
startAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx(
|
|
97
|
+
Controller,
|
|
91
98
|
{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
name: "billing_address.country",
|
|
100
|
+
control,
|
|
101
|
+
render: ({ field }) => /* @__PURE__ */ jsx(
|
|
102
|
+
CountrySelect,
|
|
103
|
+
{
|
|
104
|
+
...field,
|
|
105
|
+
sx: {
|
|
106
|
+
"&.Mui-focused .MuiOutlinedInput-notchedOutline": {
|
|
107
|
+
borderColor: "transparent"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
)
|
|
101
112
|
}
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
),
|
|
105
|
-
/* @__PURE__ */ jsx(
|
|
106
|
-
FormInput,
|
|
107
|
-
{
|
|
108
|
-
name: "billing_address.postal_code",
|
|
109
|
-
rules: { required: t("payment.checkout.required") },
|
|
110
|
-
errorPosition: "right",
|
|
111
|
-
variant: "outlined",
|
|
112
|
-
placeholder: t("payment.checkout.billing.postal_code"),
|
|
113
|
-
wrapperStyle: { height: "40px" }
|
|
113
|
+
) })
|
|
114
114
|
}
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
}
|
|
116
|
+
) }) })
|
|
117
117
|
] }) });
|
|
118
118
|
}
|
|
119
119
|
return null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Avatar, Card, Stack, Typography } from "@mui/material";
|
|
2
|
+
import { Avatar, Card, Radio, Stack, Typography } from "@mui/material";
|
|
3
3
|
import { styled } from "@mui/system";
|
|
4
4
|
export default function CurrencySelector({ value, currencies, onChange }) {
|
|
5
5
|
return /* @__PURE__ */ jsx(
|
|
@@ -8,8 +8,9 @@ export default function CurrencySelector({ value, currencies, onChange }) {
|
|
|
8
8
|
count: currencies.length,
|
|
9
9
|
style: {
|
|
10
10
|
display: currencies.length > 1 ? "grid" : "block",
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
width: "100%",
|
|
12
|
+
gap: 12,
|
|
13
|
+
gridTemplateColumns: "repeat(auto-fit, minmax(220px, 1fr))"
|
|
13
14
|
},
|
|
14
15
|
children: currencies.map((x, i) => {
|
|
15
16
|
const selected = i === value;
|
|
@@ -19,12 +20,30 @@ export default function CurrencySelector({ value, currencies, onChange }) {
|
|
|
19
20
|
variant: "outlined",
|
|
20
21
|
onClick: () => onChange(i),
|
|
21
22
|
className: selected ? "cko-payment-card" : "cko-payment-card-unselect",
|
|
22
|
-
children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", children: [
|
|
23
|
-
/* @__PURE__ */ jsx(Avatar, { src: x.logo, alt: x.name, sx: { width:
|
|
23
|
+
children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", sx: { position: "relative" }, children: [
|
|
24
|
+
/* @__PURE__ */ jsx(Avatar, { src: x.logo, alt: x.name, sx: { width: 40, height: 40, marginRight: "12px" } }),
|
|
24
25
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
25
|
-
/* @__PURE__ */ jsx(
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
/* @__PURE__ */ jsx(
|
|
27
|
+
Typography,
|
|
28
|
+
{
|
|
29
|
+
variant: "h5",
|
|
30
|
+
component: "div",
|
|
31
|
+
sx: { fontSize: "16px", color: "text.primary", fontWeight: "500" },
|
|
32
|
+
children: x.symbol
|
|
33
|
+
}
|
|
34
|
+
),
|
|
35
|
+
/* @__PURE__ */ jsx(Typography, { sx: { fontSize: 14 }, color: "text.lighter", gutterBottom: true, children: x.method.name })
|
|
36
|
+
] }),
|
|
37
|
+
/* @__PURE__ */ jsx(
|
|
38
|
+
Radio,
|
|
39
|
+
{
|
|
40
|
+
checked: selected,
|
|
41
|
+
sx: {
|
|
42
|
+
position: "absolute",
|
|
43
|
+
right: 0
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
)
|
|
28
47
|
] })
|
|
29
48
|
},
|
|
30
49
|
x.id
|
|
@@ -36,32 +55,27 @@ export default function CurrencySelector({ value, currencies, onChange }) {
|
|
|
36
55
|
const Root = styled("section")`
|
|
37
56
|
.cko-payment-card {
|
|
38
57
|
position: relative;
|
|
39
|
-
border: 1px solid
|
|
58
|
+
border: 1px solid var(--stroke-border-interactive, #0086ff);
|
|
40
59
|
padding: 4px 8px;
|
|
41
|
-
margin: 8px 0 0;
|
|
42
60
|
cursor: pointer;
|
|
61
|
+
background: var(--backgrounds-bg-field, #f9fafb);
|
|
43
62
|
}
|
|
44
63
|
|
|
45
|
-
.cko-payment-card::before {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
64
|
+
// .cko-payment-card::before {
|
|
65
|
+
// content: '';
|
|
66
|
+
// position: absolute;
|
|
67
|
+
// right: 0;
|
|
68
|
+
// bottom: 0;
|
|
69
|
+
// border: 12px solid ${(props) => props.theme.palette.primary.main};
|
|
70
|
+
// border-top-color: transparent;
|
|
71
|
+
// border-left-color: transparent;
|
|
72
|
+
// }
|
|
54
73
|
|
|
55
74
|
.cko-payment-card-unselect {
|
|
56
75
|
border: 1px solid #ddd;
|
|
57
76
|
padding: 4px 8px;
|
|
58
|
-
margin: 8px 0 0;
|
|
59
77
|
cursor: pointer;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
.cko-payment-card:nth-child(odd),
|
|
63
|
-
.cko-payment-card-unselect:nth-child(odd) {
|
|
64
|
-
margin-right: ${(props) => props.count > 1 ? 8 : 0}px;
|
|
78
|
+
background: var(--backgrounds-bg-field, #f9fafb);
|
|
65
79
|
}
|
|
66
80
|
|
|
67
81
|
.cko-payment-card::after {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import 'react-international-phone/style.css';
|
|
3
3
|
import { CheckoutCallbacks, CheckoutContext } from '../../types';
|
|
4
4
|
type PageData = CheckoutContext & CheckoutCallbacks;
|
|
5
|
-
declare function PaymentForm({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, onPaid, onError,
|
|
5
|
+
declare function PaymentForm({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, onPaid, onError, action, }: PageData): import("react").JSX.Element;
|
|
6
6
|
declare namespace PaymentForm {
|
|
7
7
|
var defaultProps: {};
|
|
8
8
|
}
|