@blocklet/payment-react 1.15.3 → 1.15.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.
@@ -26,7 +26,7 @@ declare function CheckoutDonate(props: DonateProps): import("react").JSX.Element
26
26
  declare namespace CheckoutDonate {
27
27
  var defaultProps: {
28
28
  theme: string;
29
- livemode: boolean;
29
+ livemode: undefined;
30
30
  timeout: number;
31
31
  mode: string;
32
32
  inlineOptions: {
@@ -26,6 +26,7 @@ import api from "../libs/api.js";
26
26
  import { formatAmount, formatBNStr, formatDateTime, formatError, getCustomerAvatar, lazyLoad } from "../libs/util.js";
27
27
  import CheckoutForm from "./form.js";
28
28
  import { PaymentThemeProvider } from "../theme/index.js";
29
+ import { usePaymentContext } from "../contexts/payment.js";
29
30
  const donationCache = {};
30
31
  const createOrUpdateDonation = (settings, livemode = true) => {
31
32
  if (!donationCache[settings.target]) {
@@ -177,7 +178,7 @@ function SupporterSimple({ supporters = [], totalAmount = "0", currency, method
177
178
  }
178
179
  );
179
180
  }
180
- function useDonation(settings, livemode = true, mode = "default") {
181
+ function useDonation(settings, livemode, mode = "default") {
181
182
  const [state, setState] = useSetState({
182
183
  open: false,
183
184
  supporterLoaded: false,
@@ -217,7 +218,7 @@ function useDonation(settings, livemode = true, mode = "default") {
217
218
  }
218
219
  function CheckoutDonateInner({
219
220
  settings,
220
- livemode,
221
+ livemode = true,
221
222
  timeout,
222
223
  onPaid,
223
224
  onError,
@@ -375,7 +376,10 @@ function CheckoutDonateInner({
375
376
  onError,
376
377
  action: settings.appearance?.button?.text,
377
378
  mode: "inline",
378
- theme
379
+ theme,
380
+ extraParams: {
381
+ livemode
382
+ }
379
383
  }
380
384
  ) })
381
385
  }
@@ -383,17 +387,19 @@ function CheckoutDonateInner({
383
387
  ] });
384
388
  }
385
389
  export default function CheckoutDonate(props) {
390
+ const { livemode } = usePaymentContext();
391
+ const content = /* @__PURE__ */ jsx(CheckoutDonateInner, { ...props, livemode: props.livemode === void 0 ? livemode : props.livemode });
386
392
  if (props.theme === "inherit") {
387
- return /* @__PURE__ */ jsx(CheckoutDonateInner, { ...props });
393
+ return content;
388
394
  }
389
395
  if (props.theme && typeof props.theme === "object") {
390
- return /* @__PURE__ */ jsx(PaymentThemeProvider, { theme: props.theme, children: /* @__PURE__ */ jsx(CheckoutDonateInner, { ...props }) });
396
+ return /* @__PURE__ */ jsx(PaymentThemeProvider, { theme: props.theme, children: content });
391
397
  }
392
- return /* @__PURE__ */ jsx(PaymentThemeProvider, { children: /* @__PURE__ */ jsx(CheckoutDonateInner, { ...props }) });
398
+ return /* @__PURE__ */ jsx(PaymentThemeProvider, { children: content });
393
399
  }
394
400
  CheckoutDonate.defaultProps = {
395
401
  theme: "default",
396
- livemode: true,
402
+ livemode: void 0,
397
403
  timeout: 5e3,
398
404
  mode: "default",
399
405
  inlineOptions: {
@@ -66,44 +66,63 @@ function CheckoutTableInner({ id, mode, onPaid, onError, onChange, extraParams,
66
66
  }
67
67
  if (!sessionId && !hashSessionId) {
68
68
  if (mode === "standalone") {
69
- return /* @__PURE__ */ jsxs(Stack, { direction: "column", alignItems: "center", p: 2.5, children: [
70
- /* @__PURE__ */ jsxs(
71
- Box,
72
- {
73
- sx: {
74
- display: "flex",
75
- flexDirection: "column",
76
- fontSize: "24px",
77
- alignItems: "center",
78
- margin: {
79
- xs: "20px 0",
80
- md: "20px 20px"
81
- },
82
- maxWidth: {
83
- xs: "100%",
84
- md: 400
85
- },
86
- textAlign: "center"
69
+ return /* @__PURE__ */ jsxs(
70
+ Stack,
71
+ {
72
+ direction: "column",
73
+ alignItems: "center",
74
+ sx: {
75
+ overflow: {
76
+ xs: "auto",
77
+ md: "hidden"
87
78
  },
88
- children: [
89
- !data.livemode && /* @__PURE__ */ jsx(Livemode, { sx: { display: "flex", marginBottom: "8px", width: "fit-content", ml: 0 } }),
90
- /* @__PURE__ */ jsx(
91
- Typography,
92
- {
93
- color: "text.primary",
94
- fontWeight: 600,
95
- sx: {
96
- lineHeight: "32px",
97
- fontSize: "24px"
79
+ height: "100%",
80
+ pt: {
81
+ xs: 2.5,
82
+ md: 7.5
83
+ },
84
+ px: 2.5
85
+ },
86
+ children: [
87
+ /* @__PURE__ */ jsxs(
88
+ Box,
89
+ {
90
+ sx: {
91
+ display: "flex",
92
+ flexDirection: "column",
93
+ fontSize: "24px",
94
+ alignItems: "center",
95
+ margin: {
96
+ xs: "20px 0",
97
+ md: "20px 20px"
98
+ },
99
+ maxWidth: {
100
+ xs: "100%",
101
+ md: 400
98
102
  },
99
- children: /* @__PURE__ */ jsx(TruncatedText, { text: data.name, maxLength: 60, useWidth: true })
100
- }
101
- )
102
- ]
103
- }
104
- ),
105
- /* @__PURE__ */ jsx(PricingTable, { table: data, onSelect: handleSelect })
106
- ] });
103
+ textAlign: "center"
104
+ },
105
+ children: [
106
+ !data.livemode && /* @__PURE__ */ jsx(Livemode, { sx: { display: "flex", marginBottom: "8px", width: "fit-content", ml: 0 } }),
107
+ /* @__PURE__ */ jsx(
108
+ Typography,
109
+ {
110
+ color: "text.primary",
111
+ fontWeight: 600,
112
+ sx: {
113
+ lineHeight: "32px",
114
+ fontSize: "24px"
115
+ },
116
+ children: /* @__PURE__ */ jsx(TruncatedText, { text: data.name, maxLength: 60, useWidth: true })
117
+ }
118
+ )
119
+ ]
120
+ }
121
+ ),
122
+ /* @__PURE__ */ jsx(PricingTable, { table: data, onSelect: handleSelect })
123
+ ]
124
+ }
125
+ );
107
126
  }
108
127
  return /* @__PURE__ */ jsx(PricingTable, { mode: "select", table: data, onSelect: handleSelect });
109
128
  }