@etsoo/materialui 1.4.70 → 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/cjs/pages/CommonPage.js +4 -4
- package/lib/mjs/MaskInput.d.ts +1 -1
- package/lib/mjs/MaskInput.js +10 -12
- package/lib/mjs/pages/CommonPage.js +4 -4
- package/package.json +1 -1
- package/src/MaskInput.tsx +12 -13
- package/src/pages/CommonPage.tsx +24 -20
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
|
}
|
|
@@ -30,9 +30,11 @@ function CommonPage(props) {
|
|
|
30
30
|
}
|
|
31
31
|
// Labels
|
|
32
32
|
const labels = Labels_1.Labels.CommonPage;
|
|
33
|
+
const theme = (0, material_1.useTheme)();
|
|
34
|
+
const distance = react_1.default.useMemo(() => MUGlobal_1.MUGlobal.updateWithTheme(fabPadding, theme.spacing), [fabPadding, theme.spacing]);
|
|
33
35
|
// Update
|
|
34
36
|
const updateRef = react_1.default.useRef(false);
|
|
35
|
-
const update = onUpdateAll
|
|
37
|
+
const update = react_1.default.useMemo(() => onUpdateAll
|
|
36
38
|
? onUpdateAll
|
|
37
39
|
: onUpdate
|
|
38
40
|
? async (authorized) => {
|
|
@@ -48,9 +50,7 @@ function CommonPage(props) {
|
|
|
48
50
|
updateRef.current = true;
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
|
-
: undefined;
|
|
52
|
-
const theme = (0, material_1.useTheme)();
|
|
53
|
-
const distance = react_1.default.useMemo(() => MUGlobal_1.MUGlobal.updateWithTheme(fabPadding, theme.spacing), [fabPadding, theme.spacing]);
|
|
53
|
+
: undefined, [onUpdateAll, onUpdate, onRefresh]);
|
|
54
54
|
react_1.default.useEffect(() => {
|
|
55
55
|
if (updateRef.current && update) {
|
|
56
56
|
update(true, []);
|
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
|
}
|
|
@@ -24,9 +24,11 @@ export function CommonPage(props) {
|
|
|
24
24
|
}
|
|
25
25
|
// Labels
|
|
26
26
|
const labels = Labels.CommonPage;
|
|
27
|
+
const theme = useTheme();
|
|
28
|
+
const distance = React.useMemo(() => MUGlobal.updateWithTheme(fabPadding, theme.spacing), [fabPadding, theme.spacing]);
|
|
27
29
|
// Update
|
|
28
30
|
const updateRef = React.useRef(false);
|
|
29
|
-
const update = onUpdateAll
|
|
31
|
+
const update = React.useMemo(() => onUpdateAll
|
|
30
32
|
? onUpdateAll
|
|
31
33
|
: onUpdate
|
|
32
34
|
? async (authorized) => {
|
|
@@ -42,9 +44,7 @@ export function CommonPage(props) {
|
|
|
42
44
|
updateRef.current = true;
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
|
-
: undefined;
|
|
46
|
-
const theme = useTheme();
|
|
47
|
-
const distance = React.useMemo(() => MUGlobal.updateWithTheme(fabPadding, theme.spacing), [fabPadding, theme.spacing]);
|
|
47
|
+
: undefined, [onUpdateAll, onUpdate, onRefresh]);
|
|
48
48
|
React.useEffect(() => {
|
|
49
49
|
if (updateRef.current && update) {
|
|
50
50
|
update(true, []);
|
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
|
+
}
|
package/src/pages/CommonPage.tsx
CHANGED
|
@@ -127,32 +127,36 @@ export function CommonPage(props: CommonPageProps) {
|
|
|
127
127
|
// Labels
|
|
128
128
|
const labels = Labels.CommonPage;
|
|
129
129
|
|
|
130
|
-
// Update
|
|
131
|
-
const updateRef = React.useRef(false);
|
|
132
|
-
const update = onUpdateAll
|
|
133
|
-
? onUpdateAll
|
|
134
|
-
: onUpdate
|
|
135
|
-
? async (authorized?: boolean) => {
|
|
136
|
-
if (authorized == null || authorized) {
|
|
137
|
-
await onUpdate();
|
|
138
|
-
updateRef.current = true;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
: onRefresh
|
|
142
|
-
? async (authorized?: boolean) => {
|
|
143
|
-
if (authorized) {
|
|
144
|
-
await onRefresh();
|
|
145
|
-
updateRef.current = true;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
: undefined;
|
|
149
|
-
|
|
150
130
|
const theme = useTheme();
|
|
151
131
|
const distance = React.useMemo(
|
|
152
132
|
() => MUGlobal.updateWithTheme(fabPadding, theme.spacing),
|
|
153
133
|
[fabPadding, theme.spacing]
|
|
154
134
|
);
|
|
155
135
|
|
|
136
|
+
// Update
|
|
137
|
+
const updateRef = React.useRef(false);
|
|
138
|
+
const update = React.useMemo(
|
|
139
|
+
() =>
|
|
140
|
+
onUpdateAll
|
|
141
|
+
? onUpdateAll
|
|
142
|
+
: onUpdate
|
|
143
|
+
? async (authorized?: boolean) => {
|
|
144
|
+
if (authorized == null || authorized) {
|
|
145
|
+
await onUpdate();
|
|
146
|
+
updateRef.current = true;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
: onRefresh
|
|
150
|
+
? async (authorized?: boolean) => {
|
|
151
|
+
if (authorized) {
|
|
152
|
+
await onRefresh();
|
|
153
|
+
updateRef.current = true;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
: undefined,
|
|
157
|
+
[onUpdateAll, onUpdate, onRefresh]
|
|
158
|
+
);
|
|
159
|
+
|
|
156
160
|
React.useEffect(() => {
|
|
157
161
|
if (updateRef.current && update) {
|
|
158
162
|
update(true, []);
|