@seed-design/stackflow 1.1.16 → 1.1.18

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.
@@ -16,6 +16,7 @@ const useAppBarContext = require('../../primitive/AppBar/useAppBarContext.cjs');
16
16
  const createStyleContext = require('../../utils/createStyleContext.cjs');
17
17
  const useTopActivity = require('../../primitive/private/useTopActivity.cjs');
18
18
  const react = require('@stackflow/react');
19
+ const styled = require('../../utils/styled.cjs');
19
20
 
20
21
  const { PropsProvider, ClassNamesProvider, useProps, withContext, useClassNames } = createStyleContext.createStyleContext(appBar.appBar);
21
22
  const {
@@ -25,8 +26,12 @@ const {
25
26
  } = createStyleContext.createStyleContext(appBarMain.appBarMain);
26
27
  const AppBarPropsProvider = PropsProvider;
27
28
  const AppBarRoot = React.forwardRef((props, ref) => {
29
+ const { style: boxStyle, restProps: propsWithoutBoxProps } = styled.useBoxBackgroundProps(props);
28
30
  const contextProps = useProps();
29
- const [variantProps, otherProps] = appBar.appBar.splitVariantProps({ ...contextProps, ...props });
31
+ const [variantProps, otherProps] = appBar.appBar.splitVariantProps({
32
+ ...contextProps,
33
+ ...propsWithoutBoxProps
34
+ });
30
35
  const topActivityTransitionStyle = useTopActivity.useTopActivity().transitionStyle;
31
36
  const resolvedVariantProps = {
32
37
  // this includes the default transitionStyle decided by theme, from contextProps or props
@@ -40,7 +45,7 @@ const AppBarRoot = React.forwardRef((props, ref) => {
40
45
  AppBar.AppBarRoot,
41
46
  {
42
47
  ref,
43
- ...domUtils.mergeProps({ className: classNames.root }, otherProps)
48
+ ...domUtils.mergeProps({ className: classNames.root, style: boxStyle }, otherProps)
44
49
  }
45
50
  ) }) });
46
51
  });
@@ -2,12 +2,13 @@ import { AppBarVariantProps, AppBarVariant } from '@seed-design/css/recipes/app-
2
2
  import { AppBarMainVariantProps } from '@seed-design/css/recipes/app-bar-main';
3
3
  import { PrimitiveProps } from '@seed-design/react-primitive';
4
4
  import { AppBar as AppBarPrimitive } from '../../primitive';
5
+ import { BoxBackgroundProps } from '../../utils/styled';
5
6
  import { ForwardRefExoticComponent, RefAttributes } from 'react';
6
7
  export declare const AppBarPropsProvider: ({ children, value }: {
7
8
  children: React.ReactNode;
8
9
  value: Partial< AppBarVariant>;
9
10
  }) => import("react/jsx-runtime").JSX.Element;
10
- export interface AppBarProps extends AppBarVariantProps, AppBarPrimitive.RootProps {
11
+ export interface AppBarProps extends AppBarVariantProps, AppBarPrimitive.RootProps, BoxBackgroundProps {
11
12
  }
12
13
  export declare const AppBarRoot: ForwardRefExoticComponent<AppBarProps & RefAttributes<HTMLDivElement>>;
13
14
  export interface AppBarLeftProps extends AppBarPrimitive.LeftProps {
@@ -12,6 +12,7 @@ import { useAppBarContext } from '../../primitive/AppBar/useAppBarContext.js';
12
12
  import { createStyleContext } from '../../utils/createStyleContext.js';
13
13
  import { useTopActivity } from '../../primitive/private/useTopActivity.js';
14
14
  import { useActivity } from '@stackflow/react';
15
+ import { useBoxBackgroundProps } from '../../utils/styled.js';
15
16
 
16
17
  const { PropsProvider, ClassNamesProvider, useProps, withContext, useClassNames } = createStyleContext(appBar);
17
18
  const {
@@ -21,8 +22,12 @@ const {
21
22
  } = createStyleContext(appBarMain);
22
23
  const AppBarPropsProvider = PropsProvider;
23
24
  const AppBarRoot = forwardRef((props, ref) => {
25
+ const { style: boxStyle, restProps: propsWithoutBoxProps } = useBoxBackgroundProps(props);
24
26
  const contextProps = useProps();
25
- const [variantProps, otherProps] = appBar.splitVariantProps({ ...contextProps, ...props });
27
+ const [variantProps, otherProps] = appBar.splitVariantProps({
28
+ ...contextProps,
29
+ ...propsWithoutBoxProps
30
+ });
26
31
  const topActivityTransitionStyle = useTopActivity().transitionStyle;
27
32
  const resolvedVariantProps = {
28
33
  // this includes the default transitionStyle decided by theme, from contextProps or props
@@ -36,7 +41,7 @@ const AppBarRoot = forwardRef((props, ref) => {
36
41
  AppBarRoot$1,
37
42
  {
38
43
  ref,
39
- ...mergeProps({ className: classNames.root }, otherProps)
44
+ ...mergeProps({ className: classNames.root, style: boxStyle }, otherProps)
40
45
  }
41
46
  ) }) });
42
47
  });
@@ -12,6 +12,7 @@ const createStyleContext = require('../../utils/createStyleContext.cjs');
12
12
  const AppBar = require('../AppBar/AppBar.cjs');
13
13
  const useTopActivity = require('../../primitive/private/useTopActivity.cjs');
14
14
  const react = require('@stackflow/react');
15
+ const appBar = require('@seed-design/css/recipes/app-bar');
15
16
 
16
17
  const { ClassNamesProvider, PropsProvider, withContext, useProps } = createStyleContext.createStyleContext(appScreen.appScreen);
17
18
  const AppScreenPropsProvider = PropsProvider;
@@ -24,12 +25,16 @@ const AppScreenRoot = React.forwardRef((props, ref) => {
24
25
  ...variantProps,
25
26
  transitionStyle: react.useActivity().isTop ? transitionStyle : topActivityTransitionStyle
26
27
  });
28
+ const [appBarVariantProps] = React.useMemo(
29
+ () => appBar.appBar.splitVariantProps(variantProps),
30
+ [variantProps]
31
+ );
27
32
  return /* @__PURE__ */ jsxRuntime.jsx(ClassNamesProvider, { value: classNames, children: /* @__PURE__ */ jsxRuntime.jsx(
28
33
  AppBar.AppBarPropsProvider,
29
34
  {
30
35
  value: React.useMemo(
31
- () => ({ ...variantProps, transitionStyle }),
32
- [variantProps, transitionStyle]
36
+ () => ({ ...appBarVariantProps, transitionStyle }),
37
+ [appBarVariantProps, transitionStyle]
33
38
  ),
34
39
  children: /* @__PURE__ */ jsxRuntime.jsx(
35
40
  AppScreen.AppScreenRoot,
@@ -8,6 +8,7 @@ import { createStyleContext } from '../../utils/createStyleContext.js';
8
8
  import { AppBarPropsProvider } from '../AppBar/AppBar.js';
9
9
  import { useTopActivity } from '../../primitive/private/useTopActivity.js';
10
10
  import { useActivity } from '@stackflow/react';
11
+ import { appBar } from '@seed-design/css/recipes/app-bar';
11
12
 
12
13
  const { ClassNamesProvider, PropsProvider, withContext, useProps } = createStyleContext(appScreen);
13
14
  const AppScreenPropsProvider = PropsProvider;
@@ -20,12 +21,16 @@ const AppScreenRoot = forwardRef((props, ref) => {
20
21
  ...variantProps,
21
22
  transitionStyle: useActivity().isTop ? transitionStyle : topActivityTransitionStyle
22
23
  });
24
+ const [appBarVariantProps] = useMemo(
25
+ () => appBar.splitVariantProps(variantProps),
26
+ [variantProps]
27
+ );
23
28
  return /* @__PURE__ */ jsx(ClassNamesProvider, { value: classNames, children: /* @__PURE__ */ jsx(
24
29
  AppBarPropsProvider,
25
30
  {
26
31
  value: useMemo(
27
- () => ({ ...variantProps, transitionStyle }),
28
- [variantProps, transitionStyle]
32
+ () => ({ ...appBarVariantProps, transitionStyle }),
33
+ [appBarVariantProps, transitionStyle]
29
34
  ),
30
35
  children: /* @__PURE__ */ jsx(
31
36
  AppScreenRoot$1,
@@ -0,0 +1,25 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
+
6
+ const vars = require('@seed-design/css/vars');
7
+
8
+ function handleColor(color) {
9
+ if (!color) {
10
+ return void 0;
11
+ }
12
+ const [type, value] = color.split(".");
13
+ return vars.vars.$color[type]?.[value] ?? color;
14
+ }
15
+ function useBoxBackgroundProps(props) {
16
+ const { bg, background, ...restProps } = props;
17
+ return {
18
+ style: {
19
+ "--seed-box-background": handleColor(background ?? bg)
20
+ },
21
+ restProps
22
+ };
23
+ }
24
+
25
+ exports.useBoxBackgroundProps = useBoxBackgroundProps;
@@ -0,0 +1,16 @@
1
+ import { ScopedColorBg, ScopedColorPalette, ScopedColorBanner } from '@seed-design/css/vars';
2
+ /**
3
+ * A minimal subset of `StyleProps` from `@seed-design/react`.
4
+ * Copied here to avoid package dependency. May be extracted to a shared package later.
5
+ */
6
+ export interface BoxBackgroundProps {
7
+ /**
8
+ * Shorthand for `background`.
9
+ */
10
+ bg?: ScopedColorBg | ScopedColorPalette | ScopedColorBanner | (string & {});
11
+ background?: ScopedColorBg | ScopedColorPalette | ScopedColorBanner | (string & {});
12
+ }
13
+ export declare function useBoxBackgroundProps<T extends BoxBackgroundProps>(props: T): {
14
+ style: React.CSSProperties;
15
+ restProps: Omit<T, keyof BoxBackgroundProps>;
16
+ };
@@ -0,0 +1,21 @@
1
+ 'use client';
2
+ import { vars } from '@seed-design/css/vars';
3
+
4
+ function handleColor(color) {
5
+ if (!color) {
6
+ return void 0;
7
+ }
8
+ const [type, value] = color.split(".");
9
+ return vars.$color[type]?.[value] ?? color;
10
+ }
11
+ function useBoxBackgroundProps(props) {
12
+ const { bg, background, ...restProps } = props;
13
+ return {
14
+ style: {
15
+ "--seed-box-background": handleColor(background ?? bg)
16
+ },
17
+ restProps
18
+ };
19
+ }
20
+
21
+ export { useBoxBackgroundProps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-design/stackflow",
3
- "version": "1.1.16",
3
+ "version": "1.1.18",
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.16",
39
+ "@seed-design/css": "1.2.5",
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.16",
52
+ "@seed-design/css": ">=1.1.19",
53
53
  "@stackflow/core": ">=1.1.0",
54
54
  "@stackflow/react": ">=1.4.1",
55
55
  "react": ">=18.0.0",
@@ -10,6 +10,7 @@ import { useAppBarContext } from "../../primitive/AppBar/useAppBarContext";
10
10
  import { createStyleContext } from "../../utils/createStyleContext";
11
11
  import { useTopActivity } from "../../primitive/private/useTopActivity";
12
12
  import { useActivity } from "@stackflow/react";
13
+ import { useBoxBackgroundProps, type BoxBackgroundProps } from "../../utils/styled";
13
14
 
14
15
  const { PropsProvider, ClassNamesProvider, useProps, withContext, useClassNames } =
15
16
  createStyleContext(appBar);
@@ -21,11 +22,19 @@ const {
21
22
 
22
23
  export const AppBarPropsProvider = PropsProvider;
23
24
 
24
- export interface AppBarProps extends AppBarVariantProps, AppBarPrimitive.RootProps {}
25
+ export interface AppBarProps
26
+ extends AppBarVariantProps,
27
+ AppBarPrimitive.RootProps,
28
+ BoxBackgroundProps {}
25
29
 
26
30
  export const AppBarRoot = forwardRef<HTMLDivElement, AppBarProps>((props, ref) => {
31
+ const { style: boxStyle, restProps: propsWithoutBoxProps } = useBoxBackgroundProps(props);
32
+
27
33
  const contextProps = useProps();
28
- const [variantProps, otherProps] = appBar.splitVariantProps({ ...contextProps, ...props });
34
+ const [variantProps, otherProps] = appBar.splitVariantProps({
35
+ ...contextProps,
36
+ ...propsWithoutBoxProps,
37
+ });
29
38
 
30
39
  const topActivityTransitionStyle = useTopActivity().transitionStyle;
31
40
 
@@ -46,7 +55,7 @@ export const AppBarRoot = forwardRef<HTMLDivElement, AppBarProps>((props, ref) =
46
55
  <MainPropsProvider value={resolvedVariantProps}>
47
56
  <AppBarPrimitive.Root
48
57
  ref={ref}
49
- {...mergeProps({ className: classNames.root }, otherProps)}
58
+ {...mergeProps({ className: classNames.root, style: boxStyle }, otherProps)}
50
59
  />
51
60
  </MainPropsProvider>
52
61
  </ClassNamesProvider>
@@ -6,6 +6,7 @@ import { createStyleContext } from "../../utils/createStyleContext";
6
6
  import { AppBarPropsProvider } from "../AppBar/AppBar";
7
7
  import { useTopActivity } from "../../primitive/private/useTopActivity";
8
8
  import { useActivity } from "@stackflow/react";
9
+ import { appBar } from "@seed-design/css/recipes/app-bar";
9
10
 
10
11
  const { ClassNamesProvider, PropsProvider, withContext, useProps } = createStyleContext(appScreen);
11
12
 
@@ -36,12 +37,17 @@ export const AppScreenRoot = forwardRef<HTMLDivElement, AppScreenRootProps>((pro
36
37
  : (topActivityTransitionStyle as NonNullable<AppScreenVariantProps["transitionStyle"]>),
37
38
  });
38
39
 
40
+ const [appBarVariantProps] = useMemo(
41
+ () => appBar.splitVariantProps(variantProps),
42
+ [variantProps],
43
+ );
44
+
39
45
  return (
40
46
  <ClassNamesProvider value={classNames}>
41
47
  <AppBarPropsProvider
42
48
  value={useMemo(
43
- () => ({ ...variantProps, transitionStyle }),
44
- [variantProps, transitionStyle],
49
+ () => ({ ...appBarVariantProps, transitionStyle }),
50
+ [appBarVariantProps, transitionStyle],
45
51
  )}
46
52
  >
47
53
  <AppScreenPrimitive.Root
@@ -0,0 +1,41 @@
1
+ import type { ScopedColorBg, ScopedColorPalette, ScopedColorBanner } from "@seed-design/css/vars";
2
+ import { vars } from "@seed-design/css/vars";
3
+
4
+ /**
5
+ * A minimal subset of `StyleProps` from `@seed-design/react`.
6
+ * Copied here to avoid package dependency. May be extracted to a shared package later.
7
+ */
8
+ export interface BoxBackgroundProps {
9
+ /**
10
+ * Shorthand for `background`.
11
+ */
12
+ bg?: ScopedColorBg | ScopedColorPalette | ScopedColorBanner | (string & {});
13
+
14
+ background?: ScopedColorBg | ScopedColorPalette | ScopedColorBanner | (string & {});
15
+ }
16
+
17
+ function handleColor(color: string | undefined) {
18
+ if (!color) {
19
+ return undefined;
20
+ }
21
+ const [type, value] = color.split(".");
22
+
23
+ // @ts-expect-error - dynamic access
24
+ return vars.$color[type]?.[value] ?? color;
25
+ }
26
+
27
+ export function useBoxBackgroundProps<T extends BoxBackgroundProps>(
28
+ props: T,
29
+ ): {
30
+ style: React.CSSProperties;
31
+ restProps: Omit<T, keyof BoxBackgroundProps>;
32
+ } {
33
+ const { bg, background, ...restProps } = props;
34
+
35
+ return {
36
+ style: {
37
+ "--seed-box-background": handleColor(background ?? bg),
38
+ } as React.CSSProperties,
39
+ restProps: restProps as Omit<T, keyof BoxBackgroundProps>,
40
+ };
41
+ }