react-zeugma 6.0.5 → 6.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 +58 -0
- package/dist/{types-Kf7gkm94.d.cts → dom-R8IgsWVo.d.cts} +18 -1
- package/dist/{types-Kf7gkm94.d.ts → dom-R8IgsWVo.d.ts} +18 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +2 -1
- package/dist/utils.d.ts +2 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -301,6 +301,64 @@ Recursively computes the absolute position and dimensions (as percentages relati
|
|
|
301
301
|
|
|
302
302
|
Calculates the target insertion index for a dragged tab within a list of tabs. Returns `-1` if the drop target is not in the list.
|
|
303
303
|
|
|
304
|
+
#### `getOrCreateHiddenContainer(id: string): HTMLElement`
|
|
305
|
+
|
|
306
|
+
Retrieves or initializes a hidden container `div` appended to `document.body` for sheltering portal elements while they are inactive or popped out.
|
|
307
|
+
|
|
308
|
+
## Popping Out Tabs (Open in a New Window)
|
|
309
|
+
|
|
310
|
+
`react-zeugma` includes built-in support for popping out tab panels into separate browser windows (popouts) with **zero React component unmounting or state loss**.
|
|
311
|
+
|
|
312
|
+
### How it Works
|
|
313
|
+
|
|
314
|
+
1. **State-Driven**: The popped-out state of tabs is tracked in a dedicated `popoutTabs` state map (mapping tab IDs to booleans) on the controller.
|
|
315
|
+
2. **Stable Portal target**: The React portal container reference is kept stable, and `document.adoptNode` is used to migrate the DOM container directly between parent and popup documents, keeping internal component state (like inputs, terminal histories, or connections) fully intact.
|
|
316
|
+
3. **Style Syncing**: Active stylesheets and link tags are automatically copied from the parent workspace into the popup window on creation.
|
|
317
|
+
4. **Auto-Restoration**: Close actions on the popup window automatically update the state via `setTabPopout(tabId, false)` and restore the tab wrapper back to the main document layout.
|
|
318
|
+
|
|
319
|
+
### Integration Recipe
|
|
320
|
+
|
|
321
|
+
To enable popping out tabs in your dashboard:
|
|
322
|
+
|
|
323
|
+
#### 1. Add a Popout Toggle Button
|
|
324
|
+
|
|
325
|
+
Inside your pane header or controls, add a button to toggle the popout state of the active tab:
|
|
326
|
+
|
|
327
|
+
```tsx
|
|
328
|
+
<button
|
|
329
|
+
onClick={() => {
|
|
330
|
+
const activeTabId = paneProps.activeTabId
|
|
331
|
+
const isPopout = !!zeugma.popoutTabs[activeTabId]
|
|
332
|
+
zeugma.setTabPopout(activeTabId, !isPopout)
|
|
333
|
+
}}
|
|
334
|
+
>
|
|
335
|
+
{zeugma.popoutTabs[paneProps.activeTabId] ? 'Restore' : 'Popout'}
|
|
336
|
+
</button>
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
#### 2. Display a Placeholder in the Workspace Layout
|
|
340
|
+
|
|
341
|
+
When a tab is open in a separate window, render a custom placeholder inside the main workspace pane instead of rendering the tab's active content:
|
|
342
|
+
|
|
343
|
+
```tsx
|
|
344
|
+
<div className="pane-body">
|
|
345
|
+
{zeugma.popoutTabs[paneProps.activeTabId] ? (
|
|
346
|
+
<div className="popout-placeholder">
|
|
347
|
+
<p>This tab is open in a separate window.</p>
|
|
348
|
+
<button
|
|
349
|
+
onClick={() => {
|
|
350
|
+
zeugma.setTabPopout(paneProps.activeTabId, false)
|
|
351
|
+
}}
|
|
352
|
+
>
|
|
353
|
+
Restore Tab
|
|
354
|
+
</button>
|
|
355
|
+
</div>
|
|
356
|
+
) : (
|
|
357
|
+
paneProps.renderActiveTab()
|
|
358
|
+
)}
|
|
359
|
+
</div>
|
|
360
|
+
```
|
|
361
|
+
|
|
304
362
|
---
|
|
305
363
|
|
|
306
364
|
## Custom Styling
|
|
@@ -81,6 +81,8 @@ interface ZeugmaController {
|
|
|
81
81
|
locked: boolean;
|
|
82
82
|
/** Programmatically updates the global locked status. */
|
|
83
83
|
setLocked: Dispatch<SetStateAction<boolean>>;
|
|
84
|
+
/** Map of tab IDs to their popped-out state. */
|
|
85
|
+
popoutTabs: Record<string, boolean>;
|
|
84
86
|
/** The ID of the active dragged item (pane or tab). */
|
|
85
87
|
activeId: string | null;
|
|
86
88
|
/** The type of the active dragged item ('pane' | 'tab'). */
|
|
@@ -133,6 +135,8 @@ interface ZeugmaController {
|
|
|
133
135
|
updateSplitPercentage: (currentNode: SplitNode, percentage: number) => void;
|
|
134
136
|
/** Moves/reorders a tab relative to another target tab. */
|
|
135
137
|
moveTab: (draggedTabId: string, targetTabId: string, position?: 'before' | 'after') => void;
|
|
138
|
+
/** Sets the popped-out state of a tab. */
|
|
139
|
+
setTabPopout: (tabId: string, popped: boolean) => void;
|
|
136
140
|
/** Find a PaneNode by its ID in the layout tree. */
|
|
137
141
|
findPaneById: (paneId: string) => PaneNode | null;
|
|
138
142
|
/** Find the PaneNode containing the given tab ID in the layout tree. */
|
|
@@ -197,6 +201,8 @@ interface ZeugmaStateValue {
|
|
|
197
201
|
locked: boolean;
|
|
198
202
|
/** Programmatically updates the global locked status. */
|
|
199
203
|
setLocked: Dispatch<SetStateAction<boolean>>;
|
|
204
|
+
/** Map of tab IDs to their popped-out state. */
|
|
205
|
+
popoutTabs: Record<string, boolean>;
|
|
200
206
|
/** Find a PaneNode by its ID in the layout tree. */
|
|
201
207
|
findPaneById: (paneId: string) => PaneNode | null;
|
|
202
208
|
/** Find the PaneNode containing the given tab ID in the layout tree. */
|
|
@@ -256,6 +262,8 @@ interface ZeugmaActionsValue {
|
|
|
256
262
|
updateSplitPercentage: (currentNode: SplitNode, percentage: number) => void;
|
|
257
263
|
/** Moves/reorders a tab relative to another target tab. */
|
|
258
264
|
moveTab: (draggedTabId: string, targetTabId: string, position?: 'before' | 'after') => void;
|
|
265
|
+
/** Sets the popped-out state of a tab. */
|
|
266
|
+
setTabPopout: (tabId: string, popped: boolean) => void;
|
|
259
267
|
}
|
|
260
268
|
interface ZeugmaContextValue extends ZeugmaStateValue, ZeugmaActionsValue {
|
|
261
269
|
}
|
|
@@ -263,4 +271,13 @@ interface PortalRegistryValue {
|
|
|
263
271
|
registerPortalTarget: (tabId: string, el: HTMLDivElement | null) => void;
|
|
264
272
|
}
|
|
265
273
|
|
|
266
|
-
|
|
274
|
+
/**
|
|
275
|
+
* Utility to copy stylesheets from source document to destination document.
|
|
276
|
+
*/
|
|
277
|
+
declare function copyStyles(srcDoc: Document, destDoc: Document): void;
|
|
278
|
+
/**
|
|
279
|
+
* Utility to get or create a hidden container element on the document body.
|
|
280
|
+
*/
|
|
281
|
+
declare function getOrCreateHiddenContainer(id: string): HTMLElement;
|
|
282
|
+
|
|
283
|
+
export { type PortalRegistryValue as P, type SplitDirection as S, type TreeNode as T, type UseZeugmaOptions as U, type ZeugmaActionsValue as Z, type ZeugmaDragStateValue as a, type ZeugmaStateValue as b, type ZeugmaController as c, type ZeugmaContextValue as d, type ZeugmaProps as e, type SplitNode as f, type PaneNode as g, type TabDetails as h, type ZeugmaClassNames as i, copyStyles as j, getOrCreateHiddenContainer as k };
|
|
@@ -81,6 +81,8 @@ interface ZeugmaController {
|
|
|
81
81
|
locked: boolean;
|
|
82
82
|
/** Programmatically updates the global locked status. */
|
|
83
83
|
setLocked: Dispatch<SetStateAction<boolean>>;
|
|
84
|
+
/** Map of tab IDs to their popped-out state. */
|
|
85
|
+
popoutTabs: Record<string, boolean>;
|
|
84
86
|
/** The ID of the active dragged item (pane or tab). */
|
|
85
87
|
activeId: string | null;
|
|
86
88
|
/** The type of the active dragged item ('pane' | 'tab'). */
|
|
@@ -133,6 +135,8 @@ interface ZeugmaController {
|
|
|
133
135
|
updateSplitPercentage: (currentNode: SplitNode, percentage: number) => void;
|
|
134
136
|
/** Moves/reorders a tab relative to another target tab. */
|
|
135
137
|
moveTab: (draggedTabId: string, targetTabId: string, position?: 'before' | 'after') => void;
|
|
138
|
+
/** Sets the popped-out state of a tab. */
|
|
139
|
+
setTabPopout: (tabId: string, popped: boolean) => void;
|
|
136
140
|
/** Find a PaneNode by its ID in the layout tree. */
|
|
137
141
|
findPaneById: (paneId: string) => PaneNode | null;
|
|
138
142
|
/** Find the PaneNode containing the given tab ID in the layout tree. */
|
|
@@ -197,6 +201,8 @@ interface ZeugmaStateValue {
|
|
|
197
201
|
locked: boolean;
|
|
198
202
|
/** Programmatically updates the global locked status. */
|
|
199
203
|
setLocked: Dispatch<SetStateAction<boolean>>;
|
|
204
|
+
/** Map of tab IDs to their popped-out state. */
|
|
205
|
+
popoutTabs: Record<string, boolean>;
|
|
200
206
|
/** Find a PaneNode by its ID in the layout tree. */
|
|
201
207
|
findPaneById: (paneId: string) => PaneNode | null;
|
|
202
208
|
/** Find the PaneNode containing the given tab ID in the layout tree. */
|
|
@@ -256,6 +262,8 @@ interface ZeugmaActionsValue {
|
|
|
256
262
|
updateSplitPercentage: (currentNode: SplitNode, percentage: number) => void;
|
|
257
263
|
/** Moves/reorders a tab relative to another target tab. */
|
|
258
264
|
moveTab: (draggedTabId: string, targetTabId: string, position?: 'before' | 'after') => void;
|
|
265
|
+
/** Sets the popped-out state of a tab. */
|
|
266
|
+
setTabPopout: (tabId: string, popped: boolean) => void;
|
|
259
267
|
}
|
|
260
268
|
interface ZeugmaContextValue extends ZeugmaStateValue, ZeugmaActionsValue {
|
|
261
269
|
}
|
|
@@ -263,4 +271,13 @@ interface PortalRegistryValue {
|
|
|
263
271
|
registerPortalTarget: (tabId: string, el: HTMLDivElement | null) => void;
|
|
264
272
|
}
|
|
265
273
|
|
|
266
|
-
|
|
274
|
+
/**
|
|
275
|
+
* Utility to copy stylesheets from source document to destination document.
|
|
276
|
+
*/
|
|
277
|
+
declare function copyStyles(srcDoc: Document, destDoc: Document): void;
|
|
278
|
+
/**
|
|
279
|
+
* Utility to get or create a hidden container element on the document body.
|
|
280
|
+
*/
|
|
281
|
+
declare function getOrCreateHiddenContainer(id: string): HTMLElement;
|
|
282
|
+
|
|
283
|
+
export { type PortalRegistryValue as P, type SplitDirection as S, type TreeNode as T, type UseZeugmaOptions as U, type ZeugmaActionsValue as Z, type ZeugmaDragStateValue as a, type ZeugmaStateValue as b, type ZeugmaController as c, type ZeugmaContextValue as d, type ZeugmaProps as e, type SplitNode as f, type PaneNode as g, type TabDetails as h, type ZeugmaClassNames as i, copyStyles as j, getOrCreateHiddenContainer as k };
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
'use strict';var _t=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 _t__default=/*#__PURE__*/_interopDefault(_t);function tt(e){let t=_t.useRef(null);return _t.useEffect(()=>{if(!e){t.current=null;return}let n=o=>{t.current={x:o.clientX,y:o.clientY};},s=o=>{let r=o.touches[0]||o.changedTouches[0];r&&(t.current={x:r.clientX,y:r.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 nt(e){_t.useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function ot(){let[e,t]=_t.useState({}),n=_t.useRef(true);_t.useEffect(()=>(n.current=true,()=>{n.current=false;}),[]);let s=_t.useCallback((o,r)=>{n.current&&t(a=>a[o]===r?a:{...a,[o]:r});},[]);return {portalTargets:e,registerPortalTarget:s}}var It=8,Lt=8,On=4;function de(){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 n=be(e.first,t),s=be(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 o=e.tabs.filter(l=>l!==t);if(o.length===0)return null;let r=e.activeTabId;e.activeTabId===t&&(r=o[0]);let a={...e.tabsMetadata};return delete a[t],{...e,tabs:o,activeTabId:r,tabsMetadata:Object.keys(a).length>0?a: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 ye(e,t,n,s,o){if(e===null)return typeof o=="string"?{type:"pane",id:de(),tabs:[o],activeTabId:o}:o;if(e.type==="pane"){if(e.id===t){let r=typeof o=="string"?{type:"pane",id:de(),tabs:[o],activeTabId:o}:o,a=s==="left"||s==="top";return {type:"split",direction:n,first:a?r:e,second:a?e:r,splitPercentage:50}}return e}return {...e,first:ye(e.first,t,n,s,o)||e.first,second:ye(e.second,t,n,s,o)||e.second}}function rt(e,t,n){if(e===null)return {type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:n?{[t]:n}:void 0};function s(o,r){return o.type==="pane"?{type:"split",direction:r==="row"?"column":"row",splitPercentage:50,first:o,second:{type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:n?{[t]:n}:void 0}}:{...o,second:s(o.second,o.direction)}}return s(e,null)}function Pe(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:Pe(e.first,t,n)||e.first,second:Pe(e.second,t,n)||e.second}:e}function j(e,t){return e===null?null:e.type==="pane"?e.id===t?e:null:j(e.first,t)??j(e.second,t)}function B(e,t){return e===null?null:e.type==="pane"?e.tabs.includes(t)?e:null:B(e.first,t)??B(e.second,t)}function st(e,t){let n=B(e,t);if(!n)return null;let s=n.tabs.indexOf(t);return {id:t,paneId:n.id,isActive:n.activeTabId===t,index:s,metadata:n.tabsMetadata?.[t]}}function Ee(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let s=e.tabsMetadata||{},o=s[t],r=n(o),a={...s};return r===void 0?delete a[t]:a[t]=r,{...e,tabsMetadata:Object.keys(a).length>0?a:void 0}}return e}return {...e,first:Ee(e.first,t,n)??e.first,second:Ee(e.second,t,n)??e.second}}function Ie(e,t,n,s){if(e===null)return null;if(e.type==="pane"){if(e.id===t){let o=[...e.tabs];o.includes(n)||o.push(n);let r=e.tabsMetadata;return s&&(r={...e.tabsMetadata,[n]:s}),{...e,tabs:o,activeTabId:n,tabsMetadata:r}}return e}return {...e,first:Ie(e.first,t,n,s)||e.first,second:Ie(e.second,t,n,s)||e.second}}function Le(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.id===t){if(n===false){let{locked:s,...o}=e;return o}return {...e,locked:n}}return e}return {...e,first:Le(e.first,t,n)??e.first,second:Le(e.second,t,n)??e.second}}function Re(e,t,n){return e===null?null:e.type==="pane"?e.id===t?e.activeTabId===n?e:{...e,activeTabId:n}:e:{...e,first:Re(e.first,t,n)??e.first,second:Re(e.second,t,n)??e.second}}function it(e,t,n){if(e===null)return null;let o=B(e,t)?.tabsMetadata?.[t],r=fe(e,t);if(r===null)return {type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function a(l){if(l.type==="pane"){if(l.id===n){let d=[...l.tabs];d.includes(t)||d.push(t);let p={...l.tabsMetadata};return o&&(p[t]=o),{...l,tabs:d,activeTabId:t,tabsMetadata:Object.keys(p).length>0?p:void 0}}return l}return {...l,first:a(l.first),second:a(l.second)}}return a(r)}function Me(e,t,n,s="before"){if(e===null)return null;let r=B(e,t)?.tabsMetadata?.[t],a=fe(e,t);if(a===null)return {type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:r?{[t]:r}:void 0};function l(d){if(d.type==="pane"){if(d.tabs.includes(n)){let g=[...d.tabs].filter(w=>w!==t),P=g.indexOf(n);P<0&&(P=0),s==="after"&&(P+=1),g.splice(P,0,t);let y={...d.tabsMetadata};return r&&(y[t]=r),{...d,tabs:g,activeTabId:t,tabsMetadata:Object.keys(y).length>0?y:void 0}}return d}return {...d,first:l(d.first),second:l(d.second)}}return l(a)}function ge(e,t=0,n=0,s=100,o=100,r="root"){if(e===null)return {panes:[],splitters:[]};if(e.type==="pane")return {panes:[{paneId:e.id,left:t,top:n,width:s,height:o,node:e}],splitters:[]};let{direction:a,splitPercentage:l,first:d,second:p}=e,P={id:`splitter-${r}-${a}`,currentNode:e,direction:a,left:a==="row"?t+s*(l/100):t,top:a==="column"?n+o*(l/100):n,width:a==="row"?0:s,height:a==="column"?0:o,parentLeft:t,parentTop:n,parentWidth:s,parentHeight:o},y={panes:[],splitters:[]},w={panes:[],splitters:[]};if(a==="row"){let x=s*(l/100);y=ge(d,t,n,x,o,`${r}-L`),w=ge(p,t+x,n,s-x,o,`${r}-R`);}else {let x=o*(l/100);y=ge(d,t,n,s,x,`${r}-T`),w=ge(p,t,n+x,s,o-x,`${r}-B`);}return {panes:[...y.panes,...w.panes],splitters:[P,...y.splitters,...w.splitters]}}function at(e,t,n,s){if(!(t==="tab"&&n&&e.includes(n))||!s)return -1;let a=e.indexOf(n);return s==="before"?a:a+1}function Ne(e){try{return JSON.stringify(e)}catch{return ""}}function Mt(e){let{initialLayout:t,layout:n,onChange:s,fullscreenPaneId:o,onFullscreenChange:r,locked:a=false,dragActivationDistance:l=8,snapThreshold:d=8,minSplitPercentage:p=5,maxSplitPercentage:g=95,enableDragToDismiss:P=false,dismissThreshold:y=60,onRemove:w,onDragStart:x,onDragEnd:k,onResizeStart:L,onResize:M,onResizeEnd:u,onDismissIntentChange:T}=e,[N,E]=_t.useState(()=>n!==void 0?n:t??null),[A,J]=_t.useState(()=>Ne(n!==void 0?n:null)),[q,W]=_t.useState(o||null),[ee,te]=_t.useState(a),[ie,ne]=_t.useState(null),[le,D]=_t.useState(null),[O,$]=_t.useState(null),[z,R]=_t.useState(null),i=_t.useRef(null),h=_t.useCallback(c=>{i.current=c;},[]),v=_t.useRef(N);v.current=N;let b=_t.useRef(s);b.current=s;let U=_t.useRef(r);U.current=r;let F=_t.useCallback(c=>{W(c),U.current?.(c);},[]);if(_t.useEffect(()=>{te(a);},[a]),_t.useEffect(()=>{o!==void 0&&W(o);},[o]),n!==void 0){let c=Ne(n);c!==A&&(J(c),E(n));}let f=_t.useCallback(c=>(...S)=>{let H=v.current,V=c(H,...S);Ne(H)!==Ne(V)&&(v.current=V,E(V),b.current?.(V));},[]),G=_t.useCallback(f((c,S)=>typeof S=="function"?S(c):S),[f]),m=_t.useCallback(f((c,S)=>be(c,S)),[f]),C=_t.useCallback(f((c,S,H)=>rt(c,S,H)),[f]),Z=_t.useCallback(f((c,S,H,V)=>{let pe=j(c,S)??B(c,S);if(!pe)return c;let we=B(c,H),We=we&&we.id===pe.id?c:fe(c,H)??c;return Ie(We,pe.id,H,V)}),[f]),oe=_t.useCallback(f((c,S,H,V,pe)=>{let we=j(c,S)??B(c,S);if(!we)return c;let je=j(c,pe)??B(c,pe)??{type:"pane",id:pe,tabs:[pe],activeTabId:pe},We=be(c,pe);return ye(We,we.id,H,V,je)}),[f]),K=_t.useCallback(f((c,S,H)=>Pe(c,S,H)),[f]),Q=_t.useCallback(f((c,S,H)=>Ee(c,S,H)),[f]),Se=_t.useCallback(f((c,S,H)=>{let V=j(c,S)??B(c,S);return V?Le(c,V.id,H):c}),[f]),ce=_t.useCallback(f((c,S,H)=>{let V=j(c,S)??B(c,S);return V?Re(c,V.id,H):c}),[f]),ue=_t.useCallback(f((c,S,H)=>{let V=j(c,H)??B(c,H);return V?it(c,S,V.id):c}),[f]),I=_t.useCallback(f((c,S,H,V)=>Me(c,S,H,V)),[f]),re=_t.useCallback(f((c,S)=>fe(c,S)),[f]),X=_t.useCallback(c=>j(v.current,c),[]),me=_t.useCallback(c=>B(v.current,c),[]),se=_t.useCallback(c=>st(v.current,c),[]);return {layout:N,setLayout:G,layoutBeforeDrag:ie,setLayoutBeforeDrag:ne,fullscreenPaneId:q,setFullscreenPaneId:F,locked:ee,setLocked:te,activeId:le,setActiveId:D,activeType:O,setActiveType:$,dismissIntentId:z,setDismissIntentId:R,containerRef:i,setContainerRef:h,dragActivationDistance:l,snapThreshold:d,minSplitPercentage:p,maxSplitPercentage:g,enableDragToDismiss:P,dismissThreshold:y,onRemove:w,onDragStart:x,onDragEnd:k,onResizeStart:L,onResize:M,onResizeEnd:u,onDismissIntentChange:T,removePane:m,addPane:C,addTab:Z,splitPane:oe,updateSplitPercentage:K,updateTabMetadata:Q,updatePaneLock:Se,selectTab:ce,mergeTab:ue,moveTab:I,removeTab:re,findPaneById:X,findPaneContainingTab:me,findTabById:se}}function ct({cursor:e,resizerEl:t,onMove:n,onEnd:s}){document.body.classList.add("zeugma-resizing");let o=document.createElement("style");o.id="zeugma-global-cursor-style",o.textContent=`
|
|
1
|
+
'use strict';var Kt=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 Kt__default=/*#__PURE__*/_interopDefault(Kt);function rt(e,t){Array.from(e.styleSheets).forEach(n=>{try{if(n.cssRules){let o=t.createElement("style");Array.from(n.cssRules).forEach(r=>{o.appendChild(t.createTextNode(r.cssText));}),t.head.appendChild(o);}else if(n.href){let o=t.createElement("link");o.rel="stylesheet",o.href=n.href,t.head.appendChild(o);}}catch{if(n.href){let o=t.createElement("link");o.rel="stylesheet",o.href=n.href,t.head.appendChild(o);}}});}function Xe(e){let t=document.getElementById(e);return t||(t=document.createElement("div"),t.id=e,t.style.display="none",document.body.appendChild(t)),t}function it(e){let t=Kt.useRef(null);return Kt.useEffect(()=>{if(!e){t.current=null;return}let n=r=>{t.current={x:r.clientX,y:r.clientY};},o=r=>{let s=r.touches[0]||r.changedTouches[0];s&&(t.current={x:s.clientX,y:s.clientY});};return window.addEventListener("pointermove",n,{passive:true}),window.addEventListener("touchmove",o,{passive:true}),()=>{window.removeEventListener("pointermove",n),window.removeEventListener("touchmove",o);}},[e]),t}function at(e){Kt.useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function lt(){let[e,t]=Kt.useState({}),n=Kt.useRef(true);Kt.useEffect(()=>(n.current=true,()=>{n.current=false;}),[]);let o=Kt.useCallback((r,s)=>{n.current&&t(i=>i[r]===s?i:{...i,[r]:s});},[]);return {portalTargets:e,registerPortalTarget:o}}function ct({tabId:e,isOpenedInNewWindow:t,onClose:n}){let o=Kt.useRef(null),[r,s]=Kt.useState(null);return Kt.useEffect(()=>{let i=null;if(t){if(!o.current||o.current.closed){let c=`zeugma-tab-${e.replace(/[^a-zA-Z0-9]/g,"_")}`,p=window.open("",c,"width=800,height=600,menubar=no,toolbar=no,location=no,status=no,resizable=yes");if(p){o.current=p;let f=e.includes("/")?e.split("/").pop():e;p.document.title=f,rt(document,p.document);let m=p.document.createElement("div");m.id="zeugma-popup-root",p.document.body.appendChild(m),s(m),p.addEventListener("beforeunload",n),i=setInterval(()=>{p.closed&&n();},300);}else console.warn("Popup window blocked or failed to open."),n();}}else o.current&&!o.current.closed&&o.current.close(),o.current=null,s(null);return ()=>{i&&clearInterval(i),o.current&&o.current.removeEventListener("beforeunload",n);}},[t,e,n]),Kt.useEffect(()=>()=>{o.current&&!o.current.closed&&o.current.close();},[]),{popupWindow:o.current,popupContainer:r}}var zt=8,At=8,Jn=4;function de(){return "pane-"+Math.random().toString(36).substring(2,11)}function he(e,t){if(e===null)return null;if(e.type==="pane")return e.id===t?null:e;let n=he(e.first,t),o=he(e.second,t);return n===null?o:o===null?n:{...e,first:n,second:o}}function fe(e,t){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let r=e.tabs.filter(c=>c!==t);if(r.length===0)return null;let s=e.activeTabId;e.activeTabId===t&&(s=r[0]);let i={...e.tabsMetadata};return delete i[t],{...e,tabs:r,activeTabId:s,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}let n=fe(e.first,t),o=fe(e.second,t);return n===null?o:o===null?n:{...e,first:n,second:o}}function Ce(e,t,n,o,r){if(e===null)return typeof r=="string"?{type:"pane",id:de(),tabs:[r],activeTabId:r}:r;if(e.type==="pane"){if(e.id===t){let s=typeof r=="string"?{type:"pane",id:de(),tabs:[r],activeTabId:r}:r,i=o==="left"||o==="top";return {type:"split",direction:n,first:i?s:e,second:i?e:s,splitPercentage:50}}return e}return {...e,first:Ce(e.first,t,n,o,r)||e.first,second:Ce(e.second,t,n,o,r)||e.second}}function ut(e,t,n){if(e===null)return {type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:n?{[t]:n}:void 0};function o(r,s){return r.type==="pane"?{type:"split",direction:s==="row"?"column":"row",splitPercentage:50,first:r,second:{type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:n?{[t]:n}:void 0}}:{...r,second:o(r.second,r.direction)}}return o(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 ee(e,t){return e===null?null:e.type==="pane"?e.id===t?e:null:ee(e.first,t)??ee(e.second,t)}function U(e,t){return e===null?null:e.type==="pane"?e.tabs.includes(t)?e:null:U(e.first,t)??U(e.second,t)}function dt(e,t){let n=U(e,t);if(!n)return null;let o=n.tabs.indexOf(t);return {id:t,paneId:n.id,isActive:n.activeTabId===t,index:o,metadata:n.tabsMetadata?.[t]}}function Me(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let o=e.tabsMetadata||{},r=o[t],s=n(r),i={...o};return s===void 0?delete i[t]:i[t]=s,{...e,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}return {...e,first:Me(e.first,t,n)??e.first,second:Me(e.second,t,n)??e.second}}function Ze(e,t,n,o){if(e===null)return null;if(e.type==="pane"){if(e.id===t){let r=[...e.tabs];r.includes(n)||r.push(n);let s=e.tabsMetadata;return o&&(s={...e.tabsMetadata,[n]:o}),{...e,tabs:r,activeTabId:n,tabsMetadata:s}}return e}return {...e,first:Ze(e.first,t,n,o)||e.first,second:Ze(e.second,t,n,o)||e.second}}function ke(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.id===t){if(n===false){let{locked:o,...r}=e;return r}return {...e,locked:n}}return e}return {...e,first:ke(e.first,t,n)??e.first,second:ke(e.second,t,n)??e.second}}function Re(e,t,n){return e===null?null:e.type==="pane"?e.id===t?e.activeTabId===n?e:{...e,activeTabId:n}:e:{...e,first:Re(e.first,t,n)??e.first,second:Re(e.second,t,n)??e.second}}function pt(e,t,n){if(e===null)return null;let r=U(e,t)?.tabsMetadata?.[t],s=fe(e,t);if(s===null)return {type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:r?{[t]:r}:void 0};function i(c){if(c.type==="pane"){if(c.id===n){let p=[...c.tabs];p.includes(t)||p.push(t);let f={...c.tabsMetadata};return r&&(f[t]=r),{...c,tabs:p,activeTabId:t,tabsMetadata:Object.keys(f).length>0?f:void 0}}return c}return {...c,first:i(c.first),second:i(c.second)}}return i(s)}function $e(e,t,n,o="before"){if(e===null)return null;let s=U(e,t)?.tabsMetadata?.[t],i=fe(e,t);if(i===null)return {type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:s?{[t]:s}:void 0};function c(p){if(p.type==="pane"){if(p.tabs.includes(n)){let m=[...p.tabs].filter(v=>v!==t),b=m.indexOf(n);b<0&&(b=0),o==="after"&&(b+=1),m.splice(b,0,t);let P={...p.tabsMetadata};return s&&(P[t]=s),{...p,tabs:m,activeTabId:t,tabsMetadata:Object.keys(P).length>0?P:void 0}}return p}return {...p,first:c(p.first),second:c(p.second)}}return c(i)}function ge(e,t=0,n=0,o=100,r=100,s="root"){if(e===null)return {panes:[],splitters:[]};if(e.type==="pane")return {panes:[{paneId:e.id,left:t,top:n,width:o,height:r,node:e}],splitters:[]};let{direction:i,splitPercentage:c,first:p,second:f}=e,b={id:`splitter-${s}-${i}`,currentNode:e,direction:i,left:i==="row"?t+o*(c/100):t,top:i==="column"?n+r*(c/100):n,width:i==="row"?0:o,height:i==="column"?0:r,parentLeft:t,parentTop:n,parentWidth:o,parentHeight:r},P={panes:[],splitters:[]},v={panes:[],splitters:[]};if(i==="row"){let x=o*(c/100);P=ge(p,t,n,x,r,`${s}-L`),v=ge(f,t+x,n,o-x,r,`${s}-R`);}else {let x=r*(c/100);P=ge(p,t,n,o,x,`${s}-T`),v=ge(f,t,n+x,o,r-x,`${s}-B`);}return {panes:[...P.panes,...v.panes],splitters:[b,...P.splitters,...v.splitters]}}function ft(e,t,n,o){if(!(t==="tab"&&n&&e.includes(n))||!o)return -1;let i=e.indexOf(n);return o==="before"?i:i+1}function Le(e){try{return JSON.stringify(e)}catch{return ""}}function Ht(e){let{initialLayout:t,layout:n,onChange:o,fullscreenPaneId:r,onFullscreenChange:s,locked:i=false,dragActivationDistance:c=8,snapThreshold:p=8,minSplitPercentage:f=5,maxSplitPercentage:m=95,enableDragToDismiss:b=false,dismissThreshold:P=60,onRemove:v,onDragStart:x,onDragEnd:M,onResizeStart:A,onResize:N,onResizeEnd:d,onDismissIntentChange:T}=e,[E,D]=Kt.useState(()=>n!==void 0?n:t??null),[H,q]=Kt.useState(()=>Le(n!==void 0?n:null)),[G,X]=Kt.useState(r||null),[te,oe]=Kt.useState(i),[re,se]=Kt.useState(null),[le,w]=Kt.useState({}),F=Kt.useCallback((u,C)=>{w(L=>L[u]===C?L:{...L,[u]:C});},[]),[Z,k]=Kt.useState(null),[y,a]=Kt.useState(null),[h,R]=Kt.useState(null),g=Kt.useRef(null),K=Kt.useCallback(u=>{g.current=u;},[]),$=Kt.useRef(E);$.current=E;let O=Kt.useRef(o);O.current=o;let V=Kt.useRef(s);V.current=s;let Q=Kt.useCallback(u=>{X(u),V.current?.(u);},[]);if(Kt.useEffect(()=>{oe(i);},[i]),Kt.useEffect(()=>{r!==void 0&&X(r);},[r]),n!==void 0){let u=Le(n);u!==H&&(q(u),D(n));}let l=Kt.useCallback(u=>(...C)=>{let L=$.current,B=u(L,...C);Le(L)!==Le(B)&&($.current=B,D(B),O.current?.(B));},[]),I=Kt.useCallback(l((u,C)=>typeof C=="function"?C(u):C),[l]),ie=Kt.useCallback(l((u,C)=>he(u,C)),[l]),Y=Kt.useCallback(l((u,C,L)=>ut(u,C,L)),[l]),j=Kt.useCallback(l((u,C,L,B)=>{let pe=ee(u,C)??U(u,C);if(!pe)return u;let Ee=U(u,L),_e=Ee&&Ee.id===pe.id?u:fe(u,L)??u;return Ze(_e,pe.id,L,B)}),[l]),Ne=Kt.useCallback(l((u,C,L,B,pe)=>{let Ee=ee(u,C)??U(u,C);if(!Ee)return u;let ot=ee(u,pe)??U(u,pe)??{type:"pane",id:pe,tabs:[pe],activeTabId:pe},_e=he(u,pe);return Ce(_e,Ee.id,L,B,ot)}),[l]),ce=Kt.useCallback(l((u,C,L)=>Te(u,C,L)),[l]),ue=Kt.useCallback(l((u,C,L)=>Me(u,C,L)),[l]),J=Kt.useCallback(l((u,C,L)=>{let B=ee(u,C)??U(u,C);return B?ke(u,B.id,L):u}),[l]),me=Kt.useCallback(l((u,C,L)=>{let B=ee(u,C)??U(u,C);return B?Re(u,B.id,L):u}),[l]),z=Kt.useCallback(l((u,C,L)=>{let B=ee(u,L)??U(u,L);return B?pt(u,C,B.id):u}),[l]),ae=Kt.useCallback(l((u,C,L,B)=>$e(u,C,L,B)),[l]),W=Kt.useCallback(l((u,C)=>fe(u,C)),[l]),Pe=Kt.useCallback(u=>ee($.current,u),[]),nt=Kt.useCallback(u=>U($.current,u),[]),kt=Kt.useCallback(u=>dt($.current,u),[]);return {layout:E,setLayout:I,layoutBeforeDrag:re,setLayoutBeforeDrag:se,fullscreenPaneId:G,setFullscreenPaneId:Q,locked:te,setLocked:oe,popoutTabs:le,activeId:Z,setActiveId:k,activeType:y,setActiveType:a,dismissIntentId:h,setDismissIntentId:R,containerRef:g,setContainerRef:K,dragActivationDistance:c,snapThreshold:p,minSplitPercentage:f,maxSplitPercentage:m,enableDragToDismiss:b,dismissThreshold:P,onRemove:v,onDragStart:x,onDragEnd:M,onResizeStart:A,onResize:N,onResizeEnd:d,onDismissIntentChange:T,removePane:ie,addPane:Y,addTab:j,splitPane:Ne,updateSplitPercentage:ce,updateTabMetadata:ue,updatePaneLock:J,selectTab:me,mergeTab:z,moveTab:ae,removeTab:W,setTabPopout:F,findPaneById:Pe,findPaneContainingTab:nt,findTabById:kt}}function gt({cursor:e,resizerEl:t,onMove:n,onEnd:o}){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(o),t.setAttribute("data-resizing","true");let r=l=>{n(l);},a=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let l=document.getElementById("zeugma-global-cursor-style");l&&l.remove(),document.removeEventListener("pointermove",r),document.removeEventListener("pointerup",a),s();};document.addEventListener("pointermove",r),document.addEventListener("pointerup",a);}var Xe=_t.createContext(void 0),Ye=_t.createContext(void 0),$e=_t.createContext(void 0),Je=_t.createContext(void 0),ae=()=>{let e=_t.useContext(Xe);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},ze=()=>{let e=_t.useContext(Ye);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},Ae=()=>{let e=_t.useContext(Je);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};var Zt=()=>{let e=ae(),t=ze();return {...e,...t}};var He=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 Fe(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}function dt(e){let{layout:t,setLayout:n,layoutBeforeDrag:s,setLayoutBeforeDrag:o,activeId:r,setActiveId:a,setActiveType:l,dismissIntentId:d,setDismissIntentId:p,setOverTabId:g,setOverTabPosition:P,containerRef:y,dragActivationDistance:w,enableDragToDismiss:x,dismissThreshold:k,onRemove:L,onDragStart:M,onDragEnd:u,onDismissIntentChange:T,removeTab:N}=e,E=_t.useRef(null),A=tt(r),[J,q]=_t.useState(false);nt(J);let W=core.useSensors(core.useSensor(He,{activationConstraint:{distance:w}}),core.useSensor(Oe,{activationConstraint:{delay:250,tolerance:5}})),ee=_t.useCallback(D=>{let $=D.active.id.toString().startsWith("tab-header-"),z=core.pointerWithin(D),R=$?z:z.filter(i=>!i.id.toString().startsWith("tab-drop-"));if(R.length>0)return [...R].sort((h,v)=>{let b=h.id.toString(),U=v.id.toString();if($){let _=b.startsWith("tab-drop-"),G=U.startsWith("tab-drop-");if(_&&!G)return -1;if(!_&&G)return 1}let F=b.startsWith("drop-root-"),f=U.startsWith("drop-root-");return F&&!f?-1:!F&&f?1:0});if($){let i=D.droppableContainers.filter(h=>h.id.toString().startsWith("tab-drop-"));return core.closestCenter({...D,droppableContainers:i})}return []},[]);return {sensors:W,collisionDetection:ee,onDragStart:D=>{let O=D.active.id.toString(),$=O.startsWith("tab-header-"),z=$?O.substring(11):O;a(z),l($?"tab":"pane"),g(null),P(null);let R=D.activatorEvent;A.current=Fe(R),x&&y.current?E.current=y.current.getBoundingClientRect():E.current=null;let i=t;if($){let h=B(t,z);h&&(i=Re(t,h.id,z)||t);}o(i),$&&i!==t&&n(i),M&&M(z);},onDragMove:D=>{let{over:O}=D,$=O?.id.toString()||"",z=$.startsWith("drop-locked-");q(m=>m===z?m:z);let R=D.active.id.toString(),i=R.startsWith("tab-header-"),h=i?R.substring(11):R,v=$.match(/^tab-drop-(.+)$/);if(v&&O&&i){let[,m]=v;if(h!==m){let C="before",Z=O.rect,oe=D.activatorEvent,K=null;if(A.current)K=A.current.x;else {let Q=Fe(oe);Q&&(K=Q.x+D.delta.x);}if(K!==null){let Q=Z.left+Z.width/2;K>Q&&(C="after");}g(Q=>Q===m?Q:m),P(Q=>Q===C?Q:C);}else g(C=>C===null?C:null),P(C=>C===null?C:null);}else g(m=>m===null?m:null),P(m=>m===null?m:null);if(!x)return;let b=E.current;if(!b){d!==null&&(p(null),T?.(null));return}let U=D.activatorEvent,F=null,f=null;if(A.current)F=A.current.x,f=A.current.y;else {let m=Fe(U);m&&(F=m.x+D.delta.x,f=m.y+D.delta.y);}let _=0;if(F!==null&&f!==null){let m=0,C=0;F<b.left?m=b.left-F:F>b.right&&(m=F-b.right),f<b.top?C=b.top-f:f>b.bottom&&(C=f-b.bottom),_=Math.sqrt(m*m+C*C);}else {let m=D.active.rect.current.translated;if(m){let C=m.left+m.width/2,Z=m.top+m.height/2,oe=0,K=0;C<b.left?oe=b.left-C:C>b.right&&(oe=C-b.right),Z<b.top?K=b.top-Z:Z>b.bottom&&(K=Z-b.bottom),_=Math.sqrt(oe*oe+K*K);}}_>k?d!==h&&(p(h),T?.(h)):d!==null&&(p(null),T?.(null));},onDragEnd:D=>{a(null),l(null),q(false),g(null),P(null);let{active:O,over:$}=D,z=O.id.toString(),R=z.startsWith("tab-header-"),i=R?z.substring(11):z,h=x&&d===i;p(null),T?.(null),E.current=null;let v=s||t;if(o(null),h){L?L(i):N(i),u&&u(i,null,null);return}if(!$){n(v),u&&u(i,null,null);return}let b=$.id.toString();if(b.startsWith("drop-locked-")){n(v),u&&u(i,null,null);return}let U=b.match(/^tab-drop-(.+)$/);if(U){if(!R){n(v),u&&u(i,null,null);return}let[,ce]=U;if(i!==ce){let ue="before",I=$.rect,re=D.activatorEvent,X=null;if(A.current)X=A.current.x;else {let se=Fe(re);se&&(X=se.x+D.delta.x);}if(X!==null){let se=I.left+I.width/2;X>se&&(ue="after");}let me=Me(v,i,ce,ue);n(me),u&&u(i,ce,{type:"move",position:"center"});}else n(v),u&&u(i,null,null);return}let F=b.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(F){let[,ce,ue]=F,I=ue;I==="start"&&(I="left"),I==="end"&&(I="right");let re=R?fe(v,i):be(v,i),X;if(R){let se=B(v,i)?.tabsMetadata?.[i];X={type:"pane",id:de(),tabs:[i],activeTabId:i,tabsMetadata:se?{[i]:se}:void 0};}else X=j(v,i)??{type:"pane",id:de(),tabs:[i],activeTabId:i};if(re===null)n(X);else {let me=I==="left"||I==="right",se=I==="left"||I==="top",c=50;ce==="1/4"?c=se?25:75:ce==="1/3"&&(c=se?100/3:200/3),n({type:"split",direction:me?"row":"column",first:se?X:re,second:se?re:X,splitPercentage:c});}u&&u(i,"root",{type:"split",direction:I==="left"||I==="right"?"row":"column",position:I});return}let f=b.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!f){n(v),u&&u(i,null,null);return}let[,_,G]=f,m=R?B(v,i):j(v,i),C=m&&m.id===G,Z=m&&m.tabs.length===1;if(i===G||C&&Z){n(v),u&&u(i,null,null);return}let oe=_==="left"||_==="right"?"row":"column",K;if(R){let ue=B(v,i)?.tabsMetadata?.[i];K={type:"pane",id:de(),tabs:[i],activeTabId:i,tabsMetadata:ue?{[i]:ue}:void 0};}else K=j(v,i)??{type:"pane",id:de(),tabs:[i],activeTabId:i};let Q=R?fe(v,i):be(v,i),Se=ye(Q,G,oe,_,K);n(Se),u&&u(i,G,{type:"split",direction:oe,position:_});},onDragCancel:()=>{a(null),l(null),q(false),g(null),P(null),p(null),T?.(null),E.current=null,s!==null&&(n(s),o(null));}}}var pt=({activeId:e,render:t,className:n})=>{let s=_t.useRef(null);return _t.useEffect(()=>{let o=r=>{s.current&&(s.current.style.transform=`translate(${r.clientX+12}px, ${r.clientY+12}px)`);};return document.addEventListener("pointermove",o),()=>document.removeEventListener("pointermove",o)},[]),jsxRuntime.jsx("div",{ref:s,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var ft=_t__default.default.memo(({tabId:e,target:t,renderWidget:n})=>{let[s,o]=_t.useState(false),r=_t.useRef(null);if(_t.useEffect(()=>{o(true);},[]),_t.useEffect(()=>{if(!s||!r.current)return;let l=r.current;if(t)t.appendChild(l);else {let d=document.getElementById("zeugma-hidden-portal-container");d||(d=document.createElement("div"),d.id="zeugma-hidden-portal-container",d.style.display="none",document.body.appendChild(d)),d.appendChild(l);}},[t,s]),_t.useEffect(()=>()=>{r.current&&r.current.remove();},[]),!s)return null;r.current||(r.current=document.createElement("div"),r.current.className=`zeugma-portal-wrapper-${e}`,r.current.style.width="100%",r.current.style.height="100%");let a=r.current;return !a||!n?null:reactDom.createPortal(n(e),a)});var Gt=e=>{let t=e,{renderPane:n,renderWidget:s,renderDragOverlay:o,classNames:r={},children:a,layout:l,setLayout:d,fullscreenPaneId:p,setFullscreenPaneId:g,locked:P,setLocked:y,findPaneById:w,findPaneContainingTab:x,findTabById:k,activeId:L,activeType:M,dismissIntentId:u,setContainerRef:T,layoutBeforeDrag:N,snapThreshold:E,minSplitPercentage:A,maxSplitPercentage:J,onRemove:q,onResizeStart:W,onResize:ee,onResizeEnd:te,removePane:ie,addPane:ne,addTab:le,updateTabMetadata:D,updatePaneLock:O,selectTab:$,mergeTab:z,removeTab:R,splitPane:i,updateSplitPercentage:h,moveTab:v}=t,{portalTargets:b,registerPortalTarget:U}=ot(),[F,f]=_t.useState(null),[_,G]=_t.useState(null),m=dt({...t,setOverTabId:f,setOverTabPosition:G}),C=_t.useCallback(I=>n(I),[n]),Z=_t.useMemo(()=>r,[r.dashboard,r.dashboardDismissActive,r.pane,r.paneLocked,r.dropPreview,r.dragOverlay,r.resizer,r.dismissPreview,r.dashboardLocked,r.lockedPreview,r.tabDropPreview,r.tabSeparator]),oe=_t.useCallback((I,re)=>{te&&te(I,re);},[te]),K=_t.useMemo(()=>({layout:l,setLayout:d,renderPane:C,activeId:L,activeType:M,dismissIntentId:u,setContainerRef:T,fullscreenPaneId:p,classNames:Z,onRemove:q,onFullscreenChange:g,snapThreshold:E,onResizeStart:W,onResize:ee,onResizeEnd:oe,minSplitPercentage:A,maxSplitPercentage:J,locked:P,setLocked:y,findPaneById:w,findPaneContainingTab:x,findTabById:k}),[l,L,M,u,T,p,Z,q,g,E,W,ee,A,J,d,C,oe,P,y,w,x,k]),Q=_t.useMemo(()=>({overTabId:F,overTabPosition:_}),[F,_]),Se=_t.useMemo(()=>({removePane:ie,addPane:ne,addTab:le,updateTabMetadata:D,updatePaneLock:O,selectTab:$,mergeTab:z,removeTab:R,setFullscreenPaneId:g,setLocked:y,splitPane:i,updateSplitPercentage:h,moveTab:v}),[ie,ne,le,D,O,$,z,R,g,y,i,h,v]),ce=_t.useMemo(()=>{let I=new Set;function re(X){X&&(X.type==="pane"?X.tabs.forEach(me=>{I.add(me);}):(re(X.first),re(X.second)));}return re(l),N&&re(N),Array.from(I).sort()},[l,L,N]),ue=_t.useMemo(()=>({registerPortalTarget:U}),[U]);return jsxRuntime.jsx(Ye.Provider,{value:Se,children:jsxRuntime.jsx(Xe.Provider,{value:K,children:jsxRuntime.jsx(Je.Provider,{value:Q,children:jsxRuntime.jsxs($e.Provider,{value:ue,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",...m,children:a}),L&&M&&o&&jsxRuntime.jsx(pt,{activeId:L,render:I=>o(I,M),className:`${r.dragOverlay||""} ${L===u&&r.dismissPreview||""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:ce.map(I=>jsxRuntime.jsx(ft,{tabId:I,target:b[I]||null,renderWidget:s},I))})]})})})})};var jt={top:{"1/4":{position:"absolute",top:0,left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",top:"24px",left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"}},bottom:{"1/4":{position:"absolute",bottom:0,left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",bottom:"24px",left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"}},left:{"1/4":{position:"absolute",left:0,top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",left:"24px",top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"}},right:{"1/4":{position:"absolute",right:0,top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",right:"24px",top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"}}},en={top:{"1/4":{top:0,left:0,width:"100%",height:"25%"},"1/3":{top:0,left:0,width:"100%",height:"33.3333%"}},bottom:{"1/4":{bottom:0,left:0,width:"100%",height:"25%"},"1/3":{bottom:0,left:0,width:"100%",height:"33.3333%"}},left:{"1/4":{left:0,top:0,width:"25%",height:"100%"},"1/3":{left:0,top:0,width:"33.3333%",height:"100%"}},right:{"1/4":{right:0,top:0,width:"25%",height:"100%"},"1/3":{right:0,top:0,width:"33.3333%",height:"100%"}}},tn=({id:e,fraction:t,edge:n,activeClassName:s})=>{let{setNodeRef:o,isOver:r}=core.useDroppable({id:e}),a={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...en[n][t]};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:o,style:jt[n][t]}),r&&jsxRuntime.jsx("div",{className:s,style:a})]})},bt=({activeClassName:e})=>jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:99,pointerEvents:"none"},children:[{id:"drop-root-1/3-top",fraction:"1/3",edge:"top"},{id:"drop-root-1/3-bottom",fraction:"1/3",edge:"bottom"},{id:"drop-root-1/4-left",fraction:"1/4",edge:"left"},{id:"drop-root-1/3-left",fraction:"1/3",edge:"left"},{id:"drop-root-1/4-right",fraction:"1/4",edge:"right"},{id:"drop-root-1/3-right",fraction:"1/3",edge:"right"}].map(n=>jsxRuntime.jsx(tn,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});function Ge({containerRef:e,isRow:t,direction:n,splitPercentage:s,resizerSize:o,snapThreshold:r,layout:a,currentNode:l,onLayoutChange:d,onResizeStart:p,onResizeEnd:g,parentLeft:P,parentTop:y,parentWidth:w,parentHeight:x}){let{onResizeStart:k,onResize:L,onResizeEnd:M,minSplitPercentage:u=5,maxSplitPercentage:T=95,locked:N=false}=ae();return _t.useCallback(E=>{if(N)return;E.preventDefault();let A=e.current;if(!A)return;p&&p(),k&&k(l);let J=A.getBoundingClientRect(),q=E.clientX,W=E.clientY,ee=s,te=E.currentTarget,ie=J.left+J.width*(P/100),ne=J.top+J.height*(y/100),le=J.width*(w/100),D=J.height*(x/100),$=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(R=>R!==te&&R.getAttribute("data-direction")===n).map(R=>{let i=R.getBoundingClientRect();return t?i.left+i.width/2:i.top+i.height/2}),z=ee;ct({cursor:t?"col-resize":"row-resize",resizerEl:te,onMove:R=>{let i=t?(R.clientX-q)/le*100:(R.clientY-W)/D*100,h=ee+i,v=t?ie+(le-o)*(h/100)+o/2:ne+(D-o)*(h/100)+o/2,b=1/0,U=null;for(let G of $){let m=Math.abs(v-G);m<r&&m<b&&(b=m,U=G);}let F=h;U!==null&&(F=t?(U-o/2-ie)/(le-o)*100:(U-o/2-ne)/(D-o)*100);let f=Math.max(u,Math.min(T,F));z=f;let _=Pe(a,l,f);if(_){let{panes:G,splitters:m}=ge(_),C=e.current;if(C){for(let Z of G)C.style.setProperty(`--pane-left-${Z.paneId}`,`${Z.left}%`),C.style.setProperty(`--pane-top-${Z.paneId}`,`${Z.top}%`),C.style.setProperty(`--pane-width-${Z.paneId}`,`${Z.width}%`),C.style.setProperty(`--pane-height-${Z.paneId}`,`${Z.height}%`);for(let Z of m)C.style.setProperty(`--splitter-pos-${Z.id}`,`${Z.direction==="row"?Z.left:Z.top}%`);}}L&&L(l,f);},onEnd:()=>{let R=Pe(a,l,z),i=e.current;if(i){let{panes:h,splitters:v}=ge(R);for(let b of h)i.style.removeProperty(`--pane-left-${b.paneId}`),i.style.removeProperty(`--pane-top-${b.paneId}`),i.style.removeProperty(`--pane-width-${b.paneId}`),i.style.removeProperty(`--pane-height-${b.paneId}`);for(let b of v)i.style.removeProperty(`--splitter-pos-${b.id}`);}d(R),g&&g(),M&&M(l,z);}});},[e,t,n,s,o,r,a,l,d,p,g,k,L,M,u,T,P,y,w,x])}var un=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:s})=>{let{layout:o,setLayout:r,classNames:a,locked:l}=ae(),[d,p]=_t.useState(false),{currentNode:g,direction:P,left:y,top:w,width:x,height:k,parentLeft:L,parentTop:M,parentWidth:u,parentHeight:T}=e,N=P==="row",E=Ge({containerRef:s,isRow:N,direction:P,splitPercentage:g.splitPercentage,resizerSize:t,snapThreshold:n,layout:o,currentNode:g,onLayoutChange:r,onResizeStart:()=>p(true),onResizeEnd:()=>p(false),parentLeft:L,parentTop:M,parentWidth:u,parentHeight:T}),A=N?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${y}%) - ${t/2}px)`,top:`calc(${w}% + ${t/2}px)`,width:`${t}px`,height:`calc(${k}% - ${t}px)`,cursor:l?"default":"col-resize",pointerEvents:l?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${y}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${w}%) - ${t/2}px)`,width:`calc(${x}% - ${t}px)`,height:`${t}px`,cursor:l?"default":"row-resize",pointerEvents:l?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsxRuntime.jsx("div",{className:a.resizer||"","data-direction":P,"data-resizing":d||void 0,style:A,onPointerDown:E,role:"separator","aria-valuenow":g.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},dn=_t__default.default.memo(({paneId:e,renderPane:t})=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane),pn=({tree:e,resizerSize:t=4,snapThreshold:n})=>{let{layout:s,renderPane:o,activeId:r,dismissIntentId:a,setContainerRef:l,fullscreenPaneId:d,snapThreshold:p,locked:g,classNames:P}=ae(),y=n!==void 0?n:p??8,w=e!==void 0?e:s,x=_t.useRef(null),{panes:k,splitters:L}=_t.useMemo(()=>w?ge(w):{panes:[],splitters:[]},[w]);if(!w)return null;let M=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[k.map(u=>{let T=d===u.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:T?"0%":`var(--pane-left-${u.paneId}, ${u.left}%)`,top:T?"0%":`var(--pane-top-${u.paneId}, ${u.top}%)`,width:T?"100%":`var(--pane-width-${u.paneId}, ${u.width}%)`,height:T?"100%":`var(--pane-height-${u.paneId}, ${u.height}%)`,overflow:"hidden",zIndex:T?20:1,display:d&&!T?"none":"block",padding:T?"0px":`${t/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(dn,{paneId:u.paneId,renderPane:o})},u.paneId)}),!d&&L.map(u=>jsxRuntime.jsx(un,{splitter:u,resizerSize:t,snapThreshold:y,containerRef:x},u.id))]});if(e===void 0){let u=r!==null&&r===a,T=E=>{l(E),x.current=E;},N=`${P.dashboard||""} ${u&&P.dashboardDismissActive||""} ${g&&P.dashboardLocked||""}`.trim();return jsxRuntime.jsxs("div",{ref:T,className:N,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[M(),r!==null&&!g&&jsxRuntime.jsx(bt,{activeClassName:P.dropPreview})]})}return jsxRuntime.jsx("div",{ref:x,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:M()})};var Be=_t.createContext(null);var Tn={top:{position:"absolute",top:0,left:0,width:"100%",height:"25%",zIndex:20,pointerEvents:"auto"},bottom:{position:"absolute",bottom:0,left:0,width:"100%",height:"25%",zIndex:20,pointerEvents:"auto"},left:{position:"absolute",top:"25%",left:0,width:"50%",height:"50%",zIndex:20,pointerEvents:"auto"},right:{position:"absolute",top:"25%",right:0,width:"50%",height:"50%",zIndex:20,pointerEvents:"auto"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:20,pointerEvents:"auto",cursor:"not-allowed"}},xn={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"}},Pt=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:s,isOver:o}=core.useDroppable({id:e});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:s,style:Tn[t]}),o&&jsxRuntime.jsx("div",{className:n,style:xn[t]})]})},yn=({id:e,children:t,style:n,locked:s=false})=>{let o=_t.useRef(null),{layout:r,activeId:a,classNames:l,fullscreenPaneId:d,onFullscreenChange:p,locked:g}=ae(),{removePane:P,updateTabMetadata:y,selectTab:w,removeTab:x}=ze(),k=_t.useContext($e);if(!k)throw new Error("Pane must be used within a Zeugma provider");let{registerPortalTarget:L}=k,M=_t.useMemo(()=>j(r,e),[r,e]),u=M?.id??e,T=M?.tabs??[e],N=M?.activeTabId??e,E=M?.tabsMetadata,A=E?.[e],J=M?.locked??false,q=s||J,W=g||q,ee=g||q,te=a!==null&&a!==e&&(!T.includes(a)||T.length>1)&&!ee,{attributes:ie,listeners:ne,setNodeRef:le}=core.useDraggable({id:e,disabled:W}),D=a!==null&&T.includes(a),O=d===e,$=_t.useCallback(()=>jsxRuntime.jsx("div",{ref:o,id:`zeugma-tab-target-${N}`,className:"zeugma-tab-content-wrapper",style:{height:"100%",width:"100%"}}),[N]);_t.useEffect(()=>{let h=o.current;return L(N,h),()=>{L(N,null);}},[N,L]);let z=_t.useMemo(()=>({isDragging:D,isFullscreen:O,toggleFullscreen:()=>p?.(O?null:e),remove:()=>{O&&p?.(null),P(u);},metadata:A,updateMetadata:h=>{y(e,h);},locked:W,tabs:T,activeTabId:N,selectTab:h=>w(u,h),removeTab:h=>{O&&h===N&&p?.(null),x(h);},tabsMetadata:E,updateTabMetadata:(h,v)=>{y(h,v);},renderActiveTab:$}),[D,O,p,e,x,A,y,W,T,N,w,u,E,$]),R=_t.useMemo(()=>W?{disabled:true}:{...ne,...ie},[ne,ie,W]),i=`${l.pane||""} ${q&&l.paneLocked||""}`.trim();return jsxRuntime.jsx(Be.Provider,{value:R,children:jsxRuntime.jsxs("div",{ref:le,className:i,style:{position:"relative",width:"100%",height:"100%",...n},children:[t(z),te&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(h=>jsxRuntime.jsx(Pt,{id:`drop-${h}-${e}`,position:h,activeClassName:l.dropPreview},h))}),a!==null&&a!==e&&ee&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsxRuntime.jsx(Pt,{id:`drop-locked-${e}`,position:"full",activeClassName:l.lockedPreview||""})})]})})};var Dn=({children:e,className:t,style:n})=>{let s=_t.useContext(Be);if(!s)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:o,...r}=s;return jsxRuntime.jsx("div",{className:t,style:{cursor:o?"default":"grab",userSelect:o?"auto":"none",touchAction:o?"auto":"none",...n},...o?{}:r,children:e})};var Ct=_t.createContext(void 0),Ln=()=>{let e=_t.useContext(Ct);if(!e)throw new Error("useTabContext must be used within a Tab component");return e},Dt=({id:e,locked:t=false,children:n,className:s,style:o})=>{let{locked:r,classNames:a={},activeType:l}=ae(),{overTabId:d}=Ae(),p=_t.useContext(Qe),g=t||r||(p?.locked??false),{attributes:P,listeners:y,setNodeRef:w,isDragging:x}=core.useDraggable({id:`tab-header-${e}`,disabled:g}),{setNodeRef:k,isOver:L}=core.useDroppable({id:`tab-drop-${e}`,disabled:g||l==="pane"}),M=ne=>{w(ne),k(ne);},u=L&&d===e,T=p?.tabs||[],N=T.indexOf(e),E=p?.activeTabId,J=N>0&&e!==E&&T[N-1]!==E?jsxRuntime.jsx("div",{className:a.tabSeparator}):null,q=p?p.activeTabId===e:false,W=p?.tabsMetadata?.[e],ee=_t.useCallback(()=>{p?.selectTab(e);},[p,e]),te=_t.useCallback(()=>{p?.removeTab(e);},[p,e]),ie=_t.useMemo(()=>({tabId:e,isActive:q,isDragging:x,isOver:u,metadata:W,locked:g,selectTab:ee,removeTab:te}),[e,q,x,u,W,g,ee,te]);return jsxRuntime.jsx(Ct.Provider,{value:ie,children:jsxRuntime.jsxs("div",{ref:M,className:s,style:{display:"inline-flex",position:"relative",cursor:g?"default":"grab",...o},...g?{}:y,...g?{}:P,children:[J,n({isDragging:x,isOver:u})]})})};var Qe=_t.createContext(void 0);var St=(e,t)=>typeof e=="function"?e(t):e,zn=({tabs:e,activeTabId:t,locked:n=false,tabsMetadata:s,selectTab:o,removeTab:r,renderTab:a,classNames:l,styles:d})=>{let{classNames:p={},activeType:g}=ae(),{overTabId:P,overTabPosition:y}=Ae(),w=_t.useMemo(()=>({tabs:e,activeTabId:t,locked:n,tabsMetadata:s,selectTab:o,removeTab:r}),[e,t,n,s,o,r]),x=at(e,g,P,y);return jsxRuntime.jsx(Qe.Provider,{value:w,children:jsxRuntime.jsxs("div",{className:l?.container,style:{display:"flex",alignItems:"center",height:"100%",...d?.container},children:[e.map((k,L)=>{let M=s?.[k],u=St(l?.tab,k),T=St(d?.tab,k),N=L===x;return jsxRuntime.jsxs(_t__default.default.Fragment,{children:[N&&p.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:p.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:L===0?"none":"translateX(-50%)"}})}),jsxRuntime.jsx(Dt,{id:k,locked:n,className:u,style:T,children:({isDragging:E,isOver:A})=>a({tabId:k,activeTabId:t,isDragging:E,isOver:A,metadata:M,selectTab:o,removeTab:r})})]},k)}),x===e.length&&p.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:p.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:"translateX(-100%)"}})})]})})};exports.DEFAULT_DRAG_ACTIVATION_DISTANCE=Lt;exports.DEFAULT_RESIZER_SIZE=On;exports.DEFAULT_SNAP_THRESHOLD=It;exports.DragHandle=Dn;exports.Pane=yn;exports.PaneTree=pn;exports.PortalRegistryContext=$e;exports.Tabs=zn;exports.Zeugma=Gt;exports.ZeugmaActionsContext=Ye;exports.ZeugmaDragContext=Je;exports.ZeugmaStateContext=Xe;exports.createDragSession=ct;exports.safeJsonStringify=Ne;exports.useResizer=Ge;exports.useTabContext=Ln;exports.useZeugma=Mt;exports.useZeugmaActions=ze;exports.useZeugmaContext=Zt;exports.useZeugmaDrag=Ae;exports.useZeugmaState=ae;//# sourceMappingURL=index.cjs.map
|
|
6
|
+
`,document.head.appendChild(r),t.setAttribute("data-resizing","true");let s=c=>{n(c);},i=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let c=document.getElementById("zeugma-global-cursor-style");c&&c.remove(),document.removeEventListener("pointermove",s),document.removeEventListener("pointerup",i),o();};document.addEventListener("pointermove",s),document.addEventListener("pointerup",i);}var qe=Kt.createContext(void 0),Ge=Kt.createContext(void 0),He=Kt.createContext(void 0),Ke=Kt.createContext(void 0),ne=()=>{let e=Kt.useContext(qe);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},we=()=>{let e=Kt.useContext(Ge);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},Oe=()=>{let e=Kt.useContext(Ke);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};var Ot=()=>{let e=ne(),t=we();return {...e,...t}};var Fe=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},Ve=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};function We(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}function ht(e){let{layout:t,setLayout:n,layoutBeforeDrag:o,setLayoutBeforeDrag:r,activeId:s,setActiveId:i,setActiveType:c,dismissIntentId:p,setDismissIntentId:f,setOverTabId:m,setOverTabPosition:b,containerRef:P,dragActivationDistance:v,enableDragToDismiss:x,dismissThreshold:M,onRemove:A,onDragStart:N,onDragEnd:d,onDismissIntentChange:T,removeTab:E}=e,D=Kt.useRef(null),H=it(s),[q,G]=Kt.useState(false);at(q);let X=core.useSensors(core.useSensor(Fe,{activationConstraint:{distance:v}}),core.useSensor(Ve,{activationConstraint:{delay:250,tolerance:5}})),te=Kt.useCallback(w=>{let Z=w.active.id.toString().startsWith("tab-header-"),k=core.pointerWithin(w),y=Z?k:k.filter(a=>!a.id.toString().startsWith("tab-drop-"));if(y.length>0)return [...y].sort((h,R)=>{let g=h.id.toString(),K=R.id.toString();if(Z){let V=g.startsWith("tab-drop-"),Q=K.startsWith("tab-drop-");if(V&&!Q)return -1;if(!V&&Q)return 1}let $=g.startsWith("drop-root-"),O=K.startsWith("drop-root-");return $&&!O?-1:!$&&O?1:0});if(Z){let a=w.droppableContainers.filter(h=>h.id.toString().startsWith("tab-drop-"));return core.closestCenter({...w,droppableContainers:a})}return []},[]);return {sensors:X,collisionDetection:te,onDragStart:w=>{let F=w.active.id.toString(),Z=F.startsWith("tab-header-"),k=Z?F.substring(11):F;i(k),c(Z?"tab":"pane"),m(null),b(null);let y=w.activatorEvent;H.current=We(y),x&&P.current?D.current=P.current.getBoundingClientRect():D.current=null;let a=t;if(Z){let h=U(t,k);h&&(a=Re(t,h.id,k)||t);}r(a),Z&&a!==t&&n(a),N&&N(k);},onDragMove:w=>{let{over:F}=w,Z=F?.id.toString()||"",k=Z.startsWith("drop-locked-");G(l=>l===k?l:k);let y=w.active.id.toString(),a=y.startsWith("tab-header-"),h=a?y.substring(11):y,R=Z.match(/^tab-drop-(.+)$/);if(R&&F&&a){let[,l]=R;if(h!==l){let S="before",I=F.rect,ie=w.activatorEvent,Y=null;if(H.current)Y=H.current.x;else {let j=We(ie);j&&(Y=j.x+w.delta.x);}if(Y!==null){let j=I.left+I.width/2;Y>j&&(S="after");}m(j=>j===l?j:l),b(j=>j===S?j:S);}else m(S=>S===null?S:null),b(S=>S===null?S:null);}else m(l=>l===null?l:null),b(l=>l===null?l:null);if(!x)return;let g=D.current;if(!g){p!==null&&(f(null),T?.(null));return}let K=w.activatorEvent,$=null,O=null;if(H.current)$=H.current.x,O=H.current.y;else {let l=We(K);l&&($=l.x+w.delta.x,O=l.y+w.delta.y);}let V=0;if($!==null&&O!==null){let l=0,S=0;$<g.left?l=g.left-$:$>g.right&&(l=$-g.right),O<g.top?S=g.top-O:O>g.bottom&&(S=O-g.bottom),V=Math.sqrt(l*l+S*S);}else {let l=w.active.rect.current.translated;if(l){let S=l.left+l.width/2,I=l.top+l.height/2,ie=0,Y=0;S<g.left?ie=g.left-S:S>g.right&&(ie=S-g.right),I<g.top?Y=g.top-I:I>g.bottom&&(Y=I-g.bottom),V=Math.sqrt(ie*ie+Y*Y);}}V>M?p!==h&&(f(h),T?.(h)):p!==null&&(f(null),T?.(null));},onDragEnd:w=>{i(null),c(null),G(false),m(null),b(null);let{active:F,over:Z}=w,k=F.id.toString(),y=k.startsWith("tab-header-"),a=y?k.substring(11):k,h=x&&p===a;f(null),T?.(null),D.current=null;let R=o||t;if(r(null),h){A?A(a):E(a),d&&d(a,null,null);return}if(!Z){n(R),d&&d(a,null,null);return}let g=Z.id.toString();if(g.startsWith("drop-locked-")){n(R),d&&d(a,null,null);return}let K=g.match(/^tab-drop-(.+)$/);if(K){if(!y){n(R),d&&d(a,null,null);return}let[,ce]=K;if(a!==ce){let ue="before",J=Z.rect,me=w.activatorEvent,z=null;if(H.current)z=H.current.x;else {let W=We(me);W&&(z=W.x+w.delta.x);}if(z!==null){let W=J.left+J.width/2;z>W&&(ue="after");}let ae=$e(R,a,ce,ue);n(ae),d&&d(a,ce,{type:"move",position:"center"});}else n(R),d&&d(a,null,null);return}let $=g.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if($){let[,ce,ue]=$,J=ue;J==="start"&&(J="left"),J==="end"&&(J="right");let me=y?fe(R,a):he(R,a),z;if(y){let W=U(R,a)?.tabsMetadata?.[a];z={type:"pane",id:de(),tabs:[a],activeTabId:a,tabsMetadata:W?{[a]:W}:void 0};}else z=ee(R,a)??{type:"pane",id:de(),tabs:[a],activeTabId:a};if(me===null)n(z);else {let ae=J==="left"||J==="right",W=J==="left"||J==="top",Pe=50;ce==="1/4"?Pe=W?25:75:ce==="1/3"&&(Pe=W?100/3:200/3),n({type:"split",direction:ae?"row":"column",first:W?z:me,second:W?me:z,splitPercentage:Pe});}d&&d(a,"root",{type:"split",direction:J==="left"||J==="right"?"row":"column",position:J});return}let O=g.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!O){n(R),d&&d(a,null,null);return}let[,V,Q]=O,l=y?U(R,a):ee(R,a),S=l&&l.id===Q,I=l&&l.tabs.length===1;if(a===Q||S&&I){n(R),d&&d(a,null,null);return}let ie=V==="left"||V==="right"?"row":"column",Y;if(y){let ue=U(R,a)?.tabsMetadata?.[a];Y={type:"pane",id:de(),tabs:[a],activeTabId:a,tabsMetadata:ue?{[a]:ue}:void 0};}else Y=ee(R,a)??{type:"pane",id:de(),tabs:[a],activeTabId:a};let j=y?fe(R,a):he(R,a),Ne=Ce(j,Q,ie,V,Y);n(Ne),d&&d(a,Q,{type:"split",direction:ie,position:V});},onDragCancel:()=>{i(null),c(null),G(false),m(null),b(null),f(null),T?.(null),D.current=null,o!==null&&(n(o),r(null));}}}var vt=({activeId:e,render:t,className:n})=>{let o=Kt.useRef(null);return Kt.useEffect(()=>{let r=s=>{o.current&&(o.current.style.transform=`translate(${s.clientX+12}px, ${s.clientY+12}px)`);};return document.addEventListener("pointermove",r),()=>document.removeEventListener("pointermove",r)},[]),jsxRuntime.jsx("div",{ref:o,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var Pt=Kt__default.default.memo(({tabId:e,target:t,renderWidget:n})=>{let[o,r]=Kt.useState(false),s=Kt.useRef(null),{popoutTabs:i}=ne(),{setTabPopout:c}=we(),p=!!i[e];Kt.useEffect(()=>{r(true);},[]);let f=Kt.useCallback(()=>{s.current&&(document.adoptNode(s.current),Xe("zeugma-hidden-portal-container").appendChild(s.current)),c(e,false);},[e,c]),{popupWindow:m,popupContainer:b}=ct({tabId:e,isOpenedInNewWindow:p,onClose:f});if(Kt.useEffect(()=>{if(!o||!s.current)return;let v=s.current;p?b&&m&&(m.document.adoptNode(v),b.appendChild(v)):(document.adoptNode(v),t?t.appendChild(v):Xe("zeugma-hidden-portal-container").appendChild(v));},[t,o,p,b,m]),Kt.useEffect(()=>()=>{s.current&&s.current.remove();},[]),!o)return null;s.current||(s.current=document.createElement("div"),s.current.className=`zeugma-portal-wrapper-${e}`,s.current.style.width="100%",s.current.style.height="100%");let P=s.current;return !P||!n?null:reactDom.createPortal(n(e),P)});var on=e=>{let t=e,{renderPane:n,renderWidget:o,renderDragOverlay:r,classNames:s={},children:i,layout:c,setLayout:p,fullscreenPaneId:f,setFullscreenPaneId:m,locked:b,setLocked:P,popoutTabs:v,findPaneById:x,findPaneContainingTab:M,findTabById:A,activeId:N,activeType:d,dismissIntentId:T,setContainerRef:E,layoutBeforeDrag:D,snapThreshold:H,minSplitPercentage:q,maxSplitPercentage:G,onRemove:X,onResizeStart:te,onResize:oe,onResizeEnd:re,removePane:se,addPane:le,addTab:w,updateTabMetadata:F,updatePaneLock:Z,selectTab:k,mergeTab:y,removeTab:a,splitPane:h,updateSplitPercentage:R,moveTab:g,setTabPopout:K}=t,{portalTargets:$,registerPortalTarget:O}=lt(),[V,Q]=Kt.useState(null),[l,S]=Kt.useState(null),I=ht({...t,setOverTabId:Q,setOverTabPosition:S}),ie=Kt.useCallback(z=>n(z),[n]),Y=Kt.useMemo(()=>s,[s.dashboard,s.dashboardDismissActive,s.pane,s.paneLocked,s.dropPreview,s.dragOverlay,s.resizer,s.dismissPreview,s.dashboardLocked,s.lockedPreview,s.tabDropPreview,s.tabSeparator]),j=Kt.useCallback((z,ae)=>{re&&re(z,ae);},[re]),Ne=Kt.useMemo(()=>({layout:c,setLayout:p,renderPane:ie,activeId:N,activeType:d,dismissIntentId:T,setContainerRef:E,fullscreenPaneId:f,classNames:Y,onRemove:X,onFullscreenChange:m,snapThreshold:H,onResizeStart:te,onResize:oe,onResizeEnd:j,minSplitPercentage:q,maxSplitPercentage:G,locked:b,setLocked:P,popoutTabs:v,findPaneById:x,findPaneContainingTab:M,findTabById:A}),[c,N,d,T,E,f,Y,X,m,H,te,oe,q,G,p,ie,j,b,P,v,x,M,A]),ce=Kt.useMemo(()=>({overTabId:V,overTabPosition:l}),[V,l]),ue=Kt.useMemo(()=>({removePane:se,addPane:le,addTab:w,updateTabMetadata:F,updatePaneLock:Z,selectTab:k,mergeTab:y,removeTab:a,setFullscreenPaneId:m,setLocked:P,splitPane:h,updateSplitPercentage:R,moveTab:g,setTabPopout:K}),[se,le,w,F,Z,k,y,a,m,P,h,R,g,K]),J=Kt.useMemo(()=>{let z=new Set;function ae(W){W&&(W.type==="pane"?W.tabs.forEach(Pe=>{z.add(Pe);}):(ae(W.first),ae(W.second)));}return ae(c),D&&ae(D),Array.from(z).sort()},[c,N,D]),me=Kt.useMemo(()=>({registerPortalTarget:O}),[O]);return jsxRuntime.jsx(Ge.Provider,{value:ue,children:jsxRuntime.jsx(qe.Provider,{value:Ne,children:jsxRuntime.jsx(Ke.Provider,{value:ce,children:jsxRuntime.jsxs(He.Provider,{value:me,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",...I,children:i}),N&&d&&r&&jsxRuntime.jsx(vt,{activeId:N,render:z=>r(z,d),className:`${s.dragOverlay||""} ${N===T&&s.dismissPreview||""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:J.map(z=>jsxRuntime.jsx(Pt,{tabId:z,target:$[z]||null,renderWidget:o},z))})]})})})})};var an={top:{"1/4":{position:"absolute",top:0,left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",top:"24px",left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"}},bottom:{"1/4":{position:"absolute",bottom:0,left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",bottom:"24px",left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"}},left:{"1/4":{position:"absolute",left:0,top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",left:"24px",top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"}},right:{"1/4":{position:"absolute",right:0,top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",right:"24px",top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"}}},ln={top:{"1/4":{top:0,left:0,width:"100%",height:"25%"},"1/3":{top:0,left:0,width:"100%",height:"33.3333%"}},bottom:{"1/4":{bottom:0,left:0,width:"100%",height:"25%"},"1/3":{bottom:0,left:0,width:"100%",height:"33.3333%"}},left:{"1/4":{left:0,top:0,width:"25%",height:"100%"},"1/3":{left:0,top:0,width:"33.3333%",height:"100%"}},right:{"1/4":{right:0,top:0,width:"25%",height:"100%"},"1/3":{right:0,top:0,width:"33.3333%",height:"100%"}}},cn=({id:e,fraction:t,edge:n,activeClassName:o})=>{let{setNodeRef:r,isOver:s}=core.useDroppable({id:e}),i={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...ln[n][t]};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:r,style:an[n][t]}),s&&jsxRuntime.jsx("div",{className:o,style:i})]})},yt=({activeClassName:e})=>jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:99,pointerEvents:"none"},children:[{id:"drop-root-1/3-top",fraction:"1/3",edge:"top"},{id:"drop-root-1/3-bottom",fraction:"1/3",edge:"bottom"},{id:"drop-root-1/4-left",fraction:"1/4",edge:"left"},{id:"drop-root-1/3-left",fraction:"1/3",edge:"left"},{id:"drop-root-1/4-right",fraction:"1/4",edge:"right"},{id:"drop-root-1/3-right",fraction:"1/3",edge:"right"}].map(n=>jsxRuntime.jsx(cn,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});function je({containerRef:e,isRow:t,direction:n,splitPercentage:o,resizerSize:r,snapThreshold:s,layout:i,currentNode:c,onLayoutChange:p,onResizeStart:f,onResizeEnd:m,parentLeft:b,parentTop:P,parentWidth:v,parentHeight:x}){let{onResizeStart:M,onResize:A,onResizeEnd:N,minSplitPercentage:d=5,maxSplitPercentage:T=95,locked:E=false}=ne();return Kt.useCallback(D=>{if(E)return;D.preventDefault();let H=e.current;if(!H)return;f&&f(),M&&M(c);let q=H.getBoundingClientRect(),G=D.clientX,X=D.clientY,te=o,oe=D.currentTarget,re=q.left+q.width*(b/100),se=q.top+q.height*(P/100),le=q.width*(v/100),w=q.height*(x/100),Z=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(y=>y!==oe&&y.getAttribute("data-direction")===n).map(y=>{let a=y.getBoundingClientRect();return t?a.left+a.width/2:a.top+a.height/2}),k=te;gt({cursor:t?"col-resize":"row-resize",resizerEl:oe,onMove:y=>{let a=t?(y.clientX-G)/le*100:(y.clientY-X)/w*100,h=te+a,R=t?re+(le-r)*(h/100)+r/2:se+(w-r)*(h/100)+r/2,g=1/0,K=null;for(let Q of Z){let l=Math.abs(R-Q);l<s&&l<g&&(g=l,K=Q);}let $=h;K!==null&&($=t?(K-r/2-re)/(le-r)*100:(K-r/2-se)/(w-r)*100);let O=Math.max(d,Math.min(T,$));k=O;let V=Te(i,c,O);if(V){let{panes:Q,splitters:l}=ge(V),S=e.current;if(S){for(let I of Q)S.style.setProperty(`--pane-left-${I.paneId}`,`${I.left}%`),S.style.setProperty(`--pane-top-${I.paneId}`,`${I.top}%`),S.style.setProperty(`--pane-width-${I.paneId}`,`${I.width}%`),S.style.setProperty(`--pane-height-${I.paneId}`,`${I.height}%`);for(let I of l)S.style.setProperty(`--splitter-pos-${I.id}`,`${I.direction==="row"?I.left:I.top}%`);}}A&&A(c,O);},onEnd:()=>{let y=Te(i,c,k),a=e.current;if(a){let{panes:h,splitters:R}=ge(y);for(let g of h)a.style.removeProperty(`--pane-left-${g.paneId}`),a.style.removeProperty(`--pane-top-${g.paneId}`),a.style.removeProperty(`--pane-width-${g.paneId}`),a.style.removeProperty(`--pane-height-${g.paneId}`);for(let g of R)a.style.removeProperty(`--splitter-pos-${g.id}`);}p(y),m&&m(),N&&N(c,k);}});},[e,t,n,o,r,s,i,c,p,f,m,M,A,N,d,T,b,P,v,x])}var hn=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:o})=>{let{layout:r,setLayout:s,classNames:i,locked:c}=ne(),[p,f]=Kt.useState(false),{currentNode:m,direction:b,left:P,top:v,width:x,height:M,parentLeft:A,parentTop:N,parentWidth:d,parentHeight:T}=e,E=b==="row",D=je({containerRef:o,isRow:E,direction:b,splitPercentage:m.splitPercentage,resizerSize:t,snapThreshold:n,layout:r,currentNode:m,onLayoutChange:s,onResizeStart:()=>f(true),onResizeEnd:()=>f(false),parentLeft:A,parentTop:N,parentWidth:d,parentHeight:T}),H=E?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${P}%) - ${t/2}px)`,top:`calc(${v}% + ${t/2}px)`,width:`${t}px`,height:`calc(${M}% - ${t}px)`,cursor:c?"default":"col-resize",pointerEvents:c?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${P}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${v}%) - ${t/2}px)`,width:`calc(${x}% - ${t}px)`,height:`${t}px`,cursor:c?"default":"row-resize",pointerEvents:c?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsxRuntime.jsx("div",{className:i.resizer||"","data-direction":b,"data-resizing":p||void 0,style:H,onPointerDown:D,role:"separator","aria-valuenow":m.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},vn=Kt__default.default.memo(({paneId:e,renderPane:t})=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane),Pn=({tree:e,resizerSize:t=4,snapThreshold:n})=>{let{layout:o,renderPane:r,activeId:s,dismissIntentId:i,setContainerRef:c,fullscreenPaneId:p,snapThreshold:f,locked:m,classNames:b}=ne(),P=n!==void 0?n:f??8,v=e!==void 0?e:o,x=Kt.useRef(null),{panes:M,splitters:A}=Kt.useMemo(()=>v?ge(v):{panes:[],splitters:[]},[v]);if(!v)return null;let N=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[M.map(d=>{let T=p===d.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:T?"0%":`var(--pane-left-${d.paneId}, ${d.left}%)`,top:T?"0%":`var(--pane-top-${d.paneId}, ${d.top}%)`,width:T?"100%":`var(--pane-width-${d.paneId}, ${d.width}%)`,height:T?"100%":`var(--pane-height-${d.paneId}, ${d.height}%)`,overflow:"hidden",zIndex:T?20:1,display:p&&!T?"none":"block",padding:T?"0px":`${t/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(vn,{paneId:d.paneId,renderPane:r})},d.paneId)}),!p&&A.map(d=>jsxRuntime.jsx(hn,{splitter:d,resizerSize:t,snapThreshold:P,containerRef:x},d.id))]});if(e===void 0){let d=s!==null&&s===i,T=D=>{c(D),x.current=D;},E=`${b.dashboard||""} ${d&&b.dashboardDismissActive||""} ${m&&b.dashboardLocked||""}`.trim();return jsxRuntime.jsxs("div",{ref:T,className:E,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[N(),s!==null&&!m&&jsxRuntime.jsx(yt,{activeClassName:b.dropPreview})]})}return jsxRuntime.jsx("div",{ref:x,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:N()})};var Ue=Kt.createContext(null);var Sn={top:{position:"absolute",top:0,left:0,width:"100%",height:"25%",zIndex:20,pointerEvents:"auto"},bottom:{position:"absolute",bottom:0,left:0,width:"100%",height:"25%",zIndex:20,pointerEvents:"auto"},left:{position:"absolute",top:"25%",left:0,width:"50%",height:"50%",zIndex:20,pointerEvents:"auto"},right:{position:"absolute",top:"25%",right:0,width:"50%",height:"50%",zIndex:20,pointerEvents:"auto"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:20,pointerEvents:"auto",cursor:"not-allowed"}},Nn={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"}},wt=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:o,isOver:r}=core.useDroppable({id:e});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:o,style:Sn[t]}),r&&jsxRuntime.jsx("div",{className:n,style:Nn[t]})]})},En=({id:e,children:t,style:n,locked:o=false})=>{let r=Kt.useRef(null),{layout:s,activeId:i,classNames:c,fullscreenPaneId:p,onFullscreenChange:f,locked:m}=ne(),{removePane:b,updateTabMetadata:P,selectTab:v,removeTab:x}=we(),M=Kt.useContext(He);if(!M)throw new Error("Pane must be used within a Zeugma provider");let{registerPortalTarget:A}=M,N=Kt.useMemo(()=>ee(s,e),[s,e]),d=N?.id??e,T=N?.tabs??[e],E=N?.activeTabId??e,D=N?.tabsMetadata,H=D?.[e],q=N?.locked??false,G=o||q,X=m||G,te=m||G,oe=i!==null&&i!==e&&(!T.includes(i)||T.length>1)&&!te,{attributes:re,listeners:se,setNodeRef:le}=core.useDraggable({id:e,disabled:X}),w=i!==null&&T.includes(i),F=p===e,Z=Kt.useCallback(()=>jsxRuntime.jsx("div",{ref:r,id:`zeugma-tab-target-${E}`,className:"zeugma-tab-content-wrapper",style:{height:"100%",width:"100%"}}),[E]);Kt.useEffect(()=>{let h=r.current;return A(E,h),()=>{A(E,null);}},[E,A]);let k=Kt.useMemo(()=>({isDragging:w,isFullscreen:F,toggleFullscreen:()=>f?.(F?null:e),remove:()=>{F&&f?.(null),b(d);},metadata:H,updateMetadata:h=>{P(e,h);},locked:X,tabs:T,activeTabId:E,selectTab:h=>v(d,h),removeTab:h=>{F&&h===E&&f?.(null),x(h);},tabsMetadata:D,updateTabMetadata:(h,R)=>{P(h,R);},renderActiveTab:Z}),[w,F,f,e,x,H,P,X,T,E,v,d,D,Z]),y=Kt.useMemo(()=>X?{disabled:true}:{...se,...re},[se,re,X]),a=`${c.pane||""} ${G&&c.paneLocked||""}`.trim();return jsxRuntime.jsx(Ue.Provider,{value:y,children:jsxRuntime.jsxs("div",{ref:le,className:a,style:{position:"relative",width:"100%",height:"100%",...n},children:[t(k),oe&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(h=>jsxRuntime.jsx(wt,{id:`drop-${h}-${e}`,position:h,activeClassName:c.dropPreview},h))}),i!==null&&i!==e&&te&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsxRuntime.jsx(wt,{id:`drop-locked-${e}`,position:"full",activeClassName:c.lockedPreview||""})})]})})};var Mn=({children:e,className:t,style:n})=>{let o=Kt.useContext(Ue);if(!o)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:r,...s}=o;return jsxRuntime.jsx("div",{className:t,style:{cursor:r?"default":"grab",userSelect:r?"auto":"none",touchAction:r?"auto":"none",...n},...r?{}:s,children:e})};var It=Kt.createContext(void 0),Hn=()=>{let e=Kt.useContext(It);if(!e)throw new Error("useTabContext must be used within a Tab component");return e},Lt=({id:e,locked:t=false,children:n,className:o,style:r})=>{let{locked:s,classNames:i={},activeType:c}=ne(),{overTabId:p}=Oe(),f=Kt.useContext(tt),m=t||s||(f?.locked??false),{attributes:b,listeners:P,setNodeRef:v,isDragging:x}=core.useDraggable({id:`tab-header-${e}`,disabled:m}),{setNodeRef:M,isOver:A}=core.useDroppable({id:`tab-drop-${e}`,disabled:m||c==="pane"}),N=se=>{v(se),M(se);},d=A&&p===e,T=f?.tabs||[],E=T.indexOf(e),D=f?.activeTabId,q=E>0&&e!==D&&T[E-1]!==D?jsxRuntime.jsx("div",{className:i.tabSeparator}):null,G=f?f.activeTabId===e:false,X=f?.tabsMetadata?.[e],te=Kt.useCallback(()=>{f?.selectTab(e);},[f,e]),oe=Kt.useCallback(()=>{f?.removeTab(e);},[f,e]),re=Kt.useMemo(()=>({tabId:e,isActive:G,isDragging:x,isOver:d,metadata:X,locked:m,selectTab:te,removeTab:oe}),[e,G,x,d,X,m,te,oe]);return jsxRuntime.jsx(It.Provider,{value:re,children:jsxRuntime.jsxs("div",{ref:N,className:o,style:{display:"inline-flex",position:"relative",cursor:m?"default":"grab",...r},...m?{}:P,...m?{}:b,children:[q,n({isDragging:x,isOver:d})]})})};var tt=Kt.createContext(void 0);var Mt=(e,t)=>typeof e=="function"?e(t):e,Bn=({tabs:e,activeTabId:t,locked:n=false,tabsMetadata:o,selectTab:r,removeTab:s,renderTab:i,classNames:c,styles:p})=>{let{classNames:f={},activeType:m}=ne(),{overTabId:b,overTabPosition:P}=Oe(),v=Kt.useMemo(()=>({tabs:e,activeTabId:t,locked:n,tabsMetadata:o,selectTab:r,removeTab:s}),[e,t,n,o,r,s]),x=ft(e,m,b,P);return jsxRuntime.jsx(tt.Provider,{value:v,children:jsxRuntime.jsxs("div",{className:c?.container,style:{display:"flex",alignItems:"center",height:"100%",...p?.container},children:[e.map((M,A)=>{let N=o?.[M],d=Mt(c?.tab,M),T=Mt(p?.tab,M),E=A===x;return jsxRuntime.jsxs(Kt__default.default.Fragment,{children:[E&&f.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:f.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:A===0?"none":"translateX(-50%)"}})}),jsxRuntime.jsx(Lt,{id:M,locked:n,className:d,style:T,children:({isDragging:D,isOver:H})=>i({tabId:M,activeTabId:t,isDragging:D,isOver:H,metadata:N,selectTab:r,removeTab:s})})]},M)}),x===e.length&&f.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:f.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:"translateX(-100%)"}})})]})})};exports.DEFAULT_DRAG_ACTIVATION_DISTANCE=At;exports.DEFAULT_RESIZER_SIZE=Jn;exports.DEFAULT_SNAP_THRESHOLD=zt;exports.DragHandle=Mn;exports.Pane=En;exports.PaneTree=Pn;exports.PortalRegistryContext=He;exports.Tabs=Bn;exports.Zeugma=on;exports.ZeugmaActionsContext=Ge;exports.ZeugmaDragContext=Ke;exports.ZeugmaStateContext=qe;exports.copyStyles=rt;exports.createDragSession=gt;exports.getOrCreateHiddenContainer=Xe;exports.safeJsonStringify=Le;exports.useResizer=je;exports.useTabContext=Hn;exports.useZeugma=Ht;exports.useZeugmaActions=we;exports.useZeugmaContext=Ot;exports.useZeugmaDrag=Oe;exports.useZeugmaState=ne;//# sourceMappingURL=index.cjs.map
|
|
7
7
|
//# sourceMappingURL=index.cjs.map
|