@seed-design/stackflow 1.1.16 → 1.1.17
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/components/AppBar/AppBar.cjs +7 -2
- package/lib/components/AppBar/AppBar.d.ts +2 -1
- package/lib/components/AppBar/AppBar.js +7 -2
- package/lib/utils/styled.cjs +25 -0
- package/lib/utils/styled.d.ts +16 -0
- package/lib/utils/styled.js +21 -0
- package/package.json +3 -3
- package/src/components/AppBar/AppBar.tsx +12 -3
- package/src/utils/styled.ts +41 -0
|
@@ -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({
|
|
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({
|
|
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
|
});
|
|
@@ -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.
|
|
3
|
+
"version": "1.1.17",
|
|
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.
|
|
39
|
+
"@seed-design/css": "1.2.3",
|
|
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.
|
|
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
|
|
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({
|
|
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>
|
|
@@ -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
|
+
}
|