@blocklet/payment-react 1.18.56 → 1.19.1

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 (251) 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 +29 -10
  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/date-range-picker.d.ts +13 -0
  15. package/es/components/date-range-picker.js +279 -0
  16. package/es/components/input.d.ts +14 -20
  17. package/es/components/input.js +51 -44
  18. package/es/components/label.d.ts +7 -0
  19. package/es/components/label.js +49 -0
  20. package/es/components/lazy-loader.js +1 -2
  21. package/es/components/link.d.ts +2 -9
  22. package/es/components/link.js +9 -6
  23. package/es/components/livemode.d.ts +2 -8
  24. package/es/components/livemode.js +1 -5
  25. package/es/components/loading-button.d.ts +6 -1
  26. package/es/components/loading-button.js +56 -66
  27. package/es/components/over-due-invoice-payment.d.ts +0 -18
  28. package/es/components/over-due-invoice-payment.js +138 -95
  29. package/es/components/payment-beneficiaries.d.ts +2 -7
  30. package/es/components/payment-beneficiaries.js +86 -40
  31. package/es/components/pricing-item.d.ts +0 -5
  32. package/es/components/pricing-item.js +1 -4
  33. package/es/components/pricing-table.d.ts +2 -10
  34. package/es/components/pricing-table.js +8 -7
  35. package/es/components/resume-subscription.d.ts +0 -10
  36. package/es/components/resume-subscription.js +42 -21
  37. package/es/components/truncated-text.d.ts +2 -9
  38. package/es/components/truncated-text.js +0 -5
  39. package/es/contexts/donate.d.ts +0 -7
  40. package/es/contexts/donate.js +10 -8
  41. package/es/contexts/payment.d.ts +1 -4
  42. package/es/contexts/payment.js +7 -2
  43. package/es/history/credit/grants-list.d.ts +14 -0
  44. package/es/history/credit/grants-list.js +215 -0
  45. package/es/history/credit/transactions-list.d.ts +13 -0
  46. package/es/history/credit/transactions-list.js +255 -0
  47. package/es/history/invoice/list.d.ts +2 -18
  48. package/es/history/invoice/list.js +172 -74
  49. package/es/history/payment/list.js +115 -38
  50. package/es/hooks/keyboard.d.ts +1 -1
  51. package/es/hooks/keyboard.js +2 -4
  52. package/es/index.d.ts +5 -1
  53. package/es/index.js +10 -1
  54. package/es/libs/cached-request.js +2 -4
  55. package/es/libs/phone-validator.js +1 -2
  56. package/es/libs/util.d.ts +2 -0
  57. package/es/libs/util.js +14 -4
  58. package/es/libs/validator.js +2 -4
  59. package/es/locales/en.js +20 -2
  60. package/es/locales/zh.js +20 -2
  61. package/es/payment/amount.d.ts +2 -7
  62. package/es/payment/amount.js +1 -5
  63. package/es/payment/donation-form.d.ts +2 -10
  64. package/es/payment/donation-form.js +196 -160
  65. package/es/payment/error.d.ts +2 -8
  66. package/es/payment/error.js +40 -20
  67. package/es/payment/footer.d.ts +2 -3
  68. package/es/payment/footer.js +19 -6
  69. package/es/payment/form/addon.js +14 -4
  70. package/es/payment/form/address.d.ts +2 -9
  71. package/es/payment/form/address.js +3 -6
  72. package/es/payment/form/currency.js +45 -25
  73. package/es/payment/form/index.d.ts +2 -8
  74. package/es/payment/form/index.js +151 -71
  75. package/es/payment/form/phone.js +2 -4
  76. package/es/payment/form/stripe/form.d.ts +2 -8
  77. package/es/payment/form/stripe/form.js +1 -3
  78. package/es/payment/header.js +38 -16
  79. package/es/payment/index.d.ts +2 -9
  80. package/es/payment/index.js +23 -17
  81. package/es/payment/product-card.d.ts +2 -11
  82. package/es/payment/product-card.js +84 -50
  83. package/es/payment/product-donation.js +175 -114
  84. package/es/payment/product-item.d.ts +9 -9
  85. package/es/payment/product-item.js +320 -145
  86. package/es/payment/product-skeleton.js +2 -2
  87. package/es/payment/skeleton/donation.js +27 -7
  88. package/es/payment/skeleton/overview.js +22 -2
  89. package/es/payment/skeleton/payment.js +33 -5
  90. package/es/payment/success.d.ts +2 -9
  91. package/es/payment/success.js +41 -14
  92. package/es/payment/summary.d.ts +4 -17
  93. package/es/payment/summary.js +193 -111
  94. package/es/theme/index.d.ts +0 -5
  95. package/es/theme/index.js +2 -5
  96. package/es/theme/typography.d.ts +2 -2
  97. package/lib/checkout/donate.d.ts +1 -15
  98. package/lib/checkout/donate.js +75 -54
  99. package/lib/checkout/form.d.ts +1 -15
  100. package/lib/checkout/form.js +7 -15
  101. package/lib/checkout/table.js +4 -4
  102. package/lib/components/blockchain/gas.d.ts +1 -5
  103. package/lib/components/blockchain/gas.js +3 -2
  104. package/lib/components/blockchain/tx.d.ts +1 -8
  105. package/lib/components/blockchain/tx.js +15 -10
  106. package/lib/components/confirm.d.ts +1 -10
  107. package/lib/components/confirm.js +5 -11
  108. package/lib/components/country-select.d.ts +3 -2
  109. package/lib/components/country-select.js +23 -22
  110. package/lib/components/date-range-picker.d.ts +13 -0
  111. package/lib/components/date-range-picker.js +329 -0
  112. package/lib/components/input.d.ts +14 -20
  113. package/lib/components/input.js +28 -27
  114. package/lib/components/label.d.ts +7 -0
  115. package/lib/components/label.js +60 -0
  116. package/lib/components/lazy-loader.js +1 -1
  117. package/lib/components/link.d.ts +2 -9
  118. package/lib/components/link.js +3 -8
  119. package/lib/components/livemode.d.ts +2 -8
  120. package/lib/components/livemode.js +3 -7
  121. package/lib/components/loading-button.d.ts +6 -1
  122. package/lib/components/loading-button.js +9 -17
  123. package/lib/components/over-due-invoice-payment.d.ts +0 -18
  124. package/lib/components/over-due-invoice-payment.js +31 -33
  125. package/lib/components/payment-beneficiaries.d.ts +2 -7
  126. package/lib/components/payment-beneficiaries.js +12 -11
  127. package/lib/components/pricing-item.d.ts +0 -5
  128. package/lib/components/pricing-item.js +2 -5
  129. package/lib/components/pricing-table.d.ts +2 -10
  130. package/lib/components/pricing-table.js +5 -11
  131. package/lib/components/resume-subscription.d.ts +0 -10
  132. package/lib/components/resume-subscription.js +16 -16
  133. package/lib/components/table.js +1 -1
  134. package/lib/components/truncated-text.d.ts +2 -9
  135. package/lib/components/truncated-text.js +1 -6
  136. package/lib/contexts/donate.d.ts +0 -7
  137. package/lib/contexts/donate.js +4 -7
  138. package/lib/contexts/payment.d.ts +1 -4
  139. package/lib/contexts/payment.js +4 -7
  140. package/lib/history/credit/grants-list.d.ts +14 -0
  141. package/lib/history/credit/grants-list.js +277 -0
  142. package/lib/history/credit/transactions-list.d.ts +13 -0
  143. package/lib/history/credit/transactions-list.js +301 -0
  144. package/lib/history/invoice/list.d.ts +2 -18
  145. package/lib/history/invoice/list.js +73 -37
  146. package/lib/history/payment/list.js +30 -16
  147. package/lib/hooks/keyboard.d.ts +1 -1
  148. package/lib/hooks/mobile.js +1 -1
  149. package/lib/hooks/subscription.js +1 -1
  150. package/lib/index.d.ts +5 -1
  151. package/lib/index.js +41 -2
  152. package/lib/libs/api.js +1 -1
  153. package/lib/libs/dayjs.js +1 -1
  154. package/lib/libs/phone-validator.js +0 -2
  155. package/lib/libs/theme.js +1 -1
  156. package/lib/libs/util.d.ts +2 -0
  157. package/lib/libs/util.js +15 -1
  158. package/lib/libs/validator.js +1 -1
  159. package/lib/locales/en.js +21 -3
  160. package/lib/locales/index.js +1 -1
  161. package/lib/locales/zh.js +21 -3
  162. package/lib/payment/amount.d.ts +2 -7
  163. package/lib/payment/amount.js +2 -6
  164. package/lib/payment/donation-form.d.ts +2 -10
  165. package/lib/payment/donation-form.js +33 -38
  166. package/lib/payment/error.d.ts +2 -8
  167. package/lib/payment/error.js +11 -13
  168. package/lib/payment/footer.d.ts +2 -3
  169. package/lib/payment/footer.js +5 -5
  170. package/lib/payment/form/addon.js +5 -3
  171. package/lib/payment/form/address.d.ts +2 -9
  172. package/lib/payment/form/address.js +5 -8
  173. package/lib/payment/form/currency.js +3 -3
  174. package/lib/payment/form/index.d.ts +2 -8
  175. package/lib/payment/form/index.js +64 -21
  176. package/lib/payment/form/phone.js +1 -1
  177. package/lib/payment/form/stripe/form.d.ts +2 -8
  178. package/lib/payment/form/stripe/form.js +3 -6
  179. package/lib/payment/header.js +8 -4
  180. package/lib/payment/index.d.ts +2 -9
  181. package/lib/payment/index.js +27 -18
  182. package/lib/payment/product-card.d.ts +2 -11
  183. package/lib/payment/product-card.js +13 -20
  184. package/lib/payment/product-donation.js +71 -66
  185. package/lib/payment/product-item.d.ts +9 -9
  186. package/lib/payment/product-item.js +168 -29
  187. package/lib/payment/product-skeleton.js +2 -2
  188. package/lib/payment/skeleton/donation.js +8 -4
  189. package/lib/payment/skeleton/overview.js +6 -2
  190. package/lib/payment/skeleton/payment.js +9 -3
  191. package/lib/payment/success.d.ts +2 -9
  192. package/lib/payment/success.js +12 -15
  193. package/lib/payment/summary.d.ts +4 -17
  194. package/lib/payment/summary.js +53 -45
  195. package/lib/theme/index.d.ts +0 -5
  196. package/lib/theme/index.js +2 -5
  197. package/lib/theme/typography.d.ts +2 -2
  198. package/package.json +40 -40
  199. package/src/checkout/donate.tsx +103 -35
  200. package/src/checkout/form.tsx +5 -14
  201. package/src/checkout/table.tsx +3 -3
  202. package/src/components/blockchain/gas.tsx +5 -3
  203. package/src/components/blockchain/tx.tsx +19 -11
  204. package/src/components/confirm.tsx +4 -11
  205. package/src/components/country-select.tsx +391 -378
  206. package/src/components/date-range-picker.tsx +310 -0
  207. package/src/components/input.tsx +61 -46
  208. package/src/components/label.tsx +58 -0
  209. package/src/components/link.tsx +9 -7
  210. package/src/components/livemode.tsx +2 -6
  211. package/src/components/loading-button.tsx +63 -76
  212. package/src/components/over-due-invoice-payment.tsx +43 -28
  213. package/src/components/payment-beneficiaries.tsx +33 -14
  214. package/src/components/pricing-item.tsx +1 -4
  215. package/src/components/pricing-table.tsx +8 -8
  216. package/src/components/resume-subscription.tsx +20 -14
  217. package/src/components/table.tsx +2 -2
  218. package/src/components/truncated-text.tsx +0 -6
  219. package/src/contexts/donate.tsx +6 -7
  220. package/src/contexts/payment.tsx +7 -3
  221. package/src/history/credit/grants-list.tsx +276 -0
  222. package/src/history/credit/transactions-list.tsx +317 -0
  223. package/src/history/invoice/list.tsx +92 -36
  224. package/src/history/payment/list.tsx +53 -16
  225. package/src/hooks/keyboard.ts +1 -1
  226. package/src/index.ts +9 -0
  227. package/src/libs/util.ts +14 -0
  228. package/src/locales/en.tsx +20 -0
  229. package/src/locales/zh.tsx +19 -0
  230. package/src/payment/amount.tsx +1 -6
  231. package/src/payment/donation-form.tsx +47 -29
  232. package/src/payment/error.tsx +16 -8
  233. package/src/payment/footer.tsx +11 -3
  234. package/src/payment/form/addon.tsx +6 -1
  235. package/src/payment/form/address.tsx +3 -7
  236. package/src/payment/form/currency.tsx +12 -2
  237. package/src/payment/form/index.tsx +121 -45
  238. package/src/payment/form/stripe/form.tsx +1 -5
  239. package/src/payment/header.tsx +14 -2
  240. package/src/payment/index.tsx +27 -22
  241. package/src/payment/product-card.tsx +41 -18
  242. package/src/payment/product-donation.tsx +85 -47
  243. package/src/payment/product-item.tsx +198 -28
  244. package/src/payment/product-skeleton.tsx +3 -2
  245. package/src/payment/skeleton/donation.tsx +12 -2
  246. package/src/payment/skeleton/overview.tsx +12 -2
  247. package/src/payment/skeleton/payment.tsx +16 -3
  248. package/src/payment/success.tsx +26 -15
  249. package/src/payment/summary.tsx +87 -44
  250. package/src/theme/index.tsx +5 -8
  251. package/src/theme/typography.ts +2 -2
@@ -50,18 +50,4 @@ export type DonateProps = Pick<CheckoutProps, 'onPaid' | 'onError'> & {
50
50
  children?: (openDialog: () => void, donateTotalAmount: string, supporters: DonateHistory, loading?: boolean, donateSettings?: DonationSettings) => React.ReactNode;
51
51
  };
52
52
  export declare function DonateDetails({ supporters, currency, method }: DonateHistory): import("react").JSX.Element;
53
- declare function CheckoutDonate(props: DonateProps): import("react").JSX.Element;
54
- declare namespace CheckoutDonate {
55
- var defaultProps: {
56
- theme: string;
57
- livemode: undefined;
58
- timeout: number;
59
- mode: string;
60
- inlineOptions: {
61
- button: {
62
- text: string;
63
- };
64
- };
65
- };
66
- }
67
- export default CheckoutDonate;
53
+ export default function CheckoutDonate(rawProps: DonateProps): import("react").JSX.Element;
@@ -102,9 +102,9 @@ export function DonateDetails({ supporters = [], currency, method }) {
102
102
  Stack,
103
103
  {
104
104
  direction: "row",
105
- alignItems: "center",
106
105
  spacing: 0.5,
107
106
  sx: {
107
+ alignItems: "center",
108
108
  flex: 3,
109
109
  overflow: "hidden"
110
110
  },
@@ -154,20 +154,32 @@ export function DonateDetails({ supporters = [], currency, method }) {
154
154
  ]
155
155
  }
156
156
  ),
157
- /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", justifyContent: "flex-end", spacing: 0.5, sx: { flex: 1 }, children: [
158
- /* @__PURE__ */ jsx(
159
- Avatar,
160
- {
161
- src: currency?.logo,
162
- alt: currency?.symbol,
163
- variant: "circular",
164
- sx: { width: 16, height: 16 }
157
+ /* @__PURE__ */ jsxs(
158
+ Stack,
159
+ {
160
+ direction: "row",
161
+ spacing: 0.5,
162
+ sx: {
163
+ alignItems: "center",
164
+ justifyContent: "flex-end",
165
+ flex: 1
165
166
  },
166
- x.id
167
- ),
168
- /* @__PURE__ */ jsx(Typography, { sx: { color: "text.secondary" }, children: formatBNStr(x.amount_total, currency.decimal) }),
169
- /* @__PURE__ */ jsx(Typography, { sx: { color: "text.secondary" }, children: currency.symbol })
170
- ] })
167
+ children: [
168
+ /* @__PURE__ */ jsx(
169
+ Avatar,
170
+ {
171
+ src: currency?.logo,
172
+ alt: currency?.symbol,
173
+ variant: "circular",
174
+ sx: { width: 16, height: 16 }
175
+ },
176
+ x.id
177
+ ),
178
+ /* @__PURE__ */ jsx(Typography, { sx: { color: "text.secondary" }, children: formatBNStr(x.amount_total, currency.decimal) }),
179
+ /* @__PURE__ */ jsx(Typography, { sx: { color: "text.secondary" }, children: currency.symbol })
180
+ ]
181
+ }
182
+ )
171
183
  ]
172
184
  },
173
185
  x.id
@@ -185,97 +197,116 @@ function SupporterAvatar({
185
197
  const [open, setOpen] = useState(false);
186
198
  const customers = uniqBy(supporters, "customer_id");
187
199
  const customersNum = customers.length;
188
- if (customersNum === 0)
189
- return null;
190
- return /* @__PURE__ */ jsxs(Stack, { flexDirection: "row", justifyContent: "center", alignItems: "center", children: [
191
- /* @__PURE__ */ jsx(
192
- AvatarGroup,
193
- {
194
- max: 5,
195
- sx: {
196
- "& .MuiAvatar-root": {
197
- backgroundColor: "background.paper",
198
- "&.MuiAvatar-colorDefault": {
199
- backgroundColor: "#bdbdbd"
200
- }
200
+ if (customersNum === 0) return null;
201
+ return /* @__PURE__ */ jsxs(
202
+ Stack,
203
+ {
204
+ sx: {
205
+ flexDirection: "row",
206
+ justifyContent: "center",
207
+ alignItems: "center"
208
+ },
209
+ children: [
210
+ /* @__PURE__ */ jsx(
211
+ AvatarGroup,
212
+ {
213
+ max: 5,
214
+ sx: {
215
+ "& .MuiAvatar-root": {
216
+ backgroundColor: "background.paper",
217
+ "&.MuiAvatar-colorDefault": {
218
+ backgroundColor: "#bdbdbd"
219
+ }
220
+ }
221
+ },
222
+ children: customers.slice(0, 5).map((supporter) => /* @__PURE__ */ jsx(
223
+ Avatar,
224
+ {
225
+ src: getCustomerAvatar(
226
+ supporter.customer?.did,
227
+ supporter?.updated_at ? new Date(supporter.updated_at).toISOString() : "",
228
+ 24
229
+ ),
230
+ alt: supporter.customer?.metadata?.anonymous ? "" : supporter.customer?.name,
231
+ sx: {
232
+ width: "24px",
233
+ height: "24px"
234
+ }
235
+ },
236
+ supporter.customer?.id
237
+ ))
201
238
  }
202
- },
203
- children: customers.slice(0, 5).map((supporter) => /* @__PURE__ */ jsx(
204
- Avatar,
239
+ ),
240
+ /* @__PURE__ */ jsx(
241
+ Box,
205
242
  {
206
- src: getCustomerAvatar(
207
- supporter.customer?.did,
208
- supporter?.updated_at ? new Date(supporter.updated_at).toISOString() : "",
209
- 24
210
- ),
211
- alt: supporter.customer?.metadata?.anonymous ? "" : supporter.customer?.name,
212
243
  sx: {
213
- width: "24px",
214
- height: "24px"
215
- }
216
- },
217
- supporter.customer?.id
218
- ))
219
- }
220
- ),
221
- /* @__PURE__ */ jsx(
222
- Box,
223
- {
224
- sx: {
225
- fontSize: "14px",
226
- color: "text.secondary",
227
- pl: 1.5,
228
- pr: 1,
229
- ml: -1,
230
- borderRadius: "8px",
231
- backgroundColor: "grey.100",
232
- height: "24px",
233
- ...showDonateDetails ? {
234
- cursor: "pointer",
235
- "&:hover": {
236
- backgroundColor: "grey.200"
237
- }
238
- } : {}
239
- },
240
- onClick: () => showDonateDetails && setOpen(true),
241
- children: `${customersNum} supporter${customersNum > 1 ? "s" : ""} (${formatAmount(totalAmount || "0", currency?.decimal)} ${currency.symbol})`
242
- }
243
- ),
244
- /* @__PURE__ */ jsx(
245
- Dialog,
246
- {
247
- open,
248
- onClose: () => setOpen(false),
249
- sx: {
250
- ".MuiDialogContent-root": {
251
- width: {
252
- xs: "100%",
253
- md: "450px"
244
+ fontSize: "14px",
245
+ color: "text.secondary",
246
+ pl: 1.5,
247
+ pr: 1,
248
+ ml: -1,
249
+ borderRadius: "8px",
250
+ backgroundColor: "grey.100",
251
+ height: "24px",
252
+ ...showDonateDetails ? {
253
+ cursor: "pointer",
254
+ "&:hover": {
255
+ backgroundColor: "grey.200"
256
+ }
257
+ } : {}
254
258
  },
255
- padding: "8px"
256
- },
257
- ".cko-donate-details": {
258
- maxHeight: {
259
- xs: "100%",
260
- md: "300px"
261
- }
259
+ onClick: () => showDonateDetails && setOpen(true),
260
+ children: `${customersNum} supporter${customersNum > 1 ? "s" : ""} (${formatAmount(totalAmount || "0", currency?.decimal)} ${currency.symbol})`
262
261
  }
263
- },
264
- title: `${customersNum} supporter${customersNum > 1 ? "s" : ""}`,
265
- children: /* @__PURE__ */ jsx(DonateDetails, { supporters, currency, method, totalAmount })
266
- }
267
- )
268
- ] });
262
+ ),
263
+ /* @__PURE__ */ jsx(
264
+ Dialog,
265
+ {
266
+ open,
267
+ onClose: () => setOpen(false),
268
+ sx: {
269
+ ".MuiDialogContent-root": {
270
+ width: {
271
+ xs: "100%",
272
+ md: "450px"
273
+ },
274
+ padding: "8px"
275
+ },
276
+ ".cko-donate-details": {
277
+ maxHeight: {
278
+ xs: "100%",
279
+ md: "300px"
280
+ }
281
+ }
282
+ },
283
+ title: `${customersNum} supporter${customersNum > 1 ? "s" : ""}`,
284
+ children: /* @__PURE__ */ jsx(DonateDetails, { supporters, currency, method, totalAmount })
285
+ }
286
+ )
287
+ ]
288
+ }
289
+ );
269
290
  }
270
291
  function SupporterTable({ supporters = [], totalAmount = "0", currency, method }) {
271
292
  const customers = uniqBy(supporters, "customer_id");
272
293
  const customersNum = customers.length;
273
- if (customersNum === 0)
274
- return null;
275
- return /* @__PURE__ */ jsxs(Box, { display: "flex", flexDirection: "column", alignItems: "center", gap: { xs: 0.5, sm: 1 }, children: [
276
- /* @__PURE__ */ jsx(SupporterAvatar, { supporters, totalAmount, currency, method }),
277
- /* @__PURE__ */ jsx(DonateDetails, { supporters, totalAmount, currency, method })
278
- ] });
294
+ if (customersNum === 0) return null;
295
+ return /* @__PURE__ */ jsxs(
296
+ Box,
297
+ {
298
+ sx: {
299
+ display: "flex",
300
+ flexDirection: "column",
301
+ alignItems: "center",
302
+ gap: { xs: 0.5, sm: 1 }
303
+ },
304
+ children: [
305
+ /* @__PURE__ */ jsx(SupporterAvatar, { supporters, totalAmount, currency, method }),
306
+ /* @__PURE__ */ jsx(DonateDetails, { supporters, totalAmount, currency, method })
307
+ ]
308
+ }
309
+ );
279
310
  }
280
311
  function SupporterSimple({ supporters = [], totalAmount = "0", currency, method }) {
281
312
  const { t } = useLocaleContext();
@@ -284,19 +315,30 @@ function SupporterSimple({ supporters = [], totalAmount = "0", currency, method
284
315
  return /* @__PURE__ */ jsxs(
285
316
  Box,
286
317
  {
287
- display: "flex",
288
- flexDirection: "column",
289
- alignItems: "center",
290
- gap: {
291
- xs: 0.5,
292
- sm: 1
318
+ sx: {
319
+ display: "flex",
320
+ flexDirection: "column",
321
+ alignItems: "center",
322
+ gap: {
323
+ xs: 0.5,
324
+ sm: 1
325
+ }
293
326
  },
294
327
  children: [
295
- /* @__PURE__ */ jsx(Typography, { component: "p", color: "text.secondary", children: customersNum === 0 ? /* @__PURE__ */ jsx("span", { style: emojiFont, children: t("payment.checkout.donation.empty") }) : t("payment.checkout.donation.summary", {
296
- total: customersNum,
297
- symbol: currency.symbol,
298
- totalAmount: formatAmount(totalAmount || "0", currency.decimal)
299
- }) }),
328
+ /* @__PURE__ */ jsx(
329
+ Typography,
330
+ {
331
+ component: "p",
332
+ sx: {
333
+ color: "text.secondary"
334
+ },
335
+ children: customersNum === 0 ? /* @__PURE__ */ jsx("span", { style: emojiFont, children: t("payment.checkout.donation.empty") }) : t("payment.checkout.donation.summary", {
336
+ total: customersNum,
337
+ symbol: currency.symbol,
338
+ totalAmount: formatAmount(totalAmount || "0", currency.decimal)
339
+ })
340
+ }
341
+ ),
300
342
  /* @__PURE__ */ jsx(
301
343
  AvatarGroup,
302
344
  {
@@ -371,11 +413,9 @@ function useDonation(settings, livemode, mode = "default") {
371
413
  );
372
414
  const rootMargin = isMobile ? "50px" : `${Math.min(window.innerHeight / 2, 300)}px`;
373
415
  useEffect(() => {
374
- if (mode === "inline")
375
- return;
416
+ if (mode === "inline") return;
376
417
  const element = containerRef.current;
377
- if (!element)
378
- return;
418
+ if (!element) return;
379
419
  const observer = new IntersectionObserver(
380
420
  ([entry]) => {
381
421
  if (entry.isIntersecting && !hasRequestedRef.current) {
@@ -463,10 +503,20 @@ function CheckoutDonateInner({
463
503
  variant: donateSettings.appearance?.button?.variant || "contained",
464
504
  ...donateSettings.appearance?.button,
465
505
  onClick: handlePopoverOpen,
466
- children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
467
- donateSettings.appearance.button.icon,
468
- typeof donateSettings.appearance.button.text === "string" ? /* @__PURE__ */ jsx(Typography, { sx: { whiteSpace: "nowrap" }, children: donateSettings.appearance.button.text }) : donateSettings.appearance.button.text
469
- ] })
506
+ children: /* @__PURE__ */ jsxs(
507
+ Stack,
508
+ {
509
+ direction: "row",
510
+ spacing: 0.5,
511
+ sx: {
512
+ alignItems: "center"
513
+ },
514
+ children: [
515
+ donateSettings.appearance.button.icon,
516
+ typeof donateSettings.appearance.button.text === "string" ? /* @__PURE__ */ jsx(Typography, { sx: { whiteSpace: "nowrap" }, children: donateSettings.appearance.button.text }) : donateSettings.appearance.button.text
517
+ ]
518
+ }
519
+ )
470
520
  }
471
521
  ),
472
522
  /* @__PURE__ */ jsx(
@@ -510,13 +560,34 @@ function CheckoutDonateInner({
510
560
  children: /* @__PURE__ */ jsx(CircularProgress, {})
511
561
  }
512
562
  ),
513
- /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", flexDirection: "column", gap: 2, children: [
514
- /* @__PURE__ */ jsx(Button, { ...inlineOptions.button, onClick: () => startDonate(), children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
515
- inlineOptions?.button?.icon,
516
- typeof inlineText === "string" ? /* @__PURE__ */ jsx(Typography, { sx: { whiteSpace: "nowrap" }, children: inlineText }) : inlineText
517
- ] }) }),
518
- /* @__PURE__ */ jsx(SupporterSimple, { ...supporters.data })
519
- ] })
563
+ /* @__PURE__ */ jsxs(
564
+ Box,
565
+ {
566
+ sx: {
567
+ display: "flex",
568
+ alignItems: "center",
569
+ flexDirection: "column",
570
+ gap: 2
571
+ },
572
+ children: [
573
+ /* @__PURE__ */ jsx(Button, { ...inlineOptions.button, onClick: () => startDonate(), children: /* @__PURE__ */ jsxs(
574
+ Stack,
575
+ {
576
+ direction: "row",
577
+ spacing: 0.5,
578
+ sx: {
579
+ alignItems: "center"
580
+ },
581
+ children: [
582
+ inlineOptions?.button?.icon,
583
+ typeof inlineText === "string" ? /* @__PURE__ */ jsx(Typography, { sx: { whiteSpace: "nowrap" }, children: inlineText }) : inlineText
584
+ ]
585
+ }
586
+ ) }),
587
+ /* @__PURE__ */ jsx(SupporterSimple, { ...supporters.data })
588
+ ]
589
+ }
590
+ )
520
591
  ]
521
592
  }
522
593
  )
@@ -526,11 +597,15 @@ function CheckoutDonateInner({
526
597
  const defaultRender = /* @__PURE__ */ jsxs(
527
598
  Box,
528
599
  {
529
- sx: { width: "100%", minWidth: 300, maxWidth: 720 },
530
- display: "flex",
531
- flexDirection: "column",
532
- alignItems: "center",
533
- gap: { xs: 1, sm: 2 },
600
+ sx: {
601
+ display: "flex",
602
+ flexDirection: "column",
603
+ alignItems: "center",
604
+ gap: { xs: 1, sm: 2 },
605
+ width: "100%",
606
+ minWidth: 300,
607
+ maxWidth: 720
608
+ },
534
609
  children: [
535
610
  /* @__PURE__ */ jsx(
536
611
  Button,
@@ -548,10 +623,20 @@ function CheckoutDonateInner({
548
623
  },
549
624
  ...donateSettings.appearance?.button,
550
625
  onClick: () => startDonate(),
551
- children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
552
- donateSettings.appearance.button.icon && /* @__PURE__ */ jsx(Typography, { sx: { mr: 0.5, display: "inline-flex", alignItems: "center" }, children: donateSettings.appearance.button.icon }),
553
- typeof donateSettings.appearance.button.text === "string" ? /* @__PURE__ */ jsx(Typography, { children: donateSettings.appearance.button.text }) : donateSettings.appearance.button.text
554
- ] })
626
+ children: /* @__PURE__ */ jsxs(
627
+ Stack,
628
+ {
629
+ direction: "row",
630
+ spacing: 0.5,
631
+ sx: {
632
+ alignItems: "center"
633
+ },
634
+ children: [
635
+ donateSettings.appearance.button.icon && /* @__PURE__ */ jsx(Typography, { sx: { mr: 0.5, display: "inline-flex", alignItems: "center" }, children: donateSettings.appearance.button.icon }),
636
+ typeof donateSettings.appearance.button.text === "string" ? /* @__PURE__ */ jsx(Typography, { children: donateSettings.appearance.button.text }) : donateSettings.appearance.button.text
637
+ ]
638
+ }
639
+ )
555
640
  }
556
641
  ),
557
642
  supporters.data && donateSettings.appearance.history.variant === "avatar" && /* @__PURE__ */ jsx(SupporterAvatar, { ...supporters.data, showDonateDetails: true }),
@@ -588,53 +673,74 @@ function CheckoutDonateInner({
588
673
  Dialog,
589
674
  {
590
675
  open: state.open,
591
- title: /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", gap: 0.5, children: [
592
- /* @__PURE__ */ jsx(Typography, { variant: "h3", sx: { maxWidth: 320, textOverflow: "ellipsis", overflow: "hidden" }, children: donateSettings.title }),
593
- supportUpdateSettings && isAdmin && /* @__PURE__ */ jsx(Tooltip, { title: t("payment.checkout.donation.configTip"), placement: "bottom", children: /* @__PURE__ */ jsx(
594
- IconButton,
595
- {
596
- size: "small",
597
- onClick: (e) => {
598
- e.stopPropagation();
599
- openDonationSettings(true);
600
- },
601
- children: /* @__PURE__ */ jsx(Settings, { fontSize: "small", sx: { ml: -0.5 } })
602
- }
603
- ) }),
604
- !donation.data.livemode && /* @__PURE__ */ jsx(Livemode, { sx: { width: "fit-content", ml: 0.5 } })
605
- ] }),
606
- maxWidth: "md",
607
- toolbar: isMobile ? null : /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", gap: 1, sx: { color: "text.secondary" }, children: [
608
- /* @__PURE__ */ jsx(
609
- AvatarGroup,
610
- {
611
- total: customers?.length,
612
- max: 5,
613
- spacing: 4,
614
- sx: {
615
- "& .MuiAvatar-root": {
616
- width: 18,
617
- height: 18,
618
- fontSize: "0.6rem"
676
+ title: /* @__PURE__ */ jsxs(
677
+ Box,
678
+ {
679
+ sx: {
680
+ display: "flex",
681
+ alignItems: "center",
682
+ gap: 0.5
683
+ },
684
+ children: [
685
+ /* @__PURE__ */ jsx(Typography, { variant: "h3", sx: { maxWidth: 320, textOverflow: "ellipsis", overflow: "hidden" }, children: donateSettings.title }),
686
+ supportUpdateSettings && isAdmin && /* @__PURE__ */ jsx(Tooltip, { title: t("payment.checkout.donation.configTip"), placement: "bottom", children: /* @__PURE__ */ jsx(
687
+ IconButton,
688
+ {
689
+ size: "small",
690
+ onClick: (e) => {
691
+ e.stopPropagation();
692
+ openDonationSettings(true);
693
+ },
694
+ children: /* @__PURE__ */ jsx(Settings, { fontSize: "small", sx: { ml: -0.5 } })
619
695
  }
620
- },
621
- children: customers.map((x) => /* @__PURE__ */ jsx(
622
- Avatar,
696
+ ) }),
697
+ !donation.data.livemode && /* @__PURE__ */ jsx(Livemode, { sx: { width: "fit-content", ml: 0.5 } })
698
+ ]
699
+ }
700
+ ),
701
+ maxWidth: "md",
702
+ toolbar: isMobile ? null : /* @__PURE__ */ jsxs(
703
+ Box,
704
+ {
705
+ sx: {
706
+ display: "flex",
707
+ alignItems: "center",
708
+ gap: 1,
709
+ color: "text.secondary"
710
+ },
711
+ children: [
712
+ /* @__PURE__ */ jsx(
713
+ AvatarGroup,
623
714
  {
624
- title: x.customer?.name,
625
- src: getCustomerAvatar(
626
- x.customer?.did,
627
- x?.updated_at ? new Date(x.updated_at).toISOString() : "",
628
- 24
629
- ),
630
- variant: "circular"
631
- },
632
- x.id
633
- ))
634
- }
635
- ),
636
- customers?.length > 0 && /* @__PURE__ */ jsx(Typography, { variant: "body2", children: t("payment.checkout.donation.gaveTips", { count: customers?.length }) })
637
- ] }),
715
+ total: customers?.length,
716
+ max: 5,
717
+ spacing: 4,
718
+ sx: {
719
+ "& .MuiAvatar-root": {
720
+ width: 18,
721
+ height: 18,
722
+ fontSize: "0.6rem"
723
+ }
724
+ },
725
+ children: customers.map((x) => /* @__PURE__ */ jsx(
726
+ Avatar,
727
+ {
728
+ title: x.customer?.name,
729
+ src: getCustomerAvatar(
730
+ x.customer?.did,
731
+ x?.updated_at ? new Date(x.updated_at).toISOString() : "",
732
+ 24
733
+ ),
734
+ variant: "circular"
735
+ },
736
+ x.id
737
+ ))
738
+ }
739
+ ),
740
+ customers?.length > 0 && /* @__PURE__ */ jsx(Typography, { variant: "body2", children: t("payment.checkout.donation.gaveTips", { count: customers?.length }) })
741
+ ]
742
+ }
743
+ ),
638
744
  showCloseButton: false,
639
745
  disableEscapeKeyDown: true,
640
746
  sx: {
@@ -689,9 +795,26 @@ function CheckoutDonateInner({
689
795
  )
690
796
  ] });
691
797
  }
692
- export default function CheckoutDonate(props) {
798
+ export default function CheckoutDonate(rawProps) {
799
+ const props = Object.assign(
800
+ {
801
+ theme: "default",
802
+ livemode: void 0,
803
+ inlineOptions: {
804
+ button: {
805
+ text: "Tip"
806
+ }
807
+ },
808
+ timeout: 5e3,
809
+ mode: "default"
810
+ },
811
+ rawProps
812
+ );
693
813
  const { livemode } = usePaymentContext();
694
- const content = /* @__PURE__ */ jsx(CheckoutDonateInner, { ...props, livemode: props.livemode === void 0 ? livemode : props.livemode });
814
+ const content = (
815
+ // eslint-disable-next-line react/prop-types
816
+ /* @__PURE__ */ jsx(CheckoutDonateInner, { ...props, livemode: props.livemode === void 0 ? livemode : props.livemode })
817
+ );
695
818
  if (props.theme === "inherit") {
696
819
  return content;
697
820
  }
@@ -700,14 +823,3 @@ export default function CheckoutDonate(props) {
700
823
  }
701
824
  return /* @__PURE__ */ jsx(PaymentThemeProvider, { children: content });
702
825
  }
703
- CheckoutDonate.defaultProps = {
704
- theme: "default",
705
- livemode: void 0,
706
- timeout: 5e3,
707
- mode: "default",
708
- inlineOptions: {
709
- button: {
710
- text: "Tip"
711
- }
712
- }
713
- };
@@ -1,16 +1,2 @@
1
1
  import type { CheckoutProps } from '../types';
2
- declare function CheckoutForm({ id, mode, onPaid, onError, onChange, goBack, extraParams, action, theme, formType, ...restProps }: CheckoutProps): import("react").JSX.Element;
3
- declare namespace CheckoutForm {
4
- var defaultProps: {
5
- onPaid: any;
6
- onError: {
7
- (...data: any[]): void;
8
- (message?: any, ...optionalParams: any[]): void;
9
- };
10
- mode: string;
11
- action: string;
12
- extraParams: {};
13
- formType: string;
14
- };
15
- }
16
- export default CheckoutForm;
2
+ export default function CheckoutForm({ id, mode, onPaid, onError, onChange, goBack, extraParams, action, theme, formType, ...restProps }: CheckoutProps): import("react").JSX.Element;
@@ -25,13 +25,13 @@ const fetchCheckoutSession = async (id) => {
25
25
  };
26
26
  export default function CheckoutForm({
27
27
  id,
28
- mode,
29
- onPaid,
30
- onError,
28
+ mode = "inline",
29
+ onPaid = noop,
30
+ onError = console.error,
31
31
  onChange,
32
32
  goBack,
33
- extraParams,
34
- action,
33
+ extraParams = {},
34
+ action = "",
35
35
  theme = "default",
36
36
  formType = "payment",
37
37
  ...restProps
@@ -108,11 +108,3 @@ export default function CheckoutForm({
108
108
  }
109
109
  return /* @__PURE__ */ jsx(PaymentThemeProvider, { children: Checkout });
110
110
  }
111
- CheckoutForm.defaultProps = {
112
- onPaid: noop,
113
- onError: console.error,
114
- mode: "inline",
115
- action: "",
116
- extraParams: {},
117
- formType: "payment"
118
- };