@etsoo/materialui 1.6.56 → 1.6.58

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.
@@ -33,6 +33,11 @@ export type NumberInputFieldProps = Omit<InputFieldProps, "type" | "inputProps">
33
33
  * Step value
34
34
  */
35
35
  step?: number;
36
+ /**
37
+ * Number value change handler
38
+ * @param value New value
39
+ */
40
+ onNumberChange?: (value: number | undefined) => void;
36
41
  };
37
42
  /**
38
43
  * Number input field, for controlled only components, please see IntInputField and MoneyInputField
@@ -17,8 +17,21 @@ const InputAdornment_1 = __importDefault(require("@mui/material/InputAdornment")
17
17
  function NumberInputField(props) {
18
18
  const { currency, inputStyle, min = 0, step = 1, symbol = currency
19
19
  ? `${currency} ${shared_1.NumberUtils.getCurrencySymbol(currency)}`
20
- : undefined, endSymbol, max = 9999999, slotProps = {}, ...rest } = props;
21
- return ((0, jsx_runtime_1.jsx)(InputField_1.InputField, { type: "number", slotProps: Object.assign(slotProps, {
20
+ : undefined, endSymbol, max = 9999999, onChange, onNumberChange, slotProps = {}, ...rest } = props;
21
+ return ((0, jsx_runtime_1.jsx)(InputField_1.InputField, { type: "number", onChange: (event) => {
22
+ onChange?.(event);
23
+ if (onNumberChange) {
24
+ const input = event.target;
25
+ if (input.checkValidity()) {
26
+ const qty = shared_1.NumberUtils.parse(input.value);
27
+ onNumberChange(qty);
28
+ }
29
+ else {
30
+ input.reportValidity();
31
+ onNumberChange(undefined);
32
+ }
33
+ }
34
+ }, slotProps: Object.assign(slotProps, {
22
35
  input: {
23
36
  startAdornment: symbol ? ((0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: (0, jsx_runtime_1.jsx)(InputAdornment_1.default, { position: "start", children: symbol }) })) : undefined,
24
37
  endAdornment: endSymbol ? ((0, jsx_runtime_1.jsx)(InputAdornment_1.default, { position: "end", children: endSymbol })) : undefined
@@ -33,6 +33,11 @@ export type NumberInputFieldProps = Omit<InputFieldProps, "type" | "inputProps">
33
33
  * Step value
34
34
  */
35
35
  step?: number;
36
+ /**
37
+ * Number value change handler
38
+ * @param value New value
39
+ */
40
+ onNumberChange?: (value: number | undefined) => void;
36
41
  };
37
42
  /**
38
43
  * Number input field, for controlled only components, please see IntInputField and MoneyInputField
@@ -11,8 +11,21 @@ import InputAdornment from "@mui/material/InputAdornment";
11
11
  export function NumberInputField(props) {
12
12
  const { currency, inputStyle, min = 0, step = 1, symbol = currency
13
13
  ? `${currency} ${NumberUtils.getCurrencySymbol(currency)}`
14
- : undefined, endSymbol, max = 9999999, slotProps = {}, ...rest } = props;
15
- return (_jsx(InputField, { type: "number", slotProps: Object.assign(slotProps, {
14
+ : undefined, endSymbol, max = 9999999, onChange, onNumberChange, slotProps = {}, ...rest } = props;
15
+ return (_jsx(InputField, { type: "number", onChange: (event) => {
16
+ onChange?.(event);
17
+ if (onNumberChange) {
18
+ const input = event.target;
19
+ if (input.checkValidity()) {
20
+ const qty = NumberUtils.parse(input.value);
21
+ onNumberChange(qty);
22
+ }
23
+ else {
24
+ input.reportValidity();
25
+ onNumberChange(undefined);
26
+ }
27
+ }
28
+ }, slotProps: Object.assign(slotProps, {
16
29
  input: {
17
30
  startAdornment: symbol ? (_jsx(React.Fragment, { children: _jsx(InputAdornment, { position: "start", children: symbol }) })) : undefined,
18
31
  endAdornment: endSymbol ? (_jsx(InputAdornment, { position: "end", children: endSymbol })) : undefined
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.6.56",
3
+ "version": "1.6.58",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -40,16 +40,16 @@
40
40
  "@dnd-kit/react": "^0.4.0",
41
41
  "@emotion/react": "^11.14.0",
42
42
  "@emotion/styled": "^11.14.1",
43
- "@etsoo/appscript": "^1.6.63",
43
+ "@etsoo/appscript": "^1.6.64",
44
44
  "@etsoo/notificationbase": "^1.1.71",
45
- "@etsoo/react": "^1.8.88",
45
+ "@etsoo/react": "^1.8.89",
46
46
  "@etsoo/shared": "^1.2.84",
47
47
  "@mui/icons-material": "^9.0.1",
48
48
  "@mui/material": "^9.0.1",
49
49
  "@mui/x-data-grid": "^9.1.0",
50
50
  "chart.js": "^4.5.1",
51
51
  "chartjs-plugin-datalabels": "^2.2.0",
52
- "dompurify": "^3.4.3",
52
+ "dompurify": "^3.4.5",
53
53
  "eventemitter3": "^5.0.4",
54
54
  "pica": "^9.0.1",
55
55
  "pulltorefreshjs": "^0.1.22",
@@ -46,6 +46,12 @@ export type NumberInputFieldProps = Omit<
46
46
  * Step value
47
47
  */
48
48
  step?: number;
49
+
50
+ /**
51
+ * Number value change handler
52
+ * @param value New value
53
+ */
54
+ onNumberChange?: (value: number | undefined) => void;
49
55
  };
50
56
 
51
57
  /**
@@ -64,6 +70,8 @@ export function NumberInputField(props: NumberInputFieldProps) {
64
70
  : undefined,
65
71
  endSymbol,
66
72
  max = 9999999,
73
+ onChange,
74
+ onNumberChange,
67
75
  slotProps = {},
68
76
  ...rest
69
77
  } = props;
@@ -71,6 +79,20 @@ export function NumberInputField(props: NumberInputFieldProps) {
71
79
  return (
72
80
  <InputField
73
81
  type="number"
82
+ onChange={(event) => {
83
+ onChange?.(event);
84
+
85
+ if (onNumberChange) {
86
+ const input = event.target;
87
+ if (input.checkValidity()) {
88
+ const qty = NumberUtils.parse(input.value);
89
+ onNumberChange(qty);
90
+ } else {
91
+ input.reportValidity();
92
+ onNumberChange(undefined);
93
+ }
94
+ }
95
+ }}
74
96
  slotProps={Object.assign(slotProps, {
75
97
  input: {
76
98
  startAdornment: symbol ? (