@etsoo/react 1.2.58 → 1.2.59

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.
@@ -9,11 +9,13 @@ import { useIMask } from 'react-imask';
9
9
  * @returns Component
10
10
  */
11
11
  export function MaskInput(props) {
12
+ var _a;
12
13
  // Destruct
13
- const { mask, InputLabelProps = {}, InputProps = {}, readOnly, search = false, size = search ? MUGlobal.searchFieldSize : MUGlobal.inputFieldSize, variant = search
14
+ const { defaultValue, mask, InputLabelProps = {}, InputProps = {}, readOnly, search = false, size = search ? MUGlobal.searchFieldSize : MUGlobal.inputFieldSize, value, variant = search
14
15
  ? MUGlobal.searchFieldVariant
15
16
  : MUGlobal.inputFieldVariant, ...rest } = props;
16
- const { ref } = useIMask(mask);
17
+ const { ref, maskRef } = useIMask(mask);
18
+ const localValue = (_a = defaultValue !== null && defaultValue !== void 0 ? defaultValue : value) !== null && _a !== void 0 ? _a : '';
17
19
  // Shrink
18
20
  InputLabelProps.shrink = search
19
21
  ? MUGlobal.searchFieldShrink
@@ -22,6 +24,9 @@ export function MaskInput(props) {
22
24
  if (readOnly != null)
23
25
  InputProps.readOnly = readOnly;
24
26
  InputProps.inputRef = ref;
27
+ React.useEffect(() => {
28
+ maskRef.current.value = String(localValue);
29
+ }, [localValue]);
25
30
  // Layout
26
31
  return (React.createElement(TextField, { InputLabelProps: InputLabelProps, InputProps: InputProps, size: size, variant: variant, ...rest }));
27
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.2.58",
3
+ "version": "1.2.59",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -50,9 +50,9 @@
50
50
  "@emotion/react": "^11.5.0",
51
51
  "@emotion/style": "^0.8.0",
52
52
  "@emotion/styled": "^11.3.0",
53
- "@etsoo/appscript": "^1.1.17",
53
+ "@etsoo/appscript": "^1.1.18",
54
54
  "@etsoo/notificationbase": "^1.0.88",
55
- "@etsoo/shared": "^1.0.55",
55
+ "@etsoo/shared": "^1.0.56",
56
56
  "@mui/icons-material": "^5.0.4",
57
57
  "@mui/material": "^5.0.4",
58
58
  "@reach/router": "^1.3.4",
@@ -32,19 +32,22 @@ export type MaskInputProps = TextFieldProps & {
32
32
  export function MaskInput(props: MaskInputProps) {
33
33
  // Destruct
34
34
  const {
35
+ defaultValue,
35
36
  mask,
36
37
  InputLabelProps = {},
37
38
  InputProps = {},
38
39
  readOnly,
39
40
  search = false,
40
41
  size = search ? MUGlobal.searchFieldSize : MUGlobal.inputFieldSize,
42
+ value,
41
43
  variant = search
42
44
  ? MUGlobal.searchFieldVariant
43
45
  : MUGlobal.inputFieldVariant,
44
46
  ...rest
45
47
  } = props;
46
48
 
47
- const { ref } = useIMask(mask);
49
+ const { ref, maskRef } = useIMask(mask);
50
+ const localValue = defaultValue ?? value ?? '';
48
51
 
49
52
  // Shrink
50
53
  InputLabelProps.shrink = search
@@ -55,6 +58,10 @@ export function MaskInput(props: MaskInputProps) {
55
58
  if (readOnly != null) InputProps.readOnly = readOnly;
56
59
  InputProps.inputRef = ref;
57
60
 
61
+ React.useEffect(() => {
62
+ maskRef.current.value = String(localValue);
63
+ }, [localValue]);
64
+
58
65
  // Layout
59
66
  return (
60
67
  <TextField