@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
@@ -162,7 +162,12 @@ function DonateProvider({
162
162
  <>
163
163
  {enableDonate && isAdmin && (
164
164
  <Stack spacing={1} sx={{ alignItems: 'center' }}>
165
- <Typography color="text.secondary">{t('payment.checkout.donation.inactive')}</Typography>
165
+ <Typography
166
+ sx={{
167
+ color: 'text.secondary',
168
+ }}>
169
+ {t('payment.checkout.donation.inactive')}
170
+ </Typography>
166
171
  <Button
167
172
  size="small"
168
173
  variant="outlined"
@@ -205,12 +210,6 @@ function useDonateContext() {
205
210
  return context;
206
211
  }
207
212
 
208
- DonateProvider.defaultProps = {
209
- defaultSettings: {},
210
- active: true,
211
- enableDonate: false,
212
- };
213
-
214
213
  export const clearDonateCache = (mountLocation: string) => {
215
214
  const livemode = localStorage.getItem('livemode') !== 'false';
216
215
  const cacheKey = `donate-settings-${mountLocation}-${livemode}`;
@@ -90,7 +90,13 @@ const syncToSpaceRequest = (userDid: string, spaceDid: string) => {
90
90
  });
91
91
  };
92
92
 
93
- function PaymentProvider({ session, connect, children, baseUrl, authToken }: PaymentContextProps) {
93
+ function PaymentProvider({
94
+ session,
95
+ connect,
96
+ children,
97
+ baseUrl = undefined,
98
+ authToken = undefined,
99
+ }: PaymentContextProps) {
94
100
  const [crossOriginLoading, setCrossOriginLoading] = useState(false);
95
101
 
96
102
  if (authToken) {
@@ -217,6 +223,4 @@ function usePaymentContext() {
217
223
  return context;
218
224
  }
219
225
 
220
- PaymentProvider.defaultProps = {};
221
-
222
226
  export { PaymentContext, PaymentProvider, Consumer as SettingsConsumer, usePaymentContext };
@@ -469,14 +469,22 @@ const InvoiceList = React.memo((props: Props & { onPay: (invoiceId: string) => v
469
469
  if (data && data.list.length === 0) {
470
470
  if (data.subscription && ['active', 'trialing'].includes(data.subscription.status)) {
471
471
  return (
472
- <Typography color="text.secondary" sx={{ my: 0.5 }}>
472
+ <Typography
473
+ sx={{
474
+ color: 'text.secondary',
475
+ my: 0.5,
476
+ }}>
473
477
  {t('payment.customer.invoice.next', { date: formatToDatetime(data.subscription.current_period_end * 1000) })}
474
478
  </Typography>
475
479
  );
476
480
  }
477
481
 
478
482
  return (
479
- <Typography color="text.secondary" sx={{ my: 0.5 }}>
483
+ <Typography
484
+ sx={{
485
+ color: 'text.secondary',
486
+ my: 0.5,
487
+ }}>
480
488
  {t('payment.customer.invoice.empty')}
481
489
  </Typography>
482
490
  );
@@ -502,21 +510,32 @@ const InvoiceList = React.memo((props: Props & { onPay: (invoiceId: string) => v
502
510
  <Stack
503
511
  key={invoice.id}
504
512
  direction="row"
505
- sx={{ my: 1 }}
506
- gap={{
507
- xs: 0.5,
508
- sm: 1.5,
509
- md: 3,
510
- }}
511
- alignItems="center"
512
- flexWrap="nowrap">
513
- <Box flex={2}>
513
+ sx={{
514
+ gap: {
515
+ xs: 0.5,
516
+ sm: 1.5,
517
+ md: 3,
518
+ },
519
+
520
+ alignItems: 'center',
521
+ flexWrap: 'nowrap',
522
+ my: 1,
523
+ }}>
524
+ <Box
525
+ sx={{
526
+ flex: 2,
527
+ }}>
514
528
  <a
515
529
  href={link.url}
516
530
  target={link.external ? '_blank' : target}
517
531
  rel="noreferrer"
518
532
  onClick={(e) => handleLinkClick(e, link)}>
519
- <Stack direction="row" alignItems="center" spacing={0.5}>
533
+ <Stack
534
+ direction="row"
535
+ spacing={0.5}
536
+ sx={{
537
+ alignItems: 'center',
538
+ }}>
520
539
  <Typography component="span">{invoice.number}</Typography>
521
540
  {link.external && (
522
541
  <OpenInNewOutlined
@@ -530,25 +549,39 @@ const InvoiceList = React.memo((props: Props & { onPay: (invoiceId: string) => v
530
549
  </Stack>
531
550
  </a>
532
551
  </Box>
533
- <Box flex={1} textAlign="right">
552
+ <Box
553
+ sx={{
554
+ flex: 1,
555
+ textAlign: 'right',
556
+ }}>
534
557
  <Typography sx={isVoid ? { textDecoration: 'line-through' } : {}}>
535
558
  {formatBNStr(invoice.total, invoice.paymentCurrency.decimal)}&nbsp;
536
559
  {invoice.paymentCurrency.symbol}
537
560
  </Typography>
538
561
  </Box>
539
- <Box flex={1} textAlign="right">
562
+ <Box
563
+ sx={{
564
+ flex: 1,
565
+ textAlign: 'right',
566
+ }}>
540
567
  <Typography>{formatToDate(invoice.created_at, locale, 'HH:mm:ss')}</Typography>
541
568
  </Box>
542
569
  {!action && (
543
570
  <Box
544
- flex={2}
545
571
  className="invoice-description"
546
- textAlign="right"
547
- sx={{ display: { xs: 'none', lg: 'inline-flex' } }}>
572
+ sx={{
573
+ flex: 2,
574
+ textAlign: 'right',
575
+ display: { xs: 'none', lg: 'inline-flex' },
576
+ }}>
548
577
  <Typography>{invoice.description || invoice.id}</Typography>
549
578
  </Box>
550
579
  )}
551
- <Box flex={1} textAlign="right">
580
+ <Box
581
+ sx={{
582
+ flex: 1,
583
+ textAlign: 'right',
584
+ }}>
552
585
  {action ? (
553
586
  connect ? (
554
587
  <Button
@@ -594,7 +627,10 @@ const InvoiceList = React.memo((props: Props & { onPay: (invoiceId: string) => v
594
627
  </Button>
595
628
  )}
596
629
  {!hasMore && data.count > size && (
597
- <Typography color="text.secondary">
630
+ <Typography
631
+ sx={{
632
+ color: 'text.secondary',
633
+ }}>
598
634
  {t('common.noMore', { resource: t('payment.customer.invoices') })}
599
635
  </Typography>
600
636
  )}
@@ -603,7 +639,25 @@ const InvoiceList = React.memo((props: Props & { onPay: (invoiceId: string) => v
603
639
  );
604
640
  });
605
641
 
606
- export default function CustomerInvoiceList(props: Props) {
642
+ export default function CustomerInvoiceList(rawProps: Props) {
643
+ const props = Object.assign(
644
+ {
645
+ customer_id: '',
646
+ subscription_id: '',
647
+ currency_id: '',
648
+ include_staking: false,
649
+ include_recovered_from: false,
650
+ status: 'open,paid,uncollectible',
651
+ pageSize: 10,
652
+ target: '_self',
653
+ action: '',
654
+ type: 'list',
655
+ onTableDataChange: () => {},
656
+ relatedSubscription: false,
657
+ },
658
+ rawProps
659
+ );
660
+ // eslint-disable-next-line react/prop-types
607
661
  const { action, type } = props;
608
662
  const { t, locale } = useLocaleContext();
609
663
  const { connect } = usePaymentContext();
@@ -649,21 +703,6 @@ export default function CustomerInvoiceList(props: Props) {
649
703
  return <InvoiceList {...props} onPay={onPay} />;
650
704
  }
651
705
 
652
- CustomerInvoiceList.defaultProps = {
653
- customer_id: '',
654
- subscription_id: '',
655
- currency_id: '',
656
- include_staking: false,
657
- include_recovered_from: false,
658
- status: 'open,paid,uncollectible',
659
- pageSize: 10,
660
- target: '_self',
661
- action: '',
662
- type: 'list',
663
- onTableDataChange: () => {},
664
- relatedSubscription: false,
665
- };
666
-
667
706
  const Root = styled(Stack)`
668
707
  @media (max-width: ${({ theme }) => theme.breakpoints.values.md}px) {
669
708
  svg.MuiSvgIcon-root {
@@ -53,7 +53,14 @@ export default function CustomerPaymentList({ customer_id }: Props) {
53
53
  }
54
54
 
55
55
  if (data && data.list.length === 0) {
56
- return <Typography color="text.secondary">{t('payment.customer.payment.empty')}</Typography>;
56
+ return (
57
+ <Typography
58
+ sx={{
59
+ color: 'text.secondary',
60
+ }}>
61
+ {t('payment.customer.payment.empty')}
62
+ </Typography>
63
+ );
57
64
  }
58
65
 
59
66
  const hasMore = data && data.list.length < data.count;
@@ -61,7 +68,12 @@ export default function CustomerPaymentList({ customer_id }: Props) {
61
68
  const grouped = groupByDate(data.list);
62
69
 
63
70
  return (
64
- <Stack direction="column" gap={1} sx={{ mt: 1 }}>
71
+ <Stack
72
+ direction="column"
73
+ sx={{
74
+ gap: 1,
75
+ mt: 1,
76
+ }}>
65
77
  {Object.entries(grouped).map(([date, payments]) => (
66
78
  <Box key={date}>
67
79
  <Typography sx={{ fontWeight: 'bold', color: 'text.secondary', mt: 2, mb: 1 }}>{date}</Typography>
@@ -72,29 +84,51 @@ export default function CustomerPaymentList({ customer_id }: Props) {
72
84
  xs: 'column',
73
85
  sm: 'row',
74
86
  }}
75
- sx={{ my: 1 }}
76
- gap={{
77
- xs: 0.5,
78
- sm: 1.5,
79
- md: 3,
80
- }}
81
- flexWrap="nowrap">
82
- <Box flex={3}>
87
+ sx={{
88
+ gap: {
89
+ xs: 0.5,
90
+ sm: 1.5,
91
+ md: 3,
92
+ },
93
+
94
+ flexWrap: 'nowrap',
95
+ my: 1,
96
+ }}>
97
+ <Box
98
+ sx={{
99
+ flex: 3,
100
+ }}>
83
101
  <Typography>{formatToDate(item.created_at)}</Typography>
84
102
  </Box>
85
- <Box flex={2}>
86
- <Typography textAlign="right">
103
+ <Box
104
+ sx={{
105
+ flex: 2,
106
+ }}>
107
+ <Typography
108
+ sx={{
109
+ textAlign: 'right',
110
+ }}>
87
111
  {formatBNStr(item.amount_received, item.paymentCurrency.decimal)}&nbsp;
88
112
  {item.paymentCurrency.symbol}
89
113
  </Typography>
90
114
  </Box>
91
- <Box flex={3}>
115
+ <Box
116
+ sx={{
117
+ flex: 3,
118
+ }}>
92
119
  <Status label={item.status} color={getPaymentIntentStatusColor(item.status)} />
93
120
  </Box>
94
- <Box flex={3}>
121
+ <Box
122
+ sx={{
123
+ flex: 3,
124
+ }}>
95
125
  <Typography>{item.description || '-'}</Typography>
96
126
  </Box>
97
- <Box flex={3} sx={{ minWidth: '220px' }}>
127
+ <Box
128
+ sx={{
129
+ flex: 3,
130
+ minWidth: '220px',
131
+ }}>
98
132
  {(item.payment_details?.arcblock?.tx_hash ||
99
133
  item.payment_details?.ethereum?.tx_hash ||
100
134
  item.payment_details?.base?.tx_hash) && (
@@ -114,7 +148,10 @@ export default function CustomerPaymentList({ customer_id }: Props) {
114
148
  </Button>
115
149
  )}
116
150
  {!hasMore && data.count > pageSize && (
117
- <Typography color="text.secondary">
151
+ <Typography
152
+ sx={{
153
+ color: 'text.secondary',
154
+ }}>
118
155
  {t('common.noMore', { resource: t('payment.customer.payments') })}
119
156
  </Typography>
120
157
  )}
@@ -14,7 +14,7 @@ type TabNavigationOptions<T> = {
14
14
  /** a selector to find navigable elements */
15
15
  selector?: string;
16
16
  /** an element container reference, limiting the query DOM range to improve performance */
17
- containerRef?: RefObject<HTMLElement>;
17
+ containerRef?: RefObject<HTMLElement | null>;
18
18
  /** the type of the current value, can be 'index' or 'value' */
19
19
  valueType?: 'index' | 'value';
20
20
  };
@@ -3,7 +3,7 @@ import type { TypographyProps } from '@mui/material';
3
3
 
4
4
  type Props = { amount: string } & TypographyProps;
5
5
 
6
- export default function PaymentAmount({ amount, sx }: Props) {
6
+ export default function PaymentAmount({ amount, sx = {} }: Props) {
7
7
  return (
8
8
  <Typography
9
9
  component="div"
@@ -19,8 +19,3 @@ export default function PaymentAmount({ amount, sx }: Props) {
19
19
  </Typography>
20
20
  );
21
21
  }
22
-
23
- PaymentAmount.defaultProps = {
24
- // eslint-disable-next-line react/default-props-match-prop-types
25
- sx: {},
26
- };
@@ -52,25 +52,19 @@ type Props = CheckoutContext &
52
52
  id: string;
53
53
  };
54
54
 
55
- PaymentInner.defaultProps = {
56
- completed: false,
57
- showCheckoutSummary: true,
58
- formRender: {},
59
- };
60
-
61
55
  function PaymentInner({
62
56
  checkoutSession,
63
57
  paymentMethods,
64
58
  paymentLink,
65
59
  paymentIntent,
66
60
  customer,
67
- completed,
61
+ completed = false,
68
62
  mode,
69
63
  onPaid,
70
64
  onError,
71
65
  onChange,
72
66
  action,
73
- formRender,
67
+ formRender = {},
74
68
  benefits,
75
69
  }: MainProps) {
76
70
  const { t } = useLocaleContext();
@@ -227,7 +221,14 @@ function PaymentInner({
227
221
  },
228
222
  }}
229
223
  />
230
- <Stack direction="row" justifyContent="flex-end" alignItems="center" flexWrap="wrap" gap={1}>
224
+ <Stack
225
+ direction="row"
226
+ sx={{
227
+ justifyContent: 'flex-end',
228
+ alignItems: 'center',
229
+ flexWrap: 'wrap',
230
+ gap: 1,
231
+ }}>
231
232
  <Button
232
233
  variant="outlined"
233
234
  size="large"
@@ -244,7 +245,13 @@ function PaymentInner({
244
245
  )}
245
246
 
246
247
  <Stack sx={{ display: benefitsState.open ? 'none' : 'block' }}>
247
- <Stack direction="row" justifyContent="space-between" alignItems="center" sx={{ mb: 2 }}>
248
+ <Stack
249
+ direction="row"
250
+ sx={{
251
+ justifyContent: 'space-between',
252
+ alignItems: 'center',
253
+ mb: 2,
254
+ }}>
248
255
  <Typography
249
256
  title={t('payment.checkout.orderSummary')}
250
257
  sx={{
@@ -311,7 +318,14 @@ function PaymentInner({
311
318
  },
312
319
  }}
313
320
  />
314
- <Stack direction="row" justifyContent="space-between" alignItems="center" flexWrap="wrap" gap={1}>
321
+ <Stack
322
+ direction="row"
323
+ sx={{
324
+ justifyContent: 'space-between',
325
+ alignItems: 'center',
326
+ flexWrap: 'wrap',
327
+ gap: 1,
328
+ }}>
315
329
  {benefits &&
316
330
  benefits.length > 0 &&
317
331
  (benefitsState.open ? (
@@ -331,18 +345,20 @@ function PaymentInner({
331
345
  </Typography>
332
346
  ) : (
333
347
  <Box
334
- display="flex"
335
- gap={0.5}
336
- alignItems="center"
337
348
  onClick={() => setBenefitsState({ open: true })}
338
349
  sx={{
350
+ display: 'flex',
351
+ gap: 0.5,
352
+ alignItems: 'center',
339
353
  color: 'text.secondary',
340
354
  cursor: 'pointer',
355
+
341
356
  '& .benefits-arrow': {
342
357
  opacity: 0,
343
358
  transform: 'translateX(-4px)',
344
359
  transition: 'all 0.2s',
345
360
  },
361
+
346
362
  '&:hover': {
347
363
  color: 'text.primary',
348
364
  '& .benefits-arrow': {
@@ -358,13 +374,15 @@ function PaymentInner({
358
374
  ))}
359
375
  {benefitsState.open ? null : (
360
376
  <Box
361
- display="flex"
362
- gap={2}
363
377
  sx={{
378
+ display: 'flex',
379
+ gap: 2,
380
+
364
381
  flex: {
365
382
  xs: 1,
366
383
  md: 'auto',
367
384
  },
385
+
368
386
  justifyContent: 'flex-end',
369
387
  whiteSpace: 'nowrap',
370
388
  }}>
@@ -408,21 +426,14 @@ function PaymentInner({
408
426
  );
409
427
  }
410
428
 
411
- DonationForm.defaultProps = {
412
- completed: false,
413
- error: null,
414
- showCheckoutSummary: true,
415
- formRender: {},
416
- };
417
-
418
429
  export default function DonationForm({
419
430
  checkoutSession,
420
431
  paymentMethods,
421
432
  paymentIntent,
422
433
  paymentLink,
423
434
  customer,
424
- completed,
425
- error,
435
+ completed = false,
436
+ error = null,
426
437
  mode,
427
438
  onPaid,
428
439
  onError,
@@ -430,7 +441,7 @@ export default function DonationForm({
430
441
  goBack,
431
442
  action,
432
443
  showCheckoutSummary = true,
433
- formRender,
444
+ formRender = {},
434
445
  id,
435
446
  }: Props) {
436
447
  const { t } = useLocaleContext();
@@ -473,7 +484,14 @@ export default function DonationForm({
473
484
  const footer = (
474
485
  <>
475
486
  <Divider sx={{ mt: { xs: '16px', md: '-24px' }, mb: { xs: '16px', md: '-16px' } }} />
476
- <Stack direction="row" justifyContent="flex-end" alignItems="center" flexWrap="wrap" gap={1}>
487
+ <Stack
488
+ direction="row"
489
+ sx={{
490
+ justifyContent: 'flex-end',
491
+ alignItems: 'center',
492
+ flexWrap: 'wrap',
493
+ gap: 1,
494
+ }}>
477
495
  <Button variant="outlined" size="large" onClick={formRender?.onCancel}>
478
496
  {t('common.cancel')}
479
497
  </Button>
@@ -540,9 +558,9 @@ export default function DonationForm({
540
558
 
541
559
  return (
542
560
  <Stack
543
- display="flex"
544
- flexDirection="column"
545
561
  sx={{
562
+ display: 'flex',
563
+ flexDirection: 'column',
546
564
  height: mode === 'standalone' ? '100vh' : 'auto',
547
565
  overflow: isMobileSafariEnv ? 'visible' : 'hidden',
548
566
  }}>
@@ -18,11 +18,24 @@ function getHeightStyle(mode: ModeType | undefined): any {
18
18
  return { height: 'auto', minHeight: 200 }; // 默认情况下,高度根据内容自动调整
19
19
  }
20
20
  }
21
- export default function PaymentError({ title, description, button, mode }: Props) {
21
+ export default function PaymentError({ title, description, button = 'Back', mode = 'standalone' }: Props) {
22
22
  const heightStyle = getHeightStyle(mode);
23
23
  return (
24
- <Stack sx={heightStyle} alignItems="center" justifyContent="center">
25
- <Stack sx={{ width: '280px' }} direction="column" alignItems="center" justifyContent="center">
24
+ <Stack
25
+ sx={[
26
+ {
27
+ alignItems: 'center',
28
+ justifyContent: 'center',
29
+ },
30
+ ...(Array.isArray(heightStyle) ? heightStyle : [heightStyle]),
31
+ ]}>
32
+ <Stack
33
+ direction="column"
34
+ sx={{
35
+ alignItems: 'center',
36
+ justifyContent: 'center',
37
+ width: '280px',
38
+ }}>
26
39
  <Typography variant="h5" sx={{ mb: 2 }}>
27
40
  {title}
28
41
  </Typography>
@@ -45,8 +58,3 @@ export default function PaymentError({ title, description, button, mode }: Props
45
58
  </Stack>
46
59
  );
47
60
  }
48
-
49
- PaymentError.defaultProps = {
50
- button: 'Back',
51
- mode: 'standalone',
52
- };
@@ -1,8 +1,16 @@
1
- import { Typography } from '@mui/material';
1
+ import { Typography, TypographyProps } from '@mui/material';
2
2
 
3
- export default function CheckoutFooter({ ...props }) {
3
+ export default function CheckoutFooter(props: TypographyProps) {
4
4
  return (
5
- <Typography color="text.lighter" fontSize={12} {...props}>
5
+ <Typography
6
+ {...props}
7
+ sx={[
8
+ {
9
+ color: 'text.lighter',
10
+ fontSize: 12,
11
+ },
12
+ ...(Array.isArray(props.sx) ? props.sx : [props.sx]),
13
+ ]}>
6
14
  Powered by{' '}
7
15
  <Typography component="span" sx={{ fontWeight: 'bold', fontSize: 12 }}>
8
16
  ArcBlock
@@ -10,7 +10,12 @@ export default function UserButtons() {
10
10
  const { session } = usePaymentContext();
11
11
 
12
12
  return (
13
- <Stack direction="row" alignItems="center" justifyContent="space-between">
13
+ <Stack
14
+ direction="row"
15
+ sx={{
16
+ alignItems: 'center',
17
+ justifyContent: 'space-between',
18
+ }}>
14
19
  <LocaleSelector showText={false} />
15
20
  {session?.user ? (
16
21
  <SessionManager session={session} />
@@ -14,13 +14,7 @@ type Props = {
14
14
  errorPosition?: 'right' | 'bottom';
15
15
  };
16
16
 
17
- AddressForm.defaultProps = {
18
- sx: {},
19
- fieldValidation: {},
20
- errorPosition: 'right',
21
- };
22
-
23
- export default function AddressForm({ mode, stripe, sx = {}, fieldValidation, errorPosition }: Props) {
17
+ export default function AddressForm({ mode, stripe, sx = {}, fieldValidation = {}, errorPosition = 'right' }: Props) {
24
18
  const { t, locale } = useLocaleContext();
25
19
  const { control } = useFormContext();
26
20
  const country = useWatch({ control, name: 'billing_address.country' });
@@ -85,6 +79,7 @@ export default function AddressForm({ mode, stripe, sx = {}, fieldValidation, er
85
79
  render={({ field }) => (
86
80
  <CountrySelect
87
81
  {...field}
82
+ ref={field.ref as unknown as React.RefObject<HTMLDivElement>}
88
83
  sx={{
89
84
  '&.Mui-focused .MuiOutlinedInput-notchedOutline': {
90
85
  borderColor: 'transparent',
@@ -132,6 +127,7 @@ export default function AddressForm({ mode, stripe, sx = {}, fieldValidation, er
132
127
  render={({ field }) => (
133
128
  <CountrySelect
134
129
  {...field}
130
+ ref={field.ref as unknown as React.RefObject<HTMLDivElement>}
135
131
  sx={{
136
132
  '.MuiOutlinedInput-notchedOutline': {
137
133
  borderColor: 'transparent !important',
@@ -27,7 +27,12 @@ export default function CurrencySelector({ value, currencies, onChange }: Props)
27
27
  variant="outlined"
28
28
  onClick={() => onChange(x.id, (x as any).method?.id)}
29
29
  className={selected ? 'cko-payment-card' : 'cko-payment-card-unselect'}>
30
- <Stack direction="row" alignItems="center" sx={{ position: 'relative' }}>
30
+ <Stack
31
+ direction="row"
32
+ sx={{
33
+ alignItems: 'center',
34
+ position: 'relative',
35
+ }}>
31
36
  <Avatar src={x.logo} alt={x.name} sx={{ width: 40, height: 40, marginRight: '12px' }} />
32
37
  <div>
33
38
  <Typography
@@ -36,7 +41,12 @@ export default function CurrencySelector({ value, currencies, onChange }: Props)
36
41
  sx={{ fontSize: '16px', color: 'text.primary', fontWeight: '500' }}>
37
42
  {x.symbol}
38
43
  </Typography>
39
- <Typography sx={{ fontSize: 14 }} color="text.lighter" gutterBottom>
44
+ <Typography
45
+ gutterBottom
46
+ sx={{
47
+ color: 'text.lighter',
48
+ fontSize: 14,
49
+ }}>
40
50
  {(x as any).method.name}
41
51
  </Typography>
42
52
  </div>