@seed-design/stackflow 1.1.20 → 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.
Files changed (93) hide show
  1. package/lib/_virtual/_rolldown/runtime.cjs +34 -0
  2. package/lib/_virtual/_rolldown/runtime.js +14 -0
  3. package/lib/components/AppBar/AppBar.cjs +86 -102
  4. package/lib/components/AppBar/AppBar.js +84 -98
  5. package/lib/components/AppBar/AppBar.namespace.cjs +20 -16
  6. package/lib/components/AppBar/AppBar.namespace.js +15 -1
  7. package/lib/components/AppBar/index.cjs +17 -18
  8. package/lib/components/AppBar/index.js +3 -3
  9. package/lib/components/AppScreen/AppScreen.cjs +46 -61
  10. package/lib/components/AppScreen/AppScreen.js +45 -57
  11. package/lib/components/AppScreen/AppScreen.namespace.cjs +17 -13
  12. package/lib/components/AppScreen/AppScreen.namespace.js +12 -1
  13. package/lib/components/AppScreen/index.cjs +14 -15
  14. package/lib/components/AppScreen/index.js +3 -3
  15. package/lib/components/index.cjs +30 -26
  16. package/lib/components/index.js +5 -6
  17. package/lib/hooks/index.cjs +3 -9
  18. package/lib/hooks/index.js +2 -1
  19. package/lib/hooks/useActivityZIndexBase.cjs +12 -11
  20. package/lib/hooks/useActivityZIndexBase.js +11 -7
  21. package/lib/index.cjs +41 -32
  22. package/lib/index.js +8 -10
  23. package/lib/plugin.cjs +16 -16
  24. package/lib/plugin.js +14 -12
  25. package/lib/primitive/AppBar/AppBar.cjs +41 -33
  26. package/lib/primitive/AppBar/AppBar.js +40 -29
  27. package/lib/primitive/AppBar/AppBar.namespace.cjs +16 -12
  28. package/lib/primitive/AppBar/AppBar.namespace.js +11 -1
  29. package/lib/primitive/AppBar/anatomy.cjs +18 -0
  30. package/lib/primitive/AppBar/anatomy.d.ts +15 -0
  31. package/lib/primitive/AppBar/anatomy.js +18 -0
  32. package/lib/primitive/AppBar/index.cjs +13 -14
  33. package/lib/primitive/AppBar/index.js +3 -3
  34. package/lib/primitive/AppBar/useAppBar.cjs +29 -36
  35. package/lib/primitive/AppBar/useAppBar.js +28 -32
  36. package/lib/primitive/AppBar/useAppBarContext.cjs +11 -18
  37. package/lib/primitive/AppBar/useAppBarContext.js +10 -14
  38. package/lib/primitive/AppScreen/AppScreen.cjs +49 -52
  39. package/lib/primitive/AppScreen/AppScreen.js +48 -48
  40. package/lib/primitive/AppScreen/AppScreen.namespace.cjs +16 -12
  41. package/lib/primitive/AppScreen/AppScreen.namespace.js +11 -1
  42. package/lib/primitive/AppScreen/anatomy.cjs +17 -0
  43. package/lib/primitive/AppScreen/anatomy.d.ts +14 -0
  44. package/lib/primitive/AppScreen/anatomy.js +17 -0
  45. package/lib/primitive/AppScreen/index.cjs +15 -16
  46. package/lib/primitive/AppScreen/index.js +4 -4
  47. package/lib/primitive/AppScreen/useAppScreen.cjs +60 -63
  48. package/lib/primitive/AppScreen/useAppScreen.js +59 -59
  49. package/lib/primitive/AppScreen/useAppScreenContext.cjs +11 -18
  50. package/lib/primitive/AppScreen/useAppScreenContext.js +10 -14
  51. package/lib/primitive/GlobalInteraction/GlobalInteraction.cjs +21 -26
  52. package/lib/primitive/GlobalInteraction/GlobalInteraction.js +20 -22
  53. package/lib/primitive/GlobalInteraction/animation.cjs +303 -0
  54. package/lib/primitive/GlobalInteraction/animation.d.ts +16 -0
  55. package/lib/primitive/GlobalInteraction/animation.js +299 -0
  56. package/lib/primitive/GlobalInteraction/constants.cjs +9 -0
  57. package/lib/primitive/GlobalInteraction/constants.d.ts +19 -0
  58. package/lib/primitive/GlobalInteraction/constants.js +8 -0
  59. package/lib/primitive/GlobalInteraction/dom.cjs +147 -0
  60. package/lib/primitive/GlobalInteraction/dom.d.ts +44 -0
  61. package/lib/primitive/GlobalInteraction/dom.js +140 -0
  62. package/lib/primitive/GlobalInteraction/index.cjs +5 -11
  63. package/lib/primitive/GlobalInteraction/index.js +3 -2
  64. package/lib/primitive/GlobalInteraction/useGlobalInteraction.cjs +220 -133
  65. package/lib/primitive/GlobalInteraction/useGlobalInteraction.d.ts +10 -26
  66. package/lib/primitive/GlobalInteraction/useGlobalInteraction.js +219 -129
  67. package/lib/primitive/GlobalInteraction/useGlobalInteractionContext.cjs +11 -18
  68. package/lib/primitive/GlobalInteraction/useGlobalInteractionContext.js +10 -14
  69. package/lib/primitive/GlobalInteraction/useSwipeBack.cjs +71 -55
  70. package/lib/primitive/GlobalInteraction/useSwipeBack.d.ts +19 -2
  71. package/lib/primitive/GlobalInteraction/useSwipeBack.js +70 -51
  72. package/lib/primitive/index.cjs +55 -27
  73. package/lib/primitive/index.js +26 -9
  74. package/lib/primitive/private/useElementOffset.cjs +29 -51
  75. package/lib/primitive/private/useElementOffset.js +27 -28
  76. package/lib/primitive/private/useTopActivity.cjs +22 -31
  77. package/lib/primitive/private/useTopActivity.js +21 -27
  78. package/lib/utils/createStyleContext.cjs +91 -74
  79. package/lib/utils/createStyleContext.js +89 -70
  80. package/lib/utils/styled.cjs +13 -20
  81. package/lib/utils/styled.js +12 -16
  82. package/package.json +4 -4
  83. package/src/components/AppBar/AppBar.tsx +9 -3
  84. package/src/primitive/AppBar/AppBar.tsx +4 -1
  85. package/src/primitive/AppBar/anatomy.ts +16 -0
  86. package/src/primitive/AppBar/useAppBar.tsx +2 -1
  87. package/src/primitive/AppScreen/anatomy.ts +15 -0
  88. package/src/primitive/AppScreen/useAppScreen.tsx +5 -4
  89. package/src/primitive/GlobalInteraction/animation.ts +447 -0
  90. package/src/primitive/GlobalInteraction/constants.ts +24 -0
  91. package/src/primitive/GlobalInteraction/dom.ts +211 -0
  92. package/src/primitive/GlobalInteraction/useGlobalInteraction.ts +302 -129
  93. package/src/primitive/GlobalInteraction/useSwipeBack.ts +64 -26
@@ -1,54 +1,73 @@
1
- 'use client';
2
- import { useEffect, useMemo } from 'react';
3
- import { useGlobalInteractionContext } from './useGlobalInteractionContext.js';
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
- const globalInteraction = useGlobalInteractionContext();
7
- const events = globalInteraction.getSwipeBackEvents(props);
8
- useEffect(() => {
9
- return () => {
10
- events.reset();
11
- };
12
- }, [events]);
13
- return useMemo(
14
- () => ({
15
- activityProps: {
16
- "data-swipe-back": ""
17
- },
18
- layerProps: {
19
- onAnimationEnd: (e) => {
20
- if (e.target === e.currentTarget) {
21
- events.reset();
22
- }
23
- },
24
- onTransitionEnd: (e) => {
25
- if (e.target === e.currentTarget) {
26
- events.reset();
27
- }
28
- }
29
- },
30
- edgeProps: {
31
- tabIndex: -1,
32
- onTouchStart: (e) => {
33
- const x0 = e.touches[0].clientX;
34
- const t0 = Date.now();
35
- events.startSwipeBack({ x0, t0 });
36
- },
37
- onTouchMove: (e) => {
38
- const x = e.touches[0].clientX;
39
- const t = Date.now();
40
- events.moveSwipeBack({ x, t });
41
- },
42
- onTouchEnd: () => {
43
- events.endSwipeBack({});
44
- },
45
- onTouchCancel: () => {
46
- events.endSwipeBack({});
47
- }
48
- }
49
- }),
50
- [events]
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 };
@@ -1,27 +1,55 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const AppScreen = require('./AppScreen/AppScreen.cjs');
6
- const AppScreen_namespace = require('./AppScreen/AppScreen.namespace.cjs');
7
- const useAppScreenContext = require('./AppScreen/useAppScreenContext.cjs');
8
- const AppBar = require('./AppBar/AppBar.cjs');
9
- const AppBar_namespace = require('./AppBar/AppBar.namespace.cjs');
10
- const GlobalInteraction = require('./GlobalInteraction/GlobalInteraction.cjs');
11
- const useGlobalInteractionContext = require('./GlobalInteraction/useGlobalInteractionContext.cjs');
12
-
13
-
14
-
15
- exports.AppScreenDim = AppScreen.AppScreenDim;
16
- exports.AppScreenEdge = AppScreen.AppScreenEdge;
17
- exports.AppScreenLayer = AppScreen.AppScreenLayer;
18
- exports.AppScreenRoot = AppScreen.AppScreenRoot;
19
- exports.AppScreen = AppScreen_namespace;
20
- exports.useAppScreenContext = useAppScreenContext.useAppScreenContext;
21
- exports.AppBarLeft = AppBar.AppBarLeft;
22
- exports.AppBarMain = AppBar.AppBarMain;
23
- exports.AppBarRight = AppBar.AppBarRight;
24
- exports.AppBarRoot = AppBar.AppBarRoot;
25
- exports.AppBar = AppBar_namespace;
26
- exports.GlobalInteraction = GlobalInteraction.GlobalInteraction;
27
- exports.useGlobalInteractionContext = useGlobalInteractionContext.useGlobalInteractionContext;
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;
@@ -1,9 +1,26 @@
1
- export { AppScreenDim, AppScreenEdge, AppScreenLayer, AppScreenRoot } from './AppScreen/AppScreen.js';
2
- import * as AppScreen_namespace from './AppScreen/AppScreen.namespace.js';
3
- export { AppScreen_namespace as AppScreen };
4
- export { useAppScreenContext } from './AppScreen/useAppScreenContext.js';
5
- export { AppBarLeft, AppBarMain, AppBarRight, AppBarRoot } from './AppBar/AppBar.js';
6
- import * as AppBar_namespace from './AppBar/AppBar.namespace.js';
7
- export { AppBar_namespace as AppBar };
8
- export { GlobalInteraction } from './GlobalInteraction/GlobalInteraction.js';
9
- export { useGlobalInteractionContext } from './GlobalInteraction/useGlobalInteractionContext.js';
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
- 'use client';
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
-
6
- const React = require('react');
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
- const [offset, setOffset] = React__namespace.useState(
30
- void 0
31
- );
32
- useLayoutEffect(() => {
33
- if (!element) {
34
- setOffset(void 0);
35
- return;
36
- }
37
- if (element) {
38
- setOffset({
39
- fromLeft: element.offsetLeft + element.offsetWidth,
40
- fromRight: (element.offsetParent ?? document.body).clientWidth - element.offsetLeft
41
- });
42
- const resizeObserver = new ResizeObserver(() => {
43
- const fromLeft = element.offsetLeft + element.offsetWidth;
44
- const fromRight = (element.offsetParent ?? document.body).clientWidth - element.offsetLeft;
45
- setOffset({ fromLeft, fromRight });
46
- });
47
- resizeObserver.observe(element);
48
- return () => resizeObserver.unobserve(element);
49
- }
50
- }, [element]);
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
- 'use client';
2
- import * as React from 'react';
3
-
4
- const useLayoutEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
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
- const [offset, setOffset] = React.useState(
7
- void 0
8
- );
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
- const fromLeft = element.offsetLeft + element.offsetWidth;
21
- const fromRight = (element.offsetParent ?? document.body).clientWidth - element.offsetLeft;
22
- setOffset({ fromLeft, fromRight });
23
- });
24
- resizeObserver.observe(element);
25
- return () => resizeObserver.unobserve(element);
26
- }
27
- }, [element]);
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
- 'use client';
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
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
- const stack = react.useStack();
11
- if (!stack) {
12
- throw new Error(
13
- "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)"
14
- );
15
- }
16
- const topId = stack.activities.find((activity) => activity.isTop)?.id;
17
- const topActivity = stack.activities.find((activity) => activity.isTop);
18
- const transitionState = topActivity?.transitionState ?? "enter-done";
19
- const [topEl, setTopEl] = React.useState(null);
20
- const activityType = topEl?.dataset["activityType"];
21
- const transitionStyle = topEl?.dataset["transitionStyle"];
22
- React.useLayoutEffect(() => {
23
- if (!topId) return;
24
- const el = document.querySelector(`[data-activity-id="${topId}"]`);
25
- setTopEl(el);
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
- 'use client';
2
- import { useStack } from '@stackflow/react';
3
- import { useState, useLayoutEffect } from 'react';
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
- const stack = useStack();
7
- if (!stack) {
8
- throw new Error(
9
- "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)"
10
- );
11
- }
12
- const topId = stack.activities.find((activity) => activity.isTop)?.id;
13
- const topActivity = stack.activities.find((activity) => activity.isTop);
14
- const transitionState = topActivity?.transitionState ?? "enter-done";
15
- const [topEl, setTopEl] = useState(null);
16
- const activityType = topEl?.dataset["activityType"];
17
- const transitionStyle = topEl?.dataset["transitionStyle"];
18
- useLayoutEffect(() => {
19
- if (!topId) return;
20
- const el = document.querySelector(`[data-activity-id="${topId}"]`);
21
- setTopEl(el);
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 };