@etsoo/materialui 1.0.80 → 1.0.81

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