@codacy/ui-components 0.64.16 → 0.64.17
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/lib/Avatar/Avatar.js +25 -19
- package/lib/Avatar/Avatar.types.js +5 -1
- package/lib/Avatar/gravatar.js +17 -13
- package/lib/Avatar/index.js +16 -1
- package/lib/Banner/Banner.js +45 -32
- package/lib/Banner/Banner.styles.d.ts +11 -12
- package/lib/Banner/Banner.styles.js +26 -15
- package/lib/Banner/Banner.types.js +5 -1
- package/lib/Banner/index.js +27 -2
- package/lib/Button/Button.js +54 -51
- package/lib/Button/index.js +27 -2
- package/lib/Button/styles.d.ts +16 -12
- package/lib/Button/styles.js +58 -44
- package/lib/Button/types.js +5 -1
- package/lib/Checkbox/Checkbox.js +63 -54
- package/lib/Checkbox/CheckboxFilterList.js +46 -32
- package/lib/Checkbox/index.js +38 -3
- package/lib/Checkbox/styles.d.ts +25 -22
- package/lib/Checkbox/styles.js +52 -37
- package/lib/Checkbox/types.js +5 -1
- package/lib/CloseButton/index.js +27 -16
- package/lib/Divider/Divider.js +23 -13
- package/lib/Divider/Divider.styles.d.ts +16 -19
- package/lib/Divider/Divider.styles.js +24 -11
- package/lib/Divider/Divider.types.js +5 -1
- package/lib/Divider/index.js +16 -1
- package/lib/Dropdown/Content/DropdownInput.js +20 -8
- package/lib/Dropdown/Content/DropdownItem.js +29 -21
- package/lib/Dropdown/Content/DropdownSeparator.js +19 -7
- package/lib/Dropdown/Content/index.js +38 -3
- package/lib/Dropdown/Dropdown.js +89 -85
- package/lib/Dropdown/Dropdown.styles.d.ts +37 -34
- package/lib/Dropdown/Dropdown.styles.js +62 -43
- package/lib/Dropdown/Dropdown.types.js +5 -1
- package/lib/Dropdown/Triggers/DropdownButtonTrigger.js +30 -20
- package/lib/Dropdown/Triggers/DropdownLinkTrigger.js +29 -19
- package/lib/Dropdown/Triggers/InputTrigger.js +18 -10
- package/lib/Dropdown/Triggers/SelectTrigger.js +19 -12
- package/lib/Dropdown/Triggers/hooks.js +18 -14
- package/lib/Dropdown/Triggers/index.js +60 -5
- package/lib/Dropdown/Triggers/types.js +5 -1
- package/lib/Dropdown/index.js +49 -4
- package/lib/Flexbox/Flexbox.d.ts +31 -17
- package/lib/Flexbox/Flexbox.js +36 -16
- package/lib/Flexbox/index.js +16 -1
- package/lib/Group/Group.js +17 -8
- package/lib/Group/Group.styles.d.ts +8 -10
- package/lib/Group/Group.styles.js +17 -7
- package/lib/Group/Group.types.js +5 -1
- package/lib/Group/index.js +16 -1
- package/lib/Icon/Icon.js +24 -14
- package/lib/Icon/Icon.styles.d.ts +9 -11
- package/lib/Icon/Icon.styles.js +39 -44
- package/lib/Icon/Icon.types.js +5 -1
- package/lib/Icon/index.js +16 -1
- package/lib/IconAndText/IconAndText.js +33 -21
- package/lib/IconAndText/IconAndText.styles.d.ts +8 -10
- package/lib/IconAndText/IconAndText.styles.js +20 -10
- package/lib/IconAndText/IconAndText.types.js +5 -1
- package/lib/IconAndText/index.js +16 -1
- package/lib/Icons/Chevrons.js +53 -41
- package/lib/Icons/CodacyIcon.js +17 -8
- package/lib/Icons/Messages.js +54 -35
- package/lib/Icons/Search.js +16 -7
- package/lib/Icons/Severities.js +117 -106
- package/lib/Icons/Sorting.js +23 -13
- package/lib/Icons/Spinner.js +19 -10
- package/lib/Icons/Symbols.js +73 -58
- package/lib/Icons/index.js +93 -8
- package/lib/Img/Img.js +44 -37
- package/lib/Img/Img.styles.d.ts +12 -11
- package/lib/Img/Img.styles.js +37 -32
- package/lib/Img/Img.types.js +5 -1
- package/lib/Img/index.js +16 -1
- package/lib/InlineMessage/InlineMessage.js +47 -34
- package/lib/InlineMessage/index.js +16 -1
- package/lib/InlineMessage/types.js +5 -1
- package/lib/Input/Input.js +148 -126
- package/lib/Input/hooks.js +149 -178
- package/lib/Input/index.js +27 -2
- package/lib/Input/styles.d.ts +55 -104
- package/lib/Input/styles.js +85 -54
- package/lib/Input/types.js +5 -1
- package/lib/Labeled/Labeled.js +34 -22
- package/lib/Labeled/index.js +16 -1
- package/lib/Labeled/styles.d.ts +16 -12
- package/lib/Labeled/styles.js +27 -11
- package/lib/Labeled/types.js +5 -1
- package/lib/LeftMenu/LeftMenu.js +20 -11
- package/lib/LeftMenu/LeftMenu.styles.d.ts +8 -10
- package/lib/LeftMenu/LeftMenu.styles.js +20 -10
- package/lib/LeftMenu/LeftMenu.types.js +5 -1
- package/lib/LeftMenu/index.js +16 -1
- package/lib/Link/Link.js +43 -33
- package/lib/Link/Link.styles.d.ts +4 -1
- package/lib/Link/Link.styles.js +21 -11
- package/lib/Link/Link.types.js +5 -1
- package/lib/Link/index.js +38 -3
- package/lib/Message/Message.js +32 -24
- package/lib/Message/Message.styles.d.ts +8 -10
- package/lib/Message/Message.styles.js +17 -7
- package/lib/Message/Message.types.js +5 -1
- package/lib/Message/index.js +16 -1
- package/lib/Modal/ConfirmationModal.js +64 -40
- package/lib/Modal/Modal.js +120 -107
- package/lib/Modal/index.js +27 -2
- package/lib/Modal/styles.d.ts +44 -61
- package/lib/Modal/styles.js +97 -85
- package/lib/Modal/types.js +5 -1
- package/lib/MoreInfo/MoreInfo.js +45 -39
- package/lib/MoreInfo/index.js +16 -1
- package/lib/MoreInfo/types.js +5 -1
- package/lib/Panel/Panel.js +18 -9
- package/lib/Panel/Panel.styles.d.ts +8 -11
- package/lib/Panel/Panel.styles.js +15 -5
- package/lib/Panel/Panel.types.js +5 -1
- package/lib/Panel/index.js +27 -2
- package/lib/PillLabel/PillLabel.js +28 -21
- package/lib/PillLabel/PillLabel.styles.d.ts +8 -10
- package/lib/PillLabel/PillLabel.styles.js +25 -16
- package/lib/PillLabel/PillLabel.types.js +5 -1
- package/lib/PillLabel/index.js +16 -1
- package/lib/Popup/Popup.js +55 -45
- package/lib/Popup/index.js +16 -1
- package/lib/Popup/styles.d.ts +12 -11
- package/lib/Popup/styles.js +21 -8
- package/lib/Popup/types.js +5 -1
- package/lib/ProgressBar/ProgressBar.js +30 -20
- package/lib/ProgressBar/index.js +27 -2
- package/lib/ProgressBar/styles.d.ts +24 -28
- package/lib/ProgressBar/styles.js +30 -14
- package/lib/ProgressBar/types.js +5 -1
- package/lib/Radio/Radio.js +53 -48
- package/lib/Radio/index.js +16 -1
- package/lib/Radio/styles.d.ts +25 -22
- package/lib/Radio/styles.js +49 -30
- package/lib/Radio/types.js +5 -1
- package/lib/ScrollableContent/ScrollableContent.js +35 -24
- package/lib/ScrollableContent/ScrollableContent.styles.d.ts +9 -11
- package/lib/ScrollableContent/ScrollableContent.styles.js +23 -13
- package/lib/ScrollableContent/ScrollableContent.types.js +5 -1
- package/lib/ScrollableContent/index.js +27 -2
- package/lib/ScrollableContent/useScrollContainer.js +29 -24
- package/lib/Select/Select.js +31 -20
- package/lib/Select/index.js +16 -1
- package/lib/Select/types.js +5 -1
- package/lib/Skeleton/Skeleton.js +30 -25
- package/lib/Skeleton/Skeleton.styles.d.ts +8 -10
- package/lib/Skeleton/Skeleton.styles.js +21 -14
- package/lib/Skeleton/Skeleton.types.js +5 -1
- package/lib/Skeleton/index.js +20 -2
- package/lib/Stepper/Stepper.js +49 -40
- package/lib/Stepper/Stepper.styles.d.ts +24 -29
- package/lib/Stepper/Stepper.styles.js +35 -19
- package/lib/Stepper/Stepper.types.js +5 -1
- package/lib/Stepper/index.js +16 -1
- package/lib/Switcher/Switcher.js +32 -23
- package/lib/Switcher/Switcher.styles.d.ts +13 -13
- package/lib/Switcher/Switcher.styles.js +27 -15
- package/lib/Switcher/Switcher.types.js +5 -1
- package/lib/Switcher/index.js +16 -1
- package/lib/Tab/Tab.js +31 -23
- package/lib/Tab/Tab.styles.d.ts +13 -12
- package/lib/Tab/Tab.styles.js +30 -21
- package/lib/Tab/Tab.types.js +5 -1
- package/lib/Tab/index.js +16 -1
- package/lib/Table/NewSelectableTable.js +77 -56
- package/lib/Table/SelectableTable.js +138 -118
- package/lib/Table/Table.js +126 -111
- package/lib/Table/Table.styles.d.ts +32 -16
- package/lib/Table/Table.styles.js +79 -59
- package/lib/Table/Table.types.js +5 -1
- package/lib/Table/index.js +27 -2
- package/lib/TagsInput/TagsInput.js +44 -33
- package/lib/TagsInput/index.js +16 -1
- package/lib/TagsInput/style.d.ts +16 -19
- package/lib/TagsInput/style.js +22 -9
- package/lib/TagsInput/types.js +5 -1
- package/lib/Textarea/Textarea.js +75 -58
- package/lib/Textarea/Textarea.styles.d.ts +28 -22
- package/lib/Textarea/Textarea.styles.js +55 -32
- package/lib/Textarea/Textarea.types.js +5 -1
- package/lib/Textarea/index.js +16 -1
- package/lib/ThemeProvider/ThemeProvider.d.ts +5 -2
- package/lib/ThemeProvider/ThemeProvider.js +48 -30
- package/lib/ThemeProvider/index.js +16 -1
- package/lib/Toast/Toast.js +56 -53
- package/lib/Toast/index.js +16 -1
- package/lib/Toast/styles.d.ts +4 -2
- package/lib/Toast/styles.js +13 -3
- package/lib/Toast/types.js +5 -1
- package/lib/Toggle/Toggle.js +59 -50
- package/lib/Toggle/index.js +16 -1
- package/lib/Toggle/styles.d.ts +21 -14
- package/lib/Toggle/styles.js +51 -34
- package/lib/Toggle/types.js +5 -1
- package/lib/Tooltip/Tooltip.js +100 -102
- package/lib/Tooltip/index.js +16 -1
- package/lib/Tooltip/styles.d.ts +14 -8
- package/lib/Tooltip/styles.js +33 -25
- package/lib/Tooltip/types.js +5 -1
- package/lib/Typography/Typography.js +96 -85
- package/lib/Typography/Typography.styles.d.ts +48 -54
- package/lib/Typography/Typography.styles.js +70 -45
- package/lib/Typography/Typography.types.js +5 -1
- package/lib/Typography/index.js +38 -3
- package/lib/emotion.d.js +3 -0
- package/lib/hooks/index.js +38 -3
- package/lib/hooks/useForwardedRef.js +11 -6
- package/lib/hooks/useInfiniteScroll.js +24 -20
- package/lib/hooks/useStatefulRef.js +18 -14
- package/lib/index.js +489 -44
- package/lib/system-props/color.js +8 -2
- package/lib/system-props/index.js +27 -2
- package/lib/system-props/types.js +5 -1
- package/lib/theme/ColorSchemes/codacy.js +11 -4
- package/lib/theme/ColorSchemes/pulse.js +17 -9
- package/lib/theme/index.js +38 -3
- package/lib/theme/theme.js +42 -69
- package/lib/types.js +5 -1
- package/lib/utils/hash.js +8 -6
- package/lib/utils/reactNodeToText.js +13 -14
- package/package.json +32 -32
package/lib/Input/hooks.js
CHANGED
|
@@ -1,17 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
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; }
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useAsyncValidatedInput = void 0;
|
|
8
|
+
exports.useDebounce = useDebounce;
|
|
9
|
+
exports.useEmailInput = void 0;
|
|
10
|
+
exports.useInput = useInput;
|
|
11
|
+
exports.useNumberInput = useNumberInput;
|
|
12
|
+
exports.useRegexInput = void 0;
|
|
13
|
+
exports.useRequiredInput = useRequiredInput;
|
|
14
|
+
exports.useTagsInput = useTagsInput;
|
|
15
|
+
exports.useTextarea = useTextarea;
|
|
16
|
+
exports.useValidatedInput = exports.useUrlInput = void 0;
|
|
17
|
+
var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/regeneratorRuntime"));
|
|
18
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
|
|
19
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
20
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
21
|
+
var _react = require("react");
|
|
22
|
+
function useInput(initialValue) {
|
|
23
|
+
var _useState = (0, _react.useState)(initialValue),
|
|
24
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
25
|
+
value = _useState2[0],
|
|
26
|
+
setValue = _useState2[1];
|
|
27
|
+
var onChange = (0, _react.useCallback)(function (e) {
|
|
15
28
|
return setValue(e.currentTarget.value);
|
|
16
29
|
}, []);
|
|
17
30
|
return {
|
|
@@ -24,13 +37,12 @@ export function useInput(initialValue) {
|
|
|
24
37
|
}
|
|
25
38
|
};
|
|
26
39
|
}
|
|
27
|
-
|
|
28
|
-
var _useState3 = useState(initialValue),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var onChange = useCallback(function (e) {
|
|
40
|
+
function useNumberInput(initialValue, min, max) {
|
|
41
|
+
var _useState3 = (0, _react.useState)(initialValue),
|
|
42
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
43
|
+
value = _useState4[0],
|
|
44
|
+
setValue = _useState4[1];
|
|
45
|
+
var onChange = (0, _react.useCallback)(function (e) {
|
|
34
46
|
setValue(e.currentTarget.value === '' ? null : Number(e.currentTarget.value));
|
|
35
47
|
}, []);
|
|
36
48
|
var hasValue = value !== null && value !== undefined;
|
|
@@ -50,19 +62,16 @@ export function useNumberInput(initialValue, min, max) {
|
|
|
50
62
|
hasError: hasError
|
|
51
63
|
};
|
|
52
64
|
}
|
|
53
|
-
|
|
65
|
+
function useRequiredInput(initialValue, requiredMessage) {
|
|
54
66
|
var inputProps = useInput(initialValue);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
setValid = _useState6[1];
|
|
60
|
-
|
|
67
|
+
var _useState5 = (0, _react.useState)(null),
|
|
68
|
+
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
69
|
+
valid = _useState6[0],
|
|
70
|
+
setValid = _useState6[1];
|
|
61
71
|
function handleBlur() {
|
|
62
72
|
setValid(!!inputProps.value && inputProps.value.trim() !== '');
|
|
63
73
|
}
|
|
64
|
-
|
|
65
|
-
return _objectSpread(_objectSpread({}, inputProps), {}, {
|
|
74
|
+
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, inputProps), {}, {
|
|
66
75
|
onBlur: handleBlur,
|
|
67
76
|
onClear: function onClear() {
|
|
68
77
|
inputProps.setValue('');
|
|
@@ -73,45 +82,40 @@ export function useRequiredInput(initialValue, requiredMessage) {
|
|
|
73
82
|
errorMessage: !valid ? requiredMessage || 'Please, enter a value' : undefined
|
|
74
83
|
});
|
|
75
84
|
}
|
|
76
|
-
|
|
77
|
-
var _useState7 = useState(initialValue),
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
85
|
+
function useTextarea(initialValue) {
|
|
86
|
+
var _useState7 = (0, _react.useState)(initialValue),
|
|
87
|
+
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
|
88
|
+
value = _useState8[0],
|
|
89
|
+
setValue = _useState8[1];
|
|
82
90
|
function handleChange(e) {
|
|
83
91
|
setValue(e.currentTarget.value);
|
|
84
92
|
}
|
|
85
|
-
|
|
86
93
|
return {
|
|
87
94
|
value: value,
|
|
88
95
|
setValue: setValue,
|
|
89
96
|
onChange: handleChange
|
|
90
97
|
};
|
|
91
98
|
}
|
|
92
|
-
|
|
93
|
-
var _useState9 = useState(initialValue),
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
99
|
+
function useTagsInput(initialValue) {
|
|
100
|
+
var _useState9 = (0, _react.useState)(initialValue),
|
|
101
|
+
_useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
|
|
102
|
+
tags = _useState10[0],
|
|
103
|
+
setTags = _useState10[1];
|
|
98
104
|
function handleChange(value) {
|
|
99
105
|
setTags(value);
|
|
100
106
|
}
|
|
101
|
-
|
|
102
107
|
return {
|
|
103
108
|
tags: tags,
|
|
104
109
|
setTags: setTags,
|
|
105
110
|
onChange: handleChange
|
|
106
111
|
};
|
|
107
112
|
}
|
|
108
|
-
|
|
109
|
-
var _useState11 = useState(value),
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
useEffect(function () {
|
|
113
|
+
function useDebounce(value, delay) {
|
|
114
|
+
var _useState11 = (0, _react.useState)(value),
|
|
115
|
+
_useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
|
|
116
|
+
debouncedValue = _useState12[0],
|
|
117
|
+
setDebouncedValue = _useState12[1];
|
|
118
|
+
(0, _react.useEffect)(function () {
|
|
115
119
|
var handler = setTimeout(function () {
|
|
116
120
|
setDebouncedValue(value);
|
|
117
121
|
}, delay);
|
|
@@ -121,35 +125,28 @@ export function useDebounce(value, delay) {
|
|
|
121
125
|
}, [value, delay]);
|
|
122
126
|
return debouncedValue;
|
|
123
127
|
}
|
|
124
|
-
|
|
125
128
|
function generateInputValidator(validations, inputType, hideSuccess) {
|
|
126
129
|
return function (initialValue, isRequired) {
|
|
127
|
-
var didMountRef = useRef(false);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
_useState18 = _slicedToArray(_useState17, 2),
|
|
141
|
-
errorMessage = _useState18[0],
|
|
142
|
-
setErrorMessage = _useState18[1];
|
|
143
|
-
|
|
130
|
+
var didMountRef = (0, _react.useRef)(false);
|
|
131
|
+
var _useState13 = (0, _react.useState)(initialValue),
|
|
132
|
+
_useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
|
|
133
|
+
value = _useState14[0],
|
|
134
|
+
setValue = _useState14[1];
|
|
135
|
+
var _useState15 = (0, _react.useState)(null),
|
|
136
|
+
_useState16 = (0, _slicedToArray2["default"])(_useState15, 2),
|
|
137
|
+
valid = _useState16[0],
|
|
138
|
+
setValid = _useState16[1];
|
|
139
|
+
var _useState17 = (0, _react.useState)(),
|
|
140
|
+
_useState18 = (0, _slicedToArray2["default"])(_useState17, 2),
|
|
141
|
+
errorMessage = _useState18[0],
|
|
142
|
+
setErrorMessage = _useState18[1];
|
|
144
143
|
var debouncedValue = useDebounce(value, 500);
|
|
145
|
-
var handleChange = useCallback(function (e) {
|
|
144
|
+
var handleChange = (0, _react.useCallback)(function (e) {
|
|
146
145
|
setValue(e.currentTarget.value || '');
|
|
147
146
|
}, []);
|
|
148
|
-
|
|
149
147
|
var doValidation = function doValidation() {
|
|
150
148
|
if (didMountRef.current) {
|
|
151
149
|
var val = debouncedValue || '';
|
|
152
|
-
|
|
153
150
|
if (!val) {
|
|
154
151
|
setValid(isRequired ? false : null);
|
|
155
152
|
} else {
|
|
@@ -164,8 +161,7 @@ function generateInputValidator(validations, inputType, hideSuccess) {
|
|
|
164
161
|
didMountRef.current = true;
|
|
165
162
|
}
|
|
166
163
|
};
|
|
167
|
-
|
|
168
|
-
useEffect(doValidation, [debouncedValue]);
|
|
164
|
+
(0, _react.useEffect)(doValidation, [debouncedValue]);
|
|
169
165
|
return {
|
|
170
166
|
value: value,
|
|
171
167
|
setValue: setValue,
|
|
@@ -185,121 +181,98 @@ function generateInputValidator(validations, inputType, hideSuccess) {
|
|
|
185
181
|
};
|
|
186
182
|
};
|
|
187
183
|
}
|
|
188
|
-
|
|
189
184
|
function generateAsyncInputValidator(validations, inputType, hideSuccess) {
|
|
190
185
|
return function (initialValue, isRequired) {
|
|
191
|
-
var didMountRef = useRef(false);
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
var _useState25 = useState(),
|
|
209
|
-
_useState26 = _slicedToArray(_useState25, 2),
|
|
210
|
-
errorMessage = _useState26[0],
|
|
211
|
-
setErrorMessage = _useState26[1];
|
|
212
|
-
|
|
186
|
+
var didMountRef = (0, _react.useRef)(false);
|
|
187
|
+
var _useState19 = (0, _react.useState)(initialValue),
|
|
188
|
+
_useState20 = (0, _slicedToArray2["default"])(_useState19, 2),
|
|
189
|
+
value = _useState20[0],
|
|
190
|
+
setValue = _useState20[1];
|
|
191
|
+
var _useState21 = (0, _react.useState)(null),
|
|
192
|
+
_useState22 = (0, _slicedToArray2["default"])(_useState21, 2),
|
|
193
|
+
valid = _useState22[0],
|
|
194
|
+
setValid = _useState22[1];
|
|
195
|
+
var _useState23 = (0, _react.useState)(),
|
|
196
|
+
_useState24 = (0, _slicedToArray2["default"])(_useState23, 2),
|
|
197
|
+
isLoading = _useState24[0],
|
|
198
|
+
setIsLoading = _useState24[1];
|
|
199
|
+
var _useState25 = (0, _react.useState)(),
|
|
200
|
+
_useState26 = (0, _slicedToArray2["default"])(_useState25, 2),
|
|
201
|
+
errorMessage = _useState26[0],
|
|
202
|
+
setErrorMessage = _useState26[1];
|
|
213
203
|
var debouncedValue = useDebounce(value, 500);
|
|
214
|
-
|
|
215
204
|
var doValidation = /*#__PURE__*/function () {
|
|
216
|
-
var _ref2 =
|
|
205
|
+
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee() {
|
|
217
206
|
var val, _validationFailed, index, validationFailed, isValid;
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
if (!didMountRef.current) {
|
|
224
|
-
_context.next = 28;
|
|
225
|
-
break;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
val = debouncedValue || '';
|
|
229
|
-
|
|
230
|
-
if (val) {
|
|
231
|
-
_context.next = 7;
|
|
232
|
-
break;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
setValid(isRequired ? false : null);
|
|
236
|
-
setIsLoading(false);
|
|
237
|
-
_context.next = 26;
|
|
207
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function _callee$(_context) {
|
|
208
|
+
while (1) switch (_context.prev = _context.next) {
|
|
209
|
+
case 0:
|
|
210
|
+
if (!didMountRef.current) {
|
|
211
|
+
_context.next = 28;
|
|
238
212
|
break;
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
_context.
|
|
243
|
-
index = 0;
|
|
244
|
-
|
|
245
|
-
case 10:
|
|
246
|
-
_context.next = 12;
|
|
247
|
-
return validations[index].callback(val);
|
|
248
|
-
|
|
249
|
-
case 12:
|
|
250
|
-
isValid = _context.sent;
|
|
251
|
-
if (isValid) index++;else validationFailed = validations[index];
|
|
252
|
-
|
|
253
|
-
case 14:
|
|
254
|
-
if (index < validations.length && !validationFailed) {
|
|
255
|
-
_context.next = 10;
|
|
256
|
-
break;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
case 15:
|
|
260
|
-
setValid(!validationFailed);
|
|
261
|
-
setErrorMessage((_validationFailed = validationFailed) === null || _validationFailed === void 0 ? void 0 : _validationFailed.errorMessage);
|
|
262
|
-
_context.next = 23;
|
|
213
|
+
}
|
|
214
|
+
val = debouncedValue || '';
|
|
215
|
+
if (val) {
|
|
216
|
+
_context.next = 7;
|
|
263
217
|
break;
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
218
|
+
}
|
|
219
|
+
setValid(isRequired ? false : null);
|
|
220
|
+
setIsLoading(false);
|
|
221
|
+
_context.next = 26;
|
|
222
|
+
break;
|
|
223
|
+
case 7:
|
|
224
|
+
setIsLoading(true);
|
|
225
|
+
_context.prev = 8;
|
|
226
|
+
index = 0;
|
|
227
|
+
case 10:
|
|
228
|
+
_context.next = 12;
|
|
229
|
+
return validations[index].callback(val);
|
|
230
|
+
case 12:
|
|
231
|
+
isValid = _context.sent;
|
|
232
|
+
if (isValid) index++;else validationFailed = validations[index];
|
|
233
|
+
case 14:
|
|
234
|
+
if (index < validations.length && !validationFailed) {
|
|
235
|
+
_context.next = 10;
|
|
278
236
|
break;
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
237
|
+
}
|
|
238
|
+
case 15:
|
|
239
|
+
setValid(!validationFailed);
|
|
240
|
+
setErrorMessage((_validationFailed = validationFailed) === null || _validationFailed === void 0 ? void 0 : _validationFailed.errorMessage);
|
|
241
|
+
_context.next = 23;
|
|
242
|
+
break;
|
|
243
|
+
case 19:
|
|
244
|
+
_context.prev = 19;
|
|
245
|
+
_context.t0 = _context["catch"](8);
|
|
246
|
+
setValid(false);
|
|
247
|
+
setErrorMessage(_context.t0.message);
|
|
248
|
+
case 23:
|
|
249
|
+
_context.prev = 23;
|
|
250
|
+
setIsLoading(false);
|
|
251
|
+
return _context.finish(23);
|
|
252
|
+
case 26:
|
|
253
|
+
_context.next = 29;
|
|
254
|
+
break;
|
|
255
|
+
case 28:
|
|
256
|
+
didMountRef.current = true;
|
|
257
|
+
case 29:
|
|
258
|
+
case "end":
|
|
259
|
+
return _context.stop();
|
|
287
260
|
}
|
|
288
261
|
}, _callee, null, [[8, 19, 23, 26]]);
|
|
289
262
|
}));
|
|
290
|
-
|
|
291
263
|
return function doValidation() {
|
|
292
264
|
return _ref2.apply(this, arguments);
|
|
293
265
|
};
|
|
294
266
|
}();
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
267
|
+
(0, _react.useEffect)(function () {
|
|
268
|
+
doValidation();
|
|
269
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
298
270
|
}, [debouncedValue]);
|
|
299
|
-
var handleChange = useCallback(function (e) {
|
|
271
|
+
var handleChange = (0, _react.useCallback)(function (e) {
|
|
300
272
|
var value = e.currentTarget.value || '';
|
|
301
273
|
setValue(value);
|
|
302
|
-
if (!isLoading) setIsLoading(true);
|
|
274
|
+
if (!isLoading) setIsLoading(true);
|
|
275
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
303
276
|
}, []);
|
|
304
277
|
return {
|
|
305
278
|
value: value,
|
|
@@ -321,7 +294,6 @@ function generateAsyncInputValidator(validations, inputType, hideSuccess) {
|
|
|
321
294
|
};
|
|
322
295
|
};
|
|
323
296
|
}
|
|
324
|
-
|
|
325
297
|
function generateRegexInputValidator(regex, errorMessage, inputType) {
|
|
326
298
|
return generateInputValidator([{
|
|
327
299
|
callback: function callback(value) {
|
|
@@ -330,15 +302,14 @@ function generateRegexInputValidator(regex, errorMessage, inputType) {
|
|
|
330
302
|
errorMessage: errorMessage
|
|
331
303
|
}], inputType);
|
|
332
304
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
export var useRegexInput = function useRegexInput(regex, errorMessage, inputType) {
|
|
305
|
+
var useEmailInput = exports.useEmailInput = generateRegexInputValidator(/^([a-zA-Z0-9_\-.]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,5})$/, 'Insert a valid email address', 'email');
|
|
306
|
+
var useUrlInput = exports.useUrlInput = generateRegexInputValidator(/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www\.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w\-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[.!/\\\w]*))?)/, 'Insert a valid URL', 'url');
|
|
307
|
+
var useRegexInput = exports.useRegexInput = function useRegexInput(regex, errorMessage, inputType) {
|
|
337
308
|
return generateRegexInputValidator(regex, errorMessage, inputType);
|
|
338
309
|
};
|
|
339
|
-
|
|
310
|
+
var useValidatedInput = exports.useValidatedInput = function useValidatedInput(validations, inputType, hideSuccess) {
|
|
340
311
|
return generateInputValidator(validations, inputType, hideSuccess);
|
|
341
312
|
};
|
|
342
|
-
|
|
313
|
+
var useAsyncValidatedInput = exports.useAsyncValidatedInput = function useAsyncValidatedInput(validations, inputType, hideSuccess) {
|
|
343
314
|
return generateAsyncInputValidator(validations, inputType, hideSuccess);
|
|
344
315
|
};
|
package/lib/Input/index.js
CHANGED
|
@@ -1,2 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _Input = require("./Input");
|
|
7
|
+
Object.keys(_Input).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _Input[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _Input[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _hooks = require("./hooks");
|
|
18
|
+
Object.keys(_hooks).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _hooks[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function get() {
|
|
24
|
+
return _hooks[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|