linear-react-components-ui 1.0.12-beta.0 → 1.0.12-beta.2

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.
@@ -29,20 +29,23 @@ var getEventProps = function getEventProps(_ref) {
29
29
  var name = _ref.name,
30
30
  validators = _ref.validators,
31
31
  _onBlur = _ref.onBlur,
32
+ _onChange = _ref.onChange,
32
33
  _onKeyDown = _ref.onKeyDown,
33
34
  handlerFieldValidade = _ref.handlerFieldValidade,
34
35
  handlerFieldChange = _ref.handlerFieldChange,
35
36
  handleShowValidateMessages = _ref.handleShowValidateMessages;
36
37
  return {
37
38
  onBlur: function onBlur(e) {
38
- if (handlerFieldChange) handlerFieldChange(e);
39
39
  if (validators && handlerFieldValidade) handlerFieldValidade(name, e.target.value, validators);
40
40
  if (_onBlur) _onBlur(e);
41
41
  handleShowValidateMessages(true);
42
42
  },
43
+ onChange: function onChange(e) {
44
+ if (_onChange) _onChange(e);
45
+ },
43
46
  onKeyDown: function onKeyDown(e) {
44
- if ([constants.keyCodes.ENTER].includes(e.keyCode)) {
45
- handlerFieldChange === null || handlerFieldChange === void 0 ? void 0 : handlerFieldChange(e);
47
+ if ([constants.keyCodes.ENTER, constants.keyCodes.TAB].includes(e.keyCode)) {
48
+ if (handlerFieldChange) handlerFieldChange(e);
46
49
  if (validators) handlerFieldValidade === null || handlerFieldValidade === void 0 ? void 0 : handlerFieldValidade(name, e.target.value, validators);
47
50
  if (_onKeyDown) _onKeyDown(e);
48
51
  handleShowValidateMessages(true);
@@ -20,7 +20,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
20
20
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
21
21
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
22
22
  var returnEventFormattedValue = function returnEventFormattedValue(props, event) {
23
- if (props.returnFormattedValueOnBlur || props.returnFormattedValueOnKeyDown) {
23
+ if (props.returnFormattedValueOnBlur || props.returnFormattedValueOnKeyDown || props.returnFormattedValueOnChange) {
24
24
  // Retornando um objeto com a mesma estrutura do Proxy original
25
25
  // para recuperacao do valor da mascara sem formatacao.
26
26
  // O retorno poderá ser modificado conforme necessidade, desde que seja
@@ -52,8 +52,8 @@ var getEventProps = function getEventProps(props) {
52
52
  props.onBlur(formattedEvent);
53
53
  }
54
54
  },
55
- onKeyDown: function onKeyDown(e) {
56
- if (props.onKeyDown) {
55
+ onChange: function onChange(e) {
56
+ if (props.onChange) {
57
57
  var _ref = e.target,
58
58
  value = _ref.value;
59
59
  var formatedValue = (0, _format_number.formatOnlyNumbers)(value);
@@ -63,14 +63,28 @@ var getEventProps = function getEventProps(props) {
63
63
  }
64
64
  });
65
65
  var formattedEvent = returnEventFormattedValue(props, eventWithFormatedValue);
66
+ props.onChange(formattedEvent);
67
+ }
68
+ },
69
+ onKeyDown: function onKeyDown(e) {
70
+ if (props.onKeyDown) {
71
+ var _ref2 = e.target,
72
+ value = _ref2.value;
73
+ var formatedValue = (0, _format_number.formatOnlyNumbers)(value);
74
+ var eventWithFormatedValue = _objectSpread(_objectSpread({}, e), {}, {
75
+ target: {
76
+ value: formatedValue
77
+ }
78
+ });
79
+ var formattedEvent = returnEventFormattedValue(props, eventWithFormatedValue);
66
80
  props.onKeyDown(formattedEvent);
67
81
  }
68
82
  }
69
83
  };
70
84
  };
71
- var BaseMask = function BaseMask(_ref2) {
72
- var inputRef = _ref2.inputRef,
73
- props = _objectWithoutProperties(_ref2, _excluded);
85
+ var BaseMask = function BaseMask(_ref3) {
86
+ var inputRef = _ref3.inputRef,
87
+ props = _objectWithoutProperties(_ref3, _excluded);
74
88
  return /*#__PURE__*/_react.default.createElement(_InputTextBase.default, _extends({}, props, {
75
89
  inputRef: inputRef
76
90
  }, getEventProps(props)));
@@ -60,9 +60,7 @@ var IMaskHOC = function IMaskHOC(ComposedComponent) {
60
60
  value = _props$value === void 0 ? '' : _props$value,
61
61
  onChange = props.onChange,
62
62
  _props$isDateField = props.isDateField,
63
- isDateField = _props$isDateField === void 0 ? false : _props$isDateField,
64
- _props$autoCompleteMa = props.autoCompleteMask,
65
- autoCompleteMask = _props$autoCompleteMa === void 0 ? false : _props$autoCompleteMa;
63
+ isDateField = _props$isDateField === void 0 ? false : _props$isDateField;
66
64
  var maskOptions = {
67
65
  placeholderChar: placeholderChar === '' ? ' ' : placeholderChar,
68
66
  lazy: lazy,
@@ -129,24 +127,6 @@ var IMaskHOC = function IMaskHOC(ComposedComponent) {
129
127
  }, props.unmask ? unmaskedValue : maskRef.current.value);
130
128
  }
131
129
  }, [props.onComplete]);
132
- var autoCompleteMaskValue = (0, _react.useCallback)(function (eventTargetValue) {
133
- if (eventTargetValue.length && maskRef.current && elementRef.current) {
134
- var sizeMask = (0, _imask.default)(elementRef.current, maskOptions).mask.toString().replace(/\D+/g, '').length;
135
- if (sizeMask > eventTargetValue.length) {
136
- switch (autoCompleteMask) {
137
- case 'left':
138
- setValue(eventTargetValue.padStart(sizeMask, '0'));
139
- break;
140
- case 'right':
141
- setValue(eventTargetValue.padEnd(sizeMask, '0'));
142
- break;
143
- default:
144
- setValue(eventTargetValue);
145
- break;
146
- }
147
- }
148
- }
149
- }, [props.autoCompleteMask, maskRef.current, elementRef.current]);
150
130
  var getMask = function getMask() {
151
131
  var element = elementRef.current;
152
132
  if (element) {
@@ -202,12 +182,6 @@ var IMaskHOC = function IMaskHOC(ComposedComponent) {
202
182
  return /*#__PURE__*/_react.default.createElement(ComposedComponent, _extends({}, helpers.extractNonMaskProps(props, maskOptions), {
203
183
  onDeniedActions: onDenied,
204
184
  defaultValue: value,
205
- onBlur: function onBlur(e) {
206
- if (props.autoCompleteMask) {
207
- autoCompleteMaskValue(e.target.value);
208
- }
209
- if (props.onBlur) props.onBlur(e);
210
- },
211
185
  onChange: function onChange(e) {
212
186
  return setValue(e.target.value);
213
187
  },
@@ -45,6 +45,7 @@ interface IBaseMaskProps {
45
45
  required?: boolean;
46
46
  returnFormattedValueOnBlur?: boolean;
47
47
  returnFormattedValueOnKeyDown?: boolean;
48
+ returnFormattedValueOnChange?: boolean;
48
49
  isDateField?: boolean;
49
50
  }
50
51
  interface ICnpjFieldProps extends IBaseMaskProps {
@@ -35,7 +35,8 @@ var returnEventFormattedValue = function returnEventFormattedValue(props, event)
35
35
  };
36
36
  var getEventProps = function getEventProps(props) {
37
37
  var returnFormattedValueOnBlur = props.returnFormattedValueOnBlur,
38
- returnFormattedValueOnKeyDown = props.returnFormattedValueOnKeyDown;
38
+ returnFormattedValueOnKeyDown = props.returnFormattedValueOnKeyDown,
39
+ returnFormattedValueonChange = props.returnFormattedValueonChange;
39
40
  if (props.isNumeric) return {};
40
41
  return {
41
42
  onBlur: function onBlur(e) {
@@ -44,6 +45,12 @@ var getEventProps = function getEventProps(props) {
44
45
  props.onBlur(formattedEvent);
45
46
  }
46
47
  },
48
+ onChange: function onChange(e) {
49
+ if (props.onChange) {
50
+ var formattedEvent = returnFormattedValueonChange ? returnEventFormattedValue(props, e) : e;
51
+ props.onChange(formattedEvent);
52
+ }
53
+ },
47
54
  onKeyDown: function onKeyDown(e) {
48
55
  if (props.onKeyDown) {
49
56
  var formattedEvent = returnFormattedValueOnKeyDown ? returnEventFormattedValue(props, e) : e;
@@ -25,6 +25,7 @@ interface IBaseNumberProps extends INumberFieldProps {
25
25
  onBlur?: (e: CustomInputEvent) => void;
26
26
  returnFormattedValueOnBlur?: boolean;
27
27
  returnFormattedValueOnKeyDown?: boolean;
28
+ returnFormattedValueonChange?: boolean;
28
29
  }
29
30
  interface ICurrencyProps extends INumberFieldProps {
30
31
  currencySymbol?: string;
@@ -99,7 +99,6 @@ interface IMaskHOCProps {
99
99
  skeletonize?: boolean;
100
100
  mask?: string | NumberConstructor;
101
101
  isDateField?: boolean;
102
- autoCompleteMask?: 'left' | 'right';
103
102
  }
104
103
  interface IDropdownSelectProps {
105
104
  idKey: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linear-react-components-ui",
3
- "version": "1.0.12-beta.0",
3
+ "version": "1.0.12-beta.2",
4
4
  "description": "Linear Sistemas ReactJs Components",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.cjs",