@seed-design/stackflow 0.0.0-alpha-20260414104312

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 (127) hide show
  1. package/lib/components/AppBar/AppBar.cjs +115 -0
  2. package/lib/components/AppBar/AppBar.d.ts +34 -0
  3. package/lib/components/AppBar/AppBar.js +103 -0
  4. package/lib/components/AppBar/AppBar.namespace.cjs +16 -0
  5. package/lib/components/AppBar/AppBar.namespace.d.ts +2 -0
  6. package/lib/components/AppBar/AppBar.namespace.js +1 -0
  7. package/lib/components/AppBar/index.cjs +18 -0
  8. package/lib/components/AppBar/index.d.ts +3 -0
  9. package/lib/components/AppBar/index.js +3 -0
  10. package/lib/components/AppScreen/AppScreen.cjs +68 -0
  11. package/lib/components/AppScreen/AppScreen.d.ts +23 -0
  12. package/lib/components/AppScreen/AppScreen.js +60 -0
  13. package/lib/components/AppScreen/AppScreen.namespace.cjs +13 -0
  14. package/lib/components/AppScreen/AppScreen.namespace.d.ts +2 -0
  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 -0
  18. package/lib/components/AppScreen/index.js +3 -0
  19. package/lib/components/index.cjs +26 -0
  20. package/lib/components/index.d.ts +2 -0
  21. package/lib/components/index.js +6 -0
  22. package/lib/hooks/index.cjs +9 -0
  23. package/lib/hooks/index.d.ts +1 -0
  24. package/lib/hooks/index.js +1 -0
  25. package/lib/hooks/useActivityZIndexBase.cjs +14 -0
  26. package/lib/hooks/useActivityZIndexBase.d.ts +18 -0
  27. package/lib/hooks/useActivityZIndexBase.js +10 -0
  28. package/lib/index.cjs +32 -0
  29. package/lib/index.d.ts +4 -0
  30. package/lib/index.js +10 -0
  31. package/lib/plugin.cjs +18 -0
  32. package/lib/plugin.d.ts +7 -0
  33. package/lib/plugin.js +14 -0
  34. package/lib/primitive/AppBar/AppBar.cjs +44 -0
  35. package/lib/primitive/AppBar/AppBar.d.ts +15 -0
  36. package/lib/primitive/AppBar/AppBar.js +37 -0
  37. package/lib/primitive/AppBar/AppBar.namespace.cjs +12 -0
  38. package/lib/primitive/AppBar/AppBar.namespace.d.ts +1 -0
  39. package/lib/primitive/AppBar/AppBar.namespace.js +1 -0
  40. package/lib/primitive/AppBar/index.cjs +14 -0
  41. package/lib/primitive/AppBar/index.d.ts +2 -0
  42. package/lib/primitive/AppBar/index.js +3 -0
  43. package/lib/primitive/AppBar/useAppBar.cjs +39 -0
  44. package/lib/primitive/AppBar/useAppBar.d.ts +294 -0
  45. package/lib/primitive/AppBar/useAppBar.js +35 -0
  46. package/lib/primitive/AppBar/useAppBarContext.cjs +21 -0
  47. package/lib/primitive/AppBar/useAppBarContext.d.ts +8 -0
  48. package/lib/primitive/AppBar/useAppBarContext.js +16 -0
  49. package/lib/primitive/AppScreen/AppScreen.cjs +64 -0
  50. package/lib/primitive/AppScreen/AppScreen.d.ts +15 -0
  51. package/lib/primitive/AppScreen/AppScreen.js +57 -0
  52. package/lib/primitive/AppScreen/AppScreen.namespace.cjs +12 -0
  53. package/lib/primitive/AppScreen/AppScreen.namespace.d.ts +1 -0
  54. package/lib/primitive/AppScreen/AppScreen.namespace.js +1 -0
  55. package/lib/primitive/AppScreen/index.cjs +16 -0
  56. package/lib/primitive/AppScreen/index.d.ts +3 -0
  57. package/lib/primitive/AppScreen/index.js +4 -0
  58. package/lib/primitive/AppScreen/useAppScreen.cjs +66 -0
  59. package/lib/primitive/AppScreen/useAppScreen.d.ts +1138 -0
  60. package/lib/primitive/AppScreen/useAppScreen.js +62 -0
  61. package/lib/primitive/AppScreen/useAppScreenContext.cjs +21 -0
  62. package/lib/primitive/AppScreen/useAppScreenContext.d.ts +8 -0
  63. package/lib/primitive/AppScreen/useAppScreenContext.js +16 -0
  64. package/lib/primitive/GlobalInteraction/GlobalInteraction.cjs +28 -0
  65. package/lib/primitive/GlobalInteraction/GlobalInteraction.d.ts +5 -0
  66. package/lib/primitive/GlobalInteraction/GlobalInteraction.js +24 -0
  67. package/lib/primitive/GlobalInteraction/index.cjs +11 -0
  68. package/lib/primitive/GlobalInteraction/index.d.ts +2 -0
  69. package/lib/primitive/GlobalInteraction/index.js +2 -0
  70. package/lib/primitive/GlobalInteraction/useGlobalInteraction.cjs +136 -0
  71. package/lib/primitive/GlobalInteraction/useGlobalInteraction.d.ts +54 -0
  72. package/lib/primitive/GlobalInteraction/useGlobalInteraction.js +132 -0
  73. package/lib/primitive/GlobalInteraction/useGlobalInteractionContext.cjs +21 -0
  74. package/lib/primitive/GlobalInteraction/useGlobalInteractionContext.d.ts +8 -0
  75. package/lib/primitive/GlobalInteraction/useGlobalInteractionContext.js +16 -0
  76. package/lib/primitive/GlobalInteraction/useSwipeBack.cjs +58 -0
  77. package/lib/primitive/GlobalInteraction/useSwipeBack.d.ts +8 -0
  78. package/lib/primitive/GlobalInteraction/useSwipeBack.js +54 -0
  79. package/lib/primitive/index.cjs +27 -0
  80. package/lib/primitive/index.d.ts +3 -0
  81. package/lib/primitive/index.js +9 -0
  82. package/lib/primitive/private/useElementOffset.cjs +54 -0
  83. package/lib/primitive/private/useElementOffset.d.ts +4 -0
  84. package/lib/primitive/private/useElementOffset.js +31 -0
  85. package/lib/primitive/private/useTopActivity.cjs +34 -0
  86. package/lib/primitive/private/useTopActivity.d.ts +5 -0
  87. package/lib/primitive/private/useTopActivity.js +30 -0
  88. package/lib/utils/createStyleContext.cjs +77 -0
  89. package/lib/utils/createStyleContext.d.ts +23 -0
  90. package/lib/utils/createStyleContext.js +73 -0
  91. package/lib/utils/createWithStateProps.d.ts +10 -0
  92. package/lib/utils/styled.cjs +25 -0
  93. package/lib/utils/styled.d.ts +16 -0
  94. package/lib/utils/styled.js +21 -0
  95. package/package.json +61 -0
  96. package/src/components/AppBar/AppBar.namespace.ts +21 -0
  97. package/src/components/AppBar/AppBar.tsx +146 -0
  98. package/src/components/AppBar/index.ts +23 -0
  99. package/src/components/AppScreen/AppScreen.namespace.ts +14 -0
  100. package/src/components/AppScreen/AppScreen.tsx +83 -0
  101. package/src/components/AppScreen/index.ts +16 -0
  102. package/src/components/index.ts +2 -0
  103. package/src/hooks/index.ts +1 -0
  104. package/src/hooks/useActivityZIndexBase.ts +26 -0
  105. package/src/index.ts +6 -0
  106. package/src/plugin.tsx +27 -0
  107. package/src/primitive/AppBar/AppBar.namespace.ts +10 -0
  108. package/src/primitive/AppBar/AppBar.tsx +52 -0
  109. package/src/primitive/AppBar/index.ts +12 -0
  110. package/src/primitive/AppBar/useAppBar.tsx +42 -0
  111. package/src/primitive/AppBar/useAppBarContext.ts +21 -0
  112. package/src/primitive/AppScreen/AppScreen.namespace.ts +10 -0
  113. package/src/primitive/AppScreen/AppScreen.tsx +72 -0
  114. package/src/primitive/AppScreen/index.ts +13 -0
  115. package/src/primitive/AppScreen/useAppScreen.tsx +69 -0
  116. package/src/primitive/AppScreen/useAppScreenContext.ts +21 -0
  117. package/src/primitive/GlobalInteraction/GlobalInteraction.tsx +25 -0
  118. package/src/primitive/GlobalInteraction/index.ts +6 -0
  119. package/src/primitive/GlobalInteraction/useGlobalInteraction.ts +188 -0
  120. package/src/primitive/GlobalInteraction/useGlobalInteractionContext.tsx +21 -0
  121. package/src/primitive/GlobalInteraction/useSwipeBack.ts +56 -0
  122. package/src/primitive/index.ts +3 -0
  123. package/src/primitive/private/useElementOffset.ts +37 -0
  124. package/src/primitive/private/useTopActivity.ts +33 -0
  125. package/src/utils/createStyleContext.tsx +128 -0
  126. package/src/utils/createWithStateProps.tsx +28 -0
  127. package/src/utils/styled.ts +41 -0
@@ -0,0 +1,54 @@
1
+ 'use client';
2
+ import { useEffect, useMemo } from 'react';
3
+ import { useGlobalInteractionContext } from './useGlobalInteractionContext.js';
4
+
5
+ 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
+ );
52
+ }
53
+
54
+ export { useSwipeBack };
@@ -0,0 +1,27 @@
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;
@@ -0,0 +1,3 @@
1
+ export * from './AppScreen';
2
+ export * from './AppBar';
3
+ export * from './GlobalInteraction';
@@ -0,0 +1,9 @@
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';
@@ -0,0 +1,54 @@
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;
28
+ 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;
52
+ }
53
+
54
+ exports.useElementOffset = useElementOffset;
@@ -0,0 +1,4 @@
1
+ export declare function useElementOffset(element: HTMLElement | null): {
2
+ fromLeft: number;
3
+ fromRight: number;
4
+ } | undefined;
@@ -0,0 +1,31 @@
1
+ 'use client';
2
+ import * as React from 'react';
3
+
4
+ const useLayoutEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
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;
29
+ }
30
+
31
+ export { useElementOffset };
@@ -0,0 +1,34 @@
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
+
9
+ 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
+ };
32
+ }
33
+
34
+ exports.useTopActivity = useTopActivity;
@@ -0,0 +1,5 @@
1
+ export declare function useTopActivity(): {
2
+ transitionState: "enter-active" | "enter-done" | "exit-active" | "exit-done";
3
+ activityType: string | undefined;
4
+ transitionStyle: string | undefined;
5
+ };
@@ -0,0 +1,30 @@
1
+ 'use client';
2
+ import { useStack } from '@stackflow/react';
3
+ import { useState, useLayoutEffect } from 'react';
4
+
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
+ };
28
+ }
29
+
30
+ export { useTopActivity };
@@ -0,0 +1,77 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
+
6
+ const jsxRuntime = require('react/jsx-runtime');
7
+ const clsx = require('clsx');
8
+ const React = require('react');
9
+
10
+ function createStyleContext(recipe) {
11
+ const ClassNamesContext = React.createContext(null);
12
+ const PropsContext = React.createContext(null);
13
+ const ClassNamesProvider = ({
14
+ children,
15
+ value
16
+ }) => {
17
+ return /* @__PURE__ */ jsxRuntime.jsx(ClassNamesContext.Provider, { value, children });
18
+ };
19
+ const PropsProvider = ({ children, value }) => {
20
+ return /* @__PURE__ */ jsxRuntime.jsx(PropsContext.Provider, { value, children });
21
+ };
22
+ function useClassNames() {
23
+ const context = React.useContext(ClassNamesContext);
24
+ if (context === null) {
25
+ throw new Error(
26
+ "useClassNames must be used within a ClassNamesProvider. Did you forget to wrap your component in a ClassNamesProvider?"
27
+ );
28
+ }
29
+ return context;
30
+ }
31
+ function useProps() {
32
+ return React.useContext(PropsContext);
33
+ }
34
+ const withRootProvider = (Component, options) => {
35
+ const { defaultProps } = options ?? {};
36
+ const StyledComponent = (innerProps) => {
37
+ const props = { ...defaultProps ?? {}, ...useProps(), ...innerProps };
38
+ const [variantProps, otherProps] = recipe.splitVariantProps(props);
39
+ const classNames = recipe(variantProps);
40
+ return /* @__PURE__ */ jsxRuntime.jsx(ClassNamesProvider, { value: classNames, children: /* @__PURE__ */ jsxRuntime.jsx(Component, { ...otherProps }) });
41
+ };
42
+ StyledComponent.displayName = Component.displayName || Component.name;
43
+ return StyledComponent;
44
+ };
45
+ const withProvider = (Component, slot, options) => {
46
+ const { defaultProps } = options ?? {};
47
+ const StyledComponent = React.forwardRef((innerProps, ref) => {
48
+ const props = { ...defaultProps ?? {}, ...useProps(), ...innerProps };
49
+ const [variantProps, otherProps] = recipe.splitVariantProps(props);
50
+ const classNames = recipe(variantProps);
51
+ const className = classNames[slot];
52
+ return /* @__PURE__ */ jsxRuntime.jsx(ClassNamesProvider, { value: classNames, children: /* @__PURE__ */ jsxRuntime.jsx(Component, { ref, ...otherProps, className: clsx(className, props.className) }) });
53
+ });
54
+ StyledComponent.displayName = Component.displayName || Component.name;
55
+ return StyledComponent;
56
+ };
57
+ const withContext = (Component, slot) => {
58
+ const StyledComponent = React.forwardRef((props, ref) => {
59
+ const classNames = useClassNames();
60
+ const className = classNames?.[slot];
61
+ return /* @__PURE__ */ jsxRuntime.jsx(Component, { ref, ...props, className: clsx(className, props.className) });
62
+ });
63
+ StyledComponent.displayName = Component.displayName || Component.name;
64
+ return StyledComponent;
65
+ };
66
+ return {
67
+ ClassNamesProvider,
68
+ PropsProvider,
69
+ useClassNames,
70
+ useProps,
71
+ withRootProvider,
72
+ withProvider,
73
+ withContext
74
+ };
75
+ }
76
+
77
+ exports.createStyleContext = createStyleContext;
@@ -0,0 +1,23 @@
1
+ type Recipe<Props extends Record<string, string | boolean | undefined>, Classnames extends Record<string, string>> = ((props?: Props) => Classnames) & {
2
+ splitVariantProps: <T extends Props>(props: T) => [Props, Omit<T, keyof Props>];
3
+ };
4
+ export declare function createStyleContext<Props extends Record<string, string | boolean | undefined>, Classnames extends Record<string, string>>(recipe: Recipe<Props, Classnames>): {
5
+ ClassNamesProvider: ({ children, value, }: {
6
+ children: React.ReactNode;
7
+ value: Classnames;
8
+ }) => import("react/jsx-runtime").JSX.Element;
9
+ PropsProvider: ({ children, value }: {
10
+ children: React.ReactNode;
11
+ value: Props;
12
+ }) => import("react/jsx-runtime").JSX.Element;
13
+ useClassNames: () => Classnames;
14
+ useProps: () => Props | null;
15
+ withRootProvider: <P>(Component: React.ElementType<any>, options?: {
16
+ defaultProps?: Partial<P>;
17
+ }) => React.ForwardRefExoticComponent<React.PropsWithoutRef<P>>;
18
+ withProvider: <T, P>(Component: React.ElementType<any>, slot: keyof Classnames, options?: {
19
+ defaultProps?: Partial<P>;
20
+ }) => React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<T>>;
21
+ withContext: <T, P>(Component: React.ElementType<any>, slot?: keyof Classnames) => React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<T>>;
22
+ };
23
+ export {};
@@ -0,0 +1,73 @@
1
+ 'use client';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import clsx from 'clsx';
4
+ import { createContext, forwardRef, useContext } from 'react';
5
+
6
+ function createStyleContext(recipe) {
7
+ const ClassNamesContext = createContext(null);
8
+ const PropsContext = createContext(null);
9
+ const ClassNamesProvider = ({
10
+ children,
11
+ value
12
+ }) => {
13
+ return /* @__PURE__ */ jsx(ClassNamesContext.Provider, { value, children });
14
+ };
15
+ const PropsProvider = ({ children, value }) => {
16
+ return /* @__PURE__ */ jsx(PropsContext.Provider, { value, children });
17
+ };
18
+ function useClassNames() {
19
+ const context = useContext(ClassNamesContext);
20
+ if (context === null) {
21
+ throw new Error(
22
+ "useClassNames must be used within a ClassNamesProvider. Did you forget to wrap your component in a ClassNamesProvider?"
23
+ );
24
+ }
25
+ return context;
26
+ }
27
+ function useProps() {
28
+ return useContext(PropsContext);
29
+ }
30
+ const withRootProvider = (Component, options) => {
31
+ const { defaultProps } = options ?? {};
32
+ const StyledComponent = (innerProps) => {
33
+ const props = { ...defaultProps ?? {}, ...useProps(), ...innerProps };
34
+ const [variantProps, otherProps] = recipe.splitVariantProps(props);
35
+ const classNames = recipe(variantProps);
36
+ return /* @__PURE__ */ jsx(ClassNamesProvider, { value: classNames, children: /* @__PURE__ */ jsx(Component, { ...otherProps }) });
37
+ };
38
+ StyledComponent.displayName = Component.displayName || Component.name;
39
+ return StyledComponent;
40
+ };
41
+ const withProvider = (Component, slot, options) => {
42
+ const { defaultProps } = options ?? {};
43
+ const StyledComponent = forwardRef((innerProps, ref) => {
44
+ const props = { ...defaultProps ?? {}, ...useProps(), ...innerProps };
45
+ const [variantProps, otherProps] = recipe.splitVariantProps(props);
46
+ const classNames = recipe(variantProps);
47
+ const className = classNames[slot];
48
+ return /* @__PURE__ */ jsx(ClassNamesProvider, { value: classNames, children: /* @__PURE__ */ jsx(Component, { ref, ...otherProps, className: clsx(className, props.className) }) });
49
+ });
50
+ StyledComponent.displayName = Component.displayName || Component.name;
51
+ return StyledComponent;
52
+ };
53
+ const withContext = (Component, slot) => {
54
+ const StyledComponent = forwardRef((props, ref) => {
55
+ const classNames = useClassNames();
56
+ const className = classNames?.[slot];
57
+ return /* @__PURE__ */ jsx(Component, { ref, ...props, className: clsx(className, props.className) });
58
+ });
59
+ StyledComponent.displayName = Component.displayName || Component.name;
60
+ return StyledComponent;
61
+ };
62
+ return {
63
+ ClassNamesProvider,
64
+ PropsProvider,
65
+ useClassNames,
66
+ useProps,
67
+ withRootProvider,
68
+ withProvider,
69
+ withContext
70
+ };
71
+ }
72
+
73
+ export { createStyleContext };
@@ -0,0 +1,10 @@
1
+ import { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from 'react';
2
+ type AtLeastOne<T> = [T, ...T[]];
3
+ export declare function createWithStateProps(useContexts: AtLeastOne<(prop?: {
4
+ strict?: boolean;
5
+ }) => {
6
+ stateProps: React.HTMLAttributes<HTMLElement>;
7
+ } | null>, options?: {
8
+ strict?: boolean;
9
+ }): <P, R>(Component: React.ComponentType<P & React.RefAttributes<R>>) => ForwardRefExoticComponent< PropsWithoutRef<P> & RefAttributes<R>>;
10
+ export {};
@@ -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 ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@seed-design/stackflow",
3
+ "version": "0.0.0-alpha-20260414104312",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/daangn/seed-design.git",
7
+ "directory": "packages/stackflow"
8
+ },
9
+ "sideEffects": false,
10
+ "type": "module",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./lib/index.d.ts",
14
+ "import": "./lib/index.js",
15
+ "require": "./lib/index.cjs"
16
+ },
17
+ "./package.json": "./package.json"
18
+ },
19
+ "main": "./lib/index.cjs",
20
+ "files": [
21
+ "lib",
22
+ "src"
23
+ ],
24
+ "scripts": {
25
+ "clean": "rm -rf lib",
26
+ "build": "vite build",
27
+ "lint:publish": "bun publint"
28
+ },
29
+ "dependencies": {
30
+ "@radix-ui/react-compose-refs": "^1.1.2",
31
+ "@radix-ui/react-slot": "^1.2.3",
32
+ "@radix-ui/react-use-callback-ref": "^1.1.1",
33
+ "@seed-design/dom-utils": "1.0.0",
34
+ "@seed-design/react-primitive": "0.0.0-alpha-20260414104312",
35
+ "@stackflow/react-ui-core": "^1.3.3",
36
+ "clsx": "^2.1.1"
37
+ },
38
+ "devDependencies": {
39
+ "@seed-design/css": "0.0.0-alpha-20260414104312",
40
+ "@stackflow/core": "^1.2.0",
41
+ "@stackflow/react": "^1.5.1",
42
+ "@types/react": "^19.2.2",
43
+ "@types/react-dom": "^19.2.1",
44
+ "@vitejs/plugin-react": "^5.0.0",
45
+ "globby": "^16.0.0",
46
+ "react": "^19.1.0",
47
+ "react-dom": "^19.1.0",
48
+ "vite": "^7.0.0",
49
+ "vite-plugin-dts": "^4.5.3"
50
+ },
51
+ "peerDependencies": {
52
+ "@seed-design/css": "0.0.0-alpha-20260414104312",
53
+ "@stackflow/core": ">=1.1.0",
54
+ "@stackflow/react": ">=1.4.1",
55
+ "react": ">=18.0.0",
56
+ "react-dom": ">=18.0.0"
57
+ },
58
+ "publishConfig": {
59
+ "access": "public"
60
+ }
61
+ }
@@ -0,0 +1,21 @@
1
+ export {
2
+ AppBarIconButton as IconButton,
3
+ AppBarLeft as Left,
4
+ AppBarMain as Main,
5
+ AppBarRight as Right,
6
+ AppBarRoot as Root,
7
+ AppBarSlot as Slot,
8
+ AppBarSubtitle as Subtitle,
9
+ AppBarTitle as Title,
10
+ } from "./AppBar";
11
+
12
+ export type {
13
+ AppBarIconButtonProps as IconButtonProps,
14
+ AppBarLeftProps as LeftProps,
15
+ AppBarMainProps as MainProps,
16
+ AppBarRightProps as RightProps,
17
+ AppBarProps as RootProps,
18
+ AppBarSlotProps as SlotProps,
19
+ AppBarSubtitleProps as SubtitleProps,
20
+ AppBarTitleProps as TitleProps,
21
+ } from "./AppBar";