@blocklet/payment-react 1.14.21 → 1.14.23

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 (137) hide show
  1. package/README.md +77 -0
  2. package/es/checkout/donate.d.ts +4 -2
  3. package/es/checkout/donate.js +13 -10
  4. package/es/checkout/form.d.ts +1 -1
  5. package/es/checkout/form.js +50 -4
  6. package/es/checkout/table.d.ts +1 -1
  7. package/es/checkout/table.js +11 -1
  8. package/es/components/blockchain/tx.js +2 -1
  9. package/es/components/country-select.d.ts +16 -0
  10. package/es/components/country-select.js +82 -0
  11. package/es/components/input.d.ts +21 -21
  12. package/es/components/input.js +43 -42
  13. package/es/components/livemode.js +1 -0
  14. package/es/components/pricing-table.js +0 -2
  15. package/es/components/status.js +2 -3
  16. package/es/components/table.d.ts +2 -0
  17. package/es/components/table.js +186 -0
  18. package/es/contexts/payment.d.ts +2 -0
  19. package/es/contexts/payment.js +5 -2
  20. package/es/history/invoice/list.d.ts +3 -1
  21. package/es/history/invoice/list.js +215 -48
  22. package/es/hooks/mobile.d.ts +4 -0
  23. package/es/hooks/mobile.js +10 -0
  24. package/es/index.d.ts +5 -1
  25. package/es/index.js +7 -1
  26. package/es/libs/util.d.ts +21 -8
  27. package/es/libs/util.js +92 -28
  28. package/es/locales/en.js +22 -7
  29. package/es/locales/index.d.ts +0 -1
  30. package/es/locales/index.js +10 -1
  31. package/es/locales/zh.js +21 -6
  32. package/es/payment/error.js +2 -2
  33. package/es/payment/footer.js +1 -1
  34. package/es/payment/form/address.d.ts +9 -2
  35. package/es/payment/form/address.js +69 -69
  36. package/es/payment/form/currency.js +39 -25
  37. package/es/payment/form/index.d.ts +1 -1
  38. package/es/payment/form/index.js +83 -81
  39. package/es/payment/form/phone.js +15 -51
  40. package/es/payment/index.d.ts +3 -10
  41. package/es/payment/index.js +295 -224
  42. package/es/payment/product-card.js +4 -4
  43. package/es/payment/product-donation.js +9 -3
  44. package/es/payment/product-item.d.ts +2 -2
  45. package/es/payment/product-item.js +120 -81
  46. package/es/payment/summary.js +188 -118
  47. package/es/theme/index.css +240 -0
  48. package/es/theme/index.d.ts +14 -0
  49. package/es/theme/index.js +256 -0
  50. package/es/theme/typography.d.ts +2 -0
  51. package/es/theme/typography.js +53 -0
  52. package/es/types/index.d.ts +16 -0
  53. package/lib/checkout/donate.d.ts +4 -2
  54. package/lib/checkout/donate.js +23 -2
  55. package/lib/checkout/form.d.ts +1 -1
  56. package/lib/checkout/form.js +60 -15
  57. package/lib/checkout/table.d.ts +1 -1
  58. package/lib/checkout/table.js +22 -1
  59. package/lib/components/blockchain/tx.js +4 -1
  60. package/lib/components/country-select.d.ts +16 -0
  61. package/lib/components/country-select.js +115 -0
  62. package/lib/components/input.d.ts +21 -21
  63. package/lib/components/input.js +21 -12
  64. package/lib/components/livemode.js +1 -0
  65. package/lib/components/pricing-table.js +0 -2
  66. package/lib/components/status.js +2 -3
  67. package/lib/components/table.d.ts +2 -0
  68. package/lib/components/table.js +220 -0
  69. package/lib/contexts/payment.d.ts +2 -0
  70. package/lib/contexts/payment.js +4 -1
  71. package/lib/history/invoice/list.d.ts +3 -1
  72. package/lib/history/invoice/list.js +290 -62
  73. package/lib/hooks/mobile.d.ts +4 -0
  74. package/lib/hooks/mobile.js +17 -0
  75. package/lib/index.d.ts +5 -1
  76. package/lib/index.js +36 -0
  77. package/lib/libs/util.d.ts +21 -8
  78. package/lib/libs/util.js +115 -37
  79. package/lib/locales/en.js +22 -7
  80. package/lib/locales/index.d.ts +0 -1
  81. package/lib/locales/index.js +14 -3
  82. package/lib/locales/zh.js +21 -6
  83. package/lib/payment/error.js +5 -1
  84. package/lib/payment/footer.js +1 -1
  85. package/lib/payment/form/address.d.ts +9 -2
  86. package/lib/payment/form/address.js +67 -59
  87. package/lib/payment/form/currency.js +31 -24
  88. package/lib/payment/form/index.d.ts +1 -1
  89. package/lib/payment/form/index.js +92 -93
  90. package/lib/payment/form/phone.js +11 -59
  91. package/lib/payment/index.d.ts +3 -10
  92. package/lib/payment/index.js +302 -225
  93. package/lib/payment/product-card.js +5 -4
  94. package/lib/payment/product-donation.js +11 -7
  95. package/lib/payment/product-item.d.ts +2 -2
  96. package/lib/payment/product-item.js +38 -19
  97. package/lib/payment/summary.js +219 -127
  98. package/lib/theme/index.css +240 -0
  99. package/lib/theme/index.d.ts +14 -0
  100. package/lib/theme/index.js +273 -0
  101. package/lib/theme/typography.d.ts +2 -0
  102. package/lib/theme/typography.js +59 -0
  103. package/lib/types/index.d.ts +16 -0
  104. package/package.json +14 -11
  105. package/src/checkout/donate.tsx +25 -11
  106. package/src/checkout/form.tsx +63 -15
  107. package/src/checkout/table.tsx +20 -1
  108. package/src/components/blockchain/tx.tsx +2 -1
  109. package/src/components/country-select.tsx +93 -0
  110. package/src/components/input.tsx +49 -46
  111. package/src/components/livemode.tsx +1 -0
  112. package/src/components/pricing-table.tsx +0 -2
  113. package/src/components/status.tsx +1 -2
  114. package/src/components/table.tsx +200 -0
  115. package/src/contexts/payment.tsx +6 -1
  116. package/src/history/invoice/list.tsx +254 -49
  117. package/src/hooks/mobile.ts +13 -0
  118. package/src/index.ts +7 -0
  119. package/src/libs/util.ts +120 -31
  120. package/src/locales/en.tsx +18 -4
  121. package/src/locales/index.tsx +10 -3
  122. package/src/locales/zh.tsx +17 -3
  123. package/src/payment/error.tsx +2 -2
  124. package/src/payment/footer.tsx +1 -1
  125. package/src/payment/form/address.tsx +56 -47
  126. package/src/payment/form/currency.tsx +29 -23
  127. package/src/payment/form/index.tsx +89 -76
  128. package/src/payment/form/phone.tsx +14 -51
  129. package/src/payment/index.tsx +298 -231
  130. package/src/payment/product-card.tsx +4 -4
  131. package/src/payment/product-donation.tsx +9 -4
  132. package/src/payment/product-item.tsx +49 -20
  133. package/src/payment/summary.tsx +191 -108
  134. package/src/theme/index.css +240 -0
  135. package/src/theme/index.tsx +271 -0
  136. package/src/theme/typography.ts +56 -0
  137. package/src/types/index.ts +17 -0
@@ -11,13 +11,16 @@ var _iconsMaterial = require("@mui/icons-material");
11
11
  var _material = require("@mui/material");
12
12
  var _system = require("@mui/system");
13
13
  var _ahooks = require("ahooks");
14
- var _react = require("react");
14
+ var _react = _interopRequireWildcard(require("react"));
15
15
  var _ufo = require("ufo");
16
16
  var _status = _interopRequireDefault(require("../../components/status"));
17
17
  var _payment = require("../../contexts/payment");
18
18
  var _subscription = require("../../hooks/subscription");
19
19
  var _api = _interopRequireDefault(require("../../libs/api"));
20
20
  var _util = require("../../libs/util");
21
+ var _table = _interopRequireDefault(require("../../components/table"));
22
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
23
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
21
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
25
  const groupByDate = items => {
23
26
  const grouped = {};
@@ -53,29 +56,227 @@ const getInvoiceLink = (invoice, action) => {
53
56
  url: (0, _util.getTxLink)(invoice.paymentMethod, invoice.metadata?.payment_details).link
54
57
  };
55
58
  };
56
- function CustomerInvoiceList({
57
- customer_id,
58
- subscription_id,
59
- currency_id,
60
- include_staking,
61
- include_recovered_from,
62
- status,
63
- pageSize,
64
- target,
65
- action
66
- }) {
67
- const size = pageSize || 10;
68
- const subscription = (0, _subscription.useSubscription)("events");
59
+ const InvoiceTable = _react.default.memo(props => {
60
+ const {
61
+ pageSize,
62
+ target,
63
+ action,
64
+ onPay,
65
+ status,
66
+ customer_id,
67
+ currency_id,
68
+ subscription_id,
69
+ include_staking,
70
+ include_recovered_from
71
+ } = props;
72
+ const listKey = "invoice-table";
69
73
  const {
70
74
  t,
71
75
  locale
72
76
  } = (0, _context.useLocaleContext)();
77
+ const [search, setSearch] = (0, _react.useState)({
78
+ pageSize: pageSize || 10,
79
+ page: 1
80
+ });
73
81
  const {
74
- connect
75
- } = (0, _payment.usePaymentContext)();
76
- const [state, setState] = (0, _ahooks.useSetState)({
77
- paying: ""
82
+ loading,
83
+ data = {
84
+ list: [],
85
+ count: 0
86
+ }
87
+ } = (0, _ahooks.useRequest)(() => fetchData({
88
+ ...search,
89
+ status,
90
+ customer_id,
91
+ currency_id,
92
+ subscription_id,
93
+ include_staking,
94
+ include_recovered_from,
95
+ ignore_zero: true
96
+ }), {
97
+ refreshDeps: [search]
78
98
  });
99
+ const columns = [{
100
+ label: t("payment.customer.invoice.invoiceNumber"),
101
+ name: "number",
102
+ options: {
103
+ customBodyRenderLite: (_, index) => {
104
+ const invoice = data?.list[index];
105
+ const link = getInvoiceLink(invoice, action);
106
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)("a", {
107
+ href: link.url,
108
+ target: link.external ? "_blank" : target,
109
+ rel: "noreferrer",
110
+ children: invoice?.number
111
+ });
112
+ }
113
+ }
114
+ }, {
115
+ label: t("common.amount"),
116
+ name: "total",
117
+ options: {
118
+ customBodyRenderLite: (_, index) => {
119
+ const invoice = data?.list[index];
120
+ const link = getInvoiceLink(invoice, action);
121
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)("a", {
122
+ href: link.url,
123
+ target: link.external ? "_blank" : target,
124
+ rel: "noreferrer",
125
+ children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
126
+ children: [(0, _util.formatBNStr)(invoice.total, invoice.paymentCurrency.decimal), "\xA0", invoice.paymentCurrency.symbol]
127
+ })
128
+ });
129
+ }
130
+ }
131
+ }, {
132
+ label: t("common.updatedAt"),
133
+ name: "name",
134
+ options: {
135
+ customBodyRenderLite: (val, index) => {
136
+ const invoice = data?.list[index];
137
+ const link = getInvoiceLink(invoice, action);
138
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)("a", {
139
+ href: link.url,
140
+ target: link.external ? "_blank" : target,
141
+ rel: "noreferrer",
142
+ children: (0, _util.formatToDate)(invoice.created_at, locale, "YYYY-MM-DD HH:mm:ss")
143
+ });
144
+ }
145
+ }
146
+ }, {
147
+ label: t("common.description"),
148
+ name: "",
149
+ options: {
150
+ sort: false,
151
+ customBodyRenderLite: (val, index) => {
152
+ const invoice = data?.list[index];
153
+ const link = getInvoiceLink(invoice, action);
154
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)("a", {
155
+ href: link.url,
156
+ target: link.external ? "_blank" : target,
157
+ rel: "noreferrer",
158
+ children: invoice.description || invoice.id
159
+ });
160
+ }
161
+ }
162
+ }, {
163
+ label: t("common.status"),
164
+ name: "created_at",
165
+ options: {
166
+ sort: true,
167
+ customBodyRenderLite: (val, index) => {
168
+ const invoice = data?.list[index];
169
+ const link = getInvoiceLink(invoice, action);
170
+ if (action) {
171
+ return link.connect ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
172
+ variant: "text",
173
+ size: "small",
174
+ onClick: () => onPay(invoice.id),
175
+ sx: {
176
+ color: "text.link"
177
+ },
178
+ children: t("payment.customer.invoice.pay")
179
+ }) : /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
180
+ component: "a",
181
+ variant: "text",
182
+ size: "small",
183
+ href: link.url,
184
+ target: link.external ? "_blank" : target,
185
+ sx: {
186
+ color: "var(--foregrounds-fg-interactive, #0086FF) !important"
187
+ },
188
+ rel: "noreferrer",
189
+ children: t("payment.customer.invoice.pay")
190
+ });
191
+ }
192
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)("a", {
193
+ href: link.url,
194
+ target: link.external ? "_blank" : target,
195
+ rel: "noreferrer",
196
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
197
+ label: invoice.status,
198
+ color: (0, _util.getInvoiceStatusColor)(invoice.status)
199
+ })
200
+ });
201
+ }
202
+ }
203
+ }];
204
+ const onTableChange = ({
205
+ page,
206
+ rowsPerPage
207
+ }) => {
208
+ if (search.pageSize !== rowsPerPage) {
209
+ setSearch(x => ({
210
+ ...x,
211
+ pageSize: rowsPerPage,
212
+ page: 1
213
+ }));
214
+ } else if (search.page !== page + 1) {
215
+ setSearch(x => ({
216
+ ...x,
217
+ page: page + 1
218
+ }));
219
+ }
220
+ };
221
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(InvoiceTableRoot, {
222
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_table.default, {
223
+ hasRowLink: true,
224
+ durable: `__${listKey}__`,
225
+ durableKeys: ["page", "rowsPerPage", "searchText"],
226
+ data: data.list,
227
+ columns,
228
+ options: {
229
+ count: data.count,
230
+ page: search.page - 1,
231
+ rowsPerPage: search.pageSize
232
+ },
233
+ loading,
234
+ onChange: onTableChange,
235
+ toolbar: false,
236
+ sx: {
237
+ mt: 2
238
+ },
239
+ showMobile: false,
240
+ mobileTDFlexDirection: "row",
241
+ emptyNodeText: t("payment.customer.invoice.emptyList")
242
+ })
243
+ });
244
+ });
245
+ const InvoiceTableRoot = (0, _system.styled)(_material.Box)`
246
+ @media (max-width: ${({
247
+ theme
248
+ }) => theme.breakpoints.values.md}px) {
249
+ .MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > td.MuiTableCell-root {
250
+ > div {
251
+ width: fit-content;
252
+ flex: inherit;
253
+ font-size: 14px;
254
+ }
255
+ }
256
+ .invoice-summary {
257
+ padding-right: 20px;
258
+ }
259
+ }
260
+ `;
261
+ const InvoiceList = _react.default.memo(props => {
262
+ const {
263
+ customer_id,
264
+ subscription_id,
265
+ include_recovered_from,
266
+ currency_id,
267
+ include_staking,
268
+ status,
269
+ pageSize,
270
+ target,
271
+ action,
272
+ onPay
273
+ } = props;
274
+ const size = pageSize || 10;
275
+ const subscription = (0, _subscription.useSubscription)("events");
276
+ const {
277
+ t,
278
+ locale
279
+ } = (0, _context.useLocaleContext)();
79
280
  const {
80
281
  data,
81
282
  loadMore,
@@ -109,47 +310,6 @@ function CustomerInvoiceList({
109
310
  });
110
311
  }
111
312
  }, [subscription]);
112
- const onPay = invoiceId => {
113
- if (state.paying) {
114
- return;
115
- }
116
- setState({
117
- paying: invoiceId
118
- });
119
- connect.open({
120
- action: "collect",
121
- saveConnect: false,
122
- messages: {
123
- scan: "",
124
- title: t(`payment.customer.invoice.${action || "pay"}`),
125
- success: t(`payment.customer.invoice.${action || "pay"}Success`),
126
- error: t(`payment.customer.invoice.${action || "pay"}Error`),
127
- confirm: ""
128
- },
129
- extraParams: {
130
- invoiceId,
131
- action
132
- },
133
- onSuccess: () => {
134
- connect.close();
135
- setState({
136
- paying: ""
137
- });
138
- },
139
- onClose: () => {
140
- connect.close();
141
- setState({
142
- paying: ""
143
- });
144
- },
145
- onError: err => {
146
- setState({
147
- paying: ""
148
- });
149
- _Toast.default.error((0, _util.formatError)(err));
150
- }
151
- });
152
- };
153
313
  if (loading || !data) {
154
314
  return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.CircularProgress, {});
155
315
  }
@@ -262,7 +422,6 @@ function CustomerInvoiceList({
262
422
  }) : /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
263
423
  component: "a",
264
424
  variant: "contained",
265
- color: "primary",
266
425
  size: "small",
267
426
  href: link.url,
268
427
  target: link.external ? "_blank" : target,
@@ -295,6 +454,72 @@ function CustomerInvoiceList({
295
454
  })]
296
455
  })]
297
456
  });
457
+ });
458
+ function CustomerInvoiceList(props) {
459
+ const {
460
+ action,
461
+ type
462
+ } = props;
463
+ const {
464
+ t
465
+ } = (0, _context.useLocaleContext)();
466
+ const {
467
+ connect
468
+ } = (0, _payment.usePaymentContext)();
469
+ const [state, setState] = (0, _ahooks.useSetState)({
470
+ paying: ""
471
+ });
472
+ const onPay = invoiceId => {
473
+ if (state.paying) {
474
+ return;
475
+ }
476
+ setState({
477
+ paying: invoiceId
478
+ });
479
+ connect.open({
480
+ action: "collect",
481
+ saveConnect: false,
482
+ messages: {
483
+ scan: "",
484
+ title: t(`payment.customer.invoice.${action || "pay"}`),
485
+ success: t(`payment.customer.invoice.${action || "pay"}Success`),
486
+ error: t(`payment.customer.invoice.${action || "pay"}Error`),
487
+ confirm: ""
488
+ },
489
+ extraParams: {
490
+ invoiceId,
491
+ action
492
+ },
493
+ onSuccess: () => {
494
+ connect.close();
495
+ setState({
496
+ paying: ""
497
+ });
498
+ },
499
+ onClose: () => {
500
+ connect.close();
501
+ setState({
502
+ paying: ""
503
+ });
504
+ },
505
+ onError: err => {
506
+ setState({
507
+ paying: ""
508
+ });
509
+ _Toast.default.error((0, _util.formatError)(err));
510
+ }
511
+ });
512
+ };
513
+ if (type === "table") {
514
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(InvoiceTable, {
515
+ ...props,
516
+ onPay
517
+ });
518
+ }
519
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(InvoiceList, {
520
+ ...props,
521
+ onPay
522
+ });
298
523
  }
299
524
  CustomerInvoiceList.defaultProps = {
300
525
  customer_id: "",
@@ -305,10 +530,13 @@ CustomerInvoiceList.defaultProps = {
305
530
  status: "open,paid,uncollectible",
306
531
  pageSize: 10,
307
532
  target: "_self",
308
- action: ""
533
+ action: "",
534
+ type: "list"
309
535
  };
310
536
  const Root = (0, _system.styled)(_material.Stack)`
311
- @media (max-width: 600px) {
537
+ @media (max-width: ${({
538
+ theme
539
+ }) => theme.breakpoints.values.md}px) {
312
540
  .invoice-description {
313
541
  display: none !important;
314
542
  }
@@ -0,0 +1,4 @@
1
+ export declare function useMobile(mobilePoint?: 'md' | 'sm' | 'lg' | 'xl' | 'xs'): {
2
+ isMobile: boolean;
3
+ mobileSize: string;
4
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useMobile = useMobile;
7
+ var _styles = require("@mui/material/styles");
8
+ var _useMediaQuery = _interopRequireDefault(require("@mui/material/useMediaQuery"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ const MOBILE_POINT = "md";
11
+ function useMobile(mobilePoint = MOBILE_POINT) {
12
+ const theme = (0, _styles.useTheme)();
13
+ return {
14
+ isMobile: (0, _useMediaQuery.default)(theme.breakpoints.down(mobilePoint)),
15
+ mobileSize: `${theme.breakpoints.values[mobilePoint]}px`
16
+ };
17
+ }
package/lib/index.d.ts CHANGED
@@ -7,6 +7,7 @@ import ConfirmDialog from './components/confirm';
7
7
  import FormInput from './components/input';
8
8
  import Livemode from './components/livemode';
9
9
  import PricingTable from './components/pricing-table';
10
+ import Table from './components/table';
10
11
  import SafeGuard from './components/safe-guard';
11
12
  import Status from './components/status';
12
13
  import Switch from './components/switch-button';
@@ -23,9 +24,12 @@ import Payment from './payment/index';
23
24
  import ProductSkeleton from './payment/product-skeleton';
24
25
  import PaymentSummary from './payment/summary';
25
26
  import PricingItem from './components/pricing-item';
27
+ import CountrySelect from './components/country-select';
28
+ export { PaymentThemeProvider } from './theme';
26
29
  export * from './libs/util';
27
30
  export * from './libs/connect';
28
31
  export * from './contexts/payment';
29
32
  export * from './hooks/subscription';
33
+ export * from './hooks/mobile';
30
34
  export { translations, createTranslator } from './locales';
31
- export { 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, };
35
+ export { 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, };
package/lib/index.js CHANGED
@@ -13,6 +13,7 @@ var _exportNames = {
13
13
  FormInput: true,
14
14
  Livemode: true,
15
15
  PricingTable: true,
16
+ Table: true,
16
17
  SafeGuard: true,
17
18
  Status: true,
18
19
  Switch: true,
@@ -29,6 +30,8 @@ var _exportNames = {
29
30
  ProductSkeleton: true,
30
31
  PaymentSummary: true,
31
32
  PricingItem: true,
33
+ CountrySelect: true,
34
+ PaymentThemeProvider: true,
32
35
  translations: true,
33
36
  createTranslator: true
34
37
  };
@@ -68,6 +71,12 @@ Object.defineProperty(exports, "ConfirmDialog", {
68
71
  return _confirm.default;
69
72
  }
70
73
  });
74
+ Object.defineProperty(exports, "CountrySelect", {
75
+ enumerable: true,
76
+ get: function () {
77
+ return _countrySelect.default;
78
+ }
79
+ });
71
80
  Object.defineProperty(exports, "CurrencySelector", {
72
81
  enumerable: true,
73
82
  get: function () {
@@ -110,6 +119,12 @@ Object.defineProperty(exports, "PaymentSummary", {
110
119
  return _summary.default;
111
120
  }
112
121
  });
122
+ Object.defineProperty(exports, "PaymentThemeProvider", {
123
+ enumerable: true,
124
+ get: function () {
125
+ return _theme.PaymentThemeProvider;
126
+ }
127
+ });
113
128
  Object.defineProperty(exports, "PhoneInput", {
114
129
  enumerable: true,
115
130
  get: function () {
@@ -158,6 +173,12 @@ Object.defineProperty(exports, "Switch", {
158
173
  return _switchButton.default;
159
174
  }
160
175
  });
176
+ Object.defineProperty(exports, "Table", {
177
+ enumerable: true,
178
+ get: function () {
179
+ return _table2.default;
180
+ }
181
+ });
161
182
  Object.defineProperty(exports, "TxGas", {
162
183
  enumerable: true,
163
184
  get: function () {
@@ -203,6 +224,7 @@ var _confirm = _interopRequireDefault(require("./components/confirm"));
203
224
  var _input = _interopRequireDefault(require("./components/input"));
204
225
  var _livemode = _interopRequireDefault(require("./components/livemode"));
205
226
  var _pricingTable = _interopRequireDefault(require("./components/pricing-table"));
227
+ var _table2 = _interopRequireDefault(require("./components/table"));
206
228
  var _safeGuard = _interopRequireDefault(require("./components/safe-guard"));
207
229
  var _status = _interopRequireDefault(require("./components/status"));
208
230
  var _switchButton = _interopRequireDefault(require("./components/switch-button"));
@@ -219,6 +241,8 @@ var _index = _interopRequireDefault(require("./payment/index"));
219
241
  var _productSkeleton = _interopRequireDefault(require("./payment/product-skeleton"));
220
242
  var _summary = _interopRequireDefault(require("./payment/summary"));
221
243
  var _pricingItem = _interopRequireDefault(require("./components/pricing-item"));
244
+ var _countrySelect = _interopRequireDefault(require("./components/country-select"));
245
+ var _theme = require("./theme");
222
246
  var _util = require("./libs/util");
223
247
  Object.keys(_util).forEach(function (key) {
224
248
  if (key === "default" || key === "__esModule") return;
@@ -267,5 +291,17 @@ Object.keys(_subscription).forEach(function (key) {
267
291
  }
268
292
  });
269
293
  });
294
+ var _mobile = require("./hooks/mobile");
295
+ Object.keys(_mobile).forEach(function (key) {
296
+ if (key === "default" || key === "__esModule") return;
297
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
298
+ if (key in exports && exports[key] === _mobile[key]) return;
299
+ Object.defineProperty(exports, key, {
300
+ enumerable: true,
301
+ get: function () {
302
+ return _mobile[key];
303
+ }
304
+ });
305
+ });
270
306
  var _locales = require("./locales");
271
307
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { PaymentDetails, PriceCurrency, PriceRecurring, TLineItemExpanded, TPaymentCurrency, TPaymentCurrencyExpanded, TPaymentMethod, TPaymentMethodExpanded, TPrice, TProductExpanded, TSubscriptionExpanded, TSubscriptionItemExpanded } from '@blocklet/payment-types';
3
- import { PricingRenderProps } from '../types';
3
+ import { ActionProps, PricingRenderProps } from '../types';
4
4
  export declare const PAYMENT_KIT_DID = "z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk";
5
5
  export declare const isPaymentKitMounted: () => any;
6
6
  export declare const getPrefix: () => string;
@@ -24,12 +24,12 @@ export declare function formatLineItemPricing(item: TLineItemExpanded, currency:
24
24
  secondary?: string;
25
25
  quantity: string;
26
26
  };
27
- export declare function getSubscriptionStatusColor(status: string): "success" | "primary" | "warning" | "error" | "default";
28
- export declare function getPaymentIntentStatusColor(status: string): "success" | "warning" | "default";
29
- export declare function getRefundStatusColor(status: string): "success" | "warning" | "default";
30
- export declare function getPayoutStatusColor(status: string): "success" | "warning" | "default";
31
- export declare function getInvoiceStatusColor(status: string): "success" | "warning" | "default" | "secondary";
32
- export declare function getWebhookStatusColor(status: string): "success" | "default";
27
+ export declare function getSubscriptionStatusColor(status: string): "default" | "success" | "primary" | "warning" | "error";
28
+ export declare function getPaymentIntentStatusColor(status: string): "default" | "success" | "warning";
29
+ export declare function getRefundStatusColor(status: string): "default" | "success" | "warning";
30
+ export declare function getPayoutStatusColor(status: string): "default" | "success" | "warning";
31
+ export declare function getInvoiceStatusColor(status: string): "default" | "success" | "warning" | "secondary";
32
+ export declare function getWebhookStatusColor(status: string): "default" | "success";
33
33
  export declare function getCheckoutAmount(items: TLineItemExpanded[], currency: TPaymentCurrency, trialing?: boolean, upsell?: boolean): {
34
34
  subtotal: any;
35
35
  total: any;
@@ -40,11 +40,21 @@ export declare function getCheckoutAmount(items: TLineItemExpanded[], currency:
40
40
  };
41
41
  export declare function getRecurringPeriod(recurring: PriceRecurring): number;
42
42
  export declare function formatUpsellSaving(items: TLineItemExpanded[], currency: TPaymentCurrency): string;
43
+ export declare function formatMeteredThen(subscription: string, recurring: string, hasMetered: boolean, locale?: string): string;
44
+ export declare function formatPriceDisplay({ amount, then, actualAmount, showThen }: {
45
+ amount: string;
46
+ then?: string;
47
+ actualAmount: string;
48
+ showThen?: boolean;
49
+ }, recurring: string, hasMetered: boolean, locale?: string): string;
43
50
  export declare function formatCheckoutHeadlines(items: TLineItemExpanded[], currency: TPaymentCurrency, trialInDays: number, locale?: string): {
44
51
  action: string;
45
52
  amount: string;
46
53
  then?: string;
47
54
  secondary?: string;
55
+ showThen?: boolean;
56
+ actualAmount: string;
57
+ priceDisplay: string;
48
58
  };
49
59
  export declare function formatAmount(amount: string, decimals: number): string;
50
60
  export declare function findCurrency(methods: TPaymentMethodExpanded[], currencyId: string): TPaymentCurrencyExpanded | null;
@@ -53,11 +63,13 @@ export declare function stopEvent(e: React.SyntheticEvent<any>): void;
53
63
  export declare function sleep(ms: number): Promise<unknown>;
54
64
  export declare function formatSubscriptionProduct(items: TSubscriptionItemExpanded[], maxLength?: number): string;
55
65
  export declare const getSubscriptionTimeSummary: (subscription: TSubscriptionExpanded) => string;
56
- export declare const getSubscriptionAction: (subscription: TSubscriptionExpanded) => {
66
+ export declare const getSubscriptionAction: (subscription: TSubscriptionExpanded, actionProps: ActionProps) => {
57
67
  action: string;
58
68
  variant: string;
59
69
  color: string;
60
70
  canRenew: boolean;
71
+ text?: string;
72
+ sx?: any;
61
73
  } | null;
62
74
  export declare const mergeExtraParams: (extra?: Record<string, any>) => string;
63
75
  export declare const flattenPaymentMethods: (methods?: TPaymentMethodExpanded[]) => import("sequelize").InferAttributes<import("@blocklet/payment-types").PaymentCurrency, {
@@ -77,4 +89,5 @@ export declare function formatTotalPrice({ product, quantity, priceId, locale, }
77
89
  locale: string;
78
90
  }): PricingRenderProps;
79
91
  export declare function formatQuantityInventory(price: TPrice, quantity: string | number, locale?: string): string;
92
+ export declare function formatSubscriptionStatus(status: string): string;
80
93
  export declare function formatAmountPrecisionLimit(amount: string, locale?: string, precision?: number): string;