react-zeugma 1.3.0 → 1.4.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/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 de=createContext(void 0),ce=createContext(void 0);var X=()=>{let e=useContext(de);if(!e)throw new Error("useDashboardState must be used within a DashboardProvider");return e},be=()=>{let e=useContext(ce);if(!e)throw new Error("useDashboardActions must be used within a DashboardProvider");return e};function Z(e,t){if(e===null)return null;if(e.type==="pane")return e.paneId===t?null:e;let o=Z(e.first,t),r=Z(e.second,t);return o===null?r:r===null?o:{...e,first:o,second:r}}function se(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:se(e.first,t,o,r,n)||e.first,second:se(e.second,t,o,r,n)||e.second}}function Pe(e,t,o){if(e===null)return null;let r=A(e,t),n=A(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 J(e,t,o){return e===null?null:e===t?{...e,splitPercentage:o}:e.type==="split"?{...e,first:J(e.first,t,o)||e.first,second:J(e.second,t,o)||e.second}:e}function Ve(e,t,o){let r=A(e,t)??{type:"pane",paneId:t},n=Z(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 A(e,t){return e===null?null:e.type==="pane"?e.paneId===t?e:null:A(e.first,t)??A(e.second,t)}function ue(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:ue(e.first,t,o)??e.first,second:ue(e.second,t,o)??e.second}}var Ge=8,Je=8,Zt=4;var ot=({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)})},Ne=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")}]},rt=({layout:e,onChange:t,renderPane:o,renderDragOverlay:r,classNames:n={},fullscreenPaneId:l=null,onFullscreenChange:a,onRemove:p,dragActivationDistance:C=8,snapThreshold:N=8,onDragStart:R,onDragEnd:c,onResizeStart:h,onResize:y,onResizeEnd:D,renderResizer:v,minSplitPercentage:f=5,maxSplitPercentage:b=95,enableDragToDismiss:O=false,dismissThreshold:x=60,onDismissIntentChange:K,children:ee})=>{let[g,P]=useState(e),me=useRef(e);e!==me.current&&(me.current=e,P(e));let[Y,B]=useState(null),[M,W]=useState(null),S=useRef(null),I=useRef(null),Q=useCallback(s=>{S.current=s;},[]),q=useRef(K);q.current=K;let T=useRef(g);T.current=g;let z=useRef(t);z.current=t;let te=useRef(o);te.current=o;let _=useRef(D);_.current=D;let ne=useCallback(s=>te.current(s),[]),oe=useMemo(()=>n,[n.pane,n.dropPreview,n.swapPreview,n.dragOverlay,n.resizer,n.dismissPreview]),le=useSensors(useSensor(Ne,{activationConstraint:{distance:C}}),useSensor(De,{activationConstraint:{delay:250,tolerance:5}})),re=s=>{let u=s.active.id.toString();B(u),O&&S.current?I.current=S.current.getBoundingClientRect():I.current=null,R&&R(u);},Xe=s=>{if(!O)return;let u=s.active.id.toString(),i=I.current;if(!i){M!==null&&(W(null),q.current?.(null));return}let d=s.activatorEvent,L=null,E=null;if(d instanceof MouseEvent||d instanceof PointerEvent)L=d.clientX+s.delta.x,E=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,E=m.clientY+s.delta.y);}let H=0;if(L!==null&&E!==null){let m=0,w=0;L<i.left?m=i.left-L:L>i.right&&(m=L-i.right),E<i.top?w=i.top-E:E>i.bottom&&(w=E-i.bottom),H=Math.sqrt(m*m+w*w);}else {let m=s.active.rect.current.translated;if(m){let w=m.left+m.width/2,k=m.top+m.height/2,G=0,j=0;w<i.left?G=i.left-w:w>i.right&&(G=w-i.right),k<i.top?j=i.top-k:k>i.bottom&&(j=k-i.bottom),H=Math.sqrt(G*G+j*j);}}H>x?M!==u&&(W(u),q.current?.(u)):M!==null&&(W(null),q.current?.(null));},Ye=s=>{B(null);let{active:u,over:i}=s,d=u.id.toString(),L=O&&M===d;if(W(null),q.current?.(null),I.current=null,L){p?p(d):he(d),c&&c(d,null,null);return}if(!i){c&&c(d,null,null);return}let E=i.id.toString(),H=E.match(/^drop-root-(left|right|top|bottom)$/);if(H){let[,U]=H,ie=Ve(g,d,U);P(ie),t(ie),c&&c(d,"root",{type:"split",direction:U==="left"||U==="right"?"row":"column",position:U});return}let ve=E.match(/^drop-center-(.+)$/);if(ve){let[,U]=ve;if(d!==U){let ie=Pe(g,d,U);P(ie),t(ie);}c&&c(d,U,{type:"swap",position:"center"});return}let m=E.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!m){c&&c(d,null,null);return}let[,w,k]=m;if(d===k){c&&c(d,null,null);return}let G=w==="left"||w==="right"?"row":"column",j=A(g,d)??{type:"pane",paneId:d},qe=Z(g,d),Fe=se(qe,k,G,w,j);P(Fe),t(Fe),c&&c(d,k,{type:"split",direction:G,position:w});},ze=useCallback(s=>{P(s);},[]),he=useCallback(s=>{let u=Z(T.current,s);P(u),z.current(u);},[]),Ee=useCallback(s=>{let u=$e(T.current,s);P(u),z.current(u);},[]),Ce=useCallback((s,u)=>{let i=Pe(T.current,s,u);P(i),z.current(i);},[]),Te=useCallback((s,u,i,d)=>{let L=A(T.current,d)??{type:"pane",paneId:d},E=Z(T.current,d),H=se(E,s,u,i,L);P(H),z.current(H);},[]),Le=useCallback((s,u)=>{let i=J(T.current,s,u);P(i),z.current(i);},[]),Me=useCallback((s,u)=>{let i=ue(T.current,s,u);P(i),z.current(i);},[]),Ae=useCallback((s,u)=>{let i=J(T.current,s,u);P(i),z.current(i),_.current&&_.current(s,u);},[]),Be=useMemo(()=>({layout:g,onLayoutChange:ze,renderPane:ne,activeId:Y,dismissIntentId:M,setContainerRef:Q,fullscreenPaneId:l,classNames:oe,onRemove:p,onFullscreenChange:a,snapThreshold:N,onResizeStart:h,onResize:y,onResizeEnd:Ae,renderResizer:v,minSplitPercentage:f,maxSplitPercentage:b}),[g,Y,M,Q,l,oe,p,a,N,h,y,v,f,b,ze,ne,Ae]),We=useMemo(()=>({removePane:he,addPane:Ee,swapPanes:Ce,splitPane:Te,updateSplitPercentage:Le,updatePaneMetadata:Me}),[he,Ee,Ce,Te,Le,Me]);return jsx(ce.Provider,{value:We,children:jsxs(de.Provider,{value:Be,children:[jsx(DndContext,{id:"zeugma-dnd-context",sensors:le,collisionDetection:pointerWithin,onDragStart:re,onDragMove:Xe,onDragEnd:Ye,children:ee}),Y&&r&&jsx(ot,{activeId:Y,render:r,className:`${n.dragOverlay||""} ${Y===M?n.dismissPreview||"zeugma-dismiss-preview":""}`.trim()})]})})};var at={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"}},lt={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"}},dt=({id:e,position:t,activeClassName:o})=>{let{setNodeRef:r,isOver:n}=useDroppable({id:e});return jsxs(Fragment,{children:[jsx("div",{ref:r,style:at[t]}),n&&jsx("div",{className:o,style:lt[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(dt,{id:`drop-root-${r}`,position:r,activeClassName:o},r))});function Se({containerRef:e,isRow:t,direction:o,splitPercentage:r,resizerSize:n,snapThreshold:l,layout:a,currentNode:p,onLayoutChange:C,onResizeStart:N,onResizeEnd:R}){let{onResizeStart:c,onResize:h,onResizeEnd:y,minSplitPercentage:D=5,maxSplitPercentage:v=95}=X();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),N&&N(),c&&c(p);let x=b.getBoundingClientRect(),K=f.clientX,ee=f.clientY,g=r,P=f.currentTarget;P.setAttribute("data-resizing","true");let Y=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(S=>S!==P&&S.getAttribute("data-direction")===o).map(S=>{let I=S.getBoundingClientRect();return t?I.left+I.width/2:I.top+I.height/2}),B=g,M=S=>{let I=t?(S.clientX-K)/x.width*100:(S.clientY-ee)/x.height*100,Q=g+I,q=t?x.left+(x.width-n)*(Q/100)+n/2:x.top+(x.height-n)*(Q/100)+n/2,T=1/0,z=null;for(let le of Y){let re=Math.abs(q-le);re<l&&re<T&&(T=re,z=le);}let te=Q;z!==null&&(te=t?(z-n/2-x.left)/(x.width-n)*100:(z-n/2-x.top)/(x.height-n)*100);let _=Math.max(D,Math.min(v,te));B=_;let ne=b.children[0],oe=b.children[b.children.length-1];ne&&oe&&(ne.style.flex=`${_} 1 0%`,oe.style.flex=`${100-_} 1 0%`),h&&h(p,_);},W=()=>{document.body.classList.remove("zeugma-resizing"),P.removeAttribute("data-resizing");let S=document.getElementById("zeugma-global-cursor-style");S&&S.remove(),document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",W);let I=J(a,p,B);console.log("onLayoutChange (finalized) called with percentage:",B),C(I),R&&R(),y&&y(p,B);};document.addEventListener("pointermove",M),document.addEventListener("pointerup",W);},[e,t,o,r,n,l,a,p,C,N,R,c,h,y,D,v])}var ht=({currentNode:e,resizerSize:t,snapThreshold:o,renderResizer:r})=>{let{layout:n,onLayoutChange:l,classNames:a,renderResizer:p}=X(),[C,N]=useState(false),R=r||p,c=useRef(null),{direction:h,first:y,second:D,splitPercentage:v}=e,f=h==="row",b=Se({containerRef:c,isRow:f,direction:h,splitPercentage:v,resizerSize:t,snapThreshold:o??8,layout:n,currentNode:e,onLayoutChange:l,onResizeStart:()=>N(true),onResizeEnd:()=>N(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(we,{tree:y,resizerSize:t,snapThreshold:o,renderResizer:r})}),R?R({direction:h,splitPercentage:v,resizerSize:t,isResizing:C,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(we,{tree:D,resizerSize:t,snapThreshold:o,renderResizer:r})})]})},we=({tree:e,resizerSize:t=4,snapThreshold:o,renderResizer:r})=>{let{layout:n,renderPane:l,activeId:a,dismissIntentId:p,setContainerRef:C,classNames:N,fullscreenPaneId:R,snapThreshold:c}=X(),h=o!==void 0?o:c,y=useMemo(()=>e!==void 0||!a?false:Z(n,a)!==null,[e,n,a]);if(R&&!e)return jsx("div",{style:{width:"100%",height:"100%",position:"relative"},children:l(R)});let D=e!==void 0?e:n;if(!D)return null;let v=()=>D.type==="pane"?jsx("div",{style:{width:"100%",height:"100%",position:"relative"},children:l(D.paneId)}):jsx(ht,{currentNode:D,resizerSize:t,snapThreshold:h,renderResizer:r});return e===void 0?jsxs("div",{ref:C,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:y,dropPreviewClassName:N.dropPreview})]}):v()};var ge=createContext(null);var Rt={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"}},xt={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:Rt[t]}),n&&jsx("div",{className:o,style:xt[t]})]})},Nt=({id:e,children:t,style:o})=>{let{layout:r,activeId:n,classNames:l,fullscreenPaneId:a,onRemove:p,onFullscreenChange:C}=X(),{removePane:N,updatePaneMetadata:R}=be(),c=n!==null&&n!==e,{attributes:h,listeners:y,setNodeRef:D,isDragging:v}=useDraggable({id:e}),f=n===e||v,b=a===e,x=useMemo(()=>A(r,e),[r,e])?.metadata,K=useMemo(()=>({isDragging:f,isFullscreen:b,toggleFullscreen:()=>C?.(b?null:e),remove:()=>{b&&C?.(null),p?p(e):N(e);},metadata:x,updateMetadata:g=>{R(e,g);}}),[f,b,C,e,p,N,x,R]),ee=useMemo(()=>({...y,...h}),[y,h]);return jsx(ge.Provider,{value:ee,children:jsxs("div",{ref:D,className:l.pane,style:{position:"relative",width:"100%",height:"100%",...o},children:[t(K),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 wt=({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{Je as DEFAULT_DRAG_ACTIVATION_DISTANCE,Zt as DEFAULT_RESIZER_SIZE,Ge as DEFAULT_SNAP_THRESHOLD,rt as DashboardProvider,wt as DragHandle,Nt as Pane,we as PaneTree,$e as addPane,A as findPane,Z as removePane,se as splitPane,Ve as splitRoot,Pe as swapPanes,ue as updatePaneMetadata,J as updateSplitPercentage,be as useDashboardActions,X as useDashboardState,Se 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 ae=createContext(void 0),le=createContext(void 0);var K=()=>{let e=useContext(ae);if(!e)throw new Error("useDashboardState must be used within a DashboardProvider");return e},Pe=()=>{let e=useContext(le);if(!e)throw new Error("useDashboardActions must be used within a DashboardProvider");return e};function B(e,t){if(e===null)return null;if(e.type==="pane")return e.paneId===t?null:e;let n=B(e.first,t),r=B(e.second,t);return n===null?r:r===null?n:{...e,first:n,second:r}}function ie(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,c=r==="left"||r==="top";return {type:"split",direction:n,first:c?i:e,second:c?e:i,splitPercentage:50}}return e}return {...e,first:ie(e.first,t,n,r,o)||e.first,second:ie(e.second,t,n,r,o)||e.second}}function xe(e,t,n){if(e===null)return null;let r=_(e,t),o=_(e,n);if(!r||!o)return e;function i(c){return c.type==="pane"?c.paneId===t?{...o}:c.paneId===n?{...r}:c:{...c,first:i(c.first),second:i(c.second)}}return i(e)}function _e(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 j(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:j(e.first,t,n)||e.first,second:j(e.second,t,n)||e.second}:e}function Oe(e,t,n){let r=_(e,t)??{type:"pane",paneId:t},o=B(e,t);if(o===null)return {...r};let i=n==="left"||n==="right"?"row":"column",c=n==="left"||n==="top",d={...r};return {type:"split",direction:i,first:c?d:o,second:c?o:d,splitPercentage:50}}function _(e,t){return e===null?null:e.type==="pane"?e.paneId===t?e:null:_(e.first,t)??_(e.second,t)}function ce(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:ce(e.first,t,n)??e.first,second:ce(e.second,t,n)??e.second}}var rt=8,it=8,Jt=4;var pt=({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")}]},ft=({layout:e,onChange:t,renderPane:n,renderDragOverlay:r,classNames:o={},fullscreenPaneId:i=null,onFullscreenChange:c,onRemove:d,dragActivationDistance:w=8,snapThreshold:b=8,onDragStart:I,onDragEnd:s,onResizeStart:x,onResize:m,onResizeEnd:z,minSplitPercentage:C=5,maxSplitPercentage:T=95,enableDragToDismiss:S=false,dismissThreshold:y=60,onDismissIntentChange:V,children:L})=>{let[E,f]=useState(e),[ne,oe]=useState(e);e!==ne&&(oe(e),f(e));let[v,M]=useState(null),[h,F]=useState(null),q=useRef(null),Z=useRef(null),g=useCallback(l=>{q.current=l;},[]),R=useRef(V);R.current=V;let P=useRef(E);P.current=E;let D=useRef(t);D.current=t;let k=useRef(n);k.current=n;let Y=useRef(z);Y.current=z;let ee=useCallback(l=>k.current(l),[]),Ie=useMemo(()=>o,[o.pane,o.dropPreview,o.swapPreview,o.dragOverlay,o.resizer,o.dismissPreview]),Je=useSensors(useSensor(Re,{activationConstraint:{distance:w}}),useSensor(De,{activationConstraint:{delay:250,tolerance:5}})),Qe=l=>{let p=l.active.id.toString();M(p),S&&q.current?Z.current=q.current.getBoundingClientRect():Z.current=null,I&&I(p);},je=l=>{if(!S)return;let p=l.active.id.toString(),a=Z.current;if(!a){h!==null&&(F(null),R.current?.(null));return}let u=l.activatorEvent,$=null,H=null;if(u instanceof MouseEvent||u instanceof PointerEvent)$=u.clientX+l.delta.x,H=u.clientY+l.delta.y;else if(typeof TouchEvent<"u"&&u instanceof TouchEvent){let N=u.touches[0]||u.changedTouches[0];N&&($=N.clientX+l.delta.x,H=N.clientY+l.delta.y);}let U=0;if($!==null&&H!==null){let N=0,A=0;$<a.left?N=a.left-$:$>a.right&&(N=$-a.right),H<a.top?A=a.top-H:H>a.bottom&&(A=H-a.bottom),U=Math.sqrt(N*N+A*A);}else {let N=l.active.rect.current.translated;if(N){let A=N.left+N.width/2,W=N.top+N.height/2,Q=0,te=0;A<a.left?Q=a.left-A:A>a.right&&(Q=A-a.right),W<a.top?te=a.top-W:W>a.bottom&&(te=W-a.bottom),U=Math.sqrt(Q*Q+te*te);}}U>y?h!==p&&(F(p),R.current?.(p)):h!==null&&(F(null),R.current?.(null));},et=l=>{M(null);let{active:p,over:a}=l,u=p.id.toString(),$=S&&h===u;if(F(null),R.current?.(null),Z.current=null,$){d?d(u):ve(u),s&&s(u,null,null);return}if(!a){s&&s(u,null,null);return}let H=a.id.toString(),U=H.match(/^drop-root-(left|right|top|bottom)$/);if(U){let[,G]=U,re=Oe(E,u,G);f(re),t(re),s&&s(u,"root",{type:"split",direction:G==="left"||G==="right"?"row":"column",position:G});return}let be=H.match(/^drop-center-(.+)$/);if(be){let[,G]=be;if(u!==G){let re=xe(E,u,G);f(re),t(re);}s&&s(u,G,{type:"swap",position:"center"});return}let N=H.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!N){s&&s(u,null,null);return}let[,A,W]=N;if(u===W){s&&s(u,null,null);return}let Q=A==="left"||A==="right"?"row":"column",te=_(E,u)??{type:"pane",paneId:u},ot=B(E,u),He=ie(ot,W,Q,A,te);f(He),t(He),s&&s(u,W,{type:"split",direction:Q,position:A});},ze=useCallback(l=>{f(l);},[]),ve=useCallback(l=>{let p=B(P.current,l);f(p),D.current(p);},[]),Ce=useCallback(l=>{let p=_e(P.current,l);f(p),D.current(p);},[]),Te=useCallback((l,p)=>{let a=xe(P.current,l,p);f(a),D.current(a);},[]),Le=useCallback((l,p,a,u)=>{let $=_(P.current,u)??{type:"pane",paneId:u},H=B(P.current,u),U=ie(H,l,p,a,$);f(U),D.current(U);},[]),Me=useCallback((l,p)=>{let a=j(P.current,l,p);f(a),D.current(a);},[]),Ae=useCallback((l,p)=>{let a=ce(P.current,l,p);f(a),D.current(a);},[]),Fe=useCallback((l,p)=>{let a=j(P.current,l,p);f(a),D.current(a),Y.current&&Y.current(l,p);},[]),tt=useMemo(()=>({layout:E,onLayoutChange:ze,renderPane:ee,activeId:v,dismissIntentId:h,setContainerRef:g,fullscreenPaneId:i,classNames:Ie,onRemove:d,onFullscreenChange:c,snapThreshold:b,onResizeStart:x,onResize:m,onResizeEnd:Fe,minSplitPercentage:C,maxSplitPercentage:T}),[E,v,h,g,i,Ie,d,c,b,x,m,C,T,ze,ee,Fe]),nt=useMemo(()=>({removePane:ve,addPane:Ce,swapPanes:Te,splitPane:Le,updateSplitPercentage:Me,updatePaneMetadata:Ae}),[ve,Ce,Te,Le,Me,Ae]);return jsx(le.Provider,{value:nt,children:jsxs(ae.Provider,{value:tt,children:[jsx(DndContext,{id:"zeugma-dnd-context",sensors:Je,collisionDetection:pointerWithin,onDragStart:Qe,onDragMove:je,onDragEnd:et,children:L}),v&&r&&jsx(pt,{activeId:v,render:r,className:`${o.dragOverlay||""} ${v===h?o.dismissPreview||"zeugma-dismiss-preview":""}`.trim()})]})})};var ht={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"}},vt={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"}},bt=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:r,isOver:o}=useDroppable({id:e});return jsxs(Fragment,{children:[jsx("div",{ref:r,style:ht[t]}),o&&jsx("div",{className:n,style:vt[t]})]})},ke=({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(bt,{id:`drop-root-${r}`,position:r,activeClassName:n},r))});function fe({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=d=>{n(d);},c=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let d=document.getElementById("zeugma-global-cursor-style");d&&d.remove(),document.removeEventListener("pointermove",i),document.removeEventListener("pointerup",c),r();};document.addEventListener("pointermove",i),document.addEventListener("pointerup",c);}function Ne({containerRef:e,isRow:t,direction:n,splitPercentage:r,resizerSize:o,snapThreshold:i,layout:c,currentNode:d,onLayoutChange:w,onResizeStart:b,onResizeEnd:I}){let{onResizeStart:s,onResize:x,onResizeEnd:m,minSplitPercentage:z=5,maxSplitPercentage:C=95}=K();return useCallback(T=>{T.preventDefault();let S=e.current;if(!S)return;b&&b(),s&&s(d);let y=S.getBoundingClientRect(),V=T.clientX,L=T.clientY,E=r,f=T.currentTarget,oe=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(M=>M!==f&&M.getAttribute("data-direction")===n).map(M=>{let h=M.getBoundingClientRect();return t?h.left+h.width/2:h.top+h.height/2}),v=E;fe({cursor:t?"col-resize":"row-resize",resizerEl:f,onMove:M=>{let h=t?(M.clientX-V)/y.width*100:(M.clientY-L)/y.height*100,F=E+h,q=t?y.left+(y.width-o)*(F/100)+o/2:y.top+(y.height-o)*(F/100)+o/2,Z=1/0,g=null;for(let Y of oe){let ee=Math.abs(q-Y);ee<i&&ee<Z&&(Z=ee,g=Y);}let R=F;g!==null&&(R=t?(g-o/2-y.left)/(y.width-o)*100:(g-o/2-y.top)/(y.height-o)*100);let P=Math.max(z,Math.min(C,R));v=P;let D=S.children[0],k=S.children[S.children.length-1];D&&k&&(D.style.flex=`${P} 1 0%`,k.style.flex=`${100-P} 1 0%`),x&&x(d,P);},onEnd:()=>{let M=j(c,d,v);w(M),I&&I(),m&&m(d,v);}});},[e,t,n,r,o,i,c,d,w,b,I,s,x,m,z,C])}var wt=({currentNode:e,resizerSize:t,snapThreshold:n})=>{let{layout:r,onLayoutChange:o,classNames:i}=K(),[c,d]=useState(false),w=useRef(null),{direction:b,first:I,second:s,splitPercentage:x}=e,m=b==="row",z=Ne({containerRef:w,isRow:m,direction:b,splitPercentage:x,resizerSize:t,snapThreshold:n??8,layout:r,currentNode:e,onLayoutChange:o,onResizeStart:()=>d(true),onResizeEnd:()=>d(false)});return jsxs("div",{ref:w,style:{display:"flex",flexDirection:m?"row":"column",width:"100%",height:"100%",overflow:"hidden"},children:[jsx("div",{style:{flex:`${x} 1 0%`,overflow:"hidden"},children:jsx(we,{tree:I,resizerSize:t,snapThreshold:n})}),jsx("div",{className:`zeugma-resizer ${i.resizer||""}`.trim(),"data-direction":b,"data-resizing":c||void 0,style:{width:m?`${t}px`:"100%",height:m?"100%":`${t}px`,cursor:m?"col-resize":"row-resize",position:"relative",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box",flexShrink:0},onPointerDown:z,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:c,setContainerRef:d,classNames:w,fullscreenPaneId:b,snapThreshold:I}=K(),s=n!==void 0?n:I,x=useMemo(()=>e!==void 0||!i?false:B(r,i)!==null,[e,r,i]);if(b&&!e)return jsx("div",{style:{width:"100%",height:"100%",position:"relative"},children:o(b)});let m=e!==void 0?e:r;if(!m)return null;let z=()=>m.type==="pane"?jsx("div",{style:{width:"100%",height:"100%",position:"relative"},children:o(m.paneId)}):jsx(wt,{currentNode:m,resizerSize:t,snapThreshold:s});return e===void 0?jsxs("div",{ref:d,className:`zeugma-dashboard-root ${i!==null&&i===c?"zeugma-dashboard-dismiss-active":""}`.trim(),style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[z(),jsx(ke,{activeId:i,hasOtherPanes:x,dropPreviewClassName:w.dropPreview})]}):z()};var qe="zeugma-height:",It="default-pane";function zt(e){try{let t=localStorage.getItem(qe+e);if(t!==null){let n=Number(t);if(Number.isFinite(n)&&n>0)return n}}catch{}return null}function Xe(e,t){try{localStorage.setItem(qe+e,String(Math.round(t)));}catch{}}var We=({children:e,active:t=true,height:n,onHeightChange:r,minHeight:o=100,maxHeight:i=1/0,persist:c,localStorageKey:d,resizerHeight:w=6,className:b,resizerClassName:I})=>{let s=c?d||It:null,x=()=>{let L=(s?zt(s):null)??n??400;return me(L,o,i)},[m,z]=useState(x),C=useRef(null),T=s?m:n??m,S=useRef(n);useEffect(()=>{if(n!==void 0&&n!==S.current){let L=me(n,o,i);z(L),s&&Xe(s,L);}S.current=n;},[n,o,i,s]);let y=useCallback(()=>i,[i]),V=useCallback(L=>{L.preventDefault();let E=L.clientY,f=T,ne=y(),oe=L.currentTarget,v=Ge(C.current),M=v?v.scrollTop:0,h=E,F=null,q=(g,R)=>{let P=R-M,k=g-E+P,Y=me(f+k,o,ne);return C.current&&(C.current.style.height=`${Y}px`),Y},Z=()=>{if(!v)return;let g=v===document.documentElement||v===document.body?{top:0,bottom:window.innerHeight}:v.getBoundingClientRect(),R=40,P=10,D=0;h>g.bottom-R?D=Math.min(1,(h-(g.bottom-R))/R)*P:h<g.top+R&&(D=-Math.min(1,(g.top+R-h)/R)*P),D!==0&&(v.scrollTop+=D,q(h,v.scrollTop)),F=requestAnimationFrame(Z);};F=requestAnimationFrame(Z),fe({cursor:"row-resize",resizerEl:oe,onMove:g=>{h=g.clientY,v&&q(h,v.scrollTop);},onEnd:()=>{F!==null&&cancelAnimationFrame(F);let g=f;C.current&&(g=C.current.getBoundingClientRect().height),g=me(g,o,ne),z(g),r&&r(g),s&&Xe(s,g);}});},[T,o,y,r,s]);return t?jsxs("div",{ref:C,className:`zeugma-resizable-container ${b||""}`.trim(),style:{height:`${T}px`,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:[jsx("div",{style:{height:`calc(100% - ${w}px)`,overflow:"hidden"},children:e}),jsx("div",{className:`zeugma-resizable-handle ${I||""}`.trim(),style:{height:`${w}px`,cursor:"row-resize",position:"relative",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box",flexShrink:0},onPointerDown:V,role:"separator","aria-orientation":"horizontal","aria-valuenow":Math.round(T),"aria-valuemin":o,"aria-valuemax":i===1/0?void 0:i})]}):jsx("div",{className:`zeugma-resizable-container disabled ${b||""}`.trim(),style:{height:"100%",position:"relative",overflow:"hidden",boxSizing:"border-box"},children:jsx("div",{style:{height:"100%",overflow:"hidden"},children:e})})};function me(e,t,n){return Math.max(t,Math.min(n,e))}function Ge(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:Ge(t)}var he=createContext(null);var At={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"}},Ft={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"}},Ke=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:r,isOver:o}=useDroppable({id:e});return jsxs(Fragment,{children:[jsx("div",{ref:r,style:At[t]}),o&&jsx("div",{className:n,style:Ft[t]})]})},Ht=({id:e,children:t,style:n})=>{let{layout:r,activeId:o,classNames:i,fullscreenPaneId:c,onRemove:d,onFullscreenChange:w}=K(),{removePane:b,updatePaneMetadata:I}=Pe(),s=o!==null&&o!==e,{attributes:x,listeners:m,setNodeRef:z,isDragging:C}=useDraggable({id:e}),T=o===e||C,S=c===e,V=useMemo(()=>_(r,e),[r,e])?.metadata,L=useMemo(()=>({isDragging:T,isFullscreen:S,toggleFullscreen:()=>w?.(S?null:e),remove:()=>{S&&w?.(null),d?d(e):b(e);},metadata:V,updateMetadata:f=>{I(e,f);}}),[T,S,w,e,d,b,V,I]),E=useMemo(()=>({...m,...x}),[m,x]);return jsx(he.Provider,{value:E,children:jsxs("div",{ref:z,className:i.pane,style:{position:"relative",width:"100%",height:"100%",...n},children:[t(L),s&&jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:[["top","bottom","left","right"].map(f=>jsx(Ke,{id:`drop-${f}-${e}`,position:f,activeClassName:i.dropPreview},f)),jsx(Ke,{id:`drop-center-${e}`,position:"center",activeClassName:i.swapPreview})]})]})})};var _t=({children:e,className:t,style:n})=>{let r=useContext(he);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{it as DEFAULT_DRAG_ACTIVATION_DISTANCE,Jt as DEFAULT_RESIZER_SIZE,rt as DEFAULT_SNAP_THRESHOLD,ft as DashboardProvider,_t as DragHandle,Ht as Pane,we as PaneTree,We as ResizableContainer,_e as addPane,fe as createDragSession,_ as findPane,B as removePane,ie as splitPane,Oe as splitRoot,xe as swapPanes,ce as updatePaneMetadata,j as updateSplitPercentage,Pe as useDashboardActions,K as useDashboardState,Ne as useResizer};//# sourceMappingURL=index.js.map
7
7
  //# sourceMappingURL=index.js.map