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.
- package/dist/FloatingWindow-Bw2djgpz.js +1542 -0
- package/dist/FloatingWindow-Bw2djgpz.js.map +1 -0
- package/dist/FloatingWindow-Cvyokf0m.cjs +2 -0
- package/dist/FloatingWindow-Cvyokf0m.cjs.map +1 -0
- package/dist/GridLayout-B4aCqSyd.js +947 -0
- package/dist/{GridLayout-UWNxXw77.js.map → GridLayout-B4aCqSyd.js.map} +1 -1
- package/dist/GridLayout-DNOClFzz.cjs +2 -0
- package/dist/{GridLayout-DKTg_N61.cjs.map → GridLayout-DNOClFzz.cjs.map} +1 -1
- package/dist/PanelSystem-B8Igvnb2.cjs +3 -0
- package/dist/PanelSystem-B8Igvnb2.cjs.map +1 -0
- package/dist/{PanelSystem-BqUzNtf2.js → PanelSystem-DDUSFjXD.js} +208 -247
- package/dist/PanelSystem-DDUSFjXD.js.map +1 -0
- package/dist/components/window/Drawer.d.ts +1 -0
- package/dist/components/window/DrawerRevealContext.d.ts +61 -0
- package/dist/components/window/drawerRevealAnimationUtils.d.ts +212 -0
- package/dist/components/window/drawerStyles.d.ts +5 -0
- package/dist/components/window/useDrawerSwipeTransform.d.ts +8 -2
- package/dist/components/window/useDrawerTransform.d.ts +68 -0
- package/dist/components/window/useRevealDrawerTransform.d.ts +56 -0
- package/dist/config.cjs +1 -1
- package/dist/config.cjs.map +1 -1
- package/dist/config.js +8 -7
- package/dist/config.js.map +1 -1
- package/dist/grid.cjs +1 -1
- package/dist/grid.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +4 -4
- package/dist/modules/drawer/drawerStateMachine.d.ts +168 -0
- package/dist/modules/drawer/revealDrawerConstants.d.ts +33 -0
- package/dist/modules/drawer/revealDrawerStateMachine.d.ts +146 -0
- package/dist/modules/drawer/strategies/index.d.ts +8 -0
- package/dist/modules/drawer/strategies/overlayStrategy.d.ts +12 -0
- package/dist/modules/drawer/strategies/revealStrategy.d.ts +12 -0
- package/dist/modules/drawer/strategies/types.d.ts +116 -0
- package/dist/panels.cjs +1 -1
- package/dist/panels.js +1 -1
- package/dist/stack.cjs +1 -1
- package/dist/stack.cjs.map +1 -1
- package/dist/stack.js +306 -347
- package/dist/stack.js.map +1 -1
- package/dist/types.d.ts +14 -0
- package/dist/useAnimationFrame-BZ6D2lMq.cjs +2 -0
- package/dist/useAnimationFrame-BZ6D2lMq.cjs.map +1 -0
- package/dist/useAnimationFrame-Bg4e-H8O.js +394 -0
- package/dist/useAnimationFrame-Bg4e-H8O.js.map +1 -0
- package/dist/window.cjs +1 -1
- package/dist/window.js +1 -1
- package/package.json +1 -1
- package/src/components/gesture/SwipeSafeZone.tsx +1 -0
- package/src/components/grid/GridLayout.tsx +110 -38
- package/src/components/window/Drawer.tsx +114 -10
- package/src/components/window/DrawerLayers.tsx +48 -15
- package/src/components/window/DrawerRevealContext.spec.ts +20 -0
- package/src/components/window/DrawerRevealContext.tsx +99 -0
- package/src/components/window/drawerRevealAnimationUtils.spec.ts +375 -0
- package/src/components/window/drawerRevealAnimationUtils.ts +415 -0
- package/src/components/window/drawerStyles.spec.ts +39 -0
- package/src/components/window/drawerStyles.ts +24 -0
- package/src/components/window/useDrawerSwipeTransform.ts +28 -90
- package/src/components/window/useDrawerTransform.ts +505 -0
- package/src/components/window/useRevealDrawerTransform.spec.ts +1936 -0
- package/src/components/window/useRevealDrawerTransform.ts +105 -0
- package/src/demo/components/FullscreenDemoPage.tsx +47 -0
- package/src/demo/fullscreenRoutes.tsx +32 -0
- package/src/demo/index.tsx +5 -0
- package/src/demo/pages/Dialog/components/CardExpandDemo.tsx +23 -8
- package/src/demo/pages/Drawer/components/DrawerBasics.module.css +6 -1
- package/src/demo/pages/Drawer/components/DrawerBasics.tsx +14 -4
- package/src/demo/pages/Drawer/components/DrawerReveal.module.css +157 -0
- package/src/demo/pages/Drawer/components/DrawerReveal.tsx +128 -0
- package/src/demo/pages/Drawer/reveal/index.tsx +17 -0
- package/src/demo/pages/Drawer/reveal-fullscreen/index.tsx +135 -0
- package/src/demo/pages/Drawer/reveal-fullscreen/styles.module.css +233 -0
- package/src/demo/pages/Stack/components/StackBasics.spec.tsx +56 -52
- package/src/demo/pages/Stack/components/StackTablet.spec.tsx +39 -49
- package/src/demo/routes.tsx +2 -0
- package/src/hooks/gesture/testing/createGestureSimulator.ts +1 -0
- package/src/hooks/gesture/useNativeGestureGuard.spec.ts +10 -2
- package/src/hooks/gesture/utils.ts +15 -4
- package/src/hooks/useAnimatedVisibility.spec.ts +3 -3
- package/src/hooks/useOperationContinuity.spec.ts +17 -10
- package/src/hooks/useOperationContinuity.ts +5 -5
- package/src/hooks/useSharedElementTransition.ts +28 -7
- package/src/modules/dialog/dialogAnimationUtils.spec.ts +0 -1
- package/src/modules/dialog/useDialogContainer.spec.ts +11 -3
- package/src/modules/dialog/useDialogSwipeInput.spec.ts +49 -28
- package/src/modules/dialog/useDialogSwipeInput.ts +37 -6
- package/src/modules/dialog/useDialogTransform.spec.ts +63 -30
- package/src/modules/drawer/drawerStateMachine.ts +500 -0
- package/src/modules/drawer/revealDrawerConstants.ts +38 -0
- package/src/modules/drawer/revealDrawerStateMachine.spec.ts +558 -0
- package/src/modules/drawer/revealDrawerStateMachine.ts +197 -0
- package/src/modules/drawer/strategies/index.ts +9 -0
- package/src/modules/drawer/strategies/overlayStrategy.ts +133 -0
- package/src/modules/drawer/strategies/revealStrategy.ts +111 -0
- package/src/modules/drawer/strategies/types.ts +160 -0
- package/src/modules/drawer/useDrawerSwipeInput.ts +7 -4
- package/src/modules/pivot/SwipePivotContent.spec.tsx +48 -37
- package/src/modules/pivot/usePivotSwipeInput.spec.ts +8 -8
- package/src/modules/stack/swipeTransitionContinuity.spec.tsx +1 -1
- package/src/types.ts +15 -0
- package/dist/FloatingWindow-CUXnEtrb.js +0 -827
- package/dist/FloatingWindow-CUXnEtrb.js.map +0 -1
- package/dist/FloatingWindow-DMwyK0eK.cjs +0 -2
- package/dist/FloatingWindow-DMwyK0eK.cjs.map +0 -1
- package/dist/GridLayout-DKTg_N61.cjs +0 -2
- package/dist/GridLayout-UWNxXw77.js +0 -926
- package/dist/PanelSystem-BqUzNtf2.js.map +0 -1
- package/dist/PanelSystem-D603LKKv.cjs +0 -3
- package/dist/PanelSystem-D603LKKv.cjs.map +0 -1
- package/dist/useNativeGestureGuard-C7TSqEkr.cjs +0 -2
- package/dist/useNativeGestureGuard-C7TSqEkr.cjs.map +0 -1
- package/dist/useNativeGestureGuard-CGYo6O0r.js +0 -347
- package/dist/useNativeGestureGuard-CGYo6O0r.js.map +0 -1
- 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
|
-
|
|
17
|
-
|
|
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
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
375
|
+
const mockTimeState = { value: 0 };
|
|
376
376
|
const originalPerformanceNow = performance.now;
|
|
377
|
-
performance.now = () =>
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
495
|
+
const mockTimeState = { value: 0 };
|
|
496
496
|
const originalPerformanceNow = performance.now;
|
|
497
|
-
performance.now = () =>
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
// ============================================================================
|