@etsoo/materialui 1.4.71 → 1.4.72
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/cjs/MaskInput.d.ts +1 -1
- package/lib/cjs/MaskInput.js +10 -12
- package/lib/mjs/MaskInput.d.ts +1 -1
- package/lib/mjs/MaskInput.js +10 -12
- package/package.json +1 -1
- package/src/MaskInput.tsx +12 -13
package/lib/cjs/MaskInput.d.ts
CHANGED
|
@@ -35,5 +35,5 @@ export type MaskInputProps = TextFieldProps & {
|
|
|
35
35
|
* @param props Props
|
|
36
36
|
* @returns Component
|
|
37
37
|
*/
|
|
38
|
-
export declare function MaskInput(props: MaskInputProps): import("react/jsx-runtime").JSX.Element
|
|
38
|
+
export declare function MaskInput(props: MaskInputProps): import("react/jsx-runtime").JSX.Element;
|
|
39
39
|
export {};
|
package/lib/cjs/MaskInput.js
CHANGED
|
@@ -8,6 +8,9 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
const material_1 = require("@mui/material");
|
|
9
9
|
const react_1 = __importDefault(require("react"));
|
|
10
10
|
const MUGlobal_1 = require("./MUGlobal");
|
|
11
|
+
// Currently CommonJS modules are not supported by "react-imask" package
|
|
12
|
+
let useIMask;
|
|
13
|
+
import("react-imask").then((module) => useIMask = module.useIMask);
|
|
11
14
|
/**
|
|
12
15
|
* Mask input
|
|
13
16
|
* https://imask.js.org/
|
|
@@ -16,13 +19,8 @@ const MUGlobal_1 = require("./MUGlobal");
|
|
|
16
19
|
*/
|
|
17
20
|
function MaskInput(props) {
|
|
18
21
|
// Destruct
|
|
19
|
-
const { defaultValue, mask, onAccept, onComplete, readOnly, search = false, size = search ? MUGlobal_1.MUGlobal.searchFieldSize : MUGlobal_1.MUGlobal.inputFieldSize, value, variant = search ? MUGlobal_1.MUGlobal.searchFieldVariant : MUGlobal_1.MUGlobal.inputFieldVariant, ...rest } = props;
|
|
20
|
-
|
|
21
|
-
const [useIMask, setUseIMask] = react_1.default.useState(null);
|
|
22
|
-
react_1.default.useEffect(() => {
|
|
23
|
-
import("react-imask").then((module) => setUseIMask(module.useIMask));
|
|
24
|
-
}, []);
|
|
25
|
-
const { ref, maskRef } = useIMask == null ? {} : useIMask(mask, {
|
|
22
|
+
const { defaultValue, mask, onAccept, onComplete, readOnly, search = false, size = search ? MUGlobal_1.MUGlobal.searchFieldSize : MUGlobal_1.MUGlobal.inputFieldSize, slotProps, value, variant = search ? MUGlobal_1.MUGlobal.searchFieldVariant : MUGlobal_1.MUGlobal.inputFieldVariant, ...rest } = props;
|
|
23
|
+
const { ref, maskRef } = useIMask(mask, {
|
|
26
24
|
onAccept: (value, maskRef, event) => {
|
|
27
25
|
if (onAccept)
|
|
28
26
|
onAccept(value, maskRef, event);
|
|
@@ -34,14 +32,14 @@ function MaskInput(props) {
|
|
|
34
32
|
});
|
|
35
33
|
const localValue = defaultValue ?? value;
|
|
36
34
|
react_1.default.useEffect(() => {
|
|
37
|
-
if (maskRef
|
|
35
|
+
if (maskRef.current == null || localValue == null)
|
|
38
36
|
return;
|
|
39
37
|
maskRef.current.value = String(localValue);
|
|
40
38
|
maskRef.current.updateValue();
|
|
41
|
-
}, [maskRef
|
|
39
|
+
}, [maskRef.current, localValue]);
|
|
42
40
|
// Layout
|
|
43
|
-
return
|
|
44
|
-
htmlInput: { readOnly },
|
|
45
|
-
inputLabel: { shrink: search ? MUGlobal_1.MUGlobal.searchFieldShrink : MUGlobal_1.MUGlobal.inputFieldShrink }
|
|
41
|
+
return ((0, jsx_runtime_1.jsx)(material_1.TextField, { slotProps: {
|
|
42
|
+
htmlInput: { readOnly, ...slotProps?.htmlInput },
|
|
43
|
+
inputLabel: { shrink: search ? MUGlobal_1.MUGlobal.searchFieldShrink : MUGlobal_1.MUGlobal.inputFieldShrink, ...slotProps?.inputLabel }
|
|
46
44
|
}, size: size, variant: variant, inputRef: ref, ...rest }));
|
|
47
45
|
}
|
package/lib/mjs/MaskInput.d.ts
CHANGED
|
@@ -35,5 +35,5 @@ export type MaskInputProps = TextFieldProps & {
|
|
|
35
35
|
* @param props Props
|
|
36
36
|
* @returns Component
|
|
37
37
|
*/
|
|
38
|
-
export declare function MaskInput(props: MaskInputProps): import("react/jsx-runtime").JSX.Element
|
|
38
|
+
export declare function MaskInput(props: MaskInputProps): import("react/jsx-runtime").JSX.Element;
|
|
39
39
|
export {};
|
package/lib/mjs/MaskInput.js
CHANGED
|
@@ -2,6 +2,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { TextField } from "@mui/material";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { MUGlobal } from "./MUGlobal";
|
|
5
|
+
// Currently CommonJS modules are not supported by "react-imask" package
|
|
6
|
+
let useIMask;
|
|
7
|
+
import("react-imask").then((module) => useIMask = module.useIMask);
|
|
5
8
|
/**
|
|
6
9
|
* Mask input
|
|
7
10
|
* https://imask.js.org/
|
|
@@ -10,13 +13,8 @@ import { MUGlobal } from "./MUGlobal";
|
|
|
10
13
|
*/
|
|
11
14
|
export function MaskInput(props) {
|
|
12
15
|
// Destruct
|
|
13
|
-
const { defaultValue, mask, onAccept, onComplete, readOnly, search = false, size = search ? MUGlobal.searchFieldSize : MUGlobal.inputFieldSize, value, variant = search ? MUGlobal.searchFieldVariant : MUGlobal.inputFieldVariant, ...rest } = props;
|
|
14
|
-
|
|
15
|
-
const [useIMask, setUseIMask] = React.useState(null);
|
|
16
|
-
React.useEffect(() => {
|
|
17
|
-
import("react-imask").then((module) => setUseIMask(module.useIMask));
|
|
18
|
-
}, []);
|
|
19
|
-
const { ref, maskRef } = useIMask == null ? {} : useIMask(mask, {
|
|
16
|
+
const { defaultValue, mask, onAccept, onComplete, readOnly, search = false, size = search ? MUGlobal.searchFieldSize : MUGlobal.inputFieldSize, slotProps, value, variant = search ? MUGlobal.searchFieldVariant : MUGlobal.inputFieldVariant, ...rest } = props;
|
|
17
|
+
const { ref, maskRef } = useIMask(mask, {
|
|
20
18
|
onAccept: (value, maskRef, event) => {
|
|
21
19
|
if (onAccept)
|
|
22
20
|
onAccept(value, maskRef, event);
|
|
@@ -28,14 +26,14 @@ export function MaskInput(props) {
|
|
|
28
26
|
});
|
|
29
27
|
const localValue = defaultValue ?? value;
|
|
30
28
|
React.useEffect(() => {
|
|
31
|
-
if (maskRef
|
|
29
|
+
if (maskRef.current == null || localValue == null)
|
|
32
30
|
return;
|
|
33
31
|
maskRef.current.value = String(localValue);
|
|
34
32
|
maskRef.current.updateValue();
|
|
35
|
-
}, [maskRef
|
|
33
|
+
}, [maskRef.current, localValue]);
|
|
36
34
|
// Layout
|
|
37
|
-
return
|
|
38
|
-
htmlInput: { readOnly },
|
|
39
|
-
inputLabel: { shrink: search ? MUGlobal.searchFieldShrink : MUGlobal.inputFieldShrink }
|
|
35
|
+
return (_jsx(TextField, { slotProps: {
|
|
36
|
+
htmlInput: { readOnly, ...slotProps?.htmlInput },
|
|
37
|
+
inputLabel: { shrink: search ? MUGlobal.searchFieldShrink : MUGlobal.inputFieldShrink, ...slotProps?.inputLabel }
|
|
40
38
|
}, size: size, variant: variant, inputRef: ref, ...rest }));
|
|
41
39
|
}
|
package/package.json
CHANGED
package/src/MaskInput.tsx
CHANGED
|
@@ -8,6 +8,10 @@ type RIReturns = ReturnType<ReactIMask>;
|
|
|
8
8
|
type RIMaskRef = RIReturns["maskRef"]["current"];
|
|
9
9
|
type RIMValue = RIReturns["value"];
|
|
10
10
|
|
|
11
|
+
// Currently CommonJS modules are not supported by "react-imask" package
|
|
12
|
+
let useIMask: ReactIMask;
|
|
13
|
+
import("react-imask").then((module) => useIMask = module.useIMask);
|
|
14
|
+
|
|
11
15
|
/**
|
|
12
16
|
* Mask input props
|
|
13
17
|
*/
|
|
@@ -56,18 +60,13 @@ export function MaskInput(
|
|
|
56
60
|
readOnly,
|
|
57
61
|
search = false,
|
|
58
62
|
size = search ? MUGlobal.searchFieldSize : MUGlobal.inputFieldSize,
|
|
63
|
+
slotProps,
|
|
59
64
|
value,
|
|
60
65
|
variant = search ? MUGlobal.searchFieldVariant : MUGlobal.inputFieldVariant,
|
|
61
66
|
...rest
|
|
62
67
|
} = props;
|
|
63
68
|
|
|
64
|
-
|
|
65
|
-
const [useIMask, setUseIMask] = React.useState<ReactIMask | null>(null);
|
|
66
|
-
React.useEffect(() => {
|
|
67
|
-
import("react-imask").then((module) => setUseIMask(module.useIMask));
|
|
68
|
-
}, []);
|
|
69
|
-
|
|
70
|
-
const { ref, maskRef } = useIMask == null ? {} : useIMask(mask, {
|
|
69
|
+
const { ref, maskRef } = useIMask(mask, {
|
|
71
70
|
onAccept: (value: RIMValue, maskRef: RIMaskRef, event?: InputEvent) => {
|
|
72
71
|
if (onAccept) onAccept(value, maskRef, event);
|
|
73
72
|
},
|
|
@@ -79,17 +78,17 @@ export function MaskInput(
|
|
|
79
78
|
const localValue = defaultValue ?? value;
|
|
80
79
|
|
|
81
80
|
React.useEffect(() => {
|
|
82
|
-
if (maskRef
|
|
81
|
+
if (maskRef.current == null || localValue == null) return;
|
|
83
82
|
maskRef.current.value = String(localValue);
|
|
84
83
|
maskRef.current.updateValue();
|
|
85
|
-
}, [maskRef
|
|
84
|
+
}, [maskRef.current, localValue]);
|
|
86
85
|
|
|
87
86
|
// Layout
|
|
88
|
-
return
|
|
87
|
+
return (
|
|
89
88
|
<TextField
|
|
90
89
|
slotProps={{
|
|
91
|
-
htmlInput: { readOnly },
|
|
92
|
-
inputLabel: { shrink: search ? MUGlobal.searchFieldShrink : MUGlobal.inputFieldShrink }
|
|
90
|
+
htmlInput: { readOnly, ...slotProps?.htmlInput },
|
|
91
|
+
inputLabel: { shrink: search ? MUGlobal.searchFieldShrink : MUGlobal.inputFieldShrink, ...slotProps?.inputLabel }
|
|
93
92
|
}}
|
|
94
93
|
size={size}
|
|
95
94
|
variant={variant}
|
|
@@ -97,4 +96,4 @@ export function MaskInput(
|
|
|
97
96
|
{...rest}
|
|
98
97
|
/>
|
|
99
98
|
);
|
|
100
|
-
}
|
|
99
|
+
}
|