linear-react-components-ui 1.0.10-beta.25 → 1.0.10-beta.27

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.
@@ -10,8 +10,5 @@
10
10
  },
11
11
  "editor.codeActionsOnSave": {
12
12
  "source.fixAll.eslint": true
13
- },
14
- "cSpell.words": [
15
- "licenca"
16
- ]
13
+ }
17
14
  }
@@ -0,0 +1,59 @@
1
+ @import "colors.scss";
2
+ @import "commons.scss";
3
+
4
+ p.shortcut-description {
5
+ margin-bottom: .3rem;
6
+ color: $font-color-default;
7
+ font-family: 'Roboto', sans-serif;
8
+ font-size: 14px;
9
+ font-weight: 400;
10
+ overflow-wrap: break-word;
11
+ }
12
+
13
+ .shortcut-component {
14
+ user-select: none;
15
+ display: inline-block;
16
+ padding: 0.1rem 0.3rem;
17
+ color: $font-color-default;
18
+ vertical-align: middle;
19
+ background-color: $default-color;
20
+ border: solid 1px $default-border-color;
21
+ border-radius: 3px;
22
+ box-shadow: inset 0 -1px 0 $default-border-color;
23
+ font-size: .9rem;
24
+
25
+ &.-danger {
26
+ background-color: $danger-color;
27
+ color: $font-color-second;
28
+ box-shadow: inset 0 -1px 0 $danger-actived-color;
29
+ border-color: $danger-color;
30
+ }
31
+
32
+ &.-primary {
33
+ background-color: $primary-color;
34
+ color: $font-color-second;
35
+ box-shadow: inset 0 -1px 0 $primary-actived-color;
36
+ border-color: $primary-border-color;
37
+ }
38
+
39
+ &.-warning {
40
+ background-color: $warning-color;
41
+ color: $font-color-second;
42
+ box-shadow: inset 0 -1px 0 $warning-actived-color;
43
+ border-color: $warning-color;
44
+ }
45
+
46
+ &.-success {
47
+ background-color: $success-color;
48
+ color: $font-color-second;
49
+ box-shadow: inset 0 -1px 0 $success-actived-color;
50
+ border-color: $success-color;
51
+ }
52
+
53
+ &.-info {
54
+ background-color: $info-color;
55
+ color: $font-color-second;
56
+ box-shadow: inset 0 -1px 0 $info-actived-color;
57
+ border-color: $info-color;
58
+ }
59
+ }
package/lib/form/Field.js CHANGED
@@ -9,24 +9,16 @@ var _react = _interopRequireWildcard(require("react"));
9
9
  var _lodash = _interopRequireDefault(require("lodash"));
10
10
  var _withFieldHOC = _interopRequireDefault(require("./withFieldHOC"));
11
11
  var _helpers = require("./helpers");
12
- var _excluded = ["handlerFieldChange", "handlerFieldValidade", "onChange", "onBlur", "name", "validators", "data", "fieldErrors", "handlerStoreValidators", "handlerRemoveValidators", "component", "externalFieldErrors", "originalData"];
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; }
16
15
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
17
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
20
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
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
16
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
23
17
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
24
18
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
25
19
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
26
20
  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; } }
27
21
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
28
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
29
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
30
22
  var getEvents = function getEvents(_ref) {
31
23
  var _ref$validators = _ref.validators,
32
24
  validators = _ref$validators === void 0 ? [] : _ref$validators,
@@ -35,29 +27,26 @@ var getEvents = function getEvents(_ref) {
35
27
  handlerFieldValidade = _ref.handlerFieldValidade,
36
28
  validatorFromComponent = _ref.validatorFromComponent,
37
29
  handlerFieldChange = _ref.handlerFieldChange,
38
- _onChange = _ref.onChange,
39
- handleShowValidateMessages = _ref.handleShowValidateMessages;
40
- if (!(validators || validatorFromComponent || _onBlur || _onChange)) return {};
30
+ _onChange = _ref.onChange;
31
+ if (!(validators || validatorFromComponent || _onBlur)) return {};
41
32
  var validatorsArray = (0, _helpers.getValidatorsArray)(validators, validatorFromComponent);
42
33
  return {
43
34
  onBlur: function onBlur(e) {
44
35
  if (validatorsArray && e.target && handlerFieldValidade) {
45
36
  handlerFieldValidade(name, e.target.value, validatorsArray);
46
- handleShowValidateMessages(true);
47
37
  }
48
38
  if (_onBlur) _onBlur(e);
49
39
  },
50
40
  onChange: function onChange(e) {
51
41
  if (validatorsArray && e.target && handlerFieldValidade) {
52
42
  handlerFieldValidade(name, e.target.value, validatorsArray);
53
- handleShowValidateMessages(true);
54
43
  }
55
44
  if (handlerFieldChange) handlerFieldChange(e);
56
45
  if (_onChange) _onChange(e);
57
46
  }
58
47
  };
59
48
  };
60
- var getCustomProps = function getCustomProps(props, handlerSetComponentValidator) {
49
+ var getCustomProps = function getCustomProps(props, setValidatorFromComponent) {
61
50
  var value = props.value,
62
51
  data = props.data,
63
52
  name = props.name,
@@ -77,7 +66,7 @@ var getCustomProps = function getCustomProps(props, handlerSetComponentValidator
77
66
  } else if (component.displayName === 'CpfField' || component.displayName === 'CnpjField') {
78
67
  return {
79
68
  value: _lodash.default.get(data, name),
80
- handlerSetComponentValidator: handlerSetComponentValidator
69
+ handlerSetComponentValidator: setValidatorFromComponent
81
70
  };
82
71
  }
83
72
  return {
@@ -86,52 +75,29 @@ var getCustomProps = function getCustomProps(props, handlerSetComponentValidator
86
75
  };
87
76
  var Field = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
88
77
  var handlerFieldChange = props.handlerFieldChange,
89
- handlerFieldValidade = props.handlerFieldValidade,
90
- onChange = props.onChange,
91
- onBlur = props.onBlur,
92
- name = props.name,
93
- validators = props.validators,
94
- data = props.data,
95
- fieldErrors = props.fieldErrors,
96
- handlerStoreValidators = props.handlerStoreValidators,
97
- handlerRemoveValidators = props.handlerRemoveValidators,
98
- Component = props.component,
99
- externalFieldErrors = props.externalFieldErrors,
100
- originalData = props.originalData,
101
- rest = _objectWithoutProperties(props, _excluded);
102
- var _useState = (0, _react.useState)(false),
78
+ onChange = props.onChange;
79
+ var _useState = (0, _react.useState)(undefined),
103
80
  _useState2 = _slicedToArray(_useState, 2),
104
- showValidateMessages = _useState2[0],
105
- setShowValidateMessages = _useState2[1];
81
+ validatorFromComponent = _useState2[0],
82
+ setValidatorFromComponent = _useState2[1];
106
83
  var _useContext = (0, _react.useContext)(_helpers.withFieldContext),
107
- handlerSetValidatorFromComponent = _useContext.handlerSetValidatorFromComponent,
108
- validatorFromComponent = _useContext.validatorFromComponent;
109
- var currentValue = _lodash.default.get(data, name);
110
- var originalValue = _lodash.default.get(originalData, name);
84
+ handlerSetValidatorFromComponent = _useContext.handlerSetValidatorFromComponent;
111
85
  (0, _react.useEffect)(function () {
112
- if (currentValue && currentValue !== originalValue && (!!currentValue || currentValue === 0 || Array.isArray(currentValue) && currentValue.length > 0)) {
113
- setShowValidateMessages(true);
114
- } else if (_lodash.default.isEmpty(data) || _lodash.default.every(data, _lodash.default.isEmpty) || currentValue === originalValue) {
115
- setShowValidateMessages(false);
86
+ if (validatorFromComponent && handlerSetValidatorFromComponent) {
87
+ handlerSetValidatorFromComponent(validatorFromComponent);
116
88
  }
117
- }, [currentValue, originalValue]);
118
- return /*#__PURE__*/_react.default.createElement(Component, _extends({}, rest, getEvents({
119
- name: name,
120
- validators: validators,
121
- onBlur: onBlur,
89
+ }, [validatorFromComponent]);
90
+ return /*#__PURE__*/_react.default.createElement(props.component, _extends({}, props, getEvents({
91
+ name: props.name,
92
+ validators: props.validators,
93
+ onBlur: props.onBlur,
122
94
  validatorFromComponent: validatorFromComponent,
123
- handlerFieldValidade: handlerFieldValidade,
95
+ handlerFieldValidade: props.handlerFieldValidade ? props.handlerFieldValidade : function () {},
124
96
  handlerFieldChange: handlerFieldChange,
125
- onChange: onChange,
126
- handleShowValidateMessages: function handleShowValidateMessages(value) {
127
- return setShowValidateMessages(value);
128
- }
129
- }), getCustomProps(props, handlerSetValidatorFromComponent), {
97
+ onChange: onChange
98
+ }), getCustomProps(props, setValidatorFromComponent), {
130
99
  ref: ref,
131
- name: name,
132
- errorMessages: (0, _helpers.getErrorMessages)(_objectSpread(_objectSpread({}, props), {}, {
133
- fieldErrors: showValidateMessages ? props.fieldErrors : {}
134
- }))
100
+ errorMessages: (0, _helpers.getErrorMessages)(props)
135
101
  }));
136
102
  });
137
103
  var _default = (0, _withFieldHOC.default)(Field);
@@ -10,26 +10,15 @@ var _withFieldHOC = _interopRequireDefault(require("./withFieldHOC"));
10
10
  var _gridlayout = _interopRequireDefault(require("../gridlayout"));
11
11
  var _fieldset = _interopRequireDefault(require("../fieldset"));
12
12
  var _helpers = require("./helpers");
13
- var _excluded = ["cols", "label", "bordered", "labelContainerStyle", "skipLabel", "data", "name", "handlerStoreValidators", "component", "handlerFieldChange", "handlerFieldValidade", "changePropName", "fieldErrors", "externalMessagesErrors", "dataSource", "handlerRemoveValidators", "validators", "valuePropName", "idKey", "originalData"];
14
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
14
  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); }
16
15
  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; }
17
16
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
18
17
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
19
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
20
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
21
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
22
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
23
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
24
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
25
- 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; } }
26
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
27
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
28
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
29
18
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
30
19
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
31
20
  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); }
32
- var getDefaultProps = function getDefaultProps(props, handleShowValidateMessages) {
21
+ var getDefaultProps = function getDefaultProps(props) {
33
22
  var _ref;
34
23
  var _props$valuePropName = props.valuePropName,
35
24
  valuePropName = _props$valuePropName === void 0 ? 'value' : _props$valuePropName,
@@ -38,14 +27,8 @@ var getDefaultProps = function getDefaultProps(props, handleShowValidateMessages
38
27
  data = props.data,
39
28
  name = props.name,
40
29
  handlerFieldChange = props.handlerFieldChange,
41
- handlerSelecionados = props.handlerSelecionados,
42
- _onBlur = props.onBlur;
43
- return _ref = {
44
- onBlur: function onBlur(e) {
45
- if (handleShowValidateMessages) handleShowValidateMessages(true);
46
- if (_onBlur) _onBlur(e);
47
- }
48
- }, _defineProperty(_ref, valuePropName, _lodash.default.get(data, name)), _defineProperty(_ref, changePropName, function (ids) {
30
+ handlerSelecionados = props.handlerSelecionados;
31
+ return _ref = {}, _defineProperty(_ref, valuePropName, _lodash.default.get(data, name)), _defineProperty(_ref, changePropName, function (ids) {
49
32
  if (handlerFieldChange) handlerFieldChange({
50
33
  target: {
51
34
  value: ids,
@@ -53,85 +36,25 @@ var getDefaultProps = function getDefaultProps(props, handleShowValidateMessages
53
36
  }
54
37
  });
55
38
  if (handlerSelecionados) handlerSelecionados(ids);
56
- // if (handleShowValidateMessages) handleShowValidateMessages(true);
57
39
  }), _ref;
58
40
  };
59
- var getEvents = function getEvents(_ref2) {
60
- var _onBlur2 = _ref2.onBlur,
61
- _onSelect = _ref2.onSelect,
62
- handleShowValidateMessages = _ref2.handleShowValidateMessages;
63
- return {
64
- onBlur: function onBlur(e) {
65
- handleShowValidateMessages(true);
66
- if (_onBlur2) _onBlur2(e);
67
- },
68
- onSelect: function onSelect(e) {
69
- handleShowValidateMessages(true);
70
- if (_onSelect) _onSelect(e);
71
- }
72
- };
73
- };
74
41
  var FieldArray = function FieldArray(props) {
75
42
  var cols = props.cols,
76
43
  label = props.label,
77
44
  bordered = props.bordered,
78
45
  labelContainerStyle = props.labelContainerStyle,
79
- skipLabel = props.skipLabel,
80
- data = props.data,
81
- name = props.name,
82
- handlerStoreValidators = props.handlerStoreValidators,
83
- Component = props.component,
84
- handlerFieldChange = props.handlerFieldChange,
85
- handlerFieldValidade = props.handlerFieldValidade,
86
- changePropName = props.changePropName,
87
- fieldErrors = props.fieldErrors,
88
- externalMessagesErrors = props.externalMessagesErrors,
89
- dataSource = props.dataSource,
90
- handlerRemoveValidators = props.handlerRemoveValidators,
91
- validators = props.validators,
92
- valuePropName = props.valuePropName,
93
- idKey = props.idKey,
94
- originalData = props.originalData,
95
- rest = _objectWithoutProperties(props, _excluded);
96
- var _useState = (0, _react.useState)(false),
97
- _useState2 = _slicedToArray(_useState, 2),
98
- showValidateMessages = _useState2[0],
99
- setShowValidateMessages = _useState2[1];
100
- var currentValue = _lodash.default.get(data, name);
101
- var originalValue = _lodash.default.get(originalData, name);
102
- var handleShowValidateMessages = function handleShowValidateMessages(value) {
103
- setShowValidateMessages(value);
104
- };
105
- (0, _react.useEffect)(function () {
106
- if (!_lodash.default.isEqual(currentValue, originalValue) && Array.isArray(currentValue) && currentValue.length > 0) {
107
- setShowValidateMessages(true);
108
- } else if (_lodash.default.isEmpty(data) || _lodash.default.every(data, _lodash.default.isEmpty) || _lodash.default.isEqual(currentValue, originalValue)) {
109
- setShowValidateMessages(false);
110
- }
111
- }, [currentValue]);
46
+ skipLabel = props.skipLabel;
112
47
  var content = null;
113
- if (Component) {
48
+ if (props.component) {
114
49
  if (!skipLabel && label) {
115
50
  content = /*#__PURE__*/_react.default.createElement(_fieldset.default, {
116
51
  title: label,
117
52
  customClass: "arraycontainer ".concat(bordered && '-bordered'),
118
53
  style: labelContainerStyle,
119
54
  titleCustomClass: "label"
120
- }, /*#__PURE__*/_react.default.createElement(Component, _extends({}, rest, getDefaultProps(props, handleShowValidateMessages), getEvents(_objectSpread(_objectSpread({}, props), {}, {
121
- handleShowValidateMessages: function handleShowValidateMessages(value) {
122
- return setShowValidateMessages(value);
123
- }
124
- })))), (0, _helpers.getErrorMessages)(_objectSpread(_objectSpread({}, props), {}, {
125
- fieldErrors: showValidateMessages ? props.fieldErrors : {}
126
- })));
55
+ }, /*#__PURE__*/_react.default.createElement(props.component, _extends({}, props, getDefaultProps(props))), (0, _helpers.getErrorMessages)(props));
127
56
  } else {
128
- content = /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(Component, _extends({}, rest, getDefaultProps(props, handleShowValidateMessages), getEvents(_objectSpread(_objectSpread({}, props), {}, {
129
- handleShowValidateMessages: function handleShowValidateMessages(value) {
130
- return setShowValidateMessages(value);
131
- }
132
- })))), (0, _helpers.getErrorMessages)(_objectSpread(_objectSpread({}, props), {}, {
133
- fieldErrors: showValidateMessages ? props.fieldErrors : {}
134
- })));
57
+ content = /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(props.component, _extends({}, props, getDefaultProps(props))), (0, _helpers.getErrorMessages)(props));
135
58
  }
136
59
  }
137
60
  if (cols) return /*#__PURE__*/_react.default.createElement(_gridlayout.default, {
@@ -5,77 +5,43 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _react = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
9
9
  var _lodash = _interopRequireDefault(require("lodash"));
10
10
  var _withFieldHOC = _interopRequireDefault(require("./withFieldHOC"));
11
11
  var _helpers = require("./helpers");
12
12
  var constants = _interopRequireWildcard(require("../internals/constants"));
13
- 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; }
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
16
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
17
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
20
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
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
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
23
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
24
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
25
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
26
- 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; } }
27
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
28
17
  var getEventProps = function getEventProps(_ref) {
29
18
  var name = _ref.name,
30
19
  validators = _ref.validators,
31
20
  _onBlur = _ref.onBlur,
32
21
  _onKeyDown = _ref.onKeyDown,
33
22
  handlerFieldValidade = _ref.handlerFieldValidade,
34
- handlerFieldChange = _ref.handlerFieldChange,
35
- handleShowValidateMessages = _ref.handleShowValidateMessages;
23
+ handlerFieldChange = _ref.handlerFieldChange;
36
24
  return {
37
25
  onBlur: function onBlur(e) {
38
26
  if (handlerFieldChange) handlerFieldChange(e);
39
27
  if (validators && handlerFieldValidade) handlerFieldValidade(name, e.target.value, validators);
40
28
  if (_onBlur) _onBlur(e);
41
- handleShowValidateMessages(true);
42
29
  },
43
30
  onKeyDown: function onKeyDown(e) {
44
31
  if ([constants.keyCodes.ENTER].includes(e.keyCode)) {
45
32
  handlerFieldChange === null || handlerFieldChange === void 0 ? void 0 : handlerFieldChange(e);
46
33
  if (validators) handlerFieldValidade === null || handlerFieldValidade === void 0 ? void 0 : handlerFieldValidade(name, e.target.value, validators);
47
34
  if (_onKeyDown) _onKeyDown(e);
48
- handleShowValidateMessages(true);
49
35
  }
50
36
  }
51
37
  };
52
38
  };
53
39
  var FieldMask = function FieldMask(props) {
54
40
  var data = props.data,
55
- name = props.name,
56
- originalData = props.originalData;
57
- var currentValue = _lodash.default.get(data, name);
58
- var _useState = (0, _react.useState)(false),
59
- _useState2 = _slicedToArray(_useState, 2),
60
- showValidateMessages = _useState2[0],
61
- setShowValidateMessages = _useState2[1];
62
- var originalValue = _lodash.default.get(originalData, name);
63
- (0, _react.useEffect)(function () {
64
- if (currentValue && currentValue !== originalValue && !!currentValue) {
65
- setShowValidateMessages(true);
66
- } else if (_lodash.default.isEmpty(data) || _lodash.default.every(data, _lodash.default.isEmpty) || currentValue === originalValue) {
67
- setShowValidateMessages(false);
68
- }
69
- }, [currentValue, originalValue]);
70
- return /*#__PURE__*/_react.default.createElement(props.component, _extends({}, props, getEventProps(_objectSpread(_objectSpread({}, props), {}, {
71
- handleShowValidateMessages: function handleShowValidateMessages(value) {
72
- return setShowValidateMessages(value);
73
- }
74
- })), {
75
- errorMessages: (0, _helpers.getErrorMessages)(_objectSpread(_objectSpread({}, props), {}, {
76
- fieldErrors: showValidateMessages ? props.fieldErrors : {}
77
- })),
78
- value: currentValue
41
+ name = props.name;
42
+ return /*#__PURE__*/_react.default.createElement(props.component, _extends({}, props, getEventProps(props), {
43
+ errorMessages: (0, _helpers.getErrorMessages)(props),
44
+ value: _lodash.default.get(data, name)
79
45
  }));
80
46
  };
81
47
  var _default = (0, _withFieldHOC.default)(FieldMask);
@@ -1,24 +1,15 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.default = void 0;
8
- var _react = _interopRequireWildcard(require("react"));
7
+ var _react = _interopRequireDefault(require("react"));
9
8
  var _lodash = _interopRequireDefault(require("lodash"));
10
9
  var _withFieldHOC = _interopRequireDefault(require("./withFieldHOC"));
11
10
  var _helpers = require("./helpers");
12
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
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; }
15
12
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
16
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
17
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
18
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
19
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
20
- 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; } }
21
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
22
13
  var FieldPeriod = function FieldPeriod(props) {
23
14
  var data = props.data,
24
15
  nameDateInitial = props.nameDateInitial,
@@ -28,24 +19,10 @@ var FieldPeriod = function FieldPeriod(props) {
28
19
  fieldErrors = props.fieldErrors,
29
20
  externalMessagesErrors = props.externalMessagesErrors,
30
21
  _onChange = props.onChange,
31
- validators = props.validators,
32
- originalData = props.originalData;
33
- var _useState = (0, _react.useState)(false),
34
- _useState2 = _slicedToArray(_useState, 2),
35
- showValidateMessages = _useState2[0],
36
- setShowValidateMessages = _useState2[1];
37
- var currentValue = _lodash.default.get(data, nameDateInitial);
38
- var originalValue = _lodash.default.get(originalData, nameDateInitial);
39
- (0, _react.useEffect)(function () {
40
- if (!_lodash.default.isEqual(currentValue, originalValue) && currentValue && (!!currentValue || currentValue === 0 || Array.isArray(currentValue) && currentValue.length > 0)) {
41
- setShowValidateMessages(true);
42
- } else if (_lodash.default.isEmpty(data) || _lodash.default.every(data, _lodash.default.isEmpty) || _lodash.default.isEqual(currentValue, originalValue)) {
43
- setShowValidateMessages(false);
44
- }
45
- }, [currentValue]);
22
+ validators = props.validators;
46
23
  var errorMessages = (0, _helpers.getErrorMessages)({
47
24
  name: nameDateInitial,
48
- fieldErrors: showValidateMessages ? fieldErrors : {},
25
+ fieldErrors: fieldErrors,
49
26
  externalMessagesErrors: externalMessagesErrors
50
27
  });
51
28
  if (!props.component) return null;
@@ -59,7 +36,6 @@ var FieldPeriod = function FieldPeriod(props) {
59
36
  initial: initial,
60
37
  final: final
61
38
  }, validators);
62
- setShowValidateMessages(true);
63
39
  }
64
40
  if (handlerFieldChange) {
65
41
  handlerFieldChange({
@@ -10,7 +10,7 @@ import '../@types/Period.js';
10
10
  declare const securityBeforeUnload = "securityBeforeUnload";
11
11
  declare const FormContext: React__default.Context<FormContextProps>;
12
12
  declare const withFieldContext: React__default.Context<IWithFieldContext>;
13
- declare const changeValue: (data: object, target: HTMLInputElement) => any;
13
+ declare const changeValue: (newData: object, target: HTMLInputElement) => any;
14
14
  declare const getErrorMessages: ({ name, fieldErrors, externalFieldErrors, externalMessagesErrors, }: IGetErrorMessagesParams) => string[];
15
15
  declare const getValidatorsArray: (validators?: Validator | Validator[], validatorFromComponent?: Validator | Validator[]) => Validator[];
16
16
 
@@ -19,10 +19,10 @@ var FormContext = /*#__PURE__*/_react.default.createContext({});
19
19
  exports.FormContext = FormContext;
20
20
  var withFieldContext = /*#__PURE__*/_react.default.createContext({});
21
21
  exports.withFieldContext = withFieldContext;
22
- var changeValue = function changeValue(data, target) {
22
+ var changeValue = function changeValue(newData, target) {
23
23
  var name = target.name,
24
24
  value = target.value;
25
- return _lodash.default.set(JSON.parse(JSON.stringify(data)), name, value);
25
+ return _lodash.default.set(JSON.parse(JSON.stringify(newData)), name, value);
26
26
  };
27
27
  exports.changeValue = changeValue;
28
28
  var getErrorMessages = function getErrorMessages(_ref) {
@@ -2,7 +2,7 @@ export { default as Field } from './Field.js';
2
2
  export { default as FieldNumber } from './FieldNumber.js';
3
3
  export { default as FieldArray } from './FieldArray.js';
4
4
  export { default as FieldPeriod } from './FieldPeriod.js';
5
- import { FormProps } from './types.js';
5
+ import { IFormProps } from './types.js';
6
6
  import 'react';
7
7
  import '../inputs/select/types.js';
8
8
  import '../@types/Align.js';
@@ -11,6 +11,6 @@ import '../@types/PermissionAttr.js';
11
11
  import '../inputs/base/types.js';
12
12
  import '../@types/Period.js';
13
13
 
14
- declare const Form: ({ submitOnPressEnterKey, dataSource, securityBeforeUnload, handlerReset, handlerSubmit, handlerValidates, style, customClass, securityTitle, securityText, securityData, onDataChange, onValidateForm, externalFieldErrors, onSubmit, skeletonize, disabled, children, useInternalState, }: FormProps) => JSX.Element;
14
+ declare const Form: ({ submitOnPressEnterKey, dataSource, securityBeforeUnload, handlerReset, handlerSubmit, handlerValidates, style, customClass, securityTitle, securityText, securityData, onDataChange, onValidateForm, externalFieldErrors, onSubmit, skeletonize, disabled, children, }: IFormProps) => JSX.Element;
15
15
 
16
16
  export { Form as default };
package/lib/form/index.js CHANGED
@@ -77,9 +77,7 @@ var Form = function Form(_ref) {
77
77
  onSubmit = _ref.onSubmit,
78
78
  skeletonize = _ref.skeletonize,
79
79
  disabled = _ref.disabled,
80
- children = _ref.children,
81
- _ref$useInternalState = _ref.useInternalState,
82
- useInternalState = _ref$useInternalState === void 0 ? false : _ref$useInternalState;
80
+ children = _ref.children;
83
81
  var _useState = (0, _react.useState)(dataSource),
84
82
  _useState2 = _slicedToArray(_useState, 2),
85
83
  data = _useState2[0],
@@ -98,7 +96,6 @@ var Form = function Form(_ref) {
98
96
  setFieldErrors = _useState8[1];
99
97
  var fieldsValidators = (0, _react.useRef)({});
100
98
  var context = (0, _react.useContext)(_withFormSecurity.FormSecurityContext);
101
- var usedData = useInternalState ? data : dataSource;
102
99
  var getValidatesErrorMessages = function getValidatesErrorMessages(validators, fieldValue) {
103
100
  var validatorsArray = !(validators instanceof Array) ? [validators] : validators;
104
101
  var errors = [];
@@ -110,38 +107,25 @@ var Form = function Form(_ref) {
110
107
  });
111
108
  return errors;
112
109
  };
113
- var getErrorMessages = function getErrorMessages(currentData, currentValidators) {
114
- var dataValidate = currentData || usedData;
115
- var currentFieldErrors = _lodash.default.pickBy(fieldErrors, function (error, fieldName) {
116
- var fieldValidatorsNames = Object.keys(currentValidators);
117
- return fieldValidatorsNames.includes(fieldName);
118
- });
119
- _lodash.default.forEach(currentValidators, function (validators, fieldName) {
110
+ var checkIsValid = function checkIsValid(value) {
111
+ var updateState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
112
+ var dataValidate = value || data;
113
+ var currentFieldErrors = {};
114
+ _lodash.default.forEach(fieldsValidators.current, function (validators, fieldName) {
120
115
  var fieldValue = _lodash.default.get(dataValidate, fieldName);
121
116
  var messages = getValidatesErrorMessages(validators, fieldValue);
122
- currentFieldErrors = _objectSpread(_objectSpread({}, currentFieldErrors), {}, _defineProperty({}, fieldName, messages));
117
+ if (messages.length > 0) {
118
+ currentFieldErrors = _objectSpread(_objectSpread({}, fieldErrors), {}, _defineProperty({}, fieldName, messages));
119
+ }
123
120
  });
124
- return currentFieldErrors;
125
- };
126
- var checkIsValid = function checkIsValid(currentData) {
127
- var updateState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
128
- var currentValidators = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
129
- var currentFieldErrors = getErrorMessages(currentData, currentValidators || fieldsValidators.current);
130
121
  if (updateState) setFieldErrors(currentFieldErrors);
131
- return Object.values(currentFieldErrors).every(function (value) {
132
- return value.length === 0;
133
- });
122
+ return _lodash.default.isEmpty(currentFieldErrors);
134
123
  };
135
124
  var onFieldChange = function onFieldChange(event) {
136
125
  var target = event.target;
137
- if (!useInternalState && onDataChange) {
138
- var newData = (0, _helpers.changeValue)(dataSource, target);
139
- onDataChange(newData);
140
- } else {
141
- setData(function (prevState) {
142
- return (0, _helpers.changeValue)(prevState, target);
143
- });
144
- }
126
+ setData(function (prevState) {
127
+ return (0, _helpers.changeValue)(prevState, target);
128
+ });
145
129
  };
146
130
  var onValidate = function onValidate(fieldName, fieldValue, validators) {
147
131
  if (validators) {
@@ -157,24 +141,20 @@ var Form = function Form(_ref) {
157
141
  };
158
142
  var onFormSubmit = function onFormSubmit(event) {
159
143
  if (event) event.preventDefault();
160
- if (checkIsValid(usedData)) onSubmit(usedData);
144
+ if (checkIsValid(data)) onSubmit(data);
161
145
  };
162
146
  var onReset = function onReset() {
163
- if (!useInternalState && onDataChange) {
164
- onDataChange(JSON.parse(JSON.stringify(originalData)));
165
- } else {
166
- setData(JSON.parse(JSON.stringify(originalData)));
167
- }
147
+ setData(JSON.parse(JSON.stringify(originalData)));
168
148
  setFieldErrors({});
169
149
  };
170
150
  var onRemoveFieldValidators = function onRemoveFieldValidators(fieldName) {
171
- var newFieldsValidators = _lodash.default.omit(fieldsValidators, fieldName);
151
+ var newFieldsValidators = _lodash.default.omit(fieldsValidators.current, fieldName);
172
152
  fieldsValidators.current = newFieldsValidators;
173
153
  };
174
154
  var onBeforeUnload = function onBeforeUnload(e) {
175
155
  var event = e;
176
156
  event.preventDefault();
177
- if (_lodash.default.isEqual(usedData, originalData)) {
157
+ if (_lodash.default.isEqual(data, originalData)) {
178
158
  return;
179
159
  }
180
160
  event.returnValue = true;
@@ -199,32 +179,25 @@ var Form = function Form(_ref) {
199
179
  }
200
180
  return propsForm;
201
181
  };
202
- var updateFormState = function updateFormState() {
182
+ (0, _react.useEffect)(function () {
203
183
  if (!_lodash.default.isEmpty(context)) {
204
184
  var onChangedData = context.onChangedData;
205
- if (securityData && !_lodash.default.isEqual(usedData, securityData)) {
185
+ if (securityData && !_lodash.default.isEqual(data, securityData)) {
206
186
  onChangedData(true);
207
187
  } else {
208
188
  onChangedData(false);
209
189
  }
210
190
  }
211
- if (onDataChange) onDataChange(usedData);
212
191
 
213
192
  // TODO - Usar debounce para evitar chamada a cada letra digitada
214
- if (onValidateForm) onValidateForm(checkIsValid(usedData, true));
193
+ if (onDataChange) onDataChange(data);
194
+ if (onValidateForm) onValidateForm(checkIsValid(data, false));
215
195
  if (!disabled) {
216
196
  handlerSubmit(onFormSubmit);
217
197
  if (handlerReset) handlerReset(onReset);
218
- if (handlerValidates) handlerValidates(checkIsValid(usedData));
198
+ if (handlerValidates) handlerValidates(checkIsValid(data));
219
199
  }
220
- if (_lodash.default.isEmpty(usedData)) setOriginalData(usedData);
221
- };
222
- (0, _react.useEffect)(function () {
223
- if (useInternalState) updateFormState();
224
- }, [JSON.stringify(data), useInternalState]);
225
- (0, _react.useEffect)(function () {
226
- if (!useInternalState && onDataChange) updateFormState();
227
- }, [JSON.stringify(dataSource), useInternalState]);
200
+ }, [data]);
228
201
  (0, _react.useEffect)(function () {
229
202
  if (securityBeforeUnload) {
230
203
  if (context) context.setSecurityBeforeUnload(true);
@@ -235,33 +208,27 @@ var Form = function Form(_ref) {
235
208
  };
236
209
  }, [securityBeforeUnload, onBeforeUnload]);
237
210
  (0, _react.useEffect)(function () {
238
- if (!disabled && submitOnPressEnterKey !== submitFormOnEnter) {
239
- setSubmitFormOnEnter(submitOnPressEnterKey);
211
+ if (!disabled) {
212
+ if (submitOnPressEnterKey !== submitFormOnEnter || dataSource !== originalData) {
213
+ setData(function (prevState) {
214
+ return !_lodash.default.isEqual(data, dataSource) ? dataSource : prevState;
215
+ });
216
+ setOriginalData(function (prevState) {
217
+ return prevState || dataSource;
218
+ });
219
+ setSubmitFormOnEnter(submitOnPressEnterKey);
220
+ }
240
221
  }
241
- }, [submitOnPressEnterKey]);
222
+ }, [submitOnPressEnterKey, dataSource]);
242
223
  var contextValues = {
243
224
  skeletonize: skeletonize,
244
225
  handlerFieldChange: onFieldChange,
245
226
  handlerFieldValidade: onValidate,
246
227
  handlerStoreValidators: function handlerStoreValidators(fieldName, fieldValidates) {
247
- var oldFieldsValidators = _objectSpread({}, fieldsValidators.current);
248
228
  fieldsValidators.current = _objectSpread(_objectSpread({}, fieldsValidators.current), {}, _defineProperty({}, fieldName, fieldValidates));
249
- if (onValidateForm && oldFieldsValidators && oldFieldsValidators[fieldName]) {
250
- var oldValidatorsValue = Object.values(oldFieldsValidators[fieldName]);
251
- var newValidatorValue = Object.values(fieldValidates);
252
- var validatorsIsNotEqual = oldValidatorsValue.length !== newValidatorValue.length;
253
- if (validatorsIsNotEqual) {
254
- if (!useInternalState && onDataChange) {
255
- onValidateForm(checkIsValid(dataSource, true, fieldsValidators.current));
256
- } else {
257
- onValidateForm(checkIsValid(data, true, fieldsValidators.current));
258
- }
259
- }
260
- }
261
229
  },
262
230
  handlerRemoveValidators: onRemoveFieldValidators,
263
- data: useInternalState ? data : dataSource,
264
- originalData: originalData,
231
+ data: data,
265
232
  fieldErrors: fieldErrors,
266
233
  externalFieldErrors: externalFieldErrors
267
234
  };
@@ -1,4 +1,4 @@
1
- import { ChangeEvent, ComponentType, MouseEventHandler, ReactNode, CSSProperties } from 'react';
1
+ import { ChangeEvent, ReactNode, CSSProperties, ComponentType, MouseEventHandler } from 'react';
2
2
  import { AllOptions } from '../inputs/select/types.js';
3
3
  import '../@types/Align.js';
4
4
  import '../@types/DataCombo.js';
@@ -17,7 +17,7 @@ type OnFielChangeEvent = Event & {
17
17
  type CustomKeyboardEvent = ChangeEvent<HTMLInputElement> & {
18
18
  keyCode: number;
19
19
  };
20
- type BaseFormProps = {
20
+ interface IFormProps {
21
21
  dataSource: object;
22
22
  children: ReactNode;
23
23
  onSubmit: (data: object) => void;
@@ -28,6 +28,7 @@ type BaseFormProps = {
28
28
  submitOnPressEnterKey?: boolean;
29
29
  style?: CSSProperties;
30
30
  customClass?: string;
31
+ onDataChange?: (data: object) => void;
31
32
  securityBeforeUnload?: boolean;
32
33
  securityTitle?: string;
33
34
  securityText?: string;
@@ -35,21 +36,10 @@ type BaseFormProps = {
35
36
  externalFieldErrors?: object;
36
37
  skeletonize?: boolean;
37
38
  disabled?: boolean;
38
- };
39
- type FormProps = BaseFormProps & ({
40
- useInternalState?: false;
41
- onDataChange: (data: object) => void;
42
- } | {
43
- useInternalState: true;
44
- onDataChange?: (data: object) => void;
45
- });
46
- type Data = {
47
- [key: string]: any;
48
- };
39
+ }
49
40
  interface IFieldProps extends WithFieldProps {
50
- data?: Data;
51
- originalData?: Data;
52
- dataSource?: Data;
41
+ data?: object;
42
+ dataSource?: object;
53
43
  name: string;
54
44
  value?: string;
55
45
  label?: string;
@@ -88,9 +78,8 @@ interface CustomEvent {
88
78
  };
89
79
  }
90
80
  interface IFieldArrayProps extends WithFieldProps {
91
- data?: Data;
92
- originalData?: Data;
93
- dataSource?: Data;
81
+ data?: object;
82
+ dataSource?: object;
94
83
  name: string;
95
84
  handlerFieldChange?: (event: CustomEvent) => void;
96
85
  fieldErrors?: {
@@ -113,8 +102,6 @@ interface IFieldArrayProps extends WithFieldProps {
113
102
  gridLayout?: string;
114
103
  multiple?: boolean;
115
104
  disabled?: boolean;
116
- onBlur?: (event: ChangeEvent<HTMLInputElement>) => void;
117
- handlerFieldValidade?: (name: string, value: string, validatorsArray: Validator[] | Validator) => void;
118
105
  }
119
106
  type PeriodChangeEvent = {
120
107
  initial: string;
@@ -127,8 +114,7 @@ type PeriodFieldChangeEvent = {
127
114
  };
128
115
  };
129
116
  interface IFieldPeriodProps extends WithFieldProps {
130
- data?: Data;
131
- originalData?: Data;
117
+ data?: object;
132
118
  nameDateInitial: string;
133
119
  nameDateFinal: string;
134
120
  handlerFieldChange?: (event: PeriodFieldChangeEvent) => PeriodFieldChangeEvent;
@@ -147,10 +133,9 @@ interface FormContextProps {
147
133
  skeletonize?: boolean;
148
134
  handlerFieldChange: (event: OnFielChangeEvent) => void;
149
135
  handlerFieldValidade: (name: string, value: string, validatorsArray: Validator[] | Validator) => void;
150
- handlerStoreValidators: (fieldName: string, fieldValidates: Validator) => void;
136
+ handlerStoreValidators: (fieldName: string, fieldValidates: object) => void;
151
137
  handlerRemoveValidators: (fieldName: string) => void;
152
138
  data: object;
153
- originalData: object;
154
139
  fieldErrors: object;
155
140
  externalFieldErrors?: object;
156
141
  }
@@ -161,7 +146,6 @@ interface WithFieldProps {
161
146
  validators?: Validator | Validator[] | PeriodValidator | PeriodValidator[];
162
147
  }
163
148
  interface IWithFieldContext {
164
- validatorFromComponent: Validator | Validator[] | undefined;
165
149
  handlerSetValidatorFromComponent: (validator: Validator | Validator[]) => void;
166
150
  }
167
151
  interface IWithFormSecurity {
@@ -187,7 +171,6 @@ interface IEventParams {
187
171
  handlerFieldValidade?: (name: string, value: string, validatorsArray: Validator[] | Validator) => void;
188
172
  handlerFieldChange?: (event: ChangeEvent<HTMLInputElement> | CustomKeyboardEvent) => void;
189
173
  validatorFromComponent?: Validator | Validator[];
190
- handleShowValidateMessages: (value: boolean) => void;
191
174
  }
192
175
  interface IGetErrorMessagesParams {
193
176
  name: string;
@@ -199,11 +182,5 @@ interface IGetErrorMessagesParams {
199
182
  };
200
183
  externalMessagesErrors?: string[];
201
184
  }
202
- type FieldErrors = {
203
- [name: string]: string[];
204
- };
205
- type FieldValidator = {
206
- [name: string]: Validator | Validator[];
207
- };
208
185
 
209
- export { CustomEvent, CustomKeyboardEvent, FieldErrors, FieldValidator, FormContextProps, FormProps, IEventParams, IFieldArrayProps, IFieldPeriodProps, IFieldProps, IFormSecurityContext, IGetErrorMessagesParams, IWithFieldContext, IWithFormSecurity, OnFielChangeEvent, PeriodChangeEvent, PeriodValidator, Validator, WithFieldProps };
186
+ export { CustomEvent, CustomKeyboardEvent, FormContextProps, IEventParams, IFieldArrayProps, IFieldPeriodProps, IFieldProps, IFormProps, IFormSecurityContext, IGetErrorMessagesParams, IWithFieldContext, IWithFormSecurity, OnFielChangeEvent, PeriodChangeEvent, PeriodValidator, Validator, WithFieldProps };
@@ -40,7 +40,6 @@ var withFieldHOC = function withFieldHOC(WrappedComponent) {
40
40
  updateValidators();
41
41
  }, [validators]);
42
42
  var contextValues = {
43
- validatorFromComponent: validatorFromComponent,
44
43
  handlerSetValidatorFromComponent: function handlerSetValidatorFromComponent(validator) {
45
44
  setValidatorFromComponent(validator);
46
45
  }
@@ -579,6 +579,14 @@ declare const _default: {
579
579
  viewbox: string;
580
580
  paths: string[];
581
581
  };
582
+ keyboard: {
583
+ viewbox: string;
584
+ paths: string[];
585
+ };
586
+ download: {
587
+ viewbox: string;
588
+ paths: string[];
589
+ };
582
590
  };
583
591
 
584
592
  export { _default as default };
@@ -584,6 +584,14 @@ var _default = {
584
584
  select2: {
585
585
  viewbox: '0 0 16 16',
586
586
  paths: ['M13.002 14.658v0l-2.16-4.329 4.278-0.74-10.119-7.589v12.649l3.158-2.978 2.16 4.329z', 'M1 10.5v-9c0-0.271 0.229-0.5 0.5-0.5h11c0.271 0 0.5 0.229 0.5 0.5v4l1 0.75v-4.75c0-0.825-0.675-1.5-1.5-1.5h-11c-0.825 0-1.5 0.675-1.5 1.5v9c0 0.825 0.675 1.5 1.5 1.5h1.5v-1h-1.5c-0.271 0-0.5-0.229-0.5-0.5z']
587
+ },
588
+ keyboard: {
589
+ viewbox: '0 0 16 16',
590
+ paths: ['M14 4h-13c-0.55 0-1 0.45-1 1v7c0 0.55 0.45 1 1 1h13c0.55 0 1-0.45 1-1v-7c0-0.55-0.45-1-1-1zM14 11.998c-0.001 0.001-0.001 0.001-0.002 0.002h-12.996c-0.001-0.001-0.001-0.001-0.002-0.002v-6.996c0.001-0.001 0.001-0.001 0.002-0.002h12.996c0.001 0.001 0.001 0.001 0.002 0.002v6.996zM4 10h7v1h-7zM11 8h1v1h-1zM9 8h1v1h-1zM7 8h1v1h-1zM5 8h1v1h-1zM3 8h1v1h-1zM10 6h1v1h-1zM12 6h1v1h-1zM8 6h1v1h-1zM6 6h1v1h-1zM4 6h1v1h-1zM2 6h1v1h-1z']
591
+ },
592
+ download: {
593
+ viewbox: '0 0 16 16',
594
+ paths: ['M12.5 6h-3.5v-4h-2v4h-3.5l4.5 4zM11.611 8.322l-0.525 0.462c1.746 0.35 2.914 0.987 2.914 1.716 0 1.105-2.686 2-6 2s-6-0.895-6-2c0-0.728 1.168-1.366 2.914-1.716l-0.525-0.462c-2.604 0.495-4.389 1.508-4.389 2.678 0 1.657 3.582 3 8 3s8-1.343 8-3c0-1.17-1.785-2.183-4.389-2.678z']
587
595
  }
588
596
  };
589
597
  exports.default = _default;
@@ -29,7 +29,6 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
29
29
  var CALENDAR_BUTTON_WIDTH = 24;
30
30
  var CALENDAR_MIN_WIDTH = 250;
31
31
  var DatePicker = function DatePicker(props) {
32
- var _window;
33
32
  var _props$showButtonOpen = props.showButtonOpen,
34
33
  showButtonOpen = _props$showButtonOpen === void 0 ? true : _props$showButtonOpen,
35
34
  _props$openOnFocus = props.openOnFocus,
@@ -224,7 +223,7 @@ var DatePicker = function DatePicker(props) {
224
223
  } else {
225
224
  setFormatedLeftPosition(inputDimensions === null || inputDimensions === void 0 ? void 0 : inputDimensions.left);
226
225
  }
227
- }, [(_window = window) === null || _window === void 0 ? void 0 : _window.innerWidth, inputDimensions]);
226
+ }, [getWrapperComponent]);
228
227
  if (onDenied && onDenied.unvisible) return null;
229
228
  (0, _react.useEffect)(function () {
230
229
  window.addEventListener('resize', onScreenResize);
@@ -45,11 +45,11 @@ var CpfField = function CpfField(props) {
45
45
  return debouncedOnChange.cancel;
46
46
  }, []);
47
47
  var onChange = function onChange(e) {
48
- // console.log('onChange >>>', props.onChange);
49
48
  if (enableValidation && e) {
50
49
  debouncedOnChange(e.target.value);
51
50
  if (props.onChange) props.onChange(e);
52
- } else if (props.onChange) {
51
+ }
52
+ if (props.onChange) {
53
53
  props.onChange(e);
54
54
  }
55
55
  };
@@ -61,10 +61,10 @@ var CpfField = function CpfField(props) {
61
61
  }
62
62
  return {};
63
63
  };
64
- return /*#__PURE__*/_react.default.createElement(_BaseMask.default, _extends({}, props, {
64
+ return /*#__PURE__*/_react.default.createElement(_BaseMask.default, _extends({
65
65
  onChange: onChange,
66
66
  mask: "000.000.000-00"
67
- }, getErrorMessagesProp()));
67
+ }, props, getErrorMessagesProp()));
68
68
  };
69
69
 
70
70
  // Em caso de alteração na propriedade displayName deverá ser atualizada a lógica na função
@@ -9,6 +9,7 @@ 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;
12
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14
  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); }
14
15
  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; }
@@ -99,7 +100,7 @@ var IMaskHOC = function IMaskHOC(ComposedComponent) {
99
100
  maskRef.current.value = String(newValue);
100
101
  }
101
102
  };
102
- var onAccept = (0, _react.useCallback)(function () {
103
+ var onAccept = function onAccept() {
103
104
  if (onChange && !disableCallbacks && maskRef.current) {
104
105
  var _maskRef$current = maskRef.current,
105
106
  unmaskedValue = _maskRef$current.unmaskedValue,
@@ -112,8 +113,8 @@ var IMaskHOC = function IMaskHOC(ComposedComponent) {
112
113
  }
113
114
  }, props.unmask ? unmaskedValue : maskRef.current.value);
114
115
  }
115
- }, [onChange]);
116
- var onComplete = (0, _react.useCallback)(function () {
116
+ };
117
+ var onComplete = function onComplete() {
117
118
  if (props.onComplete && !disableCallbacks && maskRef.current) {
118
119
  var _maskRef$current2 = maskRef.current,
119
120
  unmaskedValue = _maskRef$current2.unmaskedValue,
@@ -126,14 +127,13 @@ var IMaskHOC = function IMaskHOC(ComposedComponent) {
126
127
  }
127
128
  }, props.unmask ? unmaskedValue : maskRef.current.value);
128
129
  }
129
- }, [props.onComplete]);
130
+ };
130
131
  var getMask = function getMask() {
131
132
  var element = elementRef.current;
132
133
  if (element) {
133
134
  var maskCurrent = maskRef.current;
134
135
  if (!maskCurrent) {
135
- maskRef.current = (0, _imask.default)(element, maskOptions);
136
- if (value && typeof value !== 'number' && value.trim() !== '' || value && typeof value === 'number') onAccept();
136
+ maskRef.current = (0, _imask.default)(element, maskOptions).on('accept', onAccept.bind(_this)).on('complete', onComplete.bind(_this));
137
137
  setValue(value);
138
138
  } else {
139
139
  maskCurrent.updateOptions(maskOptions);
@@ -150,19 +150,14 @@ 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);
159
153
 
160
154
  // eslint-disable-next-line consistent-return
161
155
  return function () {
162
- maskCurrent.off('accept', onAccept);
163
- maskCurrent.off('complete', onComplete);
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);
164
159
  };
165
- }, [onAccept, onComplete]);
160
+ }, [maskOptions]);
166
161
  (0, _react.useEffect)(function () {
167
162
  if (maskOptions.mask && !dontInitMask) {
168
163
  if (maskRef.current) {
@@ -187,6 +182,7 @@ var IMaskHOC = function IMaskHOC(ComposedComponent) {
187
182
  },
188
183
  inputRef: function inputRef(el) {
189
184
  elementRef.current = el;
185
+ // Propagate the input ref for who call it
190
186
  if (_inputRef) {
191
187
  if (_typeof(_inputRef) === 'object') _inputRef.current = el;else _inputRef(el);
192
188
  }
@@ -24,12 +24,13 @@ 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
- return _objectSpread(_objectSpread({}, event), {}, {
27
+ var teste = _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;
33
34
  }
34
35
  return event;
35
36
  };
@@ -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.replaceAll('.', '').replaceAll(',', '.');
17
+ formattedNumber = value.replace('.', '').replace(',', '.');
18
18
  return Number(formattedNumber);
19
19
  }
20
20
  return value;
@@ -31,6 +31,7 @@ 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;
34
35
  var _props$showButtonOpen = props.showButtonOpen,
35
36
  showButtonOpen = _props$showButtonOpen === void 0 ? true : _props$showButtonOpen,
36
37
  _props$openOnFocus = props.openOnFocus,
@@ -137,7 +138,7 @@ var PeriodPicker = function PeriodPicker(props) {
137
138
  setValueInitial(newValueInitial);
138
139
  setValueFinal(newValueFinal);
139
140
  }
140
- }, [props.value]);
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]);
141
142
  var openCalendar = function openCalendar() {
142
143
  setShowCalendar(true);
143
144
  setShowPeriodSelection(false);
@@ -89,6 +89,10 @@ 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];
92
96
  var dropdownRef = (0, _react.useRef)(null);
93
97
  var componentId = "select-component".concat(_uuid.default.v1());
94
98
  var componentRef = (0, _react.useRef)(null);
@@ -237,13 +241,14 @@ var SimpleSelect = function SimpleSelect(props) {
237
241
  }
238
242
  }, [gridLayout]);
239
243
  (0, _react.useEffect)(function () {
240
- if (dataSourceWithAllOptions.length > 0) {
244
+ if (value !== valueFromProps && dataSourceWithAllOptions.length > 0) {
241
245
  var newCurrent = null;
242
- if (value || value === 0) {
246
+ if (value) {
243
247
  newCurrent = dataSourceWithAllOptions.find(function (i) {
244
248
  var _i$idKey;
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());
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());
246
250
  });
251
+ setValueFromProps(value);
247
252
  } else if (dataSourceWithAllOptions.length > 0 && selectFirstOnEnter) {
248
253
  newCurrent = dataSourceWithAllOptions[0];
249
254
  }
@@ -0,0 +1,7 @@
1
+ import { IShortcutsProps } from './types.js';
2
+ import 'react';
3
+ import '../@types/ColorStyles.js';
4
+
5
+ declare const Shortcuts: ({ type, style, styleShortcut, shortcut, description }: IShortcutsProps) => JSX.Element;
6
+
7
+ export { Shortcuts as default };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ require("../assets/styles/shortcuts.scss");
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ var Shortcuts = function Shortcuts(_ref) {
11
+ var type = _ref.type,
12
+ style = _ref.style,
13
+ styleShortcut = _ref.styleShortcut,
14
+ shortcut = _ref.shortcut,
15
+ description = _ref.description;
16
+ return /*#__PURE__*/_react.default.createElement("p", {
17
+ "data-testid": "description",
18
+ className: "shortcut-description",
19
+ style: style
20
+ }, /*#__PURE__*/_react.default.createElement("kbd", {
21
+ "data-testid": "shortcut",
22
+ className: "shortcut-component ".concat(type && "-".concat(type)),
23
+ style: styleShortcut
24
+ }, shortcut), ":\xA0", description);
25
+ };
26
+ var _default = Shortcuts;
27
+ exports.default = _default;
@@ -0,0 +1,12 @@
1
+ import { CSSProperties } from 'react';
2
+ import { ColorStyles } from '../@types/ColorStyles.js';
3
+
4
+ interface IShortcutsProps {
5
+ type?: ColorStyles;
6
+ style?: CSSProperties;
7
+ styleShortcut?: CSSProperties;
8
+ shortcut: string;
9
+ description: string;
10
+ }
11
+
12
+ export { IShortcutsProps };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linear-react-components-ui",
3
- "version": "1.0.10-beta.25",
3
+ "version": "1.0.10-beta.27",
4
4
  "description": "Linear Sistemas ReactJs Components",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.cjs",