iguazio.dashboard-react-controls 0.0.29 → 0.0.30

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.
@@ -21,14 +21,12 @@ var _InputNumberButtons = _interopRequireDefault(require("./InputNumberButtons/I
21
21
 
22
22
  var _OptionsMenu = _interopRequireDefault(require("../../elements/OptionsMenu/OptionsMenu"));
23
23
 
24
- var _TextTooltipTemplate = _interopRequireDefault(require("../TooltipTemplate/TextTooltipTemplate"));
25
-
26
- var _Tip = _interopRequireDefault(require("../Tip/Tip"));
27
-
28
- var _Tooltip = _interopRequireDefault(require("../Tooltip/Tooltip"));
24
+ var _components = require("../../components");
29
25
 
30
26
  var _ValidationTemplate = _interopRequireDefault(require("../../elements/ValidationTemplate/ValidationTemplate"));
31
27
 
28
+ var _useDebounce = require("../../hooks/useDebounce");
29
+
32
30
  var _validation = require("../../utils/validation.util");
33
31
 
34
32
  var _useDetectOutsideClick = require("../../hooks/useDetectOutsideClick");
@@ -45,7 +43,7 @@ require("./formInput.scss");
45
43
 
46
44
  var _jsxRuntime = require("react/jsx-runtime");
47
45
 
48
- var _excluded = ["className", "density", "disabled", "focused", "iconClass", "inputIcon", "invalidText", "label", "link", "name", "onBlur", "onChange", "pattern", "required", "suggestionList", "tip", "validationRules", "validator", "withoutBorder"];
46
+ var _excluded = ["async", "className", "density", "disabled", "focused", "iconClass", "inputIcon", "invalidText", "label", "link", "name", "onBlur", "onChange", "pattern", "required", "suggestionList", "tip", "validationRules", "validator", "withoutBorder"];
49
47
 
50
48
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
51
49
 
@@ -53,6 +51,12 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
53
51
 
54
52
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
55
53
 
54
+ 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, $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 generator._invoke = function (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); } }; }(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; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return 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, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), 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 (object) { var 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; }
55
+
56
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
57
+
58
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
59
+
56
60
  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; }
57
61
 
58
62
  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; }
@@ -78,7 +82,8 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
78
82
  var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
79
83
  var _ref2;
80
84
 
81
- var className = _ref.className,
85
+ var async = _ref.async,
86
+ className = _ref.className,
82
87
  density = _ref.density,
83
88
  disabled = _ref.disabled,
84
89
  focused = _ref.focused,
@@ -99,65 +104,63 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
99
104
  withoutBorder = _ref.withoutBorder,
100
105
  inputProps = _objectWithoutProperties(_ref, _excluded);
101
106
 
102
- var _useState = (0, _react.useState)({}),
107
+ var _useField = (0, _reactFinalForm.useField)(name),
108
+ input = _useField.input,
109
+ meta = _useField.meta;
110
+
111
+ var _useState = (0, _react.useState)(false),
103
112
  _useState2 = _slicedToArray(_useState, 2),
104
- fieldMeta = _useState2[0],
105
- setFieldMeta = _useState2[1];
113
+ isInvalid = _useState2[0],
114
+ setIsInvalid = _useState2[1];
106
115
 
107
- var _useState3 = (0, _react.useState)({}),
116
+ var _useState3 = (0, _react.useState)(false),
108
117
  _useState4 = _slicedToArray(_useState3, 2),
109
- fieldInput = _useState4[0],
110
- setFieldInput = _useState4[1];
118
+ isFocused = _useState4[0],
119
+ setIsFocused = _useState4[1];
111
120
 
112
- var _useState5 = (0, _react.useState)(false),
121
+ var _useState5 = (0, _react.useState)(''),
113
122
  _useState6 = _slicedToArray(_useState5, 2),
114
- isInvalid = _useState6[0],
115
- setIsInvalid = _useState6[1];
123
+ typedValue = _useState6[0],
124
+ setTypedValue = _useState6[1];
116
125
 
117
- var _useState7 = (0, _react.useState)(false),
118
- _useState8 = _slicedToArray(_useState7, 2),
119
- isFocused = _useState8[0],
120
- setIsFocused = _useState8[1];
126
+ var _useState7 = (0, _react.useState)(RegExp(pattern)),
127
+ _useState8 = _slicedToArray(_useState7, 1),
128
+ validationPattern = _useState8[0];
121
129
 
122
- var _useState9 = (0, _react.useState)(''),
130
+ var _useState9 = (0, _react.useState)(rules),
123
131
  _useState10 = _slicedToArray(_useState9, 2),
124
- typedValue = _useState10[0],
125
- setTypedValue = _useState10[1];
132
+ validationRules = _useState10[0],
133
+ setValidationRules = _useState10[1];
126
134
 
127
- var _useState11 = (0, _react.useState)(RegExp(pattern)),
128
- _useState12 = _slicedToArray(_useState11, 1),
129
- validationPattern = _useState12[0];
130
-
131
- var _useState13 = (0, _react.useState)(rules),
132
- _useState14 = _slicedToArray(_useState13, 2),
133
- validationRules = _useState14[0],
134
- setValidationRules = _useState14[1];
135
-
136
- var _useState15 = (0, _react.useState)(false),
137
- _useState16 = _slicedToArray(_useState15, 2),
138
- showValidationRules = _useState16[0],
139
- setShowValidationRules = _useState16[1];
135
+ var _useState11 = (0, _react.useState)(false),
136
+ _useState12 = _slicedToArray(_useState11, 2),
137
+ showValidationRules = _useState12[0],
138
+ setShowValidationRules = _useState12[1];
140
139
 
141
140
  var wrapperRef = (0, _react.useRef)();
142
141
  (_ref2 = ref) !== null && _ref2 !== void 0 ? _ref2 : ref = wrapperRef;
143
142
  var inputRef = (0, _react.useRef)();
143
+ var errorsRef = (0, _react.useRef)();
144
144
  (0, _useDetectOutsideClick.useDetectOutsideClick)(ref, function () {
145
145
  return setShowValidationRules(false);
146
146
  });
147
+ var debounceAsync = (0, _useDebounce.useDebounce)();
147
148
  var formFieldClassNames = (0, _classnames.default)('form-field-input', className);
148
149
  var inputWrapperClassNames = (0, _classnames.default)('form-field__wrapper', "form-field__wrapper-".concat(density), disabled && 'form-field__wrapper-disabled', isInvalid && 'form-field__wrapper-invalid', withoutBorder && 'without-border');
149
150
  var labelClassNames = (0, _classnames.default)('form-field__label', disabled && 'form-field__label-disabled');
150
151
  (0, _react.useEffect)(function () {
151
- setTypedValue(String(fieldInput.value)); // convert from number to string
152
- }, [fieldInput.value]);
152
+ setTypedValue(String(input.value)); // convert from number to string
153
+ }, [input.value]);
153
154
  (0, _react.useEffect)(function () {
154
- setIsInvalid(fieldMeta.invalid && (fieldMeta.validating || fieldMeta.modified || fieldMeta.submitFailed && fieldMeta.touched));
155
- }, [fieldMeta.invalid, fieldMeta.modified, fieldMeta.submitFailed, fieldMeta.touched, fieldMeta.validating]);
155
+ setIsInvalid(errorsRef.current && meta.invalid && (meta.validating || meta.modified || meta.submitFailed && meta.touched));
156
+ }, [meta.invalid, meta.modified, meta.submitFailed, meta.touched, meta.validating]);
156
157
  (0, _react.useEffect)(function () {
157
- if (fieldMeta.valid && showValidationRules) {
158
- setShowValidationRules(false);
158
+ if (!errorsRef.current) {
159
+ if (meta.valid && showValidationRules) {
160
+ setShowValidationRules(false);
161
+ }
159
162
  }
160
- }, [fieldMeta.valid, showValidationRules]);
163
+ }, [meta.valid, showValidationRules]);
161
164
  (0, _react.useEffect)(function () {
162
165
  if (showValidationRules) {
163
166
  window.addEventListener('scroll', handleScroll, true);
@@ -176,13 +179,13 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
176
179
  setValidationRules(function () {
177
180
  return rules.map(function (rule) {
178
181
  return _objectSpread(_objectSpread({}, rule), {}, {
179
- isValid: !fieldMeta.error || !Array.isArray(fieldMeta.error) ? true : !fieldMeta.error.some(function (err) {
182
+ isValid: !errorsRef.current || !Array.isArray(errorsRef.current) ? true : !errorsRef.current.some(function (err) {
180
183
  return err.name === rule.name;
181
184
  })
182
185
  });
183
186
  });
184
187
  });
185
- }, [fieldMeta.error, rules]);
188
+ }, [rules]);
186
189
 
187
190
  var getValidationRules = function getValidationRules() {
188
191
  return validationRules.map(function (_ref3) {
@@ -200,7 +203,7 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
200
203
  var handleInputBlur = function handleInputBlur(event) {
201
204
  var _event$relatedTarget;
202
205
 
203
- fieldInput.onBlur && fieldInput.onBlur(event);
206
+ input.onBlur && input.onBlur(event);
204
207
 
205
208
  if (!event.relatedTarget || !((_event$relatedTarget = event.relatedTarget) !== null && _event$relatedTarget !== void 0 && _event$relatedTarget.closest('.form-field__suggestion-list'))) {
206
209
  setIsFocused(false);
@@ -209,12 +212,12 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
209
212
  };
210
213
 
211
214
  var handleInputFocus = function handleInputFocus(event) {
212
- fieldInput.onFocus && fieldInput.onFocus(event);
215
+ input.onFocus && input.onFocus(event);
213
216
  setIsFocused(true);
214
217
  };
215
218
 
216
219
  var handleScroll = function handleScroll(event) {
217
- if (inputRef.current.contains(event.target)) return;
220
+ if (inputRef.current && inputRef.current.contains(event.target)) return;
218
221
 
219
222
  if (!event.target.closest('.options-menu') && !event.target.classList.contains('form-field-input')) {
220
223
  setShowValidationRules(false);
@@ -222,7 +225,7 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
222
225
  };
223
226
 
224
227
  var handleSuggestionClick = function handleSuggestionClick(item) {
225
- fieldInput.onChange && fieldInput.onChange(item);
228
+ input.onChange && input.onChange(item);
226
229
  setIsFocused(false);
227
230
  onBlur();
228
231
  };
@@ -239,7 +242,7 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
239
242
  if (!valueToValidate && !required || disabled) return;
240
243
  var validationError = null;
241
244
 
242
- if (!(0, _lodash.isEmpty)(rules)) {
245
+ if (!(0, _lodash.isEmpty)(rules) && !async) {
243
246
  var _checkPatternsValidit = (0, _validation.checkPatternsValidity)(rules, valueToValidate),
244
247
  _checkPatternsValidit2 = _slicedToArray(_checkPatternsValidit, 2),
245
248
  newRules = _checkPatternsValidit2[0],
@@ -298,33 +301,76 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
298
301
  validationError = validator(value, allValues);
299
302
  }
300
303
 
304
+ errorsRef.current = validationError;
301
305
  return validationError;
302
306
  };
303
307
 
308
+ var validateFieldAsync = debounceAsync( /*#__PURE__*/function () {
309
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(value, allValues) {
310
+ var validationError, _yield$checkPatternsV, _yield$checkPatternsV2, newRules, isValidField, invalidRules;
311
+
312
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
313
+ while (1) {
314
+ switch (_context.prev = _context.next) {
315
+ case 0:
316
+ validationError = validateField(value, allValues);
317
+
318
+ if ((0, _lodash.isEmpty)(rules)) {
319
+ _context.next = 10;
320
+ break;
321
+ }
322
+
323
+ _context.next = 4;
324
+ return (0, _validation.checkPatternsValidityAsync)(rules, value);
325
+
326
+ case 4:
327
+ _yield$checkPatternsV = _context.sent;
328
+ _yield$checkPatternsV2 = _slicedToArray(_yield$checkPatternsV, 2);
329
+ newRules = _yield$checkPatternsV2[0];
330
+ isValidField = _yield$checkPatternsV2[1];
331
+ invalidRules = newRules.filter(function (rule) {
332
+ return !rule.isValid;
333
+ });
334
+
335
+ if (!isValidField) {
336
+ validationError = invalidRules.map(function (rule) {
337
+ return {
338
+ name: rule.name,
339
+ label: rule.label
340
+ };
341
+ });
342
+ }
343
+
344
+ case 10:
345
+ errorsRef.current = validationError;
346
+ return _context.abrupt("return", validationError);
347
+
348
+ case 12:
349
+ case "end":
350
+ return _context.stop();
351
+ }
352
+ }
353
+ }, _callee);
354
+ }));
355
+
356
+ return function (_x, _x2) {
357
+ return _ref4.apply(this, arguments);
358
+ };
359
+ }(), 400);
360
+
304
361
  var parseField = function parseField(val) {
305
362
  if (!val) return;
306
363
  return inputProps.type === 'number' ? +val : val;
307
364
  };
308
365
 
309
- var setFieldData = (0, _lodash.debounce)(function (input, meta) {
310
- if (!(0, _lodash.isEqual)(meta, fieldMeta)) {
311
- setFieldMeta(meta);
312
- }
313
-
314
- if (!(0, _lodash.isEqual)(input, fieldInput)) {
315
- setFieldInput(input);
316
- }
317
- }, 50);
318
366
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, {
319
- validate: validateField,
367
+ validate: async ? validateFieldAsync : validateField,
320
368
  name: name,
321
369
  parse: parseField,
322
- children: function children(_ref4) {
323
- var _inputProps$autocompl, _meta$error$label, _meta$error;
370
+ children: function children(_ref5) {
371
+ var _inputProps$autocompl, _errorsRef$current$la, _errorsRef$current;
324
372
 
325
- var input = _ref4.input,
326
- meta = _ref4.meta;
327
- setFieldData(input, meta);
373
+ var input = _ref5.input;
328
374
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
329
375
  ref: ref,
330
376
  className: formFieldClassNames,
@@ -341,8 +387,8 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
341
387
  })]
342
388
  }), link && link.show && typedValue.trim() && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
343
389
  className: "form-field__label-icon",
344
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
345
- template: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextTooltipTemplate.default, {
390
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Tooltip, {
391
+ template: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.TextTooltipTemplate, {
346
392
  text: link.url || typedValue
347
393
  }),
348
394
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
@@ -375,18 +421,18 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
375
421
  }))
376
422
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
377
423
  className: "form-field__icons",
378
- children: [isInvalid && !Array.isArray(meta.error) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
424
+ children: [isInvalid && !Array.isArray(errorsRef.current) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Tooltip, {
379
425
  className: "form-field__warning",
380
- template: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextTooltipTemplate.default, {
381
- text: (_meta$error$label = (_meta$error = meta.error) === null || _meta$error === void 0 ? void 0 : _meta$error.label) !== null && _meta$error$label !== void 0 ? _meta$error$label : invalidText,
426
+ template: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.TextTooltipTemplate, {
427
+ text: (_errorsRef$current$la = (_errorsRef$current = errorsRef.current) === null || _errorsRef$current === void 0 ? void 0 : _errorsRef$current.label) !== null && _errorsRef$current$la !== void 0 ? _errorsRef$current$la : invalidText,
382
428
  warning: true
383
429
  }),
384
430
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_invalid.ReactComponent, {})
385
- }), isInvalid && Array.isArray(meta.error) && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
431
+ }), isInvalid && Array.isArray(errorsRef.current) && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
386
432
  className: "form-field__warning",
387
433
  onClick: toggleValidationRulesMenu,
388
434
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_warning.ReactComponent, {})
389
- }), tip && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tip.default, {
435
+ }), tip && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Tip, {
390
436
  text: tip,
391
437
  className: "form-field__tip"
392
438
  }), inputIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
@@ -394,7 +440,9 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
394
440
  className: iconClass,
395
441
  children: inputIcon
396
442
  })]
397
- }), inputProps.type === 'number' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputNumberButtons.default, _objectSpread({}, _objectSpread(_objectSpread(_objectSpread({}, inputProps), input), {}, {
443
+ }), inputProps.type === 'number' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputNumberButtons.default, _objectSpread({}, _objectSpread(_objectSpread(_objectSpread({}, inputProps), {}, {
444
+ step: +inputProps.step
445
+ }, input), {}, {
398
446
  disabled: disabled
399
447
  })))]
400
448
  }), (suggestionList === null || suggestionList === void 0 ? void 0 : suggestionList.length) > 0 && isFocused && /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", {
@@ -424,6 +472,7 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
424
472
  });
425
473
 
426
474
  FormInput.defaultProps = {
475
+ async: false,
427
476
  className: '',
428
477
  density: 'normal',
429
478
  disabled: false,
@@ -444,7 +493,7 @@ FormInput.defaultProps = {
444
493
  pattern: null,
445
494
  placeholder: '',
446
495
  required: false,
447
- step: 1,
496
+ step: '1',
448
497
  suggestionList: [],
449
498
  tip: '',
450
499
  type: 'text',
@@ -454,6 +503,7 @@ FormInput.defaultProps = {
454
503
  withoutBorder: false
455
504
  };
456
505
  FormInput.propTypes = {
506
+ async: _propTypes.default.bool,
457
507
  className: _propTypes.default.string,
458
508
  density: _propTypes.default.oneOf(['dense', 'normal', 'medium', 'chunky']),
459
509
  disabled: _propTypes.default.bool,
@@ -472,7 +522,7 @@ FormInput.propTypes = {
472
522
  pattern: _propTypes.default.string,
473
523
  placeholder: _propTypes.default.string,
474
524
  required: _propTypes.default.bool,
475
- step: _propTypes.default.number,
525
+ step: _propTypes.default.string,
476
526
  suggestionList: _propTypes.default.arrayOf(_propTypes.default.string),
477
527
  tip: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.element]),
478
528
  type: _propTypes.default.string,
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useDebounce = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ /*
11
+ Copyright 2022 Iguazio Systems Ltd.
12
+ Licensed under the Apache License, Version 2.0 (the "License") with
13
+ an addition restriction as set forth herein. You may not use this
14
+ file except in compliance with the License. You may obtain a copy of
15
+ the License at http://www.apache.org/licenses/LICENSE-2.0.
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
19
+ implied. See the License for the specific language governing
20
+ permissions and limitations under the License.
21
+ In addition, you may not use the software for any purposes that are
22
+ illegal under applicable law, and the grant of the foregoing license
23
+ under the Apache 2.0 license is conditioned upon your compliance with
24
+ such restriction.
25
+ */
26
+ var useDebounce = function useDebounce() {
27
+ return function (validate, time) {
28
+ var timeout = (0, _react.useRef)(null);
29
+ var lastValue = (0, _react.useRef)(null);
30
+ var lastResult = (0, _react.useRef)(null);
31
+ return function (value) {
32
+ return new Promise(function (resolve) {
33
+ if (timeout.current) {
34
+ timeout.current();
35
+ }
36
+
37
+ if (value !== lastValue.current) {
38
+ var timerId = setTimeout(function () {
39
+ lastValue.current = value;
40
+ lastResult.current = validate(value);
41
+ resolve(lastResult.current);
42
+ }, time);
43
+
44
+ timeout.current = function () {
45
+ clearTimeout(timerId);
46
+ resolve(true);
47
+ };
48
+ } else {
49
+ resolve(lastResult.current);
50
+ }
51
+ });
52
+ };
53
+ };
54
+ };
55
+
56
+ exports.useDebounce = useDebounce;
@@ -5,7 +5,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.required = exports.getValidationRules = exports.checkPatternsValidity = void 0;
8
+ exports.required = exports.getValidationRules = exports.checkPatternsValidityAsync = exports.checkPatternsValidity = void 0;
9
9
 
10
10
  var _lodash = _interopRequireWildcard(require("lodash"));
11
11
 
@@ -15,6 +15,24 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
15
15
 
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
 
18
+ 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, $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 generator._invoke = function (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); } }; }(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; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return 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, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), 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 (object) { var 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; }
19
+
20
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
21
+
22
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
23
+
24
+ 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); }
25
+
26
+ 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; }
27
+
28
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
29
+
30
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
31
+
32
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
33
+
34
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
35
+
18
36
  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; }
19
37
 
20
38
  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; }
@@ -90,7 +108,9 @@ exports.required = required;
90
108
  var checkPatternsValidity = function checkPatternsValidity(validationRules) {
91
109
  var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
92
110
  var required = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
93
- var newRules = !required && (0, _lodash.isEmpty)(value) ? validationRules : validationRules.map(function (rule) {
111
+ var newRules = !required && (0, _lodash.isEmpty)(value) ? validationRules : validationRules.filter(function (rule) {
112
+ return !rule.async;
113
+ }).map(function (rule) {
94
114
  return _objectSpread(_objectSpread({}, rule), {}, {
95
115
  isValid: _lodash.default.isFunction(rule.pattern) ? rule.pattern(value) :
96
116
  /* else, it is a RegExp */
@@ -101,6 +121,70 @@ var checkPatternsValidity = function checkPatternsValidity(validationRules) {
101
121
  };
102
122
 
103
123
  exports.checkPatternsValidity = checkPatternsValidity;
124
+
125
+ var checkPatternsValidityAsync = /*#__PURE__*/function () {
126
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(validationRules, value) {
127
+ var _checkPatternsValidit, _checkPatternsValidit2, newRules, asyncRules, allRules;
128
+
129
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
130
+ while (1) {
131
+ switch (_context2.prev = _context2.next) {
132
+ case 0:
133
+ _checkPatternsValidit = checkPatternsValidity(validationRules, value), _checkPatternsValidit2 = _slicedToArray(_checkPatternsValidit, 1), newRules = _checkPatternsValidit2[0];
134
+ _context2.next = 3;
135
+ return Promise.all(validationRules.filter(function (rule) {
136
+ return rule.async;
137
+ }).map( /*#__PURE__*/function () {
138
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(rule) {
139
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
140
+ while (1) {
141
+ switch (_context.prev = _context.next) {
142
+ case 0:
143
+ _context.t0 = _objectSpread;
144
+ _context.t1 = _objectSpread({}, rule);
145
+ _context.t2 = {};
146
+ _context.next = 5;
147
+ return rule.pattern(value);
148
+
149
+ case 5:
150
+ _context.t3 = _context.sent;
151
+ _context.t4 = {
152
+ isValid: _context.t3
153
+ };
154
+ return _context.abrupt("return", (0, _context.t0)(_context.t1, _context.t2, _context.t4));
155
+
156
+ case 8:
157
+ case "end":
158
+ return _context.stop();
159
+ }
160
+ }
161
+ }, _callee);
162
+ }));
163
+
164
+ return function (_x3) {
165
+ return _ref2.apply(this, arguments);
166
+ };
167
+ }()));
168
+
169
+ case 3:
170
+ asyncRules = _context2.sent;
171
+ allRules = newRules.concat(asyncRules);
172
+ return _context2.abrupt("return", [allRules, !hasInvalidRule(allRules)]);
173
+
174
+ case 6:
175
+ case "end":
176
+ return _context2.stop();
177
+ }
178
+ }
179
+ }, _callee2);
180
+ }));
181
+
182
+ return function checkPatternsValidityAsync(_x, _x2) {
183
+ return _ref.apply(this, arguments);
184
+ };
185
+ }();
186
+
187
+ exports.checkPatternsValidityAsync = checkPatternsValidityAsync;
104
188
  var generateRule = {
105
189
  beginWith: function beginWith(chars) {
106
190
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iguazio.dashboard-react-controls",
3
- "version": "0.0.29",
3
+ "version": "0.0.30",
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",