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
@@ -14,59 +14,62 @@ var _hooks = require("../../hooks");
14
14
  var _types = require("../../types");
15
15
  var _jsxRuntime = require("react/jsx-runtime");
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
18
- 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."); }
19
- 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); }
20
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
21
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
22
- 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; } /*
23
- Copyright 2022 Iguazio Systems Ltd.
24
- Licensed under the Apache License, Version 2.0 (the "License") with
25
- an addition restriction as set forth herein. You may not use this
26
- file except in compliance with the License. You may obtain a copy of
27
- the License at http://www.apache.org/licenses/LICENSE-2.0.
28
- Unless required by applicable law or agreed to in writing, software
29
- distributed under the License is distributed on an "AS IS" BASIS,
30
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
31
- implied. See the License for the specific language governing
32
- permissions and limitations under the License.
33
- In addition, you may not use the software for any purposes that are
34
- illegal under applicable law, and the grant of the foregoing license
35
- under the Apache 2.0 license is conditioned upon your compliance with
36
- such restriction.
37
- */
38
- var FormKeyValueTable = function FormKeyValueTable(_ref) {
39
- var actionButtonId = _ref.actionButtonId,
40
- addNewItemLabel = _ref.addNewItemLabel,
41
- className = _ref.className,
42
- defaultKey = _ref.defaultKey,
43
- disabled = _ref.disabled,
44
- exitEditModeTriggerItem = _ref.exitEditModeTriggerItem,
45
- fieldsPath = _ref.fieldsPath,
46
- formState = _ref.formState,
47
- isKeyRequired = _ref.isKeyRequired,
48
- isValueRequired = _ref.isValueRequired,
49
- keyHeader = _ref.keyHeader,
50
- keyLabel = _ref.keyLabel,
51
- keyOptions = _ref.keyOptions,
52
- keyValidationRules = _ref.keyValidationRules,
53
- onExitEditModeCallback = _ref.onExitEditModeCallback,
54
- valueHeader = _ref.valueHeader,
55
- valueLabel = _ref.valueLabel,
56
- valueValidationRules = _ref.valueValidationRules;
57
- var tableClassNames = (0, _classnames.default)('form-table form-key-value-table', className);
58
- var _useFormTable = (0, _hooks.useFormTable)(formState, exitEditModeTriggerItem, onExitEditModeCallback),
59
- addNewRow = _useFormTable.addNewRow,
60
- applyChanges = _useFormTable.applyChanges,
61
- bottomScrollRef = _useFormTable.bottomScrollRef,
62
- deleteRow = _useFormTable.deleteRow,
63
- discardOrDelete = _useFormTable.discardOrDelete,
64
- editingItem = _useFormTable.editingItem,
65
- enterEditMode = _useFormTable.enterEditMode,
66
- isCurrentRowEditing = _useFormTable.isCurrentRowEditing;
67
- var uniquenessValidator = function uniquenessValidator(fields, newValue) {
68
- return !fields.value.some(function (_ref2, index) {
69
- var key = _ref2.data.key;
17
+ /*
18
+ Copyright 2022 Iguazio Systems Ltd.
19
+ Licensed under the Apache License, Version 2.0 (the "License") with
20
+ an addition restriction as set forth herein. You may not use this
21
+ file except in compliance with the License. You may obtain a copy of
22
+ the License at http://www.apache.org/licenses/LICENSE-2.0.
23
+ Unless required by applicable law or agreed to in writing, software
24
+ distributed under the License is distributed on an "AS IS" BASIS,
25
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
26
+ implied. See the License for the specific language governing
27
+ permissions and limitations under the License.
28
+ In addition, you may not use the software for any purposes that are
29
+ illegal under applicable law, and the grant of the foregoing license
30
+ under the Apache 2.0 license is conditioned upon your compliance with
31
+ such restriction.
32
+ */
33
+
34
+ const FormKeyValueTable = _ref => {
35
+ let {
36
+ actionButtonId,
37
+ addNewItemLabel,
38
+ className,
39
+ defaultKey,
40
+ disabled,
41
+ exitEditModeTriggerItem,
42
+ fieldsPath,
43
+ formState,
44
+ isKeyRequired,
45
+ isValueRequired,
46
+ keyHeader,
47
+ keyLabel,
48
+ keyOptions,
49
+ keyValidationRules,
50
+ onExitEditModeCallback,
51
+ valueHeader,
52
+ valueLabel,
53
+ valueValidationRules
54
+ } = _ref;
55
+ const tableClassNames = (0, _classnames.default)('form-table form-key-value-table', className);
56
+ const {
57
+ addNewRow,
58
+ applyChanges,
59
+ bottomScrollRef,
60
+ deleteRow,
61
+ discardOrDelete,
62
+ editingItem,
63
+ enterEditMode,
64
+ isCurrentRowEditing
65
+ } = (0, _hooks.useFormTable)(formState, exitEditModeTriggerItem, onExitEditModeCallback);
66
+ const uniquenessValidator = (fields, newValue) => {
67
+ return !fields.value.some((_ref2, index) => {
68
+ let {
69
+ data: {
70
+ key
71
+ }
72
+ } = _ref2;
70
73
  return newValue.trim() === key.trim() && index !== editingItem.ui.index;
71
74
  });
72
75
  };
@@ -86,12 +89,14 @@ var FormKeyValueTable = function FormKeyValueTable(_ref) {
86
89
  })]
87
90
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalFormArrays.FieldArray, {
88
91
  name: fieldsPath,
89
- children: function children(_ref3) {
92
+ children: _ref3 => {
90
93
  var _editingItem$ui;
91
- var fields = _ref3.fields;
94
+ let {
95
+ fields
96
+ } = _ref3;
92
97
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
93
- children: [fields.map(function (rowPath, index) {
94
- var tableRowClassNames = (0, _classnames.default)('form-table__row', isCurrentRowEditing(rowPath) && 'form-table__row_active');
98
+ children: [fields.map((rowPath, index) => {
99
+ const tableRowClassNames = (0, _classnames.default)('form-table__row', isCurrentRowEditing(rowPath) && 'form-table__row_active');
95
100
  return editingItem && index === editingItem.ui.index && !disabled ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
96
101
  className: tableRowClassNames,
97
102
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
@@ -106,13 +111,11 @@ var FormKeyValueTable = function FormKeyValueTable(_ref) {
106
111
  density: "normal",
107
112
  name: "".concat(rowPath, ".data.key"),
108
113
  required: isKeyRequired,
109
- validationRules: [].concat(_toConsumableArray(keyValidationRules), [{
114
+ validationRules: [...keyValidationRules, {
110
115
  name: 'uniqueness',
111
116
  label: 'Name must be unique',
112
- pattern: function pattern(newValue) {
113
- return uniquenessValidator(fields, newValue);
114
- }
115
- }])
117
+ pattern: newValue => uniquenessValidator(fields, newValue)
118
+ }]
116
119
  })
117
120
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
118
121
  className: "form-table__cell form-table__cell_1",
@@ -134,9 +137,7 @@ var FormKeyValueTable = function FormKeyValueTable(_ref) {
134
137
  })]
135
138
  }, index) : /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
136
139
  className: tableRowClassNames,
137
- onClick: function onClick(event) {
138
- return enterEditMode(event, fields, fieldsPath, index);
139
- },
140
+ onClick: event => enterEditMode(event, fields, fieldsPath, index),
140
141
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
141
142
  className: "form-table__cell form-table__cell_1",
142
143
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Tooltip, {
@@ -165,20 +166,20 @@ var FormKeyValueTable = function FormKeyValueTable(_ref) {
165
166
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_elements.FormActionButton, {
166
167
  ref: bottomScrollRef,
167
168
  disabled: disabled,
168
- hidden: editingItem === null || editingItem === void 0 ? void 0 : (_editingItem$ui = editingItem.ui) === null || _editingItem$ui === void 0 ? void 0 : _editingItem$ui.isNew,
169
+ hidden: editingItem === null || editingItem === void 0 || (_editingItem$ui = editingItem.ui) === null || _editingItem$ui === void 0 ? void 0 : _editingItem$ui.isNew,
169
170
  fields: fields,
170
171
  id: actionButtonId,
171
172
  label: addNewItemLabel,
172
- onClick: function onClick() {
173
+ onClick: function () {
173
174
  for (var _len = arguments.length, addRowArgs = new Array(_len), _key = 0; _key < _len; _key++) {
174
175
  addRowArgs[_key] = arguments[_key];
175
176
  }
176
- return addNewRow.apply(void 0, addRowArgs.concat([{
177
+ return addNewRow(...addRowArgs, {
177
178
  data: {
178
179
  key: defaultKey || '',
179
180
  value: ''
180
181
  }
181
- }]));
182
+ });
182
183
  },
183
184
  fieldsPath: fieldsPath
184
185
  })]
@@ -200,7 +201,7 @@ FormKeyValueTable.defaultProps = {
200
201
  keyLabel: 'Key',
201
202
  keyOptions: null,
202
203
  keyValidationRules: [],
203
- onExitEditModeCallback: function onExitEditModeCallback() {},
204
+ onExitEditModeCallback: () => {},
204
205
  valueHeader: 'Value',
205
206
  valueLabel: 'Value',
206
207
  valueValidationRules: []
@@ -228,5 +229,4 @@ FormKeyValueTable.propTypes = {
228
229
  valueLabel: _propTypes.default.string,
229
230
  valueValidationRules: _types.INPUT_VALIDATION_RULES
230
231
  };
231
- var _default = FormKeyValueTable;
232
- exports.default = _default;
232
+ var _default = exports.default = FormKeyValueTable;
@@ -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
  });
@@ -11,7 +10,7 @@ var _reactFinalForm = require("react-final-form");
11
10
  var _classnames = _interopRequireDefault(require("classnames"));
12
11
  require("./FormRadio.scss");
13
12
  var _jsxRuntime = require("react/jsx-runtime");
14
- var _excluded = ["className", "name", "label", "readOnly"];
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
14
  /*
16
15
  Copyright 2022 Iguazio Systems Ltd.
17
16
  Licensed under the Apache License, Version 2.0 (the "License") with
@@ -28,38 +27,36 @@ illegal under applicable law, and the grant of the foregoing license
28
27
  under the Apache 2.0 license is conditioned upon your compliance with
29
28
  such restriction.
30
29
  */
31
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
32
- 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; }
33
- 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; }
34
- 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; }
35
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
36
- 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); }
37
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
38
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
39
- var FormRadio = function FormRadio(_ref) {
40
- var className = _ref.className,
41
- name = _ref.name,
42
- label = _ref.label,
43
- readOnly = _ref.readOnly,
44
- inputProps = _objectWithoutProperties(_ref, _excluded);
45
- var formFieldClassNames = (0, _classnames.default)('form-field-radio', readOnly && 'form-field-radio_readonly', className);
30
+
31
+ const FormRadio = _ref => {
32
+ let {
33
+ className,
34
+ name,
35
+ label,
36
+ readOnly,
37
+ ...inputProps
38
+ } = _ref;
39
+ const formFieldClassNames = (0, _classnames.default)('form-field-radio', readOnly && 'form-field-radio_readonly', className);
46
40
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, {
47
41
  name: name,
48
42
  value: inputProps.value,
49
43
  type: "radio",
50
- children: function children(_ref2) {
51
- var input = _ref2.input;
44
+ children: _ref2 => {
45
+ let {
46
+ input
47
+ } = _ref2;
52
48
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
53
49
  className: formFieldClassNames,
54
50
  "data-testid": name ? "".concat(name, "-").concat(inputProps.value, "-form-radio") : 'form-field-radio',
55
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", _objectSpread(_objectSpread({
51
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
56
52
  className: (0, _classnames.default)(input.checked ? 'checked' : 'unchecked'),
57
53
  type: "radio",
58
- "data-testid": name ? "".concat(name, "-").concat(inputProps.value, "-radio") : 'form-radio'
59
- }, _objectSpread(_objectSpread({}, input), inputProps)), {}, {
54
+ "data-testid": name ? "".concat(name, "-").concat(inputProps.value, "-radio") : 'form-radio',
55
+ ...input,
56
+ ...inputProps,
60
57
  checked: input.checked,
61
58
  id: name + inputProps.value
62
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
59
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
63
60
  htmlFor: name + inputProps.value,
64
61
  children: label
65
62
  })]
@@ -77,5 +74,4 @@ FormRadio.propTypes = {
77
74
  name: _propTypes.default.string.isRequired,
78
75
  readOnly: _propTypes.default.bool
79
76
  };
80
- var _default = /*#__PURE__*/_react.default.memo(FormRadio);
81
- exports.default = _default;
77
+ var _default = exports.default = /*#__PURE__*/_react.default.memo(FormRadio);