iguazio.dashboard-react-controls 1.3.2 → 1.3.4

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.
@@ -473,7 +473,7 @@ FormInput.propTypes = {
473
473
  pattern: _propTypes.default.string,
474
474
  placeholder: _propTypes.default.string,
475
475
  required: _propTypes.default.bool,
476
- step: _propTypes.default.string,
476
+ step: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
477
477
  suggestionList: _propTypes.default.arrayOf(_propTypes.default.string),
478
478
  tip: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]),
479
479
  type: _propTypes.default.string,
@@ -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;
@@ -1,4 +1,4 @@
1
- @import '~igz-controls/scss/colors';
1
+ @import '../../scss/colors';
2
2
 
3
3
  .form-field-toggle {
4
4
  position: relative;
@@ -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,22 +3,17 @@
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;
13
+ @media screen and (min-width: 1200px) {
14
+ flex-flow: column nowrap;
15
+ overflow-y: auto;
16
+ padding: 0 1rem;
22
17
  }
23
18
 
24
19
  & > *:not(:last-child) {
@@ -27,6 +22,7 @@
27
22
 
28
23
  .wizard-steps {
29
24
  &__item {
25
+ align-items: baseline;
30
26
  justify-content: flex-start;
31
27
  background-color: inherit;
32
28
  border: 0;
@@ -34,11 +30,21 @@
34
30
  font-size: 1em;
35
31
  padding: 8px;
36
32
  min-height: 52px;
33
+ height: auto;
37
34
  width: 100%;
38
35
 
39
36
  & > * {
40
- text-align: left;
37
+ display: flex;
38
+ flex-flow: column nowrap;
39
+ align-items: center;
40
+ text-align: center;
41
41
  white-space: normal;
42
+ width: 100%;
43
+
44
+ @media screen and (min-width: 1200px) {
45
+ flex-flow: row nowrap;
46
+ text-align: left;
47
+ }
42
48
  }
43
49
 
44
50
  &.active {
@@ -73,5 +79,23 @@
73
79
  }
74
80
  }
75
81
  }
82
+
83
+ &__indicator {
84
+ display: inline-flex;
85
+ align-items: center;
86
+ justify-content: center;
87
+ border: 2px solid transparent;
88
+ border-radius: 50%;
89
+ padding: 10px;
90
+ margin: 0 0 10px 0;
91
+ width: 36px;
92
+ height: 36px;
93
+
94
+ @media screen and (min-width: 1200px) {
95
+ flex-flow: row nowrap;
96
+ text-align: left;
97
+ margin: 0 10px 0 0;
98
+ }
99
+ }
76
100
  }
77
101
  }
@@ -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 {
@@ -124,7 +124,12 @@ var useFormTable = function useFormTable(formState) {
124
124
  applyOrDiscardOrDelete(event);
125
125
  }
126
126
  exitEditMode();
127
- formState.form.mutators.remove(fieldsPath, index);
127
+ var values = (0, _lodash.get)(formState.values, fieldsPath);
128
+ if ((values === null || values === void 0 ? void 0 : values.length) > 1) {
129
+ formState.form.mutators.remove(fieldsPath, index);
130
+ } else {
131
+ formState.form.change(fieldsPath, []);
132
+ }
128
133
  event && event.stopPropagation();
129
134
  };
130
135
  var discardChanges = function discardChanges(event, fieldsPath, index) {
@@ -139,6 +139,7 @@ textarea {
139
139
  min-height: $tableHeaderHeight;
140
140
  border-bottom: $primaryBorder;
141
141
  background-color: $white;
142
+ padding: 5px 0;
142
143
 
143
144
  &:not(.no-hover):hover {
144
145
  background-color: $alabaster;
@@ -307,7 +308,8 @@ textarea {
307
308
  }
308
309
 
309
310
  &_left {
310
- &::before, &::after {
311
+ &::before,
312
+ &::after {
311
313
  right: 15px;
312
314
  }
313
315
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iguazio.dashboard-react-controls",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
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",