@etsoo/materialui 1.1.84 → 1.1.85

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.
@@ -42,7 +42,7 @@ export type IntInputFieldProps = Omit<InputFieldProps, "type" | "inputProps" | "
42
42
  * @param source Source value
43
43
  * @param init Initial action
44
44
  */
45
- onValueChange?: (value: number | undefined, source: unknown, init: boolean) => number | undefined;
45
+ onValueChange?: (value: number | undefined, source: unknown, init: boolean) => number | boolean | null | void;
46
46
  };
47
47
  /**
48
48
  * Integer input field
@@ -14,7 +14,16 @@ export const IntInputField = React.forwardRef((props, ref) => {
14
14
  const setValue = (value, source, init = false) => {
15
15
  if (onValueChange) {
16
16
  const newValue = onValueChange(value, source, init);
17
- setLocalValue(newValue);
17
+ if (newValue === false)
18
+ return;
19
+ if (newValue === null) {
20
+ setLocalValue(undefined);
21
+ return;
22
+ }
23
+ if (newValue === true || newValue === undefined)
24
+ setLocalValue(value);
25
+ else
26
+ setLocalValue(newValue);
18
27
  }
19
28
  };
20
29
  React.useEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.1.84",
3
+ "version": "1.1.85",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -61,7 +61,7 @@ export type IntInputFieldProps = Omit<
61
61
  value: number | undefined,
62
62
  source: unknown,
63
63
  init: boolean
64
- ) => number | undefined;
64
+ ) => number | boolean | null | void;
65
65
  };
66
66
 
67
67
  /**
@@ -98,7 +98,15 @@ export const IntInputField = React.forwardRef<
98
98
  ) => {
99
99
  if (onValueChange) {
100
100
  const newValue = onValueChange(value, source, init);
101
- setLocalValue(newValue);
101
+ if (newValue === false) return;
102
+
103
+ if (newValue === null) {
104
+ setLocalValue(undefined);
105
+ return;
106
+ }
107
+
108
+ if (newValue === true || newValue === undefined) setLocalValue(value);
109
+ else setLocalValue(newValue);
102
110
  }
103
111
  };
104
112