linear-react-components-ui 1.1.11 → 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.
- package/.eslintcache +1 -1
- package/lib/form/types.d.ts +1 -0
- package/lib/inputs/date/index.js +9 -17
- package/lib/inputs/mask/BaseMask.d.ts +1 -1
- package/lib/inputs/mask/BaseMask.js +11 -12
- package/lib/inputs/mask/helpers.d.ts +10 -7
- package/lib/inputs/mask/helpers.js +17 -3
- package/lib/inputs/mask/types.d.ts +4 -1
- package/package.json +1 -1
package/lib/form/types.d.ts
CHANGED
|
@@ -172,6 +172,7 @@ interface WithFieldProps {
|
|
|
172
172
|
handlerStoreValidators?: (name: string, validators: Validator | Validator[]) => void;
|
|
173
173
|
handlerRemoveValidators?: (name: string) => void;
|
|
174
174
|
validators?: Validator | Validator[] | PeriodValidator | PeriodValidator[];
|
|
175
|
+
customClass?: string;
|
|
175
176
|
}
|
|
176
177
|
interface IWithFieldContext {
|
|
177
178
|
validatorFromComponent: Validator | Validator[] | undefined;
|
package/lib/inputs/date/index.js
CHANGED
|
@@ -218,23 +218,15 @@ const DatePicker = props => {
|
|
|
218
218
|
// TODO: Procurar solução melhor.
|
|
219
219
|
// setTimeout(() => { this.onScreenResize(); }, 300);
|
|
220
220
|
}, [inputRef.current]);
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
// } else if (!value && value !== valueFromProps) {
|
|
231
|
-
// setValueState(undefined);
|
|
232
|
-
// setValueFromProps(value);
|
|
233
|
-
// }
|
|
234
|
-
// }, [value]);
|
|
235
|
-
|
|
236
|
-
// console.log("value >>>", value);
|
|
237
|
-
|
|
221
|
+
(0, _react.useEffect)(() => {
|
|
222
|
+
if (value && (0, _moment.default)(value, _helpers.EN_US_FORMAT).format() !== 'Invalid date' && (0, _moment.default)(valueFromProps, _helpers.EN_US_FORMAT).format() !== (0, _moment.default)(value, _helpers.EN_US_FORMAT).format()) {
|
|
223
|
+
setValueState((0, _moment.default)(value, _helpers.EN_US_FORMAT));
|
|
224
|
+
setValueFromProps(value);
|
|
225
|
+
} else if (!value && value !== valueFromProps) {
|
|
226
|
+
setValueState(undefined);
|
|
227
|
+
setValueFromProps(value);
|
|
228
|
+
}
|
|
229
|
+
}, [value]);
|
|
238
230
|
if (onDenied && onDenied.unvisible) return null;
|
|
239
231
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_BaseMask.default, _extends({}, props, {
|
|
240
232
|
value: !valueState ? ' ' : valueState.format(_helpers.PT_BR_FORMAT),
|
|
@@ -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, ...rest }: IBaseMaskProps) => JSX.Element;
|
|
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);
|
|
@@ -101,7 +101,8 @@ const BaseMask = _ref => {
|
|
|
101
101
|
inputRef,
|
|
102
102
|
onChange,
|
|
103
103
|
onComplete,
|
|
104
|
-
permissionAttr
|
|
104
|
+
permissionAttr,
|
|
105
|
+
mask
|
|
105
106
|
} = _ref,
|
|
106
107
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
107
108
|
const onDenied = (0, _permissionValidations.actionsOnPermissionDenied)(options, permissionAttr);
|
|
@@ -110,10 +111,13 @@ const BaseMask = _ref => {
|
|
|
110
111
|
readOnly
|
|
111
112
|
} = onDenied;
|
|
112
113
|
const disableCallbacks = disabled || readOnly;
|
|
113
|
-
const maskOptions = (0, _helpers.getMaskOptions)(
|
|
114
|
+
const maskOptions = (0, _helpers.getMaskOptions)(_objectSpread({
|
|
115
|
+
mask
|
|
116
|
+
}, rest));
|
|
114
117
|
const {
|
|
115
118
|
ref,
|
|
116
119
|
setValue,
|
|
120
|
+
setTypedValue,
|
|
117
121
|
maskRef
|
|
118
122
|
} = (0, _reactImask.useIMask)(maskOptions, {
|
|
119
123
|
defaultValue: defaultValue,
|
|
@@ -145,20 +149,15 @@ const BaseMask = _ref => {
|
|
|
145
149
|
}
|
|
146
150
|
});
|
|
147
151
|
(0, _react.useEffect)(() => {
|
|
148
|
-
// console.log(valueProp);
|
|
149
152
|
if (valueProp) {
|
|
150
|
-
setValue(
|
|
153
|
+
if (typeof valueProp === 'string') setValue(valueProp);else setTypedValue(valueProp);
|
|
151
154
|
}
|
|
152
155
|
}, [valueProp]);
|
|
153
156
|
return /*#__PURE__*/_react.default.createElement(_InputTextBase.default, _extends({
|
|
154
157
|
inputRef: r => {
|
|
155
158
|
ref.current = r;
|
|
156
159
|
if (inputRef) {
|
|
157
|
-
if (typeof inputRef === '
|
|
158
|
-
inputRef(r);
|
|
159
|
-
} else {
|
|
160
|
-
inputRef.current = r;
|
|
161
|
-
}
|
|
160
|
+
if (typeof inputRef === 'object') inputRef.current = r;else inputRef(r);
|
|
162
161
|
}
|
|
163
162
|
},
|
|
164
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;
|