react-zeugma 2.2.0 → 2.2.2

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.cjs CHANGED
@@ -1,7 +1,7 @@
1
- 'use strict';var react=require('react'),core=require('@dnd-kit/core'),jsxRuntime=require('react/jsx-runtime');var de=react.createContext(void 0),pe=react.createContext(void 0);var X=()=>{let e=react.useContext(de);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},we=()=>{let e=react.useContext(pe);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e};function He(e){let t=react.useRef(null);return react.useEffect(()=>{if(!e){t.current=null;return}let o=n=>{t.current={x:n.clientX,y:n.clientY};},r=n=>{let i=n.touches[0]||n.changedTouches[0];i&&(t.current={x:i.clientX,y:i.clientY});};return window.addEventListener("pointermove",o,{passive:true}),window.addEventListener("touchmove",r,{passive:true}),()=>{window.removeEventListener("pointermove",o),window.removeEventListener("touchmove",r);}},[e]),t}function B(e,t){if(e===null)return null;if(e.type==="pane")return e.paneId===t?null:e;let o=B(e.first,t),r=B(e.second,t);return o===null?r:r===null?o:{...e,first:o,second:r}}function ae(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 i=typeof n=="string"?{type:"pane",paneId:n}:n,l=r==="left"||r==="top";return {type:"split",direction:o,first:l?i:e,second:l?e:i,splitPercentage:50}}return e}return {...e,first:ae(e.first,t,o,r,n)||e.first,second:ae(e.second,t,o,r,n)||e.second}}function Ee(e,t,o){if(e===null)return null;let r=_(e,t),n=_(e,o);if(!r||!n)return e;function i(l){return l.type==="pane"?l.paneId===t?{...n}:l.paneId===o?{...r}:l:{...l,first:i(l.first),second:i(l.second)}}return i(e)}function Fe(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 _(e,t){return e===null?null:e.type==="pane"?e.paneId===t?e:null:_(e.first,t)??_(e.second,t)}function me(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,...i}=e;return i}return {...e,metadata:r}}return e}return {...e,first:me(e.first,t,o)??e.first,second:me(e.second,t,o)??e.second}}var et=8,tt=8,Yt=4;var _e=({activeId:e,render:t,className:o})=>{let r=react.useRef(null);return react.useEffect(()=>{let n=i=>{r.current&&(r.current.style.transform=`translate(${i.clientX+12}px, ${i.clientY+12}px)`);};return document.addEventListener("pointermove",n),()=>document.removeEventListener("pointermove",n)},[]),jsxRuntime.jsx("div",{ref:r,className:o,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var fe=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},ge=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};function ke(e){if(e instanceof MouseEvent||e instanceof PointerEvent)return {x:e.clientX,y:e.clientY};if(typeof TouchEvent<"u"&&e instanceof TouchEvent){let t=e.touches[0]||e.changedTouches[0];if(t)return {x:t.clientX,y:t.clientY}}return null}var ct=({layout:e,onChange:t,renderPane:o,renderDragOverlay:r,classNames:n={},fullscreenPaneId:i=null,onFullscreenChange:l,onRemove:p,dragActivationDistance:h=8,snapThreshold:P=8,onDragStart:D,onDragEnd:s,onResizeStart:v,onResize:E,onResizeEnd:g,minSplitPercentage:x=5,maxSplitPercentage:I=95,enableDragToDismiss:d=false,dismissThreshold:S=60,onDismissIntentChange:y,children:b})=>{let[u,m]=react.useState(e),[U,ie]=react.useState(e);e!==U&&(ie(e),m(e));let[N,q]=react.useState(null),[z,Z]=react.useState(null),V=react.useRef(null),H=react.useRef(null),R=He(N),C=react.useCallback(c=>{V.current=c;},[]),Y=react.useCallback(c=>o(c),[o]),L=react.useMemo(()=>n,[n.pane,n.dropPreview,n.swapPreview,n.dragOverlay,n.resizer,n.dismissPreview]),A=core.useSensors(core.useSensor(fe,{activationConstraint:{distance:h}}),core.useSensor(ge,{activationConstraint:{delay:250,tolerance:5}})),W=c=>{let f=c.active.id.toString();q(f);let a=c.activatorEvent;R.current=ke(a),d&&V.current?H.current=V.current.getBoundingClientRect():H.current=null,D&&D(f);},Se=c=>{if(!d)return;let f=c.active.id.toString(),a=H.current;if(!a){z!==null&&(Z(null),y?.(null));return}let w=c.activatorEvent,F=null,$=null;if(R.current)F=R.current.x,$=R.current.y;else {let T=ke(w);T&&(F=T.x+c.delta.x,$=T.y+c.delta.y);}let O=0;if(F!==null&&$!==null){let T=0,M=0;F<a.left?T=a.left-F:F>a.right&&(T=F-a.right),$<a.top?M=a.top-$:$>a.bottom&&(M=$-a.bottom),O=Math.sqrt(T*T+M*M);}else {let T=c.active.rect.current.translated;if(T){let M=T.left+T.width/2,K=T.top+T.height/2,te=0,ne=0;M<a.left?te=a.left-M:M>a.right&&(te=M-a.right),K<a.top?ne=a.top-K:K>a.bottom&&(ne=K-a.bottom),O=Math.sqrt(te*te+ne*ne);}}O>S?z!==f&&(Z(f),y?.(f)):z!==null&&(Z(null),y?.(null));},ue=c=>{q(null);let{active:f,over:a}=c,w=f.id.toString(),F=d&&z===w;if(Z(null),y?.(null),H.current=null,F){p?p(w):Q(w),s&&s(w,null,null);return}if(!a){s&&s(w,null,null);return}let $=a.id.toString(),O=$.match(/^drop-center-(.+)$/);if(O){let[,Re]=O;if(w!==Re){let Ze=Ee(u,w,Re);m(Ze),t(Ze);}s&&s(w,Re,{type:"swap",position:"center"});return}let ye=$.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!ye){s&&s(w,null,null);return}let[,T,M]=ye;if(w===M){s&&s(w,null,null);return}let K=T==="left"||T==="right"?"row":"column",te=_(u,w)??{type:"pane",paneId:w},ne=B(u,w),Me=ae(ne,M,K,T,te);m(Me),t(Me),s&&s(w,M,{type:"split",direction:K,position:T});},G=react.useCallback(c=>{m(c),t(c);},[t]),Q=react.useCallback(c=>{let f=B(u,c);m(f),t(f);},[u,t]),j=react.useCallback(c=>{let f=Fe(u,c);m(f),t(f);},[u,t]),ce=react.useCallback((c,f)=>{let a=Ee(u,c,f);m(a),t(a);},[u,t]),se=react.useCallback((c,f,a,w)=>{let F=_(u,w)??{type:"pane",paneId:w},$=B(u,w),O=ae($,c,f,a,F);m(O),t(O);},[u,t]),ee=react.useCallback((c,f)=>{let a=J(u,c,f);m(a),t(a);},[u,t]),Le=react.useCallback((c,f)=>{let a=me(u,c,f);m(a),t(a);},[u,t]),Ce=react.useCallback((c,f)=>{let a=J(u,c,f);m(a),t(a),g&&g(c,f);},[u,t,g]),Ke=react.useMemo(()=>({layout:u,onLayoutChange:G,renderPane:Y,activeId:N,dismissIntentId:z,setContainerRef:C,fullscreenPaneId:i,classNames:L,onRemove:p,onFullscreenChange:l,snapThreshold:P,onResizeStart:v,onResize:E,onResizeEnd:Ce,minSplitPercentage:x,maxSplitPercentage:I}),[u,N,z,C,i,L,p,l,P,v,E,x,I,G,Y,Ce]),Je=react.useMemo(()=>({removePane:Q,addPane:j,swapPanes:ce,splitPane:se,updateSplitPercentage:ee,updatePaneMetadata:Le}),[Q,j,ce,se,ee,Le]);return jsxRuntime.jsx(pe.Provider,{value:Je,children:jsxRuntime.jsxs(de.Provider,{value:Ke,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",sensors:A,collisionDetection:core.pointerWithin,onDragStart:W,onDragMove:Se,onDragEnd:ue,children:b}),N&&r&&jsxRuntime.jsx(_e,{activeId:N,render:r,className:`${n.dragOverlay||""} ${N===z?n.dismissPreview||"zeugma-dismiss-preview":""}`.trim()})]})})};function be({cursor:e,resizerEl:t,onMove:o,onEnd:r}){document.body.classList.add("zeugma-resizing");let n=document.createElement("style");n.id="zeugma-global-cursor-style",n.textContent=`
1
+ 'use strict';var react=require('react'),core=require('@dnd-kit/core'),jsxRuntime=require('react/jsx-runtime');var de=react.createContext(void 0),pe=react.createContext(void 0);var W=()=>{let e=react.useContext(de);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},we=()=>{let e=react.useContext(pe);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e};function He(e){let t=react.useRef(null);return react.useEffect(()=>{if(!e){t.current=null;return}let o=n=>{t.current={x:n.clientX,y:n.clientY};},r=n=>{let i=n.touches[0]||n.changedTouches[0];i&&(t.current={x:i.clientX,y:i.clientY});};return window.addEventListener("pointermove",o,{passive:true}),window.addEventListener("touchmove",r,{passive:true}),()=>{window.removeEventListener("pointermove",o),window.removeEventListener("touchmove",r);}},[e]),t}function ne(e,t){if(e===null)return null;if(e.type==="pane")return e.paneId===t?null:e;let o=ne(e.first,t),r=ne(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 i=typeof n=="string"?{type:"pane",paneId:n}:n,a=r==="left"||r==="top";return {type:"split",direction:o,first:a?i:e,second:a?e:i,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 Ee(e,t,o){if(e===null)return null;let r=O(e,t),n=O(e,o);if(!r||!n)return e;function i(a){return a.type==="pane"?a.paneId===t?{...n}:a.paneId===o?{...r}:a:{...a,first:i(a.first),second:i(a.second)}}return i(e)}function Fe(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 O(e,t){return e===null?null:e.type==="pane"?e.paneId===t?e:null:O(e.first,t)??O(e.second,t)}function me(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,...i}=e;return i}return {...e,metadata:r}}return e}return {...e,first:me(e.first,t,o)??e.first,second:me(e.second,t,o)??e.second}}var et=8,tt=8,Yt=4;var _e=({activeId:e,render:t,className:o})=>{let r=react.useRef(null);return react.useEffect(()=>{let n=i=>{r.current&&(r.current.style.transform=`translate(${i.clientX+12}px, ${i.clientY+12}px)`);};return document.addEventListener("pointermove",n),()=>document.removeEventListener("pointermove",n)},[]),jsxRuntime.jsx("div",{ref:r,className:o,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var fe=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},ge=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};function ke(e){if(e instanceof MouseEvent||e instanceof PointerEvent)return {x:e.clientX,y:e.clientY};if(typeof TouchEvent<"u"&&e instanceof TouchEvent){let t=e.touches[0]||e.changedTouches[0];if(t)return {x:t.clientX,y:t.clientY}}return null}var ut=({layout:e,onChange:t,renderPane:o,renderDragOverlay:r,classNames:n={},fullscreenPaneId:i=null,onFullscreenChange:a,onRemove:c,dragActivationDistance:b=8,snapThreshold:P=8,onDragStart:T,onDragEnd:s,onResizeStart:h,onResize:y,onResizeEnd:v,minSplitPercentage:R=5,maxSplitPercentage:d=95,enableDragToDismiss:m=false,dismissThreshold:I=60,onDismissIntentChange:L,children:E})=>{let[p,f]=react.useState(e),[K,oe]=react.useState(e);e!==K&&(oe(e),f(e));let[w,X]=react.useState(null),[D,Z]=react.useState(null),V=react.useRef(null),H=react.useRef(null),x=He(w),C=react.useCallback(u=>{V.current=u;},[]),F=react.useCallback(u=>o(u),[o]),z=react.useMemo(()=>n,[n.pane,n.dropPreview,n.swapPreview,n.dragOverlay,n.resizer,n.dismissPreview]),A=core.useSensors(core.useSensor(fe,{activationConstraint:{distance:b}}),core.useSensor(ge,{activationConstraint:{delay:250,tolerance:5}})),U=u=>{let g=u.active.id.toString();X(g);let l=u.activatorEvent;x.current=ke(l),m&&V.current?H.current=V.current.getBoundingClientRect():H.current=null,T&&T(g);},Se=u=>{if(!m)return;let g=u.active.id.toString(),l=H.current;if(!l){D!==null&&(Z(null),L?.(null));return}let S=u.activatorEvent,_=null,$=null;if(x.current)_=x.current.x,$=x.current.y;else {let N=ke(S);N&&(_=N.x+u.delta.x,$=N.y+u.delta.y);}let k=0;if(_!==null&&$!==null){let N=0,M=0;_<l.left?N=l.left-_:_>l.right&&(N=_-l.right),$<l.top?M=l.top-$:$>l.bottom&&(M=$-l.bottom),k=Math.sqrt(N*N+M*M);}else {let N=u.active.rect.current.translated;if(N){let M=N.left+N.width/2,q=N.top+N.height/2,ee=0,te=0;M<l.left?ee=l.left-M:M>l.right&&(ee=M-l.right),q<l.top?te=l.top-q:q>l.bottom&&(te=q-l.bottom),k=Math.sqrt(ee*ee+te*te);}}k>I?D!==g&&(Z(g),L?.(g)):D!==null&&(Z(null),L?.(null));},ce=u=>{X(null);let{active:g,over:l}=u,S=g.id.toString(),_=m&&D===S;if(Z(null),L?.(null),H.current=null,_){c?c(S):J(S),s&&s(S,null,null);return}if(!l){s&&s(S,null,null);return}let $=l.id.toString(),k=$.match(/^drop-center-(.+)$/);if(k){let[,Re]=k;if(S!==Re){let Ze=Ee(p,S,Re);f(Ze),t(Ze);}s&&s(S,Re,{type:"swap",position:"center"});return}let ye=$.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!ye){s&&s(S,null,null);return}let[,N,M]=ye;if(S===M){s&&s(S,null,null);return}let q=N==="left"||N==="right"?"row":"column",ee=O(p,S)??{type:"pane",paneId:S},te=ne(p,S),Me=ie(te,M,q,N,ee);f(Me),t(Me),s&&s(S,M,{type:"split",direction:q,position:N});},B=react.useCallback((u,g=false)=>{f(u),g||t(u);},[t]),J=react.useCallback(u=>{let g=ne(p,u);f(g),t(g);},[p,t]),Q=react.useCallback(u=>{let g=Fe(p,u);f(g),t(g);},[p,t]),ue=react.useCallback((u,g)=>{let l=Ee(p,u,g);f(l),t(l);},[p,t]),re=react.useCallback((u,g,l,S)=>{let _=O(p,S)??{type:"pane",paneId:S},$=ne(p,S),k=ie($,u,g,l,_);f(k),t(k);},[p,t]),j=react.useCallback((u,g)=>{let l=G(p,u,g);f(l),t(l);},[p,t]),Ie=react.useCallback((u,g)=>{let l=me(p,u,g);f(l),t(l);},[p,t]),Ce=react.useCallback((u,g)=>{v&&v(u,g);},[v]),Ke=react.useMemo(()=>({layout:p,onLayoutChange:B,renderPane:F,activeId:w,dismissIntentId:D,setContainerRef:C,fullscreenPaneId:i,classNames:z,onRemove:c,onFullscreenChange:a,snapThreshold:P,onResizeStart:h,onResize:y,onResizeEnd:Ce,minSplitPercentage:R,maxSplitPercentage:d}),[p,w,D,C,i,z,c,a,P,h,y,R,d,B,F,Ce]),Je=react.useMemo(()=>({removePane:J,addPane:Q,swapPanes:ue,splitPane:re,updateSplitPercentage:j,updatePaneMetadata:Ie}),[J,Q,ue,re,j,Ie]);return jsxRuntime.jsx(pe.Provider,{value:Je,children:jsxRuntime.jsxs(de.Provider,{value:Ke,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",sensors:A,collisionDetection:core.pointerWithin,onDragStart:U,onDragMove:Se,onDragEnd:ce,children:E}),w&&r&&jsxRuntime.jsx(_e,{activeId:w,render:r,className:`${n.dragOverlay||""} ${w===D?n.dismissPreview||"zeugma-dismiss-preview":""}`.trim()})]})})};function be({cursor:e,resizerEl:t,onMove:o,onEnd:r}){document.body.classList.add("zeugma-resizing");let n=document.createElement("style");n.id="zeugma-global-cursor-style",n.textContent=`
2
2
  * {
3
3
  cursor: ${e} !important;
4
4
  user-select: none !important;
5
5
  }
6
- `,document.head.appendChild(n),t.setAttribute("data-resizing","true");let i=p=>{o(p);},l=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let p=document.getElementById("zeugma-global-cursor-style");p&&p.remove(),document.removeEventListener("pointermove",i),document.removeEventListener("pointerup",l),r();};document.addEventListener("pointermove",i),document.addEventListener("pointerup",l);}function Te({containerRef:e,isRow:t,direction:o,splitPercentage:r,resizerSize:n,snapThreshold:i,layout:l,currentNode:p,onLayoutChange:h,onResizeStart:P,onResizeEnd:D,parentLeft:s,parentTop:v,parentWidth:E,parentHeight:g}){let{onResizeStart:x,onResize:I,onResizeEnd:d,minSplitPercentage:S=5,maxSplitPercentage:y=95}=X();return react.useCallback(b=>{b.preventDefault();let u=e.current;if(!u)return;P&&P(),x&&x(p);let m=u.getBoundingClientRect(),U=b.clientX,ie=b.clientY,N=r,q=b.currentTarget,z=m.left+m.width*(s/100),Z=m.top+m.height*(v/100),V=m.width*(E/100),H=m.height*(g/100),C=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(L=>L!==q&&L.getAttribute("data-direction")===o).map(L=>{let A=L.getBoundingClientRect();return t?A.left+A.width/2:A.top+A.height/2}),Y=N;be({cursor:t?"col-resize":"row-resize",resizerEl:q,onMove:L=>{let A=t?(L.clientX-U)/V*100:(L.clientY-ie)/H*100,W=N+A,Se=t?z+(V-n)*(W/100)+n/2:Z+(H-n)*(W/100)+n/2,ue=1/0,G=null;for(let se of C){let ee=Math.abs(Se-se);ee<i&&ee<ue&&(ue=ee,G=se);}let Q=W;G!==null&&(Q=t?(G-n/2-z)/(V-n)*100:(G-n/2-Z)/(H-n)*100);let j=Math.max(S,Math.min(y,Q));Y=j;let ce=J(l,p,j);h(ce),I&&I(p,j);},onEnd:()=>{D&&D(),d&&d(p,Y);}});},[e,t,o,r,n,i,l,p,h,P,D,x,I,d,S,y,s,v,E,g])}function re(e,t=0,o=0,r=100,n=100,i="root"){if(e.type==="pane")return {panes:[{paneId:e.paneId,left:t,top:o,width:r,height:n,node:e}],splitters:[]};let{direction:l,splitPercentage:p,first:h,second:P}=e,s={id:`splitter-${i}-${l}`,currentNode:e,direction:l,left:l==="row"?t+r*(p/100):t,top:l==="column"?o+n*(p/100):o,width:l==="row"?0:r,height:l==="column"?0:n,parentLeft:t,parentTop:o,parentWidth:r,parentHeight:n},v={panes:[],splitters:[]},E={panes:[],splitters:[]};if(l==="row"){let g=r*(p/100);v=re(h,t,o,g,n,`${i}-L`),E=re(P,t+g,o,r-g,n,`${i}-R`);}else {let g=n*(p/100);v=re(h,t,o,r,g,`${i}-T`),E=re(P,t,o+g,r,n-g,`${i}-B`);}return {panes:[...v.panes,...E.panes],splitters:[s,...v.splitters,...E.splitters]}}var vt=({splitter:e,resizerSize:t,snapThreshold:o,containerRef:r})=>{let{layout:n,onLayoutChange:i,classNames:l}=X(),[p,h]=react.useState(false),{currentNode:P,direction:D,left:s,top:v,width:E,height:g,parentLeft:x,parentTop:I,parentWidth:d,parentHeight:S}=e,y=D==="row",b=Te({containerRef:r,isRow:y,direction:D,splitPercentage:P.splitPercentage,resizerSize:t,snapThreshold:o,layout:n,currentNode:P,onLayoutChange:i,onResizeStart:()=>h(true),onResizeEnd:()=>h(false),parentLeft:x,parentTop:I,parentWidth:d,parentHeight:S}),u=y?{position:"absolute",left:`calc(${s}% - ${t/2}px)`,top:`${v}%`,width:`${t}px`,height:`${g}%`,cursor:"col-resize",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`${s}%`,top:`calc(${v}% - ${t/2}px)`,width:`${E}%`,height:`${t}px`,cursor:"row-resize",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsxRuntime.jsx("div",{className:`zeugma-resizer ${l.resizer||""}`.trim(),"data-direction":D,"data-resizing":p||void 0,style:u,onPointerDown:b,role:"separator","aria-valuenow":P.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},bt=({tree:e,resizerSize:t=4,snapThreshold:o})=>{let{layout:r,renderPane:n,activeId:i,dismissIntentId:l,setContainerRef:p,fullscreenPaneId:h,snapThreshold:P}=X(),D=o!==void 0?o:P??8,s=e!==void 0?e:r,v=react.useRef(null),{panes:E,splitters:g,draggedPane:x}=react.useMemo(()=>{if(!s)return {panes:[],splitters:[],draggedPane:null};if(i){let y=B(s,i),b=_(s,i),u=b?{paneId:i,node:b}:null;if(y){let{panes:m,splitters:U}=re(y);return {panes:m,splitters:U,draggedPane:u}}else return {panes:[],splitters:[],draggedPane:u}}let{panes:d,splitters:S}=re(s);return {panes:d,splitters:S,draggedPane:null}},[s,i]);if(!s)return null;let I=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[E.map(d=>{let S=h===d.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:S?"0%":`${d.left}%`,top:S?"0%":`${d.top}%`,width:S?"100%":`${d.width}%`,height:S?"100%":`${d.height}%`,overflow:"hidden",zIndex:S?20:1,display:h&&!S?"none":"block",padding:S?"0px":`${t/2}px`,boxSizing:"border-box"},children:n(d.paneId)},d.paneId)}),x&&jsxRuntime.jsx("div",{style:{position:"absolute",left:"0%",top:"0%",width:"0px",height:"0px",overflow:"hidden",zIndex:0,opacity:0,pointerEvents:"none",display:"none"},children:n(x.paneId)},x.paneId),!h&&g.map(d=>jsxRuntime.jsx(vt,{splitter:d,resizerSize:t,snapThreshold:D,containerRef:v},d.id))]});return e===void 0?jsxRuntime.jsx("div",{ref:y=>{p(y),v.current=y;},className:`zeugma-dashboard-root ${i!==null&&i===l?"zeugma-dashboard-dismiss-active":""}`.trim(),style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:I()}):jsxRuntime.jsx("div",{ref:v,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:I()})};var Xe="zeugma-height:",yt="default-pane";function Rt(e){try{let t=localStorage.getItem(Xe+e);if(t!==null){let o=Number(t);if(Number.isFinite(o)&&o>0)return o}}catch{}return null}function We(e,t){try{localStorage.setItem(Xe+e,String(Math.round(t)));}catch{}}var Be=({children:e,active:t=true,height:o,onHeightChange:r,minHeight:n=100,maxHeight:i=1/0,persist:l,localStorageKey:p,resizerHeight:h=6,className:P,resizerClassName:D})=>{let s=l?p||yt:null,v=()=>{let b=(s?Rt(s):null)??o??400;return he(b,n,i)},[E,g]=react.useState(v),x=react.useRef(null),I=s?E:o??E,d=react.useRef(o);react.useEffect(()=>{if(o!==void 0&&o!==d.current){let b=he(o,n,i);g(b),s&&We(s,b);}d.current=o;},[o,n,i,s]);let S=react.useCallback(()=>i,[i]),y=react.useCallback(b=>{b.preventDefault();let u=b.clientY,m=I,U=S(),ie=b.currentTarget,N=qe(x.current),q=N?N.scrollTop:0,z=u,Z=null,V=(R,C)=>{let Y=C-q,A=R-u+Y,W=he(m+A,n,U);return x.current&&(x.current.style.height=`${W}px`),W},H=()=>{if(!N)return;let R=N===document.documentElement||N===document.body?{top:0,bottom:window.innerHeight}:N.getBoundingClientRect(),C=40,Y=10,L=0;z>R.bottom-C?L=Math.min(1,(z-(R.bottom-C))/C)*Y:z<R.top+C&&(L=-Math.min(1,(R.top+C-z)/C)*Y),L!==0&&(N.scrollTop+=L,V(z,N.scrollTop)),Z=requestAnimationFrame(H);};Z=requestAnimationFrame(H),be({cursor:"row-resize",resizerEl:ie,onMove:R=>{z=R.clientY,N&&V(z,N.scrollTop);},onEnd:()=>{Z!==null&&cancelAnimationFrame(Z);let R=m;x.current&&(R=x.current.getBoundingClientRect().height),R=he(R,n,U),g(R),r&&r(R),s&&We(s,R);}});},[I,n,S,r,s]);return t?jsxRuntime.jsxs("div",{ref:x,className:`zeugma-resizable-container ${P||""}`.trim(),style:{height:`${I}px`,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:[jsxRuntime.jsx("div",{style:{height:`calc(100% - ${h}px)`,overflow:"hidden"},children:e}),jsxRuntime.jsx("div",{className:`zeugma-resizable-handle ${D||""}`.trim(),style:{height:`${h}px`,cursor:"row-resize",position:"relative",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box",flexShrink:0},onPointerDown:y,role:"separator","aria-orientation":"horizontal","aria-valuenow":Math.round(I),"aria-valuemin":n,"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 he(e,t,o){return Math.max(t,Math.min(o,e))}function qe(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:qe(t)}var xe=react.createContext(null);var Tt={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"}},Dt={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:o})=>{let{setNodeRef:r,isOver:n}=core.useDroppable({id:e});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:r,style:Tt[t]}),n&&jsxRuntime.jsx("div",{className:o,style:Dt[t]})]})},zt=({id:e,children:t,style:o})=>{let{layout:r,activeId:n,classNames:i,fullscreenPaneId:l,onRemove:p,onFullscreenChange:h}=X(),{removePane:P,updatePaneMetadata:D}=we(),s=n!==null&&n!==e,{attributes:v,listeners:E,setNodeRef:g,isDragging:x}=core.useDraggable({id:e}),I=n===e||x,d=l===e,y=react.useMemo(()=>_(r,e),[r,e])?.metadata,b=react.useMemo(()=>({isDragging:I,isFullscreen:d,toggleFullscreen:()=>h?.(d?null:e),remove:()=>{d&&h?.(null),p?p(e):P(e);},metadata:y,updateMetadata:m=>{D(e,m);}}),[I,d,h,e,p,P,y,D]),u=react.useMemo(()=>({...E,...v}),[E,v]);return jsxRuntime.jsx(xe.Provider,{value:u,children:jsxRuntime.jsxs("div",{ref:g,className:i.pane,style:{position:"relative",width:"100%",height:"100%",...o},children:[t(b),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(Ge,{id:`drop-${m}-${e}`,position:m,activeClassName:i.dropPreview},m)),jsxRuntime.jsx(Ge,{id:`drop-center-${e}`,position:"center",activeClassName:i.swapPreview})]})]})})};var Mt=({children:e,className:t,style:o})=>{let r=react.useContext(xe);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",...o},...r,children:e})};exports.DEFAULT_DRAG_ACTIVATION_DISTANCE=tt;exports.DEFAULT_RESIZER_SIZE=Yt;exports.DEFAULT_SNAP_THRESHOLD=et;exports.DragHandle=Mt;exports.Pane=zt;exports.PaneTree=bt;exports.ResizableContainer=Be;exports.Zeugma=ct;exports.addPane=Fe;exports.createDragSession=be;exports.findPane=_;exports.removePane=B;exports.splitPane=ae;exports.swapPanes=Ee;exports.updatePaneMetadata=me;exports.updateSplitPercentage=J;exports.useResizer=Te;exports.useZeugmaActions=we;exports.useZeugmaState=X;//# sourceMappingURL=index.cjs.map
6
+ `,document.head.appendChild(n),t.setAttribute("data-resizing","true");let i=c=>{o(c);},a=()=>{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",a),r();};document.addEventListener("pointermove",i),document.addEventListener("pointerup",a);}function De({containerRef:e,isRow:t,direction:o,splitPercentage:r,resizerSize:n,snapThreshold:i,layout:a,currentNode:c,onLayoutChange:b,onResizeStart:P,onResizeEnd:T,parentLeft:s,parentTop:h,parentWidth:y,parentHeight:v}){let{onResizeStart:R,onResize:d,onResizeEnd:m,minSplitPercentage:I=5,maxSplitPercentage:L=95}=W();return react.useCallback(E=>{E.preventDefault();let p=e.current;if(!p)return;P&&P(),R&&R(c);let f=p.getBoundingClientRect(),K=E.clientX,oe=E.clientY,w=r,X=E.currentTarget,D=f.left+f.width*(s/100),Z=f.top+f.height*(h/100),V=f.width*(y/100),H=f.height*(v/100),C=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(z=>z!==X&&z.getAttribute("data-direction")===o).map(z=>{let A=z.getBoundingClientRect();return t?A.left+A.width/2:A.top+A.height/2}),F=w;be({cursor:t?"col-resize":"row-resize",resizerEl:X,onMove:z=>{let A=t?(z.clientX-K)/V*100:(z.clientY-oe)/H*100,U=w+A,Se=t?D+(V-n)*(U/100)+n/2:Z+(H-n)*(U/100)+n/2,ce=1/0,B=null;for(let re of C){let j=Math.abs(Se-re);j<i&&j<ce&&(ce=j,B=re);}let J=U;B!==null&&(J=t?(B-n/2-D)/(V-n)*100:(B-n/2-Z)/(H-n)*100);let Q=Math.max(I,Math.min(L,J));F=Q;let ue=G(a,c,Q);b(ue,true),d&&d(c,Q);},onEnd:()=>{let z=G(a,c,F);b(z),T&&T(),m&&m(c,F);}});},[e,t,o,r,n,i,a,c,b,P,T,R,d,m,I,L,s,h,y,v])}function se(e,t=0,o=0,r=100,n=100,i="root"){if(e.type==="pane")return {panes:[{paneId:e.paneId,left:t,top:o,width:r,height:n,node:e}],splitters:[]};let{direction:a,splitPercentage:c,first:b,second:P}=e,s={id:`splitter-${i}-${a}`,currentNode:e,direction:a,left:a==="row"?t+r*(c/100):t,top:a==="column"?o+n*(c/100):o,width:a==="row"?0:r,height:a==="column"?0:n,parentLeft:t,parentTop:o,parentWidth:r,parentHeight:n},h={panes:[],splitters:[]},y={panes:[],splitters:[]};if(a==="row"){let v=r*(c/100);h=se(b,t,o,v,n,`${i}-L`),y=se(P,t+v,o,r-v,n,`${i}-R`);}else {let v=n*(c/100);h=se(b,t,o,r,v,`${i}-T`),y=se(P,t,o+v,r,n-v,`${i}-B`);}return {panes:[...h.panes,...y.panes],splitters:[s,...h.splitters,...y.splitters]}}var vt=({splitter:e,resizerSize:t,snapThreshold:o,containerRef:r})=>{let{layout:n,onLayoutChange:i,classNames:a}=W(),[c,b]=react.useState(false),{currentNode:P,direction:T,left:s,top:h,width:y,height:v,parentLeft:R,parentTop:d,parentWidth:m,parentHeight:I}=e,L=T==="row",E=De({containerRef:r,isRow:L,direction:T,splitPercentage:P.splitPercentage,resizerSize:t,snapThreshold:o,layout:n,currentNode:P,onLayoutChange:i,onResizeStart:()=>b(true),onResizeEnd:()=>b(false),parentLeft:R,parentTop:d,parentWidth:m,parentHeight:I}),p=L?{position:"absolute",left:`calc(${s}% - ${t/2}px)`,top:`${h}%`,width:`${t}px`,height:`${v}%`,cursor:"col-resize",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`${s}%`,top:`calc(${h}% - ${t/2}px)`,width:`${y}%`,height:`${t}px`,cursor:"row-resize",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsxRuntime.jsx("div",{className:`zeugma-resizer ${a.resizer||""}`.trim(),"data-direction":T,"data-resizing":c||void 0,style:p,onPointerDown:E,role:"separator","aria-valuenow":P.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},bt=({tree:e,resizerSize:t=4,snapThreshold:o})=>{let{layout:r,renderPane:n,activeId:i,dismissIntentId:a,setContainerRef:c,fullscreenPaneId:b,snapThreshold:P}=W(),T=o!==void 0?o:P??8,s=e!==void 0?e:r,h=react.useRef(null),{panes:y,splitters:v}=react.useMemo(()=>s?se(s):{panes:[],splitters:[]},[s]);if(!s)return null;let R=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[y.map(d=>{let m=b===d.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:m?"0%":`${d.left}%`,top:m?"0%":`${d.top}%`,width:m?"100%":`${d.width}%`,height:m?"100%":`${d.height}%`,overflow:"hidden",zIndex:m?20:1,display:b&&!m?"none":"block",padding:m?"0px":`${t/2}px`,boxSizing:"border-box"},children:n(d.paneId)},d.paneId)}),!b&&v.map(d=>jsxRuntime.jsx(vt,{splitter:d,resizerSize:t,snapThreshold:T,containerRef:h},d.id))]});return e===void 0?jsxRuntime.jsx("div",{ref:I=>{c(I),h.current=I;},className:`zeugma-dashboard-root ${i!==null&&i===a?"zeugma-dashboard-dismiss-active":""}`.trim(),style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:R()}):jsxRuntime.jsx("div",{ref:h,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:R()})};var Xe="zeugma-height:",yt="default-pane";function Rt(e){try{let t=localStorage.getItem(Xe+e);if(t!==null){let o=Number(t);if(Number.isFinite(o)&&o>0)return o}}catch{}return null}function We(e,t){try{localStorage.setItem(Xe+e,String(Math.round(t)));}catch{}}var Be=({children:e,active:t=true,height:o,onHeightChange:r,minHeight:n=100,maxHeight:i=1/0,persist:a,localStorageKey:c,resizerHeight:b=6,className:P,resizerClassName:T})=>{let s=a?c||yt:null,h=()=>{let E=(s?Rt(s):null)??o??400;return he(E,n,i)},[y,v]=react.useState(h),R=react.useRef(null),d=s?y:o??y,m=react.useRef(o);react.useEffect(()=>{if(o!==void 0&&o!==m.current){let E=he(o,n,i);v(E),s&&We(s,E);}m.current=o;},[o,n,i,s]);let I=react.useCallback(()=>i,[i]),L=react.useCallback(E=>{E.preventDefault();let p=E.clientY,f=d,K=I(),oe=E.currentTarget,w=qe(R.current),X=w?w.scrollTop:0,D=p,Z=null,V=(x,C)=>{let F=C-X,A=x-p+F,U=he(f+A,n,K);return R.current&&(R.current.style.height=`${U}px`),U},H=()=>{if(!w)return;let x=w===document.documentElement||w===document.body?{top:0,bottom:window.innerHeight}:w.getBoundingClientRect(),C=40,F=10,z=0;D>x.bottom-C?z=Math.min(1,(D-(x.bottom-C))/C)*F:D<x.top+C&&(z=-Math.min(1,(x.top+C-D)/C)*F),z!==0&&(w.scrollTop+=z,V(D,w.scrollTop)),Z=requestAnimationFrame(H);};Z=requestAnimationFrame(H),be({cursor:"row-resize",resizerEl:oe,onMove:x=>{D=x.clientY,w&&V(D,w.scrollTop);},onEnd:()=>{Z!==null&&cancelAnimationFrame(Z);let x=f;R.current&&(x=R.current.getBoundingClientRect().height),x=he(x,n,K),v(x),r&&r(x),s&&We(s,x);}});},[d,n,I,r,s]);return t?jsxRuntime.jsxs("div",{ref:R,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% - ${b}px)`,overflow:"hidden"},children:e}),jsxRuntime.jsx("div",{className:`zeugma-resizable-handle ${T||""}`.trim(),style:{height:`${b}px`,cursor:"row-resize",position:"relative",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box",flexShrink:0},onPointerDown:L,role:"separator","aria-orientation":"horizontal","aria-valuenow":Math.round(d),"aria-valuemin":n,"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 he(e,t,o){return Math.max(t,Math.min(o,e))}function qe(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:qe(t)}var xe=react.createContext(null);var Dt={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"}},zt={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:o})=>{let{setNodeRef:r,isOver:n}=core.useDroppable({id:e});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:r,style:Dt[t]}),n&&jsxRuntime.jsx("div",{className:o,style:zt[t]})]})},Lt=({id:e,children:t,style:o})=>{let{layout:r,activeId:n,classNames:i,fullscreenPaneId:a,onRemove:c,onFullscreenChange:b}=W(),{removePane:P,updatePaneMetadata:T}=we(),s=n!==null&&n!==e,{attributes:h,listeners:y,setNodeRef:v,isDragging:R}=core.useDraggable({id:e}),d=n===e||R,m=a===e,L=react.useMemo(()=>O(r,e),[r,e])?.metadata,E=react.useMemo(()=>({isDragging:d,isFullscreen:m,toggleFullscreen:()=>b?.(m?null:e),remove:()=>{m&&b?.(null),c?c(e):P(e);},metadata:L,updateMetadata:f=>{T(e,f);}}),[d,m,b,e,c,P,L,T]),p=react.useMemo(()=>({...y,...h}),[y,h]);return jsxRuntime.jsx(xe.Provider,{value:p,children:jsxRuntime.jsxs("div",{ref:v,className:i.pane,style:{position:"relative",width:"100%",height:"100%",...o},children:[t(E),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(Ge,{id:`drop-${f}-${e}`,position:f,activeClassName:i.dropPreview},f)),jsxRuntime.jsx(Ge,{id:`drop-center-${e}`,position:"center",activeClassName:i.swapPreview})]})]})})};var Mt=({children:e,className:t,style:o})=>{let r=react.useContext(xe);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",...o},...r,children:e})};exports.DEFAULT_DRAG_ACTIVATION_DISTANCE=tt;exports.DEFAULT_RESIZER_SIZE=Yt;exports.DEFAULT_SNAP_THRESHOLD=et;exports.DragHandle=Mt;exports.Pane=Lt;exports.PaneTree=bt;exports.ResizableContainer=Be;exports.Zeugma=ut;exports.addPane=Fe;exports.createDragSession=be;exports.findPane=O;exports.removePane=ne;exports.splitPane=ie;exports.swapPanes=Ee;exports.updatePaneMetadata=me;exports.updateSplitPercentage=G;exports.useResizer=De;exports.useZeugmaActions=we;exports.useZeugmaState=W;//# sourceMappingURL=index.cjs.map
7
7
  //# sourceMappingURL=index.cjs.map