linear-react-components-ui 1.0.10-rc.13 → 1.0.10-rc.14

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.
@@ -9,7 +9,6 @@ var _imask = _interopRequireDefault(require("imask"));
9
9
  var helpers = _interopRequireWildcard(require("./helpers"));
10
10
  var _permissionValidations = require("../../permissionValidations");
11
11
  var _format_number = require("../number/format_number");
12
- var _this = void 0;
13
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
13
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -100,7 +99,7 @@ var IMaskHOC = function IMaskHOC(ComposedComponent) {
100
99
  maskRef.current.value = String(newValue);
101
100
  }
102
101
  };
103
- var onAccept = function onAccept() {
102
+ var onAccept = (0, _react.useCallback)(function () {
104
103
  if (onChange && !disableCallbacks && maskRef.current) {
105
104
  var _maskRef$current = maskRef.current,
106
105
  unmaskedValue = _maskRef$current.unmaskedValue,
@@ -113,8 +112,8 @@ var IMaskHOC = function IMaskHOC(ComposedComponent) {
113
112
  }
114
113
  }, props.unmask ? unmaskedValue : maskRef.current.value);
115
114
  }
116
- };
117
- var onComplete = function onComplete() {
115
+ }, [onChange]);
116
+ var onComplete = (0, _react.useCallback)(function () {
118
117
  if (props.onComplete && !disableCallbacks && maskRef.current) {
119
118
  var _maskRef$current2 = maskRef.current,
120
119
  unmaskedValue = _maskRef$current2.unmaskedValue,
@@ -127,13 +126,14 @@ var IMaskHOC = function IMaskHOC(ComposedComponent) {
127
126
  }
128
127
  }, props.unmask ? unmaskedValue : maskRef.current.value);
129
128
  }
130
- };
129
+ }, [props.onComplete]);
131
130
  var getMask = function getMask() {
132
131
  var element = elementRef.current;
133
132
  if (element) {
134
133
  var maskCurrent = maskRef.current;
135
134
  if (!maskCurrent) {
136
- maskRef.current = (0, _imask.default)(element, maskOptions).on('accept', onAccept.bind(_this)).on('complete', onComplete.bind(_this));
135
+ maskRef.current = (0, _imask.default)(element, maskOptions);
136
+ if (value && typeof value !== 'number' && value.trim() !== '' || value && typeof value === 'number') onAccept();
137
137
  setValue(value);
138
138
  } else {
139
139
  maskCurrent.updateOptions(maskOptions);
@@ -150,14 +150,19 @@ var IMaskHOC = function IMaskHOC(ComposedComponent) {
150
150
  if (props.handlerSetOnDenied) props.handlerSetOnDenied(onDenied);
151
151
  if (!props.mask || dontInitMask) return;
152
152
  getMask();
153
+ }, [maskOptions]);
154
+ (0, _react.useEffect)(function () {
155
+ if (!maskRef.current) return;
156
+ var maskCurrent = maskRef.current;
157
+ maskCurrent.on('accept', onAccept);
158
+ maskCurrent.on('complete', onComplete);
153
159
 
154
160
  // eslint-disable-next-line consistent-return
155
161
  return function () {
156
- var _maskRef$current3, _maskRef$current4;
157
- (_maskRef$current3 = maskRef.current) === null || _maskRef$current3 === void 0 ? void 0 : _maskRef$current3.off('accept', onAccept);
158
- (_maskRef$current4 = maskRef.current) === null || _maskRef$current4 === void 0 ? void 0 : _maskRef$current4.off('complete', onComplete);
162
+ maskCurrent.off('accept', onAccept);
163
+ maskCurrent.off('complete', onComplete);
159
164
  };
160
- }, [maskOptions]);
165
+ }, [onAccept, onComplete]);
161
166
  (0, _react.useEffect)(function () {
162
167
  if (maskOptions.mask && !dontInitMask) {
163
168
  if (maskRef.current) {
@@ -182,7 +187,6 @@ var IMaskHOC = function IMaskHOC(ComposedComponent) {
182
187
  },
183
188
  inputRef: function inputRef(el) {
184
189
  elementRef.current = el;
185
- // Propagate the input ref for who call it
186
190
  if (_inputRef) {
187
191
  if (_typeof(_inputRef) === 'object') _inputRef.current = el;else _inputRef(el);
188
192
  }
@@ -24,13 +24,12 @@ var returnEventFormattedValue = function returnEventFormattedValue(props, event)
24
24
  var _event$target = event.target,
25
25
  value = _event$target.value,
26
26
  name = _event$target.name;
27
- var teste = _objectSpread(_objectSpread({}, event), {}, {
27
+ return _objectSpread(_objectSpread({}, event), {}, {
28
28
  target: {
29
29
  value: (0, _format_number.numberToEnUS)(value),
30
30
  name: name
31
31
  }
32
32
  });
33
- return teste;
34
33
  }
35
34
  return event;
36
35
  };
@@ -14,7 +14,7 @@ exports.numberToPtBR = numberToPtBR;
14
14
  var numberToEnUS = function numberToEnUS(value) {
15
15
  var formattedNumber;
16
16
  if (value) {
17
- formattedNumber = value.replace('.', '').replace(',', '.');
17
+ formattedNumber = value.replaceAll('.', '').replaceAll(',', '.');
18
18
  return Number(formattedNumber);
19
19
  }
20
20
  return value;
@@ -31,7 +31,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
31
31
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
32
32
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
33
33
  var PeriodPicker = function PeriodPicker(props) {
34
- var _props$value2, _props$value3;
35
34
  var _props$showButtonOpen = props.showButtonOpen,
36
35
  showButtonOpen = _props$showButtonOpen === void 0 ? true : _props$showButtonOpen,
37
36
  _props$openOnFocus = props.openOnFocus,
@@ -138,7 +137,7 @@ var PeriodPicker = function PeriodPicker(props) {
138
137
  setValueInitial(newValueInitial);
139
138
  setValueFinal(newValueFinal);
140
139
  }
141
- }, [(_props$value2 = props.value) === null || _props$value2 === void 0 ? void 0 : _props$value2.initial, (_props$value3 = props.value) === null || _props$value3 === void 0 ? void 0 : _props$value3.final]);
140
+ }, [props.value]);
142
141
  var openCalendar = function openCalendar() {
143
142
  setShowCalendar(true);
144
143
  setShowPeriodSelection(false);
@@ -89,10 +89,6 @@ var SimpleSelect = function SimpleSelect(props) {
89
89
  _useState16 = _slicedToArray(_useState15, 2),
90
90
  isTyping = _useState16[0],
91
91
  setIsTyping = _useState16[1];
92
- var _useState17 = (0, _react.useState)(null),
93
- _useState18 = _slicedToArray(_useState17, 2),
94
- valueFromProps = _useState18[0],
95
- setValueFromProps = _useState18[1];
96
92
  var dropdownRef = (0, _react.useRef)(null);
97
93
  var componentId = "select-component".concat(_uuid.default.v1());
98
94
  var componentRef = (0, _react.useRef)(null);
@@ -241,14 +237,13 @@ var SimpleSelect = function SimpleSelect(props) {
241
237
  }
242
238
  }, [gridLayout]);
243
239
  (0, _react.useEffect)(function () {
244
- if (value !== valueFromProps && dataSourceWithAllOptions.length > 0) {
240
+ if (dataSourceWithAllOptions.length > 0) {
245
241
  var newCurrent = null;
246
- if (value) {
242
+ if (value || value === 0) {
247
243
  newCurrent = dataSourceWithAllOptions.find(function (i) {
248
244
  var _i$idKey;
249
- return value && ((_i$idKey = i[idKey]) === null || _i$idKey === void 0 ? void 0 : _i$idKey.toString().toLowerCase()) === (value === null || value === void 0 ? void 0 : value.toString().toLowerCase());
245
+ return (value || value === 0) && ((_i$idKey = i[idKey]) === null || _i$idKey === void 0 ? void 0 : _i$idKey.toString().toLowerCase()) === (value === null || value === void 0 ? void 0 : value.toString().toLowerCase());
250
246
  });
251
- setValueFromProps(value);
252
247
  } else if (dataSourceWithAllOptions.length > 0 && selectFirstOnEnter) {
253
248
  newCurrent = dataSourceWithAllOptions[0];
254
249
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linear-react-components-ui",
3
- "version": "1.0.10-rc.13",
3
+ "version": "1.0.10-rc.14",
4
4
  "description": "Linear Sistemas ReactJs Components",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.cjs",