@seed-design/stackflow 1.1.23 → 1.1.24

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.
@@ -82,6 +82,34 @@ function clearAllStyles(t) {
82
82
  for (const el of all) clearStyles(el);
83
83
  }
84
84
  /**
85
+ * Remove all leftover inline styles from the top activity once the
86
+ * transition has settled (globalTransitionState === "idle").
87
+ *
88
+ * The top + behind pair model only handles the single immediately adjacent
89
+ * behind layer. When transitions overlap (concurrent pop, swipe-back race,
90
+ * etc.) the landing screen can get stuck with the temporary styles of a
91
+ * "behind" or an "exiting top" — the layer stays at -30% and shifts by 1/3,
92
+ * or the appBar root stays at opacity 0 (setPostExitPositions) and the whole
93
+ * app bar disappears.
94
+ *
95
+ * At idle the top must always be in a clean default state (setIdlePositions
96
+ * only clears the top and styles the behind), so wipe any leftover inline
97
+ * back to the CSS defaults (layer 0%, appBar visible). The behind is left
98
+ * untouched, and it's a no-op if already clean.
99
+ */
100
+ function clearTopActivityStyles(stackEl) {
101
+ const t = findTransitionTargets(stackEl);
102
+ const topParts = [
103
+ t.topLayer,
104
+ t.topDim,
105
+ t.topTitle,
106
+ t.topAppBarRoot,
107
+ t.topAppBarBackground,
108
+ ...t.topIcons
109
+ ];
110
+ for (const el of topParts) clearStyles(el);
111
+ }
112
+ /**
85
113
  * Set idle positions after push completes.
86
114
  * Pattern: clear everything first, then set only non-default positions.
87
115
  */
@@ -139,6 +167,7 @@ function applySwipeStyles(t, displacement, ratio) {
139
167
  //#endregion
140
168
  exports.applySwipeStyles = applySwipeStyles;
141
169
  exports.clearAllStyles = clearAllStyles;
170
+ exports.clearTopActivityStyles = clearTopActivityStyles;
142
171
  exports.findTransitionTargets = findTransitionTargets;
143
172
  exports.readTransitionStyle = readTransitionStyle;
144
173
  exports.setIdlePositions = setIdlePositions;
@@ -30,6 +30,23 @@ export declare function setOpacity(el: HTMLElement | null, value: string): void;
30
30
  * This is the foundation — call before setting any specific positions.
31
31
  */
32
32
  export declare function clearAllStyles(t: TransitionTargets): void;
33
+ /**
34
+ * Remove all leftover inline styles from the top activity once the
35
+ * transition has settled (globalTransitionState === "idle").
36
+ *
37
+ * The top + behind pair model only handles the single immediately adjacent
38
+ * behind layer. When transitions overlap (concurrent pop, swipe-back race,
39
+ * etc.) the landing screen can get stuck with the temporary styles of a
40
+ * "behind" or an "exiting top" — the layer stays at -30% and shifts by 1/3,
41
+ * or the appBar root stays at opacity 0 (setPostExitPositions) and the whole
42
+ * app bar disappears.
43
+ *
44
+ * At idle the top must always be in a clean default state (setIdlePositions
45
+ * only clears the top and styles the behind), so wipe any leftover inline
46
+ * back to the CSS defaults (layer 0%, appBar visible). The behind is left
47
+ * untouched, and it's a no-op if already clean.
48
+ */
49
+ export declare function clearTopActivityStyles(stackEl: HTMLElement): void;
33
50
  /**
34
51
  * Set idle positions after push completes.
35
52
  * Pattern: clear everything first, then set only non-default positions.
@@ -82,6 +82,34 @@ function clearAllStyles(t) {
82
82
  for (const el of all) clearStyles(el);
83
83
  }
84
84
  /**
85
+ * Remove all leftover inline styles from the top activity once the
86
+ * transition has settled (globalTransitionState === "idle").
87
+ *
88
+ * The top + behind pair model only handles the single immediately adjacent
89
+ * behind layer. When transitions overlap (concurrent pop, swipe-back race,
90
+ * etc.) the landing screen can get stuck with the temporary styles of a
91
+ * "behind" or an "exiting top" — the layer stays at -30% and shifts by 1/3,
92
+ * or the appBar root stays at opacity 0 (setPostExitPositions) and the whole
93
+ * app bar disappears.
94
+ *
95
+ * At idle the top must always be in a clean default state (setIdlePositions
96
+ * only clears the top and styles the behind), so wipe any leftover inline
97
+ * back to the CSS defaults (layer 0%, appBar visible). The behind is left
98
+ * untouched, and it's a no-op if already clean.
99
+ */
100
+ function clearTopActivityStyles(stackEl) {
101
+ const t = findTransitionTargets(stackEl);
102
+ const topParts = [
103
+ t.topLayer,
104
+ t.topDim,
105
+ t.topTitle,
106
+ t.topAppBarRoot,
107
+ t.topAppBarBackground,
108
+ ...t.topIcons
109
+ ];
110
+ for (const el of topParts) clearStyles(el);
111
+ }
112
+ /**
85
113
  * Set idle positions after push completes.
86
114
  * Pattern: clear everything first, then set only non-default positions.
87
115
  */
@@ -137,4 +165,4 @@ function applySwipeStyles(t, displacement, ratio) {
137
165
  for (const icon of t.behindIcons) setOpacity(icon, `${ratio}`);
138
166
  }
139
167
  //#endregion
140
- export { applySwipeStyles, clearAllStyles, findTransitionTargets, readTransitionStyle, setIdlePositions, setOpacity, setPostExitPositions, setTransform };
168
+ export { applySwipeStyles, clearAllStyles, clearTopActivityStyles, findTransitionTargets, readTransitionStyle, setIdlePositions, setOpacity, setPostExitPositions, setTransform };
@@ -4,6 +4,7 @@ const require_useTopActivity = require("../private/useTopActivity.cjs");
4
4
  const require_dom = require("./dom.cjs");
5
5
  const require_animation = require("./animation.cjs");
6
6
  let react = require("react");
7
+ let _stackflow_react = require("@stackflow/react");
7
8
  //#region src/primitive/GlobalInteraction/useGlobalInteraction.ts
8
9
  var IDLE_CONTEXT = Object.freeze({
9
10
  x0: 0,
@@ -135,6 +136,7 @@ function useGlobalInteraction() {
135
136
  setSwipeBackState
136
137
  ]);
137
138
  const topActivity = require_useTopActivity.useTopActivity();
139
+ const stack = (0, _stackflow_react.useStack)();
138
140
  const prevTransitionStateRef = (0, react.useRef)(topActivity.transitionState);
139
141
  (0, react.useLayoutEffect)(() => {
140
142
  const prev = prevTransitionStateRef.current;
@@ -183,6 +185,11 @@ function useGlobalInteraction() {
183
185
  stopRunningAnims,
184
186
  cancelPendingPushRAF
185
187
  ]);
188
+ (0, react.useLayoutEffect)(() => {
189
+ if (stack?.globalTransitionState !== "idle") return;
190
+ const stackEl = stackRef.current;
191
+ if (stackEl) require_dom.clearTopActivityStyles(stackEl);
192
+ }, [stack?.globalTransitionState]);
186
193
  (0, react.useEffect)(() => {
187
194
  return () => {
188
195
  cancelPendingPushRAF();
@@ -1,8 +1,9 @@
1
1
  "use client";
2
2
  import { useTopActivity } from "../private/useTopActivity.js";
3
- import { applySwipeStyles, clearAllStyles, findTransitionTargets, readTransitionStyle, setIdlePositions, setPostExitPositions } from "./dom.js";
3
+ import { applySwipeStyles, clearAllStyles, clearTopActivityStyles, findTransitionTargets, readTransitionStyle, setIdlePositions, setPostExitPositions } from "./dom.js";
4
4
  import { animateSwipeCancel, animateSwipeComplete, animateTransition, cancelAll, scrubAppBarBackground } from "./animation.js";
5
5
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from "react";
6
+ import { useStack } from "@stackflow/react";
6
7
  //#region src/primitive/GlobalInteraction/useGlobalInteraction.ts
7
8
  var IDLE_CONTEXT = Object.freeze({
8
9
  x0: 0,
@@ -134,6 +135,7 @@ function useGlobalInteraction() {
134
135
  setSwipeBackState
135
136
  ]);
136
137
  const topActivity = useTopActivity();
138
+ const stack = useStack();
137
139
  const prevTransitionStateRef = useRef(topActivity.transitionState);
138
140
  useLayoutEffect(() => {
139
141
  const prev = prevTransitionStateRef.current;
@@ -182,6 +184,11 @@ function useGlobalInteraction() {
182
184
  stopRunningAnims,
183
185
  cancelPendingPushRAF
184
186
  ]);
187
+ useLayoutEffect(() => {
188
+ if (stack?.globalTransitionState !== "idle") return;
189
+ const stackEl = stackRef.current;
190
+ if (stackEl) clearTopActivityStyles(stackEl);
191
+ }, [stack?.globalTransitionState]);
185
192
  useEffect(() => {
186
193
  return () => {
187
194
  cancelPendingPushRAF();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-design/stackflow",
3
- "version": "1.1.23",
3
+ "version": "1.1.24",
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.2.13",
39
+ "@seed-design/css": "1.2.16",
40
40
  "@stackflow/core": "^1.2.0",
41
41
  "@stackflow/react": "^1.5.1",
42
42
  "@types/react": "^19.2.2",
@@ -138,10 +138,13 @@ function collectAnimations(anims: (Animation | null)[], durationMs: number): Ani
138
138
 
139
139
  // ─── iOS Slide ──────────────────────────────────────────────────────────────
140
140
 
141
- interface TitleKeyframe {
141
+ // Intersect with the DOM `Keyframe` so values of this type satisfy the
142
+ // `[property: string]` index signature `el.animate()` expects, while still
143
+ // guaranteeing `opacity` and `transform` are present.
144
+ type TitleKeyframe = Keyframe & {
142
145
  opacity: string;
143
146
  transform: string;
144
- }
147
+ };
145
148
 
146
149
  interface IosPositions {
147
150
  topLayer: string;
@@ -127,6 +127,35 @@ export function clearAllStyles(t: TransitionTargets) {
127
127
  for (const el of all) clearStyles(el);
128
128
  }
129
129
 
130
+ /**
131
+ * Remove all leftover inline styles from the top activity once the
132
+ * transition has settled (globalTransitionState === "idle").
133
+ *
134
+ * The top + behind pair model only handles the single immediately adjacent
135
+ * behind layer. When transitions overlap (concurrent pop, swipe-back race,
136
+ * etc.) the landing screen can get stuck with the temporary styles of a
137
+ * "behind" or an "exiting top" — the layer stays at -30% and shifts by 1/3,
138
+ * or the appBar root stays at opacity 0 (setPostExitPositions) and the whole
139
+ * app bar disappears.
140
+ *
141
+ * At idle the top must always be in a clean default state (setIdlePositions
142
+ * only clears the top and styles the behind), so wipe any leftover inline
143
+ * back to the CSS defaults (layer 0%, appBar visible). The behind is left
144
+ * untouched, and it's a no-op if already clean.
145
+ */
146
+ export function clearTopActivityStyles(stackEl: HTMLElement) {
147
+ const t = findTransitionTargets(stackEl);
148
+ const topParts = [
149
+ t.topLayer,
150
+ t.topDim,
151
+ t.topTitle,
152
+ t.topAppBarRoot,
153
+ t.topAppBarBackground,
154
+ ...t.topIcons,
155
+ ];
156
+ for (const el of topParts) clearStyles(el);
157
+ }
158
+
130
159
  /**
131
160
  * Set idle positions after push completes.
132
161
  * Pattern: clear everything first, then set only non-default positions.
@@ -1,3 +1,4 @@
1
+ import { useStack } from "@stackflow/react";
1
2
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from "react";
2
3
  import { useTopActivity } from "../private/useTopActivity";
3
4
  import {
@@ -7,6 +8,7 @@ import {
7
8
  readTransitionStyle,
8
9
  applySwipeStyles,
9
10
  clearAllStyles,
11
+ clearTopActivityStyles,
10
12
  setIdlePositions,
11
13
  setPostExitPositions,
12
14
  } from "./dom";
@@ -257,6 +259,7 @@ export function useGlobalInteraction() {
257
259
  }, [stopRunningAnims, stopAppBarBgScrub, setSwipeBackState]);
258
260
 
259
261
  const topActivity = useTopActivity();
262
+ const stack = useStack();
260
263
 
261
264
  // ── WAAPI push/pop transitions triggered by stackflow state changes ──
262
265
  const prevTransitionStateRef = useRef<string>(topActivity.transitionState);
@@ -326,6 +329,26 @@ export function useGlobalInteraction() {
326
329
  }
327
330
  }, [topActivity.transitionState, stopRunningAnims, cancelPendingPushRAF]);
328
331
 
332
+ // ── Settle safety-net ──
333
+ // The top + behind pair model only handles the single immediately adjacent
334
+ // behind layer. When transitions overlap (concurrent pop, swipe-back race,
335
+ // etc.) and end on a path the pair model didn't unwind, the landing screen
336
+ // can get stuck with temporary styles — the layer stays at -30% and shifts
337
+ // by 1/3, or the appBar root stays at opacity 0 (setPostExitPositions) and
338
+ // the whole app bar disappears.
339
+ //
340
+ // Guarantee: once everything settles (globalTransitionState === "idle") the
341
+ // top must always be in a clean default state. Wipe all leftover inline
342
+ // styles from the top activity — the behind is left untouched (stays at
343
+ // -30%), this only runs at idle, and it's a no-op if already clean.
344
+ useLayoutEffect(() => {
345
+ if (stack?.globalTransitionState !== "idle") return;
346
+ const stackEl = stackRef.current;
347
+ if (stackEl) {
348
+ clearTopActivityStyles(stackEl);
349
+ }
350
+ }, [stack?.globalTransitionState]);
351
+
329
352
  // Cancel any pending push rAF and running animations on unmount so
330
353
  // late-firing finished handlers can't run against a torn-down stack.
331
354
  useEffect(() => {