@blocklet/payment-react 1.14.30 → 1.14.32
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/table.js +3 -2
- package/es/components/pricing-table.js +2 -1
- package/es/components/truncated-text.d.ts +15 -0
- package/es/components/truncated-text.js +27 -0
- package/es/history/invoice/list.js +14 -4
- package/es/index.d.ts +2 -1
- package/es/index.js +3 -1
- package/es/libs/util.d.ts +1 -0
- package/es/libs/util.js +26 -0
- package/es/locales/en.js +3 -1
- package/es/locales/zh.js +3 -1
- package/es/payment/form/index.js +1 -2
- package/es/payment/summary.js +2 -18
- package/es/theme/index.js +5 -0
- package/lib/checkout/table.js +8 -2
- package/lib/components/pricing-table.js +6 -1
- package/lib/components/truncated-text.d.ts +15 -0
- package/lib/components/truncated-text.js +55 -0
- package/lib/history/invoice/list.js +8 -3
- package/lib/index.d.ts +2 -1
- package/lib/index.js +8 -0
- package/lib/libs/util.d.ts +1 -0
- package/lib/libs/util.js +27 -0
- package/lib/locales/en.js +3 -1
- package/lib/locales/zh.js +3 -1
- package/lib/payment/form/index.js +3 -7
- package/lib/payment/summary.js +2 -6
- package/lib/theme/index.js +5 -0
- package/package.json +8 -8
- package/src/checkout/table.tsx +3 -2
- package/src/components/pricing-table.tsx +2 -1
- package/src/components/truncated-text.tsx +41 -0
- package/src/history/invoice/list.tsx +9 -4
- package/src/index.ts +2 -0
- package/src/libs/util.ts +33 -0
- package/src/locales/en.tsx +3 -0
- package/src/locales/zh.tsx +2 -0
- package/src/payment/form/index.tsx +1 -5
- package/src/payment/summary.tsx +2 -8
- package/src/theme/index.tsx +5 -0
package/es/checkout/table.js
CHANGED
|
@@ -11,6 +11,7 @@ import api from "../libs/api.js";
|
|
|
11
11
|
import { mergeExtraParams } from "../libs/util.js";
|
|
12
12
|
import CheckoutForm from "./form.js";
|
|
13
13
|
import { PaymentThemeProvider } from "../theme/index.js";
|
|
14
|
+
import TruncatedText from "../components/truncated-text.js";
|
|
14
15
|
const fetchData = async (id) => {
|
|
15
16
|
const { data } = await api.get(`/api/pricing-tables/${id}`);
|
|
16
17
|
return data;
|
|
@@ -85,7 +86,7 @@ function CheckoutTableInner({ id, mode, onPaid, onError, onChange, extraParams,
|
|
|
85
86
|
textAlign: "center"
|
|
86
87
|
},
|
|
87
88
|
children: [
|
|
88
|
-
!data.livemode && /* @__PURE__ */ jsx(Livemode, { sx: { display: "flex", marginBottom: "8px", width: "fit-content" } }),
|
|
89
|
+
!data.livemode && /* @__PURE__ */ jsx(Livemode, { sx: { display: "flex", marginBottom: "8px", width: "fit-content", ml: 0 } }),
|
|
89
90
|
/* @__PURE__ */ jsx(
|
|
90
91
|
Typography,
|
|
91
92
|
{
|
|
@@ -95,7 +96,7 @@ function CheckoutTableInner({ id, mode, onPaid, onError, onChange, extraParams,
|
|
|
95
96
|
lineHeight: "32px",
|
|
96
97
|
fontSize: "24px"
|
|
97
98
|
},
|
|
98
|
-
children: data.name
|
|
99
|
+
children: /* @__PURE__ */ jsx(TruncatedText, { text: data.name, maxLength: 60, useWidth: true })
|
|
99
100
|
}
|
|
100
101
|
)
|
|
101
102
|
]
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
} from "../libs/util.js";
|
|
33
33
|
import Amount from "../payment/amount.js";
|
|
34
34
|
import { useMobile } from "../hooks/mobile.js";
|
|
35
|
+
import TruncatedText from "./truncated-text.js";
|
|
35
36
|
const sortOrder = {
|
|
36
37
|
year: 1,
|
|
37
38
|
month: 2,
|
|
@@ -294,7 +295,7 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
|
|
|
294
295
|
fontSize: "18px !important",
|
|
295
296
|
fontWeight: "600"
|
|
296
297
|
},
|
|
297
|
-
children: x.product.name
|
|
298
|
+
children: /* @__PURE__ */ jsx(TruncatedText, { text: x.product.name, maxLength: 26, useWidth: true })
|
|
298
299
|
}
|
|
299
300
|
),
|
|
300
301
|
x.is_highlight && /* @__PURE__ */ jsx(
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface TruncatedTextProps {
|
|
3
|
+
text?: string;
|
|
4
|
+
maxLength?: number;
|
|
5
|
+
useWidth?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare function TruncatedText({ text, maxLength, useWidth }: TruncatedTextProps): import("react").JSX.Element | null;
|
|
8
|
+
declare namespace TruncatedText {
|
|
9
|
+
var defaultProps: {
|
|
10
|
+
useWidth: boolean;
|
|
11
|
+
text: string;
|
|
12
|
+
maxLength: number;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export default TruncatedText;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Tooltip, tooltipClasses } from "@mui/material";
|
|
3
|
+
import { styled } from "@mui/system";
|
|
4
|
+
import { truncateText } from "../libs/util.js";
|
|
5
|
+
const CustomTooltip = styled(({ className, ...props }) => /* @__PURE__ */ jsx(Tooltip, { ...props, classes: { popper: className } }))({
|
|
6
|
+
[`& .${tooltipClasses.tooltip}`]: {
|
|
7
|
+
fontSize: 11,
|
|
8
|
+
maxHeight: 120,
|
|
9
|
+
maxWidth: 500,
|
|
10
|
+
overflowY: "auto"
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
export default function TruncatedText({ text = "", maxLength = 100, useWidth = false }) {
|
|
14
|
+
if (!text) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const truncatedText = truncateText(text, maxLength, useWidth);
|
|
18
|
+
if (!truncatedText.endsWith("...")) {
|
|
19
|
+
return /* @__PURE__ */ jsx("span", { children: truncatedText });
|
|
20
|
+
}
|
|
21
|
+
return /* @__PURE__ */ jsx(CustomTooltip, { title: text, placement: "bottom", enterTouchDelay: 0, children: /* @__PURE__ */ jsx("span", { title: text, children: truncatedText }) });
|
|
22
|
+
}
|
|
23
|
+
TruncatedText.defaultProps = {
|
|
24
|
+
useWidth: false,
|
|
25
|
+
text: "",
|
|
26
|
+
maxLength: 100
|
|
27
|
+
};
|
|
@@ -96,7 +96,7 @@ const InvoiceTable = React.memo((props) => {
|
|
|
96
96
|
{
|
|
97
97
|
label: t("common.amount"),
|
|
98
98
|
name: "total",
|
|
99
|
-
width:
|
|
99
|
+
width: 80,
|
|
100
100
|
align: "right",
|
|
101
101
|
options: {
|
|
102
102
|
customBodyRenderLite: (_, index) => {
|
|
@@ -146,9 +146,8 @@ const InvoiceTable = React.memo((props) => {
|
|
|
146
146
|
},
|
|
147
147
|
{
|
|
148
148
|
label: t("common.status"),
|
|
149
|
-
name: "
|
|
149
|
+
name: "status",
|
|
150
150
|
options: {
|
|
151
|
-
sort: true,
|
|
152
151
|
customBodyRenderLite: (val, index) => {
|
|
153
152
|
const invoice = data?.list[index];
|
|
154
153
|
const link = getInvoiceLink(invoice, action);
|
|
@@ -300,7 +299,17 @@ const InvoiceList = React.memo((props) => {
|
|
|
300
299
|
] }) }),
|
|
301
300
|
/* @__PURE__ */ jsx(Box, { flex: 1, textAlign: "right", children: /* @__PURE__ */ jsx(Typography, { children: formatToDate(invoice.created_at, locale, "HH:mm:ss") }) }),
|
|
302
301
|
!action && /* @__PURE__ */ jsx(Hidden, { mdDown: true, children: /* @__PURE__ */ jsx(Box, { flex: 2, className: "invoice-description", textAlign: "right", children: /* @__PURE__ */ jsx(Typography, { children: invoice.description || invoice.id }) }) }),
|
|
303
|
-
/* @__PURE__ */ jsx(Box, { flex: 1, textAlign: "right", children: action ? link.connect ? /* @__PURE__ */ jsx(
|
|
302
|
+
/* @__PURE__ */ jsx(Box, { flex: 1, textAlign: "right", children: action ? link.connect ? /* @__PURE__ */ jsx(
|
|
303
|
+
Button,
|
|
304
|
+
{
|
|
305
|
+
variant: "contained",
|
|
306
|
+
color: "primary",
|
|
307
|
+
size: "small",
|
|
308
|
+
onClick: () => onPay(invoice.id),
|
|
309
|
+
sx: { whiteSpace: "nowrap" },
|
|
310
|
+
children: t("payment.customer.invoice.pay")
|
|
311
|
+
}
|
|
312
|
+
) : /* @__PURE__ */ jsx(
|
|
304
313
|
Button,
|
|
305
314
|
{
|
|
306
315
|
component: "a",
|
|
@@ -308,6 +317,7 @@ const InvoiceList = React.memo((props) => {
|
|
|
308
317
|
size: "small",
|
|
309
318
|
href: link.url,
|
|
310
319
|
target: link.external ? "_blank" : target,
|
|
320
|
+
sx: { whiteSpace: "nowrap" },
|
|
311
321
|
rel: "noreferrer",
|
|
312
322
|
children: t("payment.customer.invoice.pay")
|
|
313
323
|
}
|
package/es/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ import ProductSkeleton from './payment/product-skeleton';
|
|
|
25
25
|
import PaymentSummary from './payment/summary';
|
|
26
26
|
import PricingItem from './components/pricing-item';
|
|
27
27
|
import CountrySelect from './components/country-select';
|
|
28
|
+
import TruncatedText from './components/truncated-text';
|
|
28
29
|
export { PaymentThemeProvider } from './theme';
|
|
29
30
|
export * from './libs/util';
|
|
30
31
|
export * from './libs/connect';
|
|
@@ -33,4 +34,4 @@ export * from './hooks/subscription';
|
|
|
33
34
|
export * from './hooks/mobile';
|
|
34
35
|
export * from './hooks/table';
|
|
35
36
|
export { translations, createTranslator } from './locales';
|
|
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, };
|
|
37
|
+
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, TruncatedText, };
|
package/es/index.js
CHANGED
|
@@ -25,6 +25,7 @@ import ProductSkeleton from "./payment/product-skeleton.js";
|
|
|
25
25
|
import PaymentSummary from "./payment/summary.js";
|
|
26
26
|
import PricingItem from "./components/pricing-item.js";
|
|
27
27
|
import CountrySelect from "./components/country-select.js";
|
|
28
|
+
import TruncatedText from "./components/truncated-text.js";
|
|
28
29
|
export { PaymentThemeProvider } from "./theme/index.js";
|
|
29
30
|
export * from "./libs/util.js";
|
|
30
31
|
export * from "./libs/connect.js";
|
|
@@ -60,5 +61,6 @@ export {
|
|
|
60
61
|
SafeGuard,
|
|
61
62
|
PricingItem,
|
|
62
63
|
CountrySelect,
|
|
63
|
-
Table
|
|
64
|
+
Table,
|
|
65
|
+
TruncatedText
|
|
64
66
|
};
|
package/es/libs/util.d.ts
CHANGED
|
@@ -106,3 +106,4 @@ export declare function formatSubscriptionStatus(status: string): string;
|
|
|
106
106
|
export declare function formatAmountPrecisionLimit(amount: string, locale?: string, precision?: number): string;
|
|
107
107
|
export declare function getWordBreakStyle(value: any): 'break-word' | 'break-all';
|
|
108
108
|
export declare function isMobileSafari(): boolean;
|
|
109
|
+
export declare function truncateText(text: string, maxLength: number, useWidth?: boolean): string;
|
package/es/libs/util.js
CHANGED
|
@@ -2,6 +2,7 @@ import { BN, fromUnitToToken } from "@ocap/util";
|
|
|
2
2
|
import omit from "lodash/omit";
|
|
3
3
|
import trimEnd from "lodash/trimEnd";
|
|
4
4
|
import numbro from "numbro";
|
|
5
|
+
import stringWidth from "string-width";
|
|
5
6
|
import { defaultCountries } from "react-international-phone";
|
|
6
7
|
import { joinURL } from "ufo";
|
|
7
8
|
import { t } from "../locales/index.js";
|
|
@@ -812,3 +813,28 @@ export function isMobileSafari() {
|
|
|
812
813
|
const isIOS = /iphone|ipad|ipod/.test(ua);
|
|
813
814
|
return isSafari && isMobile && isIOS;
|
|
814
815
|
}
|
|
816
|
+
export function truncateText(text, maxLength, useWidth = false) {
|
|
817
|
+
if (!text || !maxLength) {
|
|
818
|
+
return text;
|
|
819
|
+
}
|
|
820
|
+
if (!useWidth) {
|
|
821
|
+
if (text.length <= maxLength) {
|
|
822
|
+
return text;
|
|
823
|
+
}
|
|
824
|
+
return `${text.substring(0, maxLength)}...`;
|
|
825
|
+
}
|
|
826
|
+
let width = 0;
|
|
827
|
+
let truncated = "";
|
|
828
|
+
for (let i = 0; i < text.length; i++) {
|
|
829
|
+
const charWidth = stringWidth(text.charAt(i));
|
|
830
|
+
if (width + charWidth > maxLength) {
|
|
831
|
+
break;
|
|
832
|
+
}
|
|
833
|
+
truncated += text.charAt(i);
|
|
834
|
+
width += charWidth;
|
|
835
|
+
}
|
|
836
|
+
if (truncated === text) {
|
|
837
|
+
return truncated;
|
|
838
|
+
}
|
|
839
|
+
return `${truncated}...`;
|
|
840
|
+
}
|
package/es/locales/en.js
CHANGED
|
@@ -202,6 +202,7 @@ export default flat({
|
|
|
202
202
|
title: "Cancel your subscription",
|
|
203
203
|
comment: "Any additional feedback?",
|
|
204
204
|
description: "Your subscription will be canceled, but it is still available until the end of your current billing period on {date}",
|
|
205
|
+
trialDescription: "Free trial subscriptions will be canceled immediately and no longer available, confirm to continue",
|
|
205
206
|
feedback: {
|
|
206
207
|
tip: "We would love your feedback, it will help us improve our service",
|
|
207
208
|
too_expensive: "The service is too expensive",
|
|
@@ -303,7 +304,8 @@ export default flat({
|
|
|
303
304
|
threshold: "Metered usage billing",
|
|
304
305
|
cancel: "Subscription cancel",
|
|
305
306
|
manual: "Manual invoice",
|
|
306
|
-
upcoming: "Upcoming invoice"
|
|
307
|
+
upcoming: "Upcoming invoice",
|
|
308
|
+
slashStake: "Slash stake"
|
|
307
309
|
}
|
|
308
310
|
}
|
|
309
311
|
},
|
package/es/locales/zh.js
CHANGED
|
@@ -202,6 +202,7 @@ export default flat({
|
|
|
202
202
|
title: "\u53D6\u6D88\u60A8\u7684\u8BA2\u9605",
|
|
203
203
|
comment: "\u4F60\u8FD8\u6709\u5176\u4ED6\u53CD\u9988\u4E48\uFF1F",
|
|
204
204
|
description: "\u60A8\u7684\u8BA2\u9605\u5C06\u88AB\u53D6\u6D88\uFF0C\u4F46\u4ECD\u7136\u53EF\u7528\u76F4\u5230\u60A8\u5F53\u524D\u8BA1\u8D39\u5468\u671F\u7ED3\u675F\u4E8E{date}",
|
|
205
|
+
trialDescription: "\u514D\u8D39\u8BD5\u7528\u7684\u8BA2\u9605\u5C06\u88AB\u7ACB\u5373\u53D6\u6D88\uFF0C\u4E0D\u518D\u53EF\u7528\uFF0C\u786E\u8BA4\u662F\u5426\u7EE7\u7EED",
|
|
205
206
|
feedback: {
|
|
206
207
|
tip: "\u6211\u4EEC\u5E0C\u671B\u542C\u5230\u60A8\u7684\u53CD\u9988\uFF0C\u8FD9\u5C06\u5E2E\u52A9\u6211\u4EEC\u6539\u8FDB\u6211\u4EEC\u7684\u670D\u52A1",
|
|
207
208
|
too_expensive: "\u670D\u52A1\u8D39\u7528\u592A\u9AD8",
|
|
@@ -303,7 +304,8 @@ export default flat({
|
|
|
303
304
|
threshold: "\u7528\u91CF\u8D26\u5355",
|
|
304
305
|
cancel: "\u8BA2\u9605\u53D6\u6D88",
|
|
305
306
|
manual: "\u4EBA\u5DE5\u8D26\u5355",
|
|
306
|
-
upcoming: "\u672A\u6765\u8D26\u5355"
|
|
307
|
+
upcoming: "\u672A\u6765\u8D26\u5355",
|
|
308
|
+
slashStake: "\u7F5A\u6CA1\u8D28\u62BC"
|
|
307
309
|
}
|
|
308
310
|
}
|
|
309
311
|
},
|
package/es/payment/form/index.js
CHANGED
|
@@ -331,7 +331,7 @@ export default function PaymentForm({
|
|
|
331
331
|
children: t("payment.checkout.paymentDetails")
|
|
332
332
|
}
|
|
333
333
|
),
|
|
334
|
-
/* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { direction: "column", alignItems: "flex-start", className: "cko-payment-methods", children: [
|
|
334
|
+
/* @__PURE__ */ jsx(Fade, { in: true, children: /* @__PURE__ */ jsxs(Stack, { direction: "column", alignItems: "flex-start", className: "cko-payment-methods", sx: { mb: 1 }, children: [
|
|
335
335
|
/* @__PURE__ */ jsx(Stack, { direction: "row", sx: { width: "100%" }, children: /* @__PURE__ */ jsx(
|
|
336
336
|
Controller,
|
|
337
337
|
{
|
|
@@ -360,7 +360,6 @@ export default function PaymentForm({
|
|
|
360
360
|
}
|
|
361
361
|
)
|
|
362
362
|
] }) }),
|
|
363
|
-
/* @__PURE__ */ jsx(Stack, { direction: "row", sx: { mb: 1 }, alignItems: "center", justifyContent: "space-between" }),
|
|
364
363
|
/* @__PURE__ */ jsxs(
|
|
365
364
|
Stack,
|
|
366
365
|
{
|
package/es/payment/summary.js
CHANGED
|
@@ -277,30 +277,14 @@ export default function PaymentSummary({
|
|
|
277
277
|
/* @__PURE__ */ jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 1, children: [
|
|
278
278
|
/* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
|
|
279
279
|
/* @__PURE__ */ jsx(Typography, { sx: { color: "text.secondary" }, children: t("payment.checkout.paymentRequired") }),
|
|
280
|
-
/* @__PURE__ */ jsx(
|
|
281
|
-
Tooltip,
|
|
282
|
-
{
|
|
283
|
-
title: /* @__PURE__ */ jsx(Typography, { children: t("payment.checkout.stakingConfirm") }),
|
|
284
|
-
placement: "top",
|
|
285
|
-
sx: { maxWidth: "150px" },
|
|
286
|
-
children: /* @__PURE__ */ jsx(HelpOutline, { fontSize: "small", sx: { color: "text.lighter" } })
|
|
287
|
-
}
|
|
288
|
-
)
|
|
280
|
+
/* @__PURE__ */ jsx(Tooltip, { title: t("payment.checkout.stakingConfirm"), placement: "top", sx: { maxWidth: "150px" }, children: /* @__PURE__ */ jsx(HelpOutline, { fontSize: "small", sx: { color: "text.lighter" } }) })
|
|
289
281
|
] }),
|
|
290
282
|
/* @__PURE__ */ jsx(Typography, { children: headlines.amount })
|
|
291
283
|
] }),
|
|
292
284
|
/* @__PURE__ */ jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 1, children: [
|
|
293
285
|
/* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
|
|
294
286
|
/* @__PURE__ */ jsx(Typography, { sx: { color: "text.secondary" }, children: t("payment.checkout.staking.title") }),
|
|
295
|
-
/* @__PURE__ */ jsx(
|
|
296
|
-
Tooltip,
|
|
297
|
-
{
|
|
298
|
-
title: /* @__PURE__ */ jsx(Typography, { children: t("payment.checkout.staking.tooltip") }),
|
|
299
|
-
placement: "top",
|
|
300
|
-
sx: { maxWidth: "150px" },
|
|
301
|
-
children: /* @__PURE__ */ jsx(HelpOutline, { fontSize: "small", sx: { color: "text.lighter" } })
|
|
302
|
-
}
|
|
303
|
-
)
|
|
287
|
+
/* @__PURE__ */ jsx(Tooltip, { title: t("payment.checkout.staking.tooltip"), placement: "top", sx: { maxWidth: "150px" }, children: /* @__PURE__ */ jsx(HelpOutline, { fontSize: "small", sx: { color: "text.lighter" } }) })
|
|
304
288
|
] }),
|
|
305
289
|
/* @__PURE__ */ jsxs(Typography, { children: [
|
|
306
290
|
formatAmount(staking, currency.decimal),
|
package/es/theme/index.js
CHANGED
package/lib/checkout/table.js
CHANGED
|
@@ -17,6 +17,7 @@ var _api = _interopRequireDefault(require("../libs/api"));
|
|
|
17
17
|
var _util = require("../libs/util");
|
|
18
18
|
var _form = _interopRequireDefault(require("./form"));
|
|
19
19
|
var _theme = require("../theme");
|
|
20
|
+
var _truncatedText = _interopRequireDefault(require("../components/truncated-text"));
|
|
20
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
22
|
const fetchData = async id => {
|
|
22
23
|
const {
|
|
@@ -120,7 +121,8 @@ function CheckoutTableInner({
|
|
|
120
121
|
sx: {
|
|
121
122
|
display: "flex",
|
|
122
123
|
marginBottom: "8px",
|
|
123
|
-
width: "fit-content"
|
|
124
|
+
width: "fit-content",
|
|
125
|
+
ml: 0
|
|
124
126
|
}
|
|
125
127
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
126
128
|
color: "text.primary",
|
|
@@ -129,7 +131,11 @@ function CheckoutTableInner({
|
|
|
129
131
|
lineHeight: "32px",
|
|
130
132
|
fontSize: "24px"
|
|
131
133
|
},
|
|
132
|
-
children:
|
|
134
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_truncatedText.default, {
|
|
135
|
+
text: data.name,
|
|
136
|
+
maxLength: 60,
|
|
137
|
+
useWidth: true
|
|
138
|
+
})
|
|
133
139
|
})]
|
|
134
140
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_pricingTable.default, {
|
|
135
141
|
table: data,
|
|
@@ -19,6 +19,7 @@ var _payment = require("../contexts/payment");
|
|
|
19
19
|
var _util2 = require("../libs/util");
|
|
20
20
|
var _amount = _interopRequireDefault(require("../payment/amount"));
|
|
21
21
|
var _mobile = require("../hooks/mobile");
|
|
22
|
+
var _truncatedText = _interopRequireDefault(require("./truncated-text"));
|
|
22
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
24
|
const sortOrder = {
|
|
24
25
|
year: 1,
|
|
@@ -318,7 +319,11 @@ function PricingTable({
|
|
|
318
319
|
fontSize: "18px !important",
|
|
319
320
|
fontWeight: "600"
|
|
320
321
|
},
|
|
321
|
-
children:
|
|
322
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_truncatedText.default, {
|
|
323
|
+
text: x.product.name,
|
|
324
|
+
maxLength: 26,
|
|
325
|
+
useWidth: true
|
|
326
|
+
})
|
|
322
327
|
}), x.is_highlight && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Chip, {
|
|
323
328
|
label: x.highlight_text,
|
|
324
329
|
color: "default",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface TruncatedTextProps {
|
|
3
|
+
text?: string;
|
|
4
|
+
maxLength?: number;
|
|
5
|
+
useWidth?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare function TruncatedText({ text, maxLength, useWidth }: TruncatedTextProps): import("react").JSX.Element | null;
|
|
8
|
+
declare namespace TruncatedText {
|
|
9
|
+
var defaultProps: {
|
|
10
|
+
useWidth: boolean;
|
|
11
|
+
text: string;
|
|
12
|
+
maxLength: number;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export default TruncatedText;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
module.exports = TruncatedText;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _material = require("@mui/material");
|
|
9
|
+
var _system = require("@mui/system");
|
|
10
|
+
var _util = require("../libs/util");
|
|
11
|
+
const CustomTooltip = (0, _system.styled)(({
|
|
12
|
+
className,
|
|
13
|
+
...props
|
|
14
|
+
}) => /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Tooltip, {
|
|
15
|
+
...props,
|
|
16
|
+
classes: {
|
|
17
|
+
popper: className
|
|
18
|
+
}
|
|
19
|
+
}))({
|
|
20
|
+
[`& .${_material.tooltipClasses.tooltip}`]: {
|
|
21
|
+
fontSize: 11,
|
|
22
|
+
maxHeight: 120,
|
|
23
|
+
maxWidth: 500,
|
|
24
|
+
overflowY: "auto"
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
function TruncatedText({
|
|
28
|
+
text = "",
|
|
29
|
+
maxLength = 100,
|
|
30
|
+
useWidth = false
|
|
31
|
+
}) {
|
|
32
|
+
if (!text) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const truncatedText = (0, _util.truncateText)(text, maxLength, useWidth);
|
|
36
|
+
if (!truncatedText.endsWith("...")) {
|
|
37
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)("span", {
|
|
38
|
+
children: truncatedText
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(CustomTooltip, {
|
|
42
|
+
title: text,
|
|
43
|
+
placement: "bottom",
|
|
44
|
+
enterTouchDelay: 0,
|
|
45
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)("span", {
|
|
46
|
+
title: text,
|
|
47
|
+
children: truncatedText
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
TruncatedText.defaultProps = {
|
|
52
|
+
useWidth: false,
|
|
53
|
+
text: "",
|
|
54
|
+
maxLength: 100
|
|
55
|
+
};
|
|
@@ -99,7 +99,7 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
99
99
|
const columns = [{
|
|
100
100
|
label: t("common.amount"),
|
|
101
101
|
name: "total",
|
|
102
|
-
width:
|
|
102
|
+
width: 80,
|
|
103
103
|
align: "right",
|
|
104
104
|
options: {
|
|
105
105
|
customBodyRenderLite: (_, index) => {
|
|
@@ -163,9 +163,8 @@ const InvoiceTable = _react.default.memo(props => {
|
|
|
163
163
|
}
|
|
164
164
|
}, {
|
|
165
165
|
label: t("common.status"),
|
|
166
|
-
name: "
|
|
166
|
+
name: "status",
|
|
167
167
|
options: {
|
|
168
|
-
sort: true,
|
|
169
168
|
customBodyRenderLite: (val, index) => {
|
|
170
169
|
const invoice = data?.list[index];
|
|
171
170
|
const link = getInvoiceLink(invoice, action);
|
|
@@ -420,6 +419,9 @@ const InvoiceList = _react.default.memo(props => {
|
|
|
420
419
|
color: "primary",
|
|
421
420
|
size: "small",
|
|
422
421
|
onClick: () => onPay(invoice.id),
|
|
422
|
+
sx: {
|
|
423
|
+
whiteSpace: "nowrap"
|
|
424
|
+
},
|
|
423
425
|
children: t("payment.customer.invoice.pay")
|
|
424
426
|
}) : /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
|
|
425
427
|
component: "a",
|
|
@@ -427,6 +429,9 @@ const InvoiceList = _react.default.memo(props => {
|
|
|
427
429
|
size: "small",
|
|
428
430
|
href: link.url,
|
|
429
431
|
target: link.external ? "_blank" : target,
|
|
432
|
+
sx: {
|
|
433
|
+
whiteSpace: "nowrap"
|
|
434
|
+
},
|
|
430
435
|
rel: "noreferrer",
|
|
431
436
|
children: t("payment.customer.invoice.pay")
|
|
432
437
|
}) : /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
|
package/lib/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ import ProductSkeleton from './payment/product-skeleton';
|
|
|
25
25
|
import PaymentSummary from './payment/summary';
|
|
26
26
|
import PricingItem from './components/pricing-item';
|
|
27
27
|
import CountrySelect from './components/country-select';
|
|
28
|
+
import TruncatedText from './components/truncated-text';
|
|
28
29
|
export { PaymentThemeProvider } from './theme';
|
|
29
30
|
export * from './libs/util';
|
|
30
31
|
export * from './libs/connect';
|
|
@@ -33,4 +34,4 @@ export * from './hooks/subscription';
|
|
|
33
34
|
export * from './hooks/mobile';
|
|
34
35
|
export * from './hooks/table';
|
|
35
36
|
export { translations, createTranslator } from './locales';
|
|
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, };
|
|
37
|
+
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, TruncatedText, };
|
package/lib/index.js
CHANGED
|
@@ -31,6 +31,7 @@ var _exportNames = {
|
|
|
31
31
|
PaymentSummary: true,
|
|
32
32
|
PricingItem: true,
|
|
33
33
|
CountrySelect: true,
|
|
34
|
+
TruncatedText: true,
|
|
34
35
|
PaymentThemeProvider: true,
|
|
35
36
|
translations: true,
|
|
36
37
|
createTranslator: true
|
|
@@ -179,6 +180,12 @@ Object.defineProperty(exports, "Table", {
|
|
|
179
180
|
return _table2.default;
|
|
180
181
|
}
|
|
181
182
|
});
|
|
183
|
+
Object.defineProperty(exports, "TruncatedText", {
|
|
184
|
+
enumerable: true,
|
|
185
|
+
get: function () {
|
|
186
|
+
return _truncatedText.default;
|
|
187
|
+
}
|
|
188
|
+
});
|
|
182
189
|
Object.defineProperty(exports, "TxGas", {
|
|
183
190
|
enumerable: true,
|
|
184
191
|
get: function () {
|
|
@@ -242,6 +249,7 @@ var _productSkeleton = _interopRequireDefault(require("./payment/product-skeleto
|
|
|
242
249
|
var _summary = _interopRequireDefault(require("./payment/summary"));
|
|
243
250
|
var _pricingItem = _interopRequireDefault(require("./components/pricing-item"));
|
|
244
251
|
var _countrySelect = _interopRequireDefault(require("./components/country-select"));
|
|
252
|
+
var _truncatedText = _interopRequireDefault(require("./components/truncated-text"));
|
|
245
253
|
var _theme = require("./theme");
|
|
246
254
|
var _util = require("./libs/util");
|
|
247
255
|
Object.keys(_util).forEach(function (key) {
|
package/lib/libs/util.d.ts
CHANGED
|
@@ -106,3 +106,4 @@ export declare function formatSubscriptionStatus(status: string): string;
|
|
|
106
106
|
export declare function formatAmountPrecisionLimit(amount: string, locale?: string, precision?: number): string;
|
|
107
107
|
export declare function getWordBreakStyle(value: any): 'break-word' | 'break-all';
|
|
108
108
|
export declare function isMobileSafari(): boolean;
|
|
109
|
+
export declare function truncateText(text: string, maxLength: number, useWidth?: boolean): string;
|
package/lib/libs/util.js
CHANGED
|
@@ -51,10 +51,12 @@ exports.lazyLoad = lazyLoad;
|
|
|
51
51
|
exports.mergeExtraParams = void 0;
|
|
52
52
|
exports.sleep = sleep;
|
|
53
53
|
exports.stopEvent = stopEvent;
|
|
54
|
+
exports.truncateText = truncateText;
|
|
54
55
|
var _util = require("@ocap/util");
|
|
55
56
|
var _omit = _interopRequireDefault(require("lodash/omit"));
|
|
56
57
|
var _trimEnd = _interopRequireDefault(require("lodash/trimEnd"));
|
|
57
58
|
var _numbro = _interopRequireDefault(require("numbro"));
|
|
59
|
+
var _stringWidth = _interopRequireDefault(require("string-width"));
|
|
58
60
|
var _reactInternationalPhone = require("react-international-phone");
|
|
59
61
|
var _ufo = require("ufo");
|
|
60
62
|
var _locales = require("../locales");
|
|
@@ -982,4 +984,29 @@ function isMobileSafari() {
|
|
|
982
984
|
const isMobile = ua.indexOf("mobile") > -1 || /iphone|ipad|ipod/.test(ua);
|
|
983
985
|
const isIOS = /iphone|ipad|ipod/.test(ua);
|
|
984
986
|
return isSafari && isMobile && isIOS;
|
|
987
|
+
}
|
|
988
|
+
function truncateText(text, maxLength, useWidth = false) {
|
|
989
|
+
if (!text || !maxLength) {
|
|
990
|
+
return text;
|
|
991
|
+
}
|
|
992
|
+
if (!useWidth) {
|
|
993
|
+
if (text.length <= maxLength) {
|
|
994
|
+
return text;
|
|
995
|
+
}
|
|
996
|
+
return `${text.substring(0, maxLength)}...`;
|
|
997
|
+
}
|
|
998
|
+
let width = 0;
|
|
999
|
+
let truncated = "";
|
|
1000
|
+
for (let i = 0; i < text.length; i++) {
|
|
1001
|
+
const charWidth = (0, _stringWidth.default)(text.charAt(i));
|
|
1002
|
+
if (width + charWidth > maxLength) {
|
|
1003
|
+
break;
|
|
1004
|
+
}
|
|
1005
|
+
truncated += text.charAt(i);
|
|
1006
|
+
width += charWidth;
|
|
1007
|
+
}
|
|
1008
|
+
if (truncated === text) {
|
|
1009
|
+
return truncated;
|
|
1010
|
+
}
|
|
1011
|
+
return `${truncated}...`;
|
|
985
1012
|
}
|
package/lib/locales/en.js
CHANGED
|
@@ -209,6 +209,7 @@ module.exports = (0, _flat.default)({
|
|
|
209
209
|
title: "Cancel your subscription",
|
|
210
210
|
comment: "Any additional feedback?",
|
|
211
211
|
description: "Your subscription will be canceled, but it is still available until the end of your current billing period on {date}",
|
|
212
|
+
trialDescription: "Free trial subscriptions will be canceled immediately and no longer available, confirm to continue",
|
|
212
213
|
feedback: {
|
|
213
214
|
tip: "We would love your feedback, it will help us improve our service",
|
|
214
215
|
too_expensive: "The service is too expensive",
|
|
@@ -310,7 +311,8 @@ module.exports = (0, _flat.default)({
|
|
|
310
311
|
threshold: "Metered usage billing",
|
|
311
312
|
cancel: "Subscription cancel",
|
|
312
313
|
manual: "Manual invoice",
|
|
313
|
-
upcoming: "Upcoming invoice"
|
|
314
|
+
upcoming: "Upcoming invoice",
|
|
315
|
+
slashStake: "Slash stake"
|
|
314
316
|
}
|
|
315
317
|
}
|
|
316
318
|
},
|
package/lib/locales/zh.js
CHANGED
|
@@ -209,6 +209,7 @@ module.exports = (0, _flat.default)({
|
|
|
209
209
|
title: "\u53D6\u6D88\u60A8\u7684\u8BA2\u9605",
|
|
210
210
|
comment: "\u4F60\u8FD8\u6709\u5176\u4ED6\u53CD\u9988\u4E48\uFF1F",
|
|
211
211
|
description: "\u60A8\u7684\u8BA2\u9605\u5C06\u88AB\u53D6\u6D88\uFF0C\u4F46\u4ECD\u7136\u53EF\u7528\u76F4\u5230\u60A8\u5F53\u524D\u8BA1\u8D39\u5468\u671F\u7ED3\u675F\u4E8E{date}",
|
|
212
|
+
trialDescription: "\u514D\u8D39\u8BD5\u7528\u7684\u8BA2\u9605\u5C06\u88AB\u7ACB\u5373\u53D6\u6D88\uFF0C\u4E0D\u518D\u53EF\u7528\uFF0C\u786E\u8BA4\u662F\u5426\u7EE7\u7EED",
|
|
212
213
|
feedback: {
|
|
213
214
|
tip: "\u6211\u4EEC\u5E0C\u671B\u542C\u5230\u60A8\u7684\u53CD\u9988\uFF0C\u8FD9\u5C06\u5E2E\u52A9\u6211\u4EEC\u6539\u8FDB\u6211\u4EEC\u7684\u670D\u52A1",
|
|
214
215
|
too_expensive: "\u670D\u52A1\u8D39\u7528\u592A\u9AD8",
|
|
@@ -310,7 +311,8 @@ module.exports = (0, _flat.default)({
|
|
|
310
311
|
threshold: "\u7528\u91CF\u8D26\u5355",
|
|
311
312
|
cancel: "\u8BA2\u9605\u53D6\u6D88",
|
|
312
313
|
manual: "\u4EBA\u5DE5\u8D26\u5355",
|
|
313
|
-
upcoming: "\u672A\u6765\u8D26\u5355"
|
|
314
|
+
upcoming: "\u672A\u6765\u8D26\u5355",
|
|
315
|
+
slashStake: "\u7F5A\u6CA1\u8D28\u62BC"
|
|
314
316
|
}
|
|
315
317
|
}
|
|
316
318
|
},
|
|
@@ -399,6 +399,9 @@ function PaymentForm({
|
|
|
399
399
|
direction: "column",
|
|
400
400
|
alignItems: "flex-start",
|
|
401
401
|
className: "cko-payment-methods",
|
|
402
|
+
sx: {
|
|
403
|
+
mb: 1
|
|
404
|
+
},
|
|
402
405
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
|
|
403
406
|
direction: "row",
|
|
404
407
|
sx: {
|
|
@@ -423,13 +426,6 @@ function PaymentForm({
|
|
|
423
426
|
onCancel: onStripeCancel
|
|
424
427
|
})]
|
|
425
428
|
})
|
|
426
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
|
|
427
|
-
direction: "row",
|
|
428
|
-
sx: {
|
|
429
|
-
mb: 1
|
|
430
|
-
},
|
|
431
|
-
alignItems: "center",
|
|
432
|
-
justifyContent: "space-between"
|
|
433
429
|
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
434
430
|
direction: "column",
|
|
435
431
|
className: "cko-payment-form",
|
package/lib/payment/summary.js
CHANGED
|
@@ -342,9 +342,7 @@ function PaymentSummary({
|
|
|
342
342
|
},
|
|
343
343
|
children: t("payment.checkout.paymentRequired")
|
|
344
344
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Tooltip, {
|
|
345
|
-
title:
|
|
346
|
-
children: t("payment.checkout.stakingConfirm")
|
|
347
|
-
}),
|
|
345
|
+
title: t("payment.checkout.stakingConfirm"),
|
|
348
346
|
placement: "top",
|
|
349
347
|
sx: {
|
|
350
348
|
maxWidth: "150px"
|
|
@@ -374,9 +372,7 @@ function PaymentSummary({
|
|
|
374
372
|
},
|
|
375
373
|
children: t("payment.checkout.staking.title")
|
|
376
374
|
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Tooltip, {
|
|
377
|
-
title:
|
|
378
|
-
children: t("payment.checkout.staking.tooltip")
|
|
379
|
-
}),
|
|
375
|
+
title: t("payment.checkout.staking.tooltip"),
|
|
380
376
|
placement: "top",
|
|
381
377
|
sx: {
|
|
382
378
|
maxWidth: "150px"
|
package/lib/theme/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.32",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -53,16 +53,16 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@arcblock/did-connect": "^2.10.
|
|
57
|
-
"@arcblock/ux": "^2.10.
|
|
58
|
-
"@arcblock/ws": "^1.18.
|
|
59
|
-
"@blocklet/ui-react": "^2.10.
|
|
56
|
+
"@arcblock/did-connect": "^2.10.23",
|
|
57
|
+
"@arcblock/ux": "^2.10.23",
|
|
58
|
+
"@arcblock/ws": "^1.18.132",
|
|
59
|
+
"@blocklet/ui-react": "^2.10.23",
|
|
60
60
|
"@mui/icons-material": "^5.16.6",
|
|
61
61
|
"@mui/lab": "^5.0.0-alpha.173",
|
|
62
62
|
"@mui/material": "^5.16.6",
|
|
63
63
|
"@mui/styles": "^5.16.6",
|
|
64
64
|
"@mui/system": "^5.16.6",
|
|
65
|
-
"@ocap/util": "^1.18.
|
|
65
|
+
"@ocap/util": "^1.18.132",
|
|
66
66
|
"@stripe/react-stripe-js": "^2.7.3",
|
|
67
67
|
"@stripe/stripe-js": "^2.4.0",
|
|
68
68
|
"@vitejs/plugin-legacy": "^5.4.1",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"@babel/core": "^7.25.2",
|
|
94
94
|
"@babel/preset-env": "^7.25.2",
|
|
95
95
|
"@babel/preset-react": "^7.24.7",
|
|
96
|
-
"@blocklet/payment-types": "1.14.
|
|
96
|
+
"@blocklet/payment-types": "1.14.32",
|
|
97
97
|
"@storybook/addon-essentials": "^7.6.20",
|
|
98
98
|
"@storybook/addon-interactions": "^7.6.20",
|
|
99
99
|
"@storybook/addon-links": "^7.6.20",
|
|
@@ -123,5 +123,5 @@
|
|
|
123
123
|
"vite-plugin-babel": "^1.2.0",
|
|
124
124
|
"vite-plugin-node-polyfills": "^0.21.0"
|
|
125
125
|
},
|
|
126
|
-
"gitHead": "
|
|
126
|
+
"gitHead": "347accd83eb9354f423e06670d53003b4fd40114"
|
|
127
127
|
}
|
package/src/checkout/table.tsx
CHANGED
|
@@ -13,6 +13,7 @@ import { mergeExtraParams } from '../libs/util';
|
|
|
13
13
|
import { CheckoutProps } from '../types';
|
|
14
14
|
import CheckoutForm from './form';
|
|
15
15
|
import { PaymentThemeProvider } from '../theme';
|
|
16
|
+
import TruncatedText from '../components/truncated-text';
|
|
16
17
|
|
|
17
18
|
const fetchData = async (id: string): Promise<TPricingTableExpanded> => {
|
|
18
19
|
const { data } = await api.get(`/api/pricing-tables/${id}`);
|
|
@@ -100,7 +101,7 @@ function CheckoutTableInner({ id, mode, onPaid, onError, onChange, extraParams,
|
|
|
100
101
|
},
|
|
101
102
|
textAlign: 'center',
|
|
102
103
|
}}>
|
|
103
|
-
{!data.livemode && <Livemode sx={{ display: 'flex', marginBottom: '8px', width: 'fit-content' }} />}
|
|
104
|
+
{!data.livemode && <Livemode sx={{ display: 'flex', marginBottom: '8px', width: 'fit-content', ml: 0 }} />}
|
|
104
105
|
<Typography
|
|
105
106
|
color="text.primary"
|
|
106
107
|
fontWeight={600}
|
|
@@ -108,7 +109,7 @@ function CheckoutTableInner({ id, mode, onPaid, onError, onChange, extraParams,
|
|
|
108
109
|
lineHeight: '32px',
|
|
109
110
|
fontSize: '24px',
|
|
110
111
|
}}>
|
|
111
|
-
{data.name}
|
|
112
|
+
<TruncatedText text={data.name} maxLength={60} useWidth />
|
|
112
113
|
</Typography>
|
|
113
114
|
</Box>
|
|
114
115
|
<PricingTable table={data} onSelect={handleSelect} />
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
} from '../libs/util';
|
|
35
35
|
import Amount from '../payment/amount';
|
|
36
36
|
import { useMobile } from '../hooks/mobile';
|
|
37
|
+
import TruncatedText from './truncated-text';
|
|
37
38
|
|
|
38
39
|
type SortOrder = { [key: string]: number };
|
|
39
40
|
|
|
@@ -330,7 +331,7 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
|
|
|
330
331
|
fontSize: '18px !important',
|
|
331
332
|
fontWeight: '600',
|
|
332
333
|
}}>
|
|
333
|
-
{x.product.name}
|
|
334
|
+
<TruncatedText text={x.product.name} maxLength={26} useWidth />
|
|
334
335
|
</Typography>
|
|
335
336
|
{x.is_highlight && (
|
|
336
337
|
<Chip
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Tooltip, TooltipProps, tooltipClasses } from '@mui/material';
|
|
2
|
+
import { styled } from '@mui/system';
|
|
3
|
+
import { truncateText } from '../libs/util';
|
|
4
|
+
|
|
5
|
+
const CustomTooltip = styled(({ className, ...props }: TooltipProps) => (
|
|
6
|
+
<Tooltip {...props} classes={{ popper: className }} />
|
|
7
|
+
))({
|
|
8
|
+
[`& .${tooltipClasses.tooltip}`]: {
|
|
9
|
+
fontSize: 11,
|
|
10
|
+
maxHeight: 120,
|
|
11
|
+
maxWidth: 500,
|
|
12
|
+
overflowY: 'auto',
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
interface TruncatedTextProps {
|
|
17
|
+
text?: string;
|
|
18
|
+
maxLength?: number;
|
|
19
|
+
useWidth?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default function TruncatedText({ text = '', maxLength = 100, useWidth = false }: TruncatedTextProps) {
|
|
23
|
+
if (!text) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const truncatedText = truncateText(text, maxLength, useWidth);
|
|
27
|
+
if (!truncatedText.endsWith('...')) {
|
|
28
|
+
return <span>{truncatedText}</span>;
|
|
29
|
+
}
|
|
30
|
+
return (
|
|
31
|
+
<CustomTooltip title={text} placement="bottom" enterTouchDelay={0}>
|
|
32
|
+
<span title={text}>{truncatedText}</span>
|
|
33
|
+
</CustomTooltip>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
TruncatedText.defaultProps = {
|
|
38
|
+
useWidth: false,
|
|
39
|
+
text: '',
|
|
40
|
+
maxLength: 100,
|
|
41
|
+
};
|
|
@@ -126,7 +126,7 @@ const InvoiceTable = React.memo((props: Props & { onPay: (invoiceId: string) =>
|
|
|
126
126
|
{
|
|
127
127
|
label: t('common.amount'),
|
|
128
128
|
name: 'total',
|
|
129
|
-
width:
|
|
129
|
+
width: 80,
|
|
130
130
|
align: 'right',
|
|
131
131
|
options: {
|
|
132
132
|
customBodyRenderLite: (_: string, index: number) => {
|
|
@@ -191,9 +191,8 @@ const InvoiceTable = React.memo((props: Props & { onPay: (invoiceId: string) =>
|
|
|
191
191
|
},
|
|
192
192
|
{
|
|
193
193
|
label: t('common.status'),
|
|
194
|
-
name: '
|
|
194
|
+
name: 'status',
|
|
195
195
|
options: {
|
|
196
|
-
sort: true,
|
|
197
196
|
customBodyRenderLite: (val: string, index: number) => {
|
|
198
197
|
const invoice = data?.list[index] as TInvoiceExpanded;
|
|
199
198
|
const link = getInvoiceLink(invoice, action);
|
|
@@ -396,7 +395,12 @@ const InvoiceList = React.memo((props: Props & { onPay: (invoiceId: string) => v
|
|
|
396
395
|
<Box flex={1} textAlign="right">
|
|
397
396
|
{action ? (
|
|
398
397
|
link.connect ? (
|
|
399
|
-
<Button
|
|
398
|
+
<Button
|
|
399
|
+
variant="contained"
|
|
400
|
+
color="primary"
|
|
401
|
+
size="small"
|
|
402
|
+
onClick={() => onPay(invoice.id)}
|
|
403
|
+
sx={{ whiteSpace: 'nowrap' }}>
|
|
400
404
|
{t('payment.customer.invoice.pay')}
|
|
401
405
|
</Button>
|
|
402
406
|
) : (
|
|
@@ -406,6 +410,7 @@ const InvoiceList = React.memo((props: Props & { onPay: (invoiceId: string) => v
|
|
|
406
410
|
size="small"
|
|
407
411
|
href={link.url}
|
|
408
412
|
target={link.external ? '_blank' : target}
|
|
413
|
+
sx={{ whiteSpace: 'nowrap' }}
|
|
409
414
|
rel="noreferrer">
|
|
410
415
|
{t('payment.customer.invoice.pay')}
|
|
411
416
|
</Button>
|
package/src/index.ts
CHANGED
|
@@ -25,6 +25,7 @@ import ProductSkeleton from './payment/product-skeleton';
|
|
|
25
25
|
import PaymentSummary from './payment/summary';
|
|
26
26
|
import PricingItem from './components/pricing-item';
|
|
27
27
|
import CountrySelect from './components/country-select';
|
|
28
|
+
import TruncatedText from './components/truncated-text';
|
|
28
29
|
|
|
29
30
|
export { PaymentThemeProvider } from './theme';
|
|
30
31
|
|
|
@@ -65,4 +66,5 @@ export {
|
|
|
65
66
|
PricingItem,
|
|
66
67
|
CountrySelect,
|
|
67
68
|
Table,
|
|
69
|
+
TruncatedText,
|
|
68
70
|
};
|
package/src/libs/util.ts
CHANGED
|
@@ -19,6 +19,8 @@ import { BN, fromUnitToToken } from '@ocap/util';
|
|
|
19
19
|
import omit from 'lodash/omit';
|
|
20
20
|
import trimEnd from 'lodash/trimEnd';
|
|
21
21
|
import numbro from 'numbro';
|
|
22
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
23
|
+
import stringWidth from 'string-width';
|
|
22
24
|
import { defaultCountries } from 'react-international-phone';
|
|
23
25
|
import { joinURL } from 'ufo';
|
|
24
26
|
|
|
@@ -1050,3 +1052,34 @@ export function isMobileSafari() {
|
|
|
1050
1052
|
const isIOS = /iphone|ipad|ipod/.test(ua);
|
|
1051
1053
|
return isSafari && isMobile && isIOS;
|
|
1052
1054
|
}
|
|
1055
|
+
|
|
1056
|
+
export function truncateText(text: string, maxLength: number, useWidth: boolean = false): string {
|
|
1057
|
+
if (!text || !maxLength) {
|
|
1058
|
+
return text;
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
if (!useWidth) {
|
|
1062
|
+
if (text.length <= maxLength) {
|
|
1063
|
+
return text;
|
|
1064
|
+
}
|
|
1065
|
+
return `${text.substring(0, maxLength)}...`;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
let width = 0;
|
|
1069
|
+
let truncated = '';
|
|
1070
|
+
|
|
1071
|
+
for (let i = 0; i < text.length; i++) {
|
|
1072
|
+
const charWidth = stringWidth(text.charAt(i));
|
|
1073
|
+
if (width + charWidth > maxLength) {
|
|
1074
|
+
break;
|
|
1075
|
+
}
|
|
1076
|
+
truncated += text.charAt(i);
|
|
1077
|
+
width += charWidth;
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
if (truncated === text) {
|
|
1081
|
+
return truncated;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
return `${truncated}...`;
|
|
1085
|
+
}
|
package/src/locales/en.tsx
CHANGED
|
@@ -208,6 +208,8 @@ export default flat({
|
|
|
208
208
|
comment: 'Any additional feedback?',
|
|
209
209
|
description:
|
|
210
210
|
'Your subscription will be canceled, but it is still available until the end of your current billing period on {date}',
|
|
211
|
+
trialDescription:
|
|
212
|
+
'Free trial subscriptions will be canceled immediately and no longer available, confirm to continue',
|
|
211
213
|
feedback: {
|
|
212
214
|
tip: 'We would love your feedback, it will help us improve our service',
|
|
213
215
|
too_expensive: 'The service is too expensive',
|
|
@@ -316,6 +318,7 @@ export default flat({
|
|
|
316
318
|
cancel: 'Subscription cancel',
|
|
317
319
|
manual: 'Manual invoice',
|
|
318
320
|
upcoming: 'Upcoming invoice',
|
|
321
|
+
slashStake: 'Slash stake',
|
|
319
322
|
},
|
|
320
323
|
},
|
|
321
324
|
},
|
package/src/locales/zh.tsx
CHANGED
|
@@ -204,6 +204,7 @@ export default flat({
|
|
|
204
204
|
title: '取消您的订阅',
|
|
205
205
|
comment: '你还有其他反馈么?',
|
|
206
206
|
description: '您的订阅将被取消,但仍然可用直到您当前计费周期结束于{date}',
|
|
207
|
+
trialDescription: '免费试用的订阅将被立即取消,不再可用,确认是否继续',
|
|
207
208
|
feedback: {
|
|
208
209
|
tip: '我们希望听到您的反馈,这将帮助我们改进我们的服务',
|
|
209
210
|
too_expensive: '服务费用太高',
|
|
@@ -307,6 +308,7 @@ export default flat({
|
|
|
307
308
|
cancel: '订阅取消',
|
|
308
309
|
manual: '人工账单',
|
|
309
310
|
upcoming: '未来账单',
|
|
311
|
+
slashStake: '罚没质押',
|
|
310
312
|
},
|
|
311
313
|
},
|
|
312
314
|
},
|
|
@@ -416,7 +416,7 @@ export default function PaymentForm({
|
|
|
416
416
|
{t('payment.checkout.paymentDetails')}
|
|
417
417
|
</Typography>
|
|
418
418
|
<Fade in>
|
|
419
|
-
<Stack direction="column" alignItems="flex-start" className="cko-payment-methods">
|
|
419
|
+
<Stack direction="column" alignItems="flex-start" className="cko-payment-methods" sx={{ mb: 1 }}>
|
|
420
420
|
<Stack direction="row" sx={{ width: '100%' }}>
|
|
421
421
|
<Controller
|
|
422
422
|
name="payment_currency"
|
|
@@ -443,10 +443,6 @@ export default function PaymentForm({
|
|
|
443
443
|
)}
|
|
444
444
|
</Stack>
|
|
445
445
|
</Fade>
|
|
446
|
-
<Stack direction="row" sx={{ mb: 1 }} alignItems="center" justifyContent="space-between">
|
|
447
|
-
{/* <Typography sx={{ color: 'text.secondary', fontWeight: 600 }}>{t('payment.checkout.contact')}</Typography> */}
|
|
448
|
-
{/* {isColumnLayout || mode !== 'standalone' ? null : <UserButtons />} */}
|
|
449
|
-
</Stack>
|
|
450
446
|
<Stack
|
|
451
447
|
direction="column"
|
|
452
448
|
className="cko-payment-form"
|
package/src/payment/summary.tsx
CHANGED
|
@@ -335,10 +335,7 @@ export default function PaymentSummary({
|
|
|
335
335
|
<Stack direction="row" justifyContent="space-between" alignItems="center" spacing={1}>
|
|
336
336
|
<Stack direction="row" alignItems="center" spacing={0.5}>
|
|
337
337
|
<Typography sx={{ color: 'text.secondary' }}>{t('payment.checkout.paymentRequired')}</Typography>
|
|
338
|
-
<Tooltip
|
|
339
|
-
title={<Typography>{t('payment.checkout.stakingConfirm')}</Typography>}
|
|
340
|
-
placement="top"
|
|
341
|
-
sx={{ maxWidth: '150px' }}>
|
|
338
|
+
<Tooltip title={t('payment.checkout.stakingConfirm')} placement="top" sx={{ maxWidth: '150px' }}>
|
|
342
339
|
<HelpOutline fontSize="small" sx={{ color: 'text.lighter' }} />
|
|
343
340
|
</Tooltip>
|
|
344
341
|
</Stack>
|
|
@@ -347,10 +344,7 @@ export default function PaymentSummary({
|
|
|
347
344
|
<Stack direction="row" justifyContent="space-between" alignItems="center" spacing={1}>
|
|
348
345
|
<Stack direction="row" alignItems="center" spacing={0.5}>
|
|
349
346
|
<Typography sx={{ color: 'text.secondary' }}>{t('payment.checkout.staking.title')}</Typography>
|
|
350
|
-
<Tooltip
|
|
351
|
-
title={<Typography>{t('payment.checkout.staking.tooltip')}</Typography>}
|
|
352
|
-
placement="top"
|
|
353
|
-
sx={{ maxWidth: '150px' }}>
|
|
347
|
+
<Tooltip title={t('payment.checkout.staking.tooltip')} placement="top" sx={{ maxWidth: '150px' }}>
|
|
354
348
|
<HelpOutline fontSize="small" sx={{ color: 'text.lighter' }} />
|
|
355
349
|
</Tooltip>
|
|
356
350
|
</Stack>
|
package/src/theme/index.tsx
CHANGED