@etsoo/materialui 1.1.82 → 1.1.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/IntInputField.d.ts +18 -25
- package/lib/IntInputField.js +4 -4
- package/package.json +1 -1
- package/src/IntInputField.tsx +52 -33
package/lib/IntInputField.d.ts
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
import { InputBaseProps } from "@mui/material";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import { InputFieldProps } from "./InputField";
|
|
4
3
|
/**
|
|
5
4
|
* Integer input field props
|
|
6
5
|
*/
|
|
7
|
-
export type IntInputFieldProps = Omit<InputFieldProps, "type" | "inputProps" | "value"> &
|
|
6
|
+
export type IntInputFieldProps = Omit<InputFieldProps, "type" | "inputProps" | "value"> & {
|
|
7
|
+
/**
|
|
8
|
+
* Minimum value
|
|
9
|
+
*/
|
|
10
|
+
min?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Maximum value
|
|
13
|
+
*/
|
|
14
|
+
max?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Step value
|
|
17
|
+
*/
|
|
18
|
+
step?: number;
|
|
8
19
|
/**
|
|
9
20
|
* Display minus and plus buttons
|
|
10
21
|
*/
|
|
@@ -21,6 +32,10 @@ export type IntInputFieldProps = Omit<InputFieldProps, "type" | "inputProps" | "
|
|
|
21
32
|
* Value
|
|
22
33
|
*/
|
|
23
34
|
value?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Input field style
|
|
37
|
+
*/
|
|
38
|
+
inputStyle?: React.CSSProperties;
|
|
24
39
|
/**
|
|
25
40
|
* On value change callback
|
|
26
41
|
* @param value Value
|
|
@@ -30,26 +45,4 @@ export type IntInputFieldProps = Omit<InputFieldProps, "type" | "inputProps" | "
|
|
|
30
45
|
/**
|
|
31
46
|
* Integer input field
|
|
32
47
|
*/
|
|
33
|
-
export declare const IntInputField: React.ForwardRefExoticComponent<Omit<
|
|
34
|
-
/**
|
|
35
|
-
* Display minus and plus buttons
|
|
36
|
-
*/
|
|
37
|
-
buttons?: boolean | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* End symbol
|
|
40
|
-
*/
|
|
41
|
-
endSymbol?: string | undefined;
|
|
42
|
-
/**
|
|
43
|
-
* Start (Currency) symbol
|
|
44
|
-
*/
|
|
45
|
-
symbol?: string | undefined;
|
|
46
|
-
/**
|
|
47
|
-
* Value
|
|
48
|
-
*/
|
|
49
|
-
value?: number | undefined;
|
|
50
|
-
/**
|
|
51
|
-
* On value change callback
|
|
52
|
-
* @param value Value
|
|
53
|
-
*/
|
|
54
|
-
onValueChange?: ((value: number | undefined, init: boolean) => void) | undefined;
|
|
55
|
-
}, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
48
|
+
export declare const IntInputField: React.ForwardRefExoticComponent<Omit<IntInputFieldProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
package/lib/IntInputField.js
CHANGED
|
@@ -8,7 +8,7 @@ import { InputField } from "./InputField";
|
|
|
8
8
|
*/
|
|
9
9
|
export const IntInputField = React.forwardRef((props, ref) => {
|
|
10
10
|
// Destruct
|
|
11
|
-
const { min = 0, step = 1, max = 9999999,
|
|
11
|
+
const { min = 0, step = 1, max = 9999999, inputStyle = { textAlign: "right" }, buttons, endSymbol, symbol, value, defaultValue, onChange, onValueChange, ...rest } = props;
|
|
12
12
|
// State
|
|
13
13
|
const [localValue, setLocalValue] = React.useState();
|
|
14
14
|
const setValue = (value, init = false) => {
|
|
@@ -20,11 +20,11 @@ export const IntInputField = React.forwardRef((props, ref) => {
|
|
|
20
20
|
setValue(value, true);
|
|
21
21
|
}, [value]);
|
|
22
22
|
React.useEffect(() => {
|
|
23
|
-
if (defaultValue == null
|
|
23
|
+
if (defaultValue == null)
|
|
24
24
|
return;
|
|
25
25
|
const value = typeof defaultValue === "number"
|
|
26
26
|
? defaultValue
|
|
27
|
-
: parseFloat(defaultValue);
|
|
27
|
+
: parseFloat(`${defaultValue}`);
|
|
28
28
|
if (!isNaN(value))
|
|
29
29
|
setValue(value, true);
|
|
30
30
|
}, [defaultValue]);
|
|
@@ -33,7 +33,7 @@ export const IntInputField = React.forwardRef((props, ref) => {
|
|
|
33
33
|
min,
|
|
34
34
|
step,
|
|
35
35
|
max,
|
|
36
|
-
style,
|
|
36
|
+
style: inputStyle,
|
|
37
37
|
inputMode: "numeric"
|
|
38
38
|
}, InputProps: {
|
|
39
39
|
startAdornment: symbol ? (React.createElement(React.Fragment, null,
|
package/package.json
CHANGED
package/src/IntInputField.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Box, IconButton, InputAdornment
|
|
1
|
+
import { Box, IconButton, InputAdornment } from "@mui/material";
|
|
2
2
|
import AddIcon from "@mui/icons-material/Add";
|
|
3
3
|
import RemoveIcon from "@mui/icons-material/Remove";
|
|
4
4
|
import React from "react";
|
|
@@ -10,34 +10,53 @@ import { InputField, InputFieldProps } from "./InputField";
|
|
|
10
10
|
export type IntInputFieldProps = Omit<
|
|
11
11
|
InputFieldProps,
|
|
12
12
|
"type" | "inputProps" | "value"
|
|
13
|
-
> &
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
13
|
+
> & {
|
|
14
|
+
/**
|
|
15
|
+
* Minimum value
|
|
16
|
+
*/
|
|
17
|
+
min?: number;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Maximum value
|
|
21
|
+
*/
|
|
22
|
+
max?: number;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Step value
|
|
26
|
+
*/
|
|
27
|
+
step?: number;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Display minus and plus buttons
|
|
31
|
+
*/
|
|
32
|
+
buttons?: boolean;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* End symbol
|
|
36
|
+
*/
|
|
37
|
+
endSymbol?: string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Start (Currency) symbol
|
|
41
|
+
*/
|
|
42
|
+
symbol?: string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Value
|
|
46
|
+
*/
|
|
47
|
+
value?: number;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Input field style
|
|
51
|
+
*/
|
|
52
|
+
inputStyle?: React.CSSProperties;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* On value change callback
|
|
56
|
+
* @param value Value
|
|
57
|
+
*/
|
|
58
|
+
onValueChange?: (value: number | undefined, init: boolean) => void;
|
|
59
|
+
};
|
|
41
60
|
|
|
42
61
|
/**
|
|
43
62
|
* Integer input field
|
|
@@ -51,7 +70,7 @@ export const IntInputField = React.forwardRef<
|
|
|
51
70
|
min = 0,
|
|
52
71
|
step = 1,
|
|
53
72
|
max = 9999999,
|
|
54
|
-
|
|
73
|
+
inputStyle = { textAlign: "right" },
|
|
55
74
|
buttons,
|
|
56
75
|
endSymbol,
|
|
57
76
|
symbol,
|
|
@@ -75,11 +94,11 @@ export const IntInputField = React.forwardRef<
|
|
|
75
94
|
}, [value]);
|
|
76
95
|
|
|
77
96
|
React.useEffect(() => {
|
|
78
|
-
if (defaultValue == null
|
|
97
|
+
if (defaultValue == null) return;
|
|
79
98
|
const value =
|
|
80
99
|
typeof defaultValue === "number"
|
|
81
100
|
? defaultValue
|
|
82
|
-
: parseFloat(defaultValue);
|
|
101
|
+
: parseFloat(`${defaultValue}`);
|
|
83
102
|
if (!isNaN(value)) setValue(value, true);
|
|
84
103
|
}, [defaultValue]);
|
|
85
104
|
|
|
@@ -93,7 +112,7 @@ export const IntInputField = React.forwardRef<
|
|
|
93
112
|
min,
|
|
94
113
|
step,
|
|
95
114
|
max,
|
|
96
|
-
style,
|
|
115
|
+
style: inputStyle,
|
|
97
116
|
inputMode: "numeric"
|
|
98
117
|
}}
|
|
99
118
|
InputProps={{
|