@blocklet/payment-react 1.14.22 → 1.14.24
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 +3 -2
- package/es/checkout/donate.js +31 -4
- package/es/checkout/form.d.ts +1 -1
- package/es/checkout/form.js +31 -7
- package/es/checkout/table.js +4 -1
- package/es/components/input.d.ts +3 -3
- package/es/libs/util.d.ts +6 -6
- package/es/payment/index.d.ts +3 -1
- package/es/payment/index.js +67 -51
- package/es/payment/product-donation.js +26 -15
- package/es/payment/summary.js +1 -1
- package/es/theme/index.d.ts +8 -3
- package/es/theme/index.js +222 -209
- package/es/types/index.d.ts +6 -1
- package/lib/checkout/donate.d.ts +3 -2
- package/lib/checkout/donate.js +29 -5
- package/lib/checkout/form.d.ts +1 -1
- package/lib/checkout/form.js +41 -17
- package/lib/checkout/table.js +9 -1
- package/lib/components/input.d.ts +3 -3
- package/lib/libs/util.d.ts +6 -6
- package/lib/payment/index.d.ts +3 -1
- package/lib/payment/index.js +31 -26
- package/lib/payment/product-donation.js +5 -7
- package/lib/payment/summary.js +1 -1
- package/lib/theme/index.d.ts +8 -3
- package/lib/theme/index.js +211 -197
- package/lib/types/index.d.ts +6 -1
- package/package.json +3 -3
- package/src/checkout/donate.tsx +36 -5
- package/src/checkout/form.tsx +43 -18
- package/src/checkout/table.tsx +8 -1
- package/src/payment/index.tsx +66 -51
- package/src/payment/product-donation.tsx +9 -3
- package/src/payment/summary.tsx +1 -1
- package/src/theme/index.tsx +224 -203
- package/src/types/index.ts +6 -1
package/es/theme/index.js
CHANGED
|
@@ -1,243 +1,256 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ThemeProvider, useTheme } from "@mui/material/styles";
|
|
3
3
|
import { create } from "@arcblock/ux/lib/Theme";
|
|
4
|
-
import {
|
|
4
|
+
import { cloneDeep, merge } from "lodash";
|
|
5
|
+
import { Box, CssBaseline } from "@mui/material";
|
|
5
6
|
import { typography } from "./typography.js";
|
|
6
7
|
import "./index.css";
|
|
7
8
|
export { typography };
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
+
}
|
|
28
40
|
}
|
|
29
41
|
}
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
MuiButton: {
|
|
33
|
-
defaultProps: {
|
|
34
|
-
size: "small"
|
|
35
42
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
fontWeight: 500,
|
|
40
|
-
textTransform: "none"
|
|
43
|
+
MuiButton: {
|
|
44
|
+
defaultProps: {
|
|
45
|
+
size: "small"
|
|
41
46
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
|
47
70
|
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
MuiIconButton: {
|
|
74
|
+
defaultProps: {
|
|
75
|
+
size: "small"
|
|
48
76
|
},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
77
|
+
styleOverrides: {
|
|
78
|
+
root: {
|
|
79
|
+
textTransform: "none"
|
|
80
|
+
},
|
|
81
|
+
colorPrimary: {
|
|
82
|
+
backgroundColor: "#fff"
|
|
55
83
|
}
|
|
56
|
-
},
|
|
57
|
-
sizeSmall: {
|
|
58
|
-
height: 32
|
|
59
84
|
}
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
MuiIconButton: {
|
|
63
|
-
defaultProps: {
|
|
64
|
-
size: "small"
|
|
65
85
|
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
backgroundColor: "#fff"
|
|
86
|
+
MuiToggleButton: {
|
|
87
|
+
styleOverrides: {
|
|
88
|
+
root: {
|
|
89
|
+
textTransform: "none"
|
|
90
|
+
}
|
|
72
91
|
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
92
|
+
},
|
|
93
|
+
MuiTab: {
|
|
94
|
+
styleOverrides: {
|
|
95
|
+
root: {
|
|
96
|
+
textTransform: "none"
|
|
97
|
+
}
|
|
79
98
|
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
textTransform: "none"
|
|
99
|
+
},
|
|
100
|
+
MuiTooltip: {
|
|
101
|
+
defaultProps: {
|
|
102
|
+
enterTouchDelay: 3e3,
|
|
103
|
+
leaveTouchDelay: 100
|
|
86
104
|
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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"
|
|
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
|
+
})
|
|
119
112
|
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
root: {
|
|
129
|
-
color: "var(--stroke-border-base, #EFF1F5)",
|
|
130
|
-
"&:hover": {
|
|
131
|
-
background: "none"
|
|
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))"
|
|
132
121
|
},
|
|
133
|
-
"
|
|
134
|
-
color: "var(--foregrounds-fg-
|
|
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"
|
|
135
130
|
}
|
|
136
131
|
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
+
}
|
|
145
147
|
}
|
|
146
148
|
}
|
|
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
149
|
},
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
size: "small"
|
|
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
|
+
}
|
|
170
159
|
},
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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)"
|
|
160
|
+
MuiDivider: {
|
|
161
|
+
styleOverrides: {
|
|
162
|
+
root: {
|
|
163
|
+
borderColor: "var(--stroke-border-base, #EFF1F5)"
|
|
211
164
|
}
|
|
212
165
|
}
|
|
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
166
|
},
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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
|
+
}
|
|
232
177
|
},
|
|
233
|
-
|
|
234
|
-
|
|
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
|
+
}
|
|
235
225
|
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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: [
|
|
240
253
|
/* @__PURE__ */ jsx(CssBaseline, {}),
|
|
241
|
-
children
|
|
254
|
+
/* @__PURE__ */ jsx(Box, { sx: { height: "100%", ...themeSX }, children })
|
|
242
255
|
] });
|
|
243
256
|
}
|
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,12 +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>;
|
|
32
|
-
|
|
37
|
+
theme?: 'default' | 'inherit' | PaymentThemeOptions;
|
|
33
38
|
};
|
|
34
39
|
export type CheckoutCallbacks = {
|
|
35
40
|
onPaid: (res: CheckoutContext) => void;
|
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,11 +20,12 @@ export type DonateProps = Pick<CheckoutProps, 'onPaid' | 'onError'> & {
|
|
|
20
20
|
inlineOptions?: {
|
|
21
21
|
button?: ButtonType;
|
|
22
22
|
};
|
|
23
|
-
|
|
23
|
+
theme?: 'default' | 'inherit' | PaymentThemeOptions;
|
|
24
24
|
};
|
|
25
25
|
declare function CheckoutDonate(props: DonateProps): import("react").JSX.Element;
|
|
26
26
|
declare namespace CheckoutDonate {
|
|
27
27
|
var defaultProps: {
|
|
28
|
+
theme: string;
|
|
28
29
|
livemode: boolean;
|
|
29
30
|
timeout: number;
|
|
30
31
|
mode: string;
|
package/lib/checkout/donate.js
CHANGED
|
@@ -293,7 +293,8 @@ function CheckoutDonateInner({
|
|
|
293
293
|
onPaid,
|
|
294
294
|
onError,
|
|
295
295
|
mode,
|
|
296
|
-
inlineOptions = {}
|
|
296
|
+
inlineOptions = {},
|
|
297
|
+
theme
|
|
297
298
|
}) {
|
|
298
299
|
const {
|
|
299
300
|
state,
|
|
@@ -446,31 +447,53 @@ function CheckoutDonateInner({
|
|
|
446
447
|
maxWidth: "md",
|
|
447
448
|
showCloseButton: true,
|
|
448
449
|
disableEscapeKeyDown: true,
|
|
450
|
+
sx: {
|
|
451
|
+
".MuiDialogContent-root": {
|
|
452
|
+
padding: {
|
|
453
|
+
xs: 0,
|
|
454
|
+
md: "0 16px 0"
|
|
455
|
+
},
|
|
456
|
+
borderTop: "1px solid var(--stroke-border-base, #EFF1F5)",
|
|
457
|
+
width: {
|
|
458
|
+
xs: "100%",
|
|
459
|
+
md: 900
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
},
|
|
449
463
|
onClose: (e, reason) => setState({
|
|
450
464
|
open: reason === "backdropClick"
|
|
451
465
|
}),
|
|
452
466
|
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
453
467
|
sx: {
|
|
454
|
-
|
|
455
|
-
|
|
468
|
+
height: "100%",
|
|
469
|
+
width: "100%"
|
|
456
470
|
},
|
|
457
471
|
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_form.default, {
|
|
458
472
|
id: donation.data?.id,
|
|
459
473
|
onPaid: handlePaid,
|
|
460
474
|
onError,
|
|
461
475
|
action: settings.appearance?.button?.text,
|
|
462
|
-
mode: "inline"
|
|
476
|
+
mode: "inline",
|
|
477
|
+
theme
|
|
463
478
|
})
|
|
464
479
|
})
|
|
465
480
|
})]
|
|
466
481
|
});
|
|
467
482
|
}
|
|
468
483
|
function CheckoutDonate(props) {
|
|
469
|
-
if (props.
|
|
484
|
+
if (props.theme === "inherit") {
|
|
470
485
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(CheckoutDonateInner, {
|
|
471
486
|
...props
|
|
472
487
|
});
|
|
473
488
|
}
|
|
489
|
+
if (props.theme && typeof props.theme === "object") {
|
|
490
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_theme.PaymentThemeProvider, {
|
|
491
|
+
theme: props.theme,
|
|
492
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(CheckoutDonateInner, {
|
|
493
|
+
...props
|
|
494
|
+
})
|
|
495
|
+
});
|
|
496
|
+
}
|
|
474
497
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_theme.PaymentThemeProvider, {
|
|
475
498
|
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(CheckoutDonateInner, {
|
|
476
499
|
...props
|
|
@@ -478,6 +501,7 @@ function CheckoutDonate(props) {
|
|
|
478
501
|
});
|
|
479
502
|
}
|
|
480
503
|
CheckoutDonate.defaultProps = {
|
|
504
|
+
theme: "default",
|
|
481
505
|
livemode: true,
|
|
482
506
|
timeout: 5e3,
|
|
483
507
|
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,
|
|
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;
|