linear-react-components-ui 1.1.25-beta.5 → 1.1.25-beta.7
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/{Cnpj-bde01dd0.d.ts → Cnpj-53bfd6ab.d.ts} +1 -0
- package/lib/{Cpf-3fa496ad.d.ts → Cpf-019b21e0.d.ts} +1 -0
- package/lib/inputs2/index.d.ts +2 -2
- package/lib/inputs2/mask/Cnpj.d.ts +1 -1
- package/lib/inputs2/mask/Cnpj.js +21 -18
- package/lib/inputs2/mask/Cpf.d.ts +1 -1
- package/lib/inputs2/mask/Cpf.js +19 -12
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import React__default from 'react';
|
|
|
2
2
|
import { M as MaskFieldProps } from './BaseMask-0c14ef51.js';
|
|
3
3
|
|
|
4
4
|
interface CnpjFieldProps extends MaskFieldProps {
|
|
5
|
+
enableValidation?: boolean;
|
|
5
6
|
onValidate?: (errors: string[]) => void;
|
|
6
7
|
}
|
|
7
8
|
declare const Input: React__default.ForwardRefExoticComponent<CnpjFieldProps & React__default.RefAttributes<HTMLInputElement>>;
|
|
@@ -2,6 +2,7 @@ import React__default from 'react';
|
|
|
2
2
|
import { M as MaskFieldProps } from './BaseMask-0c14ef51.js';
|
|
3
3
|
|
|
4
4
|
interface CpfFieldProps extends MaskFieldProps {
|
|
5
|
+
enableValidation?: boolean;
|
|
5
6
|
onValidate?: (errors: string[]) => void;
|
|
6
7
|
}
|
|
7
8
|
declare const Input: React__default.ForwardRefExoticComponent<CpfFieldProps & React__default.RefAttributes<HTMLInputElement>>;
|
package/lib/inputs2/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export { i as RadioField } from '../index-afb7b5a9.js';
|
|
|
6
6
|
export { i as SelectField } from '../index-19761a50.js';
|
|
7
7
|
export { i as ColorField } from '../index-9e576346.js';
|
|
8
8
|
export { B as MaskField } from '../BaseMask-0c14ef51.js';
|
|
9
|
-
export { C as CpfField } from '../Cpf-
|
|
10
|
-
export { C as CnpjField } from '../Cnpj-
|
|
9
|
+
export { C as CpfField } from '../Cpf-019b21e0.js';
|
|
10
|
+
export { C as CnpjField } from '../Cnpj-53bfd6ab.js';
|
|
11
11
|
export { P as PhoneField } from '../Phone-2bb0b397.js';
|
|
12
12
|
export { Z as ZipCodeField } from '../ZipCode-09460e18.js';
|
|
13
13
|
export { i as CheckboxField } from '../index-4bda404f.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'react';
|
|
2
2
|
import '../../BaseMask-0c14ef51.js';
|
|
3
|
-
export { a as CnpjFieldProps, I as Input } from '../../Cnpj-
|
|
3
|
+
export { a as CnpjFieldProps, I as Input } from '../../Cnpj-53bfd6ab.js';
|
|
4
4
|
import '../../index-3b70931d.js';
|
|
5
5
|
import '../../@types/Align.js';
|
|
6
6
|
import '../../@types/ColorStyles.js';
|
package/lib/inputs2/mask/Cnpj.js
CHANGED
|
@@ -5,10 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Input = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _helpers = require("
|
|
9
|
-
var _helpers2 = require("./helpers");
|
|
8
|
+
var _helpers = require("./helpers");
|
|
10
9
|
var _BaseMask = require("./BaseMask");
|
|
11
|
-
const _excluded = ["
|
|
10
|
+
const _excluded = ["onValidate", "onBlur", "onChange", "enableValidation", "errors"];
|
|
12
11
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
12
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
14
13
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
@@ -16,33 +15,37 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
|
|
|
16
15
|
const CNPJ_INVALID_MESSAGE = 'CNPJ inválido';
|
|
17
16
|
const Input = exports.Input = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
18
17
|
const {
|
|
19
|
-
name,
|
|
20
18
|
onValidate,
|
|
21
|
-
onChange,
|
|
22
19
|
onBlur,
|
|
20
|
+
onChange,
|
|
21
|
+
enableValidation = true,
|
|
23
22
|
errors: externalErrors = []
|
|
24
23
|
} = props,
|
|
25
24
|
rest = _objectWithoutProperties(props, _excluded);
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
const [erroValidacao, setErroValidacao] = (0, _react.useState)(null);
|
|
26
|
+
const validarCnpj = raw => {
|
|
27
|
+
const isValid = (0, _helpers.CNPJValidation)(raw);
|
|
28
|
+
switch (isValid) {
|
|
29
|
+
case true:
|
|
30
|
+
onValidate === null || onValidate === void 0 ? void 0 : onValidate([]);
|
|
31
|
+
setErroValidacao(null);
|
|
32
|
+
break;
|
|
33
|
+
case false:
|
|
34
|
+
onValidate === null || onValidate === void 0 ? void 0 : onValidate([CNPJ_INVALID_MESSAGE]);
|
|
35
|
+
setErroValidacao([CNPJ_INVALID_MESSAGE]);
|
|
36
|
+
break;
|
|
35
37
|
}
|
|
36
38
|
};
|
|
37
39
|
const handleChange = e => {
|
|
38
40
|
const rawValue = e.target.value.replace(/\D/g, '');
|
|
39
|
-
|
|
41
|
+
if (enableValidation) {
|
|
42
|
+
validarCnpj(rawValue);
|
|
43
|
+
}
|
|
40
44
|
onChange === null || onChange === void 0 ? void 0 : onChange(e);
|
|
41
45
|
};
|
|
42
46
|
return /*#__PURE__*/_react.default.createElement(_BaseMask.Input, _extends({}, rest, {
|
|
47
|
+
ref: ref,
|
|
43
48
|
type: "text",
|
|
44
|
-
name: name,
|
|
45
|
-
errors: externalErrors,
|
|
46
49
|
maskOptions: {
|
|
47
50
|
mask: '00.000.000/0000-00',
|
|
48
51
|
placeholderChar: '_',
|
|
@@ -50,7 +53,7 @@ const Input = exports.Input = /*#__PURE__*/(0, _react.forwardRef)((props, ref) =
|
|
|
50
53
|
},
|
|
51
54
|
onBlur: onBlur,
|
|
52
55
|
onChange: handleChange,
|
|
53
|
-
|
|
56
|
+
errors: erroValidacao || externalErrors
|
|
54
57
|
}));
|
|
55
58
|
});
|
|
56
59
|
Input.displayName = 'CnpjInputField';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'react';
|
|
2
2
|
import '../../BaseMask-0c14ef51.js';
|
|
3
|
-
export { a as CpfFieldProps, I as Input } from '../../Cpf-
|
|
3
|
+
export { a as CpfFieldProps, I as Input } from '../../Cpf-019b21e0.js';
|
|
4
4
|
import '../../index-3b70931d.js';
|
|
5
5
|
import '../../@types/Align.js';
|
|
6
6
|
import '../../@types/ColorStyles.js';
|
package/lib/inputs2/mask/Cpf.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.Input = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _helpers = require("./helpers");
|
|
9
9
|
var _BaseMask = require("./BaseMask");
|
|
10
|
-
const _excluded = ["onValidate", "onBlur", "onChange", "errors"];
|
|
10
|
+
const _excluded = ["onValidate", "onBlur", "onChange", "enableValidation", "errors"];
|
|
11
11
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
12
12
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
13
13
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
@@ -18,35 +18,42 @@ const Input = exports.Input = /*#__PURE__*/(0, _react.forwardRef)((props, ref) =
|
|
|
18
18
|
onValidate,
|
|
19
19
|
onBlur,
|
|
20
20
|
onChange,
|
|
21
|
+
enableValidation = true,
|
|
21
22
|
errors: externalErrors = []
|
|
22
23
|
} = props,
|
|
23
24
|
rest = _objectWithoutProperties(props, _excluded);
|
|
24
|
-
const
|
|
25
|
-
|
|
25
|
+
const [erroValidacao, setErroValidacao] = (0, _react.useState)(null);
|
|
26
|
+
const validarCpf = raw => {
|
|
26
27
|
const isValid = (0, _helpers.CPFValidation)(raw);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
switch (isValid) {
|
|
29
|
+
case true:
|
|
30
|
+
onValidate === null || onValidate === void 0 ? void 0 : onValidate([]);
|
|
31
|
+
setErroValidacao(null);
|
|
32
|
+
break;
|
|
33
|
+
case false:
|
|
34
|
+
onValidate === null || onValidate === void 0 ? void 0 : onValidate([CPF_INVALID_MESSAGE]);
|
|
35
|
+
setErroValidacao([CPF_INVALID_MESSAGE]);
|
|
36
|
+
break;
|
|
32
37
|
}
|
|
33
38
|
};
|
|
34
39
|
const handleChange = e => {
|
|
35
40
|
const rawValue = e.target.value.replace(/\D/g, '');
|
|
36
|
-
|
|
41
|
+
if (enableValidation) {
|
|
42
|
+
validarCpf(rawValue);
|
|
43
|
+
}
|
|
37
44
|
onChange === null || onChange === void 0 ? void 0 : onChange(e);
|
|
38
45
|
};
|
|
39
46
|
return /*#__PURE__*/_react.default.createElement(_BaseMask.Input, _extends({}, rest, {
|
|
40
|
-
type: "text",
|
|
41
47
|
ref: ref,
|
|
48
|
+
type: "text",
|
|
42
49
|
maskOptions: {
|
|
43
50
|
mask: '000.000.000-00',
|
|
44
51
|
placeholderChar: '_',
|
|
45
52
|
lazy: false
|
|
46
53
|
},
|
|
54
|
+
onBlur: onBlur,
|
|
47
55
|
onChange: handleChange,
|
|
48
|
-
errors: externalErrors
|
|
49
|
-
onBlur: onBlur
|
|
56
|
+
errors: erroValidacao || externalErrors
|
|
50
57
|
}));
|
|
51
58
|
});
|
|
52
59
|
Input.displayName = 'CpfInputField';
|