react-panel-layout 0.5.1 → 0.6.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/{FloatingPanelFrame-D9Cp2al1.cjs → FloatingPanelFrame-CEmXDvUA.cjs} +2 -2
- package/dist/FloatingPanelFrame-CEmXDvUA.cjs.map +1 -0
- package/dist/{FloatingPanelFrame-6W5OexYe.js → FloatingPanelFrame-SgYLc6Ud.js} +12 -15
- package/dist/FloatingPanelFrame-SgYLc6Ud.js.map +1 -0
- package/dist/FloatingWindow-BpdOpg_L.js +400 -0
- package/dist/FloatingWindow-BpdOpg_L.js.map +1 -0
- package/dist/FloatingWindow-TCDNY5gE.cjs +2 -0
- package/dist/FloatingWindow-TCDNY5gE.cjs.map +1 -0
- package/dist/GridLayout-B4VRsC0r.cjs +2 -0
- package/dist/GridLayout-B4VRsC0r.cjs.map +1 -0
- package/dist/GridLayout-BltqeCPK.js +927 -0
- package/dist/GridLayout-BltqeCPK.js.map +1 -0
- package/dist/HorizontalDivider-B5Z-KZLk.cjs +2 -0
- package/dist/HorizontalDivider-B5Z-KZLk.cjs.map +1 -0
- package/dist/HorizontalDivider-WF1k_qND.js +30 -0
- package/dist/HorizontalDivider-WF1k_qND.js.map +1 -0
- package/dist/PanelSystem-Bs8bQwQF.cjs +3 -0
- package/dist/PanelSystem-Bs8bQwQF.cjs.map +1 -0
- package/dist/PanelSystem-Dr1TBhxM.js +1946 -0
- package/dist/PanelSystem-Dr1TBhxM.js.map +1 -0
- package/dist/ResizeHandle-CScipO5l.cjs +2 -0
- package/dist/ResizeHandle-CScipO5l.cjs.map +1 -0
- package/dist/ResizeHandle-CdA_JYfN.js +120 -0
- package/dist/ResizeHandle-CdA_JYfN.js.map +1 -0
- package/dist/SwipePivotTabBar-BGO9X94m.js +407 -0
- package/dist/SwipePivotTabBar-BGO9X94m.js.map +1 -0
- package/dist/SwipePivotTabBar-BrQismcZ.cjs +2 -0
- package/dist/SwipePivotTabBar-BrQismcZ.cjs.map +1 -0
- package/dist/config.cjs +1 -1
- package/dist/config.cjs.map +1 -1
- package/dist/config.js +11 -9
- package/dist/config.js.map +1 -1
- package/dist/constants/styles.d.ts +18 -4
- package/dist/floating.cjs +1 -1
- package/dist/floating.js +1 -1
- package/dist/grid/index.d.ts +58 -0
- package/dist/grid.cjs +2 -0
- package/dist/grid.cjs.map +1 -0
- package/dist/grid.js +13 -0
- package/dist/grid.js.map +1 -0
- package/dist/hooks/gesture/presets.d.ts +33 -0
- package/dist/hooks/gesture/testing/createGestureSimulator.d.ts +110 -0
- package/dist/hooks/gesture/thresholdValue.d.ts +44 -0
- package/dist/hooks/gesture/types.d.ts +254 -0
- package/dist/hooks/gesture/useDirectionalLock.d.ts +20 -0
- package/dist/hooks/gesture/useEdgeSwipeInput.d.ts +23 -0
- package/dist/hooks/gesture/useNativeGestureGuard.d.ts +23 -0
- package/dist/hooks/gesture/usePointerTracking.d.ts +22 -0
- package/dist/hooks/gesture/useScrollBoundary.d.ts +23 -0
- package/dist/hooks/gesture/useSwipeInput.d.ts +5 -0
- package/dist/hooks/gesture/utils.d.ts +40 -0
- package/dist/hooks/useAnimatedVisibility.d.ts +58 -0
- package/dist/hooks/useAnimationFrame.d.ts +84 -0
- package/dist/hooks/useSnapAnimation.d.ts +54 -0
- package/dist/hooks/useSwipeContentTransform.d.ts +79 -0
- package/dist/index.cjs +1 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +25 -2006
- package/dist/index.js.map +1 -1
- package/dist/modules/pivot/PivotContent.d.ts +1 -1
- package/dist/modules/pivot/SwipePivotContent.d.ts +39 -0
- package/dist/modules/pivot/SwipePivotContent.debug.tmp.d.ts +25 -0
- package/dist/modules/pivot/SwipePivotContent.test.d.ts +1 -0
- package/dist/modules/pivot/SwipePivotTabBar.d.ts +89 -0
- package/dist/modules/pivot/index.d.ts +3 -0
- package/dist/modules/pivot/scaleInputState.d.ts +37 -0
- package/dist/modules/pivot/types.d.ts +73 -2
- package/dist/modules/pivot/usePivotSwipeInput.d.ts +68 -0
- package/dist/modules/stack/StackContent.d.ts +15 -0
- package/dist/modules/stack/SwipeStackContent.d.ts +63 -0
- package/dist/modules/stack/SwipeStackOutlet.d.ts +80 -0
- package/dist/modules/stack/computeStackContentState.d.ts +99 -0
- package/dist/modules/stack/computeSwipeStackTransform.d.ts +76 -0
- package/dist/modules/stack/types.d.ts +194 -0
- package/dist/modules/stack/useStackAnimationState.d.ts +32 -0
- package/dist/modules/stack/useStackNavigation.d.ts +23 -0
- package/dist/modules/stack/useStackSwipeInput.d.ts +27 -0
- package/dist/panels/index.d.ts +67 -0
- package/dist/panels.cjs +2 -0
- package/dist/panels.cjs.map +1 -0
- package/dist/panels.js +28 -0
- package/dist/panels.js.map +1 -0
- package/dist/pivot/index.d.ts +3 -0
- package/dist/pivot.cjs +1 -1
- package/dist/pivot.cjs.map +1 -1
- package/dist/pivot.js +20 -2
- package/dist/pivot.js.map +1 -1
- package/dist/resizer/index.d.ts +57 -0
- package/dist/resizer.cjs +2 -0
- package/dist/resizer.cjs.map +1 -0
- package/dist/resizer.js +8 -0
- package/dist/resizer.js.map +1 -0
- package/dist/stack/index.d.ts +72 -0
- package/dist/stack.cjs +2 -0
- package/dist/stack.cjs.map +1 -0
- package/dist/stack.js +980 -0
- package/dist/stack.js.map +1 -0
- package/dist/sticky-header/StickyArea.d.ts +38 -0
- package/dist/sticky-header/index.d.ts +4 -4
- package/dist/sticky-header/types.d.ts +35 -22
- package/dist/sticky-header.cjs +1 -1
- package/dist/sticky-header.cjs.map +1 -1
- package/dist/sticky-header.js +65 -174
- package/dist/sticky-header.js.map +1 -1
- package/dist/styles-DPPuJ0sf.js +57 -0
- package/dist/styles-DPPuJ0sf.js.map +1 -0
- package/dist/styles-qf6ptVLD.cjs +2 -0
- package/dist/styles-qf6ptVLD.cjs.map +1 -0
- package/dist/types.d.ts +12 -0
- package/dist/useContentCache-CO3LYNmz.js +24 -0
- package/dist/useContentCache-CO3LYNmz.js.map +1 -0
- package/dist/useContentCache-DqXtLrLs.cjs +2 -0
- package/dist/useContentCache-DqXtLrLs.cjs.map +1 -0
- package/dist/useDocumentPointerEvents-CKdhGXd0.js +46 -0
- package/dist/useDocumentPointerEvents-CKdhGXd0.js.map +1 -0
- package/dist/useDocumentPointerEvents-ChqrKXDk.cjs +2 -0
- package/dist/useDocumentPointerEvents-ChqrKXDk.cjs.map +1 -0
- package/dist/useEffectEvent-Dp7HLCf0.js +13 -0
- package/dist/useEffectEvent-Dp7HLCf0.js.map +1 -0
- package/dist/useEffectEvent-huSsGUnl.cjs +2 -0
- package/dist/useEffectEvent-huSsGUnl.cjs.map +1 -0
- package/dist/useFloatingState-C4kRaW_R.cjs +2 -0
- package/dist/useFloatingState-C4kRaW_R.cjs.map +1 -0
- package/dist/useFloatingState-tEfA_wbc.js +74 -0
- package/dist/useFloatingState-tEfA_wbc.js.map +1 -0
- package/dist/window/index.d.ts +61 -0
- package/dist/window.cjs +2 -0
- package/dist/window.cjs.map +1 -0
- package/dist/window.js +149 -0
- package/dist/window.js.map +1 -0
- package/docs/design-tokens.md +405 -0
- package/package.json +29 -4
- package/src/PanelSystemContext.tsx +88 -0
- package/src/components/grid/GridLayerList.tsx +172 -0
- package/src/components/grid/GridLayerResizeHandles.tsx +145 -0
- package/src/components/grid/GridLayout.spec.tsx +743 -0
- package/src/components/grid/GridLayout.tsx +130 -0
- package/src/components/grid/GridTrackResizeHandle.tsx +87 -0
- package/src/components/paneling/FloatingPanelFrame.tsx +203 -0
- package/src/components/panels/DropSuggestOverlay.tsx +131 -0
- package/src/components/panels/PanelGroupView.tsx +112 -0
- package/src/components/pivot/PivotLayer.tsx +27 -0
- package/src/components/resizer/HorizontalDivider.tsx +52 -0
- package/src/components/resizer/ResizeHandle.tsx +118 -0
- package/src/components/tabs/TabBar.tsx +223 -0
- package/src/components/tabs/TabBarTab.tsx +133 -0
- package/src/components/tabs/TabDragOverlay.tsx +92 -0
- package/src/components/window/DialogOverlay.tsx +180 -0
- package/src/components/window/Drawer.tsx +282 -0
- package/src/components/window/DrawerLayers.tsx +58 -0
- package/src/components/window/FloatingWindow.tsx +95 -0
- package/src/components/window/PopupLayerPortal.tsx +218 -0
- package/src/config/PanelContentDeclaration.tsx +427 -0
- package/src/config/index.tsx +52 -0
- package/src/config/panelJsx.spec.tsx +54 -0
- package/src/config/panelJsxConfig.spec.tsx +54 -0
- package/src/config/panelJsxDrawer.spec.tsx +33 -0
- package/src/config/panelRouter.spec.ts +68 -0
- package/src/config/panelRouter.tsx +155 -0
- package/src/constants/styles.ts +261 -0
- package/src/demo/Layout.module.css +258 -0
- package/src/demo/Layout.tsx +176 -0
- package/src/demo/components/CodeBlock.module.css +54 -0
- package/src/demo/components/CodeBlock.tsx +34 -0
- package/src/demo/components/CodePreview.module.css +37 -0
- package/src/demo/components/CodePreview.tsx +31 -0
- package/src/demo/components/DataPreview.module.css +177 -0
- package/src/demo/components/DataPreview.tsx +115 -0
- package/src/demo/components/Story.module.css +68 -0
- package/src/demo/components/Story.tsx +54 -0
- package/src/demo/components/layout/CodePanel.module.css +183 -0
- package/src/demo/components/layout/CodePanel.tsx +149 -0
- package/src/demo/components/layout/DemoPage.module.css +60 -0
- package/src/demo/components/layout/DemoPage.tsx +56 -0
- package/src/demo/components/layout/SingleSamplePage.module.css +11 -0
- package/src/demo/components/layout/SingleSamplePage.tsx +35 -0
- package/src/demo/components/layout/SplitDemoLayout.module.css +107 -0
- package/src/demo/components/layout/SplitDemoLayout.tsx +218 -0
- package/src/demo/components/layout/index.ts +11 -0
- package/src/demo/components/tab-styles/ChromeTabBar.module.css +75 -0
- package/src/demo/components/tab-styles/ChromeTabBar.tsx +111 -0
- package/src/demo/components/tab-styles/GitHubTabBar.module.css +81 -0
- package/src/demo/components/tab-styles/GitHubTabBar.tsx +109 -0
- package/src/demo/components/tab-styles/VSCodeTabBar.module.css +78 -0
- package/src/demo/components/tab-styles/VSCodeTabBar.tsx +109 -0
- package/src/demo/components/tab-styles/index.ts +6 -0
- package/src/demo/components/ui/DemoButton.module.css +63 -0
- package/src/demo/components/ui/DemoButton.tsx +32 -0
- package/src/demo/components/ui/DemoCard.module.css +15 -0
- package/src/demo/components/ui/DemoCard.tsx +30 -0
- package/src/demo/components/ui/DemoContainer.module.css +17 -0
- package/src/demo/components/ui/DemoContainer.tsx +30 -0
- package/src/demo/components/ui/DemoPanel.module.css +23 -0
- package/src/demo/components/ui/DemoPanel.tsx +33 -0
- package/src/demo/components/ui/PanelText.module.css +18 -0
- package/src/demo/components/ui/PanelText.tsx +29 -0
- package/src/demo/components/ui/PanelTitle.module.css +18 -0
- package/src/demo/components/ui/PanelTitle.tsx +31 -0
- package/src/demo/contexts/TabbarDemoConfig.tsx +218 -0
- package/src/demo/demo.css +172 -0
- package/src/demo/hooks/useMedia.ts +41 -0
- package/src/demo/hooks/useShikiHighlight.ts +55 -0
- package/src/demo/index.tsx +293 -0
- package/src/demo/pages/Drawer/animations/index.tsx +22 -0
- package/src/demo/pages/Drawer/basics/index.tsx +17 -0
- package/src/demo/pages/Drawer/components/DrawerAnimations.module.css +125 -0
- package/src/demo/pages/Drawer/components/DrawerAnimations.tsx +118 -0
- package/src/demo/pages/Drawer/components/DrawerBasics.module.css +55 -0
- package/src/demo/pages/Drawer/components/DrawerBasics.tsx +76 -0
- package/src/demo/pages/Drawer/components/DrawerMenuLayout.module.css +332 -0
- package/src/demo/pages/Drawer/components/DrawerMenuLayout.tsx +199 -0
- package/src/demo/pages/Drawer/menu/index.tsx +17 -0
- package/src/demo/pages/FloatingPanelFrame/ResizableFloatingPanelsPreview.module.css +163 -0
- package/src/demo/pages/FloatingPanelFrame/ResizableFloatingPanelsPreview.tsx +234 -0
- package/src/demo/pages/FloatingPanelFrame/basic/index.tsx +17 -0
- package/src/demo/pages/FloatingPanelFrame/complex/index.tsx +26 -0
- package/src/demo/pages/FloatingPanelFrame/components/BasicPanel.module.css +16 -0
- package/src/demo/pages/FloatingPanelFrame/components/BasicPanel.tsx +24 -0
- package/src/demo/pages/FloatingPanelFrame/components/ComplexPanel.module.css +54 -0
- package/src/demo/pages/FloatingPanelFrame/components/ComplexPanel.tsx +67 -0
- package/src/demo/pages/FloatingPanelFrame/components/PanelWithControls.module.css +21 -0
- package/src/demo/pages/FloatingPanelFrame/components/PanelWithControls.tsx +41 -0
- package/src/demo/pages/FloatingPanelFrame/components/PanelWithMeta.module.css +5 -0
- package/src/demo/pages/FloatingPanelFrame/components/PanelWithMeta.tsx +43 -0
- package/src/demo/pages/FloatingPanelFrame/components/ScrollablePanel.module.css +11 -0
- package/src/demo/pages/FloatingPanelFrame/components/ScrollablePanel.tsx +42 -0
- package/src/demo/pages/FloatingPanelFrame/index.tsx +80 -0
- package/src/demo/pages/FloatingPanelFrame/scrollable/index.tsx +30 -0
- package/src/demo/pages/FloatingPanelFrame/with-controls/index.tsx +30 -0
- package/src/demo/pages/FloatingPanelFrame/with-meta/index.tsx +17 -0
- package/src/demo/pages/HorizontalDivider/components/PanelsWithRichContent.module.css +112 -0
- package/src/demo/pages/HorizontalDivider/components/PanelsWithRichContent.tsx +56 -0
- package/src/demo/pages/HorizontalDivider/components/SimpleResizablePanels.module.css +46 -0
- package/src/demo/pages/HorizontalDivider/components/SimpleResizablePanels.tsx +29 -0
- package/src/demo/pages/HorizontalDivider/components/ThreePanelLayout.module.css +54 -0
- package/src/demo/pages/HorizontalDivider/components/ThreePanelLayout.tsx +30 -0
- package/src/demo/pages/HorizontalDivider/index.module.css +14 -0
- package/src/demo/pages/HorizontalDivider/index.tsx +64 -0
- package/src/demo/pages/HorizontalDivider/panels-with-rich-content/index.tsx +21 -0
- package/src/demo/pages/HorizontalDivider/simple-resizable-panels/index.tsx +21 -0
- package/src/demo/pages/HorizontalDivider/three-panel-layout/index.tsx +21 -0
- package/src/demo/pages/PanelLayout/PanelLayoutDemo.module.css +174 -0
- package/src/demo/pages/PanelLayout/PanelLayoutDemo.tsx +248 -0
- package/src/demo/pages/PanelLayout/components/DashboardLayout.module.css +115 -0
- package/src/demo/pages/PanelLayout/components/DashboardLayout.tsx +124 -0
- package/src/demo/pages/PanelLayout/components/DraggableOverlays.module.css +101 -0
- package/src/demo/pages/PanelLayout/components/DraggableOverlays.tsx +122 -0
- package/src/demo/pages/PanelLayout/components/IDELayout.module.css +104 -0
- package/src/demo/pages/PanelLayout/components/IDELayout.tsx +143 -0
- package/src/demo/pages/PanelLayout/components/SimpleGrid.module.css +19 -0
- package/src/demo/pages/PanelLayout/components/SimpleGrid.tsx +62 -0
- package/src/demo/pages/PanelLayout/dashboard/index.tsx +22 -0
- package/src/demo/pages/PanelLayout/draggable-overlays/index.tsx +22 -0
- package/src/demo/pages/PanelLayout/ide-layout/index.tsx +22 -0
- package/src/demo/pages/PanelLayout/index.tsx +94 -0
- package/src/demo/pages/PanelLayout/simple-grid/index.tsx +22 -0
- package/src/demo/pages/PanelSystem/PanelSystemPreview.module.css +20 -0
- package/src/demo/pages/PanelSystem/PanelSystemPreview.tsx +101 -0
- package/src/demo/pages/PanelSystem/preview/index.tsx +18 -0
- package/src/demo/pages/PanelSystem/tabbar/index.tsx +129 -0
- package/src/demo/pages/Pivot/basics/index.tsx +17 -0
- package/src/demo/pages/Pivot/components/Pivot.module.css +278 -0
- package/src/demo/pages/Pivot/components/PivotBasics.tsx +103 -0
- package/src/demo/pages/Pivot/components/PivotSidebar.tsx +168 -0
- package/src/demo/pages/Pivot/components/PivotTabs.tsx +129 -0
- package/src/demo/pages/Pivot/components/PivotTransitions.tsx +120 -0
- package/src/demo/pages/Pivot/components/SwipePivot.module.css +114 -0
- package/src/demo/pages/Pivot/components/SwipePivot.tsx +193 -0
- package/src/demo/pages/Pivot/components/SwipeTabsPivot.module.css +203 -0
- package/src/demo/pages/Pivot/components/SwipeTabsPivot.tsx +289 -0
- package/src/demo/pages/Pivot/sidebar/index.tsx +17 -0
- package/src/demo/pages/Pivot/swipe/index.tsx +16 -0
- package/src/demo/pages/Pivot/swipe-debug/index.tsx +287 -0
- package/src/demo/pages/Pivot/swipe-tabs/index.tsx +15 -0
- package/src/demo/pages/Pivot/tabs/index.tsx +17 -0
- package/src/demo/pages/Pivot/transitions/index.tsx +17 -0
- package/src/demo/pages/ResizeHandle/both-directions/index.tsx +17 -0
- package/src/demo/pages/ResizeHandle/components/BothDirectionsDemo.module.css +72 -0
- package/src/demo/pages/ResizeHandle/components/BothDirectionsDemo.tsx +41 -0
- package/src/demo/pages/ResizeHandle/components/HorizontalResizeDemo.module.css +61 -0
- package/src/demo/pages/ResizeHandle/components/HorizontalResizeDemo.tsx +33 -0
- package/src/demo/pages/ResizeHandle/components/NestedPanelsDemo.module.css +83 -0
- package/src/demo/pages/ResizeHandle/components/NestedPanelsDemo.tsx +53 -0
- package/src/demo/pages/ResizeHandle/components/VerticalResizeDemo.module.css +68 -0
- package/src/demo/pages/ResizeHandle/components/VerticalResizeDemo.tsx +33 -0
- package/src/demo/pages/ResizeHandle/horizontal/index.tsx +17 -0
- package/src/demo/pages/ResizeHandle/index.module.css +11 -0
- package/src/demo/pages/ResizeHandle/index.tsx +71 -0
- package/src/demo/pages/ResizeHandle/nested-panels/index.tsx +17 -0
- package/src/demo/pages/ResizeHandle/vertical/index.tsx +17 -0
- package/src/demo/pages/ResponsiveLayout/adaptive-workspace/index.tsx +22 -0
- package/src/demo/pages/ResponsiveLayout/components/ResponsiveWorkspace.module.css +423 -0
- package/src/demo/pages/ResponsiveLayout/components/ResponsiveWorkspace.tsx +398 -0
- package/src/demo/pages/Stack/basics/index.tsx +22 -0
- package/src/demo/pages/Stack/components/Stack.module.css +234 -0
- package/src/demo/pages/Stack/components/StackBasics.tsx +217 -0
- package/src/demo/pages/Stack/components/StackTablet.module.css +299 -0
- package/src/demo/pages/Stack/components/StackTablet.tsx +401 -0
- package/src/demo/pages/Stack/tablet/index.tsx +22 -0
- package/src/demo/pages/StickyHeader/basics/index.tsx +17 -0
- package/src/demo/pages/StickyHeader/components/StickyHeader.module.css +219 -0
- package/src/demo/pages/StickyHeader/components/StickyHeaderBasics.tsx +103 -0
- package/src/demo/routes.tsx +193 -0
- package/src/demo/styles/animations.css +68 -0
- package/src/demo/styles/stack-themes.css +35 -0
- package/src/demo/utils/createPanelView.tsx +58 -0
- package/src/floating/index.ts +24 -0
- package/src/grid/index.ts +75 -0
- package/src/hooks/ContentCacheContext.tsx +87 -0
- package/src/hooks/gesture/presets.spec.ts +86 -0
- package/src/hooks/gesture/presets.ts +95 -0
- package/src/hooks/gesture/testing/createGestureSimulator.spec.ts +237 -0
- package/src/hooks/gesture/testing/createGestureSimulator.ts +310 -0
- package/src/hooks/gesture/thresholdValue.spec.ts +103 -0
- package/src/hooks/gesture/thresholdValue.ts +77 -0
- package/src/hooks/gesture/types.ts +290 -0
- package/src/hooks/gesture/useDirectionalLock.spec.ts +271 -0
- package/src/hooks/gesture/useDirectionalLock.ts +115 -0
- package/src/hooks/gesture/useEdgeSwipeInput.spec.ts +454 -0
- package/src/hooks/gesture/useEdgeSwipeInput.ts +131 -0
- package/src/hooks/gesture/useNativeGestureGuard.spec.ts +413 -0
- package/src/hooks/gesture/useNativeGestureGuard.ts +133 -0
- package/src/hooks/gesture/usePointerTracking.spec.ts +364 -0
- package/src/hooks/gesture/usePointerTracking.ts +134 -0
- package/src/hooks/gesture/useScrollBoundary.spec.ts +249 -0
- package/src/hooks/gesture/useScrollBoundary.ts +113 -0
- package/src/hooks/gesture/useSwipeInput.spec.ts +592 -0
- package/src/hooks/gesture/useSwipeInput.ts +310 -0
- package/src/hooks/gesture/utils.spec.ts +152 -0
- package/src/hooks/gesture/utils.ts +87 -0
- package/src/hooks/useAnimatedVisibility.spec.ts +257 -0
- package/src/hooks/useAnimatedVisibility.ts +146 -0
- package/src/hooks/useAnimationFrame.ts +200 -0
- package/src/hooks/useCSSMatrix.spec.ts +214 -0
- package/src/hooks/useCSSMatrix.ts +262 -0
- package/src/hooks/useClonedElementPreview.ts +28 -0
- package/src/hooks/useContainerScroll.ts +78 -0
- package/src/hooks/useContentCache.spec.tsx +232 -0
- package/src/hooks/useContentCache.tsx +127 -0
- package/src/hooks/useDocumentPointerEvents.ts +137 -0
- package/src/hooks/useDocumentScroll.ts +41 -0
- package/src/hooks/useEffectEvent.ts +40 -0
- package/src/hooks/useElementComponentWrapper.tsx +63 -0
- package/src/hooks/useIntersectionObserver.tsx +125 -0
- package/src/hooks/useIsomorphicLayoutEffect.ts +29 -0
- package/src/hooks/useResizeObserver.tsx +81 -0
- package/src/hooks/useScrollContainer.ts +79 -0
- package/src/hooks/useSnapAnimation.ts +128 -0
- package/src/hooks/useSwipeContentTransform.spec.ts +133 -0
- package/src/hooks/useSwipeContentTransform.ts +235 -0
- package/src/hooks/useTransitionState.ts +95 -0
- package/src/index.tsx +88 -0
- package/src/modules/grid/GridLayoutContext.tsx +57 -0
- package/src/modules/grid/LayerInstanceContext.tsx +56 -0
- package/src/modules/grid/resizeHandles.ts +157 -0
- package/src/modules/grid/trackUtils.ts +146 -0
- package/src/modules/grid/useGridPlacements.ts +143 -0
- package/src/modules/grid/useGridTracks.ts +156 -0
- package/src/modules/grid/useLayerDragHandle.ts +16 -0
- package/src/modules/grid/useLayerInteractions.tsx +850 -0
- package/src/modules/keybindings/KeybindingsProvider.tsx +111 -0
- package/src/modules/panels/dom/DomRegistry.tsx +94 -0
- package/src/modules/panels/index.ts +45 -0
- package/src/modules/panels/interactions/InteractionsContext.test.tsx +330 -0
- package/src/modules/panels/interactions/InteractionsContext.tsx +394 -0
- package/src/modules/panels/interactions/dnd.ts +28 -0
- package/src/modules/panels/keybindings/KeybindingsInstaller.tsx +15 -0
- package/src/modules/panels/layout/adapter.ts +124 -0
- package/src/modules/panels/rendering/ContentRegistry.spec.tsx +304 -0
- package/src/modules/panels/rendering/ContentRegistry.tsx +205 -0
- package/src/modules/panels/rendering/GroupContainer.tsx +65 -0
- package/src/modules/panels/rendering/RenderBridge.tsx +115 -0
- package/src/modules/panels/rendering/RenderContext.tsx +31 -0
- package/src/modules/panels/state/PanelSplitHandles.tsx +147 -0
- package/src/modules/panels/state/PanelSystemContext.splitLimits.spec.tsx +50 -0
- package/src/modules/panels/state/PanelSystemContext.tsx +289 -0
- package/src/modules/panels/state/StateContext.tsx +12 -0
- package/src/modules/panels/state/cleanup.ts +37 -0
- package/src/modules/panels/state/commands.ts +53 -0
- package/src/modules/panels/state/focus/Context.tsx +25 -0
- package/src/modules/panels/state/focus/logic.ts +57 -0
- package/src/modules/panels/state/groups/Context.tsx +25 -0
- package/src/modules/panels/state/groups/logic.ts +105 -0
- package/src/modules/panels/state/splitLimits.spec.ts +46 -0
- package/src/modules/panels/state/splitLimits.ts +90 -0
- package/src/modules/panels/state/state.spec.ts +49 -0
- package/src/modules/panels/state/tree/Context.tsx +24 -0
- package/src/modules/panels/state/tree/logic.spec.ts +34 -0
- package/src/modules/panels/state/tree/logic.ts +138 -0
- package/src/modules/panels/state/types.ts +142 -0
- package/src/modules/panels/system/PanelSystem.empty-tabbar.spec.tsx +53 -0
- package/src/modules/panels/system/PanelSystem.tab-click-activates.spec.tsx +44 -0
- package/src/modules/panels/system/PanelSystem.tab-reorder.spec.tsx +64 -0
- package/src/modules/panels/system/PanelSystem.tabs-no-dup.spec.tsx +57 -0
- package/src/modules/panels/system/PanelSystem.tsx +206 -0
- package/src/modules/pivot/PivotContent.spec.tsx +179 -0
- package/src/modules/pivot/PivotContent.tsx +77 -0
- package/src/modules/pivot/SwipePivotContent.debug.tmp.tsx +237 -0
- package/src/modules/pivot/SwipePivotContent.position.spec.tsx +167 -0
- package/src/modules/pivot/SwipePivotContent.spec.tsx +464 -0
- package/src/modules/pivot/SwipePivotContent.test.tsx +502 -0
- package/src/modules/pivot/SwipePivotContent.tsx +197 -0
- package/src/modules/pivot/SwipePivotTabBar.spec.tsx +865 -0
- package/src/modules/pivot/SwipePivotTabBar.tsx +523 -0
- package/src/modules/pivot/index.ts +8 -0
- package/src/modules/pivot/scaleInputState.spec.ts +210 -0
- package/src/modules/pivot/scaleInputState.ts +66 -0
- package/src/modules/pivot/types.ts +139 -0
- package/src/modules/pivot/usePivot.spec.ts +621 -0
- package/src/modules/pivot/usePivot.spec.tsx +186 -0
- package/src/modules/pivot/usePivot.tsx +345 -0
- package/src/modules/pivot/usePivotSwipeInput.spec.ts +649 -0
- package/src/modules/pivot/usePivotSwipeInput.ts +136 -0
- package/src/modules/resizer/useResizeDrag.ts +94 -0
- package/src/modules/stack/StackContent.spec.tsx +264 -0
- package/src/modules/stack/StackContent.tsx +111 -0
- package/src/modules/stack/SwipeStackContent.spec.tsx +1277 -0
- package/src/modules/stack/SwipeStackContent.tsx +356 -0
- package/src/modules/stack/SwipeStackOutlet.spec.tsx +252 -0
- package/src/modules/stack/SwipeStackOutlet.tsx +221 -0
- package/src/modules/stack/computeStackContentState.spec.ts +281 -0
- package/src/modules/stack/computeStackContentState.ts +304 -0
- package/src/modules/stack/computeSwipeStackTransform.spec.ts +186 -0
- package/src/modules/stack/computeSwipeStackTransform.ts +145 -0
- package/src/modules/stack/types.ts +226 -0
- package/src/modules/stack/useStackAnimationState.spec.ts +186 -0
- package/src/modules/stack/useStackAnimationState.ts +138 -0
- package/src/modules/stack/useStackNavigation.spec.ts +477 -0
- package/src/modules/stack/useStackNavigation.tsx +336 -0
- package/src/modules/stack/useStackSwipeInput.spec.ts +276 -0
- package/src/modules/stack/useStackSwipeInput.ts +139 -0
- package/src/modules/window/useDrawerState.ts +81 -0
- package/src/modules/window/useFloatingState.spec.ts +252 -0
- package/src/modules/window/useFloatingState.ts +141 -0
- package/src/panels/index.ts +119 -0
- package/src/pivot/index.ts +19 -0
- package/src/resizer/index.ts +68 -0
- package/src/stack/index.ts +91 -0
- package/src/sticky-header/StickyArea.tsx +221 -0
- package/src/sticky-header/index.ts +18 -0
- package/src/sticky-header/types.ts +68 -0
- package/src/types.ts +323 -0
- package/src/utils/CSSMatrix.ts +321 -0
- package/src/utils/css.ts +65 -0
- package/src/utils/dialogUtils.ts +43 -0
- package/src/utils/math.ts +18 -0
- package/src/utils/polyfills/createDialogPolyfill.ts +18 -0
- package/src/utils/typedActions.ts +103 -0
- package/src/vite-env.d.ts +6 -0
- package/src/window/index.ts +67 -0
- package/dist/FloatingPanelFrame-6W5OexYe.js.map +0 -1
- package/dist/FloatingPanelFrame-D9Cp2al1.cjs.map +0 -1
- package/dist/GridLayout-BzrIDrC9.js +0 -1465
- package/dist/GridLayout-BzrIDrC9.js.map +0 -1
- package/dist/GridLayout-ZrOhoLLB.cjs +0 -2
- package/dist/GridLayout-ZrOhoLLB.cjs.map +0 -1
- package/dist/sticky-header/StickyHeader.d.ts +0 -53
- package/dist/styles-CA2_zLZt.js +0 -52
- package/dist/styles-CA2_zLZt.js.map +0 -1
- package/dist/styles-PsqGOEJP.cjs +0 -2
- package/dist/styles-PsqGOEJP.cjs.map +0 -1
- package/dist/usePivot-BS-DGfwd.cjs +0 -2
- package/dist/usePivot-BS-DGfwd.cjs.map +0 -1
- package/dist/usePivot-BvOGxLQQ.js +0 -124
- package/dist/usePivot-BvOGxLQQ.js.map +0 -1
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Type definitions for the Stack navigation component system.
|
|
3
|
+
*
|
|
4
|
+
* Stack manages hierarchical navigation where panels stack as you drill down.
|
|
5
|
+
* Similar to iOS/iPadOS navigation controllers.
|
|
6
|
+
*/
|
|
7
|
+
import type * as React from "react";
|
|
8
|
+
import type { SwipeInputState } from "../../hooks/gesture/types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Display mode for stack panels.
|
|
11
|
+
* - "overlay": Panels fully overlap (mobile style)
|
|
12
|
+
* - "slide": Panels slide in from edge
|
|
13
|
+
* - "stack": Panels stack with visual depth (tablet style)
|
|
14
|
+
*/
|
|
15
|
+
export type StackDisplayMode = "overlay" | "slide" | "stack";
|
|
16
|
+
/**
|
|
17
|
+
* Transition mode for stack animations.
|
|
18
|
+
* - "css": Uses CSS transitions/animations
|
|
19
|
+
* - "none": No transitions (uses React.Activity for memory optimization)
|
|
20
|
+
*/
|
|
21
|
+
export type StackTransitionMode = "css" | "none";
|
|
22
|
+
/**
|
|
23
|
+
* A panel in the stack.
|
|
24
|
+
*/
|
|
25
|
+
export type StackPanel<TId extends string = string> = {
|
|
26
|
+
/** Unique identifier for this panel */
|
|
27
|
+
id: TId;
|
|
28
|
+
/** Human-readable title for the panel (used in headers, back buttons) */
|
|
29
|
+
title?: string;
|
|
30
|
+
/** The content to render */
|
|
31
|
+
content: React.ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* Enable content caching to preserve React component state.
|
|
34
|
+
* When disabled (default), content is re-created on each render.
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
cache?: boolean;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* State of the stack navigation.
|
|
41
|
+
*/
|
|
42
|
+
export type StackNavigationState<TId extends string = string> = {
|
|
43
|
+
/** Stack of panel IDs representing the navigation hierarchy */
|
|
44
|
+
stack: ReadonlyArray<TId>;
|
|
45
|
+
/** Current depth in the stack (0-indexed) */
|
|
46
|
+
depth: number;
|
|
47
|
+
/** Whether a parent panel is being revealed (peeking) */
|
|
48
|
+
isRevealing: boolean;
|
|
49
|
+
/** Depth of the revealed parent, if any */
|
|
50
|
+
revealDepth: number | null;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Props returned by getPanelProps for panel elements.
|
|
54
|
+
*/
|
|
55
|
+
export type StackPanelProps = {
|
|
56
|
+
"data-stack-panel": string;
|
|
57
|
+
"data-depth": number;
|
|
58
|
+
"data-active": "true" | "false";
|
|
59
|
+
"aria-hidden": boolean;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Props returned by getBackButtonProps for back navigation.
|
|
63
|
+
*/
|
|
64
|
+
export type StackBackButtonProps = {
|
|
65
|
+
onClick: () => void;
|
|
66
|
+
disabled: boolean;
|
|
67
|
+
"aria-label": string;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Options for useStackNavigation hook.
|
|
71
|
+
*/
|
|
72
|
+
export type UseStackNavigationOptions<TId extends string = string> = {
|
|
73
|
+
/** Array of available panels */
|
|
74
|
+
panels: ReadonlyArray<StackPanel<TId>>;
|
|
75
|
+
/** Initial panel ID to display. @default first panel */
|
|
76
|
+
initialPanelId?: TId;
|
|
77
|
+
/** Display mode for panels */
|
|
78
|
+
displayMode: StackDisplayMode;
|
|
79
|
+
/** Transition mode for animations. @default "css" */
|
|
80
|
+
transitionMode?: StackTransitionMode;
|
|
81
|
+
/** Callback when panel changes */
|
|
82
|
+
onPanelChange?: (id: TId, depth: number) => void;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Result from useStackNavigation hook.
|
|
86
|
+
*/
|
|
87
|
+
export type UseStackNavigationResult<TId extends string = string> = {
|
|
88
|
+
/** Current navigation state */
|
|
89
|
+
state: StackNavigationState<TId>;
|
|
90
|
+
/**
|
|
91
|
+
* Push a new panel onto the stack.
|
|
92
|
+
* @param id - Panel ID to push
|
|
93
|
+
*/
|
|
94
|
+
push: (id: TId) => void;
|
|
95
|
+
/**
|
|
96
|
+
* Navigate in a direction relative to current depth.
|
|
97
|
+
* @param direction - Number of steps: -1=back, -2=back2, etc.
|
|
98
|
+
*/
|
|
99
|
+
go: (direction: number) => void;
|
|
100
|
+
/**
|
|
101
|
+
* Move to an absolute depth in the stack.
|
|
102
|
+
* @param depth - Target depth (0-indexed)
|
|
103
|
+
*/
|
|
104
|
+
move: (depth: number) => void;
|
|
105
|
+
/**
|
|
106
|
+
* Replace the current panel with a new one.
|
|
107
|
+
* @param id - Panel ID to replace with
|
|
108
|
+
*/
|
|
109
|
+
replace: (id: TId) => void;
|
|
110
|
+
/**
|
|
111
|
+
* Temporarily reveal a parent panel.
|
|
112
|
+
* @param depth - Depth to reveal to (defaults to depth-1)
|
|
113
|
+
*/
|
|
114
|
+
revealParent: (depth?: number) => void;
|
|
115
|
+
/**
|
|
116
|
+
* Reveal the root panel.
|
|
117
|
+
*/
|
|
118
|
+
revealRoot: () => void;
|
|
119
|
+
/**
|
|
120
|
+
* Dismiss the parent reveal and return to current panel.
|
|
121
|
+
*/
|
|
122
|
+
dismissReveal: () => void;
|
|
123
|
+
/**
|
|
124
|
+
* Get props for a panel element.
|
|
125
|
+
* @param id - Panel ID
|
|
126
|
+
*/
|
|
127
|
+
getPanelProps: (id: TId) => StackPanelProps;
|
|
128
|
+
/**
|
|
129
|
+
* Get props for a back button.
|
|
130
|
+
*/
|
|
131
|
+
getBackButtonProps: () => StackBackButtonProps;
|
|
132
|
+
/**
|
|
133
|
+
* Check if navigation in a direction is possible.
|
|
134
|
+
* @param direction - Direction to check
|
|
135
|
+
*/
|
|
136
|
+
canGo: (direction: number) => boolean;
|
|
137
|
+
/** Current panel ID (top of stack) */
|
|
138
|
+
currentPanelId: TId;
|
|
139
|
+
/** Previous panel ID (one step back), or null if at root */
|
|
140
|
+
previousPanelId: TId | null;
|
|
141
|
+
/** Outlet component that renders the stack content */
|
|
142
|
+
Outlet: React.FC;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Options for useStackSwipeInput hook.
|
|
146
|
+
*/
|
|
147
|
+
export type UseStackSwipeInputOptions = {
|
|
148
|
+
/** Reference to the swipe container element */
|
|
149
|
+
containerRef: React.RefObject<HTMLElement | null>;
|
|
150
|
+
/** Stack navigation result from useStackNavigation */
|
|
151
|
+
navigation: Pick<UseStackNavigationResult, "go" | "canGo" | "revealParent" | "dismissReveal" | "state">;
|
|
152
|
+
/** Edge to detect swipes from. @default "left" */
|
|
153
|
+
edge?: "left" | "right";
|
|
154
|
+
/** Width of the edge detection zone. @default 20 */
|
|
155
|
+
edgeWidth?: number;
|
|
156
|
+
/** Whether swipe input is enabled. @default true */
|
|
157
|
+
enabled?: boolean;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Result from useStackSwipeInput hook.
|
|
161
|
+
*/
|
|
162
|
+
export type UseStackSwipeInputResult = {
|
|
163
|
+
/** Whether currently swiping from edge */
|
|
164
|
+
isEdgeSwiping: boolean;
|
|
165
|
+
/** Swipe progress (0-1) for animation */
|
|
166
|
+
progress: number;
|
|
167
|
+
/** Full swipe input state for direct DOM manipulation */
|
|
168
|
+
inputState: SwipeInputState;
|
|
169
|
+
/** Props to spread on the container element */
|
|
170
|
+
containerProps: React.HTMLAttributes<HTMLElement> & {
|
|
171
|
+
style: React.CSSProperties;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Props for StackContent component.
|
|
176
|
+
*/
|
|
177
|
+
export type StackContentProps = {
|
|
178
|
+
/** Panel ID */
|
|
179
|
+
id: string;
|
|
180
|
+
/** Panel depth in the stack */
|
|
181
|
+
depth: number;
|
|
182
|
+
/** Whether this panel is currently active (top of stack) */
|
|
183
|
+
isActive: boolean;
|
|
184
|
+
/** Display mode */
|
|
185
|
+
displayMode: StackDisplayMode;
|
|
186
|
+
/** Transition mode */
|
|
187
|
+
transitionMode: StackTransitionMode;
|
|
188
|
+
/** Current navigation state */
|
|
189
|
+
navigationState: StackNavigationState;
|
|
190
|
+
/** Swipe progress for animation (0-1) */
|
|
191
|
+
swipeProgress?: number;
|
|
192
|
+
/** Content to render */
|
|
193
|
+
children: React.ReactNode;
|
|
194
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type PanelAnimationPhase = "entering" | "active" | "exiting";
|
|
2
|
+
export type AnimatedPanel = {
|
|
3
|
+
id: string;
|
|
4
|
+
depth: number;
|
|
5
|
+
phase: PanelAnimationPhase;
|
|
6
|
+
};
|
|
7
|
+
export type UseStackAnimationStateOptions = {
|
|
8
|
+
/** Current stack from navigation */
|
|
9
|
+
stack: ReadonlyArray<string>;
|
|
10
|
+
/** Called when an exiting panel's animation completes */
|
|
11
|
+
onExitComplete?: (id: string) => void;
|
|
12
|
+
};
|
|
13
|
+
export type UseStackAnimationStateResult = {
|
|
14
|
+
/** All panels to render (active + exiting) */
|
|
15
|
+
panels: ReadonlyArray<AnimatedPanel>;
|
|
16
|
+
/** Mark a panel's enter animation as complete */
|
|
17
|
+
markEnterComplete: (id: string) => void;
|
|
18
|
+
/** Mark a panel's exit animation as complete */
|
|
19
|
+
markExitComplete: (id: string) => void;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Computes animated panels from current and previous stack.
|
|
23
|
+
* Pure function for easy testing.
|
|
24
|
+
*/
|
|
25
|
+
export declare function computeAnimatedPanels(prevPanels: ReadonlyArray<AnimatedPanel>, prevStack: ReadonlyArray<string>, currentStack: ReadonlyArray<string>): ReadonlyArray<AnimatedPanel>;
|
|
26
|
+
/**
|
|
27
|
+
* Hook for managing stack animation state.
|
|
28
|
+
*
|
|
29
|
+
* Uses a ref-based approach to compute panels synchronously during render,
|
|
30
|
+
* avoiding the flash that would occur with useEffect.
|
|
31
|
+
*/
|
|
32
|
+
export declare function useStackAnimationState(options: UseStackAnimationStateOptions): UseStackAnimationStateResult;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { UseStackNavigationOptions, UseStackNavigationResult } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Headless hook for managing hierarchical stack navigation.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* const { state, push, go, Outlet } = useStackNavigation({
|
|
8
|
+
* panels: [
|
|
9
|
+
* { id: 'list', title: 'Items', content: <ListPage /> },
|
|
10
|
+
* { id: 'detail', title: 'Detail', content: <DetailPage /> },
|
|
11
|
+
* ],
|
|
12
|
+
* displayMode: 'overlay',
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* return (
|
|
16
|
+
* <div>
|
|
17
|
+
* <button onClick={() => push('detail')}>View Detail</button>
|
|
18
|
+
* <Outlet />
|
|
19
|
+
* </div>
|
|
20
|
+
* );
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function useStackNavigation<TId extends string = string>(options: UseStackNavigationOptions<TId>): UseStackNavigationResult<TId>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { UseStackSwipeInputOptions, UseStackSwipeInputResult } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Hook for binding edge swipe input to Stack navigation.
|
|
4
|
+
*
|
|
5
|
+
* Detects swipe gestures from the specified edge and triggers navigation:
|
|
6
|
+
* - Left edge swipe → go(-1) (go back)
|
|
7
|
+
* - Right edge swipe → reveals parent or custom action
|
|
8
|
+
*
|
|
9
|
+
* During a swipe, provides progress for animation.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* const containerRef = useRef<HTMLDivElement>(null);
|
|
14
|
+
* const navigation = useStackNavigation({ panels, displayMode: 'overlay' });
|
|
15
|
+
* const { isEdgeSwiping, progress, containerProps } = useStackSwipeInput({
|
|
16
|
+
* containerRef,
|
|
17
|
+
* navigation,
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* return (
|
|
21
|
+
* <div ref={containerRef} {...containerProps}>
|
|
22
|
+
* <navigation.Outlet />
|
|
23
|
+
* </div>
|
|
24
|
+
* );
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function useStackSwipeInput(options: UseStackSwipeInputOptions): UseStackSwipeInputResult;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Panels entry point - VSCode-like panel system
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*
|
|
5
|
+
* This is a subpath export entry point for `react-panel-layout/panels`.
|
|
6
|
+
*
|
|
7
|
+
* ## Overview
|
|
8
|
+
* Panels provides a VSCode-like panel system with tabbed groups, drag-and-drop
|
|
9
|
+
* tab reordering, split views, and keyboard navigation. Supports both controlled
|
|
10
|
+
* and uncontrolled state management.
|
|
11
|
+
*
|
|
12
|
+
* ## Installation
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { PanelSystem, buildInitialState, usePanelSystem } from "react-panel-layout/panels";
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* ## Basic Usage
|
|
18
|
+
* ```tsx
|
|
19
|
+
* const tabs = [
|
|
20
|
+
* { id: 'file1', title: 'index.ts', render: () => <Editor file="index.ts" /> },
|
|
21
|
+
* { id: 'file2', title: 'app.tsx', render: () => <Editor file="app.tsx" /> },
|
|
22
|
+
* ];
|
|
23
|
+
*
|
|
24
|
+
* function App() {
|
|
25
|
+
* const initialState = buildInitialState(tabs);
|
|
26
|
+
* let groupCounter = 1;
|
|
27
|
+
*
|
|
28
|
+
* return (
|
|
29
|
+
* <PanelSystem
|
|
30
|
+
* initialState={initialState}
|
|
31
|
+
* createGroupId={() => `g_${++groupCounter}`}
|
|
32
|
+
* layoutMode="grid"
|
|
33
|
+
* gridTracksInteractive={true}
|
|
34
|
+
* dragThresholdPx={5}
|
|
35
|
+
* />
|
|
36
|
+
* );
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* ## Controlled State
|
|
41
|
+
* ```tsx
|
|
42
|
+
* const [state, setState] = useState(() => buildInitialState(tabs));
|
|
43
|
+
*
|
|
44
|
+
* <PanelSystem
|
|
45
|
+
* initialState={state}
|
|
46
|
+
* state={state}
|
|
47
|
+
* onStateChange={setState}
|
|
48
|
+
* // ...
|
|
49
|
+
* />
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* ## Using Context
|
|
53
|
+
* ```tsx
|
|
54
|
+
* function TabActions() {
|
|
55
|
+
* const { actions } = usePanelSystem();
|
|
56
|
+
* return <button onClick={() => actions.splitFocused('vertical')}>Split</button>;
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export { PanelSystem } from "../modules/panels/system/PanelSystem.js";
|
|
61
|
+
export { PanelGroupView } from "../components/panels/PanelGroupView.js";
|
|
62
|
+
export { DropSuggestOverlay } from "../components/panels/DropSuggestOverlay.js";
|
|
63
|
+
export { PanelSystemProvider, usePanelSystem, } from "../modules/panels/state/PanelSystemContext.js";
|
|
64
|
+
export { collectGroupsInOrder, splitLeaf, closeLeaf, isGroup, setSplitRatio, createEmptyGroup, addTabToGroup, removeTabFromGroup, moveTab, setActiveTab, reorderTabWithinGroup, addTabToGroupAtIndex, setFocusedGroup, focusGroupIndex, nextGroup, prevGroup, refreshGroupOrder, splitGroup, buildInitialState, } from "../modules/panels/index.js";
|
|
65
|
+
export type { PanelId, GroupId, SplitDirection, TabDefinition, GroupModel, PanelTree, PanelSystemState, DropZone, DraggingTab, PanelCommands, PanelSystemProps, PanelSplitLimits, IdFactory, } from "../modules/panels/index.js";
|
|
66
|
+
export type { PanelSystemContextValue, PanelSystemProviderProps, PanelStateAction, PanelStateActions, } from "../modules/panels/state/PanelSystemContext.js";
|
|
67
|
+
export type { PanelGroupViewProps } from "../components/panels/PanelGroupView.js";
|
package/dist/panels.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./PanelSystem-Bs8bQwQF.cjs");exports.DropSuggestOverlay=e.DropSuggestOverlay;exports.PanelGroupView=e.PanelGroupView;exports.PanelSystem=e.PanelSystem;exports.PanelSystemProvider=e.PanelSystemProvider;exports.addTabToGroup=e.addTabToGroup;exports.addTabToGroupAtIndex=e.addTabToGroupAtIndex;exports.buildInitialState=e.buildInitialState;exports.closeLeaf=e.closeLeaf;exports.collectGroupsInOrder=e.collectGroupsInOrder;exports.createEmptyGroup=e.createEmptyGroup;exports.focusGroupIndex=e.focusGroupIndex;exports.isGroup=e.isGroup;exports.moveTab=e.moveTab;exports.nextGroup=e.nextGroup;exports.prevGroup=e.prevGroup;exports.refreshGroupOrder=e.refreshGroupOrder;exports.removeTabFromGroup=e.removeTabFromGroup;exports.reorderTabWithinGroup=e.reorderTabWithinGroup;exports.setActiveTab=e.setActiveTab;exports.setFocusedGroup=e.setFocusedGroup;exports.setSplitRatio=e.setSplitRatio;exports.splitGroup=e.splitGroup;exports.splitLeaf=e.splitLeaf;exports.usePanelSystem=e.usePanelSystem;
|
|
2
|
+
//# sourceMappingURL=panels.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panels.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/panels.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { D as e, a as r, P as o, b as t, g as p, k as u, v as i, d as l, c as G, f as d, n, i as m, m as b, o as c, p as T, q as v, r as f, j as P, h as S, l as y, e as x, t as I, s as g, u as h } from "./PanelSystem-Dr1TBhxM.js";
|
|
2
|
+
export {
|
|
3
|
+
e as DropSuggestOverlay,
|
|
4
|
+
r as PanelGroupView,
|
|
5
|
+
o as PanelSystem,
|
|
6
|
+
t as PanelSystemProvider,
|
|
7
|
+
p as addTabToGroup,
|
|
8
|
+
u as addTabToGroupAtIndex,
|
|
9
|
+
i as buildInitialState,
|
|
10
|
+
l as closeLeaf,
|
|
11
|
+
G as collectGroupsInOrder,
|
|
12
|
+
d as createEmptyGroup,
|
|
13
|
+
n as focusGroupIndex,
|
|
14
|
+
m as isGroup,
|
|
15
|
+
b as moveTab,
|
|
16
|
+
c as nextGroup,
|
|
17
|
+
T as prevGroup,
|
|
18
|
+
v as refreshGroupOrder,
|
|
19
|
+
f as removeTabFromGroup,
|
|
20
|
+
P as reorderTabWithinGroup,
|
|
21
|
+
S as setActiveTab,
|
|
22
|
+
y as setFocusedGroup,
|
|
23
|
+
x as setSplitRatio,
|
|
24
|
+
I as splitGroup,
|
|
25
|
+
g as splitLeaf,
|
|
26
|
+
h as usePanelSystem
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=panels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panels.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/pivot/index.d.ts
CHANGED
|
@@ -4,5 +4,8 @@
|
|
|
4
4
|
* Import via: import { usePivot } from "react-panel-layout/pivot";
|
|
5
5
|
*/
|
|
6
6
|
export { usePivot } from "../modules/pivot";
|
|
7
|
+
export { SwipePivotTabBar } from "../modules/pivot";
|
|
8
|
+
export { scaleInputState } from "../modules/pivot";
|
|
7
9
|
export type { PivotItem, UsePivotOptions, UsePivotResult, PivotItemProps } from "../modules/pivot";
|
|
10
|
+
export type { SwipePivotTabBarProps, IndicatorRenderProps } from "../modules/pivot";
|
|
8
11
|
export type { PivotBehavior, PivotBehaviorItem } from "../types";
|
package/dist/pivot.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./SwipePivotTabBar-BrQismcZ.cjs"),s=(e,c,l)=>{if(c<=0||l<=0||e.phase==="idle")return e;const o=l/c;return{...e,displacement:{x:e.displacement.x*o,y:e.displacement.y*o},velocity:{x:e.velocity.x*o,y:e.velocity.y*o}}};exports.SwipePivotTabBar=r.SwipePivotTabBar;exports.usePivot=r.usePivot;exports.scaleInputState=s;
|
|
2
2
|
//# sourceMappingURL=pivot.cjs.map
|
package/dist/pivot.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pivot.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"pivot.cjs","sources":["../src/modules/pivot/scaleInputState.ts"],"sourcesContent":["/**\n * @file Utility for scaling SwipeInputState between containers of different sizes.\n *\n * This enables synchronized swipe behavior between containers with different widths,\n * such as a narrow tab bar and a wide content area moving together proportionally.\n */\nimport type { SwipeInputState } from \"../../hooks/gesture/types.js\";\n\n/**\n * Scale SwipeInputState displacement and velocity proportionally for different container sizes.\n *\n * When swiping in a container of one size, this function transforms the input state\n * to appear as if the swipe occurred in a container of a different size.\n * This allows tabs and content to move in sync despite different widths.\n *\n * @param inputState - The original swipe input state\n * @param sourceWidth - Width of the source container (where the swipe originated)\n * @param targetWidth - Width of the target container (where the scaled state will be applied)\n * @returns Scaled SwipeInputState with proportionally adjusted displacement and velocity\n *\n * @example\n * ```tsx\n * // Content area is 400px wide, each tab is 80px wide (5 tabs)\n * const contentWidth = 400;\n * const tabWidth = 80;\n *\n * // Swipe happens on content area\n * const { inputState } = usePivotSwipeInput({ containerRef, pivot, axis: \"horizontal\" });\n *\n * // Scale for tabs: 100px content swipe → 20px tab movement\n * const tabInputState = scaleInputState(inputState, contentWidth, tabWidth);\n *\n * // Apply to tabs and content respectively\n * <SwipePivotContent inputState={tabInputState} containerSize={tabWidth} />\n * <SwipePivotContent inputState={inputState} containerSize={contentWidth} />\n * ```\n */\nexport const scaleInputState = (\n inputState: SwipeInputState,\n sourceWidth: number,\n targetWidth: number,\n): SwipeInputState => {\n // Guard against invalid dimensions\n if (sourceWidth <= 0 || targetWidth <= 0) {\n return inputState;\n }\n\n // Idle state needs no scaling\n if (inputState.phase === \"idle\") {\n return inputState;\n }\n\n const scale = targetWidth / sourceWidth;\n\n return {\n ...inputState,\n displacement: {\n x: inputState.displacement.x * scale,\n y: inputState.displacement.y * scale,\n },\n velocity: {\n x: inputState.velocity.x * scale,\n y: inputState.velocity.y * scale,\n },\n };\n};\n"],"names":["scaleInputState","inputState","sourceWidth","targetWidth","scale"],"mappings":"mIAqCaA,EAAkB,CAC7BC,EACAC,EACAC,IACoB,CAOpB,GALID,GAAe,GAAKC,GAAe,GAKnCF,EAAW,QAAU,OACvB,OAAOA,EAGT,MAAMG,EAAQD,EAAcD,EAE5B,MAAO,CACL,GAAGD,EACH,aAAc,CACZ,EAAGA,EAAW,aAAa,EAAIG,EAC/B,EAAGH,EAAW,aAAa,EAAIG,CAAA,EAEjC,SAAU,CACR,EAAGH,EAAW,SAAS,EAAIG,EAC3B,EAAGH,EAAW,SAAS,EAAIG,CAAA,CAC7B,CAEJ"}
|
package/dist/pivot.js
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
import { u as
|
|
1
|
+
import { S as x, u as v } from "./SwipePivotTabBar-BGO9X94m.js";
|
|
2
|
+
const o = (e, c, l) => {
|
|
3
|
+
if (c <= 0 || l <= 0 || e.phase === "idle")
|
|
4
|
+
return e;
|
|
5
|
+
const s = l / c;
|
|
6
|
+
return {
|
|
7
|
+
...e,
|
|
8
|
+
displacement: {
|
|
9
|
+
x: e.displacement.x * s,
|
|
10
|
+
y: e.displacement.y * s
|
|
11
|
+
},
|
|
12
|
+
velocity: {
|
|
13
|
+
x: e.velocity.x * s,
|
|
14
|
+
y: e.velocity.y * s
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
};
|
|
2
18
|
export {
|
|
3
|
-
|
|
19
|
+
x as SwipePivotTabBar,
|
|
20
|
+
o as scaleInputState,
|
|
21
|
+
v as usePivot
|
|
4
22
|
};
|
|
5
23
|
//# sourceMappingURL=pivot.js.map
|
package/dist/pivot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pivot.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
1
|
+
{"version":3,"file":"pivot.js","sources":["../src/modules/pivot/scaleInputState.ts"],"sourcesContent":["/**\n * @file Utility for scaling SwipeInputState between containers of different sizes.\n *\n * This enables synchronized swipe behavior between containers with different widths,\n * such as a narrow tab bar and a wide content area moving together proportionally.\n */\nimport type { SwipeInputState } from \"../../hooks/gesture/types.js\";\n\n/**\n * Scale SwipeInputState displacement and velocity proportionally for different container sizes.\n *\n * When swiping in a container of one size, this function transforms the input state\n * to appear as if the swipe occurred in a container of a different size.\n * This allows tabs and content to move in sync despite different widths.\n *\n * @param inputState - The original swipe input state\n * @param sourceWidth - Width of the source container (where the swipe originated)\n * @param targetWidth - Width of the target container (where the scaled state will be applied)\n * @returns Scaled SwipeInputState with proportionally adjusted displacement and velocity\n *\n * @example\n * ```tsx\n * // Content area is 400px wide, each tab is 80px wide (5 tabs)\n * const contentWidth = 400;\n * const tabWidth = 80;\n *\n * // Swipe happens on content area\n * const { inputState } = usePivotSwipeInput({ containerRef, pivot, axis: \"horizontal\" });\n *\n * // Scale for tabs: 100px content swipe → 20px tab movement\n * const tabInputState = scaleInputState(inputState, contentWidth, tabWidth);\n *\n * // Apply to tabs and content respectively\n * <SwipePivotContent inputState={tabInputState} containerSize={tabWidth} />\n * <SwipePivotContent inputState={inputState} containerSize={contentWidth} />\n * ```\n */\nexport const scaleInputState = (\n inputState: SwipeInputState,\n sourceWidth: number,\n targetWidth: number,\n): SwipeInputState => {\n // Guard against invalid dimensions\n if (sourceWidth <= 0 || targetWidth <= 0) {\n return inputState;\n }\n\n // Idle state needs no scaling\n if (inputState.phase === \"idle\") {\n return inputState;\n }\n\n const scale = targetWidth / sourceWidth;\n\n return {\n ...inputState,\n displacement: {\n x: inputState.displacement.x * scale,\n y: inputState.displacement.y * scale,\n },\n velocity: {\n x: inputState.velocity.x * scale,\n y: inputState.velocity.y * scale,\n },\n };\n};\n"],"names":["scaleInputState","inputState","sourceWidth","targetWidth","scale"],"mappings":";AAqCO,MAAMA,IAAkB,CAC7BC,GACAC,GACAC,MACoB;AAOpB,MALID,KAAe,KAAKC,KAAe,KAKnCF,EAAW,UAAU;AACvB,WAAOA;AAGT,QAAMG,IAAQD,IAAcD;AAE5B,SAAO;AAAA,IACL,GAAGD;AAAA,IACH,cAAc;AAAA,MACZ,GAAGA,EAAW,aAAa,IAAIG;AAAA,MAC/B,GAAGH,EAAW,aAAa,IAAIG;AAAA,IAAA;AAAA,IAEjC,UAAU;AAAA,MACR,GAAGH,EAAW,SAAS,IAAIG;AAAA,MAC3B,GAAGH,EAAW,SAAS,IAAIG;AAAA,IAAA;AAAA,EAC7B;AAEJ;"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Resizer entry point - Resize handle components and hooks
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*
|
|
5
|
+
* This is a subpath export entry point for `react-panel-layout/resizer`.
|
|
6
|
+
*
|
|
7
|
+
* ## Overview
|
|
8
|
+
* Resizer provides draggable resize handles for creating resizable layouts.
|
|
9
|
+
* Includes both ready-to-use components and a low-level hook for custom implementations.
|
|
10
|
+
*
|
|
11
|
+
* ## Installation
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { ResizeHandle, useResizeDrag } from "react-panel-layout/resizer";
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* ## Basic Usage with ResizeHandle
|
|
17
|
+
* ```tsx
|
|
18
|
+
* function ResizableLayout() {
|
|
19
|
+
* const [width, setWidth] = useState(300);
|
|
20
|
+
*
|
|
21
|
+
* return (
|
|
22
|
+
* <div style={{ display: 'flex' }}>
|
|
23
|
+
* <div style={{ width }}>Left Panel</div>
|
|
24
|
+
* <ResizeHandle
|
|
25
|
+
* direction="vertical"
|
|
26
|
+
* onResize={(delta) => setWidth((w) => w + delta)}
|
|
27
|
+
* />
|
|
28
|
+
* <div style={{ flex: 1 }}>Right Panel</div>
|
|
29
|
+
* </div>
|
|
30
|
+
* );
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* ## Custom Handle with useResizeDrag
|
|
35
|
+
* ```tsx
|
|
36
|
+
* function CustomHandle({ onResize }) {
|
|
37
|
+
* const { ref, isDragging, onPointerDown } = useResizeDrag({
|
|
38
|
+
* axis: 'x',
|
|
39
|
+
* onResize,
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* return (
|
|
43
|
+
* <div
|
|
44
|
+
* ref={ref}
|
|
45
|
+
* onPointerDown={onPointerDown}
|
|
46
|
+
* style={{ cursor: 'col-resize', background: isDragging ? 'blue' : 'gray' }}
|
|
47
|
+
* />
|
|
48
|
+
* );
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export { useResizeDrag } from "../modules/resizer/useResizeDrag.js";
|
|
53
|
+
export { ResizeHandle } from "../components/resizer/ResizeHandle.js";
|
|
54
|
+
export { HorizontalDivider } from "../components/resizer/HorizontalDivider.js";
|
|
55
|
+
export type { ResizeDragAxis, UseResizeDragOptions, UseResizeDragResult, } from "../modules/resizer/useResizeDrag.js";
|
|
56
|
+
export type { ResizeHandleProps } from "../components/resizer/ResizeHandle.js";
|
|
57
|
+
export type { HorizontalDividerProps } from "../components/resizer/HorizontalDivider.js";
|
package/dist/resizer.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./ResizeHandle-CScipO5l.cjs"),i=require("./HorizontalDivider-B5Z-KZLk.cjs");exports.ResizeHandle=e.ResizeHandle;exports.useResizeDrag=e.useResizeDrag;exports.HorizontalDivider=i.HorizontalDivider;
|
|
2
|
+
//# sourceMappingURL=resizer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resizer.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/resizer.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resizer.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Stack entry point - Hierarchical navigation with swipe support
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*
|
|
5
|
+
* This is a subpath export entry point for `react-panel-layout/stack`.
|
|
6
|
+
*
|
|
7
|
+
* ## Overview
|
|
8
|
+
* Stack provides iOS/iPadOS-style hierarchical navigation where panels stack
|
|
9
|
+
* as users drill down into content. Supports swipe-to-go-back gestures.
|
|
10
|
+
*
|
|
11
|
+
* ## Installation
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { useStackNavigation, SwipeStackOutlet } from "react-panel-layout/stack";
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* ## Basic Usage
|
|
17
|
+
* ```tsx
|
|
18
|
+
* const panels = [
|
|
19
|
+
* { id: 'list', title: 'Items', content: <ListPage /> },
|
|
20
|
+
* { id: 'detail', title: 'Detail', content: <DetailPage /> },
|
|
21
|
+
* ];
|
|
22
|
+
*
|
|
23
|
+
* function App() {
|
|
24
|
+
* const { push, go, Outlet } = useStackNavigation({
|
|
25
|
+
* panels,
|
|
26
|
+
* displayMode: 'overlay',
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* return (
|
|
30
|
+
* <div>
|
|
31
|
+
* <button onClick={() => push('detail')}>View Detail</button>
|
|
32
|
+
* <button onClick={() => go(-1)}>Back</button>
|
|
33
|
+
* <Outlet />
|
|
34
|
+
* </div>
|
|
35
|
+
* );
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* ## With Swipe Gestures (SwipeStackContent)
|
|
40
|
+
* ```tsx
|
|
41
|
+
* const containerRef = useRef<HTMLDivElement>(null);
|
|
42
|
+
* const navigation = useStackNavigation({ panels, displayMode: 'overlay' });
|
|
43
|
+
* const swipeInput = useStackSwipeInput({ containerRef, navigation });
|
|
44
|
+
* const { rect } = useResizeObserver(containerRef);
|
|
45
|
+
*
|
|
46
|
+
* return (
|
|
47
|
+
* <div ref={containerRef} {...swipeInput.containerProps}>
|
|
48
|
+
* {panels.map((panel, index) => (
|
|
49
|
+
* <SwipeStackContent
|
|
50
|
+
* key={panel.id}
|
|
51
|
+
* id={panel.id}
|
|
52
|
+
* depth={index}
|
|
53
|
+
* navigationDepth={navigation.state.depth}
|
|
54
|
+
* isActive={navigation.currentPanelId === panel.id}
|
|
55
|
+
* inputState={swipeInput.inputState}
|
|
56
|
+
* containerSize={rect?.width ?? 0}
|
|
57
|
+
* >
|
|
58
|
+
* {panel.content}
|
|
59
|
+
* </SwipeStackContent>
|
|
60
|
+
* ))}
|
|
61
|
+
* </div>
|
|
62
|
+
* );
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export { useStackNavigation } from "../modules/stack/useStackNavigation.js";
|
|
66
|
+
export { useStackSwipeInput } from "../modules/stack/useStackSwipeInput.js";
|
|
67
|
+
export { StackContent } from "../modules/stack/StackContent.js";
|
|
68
|
+
export { SwipeStackContent } from "../modules/stack/SwipeStackContent.js";
|
|
69
|
+
export { SwipeStackOutlet } from "../modules/stack/SwipeStackOutlet.js";
|
|
70
|
+
export type { StackDisplayMode, StackTransitionMode, StackPanel, StackNavigationState, StackPanelProps, StackBackButtonProps, UseStackNavigationOptions, UseStackNavigationResult, UseStackSwipeInputOptions, UseStackSwipeInputResult, StackContentProps, } from "../modules/stack/types.js";
|
|
71
|
+
export type { SwipeStackContentProps } from "../modules/stack/SwipeStackContent.js";
|
|
72
|
+
export type { SwipeStackOutletProps } from "../modules/stack/SwipeStackOutlet.js";
|
package/dist/stack.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("react/jsx-runtime"),ee=require("react"),B=require("./styles-qf6ptVLD.cjs"),te=require("./useIsomorphicLayoutEffect-DGRNF4Lf.cjs"),ne=require("./useContentCache-DqXtLrLs.cjs"),re=require("./useDocumentPointerEvents-ChqrKXDk.cjs"),U=require("./useEffectEvent-huSsGUnl.cjs");function se(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const n=se(ee);function oe(r){const{wasActive:e,isActive:t,transitionMode:s}=r;return s!=="css"||e===t?null:t?"push":"pop"}function ce(r){const{displayMode:e,depth:t,navigationDepth:s,isActive:a,isAnimatingOut:c,isRevealing:u,revealDepth:i}=r;return e==="overlay"?a||c||u&&t===i?"visible":"hidden":t<=s||c?"visible":"hidden"}function ie(r){const{depth:e,activeDepth:t,displayMode:s,isRevealing:a,revealDepth:c}=r,u=e===t,i=e<t;if(a&&u&&c!==null)return`translateX(${.3*100}%)`;if(u)return"translateX(0)";if(i)switch(s){case"overlay":return"translateX(0)";case"slide":return"translateX(-30%)";case"stack":{const f=(t-e)*-5,p=1-(t-e)*.05;return`translateX(${f}%) scale(${p})`}}return"translateX(100%)"}function ae(r,e,t){return e===void 0||e<=0||!t?r:`translateX(${e*100}%)`}function ue(r){if(r==="css")return`transform ${B.STACK_TRANSITION_DURATION} ${B.STACK_TRANSITION_EASING}`}function le(r){const{depth:e,isActive:t,wasActive:s,currentAnimationType:a,displayMode:c,transitionMode:u,navigationState:i,swipeProgress:f}=r,o=oe({wasActive:s,isActive:t,transitionMode:u})??a,d=o==="pop",h=ce({displayMode:c,depth:e,navigationDepth:i.depth,isActive:t,isAnimatingOut:d,isRevealing:i.isRevealing,revealDepth:i.revealDepth}),g=ie({depth:e,activeDepth:i.depth,displayMode:c,isRevealing:i.isRevealing,revealDepth:i.revealDepth}),S=ae(g,f,t),v=(()=>{if(u==="css"){if(o==="push")return B.STACK_ANIMATION_PUSH;if(o==="pop")return B.STACK_ANIMATION_POP}})(),m=ue(u);return{nextAnimationType:o,visibility:h,transform:S,animation:v,transition:m,zIndex:e,pointerEvents:t?"auto":"none"}}const fe={position:"absolute",inset:0,width:"100%",height:"100%"},z=n.memo(({id:r,depth:e,isActive:t,displayMode:s,transitionMode:a,navigationState:c,swipeProgress:u,children:i})=>{const f=n.useRef(null),p=n.useRef(t),[o,d]=n.useState(null),h=le({depth:e,isActive:t,wasActive:p.current,currentAnimationType:o,displayMode:s,transitionMode:a,navigationState:c,swipeProgress:u});te.useIsomorphicLayoutEffect(()=>{const m=p.current;p.current=t,m!==t&&d(h.nextAnimationType)},[t,h.nextAnimationType]);const g=n.useCallback(m=>{m.target===m.currentTarget&&d(null)},[]),S=n.useMemo(()=>{const m={...fe,transform:h.transform,pointerEvents:h.pointerEvents,zIndex:h.zIndex,visibility:h.visibility};return h.animation!==void 0&&(m.animation=h.animation),h.transition!==void 0&&(m.transition=h.transition),m},[h.transform,h.pointerEvents,h.zIndex,h.visibility,h.animation,h.transition]),v=L.jsx("div",{ref:f,"data-stack-content":r,"data-depth":e,"data-active":t?"true":"false",style:S,onAnimationEnd:g,children:i});return a==="none"?L.jsx(n.Activity,{mode:t?"visible":"hidden",children:v}):v}),V=n.createContext(null),de=n.memo(()=>{const r=n.useContext(V);if(!r)throw new Error("StackOutlet must be used within useStackNavigation");const[,e]=n.useReducer(i=>i+1,0);n.useEffect(()=>r.subscribe(e),[r]);const{panels:t,navigationState:s,displayMode:a,transitionMode:c}=r.getState(),u=n.useMemo(()=>s.stack.map((i,f)=>{const p=t.find(o=>o.id===i);return p?{panel:p,depth:f}:null}).filter(i=>i!==null),[s.stack,t]);return L.jsx(L.Fragment,{children:u.map(({panel:i,depth:f})=>L.jsx(z,{id:i.id,depth:f,isActive:f===s.depth,displayMode:a,transitionMode:c,navigationState:s,children:i.cache?r.getCachedContent(i.id):i.content},i.id))})});function pe(r){const{panels:e,initialPanelId:t,displayMode:s,transitionMode:a="css",onPanelChange:c}=r,[u,i]=n.useState(()=>{const l=t??e[0]?.id;if(!l)throw new Error("useStackNavigation: No panels provided");return[l]}),[f,p]=n.useState({isRevealing:!1,revealDepth:null}),o=u.length-1,d=n.useMemo(()=>({stack:u,depth:o,isRevealing:f.isRevealing,revealDepth:f.revealDepth}),[u,o,f.isRevealing,f.revealDepth]),h=u[o],g=o>0?u[o-1]:null,S=n.useCallback(l=>{e.find(R=>R.id===l)&&(i(R=>[...R,l]),c?.(l,o+1))},[e,o,c]),v=n.useCallback(l=>{if(l>=0)return;const y=o+l;if(y<0)return;i(F=>F.slice(0,y+1));const R=u[y];c?.(R,y)},[o,u,c]),m=n.useCallback(l=>{if(l<0||l>=u.length)return;i(R=>R.slice(0,l+1));const y=u[l];c?.(y,l)},[u,c]),w=n.useCallback(l=>{e.find(R=>R.id===l)&&(i(R=>[...R.slice(0,-1),l]),c?.(l,o))},[e,o,c]),E=n.useCallback(l=>l>=0?!1:o+l>=0,[o]),k=n.useCallback(l=>{const y=l??o-1;y<0||y>=o||p({isRevealing:!0,revealDepth:y})},[o]),A=n.useCallback(()=>{o!==0&&p({isRevealing:!0,revealDepth:0})},[o]),P=n.useCallback(()=>{p({isRevealing:!1,revealDepth:null})},[]),D=n.useCallback(l=>{const y=u.indexOf(l),R=y===o;return{"data-stack-panel":l,"data-depth":y,"data-active":R?"true":"false","aria-hidden":!R}},[u,o]),M=n.useCallback(()=>{const l=o>0,y=g?e.find(F=>F.id===g):null,R=y?.title?`Back to ${y.title}`:"Go back";return{onClick:()=>v(-1),disabled:!l,"aria-label":R}},[o,g,e,v]),I=n.useMemo(()=>({position:"relative",width:"100%",height:"100%",overflow:"hidden"}),[]),C=n.useRef({panels:e,navigationState:d,displayMode:s,transitionMode:a});C.current={panels:e,navigationState:d,displayMode:s,transitionMode:a};const O=n.useRef(new Set);n.useEffect(()=>{O.current.forEach(l=>l())},[d,s,a]);const _=n.useCallback(l=>C.current.panels.find(R=>R.id===l)?.content??null,[]),N=n.useMemo(()=>e.map(l=>l.id),[e]),{getCachedContent:b}=ne.useContentCache({resolveContent:_,validIds:N}),x=n.useMemo(()=>({getState:()=>C.current,subscribe:l=>(O.current.add(l),()=>O.current.delete(l)),getCachedContent:b}),[b]),T=n.useMemo(()=>{const l=()=>L.jsx(V.Provider,{value:x,children:L.jsx("div",{style:I,"data-stack-container":!0,children:L.jsx(de,{})})});return l.displayName="StackOutlet",l},[x,I]);return{state:d,push:S,go:v,move:m,replace:w,revealParent:k,revealRoot:A,dismissReveal:P,getPanelProps:D,getBackButtonProps:M,canGo:E,currentPanelId:h,previousPanelId:g,Outlet:T}}const j={isDown:!1,start:null,current:null,pointerId:null,wasCanceled:!1},G=(r,e)=>({x:r,y:e,timestamp:performance.now()});function he(r){const{enabled:e,primaryOnly:t=!0}=r,[s,a]=n.useState(j),c=n.useCallback(()=>{a(j)},[]),u=U.useEffectEvent(d=>{if(!e||t&&!d.isPrimary||d.pointerType==="mouse"&&d.button!==0)return;const h=G(d.clientX,d.clientY);a({isDown:!0,start:h,current:h,pointerId:d.pointerId,wasCanceled:!1})}),i=U.useEffectEvent(d=>{if(s.pointerId!==d.pointerId)return;const h=G(d.clientX,d.clientY);a(g=>({...g,current:h}))}),f=U.useEffectEvent(()=>{a(j)}),p=U.useEffectEvent(()=>{a({...j,wasCanceled:!0})}),o=s.isDown?e:!1;return re.useDocumentPointerEvents(o,{onMove:i,onUp:f,onCancel:p}),n.useEffect(()=>{!e&&s.isDown&&c()},[e,s.isDown,c]),{state:s,onPointerDown:u,reset:c}}const me=10,ve=(r,e)=>{const t=Math.abs(r),s=Math.abs(e);return t===0&&s===0?null:t>s*1.5?"horizontal":s>t*1.5?"vertical":null};function ge(r){const{tracking:e,lockThreshold:t=me}=r,[s,a]=n.useState(null),c=n.useCallback(()=>{a(null)},[]);return n.useEffect(()=>{if(!e.isDown){s!==null&&c();return}if(s!==null||!e.start||!e.current)return;const u=e.current.x-e.start.x,i=e.current.y-e.start.y;if(Math.max(Math.abs(u),Math.abs(i))<t)return;const p=ve(u,i);p!==null&&a(p)},[e.isDown,e.start,e.current,s,t,c]),{lockedAxis:s,isLocked:s!==null,reset:c}}const H=(r,e,t)=>{const s=t-e;return s<=0?0:r/s},W=r=>r>0?1:r<0?-1:0,Ee=(...r)=>{const e={},t=[];for(const a of r)Object.assign(e,a.style),a.onPointerDown&&t.push(a.onPointerDown);return{onPointerDown:a=>{for(const c of t)c?.(a)},style:e}},Y={distanceThreshold:100,velocityThreshold:.5,lockThreshold:10},K=20,$={phase:"idle",displacement:{x:0,y:0},velocity:{x:0,y:0},direction:0},be=150,q=(r,e,t,s,a)=>{const c=t==="horizontal"?r.x:r.y,u=t==="horizontal"?e.x:e.y,i=Math.abs(c),f=Math.abs(u);if(i>=s.distanceThreshold||f>=s.velocityThreshold){const o=W(c);a?.({phase:"ended",displacement:r,velocity:e,direction:o})}};function ye(r){const{containerRef:e,axis:t,enabled:s=!0,thresholds:a,onSwipeEnd:c,enableWheel:u=!0,pointerStartFilter:i}=r,f={...Y,...a},p=U.useEffectEvent(c),{state:o,onPointerDown:d}=he({enabled:s}),h=n.useCallback(b=>{if(s){if(i){const x=e.current;if(!x||!i(b,x))return}d(b)}},[s,i,e,d]),{lockedAxis:g,isLocked:S}=ge({tracking:o,lockThreshold:f.lockThreshold}),v=n.useRef(null),m=n.useRef(!1);n.useEffect(()=>{m.current=S?g===t:!1},[S,g,t]),n.useEffect(()=>{const b=e.current;if(!b||!s)return;const x=y=>{y.preventDefault()},T=y=>{m.current&&y.preventDefault(),document.addEventListener("touchmove",x,{passive:!1})},l=()=>{document.removeEventListener("touchmove",x)};return document.addEventListener("touchend",l),document.addEventListener("touchcancel",l),b.addEventListener("touchstart",T,{passive:!1}),()=>{b.removeEventListener("touchstart",T),document.removeEventListener("touchend",l),document.removeEventListener("touchcancel",l)}},[e,s]);const[w,E]=n.useState($),k=n.useRef({x:0,y:0}),A=n.useRef(null),P=n.useRef(!1),D=n.useRef(null),M=n.useCallback(()=>{k.current={x:0,y:0},P.current=!1,D.current=null,E($)},[]),I=n.useCallback(()=>{const b={...k.current};q(b,{x:0,y:0},t,f,p),M()},[t,f,p,M]),C=U.useEffectEvent(b=>{if(!s||!u||o.isDown)return;const{deltaX:x,deltaY:T}=b;if(!P.current){const R=Math.abs(x),F=Math.abs(T);(R>=f.lockThreshold||F>=f.lockThreshold)&&(P.current=!0,D.current=R>F?"horizontal":"vertical")}if(P.current&&D.current!==t)return;k.current.x-=x,k.current.y-=T;const l=k.current,y=t==="horizontal"?l.x:l.y;E({phase:"swiping",displacement:{...l},velocity:{x:0,y:0},direction:W(y)}),A.current!==null&&clearTimeout(A.current),A.current=setTimeout(I,be)});n.useEffect(()=>{const b=e.current;if(!b||!s||!u)return;const x=T=>{T.preventDefault(),C(T)};return b.addEventListener("wheel",x,{passive:!1}),()=>{b.removeEventListener("wheel",x),A.current!==null&&clearTimeout(A.current)}},[e,s,u,C]),n.useEffect(()=>()=>{A.current!==null&&clearTimeout(A.current)},[]);const O=n.useMemo(()=>{if(!o.isDown||!o.start||!o.current)return $;const b=o.current.x-o.start.x,x=o.current.y-o.start.y,T={x:b,y:x},l={x:H(b,o.start.timestamp,o.current.timestamp),y:H(x,o.start.timestamp,o.current.timestamp)};return!S||g!==t?{phase:"tracking",displacement:T,velocity:l,direction:0}:{phase:"swiping",displacement:T,velocity:l,direction:W(t==="horizontal"?b:x)}},[o.isDown,o.start,o.current,S,g,t]);n.useEffect(()=>{O.phase!=="idle"&&(v.current=O)},[O]),n.useEffect(()=>{if(o.isDown)return;const b=v.current;!b||b.phase!=="swiping"&&b.phase!=="tracking"||(v.current=null,!o.wasCanceled&&q(b.displacement,b.velocity,t,f,p))},[o.isDown,o.wasCanceled,t,f,p]);const _=O.phase!=="idle"?O:w,N=n.useMemo(()=>({onPointerDown:h,style:{touchAction:t==="horizontal"?"pan-y pinch-zoom":"pan-x pinch-zoom",userSelect:"none",WebkitUserSelect:"none"}}),[t,h]);return{state:_,containerProps:N}}const Se=r=>r==="left"||r==="right"?"horizontal":"vertical",we=(r,e,t,s,a)=>{const c=t.getBoundingClientRect();switch(s){case"left":return r>=c.left&&r<=c.left+a;case"right":return r>=c.right-a&&r<=c.right;case"top":return e>=c.top&&e<=c.top+a;case"bottom":return e>=c.bottom-a&&e<=c.bottom}};function Te(r){const{containerRef:e,edge:t,edgeWidth:s=K,enabled:a=!0,thresholds:c,onSwipeEnd:u}=r,i={...Y,...c},f=Se(t),[p,o]=n.useState(!1),d=n.useCallback((v,m)=>{const w=we(v.clientX,v.clientY,m,t,s);return o(w),w},[t,s]),{state:h,containerProps:g}=ye({containerRef:e,axis:f,enabled:a,thresholds:i,onSwipeEnd:u,enableWheel:!1,pointerStartFilter:d});return n.useEffect(()=>{h.phase==="idle"&&o(!1)},[h.phase]),{isEdgeGesture:p,state:p?h:$,containerProps:g}}const ke=(r,e,t)=>{const s=e.getBoundingClientRect();return r>=s.left&&r<=s.left+t};function xe(r){const{containerRef:e,active:t,preventEdgeBack:s=!0,preventOverscroll:a=!0,edgeWidth:c=K}=r,u=n.useRef(null),i=n.useCallback(()=>{if(!a)return;const o=document.documentElement;u.current===null&&(u.current=o.style.overscrollBehavior),o.style.overscrollBehavior="none"},[a]);n.useEffect(()=>{t||!a||u.current!==null&&(document.documentElement.style.overscrollBehavior=u.current,u.current=null)},[t,a]),n.useEffect(()=>()=>{u.current!==null&&(document.documentElement.style.overscrollBehavior=u.current,u.current=null)},[]);const f=n.useCallback(o=>{if(!s)return;const d=e.current;d&&o.pointerType==="touch"&&ke(o.clientX,d,c)&&(i(),o.preventDefault())},[s,e,c,i]);return{containerProps:n.useMemo(()=>({onPointerDown:s?f:void 0,style:{overscrollBehavior:a?"contain":void 0,WebkitOverflowScrolling:"touch"}}),[a,s,f])}}function Re(r){const{containerRef:e,navigation:t,edge:s="left",edgeWidth:a=20,enabled:c=!0}=r,[u,i]=n.useState(null),f=n.useCallback(m=>{i(null),s==="left"&&m.direction===1&&t.canGo(-1)&&t.go(-1)},[s,t]),{isEdgeGesture:p,state:o,containerProps:d}=Te({containerRef:e,edge:s,edgeWidth:a,enabled:c&&t.canGo(-1),onSwipeEnd:f});n.useEffect(()=>{p&&(o.phase==="swiping"||o.phase==="tracking")?i(o):o.phase==="idle"&&i(null)},[p,o]);const{containerProps:h}=xe({containerRef:e,active:p,preventEdgeBack:!0,preventOverscroll:!0,edgeWidth:a}),g=n.useMemo(()=>{if(!u||!e.current)return 0;const m=e.current.clientWidth;if(m===0)return 0;const w=u.displacement.x;if(s==="left"&&w<=0||s==="right"&&w>=0)return 0;const E=Math.abs(w);return Math.min(E/m,1)},[u,e,s]),S=n.useMemo(()=>Ee(d,h),[d,h]);return{isEdgeSwiping:p,progress:g,inputState:p?o:$,containerProps:S}}const Z={easeOutExpo:r=>r===1?1:1-Math.pow(2,-10*r)},Ae=300;function De(r){const{duration:e=Ae,easing:t=Z.easeOutExpo,onFrame:s,onComplete:a}=r,[c,u]=n.useState(!1),i=n.useRef(null),f=n.useRef(null),p=n.useRef(s),o=n.useRef(a);n.useEffect(()=>{p.current=s,o.current=a},[s,a]);const d=n.useCallback(()=>{i.current!==null&&(cancelAnimationFrame(i.current),i.current=null),f.current=null,u(!1)},[]),h=n.useCallback(()=>{d(),u(!0),f.current=null;const g=S=>{f.current===null&&(f.current=S);const v=S-f.current,m=Math.min(v/e,1),w=t(m),E=m>=1,k={progress:m,easedProgress:w,elapsed:v,isComplete:E};p.current?.(k),E?(i.current=null,f.current=null,u(!1),o.current?.()):i.current=requestAnimationFrame(g)};i.current=requestAnimationFrame(g)},[e,t,d]);return n.useEffect(()=>()=>{i.current!==null&&cancelAnimationFrame(i.current)},[]),{isAnimating:c,start:h,cancel:d}}function Ce(r,e,t){return r+(e-r)*t}const Pe=300,X=r=>r==="horizontal"?"translateX":"translateY";function Ie(r){const{elementRef:e,targetPx:t,displacement:s,isSwiping:a,axis:c="horizontal",animationDuration:u=Pe,containerSize:i,animateOnTargetChange:f=!1,initialPx:p}=r,o=p??t,d=n.useRef(o),h=n.useRef(null),g=n.useRef(t),S=n.useRef(i),v=n.useRef(null),m=n.useRef(!0);m.current&&p!==void 0&&p!==t?(v.current={from:p,to:t},m.current=!1):m.current&&(m.current=!1),t!==g.current&&!a&&h.current===null&&(f&&Math.abs(d.current-t)>1?v.current={from:d.current,to:t}:d.current=t,g.current=t),i!==void 0&&i!==S.current&&i>0&&(d.current=t,S.current=i);const w=n.useCallback(({easedProgress:D})=>{const M=e.current,I=h.current;if(!M||!I)return;const C=Ce(I.from,I.to,D);d.current=C,M.style.transform=`${X(c)}(${C}px)`},[c,e]),E=n.useCallback(()=>{h.current=null,d.current=t,g.current=t},[t]),{isAnimating:k,start:A,cancel:P}=De({duration:u,easing:Z.easeOutExpo,onFrame:w,onComplete:E});return n.useLayoutEffect(()=>{if(a){P(),h.current=null,v.current=null;return}if(v.current){const I=v.current;h.current=I,v.current=null;const C=e.current;C&&(C.style.transform=`${X(c)}(${I.from}px)`),A();return}const D=d.current;Math.abs(D-t)>1?(h.current={from:D,to:t},A()):(d.current=t,g.current=t)},[a,t,A,P]),n.useLayoutEffect(()=>{const D=e.current;if(!D||k||h.current!==null||v.current!==null)return;const M=t+s;d.current=M,D.style.transform=`${X(c)}(${M}px)`},[t,s,c,k,e]),{isAnimating:k,currentPx:d.current,animationDirection:h.current}}const J=-.3;function Me(r){return Math.max(0,r)}function Oe(r,e,t=J){if(e<=0)return 0;const s=Math.max(0,r),a=Math.min(s/e,1),c=t*e,u=Math.abs(t)*a*e;return c+u}function Le(r){const{depth:e,navigationDepth:t,isActive:s,isSwiping:a,isAnimating:c}=r;return!!(s||e===t-1&&(a||c))}function _e(r,e){return r===e?"active":r===e-1?"behind":"hidden"}const Ne=300,Fe=.05,Ue=.1,$e={position:"absolute",inset:0,width:"100%",height:"100%"},je=(r,e)=>r.phase==="idle"?0:e==="horizontal"?r.displacement.x:r.displacement.y,Be="-5px 0 15px rgba(0, 0, 0, 0.1)",Q=n.memo(({id:r,depth:e,navigationDepth:t,isActive:s,inputState:a,containerSize:c,axis:u="horizontal",behindOffset:i=J,animationDuration:f=Ne,animateOnMount:p=!1,showShadow:o=!0,displayMode:d="overlay",showDimming:h=!0,children:g})=>{const S=n.useRef(null),v=n.useRef(!0),m=je(a,u),w=a.phase==="swiping"||a.phase==="tracking",E=_e(e,t),k=v.current;v.current&&(v.current=!1);const A=n.useMemo(()=>{switch(E){case"active":return 0;case"behind":return i*c;case"hidden":return c}},[E,i,c]),P=n.useMemo(()=>{if(m<=0)return 0;switch(E){case"active":return Me(m);case"behind":{const T=Oe(m,c,i),l=i*c;return T-l}case"hidden":return 0}},[E,m,c,i]),D=n.useMemo(()=>{if(!(!k||!p)&&E==="active"&&e>0)return c},[k,p,E,e,c]),{isAnimating:M}=Ie({elementRef:S,targetPx:A,displacement:P,isSwiping:w,axis:u,animationDuration:f,containerSize:c,animateOnTargetChange:!0,initialPx:D}),I=Le({depth:e,navigationDepth:t,isActive:s,isSwiping:w,isAnimating:M}),C=n.useMemo(()=>c<=0||m<=0?0:Math.min(m/c,1),[m,c]),O=n.useMemo(()=>{if(d!=="stack")return 1;const T=t-e;if(E==="active")return 1;if(E==="behind"){const l=1-T*Fe;return l+C*(1-l)}return 1},[d,E,e,t,C]),_=n.useMemo(()=>!h||E!=="behind"?0:Ue*(1-C),[h,E,C]);n.useLayoutEffect(()=>{const T=S.current;T&&(T.style.visibility=I?"visible":"hidden")},[I]),n.useLayoutEffect(()=>{const T=S.current;if(!T||d!=="stack")return;const l=T.style.transform;if(l.includes("translateX")){const y=l.match(/translateX\([^)]+\)/);y&&(T.style.transform=`${y[0]} scale(${O})`)}else T.style.transform=`scale(${O})`},[O,d]);const N=o&&e>0&&E==="active",b=n.useMemo(()=>({...$e,pointerEvents:s?"auto":"none",willChange:"transform",zIndex:e,visibility:I?"visible":"hidden",boxShadow:N?Be:void 0}),[s,e,I,N]),x=n.useMemo(()=>_<=0?null:{position:"absolute",inset:0,backgroundColor:`rgba(0, 0, 0, ${_})`,pointerEvents:"none",zIndex:1},[_]);return L.jsxs("div",{ref:S,"data-stack-content":r,"data-depth":e,"data-active":s?"true":"false","data-role":E,style:b,children:[g,x!=null&&L.jsx("div",{style:x,"data-dimming-overlay":!0})]})}),Xe=300;function We(r,e,t){const{stack:s,depth:a}=e,c=[a];a>0&&c.push(a-1);const u=[];for(const i of c){const f=s[i],p=r.find(o=>o.id===f);p&&u.push({panel:p,depth:i,isExiting:!1})}if(t!=null&&!u.some(f=>f.panel.id===t)){const f=r.find(p=>p.id===t);f&&u.push({panel:f,depth:a+1,isExiting:!0})}return u.sort((i,f)=>i.depth-f.depth)}const Ge=n.memo(({panels:r,navigationState:e,inputState:t,containerSize:s,getCachedContent:a,behindOffset:c,animateOnMount:u=!1,animationDuration:i=Xe,showShadow:f,displayMode:p,showDimming:o})=>{const[d,h]=n.useState(null),g=n.useRef(e.depth),S=n.useRef(e.stack);n.useLayoutEffect(()=>{const w=g.current,E=S.current,{depth:k,stack:A}=e;if(g.current=k,S.current=A,k<w){const P=E[w];if(P!=null){h(P);const D=setTimeout(()=>{h(null)},i);return()=>clearTimeout(D)}}},[e.depth,e.stack,i]);const v=n.useMemo(()=>We(r,e,d),[r,e,d]),m=n.useMemo(()=>({position:"relative",width:"100%",height:"100%",overflow:"hidden"}),[]);return L.jsx("div",{style:m,"data-swipe-stack-container":!0,children:v.map(({panel:w,depth:E,isExiting:k})=>{const A=E===e.depth&&!k,P=a?.(w.id)??w.content;return L.jsx(Q,{id:w.id,depth:E,navigationDepth:e.depth,isActive:A,inputState:t,containerSize:s,behindOffset:c,animateOnMount:u,animationDuration:i,showShadow:f,displayMode:p,showDimming:o,children:P},w.id)})})});exports.StackContent=z;exports.SwipeStackContent=Q;exports.SwipeStackOutlet=Ge;exports.useStackNavigation=pe;exports.useStackSwipeInput=Re;
|
|
2
|
+
//# sourceMappingURL=stack.cjs.map
|