@blocklet/payment-react 1.18.6 → 1.18.8

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 (70) hide show
  1. package/README.md +394 -341
  2. package/es/checkout/donate.d.ts +29 -4
  3. package/es/checkout/donate.js +193 -95
  4. package/es/components/livemode.js +1 -1
  5. package/es/components/loading-button.d.ts +10 -0
  6. package/es/components/loading-button.js +75 -0
  7. package/es/components/pricing-table.js +2 -3
  8. package/es/components/table.js +1 -1
  9. package/es/index.d.ts +2 -1
  10. package/es/index.js +3 -1
  11. package/es/libs/util.d.ts +1 -0
  12. package/es/libs/util.js +10 -1
  13. package/es/payment/amount.js +1 -1
  14. package/es/payment/form/index.js +14 -12
  15. package/es/payment/form/stripe/form.js +20 -5
  16. package/es/payment/index.js +0 -1
  17. package/es/payment/product-card.js +2 -2
  18. package/es/payment/product-item.js +1 -1
  19. package/es/payment/product-skeleton.js +2 -2
  20. package/es/payment/skeleton/donation.js +1 -1
  21. package/es/payment/skeleton/overview.js +1 -1
  22. package/es/payment/skeleton/payment.js +1 -1
  23. package/es/payment/summary.js +2 -2
  24. package/es/theme/index.js +5 -3
  25. package/es/theme/typography.js +8 -8
  26. package/lib/checkout/donate.d.ts +29 -4
  27. package/lib/checkout/donate.js +197 -136
  28. package/lib/components/livemode.js +1 -1
  29. package/lib/components/loading-button.d.ts +10 -0
  30. package/lib/components/loading-button.js +86 -0
  31. package/lib/components/pricing-table.js +3 -4
  32. package/lib/components/table.js +1 -1
  33. package/lib/index.d.ts +2 -1
  34. package/lib/index.js +8 -0
  35. package/lib/libs/util.d.ts +1 -0
  36. package/lib/libs/util.js +7 -0
  37. package/lib/payment/amount.js +1 -1
  38. package/lib/payment/form/index.js +14 -15
  39. package/lib/payment/form/stripe/form.js +25 -6
  40. package/lib/payment/index.js +0 -1
  41. package/lib/payment/product-card.js +2 -2
  42. package/lib/payment/product-item.js +1 -1
  43. package/lib/payment/product-skeleton.js +2 -2
  44. package/lib/payment/skeleton/donation.js +1 -1
  45. package/lib/payment/skeleton/overview.js +1 -1
  46. package/lib/payment/skeleton/payment.js +1 -1
  47. package/lib/payment/summary.js +4 -4
  48. package/lib/theme/index.js +5 -3
  49. package/lib/theme/typography.js +8 -8
  50. package/package.json +8 -8
  51. package/src/checkout/donate.tsx +209 -128
  52. package/src/components/livemode.tsx +1 -1
  53. package/src/components/loading-button.tsx +100 -0
  54. package/src/components/pricing-table.tsx +3 -3
  55. package/src/components/table.tsx +1 -1
  56. package/src/index.ts +2 -0
  57. package/src/libs/util.ts +11 -1
  58. package/src/payment/amount.tsx +1 -1
  59. package/src/payment/form/index.tsx +65 -60
  60. package/src/payment/form/stripe/form.tsx +21 -6
  61. package/src/payment/index.tsx +0 -1
  62. package/src/payment/product-card.tsx +2 -2
  63. package/src/payment/product-item.tsx +1 -1
  64. package/src/payment/product-skeleton.tsx +2 -2
  65. package/src/payment/skeleton/donation.tsx +1 -1
  66. package/src/payment/skeleton/overview.tsx +1 -1
  67. package/src/payment/skeleton/payment.tsx +1 -1
  68. package/src/payment/summary.tsx +2 -2
  69. package/src/theme/index.tsx +3 -1
  70. package/src/theme/typography.ts +8 -8
@@ -30,6 +30,7 @@ var _phone = _interopRequireDefault(require("./phone"));
30
30
  var _stripe = _interopRequireDefault(require("./stripe"));
31
31
  var _mobile = require("../../hooks/mobile");
32
32
  var _phoneValidator = require("../../libs/phone-validator");
33
+ var _loadingButton = _interopRequireDefault(require("../../components/loading-button"));
33
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
34
35
  const waitForCheckoutComplete = async sessionId => {
35
36
  let result;
@@ -165,7 +166,7 @@ function PaymentForm({
165
166
  name: "payment_method"
166
167
  });
167
168
  const afterUserLoggedIn = (0, _ahooks.useMemoizedFn)(() => {
168
- if (hasDidWallet(session.user)) {
169
+ if (hasDidWallet(session.user) || skipBindWallet) {
169
170
  handleSubmit(onFormSubmit, onFormError)();
170
171
  } else {
171
172
  session.bindWallet(() => {
@@ -190,6 +191,8 @@ function PaymentForm({
190
191
  action: buttonText
191
192
  });
192
193
  const method = paymentMethods.find(x => x.id === paymentMethod);
194
+ const showForm = session?.user;
195
+ const skipBindWallet = method.type === "stripe";
193
196
  const handleConnected = async () => {
194
197
  try {
195
198
  const result = await waitForCheckoutComplete(checkoutSession.id);
@@ -350,6 +353,10 @@ function PaymentForm({
350
353
  });
351
354
  }
352
355
  if (session?.user) {
356
+ if (skipBindWallet) {
357
+ handleSubmit(onFormSubmit, onFormError)();
358
+ return;
359
+ }
353
360
  if (hasDidWallet(session.user)) {
354
361
  handleSubmit(onFormSubmit, onFormError)();
355
362
  } else {
@@ -471,7 +478,7 @@ function PaymentForm({
471
478
  returnUrl: checkoutSession?.success_url
472
479
  })]
473
480
  })
474
- }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
481
+ }), showForm && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
475
482
  direction: "column",
476
483
  className: "cko-payment-form",
477
484
  id: "cko-payment-form",
@@ -540,33 +547,25 @@ function PaymentForm({
540
547
  className: "cko-payment-submit",
541
548
  children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
542
549
  className: "cko-payment-submit-btn",
543
- children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Button, {
550
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_loadingButton.default, {
544
551
  variant: "contained",
545
552
  color: "primary",
546
553
  size: "large",
547
554
  className: "cko-submit-button",
548
555
  onClick: () => {
549
- if (state.submitting || state.paying) {
550
- return;
551
- }
552
556
  onAction();
553
557
  },
554
558
  fullWidth: true,
559
+ loading: state.submitting || state.paying,
555
560
  disabled: state.stripePaying || !quantityInventoryStatus || !payable,
556
- children: [(state.submitting || state.paying) && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.CircularProgress, {
557
- size: 16,
558
- sx: {
559
- mr: 0.5,
560
- color: "var(--foregrounds-fg-on-color, #fff)"
561
- }
562
- }), state.submitting || state.paying ? t("payment.checkout.processing") : buttonText]
561
+ children: state.submitting || state.paying ? t("payment.checkout.processing") : buttonText
563
562
  })
564
563
  }), ["subscription", "setup"].includes(checkoutSession.mode) && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
565
564
  sx: {
566
565
  mt: 2.5,
567
566
  color: "text.lighter",
568
- fontSize: "0.9rem",
569
- lineHeight: "1.1rem"
567
+ fontSize: "0.7875rem",
568
+ lineHeight: "0.9625rem"
570
569
  },
571
570
  children: t("payment.checkout.confirm", {
572
571
  payee
@@ -8,11 +8,12 @@ var _jsxRuntime = require("react/jsx-runtime");
8
8
  var _Center = _interopRequireDefault(require("@arcblock/ux/lib/Center"));
9
9
  var _Dialog = _interopRequireDefault(require("@arcblock/ux/lib/Dialog"));
10
10
  var _context = require("@arcblock/ux/lib/Locale/context");
11
- var _lab = require("@mui/lab");
12
11
  var _material = require("@mui/material");
13
12
  var _system = require("@mui/system");
14
13
  var _ahooks = require("ahooks");
15
14
  var _react = require("react");
15
+ var _mobile = require("../../../hooks/mobile");
16
+ var _loadingButton = _interopRequireDefault(require("../../../components/loading-button"));
16
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
18
  const {
18
19
  Elements,
@@ -136,18 +137,17 @@ function StripeCheckoutForm({
136
137
  }), (!stripe || !elements || !state.loaded) && /* @__PURE__ */(0, _jsxRuntime.jsx)(_Center.default, {
137
138
  relative: "parent",
138
139
  children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.CircularProgress, {})
139
- }), stripe && elements && state.loaded && /* @__PURE__ */(0, _jsxRuntime.jsx)(_lab.LoadingButton, {
140
+ }), stripe && elements && state.loaded && /* @__PURE__ */(0, _jsxRuntime.jsx)(_loadingButton.default, {
140
141
  fullWidth: true,
141
142
  sx: {
142
143
  mt: 2,
143
144
  mb: 1,
144
145
  borderRadius: 0,
145
- fontSize: "1.1rem"
146
+ fontSize: "0.875rem"
146
147
  },
147
148
  type: "submit",
148
149
  disabled: state.confirming || !state.loaded,
149
150
  loading: state.confirming,
150
- loadingPosition: "end",
151
151
  variant: "contained",
152
152
  color: "primary",
153
153
  size: "large",
@@ -184,7 +184,11 @@ function StripeCheckout({
184
184
  }) {
185
185
  const stripePromise = loadStripe(publicKey);
186
186
  const {
187
- t
187
+ isMobile
188
+ } = (0, _mobile.useMobile)();
189
+ const {
190
+ t,
191
+ locale
188
192
  } = (0, _context.useLocaleContext)();
189
193
  const [state, setState] = (0, _ahooks.useSetState)({
190
194
  open: true,
@@ -207,9 +211,24 @@ function StripeCheckout({
207
211
  open: state.open,
208
212
  onClose: handleClose,
209
213
  disableEscapeKeyDown: true,
214
+ sx: {
215
+ ".StripeElement": {
216
+ minWidth: isMobile ? "100%" : "500px",
217
+ py: 1
218
+ },
219
+ form: {
220
+ justifyContent: "flex-start"
221
+ }
222
+ },
223
+ PaperProps: {
224
+ style: {
225
+ minWidth: isMobile ? "100%" : "500px"
226
+ }
227
+ },
210
228
  children: /* @__PURE__ */(0, _jsxRuntime.jsx)(Elements, {
211
229
  options: {
212
- clientSecret
230
+ clientSecret,
231
+ locale: locale === "zh" ? "zh-CN" : "en"
213
232
  },
214
233
  stripe: stripePromise,
215
234
  children: /* @__PURE__ */(0, _jsxRuntime.jsx)(StripeCheckoutForm, {
@@ -574,7 +574,6 @@ const Root = exports.Root = (0, _system.styled)(_material.Box)`
574
574
  .MuiButtonBase-root {
575
575
  font-size: 1.3rem;
576
576
  position: relative;
577
- padding: 4px 22px;
578
577
  }
579
578
 
580
579
  .cko-submit-progress {
@@ -65,7 +65,7 @@ function ProductCard({
65
65
  variant: "body1",
66
66
  title: description,
67
67
  sx: {
68
- fontSize: "0.85rem",
68
+ fontSize: "0.74375rem",
69
69
  mb: 0.5,
70
70
  lineHeight: 1.2,
71
71
  textAlign: "left"
@@ -74,7 +74,7 @@ function ProductCard({
74
74
  children: description
75
75
  }), extra && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
76
76
  sx: {
77
- fontSize: "0.85rem"
77
+ fontSize: "0.74375rem"
78
78
  },
79
79
  color: "text.lighter",
80
80
  children: extra
@@ -98,7 +98,7 @@ function ProductItem({
98
98
  children: primaryText
99
99
  }), pricing.secondary && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
100
100
  sx: {
101
- fontSize: "0.85rem",
101
+ fontSize: "0.74375rem",
102
102
  color: "text.lighter"
103
103
  },
104
104
  children: pricing.secondary
@@ -37,7 +37,7 @@ function ProductSkeleton({
37
37
  }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {
38
38
  variant: "text",
39
39
  sx: {
40
- fontSize: "1rem",
40
+ fontSize: "0.875rem",
41
41
  width: "60%"
42
42
  }
43
43
  }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
@@ -62,7 +62,7 @@ function ProductSkeleton({
62
62
  (0, _jsxRuntime.jsx)(_material.Skeleton, {
63
63
  variant: "text",
64
64
  sx: {
65
- fontSize: "1rem",
65
+ fontSize: "0.875rem",
66
66
  width: "60%"
67
67
  }
68
68
  }, i))]
@@ -14,7 +14,7 @@ function DonationSkeleton() {
14
14
  children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {
15
15
  variant: "text",
16
16
  sx: {
17
- fontSize: "2rem",
17
+ fontSize: "1.75rem",
18
18
  width: "40%"
19
19
  }
20
20
  }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {
@@ -18,7 +18,7 @@ function OverviewSkeleton() {
18
18
  children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {
19
19
  variant: "text",
20
20
  sx: {
21
- fontSize: "2rem",
21
+ fontSize: "1.75rem",
22
22
  width: "40%"
23
23
  }
24
24
  })
@@ -14,7 +14,7 @@ function PaymentSkeleton() {
14
14
  children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {
15
15
  variant: "text",
16
16
  sx: {
17
- fontSize: "2rem",
17
+ fontSize: "1.75rem",
18
18
  width: "40%"
19
19
  }
20
20
  }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Skeleton, {
@@ -7,7 +7,6 @@ module.exports = PaymentSummary;
7
7
  var _jsxRuntime = require("react/jsx-runtime");
8
8
  var _context = require("@arcblock/ux/lib/Locale/context");
9
9
  var _iconsMaterial = require("@mui/icons-material");
10
- var _lab = require("@mui/lab");
11
10
  var _material = require("@mui/material");
12
11
  var _util = require("@ocap/util");
13
12
  var _ahooks = require("ahooks");
@@ -24,6 +23,7 @@ var _productItem = _interopRequireDefault(require("./product-item"));
24
23
  var _livemode = _interopRequireDefault(require("../components/livemode"));
25
24
  var _payment = require("../contexts/payment");
26
25
  var _mobile = require("../hooks/mobile");
26
+ var _loadingButton = _interopRequireDefault(require("../components/loading-button"));
27
27
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
28
  const ExpandMore = (0, _styles.styled)(props => {
29
29
  const {
@@ -216,7 +216,7 @@ function PaymentSummary({
216
216
  sx: {
217
217
  width: 1
218
218
  },
219
- children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_lab.LoadingButton, {
219
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_loadingButton.default, {
220
220
  size: "small",
221
221
  loadingPosition: "end",
222
222
  endIcon: null,
@@ -261,7 +261,7 @@ function PaymentSummary({
261
261
  mr: 1
262
262
  }
263
263
  })
264
- }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_lab.LoadingButton, {
264
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_loadingButton.default, {
265
265
  size: "small",
266
266
  loadingPosition: "end",
267
267
  endIcon: null,
@@ -413,7 +413,7 @@ function PaymentSummary({
413
413
  }), headlines.then && headlines.showThen && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
414
414
  component: "div",
415
415
  sx: {
416
- fontSize: "0.9rem",
416
+ fontSize: "0.7875rem",
417
417
  color: "text.lighter",
418
418
  textAlign: "right",
419
419
  margin: "-2px 0 8px"
@@ -65,9 +65,10 @@ function PaymentThemeProvider({
65
65
  },
66
66
  styleOverrides: {
67
67
  root: {
68
- fontSize: "1rem",
68
+ fontSize: "0.875rem",
69
69
  fontWeight: 500,
70
- textTransform: "none"
70
+ textTransform: "none",
71
+ boxShadow: "none"
71
72
  },
72
73
  containedPrimary: {
73
74
  backgroundColor: "var(--buttons-button-inverted, #010714)",
@@ -112,7 +113,8 @@ function PaymentThemeProvider({
112
113
  MuiTab: {
113
114
  styleOverrides: {
114
115
  root: {
115
- textTransform: "none"
116
+ textTransform: "none",
117
+ fontSize: "0.875rem"
116
118
  }
117
119
  }
118
120
  },
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.typography = void 0;
7
7
  const typography = exports.typography = {
8
8
  h1: {
9
- fontSize: "1.875rem",
9
+ fontSize: "1.5rem",
10
10
  lineHeight: 1.2,
11
11
  fontWeight: 800,
12
12
  letterSpacing: "-.025em"
@@ -18,38 +18,38 @@ const typography = exports.typography = {
18
18
  letterSpacing: "-.025em"
19
19
  },
20
20
  h3: {
21
- fontSize: "1.25rem",
21
+ fontSize: "1.09375rem",
22
22
  lineHeight: 1.4,
23
23
  fontWeight: 600,
24
24
  letterSpacing: "-.025em"
25
25
  },
26
26
  h4: {
27
- fontSize: "1.125rem",
27
+ fontSize: "1.09375rem",
28
28
  lineHeight: 1.5,
29
29
  fontWeight: 600
30
30
  },
31
31
  h5: {
32
- fontSize: "1rem",
32
+ fontSize: "0.875rem",
33
33
  lineHeight: 1.75,
34
34
  fontWeight: 400
35
35
  },
36
36
  h6: {
37
- fontSize: "1rem",
37
+ fontSize: "0.875rem",
38
38
  lineHeight: 1.75,
39
39
  fontWeight: 400
40
40
  },
41
41
  subtitle1: {
42
- fontSize: "1rem",
42
+ fontSize: "0.875rem",
43
43
  lineHeight: 1.75,
44
44
  fontWeight: 400
45
45
  },
46
46
  subtitle2: {
47
- fontSize: "1rem",
47
+ fontSize: "0.875rem",
48
48
  lineHeight: 1.75,
49
49
  fontWeight: 400
50
50
  },
51
51
  body1: {
52
- fontSize: "1rem",
52
+ fontSize: "0.875rem",
53
53
  lineHeight: 1.75
54
54
  },
55
55
  fontWeightLight: 300,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/payment-react",
3
- "version": "1.18.6",
3
+ "version": "1.18.8",
4
4
  "description": "Reusable react components for payment kit v2",
5
5
  "keywords": [
6
6
  "react",
@@ -53,15 +53,15 @@
53
53
  }
54
54
  },
55
55
  "dependencies": {
56
- "@arcblock/did-connect": "^2.11.34",
57
- "@arcblock/ux": "^2.11.34",
58
- "@arcblock/ws": "^1.19.9",
59
- "@blocklet/ui-react": "^2.11.34",
56
+ "@arcblock/did-connect": "^2.11.44",
57
+ "@arcblock/ux": "^2.11.44",
58
+ "@arcblock/ws": "^1.19.10",
59
+ "@blocklet/ui-react": "^2.11.44",
60
60
  "@mui/icons-material": "^5.16.6",
61
61
  "@mui/lab": "^5.0.0-alpha.173",
62
62
  "@mui/material": "^5.16.6",
63
63
  "@mui/system": "^5.16.6",
64
- "@ocap/util": "^1.19.9",
64
+ "@ocap/util": "^1.19.10",
65
65
  "@stripe/react-stripe-js": "^2.7.3",
66
66
  "@stripe/stripe-js": "^2.4.0",
67
67
  "@vitejs/plugin-legacy": "^5.4.1",
@@ -92,7 +92,7 @@
92
92
  "@babel/core": "^7.25.2",
93
93
  "@babel/preset-env": "^7.25.2",
94
94
  "@babel/preset-react": "^7.24.7",
95
- "@blocklet/payment-types": "1.18.6",
95
+ "@blocklet/payment-types": "1.18.8",
96
96
  "@storybook/addon-essentials": "^7.6.20",
97
97
  "@storybook/addon-interactions": "^7.6.20",
98
98
  "@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": "784ba57910d780a44d0792ef503b666ee8f8d9c3"
126
+ "gitHead": "0815493ffd53c977d2d14779703d85f2e0e34299"
127
127
  }