@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.
- package/.babelrc +6 -0
- package/.prod.babelrc +8 -2
- package/dist/components/AdaptiveButton/AdaptiveButton.js +2 -2
- package/dist/components/AdaptiveContainer/AdaptiveContainer.js +26 -26
- package/dist/components/AdaptiveDialog/AdaptiveDialog.js +9 -9
- package/dist/components/AdaptiveSidebar/AdaptiveSidebar.js +14 -14
- package/dist/components/AnchoredTooltip/AnchoredTooltip.js +30 -30
- package/dist/components/AnimatedEntrance/AnimatedEntrance.js +27 -40
- package/dist/components/AsyncWrapper/AsyncWrapper.js +2 -2
- package/dist/components/Avatar/Avatar.js +4 -4
- package/dist/components/BucketFill/BucketFill.js +9 -9
- package/dist/components/Button/Button.js +4 -4
- package/dist/components/Card/Card.js +1 -1
- package/dist/components/Chart/Chart.view.js +34 -34
- package/dist/components/CheckBox/CheckBox.js +3 -3
- package/dist/components/Collapsable/Collapsable.js +18 -18
- package/dist/components/Countdown/Countdown.js +16 -16
- package/dist/components/Divider/Divider.js +1 -1
- package/dist/components/EmailInput/EmailInput.js +4 -4
- package/dist/components/FadeIn/FadeIn.js +9 -9
- package/dist/components/FileInput/FileInput.js +6 -6
- package/dist/components/FileInput/View/BigFactory/BigFactory.js +1 -1
- package/dist/components/FileInput/View/Compact/Compact.js +6 -6
- package/dist/components/FlowController/FlowController.js +4 -4
- package/dist/components/Form/Form.js +17 -28
- package/dist/components/Freeze/Freeze.js +1 -1
- package/dist/components/HSForms/HSForms.js +9 -11
- package/dist/components/Header/Header.js +7 -7
- package/dist/components/HeaderCloseBtn/HeaderCloseBtn.js +1 -1
- package/dist/components/InfinityScroll/InfinityScroll.js +25 -25
- package/dist/components/Input/Input.js +13 -13
- package/dist/components/InstantCounter/InstantCounter.js +9 -9
- package/dist/components/LavaLamp/LavaLamp.data.js +25 -25
- package/dist/components/LavaLamp/LavaLamp.js +7 -7
- package/dist/components/LavaLamp/v2/LavaLamp.js +29 -45
- package/dist/components/LinkToId/LinkToId.js +7 -7
- package/dist/components/Loader/Loader.js +2 -2
- package/dist/components/LoaderDotsIndicator/LoaderDotsIndicator.js +6 -6
- package/dist/components/LoopableVideo/LoopableVideo.js +4 -4
- package/dist/components/MainGrid/MainGrid.js +2 -2
- package/dist/components/MutableHamburgerButton/MutableHamburgerButton.js +2 -2
- package/dist/components/Notification/Notification.js +1 -1
- package/dist/components/OrderableList/OrderableList.js +113 -138
- package/dist/components/PaginationIndicator/PaginationIndicator.js +50 -50
- package/dist/components/Parallax/Parallax.js +39 -39
- package/dist/components/Parallax/math/helpers.js +18 -19
- package/dist/components/PasswordInput/PasswordInput.js +10 -10
- package/dist/components/PingPongText/PingPongText.js +15 -15
- package/dist/components/PixelatedScan/PixelatedScan.js +19 -19
- package/dist/components/Portal/Portal.js +10 -10
- package/dist/components/ProgressBar/ProgressBar.js +6 -6
- package/dist/components/ProgressTexts/ProgressTexts.js +3 -3
- package/dist/components/Radio/Radio.js +3 -3
- package/dist/components/SectionContainer/SectionContainer.js +1 -1
- package/dist/components/Select/Select.js +13 -13
- package/dist/components/Skeleton/Skeleton.js +1 -1
- package/dist/components/Spacing/Spacing.js +1 -1
- package/dist/components/StaticScroller/StaticScroller.js +12 -12
- package/dist/components/Switch/Switch.js +2 -2
- package/dist/components/Table/Table.js +11 -11
- package/dist/components/Tabs/Tabs.js +3 -3
- package/dist/components/Text/Text.js +5 -5
- package/dist/components/Transition/MasksFactory/DiagonalReveal.js +5 -5
- package/dist/components/Transition/MasksFactory/DiagonalSquareToBalls.js +17 -17
- package/dist/components/Transition/MasksFactory/PhysicsSquares.js +13 -13
- package/dist/components/Transition/MasksFactory/SquareToBalls.js +9 -9
- package/dist/components/Transition/MasksFactory/utils.js +8 -8
- package/dist/components/Transition/Transition.js +49 -49
- package/dist/components/UncontrolledTransition/UncontrolledTransition.js +7 -7
- package/dist/components/WalletConnectionWrapper/WalletConnectionWrapper.js +44 -82
- package/dist/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.js +6 -6
- package/dist/context/AsyncProcess.js +19 -42
- package/dist/context/CustomBrowserRouter.js +6 -6
- package/dist/context/OneUIProvider.js +15 -15
- package/dist/hooks/logs/useDependencyChangeDetection.js +2 -5
- package/dist/hooks/persistence/useLocalStorage.js +7 -7
- package/dist/hooks/shims/ObjectWatchShim.js +1 -15
- package/dist/hooks/ui/useAdaptiveImage.js +6 -6
- package/dist/hooks/ui/useBreakpoint.js +5 -5
- package/dist/hooks/ui/useCustomScrollbar.js +2 -2
- package/dist/hooks/ui/useMouseHover.js +4 -4
- package/dist/hooks/ui/usePaginationControls.js +34 -34
- package/dist/hooks/ui/useSnapToViewport.js +3 -3
- package/dist/hooks/ui/useTilt.js +38 -38
- package/dist/hooks/ui/useZoomable.js +20 -20
- package/dist/hooks/useAsyncControl.js +21 -38
- package/dist/hooks/useContainedRepositioning.js +22 -22
- package/dist/hooks/useCustomHistory.js +2 -2
- package/dist/hooks/useElementFit.js +6 -6
- package/dist/hooks/useFirestoreWatch.js +26 -39
- package/dist/hooks/useForm.js +8 -8
- package/dist/hooks/useFreeze.js +1 -1
- package/dist/hooks/useHero.js +82 -90
- package/dist/hooks/useIntersection.js +3 -3
- package/dist/hooks/useMergeRefs.js +3 -7
- package/dist/hooks/useObserve.js +5 -5
- package/dist/hooks/usePagination.js +39 -59
- package/dist/hooks/usePooledOperation.js +8 -22
- package/dist/hooks/usePooling.js +17 -33
- package/dist/hooks/useRebound.js +5 -5
- package/dist/hooks/useShortIntl.js +13 -13
- package/dist/hooks/utility/useEvents.js +5 -5
- package/dist/hooks/utility/useModule.js +3 -3
- package/dist/hooks/utility/useQuery.js +1 -1
- package/dist/models/DebugLogger.js +2 -2
- package/dist/models/GenericContract.js +1 -1
- package/dist/storybookUtils/index.js +1 -1
- package/dist/utility.d.js +3 -3
- package/dist/utils/blockchain.js +29 -102
- package/dist/utils/flatten.js +3 -3
- package/dist/utils/html.utils.js +1 -1
- package/package.json +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
|
-
|
|
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
|
-
|
|
22
|
+
const elementToCheck = (0, _react.useRef)(null);
|
|
23
23
|
(0, _react.useEffect)(function () {
|
|
24
|
-
|
|
24
|
+
const el = elementToCheck.current;
|
|
25
25
|
if (!el) return;
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
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
|
-
|
|
51
|
-
curr.style.right = "".concat(
|
|
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
|
-
|
|
67
|
-
|
|
66
|
+
const restore = function restore(_ref2) {
|
|
67
|
+
let propertyName = _ref2.propertyName,
|
|
68
68
|
currentTarget = _ref2.currentTarget;
|
|
69
|
-
|
|
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
|
-
|
|
16
|
-
|
|
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++)
|
|
12
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0)
|
|
11
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
12
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
13
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
14
|
/**
|
|
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
|
-
|
|
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
|
-
|
|
29
|
-
|
|
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
|
-
|
|
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++)
|
|
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)
|
|
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
|
-
|
|
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
|
-
|
|
24
|
+
const unsub = queryFactory.apply(void 0, _toConsumableArray(params))(function (changes) {
|
|
26
25
|
updateList(function () {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
});
|
package/dist/hooks/useForm.js
CHANGED
|
@@ -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++)
|
|
18
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0)
|
|
17
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
18
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
19
19
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
20
|
function useContextForm(config, initialState) {
|
|
21
|
-
|
|
21
|
+
const _useState = (0, _react.useState)(initialState),
|
|
22
22
|
_useState2 = _slicedToArray(_useState, 2),
|
|
23
23
|
form = _useState2[0],
|
|
24
24
|
setForm = _useState2[1];
|
|
25
|
-
|
|
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
|
-
|
|
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
|
-
|
|
35
|
+
const validFormFields = (0, _react.useMemo)(function () {
|
|
36
36
|
return Object.keys(config).reduce(function (result, field) {
|
|
37
|
-
|
|
38
|
-
|
|
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
|
package/dist/hooks/useFreeze.js
CHANGED
|
@@ -10,7 +10,7 @@ var _react = require("react");
|
|
|
10
10
|
* it returns the previous valid value
|
|
11
11
|
*/
|
|
12
12
|
function useFreeze(something) {
|
|
13
|
-
|
|
13
|
+
const currChildOrPrev = (0, _react.useRef)();
|
|
14
14
|
currChildOrPrev.current = something || currChildOrPrev.current;
|
|
15
15
|
return currChildOrPrev.current || null;
|
|
16
16
|
}
|
package/dist/hooks/useHero.js
CHANGED
|
@@ -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)
|
|
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++)
|
|
29
|
-
|
|
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
|
-
|
|
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
|
-
|
|
37
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
39
38
|
propsToTransition: []
|
|
40
39
|
};
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
53
|
-
|
|
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
|
-
|
|
60
|
-
|
|
58
|
+
const allPropsToTransition = ["width", "height", "top", "left"].concat(_toConsumableArray(propsToTransition));
|
|
59
|
+
const shouldHeroFn = events.onHeroDetect || function () {
|
|
61
60
|
return true;
|
|
62
61
|
};
|
|
63
|
-
|
|
62
|
+
const otherElements = getHerosOnScreen().filter(function (el) {
|
|
64
63
|
return shouldHeroFn(el, heroRef.current);
|
|
65
64
|
});
|
|
66
|
-
|
|
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
|
-
|
|
67
|
+
const otherElement = otherElements.find(function (el) {
|
|
69
68
|
return el !== heroRef.current;
|
|
70
69
|
});
|
|
71
70
|
if (otherElement) {
|
|
72
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
90
|
+
const _ref = events.onBeforeTransition ? events.onBeforeTransition(otherElement, heroRef.current) : [viewport, viewport],
|
|
92
91
|
_ref2 = _slicedToArray(_ref, 2),
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
if (events.onHeroCloned && !oldClone) events.onHeroCloned(
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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(
|
|
124
|
+
document.body.appendChild(clone);
|
|
126
125
|
}
|
|
127
126
|
heroRef.current.style.visibility = "hidden";
|
|
128
127
|
otherElement.style.visibility = "hidden";
|
|
129
|
-
|
|
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
|
-
|
|
134
|
-
|
|
132
|
+
const el = heroRef.current;
|
|
133
|
+
const cleanup = function cleanup() {
|
|
135
134
|
if (events.onHeroEnd) events.onHeroEnd();
|
|
136
|
-
|
|
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(
|
|
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
|
-
|
|
147
|
+
const willMove = setCloneToCoordinatesOf(el);
|
|
149
148
|
if (!willMove) cleanup();else {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
|
155
|
+
if (initialOffset === undefined) initialOffset = d.scrollTop;else clone.style.marginTop = "".concat(-(d.scrollTop - initialOffset), "px");
|
|
168
156
|
}
|
|
169
157
|
};
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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
|
-
|
|
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
|
-
|
|
200
|
-
|
|
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
|
-
|
|
208
|
-
|
|
195
|
+
const containerBounds = container.getBoundingClientRect();
|
|
196
|
+
const isContainerOutsideViewport = isElementOutsideViewport(containerBounds);
|
|
209
197
|
if (isContainerOutsideViewport) return true;
|
|
210
|
-
|
|
211
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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
|
-
|
|
9
|
+
const _useRef = (0, _react.useRef)([]),
|
|
10
10
|
targetMap = _useRef.current;
|
|
11
|
-
|
|
11
|
+
const _useRef2 = (0, _react.useRef)("IntersectionObserver" in window ? new IntersectionObserver(function (els) {
|
|
12
12
|
els.forEach(function (e, i) {
|
|
13
|
-
|
|
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 (
|
|
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 (
|
|
34
|
-
|
|
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
|
}
|