@etsoo/materialui 1.4.21 → 1.4.23
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/README.md +2 -1
- package/babel.config.json +12 -12
- package/lib/AddresSelector.d.ts +8 -2
- package/lib/AddresSelector.js +1 -1
- package/lib/AuditDisplay.d.ts +1 -1
- package/lib/BackButton.d.ts +1 -1
- package/lib/BackButton.js +5 -5
- package/lib/CountryList.d.ts +5 -4
- package/lib/CountryList.js +3 -3
- package/lib/CustomFabProps.d.ts +3 -3
- package/lib/DataGridEx.js +3 -6
- package/lib/DataGridRenderers.d.ts +3 -3
- package/lib/DataGridRenderers.js +17 -17
- package/lib/DataTable.d.ts +1 -7
- package/lib/DataTable.js +3 -13
- package/lib/DialogButton.d.ts +2 -2
- package/lib/DialogButton.js +4 -4
- package/lib/EmailInput.d.ts +2 -2
- package/lib/EmailInput.js +2 -2
- package/lib/FlexBox.d.ts +3 -3
- package/lib/FlexBox.js +1 -1
- package/lib/GridDataFormat.d.ts +2 -2
- package/lib/GridDataFormat.js +7 -7
- package/lib/GridUtils.js +2 -1
- package/lib/ListItemRightIcon.d.ts +1 -1
- package/lib/ListItemRightIcon.js +2 -2
- package/lib/LoadingButton.d.ts +1 -1
- package/lib/LoadingButton.js +2 -2
- package/lib/MUGlobal.d.ts +6 -6
- package/lib/MUGlobal.js +20 -22
- package/lib/MobileListItemRenderer.d.ts +3 -3
- package/lib/MobileListItemRenderer.js +8 -10
- package/lib/PList.js +1 -1
- package/lib/ProgressCount.js +12 -12
- package/lib/RegionsRQ.d.ts +22 -0
- package/lib/RegionsRQ.js +1 -0
- package/lib/SearchField.d.ts +1 -1
- package/lib/SearchField.js +4 -4
- package/lib/SearchOptionGroup.d.ts +2 -2
- package/lib/SearchOptionGroup.js +3 -3
- package/lib/Switch.d.ts +3 -3
- package/lib/Switch.js +5 -5
- package/lib/TabBox.d.ts +5 -5
- package/lib/TabBox.js +5 -5
- package/lib/TableEx.js +4 -7
- package/lib/TooltipClick.d.ts +3 -3
- package/lib/TooltipClick.js +3 -3
- package/lib/TwoFieldInput.d.ts +2 -2
- package/lib/TwoFieldInput.js +13 -13
- package/lib/app/IServicePage.d.ts +1 -1
- package/lib/app/Labels.d.ts +1 -1
- package/lib/app/Labels.js +31 -31
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/texts/MoneyText.d.ts +1 -1
- package/lib/texts/MoneyText.js +3 -3
- package/lib/texts/NumberText.d.ts +1 -1
- package/lib/texts/NumberText.js +3 -3
- package/package.json +25 -25
- package/src/AddresSelector.tsx +31 -4
- package/src/AuditDisplay.tsx +1 -1
- package/src/BackButton.tsx +39 -39
- package/src/CountryList.tsx +49 -48
- package/src/CustomFabProps.ts +19 -19
- package/src/DataGridEx.tsx +2 -7
- package/src/DataGridRenderers.tsx +119 -119
- package/src/DataTable.tsx +2 -31
- package/src/DialogButton.tsx +149 -151
- package/src/EmailInput.tsx +9 -11
- package/src/FlexBox.tsx +6 -6
- package/src/GridDataFormat.tsx +58 -58
- package/src/GridUtils.ts +2 -1
- package/src/ListItemRightIcon.tsx +3 -3
- package/src/LoadingButton.tsx +53 -53
- package/src/MUGlobal.ts +196 -203
- package/src/MobileListItemRenderer.tsx +63 -65
- package/src/NotifierPromptProps.ts +16 -16
- package/src/PList.tsx +14 -14
- package/src/ProgressCount.tsx +144 -148
- package/src/RegionsRQ.ts +26 -0
- package/src/SearchField.tsx +59 -59
- package/src/SearchOptionGroup.tsx +20 -20
- package/src/Switch.tsx +72 -72
- package/src/TabBox.tsx +87 -89
- package/src/TableEx.tsx +5 -8
- package/src/TooltipClick.tsx +62 -64
- package/src/TwoFieldInput.tsx +104 -104
- package/src/app/IServicePage.ts +1 -1
- package/src/app/Labels.ts +67 -67
- package/src/index.ts +1 -0
- package/src/texts/MoneyText.tsx +29 -35
- package/src/texts/NumberText.tsx +23 -23
package/src/FlexBox.tsx
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Stack, StackProps } from
|
|
2
|
-
import React from
|
|
1
|
+
import { Stack, StackProps } from "@mui/material";
|
|
2
|
+
import React from "react";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Horizonal box
|
|
6
6
|
* @param props Props
|
|
7
7
|
* @returns Component
|
|
8
8
|
*/
|
|
9
|
-
export function HBox(props: Omit<StackProps,
|
|
10
|
-
|
|
9
|
+
export function HBox(props: Omit<StackProps, "ref">) {
|
|
10
|
+
return <Stack direction="row" width="100%" {...props} />;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -15,6 +15,6 @@ export function HBox(props: Omit<StackProps, 'ref'>) {
|
|
|
15
15
|
* @param props Props
|
|
16
16
|
* @returns Component
|
|
17
17
|
*/
|
|
18
|
-
export function VBox(props: Omit<StackProps,
|
|
19
|
-
|
|
18
|
+
export function VBox(props: Omit<StackProps, "ref">) {
|
|
19
|
+
return <Stack direction="column" {...props} />;
|
|
20
20
|
}
|
package/src/GridDataFormat.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { GridColumnRenderProps, GridDataType } from
|
|
2
|
-
import { DateUtils, NumberUtils } from
|
|
3
|
-
import React from
|
|
4
|
-
import { DateText } from
|
|
1
|
+
import { GridColumnRenderProps, GridDataType } from "@etsoo/react";
|
|
2
|
+
import { DateUtils, NumberUtils } from "@etsoo/shared";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { DateText } from "./texts/DateText";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Grid data format
|
|
@@ -11,67 +11,67 @@ import { DateText } from './texts/DateText';
|
|
|
11
11
|
* @returns Result
|
|
12
12
|
*/
|
|
13
13
|
export function GridDataFormat(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
data: unknown,
|
|
15
|
+
type: GridDataType,
|
|
16
|
+
renderProps?: GridColumnRenderProps
|
|
17
17
|
): React.ReactNode {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
// Null
|
|
19
|
+
if (data == null) return undefined;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
// For date time
|
|
22
|
+
// Conversion if necessary
|
|
23
|
+
if (type === GridDataType.Date || type === GridDataType.DateTime) {
|
|
24
|
+
const dateValue =
|
|
25
|
+
data instanceof Date
|
|
26
|
+
? data
|
|
27
|
+
: typeof data === "number" || typeof data === "string"
|
|
28
|
+
? new Date(data)
|
|
29
|
+
: undefined;
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
if (dateValue == null) return undefined;
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
const option = type === GridDataType.DateTime ? "ds" : "d";
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return DateUtils.format(
|
|
49
|
-
dateValue,
|
|
50
|
-
renderProps?.culture,
|
|
51
|
-
option,
|
|
52
|
-
renderProps?.timeZone
|
|
53
|
-
);
|
|
35
|
+
const nearDays = renderProps?.nearDays;
|
|
36
|
+
if (nearDays != null) {
|
|
37
|
+
return (
|
|
38
|
+
<DateText
|
|
39
|
+
value={dateValue}
|
|
40
|
+
locale={renderProps?.culture}
|
|
41
|
+
timeZone={renderProps?.timeZone}
|
|
42
|
+
options={option}
|
|
43
|
+
nearDays={nearDays}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
54
46
|
}
|
|
55
47
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
48
|
+
return DateUtils.format(
|
|
49
|
+
dateValue,
|
|
50
|
+
renderProps?.culture,
|
|
51
|
+
option,
|
|
52
|
+
renderProps?.timeZone
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// For numbers
|
|
57
|
+
if (typeof data === "number") {
|
|
58
|
+
if (type === GridDataType.Money || type === GridDataType.IntMoney)
|
|
59
|
+
return NumberUtils.formatMoney(
|
|
60
|
+
data,
|
|
61
|
+
renderProps?.currency,
|
|
62
|
+
renderProps?.culture,
|
|
63
|
+
type === GridDataType.IntMoney,
|
|
64
|
+
renderProps?.numberFormatOptions
|
|
65
|
+
);
|
|
66
|
+
else
|
|
67
|
+
return NumberUtils.format(
|
|
68
|
+
data,
|
|
69
|
+
renderProps?.culture,
|
|
70
|
+
renderProps?.numberFormatOptions
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
if (typeof data === "string") return data;
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
return `${data}`;
|
|
77
77
|
}
|
package/src/GridUtils.ts
CHANGED
|
@@ -73,7 +73,8 @@ export namespace GridUtils {
|
|
|
73
73
|
*/
|
|
74
74
|
export function getUpdateRowsHandler<T extends object>(cacheKey?: string) {
|
|
75
75
|
return (rows: T[], state: GridLoaderStates<T>) => {
|
|
76
|
-
|
|
76
|
+
const page = state.queryPaging.currentPage ?? 0;
|
|
77
|
+
if (page > 0 && cacheKey) {
|
|
77
78
|
const data: GridDataCacheType<T> = {
|
|
78
79
|
rows,
|
|
79
80
|
state,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ListItemIcon, styled } from
|
|
1
|
+
import { ListItemIcon, styled } from "@mui/material";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* List item right icon component
|
|
5
5
|
*/
|
|
6
6
|
export const ListItemRightIcon = styled(ListItemIcon)(({ theme }) => ({
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
minWidth: "20px!important",
|
|
8
|
+
paddingLeft: theme.spacing(2)
|
|
9
9
|
})) as typeof ListItemIcon;
|
package/src/LoadingButton.tsx
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from
|
|
7
|
-
import React from
|
|
2
|
+
Button,
|
|
3
|
+
ButtonProps,
|
|
4
|
+
CircularProgress,
|
|
5
|
+
CircularProgressProps
|
|
6
|
+
} from "@mui/material";
|
|
7
|
+
import React from "react";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Loading button props
|
|
11
11
|
*/
|
|
12
12
|
export type LoadingButtonProps = ButtonProps & {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Loading icon props
|
|
15
|
+
*/
|
|
16
|
+
loadingIconProps?: CircularProgressProps;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -21,55 +21,55 @@ export type LoadingButtonProps = ButtonProps & {
|
|
|
21
21
|
* @param props Props
|
|
22
22
|
*/
|
|
23
23
|
export function LoadingButton(props: LoadingButtonProps) {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
// Destruct
|
|
25
|
+
const { endIcon, loadingIconProps = {}, onClick, ...rest } = props;
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
// Default size
|
|
28
|
+
loadingIconProps.size ??= 12;
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
// State
|
|
31
|
+
// https://stackoverflow.com/questions/55265255/react-usestate-hook-event-handler-using-initial-state
|
|
32
|
+
const [loading, setLoading] = React.useState(false);
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
// Icon
|
|
35
|
+
const localEndIcon = loading ? (
|
|
36
|
+
<CircularProgress {...loadingIconProps} />
|
|
37
|
+
) : (
|
|
38
|
+
endIcon
|
|
39
|
+
);
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
// Check if the component is mounted
|
|
42
|
+
const isMounted = React.useRef(true);
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
React.useEffect(() => {
|
|
45
|
+
return () => {
|
|
46
|
+
isMounted.current = false;
|
|
47
|
+
};
|
|
48
|
+
}, []);
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
// Layout
|
|
51
|
+
return (
|
|
52
|
+
<Button
|
|
53
|
+
disabled={loading}
|
|
54
|
+
endIcon={localEndIcon}
|
|
55
|
+
onClick={async (event) => {
|
|
56
|
+
if (onClick) {
|
|
57
|
+
// Update state
|
|
58
|
+
setLoading(true);
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
// https://stackoverflow.com/questions/38508420/how-to-know-if-a-function-is-async
|
|
61
|
+
// const AsyncFunction = (async () => {}).constructor;
|
|
62
|
+
// onClick instanceof AsyncFunction
|
|
63
|
+
await onClick(event);
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
// Warning: Can't perform a React state update on an unmounted component
|
|
66
|
+
// It's necessary to check the component is mounted now
|
|
67
|
+
if (isMounted.current) {
|
|
68
|
+
setLoading(false);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}}
|
|
72
|
+
{...rest}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
75
|
}
|