@etsoo/materialui 1.0.81 → 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.js +8 -5
- package/package.json +1 -1
- package/src/DataSteps.tsx +10 -6
package/lib/DataSteps.js
CHANGED
|
@@ -25,12 +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 Json data
|
|
29
|
+
const jsonRef = React.useRef(jsonValue);
|
|
28
30
|
// Current value
|
|
29
31
|
const [localValue, setLocalValue] = React.useState(value);
|
|
30
32
|
// Get step
|
|
31
33
|
const showStep = (index) => {
|
|
32
34
|
indexRef.current = index;
|
|
33
|
-
const [{ callback, ...rest }, more] = steps(index,
|
|
35
|
+
const [{ callback, ...rest }, more] = steps(index, jsonRef.current);
|
|
34
36
|
app.showInputDialog({
|
|
35
37
|
...rest,
|
|
36
38
|
buttons: (n, callback) => (React.createElement(HBox, { paddingLeft: 2, paddingRight: 2, paddingBottom: 2, gap: 2, justifyContent: "space-between" },
|
|
@@ -47,9 +49,10 @@ export function DataSteps(props) {
|
|
|
47
49
|
const result = await callback(event);
|
|
48
50
|
if (!result)
|
|
49
51
|
return;
|
|
50
|
-
|
|
52
|
+
const value = jsonRef.current;
|
|
53
|
+
setLocalValue(valueFormatter(value));
|
|
51
54
|
if (onValueChange)
|
|
52
|
-
onValueChange(
|
|
55
|
+
onValueChange(value);
|
|
53
56
|
} }, labels.submit)))),
|
|
54
57
|
callback: (form) => {
|
|
55
58
|
if (form == null)
|
|
@@ -66,8 +69,8 @@ export function DataSteps(props) {
|
|
|
66
69
|
event.preventDefault();
|
|
67
70
|
};
|
|
68
71
|
React.useEffect(() => {
|
|
69
|
-
setLocalValue(valueFormatter(
|
|
70
|
-
}, [
|
|
72
|
+
setLocalValue(valueFormatter(jsonRef.current));
|
|
73
|
+
}, [jsonRef.current]);
|
|
71
74
|
return (React.createElement(TextField, { InputLabelProps: InputLabelProps, inputProps: { style: { cursor: 'pointer' } }, InputProps: {
|
|
72
75
|
onKeyDown: (event) => {
|
|
73
76
|
if (event.key === 'Tab')
|
package/package.json
CHANGED
package/src/DataSteps.tsx
CHANGED
|
@@ -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,13 +83,16 @@ 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 Json data
|
|
87
|
+
const jsonRef = React.useRef<T>(jsonValue);
|
|
88
|
+
|
|
86
89
|
// Current value
|
|
87
90
|
const [localValue, setLocalValue] = React.useState(value);
|
|
88
91
|
|
|
89
92
|
// Get step
|
|
90
93
|
const showStep = (index: number) => {
|
|
91
94
|
indexRef.current = index;
|
|
92
|
-
const [{ callback, ...rest }, more] = steps(index,
|
|
95
|
+
const [{ callback, ...rest }, more] = steps(index, jsonRef.current);
|
|
93
96
|
|
|
94
97
|
app.showInputDialog({
|
|
95
98
|
...rest,
|
|
@@ -142,9 +145,10 @@ export function DataSteps<T extends object>(props: DataStepsProps<T>) {
|
|
|
142
145
|
const result = await callback(event);
|
|
143
146
|
if (!result) return;
|
|
144
147
|
|
|
145
|
-
|
|
148
|
+
const value = jsonRef.current;
|
|
149
|
+
setLocalValue(valueFormatter(value));
|
|
146
150
|
|
|
147
|
-
if (onValueChange) onValueChange(
|
|
151
|
+
if (onValueChange) onValueChange(value);
|
|
148
152
|
}}
|
|
149
153
|
>
|
|
150
154
|
{labels.submit}
|
|
@@ -168,8 +172,8 @@ export function DataSteps<T extends object>(props: DataStepsProps<T>) {
|
|
|
168
172
|
};
|
|
169
173
|
|
|
170
174
|
React.useEffect(() => {
|
|
171
|
-
setLocalValue(valueFormatter(
|
|
172
|
-
}, [
|
|
175
|
+
setLocalValue(valueFormatter(jsonRef.current));
|
|
176
|
+
}, [jsonRef.current]);
|
|
173
177
|
|
|
174
178
|
return (
|
|
175
179
|
<TextField
|