@blocklet/payment-react 1.16.4 → 1.16.5

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.
@@ -40,7 +40,12 @@ function CheckoutTableInner({ id, mode, onPaid, onError, onChange, extraParams,
40
40
  return /* @__PURE__ */ jsx(Alert, { severity: "warning", children: t("payment.checkout.noPricing") });
41
41
  }
42
42
  const handleSelect = (priceId, currencyId) => {
43
- api.post(`/api/pricing-tables/${data.id}/checkout/${priceId}?${mergeExtraParams(extraParams)}`).then((res) => {
43
+ api.post(
44
+ `/api/pricing-tables/${data.id}/checkout/${priceId}?${mergeExtraParams({
45
+ ...extraParams,
46
+ currencyId
47
+ })}`
48
+ ).then((res) => {
44
49
  if (mode === "standalone") {
45
50
  let { url } = res.data;
46
51
  url = url.indexOf("?") > -1 ? `${url}&currencyId=${currencyId}` : `${url}?currencyId=${currencyId}`;
@@ -7,10 +7,5 @@ export type CountrySelectProps = {
7
7
  name: string;
8
8
  sx?: SxProps;
9
9
  };
10
- declare function CountrySelect({ value, onChange, name, sx }: CountrySelectProps): JSX.Element;
11
- declare namespace CountrySelect {
12
- var defaultProps: {
13
- sx: {};
14
- };
15
- }
10
+ declare const CountrySelect: import("react").ForwardRefExoticComponent<CountrySelectProps & import("react").RefAttributes<HTMLDivElement>>;
16
11
  export default CountrySelect;
@@ -1,12 +1,9 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useMemo } from "react";
2
+ import { useMemo, forwardRef } from "react";
3
3
  import { Box, MenuItem, Select, Typography } from "@mui/material";
4
4
  import { useFormContext } from "react-hook-form";
5
5
  import { FlagEmoji, defaultCountries, parseCountry } from "react-international-phone";
6
- CountrySelect.defaultProps = {
7
- sx: {}
8
- };
9
- export default function CountrySelect({ value, onChange, name, sx }) {
6
+ const CountrySelect = forwardRef(({ value, onChange, name, sx }, ref) => {
10
7
  const { setValue } = useFormContext();
11
8
  const countryDetail = useMemo(() => {
12
9
  const item = defaultCountries.find((v) => v[1] === value);
@@ -19,6 +16,7 @@ export default function CountrySelect({ value, onChange, name, sx }) {
19
16
  return /* @__PURE__ */ jsx(
20
17
  Select,
21
18
  {
19
+ ref,
22
20
  MenuProps: {
23
21
  style: {
24
22
  height: "300px",
@@ -35,7 +33,6 @@ export default function CountrySelect({ value, onChange, name, sx }) {
35
33
  },
36
34
  sx: {
37
35
  width: "100%",
38
- // Remove default outline (display only on focus)
39
36
  fieldset: {
40
37
  display: "none"
41
38
  },
@@ -44,7 +41,6 @@ export default function CountrySelect({ value, onChange, name, sx }) {
44
41
  display: "block"
45
42
  }
46
43
  },
47
- // Update default spacing
48
44
  ".MuiSelect-select": {
49
45
  padding: "8px",
50
46
  paddingRight: "24px !important"
@@ -54,7 +50,6 @@ export default function CountrySelect({ value, onChange, name, sx }) {
54
50
  },
55
51
  ".MuiMenuItem-root": {
56
52
  justifyContent: "flex-start"
57
- // 确保内容左对齐
58
53
  },
59
54
  ...sx
60
55
  },
@@ -79,4 +74,8 @@ export default function CountrySelect({ value, onChange, name, sx }) {
79
74
  })
80
75
  }
81
76
  );
82
- }
77
+ });
78
+ CountrySelect.defaultProps = {
79
+ sx: {}
80
+ };
81
+ export default CountrySelect;
@@ -9,9 +9,10 @@ import { Dialog } from "@arcblock/ux";
9
9
  import { usePaymentContext } from "../contexts/payment.js";
10
10
  import { formatAmount, formatError, getPrefix } from "../libs/util.js";
11
11
  import { useSubscription } from "../hooks/subscription.js";
12
+ import api from "../libs/api.js";
12
13
  const fetchOverdueInvoices = async (subscriptionId) => {
13
- const res = await fetch(`/api/subscriptions/${subscriptionId}/overdue/invoices`);
14
- return res.json();
14
+ const res = await api.get(`/api/subscriptions/${subscriptionId}/overdue/invoices`);
15
+ return res.data;
15
16
  };
16
17
  function OverdueInvoicePayment({
17
18
  subscriptionId,
@@ -167,13 +167,13 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
167
167
  // }
168
168
  }
169
169
  @media (min-width: ${({ theme }) => theme.breakpoints.values.md}px) {
170
- .price-table-wrap:has(> div:nth-child(1)) {
170
+ .price-table-wrap:has(> div:nth-of-type(1)) {
171
171
  max-width: 360px !important;
172
172
  }
173
- .price-table-wrap:has(> div:nth-child(2)) {
173
+ .price-table-wrap:has(> div:nth-of-type(2)) {
174
174
  max-width: 780px !important;
175
175
  }
176
- .price-table-wrap:has(> div:nth-child(3)) {
176
+ .price-table-wrap:has(> div:nth-of-type(3)) {
177
177
  max-width: 1200px !important;
178
178
  }
179
179
  }
@@ -482,8 +482,6 @@ function Subscribe({ x, action, onSelect, currencyId }) {
482
482
  loading: state.loading === x.price_id && !state.loaded,
483
483
  disabled: x.is_disabled,
484
484
  onClick: () => handleSelect(x.price_id),
485
- loadingPosition: "end",
486
- endIcon: null,
487
485
  children: action
488
486
  }
489
487
  );
@@ -100,6 +100,8 @@ const Wrapped = styled(Datatable)`
100
100
  border-bottom: none;
101
101
  padding-top: 12px;
102
102
  padding-bottom: 12px;
103
+ padding-left: 16px;
104
+ padding-right: 16px;
103
105
  &:first-of-type {
104
106
  padding-left: 20px;
105
107
  }
@@ -196,6 +196,7 @@ export default function PaymentSummary({
196
196
  {
197
197
  size: "small",
198
198
  loadingPosition: "end",
199
+ endIcon: null,
199
200
  color: "error",
200
201
  variant: "text",
201
202
  loading: state.loading,
@@ -225,6 +226,7 @@ export default function PaymentSummary({
225
226
  {
226
227
  size: "small",
227
228
  loadingPosition: "end",
229
+ endIcon: null,
228
230
  color: crossSellBehavior === "required" ? "info" : "info",
229
231
  variant: crossSellBehavior === "required" ? "text" : "text",
230
232
  loading: state.loading,
@@ -70,7 +70,10 @@ function CheckoutTableInner({
70
70
  });
71
71
  }
72
72
  const handleSelect = (priceId, currencyId) => {
73
- _api.default.post(`/api/pricing-tables/${data.id}/checkout/${priceId}?${(0, _util.mergeExtraParams)(extraParams)}`).then(res => {
73
+ _api.default.post(`/api/pricing-tables/${data.id}/checkout/${priceId}?${(0, _util.mergeExtraParams)({
74
+ ...extraParams,
75
+ currencyId
76
+ })}`).then(res => {
74
77
  if (mode === "standalone") {
75
78
  let {
76
79
  url
@@ -7,10 +7,5 @@ export type CountrySelectProps = {
7
7
  name: string;
8
8
  sx?: SxProps;
9
9
  };
10
- declare function CountrySelect({ value, onChange, name, sx }: CountrySelectProps): JSX.Element;
11
- declare namespace CountrySelect {
12
- var defaultProps: {
13
- sx: {};
14
- };
15
- }
10
+ declare const CountrySelect: import("react").ForwardRefExoticComponent<CountrySelectProps & import("react").RefAttributes<HTMLDivElement>>;
16
11
  export default CountrySelect;
@@ -3,21 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- module.exports = CountrySelect;
6
+
7
7
  var _jsxRuntime = require("react/jsx-runtime");
8
8
  var _react = require("react");
9
9
  var _material = require("@mui/material");
10
10
  var _reactHookForm = require("react-hook-form");
11
11
  var _reactInternationalPhone = require("react-international-phone");
12
- CountrySelect.defaultProps = {
13
- sx: {}
14
- };
15
- function CountrySelect({
12
+ const CountrySelect = (0, _react.forwardRef)(({
16
13
  value,
17
14
  onChange,
18
15
  name,
19
16
  sx
20
- }) {
17
+ }, ref) => {
21
18
  const {
22
19
  setValue
23
20
  } = (0, _reactHookForm.useFormContext)();
@@ -32,6 +29,7 @@ function CountrySelect({
32
29
  setValue(name, e.target.value);
33
30
  };
34
31
  return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Select, {
32
+ ref,
35
33
  MenuProps: {
36
34
  style: {
37
35
  height: "300px",
@@ -48,7 +46,6 @@ function CountrySelect({
48
46
  },
49
47
  sx: {
50
48
  width: "100%",
51
- // Remove default outline (display only on focus)
52
49
  fieldset: {
53
50
  display: "none"
54
51
  },
@@ -57,7 +54,6 @@ function CountrySelect({
57
54
  display: "block"
58
55
  }
59
56
  },
60
- // Update default spacing
61
57
  ".MuiSelect-select": {
62
58
  padding: "8px",
63
59
  paddingRight: "24px !important"
@@ -67,9 +63,7 @@ function CountrySelect({
67
63
  },
68
64
  ".MuiMenuItem-root": {
69
65
  justifyContent: "flex-start"
70
- // 确保内容左对齐
71
66
  },
72
-
73
67
  ...sx
74
68
  },
75
69
  value,
@@ -112,4 +106,8 @@ function CountrySelect({
112
106
  }, parsed.iso2);
113
107
  })
114
108
  });
115
- }
109
+ });
110
+ CountrySelect.defaultProps = {
111
+ sx: {}
112
+ };
113
+ module.exports = CountrySelect;
@@ -15,10 +15,11 @@ var _ux = require("@arcblock/ux");
15
15
  var _payment = require("../contexts/payment");
16
16
  var _util = require("../libs/util");
17
17
  var _subscription = require("../hooks/subscription");
18
+ var _api = _interopRequireDefault(require("../libs/api"));
18
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
20
  const fetchOverdueInvoices = async subscriptionId => {
20
- const res = await fetch(`/api/subscriptions/${subscriptionId}/overdue/invoices`);
21
- return res.json();
21
+ const res = await _api.default.get(`/api/subscriptions/${subscriptionId}/overdue/invoices`);
22
+ return res.data;
22
23
  };
23
24
  function OverdueInvoicePayment({
24
25
  subscriptionId,
@@ -184,13 +184,13 @@ function PricingTable({
184
184
  @media (min-width: ${({
185
185
  theme
186
186
  }) => theme.breakpoints.values.md}px) {
187
- .price-table-wrap:has(> div:nth-child(1)) {
187
+ .price-table-wrap:has(> div:nth-of-type(1)) {
188
188
  max-width: 360px !important;
189
189
  }
190
- .price-table-wrap:has(> div:nth-child(2)) {
190
+ .price-table-wrap:has(> div:nth-of-type(2)) {
191
191
  max-width: 780px !important;
192
192
  }
193
- .price-table-wrap:has(> div:nth-child(3)) {
193
+ .price-table-wrap:has(> div:nth-of-type(3)) {
194
194
  max-width: 1200px !important;
195
195
  }
196
196
  }
@@ -507,8 +507,6 @@ function Subscribe({
507
507
  loading: state.loading === x.price_id && !state.loaded,
508
508
  disabled: x.is_disabled,
509
509
  onClick: () => handleSelect(x.price_id),
510
- loadingPosition: "end",
511
- endIcon: null,
512
510
  children: action
513
511
  });
514
512
  }
@@ -120,6 +120,8 @@ const Wrapped = (0, _system.styled)(_Datatable.default)`
120
120
  border-bottom: none;
121
121
  padding-top: 12px;
122
122
  padding-bottom: 12px;
123
+ padding-left: 16px;
124
+ padding-right: 16px;
123
125
  &:first-of-type {
124
126
  padding-left: 20px;
125
127
  }
@@ -219,6 +219,7 @@ function PaymentSummary({
219
219
  children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_lab.LoadingButton, {
220
220
  size: "small",
221
221
  loadingPosition: "end",
222
+ endIcon: null,
222
223
  color: "error",
223
224
  variant: "text",
224
225
  loading: state.loading,
@@ -263,6 +264,7 @@ function PaymentSummary({
263
264
  }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_lab.LoadingButton, {
264
265
  size: "small",
265
266
  loadingPosition: "end",
267
+ endIcon: null,
266
268
  color: crossSellBehavior === "required" ? "info" : "info",
267
269
  variant: crossSellBehavior === "required" ? "text" : "text",
268
270
  loading: state.loading,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/payment-react",
3
- "version": "1.16.4",
3
+ "version": "1.16.5",
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.10.67",
57
- "@arcblock/ux": "^2.10.67",
58
- "@arcblock/ws": "^1.18.147",
59
- "@blocklet/ui-react": "^2.10.67",
56
+ "@arcblock/did-connect": "^2.10.74",
57
+ "@arcblock/ux": "^2.10.74",
58
+ "@arcblock/ws": "^1.18.150",
59
+ "@blocklet/ui-react": "^2.10.74",
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.18.147",
64
+ "@ocap/util": "^1.18.150",
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.16.4",
95
+ "@blocklet/payment-types": "1.16.5",
96
96
  "@storybook/addon-essentials": "^7.6.20",
97
97
  "@storybook/addon-interactions": "^7.6.20",
98
98
  "@storybook/addon-links": "^7.6.20",
@@ -122,5 +122,5 @@
122
122
  "vite-plugin-babel": "^1.2.0",
123
123
  "vite-plugin-node-polyfills": "^0.21.0"
124
124
  },
125
- "gitHead": "d2c53c8bec3a4a34d0ef3a011ec215b69bc9a5ab"
125
+ "gitHead": "74e38987168230f01af52d1aff14bfa6a18c0578"
126
126
  }
@@ -52,7 +52,12 @@ function CheckoutTableInner({ id, mode, onPaid, onError, onChange, extraParams,
52
52
 
53
53
  const handleSelect = (priceId: string, currencyId: string) => {
54
54
  api
55
- .post(`/api/pricing-tables/${data.id}/checkout/${priceId}?${mergeExtraParams(extraParams)}`)
55
+ .post(
56
+ `/api/pricing-tables/${data.id}/checkout/${priceId}?${mergeExtraParams({
57
+ ...extraParams,
58
+ currencyId,
59
+ })}`
60
+ )
56
61
  .then((res) => {
57
62
  if (mode === 'standalone') {
58
63
  let { url } = res.data;
@@ -1,6 +1,4 @@
1
- /* eslint-disable react/prop-types */
2
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3
- import React, { useMemo } from 'react';
1
+ import { useMemo, forwardRef } from 'react';
4
2
  import { Box, MenuItem, Select, SxProps, Typography } from '@mui/material';
5
3
  import { useFormContext } from 'react-hook-form';
6
4
  import { CountryIso2, FlagEmoji, defaultCountries, parseCountry } from 'react-international-phone';
@@ -12,11 +10,7 @@ export type CountrySelectProps = {
12
10
  sx?: SxProps;
13
11
  };
14
12
 
15
- CountrySelect.defaultProps = {
16
- sx: {},
17
- };
18
-
19
- export default function CountrySelect({ value, onChange, name, sx }: CountrySelectProps) {
13
+ const CountrySelect = forwardRef<HTMLDivElement, CountrySelectProps>(({ value, onChange, name, sx }, ref) => {
20
14
  const { setValue } = useFormContext();
21
15
  const countryDetail = useMemo(() => {
22
16
  const item = defaultCountries.find((v) => v[1] === value);
@@ -30,6 +24,7 @@ export default function CountrySelect({ value, onChange, name, sx }: CountrySele
30
24
 
31
25
  return (
32
26
  <Select
27
+ ref={ref}
33
28
  MenuProps={{
34
29
  style: {
35
30
  height: '300px',
@@ -46,7 +41,6 @@ export default function CountrySelect({ value, onChange, name, sx }: CountrySele
46
41
  }}
47
42
  sx={{
48
43
  width: '100%',
49
- // Remove default outline (display only on focus)
50
44
  fieldset: {
51
45
  display: 'none',
52
46
  },
@@ -55,7 +49,6 @@ export default function CountrySelect({ value, onChange, name, sx }: CountrySele
55
49
  display: 'block',
56
50
  },
57
51
  },
58
- // Update default spacing
59
52
  '.MuiSelect-select': {
60
53
  padding: '8px',
61
54
  paddingRight: '24px !important',
@@ -64,7 +57,7 @@ export default function CountrySelect({ value, onChange, name, sx }: CountrySele
64
57
  right: 0,
65
58
  },
66
59
  '.MuiMenuItem-root': {
67
- justifyContent: 'flex-start', // 确保内容左对齐
60
+ justifyContent: 'flex-start',
68
61
  },
69
62
  ...sx,
70
63
  }}
@@ -90,4 +83,9 @@ export default function CountrySelect({ value, onChange, name, sx }: CountrySele
90
83
  })}
91
84
  </Select>
92
85
  );
93
- }
86
+ });
87
+
88
+ CountrySelect.defaultProps = {
89
+ sx: {},
90
+ };
91
+ export default CountrySelect;
@@ -9,6 +9,7 @@ import { Dialog } from '@arcblock/ux';
9
9
  import { usePaymentContext } from '../contexts/payment';
10
10
  import { formatAmount, formatError, getPrefix } from '../libs/util';
11
11
  import { useSubscription } from '../hooks/subscription';
12
+ import api from '../libs/api';
12
13
 
13
14
  type DialogProps = {
14
15
  open?: boolean;
@@ -45,8 +46,8 @@ const fetchOverdueInvoices = async (
45
46
  summary: { [key: string]: SummaryItem };
46
47
  invoices: Invoice[];
47
48
  }> => {
48
- const res = await fetch(`/api/subscriptions/${subscriptionId}/overdue/invoices`);
49
- return res.json();
49
+ const res = await api.get(`/api/subscriptions/${subscriptionId}/overdue/invoices`);
50
+ return res.data;
50
51
  };
51
52
 
52
53
  function OverdueInvoicePayment({
@@ -198,13 +198,13 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
198
198
  // }
199
199
  }
200
200
  @media (min-width: ${({ theme }) => theme.breakpoints.values.md}px) {
201
- .price-table-wrap:has(> div:nth-child(1)) {
201
+ .price-table-wrap:has(> div:nth-of-type(1)) {
202
202
  max-width: 360px !important;
203
203
  }
204
- .price-table-wrap:has(> div:nth-child(2)) {
204
+ .price-table-wrap:has(> div:nth-of-type(2)) {
205
205
  max-width: 780px !important;
206
206
  }
207
- .price-table-wrap:has(> div:nth-child(3)) {
207
+ .price-table-wrap:has(> div:nth-of-type(3)) {
208
208
  max-width: 1200px !important;
209
209
  }
210
210
  }
@@ -500,9 +500,7 @@ function Subscribe({ x, action, onSelect, currencyId }: any) {
500
500
  }}
501
501
  loading={state.loading === x.price_id && !state.loaded}
502
502
  disabled={x.is_disabled}
503
- onClick={() => handleSelect(x.price_id)}
504
- loadingPosition="end"
505
- endIcon={null}>
503
+ onClick={() => handleSelect(x.price_id)}>
506
504
  {action}
507
505
  </LoadingButton>
508
506
  );
@@ -120,6 +120,8 @@ const Wrapped = styled(Datatable)`
120
120
  border-bottom: none;
121
121
  padding-top: 12px;
122
122
  padding-bottom: 12px;
123
+ padding-left: 16px;
124
+ padding-right: 16px;
123
125
  &:first-of-type {
124
126
  padding-left: 20px;
125
127
  }
@@ -252,6 +252,7 @@ export default function PaymentSummary({
252
252
  <LoadingButton
253
253
  size="small"
254
254
  loadingPosition="end"
255
+ endIcon={null}
255
256
  color="error"
256
257
  variant="text"
257
258
  loading={state.loading}
@@ -284,6 +285,7 @@ export default function PaymentSummary({
284
285
  <LoadingButton
285
286
  size="small"
286
287
  loadingPosition="end"
288
+ endIcon={null}
287
289
  color={crossSellBehavior === 'required' ? 'info' : 'info'}
288
290
  variant={crossSellBehavior === 'required' ? 'text' : 'text'}
289
291
  loading={state.loading}