@blocklet/payment-react 1.14.22 → 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 +3 -2
- package/es/checkout/donate.js +5 -1
- 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 +2 -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 +10 -1
- 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 +2 -5
- 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 +11 -3
- 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 +2 -1
- package/src/theme/index.tsx +224 -203
- package/src/types/index.ts +6 -1
package/lib/theme/index.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.PaymentThemeProvider = PaymentThemeProvider;
|
|
7
|
-
exports.themeOverrides = void 0;
|
|
8
7
|
Object.defineProperty(exports, "typography", {
|
|
9
8
|
enumerable: true,
|
|
10
9
|
get: function () {
|
|
@@ -14,227 +13,236 @@ Object.defineProperty(exports, "typography", {
|
|
|
14
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
14
|
var _styles = require("@mui/material/styles");
|
|
16
15
|
var _Theme = require("@arcblock/ux/lib/Theme");
|
|
16
|
+
var _lodash = require("lodash");
|
|
17
17
|
var _material = require("@mui/material");
|
|
18
18
|
var _typography = require("./typography");
|
|
19
19
|
require("./index.css");
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
20
|
+
PaymentThemeProvider.defaultProps = {
|
|
21
|
+
theme: {}
|
|
22
|
+
};
|
|
23
|
+
function PaymentThemeProvider({
|
|
24
|
+
children,
|
|
25
|
+
theme: customTheme = {}
|
|
26
|
+
}) {
|
|
27
|
+
const {
|
|
28
|
+
sx: themeSX = {},
|
|
29
|
+
...restTheme
|
|
30
|
+
} = customTheme || {};
|
|
31
|
+
const parentTheme = (0, _styles.useTheme)();
|
|
32
|
+
const rootStyle = getComputedStyle(document.documentElement);
|
|
33
|
+
const themeOverrides = {
|
|
34
|
+
shape: {
|
|
35
|
+
borderRadius: 8
|
|
36
|
+
},
|
|
37
|
+
components: {
|
|
38
|
+
MuiOutlinedInput: {
|
|
39
|
+
styleOverrides: {
|
|
40
|
+
root: {
|
|
41
|
+
borderRadius: "var(--radius-m, 8px)",
|
|
42
|
+
backgroundColor: "var(--backgrounds-bg-field)",
|
|
43
|
+
"&.Mui-disabled": {
|
|
44
|
+
backgroundColor: "var(--backgrounds-bg-disabled)"
|
|
45
|
+
},
|
|
46
|
+
".MuiOutlinedInput-notchedOutline": {
|
|
47
|
+
borderColor: "var(--stroke-border-base, #EFF1F5)"
|
|
48
|
+
},
|
|
49
|
+
".MuiInputBase-input": {
|
|
50
|
+
fontSize: "14px",
|
|
51
|
+
minHeight: "1.65em",
|
|
52
|
+
lineHeight: "1.65em"
|
|
53
|
+
}
|
|
40
54
|
}
|
|
41
55
|
}
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
MuiButton: {
|
|
45
|
-
defaultProps: {
|
|
46
|
-
size: "small"
|
|
47
56
|
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
fontWeight: 500,
|
|
52
|
-
textTransform: "none"
|
|
57
|
+
MuiButton: {
|
|
58
|
+
defaultProps: {
|
|
59
|
+
size: "small"
|
|
53
60
|
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
styleOverrides: {
|
|
62
|
+
root: {
|
|
63
|
+
fontSize: "1rem",
|
|
64
|
+
fontWeight: 500,
|
|
65
|
+
textTransform: "none"
|
|
66
|
+
},
|
|
67
|
+
containedPrimary: {
|
|
68
|
+
backgroundColor: "var(--buttons-button-inverted, #010714)",
|
|
69
|
+
color: "var(--foregrounds-fg-on-color, #fff)",
|
|
70
|
+
"&:hover": {
|
|
71
|
+
backgroundColor: "var(--buttons-button-inverted-hover, #1f2937)"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
outlinedPrimary: {
|
|
75
|
+
color: "var(--foregrounds-fg-base, #010714)",
|
|
76
|
+
borderColor: "var(--stroke-button-secondary-border, #E5E7EB)",
|
|
77
|
+
"&:hover": {
|
|
78
|
+
backgroundColor: "var(--buttons-button-neutral-hover, #F3F4F6)",
|
|
79
|
+
borderColor: "var(--stroke-button-secondary-border, #E5E7EB)"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
sizeSmall: {
|
|
83
|
+
height: 32
|
|
59
84
|
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
MuiIconButton: {
|
|
88
|
+
defaultProps: {
|
|
89
|
+
size: "small"
|
|
60
90
|
},
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
91
|
+
styleOverrides: {
|
|
92
|
+
root: {
|
|
93
|
+
textTransform: "none"
|
|
94
|
+
},
|
|
95
|
+
colorPrimary: {
|
|
96
|
+
backgroundColor: "#fff"
|
|
67
97
|
}
|
|
68
|
-
},
|
|
69
|
-
sizeSmall: {
|
|
70
|
-
height: 32
|
|
71
98
|
}
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
MuiIconButton: {
|
|
75
|
-
defaultProps: {
|
|
76
|
-
size: "small"
|
|
77
99
|
},
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
backgroundColor: "#fff"
|
|
100
|
+
MuiToggleButton: {
|
|
101
|
+
styleOverrides: {
|
|
102
|
+
root: {
|
|
103
|
+
textTransform: "none"
|
|
104
|
+
}
|
|
84
105
|
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
106
|
+
},
|
|
107
|
+
MuiTab: {
|
|
108
|
+
styleOverrides: {
|
|
109
|
+
root: {
|
|
110
|
+
textTransform: "none"
|
|
111
|
+
}
|
|
91
112
|
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
textTransform: "none"
|
|
113
|
+
},
|
|
114
|
+
MuiTooltip: {
|
|
115
|
+
defaultProps: {
|
|
116
|
+
enterTouchDelay: 3e3,
|
|
117
|
+
leaveTouchDelay: 100
|
|
98
118
|
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
styleOverrides: {
|
|
109
|
-
paper: ({
|
|
110
|
-
theme
|
|
111
|
-
}) => ({
|
|
112
|
-
border: `1px solid ${theme.palette.divider}`,
|
|
113
|
-
boxShadow: "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)"
|
|
114
|
-
})
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
MuiCssBaseline: {
|
|
118
|
-
styleOverrides: {
|
|
119
|
-
".base-card": {
|
|
120
|
-
padding: "20px",
|
|
121
|
-
borderRadius: "var(--radius-l)",
|
|
122
|
-
background: "var(--backgrounds-bg-base)",
|
|
123
|
-
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))"
|
|
124
|
-
},
|
|
125
|
-
".base-label": {
|
|
126
|
-
color: "var(--foregrounds-fg-base, #010714)",
|
|
127
|
-
fontSize: "16px",
|
|
128
|
-
fontWeight: "500",
|
|
129
|
-
lineHeight: "24px"
|
|
130
|
-
},
|
|
131
|
-
a: {
|
|
132
|
-
textDecoration: "none !important"
|
|
119
|
+
},
|
|
120
|
+
MuiPopover: {
|
|
121
|
+
styleOverrides: {
|
|
122
|
+
paper: ({
|
|
123
|
+
theme
|
|
124
|
+
}) => ({
|
|
125
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
126
|
+
boxShadow: "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)"
|
|
127
|
+
})
|
|
133
128
|
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
129
|
+
},
|
|
130
|
+
MuiCssBaseline: {
|
|
131
|
+
styleOverrides: {
|
|
132
|
+
".base-card": {
|
|
133
|
+
padding: "20px",
|
|
134
|
+
borderRadius: "var(--radius-l)",
|
|
135
|
+
background: "var(--backgrounds-bg-base)",
|
|
136
|
+
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))"
|
|
137
|
+
},
|
|
138
|
+
".base-label": {
|
|
139
|
+
color: "var(--foregrounds-fg-base, #010714)",
|
|
140
|
+
fontSize: "16px",
|
|
141
|
+
fontWeight: "500",
|
|
142
|
+
lineHeight: "24px"
|
|
146
143
|
},
|
|
147
|
-
|
|
148
|
-
|
|
144
|
+
a: {
|
|
145
|
+
textDecoration: "none !important"
|
|
149
146
|
}
|
|
150
147
|
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
148
|
+
},
|
|
149
|
+
// MuiButtonBase: {
|
|
150
|
+
// styleOverrides: {
|
|
151
|
+
// }
|
|
152
|
+
// },
|
|
153
|
+
MuiRadio: {
|
|
154
|
+
styleOverrides: {
|
|
155
|
+
root: {
|
|
156
|
+
color: "var(--stroke-border-base, #EFF1F5)",
|
|
157
|
+
"&:hover": {
|
|
158
|
+
background: "none"
|
|
159
|
+
},
|
|
160
|
+
"&.Mui-checked": {
|
|
161
|
+
color: "var(--foregrounds-fg-interactive, #0086FF)"
|
|
162
|
+
}
|
|
159
163
|
}
|
|
160
164
|
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
},
|
|
166
|
+
MuiCheckbox: {
|
|
167
|
+
styleOverrides: {
|
|
168
|
+
root: {
|
|
169
|
+
color: "var(--backgrounds-bg-interactive, #0086FF)",
|
|
170
|
+
"&.Mui-checked": {
|
|
171
|
+
color: "var(--foregrounds-fg-interactive, #0086FF)"
|
|
172
|
+
}
|
|
173
|
+
}
|
|
167
174
|
}
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
MuiInputBase: {
|
|
171
|
-
defaultProps: {
|
|
172
|
-
size: "small"
|
|
173
175
|
},
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
},
|
|
181
|
-
MuiInputLabel: {
|
|
182
|
-
defaultProps: {
|
|
183
|
-
size: "small"
|
|
176
|
+
MuiDivider: {
|
|
177
|
+
styleOverrides: {
|
|
178
|
+
root: {
|
|
179
|
+
borderColor: "var(--stroke-border-base, #EFF1F5)"
|
|
180
|
+
}
|
|
181
|
+
}
|
|
184
182
|
},
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
183
|
+
MuiInputBase: {
|
|
184
|
+
defaultProps: {
|
|
185
|
+
size: "small"
|
|
186
|
+
},
|
|
187
|
+
styleOverrides: {
|
|
188
|
+
root: () => ({
|
|
189
|
+
fontSize: "0.875rem",
|
|
190
|
+
backgroundColor: "var(--backgrounds-bg-field, #F9FAFB)"
|
|
191
|
+
})
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
MuiInputLabel: {
|
|
195
|
+
defaultProps: {
|
|
196
|
+
size: "small"
|
|
197
|
+
},
|
|
198
|
+
styleOverrides: {
|
|
199
|
+
root: () => ({
|
|
200
|
+
fontSize: "0.875rem"
|
|
201
|
+
})
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
MuiChip: {
|
|
205
|
+
styleOverrides: {
|
|
206
|
+
root: {
|
|
207
|
+
borderRadius: "var(--radius-S, 4px)",
|
|
208
|
+
border: "1px solid transparent",
|
|
209
|
+
"&.MuiChip-filledSuccess": {
|
|
210
|
+
color: "var(--tags-tag-green-text, #007C52)",
|
|
211
|
+
backgroundColor: "var(--tags-tag-green-bg, #B7FEE3)",
|
|
212
|
+
borderColor: "var(--tags-tag-green-border, #63F9CB)"
|
|
213
|
+
},
|
|
214
|
+
"&.MuiChip-filledDefault": {
|
|
215
|
+
color: "var(--tags-tag-neutral-text, #007C52)",
|
|
216
|
+
backgroundColor: "var(--tags-tag-neutral-bg, #B7FEE3)",
|
|
217
|
+
borderColor: "var(--tags-tag-neutral-border, #E5E7EB)"
|
|
218
|
+
},
|
|
219
|
+
"&.MuiChip-filledSecondary": {
|
|
220
|
+
color: "var(--tags-tag-purple-text, #8118EB)",
|
|
221
|
+
backgroundColor: " var(--tags-tag-purple-bg, #EFE9FF)",
|
|
222
|
+
borderColor: "var(--tags-tag-purple-border, #E1D6FF)"
|
|
223
|
+
},
|
|
224
|
+
"&.MuiChip-filledError": {
|
|
225
|
+
color: "var(--tags-tag-red-text, #E40031)",
|
|
226
|
+
backgroundColor: "var(--tags-tag-red-bg, #FFE2E6)",
|
|
227
|
+
borderColor: "var(--tags-tag-red-border, #FFC8D3)"
|
|
228
|
+
},
|
|
229
|
+
"&.MuiChip-filledWarning": {
|
|
230
|
+
color: "var(--tags-tag-orange-text, #D24000)",
|
|
231
|
+
backgroundColor: "var(--tags-tag-orange-bg, #FFF4BC)",
|
|
232
|
+
borderColor: "var(--tags-tag-orange-border, #FFE467)"
|
|
233
|
+
},
|
|
234
|
+
"&.MuiChip-filledPrimary,&.MuiChip-filledInfo": {
|
|
235
|
+
color: "var(--tags-tag-blue-text, #0051E9)",
|
|
236
|
+
backgroundColor: "var(--tags-tag-blue-bg, #D2ECFF)",
|
|
237
|
+
borderColor: "var(--tags-tag-blue-border, #AFDDFF)"
|
|
238
|
+
}
|
|
225
239
|
}
|
|
226
240
|
}
|
|
227
241
|
}
|
|
228
242
|
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
children
|
|
233
|
-
}) {
|
|
234
|
-
const theme = (0, _styles.useTheme)();
|
|
235
|
-
const rootStyle = getComputedStyle(document.documentElement);
|
|
236
|
-
const merged = (0, _Theme.create)({
|
|
237
|
-
...theme,
|
|
243
|
+
};
|
|
244
|
+
const mergeTheme = (0, _Theme.create)((0, _lodash.merge)((0, _lodash.cloneDeep)({
|
|
245
|
+
...parentTheme,
|
|
238
246
|
typography: _typography.typography,
|
|
239
247
|
palette: {
|
|
240
248
|
primary: {
|
|
@@ -251,9 +259,15 @@ function PaymentThemeProvider({
|
|
|
251
259
|
}
|
|
252
260
|
},
|
|
253
261
|
...themeOverrides
|
|
254
|
-
});
|
|
262
|
+
}), restTheme));
|
|
255
263
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_styles.ThemeProvider, {
|
|
256
|
-
theme:
|
|
257
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.CssBaseline, {}),
|
|
264
|
+
theme: mergeTheme,
|
|
265
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.CssBaseline, {}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
266
|
+
sx: {
|
|
267
|
+
height: "100%",
|
|
268
|
+
...themeSX
|
|
269
|
+
},
|
|
270
|
+
children
|
|
271
|
+
})]
|
|
258
272
|
});
|
|
259
273
|
}
|
package/lib/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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.23",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"@babel/core": "^7.25.2",
|
|
94
94
|
"@babel/preset-env": "^7.25.2",
|
|
95
95
|
"@babel/preset-react": "^7.24.7",
|
|
96
|
-
"@blocklet/payment-types": "1.14.
|
|
96
|
+
"@blocklet/payment-types": "1.14.23",
|
|
97
97
|
"@storybook/addon-essentials": "^7.6.20",
|
|
98
98
|
"@storybook/addon-interactions": "^7.6.20",
|
|
99
99
|
"@storybook/addon-links": "^7.6.20",
|
|
@@ -123,5 +123,5 @@
|
|
|
123
123
|
"vite-plugin-babel": "^1.2.0",
|
|
124
124
|
"vite-plugin-node-polyfills": "^0.21.0"
|
|
125
125
|
},
|
|
126
|
-
"gitHead": "
|
|
126
|
+
"gitHead": "868311b6e37e21e5755e7a78daf335f3057dd1c8"
|
|
127
127
|
}
|
package/src/checkout/donate.tsx
CHANGED
|
@@ -35,7 +35,7 @@ import { useEffect, useState } from 'react';
|
|
|
35
35
|
import TxLink from '../components/blockchain/tx';
|
|
36
36
|
import api from '../libs/api';
|
|
37
37
|
import { formatAmount, formatBNStr, formatDateTime, formatError, lazyLoad } from '../libs/util';
|
|
38
|
-
import { CheckoutProps } from '../types';
|
|
38
|
+
import { CheckoutProps, PaymentThemeOptions } from '../types';
|
|
39
39
|
import CheckoutForm from './form';
|
|
40
40
|
import { PaymentThemeProvider } from '../theme';
|
|
41
41
|
|
|
@@ -60,7 +60,7 @@ export type DonateProps = Pick<CheckoutProps, 'onPaid' | 'onError'> & {
|
|
|
60
60
|
inlineOptions?: {
|
|
61
61
|
button?: ButtonType;
|
|
62
62
|
};
|
|
63
|
-
|
|
63
|
+
theme?: 'default' | 'inherit' | PaymentThemeOptions;
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
const donationCache: { [key: string]: Promise<TPaymentLink> } = {};
|
|
@@ -459,9 +459,16 @@ function CheckoutDonateInner({ settings, livemode, timeout, onPaid, onError, mod
|
|
|
459
459
|
}
|
|
460
460
|
|
|
461
461
|
export default function CheckoutDonate(props: DonateProps) {
|
|
462
|
-
if (props.
|
|
462
|
+
if (props.theme === 'inherit') {
|
|
463
463
|
return <CheckoutDonateInner {...props} />;
|
|
464
464
|
}
|
|
465
|
+
if (props.theme && typeof props.theme === 'object') {
|
|
466
|
+
return (
|
|
467
|
+
<PaymentThemeProvider theme={props.theme}>
|
|
468
|
+
<CheckoutDonateInner {...props} />
|
|
469
|
+
</PaymentThemeProvider>
|
|
470
|
+
);
|
|
471
|
+
}
|
|
465
472
|
return (
|
|
466
473
|
<PaymentThemeProvider>
|
|
467
474
|
<CheckoutDonateInner {...props} />
|
|
@@ -470,6 +477,7 @@ export default function CheckoutDonate(props: DonateProps) {
|
|
|
470
477
|
}
|
|
471
478
|
|
|
472
479
|
CheckoutDonate.defaultProps = {
|
|
480
|
+
theme: 'default',
|
|
473
481
|
livemode: true,
|
|
474
482
|
timeout: 5000,
|
|
475
483
|
mode: 'default',
|
package/src/checkout/form.tsx
CHANGED
|
@@ -40,7 +40,8 @@ export default function CheckoutForm({
|
|
|
40
40
|
goBack,
|
|
41
41
|
extraParams,
|
|
42
42
|
action,
|
|
43
|
-
|
|
43
|
+
theme = 'default',
|
|
44
|
+
...restProps
|
|
44
45
|
}: CheckoutProps) {
|
|
45
46
|
if (!id.startsWith('plink_') && !id.startsWith('cs_')) {
|
|
46
47
|
throw new Error('Either a checkoutSession or a paymentLink id is required.');
|
|
@@ -75,9 +76,29 @@ export default function CheckoutForm({
|
|
|
75
76
|
onError?.(err);
|
|
76
77
|
};
|
|
77
78
|
|
|
78
|
-
if (
|
|
79
|
+
if (theme === 'inherit') {
|
|
79
80
|
return (
|
|
80
|
-
<
|
|
81
|
+
<Payment
|
|
82
|
+
checkoutSession={data?.checkoutSession as TCheckoutSessionExpanded}
|
|
83
|
+
paymentMethods={data?.paymentMethods as TPaymentMethodExpanded[]}
|
|
84
|
+
paymentIntent={data?.paymentIntent}
|
|
85
|
+
paymentLink={data?.paymentLink}
|
|
86
|
+
customer={data?.customer}
|
|
87
|
+
completed={state.completed}
|
|
88
|
+
error={apiError || state.appError}
|
|
89
|
+
onPaid={handlePaid}
|
|
90
|
+
onError={handleError}
|
|
91
|
+
onChange={onChange}
|
|
92
|
+
goBack={goBack}
|
|
93
|
+
mode={mode as string}
|
|
94
|
+
action={action}
|
|
95
|
+
{...restProps}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
if (theme && typeof theme === 'object') {
|
|
100
|
+
return (
|
|
101
|
+
<PaymentThemeProvider theme={theme}>
|
|
81
102
|
<Payment
|
|
82
103
|
checkoutSession={data?.checkoutSession as TCheckoutSessionExpanded}
|
|
83
104
|
paymentMethods={data?.paymentMethods as TPaymentMethodExpanded[]}
|
|
@@ -92,26 +113,30 @@ export default function CheckoutForm({
|
|
|
92
113
|
goBack={goBack}
|
|
93
114
|
mode={mode as string}
|
|
94
115
|
action={action}
|
|
116
|
+
{...restProps}
|
|
95
117
|
/>
|
|
96
118
|
</PaymentThemeProvider>
|
|
97
119
|
);
|
|
98
120
|
}
|
|
99
121
|
return (
|
|
100
|
-
<
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
122
|
+
<PaymentThemeProvider>
|
|
123
|
+
<Payment
|
|
124
|
+
checkoutSession={data?.checkoutSession as TCheckoutSessionExpanded}
|
|
125
|
+
paymentMethods={data?.paymentMethods as TPaymentMethodExpanded[]}
|
|
126
|
+
paymentIntent={data?.paymentIntent}
|
|
127
|
+
paymentLink={data?.paymentLink}
|
|
128
|
+
customer={data?.customer}
|
|
129
|
+
completed={state.completed}
|
|
130
|
+
error={apiError || state.appError}
|
|
131
|
+
onPaid={handlePaid}
|
|
132
|
+
onError={handleError}
|
|
133
|
+
onChange={onChange}
|
|
134
|
+
goBack={goBack}
|
|
135
|
+
mode={mode as string}
|
|
136
|
+
action={action}
|
|
137
|
+
{...restProps}
|
|
138
|
+
/>
|
|
139
|
+
</PaymentThemeProvider>
|
|
115
140
|
);
|
|
116
141
|
}
|
|
117
142
|
|
package/src/checkout/table.tsx
CHANGED
|
@@ -126,9 +126,16 @@ function CheckoutTableInner({ id, mode, onPaid, onError, onChange, extraParams,
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
export default function CheckoutTable(props: CheckoutProps) {
|
|
129
|
-
if (props.
|
|
129
|
+
if (props.theme === 'inherit') {
|
|
130
130
|
return <CheckoutTableInner {...props} />;
|
|
131
131
|
}
|
|
132
|
+
if (props.theme && typeof props.theme === 'object') {
|
|
133
|
+
return (
|
|
134
|
+
<PaymentThemeProvider theme={props.theme}>
|
|
135
|
+
<CheckoutTableInner {...props} />
|
|
136
|
+
</PaymentThemeProvider>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
132
139
|
return (
|
|
133
140
|
<PaymentThemeProvider>
|
|
134
141
|
<CheckoutTableInner {...props} />
|