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.
- package/dist/components/Backdrop/Backdrop.js +7 -7
- package/dist/components/Button/Button.js +20 -26
- package/dist/components/ConfirmDialog/ConfirmDialog.js +18 -17
- package/dist/components/FormCheckBox/FormCheckBox.js +28 -32
- package/dist/components/FormChipCell/FormChip/FormChip.js +46 -50
- package/dist/components/FormChipCell/FormChipCell.js +122 -142
- package/dist/components/FormChipCell/FormChipCellView.js +44 -47
- package/dist/components/FormChipCell/HiddenChipsBlock/HiddenChipsBlock.js +23 -20
- package/dist/components/FormChipCell/NewChipForm/NewChipForm.js +129 -152
- package/dist/components/FormChipCell/NewChipInput/NewChipInput.js +24 -27
- package/dist/components/FormChipCell/formChipCell.util.js +6 -16
- package/dist/components/FormCombobox/FormCombobox.js +134 -195
- package/dist/components/FormInput/FormInput.js +134 -212
- package/dist/components/FormInput/InputNumberButtons/InputNumberButtons.js +15 -14
- package/dist/components/FormKeyValueTable/FormKeyValueTable.js +72 -72
- package/dist/components/FormRadio/FormRadio.js +21 -25
- package/dist/components/FormSelect/FormSelect.js +98 -126
- package/dist/components/FormSelect/FormSelect.test.js +56 -60
- package/dist/components/FormTextarea/FormTextarea.js +55 -71
- package/dist/components/FormToggle/FormToggle.js +25 -29
- package/dist/components/Modal/Modal.js +17 -18
- package/dist/components/PopUpDialog/PopUpDialog.js +53 -63
- package/dist/components/RoundedIcon/RoundedIcon.js +14 -13
- package/dist/components/Tip/Tip.js +58 -64
- package/dist/components/Tip/Tip.test.js +41 -64
- package/dist/components/Tooltip/Tooltip.js +75 -89
- package/dist/components/TooltipTemplate/ProducerTooltipTemplate.js +6 -5
- package/dist/components/TooltipTemplate/TextTooltipTemplate.js +10 -10
- package/dist/components/Wizard/Wizard.js +73 -107
- package/dist/components/Wizard/WizardSteps/WizardSteps.js +19 -20
- package/dist/components/index.js +18 -18
- package/dist/constants.js +26 -44
- package/dist/elements/FormActionButton/FormActionButton.js +12 -13
- package/dist/elements/FormRowActions/FormRowActions.js +19 -22
- package/dist/elements/OptionsMenu/OptionsMenu.js +10 -8
- package/dist/elements/SelectOption/SelectOption.js +14 -13
- package/dist/elements/SelectOption/SelectOption.test.js +39 -47
- package/dist/elements/ValidationTemplate/ValidationTemplate.js +7 -6
- package/dist/elements/index.js +5 -5
- package/dist/hooks/index.js +5 -5
- package/dist/hooks/useChipCell.hook.js +66 -85
- package/dist/hooks/useDebounce.hook.js +22 -24
- package/dist/hooks/useDetectOutsideClick.hook.js +4 -4
- package/dist/hooks/useFormTable.hook.js +99 -112
- package/dist/hooks/useHiddenChipsBlock.hook.js +40 -55
- package/dist/index.js +2 -3
- package/dist/scss/borders.scss +6 -0
- package/dist/scss/mixins.scss +32 -0
- package/dist/types.js +43 -67
- package/dist/utils/common.util.js +19 -23
- package/dist/utils/form.util.js +33 -39
- package/dist/utils/generateChipsList.util.js +7 -7
- package/dist/utils/getFirstScrollableParent.util.js +4 -10
- package/dist/utils/math.util.js +3 -3
- package/dist/utils/validation.util.js +74 -131
- package/package.json +34 -34
|
@@ -6,39 +6,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.required = exports.getValidationRules = exports.checkPatternsValidityAsync = exports.checkPatternsValidity = void 0;
|
|
7
7
|
var _lodash = _interopRequireWildcard(require("lodash"));
|
|
8
8
|
var _constants = require("../constants");
|
|
9
|
-
function _getRequireWildcardCache(
|
|
10
|
-
function _interopRequireWildcard(
|
|
11
|
-
|
|
12
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
an addition restriction as set forth herein. You may not use this
|
|
29
|
-
file except in compliance with the License. You may obtain a copy of
|
|
30
|
-
the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
31
|
-
Unless required by applicable law or agreed to in writing, software
|
|
32
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
33
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
34
|
-
implied. See the License for the specific language governing
|
|
35
|
-
permissions and limitations under the License.
|
|
36
|
-
In addition, you may not use the software for any purposes that are
|
|
37
|
-
illegal under applicable law, and the grant of the foregoing license
|
|
38
|
-
under the Apache 2.0 license is conditioned upon your compliance with
|
|
39
|
-
such restriction.
|
|
40
|
-
*/
|
|
9
|
+
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); }
|
|
10
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
/*
|
|
12
|
+
Copyright 2022 Iguazio Systems Ltd.
|
|
13
|
+
Licensed under the Apache License, Version 2.0 (the "License") with
|
|
14
|
+
an addition restriction as set forth herein. You may not use this
|
|
15
|
+
file except in compliance with the License. You may obtain a copy of
|
|
16
|
+
the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
17
|
+
Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
20
|
+
implied. See the License for the specific language governing
|
|
21
|
+
permissions and limitations under the License.
|
|
22
|
+
In addition, you may not use the software for any purposes that are
|
|
23
|
+
illegal under applicable law, and the grant of the foregoing license
|
|
24
|
+
under the Apache 2.0 license is conditioned upon your compliance with
|
|
25
|
+
such restriction.
|
|
26
|
+
*/
|
|
27
|
+
|
|
41
28
|
////// PRIVATE METHODS ///////
|
|
29
|
+
|
|
42
30
|
/**
|
|
43
31
|
* Converts characters string to readable format
|
|
44
32
|
* Note: converts Hyphens to En Dashes, replaces one space with comma and space,
|
|
@@ -49,7 +37,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
49
37
|
* convertToLabel('a-z A-Z - _ *');
|
|
50
38
|
* // => 'a–z, A–Z, –, _, *'
|
|
51
39
|
*/
|
|
52
|
-
|
|
40
|
+
const convertToLabel = chars => {
|
|
53
41
|
return chars.replace(/-/g, '–').replace(/\s/g, ', ').replace(/\bs\b/, 'spaces');
|
|
54
42
|
};
|
|
55
43
|
|
|
@@ -60,17 +48,15 @@ var convertToLabel = function convertToLabel(chars) {
|
|
|
60
48
|
* @example
|
|
61
49
|
* convertToPattern('a-z A-Z - _ *') => 'a-zA-Z\-\_\*'
|
|
62
50
|
*/
|
|
63
|
-
|
|
64
|
-
return chars.split(' ').map(
|
|
65
|
-
return patternItem.length === 1 ? '\\' + patternItem : patternItem;
|
|
66
|
-
}).join('');
|
|
51
|
+
const convertToPattern = chars => {
|
|
52
|
+
return chars.split(' ').map(patternItem => patternItem.length === 1 ? '\\' + patternItem : patternItem).join('');
|
|
67
53
|
};
|
|
68
54
|
|
|
69
55
|
/**
|
|
70
56
|
* Checks whether there is at least one failed validation rule.
|
|
71
57
|
* @returns {boolean} `true` in case there is at least one failed validation rule, or `false` otherwise.
|
|
72
58
|
*/
|
|
73
|
-
|
|
59
|
+
const hasInvalidRule = newRules => {
|
|
74
60
|
return _lodash.default.some(newRules, ['isValid', false]);
|
|
75
61
|
};
|
|
76
62
|
|
|
@@ -82,10 +68,10 @@ var hasInvalidRule = function hasInvalidRule(newRules) {
|
|
|
82
68
|
* @returns {function} Function that accepts a value and return an array [isFieldValid, validationMsg]
|
|
83
69
|
*/
|
|
84
70
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return
|
|
88
|
-
|
|
71
|
+
const required = function () {
|
|
72
|
+
let validationMsg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Required';
|
|
73
|
+
return value => {
|
|
74
|
+
let isValid = value.trim() !== '' && typeof value === 'string';
|
|
89
75
|
return [isValid, validationMsg];
|
|
90
76
|
};
|
|
91
77
|
};
|
|
@@ -99,140 +85,98 @@ var required = function required() {
|
|
|
99
85
|
* @returns {Array} [validationRules, isFieldValid] New validationRules With `isValid` property, `true` in case there is at least one failed validation rule, or `false` otherwise.
|
|
100
86
|
*/
|
|
101
87
|
exports.required = required;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return
|
|
107
|
-
|
|
108
|
-
return _objectSpread(_objectSpread({}, rule), {}, {
|
|
88
|
+
const checkPatternsValidity = function (validationRules) {
|
|
89
|
+
let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
90
|
+
let required = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
91
|
+
const newRules = !required && (0, _lodash.isEmpty)(value) ? validationRules : validationRules.filter(rule => !rule.async).map(rule => {
|
|
92
|
+
return {
|
|
93
|
+
...rule,
|
|
109
94
|
isValid: _lodash.default.isFunction(rule.pattern) ? rule.pattern(value) : /* else, it is a RegExp */rule.pattern.test(value)
|
|
110
|
-
}
|
|
95
|
+
};
|
|
111
96
|
});
|
|
112
97
|
return [newRules, !hasInvalidRule(newRules)];
|
|
113
98
|
};
|
|
114
99
|
exports.checkPatternsValidity = checkPatternsValidity;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return rule.async;
|
|
125
|
-
}).map( /*#__PURE__*/function () {
|
|
126
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(rule) {
|
|
127
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
128
|
-
while (1) switch (_context.prev = _context.next) {
|
|
129
|
-
case 0:
|
|
130
|
-
_context.t0 = _objectSpread;
|
|
131
|
-
_context.t1 = _objectSpread({}, rule);
|
|
132
|
-
_context.t2 = {};
|
|
133
|
-
_context.next = 5;
|
|
134
|
-
return rule.pattern(value);
|
|
135
|
-
case 5:
|
|
136
|
-
_context.t3 = _context.sent;
|
|
137
|
-
_context.t4 = {
|
|
138
|
-
isValid: _context.t3
|
|
139
|
-
};
|
|
140
|
-
return _context.abrupt("return", (0, _context.t0)(_context.t1, _context.t2, _context.t4));
|
|
141
|
-
case 8:
|
|
142
|
-
case "end":
|
|
143
|
-
return _context.stop();
|
|
144
|
-
}
|
|
145
|
-
}, _callee);
|
|
146
|
-
}));
|
|
147
|
-
return function (_x3) {
|
|
148
|
-
return _ref2.apply(this, arguments);
|
|
149
|
-
};
|
|
150
|
-
}()));
|
|
151
|
-
case 3:
|
|
152
|
-
asyncRules = _context2.sent;
|
|
153
|
-
allRules = newRules.concat(asyncRules);
|
|
154
|
-
return _context2.abrupt("return", [allRules, !hasInvalidRule(allRules)]);
|
|
155
|
-
case 6:
|
|
156
|
-
case "end":
|
|
157
|
-
return _context2.stop();
|
|
158
|
-
}
|
|
159
|
-
}, _callee2);
|
|
160
|
-
}));
|
|
161
|
-
return function checkPatternsValidityAsync(_x, _x2) {
|
|
162
|
-
return _ref.apply(this, arguments);
|
|
163
|
-
};
|
|
164
|
-
}();
|
|
100
|
+
const checkPatternsValidityAsync = async (validationRules, value) => {
|
|
101
|
+
const [newRules] = checkPatternsValidity(validationRules, value);
|
|
102
|
+
const asyncRules = await Promise.all(validationRules.filter(rule => rule.async).map(async rule => ({
|
|
103
|
+
...rule,
|
|
104
|
+
isValid: await rule.pattern(value)
|
|
105
|
+
})));
|
|
106
|
+
const allRules = newRules.concat(asyncRules);
|
|
107
|
+
return [allRules, !hasInvalidRule(allRules)];
|
|
108
|
+
};
|
|
165
109
|
exports.checkPatternsValidityAsync = checkPatternsValidityAsync;
|
|
166
|
-
|
|
167
|
-
beginWith:
|
|
110
|
+
const generateRule = {
|
|
111
|
+
beginWith: chars => {
|
|
168
112
|
return {
|
|
169
113
|
name: _constants.validation.BEGIN_WITH.NAME,
|
|
170
114
|
label: _constants.validation.BEGIN_WITH.LABEL + ': ' + convertToLabel(chars),
|
|
171
115
|
pattern: new RegExp('^[' + convertToPattern(chars) + ']')
|
|
172
116
|
};
|
|
173
117
|
},
|
|
174
|
-
beginNotWith:
|
|
118
|
+
beginNotWith: chars => {
|
|
175
119
|
return {
|
|
176
120
|
name: _constants.validation.BEGIN_NOT_WITH.NAME,
|
|
177
121
|
label: _constants.validation.BEGIN_NOT_WITH.LABEL + ': ' + convertToLabel(chars),
|
|
178
122
|
pattern: new RegExp('^[^' + convertToPattern(chars) + ']')
|
|
179
123
|
};
|
|
180
124
|
},
|
|
181
|
-
endWith:
|
|
125
|
+
endWith: chars => {
|
|
182
126
|
return {
|
|
183
127
|
name: _constants.validation.END_WITH.NAME,
|
|
184
128
|
label: _constants.validation.END_WITH.LABEL + ': ' + convertToLabel(chars),
|
|
185
129
|
pattern: new RegExp('[' + convertToPattern(chars) + ']$')
|
|
186
130
|
};
|
|
187
131
|
},
|
|
188
|
-
endNotWith:
|
|
132
|
+
endNotWith: chars => {
|
|
189
133
|
return {
|
|
190
134
|
name: _constants.validation.END_NOT_WITH.NAME,
|
|
191
135
|
label: _constants.validation.END_NOT_WITH.LABEL + ': ' + convertToLabel(chars),
|
|
192
136
|
pattern: new RegExp('[^' + convertToPattern(chars) + ']$')
|
|
193
137
|
};
|
|
194
138
|
},
|
|
195
|
-
beginEndWith:
|
|
196
|
-
|
|
139
|
+
beginEndWith: chars => {
|
|
140
|
+
const convertedPattern = convertToPattern(chars);
|
|
197
141
|
return {
|
|
198
142
|
name: _constants.validation.BEGIN_END_WITH.NAME,
|
|
199
143
|
label: _constants.validation.BEGIN_END_WITH.LABEL + ': ' + convertToLabel(chars),
|
|
200
144
|
pattern: new RegExp('^([' + convertedPattern + '].*)?[' + convertedPattern + ']$')
|
|
201
145
|
};
|
|
202
146
|
},
|
|
203
|
-
beginEndNotWith:
|
|
204
|
-
|
|
147
|
+
beginEndNotWith: chars => {
|
|
148
|
+
const convertedPattern = convertToPattern(chars);
|
|
205
149
|
return {
|
|
206
150
|
name: _constants.validation.BEGIN_END_NOT_WITH.NAME,
|
|
207
151
|
label: _constants.validation.BEGIN_END_NOT_WITH.LABEL + ': ' + convertToLabel(chars),
|
|
208
152
|
pattern: new RegExp('^([^' + convertedPattern + '].*)?[^' + convertedPattern + ']$')
|
|
209
153
|
};
|
|
210
154
|
},
|
|
211
|
-
onlyAtTheBeginning:
|
|
212
|
-
|
|
155
|
+
onlyAtTheBeginning: chars => {
|
|
156
|
+
const convertedPattern = convertToPattern(chars);
|
|
213
157
|
return {
|
|
214
158
|
name: _constants.validation.ONLY_AT_THE_BEGINNING.NAME,
|
|
215
159
|
label: _constants.validation.ONLY_AT_THE_BEGINNING.LABEL + ': ' + convertToLabel(chars),
|
|
216
160
|
pattern: new RegExp('^([' + convertedPattern + '])?[^' + convertedPattern + ']+$')
|
|
217
161
|
};
|
|
218
162
|
},
|
|
219
|
-
validCharacters:
|
|
163
|
+
validCharacters: chars => {
|
|
220
164
|
return {
|
|
221
165
|
name: _constants.validation.VALID_CHARACTERS.NAME,
|
|
222
166
|
label: _constants.validation.VALID_CHARACTERS.LABEL + ': ' + convertToLabel(chars),
|
|
223
167
|
pattern: new RegExp('^[' + convertToPattern(chars) + ']+$')
|
|
224
168
|
};
|
|
225
169
|
},
|
|
226
|
-
validCharactersWithPrefix:
|
|
170
|
+
validCharactersWithPrefix: chars => {
|
|
227
171
|
return {
|
|
228
172
|
name: _constants.validation.VALID_CHARACTERS_WITH_REFIX.NAME,
|
|
229
173
|
label: _constants.validation.VALID_CHARACTERS_WITH_REFIX.LABEL + ': ' + convertToLabel(chars),
|
|
230
174
|
pattern: new RegExp('^([' + convertToPattern(chars) + ']+/)?[' + convertToPattern(chars) + ']+$')
|
|
231
175
|
};
|
|
232
176
|
},
|
|
233
|
-
noConsecutiveCharacters:
|
|
234
|
-
|
|
235
|
-
|
|
177
|
+
noConsecutiveCharacters: chars => {
|
|
178
|
+
const convertedPattern = chars.split(' ').map(charPair => {
|
|
179
|
+
const charsPairArray = charPair.split('');
|
|
236
180
|
return "(?!.*\\".concat(charsPairArray[0], "\\").concat(charsPairArray[1], ")");
|
|
237
181
|
}).join('');
|
|
238
182
|
return {
|
|
@@ -241,32 +185,32 @@ var generateRule = {
|
|
|
241
185
|
pattern: new RegExp('^' + convertedPattern)
|
|
242
186
|
};
|
|
243
187
|
},
|
|
244
|
-
maxLengthBetweenDelimiters:
|
|
188
|
+
maxLengthBetweenDelimiters: (delimiter, maxLength, delimiterDescription) => {
|
|
245
189
|
return {
|
|
246
190
|
name: 'labelsLength',
|
|
247
191
|
label: "Max length between two ".concat(_lodash.default.defaultTo(delimiterDescription, delimiter), ": ").concat(maxLength),
|
|
248
|
-
pattern:
|
|
249
|
-
return value.split(delimiter).every(
|
|
192
|
+
pattern: value => {
|
|
193
|
+
return value.split(delimiter).every(item => {
|
|
250
194
|
return item.length >= 1 && item.length <= maxLength;
|
|
251
195
|
});
|
|
252
196
|
}
|
|
253
197
|
};
|
|
254
198
|
},
|
|
255
|
-
mustNotBe:
|
|
256
|
-
|
|
199
|
+
mustNotBe: words => {
|
|
200
|
+
const wordsArray = words.split(' ');
|
|
257
201
|
return {
|
|
258
202
|
name: _constants.validation.MUST_NOT_BE.NAME,
|
|
259
203
|
label: _constants.validation.MUST_NOT_BE.LABEL + ': ' + convertToLabel(words),
|
|
260
|
-
pattern: function
|
|
204
|
+
pattern: function (value) {
|
|
261
205
|
return !_lodash.default.includes(wordsArray, value);
|
|
262
206
|
}
|
|
263
207
|
};
|
|
264
208
|
},
|
|
265
|
-
length:
|
|
266
|
-
|
|
267
|
-
|
|
209
|
+
length: options => {
|
|
210
|
+
const min = Number.isSafeInteger(options.min) ? options.min : 0;
|
|
211
|
+
const max = Number.isSafeInteger(options.max) ? options.max : '';
|
|
268
212
|
if (min || max) {
|
|
269
|
-
|
|
213
|
+
const label = 'Length – ' + (min ? 'min: ' + options.min + '\xa0\xa0' : '') + (max ? 'max: ' + options.max : '');
|
|
270
214
|
return {
|
|
271
215
|
name: 'length',
|
|
272
216
|
label: label,
|
|
@@ -274,7 +218,7 @@ var generateRule = {
|
|
|
274
218
|
};
|
|
275
219
|
}
|
|
276
220
|
},
|
|
277
|
-
required:
|
|
221
|
+
required: () => {
|
|
278
222
|
return {
|
|
279
223
|
name: _constants.validation.REQUIRED.NAME,
|
|
280
224
|
label: _constants.validation.REQUIRED.LABEL,
|
|
@@ -282,7 +226,7 @@ var generateRule = {
|
|
|
282
226
|
};
|
|
283
227
|
}
|
|
284
228
|
};
|
|
285
|
-
|
|
229
|
+
const commonRules = {
|
|
286
230
|
prefixedQualifiedName: [{
|
|
287
231
|
name: 'nameValidCharacters',
|
|
288
232
|
label: "[Name] ".concat(_constants.validation.VALID_CHARACTERS.LABEL, " : a\u2013z, A\u2013Z, 0\u20139, \u2013, _, ."),
|
|
@@ -337,13 +281,12 @@ var commonRules = {
|
|
|
337
281
|
// }
|
|
338
282
|
// ]
|
|
339
283
|
};
|
|
340
|
-
|
|
341
284
|
commonRules.k8sLabels.key = commonRules.prefixedQualifiedName.concat({
|
|
342
285
|
name: 'prefixNotStart',
|
|
343
286
|
label: "[Prefix] Must not start with 'kubernetes.io', 'k8s.io'",
|
|
344
287
|
pattern: /^(?!kubernetes\.io\/)(?!k8s\.io\/)/
|
|
345
288
|
});
|
|
346
|
-
|
|
289
|
+
const validationRules = {
|
|
347
290
|
artifact: {
|
|
348
291
|
name: [generateRule.validCharacters('a-z A-Z 0-9 - _ .'), generateRule.beginEndWith('a-z A-Z 0-9'), generateRule.length({
|
|
349
292
|
max: 253
|
|
@@ -415,7 +358,7 @@ var validationRules = {
|
|
|
415
358
|
* @param {Array.<Object>} [additionalRules] - Additional rules to append.
|
|
416
359
|
* @returns {Array.<Object>} the rule list of type `type` with `additionalRules` appended to it if provided.
|
|
417
360
|
*/
|
|
418
|
-
|
|
361
|
+
const getValidationRules = (type, additionalRules) => {
|
|
419
362
|
return _lodash.default.chain(validationRules).get(type).defaultTo([]).cloneDeep().concat(_lodash.default.defaultTo(additionalRules, [])).value();
|
|
420
363
|
};
|
|
421
364
|
exports.getValidationRules = getValidationRules;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iguazio.dashboard-react-controls",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
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",
|
|
@@ -20,16 +20,16 @@
|
|
|
20
20
|
],
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"classnames": "*",
|
|
23
|
+
"final-form": "*",
|
|
24
|
+
"final-form-arrays": "*",
|
|
23
25
|
"lodash": "*",
|
|
24
26
|
"prop-types": "*",
|
|
25
27
|
"react": "*",
|
|
26
28
|
"react-dom": "*",
|
|
27
|
-
"react-modal-promise": "*",
|
|
28
|
-
"react-transition-group": "*",
|
|
29
|
-
"final-form": "*",
|
|
30
|
-
"final-form-arrays": "*",
|
|
31
29
|
"react-final-form": "*",
|
|
32
|
-
"react-final-form-arrays": "*"
|
|
30
|
+
"react-final-form-arrays": "*",
|
|
31
|
+
"react-modal-promise": "*",
|
|
32
|
+
"react-transition-group": "*"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@babel/cli": "^7.17.6",
|
|
@@ -37,42 +37,42 @@
|
|
|
37
37
|
"@babel/eslint-parser": "^7.17.0",
|
|
38
38
|
"@babel/plugin-transform-react-jsx": "^7.17.3",
|
|
39
39
|
"@babel/preset-env": "^7.16.11",
|
|
40
|
-
"@babel/preset-react": "^7.
|
|
41
|
-
"@storybook/addon-actions": "^
|
|
42
|
-
"@storybook/addon-essentials": "^
|
|
43
|
-
"@storybook/addon-interactions": "^
|
|
44
|
-
"@storybook/addon-links": "^
|
|
45
|
-
"@storybook/builder-webpack5": "^
|
|
46
|
-
"@storybook/manager-webpack5": "^6.
|
|
47
|
-
"@storybook/preset-create-react-app": "^
|
|
48
|
-
"@storybook/react": "^
|
|
49
|
-
"@storybook/testing-library": "0.
|
|
50
|
-
"@testing-library/jest-dom": "^
|
|
51
|
-
"@testing-library/react": "^
|
|
52
|
-
"@testing-library/user-event": "^
|
|
40
|
+
"@babel/preset-react": "^7.23.3",
|
|
41
|
+
"@storybook/addon-actions": "^8.0.0",
|
|
42
|
+
"@storybook/addon-essentials": "^8.0.0",
|
|
43
|
+
"@storybook/addon-interactions": "^8.0.0",
|
|
44
|
+
"@storybook/addon-links": "^8.0.0",
|
|
45
|
+
"@storybook/builder-webpack5": "^8.0.0",
|
|
46
|
+
"@storybook/manager-webpack5": "^6.5.16",
|
|
47
|
+
"@storybook/preset-create-react-app": "^8.0.0",
|
|
48
|
+
"@storybook/react": "^8.0.0",
|
|
49
|
+
"@storybook/testing-library": "0.2.2",
|
|
50
|
+
"@testing-library/jest-dom": "^6.4.2",
|
|
51
|
+
"@testing-library/react": "^14.2.1",
|
|
52
|
+
"@testing-library/user-event": "^14.5.2",
|
|
53
53
|
"babel-loader": "^8.2.4",
|
|
54
54
|
"babel-plugin-inline-react-svg": "^2.0.1",
|
|
55
55
|
"classnames": "^2.3.1",
|
|
56
56
|
"cross-env": "^7.0.3",
|
|
57
|
-
"eslint": "^8.
|
|
58
|
-
"eslint-config-prettier": "^
|
|
59
|
-
"eslint-config-react-app": "^7.0.
|
|
60
|
-
"eslint-plugin-prettier": "^
|
|
61
|
-
"eslint-plugin-storybook": "^0.
|
|
62
|
-
"eslint-webpack-plugin": "^
|
|
57
|
+
"eslint": "^8.57.0",
|
|
58
|
+
"eslint-config-prettier": "^9.1.0",
|
|
59
|
+
"eslint-config-react-app": "^7.0.1",
|
|
60
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
61
|
+
"eslint-plugin-storybook": "^0.8.0",
|
|
62
|
+
"eslint-webpack-plugin": "^4.0.1",
|
|
63
|
+
"final-form": "^4.20.10",
|
|
64
|
+
"final-form-arrays": "^3.1.0",
|
|
63
65
|
"lodash": "^4.17.21",
|
|
64
|
-
"node": "
|
|
65
|
-
"prettier": "^2.5
|
|
66
|
+
"node": "21.6.2",
|
|
67
|
+
"prettier": "^3.2.5",
|
|
66
68
|
"prop-types": "^15.8.1",
|
|
67
|
-
"react": "^
|
|
68
|
-
"react-dom": "^
|
|
69
|
-
"final-form": "^4.20.7",
|
|
70
|
-
"final-form-arrays": "^3.0.2",
|
|
69
|
+
"react": "^18.2.0",
|
|
70
|
+
"react-dom": "^18.2.0",
|
|
71
71
|
"react-final-form": "^6.5.9",
|
|
72
|
-
"react-final-form-arrays": "^3.1.
|
|
72
|
+
"react-final-form-arrays": "^3.1.4",
|
|
73
73
|
"react-modal-promise": "^1.0.2",
|
|
74
|
-
"react-scripts": "5.0.
|
|
75
|
-
"react-transition-group": "^4.4.
|
|
74
|
+
"react-scripts": "5.0.1",
|
|
75
|
+
"react-transition-group": "^4.4.5",
|
|
76
76
|
"sass": "^1.50.0",
|
|
77
77
|
"web-vitals": "^2.1.4",
|
|
78
78
|
"webpack": "^5.72.0"
|