react-panel-layout 0.6.1 → 0.7.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.
Files changed (115) hide show
  1. package/dist/FloatingWindow-Bw2djgpz.js +1542 -0
  2. package/dist/FloatingWindow-Bw2djgpz.js.map +1 -0
  3. package/dist/FloatingWindow-Cvyokf0m.cjs +2 -0
  4. package/dist/FloatingWindow-Cvyokf0m.cjs.map +1 -0
  5. package/dist/GridLayout-B4aCqSyd.js +947 -0
  6. package/dist/{GridLayout-UWNxXw77.js.map → GridLayout-B4aCqSyd.js.map} +1 -1
  7. package/dist/GridLayout-DNOClFzz.cjs +2 -0
  8. package/dist/{GridLayout-DKTg_N61.cjs.map → GridLayout-DNOClFzz.cjs.map} +1 -1
  9. package/dist/PanelSystem-B8Igvnb2.cjs +3 -0
  10. package/dist/PanelSystem-B8Igvnb2.cjs.map +1 -0
  11. package/dist/{PanelSystem-BqUzNtf2.js → PanelSystem-DDUSFjXD.js} +208 -247
  12. package/dist/PanelSystem-DDUSFjXD.js.map +1 -0
  13. package/dist/components/window/Drawer.d.ts +1 -0
  14. package/dist/components/window/DrawerRevealContext.d.ts +61 -0
  15. package/dist/components/window/drawerRevealAnimationUtils.d.ts +212 -0
  16. package/dist/components/window/drawerStyles.d.ts +5 -0
  17. package/dist/components/window/useDrawerSwipeTransform.d.ts +8 -2
  18. package/dist/components/window/useDrawerTransform.d.ts +68 -0
  19. package/dist/components/window/useRevealDrawerTransform.d.ts +56 -0
  20. package/dist/config.cjs +1 -1
  21. package/dist/config.cjs.map +1 -1
  22. package/dist/config.js +8 -7
  23. package/dist/config.js.map +1 -1
  24. package/dist/grid.cjs +1 -1
  25. package/dist/grid.js +2 -2
  26. package/dist/index.cjs +1 -1
  27. package/dist/index.js +4 -4
  28. package/dist/modules/drawer/drawerStateMachine.d.ts +168 -0
  29. package/dist/modules/drawer/revealDrawerConstants.d.ts +33 -0
  30. package/dist/modules/drawer/revealDrawerStateMachine.d.ts +146 -0
  31. package/dist/modules/drawer/strategies/index.d.ts +8 -0
  32. package/dist/modules/drawer/strategies/overlayStrategy.d.ts +12 -0
  33. package/dist/modules/drawer/strategies/revealStrategy.d.ts +12 -0
  34. package/dist/modules/drawer/strategies/types.d.ts +116 -0
  35. package/dist/panels.cjs +1 -1
  36. package/dist/panels.js +1 -1
  37. package/dist/stack.cjs +1 -1
  38. package/dist/stack.cjs.map +1 -1
  39. package/dist/stack.js +306 -347
  40. package/dist/stack.js.map +1 -1
  41. package/dist/types.d.ts +14 -0
  42. package/dist/useAnimationFrame-BZ6D2lMq.cjs +2 -0
  43. package/dist/useAnimationFrame-BZ6D2lMq.cjs.map +1 -0
  44. package/dist/useAnimationFrame-Bg4e-H8O.js +394 -0
  45. package/dist/useAnimationFrame-Bg4e-H8O.js.map +1 -0
  46. package/dist/window.cjs +1 -1
  47. package/dist/window.js +1 -1
  48. package/package.json +1 -1
  49. package/src/components/gesture/SwipeSafeZone.tsx +1 -0
  50. package/src/components/grid/GridLayout.tsx +110 -38
  51. package/src/components/window/Drawer.tsx +114 -10
  52. package/src/components/window/DrawerLayers.tsx +48 -15
  53. package/src/components/window/DrawerRevealContext.spec.ts +20 -0
  54. package/src/components/window/DrawerRevealContext.tsx +99 -0
  55. package/src/components/window/drawerRevealAnimationUtils.spec.ts +375 -0
  56. package/src/components/window/drawerRevealAnimationUtils.ts +415 -0
  57. package/src/components/window/drawerStyles.spec.ts +39 -0
  58. package/src/components/window/drawerStyles.ts +24 -0
  59. package/src/components/window/useDrawerSwipeTransform.ts +28 -90
  60. package/src/components/window/useDrawerTransform.ts +505 -0
  61. package/src/components/window/useRevealDrawerTransform.spec.ts +1936 -0
  62. package/src/components/window/useRevealDrawerTransform.ts +105 -0
  63. package/src/demo/components/FullscreenDemoPage.tsx +47 -0
  64. package/src/demo/fullscreenRoutes.tsx +32 -0
  65. package/src/demo/index.tsx +5 -0
  66. package/src/demo/pages/Dialog/components/CardExpandDemo.tsx +23 -8
  67. package/src/demo/pages/Drawer/components/DrawerBasics.module.css +6 -1
  68. package/src/demo/pages/Drawer/components/DrawerBasics.tsx +14 -4
  69. package/src/demo/pages/Drawer/components/DrawerReveal.module.css +157 -0
  70. package/src/demo/pages/Drawer/components/DrawerReveal.tsx +128 -0
  71. package/src/demo/pages/Drawer/reveal/index.tsx +17 -0
  72. package/src/demo/pages/Drawer/reveal-fullscreen/index.tsx +135 -0
  73. package/src/demo/pages/Drawer/reveal-fullscreen/styles.module.css +233 -0
  74. package/src/demo/pages/Stack/components/StackBasics.spec.tsx +56 -52
  75. package/src/demo/pages/Stack/components/StackTablet.spec.tsx +39 -49
  76. package/src/demo/routes.tsx +2 -0
  77. package/src/hooks/gesture/testing/createGestureSimulator.ts +1 -0
  78. package/src/hooks/gesture/useNativeGestureGuard.spec.ts +10 -2
  79. package/src/hooks/gesture/utils.ts +15 -4
  80. package/src/hooks/useAnimatedVisibility.spec.ts +3 -3
  81. package/src/hooks/useOperationContinuity.spec.ts +17 -10
  82. package/src/hooks/useOperationContinuity.ts +5 -5
  83. package/src/hooks/useSharedElementTransition.ts +28 -7
  84. package/src/modules/dialog/dialogAnimationUtils.spec.ts +0 -1
  85. package/src/modules/dialog/useDialogContainer.spec.ts +11 -3
  86. package/src/modules/dialog/useDialogSwipeInput.spec.ts +49 -28
  87. package/src/modules/dialog/useDialogSwipeInput.ts +37 -6
  88. package/src/modules/dialog/useDialogTransform.spec.ts +63 -30
  89. package/src/modules/drawer/drawerStateMachine.ts +500 -0
  90. package/src/modules/drawer/revealDrawerConstants.ts +38 -0
  91. package/src/modules/drawer/revealDrawerStateMachine.spec.ts +558 -0
  92. package/src/modules/drawer/revealDrawerStateMachine.ts +197 -0
  93. package/src/modules/drawer/strategies/index.ts +9 -0
  94. package/src/modules/drawer/strategies/overlayStrategy.ts +133 -0
  95. package/src/modules/drawer/strategies/revealStrategy.ts +111 -0
  96. package/src/modules/drawer/strategies/types.ts +160 -0
  97. package/src/modules/drawer/useDrawerSwipeInput.ts +7 -4
  98. package/src/modules/pivot/SwipePivotContent.spec.tsx +48 -37
  99. package/src/modules/pivot/usePivotSwipeInput.spec.ts +8 -8
  100. package/src/modules/stack/swipeTransitionContinuity.spec.tsx +1 -1
  101. package/src/types.ts +15 -0
  102. package/dist/FloatingWindow-CUXnEtrb.js +0 -827
  103. package/dist/FloatingWindow-CUXnEtrb.js.map +0 -1
  104. package/dist/FloatingWindow-DMwyK0eK.cjs +0 -2
  105. package/dist/FloatingWindow-DMwyK0eK.cjs.map +0 -1
  106. package/dist/GridLayout-DKTg_N61.cjs +0 -2
  107. package/dist/GridLayout-UWNxXw77.js +0 -926
  108. package/dist/PanelSystem-BqUzNtf2.js.map +0 -1
  109. package/dist/PanelSystem-D603LKKv.cjs +0 -3
  110. package/dist/PanelSystem-D603LKKv.cjs.map +0 -1
  111. package/dist/useNativeGestureGuard-C7TSqEkr.cjs +0 -2
  112. package/dist/useNativeGestureGuard-C7TSqEkr.cjs.map +0 -1
  113. package/dist/useNativeGestureGuard-CGYo6O0r.js +0 -347
  114. package/dist/useNativeGestureGuard-CGYo6O0r.js.map +0 -1
  115. package/src/components/window/useDrawerSwipeTransform.spec.ts +0 -234
@@ -11,47 +11,58 @@ import type { SwipeInputState } from "../../hooks/gesture/types.js";
11
11
  * Used to polyfill Web Animations API for JSDOM testing.
12
12
  */
13
13
  const createMockAnimation = (): Animation => {
14
- const animation = {} as Animation;
15
14
  const animationState = {
16
- resolveFinished: (value: Animation): void => {
17
- void value;
18
- },
15
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- required for Promise resolve callback
16
+ resolveFinished: (_anim: Animation): void => {},
17
+ playState: "running" as AnimationPlayState,
19
18
  };
20
19
 
21
- animation.currentTime = 0;
22
- animation.effect = null;
23
- animation.id = "";
24
- animation.oncancel = null;
25
- animation.onfinish = null;
26
- animation.onremove = null;
27
- animation.pending = false;
28
- animation.playState = "running";
29
- animation.playbackRate = 1;
30
- animation.replaceState = "active";
31
- animation.startTime = 0;
32
- animation.timeline = null;
33
- animation.finished = new Promise((resolve) => {
34
- animationState.resolveFinished = resolve;
35
- });
36
- animation.ready = Promise.resolve(animation);
37
- animation.cancel = () => {
38
- animation.playState = "idle";
39
- };
40
- animation.finish = () => {
41
- animation.playState = "finished";
42
- animationState.resolveFinished(animation);
20
+ const animation: Animation = {
21
+ currentTime: 0,
22
+ effect: null,
23
+ id: "",
24
+ oncancel: null,
25
+ onfinish: null,
26
+ onremove: null,
27
+ get pending() {
28
+ return false;
29
+ },
30
+ get playState() {
31
+ return animationState.playState;
32
+ },
33
+ playbackRate: 1,
34
+ get replaceState() {
35
+ return "active" as AnimationReplaceState;
36
+ },
37
+ startTime: 0,
38
+ timeline: null,
39
+ get finished() {
40
+ return new Promise<Animation>((resolve) => {
41
+ animationState.resolveFinished = resolve;
42
+ });
43
+ },
44
+ get ready() {
45
+ return Promise.resolve(animation);
46
+ },
47
+ cancel() {
48
+ animationState.playState = "idle";
49
+ },
50
+ finish() {
51
+ animationState.playState = "finished";
52
+ animationState.resolveFinished(animation);
53
+ },
54
+ commitStyles() {},
55
+ pause() {},
56
+ persist() {},
57
+ play() {},
58
+ reverse() {},
59
+ updatePlaybackRate() {},
60
+ addEventListener() {},
61
+ removeEventListener() {},
62
+ dispatchEvent() {
63
+ return true;
64
+ },
43
65
  };
44
- animation.commitStyles = () => {};
45
- animation.pause = () => {};
46
- animation.persist = () => {};
47
- animation.play = () => {};
48
- animation.reverse = () => {};
49
- animation.updatePlaybackRate = () => {};
50
-
51
- // EventTarget methods
52
- animation.addEventListener = () => {};
53
- animation.removeEventListener = () => {};
54
- animation.dispatchEvent = () => true;
55
66
 
56
67
  return animation;
57
68
  };
@@ -372,9 +372,9 @@ describe("usePivotSwipeInput", () => {
372
372
 
373
373
  // Mock performance.now() to control velocity calculation
374
374
  // 80px / 200ms = 0.4 px/ms (under 0.5 threshold)
375
- let mockTime = 0;
375
+ const mockTimeState = { value: 0 };
376
376
  const originalPerformanceNow = performance.now;
377
- performance.now = () => mockTime;
377
+ performance.now = () => mockTimeState.value;
378
378
 
379
379
  try {
380
380
  const { result } = renderHook(() =>
@@ -391,7 +391,7 @@ describe("usePivotSwipeInput", () => {
391
391
  );
392
392
 
393
393
  // Pointer down at time 0
394
- mockTime = 0;
394
+ mockTimeState.value = 0;
395
395
  const downEvent = {
396
396
  clientX: 200,
397
397
  clientY: 100,
@@ -407,7 +407,7 @@ describe("usePivotSwipeInput", () => {
407
407
 
408
408
  // 小さな移動 (80px left) at time 200ms
409
409
  // velocity = 80px / 200ms = 0.4 px/ms (under 0.5 threshold)
410
- mockTime = 200;
410
+ mockTimeState.value = 200;
411
411
  const moveEvent = new PointerEvent("pointermove", {
412
412
  clientX: 200 - smallDisplacement,
413
413
  clientY: 102,
@@ -492,9 +492,9 @@ describe("usePivotSwipeInput", () => {
492
492
 
493
493
  // Mock performance.now() to control velocity calculation
494
494
  // 60px / 200ms = 0.3 px/ms (under 0.5 threshold)
495
- let mockTime = 0;
495
+ const mockTimeState = { value: 0 };
496
496
  const originalPerformanceNow = performance.now;
497
- performance.now = () => mockTime;
497
+ performance.now = () => mockTimeState.value;
498
498
 
499
499
  try {
500
500
  // デフォルト閾値: distanceThreshold: 100px, velocityThreshold: 0.5 px/ms
@@ -506,7 +506,7 @@ describe("usePivotSwipeInput", () => {
506
506
  }),
507
507
  );
508
508
 
509
- mockTime = 0;
509
+ mockTimeState.value = 0;
510
510
  const downEvent = {
511
511
  clientX: 200,
512
512
  clientY: 100,
@@ -522,7 +522,7 @@ describe("usePivotSwipeInput", () => {
522
522
 
523
523
  // 60pxは新しいデフォルト閾値(100px)未満
524
524
  // velocity = 60px / 200ms = 0.3 px/ms (under 0.5 threshold)
525
- mockTime = 200;
525
+ mockTimeState.value = 200;
526
526
  const moveEvent = new PointerEvent("pointermove", {
527
527
  clientX: 140, // -60px (< 100px threshold)
528
528
  clientY: 102,
@@ -88,7 +88,7 @@ describe("Swipe transition continuity", () => {
88
88
  */
89
89
  it("behind panel should NOT animate after completing 100% swipe back", () => {
90
90
  const containerSize = 400;
91
- const behindOffset = -0.3; // -120px
91
+ // Behind offset: -0.3 = -120px
92
92
 
93
93
  // Step 1: Render behind panel at depth 0, navigationDepth 1
94
94
  const { container, rerender } = render(
package/src/types.ts CHANGED
@@ -186,6 +186,9 @@ export type PivotBehavior = {
186
186
  transitionMode?: "css" | "none";
187
187
  };
188
188
 
189
+ /** Animation mode for drawer appearance */
190
+ export type DrawerAnimationMode = "overlay" | "reveal";
191
+
189
192
  // Drawer behavior configuration for mobile-friendly slide-in panels
190
193
  export type DrawerBehavior = {
191
194
  /** Optional controlled state */
@@ -199,6 +202,12 @@ export type DrawerBehavior = {
199
202
  * - When not specified, inferred from position prop
200
203
  */
201
204
  anchor?: "left" | "right" | "top" | "bottom";
205
+ /**
206
+ * Animation mode for drawer appearance.
207
+ * - "overlay" (default): Drawer slides over the content
208
+ * - "reveal": Content slides away to reveal the drawer behind
209
+ */
210
+ animationMode?: DrawerAnimationMode;
202
211
  /**
203
212
  * Transition mode for drawer visibility.
204
213
  * - "css" (default) uses CSS transform transitions.
@@ -243,6 +252,12 @@ export type DrawerBehavior = {
243
252
  /** Threshold ratio (0-1) to trigger close. @default 0.3 */
244
253
  dismissThreshold?: number;
245
254
  };
255
+ /**
256
+ * Background color for content element in reveal mode.
257
+ * Applied to create stacking context during reveal animation.
258
+ * @default "#fff"
259
+ */
260
+ revealBackground?: string;
246
261
  };
247
262
 
248
263
  // ============================================================================