@seed-design/stackflow 1.1.19 → 1.1.21
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/lib/_virtual/_rolldown/runtime.cjs +34 -0
- package/lib/_virtual/_rolldown/runtime.js +14 -0
- package/lib/components/AppBar/AppBar.cjs +88 -87
- package/lib/components/AppBar/AppBar.d.ts +3 -0
- package/lib/components/AppBar/AppBar.js +86 -84
- package/lib/components/AppBar/AppBar.namespace.cjs +20 -15
- package/lib/components/AppBar/AppBar.namespace.d.ts +2 -2
- package/lib/components/AppBar/AppBar.namespace.js +15 -1
- package/lib/components/AppBar/index.cjs +17 -17
- package/lib/components/AppBar/index.d.ts +2 -2
- package/lib/components/AppBar/index.js +3 -3
- package/lib/components/AppScreen/AppScreen.cjs +46 -61
- package/lib/components/AppScreen/AppScreen.js +45 -57
- package/lib/components/AppScreen/AppScreen.namespace.cjs +17 -13
- package/lib/components/AppScreen/AppScreen.namespace.js +12 -1
- package/lib/components/AppScreen/index.cjs +14 -15
- package/lib/components/AppScreen/index.js +3 -3
- package/lib/components/index.cjs +30 -25
- package/lib/components/index.js +5 -6
- package/lib/hooks/index.cjs +3 -9
- package/lib/hooks/index.js +2 -1
- package/lib/hooks/useActivityZIndexBase.cjs +12 -11
- package/lib/hooks/useActivityZIndexBase.js +11 -7
- package/lib/index.cjs +41 -31
- package/lib/index.js +8 -10
- package/lib/plugin.cjs +16 -16
- package/lib/plugin.js +14 -12
- package/lib/primitive/AppBar/AppBar.cjs +41 -33
- package/lib/primitive/AppBar/AppBar.js +40 -29
- package/lib/primitive/AppBar/AppBar.namespace.cjs +16 -12
- package/lib/primitive/AppBar/AppBar.namespace.js +11 -1
- package/lib/primitive/AppBar/anatomy.cjs +18 -0
- package/lib/primitive/AppBar/anatomy.d.ts +15 -0
- package/lib/primitive/AppBar/anatomy.js +18 -0
- package/lib/primitive/AppBar/index.cjs +13 -14
- package/lib/primitive/AppBar/index.js +3 -3
- package/lib/primitive/AppBar/useAppBar.cjs +29 -36
- package/lib/primitive/AppBar/useAppBar.js +28 -32
- package/lib/primitive/AppBar/useAppBarContext.cjs +11 -18
- package/lib/primitive/AppBar/useAppBarContext.js +10 -14
- package/lib/primitive/AppScreen/AppScreen.cjs +49 -52
- package/lib/primitive/AppScreen/AppScreen.js +48 -48
- package/lib/primitive/AppScreen/AppScreen.namespace.cjs +16 -12
- package/lib/primitive/AppScreen/AppScreen.namespace.js +11 -1
- package/lib/primitive/AppScreen/anatomy.cjs +17 -0
- package/lib/primitive/AppScreen/anatomy.d.ts +14 -0
- package/lib/primitive/AppScreen/anatomy.js +17 -0
- package/lib/primitive/AppScreen/index.cjs +15 -16
- package/lib/primitive/AppScreen/index.js +4 -4
- package/lib/primitive/AppScreen/useAppScreen.cjs +60 -63
- package/lib/primitive/AppScreen/useAppScreen.js +59 -59
- package/lib/primitive/AppScreen/useAppScreenContext.cjs +11 -18
- package/lib/primitive/AppScreen/useAppScreenContext.js +10 -14
- package/lib/primitive/GlobalInteraction/GlobalInteraction.cjs +21 -26
- package/lib/primitive/GlobalInteraction/GlobalInteraction.js +20 -22
- package/lib/primitive/GlobalInteraction/animation.cjs +303 -0
- package/lib/primitive/GlobalInteraction/animation.d.ts +16 -0
- package/lib/primitive/GlobalInteraction/animation.js +299 -0
- package/lib/primitive/GlobalInteraction/constants.cjs +9 -0
- package/lib/primitive/GlobalInteraction/constants.d.ts +19 -0
- package/lib/primitive/GlobalInteraction/constants.js +8 -0
- package/lib/primitive/GlobalInteraction/dom.cjs +147 -0
- package/lib/primitive/GlobalInteraction/dom.d.ts +44 -0
- package/lib/primitive/GlobalInteraction/dom.js +140 -0
- package/lib/primitive/GlobalInteraction/index.cjs +5 -11
- package/lib/primitive/GlobalInteraction/index.js +3 -2
- package/lib/primitive/GlobalInteraction/useGlobalInteraction.cjs +220 -133
- package/lib/primitive/GlobalInteraction/useGlobalInteraction.d.ts +10 -26
- package/lib/primitive/GlobalInteraction/useGlobalInteraction.js +219 -129
- package/lib/primitive/GlobalInteraction/useGlobalInteractionContext.cjs +11 -18
- package/lib/primitive/GlobalInteraction/useGlobalInteractionContext.js +10 -14
- package/lib/primitive/GlobalInteraction/useSwipeBack.cjs +71 -55
- package/lib/primitive/GlobalInteraction/useSwipeBack.d.ts +19 -2
- package/lib/primitive/GlobalInteraction/useSwipeBack.js +70 -51
- package/lib/primitive/index.cjs +55 -27
- package/lib/primitive/index.js +26 -9
- package/lib/primitive/private/useElementOffset.cjs +29 -51
- package/lib/primitive/private/useElementOffset.js +27 -28
- package/lib/primitive/private/useTopActivity.cjs +22 -31
- package/lib/primitive/private/useTopActivity.js +21 -27
- package/lib/utils/createStyleContext.cjs +91 -74
- package/lib/utils/createStyleContext.js +89 -70
- package/lib/utils/styled.cjs +13 -20
- package/lib/utils/styled.js +12 -16
- package/package.json +4 -4
- package/src/components/AppBar/AppBar.namespace.ts +2 -0
- package/src/components/AppBar/AppBar.tsx +29 -3
- package/src/components/AppBar/index.ts +2 -0
- package/src/primitive/AppBar/AppBar.tsx +4 -1
- package/src/primitive/AppBar/anatomy.ts +16 -0
- package/src/primitive/AppBar/useAppBar.tsx +2 -1
- package/src/primitive/AppScreen/anatomy.ts +15 -0
- package/src/primitive/AppScreen/useAppScreen.tsx +5 -4
- package/src/primitive/GlobalInteraction/animation.ts +447 -0
- package/src/primitive/GlobalInteraction/constants.ts +24 -0
- package/src/primitive/GlobalInteraction/dom.ts +211 -0
- package/src/primitive/GlobalInteraction/useGlobalInteraction.ts +302 -129
- package/src/primitive/GlobalInteraction/useSwipeBack.ts +64 -26
|
@@ -1,54 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { useGlobalInteractionContext } from "./useGlobalInteractionContext.js";
|
|
3
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
4
|
+
import { useCallbackRef } from "@radix-ui/react-use-callback-ref";
|
|
5
|
+
//#region src/primitive/GlobalInteraction/useSwipeBack.ts
|
|
5
6
|
function useSwipeBack(props) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
7
|
+
const { swipeBackDisplacementRatioThreshold: displacementRatioThreshold, swipeBackVelocityThreshold: velocityThreshold } = props;
|
|
8
|
+
const onSwipeStart = useCallbackRef(props.onSwipeBackStart);
|
|
9
|
+
const onSwipeMove = useCallbackRef(props.onSwipeBackMove);
|
|
10
|
+
const onSwipeEnd = useCallbackRef(props.onSwipeBackEnd);
|
|
11
|
+
const { startSwipeBack, moveSwipeBack, endSwipeBack, resetSwipeBack } = useGlobalInteractionContext();
|
|
12
|
+
const rAFLockRef = useRef(false);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
return () => {
|
|
15
|
+
resetSwipeBack();
|
|
16
|
+
};
|
|
17
|
+
}, [resetSwipeBack]);
|
|
18
|
+
return useMemo(() => ({
|
|
19
|
+
activityProps: { "data-swipe-back": "" },
|
|
20
|
+
layerProps: {},
|
|
21
|
+
edgeProps: {
|
|
22
|
+
tabIndex: -1,
|
|
23
|
+
onTouchStart: (e) => {
|
|
24
|
+
const x0 = e.touches[0].clientX;
|
|
25
|
+
startSwipeBack({
|
|
26
|
+
x0,
|
|
27
|
+
t0: Date.now()
|
|
28
|
+
});
|
|
29
|
+
onSwipeStart();
|
|
30
|
+
},
|
|
31
|
+
onTouchMove: (e) => {
|
|
32
|
+
if (rAFLockRef.current) return;
|
|
33
|
+
rAFLockRef.current = true;
|
|
34
|
+
const x = e.touches[0].clientX;
|
|
35
|
+
const t = Date.now();
|
|
36
|
+
requestAnimationFrame(() => {
|
|
37
|
+
const ctx = moveSwipeBack({
|
|
38
|
+
x,
|
|
39
|
+
t
|
|
40
|
+
});
|
|
41
|
+
rAFLockRef.current = false;
|
|
42
|
+
onSwipeMove({
|
|
43
|
+
displacement: ctx.displacement,
|
|
44
|
+
displacementRatio: ctx.displacementRatio
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
onTouchEnd: () => {
|
|
49
|
+
onSwipeEnd({ swiped: endSwipeBack({
|
|
50
|
+
displacementRatioThreshold,
|
|
51
|
+
velocityThreshold
|
|
52
|
+
}) });
|
|
53
|
+
},
|
|
54
|
+
onTouchCancel: () => {
|
|
55
|
+
onSwipeEnd({ swiped: endSwipeBack({
|
|
56
|
+
displacementRatioThreshold,
|
|
57
|
+
velocityThreshold
|
|
58
|
+
}) });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}), [
|
|
62
|
+
startSwipeBack,
|
|
63
|
+
moveSwipeBack,
|
|
64
|
+
endSwipeBack,
|
|
65
|
+
onSwipeStart,
|
|
66
|
+
onSwipeMove,
|
|
67
|
+
onSwipeEnd,
|
|
68
|
+
displacementRatioThreshold,
|
|
69
|
+
velocityThreshold
|
|
70
|
+
]);
|
|
52
71
|
}
|
|
53
|
-
|
|
72
|
+
//#endregion
|
|
54
73
|
export { useSwipeBack };
|
package/lib/primitive/index.cjs
CHANGED
|
@@ -1,27 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
exports
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_useGlobalInteractionContext = require("./GlobalInteraction/useGlobalInteractionContext.cjs");
|
|
4
|
+
const require_useAppScreenContext = require("./AppScreen/useAppScreenContext.cjs");
|
|
5
|
+
const require_AppScreen = require("./AppScreen/AppScreen.cjs");
|
|
6
|
+
const require_AppScreen_namespace = require("./AppScreen/AppScreen.namespace.cjs");
|
|
7
|
+
const require_AppBar = require("./AppBar/AppBar.cjs");
|
|
8
|
+
const require_AppBar_namespace = require("./AppBar/AppBar.namespace.cjs");
|
|
9
|
+
const require_GlobalInteraction = require("./GlobalInteraction/GlobalInteraction.cjs");
|
|
10
|
+
//#region src/primitive/index.ts
|
|
11
|
+
var primitive_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
12
|
+
AppBar: () => require_AppBar_namespace.AppBar_namespace_exports,
|
|
13
|
+
AppBarLeft: () => require_AppBar.AppBarLeft,
|
|
14
|
+
AppBarMain: () => require_AppBar.AppBarMain,
|
|
15
|
+
AppBarRight: () => require_AppBar.AppBarRight,
|
|
16
|
+
AppBarRoot: () => require_AppBar.AppBarRoot,
|
|
17
|
+
AppScreen: () => require_AppScreen_namespace.AppScreen_namespace_exports,
|
|
18
|
+
AppScreenDim: () => require_AppScreen.AppScreenDim,
|
|
19
|
+
AppScreenEdge: () => require_AppScreen.AppScreenEdge,
|
|
20
|
+
AppScreenLayer: () => require_AppScreen.AppScreenLayer,
|
|
21
|
+
AppScreenRoot: () => require_AppScreen.AppScreenRoot,
|
|
22
|
+
GlobalInteraction: () => require_GlobalInteraction.GlobalInteraction,
|
|
23
|
+
useAppScreenContext: () => require_useAppScreenContext.useAppScreenContext,
|
|
24
|
+
useGlobalInteractionContext: () => require_useGlobalInteractionContext.useGlobalInteractionContext
|
|
25
|
+
});
|
|
26
|
+
//#endregion
|
|
27
|
+
Object.defineProperty(exports, "AppBar", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function() {
|
|
30
|
+
return require_AppBar_namespace.AppBar_namespace_exports;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
exports.AppBarLeft = require_AppBar.AppBarLeft;
|
|
34
|
+
exports.AppBarMain = require_AppBar.AppBarMain;
|
|
35
|
+
exports.AppBarRight = require_AppBar.AppBarRight;
|
|
36
|
+
exports.AppBarRoot = require_AppBar.AppBarRoot;
|
|
37
|
+
Object.defineProperty(exports, "AppScreen", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function() {
|
|
40
|
+
return require_AppScreen_namespace.AppScreen_namespace_exports;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
exports.AppScreenDim = require_AppScreen.AppScreenDim;
|
|
44
|
+
exports.AppScreenEdge = require_AppScreen.AppScreenEdge;
|
|
45
|
+
exports.AppScreenLayer = require_AppScreen.AppScreenLayer;
|
|
46
|
+
exports.AppScreenRoot = require_AppScreen.AppScreenRoot;
|
|
47
|
+
exports.GlobalInteraction = require_GlobalInteraction.GlobalInteraction;
|
|
48
|
+
Object.defineProperty(exports, "primitive_exports", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function() {
|
|
51
|
+
return primitive_exports;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
exports.useAppScreenContext = require_useAppScreenContext.useAppScreenContext;
|
|
55
|
+
exports.useGlobalInteractionContext = require_useGlobalInteractionContext.useGlobalInteractionContext;
|
package/lib/primitive/index.js
CHANGED
|
@@ -1,9 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { useGlobalInteractionContext } from "./GlobalInteraction/useGlobalInteractionContext.js";
|
|
3
|
+
import { useAppScreenContext } from "./AppScreen/useAppScreenContext.js";
|
|
4
|
+
import { AppScreenDim, AppScreenEdge, AppScreenLayer, AppScreenRoot } from "./AppScreen/AppScreen.js";
|
|
5
|
+
import { AppScreen_namespace_exports } from "./AppScreen/AppScreen.namespace.js";
|
|
6
|
+
import { AppBarLeft, AppBarMain, AppBarRight, AppBarRoot } from "./AppBar/AppBar.js";
|
|
7
|
+
import { AppBar_namespace_exports } from "./AppBar/AppBar.namespace.js";
|
|
8
|
+
import { GlobalInteraction } from "./GlobalInteraction/GlobalInteraction.js";
|
|
9
|
+
//#region src/primitive/index.ts
|
|
10
|
+
var primitive_exports = /* @__PURE__ */ __exportAll({
|
|
11
|
+
AppBar: () => AppBar_namespace_exports,
|
|
12
|
+
AppBarLeft: () => AppBarLeft,
|
|
13
|
+
AppBarMain: () => AppBarMain,
|
|
14
|
+
AppBarRight: () => AppBarRight,
|
|
15
|
+
AppBarRoot: () => AppBarRoot,
|
|
16
|
+
AppScreen: () => AppScreen_namespace_exports,
|
|
17
|
+
AppScreenDim: () => AppScreenDim,
|
|
18
|
+
AppScreenEdge: () => AppScreenEdge,
|
|
19
|
+
AppScreenLayer: () => AppScreenLayer,
|
|
20
|
+
AppScreenRoot: () => AppScreenRoot,
|
|
21
|
+
GlobalInteraction: () => GlobalInteraction,
|
|
22
|
+
useAppScreenContext: () => useAppScreenContext,
|
|
23
|
+
useGlobalInteractionContext: () => useGlobalInteractionContext
|
|
24
|
+
});
|
|
25
|
+
//#endregion
|
|
26
|
+
export { AppBar_namespace_exports as AppBar, AppBarLeft, AppBarMain, AppBarRight, AppBarRoot, AppScreen_namespace_exports as AppScreen, AppScreenDim, AppScreenEdge, AppScreenLayer, AppScreenRoot, GlobalInteraction, primitive_exports, useAppScreenContext, useGlobalInteractionContext };
|
|
@@ -1,54 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function _interopNamespaceDefault(e) {
|
|
9
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
|
|
10
|
-
if (e) {
|
|
11
|
-
for (const k in e) {
|
|
12
|
-
if (k !== 'default') {
|
|
13
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: () => e[k]
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
n.default = e;
|
|
22
|
-
return Object.freeze(n);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
26
|
-
|
|
27
|
-
const useLayoutEffect = typeof window !== "undefined" ? React__namespace.useLayoutEffect : React__namespace.useEffect;
|
|
1
|
+
"use client";
|
|
2
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
react = require_runtime.__toESM(react);
|
|
5
|
+
//#region src/primitive/private/useElementOffset.ts
|
|
6
|
+
var useLayoutEffect = typeof window !== "undefined" ? react.useLayoutEffect : react.useEffect;
|
|
28
7
|
function useElementOffset(element) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return offset;
|
|
8
|
+
const [offset, setOffset] = react.useState(void 0);
|
|
9
|
+
useLayoutEffect(() => {
|
|
10
|
+
if (!element) {
|
|
11
|
+
setOffset(void 0);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (element) {
|
|
15
|
+
setOffset({
|
|
16
|
+
fromLeft: element.offsetLeft + element.offsetWidth,
|
|
17
|
+
fromRight: (element.offsetParent ?? document.body).clientWidth - element.offsetLeft
|
|
18
|
+
});
|
|
19
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
20
|
+
setOffset({
|
|
21
|
+
fromLeft: element.offsetLeft + element.offsetWidth,
|
|
22
|
+
fromRight: (element.offsetParent ?? document.body).clientWidth - element.offsetLeft
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
resizeObserver.observe(element);
|
|
26
|
+
return () => resizeObserver.unobserve(element);
|
|
27
|
+
}
|
|
28
|
+
}, [element]);
|
|
29
|
+
return offset;
|
|
52
30
|
}
|
|
53
|
-
|
|
31
|
+
//#endregion
|
|
54
32
|
exports.useElementOffset = useElementOffset;
|
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
import * as React from
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
//#region src/primitive/private/useElementOffset.ts
|
|
4
|
+
var useLayoutEffect$1 = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
5
5
|
function useElementOffset(element) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return offset;
|
|
6
|
+
const [offset, setOffset] = React.useState(void 0);
|
|
7
|
+
useLayoutEffect$1(() => {
|
|
8
|
+
if (!element) {
|
|
9
|
+
setOffset(void 0);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (element) {
|
|
13
|
+
setOffset({
|
|
14
|
+
fromLeft: element.offsetLeft + element.offsetWidth,
|
|
15
|
+
fromRight: (element.offsetParent ?? document.body).clientWidth - element.offsetLeft
|
|
16
|
+
});
|
|
17
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
18
|
+
setOffset({
|
|
19
|
+
fromLeft: element.offsetLeft + element.offsetWidth,
|
|
20
|
+
fromRight: (element.offsetParent ?? document.body).clientWidth - element.offsetLeft
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
resizeObserver.observe(element);
|
|
24
|
+
return () => resizeObserver.unobserve(element);
|
|
25
|
+
}
|
|
26
|
+
}, [element]);
|
|
27
|
+
return offset;
|
|
29
28
|
}
|
|
30
|
-
|
|
29
|
+
//#endregion
|
|
31
30
|
export { useElementOffset };
|
|
@@ -1,34 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const react = require('@stackflow/react');
|
|
7
|
-
const React = require('react');
|
|
8
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let _stackflow_react = require("@stackflow/react");
|
|
5
|
+
//#region src/primitive/private/useTopActivity.ts
|
|
9
6
|
function useTopActivity() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}, [topId]);
|
|
27
|
-
return {
|
|
28
|
-
transitionState,
|
|
29
|
-
activityType,
|
|
30
|
-
transitionStyle
|
|
31
|
-
};
|
|
7
|
+
const stack = (0, _stackflow_react.useStack)();
|
|
8
|
+
if (!stack) throw new Error("useStack is not available in the context. Make sure you are using @stackflow/react >= 1.4.1. (https://github.com/daangn/stackflow/blob/main/integrations/react/CHANGELOG.md#141)");
|
|
9
|
+
const topId = stack.activities.find((activity) => activity.isTop)?.id;
|
|
10
|
+
const transitionState = stack.activities.find((activity) => activity.isTop)?.transitionState ?? "enter-done";
|
|
11
|
+
const [topEl, setTopEl] = (0, react.useState)(null);
|
|
12
|
+
const activityType = topEl?.dataset["activityType"];
|
|
13
|
+
const transitionStyle = topEl?.dataset["transitionStyle"];
|
|
14
|
+
(0, react.useLayoutEffect)(() => {
|
|
15
|
+
if (!topId) return;
|
|
16
|
+
setTopEl(document.querySelector(`[data-activity-id="${topId}"]`));
|
|
17
|
+
}, [topId]);
|
|
18
|
+
return {
|
|
19
|
+
transitionState,
|
|
20
|
+
activityType,
|
|
21
|
+
transitionStyle
|
|
22
|
+
};
|
|
32
23
|
}
|
|
33
|
-
|
|
24
|
+
//#endregion
|
|
34
25
|
exports.useTopActivity = useTopActivity;
|
|
@@ -1,30 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { useLayoutEffect, useState } from "react";
|
|
3
|
+
import { useStack } from "@stackflow/react";
|
|
4
|
+
//#region src/primitive/private/useTopActivity.ts
|
|
5
5
|
function useTopActivity() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}, [topId]);
|
|
23
|
-
return {
|
|
24
|
-
transitionState,
|
|
25
|
-
activityType,
|
|
26
|
-
transitionStyle
|
|
27
|
-
};
|
|
6
|
+
const stack = useStack();
|
|
7
|
+
if (!stack) throw new Error("useStack is not available in the context. Make sure you are using @stackflow/react >= 1.4.1. (https://github.com/daangn/stackflow/blob/main/integrations/react/CHANGELOG.md#141)");
|
|
8
|
+
const topId = stack.activities.find((activity) => activity.isTop)?.id;
|
|
9
|
+
const transitionState = stack.activities.find((activity) => activity.isTop)?.transitionState ?? "enter-done";
|
|
10
|
+
const [topEl, setTopEl] = useState(null);
|
|
11
|
+
const activityType = topEl?.dataset["activityType"];
|
|
12
|
+
const transitionStyle = topEl?.dataset["transitionStyle"];
|
|
13
|
+
useLayoutEffect(() => {
|
|
14
|
+
if (!topId) return;
|
|
15
|
+
setTopEl(document.querySelector(`[data-activity-id="${topId}"]`));
|
|
16
|
+
}, [topId]);
|
|
17
|
+
return {
|
|
18
|
+
transitionState,
|
|
19
|
+
activityType,
|
|
20
|
+
transitionStyle
|
|
21
|
+
};
|
|
28
22
|
}
|
|
29
|
-
|
|
23
|
+
//#endregion
|
|
30
24
|
export { useTopActivity };
|