iguazio.dashboard-react-controls 0.0.39 → 1.2.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 +4 -11
- package/dist/components/Button/Button.js +25 -28
- package/dist/components/ConfirmDialog/ConfirmDialog.js +10 -24
- package/dist/components/FormCheckBox/FormCheckBox.js +25 -25
- package/dist/components/FormChipCell/FormChip/FormChip.js +33 -33
- package/dist/components/FormChipCell/FormChipCell.js +66 -109
- package/dist/components/FormChipCell/FormChipCellView.js +19 -37
- package/dist/components/FormChipCell/NewChipForm/NewChipForm.js +58 -90
- package/dist/components/FormChipCell/NewChipInput/NewChipInput.js +24 -22
- package/dist/components/FormChipCell/formChipCell.util.js +0 -1
- package/dist/components/FormCombobox/FormCombobox.js +82 -140
- package/dist/components/FormInput/FormInput.js +110 -175
- package/dist/components/FormInput/InputNumberButtons/InputNumberButtons.js +6 -21
- package/dist/components/FormKeyValueTable/FormKeyValueTable.js +23 -39
- package/dist/components/FormRadio/FormRadio.js +23 -22
- package/dist/components/FormSelect/FormSelect.js +56 -92
- package/dist/components/FormSelect/FormSelect.test.js +19 -35
- package/dist/components/FormTextarea/FormTextarea.js +44 -69
- package/dist/components/Modal/Modal.js +8 -21
- package/dist/components/Modal/Modal.scss +2 -2
- package/dist/components/PopUpDialog/PopUpDialog.js +28 -43
- package/dist/components/RoundedIcon/RoundedIcon.js +7 -18
- package/dist/components/RoundedIcon/roundedIcon.scss +2 -2
- package/dist/components/Tip/Tip.js +25 -40
- package/dist/components/Tip/Tip.test.js +36 -45
- package/dist/components/Tooltip/Tooltip.js +40 -64
- package/dist/components/TooltipTemplate/ProducerTooltipTemplate.js +2 -8
- package/dist/components/TooltipTemplate/TextTooltipTemplate.js +2 -12
- package/dist/components/Wizard/Wizard.js +35 -57
- package/dist/components/Wizard/Wizard.scss +1 -3
- package/dist/components/Wizard/WizardSteps/WizardSteps.js +4 -16
- package/dist/components/Wizard/WizardSteps/WizardSteps.scss +1 -0
- package/dist/components/index.js +0 -18
- package/dist/constants.js +4 -6
- package/dist/elements/FormActionButton/FormActionButton.js +6 -12
- package/dist/elements/FormRowActions/FormRowActions.js +6 -18
- package/dist/elements/HiddenChipsBlock/HiddenChipsBlock.js +37 -55
- package/dist/elements/OptionsMenu/OptionsMenu.js +4 -14
- package/dist/elements/SelectOption/SelectOption.js +6 -18
- package/dist/elements/SelectOption/SelectOption.test.js +19 -12
- package/dist/elements/SelectOption/selectOption.scss +5 -2
- package/dist/elements/ValidationTemplate/ValidationTemplate.js +2 -11
- package/dist/elements/index.js +0 -6
- package/dist/hooks/index.js +0 -1
- package/dist/hooks/useDebounce.js +1 -5
- package/dist/hooks/useDetectOutsideClick.js +4 -8
- package/dist/hooks/useFormTable.hook.js +31 -41
- package/dist/images/archive-icon.svg +3 -0
- package/dist/images/arrow.svg +1 -1
- package/dist/images/close.svg +2 -2
- package/dist/images/collapse.svg +2 -2
- package/dist/images/copy-to-clipboard-icon.svg +3 -0
- package/dist/images/deploy-icon.svg +4 -0
- package/dist/images/edit.svg +1 -1
- package/dist/images/edit_old.svg +3 -0
- package/dist/images/expand.svg +2 -2
- package/dist/images/eye-icon.svg +3 -0
- package/dist/images/link-icon.svg +5 -0
- package/dist/images/monitor-icon.svg +3 -0
- package/dist/images/refresh.svg +1 -1
- package/dist/images/tag-icon.svg +4 -0
- package/dist/images/unarchive-icon.svg +3 -0
- package/dist/images/yaml.svg +2 -3
- package/dist/images/yaml_old.svg +4 -0
- package/dist/index.js +0 -13
- package/dist/scss/borders.scss +1 -1
- package/dist/scss/colors.scss +2 -0
- package/dist/scss/common.scss +7 -3
- package/dist/scss/mixins.scss +6 -19
- package/dist/scss/shadows.scss +3 -3
- package/dist/scss/variables.scss +2 -0
- package/dist/types.js +19 -49
- package/dist/utils/common.util.js +3 -13
- package/dist/utils/form.util.js +20 -24
- package/dist/utils/generateChipsList.util.js +0 -3
- package/dist/utils/getFirstScrollableParent.util.js +0 -5
- package/dist/utils/validation.util.js +72 -94
- package/package.json +104 -104
- package/dist/images/eye.svg +0 -4
|
@@ -1,142 +1,114 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
-
|
|
16
11
|
var _lodash = require("lodash");
|
|
17
|
-
|
|
18
12
|
var _reactFinalForm = require("react-final-form");
|
|
19
|
-
|
|
20
13
|
var _InputNumberButtons = _interopRequireDefault(require("./InputNumberButtons/InputNumberButtons"));
|
|
21
|
-
|
|
22
14
|
var _OptionsMenu = _interopRequireDefault(require("../../elements/OptionsMenu/OptionsMenu"));
|
|
23
|
-
|
|
24
15
|
var _components = require("../../components");
|
|
25
|
-
|
|
26
16
|
var _ValidationTemplate = _interopRequireDefault(require("../../elements/ValidationTemplate/ValidationTemplate"));
|
|
27
|
-
|
|
28
17
|
var _useDebounce = require("../../hooks/useDebounce");
|
|
29
|
-
|
|
30
18
|
var _validation = require("../../utils/validation.util");
|
|
31
|
-
|
|
32
19
|
var _useDetectOutsideClick = require("../../hooks/useDetectOutsideClick");
|
|
33
|
-
|
|
34
20
|
var _types = require("../../types");
|
|
35
|
-
|
|
36
21
|
var _invalid = require("../../images/invalid.svg");
|
|
37
|
-
|
|
38
22
|
var _popout = require("../../images/popout.svg");
|
|
39
|
-
|
|
40
23
|
var _warning = require("../../images/warning.svg");
|
|
41
|
-
|
|
42
24
|
require("./formInput.scss");
|
|
43
|
-
|
|
44
25
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
26
|
+
var _excluded = ["async", "className", "density", "disabled", "focused", "iconClass", "iconClick", "inputIcon", "invalidText", "label", "link", "name", "onBlur", "onChange", "pattern", "required", "suggestionList", "tip", "validationRules", "validator", "withoutBorder"];
|
|
27
|
+
/*
|
|
28
|
+
Copyright 2022 Iguazio Systems Ltd.
|
|
29
|
+
Licensed under the Apache License, Version 2.0 (the "License") with
|
|
30
|
+
an addition restriction as set forth herein. You may not use this
|
|
31
|
+
file except in compliance with the License. You may obtain a copy of
|
|
32
|
+
the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
33
|
+
Unless required by applicable law or agreed to in writing, software
|
|
34
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
35
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
36
|
+
implied. See the License for the specific language governing
|
|
37
|
+
permissions and limitations under the License.
|
|
38
|
+
In addition, you may not use the software for any purposes that are
|
|
39
|
+
illegal under applicable law, and the grant of the foregoing license
|
|
40
|
+
under the Apache 2.0 license is conditioned upon your compliance with
|
|
41
|
+
such restriction.
|
|
42
|
+
*/
|
|
48
43
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
49
|
-
|
|
50
44
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
51
|
-
|
|
52
45
|
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; }
|
|
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
|
-
|
|
46
|
+
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; }
|
|
56
47
|
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
48
|
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
|
-
|
|
60
49
|
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; }
|
|
61
|
-
|
|
62
50
|
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; }
|
|
63
|
-
|
|
64
|
-
function
|
|
65
|
-
|
|
51
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
52
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
53
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
66
54
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
67
|
-
|
|
68
55
|
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."); }
|
|
69
|
-
|
|
70
56
|
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); }
|
|
71
|
-
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
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; }
|
|
75
|
-
|
|
57
|
+
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; }
|
|
58
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
76
59
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
77
|
-
|
|
78
60
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
79
|
-
|
|
80
61
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
81
|
-
|
|
82
62
|
var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
83
63
|
var _ref2;
|
|
84
|
-
|
|
85
64
|
var async = _ref.async,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
65
|
+
className = _ref.className,
|
|
66
|
+
density = _ref.density,
|
|
67
|
+
disabled = _ref.disabled,
|
|
68
|
+
focused = _ref.focused,
|
|
69
|
+
iconClass = _ref.iconClass,
|
|
70
|
+
iconClick = _ref.iconClick,
|
|
71
|
+
inputIcon = _ref.inputIcon,
|
|
72
|
+
invalidText = _ref.invalidText,
|
|
73
|
+
label = _ref.label,
|
|
74
|
+
link = _ref.link,
|
|
75
|
+
name = _ref.name,
|
|
76
|
+
onBlur = _ref.onBlur,
|
|
77
|
+
onChange = _ref.onChange,
|
|
78
|
+
pattern = _ref.pattern,
|
|
79
|
+
required = _ref.required,
|
|
80
|
+
suggestionList = _ref.suggestionList,
|
|
81
|
+
tip = _ref.tip,
|
|
82
|
+
rules = _ref.validationRules,
|
|
83
|
+
validator = _ref.validator,
|
|
84
|
+
withoutBorder = _ref.withoutBorder,
|
|
85
|
+
inputProps = _objectWithoutProperties(_ref, _excluded);
|
|
107
86
|
var _useField = (0, _reactFinalForm.useField)(name),
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
87
|
+
input = _useField.input,
|
|
88
|
+
meta = _useField.meta;
|
|
111
89
|
var _useState = (0, _react.useState)(false),
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
90
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
91
|
+
isInvalid = _useState2[0],
|
|
92
|
+
setIsInvalid = _useState2[1];
|
|
116
93
|
var _useState3 = (0, _react.useState)(false),
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
94
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
95
|
+
isFocused = _useState4[0],
|
|
96
|
+
setIsFocused = _useState4[1];
|
|
121
97
|
var _useState5 = (0, _react.useState)(''),
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
98
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
99
|
+
typedValue = _useState6[0],
|
|
100
|
+
setTypedValue = _useState6[1];
|
|
126
101
|
var _useState7 = (0, _react.useState)(RegExp(pattern)),
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
102
|
+
_useState8 = _slicedToArray(_useState7, 1),
|
|
103
|
+
validationPattern = _useState8[0];
|
|
130
104
|
var _useState9 = (0, _react.useState)(rules),
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
105
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
106
|
+
validationRules = _useState10[0],
|
|
107
|
+
setValidationRules = _useState10[1];
|
|
135
108
|
var _useState11 = (0, _react.useState)(false),
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
109
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
110
|
+
showValidationRules = _useState12[0],
|
|
111
|
+
setShowValidationRules = _useState12[1];
|
|
140
112
|
var wrapperRef = (0, _react.useRef)();
|
|
141
113
|
(_ref2 = ref) !== null && _ref2 !== void 0 ? _ref2 : ref = wrapperRef;
|
|
142
114
|
var inputRef = (0, _react.useRef)();
|
|
@@ -165,7 +137,6 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
165
137
|
if (showValidationRules) {
|
|
166
138
|
window.addEventListener('scroll', handleScroll, true);
|
|
167
139
|
}
|
|
168
|
-
|
|
169
140
|
return function () {
|
|
170
141
|
window.removeEventListener('scroll', handleScroll, true);
|
|
171
142
|
};
|
|
@@ -186,76 +157,62 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
186
157
|
});
|
|
187
158
|
});
|
|
188
159
|
}, [rules]);
|
|
189
|
-
|
|
190
160
|
var getValidationRules = function getValidationRules() {
|
|
191
161
|
return validationRules.map(function (_ref3) {
|
|
192
162
|
var _ref3$isValid = _ref3.isValid,
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
163
|
+
isValid = _ref3$isValid === void 0 ? false : _ref3$isValid,
|
|
164
|
+
label = _ref3.label,
|
|
165
|
+
name = _ref3.name;
|
|
196
166
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ValidationTemplate.default, {
|
|
197
167
|
valid: isValid,
|
|
198
168
|
validationMessage: label
|
|
199
169
|
}, name);
|
|
200
170
|
});
|
|
201
171
|
};
|
|
202
|
-
|
|
203
172
|
var isValueEmptyAndValid = function isValueEmptyAndValid(value) {
|
|
204
173
|
return !value && !required || disabled;
|
|
205
174
|
};
|
|
206
|
-
|
|
207
175
|
var handleInputBlur = function handleInputBlur(event) {
|
|
208
176
|
var _event$relatedTarget;
|
|
209
|
-
|
|
210
177
|
input.onBlur && input.onBlur(event);
|
|
211
|
-
|
|
212
178
|
if (!event.relatedTarget || !((_event$relatedTarget = event.relatedTarget) !== null && _event$relatedTarget !== void 0 && _event$relatedTarget.closest('.form-field__suggestion-list'))) {
|
|
213
179
|
setIsFocused(false);
|
|
214
180
|
onBlur && onBlur(event);
|
|
215
181
|
}
|
|
216
182
|
};
|
|
217
|
-
|
|
218
183
|
var handleInputFocus = function handleInputFocus(event) {
|
|
219
184
|
input.onFocus && input.onFocus(event);
|
|
220
185
|
setIsFocused(true);
|
|
221
186
|
};
|
|
222
|
-
|
|
223
187
|
var handleScroll = function handleScroll(event) {
|
|
224
188
|
if (inputRef.current && inputRef.current.contains(event.target)) return;
|
|
225
|
-
|
|
226
189
|
if (!event.target.closest('.options-menu') && !event.target.classList.contains('form-field-input')) {
|
|
227
190
|
setShowValidationRules(false);
|
|
228
191
|
}
|
|
229
192
|
};
|
|
230
|
-
|
|
231
193
|
var handleSuggestionClick = function handleSuggestionClick(item) {
|
|
232
194
|
input.onChange && input.onChange(item);
|
|
233
195
|
setIsFocused(false);
|
|
234
196
|
onBlur();
|
|
235
197
|
};
|
|
236
|
-
|
|
237
198
|
var toggleValidationRulesMenu = function toggleValidationRulesMenu() {
|
|
238
199
|
inputRef.current.focus();
|
|
239
200
|
setShowValidationRules(function (state) {
|
|
240
201
|
return !state;
|
|
241
202
|
});
|
|
242
203
|
};
|
|
243
|
-
|
|
244
204
|
var validateField = function validateField(value, allValues) {
|
|
245
205
|
var valueToValidate = (0, _lodash.isNil)(value) ? '' : String(value);
|
|
246
206
|
if (isValueEmptyAndValid(valueToValidate)) return;
|
|
247
207
|
var validationError = null;
|
|
248
|
-
|
|
249
208
|
if (!(0, _lodash.isEmpty)(rules) && !async) {
|
|
250
209
|
var _checkPatternsValidit = (0, _validation.checkPatternsValidity)(rules, valueToValidate),
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
210
|
+
_checkPatternsValidit2 = _slicedToArray(_checkPatternsValidit, 2),
|
|
211
|
+
newRules = _checkPatternsValidit2[0],
|
|
212
|
+
isValidField = _checkPatternsValidit2[1];
|
|
255
213
|
var invalidRules = newRules.filter(function (rule) {
|
|
256
214
|
return !rule.isValid;
|
|
257
215
|
});
|
|
258
|
-
|
|
259
216
|
if (!isValidField) {
|
|
260
217
|
validationError = invalidRules.map(function (rule) {
|
|
261
218
|
return {
|
|
@@ -265,7 +222,6 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
265
222
|
});
|
|
266
223
|
}
|
|
267
224
|
}
|
|
268
|
-
|
|
269
225
|
if ((0, _lodash.isEmpty)(validationError)) {
|
|
270
226
|
if (inputProps.type === 'number') {
|
|
271
227
|
if (inputProps.max && +valueToValidate > +inputProps.max) {
|
|
@@ -274,7 +230,6 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
274
230
|
label: "The maximum value should be ".concat(inputProps.max)
|
|
275
231
|
};
|
|
276
232
|
}
|
|
277
|
-
|
|
278
233
|
if (inputProps.min && +valueToValidate < +inputProps.min) {
|
|
279
234
|
validationError = {
|
|
280
235
|
name: 'minValue',
|
|
@@ -282,7 +237,6 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
282
237
|
};
|
|
283
238
|
}
|
|
284
239
|
}
|
|
285
|
-
|
|
286
240
|
if (pattern && !validationPattern.test(valueToValidate)) {
|
|
287
241
|
validationError = {
|
|
288
242
|
name: 'pattern',
|
|
@@ -300,90 +254,71 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
300
254
|
};
|
|
301
255
|
}
|
|
302
256
|
}
|
|
303
|
-
|
|
304
257
|
if (!validationError && validator) {
|
|
305
258
|
validationError = validator(value, allValues);
|
|
306
259
|
}
|
|
307
|
-
|
|
308
260
|
errorsRef.current = validationError;
|
|
309
261
|
return validationError;
|
|
310
262
|
};
|
|
311
|
-
|
|
312
263
|
var validateFieldAsync = debounceAsync( /*#__PURE__*/function () {
|
|
313
264
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(value, allValues) {
|
|
314
265
|
var valueToValidate, validationError, _yield$checkPatternsV, _yield$checkPatternsV2, newRules, isValidField, invalidRules;
|
|
315
|
-
|
|
316
266
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
317
|
-
while (1) {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
267
|
+
while (1) switch (_context.prev = _context.next) {
|
|
268
|
+
case 0:
|
|
269
|
+
valueToValidate = (0, _lodash.isNil)(value) ? '' : String(value);
|
|
270
|
+
if (!isValueEmptyAndValid(valueToValidate)) {
|
|
271
|
+
_context.next = 3;
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
return _context.abrupt("return");
|
|
275
|
+
case 3:
|
|
276
|
+
validationError = validateField(valueToValidate, allValues);
|
|
277
|
+
if ((0, _lodash.isEmpty)(rules)) {
|
|
278
|
+
_context.next = 13;
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
_context.next = 7;
|
|
282
|
+
return (0, _validation.checkPatternsValidityAsync)(rules, valueToValidate);
|
|
283
|
+
case 7:
|
|
284
|
+
_yield$checkPatternsV = _context.sent;
|
|
285
|
+
_yield$checkPatternsV2 = _slicedToArray(_yield$checkPatternsV, 2);
|
|
286
|
+
newRules = _yield$checkPatternsV2[0];
|
|
287
|
+
isValidField = _yield$checkPatternsV2[1];
|
|
288
|
+
invalidRules = newRules.filter(function (rule) {
|
|
289
|
+
return !rule.isValid;
|
|
290
|
+
});
|
|
291
|
+
if (!isValidField) {
|
|
292
|
+
validationError = invalidRules.map(function (rule) {
|
|
293
|
+
return {
|
|
294
|
+
name: rule.name,
|
|
295
|
+
label: rule.label
|
|
296
|
+
};
|
|
347
297
|
});
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
case 13:
|
|
359
|
-
errorsRef.current = validationError;
|
|
360
|
-
return _context.abrupt("return", validationError);
|
|
361
|
-
|
|
362
|
-
case 15:
|
|
363
|
-
case "end":
|
|
364
|
-
return _context.stop();
|
|
365
|
-
}
|
|
298
|
+
}
|
|
299
|
+
case 13:
|
|
300
|
+
errorsRef.current = validationError;
|
|
301
|
+
return _context.abrupt("return", validationError);
|
|
302
|
+
case 15:
|
|
303
|
+
case "end":
|
|
304
|
+
return _context.stop();
|
|
366
305
|
}
|
|
367
306
|
}, _callee);
|
|
368
307
|
}));
|
|
369
|
-
|
|
370
|
-
return function (_x, _x2) {
|
|
308
|
+
return function (_x2, _x3) {
|
|
371
309
|
return _ref4.apply(this, arguments);
|
|
372
310
|
};
|
|
373
311
|
}(), 400);
|
|
374
|
-
|
|
375
312
|
var parseField = function parseField(val) {
|
|
376
313
|
if (!val) return;
|
|
377
314
|
return inputProps.type === 'number' ? +val : val;
|
|
378
315
|
};
|
|
379
|
-
|
|
380
316
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, {
|
|
381
317
|
validate: async ? validateFieldAsync : validateField,
|
|
382
318
|
name: name,
|
|
383
319
|
parse: parseField,
|
|
384
320
|
children: function children(_ref5) {
|
|
385
321
|
var _inputProps$autocompl, _errorsRef$current$la, _errorsRef$current;
|
|
386
|
-
|
|
387
322
|
var input = _ref5.input;
|
|
388
323
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
389
324
|
ref: ref,
|
|
@@ -452,6 +387,7 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
452
387
|
}), inputIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
453
388
|
"data-testid": "input-icon",
|
|
454
389
|
className: iconClass,
|
|
390
|
+
onClick: iconClick,
|
|
455
391
|
children: inputIcon
|
|
456
392
|
})]
|
|
457
393
|
}), inputProps.type === 'number' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputNumberButtons.default, _objectSpread({}, _objectSpread(_objectSpread(_objectSpread({}, inputProps), {}, {
|
|
@@ -484,7 +420,6 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
484
420
|
}
|
|
485
421
|
});
|
|
486
422
|
});
|
|
487
|
-
|
|
488
423
|
FormInput.defaultProps = {
|
|
489
424
|
async: false,
|
|
490
425
|
className: '',
|
|
@@ -492,6 +427,7 @@ FormInput.defaultProps = {
|
|
|
492
427
|
disabled: false,
|
|
493
428
|
focused: false,
|
|
494
429
|
iconClass: '',
|
|
430
|
+
iconClick: function iconClick() {},
|
|
495
431
|
inputIcon: null,
|
|
496
432
|
invalidText: 'This field is invalid',
|
|
497
433
|
label: '',
|
|
@@ -523,6 +459,7 @@ FormInput.propTypes = {
|
|
|
523
459
|
disabled: _propTypes.default.bool,
|
|
524
460
|
focused: _propTypes.default.bool,
|
|
525
461
|
iconClass: _propTypes.default.string,
|
|
462
|
+
iconClick: _propTypes.default.func,
|
|
526
463
|
inputIcon: _propTypes.default.element,
|
|
527
464
|
invalidText: _propTypes.default.string,
|
|
528
465
|
label: _propTypes.default.string,
|
|
@@ -545,7 +482,5 @@ FormInput.propTypes = {
|
|
|
545
482
|
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
546
483
|
withoutBorder: _propTypes.default.bool
|
|
547
484
|
};
|
|
548
|
-
|
|
549
485
|
var _default = /*#__PURE__*/_react.default.memo(FormInput);
|
|
550
|
-
|
|
551
486
|
exports.default = _default;
|
|
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _lodash = require("lodash");
|
|
13
|
-
|
|
14
10
|
var _rangeArrowSmall = require("../../../images/range-arrow-small.svg");
|
|
15
|
-
|
|
16
11
|
require("./InputNumberButtons.scss");
|
|
17
|
-
|
|
18
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
-
|
|
20
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
14
|
/*
|
|
23
15
|
Copyright 2022 Iguazio Systems Ltd.
|
|
24
16
|
Licensed under the Apache License, Version 2.0 (the "License") with
|
|
@@ -35,14 +27,14 @@ illegal under applicable law, and the grant of the foregoing license
|
|
|
35
27
|
under the Apache 2.0 license is conditioned upon your compliance with
|
|
36
28
|
such restriction.
|
|
37
29
|
*/
|
|
30
|
+
|
|
38
31
|
var InputNumberButtons = function InputNumberButtons(_ref) {
|
|
39
32
|
var disabled = _ref.disabled,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
33
|
+
min = _ref.min,
|
|
34
|
+
max = _ref.max,
|
|
35
|
+
onChange = _ref.onChange,
|
|
36
|
+
step = _ref.step,
|
|
37
|
+
value = _ref.value;
|
|
46
38
|
var handleIncrease = function handleIncrease(event) {
|
|
47
39
|
event.preventDefault();
|
|
48
40
|
if (max && +value >= +max) return;
|
|
@@ -50,7 +42,6 @@ var InputNumberButtons = function InputNumberButtons(_ref) {
|
|
|
50
42
|
var nextValue = isInteger(currentValue) ? currentValue : currentValue.toFixed(3);
|
|
51
43
|
onChange(nextValue);
|
|
52
44
|
};
|
|
53
|
-
|
|
54
45
|
var handleDecrease = function handleDecrease(event) {
|
|
55
46
|
event.preventDefault();
|
|
56
47
|
if (value <= 0 || +value <= +min) return;
|
|
@@ -58,15 +49,12 @@ var InputNumberButtons = function InputNumberButtons(_ref) {
|
|
|
58
49
|
var nextValue = isInteger(currentValue) ? currentValue : currentValue.toFixed(3);
|
|
59
50
|
onChange(nextValue);
|
|
60
51
|
};
|
|
61
|
-
|
|
62
52
|
var isCurrentValueEmpty = function isCurrentValueEmpty() {
|
|
63
53
|
return (0, _lodash.isNil)(value) || value === '';
|
|
64
54
|
};
|
|
65
|
-
|
|
66
55
|
var isInteger = function isInteger(number) {
|
|
67
56
|
return Number(number) === number && number % 1 === 0;
|
|
68
57
|
};
|
|
69
|
-
|
|
70
58
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
71
59
|
"data-testid": "range-input-container",
|
|
72
60
|
className: "form-field-range",
|
|
@@ -92,7 +80,6 @@ var InputNumberButtons = function InputNumberButtons(_ref) {
|
|
|
92
80
|
})
|
|
93
81
|
});
|
|
94
82
|
};
|
|
95
|
-
|
|
96
83
|
InputNumberButtons.defaultProps = {
|
|
97
84
|
disabled: false,
|
|
98
85
|
min: null,
|
|
@@ -107,7 +94,5 @@ InputNumberButtons.propTypes = {
|
|
|
107
94
|
step: _propTypes.default.number,
|
|
108
95
|
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]).isRequired
|
|
109
96
|
};
|
|
110
|
-
|
|
111
97
|
var _default = /*#__PURE__*/_react.default.memo(InputNumberButtons);
|
|
112
|
-
|
|
113
98
|
exports.default = _default;
|