iguazio.dashboard-react-controls 1.3.3 → 1.3.5

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.
@@ -50,18 +50,18 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
50
50
  variant = _ref.variant,
51
51
  restProps = _objectWithoutProperties(_ref, _excluded);
52
52
  var buttonClassName = (0, _classnames.default)('btn', "btn-".concat(variant), "btn-".concat(density), className);
53
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("button", _objectSpread(_objectSpread({}, restProps), {}, {
53
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", _objectSpread(_objectSpread({}, restProps), {}, {
54
54
  className: buttonClassName,
55
55
  ref: ref,
56
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Tooltip.default, {
56
+ children: [icon, /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
57
57
  template: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextTooltipTemplate.default, {
58
58
  text: tooltip
59
59
  }),
60
60
  hidden: !tooltip,
61
- children: [icon, label && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
61
+ children: label && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
62
62
  children: label
63
- })]
64
- })
63
+ })
64
+ })]
65
65
  }));
66
66
  });
67
67
  Button.defaultProps = {
@@ -271,7 +271,9 @@ var FormCombobox = function FormCombobox(_ref) {
271
271
  onFocus && onFocus(input.value);
272
272
  }
273
273
  }, [input, onBlur, onFocus, showSelectDropdown]);
274
- var validateField = function validateField(value, allValues) {
274
+ var validateField = function validateField() {
275
+ var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
276
+ var allValues = arguments.length > 1 ? arguments[1] : undefined;
275
277
  var valueToValidate = value.startsWith(selectValue.id) ? value.substring(selectValue.id.length) : value !== null && value !== void 0 ? value : '';
276
278
  var validationError = null;
277
279
  if (!(0, _lodash.isEmpty)(validationRules)) {
@@ -27,6 +27,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
27
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
28
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
29
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); }
30
34
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
31
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."); }
32
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); }
@@ -62,6 +66,7 @@ var FormSelect = function FormSelect(_ref) {
62
66
  required = _ref.required,
63
67
  search = _ref.search,
64
68
  selectedItemAction = _ref.selectedItemAction,
69
+ scrollToView = _ref.scrollToView,
65
70
  tooltip = _ref.tooltip,
66
71
  withoutBorder = _ref.withoutBorder,
67
72
  withSelectedIcon = _ref.withSelectedIcon;
@@ -79,7 +84,7 @@ var FormSelect = function FormSelect(_ref) {
79
84
  var _useState5 = (0, _react.useState)(false),
80
85
  _useState6 = _slicedToArray(_useState5, 2),
81
86
  isOpen = _useState6[0],
82
- setOpen = _useState6[1];
87
+ setIsOpen = _useState6[1];
83
88
  var _useState7 = (0, _react.useState)('bottom-right'),
84
89
  _useState8 = _slicedToArray(_useState7, 2),
85
90
  position = _useState8[0],
@@ -88,8 +93,10 @@ var FormSelect = function FormSelect(_ref) {
88
93
  _useState10 = _slicedToArray(_useState9, 2),
89
94
  searchValue = _useState10[0],
90
95
  setSearchValue = _useState10[1];
91
- var selectRef = (0, _react.useRef)();
96
+ var optionsListRef = (0, _react.useRef)();
92
97
  var popUpRef = (0, _react.useRef)();
98
+ var selectRef = (0, _react.useRef)();
99
+ var searchRef = (0, _react.useRef)();
93
100
  var _ref2 = (selectRef === null || selectRef === void 0 ? void 0 : (_selectRef$current = selectRef.current) === null || _selectRef$current === void 0 ? void 0 : _selectRef$current.getBoundingClientRect()) || {},
94
101
  selectWidth = _ref2.width,
95
102
  selectLeft = _ref2.left;
@@ -99,6 +106,25 @@ var FormSelect = function FormSelect(_ref) {
99
106
  var selectedOption = options.find(function (option) {
100
107
  return option.id === input.value;
101
108
  });
109
+ var getFilteredOptions = (0, _react.useCallback)(function (options) {
110
+ return options.filter(function (option) {
111
+ return !search || option.label.toLowerCase().includes(searchValue.toLowerCase());
112
+ });
113
+ }, [search, searchValue]);
114
+ var sortedOptionsList = (0, _react.useMemo)(function () {
115
+ if (scrollToView) {
116
+ return getFilteredOptions(options);
117
+ }
118
+ var optionsList = _toConsumableArray(options);
119
+ var selectedOption = optionsList.filter(function (option, idx, arr) {
120
+ if (option.id === input.value) {
121
+ arr.splice(idx, 1);
122
+ return true;
123
+ }
124
+ return false;
125
+ });
126
+ return getFilteredOptions([].concat(_toConsumableArray(selectedOption), _toConsumableArray(optionsList)));
127
+ }, [input.value, getFilteredOptions, options, scrollToView]);
102
128
  var getSelectValue = function getSelectValue() {
103
129
  if (!input.value || !input.value.length) {
104
130
  return "Select Option".concat(multiple ? 's' : '');
@@ -114,13 +140,13 @@ var FormSelect = function FormSelect(_ref) {
114
140
  }, [meta.invalid, meta.modified, meta.submitFailed, meta.touched, meta.validating]);
115
141
  var openMenu = (0, _react.useCallback)(function () {
116
142
  if (!isOpen) {
117
- setOpen(true);
143
+ setIsOpen(true);
118
144
  input.onFocus(new Event('focus'));
119
145
  }
120
146
  }, [input, isOpen]);
121
147
  var closeMenu = (0, _react.useCallback)(function () {
122
148
  if (isOpen) {
123
- setOpen(false);
149
+ setIsOpen(false);
124
150
  input.onBlur(new Event('blur'));
125
151
  }
126
152
  }, [input, isOpen]);
@@ -151,6 +177,29 @@ var FormSelect = function FormSelect(_ref) {
151
177
  window.removeEventListener('scroll', handleScroll, true);
152
178
  };
153
179
  }, [clickHandler, handleScroll, isOpen]);
180
+ var scrollOptionToView = (0, _react.useCallback)(function () {
181
+ var selectedOptionEl = optionsListRef.current.querySelector("#".concat(input.value));
182
+ searchValue ? optionsListRef.current.scrollTo({
183
+ top: 0,
184
+ left: 0,
185
+ behavior: 'smooth'
186
+ }) : setTimeout(function () {
187
+ selectedOptionEl.scrollIntoView({
188
+ behavior: 'smooth',
189
+ block: 'center'
190
+ });
191
+ }, 0);
192
+ }, [input.value, searchValue]);
193
+ (0, _react.useEffect)(function () {
194
+ if (isOpen && optionsListRef.current && scrollToView) {
195
+ scrollOptionToView();
196
+ }
197
+ }, [isOpen, scrollOptionToView, scrollToView]);
198
+ (0, _react.useEffect)(function () {
199
+ if (isOpen && search && searchRef.current) {
200
+ searchRef.current.focus();
201
+ }
202
+ }, [isOpen, search]);
154
203
  var toggleOpen = function toggleOpen() {
155
204
  if (isOpen) {
156
205
  closeMenu();
@@ -166,7 +215,7 @@ var FormSelect = function FormSelect(_ref) {
166
215
  setSearchValue('');
167
216
  }
168
217
  }, [closeMenu, multiple]);
169
- var handleSelectOptionClick = function handleSelectOptionClick(selectedOption, option) {
218
+ var handleSelectOptionClick = function handleSelectOptionClick(selectedOption, option, ref) {
170
219
  if (selectedOption !== input.value) {
171
220
  option.handler && option.handler();
172
221
  onChange && onChange(selectedOption);
@@ -292,21 +341,25 @@ var FormSelect = function FormSelect(_ref) {
292
341
  value: searchValue,
293
342
  onChange: function onChange(event) {
294
343
  return setSearchValue(event.target.value);
295
- }
296
- })
297
- }), options.filter(function (option) {
298
- return !search || option.label.toLowerCase().includes(searchValue.toLowerCase());
299
- }).map(function (option) {
300
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectOption.default, {
301
- item: option,
302
- name: name,
303
- onClick: function onClick(selectedOption) {
304
- handleSelectOptionClick(selectedOption, option);
305
344
  },
306
- multiple: multiple,
307
- selectedId: !multiple ? input.value : '',
308
- withSelectedIcon: withSelectedIcon
309
- }, option.id);
345
+ ref: searchRef,
346
+ autoFocus: true
347
+ })
348
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", {
349
+ className: "options-list",
350
+ ref: optionsListRef,
351
+ children: sortedOptionsList.map(function (option) {
352
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectOption.default, {
353
+ item: option,
354
+ name: name,
355
+ onClick: function onClick(selectedOption) {
356
+ handleSelectOptionClick(selectedOption, option);
357
+ },
358
+ multiple: multiple,
359
+ selectedId: !multiple ? input.value : '',
360
+ withSelectedIcon: withSelectedIcon
361
+ }, option.id);
362
+ })
310
363
  })]
311
364
  })
312
365
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", _objectSpread(_objectSpread({}, input), {}, {
@@ -327,6 +380,7 @@ FormSelect.defaultProps = {
327
380
  search: false,
328
381
  tooltip: '',
329
382
  multiple: false,
383
+ scrollToView: true,
330
384
  withoutBorder: false,
331
385
  withSelectedIcon: true
332
386
  };
@@ -342,6 +396,7 @@ FormSelect.propTypes = {
342
396
  search: _propTypes.default.bool,
343
397
  tooltip: _propTypes.default.string,
344
398
  multiple: _propTypes.default.bool,
399
+ scrollToView: _propTypes.default.bool,
345
400
  withoutBorder: _propTypes.default.bool,
346
401
  withSelectedIcon: _propTypes.default.bool
347
402
  };
@@ -67,10 +67,14 @@
67
67
  }
68
68
 
69
69
  .options-list {
70
+ margin: 0;
71
+ padding: 0;
72
+ list-style-type: none;
73
+ max-height: 250px;
74
+ overflow-y: auto;
75
+
70
76
  &__body {
71
77
  width: 100%;
72
- max-height: 250px;
73
- overflow-y: auto;
74
78
  color: $mulledWineTwo;
75
79
  background-color: $white;
76
80
  border: $primaryBorder;
@@ -38,15 +38,14 @@
38
38
  }
39
39
 
40
40
  &.modal-max {
41
- width: 90vw;
42
- height: 90vh;
41
+ width: 96vw;
42
+ height: 94vw;
43
43
  }
44
44
 
45
45
  &__content {
46
46
  display: flex;
47
47
  flex-flow: column nowrap;
48
48
  position: relative;
49
- padding-bottom: 1rem;
50
49
  min-height: inherit;
51
50
  height: 100%;
52
51
  width: 100%;
@@ -101,7 +100,7 @@
101
100
  flex-flow: row nowrap;
102
101
  flex-shrink: 0;
103
102
  justify-content: space-between;
104
- padding: 0 2rem;
103
+ padding: 1rem 2rem;
105
104
  min-height: 50px;
106
105
 
107
106
  &-actions {
@@ -1,17 +1,24 @@
1
1
  .wizard-form {
2
2
  .modal__body {
3
3
  display: flex;
4
- flex-flow: row nowrap;
4
+ flex-flow: column nowrap;
5
5
  overflow: hidden;
6
- padding-top: 0;
7
- padding-right: 0;
6
+ padding: 0;
7
+
8
+ @media screen and (min-width: 1200px) {
9
+ flex-flow: row nowrap;
10
+ }
8
11
  }
9
12
 
10
13
  .wizard-form__content-container {
11
14
  overflow-y: auto;
12
15
  height: 100%;
13
16
  width: 100%;
14
- padding: 1.5rem 2rem 1.5rem 1rem;
17
+ padding: 0 2rem 1.5rem;
18
+
19
+ @media screen and (min-width: 1200px) {
20
+ padding: 1.5rem 2rem 1.5rem 1rem;
21
+ }
15
22
  }
16
23
 
17
24
  .wizard-form__content {
@@ -3,42 +3,44 @@
3
3
  @import '../../../scss/borders';
4
4
 
5
5
  .wizard-steps {
6
+ display: flex;
7
+ flex-flow: row nowrap;
6
8
  background-color: $white;
7
9
  min-width: 260px;
8
- margin-right: 1rem;
9
- margin-top: 1.5rem;
10
- padding-right: 1rem;
11
- overflow-y: auto;
10
+ margin: 1.5rem 0;
11
+ padding: 0 2rem;
12
12
 
13
- &__indicator {
14
- display: inline-flex;
15
- align-items: center;
16
- justify-content: center;
17
- border: 2px solid transparent;
18
- border-radius: 50%;
19
- padding: 10px;
20
- width: 36px;
21
- height: 36px;
22
- }
13
+ @media screen and (min-width: 1200px) {
14
+ flex-flow: column nowrap;
15
+ overflow-y: auto;
16
+ padding: 0 1rem;
23
17
 
24
- & > *:not(:last-child) {
25
- margin-bottom: 10px;
18
+ & > *:not(:last-child) {
19
+ margin-bottom: 10px;
20
+ }
26
21
  }
27
22
 
28
23
  .wizard-steps {
29
24
  &__item {
30
- justify-content: flex-start;
25
+ display: block;
31
26
  background-color: inherit;
32
27
  border: 0;
33
28
  border-radius: 8px;
34
29
  font-size: 1em;
35
30
  padding: 8px;
36
31
  min-height: 52px;
32
+ height: auto;
37
33
  width: 100%;
38
34
 
39
- & > * {
40
- text-align: left;
41
- white-space: normal;
35
+ @media screen and (min-width: 1200px) {
36
+ display: flex;
37
+ align-items: center;
38
+ justify-content: flex-start;
39
+
40
+ & > * {
41
+ text-align: left;
42
+ white-space: normal;
43
+ }
42
44
  }
43
45
 
44
46
  &.active {
@@ -73,5 +75,23 @@
73
75
  }
74
76
  }
75
77
  }
78
+
79
+ &__indicator {
80
+ display: inline-flex;
81
+ align-items: center;
82
+ justify-content: center;
83
+ border: 2px solid transparent;
84
+ border-radius: 50%;
85
+ padding: 10px;
86
+ margin: 0 0 10px 0;
87
+ width: 36px;
88
+ height: 36px;
89
+
90
+ @media screen and (min-width: 1200px) {
91
+ flex-flow: row nowrap;
92
+ text-align: left;
93
+ margin: 0 10px 0 0;
94
+ }
95
+ }
76
96
  }
77
97
  }
@@ -52,12 +52,13 @@ var SelectOption = function SelectOption(_ref) {
52
52
  })
53
53
  });
54
54
  }
55
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
55
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
56
56
  "data-testid": "select-option",
57
57
  className: selectClassName,
58
58
  onClick: function onClick() {
59
59
  !item.disabled && _onClick(item.id);
60
60
  },
61
+ id: item.id,
61
62
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
62
63
  className: "label-row",
63
64
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
@@ -7,7 +7,7 @@
7
7
  align-items: center;
8
8
  flex-flow: row wrap;
9
9
  width: 100%;
10
- min-height: 50px;
10
+ min-height: 45px;
11
11
  padding: 10px 15px;
12
12
 
13
13
  &.multiple {
@@ -77,6 +77,7 @@
77
77
  &-sub-label {
78
78
  margin-top: 5px;
79
79
  font-size: 13px;
80
+ width: 100%;
80
81
  }
81
82
 
82
83
  &-icon {
@@ -0,0 +1,4 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M5.00003 13.456L12.3667 17.602L18.9794 13.902V15.3753L12.3667 19.108L5.37737 15.1347L5.0007 15.34V15.8533L12.3667 20L19.7334 15.8547V12.9767L19.3901 12.7707L12.3667 16.7453L5.7887 12.9767V11.5033L12.3667 15.2033L19.7334 11.058V8.21334L19.3901 8.008L12.3667 11.9827L6.13137 8.454L12.3667 4.92534L17.5401 7.83734L17.9854 7.56334V7.186L12.3667 4L5.00003 8.18V8.66L12.3667 12.8047L18.9794 9.10467V10.6113L12.3667 14.3467L5.37737 10.3733L5.0007 10.5787L5.00003 13.456Z" fill="#7F7989"/>
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M4.75 13.6022L4.75073 10.4302L5.37992 10.0872L12.3671 14.0593L18.7294 10.4654V9.53103L12.3664 13.0913L4.75003 8.8062V8.03442L12.3667 3.71259L18.2354 7.04037V7.70305L17.5457 8.1274L12.3671 5.21241L6.63897 8.454L12.3667 11.6954L19.3936 7.71878L19.9834 8.07155V11.2042L12.3668 15.4902L6.0387 11.9308V12.8318L12.3675 16.4577L19.3938 12.4813L19.9834 12.8351V16.0009L12.3667 20.2869L4.7507 15.9995V15.1916L5.37992 14.8485L12.3672 18.8207L18.7294 15.2294V14.3284L12.3664 17.8887L4.75 13.6022ZM18.9794 13.902V15.3753L12.3667 19.108L5.37737 15.1347L5.0007 15.34V15.8533L12.3667 20L19.7334 15.8547V12.9767L19.3901 12.7707L12.3667 16.7453L5.7887 12.9767V11.5033L12.3667 15.2033L19.7334 11.058V8.21334L19.3901 8.008L12.3667 11.9827L6.13137 8.454L12.3667 4.92534L17.5401 7.83734L17.9854 7.56334V7.186L12.3667 4L5.00003 8.18V8.66L12.3667 12.8047L18.9794 9.10467V10.6113L12.3667 14.3467L5.37737 10.3733L5.0007 10.5787L5.00003 13.456L12.3667 17.602L18.9794 13.902Z" fill="#7F7989"/>
4
+ </svg>
@@ -310,6 +310,11 @@ var validationRules = {
310
310
  }), generateRule.required()]
311
311
  }
312
312
  },
313
+ function: {
314
+ name: [generateRule.validCharacters('a-z A-Z 0-9 - .'), generateRule.beginEndWith('a-z A-Z 0-9'), generateRule.length({
315
+ max: 63
316
+ }), generateRule.required()]
317
+ },
313
318
  common: {
314
319
  name: [generateRule.validCharacters('a-z A-Z 0-9 - _ .'), generateRule.beginEndWith('a-z A-Z 0-9'), generateRule.length({
315
320
  max: 63
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iguazio.dashboard-react-controls",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
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",