@blocklet/payment-react 1.18.56 → 1.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/checkout/donate.d.ts +1 -15
- package/es/checkout/donate.js +301 -189
- package/es/checkout/form.d.ts +1 -15
- package/es/checkout/form.js +5 -13
- package/es/checkout/table.js +3 -3
- package/es/components/blockchain/gas.d.ts +1 -5
- package/es/components/blockchain/gas.js +10 -2
- package/es/components/blockchain/tx.d.ts +1 -8
- package/es/components/blockchain/tx.js +29 -10
- package/es/components/confirm.d.ts +1 -10
- package/es/components/confirm.js +4 -10
- package/es/components/country-select.d.ts +3 -2
- package/es/components/country-select.js +375 -352
- package/es/components/date-range-picker.d.ts +13 -0
- package/es/components/date-range-picker.js +279 -0
- package/es/components/input.d.ts +14 -20
- package/es/components/input.js +51 -44
- package/es/components/label.d.ts +7 -0
- package/es/components/label.js +49 -0
- package/es/components/lazy-loader.js +1 -2
- package/es/components/link.d.ts +2 -9
- package/es/components/link.js +9 -6
- package/es/components/livemode.d.ts +2 -8
- package/es/components/livemode.js +1 -5
- package/es/components/loading-button.d.ts +6 -1
- package/es/components/loading-button.js +56 -66
- package/es/components/over-due-invoice-payment.d.ts +0 -18
- package/es/components/over-due-invoice-payment.js +138 -95
- package/es/components/payment-beneficiaries.d.ts +2 -7
- package/es/components/payment-beneficiaries.js +86 -40
- package/es/components/pricing-item.d.ts +0 -5
- package/es/components/pricing-item.js +1 -4
- package/es/components/pricing-table.d.ts +2 -10
- package/es/components/pricing-table.js +8 -7
- package/es/components/resume-subscription.d.ts +0 -10
- package/es/components/resume-subscription.js +42 -21
- package/es/components/truncated-text.d.ts +2 -9
- package/es/components/truncated-text.js +0 -5
- package/es/contexts/donate.d.ts +0 -7
- package/es/contexts/donate.js +10 -8
- package/es/contexts/payment.d.ts +1 -4
- package/es/contexts/payment.js +7 -2
- package/es/history/credit/grants-list.d.ts +14 -0
- package/es/history/credit/grants-list.js +215 -0
- package/es/history/credit/transactions-list.d.ts +13 -0
- package/es/history/credit/transactions-list.js +255 -0
- package/es/history/invoice/list.d.ts +2 -18
- package/es/history/invoice/list.js +172 -74
- package/es/history/payment/list.js +115 -38
- package/es/hooks/keyboard.d.ts +1 -1
- package/es/hooks/keyboard.js +2 -4
- package/es/index.d.ts +5 -1
- package/es/index.js +10 -1
- package/es/libs/cached-request.js +2 -4
- package/es/libs/phone-validator.js +1 -2
- package/es/libs/util.d.ts +2 -0
- package/es/libs/util.js +14 -4
- package/es/libs/validator.js +2 -4
- package/es/locales/en.js +20 -2
- package/es/locales/zh.js +20 -2
- package/es/payment/amount.d.ts +2 -7
- package/es/payment/amount.js +1 -5
- package/es/payment/donation-form.d.ts +2 -10
- package/es/payment/donation-form.js +196 -160
- package/es/payment/error.d.ts +2 -8
- package/es/payment/error.js +40 -20
- package/es/payment/footer.d.ts +2 -3
- package/es/payment/footer.js +19 -6
- package/es/payment/form/addon.js +14 -4
- package/es/payment/form/address.d.ts +2 -9
- package/es/payment/form/address.js +3 -6
- package/es/payment/form/currency.js +45 -25
- package/es/payment/form/index.d.ts +2 -8
- package/es/payment/form/index.js +151 -71
- package/es/payment/form/phone.js +2 -4
- package/es/payment/form/stripe/form.d.ts +2 -8
- package/es/payment/form/stripe/form.js +1 -3
- package/es/payment/header.js +38 -16
- package/es/payment/index.d.ts +2 -9
- package/es/payment/index.js +23 -17
- package/es/payment/product-card.d.ts +2 -11
- package/es/payment/product-card.js +84 -50
- package/es/payment/product-donation.js +175 -114
- package/es/payment/product-item.d.ts +9 -9
- package/es/payment/product-item.js +320 -145
- package/es/payment/product-skeleton.js +2 -2
- package/es/payment/skeleton/donation.js +27 -7
- package/es/payment/skeleton/overview.js +22 -2
- package/es/payment/skeleton/payment.js +33 -5
- package/es/payment/success.d.ts +2 -9
- package/es/payment/success.js +41 -14
- package/es/payment/summary.d.ts +4 -17
- package/es/payment/summary.js +193 -111
- package/es/theme/index.d.ts +0 -5
- package/es/theme/index.js +2 -5
- package/es/theme/typography.d.ts +2 -2
- package/lib/checkout/donate.d.ts +1 -15
- package/lib/checkout/donate.js +75 -54
- package/lib/checkout/form.d.ts +1 -15
- package/lib/checkout/form.js +7 -15
- package/lib/checkout/table.js +4 -4
- package/lib/components/blockchain/gas.d.ts +1 -5
- package/lib/components/blockchain/gas.js +3 -2
- package/lib/components/blockchain/tx.d.ts +1 -8
- package/lib/components/blockchain/tx.js +15 -10
- package/lib/components/confirm.d.ts +1 -10
- package/lib/components/confirm.js +5 -11
- package/lib/components/country-select.d.ts +3 -2
- package/lib/components/country-select.js +23 -22
- package/lib/components/date-range-picker.d.ts +13 -0
- package/lib/components/date-range-picker.js +329 -0
- package/lib/components/input.d.ts +14 -20
- package/lib/components/input.js +28 -27
- package/lib/components/label.d.ts +7 -0
- package/lib/components/label.js +60 -0
- package/lib/components/lazy-loader.js +1 -1
- package/lib/components/link.d.ts +2 -9
- package/lib/components/link.js +3 -8
- package/lib/components/livemode.d.ts +2 -8
- package/lib/components/livemode.js +3 -7
- package/lib/components/loading-button.d.ts +6 -1
- package/lib/components/loading-button.js +9 -17
- package/lib/components/over-due-invoice-payment.d.ts +0 -18
- package/lib/components/over-due-invoice-payment.js +31 -33
- package/lib/components/payment-beneficiaries.d.ts +2 -7
- package/lib/components/payment-beneficiaries.js +12 -11
- package/lib/components/pricing-item.d.ts +0 -5
- package/lib/components/pricing-item.js +2 -5
- package/lib/components/pricing-table.d.ts +2 -10
- package/lib/components/pricing-table.js +5 -11
- package/lib/components/resume-subscription.d.ts +0 -10
- package/lib/components/resume-subscription.js +16 -16
- package/lib/components/table.js +1 -1
- package/lib/components/truncated-text.d.ts +2 -9
- package/lib/components/truncated-text.js +1 -6
- package/lib/contexts/donate.d.ts +0 -7
- package/lib/contexts/donate.js +4 -7
- package/lib/contexts/payment.d.ts +1 -4
- package/lib/contexts/payment.js +4 -7
- package/lib/history/credit/grants-list.d.ts +14 -0
- package/lib/history/credit/grants-list.js +277 -0
- package/lib/history/credit/transactions-list.d.ts +13 -0
- package/lib/history/credit/transactions-list.js +301 -0
- package/lib/history/invoice/list.d.ts +2 -18
- package/lib/history/invoice/list.js +73 -37
- package/lib/history/payment/list.js +30 -16
- package/lib/hooks/keyboard.d.ts +1 -1
- package/lib/hooks/mobile.js +1 -1
- package/lib/hooks/subscription.js +1 -1
- package/lib/index.d.ts +5 -1
- package/lib/index.js +41 -2
- package/lib/libs/api.js +1 -1
- package/lib/libs/dayjs.js +1 -1
- package/lib/libs/phone-validator.js +0 -2
- package/lib/libs/theme.js +1 -1
- package/lib/libs/util.d.ts +2 -0
- package/lib/libs/util.js +15 -1
- package/lib/libs/validator.js +1 -1
- package/lib/locales/en.js +21 -3
- package/lib/locales/index.js +1 -1
- package/lib/locales/zh.js +21 -3
- package/lib/payment/amount.d.ts +2 -7
- package/lib/payment/amount.js +2 -6
- package/lib/payment/donation-form.d.ts +2 -10
- package/lib/payment/donation-form.js +33 -38
- package/lib/payment/error.d.ts +2 -8
- package/lib/payment/error.js +11 -13
- package/lib/payment/footer.d.ts +2 -3
- package/lib/payment/footer.js +5 -5
- package/lib/payment/form/addon.js +5 -3
- package/lib/payment/form/address.d.ts +2 -9
- package/lib/payment/form/address.js +5 -8
- package/lib/payment/form/currency.js +3 -3
- package/lib/payment/form/index.d.ts +2 -8
- package/lib/payment/form/index.js +64 -21
- package/lib/payment/form/phone.js +1 -1
- package/lib/payment/form/stripe/form.d.ts +2 -8
- package/lib/payment/form/stripe/form.js +3 -6
- package/lib/payment/header.js +8 -4
- package/lib/payment/index.d.ts +2 -9
- package/lib/payment/index.js +27 -18
- package/lib/payment/product-card.d.ts +2 -11
- package/lib/payment/product-card.js +13 -20
- package/lib/payment/product-donation.js +71 -66
- package/lib/payment/product-item.d.ts +9 -9
- package/lib/payment/product-item.js +168 -29
- package/lib/payment/product-skeleton.js +2 -2
- package/lib/payment/skeleton/donation.js +8 -4
- package/lib/payment/skeleton/overview.js +6 -2
- package/lib/payment/skeleton/payment.js +9 -3
- package/lib/payment/success.d.ts +2 -9
- package/lib/payment/success.js +12 -15
- package/lib/payment/summary.d.ts +4 -17
- package/lib/payment/summary.js +53 -45
- package/lib/theme/index.d.ts +0 -5
- package/lib/theme/index.js +2 -5
- package/lib/theme/typography.d.ts +2 -2
- package/package.json +40 -40
- package/src/checkout/donate.tsx +103 -35
- package/src/checkout/form.tsx +5 -14
- package/src/checkout/table.tsx +3 -3
- package/src/components/blockchain/gas.tsx +5 -3
- package/src/components/blockchain/tx.tsx +19 -11
- package/src/components/confirm.tsx +4 -11
- package/src/components/country-select.tsx +391 -378
- package/src/components/date-range-picker.tsx +310 -0
- package/src/components/input.tsx +61 -46
- package/src/components/label.tsx +58 -0
- package/src/components/link.tsx +9 -7
- package/src/components/livemode.tsx +2 -6
- package/src/components/loading-button.tsx +63 -76
- package/src/components/over-due-invoice-payment.tsx +43 -28
- package/src/components/payment-beneficiaries.tsx +33 -14
- package/src/components/pricing-item.tsx +1 -4
- package/src/components/pricing-table.tsx +8 -8
- package/src/components/resume-subscription.tsx +20 -14
- package/src/components/table.tsx +2 -2
- package/src/components/truncated-text.tsx +0 -6
- package/src/contexts/donate.tsx +6 -7
- package/src/contexts/payment.tsx +7 -3
- package/src/history/credit/grants-list.tsx +276 -0
- package/src/history/credit/transactions-list.tsx +317 -0
- package/src/history/invoice/list.tsx +92 -36
- package/src/history/payment/list.tsx +53 -16
- package/src/hooks/keyboard.ts +1 -1
- package/src/index.ts +9 -0
- package/src/libs/util.ts +14 -0
- package/src/locales/en.tsx +20 -0
- package/src/locales/zh.tsx +19 -0
- package/src/payment/amount.tsx +1 -6
- package/src/payment/donation-form.tsx +47 -29
- package/src/payment/error.tsx +16 -8
- package/src/payment/footer.tsx +11 -3
- package/src/payment/form/addon.tsx +6 -1
- package/src/payment/form/address.tsx +3 -7
- package/src/payment/form/currency.tsx +12 -2
- package/src/payment/form/index.tsx +121 -45
- package/src/payment/form/stripe/form.tsx +1 -5
- package/src/payment/header.tsx +14 -2
- package/src/payment/index.tsx +27 -22
- package/src/payment/product-card.tsx +41 -18
- package/src/payment/product-donation.tsx +85 -47
- package/src/payment/product-item.tsx +198 -28
- package/src/payment/product-skeleton.tsx +3 -2
- package/src/payment/skeleton/donation.tsx +12 -2
- package/src/payment/skeleton/overview.tsx +12 -2
- package/src/payment/skeleton/payment.tsx +16 -3
- package/src/payment/success.tsx +26 -15
- package/src/payment/summary.tsx +87 -44
- package/src/theme/index.tsx +5 -8
- package/src/theme/typography.ts +2 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface DateRangeValue {
|
|
2
|
+
start: number | undefined;
|
|
3
|
+
end: number | undefined;
|
|
4
|
+
}
|
|
5
|
+
export interface DateRangePickerProps {
|
|
6
|
+
value: DateRangeValue;
|
|
7
|
+
onChange: (value: DateRangeValue) => void;
|
|
8
|
+
label?: string;
|
|
9
|
+
size?: 'small' | 'medium';
|
|
10
|
+
fullWidth?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export default function DateRangePicker({ value, onChange, label, size, fullWidth, disabled, }: DateRangePickerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef } from "react";
|
|
3
|
+
import {
|
|
4
|
+
TextField,
|
|
5
|
+
Stack,
|
|
6
|
+
Typography,
|
|
7
|
+
useMediaQuery,
|
|
8
|
+
useTheme,
|
|
9
|
+
Popover,
|
|
10
|
+
Dialog,
|
|
11
|
+
DialogTitle,
|
|
12
|
+
DialogContent,
|
|
13
|
+
DialogActions,
|
|
14
|
+
Button,
|
|
15
|
+
Box,
|
|
16
|
+
IconButton
|
|
17
|
+
} from "@mui/material";
|
|
18
|
+
import { DateRange, Close, Clear } from "@mui/icons-material";
|
|
19
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
20
|
+
import FormLabel from "./label.js";
|
|
21
|
+
import { formatToDate } from "../libs/util.js";
|
|
22
|
+
function DatePickerContent({
|
|
23
|
+
tempValue,
|
|
24
|
+
setTempValue,
|
|
25
|
+
handleCancel,
|
|
26
|
+
handleApply,
|
|
27
|
+
handleClear
|
|
28
|
+
}) {
|
|
29
|
+
const { t } = useLocaleContext();
|
|
30
|
+
return /* @__PURE__ */ jsx(Box, { sx: { p: 2, minWidth: 320 }, children: /* @__PURE__ */ jsxs(Stack, { spacing: 2, children: [
|
|
31
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
32
|
+
/* @__PURE__ */ jsx(FormLabel, { children: t("common.startDate") }),
|
|
33
|
+
/* @__PURE__ */ jsx(
|
|
34
|
+
TextField,
|
|
35
|
+
{
|
|
36
|
+
type: "date",
|
|
37
|
+
value: tempValue.startDate,
|
|
38
|
+
onChange: (e) => setTempValue((prev) => ({ ...prev, startDate: e.target.value })),
|
|
39
|
+
size: "small",
|
|
40
|
+
fullWidth: true,
|
|
41
|
+
slotProps: {
|
|
42
|
+
inputLabel: { shrink: true }
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
] }),
|
|
47
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
48
|
+
/* @__PURE__ */ jsx(FormLabel, { children: t("common.endDate") }),
|
|
49
|
+
/* @__PURE__ */ jsx(
|
|
50
|
+
TextField,
|
|
51
|
+
{
|
|
52
|
+
type: "date",
|
|
53
|
+
value: tempValue.endDate,
|
|
54
|
+
onChange: (e) => setTempValue((prev) => ({ ...prev, endDate: e.target.value })),
|
|
55
|
+
size: "small",
|
|
56
|
+
fullWidth: true,
|
|
57
|
+
slotProps: {
|
|
58
|
+
inputLabel: { shrink: true }
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
] }),
|
|
63
|
+
/* @__PURE__ */ jsxs(
|
|
64
|
+
Stack,
|
|
65
|
+
{
|
|
66
|
+
direction: "row",
|
|
67
|
+
spacing: 1,
|
|
68
|
+
sx: {
|
|
69
|
+
justifyContent: "space-between"
|
|
70
|
+
},
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ jsx(Button, { variant: "text", onClick: handleClear, size: "small", color: "secondary", sx: { px: 0.5, minWidth: 0 }, children: t("common.clear") }),
|
|
73
|
+
/* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, children: [
|
|
74
|
+
/* @__PURE__ */ jsx(Button, { variant: "outlined", onClick: handleCancel, size: "small", children: t("common.cancel") }),
|
|
75
|
+
/* @__PURE__ */ jsx(Button, { variant: "contained", onClick: handleApply, size: "small", children: t("common.confirm") })
|
|
76
|
+
] })
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
] }) });
|
|
81
|
+
}
|
|
82
|
+
const DateFormat = "YYYY-MM-DD";
|
|
83
|
+
export default function DateRangePicker({
|
|
84
|
+
value,
|
|
85
|
+
onChange,
|
|
86
|
+
label = "",
|
|
87
|
+
size = "small",
|
|
88
|
+
fullWidth = false,
|
|
89
|
+
disabled = false
|
|
90
|
+
}) {
|
|
91
|
+
const theme = useTheme();
|
|
92
|
+
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
|
|
93
|
+
const [open, setOpen] = useState(false);
|
|
94
|
+
const { t, locale } = useLocaleContext();
|
|
95
|
+
const [tempValue, setTempValue] = useState({
|
|
96
|
+
startDate: value.start ? formatToDate(value.start * 1e3, locale, DateFormat) : "",
|
|
97
|
+
endDate: value.end ? formatToDate(value.end * 1e3, locale, DateFormat) : ""
|
|
98
|
+
});
|
|
99
|
+
const anchorRef = useRef(null);
|
|
100
|
+
const formatDisplayValue = (startUnix, endUnix) => {
|
|
101
|
+
if (!startUnix || !endUnix) return t("common.selectTimeRange");
|
|
102
|
+
const start = formatToDate(startUnix * 1e3, locale, DateFormat);
|
|
103
|
+
const end = formatToDate(endUnix * 1e3, locale, DateFormat);
|
|
104
|
+
return `${start} ~ ${end}`;
|
|
105
|
+
};
|
|
106
|
+
const handleOpen = () => {
|
|
107
|
+
if (disabled) return;
|
|
108
|
+
setTempValue({
|
|
109
|
+
startDate: value.start ? formatToDate(value.start * 1e3, locale, DateFormat) : "",
|
|
110
|
+
endDate: value.end ? formatToDate(value.end * 1e3, locale, DateFormat) : ""
|
|
111
|
+
});
|
|
112
|
+
setOpen(true);
|
|
113
|
+
};
|
|
114
|
+
const handleClose = () => {
|
|
115
|
+
setOpen(false);
|
|
116
|
+
};
|
|
117
|
+
const handleApply = () => {
|
|
118
|
+
const unixValue = {
|
|
119
|
+
start: tempValue.startDate ? Math.floor((/* @__PURE__ */ new Date(`${tempValue.startDate}T00:00:00`)).getTime() / 1e3) : 0,
|
|
120
|
+
end: tempValue.endDate ? Math.floor((/* @__PURE__ */ new Date(`${tempValue.endDate}T23:59:59`)).getTime() / 1e3) : 0
|
|
121
|
+
};
|
|
122
|
+
onChange(unixValue);
|
|
123
|
+
setOpen(false);
|
|
124
|
+
};
|
|
125
|
+
const handleCancel = () => {
|
|
126
|
+
setTempValue({
|
|
127
|
+
startDate: value.start ? formatToDate(value.start * 1e3, locale, DateFormat) : "",
|
|
128
|
+
endDate: value.end ? formatToDate(value.end * 1e3, locale, DateFormat) : ""
|
|
129
|
+
});
|
|
130
|
+
setOpen(false);
|
|
131
|
+
};
|
|
132
|
+
const handleClear = () => {
|
|
133
|
+
const emptyValue = { start: void 0, end: void 0 };
|
|
134
|
+
onChange(emptyValue);
|
|
135
|
+
setTempValue({ startDate: "", endDate: "" });
|
|
136
|
+
setOpen(false);
|
|
137
|
+
};
|
|
138
|
+
const hasValue = !!value.start && !!value.end;
|
|
139
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
140
|
+
/* @__PURE__ */ jsx(
|
|
141
|
+
TextField,
|
|
142
|
+
{
|
|
143
|
+
ref: anchorRef,
|
|
144
|
+
label,
|
|
145
|
+
value: formatDisplayValue(value.start, value.end),
|
|
146
|
+
size,
|
|
147
|
+
fullWidth,
|
|
148
|
+
disabled,
|
|
149
|
+
sx: {
|
|
150
|
+
"& .MuiInputBase-input": {
|
|
151
|
+
cursor: disabled ? "default" : "pointer"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
onClick: handleOpen,
|
|
155
|
+
placeholder: t("common.selectTimeRange"),
|
|
156
|
+
slotProps: {
|
|
157
|
+
input: {
|
|
158
|
+
readOnly: true,
|
|
159
|
+
startAdornment: /* @__PURE__ */ jsx(DateRange, { fontSize: "small", sx: { mr: 1, color: "text.secondary" } }),
|
|
160
|
+
endAdornment: hasValue && !disabled && /* @__PURE__ */ jsx(
|
|
161
|
+
IconButton,
|
|
162
|
+
{
|
|
163
|
+
size: "small",
|
|
164
|
+
onClick: (e) => {
|
|
165
|
+
e.stopPropagation();
|
|
166
|
+
handleClear();
|
|
167
|
+
},
|
|
168
|
+
sx: {
|
|
169
|
+
color: "text.secondary",
|
|
170
|
+
"&:hover": { color: "text.primary" }
|
|
171
|
+
},
|
|
172
|
+
children: /* @__PURE__ */ jsx(Clear, { fontSize: "small" })
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
},
|
|
176
|
+
inputLabel: { shrink: true }
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
),
|
|
180
|
+
!isMobile && /* @__PURE__ */ jsx(
|
|
181
|
+
Popover,
|
|
182
|
+
{
|
|
183
|
+
open,
|
|
184
|
+
anchorEl: anchorRef.current,
|
|
185
|
+
onClose: handleClose,
|
|
186
|
+
anchorOrigin: {
|
|
187
|
+
vertical: "bottom",
|
|
188
|
+
horizontal: "left"
|
|
189
|
+
},
|
|
190
|
+
transformOrigin: {
|
|
191
|
+
vertical: "top",
|
|
192
|
+
horizontal: "left"
|
|
193
|
+
},
|
|
194
|
+
sx: {
|
|
195
|
+
"& .MuiPaper-root": {
|
|
196
|
+
boxShadow: theme.shadows[8],
|
|
197
|
+
border: `1px solid ${theme.palette.divider}`
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
children: /* @__PURE__ */ jsx(
|
|
201
|
+
DatePickerContent,
|
|
202
|
+
{
|
|
203
|
+
tempValue,
|
|
204
|
+
setTempValue,
|
|
205
|
+
handleCancel,
|
|
206
|
+
handleApply,
|
|
207
|
+
handleClear
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
),
|
|
212
|
+
isMobile && /* @__PURE__ */ jsxs(
|
|
213
|
+
Dialog,
|
|
214
|
+
{
|
|
215
|
+
open,
|
|
216
|
+
onClose: handleClose,
|
|
217
|
+
fullWidth: true,
|
|
218
|
+
maxWidth: "sm",
|
|
219
|
+
PaperProps: {
|
|
220
|
+
sx: {
|
|
221
|
+
m: 1,
|
|
222
|
+
maxHeight: "calc(100% - 64px)"
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
children: [
|
|
226
|
+
/* @__PURE__ */ jsxs(
|
|
227
|
+
DialogTitle,
|
|
228
|
+
{
|
|
229
|
+
sx: {
|
|
230
|
+
display: "flex",
|
|
231
|
+
justifyContent: "space-between",
|
|
232
|
+
alignItems: "center",
|
|
233
|
+
pb: 1
|
|
234
|
+
},
|
|
235
|
+
children: [
|
|
236
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h6", children: t("common.selectTimeRange") }),
|
|
237
|
+
/* @__PURE__ */ jsx(IconButton, { edge: "end", color: "inherit", onClick: handleClose, "aria-label": "close", size: "small", children: /* @__PURE__ */ jsx(Close, {}) })
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
),
|
|
241
|
+
/* @__PURE__ */ jsx(DialogContent, { sx: { pb: 1 }, children: /* @__PURE__ */ jsxs(Stack, { spacing: 2, sx: { mt: 1 }, children: [
|
|
242
|
+
/* @__PURE__ */ jsx(FormLabel, { children: t("common.startDate") }),
|
|
243
|
+
/* @__PURE__ */ jsx(
|
|
244
|
+
TextField,
|
|
245
|
+
{
|
|
246
|
+
type: "date",
|
|
247
|
+
value: tempValue.startDate,
|
|
248
|
+
onChange: (e) => setTempValue((prev) => ({ ...prev, startDate: e.target.value })),
|
|
249
|
+
size: "small",
|
|
250
|
+
fullWidth: true,
|
|
251
|
+
slotProps: {
|
|
252
|
+
inputLabel: { shrink: true }
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
),
|
|
256
|
+
/* @__PURE__ */ jsx(FormLabel, { children: t("common.endDate") }),
|
|
257
|
+
/* @__PURE__ */ jsx(
|
|
258
|
+
TextField,
|
|
259
|
+
{
|
|
260
|
+
type: "date",
|
|
261
|
+
value: tempValue.endDate,
|
|
262
|
+
onChange: (e) => setTempValue((prev) => ({ ...prev, endDate: e.target.value })),
|
|
263
|
+
size: "small",
|
|
264
|
+
fullWidth: true,
|
|
265
|
+
slotProps: {
|
|
266
|
+
inputLabel: { shrink: true }
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
)
|
|
270
|
+
] }) }),
|
|
271
|
+
/* @__PURE__ */ jsxs(DialogActions, { sx: { px: 3, pb: 2 }, children: [
|
|
272
|
+
/* @__PURE__ */ jsx(Button, { onClick: handleCancel, color: "inherit", children: t("common.cancel") }),
|
|
273
|
+
/* @__PURE__ */ jsx(Button, { onClick: handleApply, variant: "contained", children: t("common.confirm") })
|
|
274
|
+
] })
|
|
275
|
+
]
|
|
276
|
+
}
|
|
277
|
+
)
|
|
278
|
+
] });
|
|
279
|
+
}
|
package/es/components/input.d.ts
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import type { TextFieldProps } from '@mui/material';
|
|
2
3
|
import type { RegisterOptions } from 'react-hook-form';
|
|
3
|
-
|
|
4
|
+
type InputProps = TextFieldProps & {
|
|
4
5
|
name: string;
|
|
5
6
|
label?: ReactNode;
|
|
6
7
|
placeholder?: string;
|
|
7
|
-
errorPosition?:
|
|
8
|
+
errorPosition?: 'right' | 'bottom';
|
|
8
9
|
rules?: RegisterOptions;
|
|
9
|
-
wrapperStyle?:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
label?: ReactNode;
|
|
20
|
-
placeholder?: string;
|
|
21
|
-
errorPosition?: "right" | "bottom";
|
|
22
|
-
rules?: RegisterOptions;
|
|
23
|
-
wrapperStyle?: any;
|
|
24
|
-
}, "ref">) & import("react").RefAttributes<HTMLInputElement>>;
|
|
25
|
-
export default FormInput;
|
|
10
|
+
wrapperStyle?: React.CSSProperties;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
tooltip?: ReactNode | string;
|
|
13
|
+
description?: ReactNode | string;
|
|
14
|
+
};
|
|
15
|
+
export default function FormInput({ ref, name, label, placeholder, rules, errorPosition, wrapperStyle, inputProps, required, tooltip, description, ...rest }: InputProps & {
|
|
16
|
+
ref?: React.RefObject<HTMLInputElement | null>;
|
|
17
|
+
inputProps?: TextFieldProps['inputProps'];
|
|
18
|
+
}): JSX.Element;
|
|
19
|
+
export {};
|
package/es/components/input.js
CHANGED
|
@@ -1,54 +1,61 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { Box,
|
|
2
|
+
import { useImperativeHandle, useRef } from "react";
|
|
3
|
+
import { Box, InputAdornment, TextField, Typography } from "@mui/material";
|
|
4
4
|
import get from "lodash/get";
|
|
5
5
|
import { Controller, useFormContext } from "react-hook-form";
|
|
6
|
+
import FormLabel from "./label.js";
|
|
6
7
|
function FormInputError({ error }) {
|
|
7
8
|
return /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx(Typography, { component: "span", color: "error", children: error }) });
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
10
|
+
export default function FormInput({
|
|
11
|
+
ref = void 0,
|
|
12
|
+
name,
|
|
13
|
+
label = "",
|
|
14
|
+
placeholder = "",
|
|
15
|
+
rules = {},
|
|
16
|
+
errorPosition = "bottom",
|
|
17
|
+
wrapperStyle = {},
|
|
18
|
+
inputProps = {},
|
|
19
|
+
required = false,
|
|
20
|
+
tooltip = "",
|
|
21
|
+
description = "",
|
|
22
|
+
...rest
|
|
23
|
+
}) {
|
|
24
|
+
const { control, formState } = useFormContext();
|
|
25
|
+
const inputRef = useRef(null);
|
|
26
|
+
useImperativeHandle(ref, () => {
|
|
27
|
+
return inputRef.current;
|
|
28
|
+
});
|
|
29
|
+
const error = get(formState.errors, name)?.message;
|
|
30
|
+
return /* @__PURE__ */ jsx(
|
|
31
|
+
Controller,
|
|
32
|
+
{
|
|
33
|
+
name,
|
|
34
|
+
control,
|
|
35
|
+
rules,
|
|
36
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Box, { sx: { width: "100%", ...wrapperStyle }, children: [
|
|
37
|
+
!!label && /* @__PURE__ */ jsx(FormLabel, { required, tooltip, description, children: label }),
|
|
38
|
+
/* @__PURE__ */ jsx(
|
|
39
|
+
TextField,
|
|
40
|
+
{
|
|
41
|
+
fullWidth: true,
|
|
42
|
+
error: !!get(formState.errors, name),
|
|
43
|
+
helperText: errorPosition === "bottom" && error ? error : "",
|
|
44
|
+
placeholder,
|
|
45
|
+
size: "small",
|
|
46
|
+
...field,
|
|
47
|
+
...rest,
|
|
48
|
+
inputRef,
|
|
49
|
+
slotProps: {
|
|
50
|
+
htmlInput: inputProps,
|
|
51
|
+
input: Object.assign(
|
|
37
52
|
rest.InputProps || {},
|
|
38
53
|
errorPosition === "right" && error ? { endAdornment: /* @__PURE__ */ jsx(FormInputError, { error }) } : {}
|
|
39
54
|
)
|
|
40
55
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
FormInput.defaultProps = {
|
|
48
|
-
label: "",
|
|
49
|
-
placeholder: "",
|
|
50
|
-
errorPosition: "bottom",
|
|
51
|
-
rules: {},
|
|
52
|
-
wrapperStyle: {}
|
|
53
|
-
};
|
|
54
|
-
export default FormInput;
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
] })
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FormLabelProps } from '@mui/material';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
export default function CustomFormLabel({ children, required, tooltip, description, ...props }: FormLabelProps & {
|
|
4
|
+
required?: boolean;
|
|
5
|
+
tooltip?: ReactNode | string;
|
|
6
|
+
description?: ReactNode | string;
|
|
7
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { InfoOutlined } from "@mui/icons-material";
|
|
3
|
+
import { Box, FormLabel, Tooltip, Typography } from "@mui/material";
|
|
4
|
+
export default function CustomFormLabel({
|
|
5
|
+
children,
|
|
6
|
+
required = false,
|
|
7
|
+
tooltip = "",
|
|
8
|
+
description = "",
|
|
9
|
+
...props
|
|
10
|
+
}) {
|
|
11
|
+
return /* @__PURE__ */ jsxs(Box, { sx: { mb: 1, width: "100%" }, children: [
|
|
12
|
+
/* @__PURE__ */ jsxs(
|
|
13
|
+
FormLabel,
|
|
14
|
+
{
|
|
15
|
+
...props,
|
|
16
|
+
sx: {
|
|
17
|
+
display: "flex",
|
|
18
|
+
alignItems: "center",
|
|
19
|
+
gap: 0.5,
|
|
20
|
+
fontWeight: 500,
|
|
21
|
+
color: "text.primary",
|
|
22
|
+
"&.MuiFormLabel-root": {
|
|
23
|
+
display: "flex",
|
|
24
|
+
alignItems: "center",
|
|
25
|
+
gap: 0.5,
|
|
26
|
+
fontWeight: 500,
|
|
27
|
+
color: "text.primary"
|
|
28
|
+
},
|
|
29
|
+
...props.sx || {}
|
|
30
|
+
},
|
|
31
|
+
children: [
|
|
32
|
+
children,
|
|
33
|
+
required && /* @__PURE__ */ jsx(Typography, { component: "span", color: "error", children: "*" }),
|
|
34
|
+
tooltip && (typeof tooltip === "string" ? /* @__PURE__ */ jsx(Tooltip, { title: tooltip, children: /* @__PURE__ */ jsx(InfoOutlined, { fontSize: "small", sx: { opacity: 0.7 } }) }) : tooltip)
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
),
|
|
38
|
+
description && /* @__PURE__ */ jsx(
|
|
39
|
+
Typography,
|
|
40
|
+
{
|
|
41
|
+
variant: "caption",
|
|
42
|
+
sx: {
|
|
43
|
+
color: "text.secondary"
|
|
44
|
+
},
|
|
45
|
+
children: description
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
] });
|
|
49
|
+
}
|
|
@@ -12,8 +12,7 @@ export function createLazyComponent(loader, options = {}) {
|
|
|
12
12
|
] })
|
|
13
13
|
} = options;
|
|
14
14
|
const loadComponent = async () => {
|
|
15
|
-
if (loadPromise)
|
|
16
|
-
return loadPromise;
|
|
15
|
+
if (loadPromise) return loadPromise;
|
|
17
16
|
try {
|
|
18
17
|
loadPromise = loader().then((result) => "default" in result ? result.default : result);
|
|
19
18
|
return await loadPromise;
|
package/es/components/link.d.ts
CHANGED
|
@@ -6,12 +6,5 @@ interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
|
6
6
|
target?: string;
|
|
7
7
|
outLink?: boolean;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var defaultProps: {
|
|
12
|
-
replace: boolean;
|
|
13
|
-
target: undefined;
|
|
14
|
-
outLink: boolean;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
export default Link;
|
|
9
|
+
export default function Link({ to, children, onClick, replace, target, outLink, ...props }: LinkProps): JSX.Element;
|
|
10
|
+
export {};
|
package/es/components/link.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useNavigate } from "react-router-dom";
|
|
3
|
-
export default function Link({
|
|
3
|
+
export default function Link({
|
|
4
|
+
to,
|
|
5
|
+
children,
|
|
6
|
+
onClick,
|
|
7
|
+
replace = false,
|
|
8
|
+
target = void 0,
|
|
9
|
+
outLink = false,
|
|
10
|
+
...props
|
|
11
|
+
}) {
|
|
4
12
|
const navigate = useNavigate();
|
|
5
13
|
const handleClick = (e) => {
|
|
6
14
|
const isInternal = to.startsWith("/") || to.startsWith("#") || to.startsWith("?");
|
|
@@ -16,8 +24,3 @@ export default function Link({ to, children, onClick, replace, target, outLink =
|
|
|
16
24
|
};
|
|
17
25
|
return /* @__PURE__ */ jsx("a", { href: to, onClick: handleClick, target, rel: "noreferrer", ...props, children });
|
|
18
26
|
}
|
|
19
|
-
Link.defaultProps = {
|
|
20
|
-
replace: false,
|
|
21
|
-
target: void 0,
|
|
22
|
-
outLink: false
|
|
23
|
-
};
|
|
@@ -3,11 +3,5 @@ type Props = {
|
|
|
3
3
|
color?: string;
|
|
4
4
|
backgroundColor?: string;
|
|
5
5
|
} & ChipOwnProps;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var defaultProps: {
|
|
9
|
-
color: string;
|
|
10
|
-
backgroundColor: string;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export default Livemode;
|
|
6
|
+
export default function Livemode({ color, backgroundColor, sx }: Props): import("react").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
3
3
|
import { Chip } from "@mui/material";
|
|
4
|
-
export default function Livemode({ color, backgroundColor, sx }) {
|
|
4
|
+
export default function Livemode({ color = "#bb5504", backgroundColor = "#ffde92", sx }) {
|
|
5
5
|
const { t } = useLocaleContext();
|
|
6
6
|
return /* @__PURE__ */ jsx(
|
|
7
7
|
Chip,
|
|
@@ -24,7 +24,3 @@ export default function Livemode({ color, backgroundColor, sx }) {
|
|
|
24
24
|
}
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
|
-
Livemode.defaultProps = {
|
|
28
|
-
color: "#bb5504",
|
|
29
|
-
backgroundColor: "#ffde92"
|
|
30
|
-
};
|
|
@@ -6,5 +6,10 @@ export interface LoadingButtonProps extends ButtonProps {
|
|
|
6
6
|
loadingProps?: Partial<CircularProgressProps>;
|
|
7
7
|
loadingOnly?: boolean;
|
|
8
8
|
}
|
|
9
|
-
declare
|
|
9
|
+
declare function LoadingButton({ ref, children, loading, loadingPosition, loadingIndicator, loadingProps, loadingOnly, onClick, sx, ...props }: LoadingButtonProps & {
|
|
10
|
+
ref?: React.RefObject<HTMLButtonElement | null>;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
12
|
+
declare namespace LoadingButton {
|
|
13
|
+
var displayName: string;
|
|
14
|
+
}
|
|
10
15
|
export default LoadingButton;
|