linear-react-components-ui 1.1.14 → 1.1.15

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.
@@ -173,6 +173,7 @@ interface WithFieldProps {
173
173
  handlerStoreValidators?: (name: string, validators: Validator | Validator[]) => void;
174
174
  handlerRemoveValidators?: (name: string) => void;
175
175
  validators?: Validator | Validator[] | PeriodValidator | PeriodValidator[];
176
+ customClass?: string;
176
177
  }
177
178
  interface IWithFieldContext {
178
179
  validatorFromComponent: Validator | Validator[] | undefined;
@@ -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(e) { return e && e.__esModule ? e : { default: e }; }
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)(rest);
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(String(valueProp));
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 === 'function') {
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 | undefined;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linear-react-components-ui",
3
- "version": "1.1.14",
3
+ "version": "1.1.15",
4
4
  "description": "Linear Sistemas ReactJs Components",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.cjs",
@@ -67,6 +67,7 @@
67
67
  "@babel/preset-typescript": "7.23.3",
68
68
  "@svgr/webpack": "8.1.0",
69
69
  "@swc/core": "1.4.13",
70
+ "@testing-library/dom": "10.4.0",
70
71
  "@testing-library/jest-dom": "5.16.5",
71
72
  "@testing-library/react": "14.1.2",
72
73
  "@testing-library/user-event": "14.4.3",