@etsoo/materialui 1.4.69 → 1.4.71
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 -2
- package/lib/cjs/MaskInput.js +8 -15
- package/lib/cjs/pages/CommonPage.js +20 -10
- package/lib/mjs/MaskInput.d.ts +1 -2
- package/lib/mjs/MaskInput.js +8 -15
- package/lib/mjs/pages/CommonPage.js +20 -10
- package/package.json +1 -1
- package/src/MaskInput.tsx +11 -21
- package/src/pages/CommonPage.tsx +30 -13
package/lib/cjs/MaskInput.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { TextFieldProps } from "@mui/material";
|
|
2
2
|
type ReactIMask = typeof import("react-imask", { with: { "resolution-mode": "import" } }).useIMask;
|
|
3
|
-
type
|
|
4
|
-
type RIOpts = ReactIMaskProps[0];
|
|
3
|
+
type RIOpts = Parameters<ReactIMask>[0];
|
|
5
4
|
type RIReturns = ReturnType<ReactIMask>;
|
|
6
5
|
type RIMaskRef = RIReturns["maskRef"]["current"];
|
|
7
6
|
type RIMValue = RIReturns["value"];
|
package/lib/cjs/MaskInput.js
CHANGED
|
@@ -16,15 +16,13 @@ const MUGlobal_1 = require("./MUGlobal");
|
|
|
16
16
|
*/
|
|
17
17
|
function MaskInput(props) {
|
|
18
18
|
// Destruct
|
|
19
|
-
const { defaultValue, mask,
|
|
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
20
|
// State
|
|
21
21
|
const [useIMask, setUseIMask] = react_1.default.useState(null);
|
|
22
22
|
react_1.default.useEffect(() => {
|
|
23
23
|
import("react-imask").then((module) => setUseIMask(module.useIMask));
|
|
24
24
|
}, []);
|
|
25
|
-
|
|
26
|
-
return;
|
|
27
|
-
const { ref, maskRef } = useIMask(mask, {
|
|
25
|
+
const { ref, maskRef } = useIMask == null ? {} : useIMask(mask, {
|
|
28
26
|
onAccept: (value, maskRef, event) => {
|
|
29
27
|
if (onAccept)
|
|
30
28
|
onAccept(value, maskRef, event);
|
|
@@ -35,20 +33,15 @@ function MaskInput(props) {
|
|
|
35
33
|
}
|
|
36
34
|
});
|
|
37
35
|
const localValue = defaultValue ?? value;
|
|
38
|
-
// Shrink
|
|
39
|
-
InputLabelProps.shrink ??= search
|
|
40
|
-
? MUGlobal_1.MUGlobal.searchFieldShrink
|
|
41
|
-
: MUGlobal_1.MUGlobal.inputFieldShrink;
|
|
42
|
-
// Read only
|
|
43
|
-
if (readOnly != null)
|
|
44
|
-
InputProps.readOnly = readOnly;
|
|
45
|
-
InputProps.inputRef = ref;
|
|
46
36
|
react_1.default.useEffect(() => {
|
|
47
|
-
if (maskRef
|
|
37
|
+
if (maskRef?.current == null || localValue == null)
|
|
48
38
|
return;
|
|
49
39
|
maskRef.current.value = String(localValue);
|
|
50
40
|
maskRef.current.updateValue();
|
|
51
|
-
}, [maskRef
|
|
41
|
+
}, [maskRef?.current, localValue]);
|
|
52
42
|
// Layout
|
|
53
|
-
return ((0, jsx_runtime_1.jsx)(material_1.TextField, {
|
|
43
|
+
return ref == null ? undefined : ((0, jsx_runtime_1.jsx)(material_1.TextField, { slotProps: {
|
|
44
|
+
htmlInput: { readOnly },
|
|
45
|
+
inputLabel: { shrink: search ? MUGlobal_1.MUGlobal.searchFieldShrink : MUGlobal_1.MUGlobal.inputFieldShrink }
|
|
46
|
+
}, size: size, variant: variant, inputRef: ref, ...rest }));
|
|
54
47
|
}
|
|
@@ -30,22 +30,32 @@ 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
|
-
const
|
|
36
|
+
const updateRef = react_1.default.useRef(false);
|
|
37
|
+
const update = react_1.default.useMemo(() => onUpdateAll
|
|
35
38
|
? onUpdateAll
|
|
36
39
|
: onUpdate
|
|
37
|
-
? (authorized) => {
|
|
38
|
-
if (authorized == null || authorized)
|
|
39
|
-
onUpdate();
|
|
40
|
+
? async (authorized) => {
|
|
41
|
+
if (authorized == null || authorized) {
|
|
42
|
+
await onUpdate();
|
|
43
|
+
updateRef.current = true;
|
|
44
|
+
}
|
|
40
45
|
}
|
|
41
46
|
: onRefresh
|
|
42
|
-
? (authorized) => {
|
|
43
|
-
if (authorized)
|
|
44
|
-
onRefresh();
|
|
47
|
+
? async (authorized) => {
|
|
48
|
+
if (authorized) {
|
|
49
|
+
await onRefresh();
|
|
50
|
+
updateRef.current = true;
|
|
51
|
+
}
|
|
45
52
|
}
|
|
46
|
-
: undefined;
|
|
47
|
-
|
|
48
|
-
|
|
53
|
+
: undefined, [onUpdateAll, onUpdate, onRefresh]);
|
|
54
|
+
react_1.default.useEffect(() => {
|
|
55
|
+
if (updateRef.current && update) {
|
|
56
|
+
update(true, []);
|
|
57
|
+
}
|
|
58
|
+
}, [update]);
|
|
49
59
|
// Return the UI
|
|
50
60
|
return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [update && ((0, jsx_runtime_1.jsx)(ReactApp_1.ReactAppStateDetector, { targetFields: targetFields, update: update })), (0, jsx_runtime_1.jsxs)(material_1.Container, { disableGutters: disableGutters, maxWidth: maxWidth, sx: sx, id: "page-container", ...rest, children: [(0, jsx_runtime_1.jsxs)(FabBox_1.FabBox, { sx: {
|
|
51
61
|
zIndex: 1,
|
package/lib/mjs/MaskInput.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { TextFieldProps } from "@mui/material";
|
|
2
2
|
type ReactIMask = typeof import("react-imask", { with: { "resolution-mode": "import" } }).useIMask;
|
|
3
|
-
type
|
|
4
|
-
type RIOpts = ReactIMaskProps[0];
|
|
3
|
+
type RIOpts = Parameters<ReactIMask>[0];
|
|
5
4
|
type RIReturns = ReturnType<ReactIMask>;
|
|
6
5
|
type RIMaskRef = RIReturns["maskRef"]["current"];
|
|
7
6
|
type RIMValue = RIReturns["value"];
|
package/lib/mjs/MaskInput.js
CHANGED
|
@@ -10,15 +10,13 @@ import { MUGlobal } from "./MUGlobal";
|
|
|
10
10
|
*/
|
|
11
11
|
export function MaskInput(props) {
|
|
12
12
|
// Destruct
|
|
13
|
-
const { defaultValue, mask,
|
|
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
14
|
// State
|
|
15
15
|
const [useIMask, setUseIMask] = React.useState(null);
|
|
16
16
|
React.useEffect(() => {
|
|
17
17
|
import("react-imask").then((module) => setUseIMask(module.useIMask));
|
|
18
18
|
}, []);
|
|
19
|
-
|
|
20
|
-
return;
|
|
21
|
-
const { ref, maskRef } = useIMask(mask, {
|
|
19
|
+
const { ref, maskRef } = useIMask == null ? {} : useIMask(mask, {
|
|
22
20
|
onAccept: (value, maskRef, event) => {
|
|
23
21
|
if (onAccept)
|
|
24
22
|
onAccept(value, maskRef, event);
|
|
@@ -29,20 +27,15 @@ export function MaskInput(props) {
|
|
|
29
27
|
}
|
|
30
28
|
});
|
|
31
29
|
const localValue = defaultValue ?? value;
|
|
32
|
-
// Shrink
|
|
33
|
-
InputLabelProps.shrink ??= search
|
|
34
|
-
? MUGlobal.searchFieldShrink
|
|
35
|
-
: MUGlobal.inputFieldShrink;
|
|
36
|
-
// Read only
|
|
37
|
-
if (readOnly != null)
|
|
38
|
-
InputProps.readOnly = readOnly;
|
|
39
|
-
InputProps.inputRef = ref;
|
|
40
30
|
React.useEffect(() => {
|
|
41
|
-
if (maskRef
|
|
31
|
+
if (maskRef?.current == null || localValue == null)
|
|
42
32
|
return;
|
|
43
33
|
maskRef.current.value = String(localValue);
|
|
44
34
|
maskRef.current.updateValue();
|
|
45
|
-
}, [maskRef
|
|
35
|
+
}, [maskRef?.current, localValue]);
|
|
46
36
|
// Layout
|
|
47
|
-
return
|
|
37
|
+
return ref == null ? undefined : (_jsx(TextField, { slotProps: {
|
|
38
|
+
htmlInput: { readOnly },
|
|
39
|
+
inputLabel: { shrink: search ? MUGlobal.searchFieldShrink : MUGlobal.inputFieldShrink }
|
|
40
|
+
}, size: size, variant: variant, inputRef: ref, ...rest }));
|
|
48
41
|
}
|
|
@@ -24,22 +24,32 @@ 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
|
-
const
|
|
30
|
+
const updateRef = React.useRef(false);
|
|
31
|
+
const update = React.useMemo(() => onUpdateAll
|
|
29
32
|
? onUpdateAll
|
|
30
33
|
: onUpdate
|
|
31
|
-
? (authorized) => {
|
|
32
|
-
if (authorized == null || authorized)
|
|
33
|
-
onUpdate();
|
|
34
|
+
? async (authorized) => {
|
|
35
|
+
if (authorized == null || authorized) {
|
|
36
|
+
await onUpdate();
|
|
37
|
+
updateRef.current = true;
|
|
38
|
+
}
|
|
34
39
|
}
|
|
35
40
|
: onRefresh
|
|
36
|
-
? (authorized) => {
|
|
37
|
-
if (authorized)
|
|
38
|
-
onRefresh();
|
|
41
|
+
? async (authorized) => {
|
|
42
|
+
if (authorized) {
|
|
43
|
+
await onRefresh();
|
|
44
|
+
updateRef.current = true;
|
|
45
|
+
}
|
|
39
46
|
}
|
|
40
|
-
: undefined;
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
: undefined, [onUpdateAll, onUpdate, onRefresh]);
|
|
48
|
+
React.useEffect(() => {
|
|
49
|
+
if (updateRef.current && update) {
|
|
50
|
+
update(true, []);
|
|
51
|
+
}
|
|
52
|
+
}, [update]);
|
|
43
53
|
// Return the UI
|
|
44
54
|
return (_jsxs(React.Fragment, { children: [update && (_jsx(ReactAppStateDetector, { targetFields: targetFields, update: update })), _jsxs(Container, { disableGutters: disableGutters, maxWidth: maxWidth, sx: sx, id: "page-container", ...rest, children: [_jsxs(FabBox, { sx: {
|
|
45
55
|
zIndex: 1,
|
package/package.json
CHANGED
package/src/MaskInput.tsx
CHANGED
|
@@ -3,8 +3,7 @@ import React from "react";
|
|
|
3
3
|
import { MUGlobal } from "./MUGlobal";
|
|
4
4
|
|
|
5
5
|
type ReactIMask = typeof import("react-imask", { with: { "resolution-mode": "import" }}).useIMask;
|
|
6
|
-
type
|
|
7
|
-
type RIOpts = ReactIMaskProps[0];
|
|
6
|
+
type RIOpts = Parameters<ReactIMask>[0];
|
|
8
7
|
type RIReturns = ReturnType<ReactIMask>;
|
|
9
8
|
type RIMaskRef = RIReturns["maskRef"]["current"];
|
|
10
9
|
type RIMValue = RIReturns["value"];
|
|
@@ -52,8 +51,6 @@ export function MaskInput(
|
|
|
52
51
|
const {
|
|
53
52
|
defaultValue,
|
|
54
53
|
mask,
|
|
55
|
-
InputLabelProps = {},
|
|
56
|
-
InputProps = {},
|
|
57
54
|
onAccept,
|
|
58
55
|
onComplete,
|
|
59
56
|
readOnly,
|
|
@@ -70,9 +67,7 @@ export function MaskInput(
|
|
|
70
67
|
import("react-imask").then((module) => setUseIMask(module.useIMask));
|
|
71
68
|
}, []);
|
|
72
69
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const { ref, maskRef } = useIMask(mask, {
|
|
70
|
+
const { ref, maskRef } = useIMask == null ? {} : useIMask(mask, {
|
|
76
71
|
onAccept: (value: RIMValue, maskRef: RIMaskRef, event?: InputEvent) => {
|
|
77
72
|
if (onAccept) onAccept(value, maskRef, event);
|
|
78
73
|
},
|
|
@@ -80,30 +75,25 @@ export function MaskInput(
|
|
|
80
75
|
if (onComplete) onComplete(value, maskRef, event);
|
|
81
76
|
}
|
|
82
77
|
});
|
|
83
|
-
const localValue = defaultValue ?? value;
|
|
84
78
|
|
|
85
|
-
|
|
86
|
-
InputLabelProps.shrink ??= search
|
|
87
|
-
? MUGlobal.searchFieldShrink
|
|
88
|
-
: MUGlobal.inputFieldShrink;
|
|
89
|
-
|
|
90
|
-
// Read only
|
|
91
|
-
if (readOnly != null) InputProps.readOnly = readOnly;
|
|
92
|
-
InputProps.inputRef = ref;
|
|
79
|
+
const localValue = defaultValue ?? value;
|
|
93
80
|
|
|
94
81
|
React.useEffect(() => {
|
|
95
|
-
if (maskRef
|
|
82
|
+
if (maskRef?.current == null || localValue == null) return;
|
|
96
83
|
maskRef.current.value = String(localValue);
|
|
97
84
|
maskRef.current.updateValue();
|
|
98
|
-
}, [maskRef
|
|
85
|
+
}, [maskRef?.current, localValue]);
|
|
99
86
|
|
|
100
87
|
// Layout
|
|
101
|
-
return (
|
|
88
|
+
return ref == null ? undefined: (
|
|
102
89
|
<TextField
|
|
103
|
-
|
|
104
|
-
|
|
90
|
+
slotProps={{
|
|
91
|
+
htmlInput: { readOnly },
|
|
92
|
+
inputLabel: { shrink: search ? MUGlobal.searchFieldShrink : MUGlobal.inputFieldShrink }
|
|
93
|
+
}}
|
|
105
94
|
size={size}
|
|
106
95
|
variant={variant}
|
|
96
|
+
inputRef={ref}
|
|
107
97
|
{...rest}
|
|
108
98
|
/>
|
|
109
99
|
);
|
package/src/pages/CommonPage.tsx
CHANGED
|
@@ -127,25 +127,42 @@ export function CommonPage(props: CommonPageProps) {
|
|
|
127
127
|
// Labels
|
|
128
128
|
const labels = Labels.CommonPage;
|
|
129
129
|
|
|
130
|
-
// Update
|
|
131
|
-
const update = onUpdateAll
|
|
132
|
-
? onUpdateAll
|
|
133
|
-
: onUpdate
|
|
134
|
-
? (authorized?: boolean) => {
|
|
135
|
-
if (authorized == null || authorized) onUpdate();
|
|
136
|
-
}
|
|
137
|
-
: onRefresh
|
|
138
|
-
? (authorized?: boolean) => {
|
|
139
|
-
if (authorized) onRefresh();
|
|
140
|
-
}
|
|
141
|
-
: undefined;
|
|
142
|
-
|
|
143
130
|
const theme = useTheme();
|
|
144
131
|
const distance = React.useMemo(
|
|
145
132
|
() => MUGlobal.updateWithTheme(fabPadding, theme.spacing),
|
|
146
133
|
[fabPadding, theme.spacing]
|
|
147
134
|
);
|
|
148
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
|
+
|
|
160
|
+
React.useEffect(() => {
|
|
161
|
+
if (updateRef.current && update) {
|
|
162
|
+
update(true, []);
|
|
163
|
+
}
|
|
164
|
+
}, [update]);
|
|
165
|
+
|
|
149
166
|
// Return the UI
|
|
150
167
|
return (
|
|
151
168
|
<React.Fragment>
|