@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.
- package/es/checkout/donate.d.ts +1 -15
- package/es/checkout/donate.js +301 -189
- package/es/checkout/form.d.ts +1 -15
- package/es/checkout/form.js +5 -13
- package/es/checkout/table.js +3 -3
- package/es/components/blockchain/gas.d.ts +1 -5
- package/es/components/blockchain/gas.js +10 -2
- package/es/components/blockchain/tx.d.ts +1 -8
- package/es/components/blockchain/tx.js +29 -10
- package/es/components/confirm.d.ts +1 -10
- package/es/components/confirm.js +4 -10
- package/es/components/country-select.d.ts +3 -2
- package/es/components/country-select.js +375 -352
- package/es/components/date-range-picker.d.ts +13 -0
- package/es/components/date-range-picker.js +279 -0
- package/es/components/input.d.ts +14 -20
- package/es/components/input.js +51 -44
- package/es/components/label.d.ts +7 -0
- package/es/components/label.js +49 -0
- package/es/components/lazy-loader.js +1 -2
- package/es/components/link.d.ts +2 -9
- package/es/components/link.js +9 -6
- package/es/components/livemode.d.ts +2 -8
- package/es/components/livemode.js +1 -5
- package/es/components/loading-button.d.ts +6 -1
- package/es/components/loading-button.js +56 -66
- package/es/components/over-due-invoice-payment.d.ts +0 -18
- package/es/components/over-due-invoice-payment.js +138 -95
- package/es/components/payment-beneficiaries.d.ts +2 -7
- package/es/components/payment-beneficiaries.js +86 -40
- package/es/components/pricing-item.d.ts +0 -5
- package/es/components/pricing-item.js +1 -4
- package/es/components/pricing-table.d.ts +2 -10
- package/es/components/pricing-table.js +8 -7
- package/es/components/resume-subscription.d.ts +0 -10
- package/es/components/resume-subscription.js +42 -21
- package/es/components/truncated-text.d.ts +2 -9
- package/es/components/truncated-text.js +0 -5
- package/es/contexts/donate.d.ts +0 -7
- package/es/contexts/donate.js +10 -8
- package/es/contexts/payment.d.ts +1 -4
- package/es/contexts/payment.js +7 -2
- package/es/history/credit/grants-list.d.ts +14 -0
- package/es/history/credit/grants-list.js +215 -0
- package/es/history/credit/transactions-list.d.ts +13 -0
- package/es/history/credit/transactions-list.js +255 -0
- package/es/history/invoice/list.d.ts +2 -18
- package/es/history/invoice/list.js +172 -74
- package/es/history/payment/list.js +115 -38
- package/es/hooks/keyboard.d.ts +1 -1
- package/es/hooks/keyboard.js +2 -4
- package/es/index.d.ts +5 -1
- package/es/index.js +10 -1
- package/es/libs/cached-request.js +2 -4
- package/es/libs/phone-validator.js +1 -2
- package/es/libs/util.d.ts +2 -0
- package/es/libs/util.js +14 -4
- package/es/libs/validator.js +2 -4
- package/es/locales/en.js +20 -2
- package/es/locales/zh.js +20 -2
- package/es/payment/amount.d.ts +2 -7
- package/es/payment/amount.js +1 -5
- package/es/payment/donation-form.d.ts +2 -10
- package/es/payment/donation-form.js +196 -160
- package/es/payment/error.d.ts +2 -8
- package/es/payment/error.js +40 -20
- package/es/payment/footer.d.ts +2 -3
- package/es/payment/footer.js +19 -6
- package/es/payment/form/addon.js +14 -4
- package/es/payment/form/address.d.ts +2 -9
- package/es/payment/form/address.js +3 -6
- package/es/payment/form/currency.js +45 -25
- package/es/payment/form/index.d.ts +2 -8
- package/es/payment/form/index.js +151 -71
- package/es/payment/form/phone.js +2 -4
- package/es/payment/form/stripe/form.d.ts +2 -8
- package/es/payment/form/stripe/form.js +1 -3
- package/es/payment/header.js +38 -16
- package/es/payment/index.d.ts +2 -9
- package/es/payment/index.js +23 -17
- package/es/payment/product-card.d.ts +2 -11
- package/es/payment/product-card.js +84 -50
- package/es/payment/product-donation.js +175 -114
- package/es/payment/product-item.d.ts +9 -9
- package/es/payment/product-item.js +320 -145
- package/es/payment/product-skeleton.js +2 -2
- package/es/payment/skeleton/donation.js +27 -7
- package/es/payment/skeleton/overview.js +22 -2
- package/es/payment/skeleton/payment.js +33 -5
- package/es/payment/success.d.ts +2 -9
- package/es/payment/success.js +41 -14
- package/es/payment/summary.d.ts +4 -17
- package/es/payment/summary.js +193 -111
- package/es/theme/index.d.ts +0 -5
- package/es/theme/index.js +2 -5
- package/es/theme/typography.d.ts +2 -2
- package/lib/checkout/donate.d.ts +1 -15
- package/lib/checkout/donate.js +75 -54
- package/lib/checkout/form.d.ts +1 -15
- package/lib/checkout/form.js +7 -15
- package/lib/checkout/table.js +4 -4
- package/lib/components/blockchain/gas.d.ts +1 -5
- package/lib/components/blockchain/gas.js +3 -2
- package/lib/components/blockchain/tx.d.ts +1 -8
- package/lib/components/blockchain/tx.js +15 -10
- package/lib/components/confirm.d.ts +1 -10
- package/lib/components/confirm.js +5 -11
- package/lib/components/country-select.d.ts +3 -2
- package/lib/components/country-select.js +23 -22
- package/lib/components/date-range-picker.d.ts +13 -0
- package/lib/components/date-range-picker.js +329 -0
- package/lib/components/input.d.ts +14 -20
- package/lib/components/input.js +28 -27
- package/lib/components/label.d.ts +7 -0
- package/lib/components/label.js +60 -0
- package/lib/components/lazy-loader.js +1 -1
- package/lib/components/link.d.ts +2 -9
- package/lib/components/link.js +3 -8
- package/lib/components/livemode.d.ts +2 -8
- package/lib/components/livemode.js +3 -7
- package/lib/components/loading-button.d.ts +6 -1
- package/lib/components/loading-button.js +9 -17
- package/lib/components/over-due-invoice-payment.d.ts +0 -18
- package/lib/components/over-due-invoice-payment.js +31 -33
- package/lib/components/payment-beneficiaries.d.ts +2 -7
- package/lib/components/payment-beneficiaries.js +12 -11
- package/lib/components/pricing-item.d.ts +0 -5
- package/lib/components/pricing-item.js +2 -5
- package/lib/components/pricing-table.d.ts +2 -10
- package/lib/components/pricing-table.js +5 -11
- package/lib/components/resume-subscription.d.ts +0 -10
- package/lib/components/resume-subscription.js +16 -16
- package/lib/components/table.js +1 -1
- package/lib/components/truncated-text.d.ts +2 -9
- package/lib/components/truncated-text.js +1 -6
- package/lib/contexts/donate.d.ts +0 -7
- package/lib/contexts/donate.js +4 -7
- package/lib/contexts/payment.d.ts +1 -4
- package/lib/contexts/payment.js +4 -7
- package/lib/history/credit/grants-list.d.ts +14 -0
- package/lib/history/credit/grants-list.js +277 -0
- package/lib/history/credit/transactions-list.d.ts +13 -0
- package/lib/history/credit/transactions-list.js +301 -0
- package/lib/history/invoice/list.d.ts +2 -18
- package/lib/history/invoice/list.js +73 -37
- package/lib/history/payment/list.js +30 -16
- package/lib/hooks/keyboard.d.ts +1 -1
- package/lib/hooks/mobile.js +1 -1
- package/lib/hooks/subscription.js +1 -1
- package/lib/index.d.ts +5 -1
- package/lib/index.js +41 -2
- package/lib/libs/api.js +1 -1
- package/lib/libs/dayjs.js +1 -1
- package/lib/libs/phone-validator.js +0 -2
- package/lib/libs/theme.js +1 -1
- package/lib/libs/util.d.ts +2 -0
- package/lib/libs/util.js +15 -1
- package/lib/libs/validator.js +1 -1
- package/lib/locales/en.js +21 -3
- package/lib/locales/index.js +1 -1
- package/lib/locales/zh.js +21 -3
- package/lib/payment/amount.d.ts +2 -7
- package/lib/payment/amount.js +2 -6
- package/lib/payment/donation-form.d.ts +2 -10
- package/lib/payment/donation-form.js +33 -38
- package/lib/payment/error.d.ts +2 -8
- package/lib/payment/error.js +11 -13
- package/lib/payment/footer.d.ts +2 -3
- package/lib/payment/footer.js +5 -5
- package/lib/payment/form/addon.js +5 -3
- package/lib/payment/form/address.d.ts +2 -9
- package/lib/payment/form/address.js +5 -8
- package/lib/payment/form/currency.js +3 -3
- package/lib/payment/form/index.d.ts +2 -8
- package/lib/payment/form/index.js +64 -21
- package/lib/payment/form/phone.js +1 -1
- package/lib/payment/form/stripe/form.d.ts +2 -8
- package/lib/payment/form/stripe/form.js +3 -6
- package/lib/payment/header.js +8 -4
- package/lib/payment/index.d.ts +2 -9
- package/lib/payment/index.js +27 -18
- package/lib/payment/product-card.d.ts +2 -11
- package/lib/payment/product-card.js +13 -20
- package/lib/payment/product-donation.js +71 -66
- package/lib/payment/product-item.d.ts +9 -9
- package/lib/payment/product-item.js +168 -29
- package/lib/payment/product-skeleton.js +2 -2
- package/lib/payment/skeleton/donation.js +8 -4
- package/lib/payment/skeleton/overview.js +6 -2
- package/lib/payment/skeleton/payment.js +9 -3
- package/lib/payment/success.d.ts +2 -9
- package/lib/payment/success.js +12 -15
- package/lib/payment/summary.d.ts +4 -17
- package/lib/payment/summary.js +53 -45
- package/lib/theme/index.d.ts +0 -5
- package/lib/theme/index.js +2 -5
- package/lib/theme/typography.d.ts +2 -2
- package/package.json +40 -40
- package/src/checkout/donate.tsx +103 -35
- package/src/checkout/form.tsx +5 -14
- package/src/checkout/table.tsx +3 -3
- package/src/components/blockchain/gas.tsx +5 -3
- package/src/components/blockchain/tx.tsx +19 -11
- package/src/components/confirm.tsx +4 -11
- package/src/components/country-select.tsx +391 -378
- package/src/components/date-range-picker.tsx +310 -0
- package/src/components/input.tsx +61 -46
- package/src/components/label.tsx +58 -0
- package/src/components/link.tsx +9 -7
- package/src/components/livemode.tsx +2 -6
- package/src/components/loading-button.tsx +63 -76
- package/src/components/over-due-invoice-payment.tsx +43 -28
- package/src/components/payment-beneficiaries.tsx +33 -14
- package/src/components/pricing-item.tsx +1 -4
- package/src/components/pricing-table.tsx +8 -8
- package/src/components/resume-subscription.tsx +20 -14
- package/src/components/table.tsx +2 -2
- package/src/components/truncated-text.tsx +0 -6
- package/src/contexts/donate.tsx +6 -7
- package/src/contexts/payment.tsx +7 -3
- package/src/history/credit/grants-list.tsx +276 -0
- package/src/history/credit/transactions-list.tsx +317 -0
- package/src/history/invoice/list.tsx +92 -36
- package/src/history/payment/list.tsx +53 -16
- package/src/hooks/keyboard.ts +1 -1
- package/src/index.ts +9 -0
- package/src/libs/util.ts +14 -0
- package/src/locales/en.tsx +20 -0
- package/src/locales/zh.tsx +19 -0
- package/src/payment/amount.tsx +1 -6
- package/src/payment/donation-form.tsx +47 -29
- package/src/payment/error.tsx +16 -8
- package/src/payment/footer.tsx +11 -3
- package/src/payment/form/addon.tsx +6 -1
- package/src/payment/form/address.tsx +3 -7
- package/src/payment/form/currency.tsx +12 -2
- package/src/payment/form/index.tsx +121 -45
- package/src/payment/form/stripe/form.tsx +1 -5
- package/src/payment/header.tsx +14 -2
- package/src/payment/index.tsx +27 -22
- package/src/payment/product-card.tsx +41 -18
- package/src/payment/product-donation.tsx +85 -47
- package/src/payment/product-item.tsx +198 -28
- package/src/payment/product-skeleton.tsx +3 -2
- package/src/payment/skeleton/donation.tsx +12 -2
- package/src/payment/skeleton/overview.tsx +12 -2
- package/src/payment/skeleton/payment.tsx +16 -3
- package/src/payment/success.tsx +26 -15
- package/src/payment/summary.tsx +87 -44
- package/src/theme/index.tsx +5 -8
- package/src/theme/typography.ts +2 -2
package/es/checkout/donate.d.ts
CHANGED
|
@@ -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
|
-
|
|
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;
|
package/es/checkout/donate.js
CHANGED
|
@@ -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(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
-
|
|
204
|
-
|
|
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
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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
|
-
|
|
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
|
-
|
|
265
|
-
|
|
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
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
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
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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(
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
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(
|
|
467
|
-
|
|
468
|
-
|
|
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(
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
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: {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
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(
|
|
552
|
-
|
|
553
|
-
|
|
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(
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
},
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
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
|
-
|
|
622
|
-
|
|
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
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
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(
|
|
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 =
|
|
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
|
-
};
|
package/es/checkout/form.d.ts
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
1
|
import type { CheckoutProps } from '../types';
|
|
2
|
-
|
|
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;
|
package/es/checkout/form.js
CHANGED
|
@@ -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
|
-
};
|