@seed-design/stackflow 0.1.2 → 0.2.0
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/primitive/GlobalInteraction/useGlobalInteraction.cjs +6 -0
- package/lib/primitive/GlobalInteraction/useGlobalInteraction.js +6 -0
- package/package.json +4 -4
- package/src/primitive/AppBar/useAppBarContext.ts +3 -1
- package/src/primitive/AppScreen/useAppScreenContext.ts +3 -1
- package/src/primitive/GlobalInteraction/useGlobalInteraction.ts +7 -2
- package/src/primitive/GlobalInteraction/useGlobalInteractionContext.tsx +3 -3
- package/src/utils/createStyleContext.tsx +4 -1
|
@@ -70,6 +70,11 @@ function useGlobalInteraction() {
|
|
|
70
70
|
const endSwipeBack = React.useCallback(
|
|
71
71
|
(_) => {
|
|
72
72
|
const swiped = swipeBackContextRef.current.displacementRatio > displacementRatioThreshold || swipeBackContextRef.current.velocity > velocityThreshold;
|
|
73
|
+
if (swiped) {
|
|
74
|
+
stackRef.current?.style.setProperty("--swipe-back-target", "100%");
|
|
75
|
+
} else {
|
|
76
|
+
stackRef.current?.style.setProperty("--swipe-back-target", "0");
|
|
77
|
+
}
|
|
73
78
|
setSwipeBackState("transitioning");
|
|
74
79
|
onSwipeEnd?.({ swiped });
|
|
75
80
|
},
|
|
@@ -83,6 +88,7 @@ function useGlobalInteraction() {
|
|
|
83
88
|
displacementRatio: 0,
|
|
84
89
|
velocity: 0
|
|
85
90
|
});
|
|
91
|
+
stackRef.current?.style.setProperty("--swipe-back-target", "0");
|
|
86
92
|
setSwipeBackState("idle");
|
|
87
93
|
}, []);
|
|
88
94
|
return React.useMemo(
|
|
@@ -66,6 +66,11 @@ function useGlobalInteraction() {
|
|
|
66
66
|
const endSwipeBack = useCallback(
|
|
67
67
|
(_) => {
|
|
68
68
|
const swiped = swipeBackContextRef.current.displacementRatio > displacementRatioThreshold || swipeBackContextRef.current.velocity > velocityThreshold;
|
|
69
|
+
if (swiped) {
|
|
70
|
+
stackRef.current?.style.setProperty("--swipe-back-target", "100%");
|
|
71
|
+
} else {
|
|
72
|
+
stackRef.current?.style.setProperty("--swipe-back-target", "0");
|
|
73
|
+
}
|
|
69
74
|
setSwipeBackState("transitioning");
|
|
70
75
|
onSwipeEnd?.({ swiped });
|
|
71
76
|
},
|
|
@@ -79,6 +84,7 @@ function useGlobalInteraction() {
|
|
|
79
84
|
displacementRatio: 0,
|
|
80
85
|
velocity: 0
|
|
81
86
|
});
|
|
87
|
+
stackRef.current?.style.setProperty("--swipe-back-target", "0");
|
|
82
88
|
setSwipeBackState("idle");
|
|
83
89
|
}, []);
|
|
84
90
|
return useMemo(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seed-design/stackflow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/daangn/seed-design.git",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"clsx": "^2.1.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@seed-design/css": "0.
|
|
38
|
+
"@seed-design/css": "0.2.0",
|
|
39
39
|
"@stackflow/core": "^1.2.0",
|
|
40
40
|
"@stackflow/react": "^1.5.1",
|
|
41
41
|
"@stackflow/react-ui-core": "^1.3.2",
|
|
42
|
-
"@vitejs/plugin-react": "^
|
|
42
|
+
"@vitejs/plugin-react": "^5.0.0",
|
|
43
43
|
"globby": "^14.1.0",
|
|
44
44
|
"react": "^19.1.0",
|
|
45
45
|
"react-dom": "^19.1.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"vite-plugin-dts": "^4.5.3"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@seed-design/css": ">=0.
|
|
50
|
+
"@seed-design/css": ">=0.2.0",
|
|
51
51
|
"@stackflow/core": ">=1.1.0",
|
|
52
52
|
"@stackflow/react": ">=1.4.1",
|
|
53
53
|
"@stackflow/react-ui-core": ">=1.3.2",
|
|
@@ -9,7 +9,9 @@ export const AppBarProvider = AppBarContext.Provider;
|
|
|
9
9
|
|
|
10
10
|
export function useAppBarContext<T extends boolean | undefined = true>({
|
|
11
11
|
strict = true,
|
|
12
|
-
}: {
|
|
12
|
+
}: {
|
|
13
|
+
strict?: T;
|
|
14
|
+
} = {}): T extends false ? UseAppBarContext | null : UseAppBarContext {
|
|
13
15
|
const context = useContext(AppBarContext);
|
|
14
16
|
if (!context && strict) {
|
|
15
17
|
throw new Error("useAppBarContext must be used within a AppBar");
|
|
@@ -9,7 +9,9 @@ export const AppScreenProvider = AppScreenContext.Provider;
|
|
|
9
9
|
|
|
10
10
|
export function useAppScreenContext<T extends boolean | undefined = true>({
|
|
11
11
|
strict = true,
|
|
12
|
-
}: {
|
|
12
|
+
}: {
|
|
13
|
+
strict?: T;
|
|
14
|
+
} = {}): T extends false ? UseAppScreenContext | null : UseAppScreenContext {
|
|
13
15
|
const context = useContext(AppScreenContext);
|
|
14
16
|
if (!context && strict) {
|
|
15
17
|
throw new Error("useAppScreenContext must be used within a AppScreen");
|
|
@@ -119,9 +119,13 @@ export function useGlobalInteraction() {
|
|
|
119
119
|
swipeBackContextRef.current.displacementRatio > displacementRatioThreshold ||
|
|
120
120
|
swipeBackContextRef.current.velocity > velocityThreshold;
|
|
121
121
|
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
if (swiped) {
|
|
123
|
+
stackRef.current?.style.setProperty("--swipe-back-target", "100%");
|
|
124
|
+
} else {
|
|
125
|
+
stackRef.current?.style.setProperty("--swipe-back-target", "0");
|
|
126
|
+
}
|
|
124
127
|
|
|
128
|
+
setSwipeBackState("transitioning");
|
|
125
129
|
onSwipeEnd?.({ swiped });
|
|
126
130
|
},
|
|
127
131
|
[onSwipeEnd, displacementRatioThreshold, velocityThreshold],
|
|
@@ -135,6 +139,7 @@ export function useGlobalInteraction() {
|
|
|
135
139
|
displacementRatio: 0,
|
|
136
140
|
velocity: 0,
|
|
137
141
|
});
|
|
142
|
+
stackRef.current?.style.setProperty("--swipe-back-target", "0");
|
|
138
143
|
setSwipeBackState("idle");
|
|
139
144
|
}, []);
|
|
140
145
|
|
|
@@ -9,9 +9,9 @@ export const GlobalInteractionProvider = GlobalInteractionContext.Provider;
|
|
|
9
9
|
|
|
10
10
|
export function useGlobalInteractionContext<T extends boolean | undefined = true>({
|
|
11
11
|
strict = true,
|
|
12
|
-
}: {
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
}: {
|
|
13
|
+
strict?: T;
|
|
14
|
+
} = {}): T extends false ? UseGlobalInteractionContext | null : UseGlobalInteractionContext {
|
|
15
15
|
const context = useContext(GlobalInteractionContext);
|
|
16
16
|
if (!context && strict) {
|
|
17
17
|
throw new Error("useGlobalInteractionContext must be used within a GlobalInteractionProvider");
|
|
@@ -18,7 +18,10 @@ export function createStyleContext<
|
|
|
18
18
|
const ClassNamesProvider = ({
|
|
19
19
|
children,
|
|
20
20
|
value,
|
|
21
|
-
}: {
|
|
21
|
+
}: {
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
value: Classnames;
|
|
24
|
+
}) => {
|
|
22
25
|
return <ClassNamesContext.Provider value={value}>{children}</ClassNamesContext.Provider>;
|
|
23
26
|
};
|
|
24
27
|
|