iguazio.dashboard-react-controls 1.9.2 → 2.0.0

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 (56) hide show
  1. package/dist/components/Backdrop/Backdrop.js +7 -7
  2. package/dist/components/Button/Button.js +20 -26
  3. package/dist/components/ConfirmDialog/ConfirmDialog.js +18 -17
  4. package/dist/components/FormCheckBox/FormCheckBox.js +28 -32
  5. package/dist/components/FormChipCell/FormChip/FormChip.js +46 -50
  6. package/dist/components/FormChipCell/FormChipCell.js +122 -142
  7. package/dist/components/FormChipCell/FormChipCellView.js +44 -47
  8. package/dist/components/FormChipCell/HiddenChipsBlock/HiddenChipsBlock.js +23 -20
  9. package/dist/components/FormChipCell/NewChipForm/NewChipForm.js +129 -152
  10. package/dist/components/FormChipCell/NewChipInput/NewChipInput.js +24 -27
  11. package/dist/components/FormChipCell/formChipCell.util.js +6 -16
  12. package/dist/components/FormCombobox/FormCombobox.js +134 -195
  13. package/dist/components/FormInput/FormInput.js +134 -212
  14. package/dist/components/FormInput/InputNumberButtons/InputNumberButtons.js +15 -14
  15. package/dist/components/FormKeyValueTable/FormKeyValueTable.js +72 -72
  16. package/dist/components/FormRadio/FormRadio.js +21 -25
  17. package/dist/components/FormSelect/FormSelect.js +98 -126
  18. package/dist/components/FormSelect/FormSelect.test.js +56 -60
  19. package/dist/components/FormTextarea/FormTextarea.js +55 -71
  20. package/dist/components/FormToggle/FormToggle.js +25 -29
  21. package/dist/components/Modal/Modal.js +17 -18
  22. package/dist/components/PopUpDialog/PopUpDialog.js +53 -63
  23. package/dist/components/RoundedIcon/RoundedIcon.js +14 -13
  24. package/dist/components/Tip/Tip.js +58 -64
  25. package/dist/components/Tip/Tip.test.js +41 -64
  26. package/dist/components/Tooltip/Tooltip.js +75 -89
  27. package/dist/components/TooltipTemplate/ProducerTooltipTemplate.js +6 -5
  28. package/dist/components/TooltipTemplate/TextTooltipTemplate.js +10 -10
  29. package/dist/components/Wizard/Wizard.js +73 -107
  30. package/dist/components/Wizard/WizardSteps/WizardSteps.js +19 -20
  31. package/dist/components/index.js +18 -18
  32. package/dist/constants.js +26 -44
  33. package/dist/elements/FormActionButton/FormActionButton.js +12 -13
  34. package/dist/elements/FormRowActions/FormRowActions.js +19 -22
  35. package/dist/elements/OptionsMenu/OptionsMenu.js +10 -8
  36. package/dist/elements/SelectOption/SelectOption.js +14 -13
  37. package/dist/elements/SelectOption/SelectOption.test.js +39 -47
  38. package/dist/elements/ValidationTemplate/ValidationTemplate.js +7 -6
  39. package/dist/elements/index.js +5 -5
  40. package/dist/hooks/index.js +5 -5
  41. package/dist/hooks/useChipCell.hook.js +66 -85
  42. package/dist/hooks/useDebounce.hook.js +22 -24
  43. package/dist/hooks/useDetectOutsideClick.hook.js +4 -4
  44. package/dist/hooks/useFormTable.hook.js +99 -112
  45. package/dist/hooks/useHiddenChipsBlock.hook.js +40 -55
  46. package/dist/index.js +2 -3
  47. package/dist/scss/borders.scss +6 -0
  48. package/dist/scss/mixins.scss +32 -0
  49. package/dist/types.js +43 -67
  50. package/dist/utils/common.util.js +19 -23
  51. package/dist/utils/form.util.js +33 -39
  52. package/dist/utils/generateChipsList.util.js +7 -7
  53. package/dist/utils/getFirstScrollableParent.util.js +4 -10
  54. package/dist/utils/math.util.js +3 -3
  55. package/dist/utils/validation.util.js +74 -131
  56. package/package.json +34 -34
@@ -22,31 +22,29 @@ under the Apache 2.0 license is conditioned upon your compliance with
22
22
  such restriction.
23
23
  */
24
24
 
25
- var useDebounce = function useDebounce() {
26
- return function (validate, time) {
27
- var timeout = (0, _react.useRef)(null);
28
- var lastValue = (0, _react.useRef)(null);
29
- var lastResult = (0, _react.useRef)(null);
30
- return function (value) {
31
- return new Promise(function (resolve) {
32
- if (timeout.current) {
33
- timeout.current();
34
- }
35
- if (value !== lastValue.current) {
36
- var timerId = setTimeout(function () {
37
- lastValue.current = value;
38
- lastResult.current = validate(value);
39
- resolve(lastResult.current);
40
- }, time);
41
- timeout.current = function () {
42
- clearTimeout(timerId);
43
- resolve(true);
44
- };
45
- } else {
25
+ const useDebounce = () => (validate, time) => {
26
+ const timeout = (0, _react.useRef)(null);
27
+ const lastValue = (0, _react.useRef)(null);
28
+ const lastResult = (0, _react.useRef)(null);
29
+ return function (value) {
30
+ return new Promise(resolve => {
31
+ if (timeout.current) {
32
+ timeout.current();
33
+ }
34
+ if (value !== lastValue.current) {
35
+ const timerId = setTimeout(() => {
36
+ lastValue.current = value;
37
+ lastResult.current = validate(value);
46
38
  resolve(lastResult.current);
47
- }
48
- });
49
- };
39
+ }, time);
40
+ timeout.current = () => {
41
+ clearTimeout(timerId);
42
+ resolve(true);
43
+ };
44
+ } else {
45
+ resolve(lastResult.current);
46
+ }
47
+ });
50
48
  };
51
49
  };
52
50
  exports.useDebounce = useDebounce;
@@ -28,9 +28,9 @@ such restriction.
28
28
  * @param {React.node} ref
29
29
  * @param {function} handler A callback function to use on outside click
30
30
  */
31
- var useDetectOutsideClick = function useDetectOutsideClick(ref, handler) {
32
- (0, _react.useEffect)(function () {
33
- var onClick = function onClick(e) {
31
+ const useDetectOutsideClick = (ref, handler) => {
32
+ (0, _react.useEffect)(() => {
33
+ const onClick = e => {
34
34
  e.stopPropagation();
35
35
  // If the active element exists and is clicked outside of
36
36
  if (ref.current !== null && !ref.current.contains(e.target)) {
@@ -39,7 +39,7 @@ var useDetectOutsideClick = function useDetectOutsideClick(ref, handler) {
39
39
  };
40
40
  // If the item is active (ie open) then listen for clicks outside
41
41
  window.addEventListener('click', onClick);
42
- return function () {
42
+ return () => {
43
43
  window.removeEventListener('click', onClick);
44
44
  };
45
45
  }, [ref, handler]);
@@ -1,6 +1,5 @@
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
  });
@@ -8,36 +7,27 @@ exports.useFormTable = void 0;
8
7
  var _react = require("react");
9
8
  var _lodash = require("lodash");
10
9
  var _finalForm = require("final-form");
11
- 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; }
12
- 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; }
13
- 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; }
14
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
15
- 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); }
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
- Copyright 2019 Iguazio Systems Ltd.
23
-
24
- Licensed under the Apache License, Version 2.0 (the "License") with
25
- an addition restriction as set forth herein. You may not use this
26
- file except in compliance with the License. You may obtain a copy of
27
- the License at http://www.apache.org/licenses/LICENSE-2.0.
28
-
29
- Unless required by applicable law or agreed to in writing, software
30
- distributed under the License is distributed on an "AS IS" BASIS,
31
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
32
- implied. See the License for the specific language governing
33
- permissions and limitations under the License.
34
-
35
- In addition, you may not use the software for any purposes that are
36
- illegal under applicable law, and the grant of the foregoing license
37
- under the Apache 2.0 license is conditioned upon your compliance with
38
- such restriction.
39
- */
40
- var useFormTable = function useFormTable(formState, exitEditModeTriggerItem, onExitEditModeCallback) {
10
+ /*
11
+ Copyright 2019 Iguazio Systems Ltd.
12
+
13
+ Licensed under the Apache License, Version 2.0 (the "License") with
14
+ an addition restriction as set forth herein. You may not use this
15
+ file except in compliance with the License. You may obtain a copy of
16
+ the License at http://www.apache.org/licenses/LICENSE-2.0.
17
+
18
+ Unless required by applicable law or agreed to in writing, software
19
+ distributed under the License is distributed on an "AS IS" BASIS,
20
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
21
+ implied. See the License for the specific language governing
22
+ permissions and limitations under the License.
23
+
24
+ In addition, you may not use the software for any purposes that are
25
+ illegal under applicable law, and the grant of the foregoing license
26
+ under the Apache 2.0 license is conditioned upon your compliance with
27
+ such restriction.
28
+ */
29
+
30
+ const useFormTable = (formState, exitEditModeTriggerItem, onExitEditModeCallback) => {
41
31
  // `editingItem` should contain the `data` object with all fields that are used in the `formState`.
42
32
  // Properties that aren't used in the `formState` should be placed directly in the `editingItem` object
43
33
  // `editingItem` also has an `ui` property which is used internally in this hook
@@ -55,34 +45,30 @@ var useFormTable = function useFormTable(formState, exitEditModeTriggerItem, onE
55
45
  // index: <0|1|...> // index of the editing row
56
46
  // }
57
47
  // }
58
- var _useState = (0, _react.useState)(null),
59
- _useState2 = _slicedToArray(_useState, 2),
60
- editingItem = _useState2[0],
61
- setEditingItem = _useState2[1];
62
- var editingItemRef = (0, _react.useRef)(null);
63
- var editingItemErrorsRef = (0, _react.useRef)(null);
64
- var formStateRef = (0, _react.useRef)(null);
65
- var bottomScrollRef = (0, _react.useRef)(null);
66
- var onExitEditModeCallbackRef = (0, _react.useRef)(onExitEditModeCallback);
67
- (0, _react.useLayoutEffect)(function () {
68
- var tableErrors = (0, _lodash.get)(formState === null || formState === void 0 ? void 0 : formState.errors, editingItem === null || editingItem === void 0 ? void 0 : editingItem.ui.fieldsPath, []);
48
+ const [editingItem, setEditingItem] = (0, _react.useState)(null);
49
+ const editingItemRef = (0, _react.useRef)(null);
50
+ const editingItemErrorsRef = (0, _react.useRef)(null);
51
+ const formStateRef = (0, _react.useRef)(null);
52
+ const bottomScrollRef = (0, _react.useRef)(null);
53
+ const onExitEditModeCallbackRef = (0, _react.useRef)(onExitEditModeCallback);
54
+ (0, _react.useLayoutEffect)(() => {
55
+ const tableErrors = (0, _lodash.get)(formState === null || formState === void 0 ? void 0 : formState.errors, editingItem === null || editingItem === void 0 ? void 0 : editingItem.ui.fieldsPath, []);
69
56
  editingItemErrorsRef.current = (0, _lodash.get)(tableErrors, editingItem === null || editingItem === void 0 ? void 0 : editingItem.ui.index, null);
70
57
  }, [editingItem === null || editingItem === void 0 ? void 0 : editingItem.ui.fieldsPath, editingItem === null || editingItem === void 0 ? void 0 : editingItem.ui.index, formState === null || formState === void 0 ? void 0 : formState.errors]);
71
- (0, _react.useLayoutEffect)(function () {
58
+ (0, _react.useLayoutEffect)(() => {
72
59
  formStateRef.current = formState;
73
60
  }, [formState]);
74
- (0, _react.useLayoutEffect)(function () {
61
+ (0, _react.useLayoutEffect)(() => {
75
62
  onExitEditModeCallbackRef.current = onExitEditModeCallback;
76
63
  }, [onExitEditModeCallback]);
77
- var exitEditMode = function exitEditMode() {
64
+ const exitEditMode = () => {
78
65
  var _editingItemRef$curre;
79
66
  if ((_editingItemRef$curre = editingItemRef.current) !== null && _editingItemRef$curre !== void 0 && _editingItemRef$curre.data) {
80
67
  var _editingItemRef$curre2;
81
- Object.entries((_editingItemRef$curre2 = editingItemRef.current) === null || _editingItemRef$curre2 === void 0 ? void 0 : _editingItemRef$curre2.data).forEach(function (_ref) {
68
+ Object.entries((_editingItemRef$curre2 = editingItemRef.current) === null || _editingItemRef$curre2 === void 0 ? void 0 : _editingItemRef$curre2.data).forEach(_ref => {
82
69
  var _formStateRef$current, _editingItemRef$curre3, _editingItemRef$curre4;
83
- var _ref2 = _slicedToArray(_ref, 1),
84
- fieldName = _ref2[0];
85
- (_formStateRef$current = formStateRef.current) === null || _formStateRef$current === void 0 ? void 0 : _formStateRef$current.form.mutators.setFieldState("".concat((_editingItemRef$curre3 = editingItemRef.current) === null || _editingItemRef$curre3 === void 0 ? void 0 : _editingItemRef$curre3.ui.fieldsPath, "[").concat((_editingItemRef$curre4 = editingItemRef.current) === null || _editingItemRef$curre4 === void 0 ? void 0 : _editingItemRef$curre4.ui.index, "].data.").concat(fieldName), {
70
+ let [fieldName] = _ref;
71
+ (_formStateRef$current = formStateRef.current) === null || _formStateRef$current === void 0 || _formStateRef$current.form.mutators.setFieldState("".concat((_editingItemRef$curre3 = editingItemRef.current) === null || _editingItemRef$curre3 === void 0 ? void 0 : _editingItemRef$curre3.ui.fieldsPath, "[").concat((_editingItemRef$curre4 = editingItemRef.current) === null || _editingItemRef$curre4 === void 0 ? void 0 : _editingItemRef$curre4.ui.index, "].data.").concat(fieldName), {
86
72
  modified: false
87
73
  });
88
74
  });
@@ -91,79 +77,79 @@ var useFormTable = function useFormTable(formState, exitEditModeTriggerItem, onE
91
77
  setEditingItem(null);
92
78
  (onExitEditModeCallbackRef === null || onExitEditModeCallbackRef === void 0 ? void 0 : onExitEditModeCallbackRef.current) && onExitEditModeCallbackRef.current();
93
79
  };
94
- (0, _react.useEffect)(function () {
95
- var applyOrDiscardOrDeleteInEffect = function applyOrDiscardOrDeleteInEffect() {
80
+ (0, _react.useEffect)(() => {
81
+ const applyOrDiscardOrDeleteInEffect = () => {
96
82
  if (editingItemRef !== null && editingItemRef !== void 0 && editingItemRef.current) {
97
83
  if (!editingItemErrorsRef.current) {
98
84
  exitEditMode();
99
85
  } else {
100
- var _editingItemRef$curre5, _editingItemRef$curre6;
101
- if ((_editingItemRef$curre5 = editingItemRef.current) !== null && _editingItemRef$curre5 !== void 0 && (_editingItemRef$curre6 = _editingItemRef$curre5.ui) !== null && _editingItemRef$curre6 !== void 0 && _editingItemRef$curre6.isNew) {
102
- var _editingItemRef$curre7;
103
- var values = (0, _lodash.get)(formStateRef.current.values, (_editingItemRef$curre7 = editingItemRef.current) === null || _editingItemRef$curre7 === void 0 ? void 0 : _editingItemRef$curre7.ui.fieldsPath);
86
+ var _editingItemRef$curre5;
87
+ if ((_editingItemRef$curre5 = editingItemRef.current) !== null && _editingItemRef$curre5 !== void 0 && (_editingItemRef$curre5 = _editingItemRef$curre5.ui) !== null && _editingItemRef$curre5 !== void 0 && _editingItemRef$curre5.isNew) {
88
+ var _editingItemRef$curre6;
89
+ const values = (0, _lodash.get)(formStateRef.current.values, (_editingItemRef$curre6 = editingItemRef.current) === null || _editingItemRef$curre6 === void 0 ? void 0 : _editingItemRef$curre6.ui.fieldsPath);
104
90
  if ((values === null || values === void 0 ? void 0 : values.length) > 1) {
105
- var _editingItemRef$curre8, _editingItemRef$curre9;
106
- formStateRef.current.form.mutators.remove((_editingItemRef$curre8 = editingItemRef.current) === null || _editingItemRef$curre8 === void 0 ? void 0 : _editingItemRef$curre8.ui.fieldsPath, (_editingItemRef$curre9 = editingItemRef.current) === null || _editingItemRef$curre9 === void 0 ? void 0 : _editingItemRef$curre9.ui.index);
91
+ var _editingItemRef$curre7, _editingItemRef$curre8;
92
+ formStateRef.current.form.mutators.remove((_editingItemRef$curre7 = editingItemRef.current) === null || _editingItemRef$curre7 === void 0 ? void 0 : _editingItemRef$curre7.ui.fieldsPath, (_editingItemRef$curre8 = editingItemRef.current) === null || _editingItemRef$curre8 === void 0 ? void 0 : _editingItemRef$curre8.ui.index);
107
93
  } else {
108
- var _editingItemRef$curre10;
109
- formStateRef.current.form.change((_editingItemRef$curre10 = editingItemRef.current) === null || _editingItemRef$curre10 === void 0 ? void 0 : _editingItemRef$curre10.ui.fieldsPath, []);
94
+ var _editingItemRef$curre9;
95
+ formStateRef.current.form.change((_editingItemRef$curre9 = editingItemRef.current) === null || _editingItemRef$curre9 === void 0 ? void 0 : _editingItemRef$curre9.ui.fieldsPath, []);
110
96
  }
111
97
  } else {
112
- var _editingItemRef$curre11, _editingItemRef$curre12;
113
- formStateRef.current.form.mutators.update((_editingItemRef$curre11 = editingItemRef.current) === null || _editingItemRef$curre11 === void 0 ? void 0 : _editingItemRef$curre11.ui.fieldsPath, (_editingItemRef$curre12 = editingItemRef.current) === null || _editingItemRef$curre12 === void 0 ? void 0 : _editingItemRef$curre12.ui.index, (0, _lodash.omit)(editingItemRef.current, ['ui']));
98
+ var _editingItemRef$curre10, _editingItemRef$curre11;
99
+ formStateRef.current.form.mutators.update((_editingItemRef$curre10 = editingItemRef.current) === null || _editingItemRef$curre10 === void 0 ? void 0 : _editingItemRef$curre10.ui.fieldsPath, (_editingItemRef$curre11 = editingItemRef.current) === null || _editingItemRef$curre11 === void 0 ? void 0 : _editingItemRef$curre11.ui.index, (0, _lodash.omit)(editingItemRef.current, ['ui']));
114
100
  }
115
101
  exitEditMode();
116
102
  }
117
103
  }
118
104
  };
119
- return function () {
105
+ return () => {
120
106
  applyOrDiscardOrDeleteInEffect();
121
107
  };
122
108
  }, [exitEditModeTriggerItem]);
123
- var addNewRow = function addNewRow(event, fields, fieldsPath, newItem) {
109
+ const addNewRow = (event, fields, fieldsPath, newItem) => {
124
110
  applyOrDiscardOrDelete(event);
125
111
  formStateRef.current.form.mutators.push(fieldsPath, newItem);
126
- setEditingItem(function () {
112
+ setEditingItem(() => {
127
113
  var _fields$value;
128
- var newEditingItem = _objectSpread(_objectSpread({}, newItem), {}, {
114
+ const newEditingItem = {
115
+ ...newItem,
129
116
  ui: {
130
117
  isNew: true,
131
- fieldsPath: fieldsPath,
118
+ fieldsPath,
132
119
  index: ((_fields$value = fields.value) === null || _fields$value === void 0 ? void 0 : _fields$value.length) || 0
133
120
  }
134
- });
121
+ };
135
122
  editingItemRef.current = newEditingItem;
136
123
  return newEditingItem;
137
124
  });
138
125
  scrollIntoView();
139
126
  };
140
- var applyChanges = function applyChanges(event, index) {
127
+ const applyChanges = (event, index) => {
141
128
  if (editingItemRef.current) {
142
129
  if (!editingItemErrorsRef.current) {
143
- var _editingItemRef$curre13;
144
- if ((_editingItemRef$curre13 = editingItemRef.current) !== null && _editingItemRef$curre13 !== void 0 && _editingItemRef$curre13.ui.isNew) {
130
+ var _editingItemRef$curre12;
131
+ if ((_editingItemRef$curre12 = editingItemRef.current) !== null && _editingItemRef$curre12 !== void 0 && _editingItemRef$curre12.ui.isNew) {
145
132
  scrollIntoView();
146
133
  }
147
134
  exitEditMode();
148
135
  } else {
149
136
  var _editingItemErrorsRef;
150
137
  // Mark all empty fields as `modified` in order to highlight the error if the field is invalid
151
- Object.entries((_editingItemErrorsRef = editingItemErrorsRef.current) === null || _editingItemErrorsRef === void 0 ? void 0 : _editingItemErrorsRef.data).forEach(function (_ref3) {
152
- var _formStateRef$current2, _editingItemRef$curre14;
153
- var _ref4 = _slicedToArray(_ref3, 1),
154
- fieldName = _ref4[0];
155
- (_formStateRef$current2 = formStateRef.current) === null || _formStateRef$current2 === void 0 ? void 0 : _formStateRef$current2.form.mutators.setFieldState("".concat((_editingItemRef$curre14 = editingItemRef.current) === null || _editingItemRef$curre14 === void 0 ? void 0 : _editingItemRef$curre14.ui.fieldsPath, "[").concat(index, "].data.").concat(fieldName), {
138
+ Object.entries((_editingItemErrorsRef = editingItemErrorsRef.current) === null || _editingItemErrorsRef === void 0 ? void 0 : _editingItemErrorsRef.data).forEach(_ref2 => {
139
+ var _formStateRef$current2, _editingItemRef$curre13;
140
+ let [fieldName] = _ref2;
141
+ (_formStateRef$current2 = formStateRef.current) === null || _formStateRef$current2 === void 0 || _formStateRef$current2.form.mutators.setFieldState("".concat((_editingItemRef$curre13 = editingItemRef.current) === null || _editingItemRef$curre13 === void 0 ? void 0 : _editingItemRef$curre13.ui.fieldsPath, "[").concat(index, "].data.").concat(fieldName), {
156
142
  modified: true
157
143
  });
158
144
  });
159
145
  }
160
146
  }
161
147
  };
162
- var deleteRow = function deleteRow(event, fieldsPath, index) {
148
+ const deleteRow = (event, fieldsPath, index) => {
163
149
  if (editingItemRef.current && index !== editingItemRef.current.ui.index) {
164
150
  applyOrDiscardOrDelete(event);
165
151
  }
166
- var values = (0, _lodash.get)(formStateRef.current.values, fieldsPath);
152
+ const values = (0, _lodash.get)(formStateRef.current.values, fieldsPath);
167
153
  if ((values === null || values === void 0 ? void 0 : values.length) > 1) {
168
154
  formStateRef.current.form.mutators.remove(fieldsPath, index);
169
155
  } else {
@@ -172,50 +158,51 @@ var useFormTable = function useFormTable(formState, exitEditModeTriggerItem, onE
172
158
  exitEditMode();
173
159
  event && event.stopPropagation();
174
160
  };
175
- var discardChanges = function discardChanges(event, fieldsPath, index) {
161
+ const discardChanges = (event, fieldsPath, index) => {
176
162
  formStateRef.current.form.mutators.update(fieldsPath, index, (0, _lodash.omit)(editingItemRef.current, ['ui']));
177
163
  exitEditMode();
178
164
  event && event.stopPropagation();
179
165
  };
180
- var discardOrDelete = function discardOrDelete(event, fieldsPath, index) {
181
- var _editingItemRef$curre15, _editingItemRef$curre16;
182
- if (!editingItemRef.current || (_editingItemRef$curre15 = editingItemRef.current) !== null && _editingItemRef$curre15 !== void 0 && (_editingItemRef$curre16 = _editingItemRef$curre15.ui) !== null && _editingItemRef$curre16 !== void 0 && _editingItemRef$curre16.isNew) {
166
+ const discardOrDelete = (event, fieldsPath, index) => {
167
+ var _editingItemRef$curre14;
168
+ if (!editingItemRef.current || (_editingItemRef$curre14 = editingItemRef.current) !== null && _editingItemRef$curre14 !== void 0 && (_editingItemRef$curre14 = _editingItemRef$curre14.ui) !== null && _editingItemRef$curre14 !== void 0 && _editingItemRef$curre14.isNew) {
183
169
  deleteRow(event, fieldsPath, index);
184
170
  } else {
185
171
  discardChanges(event, fieldsPath, index);
186
172
  }
187
173
  };
188
- var applyOrDiscardOrDelete = function applyOrDiscardOrDelete() {
189
- var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
174
+ const applyOrDiscardOrDelete = function () {
175
+ let event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
190
176
  if (editingItemRef !== null && editingItemRef !== void 0 && editingItemRef.current) {
191
177
  if (!editingItemErrorsRef.current) {
192
- var _editingItemRef$curre17;
193
- applyChanges(event, (_editingItemRef$curre17 = editingItemRef.current) === null || _editingItemRef$curre17 === void 0 ? void 0 : _editingItemRef$curre17.ui.index);
178
+ var _editingItemRef$curre15;
179
+ applyChanges(event, (_editingItemRef$curre15 = editingItemRef.current) === null || _editingItemRef$curre15 === void 0 ? void 0 : _editingItemRef$curre15.ui.index);
194
180
  } else {
195
- var _editingItemRef$curre18, _editingItemRef$curre19;
196
- discardOrDelete(event, (_editingItemRef$curre18 = editingItemRef.current) === null || _editingItemRef$curre18 === void 0 ? void 0 : _editingItemRef$curre18.ui.fieldsPath, (_editingItemRef$curre19 = editingItemRef.current) === null || _editingItemRef$curre19 === void 0 ? void 0 : _editingItemRef$curre19.ui.index);
181
+ var _editingItemRef$curre16, _editingItemRef$curre17;
182
+ discardOrDelete(event, (_editingItemRef$curre16 = editingItemRef.current) === null || _editingItemRef$curre16 === void 0 ? void 0 : _editingItemRef$curre16.ui.fieldsPath, (_editingItemRef$curre17 = editingItemRef.current) === null || _editingItemRef$curre17 === void 0 ? void 0 : _editingItemRef$curre17.ui.index);
197
183
  }
198
184
  }
199
185
  };
200
- var enterEditMode = function enterEditMode(event, fields, fieldsPath, index) {
186
+ const enterEditMode = (event, fields, fieldsPath, index) => {
201
187
  applyOrDiscardOrDelete(event);
202
- setTimeout(function () {
203
- var editItem = fields.value[index];
204
- setEditingItem(function () {
205
- var newEditingItem = _objectSpread(_objectSpread({}, editItem), {}, {
188
+ setTimeout(() => {
189
+ const editItem = fields.value[index];
190
+ setEditingItem(() => {
191
+ const newEditingItem = {
192
+ ...editItem,
206
193
  ui: {
207
- fieldsPath: fieldsPath,
208
- index: index
194
+ fieldsPath,
195
+ index
209
196
  }
210
- });
197
+ };
211
198
  editingItemRef.current = newEditingItem;
212
199
  return newEditingItem;
213
200
  });
214
201
  });
215
202
  };
216
- var scrollIntoView = function scrollIntoView() {
203
+ const scrollIntoView = () => {
217
204
  if (bottomScrollRef.current) {
218
- setTimeout(function () {
205
+ setTimeout(() => {
219
206
  bottomScrollRef.current.scrollIntoView({
220
207
  behavior: 'smooth',
221
208
  block: 'nearest'
@@ -223,10 +210,10 @@ var useFormTable = function useFormTable(formState, exitEditModeTriggerItem, onE
223
210
  });
224
211
  }
225
212
  };
226
- var isCurrentRowEditing = function isCurrentRowEditing(rowPath) {
213
+ const isCurrentRowEditing = rowPath => {
227
214
  return (editingItemRef === null || editingItemRef === void 0 ? void 0 : editingItemRef.current) && "".concat(editingItemRef.current.ui.fieldsPath, "[").concat(editingItemRef.current.ui.index, "]") === rowPath;
228
215
  };
229
- var getTableArrayErrors = function getTableArrayErrors(fieldsPath) {
216
+ const getTableArrayErrors = fieldsPath => {
230
217
  if (formState.submitFailed && formState.invalid) {
231
218
  return (0, _lodash.get)(formState, "errors.".concat(fieldsPath, ".").concat(_finalForm.ARRAY_ERROR), []);
232
219
  } else {
@@ -234,19 +221,19 @@ var useFormTable = function useFormTable(formState, exitEditModeTriggerItem, onE
234
221
  }
235
222
  };
236
223
  return {
237
- addNewRow: addNewRow,
238
- applyChanges: applyChanges,
239
- applyOrDiscardOrDelete: applyOrDiscardOrDelete,
240
- bottomScrollRef: bottomScrollRef,
241
- deleteRow: deleteRow,
242
- discardChanges: discardChanges,
243
- discardOrDelete: discardOrDelete,
244
- editingItem: editingItem,
245
- editingItemRef: editingItemRef,
246
- enterEditMode: enterEditMode,
247
- exitEditMode: exitEditMode,
248
- getTableArrayErrors: getTableArrayErrors,
249
- isCurrentRowEditing: isCurrentRowEditing
224
+ addNewRow,
225
+ applyChanges,
226
+ applyOrDiscardOrDelete,
227
+ bottomScrollRef,
228
+ deleteRow,
229
+ discardChanges,
230
+ discardOrDelete,
231
+ editingItem,
232
+ editingItemRef,
233
+ enterEditMode,
234
+ exitEditMode,
235
+ getTableArrayErrors,
236
+ isCurrentRowEditing
250
237
  };
251
238
  };
252
239
  exports.useFormTable = useFormTable;
@@ -8,60 +8,45 @@ var _react = require("react");
8
8
  var _classnames = _interopRequireDefault(require("classnames"));
9
9
  var _common = require("../utils/common.util");
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
12
- 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."); }
13
- 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); }
14
- 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; }
15
- 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; } }
16
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /*
17
- Copyright 2019 Iguazio Systems Ltd.
18
-
19
- Licensed under the Apache License, Version 2.0 (the "License") with
20
- an addition restriction as set forth herein. You may not use this
21
- file except in compliance with the License. You may obtain a copy of
22
- the License at http://www.apache.org/licenses/LICENSE-2.0.
23
-
24
- Unless required by applicable law or agreed to in writing, software
25
- distributed under the License is distributed on an "AS IS" BASIS,
26
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
27
- implied. See the License for the specific language governing
28
- permissions and limitations under the License.
29
-
30
- In addition, you may not use the software for any purposes that are
31
- illegal under applicable law, and the grant of the foregoing license
32
- under the Apache 2.0 license is conditioned upon your compliance with
33
- such restriction.
34
- */
35
- var useHiddenChipsBlock = function useHiddenChipsBlock(hiddenChipsCounterRef, hiddenChipsPopUpRef) {
36
- var _useState = (0, _react.useState)(false),
37
- _useState2 = _slicedToArray(_useState, 2),
38
- isTop = _useState2[0],
39
- setIsTop = _useState2[1];
40
- var _useState3 = (0, _react.useState)(false),
41
- _useState4 = _slicedToArray(_useState3, 2),
42
- isLeft = _useState4[0],
43
- setIsLeft = _useState4[1];
44
- var _useState5 = (0, _react.useState)(false),
45
- _useState6 = _slicedToArray(_useState5, 2),
46
- isVisible = _useState6[0],
47
- setIsVisible = _useState6[1];
48
- var transitionEndEventName = (0, _react.useMemo)(function () {
49
- return (0, _common.getTransitionEndEventName)();
50
- }, []);
51
- var hiddenChipsBlockClassNames = (0, _classnames.default)('chip-block-hidden', isTop ? 'chip-block-hidden_top' : 'chip-block-hidden_bottom', isLeft ? 'chip-block-hidden_left' : 'chip-block-hidden_right', isVisible && 'chip-block-hidden_visible');
52
- var resizePopUp = (0, _react.useCallback)(function () {
11
+ /*
12
+ Copyright 2019 Iguazio Systems Ltd.
13
+
14
+ Licensed under the Apache License, Version 2.0 (the "License") with
15
+ an addition restriction as set forth herein. You may not use this
16
+ file except in compliance with the License. You may obtain a copy of
17
+ the License at http://www.apache.org/licenses/LICENSE-2.0.
18
+
19
+ Unless required by applicable law or agreed to in writing, software
20
+ distributed under the License is distributed on an "AS IS" BASIS,
21
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
22
+ implied. See the License for the specific language governing
23
+ permissions and limitations under the License.
24
+
25
+ In addition, you may not use the software for any purposes that are
26
+ illegal under applicable law, and the grant of the foregoing license
27
+ under the Apache 2.0 license is conditioned upon your compliance with
28
+ such restriction.
29
+ */
30
+
31
+ const useHiddenChipsBlock = (hiddenChipsCounterRef, hiddenChipsPopUpRef) => {
32
+ const [isTop, setIsTop] = (0, _react.useState)(false);
33
+ const [isLeft, setIsLeft] = (0, _react.useState)(false);
34
+ const [isVisible, setIsVisible] = (0, _react.useState)(false);
35
+ const transitionEndEventName = (0, _react.useMemo)(() => (0, _common.getTransitionEndEventName)(), []);
36
+ const hiddenChipsBlockClassNames = (0, _classnames.default)('chip-block-hidden', isTop ? 'chip-block-hidden_top' : 'chip-block-hidden_bottom', isLeft ? 'chip-block-hidden_left' : 'chip-block-hidden_right', isVisible && 'chip-block-hidden_visible');
37
+ const resizePopUp = (0, _react.useCallback)(() => {
53
38
  if (hiddenChipsPopUpRef !== null && hiddenChipsPopUpRef !== void 0 && hiddenChipsPopUpRef.current && hiddenChipsCounterRef !== null && hiddenChipsCounterRef !== void 0 && hiddenChipsCounterRef.current) {
54
- var offset = 10;
55
- var offsetMargin = 20;
56
- var elementRect = hiddenChipsCounterRef.current.getBoundingClientRect();
39
+ const offset = 10;
40
+ const offsetMargin = 20;
41
+ const elementRect = hiddenChipsCounterRef.current.getBoundingClientRect();
57
42
 
58
43
  // Calculate the distance from the right edge of the window to the element's right edge
59
- var elementRectRight = Math.floor(window.innerWidth - elementRect.left - elementRect.width);
44
+ const elementRectRight = Math.floor(window.innerWidth - elementRect.left - elementRect.width);
60
45
 
61
46
  // Calculate the distance from the bottom edge of the window to the element's bottom edge
62
- var elementRectBottom = Math.floor(window.innerHeight - elementRect.top - elementRect.height);
63
- var isLeftPosition = false;
64
- var isTopPosition = false;
47
+ const elementRectBottom = Math.floor(window.innerHeight - elementRect.top - elementRect.height);
48
+ let isLeftPosition = false;
49
+ let isTopPosition = false;
65
50
  hiddenChipsPopUpRef.current.style.maxWidth = '100%';
66
51
  hiddenChipsPopUpRef.current.style.maxHeight = '100%';
67
52
 
@@ -73,7 +58,7 @@ var useHiddenChipsBlock = function useHiddenChipsBlock(hiddenChipsCounterRef, hi
73
58
  } else {
74
59
  // Compare elementRect.left and elementRectRight to choose the larger value as the max width
75
60
  isLeftPosition = elementRect.left > elementRectRight;
76
- var popUpMaxWidth = Math.max(elementRect.left, elementRectRight);
61
+ const popUpMaxWidth = Math.max(elementRect.left, elementRectRight);
77
62
  hiddenChipsPopUpRef.current.style.maxWidth = "".concat(popUpMaxWidth, "px");
78
63
  }
79
64
  hiddenChipsPopUpRef.current.style.right = isLeftPosition ? "".concat(elementRectRight, "px") : 'unset';
@@ -87,7 +72,7 @@ var useHiddenChipsBlock = function useHiddenChipsBlock(hiddenChipsCounterRef, hi
87
72
  } else {
88
73
  // Compare elementRect.top and elementRectBottom to choose the larger value as the max height
89
74
  isTopPosition = elementRect.top > elementRectBottom + offset;
90
- var popUpMaxHeight = Math.max(elementRect.top, elementRectBottom) - offset - offsetMargin;
75
+ const popUpMaxHeight = Math.max(elementRect.top, elementRectBottom) - offset - offsetMargin;
91
76
  hiddenChipsPopUpRef.current.style.maxHeight = "".concat(popUpMaxHeight, "px");
92
77
  }
93
78
  hiddenChipsPopUpRef.current.style.bottom = isTopPosition ? "".concat(elementRectBottom + elementRect.height + offset, "px") : 'unset';
@@ -97,21 +82,21 @@ var useHiddenChipsBlock = function useHiddenChipsBlock(hiddenChipsCounterRef, hi
97
82
  setIsVisible(true);
98
83
  }
99
84
  }, [hiddenChipsCounterRef, hiddenChipsPopUpRef]);
100
- (0, _react.useEffect)(function () {
85
+ (0, _react.useEffect)(() => {
101
86
  if (hiddenChipsPopUpRef !== null && hiddenChipsPopUpRef !== void 0 && hiddenChipsPopUpRef.current && hiddenChipsCounterRef !== null && hiddenChipsCounterRef !== void 0 && hiddenChipsCounterRef.current) {
102
87
  window.addEventListener('resize', resizePopUp);
103
88
  window.addEventListener(transitionEndEventName, resizePopUp);
104
- return function () {
89
+ return () => {
105
90
  window.removeEventListener('resize', resizePopUp);
106
91
  window.removeEventListener(transitionEndEventName, resizePopUp);
107
92
  };
108
93
  }
109
94
  }, [hiddenChipsPopUpRef, hiddenChipsCounterRef, resizePopUp, transitionEndEventName]);
110
- (0, _react.useEffect)(function () {
95
+ (0, _react.useEffect)(() => {
111
96
  resizePopUp();
112
97
  }, [resizePopUp]);
113
98
  return {
114
- hiddenChipsBlockClassNames: hiddenChipsBlockClassNames
99
+ hiddenChipsBlockClassNames
115
100
  };
116
101
  };
117
102
  exports.useHiddenChipsBlock = useHiddenChipsBlock;
package/dist/index.js CHANGED
@@ -1,6 +1,5 @@
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
  });
@@ -15,5 +14,5 @@ var hooks = _interopRequireWildcard(require("./hooks"));
15
14
  exports.hooks = hooks;
16
15
  var types = _interopRequireWildcard(require("./types"));
17
16
  exports.types = types;
18
- 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); }
19
- 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
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
18
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -18,3 +18,9 @@ $labelEditBorder: 1px solid rgba($amethyst, 0.34);
18
18
  $applyBtnBorder: 4px solid $brightTurquoise;
19
19
  $focusBorder: 1px solid $topaz;
20
20
  $tableRowBorder: 1px solid $titanWhite;
21
+
22
+ // stats borders
23
+ $runningBorder: 2px solid $pictonBlue;
24
+ $totalBorder: 2px solid rgba($black, 0.2);
25
+ $failedBorder: 2px solid $amaranth;
26
+ $completedBorder: 2px solid $brightTurquoise;