@blocklet/payment-react 1.18.55 → 1.19.0

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 (220) hide show
  1. package/es/checkout/donate.d.ts +1 -15
  2. package/es/checkout/donate.js +301 -189
  3. package/es/checkout/form.d.ts +1 -15
  4. package/es/checkout/form.js +5 -13
  5. package/es/checkout/table.js +3 -3
  6. package/es/components/blockchain/gas.d.ts +1 -5
  7. package/es/components/blockchain/gas.js +10 -2
  8. package/es/components/blockchain/tx.d.ts +1 -8
  9. package/es/components/blockchain/tx.js +28 -7
  10. package/es/components/confirm.d.ts +1 -10
  11. package/es/components/confirm.js +4 -10
  12. package/es/components/country-select.d.ts +3 -2
  13. package/es/components/country-select.js +375 -352
  14. package/es/components/input.d.ts +11 -20
  15. package/es/components/input.js +46 -43
  16. package/es/components/lazy-loader.js +1 -2
  17. package/es/components/link.d.ts +2 -9
  18. package/es/components/link.js +9 -6
  19. package/es/components/livemode.d.ts +2 -8
  20. package/es/components/livemode.js +1 -5
  21. package/es/components/loading-button.d.ts +6 -1
  22. package/es/components/loading-button.js +56 -66
  23. package/es/components/over-due-invoice-payment.d.ts +0 -18
  24. package/es/components/over-due-invoice-payment.js +138 -95
  25. package/es/components/payment-beneficiaries.d.ts +2 -7
  26. package/es/components/payment-beneficiaries.js +86 -40
  27. package/es/components/pricing-item.d.ts +0 -5
  28. package/es/components/pricing-item.js +1 -4
  29. package/es/components/pricing-table.d.ts +2 -10
  30. package/es/components/pricing-table.js +8 -7
  31. package/es/components/resume-subscription.d.ts +0 -10
  32. package/es/components/resume-subscription.js +42 -21
  33. package/es/components/truncated-text.d.ts +2 -9
  34. package/es/components/truncated-text.js +0 -5
  35. package/es/contexts/donate.d.ts +0 -7
  36. package/es/contexts/donate.js +10 -8
  37. package/es/contexts/payment.d.ts +1 -4
  38. package/es/contexts/payment.js +7 -2
  39. package/es/history/invoice/list.d.ts +2 -18
  40. package/es/history/invoice/list.js +151 -73
  41. package/es/history/payment/list.js +115 -38
  42. package/es/hooks/keyboard.d.ts +1 -1
  43. package/es/hooks/keyboard.js +2 -4
  44. package/es/libs/cached-request.js +2 -4
  45. package/es/libs/phone-validator.js +1 -2
  46. package/es/libs/util.js +2 -4
  47. package/es/libs/validator.js +2 -4
  48. package/es/payment/amount.d.ts +2 -7
  49. package/es/payment/amount.js +1 -5
  50. package/es/payment/donation-form.d.ts +2 -10
  51. package/es/payment/donation-form.js +196 -160
  52. package/es/payment/error.d.ts +2 -8
  53. package/es/payment/error.js +40 -20
  54. package/es/payment/footer.d.ts +2 -3
  55. package/es/payment/footer.js +19 -6
  56. package/es/payment/form/addon.js +14 -4
  57. package/es/payment/form/address.d.ts +2 -9
  58. package/es/payment/form/address.js +3 -6
  59. package/es/payment/form/currency.js +45 -25
  60. package/es/payment/form/index.d.ts +2 -8
  61. package/es/payment/form/index.js +107 -65
  62. package/es/payment/form/phone.js +2 -4
  63. package/es/payment/form/stripe/form.d.ts +2 -8
  64. package/es/payment/form/stripe/form.js +1 -3
  65. package/es/payment/header.js +38 -16
  66. package/es/payment/index.d.ts +2 -9
  67. package/es/payment/index.js +5 -14
  68. package/es/payment/product-card.d.ts +2 -11
  69. package/es/payment/product-card.js +84 -50
  70. package/es/payment/product-donation.js +175 -114
  71. package/es/payment/product-item.d.ts +2 -9
  72. package/es/payment/product-item.js +185 -142
  73. package/es/payment/product-skeleton.js +2 -2
  74. package/es/payment/skeleton/donation.js +27 -7
  75. package/es/payment/skeleton/overview.js +22 -2
  76. package/es/payment/skeleton/payment.js +33 -5
  77. package/es/payment/success.d.ts +2 -9
  78. package/es/payment/success.js +41 -14
  79. package/es/payment/summary.d.ts +2 -17
  80. package/es/payment/summary.js +184 -111
  81. package/es/theme/index.d.ts +0 -5
  82. package/es/theme/index.js +2 -5
  83. package/es/theme/typography.d.ts +2 -2
  84. package/lib/checkout/donate.d.ts +1 -15
  85. package/lib/checkout/donate.js +75 -54
  86. package/lib/checkout/form.d.ts +1 -15
  87. package/lib/checkout/form.js +7 -15
  88. package/lib/checkout/table.js +4 -4
  89. package/lib/components/blockchain/gas.d.ts +1 -5
  90. package/lib/components/blockchain/gas.js +3 -2
  91. package/lib/components/blockchain/tx.d.ts +1 -8
  92. package/lib/components/blockchain/tx.js +11 -7
  93. package/lib/components/confirm.d.ts +1 -10
  94. package/lib/components/confirm.js +5 -11
  95. package/lib/components/country-select.d.ts +3 -2
  96. package/lib/components/country-select.js +23 -22
  97. package/lib/components/input.d.ts +11 -20
  98. package/lib/components/input.js +20 -23
  99. package/lib/components/lazy-loader.js +1 -1
  100. package/lib/components/link.d.ts +2 -9
  101. package/lib/components/link.js +3 -8
  102. package/lib/components/livemode.d.ts +2 -8
  103. package/lib/components/livemode.js +3 -7
  104. package/lib/components/loading-button.d.ts +6 -1
  105. package/lib/components/loading-button.js +9 -17
  106. package/lib/components/over-due-invoice-payment.d.ts +0 -18
  107. package/lib/components/over-due-invoice-payment.js +31 -33
  108. package/lib/components/payment-beneficiaries.d.ts +2 -7
  109. package/lib/components/payment-beneficiaries.js +12 -11
  110. package/lib/components/pricing-item.d.ts +0 -5
  111. package/lib/components/pricing-item.js +2 -5
  112. package/lib/components/pricing-table.d.ts +2 -10
  113. package/lib/components/pricing-table.js +5 -11
  114. package/lib/components/resume-subscription.d.ts +0 -10
  115. package/lib/components/resume-subscription.js +16 -16
  116. package/lib/components/table.js +1 -1
  117. package/lib/components/truncated-text.d.ts +2 -9
  118. package/lib/components/truncated-text.js +1 -6
  119. package/lib/contexts/donate.d.ts +0 -7
  120. package/lib/contexts/donate.js +4 -7
  121. package/lib/contexts/payment.d.ts +1 -4
  122. package/lib/contexts/payment.js +4 -7
  123. package/lib/history/invoice/list.d.ts +2 -18
  124. package/lib/history/invoice/list.js +49 -37
  125. package/lib/history/payment/list.js +30 -16
  126. package/lib/hooks/keyboard.d.ts +1 -1
  127. package/lib/hooks/mobile.js +1 -1
  128. package/lib/hooks/subscription.js +1 -1
  129. package/lib/index.js +2 -2
  130. package/lib/libs/api.js +1 -1
  131. package/lib/libs/dayjs.js +1 -1
  132. package/lib/libs/phone-validator.js +0 -2
  133. package/lib/libs/theme.js +1 -1
  134. package/lib/libs/util.js +1 -1
  135. package/lib/libs/validator.js +1 -1
  136. package/lib/locales/en.js +1 -1
  137. package/lib/locales/index.js +1 -1
  138. package/lib/locales/zh.js +1 -1
  139. package/lib/payment/amount.d.ts +2 -7
  140. package/lib/payment/amount.js +2 -6
  141. package/lib/payment/donation-form.d.ts +2 -10
  142. package/lib/payment/donation-form.js +33 -38
  143. package/lib/payment/error.d.ts +2 -8
  144. package/lib/payment/error.js +11 -13
  145. package/lib/payment/footer.d.ts +2 -3
  146. package/lib/payment/footer.js +5 -5
  147. package/lib/payment/form/addon.js +5 -3
  148. package/lib/payment/form/address.d.ts +2 -9
  149. package/lib/payment/form/address.js +5 -8
  150. package/lib/payment/form/currency.js +3 -3
  151. package/lib/payment/form/index.d.ts +2 -8
  152. package/lib/payment/form/index.js +19 -15
  153. package/lib/payment/form/phone.js +1 -1
  154. package/lib/payment/form/stripe/form.d.ts +2 -8
  155. package/lib/payment/form/stripe/form.js +3 -6
  156. package/lib/payment/header.js +8 -4
  157. package/lib/payment/index.d.ts +2 -9
  158. package/lib/payment/index.js +7 -16
  159. package/lib/payment/product-card.d.ts +2 -11
  160. package/lib/payment/product-card.js +13 -20
  161. package/lib/payment/product-donation.js +71 -66
  162. package/lib/payment/product-item.d.ts +2 -9
  163. package/lib/payment/product-item.js +24 -25
  164. package/lib/payment/product-skeleton.js +2 -2
  165. package/lib/payment/skeleton/donation.js +8 -4
  166. package/lib/payment/skeleton/overview.js +6 -2
  167. package/lib/payment/skeleton/payment.js +9 -3
  168. package/lib/payment/success.d.ts +2 -9
  169. package/lib/payment/success.js +12 -15
  170. package/lib/payment/summary.d.ts +2 -17
  171. package/lib/payment/summary.js +44 -45
  172. package/lib/theme/index.d.ts +0 -5
  173. package/lib/theme/index.js +2 -5
  174. package/lib/theme/typography.d.ts +2 -2
  175. package/package.json +40 -40
  176. package/src/checkout/donate.tsx +103 -35
  177. package/src/checkout/form.tsx +5 -14
  178. package/src/checkout/table.tsx +3 -3
  179. package/src/components/blockchain/gas.tsx +5 -3
  180. package/src/components/blockchain/tx.tsx +22 -8
  181. package/src/components/confirm.tsx +4 -11
  182. package/src/components/country-select.tsx +391 -378
  183. package/src/components/input.tsx +49 -45
  184. package/src/components/link.tsx +9 -7
  185. package/src/components/livemode.tsx +2 -6
  186. package/src/components/loading-button.tsx +63 -76
  187. package/src/components/over-due-invoice-payment.tsx +43 -28
  188. package/src/components/payment-beneficiaries.tsx +33 -14
  189. package/src/components/pricing-item.tsx +1 -4
  190. package/src/components/pricing-table.tsx +8 -8
  191. package/src/components/resume-subscription.tsx +20 -14
  192. package/src/components/table.tsx +2 -2
  193. package/src/components/truncated-text.tsx +0 -6
  194. package/src/contexts/donate.tsx +6 -7
  195. package/src/contexts/payment.tsx +7 -3
  196. package/src/history/invoice/list.tsx +74 -35
  197. package/src/history/payment/list.tsx +53 -16
  198. package/src/hooks/keyboard.ts +1 -1
  199. package/src/payment/amount.tsx +1 -6
  200. package/src/payment/donation-form.tsx +47 -29
  201. package/src/payment/error.tsx +16 -8
  202. package/src/payment/footer.tsx +11 -3
  203. package/src/payment/form/addon.tsx +6 -1
  204. package/src/payment/form/address.tsx +3 -7
  205. package/src/payment/form/currency.tsx +12 -2
  206. package/src/payment/form/index.tsx +30 -12
  207. package/src/payment/form/stripe/form.tsx +1 -5
  208. package/src/payment/header.tsx +14 -2
  209. package/src/payment/index.tsx +10 -21
  210. package/src/payment/product-card.tsx +41 -18
  211. package/src/payment/product-donation.tsx +85 -47
  212. package/src/payment/product-item.tsx +46 -24
  213. package/src/payment/product-skeleton.tsx +3 -2
  214. package/src/payment/skeleton/donation.tsx +12 -2
  215. package/src/payment/skeleton/overview.tsx +12 -2
  216. package/src/payment/skeleton/payment.tsx +16 -3
  217. package/src/payment/success.tsx +26 -15
  218. package/src/payment/summary.tsx +74 -42
  219. package/src/theme/index.tsx +5 -8
  220. package/src/theme/typography.ts +2 -2
@@ -21,31 +21,51 @@ export default function CurrencySelector({ value, currencies, onChange }) {
21
21
  variant: "outlined",
22
22
  onClick: () => onChange(x.id, x.method?.id),
23
23
  className: selected ? "cko-payment-card" : "cko-payment-card-unselect",
24
- children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", sx: { position: "relative" }, children: [
25
- /* @__PURE__ */ jsx(Avatar, { src: x.logo, alt: x.name, sx: { width: 40, height: 40, marginRight: "12px" } }),
26
- /* @__PURE__ */ jsxs("div", { children: [
27
- /* @__PURE__ */ jsx(
28
- Typography,
29
- {
30
- variant: "h5",
31
- component: "div",
32
- sx: { fontSize: "16px", color: "text.primary", fontWeight: "500" },
33
- children: x.symbol
34
- }
35
- ),
36
- /* @__PURE__ */ jsx(Typography, { sx: { fontSize: 14 }, color: "text.lighter", gutterBottom: true, children: x.method.name })
37
- ] }),
38
- /* @__PURE__ */ jsx(
39
- Radio,
40
- {
41
- checked: selected,
42
- sx: {
43
- position: "absolute",
44
- right: 0
45
- }
46
- }
47
- )
48
- ] })
24
+ children: /* @__PURE__ */ jsxs(
25
+ Stack,
26
+ {
27
+ direction: "row",
28
+ sx: {
29
+ alignItems: "center",
30
+ position: "relative"
31
+ },
32
+ children: [
33
+ /* @__PURE__ */ jsx(Avatar, { src: x.logo, alt: x.name, sx: { width: 40, height: 40, marginRight: "12px" } }),
34
+ /* @__PURE__ */ jsxs("div", { children: [
35
+ /* @__PURE__ */ jsx(
36
+ Typography,
37
+ {
38
+ variant: "h5",
39
+ component: "div",
40
+ sx: { fontSize: "16px", color: "text.primary", fontWeight: "500" },
41
+ children: x.symbol
42
+ }
43
+ ),
44
+ /* @__PURE__ */ jsx(
45
+ Typography,
46
+ {
47
+ gutterBottom: true,
48
+ sx: {
49
+ color: "text.lighter",
50
+ fontSize: 14
51
+ },
52
+ children: x.method.name
53
+ }
54
+ )
55
+ ] }),
56
+ /* @__PURE__ */ jsx(
57
+ Radio,
58
+ {
59
+ checked: selected,
60
+ sx: {
61
+ position: "absolute",
62
+ right: 0
63
+ }
64
+ }
65
+ )
66
+ ]
67
+ }
68
+ )
49
69
  },
50
70
  x.id
51
71
  );
@@ -6,11 +6,5 @@ type PageData = CheckoutContext & CheckoutCallbacks & {
6
6
  onlyShowBtn?: boolean;
7
7
  isDonation?: boolean;
8
8
  };
9
- declare function PaymentForm({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, onPaid, onError, action, onlyShowBtn, isDonation, }: PageData): import("react").JSX.Element;
10
- declare namespace PaymentForm {
11
- var defaultProps: {
12
- onlyShowBtn: boolean;
13
- isDonation: boolean;
14
- };
15
- }
16
- export default PaymentForm;
9
+ export default function PaymentForm({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, onPaid, onError, action, onlyShowBtn, isDonation, }: PageData): import("react").JSX.Element;
10
+ export {};
@@ -85,10 +85,6 @@ const setUserFormValues = (userInfo, currentValues, setValue, options = {}) => {
85
85
  }
86
86
  });
87
87
  };
88
- PaymentForm.defaultProps = {
89
- onlyShowBtn: false,
90
- isDonation: false
91
- };
92
88
  export default function PaymentForm({
93
89
  checkoutSession,
94
90
  paymentMethods,
@@ -99,7 +95,7 @@ export default function PaymentForm({
99
95
  onError,
100
96
  // mode,
101
97
  action,
102
- onlyShowBtn,
98
+ onlyShowBtn = false,
103
99
  isDonation = false
104
100
  }) {
105
101
  const { t, locale } = useLocaleContext();
@@ -270,8 +266,7 @@ export default function PaymentForm({
270
266
  }
271
267
  };
272
268
  const handleFastCheckoutConfirm = async () => {
273
- if (!state.fastCheckoutInfo)
274
- return;
269
+ if (!state.fastCheckoutInfo) return;
275
270
  setState({
276
271
  fastCheckoutInfo: {
277
272
  ...state.fastCheckoutInfo,
@@ -455,34 +450,71 @@ export default function PaymentForm({
455
450
  /* @__PURE__ */ jsx(Typography, { children: t("payment.checkout.fastPay.autoPaymentReason") }),
456
451
  /* @__PURE__ */ jsx(Divider, { sx: { mt: 1.5, mb: 1.5 } }),
457
452
  /* @__PURE__ */ jsxs(Stack, { spacing: 1, children: [
458
- /* @__PURE__ */ jsxs(Stack, { flexDirection: "row", alignItems: "center", justifyContent: "space-between", children: [
459
- /* @__PURE__ */ jsx(Typography, { color: "text.primary", sx: { whiteSpace: "nowrap" }, children: t("payment.checkout.fastPay.payer") }),
460
- /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
461
- /* @__PURE__ */ jsx(DID, { did: state.fastCheckoutInfo.payer || "", compact: true, responsive: false }),
462
- balanceLink && /* @__PURE__ */ jsx(Tooltip, { title: t("payment.checkout.fastPay.balanceLink"), placement: "top", children: /* @__PURE__ */ jsx(
463
- OpenInNew,
464
- {
465
- sx: {
466
- color: "text.lighter",
467
- fontSize: "0.85rem",
468
- cursor: "pointer",
469
- "&:hover": { color: "text.primary" }
470
- },
471
- onClick: () => {
472
- window.open(balanceLink, "_blank");
453
+ /* @__PURE__ */ jsxs(
454
+ Stack,
455
+ {
456
+ sx: {
457
+ flexDirection: "row",
458
+ alignItems: "center",
459
+ justifyContent: "space-between"
460
+ },
461
+ children: [
462
+ /* @__PURE__ */ jsx(
463
+ Typography,
464
+ {
465
+ sx: {
466
+ color: "text.primary",
467
+ whiteSpace: "nowrap"
468
+ },
469
+ children: t("payment.checkout.fastPay.payer")
473
470
  }
474
- }
475
- ) })
476
- ] })
477
- ] }),
478
- /* @__PURE__ */ jsxs(Stack, { flexDirection: "row", alignItems: "center", justifyContent: "space-between", children: [
479
- /* @__PURE__ */ jsx(Typography, { color: "text.primary", children: t("payment.checkout.fastPay.amount") }),
480
- /* @__PURE__ */ jsxs(Typography, { children: [
481
- fromUnitToToken(state.fastCheckoutInfo.amount, paymentCurrency?.decimal || 18).toString(),
482
- " ",
483
- paymentCurrency?.symbol
484
- ] })
485
- ] })
471
+ ),
472
+ /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
473
+ /* @__PURE__ */ jsx(DID, { did: state.fastCheckoutInfo.payer || "", compact: true, responsive: false }),
474
+ balanceLink && /* @__PURE__ */ jsx(Tooltip, { title: t("payment.checkout.fastPay.balanceLink"), placement: "top", children: /* @__PURE__ */ jsx(
475
+ OpenInNew,
476
+ {
477
+ sx: {
478
+ color: "text.lighter",
479
+ fontSize: "0.85rem",
480
+ cursor: "pointer",
481
+ "&:hover": { color: "text.primary" }
482
+ },
483
+ onClick: () => {
484
+ window.open(balanceLink, "_blank");
485
+ }
486
+ }
487
+ ) })
488
+ ] })
489
+ ]
490
+ }
491
+ ),
492
+ /* @__PURE__ */ jsxs(
493
+ Stack,
494
+ {
495
+ sx: {
496
+ flexDirection: "row",
497
+ alignItems: "center",
498
+ justifyContent: "space-between"
499
+ },
500
+ children: [
501
+ /* @__PURE__ */ jsx(
502
+ Typography,
503
+ {
504
+ sx: {
505
+ color: "text.primary"
506
+ },
507
+ children: t("payment.checkout.fastPay.amount")
508
+ }
509
+ ),
510
+ /* @__PURE__ */ jsxs(Typography, { children: [
511
+ fromUnitToToken(state.fastCheckoutInfo.amount, paymentCurrency?.decimal || 18).toString(),
512
+ " ",
513
+ paymentCurrency?.symbol
514
+ ] })
515
+ ]
516
+ }
517
+ )
486
518
  ] })
487
519
  ] }),
488
520
  loading: state.fastCheckoutInfo.loading,
@@ -563,40 +595,50 @@ export default function PaymentForm({
563
595
  children: t("payment.checkout.paymentDetails")
564
596
  }
565
597
  ),
566
- /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { direction: "column", alignItems: "flex-start", className: "cko-payment-methods", children: [
567
- /* @__PURE__ */ jsx(Stack, { direction: "row", sx: { width: "100%" }, children: /* @__PURE__ */ jsx(
568
- Controller,
569
- {
570
- name: "payment_currency",
571
- control,
572
- render: ({ field }) => /* @__PURE__ */ jsx(
573
- CurrencySelector,
598
+ /* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(
599
+ Stack,
600
+ {
601
+ direction: "column",
602
+ className: "cko-payment-methods",
603
+ sx: {
604
+ alignItems: "flex-start"
605
+ },
606
+ children: [
607
+ /* @__PURE__ */ jsx(Stack, { direction: "row", sx: { width: "100%" }, children: /* @__PURE__ */ jsx(
608
+ Controller,
574
609
  {
575
- value: field.value,
576
- currencies,
577
- onChange: (id, methodId) => {
578
- field.onChange(id);
579
- setValue("payment_method", methodId);
580
- saveCurrencyPreference(id, session?.user?.did);
581
- }
610
+ name: "payment_currency",
611
+ control,
612
+ render: ({ field }) => /* @__PURE__ */ jsx(
613
+ CurrencySelector,
614
+ {
615
+ value: field.value,
616
+ currencies,
617
+ onChange: (id, methodId) => {
618
+ field.onChange(id);
619
+ setValue("payment_method", methodId);
620
+ saveCurrencyPreference(id, session?.user?.did);
621
+ }
622
+ }
623
+ )
624
+ }
625
+ ) }),
626
+ state.stripePaying && state.stripeContext && /* @__PURE__ */ jsx(
627
+ StripeCheckout,
628
+ {
629
+ clientSecret: state.stripeContext.client_secret,
630
+ intentType: state.stripeContext.intent_type,
631
+ publicKey: method.settings.stripe?.publishable_key,
632
+ customer: state.customer,
633
+ mode: checkoutSession.mode,
634
+ onConfirm: onStripeConfirm,
635
+ onCancel: onStripeCancel,
636
+ returnUrl: checkoutSession?.success_url
582
637
  }
583
638
  )
584
- }
585
- ) }),
586
- state.stripePaying && state.stripeContext && /* @__PURE__ */ jsx(
587
- StripeCheckout,
588
- {
589
- clientSecret: state.stripeContext.client_secret,
590
- intentType: state.stripeContext.intent_type,
591
- publicKey: method.settings.stripe?.publishable_key,
592
- customer: state.customer,
593
- mode: checkoutSession.mode,
594
- onConfirm: onStripeConfirm,
595
- onCancel: onStripeCancel,
596
- returnUrl: checkoutSession?.success_url
597
- }
598
- )
599
- ] }) }),
639
+ ]
640
+ }
641
+ ) }),
600
642
  showForm && /* @__PURE__ */ jsxs(
601
643
  Stack,
602
644
  {
@@ -15,8 +15,7 @@ export default function PhoneInput({ ...props }) {
15
15
  const values = getValues();
16
16
  const isUpdatingRef = useRef(false);
17
17
  const safeUpdate = useCallback((callback) => {
18
- if (isUpdatingRef.current)
19
- return;
18
+ if (isUpdatingRef.current) return;
20
19
  try {
21
20
  isUpdatingRef.current = true;
22
21
  callback();
@@ -39,8 +38,7 @@ export default function PhoneInput({ ...props }) {
39
38
  });
40
39
  const userCountry = useWatch({ control, name: countryFieldName });
41
40
  useEffect(() => {
42
- if (!userCountry || userCountry === country)
43
- return;
41
+ if (!userCountry || userCountry === country) return;
44
42
  safeUpdate(() => {
45
43
  setCountry(userCountry);
46
44
  });
@@ -5,7 +5,7 @@ export type StripeCheckoutFormProps = {
5
5
  customer: TCustomer;
6
6
  mode: string;
7
7
  onConfirm: Function;
8
- returnUrl: string;
8
+ returnUrl?: string;
9
9
  };
10
10
  export type StripeCheckoutProps = {
11
11
  clientSecret: string;
@@ -17,10 +17,4 @@ export type StripeCheckoutProps = {
17
17
  onCancel: Function;
18
18
  returnUrl?: string;
19
19
  };
20
- declare function StripeCheckout({ clientSecret, intentType, publicKey, mode, customer, onConfirm, onCancel, returnUrl, }: StripeCheckoutProps): import("react").JSX.Element;
21
- declare namespace StripeCheckout {
22
- var defaultProps: {
23
- returnUrl: string;
24
- };
25
- }
26
- export default StripeCheckout;
20
+ export default function StripeCheckout({ clientSecret, intentType, publicKey, mode, customer, onConfirm, onCancel, returnUrl, }: StripeCheckoutProps): import("react").JSX.Element;
@@ -79,6 +79,7 @@ function StripeCheckoutForm({
79
79
  setState({ message: t("paymentCredit.preparePayMessage.processing") });
80
80
  break;
81
81
  case "requires_payment_method":
82
+ // 忽略该状态
82
83
  default:
83
84
  break;
84
85
  }
@@ -304,6 +305,3 @@ export default function StripeCheckout({
304
305
  }
305
306
  );
306
307
  }
307
- StripeCheckout.defaultProps = {
308
- returnUrl: ""
309
- };
@@ -18,20 +18,42 @@ export default function PaymentHeader({ checkoutSession }) {
18
18
  }
19
19
  return false;
20
20
  }, [domSize, theme]);
21
- return /* @__PURE__ */ jsxs(Stack, { className: "cko-header", direction: "row", spacing: 1, alignItems: "center", justifyContent: "space-between", children: [
22
- /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [
23
- /* @__PURE__ */ jsx(
24
- Avatar,
25
- {
26
- variant: "square",
27
- src: window.blocklet.appLogo,
28
- sx: { width: 32, height: 32 },
29
- alt: window.blocklet?.appName || "Logo"
30
- }
31
- ),
32
- /* @__PURE__ */ jsx(Typography, { sx: { color: "text.primary", fontWeight: 600 }, children: brand }),
33
- !livemode && /* @__PURE__ */ jsx(Livemode, {})
34
- ] }),
35
- isColumnLayout ? /* @__PURE__ */ jsx(UserButtons, {}) : null
36
- ] });
21
+ return /* @__PURE__ */ jsxs(
22
+ Stack,
23
+ {
24
+ className: "cko-header",
25
+ direction: "row",
26
+ spacing: 1,
27
+ sx: {
28
+ alignItems: "center",
29
+ justifyContent: "space-between"
30
+ },
31
+ children: [
32
+ /* @__PURE__ */ jsxs(
33
+ Stack,
34
+ {
35
+ direction: "row",
36
+ spacing: 1,
37
+ sx: {
38
+ alignItems: "center"
39
+ },
40
+ children: [
41
+ /* @__PURE__ */ jsx(
42
+ Avatar,
43
+ {
44
+ variant: "square",
45
+ src: window.blocklet.appLogo,
46
+ sx: { width: 32, height: 32 },
47
+ alt: window.blocklet?.appName || "Logo"
48
+ }
49
+ ),
50
+ /* @__PURE__ */ jsx(Typography, { sx: { color: "text.primary", fontWeight: 600 }, children: brand }),
51
+ !livemode && /* @__PURE__ */ jsx(Livemode, {})
52
+ ]
53
+ }
54
+ ),
55
+ isColumnLayout ? /* @__PURE__ */ jsx(UserButtons, {}) : null
56
+ ]
57
+ }
58
+ );
37
59
  }
@@ -6,16 +6,9 @@ type Props = CheckoutContext & CheckoutCallbacks & {
6
6
  error?: any;
7
7
  showCheckoutSummary?: boolean;
8
8
  };
9
- declare function Payment({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, completed, error, mode, onPaid, onError, onChange, goBack, action, showCheckoutSummary, }: Props): import("react").JSX.Element;
10
- declare namespace Payment {
11
- var defaultProps: {
12
- completed: boolean;
13
- error: null;
14
- showCheckoutSummary: boolean;
15
- };
16
- }
17
- export default Payment;
9
+ export default function Payment({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, completed, error, mode, onPaid, onError, onChange, goBack, action, showCheckoutSummary, }: Props): import("react").JSX.Element;
18
10
  type RootProps = {
19
11
  mode: LiteralUnion<'standalone' | 'inline' | 'popup', string>;
20
12
  } & BoxProps;
21
13
  export declare const Root: React.FC<RootProps>;
14
+ export {};
@@ -30,17 +30,13 @@ import PaymentSummary from "./summary.js";
30
30
  import { useMobile } from "../hooks/mobile.js";
31
31
  import { formatPhone } from "../libs/phone-validator.js";
32
32
  import { getCurrencyPreference } from "../libs/currency.js";
33
- PaymentInner.defaultProps = {
34
- completed: false,
35
- showCheckoutSummary: true
36
- };
37
33
  function PaymentInner({
38
34
  checkoutSession,
39
35
  paymentMethods,
40
36
  paymentLink,
41
37
  paymentIntent,
42
38
  customer,
43
- completed,
39
+ completed = false,
44
40
  mode,
45
41
  onPaid,
46
42
  onError,
@@ -275,19 +271,14 @@ function PaymentInner({
275
271
  mode === "standalone" && isMobile && /* @__PURE__ */ jsx(CheckoutFooter, { className: "cko-footer", sx: { color: "text.lighter" } })
276
272
  ] }) });
277
273
  }
278
- Payment.defaultProps = {
279
- completed: false,
280
- error: null,
281
- showCheckoutSummary: true
282
- };
283
274
  export default function Payment({
284
275
  checkoutSession,
285
276
  paymentMethods,
286
277
  paymentIntent,
287
278
  paymentLink,
288
279
  customer,
289
- completed,
290
- error,
280
+ completed = false,
281
+ error = null,
291
282
  mode,
292
283
  onPaid,
293
284
  onError,
@@ -366,9 +357,9 @@ export default function Payment({
366
357
  return /* @__PURE__ */ jsxs(
367
358
  Stack,
368
359
  {
369
- display: "flex",
370
- flexDirection: "column",
371
360
  sx: {
361
+ display: "flex",
362
+ flexDirection: "column",
372
363
  height: mode === "standalone" ? "100vh" : "auto",
373
364
  overflow: isMobileSafariEnv ? "visible" : "hidden"
374
365
  },
@@ -7,14 +7,5 @@ type Props = {
7
7
  extra?: React.ReactNode;
8
8
  variant?: LiteralUnion<'square' | 'rounded' | 'circular', string>;
9
9
  };
10
- declare function ProductCard({ size, variant, name, logo, description, extra }: Props): import("react").JSX.Element;
11
- declare namespace ProductCard {
12
- var defaultProps: {
13
- logo: string;
14
- size: number;
15
- description: string;
16
- variant: string;
17
- extra: undefined;
18
- };
19
- }
20
- export default ProductCard;
10
+ export default function ProductCard({ size, variant, name, logo, description, extra, }: Props): import("react").JSX.Element;
11
+ export {};
@@ -1,54 +1,88 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Avatar, Box, Stack, Typography } from "@mui/material";
3
- export default function ProductCard({ size, variant, name, logo, description, extra }) {
3
+ export default function ProductCard({
4
+ size = 48,
5
+ variant = "rounded",
6
+ name,
7
+ logo = "",
8
+ description = "",
9
+ extra = void 0
10
+ }) {
4
11
  const s = { width: size, height: size };
5
- return /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, flex: 2, sx: { width: "100%" }, children: [
6
- logo ? (
7
- // @ts-ignore
8
- /* @__PURE__ */ jsx(Avatar, { src: logo, alt: name, variant, sx: s })
9
- ) : (
10
- // @ts-ignore
11
- /* @__PURE__ */ jsx(Avatar, { variant, sx: s, children: (name || "?").slice(0, 1) })
12
- ),
13
- /* @__PURE__ */ jsxs(
14
- Stack,
15
- {
16
- direction: "column",
17
- alignItems: "flex-start",
18
- justifyContent: "space-around",
19
- sx: { flexShrink: 1, overflow: "hidden" },
20
- children: [
21
- /* @__PURE__ */ jsx(
22
- Typography,
23
- {
24
- className: "cko-ellipsis",
25
- variant: "body1",
26
- title: name,
27
- sx: { fontWeight: 500, mb: 0.5, lineHeight: 1.2, fontSize: 16 },
28
- color: "text.primary",
29
- children: name
30
- }
31
- ),
32
- description && /* @__PURE__ */ jsx(
33
- Typography,
34
- {
35
- variant: "body1",
36
- title: description,
37
- sx: { fontSize: "0.74375rem", mb: 0.5, lineHeight: 1.2, textAlign: "left" },
38
- color: "text.lighter",
39
- children: description
40
- }
41
- ),
42
- extra && /* @__PURE__ */ jsx(Box, { sx: { fontSize: "0.74375rem" }, color: "text.lighter", children: extra })
43
- ]
44
- }
45
- )
46
- ] });
12
+ return /* @__PURE__ */ jsxs(
13
+ Stack,
14
+ {
15
+ direction: "row",
16
+ spacing: 1,
17
+ sx: {
18
+ alignItems: "center",
19
+ flex: 2,
20
+ width: "100%"
21
+ },
22
+ children: [
23
+ logo ? (
24
+ // @ts-ignore
25
+ /* @__PURE__ */ jsx(Avatar, { src: logo, alt: name, variant, sx: s })
26
+ ) : (
27
+ // @ts-ignore
28
+ /* @__PURE__ */ jsx(Avatar, { variant, sx: s, children: (name || "?").slice(0, 1) })
29
+ ),
30
+ /* @__PURE__ */ jsxs(
31
+ Stack,
32
+ {
33
+ direction: "column",
34
+ sx: {
35
+ alignItems: "flex-start",
36
+ justifyContent: "space-around",
37
+ flexShrink: 1,
38
+ overflow: "hidden"
39
+ },
40
+ children: [
41
+ /* @__PURE__ */ jsx(
42
+ Typography,
43
+ {
44
+ className: "cko-ellipsis",
45
+ variant: "body1",
46
+ title: name,
47
+ sx: {
48
+ color: "text.primary",
49
+ fontWeight: 500,
50
+ mb: 0.5,
51
+ lineHeight: 1.2,
52
+ fontSize: 16
53
+ },
54
+ children: name
55
+ }
56
+ ),
57
+ description && /* @__PURE__ */ jsx(
58
+ Typography,
59
+ {
60
+ variant: "body1",
61
+ title: description,
62
+ sx: {
63
+ color: "text.lighter",
64
+ fontSize: "0.74375rem",
65
+ mb: 0.5,
66
+ lineHeight: 1.2,
67
+ textAlign: "left"
68
+ },
69
+ children: description
70
+ }
71
+ ),
72
+ extra && /* @__PURE__ */ jsx(
73
+ Box,
74
+ {
75
+ sx: {
76
+ color: "text.lighter",
77
+ fontSize: "0.74375rem"
78
+ },
79
+ children: extra
80
+ }
81
+ )
82
+ ]
83
+ }
84
+ )
85
+ ]
86
+ }
87
+ );
47
88
  }
48
- ProductCard.defaultProps = {
49
- logo: "",
50
- size: 48,
51
- description: "",
52
- variant: "rounded",
53
- extra: void 0
54
- };