iguazio.dashboard-react-controls 0.0.4 → 0.0.7

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 (40) hide show
  1. package/dist/components/Backdrop/Backdrop.js +48 -0
  2. package/dist/components/Backdrop/Backdrop.scss +32 -0
  3. package/dist/components/ConfirmDialog/ConfirmDialog.js +100 -0
  4. package/dist/components/ConfirmDialog/confirmDialog.scss +19 -0
  5. package/dist/components/FormCheckBox/FormCheckBox.js +57 -0
  6. package/dist/components/FormCheckBox/formCheckBox.scss +33 -0
  7. package/dist/components/FormInput/FormInput.js +418 -0
  8. package/dist/components/FormInput/formInput.scss +169 -0
  9. package/dist/components/FormSelect/FormSelect.js +306 -0
  10. package/dist/components/FormSelect/FormSelect.test.js +158 -0
  11. package/dist/components/FormSelect/formSelect.scss +303 -0
  12. package/dist/components/Modal/Modal.js +116 -0
  13. package/dist/components/Modal/Modal.scss +121 -0
  14. package/dist/components/PopUpDialog/PopUpDialog.js +1 -1
  15. package/dist/components/PopUpDialog/popUpDialog.scss +2 -2
  16. package/dist/components/Tip/Tip.js +132 -0
  17. package/dist/components/Tip/Tip.test.js +96 -0
  18. package/dist/components/Tip/tip.scss +89 -0
  19. package/dist/components/Wizard/Wizard.js +253 -0
  20. package/dist/components/Wizard/Wizard.scss +17 -0
  21. package/dist/components/Wizard/WizardSteps/WizardSteps.js +65 -0
  22. package/dist/components/Wizard/WizardSteps/WizardSteps.scss +67 -0
  23. package/dist/components/index.js +56 -0
  24. package/dist/constants.js +29 -3
  25. package/dist/elements/OptionsMenu/OptionsMenu.js +64 -0
  26. package/dist/elements/OptionsMenu/optionsMenu.scss +49 -0
  27. package/dist/elements/SelectOption/SelectOption.js +95 -0
  28. package/dist/elements/SelectOption/SelectOption.test.js +99 -0
  29. package/dist/elements/SelectOption/selectOption.scss +61 -0
  30. package/dist/elements/ValidationTemplate/ValidationTemplate.js +48 -0
  31. package/dist/elements/ValidationTemplate/ValidationTemplate.scss +36 -0
  32. package/dist/hooks/useDetectOutsideClick.js +34 -0
  33. package/dist/images/checkmark2.svg +3 -0
  34. package/dist/index.js +5 -1
  35. package/dist/scss/colors.scss +1 -0
  36. package/dist/scss/mixins.scss +11 -23
  37. package/dist/scss/variables.scss +1 -0
  38. package/dist/types.js +62 -2
  39. package/dist/utils/validationService.js +269 -0
  40. package/package.json +7 -4
@@ -181,9 +181,7 @@
181
181
  &_grey {
182
182
  @include chipButtonAddBackground($mulledWineThree, $topaz);
183
183
  }
184
- }
185
-
186
- @else {
184
+ } @else {
187
185
  &_none {
188
186
  background-color: transparent;
189
187
  }
@@ -261,9 +259,7 @@
261
259
  &_medium {
262
260
  @include chipButtonAddSize(34px);
263
261
  }
264
- }
265
-
266
- @else {
262
+ } @else {
267
263
  &_dense {
268
264
  height: 26px;
269
265
  }
@@ -308,9 +304,7 @@
308
304
  &_purple {
309
305
  @include editableChipFont($amethyst);
310
306
  }
311
- }
312
-
313
- @else if $component == Chip {
307
+ } @else if $component == Chip {
314
308
  &_white {
315
309
  @include chipFont($white);
316
310
  }
@@ -330,9 +324,7 @@
330
324
  &_orange {
331
325
  @include chipFont($sorbus);
332
326
  }
333
- }
334
-
335
- @else if $component == ButtonAddChip {
327
+ } @else if $component == ButtonAddChip {
336
328
  &_primary {
337
329
  @include chipButtonAddColor($topaz);
338
330
  }
@@ -722,6 +714,11 @@
722
714
  }
723
715
  }
724
716
 
717
+ .disabled {
718
+ color: $doveGray;
719
+ cursor: not-allowed;
720
+ }
721
+
725
722
  .no-border {
726
723
  border-bottom: none;
727
724
 
@@ -980,23 +977,14 @@
980
977
  @mixin gradient($type) {
981
978
  @if $type == 'card' {
982
979
  background: linear-gradient(180deg, $brightTurquoise 4px, $white 4px);
983
- }
984
-
985
- @else {
986
- background:
987
- linear-gradient(
988
- 88.84deg,
989
- #d873e1 5.49%,
990
- #fc658f 57.67%,
991
- #ffb971 107.73%
992
- );
980
+ } @else {
981
+ background: linear-gradient(88.84deg, #d873e1 5.49%, #fc658f 57.67%, #ffb971 107.73%);
993
982
  }
994
983
  }
995
984
 
996
985
  @mixin fieldWrapper {
997
986
  position: relative;
998
987
  width: 100%;
999
- padding: 18px 16px;
1000
988
  color: $primary;
1001
989
  background-color: transparent;
1002
990
  border: $primaryBorder;
@@ -3,6 +3,7 @@
3
3
  $heightRowTable: 55px;
4
4
  $leftRowOffset: 49px;
5
5
  $mainBorderRadius: 4px;
6
+ $modalBorderRadius: 8px;
6
7
 
7
8
  $navbarWidth: 245px;
8
9
  $navbarTogglerWidth: 35px;
package/dist/types.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.POP_UP_CUSTOM_POSITION = exports.BUTTON_VARIANTS = void 0;
6
+ exports.WIZARD_STEPS_CONFIG = exports.SELECT_OPTIONS = exports.SELECT_OPTION = exports.POP_UP_CUSTOM_POSITION = exports.MODAL_SIZES = exports.INPUT_VALIDATION_RULES = exports.INPUT_LINK = exports.CONFIRM_DIALOG_SUBMIT_BUTTON = exports.CONFIRM_DIALOG_CANCEL_BUTTON = exports.BUTTON_VARIANTS = void 0;
7
7
 
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
 
@@ -20,4 +20,64 @@ var POP_UP_CUSTOM_POSITION = _propTypes.default.shape({
20
20
  position: _propTypes.default.oneOf(['top-left', 'top-right', 'bottom-left', 'bottom-right'])
21
21
  });
22
22
 
23
- exports.POP_UP_CUSTOM_POSITION = POP_UP_CUSTOM_POSITION;
23
+ exports.POP_UP_CUSTOM_POSITION = POP_UP_CUSTOM_POSITION;
24
+
25
+ var MODAL_SIZES = _propTypes.default.oneOf([_constants.MODAL_SM, _constants.MODAL_MD, _constants.MODAL_LG]);
26
+
27
+ exports.MODAL_SIZES = MODAL_SIZES;
28
+
29
+ var CONFIRM_DIALOG_CANCEL_BUTTON = _propTypes.default.shape({
30
+ handler: _propTypes.default.func,
31
+ label: _propTypes.default.string.isRequired,
32
+ variant: _propTypes.default.string.isRequired
33
+ });
34
+
35
+ exports.CONFIRM_DIALOG_CANCEL_BUTTON = CONFIRM_DIALOG_CANCEL_BUTTON;
36
+
37
+ var CONFIRM_DIALOG_SUBMIT_BUTTON = _propTypes.default.shape({
38
+ handler: _propTypes.default.func.isRequired,
39
+ label: _propTypes.default.string.isRequired,
40
+ variant: _propTypes.default.string.isRequired
41
+ });
42
+
43
+ exports.CONFIRM_DIALOG_SUBMIT_BUTTON = CONFIRM_DIALOG_SUBMIT_BUTTON;
44
+
45
+ var WIZARD_STEPS_CONFIG = _propTypes.default.arrayOf(_propTypes.default.shape({
46
+ id: _propTypes.default.string,
47
+ label: _propTypes.default.string,
48
+ getActions: _propTypes.default.func
49
+ }));
50
+
51
+ exports.WIZARD_STEPS_CONFIG = WIZARD_STEPS_CONFIG;
52
+
53
+ var INPUT_LINK = _propTypes.default.shape({
54
+ show: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.string]),
55
+ url: _propTypes.default.string
56
+ });
57
+
58
+ exports.INPUT_LINK = INPUT_LINK;
59
+
60
+ var SELECT_OPTION = _propTypes.default.shape({
61
+ disabled: _propTypes.default.bool,
62
+ hidden: _propTypes.default.bool,
63
+ icon: _propTypes.default.element,
64
+ id: _propTypes.default.string.isRequired,
65
+ label: _propTypes.default.string.isRequired,
66
+ status: _propTypes.default.string,
67
+ subLabel: _propTypes.default.string
68
+ });
69
+
70
+ exports.SELECT_OPTION = SELECT_OPTION;
71
+
72
+ var SELECT_OPTIONS = _propTypes.default.arrayOf(SELECT_OPTION);
73
+
74
+ exports.SELECT_OPTIONS = SELECT_OPTIONS;
75
+
76
+ var INPUT_VALIDATION_RULES = _propTypes.default.arrayOf(_propTypes.default.shape({
77
+ name: _propTypes.default.string.isRequired,
78
+ label: _propTypes.default.string.isRequired,
79
+ pattern: _propTypes.default.oneOfType([_propTypes.default.instanceOf(RegExp), _propTypes.default.func]).isRequired,
80
+ isValid: _propTypes.default.bool
81
+ }));
82
+
83
+ exports.INPUT_VALIDATION_RULES = INPUT_VALIDATION_RULES;
@@ -0,0 +1,269 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.required = exports.getValidationRules = exports.checkPatternsValidity = void 0;
7
+
8
+ var _lodash = _interopRequireDefault(require("lodash"));
9
+
10
+ var _constants = require("../constants");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ 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; }
15
+
16
+ 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; }
17
+
18
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
+
20
+ ////// PRIVATE METHODS ///////
21
+
22
+ /**
23
+ * Converts characters string to readable format
24
+ * Note: converts Hyphens to En Dashes, replaces one space with comma and space,
25
+ * replaces letter `s` with `spaces` word
26
+ * @param {string} chars - characters to convert
27
+ * @returns {string} - converted string
28
+ * @example
29
+ * convertToLabel('a-z A-Z - _ *');
30
+ * // => 'a–z, A–Z, –, _, *'
31
+ */
32
+ var convertToLabel = function convertToLabel(chars) {
33
+ return chars.replace(/-/g, '–').replace(/\s/g, ', ').replace(/\bs\b/);
34
+ };
35
+ /**
36
+ * Converts characters string to valid RegExp string that will be placed into RegExp pattern
37
+ * @param {string} chars - characters to convert
38
+ * @returns {string} - converted string
39
+ * @example
40
+ * convertToPattern('a-z A-Z - _ *');
41
+ * // => 'a-zA-Z\-\_\*'
42
+ */
43
+
44
+
45
+ var convertToPattern = function convertToPattern(chars) {
46
+ return chars.split(' ').map(function (patternItem) {
47
+ return patternItem.length === 1 ? '\\' + patternItem : patternItem;
48
+ }).join('');
49
+ };
50
+ /**
51
+ * Checks whether there is at least one failed validation rule.
52
+ * @returns {boolean} `true` in case there is at least one failed validation rule, or `false` otherwise.
53
+ */
54
+
55
+
56
+ var hasInvalidRule = function hasInvalidRule(newRules) {
57
+ return _lodash.default.some(newRules, ['isValid', false]);
58
+ }; ////// PUBLIC METHODS ///////
59
+
60
+ /**
61
+ * validate required field value
62
+ * @param {string} validationMsg Custom validationMsg. Defualt to "Required"
63
+ * @returns {function} Function that accepts a value and return an array [isFieldValid, validationMsg]
64
+ */
65
+
66
+
67
+ var required = function required() {
68
+ var validationMsg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Required';
69
+ return function (value) {
70
+ var isValid = value.trim() !== '' && typeof value === 'string';
71
+ return [isValid, validationMsg];
72
+ };
73
+ };
74
+ /**
75
+ * Checks whether there is at least one failed validation rule.
76
+ * @function checkPatternsValidity
77
+ * @param {Array} validationRules Array of Validation Rule Objects {name: "", lable: "", pattren: [Function || Regex]}
78
+ * @param {string} value Field value to check validity
79
+ * @returns {Array} [validationRules, isFieldValid] New validationRules With `isValid` property, `true` in case there is at least one failed validation rule, or `false` otherwise.
80
+ */
81
+
82
+
83
+ exports.required = required;
84
+
85
+ var checkPatternsValidity = function checkPatternsValidity(validationRules, value) {
86
+ var newRules = validationRules.map(function (rule) {
87
+ return _objectSpread(_objectSpread({}, rule), {}, {
88
+ isValid: _lodash.default.isFunction(rule.pattern) ? rule.pattern(value) :
89
+ /* else, it is a RegExp */
90
+ rule.pattern.test(value)
91
+ });
92
+ });
93
+ return [newRules, !hasInvalidRule(newRules)];
94
+ };
95
+
96
+ exports.checkPatternsValidity = checkPatternsValidity;
97
+ var generateRule = {
98
+ beginWith: function beginWith(chars) {
99
+ return {
100
+ name: 'begin',
101
+ label: _constants.validation.BEGIN_WITH + ': ' + convertToLabel(chars),
102
+ pattern: new RegExp('^[' + convertToPattern(chars) + ']')
103
+ };
104
+ },
105
+ beginNotWith: function beginNotWith(chars) {
106
+ return {
107
+ name: 'beginNot',
108
+ label: _constants.validation.BEGIN_NOT_WITH + ': ' + convertToLabel(chars),
109
+ pattern: new RegExp('^[^' + convertToPattern(chars) + ']')
110
+ };
111
+ },
112
+ endWith: function endWith(chars) {
113
+ return {
114
+ name: 'end',
115
+ label: _constants.validation.END_WITH + ': ' + convertToLabel(chars),
116
+ pattern: new RegExp('[' + convertToPattern(chars) + ']$')
117
+ };
118
+ },
119
+ endNotWith: function endNotWith(chars) {
120
+ return {
121
+ name: 'endNot',
122
+ label: _constants.validation.END_NOT_WITH + ': ' + convertToLabel(chars),
123
+ pattern: new RegExp('[^' + convertToPattern(chars) + ']$')
124
+ };
125
+ },
126
+ beginEndWith: function beginEndWith(chars) {
127
+ var convertedPattern = convertToPattern(chars);
128
+ return {
129
+ name: 'beginEnd',
130
+ label: _constants.validation.BEGIN_END_WITH + ': ' + convertToLabel(chars),
131
+ pattern: new RegExp('^([' + convertedPattern + '].*)?[' + convertedPattern + ']$')
132
+ };
133
+ },
134
+ beginEndNotWith: function beginEndNotWith(chars) {
135
+ var convertedPattern = convertToPattern(chars);
136
+ return {
137
+ name: 'beginEndNot',
138
+ label: _constants.validation.BEGIN_END_NOT_WITH + ': ' + convertToLabel(chars),
139
+ pattern: new RegExp('^([^' + convertedPattern + '].*)?[^' + convertedPattern + ']$')
140
+ };
141
+ },
142
+ onlyAtTheBeginning: function onlyAtTheBeginning(chars) {
143
+ var convertedPattern = convertToPattern(chars);
144
+ return {
145
+ name: 'onlyAtTheBeginning',
146
+ label: _constants.validation.ONLY_AT_THE_BEGINNING + ': ' + convertToLabel(chars),
147
+ pattern: new RegExp('^([' + convertedPattern + '])?[^' + convertedPattern + ']+$')
148
+ };
149
+ },
150
+ validCharacters: function validCharacters(chars) {
151
+ return {
152
+ name: 'validCharacters',
153
+ label: _constants.validation.VALID_CHARACTERS + ': ' + convertToLabel(chars),
154
+ pattern: new RegExp('^[' + convertToPattern(chars) + ']+$')
155
+ };
156
+ },
157
+ noConsecutiveCharacters: function noConsecutiveCharacters(chars) {
158
+ var convertedPattern = chars.split(' ').map(function (charPair) {
159
+ var charsPairArray = charPair.split('');
160
+ return "(?!.*\\".concat(charsPairArray[0], "\\").concat(charsPairArray[1], ")");
161
+ }).join('');
162
+ return {
163
+ name: 'noConsecutiveCharacters',
164
+ label: _constants.validation.NO_CONSECUTIVE_CHARACTER + ': ' + convertToLabel(chars),
165
+ pattern: new RegExp('^' + convertedPattern)
166
+ };
167
+ },
168
+ maxLengthBetweenDelimiters: function maxLengthBetweenDelimiters(delimiter, maxLength, delimiterDescription) {
169
+ return {
170
+ name: 'labelsLength',
171
+ label: "Max length between two ".concat(_lodash.default.defaultTo(delimiterDescription, delimiter), ": ").concat(maxLength),
172
+ pattern: function pattern(value) {
173
+ return value.split(delimiter).every(function (item) {
174
+ return item.length >= 1 && item.length <= maxLength;
175
+ });
176
+ }
177
+ };
178
+ },
179
+ mustNotBe: function mustNotBe(words) {
180
+ var wordsArray = words.split(' ');
181
+ return {
182
+ name: 'mustNotBe',
183
+ label: _constants.validation.MUST_NOT_BE + ': ' + convertToLabel(words),
184
+ pattern: function pattern(value) {
185
+ return !_lodash.default.includes(wordsArray, value);
186
+ }
187
+ };
188
+ },
189
+ length: function length(options) {
190
+ var min = Number.isSafeInteger(options.min) ? options.min : 0;
191
+ var max = Number.isSafeInteger(options.max) ? options.max : '';
192
+
193
+ if (min || max) {
194
+ var label = 'Length – ' + (min ? 'min: ' + options.min + '\xa0\xa0' : '') + (max ? 'max: ' + options.max : '');
195
+ return {
196
+ name: 'length',
197
+ label: label,
198
+ pattern: new RegExp('^[\\S\\s]{' + min + ',' + max + '}$')
199
+ };
200
+ }
201
+ },
202
+ required: function required() {
203
+ return {
204
+ name: 'required',
205
+ label: _constants.validation.REQUIRED,
206
+ pattern: new RegExp('\\S')
207
+ };
208
+ }
209
+ }; //const commonRules = {
210
+ // email: [
211
+ // generateRule.beginEndNotWith('@ .'),
212
+ // {
213
+ // name: 'exactlyOne',
214
+ // label: ValidationConstants.MUST_CONTAIN_EXACTLY_ONE + ': @',
215
+ // pattern: /^[^@]+@[^@]+$/
216
+ // },
217
+ // {
218
+ // name: 'dotAfterAt',
219
+ // label: ValidationConstants.MUST_HAVE_DOT_AFTER_AT,
220
+ // pattern: /@.+\..+$/
221
+ // }
222
+ // ]
223
+ //}
224
+
225
+ var validationRules = {
226
+ artifact: {
227
+ name: [generateRule.validCharacters('a-z A-Z 0-9 - _ .'), generateRule.beginEndWith('a-z A-Z 0-9'), generateRule.length({
228
+ max: 253
229
+ }), generateRule.required()]
230
+ },
231
+ feature: {
232
+ sets: {
233
+ tag: [generateRule.validCharacters('a-z A-Z 0-9 - _'), generateRule.beginEndWith('a-z A-Z 0-9'), generateRule.length({
234
+ max: 56
235
+ })]
236
+ },
237
+ vector: {
238
+ name: [generateRule.validCharacters('a-z A-Z 0-9 - _ .'), generateRule.beginEndWith('a-z A-Z 0-9'), generateRule.length({
239
+ max: 56
240
+ }), generateRule.required()]
241
+ }
242
+ },
243
+ common: {
244
+ name: [generateRule.validCharacters('a-z A-Z 0-9 - _ .'), generateRule.beginEndWith('a-z A-Z 0-9'), generateRule.length({
245
+ max: 63
246
+ }), generateRule.required()],
247
+ tag: [generateRule.validCharacters('a-z A-Z 0-9 - _ .'), generateRule.beginEndWith('a-z A-Z 0-9'), generateRule.length({
248
+ max: 56
249
+ })]
250
+ },
251
+ project: {
252
+ name: [generateRule.validCharacters('a-z 0-9 -'), generateRule.beginWith('a-z'), generateRule.endWith('a-z 0-9'), generateRule.length({
253
+ max: 63
254
+ }), generateRule.required()]
255
+ }
256
+ };
257
+ /**
258
+ * Returns the list of validation rules for `type`, optionally appending provided additional rules.
259
+ * @function getValidationRules
260
+ * @param {string} type - The property path to the list of validation rules.
261
+ * @param {Array.<Object>} [additionalRules] - Additional rules to append.
262
+ * @returns {Array.<Object>} the rule list of type `type` with `additionalRules` appended to it if provided.
263
+ */
264
+
265
+ var getValidationRules = function getValidationRules(type, additionalRules) {
266
+ return _lodash.default.chain(validationRules).get(type).defaultTo([]).cloneDeep().concat(_lodash.default.defaultTo(additionalRules, [])).value();
267
+ };
268
+
269
+ exports.getValidationRules = getValidationRules;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iguazio.dashboard-react-controls",
3
- "version": "0.0.4",
3
+ "version": "0.0.7",
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",
@@ -25,7 +25,9 @@
25
25
  "react": "*",
26
26
  "react-dom": "*",
27
27
  "react-modal-promise": "*",
28
- "react-transition-group": "*"
28
+ "react-transition-group": "*",
29
+ "final-form": "^4.20.7",
30
+ "react-final-form": "^6.5.9"
29
31
  },
30
32
  "devDependencies": {
31
33
  "@babel/cli": "^7.17.6",
@@ -62,6 +64,8 @@
62
64
  "prop-types": "^15.8.1",
63
65
  "react": "^17.0.2",
64
66
  "react-dom": "^17.0.2",
67
+ "final-form": "^4.20.7",
68
+ "react-final-form": "^6.5.9",
65
69
  "react-modal-promise": "^1.0.2",
66
70
  "react-scripts": "5.0.0",
67
71
  "react-transition-group": "^4.4.2",
@@ -95,6 +99,5 @@
95
99
  "last 1 firefox version",
96
100
  "last 1 safari version"
97
101
  ]
98
- },
99
- "dependencies": {}
102
+ }
100
103
  }