iguazio.dashboard-react-controls 1.9.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Backdrop/Backdrop.js +7 -7
- package/dist/components/Button/Button.js +20 -26
- package/dist/components/ConfirmDialog/ConfirmDialog.js +18 -17
- package/dist/components/FormCheckBox/FormCheckBox.js +28 -32
- package/dist/components/FormChipCell/FormChip/FormChip.js +46 -50
- package/dist/components/FormChipCell/FormChipCell.js +122 -142
- package/dist/components/FormChipCell/FormChipCellView.js +44 -47
- package/dist/components/FormChipCell/HiddenChipsBlock/HiddenChipsBlock.js +23 -20
- package/dist/components/FormChipCell/NewChipForm/NewChipForm.js +129 -152
- package/dist/components/FormChipCell/NewChipInput/NewChipInput.js +24 -27
- package/dist/components/FormChipCell/formChipCell.util.js +6 -16
- package/dist/components/FormCombobox/FormCombobox.js +134 -195
- package/dist/components/FormInput/FormInput.js +134 -212
- package/dist/components/FormInput/InputNumberButtons/InputNumberButtons.js +15 -14
- package/dist/components/FormKeyValueTable/FormKeyValueTable.js +72 -72
- package/dist/components/FormRadio/FormRadio.js +21 -25
- package/dist/components/FormSelect/FormSelect.js +98 -126
- package/dist/components/FormSelect/FormSelect.test.js +56 -60
- package/dist/components/FormTextarea/FormTextarea.js +55 -71
- package/dist/components/FormToggle/FormToggle.js +25 -29
- package/dist/components/Modal/Modal.js +17 -18
- package/dist/components/PopUpDialog/PopUpDialog.js +53 -63
- package/dist/components/RoundedIcon/RoundedIcon.js +14 -13
- package/dist/components/Tip/Tip.js +58 -64
- package/dist/components/Tip/Tip.test.js +41 -64
- package/dist/components/Tooltip/Tooltip.js +75 -89
- package/dist/components/TooltipTemplate/ProducerTooltipTemplate.js +6 -5
- package/dist/components/TooltipTemplate/TextTooltipTemplate.js +10 -10
- package/dist/components/Wizard/Wizard.js +73 -107
- package/dist/components/Wizard/WizardSteps/WizardSteps.js +19 -20
- package/dist/components/index.js +18 -18
- package/dist/constants.js +26 -44
- package/dist/elements/FormActionButton/FormActionButton.js +12 -13
- package/dist/elements/FormRowActions/FormRowActions.js +19 -22
- package/dist/elements/OptionsMenu/OptionsMenu.js +10 -8
- package/dist/elements/SelectOption/SelectOption.js +14 -13
- package/dist/elements/SelectOption/SelectOption.test.js +39 -47
- package/dist/elements/ValidationTemplate/ValidationTemplate.js +7 -6
- package/dist/elements/index.js +5 -5
- package/dist/hooks/index.js +5 -5
- package/dist/hooks/useChipCell.hook.js +66 -85
- package/dist/hooks/useDebounce.hook.js +22 -24
- package/dist/hooks/useDetectOutsideClick.hook.js +4 -4
- package/dist/hooks/useFormTable.hook.js +99 -112
- package/dist/hooks/useHiddenChipsBlock.hook.js +40 -55
- package/dist/index.js +2 -3
- package/dist/scss/borders.scss +6 -0
- package/dist/scss/mixins.scss +32 -0
- package/dist/types.js +43 -67
- package/dist/utils/common.util.js +19 -23
- package/dist/utils/form.util.js +33 -39
- package/dist/utils/generateChipsList.util.js +7 -7
- package/dist/utils/getFirstScrollableParent.util.js +4 -10
- package/dist/utils/math.util.js +3 -3
- package/dist/utils/validation.util.js +74 -131
- package/package.json +34 -34
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
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
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -23,7 +22,9 @@ var _popout = require("../../images/popout.svg");
|
|
|
23
22
|
var _warning = require("../../images/warning.svg");
|
|
24
23
|
require("./formInput.scss");
|
|
25
24
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
|
-
|
|
25
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
27
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
27
28
|
/*
|
|
28
29
|
Copyright 2022 Iguazio Systems Ltd.
|
|
29
30
|
Licensed under the Apache License, Version 2.0 (the "License") with
|
|
@@ -40,147 +41,113 @@ illegal under applicable law, and the grant of the foregoing license
|
|
|
40
41
|
under the Apache 2.0 license is conditioned upon your compliance with
|
|
41
42
|
such restriction.
|
|
42
43
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
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; }
|
|
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; }
|
|
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); } }
|
|
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); }); }; }
|
|
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; }
|
|
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; }
|
|
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); }
|
|
54
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
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."); }
|
|
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); }
|
|
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; } }
|
|
59
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
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; }
|
|
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; }
|
|
62
|
-
var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
44
|
+
|
|
45
|
+
const FormInput = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
63
46
|
var _ref2;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
typedValue = _useState6[0],
|
|
103
|
-
setTypedValue = _useState6[1];
|
|
104
|
-
var _useState7 = (0, _react.useState)(RegExp(pattern)),
|
|
105
|
-
_useState8 = _slicedToArray(_useState7, 1),
|
|
106
|
-
validationPattern = _useState8[0];
|
|
107
|
-
var _useState9 = (0, _react.useState)(rules),
|
|
108
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
109
|
-
validationRules = _useState10[0],
|
|
110
|
-
setValidationRules = _useState10[1];
|
|
111
|
-
var _useState11 = (0, _react.useState)(false),
|
|
112
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
113
|
-
showValidationRules = _useState12[0],
|
|
114
|
-
setShowValidationRules = _useState12[1];
|
|
115
|
-
var wrapperRef = (0, _react.useRef)();
|
|
47
|
+
let {
|
|
48
|
+
async,
|
|
49
|
+
className,
|
|
50
|
+
customRequiredLabel,
|
|
51
|
+
density,
|
|
52
|
+
disabled,
|
|
53
|
+
focused,
|
|
54
|
+
iconClass,
|
|
55
|
+
iconClick,
|
|
56
|
+
inputIcon,
|
|
57
|
+
invalidText,
|
|
58
|
+
label,
|
|
59
|
+
link,
|
|
60
|
+
name,
|
|
61
|
+
onBlur,
|
|
62
|
+
onChange,
|
|
63
|
+
onFocus,
|
|
64
|
+
onKeyDown,
|
|
65
|
+
pattern,
|
|
66
|
+
required,
|
|
67
|
+
suggestionList,
|
|
68
|
+
tip,
|
|
69
|
+
validationRules: rules,
|
|
70
|
+
validator,
|
|
71
|
+
withoutBorder,
|
|
72
|
+
...inputProps
|
|
73
|
+
} = _ref;
|
|
74
|
+
const {
|
|
75
|
+
input,
|
|
76
|
+
meta
|
|
77
|
+
} = (0, _reactFinalForm.useField)(name);
|
|
78
|
+
const [isInvalid, setIsInvalid] = (0, _react.useState)(false);
|
|
79
|
+
const [isFocused, setIsFocused] = (0, _react.useState)(false);
|
|
80
|
+
const [typedValue, setTypedValue] = (0, _react.useState)('');
|
|
81
|
+
const [validationPattern] = (0, _react.useState)(RegExp(pattern));
|
|
82
|
+
const [validationRules, setValidationRules] = (0, _react.useState)(rules);
|
|
83
|
+
const [showValidationRules, setShowValidationRules] = (0, _react.useState)(false);
|
|
84
|
+
const wrapperRef = (0, _react.useRef)();
|
|
116
85
|
(_ref2 = ref) !== null && _ref2 !== void 0 ? _ref2 : ref = wrapperRef;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
(0, _hooks.useDetectOutsideClick)(ref,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
var labelClassNames = (0, _classnames.default)('form-field__label', disabled && 'form-field__label-disabled');
|
|
127
|
-
(0, _react.useEffect)(function () {
|
|
86
|
+
const inputRef = (0, _react.useRef)();
|
|
87
|
+
const errorsRef = (0, _react.useRef)();
|
|
88
|
+
const isRequiredRulePresentRef = (0, _react.useRef)(false);
|
|
89
|
+
(0, _hooks.useDetectOutsideClick)(ref, () => setShowValidationRules(false));
|
|
90
|
+
const debounceAsync = (0, _hooks.useDebounce)();
|
|
91
|
+
const formFieldClassNames = (0, _classnames.default)('form-field-input', className);
|
|
92
|
+
const 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');
|
|
93
|
+
const labelClassNames = (0, _classnames.default)('form-field__label', disabled && 'form-field__label-disabled');
|
|
94
|
+
(0, _react.useEffect)(() => {
|
|
128
95
|
setTypedValue(String(input.value)); // convert from number to string
|
|
129
96
|
}, [input.value]);
|
|
130
|
-
(0, _react.useEffect)(
|
|
97
|
+
(0, _react.useEffect)(() => {
|
|
131
98
|
setIsInvalid(errorsRef.current && meta.invalid && (meta.validating || meta.modified || meta.submitFailed && meta.touched));
|
|
132
99
|
}, [meta.invalid, meta.modified, meta.submitFailed, meta.touched, meta.validating]);
|
|
133
|
-
(0, _react.useEffect)(
|
|
100
|
+
(0, _react.useEffect)(() => {
|
|
134
101
|
if (!errorsRef.current) {
|
|
135
102
|
if (meta.valid && showValidationRules) {
|
|
136
103
|
setShowValidationRules(false);
|
|
137
104
|
}
|
|
138
105
|
}
|
|
139
106
|
}, [errorsRef.current, meta.valid, showValidationRules]);
|
|
140
|
-
(0, _react.useEffect)(
|
|
107
|
+
(0, _react.useEffect)(() => {
|
|
141
108
|
if (showValidationRules) {
|
|
142
109
|
window.addEventListener('scroll', handleScroll, true);
|
|
143
110
|
}
|
|
144
|
-
return
|
|
111
|
+
return () => {
|
|
145
112
|
window.removeEventListener('scroll', handleScroll, true);
|
|
146
113
|
};
|
|
147
114
|
}, [showValidationRules]);
|
|
148
|
-
(0, _react.useEffect)(
|
|
115
|
+
(0, _react.useEffect)(() => {
|
|
149
116
|
if (focused) {
|
|
150
117
|
inputRef.current.focus();
|
|
151
118
|
}
|
|
152
119
|
}, [focused]);
|
|
153
|
-
(0, _react.useEffect)(
|
|
154
|
-
setValidationRules(
|
|
120
|
+
(0, _react.useEffect)(() => {
|
|
121
|
+
setValidationRules(() => {
|
|
155
122
|
isRequiredRulePresentRef.current = false;
|
|
156
|
-
return rules.map(
|
|
123
|
+
return rules.map(rule => {
|
|
157
124
|
if (rule.name === _constants.validation.REQUIRED.NAME) {
|
|
158
125
|
isRequiredRulePresentRef.current = true;
|
|
159
126
|
}
|
|
160
|
-
return
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
});
|
|
127
|
+
return {
|
|
128
|
+
...rule,
|
|
129
|
+
isValid: !errorsRef.current || !Array.isArray(errorsRef.current) ? true : !errorsRef.current.some(err => err.name === rule.name)
|
|
130
|
+
};
|
|
165
131
|
});
|
|
166
132
|
});
|
|
167
133
|
}, [rules]);
|
|
168
|
-
|
|
169
|
-
return validationRules.map(
|
|
170
|
-
|
|
171
|
-
isValid =
|
|
172
|
-
label
|
|
173
|
-
name
|
|
134
|
+
const getValidationRules = () => {
|
|
135
|
+
return validationRules.map(_ref3 => {
|
|
136
|
+
let {
|
|
137
|
+
isValid = false,
|
|
138
|
+
label,
|
|
139
|
+
name
|
|
140
|
+
} = _ref3;
|
|
174
141
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ValidationTemplate.default, {
|
|
175
142
|
valid: isValid,
|
|
176
143
|
validationMessage: label
|
|
177
144
|
}, name);
|
|
178
145
|
});
|
|
179
146
|
};
|
|
180
|
-
|
|
147
|
+
const isValueEmptyAndValid = value => {
|
|
181
148
|
return !value && !required || disabled;
|
|
182
149
|
};
|
|
183
|
-
|
|
150
|
+
const handleInputBlur = event => {
|
|
184
151
|
var _event$relatedTarget;
|
|
185
152
|
input.onBlur && input.onBlur(event);
|
|
186
153
|
if (!event.relatedTarget || !((_event$relatedTarget = event.relatedTarget) !== null && _event$relatedTarget !== void 0 && _event$relatedTarget.closest('.form-field__suggestion-list'))) {
|
|
@@ -188,56 +155,47 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
188
155
|
onBlur && onBlur(event);
|
|
189
156
|
}
|
|
190
157
|
};
|
|
191
|
-
|
|
158
|
+
const handleInputFocus = event => {
|
|
192
159
|
input.onFocus && input.onFocus(event);
|
|
193
160
|
onFocus && onFocus(event);
|
|
194
161
|
setIsFocused(true);
|
|
195
162
|
};
|
|
196
|
-
|
|
163
|
+
const handleInputKeyDown = event => {
|
|
197
164
|
input.onKeyDown && input.onKeyDown(event);
|
|
198
165
|
onKeyDown && onKeyDown(event);
|
|
199
166
|
};
|
|
200
|
-
|
|
167
|
+
const handleScroll = event => {
|
|
201
168
|
if (inputRef.current && inputRef.current.contains(event.target)) return;
|
|
202
169
|
if (!event.target.closest('.options-menu') && !event.target.classList.contains('form-field-input')) {
|
|
203
170
|
setShowValidationRules(false);
|
|
204
171
|
}
|
|
205
172
|
};
|
|
206
|
-
|
|
173
|
+
const handleSuggestionClick = item => {
|
|
207
174
|
input.onChange && input.onChange(item);
|
|
208
175
|
setIsFocused(false);
|
|
209
176
|
onBlur();
|
|
210
177
|
};
|
|
211
|
-
|
|
178
|
+
const toggleValidationRulesMenu = () => {
|
|
212
179
|
inputRef.current.focus();
|
|
213
|
-
setShowValidationRules(
|
|
214
|
-
return !state;
|
|
215
|
-
});
|
|
180
|
+
setShowValidationRules(state => !state);
|
|
216
181
|
};
|
|
217
|
-
|
|
218
|
-
|
|
182
|
+
const validateField = (value, allValues) => {
|
|
183
|
+
let valueToValidate = (0, _lodash.isNil)(value) ? '' : String(value);
|
|
219
184
|
if (isValueEmptyAndValid(valueToValidate)) return;
|
|
220
|
-
|
|
185
|
+
let validationError = null;
|
|
221
186
|
if (required && valueToValidate.trim().length === 0 && !isRequiredRulePresentRef.current) {
|
|
222
187
|
validationError = {
|
|
223
188
|
name: 'required',
|
|
224
189
|
label: customRequiredLabel || 'This field is required'
|
|
225
190
|
};
|
|
226
191
|
} else if (!(0, _lodash.isEmpty)(rules) && !async) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
newRules = _checkPatternsValidit2[0],
|
|
230
|
-
isValidField = _checkPatternsValidit2[1];
|
|
231
|
-
var invalidRules = newRules.filter(function (rule) {
|
|
232
|
-
return !rule.isValid;
|
|
233
|
-
});
|
|
192
|
+
const [newRules, isValidField] = (0, _validation.checkPatternsValidity)(rules, valueToValidate);
|
|
193
|
+
const invalidRules = newRules.filter(rule => !rule.isValid);
|
|
234
194
|
if (!isValidField) {
|
|
235
|
-
validationError = invalidRules.map(
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
};
|
|
240
|
-
});
|
|
195
|
+
validationError = invalidRules.map(rule => ({
|
|
196
|
+
name: rule.name,
|
|
197
|
+
label: rule.label
|
|
198
|
+
}));
|
|
241
199
|
}
|
|
242
200
|
}
|
|
243
201
|
if ((0, _lodash.isEmpty)(validationError)) {
|
|
@@ -273,65 +231,35 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
273
231
|
errorsRef.current = validationError;
|
|
274
232
|
return validationError;
|
|
275
233
|
};
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
_context.next = 7;
|
|
295
|
-
return (0, _validation.checkPatternsValidityAsync)(rules, valueToValidate);
|
|
296
|
-
case 7:
|
|
297
|
-
_yield$checkPatternsV = _context.sent;
|
|
298
|
-
_yield$checkPatternsV2 = _slicedToArray(_yield$checkPatternsV, 2);
|
|
299
|
-
newRules = _yield$checkPatternsV2[0];
|
|
300
|
-
isValidField = _yield$checkPatternsV2[1];
|
|
301
|
-
invalidRules = newRules.filter(function (rule) {
|
|
302
|
-
return !rule.isValid;
|
|
303
|
-
});
|
|
304
|
-
if (!isValidField) {
|
|
305
|
-
validationError = invalidRules.map(function (rule) {
|
|
306
|
-
return {
|
|
307
|
-
name: rule.name,
|
|
308
|
-
label: rule.label
|
|
309
|
-
};
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
case 13:
|
|
313
|
-
errorsRef.current = validationError;
|
|
314
|
-
return _context.abrupt("return", validationError);
|
|
315
|
-
case 15:
|
|
316
|
-
case "end":
|
|
317
|
-
return _context.stop();
|
|
318
|
-
}
|
|
319
|
-
}, _callee);
|
|
320
|
-
}));
|
|
321
|
-
return function (_x2, _x3) {
|
|
322
|
-
return _ref4.apply(this, arguments);
|
|
323
|
-
};
|
|
324
|
-
}(), 400);
|
|
325
|
-
var parseField = function parseField(val) {
|
|
234
|
+
const validateFieldAsync = debounceAsync(async (value, allValues) => {
|
|
235
|
+
let valueToValidate = (0, _lodash.isNil)(value) ? '' : String(value);
|
|
236
|
+
if (isValueEmptyAndValid(valueToValidate)) return;
|
|
237
|
+
let validationError = validateField(valueToValidate, allValues);
|
|
238
|
+
if (!(0, _lodash.isEmpty)(rules)) {
|
|
239
|
+
const [newRules, isValidField] = await (0, _validation.checkPatternsValidityAsync)(rules, valueToValidate);
|
|
240
|
+
const invalidRules = newRules.filter(rule => !rule.isValid);
|
|
241
|
+
if (!isValidField) {
|
|
242
|
+
validationError = invalidRules.map(rule => ({
|
|
243
|
+
name: rule.name,
|
|
244
|
+
label: rule.label
|
|
245
|
+
}));
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
errorsRef.current = validationError;
|
|
249
|
+
return validationError;
|
|
250
|
+
}, 400);
|
|
251
|
+
const parseField = val => {
|
|
326
252
|
return inputProps.type === 'number' && val ? parseFloat(val) || val : val;
|
|
327
253
|
};
|
|
328
254
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, {
|
|
329
255
|
validate: async ? validateFieldAsync : validateField,
|
|
330
256
|
name: name,
|
|
331
257
|
parse: parseField,
|
|
332
|
-
children:
|
|
258
|
+
children: _ref4 => {
|
|
333
259
|
var _inputProps$autocompl, _errorsRef$current$la, _errorsRef$current;
|
|
334
|
-
|
|
260
|
+
let {
|
|
261
|
+
input
|
|
262
|
+
} = _ref4;
|
|
335
263
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
336
264
|
ref: ref,
|
|
337
265
|
className: formFieldClassNames,
|
|
@@ -341,9 +269,7 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
341
269
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
|
|
342
270
|
"data-testid": name ? "".concat(name, "-form-label") : 'form-label',
|
|
343
271
|
htmlFor: input.name,
|
|
344
|
-
children: [label, (required || validationRules.find(
|
|
345
|
-
return rule.name === 'required';
|
|
346
|
-
})) && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
272
|
+
children: [label, (required || validationRules.find(rule => rule.name === 'required')) && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
347
273
|
className: "form-field__label-mandatory",
|
|
348
274
|
children: " *"
|
|
349
275
|
})]
|
|
@@ -355,9 +281,7 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
355
281
|
}),
|
|
356
282
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
|
|
357
283
|
href: link.url || typedValue,
|
|
358
|
-
onClick:
|
|
359
|
-
return event.stopPropagation();
|
|
360
|
-
},
|
|
284
|
+
onClick: event => event.stopPropagation(),
|
|
361
285
|
target: "_blank",
|
|
362
286
|
rel: "noreferrer",
|
|
363
287
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_popout.ReactComponent, {})
|
|
@@ -368,20 +292,20 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
368
292
|
className: inputWrapperClassNames,
|
|
369
293
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
370
294
|
className: "form-field__control",
|
|
371
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("input",
|
|
295
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
372
296
|
"data-testid": name ? "".concat(name, "-form-input") : 'form-input',
|
|
373
297
|
id: input.name,
|
|
374
298
|
ref: inputRef,
|
|
375
|
-
required: isInvalid || required
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
299
|
+
required: isInvalid || required,
|
|
300
|
+
disabled,
|
|
301
|
+
pattern,
|
|
302
|
+
...inputProps,
|
|
303
|
+
...input,
|
|
380
304
|
autoComplete: (_inputProps$autocompl = inputProps.autocomplete) !== null && _inputProps$autocompl !== void 0 ? _inputProps$autocompl : 'off',
|
|
381
305
|
onBlur: handleInputBlur,
|
|
382
306
|
onKeyDown: handleInputKeyDown,
|
|
383
307
|
onFocus: handleInputFocus
|
|
384
|
-
})
|
|
308
|
+
})
|
|
385
309
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
386
310
|
className: "form-field__icons",
|
|
387
311
|
children: [isInvalid && !Array.isArray(errorsRef.current) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Tooltip, {
|
|
@@ -404,24 +328,23 @@ var FormInput = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
404
328
|
onClick: iconClick,
|
|
405
329
|
children: inputIcon
|
|
406
330
|
})]
|
|
407
|
-
}), inputProps.type === 'number' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputNumberButtons.default,
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
331
|
+
}), inputProps.type === 'number' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputNumberButtons.default, {
|
|
332
|
+
...inputProps,
|
|
333
|
+
step: +inputProps.step,
|
|
334
|
+
...input,
|
|
335
|
+
disabled
|
|
336
|
+
})]
|
|
412
337
|
}), (suggestionList === null || suggestionList === void 0 ? void 0 : suggestionList.length) > 0 && isFocused && /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", {
|
|
413
338
|
className: "form-field__suggestion-list",
|
|
414
|
-
children: suggestionList.map(
|
|
339
|
+
children: suggestionList.map((item, index) => {
|
|
415
340
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
416
341
|
className: "suggestion-item",
|
|
417
|
-
onClick:
|
|
342
|
+
onClick: () => {
|
|
418
343
|
handleSuggestionClick(item);
|
|
419
344
|
},
|
|
420
345
|
tabIndex: index,
|
|
421
346
|
dangerouslySetInnerHTML: {
|
|
422
|
-
__html: item.replace(new RegExp(typedValue, 'gi'),
|
|
423
|
-
return match ? "<b>".concat(match, "</b>") : match;
|
|
424
|
-
})
|
|
347
|
+
__html: item.replace(new RegExp(typedValue, 'gi'), match => match ? "<b>".concat(match, "</b>") : match)
|
|
425
348
|
}
|
|
426
349
|
}, "".concat(item).concat(index));
|
|
427
350
|
})
|
|
@@ -442,7 +365,7 @@ FormInput.defaultProps = {
|
|
|
442
365
|
disabled: false,
|
|
443
366
|
focused: false,
|
|
444
367
|
iconClass: '',
|
|
445
|
-
iconClick:
|
|
368
|
+
iconClick: () => {},
|
|
446
369
|
inputIcon: null,
|
|
447
370
|
invalidText: 'This field is invalid',
|
|
448
371
|
label: '',
|
|
@@ -452,9 +375,9 @@ FormInput.defaultProps = {
|
|
|
452
375
|
},
|
|
453
376
|
min: null,
|
|
454
377
|
max: null,
|
|
455
|
-
onBlur:
|
|
456
|
-
onChange:
|
|
457
|
-
onKeyDown:
|
|
378
|
+
onBlur: () => {},
|
|
379
|
+
onChange: () => {},
|
|
380
|
+
onKeyDown: () => {},
|
|
458
381
|
pattern: null,
|
|
459
382
|
placeholder: '',
|
|
460
383
|
required: false,
|
|
@@ -463,7 +386,7 @@ FormInput.defaultProps = {
|
|
|
463
386
|
tip: '',
|
|
464
387
|
type: 'text',
|
|
465
388
|
validationRules: [],
|
|
466
|
-
validator:
|
|
389
|
+
validator: () => {},
|
|
467
390
|
value: '',
|
|
468
391
|
withoutBorder: false
|
|
469
392
|
};
|
|
@@ -499,5 +422,4 @@ FormInput.propTypes = {
|
|
|
499
422
|
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
500
423
|
withoutBorder: _propTypes.default.bool
|
|
501
424
|
};
|
|
502
|
-
var _default = /*#__PURE__*/_react.default.memo(FormInput);
|
|
503
|
-
exports.default = _default;
|
|
425
|
+
var _default = exports.default = /*#__PURE__*/_react.default.memo(FormInput);
|
|
@@ -29,28 +29,30 @@ under the Apache 2.0 license is conditioned upon your compliance with
|
|
|
29
29
|
such restriction.
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
const InputNumberButtons = _ref => {
|
|
33
|
+
let {
|
|
34
|
+
disabled,
|
|
35
|
+
min,
|
|
36
|
+
max,
|
|
37
|
+
onChange,
|
|
38
|
+
step,
|
|
39
|
+
value
|
|
40
|
+
} = _ref;
|
|
41
|
+
const handleIncrease = event => {
|
|
40
42
|
event.preventDefault();
|
|
41
43
|
if (max && value >= max) return;
|
|
42
|
-
|
|
44
|
+
let newValue = isCurrentValueEmpty() ? step : (0, _math.performFloatOperation)(value, step, '+');
|
|
43
45
|
newValue = max && newValue > max ? max : newValue;
|
|
44
46
|
onChange(newValue);
|
|
45
47
|
};
|
|
46
|
-
|
|
48
|
+
const handleDecrease = event => {
|
|
47
49
|
event.preventDefault();
|
|
48
50
|
if (min && value <= min) return;
|
|
49
|
-
|
|
51
|
+
let newValue = isCurrentValueEmpty() ? -step : (0, _math.performFloatOperation)(value, step, '-');
|
|
50
52
|
newValue = min && newValue < min ? min : newValue;
|
|
51
53
|
onChange(newValue);
|
|
52
54
|
};
|
|
53
|
-
|
|
55
|
+
const isCurrentValueEmpty = () => {
|
|
54
56
|
return (0, _lodash.isNil)(value) || value === '';
|
|
55
57
|
};
|
|
56
58
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -92,5 +94,4 @@ InputNumberButtons.propTypes = {
|
|
|
92
94
|
step: _propTypes.default.number,
|
|
93
95
|
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]).isRequired
|
|
94
96
|
};
|
|
95
|
-
var _default = /*#__PURE__*/_react.default.memo(InputNumberButtons);
|
|
96
|
-
exports.default = _default;
|
|
97
|
+
var _default = exports.default = /*#__PURE__*/_react.default.memo(InputNumberButtons);
|