@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/lib/checkout/donate.js
CHANGED
|
@@ -295,7 +295,8 @@ function CheckoutDonateInner({
|
|
|
295
295
|
onError,
|
|
296
296
|
mode,
|
|
297
297
|
inlineOptions = {},
|
|
298
|
-
theme
|
|
298
|
+
theme,
|
|
299
|
+
children
|
|
299
300
|
}) {
|
|
300
301
|
const {
|
|
301
302
|
state,
|
|
@@ -331,118 +332,136 @@ function CheckoutDonateInner({
|
|
|
331
332
|
const handlePopoverClose = () => {
|
|
332
333
|
setPopoverOpen(false);
|
|
333
334
|
};
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}) : settings.appearance.button.text]
|
|
352
|
-
})
|
|
353
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Popover, {
|
|
354
|
-
id: "mouse-over-popper",
|
|
355
|
-
open: popoverOpen,
|
|
356
|
-
anchorEl,
|
|
357
|
-
onClose: handlePopoverClose,
|
|
358
|
-
anchorOrigin: {
|
|
359
|
-
vertical: "top",
|
|
360
|
-
horizontal: "center"
|
|
361
|
-
},
|
|
362
|
-
transformOrigin: {
|
|
363
|
-
vertical: "bottom",
|
|
364
|
-
horizontal: "center"
|
|
365
|
-
},
|
|
366
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
335
|
+
const startDonate = () => {
|
|
336
|
+
setState({
|
|
337
|
+
open: true
|
|
338
|
+
});
|
|
339
|
+
};
|
|
340
|
+
const inlineRender = /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
341
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
|
|
342
|
+
size: settings.appearance?.button?.size || "medium",
|
|
343
|
+
color: settings.appearance?.button?.color || "primary",
|
|
344
|
+
variant: settings.appearance?.button?.variant || "contained",
|
|
345
|
+
...settings.appearance?.button,
|
|
346
|
+
onClick: handlePopoverOpen,
|
|
347
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
348
|
+
direction: "row",
|
|
349
|
+
alignItems: "center",
|
|
350
|
+
spacing: 0.5,
|
|
351
|
+
children: [settings.appearance.button.icon, typeof settings.appearance.button.text === "string" ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
367
352
|
sx: {
|
|
368
|
-
|
|
369
|
-
padding: "20px"
|
|
353
|
+
whiteSpace: "nowrap"
|
|
370
354
|
},
|
|
371
|
-
children:
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
},
|
|
383
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.CircularProgress, {})
|
|
384
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
385
|
-
display: "flex",
|
|
386
|
-
alignItems: "center",
|
|
387
|
-
flexDirection: "column",
|
|
388
|
-
gap: 2,
|
|
389
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
|
|
390
|
-
...inlineOptions.button,
|
|
391
|
-
onClick: () => setState({
|
|
392
|
-
open: true
|
|
393
|
-
}),
|
|
394
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
395
|
-
direction: "row",
|
|
396
|
-
alignItems: "center",
|
|
397
|
-
spacing: 0.5,
|
|
398
|
-
children: [inlineOptions?.button?.icon, typeof inlineOptions?.button?.text === "string" ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
399
|
-
sx: {
|
|
400
|
-
whiteSpace: "nowrap"
|
|
401
|
-
},
|
|
402
|
-
children: inlineOptions?.button?.text
|
|
403
|
-
}) : inlineOptions?.button?.text]
|
|
404
|
-
})
|
|
405
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(SupporterSimple, {
|
|
406
|
-
...supporters.data
|
|
407
|
-
})]
|
|
408
|
-
})]
|
|
409
|
-
})
|
|
410
|
-
})]
|
|
411
|
-
}) : /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
412
|
-
sx: {
|
|
413
|
-
width: "100%",
|
|
414
|
-
minWidth: 300,
|
|
415
|
-
maxWidth: 720
|
|
355
|
+
children: settings.appearance.button.text
|
|
356
|
+
}) : settings.appearance.button.text]
|
|
357
|
+
})
|
|
358
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Popover, {
|
|
359
|
+
id: "mouse-over-popper",
|
|
360
|
+
open: popoverOpen,
|
|
361
|
+
anchorEl,
|
|
362
|
+
onClose: handlePopoverClose,
|
|
363
|
+
anchorOrigin: {
|
|
364
|
+
vertical: "top",
|
|
365
|
+
horizontal: "center"
|
|
416
366
|
},
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
gap: {
|
|
421
|
-
xs: 1,
|
|
422
|
-
sm: 2
|
|
367
|
+
transformOrigin: {
|
|
368
|
+
vertical: "bottom",
|
|
369
|
+
horizontal: "center"
|
|
423
370
|
},
|
|
424
|
-
children:
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
371
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
372
|
+
sx: {
|
|
373
|
+
minWidth: 320,
|
|
374
|
+
padding: "20px"
|
|
375
|
+
},
|
|
376
|
+
children: [supporters.loading && /* @__PURE__ */(0, _jsxRuntime.jsx)("div", {
|
|
377
|
+
style: {
|
|
378
|
+
position: "absolute",
|
|
379
|
+
top: 0,
|
|
380
|
+
left: 0,
|
|
381
|
+
right: 0,
|
|
382
|
+
bottom: 0,
|
|
383
|
+
display: "flex",
|
|
384
|
+
justifyContent: "center",
|
|
385
|
+
alignItems: "center",
|
|
386
|
+
backgroundColor: "rgba(255, 255, 255, 0.7)"
|
|
387
|
+
},
|
|
388
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.CircularProgress, {})
|
|
389
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
390
|
+
display: "flex",
|
|
434
391
|
alignItems: "center",
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
392
|
+
flexDirection: "column",
|
|
393
|
+
gap: 2,
|
|
394
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
|
|
395
|
+
...inlineOptions.button,
|
|
396
|
+
onClick: () => startDonate(),
|
|
397
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
398
|
+
direction: "row",
|
|
399
|
+
alignItems: "center",
|
|
400
|
+
spacing: 0.5,
|
|
401
|
+
children: [inlineOptions?.button?.icon, typeof inlineOptions?.button?.text === "string" ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
402
|
+
sx: {
|
|
403
|
+
whiteSpace: "nowrap"
|
|
404
|
+
},
|
|
405
|
+
children: inlineOptions?.button?.text
|
|
406
|
+
}) : inlineOptions?.button?.text]
|
|
407
|
+
})
|
|
408
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(SupporterSimple, {
|
|
409
|
+
...supporters.data
|
|
410
|
+
})]
|
|
411
|
+
})]
|
|
412
|
+
})
|
|
413
|
+
})]
|
|
414
|
+
});
|
|
415
|
+
const defaultRender = /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
416
|
+
sx: {
|
|
417
|
+
width: "100%",
|
|
418
|
+
minWidth: 300,
|
|
419
|
+
maxWidth: 720
|
|
420
|
+
},
|
|
421
|
+
display: "flex",
|
|
422
|
+
flexDirection: "column",
|
|
423
|
+
alignItems: "center",
|
|
424
|
+
gap: {
|
|
425
|
+
xs: 1,
|
|
426
|
+
sm: 2
|
|
427
|
+
},
|
|
428
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
|
|
429
|
+
size: settings.appearance?.button?.size || "medium",
|
|
430
|
+
color: settings.appearance?.button?.color || "primary",
|
|
431
|
+
variant: settings.appearance?.button?.variant || "contained",
|
|
432
|
+
...settings.appearance?.button,
|
|
433
|
+
onClick: () => startDonate(),
|
|
434
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
435
|
+
direction: "row",
|
|
436
|
+
alignItems: "center",
|
|
437
|
+
spacing: 0.5,
|
|
438
|
+
children: [settings.appearance.button.icon, typeof settings.appearance.button.text === "string" ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
439
|
+
children: settings.appearance.button.text
|
|
440
|
+
}) : settings.appearance.button.text]
|
|
441
|
+
})
|
|
442
|
+
}), supporters.data && settings.appearance.history.variant === "avatar" && /* @__PURE__ */(0, _jsxRuntime.jsx)(SupporterAvatar, {
|
|
443
|
+
...supporters.data
|
|
444
|
+
}), supporters.data && settings.appearance.history.variant === "table" && /* @__PURE__ */(0, _jsxRuntime.jsx)(SupporterTable, {
|
|
445
|
+
...supporters.data
|
|
446
|
+
})]
|
|
447
|
+
});
|
|
448
|
+
const renderInnerView = () => {
|
|
449
|
+
if (mode === "inline") {
|
|
450
|
+
return inlineRender;
|
|
451
|
+
}
|
|
452
|
+
if (mode === "custom") {
|
|
453
|
+
return children && typeof children === "function" ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
454
|
+
children: children(startDonate, `${(0, _util.formatAmount)(supporters.data?.totalAmount || "0", supporters.data?.currency?.decimal)} ${supporters.data?.currency?.symbol}`, supporters.data || {})
|
|
455
|
+
}) : /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
456
|
+
children: ["Please provide a valid render function ", /* @__PURE__ */(0, _jsxRuntime.jsx)("pre", {
|
|
457
|
+
children: "(openDonate, donateTotalAmount, supporters) => ReactNode"
|
|
458
|
+
})]
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
return defaultRender;
|
|
462
|
+
};
|
|
463
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
464
|
+
children: [renderInnerView(), donation.data && /* @__PURE__ */(0, _jsxRuntime.jsx)(_Dialog.default, {
|
|
446
465
|
open: state.open,
|
|
447
466
|
title: settings.title,
|
|
448
467
|
maxWidth: "md",
|
|
@@ -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;
|
|
@@ -17,7 +17,6 @@ var _util = require("@ocap/util");
|
|
|
17
17
|
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
18
18
|
var _payment = require("../contexts/payment");
|
|
19
19
|
var _util2 = require("../libs/util");
|
|
20
|
-
var _amount = _interopRequireDefault(require("../payment/amount"));
|
|
21
20
|
var _mobile = require("../hooks/mobile");
|
|
22
21
|
var _truncatedText = _interopRequireDefault(require("./truncated-text"));
|
|
23
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -48,14 +47,16 @@ const groupItemsByRecurring = (items, currency) => {
|
|
|
48
47
|
PricingTable.defaultProps = {
|
|
49
48
|
alignItems: "center",
|
|
50
49
|
mode: "checkout",
|
|
51
|
-
interval: ""
|
|
50
|
+
interval: "",
|
|
51
|
+
hideCurrency: false
|
|
52
52
|
};
|
|
53
53
|
function PricingTable({
|
|
54
54
|
table,
|
|
55
55
|
alignItems,
|
|
56
56
|
interval,
|
|
57
57
|
mode,
|
|
58
|
-
onSelect
|
|
58
|
+
onSelect,
|
|
59
|
+
hideCurrency
|
|
59
60
|
}) {
|
|
60
61
|
const {
|
|
61
62
|
t,
|
|
@@ -187,10 +188,10 @@ function PricingTable({
|
|
|
187
188
|
max-width: 360px !important;
|
|
188
189
|
}
|
|
189
190
|
.price-table-wrap:has(> div:nth-child(2)) {
|
|
190
|
-
max-width:
|
|
191
|
+
max-width: 780px !important;
|
|
191
192
|
}
|
|
192
193
|
.price-table-wrap:has(> div:nth-child(3)) {
|
|
193
|
-
max-width:
|
|
194
|
+
max-width: 1200px !important;
|
|
194
195
|
}
|
|
195
196
|
}
|
|
196
197
|
`;
|
|
@@ -274,7 +275,7 @@ function PricingTable({
|
|
|
274
275
|
children: (0, _util2.formatRecurring)(recurring[x], true, "", locale)
|
|
275
276
|
}, x))
|
|
276
277
|
})
|
|
277
|
-
}), currencyList.length > 0 && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Select, {
|
|
278
|
+
}), currencyList.length > 0 && !hideCurrency && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Select, {
|
|
278
279
|
value: currency?.id,
|
|
279
280
|
onChange: e => setCurrency(currencyList.find(v => v?.id === e.target.value)),
|
|
280
281
|
size: "small",
|
|
@@ -306,6 +307,7 @@ function PricingTable({
|
|
|
306
307
|
if (mode === "select") {
|
|
307
308
|
action = x.is_selected ? t("payment.checkout.selected") : t("payment.checkout.select");
|
|
308
309
|
}
|
|
310
|
+
const [amount, unit] = (0, _util2.formatPriceAmount)(x.price, currency, x.product.unit_label).split("/");
|
|
309
311
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
310
312
|
padding: 4,
|
|
311
313
|
spacing: 2,
|
|
@@ -327,13 +329,12 @@ function PricingTable({
|
|
|
327
329
|
},
|
|
328
330
|
width: {
|
|
329
331
|
xs: "100%",
|
|
330
|
-
md: "
|
|
332
|
+
md: "360px"
|
|
331
333
|
},
|
|
332
334
|
maxWidth: "360px",
|
|
333
335
|
minWidth: "300px",
|
|
334
336
|
padding: "20px",
|
|
335
|
-
position: "relative"
|
|
336
|
-
height: "fit-content"
|
|
337
|
+
position: "relative"
|
|
337
338
|
},
|
|
338
339
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
339
340
|
textAlign: "center",
|
|
@@ -352,7 +353,7 @@ function PricingTable({
|
|
|
352
353
|
justifyContent: "space-between"
|
|
353
354
|
},
|
|
354
355
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
355
|
-
color: "text.
|
|
356
|
+
color: "text.secondary",
|
|
356
357
|
fontWeight: 600,
|
|
357
358
|
sx: {
|
|
358
359
|
fontSize: "18px !important",
|
|
@@ -365,7 +366,7 @@ function PricingTable({
|
|
|
365
366
|
})
|
|
366
367
|
}), x.is_highlight && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Chip, {
|
|
367
368
|
label: x.highlight_text,
|
|
368
|
-
color: "
|
|
369
|
+
color: "primary",
|
|
369
370
|
size: "small",
|
|
370
371
|
sx: {
|
|
371
372
|
position: "absolute",
|
|
@@ -373,14 +374,28 @@ function PricingTable({
|
|
|
373
374
|
right: "20px"
|
|
374
375
|
}
|
|
375
376
|
})]
|
|
376
|
-
}), /* @__PURE__ */(0, _jsxRuntime.
|
|
377
|
-
|
|
377
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
378
|
+
component: "div",
|
|
378
379
|
sx: {
|
|
379
380
|
my: 0,
|
|
380
|
-
|
|
381
|
-
fontSize: "
|
|
382
|
-
|
|
383
|
-
|
|
381
|
+
fontWeight: "700",
|
|
382
|
+
fontSize: "32px",
|
|
383
|
+
letterSpacing: "-0.03rem",
|
|
384
|
+
fontVariantNumeric: "tabular-nums",
|
|
385
|
+
display: "flex",
|
|
386
|
+
alignItems: "baseline",
|
|
387
|
+
gap: "4px",
|
|
388
|
+
flexWrap: "wrap"
|
|
389
|
+
},
|
|
390
|
+
children: [amount, unit ? /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
391
|
+
sx: {
|
|
392
|
+
fontSize: "16px",
|
|
393
|
+
fontWeight: "400",
|
|
394
|
+
color: "text.secondary",
|
|
395
|
+
textAlign: "left"
|
|
396
|
+
},
|
|
397
|
+
children: ["/ ", unit]
|
|
398
|
+
}) : ""]
|
|
384
399
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
385
400
|
color: "text.secondary",
|
|
386
401
|
sx: {
|
|
@@ -482,7 +497,7 @@ function Subscribe({
|
|
|
482
497
|
fullWidth: true,
|
|
483
498
|
size: "medium",
|
|
484
499
|
variant: "contained",
|
|
485
|
-
color:
|
|
500
|
+
color: "primary",
|
|
486
501
|
sx: {
|
|
487
502
|
fontSize: "16px",
|
|
488
503
|
padding: "10px 20px",
|
|
@@ -67,6 +67,7 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
67
67
|
currency_id,
|
|
68
68
|
subscription_id,
|
|
69
69
|
include_staking,
|
|
70
|
+
include_return_staking,
|
|
70
71
|
include_recovered_from,
|
|
71
72
|
onTableDataChange
|
|
72
73
|
} = props;
|
|
@@ -93,6 +94,7 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
93
94
|
currency_id,
|
|
94
95
|
subscription_id,
|
|
95
96
|
include_staking,
|
|
97
|
+
include_return_staking,
|
|
96
98
|
include_recovered_from,
|
|
97
99
|
ignore_zero: true
|
|
98
100
|
}), {
|
|
@@ -135,6 +137,23 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
135
137
|
});
|
|
136
138
|
}
|
|
137
139
|
}
|
|
140
|
+
}, {
|
|
141
|
+
label: t("common.type"),
|
|
142
|
+
name: "billing_reason",
|
|
143
|
+
options: {
|
|
144
|
+
customBodyRenderLite: (_, index) => {
|
|
145
|
+
const invoice = data.list[index];
|
|
146
|
+
const link = getInvoiceLink(invoice, action);
|
|
147
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)("a", {
|
|
148
|
+
href: link.url,
|
|
149
|
+
target: link.external ? "_blank" : target,
|
|
150
|
+
rel: "noreferrer",
|
|
151
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
|
|
152
|
+
label: (0, _util.getInvoiceDescriptionAndReason)(invoice, locale)?.type
|
|
153
|
+
})
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
138
157
|
}, {
|
|
139
158
|
label: t("payment.customer.invoice.invoiceNumber"),
|
|
140
159
|
name: "number",
|
|
@@ -177,7 +196,7 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
177
196
|
href: link.url,
|
|
178
197
|
target: link.external ? "_blank" : target,
|
|
179
198
|
rel: "noreferrer",
|
|
180
|
-
children: invoice
|
|
199
|
+
children: (0, _util.getInvoiceDescriptionAndReason)(invoice, locale)?.description || invoice.id
|
|
181
200
|
});
|
|
182
201
|
}
|
|
183
202
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function usePreventWheel(): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.usePreventWheel = usePreventWheel;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
function usePreventWheel() {
|
|
9
|
+
(0, _react.useEffect)(() => {
|
|
10
|
+
const handleWheel = e => {
|
|
11
|
+
if (document.activeElement?.type === "number") {
|
|
12
|
+
e.preventDefault();
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
window.addEventListener("wheel", handleWheel, {
|
|
16
|
+
passive: false
|
|
17
|
+
});
|
|
18
|
+
return () => {
|
|
19
|
+
window.removeEventListener("wheel", handleWheel);
|
|
20
|
+
};
|
|
21
|
+
}, []);
|
|
22
|
+
}
|
package/lib/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/lib/index.js
CHANGED
|
@@ -351,5 +351,17 @@ Object.keys(_table3).forEach(function (key) {
|
|
|
351
351
|
}
|
|
352
352
|
});
|
|
353
353
|
});
|
|
354
|
+
var _scroll = require("./hooks/scroll");
|
|
355
|
+
Object.keys(_scroll).forEach(function (key) {
|
|
356
|
+
if (key === "default" || key === "__esModule") return;
|
|
357
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
358
|
+
if (key in exports && exports[key] === _scroll[key]) return;
|
|
359
|
+
Object.defineProperty(exports, key, {
|
|
360
|
+
enumerable: true,
|
|
361
|
+
get: function () {
|
|
362
|
+
return _scroll[key];
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
});
|
|
354
366
|
var _locales = require("./locales");
|
|
355
367
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/lib/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/lib/libs/util.js
CHANGED
|
@@ -30,6 +30,7 @@ exports.formatUpsellSaving = formatUpsellSaving;
|
|
|
30
30
|
exports.getCheckoutAmount = getCheckoutAmount;
|
|
31
31
|
exports.getCustomerAvatar = getCustomerAvatar;
|
|
32
32
|
exports.getFreeTrialTime = getFreeTrialTime;
|
|
33
|
+
exports.getInvoiceDescriptionAndReason = getInvoiceDescriptionAndReason;
|
|
33
34
|
exports.getInvoiceStatusColor = getInvoiceStatusColor;
|
|
34
35
|
exports.getPaymentIntentStatusColor = getPaymentIntentStatusColor;
|
|
35
36
|
exports.getPayoutStatusColor = getPayoutStatusColor;
|
|
@@ -45,6 +46,7 @@ exports.getSubscriptionStatusColor = getSubscriptionStatusColor;
|
|
|
45
46
|
exports.getTxLink = exports.getSubscriptionTimeSummary = void 0;
|
|
46
47
|
exports.getWebhookStatusColor = getWebhookStatusColor;
|
|
47
48
|
exports.getWordBreakStyle = getWordBreakStyle;
|
|
49
|
+
exports.hasDelegateTxHash = hasDelegateTxHash;
|
|
48
50
|
exports.isMobileSafari = isMobileSafari;
|
|
49
51
|
exports.isPaymentKitMounted = void 0;
|
|
50
52
|
exports.isValidCountry = isValidCountry;
|
|
@@ -827,6 +829,13 @@ const flattenPaymentMethods = (methods = []) => {
|
|
|
827
829
|
};
|
|
828
830
|
exports.flattenPaymentMethods = flattenPaymentMethods;
|
|
829
831
|
const getTxLink = (method, details) => {
|
|
832
|
+
if (!details) {
|
|
833
|
+
return {
|
|
834
|
+
text: "N/A",
|
|
835
|
+
link: "",
|
|
836
|
+
gas: ""
|
|
837
|
+
};
|
|
838
|
+
}
|
|
830
839
|
if (method.type === "arcblock" && details.arcblock?.tx_hash) {
|
|
831
840
|
return {
|
|
832
841
|
link: (0, _ufo.joinURL)(method.settings.arcblock?.explorer_host, "/txs", details.arcblock?.tx_hash),
|
|
@@ -1014,4 +1023,52 @@ function truncateText(text, maxLength, useWidth = false) {
|
|
|
1014
1023
|
function getCustomerAvatar(did, updated_at, imageSize = 48) {
|
|
1015
1024
|
const updated = typeof updated_at === "number" ? updated_at : (0, _dayjs.default)(updated_at).unix();
|
|
1016
1025
|
return `/.well-known/service/user/avatar/${did}?imageFilter=resize&w=${imageSize}&h=${imageSize}&updateAt=${updated || (0, _dayjs.default)().unix()}`;
|
|
1026
|
+
}
|
|
1027
|
+
function hasDelegateTxHash(details, paymentMethod) {
|
|
1028
|
+
return paymentMethod?.type && ["arcblock", "ethereum"].includes(paymentMethod?.type) &&
|
|
1029
|
+
// @ts-ignore
|
|
1030
|
+
details?.[paymentMethod?.type]?.tx_hash;
|
|
1031
|
+
}
|
|
1032
|
+
function getInvoiceDescriptionAndReason(invoice, locale = "en") {
|
|
1033
|
+
const {
|
|
1034
|
+
billing_reason: reason,
|
|
1035
|
+
description
|
|
1036
|
+
} = invoice;
|
|
1037
|
+
const reasonMap = {
|
|
1038
|
+
subscription_create: (0, _locales.t)("payment.invoice.reason.creation", locale),
|
|
1039
|
+
subscription_cycle: (0, _locales.t)("payment.invoice.reason.cycle", locale),
|
|
1040
|
+
subscription_update: (0, _locales.t)("payment.invoice.reason.update", locale),
|
|
1041
|
+
subscription_recover: (0, _locales.t)("payment.invoice.reason.recover", locale),
|
|
1042
|
+
subscription_threshold: (0, _locales.t)("payment.invoice.reason.threshold", locale),
|
|
1043
|
+
subscription_cancel: (0, _locales.t)("payment.invoice.reason.cancel", locale),
|
|
1044
|
+
manual: (0, _locales.t)("payment.invoice.reason.manual", locale),
|
|
1045
|
+
upcoming: (0, _locales.t)("payment.invoice.reason.upcoming", locale),
|
|
1046
|
+
slash_stake: (0, _locales.t)("payment.invoice.reason.slashStake", locale),
|
|
1047
|
+
stake: (0, _locales.t)("payment.invoice.reason.stake", locale),
|
|
1048
|
+
return_stake: (0, _locales.t)("payment.invoice.reason.returnStake", locale),
|
|
1049
|
+
recharge: (0, _locales.t)("payment.invoice.reason.recharge", locale)
|
|
1050
|
+
};
|
|
1051
|
+
let invoiceType = (0, _locales.t)("payment.invoice.reason.payment", locale);
|
|
1052
|
+
if (reason.includes("stake") || reason.includes("recharge")) {
|
|
1053
|
+
invoiceType = reasonMap[reason];
|
|
1054
|
+
}
|
|
1055
|
+
if (description?.startsWith("Subscription ") || description?.startsWith("Slash stake")) {
|
|
1056
|
+
return {
|
|
1057
|
+
description: reasonMap[reason],
|
|
1058
|
+
reason: reasonMap[reason],
|
|
1059
|
+
type: invoiceType
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
const descMap = {
|
|
1063
|
+
"Stake for subscription plan change": (0, _locales.t)("payment.invoice.reason.stakeForChangePlan", locale),
|
|
1064
|
+
"Stake for subscription payment change": (0, _locales.t)("payment.invoice.reason.stakeForChangePayment", locale),
|
|
1065
|
+
"Stake for subscription": (0, _locales.t)("payment.invoice.reason.staking", locale),
|
|
1066
|
+
"Return Subscription staking": (0, _locales.t)("payment.invoice.reason.returnStake", locale),
|
|
1067
|
+
"Recharge for subscription": (0, _locales.t)("payment.invoice.reason.rechargeForSubscription", locale)
|
|
1068
|
+
};
|
|
1069
|
+
return {
|
|
1070
|
+
description: descMap[description] || description,
|
|
1071
|
+
reason: reasonMap[reason] || reason,
|
|
1072
|
+
type: invoiceType
|
|
1073
|
+
};
|
|
1017
1074
|
}
|
package/lib/locales/en.js
CHANGED
|
@@ -95,7 +95,9 @@ module.exports = (0, _flat.default)({
|
|
|
95
95
|
quantityLimitPerCheckout: "Exceed purchase limit",
|
|
96
96
|
quantityNotEnough: "Exceed inventory",
|
|
97
97
|
amountPrecisionLimit: "Amount decimal places must be less than or equal to {precision}",
|
|
98
|
-
saveAsDefaultPriceSuccess: "Set default price successfully"
|
|
98
|
+
saveAsDefaultPriceSuccess: "Set default price successfully",
|
|
99
|
+
stakeAmount: "Stake Amount",
|
|
100
|
+
slashStakeAmount: "Slash Stake Amount"
|
|
99
101
|
},
|
|
100
102
|
payment: {
|
|
101
103
|
checkout: {
|
|
@@ -312,7 +314,14 @@ module.exports = (0, _flat.default)({
|
|
|
312
314
|
cancel: "Subscription cancel",
|
|
313
315
|
manual: "Manual invoice",
|
|
314
316
|
upcoming: "Upcoming invoice",
|
|
315
|
-
slashStake: "Slash stake"
|
|
317
|
+
slashStake: "Slash stake",
|
|
318
|
+
stake: "Stake",
|
|
319
|
+
payment: "Payment",
|
|
320
|
+
returnStake: "Return stake",
|
|
321
|
+
stakeForChangePlan: "Subscription plan update",
|
|
322
|
+
stakeForChangePayment: "Subscription payment method update",
|
|
323
|
+
recharge: "Recharge",
|
|
324
|
+
rechargeForSubscription: "Subscription recharge"
|
|
316
325
|
}
|
|
317
326
|
}
|
|
318
327
|
},
|