@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.
@@ -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,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 dataRef = React.useRef({});
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, dataRef.current);
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 = dataRef.current;
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
- if (jsonValue) {
73
- dataRef.current = JSON.parse(jsonValue);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.0.80",
3
+ "version": "1.0.82",
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
@@ -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,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 dataRef = React.useRef({} as T);
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, dataRef.current);
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 = dataRef.current;
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
- if (jsonValue) {
176
- dataRef.current = JSON.parse(jsonValue);
177
- setLocalValue(valueFormatter(dataRef.current));
178
- }
179
- }, [jsonValue]);
175
+ setLocalValue(valueFormatter(jsonRef.current));
176
+ }, [jsonRef.current]);
180
177
 
181
178
  return (
182
179
  <TextField