@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.
Files changed (124) hide show
  1. package/.babelrc +6 -0
  2. package/.prod.babelrc +8 -2
  3. package/dist/assets/styles/variables.scss +1 -0
  4. package/dist/components/AdaptiveButton/AdaptiveButton.js +2 -2
  5. package/dist/components/AdaptiveContainer/AdaptiveContainer.js +28 -26
  6. package/dist/components/AdaptiveContainer/AdaptiveContainer.module.scss +3 -1
  7. package/dist/components/AdaptiveDialog/AdaptiveDialog.js +9 -9
  8. package/dist/components/AdaptiveSidebar/AdaptiveSidebar.js +14 -14
  9. package/dist/components/AnchoredTooltip/AnchoredTooltip.js +30 -30
  10. package/dist/components/AnimatedEntrance/AnimatedEntrance.d.ts +1 -1
  11. package/dist/components/AnimatedEntrance/AnimatedEntrance.js +34 -45
  12. package/dist/components/AsyncWrapper/AsyncWrapper.js +2 -2
  13. package/dist/components/Avatar/Avatar.js +4 -4
  14. package/dist/components/BucketFill/BucketFill.js +9 -9
  15. package/dist/components/Button/Button.js +4 -4
  16. package/dist/components/Card/Card.js +1 -1
  17. package/dist/components/Chart/Chart.view.js +34 -34
  18. package/dist/components/CheckBox/CheckBox.js +3 -3
  19. package/dist/components/Collapsable/Collapsable.js +18 -18
  20. package/dist/components/Countdown/Countdown.js +16 -16
  21. package/dist/components/Divider/Divider.js +1 -1
  22. package/dist/components/EmailInput/EmailInput.d.ts +1 -1
  23. package/dist/components/EmailInput/EmailInput.js +4 -4
  24. package/dist/components/FadeIn/FadeIn.js +9 -9
  25. package/dist/components/FileInput/FileInput.js +6 -6
  26. package/dist/components/FileInput/View/BigFactory/BigFactory.js +1 -1
  27. package/dist/components/FileInput/View/Compact/Compact.js +6 -6
  28. package/dist/components/FlowController/FlowController.js +4 -4
  29. package/dist/components/Form/Form.js +17 -28
  30. package/dist/components/Freeze/Freeze.js +1 -1
  31. package/dist/components/HSForms/HSForms.js +9 -11
  32. package/dist/components/Header/Header.js +7 -7
  33. package/dist/components/HeaderCloseBtn/HeaderCloseBtn.js +1 -1
  34. package/dist/components/InfinityScroll/InfinityScroll.js +25 -25
  35. package/dist/components/Input/Input.js +13 -13
  36. package/dist/components/InstantCounter/InstantCounter.js +9 -9
  37. package/dist/components/LavaLamp/LavaLamp.data.js +25 -25
  38. package/dist/components/LavaLamp/LavaLamp.js +7 -7
  39. package/dist/components/LavaLamp/v2/LavaLamp.js +29 -45
  40. package/dist/components/LinkToId/LinkToId.js +7 -7
  41. package/dist/components/Loader/Loader.js +2 -2
  42. package/dist/components/LoaderDotsIndicator/LoaderDotsIndicator.js +6 -6
  43. package/dist/components/LoopableVideo/LoopableVideo.js +4 -4
  44. package/dist/components/MainGrid/MainGrid.js +2 -2
  45. package/dist/components/MutableHamburgerButton/MutableHamburgerButton.js +2 -2
  46. package/dist/components/Notification/Notification.js +1 -1
  47. package/dist/components/OrderableList/OrderableList.js +113 -138
  48. package/dist/components/PaginationIndicator/PaginationIndicator.js +50 -50
  49. package/dist/components/Parallax/Parallax.js +39 -39
  50. package/dist/components/Parallax/math/helpers.js +18 -19
  51. package/dist/components/PasswordInput/PasswordInput.d.ts +1 -1
  52. package/dist/components/PasswordInput/PasswordInput.js +10 -10
  53. package/dist/components/PingPongText/PingPongText.js +15 -15
  54. package/dist/components/PixelatedScan/PixelatedScan.js +19 -19
  55. package/dist/components/Portal/Portal.js +10 -10
  56. package/dist/components/ProgressBar/ProgressBar.js +6 -6
  57. package/dist/components/ProgressTexts/ProgressTexts.js +3 -3
  58. package/dist/components/Radio/Radio.js +3 -3
  59. package/dist/components/SectionContainer/SectionContainer.js +1 -1
  60. package/dist/components/Select/Select.js +13 -13
  61. package/dist/components/Select/Select.module.scss +8 -5
  62. package/dist/components/Skeleton/Skeleton.js +1 -1
  63. package/dist/components/Spacing/Spacing.js +1 -1
  64. package/dist/components/StaticScroller/StaticScroller.js +12 -12
  65. package/dist/components/Switch/Switch.js +2 -2
  66. package/dist/components/Table/Table.js +11 -11
  67. package/dist/components/Tabs/Tabs.d.ts +6 -1
  68. package/dist/components/Tabs/Tabs.js +28 -9
  69. package/dist/components/Tabs/Tabs.module.scss +20 -2
  70. package/dist/components/Text/Text.js +5 -5
  71. package/dist/components/Transition/MasksFactory/DiagonalReveal.js +5 -5
  72. package/dist/components/Transition/MasksFactory/DiagonalSquareToBalls.js +17 -17
  73. package/dist/components/Transition/MasksFactory/PhysicsSquares.js +13 -13
  74. package/dist/components/Transition/MasksFactory/SquareToBalls.js +9 -9
  75. package/dist/components/Transition/MasksFactory/utils.js +8 -8
  76. package/dist/components/Transition/Transition.js +49 -49
  77. package/dist/components/UncontrolledTransition/UncontrolledTransition.js +7 -7
  78. package/dist/components/WalletConnectionWrapper/WalletConnectionWrapper.js +44 -82
  79. package/dist/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.js +6 -6
  80. package/dist/context/AsyncProcess.js +19 -42
  81. package/dist/context/CustomBrowserRouter.js +6 -6
  82. package/dist/context/OneUIProvider.js +15 -15
  83. package/dist/hooks/logs/useDependencyChangeDetection.js +2 -5
  84. package/dist/hooks/persistence/useLocalStorage.js +7 -7
  85. package/dist/hooks/shims/ObjectWatchShim.js +1 -15
  86. package/dist/hooks/ui/useAdaptiveImage.js +6 -6
  87. package/dist/hooks/ui/useBreakpoint.js +5 -5
  88. package/dist/hooks/ui/useCustomScrollbar.js +2 -2
  89. package/dist/hooks/ui/useMouseHover.js +4 -4
  90. package/dist/hooks/ui/usePaginationControls.js +34 -34
  91. package/dist/hooks/ui/useSnapToViewport.js +3 -3
  92. package/dist/hooks/ui/useTilt.js +38 -38
  93. package/dist/hooks/ui/useZoomable.js +20 -20
  94. package/dist/hooks/useAsyncControl.js +21 -38
  95. package/dist/hooks/useContainedRepositioning.js +22 -22
  96. package/dist/hooks/useCustomHistory.js +2 -2
  97. package/dist/hooks/useElementFit.js +6 -6
  98. package/dist/hooks/useFirestoreWatch.js +26 -39
  99. package/dist/hooks/useForm.js +8 -8
  100. package/dist/hooks/useFreeze.js +1 -1
  101. package/dist/hooks/useHero.d.ts +1 -0
  102. package/dist/hooks/useHero.js +132 -91
  103. package/dist/hooks/useHero.module.scss +7 -0
  104. package/dist/hooks/useIntersection.js +3 -3
  105. package/dist/hooks/useMergeRefs.js +3 -7
  106. package/dist/hooks/useObserve.js +5 -5
  107. package/dist/hooks/usePagination.js +39 -59
  108. package/dist/hooks/usePooledOperation.js +8 -22
  109. package/dist/hooks/usePooling.js +17 -33
  110. package/dist/hooks/useRebound.js +5 -5
  111. package/dist/hooks/useShortIntl.js +13 -13
  112. package/dist/hooks/utility/useEvents.js +5 -5
  113. package/dist/hooks/utility/useModule.js +3 -3
  114. package/dist/hooks/utility/useQuery.js +1 -1
  115. package/dist/models/DebugLogger.js +2 -2
  116. package/dist/models/GenericContract.js +1 -1
  117. package/dist/storybookUtils/index.js +1 -1
  118. package/dist/types.d.ts +11 -4
  119. package/dist/utility.d.js +3 -3
  120. package/dist/utils/blockchain.js +29 -102
  121. package/dist/utils/flatten.js +3 -3
  122. package/dist/utils/html.utils.js +1 -1
  123. package/package.json +2 -1
  124. package/src/types.ts +155 -41
package/dist/types.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- declare type PrependNextNum<A extends Array<unknown>> = A['length'] extends infer T ? ((t: T, ...a: A) => void) extends ((...x: infer X) => void) ? X : never : never;
1
+ declare type PrependNextNum<A extends Array<unknown>> = A["length"] extends infer T ? ((t: T, ...a: A) => void) extends (...x: infer X) => void ? X : never : never;
2
2
  declare type EnumerateInternal<A extends Array<unknown>, N extends number> = {
3
3
  0: A;
4
4
  1: EnumerateInternal<PrependNextNum<A>, N>;
5
- }[N extends A['length'] ? 0 : 1];
6
- export declare type Enumerate<N extends number> = EnumerateInternal<[], N> extends (infer E)[] ? E : never;
5
+ }[N extends A["length"] ? 0 : 1];
6
+ export declare type Enumerate<N extends number> = EnumerateInternal<[
7
+ ], N> extends (infer E)[] ? E : never;
7
8
  export declare type Range<FROM extends number, TO extends number> = Exclude<Enumerate<TO>, Enumerate<FROM>>;
8
9
  export declare type CommonErrorCodes = "UNEXPECTED_ERROR";
9
10
  export declare type BasicContext<T extends object> = {
@@ -46,7 +47,7 @@ export declare type DeepMap<T, TValue> = {
46
47
  [K in keyof T]?: IsAny<T[K]> extends true ? any : NonNullable<T[K]> extends NestedValue | Date | FileList | File ? TValue : NonUndefined<T[K]> extends object | null ? DeepMap<T[K], TValue> : NonUndefined<T[K]> extends Array<infer U> ? IsAny<U> extends true ? Array<any> : U extends NestedValue | Date | FileList ? Array<TValue> : U extends object ? Array<DeepMap<U, TValue>> : Array<TValue> : TValue;
47
48
  };
48
49
  export declare type IsFlatObject<T extends object> = Extract<Exclude<T[keyof T], NestedValue | Date | FileList>, any[] | object> extends never ? true : false;
49
- declare type IsTuple<T extends ReadonlyArray<any>> = number extends T['length'] ? false : true;
50
+ declare type IsTuple<T extends ReadonlyArray<any>> = number extends T["length"] ? false : true;
50
51
  declare type TupleKey<T extends ReadonlyArray<any>> = Exclude<keyof T, keyof any[]>;
51
52
  declare type ArrayKey = number;
52
53
  declare type PathImpl<K extends string | number, V> = V extends Primitive ? `${K}` : `${K}.${Path<V>}`;
@@ -69,4 +70,10 @@ export declare type FieldArrayPathValue<TFieldValues extends FieldValues, TField
69
70
  export declare type FieldPathValues<TFieldValues extends FieldValues, TPath extends FieldPath<TFieldValues>[] | readonly FieldPath<TFieldValues>[]> = {} & {
70
71
  [K in keyof TPath]: FieldPathValue<TFieldValues, TPath[K] & FieldPath<TFieldValues>>;
71
72
  };
73
+ export declare type ToFirebaseType<B> = {
74
+ [k in keyof B]: B[k] extends Date ? import("firebase/firestore").Timestamp : B[k] extends Object ? ToFirebaseType<B[k]> : B[k];
75
+ };
76
+ export declare type FromFirebaseType<B> = {
77
+ [k in keyof B]: B[k] extends import("firebase/firestore").Timestamp ? Date : B[k] extends Object ? FromFirebaseType<B[k]> : B[k];
78
+ };
72
79
  export {};
package/dist/utility.d.js CHANGED
@@ -5,13 +5,13 @@
5
5
  *
6
6
  * Redeclare this namespace with the usefull typings for your project and enjoy intelisense :)
7
7
  */
8
- var OnepercentUtility;
8
+ let OnepercentUtility;
9
9
  (function (_OnepercentUtility) {
10
10
  /** The ids used by the useShortIntl hooks */
11
11
  /** A type hint to bind the LinkToId action and the SectionContainer identifier */
12
12
  /** A type hint to autocomplete functions related to the AsyncProcess context */
13
- var AsyncQueue;
13
+ let AsyncQueue;
14
14
  (function (_AsyncQueue) {})(AsyncQueue || (AsyncQueue = {}));
15
- var UIElements;
15
+ let UIElements;
16
16
  (function (_UIElements) {})(UIElements || (UIElements = {}));
17
17
  })(OnepercentUtility || (OnepercentUtility = {}));
@@ -7,105 +7,47 @@ exports.dispatchAndWait = dispatchAndWait;
7
7
  exports.isTransactionMined = isTransactionMined;
8
8
  exports.sendAndWaitForConfirmation = sendAndWaitForConfirmation;
9
9
  exports.waitForConfirmation = waitForConfirmation;
10
- 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); }
11
- 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; }
12
10
  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); } }
13
11
  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); }); }; }
14
12
  function isTransactionMined(_x, _x2) {
15
13
  return _isTransactionMined.apply(this, arguments);
16
14
  }
17
15
  function _isTransactionMined() {
18
- _isTransactionMined = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(transactionHash, provider) {
19
- var transaction;
20
- return _regeneratorRuntime().wrap(function _callee$(_context) {
21
- while (1) {
22
- switch (_context.prev = _context.next) {
23
- case 0:
24
- _context.next = 2;
25
- return provider.eth.getTransactionReceipt(transactionHash);
26
- case 2:
27
- transaction = _context.sent;
28
- if (!(!transaction || !transaction.blockHash || transaction.status === undefined)) {
29
- _context.next = 7;
30
- break;
31
- }
32
- return _context.abrupt("return", undefined);
33
- case 7:
34
- return _context.abrupt("return", !!transaction.status === true);
35
- case 8:
36
- case "end":
37
- return _context.stop();
38
- }
39
- }
40
- }, _callee);
41
- }));
16
+ _isTransactionMined = _asyncToGenerator(function* (transactionHash, provider) {
17
+ const transaction = yield provider.eth.getTransactionReceipt(transactionHash);
18
+ if (!transaction || !transaction.blockHash || transaction.status === undefined) return undefined; // I still don't know if it's loaded
19
+ else return !!transaction.status === true;
20
+ });
42
21
  return _isTransactionMined.apply(this, arguments);
43
22
  }
44
23
  function waitForConfirmation(_x3, _x4) {
45
24
  return _waitForConfirmation.apply(this, arguments);
46
25
  }
47
26
  function _waitForConfirmation() {
48
- _waitForConfirmation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(tHash, provider) {
49
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
50
- while (1) {
51
- switch (_context3.prev = _context3.next) {
52
- case 0:
53
- return _context3.abrupt("return", new Promise( /*#__PURE__*/function () {
54
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(r, rej) {
55
- var bought;
56
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
57
- while (1) {
58
- switch (_context2.prev = _context2.next) {
59
- case 0:
60
- if (!true) {
61
- _context2.next = 13;
62
- break;
63
- }
64
- _context2.next = 3;
65
- return isTransactionMined(tHash, provider);
66
- case 3:
67
- bought = _context2.sent;
68
- if (!(bought === undefined)) {
69
- _context2.next = 9;
70
- break;
71
- }
72
- _context2.next = 7;
73
- return new Promise(function (r) {
74
- return setTimeout(function () {
75
- return r();
76
- }, 2000);
77
- });
78
- case 7:
79
- _context2.next = 11;
80
- break;
81
- case 9:
82
- if (bought) r();else rej('TRANSACTION_FAILED');
83
- return _context2.abrupt("break", 13);
84
- case 11:
85
- _context2.next = 0;
86
- break;
87
- case 13:
88
- case "end":
89
- return _context2.stop();
90
- }
91
- }
92
- }, _callee2);
93
- }));
94
- return function (_x7, _x8) {
95
- return _ref.apply(this, arguments);
96
- };
97
- }()));
98
- case 1:
99
- case "end":
100
- return _context3.stop();
27
+ _waitForConfirmation = _asyncToGenerator(function* (tHash, provider) {
28
+ return new Promise( /*#__PURE__*/function () {
29
+ var _ref = _asyncToGenerator(function* (r, rej) {
30
+ while (true) {
31
+ const bought = yield isTransactionMined(tHash, provider);
32
+ if (bought === undefined) yield new Promise(function (r) {
33
+ return setTimeout(function () {
34
+ return r();
35
+ }, 2000);
36
+ });else {
37
+ if (bought) r();else rej('TRANSACTION_FAILED');
38
+ break;
39
+ }
101
40
  }
102
- }
103
- }, _callee3);
104
- }));
41
+ });
42
+ return function (_x7, _x8) {
43
+ return _ref.apply(this, arguments);
44
+ };
45
+ }());
46
+ });
105
47
  return _waitForConfirmation.apply(this, arguments);
106
48
  }
107
49
  function dispatchAndWait(func) {
108
- var _func = func;
50
+ const _func = func;
109
51
  return new Promise(function (r, rej) {
110
52
  _func.on('transactionHash', function (tX) {
111
53
  r(tX);
@@ -117,24 +59,9 @@ function sendAndWaitForConfirmation(_x5, _x6) {
117
59
  return _sendAndWaitForConfirmation.apply(this, arguments);
118
60
  }
119
61
  function _sendAndWaitForConfirmation() {
120
- _sendAndWaitForConfirmation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(func, provider) {
121
- var tHash;
122
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
123
- while (1) {
124
- switch (_context4.prev = _context4.next) {
125
- case 0:
126
- _context4.next = 2;
127
- return dispatchAndWait(func);
128
- case 2:
129
- tHash = _context4.sent;
130
- _context4.next = 5;
131
- return waitForConfirmation(tHash, provider);
132
- case 5:
133
- case "end":
134
- return _context4.stop();
135
- }
136
- }
137
- }, _callee4);
138
- }));
62
+ _sendAndWaitForConfirmation = _asyncToGenerator(function* (func, provider) {
63
+ const tHash = yield dispatchAndWait(func);
64
+ yield waitForConfirmation(tHash, provider);
65
+ });
139
66
  return _sendAndWaitForConfirmation.apply(this, arguments);
140
67
  }
@@ -13,12 +13,12 @@ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread n
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
14
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
15
15
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
16
- 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; }
16
+ 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; }
17
17
  function flatten(obj) {
18
18
  return Object.assign.apply(Object, [{}].concat(_toConsumableArray(function _flatten(o, _ref) {
19
- var prevKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
19
+ let prevKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
20
20
  return (_ref = []).concat.apply(_ref, _toConsumableArray(Object.keys(o).map(function (_k) {
21
- var k = _k;
21
+ const k = _k;
22
22
  return _typeof(o[k]) === "object" ? _flatten(o[k], prevKey ? "".concat(prevKey, ".").concat(k) : k) : _defineProperty({}, prevKey ? "".concat(prevKey, ".").concat(k) : k, o[k]);
23
23
  })));
24
24
  }(obj))));
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.isSameTarget = isSameTarget;
7
7
  function isSameTarget(_ref) {
8
- var target = _ref.target,
8
+ let target = _ref.target,
9
9
  currentTarget = _ref.currentTarget;
10
10
  return target === currentTarget;
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onepercentio/one-ui",
3
- "version": "0.20.4",
3
+ "version": "0.21.0",
4
4
  "description": "A set of reusable components created through the development of Onepercent projects",
5
5
  "repository": "git@github.com:onepercentio/one-ui.git",
6
6
  "author": "Murilo Oliveira de Araujo <murilo.araujo@onepercent.io>",
@@ -40,6 +40,7 @@
40
40
  "babel-plugin-remove-unused-vars": "2.2.0",
41
41
  "buffer": "^6.0.3",
42
42
  "chroma-js": "^2.4.2",
43
+ "color-seed": "^1.1.3",
43
44
  "cpy-cli": "^3.1.1",
44
45
  "crypto-browserify": "^3.12.0",
45
46
  "css-loader": "^5",
package/src/types.ts CHANGED
@@ -1,10 +1,25 @@
1
- type PrependNextNum<A extends Array<unknown>> = A['length'] extends infer T ? ((t: T, ...a: A) => void) extends ((...x: infer X) => void) ? X : never : never;
1
+ type PrependNextNum<A extends Array<unknown>> = A["length"] extends infer T
2
+ ? ((t: T, ...a: A) => void) extends (...x: infer X) => void
3
+ ? X
4
+ : never
5
+ : never;
2
6
 
3
- type EnumerateInternal<A extends Array<unknown>, N extends number> = { 0: A, 1: EnumerateInternal<PrependNextNum<A>, N> }[N extends A['length'] ? 0 : 1];
7
+ type EnumerateInternal<A extends Array<unknown>, N extends number> = {
8
+ 0: A;
9
+ 1: EnumerateInternal<PrependNextNum<A>, N>;
10
+ }[N extends A["length"] ? 0 : 1];
4
11
 
5
- export type Enumerate<N extends number> = EnumerateInternal<[], N> extends (infer E)[] ? E : never;
12
+ export type Enumerate<N extends number> = EnumerateInternal<
13
+ [],
14
+ N
15
+ > extends (infer E)[]
16
+ ? E
17
+ : never;
6
18
 
7
- export type Range<FROM extends number, TO extends number> = Exclude<Enumerate<TO>, Enumerate<FROM>>;
19
+ export type Range<FROM extends number, TO extends number> = Exclude<
20
+ Enumerate<TO>,
21
+ Enumerate<FROM>
22
+ >;
8
23
 
9
24
  export type CommonErrorCodes = "UNEXPECTED_ERROR";
10
25
 
@@ -37,49 +52,148 @@ declare global {
37
52
  type NestedValue = unknown;
38
53
  type FieldValues = unknown;
39
54
 
40
- export declare type Primitive = null | undefined | string | number | boolean | symbol | bigint;
55
+ export declare type Primitive =
56
+ | null
57
+ | undefined
58
+ | string
59
+ | number
60
+ | boolean
61
+ | symbol
62
+ | bigint;
41
63
  export declare type EmptyObject = {
42
64
  [K in string | number]: never;
43
65
  };
44
66
  export declare type NonUndefined<T> = T extends undefined ? never : T;
45
- export declare type LiteralUnion<T extends U, U extends Primitive> = T | (U & {
46
- _?: never;
47
- });
48
- export declare type DeepPartial<T> = T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {
49
- [key in keyof T]: T[key];
50
- } ? {
51
- [K in keyof T]?: DeepPartial<T[K]>;
52
- } : T;
53
- export declare type IsAny<T> = boolean extends (T extends never ? true : false) ? true : false;
67
+ export declare type LiteralUnion<T extends U, U extends Primitive> =
68
+ | T
69
+ | (U & {
70
+ _?: never;
71
+ });
72
+ export declare type DeepPartial<T> = T extends Array<infer U>
73
+ ? Array<DeepPartial<U>>
74
+ : T extends ReadonlyArray<infer U>
75
+ ? ReadonlyArray<DeepPartial<U>>
76
+ : T extends {
77
+ [key in keyof T]: T[key];
78
+ }
79
+ ? {
80
+ [K in keyof T]?: DeepPartial<T[K]>;
81
+ }
82
+ : T;
83
+ export declare type IsAny<T> = boolean extends (T extends never ? true : false)
84
+ ? true
85
+ : false;
54
86
  export declare type DeepMap<T, TValue> = {
55
- [K in keyof T]?: IsAny<T[K]> extends true ? any : NonNullable<T[K]> extends NestedValue | Date | FileList | File ? TValue : NonUndefined<T[K]> extends object | null ? DeepMap<T[K], TValue> : NonUndefined<T[K]> extends Array<infer U> ? IsAny<U> extends true ? Array<any> : U extends NestedValue | Date | FileList ? Array<TValue> : U extends object ? Array<DeepMap<U, TValue>> : Array<TValue> : TValue;
87
+ [K in keyof T]?: IsAny<T[K]> extends true
88
+ ? any
89
+ : NonNullable<T[K]> extends NestedValue | Date | FileList | File
90
+ ? TValue
91
+ : NonUndefined<T[K]> extends object | null
92
+ ? DeepMap<T[K], TValue>
93
+ : NonUndefined<T[K]> extends Array<infer U>
94
+ ? IsAny<U> extends true
95
+ ? Array<any>
96
+ : U extends NestedValue | Date | FileList
97
+ ? Array<TValue>
98
+ : U extends object
99
+ ? Array<DeepMap<U, TValue>>
100
+ : Array<TValue>
101
+ : TValue;
56
102
  };
57
- export declare type IsFlatObject<T extends object> = Extract<Exclude<T[keyof T], NestedValue | Date | FileList>, any[] | object> extends never ? true : false;
58
- declare type IsTuple<T extends ReadonlyArray<any>> = number extends T['length'] ? false : true;
59
- declare type TupleKey<T extends ReadonlyArray<any>> = Exclude<keyof T, keyof any[]>;
103
+ export declare type IsFlatObject<T extends object> = Extract<
104
+ Exclude<T[keyof T], NestedValue | Date | FileList>,
105
+ any[] | object
106
+ > extends never
107
+ ? true
108
+ : false;
109
+ declare type IsTuple<T extends ReadonlyArray<any>> = number extends T["length"]
110
+ ? false
111
+ : true;
112
+ declare type TupleKey<T extends ReadonlyArray<any>> = Exclude<
113
+ keyof T,
114
+ keyof any[]
115
+ >;
60
116
  declare type ArrayKey = number;
61
- declare type PathImpl<K extends string | number, V> = V extends Primitive ? `${K}` : `${K}.${Path<V>}`;
117
+ declare type PathImpl<K extends string | number, V> = V extends Primitive
118
+ ? `${K}`
119
+ : `${K}.${Path<V>}`;
62
120
  export declare type Path<T> = T extends ReadonlyArray<infer V>
63
- ?
64
- IsTuple<T> extends true
65
- ? {
66
- [K in TupleKey<T>]-?: PathImpl<K & string, T[K]>;
67
- }[TupleKey<T>]
68
- : PathImpl<ArrayKey, V>
121
+ ? IsTuple<T> extends true
122
+ ? {
123
+ [K in TupleKey<T>]-?: PathImpl<K & string, T[K]>;
124
+ }[TupleKey<T>]
125
+ : PathImpl<ArrayKey, V>
126
+ : {
127
+ [K in keyof T]-?: PathImpl<K & string, T[K]>;
128
+ }[keyof T];
129
+ export declare type FieldPath<TFieldValues extends FieldValues> =
130
+ Path<TFieldValues>;
131
+ declare type ArrayPathImpl<K extends string | number, V> = V extends Primitive
132
+ ? never
133
+ : V extends ReadonlyArray<infer U>
134
+ ? U extends Primitive
135
+ ? never
136
+ : `${K}` | `${K}.${ArrayPath<V>}`
137
+ : `${K}.${ArrayPath<V>}`;
138
+ export declare type ArrayPath<T> = T extends ReadonlyArray<infer V>
139
+ ? IsTuple<T> extends true
140
+ ? {
141
+ [K in TupleKey<T>]-?: ArrayPathImpl<K & string, T[K]>;
142
+ }[TupleKey<T>]
143
+ : ArrayPathImpl<ArrayKey, V>
69
144
  : {
70
- [K in keyof T]-?: PathImpl<K & string, T[K]>;
71
- }[keyof T];
72
- export declare type FieldPath<TFieldValues extends FieldValues> = Path<TFieldValues>;
73
- declare type ArrayPathImpl<K extends string | number, V> = V extends Primitive ? never : V extends ReadonlyArray<infer U> ? U extends Primitive ? never : `${K}` | `${K}.${ArrayPath<V>}` : `${K}.${ArrayPath<V>}`;
74
- export declare type ArrayPath<T> = T extends ReadonlyArray<infer V> ? IsTuple<T> extends true ? {
75
- [K in TupleKey<T>]-?: ArrayPathImpl<K & string, T[K]>;
76
- }[TupleKey<T>] : ArrayPathImpl<ArrayKey, V> : {
77
- [K in keyof T]-?: ArrayPathImpl<K & string, T[K]>;
78
- }[keyof T];
79
- export declare type FieldArrayPath<TFieldValues extends FieldValues> = ArrayPath<TFieldValues>;
80
- export declare type PathValue<T, P extends Path<T> | ArrayPath<T>> = P extends `${infer K}.${infer R}` ? K extends keyof T ? R extends Path<T[K]> ? PathValue<T[K], R> : never : K extends `${ArrayKey}` ? T extends ReadonlyArray<infer V> ? PathValue<V, R & Path<V>> : never : never : P extends keyof T ? T[P] : P extends `${ArrayKey}` ? T extends ReadonlyArray<infer V> ? V : never : never;
81
- export declare type FieldPathValue<TFieldValues extends FieldValues, TFieldPath extends FieldPath<TFieldValues>> = PathValue<TFieldValues, TFieldPath>;
82
- export declare type FieldArrayPathValue<TFieldValues extends FieldValues, TFieldArrayPath extends FieldArrayPath<TFieldValues>> = PathValue<TFieldValues, TFieldArrayPath>;
83
- export declare type FieldPathValues<TFieldValues extends FieldValues, TPath extends FieldPath<TFieldValues>[] | readonly FieldPath<TFieldValues>[]> = {} & {
84
- [K in keyof TPath]: FieldPathValue<TFieldValues, TPath[K] & FieldPath<TFieldValues>>;
85
- };
145
+ [K in keyof T]-?: ArrayPathImpl<K & string, T[K]>;
146
+ }[keyof T];
147
+ export declare type FieldArrayPath<TFieldValues extends FieldValues> =
148
+ ArrayPath<TFieldValues>;
149
+ export declare type PathValue<T, P extends Path<T> | ArrayPath<T>> =
150
+ P extends `${infer K}.${infer R}`
151
+ ? K extends keyof T
152
+ ? R extends Path<T[K]>
153
+ ? PathValue<T[K], R>
154
+ : never
155
+ : K extends `${ArrayKey}`
156
+ ? T extends ReadonlyArray<infer V>
157
+ ? PathValue<V, R & Path<V>>
158
+ : never
159
+ : never
160
+ : P extends keyof T
161
+ ? T[P]
162
+ : P extends `${ArrayKey}`
163
+ ? T extends ReadonlyArray<infer V>
164
+ ? V
165
+ : never
166
+ : never;
167
+ export declare type FieldPathValue<
168
+ TFieldValues extends FieldValues,
169
+ TFieldPath extends FieldPath<TFieldValues>
170
+ > = PathValue<TFieldValues, TFieldPath>;
171
+ export declare type FieldArrayPathValue<
172
+ TFieldValues extends FieldValues,
173
+ TFieldArrayPath extends FieldArrayPath<TFieldValues>
174
+ > = PathValue<TFieldValues, TFieldArrayPath>;
175
+ export declare type FieldPathValues<
176
+ TFieldValues extends FieldValues,
177
+ TPath extends FieldPath<TFieldValues>[] | readonly FieldPath<TFieldValues>[]
178
+ > = {} & {
179
+ [K in keyof TPath]: FieldPathValue<
180
+ TFieldValues,
181
+ TPath[K] & FieldPath<TFieldValues>
182
+ >;
183
+ };
184
+
185
+ export type ToFirebaseType<B> = {
186
+ [k in keyof B]: B[k] extends Date
187
+ ? import("firebase/firestore").Timestamp
188
+ : B[k] extends Object
189
+ ? ToFirebaseType<B[k]>
190
+ : B[k];
191
+ };
192
+
193
+ export type FromFirebaseType<B> = {
194
+ [k in keyof B]: B[k] extends import("firebase/firestore").Timestamp
195
+ ? Date
196
+ : B[k] extends Object
197
+ ? FromFirebaseType<B[k]>
198
+ : B[k];
199
+ };