@tecsinapse/cortex-react 1.3.0-beta.18 → 1.3.0-beta.19
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.
|
@@ -4,9 +4,12 @@ var React = require('react');
|
|
|
4
4
|
var reactImask = require('react-imask');
|
|
5
5
|
var index = require('./index.js');
|
|
6
6
|
|
|
7
|
-
const useIMaskLocal = (mask, inputProps, ref) => {
|
|
7
|
+
const useIMaskLocal = (mask, inputProps, ref, unmaskedRef) => {
|
|
8
8
|
const { ref: iMaskRef, maskRef } = reactImask.useIMask(mask, {
|
|
9
|
-
onAccept: () =>
|
|
9
|
+
onAccept: () => {
|
|
10
|
+
if (unmaskedRef) unmaskedRef.current = maskRef.current.unmaskedValue;
|
|
11
|
+
return inputProps.onChange?.(maskRef.current);
|
|
12
|
+
},
|
|
10
13
|
ref: ref ? ref : React.createRef()
|
|
11
14
|
});
|
|
12
15
|
React.useEffect(() => {
|
|
@@ -18,36 +21,32 @@ const useIMaskLocal = (mask, inputProps, ref) => {
|
|
|
18
21
|
iMaskRef
|
|
19
22
|
};
|
|
20
23
|
};
|
|
21
|
-
const InputMaskExpression = React.forwardRef(({ mask, ...rest }, ref) => {
|
|
22
|
-
const { iMaskRef } = useIMaskLocal({ mask }, rest, ref);
|
|
24
|
+
const InputMaskExpression = React.forwardRef(({ mask, unmaskedRef, ...rest }, ref) => {
|
|
25
|
+
const { iMaskRef } = useIMaskLocal({ mask }, rest, ref, unmaskedRef);
|
|
23
26
|
return /* @__PURE__ */ React.createElement(index.Input.Root, { ...rest, ref: iMaskRef });
|
|
24
27
|
});
|
|
25
|
-
const InputMaskNumber = React.forwardRef(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
padFractionalZeros: true,
|
|
42
|
-
radix: ",",
|
|
43
|
-
mapToRadix: ["."]
|
|
44
|
-
}
|
|
28
|
+
const InputMaskNumber = React.forwardRef(({ unmaskedRef, ...rest }, ref) => {
|
|
29
|
+
const mask = { mask: Number, scale: 2 };
|
|
30
|
+
const { iMaskRef } = useIMaskLocal(mask, rest, ref, unmaskedRef);
|
|
31
|
+
return /* @__PURE__ */ React.createElement(index.Input.Root, { ...rest, ref: iMaskRef });
|
|
32
|
+
});
|
|
33
|
+
const InputMaskCurrency = React.forwardRef(({ unmaskedRef, ...rest }, ref) => {
|
|
34
|
+
const mask = {
|
|
35
|
+
mask: "R$ num",
|
|
36
|
+
blocks: {
|
|
37
|
+
num: {
|
|
38
|
+
mask: Number,
|
|
39
|
+
scale: 2,
|
|
40
|
+
thousandsSeparator: ".",
|
|
41
|
+
padFractionalZeros: true,
|
|
42
|
+
radix: ",",
|
|
43
|
+
mapToRadix: ["."]
|
|
45
44
|
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const { iMaskRef } = useIMaskLocal(mask, rest, ref, unmaskedRef);
|
|
48
|
+
return /* @__PURE__ */ React.createElement(index.Input.Root, { ...rest, ref: iMaskRef });
|
|
49
|
+
});
|
|
51
50
|
|
|
52
51
|
exports.InputMaskCurrency = InputMaskCurrency;
|
|
53
52
|
exports.InputMaskExpression = InputMaskExpression;
|
|
@@ -2,9 +2,12 @@ import React, { createRef, useEffect } from 'react';
|
|
|
2
2
|
import { useIMask } from 'react-imask';
|
|
3
3
|
import { Input } from './index.js';
|
|
4
4
|
|
|
5
|
-
const useIMaskLocal = (mask, inputProps, ref) => {
|
|
5
|
+
const useIMaskLocal = (mask, inputProps, ref, unmaskedRef) => {
|
|
6
6
|
const { ref: iMaskRef, maskRef } = useIMask(mask, {
|
|
7
|
-
onAccept: () =>
|
|
7
|
+
onAccept: () => {
|
|
8
|
+
if (unmaskedRef) unmaskedRef.current = maskRef.current.unmaskedValue;
|
|
9
|
+
return inputProps.onChange?.(maskRef.current);
|
|
10
|
+
},
|
|
8
11
|
ref: ref ? ref : createRef()
|
|
9
12
|
});
|
|
10
13
|
useEffect(() => {
|
|
@@ -16,35 +19,31 @@ const useIMaskLocal = (mask, inputProps, ref) => {
|
|
|
16
19
|
iMaskRef
|
|
17
20
|
};
|
|
18
21
|
};
|
|
19
|
-
const InputMaskExpression = React.forwardRef(({ mask, ...rest }, ref) => {
|
|
20
|
-
const { iMaskRef } = useIMaskLocal({ mask }, rest, ref);
|
|
22
|
+
const InputMaskExpression = React.forwardRef(({ mask, unmaskedRef, ...rest }, ref) => {
|
|
23
|
+
const { iMaskRef } = useIMaskLocal({ mask }, rest, ref, unmaskedRef);
|
|
21
24
|
return /* @__PURE__ */ React.createElement(Input.Root, { ...rest, ref: iMaskRef });
|
|
22
25
|
});
|
|
23
|
-
const InputMaskNumber = React.forwardRef(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
padFractionalZeros: true,
|
|
40
|
-
radix: ",",
|
|
41
|
-
mapToRadix: ["."]
|
|
42
|
-
}
|
|
26
|
+
const InputMaskNumber = React.forwardRef(({ unmaskedRef, ...rest }, ref) => {
|
|
27
|
+
const mask = { mask: Number, scale: 2 };
|
|
28
|
+
const { iMaskRef } = useIMaskLocal(mask, rest, ref, unmaskedRef);
|
|
29
|
+
return /* @__PURE__ */ React.createElement(Input.Root, { ...rest, ref: iMaskRef });
|
|
30
|
+
});
|
|
31
|
+
const InputMaskCurrency = React.forwardRef(({ unmaskedRef, ...rest }, ref) => {
|
|
32
|
+
const mask = {
|
|
33
|
+
mask: "R$ num",
|
|
34
|
+
blocks: {
|
|
35
|
+
num: {
|
|
36
|
+
mask: Number,
|
|
37
|
+
scale: 2,
|
|
38
|
+
thousandsSeparator: ".",
|
|
39
|
+
padFractionalZeros: true,
|
|
40
|
+
radix: ",",
|
|
41
|
+
mapToRadix: ["."]
|
|
43
42
|
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const { iMaskRef } = useIMaskLocal(mask, rest, ref, unmaskedRef);
|
|
46
|
+
return /* @__PURE__ */ React.createElement(Input.Root, { ...rest, ref: iMaskRef });
|
|
47
|
+
});
|
|
49
48
|
|
|
50
49
|
export { InputMaskCurrency, InputMaskExpression, InputMaskNumber };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export declare const InputMaskExpression: React.ForwardRefExoticComponent<
|
|
4
|
-
export declare const InputMaskNumber: React.ForwardRefExoticComponent<
|
|
5
|
-
export declare const InputMaskCurrency: React.ForwardRefExoticComponent<
|
|
2
|
+
import { InputMaskExpressionProps, InputMaskProps } from './types';
|
|
3
|
+
export declare const InputMaskExpression: React.ForwardRefExoticComponent<InputMaskExpressionProps & React.RefAttributes<HTMLInputElement>>;
|
|
4
|
+
export declare const InputMaskNumber: React.ForwardRefExoticComponent<InputMaskProps & React.RefAttributes<HTMLInputElement>>;
|
|
5
|
+
export declare const InputMaskCurrency: React.ForwardRefExoticComponent<InputMaskProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -5,8 +5,8 @@ export declare const Input: {
|
|
|
5
5
|
Left: import("react").ForwardRefExoticComponent<import("./types").InputLeftProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
6
6
|
Right: import("react").ForwardRefExoticComponent<import("./types").InputRightProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
7
7
|
Search: import("react").ForwardRefExoticComponent<import("./types").InputSearchProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
8
|
-
MaskCurrency: import("react").ForwardRefExoticComponent<import("./types").
|
|
9
|
-
MaskNumber: import("react").ForwardRefExoticComponent<import("./types").
|
|
10
|
-
MaskExpression: import("react").ForwardRefExoticComponent<import("./types").
|
|
8
|
+
MaskCurrency: import("react").ForwardRefExoticComponent<import("./types").InputMaskProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
9
|
+
MaskNumber: import("react").ForwardRefExoticComponent<import("./types").InputMaskProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
10
|
+
MaskExpression: import("react").ForwardRefExoticComponent<import("./types").InputMaskExpressionProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
11
11
|
};
|
|
12
12
|
export * from './types';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { InputBaseVariants } from '@tecsinapse/cortex-core';
|
|
2
|
+
import { MutableRefObject } from 'react';
|
|
2
3
|
export interface InputPropsBase {
|
|
3
4
|
variants?: InputBaseVariants;
|
|
4
5
|
label?: string;
|
|
@@ -19,5 +20,8 @@ export interface InputSearchProps extends InputProps {
|
|
|
19
20
|
bounceTimeout?: number;
|
|
20
21
|
}
|
|
21
22
|
export interface InputMaskProps extends InputProps {
|
|
23
|
+
unmaskedRef?: MutableRefObject<string>;
|
|
24
|
+
}
|
|
25
|
+
export interface InputMaskExpressionProps extends InputMaskProps {
|
|
22
26
|
mask: any;
|
|
23
27
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/cortex-react",
|
|
3
|
-
"version": "1.3.0-beta.
|
|
3
|
+
"version": "1.3.0-beta.19",
|
|
4
4
|
"description": "React components based in @tecsinapse/cortex-core",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"react-dom": ">=18.0.0",
|
|
44
44
|
"tailwind": ">=3.3.0"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "146c1df23292decd716af07e65e31deb03f1427d"
|
|
47
47
|
}
|