iguazio.dashboard-react-controls 1.9.3 → 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/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
|
});
|
|
@@ -20,78 +19,69 @@ var _hooks = require("../../hooks");
|
|
|
20
19
|
require("./formChipCell.scss");
|
|
21
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
function _getRequireWildcardCache(
|
|
24
|
-
function _interopRequireWildcard(
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
isEdit: false,
|
|
81
|
-
isKeyFocused: false,
|
|
82
|
-
isValueFocused: false,
|
|
83
|
-
isNewChip: false
|
|
84
|
-
}),
|
|
85
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
86
|
-
editConfig = _useState2[0],
|
|
87
|
-
setEditConfig = _useState2[1];
|
|
88
|
-
var chips = (0, _react.useMemo)(function () {
|
|
22
|
+
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); }
|
|
23
|
+
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; }
|
|
24
|
+
/*
|
|
25
|
+
Copyright 2022 Iguazio Systems Ltd.
|
|
26
|
+
Licensed under the Apache License, Version 2.0 (the "License") with
|
|
27
|
+
an addition restriction as set forth herein. You may not use this
|
|
28
|
+
file except in compliance with the License. You may obtain a copy of
|
|
29
|
+
the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
30
|
+
Unless required by applicable law or agreed to in writing, software
|
|
31
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
32
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
33
|
+
implied. See the License for the specific language governing
|
|
34
|
+
permissions and limitations under the License.
|
|
35
|
+
In addition, you may not use the software for any purposes that are
|
|
36
|
+
illegal under applicable law, and the grant of the foregoing license
|
|
37
|
+
under the Apache 2.0 license is conditioned upon your compliance with
|
|
38
|
+
such restriction.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
const FormChipCell = _ref => {
|
|
42
|
+
let {
|
|
43
|
+
chipOptions,
|
|
44
|
+
className,
|
|
45
|
+
delimiter,
|
|
46
|
+
formState,
|
|
47
|
+
initialValues,
|
|
48
|
+
isEditable,
|
|
49
|
+
label,
|
|
50
|
+
name,
|
|
51
|
+
onClick,
|
|
52
|
+
shortChips,
|
|
53
|
+
validationRules,
|
|
54
|
+
validator,
|
|
55
|
+
onExitEditModeCallback,
|
|
56
|
+
visibleChipsMaxLength
|
|
57
|
+
} = _ref;
|
|
58
|
+
const chipsClassName = (0, _classnames.default)('chips', className);
|
|
59
|
+
const {
|
|
60
|
+
chipsCellRef,
|
|
61
|
+
chipsWrapperRef,
|
|
62
|
+
handleShowElements,
|
|
63
|
+
hiddenChipsCounterRef,
|
|
64
|
+
hiddenChipsPopUpRef,
|
|
65
|
+
setChipsSizes,
|
|
66
|
+
setShowHiddenChips,
|
|
67
|
+
showChips,
|
|
68
|
+
showHiddenChips,
|
|
69
|
+
visibleChipsCount
|
|
70
|
+
} = (0, _hooks.useChipCell)(isEditable, visibleChipsMaxLength);
|
|
71
|
+
const [editConfig, setEditConfig] = (0, _react.useState)({
|
|
72
|
+
chipIndex: null,
|
|
73
|
+
isEdit: false,
|
|
74
|
+
isKeyFocused: false,
|
|
75
|
+
isValueFocused: false,
|
|
76
|
+
isNewChip: false
|
|
77
|
+
});
|
|
78
|
+
let chips = (0, _react.useMemo)(() => {
|
|
89
79
|
return isEditable || visibleChipsMaxLength === 'all' ? {
|
|
90
80
|
visibleChips: (0, _lodash.get)(formState.values, name),
|
|
91
81
|
hiddenChips: []
|
|
92
82
|
} : (0, _generateChipsList.generateChipsList)((0, _lodash.get)(formState.values, name), visibleChipsMaxLength ? visibleChipsMaxLength : visibleChipsCount);
|
|
93
83
|
}, [visibleChipsMaxLength, isEditable, visibleChipsCount, formState.values, name]);
|
|
94
|
-
|
|
84
|
+
const checkChipsList = (0, _react.useCallback)(currentChipsList => {
|
|
95
85
|
if ((0, _common.areArraysEqual)((0, _lodash.get)(initialValues, name), currentChipsList, ['id'])) {
|
|
96
86
|
(0, _lodash.set)(formState.initialValues, name, currentChipsList);
|
|
97
87
|
}
|
|
@@ -102,9 +92,9 @@ var FormChipCell = function FormChipCell(_ref) {
|
|
|
102
92
|
touched: true
|
|
103
93
|
});
|
|
104
94
|
}, [initialValues, name, formState]);
|
|
105
|
-
|
|
95
|
+
const handleAddNewChip = (0, _react.useCallback)((event, fields) => {
|
|
106
96
|
var _fields$value;
|
|
107
|
-
|
|
97
|
+
const fieldsLength = ((_fields$value = fields.value) === null || _fields$value === void 0 ? void 0 : _fields$value.length) || 0;
|
|
108
98
|
if (!editConfig.isEdit && !editConfig.chipIndex) {
|
|
109
99
|
formState.form.mutators.push(name, {
|
|
110
100
|
id: fieldsLength + new Date(),
|
|
@@ -125,19 +115,18 @@ var FormChipCell = function FormChipCell(_ref) {
|
|
|
125
115
|
});
|
|
126
116
|
event && event.preventDefault();
|
|
127
117
|
}, [editConfig.isEdit, editConfig.chipIndex, showHiddenChips, formState.form.mutators, name, delimiter, setShowHiddenChips]);
|
|
128
|
-
|
|
129
|
-
checkChipsList(_lodash.default.chain(formState).get(['values', name]).filter(
|
|
130
|
-
return index !== chipIndex;
|
|
131
|
-
}).value());
|
|
118
|
+
const handleRemoveChip = (0, _react.useCallback)((event, fields, chipIndex) => {
|
|
119
|
+
checkChipsList(_lodash.default.chain(formState).get(['values', name]).filter((_, index) => index !== chipIndex).value());
|
|
132
120
|
fields.remove(chipIndex);
|
|
133
121
|
onExitEditModeCallback && onExitEditModeCallback();
|
|
134
122
|
event && event.stopPropagation();
|
|
135
123
|
}, [checkChipsList, formState, name, onExitEditModeCallback]);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
key
|
|
139
|
-
value
|
|
140
|
-
|
|
124
|
+
const handleEditChip = (0, _react.useCallback)((event, fields, nameEvent) => {
|
|
125
|
+
const {
|
|
126
|
+
key,
|
|
127
|
+
value
|
|
128
|
+
} = fields.value[editConfig.chipIndex];
|
|
129
|
+
const isChipNotEmpty = !!(key !== null && key !== void 0 && key.trim() && value !== null && value !== void 0 && value.trim());
|
|
141
130
|
if (nameEvent === _constants.CLICK) {
|
|
142
131
|
if (!isChipNotEmpty) {
|
|
143
132
|
handleRemoveChip(event, fields, editConfig.chipIndex);
|
|
@@ -154,8 +143,8 @@ var FormChipCell = function FormChipCell(_ref) {
|
|
|
154
143
|
if (!isChipNotEmpty) {
|
|
155
144
|
handleRemoveChip(event, fields, editConfig.chipIndex);
|
|
156
145
|
}
|
|
157
|
-
setEditConfig(
|
|
158
|
-
|
|
146
|
+
setEditConfig(prevState => {
|
|
147
|
+
const lastChipSelected = prevState.chipIndex + 1 > fields.value.length - 1;
|
|
159
148
|
isChipNotEmpty && lastChipSelected && onExitEditModeCallback && onExitEditModeCallback();
|
|
160
149
|
return {
|
|
161
150
|
chipIndex: lastChipSelected ? null : prevState.chipIndex + 1,
|
|
@@ -169,8 +158,8 @@ var FormChipCell = function FormChipCell(_ref) {
|
|
|
169
158
|
if (!isChipNotEmpty) {
|
|
170
159
|
handleRemoveChip(event, fields, editConfig.chipIndex);
|
|
171
160
|
}
|
|
172
|
-
setEditConfig(
|
|
173
|
-
|
|
161
|
+
setEditConfig(prevState => {
|
|
162
|
+
const firstChipIsSelected = prevState.chipIndex === 0;
|
|
174
163
|
isChipNotEmpty && firstChipIsSelected && onExitEditModeCallback && onExitEditModeCallback();
|
|
175
164
|
return {
|
|
176
165
|
chipIndex: firstChipIsSelected ? null : prevState.chipIndex - 1,
|
|
@@ -186,18 +175,21 @@ var FormChipCell = function FormChipCell(_ref) {
|
|
|
186
175
|
event && event.preventDefault();
|
|
187
176
|
}
|
|
188
177
|
}, [editConfig.chipIndex, checkChipsList, formState.values, name, onExitEditModeCallback, handleRemoveChip]);
|
|
189
|
-
|
|
178
|
+
const handleToEditMode = (0, _react.useCallback)((event, chipIndex, keyName) => {
|
|
190
179
|
if (isEditable) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
180
|
+
const {
|
|
181
|
+
clientX: pointerCoordinateX,
|
|
182
|
+
clientY: pointerCoordinateY
|
|
183
|
+
} = event;
|
|
184
|
+
let isKeyClicked = false;
|
|
185
|
+
const isClickedInsideInputElement = (pointerCoordinateX, pointerCoordinateY, inputElement) => {
|
|
195
186
|
if (inputElement) {
|
|
196
|
-
|
|
197
|
-
topPosition
|
|
198
|
-
leftPosition
|
|
199
|
-
rightPosition
|
|
200
|
-
bottomPosition
|
|
187
|
+
const {
|
|
188
|
+
top: topPosition,
|
|
189
|
+
left: leftPosition,
|
|
190
|
+
right: rightPosition,
|
|
191
|
+
bottom: bottomPosition
|
|
192
|
+
} = inputElement.getBoundingClientRect();
|
|
201
193
|
if (pointerCoordinateX > rightPosition || pointerCoordinateX < leftPosition) return false;
|
|
202
194
|
if (pointerCoordinateY > bottomPosition || pointerCoordinateY < topPosition) return false;
|
|
203
195
|
return true;
|
|
@@ -211,32 +203,30 @@ var FormChipCell = function FormChipCell(_ref) {
|
|
|
211
203
|
} else {
|
|
212
204
|
isKeyClicked = event.target.name === keyName;
|
|
213
205
|
}
|
|
214
|
-
setEditConfig(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
});
|
|
206
|
+
setEditConfig(preState => ({
|
|
207
|
+
...preState,
|
|
208
|
+
chipIndex,
|
|
209
|
+
isEdit: true,
|
|
210
|
+
isKeyFocused: isKeyClicked,
|
|
211
|
+
isValueFocused: !isKeyClicked
|
|
212
|
+
}));
|
|
222
213
|
}
|
|
223
214
|
onClick && onClick();
|
|
224
215
|
}, [isEditable, onClick]);
|
|
225
|
-
|
|
216
|
+
const validateFields = fieldsArray => {
|
|
226
217
|
if (!fieldsArray) return null;
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
return !fieldsArray.some(
|
|
230
|
-
|
|
218
|
+
let errorData = [];
|
|
219
|
+
const uniquenessValidator = (newValue, idx) => {
|
|
220
|
+
return !fieldsArray.some((_ref2, index) => {
|
|
221
|
+
let {
|
|
222
|
+
key
|
|
223
|
+
} = _ref2;
|
|
231
224
|
return newValue === key && index !== idx;
|
|
232
225
|
});
|
|
233
226
|
};
|
|
234
227
|
if (!(0, _lodash.isEmpty)(validationRules)) {
|
|
235
|
-
errorData = fieldsArray.map(
|
|
236
|
-
|
|
237
|
-
_validateChip2 = _slicedToArray(_validateChip, 2),
|
|
238
|
-
keyValidation = _validateChip2[0],
|
|
239
|
-
valueValidation = _validateChip2[1];
|
|
228
|
+
errorData = fieldsArray.map(chip => {
|
|
229
|
+
const [keyValidation, valueValidation] = validateChip(chip);
|
|
240
230
|
if (keyValidation && valueValidation) return {
|
|
241
231
|
key: keyValidation,
|
|
242
232
|
value: valueValidation
|
|
@@ -252,8 +242,8 @@ var FormChipCell = function FormChipCell(_ref) {
|
|
|
252
242
|
}
|
|
253
243
|
|
|
254
244
|
// uniqueness
|
|
255
|
-
fieldsArray.forEach(
|
|
256
|
-
|
|
245
|
+
fieldsArray.forEach((chip, index) => {
|
|
246
|
+
const isUnique = uniquenessValidator(chip.key, index);
|
|
257
247
|
if (!isUnique) {
|
|
258
248
|
if ((0, _lodash.get)(errorData, [index, 'key'], false)) {
|
|
259
249
|
errorData.at(index).key.push(_formChipCell.uniquenessError);
|
|
@@ -265,33 +255,24 @@ var FormChipCell = function FormChipCell(_ref) {
|
|
|
265
255
|
if ((0, _lodash.isEmpty)(errorData) && validator) {
|
|
266
256
|
errorData = validator(fieldsArray);
|
|
267
257
|
}
|
|
268
|
-
if (errorData.every(
|
|
269
|
-
return (0, _lodash.isNil)(label);
|
|
270
|
-
})) {
|
|
258
|
+
if (errorData.every(label => (0, _lodash.isNil)(label))) {
|
|
271
259
|
return null;
|
|
272
260
|
}
|
|
273
261
|
return errorData;
|
|
274
262
|
};
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
_checkPatternsValidit2 = _slicedToArray(_checkPatternsValidit, 2),
|
|
283
|
-
newRules = _checkPatternsValidit2[0],
|
|
284
|
-
isValidField = _checkPatternsValidit2[1];
|
|
263
|
+
const validateChip = _ref3 => {
|
|
264
|
+
let {
|
|
265
|
+
key,
|
|
266
|
+
value
|
|
267
|
+
} = _ref3;
|
|
268
|
+
const validateField = (value, field) => {
|
|
269
|
+
const [newRules, isValidField] = (0, _validation.checkPatternsValidity)(validationRules[field].filter(rule => rule.pattern), value);
|
|
285
270
|
if (isValidField) return null;
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
name: rule.name,
|
|
292
|
-
label: rule.label
|
|
293
|
-
};
|
|
294
|
-
});
|
|
271
|
+
const invalidRules = newRules.filter(rule => !rule.isValid);
|
|
272
|
+
return invalidRules.map(rule => ({
|
|
273
|
+
name: rule.name,
|
|
274
|
+
label: rule.label
|
|
275
|
+
}));
|
|
295
276
|
};
|
|
296
277
|
return [validateField(key, 'key'), validateField(value, 'value')];
|
|
297
278
|
};
|
|
@@ -316,10 +297,10 @@ var FormChipCell = function FormChipCell(_ref) {
|
|
|
316
297
|
isEditable: isEditable,
|
|
317
298
|
name: name,
|
|
318
299
|
ref: {
|
|
319
|
-
chipsCellRef
|
|
320
|
-
chipsWrapperRef
|
|
321
|
-
hiddenChipsCounterRef
|
|
322
|
-
hiddenChipsPopUpRef
|
|
300
|
+
chipsCellRef,
|
|
301
|
+
chipsWrapperRef,
|
|
302
|
+
hiddenChipsCounterRef,
|
|
303
|
+
hiddenChipsPopUpRef
|
|
323
304
|
},
|
|
324
305
|
setChipsSizes: setChipsSizes,
|
|
325
306
|
setEditConfig: setEditConfig,
|
|
@@ -345,7 +326,7 @@ FormChipCell.defaultProps = {
|
|
|
345
326
|
delimiter: null,
|
|
346
327
|
isEditable: false,
|
|
347
328
|
label: null,
|
|
348
|
-
onClick:
|
|
329
|
+
onClick: () => {},
|
|
349
330
|
shortChips: false,
|
|
350
331
|
validationRules: {},
|
|
351
332
|
validator: null,
|
|
@@ -366,5 +347,4 @@ FormChipCell.propTypes = {
|
|
|
366
347
|
validator: _propTypes.default.func,
|
|
367
348
|
visibleChipsMaxLength: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number])
|
|
368
349
|
};
|
|
369
|
-
var _default = /*#__PURE__*/_react.default.memo(FormChipCell);
|
|
370
|
-
exports.default = _default;
|
|
350
|
+
var _default = exports.default = /*#__PURE__*/_react.default.memo(FormChipCell);
|
|
@@ -36,42 +36,46 @@ under the Apache 2.0 license is conditioned upon your compliance with
|
|
|
36
36
|
such restriction.
|
|
37
37
|
*/
|
|
38
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
|
-
|
|
39
|
+
const FormChipCellView = /*#__PURE__*/_react.default.forwardRef((_ref, _ref2) => {
|
|
40
|
+
let {
|
|
41
|
+
chipOptions,
|
|
42
|
+
chips,
|
|
43
|
+
editConfig,
|
|
44
|
+
formState,
|
|
45
|
+
handleAddNewChip,
|
|
46
|
+
handleEditChip,
|
|
47
|
+
handleRemoveChip,
|
|
48
|
+
handleShowElements,
|
|
49
|
+
handleToEditMode,
|
|
50
|
+
isEditable,
|
|
51
|
+
name,
|
|
52
|
+
setChipsSizes,
|
|
53
|
+
setEditConfig,
|
|
54
|
+
shortChips,
|
|
55
|
+
showChips,
|
|
56
|
+
showHiddenChips,
|
|
57
|
+
validateFields,
|
|
58
|
+
validationRules
|
|
59
|
+
} = _ref;
|
|
60
|
+
let {
|
|
61
|
+
chipsCellRef,
|
|
62
|
+
chipsWrapperRef,
|
|
63
|
+
hiddenChipsCounterRef,
|
|
64
|
+
hiddenChipsPopUpRef
|
|
65
|
+
} = _ref2;
|
|
66
|
+
const buttonAddClassNames = (0, _classnames.default)('button-add', chipOptions.background && "button-add-background_".concat(chipOptions.background), chipOptions.borderColor && "button-add-border_".concat(chipOptions.borderColor), chipOptions.font && "button-add-font_".concat(chipOptions.font), chipOptions.density && "button-add-density_".concat(chipOptions.density));
|
|
67
|
+
const wrapperClassNames = (0, _classnames.default)('chips-wrapper', isEditable && 'fixed-max-width');
|
|
68
|
+
const chipClassNames = (0, _classnames.default)('chip', 'chip__content', isEditable && 'data-ellipsis', shortChips && 'chip_short', chips.hiddenChips && 'chip_hidden', chipOptions.density && "chip-density_".concat(chipOptions.density), chipOptions.borderRadius && "chip-border_".concat(chipOptions.borderRadius), chipOptions.background && "chip-background_".concat(chipOptions.background), chipOptions.borderColor && "chip-border_".concat(chipOptions.borderColor), chipOptions.font && "chip-font_".concat(chipOptions.font), isEditable && 'editable', (showChips || isEditable) && 'chip_visible');
|
|
65
69
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalFormArrays.FieldArray, {
|
|
66
70
|
name: name,
|
|
67
71
|
initialValue: formState.initialValues[name],
|
|
68
72
|
validate: validateFields,
|
|
69
|
-
children:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
children: _ref3 => {
|
|
74
|
+
let {
|
|
75
|
+
fields,
|
|
76
|
+
meta
|
|
77
|
+
} = _ref3;
|
|
78
|
+
if (!(0, _lodash.isEmpty)(validationRules) && validationRules.key.every(rule => rule.name !== _formChipCell.uniquenessError.name)) {
|
|
75
79
|
validationRules.key.push(_formChipCell.uniquenessError);
|
|
76
80
|
}
|
|
77
81
|
return (isEditable || !(0, _common.isEveryObjectValueEmpty)(fields)) && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -80,9 +84,9 @@ var FormChipCellView = /*#__PURE__*/_react.default.forwardRef(function (_ref, _r
|
|
|
80
84
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
81
85
|
className: wrapperClassNames,
|
|
82
86
|
ref: chipsWrapperRef,
|
|
83
|
-
children: [fields.map(
|
|
87
|
+
children: [fields.map((contentItem, index) => {
|
|
84
88
|
var _chips$visibleChips;
|
|
85
|
-
|
|
89
|
+
const chipData = fields.value[index];
|
|
86
90
|
return index < ((_chips$visibleChips = chips.visibleChips) === null || _chips$visibleChips === void 0 ? void 0 : _chips$visibleChips.length) && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
87
91
|
className: "chip-block",
|
|
88
92
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
|
|
@@ -103,12 +107,8 @@ var FormChipCellView = /*#__PURE__*/_react.default.forwardRef(function (_ref, _r
|
|
|
103
107
|
chipIndex: index,
|
|
104
108
|
chipOptions: chipOptions,
|
|
105
109
|
editConfig: editConfig,
|
|
106
|
-
handleEditChip:
|
|
107
|
-
|
|
108
|
-
},
|
|
109
|
-
handleRemoveChip: function handleRemoveChip(event, index) {
|
|
110
|
-
return _handleRemoveChip(event, fields, index);
|
|
111
|
-
},
|
|
110
|
+
handleEditChip: (event, nameEvent) => handleEditChip(event, fields, nameEvent),
|
|
111
|
+
handleRemoveChip: (event, index) => handleRemoveChip(event, fields, index),
|
|
112
112
|
handleToEditMode: handleToEditMode,
|
|
113
113
|
isEditable: isEditable,
|
|
114
114
|
keyName: "".concat(contentItem, ".key"),
|
|
@@ -129,8 +129,8 @@ var FormChipCellView = /*#__PURE__*/_react.default.forwardRef(function (_ref, _r
|
|
|
129
129
|
chips: chips.hiddenChips,
|
|
130
130
|
handleShowElements: handleShowElements,
|
|
131
131
|
ref: {
|
|
132
|
-
hiddenChipsCounterRef
|
|
133
|
-
hiddenChipsPopUpRef
|
|
132
|
+
hiddenChipsCounterRef,
|
|
133
|
+
hiddenChipsPopUpRef
|
|
134
134
|
},
|
|
135
135
|
textOverflowEllipsis: true
|
|
136
136
|
}), chips.hiddenChipsNumber && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
@@ -142,9 +142,7 @@ var FormChipCellView = /*#__PURE__*/_react.default.forwardRef(function (_ref, _r
|
|
|
142
142
|
}), isEditable && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
143
143
|
"data-testid": "".concat(name, "-add-chip"),
|
|
144
144
|
className: buttonAddClassNames,
|
|
145
|
-
onClick:
|
|
146
|
-
return handleAddNewChip(e, fields);
|
|
147
|
-
},
|
|
145
|
+
onClick: e => handleAddNewChip(e, fields),
|
|
148
146
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_add.ReactComponent, {})
|
|
149
147
|
})]
|
|
150
148
|
})
|
|
@@ -185,5 +183,4 @@ FormChipCellView.propTypes = {
|
|
|
185
183
|
validateFields: _propTypes.default.func.isRequired,
|
|
186
184
|
validationRules: _propTypes.default.object
|
|
187
185
|
};
|
|
188
|
-
var _default = FormChipCellView;
|
|
189
|
-
exports.default = _default;
|
|
186
|
+
var _default = exports.default = FormChipCellView;
|
|
@@ -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
|
});
|
|
@@ -15,8 +14,8 @@ var _types = require("../../../types");
|
|
|
15
14
|
var _hooks = require("../../../hooks");
|
|
16
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
function _getRequireWildcardCache(
|
|
19
|
-
function _interopRequireWildcard(
|
|
17
|
+
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); }
|
|
18
|
+
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; }
|
|
20
19
|
/*
|
|
21
20
|
Copyright 2022 Iguazio Systems Ltd.
|
|
22
21
|
Licensed under the Apache License, Version 2.0 (the "License") with
|
|
@@ -34,22 +33,27 @@ under the Apache 2.0 license is conditioned upon your compliance with
|
|
|
34
33
|
such restriction.
|
|
35
34
|
*/
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
const HiddenChipsBlock = /*#__PURE__*/_react.default.forwardRef((_ref, _ref2) => {
|
|
37
|
+
let {
|
|
38
|
+
chipClassNames,
|
|
39
|
+
chipOptions,
|
|
40
|
+
chips,
|
|
41
|
+
handleShowElements,
|
|
42
|
+
textOverflowEllipsis
|
|
43
|
+
} = _ref;
|
|
44
|
+
let {
|
|
45
|
+
hiddenChipsCounterRef,
|
|
46
|
+
hiddenChipsPopUpRef
|
|
47
|
+
} = _ref2;
|
|
48
|
+
const {
|
|
49
|
+
hiddenChipsBlockClassNames
|
|
50
|
+
} = (0, _hooks.useHiddenChipsBlock)(hiddenChipsCounterRef, hiddenChipsPopUpRef);
|
|
51
|
+
const chipLabelClassNames = (0, _classnames.default)('chip__label', textOverflowEllipsis && 'data-ellipsis');
|
|
52
|
+
const chipValueClassNames = (0, _classnames.default)('chip__value', textOverflowEllipsis && 'data-ellipsis', chipOptions.boldValue && 'chip-value_bold');
|
|
53
|
+
const generateChipData = chip => {
|
|
50
54
|
return chip.isKeyOnly ? chip.key : "".concat(chip.key).concat(chip.delimiter ? chip.delimiter : ':', " ").concat(chip.value);
|
|
51
55
|
};
|
|
52
|
-
(0, _react.useEffect)(
|
|
56
|
+
(0, _react.useEffect)(() => {
|
|
53
57
|
if (chips.length === 0) {
|
|
54
58
|
handleShowElements();
|
|
55
59
|
}
|
|
@@ -59,7 +63,7 @@ var HiddenChipsBlock = /*#__PURE__*/_react.default.forwardRef(function (_ref, _r
|
|
|
59
63
|
className: hiddenChipsBlockClassNames,
|
|
60
64
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
61
65
|
className: "chip-block-hidden__scrollable-container",
|
|
62
|
-
children: chips === null || chips === void 0 ? void 0 : chips.map(
|
|
66
|
+
children: chips === null || chips === void 0 ? void 0 : chips.map(element => {
|
|
63
67
|
var _element$delimiter;
|
|
64
68
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
|
|
65
69
|
template: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextTooltipTemplate.default, {
|
|
@@ -103,5 +107,4 @@ HiddenChipsBlock.propTypes = {
|
|
|
103
107
|
handleShowElements: _propTypes.default.func.isRequired,
|
|
104
108
|
textOverflowEllipsis: _propTypes.default.bool
|
|
105
109
|
};
|
|
106
|
-
var _default = HiddenChipsBlock;
|
|
107
|
-
exports.default = _default;
|
|
110
|
+
var _default = exports.default = HiddenChipsBlock;
|