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.
- package/dist/components/Backdrop/Backdrop.js +7 -7
- package/dist/components/Button/Button.js +20 -26
- package/dist/components/ConfirmDialog/ConfirmDialog.js +18 -17
- package/dist/components/FormCheckBox/FormCheckBox.js +28 -32
- package/dist/components/FormChipCell/FormChip/FormChip.js +46 -50
- package/dist/components/FormChipCell/FormChipCell.js +122 -142
- package/dist/components/FormChipCell/FormChipCellView.js +44 -47
- package/dist/components/FormChipCell/HiddenChipsBlock/HiddenChipsBlock.js +23 -20
- package/dist/components/FormChipCell/NewChipForm/NewChipForm.js +129 -152
- package/dist/components/FormChipCell/NewChipInput/NewChipInput.js +24 -27
- package/dist/components/FormChipCell/formChipCell.util.js +6 -16
- package/dist/components/FormCombobox/FormCombobox.js +134 -195
- package/dist/components/FormInput/FormInput.js +134 -212
- package/dist/components/FormInput/InputNumberButtons/InputNumberButtons.js +15 -14
- package/dist/components/FormKeyValueTable/FormKeyValueTable.js +72 -72
- package/dist/components/FormRadio/FormRadio.js +21 -25
- package/dist/components/FormSelect/FormSelect.js +98 -126
- package/dist/components/FormSelect/FormSelect.test.js +56 -60
- package/dist/components/FormTextarea/FormTextarea.js +55 -71
- package/dist/components/FormToggle/FormToggle.js +25 -29
- package/dist/components/Modal/Modal.js +17 -18
- package/dist/components/PopUpDialog/PopUpDialog.js +53 -63
- package/dist/components/RoundedIcon/RoundedIcon.js +14 -13
- package/dist/components/Tip/Tip.js +58 -64
- package/dist/components/Tip/Tip.test.js +41 -64
- package/dist/components/Tooltip/Tooltip.js +75 -89
- package/dist/components/TooltipTemplate/ProducerTooltipTemplate.js +6 -5
- package/dist/components/TooltipTemplate/TextTooltipTemplate.js +10 -10
- package/dist/components/Wizard/Wizard.js +73 -107
- package/dist/components/Wizard/WizardSteps/WizardSteps.js +19 -20
- package/dist/components/index.js +18 -18
- package/dist/constants.js +26 -44
- package/dist/elements/FormActionButton/FormActionButton.js +12 -13
- package/dist/elements/FormRowActions/FormRowActions.js +19 -22
- package/dist/elements/OptionsMenu/OptionsMenu.js +10 -8
- package/dist/elements/SelectOption/SelectOption.js +14 -13
- package/dist/elements/SelectOption/SelectOption.test.js +39 -47
- package/dist/elements/ValidationTemplate/ValidationTemplate.js +7 -6
- package/dist/elements/index.js +5 -5
- package/dist/hooks/index.js +5 -5
- package/dist/hooks/useChipCell.hook.js +66 -85
- package/dist/hooks/useDebounce.hook.js +22 -24
- package/dist/hooks/useDetectOutsideClick.hook.js +4 -4
- package/dist/hooks/useFormTable.hook.js +99 -112
- package/dist/hooks/useHiddenChipsBlock.hook.js +40 -55
- package/dist/index.js +2 -3
- package/dist/scss/borders.scss +6 -0
- package/dist/scss/mixins.scss +32 -0
- package/dist/types.js +43 -67
- package/dist/utils/common.util.js +19 -23
- package/dist/utils/form.util.js +33 -39
- package/dist/utils/generateChipsList.util.js +7 -7
- package/dist/utils/getFirstScrollableParent.util.js +4 -10
- package/dist/utils/math.util.js +3 -3
- package/dist/utils/validation.util.js +74 -131
- package/package.json +34 -34
|
@@ -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
|
});
|
|
@@ -19,114 +18,96 @@ var _close = require("../../../images/close.svg");
|
|
|
19
18
|
require("./newChipForm.scss");
|
|
20
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
-
function _getRequireWildcardCache(
|
|
23
|
-
function _interopRequireWildcard(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
keyFieldWidth: 0,
|
|
69
|
-
valueFieldWidth: 0
|
|
70
|
-
}),
|
|
71
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
72
|
-
chipData = _useState2[0],
|
|
73
|
-
setChipData = _useState2[1];
|
|
74
|
-
var _useState3 = (0, _react.useState)('key'),
|
|
75
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
76
|
-
selectedInput = _useState4[0],
|
|
77
|
-
setSelectedInput = _useState4[1];
|
|
78
|
-
var _useState5 = (0, _react.useState)(rules),
|
|
79
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
80
|
-
validationRules = _useState6[0],
|
|
81
|
-
setValidationRules = _useState6[1];
|
|
82
|
-
var _useState7 = (0, _react.useState)(false),
|
|
83
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
84
|
-
showValidationRules = _useState8[0],
|
|
85
|
-
setShowValidationRules = _useState8[1];
|
|
86
|
-
var maxWidthInput = (0, _react.useMemo)(function () {
|
|
21
|
+
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); }
|
|
22
|
+
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; }
|
|
23
|
+
/*
|
|
24
|
+
Copyright 2022 Iguazio Systems Ltd.
|
|
25
|
+
Licensed under the Apache License, Version 2.0 (the "License") with
|
|
26
|
+
an addition restriction as set forth herein. You may not use this
|
|
27
|
+
file except in compliance with the License. You may obtain a copy of
|
|
28
|
+
the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
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
|
+
In addition, you may not use the software for any purposes that are
|
|
35
|
+
illegal under applicable law, and the grant of the foregoing license
|
|
36
|
+
under the Apache 2.0 license is conditioned upon your compliance with
|
|
37
|
+
such restriction.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
const NewChipForm = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
41
|
+
let {
|
|
42
|
+
chip,
|
|
43
|
+
chipIndex,
|
|
44
|
+
chipOptions,
|
|
45
|
+
className,
|
|
46
|
+
editConfig,
|
|
47
|
+
handleRemoveChip,
|
|
48
|
+
isEditable,
|
|
49
|
+
keyName,
|
|
50
|
+
meta,
|
|
51
|
+
onChange,
|
|
52
|
+
setEditConfig,
|
|
53
|
+
validationRules: rules,
|
|
54
|
+
valueName
|
|
55
|
+
} = _ref;
|
|
56
|
+
const [chipData, setChipData] = (0, _react.useState)({
|
|
57
|
+
isKeyOnly: chip.isKeyOnly,
|
|
58
|
+
key: chip.key,
|
|
59
|
+
value: chip.value,
|
|
60
|
+
keyFieldWidth: 0,
|
|
61
|
+
valueFieldWidth: 0
|
|
62
|
+
});
|
|
63
|
+
const [selectedInput, setSelectedInput] = (0, _react.useState)('key');
|
|
64
|
+
const [validationRules, setValidationRules] = (0, _react.useState)(rules);
|
|
65
|
+
const [showValidationRules, setShowValidationRules] = (0, _react.useState)(false);
|
|
66
|
+
const maxWidthInput = (0, _react.useMemo)(() => {
|
|
87
67
|
var _ref$current;
|
|
88
68
|
return ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.clientWidth) - 50;
|
|
89
69
|
}, [ref]);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
(0,
|
|
70
|
+
const {
|
|
71
|
+
background,
|
|
72
|
+
borderColor,
|
|
73
|
+
borderRadius,
|
|
74
|
+
density,
|
|
75
|
+
font
|
|
76
|
+
} = chipOptions;
|
|
77
|
+
const minWidthInput = 25;
|
|
78
|
+
const minWidthValueInput = 35;
|
|
79
|
+
const refInputKey = _react.default.useRef({});
|
|
80
|
+
const refInputValue = _react.default.useRef({});
|
|
81
|
+
const refInputContainer = _react.default.useRef();
|
|
82
|
+
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) && 'item_edited_invalid');
|
|
83
|
+
const 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');
|
|
84
|
+
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');
|
|
85
|
+
const closeButtonClass = (0, _classnames.default)('item-icon-close', (editConfig.chipIndex === chipIndex || !isEditable) && 'item-icon-close_hidden');
|
|
86
|
+
(0, _react.useLayoutEffect)(() => {
|
|
105
87
|
if (!chipData.keyFieldWidth && !chipData.valueFieldWidth) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
setChipData(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
});
|
|
88
|
+
const currentWidthKeyInput = refInputKey.current.scrollWidth + 1;
|
|
89
|
+
const currentWidthValueInput = refInputValue.current.scrollWidth + 1;
|
|
90
|
+
const keyFieldWidth = !chipData.key || currentWidthKeyInput <= minWidthInput ? minWidthInput : currentWidthKeyInput >= maxWidthInput ? maxWidthInput : currentWidthKeyInput;
|
|
91
|
+
const valueFieldWidth = !chipData.value || currentWidthValueInput <= minWidthValueInput ? minWidthValueInput : currentWidthValueInput >= maxWidthInput ? maxWidthInput : currentWidthValueInput;
|
|
92
|
+
setChipData(prevState => ({
|
|
93
|
+
...prevState,
|
|
94
|
+
keyFieldWidth,
|
|
95
|
+
valueFieldWidth
|
|
96
|
+
}));
|
|
116
97
|
}
|
|
117
98
|
}, [chipData.key, chipData.value, chipData.keyFieldWidth, chipData.valueFieldWidth, maxWidthInput, refInputKey, refInputValue]);
|
|
118
|
-
|
|
99
|
+
const handleScroll = () => {
|
|
119
100
|
setShowValidationRules(false);
|
|
120
101
|
};
|
|
121
|
-
(0, _react.useEffect)(
|
|
102
|
+
(0, _react.useEffect)(() => {
|
|
122
103
|
if (showValidationRules) {
|
|
123
104
|
window.addEventListener('scroll', handleScroll, true);
|
|
124
105
|
}
|
|
125
|
-
return
|
|
106
|
+
return () => {
|
|
126
107
|
window.removeEventListener('scroll', handleScroll, true);
|
|
127
108
|
};
|
|
128
109
|
}, [showValidationRules]);
|
|
129
|
-
(0, _react.useEffect)(
|
|
110
|
+
(0, _react.useEffect)(() => {
|
|
130
111
|
if (editConfig.chipIndex === chipIndex) {
|
|
131
112
|
if (editConfig.isKeyFocused) {
|
|
132
113
|
refInputKey.current.focus();
|
|
@@ -135,10 +116,10 @@ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
135
116
|
}
|
|
136
117
|
}
|
|
137
118
|
}, [editConfig.isKeyFocused, editConfig.isValueFocused, refInputKey, refInputValue, chipIndex, editConfig.chipIndex]);
|
|
138
|
-
|
|
119
|
+
const outsideClick = (0, _react.useCallback)(event => {
|
|
139
120
|
if (editConfig.chipIndex === chipIndex) {
|
|
140
121
|
var _event$path, _event$composedPath;
|
|
141
|
-
|
|
122
|
+
const elementPath = (_event$path = event.path) !== null && _event$path !== void 0 ? _event$path : (_event$composedPath = event.composedPath) === null || _event$composedPath === void 0 ? void 0 : _event$composedPath.call(event);
|
|
142
123
|
if (!elementPath.includes(refInputContainer.current)) {
|
|
143
124
|
onChange(event, _constants.CLICK);
|
|
144
125
|
window.getSelection().removeAllRanges();
|
|
@@ -147,15 +128,15 @@ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
147
128
|
}
|
|
148
129
|
}
|
|
149
130
|
}, [onChange, refInputContainer, chipIndex, editConfig.chipIndex]);
|
|
150
|
-
(0, _react.useEffect)(
|
|
131
|
+
(0, _react.useEffect)(() => {
|
|
151
132
|
if (editConfig.isEdit) {
|
|
152
133
|
document.addEventListener('click', outsideClick, true);
|
|
153
|
-
return
|
|
134
|
+
return () => {
|
|
154
135
|
document.removeEventListener('click', outsideClick, true);
|
|
155
136
|
};
|
|
156
137
|
}
|
|
157
138
|
}, [outsideClick, editConfig.isEdit]);
|
|
158
|
-
|
|
139
|
+
const focusChip = (0, _react.useCallback)(event => {
|
|
159
140
|
if (editConfig.chipIndex === chipIndex && isEditable) {
|
|
160
141
|
if (!event.shiftKey && event.key === _constants.TAB && editConfig.isValueFocused) {
|
|
161
142
|
return onChange(event, _constants.TAB);
|
|
@@ -165,25 +146,23 @@ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
165
146
|
}
|
|
166
147
|
event.stopPropagation();
|
|
167
148
|
}, [editConfig, onChange, chipIndex, isEditable]);
|
|
168
|
-
|
|
169
|
-
|
|
149
|
+
const handleOnFocus = (0, _react.useCallback)(event => {
|
|
150
|
+
const isKeyFocused = event.target.name === keyName;
|
|
170
151
|
if (editConfig.chipIndex === chipIndex) {
|
|
171
152
|
if (isKeyFocused) {
|
|
172
153
|
refInputKey.current.selectionStart = refInputKey.current.selectionEnd;
|
|
173
|
-
setEditConfig(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
});
|
|
154
|
+
setEditConfig(prevConfig => ({
|
|
155
|
+
...prevConfig,
|
|
156
|
+
isKeyFocused: true,
|
|
157
|
+
isValueFocused: false
|
|
158
|
+
}));
|
|
179
159
|
} else {
|
|
180
160
|
refInputValue.current.selectionStart = refInputValue.current.selectionEnd;
|
|
181
|
-
setEditConfig(
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
});
|
|
161
|
+
setEditConfig(prevConfig => ({
|
|
162
|
+
...prevConfig,
|
|
163
|
+
isKeyFocused: false,
|
|
164
|
+
isValueFocused: true
|
|
165
|
+
}));
|
|
187
166
|
}
|
|
188
167
|
event && event.stopPropagation();
|
|
189
168
|
} else if ((0, _lodash.isNil)(editConfig.chipIndex)) {
|
|
@@ -193,66 +172,69 @@ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
193
172
|
refInputValue.current.selectionStart = refInputValue.current.selectionEnd;
|
|
194
173
|
}
|
|
195
174
|
setEditConfig({
|
|
196
|
-
chipIndex
|
|
175
|
+
chipIndex,
|
|
197
176
|
isEdit: true,
|
|
198
177
|
isKeyFocused: isKeyFocused,
|
|
199
178
|
isValueFocused: !isKeyFocused
|
|
200
179
|
});
|
|
201
180
|
}
|
|
202
181
|
}, [keyName, refInputKey, refInputValue, setEditConfig, editConfig.chipIndex, chipIndex]);
|
|
203
|
-
|
|
182
|
+
const handleOnChange = (0, _react.useCallback)(event => {
|
|
204
183
|
event.preventDefault();
|
|
205
184
|
if (event.target.name === keyName) {
|
|
206
|
-
|
|
207
|
-
setChipData(
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
});
|
|
185
|
+
const currentWidthKeyInput = (0, _formChipCell.getTextWidth)(refInputKey.current);
|
|
186
|
+
setChipData(prevState => ({
|
|
187
|
+
...prevState,
|
|
188
|
+
key: refInputKey.current.value,
|
|
189
|
+
keyFieldWidth: refInputKey.current.value.length <= 1 ? minWidthInput : currentWidthKeyInput >= maxWidthInput ? maxWidthInput : currentWidthKeyInput > minWidthInput ? currentWidthKeyInput + 2 : minWidthInput
|
|
190
|
+
}));
|
|
213
191
|
} else {
|
|
214
|
-
|
|
215
|
-
setChipData(
|
|
192
|
+
const currentWidthValueInput = (0, _formChipCell.getTextWidth)(refInputValue.current);
|
|
193
|
+
setChipData(prevState => {
|
|
216
194
|
var _refInputValue$curren;
|
|
217
|
-
return
|
|
195
|
+
return {
|
|
196
|
+
...prevState,
|
|
218
197
|
value: refInputValue.current.value,
|
|
219
198
|
valueFieldWidth: ((_refInputValue$curren = refInputValue.current.value) === null || _refInputValue$curren === void 0 ? void 0 : _refInputValue$curren.length) <= 1 ? minWidthValueInput : currentWidthValueInput >= maxWidthInput ? maxWidthInput : currentWidthValueInput > minWidthValueInput ? currentWidthValueInput + 2 : minWidthValueInput
|
|
220
|
-
}
|
|
199
|
+
};
|
|
221
200
|
});
|
|
222
201
|
}
|
|
223
202
|
}, [maxWidthInput, refInputKey, refInputValue, keyName]);
|
|
224
|
-
(0, _react.useLayoutEffect)(
|
|
203
|
+
(0, _react.useLayoutEffect)(() => {
|
|
225
204
|
if (editConfig.chipIndex === chipIndex) {
|
|
226
205
|
setSelectedInput(editConfig.isKeyFocused ? 'key' : editConfig.isValueFocused ? 'value' : null);
|
|
227
206
|
}
|
|
228
207
|
}, [editConfig.isKeyFocused, editConfig.isValueFocused, editConfig.chipIndex, chipIndex]);
|
|
229
|
-
(0, _react.useEffect)(
|
|
208
|
+
(0, _react.useEffect)(() => {
|
|
230
209
|
if (meta.valid && showValidationRules) {
|
|
231
210
|
setShowValidationRules(false);
|
|
232
211
|
}
|
|
233
212
|
}, [meta.valid, showValidationRules]);
|
|
234
|
-
(0, _react.useEffect)(
|
|
213
|
+
(0, _react.useEffect)(() => {
|
|
235
214
|
if (meta.error) {
|
|
236
|
-
setValidationRules(
|
|
215
|
+
setValidationRules(prevState => {
|
|
237
216
|
var _prevState$selectedIn;
|
|
238
|
-
return
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
217
|
+
return {
|
|
218
|
+
...prevState,
|
|
219
|
+
[selectedInput]: (_prevState$selectedIn = prevState[selectedInput]) === null || _prevState$selectedIn === void 0 ? void 0 : _prevState$selectedIn.map(rule => {
|
|
220
|
+
return {
|
|
221
|
+
...rule,
|
|
222
|
+
isValid: (0, _lodash.isEmpty)((0, _lodash.get)(meta, ['error', editConfig.chipIndex, selectedInput], [])) ? true : !meta.error[editConfig.chipIndex][selectedInput].some(err => err && err.name === rule.name)
|
|
223
|
+
};
|
|
224
|
+
})
|
|
225
|
+
};
|
|
245
226
|
});
|
|
246
227
|
!showValidationRules && setShowValidationRules(true);
|
|
247
228
|
}
|
|
248
229
|
}, [meta, showValidationRules, selectedInput, editConfig.chipIndex]);
|
|
249
|
-
|
|
230
|
+
const getValidationRules = (0, _react.useCallback)(() => {
|
|
250
231
|
var _validationRules$sele;
|
|
251
|
-
return (_validationRules$sele = validationRules[selectedInput]) === null || _validationRules$sele === void 0 ? void 0 : _validationRules$sele.map(
|
|
252
|
-
|
|
253
|
-
isValid =
|
|
254
|
-
label
|
|
255
|
-
name
|
|
232
|
+
return (_validationRules$sele = validationRules[selectedInput]) === null || _validationRules$sele === void 0 ? void 0 : _validationRules$sele.map(_ref2 => {
|
|
233
|
+
let {
|
|
234
|
+
isValid = false,
|
|
235
|
+
label,
|
|
236
|
+
name
|
|
237
|
+
} = _ref2;
|
|
256
238
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ValidationTemplate.default, {
|
|
257
239
|
valid: isValid,
|
|
258
240
|
validationMessage: label
|
|
@@ -261,9 +243,7 @@ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
261
243
|
}, [selectedInput, validationRules]);
|
|
262
244
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
263
245
|
className: labelContainerClassName,
|
|
264
|
-
onKeyDown:
|
|
265
|
-
return editConfig.isEdit && focusChip(event);
|
|
266
|
-
},
|
|
246
|
+
onKeyDown: event => editConfig.isEdit && focusChip(event),
|
|
267
247
|
ref: refInputContainer,
|
|
268
248
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_NewChipInput.default, {
|
|
269
249
|
className: labelKeyClassName,
|
|
@@ -292,9 +272,7 @@ var NewChipForm = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
292
272
|
}
|
|
293
273
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
294
274
|
className: closeButtonClass,
|
|
295
|
-
onClick:
|
|
296
|
-
return handleRemoveChip(event, chipIndex);
|
|
297
|
-
},
|
|
275
|
+
onClick: event => handleRemoveChip(event, chipIndex),
|
|
298
276
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_close.ReactComponent, {})
|
|
299
277
|
}), (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, {
|
|
300
278
|
show: showValidationRules,
|
|
@@ -322,5 +300,4 @@ NewChipForm.propTypes = {
|
|
|
322
300
|
validationRules: _propTypes.default.object,
|
|
323
301
|
valueName: _propTypes.default.string.isRequired
|
|
324
302
|
};
|
|
325
|
-
var _default = NewChipForm;
|
|
326
|
-
exports.default = _default;
|
|
303
|
+
var _default = exports.default = NewChipForm;
|
|
@@ -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
|
});
|
|
@@ -9,7 +8,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
9
|
var _reactFinalForm = require("react-final-form");
|
|
11
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
-
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
12
|
/*
|
|
14
13
|
Copyright 2022 Iguazio Systems Ltd.
|
|
15
14
|
Licensed under the Apache License, Version 2.0 (the "License") with
|
|
@@ -26,43 +25,42 @@ illegal under applicable law, and the grant of the foregoing license
|
|
|
26
25
|
under the Apache 2.0 license is conditioned upon your compliance with
|
|
27
26
|
such restriction.
|
|
28
27
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
inputProps = _objectWithoutProperties(_ref, _excluded);
|
|
42
|
-
var _useField = (0, _reactFinalForm.useField)(name),
|
|
43
|
-
input = _useField.input;
|
|
44
|
-
var handleInputChange = function handleInputChange(event) {
|
|
28
|
+
|
|
29
|
+
const NewChipInput = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
30
|
+
let {
|
|
31
|
+
name,
|
|
32
|
+
onChange,
|
|
33
|
+
onFocus,
|
|
34
|
+
...inputProps
|
|
35
|
+
} = _ref;
|
|
36
|
+
const {
|
|
37
|
+
input
|
|
38
|
+
} = (0, _reactFinalForm.useField)(name);
|
|
39
|
+
const handleInputChange = event => {
|
|
45
40
|
input.onChange(event);
|
|
46
41
|
onChange(event);
|
|
47
42
|
};
|
|
48
|
-
|
|
43
|
+
const handleInputFocus = event => {
|
|
49
44
|
input.onFocus(event);
|
|
50
45
|
onFocus(event);
|
|
51
46
|
};
|
|
52
47
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, {
|
|
53
48
|
name: name,
|
|
54
|
-
children:
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
children: _ref2 => {
|
|
50
|
+
let {
|
|
51
|
+
input
|
|
52
|
+
} = _ref2;
|
|
53
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
57
54
|
autoComplete: "off",
|
|
58
55
|
"data-testid": "input",
|
|
59
56
|
ref: ref,
|
|
60
57
|
type: "text",
|
|
61
|
-
id: input.name
|
|
62
|
-
|
|
58
|
+
id: input.name,
|
|
59
|
+
...inputProps,
|
|
60
|
+
...input,
|
|
63
61
|
onChange: handleInputChange,
|
|
64
62
|
onFocus: handleInputFocus
|
|
65
|
-
})
|
|
63
|
+
});
|
|
66
64
|
}
|
|
67
65
|
});
|
|
68
66
|
});
|
|
@@ -71,5 +69,4 @@ NewChipInput.propTypes = {
|
|
|
71
69
|
onChange: _propTypes.default.func.isRequired,
|
|
72
70
|
onFocus: _propTypes.default.func.isRequired
|
|
73
71
|
};
|
|
74
|
-
var _default = NewChipInput;
|
|
75
|
-
exports.default = _default;
|
|
72
|
+
var _default = exports.default = NewChipInput;
|
|
@@ -4,12 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
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; }
|
|
13
7
|
/*
|
|
14
8
|
Copyright 2022 Iguazio Systems Ltd.
|
|
15
9
|
Licensed under the Apache License, Version 2.0 (the "License") with
|
|
@@ -26,30 +20,26 @@ illegal under applicable law, and the grant of the foregoing license
|
|
|
26
20
|
under the Apache 2.0 license is conditioned upon your compliance with
|
|
27
21
|
such restriction.
|
|
28
22
|
*/
|
|
29
|
-
|
|
23
|
+
const uniquenessError = exports.uniquenessError = {
|
|
30
24
|
name: 'uniqueness',
|
|
31
25
|
label: 'Key must be unique'
|
|
32
26
|
};
|
|
33
|
-
|
|
34
|
-
var getTextWidth = function getTextWidth(elementWithText) {
|
|
27
|
+
const getTextWidth = elementWithText => {
|
|
35
28
|
var _hiddenElement$offset;
|
|
36
29
|
if (!elementWithText) {
|
|
37
30
|
return 0;
|
|
38
31
|
}
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
const hiddenElementId = 'chips-hidden-element';
|
|
33
|
+
let hiddenElement = document.getElementById(hiddenElementId);
|
|
41
34
|
if (!hiddenElement) {
|
|
42
35
|
hiddenElement = document.createElement('span');
|
|
43
|
-
|
|
36
|
+
const styles = {
|
|
44
37
|
position: 'absolute',
|
|
45
38
|
left: '-10000px',
|
|
46
39
|
top: "auto",
|
|
47
40
|
visibility: 'hidden'
|
|
48
41
|
};
|
|
49
|
-
for (
|
|
50
|
-
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
51
|
-
styleName = _Object$entries$_i[0],
|
|
52
|
-
styleValue = _Object$entries$_i[1];
|
|
42
|
+
for (const [styleName, styleValue] of Object.entries(styles)) {
|
|
53
43
|
hiddenElement.style[styleName] = styleValue;
|
|
54
44
|
}
|
|
55
45
|
hiddenElement.style.font = window.getComputedStyle(elementWithText).font;
|