@blocklet/payment-react 1.15.33 → 1.15.35
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 +119 -94
- package/es/components/pricing-table.d.ts +3 -1
- package/es/components/pricing-table.js +39 -16
- package/es/history/invoice/list.d.ts +1 -0
- package/es/history/invoice/list.js +15 -1
- package/es/hooks/scroll.d.ts +1 -0
- package/es/hooks/scroll.js +14 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/libs/util.d.ts +7 -1
- package/es/libs/util.js +47 -0
- package/es/locales/en.js +11 -2
- package/es/locales/zh.js +12 -3
- package/es/payment/product-donation.js +2 -0
- package/lib/checkout/donate.d.ts +2 -1
- package/lib/checkout/donate.js +127 -108
- package/lib/components/pricing-table.d.ts +3 -1
- package/lib/components/pricing-table.js +33 -18
- package/lib/history/invoice/list.d.ts +1 -0
- package/lib/history/invoice/list.js +20 -1
- package/lib/hooks/scroll.d.ts +1 -0
- package/lib/hooks/scroll.js +22 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +12 -0
- package/lib/libs/util.d.ts +7 -1
- package/lib/libs/util.js +57 -0
- package/lib/locales/en.js +11 -2
- package/lib/locales/zh.js +12 -3
- package/lib/payment/product-donation.js +2 -0
- package/package.json +3 -3
- package/src/checkout/donate.tsx +127 -95
- package/src/components/pricing-table.tsx +34 -14
- package/src/history/invoice/list.tsx +20 -1
- package/src/hooks/scroll.ts +16 -0
- package/src/index.ts +1 -0
- package/src/libs/util.ts +56 -0
- package/src/locales/en.tsx +9 -0
- package/src/locales/zh.tsx +10 -1
- package/src/payment/product-donation.tsx +2 -0
package/es/checkout/donate.d.ts
CHANGED
|
@@ -16,11 +16,12 @@ export type DonateProps = Pick<CheckoutProps, 'onPaid' | 'onError'> & {
|
|
|
16
16
|
settings: DonationSettings;
|
|
17
17
|
livemode?: boolean;
|
|
18
18
|
timeout?: number;
|
|
19
|
-
mode?: 'inline' | 'default';
|
|
19
|
+
mode?: 'inline' | 'default' | 'custom';
|
|
20
20
|
inlineOptions?: {
|
|
21
21
|
button?: ButtonType;
|
|
22
22
|
};
|
|
23
23
|
theme?: 'default' | 'inherit' | PaymentThemeOptions;
|
|
24
|
+
children?: (openDialog: () => void, donateTotalAmount: string, supporters: DonateHistory) => React.ReactNode;
|
|
24
25
|
};
|
|
25
26
|
declare function CheckoutDonate(props: DonateProps): import("react").JSX.Element;
|
|
26
27
|
declare namespace CheckoutDonate {
|
package/es/checkout/donate.js
CHANGED
|
@@ -224,7 +224,8 @@ function CheckoutDonateInner({
|
|
|
224
224
|
onError,
|
|
225
225
|
mode,
|
|
226
226
|
inlineOptions = {},
|
|
227
|
-
theme
|
|
227
|
+
theme,
|
|
228
|
+
children
|
|
228
229
|
}) {
|
|
229
230
|
const { state, setState, donation, supporters } = useDonation(settings, livemode, mode);
|
|
230
231
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
@@ -250,102 +251,126 @@ function CheckoutDonateInner({
|
|
|
250
251
|
const handlePopoverClose = () => {
|
|
251
252
|
setPopoverOpen(false);
|
|
252
253
|
};
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
color: settings.appearance?.button?.color || "primary",
|
|
260
|
-
variant: settings.appearance?.button?.variant || "contained",
|
|
261
|
-
...settings.appearance?.button,
|
|
262
|
-
onClick: handlePopoverOpen,
|
|
263
|
-
children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
|
|
264
|
-
settings.appearance.button.icon,
|
|
265
|
-
typeof settings.appearance.button.text === "string" ? /* @__PURE__ */ jsx(Typography, { sx: { whiteSpace: "nowrap" }, children: settings.appearance.button.text }) : settings.appearance.button.text
|
|
266
|
-
] })
|
|
267
|
-
}
|
|
268
|
-
),
|
|
269
|
-
/* @__PURE__ */ jsx(
|
|
270
|
-
Popover,
|
|
271
|
-
{
|
|
272
|
-
id: "mouse-over-popper",
|
|
273
|
-
open: popoverOpen,
|
|
274
|
-
anchorEl,
|
|
275
|
-
onClose: handlePopoverClose,
|
|
276
|
-
anchorOrigin: {
|
|
277
|
-
vertical: "top",
|
|
278
|
-
horizontal: "center"
|
|
279
|
-
},
|
|
280
|
-
transformOrigin: {
|
|
281
|
-
vertical: "bottom",
|
|
282
|
-
horizontal: "center"
|
|
283
|
-
},
|
|
284
|
-
children: /* @__PURE__ */ jsxs(
|
|
285
|
-
Box,
|
|
286
|
-
{
|
|
287
|
-
sx: {
|
|
288
|
-
minWidth: 320,
|
|
289
|
-
padding: "20px"
|
|
290
|
-
},
|
|
291
|
-
children: [
|
|
292
|
-
supporters.loading && /* @__PURE__ */ jsx(
|
|
293
|
-
"div",
|
|
294
|
-
{
|
|
295
|
-
style: {
|
|
296
|
-
position: "absolute",
|
|
297
|
-
top: 0,
|
|
298
|
-
left: 0,
|
|
299
|
-
right: 0,
|
|
300
|
-
bottom: 0,
|
|
301
|
-
display: "flex",
|
|
302
|
-
justifyContent: "center",
|
|
303
|
-
alignItems: "center",
|
|
304
|
-
backgroundColor: "rgba(255, 255, 255, 0.7)"
|
|
305
|
-
},
|
|
306
|
-
children: /* @__PURE__ */ jsx(CircularProgress, {})
|
|
307
|
-
}
|
|
308
|
-
),
|
|
309
|
-
/* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", flexDirection: "column", gap: 2, children: [
|
|
310
|
-
/* @__PURE__ */ jsx(Button, { ...inlineOptions.button, onClick: () => setState({ open: true }), children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
|
|
311
|
-
inlineOptions?.button?.icon,
|
|
312
|
-
typeof inlineOptions?.button?.text === "string" ? /* @__PURE__ */ jsx(Typography, { sx: { whiteSpace: "nowrap" }, children: inlineOptions?.button?.text }) : inlineOptions?.button?.text
|
|
313
|
-
] }) }),
|
|
314
|
-
/* @__PURE__ */ jsx(SupporterSimple, { ...supporters.data })
|
|
315
|
-
] })
|
|
316
|
-
]
|
|
317
|
-
}
|
|
318
|
-
)
|
|
319
|
-
}
|
|
320
|
-
)
|
|
321
|
-
] }) : /* @__PURE__ */ jsxs(
|
|
322
|
-
Box,
|
|
254
|
+
const startDonate = () => {
|
|
255
|
+
setState({ open: true });
|
|
256
|
+
};
|
|
257
|
+
const inlineRender = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
258
|
+
/* @__PURE__ */ jsx(
|
|
259
|
+
Button,
|
|
323
260
|
{
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
children: [
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
size: settings.appearance?.button?.size || "medium",
|
|
334
|
-
color: settings.appearance?.button?.color || "primary",
|
|
335
|
-
variant: settings.appearance?.button?.variant || "contained",
|
|
336
|
-
...settings.appearance?.button,
|
|
337
|
-
onClick: () => setState({ open: true }),
|
|
338
|
-
children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
|
|
339
|
-
settings.appearance.button.icon,
|
|
340
|
-
typeof settings.appearance.button.text === "string" ? /* @__PURE__ */ jsx(Typography, { children: settings.appearance.button.text }) : settings.appearance.button.text
|
|
341
|
-
] })
|
|
342
|
-
}
|
|
343
|
-
),
|
|
344
|
-
supporters.data && settings.appearance.history.variant === "avatar" && /* @__PURE__ */ jsx(SupporterAvatar, { ...supporters.data }),
|
|
345
|
-
supporters.data && settings.appearance.history.variant === "table" && /* @__PURE__ */ jsx(SupporterTable, { ...supporters.data })
|
|
346
|
-
]
|
|
261
|
+
size: settings.appearance?.button?.size || "medium",
|
|
262
|
+
color: settings.appearance?.button?.color || "primary",
|
|
263
|
+
variant: settings.appearance?.button?.variant || "contained",
|
|
264
|
+
...settings.appearance?.button,
|
|
265
|
+
onClick: handlePopoverOpen,
|
|
266
|
+
children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
|
|
267
|
+
settings.appearance.button.icon,
|
|
268
|
+
typeof settings.appearance.button.text === "string" ? /* @__PURE__ */ jsx(Typography, { sx: { whiteSpace: "nowrap" }, children: settings.appearance.button.text }) : settings.appearance.button.text
|
|
269
|
+
] })
|
|
347
270
|
}
|
|
348
271
|
),
|
|
272
|
+
/* @__PURE__ */ jsx(
|
|
273
|
+
Popover,
|
|
274
|
+
{
|
|
275
|
+
id: "mouse-over-popper",
|
|
276
|
+
open: popoverOpen,
|
|
277
|
+
anchorEl,
|
|
278
|
+
onClose: handlePopoverClose,
|
|
279
|
+
anchorOrigin: {
|
|
280
|
+
vertical: "top",
|
|
281
|
+
horizontal: "center"
|
|
282
|
+
},
|
|
283
|
+
transformOrigin: {
|
|
284
|
+
vertical: "bottom",
|
|
285
|
+
horizontal: "center"
|
|
286
|
+
},
|
|
287
|
+
children: /* @__PURE__ */ jsxs(
|
|
288
|
+
Box,
|
|
289
|
+
{
|
|
290
|
+
sx: {
|
|
291
|
+
minWidth: 320,
|
|
292
|
+
padding: "20px"
|
|
293
|
+
},
|
|
294
|
+
children: [
|
|
295
|
+
supporters.loading && /* @__PURE__ */ jsx(
|
|
296
|
+
"div",
|
|
297
|
+
{
|
|
298
|
+
style: {
|
|
299
|
+
position: "absolute",
|
|
300
|
+
top: 0,
|
|
301
|
+
left: 0,
|
|
302
|
+
right: 0,
|
|
303
|
+
bottom: 0,
|
|
304
|
+
display: "flex",
|
|
305
|
+
justifyContent: "center",
|
|
306
|
+
alignItems: "center",
|
|
307
|
+
backgroundColor: "rgba(255, 255, 255, 0.7)"
|
|
308
|
+
},
|
|
309
|
+
children: /* @__PURE__ */ jsx(CircularProgress, {})
|
|
310
|
+
}
|
|
311
|
+
),
|
|
312
|
+
/* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", flexDirection: "column", gap: 2, children: [
|
|
313
|
+
/* @__PURE__ */ jsx(Button, { ...inlineOptions.button, onClick: () => startDonate(), children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
|
|
314
|
+
inlineOptions?.button?.icon,
|
|
315
|
+
typeof inlineOptions?.button?.text === "string" ? /* @__PURE__ */ jsx(Typography, { sx: { whiteSpace: "nowrap" }, children: inlineOptions?.button?.text }) : inlineOptions?.button?.text
|
|
316
|
+
] }) }),
|
|
317
|
+
/* @__PURE__ */ jsx(SupporterSimple, { ...supporters.data })
|
|
318
|
+
] })
|
|
319
|
+
]
|
|
320
|
+
}
|
|
321
|
+
)
|
|
322
|
+
}
|
|
323
|
+
)
|
|
324
|
+
] });
|
|
325
|
+
const defaultRender = /* @__PURE__ */ jsxs(
|
|
326
|
+
Box,
|
|
327
|
+
{
|
|
328
|
+
sx: { width: "100%", minWidth: 300, maxWidth: 720 },
|
|
329
|
+
display: "flex",
|
|
330
|
+
flexDirection: "column",
|
|
331
|
+
alignItems: "center",
|
|
332
|
+
gap: { xs: 1, sm: 2 },
|
|
333
|
+
children: [
|
|
334
|
+
/* @__PURE__ */ jsx(
|
|
335
|
+
Button,
|
|
336
|
+
{
|
|
337
|
+
size: settings.appearance?.button?.size || "medium",
|
|
338
|
+
color: settings.appearance?.button?.color || "primary",
|
|
339
|
+
variant: settings.appearance?.button?.variant || "contained",
|
|
340
|
+
...settings.appearance?.button,
|
|
341
|
+
onClick: () => startDonate(),
|
|
342
|
+
children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
|
|
343
|
+
settings.appearance.button.icon,
|
|
344
|
+
typeof settings.appearance.button.text === "string" ? /* @__PURE__ */ jsx(Typography, { children: settings.appearance.button.text }) : settings.appearance.button.text
|
|
345
|
+
] })
|
|
346
|
+
}
|
|
347
|
+
),
|
|
348
|
+
supporters.data && settings.appearance.history.variant === "avatar" && /* @__PURE__ */ jsx(SupporterAvatar, { ...supporters.data }),
|
|
349
|
+
supporters.data && settings.appearance.history.variant === "table" && /* @__PURE__ */ jsx(SupporterTable, { ...supporters.data })
|
|
350
|
+
]
|
|
351
|
+
}
|
|
352
|
+
);
|
|
353
|
+
const renderInnerView = () => {
|
|
354
|
+
if (mode === "inline") {
|
|
355
|
+
return inlineRender;
|
|
356
|
+
}
|
|
357
|
+
if (mode === "custom") {
|
|
358
|
+
return children && typeof children === "function" ? /* @__PURE__ */ jsx(Fragment, { children: children(
|
|
359
|
+
startDonate,
|
|
360
|
+
`${formatAmount(
|
|
361
|
+
supporters.data?.totalAmount || "0",
|
|
362
|
+
supporters.data?.currency?.decimal
|
|
363
|
+
)} ${supporters.data?.currency?.symbol}`,
|
|
364
|
+
supporters.data || {}
|
|
365
|
+
) }) : /* @__PURE__ */ jsxs(Typography, { children: [
|
|
366
|
+
"Please provide a valid render function ",
|
|
367
|
+
/* @__PURE__ */ jsx("pre", { children: "(openDonate, donateTotalAmount, supporters) => ReactNode" })
|
|
368
|
+
] });
|
|
369
|
+
}
|
|
370
|
+
return defaultRender;
|
|
371
|
+
};
|
|
372
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
373
|
+
renderInnerView(),
|
|
349
374
|
donation.data && /* @__PURE__ */ jsx(
|
|
350
375
|
Dialog,
|
|
351
376
|
{
|
|
@@ -6,13 +6,15 @@ type Props = {
|
|
|
6
6
|
alignItems?: 'center' | 'left';
|
|
7
7
|
mode?: 'checkout' | 'select';
|
|
8
8
|
interval?: string;
|
|
9
|
+
hideCurrency?: boolean;
|
|
9
10
|
};
|
|
10
|
-
declare function PricingTable({ table, alignItems, interval, mode, onSelect }: Props): import("react").JSX.Element;
|
|
11
|
+
declare function PricingTable({ table, alignItems, interval, mode, onSelect, hideCurrency }: Props): import("react").JSX.Element;
|
|
11
12
|
declare namespace PricingTable {
|
|
12
13
|
var defaultProps: {
|
|
13
14
|
alignItems: string;
|
|
14
15
|
mode: string;
|
|
15
16
|
interval: string;
|
|
17
|
+
hideCurrency: boolean;
|
|
16
18
|
};
|
|
17
19
|
}
|
|
18
20
|
export default PricingTable;
|
|
@@ -31,7 +31,6 @@ import {
|
|
|
31
31
|
getPriceUintAmountByCurrency,
|
|
32
32
|
isMobileSafari
|
|
33
33
|
} from "../libs/util.js";
|
|
34
|
-
import Amount from "../payment/amount.js";
|
|
35
34
|
import { useMobile } from "../hooks/mobile.js";
|
|
36
35
|
import TruncatedText from "./truncated-text.js";
|
|
37
36
|
const sortOrder = {
|
|
@@ -58,9 +57,10 @@ const groupItemsByRecurring = (items, currency) => {
|
|
|
58
57
|
PricingTable.defaultProps = {
|
|
59
58
|
alignItems: "center",
|
|
60
59
|
mode: "checkout",
|
|
61
|
-
interval: ""
|
|
60
|
+
interval: "",
|
|
61
|
+
hideCurrency: false
|
|
62
62
|
};
|
|
63
|
-
export default function PricingTable({ table, alignItems, interval, mode, onSelect }) {
|
|
63
|
+
export default function PricingTable({ table, alignItems, interval, mode, onSelect, hideCurrency }) {
|
|
64
64
|
const { t, locale } = useLocaleContext();
|
|
65
65
|
const { isMobile } = useMobile();
|
|
66
66
|
const {
|
|
@@ -171,10 +171,10 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
|
|
|
171
171
|
max-width: 360px !important;
|
|
172
172
|
}
|
|
173
173
|
.price-table-wrap:has(> div:nth-child(2)) {
|
|
174
|
-
max-width:
|
|
174
|
+
max-width: 780px !important;
|
|
175
175
|
}
|
|
176
176
|
.price-table-wrap:has(> div:nth-child(3)) {
|
|
177
|
-
max-width:
|
|
177
|
+
max-width: 1200px !important;
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
`;
|
|
@@ -258,7 +258,7 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
|
|
|
258
258
|
))
|
|
259
259
|
}
|
|
260
260
|
) }),
|
|
261
|
-
currencyList.length > 0 && /* @__PURE__ */ jsx(
|
|
261
|
+
currencyList.length > 0 && !hideCurrency && /* @__PURE__ */ jsx(
|
|
262
262
|
Select,
|
|
263
263
|
{
|
|
264
264
|
value: currency?.id,
|
|
@@ -287,6 +287,7 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
|
|
|
287
287
|
if (mode === "select") {
|
|
288
288
|
action = x.is_selected ? t("payment.checkout.selected") : t("payment.checkout.select");
|
|
289
289
|
}
|
|
290
|
+
const [amount, unit] = formatPriceAmount(x.price, currency, x.product.unit_label).split("/");
|
|
290
291
|
return /* @__PURE__ */ jsxs(
|
|
291
292
|
Stack,
|
|
292
293
|
{
|
|
@@ -310,13 +311,12 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
|
|
|
310
311
|
},
|
|
311
312
|
width: {
|
|
312
313
|
xs: "100%",
|
|
313
|
-
md: "
|
|
314
|
+
md: "360px"
|
|
314
315
|
},
|
|
315
316
|
maxWidth: "360px",
|
|
316
317
|
minWidth: "300px",
|
|
317
318
|
padding: "20px",
|
|
318
|
-
position: "relative"
|
|
319
|
-
height: "fit-content"
|
|
319
|
+
position: "relative"
|
|
320
320
|
},
|
|
321
321
|
children: [
|
|
322
322
|
/* @__PURE__ */ jsx(Box, { textAlign: "center", children: /* @__PURE__ */ jsxs(
|
|
@@ -332,7 +332,7 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
|
|
|
332
332
|
/* @__PURE__ */ jsx(
|
|
333
333
|
Typography,
|
|
334
334
|
{
|
|
335
|
-
color: "text.
|
|
335
|
+
color: "text.secondary",
|
|
336
336
|
fontWeight: 600,
|
|
337
337
|
sx: {
|
|
338
338
|
fontSize: "18px !important",
|
|
@@ -345,7 +345,7 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
|
|
|
345
345
|
Chip,
|
|
346
346
|
{
|
|
347
347
|
label: x.highlight_text,
|
|
348
|
-
color: "
|
|
348
|
+
color: "primary",
|
|
349
349
|
size: "small",
|
|
350
350
|
sx: {
|
|
351
351
|
position: "absolute",
|
|
@@ -355,11 +355,34 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
|
|
|
355
355
|
}
|
|
356
356
|
)
|
|
357
357
|
] }),
|
|
358
|
-
/* @__PURE__ */
|
|
359
|
-
|
|
358
|
+
/* @__PURE__ */ jsxs(
|
|
359
|
+
Typography,
|
|
360
360
|
{
|
|
361
|
-
|
|
362
|
-
sx: {
|
|
361
|
+
component: "div",
|
|
362
|
+
sx: {
|
|
363
|
+
my: 0,
|
|
364
|
+
fontWeight: "700",
|
|
365
|
+
fontSize: "32px",
|
|
366
|
+
letterSpacing: "-0.03rem",
|
|
367
|
+
fontVariantNumeric: "tabular-nums",
|
|
368
|
+
display: "flex",
|
|
369
|
+
alignItems: "baseline",
|
|
370
|
+
gap: "4px",
|
|
371
|
+
flexWrap: "wrap"
|
|
372
|
+
},
|
|
373
|
+
children: [
|
|
374
|
+
amount,
|
|
375
|
+
unit ? /* @__PURE__ */ jsxs(
|
|
376
|
+
Typography,
|
|
377
|
+
{
|
|
378
|
+
sx: { fontSize: "16px", fontWeight: "400", color: "text.secondary", textAlign: "left" },
|
|
379
|
+
children: [
|
|
380
|
+
"/ ",
|
|
381
|
+
unit
|
|
382
|
+
]
|
|
383
|
+
}
|
|
384
|
+
) : ""
|
|
385
|
+
]
|
|
363
386
|
}
|
|
364
387
|
),
|
|
365
388
|
/* @__PURE__ */ jsx(
|
|
@@ -449,7 +472,7 @@ function Subscribe({ x, action, onSelect, currencyId }) {
|
|
|
449
472
|
fullWidth: true,
|
|
450
473
|
size: "medium",
|
|
451
474
|
variant: "contained",
|
|
452
|
-
color:
|
|
475
|
+
color: "primary",
|
|
453
476
|
sx: {
|
|
454
477
|
fontSize: "16px",
|
|
455
478
|
padding: "10px 20px",
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
formatError,
|
|
17
17
|
formatToDate,
|
|
18
18
|
formatToDatetime,
|
|
19
|
+
getInvoiceDescriptionAndReason,
|
|
19
20
|
getInvoiceStatusColor,
|
|
20
21
|
getPrefix,
|
|
21
22
|
getTxLink
|
|
@@ -69,6 +70,7 @@ const InvoiceTable = React.memo((props) => {
|
|
|
69
70
|
currency_id,
|
|
70
71
|
subscription_id,
|
|
71
72
|
include_staking,
|
|
73
|
+
include_return_staking,
|
|
72
74
|
include_recovered_from,
|
|
73
75
|
onTableDataChange
|
|
74
76
|
} = props;
|
|
@@ -90,6 +92,7 @@ const InvoiceTable = React.memo((props) => {
|
|
|
90
92
|
currency_id,
|
|
91
93
|
subscription_id,
|
|
92
94
|
include_staking,
|
|
95
|
+
include_return_staking,
|
|
93
96
|
include_recovered_from,
|
|
94
97
|
ignore_zero: true
|
|
95
98
|
}),
|
|
@@ -131,6 +134,17 @@ const InvoiceTable = React.memo((props) => {
|
|
|
131
134
|
}
|
|
132
135
|
}
|
|
133
136
|
},
|
|
137
|
+
{
|
|
138
|
+
label: t("common.type"),
|
|
139
|
+
name: "billing_reason",
|
|
140
|
+
options: {
|
|
141
|
+
customBodyRenderLite: (_, index) => {
|
|
142
|
+
const invoice = data.list[index];
|
|
143
|
+
const link = getInvoiceLink(invoice, action);
|
|
144
|
+
return /* @__PURE__ */ jsx("a", { href: link.url, target: link.external ? "_blank" : target, rel: "noreferrer", children: /* @__PURE__ */ jsx(Status, { label: getInvoiceDescriptionAndReason(invoice, locale)?.type }) });
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
},
|
|
134
148
|
{
|
|
135
149
|
label: t("payment.customer.invoice.invoiceNumber"),
|
|
136
150
|
name: "number",
|
|
@@ -161,7 +175,7 @@ const InvoiceTable = React.memo((props) => {
|
|
|
161
175
|
customBodyRenderLite: (val, index) => {
|
|
162
176
|
const invoice = data?.list[index];
|
|
163
177
|
const link = getInvoiceLink(invoice, action);
|
|
164
|
-
return /* @__PURE__ */ jsx("a", { href: link.url, target: link.external ? "_blank" : target, rel: "noreferrer", children: invoice
|
|
178
|
+
return /* @__PURE__ */ jsx("a", { href: link.url, target: link.external ? "_blank" : target, rel: "noreferrer", children: getInvoiceDescriptionAndReason(invoice, locale)?.description || invoice.id });
|
|
165
179
|
}
|
|
166
180
|
}
|
|
167
181
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function usePreventWheel(): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
export function usePreventWheel() {
|
|
3
|
+
useEffect(() => {
|
|
4
|
+
const handleWheel = (e) => {
|
|
5
|
+
if (document.activeElement?.type === "number") {
|
|
6
|
+
e.preventDefault();
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
window.addEventListener("wheel", handleWheel, { passive: false });
|
|
10
|
+
return () => {
|
|
11
|
+
window.removeEventListener("wheel", handleWheel);
|
|
12
|
+
};
|
|
13
|
+
}, []);
|
|
14
|
+
}
|
package/es/index.d.ts
CHANGED
|
@@ -36,5 +36,6 @@ export * from './contexts/payment';
|
|
|
36
36
|
export * from './hooks/subscription';
|
|
37
37
|
export * from './hooks/mobile';
|
|
38
38
|
export * from './hooks/table';
|
|
39
|
+
export * from './hooks/scroll';
|
|
39
40
|
export { translations, createTranslator } from './locales';
|
|
40
41
|
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, };
|
package/es/index.js
CHANGED
|
@@ -36,6 +36,7 @@ export * from "./contexts/payment.js";
|
|
|
36
36
|
export * from "./hooks/subscription.js";
|
|
37
37
|
export * from "./hooks/mobile.js";
|
|
38
38
|
export * from "./hooks/table.js";
|
|
39
|
+
export * from "./hooks/scroll.js";
|
|
39
40
|
export { translations, createTranslator } from "./locales/index.js";
|
|
40
41
|
export {
|
|
41
42
|
createLazyComponent,
|
package/es/libs/util.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { PaymentDetails, PriceCurrency, PriceRecurring, TLineItemExpanded, TPaymentCurrency, TPaymentCurrencyExpanded, TPaymentMethod, TPaymentMethodExpanded, TPrice, TProductExpanded, TSubscriptionExpanded, TSubscriptionItemExpanded } from '@blocklet/payment-types';
|
|
2
|
+
import type { PaymentDetails, PriceCurrency, PriceRecurring, TInvoiceExpanded, TLineItemExpanded, TPaymentCurrency, TPaymentCurrencyExpanded, TPaymentMethod, TPaymentMethodExpanded, TPrice, TProductExpanded, TSubscriptionExpanded, TSubscriptionItemExpanded } from '@blocklet/payment-types';
|
|
3
3
|
import { ActionProps, PricingRenderProps } from '../types';
|
|
4
4
|
export declare const PAYMENT_KIT_DID = "z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk";
|
|
5
5
|
export declare const isPaymentKitMounted: () => any;
|
|
@@ -108,3 +108,9 @@ export declare function getWordBreakStyle(value: any): 'break-word' | 'break-all
|
|
|
108
108
|
export declare function isMobileSafari(): boolean;
|
|
109
109
|
export declare function truncateText(text: string, maxLength: number, useWidth?: boolean): string;
|
|
110
110
|
export declare function getCustomerAvatar(did: string | undefined, updated_at: string | number | undefined, imageSize?: number): string;
|
|
111
|
+
export declare function hasDelegateTxHash(details: PaymentDetails, paymentMethod: TPaymentMethod): any;
|
|
112
|
+
export declare function getInvoiceDescriptionAndReason(invoice: TInvoiceExpanded, locale?: string): {
|
|
113
|
+
description: string | undefined;
|
|
114
|
+
reason: string;
|
|
115
|
+
type: string;
|
|
116
|
+
};
|
package/es/libs/util.js
CHANGED
|
@@ -669,6 +669,9 @@ export const flattenPaymentMethods = (methods = []) => {
|
|
|
669
669
|
return out;
|
|
670
670
|
};
|
|
671
671
|
export const getTxLink = (method, details) => {
|
|
672
|
+
if (!details) {
|
|
673
|
+
return { text: "N/A", link: "", gas: "" };
|
|
674
|
+
}
|
|
672
675
|
if (method.type === "arcblock" && details.arcblock?.tx_hash) {
|
|
673
676
|
return {
|
|
674
677
|
link: joinURL(method.settings.arcblock?.explorer_host, "/txs", details.arcblock?.tx_hash),
|
|
@@ -842,3 +845,47 @@ export function getCustomerAvatar(did, updated_at, imageSize = 48) {
|
|
|
842
845
|
const updated = typeof updated_at === "number" ? updated_at : dayjs(updated_at).unix();
|
|
843
846
|
return `/.well-known/service/user/avatar/${did}?imageFilter=resize&w=${imageSize}&h=${imageSize}&updateAt=${updated || dayjs().unix()}`;
|
|
844
847
|
}
|
|
848
|
+
export function hasDelegateTxHash(details, paymentMethod) {
|
|
849
|
+
return paymentMethod?.type && ["arcblock", "ethereum"].includes(paymentMethod?.type) && // @ts-ignore
|
|
850
|
+
details?.[paymentMethod?.type]?.tx_hash;
|
|
851
|
+
}
|
|
852
|
+
export function getInvoiceDescriptionAndReason(invoice, locale = "en") {
|
|
853
|
+
const { billing_reason: reason, description } = invoice;
|
|
854
|
+
const reasonMap = {
|
|
855
|
+
subscription_create: t("payment.invoice.reason.creation", locale),
|
|
856
|
+
subscription_cycle: t("payment.invoice.reason.cycle", locale),
|
|
857
|
+
subscription_update: t("payment.invoice.reason.update", locale),
|
|
858
|
+
subscription_recover: t("payment.invoice.reason.recover", locale),
|
|
859
|
+
subscription_threshold: t("payment.invoice.reason.threshold", locale),
|
|
860
|
+
subscription_cancel: t("payment.invoice.reason.cancel", locale),
|
|
861
|
+
manual: t("payment.invoice.reason.manual", locale),
|
|
862
|
+
upcoming: t("payment.invoice.reason.upcoming", locale),
|
|
863
|
+
slash_stake: t("payment.invoice.reason.slashStake", locale),
|
|
864
|
+
stake: t("payment.invoice.reason.stake", locale),
|
|
865
|
+
return_stake: t("payment.invoice.reason.returnStake", locale),
|
|
866
|
+
recharge: t("payment.invoice.reason.recharge", locale)
|
|
867
|
+
};
|
|
868
|
+
let invoiceType = t("payment.invoice.reason.payment", locale);
|
|
869
|
+
if (reason.includes("stake") || reason.includes("recharge")) {
|
|
870
|
+
invoiceType = reasonMap[reason];
|
|
871
|
+
}
|
|
872
|
+
if (description?.startsWith("Subscription ") || description?.startsWith("Slash stake")) {
|
|
873
|
+
return {
|
|
874
|
+
description: reasonMap[reason],
|
|
875
|
+
reason: reasonMap[reason],
|
|
876
|
+
type: invoiceType
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
const descMap = {
|
|
880
|
+
"Stake for subscription plan change": t("payment.invoice.reason.stakeForChangePlan", locale),
|
|
881
|
+
"Stake for subscription payment change": t("payment.invoice.reason.stakeForChangePayment", locale),
|
|
882
|
+
"Stake for subscription": t("payment.invoice.reason.staking", locale),
|
|
883
|
+
"Return Subscription staking": t("payment.invoice.reason.returnStake", locale),
|
|
884
|
+
"Recharge for subscription": t("payment.invoice.reason.rechargeForSubscription", locale)
|
|
885
|
+
};
|
|
886
|
+
return {
|
|
887
|
+
description: descMap[description] || description,
|
|
888
|
+
reason: reasonMap[reason] || reason,
|
|
889
|
+
type: invoiceType
|
|
890
|
+
};
|
|
891
|
+
}
|
package/es/locales/en.js
CHANGED
|
@@ -88,7 +88,9 @@ export default flat({
|
|
|
88
88
|
quantityLimitPerCheckout: "Exceed purchase limit",
|
|
89
89
|
quantityNotEnough: "Exceed inventory",
|
|
90
90
|
amountPrecisionLimit: "Amount decimal places must be less than or equal to {precision}",
|
|
91
|
-
saveAsDefaultPriceSuccess: "Set default price successfully"
|
|
91
|
+
saveAsDefaultPriceSuccess: "Set default price successfully",
|
|
92
|
+
stakeAmount: "Stake Amount",
|
|
93
|
+
slashStakeAmount: "Slash Stake Amount"
|
|
92
94
|
},
|
|
93
95
|
payment: {
|
|
94
96
|
checkout: {
|
|
@@ -305,7 +307,14 @@ export default flat({
|
|
|
305
307
|
cancel: "Subscription cancel",
|
|
306
308
|
manual: "Manual invoice",
|
|
307
309
|
upcoming: "Upcoming invoice",
|
|
308
|
-
slashStake: "Slash stake"
|
|
310
|
+
slashStake: "Slash stake",
|
|
311
|
+
stake: "Stake",
|
|
312
|
+
payment: "Payment",
|
|
313
|
+
returnStake: "Return stake",
|
|
314
|
+
stakeForChangePlan: "Subscription plan update",
|
|
315
|
+
stakeForChangePayment: "Subscription payment method update",
|
|
316
|
+
recharge: "Recharge",
|
|
317
|
+
rechargeForSubscription: "Subscription recharge"
|
|
309
318
|
}
|
|
310
319
|
}
|
|
311
320
|
},
|
package/es/locales/zh.js
CHANGED
|
@@ -88,7 +88,9 @@ export default flat({
|
|
|
88
88
|
quantityLimitPerCheckout: "\u8D85\u51FA\u8D2D\u4E70\u9650\u5236",
|
|
89
89
|
quantityNotEnough: "\u5E93\u5B58\u4E0D\u8DB3",
|
|
90
90
|
amountPrecisionLimit: "\u91D1\u989D\u5C0F\u6570\u4F4D\u6570\u5FC5\u987B\u5728 {precision} \u4F4D\u4EE5\u5185",
|
|
91
|
-
saveAsDefaultPriceSuccess: "\u8BBE\u7F6E\u9ED8\u8BA4\u4EF7\u683C\u6210\u529F"
|
|
91
|
+
saveAsDefaultPriceSuccess: "\u8BBE\u7F6E\u9ED8\u8BA4\u4EF7\u683C\u6210\u529F",
|
|
92
|
+
stakeAmount: "\u8D28\u62BC\u91D1\u989D",
|
|
93
|
+
slashStakeAmount: "\u7F5A\u6CA1\u91D1\u989D"
|
|
92
94
|
},
|
|
93
95
|
payment: {
|
|
94
96
|
checkout: {
|
|
@@ -298,14 +300,21 @@ export default flat({
|
|
|
298
300
|
reason: {
|
|
299
301
|
creation: "\u8BA2\u9605\u521B\u5EFA",
|
|
300
302
|
cycle: "\u81EA\u52A8\u6263\u8D39",
|
|
301
|
-
staking: "\u8BA2\u9605\u521B\u5EFA
|
|
303
|
+
staking: "\u8BA2\u9605\u521B\u5EFA",
|
|
302
304
|
update: "\u8BA2\u9605\u66F4\u65B0",
|
|
303
305
|
recover: "\u8BA2\u9605\u6062\u590D",
|
|
304
306
|
threshold: "\u7528\u91CF\u8D26\u5355",
|
|
305
307
|
cancel: "\u8BA2\u9605\u53D6\u6D88",
|
|
306
308
|
manual: "\u4EBA\u5DE5\u8D26\u5355",
|
|
307
309
|
upcoming: "\u672A\u6765\u8D26\u5355",
|
|
308
|
-
slashStake: "\u7F5A\u6CA1\u8D28\u62BC"
|
|
310
|
+
slashStake: "\u7F5A\u6CA1\u8D28\u62BC",
|
|
311
|
+
stake: "\u62BC\u91D1",
|
|
312
|
+
payment: "\u4ED8\u6B3E",
|
|
313
|
+
returnStake: "\u9000\u62BC\u91D1",
|
|
314
|
+
stakeForChangePlan: "\u8BA2\u9605\u5957\u9910\u66F4\u65B0",
|
|
315
|
+
stakeForChangePayment: "\u8BA2\u9605\u652F\u4ED8\u65B9\u5F0F\u66F4\u65B0",
|
|
316
|
+
recharge: "\u5145\u503C",
|
|
317
|
+
rechargeForSubscription: "\u8BA2\u9605\u5145\u503C"
|
|
309
318
|
}
|
|
310
319
|
}
|
|
311
320
|
},
|
|
@@ -6,6 +6,7 @@ import { useEffect } from "react";
|
|
|
6
6
|
import Switch from "../components/switch-button.js";
|
|
7
7
|
import { formatAmountPrecisionLimit } from "../libs/util.js";
|
|
8
8
|
import { usePaymentContext } from "../contexts/payment.js";
|
|
9
|
+
import { usePreventWheel } from "../hooks/scroll.js";
|
|
9
10
|
export default function ProductDonation({
|
|
10
11
|
item,
|
|
11
12
|
settings,
|
|
@@ -14,6 +15,7 @@ export default function ProductDonation({
|
|
|
14
15
|
}) {
|
|
15
16
|
const { t, locale } = useLocaleContext();
|
|
16
17
|
const { setPayable } = usePaymentContext();
|
|
18
|
+
usePreventWheel();
|
|
17
19
|
const preset = settings.amount.preset || settings.amount.presets?.[0] || "0";
|
|
18
20
|
const [state, setState] = useSetState({
|
|
19
21
|
selected: preset,
|
package/lib/checkout/donate.d.ts
CHANGED
|
@@ -16,11 +16,12 @@ export type DonateProps = Pick<CheckoutProps, 'onPaid' | 'onError'> & {
|
|
|
16
16
|
settings: DonationSettings;
|
|
17
17
|
livemode?: boolean;
|
|
18
18
|
timeout?: number;
|
|
19
|
-
mode?: 'inline' | 'default';
|
|
19
|
+
mode?: 'inline' | 'default' | 'custom';
|
|
20
20
|
inlineOptions?: {
|
|
21
21
|
button?: ButtonType;
|
|
22
22
|
};
|
|
23
23
|
theme?: 'default' | 'inherit' | PaymentThemeOptions;
|
|
24
|
+
children?: (openDialog: () => void, donateTotalAmount: string, supporters: DonateHistory) => React.ReactNode;
|
|
24
25
|
};
|
|
25
26
|
declare function CheckoutDonate(props: DonateProps): import("react").JSX.Element;
|
|
26
27
|
declare namespace CheckoutDonate {
|