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.
Files changed (54) hide show
  1. package/dist/components/Backdrop/Backdrop.js +7 -7
  2. package/dist/components/Button/Button.js +20 -26
  3. package/dist/components/ConfirmDialog/ConfirmDialog.js +18 -17
  4. package/dist/components/FormCheckBox/FormCheckBox.js +28 -32
  5. package/dist/components/FormChipCell/FormChip/FormChip.js +46 -50
  6. package/dist/components/FormChipCell/FormChipCell.js +122 -142
  7. package/dist/components/FormChipCell/FormChipCellView.js +44 -47
  8. package/dist/components/FormChipCell/HiddenChipsBlock/HiddenChipsBlock.js +23 -20
  9. package/dist/components/FormChipCell/NewChipForm/NewChipForm.js +129 -152
  10. package/dist/components/FormChipCell/NewChipInput/NewChipInput.js +24 -27
  11. package/dist/components/FormChipCell/formChipCell.util.js +6 -16
  12. package/dist/components/FormCombobox/FormCombobox.js +134 -195
  13. package/dist/components/FormInput/FormInput.js +134 -212
  14. package/dist/components/FormInput/InputNumberButtons/InputNumberButtons.js +15 -14
  15. package/dist/components/FormKeyValueTable/FormKeyValueTable.js +72 -72
  16. package/dist/components/FormRadio/FormRadio.js +21 -25
  17. package/dist/components/FormSelect/FormSelect.js +98 -126
  18. package/dist/components/FormSelect/FormSelect.test.js +56 -60
  19. package/dist/components/FormTextarea/FormTextarea.js +55 -71
  20. package/dist/components/FormToggle/FormToggle.js +25 -29
  21. package/dist/components/Modal/Modal.js +17 -18
  22. package/dist/components/PopUpDialog/PopUpDialog.js +53 -63
  23. package/dist/components/RoundedIcon/RoundedIcon.js +14 -13
  24. package/dist/components/Tip/Tip.js +58 -64
  25. package/dist/components/Tip/Tip.test.js +41 -64
  26. package/dist/components/Tooltip/Tooltip.js +75 -89
  27. package/dist/components/TooltipTemplate/ProducerTooltipTemplate.js +6 -5
  28. package/dist/components/TooltipTemplate/TextTooltipTemplate.js +10 -10
  29. package/dist/components/Wizard/Wizard.js +73 -107
  30. package/dist/components/Wizard/WizardSteps/WizardSteps.js +19 -20
  31. package/dist/components/index.js +18 -18
  32. package/dist/constants.js +26 -44
  33. package/dist/elements/FormActionButton/FormActionButton.js +12 -13
  34. package/dist/elements/FormRowActions/FormRowActions.js +19 -22
  35. package/dist/elements/OptionsMenu/OptionsMenu.js +10 -8
  36. package/dist/elements/SelectOption/SelectOption.js +14 -13
  37. package/dist/elements/SelectOption/SelectOption.test.js +39 -47
  38. package/dist/elements/ValidationTemplate/ValidationTemplate.js +7 -6
  39. package/dist/elements/index.js +5 -5
  40. package/dist/hooks/index.js +5 -5
  41. package/dist/hooks/useChipCell.hook.js +66 -85
  42. package/dist/hooks/useDebounce.hook.js +22 -24
  43. package/dist/hooks/useDetectOutsideClick.hook.js +4 -4
  44. package/dist/hooks/useFormTable.hook.js +99 -112
  45. package/dist/hooks/useHiddenChipsBlock.hook.js +40 -55
  46. package/dist/index.js +2 -3
  47. package/dist/types.js +43 -67
  48. package/dist/utils/common.util.js +19 -23
  49. package/dist/utils/form.util.js +33 -39
  50. package/dist/utils/generateChipsList.util.js +7 -7
  51. package/dist/utils/getFirstScrollableParent.util.js +4 -10
  52. package/dist/utils/math.util.js +3 -3
  53. package/dist/utils/validation.util.js +74 -131
  54. 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(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
24
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
26
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
28
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
29
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
30
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
31
- 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."); }
32
- 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); }
33
- 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; }
34
- 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; } }
35
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /*
36
- Copyright 2022 Iguazio Systems Ltd.
37
- Licensed under the Apache License, Version 2.0 (the "License") with
38
- an addition restriction as set forth herein. You may not use this
39
- file except in compliance with the License. You may obtain a copy of
40
- the License at http://www.apache.org/licenses/LICENSE-2.0.
41
- Unless required by applicable law or agreed to in writing, software
42
- distributed under the License is distributed on an "AS IS" BASIS,
43
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
44
- implied. See the License for the specific language governing
45
- permissions and limitations under the License.
46
- In addition, you may not use the software for any purposes that are
47
- illegal under applicable law, and the grant of the foregoing license
48
- under the Apache 2.0 license is conditioned upon your compliance with
49
- such restriction.
50
- */
51
- var FormChipCell = function FormChipCell(_ref) {
52
- var chipOptions = _ref.chipOptions,
53
- className = _ref.className,
54
- delimiter = _ref.delimiter,
55
- formState = _ref.formState,
56
- initialValues = _ref.initialValues,
57
- isEditable = _ref.isEditable,
58
- label = _ref.label,
59
- name = _ref.name,
60
- onClick = _ref.onClick,
61
- shortChips = _ref.shortChips,
62
- validationRules = _ref.validationRules,
63
- validator = _ref.validator,
64
- onExitEditModeCallback = _ref.onExitEditModeCallback,
65
- visibleChipsMaxLength = _ref.visibleChipsMaxLength;
66
- var chipsClassName = (0, _classnames.default)('chips', className);
67
- var _useChipCell = (0, _hooks.useChipCell)(isEditable, visibleChipsMaxLength),
68
- chipsCellRef = _useChipCell.chipsCellRef,
69
- chipsWrapperRef = _useChipCell.chipsWrapperRef,
70
- handleShowElements = _useChipCell.handleShowElements,
71
- hiddenChipsCounterRef = _useChipCell.hiddenChipsCounterRef,
72
- hiddenChipsPopUpRef = _useChipCell.hiddenChipsPopUpRef,
73
- setChipsSizes = _useChipCell.setChipsSizes,
74
- setShowHiddenChips = _useChipCell.setShowHiddenChips,
75
- showChips = _useChipCell.showChips,
76
- showHiddenChips = _useChipCell.showHiddenChips,
77
- visibleChipsCount = _useChipCell.visibleChipsCount;
78
- var _useState = (0, _react.useState)({
79
- chipIndex: null,
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
- var checkChipsList = (0, _react.useCallback)(function (currentChipsList) {
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
- var handleAddNewChip = (0, _react.useCallback)(function (event, fields) {
95
+ const handleAddNewChip = (0, _react.useCallback)((event, fields) => {
106
96
  var _fields$value;
107
- var fieldsLength = ((_fields$value = fields.value) === null || _fields$value === void 0 ? void 0 : _fields$value.length) || 0;
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
- var handleRemoveChip = (0, _react.useCallback)(function (event, fields, chipIndex) {
129
- checkChipsList(_lodash.default.chain(formState).get(['values', name]).filter(function (_, index) {
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
- var handleEditChip = (0, _react.useCallback)(function (event, fields, nameEvent) {
137
- var _fields$value$editCon = fields.value[editConfig.chipIndex],
138
- key = _fields$value$editCon.key,
139
- value = _fields$value$editCon.value;
140
- var isChipNotEmpty = !!(key !== null && key !== void 0 && key.trim() && value !== null && value !== void 0 && value.trim());
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(function (prevState) {
158
- var lastChipSelected = prevState.chipIndex + 1 > fields.value.length - 1;
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(function (prevState) {
173
- var firstChipIsSelected = prevState.chipIndex === 0;
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
- var handleToEditMode = (0, _react.useCallback)(function (event, chipIndex, keyName) {
178
+ const handleToEditMode = (0, _react.useCallback)((event, chipIndex, keyName) => {
190
179
  if (isEditable) {
191
- var pointerCoordinateX = event.clientX,
192
- pointerCoordinateY = event.clientY;
193
- var isKeyClicked = false;
194
- var isClickedInsideInputElement = function isClickedInsideInputElement(pointerCoordinateX, pointerCoordinateY, inputElement) {
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
- var _inputElement$getBoun = inputElement.getBoundingClientRect(),
197
- topPosition = _inputElement$getBoun.top,
198
- leftPosition = _inputElement$getBoun.left,
199
- rightPosition = _inputElement$getBoun.right,
200
- bottomPosition = _inputElement$getBoun.bottom;
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(function (preState) {
215
- return _objectSpread(_objectSpread({}, preState), {}, {
216
- chipIndex: chipIndex,
217
- isEdit: true,
218
- isKeyFocused: isKeyClicked,
219
- isValueFocused: !isKeyClicked
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
- var validateFields = function validateFields(fieldsArray) {
216
+ const validateFields = fieldsArray => {
226
217
  if (!fieldsArray) return null;
227
- var errorData = [];
228
- var uniquenessValidator = function uniquenessValidator(newValue, idx) {
229
- return !fieldsArray.some(function (_ref2, index) {
230
- var key = _ref2.key;
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(function (chip) {
236
- var _validateChip = validateChip(chip),
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(function (chip, index) {
256
- var isUnique = uniquenessValidator(chip.key, index);
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(function (label) {
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
- var validateChip = function validateChip(_ref3) {
276
- var key = _ref3.key,
277
- value = _ref3.value;
278
- var validateField = function validateField(value, field) {
279
- var _checkPatternsValidit = (0, _validation.checkPatternsValidity)(validationRules[field].filter(function (rule) {
280
- return rule.pattern;
281
- }), value),
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
- var invalidRules = newRules.filter(function (rule) {
287
- return !rule.isValid;
288
- });
289
- return invalidRules.map(function (rule) {
290
- return {
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: chipsCellRef,
320
- chipsWrapperRef: chipsWrapperRef,
321
- hiddenChipsCounterRef: hiddenChipsCounterRef,
322
- hiddenChipsPopUpRef: 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: function 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
- var FormChipCellView = /*#__PURE__*/_react.default.forwardRef(function (_ref, _ref2) {
40
- var chipOptions = _ref.chipOptions,
41
- chips = _ref.chips,
42
- editConfig = _ref.editConfig,
43
- formState = _ref.formState,
44
- handleAddNewChip = _ref.handleAddNewChip,
45
- _handleEditChip = _ref.handleEditChip,
46
- _handleRemoveChip = _ref.handleRemoveChip,
47
- handleShowElements = _ref.handleShowElements,
48
- handleToEditMode = _ref.handleToEditMode,
49
- isEditable = _ref.isEditable,
50
- name = _ref.name,
51
- setChipsSizes = _ref.setChipsSizes,
52
- setEditConfig = _ref.setEditConfig,
53
- shortChips = _ref.shortChips,
54
- showChips = _ref.showChips,
55
- showHiddenChips = _ref.showHiddenChips,
56
- validateFields = _ref.validateFields,
57
- validationRules = _ref.validationRules;
58
- var chipsCellRef = _ref2.chipsCellRef,
59
- chipsWrapperRef = _ref2.chipsWrapperRef,
60
- hiddenChipsCounterRef = _ref2.hiddenChipsCounterRef,
61
- hiddenChipsPopUpRef = _ref2.hiddenChipsPopUpRef;
62
- var 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));
63
- var wrapperClassNames = (0, _classnames.default)('chips-wrapper', isEditable && 'fixed-max-width');
64
- var 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');
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: function children(_ref3) {
70
- var fields = _ref3.fields,
71
- meta = _ref3.meta;
72
- if (!(0, _lodash.isEmpty)(validationRules) && validationRules.key.every(function (rule) {
73
- return rule.name !== _formChipCell.uniquenessError.name;
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(function (contentItem, index) {
87
+ children: [fields.map((contentItem, index) => {
84
88
  var _chips$visibleChips;
85
- var chipData = fields.value[index];
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: function handleEditChip(event, nameEvent) {
107
- return _handleEditChip(event, fields, nameEvent);
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: hiddenChipsCounterRef,
133
- hiddenChipsPopUpRef: 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: function onClick(e) {
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(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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
- var HiddenChipsBlock = /*#__PURE__*/_react.default.forwardRef(function (_ref, _ref2) {
38
- var chipClassNames = _ref.chipClassNames,
39
- chipOptions = _ref.chipOptions,
40
- chips = _ref.chips,
41
- handleShowElements = _ref.handleShowElements,
42
- textOverflowEllipsis = _ref.textOverflowEllipsis;
43
- var hiddenChipsCounterRef = _ref2.hiddenChipsCounterRef,
44
- hiddenChipsPopUpRef = _ref2.hiddenChipsPopUpRef;
45
- var _useHiddenChipsBlock = (0, _hooks.useHiddenChipsBlock)(hiddenChipsCounterRef, hiddenChipsPopUpRef),
46
- hiddenChipsBlockClassNames = _useHiddenChipsBlock.hiddenChipsBlockClassNames;
47
- var chipLabelClassNames = (0, _classnames.default)('chip__label', textOverflowEllipsis && 'data-ellipsis');
48
- var chipValueClassNames = (0, _classnames.default)('chip__value', textOverflowEllipsis && 'data-ellipsis', chipOptions.boldValue && 'chip-value_bold');
49
- var generateChipData = function generateChipData(chip) {
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)(function () {
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(function (element) {
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;