@seed-design/stackflow 1.1.11 → 1.1.16

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.
@@ -14,6 +14,8 @@ const React = require('react');
14
14
  const AppBar = require('../../primitive/AppBar/AppBar.cjs');
15
15
  const useAppBarContext = require('../../primitive/AppBar/useAppBarContext.cjs');
16
16
  const createStyleContext = require('../../utils/createStyleContext.cjs');
17
+ const useTopActivity = require('../../primitive/private/useTopActivity.cjs');
18
+ const react = require('@stackflow/react');
17
19
 
18
20
  const { PropsProvider, ClassNamesProvider, useProps, withContext, useClassNames } = createStyleContext.createStyleContext(appBar.appBar);
19
21
  const {
@@ -25,24 +27,22 @@ const AppBarPropsProvider = PropsProvider;
25
27
  const AppBarRoot = React.forwardRef((props, ref) => {
26
28
  const contextProps = useProps();
27
29
  const [variantProps, otherProps] = appBar.appBar.splitVariantProps({ ...contextProps, ...props });
28
- const classNames = appBar.appBar(variantProps);
29
- return /* @__PURE__ */ jsxRuntime.jsx(ClassNamesProvider, { value: classNames, children: /* @__PURE__ */ jsxRuntime.jsx(
30
- MainPropsProvider,
30
+ const topActivityTransitionStyle = useTopActivity.useTopActivity().transitionStyle;
31
+ const resolvedVariantProps = {
32
+ // this includes the default transitionStyle decided by theme, from contextProps or props
33
+ ...variantProps,
34
+ ...react.useActivity().isTop === false && {
35
+ transitionStyle: topActivityTransitionStyle
36
+ }
37
+ };
38
+ const classNames = appBar.appBar(resolvedVariantProps);
39
+ return /* @__PURE__ */ jsxRuntime.jsx(ClassNamesProvider, { value: classNames, children: /* @__PURE__ */ jsxRuntime.jsx(MainPropsProvider, { value: resolvedVariantProps, children: /* @__PURE__ */ jsxRuntime.jsx(
40
+ AppBar.AppBarRoot,
31
41
  {
32
- value: {
33
- theme: variantProps.theme,
34
- transitionStyle: variantProps.transitionStyle,
35
- tone: variantProps.tone
36
- },
37
- children: /* @__PURE__ */ jsxRuntime.jsx(
38
- AppBar.AppBarRoot,
39
- {
40
- ref,
41
- ...domUtils.mergeProps({ className: classNames.root }, otherProps)
42
- }
43
- )
42
+ ref,
43
+ ...domUtils.mergeProps({ className: classNames.root }, otherProps)
44
44
  }
45
- ) });
45
+ ) }) });
46
46
  });
47
47
  AppBarRoot.displayName = "AppBarRoot";
48
48
  const AppBarLeft = withContext(
@@ -10,6 +10,8 @@ import { forwardRef } from 'react';
10
10
  import { AppBarLeft as AppBarLeft$1, AppBarMain as AppBarMain$1, AppBarRight as AppBarRight$1, AppBarRoot as AppBarRoot$1 } from '../../primitive/AppBar/AppBar.js';
11
11
  import { useAppBarContext } from '../../primitive/AppBar/useAppBarContext.js';
12
12
  import { createStyleContext } from '../../utils/createStyleContext.js';
13
+ import { useTopActivity } from '../../primitive/private/useTopActivity.js';
14
+ import { useActivity } from '@stackflow/react';
13
15
 
14
16
  const { PropsProvider, ClassNamesProvider, useProps, withContext, useClassNames } = createStyleContext(appBar);
15
17
  const {
@@ -21,24 +23,22 @@ const AppBarPropsProvider = PropsProvider;
21
23
  const AppBarRoot = forwardRef((props, ref) => {
22
24
  const contextProps = useProps();
23
25
  const [variantProps, otherProps] = appBar.splitVariantProps({ ...contextProps, ...props });
24
- const classNames = appBar(variantProps);
25
- return /* @__PURE__ */ jsx(ClassNamesProvider, { value: classNames, children: /* @__PURE__ */ jsx(
26
- MainPropsProvider,
26
+ const topActivityTransitionStyle = useTopActivity().transitionStyle;
27
+ const resolvedVariantProps = {
28
+ // this includes the default transitionStyle decided by theme, from contextProps or props
29
+ ...variantProps,
30
+ ...useActivity().isTop === false && {
31
+ transitionStyle: topActivityTransitionStyle
32
+ }
33
+ };
34
+ const classNames = appBar(resolvedVariantProps);
35
+ return /* @__PURE__ */ jsx(ClassNamesProvider, { value: classNames, children: /* @__PURE__ */ jsx(MainPropsProvider, { value: resolvedVariantProps, children: /* @__PURE__ */ jsx(
36
+ AppBarRoot$1,
27
37
  {
28
- value: {
29
- theme: variantProps.theme,
30
- transitionStyle: variantProps.transitionStyle,
31
- tone: variantProps.tone
32
- },
33
- children: /* @__PURE__ */ jsx(
34
- AppBarRoot$1,
35
- {
36
- ref,
37
- ...mergeProps({ className: classNames.root }, otherProps)
38
- }
39
- )
38
+ ref,
39
+ ...mergeProps({ className: classNames.root }, otherProps)
40
40
  }
41
- ) });
41
+ ) }) });
42
42
  });
43
43
  AppBarRoot.displayName = "AppBarRoot";
44
44
  const AppBarLeft = withContext(
@@ -10,6 +10,8 @@ const React = require('react');
10
10
  const AppScreen = require('../../primitive/AppScreen/AppScreen.cjs');
11
11
  const createStyleContext = require('../../utils/createStyleContext.cjs');
12
12
  const AppBar = require('../AppBar/AppBar.cjs');
13
+ const useTopActivity = require('../../primitive/private/useTopActivity.cjs');
14
+ const react = require('@stackflow/react');
13
15
 
14
16
  const { ClassNamesProvider, PropsProvider, withContext, useProps } = createStyleContext.createStyleContext(appScreen.appScreen);
15
17
  const AppScreenPropsProvider = PropsProvider;
@@ -17,21 +19,23 @@ const AppScreenRoot = React.forwardRef((props, ref) => {
17
19
  const contextProps = useProps();
18
20
  const [variantProps, otherProps] = appScreen.appScreen.splitVariantProps({ ...contextProps, ...props });
19
21
  const transitionStyle = variantProps.transitionStyle ?? (variantProps.theme === "cupertino" ? "slideFromRightIOS" : "fadeFromBottomAndroid");
22
+ const topActivityTransitionStyle = useTopActivity.useTopActivity().transitionStyle;
20
23
  const classNames = appScreen.appScreen({
21
24
  ...variantProps,
22
- transitionStyle
25
+ transitionStyle: react.useActivity().isTop ? transitionStyle : topActivityTransitionStyle
23
26
  });
24
27
  return /* @__PURE__ */ jsxRuntime.jsx(ClassNamesProvider, { value: classNames, children: /* @__PURE__ */ jsxRuntime.jsx(
25
28
  AppBar.AppBarPropsProvider,
26
29
  {
27
30
  value: React.useMemo(
28
- () => ({ theme: variantProps.theme, transitionStyle, tone: variantProps.tone }),
29
- [variantProps.theme, transitionStyle, variantProps.tone]
31
+ () => ({ ...variantProps, transitionStyle }),
32
+ [variantProps, transitionStyle]
30
33
  ),
31
34
  children: /* @__PURE__ */ jsxRuntime.jsx(
32
35
  AppScreen.AppScreenRoot,
33
36
  {
34
37
  ref,
38
+ "data-transition-style": transitionStyle,
35
39
  ...domUtils.mergeProps({ className: classNames.root }, otherProps)
36
40
  }
37
41
  )
@@ -6,6 +6,8 @@ import { forwardRef, useMemo } from 'react';
6
6
  import { AppScreenDim as AppScreenDim$1, AppScreenEdge as AppScreenEdge$1, AppScreenLayer as AppScreenLayer$1, AppScreenRoot as AppScreenRoot$1 } from '../../primitive/AppScreen/AppScreen.js';
7
7
  import { createStyleContext } from '../../utils/createStyleContext.js';
8
8
  import { AppBarPropsProvider } from '../AppBar/AppBar.js';
9
+ import { useTopActivity } from '../../primitive/private/useTopActivity.js';
10
+ import { useActivity } from '@stackflow/react';
9
11
 
10
12
  const { ClassNamesProvider, PropsProvider, withContext, useProps } = createStyleContext(appScreen);
11
13
  const AppScreenPropsProvider = PropsProvider;
@@ -13,21 +15,23 @@ const AppScreenRoot = forwardRef((props, ref) => {
13
15
  const contextProps = useProps();
14
16
  const [variantProps, otherProps] = appScreen.splitVariantProps({ ...contextProps, ...props });
15
17
  const transitionStyle = variantProps.transitionStyle ?? (variantProps.theme === "cupertino" ? "slideFromRightIOS" : "fadeFromBottomAndroid");
18
+ const topActivityTransitionStyle = useTopActivity().transitionStyle;
16
19
  const classNames = appScreen({
17
20
  ...variantProps,
18
- transitionStyle
21
+ transitionStyle: useActivity().isTop ? transitionStyle : topActivityTransitionStyle
19
22
  });
20
23
  return /* @__PURE__ */ jsx(ClassNamesProvider, { value: classNames, children: /* @__PURE__ */ jsx(
21
24
  AppBarPropsProvider,
22
25
  {
23
26
  value: useMemo(
24
- () => ({ theme: variantProps.theme, transitionStyle, tone: variantProps.tone }),
25
- [variantProps.theme, transitionStyle, variantProps.tone]
27
+ () => ({ ...variantProps, transitionStyle }),
28
+ [variantProps, transitionStyle]
26
29
  ),
27
30
  children: /* @__PURE__ */ jsx(
28
31
  AppScreenRoot$1,
29
32
  {
30
33
  ref,
34
+ "data-transition-style": transitionStyle,
31
35
  ...mergeProps({ className: classNames.root }, otherProps)
32
36
  }
33
37
  )
@@ -109,9 +109,15 @@ function useGlobalInteraction() {
109
109
  () => ({
110
110
  "data-swipe-back-state": swipeBackState,
111
111
  "data-global-transition-state": topActivity.transitionState,
112
- "data-top-activity-type": topActivity.activityType
112
+ "data-top-activity-type": topActivity.activityType,
113
+ "data-top-transition-style": topActivity.transitionStyle
113
114
  }),
114
- [swipeBackState, topActivity.transitionState, topActivity.activityType]
115
+ [
116
+ swipeBackState,
117
+ topActivity.transitionState,
118
+ topActivity.activityType,
119
+ topActivity.transitionStyle
120
+ ]
115
121
  );
116
122
  return React.useMemo(
117
123
  () => ({
@@ -105,9 +105,15 @@ function useGlobalInteraction() {
105
105
  () => ({
106
106
  "data-swipe-back-state": swipeBackState,
107
107
  "data-global-transition-state": topActivity.transitionState,
108
- "data-top-activity-type": topActivity.activityType
108
+ "data-top-activity-type": topActivity.activityType,
109
+ "data-top-transition-style": topActivity.transitionStyle
109
110
  }),
110
- [swipeBackState, topActivity.transitionState, topActivity.activityType]
111
+ [
112
+ swipeBackState,
113
+ topActivity.transitionState,
114
+ topActivity.activityType,
115
+ topActivity.transitionStyle
116
+ ]
111
117
  );
112
118
  return useMemo(
113
119
  () => ({
@@ -24,6 +24,11 @@ function useSwipeBack(props) {
24
24
  if (e.target === e.currentTarget) {
25
25
  events.reset();
26
26
  }
27
+ },
28
+ onTransitionEnd: (e) => {
29
+ if (e.target === e.currentTarget) {
30
+ events.reset();
31
+ }
27
32
  }
28
33
  },
29
34
  edgeProps: {
@@ -20,6 +20,11 @@ function useSwipeBack(props) {
20
20
  if (e.target === e.currentTarget) {
21
21
  events.reset();
22
22
  }
23
+ },
24
+ onTransitionEnd: (e) => {
25
+ if (e.target === e.currentTarget) {
26
+ events.reset();
27
+ }
23
28
  }
24
29
  },
25
30
  edgeProps: {
@@ -18,6 +18,7 @@ function useTopActivity() {
18
18
  const transitionState = topActivity?.transitionState ?? "enter-done";
19
19
  const [topEl, setTopEl] = React.useState(null);
20
20
  const activityType = topEl?.dataset["activityType"];
21
+ const transitionStyle = topEl?.dataset["transitionStyle"];
21
22
  React.useLayoutEffect(() => {
22
23
  if (!topId) return;
23
24
  const el = document.querySelector(`[data-activity-id="${topId}"]`);
@@ -25,7 +26,8 @@ function useTopActivity() {
25
26
  }, [topId]);
26
27
  return {
27
28
  transitionState,
28
- activityType
29
+ activityType,
30
+ transitionStyle
29
31
  };
30
32
  }
31
33
 
@@ -1,4 +1,5 @@
1
1
  export declare function useTopActivity(): {
2
2
  transitionState: "enter-active" | "enter-done" | "exit-active" | "exit-done";
3
3
  activityType: string | undefined;
4
+ transitionStyle: string | undefined;
4
5
  };
@@ -14,6 +14,7 @@ function useTopActivity() {
14
14
  const transitionState = topActivity?.transitionState ?? "enter-done";
15
15
  const [topEl, setTopEl] = useState(null);
16
16
  const activityType = topEl?.dataset["activityType"];
17
+ const transitionStyle = topEl?.dataset["transitionStyle"];
17
18
  useLayoutEffect(() => {
18
19
  if (!topId) return;
19
20
  const el = document.querySelector(`[data-activity-id="${topId}"]`);
@@ -21,7 +22,8 @@ function useTopActivity() {
21
22
  }, [topId]);
22
23
  return {
23
24
  transitionState,
24
- activityType
25
+ activityType,
26
+ transitionStyle
25
27
  };
26
28
  }
27
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-design/stackflow",
3
- "version": "1.1.11",
3
+ "version": "1.1.16",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/daangn/seed-design.git",
@@ -36,7 +36,7 @@
36
36
  "clsx": "^2.1.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@seed-design/css": "1.1.10",
39
+ "@seed-design/css": "1.1.16",
40
40
  "@stackflow/core": "^1.2.0",
41
41
  "@stackflow/react": "^1.5.1",
42
42
  "@types/react": "^19.2.2",
@@ -49,7 +49,7 @@
49
49
  "vite-plugin-dts": "^4.5.3"
50
50
  },
51
51
  "peerDependencies": {
52
- "@seed-design/css": ">=1.1.10",
52
+ "@seed-design/css": ">=1.1.16",
53
53
  "@stackflow/core": ">=1.1.0",
54
54
  "@stackflow/react": ">=1.4.1",
55
55
  "react": ">=18.0.0",
@@ -8,6 +8,8 @@ import { forwardRef } from "react";
8
8
  import { AppBar as AppBarPrimitive } from "../../primitive";
9
9
  import { useAppBarContext } from "../../primitive/AppBar/useAppBarContext";
10
10
  import { createStyleContext } from "../../utils/createStyleContext";
11
+ import { useTopActivity } from "../../primitive/private/useTopActivity";
12
+ import { useActivity } from "@stackflow/react";
11
13
 
12
14
  const { PropsProvider, ClassNamesProvider, useProps, withContext, useClassNames } =
13
15
  createStyleContext(appBar);
@@ -24,17 +26,24 @@ export interface AppBarProps extends AppBarVariantProps, AppBarPrimitive.RootPro
24
26
  export const AppBarRoot = forwardRef<HTMLDivElement, AppBarProps>((props, ref) => {
25
27
  const contextProps = useProps();
26
28
  const [variantProps, otherProps] = appBar.splitVariantProps({ ...contextProps, ...props });
27
- const classNames = appBar(variantProps);
29
+
30
+ const topActivityTransitionStyle = useTopActivity().transitionStyle;
31
+
32
+ const resolvedVariantProps: AppBarVariantProps = {
33
+ // this includes the default transitionStyle decided by theme, from contextProps or props
34
+ ...variantProps,
35
+ ...(useActivity().isTop === false && {
36
+ transitionStyle: topActivityTransitionStyle as NonNullable<
37
+ AppBarVariantProps["transitionStyle"]
38
+ >,
39
+ }),
40
+ };
41
+
42
+ const classNames = appBar(resolvedVariantProps);
28
43
 
29
44
  return (
30
45
  <ClassNamesProvider value={classNames}>
31
- <MainPropsProvider
32
- value={{
33
- theme: variantProps.theme,
34
- transitionStyle: variantProps.transitionStyle,
35
- tone: variantProps.tone,
36
- }}
37
- >
46
+ <MainPropsProvider value={resolvedVariantProps}>
38
47
  <AppBarPrimitive.Root
39
48
  ref={ref}
40
49
  {...mergeProps({ className: classNames.root }, otherProps)}
@@ -4,6 +4,8 @@ import { forwardRef, useMemo } from "react";
4
4
  import { AppScreen as AppScreenPrimitive } from "../../primitive";
5
5
  import { createStyleContext } from "../../utils/createStyleContext";
6
6
  import { AppBarPropsProvider } from "../AppBar/AppBar";
7
+ import { useTopActivity } from "../../primitive/private/useTopActivity";
8
+ import { useActivity } from "@stackflow/react";
7
9
 
8
10
  const { ClassNamesProvider, PropsProvider, withContext, useProps } = createStyleContext(appScreen);
9
11
 
@@ -21,25 +23,30 @@ export const AppScreenRoot = forwardRef<HTMLDivElement, AppScreenRootProps>((pro
21
23
  const [variantProps, otherProps] = appScreen.splitVariantProps({ ...contextProps, ...props });
22
24
 
23
25
  // TODO: we have to implement conditional default in recipe; this is temporal workaround.
24
- const transitionStyle =
26
+ const transitionStyle: NonNullable<AppScreenVariantProps["transitionStyle"]> =
25
27
  variantProps.transitionStyle ??
26
28
  (variantProps.theme === "cupertino" ? "slideFromRightIOS" : "fadeFromBottomAndroid");
27
29
 
30
+ const topActivityTransitionStyle = useTopActivity().transitionStyle;
31
+
28
32
  const classNames = appScreen({
29
33
  ...variantProps,
30
- transitionStyle,
34
+ transitionStyle: useActivity().isTop
35
+ ? transitionStyle
36
+ : (topActivityTransitionStyle as NonNullable<AppScreenVariantProps["transitionStyle"]>),
31
37
  });
32
38
 
33
39
  return (
34
40
  <ClassNamesProvider value={classNames}>
35
41
  <AppBarPropsProvider
36
42
  value={useMemo(
37
- () => ({ theme: variantProps.theme, transitionStyle, tone: variantProps.tone }),
38
- [variantProps.theme, transitionStyle, variantProps.tone],
43
+ () => ({ ...variantProps, transitionStyle }),
44
+ [variantProps, transitionStyle],
39
45
  )}
40
46
  >
41
47
  <AppScreenPrimitive.Root
42
48
  ref={ref}
49
+ data-transition-style={transitionStyle}
43
50
  {...mergeProps({ className: classNames.root }, otherProps)}
44
51
  />
45
52
  </AppBarPropsProvider>
@@ -162,8 +162,14 @@ export function useGlobalInteraction() {
162
162
  "data-swipe-back-state": swipeBackState,
163
163
  "data-global-transition-state": topActivity.transitionState,
164
164
  "data-top-activity-type": topActivity.activityType,
165
+ "data-top-transition-style": topActivity.transitionStyle,
165
166
  }),
166
- [swipeBackState, topActivity.transitionState, topActivity.activityType],
167
+ [
168
+ swipeBackState,
169
+ topActivity.transitionState,
170
+ topActivity.activityType,
171
+ topActivity.transitionStyle,
172
+ ],
167
173
  ) as React.HTMLAttributes<HTMLElement>;
168
174
 
169
175
  return useMemo(
@@ -25,6 +25,11 @@ export function useSwipeBack(props: UseSwipeBackProps) {
25
25
  events.reset();
26
26
  }
27
27
  },
28
+ onTransitionEnd: (e) => {
29
+ if (e.target === e.currentTarget) {
30
+ events.reset();
31
+ }
32
+ },
28
33
  } as React.HTMLAttributes<HTMLDivElement>,
29
34
  edgeProps: {
30
35
  tabIndex: -1,
@@ -16,6 +16,7 @@ export function useTopActivity() {
16
16
  // TODO: There should be a better way to handle this. We should not rely on the DOM element to get the activity type.
17
17
  const [topEl, setTopEl] = useState<HTMLElement | null>(null);
18
18
  const activityType = topEl?.dataset["activityType"];
19
+ const transitionStyle = topEl?.dataset["transitionStyle"];
19
20
 
20
21
  useLayoutEffect(() => {
21
22
  if (!topId) return;
@@ -27,5 +28,6 @@ export function useTopActivity() {
27
28
  return {
28
29
  transitionState,
29
30
  activityType,
31
+ transitionStyle,
30
32
  };
31
33
  }