@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.
- package/README.md +77 -0
- package/es/checkout/donate.d.ts +4 -2
- package/es/checkout/donate.js +13 -10
- package/es/checkout/form.d.ts +1 -1
- package/es/checkout/form.js +50 -4
- package/es/checkout/table.d.ts +1 -1
- package/es/checkout/table.js +11 -1
- package/es/components/blockchain/tx.js +2 -1
- package/es/components/country-select.d.ts +16 -0
- package/es/components/country-select.js +82 -0
- package/es/components/input.d.ts +21 -21
- package/es/components/input.js +43 -42
- package/es/components/livemode.js +1 -0
- package/es/components/pricing-table.js +0 -2
- package/es/components/status.js +2 -3
- package/es/components/table.d.ts +2 -0
- package/es/components/table.js +186 -0
- package/es/contexts/payment.d.ts +2 -0
- package/es/contexts/payment.js +5 -2
- package/es/history/invoice/list.d.ts +3 -1
- package/es/history/invoice/list.js +215 -48
- package/es/hooks/mobile.d.ts +4 -0
- package/es/hooks/mobile.js +10 -0
- package/es/index.d.ts +5 -1
- package/es/index.js +7 -1
- package/es/libs/util.d.ts +21 -8
- package/es/libs/util.js +92 -28
- package/es/locales/en.js +22 -7
- package/es/locales/index.d.ts +0 -1
- package/es/locales/index.js +10 -1
- package/es/locales/zh.js +21 -6
- package/es/payment/error.js +2 -2
- package/es/payment/footer.js +1 -1
- package/es/payment/form/address.d.ts +9 -2
- package/es/payment/form/address.js +69 -69
- package/es/payment/form/currency.js +39 -25
- package/es/payment/form/index.d.ts +1 -1
- package/es/payment/form/index.js +83 -81
- package/es/payment/form/phone.js +15 -51
- package/es/payment/index.d.ts +3 -10
- package/es/payment/index.js +295 -224
- package/es/payment/product-card.js +4 -4
- package/es/payment/product-donation.js +9 -3
- package/es/payment/product-item.d.ts +2 -2
- package/es/payment/product-item.js +120 -81
- package/es/payment/summary.js +188 -118
- package/es/theme/index.css +240 -0
- package/es/theme/index.d.ts +14 -0
- package/es/theme/index.js +256 -0
- package/es/theme/typography.d.ts +2 -0
- package/es/theme/typography.js +53 -0
- package/es/types/index.d.ts +16 -0
- package/lib/checkout/donate.d.ts +4 -2
- package/lib/checkout/donate.js +23 -2
- package/lib/checkout/form.d.ts +1 -1
- package/lib/checkout/form.js +60 -15
- package/lib/checkout/table.d.ts +1 -1
- package/lib/checkout/table.js +22 -1
- package/lib/components/blockchain/tx.js +4 -1
- package/lib/components/country-select.d.ts +16 -0
- package/lib/components/country-select.js +115 -0
- package/lib/components/input.d.ts +21 -21
- package/lib/components/input.js +21 -12
- package/lib/components/livemode.js +1 -0
- package/lib/components/pricing-table.js +0 -2
- package/lib/components/status.js +2 -3
- package/lib/components/table.d.ts +2 -0
- package/lib/components/table.js +220 -0
- package/lib/contexts/payment.d.ts +2 -0
- package/lib/contexts/payment.js +4 -1
- package/lib/history/invoice/list.d.ts +3 -1
- package/lib/history/invoice/list.js +290 -62
- package/lib/hooks/mobile.d.ts +4 -0
- package/lib/hooks/mobile.js +17 -0
- package/lib/index.d.ts +5 -1
- package/lib/index.js +36 -0
- package/lib/libs/util.d.ts +21 -8
- package/lib/libs/util.js +115 -37
- package/lib/locales/en.js +22 -7
- package/lib/locales/index.d.ts +0 -1
- package/lib/locales/index.js +14 -3
- package/lib/locales/zh.js +21 -6
- package/lib/payment/error.js +5 -1
- package/lib/payment/footer.js +1 -1
- package/lib/payment/form/address.d.ts +9 -2
- package/lib/payment/form/address.js +67 -59
- package/lib/payment/form/currency.js +31 -24
- package/lib/payment/form/index.d.ts +1 -1
- package/lib/payment/form/index.js +92 -93
- package/lib/payment/form/phone.js +11 -59
- package/lib/payment/index.d.ts +3 -10
- package/lib/payment/index.js +302 -225
- package/lib/payment/product-card.js +5 -4
- package/lib/payment/product-donation.js +11 -7
- package/lib/payment/product-item.d.ts +2 -2
- package/lib/payment/product-item.js +38 -19
- package/lib/payment/summary.js +219 -127
- package/lib/theme/index.css +240 -0
- package/lib/theme/index.d.ts +14 -0
- package/lib/theme/index.js +273 -0
- package/lib/theme/typography.d.ts +2 -0
- package/lib/theme/typography.js +59 -0
- package/lib/types/index.d.ts +16 -0
- package/package.json +14 -11
- package/src/checkout/donate.tsx +25 -11
- package/src/checkout/form.tsx +63 -15
- package/src/checkout/table.tsx +20 -1
- package/src/components/blockchain/tx.tsx +2 -1
- package/src/components/country-select.tsx +93 -0
- package/src/components/input.tsx +49 -46
- package/src/components/livemode.tsx +1 -0
- package/src/components/pricing-table.tsx +0 -2
- package/src/components/status.tsx +1 -2
- package/src/components/table.tsx +200 -0
- package/src/contexts/payment.tsx +6 -1
- package/src/history/invoice/list.tsx +254 -49
- package/src/hooks/mobile.ts +13 -0
- package/src/index.ts +7 -0
- package/src/libs/util.ts +120 -31
- package/src/locales/en.tsx +18 -4
- package/src/locales/index.tsx +10 -3
- package/src/locales/zh.tsx +17 -3
- package/src/payment/error.tsx +2 -2
- package/src/payment/footer.tsx +1 -1
- package/src/payment/form/address.tsx +56 -47
- package/src/payment/form/currency.tsx +29 -23
- package/src/payment/form/index.tsx +89 -76
- package/src/payment/form/phone.tsx +14 -51
- package/src/payment/index.tsx +298 -231
- package/src/payment/product-card.tsx +4 -4
- package/src/payment/product-donation.tsx +9 -4
- package/src/payment/product-item.tsx +49 -20
- package/src/payment/summary.tsx +191 -108
- package/src/theme/index.css +240 -0
- package/src/theme/index.tsx +271 -0
- package/src/theme/typography.ts +56 -0
- package/src/types/index.ts +17 -0
|
@@ -0,0 +1,256 @@
|
|
|
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 { cloneDeep, merge } from "lodash";
|
|
5
|
+
import { Box, CssBaseline } from "@mui/material";
|
|
6
|
+
import { typography } from "./typography.js";
|
|
7
|
+
import "./index.css";
|
|
8
|
+
export { typography };
|
|
9
|
+
PaymentThemeProvider.defaultProps = {
|
|
10
|
+
theme: {}
|
|
11
|
+
};
|
|
12
|
+
export function PaymentThemeProvider({
|
|
13
|
+
children,
|
|
14
|
+
theme: customTheme = {}
|
|
15
|
+
}) {
|
|
16
|
+
const { sx: themeSX = {}, ...restTheme } = customTheme || {};
|
|
17
|
+
const parentTheme = useTheme();
|
|
18
|
+
const rootStyle = getComputedStyle(document.documentElement);
|
|
19
|
+
const themeOverrides = {
|
|
20
|
+
shape: {
|
|
21
|
+
borderRadius: 8
|
|
22
|
+
},
|
|
23
|
+
components: {
|
|
24
|
+
MuiOutlinedInput: {
|
|
25
|
+
styleOverrides: {
|
|
26
|
+
root: {
|
|
27
|
+
borderRadius: "var(--radius-m, 8px)",
|
|
28
|
+
backgroundColor: "var(--backgrounds-bg-field)",
|
|
29
|
+
"&.Mui-disabled": {
|
|
30
|
+
backgroundColor: "var(--backgrounds-bg-disabled)"
|
|
31
|
+
},
|
|
32
|
+
".MuiOutlinedInput-notchedOutline": {
|
|
33
|
+
borderColor: "var(--stroke-border-base, #EFF1F5)"
|
|
34
|
+
},
|
|
35
|
+
".MuiInputBase-input": {
|
|
36
|
+
fontSize: "14px",
|
|
37
|
+
minHeight: "1.65em",
|
|
38
|
+
lineHeight: "1.65em"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
MuiButton: {
|
|
44
|
+
defaultProps: {
|
|
45
|
+
size: "small"
|
|
46
|
+
},
|
|
47
|
+
styleOverrides: {
|
|
48
|
+
root: {
|
|
49
|
+
fontSize: "1rem",
|
|
50
|
+
fontWeight: 500,
|
|
51
|
+
textTransform: "none"
|
|
52
|
+
},
|
|
53
|
+
containedPrimary: {
|
|
54
|
+
backgroundColor: "var(--buttons-button-inverted, #010714)",
|
|
55
|
+
color: "var(--foregrounds-fg-on-color, #fff)",
|
|
56
|
+
"&:hover": {
|
|
57
|
+
backgroundColor: "var(--buttons-button-inverted-hover, #1f2937)"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
outlinedPrimary: {
|
|
61
|
+
color: "var(--foregrounds-fg-base, #010714)",
|
|
62
|
+
borderColor: "var(--stroke-button-secondary-border, #E5E7EB)",
|
|
63
|
+
"&:hover": {
|
|
64
|
+
backgroundColor: "var(--buttons-button-neutral-hover, #F3F4F6)",
|
|
65
|
+
borderColor: "var(--stroke-button-secondary-border, #E5E7EB)"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
sizeSmall: {
|
|
69
|
+
height: 32
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
MuiIconButton: {
|
|
74
|
+
defaultProps: {
|
|
75
|
+
size: "small"
|
|
76
|
+
},
|
|
77
|
+
styleOverrides: {
|
|
78
|
+
root: {
|
|
79
|
+
textTransform: "none"
|
|
80
|
+
},
|
|
81
|
+
colorPrimary: {
|
|
82
|
+
backgroundColor: "#fff"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
MuiToggleButton: {
|
|
87
|
+
styleOverrides: {
|
|
88
|
+
root: {
|
|
89
|
+
textTransform: "none"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
MuiTab: {
|
|
94
|
+
styleOverrides: {
|
|
95
|
+
root: {
|
|
96
|
+
textTransform: "none"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
MuiTooltip: {
|
|
101
|
+
defaultProps: {
|
|
102
|
+
enterTouchDelay: 3e3,
|
|
103
|
+
leaveTouchDelay: 100
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
MuiPopover: {
|
|
107
|
+
styleOverrides: {
|
|
108
|
+
paper: ({ theme }) => ({
|
|
109
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
110
|
+
boxShadow: "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)"
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
MuiCssBaseline: {
|
|
115
|
+
styleOverrides: {
|
|
116
|
+
".base-card": {
|
|
117
|
+
padding: "20px",
|
|
118
|
+
borderRadius: "var(--radius-l)",
|
|
119
|
+
background: "var(--backgrounds-bg-base)",
|
|
120
|
+
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))"
|
|
121
|
+
},
|
|
122
|
+
".base-label": {
|
|
123
|
+
color: "var(--foregrounds-fg-base, #010714)",
|
|
124
|
+
fontSize: "16px",
|
|
125
|
+
fontWeight: "500",
|
|
126
|
+
lineHeight: "24px"
|
|
127
|
+
},
|
|
128
|
+
a: {
|
|
129
|
+
textDecoration: "none !important"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
// MuiButtonBase: {
|
|
134
|
+
// styleOverrides: {
|
|
135
|
+
// }
|
|
136
|
+
// },
|
|
137
|
+
MuiRadio: {
|
|
138
|
+
styleOverrides: {
|
|
139
|
+
root: {
|
|
140
|
+
color: "var(--stroke-border-base, #EFF1F5)",
|
|
141
|
+
"&:hover": {
|
|
142
|
+
background: "none"
|
|
143
|
+
},
|
|
144
|
+
"&.Mui-checked": {
|
|
145
|
+
color: "var(--foregrounds-fg-interactive, #0086FF)"
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
MuiCheckbox: {
|
|
151
|
+
styleOverrides: {
|
|
152
|
+
root: {
|
|
153
|
+
color: "var(--backgrounds-bg-interactive, #0086FF)",
|
|
154
|
+
"&.Mui-checked": {
|
|
155
|
+
color: "var(--foregrounds-fg-interactive, #0086FF)"
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
MuiDivider: {
|
|
161
|
+
styleOverrides: {
|
|
162
|
+
root: {
|
|
163
|
+
borderColor: "var(--stroke-border-base, #EFF1F5)"
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
MuiInputBase: {
|
|
168
|
+
defaultProps: {
|
|
169
|
+
size: "small"
|
|
170
|
+
},
|
|
171
|
+
styleOverrides: {
|
|
172
|
+
root: () => ({
|
|
173
|
+
fontSize: "0.875rem",
|
|
174
|
+
backgroundColor: "var(--backgrounds-bg-field, #F9FAFB)"
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
MuiInputLabel: {
|
|
179
|
+
defaultProps: {
|
|
180
|
+
size: "small"
|
|
181
|
+
},
|
|
182
|
+
styleOverrides: {
|
|
183
|
+
root: () => ({
|
|
184
|
+
fontSize: "0.875rem"
|
|
185
|
+
})
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
MuiChip: {
|
|
189
|
+
styleOverrides: {
|
|
190
|
+
root: {
|
|
191
|
+
borderRadius: "var(--radius-S, 4px)",
|
|
192
|
+
border: "1px solid transparent",
|
|
193
|
+
"&.MuiChip-filledSuccess": {
|
|
194
|
+
color: "var(--tags-tag-green-text, #007C52)",
|
|
195
|
+
backgroundColor: "var(--tags-tag-green-bg, #B7FEE3)",
|
|
196
|
+
borderColor: "var(--tags-tag-green-border, #63F9CB)"
|
|
197
|
+
},
|
|
198
|
+
"&.MuiChip-filledDefault": {
|
|
199
|
+
color: "var(--tags-tag-neutral-text, #007C52)",
|
|
200
|
+
backgroundColor: "var(--tags-tag-neutral-bg, #B7FEE3)",
|
|
201
|
+
borderColor: "var(--tags-tag-neutral-border, #E5E7EB)"
|
|
202
|
+
},
|
|
203
|
+
"&.MuiChip-filledSecondary": {
|
|
204
|
+
color: "var(--tags-tag-purple-text, #8118EB)",
|
|
205
|
+
backgroundColor: " var(--tags-tag-purple-bg, #EFE9FF)",
|
|
206
|
+
borderColor: "var(--tags-tag-purple-border, #E1D6FF)"
|
|
207
|
+
},
|
|
208
|
+
"&.MuiChip-filledError": {
|
|
209
|
+
color: "var(--tags-tag-red-text, #E40031)",
|
|
210
|
+
backgroundColor: "var(--tags-tag-red-bg, #FFE2E6)",
|
|
211
|
+
borderColor: "var(--tags-tag-red-border, #FFC8D3)"
|
|
212
|
+
},
|
|
213
|
+
"&.MuiChip-filledWarning": {
|
|
214
|
+
color: "var(--tags-tag-orange-text, #D24000)",
|
|
215
|
+
backgroundColor: "var(--tags-tag-orange-bg, #FFF4BC)",
|
|
216
|
+
borderColor: "var(--tags-tag-orange-border, #FFE467)"
|
|
217
|
+
},
|
|
218
|
+
"&.MuiChip-filledPrimary,&.MuiChip-filledInfo": {
|
|
219
|
+
color: "var(--tags-tag-blue-text, #0051E9)",
|
|
220
|
+
backgroundColor: "var(--tags-tag-blue-bg, #D2ECFF)",
|
|
221
|
+
borderColor: "var(--tags-tag-blue-border, #AFDDFF)"
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
const mergeTheme = create(
|
|
229
|
+
merge(
|
|
230
|
+
cloneDeep({
|
|
231
|
+
...parentTheme,
|
|
232
|
+
typography,
|
|
233
|
+
palette: {
|
|
234
|
+
primary: {
|
|
235
|
+
main: rootStyle.getPropertyValue("--foregrounds-fg-base").trim() || "#030712"
|
|
236
|
+
},
|
|
237
|
+
text: {
|
|
238
|
+
primary: rootStyle.getPropertyValue("--foregrounds-fg-base").trim() || "#030712",
|
|
239
|
+
secondary: rootStyle.getPropertyValue("--foregrounds-fg-subtle").trim() || "#4b5563",
|
|
240
|
+
lighter: rootStyle.getPropertyValue("--foregrounds-fg-muted").trim() || "#9ca3af",
|
|
241
|
+
link: rootStyle.getPropertyValue("--foregrounds-fg-interactive").trim() || "#0086FF"
|
|
242
|
+
},
|
|
243
|
+
error: {
|
|
244
|
+
main: rootStyle.getPropertyValue("--foregrounds-fg-danger").trim() || "#FF003B"
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
...themeOverrides
|
|
248
|
+
}),
|
|
249
|
+
restTheme
|
|
250
|
+
)
|
|
251
|
+
);
|
|
252
|
+
return /* @__PURE__ */ jsxs(ThemeProvider, { theme: mergeTheme, children: [
|
|
253
|
+
/* @__PURE__ */ jsx(CssBaseline, {}),
|
|
254
|
+
/* @__PURE__ */ jsx(Box, { sx: { height: "100%", ...themeSX }, children })
|
|
255
|
+
] });
|
|
256
|
+
}
|
|
@@ -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
|
+
};
|
package/es/types/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TCheckoutSessionExpanded, TCustomer, TPaymentIntent, TPaymentLink, TPaymentMethodExpanded } from '@blocklet/payment-types';
|
|
2
|
+
import { SxProps, ThemeOptions } from '@mui/material';
|
|
2
3
|
import { LiteralUnion } from 'type-fest';
|
|
3
4
|
export type CheckoutContext = {
|
|
4
5
|
checkoutSession: TCheckoutSessionExpanded;
|
|
@@ -8,6 +9,7 @@ export type CheckoutContext = {
|
|
|
8
9
|
customer?: TCustomer;
|
|
9
10
|
mode: LiteralUnion<'standalone' | 'inline' | 'popup', string>;
|
|
10
11
|
action?: string;
|
|
12
|
+
showCheckoutSummary?: boolean;
|
|
11
13
|
};
|
|
12
14
|
export type CheckoutFormData = {
|
|
13
15
|
customer_name: string;
|
|
@@ -24,11 +26,15 @@ export type CheckoutFormData = {
|
|
|
24
26
|
postal_code: string;
|
|
25
27
|
};
|
|
26
28
|
};
|
|
29
|
+
export type PaymentThemeOptions = ThemeOptions & {
|
|
30
|
+
sx?: SxProps;
|
|
31
|
+
};
|
|
27
32
|
export type CheckoutProps = Partial<CheckoutCallbacks> & {
|
|
28
33
|
id: string;
|
|
29
34
|
extraParams?: Record<string, any>;
|
|
30
35
|
action?: string;
|
|
31
36
|
mode?: LiteralUnion<'standalone' | 'inline' | 'popup' | 'inline-minimal' | 'popup-minimal', string>;
|
|
37
|
+
theme?: 'default' | 'inherit' | PaymentThemeOptions;
|
|
32
38
|
};
|
|
33
39
|
export type CheckoutCallbacks = {
|
|
34
40
|
onPaid: (res: CheckoutContext) => void;
|
|
@@ -42,3 +48,13 @@ export type PricingRenderProps = {
|
|
|
42
48
|
quantity: string;
|
|
43
49
|
totalAmount: string;
|
|
44
50
|
};
|
|
51
|
+
export type ActionProps = {
|
|
52
|
+
[key: string]: {
|
|
53
|
+
color?: string;
|
|
54
|
+
variant?: string;
|
|
55
|
+
sx?: {
|
|
56
|
+
[key: string]: any;
|
|
57
|
+
};
|
|
58
|
+
text?: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
package/lib/checkout/donate.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { DonationSettings, TCheckoutSessionExpanded, TPaymentCurrency, TPaymentMethod } from '@blocklet/payment-types';
|
|
3
3
|
import { ButtonProps as MUIButtonProps } from '@mui/material';
|
|
4
|
-
import { CheckoutProps } from '../types';
|
|
4
|
+
import { CheckoutProps, PaymentThemeOptions } from '../types';
|
|
5
5
|
export type DonateHistory = {
|
|
6
6
|
supporters: TCheckoutSessionExpanded[];
|
|
7
7
|
currency: TPaymentCurrency;
|
|
@@ -20,10 +20,12 @@ export type DonateProps = Pick<CheckoutProps, 'onPaid' | 'onError'> & {
|
|
|
20
20
|
inlineOptions?: {
|
|
21
21
|
button?: ButtonType;
|
|
22
22
|
};
|
|
23
|
+
theme?: 'default' | 'inherit' | PaymentThemeOptions;
|
|
23
24
|
};
|
|
24
|
-
declare function CheckoutDonate(
|
|
25
|
+
declare function CheckoutDonate(props: DonateProps): import("react").JSX.Element;
|
|
25
26
|
declare namespace CheckoutDonate {
|
|
26
27
|
var defaultProps: {
|
|
28
|
+
theme: string;
|
|
27
29
|
livemode: boolean;
|
|
28
30
|
timeout: number;
|
|
29
31
|
mode: string;
|
package/lib/checkout/donate.js
CHANGED
|
@@ -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
|
|
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,7 +465,28 @@ function CheckoutDonate({
|
|
|
465
465
|
})]
|
|
466
466
|
});
|
|
467
467
|
}
|
|
468
|
+
function CheckoutDonate(props) {
|
|
469
|
+
if (props.theme === "inherit") {
|
|
470
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(CheckoutDonateInner, {
|
|
471
|
+
...props
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
if (props.theme && typeof props.theme === "object") {
|
|
475
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_theme.PaymentThemeProvider, {
|
|
476
|
+
theme: props.theme,
|
|
477
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(CheckoutDonateInner, {
|
|
478
|
+
...props
|
|
479
|
+
})
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_theme.PaymentThemeProvider, {
|
|
483
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(CheckoutDonateInner, {
|
|
484
|
+
...props
|
|
485
|
+
})
|
|
486
|
+
});
|
|
487
|
+
}
|
|
468
488
|
CheckoutDonate.defaultProps = {
|
|
489
|
+
theme: "default",
|
|
469
490
|
livemode: true,
|
|
470
491
|
timeout: 5e3,
|
|
471
492
|
mode: "default",
|
package/lib/checkout/form.d.ts
CHANGED
|
@@ -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, theme, ...restProps }: CheckoutProps): import("react").JSX.Element;
|
|
4
4
|
declare namespace CheckoutForm {
|
|
5
5
|
var defaultProps: {
|
|
6
6
|
onPaid: any;
|
package/lib/checkout/form.js
CHANGED
|
@@ -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,9 @@ function CheckoutForm({
|
|
|
38
39
|
onChange,
|
|
39
40
|
goBack,
|
|
40
41
|
extraParams,
|
|
41
|
-
action
|
|
42
|
+
action,
|
|
43
|
+
theme = "default",
|
|
44
|
+
...restProps
|
|
42
45
|
}) {
|
|
43
46
|
if (!id.startsWith("plink_") && !id.startsWith("cs_")) {
|
|
44
47
|
throw new Error("Either a checkoutSession or a paymentLink id is required.");
|
|
@@ -70,20 +73,62 @@ function CheckoutForm({
|
|
|
70
73
|
});
|
|
71
74
|
onError?.(err);
|
|
72
75
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
76
|
+
if (theme === "inherit") {
|
|
77
|
+
return /* @__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
|
+
...restProps
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (theme && typeof theme === "object") {
|
|
95
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_theme.PaymentThemeProvider, {
|
|
96
|
+
theme,
|
|
97
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_payment.default, {
|
|
98
|
+
checkoutSession: data?.checkoutSession,
|
|
99
|
+
paymentMethods: data?.paymentMethods,
|
|
100
|
+
paymentIntent: data?.paymentIntent,
|
|
101
|
+
paymentLink: data?.paymentLink,
|
|
102
|
+
customer: data?.customer,
|
|
103
|
+
completed: state.completed,
|
|
104
|
+
error: apiError || state.appError,
|
|
105
|
+
onPaid: handlePaid,
|
|
106
|
+
onError: handleError,
|
|
107
|
+
onChange,
|
|
108
|
+
goBack,
|
|
109
|
+
mode,
|
|
110
|
+
action,
|
|
111
|
+
...restProps
|
|
112
|
+
})
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_theme.PaymentThemeProvider, {
|
|
116
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_payment.default, {
|
|
117
|
+
checkoutSession: data?.checkoutSession,
|
|
118
|
+
paymentMethods: data?.paymentMethods,
|
|
119
|
+
paymentIntent: data?.paymentIntent,
|
|
120
|
+
paymentLink: data?.paymentLink,
|
|
121
|
+
customer: data?.customer,
|
|
122
|
+
completed: state.completed,
|
|
123
|
+
error: apiError || state.appError,
|
|
124
|
+
onPaid: handlePaid,
|
|
125
|
+
onError: handleError,
|
|
126
|
+
onChange,
|
|
127
|
+
goBack,
|
|
128
|
+
mode,
|
|
129
|
+
action,
|
|
130
|
+
...restProps
|
|
131
|
+
})
|
|
87
132
|
});
|
|
88
133
|
}
|
|
89
134
|
CheckoutForm.defaultProps = {
|
package/lib/checkout/table.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CheckoutProps } from '../types';
|
|
3
|
-
export default function CheckoutTable(
|
|
3
|
+
export default function CheckoutTable(props: CheckoutProps): import("react").JSX.Element;
|
package/lib/checkout/table.js
CHANGED
|
@@ -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
|
|
33
|
+
function CheckoutTableInner({
|
|
33
34
|
id,
|
|
34
35
|
mode,
|
|
35
36
|
onPaid,
|
|
@@ -145,4 +146,24 @@ function CheckoutTable({
|
|
|
145
146
|
...prop
|
|
146
147
|
})
|
|
147
148
|
});
|
|
149
|
+
}
|
|
150
|
+
function CheckoutTable(props) {
|
|
151
|
+
if (props.theme === "inherit") {
|
|
152
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(CheckoutTableInner, {
|
|
153
|
+
...props
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
if (props.theme && typeof props.theme === "object") {
|
|
157
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_theme.PaymentThemeProvider, {
|
|
158
|
+
theme: props.theme,
|
|
159
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(CheckoutTableInner, {
|
|
160
|
+
...props
|
|
161
|
+
})
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_theme.PaymentThemeProvider, {
|
|
165
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(CheckoutTableInner, {
|
|
166
|
+
...props
|
|
167
|
+
})
|
|
168
|
+
});
|
|
148
169
|
}
|
|
@@ -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: "
|
|
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;
|