react-zeugma 1.3.1 → 1.4.1

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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import React$1, { ReactNode } from 'react';
1
+ import React, { ReactNode } from 'react';
2
2
 
3
3
  type SplitDirection = 'row' | 'column';
4
4
  interface SplitNode {
@@ -23,13 +23,6 @@ interface ZeugmaClassNames {
23
23
  resizer?: string;
24
24
  dismissPreview?: string;
25
25
  }
26
- interface ResizerRenderProps {
27
- direction: SplitDirection;
28
- splitPercentage: number;
29
- resizerSize: number;
30
- isResizing: boolean;
31
- onPointerDown: (e: React.PointerEvent<HTMLDivElement>) => void;
32
- }
33
26
  /**
34
27
  * State context — holds reactive values that change during runtime.
35
28
  * All consumers of this context will re-render when any of these values change.
@@ -49,7 +42,6 @@ interface DashboardStateValue {
49
42
  onResizeStart?: (currentNode: SplitNode) => void;
50
43
  onResize?: (currentNode: SplitNode, percentage: number) => void;
51
44
  onResizeEnd?: (currentNode: SplitNode, percentage: number) => void;
52
- renderResizer?: (props: ResizerRenderProps) => ReactNode;
53
45
  minSplitPercentage?: number;
54
46
  maxSplitPercentage?: number;
55
47
  }
@@ -91,7 +83,6 @@ interface DashboardProviderProps {
91
83
  onResizeStart?: (currentNode: SplitNode) => void;
92
84
  onResize?: (currentNode: SplitNode, percentage: number) => void;
93
85
  onResizeEnd?: (currentNode: SplitNode, percentage: number) => void;
94
- renderResizer?: (props: ResizerRenderProps) => ReactNode;
95
86
  minSplitPercentage?: number;
96
87
  maxSplitPercentage?: number;
97
88
  enableDragToDismiss?: boolean;
@@ -99,10 +90,10 @@ interface DashboardProviderProps {
99
90
  onDismissIntentChange?: (paneId: string | null) => void;
100
91
  children: ReactNode;
101
92
  }
102
- declare const DashboardProvider: React$1.FC<DashboardProviderProps>;
93
+ declare const DashboardProvider: React.FC<DashboardProviderProps>;
103
94
 
104
95
  interface UseResizerProps {
105
- containerRef: React$1.RefObject<HTMLDivElement | null>;
96
+ containerRef: React.RefObject<HTMLDivElement | null>;
106
97
  isRow: boolean;
107
98
  direction: SplitDirection;
108
99
  splitPercentage: number;
@@ -114,7 +105,7 @@ interface UseResizerProps {
114
105
  onResizeStart?: () => void;
115
106
  onResizeEnd?: () => void;
116
107
  }
117
- declare function useResizer({ containerRef, isRow, direction, splitPercentage, resizerSize, snapThreshold, layout, currentNode, onLayoutChange, onResizeStart: localOnResizeStart, onResizeEnd: localOnResizeEnd, }: UseResizerProps): (e: React$1.PointerEvent<HTMLDivElement>) => void;
108
+ declare function useResizer({ containerRef, isRow, direction, splitPercentage, resizerSize, snapThreshold, layout, currentNode, onLayoutChange, onResizeStart: localOnResizeStart, onResizeEnd: localOnResizeEnd, }: UseResizerProps): (e: React.PointerEvent<HTMLDivElement>) => void;
118
109
 
119
110
  interface PaneTreeProps {
120
111
  tree?: TreeNode | null;
@@ -122,10 +113,33 @@ interface PaneTreeProps {
122
113
  resizerSize?: number;
123
114
  /** Threshold in pixels to snap to adjacent resizer edges (default 8) */
124
115
  snapThreshold?: number;
125
- /** Custom resizer renderer to override context-level renderResizer */
126
- renderResizer?: (props: ResizerRenderProps) => React$1.ReactNode;
127
116
  }
128
- declare const PaneTree: React$1.FC<PaneTreeProps>;
117
+ declare const PaneTree: React.FC<PaneTreeProps>;
118
+
119
+ interface ResizableContainerProps {
120
+ children: React.ReactNode;
121
+ /** Whether the resizable container is active. When false, acts as a normal 100% height container. */
122
+ active?: boolean;
123
+ /** Current height in pixels (controlled mode) or default/initial height */
124
+ height?: number;
125
+ /** Called when the height changes during or after a drag */
126
+ onHeightChange?: (height: number) => void;
127
+ /** Minimum height in pixels (default: 100) */
128
+ minHeight?: number;
129
+ /** Maximum height in pixels (default: Infinity — bounded by parent) */
130
+ maxHeight?: number;
131
+ /** Whether to persist height in localStorage */
132
+ persist?: boolean;
133
+ /** Custom localStorage key to save the height under (default: 'default-pane') */
134
+ localStorageKey?: string;
135
+ /** Height of the resizer handle in pixels (default: 6) */
136
+ resizerHeight?: number;
137
+ /** CSS class applied to the outer container div */
138
+ className?: string;
139
+ /** CSS class applied to the resizer handle */
140
+ resizerClassName?: string;
141
+ }
142
+ declare const ResizableContainer: React.FC<ResizableContainerProps>;
129
143
 
130
144
  interface PaneRenderProps {
131
145
  isDragging: boolean;
@@ -138,17 +152,17 @@ interface PaneRenderProps {
138
152
 
139
153
  interface PaneProps {
140
154
  id: string;
141
- children: (props: PaneRenderProps) => React$1.ReactNode;
142
- style?: React$1.CSSProperties;
155
+ children: (props: PaneRenderProps) => React.ReactNode;
156
+ style?: React.CSSProperties;
143
157
  }
144
- declare const Pane: React$1.FC<PaneProps>;
158
+ declare const Pane: React.FC<PaneProps>;
145
159
 
146
160
  interface DragHandleProps {
147
- children: React$1.ReactNode;
161
+ children: React.ReactNode;
148
162
  className?: string;
149
- style?: React$1.CSSProperties;
163
+ style?: React.CSSProperties;
150
164
  }
151
- declare const DragHandle: React$1.FC<DragHandleProps>;
165
+ declare const DragHandle: React.FC<DragHandleProps>;
152
166
 
153
167
  declare const DEFAULT_SNAP_THRESHOLD = 8;
154
168
  declare const DEFAULT_DRAG_ACTIVATION_DISTANCE = 8;
@@ -187,4 +201,29 @@ declare function findPane(tree: TreeNode | null, paneId: string): PaneNode | nul
187
201
  */
188
202
  declare function updatePaneMetadata(tree: TreeNode | null, paneId: string, updater: (current: Record<string, unknown> | undefined) => Record<string, unknown> | undefined): TreeNode | null;
189
203
 
190
- export { DEFAULT_DRAG_ACTIVATION_DISTANCE, DEFAULT_RESIZER_SIZE, DEFAULT_SNAP_THRESHOLD, type DashboardActionsValue, DashboardProvider, type DashboardStateValue, DragHandle, Pane, type PaneNode, type PaneRenderProps, PaneTree, type ResizerRenderProps, type SplitDirection, type SplitNode, type TreeNode, type ZeugmaClassNames, addPane, findPane, removePane, splitPane, splitRoot, swapPanes, updatePaneMetadata, updateSplitPercentage, useDashboardActions, useDashboardState, useResizer };
204
+ /**
205
+ * Shared drag-session lifecycle utility.
206
+ *
207
+ * Handles the common boilerplate for pointer-based resize operations:
208
+ * - Adds `zeugma-resizing` class to `document.body`
209
+ * - Injects a global `cursor` style so the resize cursor stays active
210
+ * even when the pointer leaves the handle element
211
+ * - Sets `data-resizing` on the resizer element
212
+ * - Attaches `pointermove` / `pointerup` listeners to `document`
213
+ * - Cleans everything up on pointer-up
214
+ *
215
+ * Consumers provide domain-specific `onMove` and `onEnd` callbacks.
216
+ */
217
+ interface DragSessionConfig {
218
+ /** CSS cursor to enforce globally during the drag */
219
+ cursor: 'col-resize' | 'row-resize';
220
+ /** The resizer DOM element (receives `data-resizing` attribute) */
221
+ resizerEl: HTMLElement;
222
+ /** Called on every `pointermove` during the drag */
223
+ onMove: (e: PointerEvent) => void;
224
+ /** Called once on `pointerup` — after cleanup has already run */
225
+ onEnd: () => void;
226
+ }
227
+ declare function createDragSession({ cursor, resizerEl, onMove, onEnd }: DragSessionConfig): void;
228
+
229
+ export { DEFAULT_DRAG_ACTIVATION_DISTANCE, DEFAULT_RESIZER_SIZE, DEFAULT_SNAP_THRESHOLD, type DashboardActionsValue, DashboardProvider, type DashboardStateValue, DragHandle, type DragSessionConfig, Pane, type PaneNode, type PaneRenderProps, PaneTree, ResizableContainer, type ResizableContainerProps, type SplitDirection, type SplitNode, type TreeNode, type ZeugmaClassNames, addPane, createDragSession, findPane, removePane, splitPane, splitRoot, swapPanes, updatePaneMetadata, updateSplitPercentage, useDashboardActions, useDashboardState, useResizer };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import {createContext,useContext,useState,useRef,useCallback,useMemo,useEffect}from'react';import {useSensors,useSensor,DndContext,pointerWithin,useDraggable,PointerSensor,TouchSensor,useDroppable}from'@dnd-kit/core';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var le=createContext(void 0),de=createContext(void 0);var Y=()=>{let e=useContext(le);if(!e)throw new Error("useDashboardState must be used within a DashboardProvider");return e},be=()=>{let e=useContext(de);if(!e)throw new Error("useDashboardActions must be used within a DashboardProvider");return e};function $(e,t){if(e===null)return null;if(e.type==="pane")return e.paneId===t?null:e;let o=$(e.first,t),r=$(e.second,t);return o===null?r:r===null?o:{...e,first:o,second:r}}function ie(e,t,o,r,n){if(e===null)return typeof n=="string"?{type:"pane",paneId:n}:n;if(e.type==="pane"){if(e.paneId===t){let l=typeof n=="string"?{type:"pane",paneId:n}:n,a=r==="left"||r==="top";return {type:"split",direction:o,first:a?l:e,second:a?e:l,splitPercentage:50}}return e}return {...e,first:ie(e.first,t,o,r,n)||e.first,second:ie(e.second,t,o,r,n)||e.second}}function Pe(e,t,o){if(e===null)return null;let r=F(e,t),n=F(e,o);if(!r||!n)return e;function l(a){return a.type==="pane"?a.paneId===t?{...n}:a.paneId===o?{...r}:a:{...a,first:l(a.first),second:l(a.second)}}return l(e)}function $e(e,t){if(e===null)return {type:"pane",paneId:t};function o(r,n){return r.type==="pane"?{type:"split",direction:n==="row"?"column":"row",splitPercentage:50,first:r,second:{type:"pane",paneId:t}}:{...r,second:o(r.second,r.direction)}}return o(e,null)}function G(e,t,o){return e===null?null:e===t?{...e,splitPercentage:o}:e.type==="split"?{...e,first:G(e.first,t,o)||e.first,second:G(e.second,t,o)||e.second}:e}function Ve(e,t,o){let r=F(e,t)??{type:"pane",paneId:t},n=$(e,t);if(n===null)return {...r};let l=o==="left"||o==="right"?"row":"column",a=o==="left"||o==="top",p={...r};return {type:"split",direction:l,first:a?p:n,second:a?n:p,splitPercentage:50}}function F(e,t){return e===null?null:e.type==="pane"?e.paneId===t?e:null:F(e.first,t)??F(e.second,t)}function ce(e,t,o){if(e===null)return null;if(e.type==="pane"){if(e.paneId===t){let r=o(e.metadata);if(r===void 0){let{metadata:n,...l}=e;return l}return {...e,metadata:r}}return e}return {...e,first:ce(e.first,t,o)??e.first,second:ce(e.second,t,o)??e.second}}var Je=8,Ke=8,$t=4;var rt=({activeId:e,render:t,className:o})=>{let r=useRef(null);return useEffect(()=>{let n=l=>{r.current&&(r.current.style.transform=`translate(${l.clientX+12}px, ${l.clientY+12}px)`);};return document.addEventListener("pointermove",n),()=>document.removeEventListener("pointermove",n)},[]),jsx("div",{ref:r,className:o,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})},xe=class extends PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},Ne=class extends TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},it=({layout:e,onChange:t,renderPane:o,renderDragOverlay:r,classNames:n={},fullscreenPaneId:l=null,onFullscreenChange:a,onRemove:p,dragActivationDistance:E=8,snapThreshold:D=8,onDragStart:R,onDragEnd:c,onResizeStart:h,onResize:I,onResizeEnd:S,renderResizer:v,minSplitPercentage:f=5,maxSplitPercentage:b=95,enableDragToDismiss:O=false,dismissThreshold:x=60,onDismissIntentChange:J,children:j})=>{let[g,P]=useState(e),[Ie,me]=useState(e);e!==Ie&&(me(e),P(e));let[M,ee]=useState(null),[A,N]=useState(null),C=useRef(null),_=useRef(null),ae=useCallback(s=>{C.current=s;},[]),k=useRef(J);k.current=J;let w=useRef(g);w.current=g;let T=useRef(t);T.current=t;let W=useRef(o);W.current=o;let K=useRef(S);K.current=S;let te=useCallback(s=>W.current(s),[]),ne=useMemo(()=>n,[n.pane,n.dropPreview,n.swapPreview,n.dragOverlay,n.resizer,n.dismissPreview]),oe=useSensors(useSensor(xe,{activationConstraint:{distance:E}}),useSensor(Ne,{activationConstraint:{delay:250,tolerance:5}})),Xe=s=>{let u=s.active.id.toString();ee(u),O&&C.current?_.current=C.current.getBoundingClientRect():_.current=null,R&&R(u);},Ye=s=>{if(!O)return;let u=s.active.id.toString(),i=_.current;if(!i){A!==null&&(N(null),k.current?.(null));return}let d=s.activatorEvent,L=null,z=null;if(d instanceof MouseEvent||d instanceof PointerEvent)L=d.clientX+s.delta.x,z=d.clientY+s.delta.y;else if(typeof TouchEvent<"u"&&d instanceof TouchEvent){let m=d.touches[0]||d.changedTouches[0];m&&(L=m.clientX+s.delta.x,z=m.clientY+s.delta.y);}let Z=0;if(L!==null&&z!==null){let m=0,y=0;L<i.left?m=i.left-L:L>i.right&&(m=L-i.right),z<i.top?y=i.top-z:z>i.bottom&&(y=z-i.bottom),Z=Math.sqrt(m*m+y*y);}else {let m=s.active.rect.current.translated;if(m){let y=m.left+m.width/2,U=m.top+m.height/2,q=0,Q=0;y<i.left?q=i.left-y:y>i.right&&(q=y-i.right),U<i.top?Q=i.top-U:U>i.bottom&&(Q=U-i.bottom),Z=Math.sqrt(q*q+Q*Q);}}Z>x?A!==u&&(N(u),k.current?.(u)):A!==null&&(N(null),k.current?.(null));},Be=s=>{ee(null);let{active:u,over:i}=s,d=u.id.toString(),L=O&&A===d;if(N(null),k.current?.(null),_.current=null,L){p?p(d):he(d),c&&c(d,null,null);return}if(!i){c&&c(d,null,null);return}let z=i.id.toString(),Z=z.match(/^drop-root-(left|right|top|bottom)$/);if(Z){let[,X]=Z,re=Ve(g,d,X);P(re),t(re),c&&c(d,"root",{type:"split",direction:X==="left"||X==="right"?"row":"column",position:X});return}let ve=z.match(/^drop-center-(.+)$/);if(ve){let[,X]=ve;if(d!==X){let re=Pe(g,d,X);P(re),t(re);}c&&c(d,X,{type:"swap",position:"center"});return}let m=z.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!m){c&&c(d,null,null);return}let[,y,U]=m;if(d===U){c&&c(d,null,null);return}let q=y==="left"||y==="right"?"row":"column",Q=F(g,d)??{type:"pane",paneId:d},Ge=$(g,d),Fe=ie(Ge,U,q,y,Q);P(Fe),t(Fe),c&&c(d,U,{type:"split",direction:q,position:y});},ze=useCallback(s=>{P(s);},[]),he=useCallback(s=>{let u=$(w.current,s);P(u),T.current(u);},[]),Ee=useCallback(s=>{let u=$e(w.current,s);P(u),T.current(u);},[]),Ce=useCallback((s,u)=>{let i=Pe(w.current,s,u);P(i),T.current(i);},[]),Te=useCallback((s,u,i,d)=>{let L=F(w.current,d)??{type:"pane",paneId:d},z=$(w.current,d),Z=ie(z,s,u,i,L);P(Z),T.current(Z);},[]),Le=useCallback((s,u)=>{let i=G(w.current,s,u);P(i),T.current(i);},[]),Me=useCallback((s,u)=>{let i=ce(w.current,s,u);P(i),T.current(i);},[]),Ae=useCallback((s,u)=>{let i=G(w.current,s,u);P(i),T.current(i),K.current&&K.current(s,u);},[]),We=useMemo(()=>({layout:g,onLayoutChange:ze,renderPane:te,activeId:M,dismissIntentId:A,setContainerRef:ae,fullscreenPaneId:l,classNames:ne,onRemove:p,onFullscreenChange:a,snapThreshold:D,onResizeStart:h,onResize:I,onResizeEnd:Ae,renderResizer:v,minSplitPercentage:f,maxSplitPercentage:b}),[g,M,A,ae,l,ne,p,a,D,h,I,v,f,b,ze,te,Ae]),qe=useMemo(()=>({removePane:he,addPane:Ee,swapPanes:Ce,splitPane:Te,updateSplitPercentage:Le,updatePaneMetadata:Me}),[he,Ee,Ce,Te,Le,Me]);return jsx(de.Provider,{value:qe,children:jsxs(le.Provider,{value:We,children:[jsx(DndContext,{id:"zeugma-dnd-context",sensors:oe,collisionDetection:pointerWithin,onDragStart:Xe,onDragMove:Ye,onDragEnd:Be,children:j}),M&&r&&jsx(rt,{activeId:M,render:r,className:`${n.dragOverlay||""} ${M===A?n.dismissPreview||"zeugma-dismiss-preview":""}`.trim()})]})})};var lt={top:{position:"absolute",top:0,left:0,right:0,height:"32px",zIndex:30,pointerEvents:"auto"},bottom:{position:"absolute",bottom:0,left:0,right:0,height:"32px",zIndex:30,pointerEvents:"auto"},left:{position:"absolute",top:0,bottom:0,left:0,width:"32px",zIndex:30,pointerEvents:"auto"},right:{position:"absolute",top:0,bottom:0,right:0,width:"32px",zIndex:30,pointerEvents:"auto"}},dt={top:{position:"absolute",top:0,left:0,right:0,height:"50%",zIndex:31,pointerEvents:"none",boxSizing:"border-box"},bottom:{position:"absolute",bottom:0,left:0,right:0,height:"50%",zIndex:31,pointerEvents:"none",boxSizing:"border-box"},left:{position:"absolute",top:0,bottom:0,left:0,width:"50%",zIndex:31,pointerEvents:"none",boxSizing:"border-box"},right:{position:"absolute",top:0,bottom:0,right:0,width:"50%",zIndex:31,pointerEvents:"none",boxSizing:"border-box"}},ct=({id:e,position:t,activeClassName:o})=>{let{setNodeRef:r,isOver:n}=useDroppable({id:e});return jsxs(Fragment,{children:[jsx("div",{ref:r,style:lt[t]}),n&&jsx("div",{className:o,style:dt[t]})]})},_e=({activeId:e,hasOtherPanes:t,dropPreviewClassName:o})=>!e||!t?null:jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:30,pointerEvents:"none"},children:["top","bottom","left","right"].map(r=>jsx(ct,{id:`drop-root-${r}`,position:r,activeClassName:o},r))});function De({containerRef:e,isRow:t,direction:o,splitPercentage:r,resizerSize:n,snapThreshold:l,layout:a,currentNode:p,onLayoutChange:E,onResizeStart:D,onResizeEnd:R}){let{onResizeStart:c,onResize:h,onResizeEnd:I,minSplitPercentage:S=5,maxSplitPercentage:v=95}=Y();return useCallback(f=>{f.preventDefault();let b=e.current;if(!b)return;document.body.classList.add("zeugma-resizing");let O=document.createElement("style");O.id="zeugma-global-cursor-style",O.textContent=`
2
- * {
3
- cursor: ${t?"col-resize":"row-resize"} !important;
4
- user-select: none !important;
5
- }
6
- `,document.head.appendChild(O),D&&D(),c&&c(p);let x=b.getBoundingClientRect(),J=f.clientX,j=f.clientY,g=r,P=f.currentTarget;P.setAttribute("data-resizing","true");let me=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(N=>N!==P&&N.getAttribute("data-direction")===o).map(N=>{let C=N.getBoundingClientRect();return t?C.left+C.width/2:C.top+C.height/2}),M=g,ee=N=>{let C=t?(N.clientX-J)/x.width*100:(N.clientY-j)/x.height*100,_=g+C,ae=t?x.left+(x.width-n)*(_/100)+n/2:x.top+(x.height-n)*(_/100)+n/2,k=1/0,w=null;for(let ne of me){let oe=Math.abs(ae-ne);oe<l&&oe<k&&(k=oe,w=ne);}let T=_;w!==null&&(T=t?(w-n/2-x.left)/(x.width-n)*100:(w-n/2-x.top)/(x.height-n)*100);let W=Math.max(S,Math.min(v,T));M=W;let K=b.children[0],te=b.children[b.children.length-1];K&&te&&(K.style.flex=`${W} 1 0%`,te.style.flex=`${100-W} 1 0%`),h&&h(p,W);},A=()=>{document.body.classList.remove("zeugma-resizing"),P.removeAttribute("data-resizing");let N=document.getElementById("zeugma-global-cursor-style");N&&N.remove(),document.removeEventListener("pointermove",ee),document.removeEventListener("pointerup",A);let C=G(a,p,M);console.log("onLayoutChange (finalized) called with percentage:",M),E(C),R&&R(),I&&I(p,M);};document.addEventListener("pointermove",ee),document.addEventListener("pointerup",A);},[e,t,o,r,n,l,a,p,E,D,R,c,h,I,S,v])}var vt=({currentNode:e,resizerSize:t,snapThreshold:o,renderResizer:r})=>{let{layout:n,onLayoutChange:l,classNames:a,renderResizer:p}=Y(),[E,D]=useState(false),R=r||p,c=useRef(null),{direction:h,first:I,second:S,splitPercentage:v}=e,f=h==="row",b=De({containerRef:c,isRow:f,direction:h,splitPercentage:v,resizerSize:t,snapThreshold:o??8,layout:n,currentNode:e,onLayoutChange:l,onResizeStart:()=>D(true),onResizeEnd:()=>D(false)});return jsxs("div",{ref:c,style:{display:"flex",flexDirection:f?"row":"column",width:"100%",height:"100%",overflow:"hidden"},children:[jsx("div",{style:{flex:`${v} 1 0%`,overflow:"hidden"},children:jsx(Se,{tree:I,resizerSize:t,snapThreshold:o,renderResizer:r})}),R?R({direction:h,splitPercentage:v,resizerSize:t,isResizing:E,onPointerDown:b}):jsx("div",{className:a.resizer,"data-direction":h,style:{width:f?`${t}px`:"100%",height:f?"100%":`${t}px`,cursor:f?"col-resize":"row-resize",position:"relative",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box",flexShrink:0},onPointerDown:b,role:"separator","aria-valuenow":v,"aria-valuemin":5,"aria-valuemax":95}),jsx("div",{style:{flex:`${100-v} 1 0%`,overflow:"hidden"},children:jsx(Se,{tree:S,resizerSize:t,snapThreshold:o,renderResizer:r})})]})},Se=({tree:e,resizerSize:t=4,snapThreshold:o,renderResizer:r})=>{let{layout:n,renderPane:l,activeId:a,dismissIntentId:p,setContainerRef:E,classNames:D,fullscreenPaneId:R,snapThreshold:c}=Y(),h=o!==void 0?o:c,I=useMemo(()=>e!==void 0||!a?false:$(n,a)!==null,[e,n,a]);if(R&&!e)return jsx("div",{style:{width:"100%",height:"100%",position:"relative"},children:l(R)});let S=e!==void 0?e:n;if(!S)return null;let v=()=>S.type==="pane"?jsx("div",{style:{width:"100%",height:"100%",position:"relative"},children:l(S.paneId)}):jsx(vt,{currentNode:S,resizerSize:t,snapThreshold:h,renderResizer:r});return e===void 0?jsxs("div",{ref:E,className:`zeugma-dashboard-root ${a!==null&&a===p?"zeugma-dashboard-dismiss-active":""}`.trim(),style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[v(),jsx(_e,{activeId:a,hasOtherPanes:I,dropPreviewClassName:D.dropPreview})]}):v()};var ge=createContext(null);var xt={top:{position:"absolute",top:0,left:"25%",width:"50%",height:"25%",zIndex:20,pointerEvents:"auto"},bottom:{position:"absolute",bottom:0,left:"25%",width:"50%",height:"25%",zIndex:20,pointerEvents:"auto"},left:{position:"absolute",top:"25%",left:0,width:"25%",height:"50%",zIndex:20,pointerEvents:"auto"},right:{position:"absolute",top:"25%",right:0,width:"25%",height:"50%",zIndex:20,pointerEvents:"auto"},center:{position:"absolute",top:"25%",left:"25%",width:"50%",height:"50%",zIndex:20,pointerEvents:"auto"}},Nt={top:{position:"absolute",top:0,left:0,right:0,height:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},bottom:{position:"absolute",bottom:0,left:0,right:0,height:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},left:{position:"absolute",top:0,bottom:0,left:0,width:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},right:{position:"absolute",top:0,bottom:0,right:0,width:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},center:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:21,pointerEvents:"none",boxSizing:"border-box"}},Ue=({id:e,position:t,activeClassName:o})=>{let{setNodeRef:r,isOver:n}=useDroppable({id:e});return jsxs(Fragment,{children:[jsx("div",{ref:r,style:xt[t]}),n&&jsx("div",{className:o,style:Nt[t]})]})},Dt=({id:e,children:t,style:o})=>{let{layout:r,activeId:n,classNames:l,fullscreenPaneId:a,onRemove:p,onFullscreenChange:E}=Y(),{removePane:D,updatePaneMetadata:R}=be(),c=n!==null&&n!==e,{attributes:h,listeners:I,setNodeRef:S,isDragging:v}=useDraggable({id:e}),f=n===e||v,b=a===e,x=useMemo(()=>F(r,e),[r,e])?.metadata,J=useMemo(()=>({isDragging:f,isFullscreen:b,toggleFullscreen:()=>E?.(b?null:e),remove:()=>{b&&E?.(null),p?p(e):D(e);},metadata:x,updateMetadata:g=>{R(e,g);}}),[f,b,E,e,p,D,x,R]),j=useMemo(()=>({...I,...h}),[I,h]);return jsx(ge.Provider,{value:j,children:jsxs("div",{ref:S,className:l.pane,style:{position:"relative",width:"100%",height:"100%",...o},children:[t(J),c&&jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:[["top","bottom","left","right"].map(g=>jsx(Ue,{id:`drop-${g}-${e}`,position:g,activeClassName:l.dropPreview},g)),jsx(Ue,{id:`drop-center-${e}`,position:"center",activeClassName:l.swapPreview})]})]})})};var yt=({children:e,className:t,style:o})=>{let r=useContext(ge);if(!r)throw new Error("<DragHandle> must be used inside a <Pane>");return jsx("div",{className:t,style:{cursor:"grab",userSelect:"none",touchAction:"none",...o},...r,children:e})};export{Ke as DEFAULT_DRAG_ACTIVATION_DISTANCE,$t as DEFAULT_RESIZER_SIZE,Je as DEFAULT_SNAP_THRESHOLD,it as DashboardProvider,yt as DragHandle,Dt as Pane,Se as PaneTree,$e as addPane,F as findPane,$ as removePane,ie as splitPane,Ve as splitRoot,Pe as swapPanes,ce as updatePaneMetadata,G as updateSplitPercentage,be as useDashboardActions,Y as useDashboardState,De as useResizer};//# sourceMappingURL=index.js.map
1
+ import {createContext,useContext,useState,useRef,useCallback,useMemo,useEffect}from'react';import {useSensors,useSensor,DndContext,pointerWithin,useDraggable,PointerSensor,TouchSensor,useDroppable}from'@dnd-kit/core';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var se=createContext(void 0),ae=createContext(void 0);var G=()=>{let e=useContext(se);if(!e)throw new Error("useDashboardState must be used within a DashboardProvider");return e},be=()=>{let e=useContext(ae);if(!e)throw new Error("useDashboardActions must be used within a DashboardProvider");return e};function Y(e,t){if(e===null)return null;if(e.type==="pane")return e.paneId===t?null:e;let n=Y(e.first,t),r=Y(e.second,t);return n===null?r:r===null?n:{...e,first:n,second:r}}function re(e,t,n,r,o){if(e===null)return typeof o=="string"?{type:"pane",paneId:o}:o;if(e.type==="pane"){if(e.paneId===t){let i=typeof o=="string"?{type:"pane",paneId:o}:o,d=r==="left"||r==="top";return {type:"split",direction:n,first:d?i:e,second:d?e:i,splitPercentage:50}}return e}return {...e,first:re(e.first,t,n,r,o)||e.first,second:re(e.second,t,n,r,o)||e.second}}function Pe(e,t,n){if(e===null)return null;let r=O(e,t),o=O(e,n);if(!r||!o)return e;function i(d){return d.type==="pane"?d.paneId===t?{...o}:d.paneId===n?{...r}:d:{...d,first:i(d.first),second:i(d.second)}}return i(e)}function Ze(e,t){if(e===null)return {type:"pane",paneId:t};function n(r,o){return r.type==="pane"?{type:"split",direction:o==="row"?"column":"row",splitPercentage:50,first:r,second:{type:"pane",paneId:t}}:{...r,second:n(r.second,r.direction)}}return n(e,null)}function Q(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:Q(e.first,t,n)||e.first,second:Q(e.second,t,n)||e.second}:e}function _e(e,t,n){let r=O(e,t)??{type:"pane",paneId:t},o=Y(e,t);if(o===null)return {...r};let i=n==="left"||n==="right"?"row":"column",d=n==="left"||n==="top",c={...r};return {type:"split",direction:i,first:d?c:o,second:d?o:c,splitPercentage:50}}function O(e,t){return e===null?null:e.type==="pane"?e.paneId===t?e:null:O(e.first,t)??O(e.second,t)}function le(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.paneId===t){let r=n(e.metadata);if(r===void 0){let{metadata:o,...i}=e;return i}return {...e,metadata:r}}return e}return {...e,first:le(e.first,t,n)??e.first,second:le(e.second,t,n)??e.second}}var je=8,et=8,Xt=4;var at=({activeId:e,render:t,className:n})=>{let r=useRef(null);return useEffect(()=>{let o=i=>{r.current&&(r.current.style.transform=`translate(${i.clientX+12}px, ${i.clientY+12}px)`);};return document.addEventListener("pointermove",o),()=>document.removeEventListener("pointermove",o)},[]),jsx("div",{ref:r,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})},Re=class extends PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},De=class extends TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},lt=({layout:e,onChange:t,renderPane:n,renderDragOverlay:r,classNames:o={},fullscreenPaneId:i=null,onFullscreenChange:d,onRemove:c,dragActivationDistance:D=8,snapThreshold:P=8,onDragStart:y,onDragEnd:s,onResizeStart:x,onResize:g,onResizeEnd:N,minSplitPercentage:E=5,maxSplitPercentage:I=95,enableDragToDismiss:S=false,dismissThreshold:w=60,onDismissIntentChange:H,children:z})=>{let[u,m]=useState(e),[ee,te]=useState(e);e!==ee&&(te(e),m(e));let[b,T]=useState(null),[v,M]=useState(null),B=useRef(null),Z=useRef(null),h=useCallback(l=>{B.current=l;},[]),C=useCallback(l=>n(l),[n]),F=useMemo(()=>o,[o.pane,o.dropPreview,o.swapPreview,o.dragOverlay,o.resizer,o.dismissPreview]),_=useSensors(useSensor(Re,{activationConstraint:{distance:D}}),useSensor(De,{activationConstraint:{delay:250,tolerance:5}})),X=l=>{let f=l.active.id.toString();T(f),S&&B.current?Z.current=B.current.getBoundingClientRect():Z.current=null,y&&y(f);},K=l=>{if(!S)return;let f=l.active.id.toString(),a=Z.current;if(!a){v!==null&&(M(null),H?.(null));return}let p=l.activatorEvent,$=null,A=null;if(p instanceof MouseEvent||p instanceof PointerEvent)$=p.clientX+l.delta.x,A=p.clientY+l.delta.y;else if(typeof TouchEvent<"u"&&p instanceof TouchEvent){let R=p.touches[0]||p.changedTouches[0];R&&($=R.clientX+l.delta.x,A=R.clientY+l.delta.y);}let k=0;if($!==null&&A!==null){let R=0,L=0;$<a.left?R=a.left-$:$>a.right&&(R=$-a.right),A<a.top?L=a.top-A:A>a.bottom&&(L=A-a.bottom),k=Math.sqrt(R*R+L*L);}else {let R=l.active.rect.current.translated;if(R){let L=R.left+R.width/2,q=R.top+R.height/2,J=0,j=0;L<a.left?J=a.left-L:L>a.right&&(J=L-a.right),q<a.top?j=a.top-q:q>a.bottom&&(j=q-a.bottom),k=Math.sqrt(J*J+j*j);}}k>w?v!==f&&(M(f),H?.(f)):v!==null&&(M(null),H?.(null));},ne=l=>{T(null);let{active:f,over:a}=l,p=f.id.toString(),$=S&&v===p;if(M(null),H?.(null),Z.current=null,$){c?c(p):he(p),s&&s(p,null,null);return}if(!a){s&&s(p,null,null);return}let A=a.id.toString(),k=A.match(/^drop-root-(left|right|top|bottom)$/);if(k){let[,W]=k,oe=_e(u,p,W);m(oe),t(oe),s&&s(p,"root",{type:"split",direction:W==="left"||W==="right"?"row":"column",position:W});return}let ve=A.match(/^drop-center-(.+)$/);if(ve){let[,W]=ve;if(p!==W){let oe=Pe(u,p,W);m(oe),t(oe);}s&&s(p,W,{type:"swap",position:"center"});return}let R=A.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!R){s&&s(p,null,null);return}let[,L,q]=R;if(p===q){s&&s(p,null,null);return}let J=L==="left"||L==="right"?"row":"column",j=O(u,p)??{type:"pane",paneId:p},Qe=Y(u,p),Fe=re(Qe,q,J,L,j);m(Fe),t(Fe),s&&s(p,q,{type:"split",direction:J,position:L});},Ie=useCallback(l=>{m(l),t(l);},[t]),he=useCallback(l=>{let f=Y(u,l);m(f),t(f);},[u,t]),ze=useCallback(l=>{let f=Ze(u,l);m(f),t(f);},[u,t]),Te=useCallback((l,f)=>{let a=Pe(u,l,f);m(a),t(a);},[u,t]),Ce=useCallback((l,f,a,p)=>{let $=O(u,p)??{type:"pane",paneId:p},A=Y(u,p),k=re(A,l,f,a,$);m(k),t(k);},[u,t]),Le=useCallback((l,f)=>{let a=Q(u,l,f);m(a),t(a);},[u,t]),Me=useCallback((l,f)=>{let a=le(u,l,f);m(a),t(a);},[u,t]),Ae=useCallback((l,f)=>{let a=Q(u,l,f);m(a),t(a),N&&N(l,f);},[u,t,N]),Ke=useMemo(()=>({layout:u,onLayoutChange:Ie,renderPane:C,activeId:b,dismissIntentId:v,setContainerRef:h,fullscreenPaneId:i,classNames:F,onRemove:c,onFullscreenChange:d,snapThreshold:P,onResizeStart:x,onResize:g,onResizeEnd:Ae,minSplitPercentage:E,maxSplitPercentage:I}),[u,b,v,h,i,F,c,d,P,x,g,E,I,Ie,C,Ae]),Je=useMemo(()=>({removePane:he,addPane:ze,swapPanes:Te,splitPane:Ce,updateSplitPercentage:Le,updatePaneMetadata:Me}),[he,ze,Te,Ce,Le,Me]);return jsx(ae.Provider,{value:Je,children:jsxs(se.Provider,{value:Ke,children:[jsx(DndContext,{id:"zeugma-dnd-context",sensors:_,collisionDetection:pointerWithin,onDragStart:X,onDragMove:K,onDragEnd:ne,children:z}),b&&r&&jsx(at,{activeId:b,render:r,className:`${o.dragOverlay||""} ${b===v?o.dismissPreview||"zeugma-dismiss-preview":""}`.trim()})]})})};var ut={top:{position:"absolute",top:0,left:0,right:0,height:"32px",zIndex:30,pointerEvents:"auto"},bottom:{position:"absolute",bottom:0,left:0,right:0,height:"32px",zIndex:30,pointerEvents:"auto"},left:{position:"absolute",top:0,bottom:0,left:0,width:"32px",zIndex:30,pointerEvents:"auto"},right:{position:"absolute",top:0,bottom:0,right:0,width:"32px",zIndex:30,pointerEvents:"auto"}},pt={top:{position:"absolute",top:0,left:0,right:0,height:"50%",zIndex:31,pointerEvents:"none",boxSizing:"border-box"},bottom:{position:"absolute",bottom:0,left:0,right:0,height:"50%",zIndex:31,pointerEvents:"none",boxSizing:"border-box"},left:{position:"absolute",top:0,bottom:0,left:0,width:"50%",zIndex:31,pointerEvents:"none",boxSizing:"border-box"},right:{position:"absolute",top:0,bottom:0,right:0,width:"50%",zIndex:31,pointerEvents:"none",boxSizing:"border-box"}},ft=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:r,isOver:o}=useDroppable({id:e});return jsxs(Fragment,{children:[jsx("div",{ref:r,style:ut[t]}),o&&jsx("div",{className:n,style:pt[t]})]})},Ve=({activeId:e,hasOtherPanes:t,dropPreviewClassName:n})=>!e||!t?null:jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:30,pointerEvents:"none"},children:["top","bottom","left","right"].map(r=>jsx(ft,{id:`drop-root-${r}`,position:r,activeClassName:n},r))});function pe({cursor:e,resizerEl:t,onMove:n,onEnd:r}){document.body.classList.add("zeugma-resizing");let o=document.createElement("style");o.id="zeugma-global-cursor-style",o.textContent=`
2
+ * {
3
+ cursor: ${e} !important;
4
+ user-select: none !important;
5
+ }
6
+ `,document.head.appendChild(o),t.setAttribute("data-resizing","true");let i=c=>{n(c);},d=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let c=document.getElementById("zeugma-global-cursor-style");c&&c.remove(),document.removeEventListener("pointermove",i),document.removeEventListener("pointerup",d),r();};document.addEventListener("pointermove",i),document.addEventListener("pointerup",d);}function Ne({containerRef:e,isRow:t,direction:n,splitPercentage:r,resizerSize:o,snapThreshold:i,layout:d,currentNode:c,onLayoutChange:D,onResizeStart:P,onResizeEnd:y}){let{onResizeStart:s,onResize:x,onResizeEnd:g,minSplitPercentage:N=5,maxSplitPercentage:E=95}=G();return useCallback(I=>{I.preventDefault();let S=e.current;if(!S)return;P&&P(),s&&s(c);let w=S.getBoundingClientRect(),H=I.clientX,z=I.clientY,u=r,m=I.currentTarget,te=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(T=>T!==m&&T.getAttribute("data-direction")===n).map(T=>{let v=T.getBoundingClientRect();return t?v.left+v.width/2:v.top+v.height/2}),b=u;pe({cursor:t?"col-resize":"row-resize",resizerEl:m,onMove:T=>{let v=t?(T.clientX-H)/w.width*100:(T.clientY-z)/w.height*100,M=u+v,B=t?w.left+(w.width-o)*(M/100)+o/2:w.top+(w.height-o)*(M/100)+o/2,Z=1/0,h=null;for(let K of te){let ne=Math.abs(B-K);ne<i&&ne<Z&&(Z=ne,h=K);}let C=M;h!==null&&(C=t?(h-o/2-w.left)/(w.width-o)*100:(h-o/2-w.top)/(w.height-o)*100);let F=Math.max(N,Math.min(E,C));b=F;let _=S.children[0],X=S.children[S.children.length-1];_&&X&&(_.style.flex=`${F} 1 0%`,X.style.flex=`${100-F} 1 0%`),x&&x(c,F);},onEnd:()=>{let T=Q(d,c,b);D(T),y&&y(),g&&g(c,b);}});},[e,t,n,r,o,i,d,c,D,P,y,s,x,g,N,E])}var xt=({currentNode:e,resizerSize:t,snapThreshold:n})=>{let{layout:r,onLayoutChange:o,classNames:i}=G(),[d,c]=useState(false),D=useRef(null),{direction:P,first:y,second:s,splitPercentage:x}=e,g=P==="row",N=Ne({containerRef:D,isRow:g,direction:P,splitPercentage:x,resizerSize:t,snapThreshold:n??8,layout:r,currentNode:e,onLayoutChange:o,onResizeStart:()=>c(true),onResizeEnd:()=>c(false)});return jsxs("div",{ref:D,style:{display:"flex",flexDirection:g?"row":"column",width:"100%",height:"100%",overflow:"hidden"},children:[jsx("div",{style:{flex:`${x} 1 0%`,overflow:"hidden"},children:jsx(we,{tree:y,resizerSize:t,snapThreshold:n})}),jsx("div",{className:`zeugma-resizer ${i.resizer||""}`.trim(),"data-direction":P,"data-resizing":d||void 0,style:{width:g?`${t}px`:"100%",height:g?"100%":`${t}px`,cursor:g?"col-resize":"row-resize",position:"relative",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box",flexShrink:0},onPointerDown:N,role:"separator","aria-valuenow":x,"aria-valuemin":5,"aria-valuemax":95}),jsx("div",{style:{flex:`${100-x} 1 0%`,overflow:"hidden"},children:jsx(we,{tree:s,resizerSize:t,snapThreshold:n})})]})},we=({tree:e,resizerSize:t=4,snapThreshold:n})=>{let{layout:r,renderPane:o,activeId:i,dismissIntentId:d,setContainerRef:c,classNames:D,fullscreenPaneId:P,snapThreshold:y}=G(),s=n!==void 0?n:y,x=useMemo(()=>e!==void 0||!i?false:Y(r,i)!==null,[e,r,i]);if(P&&!e)return jsx("div",{style:{width:"100%",height:"100%",position:"relative"},children:o(P)});let g=e!==void 0?e:r;if(!g)return null;let N=()=>g.type==="pane"?jsx("div",{style:{width:"100%",height:"100%",position:"relative"},children:o(g.paneId)}):jsx(xt,{currentNode:g,resizerSize:t,snapThreshold:s});return e===void 0?jsxs("div",{ref:c,className:`zeugma-dashboard-root ${i!==null&&i===d?"zeugma-dashboard-dismiss-active":""}`.trim(),style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[N(),jsx(Ve,{activeId:i,hasOtherPanes:x,dropPreviewClassName:D.dropPreview})]}):N()};var Xe="zeugma-height:",Dt="default-pane";function Nt(e){try{let t=localStorage.getItem(Xe+e);if(t!==null){let n=Number(t);if(Number.isFinite(n)&&n>0)return n}}catch{}return null}function Be(e,t){try{localStorage.setItem(Xe+e,String(Math.round(t)));}catch{}}var qe=({children:e,active:t=true,height:n,onHeightChange:r,minHeight:o=100,maxHeight:i=1/0,persist:d,localStorageKey:c,resizerHeight:D=6,className:P,resizerClassName:y})=>{let s=d?c||Dt:null,x=()=>{let z=(s?Nt(s):null)??n??400;return fe(z,o,i)},[g,N]=useState(x),E=useRef(null),I=s?g:n??g,S=useRef(n);useEffect(()=>{if(n!==void 0&&n!==S.current){let z=fe(n,o,i);N(z),s&&Be(s,z);}S.current=n;},[n,o,i,s]);let w=useCallback(()=>i,[i]),H=useCallback(z=>{z.preventDefault();let u=z.clientY,m=I,ee=w(),te=z.currentTarget,b=We(E.current),T=b?b.scrollTop:0,v=u,M=null,B=(h,C)=>{let F=C-T,X=h-u+F,K=fe(m+X,o,ee);return E.current&&(E.current.style.height=`${K}px`),K},Z=()=>{if(!b)return;let h=b===document.documentElement||b===document.body?{top:0,bottom:window.innerHeight}:b.getBoundingClientRect(),C=40,F=10,_=0;v>h.bottom-C?_=Math.min(1,(v-(h.bottom-C))/C)*F:v<h.top+C&&(_=-Math.min(1,(h.top+C-v)/C)*F),_!==0&&(b.scrollTop+=_,B(v,b.scrollTop)),M=requestAnimationFrame(Z);};M=requestAnimationFrame(Z),pe({cursor:"row-resize",resizerEl:te,onMove:h=>{v=h.clientY,b&&B(v,b.scrollTop);},onEnd:()=>{M!==null&&cancelAnimationFrame(M);let h=m;E.current&&(h=E.current.getBoundingClientRect().height),h=fe(h,o,ee),N(h),r&&r(h),s&&Be(s,h);}});},[I,o,w,r,s]);return t?jsxs("div",{ref:E,className:`zeugma-resizable-container ${P||""}`.trim(),style:{height:`${I}px`,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:[jsx("div",{style:{height:`calc(100% - ${D}px)`,overflow:"hidden"},children:e}),jsx("div",{className:`zeugma-resizable-handle ${y||""}`.trim(),style:{height:`${D}px`,cursor:"row-resize",position:"relative",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box",flexShrink:0},onPointerDown:H,role:"separator","aria-orientation":"horizontal","aria-valuenow":Math.round(I),"aria-valuemin":o,"aria-valuemax":i===1/0?void 0:i})]}):jsx("div",{className:`zeugma-resizable-container disabled ${P||""}`.trim(),style:{height:"100%",position:"relative",overflow:"hidden",boxSizing:"border-box"},children:jsx("div",{style:{height:"100%",overflow:"hidden"},children:e})})};function fe(e,t,n){return Math.max(t,Math.min(n,e))}function We(e){if(typeof window>"u"||!e)return null;let t=e.parentElement;if(!t)return document.documentElement;let r=window.getComputedStyle(t).overflowY;return r==="auto"||r==="scroll"?t:We(t)}var ge=createContext(null);var zt={top:{position:"absolute",top:0,left:"25%",width:"50%",height:"25%",zIndex:20,pointerEvents:"auto"},bottom:{position:"absolute",bottom:0,left:"25%",width:"50%",height:"25%",zIndex:20,pointerEvents:"auto"},left:{position:"absolute",top:"25%",left:0,width:"25%",height:"50%",zIndex:20,pointerEvents:"auto"},right:{position:"absolute",top:"25%",right:0,width:"25%",height:"50%",zIndex:20,pointerEvents:"auto"},center:{position:"absolute",top:"25%",left:"25%",width:"50%",height:"50%",zIndex:20,pointerEvents:"auto"}},Tt={top:{position:"absolute",top:0,left:0,right:0,height:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},bottom:{position:"absolute",bottom:0,left:0,right:0,height:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},left:{position:"absolute",top:0,bottom:0,left:0,width:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},right:{position:"absolute",top:0,bottom:0,right:0,width:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},center:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:21,pointerEvents:"none",boxSizing:"border-box"}},Ge=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:r,isOver:o}=useDroppable({id:e});return jsxs(Fragment,{children:[jsx("div",{ref:r,style:zt[t]}),o&&jsx("div",{className:n,style:Tt[t]})]})},Ct=({id:e,children:t,style:n})=>{let{layout:r,activeId:o,classNames:i,fullscreenPaneId:d,onRemove:c,onFullscreenChange:D}=G(),{removePane:P,updatePaneMetadata:y}=be(),s=o!==null&&o!==e,{attributes:x,listeners:g,setNodeRef:N,isDragging:E}=useDraggable({id:e}),I=o===e||E,S=d===e,H=useMemo(()=>O(r,e),[r,e])?.metadata,z=useMemo(()=>({isDragging:I,isFullscreen:S,toggleFullscreen:()=>D?.(S?null:e),remove:()=>{S&&D?.(null),c?c(e):P(e);},metadata:H,updateMetadata:m=>{y(e,m);}}),[I,S,D,e,c,P,H,y]),u=useMemo(()=>({...g,...x}),[g,x]);return jsx(ge.Provider,{value:u,children:jsxs("div",{ref:N,className:i.pane,style:{position:"relative",width:"100%",height:"100%",...n},children:[t(z),s&&jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:[["top","bottom","left","right"].map(m=>jsx(Ge,{id:`drop-${m}-${e}`,position:m,activeClassName:i.dropPreview},m)),jsx(Ge,{id:`drop-center-${e}`,position:"center",activeClassName:i.swapPreview})]})]})})};var At=({children:e,className:t,style:n})=>{let r=useContext(ge);if(!r)throw new Error("<DragHandle> must be used inside a <Pane>");return jsx("div",{className:t,style:{cursor:"grab",userSelect:"none",touchAction:"none",...n},...r,children:e})};export{et as DEFAULT_DRAG_ACTIVATION_DISTANCE,Xt as DEFAULT_RESIZER_SIZE,je as DEFAULT_SNAP_THRESHOLD,lt as DashboardProvider,At as DragHandle,Ct as Pane,we as PaneTree,qe as ResizableContainer,Ze as addPane,pe as createDragSession,O as findPane,Y as removePane,re as splitPane,_e as splitRoot,Pe as swapPanes,le as updatePaneMetadata,Q as updateSplitPercentage,be as useDashboardActions,G as useDashboardState,Ne as useResizer};//# sourceMappingURL=index.js.map
7
7
  //# sourceMappingURL=index.js.map