iguazio.dashboard-react-controls 2.0.10 → 2.0.12
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/FormChipCellView.js +2 -2
- package/dist/components/FormChipCell/NewChipForm/NewChipForm.js +9 -8
- package/dist/components/FormChipCell/NewChipForm/newChipForm.scss +6 -2
- package/dist/scss/colors.scss +1 -0
- package/dist/scss/mixins.scss +4 -0
- package/dist/utils/validation.util.js +22 -6
- package/package.json +1 -1
|
@@ -90,9 +90,9 @@ const FormChipCellView = /*#__PURE__*/_react.default.forwardRef((_ref, _ref2) =>
|
|
|
90
90
|
return index < ((_chips$visibleChips = chips.visibleChips) === null || _chips$visibleChips === void 0 ? void 0 : _chips$visibleChips.length) && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
91
91
|
className: "chip-block",
|
|
92
92
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
|
|
93
|
-
hidden: editConfig.isEdit,
|
|
93
|
+
hidden: editConfig.isEdit && !chipData.tooltip,
|
|
94
94
|
template: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextTooltipTemplate.default, {
|
|
95
|
-
text: /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
95
|
+
text: chipData.tooltip || /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
96
96
|
className: "chip__content",
|
|
97
97
|
children: [chipData.key, !chipData.isKeyOnly && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
98
98
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
@@ -79,10 +79,10 @@ const NewChipForm = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
79
79
|
const refInputKey = _react.default.useRef({});
|
|
80
80
|
const refInputValue = _react.default.useRef({});
|
|
81
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');
|
|
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) && !chip.disabled && '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', chip.disabled && 'edit-chip-container_disabled edit-chip-container-font_disabled');
|
|
84
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');
|
|
85
|
+
const closeButtonClass = (0, _classnames.default)('item-icon-close', !chip.disabled && (editConfig.chipIndex === chipIndex || !isEditable) && 'item-icon-close_hidden');
|
|
86
86
|
(0, _react.useLayoutEffect)(() => {
|
|
87
87
|
if (!chipData.keyFieldWidth && !chipData.valueFieldWidth) {
|
|
88
88
|
const currentWidthKeyInput = refInputKey.current.scrollWidth + 1;
|
|
@@ -243,11 +243,11 @@ const NewChipForm = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
243
243
|
}, [selectedInput, validationRules]);
|
|
244
244
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
245
245
|
className: labelContainerClassName,
|
|
246
|
-
onKeyDown: event => editConfig.isEdit && focusChip(event),
|
|
246
|
+
onKeyDown: event => !chip.disabled && editConfig.isEdit && focusChip(event),
|
|
247
247
|
ref: refInputContainer,
|
|
248
248
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_NewChipInput.default, {
|
|
249
249
|
className: labelKeyClassName,
|
|
250
|
-
disabled: !isEditable || !(0, _lodash.isNil)(editConfig.chipIndex) && editConfig.chipIndex !== chipIndex,
|
|
250
|
+
disabled: chip.disabled || !isEditable || !(0, _lodash.isNil)(editConfig.chipIndex) && editConfig.chipIndex !== chipIndex,
|
|
251
251
|
name: keyName,
|
|
252
252
|
onChange: handleOnChange,
|
|
253
253
|
onFocus: handleOnFocus,
|
|
@@ -261,7 +261,7 @@ const NewChipForm = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
261
261
|
children: ":"
|
|
262
262
|
}), !chipData.isKeyOnly && /*#__PURE__*/(0, _jsxRuntime.jsx)(_NewChipInput.default, {
|
|
263
263
|
className: labelValueClassName,
|
|
264
|
-
disabled: !isEditable || !(0, _lodash.isNil)(editConfig.chipIndex) && editConfig.chipIndex !== chipIndex,
|
|
264
|
+
disabled: chip.disabled || !isEditable || !(0, _lodash.isNil)(editConfig.chipIndex) && editConfig.chipIndex !== chipIndex,
|
|
265
265
|
name: valueName,
|
|
266
266
|
onChange: handleOnChange,
|
|
267
267
|
onFocus: handleOnFocus,
|
|
@@ -271,10 +271,11 @@ const NewChipForm = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
271
271
|
width: chipData.valueFieldWidth
|
|
272
272
|
}
|
|
273
273
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
274
|
+
disabled: chip.disabled,
|
|
274
275
|
className: closeButtonClass,
|
|
275
|
-
onClick: event => handleRemoveChip(event, chipIndex),
|
|
276
|
+
onClick: event => !chip.disabled && handleRemoveChip(event, chipIndex),
|
|
276
277
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_close.ReactComponent, {})
|
|
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, {
|
|
278
|
+
}), !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, {
|
|
278
279
|
show: showValidationRules,
|
|
279
280
|
ref: refInputContainer,
|
|
280
281
|
children: getValidationRules()
|
|
@@ -56,15 +56,19 @@
|
|
|
56
56
|
display: flex;
|
|
57
57
|
align-items: center;
|
|
58
58
|
justify-content: center;
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
&_hidden {
|
|
61
61
|
visibility: hidden;
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
svg {
|
|
65
65
|
transform: scale(0.7);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
+
|
|
69
|
+
&_disabled {
|
|
70
|
+
cursor: not-allowed;
|
|
71
|
+
}
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
&-separator {
|
package/dist/scss/colors.scss
CHANGED
package/dist/scss/mixins.scss
CHANGED
|
@@ -224,6 +224,15 @@ const generateRule = {
|
|
|
224
224
|
label: _constants.validation.REQUIRED.LABEL,
|
|
225
225
|
pattern: new RegExp('\\S')
|
|
226
226
|
};
|
|
227
|
+
},
|
|
228
|
+
checkForValidCustomLabels: internalLabels => {
|
|
229
|
+
return {
|
|
230
|
+
name: 'customLabels',
|
|
231
|
+
label: 'System-defined labels cannot be modified.',
|
|
232
|
+
pattern: value => {
|
|
233
|
+
return !internalLabels.includes(value);
|
|
234
|
+
}
|
|
235
|
+
};
|
|
227
236
|
}
|
|
228
237
|
};
|
|
229
238
|
const commonRules = {
|
|
@@ -316,14 +325,15 @@ const validationRules = {
|
|
|
316
325
|
tag: [generateRule.validCharacters('a-z A-Z 0-9 - _ .'), generateRule.beginEndWith('a-z A-Z 0-9'), generateRule.length({
|
|
317
326
|
max: 56
|
|
318
327
|
})],
|
|
319
|
-
combobox: [generateRule.required()]
|
|
328
|
+
combobox: [generateRule.required()],
|
|
329
|
+
labels: [internalLabels => generateRule.checkForValidCustomLabels(internalLabels)]
|
|
320
330
|
},
|
|
321
331
|
project: {
|
|
322
332
|
name: [generateRule.validCharacters('a-z 0-9 -'), generateRule.beginWith('a-z'), generateRule.endWith('a-z 0-9'), generateRule.length({
|
|
323
333
|
max: 63
|
|
324
334
|
}), generateRule.required()],
|
|
325
335
|
labels: {
|
|
326
|
-
key: commonRules.k8sLabels.key,
|
|
336
|
+
key: [...commonRules.k8sLabels.key, internalLabels => generateRule.checkForValidCustomLabels(internalLabels)],
|
|
327
337
|
value: commonRules.k8sLabels.value
|
|
328
338
|
},
|
|
329
339
|
params: {
|
|
@@ -350,7 +360,7 @@ const validationRules = {
|
|
|
350
360
|
label: {
|
|
351
361
|
key: [generateRule.validCharactersWithPrefix('a-z A-Z 0-9 - _ .'), generateRule.beginEndWith('a-z A-Z 0-9'), generateRule.length({
|
|
352
362
|
max: 75
|
|
353
|
-
})],
|
|
363
|
+
}), internalLabels => generateRule.checkForValidCustomLabels(internalLabels)],
|
|
354
364
|
value: generateRule.length({
|
|
355
365
|
max: 255
|
|
356
366
|
})
|
|
@@ -363,9 +373,15 @@ const validationRules = {
|
|
|
363
373
|
* @function getValidationRules
|
|
364
374
|
* @param {string} type - The property path to the list of validation rules.
|
|
365
375
|
* @param {Array.<Object>} [additionalRules] - Additional rules to append.
|
|
366
|
-
* @
|
|
376
|
+
* @param {Array.<Object>} [customData] - Additional data to be passed to the custom rule functions.
|
|
377
|
+
* @returns {Array.<Object>} The rule list of type `type` with `additionalRules` appended to it if provided.
|
|
367
378
|
*/
|
|
368
|
-
const getValidationRules = (type, additionalRules) => {
|
|
369
|
-
return _lodash.default.chain(validationRules).get(type).defaultTo([]).cloneDeep().
|
|
379
|
+
const getValidationRules = (type, additionalRules, customData) => {
|
|
380
|
+
return _lodash.default.chain(validationRules).get(type).defaultTo([]).cloneDeep().map(rule => {
|
|
381
|
+
if (typeof rule === 'function') {
|
|
382
|
+
return rule(customData);
|
|
383
|
+
}
|
|
384
|
+
return rule;
|
|
385
|
+
}).concat(_lodash.default.defaultTo(additionalRules, [])).value();
|
|
370
386
|
};
|
|
371
387
|
exports.getValidationRules = getValidationRules;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iguazio.dashboard-react-controls",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.12",
|
|
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",
|