@etsoo/materialui 1.0.80 → 1.0.82
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/DataSteps.d.ts +1 -1
- package/lib/DataSteps.js +6 -9
- package/package.json +1 -1
- package/src/DataSteps.tsx +8 -11
package/lib/DataSteps.d.ts
CHANGED
package/lib/DataSteps.js
CHANGED
|
@@ -25,14 +25,14 @@ export function DataSteps(props) {
|
|
|
25
25
|
(_a = InputLabelProps.shrink) !== null && _a !== void 0 ? _a : (InputLabelProps.shrink = MUGlobal.searchFieldShrink);
|
|
26
26
|
// Current index
|
|
27
27
|
const indexRef = React.useRef(-1);
|
|
28
|
-
// Current data
|
|
29
|
-
const
|
|
28
|
+
// Current Json data
|
|
29
|
+
const jsonRef = React.useRef(jsonValue);
|
|
30
30
|
// Current value
|
|
31
31
|
const [localValue, setLocalValue] = React.useState(value);
|
|
32
32
|
// Get step
|
|
33
33
|
const showStep = (index) => {
|
|
34
34
|
indexRef.current = index;
|
|
35
|
-
const [{ callback, ...rest }, more] = steps(index,
|
|
35
|
+
const [{ callback, ...rest }, more] = steps(index, jsonRef.current);
|
|
36
36
|
app.showInputDialog({
|
|
37
37
|
...rest,
|
|
38
38
|
buttons: (n, callback) => (React.createElement(HBox, { paddingLeft: 2, paddingRight: 2, paddingBottom: 2, gap: 2, justifyContent: "space-between" },
|
|
@@ -49,7 +49,7 @@ export function DataSteps(props) {
|
|
|
49
49
|
const result = await callback(event);
|
|
50
50
|
if (!result)
|
|
51
51
|
return;
|
|
52
|
-
const value =
|
|
52
|
+
const value = jsonRef.current;
|
|
53
53
|
setLocalValue(valueFormatter(value));
|
|
54
54
|
if (onValueChange)
|
|
55
55
|
onValueChange(value);
|
|
@@ -69,11 +69,8 @@ export function DataSteps(props) {
|
|
|
69
69
|
event.preventDefault();
|
|
70
70
|
};
|
|
71
71
|
React.useEffect(() => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
setLocalValue(valueFormatter(dataRef.current));
|
|
75
|
-
}
|
|
76
|
-
}, [jsonValue]);
|
|
72
|
+
setLocalValue(valueFormatter(jsonRef.current));
|
|
73
|
+
}, [jsonRef.current]);
|
|
77
74
|
return (React.createElement(TextField, { InputLabelProps: InputLabelProps, inputProps: { style: { cursor: 'pointer' } }, InputProps: {
|
|
78
75
|
onKeyDown: (event) => {
|
|
79
76
|
if (event.key === 'Tab')
|
package/package.json
CHANGED
package/src/DataSteps.tsx
CHANGED
|
@@ -36,7 +36,7 @@ export type DataStepsProps<T extends object> = Omit<
|
|
|
36
36
|
/**
|
|
37
37
|
* JSON value
|
|
38
38
|
*/
|
|
39
|
-
jsonValue
|
|
39
|
+
jsonValue: T;
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Value formatter
|
|
@@ -70,7 +70,7 @@ export function DataSteps<T extends object>(props: DataStepsProps<T>) {
|
|
|
70
70
|
const {
|
|
71
71
|
InputLabelProps = {},
|
|
72
72
|
jsonValue,
|
|
73
|
-
valueFormatter = (_data
|
|
73
|
+
valueFormatter = (_data) => '...',
|
|
74
74
|
onValueChange,
|
|
75
75
|
steps,
|
|
76
76
|
value = '',
|
|
@@ -83,8 +83,8 @@ export function DataSteps<T extends object>(props: DataStepsProps<T>) {
|
|
|
83
83
|
// Current index
|
|
84
84
|
const indexRef = React.useRef<number>(-1);
|
|
85
85
|
|
|
86
|
-
// Current data
|
|
87
|
-
const
|
|
86
|
+
// Current Json data
|
|
87
|
+
const jsonRef = React.useRef<T>(jsonValue);
|
|
88
88
|
|
|
89
89
|
// Current value
|
|
90
90
|
const [localValue, setLocalValue] = React.useState(value);
|
|
@@ -92,7 +92,7 @@ export function DataSteps<T extends object>(props: DataStepsProps<T>) {
|
|
|
92
92
|
// Get step
|
|
93
93
|
const showStep = (index: number) => {
|
|
94
94
|
indexRef.current = index;
|
|
95
|
-
const [{ callback, ...rest }, more] = steps(index,
|
|
95
|
+
const [{ callback, ...rest }, more] = steps(index, jsonRef.current);
|
|
96
96
|
|
|
97
97
|
app.showInputDialog({
|
|
98
98
|
...rest,
|
|
@@ -145,7 +145,7 @@ export function DataSteps<T extends object>(props: DataStepsProps<T>) {
|
|
|
145
145
|
const result = await callback(event);
|
|
146
146
|
if (!result) return;
|
|
147
147
|
|
|
148
|
-
const value =
|
|
148
|
+
const value = jsonRef.current;
|
|
149
149
|
setLocalValue(valueFormatter(value));
|
|
150
150
|
|
|
151
151
|
if (onValueChange) onValueChange(value);
|
|
@@ -172,11 +172,8 @@ export function DataSteps<T extends object>(props: DataStepsProps<T>) {
|
|
|
172
172
|
};
|
|
173
173
|
|
|
174
174
|
React.useEffect(() => {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
setLocalValue(valueFormatter(dataRef.current));
|
|
178
|
-
}
|
|
179
|
-
}, [jsonValue]);
|
|
175
|
+
setLocalValue(valueFormatter(jsonRef.current));
|
|
176
|
+
}, [jsonRef.current]);
|
|
180
177
|
|
|
181
178
|
return (
|
|
182
179
|
<TextField
|