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
@@ -34,43 +34,41 @@ under the Apache 2.0 license is conditioned upon your compliance with
34
34
  such restriction.
35
35
  */
36
36
 
37
- var FormRowActions = function FormRowActions(_ref) {
37
+ const FormRowActions = _ref => {
38
38
  var _editingItem$ui, _editingItem$ui2, _editingItem$ui3, _editingItem$ui4;
39
- var applyChanges = _ref.applyChanges,
40
- deleteButtonIsHidden = _ref.deleteButtonIsHidden,
41
- deleteRow = _ref.deleteRow,
42
- disabled = _ref.disabled,
43
- discardOrDelete = _ref.discardOrDelete,
44
- editingItem = _ref.editingItem,
45
- fieldsPath = _ref.fieldsPath,
46
- hidden = _ref.hidden,
47
- index = _ref.index;
39
+ let {
40
+ applyChanges,
41
+ deleteButtonIsHidden,
42
+ deleteRow,
43
+ disabled,
44
+ discardOrDelete,
45
+ editingItem,
46
+ fieldsPath,
47
+ hidden,
48
+ index
49
+ } = _ref;
48
50
  return hidden ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
49
51
  className: "form-table__cell form-table__actions-cell"
50
52
  }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
51
53
  className: "form-table__cell form-table__actions-cell",
52
- children: [(editingItem === null || editingItem === void 0 ? void 0 : (_editingItem$ui = editingItem.ui) === null || _editingItem$ui === void 0 ? void 0 : _editingItem$ui.index) === index && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
54
+ children: [(editingItem === null || editingItem === void 0 || (_editingItem$ui = editingItem.ui) === null || _editingItem$ui === void 0 ? void 0 : _editingItem$ui.index) === index && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
53
55
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.RoundedIcon, {
54
56
  id: "apply-btn",
55
- onClick: function onClick(event) {
56
- return applyChanges(event, index);
57
- },
57
+ onClick: event => applyChanges(event, index),
58
58
  tooltipText: "Apply",
59
59
  disabled: disabled,
60
60
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_checkmark.ReactComponent, {})
61
61
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.RoundedIcon, {
62
62
  id: "delete-discard-btn",
63
- onClick: function onClick(event) {
64
- return discardOrDelete(event, fieldsPath, index);
65
- },
63
+ onClick: event => discardOrDelete(event, fieldsPath, index),
66
64
  tooltipText: (_editingItem$ui2 = editingItem.ui) !== null && _editingItem$ui2 !== void 0 && _editingItem$ui2.isNew ? 'Delete' : 'Discard changes',
67
65
  disabled: disabled,
68
66
  children: (_editingItem$ui3 = editingItem.ui) !== null && _editingItem$ui3 !== void 0 && _editingItem$ui3.isNew ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_delete.ReactComponent, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_close.ReactComponent, {})
69
67
  })]
70
- }), (!editingItem || (editingItem === null || editingItem === void 0 ? void 0 : (_editingItem$ui4 = editingItem.ui) === null || _editingItem$ui4 === void 0 ? void 0 : _editingItem$ui4.index) !== index) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
68
+ }), (!editingItem || (editingItem === null || editingItem === void 0 || (_editingItem$ui4 = editingItem.ui) === null || _editingItem$ui4 === void 0 ? void 0 : _editingItem$ui4.index) !== index) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
71
69
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.RoundedIcon, {
72
70
  id: "edit-btn",
73
- onClick: function onClick(event) {
71
+ onClick: event => {
74
72
  event.preventDefault();
75
73
  },
76
74
  tooltipText: "Edit",
@@ -78,7 +76,7 @@ var FormRowActions = function FormRowActions(_ref) {
78
76
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_edit.ReactComponent, {})
79
77
  }), !deleteButtonIsHidden && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.RoundedIcon, {
80
78
  id: "delete-btn",
81
- onClick: function onClick(event) {
79
+ onClick: event => {
82
80
  deleteRow(event, fieldsPath, index);
83
81
  },
84
82
  tooltipText: "Delete",
@@ -105,5 +103,4 @@ FormRowActions.propTypes = {
105
103
  hidden: _propTypes.default.bool,
106
104
  index: _propTypes.default.number.isRequired
107
105
  };
108
- var _default = FormRowActions;
109
- exports.default = _default;
106
+ var _default = exports.default = FormRowActions;
@@ -28,12 +28,15 @@ under the Apache 2.0 license is conditioned upon your compliance with
28
28
  such restriction.
29
29
  */
30
30
 
31
- var OptionsMenu = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
32
- var children = _ref.children,
33
- show = _ref.show,
34
- timeout = _ref.timeout;
35
- var _ref2 = ref.current ? ref.current.getBoundingClientRect() : {},
36
- dropdownWidth = _ref2.width;
31
+ const OptionsMenu = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
32
+ let {
33
+ children,
34
+ show,
35
+ timeout
36
+ } = _ref;
37
+ const {
38
+ width: dropdownWidth
39
+ } = ref.current ? ref.current.getBoundingClientRect() : {};
37
40
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactTransitionGroup.CSSTransition, {
38
41
  in: show,
39
42
  timeout: timeout,
@@ -68,5 +71,4 @@ OptionsMenu.propTypes = {
68
71
  show: _propTypes.default.bool.isRequired,
69
72
  timeout: _propTypes.default.number
70
73
  };
71
- var _default = OptionsMenu;
72
- exports.default = _default;
74
+ var _default = exports.default = OptionsMenu;
@@ -30,15 +30,17 @@ under the Apache 2.0 license is conditioned upon your compliance with
30
30
  such restriction.
31
31
  */
32
32
 
33
- var SelectOption = function SelectOption(_ref) {
33
+ const SelectOption = _ref => {
34
34
  var _item$labelHtml;
35
- var item = _ref.item,
36
- name = _ref.name,
37
- _onClick = _ref.onClick,
38
- multiple = _ref.multiple,
39
- selectedId = _ref.selectedId,
40
- withSelectedIcon = _ref.withSelectedIcon;
41
- var selectClassName = (0, _classnames.default)('select__item', multiple && 'multiple', item.hidden && 'hidden', item.disabled && 'disabled');
35
+ let {
36
+ item,
37
+ name,
38
+ onClick,
39
+ multiple,
40
+ selectedId,
41
+ withSelectedIcon
42
+ } = _ref;
43
+ const selectClassName = (0, _classnames.default)('select__item', multiple && 'multiple', item.hidden && 'hidden', item.disabled && 'disabled');
42
44
  if (multiple) {
43
45
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
44
46
  "data-testid": "select-checkbox",
@@ -56,8 +58,8 @@ var SelectOption = function SelectOption(_ref) {
56
58
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
57
59
  "data-testid": "select-option",
58
60
  className: selectClassName,
59
- onClick: function onClick() {
60
- !item.disabled && _onClick(item.id);
61
+ onClick: () => {
62
+ !item.disabled && onClick(item.id);
61
63
  },
62
64
  "data-custom-id": item.id,
63
65
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
@@ -95,7 +97,7 @@ var SelectOption = function SelectOption(_ref) {
95
97
  });
96
98
  };
97
99
  SelectOption.defaultProps = {
98
- onClick: function onClick() {},
100
+ onClick: () => {},
99
101
  multiple: false,
100
102
  withSelectedIcon: true
101
103
  };
@@ -107,5 +109,4 @@ SelectOption.propTypes = {
107
109
  selectedId: _propTypes.default.string,
108
110
  withSelectedIcon: _propTypes.default.bool
109
111
  };
110
- var _default = SelectOption;
111
- exports.default = _default;
112
+ var _default = exports.default = SelectOption;
@@ -5,44 +5,36 @@ var _react2 = require("@testing-library/react");
5
5
  var _SelectOption = _interopRequireDefault(require("./SelectOption"));
6
6
  var _jsxRuntime = require("react/jsx-runtime");
7
7
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
- 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); }
9
- 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; }
10
- 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; }
11
- 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; }
12
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
13
- 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); } /*
14
- Copyright 2022 Iguazio Systems Ltd.
15
- Licensed under the Apache License, Version 2.0 (the "License") with
16
- an addition restriction as set forth herein. You may not use this
17
- file except in compliance with the License. You may obtain a copy of
18
- the License at http://www.apache.org/licenses/LICENSE-2.0.
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
- 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
- var renderComponent = function renderComponent(props) {
30
- return (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectOption.default, _objectSpread({}, props)));
31
- };
32
- jest.mock('../../images/checkbox-unchecked.svg', function () {
33
- return {
34
- ReactComponent: 'unchecked-icon'
35
- };
36
- });
37
- jest.mock('../../images/checkbox-checked.svg', function () {
38
- return {
39
- ReactComponent: 'unchecked-icon'
40
- };
41
- });
42
- describe('SelectOption component', function () {
43
- var wrapper;
44
- beforeEach(function () {
45
- var props = {
8
+ /*
9
+ Copyright 2022 Iguazio Systems Ltd.
10
+ Licensed under the Apache License, Version 2.0 (the "License") with
11
+ an addition restriction as set forth herein. You may not use this
12
+ file except in compliance with the License. You may obtain a copy of
13
+ the License at http://www.apache.org/licenses/LICENSE-2.0.
14
+ Unless required by applicable law or agreed to in writing, software
15
+ distributed under the License is distributed on an "AS IS" BASIS,
16
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17
+ implied. See the License for the specific language governing
18
+ permissions and limitations under the License.
19
+ In addition, you may not use the software for any purposes that are
20
+ illegal under applicable law, and the grant of the foregoing license
21
+ under the Apache 2.0 license is conditioned upon your compliance with
22
+ such restriction.
23
+ */
24
+
25
+ const renderComponent = props => (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectOption.default, {
26
+ ...props
27
+ }));
28
+ jest.mock('../../images/checkbox-unchecked.svg', () => ({
29
+ ReactComponent: 'unchecked-icon'
30
+ }));
31
+ jest.mock('../../images/checkbox-checked.svg', () => ({
32
+ ReactComponent: 'unchecked-icon'
33
+ }));
34
+ describe('SelectOption component', () => {
35
+ let wrapper;
36
+ beforeEach(() => {
37
+ const props = {
46
38
  item: {
47
39
  label: 'Test1',
48
40
  id: 'test1',
@@ -56,10 +48,10 @@ describe('SelectOption component', function () {
56
48
  wrapper = renderComponent(props);
57
49
  });
58
50
  afterEach(_react2.cleanup);
59
- it('renders without crashing', function () {
51
+ it('renders without crashing', () => {
60
52
  expect(wrapper.queryByTestId('select-option')).not.toBeNull();
61
53
  });
62
- it('should display checkbox inside option if props selectType is "checkbox"', function () {
54
+ it('should display checkbox inside option if props selectType is "checkbox"', () => {
63
55
  wrapper.rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectOption.default, {
64
56
  item: {
65
57
  label: 'Test1',
@@ -70,11 +62,11 @@ describe('SelectOption component', function () {
70
62
  }));
71
63
  expect(wrapper.queryByTestId('select-checkbox')).not.toBeNull();
72
64
  });
73
- it('should display select icon if it exists in the props "item"', function () {
65
+ it('should display select icon if it exists in the props "item"', () => {
74
66
  expect(wrapper.getByTestId('select-icon')).not.toBeNull();
75
67
  });
76
- it('should won\'t call onClick callback if props disable set to "true"', function () {
77
- var mockCLick = jest.fn();
68
+ it('should won\'t call onClick callback if props disable set to "true"', () => {
69
+ const mockCLick = jest.fn();
78
70
  wrapper.rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectOption.default, {
79
71
  item: {
80
72
  label: 'Test1',
@@ -84,14 +76,14 @@ describe('SelectOption component', function () {
84
76
  selectType: "test1",
85
77
  disabled: true
86
78
  }));
87
- var selectOption = wrapper.getByTestId('select-option');
79
+ const selectOption = wrapper.getByTestId('select-option');
88
80
  _react2.fireEvent.click(selectOption);
89
81
  expect(mockCLick).toHaveBeenCalledTimes(0);
90
82
  });
91
- it('should display subLabel if it exists in props item', function () {
83
+ it('should display subLabel if it exists in props item', () => {
92
84
  expect(wrapper.queryByTestId('tooltip-wrapper')).not.toBeNull();
93
85
  });
94
- it('should add class "disabled" to SelectOption if props disabled set to "true"', function () {
86
+ it('should add class "disabled" to SelectOption if props disabled set to "true"', () => {
95
87
  wrapper.rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectOption.default, {
96
88
  item: {
97
89
  label: 'Test1',
@@ -100,7 +92,7 @@ describe('SelectOption component', function () {
100
92
  selectType: "test1",
101
93
  disabled: true
102
94
  }));
103
- var selectOption = wrapper.getByTestId('select-option');
95
+ const selectOption = wrapper.getByTestId('select-option');
104
96
  expect(selectOption.className).toMatch('disabled');
105
97
  });
106
98
  });
@@ -29,10 +29,12 @@ under the Apache 2.0 license is conditioned upon your compliance with
29
29
  such restriction.
30
30
  */
31
31
 
32
- var ValidationTemplate = function ValidationTemplate(_ref) {
33
- var valid = _ref.valid,
34
- validationMessage = _ref.validationMessage;
35
- var validationClasses = (0, _classnames.default)('validation-option', valid && 'text-muted');
32
+ const ValidationTemplate = _ref => {
33
+ let {
34
+ valid,
35
+ validationMessage
36
+ } = _ref;
37
+ const validationClasses = (0, _classnames.default)('validation-option', valid && 'text-muted');
36
38
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
37
39
  className: validationClasses,
38
40
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
@@ -51,5 +53,4 @@ ValidationTemplate.propTypes = {
51
53
  valid: _propTypes.default.bool.isRequired,
52
54
  validationMessage: _propTypes.default.string.isRequired
53
55
  };
54
- var _default = ValidationTemplate;
55
- exports.default = _default;
56
+ var _default = exports.default = ValidationTemplate;
@@ -5,31 +5,31 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  Object.defineProperty(exports, "FormActionButton", {
7
7
  enumerable: true,
8
- get: function get() {
8
+ get: function () {
9
9
  return _FormActionButton.default;
10
10
  }
11
11
  });
12
12
  Object.defineProperty(exports, "FormRowActions", {
13
13
  enumerable: true,
14
- get: function get() {
14
+ get: function () {
15
15
  return _FormRowActions.default;
16
16
  }
17
17
  });
18
18
  Object.defineProperty(exports, "OptionsMenu", {
19
19
  enumerable: true,
20
- get: function get() {
20
+ get: function () {
21
21
  return _OptionsMenu.default;
22
22
  }
23
23
  });
24
24
  Object.defineProperty(exports, "SelectOption", {
25
25
  enumerable: true,
26
- get: function get() {
26
+ get: function () {
27
27
  return _SelectOption.default;
28
28
  }
29
29
  });
30
30
  Object.defineProperty(exports, "ValidationTemplate", {
31
31
  enumerable: true,
32
- get: function get() {
32
+ get: function () {
33
33
  return _ValidationTemplate.default;
34
34
  }
35
35
  });
@@ -5,31 +5,31 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  Object.defineProperty(exports, "useChipCell", {
7
7
  enumerable: true,
8
- get: function get() {
8
+ get: function () {
9
9
  return _useChipCell.useChipCell;
10
10
  }
11
11
  });
12
12
  Object.defineProperty(exports, "useDebounce", {
13
13
  enumerable: true,
14
- get: function get() {
14
+ get: function () {
15
15
  return _useDebounce.useDebounce;
16
16
  }
17
17
  });
18
18
  Object.defineProperty(exports, "useDetectOutsideClick", {
19
19
  enumerable: true,
20
- get: function get() {
20
+ get: function () {
21
21
  return _useDetectOutsideClick.useDetectOutsideClick;
22
22
  }
23
23
  });
24
24
  Object.defineProperty(exports, "useFormTable", {
25
25
  enumerable: true,
26
- get: function get() {
26
+ get: function () {
27
27
  return _useFormTable.useFormTable;
28
28
  }
29
29
  });
30
30
  Object.defineProperty(exports, "useHiddenChipsBlock", {
31
31
  enumerable: true,
32
- get: function get() {
32
+ get: function () {
33
33
  return _useHiddenChipsBlock.useHiddenChipsBlock;
34
34
  }
35
35
  });
@@ -8,88 +8,69 @@ var _react = require("react");
8
8
  var _lodash = require("lodash");
9
9
  var _common = require("../utils/common.util");
10
10
  var _getFirstScrollableParent = require("../utils/getFirstScrollableParent.util");
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 useChipCell = function useChipCell(isEditMode, visibleChipsMaxLength) {
36
- var _useState = (0, _react.useState)(false),
37
- _useState2 = _slicedToArray(_useState, 2),
38
- showHiddenChips = _useState2[0],
39
- setShowHiddenChips = _useState2[1];
40
- var _useState3 = (0, _react.useState)({}),
41
- _useState4 = _slicedToArray(_useState3, 2),
42
- chipsSizes = _useState4[0],
43
- setChipsSizes = _useState4[1];
44
- var _useState5 = (0, _react.useState)(false),
45
- _useState6 = _slicedToArray(_useState5, 2),
46
- showChips = _useState6[0],
47
- setShowChips = _useState6[1];
48
- var _useState7 = (0, _react.useState)(8),
49
- _useState8 = _slicedToArray(_useState7, 2),
50
- visibleChipsCount = _useState8[0],
51
- setVisibleChipsCount = _useState8[1];
52
- var transitionEndEventName = (0, _react.useMemo)(function () {
53
- return (0, _common.getTransitionEndEventName)();
54
- }, []);
55
- var chipsCellRef = (0, _react.useRef)();
56
- var chipsWrapperRef = (0, _react.useRef)();
57
- var hiddenChipsCounterRef = (0, _react.useRef)();
58
- var hiddenChipsPopUpRef = (0, _react.useRef)();
59
- var handleShowElements = (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 useChipCell = (isEditMode, visibleChipsMaxLength) => {
32
+ const [showHiddenChips, setShowHiddenChips] = (0, _react.useState)(false);
33
+ const [chipsSizes, setChipsSizes] = (0, _react.useState)({});
34
+ const [showChips, setShowChips] = (0, _react.useState)(false);
35
+ const [visibleChipsCount, setVisibleChipsCount] = (0, _react.useState)(8);
36
+ const transitionEndEventName = (0, _react.useMemo)(() => (0, _common.getTransitionEndEventName)(), []);
37
+ const chipsCellRef = (0, _react.useRef)();
38
+ const chipsWrapperRef = (0, _react.useRef)();
39
+ const hiddenChipsCounterRef = (0, _react.useRef)();
40
+ const hiddenChipsPopUpRef = (0, _react.useRef)();
41
+ const handleShowElements = (0, _react.useCallback)(event => {
60
42
  if (!isEditMode || isEditMode && visibleChipsMaxLength) {
61
- setShowHiddenChips(function (state) {
62
- return !state;
63
- });
43
+ var _hiddenChipsCounterRe;
44
+ if (!((_hiddenChipsCounterRe = hiddenChipsCounterRef.current) !== null && _hiddenChipsCounterRe !== void 0 && _hiddenChipsCounterRe.contains(event.target))) {
45
+ setShowHiddenChips(false);
46
+ } else {
47
+ setShowHiddenChips(true);
48
+ }
64
49
  }
65
50
  }, [isEditMode, visibleChipsMaxLength]);
66
- (0, _react.useEffect)(function () {
51
+ (0, _react.useEffect)(() => {
67
52
  if (showHiddenChips) {
68
53
  window.addEventListener('click', handleShowElements);
69
- return function () {
70
- return window.removeEventListener('click', handleShowElements);
71
- };
54
+ return () => window.removeEventListener('click', handleShowElements);
72
55
  }
73
56
  }, [showHiddenChips, handleShowElements]);
74
- var handleScroll = (0, _react.useCallback)(function (event) {
57
+ const handleScroll = (0, _react.useCallback)(event => {
75
58
  if (event.target.parentElement !== (hiddenChipsPopUpRef === null || hiddenChipsPopUpRef === void 0 ? void 0 : hiddenChipsPopUpRef.current)) {
76
59
  setShowHiddenChips(false);
77
60
  }
78
61
  }, [hiddenChipsPopUpRef]);
79
- (0, _react.useEffect)(function () {
62
+ (0, _react.useEffect)(() => {
80
63
  if (showHiddenChips) {
81
64
  window.addEventListener('scroll', handleScroll, true);
82
65
  }
83
- return function () {
84
- return window.removeEventListener('scroll', handleScroll, true);
85
- };
66
+ return () => window.removeEventListener('scroll', handleScroll, true);
86
67
  }, [handleScroll, showHiddenChips]);
87
- var resizeChipCell = (0, _react.useCallback)(function () {
68
+ const resizeChipCell = (0, _react.useCallback)(() => {
88
69
  if (hiddenChipsPopUpRef !== null && hiddenChipsPopUpRef !== void 0 && hiddenChipsPopUpRef.current) {
89
- var _hiddenChipsCounterRe;
90
- var scrollableParent = (0, _getFirstScrollableParent.getFirstScrollableParent)(hiddenChipsCounterRef.current.offsetParent);
91
- var scrollableParentRect = scrollableParent.getBoundingClientRect();
92
- var hiddenChipsCounterRect = (_hiddenChipsCounterRe = hiddenChipsCounterRef.current) === null || _hiddenChipsCounterRe === void 0 ? void 0 : _hiddenChipsCounterRe.getBoundingClientRect();
70
+ var _hiddenChipsCounterRe2;
71
+ const scrollableParent = (0, _getFirstScrollableParent.getFirstScrollableParent)(hiddenChipsCounterRef.current.offsetParent);
72
+ const scrollableParentRect = scrollableParent.getBoundingClientRect();
73
+ const hiddenChipsCounterRect = (_hiddenChipsCounterRe2 = hiddenChipsCounterRef.current) === null || _hiddenChipsCounterRe2 === void 0 ? void 0 : _hiddenChipsCounterRe2.getBoundingClientRect();
93
74
 
94
75
  // Check if the hiddenChipsCounterRect is outside the boundaries of the scrollableParentRect or the window
95
76
  if (hiddenChipsCounterRect.left < scrollableParentRect.left || hiddenChipsCounterRect.top < scrollableParentRect.top || hiddenChipsCounterRect.right > scrollableParentRect.right || hiddenChipsCounterRect.bottom > scrollableParentRect.bottom || hiddenChipsCounterRect.right > window.innerWidth || hiddenChipsCounterRect.bottom > window.innerHeight) {
@@ -98,11 +79,11 @@ var useChipCell = function useChipCell(isEditMode, visibleChipsMaxLength) {
98
79
  }
99
80
  if (!isEditMode && !(0, _common.isEveryObjectValueEmpty)(chipsSizes)) {
100
81
  var _chipsCellRef$current;
101
- var parentSize = (_chipsCellRef$current = chipsCellRef.current) === null || _chipsCellRef$current === void 0 ? void 0 : _chipsCellRef$current.getBoundingClientRect().width;
102
- var maxLength = 0;
103
- var chipIndex = 0;
104
- var padding = 65;
105
- Object.values(chipsSizes).every(function (chipSize, index) {
82
+ const parentSize = (_chipsCellRef$current = chipsCellRef.current) === null || _chipsCellRef$current === void 0 ? void 0 : _chipsCellRef$current.getBoundingClientRect().width;
83
+ let maxLength = 0;
84
+ let chipIndex = 0;
85
+ const padding = 65;
86
+ Object.values(chipsSizes).every((chipSize, index) => {
106
87
  // Check if adding chipSize to maxLength exceeds parentSize
107
88
  // or if adding chipSize and padding exceeds parentSize when there are multiple chips
108
89
  if (maxLength + chipSize > parentSize || Object.values(chipsSizes).length > 1 && maxLength + chipSize + padding > parentSize) {
@@ -120,31 +101,31 @@ var useChipCell = function useChipCell(isEditMode, visibleChipsMaxLength) {
120
101
  setShowChips(true);
121
102
  }
122
103
  }, [chipsSizes, isEditMode]);
123
- (0, _react.useEffect)(function () {
104
+ (0, _react.useEffect)(() => {
124
105
  resizeChipCell();
125
106
  }, [resizeChipCell]);
126
- (0, _react.useEffect)(function () {
127
- var resizeChipCellDebounced = (0, _lodash.throttle)(resizeChipCell, 500);
107
+ (0, _react.useEffect)(() => {
108
+ const resizeChipCellDebounced = (0, _lodash.throttle)(resizeChipCell, 500);
128
109
  if (!isEditMode) {
129
110
  window.addEventListener('resize', resizeChipCellDebounced);
130
111
  window.addEventListener(transitionEndEventName, resizeChipCellDebounced);
131
- return function () {
112
+ return () => {
132
113
  window.removeEventListener('resize', resizeChipCellDebounced);
133
114
  window.removeEventListener(transitionEndEventName, resizeChipCellDebounced);
134
115
  };
135
116
  }
136
117
  }, [resizeChipCell, isEditMode, transitionEndEventName]);
137
118
  return {
138
- chipsCellRef: chipsCellRef,
139
- chipsWrapperRef: chipsWrapperRef,
140
- handleShowElements: handleShowElements,
141
- hiddenChipsCounterRef: hiddenChipsCounterRef,
142
- hiddenChipsPopUpRef: hiddenChipsPopUpRef,
143
- setChipsSizes: setChipsSizes,
144
- setShowHiddenChips: setShowHiddenChips,
145
- showChips: showChips,
146
- showHiddenChips: showHiddenChips,
147
- visibleChipsCount: visibleChipsCount
119
+ chipsCellRef,
120
+ chipsWrapperRef,
121
+ handleShowElements,
122
+ hiddenChipsCounterRef,
123
+ hiddenChipsPopUpRef,
124
+ setChipsSizes,
125
+ setShowHiddenChips,
126
+ showChips,
127
+ showHiddenChips,
128
+ visibleChipsCount
148
129
  };
149
130
  };
150
131
  exports.useChipCell = useChipCell;