@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.
@@ -40,7 +40,8 @@ function CheckoutForm({
40
40
  goBack,
41
41
  extraParams,
42
42
  action,
43
- customTheme = false
43
+ theme = "default",
44
+ ...restProps
44
45
  }) {
45
46
  if (!id.startsWith("plink_") && !id.startsWith("cs_")) {
46
47
  throw new Error("Either a checkoutSession or a paymentLink id is required.");
@@ -72,8 +73,27 @@ function CheckoutForm({
72
73
  });
73
74
  onError?.(err);
74
75
  };
75
- if (!customTheme) {
76
+ if (theme === "inherit") {
77
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_payment.default, {
78
+ checkoutSession: data?.checkoutSession,
79
+ paymentMethods: data?.paymentMethods,
80
+ paymentIntent: data?.paymentIntent,
81
+ paymentLink: data?.paymentLink,
82
+ customer: data?.customer,
83
+ completed: state.completed,
84
+ error: apiError || state.appError,
85
+ onPaid: handlePaid,
86
+ onError: handleError,
87
+ onChange,
88
+ goBack,
89
+ mode,
90
+ action,
91
+ ...restProps
92
+ });
93
+ }
94
+ if (theme && typeof theme === "object") {
76
95
  return /* @__PURE__ */(0, _jsxRuntime.jsx)(_theme.PaymentThemeProvider, {
96
+ theme,
77
97
  children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_payment.default, {
78
98
  checkoutSession: data?.checkoutSession,
79
99
  paymentMethods: data?.paymentMethods,
@@ -87,24 +107,28 @@ function CheckoutForm({
87
107
  onChange,
88
108
  goBack,
89
109
  mode,
90
- action
110
+ action,
111
+ ...restProps
91
112
  })
92
113
  });
93
114
  }
94
- return /* @__PURE__ */(0, _jsxRuntime.jsx)(_payment.default, {
95
- checkoutSession: data?.checkoutSession,
96
- paymentMethods: data?.paymentMethods,
97
- paymentIntent: data?.paymentIntent,
98
- paymentLink: data?.paymentLink,
99
- customer: data?.customer,
100
- completed: state.completed,
101
- error: apiError || state.appError,
102
- onPaid: handlePaid,
103
- onError: handleError,
104
- onChange,
105
- goBack,
106
- mode,
107
- action
115
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_theme.PaymentThemeProvider, {
116
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_payment.default, {
117
+ checkoutSession: data?.checkoutSession,
118
+ paymentMethods: data?.paymentMethods,
119
+ paymentIntent: data?.paymentIntent,
120
+ paymentLink: data?.paymentLink,
121
+ customer: data?.customer,
122
+ completed: state.completed,
123
+ error: apiError || state.appError,
124
+ onPaid: handlePaid,
125
+ onError: handleError,
126
+ onChange,
127
+ goBack,
128
+ mode,
129
+ action,
130
+ ...restProps
131
+ })
108
132
  });
109
133
  }
110
134
  CheckoutForm.defaultProps = {
@@ -148,11 +148,19 @@ function CheckoutTableInner({
148
148
  });
149
149
  }
150
150
  function CheckoutTable(props) {
151
- if (props.customTheme) {
151
+ if (props.theme === "inherit") {
152
152
  return /* @__PURE__ */(0, _jsxRuntime.jsx)(CheckoutTableInner, {
153
153
  ...props
154
154
  });
155
155
  }
156
+ if (props.theme && typeof props.theme === "object") {
157
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_theme.PaymentThemeProvider, {
158
+ theme: props.theme,
159
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(CheckoutTableInner, {
160
+ ...props
161
+ })
162
+ });
163
+ }
156
164
  return /* @__PURE__ */(0, _jsxRuntime.jsx)(_theme.PaymentThemeProvider, {
157
165
  children: /* @__PURE__ */(0, _jsxRuntime.jsx)(CheckoutTableInner, {
158
166
  ...props
@@ -4,21 +4,21 @@ declare const FormInput: import("react").ForwardRefExoticComponent<(Omit<import(
4
4
  name: string;
5
5
  label?: string | undefined;
6
6
  placeholder?: string | undefined;
7
- errorPosition?: "right" | "bottom" | undefined;
7
+ errorPosition?: "bottom" | "right" | undefined;
8
8
  rules?: RegisterOptions<import("react-hook-form").FieldValues, string> | undefined;
9
9
  wrapperStyle?: any;
10
10
  }, "ref"> | Omit<import("@mui/material").FilledTextFieldProps & {
11
11
  name: string;
12
12
  label?: string | undefined;
13
13
  placeholder?: string | undefined;
14
- errorPosition?: "right" | "bottom" | undefined;
14
+ errorPosition?: "bottom" | "right" | undefined;
15
15
  rules?: RegisterOptions<import("react-hook-form").FieldValues, string> | undefined;
16
16
  wrapperStyle?: any;
17
17
  }, "ref"> | Omit<import("@mui/material").StandardTextFieldProps & {
18
18
  name: string;
19
19
  label?: string | undefined;
20
20
  placeholder?: string | undefined;
21
- errorPosition?: "right" | "bottom" | undefined;
21
+ errorPosition?: "bottom" | "right" | undefined;
22
22
  rules?: RegisterOptions<import("react-hook-form").FieldValues, string> | undefined;
23
23
  wrapperStyle?: any;
24
24
  }, "ref">) & import("react").RefAttributes<HTMLInputElement>>;
@@ -24,12 +24,12 @@ export declare function formatLineItemPricing(item: TLineItemExpanded, currency:
24
24
  secondary?: string;
25
25
  quantity: string;
26
26
  };
27
- export declare function getSubscriptionStatusColor(status: string): "success" | "primary" | "warning" | "error" | "default";
28
- export declare function getPaymentIntentStatusColor(status: string): "success" | "warning" | "default";
29
- export declare function getRefundStatusColor(status: string): "success" | "warning" | "default";
30
- export declare function getPayoutStatusColor(status: string): "success" | "warning" | "default";
31
- export declare function getInvoiceStatusColor(status: string): "success" | "warning" | "default" | "secondary";
32
- export declare function getWebhookStatusColor(status: string): "success" | "default";
27
+ export declare function getSubscriptionStatusColor(status: string): "default" | "success" | "primary" | "warning" | "error";
28
+ export declare function getPaymentIntentStatusColor(status: string): "default" | "success" | "warning";
29
+ export declare function getRefundStatusColor(status: string): "default" | "success" | "warning";
30
+ export declare function getPayoutStatusColor(status: string): "default" | "success" | "warning";
31
+ export declare function getInvoiceStatusColor(status: string): "default" | "success" | "warning" | "secondary";
32
+ export declare function getWebhookStatusColor(status: string): "default" | "success";
33
33
  export declare function getCheckoutAmount(items: TLineItemExpanded[], currency: TPaymentCurrency, trialing?: boolean, upsell?: boolean): {
34
34
  subtotal: any;
35
35
  total: any;
@@ -4,12 +4,14 @@ import { CheckoutCallbacks, CheckoutContext } from '../types';
4
4
  type Props = CheckoutContext & CheckoutCallbacks & {
5
5
  completed?: boolean;
6
6
  error?: any;
7
+ showCheckoutSummary?: boolean;
7
8
  };
8
- declare function Payment({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, completed, mode, onPaid, onError, onChange, goBack, action, }: Props): import("react").JSX.Element;
9
+ declare function Payment({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, completed, mode, onPaid, onError, onChange, goBack, action, showCheckoutSummary, }: Props): import("react").JSX.Element;
9
10
  declare namespace Payment {
10
11
  var defaultProps: {
11
12
  completed: boolean;
12
13
  error: null;
14
+ showCheckoutSummary: boolean;
13
15
  };
14
16
  }
15
17
  export default Payment;
@@ -29,7 +29,8 @@ var _summary = _interopRequireDefault(require("./summary"));
29
29
  var _mobile = require("../hooks/mobile");
30
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
31
  PaymentInner.defaultProps = {
32
- completed: false
32
+ completed: false,
33
+ showCheckoutSummary: true
33
34
  };
34
35
  function PaymentInner({
35
36
  checkoutSession,
@@ -42,7 +43,8 @@ function PaymentInner({
42
43
  onPaid,
43
44
  onError,
44
45
  onChange,
45
- action
46
+ action,
47
+ showCheckoutSummary = true
46
48
  }) {
47
49
  const {
48
50
  t
@@ -59,6 +61,7 @@ function PaymentInner({
59
61
  });
60
62
  const defaultCurrencyId = state.checkoutSession.currency_id || state.checkoutSession.line_items[0]?.price.currency_id;
61
63
  const defaultMethodId = paymentMethods.find(m => m.payment_currencies.some(c => c.id === defaultCurrencyId))?.id;
64
+ const hideSummaryCard = mode.endsWith("-minimal") || !showCheckoutSummary;
62
65
  const methods = (0, _reactHookForm.useForm)({
63
66
  defaultValues: {
64
67
  customer_name: customer?.name || session?.user?.fullName || "",
@@ -183,10 +186,10 @@ function PaymentInner({
183
186
  sm: mode === "standalone" ? 0 : mode === "inline" ? 4 : 8
184
187
  }
185
188
  },
186
- children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Fade, {
189
+ children: [!hideSummaryCard && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Fade, {
187
190
  in: true,
188
191
  children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
189
- className: "cko-overview base-card",
192
+ className: "base-card cko-overview",
190
193
  direction: "column",
191
194
  children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_summary.default, {
192
195
  items: state.checkoutSession.line_items,
@@ -213,7 +216,7 @@ function PaymentInner({
213
216
  })]
214
217
  })
215
218
  }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
216
- className: "cko-payment base-card",
219
+ className: "base-card cko-payment",
217
220
  direction: "column",
218
221
  spacing: {
219
222
  xs: 2,
@@ -248,7 +251,8 @@ function PaymentInner({
248
251
  }
249
252
  Payment.defaultProps = {
250
253
  completed: false,
251
- error: null
254
+ error: null,
255
+ showCheckoutSummary: true
252
256
  };
253
257
  function Payment({
254
258
  checkoutSession,
@@ -263,7 +267,8 @@ function Payment({
263
267
  onError,
264
268
  onChange,
265
269
  goBack,
266
- action
270
+ action,
271
+ showCheckoutSummary = true
267
272
  }) {
268
273
  const {
269
274
  t
@@ -274,6 +279,7 @@ function Payment({
274
279
  setLivemode
275
280
  } = (0, _payment.usePaymentContext)();
276
281
  const [delay, setDelay] = (0, _react.useState)(false);
282
+ const hideSummaryCard = mode.endsWith("-minimal") || !showCheckoutSummary;
277
283
  (0, _react.useEffect)(() => {
278
284
  setTimeout(() => {
279
285
  setDelay(true);
@@ -298,14 +304,14 @@ function Payment({
298
304
  sm: mode === "standalone" ? 0 : mode === "inline" ? 4 : 8
299
305
  }
300
306
  },
301
- children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
302
- className: "cko-overview base-card",
307
+ children: [!hideSummaryCard && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
308
+ className: "base-card cko-overview",
303
309
  children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
304
310
  className: "cko-product",
305
311
  children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_overview.default, {})
306
312
  })
307
313
  }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
308
- className: "cko-payment base-card",
314
+ className: "base-card cko-payment",
309
315
  children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_payment2.default, {})
310
316
  })]
311
317
  });
@@ -336,7 +342,8 @@ function Payment({
336
342
  onChange,
337
343
  goBack,
338
344
  mode,
339
- action
345
+ action,
346
+ showCheckoutSummary
340
347
  });
341
348
  };
342
349
  return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
@@ -407,16 +414,24 @@ const Root = exports.Root = (0, _system.styled)(_material.Box)`
407
414
  // padding: ${props => props.mode === "standalone" ? "0 16px" : "0"};
408
415
  }
409
416
 
417
+ .base-card {
418
+ border: none;
419
+ border-radius: 0;
420
+ padding: ${props => props.mode === "standalone" ? "100px 40px 20px" : "20px 0"};
421
+ box-shadow: none;
422
+ flex: 1;
423
+ max-width: 582px;
424
+ }
425
+
410
426
  .cko-overview {
411
427
  // width: ${props => props.mode.endsWith("-minimal") ? "100%" : "400px"};
412
428
  // min-height: ${props => props.mode === "standalone" ? "540px" : "auto"};
413
429
  position: relative;
414
- display: ${props => props.mode.endsWith("-minimal") ? "none" : "block"};
430
+ flex-direction: column;
431
+ display: ${props => props.mode.endsWith("-minimal") ? "none" : "flex"};
415
432
  background: var(--backgrounds-bg-base);
416
433
  min-height: 'auto';
417
434
  // width: 502px;
418
- display: flex;
419
- flex-direction: column;
420
435
  }
421
436
  .cko-header {
422
437
  left: 0;
@@ -442,15 +457,6 @@ const Root = exports.Root = (0, _system.styled)(_material.Box)`
442
457
  text-overflow: ellipsis;
443
458
  }
444
459
 
445
- .base-card {
446
- border: none;
447
- border-radius: 0;
448
- padding: ${props => props.mode === "standalone" ? "100px 40px 20px" : "20px 0"};
449
- box-shadow: none;
450
- flex: 1;
451
- max-width: 582px;
452
- }
453
-
454
460
  .cko-payment {
455
461
  width: 502px;
456
462
  // width: ${props => props.mode.endsWith("-minimal") ? "100%" : "400px"};
@@ -490,7 +496,7 @@ const Root = exports.Root = (0, _system.styled)(_material.Box)`
490
496
  margin-bottom: 4px;
491
497
  }
492
498
  .MuiBox-root {
493
- margin: -1px 0 0 -1px;
499
+ margin: 0;
494
500
  }
495
501
 
496
502
  .MuiFormHelperText-root {
@@ -551,9 +557,8 @@ const Root = exports.Root = (0, _system.styled)(_material.Box)`
551
557
  flex-direction: column;
552
558
  align-items: center;
553
559
  gap: 32px;
554
- min-width: 350px;
555
- max-width: 400px;
556
560
  overflow: visible;
561
+ min-width: 200px;
557
562
  }
558
563
  .cko-overview {
559
564
  width: 100%;
@@ -109,11 +109,8 @@ function ProductDonation({
109
109
  error: ""
110
110
  });
111
111
  } else {
112
- setState({
113
- custom: false,
114
- input: "",
115
- error: ""
116
- });
112
+ setPayable(true);
113
+ handleSelect(preset);
117
114
  }
118
115
  };
119
116
  return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
@@ -154,7 +151,8 @@ function ProductDonation({
154
151
  children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
155
152
  direction: "row",
156
153
  sx: {
157
- py: 1
154
+ py: 1,
155
+ px: 0.5
158
156
  },
159
157
  spacing: 0.5,
160
158
  alignItems: "flex-end",
@@ -162,7 +160,7 @@ function ProductDonation({
162
160
  children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
163
161
  component: "strong",
164
162
  lineHeight: 1,
165
- variant: "h5",
163
+ variant: "h3",
166
164
  sx: {
167
165
  fontVariantNumeric: "tabular-nums",
168
166
  fontWeight: 400
@@ -289,7 +289,7 @@ function PaymentSummary({
289
289
  },
290
290
  children: action || t("payment.checkout.orderSummary")
291
291
  }), !settings.livemode && /* @__PURE__ */(0, _jsxRuntime.jsx)(_livemode.default, {})]
292
- }), isMobile ? /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
292
+ }), isMobile && !donationSettings ? /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
293
293
  children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
294
294
  justifyContent: "space-between",
295
295
  flexDirection: "row",
@@ -1,9 +1,14 @@
1
- import { type ThemeOptions } from '@mui/material/styles';
2
1
  import React from 'react';
3
2
  import { typography } from './typography';
4
3
  import './index.css';
4
+ import { PaymentThemeOptions } from '../types';
5
5
  export { typography };
6
- export declare const themeOverrides: Partial<ThemeOptions>;
7
- export declare function PaymentThemeProvider({ children }: {
6
+ export declare function PaymentThemeProvider({ children, theme: customTheme, }: {
8
7
  children: React.ReactNode;
8
+ theme?: PaymentThemeOptions;
9
9
  }): JSX.Element;
10
+ export declare namespace PaymentThemeProvider {
11
+ var defaultProps: {
12
+ theme: {};
13
+ };
14
+ }