linear-react-components-ui 1.1.12 → 1.1.13
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.
|
@@ -7,6 +7,6 @@ import '../../@types/Period.js';
|
|
|
7
7
|
import '../../internals/types.js';
|
|
8
8
|
import '../../@types/Position.js';
|
|
9
9
|
|
|
10
|
-
declare const BaseMask: ({ value: valueProp, defaultValue, inputRef, onChange, onComplete, permissionAttr,
|
|
10
|
+
declare const BaseMask: ({ value: valueProp, defaultValue, inputRef, onChange, onComplete, permissionAttr, mask, ...rest }: IBaseMaskProps) => JSX.Element;
|
|
11
11
|
|
|
12
12
|
export { BaseMask as default };
|
|
@@ -10,7 +10,7 @@ var _format_number = require("../number/format_number");
|
|
|
10
10
|
var _reactImask = require("react-imask");
|
|
11
11
|
var _permissionValidations = require("../../permissionValidations");
|
|
12
12
|
var _helpers = require("./helpers");
|
|
13
|
-
const _excluded = ["value", "defaultValue", "inputRef", "onChange", "onComplete", "permissionAttr", "
|
|
13
|
+
const _excluded = ["value", "defaultValue", "inputRef", "onChange", "onComplete", "permissionAttr", "mask"];
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -68,9 +68,9 @@ const getEventProps = (props, setValue, maskRef) => {
|
|
|
68
68
|
} = e.target;
|
|
69
69
|
const formatedValue = (0, _format_number.formatOnlyNumbers)(value);
|
|
70
70
|
const eventWithFormatedValue = _objectSpread(_objectSpread({}, e), {}, {
|
|
71
|
-
target: {
|
|
71
|
+
target: _objectSpread(_objectSpread({}, e.target), {}, {
|
|
72
72
|
value: formatedValue
|
|
73
|
-
}
|
|
73
|
+
})
|
|
74
74
|
});
|
|
75
75
|
const formattedEvent = returnEventFormattedValue(props, eventWithFormatedValue);
|
|
76
76
|
props.onBlur(formattedEvent);
|
|
@@ -102,7 +102,7 @@ const BaseMask = _ref => {
|
|
|
102
102
|
onChange,
|
|
103
103
|
onComplete,
|
|
104
104
|
permissionAttr,
|
|
105
|
-
|
|
105
|
+
mask
|
|
106
106
|
} = _ref,
|
|
107
107
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
108
108
|
const onDenied = (0, _permissionValidations.actionsOnPermissionDenied)(options, permissionAttr);
|
|
@@ -111,10 +111,13 @@ const BaseMask = _ref => {
|
|
|
111
111
|
readOnly
|
|
112
112
|
} = onDenied;
|
|
113
113
|
const disableCallbacks = disabled || readOnly;
|
|
114
|
-
const maskOptions = (0, _helpers.getMaskOptions)(
|
|
114
|
+
const maskOptions = (0, _helpers.getMaskOptions)(_objectSpread({
|
|
115
|
+
mask
|
|
116
|
+
}, rest));
|
|
115
117
|
const {
|
|
116
118
|
ref,
|
|
117
119
|
setValue,
|
|
120
|
+
setTypedValue,
|
|
118
121
|
maskRef
|
|
119
122
|
} = (0, _reactImask.useIMask)(maskOptions, {
|
|
120
123
|
defaultValue: defaultValue,
|
|
@@ -147,23 +150,14 @@ const BaseMask = _ref => {
|
|
|
147
150
|
});
|
|
148
151
|
(0, _react.useEffect)(() => {
|
|
149
152
|
if (valueProp) {
|
|
150
|
-
if (
|
|
151
|
-
const value = (0, _format_number.numberToPtBR)(valueProp) || '';
|
|
152
|
-
setValue(value);
|
|
153
|
-
} else {
|
|
154
|
-
setValue(String(valueProp));
|
|
155
|
-
}
|
|
153
|
+
if (typeof valueProp === 'string') setValue(valueProp);else setTypedValue(valueProp);
|
|
156
154
|
}
|
|
157
155
|
}, [valueProp]);
|
|
158
156
|
return /*#__PURE__*/_react.default.createElement(_InputTextBase.default, _extends({
|
|
159
157
|
inputRef: r => {
|
|
160
158
|
ref.current = r;
|
|
161
159
|
if (inputRef) {
|
|
162
|
-
if (typeof inputRef === '
|
|
163
|
-
inputRef(r);
|
|
164
|
-
} else {
|
|
165
|
-
inputRef.current = r;
|
|
166
|
-
}
|
|
160
|
+
if (typeof inputRef === 'object') inputRef.current = r;else inputRef(r);
|
|
167
161
|
}
|
|
168
162
|
},
|
|
169
163
|
permissionAttr: permissionAttr
|
|
@@ -7,20 +7,16 @@ import '../../@types/Period.js';
|
|
|
7
7
|
import '../../internals/types.js';
|
|
8
8
|
import '../../@types/Position.js';
|
|
9
9
|
|
|
10
|
-
declare const getMaskOptions: ({ isDateField, placeholderChar, min, max, lazy, rightElements, ...rest }: IBaseMaskProps) => {
|
|
11
|
-
value?: string | undefined;
|
|
10
|
+
declare const getMaskOptions: ({ isDateField, placeholderChar, min, max, lazy, pattern, radix, thousandsSeparator, mapToRadix, scale, normalizeZeros, padFractionalZeros, rightElements, ...rest }: IBaseMaskProps) => {
|
|
11
|
+
value?: string | number | undefined;
|
|
12
12
|
onBlur?: ((e: CustomInputEvent) => void) | undefined;
|
|
13
13
|
onKeyDown?: ((e: CustomInputEvent | React.KeyboardEvent<Element>) => void) | undefined;
|
|
14
14
|
defaultValue?: string | undefined;
|
|
15
15
|
isNumeric?: boolean | undefined;
|
|
16
|
-
scale?: number | undefined;
|
|
17
|
-
radix?: string | undefined;
|
|
18
16
|
blocks?: any;
|
|
19
|
-
thousandsSeparator?: string | undefined;
|
|
20
17
|
leftElements?: JSX.Element | JSX.Element[] | undefined;
|
|
21
18
|
handlerSetOnDenied?: ((onDeniedValue: OnDenied) => void) | undefined;
|
|
22
19
|
onChange?: ((e: CustomInputEvent, maskValue?: string | undefined, date?: string | undefined) => void) | undefined;
|
|
23
|
-
padFractionalZeros?: boolean | undefined;
|
|
24
20
|
onComplete?: ((e: CustomInputEvent, maskValue?: string | undefined, date?: string | undefined) => void) | undefined;
|
|
25
21
|
inputRef?: React.MutableRefObject<HTMLInputElement | HTMLTextAreaElement | null> | ((ref: HTMLInputElement | HTMLTextAreaElement | null) => void) | undefined;
|
|
26
22
|
permissionAttr?: PermissionAttr | undefined;
|
|
@@ -48,7 +44,14 @@ declare const getMaskOptions: ({ isDateField, placeholderChar, min, max, lazy, r
|
|
|
48
44
|
placeholderChar: string;
|
|
49
45
|
min: any;
|
|
50
46
|
max: any;
|
|
51
|
-
lazy: boolean
|
|
47
|
+
lazy: boolean;
|
|
48
|
+
pattern: string;
|
|
49
|
+
radix: string;
|
|
50
|
+
thousandsSeparator: string;
|
|
51
|
+
mapToRadix: string[];
|
|
52
|
+
scale: number;
|
|
53
|
+
normalizeZeros: boolean;
|
|
54
|
+
padFractionalZeros: boolean;
|
|
52
55
|
};
|
|
53
56
|
declare function CPFValidation(cpf?: string, returnMessage?: (msg: string) => void): void | "CPF inválido";
|
|
54
57
|
declare function CNPJValidation(cnpj?: string, returnMessage?: (msg: string) => void): void | "CNPJ inválido";
|
|
@@ -7,7 +7,7 @@ exports.CNPJValidation = CNPJValidation;
|
|
|
7
7
|
exports.CPFValidation = CPFValidation;
|
|
8
8
|
exports.getMaskOptions = void 0;
|
|
9
9
|
var _lodash = require("lodash");
|
|
10
|
-
const _excluded = ["isDateField", "placeholderChar", "min", "max", "lazy", "rightElements"];
|
|
10
|
+
const _excluded = ["isDateField", "placeholderChar", "min", "max", "lazy", "pattern", "radix", "thousandsSeparator", "mapToRadix", "scale", "normalizeZeros", "padFractionalZeros", "rightElements"];
|
|
11
11
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
12
12
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
13
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -23,7 +23,14 @@ const getMaskOptions = _ref => {
|
|
|
23
23
|
placeholderChar = '_',
|
|
24
24
|
min,
|
|
25
25
|
max,
|
|
26
|
-
lazy,
|
|
26
|
+
lazy = false,
|
|
27
|
+
pattern = '',
|
|
28
|
+
radix = ' ',
|
|
29
|
+
thousandsSeparator = '',
|
|
30
|
+
mapToRadix = [],
|
|
31
|
+
scale = 2,
|
|
32
|
+
normalizeZeros = true,
|
|
33
|
+
padFractionalZeros = true,
|
|
27
34
|
rightElements
|
|
28
35
|
} = _ref,
|
|
29
36
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -63,7 +70,14 @@ const getMaskOptions = _ref => {
|
|
|
63
70
|
placeholderChar: placeholderChar === '' ? ' ' : placeholderChar,
|
|
64
71
|
min,
|
|
65
72
|
max,
|
|
66
|
-
lazy
|
|
73
|
+
lazy,
|
|
74
|
+
pattern,
|
|
75
|
+
radix,
|
|
76
|
+
thousandsSeparator,
|
|
77
|
+
mapToRadix,
|
|
78
|
+
scale,
|
|
79
|
+
normalizeZeros,
|
|
80
|
+
padFractionalZeros
|
|
67
81
|
}, rest);
|
|
68
82
|
};
|
|
69
83
|
exports.getMaskOptions = getMaskOptions;
|
|
@@ -7,7 +7,7 @@ import '../../internals/types.js';
|
|
|
7
7
|
import '../../@types/Position.js';
|
|
8
8
|
|
|
9
9
|
type IBaseMaskProps = {
|
|
10
|
-
value?: string;
|
|
10
|
+
value?: string | number;
|
|
11
11
|
onBlur?: (e: CustomInputEvent) => void;
|
|
12
12
|
onKeyDown?: (e: CustomInputEvent | KeyboardEvent<Element>) => void;
|
|
13
13
|
defaultValue?: string;
|
|
@@ -50,6 +50,9 @@ type IBaseMaskProps = {
|
|
|
50
50
|
mask?: any;
|
|
51
51
|
min?: any;
|
|
52
52
|
max?: any;
|
|
53
|
+
pattern?: string;
|
|
54
|
+
mapToRadix?: string[];
|
|
55
|
+
normalizeZeros?: boolean;
|
|
53
56
|
};
|
|
54
57
|
type ICnpjFieldProps = IBaseMaskProps & {
|
|
55
58
|
value?: string;
|