@etsoo/materialui 1.1.39 → 1.1.42
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/lib/AuditDisplay.d.ts +5 -5
- package/lib/AuditDisplay.js +17 -19
- package/lib/BridgeCloseButton.d.ts +2 -2
- package/lib/BridgeCloseButton.js +7 -8
- package/lib/DataSteps.d.ts +4 -4
- package/lib/DataSteps.js +17 -14
- package/lib/DataTable.d.ts +33 -0
- package/lib/DataTable.js +56 -0
- package/lib/ListMoreDisplay.d.ts +5 -5
- package/lib/ListMoreDisplay.js +8 -10
- package/lib/OptionBool.js +2 -1
- package/lib/SelectBool.js +2 -1
- package/lib/ShowDataComparison.d.ts +1 -1
- package/lib/ShowDataComparison.js +27 -20
- package/lib/SwitchAnt.d.ts +3 -3
- package/lib/SwitchAnt.js +11 -8
- package/lib/SwitchField.d.ts +45 -0
- package/lib/SwitchField.js +33 -0
- package/lib/Tiplist.js +4 -4
- package/lib/UserAvatar.js +7 -8
- package/lib/app/ReactApp.d.ts +7 -7
- package/lib/app/ReactApp.js +26 -26
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/pages/ViewPage.d.ts +7 -7
- package/lib/pages/ViewPage.js +30 -29
- package/package.json +3 -2
- package/src/AuditDisplay.tsx +92 -99
- package/src/BridgeCloseButton.tsx +48 -50
- package/src/DataSteps.tsx +188 -185
- package/src/DataTable.tsx +124 -0
- package/src/ListMoreDisplay.tsx +184 -188
- package/src/OptionBool.tsx +1 -1
- package/src/SelectBool.tsx +1 -1
- package/src/ShowDataComparison.tsx +88 -76
- package/src/SwitchAnt.tsx +82 -78
- package/src/SwitchField.tsx +133 -0
- package/src/Tiplist.tsx +5 -4
- package/src/UserAvatar.tsx +43 -45
- package/src/app/ReactApp.ts +485 -489
- package/src/index.ts +2 -0
- package/src/pages/ViewPage.tsx +272 -277
package/src/SwitchAnt.tsx
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { Stack, Typography } from
|
|
2
|
-
import Switch, { SwitchProps } from
|
|
3
|
-
import React from
|
|
1
|
+
import { Stack, Typography } from "@mui/material";
|
|
2
|
+
import Switch, { SwitchProps } from "@mui/material/Switch";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { globalApp } from "./app/ReactApp";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Ant style switch props
|
|
7
8
|
*/
|
|
8
9
|
export interface SwitchAntProps extends SwitchProps {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Active color
|
|
12
|
+
*/
|
|
13
|
+
activeColor?: string;
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Start label
|
|
17
|
+
*/
|
|
18
|
+
startLabel?: string;
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
/**
|
|
21
|
+
* End label
|
|
22
|
+
*/
|
|
23
|
+
endLabel?: string;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
/**
|
|
@@ -28,72 +29,75 @@ export interface SwitchAntProps extends SwitchProps {
|
|
|
28
29
|
* @returns Component
|
|
29
30
|
*/
|
|
30
31
|
export function SwitchAnt(props: SwitchAntProps) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
activeColor,
|
|
34
|
-
checked,
|
|
35
|
-
defaultChecked,
|
|
36
|
-
defaultValue,
|
|
37
|
-
endLabel,
|
|
38
|
-
startLabel,
|
|
39
|
-
onChange,
|
|
40
|
-
value = 'true',
|
|
41
|
-
...rest
|
|
42
|
-
} = props;
|
|
32
|
+
// Labels
|
|
33
|
+
const { yes = "Yes", no = "No" } = globalApp?.getLabels("yes", "no") ?? {};
|
|
43
34
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
35
|
+
// Destruct
|
|
36
|
+
const {
|
|
37
|
+
activeColor,
|
|
38
|
+
checked,
|
|
39
|
+
defaultChecked,
|
|
40
|
+
defaultValue,
|
|
41
|
+
endLabel = yes,
|
|
42
|
+
startLabel = no,
|
|
43
|
+
onChange,
|
|
44
|
+
value = "true",
|
|
45
|
+
...rest
|
|
46
|
+
} = props;
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
// Checked state
|
|
49
|
+
const [controlChecked, setControlChecked] = React.useState(
|
|
50
|
+
checked ?? defaultChecked ?? defaultValue == value
|
|
51
|
+
);
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}, [checked]);
|
|
53
|
+
// Ref
|
|
54
|
+
const ref = React.useRef<HTMLButtonElement>(null);
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
checked: boolean
|
|
60
|
-
) => {
|
|
61
|
-
if (onChange) onChange(event, checked);
|
|
62
|
-
setControlChecked(checked);
|
|
63
|
-
};
|
|
56
|
+
React.useEffect(() => {
|
|
57
|
+
if (checked) setControlChecked(checked);
|
|
58
|
+
}, [checked]);
|
|
64
59
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
60
|
+
// On change
|
|
61
|
+
const onChangeLocal = (
|
|
62
|
+
event: React.ChangeEvent<HTMLInputElement>,
|
|
63
|
+
checked: boolean
|
|
64
|
+
) => {
|
|
65
|
+
if (onChange) onChange(event, checked);
|
|
66
|
+
setControlChecked(checked);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// Layout
|
|
70
|
+
return (
|
|
71
|
+
<Stack direction="row" spacing={1} alignItems="center">
|
|
72
|
+
<Typography
|
|
73
|
+
onClick={() => controlChecked && ref.current?.click()}
|
|
74
|
+
sx={{
|
|
75
|
+
cursor: "pointer",
|
|
76
|
+
color: controlChecked
|
|
77
|
+
? undefined
|
|
78
|
+
: (theme) => activeColor ?? theme.palette.warning.main
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
{startLabel}
|
|
82
|
+
</Typography>
|
|
83
|
+
<Switch
|
|
84
|
+
checked={controlChecked}
|
|
85
|
+
inputRef={ref}
|
|
86
|
+
value={value}
|
|
87
|
+
onChange={onChangeLocal}
|
|
88
|
+
{...rest}
|
|
89
|
+
/>
|
|
90
|
+
<Typography
|
|
91
|
+
onClick={() => !controlChecked && ref.current?.click()}
|
|
92
|
+
sx={{
|
|
93
|
+
cursor: "pointer",
|
|
94
|
+
color: controlChecked
|
|
95
|
+
? (theme) => activeColor ?? theme.palette.warning.main
|
|
96
|
+
: undefined
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
{endLabel}
|
|
100
|
+
</Typography>
|
|
101
|
+
</Stack>
|
|
102
|
+
);
|
|
99
103
|
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Box,
|
|
3
|
+
FormControl,
|
|
4
|
+
FormControlProps,
|
|
5
|
+
FormHelperText,
|
|
6
|
+
InputLabel
|
|
7
|
+
} from "@mui/material";
|
|
8
|
+
import NotchedOutline from "@mui/material/OutlinedInput";
|
|
9
|
+
import React from "react";
|
|
10
|
+
import { SwitchAnt } from "./SwitchAnt";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* SwitchField props
|
|
14
|
+
*/
|
|
15
|
+
export type SwitchFieldProps = Omit<
|
|
16
|
+
FormControlProps<"fieldset">,
|
|
17
|
+
"defaultValue"
|
|
18
|
+
> & {
|
|
19
|
+
/**
|
|
20
|
+
* Helper text
|
|
21
|
+
*/
|
|
22
|
+
helperText?: React.ReactNode;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Label
|
|
26
|
+
*/
|
|
27
|
+
label?: string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Checked
|
|
31
|
+
*/
|
|
32
|
+
checked?: boolean;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Active color
|
|
36
|
+
*/
|
|
37
|
+
activeColor?: string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Start label
|
|
41
|
+
*/
|
|
42
|
+
startLabel?: string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* End label
|
|
46
|
+
*/
|
|
47
|
+
endLabel?: string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Height in px
|
|
51
|
+
*/
|
|
52
|
+
height?: number;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Value, default is true
|
|
56
|
+
*/
|
|
57
|
+
value?: unknown;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* SwitchField
|
|
62
|
+
* @param props Props
|
|
63
|
+
* @returns Component
|
|
64
|
+
*/
|
|
65
|
+
export function SwitchField(props: SwitchFieldProps) {
|
|
66
|
+
// Destruct
|
|
67
|
+
const {
|
|
68
|
+
activeColor,
|
|
69
|
+
startLabel,
|
|
70
|
+
endLabel,
|
|
71
|
+
value = true,
|
|
72
|
+
|
|
73
|
+
fullWidth,
|
|
74
|
+
height = 56,
|
|
75
|
+
helperText,
|
|
76
|
+
label,
|
|
77
|
+
name,
|
|
78
|
+
required,
|
|
79
|
+
sx = {},
|
|
80
|
+
checked,
|
|
81
|
+
variant = "outlined",
|
|
82
|
+
...rest
|
|
83
|
+
} = props;
|
|
84
|
+
|
|
85
|
+
// Outlined
|
|
86
|
+
const outlined = variant === "outlined";
|
|
87
|
+
|
|
88
|
+
if (sx) {
|
|
89
|
+
Object.assign(sx, { height: outlined ? `${height}px` : undefined });
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Layout
|
|
93
|
+
return (
|
|
94
|
+
<React.Fragment>
|
|
95
|
+
<FormControl component="fieldset" fullWidth={fullWidth} sx={sx} {...rest}>
|
|
96
|
+
{label && (
|
|
97
|
+
<InputLabel required={required} variant={variant} shrink>
|
|
98
|
+
{label}
|
|
99
|
+
</InputLabel>
|
|
100
|
+
)}
|
|
101
|
+
{outlined && (
|
|
102
|
+
<NotchedOutline
|
|
103
|
+
label={label && required ? label + " *" : label}
|
|
104
|
+
notched
|
|
105
|
+
sx={{
|
|
106
|
+
cursor: "default",
|
|
107
|
+
position: "absolute",
|
|
108
|
+
width: fullWidth ? "100%" : "auto",
|
|
109
|
+
"& input": {
|
|
110
|
+
visibility: "hidden"
|
|
111
|
+
}
|
|
112
|
+
}}
|
|
113
|
+
/>
|
|
114
|
+
)}
|
|
115
|
+
<Box
|
|
116
|
+
paddingLeft={2}
|
|
117
|
+
paddingY="7px"
|
|
118
|
+
position={outlined ? "absolute" : undefined}
|
|
119
|
+
>
|
|
120
|
+
<SwitchAnt
|
|
121
|
+
activeColor={activeColor}
|
|
122
|
+
name={name}
|
|
123
|
+
startLabel={startLabel ?? "NO"}
|
|
124
|
+
endLabel={endLabel ?? "YES"}
|
|
125
|
+
value={value}
|
|
126
|
+
checked={checked}
|
|
127
|
+
/>
|
|
128
|
+
</Box>
|
|
129
|
+
</FormControl>
|
|
130
|
+
{helperText && <FormHelperText>{helperText}</FormHelperText>}
|
|
131
|
+
</React.Fragment>
|
|
132
|
+
);
|
|
133
|
+
}
|
package/src/Tiplist.tsx
CHANGED
|
@@ -47,7 +47,8 @@ export function Tiplist<
|
|
|
47
47
|
D extends DataTypes.Keys<T> = IdDefaultType<T>
|
|
48
48
|
>(props: TiplistProps<T, D>) {
|
|
49
49
|
// Labels
|
|
50
|
-
const
|
|
50
|
+
const { noOptions, loading, more } =
|
|
51
|
+
globalApp?.getLabels("noOptions", "loading", "more") ?? {};
|
|
51
52
|
|
|
52
53
|
// Destruct
|
|
53
54
|
const {
|
|
@@ -71,8 +72,8 @@ export function Tiplist<
|
|
|
71
72
|
onChange,
|
|
72
73
|
openOnFocus = true,
|
|
73
74
|
sx = { minWidth: "180px" },
|
|
74
|
-
noOptionsText =
|
|
75
|
-
loadingText =
|
|
75
|
+
noOptionsText = noOptions,
|
|
76
|
+
loadingText = loading,
|
|
76
77
|
getOptionLabel,
|
|
77
78
|
getOptionDisabled,
|
|
78
79
|
...rest
|
|
@@ -318,7 +319,7 @@ export function Tiplist<
|
|
|
318
319
|
}}
|
|
319
320
|
getOptionLabel={(item) => {
|
|
320
321
|
if (typeof item !== "object") return `${item}`;
|
|
321
|
-
if (item[idField] === "n/a") return (
|
|
322
|
+
if (item[idField] === "n/a") return (more ?? "More") + "...";
|
|
322
323
|
return getOptionLabel
|
|
323
324
|
? getOptionLabel(item)
|
|
324
325
|
: "label" in item
|
package/src/UserAvatar.tsx
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Avatar } from
|
|
3
|
-
import { BusinessUtils } from
|
|
4
|
-
import { globalApp } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Avatar } from "@mui/material";
|
|
3
|
+
import { BusinessUtils } from "@etsoo/appscript";
|
|
4
|
+
import { globalApp } from "./app/ReactApp";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* User avatar props
|
|
8
8
|
*/
|
|
9
9
|
export interface UserAvatarProps {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Photo src
|
|
12
|
+
*/
|
|
13
|
+
src?: string;
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Format title
|
|
17
|
+
*/
|
|
18
|
+
formatTitle?: (title?: string) => string;
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Title of the user
|
|
22
|
+
*/
|
|
23
|
+
title?: string;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -29,36 +29,34 @@ export interface UserAvatarProps {
|
|
|
29
29
|
* @returns Component
|
|
30
30
|
*/
|
|
31
31
|
export function UserAvatar(props: UserAvatarProps) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
// Destruct
|
|
33
|
+
const {
|
|
34
|
+
src,
|
|
35
|
+
title,
|
|
36
|
+
formatTitle = (title?: string) => {
|
|
37
|
+
return BusinessUtils.formatAvatarTitle(
|
|
35
38
|
title,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
? 'ME'
|
|
42
|
-
: globalApp.get<string>('me')
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
} = props;
|
|
39
|
+
3,
|
|
40
|
+
globalApp?.get<string>("me") ?? "ME"
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
} = props;
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
// Format
|
|
46
|
+
const fTitle = formatTitle(title);
|
|
47
|
+
const count = fTitle.length;
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
49
|
+
return (
|
|
50
|
+
<Avatar
|
|
51
|
+
title={title}
|
|
52
|
+
src={src}
|
|
53
|
+
sx={{
|
|
54
|
+
width: 48,
|
|
55
|
+
height: 32,
|
|
56
|
+
fontSize: count <= 2 ? "15px" : "12px"
|
|
57
|
+
}}
|
|
58
|
+
>
|
|
59
|
+
{fTitle}
|
|
60
|
+
</Avatar>
|
|
61
|
+
);
|
|
64
62
|
}
|