@etsoo/materialui 1.0.81 → 1.0.83

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