@onepercentio/one-ui 0.20.4 → 0.21.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/.babelrc +6 -0
- package/.prod.babelrc +8 -2
- package/dist/assets/styles/variables.scss +1 -0
- package/dist/components/AdaptiveButton/AdaptiveButton.js +2 -2
- package/dist/components/AdaptiveContainer/AdaptiveContainer.js +28 -26
- package/dist/components/AdaptiveContainer/AdaptiveContainer.module.scss +3 -1
- package/dist/components/AdaptiveDialog/AdaptiveDialog.js +9 -9
- package/dist/components/AdaptiveSidebar/AdaptiveSidebar.js +14 -14
- package/dist/components/AnchoredTooltip/AnchoredTooltip.js +30 -30
- package/dist/components/AnimatedEntrance/AnimatedEntrance.d.ts +1 -1
- package/dist/components/AnimatedEntrance/AnimatedEntrance.js +34 -45
- package/dist/components/AsyncWrapper/AsyncWrapper.js +2 -2
- package/dist/components/Avatar/Avatar.js +4 -4
- package/dist/components/BucketFill/BucketFill.js +9 -9
- package/dist/components/Button/Button.js +4 -4
- package/dist/components/Card/Card.js +1 -1
- package/dist/components/Chart/Chart.view.js +34 -34
- package/dist/components/CheckBox/CheckBox.js +3 -3
- package/dist/components/Collapsable/Collapsable.js +18 -18
- package/dist/components/Countdown/Countdown.js +16 -16
- package/dist/components/Divider/Divider.js +1 -1
- package/dist/components/EmailInput/EmailInput.d.ts +1 -1
- package/dist/components/EmailInput/EmailInput.js +4 -4
- package/dist/components/FadeIn/FadeIn.js +9 -9
- package/dist/components/FileInput/FileInput.js +6 -6
- package/dist/components/FileInput/View/BigFactory/BigFactory.js +1 -1
- package/dist/components/FileInput/View/Compact/Compact.js +6 -6
- package/dist/components/FlowController/FlowController.js +4 -4
- package/dist/components/Form/Form.js +17 -28
- package/dist/components/Freeze/Freeze.js +1 -1
- package/dist/components/HSForms/HSForms.js +9 -11
- package/dist/components/Header/Header.js +7 -7
- package/dist/components/HeaderCloseBtn/HeaderCloseBtn.js +1 -1
- package/dist/components/InfinityScroll/InfinityScroll.js +25 -25
- package/dist/components/Input/Input.js +13 -13
- package/dist/components/InstantCounter/InstantCounter.js +9 -9
- package/dist/components/LavaLamp/LavaLamp.data.js +25 -25
- package/dist/components/LavaLamp/LavaLamp.js +7 -7
- package/dist/components/LavaLamp/v2/LavaLamp.js +29 -45
- package/dist/components/LinkToId/LinkToId.js +7 -7
- package/dist/components/Loader/Loader.js +2 -2
- package/dist/components/LoaderDotsIndicator/LoaderDotsIndicator.js +6 -6
- package/dist/components/LoopableVideo/LoopableVideo.js +4 -4
- package/dist/components/MainGrid/MainGrid.js +2 -2
- package/dist/components/MutableHamburgerButton/MutableHamburgerButton.js +2 -2
- package/dist/components/Notification/Notification.js +1 -1
- package/dist/components/OrderableList/OrderableList.js +113 -138
- package/dist/components/PaginationIndicator/PaginationIndicator.js +50 -50
- package/dist/components/Parallax/Parallax.js +39 -39
- package/dist/components/Parallax/math/helpers.js +18 -19
- package/dist/components/PasswordInput/PasswordInput.d.ts +1 -1
- package/dist/components/PasswordInput/PasswordInput.js +10 -10
- package/dist/components/PingPongText/PingPongText.js +15 -15
- package/dist/components/PixelatedScan/PixelatedScan.js +19 -19
- package/dist/components/Portal/Portal.js +10 -10
- package/dist/components/ProgressBar/ProgressBar.js +6 -6
- package/dist/components/ProgressTexts/ProgressTexts.js +3 -3
- package/dist/components/Radio/Radio.js +3 -3
- package/dist/components/SectionContainer/SectionContainer.js +1 -1
- package/dist/components/Select/Select.js +13 -13
- package/dist/components/Select/Select.module.scss +8 -5
- package/dist/components/Skeleton/Skeleton.js +1 -1
- package/dist/components/Spacing/Spacing.js +1 -1
- package/dist/components/StaticScroller/StaticScroller.js +12 -12
- package/dist/components/Switch/Switch.js +2 -2
- package/dist/components/Table/Table.js +11 -11
- package/dist/components/Tabs/Tabs.d.ts +6 -1
- package/dist/components/Tabs/Tabs.js +28 -9
- package/dist/components/Tabs/Tabs.module.scss +20 -2
- package/dist/components/Text/Text.js +5 -5
- package/dist/components/Transition/MasksFactory/DiagonalReveal.js +5 -5
- package/dist/components/Transition/MasksFactory/DiagonalSquareToBalls.js +17 -17
- package/dist/components/Transition/MasksFactory/PhysicsSquares.js +13 -13
- package/dist/components/Transition/MasksFactory/SquareToBalls.js +9 -9
- package/dist/components/Transition/MasksFactory/utils.js +8 -8
- package/dist/components/Transition/Transition.js +49 -49
- package/dist/components/UncontrolledTransition/UncontrolledTransition.js +7 -7
- package/dist/components/WalletConnectionWrapper/WalletConnectionWrapper.js +44 -82
- package/dist/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.js +6 -6
- package/dist/context/AsyncProcess.js +19 -42
- package/dist/context/CustomBrowserRouter.js +6 -6
- package/dist/context/OneUIProvider.js +15 -15
- package/dist/hooks/logs/useDependencyChangeDetection.js +2 -5
- package/dist/hooks/persistence/useLocalStorage.js +7 -7
- package/dist/hooks/shims/ObjectWatchShim.js +1 -15
- package/dist/hooks/ui/useAdaptiveImage.js +6 -6
- package/dist/hooks/ui/useBreakpoint.js +5 -5
- package/dist/hooks/ui/useCustomScrollbar.js +2 -2
- package/dist/hooks/ui/useMouseHover.js +4 -4
- package/dist/hooks/ui/usePaginationControls.js +34 -34
- package/dist/hooks/ui/useSnapToViewport.js +3 -3
- package/dist/hooks/ui/useTilt.js +38 -38
- package/dist/hooks/ui/useZoomable.js +20 -20
- package/dist/hooks/useAsyncControl.js +21 -38
- package/dist/hooks/useContainedRepositioning.js +22 -22
- package/dist/hooks/useCustomHistory.js +2 -2
- package/dist/hooks/useElementFit.js +6 -6
- package/dist/hooks/useFirestoreWatch.js +26 -39
- package/dist/hooks/useForm.js +8 -8
- package/dist/hooks/useFreeze.js +1 -1
- package/dist/hooks/useHero.d.ts +1 -0
- package/dist/hooks/useHero.js +132 -91
- package/dist/hooks/useHero.module.scss +7 -0
- package/dist/hooks/useIntersection.js +3 -3
- package/dist/hooks/useMergeRefs.js +3 -7
- package/dist/hooks/useObserve.js +5 -5
- package/dist/hooks/usePagination.js +39 -59
- package/dist/hooks/usePooledOperation.js +8 -22
- package/dist/hooks/usePooling.js +17 -33
- package/dist/hooks/useRebound.js +5 -5
- package/dist/hooks/useShortIntl.js +13 -13
- package/dist/hooks/utility/useEvents.js +5 -5
- package/dist/hooks/utility/useModule.js +3 -3
- package/dist/hooks/utility/useQuery.js +1 -1
- package/dist/models/DebugLogger.js +2 -2
- package/dist/models/GenericContract.js +1 -1
- package/dist/storybookUtils/index.js +1 -1
- package/dist/types.d.ts +11 -4
- package/dist/utility.d.js +3 -3
- package/dist/utils/blockchain.js +29 -102
- package/dist/utils/flatten.js +3 -3
- package/dist/utils/html.utils.js +1 -1
- package/package.json +2 -1
- package/src/types.ts +155 -41
|
@@ -14,10 +14,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
14
14
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
15
15
|
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."); }
|
|
16
16
|
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); }
|
|
17
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
18
|
-
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)
|
|
17
|
+
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; }
|
|
18
|
+
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; } }
|
|
19
19
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
|
-
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; }
|
|
21
20
|
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); } }
|
|
22
21
|
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); }); }; }
|
|
23
22
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
@@ -38,53 +37,31 @@ function _BaseWalletConnectionWrapper(props, ref) {
|
|
|
38
37
|
}, props));
|
|
39
38
|
}
|
|
40
39
|
function Content(_ref) {
|
|
41
|
-
|
|
40
|
+
let ProviderUnavailable = _ref.ProviderUnavailable,
|
|
42
41
|
ChainIdInvalid = _ref.ChainIdInvalid,
|
|
43
42
|
chain = _ref.chain,
|
|
44
43
|
ProvidedContentWrapper = _ref.Content,
|
|
45
44
|
compRef = _ref.compRef,
|
|
46
45
|
children = _ref.children;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var _ref2 = _asyncToGenerator(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
57
|
-
while (1) {
|
|
58
|
-
switch (_context.prev = _context.next) {
|
|
59
|
-
case 0:
|
|
60
|
-
_context.next = 2;
|
|
61
|
-
return wallet.connect("injected");
|
|
62
|
-
case 2:
|
|
63
|
-
localStorage.setItem("auto_connect", "true");
|
|
64
|
-
case 3:
|
|
65
|
-
case "end":
|
|
66
|
-
return _context.stop();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}, _callee);
|
|
70
|
-
})));
|
|
71
|
-
case 1:
|
|
72
|
-
case "end":
|
|
73
|
-
return _context2.stop();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}, _callee2);
|
|
77
|
-
}));
|
|
46
|
+
const wallet = (0, _useWallet.useWallet)();
|
|
47
|
+
const connectionAsyncWrapper = (0, _useAsyncControl.default)();
|
|
48
|
+
const connect = /*#__PURE__*/function () {
|
|
49
|
+
var _ref2 = _asyncToGenerator(function* () {
|
|
50
|
+
connectionAsyncWrapper.process( /*#__PURE__*/_asyncToGenerator(function* () {
|
|
51
|
+
yield wallet.connect("injected");
|
|
52
|
+
localStorage.setItem("auto_connect", "true");
|
|
53
|
+
}));
|
|
54
|
+
});
|
|
78
55
|
return function connect() {
|
|
79
56
|
return _ref2.apply(this, arguments);
|
|
80
57
|
};
|
|
81
58
|
}();
|
|
82
|
-
|
|
59
|
+
const disconnect = function disconnect() {
|
|
83
60
|
wallet.reset();
|
|
84
61
|
localStorage.removeItem("auto_connect");
|
|
85
62
|
};
|
|
86
63
|
(0, _react.useEffect)(function () {
|
|
87
|
-
|
|
64
|
+
const autoConnect = !!localStorage.getItem("auto_connect");
|
|
88
65
|
if (autoConnect && !wallet.account) connect();
|
|
89
66
|
}, []);
|
|
90
67
|
(0, _react.useImperativeHandle)(compRef, function () {
|
|
@@ -93,63 +70,48 @@ function Content(_ref) {
|
|
|
93
70
|
disconnect: disconnect
|
|
94
71
|
};
|
|
95
72
|
}, [wallet]);
|
|
96
|
-
|
|
73
|
+
const _useState = (0, _react.useState)(function () {
|
|
97
74
|
return !!window.ethereum;
|
|
98
75
|
}),
|
|
99
76
|
_useState2 = _slicedToArray(_useState, 1),
|
|
100
77
|
isProviderAvailable = _useState2[0];
|
|
101
|
-
|
|
78
|
+
const isChainIdValid = (0, _react.useMemo)(function () {
|
|
102
79
|
return wallet.isConnected() ? wallet.chainId === chain.id : true;
|
|
103
80
|
}, [wallet, chain.id]);
|
|
104
81
|
function changeChainId() {
|
|
105
82
|
return _changeChainId.apply(this, arguments);
|
|
106
83
|
}
|
|
107
84
|
function _changeChainId() {
|
|
108
|
-
_changeChainId = _asyncToGenerator(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
chainId: "0x".concat(chain.id.toString(16).padStart(2, "0")),
|
|
133
|
-
chainName: chain.name,
|
|
134
|
-
rpcUrls: [chain.rpcUrl],
|
|
135
|
-
blockExplorerUrls: [chain.explorerUrl],
|
|
136
|
-
nativeCurrency: {
|
|
137
|
-
symbol: chain.currency,
|
|
138
|
-
decimals: 18
|
|
139
|
-
}
|
|
140
|
-
}]
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
case 8:
|
|
144
|
-
case "end":
|
|
145
|
-
return _context3.stop();
|
|
146
|
-
}
|
|
85
|
+
_changeChainId = _asyncToGenerator(function* () {
|
|
86
|
+
try {
|
|
87
|
+
yield window.ethereum.request({
|
|
88
|
+
method: "wallet_switchEthereumChain",
|
|
89
|
+
params: [{
|
|
90
|
+
chainId: "0x".concat(chain.id.toString(16).padStart(2, "0"))
|
|
91
|
+
}]
|
|
92
|
+
});
|
|
93
|
+
} catch (e) {
|
|
94
|
+
switch (e.code) {
|
|
95
|
+
case 4902:
|
|
96
|
+
window.ethereum.request({
|
|
97
|
+
method: "wallet_addEthereumChain",
|
|
98
|
+
params: [{
|
|
99
|
+
chainId: "0x".concat(chain.id.toString(16).padStart(2, "0")),
|
|
100
|
+
chainName: chain.name,
|
|
101
|
+
rpcUrls: [chain.rpcUrl],
|
|
102
|
+
blockExplorerUrls: [chain.explorerUrl],
|
|
103
|
+
nativeCurrency: {
|
|
104
|
+
symbol: chain.currency,
|
|
105
|
+
decimals: 18
|
|
106
|
+
}
|
|
107
|
+
}]
|
|
108
|
+
});
|
|
147
109
|
}
|
|
148
|
-
}
|
|
149
|
-
})
|
|
110
|
+
}
|
|
111
|
+
});
|
|
150
112
|
return _changeChainId.apply(this, arguments);
|
|
151
113
|
}
|
|
152
|
-
|
|
114
|
+
const ContentWrapper = ProvidedContentWrapper;
|
|
153
115
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, ProviderUnavailable && !isProviderAvailable && /*#__PURE__*/_react.default.createElement(ProviderUnavailable, null), ChainIdInvalid && !isChainIdValid && /*#__PURE__*/_react.default.createElement(ChainIdInvalid, {
|
|
154
116
|
changeChainId: changeChainId
|
|
155
117
|
}), /*#__PURE__*/_react.default.createElement(ContentWrapper, _extends({}, connectionAsyncWrapper, {
|
|
@@ -166,5 +128,5 @@ function Content(_ref) {
|
|
|
166
128
|
}
|
|
167
129
|
var _default = /*#__PURE__*/(0, _react.forwardRef)(WalletConnectionWrapper);
|
|
168
130
|
exports.default = _default;
|
|
169
|
-
|
|
131
|
+
const BaseWalletConnectionWrapper = /*#__PURE__*/(0, _react.forwardRef)(_BaseWalletConnectionWrapper);
|
|
170
132
|
exports.BaseWalletConnectionWrapper = BaseWalletConnectionWrapper;
|
|
@@ -14,11 +14,11 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
14
14
|
* This utilitary component shall be used to lock the focus and disable scroll over the wrapped component
|
|
15
15
|
**/
|
|
16
16
|
function ScrollAndFocusLock(_ref) {
|
|
17
|
-
|
|
17
|
+
let open = _ref.open,
|
|
18
18
|
children = _ref.children;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const firstAnchor = (0, _react.useRef)(null);
|
|
20
|
+
const lastAnchor = (0, _react.useRef)(null);
|
|
21
|
+
const startOfModal = (0, _react.useRef)(null);
|
|
22
22
|
(0, _react.useEffect)(function () {
|
|
23
23
|
if (open) startOfModal.current.focus();
|
|
24
24
|
}, []);
|
|
@@ -32,8 +32,8 @@ function ScrollAndFocusLock(_ref) {
|
|
|
32
32
|
}
|
|
33
33
|
}, [open]);
|
|
34
34
|
function onFocusAnchors(e) {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const focusOnStartOfModal = function focusOnStartOfModal() {
|
|
36
|
+
const nextSibling = firstAnchor.current.nextElementSibling;
|
|
37
37
|
if (nextSibling instanceof HTMLDivElement) nextSibling.focus();
|
|
38
38
|
};
|
|
39
39
|
if (e.target === firstAnchor.current) {
|
|
@@ -13,32 +13,31 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
13
13
|
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); }
|
|
14
14
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
15
15
|
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."); }
|
|
16
|
-
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; } }
|
|
17
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
19
16
|
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); }
|
|
20
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
17
|
+
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; }
|
|
18
|
+
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; } }
|
|
19
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
21
20
|
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; }
|
|
22
21
|
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; }
|
|
23
22
|
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; }
|
|
24
23
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
25
24
|
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); }
|
|
26
|
-
|
|
25
|
+
const AsyncProcessContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
27
26
|
function AsyncProcessProvider(_ref) {
|
|
28
|
-
|
|
27
|
+
let children = _ref.children,
|
|
29
28
|
triggers = _ref.triggers,
|
|
30
29
|
persistence = _ref.persistence;
|
|
31
|
-
|
|
30
|
+
const _useEvents = (0, _useEvents2.default)(),
|
|
32
31
|
subscriber = _useEvents.subscriber,
|
|
33
32
|
dispatcher = _useEvents.dispatcher;
|
|
34
|
-
|
|
33
|
+
const wrappedFunctions = (0, _react.useMemo)(function () {
|
|
35
34
|
return Object.keys(triggers).reduce(function (r, k) {
|
|
36
35
|
return _objectSpread(_objectSpread({}, r), {}, _defineProperty({}, k, function () {
|
|
37
36
|
var _ref2;
|
|
38
37
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
39
38
|
args[_key] = arguments[_key];
|
|
40
39
|
}
|
|
41
|
-
|
|
40
|
+
let persisted = persistence.write.apply(persistence, [k].concat(args));
|
|
42
41
|
return (_ref2 = triggers)[k].apply(_ref2, args).finally(function () {
|
|
43
42
|
persistence.remove(persisted);
|
|
44
43
|
dispatcher(k);
|
|
@@ -47,25 +46,14 @@ function AsyncProcessProvider(_ref) {
|
|
|
47
46
|
}, {});
|
|
48
47
|
}, []);
|
|
49
48
|
(0, _react.useEffect)(function () {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
recoveryProcess.finally(function () {
|
|
59
|
-
persistence.remove(recoveryId);
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
63
|
-
_loop();
|
|
64
|
-
}
|
|
65
|
-
} catch (err) {
|
|
66
|
-
_iterator.e(err);
|
|
67
|
-
} finally {
|
|
68
|
-
_iterator.f();
|
|
49
|
+
const recoveries = persistence.recover();
|
|
50
|
+
for (let _ref3 of recoveries) {
|
|
51
|
+
var _ref4 = _slicedToArray(_ref3, 2);
|
|
52
|
+
let recoveryId = _ref4[0];
|
|
53
|
+
let recoveryProcess = _ref4[1];
|
|
54
|
+
recoveryProcess.finally(function () {
|
|
55
|
+
persistence.remove(recoveryId);
|
|
56
|
+
});
|
|
69
57
|
}
|
|
70
58
|
}, []);
|
|
71
59
|
return /*#__PURE__*/_react.default.createElement(AsyncProcessContext.Provider, {
|
|
@@ -76,24 +64,13 @@ function AsyncProcessProvider(_ref) {
|
|
|
76
64
|
}, children);
|
|
77
65
|
}
|
|
78
66
|
function useAsyncProcess() {
|
|
79
|
-
|
|
67
|
+
const _useContext = (0, _react.useContext)(AsyncProcessContext),
|
|
80
68
|
subscriber = _useContext._subscriber,
|
|
81
69
|
_wrappedFunctions = _useContext._wrappedFunctions;
|
|
82
|
-
|
|
70
|
+
const subscriptions = (0, _react.useRef)([]);
|
|
83
71
|
(0, _react.useEffect)(function () {
|
|
84
72
|
return function () {
|
|
85
|
-
|
|
86
|
-
_step2;
|
|
87
|
-
try {
|
|
88
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
89
|
-
var unsubscribe = _step2.value;
|
|
90
|
-
unsubscribe();
|
|
91
|
-
}
|
|
92
|
-
} catch (err) {
|
|
93
|
-
_iterator2.e(err);
|
|
94
|
-
} finally {
|
|
95
|
-
_iterator2.f();
|
|
96
|
-
}
|
|
73
|
+
for (let unsubscribe of subscriptions.current) unsubscribe();
|
|
97
74
|
};
|
|
98
75
|
}, []);
|
|
99
76
|
return _objectSpread({
|
|
@@ -11,23 +11,23 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
11
11
|
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); }
|
|
12
12
|
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; }
|
|
13
13
|
function CustomBrowserRouter(_ref) {
|
|
14
|
-
|
|
14
|
+
let children = _ref.children,
|
|
15
15
|
_ref$beforeRouteChang = _ref.beforeRouteChange,
|
|
16
16
|
beforeRouteChange = _ref$beforeRouteChang === void 0 ? function (s) {
|
|
17
17
|
return s;
|
|
18
18
|
} : _ref$beforeRouteChang;
|
|
19
|
-
|
|
19
|
+
const _useRef = (0, _react.useRef)((0, _history.createBrowserHistory)()),
|
|
20
20
|
historyCustom = _useRef.current;
|
|
21
21
|
(0, _react.useLayoutEffect)(function () {
|
|
22
22
|
function overrideFunction(name) {
|
|
23
|
-
|
|
23
|
+
const orig = historyCustom[name];
|
|
24
24
|
historyCustom[name] = function (route, state) {
|
|
25
25
|
var _history$state, _history$state$state, _history$state2, _history$state2$state;
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const isReplacingAnInternalNavigation = name === "replace" && ((_history$state = history.state) === null || _history$state === void 0 ? void 0 : (_history$state$state = _history$state.state) === null || _history$state$state === void 0 ? void 0 : _history$state$state.internalNavigation);
|
|
27
|
+
const isARouteChange = name !== "replace";
|
|
28
28
|
if ((isARouteChange || isReplacingAnInternalNavigation) && !state) state = {};
|
|
29
29
|
if (state) state.internalNavigation = name === "replace" ? (_history$state2 = history.state) === null || _history$state2 === void 0 ? void 0 : (_history$state2$state = _history$state2.state) === null || _history$state2$state === void 0 ? void 0 : _history$state2$state.internalNavigation : true;
|
|
30
|
-
|
|
30
|
+
const modifiedRoute = beforeRouteChange(route, historyCustom);
|
|
31
31
|
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
32
32
|
args[_key - 2] = arguments[_key];
|
|
33
33
|
}
|
|
@@ -17,13 +17,13 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
17
17
|
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; }
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
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); }
|
|
20
|
-
|
|
20
|
+
const Context = /*#__PURE__*/(0, _react.createContext)(null);
|
|
21
21
|
function OneUIProvider(_ref) {
|
|
22
|
-
|
|
22
|
+
let children = _ref.children,
|
|
23
23
|
config = _ref.config;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const prevCtx = (0, _react.useContext)(Context);
|
|
25
|
+
const scale = (0, _useAdaptiveImage.default)();
|
|
26
|
+
const mergedConfig = (0, _react.useMemo)(function () {
|
|
27
27
|
return (0, _merge.default)((0, _cloneDeep.default)(prevCtx), config, {
|
|
28
28
|
state: {
|
|
29
29
|
imageScale: scale
|
|
@@ -35,7 +35,7 @@ function OneUIProvider(_ref) {
|
|
|
35
35
|
}, children);
|
|
36
36
|
}
|
|
37
37
|
function pathToJson(path, key) {
|
|
38
|
-
|
|
38
|
+
let exampleConfig = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "THE_MISSING_CONFIG";
|
|
39
39
|
if (!key) {
|
|
40
40
|
key = path.split(".").slice(-1)[0];
|
|
41
41
|
path = path.replace(".".concat(key), "");
|
|
@@ -48,7 +48,7 @@ function pathToJson(path, key) {
|
|
|
48
48
|
}, {});
|
|
49
49
|
}
|
|
50
50
|
function ErrorWrapper(originalObject) {
|
|
51
|
-
|
|
51
|
+
let path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "config";
|
|
52
52
|
return new Proxy(_typeof(originalObject) !== "object" ? {} : originalObject || {}, {
|
|
53
53
|
get: function get(_target, key) {
|
|
54
54
|
if (key === Symbol.toPrimitive) {
|
|
@@ -57,45 +57,45 @@ function ErrorWrapper(originalObject) {
|
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
try {
|
|
60
|
-
|
|
60
|
+
const value = originalObject[key];
|
|
61
61
|
if (typeof value === "undefined") return undefined;
|
|
62
62
|
if (_typeof(value) === "object") return ErrorWrapper(value, [path, key].filter(Boolean).join("."));
|
|
63
63
|
return value;
|
|
64
64
|
} catch (e) {
|
|
65
|
-
|
|
65
|
+
const pathJson = pathToJson(path, key);
|
|
66
66
|
throw new Error("A component is using the UI config ".concat([path, key].join("."), ".\n\nPlease define it using:\nimport OneUIProvider from \"@onepercent/one-ui/dist/context/OneUIProvider\";\n\n ...\n").concat("<OneUIProvider config={".concat(JSON.stringify(pathJson, null, 4), "}>\n...\n</OneUIProvider>").replace(/[ ]/g, "-")));
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
function useOneUIContext() {
|
|
72
|
-
|
|
72
|
+
const context = (0, _react.useContext)(Context);
|
|
73
73
|
if (process.env.NODE_ENV === "development") return ErrorWrapper(context);
|
|
74
74
|
return context;
|
|
75
75
|
}
|
|
76
76
|
function useOneUIView(oneuiConfigPath, componentName) {
|
|
77
|
-
|
|
77
|
+
const providedValue = useOneUIConfig(oneuiConfigPath);
|
|
78
78
|
if (!providedValue) {
|
|
79
79
|
throw new Error("The component ".concat(componentName, " requires a view to be set on OneUI initialization\n\nViews ready for use with this component shall be available at:\nimport SomeView from \"@onepercentio/one-ui/dist/components/").concat(componentName, "/View/SomeView\";\n \nPlease define it using:\nimport OneUIProvider from \"@onepercentio/one-ui/dist/context/OneUIProvider\";\n\n ...\n").concat("<OneUIProvider config={".concat(JSON.stringify(pathToJson(oneuiConfigPath, undefined, "SomeView"), null, 4), "}>\n...\n</OneUIProvider>").replace(/[ ]/g, "-")));
|
|
80
80
|
}
|
|
81
81
|
return providedValue;
|
|
82
82
|
}
|
|
83
83
|
function useOneUIConfig(prop, defaultValue) {
|
|
84
|
-
|
|
84
|
+
const context = (0, _react.useContext)(Context);
|
|
85
85
|
if (process.env.NODE_ENV === "development") {
|
|
86
|
-
|
|
86
|
+
const val = (0, _react.useMemo)(function () {
|
|
87
87
|
return (0, _get.default)(context, prop);
|
|
88
88
|
}, [context, prop]);
|
|
89
89
|
if (typeof val === "string" || typeof val === "function" || prop.endsWith(".Component") || prop.endsWith(".View")) return val || defaultValue;
|
|
90
90
|
if (typeof val === "boolean") return val;
|
|
91
91
|
return ErrorWrapper(val || defaultValue);
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
const value = (0, _react.useMemo)(function () {
|
|
94
94
|
return (0, _get.default)(context, prop);
|
|
95
95
|
}, [context, prop]);
|
|
96
96
|
return value || defaultValue;
|
|
97
97
|
}
|
|
98
98
|
function useCurrentImageScale() {
|
|
99
|
-
|
|
99
|
+
const context = (0, _react.useContext)(Context);
|
|
100
100
|
return context.state.imageScale;
|
|
101
101
|
}
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = useDependencyChangeDetection;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
function useDependencyChangeDetection(tag, dependencyArray) {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
for (let dependencyIndex in dependencyArray) {
|
|
10
|
+
const prevValue = (0, _react.useRef)();
|
|
11
11
|
(0, _react.useEffect)(function () {
|
|
12
12
|
if (!prevValue.current) return;
|
|
13
13
|
if (process.env.NODE_ENV === "development") require('../../models/DebugLogger').default("".concat(useDependencyChangeDetection.name, ":").concat(tag), "Element index ".concat(dependencyIndex, " (prev: ").concat(JSON.stringify(prevValue.current), ") (new: ").concat(JSON.stringify(dependencyArray[dependencyIndex]), ") has changed"));
|
|
@@ -15,8 +15,5 @@ function useDependencyChangeDetection(tag, dependencyArray) {
|
|
|
15
15
|
(0, _react.useEffect)(function () {
|
|
16
16
|
prevValue.current = dependencyArray[dependencyIndex];
|
|
17
17
|
}, [dependencyArray[dependencyIndex]]);
|
|
18
|
-
};
|
|
19
|
-
for (var dependencyIndex in dependencyArray) {
|
|
20
|
-
_loop(dependencyIndex);
|
|
21
18
|
}
|
|
22
19
|
}
|
|
@@ -8,12 +8,12 @@ var _react = require("react");
|
|
|
8
8
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
9
|
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."); }
|
|
10
10
|
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); }
|
|
11
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
12
|
-
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)
|
|
11
|
+
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; }
|
|
12
|
+
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; } }
|
|
13
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
14
|
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); }
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const DUD = _typeof("");
|
|
16
|
+
const toString = function toString(val) {
|
|
17
17
|
switch (_typeof(val)) {
|
|
18
18
|
case "boolean":
|
|
19
19
|
return !val ? "0" : "1";
|
|
@@ -23,7 +23,7 @@ var toString = function toString(val) {
|
|
|
23
23
|
throw new Error("Doesn't know how to handle type " + _typeof(val));
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
|
|
26
|
+
const fromString = function fromString(type, value) {
|
|
27
27
|
switch (type) {
|
|
28
28
|
case "boolean":
|
|
29
29
|
return value === "1";
|
|
@@ -34,8 +34,8 @@ var fromString = function fromString(type, value) {
|
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
function useLocalStorage(id, defaultValue) {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const _useState = (0, _react.useState)(function () {
|
|
38
|
+
const persistedValue = localStorage.getItem(id);
|
|
39
39
|
if (persistedValue === null) return defaultValue;
|
|
40
40
|
return fromString(_typeof(defaultValue), persistedValue);
|
|
41
41
|
}),
|
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
7
|
-
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); }
|
|
8
|
-
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; }
|
|
9
6
|
// @ts-nocheck
|
|
10
7
|
// object.watch
|
|
11
8
|
if (!Object.prototype.watch) {
|
|
@@ -22,18 +19,7 @@ if (!Object.prototype.watch) {
|
|
|
22
19
|
var _this2 = this;
|
|
23
20
|
if (this._watchTimer) clearTimeout(this._watchTimer);
|
|
24
21
|
this._watchTimer = setTimeout(function () {
|
|
25
|
-
|
|
26
|
-
_step;
|
|
27
|
-
try {
|
|
28
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
29
|
-
var _handler = _step.value;
|
|
30
|
-
_handler.call();
|
|
31
|
-
}
|
|
32
|
-
} catch (err) {
|
|
33
|
-
_iterator.e(err);
|
|
34
|
-
} finally {
|
|
35
|
-
_iterator.f();
|
|
36
|
-
}
|
|
22
|
+
for (let handler of _this2._handlers) handler.call();
|
|
37
23
|
clearTimeout(_this2._watchTimer);
|
|
38
24
|
delete _this2._watchTimer;
|
|
39
25
|
}, 0);
|
|
@@ -11,8 +11,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
11
11
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
12
12
|
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."); }
|
|
13
13
|
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); }
|
|
14
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
15
|
-
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)
|
|
14
|
+
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; }
|
|
15
|
+
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; } }
|
|
16
16
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
17
|
/**
|
|
18
18
|
* This hooks is built over the implementation of this loader https://github.com/Muritavo/webpack-microfrontend-scripts#imageresolutionoptimizer
|
|
@@ -21,23 +21,23 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
21
21
|
function useAdaptiveImage() {
|
|
22
22
|
function ScaleFromCurrentWidth() {
|
|
23
23
|
if (window.PRERENDER) return _ImageScales.ImageScales.LARGE;
|
|
24
|
-
|
|
24
|
+
const width = window.visualViewport.width;
|
|
25
25
|
if (width < 480) return _ImageScales.ImageScales.SMALL;
|
|
26
26
|
if (width < 800) return _ImageScales.ImageScales.NORMAL;
|
|
27
27
|
if (width < 1280) return _ImageScales.ImageScales.BIG;
|
|
28
28
|
if (width < 1920) return _ImageScales.ImageScales.LARGE;else return _ImageScales.ImageScales.EXTRA_LARGE;
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
const _useState = (0, _react.useState)(function () {
|
|
31
31
|
return ScaleFromCurrentWidth();
|
|
32
32
|
}),
|
|
33
33
|
_useState2 = _slicedToArray(_useState, 2),
|
|
34
34
|
currentScale = _useState2[0],
|
|
35
35
|
setCurrentScale = _useState2[1];
|
|
36
36
|
(0, _react.useEffect)(function () {
|
|
37
|
-
|
|
37
|
+
const onResizeThrottle = (0, _throttle.default)(function () {
|
|
38
38
|
setCurrentScale(ScaleFromCurrentWidth());
|
|
39
39
|
}, 1000 / 4);
|
|
40
|
-
|
|
40
|
+
const onResize = function onResize() {
|
|
41
41
|
return onResizeThrottle();
|
|
42
42
|
};
|
|
43
43
|
window.addEventListener("resize", onResize);
|