@blocklet/payment-react 1.14.20 → 1.14.22
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 +2 -1
- package/es/checkout/donate.js +9 -10
- package/es/checkout/form.d.ts +1 -1
- package/es/checkout/form.js +23 -1
- package/es/checkout/table.d.ts +1 -1
- package/es/checkout/table.js +8 -1
- package/es/components/blockchain/tx.js +2 -1
- package/es/components/country-select.d.ts +16 -0
- package/es/components/country-select.js +82 -0
- package/es/components/input.d.ts +21 -21
- package/es/components/input.js +43 -42
- package/es/components/livemode.js +1 -0
- package/es/components/pricing-table.js +0 -2
- package/es/components/status.js +2 -3
- package/es/components/table.d.ts +2 -0
- package/es/components/table.js +186 -0
- package/es/contexts/payment.d.ts +2 -0
- package/es/contexts/payment.js +5 -2
- package/es/history/invoice/list.d.ts +5 -1
- package/es/history/invoice/list.js +218 -48
- package/es/hooks/mobile.d.ts +4 -0
- package/es/hooks/mobile.js +10 -0
- package/es/index.d.ts +5 -1
- package/es/index.js +7 -1
- package/es/libs/util.d.ts +15 -2
- package/es/libs/util.js +92 -28
- package/es/locales/en.js +23 -7
- package/es/locales/index.d.ts +0 -1
- package/es/locales/index.js +10 -1
- package/es/locales/zh.js +22 -6
- package/es/payment/error.js +2 -2
- package/es/payment/footer.js +1 -1
- package/es/payment/form/address.d.ts +9 -2
- package/es/payment/form/address.js +69 -69
- package/es/payment/form/currency.js +39 -25
- package/es/payment/form/index.d.ts +1 -1
- package/es/payment/form/index.js +83 -81
- package/es/payment/form/phone.js +15 -51
- package/es/payment/index.d.ts +1 -10
- package/es/payment/index.js +274 -219
- package/es/payment/product-card.js +4 -4
- package/es/payment/product-donation.js +7 -2
- package/es/payment/product-item.d.ts +2 -2
- package/es/payment/product-item.js +120 -81
- package/es/payment/summary.js +188 -118
- package/es/theme/index.css +240 -0
- package/es/theme/index.d.ts +9 -0
- package/es/theme/index.js +243 -0
- package/es/theme/typography.d.ts +2 -0
- package/es/theme/typography.js +53 -0
- package/es/types/index.d.ts +11 -0
- package/lib/checkout/donate.d.ts +2 -1
- package/lib/checkout/donate.js +14 -2
- package/lib/checkout/form.d.ts +1 -1
- package/lib/checkout/form.js +22 -1
- package/lib/checkout/table.d.ts +1 -1
- package/lib/checkout/table.js +14 -1
- package/lib/components/blockchain/tx.js +4 -1
- package/lib/components/country-select.d.ts +16 -0
- package/lib/components/country-select.js +115 -0
- package/lib/components/input.d.ts +21 -21
- package/lib/components/input.js +21 -12
- package/lib/components/livemode.js +1 -0
- package/lib/components/pricing-table.js +0 -2
- package/lib/components/status.js +2 -3
- package/lib/components/table.d.ts +2 -0
- package/lib/components/table.js +220 -0
- package/lib/contexts/payment.d.ts +2 -0
- package/lib/contexts/payment.js +4 -1
- package/lib/history/invoice/list.d.ts +5 -1
- package/lib/history/invoice/list.js +293 -62
- package/lib/hooks/mobile.d.ts +4 -0
- package/lib/hooks/mobile.js +17 -0
- package/lib/index.d.ts +5 -1
- package/lib/index.js +36 -0
- package/lib/libs/util.d.ts +15 -2
- package/lib/libs/util.js +115 -37
- package/lib/locales/en.js +23 -7
- package/lib/locales/index.d.ts +0 -1
- package/lib/locales/index.js +14 -3
- package/lib/locales/zh.js +22 -6
- package/lib/payment/error.js +5 -1
- package/lib/payment/footer.js +1 -1
- package/lib/payment/form/address.d.ts +9 -2
- package/lib/payment/form/address.js +67 -59
- package/lib/payment/form/currency.js +31 -24
- package/lib/payment/form/index.d.ts +1 -1
- package/lib/payment/form/index.js +92 -93
- package/lib/payment/form/phone.js +11 -59
- package/lib/payment/index.d.ts +1 -10
- package/lib/payment/index.js +291 -219
- package/lib/payment/product-card.js +5 -4
- package/lib/payment/product-donation.js +9 -2
- package/lib/payment/product-item.d.ts +2 -2
- package/lib/payment/product-item.js +38 -19
- package/lib/payment/summary.js +219 -127
- package/lib/theme/index.css +240 -0
- package/lib/theme/index.d.ts +9 -0
- package/lib/theme/index.js +259 -0
- package/lib/theme/typography.d.ts +2 -0
- package/lib/theme/typography.js +59 -0
- package/lib/types/index.d.ts +11 -0
- package/package.json +14 -11
- package/src/checkout/donate.tsx +16 -10
- package/src/checkout/form.tsx +23 -0
- package/src/checkout/table.tsx +13 -1
- package/src/components/blockchain/tx.tsx +2 -1
- package/src/components/country-select.tsx +93 -0
- package/src/components/input.tsx +49 -46
- package/src/components/livemode.tsx +1 -0
- package/src/components/pricing-table.tsx +0 -2
- package/src/components/status.tsx +1 -2
- package/src/components/table.tsx +200 -0
- package/src/contexts/payment.tsx +6 -1
- package/src/history/invoice/list.tsx +258 -49
- package/src/hooks/mobile.ts +13 -0
- package/src/index.ts +7 -0
- package/src/libs/util.ts +120 -31
- package/src/locales/en.tsx +19 -4
- package/src/locales/index.tsx +10 -3
- package/src/locales/zh.tsx +18 -3
- package/src/payment/error.tsx +2 -2
- package/src/payment/footer.tsx +1 -1
- package/src/payment/form/address.tsx +56 -47
- package/src/payment/form/currency.tsx +29 -23
- package/src/payment/form/index.tsx +89 -76
- package/src/payment/form/phone.tsx +14 -51
- package/src/payment/index.tsx +294 -242
- package/src/payment/product-card.tsx +4 -4
- package/src/payment/product-donation.tsx +7 -3
- package/src/payment/product-item.tsx +49 -20
- package/src/payment/summary.tsx +191 -108
- package/src/theme/index.css +240 -0
- package/src/theme/index.tsx +250 -0
- package/src/theme/typography.ts +56 -0
- package/src/types/index.ts +12 -0
package/es/checkout/donate.d.ts
CHANGED
|
@@ -20,8 +20,9 @@ export type DonateProps = Pick<CheckoutProps, 'onPaid' | 'onError'> & {
|
|
|
20
20
|
inlineOptions?: {
|
|
21
21
|
button?: ButtonType;
|
|
22
22
|
};
|
|
23
|
+
customTheme?: boolean;
|
|
23
24
|
};
|
|
24
|
-
declare function CheckoutDonate(
|
|
25
|
+
declare function CheckoutDonate(props: DonateProps): import("react").JSX.Element;
|
|
25
26
|
declare namespace CheckoutDonate {
|
|
26
27
|
var defaultProps: {
|
|
27
28
|
livemode: boolean;
|
package/es/checkout/donate.js
CHANGED
|
@@ -25,6 +25,7 @@ import TxLink from "../components/blockchain/tx.js";
|
|
|
25
25
|
import api from "../libs/api.js";
|
|
26
26
|
import { formatAmount, formatBNStr, formatDateTime, formatError, lazyLoad } from "../libs/util.js";
|
|
27
27
|
import CheckoutForm from "./form.js";
|
|
28
|
+
import { PaymentThemeProvider } from "../theme/index.js";
|
|
28
29
|
const donationCache = {};
|
|
29
30
|
const createOrUpdateDonation = (settings, livemode = true) => {
|
|
30
31
|
if (!donationCache[settings.target]) {
|
|
@@ -210,15 +211,7 @@ function useDonation(settings, livemode = true, mode = "default") {
|
|
|
210
211
|
setState
|
|
211
212
|
};
|
|
212
213
|
}
|
|
213
|
-
|
|
214
|
-
settings,
|
|
215
|
-
livemode,
|
|
216
|
-
timeout,
|
|
217
|
-
onPaid,
|
|
218
|
-
onError,
|
|
219
|
-
mode,
|
|
220
|
-
inlineOptions = {}
|
|
221
|
-
}) {
|
|
214
|
+
function CheckoutDonateInner({ settings, livemode, timeout, onPaid, onError, mode, inlineOptions = {} }) {
|
|
222
215
|
const { state, setState, donation, supporters } = useDonation(settings, livemode, mode);
|
|
223
216
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
224
217
|
const [popoverOpen, setPopoverOpen] = useState(false);
|
|
@@ -348,7 +341,7 @@ export default function CheckoutDonate({
|
|
|
348
341
|
showCloseButton: true,
|
|
349
342
|
disableEscapeKeyDown: true,
|
|
350
343
|
onClose: (e, reason) => setState({ open: reason === "backdropClick" }),
|
|
351
|
-
children: /* @__PURE__ */ jsx(Box, { sx: { mb: 1,
|
|
344
|
+
children: /* @__PURE__ */ jsx(Box, { sx: { mb: 1, height: "100%" }, children: /* @__PURE__ */ jsx(
|
|
352
345
|
CheckoutForm,
|
|
353
346
|
{
|
|
354
347
|
id: donation.data?.id,
|
|
@@ -362,6 +355,12 @@ export default function CheckoutDonate({
|
|
|
362
355
|
)
|
|
363
356
|
] });
|
|
364
357
|
}
|
|
358
|
+
export default function CheckoutDonate(props) {
|
|
359
|
+
if (props.customTheme) {
|
|
360
|
+
return /* @__PURE__ */ jsx(CheckoutDonateInner, { ...props });
|
|
361
|
+
}
|
|
362
|
+
return /* @__PURE__ */ jsx(PaymentThemeProvider, { children: /* @__PURE__ */ jsx(CheckoutDonateInner, { ...props }) });
|
|
363
|
+
}
|
|
365
364
|
CheckoutDonate.defaultProps = {
|
|
366
365
|
livemode: true,
|
|
367
366
|
timeout: 5e3,
|
package/es/checkout/form.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CheckoutProps } from '../types';
|
|
3
|
-
declare function CheckoutForm({ id, mode, onPaid, onError, onChange, goBack, extraParams, action, }: CheckoutProps): import("react").JSX.Element;
|
|
3
|
+
declare function CheckoutForm({ id, mode, onPaid, onError, onChange, goBack, extraParams, action, customTheme, }: CheckoutProps): import("react").JSX.Element;
|
|
4
4
|
declare namespace CheckoutForm {
|
|
5
5
|
var defaultProps: {
|
|
6
6
|
onPaid: any;
|
package/es/checkout/form.js
CHANGED
|
@@ -6,6 +6,7 @@ import { joinURL } from "ufo";
|
|
|
6
6
|
import api from "../libs/api.js";
|
|
7
7
|
import { getPrefix, mergeExtraParams } from "../libs/util.js";
|
|
8
8
|
import Payment from "../payment/index.js";
|
|
9
|
+
import { PaymentThemeProvider } from "../theme/index.js";
|
|
9
10
|
const promises = {};
|
|
10
11
|
const startFromPaymentLink = (id, params) => {
|
|
11
12
|
if (!promises[id]) {
|
|
@@ -29,7 +30,8 @@ export default function CheckoutForm({
|
|
|
29
30
|
onChange,
|
|
30
31
|
goBack,
|
|
31
32
|
extraParams,
|
|
32
|
-
action
|
|
33
|
+
action,
|
|
34
|
+
customTheme = false
|
|
33
35
|
}) {
|
|
34
36
|
if (!id.startsWith("plink_") && !id.startsWith("cs_")) {
|
|
35
37
|
throw new Error("Either a checkoutSession or a paymentLink id is required.");
|
|
@@ -57,6 +59,26 @@ export default function CheckoutForm({
|
|
|
57
59
|
setState({ appError: err });
|
|
58
60
|
onError?.(err);
|
|
59
61
|
};
|
|
62
|
+
if (!customTheme) {
|
|
63
|
+
return /* @__PURE__ */ jsx(PaymentThemeProvider, { children: /* @__PURE__ */ jsx(
|
|
64
|
+
Payment,
|
|
65
|
+
{
|
|
66
|
+
checkoutSession: data?.checkoutSession,
|
|
67
|
+
paymentMethods: data?.paymentMethods,
|
|
68
|
+
paymentIntent: data?.paymentIntent,
|
|
69
|
+
paymentLink: data?.paymentLink,
|
|
70
|
+
customer: data?.customer,
|
|
71
|
+
completed: state.completed,
|
|
72
|
+
error: apiError || state.appError,
|
|
73
|
+
onPaid: handlePaid,
|
|
74
|
+
onError: handleError,
|
|
75
|
+
onChange,
|
|
76
|
+
goBack,
|
|
77
|
+
mode,
|
|
78
|
+
action
|
|
79
|
+
}
|
|
80
|
+
) });
|
|
81
|
+
}
|
|
60
82
|
return /* @__PURE__ */ jsx(
|
|
61
83
|
Payment,
|
|
62
84
|
{
|
package/es/checkout/table.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CheckoutProps } from '../types';
|
|
3
|
-
export default function CheckoutTable(
|
|
3
|
+
export default function CheckoutTable(props: CheckoutProps): import("react").JSX.Element;
|
package/es/checkout/table.js
CHANGED
|
@@ -10,6 +10,7 @@ import PricingTable from "../components/pricing-table.js";
|
|
|
10
10
|
import api from "../libs/api.js";
|
|
11
11
|
import { mergeExtraParams } from "../libs/util.js";
|
|
12
12
|
import CheckoutForm from "./form.js";
|
|
13
|
+
import { PaymentThemeProvider } from "../theme/index.js";
|
|
13
14
|
const fetchData = async (id) => {
|
|
14
15
|
const { data } = await api.get(`/api/pricing-tables/${id}`);
|
|
15
16
|
return data;
|
|
@@ -20,7 +21,7 @@ const ensureProtocol = (url) => {
|
|
|
20
21
|
}
|
|
21
22
|
return url;
|
|
22
23
|
};
|
|
23
|
-
|
|
24
|
+
function CheckoutTableInner({ id, mode, onPaid, onError, onChange, extraParams, goBack }) {
|
|
24
25
|
if (!id.startsWith("prctbl_")) {
|
|
25
26
|
throw new Error("A valid pricing table id is required.");
|
|
26
27
|
}
|
|
@@ -109,3 +110,9 @@ export default function CheckoutTable({ id, mode, onPaid, onError, onChange, ext
|
|
|
109
110
|
}
|
|
110
111
|
) });
|
|
111
112
|
}
|
|
113
|
+
export default function CheckoutTable(props) {
|
|
114
|
+
if (props.customTheme) {
|
|
115
|
+
return /* @__PURE__ */ jsx(CheckoutTableInner, { ...props });
|
|
116
|
+
}
|
|
117
|
+
return /* @__PURE__ */ jsx(PaymentThemeProvider, { children: /* @__PURE__ */ jsx(CheckoutTableInner, { ...props }) });
|
|
118
|
+
}
|
|
@@ -21,9 +21,10 @@ export default function TxLink(props) {
|
|
|
21
21
|
direction: "row",
|
|
22
22
|
alignItems: "center",
|
|
23
23
|
justifyContent: props.align === "left" ? "flex-start" : "flex-end",
|
|
24
|
+
sx: { color: "text.link" },
|
|
24
25
|
spacing: 1,
|
|
25
26
|
children: [
|
|
26
|
-
/* @__PURE__ */ jsx(Typography, { component: "span", color: "
|
|
27
|
+
/* @__PURE__ */ jsx(Typography, { component: "span", color: "text.link", children: text.length > 40 ? [text.slice(0, 6), text.slice(-6)].join("...") : text }),
|
|
27
28
|
/* @__PURE__ */ jsx(OpenInNewOutlined, { fontSize: "small" })
|
|
28
29
|
]
|
|
29
30
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SxProps } from '@mui/material';
|
|
3
|
+
import { CountryIso2 } from 'react-international-phone';
|
|
4
|
+
export type CountrySelectProps = {
|
|
5
|
+
value: CountryIso2;
|
|
6
|
+
onChange: (value: CountryIso2) => void;
|
|
7
|
+
name: string;
|
|
8
|
+
sx?: SxProps;
|
|
9
|
+
};
|
|
10
|
+
declare function CountrySelect({ value, onChange, name, sx }: CountrySelectProps): JSX.Element;
|
|
11
|
+
declare namespace CountrySelect {
|
|
12
|
+
var defaultProps: {
|
|
13
|
+
sx: {};
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export default CountrySelect;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { Box, MenuItem, Select, Typography } from "@mui/material";
|
|
4
|
+
import { useFormContext } from "react-hook-form";
|
|
5
|
+
import { FlagEmoji, defaultCountries, parseCountry } from "react-international-phone";
|
|
6
|
+
CountrySelect.defaultProps = {
|
|
7
|
+
sx: {}
|
|
8
|
+
};
|
|
9
|
+
export default function CountrySelect({ value, onChange, name, sx }) {
|
|
10
|
+
const { setValue } = useFormContext();
|
|
11
|
+
const countryDetail = useMemo(() => {
|
|
12
|
+
const item = defaultCountries.find((v) => v[1] === value);
|
|
13
|
+
return value && item ? parseCountry(item) : { name: "" };
|
|
14
|
+
}, [value]);
|
|
15
|
+
const onCountryChange = (e) => {
|
|
16
|
+
onChange(e.target.value);
|
|
17
|
+
setValue(name, e.target.value);
|
|
18
|
+
};
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
Select,
|
|
21
|
+
{
|
|
22
|
+
MenuProps: {
|
|
23
|
+
style: {
|
|
24
|
+
height: "300px",
|
|
25
|
+
top: "10px"
|
|
26
|
+
},
|
|
27
|
+
anchorOrigin: {
|
|
28
|
+
vertical: "bottom",
|
|
29
|
+
horizontal: "left"
|
|
30
|
+
},
|
|
31
|
+
transformOrigin: {
|
|
32
|
+
vertical: "top",
|
|
33
|
+
horizontal: "left"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
sx: {
|
|
37
|
+
width: "100%",
|
|
38
|
+
// Remove default outline (display only on focus)
|
|
39
|
+
fieldset: {
|
|
40
|
+
display: "none"
|
|
41
|
+
},
|
|
42
|
+
'&.Mui-focused:has(div[aria-expanded="false"])': {
|
|
43
|
+
fieldset: {
|
|
44
|
+
display: "block"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
// Update default spacing
|
|
48
|
+
".MuiSelect-select": {
|
|
49
|
+
padding: "8px",
|
|
50
|
+
paddingRight: "24px !important"
|
|
51
|
+
},
|
|
52
|
+
svg: {
|
|
53
|
+
right: 0
|
|
54
|
+
},
|
|
55
|
+
".MuiMenuItem-root": {
|
|
56
|
+
justifyContent: "flex-start"
|
|
57
|
+
// 确保内容左对齐
|
|
58
|
+
},
|
|
59
|
+
...sx
|
|
60
|
+
},
|
|
61
|
+
value,
|
|
62
|
+
onChange: onCountryChange,
|
|
63
|
+
renderValue: (code) => {
|
|
64
|
+
return /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", flexWrap: "nowrap", gap: 0.5, sx: { cursor: "pointer" }, children: [
|
|
65
|
+
/* @__PURE__ */ jsx(FlagEmoji, { iso2: code, style: { display: "flex" } }),
|
|
66
|
+
/* @__PURE__ */ jsx(Typography, { children: countryDetail?.name })
|
|
67
|
+
] });
|
|
68
|
+
},
|
|
69
|
+
children: defaultCountries.map((c) => {
|
|
70
|
+
const parsed = parseCountry(c);
|
|
71
|
+
return /* @__PURE__ */ jsxs(MenuItem, { value: parsed.iso2, children: [
|
|
72
|
+
/* @__PURE__ */ jsx(FlagEmoji, { iso2: parsed.iso2, style: { marginRight: "8px" } }),
|
|
73
|
+
/* @__PURE__ */ jsx(Typography, { marginRight: "8px", children: parsed.name }),
|
|
74
|
+
/* @__PURE__ */ jsxs(Typography, { color: "gray", children: [
|
|
75
|
+
"+",
|
|
76
|
+
parsed.dialCode
|
|
77
|
+
] })
|
|
78
|
+
] }, parsed.iso2);
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
}
|
package/es/components/input.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { TextFieldProps } from '@mui/material';
|
|
3
2
|
import { RegisterOptions } from 'react-hook-form';
|
|
4
|
-
|
|
3
|
+
declare const FormInput: import("react").ForwardRefExoticComponent<(Omit<import("@mui/material").OutlinedTextFieldProps & {
|
|
5
4
|
name: string;
|
|
6
|
-
label?: string;
|
|
7
|
-
placeholder?: string;
|
|
8
|
-
errorPosition?:
|
|
9
|
-
rules?: RegisterOptions;
|
|
10
|
-
wrapperStyle?:
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
5
|
+
label?: string | undefined;
|
|
6
|
+
placeholder?: string | undefined;
|
|
7
|
+
errorPosition?: "right" | "bottom" | undefined;
|
|
8
|
+
rules?: RegisterOptions<import("react-hook-form").FieldValues, string> | undefined;
|
|
9
|
+
wrapperStyle?: any;
|
|
10
|
+
}, "ref"> | Omit<import("@mui/material").FilledTextFieldProps & {
|
|
11
|
+
name: string;
|
|
12
|
+
label?: string | undefined;
|
|
13
|
+
placeholder?: string | undefined;
|
|
14
|
+
errorPosition?: "right" | "bottom" | undefined;
|
|
15
|
+
rules?: RegisterOptions<import("react-hook-form").FieldValues, string> | undefined;
|
|
16
|
+
wrapperStyle?: any;
|
|
17
|
+
}, "ref"> | Omit<import("@mui/material").StandardTextFieldProps & {
|
|
18
|
+
name: string;
|
|
19
|
+
label?: string | undefined;
|
|
20
|
+
placeholder?: string | undefined;
|
|
21
|
+
errorPosition?: "right" | "bottom" | undefined;
|
|
22
|
+
rules?: RegisterOptions<import("react-hook-form").FieldValues, string> | undefined;
|
|
23
|
+
wrapperStyle?: any;
|
|
24
|
+
}, "ref">) & import("react").RefAttributes<HTMLInputElement>>;
|
|
25
25
|
export default FormInput;
|
package/es/components/input.js
CHANGED
|
@@ -1,7 +1,49 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useImperativeHandle, useRef } from "react";
|
|
2
3
|
import { Box, FormLabel, InputAdornment, TextField, Typography } from "@mui/material";
|
|
3
4
|
import get from "lodash/get";
|
|
4
5
|
import { Controller, useFormContext } from "react-hook-form";
|
|
6
|
+
function FormInputError({ error }) {
|
|
7
|
+
return /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx(Typography, { component: "span", color: "error", children: error }) });
|
|
8
|
+
}
|
|
9
|
+
const FormInput = forwardRef(
|
|
10
|
+
({ name, label, placeholder, rules, errorPosition, wrapperStyle, ...rest }, ref) => {
|
|
11
|
+
const { control, formState } = useFormContext();
|
|
12
|
+
const inputRef = useRef(null);
|
|
13
|
+
useImperativeHandle(ref, () => {
|
|
14
|
+
return inputRef.current;
|
|
15
|
+
});
|
|
16
|
+
const error = get(formState.errors, name)?.message;
|
|
17
|
+
return /* @__PURE__ */ jsx(
|
|
18
|
+
Controller,
|
|
19
|
+
{
|
|
20
|
+
name,
|
|
21
|
+
control,
|
|
22
|
+
rules,
|
|
23
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Box, { sx: { width: "100%", ...wrapperStyle }, children: [
|
|
24
|
+
!!label && /* @__PURE__ */ jsx(FormLabel, { sx: { color: "text.primary" }, children: label }),
|
|
25
|
+
/* @__PURE__ */ jsx(
|
|
26
|
+
TextField,
|
|
27
|
+
{
|
|
28
|
+
fullWidth: true,
|
|
29
|
+
error: !!get(formState.errors, name),
|
|
30
|
+
helperText: errorPosition === "bottom" && error ? error : "",
|
|
31
|
+
placeholder,
|
|
32
|
+
size: "small",
|
|
33
|
+
...field,
|
|
34
|
+
...rest,
|
|
35
|
+
inputRef,
|
|
36
|
+
InputProps: Object.assign(
|
|
37
|
+
rest.InputProps || {},
|
|
38
|
+
errorPosition === "right" && error ? { endAdornment: /* @__PURE__ */ jsx(FormInputError, { error }) } : {}
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
] })
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
);
|
|
5
47
|
FormInput.defaultProps = {
|
|
6
48
|
label: "",
|
|
7
49
|
placeholder: "",
|
|
@@ -9,45 +51,4 @@ FormInput.defaultProps = {
|
|
|
9
51
|
rules: {},
|
|
10
52
|
wrapperStyle: {}
|
|
11
53
|
};
|
|
12
|
-
export
|
|
13
|
-
return /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx(Typography, { component: "span", color: "error", children: error }) });
|
|
14
|
-
}
|
|
15
|
-
export default function FormInput({
|
|
16
|
-
name,
|
|
17
|
-
label,
|
|
18
|
-
placeholder,
|
|
19
|
-
rules,
|
|
20
|
-
errorPosition,
|
|
21
|
-
wrapperStyle,
|
|
22
|
-
...rest
|
|
23
|
-
}) {
|
|
24
|
-
const { control, formState } = useFormContext();
|
|
25
|
-
const error = get(formState.errors, name)?.message;
|
|
26
|
-
return /* @__PURE__ */ jsx(
|
|
27
|
-
Controller,
|
|
28
|
-
{
|
|
29
|
-
name,
|
|
30
|
-
control,
|
|
31
|
-
rules,
|
|
32
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Box, { sx: { width: "100%", ...wrapperStyle }, children: [
|
|
33
|
-
!!label && /* @__PURE__ */ jsx(FormLabel, { children: label }),
|
|
34
|
-
/* @__PURE__ */ jsx(
|
|
35
|
-
TextField,
|
|
36
|
-
{
|
|
37
|
-
fullWidth: true,
|
|
38
|
-
error: !!get(formState.errors, name),
|
|
39
|
-
helperText: errorPosition === "bottom" && error ? error : "",
|
|
40
|
-
placeholder,
|
|
41
|
-
size: "small",
|
|
42
|
-
...field,
|
|
43
|
-
...rest,
|
|
44
|
-
InputProps: Object.assign(
|
|
45
|
-
rest.InputProps || {},
|
|
46
|
-
errorPosition === "right" && error ? { endAdornment: /* @__PURE__ */ jsx(FormInputError, { error }) } : {}
|
|
47
|
-
)
|
|
48
|
-
}
|
|
49
|
-
)
|
|
50
|
-
] })
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
+
export default FormInput;
|
|
@@ -254,7 +254,6 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
|
|
|
254
254
|
color: "text.primary",
|
|
255
255
|
fontWeight: 600,
|
|
256
256
|
sx: {
|
|
257
|
-
color: "#4B5563",
|
|
258
257
|
fontSize: "18px !important",
|
|
259
258
|
fontWeight: "600"
|
|
260
259
|
},
|
|
@@ -288,7 +287,6 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
|
|
|
288
287
|
color: "text.secondary",
|
|
289
288
|
sx: {
|
|
290
289
|
marginTop: "0px !important",
|
|
291
|
-
color: "#4b5563",
|
|
292
290
|
fontWeight: "400",
|
|
293
291
|
fontSize: "16px",
|
|
294
292
|
textAlign: "left"
|
package/es/components/status.js
CHANGED
|
@@ -5,14 +5,13 @@ export default function Status(props) {
|
|
|
5
5
|
Chip,
|
|
6
6
|
{
|
|
7
7
|
size: "small",
|
|
8
|
-
variant: "
|
|
8
|
+
variant: "filled",
|
|
9
9
|
...props,
|
|
10
10
|
sx: {
|
|
11
11
|
...props.sx || {},
|
|
12
12
|
borderRadius: "4px",
|
|
13
13
|
height: 20,
|
|
14
|
-
textTransform: "capitalize"
|
|
15
|
-
marginRight: "10px"
|
|
14
|
+
textTransform: "capitalize"
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
17
|
);
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import Empty from "@arcblock/ux/lib/Empty";
|
|
4
|
+
import Datatable from "@arcblock/ux/lib/Datatable";
|
|
5
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
6
|
+
import { styled } from "@mui/system";
|
|
7
|
+
import { useMobile } from "../hooks/mobile.js";
|
|
8
|
+
function EmptyStub() {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const Table = React.memo(
|
|
12
|
+
({ options, columns, toolbar = true, footer = true, hasRowLink = false, emptyNodeText = "", ...rest }) => {
|
|
13
|
+
const { locale, t } = useLocaleContext();
|
|
14
|
+
const { isMobile } = useMobile();
|
|
15
|
+
const defaultOptions = {
|
|
16
|
+
print: false,
|
|
17
|
+
download: false,
|
|
18
|
+
filter: false,
|
|
19
|
+
selectableRows: "none",
|
|
20
|
+
rowsPerPage: 10,
|
|
21
|
+
rowsPerPageOptions: [10, 20, 50, 100],
|
|
22
|
+
searchDebounceTime: 300,
|
|
23
|
+
tableBodyHeight: "100%",
|
|
24
|
+
loading: true
|
|
25
|
+
};
|
|
26
|
+
const components = {};
|
|
27
|
+
if (!toolbar) {
|
|
28
|
+
components.TableToolbar = EmptyStub;
|
|
29
|
+
}
|
|
30
|
+
if (!footer) {
|
|
31
|
+
components.TableFooter = EmptyStub;
|
|
32
|
+
}
|
|
33
|
+
return /* @__PURE__ */ jsx(
|
|
34
|
+
Wrapped,
|
|
35
|
+
{
|
|
36
|
+
locale,
|
|
37
|
+
options: { ...defaultOptions, ...options },
|
|
38
|
+
columns: columns.map((x) => {
|
|
39
|
+
x.options = x.options || {};
|
|
40
|
+
x.options.filter = x.options.filter || false;
|
|
41
|
+
x.options.sort = x.options.sort || false;
|
|
42
|
+
return x;
|
|
43
|
+
}),
|
|
44
|
+
emptyNode: /* @__PURE__ */ jsx(Empty, { children: emptyNodeText || t("empty.records") }),
|
|
45
|
+
...rest,
|
|
46
|
+
components,
|
|
47
|
+
hasRowLink,
|
|
48
|
+
isMobile
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
const Wrapped = styled(Datatable)`
|
|
54
|
+
${(props) => props.hasRowLink ? `.MuiTableCell-root {
|
|
55
|
+
font-size: 1rem !important;
|
|
56
|
+
}` : ""}
|
|
57
|
+
.MuiPaper-root {
|
|
58
|
+
border-radius: 8px;
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
}
|
|
61
|
+
table.MuiTable-root {
|
|
62
|
+
outline: 1px solid var(--stroke-border-base, #eff1f5);
|
|
63
|
+
border-radius: var(--radius-m, 8px);
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
}
|
|
66
|
+
[class*='MUIDataTable-responsiveBase'] {
|
|
67
|
+
outline: 1px solid var(--stroke-border-base, #eff1f5);
|
|
68
|
+
border-radius: var(--radius-m, 8px);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
th.MuiTableCell-head {
|
|
72
|
+
padding: 8px 16px 8px 16px;
|
|
73
|
+
text-transform: inherit;
|
|
74
|
+
background: var(--backgrounds-bg-subtle, #f9fafb);
|
|
75
|
+
border-bottom: none;
|
|
76
|
+
&:first-of-type {
|
|
77
|
+
border-top-left-radius: 8px;
|
|
78
|
+
padding-left: 20px;
|
|
79
|
+
}
|
|
80
|
+
&:last-of-type {
|
|
81
|
+
border-top-right-radius: 8px;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
tr.MuiTableRow-root:not(.MuiTableRow-footer):hover {
|
|
86
|
+
background: #f5f5f5;
|
|
87
|
+
}
|
|
88
|
+
tr.MuiTableRow-root:last-of-type td:first-of-type {
|
|
89
|
+
border-bottom-left-radius: 8px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
tr.MuiTableRow-root:last-of-type td:last-of-type {
|
|
93
|
+
border-bottom-right-radius: 8px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
tr.MuiTableRow-root:nth-of-type(even) {
|
|
97
|
+
background: var(--backgrounds-bg-subtle, #f9fafb);
|
|
98
|
+
}
|
|
99
|
+
td.MuiTableCell-root {
|
|
100
|
+
border-bottom: none;
|
|
101
|
+
&:first-of-type {
|
|
102
|
+
padding-left: 20px;
|
|
103
|
+
}
|
|
104
|
+
&.MuiTableCell-footer {
|
|
105
|
+
border: none;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.datatable-footer {
|
|
110
|
+
.MuiTableRow-root.MuiTableRow-footer {
|
|
111
|
+
border: none;
|
|
112
|
+
}
|
|
113
|
+
table.MuiTable-root {
|
|
114
|
+
outline: none;
|
|
115
|
+
overflow: hidden;
|
|
116
|
+
}
|
|
117
|
+
.MuiTablePagination-input {
|
|
118
|
+
background: none;
|
|
119
|
+
}
|
|
120
|
+
div.MuiSelect-select {
|
|
121
|
+
padding: 0 24px 0 0;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
th a,
|
|
126
|
+
td a {
|
|
127
|
+
text-decoration: none;
|
|
128
|
+
display: block;
|
|
129
|
+
color: inherit;
|
|
130
|
+
&:first-of-type {
|
|
131
|
+
padding-left: 0;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
> div {
|
|
136
|
+
overflow: auto;
|
|
137
|
+
}
|
|
138
|
+
@media (max-width: ${({ theme }) => theme.breakpoints.values.md}px) {
|
|
139
|
+
th a,
|
|
140
|
+
td a {
|
|
141
|
+
text-decoration: none;
|
|
142
|
+
display: block;
|
|
143
|
+
color: inherit;
|
|
144
|
+
padding-top: 0;
|
|
145
|
+
padding-bottom: 0;
|
|
146
|
+
padding-right: 0;
|
|
147
|
+
}
|
|
148
|
+
tr.MuiTableRow-root {
|
|
149
|
+
border: none;
|
|
150
|
+
padding: 20px;
|
|
151
|
+
display: block;
|
|
152
|
+
}
|
|
153
|
+
td.MuiTableCell-root:first-of-type {
|
|
154
|
+
padding-left: 0;
|
|
155
|
+
margin-top: 0;
|
|
156
|
+
}
|
|
157
|
+
td.MuiTableCell-root {
|
|
158
|
+
margin: 0;
|
|
159
|
+
margin-top: 8px;
|
|
160
|
+
align-items: center;
|
|
161
|
+
padding: 0;
|
|
162
|
+
flex-wrap: wrap;
|
|
163
|
+
flex-direction: ${({ mobileTDFlexDirection = "column" }) => mobileTDFlexDirection || "row"};
|
|
164
|
+
align-items: ${({ mobileTDFlexDirection = "column" }) => mobileTDFlexDirection === "column" ? "flex-start" : "center"};
|
|
165
|
+
justify-content: ${({ mobileTDFlexDirection = "column" }) => mobileTDFlexDirection === "column" ? "flex-start" : "space-between"};
|
|
166
|
+
}
|
|
167
|
+
td.MuiTableCell-root > div {
|
|
168
|
+
margin-bottom: 4px;
|
|
169
|
+
}
|
|
170
|
+
.MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > td.MuiTableCell-root {
|
|
171
|
+
display: flex;
|
|
172
|
+
flex-direction: ${({ mobileTDFlexDirection = "column" }) => mobileTDFlexDirection || "row"};
|
|
173
|
+
align-items: flex-start;
|
|
174
|
+
justify-content: ${({ mobileTDFlexDirection = "column" }) => mobileTDFlexDirection === "row" ? "space-between" : "flex-start"};
|
|
175
|
+
flex-wrap: ${({ mobileTDFlexDirection = "column" }) => mobileTDFlexDirection === "row" ? "nowrap" : "wrap"};
|
|
176
|
+
word-break: break-all;
|
|
177
|
+
&.datatables-noprint {
|
|
178
|
+
justify-content: center;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
[class*='MUIDataTable-responsiveBase'] tr:not([class*='responsiveSimple']) td.MuiTableCell-body > div {
|
|
182
|
+
width: inherit;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
`;
|
|
186
|
+
export default Table;
|
package/es/contexts/payment.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export type PaymentContextType = {
|
|
|
18
18
|
getMethod: (methodId: string) => TPaymentMethodExpanded | undefined;
|
|
19
19
|
setLivemode: (livemode: boolean) => void;
|
|
20
20
|
api: Axios;
|
|
21
|
+
payable: boolean;
|
|
22
|
+
setPayable: (status: boolean) => void;
|
|
21
23
|
};
|
|
22
24
|
export type PaymentContextProps = {
|
|
23
25
|
session: import('@arcblock/did-connect/lib/types').SessionContext['session'];
|
package/es/contexts/payment.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Alert } from "@mui/material";
|
|
3
3
|
import { useLocalStorageState, useRequest } from "ahooks";
|
|
4
|
-
import { createContext, useContext } from "react";
|
|
4
|
+
import { createContext, useContext, useState } from "react";
|
|
5
5
|
import api from "../libs/api.js";
|
|
6
6
|
import { getPrefix } from "../libs/util.js";
|
|
7
7
|
const PaymentContext = createContext({ api });
|
|
@@ -24,6 +24,7 @@ function PaymentProvider({ session, connect, children, baseUrl }) {
|
|
|
24
24
|
const { data, error, run, loading } = useRequest(getSettings);
|
|
25
25
|
const [livemode, setLivemode] = useLocalStorageState("livemode", { defaultValue: true });
|
|
26
26
|
const prefix = getPrefix();
|
|
27
|
+
const [payable, setPayable] = useState(true);
|
|
27
28
|
if (error) {
|
|
28
29
|
return /* @__PURE__ */ jsx(Alert, { severity: "error", children: error.message });
|
|
29
30
|
}
|
|
@@ -43,7 +44,9 @@ function PaymentProvider({ session, connect, children, baseUrl }) {
|
|
|
43
44
|
getMethod: (methodId) => getMethod(methodId, data.paymentMethods),
|
|
44
45
|
refresh: run,
|
|
45
46
|
setLivemode,
|
|
46
|
-
api
|
|
47
|
+
api,
|
|
48
|
+
payable,
|
|
49
|
+
setPayable
|
|
47
50
|
},
|
|
48
51
|
children
|
|
49
52
|
}
|