@tecsinapse/cortex-react 1.3.0-beta.26 → 1.3.0-beta.27
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/dist/cjs/components/Input/Mask.js +13 -33
- package/dist/cjs/components/Input/index.js +1 -3
- package/dist/cjs/components/Input/masks.js +43 -0
- package/dist/cjs/index.js +5 -0
- package/dist/esm/components/Input/Mask.js +13 -31
- package/dist/esm/components/Input/index.js +2 -4
- package/dist/esm/components/Input/masks.js +38 -0
- package/dist/esm/index.js +1 -0
- package/dist/types/components/Input/Mask.d.ts +2 -4
- package/dist/types/components/Input/index.d.ts +2 -3
- package/dist/types/components/Input/masks.d.ts +39 -0
- package/dist/types/components/Input/types.d.ts +11 -4
- package/package.json +2 -2
|
@@ -4,11 +4,13 @@ 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, onChangeMask) => {
|
|
8
8
|
const { ref: iMaskRef, maskRef } = reactImask.useIMask(mask, {
|
|
9
|
-
onAccept: () => {
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
onAccept: (value, mask2) => {
|
|
10
|
+
onChangeMask?.({
|
|
11
|
+
unmaskedValue: mask2._unmaskedValue,
|
|
12
|
+
value
|
|
13
|
+
});
|
|
12
14
|
},
|
|
13
15
|
ref: ref ? ref : React.createRef()
|
|
14
16
|
});
|
|
@@ -21,33 +23,11 @@ const useIMaskLocal = (mask, inputProps, ref, unmaskedRef) => {
|
|
|
21
23
|
iMaskRef
|
|
22
24
|
};
|
|
23
25
|
};
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
|
|
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: ["."]
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const { iMaskRef } = useIMaskLocal(mask, rest, ref, unmaskedRef);
|
|
48
|
-
return /* @__PURE__ */ React.createElement(index.Input.Root, { ...rest, ref: iMaskRef });
|
|
49
|
-
});
|
|
26
|
+
const InputMask = React.forwardRef(
|
|
27
|
+
({ mask, onChange, ...rest }, ref) => {
|
|
28
|
+
const { iMaskRef } = useIMaskLocal(mask, rest, ref, onChange);
|
|
29
|
+
return /* @__PURE__ */ React.createElement(index.Input.Root, { ...rest, ref: iMaskRef });
|
|
30
|
+
}
|
|
31
|
+
);
|
|
50
32
|
|
|
51
|
-
exports.
|
|
52
|
-
exports.InputMaskExpression = InputMaskExpression;
|
|
53
|
-
exports.InputMaskNumber = InputMaskNumber;
|
|
33
|
+
exports.InputMask = InputMask;
|
|
@@ -15,9 +15,7 @@ const Input = {
|
|
|
15
15
|
Left: Left.InputLeft,
|
|
16
16
|
Right: Right.InputRight,
|
|
17
17
|
Search: Search.InputSearch,
|
|
18
|
-
|
|
19
|
-
MaskNumber: Mask.InputMaskNumber,
|
|
20
|
-
MaskExpression: Mask.InputMaskExpression
|
|
18
|
+
Mask: Mask.InputMask
|
|
21
19
|
};
|
|
22
20
|
|
|
23
21
|
exports.Input = Input;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const ExpressionMasks = {
|
|
4
|
+
CPF: "000.000.000-00",
|
|
5
|
+
CNPJ: "00.000.000/0000-00",
|
|
6
|
+
PHONE: "(00) 0000-0000",
|
|
7
|
+
PHONE_EXTENDED: "(00) 00000-0000",
|
|
8
|
+
DATE: "00/00/0000",
|
|
9
|
+
CEP: "00000-000"
|
|
10
|
+
};
|
|
11
|
+
const NumberIMask = { mask: Number, scale: 2 };
|
|
12
|
+
const CurrencyIMask = {
|
|
13
|
+
mask: "R$ num",
|
|
14
|
+
blocks: {
|
|
15
|
+
num: {
|
|
16
|
+
mask: Number,
|
|
17
|
+
scale: 2,
|
|
18
|
+
thousandsSeparator: ".",
|
|
19
|
+
padFractionalZeros: true,
|
|
20
|
+
radix: ",",
|
|
21
|
+
mapToRadix: ["."]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const PercentageIMask = {
|
|
26
|
+
mask: "num %",
|
|
27
|
+
lazy: false,
|
|
28
|
+
blocks: {
|
|
29
|
+
num: {
|
|
30
|
+
mask: Number,
|
|
31
|
+
scale: 2,
|
|
32
|
+
thousandsSeparator: ".",
|
|
33
|
+
padFractionalZeros: true,
|
|
34
|
+
radix: ",",
|
|
35
|
+
mapToRadix: ["."]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
exports.CurrencyIMask = CurrencyIMask;
|
|
41
|
+
exports.ExpressionMasks = ExpressionMasks;
|
|
42
|
+
exports.NumberIMask = NumberIMask;
|
|
43
|
+
exports.PercentageIMask = PercentageIMask;
|
package/dist/cjs/index.js
CHANGED
|
@@ -48,6 +48,7 @@ var useSelectOptions = require('./hooks/useSelectOptions.js');
|
|
|
48
48
|
var SnackbarSonner = require('./service/SnackbarSonner.js');
|
|
49
49
|
var MenubarProvider = require('./provider/MenubarProvider.js');
|
|
50
50
|
var SnackbarProvider = require('./provider/SnackbarProvider.js');
|
|
51
|
+
var masks = require('./components/Input/masks.js');
|
|
51
52
|
|
|
52
53
|
|
|
53
54
|
|
|
@@ -109,3 +110,7 @@ exports.MenubarProvider = MenubarProvider.MenubarProvider;
|
|
|
109
110
|
exports.useMenubar = MenubarProvider.useMenubar;
|
|
110
111
|
exports.SnackbarProvider = SnackbarProvider.SnackbarProvider;
|
|
111
112
|
exports.useSnackbar = SnackbarProvider.useSnackbar;
|
|
113
|
+
exports.CurrencyIMask = masks.CurrencyIMask;
|
|
114
|
+
exports.ExpressionMasks = masks.ExpressionMasks;
|
|
115
|
+
exports.NumberIMask = masks.NumberIMask;
|
|
116
|
+
exports.PercentageIMask = masks.PercentageIMask;
|
|
@@ -2,11 +2,13 @@ import React__default, { 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, onChangeMask) => {
|
|
6
6
|
const { ref: iMaskRef, maskRef } = useIMask(mask, {
|
|
7
|
-
onAccept: () => {
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
onAccept: (value, mask2) => {
|
|
8
|
+
onChangeMask?.({
|
|
9
|
+
unmaskedValue: mask2._unmaskedValue,
|
|
10
|
+
value
|
|
11
|
+
});
|
|
10
12
|
},
|
|
11
13
|
ref: ref ? ref : createRef()
|
|
12
14
|
});
|
|
@@ -19,31 +21,11 @@ const useIMaskLocal = (mask, inputProps, ref, unmaskedRef) => {
|
|
|
19
21
|
iMaskRef
|
|
20
22
|
};
|
|
21
23
|
};
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const { iMaskRef } = useIMaskLocal(mask, rest, ref, unmaskedRef);
|
|
29
|
-
return /* @__PURE__ */ React__default.createElement(Input.Root, { ...rest, ref: iMaskRef });
|
|
30
|
-
});
|
|
31
|
-
const InputMaskCurrency = React__default.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: ["."]
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const { iMaskRef } = useIMaskLocal(mask, rest, ref, unmaskedRef);
|
|
46
|
-
return /* @__PURE__ */ React__default.createElement(Input.Root, { ...rest, ref: iMaskRef });
|
|
47
|
-
});
|
|
24
|
+
const InputMask = React__default.forwardRef(
|
|
25
|
+
({ mask, onChange, ...rest }, ref) => {
|
|
26
|
+
const { iMaskRef } = useIMaskLocal(mask, rest, ref, onChange);
|
|
27
|
+
return /* @__PURE__ */ React__default.createElement(Input.Root, { ...rest, ref: iMaskRef });
|
|
28
|
+
}
|
|
29
|
+
);
|
|
48
30
|
|
|
49
|
-
export {
|
|
31
|
+
export { InputMask };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InputBox } from './Box.js';
|
|
2
2
|
import { InputFace } from './Face.js';
|
|
3
3
|
import { InputLeft } from './Left.js';
|
|
4
|
-
import {
|
|
4
|
+
import { InputMask } from './Mask.js';
|
|
5
5
|
import { InputRight } from './Right.js';
|
|
6
6
|
import { InputRoot } from './Root.js';
|
|
7
7
|
import { InputSearch } from './Search.js';
|
|
@@ -13,9 +13,7 @@ const Input = {
|
|
|
13
13
|
Left: InputLeft,
|
|
14
14
|
Right: InputRight,
|
|
15
15
|
Search: InputSearch,
|
|
16
|
-
|
|
17
|
-
MaskNumber: InputMaskNumber,
|
|
18
|
-
MaskExpression: InputMaskExpression
|
|
16
|
+
Mask: InputMask
|
|
19
17
|
};
|
|
20
18
|
|
|
21
19
|
export { Input };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const ExpressionMasks = {
|
|
2
|
+
CPF: "000.000.000-00",
|
|
3
|
+
CNPJ: "00.000.000/0000-00",
|
|
4
|
+
PHONE: "(00) 0000-0000",
|
|
5
|
+
PHONE_EXTENDED: "(00) 00000-0000",
|
|
6
|
+
DATE: "00/00/0000",
|
|
7
|
+
CEP: "00000-000"
|
|
8
|
+
};
|
|
9
|
+
const NumberIMask = { mask: Number, scale: 2 };
|
|
10
|
+
const CurrencyIMask = {
|
|
11
|
+
mask: "R$ num",
|
|
12
|
+
blocks: {
|
|
13
|
+
num: {
|
|
14
|
+
mask: Number,
|
|
15
|
+
scale: 2,
|
|
16
|
+
thousandsSeparator: ".",
|
|
17
|
+
padFractionalZeros: true,
|
|
18
|
+
radix: ",",
|
|
19
|
+
mapToRadix: ["."]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const PercentageIMask = {
|
|
24
|
+
mask: "num %",
|
|
25
|
+
lazy: false,
|
|
26
|
+
blocks: {
|
|
27
|
+
num: {
|
|
28
|
+
mask: Number,
|
|
29
|
+
scale: 2,
|
|
30
|
+
thousandsSeparator: ".",
|
|
31
|
+
padFractionalZeros: true,
|
|
32
|
+
radix: ",",
|
|
33
|
+
mapToRadix: ["."]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { CurrencyIMask, ExpressionMasks, NumberIMask, PercentageIMask };
|
package/dist/esm/index.js
CHANGED
|
@@ -46,3 +46,4 @@ export { useSelectOptions } from './hooks/useSelectOptions.js';
|
|
|
46
46
|
export { SnackbarSonner } from './service/SnackbarSonner.js';
|
|
47
47
|
export { MenubarProvider, useMenubar } from './provider/MenubarProvider.js';
|
|
48
48
|
export { SnackbarProvider, useSnackbar } from './provider/SnackbarProvider.js';
|
|
49
|
+
export { CurrencyIMask, ExpressionMasks, NumberIMask, PercentageIMask } from './components/Input/masks.js';
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const InputMaskNumber: React.ForwardRefExoticComponent<InputMaskProps & React.RefAttributes<HTMLInputElement>>;
|
|
5
|
-
export declare const InputMaskCurrency: React.ForwardRefExoticComponent<InputMaskProps & React.RefAttributes<HTMLInputElement>>;
|
|
2
|
+
import { InputMaskProps } from './types';
|
|
3
|
+
export declare const InputMask: React.ForwardRefExoticComponent<InputMaskProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -5,8 +5,7 @@ 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
|
-
|
|
9
|
-
MaskNumber: import("react").ForwardRefExoticComponent<import("./types").InputMaskProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
10
|
-
MaskExpression: import("react").ForwardRefExoticComponent<import("./types").InputMaskExpressionProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
8
|
+
Mask: import("react").ForwardRefExoticComponent<import("./types").InputMaskProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
11
9
|
};
|
|
10
|
+
export * from './masks';
|
|
12
11
|
export * from './types';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare const ExpressionMasks: {
|
|
2
|
+
CPF: string;
|
|
3
|
+
CNPJ: string;
|
|
4
|
+
PHONE: string;
|
|
5
|
+
PHONE_EXTENDED: string;
|
|
6
|
+
DATE: string;
|
|
7
|
+
CEP: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const NumberIMask: {
|
|
10
|
+
mask: NumberConstructor;
|
|
11
|
+
scale: number;
|
|
12
|
+
};
|
|
13
|
+
export declare const CurrencyIMask: {
|
|
14
|
+
mask: string;
|
|
15
|
+
blocks: {
|
|
16
|
+
num: {
|
|
17
|
+
mask: NumberConstructor;
|
|
18
|
+
scale: number;
|
|
19
|
+
thousandsSeparator: string;
|
|
20
|
+
padFractionalZeros: boolean;
|
|
21
|
+
radix: string;
|
|
22
|
+
mapToRadix: string[];
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export declare const PercentageIMask: {
|
|
27
|
+
mask: string;
|
|
28
|
+
lazy: boolean;
|
|
29
|
+
blocks: {
|
|
30
|
+
num: {
|
|
31
|
+
mask: NumberConstructor;
|
|
32
|
+
scale: number;
|
|
33
|
+
thousandsSeparator: string;
|
|
34
|
+
padFractionalZeros: boolean;
|
|
35
|
+
radix: string;
|
|
36
|
+
mapToRadix: string[];
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { InputBaseVariants } from '@tecsinapse/cortex-core';
|
|
2
|
-
import { MutableRefObject } from 'react';
|
|
3
2
|
export interface InputPropsBase {
|
|
4
3
|
variants?: InputBaseVariants;
|
|
5
4
|
label?: string;
|
|
@@ -19,9 +18,17 @@ export interface InputRightProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
19
18
|
export interface InputSearchProps extends InputProps {
|
|
20
19
|
bounceTimeout?: number;
|
|
21
20
|
}
|
|
22
|
-
export
|
|
23
|
-
|
|
21
|
+
export type InputMaskEvent = {
|
|
22
|
+
value: string;
|
|
23
|
+
unmaskedValue: string;
|
|
24
|
+
};
|
|
25
|
+
export interface Mask extends Record<string, any> {
|
|
26
|
+
mask: any;
|
|
27
|
+
}
|
|
28
|
+
export interface InputMaskProps extends Omit<InputProps, 'onChange'> {
|
|
29
|
+
onChange?: (e: InputMaskEvent) => void;
|
|
30
|
+
mask: Mask;
|
|
24
31
|
}
|
|
25
32
|
export interface InputMaskExpressionProps extends InputMaskProps {
|
|
26
|
-
mask:
|
|
33
|
+
mask: Mask;
|
|
27
34
|
}
|
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.27",
|
|
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": "43a88a5a80a54451f5e2621363f7164927e5ef47"
|
|
47
47
|
}
|