@blocklet/payment-react 1.17.12 → 1.18.1
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.js +40 -10
- package/es/checkout/form.d.ts +2 -1
- package/es/checkout/form.js +32 -45
- package/es/components/payment-beneficiaries.d.ts +24 -0
- package/es/components/payment-beneficiaries.js +70 -0
- package/es/index.d.ts +2 -1
- package/es/index.js +3 -1
- package/es/locales/en.js +13 -1
- package/es/locales/zh.js +13 -1
- package/es/payment/donation-form.d.ts +24 -0
- package/es/payment/donation-form.js +603 -0
- package/es/payment/error.d.ts +1 -1
- package/es/payment/error.js +11 -1
- package/es/payment/form/index.d.ts +9 -3
- package/es/payment/form/index.js +39 -4
- package/es/payment/product-donation.js +98 -57
- package/es/payment/skeleton/donation.d.ts +1 -0
- package/es/payment/skeleton/donation.js +30 -0
- package/es/theme/index.js +3 -0
- package/es/types/index.d.ts +2 -0
- package/lib/checkout/donate.js +76 -10
- package/lib/checkout/form.d.ts +2 -1
- package/lib/checkout/form.js +39 -49
- package/lib/components/payment-beneficiaries.d.ts +24 -0
- package/lib/components/payment-beneficiaries.js +113 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +8 -0
- package/lib/locales/en.js +13 -1
- package/lib/locales/zh.js +13 -1
- package/lib/payment/donation-form.d.ts +24 -0
- package/lib/payment/donation-form.js +644 -0
- package/lib/payment/error.d.ts +1 -1
- package/lib/payment/error.js +2 -2
- package/lib/payment/form/index.d.ts +9 -3
- package/lib/payment/form/index.js +35 -2
- package/lib/payment/product-donation.js +140 -73
- package/lib/payment/skeleton/donation.d.ts +1 -0
- package/lib/payment/skeleton/donation.js +66 -0
- package/lib/theme/index.js +3 -0
- package/lib/types/index.d.ts +2 -0
- package/package.json +3 -3
- package/src/checkout/donate.tsx +54 -11
- package/src/checkout/form.tsx +17 -31
- package/src/components/payment-beneficiaries.tsx +97 -0
- package/src/index.ts +2 -0
- package/src/locales/en.tsx +12 -0
- package/src/locales/zh.tsx +12 -0
- package/src/payment/donation-form.tsx +646 -0
- package/src/payment/error.tsx +13 -4
- package/src/payment/form/index.tsx +46 -4
- package/src/payment/product-donation.tsx +91 -40
- package/src/payment/skeleton/donation.tsx +35 -0
- package/src/theme/index.tsx +3 -0
- package/src/types/index.ts +2 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
module.exports = PaymentBeneficiaries;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _material = require("@mui/material");
|
|
9
|
+
var _util = require("@ocap/util");
|
|
10
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
11
|
+
PaymentBeneficiaries.defaultProps = {
|
|
12
|
+
totalAmount: "0"
|
|
13
|
+
};
|
|
14
|
+
function PaymentBeneficiaries({
|
|
15
|
+
data,
|
|
16
|
+
currency,
|
|
17
|
+
totalAmount
|
|
18
|
+
}) {
|
|
19
|
+
const {
|
|
20
|
+
t
|
|
21
|
+
} = (0, _context.useLocaleContext)();
|
|
22
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
23
|
+
spacing: 2,
|
|
24
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
25
|
+
variant: "subtitle2",
|
|
26
|
+
color: "text.secondary",
|
|
27
|
+
children: t("benefits.title", {
|
|
28
|
+
count: data.length
|
|
29
|
+
})
|
|
30
|
+
}), data.map(item => {
|
|
31
|
+
const amount = item.amount || (totalAmount ? new _util.BN(totalAmount).mul(new _util.BN(Number(item.percent))).div(new _util.BN(100)).toString() : "0");
|
|
32
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
33
|
+
direction: {
|
|
34
|
+
xs: "column",
|
|
35
|
+
sm: "row"
|
|
36
|
+
},
|
|
37
|
+
alignItems: "center",
|
|
38
|
+
justifyContent: "space-between",
|
|
39
|
+
sx: {
|
|
40
|
+
px: 0.5,
|
|
41
|
+
borderRadius: 1,
|
|
42
|
+
bgcolor: "background.paper",
|
|
43
|
+
"&:hover": {
|
|
44
|
+
bgcolor: "action.hover"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
48
|
+
direction: "row",
|
|
49
|
+
spacing: 1.5,
|
|
50
|
+
alignItems: "center",
|
|
51
|
+
sx: {
|
|
52
|
+
width: {
|
|
53
|
+
xs: "100%",
|
|
54
|
+
sm: "auto"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Avatar, {
|
|
58
|
+
src: item.avatar,
|
|
59
|
+
alt: item.name,
|
|
60
|
+
sx: {
|
|
61
|
+
width: 32,
|
|
62
|
+
height: 32
|
|
63
|
+
},
|
|
64
|
+
variant: "square"
|
|
65
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
66
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
67
|
+
variant: "subtitle2",
|
|
68
|
+
onClick: () => {
|
|
69
|
+
if (item.url) {
|
|
70
|
+
window.open(item.url, "_blank");
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
sx: {
|
|
74
|
+
cursor: item.url ? "pointer" : "default",
|
|
75
|
+
"&:hover": {
|
|
76
|
+
color: item.url ? "text.link" : "inherit"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
children: item.name
|
|
80
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
81
|
+
variant: "caption",
|
|
82
|
+
color: "text.secondary",
|
|
83
|
+
sx: {
|
|
84
|
+
cursor: "pointer"
|
|
85
|
+
},
|
|
86
|
+
children: item.address
|
|
87
|
+
})]
|
|
88
|
+
})]
|
|
89
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
90
|
+
alignItems: "flex-end",
|
|
91
|
+
sx: {
|
|
92
|
+
width: {
|
|
93
|
+
xs: "100%",
|
|
94
|
+
sm: "auto"
|
|
95
|
+
},
|
|
96
|
+
mt: {
|
|
97
|
+
xs: 1,
|
|
98
|
+
sm: 0
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
102
|
+
variant: "subtitle2",
|
|
103
|
+
children: [(0, _util.fromUnitToToken)(amount, currency.decimal), " ", currency.symbol]
|
|
104
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
105
|
+
variant: "caption",
|
|
106
|
+
color: "text.secondary",
|
|
107
|
+
children: [Number(item.percent), "%"]
|
|
108
|
+
})]
|
|
109
|
+
})]
|
|
110
|
+
}, item.address);
|
|
111
|
+
})]
|
|
112
|
+
});
|
|
113
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ import TruncatedText from './components/truncated-text';
|
|
|
29
29
|
import Link from './components/link';
|
|
30
30
|
import { createLazyComponent } from './components/lazy-loader';
|
|
31
31
|
import OverdueInvoicePayment from './components/over-due-invoice-payment';
|
|
32
|
+
import PaymentBeneficiaries from './components/payment-beneficiaries';
|
|
32
33
|
export { PaymentThemeProvider } from './theme';
|
|
33
34
|
export * from './libs/util';
|
|
34
35
|
export * from './libs/connect';
|
|
@@ -39,4 +40,4 @@ export * from './hooks/mobile';
|
|
|
39
40
|
export * from './hooks/table';
|
|
40
41
|
export * from './hooks/scroll';
|
|
41
42
|
export { translations, createTranslator } from './locales';
|
|
42
|
-
export { createLazyComponent, api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, TxLink, TxGas, SafeGuard, PricingItem, CountrySelect, Table, TruncatedText, Link, OverdueInvoicePayment, };
|
|
43
|
+
export { createLazyComponent, api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, TxLink, TxGas, SafeGuard, PricingItem, CountrySelect, Table, TruncatedText, Link, OverdueInvoicePayment, PaymentBeneficiaries, };
|
package/lib/index.js
CHANGED
|
@@ -35,6 +35,7 @@ var _exportNames = {
|
|
|
35
35
|
Link: true,
|
|
36
36
|
createLazyComponent: true,
|
|
37
37
|
OverdueInvoicePayment: true,
|
|
38
|
+
PaymentBeneficiaries: true,
|
|
38
39
|
PaymentThemeProvider: true,
|
|
39
40
|
translations: true,
|
|
40
41
|
createTranslator: true
|
|
@@ -129,6 +130,12 @@ Object.defineProperty(exports, "Payment", {
|
|
|
129
130
|
return _index.default;
|
|
130
131
|
}
|
|
131
132
|
});
|
|
133
|
+
Object.defineProperty(exports, "PaymentBeneficiaries", {
|
|
134
|
+
enumerable: true,
|
|
135
|
+
get: function () {
|
|
136
|
+
return _paymentBeneficiaries.default;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
132
139
|
Object.defineProperty(exports, "PaymentSummary", {
|
|
133
140
|
enumerable: true,
|
|
134
141
|
get: function () {
|
|
@@ -274,6 +281,7 @@ var _truncatedText = _interopRequireDefault(require("./components/truncated-text
|
|
|
274
281
|
var _link = _interopRequireDefault(require("./components/link"));
|
|
275
282
|
var _lazyLoader = require("./components/lazy-loader");
|
|
276
283
|
var _overDueInvoicePayment = _interopRequireDefault(require("./components/over-due-invoice-payment"));
|
|
284
|
+
var _paymentBeneficiaries = _interopRequireDefault(require("./components/payment-beneficiaries"));
|
|
277
285
|
var _theme = require("./theme");
|
|
278
286
|
var _util = require("./libs/util");
|
|
279
287
|
Object.keys(_util).forEach(function (key) {
|
package/lib/locales/en.js
CHANGED
|
@@ -38,6 +38,8 @@ module.exports = (0, _flat.default)({
|
|
|
38
38
|
upload: "Upload",
|
|
39
39
|
change: "Change",
|
|
40
40
|
cancel: "Cancel",
|
|
41
|
+
close: "Close",
|
|
42
|
+
back: "Back",
|
|
41
43
|
every: "every",
|
|
42
44
|
per: "per {interval}",
|
|
43
45
|
slash: "/ {interval}",
|
|
@@ -132,7 +134,14 @@ module.exports = (0, _flat.default)({
|
|
|
132
134
|
custom: "Custom Amount",
|
|
133
135
|
select: "Select Amount",
|
|
134
136
|
summary: "{total} supporters {totalAmount} {symbol}",
|
|
135
|
-
empty: "No supporters yet"
|
|
137
|
+
empty: "No supporters yet",
|
|
138
|
+
gaveTips: "{count} people gave tips",
|
|
139
|
+
tipAmount: "Tip Amount",
|
|
140
|
+
benefits: {
|
|
141
|
+
one: "{name} will receive all tips",
|
|
142
|
+
multiple: "Tips will be distributed to {count} beneficiaries",
|
|
143
|
+
view: "Click to view details"
|
|
144
|
+
}
|
|
136
145
|
},
|
|
137
146
|
cardPay: "{action} with card",
|
|
138
147
|
empty: "No thing to pay",
|
|
@@ -354,5 +363,8 @@ module.exports = (0, _flat.default)({
|
|
|
354
363
|
},
|
|
355
364
|
empty: {
|
|
356
365
|
records: "No matching records found"
|
|
366
|
+
},
|
|
367
|
+
benefits: {
|
|
368
|
+
title: "{count} Beneficiaries"
|
|
357
369
|
}
|
|
358
370
|
});
|
package/lib/locales/zh.js
CHANGED
|
@@ -38,6 +38,8 @@ module.exports = (0, _flat.default)({
|
|
|
38
38
|
change: "\u66F4\u6362",
|
|
39
39
|
confirm: "\u786E\u8BA4",
|
|
40
40
|
cancel: "\u53D6\u6D88",
|
|
41
|
+
close: "\u5173\u95ED",
|
|
42
|
+
back: "\u8FD4\u56DE",
|
|
41
43
|
every: "\u6BCF",
|
|
42
44
|
per: "\u6BCF{interval}",
|
|
43
45
|
slash: "\u6BCF{interval}",
|
|
@@ -132,7 +134,14 @@ module.exports = (0, _flat.default)({
|
|
|
132
134
|
custom: "\u8F93\u5165\u91D1\u989D",
|
|
133
135
|
select: "\u9009\u62E9\u91D1\u989D",
|
|
134
136
|
summary: "\u5171\u6709 {total} \u4EBA\u652F\u6301 {totalAmount} {symbol}",
|
|
135
|
-
empty: "\u2764\uFE0F \u652F\u6301\u4E00\u4E0B"
|
|
137
|
+
empty: "\u2764\uFE0F \u652F\u6301\u4E00\u4E0B",
|
|
138
|
+
gaveTips: "\u5DF2\u6709 {count} \u4EBA\u6253\u8D4F",
|
|
139
|
+
tipAmount: "\u6253\u8D4F\u91D1\u989D",
|
|
140
|
+
benefits: {
|
|
141
|
+
one: "{name} \u5C06\u83B7\u5F97\u5168\u90E8\u6253\u8D4F",
|
|
142
|
+
multiple: "\u6253\u8D4F\u5C06\u6309\u6BD4\u4F8B\u5206\u914D\u7ED9 {count} \u4F4D\u53D7\u76CA\u4EBA",
|
|
143
|
+
view: "\u70B9\u51FB\u67E5\u770B\u8BE6\u60C5"
|
|
144
|
+
}
|
|
136
145
|
},
|
|
137
146
|
cardPay: "\u4F7F\u7528\u5361\u7247{action}",
|
|
138
147
|
empty: "\u6CA1\u6709\u53EF\u652F\u4ED8\u7684\u9879\u76EE",
|
|
@@ -354,5 +363,8 @@ module.exports = (0, _flat.default)({
|
|
|
354
363
|
},
|
|
355
364
|
empty: {
|
|
356
365
|
records: "\u6CA1\u6709\u627E\u5230\u5339\u914D\u7684\u8BB0\u5F55"
|
|
366
|
+
},
|
|
367
|
+
benefits: {
|
|
368
|
+
title: "{count} \u4F4D\u53D7\u76CA\u4EBA"
|
|
357
369
|
}
|
|
358
370
|
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type BoxProps } from '@mui/material';
|
|
2
|
+
import type { LiteralUnion } from 'type-fest';
|
|
3
|
+
import type { CheckoutCallbacks, CheckoutContext } from '../types';
|
|
4
|
+
type Props = CheckoutContext & CheckoutCallbacks & {
|
|
5
|
+
completed?: boolean;
|
|
6
|
+
error?: any;
|
|
7
|
+
showCheckoutSummary?: boolean;
|
|
8
|
+
formRender?: Record<string, any>;
|
|
9
|
+
id: string;
|
|
10
|
+
};
|
|
11
|
+
declare function DonationForm({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, completed, error, mode, onPaid, onError, onChange, goBack, action, showCheckoutSummary, formRender, id, }: Props): import("react").JSX.Element;
|
|
12
|
+
declare namespace DonationForm {
|
|
13
|
+
var defaultProps: {
|
|
14
|
+
completed: boolean;
|
|
15
|
+
error: null;
|
|
16
|
+
showCheckoutSummary: boolean;
|
|
17
|
+
formRender: {};
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export default DonationForm;
|
|
21
|
+
type RootProps = {
|
|
22
|
+
mode: LiteralUnion<'standalone' | 'inline' | 'popup', string>;
|
|
23
|
+
} & BoxProps;
|
|
24
|
+
export declare const Root: React.FC<RootProps>;
|