iguazio.dashboard-react-controls 2.1.3 → 2.1.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.
Files changed (32) hide show
  1. package/dist/components/Backdrop/Backdrop.js +1 -5
  2. package/dist/components/Button/Button.js +6 -14
  3. package/dist/components/ConfirmDialog/ConfirmDialog.js +7 -16
  4. package/dist/components/FormCheckBox/FormCheckBox.js +4 -10
  5. package/dist/components/FormChipCell/FormChip/FormChip.js +12 -22
  6. package/dist/components/FormChipCell/FormChipCell.js +17 -29
  7. package/dist/components/FormChipCell/FormChipCellView.js +11 -17
  8. package/dist/components/FormChipCell/HiddenChipsBlock/HiddenChipsBlock.js +1 -4
  9. package/dist/components/FormChipCell/NewChipForm/NewChipForm.js +5 -6
  10. package/dist/components/FormCombobox/FormCombobox.js +22 -42
  11. package/dist/components/FormInput/FormInput.js +41 -59
  12. package/dist/components/FormInput/InputNumberButtons/InputNumberButtons.js +4 -10
  13. package/dist/components/FormKeyValueTable/FormKeyValueTable.js +18 -38
  14. package/dist/components/FormRadio/FormRadio.js +2 -6
  15. package/dist/components/FormSelect/FormSelect.js +11 -27
  16. package/dist/components/FormTextarea/FormTextarea.js +13 -28
  17. package/dist/components/FormToggle/FormToggle.js +3 -8
  18. package/dist/components/Modal/Modal.js +6 -14
  19. package/dist/components/PopUpDialog/PopUpDialog.js +8 -18
  20. package/dist/components/RoundedIcon/RoundedIcon.js +6 -14
  21. package/dist/components/Tip/Tip.js +1 -4
  22. package/dist/components/Tooltip/Tooltip.js +4 -10
  23. package/dist/components/TooltipTemplate/ProducerTooltipTemplate.js +2 -6
  24. package/dist/components/Wizard/Wizard.js +6 -16
  25. package/dist/components/Wizard/WizardSteps/WizardSteps.js +1 -4
  26. package/dist/elements/FormActionButton/FormActionButton.js +3 -8
  27. package/dist/elements/FormRowActions/FormRowActions.js +4 -10
  28. package/dist/elements/OptionsMenu/OptionsMenu.js +4 -9
  29. package/dist/elements/SelectOption/SelectOption.js +3 -8
  30. package/dist/utils/form.util.js +6 -2
  31. package/dist/utils/validation.util.js +18 -21
  32. package/package.json +1 -1
@@ -32,10 +32,10 @@ such restriction.
32
32
 
33
33
  const FormRadio = _ref => {
34
34
  let {
35
- className,
35
+ className = '',
36
36
  name,
37
37
  label,
38
- readOnly,
38
+ readOnly = false,
39
39
  tooltip,
40
40
  ...inputProps
41
41
  } = _ref;
@@ -76,10 +76,6 @@ const FormRadio = _ref => {
76
76
  }
77
77
  });
78
78
  };
79
- FormRadio.defaultProps = {
80
- className: '',
81
- readOnly: false
82
- };
83
79
  FormRadio.propTypes = {
84
80
  className: _propTypes.default.string,
85
81
  label: _propTypes.default.string.isRequired,
@@ -17,7 +17,6 @@ var _types = require("../../types");
17
17
  var _constants = require("../../constants");
18
18
  var _dropdown = require("../../images/dropdown.svg");
19
19
  require("./formSelect.scss");
20
- var _lodash = require("lodash");
21
20
  var _jsxRuntime = require("react/jsx-runtime");
22
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
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); }
@@ -42,22 +41,22 @@ such restriction.
42
41
  const FormSelect = _ref => {
43
42
  var _selectRef$current;
44
43
  let {
45
- className,
46
- density,
47
- disabled,
48
- hideSelectedOption,
49
- label,
50
- multiple,
44
+ className = '',
45
+ density = 'normal',
46
+ disabled = false,
47
+ hideSelectedOption = false,
48
+ label = '',
49
+ multiple = false,
51
50
  name,
52
51
  onChange,
53
52
  options,
54
53
  required,
55
- search,
54
+ search = false,
56
55
  selectedItemAction,
57
- scrollToView,
58
- tooltip,
59
- withoutBorder,
60
- withSelectedIcon
56
+ scrollToView = true,
57
+ tooltip = '',
58
+ withoutBorder = false,
59
+ withSelectedIcon = true
61
60
  } = _ref;
62
61
  const {
63
62
  input,
@@ -335,20 +334,6 @@ const FormSelect = _ref => {
335
334
  }
336
335
  });
337
336
  };
338
- FormSelect.defaultProps = {
339
- className: '',
340
- density: 'normal',
341
- disabled: false,
342
- hideSelectedOption: false,
343
- label: '',
344
- onClick: null,
345
- search: false,
346
- tooltip: '',
347
- multiple: false,
348
- scrollToView: true,
349
- withoutBorder: false,
350
- withSelectedIcon: true
351
- };
352
337
  FormSelect.propTypes = {
353
338
  className: _propTypes.default.string,
354
339
  density: _propTypes.default.oneOf(['dense', 'normal', 'medium', 'chunky']),
@@ -356,7 +341,6 @@ FormSelect.propTypes = {
356
341
  hideSelectedOption: _propTypes.default.bool,
357
342
  label: _propTypes.default.string,
358
343
  name: _propTypes.default.string.isRequired,
359
- onClick: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.bool]),
360
344
  options: _types.SELECT_OPTIONS.isRequired,
361
345
  search: _propTypes.default.bool,
362
346
  tooltip: _propTypes.default.string,
@@ -36,19 +36,20 @@ such restriction.
36
36
 
37
37
  const FormTextarea = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
38
38
  let {
39
- className,
40
- disabled,
41
- focused,
42
- iconClass,
43
- invalidText,
44
- label,
45
- maxLength,
39
+ className = '',
40
+ disabled = false,
41
+ focused = false,
42
+ iconClass = '',
43
+ invalidText = 'This field is invalid',
44
+ label = '',
45
+ maxLength = null,
46
46
  name,
47
- onBlur,
48
- onChange,
49
- required,
47
+ onBlur = () => {},
48
+ onChange = () => {},
49
+ required = false,
50
+ rows = 3,
50
51
  textAreaIcon,
51
- tip,
52
+ tip = '',
52
53
  withoutBorder,
53
54
  ...textareaProps
54
55
  } = _ref;
@@ -133,6 +134,7 @@ const FormTextarea = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
133
134
  ref: textAreaRef,
134
135
  required: isInvalid || required,
135
136
  disabled,
137
+ rows,
136
138
  ...textareaProps,
137
139
  ...input,
138
140
  onBlur: handleInputBlur,
@@ -165,22 +167,6 @@ const FormTextarea = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
165
167
  }
166
168
  });
167
169
  });
168
- FormTextarea.defaultProps = {
169
- className: '',
170
- disabled: false,
171
- focused: false,
172
- iconClass: '',
173
- textAreaIcon: null,
174
- invalidText: 'This field is invalid',
175
- label: '',
176
- maxLength: null,
177
- onBlur: () => {},
178
- onChange: () => {},
179
- placeholder: '',
180
- required: false,
181
- rows: 3,
182
- tip: ''
183
- };
184
170
  FormTextarea.propTypes = {
185
171
  className: _propTypes.default.string,
186
172
  disabled: _propTypes.default.bool,
@@ -193,7 +179,6 @@ FormTextarea.propTypes = {
193
179
  name: _propTypes.default.string.isRequired,
194
180
  onBlur: _propTypes.default.func,
195
181
  onChange: _propTypes.default.func,
196
- placeholder: _propTypes.default.string,
197
182
  required: _propTypes.default.bool,
198
183
  tip: _propTypes.default.string
199
184
  };
@@ -30,11 +30,11 @@ such restriction.
30
30
 
31
31
  const FormToggle = _ref => {
32
32
  let {
33
- className,
33
+ className = '',
34
34
  density,
35
- label,
35
+ label = '',
36
36
  name,
37
- onChange,
37
+ onChange = () => {},
38
38
  ...inputProps
39
39
  } = _ref;
40
40
  const toggleWrapperClassNames = (0, _classnames.default)('form-field__wrapper', density && "form-field__wrapper-".concat(density));
@@ -72,11 +72,6 @@ const FormToggle = _ref => {
72
72
  }
73
73
  });
74
74
  };
75
- FormToggle.defaultProps = {
76
- className: '',
77
- label: '',
78
- onChange: () => {}
79
- };
80
75
  FormToggle.propTypes = {
81
76
  className: _propTypes.default.string,
82
77
  density: _propTypes.default.string,
@@ -35,15 +35,15 @@ such restriction.
35
35
 
36
36
  const Modal = _ref => {
37
37
  let {
38
- actions,
38
+ actions = [],
39
39
  children,
40
40
  className,
41
41
  onClose,
42
- previewText,
43
- size,
44
- show,
45
- subTitle,
46
- title
42
+ previewText = '',
43
+ size = _constants.MODAL_MD,
44
+ show = false,
45
+ subTitle = null,
46
+ title = ''
47
47
  } = _ref;
48
48
  const modalClassNames = (0, _classnames.default)('modal', className, size && "modal-".concat(size));
49
49
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
@@ -97,14 +97,6 @@ const Modal = _ref => {
97
97
  })]
98
98
  });
99
99
  };
100
- Modal.defaultProps = {
101
- actions: [],
102
- previewText: '',
103
- show: false,
104
- size: _constants.MODAL_MD,
105
- subTitle: null,
106
- title: ''
107
- };
108
100
  Modal.propTypes = {
109
101
  actions: _propTypes.default.array,
110
102
  children: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.object, _propTypes.default.node, _propTypes.default.string]).isRequired,
@@ -40,14 +40,14 @@ const PopUpDialog = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
40
40
  var _ref2;
41
41
  let {
42
42
  children,
43
- className,
44
- closePopUp,
45
- customPosition,
46
- headerIsHidden,
47
- headerText,
48
- showPopUpDialog,
49
- style,
50
- tooltipText
43
+ className = '',
44
+ closePopUp = () => {},
45
+ customPosition = {},
46
+ headerIsHidden = false,
47
+ headerText = '',
48
+ showPopUpDialog = true,
49
+ style = {},
50
+ tooltipText = ''
51
51
  } = _ref;
52
52
  const [showPopUp, setShowPopUp] = (0, _react.useState)(showPopUpDialog !== null && showPopUpDialog !== void 0 ? showPopUpDialog : true);
53
53
  const popUpOverlayRef = (0, _react.useRef)(null);
@@ -154,16 +154,6 @@ const PopUpDialog = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
154
154
  })
155
155
  }), document.getElementById('overlay_container')) : null;
156
156
  });
157
- PopUpDialog.defaultProps = {
158
- className: '',
159
- closePopUp: () => {},
160
- customPosition: {},
161
- headerIsHidden: false,
162
- headerText: '',
163
- showPopUpDialog: true,
164
- style: {},
165
- tooltipText: ''
166
- };
167
157
  PopUpDialog.propTypes = {
168
158
  className: _propTypes.default.string,
169
159
  closePopUp: _propTypes.default.func,
@@ -32,12 +32,12 @@ such restriction.
32
32
  const RoundedIcon = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
33
33
  let {
34
34
  children,
35
- className,
36
- disabled,
37
- id,
38
- isActive,
39
- onClick,
40
- tooltipText
35
+ className = '',
36
+ disabled = false,
37
+ id = '',
38
+ isActive = false,
39
+ onClick = () => {},
40
+ tooltipText = ''
41
41
  } = _ref;
42
42
  const wrapperClassNames = (0, _classnames.default)('round-icon-cp', className);
43
43
  const IconClassNames = (0, _classnames.default)('round-icon-cp__circle', isActive && 'round-icon-cp__circle-active', disabled && 'round-icon-cp__circle-disabled');
@@ -60,14 +60,6 @@ const RoundedIcon = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
60
60
  })
61
61
  });
62
62
  });
63
- RoundedIcon.defaultProps = {
64
- className: '',
65
- disabled: false,
66
- id: '',
67
- isActive: false,
68
- onClick: () => {},
69
- tooltipText: ''
70
- };
71
63
  RoundedIcon.propTypes = {
72
64
  children: _propTypes.default.node.isRequired,
73
65
  className: _propTypes.default.string,
@@ -39,7 +39,7 @@ const iconLength = parseInt(_tip.default.iconlength);
39
39
  const minTextLength = 40;
40
40
  const Tip = _ref => {
41
41
  let {
42
- className,
42
+ className = '',
43
43
  text,
44
44
  withExclamationMark
45
45
  } = _ref;
@@ -108,9 +108,6 @@ const Tip = _ref => {
108
108
  }), document.getElementById('overlay_container'))]
109
109
  });
110
110
  };
111
- Tip.defaultProps = {
112
- className: ''
113
- };
114
111
  Tip.propTypes = {
115
112
  className: _propTypes.default.string,
116
113
  text: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]).isRequired
@@ -37,11 +37,11 @@ const Tooltip = _ref => {
37
37
  let {
38
38
  children,
39
39
  className,
40
- hidden,
41
- id,
42
- renderChildAsHtml,
40
+ hidden = false,
41
+ id = '',
42
+ renderChildAsHtml = false,
43
43
  template,
44
- textShow
44
+ textShow = false
45
45
  } = _ref;
46
46
  const [show, setShow] = (0, _react.useState)(false);
47
47
  const [style, setStyle] = (0, _react.useState)({});
@@ -167,12 +167,6 @@ const Tooltip = _ref => {
167
167
  }), document.getElementById('overlay_container'))]
168
168
  });
169
169
  };
170
- Tooltip.defaultProps = {
171
- hidden: false,
172
- id: '',
173
- renderChildAsHtml: false,
174
- textShow: false
175
- };
176
170
  Tooltip.propTypes = {
177
171
  className: _propTypes.default.string,
178
172
  hidden: _propTypes.default.bool,
@@ -28,8 +28,8 @@ such restriction.
28
28
 
29
29
  const ProducerTooltipTemplate = _ref => {
30
30
  let {
31
- kind,
32
- owner
31
+ kind = '',
32
+ owner = ''
33
33
  } = _ref;
34
34
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
35
35
  className: "tooltip-container",
@@ -46,10 +46,6 @@ const ProducerTooltipTemplate = _ref => {
46
46
  })]
47
47
  });
48
48
  };
49
- ProducerTooltipTemplate.defaultProps = {
50
- kind: '',
51
- owner: ''
52
- };
53
49
  ProducerTooltipTemplate.propTypes = {
54
50
  kind: _propTypes.default.string.isRequired,
55
51
  owner: _propTypes.default.string.isRequired
@@ -38,15 +38,15 @@ such restriction.
38
38
  const Wizard = _ref => {
39
39
  let {
40
40
  children,
41
- className,
42
- getActions,
41
+ className = '',
42
+ getActions = null,
43
43
  isWizardOpen,
44
44
  location,
45
45
  onWizardResolve,
46
- previewText,
47
- size,
48
- stepsConfig,
49
- subTitle,
46
+ previewText = '',
47
+ size = _constants.MODAL_MD,
48
+ stepsConfig = [],
49
+ subTitle = null,
50
50
  title
51
51
  } = _ref;
52
52
  const wizardClasses = (0, _classnames.default)('wizard-form', className);
@@ -164,19 +164,9 @@ const Wizard = _ref => {
164
164
  })]
165
165
  });
166
166
  };
167
- Wizard.defaultProps = {
168
- className: '',
169
- getActions: null,
170
- confirmClose: false,
171
- previewText: '',
172
- size: _constants.MODAL_MD,
173
- stepsConfig: [],
174
- subTitle: null
175
- };
176
167
  Wizard.propsTypes = {
177
168
  className: _propTypes.default.string,
178
169
  getActions: _propTypes.default.func,
179
- confirmClose: _propTypes.default.bool,
180
170
  isWizardOpen: _propTypes.default.bool.isRequired,
181
171
  location: _propTypes.default.string.isRequired,
182
172
  onWizardResolve: _propTypes.default.func.isRequired,
@@ -33,7 +33,7 @@ such restriction.
33
33
  const WizardSteps = _ref => {
34
34
  let {
35
35
  activeStepNumber,
36
- firstDisabledStepIdx,
36
+ firstDisabledStepIdx = null,
37
37
  jumpToStep,
38
38
  steps
39
39
  } = _ref;
@@ -65,9 +65,6 @@ const WizardSteps = _ref => {
65
65
  })
66
66
  });
67
67
  };
68
- WizardSteps.defaultProps = {
69
- firstDisabledStepIdx: null
70
- };
71
68
  WizardSteps.propTypes = {
72
69
  activeStepNumber: _propTypes.default.number.isRequired,
73
70
  firstDisabledStepIdx: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.oneOf([null])]),
@@ -31,12 +31,12 @@ such restriction.
31
31
 
32
32
  const FormActionButton = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
33
33
  let {
34
- disabled,
34
+ disabled = false,
35
35
  fields,
36
36
  fieldsPath,
37
37
  hidden,
38
- id,
39
- label,
38
+ id = '',
39
+ label = 'Add new item',
40
40
  onClick
41
41
  } = _ref;
42
42
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
@@ -53,11 +53,6 @@ const FormActionButton = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
53
53
  })]
54
54
  });
55
55
  });
56
- FormActionButton.defaultProps = {
57
- disabled: false,
58
- id: '',
59
- label: 'Add new item'
60
- };
61
56
  FormActionButton.propTypes = {
62
57
  disabled: _propTypes.default.bool,
63
58
  fields: _propTypes.default.shape({}).isRequired,
@@ -38,13 +38,13 @@ const FormRowActions = _ref => {
38
38
  var _editingItem$ui, _editingItem$ui2, _editingItem$ui3, _editingItem$ui4;
39
39
  let {
40
40
  applyChanges,
41
- deleteButtonIsHidden,
41
+ deleteButtonIsHidden = false,
42
42
  deleteRow,
43
- disabled,
43
+ disabled = false,
44
44
  discardOrDelete,
45
- editingItem,
45
+ editingItem = null,
46
46
  fieldsPath,
47
- hidden,
47
+ hidden = false,
48
48
  index
49
49
  } = _ref;
50
50
  return hidden ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
@@ -86,12 +86,6 @@ const FormRowActions = _ref => {
86
86
  })]
87
87
  });
88
88
  };
89
- FormRowActions.defaultProps = {
90
- deleteButtonIsHidden: false,
91
- disabled: false,
92
- editingItem: null,
93
- hidden: false
94
- };
95
89
  FormRowActions.propTypes = {
96
90
  applyChanges: _propTypes.default.func.isRequired,
97
91
  deleteButtonIsHidden: _propTypes.default.bool,
@@ -30,9 +30,9 @@ such restriction.
30
30
 
31
31
  const OptionsMenu = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
32
32
  let {
33
- children,
34
- show,
35
- timeout
33
+ children = [],
34
+ show = false,
35
+ timeout = 300
36
36
  } = _ref;
37
37
  const {
38
38
  width: dropdownWidth
@@ -52,7 +52,7 @@ const OptionsMenu = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
52
52
  autoHorizontalPosition: true
53
53
  },
54
54
  style: {
55
- 'minWidth': "".concat(dropdownWidth, "px")
55
+ minWidth: "".concat(dropdownWidth, "px")
56
56
  },
57
57
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", {
58
58
  className: "options-menu__body",
@@ -61,11 +61,6 @@ const OptionsMenu = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
61
61
  })
62
62
  });
63
63
  });
64
- OptionsMenu.defaultProps = {
65
- children: [],
66
- show: false,
67
- timeout: 300
68
- };
69
64
  OptionsMenu.propTypes = {
70
65
  children: _propTypes.default.arrayOf(_propTypes.default.element),
71
66
  show: _propTypes.default.bool.isRequired,
@@ -35,10 +35,10 @@ const SelectOption = _ref => {
35
35
  let {
36
36
  item,
37
37
  name,
38
- onClick,
39
- multiple,
38
+ onClick = () => {},
39
+ multiple = false,
40
40
  selectedId,
41
- withSelectedIcon
41
+ withSelectedIcon = true
42
42
  } = _ref;
43
43
  const selectClassName = (0, _classnames.default)('select__item', multiple && 'multiple', item.hidden && 'hidden', item.disabled && 'disabled');
44
44
  if (multiple) {
@@ -97,11 +97,6 @@ const SelectOption = _ref => {
97
97
  })
98
98
  });
99
99
  };
100
- SelectOption.defaultProps = {
101
- onClick: () => {},
102
- multiple: false,
103
- withSelectedIcon: true
104
- };
105
100
  SelectOption.propTypes = {
106
101
  name: _propTypes.default.string.isRequired,
107
102
  item: _types.SELECT_OPTION.isRequired,
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.setFieldState = exports.parseObjectToKeyValue = exports.generateObjectFromKeyValue = exports.areFormValuesChanged = void 0;
6
+ exports.setFieldState = exports.parseObjectToKeyValue = exports.isSubmitDisabled = exports.generateObjectFromKeyValue = exports.areFormValuesChanged = void 0;
7
7
  var _lodash = require("lodash");
8
8
  /*
9
9
  Copyright 2022 Iguazio Systems Ltd.
@@ -63,4 +63,8 @@ const parseObjectToKeyValue = function () {
63
63
  };
64
64
  });
65
65
  };
66
- exports.parseObjectToKeyValue = parseObjectToKeyValue;
66
+ exports.parseObjectToKeyValue = parseObjectToKeyValue;
67
+ const isSubmitDisabled = formState => {
68
+ return formState.submitting || formState.invalid && formState.submitFailed;
69
+ };
70
+ exports.isSubmitDisabled = isSubmitDisabled;
@@ -136,11 +136,12 @@ const generateRule = {
136
136
  pattern: new RegExp('[^' + convertToPattern(chars) + ']$')
137
137
  };
138
138
  },
139
- beginEndWith: chars => {
139
+ beginEndWith: function (chars) {
140
+ let labelPrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
140
141
  const convertedPattern = convertToPattern(chars);
141
142
  return {
142
143
  name: _constants.validation.BEGIN_END_WITH.NAME,
143
- label: _constants.validation.BEGIN_END_WITH.LABEL + ': ' + convertToLabel(chars),
144
+ label: labelPrefix + _constants.validation.BEGIN_END_WITH.LABEL + ': ' + convertToLabel(chars),
144
145
  pattern: new RegExp('^([' + convertedPattern + '].*)?[' + convertedPattern + ']$')
145
146
  };
146
147
  },
@@ -160,10 +161,11 @@ const generateRule = {
160
161
  pattern: new RegExp('^([' + convertedPattern + '])?[^' + convertedPattern + ']+$')
161
162
  };
162
163
  },
163
- validCharacters: chars => {
164
+ validCharacters: function (chars) {
165
+ let labelPrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
164
166
  return {
165
167
  name: _constants.validation.VALID_CHARACTERS.NAME,
166
- label: _constants.validation.VALID_CHARACTERS.LABEL + ': ' + convertToLabel(chars),
168
+ label: labelPrefix + _constants.validation.VALID_CHARACTERS.LABEL + ': ' + convertToLabel(chars),
167
169
  pattern: new RegExp('^[' + convertToPattern(chars) + ']+$')
168
170
  };
169
171
  },
@@ -213,14 +215,15 @@ const generateRule = {
213
215
  }
214
216
  };
215
217
  },
216
- length: options => {
218
+ length: function (options) {
219
+ let labelPrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
217
220
  const min = Number.isSafeInteger(options.min) ? options.min : 0;
218
221
  const max = Number.isSafeInteger(options.max) ? options.max : '';
219
222
  if (min || max) {
220
223
  const label = 'Length – ' + (min ? 'min: ' + options.min + '\xa0\xa0' : '') + (max ? 'max: ' + options.max : '');
221
224
  return {
222
225
  name: 'length',
223
- label: label,
226
+ label: labelPrefix + label,
224
227
  pattern: new RegExp('^[\\S\\s]{' + min + ',' + max + '}$')
225
228
  };
226
229
  }
@@ -260,19 +263,13 @@ const commonRules = {
260
263
  pattern: /^(?![^/]{254,}\/)/
261
264
  }],
262
265
  k8sLabels: {
263
- value: [{
264
- name: 'valueBeginEnd',
265
- label: "[Value] ".concat(_constants.validation.BEGIN_END_WITH.LABEL, " : a\u2013z, A\u2013Z, 0\u20139"),
266
- pattern: /^([^/]+\/)?([A-Za-z0-9][^/]*)?[A-Za-z0-9]$/
267
- }, {
268
- name: 'valueMaxLength',
269
- label: '[Value] Max length - 63 characters',
270
- pattern: /^([^/]+\/)?[^/]{1,63}$/
271
- }, {
272
- name: 'valueValidCharacters',
273
- label: "[Value] ".concat(_constants.validation.VALID_CHARACTERS.LABEL, ": a\u2013z, A\u2013Z, 0\u20139, \u2013, _, ."),
274
- pattern: /^[a-zA-Z0-9\-_.]+$/
275
- }]
266
+ getValue: function () {
267
+ let withPrefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
268
+ let labelPrefix = withPrefix ? '[Value] ' : '';
269
+ return [generateRule.beginEndWith('a-z A-Z 0-9', labelPrefix), generateRule.length({
270
+ max: 63
271
+ }, labelPrefix), generateRule.validCharacters('a-z A-Z 0-9 - _ .', labelPrefix)];
272
+ }
276
273
  }
277
274
  // email: [
278
275
  // generateRule.beginEndNotWith('@ .'),
@@ -331,7 +328,7 @@ const validationRules = {
331
328
  }), generateRule.required()],
332
329
  labels: {
333
330
  key: commonRules.k8sLabels.key,
334
- value: commonRules.k8sLabels.value
331
+ value: commonRules.k8sLabels.getValue(true)
335
332
  },
336
333
  params: {
337
334
  key: [generateRule.notContainCharacters('s')],
@@ -343,7 +340,7 @@ const validationRules = {
343
340
  },
344
341
  nodeSelectors: {
345
342
  key: commonRules.prefixedQualifiedName,
346
- value: commonRules.k8sLabels.value
343
+ value: commonRules.k8sLabels.getValue(false)
347
344
  },
348
345
  environmentVariables: {
349
346
  secretName: [generateRule.validCharacters('a-z A-Z 0-9 - _ .'), generateRule.beginEndWith('a-z A-Z 0-9'), generateRule.noConsecutiveCharacters('.., .–, –.'), generateRule.maxLengthBetweenDelimiters(/[\.\-\_]/, 63, 'periods'), generateRule.length({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iguazio.dashboard-react-controls",
3
- "version": "2.1.3",
3
+ "version": "2.1.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",