@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
@@ -34,24 +34,19 @@ const getBenefits = async (id, url) => {
34
34
  const { data } = await api.get(`/api/payment-links/${id}/benefits?${url ? `url=${url}` : ""}`);
35
35
  return data;
36
36
  };
37
- PaymentInner.defaultProps = {
38
- completed: false,
39
- showCheckoutSummary: true,
40
- formRender: {}
41
- };
42
37
  function PaymentInner({
43
38
  checkoutSession,
44
39
  paymentMethods,
45
40
  paymentLink,
46
41
  paymentIntent,
47
42
  customer,
48
- completed,
43
+ completed = false,
49
44
  mode,
50
45
  onPaid,
51
46
  onError,
52
47
  onChange,
53
48
  action,
54
- formRender,
49
+ formRender = {},
55
50
  benefits
56
51
  }) {
57
52
  const { t } = useLocaleContext();
@@ -193,69 +188,92 @@ function PaymentInner({
193
188
  }
194
189
  }
195
190
  ),
196
- /* @__PURE__ */ jsx(Stack, { direction: "row", justifyContent: "flex-end", alignItems: "center", flexWrap: "wrap", gap: 1, children: /* @__PURE__ */ jsx(
197
- Button,
191
+ /* @__PURE__ */ jsx(
192
+ Stack,
198
193
  {
199
- variant: "outlined",
200
- size: "large",
201
- onClick: formRender?.onCancel,
202
- sx: { width: "fit-content", minWidth: 120 },
203
- children: t("common.close")
194
+ direction: "row",
195
+ sx: {
196
+ justifyContent: "flex-end",
197
+ alignItems: "center",
198
+ flexWrap: "wrap",
199
+ gap: 1
200
+ },
201
+ children: /* @__PURE__ */ jsx(
202
+ Button,
203
+ {
204
+ variant: "outlined",
205
+ size: "large",
206
+ onClick: formRender?.onCancel,
207
+ sx: { width: "fit-content", minWidth: 120 },
208
+ children: t("common.close")
209
+ }
210
+ )
204
211
  }
205
- ) })
212
+ )
206
213
  ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
207
214
  benefitsState.open && /* @__PURE__ */ jsx(PaymentBeneficiaries, { data: benefits, currency, totalAmount: benefitsState.amount }),
208
215
  /* @__PURE__ */ jsxs(Stack, { sx: { display: benefitsState.open ? "none" : "block" }, children: [
209
- /* @__PURE__ */ jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { mb: 2 }, children: [
210
- /* @__PURE__ */ jsx(
211
- Typography,
212
- {
213
- title: t("payment.checkout.orderSummary"),
214
- sx: {
215
- color: "text.primary",
216
- fontSize: "18px",
217
- fontWeight: "500",
218
- lineHeight: "24px"
219
- },
220
- children: t("payment.checkout.donation.tipAmount")
221
- }
222
- ),
223
- !isMobile && donationSettings?.amount?.presets && donationSettings.amount.presets.length > 0 && /* @__PURE__ */ jsxs(
224
- Typography,
225
- {
226
- sx: {
227
- color: "text.secondary",
228
- fontSize: "13px",
229
- display: "flex",
230
- alignItems: "center",
231
- gap: 0.5,
232
- opacity: 0.8
233
- },
234
- children: [
235
- /* @__PURE__ */ jsx(
236
- Box,
237
- {
238
- component: "span",
239
- sx: {
240
- border: "1px solid",
241
- borderColor: "divider",
242
- borderRadius: 0.75,
243
- px: 0.75,
244
- py: 0.25,
245
- fontSize: "12px",
246
- lineHeight: 1,
247
- color: "text.secondary",
248
- fontWeight: "400",
249
- bgcolor: "transparent"
250
- },
251
- children: "Tab"
252
- }
253
- ),
254
- t("payment.checkout.donation.tabHint")
255
- ]
256
- }
257
- )
258
- ] }),
216
+ /* @__PURE__ */ jsxs(
217
+ Stack,
218
+ {
219
+ direction: "row",
220
+ sx: {
221
+ justifyContent: "space-between",
222
+ alignItems: "center",
223
+ mb: 2
224
+ },
225
+ children: [
226
+ /* @__PURE__ */ jsx(
227
+ Typography,
228
+ {
229
+ title: t("payment.checkout.orderSummary"),
230
+ sx: {
231
+ color: "text.primary",
232
+ fontSize: "18px",
233
+ fontWeight: "500",
234
+ lineHeight: "24px"
235
+ },
236
+ children: t("payment.checkout.donation.tipAmount")
237
+ }
238
+ ),
239
+ !isMobile && donationSettings?.amount?.presets && donationSettings.amount.presets.length > 0 && /* @__PURE__ */ jsxs(
240
+ Typography,
241
+ {
242
+ sx: {
243
+ color: "text.secondary",
244
+ fontSize: "13px",
245
+ display: "flex",
246
+ alignItems: "center",
247
+ gap: 0.5,
248
+ opacity: 0.8
249
+ },
250
+ children: [
251
+ /* @__PURE__ */ jsx(
252
+ Box,
253
+ {
254
+ component: "span",
255
+ sx: {
256
+ border: "1px solid",
257
+ borderColor: "divider",
258
+ borderRadius: 0.75,
259
+ px: 0.75,
260
+ py: 0.25,
261
+ fontSize: "12px",
262
+ lineHeight: 1,
263
+ color: "text.secondary",
264
+ fontWeight: "400",
265
+ bgcolor: "transparent"
266
+ },
267
+ children: "Tab"
268
+ }
269
+ ),
270
+ t("payment.checkout.donation.tabHint")
271
+ ]
272
+ }
273
+ )
274
+ ]
275
+ }
276
+ ),
259
277
  items.map((x) => /* @__PURE__ */ jsx(
260
278
  ProductDonation,
261
279
  {
@@ -282,91 +300,103 @@ function PaymentInner({
282
300
  }
283
301
  }
284
302
  ),
285
- /* @__PURE__ */ jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", flexWrap: "wrap", gap: 1, children: [
286
- benefits && benefits.length > 0 && (benefitsState.open ? /* @__PURE__ */ jsxs(
287
- Typography,
288
- {
289
- onClick: () => setBenefitsState({ open: false }),
290
- sx: {
291
- cursor: "pointer",
292
- color: "text.secondary",
293
- "&:hover": {
294
- color: "text.primary"
295
- },
296
- display: "flex",
297
- alignItems: "center"
298
- },
299
- children: [
300
- /* @__PURE__ */ jsx(ArrowBackOutlined, { className: "benefits-arrow", sx: { fontSize: "18px", mr: 0.5 } }),
301
- t("common.back")
302
- ]
303
- }
304
- ) : /* @__PURE__ */ jsxs(
305
- Box,
306
- {
307
- display: "flex",
308
- gap: 0.5,
303
+ /* @__PURE__ */ jsxs(
304
+ Stack,
305
+ {
306
+ direction: "row",
307
+ sx: {
308
+ justifyContent: "space-between",
309
309
  alignItems: "center",
310
- onClick: () => setBenefitsState({ open: true }),
311
- sx: {
312
- color: "text.secondary",
313
- cursor: "pointer",
314
- "& .benefits-arrow": {
315
- opacity: 0,
316
- transform: "translateX(-4px)",
317
- transition: "all 0.2s"
318
- },
319
- "&:hover": {
320
- color: "text.primary",
321
- "& .benefits-arrow": {
322
- opacity: 1,
323
- transform: "translateX(0)"
324
- }
310
+ flexWrap: "wrap",
311
+ gap: 1
312
+ },
313
+ children: [
314
+ benefits && benefits.length > 0 && (benefitsState.open ? /* @__PURE__ */ jsxs(
315
+ Typography,
316
+ {
317
+ onClick: () => setBenefitsState({ open: false }),
318
+ sx: {
319
+ cursor: "pointer",
320
+ color: "text.secondary",
321
+ "&:hover": {
322
+ color: "text.primary"
323
+ },
324
+ display: "flex",
325
+ alignItems: "center"
326
+ },
327
+ children: [
328
+ /* @__PURE__ */ jsx(ArrowBackOutlined, { className: "benefits-arrow", sx: { fontSize: "18px", mr: 0.5 } }),
329
+ t("common.back")
330
+ ]
325
331
  }
326
- },
327
- children: [
328
- /* @__PURE__ */ jsx(HelpOutlineOutlined, { sx: { fontSize: "18px" } }),
329
- /* @__PURE__ */ jsx(Typography, { variant: "body2", children: renderBenefits() }),
330
- /* @__PURE__ */ jsx(ArrowForwardOutlined, { className: "benefits-arrow", sx: { fontSize: "18px" } })
331
- ]
332
- }
333
- )),
334
- benefitsState.open ? null : /* @__PURE__ */ jsxs(
335
- Box,
336
- {
337
- display: "flex",
338
- gap: 2,
339
- sx: {
340
- flex: {
341
- xs: 1,
342
- md: "auto"
343
- },
344
- justifyContent: "flex-end",
345
- whiteSpace: "nowrap"
346
- },
347
- children: [
348
- formRender?.cancel,
349
- /* @__PURE__ */ jsx(
350
- PaymentForm,
351
- {
352
- currencyId,
353
- checkoutSession: state.checkoutSession,
354
- paymentMethods,
355
- paymentIntent,
356
- paymentLink,
357
- customer,
358
- onPaid: handlePaid,
359
- onError,
360
- mode,
361
- action,
362
- onlyShowBtn: true,
363
- isDonation: true
364
- }
365
- )
366
- ]
367
- }
368
- )
369
- ] })
332
+ ) : /* @__PURE__ */ jsxs(
333
+ Box,
334
+ {
335
+ onClick: () => setBenefitsState({ open: true }),
336
+ sx: {
337
+ display: "flex",
338
+ gap: 0.5,
339
+ alignItems: "center",
340
+ color: "text.secondary",
341
+ cursor: "pointer",
342
+ "& .benefits-arrow": {
343
+ opacity: 0,
344
+ transform: "translateX(-4px)",
345
+ transition: "all 0.2s"
346
+ },
347
+ "&:hover": {
348
+ color: "text.primary",
349
+ "& .benefits-arrow": {
350
+ opacity: 1,
351
+ transform: "translateX(0)"
352
+ }
353
+ }
354
+ },
355
+ children: [
356
+ /* @__PURE__ */ jsx(HelpOutlineOutlined, { sx: { fontSize: "18px" } }),
357
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", children: renderBenefits() }),
358
+ /* @__PURE__ */ jsx(ArrowForwardOutlined, { className: "benefits-arrow", sx: { fontSize: "18px" } })
359
+ ]
360
+ }
361
+ )),
362
+ benefitsState.open ? null : /* @__PURE__ */ jsxs(
363
+ Box,
364
+ {
365
+ sx: {
366
+ display: "flex",
367
+ gap: 2,
368
+ flex: {
369
+ xs: 1,
370
+ md: "auto"
371
+ },
372
+ justifyContent: "flex-end",
373
+ whiteSpace: "nowrap"
374
+ },
375
+ children: [
376
+ formRender?.cancel,
377
+ /* @__PURE__ */ jsx(
378
+ PaymentForm,
379
+ {
380
+ currencyId,
381
+ checkoutSession: state.checkoutSession,
382
+ paymentMethods,
383
+ paymentIntent,
384
+ paymentLink,
385
+ customer,
386
+ onPaid: handlePaid,
387
+ onError,
388
+ mode,
389
+ action,
390
+ onlyShowBtn: true,
391
+ isDonation: true
392
+ }
393
+ )
394
+ ]
395
+ }
396
+ )
397
+ ]
398
+ }
399
+ )
370
400
  ] }),
371
401
  state.customerLimited && /* @__PURE__ */ jsx(
372
402
  ConfirmDialog,
@@ -384,20 +414,14 @@ function PaymentInner({
384
414
  )
385
415
  ] }) });
386
416
  }
387
- DonationForm.defaultProps = {
388
- completed: false,
389
- error: null,
390
- showCheckoutSummary: true,
391
- formRender: {}
392
- };
393
417
  export default function DonationForm({
394
418
  checkoutSession,
395
419
  paymentMethods,
396
420
  paymentIntent,
397
421
  paymentLink,
398
422
  customer,
399
- completed,
400
- error,
423
+ completed = false,
424
+ error = null,
401
425
  mode,
402
426
  onPaid,
403
427
  onError,
@@ -405,7 +429,7 @@ export default function DonationForm({
405
429
  goBack,
406
430
  action,
407
431
  showCheckoutSummary = true,
408
- formRender,
432
+ formRender = {},
409
433
  id
410
434
  }) {
411
435
  const { t } = useLocaleContext();
@@ -441,7 +465,19 @@ export default function DonationForm({
441
465
  const renderContent = () => {
442
466
  const footer = /* @__PURE__ */ jsxs(Fragment, { children: [
443
467
  /* @__PURE__ */ jsx(Divider, { sx: { mt: { xs: "16px", md: "-24px" }, mb: { xs: "16px", md: "-16px" } } }),
444
- /* @__PURE__ */ jsx(Stack, { direction: "row", justifyContent: "flex-end", alignItems: "center", flexWrap: "wrap", gap: 1, children: /* @__PURE__ */ jsx(Button, { variant: "outlined", size: "large", onClick: formRender?.onCancel, children: t("common.cancel") }) })
468
+ /* @__PURE__ */ jsx(
469
+ Stack,
470
+ {
471
+ direction: "row",
472
+ sx: {
473
+ justifyContent: "flex-end",
474
+ alignItems: "center",
475
+ flexWrap: "wrap",
476
+ gap: 1
477
+ },
478
+ children: /* @__PURE__ */ jsx(Button, { variant: "outlined", size: "large", onClick: formRender?.onCancel, children: t("common.cancel") })
479
+ }
480
+ )
445
481
  ] });
446
482
  if (error) {
447
483
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -504,9 +540,9 @@ export default function DonationForm({
504
540
  return /* @__PURE__ */ jsxs(
505
541
  Stack,
506
542
  {
507
- display: "flex",
508
- flexDirection: "column",
509
543
  sx: {
544
+ display: "flex",
545
+ flexDirection: "column",
510
546
  height: mode === "standalone" ? "100vh" : "auto",
511
547
  overflow: isMobileSafariEnv ? "visible" : "hidden"
512
548
  },
@@ -6,11 +6,5 @@ type Props = {
6
6
  button?: string | React.ReactNode;
7
7
  mode?: ModeType;
8
8
  };
9
- declare function PaymentError({ title, description, button, mode }: Props): import("react").JSX.Element;
10
- declare namespace PaymentError {
11
- var defaultProps: {
12
- button: string;
13
- mode: string;
14
- };
15
- }
16
- export default PaymentError;
9
+ export default function PaymentError({ title, description, button, mode }: Props): import("react").JSX.Element;
10
+ export {};
@@ -4,29 +4,49 @@ function getHeightStyle(mode) {
4
4
  switch (mode) {
5
5
  case "standalone":
6
6
  return { height: "100vh", maxHeight: "100%" };
7
+ // 独立模式下,高度为100vh
7
8
  default:
8
9
  return { height: "auto", minHeight: 200 };
9
10
  }
10
11
  }
11
- export default function PaymentError({ title, description, button, mode }) {
12
+ export default function PaymentError({ title, description, button = "Back", mode = "standalone" }) {
12
13
  const heightStyle = getHeightStyle(mode);
13
- return /* @__PURE__ */ jsx(Stack, { sx: heightStyle, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsxs(Stack, { sx: { width: "280px" }, direction: "column", alignItems: "center", justifyContent: "center", children: [
14
- /* @__PURE__ */ jsx(Typography, { variant: "h5", sx: { mb: 2 }, children: title }),
15
- /* @__PURE__ */ jsx(Typography, { variant: "body1", sx: { mb: 2, textAlign: "center" }, children: description }),
16
- typeof button === "string" ? /* @__PURE__ */ jsx(
17
- Button,
18
- {
19
- variant: "text",
20
- size: "small",
21
- sx: { color: "text.link" },
22
- component: Link,
23
- href: window.blocklet?.appUrl,
24
- children: button
25
- }
26
- ) : button
27
- ] }) });
14
+ return /* @__PURE__ */ jsx(
15
+ Stack,
16
+ {
17
+ sx: [
18
+ {
19
+ alignItems: "center",
20
+ justifyContent: "center"
21
+ },
22
+ ...Array.isArray(heightStyle) ? heightStyle : [heightStyle]
23
+ ],
24
+ children: /* @__PURE__ */ jsxs(
25
+ Stack,
26
+ {
27
+ direction: "column",
28
+ sx: {
29
+ alignItems: "center",
30
+ justifyContent: "center",
31
+ width: "280px"
32
+ },
33
+ children: [
34
+ /* @__PURE__ */ jsx(Typography, { variant: "h5", sx: { mb: 2 }, children: title }),
35
+ /* @__PURE__ */ jsx(Typography, { variant: "body1", sx: { mb: 2, textAlign: "center" }, children: description }),
36
+ typeof button === "string" ? /* @__PURE__ */ jsx(
37
+ Button,
38
+ {
39
+ variant: "text",
40
+ size: "small",
41
+ sx: { color: "text.link" },
42
+ component: Link,
43
+ href: window.blocklet?.appUrl,
44
+ children: button
45
+ }
46
+ ) : button
47
+ ]
48
+ }
49
+ )
50
+ }
51
+ );
28
52
  }
29
- PaymentError.defaultProps = {
30
- button: "Back",
31
- mode: "standalone"
32
- };
@@ -1,3 +1,2 @@
1
- export default function CheckoutFooter({ ...props }: {
2
- [x: string]: any;
3
- }): import("react").JSX.Element;
1
+ import { TypographyProps } from '@mui/material';
2
+ export default function CheckoutFooter(props: TypographyProps): import("react").JSX.Element;
@@ -1,9 +1,22 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Typography } from "@mui/material";
3
- export default function CheckoutFooter({ ...props }) {
4
- return /* @__PURE__ */ jsxs(Typography, { color: "text.lighter", fontSize: 12, ...props, children: [
5
- "Powered by",
6
- " ",
7
- /* @__PURE__ */ jsx(Typography, { component: "span", sx: { fontWeight: "bold", fontSize: 12 }, children: "ArcBlock" })
8
- ] });
3
+ export default function CheckoutFooter(props) {
4
+ return /* @__PURE__ */ jsxs(
5
+ Typography,
6
+ {
7
+ ...props,
8
+ sx: [
9
+ {
10
+ color: "text.lighter",
11
+ fontSize: 12
12
+ },
13
+ ...Array.isArray(props.sx) ? props.sx : [props.sx]
14
+ ],
15
+ children: [
16
+ "Powered by",
17
+ " ",
18
+ /* @__PURE__ */ jsx(Typography, { component: "span", sx: { fontWeight: "bold", fontSize: 12 }, children: "ArcBlock" })
19
+ ]
20
+ }
21
+ );
9
22
  }
@@ -7,8 +7,18 @@ import { usePaymentContext } from "../../contexts/payment.js";
7
7
  export default function UserButtons() {
8
8
  const { t } = useLocaleContext();
9
9
  const { session } = usePaymentContext();
10
- return /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", justifyContent: "space-between", children: [
11
- /* @__PURE__ */ jsx(LocaleSelector, { showText: false }),
12
- session?.user ? /* @__PURE__ */ jsx(SessionManager, { session }) : /* @__PURE__ */ jsx(Tooltip, { title: t("payment.checkout.login"), arrow: true, children: /* @__PURE__ */ jsx(SessionManager, { session }) })
13
- ] });
10
+ return /* @__PURE__ */ jsxs(
11
+ Stack,
12
+ {
13
+ direction: "row",
14
+ sx: {
15
+ alignItems: "center",
16
+ justifyContent: "space-between"
17
+ },
18
+ children: [
19
+ /* @__PURE__ */ jsx(LocaleSelector, { showText: false }),
20
+ session?.user ? /* @__PURE__ */ jsx(SessionManager, { session }) : /* @__PURE__ */ jsx(Tooltip, { title: t("payment.checkout.login"), arrow: true, children: /* @__PURE__ */ jsx(SessionManager, { session }) })
21
+ ]
22
+ }
23
+ );
14
24
  }
@@ -6,12 +6,5 @@ type Props = {
6
6
  fieldValidation?: Record<string, any>;
7
7
  errorPosition?: 'right' | 'bottom';
8
8
  };
9
- declare function AddressForm({ mode, stripe, sx, fieldValidation, errorPosition }: Props): import("react").JSX.Element | null;
10
- declare namespace AddressForm {
11
- var defaultProps: {
12
- sx: {};
13
- fieldValidation: {};
14
- errorPosition: string;
15
- };
16
- }
17
- export default AddressForm;
9
+ export default function AddressForm({ mode, stripe, sx, fieldValidation, errorPosition }: Props): import("react").JSX.Element | null;
10
+ export {};
@@ -5,12 +5,7 @@ import { Controller, useFormContext, useWatch } from "react-hook-form";
5
5
  import FormInput from "../../components/input.js";
6
6
  import CountrySelect from "../../components/country-select.js";
7
7
  import { getFieldValidation, validatePostalCode } from "../../libs/validator.js";
8
- AddressForm.defaultProps = {
9
- sx: {},
10
- fieldValidation: {},
11
- errorPosition: "right"
12
- };
13
- export default function AddressForm({ mode, stripe, sx = {}, fieldValidation, errorPosition }) {
8
+ export default function AddressForm({ mode, stripe, sx = {}, fieldValidation = {}, errorPosition = "right" }) {
14
9
  const { t, locale } = useLocaleContext();
15
10
  const { control } = useFormContext();
16
11
  const country = useWatch({ control, name: "billing_address.country" });
@@ -84,6 +79,7 @@ export default function AddressForm({ mode, stripe, sx = {}, fieldValidation, er
84
79
  CountrySelect,
85
80
  {
86
81
  ...field,
82
+ ref: field.ref,
87
83
  sx: {
88
84
  "&.Mui-focused .MuiOutlinedInput-notchedOutline": {
89
85
  borderColor: "transparent"
@@ -126,6 +122,7 @@ export default function AddressForm({ mode, stripe, sx = {}, fieldValidation, er
126
122
  CountrySelect,
127
123
  {
128
124
  ...field,
125
+ ref: field.ref,
129
126
  sx: {
130
127
  ".MuiOutlinedInput-notchedOutline": {
131
128
  borderColor: "transparent !important"