@blocklet/payment-react 1.14.20 → 1.14.22

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 (136) hide show
  1. package/es/checkout/donate.d.ts +2 -1
  2. package/es/checkout/donate.js +9 -10
  3. package/es/checkout/form.d.ts +1 -1
  4. package/es/checkout/form.js +23 -1
  5. package/es/checkout/table.d.ts +1 -1
  6. package/es/checkout/table.js +8 -1
  7. package/es/components/blockchain/tx.js +2 -1
  8. package/es/components/country-select.d.ts +16 -0
  9. package/es/components/country-select.js +82 -0
  10. package/es/components/input.d.ts +21 -21
  11. package/es/components/input.js +43 -42
  12. package/es/components/livemode.js +1 -0
  13. package/es/components/pricing-table.js +0 -2
  14. package/es/components/status.js +2 -3
  15. package/es/components/table.d.ts +2 -0
  16. package/es/components/table.js +186 -0
  17. package/es/contexts/payment.d.ts +2 -0
  18. package/es/contexts/payment.js +5 -2
  19. package/es/history/invoice/list.d.ts +5 -1
  20. package/es/history/invoice/list.js +218 -48
  21. package/es/hooks/mobile.d.ts +4 -0
  22. package/es/hooks/mobile.js +10 -0
  23. package/es/index.d.ts +5 -1
  24. package/es/index.js +7 -1
  25. package/es/libs/util.d.ts +15 -2
  26. package/es/libs/util.js +92 -28
  27. package/es/locales/en.js +23 -7
  28. package/es/locales/index.d.ts +0 -1
  29. package/es/locales/index.js +10 -1
  30. package/es/locales/zh.js +22 -6
  31. package/es/payment/error.js +2 -2
  32. package/es/payment/footer.js +1 -1
  33. package/es/payment/form/address.d.ts +9 -2
  34. package/es/payment/form/address.js +69 -69
  35. package/es/payment/form/currency.js +39 -25
  36. package/es/payment/form/index.d.ts +1 -1
  37. package/es/payment/form/index.js +83 -81
  38. package/es/payment/form/phone.js +15 -51
  39. package/es/payment/index.d.ts +1 -10
  40. package/es/payment/index.js +274 -219
  41. package/es/payment/product-card.js +4 -4
  42. package/es/payment/product-donation.js +7 -2
  43. package/es/payment/product-item.d.ts +2 -2
  44. package/es/payment/product-item.js +120 -81
  45. package/es/payment/summary.js +188 -118
  46. package/es/theme/index.css +240 -0
  47. package/es/theme/index.d.ts +9 -0
  48. package/es/theme/index.js +243 -0
  49. package/es/theme/typography.d.ts +2 -0
  50. package/es/theme/typography.js +53 -0
  51. package/es/types/index.d.ts +11 -0
  52. package/lib/checkout/donate.d.ts +2 -1
  53. package/lib/checkout/donate.js +14 -2
  54. package/lib/checkout/form.d.ts +1 -1
  55. package/lib/checkout/form.js +22 -1
  56. package/lib/checkout/table.d.ts +1 -1
  57. package/lib/checkout/table.js +14 -1
  58. package/lib/components/blockchain/tx.js +4 -1
  59. package/lib/components/country-select.d.ts +16 -0
  60. package/lib/components/country-select.js +115 -0
  61. package/lib/components/input.d.ts +21 -21
  62. package/lib/components/input.js +21 -12
  63. package/lib/components/livemode.js +1 -0
  64. package/lib/components/pricing-table.js +0 -2
  65. package/lib/components/status.js +2 -3
  66. package/lib/components/table.d.ts +2 -0
  67. package/lib/components/table.js +220 -0
  68. package/lib/contexts/payment.d.ts +2 -0
  69. package/lib/contexts/payment.js +4 -1
  70. package/lib/history/invoice/list.d.ts +5 -1
  71. package/lib/history/invoice/list.js +293 -62
  72. package/lib/hooks/mobile.d.ts +4 -0
  73. package/lib/hooks/mobile.js +17 -0
  74. package/lib/index.d.ts +5 -1
  75. package/lib/index.js +36 -0
  76. package/lib/libs/util.d.ts +15 -2
  77. package/lib/libs/util.js +115 -37
  78. package/lib/locales/en.js +23 -7
  79. package/lib/locales/index.d.ts +0 -1
  80. package/lib/locales/index.js +14 -3
  81. package/lib/locales/zh.js +22 -6
  82. package/lib/payment/error.js +5 -1
  83. package/lib/payment/footer.js +1 -1
  84. package/lib/payment/form/address.d.ts +9 -2
  85. package/lib/payment/form/address.js +67 -59
  86. package/lib/payment/form/currency.js +31 -24
  87. package/lib/payment/form/index.d.ts +1 -1
  88. package/lib/payment/form/index.js +92 -93
  89. package/lib/payment/form/phone.js +11 -59
  90. package/lib/payment/index.d.ts +1 -10
  91. package/lib/payment/index.js +291 -219
  92. package/lib/payment/product-card.js +5 -4
  93. package/lib/payment/product-donation.js +9 -2
  94. package/lib/payment/product-item.d.ts +2 -2
  95. package/lib/payment/product-item.js +38 -19
  96. package/lib/payment/summary.js +219 -127
  97. package/lib/theme/index.css +240 -0
  98. package/lib/theme/index.d.ts +9 -0
  99. package/lib/theme/index.js +259 -0
  100. package/lib/theme/typography.d.ts +2 -0
  101. package/lib/theme/typography.js +59 -0
  102. package/lib/types/index.d.ts +11 -0
  103. package/package.json +14 -11
  104. package/src/checkout/donate.tsx +16 -10
  105. package/src/checkout/form.tsx +23 -0
  106. package/src/checkout/table.tsx +13 -1
  107. package/src/components/blockchain/tx.tsx +2 -1
  108. package/src/components/country-select.tsx +93 -0
  109. package/src/components/input.tsx +49 -46
  110. package/src/components/livemode.tsx +1 -0
  111. package/src/components/pricing-table.tsx +0 -2
  112. package/src/components/status.tsx +1 -2
  113. package/src/components/table.tsx +200 -0
  114. package/src/contexts/payment.tsx +6 -1
  115. package/src/history/invoice/list.tsx +258 -49
  116. package/src/hooks/mobile.ts +13 -0
  117. package/src/index.ts +7 -0
  118. package/src/libs/util.ts +120 -31
  119. package/src/locales/en.tsx +19 -4
  120. package/src/locales/index.tsx +10 -3
  121. package/src/locales/zh.tsx +18 -3
  122. package/src/payment/error.tsx +2 -2
  123. package/src/payment/footer.tsx +1 -1
  124. package/src/payment/form/address.tsx +56 -47
  125. package/src/payment/form/currency.tsx +29 -23
  126. package/src/payment/form/index.tsx +89 -76
  127. package/src/payment/form/phone.tsx +14 -51
  128. package/src/payment/index.tsx +294 -242
  129. package/src/payment/product-card.tsx +4 -4
  130. package/src/payment/product-donation.tsx +7 -3
  131. package/src/payment/product-item.tsx +49 -20
  132. package/src/payment/summary.tsx +191 -108
  133. package/src/theme/index.css +240 -0
  134. package/src/theme/index.tsx +250 -0
  135. package/src/theme/typography.ts +56 -0
  136. package/src/types/index.ts +12 -0
@@ -0,0 +1,243 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { ThemeProvider, useTheme } from "@mui/material/styles";
3
+ import { create } from "@arcblock/ux/lib/Theme";
4
+ import { CssBaseline } from "@mui/material";
5
+ import { typography } from "./typography.js";
6
+ import "./index.css";
7
+ export { typography };
8
+ export const themeOverrides = {
9
+ shape: {
10
+ borderRadius: 8
11
+ },
12
+ components: {
13
+ MuiOutlinedInput: {
14
+ styleOverrides: {
15
+ root: {
16
+ borderRadius: "var(--radius-m, 8px)",
17
+ backgroundColor: "var(--backgrounds-bg-field)",
18
+ "&.Mui-disabled": {
19
+ backgroundColor: "var(--backgrounds-bg-disabled)"
20
+ },
21
+ ".MuiOutlinedInput-notchedOutline": {
22
+ borderColor: "var(--stroke-border-base, #EFF1F5)"
23
+ },
24
+ ".MuiInputBase-input": {
25
+ fontSize: "14px",
26
+ minHeight: "1.65em",
27
+ lineHeight: "1.65em"
28
+ }
29
+ }
30
+ }
31
+ },
32
+ MuiButton: {
33
+ defaultProps: {
34
+ size: "small"
35
+ },
36
+ styleOverrides: {
37
+ root: {
38
+ fontSize: "1rem",
39
+ fontWeight: 500,
40
+ textTransform: "none"
41
+ },
42
+ containedPrimary: {
43
+ backgroundColor: "var(--buttons-button-inverted, #010714)",
44
+ color: "var(--foregrounds-fg-on-color, #fff)",
45
+ "&:hover": {
46
+ backgroundColor: "var(--buttons-button-inverted-hover, #1f2937)"
47
+ }
48
+ },
49
+ outlinedPrimary: {
50
+ color: "var(--foregrounds-fg-base, #010714)",
51
+ borderColor: "var(--stroke-button-secondary-border, #E5E7EB)",
52
+ "&:hover": {
53
+ backgroundColor: "var(--buttons-button-neutral-hover, #F3F4F6)",
54
+ borderColor: "var(--stroke-button-secondary-border, #E5E7EB)"
55
+ }
56
+ },
57
+ sizeSmall: {
58
+ height: 32
59
+ }
60
+ }
61
+ },
62
+ MuiIconButton: {
63
+ defaultProps: {
64
+ size: "small"
65
+ },
66
+ styleOverrides: {
67
+ root: {
68
+ textTransform: "none"
69
+ },
70
+ colorPrimary: {
71
+ backgroundColor: "#fff"
72
+ }
73
+ }
74
+ },
75
+ MuiToggleButton: {
76
+ styleOverrides: {
77
+ root: {
78
+ textTransform: "none"
79
+ }
80
+ }
81
+ },
82
+ MuiTab: {
83
+ styleOverrides: {
84
+ root: {
85
+ textTransform: "none"
86
+ }
87
+ }
88
+ },
89
+ MuiTooltip: {
90
+ defaultProps: {
91
+ enterTouchDelay: 3e3,
92
+ leaveTouchDelay: 100
93
+ }
94
+ },
95
+ MuiPopover: {
96
+ styleOverrides: {
97
+ paper: ({ theme }) => ({
98
+ border: `1px solid ${theme.palette.divider}`,
99
+ boxShadow: "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)"
100
+ })
101
+ }
102
+ },
103
+ MuiCssBaseline: {
104
+ styleOverrides: {
105
+ ".base-card": {
106
+ padding: "20px",
107
+ borderRadius: "var(--radius-l)",
108
+ background: "var(--backgrounds-bg-base)",
109
+ boxShadow: "0px 0px 0px 1px var(--shadows-card-rest-1, rgba(2, 7, 19, 0.08)), 0px 1px 2px -1px var(--shadows-card-rest-2, rgba(2, 7, 19, 0.08)), 0px 2px 4px 0px var(--shadows-card-rest-3, rgba(2, 7, 19, 0.04))"
110
+ },
111
+ ".base-label": {
112
+ color: "var(--foregrounds-fg-base, #010714)",
113
+ fontSize: "16px",
114
+ fontWeight: "500",
115
+ lineHeight: "24px"
116
+ },
117
+ a: {
118
+ textDecoration: "none !important"
119
+ }
120
+ }
121
+ },
122
+ // MuiButtonBase: {
123
+ // styleOverrides: {
124
+ // }
125
+ // },
126
+ MuiRadio: {
127
+ styleOverrides: {
128
+ root: {
129
+ color: "var(--stroke-border-base, #EFF1F5)",
130
+ "&:hover": {
131
+ background: "none"
132
+ },
133
+ "&.Mui-checked": {
134
+ color: "var(--foregrounds-fg-interactive, #0086FF)"
135
+ }
136
+ }
137
+ }
138
+ },
139
+ MuiCheckbox: {
140
+ styleOverrides: {
141
+ root: {
142
+ color: "var(--backgrounds-bg-interactive, #0086FF)",
143
+ "&.Mui-checked": {
144
+ color: "var(--foregrounds-fg-interactive, #0086FF)"
145
+ }
146
+ }
147
+ }
148
+ },
149
+ MuiDivider: {
150
+ styleOverrides: {
151
+ root: {
152
+ borderColor: "var(--stroke-border-base, #EFF1F5)"
153
+ }
154
+ }
155
+ },
156
+ MuiInputBase: {
157
+ defaultProps: {
158
+ size: "small"
159
+ },
160
+ styleOverrides: {
161
+ root: () => ({
162
+ fontSize: "0.875rem",
163
+ backgroundColor: "var(--backgrounds-bg-field, #F9FAFB)"
164
+ })
165
+ }
166
+ },
167
+ MuiInputLabel: {
168
+ defaultProps: {
169
+ size: "small"
170
+ },
171
+ styleOverrides: {
172
+ root: () => ({
173
+ fontSize: "0.875rem"
174
+ })
175
+ }
176
+ },
177
+ MuiChip: {
178
+ styleOverrides: {
179
+ root: {
180
+ borderRadius: "var(--radius-S, 4px)",
181
+ border: "1px solid transparent",
182
+ "&.MuiChip-filledSuccess": {
183
+ color: "var(--tags-tag-green-text, #007C52)",
184
+ backgroundColor: "var(--tags-tag-green-bg, #B7FEE3)",
185
+ borderColor: "var(--tags-tag-green-border, #63F9CB)"
186
+ },
187
+ "&.MuiChip-filledDefault": {
188
+ color: "var(--tags-tag-neutral-text, #007C52)",
189
+ backgroundColor: "var(--tags-tag-neutral-bg, #B7FEE3)",
190
+ borderColor: "var(--tags-tag-neutral-border, #E5E7EB)"
191
+ },
192
+ "&.MuiChip-filledSecondary": {
193
+ color: "var(--tags-tag-purple-text, #8118EB)",
194
+ backgroundColor: " var(--tags-tag-purple-bg, #EFE9FF)",
195
+ borderColor: "var(--tags-tag-purple-border, #E1D6FF)"
196
+ },
197
+ "&.MuiChip-filledError": {
198
+ color: "var(--tags-tag-red-text, #E40031)",
199
+ backgroundColor: "var(--tags-tag-red-bg, #FFE2E6)",
200
+ borderColor: "var(--tags-tag-red-border, #FFC8D3)"
201
+ },
202
+ "&.MuiChip-filledWarning": {
203
+ color: "var(--tags-tag-orange-text, #D24000)",
204
+ backgroundColor: "var(--tags-tag-orange-bg, #FFF4BC)",
205
+ borderColor: "var(--tags-tag-orange-border, #FFE467)"
206
+ },
207
+ "&.MuiChip-filledPrimary,&.MuiChip-filledInfo": {
208
+ color: "var(--tags-tag-blue-text, #0051E9)",
209
+ backgroundColor: "var(--tags-tag-blue-bg, #D2ECFF)",
210
+ borderColor: "var(--tags-tag-blue-border, #AFDDFF)"
211
+ }
212
+ }
213
+ }
214
+ }
215
+ }
216
+ };
217
+ export function PaymentThemeProvider({ children }) {
218
+ const theme = useTheme();
219
+ const rootStyle = getComputedStyle(document.documentElement);
220
+ const merged = create({
221
+ ...theme,
222
+ typography,
223
+ palette: {
224
+ primary: {
225
+ main: rootStyle.getPropertyValue("--foregrounds-fg-base").trim() || "#030712"
226
+ },
227
+ text: {
228
+ primary: rootStyle.getPropertyValue("--foregrounds-fg-base").trim() || "#030712",
229
+ secondary: rootStyle.getPropertyValue("--foregrounds-fg-subtle").trim() || "#4b5563",
230
+ lighter: rootStyle.getPropertyValue("--foregrounds-fg-muted").trim() || "#9ca3af",
231
+ link: rootStyle.getPropertyValue("--foregrounds-fg-interactive").trim() || "#0086FF"
232
+ },
233
+ error: {
234
+ main: rootStyle.getPropertyValue("--foregrounds-fg-danger").trim() || "#FF003B"
235
+ }
236
+ },
237
+ ...themeOverrides
238
+ });
239
+ return /* @__PURE__ */ jsxs(ThemeProvider, { theme: merged, children: [
240
+ /* @__PURE__ */ jsx(CssBaseline, {}),
241
+ children
242
+ ] });
243
+ }
@@ -0,0 +1,2 @@
1
+ import type { TypographyOptions } from '@mui/material/styles/createTypography';
2
+ export declare const typography: TypographyOptions;
@@ -0,0 +1,53 @@
1
+ export const typography = {
2
+ h1: {
3
+ fontSize: "1.875rem",
4
+ lineHeight: 1.2,
5
+ fontWeight: 800,
6
+ letterSpacing: "-.025em"
7
+ },
8
+ h2: {
9
+ fontSize: "1.5rem",
10
+ lineHeight: 1.3333333,
11
+ fontWeight: 700,
12
+ letterSpacing: "-.025em"
13
+ },
14
+ h3: {
15
+ fontSize: "1.25rem",
16
+ lineHeight: 1.4,
17
+ fontWeight: 600,
18
+ letterSpacing: "-.025em"
19
+ },
20
+ h4: {
21
+ fontSize: "1.125rem",
22
+ lineHeight: 1.5,
23
+ fontWeight: 600
24
+ },
25
+ h5: {
26
+ fontSize: "1rem",
27
+ lineHeight: 1.75,
28
+ fontWeight: 400
29
+ },
30
+ h6: {
31
+ fontSize: "1rem",
32
+ lineHeight: 1.75,
33
+ fontWeight: 400
34
+ },
35
+ subtitle1: {
36
+ fontSize: "1rem",
37
+ lineHeight: 1.75,
38
+ fontWeight: 400
39
+ },
40
+ subtitle2: {
41
+ fontSize: "1rem",
42
+ lineHeight: 1.75,
43
+ fontWeight: 400
44
+ },
45
+ body1: {
46
+ fontSize: "1rem",
47
+ lineHeight: 1.75
48
+ },
49
+ fontWeightLight: 300,
50
+ fontWeightRegular: 400,
51
+ fontWeightMedium: 500,
52
+ fontWeightBold: 700
53
+ };
@@ -29,6 +29,7 @@ export type CheckoutProps = Partial<CheckoutCallbacks> & {
29
29
  extraParams?: Record<string, any>;
30
30
  action?: string;
31
31
  mode?: LiteralUnion<'standalone' | 'inline' | 'popup' | 'inline-minimal' | 'popup-minimal', string>;
32
+ customTheme?: boolean;
32
33
  };
33
34
  export type CheckoutCallbacks = {
34
35
  onPaid: (res: CheckoutContext) => void;
@@ -42,3 +43,13 @@ export type PricingRenderProps = {
42
43
  quantity: string;
43
44
  totalAmount: string;
44
45
  };
46
+ export type ActionProps = {
47
+ [key: string]: {
48
+ color?: string;
49
+ variant?: string;
50
+ sx?: {
51
+ [key: string]: any;
52
+ };
53
+ text?: string;
54
+ };
55
+ };
@@ -20,8 +20,9 @@ export type DonateProps = Pick<CheckoutProps, 'onPaid' | 'onError'> & {
20
20
  inlineOptions?: {
21
21
  button?: ButtonType;
22
22
  };
23
+ customTheme?: boolean;
23
24
  };
24
- declare function CheckoutDonate({ settings, livemode, timeout, onPaid, onError, mode, inlineOptions, }: DonateProps): import("react").JSX.Element;
25
+ declare function CheckoutDonate(props: DonateProps): import("react").JSX.Element;
25
26
  declare namespace CheckoutDonate {
26
27
  var defaultProps: {
27
28
  livemode: boolean;
@@ -16,6 +16,7 @@ var _tx = _interopRequireDefault(require("../components/blockchain/tx"));
16
16
  var _api = _interopRequireDefault(require("../libs/api"));
17
17
  var _util = require("../libs/util");
18
18
  var _form = _interopRequireDefault(require("./form"));
19
+ var _theme = require("../theme");
19
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
21
  const donationCache = {};
21
22
  const createOrUpdateDonation = (settings, livemode = true) => {
@@ -285,7 +286,7 @@ function useDonation(settings, livemode = true, mode = "default") {
285
286
  setState
286
287
  };
287
288
  }
288
- function CheckoutDonate({
289
+ function CheckoutDonateInner({
289
290
  settings,
290
291
  livemode,
291
292
  timeout,
@@ -451,7 +452,6 @@ function CheckoutDonate({
451
452
  children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
452
453
  sx: {
453
454
  mb: 1,
454
- mt: -2,
455
455
  height: "100%"
456
456
  },
457
457
  children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_form.default, {
@@ -465,6 +465,18 @@ function CheckoutDonate({
465
465
  })]
466
466
  });
467
467
  }
468
+ function CheckoutDonate(props) {
469
+ if (props.customTheme) {
470
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(CheckoutDonateInner, {
471
+ ...props
472
+ });
473
+ }
474
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_theme.PaymentThemeProvider, {
475
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(CheckoutDonateInner, {
476
+ ...props
477
+ })
478
+ });
479
+ }
468
480
  CheckoutDonate.defaultProps = {
469
481
  livemode: true,
470
482
  timeout: 5e3,
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { CheckoutProps } from '../types';
3
- declare function CheckoutForm({ id, mode, onPaid, onError, onChange, goBack, extraParams, action, }: CheckoutProps): import("react").JSX.Element;
3
+ declare function CheckoutForm({ id, mode, onPaid, onError, onChange, goBack, extraParams, action, customTheme, }: CheckoutProps): import("react").JSX.Element;
4
4
  declare namespace CheckoutForm {
5
5
  var defaultProps: {
6
6
  onPaid: any;
@@ -12,6 +12,7 @@ var _ufo = require("ufo");
12
12
  var _api = _interopRequireDefault(require("../libs/api"));
13
13
  var _util = require("../libs/util");
14
14
  var _payment = _interopRequireDefault(require("../payment"));
15
+ var _theme = require("../theme");
15
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
17
  const promises = {};
17
18
  const startFromPaymentLink = (id, params) => {
@@ -38,7 +39,8 @@ function CheckoutForm({
38
39
  onChange,
39
40
  goBack,
40
41
  extraParams,
41
- action
42
+ action,
43
+ customTheme = false
42
44
  }) {
43
45
  if (!id.startsWith("plink_") && !id.startsWith("cs_")) {
44
46
  throw new Error("Either a checkoutSession or a paymentLink id is required.");
@@ -70,6 +72,25 @@ function CheckoutForm({
70
72
  });
71
73
  onError?.(err);
72
74
  };
75
+ if (!customTheme) {
76
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_theme.PaymentThemeProvider, {
77
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_payment.default, {
78
+ checkoutSession: data?.checkoutSession,
79
+ paymentMethods: data?.paymentMethods,
80
+ paymentIntent: data?.paymentIntent,
81
+ paymentLink: data?.paymentLink,
82
+ customer: data?.customer,
83
+ completed: state.completed,
84
+ error: apiError || state.appError,
85
+ onPaid: handlePaid,
86
+ onError: handleError,
87
+ onChange,
88
+ goBack,
89
+ mode,
90
+ action
91
+ })
92
+ });
93
+ }
73
94
  return /* @__PURE__ */(0, _jsxRuntime.jsx)(_payment.default, {
74
95
  checkoutSession: data?.checkoutSession,
75
96
  paymentMethods: data?.paymentMethods,
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { CheckoutProps } from '../types';
3
- export default function CheckoutTable({ id, mode, onPaid, onError, onChange, extraParams, goBack }: CheckoutProps): import("react").JSX.Element;
3
+ export default function CheckoutTable(props: CheckoutProps): import("react").JSX.Element;
@@ -16,6 +16,7 @@ var _pricingTable = _interopRequireDefault(require("../components/pricing-table"
16
16
  var _api = _interopRequireDefault(require("../libs/api"));
17
17
  var _util = require("../libs/util");
18
18
  var _form = _interopRequireDefault(require("./form"));
19
+ var _theme = require("../theme");
19
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
21
  const fetchData = async id => {
21
22
  const {
@@ -29,7 +30,7 @@ const ensureProtocol = url => {
29
30
  }
30
31
  return url;
31
32
  };
32
- function CheckoutTable({
33
+ function CheckoutTableInner({
33
34
  id,
34
35
  mode,
35
36
  onPaid,
@@ -145,4 +146,16 @@ function CheckoutTable({
145
146
  ...prop
146
147
  })
147
148
  });
149
+ }
150
+ function CheckoutTable(props) {
151
+ if (props.customTheme) {
152
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(CheckoutTableInner, {
153
+ ...props
154
+ });
155
+ }
156
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_theme.PaymentThemeProvider, {
157
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(CheckoutTableInner, {
158
+ ...props
159
+ })
160
+ });
148
161
  }
@@ -38,10 +38,13 @@ function TxLink(props) {
38
38
  direction: "row",
39
39
  alignItems: "center",
40
40
  justifyContent: props.align === "left" ? "flex-start" : "flex-end",
41
+ sx: {
42
+ color: "text.link"
43
+ },
41
44
  spacing: 1,
42
45
  children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
43
46
  component: "span",
44
- color: "primary",
47
+ color: "text.link",
45
48
  children: text.length > 40 ? [text.slice(0, 6), text.slice(-6)].join("...") : text
46
49
  }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_iconsMaterial.OpenInNewOutlined, {
47
50
  fontSize: "small"
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" />
2
+ import { SxProps } from '@mui/material';
3
+ import { CountryIso2 } from 'react-international-phone';
4
+ export type CountrySelectProps = {
5
+ value: CountryIso2;
6
+ onChange: (value: CountryIso2) => void;
7
+ name: string;
8
+ sx?: SxProps;
9
+ };
10
+ declare function CountrySelect({ value, onChange, name, sx }: CountrySelectProps): JSX.Element;
11
+ declare namespace CountrySelect {
12
+ var defaultProps: {
13
+ sx: {};
14
+ };
15
+ }
16
+ export default CountrySelect;
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ module.exports = CountrySelect;
7
+ var _jsxRuntime = require("react/jsx-runtime");
8
+ var _react = require("react");
9
+ var _material = require("@mui/material");
10
+ var _reactHookForm = require("react-hook-form");
11
+ var _reactInternationalPhone = require("react-international-phone");
12
+ CountrySelect.defaultProps = {
13
+ sx: {}
14
+ };
15
+ function CountrySelect({
16
+ value,
17
+ onChange,
18
+ name,
19
+ sx
20
+ }) {
21
+ const {
22
+ setValue
23
+ } = (0, _reactHookForm.useFormContext)();
24
+ const countryDetail = (0, _react.useMemo)(() => {
25
+ const item = _reactInternationalPhone.defaultCountries.find(v => v[1] === value);
26
+ return value && item ? (0, _reactInternationalPhone.parseCountry)(item) : {
27
+ name: ""
28
+ };
29
+ }, [value]);
30
+ const onCountryChange = e => {
31
+ onChange(e.target.value);
32
+ setValue(name, e.target.value);
33
+ };
34
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Select, {
35
+ MenuProps: {
36
+ style: {
37
+ height: "300px",
38
+ top: "10px"
39
+ },
40
+ anchorOrigin: {
41
+ vertical: "bottom",
42
+ horizontal: "left"
43
+ },
44
+ transformOrigin: {
45
+ vertical: "top",
46
+ horizontal: "left"
47
+ }
48
+ },
49
+ sx: {
50
+ width: "100%",
51
+ // Remove default outline (display only on focus)
52
+ fieldset: {
53
+ display: "none"
54
+ },
55
+ '&.Mui-focused:has(div[aria-expanded="false"])': {
56
+ fieldset: {
57
+ display: "block"
58
+ }
59
+ },
60
+ // Update default spacing
61
+ ".MuiSelect-select": {
62
+ padding: "8px",
63
+ paddingRight: "24px !important"
64
+ },
65
+ svg: {
66
+ right: 0
67
+ },
68
+ ".MuiMenuItem-root": {
69
+ justifyContent: "flex-start"
70
+ // 确保内容左对齐
71
+ },
72
+
73
+ ...sx
74
+ },
75
+ value,
76
+ onChange: onCountryChange,
77
+ renderValue: code => {
78
+ return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
79
+ display: "flex",
80
+ alignItems: "center",
81
+ flexWrap: "nowrap",
82
+ gap: 0.5,
83
+ sx: {
84
+ cursor: "pointer"
85
+ },
86
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_reactInternationalPhone.FlagEmoji, {
87
+ iso2: code,
88
+ style: {
89
+ display: "flex"
90
+ }
91
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
92
+ children: countryDetail?.name
93
+ })]
94
+ });
95
+ },
96
+ children: _reactInternationalPhone.defaultCountries.map(c => {
97
+ const parsed = (0, _reactInternationalPhone.parseCountry)(c);
98
+ return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.MenuItem, {
99
+ value: parsed.iso2,
100
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_reactInternationalPhone.FlagEmoji, {
101
+ iso2: parsed.iso2,
102
+ style: {
103
+ marginRight: "8px"
104
+ }
105
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
106
+ marginRight: "8px",
107
+ children: parsed.name
108
+ }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
109
+ color: "gray",
110
+ children: ["+", parsed.dialCode]
111
+ })]
112
+ }, parsed.iso2);
113
+ })
114
+ });
115
+ }
@@ -1,25 +1,25 @@
1
1
  /// <reference types="react" />
2
- import { TextFieldProps } from '@mui/material';
3
2
  import { RegisterOptions } from 'react-hook-form';
4
- type InputProps = TextFieldProps & {
3
+ declare const FormInput: import("react").ForwardRefExoticComponent<(Omit<import("@mui/material").OutlinedTextFieldProps & {
5
4
  name: string;
6
- label?: string;
7
- placeholder?: string;
8
- errorPosition?: 'right' | 'bottom';
9
- rules?: RegisterOptions;
10
- wrapperStyle?: React.CSSProperties;
11
- };
12
- export declare function FormInputError({ error }: {
13
- error: string;
14
- }): import("react").JSX.Element;
15
- declare function FormInput({ name, label, placeholder, rules, errorPosition, wrapperStyle, ...rest }: InputProps): import("react").JSX.Element;
16
- declare namespace FormInput {
17
- var defaultProps: {
18
- label: string;
19
- placeholder: string;
20
- errorPosition: string;
21
- rules: {};
22
- wrapperStyle: {};
23
- };
24
- }
5
+ label?: string | undefined;
6
+ placeholder?: string | undefined;
7
+ errorPosition?: "right" | "bottom" | undefined;
8
+ rules?: RegisterOptions<import("react-hook-form").FieldValues, string> | undefined;
9
+ wrapperStyle?: any;
10
+ }, "ref"> | Omit<import("@mui/material").FilledTextFieldProps & {
11
+ name: string;
12
+ label?: string | undefined;
13
+ placeholder?: string | undefined;
14
+ errorPosition?: "right" | "bottom" | undefined;
15
+ rules?: RegisterOptions<import("react-hook-form").FieldValues, string> | undefined;
16
+ wrapperStyle?: any;
17
+ }, "ref"> | Omit<import("@mui/material").StandardTextFieldProps & {
18
+ name: string;
19
+ label?: string | undefined;
20
+ placeholder?: string | undefined;
21
+ errorPosition?: "right" | "bottom" | undefined;
22
+ rules?: RegisterOptions<import("react-hook-form").FieldValues, string> | undefined;
23
+ wrapperStyle?: any;
24
+ }, "ref">) & import("react").RefAttributes<HTMLInputElement>>;
25
25
  export default FormInput;