iguazio.dashboard-react-controls 0.0.27 → 0.0.29

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.
Files changed (34) hide show
  1. package/dist/components/ConfirmDialog/ConfirmDialog.js +1 -1
  2. package/dist/components/FormChipCell/FormChip/FormChip.js +4 -4
  3. package/dist/components/FormChipCell/FormChipCell.js +14 -14
  4. package/dist/components/FormChipCell/FormChipCellView.js +8 -8
  5. package/dist/components/FormChipCell/NewChipForm/NewChipForm.js +9 -9
  6. package/dist/components/FormChipCell/NewChipForm/newChipForm.scss +5 -2
  7. package/dist/components/FormCombobox/FormCombobox.js +3 -1
  8. package/dist/components/FormCombobox/formCombobox.scss +0 -5
  9. package/dist/components/FormInput/FormInput.js +66 -51
  10. package/dist/components/FormInput/InputNumberButtons/InputNumberButtons.js +2 -2
  11. package/dist/components/FormKeyValueTable/FormKeyValueTable.js +137 -265
  12. package/dist/components/FormSelect/FormSelect.js +4 -1
  13. package/dist/components/FormSelect/formSelect.scss +1 -16
  14. package/dist/components/Modal/Modal.scss +2 -2
  15. package/dist/components/PopUpDialog/PopUpDialog.js +7 -2
  16. package/dist/components/Wizard/Wizard.js +16 -7
  17. package/dist/components/Wizard/Wizard.scss +6 -2
  18. package/dist/elements/FormActionButton/FormActionButton.js +71 -0
  19. package/dist/elements/FormRowActions/FormRowActions.js +103 -0
  20. package/dist/elements/OptionsMenu/OptionsMenu.js +1 -0
  21. package/dist/elements/OptionsMenu/optionsMenu.scss +0 -4
  22. package/dist/elements/SelectOption/SelectOption.js +6 -2
  23. package/dist/elements/SelectOption/selectOption.scss +6 -0
  24. package/dist/elements/index.js +16 -0
  25. package/dist/hooks/useFormTable.hook.js +198 -0
  26. package/dist/images/mlrun-logo-small.png +0 -0
  27. package/dist/scss/colors.scss +1 -0
  28. package/dist/scss/common.scss +130 -0
  29. package/dist/types.js +15 -18
  30. package/dist/utils/common.util.js +23 -1
  31. package/dist/utils/form.util.js +44 -20
  32. package/dist/utils/validation.util.js +8 -0
  33. package/package.json +2 -2
  34. package/dist/components/FormKeyValueTable/formKeyValueTable.scss +0 -117
@@ -64,7 +64,7 @@ var ConfirmDialog = function ConfirmDialog(_ref) {
64
64
 
65
65
  var handleConfirmDialog = function handleConfirmDialog(event) {
66
66
  onResolve && onResolve();
67
- confirmButton.handler(event);
67
+ confirmButton.handler && confirmButton.handler(event);
68
68
  };
69
69
 
70
70
  return isOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(_PopUpDialog.default, {
@@ -40,7 +40,7 @@ var FormChip = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
40
40
  handleRemoveChip = _ref.handleRemoveChip,
41
41
  handleToEditMode = _ref.handleToEditMode,
42
42
  isDeleteMode = _ref.isDeleteMode,
43
- isEditMode = _ref.isEditMode,
43
+ isEditable = _ref.isEditable,
44
44
  keyName = _ref.keyName,
45
45
  meta = _ref.meta,
46
46
  setChipsSizes = _ref.setChipsSizes,
@@ -69,7 +69,7 @@ var FormChip = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
69
69
  className: "input-label-key",
70
70
  editConfig: editConfig,
71
71
  handleRemoveChip: handleRemoveChip,
72
- isEditMode: isEditMode,
72
+ isEditable: isEditable,
73
73
  keyName: keyName,
74
74
  meta: meta,
75
75
  onChange: handleEditChip,
@@ -91,7 +91,7 @@ FormChip.defaultProps = {
91
91
  font: 'purple'
92
92
  },
93
93
  isDeleteMode: false,
94
- isEditMode: false,
94
+ isEditable: false,
95
95
  keyName: '',
96
96
  validationRules: {},
97
97
  valueName: ''
@@ -105,7 +105,7 @@ FormChip.propTypes = {
105
105
  handleRemoveChip: _propTypes.default.func.isRequired,
106
106
  handleToEditMode: _propTypes.default.func.isRequired,
107
107
  isDeleteMode: _propTypes.default.bool,
108
- isEditMode: _propTypes.default.bool,
108
+ isEditable: _propTypes.default.bool,
109
109
  keyName: _propTypes.default.string,
110
110
  meta: _propTypes.default.object.isRequired,
111
111
  setChipsSizes: _propTypes.default.func.isRequired,
@@ -60,7 +60,7 @@ var FormChipCell = function FormChipCell(_ref) {
60
60
  delimiter = _ref.delimiter,
61
61
  formState = _ref.formState,
62
62
  initialValues = _ref.initialValues,
63
- isEditMode = _ref.isEditMode,
63
+ isEditable = _ref.isEditable,
64
64
  label = _ref.label,
65
65
  name = _ref.name,
66
66
  onClick = _ref.onClick,
@@ -103,20 +103,20 @@ var FormChipCell = function FormChipCell(_ref) {
103
103
  var chipsCellRef = (0, _react.useRef)();
104
104
  var chipsWrapperRef = (0, _react.useRef)();
105
105
  var handleShowElements = (0, _react.useCallback)(function () {
106
- if (!isEditMode || isEditMode && visibleChipsMaxLength) {
106
+ if (!isEditable || isEditable && visibleChipsMaxLength) {
107
107
  setShowHiddenChips(function (state) {
108
108
  return !state;
109
109
  });
110
110
  }
111
- }, [isEditMode, visibleChipsMaxLength]);
111
+ }, [isEditable, visibleChipsMaxLength]);
112
112
  var chips = (0, _react.useMemo)(function () {
113
- return isEditMode || visibleChipsMaxLength === 'all' ? {
113
+ return isEditable || visibleChipsMaxLength === 'all' ? {
114
114
  visibleChips: (0, _lodash.get)(formState.values, name),
115
115
  hiddenChips: []
116
116
  } : (0, _generateChipsList.generateChipsList)((0, _lodash.get)(formState.values, name), visibleChipsMaxLength ? visibleChipsMaxLength : visibleChipsCount);
117
- }, [visibleChipsMaxLength, isEditMode, visibleChipsCount, formState.values, name]);
117
+ }, [visibleChipsMaxLength, isEditable, visibleChipsCount, formState.values, name]);
118
118
  var handleResize = (0, _react.useCallback)(function () {
119
- if (!isEditMode && !(0, _common.isEveryObjectValueEmpty)(chipsSizes)) {
119
+ if (!isEditable && !(0, _common.isEveryObjectValueEmpty)(chipsSizes)) {
120
120
  var _chipsCellRef$current;
121
121
 
122
122
  var parentSize = (_chipsCellRef$current = chipsCellRef.current) === null || _chipsCellRef$current === void 0 ? void 0 : _chipsCellRef$current.getBoundingClientRect().width;
@@ -140,18 +140,18 @@ var FormChipCell = function FormChipCell(_ref) {
140
140
  setVisibleChipsCount(chipIndex);
141
141
  setShowChips(true);
142
142
  }
143
- }, [chipsSizes, isEditMode]);
143
+ }, [chipsSizes, isEditable]);
144
144
  (0, _react.useEffect)(function () {
145
145
  handleResize();
146
146
  }, [handleResize, showChips]);
147
147
  (0, _react.useEffect)(function () {
148
- if (!isEditMode) {
148
+ if (!isEditable) {
149
149
  window.addEventListener('resize', handleResize);
150
150
  return function () {
151
151
  return window.removeEventListener('resize', handleResize);
152
152
  };
153
153
  }
154
- }, [handleResize, isEditMode]);
154
+ }, [handleResize, isEditable]);
155
155
  (0, _react.useEffect)(function () {
156
156
  window.addEventListener('mainResize', handleResize);
157
157
  return function () {
@@ -262,7 +262,7 @@ var FormChipCell = function FormChipCell(_ref) {
262
262
  event && event.preventDefault();
263
263
  }, [editConfig.chipIndex, handleRemoveChip, checkChipsList, formState.values, name]);
264
264
  var handleToEditMode = (0, _react.useCallback)(function (event, index) {
265
- if (isEditMode) {
265
+ if (isEditable) {
266
266
  event.stopPropagation();
267
267
  setEditConfig(function (preState) {
268
268
  return _objectSpread(_objectSpread({}, preState), {}, {
@@ -275,7 +275,7 @@ var FormChipCell = function FormChipCell(_ref) {
275
275
  }
276
276
 
277
277
  onClick && onClick();
278
- }, [isEditMode, onClick]);
278
+ }, [isEditable, onClick]);
279
279
 
280
280
  var validateFields = function validateFields(fieldsArray) {
281
281
  var uniquenessValidator = function uniquenessValidator(newValue, idx) {
@@ -378,7 +378,7 @@ var FormChipCell = function FormChipCell(_ref) {
378
378
  handleRemoveChip: handleRemoveChip,
379
379
  handleShowElements: handleShowElements,
380
380
  handleToEditMode: handleToEditMode,
381
- isEditMode: isEditMode,
381
+ isEditable: isEditable,
382
382
  name: name,
383
383
  ref: {
384
384
  chipsCellRef: chipsCellRef,
@@ -406,7 +406,7 @@ FormChipCell.defaultProps = {
406
406
  font: 'purple'
407
407
  },
408
408
  delimiter: null,
409
- isEditMode: false,
409
+ isEditable: false,
410
410
  label: null,
411
411
  onClick: function onClick() {},
412
412
  shortChips: false,
@@ -419,7 +419,7 @@ FormChipCell.propTypes = {
419
419
  delimiter: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]),
420
420
  formState: _propTypes.default.shape({}).isRequired,
421
421
  initialValues: _propTypes.default.object.isRequired,
422
- isEditMode: _propTypes.default.bool,
422
+ isEditable: _propTypes.default.bool,
423
423
  label: _propTypes.default.string,
424
424
  name: _propTypes.default.string.isRequired,
425
425
  onClick: _propTypes.default.func,
@@ -58,7 +58,7 @@ var FormChipCellView = /*#__PURE__*/_react.default.forwardRef(function (_ref, _r
58
58
  _handleRemoveChip = _ref.handleRemoveChip,
59
59
  handleShowElements = _ref.handleShowElements,
60
60
  handleToEditMode = _ref.handleToEditMode,
61
- isEditMode = _ref.isEditMode,
61
+ isEditable = _ref.isEditable,
62
62
  name = _ref.name,
63
63
  setChipsSizes = _ref.setChipsSizes,
64
64
  setEditConfig = _ref.setEditConfig,
@@ -70,8 +70,8 @@ var FormChipCellView = /*#__PURE__*/_react.default.forwardRef(function (_ref, _r
70
70
  var chipsCellRef = _ref2.chipsCellRef,
71
71
  chipsWrapperRef = _ref2.chipsWrapperRef;
72
72
  var buttonAddClassNames = (0, _classnames.default)('button-add', chipOptions.background && "button-add-background_".concat(chipOptions.background), chipOptions.borderColor && "button-add-border_".concat(chipOptions.borderColor), chipOptions.font && "button-add-font_".concat(chipOptions.font), chipOptions.density && "button-add-density_".concat(chipOptions.density));
73
- var wrapperClassNames = (0, _classnames.default)('chips-wrapper', isEditMode && 'fixed-max-width');
74
- var chipClassNames = (0, _classnames.default)('chip', 'chip__content', isEditMode && 'data-ellipsis', shortChips && 'chip_short', chips.hiddenChips && 'chip_hidden', chipOptions.density && "chip-density_".concat(chipOptions.density), chipOptions.borderRadius && "chip-border_".concat(chipOptions.borderRadius), chipOptions.background && "chip-background_".concat(chipOptions.background), chipOptions.borderColor && "chip-border_".concat(chipOptions.borderColor), chipOptions.font && "chip-font_".concat(chipOptions.font), isEditMode && 'editable', (showChips || isEditMode) && 'chip_visible');
73
+ var wrapperClassNames = (0, _classnames.default)('chips-wrapper', isEditable && 'fixed-max-width');
74
+ var chipClassNames = (0, _classnames.default)('chip', 'chip__content', isEditable && 'data-ellipsis', shortChips && 'chip_short', chips.hiddenChips && 'chip_hidden', chipOptions.density && "chip-density_".concat(chipOptions.density), chipOptions.borderRadius && "chip-border_".concat(chipOptions.borderRadius), chipOptions.background && "chip-background_".concat(chipOptions.background), chipOptions.borderColor && "chip-border_".concat(chipOptions.borderColor), chipOptions.font && "chip-font_".concat(chipOptions.font), isEditable && 'editable', (showChips || isEditable) && 'chip_visible');
75
75
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalFormArrays.FieldArray, {
76
76
  name: name,
77
77
  validate: validateFields,
@@ -85,7 +85,7 @@ var FormChipCellView = /*#__PURE__*/_react.default.forwardRef(function (_ref, _r
85
85
  validationRules.key.push(_formChipCell.uniquenessError);
86
86
  }
87
87
 
88
- return (isEditMode || !(0, _common.isEveryObjectValueEmpty)(fields)) && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
88
+ return (isEditable || !(0, _common.isEveryObjectValueEmpty)(fields)) && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
89
89
  className: "chips-cell",
90
90
  ref: chipsCellRef,
91
91
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
@@ -118,7 +118,7 @@ var FormChipCellView = /*#__PURE__*/_react.default.forwardRef(function (_ref, _r
118
118
  return _handleRemoveChip(event, fields, index);
119
119
  },
120
120
  handleToEditMode: handleToEditMode,
121
- isEditMode: isEditMode,
121
+ isEditable: isEditable,
122
122
  keyName: "".concat(contentItem, ".key"),
123
123
  meta: meta,
124
124
  ref: chipsCellRef,
@@ -143,7 +143,7 @@ var FormChipCellView = /*#__PURE__*/_react.default.forwardRef(function (_ref, _r
143
143
  onClick: handleShowElements,
144
144
  children: chips.hiddenChipsNumber
145
145
  })]
146
- }), isEditMode && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
146
+ }), isEditable && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
147
147
  className: buttonAddClassNames,
148
148
  onClick: function onClick(e) {
149
149
  return handleAddNewChip(e, fields);
@@ -165,7 +165,7 @@ FormChipCellView.defaultProps = {
165
165
  density: 'dense',
166
166
  font: 'purple'
167
167
  },
168
- isEditMode: false,
168
+ isEditable: false,
169
169
  shortChips: false,
170
170
  validationRules: {}
171
171
  };
@@ -178,7 +178,7 @@ FormChipCellView.propTypes = {
178
178
  handleRemoveChip: _propTypes.default.func.isRequired,
179
179
  handleShowElements: _propTypes.default.func.isRequired,
180
180
  handleToEditMode: _propTypes.default.func.isRequired,
181
- isEditMode: _propTypes.default.bool,
181
+ isEditable: _propTypes.default.bool,
182
182
  name: _propTypes.default.string.isRequired,
183
183
  setChipsSizes: _propTypes.default.func.isRequired,
184
184
  setEditConfig: _propTypes.default.func.isRequired,
@@ -62,7 +62,7 @@ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
62
62
  className = _ref.className,
63
63
  editConfig = _ref.editConfig,
64
64
  handleRemoveChip = _ref.handleRemoveChip,
65
- isEditMode = _ref.isEditMode,
65
+ isEditable = _ref.isEditable,
66
66
  keyName = _ref.keyName,
67
67
  meta = _ref.meta,
68
68
  onChange = _ref.onChange,
@@ -125,8 +125,8 @@ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
125
125
  if (chipData.key && chipData.value) {
126
126
  setChipData(function (prevState) {
127
127
  return _objectSpread(_objectSpread({}, prevState), {}, {
128
- keyFieldWidth: currentWidthKeyInput >= maxWidthInput ? maxWidthInput : currentWidthKeyInput,
129
- valueFieldWidth: currentWidthValueInput >= maxWidthInput ? maxWidthInput : currentWidthValueInput
128
+ keyFieldWidth: currentWidthKeyInput >= maxWidthInput ? maxWidthInput : currentWidthKeyInput <= minWidthInput ? minWidthInput : currentWidthKeyInput,
129
+ valueFieldWidth: currentWidthValueInput >= maxWidthInput ? maxWidthInput : currentWidthValueInput <= minWidthValueInput ? minWidthValueInput : currentWidthValueInput
130
130
  });
131
131
  });
132
132
  } else {
@@ -187,7 +187,7 @@ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
187
187
  var focusChip = (0, _react.useCallback)(function (event) {
188
188
  event.stopPropagation();
189
189
 
190
- if (editConfig.chipIndex === chipIndex && isEditMode) {
190
+ if (editConfig.chipIndex === chipIndex && isEditable) {
191
191
  if (!event.shiftKey && event.key === _constants.TAB && editConfig.isValueFocused) {
192
192
  onChange(event, _constants.TAB);
193
193
  } else if (event.shiftKey && event.key === _constants.TAB && editConfig.isKeyFocused) {
@@ -203,7 +203,7 @@ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
203
203
  });
204
204
  }
205
205
  }
206
- }, [editConfig, onChange, chipIndex, isEditMode]);
206
+ }, [editConfig, onChange, chipIndex, isEditable]);
207
207
  var handleOnFocus = (0, _react.useCallback)(function (event) {
208
208
  if (editConfig.chipIndex === chipIndex) {
209
209
  if (event.target.name === keyName) {
@@ -292,7 +292,7 @@ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
292
292
  ref: refInputContainer,
293
293
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_NewChipInput.default, {
294
294
  className: labelKeyClassName,
295
- disabled: !isEditMode || editConfig.chipIndex !== chipIndex,
295
+ disabled: !isEditable || editConfig.chipIndex !== chipIndex,
296
296
  name: keyName,
297
297
  onChange: handleOnChange,
298
298
  onFocus: handleOnFocus,
@@ -306,7 +306,7 @@ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
306
306
  children: ":"
307
307
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_NewChipInput.default, {
308
308
  className: labelValueClassName,
309
- disabled: !isEditMode || editConfig.chipIndex !== chipIndex,
309
+ disabled: !isEditable || editConfig.chipIndex !== chipIndex,
310
310
  name: valueName,
311
311
  onChange: handleOnChange,
312
312
  onFocus: handleOnFocus,
@@ -315,7 +315,7 @@ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
315
315
  style: {
316
316
  width: chipData.valueFieldWidth
317
317
  }
318
- }), editConfig.chipIndex !== chipIndex && isEditMode && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
318
+ }), editConfig.chipIndex !== chipIndex && isEditable && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
319
319
  className: "edit-chip__icon-close",
320
320
  onClick: function onClick(event) {
321
321
  return handleRemoveChip(event, chipIndex);
@@ -340,7 +340,7 @@ NewChipForm.propTypes = {
340
340
  className: _propTypes.default.string,
341
341
  editConfig: _propTypes.default.shape({}).isRequired,
342
342
  handleRemoveChip: _propTypes.default.func.isRequired,
343
- isEditMode: _propTypes.default.bool.isRequired,
343
+ isEditable: _propTypes.default.bool.isRequired,
344
344
  keyName: _propTypes.default.string.isRequired,
345
345
  meta: _propTypes.default.object.isRequired,
346
346
  onChange: _propTypes.default.func.isRequired,
@@ -22,13 +22,16 @@
22
22
  &_invalid {
23
23
  color: $amaranth;
24
24
  }
25
+
25
26
  &::placeholder {
26
27
  color: $spunPearl;
27
28
  }
28
29
  }
29
30
 
30
- &::placeholder {
31
- color: $primary;
31
+ &.input-label-key, &.input-label-value {
32
+ &::placeholder {
33
+ color: $topaz;
34
+ }
32
35
  }
33
36
  }
34
37
 
@@ -177,7 +177,7 @@ var FormCombobox = function FormCombobox(_ref) {
177
177
  setIsInvalid(meta.invalid && (meta.validating || meta.modified || meta.submitFailed && meta.touched));
178
178
  }, [meta.invalid, meta.modified, meta.submitFailed, meta.touched, meta.validating]);
179
179
  var handleOutsideClick = (0, _react.useCallback)(function (event) {
180
- if (comboboxRef.current && !comboboxRef.current.contains(event.target)) {
180
+ if (comboboxRef.current && !comboboxRef.current.contains(event.target) && suggestionListRef.current && !suggestionListRef.current.contains(event.target)) {
181
181
  setSearchIsFocused(false);
182
182
  setShowSelectDropdown(false);
183
183
  setShowSuggestionList(false);
@@ -423,6 +423,7 @@ var FormCombobox = function FormCombobox(_ref) {
423
423
  })
424
424
  })]
425
425
  }), showSelectDropdown && /*#__PURE__*/(0, _jsxRuntime.jsx)(_PopUpDialog.default, {
426
+ headerIsHidden: true,
426
427
  customPosition: {
427
428
  element: selectRef,
428
429
  position: 'bottom-right'
@@ -455,6 +456,7 @@ var FormCombobox = function FormCombobox(_ref) {
455
456
  type: "text",
456
457
  value: inputValue
457
458
  }), showSuggestionList && (dropdownList.length > 0 || searchIsFocused) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_PopUpDialog.default, {
459
+ headerIsHidden: true,
458
460
  customPosition: {
459
461
  element: selectRef,
460
462
  position: 'bottom-right'
@@ -103,11 +103,6 @@
103
103
  width: 100%;
104
104
  max-height: 250px;
105
105
  padding: 0;
106
- border-radius: 0;
107
-
108
- &__header {
109
- display: none;
110
- }
111
106
  }
112
107
  }
113
108
 
@@ -99,38 +99,44 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
99
99
  withoutBorder = _ref.withoutBorder,
100
100
  inputProps = _objectWithoutProperties(_ref, _excluded);
101
101
 
102
- var _useField = (0, _reactFinalForm.useField)(name),
103
- input = _useField.input,
104
- meta = _useField.meta;
105
-
106
- var _useState = (0, _react.useState)(false),
102
+ var _useState = (0, _react.useState)({}),
107
103
  _useState2 = _slicedToArray(_useState, 2),
108
- isInvalid = _useState2[0],
109
- setIsInvalid = _useState2[1];
104
+ fieldMeta = _useState2[0],
105
+ setFieldMeta = _useState2[1];
110
106
 
111
- var _useState3 = (0, _react.useState)(false),
107
+ var _useState3 = (0, _react.useState)({}),
112
108
  _useState4 = _slicedToArray(_useState3, 2),
113
- isFocused = _useState4[0],
114
- setIsFocused = _useState4[1];
109
+ fieldInput = _useState4[0],
110
+ setFieldInput = _useState4[1];
115
111
 
116
- var _useState5 = (0, _react.useState)(''),
112
+ var _useState5 = (0, _react.useState)(false),
117
113
  _useState6 = _slicedToArray(_useState5, 2),
118
- typedValue = _useState6[0],
119
- setTypedValue = _useState6[1];
114
+ isInvalid = _useState6[0],
115
+ setIsInvalid = _useState6[1];
120
116
 
121
- var _useState7 = (0, _react.useState)(RegExp(pattern)),
122
- _useState8 = _slicedToArray(_useState7, 1),
123
- validationPattern = _useState8[0];
117
+ var _useState7 = (0, _react.useState)(false),
118
+ _useState8 = _slicedToArray(_useState7, 2),
119
+ isFocused = _useState8[0],
120
+ setIsFocused = _useState8[1];
124
121
 
125
- var _useState9 = (0, _react.useState)(rules),
122
+ var _useState9 = (0, _react.useState)(''),
126
123
  _useState10 = _slicedToArray(_useState9, 2),
127
- validationRules = _useState10[0],
128
- setValidationRules = _useState10[1];
124
+ typedValue = _useState10[0],
125
+ setTypedValue = _useState10[1];
126
+
127
+ var _useState11 = (0, _react.useState)(RegExp(pattern)),
128
+ _useState12 = _slicedToArray(_useState11, 1),
129
+ validationPattern = _useState12[0];
130
+
131
+ var _useState13 = (0, _react.useState)(rules),
132
+ _useState14 = _slicedToArray(_useState13, 2),
133
+ validationRules = _useState14[0],
134
+ setValidationRules = _useState14[1];
129
135
 
130
- var _useState11 = (0, _react.useState)(false),
131
- _useState12 = _slicedToArray(_useState11, 2),
132
- showValidationRules = _useState12[0],
133
- setShowValidationRules = _useState12[1];
136
+ var _useState15 = (0, _react.useState)(false),
137
+ _useState16 = _slicedToArray(_useState15, 2),
138
+ showValidationRules = _useState16[0],
139
+ setShowValidationRules = _useState16[1];
134
140
 
135
141
  var wrapperRef = (0, _react.useRef)();
136
142
  (_ref2 = ref) !== null && _ref2 !== void 0 ? _ref2 : ref = wrapperRef;
@@ -142,16 +148,16 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
142
148
  var inputWrapperClassNames = (0, _classnames.default)('form-field__wrapper', "form-field__wrapper-".concat(density), disabled && 'form-field__wrapper-disabled', isInvalid && 'form-field__wrapper-invalid', withoutBorder && 'without-border');
143
149
  var labelClassNames = (0, _classnames.default)('form-field__label', disabled && 'form-field__label-disabled');
144
150
  (0, _react.useEffect)(function () {
145
- setTypedValue(String(input.value)); // convert from number to string
146
- }, [input.value]);
151
+ setTypedValue(String(fieldInput.value)); // convert from number to string
152
+ }, [fieldInput.value]);
147
153
  (0, _react.useEffect)(function () {
148
- setIsInvalid(meta.invalid && (meta.validating || meta.modified || meta.submitFailed && meta.touched));
149
- }, [meta.invalid, meta.modified, meta.submitFailed, meta.touched, meta.validating]);
154
+ setIsInvalid(fieldMeta.invalid && (fieldMeta.validating || fieldMeta.modified || fieldMeta.submitFailed && fieldMeta.touched));
155
+ }, [fieldMeta.invalid, fieldMeta.modified, fieldMeta.submitFailed, fieldMeta.touched, fieldMeta.validating]);
150
156
  (0, _react.useEffect)(function () {
151
- if (meta.valid && showValidationRules) {
157
+ if (fieldMeta.valid && showValidationRules) {
152
158
  setShowValidationRules(false);
153
159
  }
154
- }, [meta.valid, showValidationRules]);
160
+ }, [fieldMeta.valid, showValidationRules]);
155
161
  (0, _react.useEffect)(function () {
156
162
  if (showValidationRules) {
157
163
  window.addEventListener('scroll', handleScroll, true);
@@ -166,6 +172,17 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
166
172
  inputRef.current.focus();
167
173
  }
168
174
  }, [focused]);
175
+ (0, _react.useEffect)(function () {
176
+ setValidationRules(function () {
177
+ return rules.map(function (rule) {
178
+ return _objectSpread(_objectSpread({}, rule), {}, {
179
+ isValid: !fieldMeta.error || !Array.isArray(fieldMeta.error) ? true : !fieldMeta.error.some(function (err) {
180
+ return err.name === rule.name;
181
+ })
182
+ });
183
+ });
184
+ });
185
+ }, [fieldMeta.error, rules]);
169
186
 
170
187
  var getValidationRules = function getValidationRules() {
171
188
  return validationRules.map(function (_ref3) {
@@ -183,7 +200,7 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
183
200
  var handleInputBlur = function handleInputBlur(event) {
184
201
  var _event$relatedTarget;
185
202
 
186
- input.onBlur(event);
203
+ fieldInput.onBlur && fieldInput.onBlur(event);
187
204
 
188
205
  if (!event.relatedTarget || !((_event$relatedTarget = event.relatedTarget) !== null && _event$relatedTarget !== void 0 && _event$relatedTarget.closest('.form-field__suggestion-list'))) {
189
206
  setIsFocused(false);
@@ -192,7 +209,7 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
192
209
  };
193
210
 
194
211
  var handleInputFocus = function handleInputFocus(event) {
195
- input.onFocus(event);
212
+ fieldInput.onFocus && fieldInput.onFocus(event);
196
213
  setIsFocused(true);
197
214
  };
198
215
 
@@ -205,7 +222,7 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
205
222
  };
206
223
 
207
224
  var handleSuggestionClick = function handleSuggestionClick(item) {
208
- input.onChange && input.onChange(item);
225
+ fieldInput.onChange && fieldInput.onChange(item);
209
226
  setIsFocused(false);
210
227
  onBlur();
211
228
  };
@@ -217,24 +234,12 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
217
234
  });
218
235
  };
219
236
 
220
- (0, _react.useEffect)(function () {
221
- setValidationRules(function (prevState) {
222
- return prevState.map(function (rule) {
223
- return _objectSpread(_objectSpread({}, rule), {}, {
224
- isValid: !meta.error || !Array.isArray(meta.error) ? true : !meta.error.some(function (err) {
225
- return err.name === rule.name;
226
- })
227
- });
228
- });
229
- });
230
- }, [meta.error]);
231
-
232
- var validateField = function validateField(value) {
237
+ var validateField = function validateField(value, allValues) {
233
238
  var valueToValidate = (0, _lodash.isNil)(value) ? '' : String(value);
234
239
  if (!valueToValidate && !required || disabled) return;
235
240
  var validationError = null;
236
241
 
237
- if (!(0, _lodash.isEmpty)(validationRules)) {
242
+ if (!(0, _lodash.isEmpty)(rules)) {
238
243
  var _checkPatternsValidit = (0, _validation.checkPatternsValidity)(rules, valueToValidate),
239
244
  _checkPatternsValidit2 = _slicedToArray(_checkPatternsValidit, 2),
240
245
  newRules = _checkPatternsValidit2[0],
@@ -259,14 +264,14 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
259
264
  if (inputProps.max && +valueToValidate > +inputProps.max) {
260
265
  validationError = {
261
266
  name: 'maxValue',
262
- label: "Max value is ".concat(inputProps.max)
267
+ label: "The maximum value should be ".concat(inputProps.max)
263
268
  };
264
269
  }
265
270
 
266
271
  if (inputProps.min && +valueToValidate < +inputProps.min) {
267
272
  validationError = {
268
273
  name: 'minValue',
269
- label: "Min value is ".concat(inputProps.min)
274
+ label: "The minimum value should be ".concat(inputProps.min)
270
275
  };
271
276
  }
272
277
  }
@@ -290,7 +295,7 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
290
295
  }
291
296
 
292
297
  if (!validationError && validator) {
293
- validationError = validator(value);
298
+ validationError = validator(value, allValues);
294
299
  }
295
300
 
296
301
  return validationError;
@@ -301,6 +306,15 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
301
306
  return inputProps.type === 'number' ? +val : val;
302
307
  };
303
308
 
309
+ var setFieldData = (0, _lodash.debounce)(function (input, meta) {
310
+ if (!(0, _lodash.isEqual)(meta, fieldMeta)) {
311
+ setFieldMeta(meta);
312
+ }
313
+
314
+ if (!(0, _lodash.isEqual)(input, fieldInput)) {
315
+ setFieldInput(input);
316
+ }
317
+ }, 50);
304
318
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, {
305
319
  validate: validateField,
306
320
  name: name,
@@ -310,6 +324,7 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
310
324
 
311
325
  var input = _ref4.input,
312
326
  meta = _ref4.meta;
327
+ setFieldData(input, meta);
313
328
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
314
329
  ref: ref,
315
330
  className: formFieldClassNames,
@@ -429,7 +444,7 @@ FormInput.defaultProps = {
429
444
  pattern: null,
430
445
  placeholder: '',
431
446
  required: false,
432
- step: '1',
447
+ step: 1,
433
448
  suggestionList: [],
434
449
  tip: '',
435
450
  type: 'text',
@@ -457,7 +472,7 @@ FormInput.propTypes = {
457
472
  pattern: _propTypes.default.string,
458
473
  placeholder: _propTypes.default.string,
459
474
  required: _propTypes.default.bool,
460
- step: _propTypes.default.string,
475
+ step: _propTypes.default.number,
461
476
  suggestionList: _propTypes.default.arrayOf(_propTypes.default.string),
462
477
  tip: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]),
463
478
  type: _propTypes.default.string,
@@ -97,14 +97,14 @@ InputNumberButtons.defaultProps = {
97
97
  disabled: false,
98
98
  min: null,
99
99
  max: null,
100
- step: '1'
100
+ step: 1
101
101
  };
102
102
  InputNumberButtons.propTypes = {
103
103
  disabled: _propTypes.default.bool,
104
104
  min: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
105
105
  max: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
106
106
  onChange: _propTypes.default.func.isRequired,
107
- step: _propTypes.default.string,
107
+ step: _propTypes.default.number,
108
108
  value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]).isRequired
109
109
  };
110
110