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.
Files changed (56) 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/scss/borders.scss +6 -0
  48. package/dist/scss/mixins.scss +32 -0
  49. package/dist/types.js +43 -67
  50. package/dist/utils/common.util.js +19 -23
  51. package/dist/utils/form.util.js +33 -39
  52. package/dist/utils/generateChipsList.util.js +7 -7
  53. package/dist/utils/getFirstScrollableParent.util.js +4 -10
  54. package/dist/utils/math.util.js +3 -3
  55. package/dist/utils/validation.util.js +74 -131
  56. 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,183 +19,156 @@ var _dropdown = require("../../images/dropdown.svg");
20
19
  require("./formSelect.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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
31
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
32
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
33
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
34
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
35
- 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."); }
36
- 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); }
37
- 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; }
38
- 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; } }
39
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /*
40
- Copyright 2022 Iguazio Systems Ltd.
41
- Licensed under the Apache License, Version 2.0 (the "License") with
42
- an addition restriction as set forth herein. You may not use this
43
- file except in compliance with the License. You may obtain a copy of
44
- the License at http://www.apache.org/licenses/LICENSE-2.0.
45
- Unless required by applicable law or agreed to in writing, software
46
- distributed under the License is distributed on an "AS IS" BASIS,
47
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
48
- implied. See the License for the specific language governing
49
- permissions and limitations under the License.
50
- In addition, you may not use the software for any purposes that are
51
- illegal under applicable law, and the grant of the foregoing license
52
- under the Apache 2.0 license is conditioned upon your compliance with
53
- such restriction.
54
- */
55
- var FormSelect = function FormSelect(_ref) {
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 FormSelect = _ref => {
56
42
  var _selectRef$current;
57
- var className = _ref.className,
58
- density = _ref.density,
59
- disabled = _ref.disabled,
60
- hideSelectedOption = _ref.hideSelectedOption,
61
- label = _ref.label,
62
- multiple = _ref.multiple,
63
- name = _ref.name,
64
- onChange = _ref.onChange,
65
- options = _ref.options,
66
- required = _ref.required,
67
- search = _ref.search,
68
- selectedItemAction = _ref.selectedItemAction,
69
- scrollToView = _ref.scrollToView,
70
- tooltip = _ref.tooltip,
71
- withoutBorder = _ref.withoutBorder,
72
- withSelectedIcon = _ref.withSelectedIcon;
73
- var _useField = (0, _reactFinalForm.useField)(name),
74
- input = _useField.input,
75
- meta = _useField.meta;
76
- var _useState = (0, _react.useState)(false),
77
- _useState2 = _slicedToArray(_useState, 2),
78
- isInvalid = _useState2[0],
79
- setIsInvalid = _useState2[1];
80
- var _useState3 = (0, _react.useState)(false),
81
- _useState4 = _slicedToArray(_useState3, 2),
82
- isConfirmDialogOpen = _useState4[0],
83
- setConfirmDialogOpen = _useState4[1];
84
- var _useState5 = (0, _react.useState)(false),
85
- _useState6 = _slicedToArray(_useState5, 2),
86
- isOpen = _useState6[0],
87
- setIsOpen = _useState6[1];
88
- var _useState7 = (0, _react.useState)(''),
89
- _useState8 = _slicedToArray(_useState7, 2),
90
- searchValue = _useState8[0],
91
- setSearchValue = _useState8[1];
92
- var optionsListRef = (0, _react.useRef)();
93
- var popUpRef = (0, _react.useRef)();
94
- var selectRef = (0, _react.useRef)();
95
- var searchRef = (0, _react.useRef)();
96
- var _ref2 = (selectRef === null || selectRef === void 0 ? void 0 : (_selectRef$current = selectRef.current) === null || _selectRef$current === void 0 ? void 0 : _selectRef$current.getBoundingClientRect()) || {},
97
- selectWidth = _ref2.width;
98
- var selectWrapperClassNames = (0, _classnames.default)('form-field__wrapper', "form-field__wrapper-".concat(density), disabled && 'form-field__wrapper-disabled', isOpen && 'form-field__wrapper-active', isInvalid && 'form-field__wrapper-invalid', withoutBorder && 'without-border');
99
- var selectLabelClassName = (0, _classnames.default)('form-field__label', disabled && 'form-field__label-disabled');
100
- var selectValueClassName = (0, _classnames.default)('form-field__select-value', !input.value && 'form-field__select-placeholder');
101
- var selectedOption = options.find(function (option) {
102
- return option.id === input.value;
103
- });
104
- var getFilteredOptions = (0, _react.useCallback)(function (options) {
105
- return options.filter(function (option) {
43
+ let {
44
+ className,
45
+ density,
46
+ disabled,
47
+ hideSelectedOption,
48
+ label,
49
+ multiple,
50
+ name,
51
+ onChange,
52
+ options,
53
+ required,
54
+ search,
55
+ selectedItemAction,
56
+ scrollToView,
57
+ tooltip,
58
+ withoutBorder,
59
+ withSelectedIcon
60
+ } = _ref;
61
+ const {
62
+ input,
63
+ meta
64
+ } = (0, _reactFinalForm.useField)(name);
65
+ const [isInvalid, setIsInvalid] = (0, _react.useState)(false);
66
+ const [isConfirmDialogOpen, setConfirmDialogOpen] = (0, _react.useState)(false);
67
+ const [isOpen, setIsOpen] = (0, _react.useState)(false);
68
+ const [searchValue, setSearchValue] = (0, _react.useState)('');
69
+ const optionsListRef = (0, _react.useRef)();
70
+ const popUpRef = (0, _react.useRef)();
71
+ const selectRef = (0, _react.useRef)();
72
+ const searchRef = (0, _react.useRef)();
73
+ const {
74
+ width: selectWidth
75
+ } = (selectRef === null || selectRef === void 0 || (_selectRef$current = selectRef.current) === null || _selectRef$current === void 0 ? void 0 : _selectRef$current.getBoundingClientRect()) || {};
76
+ const selectWrapperClassNames = (0, _classnames.default)('form-field__wrapper', "form-field__wrapper-".concat(density), disabled && 'form-field__wrapper-disabled', isOpen && 'form-field__wrapper-active', isInvalid && 'form-field__wrapper-invalid', withoutBorder && 'without-border');
77
+ const selectLabelClassName = (0, _classnames.default)('form-field__label', disabled && 'form-field__label-disabled');
78
+ const selectValueClassName = (0, _classnames.default)('form-field__select-value', !input.value && 'form-field__select-placeholder');
79
+ const selectedOption = options.find(option => option.id === input.value);
80
+ const getFilteredOptions = (0, _react.useCallback)(options => {
81
+ return options.filter(option => {
106
82
  return !search || option.label.toLowerCase().includes(searchValue.toLowerCase());
107
83
  });
108
84
  }, [search, searchValue]);
109
- var sortedOptionsList = (0, _react.useMemo)(function () {
85
+ const sortedOptionsList = (0, _react.useMemo)(() => {
110
86
  if (scrollToView) {
111
87
  return getFilteredOptions(options);
112
88
  }
113
- var optionsList = _toConsumableArray(options);
114
- var selectedOption = optionsList.filter(function (option, idx, arr) {
89
+ const optionsList = [...options];
90
+ const selectedOption = optionsList.filter((option, idx, arr) => {
115
91
  if (option.id === input.value) {
116
92
  arr.splice(idx, 1);
117
93
  return true;
118
94
  }
119
95
  return false;
120
96
  });
121
- return getFilteredOptions([].concat(_toConsumableArray(selectedOption), _toConsumableArray(optionsList)));
97
+ return getFilteredOptions([...selectedOption, ...optionsList]);
122
98
  }, [input.value, getFilteredOptions, options, scrollToView]);
123
- var getSelectValue = function getSelectValue() {
99
+ const getSelectValue = () => {
124
100
  if (!input.value || !input.value.length) {
125
101
  return "Select Option".concat(multiple ? 's' : '');
126
102
  }
127
- return !multiple ? selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label : input.value.length <= 2 ? options.filter(function (option) {
128
- return input.value.includes(option.id);
129
- }).map(function (option) {
130
- return option.label;
131
- }).join(', ') : "".concat(input.value.length, " items selected");
103
+ return !multiple ? selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label : input.value.length <= 2 ? options.filter(option => input.value.includes(option.id)).map(option => option.label).join(', ') : "".concat(input.value.length, " items selected");
132
104
  };
133
- (0, _react.useEffect)(function () {
105
+ (0, _react.useEffect)(() => {
134
106
  setIsInvalid(meta.invalid && (meta.validating || meta.modified || meta.submitFailed && meta.touched));
135
107
  }, [meta.invalid, meta.modified, meta.submitFailed, meta.touched, meta.validating]);
136
- var openMenu = (0, _react.useCallback)(function () {
108
+ const openMenu = (0, _react.useCallback)(() => {
137
109
  if (!isOpen) {
138
110
  setIsOpen(true);
139
111
  input.onFocus(new Event('focus'));
140
112
  }
141
113
  }, [input, isOpen]);
142
- var closeMenu = (0, _react.useCallback)(function () {
114
+ const closeMenu = (0, _react.useCallback)(() => {
143
115
  if (isOpen) {
144
116
  setIsOpen(false);
145
117
  input.onBlur(new Event('blur'));
146
118
  }
147
119
  }, [input, isOpen]);
148
- var clickHandler = (0, _react.useCallback)(function (event) {
120
+ const clickHandler = (0, _react.useCallback)(event => {
149
121
  if (selectRef.current !== event.target.closest('.form-field-select')) {
150
122
  closeMenu();
151
123
  }
152
124
  }, [closeMenu]);
153
- var handleScroll = (0, _react.useCallback)(function (event) {
125
+ const handleScroll = (0, _react.useCallback)(event => {
154
126
  if (!event.target.closest('.options-list__body')) {
155
127
  closeMenu();
156
128
  }
157
129
  }, [closeMenu]);
158
- (0, _react.useEffect)(function () {
130
+ (0, _react.useEffect)(() => {
159
131
  if (isOpen) {
160
132
  window.addEventListener('scroll', handleScroll, true);
161
133
  }
162
134
  window.addEventListener('click', clickHandler);
163
- return function () {
135
+ return () => {
164
136
  window.removeEventListener('click', clickHandler);
165
137
  window.removeEventListener('scroll', handleScroll, true);
166
138
  };
167
139
  }, [clickHandler, handleScroll, isOpen]);
168
- var scrollOptionToView = (0, _react.useCallback)(function () {
169
- var selectedOptionEl = optionsListRef.current.querySelector("[data-custom-id=\"".concat(input.value, "\"]"));
140
+ const scrollOptionToView = (0, _react.useCallback)(() => {
141
+ const selectedOptionEl = optionsListRef.current.querySelector("[data-custom-id=\"".concat(input.value, "\"]"));
170
142
  if (!selectedOptionEl) return;
171
143
  searchValue ? optionsListRef.current.scrollTo({
172
144
  top: 0,
173
145
  left: 0,
174
146
  behavior: 'smooth'
175
- }) : setTimeout(function () {
147
+ }) : setTimeout(() => {
176
148
  selectedOptionEl.scrollIntoView({
177
149
  behavior: 'smooth',
178
150
  block: 'center'
179
151
  });
180
152
  }, 0);
181
153
  }, [input.value, searchValue]);
182
- (0, _react.useEffect)(function () {
154
+ (0, _react.useEffect)(() => {
183
155
  if (isOpen && optionsListRef.current && scrollToView) {
184
156
  scrollOptionToView();
185
157
  }
186
158
  }, [isOpen, scrollOptionToView, scrollToView]);
187
- (0, _react.useEffect)(function () {
159
+ (0, _react.useEffect)(() => {
188
160
  if (isOpen && search && searchRef.current) {
189
161
  searchRef.current.focus();
190
162
  }
191
163
  }, [isOpen, search]);
192
- var toggleOpen = function toggleOpen() {
164
+ const toggleOpen = () => {
193
165
  if (isOpen) {
194
166
  closeMenu();
195
167
  } else {
196
168
  !disabled && openMenu();
197
169
  }
198
170
  };
199
- var handleCloseSelectBody = (0, _react.useCallback)(function (event) {
171
+ const handleCloseSelectBody = (0, _react.useCallback)(event => {
200
172
  event.stopPropagation();
201
173
  if (multiple) return;
202
174
  if (!event.target.classList.contains('disabled') && !event.target.closest('.options-list__search')) {
@@ -204,16 +176,16 @@ var FormSelect = function FormSelect(_ref) {
204
176
  setSearchValue('');
205
177
  }
206
178
  }, [closeMenu, multiple]);
207
- var handleSelectOptionClick = function handleSelectOptionClick(selectedOption, option) {
179
+ const handleSelectOptionClick = (selectedOption, option) => {
208
180
  if (selectedOption !== input.value) {
209
181
  option.handler && option.handler();
210
182
  onChange && onChange(selectedOption);
211
- setTimeout(function () {
183
+ setTimeout(() => {
212
184
  input.onChange(selectedOption);
213
185
  });
214
186
  }
215
187
  };
216
- var validateField = function validateField(value) {
188
+ const validateField = value => {
217
189
  if (required) {
218
190
  return value ? undefined : 'Required';
219
191
  }
@@ -221,9 +193,11 @@ var FormSelect = function FormSelect(_ref) {
221
193
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, {
222
194
  name: name,
223
195
  validate: validateField,
224
- children: function children(_ref3) {
225
- var input = _ref3.input,
226
- meta = _ref3.meta;
196
+ children: _ref2 => {
197
+ let {
198
+ input,
199
+ meta
200
+ } = _ref2;
227
201
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
228
202
  className: "select-tooltip",
229
203
  template: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextTooltipTemplate.default, {
@@ -265,7 +239,7 @@ var FormSelect = function FormSelect(_ref) {
265
239
  text: selectedItemAction.tooltip
266
240
  }),
267
241
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
268
- onClick: function onClick(event) {
242
+ onClick: event => {
269
243
  if (selectedItemAction.confirm) {
270
244
  setConfirmDialogOpen(true);
271
245
  } else {
@@ -286,17 +260,17 @@ var FormSelect = function FormSelect(_ref) {
286
260
  })]
287
261
  }), isConfirmDialogOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ConfirmDialog.default, {
288
262
  cancelButton: {
289
- handler: function handler() {
263
+ handler: () => {
290
264
  setConfirmDialogOpen(false);
291
265
  },
292
266
  label: 'Cancel',
293
267
  variant: _constants.TERTIARY_BUTTON
294
268
  },
295
- closePopUp: function closePopUp() {
269
+ closePopUp: () => {
296
270
  setConfirmDialogOpen(false);
297
271
  },
298
272
  confirmButton: {
299
- handler: function handler() {
273
+ handler: () => {
300
274
  selectedItemAction.handler(input.value);
301
275
  setConfirmDialogOpen(false);
302
276
  },
@@ -329,20 +303,18 @@ var FormSelect = function FormSelect(_ref) {
329
303
  type: "text",
330
304
  placeholder: "Search...",
331
305
  value: searchValue,
332
- onChange: function onChange(event) {
333
- return setSearchValue(event.target.value);
334
- },
306
+ onChange: event => setSearchValue(event.target.value),
335
307
  ref: searchRef,
336
308
  autoFocus: true
337
309
  })
338
310
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", {
339
311
  className: "options-list",
340
312
  ref: optionsListRef,
341
- children: sortedOptionsList.map(function (option) {
313
+ children: sortedOptionsList.map(option => {
342
314
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectOption.default, {
343
315
  item: option,
344
316
  name: name,
345
- onClick: function onClick(selectedOption) {
317
+ onClick: selectedOption => {
346
318
  handleSelectOptionClick(selectedOption, option);
347
319
  },
348
320
  multiple: multiple,
@@ -352,9 +324,10 @@ var FormSelect = function FormSelect(_ref) {
352
324
  })
353
325
  })]
354
326
  })
355
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", _objectSpread(_objectSpread({}, input), {}, {
327
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
328
+ ...input,
356
329
  type: "hidden"
357
- }))]
330
+ })]
358
331
  })
359
332
  });
360
333
  }
@@ -390,5 +363,4 @@ FormSelect.propTypes = {
390
363
  withoutBorder: _propTypes.default.bool,
391
364
  withSelectedIcon: _propTypes.default.bool
392
365
  };
393
- var _default = /*#__PURE__*/_react.default.memo(FormSelect);
394
- exports.default = _default;
366
+ var _default = exports.default = /*#__PURE__*/_react.default.memo(FormSelect);
@@ -5,40 +5,34 @@ var _Select = _interopRequireDefault(require("./Select"));
5
5
  var _react2 = require("@testing-library/react");
6
6
  var _jsxRuntime = require("react/jsx-runtime");
7
7
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
- 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); }
9
- 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; }
10
- 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; }
11
- 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; }
12
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
13
- 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); } /*
14
- Copyright 2022 Iguazio Systems Ltd.
15
- Licensed under the Apache License, Version 2.0 (the "License") with
16
- an addition restriction as set forth herein. You may not use this
17
- file except in compliance with the License. You may obtain a copy of
18
- the License at http://www.apache.org/licenses/LICENSE-2.0.
19
- Unless required by applicable law or agreed to in writing, software
20
- distributed under the License is distributed on an "AS IS" BASIS,
21
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
22
- implied. See the License for the specific language governing
23
- permissions and limitations under the License.
24
- In addition, you may not use the software for any purposes that are
25
- illegal under applicable law, and the grant of the foregoing license
26
- under the Apache 2.0 license is conditioned upon your compliance with
27
- such restriction.
28
- */
29
- jest.mock('../../images/dropdown.svg', function () {
30
- return {
31
- ReactComponent: 'caret-icon'
32
- };
33
- });
34
- var renderComponent = function renderComponent(props) {
35
- return (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Select.default, _objectSpread({}, props)));
36
- };
37
- describe('Select component', function () {
38
- var wrapper;
39
- var mockClick = jest.fn();
40
- beforeEach(function () {
41
- var props = {
8
+ /*
9
+ Copyright 2022 Iguazio Systems Ltd.
10
+ Licensed under the Apache License, Version 2.0 (the "License") with
11
+ an addition restriction as set forth herein. You may not use this
12
+ file except in compliance with the License. You may obtain a copy of
13
+ the License at http://www.apache.org/licenses/LICENSE-2.0.
14
+ Unless required by applicable law or agreed to in writing, software
15
+ distributed under the License is distributed on an "AS IS" BASIS,
16
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17
+ implied. See the License for the specific language governing
18
+ permissions and limitations under the License.
19
+ In addition, you may not use the software for any purposes that are
20
+ illegal under applicable law, and the grant of the foregoing license
21
+ under the Apache 2.0 license is conditioned upon your compliance with
22
+ such restriction.
23
+ */
24
+
25
+ jest.mock('../../images/dropdown.svg', () => ({
26
+ ReactComponent: 'caret-icon'
27
+ }));
28
+ const renderComponent = props => (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Select.default, {
29
+ ...props
30
+ }));
31
+ describe('Select component', () => {
32
+ let wrapper;
33
+ const mockClick = jest.fn();
34
+ beforeEach(() => {
35
+ const props = {
42
36
  label: 'Select',
43
37
  floatingLabel: true,
44
38
  selectedId: 'test1',
@@ -52,47 +46,49 @@ describe('Select component', function () {
52
46
  wrapper = renderComponent(props);
53
47
  });
54
48
  afterEach(_react2.cleanup);
55
- it('renders without crashing', function () {
49
+ it('renders without crashing', () => {
56
50
  expect(wrapper.queryByTestId('select')).not.toBeNull();
57
51
  });
58
- it('should show select body after click by select header', function () {
59
- var select = wrapper.getByTestId('select');
52
+ it('should show select body after click by select header', () => {
53
+ const select = wrapper.getByTestId('select');
60
54
  _react2.fireEvent.click(select);
61
55
  expect(wrapper.queryByTestId('select-body')).not.toBeNull();
62
56
  });
63
- it('should hide the select body when scrolling', function () {
64
- var select = wrapper.getByTestId('select');
57
+ it('should hide the select body when scrolling', () => {
58
+ const select = wrapper.getByTestId('select');
65
59
  _react2.fireEvent.click(select);
66
60
  expect(wrapper.queryByTestId('select-body')).not.toBeNull();
67
61
  _react2.fireEvent.scroll(window);
68
62
  expect(wrapper.queryByTestId('select-body')).toBeNull();
69
63
  });
70
- it('should call "onClick" callback with "test1"', function () {
71
- var select = wrapper.getByTestId('select');
64
+ it('should call "onClick" callback with "test1"', () => {
65
+ const select = wrapper.getByTestId('select');
72
66
  _react2.fireEvent.click(select);
73
- var selectOption = wrapper.getByTestId('select-option');
67
+ const selectOption = wrapper.getByTestId('select-option');
74
68
  _react2.fireEvent.click(selectOption);
75
69
  expect(mockClick).toHaveBeenCalledWith('test1');
76
70
  });
77
- it('should not close "selectBody" if click by disabled option', function () {
78
- var props = {
71
+ it('should not close "selectBody" if click by disabled option', () => {
72
+ const props = {
79
73
  options: [{
80
74
  label: 'Test1',
81
75
  id: 'test1'
82
76
  }],
83
77
  disabledOptions: ['test1']
84
78
  };
85
- wrapper.rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Select.default, _objectSpread({}, props)));
86
- var select = wrapper.getByTestId('select');
79
+ wrapper.rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Select.default, {
80
+ ...props
81
+ }));
82
+ const select = wrapper.getByTestId('select');
87
83
  _react2.fireEvent.click(select);
88
- var selectOption = wrapper.getByTestId('select-option');
84
+ const selectOption = wrapper.getByTestId('select-option');
89
85
  _react2.fireEvent.click(selectOption);
90
86
  expect(wrapper.queryByTestId('select-body')).not.toBeNull();
91
87
  });
92
- it('should display selected option', function () {
93
- var select = wrapper.getByTestId('select');
88
+ it('should display selected option', () => {
89
+ const select = wrapper.getByTestId('select');
94
90
  _react2.fireEvent.click(select);
95
- var selectOption = wrapper.getByTestId('select-option');
91
+ const selectOption = wrapper.getByTestId('select-option');
96
92
  _react2.fireEvent.click(selectOption);
97
93
  expect(mockClick).toHaveBeenCalledWith('test1');
98
94
  wrapper.rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Select.default, {
@@ -102,13 +98,13 @@ describe('Select component', function () {
102
98
  }],
103
99
  selectedId: "test1"
104
100
  }));
105
- var selectedOption = wrapper.getByTestId('selected-option');
101
+ const selectedOption = wrapper.getByTestId('selected-option');
106
102
  expect(selectedOption.textContent).toEqual('Test1');
107
103
  });
108
- it('should add className "select__label_floating" to select label if props floatingLabel "true"', function () {
104
+ it('should add className "select__label_floating" to select label if props floatingLabel "true"', () => {
109
105
  expect(wrapper.getByTestId('select-label').className).toMatch('select__label_floating');
110
106
  });
111
- it('should not open select body if props disabled set to "true"', function () {
107
+ it('should not open select body if props disabled set to "true"', () => {
112
108
  wrapper.rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Select.default, {
113
109
  options: [{
114
110
  label: 'Test1',
@@ -116,16 +112,16 @@ describe('Select component', function () {
116
112
  }],
117
113
  disabled: true
118
114
  }));
119
- var select = wrapper.getByTestId('select');
115
+ const select = wrapper.getByTestId('select');
120
116
  _react2.fireEvent.click(select);
121
117
  expect(wrapper.queryByTestId('select-body')).toBeNull();
122
118
  });
123
- it('should display a "subLabel" if it exists in the option', function () {
124
- var subLabel = wrapper.queryByTestId('select-subLabel');
119
+ it('should display a "subLabel" if it exists in the option', () => {
120
+ const subLabel = wrapper.queryByTestId('select-subLabel');
125
121
  expect(subLabel).not.toBeNull();
126
122
  });
127
- it('should call handler callback if it exists in the option', function () {
128
- var mockHandler = jest.fn();
123
+ it('should call handler callback if it exists in the option', () => {
124
+ const mockHandler = jest.fn();
129
125
  wrapper.rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Select.default, {
130
126
  options: [{
131
127
  label: 'Test1',
@@ -133,9 +129,9 @@ describe('Select component', function () {
133
129
  handler: mockHandler
134
130
  }]
135
131
  }));
136
- var select = wrapper.getByTestId('select');
132
+ const select = wrapper.getByTestId('select');
137
133
  _react2.fireEvent.click(select);
138
- var selectOption = wrapper.getByTestId('select-option');
134
+ const selectOption = wrapper.getByTestId('select-option');
139
135
  _react2.fireEvent.click(selectOption);
140
136
  expect(mockHandler).toHaveBeenCalled();
141
137
  });