@blocklet/payment-react 1.14.24 → 1.14.26
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/components/table.js +8 -2
- package/es/hooks/table.d.ts +1 -0
- package/es/hooks/table.js +5 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/libs/util.d.ts +15 -2
- package/es/libs/util.js +44 -9
- package/es/locales/en.js +3 -2
- package/es/locales/zh.js +3 -2
- package/es/payment/form/currency.js +0 -10
- package/es/payment/index.js +1 -14
- package/es/payment/product-item.d.ts +3 -1
- package/es/payment/product-item.js +8 -4
- package/es/payment/summary.d.ts +3 -1
- package/es/payment/summary.js +6 -2
- package/lib/components/table.js +8 -2
- package/lib/hooks/table.d.ts +1 -0
- package/lib/hooks/table.js +13 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +12 -0
- package/lib/libs/util.d.ts +15 -2
- package/lib/libs/util.js +61 -9
- package/lib/locales/en.js +3 -2
- package/lib/locales/zh.js +3 -2
- package/lib/payment/form/currency.js +0 -10
- package/lib/payment/index.js +1 -14
- package/lib/payment/product-item.d.ts +3 -1
- package/lib/payment/product-item.js +11 -4
- package/lib/payment/summary.d.ts +3 -1
- package/lib/payment/summary.js +9 -2
- package/package.json +3 -3
- package/src/components/table.tsx +8 -2
- package/src/hooks/table.ts +6 -0
- package/src/index.ts +1 -0
- package/src/libs/util.ts +53 -10
- package/src/locales/en.tsx +3 -2
- package/src/locales/zh.tsx +3 -2
- package/src/payment/form/currency.tsx +0 -10
- package/src/payment/index.tsx +2 -14
- package/src/payment/product-item.tsx +8 -3
- package/src/payment/summary.tsx +6 -1
package/es/components/table.js
CHANGED
|
@@ -17,8 +17,8 @@ const Table = React.memo(
|
|
|
17
17
|
download: false,
|
|
18
18
|
filter: false,
|
|
19
19
|
selectableRows: "none",
|
|
20
|
-
rowsPerPage: 10,
|
|
21
|
-
rowsPerPageOptions: [10, 20, 50, 100],
|
|
20
|
+
rowsPerPage: isMobile ? 5 : 10,
|
|
21
|
+
rowsPerPageOptions: [5, 10, 20, 50, 100],
|
|
22
22
|
searchDebounceTime: 300,
|
|
23
23
|
tableBodyHeight: "100%",
|
|
24
24
|
loading: true
|
|
@@ -98,6 +98,8 @@ const Wrapped = styled(Datatable)`
|
|
|
98
98
|
}
|
|
99
99
|
td.MuiTableCell-root {
|
|
100
100
|
border-bottom: none;
|
|
101
|
+
padding-top: 12px;
|
|
102
|
+
padding-bottom: 12px;
|
|
101
103
|
&:first-of-type {
|
|
102
104
|
padding-left: 20px;
|
|
103
105
|
}
|
|
@@ -135,6 +137,10 @@ const Wrapped = styled(Datatable)`
|
|
|
135
137
|
> div {
|
|
136
138
|
overflow: auto;
|
|
137
139
|
}
|
|
140
|
+
.custom-toobar-title-inner {
|
|
141
|
+
display: flex;
|
|
142
|
+
align-items: center;
|
|
143
|
+
}
|
|
138
144
|
@media (max-width: ${({ theme }) => theme.breakpoints.values.md}px) {
|
|
139
145
|
th a,
|
|
140
146
|
td a {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useDefaultPageSize(pageSize?: number): number;
|
package/es/index.d.ts
CHANGED
|
@@ -31,5 +31,6 @@ export * from './libs/connect';
|
|
|
31
31
|
export * from './contexts/payment';
|
|
32
32
|
export * from './hooks/subscription';
|
|
33
33
|
export * from './hooks/mobile';
|
|
34
|
+
export * from './hooks/table';
|
|
34
35
|
export { translations, createTranslator } from './locales';
|
|
35
36
|
export { api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, TxLink, TxGas, SafeGuard, PricingItem, CountrySelect, Table, };
|
package/es/index.js
CHANGED
|
@@ -31,6 +31,7 @@ export * from "./libs/connect.js";
|
|
|
31
31
|
export * from "./contexts/payment.js";
|
|
32
32
|
export * from "./hooks/subscription.js";
|
|
33
33
|
export * from "./hooks/mobile.js";
|
|
34
|
+
export * from "./hooks/table.js";
|
|
34
35
|
export { translations, createTranslator } from "./locales/index.js";
|
|
35
36
|
export {
|
|
36
37
|
api,
|
package/es/libs/util.d.ts
CHANGED
|
@@ -19,7 +19,10 @@ export declare function getStatementDescriptor(items: any[]): any;
|
|
|
19
19
|
export declare function formatRecurring(recurring: PriceRecurring, translate?: boolean, separator?: string, locale?: string): string;
|
|
20
20
|
export declare function getPriceUintAmountByCurrency(price: TPrice, currency: TPaymentCurrency): string;
|
|
21
21
|
export declare function getPriceCurrencyOptions(price: TPrice): PriceCurrency[];
|
|
22
|
-
export declare function formatLineItemPricing(item: TLineItemExpanded, currency: TPaymentCurrency,
|
|
22
|
+
export declare function formatLineItemPricing(item: TLineItemExpanded, currency: TPaymentCurrency, { trialEnd, trialInDays }: {
|
|
23
|
+
trialEnd: number;
|
|
24
|
+
trialInDays: number;
|
|
25
|
+
}, locale?: string): {
|
|
23
26
|
primary: string;
|
|
24
27
|
secondary?: string;
|
|
25
28
|
quantity: string;
|
|
@@ -47,7 +50,17 @@ export declare function formatPriceDisplay({ amount, then, actualAmount, showThe
|
|
|
47
50
|
actualAmount: string;
|
|
48
51
|
showThen?: boolean;
|
|
49
52
|
}, recurring: string, hasMetered: boolean, locale?: string): string;
|
|
50
|
-
export declare function
|
|
53
|
+
export declare function getFreeTrialTime({ trialInDays, trialEnd }: {
|
|
54
|
+
trialInDays: number;
|
|
55
|
+
trialEnd: number;
|
|
56
|
+
}, locale?: string): {
|
|
57
|
+
count: number;
|
|
58
|
+
interval: string;
|
|
59
|
+
};
|
|
60
|
+
export declare function formatCheckoutHeadlines(items: TLineItemExpanded[], currency: TPaymentCurrency, { trialInDays, trialEnd }: {
|
|
61
|
+
trialInDays: number;
|
|
62
|
+
trialEnd: number;
|
|
63
|
+
}, locale?: string): {
|
|
51
64
|
action: string;
|
|
52
65
|
amount: string;
|
|
53
66
|
then?: string;
|
package/es/libs/util.js
CHANGED
|
@@ -202,7 +202,7 @@ export function getPriceCurrencyOptions(price) {
|
|
|
202
202
|
}
|
|
203
203
|
];
|
|
204
204
|
}
|
|
205
|
-
export function formatLineItemPricing(item, currency,
|
|
205
|
+
export function formatLineItemPricing(item, currency, { trialEnd, trialInDays }, locale = "en") {
|
|
206
206
|
const price = item.upsell_price || item.price;
|
|
207
207
|
let quantity = t("common.qty", locale, { count: item.quantity });
|
|
208
208
|
if (price.recurring?.usage_type === "metered" || +item.quantity === 1) {
|
|
@@ -211,6 +211,7 @@ export function formatLineItemPricing(item, currency, trial, locale = "en") {
|
|
|
211
211
|
const unitValue = new BN(getPriceUintAmountByCurrency(price, currency));
|
|
212
212
|
const total = `${fromUnitToToken(unitValue.mul(new BN(item.quantity)), currency.decimal)} ${currency.symbol}`;
|
|
213
213
|
const unit = `${fromUnitToToken(unitValue, currency.decimal)} ${currency.symbol}`;
|
|
214
|
+
const trialResult = getFreeTrialTime({ trialInDays, trialEnd }, locale);
|
|
214
215
|
const appendUnit = (v, alt) => {
|
|
215
216
|
if (price.product.unit_label) {
|
|
216
217
|
return `${v}/${price.product.unit_label}`;
|
|
@@ -221,9 +222,9 @@ export function formatLineItemPricing(item, currency, trial, locale = "en") {
|
|
|
221
222
|
return quantity ? t("common.each", locale, { unit }) : "";
|
|
222
223
|
};
|
|
223
224
|
if (price.type === "recurring" && price.recurring) {
|
|
224
|
-
if (
|
|
225
|
+
if (trialResult.count > 0) {
|
|
225
226
|
return {
|
|
226
|
-
primary: t("common.trial", locale, { count:
|
|
227
|
+
primary: t("common.trial", locale, { count: trialResult.count, interval: trialResult.interval }),
|
|
227
228
|
secondary: `${appendUnit(total, total)} ${formatRecurring(price.recurring, false, "slash", locale)}`,
|
|
228
229
|
quantity
|
|
229
230
|
};
|
|
@@ -415,11 +416,43 @@ export function formatPriceDisplay({ amount, then, actualAmount, showThen }, rec
|
|
|
415
416
|
}
|
|
416
417
|
return [amount, then].filter(Boolean).join(" ");
|
|
417
418
|
}
|
|
418
|
-
export function
|
|
419
|
+
export function getFreeTrialTime({ trialInDays, trialEnd }, locale = "en") {
|
|
420
|
+
const now = dayjs().unix();
|
|
421
|
+
if (trialEnd > 0 && trialEnd > now) {
|
|
422
|
+
if (trialEnd - now < 3600) {
|
|
423
|
+
return {
|
|
424
|
+
count: Math.ceil((trialEnd - now) / 60),
|
|
425
|
+
interval: t("common.minute", locale)
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
if (trialEnd - now < 86400) {
|
|
429
|
+
return {
|
|
430
|
+
count: Math.ceil((trialEnd - now) / 3600),
|
|
431
|
+
interval: t("common.hour", locale)
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
return {
|
|
435
|
+
count: Math.ceil((trialEnd - now) / 86400),
|
|
436
|
+
interval: t("common.day", locale)
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
if (trialInDays > 0) {
|
|
440
|
+
return {
|
|
441
|
+
count: trialInDays,
|
|
442
|
+
interval: t("common.day", locale)
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
return {
|
|
446
|
+
count: 0,
|
|
447
|
+
interval: t("common.day", locale)
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
export function formatCheckoutHeadlines(items, currency, { trialInDays, trialEnd }, locale = "en") {
|
|
419
451
|
const brand = getStatementDescriptor(items);
|
|
420
452
|
const { total } = getCheckoutAmount(items, currency, trialInDays > 0);
|
|
421
453
|
const actualAmount = fromUnitToToken(total, currency.decimal);
|
|
422
454
|
const amount = `${fromUnitToToken(total, currency.decimal)} ${currency.symbol}`;
|
|
455
|
+
const trialResult = getFreeTrialTime({ trialInDays, trialEnd }, locale);
|
|
423
456
|
if (items.length === 0) {
|
|
424
457
|
return {
|
|
425
458
|
action: t("payment.checkout.empty", locale),
|
|
@@ -453,17 +486,19 @@ export function formatCheckoutHeadlines(items, currency, trialInDays, locale = "
|
|
|
453
486
|
if (x.price.recurring?.usage_type === "metered") {
|
|
454
487
|
return acc;
|
|
455
488
|
}
|
|
456
|
-
return acc.add(
|
|
489
|
+
return acc.add(
|
|
490
|
+
new BN(getPriceUintAmountByCurrency(x.upsell_price || x.price, currency)).mul(new BN(x.quantity))
|
|
491
|
+
);
|
|
457
492
|
}, new BN(0)),
|
|
458
493
|
currency.decimal
|
|
459
494
|
),
|
|
460
495
|
currency.symbol
|
|
461
496
|
].filter(Boolean).join(" ");
|
|
462
497
|
if (items.length > 1) {
|
|
463
|
-
if (
|
|
498
|
+
if (trialResult.count > 0) {
|
|
464
499
|
const result4 = {
|
|
465
500
|
action: t("payment.checkout.try2", locale, { name, count: items.length - 1 }),
|
|
466
|
-
amount: t("payment.checkout.free", locale, { count:
|
|
501
|
+
amount: t("payment.checkout.free", locale, { count: trialResult.count, interval: trialResult.interval }),
|
|
467
502
|
then: formatMeteredThen(subscription2, recurring, hasMetered && Number(subscription2) === 0, locale),
|
|
468
503
|
showThen: true,
|
|
469
504
|
actualAmount: "0"
|
|
@@ -485,10 +520,10 @@ export function formatCheckoutHeadlines(items, currency, trialInDays, locale = "
|
|
|
485
520
|
priceDisplay: formatPriceDisplay(result3, recurring, hasMetered, locale)
|
|
486
521
|
};
|
|
487
522
|
}
|
|
488
|
-
if (
|
|
523
|
+
if (trialResult.count > 0) {
|
|
489
524
|
const result3 = {
|
|
490
525
|
action: t("payment.checkout.try1", locale, { name }),
|
|
491
|
-
amount: t("payment.checkout.free", locale, { count:
|
|
526
|
+
amount: t("payment.checkout.free", locale, { count: trialResult.count, interval: trialResult.interval }),
|
|
492
527
|
then: formatMeteredThen(subscription2, recurring, hasMetered && Number(subscription2) === 0, locale),
|
|
493
528
|
showThen: true,
|
|
494
529
|
actualAmount: "0"
|
package/es/locales/en.js
CHANGED
|
@@ -60,9 +60,10 @@ export default flat({
|
|
|
60
60
|
continue: "Continue",
|
|
61
61
|
qty: "Qty {count}",
|
|
62
62
|
each: "{unit} each",
|
|
63
|
-
trial: "Free for {count}
|
|
63
|
+
trial: "Free for {count} {interval}{count > 1 ? 's' : ''}",
|
|
64
64
|
billed: "billed {rule}",
|
|
65
65
|
metered: "based on usage",
|
|
66
|
+
minute: "minute",
|
|
66
67
|
hour: "hour",
|
|
67
68
|
day: "day",
|
|
68
69
|
week: "week",
|
|
@@ -133,7 +134,7 @@ export default flat({
|
|
|
133
134
|
then: "Then {subscription} {recurring}",
|
|
134
135
|
meteredThen: "Then {recurring} based on usage",
|
|
135
136
|
metered: "{recurring} based on usage",
|
|
136
|
-
free: "{count}
|
|
137
|
+
free: "{count} {interval}{count > 1 ? 's' : ''} free",
|
|
137
138
|
least: "continue with at least",
|
|
138
139
|
completed: {
|
|
139
140
|
payment: "Thanks for your purchase",
|
package/es/locales/zh.js
CHANGED
|
@@ -60,9 +60,10 @@ export default flat({
|
|
|
60
60
|
continue: "\u7EE7\u7EED",
|
|
61
61
|
qty: "{count} \u4EF6",
|
|
62
62
|
each: "\u6BCF\u4EF6 {unit}",
|
|
63
|
-
trial: "\u514D\u8D39\u8BD5\u7528 {count}
|
|
63
|
+
trial: "\u514D\u8D39\u8BD5\u7528 {count} {interval}",
|
|
64
64
|
billed: "{rule}\u6536\u8D39",
|
|
65
65
|
metered: "\u6309\u7528\u91CF",
|
|
66
|
+
minute: "\u5206\u949F",
|
|
66
67
|
hour: "\u5C0F\u65F6",
|
|
67
68
|
day: "\u5929",
|
|
68
69
|
week: "\u5468",
|
|
@@ -133,7 +134,7 @@ export default flat({
|
|
|
133
134
|
then: "\u7136\u540E {subscription} {recurring}",
|
|
134
135
|
meteredThen: "\u7136\u540E{recurring}\u6309\u7528\u91CF\u8BA1\u8D39",
|
|
135
136
|
metered: "{recurring}\u6309\u7528\u91CF\u8BA1\u8D39",
|
|
136
|
-
free: "\u514D\u8D39\u8BD5\u7528 {count}
|
|
137
|
+
free: "\u514D\u8D39\u8BD5\u7528 {count} {interval}",
|
|
137
138
|
least: "\u81F3\u5C11",
|
|
138
139
|
completed: {
|
|
139
140
|
payment: "\u611F\u8C22\u60A8\u7684\u8D2D\u4E70",
|
|
@@ -61,16 +61,6 @@ const Root = styled("section")`
|
|
|
61
61
|
background: var(--backgrounds-bg-field, #f9fafb);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
// .cko-payment-card::before {
|
|
65
|
-
// content: '';
|
|
66
|
-
// position: absolute;
|
|
67
|
-
// right: 0;
|
|
68
|
-
// bottom: 0;
|
|
69
|
-
// border: 12px solid ${(props) => props.theme.palette.primary.main};
|
|
70
|
-
// border-top-color: transparent;
|
|
71
|
-
// border-left-color: transparent;
|
|
72
|
-
// }
|
|
73
|
-
|
|
74
64
|
.cko-payment-card-unselect {
|
|
75
65
|
border: 1px solid #ddd;
|
|
76
66
|
padding: 4px 8px;
|
package/es/payment/index.js
CHANGED
|
@@ -133,6 +133,7 @@ function PaymentInner({
|
|
|
133
133
|
{
|
|
134
134
|
items: state.checkoutSession.line_items,
|
|
135
135
|
trialInDays: state.checkoutSession.subscription_data?.trial_period_days || 0,
|
|
136
|
+
trialEnd: state.checkoutSession.subscription_data?.trial_end || 0,
|
|
136
137
|
billingThreshold: Math.max(
|
|
137
138
|
state.checkoutSession.subscription_data?.billing_threshold_amount || 0,
|
|
138
139
|
// @ts-ignore
|
|
@@ -321,23 +322,18 @@ export const Root = styled(Box)`
|
|
|
321
322
|
box-sizing: border-box;
|
|
322
323
|
display: flex;
|
|
323
324
|
flex-direction: column;
|
|
324
|
-
// justify-content: center;
|
|
325
325
|
align-items: center;
|
|
326
326
|
overflow: hidden;
|
|
327
|
-
// min-height: ${(props) => props.mode === "standalone" ? "100vh" : "auto"};
|
|
328
327
|
position: relative;
|
|
329
328
|
.cko-container {
|
|
330
329
|
overflow: hidden;
|
|
331
330
|
width: 100%;
|
|
332
|
-
// max-width: ${(props) => props.mode.endsWith("-minimal") ? "400px" : "1000px"};
|
|
333
331
|
display: flex;
|
|
334
332
|
flex-direction: row;
|
|
335
333
|
justify-content: center;
|
|
336
|
-
// gap: 4px;
|
|
337
334
|
position: relative;
|
|
338
335
|
flex: 1;
|
|
339
336
|
padding: 1px;
|
|
340
|
-
// padding: ${(props) => props.mode === "standalone" ? "0 16px" : "0"};
|
|
341
337
|
}
|
|
342
338
|
|
|
343
339
|
.base-card {
|
|
@@ -350,14 +346,11 @@ export const Root = styled(Box)`
|
|
|
350
346
|
}
|
|
351
347
|
|
|
352
348
|
.cko-overview {
|
|
353
|
-
// width: ${(props) => props.mode.endsWith("-minimal") ? "100%" : "400px"};
|
|
354
|
-
// min-height: ${(props) => props.mode === "standalone" ? "540px" : "auto"};
|
|
355
349
|
position: relative;
|
|
356
350
|
flex-direction: column;
|
|
357
351
|
display: ${(props) => props.mode.endsWith("-minimal") ? "none" : "flex"};
|
|
358
352
|
background: var(--backgrounds-bg-base);
|
|
359
353
|
min-height: 'auto';
|
|
360
|
-
// width: 502px;
|
|
361
354
|
}
|
|
362
355
|
.cko-header {
|
|
363
356
|
left: 0;
|
|
@@ -385,8 +378,6 @@ export const Root = styled(Box)`
|
|
|
385
378
|
|
|
386
379
|
.cko-payment {
|
|
387
380
|
width: 502px;
|
|
388
|
-
// width: ${(props) => props.mode.endsWith("-minimal") ? "100%" : "400px"};
|
|
389
|
-
// box-shadow: -4px 0px 8px 0px rgba(2, 7, 19, 0.04);
|
|
390
381
|
padding-left: ${(props) => props.mode === "standalone" ? "40px" : "20px"};
|
|
391
382
|
position: relative;
|
|
392
383
|
&:before {
|
|
@@ -411,10 +402,6 @@ export const Root = styled(Box)`
|
|
|
411
402
|
}
|
|
412
403
|
|
|
413
404
|
.cko-payment-form {
|
|
414
|
-
// .MuiInputAdornment-positionStart {
|
|
415
|
-
// width: 50px;
|
|
416
|
-
// }
|
|
417
|
-
|
|
418
405
|
.MuiFormLabel-root {
|
|
419
406
|
color: var(--foregrounds-fg-base, #010714);
|
|
420
407
|
font-weight: 500;
|
|
@@ -4,17 +4,19 @@ type Props = {
|
|
|
4
4
|
item: TLineItemExpanded;
|
|
5
5
|
items: TLineItemExpanded[];
|
|
6
6
|
trialInDays: number;
|
|
7
|
+
trialEnd?: number;
|
|
7
8
|
currency: TPaymentCurrency;
|
|
8
9
|
onUpsell: Function;
|
|
9
10
|
onDownsell: Function;
|
|
10
11
|
mode?: 'normal' | 'cross-sell';
|
|
11
12
|
children?: React.ReactNode;
|
|
12
13
|
};
|
|
13
|
-
declare function ProductItem({ item, items, trialInDays, currency, mode, children, onUpsell, onDownsell, }: Props): JSX.Element;
|
|
14
|
+
declare function ProductItem({ item, items, trialInDays, trialEnd, currency, mode, children, onUpsell, onDownsell, }: Props): JSX.Element;
|
|
14
15
|
declare namespace ProductItem {
|
|
15
16
|
var defaultProps: {
|
|
16
17
|
mode: string;
|
|
17
18
|
children: null;
|
|
19
|
+
trialEnd: number;
|
|
18
20
|
};
|
|
19
21
|
}
|
|
20
22
|
export default ProductItem;
|
|
@@ -12,14 +12,17 @@ import {
|
|
|
12
12
|
formatUpsellSaving
|
|
13
13
|
} from "../libs/util.js";
|
|
14
14
|
import ProductCard from "./product-card.js";
|
|
15
|
+
import dayjs from "../libs/dayjs.js";
|
|
15
16
|
ProductItem.defaultProps = {
|
|
16
17
|
mode: "normal",
|
|
17
|
-
children: null
|
|
18
|
+
children: null,
|
|
19
|
+
trialEnd: 0
|
|
18
20
|
};
|
|
19
21
|
export default function ProductItem({
|
|
20
22
|
item,
|
|
21
23
|
items,
|
|
22
24
|
trialInDays,
|
|
25
|
+
trialEnd = 0,
|
|
23
26
|
currency,
|
|
24
27
|
mode,
|
|
25
28
|
children,
|
|
@@ -27,18 +30,19 @@ export default function ProductItem({
|
|
|
27
30
|
onDownsell
|
|
28
31
|
}) {
|
|
29
32
|
const { t, locale } = useLocaleContext();
|
|
30
|
-
const pricing = formatLineItemPricing(item, currency, trialInDays, locale);
|
|
33
|
+
const pricing = formatLineItemPricing(item, currency, { trialEnd, trialInDays }, locale);
|
|
31
34
|
const saving = formatUpsellSaving(items, currency);
|
|
32
35
|
const metered = item.price?.recurring?.usage_type === "metered" ? t("common.metered") : "";
|
|
33
36
|
const canUpsell = mode === "normal" && items.length === 1;
|
|
34
37
|
const primaryText = useMemo(() => {
|
|
35
38
|
const price = item.upsell_price || item.price || {};
|
|
36
39
|
const isRecurring = price?.type === "recurring" && price?.recurring;
|
|
37
|
-
|
|
40
|
+
const trial = trialInDays > 0 || trialEnd > dayjs().unix();
|
|
41
|
+
if (isRecurring && !trial && price?.recurring?.usage_type !== "metered") {
|
|
38
42
|
return `${pricing.primary} ${price.recurring ? formatRecurring(price.recurring, false, "slash", locale) : ""}`;
|
|
39
43
|
}
|
|
40
44
|
return pricing.primary;
|
|
41
|
-
}, [trialInDays, pricing, item, locale]);
|
|
45
|
+
}, [trialInDays, trialEnd, pricing, item, locale]);
|
|
42
46
|
return /* @__PURE__ */ jsxs(Stack, { direction: "column", alignItems: "flex-start", spacing: 1, sx: { width: "100%" }, className: "product-item", children: [
|
|
43
47
|
/* @__PURE__ */ jsxs(Stack, { direction: "column", alignItems: "flex-start", sx: { width: "100%" }, className: "product-item-content", children: [
|
|
44
48
|
/* @__PURE__ */ jsxs(
|
package/es/payment/summary.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ type Props = {
|
|
|
4
4
|
items: TLineItemExpanded[];
|
|
5
5
|
currency: TPaymentCurrency;
|
|
6
6
|
trialInDays: number;
|
|
7
|
+
trialEnd?: number;
|
|
7
8
|
billingThreshold: number;
|
|
8
9
|
showStaking?: boolean;
|
|
9
10
|
onUpsell?: Function;
|
|
@@ -16,7 +17,7 @@ type Props = {
|
|
|
16
17
|
donationSettings?: DonationSettings;
|
|
17
18
|
action?: string;
|
|
18
19
|
};
|
|
19
|
-
declare function PaymentSummary({ items, currency, trialInDays, billingThreshold, onUpsell, onDownsell, onApplyCrossSell, onCancelCrossSell, onChangeAmount, checkoutSessionId, crossSellBehavior, showStaking, donationSettings, action, ...rest }: Props): import("react").JSX.Element;
|
|
20
|
+
declare function PaymentSummary({ items, currency, trialInDays, billingThreshold, onUpsell, onDownsell, onApplyCrossSell, onCancelCrossSell, onChangeAmount, checkoutSessionId, crossSellBehavior, showStaking, donationSettings, action, trialEnd, ...rest }: Props): import("react").JSX.Element;
|
|
20
21
|
declare namespace PaymentSummary {
|
|
21
22
|
var defaultProps: {
|
|
22
23
|
onUpsell: any;
|
|
@@ -29,6 +30,7 @@ declare namespace PaymentSummary {
|
|
|
29
30
|
showStaking: boolean;
|
|
30
31
|
donationSettings: null;
|
|
31
32
|
action: string;
|
|
33
|
+
trialEnd: number;
|
|
32
34
|
};
|
|
33
35
|
}
|
|
34
36
|
export default PaymentSummary;
|
package/es/payment/summary.js
CHANGED
|
@@ -83,7 +83,8 @@ PaymentSummary.defaultProps = {
|
|
|
83
83
|
crossSellBehavior: "",
|
|
84
84
|
showStaking: false,
|
|
85
85
|
donationSettings: null,
|
|
86
|
-
action: ""
|
|
86
|
+
action: "",
|
|
87
|
+
trialEnd: 0
|
|
87
88
|
};
|
|
88
89
|
export default function PaymentSummary({
|
|
89
90
|
items,
|
|
@@ -100,6 +101,7 @@ export default function PaymentSummary({
|
|
|
100
101
|
showStaking,
|
|
101
102
|
donationSettings,
|
|
102
103
|
action,
|
|
104
|
+
trialEnd = 0,
|
|
103
105
|
...rest
|
|
104
106
|
}) {
|
|
105
107
|
const { t, locale } = useLocaleContext();
|
|
@@ -109,7 +111,7 @@ export default function PaymentSummary({
|
|
|
109
111
|
const { data, runAsync } = useRequest(
|
|
110
112
|
() => checkoutSessionId ? fetchCrossSell(checkoutSessionId) : Promise.resolve(null)
|
|
111
113
|
);
|
|
112
|
-
const headlines = formatCheckoutHeadlines(items, currency, trialInDays, locale);
|
|
114
|
+
const headlines = formatCheckoutHeadlines(items, currency, { trialEnd, trialInDays }, locale);
|
|
113
115
|
const staking = showStaking ? getStakingSetup(items, currency, billingThreshold) : "0";
|
|
114
116
|
const totalAmount = fromUnitToToken(
|
|
115
117
|
new BN(fromTokenToUnit(headlines.actualAmount, currency?.decimal)).add(new BN(staking)).toString(),
|
|
@@ -180,6 +182,7 @@ export default function PaymentSummary({
|
|
|
180
182
|
item: x,
|
|
181
183
|
items,
|
|
182
184
|
trialInDays,
|
|
185
|
+
trialEnd,
|
|
183
186
|
currency,
|
|
184
187
|
onUpsell: handleUpsell,
|
|
185
188
|
onDownsell: handleDownsell,
|
|
@@ -209,6 +212,7 @@ export default function PaymentSummary({
|
|
|
209
212
|
items,
|
|
210
213
|
trialInDays,
|
|
211
214
|
currency,
|
|
215
|
+
trialEnd,
|
|
212
216
|
onUpsell: noop,
|
|
213
217
|
onDownsell: noop,
|
|
214
218
|
children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", justifyContent: "space-between", sx: { width: 1 }, children: [
|
package/lib/components/table.js
CHANGED
|
@@ -36,8 +36,8 @@ const Table = _react.default.memo(({
|
|
|
36
36
|
download: false,
|
|
37
37
|
filter: false,
|
|
38
38
|
selectableRows: "none",
|
|
39
|
-
rowsPerPage: 10,
|
|
40
|
-
rowsPerPageOptions: [10, 20, 50, 100],
|
|
39
|
+
rowsPerPage: isMobile ? 5 : 10,
|
|
40
|
+
rowsPerPageOptions: [5, 10, 20, 50, 100],
|
|
41
41
|
searchDebounceTime: 300,
|
|
42
42
|
tableBodyHeight: "100%",
|
|
43
43
|
loading: true
|
|
@@ -118,6 +118,8 @@ const Wrapped = (0, _system.styled)(_Datatable.default)`
|
|
|
118
118
|
}
|
|
119
119
|
td.MuiTableCell-root {
|
|
120
120
|
border-bottom: none;
|
|
121
|
+
padding-top: 12px;
|
|
122
|
+
padding-bottom: 12px;
|
|
121
123
|
&:first-of-type {
|
|
122
124
|
padding-left: 20px;
|
|
123
125
|
}
|
|
@@ -155,6 +157,10 @@ const Wrapped = (0, _system.styled)(_Datatable.default)`
|
|
|
155
157
|
> div {
|
|
156
158
|
overflow: auto;
|
|
157
159
|
}
|
|
160
|
+
.custom-toobar-title-inner {
|
|
161
|
+
display: flex;
|
|
162
|
+
align-items: center;
|
|
163
|
+
}
|
|
158
164
|
@media (max-width: ${({
|
|
159
165
|
theme
|
|
160
166
|
}) => theme.breakpoints.values.md}px) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useDefaultPageSize(pageSize?: number): number;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useDefaultPageSize = useDefaultPageSize;
|
|
7
|
+
var _mobile = require("./mobile");
|
|
8
|
+
function useDefaultPageSize(pageSize = 10) {
|
|
9
|
+
const {
|
|
10
|
+
isMobile
|
|
11
|
+
} = (0, _mobile.useMobile)();
|
|
12
|
+
return isMobile ? 5 : pageSize;
|
|
13
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -31,5 +31,6 @@ export * from './libs/connect';
|
|
|
31
31
|
export * from './contexts/payment';
|
|
32
32
|
export * from './hooks/subscription';
|
|
33
33
|
export * from './hooks/mobile';
|
|
34
|
+
export * from './hooks/table';
|
|
34
35
|
export { translations, createTranslator } from './locales';
|
|
35
36
|
export { api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, TxLink, TxGas, SafeGuard, PricingItem, CountrySelect, Table, };
|
package/lib/index.js
CHANGED
|
@@ -303,5 +303,17 @@ Object.keys(_mobile).forEach(function (key) {
|
|
|
303
303
|
}
|
|
304
304
|
});
|
|
305
305
|
});
|
|
306
|
+
var _table3 = require("./hooks/table");
|
|
307
|
+
Object.keys(_table3).forEach(function (key) {
|
|
308
|
+
if (key === "default" || key === "__esModule") return;
|
|
309
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
310
|
+
if (key in exports && exports[key] === _table3[key]) return;
|
|
311
|
+
Object.defineProperty(exports, key, {
|
|
312
|
+
enumerable: true,
|
|
313
|
+
get: function () {
|
|
314
|
+
return _table3[key];
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
});
|
|
306
318
|
var _locales = require("./locales");
|
|
307
319
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/lib/libs/util.d.ts
CHANGED
|
@@ -19,7 +19,10 @@ export declare function getStatementDescriptor(items: any[]): any;
|
|
|
19
19
|
export declare function formatRecurring(recurring: PriceRecurring, translate?: boolean, separator?: string, locale?: string): string;
|
|
20
20
|
export declare function getPriceUintAmountByCurrency(price: TPrice, currency: TPaymentCurrency): string;
|
|
21
21
|
export declare function getPriceCurrencyOptions(price: TPrice): PriceCurrency[];
|
|
22
|
-
export declare function formatLineItemPricing(item: TLineItemExpanded, currency: TPaymentCurrency,
|
|
22
|
+
export declare function formatLineItemPricing(item: TLineItemExpanded, currency: TPaymentCurrency, { trialEnd, trialInDays }: {
|
|
23
|
+
trialEnd: number;
|
|
24
|
+
trialInDays: number;
|
|
25
|
+
}, locale?: string): {
|
|
23
26
|
primary: string;
|
|
24
27
|
secondary?: string;
|
|
25
28
|
quantity: string;
|
|
@@ -47,7 +50,17 @@ export declare function formatPriceDisplay({ amount, then, actualAmount, showThe
|
|
|
47
50
|
actualAmount: string;
|
|
48
51
|
showThen?: boolean;
|
|
49
52
|
}, recurring: string, hasMetered: boolean, locale?: string): string;
|
|
50
|
-
export declare function
|
|
53
|
+
export declare function getFreeTrialTime({ trialInDays, trialEnd }: {
|
|
54
|
+
trialInDays: number;
|
|
55
|
+
trialEnd: number;
|
|
56
|
+
}, locale?: string): {
|
|
57
|
+
count: number;
|
|
58
|
+
interval: string;
|
|
59
|
+
};
|
|
60
|
+
export declare function formatCheckoutHeadlines(items: TLineItemExpanded[], currency: TPaymentCurrency, { trialInDays, trialEnd }: {
|
|
61
|
+
trialInDays: number;
|
|
62
|
+
trialEnd: number;
|
|
63
|
+
}, locale?: string): {
|
|
51
64
|
action: string;
|
|
52
65
|
amount: string;
|
|
53
66
|
then?: string;
|