@etsoo/materialui 1.4.69 → 1.4.70

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.
@@ -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 ReactIMaskProps = Parameters<ReactIMask>;
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"];
@@ -16,15 +16,13 @@ const MUGlobal_1 = require("./MUGlobal");
16
16
  */
17
17
  function MaskInput(props) {
18
18
  // Destruct
19
- const { defaultValue, mask, InputLabelProps = {}, InputProps = {}, 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;
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
- if (useIMask == null)
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.current == null || localValue == null)
37
+ if (maskRef?.current == null || localValue == null)
48
38
  return;
49
39
  maskRef.current.value = String(localValue);
50
40
  maskRef.current.updateValue();
51
- }, [maskRef.current, localValue]);
41
+ }, [maskRef?.current, localValue]);
52
42
  // Layout
53
- return ((0, jsx_runtime_1.jsx)(material_1.TextField, { InputLabelProps: InputLabelProps, InputProps: InputProps, size: size, variant: variant, ...rest }));
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
  }
@@ -31,21 +31,31 @@ function CommonPage(props) {
31
31
  // Labels
32
32
  const labels = Labels_1.Labels.CommonPage;
33
33
  // Update
34
+ const updateRef = react_1.default.useRef(false);
34
35
  const update = onUpdateAll
35
36
  ? onUpdateAll
36
37
  : onUpdate
37
- ? (authorized) => {
38
- if (authorized == null || authorized)
39
- onUpdate();
38
+ ? async (authorized) => {
39
+ if (authorized == null || authorized) {
40
+ await onUpdate();
41
+ updateRef.current = true;
42
+ }
40
43
  }
41
44
  : onRefresh
42
- ? (authorized) => {
43
- if (authorized)
44
- onRefresh();
45
+ ? async (authorized) => {
46
+ if (authorized) {
47
+ await onRefresh();
48
+ updateRef.current = true;
49
+ }
45
50
  }
46
51
  : undefined;
47
52
  const theme = (0, material_1.useTheme)();
48
53
  const distance = react_1.default.useMemo(() => MUGlobal_1.MUGlobal.updateWithTheme(fabPadding, theme.spacing), [fabPadding, theme.spacing]);
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,
@@ -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 ReactIMaskProps = Parameters<ReactIMask>;
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"];
@@ -10,15 +10,13 @@ import { MUGlobal } from "./MUGlobal";
10
10
  */
11
11
  export function MaskInput(props) {
12
12
  // Destruct
13
- const { defaultValue, mask, InputLabelProps = {}, InputProps = {}, onAccept, onComplete, readOnly, search = false, size = search ? MUGlobal.searchFieldSize : MUGlobal.inputFieldSize, value, variant = search ? MUGlobal.searchFieldVariant : MUGlobal.inputFieldVariant, ...rest } = props;
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
- if (useIMask == null)
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.current == null || localValue == null)
31
+ if (maskRef?.current == null || localValue == null)
42
32
  return;
43
33
  maskRef.current.value = String(localValue);
44
34
  maskRef.current.updateValue();
45
- }, [maskRef.current, localValue]);
35
+ }, [maskRef?.current, localValue]);
46
36
  // Layout
47
- return (_jsx(TextField, { InputLabelProps: InputLabelProps, InputProps: InputProps, size: size, variant: variant, ...rest }));
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
  }
@@ -25,21 +25,31 @@ export function CommonPage(props) {
25
25
  // Labels
26
26
  const labels = Labels.CommonPage;
27
27
  // Update
28
+ const updateRef = React.useRef(false);
28
29
  const update = onUpdateAll
29
30
  ? onUpdateAll
30
31
  : onUpdate
31
- ? (authorized) => {
32
- if (authorized == null || authorized)
33
- onUpdate();
32
+ ? async (authorized) => {
33
+ if (authorized == null || authorized) {
34
+ await onUpdate();
35
+ updateRef.current = true;
36
+ }
34
37
  }
35
38
  : onRefresh
36
- ? (authorized) => {
37
- if (authorized)
38
- onRefresh();
39
+ ? async (authorized) => {
40
+ if (authorized) {
41
+ await onRefresh();
42
+ updateRef.current = true;
43
+ }
39
44
  }
40
45
  : undefined;
41
46
  const theme = useTheme();
42
47
  const distance = React.useMemo(() => MUGlobal.updateWithTheme(fabPadding, theme.spacing), [fabPadding, theme.spacing]);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.4.69",
3
+ "version": "1.4.70",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
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 ReactIMaskProps = Parameters<ReactIMask>;
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
- if(useIMask == null) return;
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
- // Shrink
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.current == null || localValue == null) return;
82
+ if (maskRef?.current == null || localValue == null) return;
96
83
  maskRef.current.value = String(localValue);
97
84
  maskRef.current.updateValue();
98
- }, [maskRef.current, localValue]);
85
+ }, [maskRef?.current, localValue]);
99
86
 
100
87
  // Layout
101
- return (
88
+ return ref == null ? undefined: (
102
89
  <TextField
103
- InputLabelProps={InputLabelProps}
104
- InputProps={InputProps}
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
  );
@@ -128,15 +128,22 @@ export function CommonPage(props: CommonPageProps) {
128
128
  const labels = Labels.CommonPage;
129
129
 
130
130
  // Update
131
+ const updateRef = React.useRef(false);
131
132
  const update = onUpdateAll
132
133
  ? onUpdateAll
133
134
  : onUpdate
134
- ? (authorized?: boolean) => {
135
- if (authorized == null || authorized) onUpdate();
135
+ ? async (authorized?: boolean) => {
136
+ if (authorized == null || authorized) {
137
+ await onUpdate();
138
+ updateRef.current = true;
139
+ }
136
140
  }
137
141
  : onRefresh
138
- ? (authorized?: boolean) => {
139
- if (authorized) onRefresh();
142
+ ? async (authorized?: boolean) => {
143
+ if (authorized) {
144
+ await onRefresh();
145
+ updateRef.current = true;
146
+ }
140
147
  }
141
148
  : undefined;
142
149
 
@@ -146,6 +153,12 @@ export function CommonPage(props: CommonPageProps) {
146
153
  [fabPadding, theme.spacing]
147
154
  );
148
155
 
156
+ React.useEffect(() => {
157
+ if (updateRef.current && update) {
158
+ update(true, []);
159
+ }
160
+ }, [update]);
161
+
149
162
  // Return the UI
150
163
  return (
151
164
  <React.Fragment>