@blocklet/payment-react 1.18.6 → 1.18.8
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 +394 -341
- package/es/checkout/donate.d.ts +29 -4
- package/es/checkout/donate.js +193 -95
- package/es/components/livemode.js +1 -1
- package/es/components/loading-button.d.ts +10 -0
- package/es/components/loading-button.js +75 -0
- package/es/components/pricing-table.js +2 -3
- package/es/components/table.js +1 -1
- package/es/index.d.ts +2 -1
- package/es/index.js +3 -1
- package/es/libs/util.d.ts +1 -0
- package/es/libs/util.js +10 -1
- package/es/payment/amount.js +1 -1
- package/es/payment/form/index.js +14 -12
- package/es/payment/form/stripe/form.js +20 -5
- package/es/payment/index.js +0 -1
- package/es/payment/product-card.js +2 -2
- package/es/payment/product-item.js +1 -1
- package/es/payment/product-skeleton.js +2 -2
- package/es/payment/skeleton/donation.js +1 -1
- package/es/payment/skeleton/overview.js +1 -1
- package/es/payment/skeleton/payment.js +1 -1
- package/es/payment/summary.js +2 -2
- package/es/theme/index.js +5 -3
- package/es/theme/typography.js +8 -8
- package/lib/checkout/donate.d.ts +29 -4
- package/lib/checkout/donate.js +197 -136
- package/lib/components/livemode.js +1 -1
- package/lib/components/loading-button.d.ts +10 -0
- package/lib/components/loading-button.js +86 -0
- package/lib/components/pricing-table.js +3 -4
- package/lib/components/table.js +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +8 -0
- package/lib/libs/util.d.ts +1 -0
- package/lib/libs/util.js +7 -0
- package/lib/payment/amount.js +1 -1
- package/lib/payment/form/index.js +14 -15
- package/lib/payment/form/stripe/form.js +25 -6
- package/lib/payment/index.js +0 -1
- package/lib/payment/product-card.js +2 -2
- package/lib/payment/product-item.js +1 -1
- package/lib/payment/product-skeleton.js +2 -2
- package/lib/payment/skeleton/donation.js +1 -1
- package/lib/payment/skeleton/overview.js +1 -1
- package/lib/payment/skeleton/payment.js +1 -1
- package/lib/payment/summary.js +4 -4
- package/lib/theme/index.js +5 -3
- package/lib/theme/typography.js +8 -8
- package/package.json +8 -8
- package/src/checkout/donate.tsx +209 -128
- package/src/components/livemode.tsx +1 -1
- package/src/components/loading-button.tsx +100 -0
- package/src/components/pricing-table.tsx +3 -3
- package/src/components/table.tsx +1 -1
- package/src/index.ts +2 -0
- package/src/libs/util.ts +11 -1
- package/src/payment/amount.tsx +1 -1
- package/src/payment/form/index.tsx +65 -60
- package/src/payment/form/stripe/form.tsx +21 -6
- package/src/payment/index.tsx +0 -1
- package/src/payment/product-card.tsx +2 -2
- package/src/payment/product-item.tsx +1 -1
- package/src/payment/product-skeleton.tsx +2 -2
- package/src/payment/skeleton/donation.tsx +1 -1
- package/src/payment/skeleton/overview.tsx +1 -1
- package/src/payment/skeleton/payment.tsx +1 -1
- package/src/payment/summary.tsx +2 -2
- package/src/theme/index.tsx +3 -1
- package/src/theme/typography.ts +8 -8
package/es/checkout/donate.d.ts
CHANGED
|
@@ -1,20 +1,45 @@
|
|
|
1
|
-
import type { DonationSettings, TCheckoutSessionExpanded, TPaymentCurrency, TPaymentMethod } from '@blocklet/payment-types';
|
|
1
|
+
import type { DonationSettings, PaymentBeneficiary, TCheckoutSessionExpanded, TPaymentCurrency, TPaymentMethod } from '@blocklet/payment-types';
|
|
2
2
|
import { type ButtonProps as MUIButtonProps } from '@mui/material';
|
|
3
3
|
import type { CheckoutProps, PaymentThemeOptions } from '../types';
|
|
4
4
|
export type DonateHistory = {
|
|
5
5
|
supporters: TCheckoutSessionExpanded[];
|
|
6
6
|
currency: TPaymentCurrency;
|
|
7
7
|
method: TPaymentMethod;
|
|
8
|
+
total?: number;
|
|
8
9
|
totalAmount: string;
|
|
9
10
|
};
|
|
10
|
-
export type
|
|
11
|
-
|
|
11
|
+
export type CheckoutDonateSettings = {
|
|
12
|
+
target: string;
|
|
13
|
+
title: string;
|
|
14
|
+
description: string;
|
|
15
|
+
reference: string;
|
|
16
|
+
beneficiaries: PaymentBeneficiary[];
|
|
17
|
+
amount?: {
|
|
18
|
+
presets?: string[];
|
|
19
|
+
preset?: string;
|
|
20
|
+
minimum?: string;
|
|
21
|
+
maximum?: string;
|
|
22
|
+
custom?: boolean;
|
|
23
|
+
};
|
|
24
|
+
appearance?: {
|
|
25
|
+
button?: {
|
|
26
|
+
text?: any;
|
|
27
|
+
icon?: any;
|
|
28
|
+
size?: string;
|
|
29
|
+
color?: string;
|
|
30
|
+
variant?: string;
|
|
31
|
+
};
|
|
32
|
+
history?: {
|
|
33
|
+
variant?: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
12
37
|
export interface ButtonType extends Omit<MUIButtonProps, 'text' | 'icon'> {
|
|
13
38
|
text?: string | React.ReactNode;
|
|
14
39
|
icon: React.ReactNode;
|
|
15
40
|
}
|
|
16
41
|
export type DonateProps = Pick<CheckoutProps, 'onPaid' | 'onError'> & {
|
|
17
|
-
settings:
|
|
42
|
+
settings: CheckoutDonateSettings;
|
|
18
43
|
livemode?: boolean;
|
|
19
44
|
timeout?: number;
|
|
20
45
|
mode?: 'inline' | 'default' | 'custom';
|
package/es/checkout/donate.js
CHANGED
|
@@ -2,20 +2,14 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import Dialog from "@arcblock/ux/lib/Dialog";
|
|
3
3
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
4
4
|
import {
|
|
5
|
-
Alert,
|
|
6
5
|
Avatar,
|
|
7
6
|
AvatarGroup,
|
|
8
7
|
Box,
|
|
9
8
|
Button,
|
|
10
9
|
CircularProgress,
|
|
11
|
-
Hidden,
|
|
12
10
|
IconButton,
|
|
13
11
|
Popover,
|
|
14
12
|
Stack,
|
|
15
|
-
Table,
|
|
16
|
-
TableBody,
|
|
17
|
-
TableCell,
|
|
18
|
-
TableRow,
|
|
19
13
|
Typography,
|
|
20
14
|
Tooltip
|
|
21
15
|
} from "@mui/material";
|
|
@@ -24,14 +18,13 @@ import omit from "lodash/omit";
|
|
|
24
18
|
import uniqBy from "lodash/unionBy";
|
|
25
19
|
import { useEffect, useRef, useState } from "react";
|
|
26
20
|
import { Settings } from "@mui/icons-material";
|
|
27
|
-
import TxLink from "../components/blockchain/tx.js";
|
|
28
21
|
import api from "../libs/api.js";
|
|
29
22
|
import {
|
|
30
23
|
formatAmount,
|
|
31
24
|
formatBNStr,
|
|
32
|
-
formatDateTime,
|
|
33
|
-
formatError,
|
|
34
25
|
getCustomerAvatar,
|
|
26
|
+
getTxLink,
|
|
27
|
+
getUserProfileLink,
|
|
35
28
|
lazyLoad,
|
|
36
29
|
openDonationSettings
|
|
37
30
|
} from "../libs/util.js";
|
|
@@ -67,98 +60,190 @@ const fetchSupporters = (target, livemode = true) => {
|
|
|
67
60
|
const emojiFont = {
|
|
68
61
|
fontFamily: 'Avenir, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"'
|
|
69
62
|
};
|
|
70
|
-
function
|
|
71
|
-
const {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return /* @__PURE__ */ jsxs(
|
|
75
|
-
Box,
|
|
63
|
+
function DonateDetails({ supporters = [], currency, method }) {
|
|
64
|
+
const { locale } = useLocaleContext();
|
|
65
|
+
return /* @__PURE__ */ jsx(
|
|
66
|
+
Stack,
|
|
76
67
|
{
|
|
77
|
-
display: "flex",
|
|
78
|
-
flexDirection: "column",
|
|
79
|
-
alignItems: "center",
|
|
80
68
|
sx: {
|
|
81
|
-
"
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
69
|
+
width: "100%",
|
|
70
|
+
minWidth: "256px",
|
|
71
|
+
maxWidth: "calc(100vw - 32px)",
|
|
72
|
+
maxHeight: "300px",
|
|
73
|
+
overflowX: "hidden",
|
|
74
|
+
overflowY: "auto",
|
|
75
|
+
margin: "0 auto"
|
|
85
76
|
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
alt: x.customer?.name,
|
|
101
|
-
src: getCustomerAvatar(x.customer?.did, x?.updated_at ? new Date(x.updated_at).toISOString() : "", 48),
|
|
102
|
-
variant: "circular",
|
|
103
|
-
sx: { width: 32, height: 32 }
|
|
77
|
+
children: supporters.map((x) => /* @__PURE__ */ jsxs(
|
|
78
|
+
Box,
|
|
79
|
+
{
|
|
80
|
+
sx: {
|
|
81
|
+
padding: "6px",
|
|
82
|
+
"&:hover": {
|
|
83
|
+
backgroundColor: "var(--backgrounds-bg-highlight, #eff6ff)",
|
|
84
|
+
transition: "background-color 200ms linear",
|
|
85
|
+
cursor: "pointer"
|
|
86
|
+
},
|
|
87
|
+
borderBottom: "1px solid var(--stroke-border-base, #EFF1F5)",
|
|
88
|
+
display: "flex",
|
|
89
|
+
justifyContent: "space-between",
|
|
90
|
+
alignItems: "center"
|
|
104
91
|
},
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
92
|
+
onClick: () => {
|
|
93
|
+
const { link, text } = getTxLink(method, x.payment_details);
|
|
94
|
+
if (link && text) {
|
|
95
|
+
window.open(link, "_blank");
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
children: [
|
|
99
|
+
/* @__PURE__ */ jsxs(
|
|
100
|
+
Stack,
|
|
101
|
+
{
|
|
102
|
+
direction: "row",
|
|
103
|
+
alignItems: "center",
|
|
104
|
+
spacing: 0.5,
|
|
105
|
+
sx: {
|
|
106
|
+
flex: 3,
|
|
107
|
+
overflow: "hidden"
|
|
108
|
+
},
|
|
109
|
+
children: [
|
|
110
|
+
/* @__PURE__ */ jsx(
|
|
111
|
+
Avatar,
|
|
112
|
+
{
|
|
113
|
+
src: getCustomerAvatar(x.customer?.did, x?.updated_at ? new Date(x.updated_at).toISOString() : "", 20),
|
|
114
|
+
alt: x.customer?.name,
|
|
115
|
+
variant: "circular",
|
|
116
|
+
sx: { width: 20, height: 20 },
|
|
117
|
+
onClick: (e) => {
|
|
118
|
+
e.stopPropagation();
|
|
119
|
+
if (x.customer?.did) {
|
|
120
|
+
window.open(getUserProfileLink(x.customer?.did, locale), "_blank");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
x.id
|
|
125
|
+
),
|
|
126
|
+
/* @__PURE__ */ jsx(
|
|
127
|
+
Typography,
|
|
128
|
+
{
|
|
129
|
+
sx: {
|
|
130
|
+
ml: "8px !important",
|
|
131
|
+
fontSize: "0.875rem",
|
|
132
|
+
fontWeight: "500",
|
|
133
|
+
overflow: "hidden",
|
|
134
|
+
whiteSpace: "nowrap",
|
|
135
|
+
textOverflow: "ellipsis"
|
|
136
|
+
},
|
|
137
|
+
onClick: (e) => {
|
|
138
|
+
e.stopPropagation();
|
|
139
|
+
if (x.customer?.did) {
|
|
140
|
+
window.open(getUserProfileLink(x.customer?.did, locale), "_blank");
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
children: x.customer?.name
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
/* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", justifyContent: "flex-end", spacing: 0.5, sx: { flex: 1 }, children: [
|
|
150
|
+
/* @__PURE__ */ jsx(
|
|
151
|
+
Avatar,
|
|
152
|
+
{
|
|
153
|
+
src: currency?.logo,
|
|
154
|
+
alt: currency?.symbol,
|
|
155
|
+
variant: "circular",
|
|
156
|
+
sx: { width: 16, height: 16 }
|
|
157
|
+
},
|
|
158
|
+
x.id
|
|
159
|
+
),
|
|
160
|
+
/* @__PURE__ */ jsx(Typography, { sx: { color: "text.secondary" }, children: formatBNStr(x.amount_total, currency.decimal) }),
|
|
161
|
+
/* @__PURE__ */ jsx(Typography, { sx: { color: "text.secondary" }, children: currency.symbol })
|
|
162
|
+
] })
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
x.id
|
|
166
|
+
))
|
|
108
167
|
}
|
|
109
168
|
);
|
|
110
169
|
}
|
|
111
|
-
function
|
|
112
|
-
|
|
170
|
+
function SupporterAvatar({
|
|
171
|
+
supporters = [],
|
|
172
|
+
totalAmount = "0",
|
|
173
|
+
currency,
|
|
174
|
+
method,
|
|
175
|
+
showDonateDetails = false
|
|
176
|
+
}) {
|
|
177
|
+
const [open, setOpen] = useState(false);
|
|
113
178
|
const customers = uniqBy(supporters, "customer_did");
|
|
114
179
|
const customersNum = customers.length;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}) }),
|
|
121
|
-
/* @__PURE__ */ jsx(Table, { size: "small", sx: { width: "100%", overflow: "hidden" }, children: /* @__PURE__ */ jsx(TableBody, { children: supporters.map((x) => /* @__PURE__ */ jsxs(
|
|
122
|
-
TableRow,
|
|
180
|
+
if (customersNum === 0)
|
|
181
|
+
return null;
|
|
182
|
+
return /* @__PURE__ */ jsxs(Stack, { flexDirection: "row", justifyContent: "center", alignItems: "center", children: [
|
|
183
|
+
/* @__PURE__ */ jsx(AvatarGroup, { max: 5, children: customers.slice(0, 5).map((supporter) => /* @__PURE__ */ jsx(
|
|
184
|
+
Avatar,
|
|
123
185
|
{
|
|
186
|
+
src: getCustomerAvatar(
|
|
187
|
+
supporter.customer?.did,
|
|
188
|
+
supporter?.updated_at ? new Date(supporter.updated_at).toISOString() : "",
|
|
189
|
+
24
|
|
190
|
+
),
|
|
191
|
+
alt: supporter.customer?.name,
|
|
124
192
|
sx: {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
193
|
+
width: "24px",
|
|
194
|
+
height: "24px"
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
supporter.customer?.id
|
|
198
|
+
)) }),
|
|
199
|
+
/* @__PURE__ */ jsx(
|
|
200
|
+
Box,
|
|
201
|
+
{
|
|
202
|
+
sx: {
|
|
203
|
+
fontSize: "14px",
|
|
204
|
+
color: "text.secondary",
|
|
205
|
+
pl: 1.5,
|
|
206
|
+
pr: 1,
|
|
207
|
+
ml: -1,
|
|
208
|
+
borderRadius: "8px",
|
|
209
|
+
backgroundColor: "#f4f4f5",
|
|
210
|
+
height: "24px",
|
|
211
|
+
...showDonateDetails ? {
|
|
212
|
+
cursor: "pointer",
|
|
213
|
+
"&:hover": {
|
|
214
|
+
backgroundColor: "#e5e7eb"
|
|
215
|
+
}
|
|
216
|
+
} : {}
|
|
217
|
+
},
|
|
218
|
+
onClick: () => showDonateDetails && setOpen(true),
|
|
219
|
+
children: `${customersNum} supporter${customersNum > 1 ? "s" : ""} (${formatAmount(totalAmount || "0", currency?.decimal)} ${currency.symbol})`
|
|
220
|
+
}
|
|
221
|
+
),
|
|
222
|
+
/* @__PURE__ */ jsx(
|
|
223
|
+
Dialog,
|
|
224
|
+
{
|
|
225
|
+
open,
|
|
226
|
+
onClose: () => setOpen(false),
|
|
227
|
+
sx: {
|
|
228
|
+
".MuiDialogContent-root": {
|
|
229
|
+
width: "450px",
|
|
230
|
+
padding: "8px"
|
|
132
231
|
}
|
|
133
232
|
},
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
x.id
|
|
149
|
-
),
|
|
150
|
-
/* @__PURE__ */ jsx(Hidden, { smDown: true, children: /* @__PURE__ */ jsx(Typography, { children: x.customer?.name }) })
|
|
151
|
-
] }) }),
|
|
152
|
-
/* @__PURE__ */ jsx(TableCell, { align: "right", children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", justifyContent: "flex-end", spacing: 0.5, children: [
|
|
153
|
-
/* @__PURE__ */ jsx(Typography, { fontWeight: 500, component: "strong", children: formatBNStr(x.amount_total, currency.decimal) }),
|
|
154
|
-
/* @__PURE__ */ jsx(Typography, { component: "span", children: currency.symbol })
|
|
155
|
-
] }) }),
|
|
156
|
-
/* @__PURE__ */ jsx(Hidden, { smDown: true, children: /* @__PURE__ */ jsx(TableCell, { align: "right", children: /* @__PURE__ */ jsx(Typography, { children: formatDateTime(x.created_at) }) }) }),
|
|
157
|
-
/* @__PURE__ */ jsx(TableCell, { align: "right", children: /* @__PURE__ */ jsx(TxLink, { method, details: x.payment_details, mode: "customer", align: "right" }) })
|
|
158
|
-
]
|
|
159
|
-
},
|
|
160
|
-
x.id
|
|
161
|
-
)) }) })
|
|
233
|
+
title: `${customersNum} supporter${customersNum > 1 ? "s" : ""}`,
|
|
234
|
+
children: /* @__PURE__ */ jsx(DonateDetails, { supporters, currency, method, totalAmount })
|
|
235
|
+
}
|
|
236
|
+
)
|
|
237
|
+
] });
|
|
238
|
+
}
|
|
239
|
+
function SupporterTable({ supporters = [], totalAmount = "0", currency, method }) {
|
|
240
|
+
const customers = uniqBy(supporters, "customer_did");
|
|
241
|
+
const customersNum = customers.length;
|
|
242
|
+
if (customersNum === 0)
|
|
243
|
+
return null;
|
|
244
|
+
return /* @__PURE__ */ jsxs(Box, { display: "flex", flexDirection: "column", alignItems: "center", gap: { xs: 0.5, sm: 1 }, children: [
|
|
245
|
+
/* @__PURE__ */ jsx(SupporterAvatar, { supporters, totalAmount, currency, method }),
|
|
246
|
+
/* @__PURE__ */ jsx(DonateDetails, { supporters, totalAmount, currency, method })
|
|
162
247
|
] });
|
|
163
248
|
}
|
|
164
249
|
function SupporterSimple({ supporters = [], totalAmount = "0", currency, method }) {
|
|
@@ -309,7 +394,7 @@ function CheckoutDonateInner({
|
|
|
309
394
|
}, timeout);
|
|
310
395
|
};
|
|
311
396
|
if (donation.error) {
|
|
312
|
-
return
|
|
397
|
+
return null;
|
|
313
398
|
}
|
|
314
399
|
const handlePopoverOpen = (event) => {
|
|
315
400
|
donation.run();
|
|
@@ -406,16 +491,28 @@ function CheckoutDonateInner({
|
|
|
406
491
|
{
|
|
407
492
|
size: donateSettings.appearance?.button?.size || "medium",
|
|
408
493
|
color: donateSettings.appearance?.button?.color || "primary",
|
|
409
|
-
variant: donateSettings.appearance?.button?.variant || "
|
|
494
|
+
variant: donateSettings.appearance?.button?.variant || "outlined",
|
|
495
|
+
sx: {
|
|
496
|
+
...!donateSettings.appearance?.button?.variant ? {
|
|
497
|
+
color: "var(--foregrounds-fg-base, #010714)",
|
|
498
|
+
borderColor: "var(--stroke-button-secondary-border, #E5E7EB)",
|
|
499
|
+
"&:hover": {
|
|
500
|
+
backgroundColor: "var(--buttons-button-neutral-hover, #F3F4F6)",
|
|
501
|
+
borderColor: "var(--stroke-button-secondary-border, #E5E7EB)"
|
|
502
|
+
}
|
|
503
|
+
} : {},
|
|
504
|
+
// @ts-ignore
|
|
505
|
+
...donateSettings.appearance?.button?.sx || {}
|
|
506
|
+
},
|
|
410
507
|
...donateSettings.appearance?.button,
|
|
411
508
|
onClick: () => startDonate(),
|
|
412
509
|
children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
|
|
413
|
-
donateSettings.appearance.button.icon,
|
|
510
|
+
donateSettings.appearance.button.icon && /* @__PURE__ */ jsx(Typography, { sx: { mr: 0.5, display: "inline-flex", alignItems: "center" }, children: donateSettings.appearance.button.icon }),
|
|
414
511
|
typeof donateSettings.appearance.button.text === "string" ? /* @__PURE__ */ jsx(Typography, { children: donateSettings.appearance.button.text }) : donateSettings.appearance.button.text
|
|
415
512
|
] })
|
|
416
513
|
}
|
|
417
514
|
),
|
|
418
|
-
supporters.data && donateSettings.appearance.history.variant === "avatar" && /* @__PURE__ */ jsx(SupporterAvatar, { ...supporters.data }),
|
|
515
|
+
supporters.data && donateSettings.appearance.history.variant === "avatar" && /* @__PURE__ */ jsx(SupporterAvatar, { ...supporters.data, showDonateDetails: true }),
|
|
419
516
|
supporters.data && donateSettings.appearance.history.variant === "table" && /* @__PURE__ */ jsx(SupporterTable, { ...supporters.data })
|
|
420
517
|
]
|
|
421
518
|
}
|
|
@@ -430,13 +527,14 @@ function CheckoutDonateInner({
|
|
|
430
527
|
`${formatAmount(
|
|
431
528
|
supporters.data?.totalAmount || "0",
|
|
432
529
|
supporters.data?.currency?.decimal
|
|
433
|
-
)} ${supporters.data?.currency?.symbol}`,
|
|
530
|
+
)} ${supporters.data?.currency?.symbol || ""}`,
|
|
434
531
|
supporters.data || {},
|
|
435
532
|
!!supporters.loading,
|
|
436
533
|
donateSettings
|
|
437
534
|
) }) : /* @__PURE__ */ jsxs(Typography, { children: [
|
|
438
|
-
"Please provide a valid render function
|
|
439
|
-
|
|
535
|
+
"Please provide a valid render function",
|
|
536
|
+
" ",
|
|
537
|
+
/* @__PURE__ */ jsx("pre", { children: "(openDonate, donateTotalAmount, supporters, loading, donateSettings) => ReactNode" })
|
|
440
538
|
] });
|
|
441
539
|
}
|
|
442
540
|
return defaultRender;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ButtonProps, type CircularProgressProps } from '@mui/material';
|
|
2
|
+
export interface LoadingButtonProps extends ButtonProps {
|
|
3
|
+
loading?: boolean;
|
|
4
|
+
loadingIndicator?: React.ReactNode;
|
|
5
|
+
loadingPosition?: 'start' | 'center' | 'end';
|
|
6
|
+
loadingProps?: Partial<CircularProgressProps>;
|
|
7
|
+
loadingOnly?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const LoadingButton: import("react").ForwardRefExoticComponent<Omit<LoadingButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
10
|
+
export default LoadingButton;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
CircularProgress,
|
|
5
|
+
Typography
|
|
6
|
+
} from "@mui/material";
|
|
7
|
+
import { forwardRef } from "react";
|
|
8
|
+
const LoadingButton = forwardRef(
|
|
9
|
+
({
|
|
10
|
+
children,
|
|
11
|
+
loading,
|
|
12
|
+
loadingPosition = "start",
|
|
13
|
+
loadingIndicator,
|
|
14
|
+
loadingProps = {},
|
|
15
|
+
onClick,
|
|
16
|
+
sx,
|
|
17
|
+
loadingOnly = false,
|
|
18
|
+
...props
|
|
19
|
+
}, ref) => {
|
|
20
|
+
const handleClick = (e) => {
|
|
21
|
+
if (loading) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
onClick?.(e);
|
|
25
|
+
};
|
|
26
|
+
const getPositionStyles = (position) => {
|
|
27
|
+
return {
|
|
28
|
+
color: "inherit",
|
|
29
|
+
...position === "start" && { mr: 1 },
|
|
30
|
+
...position === "end" && { ml: 1 },
|
|
31
|
+
...position === "center" && {
|
|
32
|
+
position: "absolute",
|
|
33
|
+
left: "50%",
|
|
34
|
+
transform: "translateY(-50%) translateX(-50%)",
|
|
35
|
+
top: "50%"
|
|
36
|
+
},
|
|
37
|
+
display: "inline-flex",
|
|
38
|
+
alignItems: "center"
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
const defaultIndicator = /* @__PURE__ */ jsx(CircularProgress, { size: 16, ...loadingProps, sx: { color: "inherit", ...loadingProps?.sx || {} } });
|
|
42
|
+
const indicator = /* @__PURE__ */ jsx(Typography, { sx: getPositionStyles(loadingPosition), children: loadingIndicator || defaultIndicator });
|
|
43
|
+
return /* @__PURE__ */ jsxs(
|
|
44
|
+
Button,
|
|
45
|
+
{
|
|
46
|
+
ref,
|
|
47
|
+
disabled: props.disabled,
|
|
48
|
+
onClick: handleClick,
|
|
49
|
+
sx: {
|
|
50
|
+
position: "relative",
|
|
51
|
+
display: "inline-flex",
|
|
52
|
+
alignItems: "center",
|
|
53
|
+
justifyContent: "center",
|
|
54
|
+
...sx
|
|
55
|
+
},
|
|
56
|
+
...props,
|
|
57
|
+
children: [
|
|
58
|
+
loading && loadingPosition === "start" && indicator,
|
|
59
|
+
/* @__PURE__ */ jsx(Typography, { sx: { visibility: loading && loadingOnly ? "hidden" : "visible" }, children }),
|
|
60
|
+
loading && loadingPosition === "center" && indicator,
|
|
61
|
+
loading && loadingPosition === "end" && indicator
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
LoadingButton.displayName = "LoadingButton";
|
|
68
|
+
LoadingButton.defaultProps = {
|
|
69
|
+
loading: false,
|
|
70
|
+
loadingIndicator: void 0,
|
|
71
|
+
loadingPosition: "start",
|
|
72
|
+
loadingProps: {},
|
|
73
|
+
loadingOnly: false
|
|
74
|
+
};
|
|
75
|
+
export default LoadingButton;
|
|
@@ -2,7 +2,6 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
3
3
|
import Toast from "@arcblock/ux/lib/Toast";
|
|
4
4
|
import { CheckOutlined } from "@mui/icons-material";
|
|
5
|
-
import { LoadingButton } from "@mui/lab";
|
|
6
5
|
import {
|
|
7
6
|
Avatar,
|
|
8
7
|
Box,
|
|
@@ -34,6 +33,7 @@ import {
|
|
|
34
33
|
} from "../libs/util.js";
|
|
35
34
|
import { useMobile } from "../hooks/mobile.js";
|
|
36
35
|
import TruncatedText from "./truncated-text.js";
|
|
36
|
+
import LoadingButton from "./loading-button.js";
|
|
37
37
|
const sortOrder = {
|
|
38
38
|
year: 1,
|
|
39
39
|
month: 2,
|
|
@@ -290,7 +290,6 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
|
|
|
290
290
|
justifyContent: alignItems === "center" ? "center" : "flex-start",
|
|
291
291
|
sx: {
|
|
292
292
|
flex: "0 1 auto",
|
|
293
|
-
overflow: "auto",
|
|
294
293
|
pb: 2.5
|
|
295
294
|
},
|
|
296
295
|
className: "price-table-wrap",
|
|
@@ -319,7 +318,7 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
|
|
|
319
318
|
boxShadow: "0px 0px 0px 1px rgba(3, 7, 18, 0.08), 0px 1px 2px -1px rgba(3, 7, 18, 0.08), 0px 2px 4px rgba(3, 7, 18, 0.04)",
|
|
320
319
|
"&:hover": {
|
|
321
320
|
borderColor: mode === "select" && x.is_selected ? "primary.main" : "#ddd",
|
|
322
|
-
boxShadow: "
|
|
321
|
+
boxShadow: "0px 0px 0px 1px var(--shadows-card-hover-1, rgba(2, 7, 19, 0.08)),0px 1px 2px -1px var(--shadows-card-hover-2, rgba(2, 7, 19, 0.08)),0px 2px 8px 0px var(--shadows-card-hover-3, rgba(2, 7, 19, 0.10))"
|
|
323
322
|
},
|
|
324
323
|
width: {
|
|
325
324
|
xs: "100%",
|
package/es/components/table.js
CHANGED
package/es/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ import Link from './components/link';
|
|
|
30
30
|
import { createLazyComponent } from './components/lazy-loader';
|
|
31
31
|
import OverdueInvoicePayment from './components/over-due-invoice-payment';
|
|
32
32
|
import PaymentBeneficiaries from './components/payment-beneficiaries';
|
|
33
|
+
import LoadingButton from './components/loading-button';
|
|
33
34
|
export { PaymentThemeProvider } from './theme';
|
|
34
35
|
export * from './libs/util';
|
|
35
36
|
export * from './libs/connect';
|
|
@@ -42,4 +43,4 @@ export * from './hooks/mobile';
|
|
|
42
43
|
export * from './hooks/table';
|
|
43
44
|
export * from './hooks/scroll';
|
|
44
45
|
export { translations, createTranslator } from './locales';
|
|
45
|
-
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, };
|
|
46
|
+
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, LoadingButton, };
|
package/es/index.js
CHANGED
|
@@ -30,6 +30,7 @@ import Link from "./components/link.js";
|
|
|
30
30
|
import { createLazyComponent } from "./components/lazy-loader.js";
|
|
31
31
|
import OverdueInvoicePayment from "./components/over-due-invoice-payment.js";
|
|
32
32
|
import PaymentBeneficiaries from "./components/payment-beneficiaries.js";
|
|
33
|
+
import LoadingButton from "./components/loading-button.js";
|
|
33
34
|
export { PaymentThemeProvider } from "./theme/index.js";
|
|
34
35
|
export * from "./libs/util.js";
|
|
35
36
|
export * from "./libs/connect.js";
|
|
@@ -74,5 +75,6 @@ export {
|
|
|
74
75
|
TruncatedText,
|
|
75
76
|
Link,
|
|
76
77
|
OverdueInvoicePayment,
|
|
77
|
-
PaymentBeneficiaries
|
|
78
|
+
PaymentBeneficiaries,
|
|
79
|
+
LoadingButton
|
|
78
80
|
};
|
package/es/libs/util.d.ts
CHANGED
|
@@ -113,3 +113,4 @@ export declare function getInvoiceDescriptionAndReason(invoice: TInvoiceExpanded
|
|
|
113
113
|
};
|
|
114
114
|
export declare function getPaymentKitComponent(): any;
|
|
115
115
|
export declare function openDonationSettings(openInNewTab?: boolean): void;
|
|
116
|
+
export declare function getUserProfileLink(userDid: string, locale?: string): string;
|
package/es/libs/util.js
CHANGED
|
@@ -4,7 +4,7 @@ import trimEnd from "lodash/trimEnd";
|
|
|
4
4
|
import numbro from "numbro";
|
|
5
5
|
import stringWidth from "string-width";
|
|
6
6
|
import { defaultCountries } from "react-international-phone";
|
|
7
|
-
import { joinURL } from "ufo";
|
|
7
|
+
import { joinURL, withQuery } from "ufo";
|
|
8
8
|
import { t } from "../locales/index.js";
|
|
9
9
|
import dayjs from "./dayjs.js";
|
|
10
10
|
export const PAYMENT_KIT_DID = "z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk";
|
|
@@ -924,3 +924,12 @@ export function openDonationSettings(openInNewTab = false) {
|
|
|
924
924
|
window.open(`${window.location.origin}${mountPoint}/integrations/donations`, openInNewTab ? "_blank" : "_self");
|
|
925
925
|
}
|
|
926
926
|
}
|
|
927
|
+
export function getUserProfileLink(userDid, locale = "en") {
|
|
928
|
+
return joinURL(
|
|
929
|
+
window.location.origin,
|
|
930
|
+
withQuery(".well-known/service/user", {
|
|
931
|
+
locale,
|
|
932
|
+
did: userDid
|
|
933
|
+
})
|
|
934
|
+
);
|
|
935
|
+
}
|