iguazio.dashboard-react-controls 1.3.8 → 1.3.10
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.
- package/dist/components/FormSelect/FormSelect.js +1 -1
- package/dist/components/Tooltip/Tooltip.js +57 -43
- package/dist/constants.js +2 -6
- package/dist/elements/SelectOption/SelectOption.js +1 -3
- package/dist/hooks/useFormTable.hook.js +3 -0
- package/dist/utils/validation.util.js +2 -2
- package/package.json +1 -1
|
@@ -178,7 +178,7 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
178
178
|
};
|
|
179
179
|
}, [clickHandler, handleScroll, isOpen]);
|
|
180
180
|
var scrollOptionToView = (0, _react.useCallback)(function () {
|
|
181
|
-
var selectedOptionEl = optionsListRef.current.querySelector("
|
|
181
|
+
var selectedOptionEl = optionsListRef.current.querySelector("[data-custom-id=\"".concat(input.value, "\"]"));
|
|
182
182
|
if (!selectedOptionEl) return;
|
|
183
183
|
searchValue ? optionsListRef.current.scrollTo({
|
|
184
184
|
top: 0,
|
|
@@ -65,61 +65,75 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
65
65
|
var handleScroll = function handleScroll() {
|
|
66
66
|
setShow(false);
|
|
67
67
|
};
|
|
68
|
-
var handleMouseLeave = function
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
var handleMouseLeave = (0, _react.useCallback)(function (event) {
|
|
69
|
+
if (tooltipRef.current && !tooltipRef.current.contains(event.relatedTarget) && parentRef.current && !parentRef.current.contains(event.relatedTarget)) {
|
|
70
|
+
setShow(false);
|
|
71
|
+
}
|
|
72
|
+
}, []);
|
|
71
73
|
var handleMouseEnter = (0, _react.useCallback)(function (event) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
74
|
+
if (!show) {
|
|
75
|
+
var _parentRef$current$ch = _slicedToArray(parentRef.current.childNodes, 1),
|
|
76
|
+
child = _parentRef$current$ch[0];
|
|
77
|
+
var _show = !hidden && (textShow ? true : !child ? false : child.nodeType !== Node.TEXT_NODE ||
|
|
78
|
+
/*
|
|
79
|
+
If the child node is a text node and the text of the child node inside the container is greater than the width of the container, then show tooltip.
|
|
80
|
+
*/
|
|
81
|
+
child.nodeType === Node.TEXT_NODE && parentRef.current.scrollWidth > parentRef.current.offsetWidth);
|
|
82
|
+
if (_show) {
|
|
83
|
+
var _parentRef$current$ge, _parentRef$current, _tooltipRef$current$g, _tooltipRef$current;
|
|
84
|
+
setShow(true);
|
|
85
|
+
var _ref2 = (_parentRef$current$ge = parentRef === null || parentRef === void 0 ? void 0 : (_parentRef$current = parentRef.current) === null || _parentRef$current === void 0 ? void 0 : _parentRef$current.getBoundingClientRect()) !== null && _parentRef$current$ge !== void 0 ? _parentRef$current$ge : {},
|
|
86
|
+
height = _ref2.height,
|
|
87
|
+
top = _ref2.top,
|
|
88
|
+
bottom = _ref2.bottom;
|
|
89
|
+
var _ref3 = (_tooltipRef$current$g = (_tooltipRef$current = tooltipRef.current) === null || _tooltipRef$current === void 0 ? void 0 : _tooltipRef$current.getBoundingClientRect()) !== null && _tooltipRef$current$g !== void 0 ? _tooltipRef$current$g : {
|
|
90
|
+
height: 0,
|
|
91
|
+
width: 0
|
|
92
|
+
},
|
|
93
|
+
tooltipHeight = _ref3.height,
|
|
94
|
+
tooltipWidth = _ref3.width;
|
|
95
|
+
var leftPosition = event.x - (event.x + tooltipWidth - window.innerWidth + offset);
|
|
96
|
+
var left = event.x + tooltipWidth + offset > window.innerWidth ? leftPosition > offset ? leftPosition : offset : event.x + offset;
|
|
97
|
+
if (top + height + offset + tooltipHeight >= window.innerHeight) {
|
|
98
|
+
var topPosition = bottom - height - offset - tooltipHeight;
|
|
99
|
+
setStyle({
|
|
100
|
+
top: topPosition > 0 ? topPosition : offset,
|
|
101
|
+
left: left
|
|
102
|
+
});
|
|
103
|
+
} else {
|
|
104
|
+
setStyle({
|
|
105
|
+
top: top + height + offset,
|
|
106
|
+
left: left
|
|
107
|
+
});
|
|
108
|
+
}
|
|
104
109
|
}
|
|
105
110
|
}
|
|
106
|
-
}, [hidden, textShow]);
|
|
111
|
+
}, [hidden, textShow, show]);
|
|
107
112
|
var clearStyles = (0, _lodash.debounce)(function () {
|
|
108
113
|
if (!(0, _common.isEveryObjectValueEmpty)(style)) {
|
|
109
114
|
setStyle({});
|
|
110
115
|
}
|
|
111
116
|
}, 100);
|
|
112
117
|
(0, _react.useEffect)(function () {
|
|
113
|
-
var
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
|
|
118
|
+
var parentNode = parentRef.current;
|
|
119
|
+
if (parentNode) {
|
|
120
|
+
parentNode.addEventListener('mouseenter', handleMouseEnter);
|
|
121
|
+
parentNode.addEventListener('mouseleave', handleMouseLeave);
|
|
122
|
+
return function () {
|
|
123
|
+
parentNode.removeEventListener('mouseenter', handleMouseEnter);
|
|
124
|
+
parentNode.removeEventListener('mouseleave', handleMouseLeave);
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}, [parentRef, handleMouseEnter, handleMouseLeave]);
|
|
128
|
+
(0, _react.useEffect)(function () {
|
|
129
|
+
var tooltipNode = tooltipRef.current;
|
|
130
|
+
if (tooltipNode && show) {
|
|
131
|
+
tooltipNode.addEventListener('mouseleave', handleMouseLeave);
|
|
117
132
|
return function () {
|
|
118
|
-
|
|
119
|
-
node.removeEventListener('mouseleave', handleMouseLeave);
|
|
133
|
+
tooltipNode.removeEventListener('mouseleave', handleMouseLeave);
|
|
120
134
|
};
|
|
121
135
|
}
|
|
122
|
-
}, [
|
|
136
|
+
}, [tooltipRef, handleMouseEnter, handleMouseLeave, show]);
|
|
123
137
|
(0, _react.useEffect)(function () {
|
|
124
138
|
if (show) {
|
|
125
139
|
window.addEventListener('scroll', handleScroll, true);
|
package/dist/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.validation = exports.TERTIARY_BUTTON = exports.TAB_SHIFT = exports.TAB = exports.
|
|
6
|
+
exports.validation = exports.TERTIARY_BUTTON = exports.TAB_SHIFT = exports.TAB = exports.SECONDARY_BUTTON = exports.PRIMARY_BUTTON = exports.NOTFOUND_ERROR_STATUS_CODE = exports.MODAL_SM = exports.MODAL_MIN = exports.MODAL_MD = exports.MODAL_MAX = exports.MODAL_LG = exports.LABEL_BUTTON = exports.INTERNAL_SERVER_ERROR_STATUS_CODE = exports.GATEWAY_TIMEOUT_STATUS_CODE = exports.FORBIDDEN_ERROR_STATUS_CODE = exports.DELETE = exports.DANGER_BUTTON = exports.CONFLICT_ERROR_STATUS_CODE = exports.CLICK = exports.BADREQUEST_ERROR_STATUS_CODE = exports.BACKSPACE = void 0;
|
|
7
7
|
/*
|
|
8
8
|
Copyright 2022 Iguazio Systems Ltd.
|
|
9
9
|
Licensed under the Apache License, Version 2.0 (the "License") with
|
|
@@ -86,8 +86,4 @@ exports.MODAL_LG = MODAL_LG;
|
|
|
86
86
|
var MODAL_MIN = 'min';
|
|
87
87
|
exports.MODAL_MIN = MODAL_MIN;
|
|
88
88
|
var MODAL_MAX = 'max';
|
|
89
|
-
|
|
90
|
-
/*=========== SELECT =============*/
|
|
91
|
-
exports.MODAL_MAX = MODAL_MAX;
|
|
92
|
-
var SELECT_OPTION_ID_PREFIX = 'id-';
|
|
93
|
-
exports.SELECT_OPTION_ID_PREFIX = SELECT_OPTION_ID_PREFIX;
|
|
89
|
+
exports.MODAL_MAX = MODAL_MAX;
|
|
@@ -9,7 +9,6 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
9
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
10
|
var _components = require("../../components");
|
|
11
11
|
var _types = require("../../types");
|
|
12
|
-
var _constants = require("../../constants");
|
|
13
12
|
var _checkmark = require("../../images/checkmark.svg");
|
|
14
13
|
require("./selectOption.scss");
|
|
15
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -59,7 +58,7 @@ var SelectOption = function SelectOption(_ref) {
|
|
|
59
58
|
onClick: function onClick() {
|
|
60
59
|
!item.disabled && _onClick(item.id);
|
|
61
60
|
},
|
|
62
|
-
id:
|
|
61
|
+
"data-custom-id": item.id,
|
|
63
62
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
64
63
|
className: "label-row",
|
|
65
64
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
@@ -99,7 +98,6 @@ SelectOption.defaultProps = {
|
|
|
99
98
|
withSelectedIcon: true
|
|
100
99
|
};
|
|
101
100
|
SelectOption.propTypes = {
|
|
102
|
-
disabled: _propTypes.default.bool,
|
|
103
101
|
name: _propTypes.default.string.isRequired,
|
|
104
102
|
item: _types.SELECT_OPTION.isRequired,
|
|
105
103
|
onClick: _propTypes.default.func,
|
|
@@ -68,6 +68,9 @@ var useFormTable = function useFormTable(formState) {
|
|
|
68
68
|
var _editingItemRef$curre, _editingItemRef$curre2;
|
|
69
69
|
if ((_editingItemRef$curre = editingItemRef.current) !== null && _editingItemRef$curre !== void 0 && (_editingItemRef$curre2 = _editingItemRef$curre.ui) !== null && _editingItemRef$curre2 !== void 0 && _editingItemRef$curre2.isNew) {
|
|
70
70
|
formState.form.mutators.remove(editingItemRef.current.ui.fieldsPath, editingItemRef.current.ui.index);
|
|
71
|
+
if (editingItemRef.current.ui.index === 0) {
|
|
72
|
+
formState.form.mutators.concat(editingItemRef.current.ui.fieldsPath, []);
|
|
73
|
+
}
|
|
71
74
|
} else if (editingItemRef.current) {
|
|
72
75
|
formState.form.mutators.update(editingItemRef.current.ui.fieldsPath, editingItemRef.current.ui.index, (0, _lodash.omit)(editingItemRef.current, ['ui']));
|
|
73
76
|
}
|
|
@@ -228,7 +228,7 @@ var generateRule = {
|
|
|
228
228
|
return {
|
|
229
229
|
name: 'validCharactersWithPrefix',
|
|
230
230
|
label: _constants.validation.VALID_CHARACTERS + ': ' + convertToLabel(chars),
|
|
231
|
-
pattern: new RegExp('^([' + convertToPattern(chars) + ']
|
|
231
|
+
pattern: new RegExp('^([' + convertToPattern(chars) + ']+/)?[' + convertToPattern(chars) + ']+$')
|
|
232
232
|
};
|
|
233
233
|
},
|
|
234
234
|
noConsecutiveCharacters: function noConsecutiveCharacters(chars) {
|
|
@@ -318,7 +318,7 @@ var validationRules = {
|
|
|
318
318
|
}
|
|
319
319
|
},
|
|
320
320
|
function: {
|
|
321
|
-
name: [generateRule.validCharacters('a-z
|
|
321
|
+
name: [generateRule.validCharacters('a-z 0-9 - .'), generateRule.beginEndWith('a-z 0-9'), generateRule.length({
|
|
322
322
|
max: 63
|
|
323
323
|
}), generateRule.required()]
|
|
324
324
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iguazio.dashboard-react-controls",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.10",
|
|
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",
|