iguazio.dashboard-react-controls 2.2.23 → 2.2.25
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/FormChipCell/FormChip/FormChip.js +7 -9
- package/dist/components/FormChipCell/NewChipForm/NewChipForm.js +70 -17
- package/dist/components/FormInput/FormInput.js +6 -2
- package/dist/elements/OptionsMenu/OptionsMenu.js +10 -9
- package/dist/images/navbar/llm-prompt-icon.svg +3 -0
- package/dist/images/navbar/model-monitoring.svg +3 -0
- package/package.json +1 -1
|
@@ -55,15 +55,13 @@ const FormChip = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
55
55
|
valueName = ''
|
|
56
56
|
} = _ref;
|
|
57
57
|
const chipRef = _react.default.useRef();
|
|
58
|
-
(0, _react.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
});
|
|
58
|
+
(0, _react.useLayoutEffect)(() => {
|
|
59
|
+
if (chipRef.current && setChipsSizes) {
|
|
60
|
+
setChipsSizes(state => ({
|
|
61
|
+
...state,
|
|
62
|
+
[chipIndex]: chipRef.current.getBoundingClientRect().width
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
67
65
|
}, [chipIndex, setChipsSizes]);
|
|
68
66
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
69
67
|
onClick: event => handleToEditMode(event, chipIndex, keyName),
|
|
@@ -14,6 +14,7 @@ var _ValidationTemplate = _interopRequireDefault(require("../../../elements/Vali
|
|
|
14
14
|
var _types = require("../../../types");
|
|
15
15
|
var _constants = require("../../../constants");
|
|
16
16
|
var _formChipCell = require("../formChipCell.util");
|
|
17
|
+
var _common = require("../../../utils/common.util");
|
|
17
18
|
var _close = require("../../../images/close.svg");
|
|
18
19
|
require("./newChipForm.scss");
|
|
19
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -66,9 +67,6 @@ const NewChipForm = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
66
67
|
const [selectedInput, setSelectedInput] = (0, _react.useState)('key');
|
|
67
68
|
const [validationRules, setValidationRules] = (0, _react.useState)(rules);
|
|
68
69
|
const [showValidationRules, setShowValidationRules] = (0, _react.useState)(false);
|
|
69
|
-
const maxWidthInput = (0, _react.useMemo)(() => {
|
|
70
|
-
return ref.current?.clientWidth - 50;
|
|
71
|
-
}, [ref]);
|
|
72
70
|
const {
|
|
73
71
|
background,
|
|
74
72
|
borderColor,
|
|
@@ -82,29 +80,65 @@ const NewChipForm = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
82
80
|
const minWidthValueInput = (0, _react.useMemo)(() => {
|
|
83
81
|
return isEditable ? 35 : 20;
|
|
84
82
|
}, [isEditable]);
|
|
83
|
+
const transitionEndEventName = (0, _react.useMemo)(() => (0, _common.getTransitionEndEventName)(), []);
|
|
85
84
|
const refInputKey = _react.default.useRef({});
|
|
86
85
|
const refInputValue = _react.default.useRef({});
|
|
87
86
|
const refInputContainer = _react.default.useRef();
|
|
87
|
+
const validationRulesRef = _react.default.useRef();
|
|
88
88
|
const labelKeyClassName = (0, _classnames.default)(className, !editConfig.isKeyFocused && 'item_edited', !(0, _lodash.isEmpty)((0, _lodash.get)(meta, ['error', chipIndex, 'key'], [])) && !(0, _lodash.isEmpty)(chipData.key) && !chip.disabled && 'item_edited_invalid');
|
|
89
89
|
const labelContainerClassName = (0, _classnames.default)('edit-chip-container', background && `edit-chip-container-background_${background}`, borderColor && `edit-chip-container-border_${borderColor}`, font && `edit-chip-container-font_${font}`, density && `edit-chip-container-density_${density}`, borderRadius && `edit-chip-container-border_${borderRadius}`, (editConfig.isEdit || editConfig.isNewChip) && 'edit-chip-container_edited', chip.disabled && 'edit-chip-container_disabled edit-chip-container-font_disabled');
|
|
90
90
|
const 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');
|
|
91
91
|
const closeButtonClass = (0, _classnames.default)('item-icon-close', !chip.disabled && editConfig.chipIndex === chipIndex && isEditable && 'item-icon-close_invisible', !isEditable && 'item-icon-close_hidden');
|
|
92
|
-
(0, _react.
|
|
93
|
-
if (
|
|
94
|
-
const currentWidthKeyInput = refInputKey.current
|
|
95
|
-
const currentWidthValueInput = refInputValue.current
|
|
96
|
-
const
|
|
97
|
-
const
|
|
92
|
+
const resizeChip = (0, _react.useCallback)(() => {
|
|
93
|
+
if (refInputKey.current) {
|
|
94
|
+
const currentWidthKeyInput = (0, _formChipCell.getTextWidth)(refInputKey.current) + 1;
|
|
95
|
+
const currentWidthValueInput = (0, _formChipCell.getTextWidth)(refInputValue.current) + 1;
|
|
96
|
+
const maxWidthInput = ref.current?.clientWidth - 50;
|
|
97
|
+
const keyEllipsis = currentWidthKeyInput >= maxWidthInput / 2;
|
|
98
|
+
const valueEllipsis = currentWidthValueInput >= maxWidthInput / 2;
|
|
99
|
+
let keyFieldWidth = null;
|
|
100
|
+
let valueFieldWidth = null;
|
|
101
|
+
if (keyEllipsis && valueEllipsis) {
|
|
102
|
+
keyFieldWidth = valueFieldWidth = maxWidthInput / 2;
|
|
103
|
+
} else if (keyEllipsis) {
|
|
104
|
+
valueFieldWidth = !chipData.value ? minWidthValueInput : currentWidthValueInput;
|
|
105
|
+
const remainingPlace = maxWidthInput - valueFieldWidth;
|
|
106
|
+
keyFieldWidth = remainingPlace > currentWidthKeyInput ? currentWidthKeyInput : remainingPlace;
|
|
107
|
+
} else if (valueEllipsis) {
|
|
108
|
+
keyFieldWidth = !chipData.key ? minWidthInput : currentWidthKeyInput;
|
|
109
|
+
const remainingPlace = maxWidthInput - keyFieldWidth;
|
|
110
|
+
valueFieldWidth = remainingPlace > currentWidthValueInput ? currentWidthValueInput : remainingPlace;
|
|
111
|
+
} else {
|
|
112
|
+
keyFieldWidth = !chipData.key || currentWidthKeyInput <= minWidthInput ? minWidthInput : currentWidthKeyInput;
|
|
113
|
+
valueFieldWidth = !chipData.value || currentWidthValueInput <= minWidthValueInput ? minWidthValueInput : currentWidthValueInput;
|
|
114
|
+
}
|
|
115
|
+
refInputKey.current.style.width = `${keyFieldWidth}px`;
|
|
116
|
+
if (!(0, _lodash.isEmpty)(refInputValue.current)) {
|
|
117
|
+
refInputValue.current.style.width = `${valueFieldWidth}px`;
|
|
118
|
+
}
|
|
98
119
|
setChipData(prevState => ({
|
|
99
120
|
...prevState,
|
|
100
121
|
keyFieldWidth,
|
|
101
122
|
valueFieldWidth
|
|
102
123
|
}));
|
|
103
124
|
}
|
|
104
|
-
}, [
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
125
|
+
}, [chipData.key, chipData.value, minWidthInput, minWidthValueInput, ref]);
|
|
126
|
+
(0, _react.useEffect)(() => {
|
|
127
|
+
const resizeChipDebounced = (0, _lodash.throttle)(resizeChip, 500);
|
|
128
|
+
if (isEditable) {
|
|
129
|
+
window.addEventListener('resize', resizeChipDebounced);
|
|
130
|
+
window.addEventListener(transitionEndEventName, resizeChipDebounced);
|
|
131
|
+
return () => {
|
|
132
|
+
window.removeEventListener('resize', resizeChipDebounced);
|
|
133
|
+
window.removeEventListener(transitionEndEventName, resizeChipDebounced);
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}, [isEditable, resizeChip, transitionEndEventName]);
|
|
137
|
+
(0, _react.useEffect)(() => {
|
|
138
|
+
if (!chipData.keyFieldWidth && !chipData.valueFieldWidth) {
|
|
139
|
+
resizeChip();
|
|
140
|
+
}
|
|
141
|
+
}, [chipData.keyFieldWidth, chipData.valueFieldWidth, resizeChip]);
|
|
108
142
|
(0, _react.useEffect)(() => {
|
|
109
143
|
if (showValidationRules) {
|
|
110
144
|
window.addEventListener('scroll', handleScroll, true);
|
|
@@ -122,17 +156,32 @@ const NewChipForm = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
122
156
|
}
|
|
123
157
|
}
|
|
124
158
|
}, [editConfig.isKeyFocused, editConfig.isValueFocused, refInputKey, refInputValue, chipIndex, editConfig.chipIndex]);
|
|
125
|
-
const outsideClick = (0, _react.useCallback)(event => {
|
|
159
|
+
const outsideClick = (0, _react.useCallback)((event, forceOutsideClick) => {
|
|
126
160
|
if (editConfig.chipIndex === chipIndex) {
|
|
127
161
|
const elementPath = event.path ?? event.composedPath?.();
|
|
128
|
-
if (!elementPath.includes(refInputContainer.current)) {
|
|
162
|
+
if (!elementPath.includes(refInputContainer.current) || forceOutsideClick) {
|
|
129
163
|
onChange(event, _constants.CLICK, true);
|
|
130
164
|
window.getSelection().removeAllRanges();
|
|
165
|
+
document.activeElement.blur();
|
|
131
166
|
} else {
|
|
132
167
|
event.stopPropagation();
|
|
133
168
|
}
|
|
134
169
|
}
|
|
135
170
|
}, [onChange, refInputContainer, chipIndex, editConfig.chipIndex]);
|
|
171
|
+
const handleScroll = (0, _react.useCallback)(event => {
|
|
172
|
+
if (validationRulesRef?.current && !validationRulesRef.current.contains(event.target)) {
|
|
173
|
+
setShowValidationRules(false);
|
|
174
|
+
outsideClick(event, true);
|
|
175
|
+
}
|
|
176
|
+
}, [outsideClick]);
|
|
177
|
+
(0, _react.useEffect)(() => {
|
|
178
|
+
if (showValidationRules) {
|
|
179
|
+
window.addEventListener('scroll', handleScroll, true);
|
|
180
|
+
}
|
|
181
|
+
return () => {
|
|
182
|
+
window.removeEventListener('scroll', handleScroll, true);
|
|
183
|
+
};
|
|
184
|
+
}, [handleScroll, showValidationRules]);
|
|
136
185
|
(0, _react.useEffect)(() => {
|
|
137
186
|
if (editConfig.isEdit) {
|
|
138
187
|
document.addEventListener('click', outsideClick, true);
|
|
@@ -185,6 +234,7 @@ const NewChipForm = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
185
234
|
}
|
|
186
235
|
}, [keyName, refInputKey, refInputValue, setEditConfig, editConfig.chipIndex, chipIndex]);
|
|
187
236
|
const handleOnChange = (0, _react.useCallback)(event => {
|
|
237
|
+
const maxWidthInput = ref.current?.clientWidth - 50;
|
|
188
238
|
event.preventDefault();
|
|
189
239
|
if (event.target.name === keyName) {
|
|
190
240
|
const currentWidthKeyInput = (0, _formChipCell.getTextWidth)(refInputKey.current);
|
|
@@ -201,7 +251,7 @@ const NewChipForm = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
201
251
|
valueFieldWidth: refInputValue.current.value?.length <= 1 ? minWidthValueInput : currentWidthValueInput >= maxWidthInput ? maxWidthInput : currentWidthValueInput > minWidthValueInput ? currentWidthValueInput + 2 : minWidthValueInput
|
|
202
252
|
}));
|
|
203
253
|
}
|
|
204
|
-
}, [keyName, minWidthInput,
|
|
254
|
+
}, [keyName, minWidthInput, ref, minWidthValueInput]);
|
|
205
255
|
(0, _react.useLayoutEffect)(() => {
|
|
206
256
|
if (editConfig.chipIndex === chipIndex) {
|
|
207
257
|
setSelectedInput(editConfig.isKeyFocused ? 'key' : editConfig.isValueFocused ? 'value' : null);
|
|
@@ -277,7 +327,10 @@ const NewChipForm = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
277
327
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_close.ReactComponent, {})
|
|
278
328
|
}), !chip.disabled && (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, {
|
|
279
329
|
show: showValidationRules,
|
|
280
|
-
ref:
|
|
330
|
+
ref: {
|
|
331
|
+
refInputContainer,
|
|
332
|
+
validationRulesRef
|
|
333
|
+
},
|
|
281
334
|
children: getValidationRules()
|
|
282
335
|
})]
|
|
283
336
|
});
|
|
@@ -51,6 +51,7 @@ const defaultProps = {
|
|
|
51
51
|
onBlur: () => {},
|
|
52
52
|
onChange: () => {},
|
|
53
53
|
onKeyDown: () => {},
|
|
54
|
+
onValidationError: () => {},
|
|
54
55
|
validator: () => {},
|
|
55
56
|
rules: []
|
|
56
57
|
};
|
|
@@ -75,6 +76,7 @@ const FormInput = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
75
76
|
onKeyDown = defaultProps.onKeyDown,
|
|
76
77
|
pattern = null,
|
|
77
78
|
required = false,
|
|
79
|
+
onValidationError = defaultProps.onValidationError,
|
|
78
80
|
suggestionList = [],
|
|
79
81
|
step = '1',
|
|
80
82
|
tip = '',
|
|
@@ -108,8 +110,10 @@ const FormInput = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
108
110
|
setTypedValue(String(input.value)); // convert from number to string
|
|
109
111
|
}, [input.value]);
|
|
110
112
|
(0, _react.useEffect)(() => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
const isInputInvalid = errorsRef.current && meta.invalid && (meta.validating || meta.modified || meta.submitFailed && meta.touched);
|
|
114
|
+
setIsInvalid(isInputInvalid);
|
|
115
|
+
onValidationError(isInputInvalid);
|
|
116
|
+
}, [meta.invalid, meta.modified, meta.submitFailed, meta.touched, meta.validating, onValidationError]);
|
|
113
117
|
(0, _react.useEffect)(() => {
|
|
114
118
|
if (!errorsRef.current) {
|
|
115
119
|
if (meta.valid && showValidationRules) {
|
|
@@ -4,15 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _reactTransitionGroup = require("react-transition-group");
|
|
10
10
|
var _components = require("../../components");
|
|
11
11
|
require("./optionsMenu.scss");
|
|
12
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
-
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); }
|
|
15
|
-
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; }
|
|
16
14
|
/*
|
|
17
15
|
Copyright 2022 Iguazio Systems Ltd.
|
|
18
16
|
Licensed under the Apache License, Version 2.0 (the "License") with
|
|
@@ -30,28 +28,31 @@ under the Apache 2.0 license is conditioned upon your compliance with
|
|
|
30
28
|
such restriction.
|
|
31
29
|
*/
|
|
32
30
|
|
|
33
|
-
const OptionsMenu = /*#__PURE__*/_react.default.forwardRef((_ref,
|
|
31
|
+
const OptionsMenu = /*#__PURE__*/_react.default.forwardRef((_ref, _ref2) => {
|
|
34
32
|
let {
|
|
35
33
|
children = [],
|
|
36
34
|
show = false,
|
|
37
35
|
timeout = 300
|
|
38
36
|
} = _ref;
|
|
39
|
-
|
|
37
|
+
let {
|
|
38
|
+
refInputContainer,
|
|
39
|
+
validationRulesRef
|
|
40
|
+
} = _ref2;
|
|
40
41
|
const {
|
|
41
42
|
width: dropdownWidth
|
|
42
|
-
} =
|
|
43
|
+
} = refInputContainer?.current ? refInputContainer.current.getBoundingClientRect() : {};
|
|
43
44
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactTransitionGroup.CSSTransition, {
|
|
44
|
-
nodeRef:
|
|
45
|
+
nodeRef: validationRulesRef,
|
|
45
46
|
in: show,
|
|
46
47
|
timeout: timeout,
|
|
47
48
|
classNames: "options-menu-transition",
|
|
48
49
|
unmountOnExit: true,
|
|
49
50
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.PopUpDialog, {
|
|
50
|
-
ref:
|
|
51
|
+
ref: validationRulesRef,
|
|
51
52
|
headerIsHidden: true,
|
|
52
53
|
className: "options-menu",
|
|
53
54
|
customPosition: {
|
|
54
|
-
element:
|
|
55
|
+
element: refInputContainer,
|
|
55
56
|
position: 'bottom-right',
|
|
56
57
|
autoVerticalPosition: true,
|
|
57
58
|
autoHorizontalPosition: true
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M3.6 10.8H10.8V9H3.6V10.8ZM3.6 8.1H14.4V6.3H3.6V8.1ZM3.6 5.4H14.4V3.6H3.6V5.4ZM0 18V1.8C0 1.305 0.17625 0.88125 0.52875 0.52875C0.88125 0.17625 1.305 0 1.8 0H16.2C16.695 0 17.1187 0.17625 17.4713 0.52875C17.8237 0.88125 18 1.305 18 1.8V12.6C18 13.095 17.8237 13.5188 17.4713 13.8713C17.1187 14.2238 16.695 14.4 16.2 14.4H3.6L0 18ZM2.835 12.6H16.2V1.8H1.8V13.6125L2.835 12.6Z" fill="white"/>
|
|
3
|
+
</svg>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iguazio.dashboard-react-controls",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.25",
|
|
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",
|