@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
@@ -15,61 +15,96 @@ 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;
32
+ const DATA_TAG_HERO_COMPONENT = "data-hero-component";
33
+ function triggerDynamicComponents(clone, componentsThatWillAppear) {
34
+ const idsThatWillAppear = componentsThatWillAppear.map(function (a) {
35
+ return a.getAttribute(DATA_TAG_HERO_COMPONENT);
36
+ });
37
+ const preexistingComponents = Array.from(clone.querySelectorAll("[".concat(DATA_TAG_HERO_COMPONENT, "]")));
38
+ const removedElements = preexistingComponents.filter(function (el) {
39
+ return !idsThatWillAppear.includes(el.getAttribute(DATA_TAG_HERO_COMPONENT));
40
+ });
41
+ for (let elementThatIsBeingRemoved of removedElements) {
42
+ elementThatIsBeingRemoved.style.height = "".concat(elementThatIsBeingRemoved.clientHeight, "px");
43
+ }
44
+ setTimeout(function () {
45
+ for (let elementThatIsBeingRemoved of removedElements) {
46
+ elementThatIsBeingRemoved.style.height = "0px";
47
+ elementThatIsBeingRemoved.style.opacity = "0";
48
+ }
49
+ }, 0);
50
+ for (let componentThatWillAppear of componentsThatWillAppear) {
51
+ const alreadyInjectedElement = !!clone.querySelector("[".concat(DATA_TAG_HERO_COMPONENT, "=\"").concat(componentThatWillAppear.getAttribute(DATA_TAG_HERO_COMPONENT), "\"]"));
52
+ if (!alreadyInjectedElement) {
53
+ const targetElementClone = componentThatWillAppear.cloneNode(true);
54
+ targetElementClone.style.height = "0px";
55
+ const shouldBeInsrtedAtIndex = Array.from(componentThatWillAppear.parentElement.children).indexOf(componentThatWillAppear);
56
+ const remainingIndexes = Array.from(clone.children).map(function (el, i) {
57
+ return removedElements.includes(el) ? undefined : i;
58
+ }).filter(function (e) {
59
+ return e !== undefined;
60
+ });
61
+ if (shouldBeInsrtedAtIndex === remainingIndexes.length) clone.append(targetElementClone);else clone.insertBefore(targetElementClone, clone.childNodes.item(remainingIndexes[shouldBeInsrtedAtIndex]));
62
+ setTimeout(function () {
63
+ targetElementClone.style.height = "".concat(componentThatWillAppear.clientHeight, "px");
64
+ }, 0);
65
+ }
66
+ }
67
+ }
33
68
 
34
69
  /**
35
70
  * This hook implements the logic for a hero animation between 2 elements
36
71
  */
37
72
  function useHero(id) {
38
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
73
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
39
74
  propsToTransition: []
40
75
  };
41
- var events = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
42
- var _options$propsToTrans = options.propsToTransition,
76
+ let events = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
77
+ const _options$propsToTrans = options.propsToTransition,
43
78
  propsToTransition = _options$propsToTrans === void 0 ? [] : _options$propsToTrans,
44
79
  dataPreffix = options["data-preffix"],
45
80
  repeatable = options.repeatable;
46
- var _dataPreffix = dataPreffix ? "-".concat(dataPreffix) : "";
47
- var dataProperty = "data".concat(_dataPreffix, "-hero");
48
- var heroRef = (0, _react.useRef)(null);
81
+ const _dataPreffix = dataPreffix ? "-".concat(dataPreffix) : "";
82
+ const dataProperty = "data".concat(_dataPreffix, "-hero");
83
+ const heroRef = (0, _react.useRef)(null);
49
84
  (0, _react.useLayoutEffect)(function () {
50
85
  heroRef.current.setAttribute(dataProperty, id);
51
86
  }, [id]);
52
- var getHerosOnScreen = (0, _react.useCallback)(function () {
53
- var otherElements = Array.from(document.querySelectorAll("[".concat(dataProperty, "=\"").concat(id, "\"]"))).filter(function (el) {
87
+ const getHerosOnScreen = (0, _react.useCallback)(function () {
88
+ const otherElements = Array.from(document.querySelectorAll("[".concat(dataProperty, "=\"").concat(id, "\"]"))).filter(function (el) {
54
89
  return el !== heroRef.current;
55
90
  });
56
91
  return otherElements;
57
92
  }, [id]);
58
93
  function triggerHeroAnimation() {
59
- var allPropsToTransition = ["width", "height", "top", "left"].concat(_toConsumableArray(propsToTransition));
60
- var shouldHeroFn = events.onHeroDetect || function () {
94
+ const allPropsToTransition = ["width", "height", "top", "left"].concat(_toConsumableArray(propsToTransition));
95
+ const shouldHeroFn = events.onHeroDetect || function () {
61
96
  return true;
62
97
  };
63
- var otherElements = getHerosOnScreen().filter(function (el) {
98
+ const otherElements = getHerosOnScreen().filter(function (el) {
64
99
  return shouldHeroFn(el, heroRef.current);
65
100
  });
66
- var currentElCoordinates = heroRef.current.getBoundingClientRect();
101
+ const currentElCoordinates = heroRef.current.getBoundingClientRect();
67
102
  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) {
103
+ const otherElement = otherElements.find(function (el) {
69
104
  return el !== heroRef.current;
70
105
  });
71
106
  if (otherElement) {
72
- var willTheHeroMove = function willTheHeroMove(origin, target) {
107
+ let willTheHeroMove = function willTheHeroMove(origin, target) {
73
108
  return !(origin.top === target.top && origin.left === target.left && origin.width === target.width && origin.height === target.height);
74
109
  };
75
110
  /**
@@ -77,22 +112,22 @@ function useHero(id) {
77
112
  * @param el
78
113
  * @returns Returns if it will move
79
114
  */
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");
115
+ let setCloneToCoordinatesOf = function setCloneToCoordinatesOf(el) {
116
+ const coordinates = el.getBoundingClientRect();
117
+ const currentCoordinates = clone.getBoundingClientRect();
118
+ const willMove = willTheHeroMove(coordinates, currentCoordinates);
119
+ clone.style.position = "fixed";
120
+ clone.style.top = "".concat(coordinates.top, "px");
121
+ clone.style.left = "".concat(coordinates.left, "px");
122
+ clone.style.width = "".concat(coordinates.width, "px");
123
+ clone.style.height = "".concat(coordinates.height, "px");
89
124
  return willMove;
90
125
  };
91
- var _ref = events.onBeforeTransition ? events.onBeforeTransition(otherElement, heroRef.current) : [viewport, viewport],
126
+ const _ref = events.onBeforeTransition ? events.onBeforeTransition(otherElement, heroRef.current) : [viewport, viewport],
92
127
  _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 () {
128
+ originContainer = _ref2[0],
129
+ targetContainer = _ref2[1];
130
+ const shouldSkip = isElementOutsideContainer(targetContainer, currentElCoordinates) || isElementOutsideContainer(originContainer, otherElement.getBoundingClientRect()) ? (events.onHeroSkip || function () {
96
131
  return true;
97
132
  })(otherElement, heroRef.current) : false;
98
133
  if (shouldSkip) {
@@ -100,14 +135,14 @@ function useHero(id) {
100
135
  (_events$onHeroSkipped = events.onHeroSkipped) === null || _events$onHeroSkipped === void 0 ? void 0 : _events$onHeroSkipped.call(events);
101
136
  return;
102
137
  }
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);
138
+ const oldClone = document.querySelector("[".concat(dataProperty, "-clone=\"").concat(ID(id), "\"]"));
139
+ const clone = oldClone || otherElement.cloneNode(true);
140
+ if (events.onHeroCloned && !oldClone) events.onHeroCloned(clone);
106
141
 
107
142
  // 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));
143
+ clone.style.visibility = "";
144
+ clone.removeAttribute(dataProperty);
145
+ clone.setAttribute("".concat(dataProperty, "-clone"), ID(id));
111
146
 
112
147
  /**
113
148
  * If it's repeatable, we should keep the flag that indicates the hero existance
@@ -115,72 +150,66 @@ function useHero(id) {
115
150
  if (!repeatable)
116
151
  // Since a transition is now triggering from the old element, he cannot be considered for other transitions
117
152
  otherElement.removeAttribute(dataProperty);
118
- var coordinates = otherElement.getBoundingClientRect();
119
- var currentCoordinates = heroRef.current.getBoundingClientRect();
120
- var itWontMove = !willTheHeroMove(coordinates, currentCoordinates);
153
+ const coordinates = otherElement.getBoundingClientRect();
154
+ const currentCoordinates = heroRef.current.getBoundingClientRect();
155
+ const itWontMove = !willTheHeroMove(coordinates, currentCoordinates);
121
156
  if (itWontMove) return;
122
157
  if (!oldClone) {
123
158
  /** Set the clone over the starting element */
124
159
  setCloneToCoordinatesOf(otherElement);
125
- document.body.appendChild(_clone);
160
+ document.body.appendChild(clone);
126
161
  }
127
162
  heroRef.current.style.visibility = "hidden";
128
163
  otherElement.style.visibility = "hidden";
129
- _clone.style.transition = "".concat(allPropsToTransition.map(function (prop) {
164
+ clone.style.transition = "".concat(allPropsToTransition.map(function (prop) {
130
165
  return "".concat(prop, " var(--animation--speed-fast, 250ms) ease-out");
131
166
  }).join(", "));
132
167
  setTimeout(function () {
133
- var el = heroRef.current;
134
- var cleanup = function cleanup() {
168
+ const el = heroRef.current;
169
+ const cleanup = function cleanup() {
135
170
  if (events.onHeroEnd) events.onHeroEnd();
136
- _clone.remove();
137
171
  if (el) {
138
172
  if (repeatable) el.setAttribute(dataProperty, id);
139
173
  el.style.visibility = "";
140
174
  }
175
+ setTimeout(function () {
176
+ clone.remove();
177
+ }, 0);
141
178
  };
142
- if (events.onHeroStart) events.onHeroStart(_clone, otherElement, heroRef.current);
179
+ if (events.onHeroStart) {
180
+ events.onHeroStart(clone, otherElement, heroRef.current);
181
+ }
182
+ triggerDynamicComponents(clone, Array.from(heroRef.current.querySelectorAll("[".concat(DATA_TAG_HERO_COMPONENT, "]"))));
143
183
  if (!el) {
144
184
  cleanup();
145
185
  return;
146
186
  }
147
187
  /** Set the clone over the new position */
148
- var willMove = setCloneToCoordinatesOf(el);
188
+ const willMove = setCloneToCoordinatesOf(el);
149
189
  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;
190
+ for (let propToTransition of propsToTransition) clone.style[propToTransition] = window.getComputedStyle(el)[propToTransition];
191
+ let initialOffset;
192
+ const s = function s(_ref3) {
193
+ let target = _ref3.target;
194
+ const d = target;
166
195
  if (d.contains(el)) {
167
- if (initialOffset === undefined) initialOffset = d.scrollTop;else _clone.style.marginTop = "".concat(-(d.scrollTop - initialOffset), "px");
196
+ if (initialOffset === undefined) initialOffset = d.scrollTop;else clone.style.marginTop = "".concat(-(d.scrollTop - initialOffset), "px");
168
197
  }
169
198
  };
170
- var transitionEndCb = (0, _ownEvent.default)(function (_ref4) {
171
- var target = _ref4.target,
199
+ const transitionEndCb = (0, _ownEvent.default)(function (_ref4) {
200
+ let target = _ref4.target,
172
201
  currentTarget = _ref4.currentTarget;
173
202
  if (target === currentTarget) cleanup();
174
203
  document.removeEventListener("scroll", s, true);
175
204
  });
176
205
  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);
206
+ clone.addEventListener("transitionend", transitionEndCb);
207
+ clone.addEventListener("transitionstart", function () {
208
+ const onCancelCb = (0, _ownEvent.default)(function (e) {
209
+ clone.removeEventListener("transitionend", transitionEndCb);
210
+ clone.removeEventListener("transitioncancel", onCancelCb);
182
211
  });
183
- _clone.addEventListener("transitioncancel", onCancelCb);
212
+ clone.addEventListener("transitioncancel", onCancelCb);
184
213
  });
185
214
  }
186
215
  }, 0);
@@ -192,52 +221,64 @@ function useHero(id) {
192
221
  return {
193
222
  heroRef: heroRef,
194
223
  getHerosOnScreen: getHerosOnScreen,
195
- trigger: triggerHeroAnimation
224
+ trigger: triggerHeroAnimation,
225
+ heroComponentRef: function heroComponentRef(componentId) {
226
+ return function (elRef) {
227
+ if (elRef) {
228
+ elRef.setAttribute(DATA_TAG_HERO_COMPONENT, componentId);
229
+ elRef.classList.add(_useHeroModule.default.component);
230
+ }
231
+ };
232
+ }
196
233
  };
197
234
  }
198
235
  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;
236
+ const elementOverflowsViewport = coordinates.left >= viewport.width || coordinates.top >= viewport.height;
237
+ const elementUnderflowsViewport = coordinates.left <= -coordinates.width || coordinates.top <= -coordinates.height;
201
238
  return elementOverflowsViewport || elementUnderflowsViewport;
202
239
  }
203
240
  function isElementOutsideContainer(container, coordinates) {
204
241
  if (container instanceof VisualViewport) {
205
242
  return isElementOutsideViewport(coordinates);
206
243
  } else {
207
- var containerBounds = container.getBoundingClientRect();
208
- var isContainerOutsideViewport = isElementOutsideViewport(containerBounds);
244
+ const containerBounds = container.getBoundingClientRect();
245
+ const isContainerOutsideViewport = isElementOutsideViewport(containerBounds);
209
246
  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;
247
+ const elementOverflowsViewport = coordinates.left >= containerBounds.left + containerBounds.width || coordinates.top >= containerBounds.top + containerBounds.height;
248
+ const elementUnderflowsViewport = containerBounds.left - coordinates.left >= coordinates.width || containerBounds.top - coordinates.top >= coordinates.height;
212
249
  return elementUnderflowsViewport || elementOverflowsViewport;
213
250
  }
214
251
  }
215
252
  function centerPoint(rect) {
216
253
  return [rect.left + rect.width / 2, rect.top + rect.height / 2];
217
254
  }
218
- var angle = function angle(pointA, pointB) {
255
+ const angle = function angle(pointA, pointB) {
219
256
  return Number((Math.atan2(pointA[1] - pointB[1], pointA[0] - pointB[0]) * (179.08 / Math.PI)).toFixed(5));
220
257
  };
221
- var TRANSITION_FACTORY = {
258
+ const TRANSITION_FACTORY = {
222
259
  ACCELERATION: function ACCELERATION(events) {
223
260
  return _objectSpread(_objectSpread({}, events), {}, {
224
261
  onHeroStart: function onHeroStart(clone, origin, target) {
225
262
  if (events !== null && events !== void 0 && events.onHeroStart) events.onHeroStart(clone, origin, target);
226
263
  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;
264
+ const centerPointOrigin = centerPoint(origin.getBoundingClientRect());
265
+ const centerPointDestination = centerPoint(target.getBoundingClientRect());
266
+ const angleBetweenElements = angle(centerPointOrigin, centerPointDestination);
267
+ const vectorX = Math.sin(angleBetweenElements);
268
+ const vectorY = Math.cos(angleBetweenElements);
269
+ const rotateY = (10 * vectorY).toFixed(0);
270
+ const originX = (vectorY + 1) * 50;
271
+ const rotateX = -(10 * vectorX).toFixed(0);
272
+ const originY = (vectorX + 1) * 50;
236
273
  clone.style.setProperty("--stage-1", "rotateY(".concat(rotateY, "deg) rotateX(").concat(-rotateX, "deg)"));
237
274
  clone.style.setProperty("--stage-2", "rotateY(".concat(-rotateY * 0.3, "deg) rotateX(").concat(rotateX * 0.3, "deg)"));
238
275
  clone.style.setProperty("--origin-1", "".concat(originX, "% ").concat(originY, "%"));
239
276
  clone.style.setProperty("--origin-2", "".concat(100 - originX, "% ").concat(100 - originY, "%"));
240
277
  document.body.style.perspective = "100vw";
278
+ },
279
+ onHeroEnd: function onHeroEnd() {
280
+ if (events !== null && events !== void 0 && events.onHeroEnd) events.onHeroEnd();
281
+ document.body.style.perspective = "";
241
282
  }
242
283
  });
243
284
  }
@@ -1,3 +1,5 @@
1
+ @import "../assets/styles/index.scss";
2
+
1
3
  $timing: cubic-bezier(0.5, -0.45, 0.44, 1.37);
2
4
  // $timing: cubic-bezier(0.73, -0.49, 0.16, 1.4);
3
5
 
@@ -31,3 +33,8 @@ $timing: cubic-bezier(0.5, -0.45, 0.44, 1.37);
31
33
  transform: rotateY(0deg);
32
34
  }
33
35
  }
36
+
37
+ .component {
38
+ transition: height $fast linear, opacity $fast linear;
39
+ overflow: hidden;
40
+ }
@@ -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
  }
@@ -9,17 +9,17 @@ require("./shims/ObjectWatchShim.js");
9
9
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
10
  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."); }
11
11
  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); }
12
- 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; }
13
- 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; } }
12
+ 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; }
13
+ 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; } }
14
14
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
15
  function useObserve(toObserve, keysToObserve) {
16
- var _useState = (0, _react.useState)(0),
16
+ const _useState = (0, _react.useState)(0),
17
17
  _useState2 = _slicedToArray(_useState, 2),
18
18
  _ = _useState2[0],
19
19
  ss = _useState2[1];
20
20
  (0, _react.useLayoutEffect)(function () {
21
- var arr = Array.isArray(toObserve) ? toObserve : [toObserve];
22
- var unwatchers = arr.map(function (object) {
21
+ const arr = Array.isArray(toObserve) ? toObserve : [toObserve];
22
+ const unwatchers = arr.map(function (object) {
23
23
  return object.watch(keysToObserve, function () {
24
24
  ss(function (p) {
25
25
  return p + 1;