react-zeugma 1.4.0 → 2.0.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/README.md CHANGED
@@ -41,7 +41,7 @@ Import the core components and configure the layout state inside your React appl
41
41
 
42
42
  ```tsx
43
43
  import { useState } from 'react'
44
- import { DashboardProvider, PaneTree, Pane, DragHandle, TreeNode } from 'react-zeugma'
44
+ import { Zeugma, PaneTree, Pane, DragHandle, TreeNode } from 'react-zeugma'
45
45
 
46
46
  const initialLayout: TreeNode = {
47
47
  type: 'split',
@@ -81,11 +81,11 @@ export default function Dashboard() {
81
81
  const [layout, setLayout] = useState<TreeNode | null>(initialLayout)
82
82
 
83
83
  return (
84
- <DashboardProvider layout={layout} onChange={setLayout} renderPane={(id) => <MyPane id={id} />}>
84
+ <Zeugma layout={layout} onChange={setLayout} renderPane={(id) => <MyPane id={id} />}>
85
85
  <div className="w-screen h-screen">
86
86
  <PaneTree />
87
87
  </div>
88
- </DashboardProvider>
88
+ </Zeugma>
89
89
  )
90
90
  }
91
91
  ```
@@ -94,7 +94,7 @@ export default function Dashboard() {
94
94
 
95
95
  ## API Reference
96
96
 
97
- ### `<DashboardProvider>`
97
+ ### `<Zeugma>`
98
98
 
99
99
  The context provider that sets up the drag-and-drop state machine, monitors active drags, and registers layout change notifications.
100
100
 
@@ -122,7 +122,7 @@ The context provider that sets up the drag-and-drop state machine, monitors acti
122
122
 
123
123
  ### `<PaneTree>`
124
124
 
125
- Recursively renders the split nodes and pane nodes. Must be placed inside `<DashboardProvider>`.
125
+ Recursively renders the split nodes and pane nodes. Must be placed inside `<Zeugma>`.
126
126
 
127
127
  | Prop | Type | Required | Description |
128
128
  | ------------- | ------------------ | -------- | ------------------------------------------------------------------- |
@@ -210,7 +210,7 @@ Recursively searches the layout tree and returns the target `PaneNode` if found,
210
210
  Use custom CSS or styling rules to style resizers, dragging states, drop previews, or active nodes by overriding `classNames` in the provider.
211
211
 
212
212
  ```tsx
213
- <DashboardProvider
213
+ <Zeugma
214
214
  layout={layout}
215
215
  onChange={setLayout}
216
216
  renderPane={renderPane}
@@ -225,7 +225,7 @@ Use custom CSS or styling rules to style resizers, dragging states, drop preview
225
225
  }}
226
226
  >
227
227
  <PaneTree />
228
- </DashboardProvider>
228
+ </Zeugma>
229
229
  ```
230
230
 
231
231
  ---
@@ -273,12 +273,12 @@ export interface PaneRenderProps {
273
273
  ) => void
274
274
  }
275
275
 
276
- export interface DashboardStateValue {
276
+ export interface ZeugmaStateValue {
277
277
  layout: TreeNode | null
278
278
  onLayoutChange: (newLayout: TreeNode | null) => void
279
279
  renderPane: (paneId: string) => ReactNode
280
280
  activeId: string | null
281
- draggedOutId: string | null
281
+ dismissIntentId: string | null
282
282
  setContainerRef: (element: HTMLElement | null) => void
283
283
  fullscreenPaneId: string | null
284
284
  classNames: ZeugmaClassNames
@@ -292,7 +292,7 @@ export interface DashboardStateValue {
292
292
  maxSplitPercentage?: number
293
293
  }
294
294
 
295
- export interface DashboardActionsValue {
295
+ export interface ZeugmaActionsValue {
296
296
  removePane: (paneId: string) => void
297
297
  addPane: (paneId: string) => void
298
298
  swapPanes: (paneIdA: string, paneIdB: string) => void
@@ -361,7 +361,7 @@ export type TreeNode = SplitNode | PaneNode
361
361
 
362
362
  ## 2. Core Components
363
363
 
364
- ### `<DashboardProvider>`
364
+ ### `<Zeugma>`
365
365
 
366
366
  The root context provider. It handles the drag-and-drop event loop and coordinates the layout state.
367
367
 
@@ -389,7 +389,7 @@ The root context provider. It handles the drag-and-drop event loop and coordinat
389
389
 
390
390
  ### `<PaneTree>`
391
391
 
392
- Recursively renders the split nodes and pane nodes. Must be placed inside `<DashboardProvider>`.
392
+ Recursively renders the split nodes and pane nodes. Must be placed inside `<Zeugma>`.
393
393
 
394
394
  #### Props
395
395
 
@@ -467,10 +467,10 @@ Import these helpers from `react-zeugma` to manipulate the tree layout programma
467
467
 
468
468
  Alternatively, you can consume state and mutation helpers directly from the context hooks:
469
469
 
470
- - **`useDashboardState()`**: Returns the reactive state values (e.g., `layout`, `activeId`, `classNames`). Consumers of this hook will re-render whenever layout state updates.
471
- - **`useDashboardActions()`**: Returns the stable layout mutation actions (e.g., `removePane`, `splitPane`). Because these actions have a permanent identity, consumers of this hook **will not** re-render when layout state changes, providing a significant performance optimization.
470
+ - **`useZeugmaState()`**: Returns the reactive state values (e.g., `layout`, `activeId`, `classNames`). Consumers of this hook will re-render whenever layout state updates.
471
+ - **`useZeugmaActions()`**: Returns the stable layout mutation actions (e.g., `removePane`, `splitPane`). Because these actions have a permanent identity, consumers of this hook **will not** re-render when layout state changes, providing a significant performance optimization.
472
472
 
473
- The actions returned by `useDashboardActions()` are:
473
+ The actions returned by `useZeugmaActions()` are:
474
474
 
475
475
  - **`removePane(paneId: string) => void`**
476
476
  - **`addPane(paneId: string) => void`**
@@ -485,7 +485,7 @@ The actions returned by `useDashboardActions()` are:
485
485
 
486
486
  ```tsx
487
487
  import { useState } from 'react'
488
- import { DashboardProvider, PaneTree, Pane, DragHandle, TreeNode } from 'react-zeugma'
488
+ import { Zeugma, PaneTree, Pane, DragHandle, TreeNode } from 'react-zeugma'
489
489
 
490
490
  const initialLayout: TreeNode = {
491
491
  type: 'split',
@@ -526,7 +526,7 @@ export default function App() {
526
526
  }
527
527
 
528
528
  return (
529
- <DashboardProvider
529
+ <Zeugma
530
530
  layout={layout}
531
531
  onChange={setLayout}
532
532
  renderPane={(id) => <CustomPane id={id} />}
@@ -537,7 +537,7 @@ export default function App() {
537
537
  <div style={{ width: '100vw', height: '100vh' }}>
538
538
  <PaneTree />
539
539
  </div>
540
- </DashboardProvider>
540
+ </Zeugma>
541
541
  )
542
542
  }
543
543
  ```
@@ -546,7 +546,7 @@ export default function App() {
546
546
 
547
547
  ## 5. Styling Customization
548
548
 
549
- `react-zeugma` is style-agnostic and relies on class name configuration for visual states. Define classes in your styling framework and pass them via the `classNames` prop on `<DashboardProvider>`:
549
+ `react-zeugma` is style-agnostic and relies on class name configuration for visual states. Define classes in your styling framework and pass them via the `classNames` prop on `<Zeugma>`:
550
550
 
551
551
  ```ts
552
552
  interface ZeugmaClassNames {
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
- 'use strict';var react=require('react'),core=require('@dnd-kit/core'),jsxRuntime=require('react/jsx-runtime');var ae=react.createContext(void 0),le=react.createContext(void 0);var K=()=>{let e=react.useContext(ae);if(!e)throw new Error("useDashboardState must be used within a DashboardProvider");return e},Pe=()=>{let e=react.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=react.useRef(null);return react.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)},[]),jsxRuntime.jsx("div",{ref:r,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})},Re=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},De=class extends core.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]=react.useState(e),[ne,oe]=react.useState(e);e!==ne&&(oe(e),f(e));let[v,M]=react.useState(null),[h,F]=react.useState(null),q=react.useRef(null),Z=react.useRef(null),g=react.useCallback(l=>{q.current=l;},[]),R=react.useRef(V);R.current=V;let P=react.useRef(E);P.current=E;let D=react.useRef(t);D.current=t;let k=react.useRef(n);k.current=n;let Y=react.useRef(z);Y.current=z;let ee=react.useCallback(l=>k.current(l),[]),Ie=react.useMemo(()=>o,[o.pane,o.dropPreview,o.swapPreview,o.dragOverlay,o.resizer,o.dismissPreview]),Je=core.useSensors(core.useSensor(Re,{activationConstraint:{distance:w}}),core.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=react.useCallback(l=>{f(l);},[]),ve=react.useCallback(l=>{let p=B(P.current,l);f(p),D.current(p);},[]),Ce=react.useCallback(l=>{let p=_e(P.current,l);f(p),D.current(p);},[]),Te=react.useCallback((l,p)=>{let a=xe(P.current,l,p);f(a),D.current(a);},[]),Le=react.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=react.useCallback((l,p)=>{let a=j(P.current,l,p);f(a),D.current(a);},[]),Ae=react.useCallback((l,p)=>{let a=ce(P.current,l,p);f(a),D.current(a);},[]),Fe=react.useCallback((l,p)=>{let a=j(P.current,l,p);f(a),D.current(a),Y.current&&Y.current(l,p);},[]),tt=react.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=react.useMemo(()=>({removePane:ve,addPane:Ce,swapPanes:Te,splitPane:Le,updateSplitPercentage:Me,updatePaneMetadata:Ae}),[ve,Ce,Te,Le,Me,Ae]);return jsxRuntime.jsx(le.Provider,{value:nt,children:jsxRuntime.jsxs(ae.Provider,{value:tt,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",sensors:Je,collisionDetection:core.pointerWithin,onDragStart:Qe,onDragMove:je,onDragEnd:et,children:L}),v&&r&&jsxRuntime.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}=core.useDroppable({id:e});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:r,style:ht[t]}),o&&jsxRuntime.jsx("div",{className:n,style:vt[t]})]})},ke=({activeId:e,hasOtherPanes:t,dropPreviewClassName:n})=>!e||!t?null:jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:30,pointerEvents:"none"},children:["top","bottom","left","right"].map(r=>jsxRuntime.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=`
1
+ 'use strict';var react=require('react'),core=require('@dnd-kit/core'),jsxRuntime=require('react/jsx-runtime');var se=react.createContext(void 0),ae=react.createContext(void 0);var G=()=>{let e=react.useContext(se);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},Pe=()=>{let e=react.useContext(ae);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e};function k(e,t){if(e===null)return null;if(e.type==="pane")return e.paneId===t?null:e;let n=k(e.first,t),r=k(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,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:re(e.first,t,n,r,o)||e.first,second:re(e.second,t,n,r,o)||e.second}}function xe(e,t,n){if(e===null)return null;let r=V(e,t),o=V(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 Fe(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=V(e,t)??{type:"pane",paneId:t},o=k(e,t);if(o===null)return {...r};let i=n==="left"||n==="right"?"row":"column",c=n==="left"||n==="top",u={...r};return {type:"split",direction:i,first:c?u:o,second:c?o:u,splitPercentage:50}}function V(e,t){return e===null?null:e.type==="pane"?e.paneId===t?e:null:V(e.first,t)??V(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 et=8,tt=8,Xt=4;var _e=({activeId:e,render:t,className:n})=>{let r=react.useRef(null);return react.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)},[]),jsxRuntime.jsx("div",{ref:r,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var ce=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},ue=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};var ut=({layout:e,onChange:t,renderPane:n,renderDragOverlay:r,classNames:o={},fullscreenPaneId:i=null,onFullscreenChange:c,onRemove:u,dragActivationDistance:w=8,snapThreshold:P=8,onDragStart:N,onDragEnd:s,onResizeStart:x,onResize:g,onResizeEnd:y,minSplitPercentage:z=5,maxSplitPercentage:D=95,enableDragToDismiss:S=false,dismissThreshold:E=60,onDismissIntentChange:H,children:I})=>{let[d,m]=react.useState(e),[ee,te]=react.useState(e);e!==ee&&(te(e),m(e));let[b,T]=react.useState(null),[h,M]=react.useState(null),X=react.useRef(null),$=react.useRef(null),v=react.useCallback(l=>{X.current=l;},[]),C=react.useCallback(l=>n(l),[n]),A=react.useMemo(()=>o,[o.pane,o.dropPreview,o.swapPreview,o.dragOverlay,o.resizer,o.dismissPreview]),_=core.useSensors(core.useSensor(ce,{activationConstraint:{distance:w}}),core.useSensor(ue,{activationConstraint:{delay:250,tolerance:5}})),B=l=>{let f=l.active.id.toString();T(f),S&&X.current?$.current=X.current.getBoundingClientRect():$.current=null,N&&N(f);},K=l=>{if(!S)return;let f=l.active.id.toString(),a=$.current;if(!a){h!==null&&(M(null),H?.(null));return}let p=l.activatorEvent,F=null,Z=null;if(p instanceof MouseEvent||p instanceof PointerEvent)F=p.clientX+l.delta.x,Z=p.clientY+l.delta.y;else if(typeof TouchEvent<"u"&&p instanceof TouchEvent){let R=p.touches[0]||p.changedTouches[0];R&&(F=R.clientX+l.delta.x,Z=R.clientY+l.delta.y);}let Y=0;if(F!==null&&Z!==null){let R=0,L=0;F<a.left?R=a.left-F:F>a.right&&(R=F-a.right),Z<a.top?L=a.top-Z:Z>a.bottom&&(L=Z-a.bottom),Y=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),Y=Math.sqrt(J*J+j*j);}}Y>E?h!==f&&(M(f),H?.(f)):h!==null&&(M(null),H?.(null));},ne=l=>{T(null);let{active:f,over:a}=l,p=f.id.toString(),F=S&&h===p;if(M(null),H?.(null),$.current=null,F){u?u(p):he(p),s&&s(p,null,null);return}if(!a){s&&s(p,null,null);return}let Z=a.id.toString(),Y=Z.match(/^drop-root-(left|right|top|bottom)$/);if(Y){let[,W]=Y,oe=$e(d,p,W);m(oe),t(oe),s&&s(p,"root",{type:"split",direction:W==="left"||W==="right"?"row":"column",position:W});return}let be=Z.match(/^drop-center-(.+)$/);if(be){let[,W]=be;if(p!==W){let oe=xe(d,p,W);m(oe),t(oe);}s&&s(p,W,{type:"swap",position:"center"});return}let R=Z.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=V(d,p)??{type:"pane",paneId:p},je=k(d,p),Ze=re(je,q,J,L,j);m(Ze),t(Ze),s&&s(p,q,{type:"split",direction:J,position:L});},ze=react.useCallback(l=>{m(l),t(l);},[t]),he=react.useCallback(l=>{let f=k(d,l);m(f),t(f);},[d,t]),De=react.useCallback(l=>{let f=Fe(d,l);m(f),t(f);},[d,t]),Ie=react.useCallback((l,f)=>{let a=xe(d,l,f);m(a),t(a);},[d,t]),Te=react.useCallback((l,f,a,p)=>{let F=V(d,p)??{type:"pane",paneId:p},Z=k(d,p),Y=re(Z,l,f,a,F);m(Y),t(Y);},[d,t]),Ce=react.useCallback((l,f)=>{let a=Q(d,l,f);m(a),t(a);},[d,t]),Le=react.useCallback((l,f)=>{let a=le(d,l,f);m(a),t(a);},[d,t]),Me=react.useCallback((l,f)=>{let a=Q(d,l,f);m(a),t(a),y&&y(l,f);},[d,t,y]),Je=react.useMemo(()=>({layout:d,onLayoutChange:ze,renderPane:C,activeId:b,dismissIntentId:h,setContainerRef:v,fullscreenPaneId:i,classNames:A,onRemove:u,onFullscreenChange:c,snapThreshold:P,onResizeStart:x,onResize:g,onResizeEnd:Me,minSplitPercentage:z,maxSplitPercentage:D}),[d,b,h,v,i,A,u,c,P,x,g,z,D,ze,C,Me]),Qe=react.useMemo(()=>({removePane:he,addPane:De,swapPanes:Ie,splitPane:Te,updateSplitPercentage:Ce,updatePaneMetadata:Le}),[he,De,Ie,Te,Ce,Le]);return jsxRuntime.jsx(ae.Provider,{value:Qe,children:jsxRuntime.jsxs(se.Provider,{value:Je,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",sensors:_,collisionDetection:core.pointerWithin,onDragStart:B,onDragMove:K,onDragEnd:ne,children:I}),b&&r&&jsxRuntime.jsx(_e,{activeId:b,render:r,className:`${o.dragOverlay||""} ${b===h?o.dismissPreview||"zeugma-dismiss-preview":""}`.trim()})]})})};var ft={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"}},mt={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"}},gt=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:r,isOver:o}=core.useDroppable({id:e});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:r,style:ft[t]}),o&&jsxRuntime.jsx("div",{className:n,style:mt[t]})]})},Ye=({activeId:e,hasOtherPanes:t,dropPreviewClassName:n})=>!e||!t?null:jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:30,pointerEvents:"none"},children:["top","bottom","left","right"].map(r=>jsxRuntime.jsx(gt,{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
2
  * {
3
3
  cursor: ${e} !important;
4
4
  user-select: none !important;
5
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 react.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]=react.useState(false),w=react.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 jsxRuntime.jsxs("div",{ref:w,style:{display:"flex",flexDirection:m?"row":"column",width:"100%",height:"100%",overflow:"hidden"},children:[jsxRuntime.jsx("div",{style:{flex:`${x} 1 0%`,overflow:"hidden"},children:jsxRuntime.jsx(we,{tree:I,resizerSize:t,snapThreshold:n})}),jsxRuntime.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}),jsxRuntime.jsx("div",{style:{flex:`${100-x} 1 0%`,overflow:"hidden"},children:jsxRuntime.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=react.useMemo(()=>e!==void 0||!i?false:B(r,i)!==null,[e,r,i]);if(b&&!e)return jsxRuntime.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"?jsxRuntime.jsx("div",{style:{width:"100%",height:"100%",position:"relative"},children:o(m.paneId)}):jsxRuntime.jsx(wt,{currentNode:m,resizerSize:t,snapThreshold:s});return e===void 0?jsxRuntime.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(),jsxRuntime.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]=react.useState(x),C=react.useRef(null),T=s?m:n??m,S=react.useRef(n);react.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=react.useCallback(()=>i,[i]),V=react.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?jsxRuntime.jsxs("div",{ref:C,className:`zeugma-resizable-container ${b||""}`.trim(),style:{height:`${T}px`,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:[jsxRuntime.jsx("div",{style:{height:`calc(100% - ${w}px)`,overflow:"hidden"},children:e}),jsxRuntime.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})]}):jsxRuntime.jsx("div",{className:`zeugma-resizable-container disabled ${b||""}`.trim(),style:{height:"100%",position:"relative",overflow:"hidden",boxSizing:"border-box"},children:jsxRuntime.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=react.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}=core.useDroppable({id:e});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:r,style:At[t]}),o&&jsxRuntime.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}=core.useDraggable({id:e}),T=o===e||C,S=c===e,V=react.useMemo(()=>_(r,e),[r,e])?.metadata,L=react.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=react.useMemo(()=>({...m,...x}),[m,x]);return jsxRuntime.jsx(he.Provider,{value:E,children:jsxRuntime.jsxs("div",{ref:z,className:i.pane,style:{position:"relative",width:"100%",height:"100%",...n},children:[t(L),s&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:[["top","bottom","left","right"].map(f=>jsxRuntime.jsx(Ke,{id:`drop-${f}-${e}`,position:f,activeClassName:i.dropPreview},f)),jsxRuntime.jsx(Ke,{id:`drop-center-${e}`,position:"center",activeClassName:i.swapPreview})]})]})})};var _t=({children:e,className:t,style:n})=>{let r=react.useContext(he);if(!r)throw new Error("<DragHandle> must be used inside a <Pane>");return jsxRuntime.jsx("div",{className:t,style:{cursor:"grab",userSelect:"none",touchAction:"none",...n},...r,children:e})};exports.DEFAULT_DRAG_ACTIVATION_DISTANCE=it;exports.DEFAULT_RESIZER_SIZE=Jt;exports.DEFAULT_SNAP_THRESHOLD=rt;exports.DashboardProvider=ft;exports.DragHandle=_t;exports.Pane=Ht;exports.PaneTree=we;exports.ResizableContainer=We;exports.addPane=_e;exports.createDragSession=fe;exports.findPane=_;exports.removePane=B;exports.splitPane=ie;exports.splitRoot=Oe;exports.swapPanes=xe;exports.updatePaneMetadata=ce;exports.updateSplitPercentage=j;exports.useDashboardActions=Pe;exports.useDashboardState=K;exports.useResizer=Ne;//# sourceMappingURL=index.cjs.map
6
+ `,document.head.appendChild(o),t.setAttribute("data-resizing","true");let i=u=>{n(u);},c=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let u=document.getElementById("zeugma-global-cursor-style");u&&u.remove(),document.removeEventListener("pointermove",i),document.removeEventListener("pointerup",c),r();};document.addEventListener("pointermove",i),document.addEventListener("pointerup",c);}function we({containerRef:e,isRow:t,direction:n,splitPercentage:r,resizerSize:o,snapThreshold:i,layout:c,currentNode:u,onLayoutChange:w,onResizeStart:P,onResizeEnd:N}){let{onResizeStart:s,onResize:x,onResizeEnd:g,minSplitPercentage:y=5,maxSplitPercentage:z=95}=G();return react.useCallback(D=>{D.preventDefault();let S=e.current;if(!S)return;P&&P(),s&&s(u);let E=S.getBoundingClientRect(),H=D.clientX,I=D.clientY,d=r,m=D.currentTarget,te=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(T=>T!==m&&T.getAttribute("data-direction")===n).map(T=>{let h=T.getBoundingClientRect();return t?h.left+h.width/2:h.top+h.height/2}),b=d;fe({cursor:t?"col-resize":"row-resize",resizerEl:m,onMove:T=>{let h=t?(T.clientX-H)/E.width*100:(T.clientY-I)/E.height*100,M=d+h,X=t?E.left+(E.width-o)*(M/100)+o/2:E.top+(E.height-o)*(M/100)+o/2,$=1/0,v=null;for(let K of te){let ne=Math.abs(X-K);ne<i&&ne<$&&($=ne,v=K);}let C=M;v!==null&&(C=t?(v-o/2-E.left)/(E.width-o)*100:(v-o/2-E.top)/(E.height-o)*100);let A=Math.max(y,Math.min(z,C));b=A;let _=S.children[0],B=S.children[S.children.length-1];_&&B&&(_.style.flex=`${A} 1 0%`,B.style.flex=`${100-A} 1 0%`),x&&x(u,A);},onEnd:()=>{let T=Q(c,u,b);w(T),N&&N(),g&&g(u,b);}});},[e,t,n,r,o,i,c,u,w,P,N,s,x,g,y,z])}var Rt=({currentNode:e,resizerSize:t,snapThreshold:n})=>{let{layout:r,onLayoutChange:o,classNames:i}=G(),[c,u]=react.useState(false),w=react.useRef(null),{direction:P,first:N,second:s,splitPercentage:x}=e,g=P==="row",y=we({containerRef:w,isRow:g,direction:P,splitPercentage:x,resizerSize:t,snapThreshold:n??8,layout:r,currentNode:e,onLayoutChange:o,onResizeStart:()=>u(true),onResizeEnd:()=>u(false)});return jsxRuntime.jsxs("div",{ref:w,style:{display:"flex",flexDirection:g?"row":"column",width:"100%",height:"100%",overflow:"hidden"},children:[jsxRuntime.jsx("div",{style:{flex:`${x} 1 0%`,overflow:"hidden"},children:jsxRuntime.jsx(ye,{tree:N,resizerSize:t,snapThreshold:n})}),jsxRuntime.jsx("div",{className:`zeugma-resizer ${i.resizer||""}`.trim(),"data-direction":P,"data-resizing":c||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:y,role:"separator","aria-valuenow":x,"aria-valuemin":5,"aria-valuemax":95}),jsxRuntime.jsx("div",{style:{flex:`${100-x} 1 0%`,overflow:"hidden"},children:jsxRuntime.jsx(ye,{tree:s,resizerSize:t,snapThreshold:n})})]})},ye=({tree:e,resizerSize:t=4,snapThreshold:n})=>{let{layout:r,renderPane:o,activeId:i,dismissIntentId:c,setContainerRef:u,classNames:w,fullscreenPaneId:P,snapThreshold:N}=G(),s=n!==void 0?n:N,x=react.useMemo(()=>e!==void 0||!i?false:k(r,i)!==null,[e,r,i]);if(P&&!e)return jsxRuntime.jsx("div",{style:{width:"100%",height:"100%",position:"relative"},children:o(P)});let g=e!==void 0?e:r;if(!g)return null;let y=()=>g.type==="pane"?jsxRuntime.jsx("div",{style:{width:"100%",height:"100%",position:"relative"},children:o(g.paneId)}):jsxRuntime.jsx(Rt,{currentNode:g,resizerSize:t,snapThreshold:s});return e===void 0?jsxRuntime.jsxs("div",{ref:u,className:`zeugma-dashboard-root ${i!==null&&i===c?"zeugma-dashboard-dismiss-active":""}`.trim(),style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[y(),jsxRuntime.jsx(Ye,{activeId:i,hasOtherPanes:x,dropPreviewClassName:w.dropPreview})]}):y()};var qe="zeugma-height:",Et="default-pane";function Nt(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 Be(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:u,resizerHeight:w=6,className:P,resizerClassName:N})=>{let s=c?u||Et:null,x=()=>{let I=(s?Nt(s):null)??n??400;return me(I,o,i)},[g,y]=react.useState(x),z=react.useRef(null),D=s?g:n??g,S=react.useRef(n);react.useEffect(()=>{if(n!==void 0&&n!==S.current){let I=me(n,o,i);y(I),s&&Be(s,I);}S.current=n;},[n,o,i,s]);let E=react.useCallback(()=>i,[i]),H=react.useCallback(I=>{I.preventDefault();let d=I.clientY,m=D,ee=E(),te=I.currentTarget,b=Ge(z.current),T=b?b.scrollTop:0,h=d,M=null,X=(v,C)=>{let A=C-T,B=v-d+A,K=me(m+B,o,ee);return z.current&&(z.current.style.height=`${K}px`),K},$=()=>{if(!b)return;let v=b===document.documentElement||b===document.body?{top:0,bottom:window.innerHeight}:b.getBoundingClientRect(),C=40,A=10,_=0;h>v.bottom-C?_=Math.min(1,(h-(v.bottom-C))/C)*A:h<v.top+C&&(_=-Math.min(1,(v.top+C-h)/C)*A),_!==0&&(b.scrollTop+=_,X(h,b.scrollTop)),M=requestAnimationFrame($);};M=requestAnimationFrame($),fe({cursor:"row-resize",resizerEl:te,onMove:v=>{h=v.clientY,b&&X(h,b.scrollTop);},onEnd:()=>{M!==null&&cancelAnimationFrame(M);let v=m;z.current&&(v=z.current.getBoundingClientRect().height),v=me(v,o,ee),y(v),r&&r(v),s&&Be(s,v);}});},[D,o,E,r,s]);return t?jsxRuntime.jsxs("div",{ref:z,className:`zeugma-resizable-container ${P||""}`.trim(),style:{height:`${D}px`,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:[jsxRuntime.jsx("div",{style:{height:`calc(100% - ${w}px)`,overflow:"hidden"},children:e}),jsxRuntime.jsx("div",{className:`zeugma-resizable-handle ${N||""}`.trim(),style:{height:`${w}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(D),"aria-valuemin":o,"aria-valuemax":i===1/0?void 0:i})]}):jsxRuntime.jsx("div",{className:`zeugma-resizable-container disabled ${P||""}`.trim(),style:{height:"100%",position:"relative",overflow:"hidden",boxSizing:"border-box"},children:jsxRuntime.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 ve=react.createContext(null);var Ct={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"}},Lt={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}=core.useDroppable({id:e});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:r,style:Ct[t]}),o&&jsxRuntime.jsx("div",{className:n,style:Lt[t]})]})},Mt=({id:e,children:t,style:n})=>{let{layout:r,activeId:o,classNames:i,fullscreenPaneId:c,onRemove:u,onFullscreenChange:w}=G(),{removePane:P,updatePaneMetadata:N}=Pe(),s=o!==null&&o!==e,{attributes:x,listeners:g,setNodeRef:y,isDragging:z}=core.useDraggable({id:e}),D=o===e||z,S=c===e,H=react.useMemo(()=>V(r,e),[r,e])?.metadata,I=react.useMemo(()=>({isDragging:D,isFullscreen:S,toggleFullscreen:()=>w?.(S?null:e),remove:()=>{S&&w?.(null),u?u(e):P(e);},metadata:H,updateMetadata:m=>{N(e,m);}}),[D,S,w,e,u,P,H,N]),d=react.useMemo(()=>({...g,...x}),[g,x]);return jsxRuntime.jsx(ve.Provider,{value:d,children:jsxRuntime.jsxs("div",{ref:y,className:i.pane,style:{position:"relative",width:"100%",height:"100%",...n},children:[t(I),s&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:[["top","bottom","left","right"].map(m=>jsxRuntime.jsx(Ke,{id:`drop-${m}-${e}`,position:m,activeClassName:i.dropPreview},m)),jsxRuntime.jsx(Ke,{id:`drop-center-${e}`,position:"center",activeClassName:i.swapPreview})]})]})})};var Ht=({children:e,className:t,style:n})=>{let r=react.useContext(ve);if(!r)throw new Error("<DragHandle> must be used inside a <Pane>");return jsxRuntime.jsx("div",{className:t,style:{cursor:"grab",userSelect:"none",touchAction:"none",...n},...r,children:e})};exports.DEFAULT_DRAG_ACTIVATION_DISTANCE=tt;exports.DEFAULT_RESIZER_SIZE=Xt;exports.DEFAULT_SNAP_THRESHOLD=et;exports.DragHandle=Ht;exports.Pane=Mt;exports.PaneTree=ye;exports.ResizableContainer=We;exports.Zeugma=ut;exports.addPane=Fe;exports.createDragSession=fe;exports.findPane=V;exports.removePane=k;exports.splitPane=re;exports.splitRoot=$e;exports.swapPanes=xe;exports.updatePaneMetadata=le;exports.updateSplitPercentage=Q;exports.useResizer=we;exports.useZeugmaActions=Pe;exports.useZeugmaState=G;//# sourceMappingURL=index.cjs.map
7
7
  //# sourceMappingURL=index.cjs.map