@onepercentio/one-ui 0.20.4 → 0.20.5

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 (112) hide show
  1. package/.babelrc +6 -0
  2. package/.prod.babelrc +8 -2
  3. package/dist/components/AdaptiveButton/AdaptiveButton.js +2 -2
  4. package/dist/components/AdaptiveContainer/AdaptiveContainer.js +26 -26
  5. package/dist/components/AdaptiveDialog/AdaptiveDialog.js +9 -9
  6. package/dist/components/AdaptiveSidebar/AdaptiveSidebar.js +14 -14
  7. package/dist/components/AnchoredTooltip/AnchoredTooltip.js +30 -30
  8. package/dist/components/AnimatedEntrance/AnimatedEntrance.js +27 -40
  9. package/dist/components/AsyncWrapper/AsyncWrapper.js +2 -2
  10. package/dist/components/Avatar/Avatar.js +4 -4
  11. package/dist/components/BucketFill/BucketFill.js +9 -9
  12. package/dist/components/Button/Button.js +4 -4
  13. package/dist/components/Card/Card.js +1 -1
  14. package/dist/components/Chart/Chart.view.js +34 -34
  15. package/dist/components/CheckBox/CheckBox.js +3 -3
  16. package/dist/components/Collapsable/Collapsable.js +18 -18
  17. package/dist/components/Countdown/Countdown.js +16 -16
  18. package/dist/components/Divider/Divider.js +1 -1
  19. package/dist/components/EmailInput/EmailInput.js +4 -4
  20. package/dist/components/FadeIn/FadeIn.js +9 -9
  21. package/dist/components/FileInput/FileInput.js +6 -6
  22. package/dist/components/FileInput/View/BigFactory/BigFactory.js +1 -1
  23. package/dist/components/FileInput/View/Compact/Compact.js +6 -6
  24. package/dist/components/FlowController/FlowController.js +4 -4
  25. package/dist/components/Form/Form.js +17 -28
  26. package/dist/components/Freeze/Freeze.js +1 -1
  27. package/dist/components/HSForms/HSForms.js +9 -11
  28. package/dist/components/Header/Header.js +7 -7
  29. package/dist/components/HeaderCloseBtn/HeaderCloseBtn.js +1 -1
  30. package/dist/components/InfinityScroll/InfinityScroll.js +25 -25
  31. package/dist/components/Input/Input.js +13 -13
  32. package/dist/components/InstantCounter/InstantCounter.js +9 -9
  33. package/dist/components/LavaLamp/LavaLamp.data.js +25 -25
  34. package/dist/components/LavaLamp/LavaLamp.js +7 -7
  35. package/dist/components/LavaLamp/v2/LavaLamp.js +29 -45
  36. package/dist/components/LinkToId/LinkToId.js +7 -7
  37. package/dist/components/Loader/Loader.js +2 -2
  38. package/dist/components/LoaderDotsIndicator/LoaderDotsIndicator.js +6 -6
  39. package/dist/components/LoopableVideo/LoopableVideo.js +4 -4
  40. package/dist/components/MainGrid/MainGrid.js +2 -2
  41. package/dist/components/MutableHamburgerButton/MutableHamburgerButton.js +2 -2
  42. package/dist/components/Notification/Notification.js +1 -1
  43. package/dist/components/OrderableList/OrderableList.js +113 -138
  44. package/dist/components/PaginationIndicator/PaginationIndicator.js +50 -50
  45. package/dist/components/Parallax/Parallax.js +39 -39
  46. package/dist/components/Parallax/math/helpers.js +18 -19
  47. package/dist/components/PasswordInput/PasswordInput.js +10 -10
  48. package/dist/components/PingPongText/PingPongText.js +15 -15
  49. package/dist/components/PixelatedScan/PixelatedScan.js +19 -19
  50. package/dist/components/Portal/Portal.js +10 -10
  51. package/dist/components/ProgressBar/ProgressBar.js +6 -6
  52. package/dist/components/ProgressTexts/ProgressTexts.js +3 -3
  53. package/dist/components/Radio/Radio.js +3 -3
  54. package/dist/components/SectionContainer/SectionContainer.js +1 -1
  55. package/dist/components/Select/Select.js +13 -13
  56. package/dist/components/Skeleton/Skeleton.js +1 -1
  57. package/dist/components/Spacing/Spacing.js +1 -1
  58. package/dist/components/StaticScroller/StaticScroller.js +12 -12
  59. package/dist/components/Switch/Switch.js +2 -2
  60. package/dist/components/Table/Table.js +11 -11
  61. package/dist/components/Tabs/Tabs.js +3 -3
  62. package/dist/components/Text/Text.js +5 -5
  63. package/dist/components/Transition/MasksFactory/DiagonalReveal.js +5 -5
  64. package/dist/components/Transition/MasksFactory/DiagonalSquareToBalls.js +17 -17
  65. package/dist/components/Transition/MasksFactory/PhysicsSquares.js +13 -13
  66. package/dist/components/Transition/MasksFactory/SquareToBalls.js +9 -9
  67. package/dist/components/Transition/MasksFactory/utils.js +8 -8
  68. package/dist/components/Transition/Transition.js +49 -49
  69. package/dist/components/UncontrolledTransition/UncontrolledTransition.js +7 -7
  70. package/dist/components/WalletConnectionWrapper/WalletConnectionWrapper.js +44 -82
  71. package/dist/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.js +6 -6
  72. package/dist/context/AsyncProcess.js +19 -42
  73. package/dist/context/CustomBrowserRouter.js +6 -6
  74. package/dist/context/OneUIProvider.js +15 -15
  75. package/dist/hooks/logs/useDependencyChangeDetection.js +2 -5
  76. package/dist/hooks/persistence/useLocalStorage.js +7 -7
  77. package/dist/hooks/shims/ObjectWatchShim.js +1 -15
  78. package/dist/hooks/ui/useAdaptiveImage.js +6 -6
  79. package/dist/hooks/ui/useBreakpoint.js +5 -5
  80. package/dist/hooks/ui/useCustomScrollbar.js +2 -2
  81. package/dist/hooks/ui/useMouseHover.js +4 -4
  82. package/dist/hooks/ui/usePaginationControls.js +34 -34
  83. package/dist/hooks/ui/useSnapToViewport.js +3 -3
  84. package/dist/hooks/ui/useTilt.js +38 -38
  85. package/dist/hooks/ui/useZoomable.js +20 -20
  86. package/dist/hooks/useAsyncControl.js +21 -38
  87. package/dist/hooks/useContainedRepositioning.js +22 -22
  88. package/dist/hooks/useCustomHistory.js +2 -2
  89. package/dist/hooks/useElementFit.js +6 -6
  90. package/dist/hooks/useFirestoreWatch.js +26 -39
  91. package/dist/hooks/useForm.js +8 -8
  92. package/dist/hooks/useFreeze.js +1 -1
  93. package/dist/hooks/useHero.js +82 -90
  94. package/dist/hooks/useIntersection.js +3 -3
  95. package/dist/hooks/useMergeRefs.js +3 -7
  96. package/dist/hooks/useObserve.js +5 -5
  97. package/dist/hooks/usePagination.js +39 -59
  98. package/dist/hooks/usePooledOperation.js +8 -22
  99. package/dist/hooks/usePooling.js +17 -33
  100. package/dist/hooks/useRebound.js +5 -5
  101. package/dist/hooks/useShortIntl.js +13 -13
  102. package/dist/hooks/utility/useEvents.js +5 -5
  103. package/dist/hooks/utility/useModule.js +3 -3
  104. package/dist/hooks/utility/useQuery.js +1 -1
  105. package/dist/models/DebugLogger.js +2 -2
  106. package/dist/models/GenericContract.js +1 -1
  107. package/dist/storybookUtils/index.js +1 -1
  108. package/dist/utility.d.js +3 -3
  109. package/dist/utils/blockchain.js +29 -102
  110. package/dist/utils/flatten.js +3 -3
  111. package/dist/utils/html.utils.js +1 -1
  112. package/package.json +1 -1
@@ -12,43 +12,43 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
12
12
  * If it is, it should move it so it can be totally visible inside the container
13
13
  */
14
14
  function useContainedRepositioning(focused, getParent) {
15
- var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
15
+ let _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
16
16
  _ref$offset = _ref.offset,
17
17
  offset = _ref$offset === void 0 ? 16 : _ref$offset,
18
18
  _ref$scale = _ref.scale,
19
19
  scale = _ref$scale === void 0 ? 1 : _ref$scale,
20
20
  _ref$offsetLimit = _ref.offsetLimit,
21
21
  offsetLimit = _ref$offsetLimit === void 0 ? Number.POSITIVE_INFINITY : _ref$offsetLimit;
22
- var elementToCheck = (0, _react.useRef)(null);
22
+ const elementToCheck = (0, _react.useRef)(null);
23
23
  (0, _react.useEffect)(function () {
24
- var el = elementToCheck.current;
24
+ const el = elementToCheck.current;
25
25
  if (!el) return;
26
- var curr = el;
27
- var relativeParent = getParent(curr);
26
+ const curr = el;
27
+ const relativeParent = getParent(curr);
28
28
  if (process.env.NODE_ENV === "development") {
29
29
  if (window.getComputedStyle(el).position !== "relative") throw new Error("The target element MUST have position relative so it can be moved");
30
30
  if (window.getComputedStyle(relativeParent).position !== "relative") throw new Error("The relative to element MUST have position relative so it can calculate correctly the target position");
31
31
  }
32
32
  if (focused) {
33
33
  curr.style.right = "0px";
34
- var reposition = (0, _debounce.default)(function () {
35
- var alreadyRight = Number(curr.style.right.replace("px", ""));
36
- var limitOffset = relativeParent.scrollLeft + relativeParent.clientWidth;
37
- var elWidth = curr.clientWidth * scale;
38
- var offsetOfScale = (elWidth - curr.clientWidth) / 2;
39
- var cardLimit = curr.offsetLeft - offsetOfScale + alreadyRight + elWidth;
40
- var exceedingSpace = cardLimit - limitOffset;
41
- var offsetLeft = curr.offsetLeft - offsetOfScale + alreadyRight - relativeParent.scrollLeft;
42
- var isOverflowedRight = exceedingSpace > 0;
43
- var isOverflowedLeft = offsetLeft < 0;
44
- var limit = exceedingSpace + -offsetLeft;
34
+ const reposition = (0, _debounce.default)(function () {
35
+ const alreadyRight = Number(curr.style.right.replace("px", ""));
36
+ const limitOffset = relativeParent.scrollLeft + relativeParent.clientWidth;
37
+ const elWidth = curr.clientWidth * scale;
38
+ const offsetOfScale = (elWidth - curr.clientWidth) / 2;
39
+ const cardLimit = curr.offsetLeft - offsetOfScale + alreadyRight + elWidth;
40
+ const exceedingSpace = cardLimit - limitOffset;
41
+ const offsetLeft = curr.offsetLeft - offsetOfScale + alreadyRight - relativeParent.scrollLeft;
42
+ const isOverflowedRight = exceedingSpace > 0;
43
+ const isOverflowedLeft = offsetLeft < 0;
44
+ const limit = exceedingSpace + -offsetLeft;
45
45
  if (isOverflowedRight) {
46
- var val = Math.min(exceedingSpace - -Math.min(Math.abs(limit / 2), offset), offsetLimit);
46
+ const val = Math.min(exceedingSpace - -Math.min(Math.abs(limit / 2), offset), offsetLimit);
47
47
  curr.style.right = "".concat(val, "px");
48
48
  }
49
49
  if (isOverflowedLeft) {
50
- var _val = Math.max(offsetLeft - Math.min(Math.abs(limit) / 2, offset), -offsetLimit);
51
- curr.style.right = "".concat(_val, "px");
50
+ const val = Math.max(offsetLeft - Math.min(Math.abs(limit) / 2, offset), -offsetLimit);
51
+ curr.style.right = "".concat(val, "px");
52
52
  }
53
53
  if (isOverflowedLeft || isOverflowedRight) {
54
54
  curr.style.zIndex = "1000";
@@ -63,10 +63,10 @@ function useContainedRepositioning(focused, getParent) {
63
63
  reposition.cancel();
64
64
  relativeParent.removeEventListener("scroll", reposition);
65
65
  el.style.right = "0px";
66
- var restore = function restore(_ref2) {
67
- var propertyName = _ref2.propertyName,
66
+ const restore = function restore(_ref2) {
67
+ let propertyName = _ref2.propertyName,
68
68
  currentTarget = _ref2.currentTarget;
69
- var targetTransformation = window.getComputedStyle(currentTarget).right;
69
+ const targetTransformation = window.getComputedStyle(currentTarget).right;
70
70
  if (propertyName === "right" && targetTransformation === "0px") {
71
71
  curr.style.zIndex = "";
72
72
  el.removeEventListener("transitionend", restore);
@@ -12,8 +12,8 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
12
12
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
13
13
  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); }
14
14
  function useCustomHistory() {
15
- var customHistory = (0, _reactRouterDom.useHistory)();
16
- var _useLocation = (0, _reactRouterDom.useLocation)(),
15
+ const customHistory = (0, _reactRouterDom.useHistory)();
16
+ const _useLocation = (0, _reactRouterDom.useLocation)(),
17
17
  state = _useLocation.state;
18
18
  return _objectSpread(_objectSpread({}, customHistory), {}, {
19
19
  goBackWithFallback: function goBackWithFallback(fallbackRoute) {
@@ -8,8 +8,8 @@ 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++) { 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; } }
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
  /**
15
15
  * This hook receives a base width of an element and returns how much items fit **vertically** inside the referenced html element
@@ -17,7 +17,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
17
  * @param baseWidth The base width of each element
18
18
  */
19
19
  function useElementFit(baseWidth, baseHeight) {
20
- var ref = (0, _react.useRef)(null);
20
+ const ref = (0, _react.useRef)(null);
21
21
  function calculateDimension() {
22
22
  var _ref$current, _ref$current2;
23
23
  function fittingRows() {
@@ -25,12 +25,12 @@ function useElementFit(baseWidth, baseHeight) {
25
25
  return Math.ceil(ref.current.clientHeight / baseHeight);
26
26
  }
27
27
  if (window.PRERENDER) return 4;
28
- var width = ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.clientWidth) || window.visualViewport.width;
29
- var maxItemsVertically = Math.floor(width / baseWidth) || 1;
28
+ const width = ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.clientWidth) || window.visualViewport.width;
29
+ const maxItemsVertically = Math.floor(width / baseWidth) || 1;
30
30
  if (process.env.NODE_ENV === "development") require('../models/DebugLogger').default("".concat(useElementFit.name, ":clientWidth"), (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.clientWidth);
31
31
  return maxItemsVertically * fittingRows();
32
32
  }
33
- var _useState = (0, _react.useState)(window.PRERENDER ? 4 : undefined),
33
+ const _useState = (0, _react.useState)(window.PRERENDER ? 4 : undefined),
34
34
  _useState2 = _slicedToArray(_useState, 2),
35
35
  itemsToShow = _useState2[0],
36
36
  setItemsToShow = _useState2[1];
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = useFirestoreWatch;
7
7
  var _react = require("react");
8
- 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; } } }; }
9
8
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
10
9
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
10
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
@@ -13,53 +12,41 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
13
12
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
13
  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."); }
15
14
  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); }
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
- 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; } }
15
+ 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 _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; } }
18
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
18
  function useFirestoreWatch(queryFactory, params) {
20
- var _useState = (0, _react.useState)(),
19
+ const _useState = (0, _react.useState)(),
21
20
  _useState2 = _slicedToArray(_useState, 2),
22
21
  docsList = _useState2[0],
23
22
  updateList = _useState2[1];
24
23
  (0, _react.useEffect)(function () {
25
- var unsub = queryFactory.apply(void 0, _toConsumableArray(params))(function (changes) {
24
+ const unsub = queryFactory.apply(void 0, _toConsumableArray(params))(function (changes) {
26
25
  updateList(function () {
27
- var prevList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
28
- var _iterator = _createForOfIteratorHelper(changes),
29
- _step;
30
- try {
31
- var _loop = function _loop() {
32
- var docChange = _step.value;
33
- switch (docChange.type) {
34
- case 'added':
35
- if (!prevList.find(function (f) {
36
- return f.id === docChange.doc.id;
37
- })) {
38
- prevList.unshift(docChange.doc);
26
+ let prevList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
27
+ for (let docChange of changes) {
28
+ switch (docChange.type) {
29
+ case 'added':
30
+ if (!prevList.find(function (f) {
31
+ return f.id === docChange.doc.id;
32
+ })) {
33
+ prevList.unshift(docChange.doc);
34
+ }
35
+ break;
36
+ case 'modified':
37
+ prevList = prevList.map(function (item) {
38
+ if (item.id === docChange.doc.id) for (let key in docChange.doc) {
39
+ item[key] = docChange.doc[key];
39
40
  }
40
- break;
41
- case 'modified':
42
- prevList = prevList.map(function (item) {
43
- if (item.id === docChange.doc.id) for (var key in docChange.doc) {
44
- item[key] = docChange.doc[key];
45
- }
46
- return item;
47
- });
48
- break;
49
- case 'removed':
50
- prevList = prevList.filter(function (item) {
51
- return item.id !== docChange.doc.id;
52
- });
53
- break;
54
- }
55
- };
56
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
57
- _loop();
41
+ return item;
42
+ });
43
+ break;
44
+ case 'removed':
45
+ prevList = prevList.filter(function (item) {
46
+ return item.id !== docChange.doc.id;
47
+ });
48
+ break;
58
49
  }
59
- } catch (err) {
60
- _iterator.e(err);
61
- } finally {
62
- _iterator.f();
63
50
  }
64
51
  return _toConsumableArray(prevList);
65
52
  });
@@ -14,28 +14,28 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
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++) { 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; } }
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
20
  function useContextForm(config, initialState) {
21
- var _useState = (0, _react.useState)(initialState),
21
+ const _useState = (0, _react.useState)(initialState),
22
22
  _useState2 = _slicedToArray(_useState, 2),
23
23
  form = _useState2[0],
24
24
  setForm = _useState2[1];
25
- var isValid = (0, _react.useMemo)(function () {
25
+ const isValid = (0, _react.useMemo)(function () {
26
26
  return !Object.keys(config).some(function (a) {
27
27
  return typeof config[a].validator(form[a], form) === "string";
28
28
  });
29
29
  }, [form]);
30
- var _setFormField = function _setFormField(key, value) {
30
+ const _setFormField = function _setFormField(key, value) {
31
31
  setForm(function (prev) {
32
32
  return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, key, value));
33
33
  });
34
34
  };
35
- var validFormFields = (0, _react.useMemo)(function () {
35
+ const validFormFields = (0, _react.useMemo)(function () {
36
36
  return Object.keys(config).reduce(function (result, field) {
37
- var fieldConfig = config[field];
38
- var invalidMessage = fieldConfig.validator(form[field], form);
37
+ const fieldConfig = config[field];
38
+ const invalidMessage = fieldConfig.validator(form[field], form);
39
39
  return _objectSpread(_objectSpread({}, result), {}, _defineProperty({}, field, invalidMessage));
40
40
  }, {
41
41
  isValid: isValid
@@ -10,7 +10,7 @@ var _react = require("react");
10
10
  * it returns the previous valid value
11
11
  */
12
12
  function useFreeze(something) {
13
- var currChildOrPrev = (0, _react.useRef)();
13
+ const currChildOrPrev = (0, _react.useRef)();
14
14
  currChildOrPrev.current = something || currChildOrPrev.current;
15
15
  return currChildOrPrev.current || null;
16
16
  }
@@ -15,61 +15,60 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
15
15
  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; }
16
16
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
17
17
  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); }
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
18
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
20
19
  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."); }
21
- 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; } }
20
+ 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; } }
22
21
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
23
22
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
24
23
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
25
24
  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); }
26
25
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
27
26
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
28
- 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; }
29
- var ID = function ID(id) {
27
+ 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; }
28
+ const ID = function ID(id) {
30
29
  return "".concat(id, "-hero");
31
30
  };
32
- var viewport = window.visualViewport;
31
+ const viewport = window.visualViewport;
33
32
 
34
33
  /**
35
34
  * This hook implements the logic for a hero animation between 2 elements
36
35
  */
37
36
  function useHero(id) {
38
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
37
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
39
38
  propsToTransition: []
40
39
  };
41
- var events = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
42
- var _options$propsToTrans = options.propsToTransition,
40
+ let events = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
41
+ const _options$propsToTrans = options.propsToTransition,
43
42
  propsToTransition = _options$propsToTrans === void 0 ? [] : _options$propsToTrans,
44
43
  dataPreffix = options["data-preffix"],
45
44
  repeatable = options.repeatable;
46
- var _dataPreffix = dataPreffix ? "-".concat(dataPreffix) : "";
47
- var dataProperty = "data".concat(_dataPreffix, "-hero");
48
- var heroRef = (0, _react.useRef)(null);
45
+ const _dataPreffix = dataPreffix ? "-".concat(dataPreffix) : "";
46
+ const dataProperty = "data".concat(_dataPreffix, "-hero");
47
+ const heroRef = (0, _react.useRef)(null);
49
48
  (0, _react.useLayoutEffect)(function () {
50
49
  heroRef.current.setAttribute(dataProperty, id);
51
50
  }, [id]);
52
- var getHerosOnScreen = (0, _react.useCallback)(function () {
53
- var otherElements = Array.from(document.querySelectorAll("[".concat(dataProperty, "=\"").concat(id, "\"]"))).filter(function (el) {
51
+ const getHerosOnScreen = (0, _react.useCallback)(function () {
52
+ const otherElements = Array.from(document.querySelectorAll("[".concat(dataProperty, "=\"").concat(id, "\"]"))).filter(function (el) {
54
53
  return el !== heroRef.current;
55
54
  });
56
55
  return otherElements;
57
56
  }, [id]);
58
57
  function triggerHeroAnimation() {
59
- var allPropsToTransition = ["width", "height", "top", "left"].concat(_toConsumableArray(propsToTransition));
60
- var shouldHeroFn = events.onHeroDetect || function () {
58
+ const allPropsToTransition = ["width", "height", "top", "left"].concat(_toConsumableArray(propsToTransition));
59
+ const shouldHeroFn = events.onHeroDetect || function () {
61
60
  return true;
62
61
  };
63
- var otherElements = getHerosOnScreen().filter(function (el) {
62
+ const otherElements = getHerosOnScreen().filter(function (el) {
64
63
  return shouldHeroFn(el, heroRef.current);
65
64
  });
66
- var currentElCoordinates = heroRef.current.getBoundingClientRect();
65
+ const currentElCoordinates = heroRef.current.getBoundingClientRect();
67
66
  if (process.env.NODE_ENV === "development" && otherElements.length > 2) console.warn("There are too many elements to transition to, I will transition to the first I find", otherElements);
68
- var otherElement = otherElements.find(function (el) {
67
+ const otherElement = otherElements.find(function (el) {
69
68
  return el !== heroRef.current;
70
69
  });
71
70
  if (otherElement) {
72
- var willTheHeroMove = function willTheHeroMove(origin, target) {
71
+ let willTheHeroMove = function willTheHeroMove(origin, target) {
73
72
  return !(origin.top === target.top && origin.left === target.left && origin.width === target.width && origin.height === target.height);
74
73
  };
75
74
  /**
@@ -77,22 +76,22 @@ function useHero(id) {
77
76
  * @param el
78
77
  * @returns Returns if it will move
79
78
  */
80
- var setCloneToCoordinatesOf = function setCloneToCoordinatesOf(el) {
81
- var coordinates = el.getBoundingClientRect();
82
- var currentCoordinates = _clone.getBoundingClientRect();
83
- var willMove = willTheHeroMove(coordinates, currentCoordinates);
84
- _clone.style.position = "fixed";
85
- _clone.style.top = "".concat(coordinates.top, "px");
86
- _clone.style.left = "".concat(coordinates.left, "px");
87
- _clone.style.width = "".concat(coordinates.width, "px");
88
- _clone.style.height = "".concat(coordinates.height, "px");
79
+ let setCloneToCoordinatesOf = function setCloneToCoordinatesOf(el) {
80
+ const coordinates = el.getBoundingClientRect();
81
+ const currentCoordinates = clone.getBoundingClientRect();
82
+ const willMove = willTheHeroMove(coordinates, currentCoordinates);
83
+ clone.style.position = "fixed";
84
+ clone.style.top = "".concat(coordinates.top, "px");
85
+ clone.style.left = "".concat(coordinates.left, "px");
86
+ clone.style.width = "".concat(coordinates.width, "px");
87
+ clone.style.height = "".concat(coordinates.height, "px");
89
88
  return willMove;
90
89
  };
91
- var _ref = events.onBeforeTransition ? events.onBeforeTransition(otherElement, heroRef.current) : [viewport, viewport],
90
+ const _ref = events.onBeforeTransition ? events.onBeforeTransition(otherElement, heroRef.current) : [viewport, viewport],
92
91
  _ref2 = _slicedToArray(_ref, 2),
93
- _originContainer = _ref2[0],
94
- _targetContainer = _ref2[1];
95
- var shouldSkip = isElementOutsideContainer(_targetContainer, currentElCoordinates) || isElementOutsideContainer(_originContainer, otherElement.getBoundingClientRect()) ? (events.onHeroSkip || function () {
92
+ originContainer = _ref2[0],
93
+ targetContainer = _ref2[1];
94
+ const shouldSkip = isElementOutsideContainer(targetContainer, currentElCoordinates) || isElementOutsideContainer(originContainer, otherElement.getBoundingClientRect()) ? (events.onHeroSkip || function () {
96
95
  return true;
97
96
  })(otherElement, heroRef.current) : false;
98
97
  if (shouldSkip) {
@@ -100,14 +99,14 @@ function useHero(id) {
100
99
  (_events$onHeroSkipped = events.onHeroSkipped) === null || _events$onHeroSkipped === void 0 ? void 0 : _events$onHeroSkipped.call(events);
101
100
  return;
102
101
  }
103
- var oldClone = document.querySelector("[".concat(dataProperty, "-clone=\"").concat(ID(id), "\"]"));
104
- var _clone = oldClone || otherElement.cloneNode(true);
105
- if (events.onHeroCloned && !oldClone) events.onHeroCloned(_clone);
102
+ const oldClone = document.querySelector("[".concat(dataProperty, "-clone=\"").concat(ID(id), "\"]"));
103
+ const clone = oldClone || otherElement.cloneNode(true);
104
+ if (events.onHeroCloned && !oldClone) events.onHeroCloned(clone);
106
105
 
107
106
  // Clean up thos properties that can cause confusion since it's a clone
108
- _clone.style.visibility = "";
109
- _clone.removeAttribute(dataProperty);
110
- _clone.setAttribute("".concat(dataProperty, "-clone"), ID(id));
107
+ clone.style.visibility = "";
108
+ clone.removeAttribute(dataProperty);
109
+ clone.setAttribute("".concat(dataProperty, "-clone"), ID(id));
111
110
 
112
111
  /**
113
112
  * If it's repeatable, we should keep the flag that indicates the hero existance
@@ -115,72 +114,61 @@ function useHero(id) {
115
114
  if (!repeatable)
116
115
  // Since a transition is now triggering from the old element, he cannot be considered for other transitions
117
116
  otherElement.removeAttribute(dataProperty);
118
- var coordinates = otherElement.getBoundingClientRect();
119
- var currentCoordinates = heroRef.current.getBoundingClientRect();
120
- var itWontMove = !willTheHeroMove(coordinates, currentCoordinates);
117
+ const coordinates = otherElement.getBoundingClientRect();
118
+ const currentCoordinates = heroRef.current.getBoundingClientRect();
119
+ const itWontMove = !willTheHeroMove(coordinates, currentCoordinates);
121
120
  if (itWontMove) return;
122
121
  if (!oldClone) {
123
122
  /** Set the clone over the starting element */
124
123
  setCloneToCoordinatesOf(otherElement);
125
- document.body.appendChild(_clone);
124
+ document.body.appendChild(clone);
126
125
  }
127
126
  heroRef.current.style.visibility = "hidden";
128
127
  otherElement.style.visibility = "hidden";
129
- _clone.style.transition = "".concat(allPropsToTransition.map(function (prop) {
128
+ clone.style.transition = "".concat(allPropsToTransition.map(function (prop) {
130
129
  return "".concat(prop, " var(--animation--speed-fast, 250ms) ease-out");
131
130
  }).join(", "));
132
131
  setTimeout(function () {
133
- var el = heroRef.current;
134
- var cleanup = function cleanup() {
132
+ const el = heroRef.current;
133
+ const cleanup = function cleanup() {
135
134
  if (events.onHeroEnd) events.onHeroEnd();
136
- _clone.remove();
135
+ clone.remove();
137
136
  if (el) {
138
137
  if (repeatable) el.setAttribute(dataProperty, id);
139
138
  el.style.visibility = "";
140
139
  }
141
140
  };
142
- if (events.onHeroStart) events.onHeroStart(_clone, otherElement, heroRef.current);
141
+ if (events.onHeroStart) events.onHeroStart(clone, otherElement, heroRef.current);
143
142
  if (!el) {
144
143
  cleanup();
145
144
  return;
146
145
  }
147
146
  /** Set the clone over the new position */
148
- var willMove = setCloneToCoordinatesOf(el);
147
+ const willMove = setCloneToCoordinatesOf(el);
149
148
  if (!willMove) cleanup();else {
150
- var _iterator = _createForOfIteratorHelper(propsToTransition),
151
- _step;
152
- try {
153
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
154
- var propToTransition = _step.value;
155
- _clone.style[propToTransition] = window.getComputedStyle(el)[propToTransition];
156
- }
157
- } catch (err) {
158
- _iterator.e(err);
159
- } finally {
160
- _iterator.f();
161
- }
162
- var initialOffset;
163
- var s = function s(_ref3) {
164
- var target = _ref3.target;
165
- var d = target;
149
+ for (let propToTransition of propsToTransition) clone.style[propToTransition] = window.getComputedStyle(el)[propToTransition];
150
+ let initialOffset;
151
+ const s = function s(_ref3) {
152
+ let target = _ref3.target;
153
+ const d = target;
166
154
  if (d.contains(el)) {
167
- if (initialOffset === undefined) initialOffset = d.scrollTop;else _clone.style.marginTop = "".concat(-(d.scrollTop - initialOffset), "px");
155
+ if (initialOffset === undefined) initialOffset = d.scrollTop;else clone.style.marginTop = "".concat(-(d.scrollTop - initialOffset), "px");
168
156
  }
169
157
  };
170
- var transitionEndCb = (0, _ownEvent.default)(function (_ref4) {
171
- var target = _ref4.target,
158
+ const transitionEndCb = (0, _ownEvent.default)(function (_ref4) {
159
+ let target = _ref4.target,
172
160
  currentTarget = _ref4.currentTarget;
173
161
  if (target === currentTarget) cleanup();
174
162
  document.removeEventListener("scroll", s, true);
175
163
  });
176
164
  document.addEventListener("scroll", s, true);
177
- _clone.addEventListener("transitionend", transitionEndCb);
178
- _clone.addEventListener("transitionstart", function () {
179
- var onCancelCb = (0, _ownEvent.default)(function (e) {
180
- _clone.removeEventListener("transitionend", transitionEndCb);
181
- _clone.removeEventListener("transitioncancel", onCancelCb);
165
+ clone.addEventListener("transitionend", transitionEndCb);
166
+ clone.addEventListener("transitionstart", function () {
167
+ const onCancelCb = (0, _ownEvent.default)(function (e) {
168
+ clone.removeEventListener("transitionend", transitionEndCb);
169
+ clone.removeEventListener("transitioncancel", onCancelCb);
182
170
  });
183
- _clone.addEventListener("transitioncancel", onCancelCb);
171
+ clone.addEventListener("transitioncancel", onCancelCb);
184
172
  });
185
173
  }
186
174
  }, 0);
@@ -196,48 +184,52 @@ function useHero(id) {
196
184
  };
197
185
  }
198
186
  function isElementOutsideViewport(coordinates) {
199
- var elementOverflowsViewport = coordinates.left >= viewport.width || coordinates.top >= viewport.height;
200
- var elementUnderflowsViewport = coordinates.left <= -coordinates.width || coordinates.top <= -coordinates.height;
187
+ const elementOverflowsViewport = coordinates.left >= viewport.width || coordinates.top >= viewport.height;
188
+ const elementUnderflowsViewport = coordinates.left <= -coordinates.width || coordinates.top <= -coordinates.height;
201
189
  return elementOverflowsViewport || elementUnderflowsViewport;
202
190
  }
203
191
  function isElementOutsideContainer(container, coordinates) {
204
192
  if (container instanceof VisualViewport) {
205
193
  return isElementOutsideViewport(coordinates);
206
194
  } else {
207
- var containerBounds = container.getBoundingClientRect();
208
- var isContainerOutsideViewport = isElementOutsideViewport(containerBounds);
195
+ const containerBounds = container.getBoundingClientRect();
196
+ const isContainerOutsideViewport = isElementOutsideViewport(containerBounds);
209
197
  if (isContainerOutsideViewport) return true;
210
- var elementOverflowsViewport = coordinates.left >= containerBounds.left + containerBounds.width || coordinates.top >= containerBounds.top + containerBounds.height;
211
- var elementUnderflowsViewport = containerBounds.left - coordinates.left >= coordinates.width || containerBounds.top - coordinates.top >= coordinates.height;
198
+ const elementOverflowsViewport = coordinates.left >= containerBounds.left + containerBounds.width || coordinates.top >= containerBounds.top + containerBounds.height;
199
+ const elementUnderflowsViewport = containerBounds.left - coordinates.left >= coordinates.width || containerBounds.top - coordinates.top >= coordinates.height;
212
200
  return elementUnderflowsViewport || elementOverflowsViewport;
213
201
  }
214
202
  }
215
203
  function centerPoint(rect) {
216
204
  return [rect.left + rect.width / 2, rect.top + rect.height / 2];
217
205
  }
218
- var angle = function angle(pointA, pointB) {
206
+ const angle = function angle(pointA, pointB) {
219
207
  return Number((Math.atan2(pointA[1] - pointB[1], pointA[0] - pointB[0]) * (179.08 / Math.PI)).toFixed(5));
220
208
  };
221
- var TRANSITION_FACTORY = {
209
+ const TRANSITION_FACTORY = {
222
210
  ACCELERATION: function ACCELERATION(events) {
223
211
  return _objectSpread(_objectSpread({}, events), {}, {
224
212
  onHeroStart: function onHeroStart(clone, origin, target) {
225
213
  if (events !== null && events !== void 0 && events.onHeroStart) events.onHeroStart(clone, origin, target);
226
214
  clone.classList.add(_useHeroModule.default.acceleration);
227
- var centerPointOrigin = centerPoint(origin.getBoundingClientRect());
228
- var centerPointDestination = centerPoint(target.getBoundingClientRect());
229
- var angleBetweenElements = angle(centerPointOrigin, centerPointDestination);
230
- var vectorX = Math.sin(angleBetweenElements);
231
- var vectorY = Math.cos(angleBetweenElements);
232
- var rotateY = (10 * vectorY).toFixed(0);
233
- var originX = (vectorY + 1) * 50;
234
- var rotateX = -(10 * vectorX).toFixed(0);
235
- var originY = (vectorX + 1) * 50;
215
+ const centerPointOrigin = centerPoint(origin.getBoundingClientRect());
216
+ const centerPointDestination = centerPoint(target.getBoundingClientRect());
217
+ const angleBetweenElements = angle(centerPointOrigin, centerPointDestination);
218
+ const vectorX = Math.sin(angleBetweenElements);
219
+ const vectorY = Math.cos(angleBetweenElements);
220
+ const rotateY = (10 * vectorY).toFixed(0);
221
+ const originX = (vectorY + 1) * 50;
222
+ const rotateX = -(10 * vectorX).toFixed(0);
223
+ const originY = (vectorX + 1) * 50;
236
224
  clone.style.setProperty("--stage-1", "rotateY(".concat(rotateY, "deg) rotateX(").concat(-rotateX, "deg)"));
237
225
  clone.style.setProperty("--stage-2", "rotateY(".concat(-rotateY * 0.3, "deg) rotateX(").concat(rotateX * 0.3, "deg)"));
238
226
  clone.style.setProperty("--origin-1", "".concat(originX, "% ").concat(originY, "%"));
239
227
  clone.style.setProperty("--origin-2", "".concat(100 - originX, "% ").concat(100 - originY, "%"));
240
228
  document.body.style.perspective = "100vw";
229
+ },
230
+ onHeroEnd: function onHeroEnd() {
231
+ if (events !== null && events !== void 0 && events.onHeroEnd) events.onHeroEnd();
232
+ document.body.style.perspective = "";
241
233
  }
242
234
  });
243
235
  }
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = useIntersection;
7
7
  var _react = require("react");
8
8
  function useIntersection() {
9
- var _useRef = (0, _react.useRef)([]),
9
+ const _useRef = (0, _react.useRef)([]),
10
10
  targetMap = _useRef.current;
11
- var _useRef2 = (0, _react.useRef)("IntersectionObserver" in window ? new IntersectionObserver(function (els) {
11
+ const _useRef2 = (0, _react.useRef)("IntersectionObserver" in window ? new IntersectionObserver(function (els) {
12
12
  els.forEach(function (e, i) {
13
- var result = targetMap.find(function (el) {
13
+ const result = targetMap.find(function (el) {
14
14
  return el[0] === e.target;
15
15
  });
16
16
  if (result && e.isIntersecting) {
@@ -14,10 +14,7 @@ function useMergeRefs(mainRef) {
14
14
  otherRefs[_key - 1] = arguments[_key];
15
15
  }
16
16
  (0, _react.useLayoutEffect)(function () {
17
- for (var _i = 0, _otherRefs = otherRefs; _i < _otherRefs.length; _i++) {
18
- var _ref = _otherRefs[_i];
19
- _ref.current = mainRef.current;
20
- }
17
+ for (let ref of otherRefs) ref.current = mainRef.current;
21
18
  }, []);
22
19
  return mainRef;
23
20
  }
@@ -30,9 +27,8 @@ function useMergeRefsFunc(mainRef) {
30
27
  otherRefs[_key2 - 1] = arguments[_key2];
31
28
  }
32
29
  return function (providedRef) {
33
- if (providedRef) for (var _i2 = 0, _arr = [mainRef].concat(otherRefs); _i2 < _arr.length; _i2++) {
34
- var _ref2 = _arr[_i2];
35
- if (typeof _ref2 === "function") _ref2(providedRef);else _ref2.current = providedRef;
30
+ if (providedRef) for (let ref of [mainRef].concat(otherRefs)) {
31
+ if (typeof ref === "function") ref(providedRef);else ref.current = providedRef;
36
32
  }
37
33
  };
38
34
  }