iguazio.dashboard-react-controls 1.8.11 → 1.9.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.
@@ -62,7 +62,7 @@ var FormChip = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
62
62
  }, [chipIndex, setChipsSizes]);
63
63
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
64
64
  onClick: function onClick(event) {
65
- return handleToEditMode(event, chipIndex);
65
+ return handleToEditMode(event, chipIndex, keyName);
66
66
  },
67
67
  ref: chipRef,
68
68
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_NewChipForm.default, {
@@ -160,7 +160,7 @@ var FormChipCell = function FormChipCell(_ref) {
160
160
  return {
161
161
  chipIndex: lastChipSelected ? null : prevState.chipIndex + 1,
162
162
  isEdit: !lastChipSelected,
163
- isKeyFocused: true,
163
+ isKeyFocused: !lastChipSelected,
164
164
  isValueFocused: false,
165
165
  isNewChip: false
166
166
  };
@@ -170,29 +170,53 @@ var FormChipCell = function FormChipCell(_ref) {
170
170
  handleRemoveChip(event, fields, editConfig.chipIndex);
171
171
  }
172
172
  setEditConfig(function (prevState) {
173
- var isPrevChipIndexExists = prevState.chipIndex - 1 < 0;
174
- isChipNotEmpty && isPrevChipIndexExists && onExitEditModeCallback && onExitEditModeCallback();
173
+ var firstChipIsSelected = prevState.chipIndex === 0;
174
+ isChipNotEmpty && firstChipIsSelected && onExitEditModeCallback && onExitEditModeCallback();
175
175
  return {
176
- chipIndex: isPrevChipIndexExists ? null : prevState.chipIndex - 1,
177
- isEdit: !isPrevChipIndexExists,
178
- isKeyFocused: isPrevChipIndexExists,
179
- isValueFocused: !isPrevChipIndexExists,
176
+ chipIndex: firstChipIsSelected ? null : prevState.chipIndex - 1,
177
+ isEdit: !firstChipIsSelected,
178
+ isKeyFocused: false,
179
+ isValueFocused: !firstChipIsSelected,
180
180
  isNewChip: false
181
181
  };
182
182
  });
183
183
  }
184
184
  checkChipsList((0, _lodash.get)(formState.values, name));
185
- event && event.preventDefault();
185
+ if (editConfig.chipIndex > 0 && editConfig.chipIndex < fields.value.length - 1 || fields.value.length > 1 && editConfig.chipIndex === 0 && nameEvent !== _constants.TAB_SHIFT || fields.value.length > 1 && editConfig.chipIndex === fields.value.length - 1 && nameEvent !== _constants.TAB) {
186
+ event && event.preventDefault();
187
+ }
186
188
  }, [editConfig.chipIndex, checkChipsList, formState.values, name, onExitEditModeCallback, handleRemoveChip]);
187
- var handleToEditMode = (0, _react.useCallback)(function (event, index) {
189
+ var handleToEditMode = (0, _react.useCallback)(function (event, chipIndex, keyName) {
188
190
  if (isEditable) {
191
+ var pointerCoordinateX = event.clientX,
192
+ pointerCoordinateY = event.clientY;
193
+ var isKeyClicked = false;
194
+ var isClickedInsideInputElement = function isClickedInsideInputElement(pointerCoordinateX, pointerCoordinateY, inputElement) {
195
+ if (inputElement) {
196
+ var _inputElement$getBoun = inputElement.getBoundingClientRect(),
197
+ topPosition = _inputElement$getBoun.top,
198
+ leftPosition = _inputElement$getBoun.left,
199
+ rightPosition = _inputElement$getBoun.right,
200
+ bottomPosition = _inputElement$getBoun.bottom;
201
+ if (pointerCoordinateX > rightPosition || pointerCoordinateX < leftPosition) return false;
202
+ if (pointerCoordinateY > bottomPosition || pointerCoordinateY < topPosition) return false;
203
+ return true;
204
+ }
205
+ };
189
206
  event.stopPropagation();
207
+ if (event.target.nodeName !== 'INPUT') {
208
+ if (event.target.firstElementChild) {
209
+ isKeyClicked = isClickedInsideInputElement(pointerCoordinateX, pointerCoordinateY, event.target.firstElementChild);
210
+ }
211
+ } else {
212
+ isKeyClicked = event.target.name === keyName;
213
+ }
190
214
  setEditConfig(function (preState) {
191
215
  return _objectSpread(_objectSpread({}, preState), {}, {
192
- chipIndex: index,
216
+ chipIndex: chipIndex,
193
217
  isEdit: true,
194
- isKeyFocused: true,
195
- isValueFocused: false
218
+ isKeyFocused: isKeyClicked,
219
+ isValueFocused: !isKeyClicked
196
220
  });
197
221
  });
198
222
  }
@@ -14,6 +14,7 @@ var _OptionsMenu = _interopRequireDefault(require("../../../elements/OptionsMenu
14
14
  var _ValidationTemplate = _interopRequireDefault(require("../../../elements/ValidationTemplate/ValidationTemplate"));
15
15
  var _types = require("../../../types");
16
16
  var _constants = require("../../../constants");
17
+ var _formChipCell = require("../formChipCell.util");
17
18
  var _close = require("../../../images/close.svg");
18
19
  require("./newChipForm.scss");
19
20
  var _jsxRuntime = require("react/jsx-runtime");
@@ -99,6 +100,7 @@ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
99
100
  var labelKeyClassName = (0, _classnames.default)(className, !editConfig.isKeyFocused && 'item_edited', !(0, _lodash.isEmpty)((0, _lodash.get)(meta, ['error', chipIndex, 'key'], [])) && !(0, _lodash.isEmpty)(chipData.key) && 'item_edited_invalid');
100
101
  var labelContainerClassName = (0, _classnames.default)('edit-chip-container', background && "edit-chip-container-background_".concat(background), borderColor && "edit-chip-container-border_".concat(borderColor), font && "edit-chip-container-font_".concat(font), density && "edit-chip-container-density_".concat(density), borderRadius && "edit-chip-container-border_".concat(borderRadius), (editConfig.isEdit || editConfig.isNewChip) && 'edit-chip-container_edited');
101
102
  var labelValueClassName = (0, _classnames.default)('input-label-value', !editConfig.isValueFocused && 'item_edited', !(0, _lodash.isEmpty)((0, _lodash.get)(meta, ['error', chipIndex, 'value'], [])) && !(0, _lodash.isEmpty)(chipData.value) && 'item_edited_invalid');
103
+ var closeButtonClass = (0, _classnames.default)('edit-chip__icon-close', (editConfig.chipIndex === chipIndex || !isEditable) && 'edit-chip__icon-close_hidden');
102
104
  (0, _react.useLayoutEffect)(function () {
103
105
  if (!chipData.keyFieldWidth && !chipData.valueFieldWidth) {
104
106
  var currentWidthKeyInput = refInputKey.current.scrollWidth + 1;
@@ -154,26 +156,19 @@ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
154
156
  }
155
157
  }, [outsideClick, editConfig.isEdit]);
156
158
  var focusChip = (0, _react.useCallback)(function (event) {
157
- event.stopPropagation();
158
159
  if (editConfig.chipIndex === chipIndex && isEditable) {
159
160
  if (!event.shiftKey && event.key === _constants.TAB && editConfig.isValueFocused) {
160
- onChange(event, _constants.TAB);
161
+ return onChange(event, _constants.TAB);
161
162
  } else if (event.shiftKey && event.key === _constants.TAB && editConfig.isKeyFocused) {
162
- onChange(event, _constants.TAB_SHIFT);
163
- }
164
- if (event.key === _constants.BACKSPACE || event.key === _constants.DELETE) {
165
- setChipData(function (prevState) {
166
- return _objectSpread(_objectSpread({}, prevState), {}, {
167
- keyFieldWidth: editConfig.isKeyFocused ? minWidthInput : prevState.keyFieldWidth,
168
- valueFieldWidth: editConfig.isValueFocused ? minWidthValueInput : prevState.valueFieldWidth
169
- });
170
- });
163
+ return onChange(event, _constants.TAB_SHIFT);
171
164
  }
172
165
  }
166
+ event.stopPropagation();
173
167
  }, [editConfig, onChange, chipIndex, isEditable]);
174
168
  var handleOnFocus = (0, _react.useCallback)(function (event) {
169
+ var isKeyFocused = event.target.name === keyName;
175
170
  if (editConfig.chipIndex === chipIndex) {
176
- if (event.target.name === keyName) {
171
+ if (isKeyFocused) {
177
172
  refInputKey.current.selectionStart = refInputKey.current.selectionEnd;
178
173
  setEditConfig(function (prevConfig) {
179
174
  return _objectSpread(_objectSpread({}, prevConfig), {}, {
@@ -191,12 +186,24 @@ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
191
186
  });
192
187
  }
193
188
  event && event.stopPropagation();
189
+ } else if ((0, _lodash.isNil)(editConfig.chipIndex)) {
190
+ if (isKeyFocused) {
191
+ refInputKey.current.selectionStart = refInputKey.current.selectionEnd;
192
+ } else {
193
+ refInputValue.current.selectionStart = refInputValue.current.selectionEnd;
194
+ }
195
+ setEditConfig({
196
+ chipIndex: chipIndex,
197
+ isEdit: true,
198
+ isKeyFocused: isKeyFocused,
199
+ isValueFocused: !isKeyFocused
200
+ });
194
201
  }
195
202
  }, [keyName, refInputKey, refInputValue, setEditConfig, editConfig.chipIndex, chipIndex]);
196
203
  var handleOnChange = (0, _react.useCallback)(function (event) {
197
204
  event.preventDefault();
198
205
  if (event.target.name === keyName) {
199
- var currentWidthKeyInput = refInputKey.current.scrollWidth;
206
+ var currentWidthKeyInput = (0, _formChipCell.getTextWidth)(refInputKey.current);
200
207
  setChipData(function (prevState) {
201
208
  return _objectSpread(_objectSpread({}, prevState), {}, {
202
209
  key: refInputKey.current.value,
@@ -204,7 +211,7 @@ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
204
211
  });
205
212
  });
206
213
  } else {
207
- var currentWidthValueInput = refInputValue.current.scrollWidth;
214
+ var currentWidthValueInput = (0, _formChipCell.getTextWidth)(refInputValue.current);
208
215
  setChipData(function (prevState) {
209
216
  var _refInputValue$curren;
210
217
  return _objectSpread(_objectSpread({}, prevState), {}, {
@@ -214,7 +221,7 @@ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
214
221
  });
215
222
  }
216
223
  }, [maxWidthInput, refInputKey, refInputValue, keyName]);
217
- (0, _react.useEffect)(function () {
224
+ (0, _react.useLayoutEffect)(function () {
218
225
  if (editConfig.chipIndex === chipIndex) {
219
226
  setSelectedInput(editConfig.isKeyFocused ? 'key' : editConfig.isValueFocused ? 'value' : null);
220
227
  }
@@ -260,7 +267,7 @@ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
260
267
  ref: refInputContainer,
261
268
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_NewChipInput.default, {
262
269
  className: labelKeyClassName,
263
- disabled: !isEditable || editConfig.chipIndex && editConfig.chipIndex !== chipIndex,
270
+ disabled: !isEditable || !(0, _lodash.isNil)(editConfig.chipIndex) && editConfig.chipIndex !== chipIndex,
264
271
  name: keyName,
265
272
  onChange: handleOnChange,
266
273
  onFocus: handleOnFocus,
@@ -274,7 +281,7 @@ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
274
281
  children: ":"
275
282
  }), !chipData.isKeyOnly && /*#__PURE__*/(0, _jsxRuntime.jsx)(_NewChipInput.default, {
276
283
  className: labelValueClassName,
277
- disabled: !isEditable || editConfig.chipIndex && editConfig.chipIndex !== chipIndex,
284
+ disabled: !isEditable || !(0, _lodash.isNil)(editConfig.chipIndex) && editConfig.chipIndex !== chipIndex,
278
285
  name: valueName,
279
286
  onChange: handleOnChange,
280
287
  onFocus: handleOnFocus,
@@ -283,15 +290,15 @@ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
283
290
  style: {
284
291
  width: chipData.valueFieldWidth
285
292
  }
286
- }), editConfig.chipIndex !== chipIndex && isEditable && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
287
- className: "edit-chip__icon-close",
293
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
294
+ className: closeButtonClass,
288
295
  onClick: function onClick(event) {
289
296
  return handleRemoveChip(event, chipIndex);
290
297
  },
291
298
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_close.ReactComponent, {})
292
299
  }), (editConfig.isKeyFocused ? !(0, _lodash.isEmpty)(chipData.key) : !(0, _lodash.isEmpty)(chipData.value)) && editConfig.chipIndex === chipIndex && !(0, _lodash.isEmpty)((0, _lodash.get)(meta, ['error', editConfig.chipIndex, selectedInput], [])) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_OptionsMenu.default, {
293
300
  show: showValidationRules,
294
- ref: ref,
301
+ ref: refInputContainer,
295
302
  children: getValidationRules()
296
303
  })]
297
304
  });
@@ -18,6 +18,10 @@
18
18
  background-color: transparent;
19
19
  border: none;
20
20
 
21
+ &[disabled] {
22
+ pointer-events: none;
23
+ }
24
+
21
25
  &.item_edited {
22
26
  &_invalid {
23
27
  color: $amaranth;
@@ -58,6 +62,10 @@
58
62
  align-items: center;
59
63
  justify-content: center;
60
64
 
65
+ &_hidden {
66
+ visibility: hidden;
67
+ }
68
+
61
69
  svg {
62
70
  transform: scale(0.7);
63
71
  }
@@ -3,7 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.uniquenessError = void 0;
6
+ exports.uniquenessError = exports.getTextWidth = void 0;
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ 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."); }
9
+ 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); }
10
+ 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; }
11
+ 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; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
13
  /*
8
14
  Copyright 2022 Iguazio Systems Ltd.
9
15
  Licensed under the Apache License, Version 2.0 (the "License") with
@@ -24,4 +30,34 @@ var uniquenessError = {
24
30
  name: 'uniqueness',
25
31
  label: 'Key must be unique'
26
32
  };
27
- exports.uniquenessError = uniquenessError;
33
+ exports.uniquenessError = uniquenessError;
34
+ var getTextWidth = function getTextWidth(elementWithText) {
35
+ var _hiddenElement$offset;
36
+ if (!elementWithText) {
37
+ return 0;
38
+ }
39
+ var hiddenElementId = 'chips-hidden-element';
40
+ var hiddenElement = document.getElementById(hiddenElementId);
41
+ if (!hiddenElement) {
42
+ hiddenElement = document.createElement('span');
43
+ var styles = {
44
+ position: 'absolute',
45
+ left: '-10000px',
46
+ top: "auto",
47
+ visibility: 'hidden'
48
+ };
49
+ for (var _i = 0, _Object$entries = Object.entries(styles); _i < _Object$entries.length; _i++) {
50
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
51
+ styleName = _Object$entries$_i[0],
52
+ styleValue = _Object$entries$_i[1];
53
+ hiddenElement.style[styleName] = styleValue;
54
+ }
55
+ hiddenElement.style.font = window.getComputedStyle(elementWithText).font;
56
+ hiddenElement.id = hiddenElementId;
57
+ hiddenElement.tabIndex = -1;
58
+ document.body.append(hiddenElement);
59
+ }
60
+ hiddenElement.textContent = elementWithText.value;
61
+ return (_hiddenElement$offset = hiddenElement.offsetWidth) !== null && _hiddenElement$offset !== void 0 ? _hiddenElement$offset : 0;
62
+ };
63
+ exports.getTextWidth = getTextWidth;
@@ -85,21 +85,16 @@ var FormSelect = function FormSelect(_ref) {
85
85
  _useState6 = _slicedToArray(_useState5, 2),
86
86
  isOpen = _useState6[0],
87
87
  setIsOpen = _useState6[1];
88
- var _useState7 = (0, _react.useState)('bottom-right'),
88
+ var _useState7 = (0, _react.useState)(''),
89
89
  _useState8 = _slicedToArray(_useState7, 2),
90
- position = _useState8[0],
91
- setPosition = _useState8[1];
92
- var _useState9 = (0, _react.useState)(''),
93
- _useState10 = _slicedToArray(_useState9, 2),
94
- searchValue = _useState10[0],
95
- setSearchValue = _useState10[1];
90
+ searchValue = _useState8[0],
91
+ setSearchValue = _useState8[1];
96
92
  var optionsListRef = (0, _react.useRef)();
97
93
  var popUpRef = (0, _react.useRef)();
98
94
  var selectRef = (0, _react.useRef)();
99
95
  var searchRef = (0, _react.useRef)();
100
96
  var _ref2 = (selectRef === null || selectRef === void 0 ? void 0 : (_selectRef$current = selectRef.current) === null || _selectRef$current === void 0 ? void 0 : _selectRef$current.getBoundingClientRect()) || {},
101
- selectWidth = _ref2.width,
102
- selectLeft = _ref2.left;
97
+ selectWidth = _ref2.width;
103
98
  var selectWrapperClassNames = (0, _classnames.default)('form-field__wrapper', "form-field__wrapper-".concat(density), disabled && 'form-field__wrapper-disabled', isOpen && 'form-field__wrapper-active', isInvalid && 'form-field__wrapper-invalid', withoutBorder && 'without-border');
104
99
  var selectLabelClassName = (0, _classnames.default)('form-field__label', disabled && 'form-field__label-disabled');
105
100
  var selectValueClassName = (0, _classnames.default)('form-field__select-value', !input.value && 'form-field__select-placeholder');
@@ -160,13 +155,6 @@ var FormSelect = function FormSelect(_ref) {
160
155
  closeMenu();
161
156
  }
162
157
  }, [closeMenu]);
163
- (0, _react.useLayoutEffect)(function () {
164
- if (popUpRef !== null && popUpRef !== void 0 && popUpRef.current) {
165
- var _popUpRef$current$get = popUpRef.current.getBoundingClientRect(),
166
- width = _popUpRef$current$get.width;
167
- selectLeft + width > window.innerWidth ? setPosition('bottom-left') : setPosition('bottom-right');
168
- }
169
- }, [isOpen, selectLeft]);
170
158
  (0, _react.useEffect)(function () {
171
159
  if (isOpen) {
172
160
  window.addEventListener('scroll', handleScroll, true);
@@ -324,7 +312,8 @@ var FormSelect = function FormSelect(_ref) {
324
312
  ref: popUpRef,
325
313
  customPosition: {
326
314
  element: selectRef,
327
- position: position
315
+ position: 'bottom-right',
316
+ autoHorizontalPosition: true
328
317
  },
329
318
  style: {
330
319
  maxWidth: "".concat(selectWidth < 500 ? 500 : selectWidth, "px"),
@@ -74,15 +74,45 @@ var PopUpDialog = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
74
74
  horizontalPosition = _customPosition$posit2[1];
75
75
  var popupMargin = 15;
76
76
  var elementMargin = 5;
77
+ var isEnoughSpaceFromLeft = elementRect.right >= popUpRect.width + popupMargin;
78
+ var isEnoughSpaceFromRight = window.innerWidth - elementRect.left >= popUpRect.width + popupMargin;
79
+ var isEnoughSpaceFromTop = elementRect.top > popUpRect.height + popupMargin + elementMargin;
80
+ var isEnoughSpaceFromBottom = elementRect.bottom + popUpRect.height + popupMargin + elementMargin <= window.innerHeight;
77
81
  var leftPosition = horizontalPosition === 'left' ? elementRect.right - popUpRect.width : elementRect.left;
78
82
  var topPosition;
79
83
  if (verticalPosition === 'top') {
80
- topPosition = elementRect.top > popUpRect.height + popupMargin ? elementRect.top - popUpRect.height - elementMargin : popupMargin;
84
+ topPosition = isEnoughSpaceFromTop ? elementRect.top - popUpRect.height - elementMargin : popupMargin;
81
85
  } else {
82
- topPosition = popUpRect.height + elementRect.bottom + popupMargin > window.innerHeight ? window.innerHeight - popUpRect.height - popupMargin : elementRect.bottom + elementMargin;
86
+ topPosition = isEnoughSpaceFromBottom ? elementRect.bottom + elementMargin : window.innerHeight - popUpRect.height - popupMargin;
87
+ }
88
+ if (customPosition.autoVerticalPosition) {
89
+ if (verticalPosition === 'top') {
90
+ if (!isEnoughSpaceFromTop && isEnoughSpaceFromBottom) {
91
+ topPosition = elementRect.bottom + elementMargin;
92
+ }
93
+ } else {
94
+ if (isEnoughSpaceFromTop && !isEnoughSpaceFromBottom) {
95
+ topPosition = elementRect.top - popUpRect.height - elementMargin;
96
+ }
97
+ }
98
+ }
99
+ if (customPosition.autoHorizontalPosition) {
100
+ if (verticalPosition === 'left') {
101
+ if (!isEnoughSpaceFromLeft && isEnoughSpaceFromRight) {
102
+ leftPosition = elementRect.left;
103
+ } else if (!isEnoughSpaceFromLeft && !isEnoughSpaceFromRight) {
104
+ leftPosition = popupMargin;
105
+ }
106
+ } else {
107
+ if (isEnoughSpaceFromLeft && !isEnoughSpaceFromRight) {
108
+ leftPosition = elementRect.right - popUpRect.width;
109
+ } else if (!isEnoughSpaceFromLeft && !isEnoughSpaceFromRight) {
110
+ leftPosition = window.innerWidth - popUpRect.width - popupMargin;
111
+ }
112
+ }
83
113
  }
84
114
  ref.current.style.top = "".concat(topPosition, "px");
85
- if (style.left) {
115
+ if (style.left && !(customPosition.autoHorizontalPosition && isEnoughSpaceFromRight)) {
86
116
  ref.current.style.left = "calc(".concat(leftPosition, "px + ").concat(style.left, ")");
87
117
  } else {
88
118
  ref.current.style.left = "".concat(leftPosition, "px");
@@ -68,10 +68,10 @@ var Tooltip = function Tooltip(_ref) {
68
68
  setShow(false);
69
69
  };
70
70
  var handleMouseLeave = (0, _react.useCallback)(function (event) {
71
- if (tooltipRef.current && !tooltipRef.current.contains(event.relatedTarget) && parentRef.current && !parentRef.current.contains(event.relatedTarget)) {
71
+ if (tooltipRef.current && !tooltipRef.current.contains(event.relatedTarget) && parentRef.current && !parentRef.current.contains(event.relatedTarget) || hidden) {
72
72
  setShow(false);
73
73
  }
74
- }, []);
74
+ }, [hidden]);
75
75
  var handleMouseEnter = (0, _react.useCallback)(function (event) {
76
76
  if (!show) {
77
77
  var _parentRef$current$ch = _slicedToArray(parentRef.current.childNodes, 1),
@@ -44,10 +44,12 @@ var OptionsMenu = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
44
44
  className: "options-menu",
45
45
  customPosition: {
46
46
  element: ref,
47
- position: 'bottom-right'
47
+ position: 'bottom-right',
48
+ autoVerticalPosition: true,
49
+ autoHorizontalPosition: true
48
50
  },
49
51
  style: {
50
- width: "".concat(dropdownWidth, "px")
52
+ 'minWidth': "".concat(dropdownWidth, "px")
51
53
  },
52
54
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", {
53
55
  className: "options-menu__body",
@@ -64,7 +66,7 @@ OptionsMenu.defaultProps = {
64
66
  OptionsMenu.propTypes = {
65
67
  children: _propTypes.default.arrayOf(_propTypes.default.element),
66
68
  show: _propTypes.default.bool.isRequired,
67
- timout: _propTypes.default.number
69
+ timeout: _propTypes.default.number
68
70
  };
69
71
  var _default = OptionsMenu;
70
72
  exports.default = _default;
@@ -4,6 +4,7 @@ $amaranth: #ea336a;
4
4
  $amethyst: #a44cc5;
5
5
  $amethystTwo: rgba($amethyst, 0.16);
6
6
  $athensGray: #ebebec;
7
+ $babyPink: #f4bec6;
7
8
  $black: #000;
8
9
  $bombay: #b1b1b7;
9
10
  $brightTurquoise: #0fddaf;
package/dist/types.js CHANGED
@@ -56,7 +56,9 @@ var CHIPS = _propTypes.default.arrayOf(CHIP);
56
56
  exports.CHIPS = CHIPS;
57
57
  var POP_UP_CUSTOM_POSITION = _propTypes.default.shape({
58
58
  element: _propTypes.default.shape({}),
59
- position: _propTypes.default.oneOf(['top-left', 'top-right', 'bottom-left', 'bottom-right'])
59
+ position: _propTypes.default.oneOf(['top-left', 'top-right', 'bottom-left', 'bottom-right']),
60
+ autoHorizontalPosition: _propTypes.default.bool,
61
+ autoVerticalPosition: _propTypes.default.bool
60
62
  });
61
63
  exports.POP_UP_CUSTOM_POSITION = POP_UP_CUSTOM_POSITION;
62
64
  var MODAL_SIZES = _propTypes.default.oneOf([_constants.MODAL_SM, _constants.MODAL_MD, _constants.MODAL_LG, _constants.MODAL_MIN, _constants.MODAL_MAX]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iguazio.dashboard-react-controls",
3
- "version": "1.8.11",
3
+ "version": "1.9.0",
4
4
  "description": "Collection of resources (such as CSS styles, fonts and images) and ReactJS 17.x components to share among different Iguazio React repos.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",