@seed-design/stackflow 0.0.1-rc.1 → 0.0.1-rc.4

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 (92) hide show
  1. package/lib/components/AppBar/AppBar.cjs +92 -0
  2. package/lib/components/AppBar/AppBar.d.ts +13 -12
  3. package/lib/components/AppBar/AppBar.js +81 -0
  4. package/lib/components/AppBar/AppBar.namespace.cjs +15 -0
  5. package/lib/components/AppBar/AppBar.namespace.d.ts +2 -2
  6. package/lib/components/AppBar/AppBar.namespace.js +1 -0
  7. package/lib/components/AppBar/index.cjs +17 -0
  8. package/lib/components/AppBar/index.d.ts +3 -3
  9. package/lib/components/AppBar/index.js +3 -0
  10. package/lib/components/AppScreen/AppScreen.cjs +58 -0
  11. package/lib/components/AppScreen/AppScreen.d.ts +8 -7
  12. package/lib/components/AppScreen/AppScreen.js +50 -0
  13. package/lib/components/AppScreen/AppScreen.namespace.cjs +13 -0
  14. package/lib/components/AppScreen/AppScreen.namespace.d.ts +2 -2
  15. package/lib/components/AppScreen/AppScreen.namespace.js +1 -0
  16. package/lib/components/AppScreen/index.cjs +15 -0
  17. package/lib/components/AppScreen/index.d.ts +3 -3
  18. package/lib/components/AppScreen/index.js +3 -0
  19. package/lib/components/index.cjs +25 -0
  20. package/lib/components/index.d.ts +2 -2
  21. package/lib/components/index.js +6 -0
  22. package/lib/index.cjs +29 -0
  23. package/lib/index.d.ts +3 -3
  24. package/lib/index.js +9 -786
  25. package/lib/plugin.cjs +16 -0
  26. package/lib/plugin.d.ts +1 -1
  27. package/lib/plugin.js +12 -0
  28. package/lib/primitive/AppBar/AppBar.cjs +43 -0
  29. package/lib/primitive/AppBar/AppBar.d.ts +7 -6
  30. package/lib/primitive/AppBar/AppBar.js +36 -0
  31. package/lib/primitive/AppBar/AppBar.namespace.cjs +12 -0
  32. package/lib/primitive/AppBar/AppBar.namespace.d.ts +1 -1
  33. package/lib/primitive/AppBar/AppBar.namespace.js +1 -0
  34. package/lib/primitive/AppBar/index.cjs +14 -0
  35. package/lib/primitive/AppBar/index.d.ts +2 -2
  36. package/lib/primitive/AppBar/index.js +3 -0
  37. package/lib/primitive/AppBar/useAppBar.cjs +38 -0
  38. package/lib/primitive/AppBar/useAppBar.d.ts +168 -167
  39. package/lib/primitive/AppBar/useAppBar.js +34 -0
  40. package/lib/primitive/AppBar/useAppBarContext.cjs +20 -0
  41. package/lib/primitive/AppBar/useAppBarContext.d.ts +3 -2
  42. package/lib/primitive/AppBar/useAppBarContext.js +15 -0
  43. package/lib/primitive/AppScreen/AppScreen.cjs +57 -0
  44. package/lib/primitive/AppScreen/AppScreen.d.ts +7 -6
  45. package/lib/primitive/AppScreen/AppScreen.js +50 -0
  46. package/lib/primitive/AppScreen/AppScreen.namespace.cjs +12 -0
  47. package/lib/primitive/AppScreen/AppScreen.namespace.d.ts +1 -1
  48. package/lib/primitive/AppScreen/AppScreen.namespace.js +1 -0
  49. package/lib/primitive/AppScreen/index.cjs +16 -0
  50. package/lib/primitive/AppScreen/index.d.ts +3 -3
  51. package/lib/primitive/AppScreen/index.js +4 -0
  52. package/lib/primitive/AppScreen/useAppScreen.cjs +64 -0
  53. package/lib/primitive/AppScreen/useAppScreen.d.ts +657 -655
  54. package/lib/primitive/AppScreen/useAppScreen.js +60 -0
  55. package/lib/primitive/AppScreen/useAppScreenContext.cjs +20 -0
  56. package/lib/primitive/AppScreen/useAppScreenContext.d.ts +3 -2
  57. package/lib/primitive/AppScreen/useAppScreenContext.js +15 -0
  58. package/lib/primitive/GlobalInteraction/GlobalInteraction.cjs +27 -0
  59. package/lib/primitive/GlobalInteraction/GlobalInteraction.d.ts +3 -2
  60. package/lib/primitive/GlobalInteraction/GlobalInteraction.js +23 -0
  61. package/lib/primitive/GlobalInteraction/index.cjs +11 -0
  62. package/lib/primitive/GlobalInteraction/index.d.ts +2 -2
  63. package/lib/primitive/GlobalInteraction/index.js +2 -0
  64. package/lib/primitive/GlobalInteraction/useGlobalInteraction.cjs +122 -0
  65. package/lib/primitive/GlobalInteraction/useGlobalInteraction.d.ts +5 -4
  66. package/lib/primitive/GlobalInteraction/useGlobalInteraction.js +118 -0
  67. package/lib/primitive/GlobalInteraction/useGlobalInteractionContext.cjs +20 -0
  68. package/lib/primitive/GlobalInteraction/useGlobalInteractionContext.d.ts +3 -2
  69. package/lib/primitive/GlobalInteraction/useGlobalInteractionContext.js +15 -0
  70. package/lib/primitive/GlobalInteraction/useSwipeBack.cjs +57 -0
  71. package/lib/primitive/GlobalInteraction/useSwipeBack.d.ts +1 -1
  72. package/lib/primitive/GlobalInteraction/useSwipeBack.js +53 -0
  73. package/lib/primitive/index.cjs +27 -0
  74. package/lib/primitive/index.d.ts +3 -3
  75. package/lib/primitive/index.js +9 -0
  76. package/lib/primitive/private/useElementOffset.cjs +53 -0
  77. package/lib/primitive/private/useElementOffset.js +30 -0
  78. package/lib/primitive/private/useTopActivity.cjs +31 -0
  79. package/lib/primitive/private/useTopActivity.js +27 -0
  80. package/lib/utils/createStyleContext.cjs +76 -0
  81. package/lib/utils/createStyleContext.js +72 -0
  82. package/lib/utils/createWithStateProps.d.ts +2 -1
  83. package/package.json +13 -14
  84. package/src/components/AppScreen/AppScreen.namespace.ts +1 -0
  85. package/src/components/AppScreen/{index.tsx → index.ts} +1 -0
  86. package/src/plugin.tsx +1 -1
  87. package/lib/index.js.map +0 -7
  88. package/lib/index.mjs +0 -759
  89. package/lib/index.mjs.map +0 -7
  90. /package/src/components/AppBar/{index.tsx → index.ts} +0 -0
  91. /package/src/components/{index.tsx → index.ts} +0 -0
  92. /package/src/primitive/{index.tsx → index.ts} +0 -0
@@ -0,0 +1,34 @@
1
+ import { elementProps } from '@seed-design/dom-utils';
2
+ import { useState, useMemo } from 'react';
3
+ import { useAppScreenContext } from '../AppScreen/useAppScreenContext.js';
4
+ import { useElementOffset } from '../private/useElementOffset.js';
5
+
6
+ function useAppBar(_props) {
7
+ const { stateProps } = useAppScreenContext();
8
+ const [root, rootRef] = useState(null);
9
+ const [left, leftRef] = useState(null);
10
+ const [right, rightRef] = useState(null);
11
+ const leftOffset = useElementOffset(left);
12
+ const rightOffset = useElementOffset(right);
13
+ const centeredTitlePaddingX = root ? `${Math.max(leftOffset?.fromLeft ?? 0, rightOffset?.fromRight ?? 0)}px` : "initial";
14
+ return useMemo(
15
+ () => ({
16
+ refs: {
17
+ root: rootRef,
18
+ left: leftRef,
19
+ right: rightRef
20
+ },
21
+ stateProps,
22
+ rootProps: elementProps({
23
+ "data-part": "appBar",
24
+ ...stateProps,
25
+ style: {
26
+ "--centered-title-padding-x": centeredTitlePaddingX
27
+ }
28
+ })
29
+ }),
30
+ [stateProps, centeredTitlePaddingX]
31
+ );
32
+ }
33
+
34
+ export { useAppBar };
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const React = require('react');
6
+
7
+ const AppBarContext = React.createContext(null);
8
+ const AppBarProvider = AppBarContext.Provider;
9
+ function useAppBarContext({
10
+ strict = true
11
+ } = {}) {
12
+ const context = React.useContext(AppBarContext);
13
+ if (!context && strict) {
14
+ throw new Error("useAppBarContext must be used within a AppBar");
15
+ }
16
+ return context;
17
+ }
18
+
19
+ exports.AppBarProvider = AppBarProvider;
20
+ exports.useAppBarContext = useAppBarContext;
@@ -1,7 +1,8 @@
1
- import type { UseAppBarReturn } from "./useAppBar";
1
+ import { UseAppBarReturn } from './useAppBar';
2
+ import { Provider } from 'react';
2
3
  export interface UseAppBarContext extends UseAppBarReturn {
3
4
  }
4
- export declare const AppBarProvider: import("react").Provider<UseAppBarContext | null>;
5
+ export declare const AppBarProvider: Provider<UseAppBarContext | null>;
5
6
  export declare function useAppBarContext<T extends boolean | undefined = true>({ strict, }?: {
6
7
  strict?: T;
7
8
  }): T extends false ? UseAppBarContext | null : UseAppBarContext;
@@ -0,0 +1,15 @@
1
+ import { createContext, useContext } from 'react';
2
+
3
+ const AppBarContext = createContext(null);
4
+ const AppBarProvider = AppBarContext.Provider;
5
+ function useAppBarContext({
6
+ strict = true
7
+ } = {}) {
8
+ const context = useContext(AppBarContext);
9
+ if (!context && strict) {
10
+ throw new Error("useAppBarContext must be used within a AppBar");
11
+ }
12
+ return context;
13
+ }
14
+
15
+ export { AppBarProvider, useAppBarContext };
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const jsxRuntime = require('react/jsx-runtime');
6
+ const domUtils = require('@seed-design/dom-utils');
7
+ const reactPrimitive = require('@seed-design/react-primitive');
8
+ const React = require('react');
9
+ const useAppScreen = require('./useAppScreen.cjs');
10
+ const useAppScreenContext = require('./useAppScreenContext.cjs');
11
+
12
+ const AppScreenRoot = React.forwardRef((props, ref) => {
13
+ const {
14
+ swipeBackDisplacementRatioThreshold,
15
+ swipeBackVelocityThreshold,
16
+ onSwipeBackEnd,
17
+ onSwipeBackMove,
18
+ onSwipeBackStart,
19
+ ...otherProps
20
+ } = props;
21
+ const api = useAppScreen.useAppScreen({
22
+ swipeBackDisplacementRatioThreshold,
23
+ swipeBackVelocityThreshold,
24
+ onSwipeBackEnd,
25
+ onSwipeBackMove,
26
+ onSwipeBackStart
27
+ });
28
+ return /* @__PURE__ */ jsxRuntime.jsx(useAppScreenContext.AppScreenProvider, { value: api, children: /* @__PURE__ */ jsxRuntime.jsx(
29
+ reactPrimitive.Primitive.div,
30
+ {
31
+ ref,
32
+ "data-stackflow-component-name": "AppScreen",
33
+ ...domUtils.mergeProps(api.activityProps, otherProps)
34
+ }
35
+ ) });
36
+ });
37
+ AppScreenRoot.displayName = "AppScreenRoot";
38
+ const AppScreenDim = React.forwardRef((props, ref) => {
39
+ const { dimProps } = useAppScreenContext.useAppScreenContext();
40
+ return /* @__PURE__ */ jsxRuntime.jsx(reactPrimitive.Primitive.div, { ref, ...domUtils.mergeProps(dimProps, props) });
41
+ });
42
+ AppScreenDim.displayName = "AppScreenDim";
43
+ const AppScreenEdge = React.forwardRef((props, ref) => {
44
+ const { edgeProps } = useAppScreenContext.useAppScreenContext();
45
+ return /* @__PURE__ */ jsxRuntime.jsx(reactPrimitive.Primitive.div, { ref, ...domUtils.mergeProps(edgeProps, props) });
46
+ });
47
+ AppScreenEdge.displayName = "AppScreenEdge";
48
+ const AppScreenLayer = React.forwardRef((props, ref) => {
49
+ const { layerProps } = useAppScreenContext.useAppScreenContext();
50
+ return /* @__PURE__ */ jsxRuntime.jsx(reactPrimitive.Primitive.div, { ref, ...domUtils.mergeProps(layerProps, props) });
51
+ });
52
+ AppScreenLayer.displayName = "AppScreenLayer";
53
+
54
+ exports.AppScreenDim = AppScreenDim;
55
+ exports.AppScreenEdge = AppScreenEdge;
56
+ exports.AppScreenLayer = AppScreenLayer;
57
+ exports.AppScreenRoot = AppScreenRoot;
@@ -1,14 +1,15 @@
1
- import { type PrimitiveProps } from "@seed-design/react-primitive";
2
- import { type UseAppScreenProps } from "./useAppScreen";
1
+ import { PrimitiveProps } from '@seed-design/react-primitive';
2
+ import { UseAppScreenProps } from './useAppScreen';
3
+ import { ForwardRefExoticComponent, RefAttributes } from 'react';
3
4
  export interface AppScreenRootProps extends PrimitiveProps, UseAppScreenProps, React.HTMLAttributes<HTMLDivElement> {
4
5
  }
5
- export declare const AppScreenRoot: import("react").ForwardRefExoticComponent<AppScreenRootProps & import("react").RefAttributes<HTMLDivElement>>;
6
+ export declare const AppScreenRoot: ForwardRefExoticComponent<AppScreenRootProps & RefAttributes<HTMLDivElement>>;
6
7
  export interface AppScreenDimProps extends PrimitiveProps, React.HTMLAttributes<HTMLDivElement> {
7
8
  }
8
- export declare const AppScreenDim: import("react").ForwardRefExoticComponent<AppScreenDimProps & import("react").RefAttributes<HTMLDivElement>>;
9
+ export declare const AppScreenDim: ForwardRefExoticComponent<AppScreenDimProps & RefAttributes<HTMLDivElement>>;
9
10
  export interface AppScreenEdgeProps extends PrimitiveProps, React.HTMLAttributes<HTMLDivElement> {
10
11
  }
11
- export declare const AppScreenEdge: import("react").ForwardRefExoticComponent<AppScreenEdgeProps & import("react").RefAttributes<HTMLDivElement>>;
12
+ export declare const AppScreenEdge: ForwardRefExoticComponent<AppScreenEdgeProps & RefAttributes<HTMLDivElement>>;
12
13
  export interface AppScreenLayerProps extends PrimitiveProps, React.HTMLAttributes<HTMLDivElement> {
13
14
  }
14
- export declare const AppScreenLayer: import("react").ForwardRefExoticComponent<AppScreenLayerProps & import("react").RefAttributes<HTMLDivElement>>;
15
+ export declare const AppScreenLayer: ForwardRefExoticComponent<AppScreenLayerProps & RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,50 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { mergeProps } from '@seed-design/dom-utils';
3
+ import { Primitive } from '@seed-design/react-primitive';
4
+ import { forwardRef } from 'react';
5
+ import { useAppScreen } from './useAppScreen.js';
6
+ import { useAppScreenContext, AppScreenProvider } from './useAppScreenContext.js';
7
+
8
+ const AppScreenRoot = forwardRef((props, ref) => {
9
+ const {
10
+ swipeBackDisplacementRatioThreshold,
11
+ swipeBackVelocityThreshold,
12
+ onSwipeBackEnd,
13
+ onSwipeBackMove,
14
+ onSwipeBackStart,
15
+ ...otherProps
16
+ } = props;
17
+ const api = useAppScreen({
18
+ swipeBackDisplacementRatioThreshold,
19
+ swipeBackVelocityThreshold,
20
+ onSwipeBackEnd,
21
+ onSwipeBackMove,
22
+ onSwipeBackStart
23
+ });
24
+ return /* @__PURE__ */ jsx(AppScreenProvider, { value: api, children: /* @__PURE__ */ jsx(
25
+ Primitive.div,
26
+ {
27
+ ref,
28
+ "data-stackflow-component-name": "AppScreen",
29
+ ...mergeProps(api.activityProps, otherProps)
30
+ }
31
+ ) });
32
+ });
33
+ AppScreenRoot.displayName = "AppScreenRoot";
34
+ const AppScreenDim = forwardRef((props, ref) => {
35
+ const { dimProps } = useAppScreenContext();
36
+ return /* @__PURE__ */ jsx(Primitive.div, { ref, ...mergeProps(dimProps, props) });
37
+ });
38
+ AppScreenDim.displayName = "AppScreenDim";
39
+ const AppScreenEdge = forwardRef((props, ref) => {
40
+ const { edgeProps } = useAppScreenContext();
41
+ return /* @__PURE__ */ jsx(Primitive.div, { ref, ...mergeProps(edgeProps, props) });
42
+ });
43
+ AppScreenEdge.displayName = "AppScreenEdge";
44
+ const AppScreenLayer = forwardRef((props, ref) => {
45
+ const { layerProps } = useAppScreenContext();
46
+ return /* @__PURE__ */ jsx(Primitive.div, { ref, ...mergeProps(layerProps, props) });
47
+ });
48
+ AppScreenLayer.displayName = "AppScreenLayer";
49
+
50
+ export { AppScreenDim, AppScreenEdge, AppScreenLayer, AppScreenRoot };
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const AppScreen = require('./AppScreen.cjs');
6
+
7
+
8
+
9
+ exports.Dim = AppScreen.AppScreenDim;
10
+ exports.Edge = AppScreen.AppScreenEdge;
11
+ exports.Layer = AppScreen.AppScreenLayer;
12
+ exports.Root = AppScreen.AppScreenRoot;
@@ -1 +1 @@
1
- export { AppScreenDim as Dim, AppScreenEdge as Edge, AppScreenLayer as Layer, AppScreenRoot as Root, type AppScreenDimProps as DimProps, type AppScreenEdgeProps as EdgeProps, type AppScreenLayerProps as LayerProps, type AppScreenRootProps as RootProps, } from "./AppScreen";
1
+ export { AppScreenDim as Dim, AppScreenEdge as Edge, AppScreenLayer as Layer, AppScreenRoot as Root, type AppScreenDimProps as DimProps, type AppScreenEdgeProps as EdgeProps, type AppScreenLayerProps as LayerProps, type AppScreenRootProps as RootProps, } from './AppScreen';
@@ -0,0 +1 @@
1
+ export { AppScreenDim as Dim, AppScreenEdge as Edge, AppScreenLayer as Layer, AppScreenRoot as Root } from './AppScreen.js';
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const AppScreen = require('./AppScreen.cjs');
6
+ const AppScreen_namespace = require('./AppScreen.namespace.cjs');
7
+ const useAppScreenContext = require('./useAppScreenContext.cjs');
8
+
9
+
10
+
11
+ exports.AppScreenDim = AppScreen.AppScreenDim;
12
+ exports.AppScreenEdge = AppScreen.AppScreenEdge;
13
+ exports.AppScreenLayer = AppScreen.AppScreenLayer;
14
+ exports.AppScreenRoot = AppScreen.AppScreenRoot;
15
+ exports.AppScreen = AppScreen_namespace;
16
+ exports.useAppScreenContext = useAppScreenContext.useAppScreenContext;
@@ -1,3 +1,3 @@
1
- export { AppScreenDim, AppScreenEdge, AppScreenLayer, AppScreenRoot, type AppScreenDimProps, type AppScreenEdgeProps, type AppScreenLayerProps, type AppScreenRootProps, } from "./AppScreen";
2
- export * as AppScreen from "./AppScreen.namespace";
3
- export { useAppScreenContext, type UseAppScreenContext } from "./useAppScreenContext";
1
+ export { AppScreenDim, AppScreenEdge, AppScreenLayer, AppScreenRoot, type AppScreenDimProps, type AppScreenEdgeProps, type AppScreenLayerProps, type AppScreenRootProps, } from './AppScreen';
2
+ export * as AppScreen from './AppScreen.namespace';
3
+ export { useAppScreenContext, type UseAppScreenContext } from './useAppScreenContext';
@@ -0,0 +1,4 @@
1
+ export { AppScreenDim, AppScreenEdge, AppScreenLayer, AppScreenRoot } from './AppScreen.js';
2
+ import * as AppScreen_namespace from './AppScreen.namespace.js';
3
+ export { AppScreen_namespace as AppScreen };
4
+ export { useAppScreenContext } from './useAppScreenContext.js';
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const domUtils = require('@seed-design/dom-utils');
6
+ const reactUiCore = require('@stackflow/react-ui-core');
7
+ const React = require('react');
8
+ const useSwipeBack = require('../GlobalInteraction/useSwipeBack.cjs');
9
+
10
+ function useAppScreen(props) {
11
+ const activity = reactUiCore.useNullableActivity();
12
+ const transitionState = activity?.transitionState ?? "enter-done";
13
+ const { activityProps, layerProps, edgeProps } = useSwipeBack.useSwipeBack(props);
14
+ const zIndexBase = reactUiCore.useZIndexBase();
15
+ const zIndexStyle = React.useMemo(
16
+ () => ({
17
+ "--z-index-base": zIndexBase.toString()
18
+ }),
19
+ [zIndexBase]
20
+ );
21
+ const stateProps = React.useMemo(
22
+ () => ({
23
+ "data-activity-is-top": domUtils.dataAttr(activity?.isTop),
24
+ "data-activity-is-active": domUtils.dataAttr(activity?.isActive),
25
+ "data-transition-state": transitionState
26
+ }),
27
+ [transitionState, activity?.isActive, activity?.isTop]
28
+ );
29
+ return React.useMemo(
30
+ () => ({
31
+ activity,
32
+ stateProps,
33
+ activityProps: domUtils.elementProps({
34
+ "data-part": "activity",
35
+ "data-activity-type": "full-screen",
36
+ ...activityProps,
37
+ ...stateProps,
38
+ "data-activity-id": activity?.id,
39
+ style: zIndexStyle,
40
+ // FIXME: @stackflow/react should prevent activity.id hydration mismatch; this is temporal fix.
41
+ suppressHydrationWarning: true
42
+ }),
43
+ dimProps: domUtils.elementProps({
44
+ "data-part": "dim",
45
+ ...stateProps
46
+ }),
47
+ layerProps: domUtils.elementProps({
48
+ "data-part": "layer",
49
+ ...stateProps,
50
+ ...layerProps
51
+ }),
52
+ edgeProps: domUtils.elementProps({
53
+ "data-part": "edge",
54
+ "aria-hidden": true,
55
+ tabIndex: -1,
56
+ ...edgeProps,
57
+ ...stateProps
58
+ })
59
+ }),
60
+ [activity, zIndexStyle, stateProps, activityProps, edgeProps, layerProps]
61
+ );
62
+ }
63
+
64
+ exports.useAppScreen = useAppScreen;