react-zeugma 4.1.0 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -18
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -109,23 +109,24 @@ The context provider that sets up the drag-and-drop state machine, monitors acti
|
|
|
109
109
|
|
|
110
110
|
A custom state hook that initializes and manages the recursive layout tree and handles drag-and-drop actions.
|
|
111
111
|
|
|
112
|
-
| Option | Type | Default | Description
|
|
113
|
-
| ------------------------ | --------------------------------------------------------------------- | ------- |
|
|
114
|
-
| `initialLayout` | `TreeNode \| null` |
|
|
115
|
-
| `
|
|
116
|
-
| `
|
|
117
|
-
| `
|
|
118
|
-
| `
|
|
119
|
-
| `
|
|
120
|
-
| `
|
|
121
|
-
| `
|
|
122
|
-
| `
|
|
123
|
-
| `
|
|
124
|
-
| `
|
|
125
|
-
| `
|
|
126
|
-
| `
|
|
127
|
-
| `
|
|
128
|
-
| `
|
|
112
|
+
| Option | Type | Default | Description |
|
|
113
|
+
| ------------------------ | --------------------------------------------------------------------- | ------- | --------------------------------------------------------------------------------------------------------- |
|
|
114
|
+
| `initialLayout` | `TreeNode \| null` | — | Initial layout tree structure for uncontrolled mode. Only used on initial mount. |
|
|
115
|
+
| `layout` | `TreeNode \| null` | — | Controlled layout tree structure. If provided, the hook runs in controlled mode and synchronizes with it. |
|
|
116
|
+
| `locked` | `boolean` | `false` | If true, layout resizes and drags are disabled. |
|
|
117
|
+
| `dragActivationDistance` | `number` | `8` | Minimum pointer drag distance (in pixels) required to activate dragging. |
|
|
118
|
+
| `snapThreshold` | `number` | `8` | Threshold in pixels to snap layout resizers to adjacent edges. |
|
|
119
|
+
| `minSplitPercentage` | `number` | `5` | Minimum resizing limit percentage. |
|
|
120
|
+
| `maxSplitPercentage` | `number` | `95` | Maximum resizing limit percentage. |
|
|
121
|
+
| `enableDragToDismiss` | `boolean` | `false` | If true, enables the drag-out-to-dismiss gesture to close widgets. |
|
|
122
|
+
| `dismissThreshold` | `number` | `60` | Distance in pixels outside container bounds required to trigger dismissal. |
|
|
123
|
+
| `onRemove` | `(paneId: string) => void` | — | Callback triggered when a pane is removed. |
|
|
124
|
+
| `onDragStart` | `(activeId: string) => void` | — | Callback triggered when dragging starts. |
|
|
125
|
+
| `onDragEnd` | `(activeId: string, overId: string \| null, dropAction: any) => void` | — | Callback triggered when dragging ends. |
|
|
126
|
+
| `onResizeStart` | `(currentNode: SplitNode) => void` | — | Callback triggered when resizing starts. |
|
|
127
|
+
| `onResize` | `(currentNode: SplitNode, percentage: number) => void` | — | Callback triggered during resizing. |
|
|
128
|
+
| `onResizeEnd` | `(currentNode: SplitNode, percentage: number) => void` | — | Callback triggered when resizing ends. |
|
|
129
|
+
| `onDismissIntentChange` | `(paneId: string \| null) => void` | — | Callback triggered when drag-out intent changes. |
|
|
129
130
|
|
|
130
131
|
### `useZeugmaContext()`
|
|
131
132
|
|
|
@@ -329,7 +330,7 @@ A custom hook to manage the dashboard layout state.
|
|
|
329
330
|
|
|
330
331
|
#### Options
|
|
331
332
|
|
|
332
|
-
- `initialLayout: TreeNode | null` — Initial layout tree.
|
|
333
|
+
- `initialLayout: TreeNode | null` — Initial layout tree structure.
|
|
333
334
|
- `locked?: boolean` — Whether the layout is globally locked.
|
|
334
335
|
- `dragActivationDistance?: number` — Minimum pointer drag distance (in pixels) required to activate dragging (defaults to `8`).
|
|
335
336
|
- `snapThreshold?: number` — Threshold in pixels to snap layout resizers to adjacent edges (defaults to `8`).
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
'use strict';var tn=require('react'),reactDom=require('react-dom'),core=require('@dnd-kit/core'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var tn__default=/*#__PURE__*/_interopDefault(tn);var ze=tn.createContext(void 0),Ie=tn.createContext(void 0);var ee=()=>{let e=tn.useContext(ze);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},$e=()=>{let e=tn.useContext(Ie);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e};function st(e){let t=tn.useRef(null);return tn.useEffect(()=>{if(!e){t.current=null;return}let r=n=>{t.current={x:n.clientX,y:n.clientY};},s=n=>{let o=n.touches[0]||n.changedTouches[0];o&&(t.current={x:o.clientX,y:o.clientY});};return window.addEventListener("pointermove",r,{passive:true}),window.addEventListener("touchmove",s,{passive:true}),()=>{window.removeEventListener("pointermove",r),window.removeEventListener("touchmove",s);}},[e]),t}function it(e){tn.useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function at(){let[e,t]=tn.useState({}),r=tn.useRef(true);tn.useEffect(()=>(r.current=true,()=>{r.current=false;}),[]);let s=tn.useCallback((n,o)=>{setTimeout(()=>{r.current&&t(i=>i[n]===o?i:{...i,[n]:o});},0);},[]);return {portalTargets:e,registerPortalTarget:s}}var ke=tn.createContext(void 0);var Ht=8,At=8,Fn=4;function ie(){return "pane-"+Math.random().toString(36).substring(2,11)}function be(e,t){if(e===null)return null;if(e.type==="pane")return e.id===t?null:e;let r=be(e.first,t),s=be(e.second,t);return r===null?s:s===null?r:{...e,first:r,second:s}}function de(e,t){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let n=e.tabs.filter(a=>a!==t);if(n.length===0)return null;let o=e.activeTabId;e.activeTabId===t&&(o=n[0]);let i={...e.tabsMetadata};return delete i[t],{...e,tabs:n,activeTabId:o,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}let r=de(e.first,t),s=de(e.second,t);return r===null?s:s===null?r:{...e,first:r,second:s}}function ye(e,t,r,s,n){if(e===null)return typeof n=="string"?{type:"pane",id:ie(),tabs:[n],activeTabId:n}:n;if(e.type==="pane"){if(e.id===t||e.tabs.includes(t)){let o=typeof n=="string"?{type:"pane",id:ie(),tabs:[n],activeTabId:n}:n,i=s==="left"||s==="top";return {type:"split",direction:r,first:i?o:e,second:i?e:o,splitPercentage:50}}return e}return {...e,first:ye(e.first,t,r,s,n)||e.first,second:ye(e.second,t,r,s,n)||e.second}}function lt(e,t){if(e===null)return {type:"pane",id:ie(),tabs:[t],activeTabId:t};function r(s,n){return s.type==="pane"?{type:"split",direction:n==="row"?"column":"row",splitPercentage:50,first:s,second:{type:"pane",id:ie(),tabs:[t],activeTabId:t}}:{...s,second:r(s.second,s.direction)}}return r(e,null)}function ve(e,t,r){return e===null?null:e===t?{...e,splitPercentage:r}:e.type==="split"?{...e,first:ve(e.first,t,r)||e.first,second:ve(e.second,t,r)||e.second}:e}function q(e,t){return e===null?null:e.type==="pane"?e.id===t||e.tabs.includes(t)?e:null:q(e.first,t)??q(e.second,t)}function Ze(e,t,r){if(e===null)return null;if(e.type==="pane"){if(e.id===t||e.tabs.includes(t)){let s=e.tabsMetadata||{},n=s[t],o=r(n),i={...s};return o===void 0?delete i[t]:i[t]=o,{...e,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}return {...e,first:Ze(e.first,t,r)??e.first,second:Ze(e.second,t,r)??e.second}}function He(e,t,r){if(e===null)return null;if(e.type==="pane"){if(e.id===t||e.tabs.includes(t)){if(r===false){let{locked:s,...n}=e;return n}return {...e,locked:r}}return e}return {...e,first:He(e.first,t,r)??e.first,second:He(e.second,t,r)??e.second}}function Ae(e,t,r){return e===null?null:e.type==="pane"?e.id===t||e.tabs.includes(t)?{...e,activeTabId:r}:e:{...e,first:Ae(e.first,t,r)??e.first,second:Ae(e.second,t,r)??e.second}}function ct(e,t,r){if(e===null)return null;let n=q(e,t)?.tabsMetadata?.[t],o=de(e,t);if(o===null)return {type:"pane",id:ie(),tabs:[t],activeTabId:t,tabsMetadata:n?{[t]:n}:void 0};function i(a){if(a.type==="pane"){if(a.id===r||a.tabs.includes(r)){let l=[...a.tabs];l.includes(t)||l.push(t);let y={...a.tabsMetadata};return n&&(y[t]=n),{...a,tabs:l,activeTabId:t,tabsMetadata:Object.keys(y).length>0?y:void 0}}return a}return {...a,first:i(a.first),second:i(a.second)}}return i(o)}function ut(e,t,r,s="before"){if(e===null)return null;let o=q(e,t)?.tabsMetadata?.[t],i=de(e,t);if(i===null)return {type:"pane",id:ie(),tabs:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function a(l){if(l.type==="pane"){if(l.id===r||l.tabs.includes(r)){let D=[...l.tabs].filter(x=>x!==t),c=D.indexOf(r);c<0&&(c=0),s==="after"&&(c+=1),D.splice(c,0,t);let T={...l.tabsMetadata};return o&&(T[t]=o),{...l,tabs:D,activeTabId:t,tabsMetadata:Object.keys(T).length>0?T:void 0}}return l}return {...l,first:a(l.first),second:a(l.second)}}return a(i)}function se(e,t=0,r=0,s=100,n=100,o="root"){if(e===null)return {panes:[],splitters:[]};if(e.type==="pane")return {panes:[{paneId:e.id,left:t,top:r,width:s,height:n,node:e}],splitters:[]};let{direction:i,splitPercentage:a,first:l,second:y}=e,c={id:`splitter-${o}-${i}`,currentNode:e,direction:i,left:i==="row"?t+s*(a/100):t,top:i==="column"?r+n*(a/100):r,width:i==="row"?0:s,height:i==="column"?0:n,parentLeft:t,parentTop:r,parentWidth:s,parentHeight:n},T={panes:[],splitters:[]},x={panes:[],splitters:[]};if(i==="row"){let v=s*(a/100);T=se(l,t,r,v,n,`${o}-L`),x=se(y,t+v,r,s-v,n,`${o}-R`);}else {let v=n*(a/100);T=se(l,t,r,s,v,`${o}-T`),x=se(y,t,r+v,s,n-v,`${o}-B`);}return {panes:[...T.panes,...x.panes],splitters:[c,...T.splitters,...x.splitters]}}function Ft(e){let{initialLayout:t,onChange:r,fullscreenPaneId:s,onFullscreenChange:n,locked:o=false,dragActivationDistance:i=8,snapThreshold:a=8,minSplitPercentage:l=5,maxSplitPercentage:y=95,enableDragToDismiss:D=false,dismissThreshold:c=60,onRemove:T,onDragStart:x,onDragEnd:v,onResizeStart:R,onResize:E,onResizeEnd:L,onDismissIntentChange:p}=e,[b,f]=tn.useState(t),[z,A]=tn.useState(s||null),[I,V]=tn.useState(o),[w,K]=tn.useState(null),[h,F]=tn.useState(null),[Y,O]=tn.useState(null),m=tn.useRef(null),$=tn.useCallback(u=>{m.current=u;},[]),_=tn.useCallback(u=>{A(u),n?.(u);},[n]);tn.useEffect(()=>{V(o);},[o]),tn.useEffect(()=>{s!==void 0&&A(s);},[s]);let k=tn.useRef(true);tn.useEffect(()=>{if(k.current){k.current=false;return}r?.(b);},[b,r]);let N=tn.useCallback(u=>{f(S=>be(S,u));},[]),d=tn.useCallback(u=>{f(S=>lt(S,u));},[]),B=tn.useCallback((u,S,P,ne)=>{f(Re=>{let Ye=q(Re,ne)??{type:"pane",id:ne,tabs:[ne],activeTabId:ne},Be=be(Re,ne);return ye(Be,u,S,P,Ye)});},[]),ae=tn.useCallback((u,S)=>{f(P=>ve(P,u,S));},[]),W=tn.useCallback((u,S)=>{f(P=>Ze(P,u,S));},[]),te=tn.useCallback((u,S)=>{f(P=>He(P,u,S));},[]),le=tn.useCallback((u,S)=>{f(P=>Ae(P,u,S));},[]),fe=tn.useCallback((u,S)=>{f(P=>ct(P,u,S));},[]),me=tn.useCallback((u,S,P)=>{f(ne=>ut(ne,u,S,P));},[]),j=tn.useCallback(u=>{f(S=>de(S,u));},[]);return {layout:b,setLayout:f,fullscreenPaneId:z,setFullscreenPaneId:_,locked:I,setLocked:V,activeId:w,setActiveId:K,activeType:h,setActiveType:F,dismissIntentId:Y,setDismissIntentId:O,containerRef:m,setContainerRef:$,dragActivationDistance:i,snapThreshold:a,minSplitPercentage:l,maxSplitPercentage:y,enableDragToDismiss:D,dismissThreshold:c,onRemove:T,onDragStart:x,onDragEnd:v,onResizeStart:R,onResize:E,onResizeEnd:L,onDismissIntentChange:p,removePane:N,addPane:d,splitPane:B,updateSplitPercentage:ae,updateTabMetadata:W,updatePaneLock:te,selectTab:le,mergeTab:fe,moveTab:me,removeTab:j}}var Ot=()=>{let e=ee(),t=$e();return {...e,...t}};var pt=({activeId:e,render:t,className:r})=>{let s=tn.useRef(null);return tn.useEffect(()=>{let n=o=>{s.current&&(s.current.style.transform=`translate(${o.clientX+12}px, ${o.clientY+12}px)`);};return document.addEventListener("pointermove",n),()=>document.removeEventListener("pointermove",n)},[]),jsxRuntime.jsx("div",{ref:s,className:r,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")}]},Oe=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};function je(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 jt=e=>{let{renderPane:t,renderWidget:r,renderDragOverlay:s,classNames:n={},children:o,layout:i,setLayout:a,fullscreenPaneId:l,setFullscreenPaneId:y,locked:D,activeId:c,setActiveId:T,activeType:x,setActiveType:v,dismissIntentId:R,setDismissIntentId:E,containerRef:L,setContainerRef:p,dragActivationDistance:b,snapThreshold:f,minSplitPercentage:z,maxSplitPercentage:A,enableDragToDismiss:I,dismissThreshold:V,onRemove:w,onDragStart:K,onDragEnd:h,onResizeStart:F,onResize:Y,onResizeEnd:O,onDismissIntentChange:m,removePane:$,addPane:_,splitPane:k,updateSplitPercentage:N,updateTabMetadata:d,updatePaneLock:B,selectTab:ae,mergeTab:W,moveTab:te,removeTab:le}=e,{portalTargets:fe,registerPortalTarget:me}=at(),j=tn.useRef(null),u=st(c),[S,P]=tn.useState(false);it(S);let ne=tn.useCallback(g=>t(g),[t]),Re=tn.useMemo(()=>n,[n.pane,n.paneLocked,n.dropPreview,n.dragOverlay,n.resizer,n.dismissPreview,n.dashboardLocked,n.lockedPreview]),Ye=core.useSensors(core.useSensor(Fe,{activationConstraint:{distance:b}}),core.useSensor(Oe,{activationConstraint:{delay:250,tolerance:5}})),Be=tn.useCallback(g=>{let Z=core.pointerWithin(g);if(Z.length>0)return Z;if(g.active.id.toString().startsWith("tab-header-")){let re=g.droppableContainers.filter(J=>J.id.toString().startsWith("tab-drop-"));return core.closestCenter({...g,droppableContainers:re})}return []},[]),Dt=g=>{let Z=g.active.id.toString(),U=Z.startsWith("tab-header-"),re=U?Z.substring(11):Z;T(re),v(U?"tab":"pane");let J=g.activatorEvent;u.current=je(J),I&&L.current?j.current=L.current.getBoundingClientRect():j.current=null,K&&K(re);},Et=g=>{let{over:Z}=g,re=(Z?.id.toString()||"").startsWith("drop-locked-");if(P(re),!I)return;let J=g.active.id.toString(),Se=J.startsWith("tab-header-")?J.substring(11):J,M=j.current;if(!M){R!==null&&(E(null),m?.(null));return}let we=g.activatorEvent,oe=null,X=null;if(u.current)oe=u.current.x,X=u.current.y;else {let H=je(we);H&&(oe=H.x+g.delta.x,X=H.y+g.delta.y);}let ce=0;if(oe!==null&&X!==null){let H=0,Q=0;oe<M.left?H=M.left-oe:oe>M.right&&(H=oe-M.right),X<M.top?Q=M.top-X:X>M.bottom&&(Q=X-M.bottom),ce=Math.sqrt(H*H+Q*Q);}else {let H=g.active.rect.current.translated;if(H){let Q=H.left+H.width/2,ge=H.top+H.height/2,ue=0,Pe=0;Q<M.left?ue=M.left-Q:Q>M.right&&(ue=Q-M.right),ge<M.top?Pe=M.top-ge:ge>M.bottom&&(Pe=ge-M.bottom),ce=Math.sqrt(ue*ue+Pe*Pe);}}ce>V?R!==Se&&(E(Se),m?.(Se)):R!==null&&(E(null),m?.(null));},Ct=g=>{T(null),v(null),P(false);let{active:Z,over:U}=g,re=Z.id.toString(),J=re.startsWith("tab-header-"),C=J?re.substring(11):re,Se=I&&R===C;if(E(null),m?.(null),j.current=null,Se){w?w(C):le(C),h&&h(C,null,null);return}if(!U){h&&h(C,null,null);return}let M=U.id.toString();if(M.startsWith("drop-locked-")){h&&h(C,null,null);return}let we=M.match(/^tab-drop-(.+)$/);if(we){let[,Ne]=we;if(C!==Ne){let Ee="before",tt=U.rect,It=g.activatorEvent,Me=null;if(u.current)Me=u.current.x;else {let Le=je(It);Le&&(Me=Le.x+g.delta.x);}if(Me!==null){let Le=tt.left+tt.width/2;Me>Le&&(Ee="after");}te(C,Ne,Ee);}h&&h(C,Ne,{type:"swap",position:"center"});return}let oe=M.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!oe){h&&h(C,null,null);return}let[,X,ce]=oe,De=q(i,C),H=De&&De.id===ce,Q=De&&De.tabs.length===1;if(C===ce||H&&Q){h&&h(C,null,null);return}let ge=X==="left"||X==="right"?"row":"column",ue;if(J){let Ee=q(i,C)?.tabsMetadata?.[C];ue={type:"pane",id:ie(),tabs:[C],activeTabId:C,tabsMetadata:Ee?{[C]:Ee}:void 0};}else ue=q(i,C)??{type:"pane",id:ie(),tabs:[C],activeTabId:C};let Pe=J?de(i,C):be(i,C),zt=ye(Pe,ce,ge,X,ue);a(zt),h&&h(C,ce,{type:"split",direction:ge,position:X});},et=tn.useCallback((g,Z)=>{O&&O(g,Z);},[O]),wt=tn.useMemo(()=>({layout:i,onLayoutChange:g=>a(g),renderPane:ne,activeId:c,dismissIntentId:R,setContainerRef:p,fullscreenPaneId:l,classNames:Re,onRemove:w,onFullscreenChange:y,snapThreshold:f,onResizeStart:F,onResize:Y,onResizeEnd:et,minSplitPercentage:z,maxSplitPercentage:A,locked:D}),[i,c,R,p,l,Re,w,y,f,F,Y,z,A,a,ne,et,D]),Nt=tn.useMemo(()=>({removePane:$,addPane:_,splitPane:k,updateSplitPercentage:N,updateTabMetadata:d,updatePaneLock:B,selectTab:ae,mergeTab:W,moveTab:te,removeTab:le}),[$,_,k,N,d,B,ae,W,te,le]),Mt=tn.useMemo(()=>{let g=[];function Z(U){U&&(U.type==="pane"?g.push(...U.tabs):(Z(U.first),Z(U.second)));}return Z(i),g},[i]),Lt=tn.useMemo(()=>({registerPortalTarget:me}),[me]);return jsxRuntime.jsx(Ie.Provider,{value:Nt,children:jsxRuntime.jsx(ze.Provider,{value:wt,children:jsxRuntime.jsxs(ke.Provider,{value:Lt,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",sensors:Ye,collisionDetection:Be,onDragStart:Dt,onDragMove:Et,onDragEnd:Ct,children:o}),c&&x&&s&&jsxRuntime.jsx(pt,{activeId:c,render:g=>s(g,x),className:`${n.dragOverlay||""} ${c===R?n.dismissPreview||"zeugma-dismiss-preview":""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:Mt.map(g=>jsxRuntime.jsx(Jt,{tabId:g,target:fe[g]||null,renderWidget:r},g))})]})})})},Jt=({tabId:e,target:t,renderWidget:r})=>{let[s,n]=tn.useState(false),o=tn.useRef(null);if(tn.useEffect(()=>{n(true);},[]),tn.useEffect(()=>{if(!s||!o.current)return;let a=o.current;if(t)t.appendChild(a);else {let l=document.getElementById("zeugma-hidden-portal-container");l||(l=document.createElement("div"),l.id="zeugma-hidden-portal-container",l.style.display="none",document.body.appendChild(l)),l.appendChild(a);}},[t,s]),tn.useEffect(()=>()=>{o.current&&o.current.remove();},[]),!s)return null;o.current||(o.current=document.createElement("div"),o.current.className=`zeugma-portal-wrapper-${e}`,o.current.style.width="100%",o.current.style.height="100%");let i=o.current;return !i||!r?null:reactDom.createPortal(r(e),i)};function Ve({cursor:e,resizerEl:t,onMove:r,onEnd:s}){document.body.classList.add("zeugma-resizing");let n=document.createElement("style");n.id="zeugma-global-cursor-style",n.textContent=`
|
|
1
|
+
'use strict';var on=require('react'),core=require('@dnd-kit/core'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var on__default=/*#__PURE__*/_interopDefault(on);var Fe=on.createContext(void 0),Oe=on.createContext(void 0);var ne=()=>{let e=on.useContext(Fe);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},Ve=()=>{let e=on.useContext(Oe);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e};function ct(e){let t=on.useRef(null);return on.useEffect(()=>{if(!e){t.current=null;return}let n=r=>{t.current={x:r.clientX,y:r.clientY};},s=r=>{let o=r.touches[0]||r.changedTouches[0];o&&(t.current={x:o.clientX,y:o.clientY});};return window.addEventListener("pointermove",n,{passive:true}),window.addEventListener("touchmove",s,{passive:true}),()=>{window.removeEventListener("pointermove",n),window.removeEventListener("touchmove",s);}},[e]),t}function ut(e){on.useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function dt(){let[e,t]=on.useState({}),n=on.useRef(true);on.useEffect(()=>(n.current=true,()=>{n.current=false;}),[]);let s=on.useCallback((r,o)=>{setTimeout(()=>{n.current&&t(i=>i[r]===o?i:{...i,[r]:o});},0);},[]);return {portalTargets:e,registerPortalTarget:s}}var We=on.createContext(void 0);var Zt=8,Ht=8,Wn=4;function ce(){return "pane-"+Math.random().toString(36).substring(2,11)}function ye(e,t){if(e===null)return null;if(e.type==="pane")return e.id===t?null:e;let n=ye(e.first,t),s=ye(e.second,t);return n===null?s:s===null?n:{...e,first:n,second:s}}function fe(e,t){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let r=e.tabs.filter(a=>a!==t);if(r.length===0)return null;let o=e.activeTabId;e.activeTabId===t&&(o=r[0]);let i={...e.tabsMetadata};return delete i[t],{...e,tabs:r,activeTabId:o,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}let n=fe(e.first,t),s=fe(e.second,t);return n===null?s:s===null?n:{...e,first:n,second:s}}function De(e,t,n,s,r){if(e===null)return typeof r=="string"?{type:"pane",id:ce(),tabs:[r],activeTabId:r}:r;if(e.type==="pane"){if(e.id===t||e.tabs.includes(t)){let o=typeof r=="string"?{type:"pane",id:ce(),tabs:[r],activeTabId:r}:r,i=s==="left"||s==="top";return {type:"split",direction:n,first:i?o:e,second:i?e:o,splitPercentage:50}}return e}return {...e,first:De(e.first,t,n,s,r)||e.first,second:De(e.second,t,n,s,r)||e.second}}function pt(e,t){if(e===null)return {type:"pane",id:ce(),tabs:[t],activeTabId:t};function n(s,r){return s.type==="pane"?{type:"split",direction:r==="row"?"column":"row",splitPercentage:50,first:s,second:{type:"pane",id:ce(),tabs:[t],activeTabId:t}}:{...s,second:n(s.second,s.direction)}}return n(e,null)}function Te(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:Te(e.first,t,n)||e.first,second:Te(e.second,t,n)||e.second}:e}function K(e,t){return e===null?null:e.type==="pane"?e.id===t||e.tabs.includes(t)?e:null:K(e.first,t)??K(e.second,t)}function _e(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.id===t||e.tabs.includes(t)){let s=e.tabsMetadata||{},r=s[t],o=n(r),i={...s};return o===void 0?delete i[t]:i[t]=o,{...e,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}return {...e,first:_e(e.first,t,n)??e.first,second:_e(e.second,t,n)??e.second}}function Ue(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.id===t||e.tabs.includes(t)){if(n===false){let{locked:s,...r}=e;return r}return {...e,locked:n}}return e}return {...e,first:Ue(e.first,t,n)??e.first,second:Ue(e.second,t,n)??e.second}}function Ye(e,t,n){return e===null?null:e.type==="pane"?e.id===t||e.tabs.includes(t)?{...e,activeTabId:n}:e:{...e,first:Ye(e.first,t,n)??e.first,second:Ye(e.second,t,n)??e.second}}function ft(e,t,n){if(e===null)return null;let r=K(e,t)?.tabsMetadata?.[t],o=fe(e,t);if(o===null)return {type:"pane",id:ce(),tabs:[t],activeTabId:t,tabsMetadata:r?{[t]:r}:void 0};function i(a){if(a.type==="pane"){if(a.id===n||a.tabs.includes(n)){let l=[...a.tabs];l.includes(t)||l.push(t);let P={...a.tabsMetadata};return r&&(P[t]=r),{...a,tabs:l,activeTabId:t,tabsMetadata:Object.keys(P).length>0?P:void 0}}return a}return {...a,first:i(a.first),second:i(a.second)}}return i(o)}function mt(e,t,n,s="before"){if(e===null)return null;let o=K(e,t)?.tabsMetadata?.[t],i=fe(e,t);if(i===null)return {type:"pane",id:ce(),tabs:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function a(l){if(l.type==="pane"){if(l.id===n||l.tabs.includes(n)){let D=[...l.tabs].filter(y=>y!==t),c=D.indexOf(n);c<0&&(c=0),s==="after"&&(c+=1),D.splice(c,0,t);let T={...l.tabsMetadata};return o&&(T[t]=o),{...l,tabs:D,activeTabId:t,tabsMetadata:Object.keys(T).length>0?T:void 0}}return l}return {...l,first:a(l.first),second:a(l.second)}}return a(i)}function le(e,t=0,n=0,s=100,r=100,o="root"){if(e===null)return {panes:[],splitters:[]};if(e.type==="pane")return {panes:[{paneId:e.id,left:t,top:n,width:s,height:r,node:e}],splitters:[]};let{direction:i,splitPercentage:a,first:l,second:P}=e,c={id:`splitter-${o}-${i}`,currentNode:e,direction:i,left:i==="row"?t+s*(a/100):t,top:i==="column"?n+r*(a/100):n,width:i==="row"?0:s,height:i==="column"?0:r,parentLeft:t,parentTop:n,parentWidth:s,parentHeight:r},T={panes:[],splitters:[]},y={panes:[],splitters:[]};if(i==="row"){let v=s*(a/100);T=le(l,t,n,v,r,`${o}-L`),y=le(P,t+v,n,s-v,r,`${o}-R`);}else {let v=r*(a/100);T=le(l,t,n,s,v,`${o}-T`),y=le(P,t,n+v,s,r-v,`${o}-B`);}return {panes:[...T.panes,...y.panes],splitters:[c,...T.splitters,...y.splitters]}}function Be({cursor:e,resizerEl:t,onMove:n,onEnd:s}){document.body.classList.add("zeugma-resizing");let r=document.createElement("style");r.id="zeugma-global-cursor-style",r.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 o=a=>{r(a);},i=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let a=document.getElementById("zeugma-global-cursor-style");a&&a.remove(),document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",i),s();};document.addEventListener("pointermove",o),document.addEventListener("pointerup",i);}function Je({containerRef:e,isRow:t,direction:r,splitPercentage:s,resizerSize:n,snapThreshold:o,layout:i,currentNode:a,onLayoutChange:l,onResizeStart:y,onResizeEnd:D,parentLeft:c,parentTop:T,parentWidth:x,parentHeight:v}){let{onResizeStart:R,onResize:E,onResizeEnd:L,minSplitPercentage:p=5,maxSplitPercentage:b=95,locked:f=false}=ee();return tn.useCallback(z=>{if(f)return;z.preventDefault();let A=e.current;if(!A)return;y&&y(),R&&R(a);let I=A.getBoundingClientRect(),V=z.clientX,w=z.clientY,K=s,h=z.currentTarget,F=I.left+I.width*(c/100),Y=I.top+I.height*(T/100),O=I.width*(x/100),m=I.height*(v/100),_=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(N=>N!==h&&N.getAttribute("data-direction")===r).map(N=>{let d=N.getBoundingClientRect();return t?d.left+d.width/2:d.top+d.height/2}),k=K;Ve({cursor:t?"col-resize":"row-resize",resizerEl:h,onMove:N=>{let d=t?(N.clientX-V)/O*100:(N.clientY-w)/m*100,B=K+d,ae=t?F+(O-n)*(B/100)+n/2:Y+(m-n)*(B/100)+n/2,W=1/0,te=null;for(let j of _){let u=Math.abs(ae-j);u<o&&u<W&&(W=u,te=j);}let le=B;te!==null&&(le=t?(te-n/2-F)/(O-n)*100:(te-n/2-Y)/(m-n)*100);let fe=Math.max(p,Math.min(b,le));k=fe;let me=ve(i,a,fe);if(me){let{panes:j,splitters:u}=se(me),S=e.current;if(S){for(let P of j)S.style.setProperty(`--pane-left-${P.paneId}`,`${P.left}%`),S.style.setProperty(`--pane-top-${P.paneId}`,`${P.top}%`),S.style.setProperty(`--pane-width-${P.paneId}`,`${P.width}%`),S.style.setProperty(`--pane-height-${P.paneId}`,`${P.height}%`);for(let P of u)S.style.setProperty(`--splitter-pos-${P.id}`,`${P.direction==="row"?P.left:P.top}%`);}}E&&E(a,fe);},onEnd:()=>{let N=ve(i,a,k),d=e.current;if(d){let{panes:B,splitters:ae}=se(N);for(let W of B)d.style.removeProperty(`--pane-left-${W.paneId}`),d.style.removeProperty(`--pane-top-${W.paneId}`),d.style.removeProperty(`--pane-width-${W.paneId}`),d.style.removeProperty(`--pane-height-${W.paneId}`);for(let W of ae)d.style.removeProperty(`--splitter-pos-${W.id}`);}l(N),D&&D(),L&&L(a,k);}});},[e,t,r,s,n,o,i,a,l,y,D,R,E,L,p,b,c,T,x,v])}var sn=({splitter:e,resizerSize:t,snapThreshold:r,containerRef:s})=>{let{layout:n,onLayoutChange:o,classNames:i,locked:a}=ee(),[l,y]=tn.useState(false),{currentNode:D,direction:c,left:T,top:x,width:v,height:R,parentLeft:E,parentTop:L,parentWidth:p,parentHeight:b}=e,f=c==="row",z=Je({containerRef:s,isRow:f,direction:c,splitPercentage:D.splitPercentage,resizerSize:t,snapThreshold:r,layout:n,currentNode:D,onLayoutChange:o,onResizeStart:()=>y(true),onResizeEnd:()=>y(false),parentLeft:E,parentTop:L,parentWidth:p,parentHeight:b}),A=f?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${T}%) - ${t/2}px)`,top:`calc(${x}% + ${t/2}px)`,width:`${t}px`,height:`calc(${R}% - ${t}px)`,cursor:a?"default":"col-resize",pointerEvents:a?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${T}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${x}%) - ${t/2}px)`,width:`calc(${v}% - ${t}px)`,height:`${t}px`,cursor:a?"default":"row-resize",pointerEvents:a?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsxRuntime.jsx("div",{className:`zeugma-resizer ${i.resizer||""}`.trim(),"data-direction":c,"data-resizing":l||void 0,style:A,onPointerDown:z,role:"separator","aria-valuenow":D.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},an=tn__default.default.memo(({paneId:e,renderPane:t})=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane),ln=({tree:e,resizerSize:t=4,snapThreshold:r})=>{let{layout:s,renderPane:n,activeId:o,dismissIntentId:i,setContainerRef:a,fullscreenPaneId:l,snapThreshold:y,locked:D,classNames:c}=ee(),T=r!==void 0?r:y??8,x=e!==void 0?e:s,v=tn.useRef(null),{panes:R,splitters:E}=tn.useMemo(()=>x?se(x):{panes:[],splitters:[]},[x]);if(!x)return null;let L=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[R.map(p=>{let b=l===p.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:b?"0%":`var(--pane-left-${p.paneId}, ${p.left}%)`,top:b?"0%":`var(--pane-top-${p.paneId}, ${p.top}%)`,width:b?"100%":`var(--pane-width-${p.paneId}, ${p.width}%)`,height:b?"100%":`var(--pane-height-${p.paneId}, ${p.height}%)`,overflow:"hidden",zIndex:b?20:1,display:l&&!b?"none":"block",padding:b?"0px":`${t/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(an,{paneId:p.paneId,renderPane:n})},p.paneId)}),!l&&E.map(p=>jsxRuntime.jsx(sn,{splitter:p,resizerSize:t,snapThreshold:T,containerRef:v},p.id))]});if(e===void 0){let p=o!==null&&o===i,b=z=>{a(z),v.current=z;},f=`zeugma-dashboard-root ${p?"zeugma-dashboard-dismiss-active":""} ${D?c.dashboardLocked||"zeugma-dashboard-locked":""}`.trim();return jsxRuntime.jsx("div",{ref:b,className:f,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:L()})}return jsxRuntime.jsx("div",{ref:v,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:L()})};var yt="zeugma-height:",pn="default-pane";function fn(e){try{let t=localStorage.getItem(yt+e);if(t!==null){let r=Number(t);if(Number.isFinite(r)&&r>0)return r}}catch{}return null}function Pt(e,t){try{localStorage.setItem(yt+e,String(Math.round(t)));}catch{}}var xt=({children:e,active:t=true,height:r,onHeightChange:s,minHeight:n=100,maxHeight:o=1/0,persist:i,localStorageKey:a,resizerHeight:l=6,className:y,resizerClassName:D})=>{let c=i?a||pn:null,T=()=>{let f=(c?fn(c):null)??r??400;return We(f,n,o)},[x,v]=tn.useState(T),R=tn.useRef(null),E=c?x:r??x,L=tn.useRef(r);tn.useEffect(()=>{if(r!==void 0&&r!==L.current){let f=We(r,n,o);v(f),c&&Pt(c,f);}L.current=r;},[r,n,o,c]);let p=tn.useCallback(()=>o,[o]),b=tn.useCallback(f=>{f.preventDefault();let z=f.clientY,A=E,I=p(),V=f.currentTarget,w=Tt(R.current),K=w?w.scrollTop:0,h=z,F=null,Y=(m,$)=>{let _=$-K,N=m-z+_,d=We(A+N,n,I);return R.current&&(R.current.style.height=`${d}px`),d},O=()=>{if(!w)return;let m=w===document.documentElement||w===document.body?{top:0,bottom:window.innerHeight}:w.getBoundingClientRect(),$=40,_=10,k=0;h>m.bottom-$?k=Math.min(1,(h-(m.bottom-$))/$)*_:h<m.top+$&&(k=-Math.min(1,(m.top+$-h)/$)*_),k!==0&&(w.scrollTop+=k,Y(h,w.scrollTop)),F=requestAnimationFrame(O);};F=requestAnimationFrame(O),Ve({cursor:"row-resize",resizerEl:V,onMove:m=>{h=m.clientY,w&&Y(h,w.scrollTop);},onEnd:()=>{F!==null&&cancelAnimationFrame(F);let m=A;R.current&&(m=R.current.getBoundingClientRect().height),m=We(m,n,I),v(m),s&&s(m),c&&Pt(c,m);}});},[E,n,p,s,c]);return t?jsxRuntime.jsxs("div",{ref:R,className:`zeugma-resizable-container ${y||""}`.trim(),style:{height:`${E}px`,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:[jsxRuntime.jsx("div",{style:{height:`calc(100% - ${l}px)`,overflow:"hidden"},children:e}),jsxRuntime.jsx("div",{className:`zeugma-resizable-handle ${D||""}`.trim(),style:{height:`${l}px`,cursor:"row-resize",position:"relative",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box",flexShrink:0},onPointerDown:b,role:"separator","aria-orientation":"horizontal","aria-valuenow":Math.round(E),"aria-valuemin":n,"aria-valuemax":o===1/0?void 0:o})]}):jsxRuntime.jsx("div",{className:`zeugma-resizable-container disabled ${y||""}`.trim(),style:{height:"100%",position:"relative",overflow:"hidden",boxSizing:"border-box"},children:jsxRuntime.jsx("div",{style:{height:"100%",overflow:"hidden"},children:e})})};function We(e,t,r){return Math.max(t,Math.min(r,e))}function Tt(e){if(typeof window>"u"||!e)return null;let t=e.parentElement;if(!t)return document.documentElement;let s=window.getComputedStyle(t).overflowY;return s==="auto"||s==="scroll"?t:Tt(t)}var _e=tn.createContext(null);var xn={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"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:20,pointerEvents:"auto",cursor:"not-allowed"}},Tn={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"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:21,pointerEvents:"none",boxSizing:"border-box"}},Rt=({id:e,position:t,activeClassName:r})=>{let{setNodeRef:s,isOver:n}=core.useDroppable({id:e});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:s,style:xn[t]}),n&&jsxRuntime.jsx("div",{className:r,style:Tn[t]})]})},Rn=({id:e,children:t,style:r,locked:s=false})=>{let{layout:n,activeId:o,classNames:i,fullscreenPaneId:a,onFullscreenChange:l,locked:y}=ee(),{removePane:D,updateTabMetadata:c,selectTab:T,removeTab:x}=$e(),v=tn.useContext(ke);if(!v)throw new Error("Pane must be used within a Zeugma provider");let{registerPortalTarget:R}=v,E=tn.useMemo(()=>q(n,e),[n,e]),L=E?.id??e,p=E?.tabs??[e],b=E?.activeTabId??e,f=E?.tabsMetadata,z=f?.[e],A=E?.locked??false,I=s||A,V=y||I,w=y||I,K=o!==null&&o!==e&&(!p.includes(o)||p.length>1)&&!w,{attributes:h,listeners:F,setNodeRef:Y}=core.useDraggable({id:e,disabled:V}),O=o!==null&&p.includes(o),m=a===e,$=tn.useCallback(()=>jsxRuntime.jsx("div",{id:`zeugma-tab-target-${b}`,className:"zeugma-tab-content-wrapper",style:{height:"100%",width:"100%"}}),[b]);tn.useEffect(()=>{let d=document.getElementById(`zeugma-tab-target-${b}`);return R(b,d),()=>{R(b,null);}},[b,R]);let _=tn.useMemo(()=>({isDragging:O,isFullscreen:m,toggleFullscreen:()=>l?.(m?null:e),remove:()=>{m&&l?.(null),D(L);},metadata:z,updateMetadata:d=>{c(e,d);},locked:V,tabs:p,activeTabId:b,selectTab:d=>T(L,d),removeTab:d=>{m&&d===b&&l?.(null),x(d);},tabsMetadata:f,updateTabMetadata:(d,B)=>{c(d,B);},renderActiveTab:$}),[O,m,l,e,x,z,c,V,p,b,T,L,f,$]),k=tn.useMemo(()=>V?{disabled:true}:{...F,...h},[F,h,V]),N=`${i.pane||""} ${I?i.paneLocked||"zeugma-pane-locked":""}`.trim();return jsxRuntime.jsx(_e.Provider,{value:k,children:jsxRuntime.jsxs("div",{ref:Y,className:N,style:{position:"relative",width:"100%",height:"100%",...r},children:[t(_),K&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(d=>jsxRuntime.jsx(Rt,{id:`drop-${d}-${e}`,position:d,activeClassName:i.dropPreview},d))}),o!==null&&o!==e&&w&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsxRuntime.jsx(Rt,{id:`drop-locked-${e}`,position:"full",activeClassName:i.lockedPreview||"zeugma-locked-preview"})})]})})};var En=({children:e,className:t,style:r})=>{let s=tn.useContext(_e);if(!s)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:n,...o}=s;return jsxRuntime.jsx("div",{className:t,style:{cursor:n?"default":"grab",userSelect:n?"auto":"none",touchAction:n?"auto":"none",...r},...n?{}:o,children:e})};var Mn=({id:e,locked:t=false,children:r,className:s,style:n})=>{let{locked:o}=ee(),i=t||o,{attributes:a,listeners:l,setNodeRef:y,isDragging:D}=core.useDraggable({id:`tab-header-${e}`,disabled:i}),{setNodeRef:c,isOver:T}=core.useDroppable({id:`tab-drop-${e}`,disabled:i});return jsxRuntime.jsx("div",{ref:v=>{y(v),c(v);},className:s,style:{display:"inline-flex",cursor:i?"default":"grab",...n},...i?{}:l,...i?{}:a,children:r({isDragging:D,isOver:T})})};exports.DEFAULT_DRAG_ACTIVATION_DISTANCE=At;exports.DEFAULT_RESIZER_SIZE=Fn;exports.DEFAULT_SNAP_THRESHOLD=Ht;exports.DragHandle=En;exports.Pane=Rn;exports.PaneTree=ln;exports.ResizableContainer=xt;exports.Tab=Mn;exports.Zeugma=jt;exports.addPane=lt;exports.computeLayout=se;exports.createDragSession=Ve;exports.findPane=q;exports.generateUniqueId=ie;exports.mergeTab=ct;exports.moveTab=ut;exports.removePane=be;exports.removeTab=de;exports.selectTab=Ae;exports.splitPane=ye;exports.updatePaneLock=He;exports.updateSplitPercentage=ve;exports.updateTabMetadata=Ze;exports.useResizer=Je;exports.useZeugma=Ft;exports.useZeugmaContext=Ot;//# sourceMappingURL=index.cjs.map
|
|
6
|
+
`,document.head.appendChild(r),t.setAttribute("data-resizing","true");let o=a=>{n(a);},i=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let a=document.getElementById("zeugma-global-cursor-style");a&&a.remove(),document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",i),s();};document.addEventListener("pointermove",o),document.addEventListener("pointerup",i);}function Le(e){try{return JSON.stringify(e)}catch{return ""}}function Ft(e){let{initialLayout:t,layout:n,onChange:s,fullscreenPaneId:r,onFullscreenChange:o,locked:i=false,dragActivationDistance:a=8,snapThreshold:l=8,minSplitPercentage:P=5,maxSplitPercentage:D=95,enableDragToDismiss:c=false,dismissThreshold:T=60,onRemove:y,onDragStart:v,onDragEnd:x,onResizeStart:C,onResize:z,onResizeEnd:d,onDismissIntentChange:h}=e,[S,N]=on.useState(()=>n!==void 0?n:t??null),[W,I]=on.useState(()=>Le(n!==void 0?n:null)),[X,w]=on.useState(r||null),[j,b]=on.useState(i),[O,J]=on.useState(null),[V,g]=on.useState(null),[Z,q]=on.useState(null),H=on.useRef(null),L=on.useCallback(p=>{H.current=p;},[]),u=on.useCallback(p=>{w(p),o?.(p);},[o]);if(on.useEffect(()=>{b(i);},[i]),on.useEffect(()=>{r!==void 0&&w(r);},[r]),n!==void 0){let p=Le(n);p!==W&&(I(p),N(n));}let f=on.useCallback(p=>(...R)=>{let k=S,ae=p(k,...R);Le(k)!==Le(ae)&&(N(ae),s?.(ae));},[S,s]),_=on.useCallback(f((p,R)=>typeof R=="function"?R(p):R),[f]),re=on.useCallback(f((p,R)=>ye(p,R)),[f]),ue=on.useCallback(f((p,R)=>pt(p,R)),[f]),be=on.useCallback(f((p,R,k,ae,he)=>{let $e=K(p,he)??{type:"pane",id:he,tabs:[he],activeTabId:he},je=ye(p,he);return De(je,R,k,ae,$e)}),[f]),ve=on.useCallback(f((p,R,k)=>Te(p,R,k)),[f]),Q=on.useCallback(f((p,R,k)=>_e(p,R,k)),[f]),U=on.useCallback(f((p,R,k)=>Ue(p,R,k)),[f]),oe=on.useCallback(f((p,R,k)=>Ye(p,R,k)),[f]),$=on.useCallback(f((p,R,k)=>ft(p,R,k)),[f]),ze=on.useCallback(f((p,R,k,ae)=>mt(p,R,k,ae)),[f]),Ie=on.useCallback(f((p,R)=>fe(p,R)),[f]);return {layout:S,setLayout:_,fullscreenPaneId:X,setFullscreenPaneId:u,locked:j,setLocked:b,activeId:O,setActiveId:J,activeType:V,setActiveType:g,dismissIntentId:Z,setDismissIntentId:q,containerRef:H,setContainerRef:L,dragActivationDistance:a,snapThreshold:l,minSplitPercentage:P,maxSplitPercentage:D,enableDragToDismiss:c,dismissThreshold:T,onRemove:y,onDragStart:v,onDragEnd:x,onResizeStart:C,onResize:z,onResizeEnd:d,onDismissIntentChange:h,removePane:re,addPane:ue,splitPane:be,updateSplitPercentage:ve,updateTabMetadata:Q,updatePaneLock:U,selectTab:oe,mergeTab:$,moveTab:ze,removeTab:Ie}}var Ot=()=>{let e=ne(),t=Ve();return {...e,...t}};var bt=({activeId:e,render:t,className:n})=>{let s=on.useRef(null);return on.useEffect(()=>{let r=o=>{s.current&&(s.current.style.transform=`translate(${o.clientX+12}px, ${o.clientY+12}px)`);};return document.addEventListener("pointermove",r),()=>document.removeEventListener("pointermove",r)},[]),jsxRuntime.jsx("div",{ref:s,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var Xe=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},qe=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};var vt=({tabId:e,target:t,renderWidget:n})=>{let[s,r]=on.useState(false),o=on.useRef(null);if(on.useEffect(()=>{r(true);},[]),on.useEffect(()=>{if(!s||!o.current)return;let a=o.current;if(t)t.appendChild(a);else {let l=document.getElementById("zeugma-hidden-portal-container");l||(l=document.createElement("div"),l.id="zeugma-hidden-portal-container",l.style.display="none",document.body.appendChild(l)),l.appendChild(a);}},[t,s]),on.useEffect(()=>()=>{o.current&&o.current.remove();},[]),!s)return null;o.current||(o.current=document.createElement("div"),o.current.className=`zeugma-portal-wrapper-${e}`,o.current.style.width="100%",o.current.style.height="100%");let i=o.current;return !i||!n?null:reactDom.createPortal(n(e),i)};function nt(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 tn=e=>{let{renderPane:t,renderWidget:n,renderDragOverlay:s,classNames:r={},children:o,layout:i,setLayout:a,fullscreenPaneId:l,setFullscreenPaneId:P,locked:D,activeId:c,setActiveId:T,activeType:y,setActiveType:v,dismissIntentId:x,setDismissIntentId:C,containerRef:z,setContainerRef:d,dragActivationDistance:h,snapThreshold:S,minSplitPercentage:N,maxSplitPercentage:W,enableDragToDismiss:I,dismissThreshold:X,onRemove:w,onDragStart:j,onDragEnd:b,onResizeStart:O,onResize:J,onResizeEnd:V,onDismissIntentChange:g,removePane:Z,addPane:q,splitPane:H,updateSplitPercentage:L,updateTabMetadata:u,updatePaneLock:f,selectTab:ge,mergeTab:_,moveTab:re,removeTab:ue}=e,{portalTargets:be,registerPortalTarget:ve}=dt(),Q=on.useRef(null),U=ct(c),[oe,$]=on.useState(false);ut(oe);let ze=on.useCallback(m=>t(m),[t]),Ie=on.useMemo(()=>r,[r.pane,r.paneLocked,r.dropPreview,r.dragOverlay,r.resizer,r.dismissPreview,r.dashboardLocked,r.lockedPreview]),p=core.useSensors(core.useSensor(Xe,{activationConstraint:{distance:h}}),core.useSensor(qe,{activationConstraint:{delay:250,tolerance:5}})),R=on.useCallback(m=>{let A=core.pointerWithin(m);if(A.length>0)return A;if(m.active.id.toString().startsWith("tab-header-")){let se=m.droppableContainers.filter(ee=>ee.id.toString().startsWith("tab-drop-"));return core.closestCenter({...m,droppableContainers:se})}return []},[]),k=m=>{let A=m.active.id.toString(),Y=A.startsWith("tab-header-"),se=Y?A.substring(11):A;T(se),v(Y?"tab":"pane");let ee=m.activatorEvent;U.current=nt(ee),I&&z.current?Q.current=z.current.getBoundingClientRect():Q.current=null,j&&j(se);},ae=m=>{let{over:A}=m,se=(A?.id.toString()||"").startsWith("drop-locked-");if($(se),!I)return;let ee=m.active.id.toString(),Ee=ee.startsWith("tab-header-")?ee.substring(11):ee,M=Q.current;if(!M){x!==null&&(C(null),g?.(null));return}let ke=m.activatorEvent,ie=null,G=null;if(U.current)ie=U.current.x,G=U.current.y;else {let F=nt(ke);F&&(ie=F.x+m.delta.x,G=F.y+m.delta.y);}let de=0;if(ie!==null&&G!==null){let F=0,te=0;ie<M.left?F=M.left-ie:ie>M.right&&(F=ie-M.right),G<M.top?te=M.top-G:G>M.bottom&&(te=G-M.bottom),de=Math.sqrt(F*F+te*te);}else {let F=m.active.rect.current.translated;if(F){let te=F.left+F.width/2,Pe=F.top+F.height/2,pe=0,Se=0;te<M.left?pe=M.left-te:te>M.right&&(pe=te-M.right),Pe<M.top?Se=M.top-Pe:Pe>M.bottom&&(Se=Pe-M.bottom),de=Math.sqrt(pe*pe+Se*Se);}}de>X?x!==Ee&&(C(Ee),g?.(Ee)):x!==null&&(C(null),g?.(null));},he=m=>{T(null),v(null),$(false);let{active:A,over:Y}=m,se=A.id.toString(),ee=se.startsWith("tab-header-"),E=ee?se.substring(11):se,Ee=I&&x===E;if(C(null),g?.(null),Q.current=null,Ee){w?w(E):ue(E),b&&b(E,null,null);return}if(!Y){b&&b(E,null,null);return}let M=Y.id.toString();if(M.startsWith("drop-locked-")){b&&b(E,null,null);return}let ke=M.match(/^tab-drop-(.+)$/);if(ke){let[,Ze]=ke;if(E!==Ze){let Ne="before",st=Y.rect,zt=m.activatorEvent,He=null;if(U.current)He=U.current.x;else {let Ae=nt(zt);Ae&&(He=Ae.x+m.delta.x);}if(He!==null){let Ae=st.left+st.width/2;He>Ae&&(Ne="after");}re(E,Ze,Ne);}b&&b(E,Ze,{type:"swap",position:"center"});return}let ie=M.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!ie){b&&b(E,null,null);return}let[,G,de]=ie,we=K(i,E),F=we&&we.id===de,te=we&&we.tabs.length===1;if(E===de||F&&te){b&&b(E,null,null);return}let Pe=G==="left"||G==="right"?"row":"column",pe;if(ee){let Ne=K(i,E)?.tabsMetadata?.[E];pe={type:"pane",id:ce(),tabs:[E],activeTabId:E,tabsMetadata:Ne?{[E]:Ne}:void 0};}else pe=K(i,E)??{type:"pane",id:ce(),tabs:[E],activeTabId:E};let Se=ee?fe(i,E):ye(i,E),Mt=De(Se,de,Pe,G,pe);a(Mt),b&&b(E,de,{type:"split",direction:Pe,position:G});},$e=on.useCallback((m,A)=>{V&&V(m,A);},[V]),je=on.useMemo(()=>({layout:i,onLayoutChange:m=>a(m),renderPane:ze,activeId:c,dismissIntentId:x,setContainerRef:d,fullscreenPaneId:l,classNames:Ie,onRemove:w,onFullscreenChange:P,snapThreshold:S,onResizeStart:O,onResize:J,onResizeEnd:$e,minSplitPercentage:N,maxSplitPercentage:W,locked:D}),[i,c,x,d,l,Ie,w,P,S,O,J,N,W,a,ze,$e,D]),wt=on.useMemo(()=>({removePane:Z,addPane:q,splitPane:H,updateSplitPercentage:L,updateTabMetadata:u,updatePaneLock:f,selectTab:ge,mergeTab:_,moveTab:re,removeTab:ue}),[Z,q,H,L,u,f,ge,_,re,ue]),Nt=on.useMemo(()=>{let m=[];function A(Y){Y&&(Y.type==="pane"?m.push(...Y.tabs):(A(Y.first),A(Y.second)));}return A(i),m},[i]),Lt=on.useMemo(()=>({registerPortalTarget:ve}),[ve]);return jsxRuntime.jsx(Oe.Provider,{value:wt,children:jsxRuntime.jsx(Fe.Provider,{value:je,children:jsxRuntime.jsxs(We.Provider,{value:Lt,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",sensors:p,collisionDetection:R,onDragStart:k,onDragMove:ae,onDragEnd:he,children:o}),c&&y&&s&&jsxRuntime.jsx(bt,{activeId:c,render:m=>s(m,y),className:`${r.dragOverlay||""} ${c===x?r.dismissPreview||"zeugma-dismiss-preview":""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:Nt.map(m=>jsxRuntime.jsx(vt,{tabId:m,target:be[m]||null,renderWidget:n},m))})]})})})};function rt({containerRef:e,isRow:t,direction:n,splitPercentage:s,resizerSize:r,snapThreshold:o,layout:i,currentNode:a,onLayoutChange:l,onResizeStart:P,onResizeEnd:D,parentLeft:c,parentTop:T,parentWidth:y,parentHeight:v}){let{onResizeStart:x,onResize:C,onResizeEnd:z,minSplitPercentage:d=5,maxSplitPercentage:h=95,locked:S=false}=ne();return on.useCallback(N=>{if(S)return;N.preventDefault();let W=e.current;if(!W)return;P&&P(),x&&x(a);let I=W.getBoundingClientRect(),X=N.clientX,w=N.clientY,j=s,b=N.currentTarget,O=I.left+I.width*(c/100),J=I.top+I.height*(T/100),V=I.width*(y/100),g=I.height*(v/100),q=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(L=>L!==b&&L.getAttribute("data-direction")===n).map(L=>{let u=L.getBoundingClientRect();return t?u.left+u.width/2:u.top+u.height/2}),H=j;Be({cursor:t?"col-resize":"row-resize",resizerEl:b,onMove:L=>{let u=t?(L.clientX-X)/V*100:(L.clientY-w)/g*100,f=j+u,ge=t?O+(V-r)*(f/100)+r/2:J+(g-r)*(f/100)+r/2,_=1/0,re=null;for(let Q of q){let U=Math.abs(ge-Q);U<o&&U<_&&(_=U,re=Q);}let ue=f;re!==null&&(ue=t?(re-r/2-O)/(V-r)*100:(re-r/2-J)/(g-r)*100);let be=Math.max(d,Math.min(h,ue));H=be;let ve=Te(i,a,be);if(ve){let{panes:Q,splitters:U}=le(ve),oe=e.current;if(oe){for(let $ of Q)oe.style.setProperty(`--pane-left-${$.paneId}`,`${$.left}%`),oe.style.setProperty(`--pane-top-${$.paneId}`,`${$.top}%`),oe.style.setProperty(`--pane-width-${$.paneId}`,`${$.width}%`),oe.style.setProperty(`--pane-height-${$.paneId}`,`${$.height}%`);for(let $ of U)oe.style.setProperty(`--splitter-pos-${$.id}`,`${$.direction==="row"?$.left:$.top}%`);}}C&&C(a,be);},onEnd:()=>{let L=Te(i,a,H),u=e.current;if(u){let{panes:f,splitters:ge}=le(L);for(let _ of f)u.style.removeProperty(`--pane-left-${_.paneId}`),u.style.removeProperty(`--pane-top-${_.paneId}`),u.style.removeProperty(`--pane-width-${_.paneId}`),u.style.removeProperty(`--pane-height-${_.paneId}`);for(let _ of ge)u.style.removeProperty(`--splitter-pos-${_.id}`);}l(L),D&&D(),z&&z(a,H);}});},[e,t,n,s,r,o,i,a,l,P,D,x,C,z,d,h,c,T,y,v])}var cn=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:s})=>{let{layout:r,onLayoutChange:o,classNames:i,locked:a}=ne(),[l,P]=on.useState(false),{currentNode:D,direction:c,left:T,top:y,width:v,height:x,parentLeft:C,parentTop:z,parentWidth:d,parentHeight:h}=e,S=c==="row",N=rt({containerRef:s,isRow:S,direction:c,splitPercentage:D.splitPercentage,resizerSize:t,snapThreshold:n,layout:r,currentNode:D,onLayoutChange:o,onResizeStart:()=>P(true),onResizeEnd:()=>P(false),parentLeft:C,parentTop:z,parentWidth:d,parentHeight:h}),W=S?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${T}%) - ${t/2}px)`,top:`calc(${y}% + ${t/2}px)`,width:`${t}px`,height:`calc(${x}% - ${t}px)`,cursor:a?"default":"col-resize",pointerEvents:a?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${T}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${y}%) - ${t/2}px)`,width:`calc(${v}% - ${t}px)`,height:`${t}px`,cursor:a?"default":"row-resize",pointerEvents:a?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsxRuntime.jsx("div",{className:`zeugma-resizer ${i.resizer||""}`.trim(),"data-direction":c,"data-resizing":l||void 0,style:W,onPointerDown:N,role:"separator","aria-valuenow":D.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},un=on__default.default.memo(({paneId:e,renderPane:t})=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane),dn=({tree:e,resizerSize:t=4,snapThreshold:n})=>{let{layout:s,renderPane:r,activeId:o,dismissIntentId:i,setContainerRef:a,fullscreenPaneId:l,snapThreshold:P,locked:D,classNames:c}=ne(),T=n!==void 0?n:P??8,y=e!==void 0?e:s,v=on.useRef(null),{panes:x,splitters:C}=on.useMemo(()=>y?le(y):{panes:[],splitters:[]},[y]);if(!y)return null;let z=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[x.map(d=>{let h=l===d.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:h?"0%":`var(--pane-left-${d.paneId}, ${d.left}%)`,top:h?"0%":`var(--pane-top-${d.paneId}, ${d.top}%)`,width:h?"100%":`var(--pane-width-${d.paneId}, ${d.width}%)`,height:h?"100%":`var(--pane-height-${d.paneId}, ${d.height}%)`,overflow:"hidden",zIndex:h?20:1,display:l&&!h?"none":"block",padding:h?"0px":`${t/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(un,{paneId:d.paneId,renderPane:r})},d.paneId)}),!l&&C.map(d=>jsxRuntime.jsx(cn,{splitter:d,resizerSize:t,snapThreshold:T,containerRef:v},d.id))]});if(e===void 0){let d=o!==null&&o===i,h=N=>{a(N),v.current=N;},S=`zeugma-dashboard-root ${d?"zeugma-dashboard-dismiss-active":""} ${D?c.dashboardLocked||"zeugma-dashboard-locked":""}`.trim();return jsxRuntime.jsx("div",{ref:h,className:S,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:z()})}return jsxRuntime.jsx("div",{ref:v,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:z()})};var Rt="zeugma-height:",gn="default-pane";function bn(e){try{let t=localStorage.getItem(Rt+e);if(t!==null){let n=Number(t);if(Number.isFinite(n)&&n>0)return n}}catch{}return null}function xt(e,t){try{localStorage.setItem(Rt+e,String(Math.round(t)));}catch{}}var St=({children:e,active:t=true,height:n,onHeightChange:s,minHeight:r=100,maxHeight:o=1/0,persist:i,localStorageKey:a,resizerHeight:l=6,className:P,resizerClassName:D})=>{let c=i?a||gn:null,T=()=>{let S=(c?bn(c):null)??n??400;return Je(S,r,o)},[y,v]=on.useState(T),x=on.useRef(null),C=c?y:n??y,z=on.useRef(n);on.useEffect(()=>{if(n!==void 0&&n!==z.current){let S=Je(n,r,o);v(S),c&&xt(c,S);}z.current=n;},[n,r,o,c]);let d=on.useCallback(()=>o,[o]),h=on.useCallback(S=>{S.preventDefault();let N=S.clientY,W=C,I=d(),X=S.currentTarget,w=Dt(x.current),j=w?w.scrollTop:0,b=N,O=null,J=(g,Z)=>{let q=Z-j,L=g-N+q,u=Je(W+L,r,I);return x.current&&(x.current.style.height=`${u}px`),u},V=()=>{if(!w)return;let g=w===document.documentElement||w===document.body?{top:0,bottom:window.innerHeight}:w.getBoundingClientRect(),Z=40,q=10,H=0;b>g.bottom-Z?H=Math.min(1,(b-(g.bottom-Z))/Z)*q:b<g.top+Z&&(H=-Math.min(1,(g.top+Z-b)/Z)*q),H!==0&&(w.scrollTop+=H,J(b,w.scrollTop)),O=requestAnimationFrame(V);};O=requestAnimationFrame(V),Be({cursor:"row-resize",resizerEl:X,onMove:g=>{b=g.clientY,w&&J(b,w.scrollTop);},onEnd:()=>{O!==null&&cancelAnimationFrame(O);let g=W;x.current&&(g=x.current.getBoundingClientRect().height),g=Je(g,r,I),v(g),s&&s(g),c&&xt(c,g);}});},[C,r,d,s,c]);return t?jsxRuntime.jsxs("div",{ref:x,className:`zeugma-resizable-container ${P||""}`.trim(),style:{height:`${C}px`,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:[jsxRuntime.jsx("div",{style:{height:`calc(100% - ${l}px)`,overflow:"hidden"},children:e}),jsxRuntime.jsx("div",{className:`zeugma-resizable-handle ${D||""}`.trim(),style:{height:`${l}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(C),"aria-valuemin":r,"aria-valuemax":o===1/0?void 0:o})]}):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 Je(e,t,n){return Math.max(t,Math.min(n,e))}function Dt(e){if(typeof window>"u"||!e)return null;let t=e.parentElement;if(!t)return document.documentElement;let s=window.getComputedStyle(t).overflowY;return s==="auto"||s==="scroll"?t:Dt(t)}var Ke=on.createContext(null);var Sn={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"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:20,pointerEvents:"auto",cursor:"not-allowed"}},Dn={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"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:21,pointerEvents:"none",boxSizing:"border-box"}},Ct=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:s,isOver:r}=core.useDroppable({id:e});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:s,style:Sn[t]}),r&&jsxRuntime.jsx("div",{className:n,style:Dn[t]})]})},Cn=({id:e,children:t,style:n,locked:s=false})=>{let{layout:r,activeId:o,classNames:i,fullscreenPaneId:a,onFullscreenChange:l,locked:P}=ne(),{removePane:D,updateTabMetadata:c,selectTab:T,removeTab:y}=Ve(),v=on.useContext(We);if(!v)throw new Error("Pane must be used within a Zeugma provider");let{registerPortalTarget:x}=v,C=on.useMemo(()=>K(r,e),[r,e]),z=C?.id??e,d=C?.tabs??[e],h=C?.activeTabId??e,S=C?.tabsMetadata,N=S?.[e],W=C?.locked??false,I=s||W,X=P||I,w=P||I,j=o!==null&&o!==e&&(!d.includes(o)||d.length>1)&&!w,{attributes:b,listeners:O,setNodeRef:J}=core.useDraggable({id:e,disabled:X}),V=o!==null&&d.includes(o),g=a===e,Z=on.useCallback(()=>jsxRuntime.jsx("div",{id:`zeugma-tab-target-${h}`,className:"zeugma-tab-content-wrapper",style:{height:"100%",width:"100%"}}),[h]);on.useEffect(()=>{let u=document.getElementById(`zeugma-tab-target-${h}`);return x(h,u),()=>{x(h,null);}},[h,x]);let q=on.useMemo(()=>({isDragging:V,isFullscreen:g,toggleFullscreen:()=>l?.(g?null:e),remove:()=>{g&&l?.(null),D(z);},metadata:N,updateMetadata:u=>{c(e,u);},locked:X,tabs:d,activeTabId:h,selectTab:u=>T(z,u),removeTab:u=>{g&&u===h&&l?.(null),y(u);},tabsMetadata:S,updateTabMetadata:(u,f)=>{c(u,f);},renderActiveTab:Z}),[V,g,l,e,y,N,c,X,d,h,T,z,S,Z]),H=on.useMemo(()=>X?{disabled:true}:{...O,...b},[O,b,X]),L=`${i.pane||""} ${I?i.paneLocked||"zeugma-pane-locked":""}`.trim();return jsxRuntime.jsx(Ke.Provider,{value:H,children:jsxRuntime.jsxs("div",{ref:J,className:L,style:{position:"relative",width:"100%",height:"100%",...n},children:[t(q),j&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(u=>jsxRuntime.jsx(Ct,{id:`drop-${u}-${e}`,position:u,activeClassName:i.dropPreview},u))}),o!==null&&o!==e&&w&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsxRuntime.jsx(Ct,{id:`drop-locked-${e}`,position:"full",activeClassName:i.lockedPreview||"zeugma-locked-preview"})})]})})};var Nn=({children:e,className:t,style:n})=>{let s=on.useContext(Ke);if(!s)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:r,...o}=s;return jsxRuntime.jsx("div",{className:t,style:{cursor:r?"default":"grab",userSelect:r?"auto":"none",touchAction:r?"auto":"none",...n},...r?{}:o,children:e})};var In=({id:e,locked:t=false,children:n,className:s,style:r})=>{let{locked:o}=ne(),i=t||o,{attributes:a,listeners:l,setNodeRef:P,isDragging:D}=core.useDraggable({id:`tab-header-${e}`,disabled:i}),{setNodeRef:c,isOver:T}=core.useDroppable({id:`tab-drop-${e}`,disabled:i});return jsxRuntime.jsx("div",{ref:v=>{P(v),c(v);},className:s,style:{display:"inline-flex",cursor:i?"default":"grab",...r},...i?{}:l,...i?{}:a,children:n({isDragging:D,isOver:T})})};exports.DEFAULT_DRAG_ACTIVATION_DISTANCE=Ht;exports.DEFAULT_RESIZER_SIZE=Wn;exports.DEFAULT_SNAP_THRESHOLD=Zt;exports.DragHandle=Nn;exports.Pane=Cn;exports.PaneTree=dn;exports.ResizableContainer=St;exports.Tab=In;exports.Zeugma=tn;exports.addPane=pt;exports.computeLayout=le;exports.createDragSession=Be;exports.findPane=K;exports.generateUniqueId=ce;exports.mergeTab=ft;exports.moveTab=mt;exports.removePane=ye;exports.removeTab=fe;exports.safeJsonStringify=Le;exports.selectTab=Ye;exports.splitPane=De;exports.updatePaneLock=Ue;exports.updateSplitPercentage=Te;exports.updateTabMetadata=_e;exports.useResizer=rt;exports.useZeugma=Ft;exports.useZeugmaContext=Ot;//# sourceMappingURL=index.cjs.map
|
|
7
7
|
//# sourceMappingURL=index.cjs.map
|