iguazio.dashboard-react-controls 2.1.3 → 2.1.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.
@@ -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.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",