@blocklet/payment-react 1.18.0 → 1.18.2

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.
Files changed (54) hide show
  1. package/es/checkout/donate.js +55 -10
  2. package/es/checkout/form.d.ts +2 -1
  3. package/es/checkout/form.js +32 -45
  4. package/es/components/payment-beneficiaries.d.ts +24 -0
  5. package/es/components/payment-beneficiaries.js +70 -0
  6. package/es/index.d.ts +2 -1
  7. package/es/index.js +3 -1
  8. package/es/locales/en.js +13 -1
  9. package/es/locales/zh.js +13 -1
  10. package/es/payment/donation-form.d.ts +24 -0
  11. package/es/payment/donation-form.js +604 -0
  12. package/es/payment/error.d.ts +1 -1
  13. package/es/payment/error.js +11 -1
  14. package/es/payment/form/index.d.ts +9 -3
  15. package/es/payment/form/index.js +60 -12
  16. package/es/payment/product-donation.js +101 -56
  17. package/es/payment/skeleton/donation.d.ts +1 -0
  18. package/es/payment/skeleton/donation.js +30 -0
  19. package/es/theme/index.js +13 -0
  20. package/es/types/index.d.ts +2 -0
  21. package/lib/checkout/donate.js +85 -10
  22. package/lib/checkout/form.d.ts +2 -1
  23. package/lib/checkout/form.js +39 -49
  24. package/lib/components/payment-beneficiaries.d.ts +24 -0
  25. package/lib/components/payment-beneficiaries.js +113 -0
  26. package/lib/index.d.ts +2 -1
  27. package/lib/index.js +8 -0
  28. package/lib/locales/en.js +13 -1
  29. package/lib/locales/zh.js +13 -1
  30. package/lib/payment/donation-form.d.ts +24 -0
  31. package/lib/payment/donation-form.js +645 -0
  32. package/lib/payment/error.d.ts +1 -1
  33. package/lib/payment/error.js +2 -2
  34. package/lib/payment/form/index.d.ts +9 -3
  35. package/lib/payment/form/index.js +60 -8
  36. package/lib/payment/product-donation.js +143 -72
  37. package/lib/payment/skeleton/donation.d.ts +1 -0
  38. package/lib/payment/skeleton/donation.js +66 -0
  39. package/lib/theme/index.js +13 -0
  40. package/lib/types/index.d.ts +2 -0
  41. package/package.json +3 -3
  42. package/src/checkout/donate.tsx +64 -11
  43. package/src/checkout/form.tsx +17 -31
  44. package/src/components/payment-beneficiaries.tsx +97 -0
  45. package/src/index.ts +2 -0
  46. package/src/locales/en.tsx +12 -0
  47. package/src/locales/zh.tsx +12 -0
  48. package/src/payment/donation-form.tsx +647 -0
  49. package/src/payment/error.tsx +13 -4
  50. package/src/payment/form/index.tsx +66 -11
  51. package/src/payment/product-donation.tsx +94 -39
  52. package/src/payment/skeleton/donation.tsx +35 -0
  53. package/src/theme/index.tsx +13 -0
  54. package/src/types/index.ts +2 -0
@@ -0,0 +1,24 @@
1
+ export interface TBeneficiary {
2
+ name: string;
3
+ address: string;
4
+ avatar?: string;
5
+ percent: number;
6
+ amount?: string;
7
+ url?: string;
8
+ type?: 'user' | 'dapp';
9
+ }
10
+ interface BenefitsProps {
11
+ data: TBeneficiary[];
12
+ currency: {
13
+ symbol: string;
14
+ decimal: number;
15
+ };
16
+ totalAmount?: string;
17
+ }
18
+ declare function PaymentBeneficiaries({ data, currency, totalAmount }: BenefitsProps): import("react").JSX.Element;
19
+ declare namespace PaymentBeneficiaries {
20
+ var defaultProps: {
21
+ totalAmount: string;
22
+ };
23
+ }
24
+ export default PaymentBeneficiaries;
@@ -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>;