@etsoo/materialui 1.1.39 → 1.1.41
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/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 +1 -1
- package/lib/SwitchAnt.js +11 -8
- 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/pages/ViewPage.d.ts +7 -7
- package/lib/pages/ViewPage.js +30 -29
- package/package.json +2 -2
- package/src/AuditDisplay.tsx +92 -99
- package/src/BridgeCloseButton.tsx +48 -50
- package/src/DataSteps.tsx +188 -185
- 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/Tiplist.tsx +5 -4
- package/src/UserAvatar.tsx +43 -45
- package/src/app/ReactApp.ts +485 -489
- package/src/pages/ViewPage.tsx +272 -277
package/src/DataSteps.tsx
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from
|
|
8
|
-
import CloseIcon from
|
|
9
|
-
import NavigateNextIcon from
|
|
10
|
-
import NavigateBeforeIcon from
|
|
11
|
-
import CheckIcon from
|
|
12
|
-
import StartIcon from
|
|
13
|
-
import { InputDialogProps } from
|
|
14
|
-
import React from
|
|
15
|
-
import { HBox } from
|
|
16
|
-
import { globalApp } from
|
|
17
|
-
import { MUGlobal } from
|
|
2
|
+
Button,
|
|
3
|
+
IconButton,
|
|
4
|
+
InputAdornment,
|
|
5
|
+
TextField,
|
|
6
|
+
TextFieldProps
|
|
7
|
+
} from "@mui/material";
|
|
8
|
+
import CloseIcon from "@mui/icons-material/Close";
|
|
9
|
+
import NavigateNextIcon from "@mui/icons-material/NavigateNext";
|
|
10
|
+
import NavigateBeforeIcon from "@mui/icons-material/NavigateBefore";
|
|
11
|
+
import CheckIcon from "@mui/icons-material/Check";
|
|
12
|
+
import StartIcon from "@mui/icons-material/Start";
|
|
13
|
+
import { InputDialogProps } from "@etsoo/react";
|
|
14
|
+
import React from "react";
|
|
15
|
+
import { HBox } from "./FlexBox";
|
|
16
|
+
import { globalApp } from "./app/ReactApp";
|
|
17
|
+
import { MUGlobal } from "./MUGlobal";
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Data step
|
|
21
21
|
*/
|
|
22
|
-
export type DataStep = Omit<InputDialogProps,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
export type DataStep = Omit<InputDialogProps, "callback"> & {
|
|
23
|
+
/**
|
|
24
|
+
* Callback
|
|
25
|
+
*/
|
|
26
|
+
callback: (form: HTMLFormElement) => boolean | void;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Data collecting steps component props
|
|
31
31
|
*/
|
|
32
32
|
export type DataStepsProps<T extends object> = Omit<
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
TextFieldProps,
|
|
34
|
+
"InputProps" | "onClick"
|
|
35
35
|
> & {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
36
|
+
/**
|
|
37
|
+
* JSON value
|
|
38
|
+
*/
|
|
39
|
+
jsonValue: T;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Value formatter
|
|
43
|
+
*/
|
|
44
|
+
valueFormatter?: (data: T) => string;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Steps
|
|
48
|
+
*/
|
|
49
|
+
steps: (index: number, data: T) => [DataStep, boolean];
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* On value change handler
|
|
53
|
+
*/
|
|
54
|
+
onValueChange?: (value: T) => void;
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
/**
|
|
@@ -60,147 +60,150 @@ export type DataStepsProps<T extends object> = Omit<
|
|
|
60
60
|
* @returns Component
|
|
61
61
|
*/
|
|
62
62
|
export function DataSteps<T extends object>(props: DataStepsProps<T>) {
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
63
|
+
// App
|
|
64
|
+
const app = globalApp;
|
|
65
|
+
if (app == null) {
|
|
66
|
+
throw new Error("No globalApp");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Labels
|
|
70
|
+
const labels = app.getLabels("close", "nextStep", "previousStep", "submit");
|
|
71
|
+
|
|
72
|
+
// Destruct
|
|
73
|
+
const {
|
|
74
|
+
InputLabelProps = {},
|
|
75
|
+
jsonValue,
|
|
76
|
+
valueFormatter = (_data) => "...",
|
|
77
|
+
onValueChange,
|
|
78
|
+
steps,
|
|
79
|
+
value = "",
|
|
80
|
+
...rest
|
|
81
|
+
} = props;
|
|
82
|
+
|
|
83
|
+
// Shrink
|
|
84
|
+
InputLabelProps.shrink ??= MUGlobal.searchFieldShrink;
|
|
85
|
+
|
|
86
|
+
// Current index
|
|
87
|
+
const indexRef = React.useRef<number>(-1);
|
|
88
|
+
|
|
89
|
+
// Current Json data
|
|
90
|
+
const jsonRef = React.useRef<T>(jsonValue);
|
|
91
|
+
|
|
92
|
+
// Ignore empty value case
|
|
93
|
+
if (jsonValue !== jsonRef.current && valueFormatter(jsonValue))
|
|
94
|
+
jsonRef.current = jsonValue;
|
|
95
|
+
|
|
96
|
+
// Current value
|
|
97
|
+
const [localValue, setLocalValue] = React.useState(value);
|
|
98
|
+
|
|
99
|
+
// Get step
|
|
100
|
+
const showStep = (index: number) => {
|
|
101
|
+
indexRef.current = index;
|
|
102
|
+
const [{ callback, ...rest }, more] = steps(index, jsonRef.current);
|
|
103
|
+
|
|
104
|
+
app.showInputDialog({
|
|
105
|
+
...rest,
|
|
106
|
+
buttons: (n, callback) => (
|
|
107
|
+
<HBox
|
|
108
|
+
paddingLeft={2}
|
|
109
|
+
paddingRight={2}
|
|
110
|
+
paddingBottom={2}
|
|
111
|
+
gap={2}
|
|
112
|
+
justifyContent="space-between"
|
|
113
|
+
>
|
|
114
|
+
{index === 0 ? (
|
|
115
|
+
<Button
|
|
116
|
+
variant="outlined"
|
|
117
|
+
startIcon={<CloseIcon />}
|
|
118
|
+
onClick={() => n.dismiss()}
|
|
119
|
+
>
|
|
120
|
+
{labels.close}
|
|
121
|
+
</Button>
|
|
122
|
+
) : (
|
|
123
|
+
<Button
|
|
124
|
+
variant="outlined"
|
|
125
|
+
startIcon={<NavigateBeforeIcon />}
|
|
126
|
+
onClick={() => {
|
|
127
|
+
n.dismiss();
|
|
128
|
+
showStep(indexRef.current - 1);
|
|
129
|
+
}}
|
|
130
|
+
>
|
|
131
|
+
{labels.previousStep}
|
|
132
|
+
</Button>
|
|
133
|
+
)}
|
|
134
|
+
|
|
135
|
+
{more ? (
|
|
136
|
+
<Button
|
|
137
|
+
variant="contained"
|
|
138
|
+
startIcon={<NavigateNextIcon />}
|
|
139
|
+
onClick={async (event) => {
|
|
140
|
+
const result = await callback(event);
|
|
141
|
+
if (!result) return;
|
|
142
|
+
showStep(indexRef.current + 1);
|
|
143
|
+
}}
|
|
144
|
+
>
|
|
145
|
+
{labels.nextStep}
|
|
146
|
+
</Button>
|
|
147
|
+
) : (
|
|
148
|
+
<Button
|
|
149
|
+
variant="contained"
|
|
150
|
+
startIcon={<CheckIcon />}
|
|
151
|
+
onClick={async (event) => {
|
|
152
|
+
const result = await callback(event);
|
|
153
|
+
if (!result) return;
|
|
154
|
+
|
|
155
|
+
const value = jsonRef.current;
|
|
156
|
+
setLocalValue(valueFormatter(value));
|
|
157
|
+
|
|
158
|
+
if (onValueChange) onValueChange(value);
|
|
159
|
+
}}
|
|
160
|
+
>
|
|
161
|
+
{labels.submit}
|
|
162
|
+
</Button>
|
|
163
|
+
)}
|
|
164
|
+
</HBox>
|
|
165
|
+
),
|
|
166
|
+
callback: (form) => {
|
|
167
|
+
if (form == null) return;
|
|
168
|
+
const result = callback(form);
|
|
169
|
+
if (result !== true) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const cancelInput = (event: React.SyntheticEvent) => {
|
|
177
|
+
event.stopPropagation();
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
React.useEffect(() => {
|
|
182
|
+
setLocalValue(valueFormatter(jsonRef.current));
|
|
183
|
+
}, [valueFormatter]);
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<TextField
|
|
187
|
+
autoComplete="new-password"
|
|
188
|
+
InputLabelProps={InputLabelProps}
|
|
189
|
+
inputProps={{ style: { cursor: "pointer" } }}
|
|
190
|
+
InputProps={{
|
|
191
|
+
onKeyDown: (event) => {
|
|
192
|
+
if (event.key === "Tab") return;
|
|
193
|
+
cancelInput(event);
|
|
194
|
+
},
|
|
195
|
+
onPaste: cancelInput,
|
|
196
|
+
endAdornment: (
|
|
197
|
+
<InputAdornment position="end">
|
|
198
|
+
<IconButton edge="end" size="small">
|
|
199
|
+
<StartIcon />
|
|
200
|
+
</IconButton>
|
|
201
|
+
</InputAdornment>
|
|
202
|
+
)
|
|
203
|
+
}}
|
|
204
|
+
onClick={() => showStep(0)}
|
|
205
|
+
value={localValue}
|
|
206
|
+
{...rest}
|
|
207
|
+
/>
|
|
208
|
+
);
|
|
206
209
|
}
|