react-zeugma 6.4.0 → 6.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,55 +1,16 @@
1
- import * as React from 'react';
2
- import React__default from 'react';
3
- import { P as PortalRegistryValue, Z as ZeugmaActionsValue, a as ZeugmaDragStateValue, b as ZeugmaStateValue, U as UseZeugmaOptions, c as ZeugmaController, d as ZeugmaProps, S as SplitDirection, T as TreeNode, e as SplitNode, f as TabDetails } from './types-B9LrYapR.cjs';
4
- export { D as DragOverlayActiveItem, g as PaneNode, h as ZeugmaActions, i as ZeugmaClassNames, j as ZeugmaControllerInternal, k as ZeugmaQueries, l as ZeugmaState, m as ZeugmaStateSetters } from './types-B9LrYapR.cjs';
5
-
6
- declare const DEFAULT_SNAP_THRESHOLD = 8;
7
- declare const DEFAULT_DRAG_ACTIVATION_DISTANCE = 8;
8
- declare const DEFAULT_RESIZER_SIZE = 4;
9
-
10
- /**
11
- * Shared drag-session lifecycle utility.
12
- *
13
- * Handles the common boilerplate for pointer-based resize operations:
14
- * - Adds `zeugma-resizing` class to `document.body`
15
- * - Injects a global `cursor` style so the resize cursor stays active
16
- * even when the pointer leaves the handle element
17
- * - Sets `data-resizing` on the resizer element
18
- * - Attaches `pointermove` / `pointerup` listeners to `document`
19
- * - Cleans everything up on pointer-up
20
- *
21
- * Consumers provide domain-specific `onMove` and `onEnd` callbacks.
22
- */
23
- interface DragSessionConfig {
24
- /** CSS cursor to enforce globally during the drag */
25
- cursor: 'col-resize' | 'row-resize';
26
- /** The resizer DOM element (receives `data-resizing` attribute) */
27
- resizerEl: HTMLElement;
28
- /** Called on every `pointermove` during the drag */
29
- onMove: (e: PointerEvent) => void;
30
- /** Called once on `pointerup` — after cleanup has already run */
31
- onEnd: () => void;
32
- }
33
- declare function createDragSession({ cursor, resizerEl, onMove, onEnd }: DragSessionConfig): void;
34
-
35
- declare function safeJsonStringify(val: unknown): string;
36
-
37
- declare const ZeugmaStateContext: React.Context<ZeugmaStateValue | undefined>;
38
- declare const ZeugmaActionsContext: React.Context<ZeugmaActionsValue | undefined>;
39
- declare const PortalRegistryContext: React.Context<PortalRegistryValue | undefined>;
40
- declare const ZeugmaDragContext: React.Context<ZeugmaDragStateValue | undefined>;
41
- declare const useZeugmaState: () => ZeugmaStateValue;
42
- declare const useZeugmaActions: () => ZeugmaActionsValue;
43
- declare const useZeugmaDrag: () => ZeugmaDragStateValue;
1
+ import { U as UseZeugmaOptions, Z as ZeugmaController, a as ZeugmaProps, b as ZeugmaProviderProps, S as SplitDirection, T as TreeNode, c as SplitNode, d as TabDetails } from './types-BN5W7EvY.cjs';
2
+ export { D as DragOverlayActiveItem, P as PaneNode, e as ZeugmaClassNames } from './types-BN5W7EvY.cjs';
3
+ import React from 'react';
44
4
 
45
5
  declare function useZeugma(options: UseZeugmaOptions): ZeugmaController;
46
6
 
47
7
  declare const useZeugmaContext: () => ZeugmaController;
48
8
 
49
- declare const Zeugma: React__default.FC<ZeugmaProps>;
9
+ declare const ZeugmaProvider: React.FC<ZeugmaProviderProps>;
10
+ declare const Zeugma: React.FC<ZeugmaProps>;
50
11
 
51
12
  interface UseResizerProps {
52
- containerRef: React__default.RefObject<HTMLDivElement | null>;
13
+ containerRef: React.RefObject<HTMLDivElement | null>;
53
14
  isRow: boolean;
54
15
  direction: SplitDirection;
55
16
  splitPercentage: number;
@@ -65,11 +26,11 @@ interface UseResizerProps {
65
26
  parentWidth: number;
66
27
  parentHeight: number;
67
28
  }
68
- declare function useResizer({ containerRef, isRow, direction, splitPercentage, resizerSize, snapThreshold, layout, currentNode, onLayoutChange, onResizeStart: localOnResizeStart, onResizeEnd: localOnResizeEnd, parentLeft, parentTop, parentWidth, parentHeight, }: UseResizerProps): (e: React__default.PointerEvent<HTMLDivElement>) => void;
29
+ declare function useResizer({ containerRef, isRow, direction, splitPercentage, resizerSize, snapThreshold, layout, currentNode, onLayoutChange, onResizeStart: localOnResizeStart, onResizeEnd: localOnResizeEnd, parentLeft, parentTop, parentWidth, parentHeight, }: UseResizerProps): (e: React.PointerEvent<HTMLDivElement>) => void;
69
30
 
70
31
  interface PaneTreeProps {
71
32
  /** Render function mapping unique pane nodes to React elements. Usually renders a <Pane> wrapper. */
72
- renderPane: (paneId: string) => React__default.ReactNode;
33
+ renderPane?: (paneId: string) => React.ReactNode;
73
34
  /** The layout subtree node to render. If not specified, defaults to the root layout tree from the Zeugma context. */
74
35
  tree?: TreeNode | null;
75
36
  /** Size/thickness of the split handle resizer bars in pixels (default 4). */
@@ -77,7 +38,7 @@ interface PaneTreeProps {
77
38
  /** Threshold distance in pixels to snap layout resizers to adjacent edges (default 8). */
78
39
  snapThreshold?: number;
79
40
  }
80
- declare const PaneTree: React__default.FC<PaneTreeProps>;
41
+ declare const PaneTree: React.FC<PaneTreeProps>;
81
42
 
82
43
  interface BaseLeafRenderProps {
83
44
  /** True if the leaf is actively being dragged. */
@@ -112,13 +73,13 @@ interface PaneRenderProps extends BaseLeafRenderProps {
112
73
 
113
74
  interface DragHandleProps {
114
75
  /** The children elements that will trigger dragging when held and dragged. */
115
- children?: React__default.ReactNode;
76
+ children?: React.ReactNode;
116
77
  /** Custom CSS class applied to the drag handle element. */
117
78
  className?: string;
118
79
  /** Optional inline CSS styles applied to the drag handle. */
119
- style?: React__default.CSSProperties;
80
+ style?: React.CSSProperties;
120
81
  }
121
- declare const DragHandle: React__default.FC<DragHandleProps>;
82
+ declare const DragHandle: React.FC<DragHandleProps>;
122
83
 
123
84
  interface TabRenderProps {
124
85
  isDragging: boolean;
@@ -130,13 +91,13 @@ interface TabProps {
130
91
  /** Whether dragging is locked on this tab. */
131
92
  locked?: boolean;
132
93
  /** Render prop child function. */
133
- children: (props: TabRenderProps) => React__default.ReactNode;
94
+ children: (props: TabRenderProps) => React.ReactNode;
134
95
  /** Custom CSS class applied to the tab wrapper. */
135
96
  className?: string;
136
97
  /** Custom inline CSS style applied to the tab wrapper. */
137
- style?: React__default.CSSProperties;
98
+ style?: React.CSSProperties;
138
99
  }
139
- declare const Tab: React__default.FC<TabProps>;
100
+ declare const Tab: React.FC<TabProps>;
140
101
 
141
102
  interface TabsProps {
142
103
  /** The list of tab IDs in this pane. */
@@ -160,7 +121,7 @@ interface TabsProps {
160
121
  metadata?: Record<string, unknown>;
161
122
  onSelect: () => void;
162
123
  onRemove: () => void;
163
- }) => React__default.ReactNode;
124
+ }) => React.ReactNode;
164
125
  /** Custom CSS classes for Tabs container and tab wrappers. */
165
126
  classNames?: {
166
127
  container?: string;
@@ -168,11 +129,11 @@ interface TabsProps {
168
129
  };
169
130
  /** Custom inline CSS styles for Tabs container and tab wrappers. */
170
131
  styles?: {
171
- container?: React__default.CSSProperties;
172
- tab?: React__default.CSSProperties | ((tabId: string) => React__default.CSSProperties);
132
+ container?: React.CSSProperties;
133
+ tab?: React.CSSProperties | ((tabId: string) => React.CSSProperties);
173
134
  };
174
135
  }
175
- declare const Tabs: React__default.FC<TabsProps> & {
136
+ declare const Tabs: React.FC<TabsProps> & {
176
137
  Tab: typeof Tab;
177
138
  };
178
139
 
@@ -180,11 +141,11 @@ interface PaneControlsProps {
180
141
  /** Custom CSS class applied to the controls container. */
181
142
  className?: string;
182
143
  /** Custom inline CSS style applied to the controls container. */
183
- style?: React__default.CSSProperties;
144
+ style?: React.CSSProperties;
184
145
  /** The children elements (e.g. close and fullscreen buttons) to render inside the controls container. */
185
- children?: React__default.ReactNode;
146
+ children?: React.ReactNode;
186
147
  }
187
- declare const PaneControls: React__default.FC<PaneControlsProps>;
148
+ declare const PaneControls: React.FC<PaneControlsProps>;
188
149
 
189
150
  interface PaneContextValue extends PaneRenderProps {
190
151
  id: string;
@@ -192,24 +153,24 @@ interface PaneContextValue extends PaneRenderProps {
192
153
  declare const usePaneContext: () => PaneContextValue;
193
154
  interface PaneContentProps {
194
155
  /** A render callback (tab) => ReactNode or static ReactNode content to render for the active tab. */
195
- children?: React__default.ReactNode | ((tab: TabDetails) => React__default.ReactNode);
156
+ children?: React.ReactNode | ((tab: TabDetails) => React.ReactNode);
196
157
  /** Custom CSS class applied to the tab content wrapper. */
197
158
  className?: string;
198
159
  /** Custom inline CSS style applied to the tab content wrapper. */
199
- style?: React__default.CSSProperties;
160
+ style?: React.CSSProperties;
200
161
  }
201
- declare const PaneContent: React__default.FC<PaneContentProps>;
162
+ declare const PaneContent: React.FC<PaneContentProps>;
202
163
  interface PaneProps {
203
164
  /** The unique ID of the pane, matching a `paneId` in the layout tree schema. */
204
165
  id: string;
205
166
  /** The children elements inside the pane (e.g. headers, tabs, content). */
206
- children: React__default.ReactNode;
167
+ children: React.ReactNode;
207
168
  /** Optional inline CSS styles applied to the pane outer container. */
208
- style?: React__default.CSSProperties;
169
+ style?: React.CSSProperties;
209
170
  /** Optional override to lock this specific pane. */
210
171
  locked?: boolean;
211
172
  }
212
- declare const Pane: React__default.FC<PaneProps> & {
173
+ declare const Pane: React.FC<PaneProps> & {
213
174
  Content: typeof PaneContent;
214
175
  DragHandle: typeof DragHandle;
215
176
  Tabs: typeof Tabs;
@@ -217,4 +178,4 @@ declare const Pane: React__default.FC<PaneProps> & {
217
178
  Controls: typeof PaneControls;
218
179
  };
219
180
 
220
- export { DEFAULT_DRAG_ACTIVATION_DISTANCE, DEFAULT_RESIZER_SIZE, DEFAULT_SNAP_THRESHOLD, type DragHandleProps, type DragSessionConfig, Pane, type PaneControlsProps, type PaneProps, type PaneRenderProps, PaneTree, PortalRegistryContext, PortalRegistryValue, SplitDirection, SplitNode, TabDetails, type TabsProps, TreeNode, UseZeugmaOptions, Zeugma, ZeugmaActionsContext, ZeugmaActionsValue, ZeugmaController, ZeugmaDragContext, ZeugmaDragStateValue, ZeugmaProps, ZeugmaStateContext, ZeugmaStateValue, createDragSession, safeJsonStringify, usePaneContext, useResizer, useZeugma, useZeugmaActions, useZeugmaContext, useZeugmaDrag, useZeugmaState };
181
+ export { type DragHandleProps, Pane, type PaneControlsProps, type PaneProps, type PaneRenderProps, PaneTree, SplitDirection, SplitNode, TabDetails, type TabsProps, TreeNode, UseZeugmaOptions, Zeugma, ZeugmaController, ZeugmaProps, ZeugmaProvider, ZeugmaProviderProps, usePaneContext, useResizer, useZeugma, useZeugmaContext };
package/dist/index.d.ts CHANGED
@@ -1,55 +1,16 @@
1
- import * as React from 'react';
2
- import React__default from 'react';
3
- import { P as PortalRegistryValue, Z as ZeugmaActionsValue, a as ZeugmaDragStateValue, b as ZeugmaStateValue, U as UseZeugmaOptions, c as ZeugmaController, d as ZeugmaProps, S as SplitDirection, T as TreeNode, e as SplitNode, f as TabDetails } from './types-B9LrYapR.js';
4
- export { D as DragOverlayActiveItem, g as PaneNode, h as ZeugmaActions, i as ZeugmaClassNames, j as ZeugmaControllerInternal, k as ZeugmaQueries, l as ZeugmaState, m as ZeugmaStateSetters } from './types-B9LrYapR.js';
5
-
6
- declare const DEFAULT_SNAP_THRESHOLD = 8;
7
- declare const DEFAULT_DRAG_ACTIVATION_DISTANCE = 8;
8
- declare const DEFAULT_RESIZER_SIZE = 4;
9
-
10
- /**
11
- * Shared drag-session lifecycle utility.
12
- *
13
- * Handles the common boilerplate for pointer-based resize operations:
14
- * - Adds `zeugma-resizing` class to `document.body`
15
- * - Injects a global `cursor` style so the resize cursor stays active
16
- * even when the pointer leaves the handle element
17
- * - Sets `data-resizing` on the resizer element
18
- * - Attaches `pointermove` / `pointerup` listeners to `document`
19
- * - Cleans everything up on pointer-up
20
- *
21
- * Consumers provide domain-specific `onMove` and `onEnd` callbacks.
22
- */
23
- interface DragSessionConfig {
24
- /** CSS cursor to enforce globally during the drag */
25
- cursor: 'col-resize' | 'row-resize';
26
- /** The resizer DOM element (receives `data-resizing` attribute) */
27
- resizerEl: HTMLElement;
28
- /** Called on every `pointermove` during the drag */
29
- onMove: (e: PointerEvent) => void;
30
- /** Called once on `pointerup` — after cleanup has already run */
31
- onEnd: () => void;
32
- }
33
- declare function createDragSession({ cursor, resizerEl, onMove, onEnd }: DragSessionConfig): void;
34
-
35
- declare function safeJsonStringify(val: unknown): string;
36
-
37
- declare const ZeugmaStateContext: React.Context<ZeugmaStateValue | undefined>;
38
- declare const ZeugmaActionsContext: React.Context<ZeugmaActionsValue | undefined>;
39
- declare const PortalRegistryContext: React.Context<PortalRegistryValue | undefined>;
40
- declare const ZeugmaDragContext: React.Context<ZeugmaDragStateValue | undefined>;
41
- declare const useZeugmaState: () => ZeugmaStateValue;
42
- declare const useZeugmaActions: () => ZeugmaActionsValue;
43
- declare const useZeugmaDrag: () => ZeugmaDragStateValue;
1
+ import { U as UseZeugmaOptions, Z as ZeugmaController, a as ZeugmaProps, b as ZeugmaProviderProps, S as SplitDirection, T as TreeNode, c as SplitNode, d as TabDetails } from './types-BN5W7EvY.js';
2
+ export { D as DragOverlayActiveItem, P as PaneNode, e as ZeugmaClassNames } from './types-BN5W7EvY.js';
3
+ import React from 'react';
44
4
 
45
5
  declare function useZeugma(options: UseZeugmaOptions): ZeugmaController;
46
6
 
47
7
  declare const useZeugmaContext: () => ZeugmaController;
48
8
 
49
- declare const Zeugma: React__default.FC<ZeugmaProps>;
9
+ declare const ZeugmaProvider: React.FC<ZeugmaProviderProps>;
10
+ declare const Zeugma: React.FC<ZeugmaProps>;
50
11
 
51
12
  interface UseResizerProps {
52
- containerRef: React__default.RefObject<HTMLDivElement | null>;
13
+ containerRef: React.RefObject<HTMLDivElement | null>;
53
14
  isRow: boolean;
54
15
  direction: SplitDirection;
55
16
  splitPercentage: number;
@@ -65,11 +26,11 @@ interface UseResizerProps {
65
26
  parentWidth: number;
66
27
  parentHeight: number;
67
28
  }
68
- declare function useResizer({ containerRef, isRow, direction, splitPercentage, resizerSize, snapThreshold, layout, currentNode, onLayoutChange, onResizeStart: localOnResizeStart, onResizeEnd: localOnResizeEnd, parentLeft, parentTop, parentWidth, parentHeight, }: UseResizerProps): (e: React__default.PointerEvent<HTMLDivElement>) => void;
29
+ declare function useResizer({ containerRef, isRow, direction, splitPercentage, resizerSize, snapThreshold, layout, currentNode, onLayoutChange, onResizeStart: localOnResizeStart, onResizeEnd: localOnResizeEnd, parentLeft, parentTop, parentWidth, parentHeight, }: UseResizerProps): (e: React.PointerEvent<HTMLDivElement>) => void;
69
30
 
70
31
  interface PaneTreeProps {
71
32
  /** Render function mapping unique pane nodes to React elements. Usually renders a <Pane> wrapper. */
72
- renderPane: (paneId: string) => React__default.ReactNode;
33
+ renderPane?: (paneId: string) => React.ReactNode;
73
34
  /** The layout subtree node to render. If not specified, defaults to the root layout tree from the Zeugma context. */
74
35
  tree?: TreeNode | null;
75
36
  /** Size/thickness of the split handle resizer bars in pixels (default 4). */
@@ -77,7 +38,7 @@ interface PaneTreeProps {
77
38
  /** Threshold distance in pixels to snap layout resizers to adjacent edges (default 8). */
78
39
  snapThreshold?: number;
79
40
  }
80
- declare const PaneTree: React__default.FC<PaneTreeProps>;
41
+ declare const PaneTree: React.FC<PaneTreeProps>;
81
42
 
82
43
  interface BaseLeafRenderProps {
83
44
  /** True if the leaf is actively being dragged. */
@@ -112,13 +73,13 @@ interface PaneRenderProps extends BaseLeafRenderProps {
112
73
 
113
74
  interface DragHandleProps {
114
75
  /** The children elements that will trigger dragging when held and dragged. */
115
- children?: React__default.ReactNode;
76
+ children?: React.ReactNode;
116
77
  /** Custom CSS class applied to the drag handle element. */
117
78
  className?: string;
118
79
  /** Optional inline CSS styles applied to the drag handle. */
119
- style?: React__default.CSSProperties;
80
+ style?: React.CSSProperties;
120
81
  }
121
- declare const DragHandle: React__default.FC<DragHandleProps>;
82
+ declare const DragHandle: React.FC<DragHandleProps>;
122
83
 
123
84
  interface TabRenderProps {
124
85
  isDragging: boolean;
@@ -130,13 +91,13 @@ interface TabProps {
130
91
  /** Whether dragging is locked on this tab. */
131
92
  locked?: boolean;
132
93
  /** Render prop child function. */
133
- children: (props: TabRenderProps) => React__default.ReactNode;
94
+ children: (props: TabRenderProps) => React.ReactNode;
134
95
  /** Custom CSS class applied to the tab wrapper. */
135
96
  className?: string;
136
97
  /** Custom inline CSS style applied to the tab wrapper. */
137
- style?: React__default.CSSProperties;
98
+ style?: React.CSSProperties;
138
99
  }
139
- declare const Tab: React__default.FC<TabProps>;
100
+ declare const Tab: React.FC<TabProps>;
140
101
 
141
102
  interface TabsProps {
142
103
  /** The list of tab IDs in this pane. */
@@ -160,7 +121,7 @@ interface TabsProps {
160
121
  metadata?: Record<string, unknown>;
161
122
  onSelect: () => void;
162
123
  onRemove: () => void;
163
- }) => React__default.ReactNode;
124
+ }) => React.ReactNode;
164
125
  /** Custom CSS classes for Tabs container and tab wrappers. */
165
126
  classNames?: {
166
127
  container?: string;
@@ -168,11 +129,11 @@ interface TabsProps {
168
129
  };
169
130
  /** Custom inline CSS styles for Tabs container and tab wrappers. */
170
131
  styles?: {
171
- container?: React__default.CSSProperties;
172
- tab?: React__default.CSSProperties | ((tabId: string) => React__default.CSSProperties);
132
+ container?: React.CSSProperties;
133
+ tab?: React.CSSProperties | ((tabId: string) => React.CSSProperties);
173
134
  };
174
135
  }
175
- declare const Tabs: React__default.FC<TabsProps> & {
136
+ declare const Tabs: React.FC<TabsProps> & {
176
137
  Tab: typeof Tab;
177
138
  };
178
139
 
@@ -180,11 +141,11 @@ interface PaneControlsProps {
180
141
  /** Custom CSS class applied to the controls container. */
181
142
  className?: string;
182
143
  /** Custom inline CSS style applied to the controls container. */
183
- style?: React__default.CSSProperties;
144
+ style?: React.CSSProperties;
184
145
  /** The children elements (e.g. close and fullscreen buttons) to render inside the controls container. */
185
- children?: React__default.ReactNode;
146
+ children?: React.ReactNode;
186
147
  }
187
- declare const PaneControls: React__default.FC<PaneControlsProps>;
148
+ declare const PaneControls: React.FC<PaneControlsProps>;
188
149
 
189
150
  interface PaneContextValue extends PaneRenderProps {
190
151
  id: string;
@@ -192,24 +153,24 @@ interface PaneContextValue extends PaneRenderProps {
192
153
  declare const usePaneContext: () => PaneContextValue;
193
154
  interface PaneContentProps {
194
155
  /** A render callback (tab) => ReactNode or static ReactNode content to render for the active tab. */
195
- children?: React__default.ReactNode | ((tab: TabDetails) => React__default.ReactNode);
156
+ children?: React.ReactNode | ((tab: TabDetails) => React.ReactNode);
196
157
  /** Custom CSS class applied to the tab content wrapper. */
197
158
  className?: string;
198
159
  /** Custom inline CSS style applied to the tab content wrapper. */
199
- style?: React__default.CSSProperties;
160
+ style?: React.CSSProperties;
200
161
  }
201
- declare const PaneContent: React__default.FC<PaneContentProps>;
162
+ declare const PaneContent: React.FC<PaneContentProps>;
202
163
  interface PaneProps {
203
164
  /** The unique ID of the pane, matching a `paneId` in the layout tree schema. */
204
165
  id: string;
205
166
  /** The children elements inside the pane (e.g. headers, tabs, content). */
206
- children: React__default.ReactNode;
167
+ children: React.ReactNode;
207
168
  /** Optional inline CSS styles applied to the pane outer container. */
208
- style?: React__default.CSSProperties;
169
+ style?: React.CSSProperties;
209
170
  /** Optional override to lock this specific pane. */
210
171
  locked?: boolean;
211
172
  }
212
- declare const Pane: React__default.FC<PaneProps> & {
173
+ declare const Pane: React.FC<PaneProps> & {
213
174
  Content: typeof PaneContent;
214
175
  DragHandle: typeof DragHandle;
215
176
  Tabs: typeof Tabs;
@@ -217,4 +178,4 @@ declare const Pane: React__default.FC<PaneProps> & {
217
178
  Controls: typeof PaneControls;
218
179
  };
219
180
 
220
- export { DEFAULT_DRAG_ACTIVATION_DISTANCE, DEFAULT_RESIZER_SIZE, DEFAULT_SNAP_THRESHOLD, type DragHandleProps, type DragSessionConfig, Pane, type PaneControlsProps, type PaneProps, type PaneRenderProps, PaneTree, PortalRegistryContext, PortalRegistryValue, SplitDirection, SplitNode, TabDetails, type TabsProps, TreeNode, UseZeugmaOptions, Zeugma, ZeugmaActionsContext, ZeugmaActionsValue, ZeugmaController, ZeugmaDragContext, ZeugmaDragStateValue, ZeugmaProps, ZeugmaStateContext, ZeugmaStateValue, createDragSession, safeJsonStringify, usePaneContext, useResizer, useZeugma, useZeugmaActions, useZeugmaContext, useZeugmaDrag, useZeugmaState };
181
+ export { type DragHandleProps, Pane, type PaneControlsProps, type PaneProps, type PaneRenderProps, PaneTree, SplitDirection, SplitNode, TabDetails, type TabsProps, TreeNode, UseZeugmaOptions, Zeugma, ZeugmaController, ZeugmaProps, ZeugmaProvider, ZeugmaProviderProps, usePaneContext, useResizer, useZeugma, useZeugmaContext };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import tn,{createContext,useState,useRef,useEffect,useCallback,useContext,useMemo}from'react';import {DndContext,useDraggable,useSensors,useSensor,pointerWithin,closestCenter,useDroppable,PointerSensor,TouchSensor}from'@dnd-kit/core';import {jsx,Fragment,jsxs}from'react/jsx-runtime';import {createPortal}from'react-dom';function ct(e){let t=useRef(null);return useEffect(()=>{if(!e){t.current=null;return}let n=r=>{t.current={x:r.clientX,y:r.clientY};},o=r=>{let l=r.touches[0]||r.changedTouches[0];l&&(t.current={x:l.clientX,y:l.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 ut(e){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]=useState({}),n=useRef({}),o=useRef(true);useEffect(()=>(o.current=true,()=>{o.current=false;}),[]);let r=useCallback((a,i)=>{o.current&&t(u=>{if(!i){if(!u[a])return u;let d={...u};return delete d[a],d}return u[a]===i?u:{...u,[a]:i}});},[]),l=useCallback((a,i)=>{n.current[a]=i;},[]);return {portalTargets:e,registerPortalTarget:r,registerRenderCallback:l,renderCallbacksRef:n}}function ce(){return "pane-"+Math.random().toString(36).substring(2,11)}function me(e,t){if(e===null)return null;if(e.type==="pane")return e.id===t?null:e;let n=me(e.first,t),o=me(e.second,t);return n===null?o:o===null?n:{...e,first:n,second:o}}function ue(e,t){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let r=e.tabs.filter(i=>i!==t);if(r.length===0)return null;let l=e.activeTabId;e.activeTabId===t&&(l=r[0]);let a={...e.tabsMetadata};return delete a[t],{...e,tabs:r,activeTabId:l,tabsMetadata:Object.keys(a).length>0?a:void 0}}return e}let n=ue(e.first,t),o=ue(e.second,t);return n===null?o:o===null?n:{...e,first:n,second:o}}function xe(e,t,n,o,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){let l=typeof r=="string"?{type:"pane",id:ce(),tabs:[r],activeTabId:r}:r,a=o==="left"||o==="top";return {type:"split",direction:n,first:a?l:e,second:a?e:l,splitPercentage:50}}return e}return {...e,first:xe(e.first,t,n,o,r)||e.first,second:xe(e.second,t,n,o,r)||e.second}}function Ot(e,t){if(e===null)return t;function n(o,r){return o.type==="pane"?{type:"split",direction:r==="row"?"column":"row",splitPercentage:50,first:o,second:t}:{...o,second:n(o.second,o.direction)}}return n(e,null)}function pt(e,t,n,o){if(e===null)return {type:"pane",id:ce(),tabs:[n],activeTabId:n,tabsMetadata:o?{[n]:o}:void 0};let r=t?j(e,t):null;if(r&&r.type==="pane"){let i=function(u){if(u.type==="pane"&&u.id===t){let d=[...u.tabs];d.includes(n)||d.push(n);let g=u.tabsMetadata;return o&&(g={...u.tabsMetadata,[n]:o}),{...u,tabs:d,activeTabId:n,tabsMetadata:g}}return u.type==="split"?{...u,first:i(u.first),second:i(u.second)}:u};return i(e)}let l={type:"pane",id:ce(),tabs:[n],activeTabId:n,tabsMetadata:o?{[n]:o}:void 0};return Ot(e,l)}function he(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:he(e.first,t,n)||e.first,second:he(e.second,t,n)||e.second}:e}function j(e,t){return e===null?null:e.type==="pane"?e.id===t?e:null:e.type==="split"?j(e.first,t)??j(e.second,t):null}function K(e,t){return e===null?null:e.type==="pane"?e.tabs.includes(t)?e:null:e.type==="split"?K(e.first,t)??K(e.second,t):null}function Xe(e,t){let n=K(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 Ye(e,t){return K(e,t)?.tabsMetadata?.[t]}function Je(e,t){let n=j(e,t);return n?.tabsMetadata?.[n.activeTabId]}function Ee(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let o=e.tabsMetadata||{},r=o[t],l=n(r),a={...o};return l===void 0?delete a[t]:a[t]=l,{...e,tabsMetadata:Object.keys(a).length>0?a:void 0}}return e}return e.type==="split"?{...e,first:Ee(e.first,t,n)??e.first,second:Ee(e.second,t,n)??e.second}:e}function Le(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.type==="split"?{...e,first:Le(e.first,t,n)??e.first,second:Le(e.second,t,n)??e.second}:e}function ye(e,t,n){return e===null?null:e.type==="pane"?e.id===t?e.activeTabId===n?e:{...e,activeTabId:n}:e:e.type==="split"?{...e,first:ye(e.first,t,n)??e.first,second:ye(e.second,t,n)??e.second}:e}function ft(e,t,n){if(e===null)return null;let r=K(e,t)?.tabsMetadata?.[t],l=ue(e,t);if(l===null)return {type:"pane",id:ce(),tabs:[t],activeTabId:t,tabsMetadata:r?{[t]:r}:void 0};function a(i){if(i.type==="pane"){if(i.id===n){let u=[...i.tabs];u.includes(t)||u.push(t);let d={...i.tabsMetadata};return r&&(d[t]=r),{...i,tabs:u,activeTabId:t,tabsMetadata:Object.keys(d).length>0?d:void 0}}return i}return i.type==="split"?{...i,first:a(i.first),second:a(i.second)}:i}return a(l)}function Me(e,t,n,o="before"){if(e===null)return null;let l=K(e,t)?.tabsMetadata?.[t],a=ue(e,t);if(a===null)return {type:"pane",id:ce(),tabs:[t],activeTabId:t,tabsMetadata:l?{[t]:l}:void 0};function i(u){if(u.type==="pane"){if(u.tabs.includes(n)){let g=[...u.tabs].filter(D=>D!==t),b=g.indexOf(n);b<0&&(b=0),o==="after"&&(b+=1),g.splice(b,0,t);let T={...u.tabsMetadata};return l&&(T[t]=l),{...u,tabs:g,activeTabId:t,tabsMetadata:Object.keys(T).length>0?T:void 0}}return u}return u.type==="split"?{...u,first:i(u.first),second:i(u.second)}:u}return i(a)}function pe(e,t=0,n=0,o=100,r=100,l="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:a,splitPercentage:i,first:u,second:d}=e,b={id:`splitter-${l}-${a}`,currentNode:e,direction:a,left:a==="row"?t+o*(i/100):t,top:a==="column"?n+r*(i/100):n,width:a==="row"?0:o,height:a==="column"?0:r,parentLeft:t,parentTop:n,parentWidth:o,parentHeight:r},T={panes:[],splitters:[]},D={panes:[],splitters:[]};if(a==="row"){let h=o*(i/100);T=pe(u,t,n,h,r,`${l}-L`),D=pe(d,t+h,n,o-h,r,`${l}-R`);}else {let h=r*(i/100);T=pe(u,t,n,o,h,`${l}-T`),D=pe(d,t,n+h,o,r-h,`${l}-B`);}return {panes:[...T.panes,...D.panes],splitters:[b,...T.splitters,...D.splitters]}}function gt(e,t,n,o){if(!(t==="tab"&&n&&e.includes(n))||!o)return -1;let a=e.indexOf(n);return o==="before"?a:a+1}function we(e){try{return JSON.stringify(e)}catch{return ""}}function Vt(e){let{initialLayout:t,layout:n,onChange:o,fullscreenPaneId:r,onFullscreenChange:l,locked:a=false}=e,[i,u]=useState(()=>n!==void 0?n:t??null),[d,g]=useState(()=>we(n!==void 0?n:null)),[b,T]=useState(r||null),[D,h]=useState(a),[A,L]=useState(null),[B,p]=useState(null),[C,H]=useState(null),[N,P]=useState(null),W=useRef(null),J=useCallback(s=>{W.current=s;},[]),O=useRef(i);O.current=i;let M=useRef(A);M.current=A;let ne=useRef(o);ne.current=o;let ee=useRef(l);ee.current=l;let _=useCallback(s=>{T(s),ee.current?.(s);},[]);if(useEffect(()=>{h(a);},[a]),useEffect(()=>{r!==void 0&&T(r);},[r]),n!==void 0){let s=we(n);s!==d&&(g(s),u(n));}let S=useCallback(s=>(...f)=>{let k=O.current,E=s(k,...f);we(k)!==we(E)&&(O.current=E,u(E),ne.current?.(E));},[]),y=useCallback(S((s,f)=>typeof f=="function"?f(s):f),[S]),F=y,x=useCallback(s=>{T(null),ee.current?.(null),L(null),p(null),H(null),P(null),y(s);},[y]),Z=useCallback(S((s,f)=>me(s,f)),[S]),w=useCallback(S((s,f,k,E)=>{let z=ue(s,f)??s;return pt(z,k,f,E)}),[S]),c=useCallback(S((s,f,k,E,z)=>{let ie=j(s,f)??K(s,f);if(!ie)return s;let re=j(s,z)??K(s,z)??{type:"pane",id:z,tabs:[z],activeTabId:z},fe=me(s,z);return xe(fe,ie.id,k,E,re)}),[S]),V=useCallback(S((s,f,k)=>he(s,f,k)),[S]),I=useCallback(S((s,f,k)=>Ee(s,f,k)),[S]),v=useCallback(S((s,f,k)=>{let E=j(s,f)??K(s,f);return E?Le(s,E.id,k):s}),[S]),q=useCallback(S((s,f,k)=>{let E=j(s,f)??K(s,f);return E?ye(s,E.id,k):s}),[S]),X=useCallback(S((s,f,k)=>{let E=j(s,k)??K(s,k);return E?ft(s,f,E.id):s}),[S]),U=useCallback(S((s,f,k,E)=>Me(s,f,k,E)),[S]),G=useCallback(S((s,f)=>ue(s,f)),[S]),Q=useCallback(s=>{let f=j(O.current,s);return !f&&M.current&&(f=j(M.current,s)),f},[]),m=useCallback(s=>{let f=K(O.current,s);return !f&&M.current&&(f=K(M.current,s)),f},[]),R=useCallback(s=>{let f=Xe(O.current,s);return !f&&M.current&&(f=Xe(M.current,s)),f},[]),$=useCallback(s=>{let f=Ye(O.current,s);return !f&&M.current&&(f=Ye(M.current,s)),f},[]),oe=useCallback(s=>{let f=Je(O.current,s);return !f&&M.current&&(f=Je(M.current,s)),f},[]);return {layout:i,setLayout:x,_internalSetLayout:F,layoutBeforeDrag:A,setLayoutBeforeDrag:L,fullscreenPaneId:b,setFullscreenPaneId:_,locked:D,setLocked:h,activeId:B,setActiveId:p,activeType:C,setActiveType:H,dismissIntentId:N,setDismissIntentId:P,containerRef:W,setContainerRef:J,removePane:Z,addTab:w,updateMetadata:I,updatePaneLock:v,selectTab:q,mergeTab:X,moveTab:U,removeTab:G,splitPane:c,updateSplitPercentage:V,findPaneById:Q,findPaneContainingTab:m,findTabById:R,getTabMetadata:$,getActiveTabMetadata:oe}}var ro=8,ao=8,so=4;function bt({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=`
1
+ import rn,{createContext,useState,useRef,useEffect,useCallback,useMemo,useContext}from'react';import {DndContext,useDraggable,useSensors,useSensor,pointerWithin,closestCenter,useDroppable,PointerSensor,TouchSensor}from'@dnd-kit/core';import {jsx,Fragment,jsxs}from'react/jsx-runtime';import {createPortal}from'react-dom';function ut(e){let t=useRef(null);return useEffect(()=>{if(!e){t.current=null;return}let n=o=>{t.current={x:o.clientX,y:o.clientY};},r=o=>{let i=o.touches[0]||o.changedTouches[0];i&&(t.current={x:i.clientX,y:i.clientY});};return window.addEventListener("pointermove",n,{passive:true}),window.addEventListener("touchmove",r,{passive:true}),()=>{window.removeEventListener("pointermove",n),window.removeEventListener("touchmove",r);}},[e]),t}function dt(e){useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function pt(){let[e,t]=useState({}),n=useRef({}),r=useRef(true);useEffect(()=>(r.current=true,()=>{r.current=false;}),[]);let o=useCallback((a,l)=>{r.current&&t(c=>{if(!l){if(!c[a])return c;let p={...c};return delete p[a],p}return c[a]===l?c:{...c,[a]:l}});},[]),i=useCallback((a,l)=>{n.current[a]=l;},[]);return {portalTargets:e,registerPortalTarget:o,registerRenderCallback:i,renderCallbacksRef:n}}function ue(){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),r=be(e.second,t);return n===null?r:r===null?n:{...e,first:n,second:r}}function pe(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 i=e.activeTabId;e.activeTabId===t&&(i=o[0]);let a={...e.tabsMetadata};return delete a[t],{...e,tabs:o,activeTabId:i,tabsMetadata:Object.keys(a).length>0?a:void 0}}return e}let n=pe(e.first,t),r=pe(e.second,t);return n===null?r:r===null?n:{...e,first:n,second:r}}function ye(e,t,n,r,o){if(e===null)return typeof o=="string"?{type:"pane",id:ue(),tabs:[o],activeTabId:o}:o;if(e.type==="pane"){if(e.id===t){let i=typeof o=="string"?{type:"pane",id:ue(),tabs:[o],activeTabId:o}:o,a=r==="left"||r==="top";return {type:"split",direction:n,first:a?i:e,second:a?e:i,splitPercentage:50}}return e}return {...e,first:ye(e.first,t,n,r,o)||e.first,second:ye(e.second,t,n,r,o)||e.second}}function Ut(e,t){if(e===null)return t;function n(r,o){return r.type==="pane"?{type:"split",direction:o==="row"?"column":"row",splitPercentage:50,first:r,second:t}:{...r,second:n(r.second,r.direction)}}return n(e,null)}function ft(e,t,n,r){if(e===null)return {type:"pane",id:ue(),tabs:[n],activeTabId:n,tabsMetadata:r?{[n]:r}:void 0};let o=t?Q(e,t):null;if(o&&o.type==="pane"){let l=function(c){if(c.type==="pane"&&c.id===t){let p=[...c.tabs];p.includes(n)||p.push(n);let g=c.tabsMetadata;return r&&(g={...c.tabsMetadata,[n]:r}),{...c,tabs:p,activeTabId:n,tabsMetadata:g}}return c.type==="split"?{...c,first:l(c.first),second:l(c.second)}:c};return l(e)}let i={type:"pane",id:ue(),tabs:[n],activeTabId:n,tabsMetadata:r?{[n]:r}:void 0};return Ut(e,i)}function he(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:he(e.first,t,n)||e.first,second:he(e.second,t,n)||e.second}:e}function Q(e,t){return e===null?null:e.type==="pane"?e.id===t?e:null:e.type==="split"?Q(e.first,t)??Q(e.second,t):null}function K(e,t){return e===null?null:e.type==="pane"?e.tabs.includes(t)?e:null:e.type==="split"?K(e.first,t)??K(e.second,t):null}function Je(e,t){let n=K(e,t);if(!n)return null;let r=n.tabs.indexOf(t);return {id:t,paneId:n.id,isActive:n.activeTabId===t,index:r,metadata:n.tabsMetadata?.[t]}}function _e(e,t){return K(e,t)?.tabsMetadata?.[t]}function Ge(e,t){let n=Q(e,t);return n?.tabsMetadata?.[n.activeTabId]}function Ee(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let r=e.tabsMetadata||{},o=r[t],i=n(o),a={...r};return i===void 0?delete a[t]:a[t]=i,{...e,tabsMetadata:Object.keys(a).length>0?a:void 0}}return e}return e.type==="split"?{...e,first:Ee(e.first,t,n)??e.first,second:Ee(e.second,t,n)??e.second}:e}function Me(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.id===t){if(n===false){let{locked:r,...o}=e;return o}return {...e,locked:n}}return e}return e.type==="split"?{...e,first:Me(e.first,t,n)??e.first,second:Me(e.second,t,n)??e.second}:e}function Re(e,t,n){return e===null?null:e.type==="pane"?e.id===t?e.activeTabId===n?e:{...e,activeTabId:n}:e:e.type==="split"?{...e,first:Re(e.first,t,n)??e.first,second:Re(e.second,t,n)??e.second}:e}function gt(e,t,n){if(e===null)return null;let o=K(e,t)?.tabsMetadata?.[t],i=pe(e,t);if(i===null)return {type:"pane",id:ue(),tabs:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function a(l){if(l.type==="pane"){if(l.id===n){let c=[...l.tabs];c.includes(t)||c.push(t);let p={...l.tabsMetadata};return o&&(p[t]=o),{...l,tabs:c,activeTabId:t,tabsMetadata:Object.keys(p).length>0?p:void 0}}return l}return l.type==="split"?{...l,first:a(l.first),second:a(l.second)}:l}return a(i)}function Ze(e,t,n,r="before"){if(e===null)return null;let i=K(e,t)?.tabsMetadata?.[t],a=pe(e,t);if(a===null)return {type:"pane",id:ue(),tabs:[t],activeTabId:t,tabsMetadata:i?{[t]:i}:void 0};function l(c){if(c.type==="pane"){if(c.tabs.includes(n)){let g=[...c.tabs].filter(N=>N!==t),v=g.indexOf(n);v<0&&(v=0),r==="after"&&(v+=1),g.splice(v,0,t);let D={...c.tabsMetadata};return i&&(D[t]=i),{...c,tabs:g,activeTabId:t,tabsMetadata:Object.keys(D).length>0?D:void 0}}return c}return c.type==="split"?{...c,first:l(c.first),second:l(c.second)}:c}return l(a)}function ge(e,t=0,n=0,r=100,o=100,i="root"){if(e===null)return {panes:[],splitters:[]};if(e.type==="pane")return {panes:[{paneId:e.id,left:t,top:n,width:r,height:o,node:e}],splitters:[]};let{direction:a,splitPercentage:l,first:c,second:p}=e,v={id:`splitter-${i}-${a}`,currentNode:e,direction:a,left:a==="row"?t+r*(l/100):t,top:a==="column"?n+o*(l/100):n,width:a==="row"?0:r,height:a==="column"?0:o,parentLeft:t,parentTop:n,parentWidth:r,parentHeight:o},D={panes:[],splitters:[]},N={panes:[],splitters:[]};if(a==="row"){let P=r*(l/100);D=ge(c,t,n,P,o,`${i}-L`),N=ge(p,t+P,n,r-P,o,`${i}-R`);}else {let P=o*(l/100);D=ge(c,t,n,r,P,`${i}-T`),N=ge(p,t,n+P,r,o-P,`${i}-B`);}return {panes:[...D.panes,...N.panes],splitters:[v,...D.splitters,...N.splitters]}}function mt(e,t,n,r){if(!(t==="tab"&&n&&e.includes(n))||!r)return -1;let a=e.indexOf(n);return r==="before"?a:a+1}function Ne(e){try{return JSON.stringify(e)}catch{return ""}}function Xt(e){let{initialLayout:t,layout:n,onChange:r,fullscreenPaneId:o,onFullscreenChange:i,locked:a=false}=e,[l,c]=useState(()=>n!==void 0?n:t??null),[p,g]=useState(()=>Ne(n!==void 0?n:null)),[v,D]=useState(o||null),[N,P]=useState(a),[z,I]=useState(null),[$,m]=useState(null),[B,U]=useState(null),[E,f]=useState(null),T=useRef(null),j=useCallback(s=>{T.current=s;},[]),L=useRef(l);L.current=l;let k=useRef(z);k.current=z;let q=useRef(r);q.current=r;let ee=useRef(i);ee.current=i;let J=useCallback(s=>{D(s),ee.current?.(s);},[]);if(useEffect(()=>{P(a);},[a]),useEffect(()=>{o!==void 0&&D(o);},[o]),n!==void 0){let s=Ne(n);s!==p&&(g(s),c(n));}let S=useCallback(s=>(...d)=>{let H=L.current,M=s(H,...d);Ne(H)!==Ne(M)&&(L.current=M,c(M),q.current?.(M));},[]),ie=useCallback(S((s,d)=>typeof d=="function"?d(s):d),[S]),Z=ie,x=useCallback(s=>{D(null),ee.current?.(null),I(null),m(null),U(null),f(null),ie(s);},[ie]),A=useCallback(S((s,d)=>be(s,d)),[S]),w=useCallback(S((s,d,H,M)=>{let G=pe(s,d)??s;return ft(G,H,d,M)}),[S]),R=useCallback(S((s,d,H,M,G)=>{let X=Q(s,d)??K(s,d);if(!X)return s;let le=Q(s,G)??K(s,G)??{type:"pane",id:G,tabs:[G],activeTabId:G},ne=be(s,G);return ye(ne,X.id,H,M,le)}),[S]),u=useCallback(S((s,d,H)=>he(s,d,H)),[S]),F=useCallback(S((s,d,H)=>Ee(s,d,H)),[S]),y=useCallback(S((s,d,H)=>{let M=Q(s,d)??K(s,d);return M?Me(s,M.id,H):s}),[S]),C=useCallback(S((s,d,H)=>{let M=Q(s,d)??K(s,d);return M?Re(s,M.id,H):s}),[S]),te=useCallback(S((s,d,H)=>{let M=Q(s,H)??K(s,H);return M?gt(s,d,M.id):s}),[S]),V=useCallback(S((s,d,H,M)=>Ze(s,d,H,M)),[S]),O=useCallback(S((s,d)=>pe(s,d)),[S]),W=useCallback(s=>{let d=Q(L.current,s);return !d&&k.current&&(d=Q(k.current,s)),d},[]),_=useCallback(s=>{let d=K(L.current,s);return !d&&k.current&&(d=K(k.current,s)),d},[]),b=useCallback(s=>{let d=Je(L.current,s);return !d&&k.current&&(d=Je(k.current,s)),d},[]),h=useCallback(s=>{let d=_e(L.current,s);return !d&&k.current&&(d=_e(k.current,s)),d},[]),re=useCallback(s=>{let d=Ge(L.current,s);return !d&&k.current&&(d=Ge(k.current,s)),d},[]);return {layout:l,setLayout:x,_internalSetLayout:Z,layoutBeforeDrag:z,setLayoutBeforeDrag:I,fullscreenPaneId:v,setFullscreenPaneId:J,locked:N,setLocked:P,activeId:$,setActiveId:m,activeType:B,setActiveType:U,dismissIntentId:E,setDismissIntentId:f,containerRef:T,setContainerRef:j,removePane:A,addTab:w,updateMetadata:F,updatePaneLock:y,selectTab:C,mergeTab:te,moveTab:V,removeTab:O,splitPane:R,updateSplitPercentage:u,findPaneById:W,findPaneContainingTab:_,findTabById:b,getTabMetadata:h,getActiveTabMetadata:re}}function vt({cursor:e,resizerEl:t,onMove:n,onEnd:r}){document.body.classList.add("zeugma-resizing");let o=document.createElement("style");o.id="zeugma-global-cursor-style",o.textContent=`
2
2
  * {
3
3
  cursor: ${e} !important;
4
4
  user-select: none !important;
5
5
  }
6
- `,document.head.appendChild(r),t.setAttribute("data-resizing","true");let l=i=>{n(i);},a=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let i=document.getElementById("zeugma-global-cursor-style");i&&i.remove(),document.removeEventListener("pointermove",l),document.removeEventListener("pointerup",a),o();};document.addEventListener("pointermove",l),document.addEventListener("pointerup",a);}var Ge=createContext(void 0),Ke=createContext(void 0),Ze=createContext(void 0),Qe=createContext(void 0),se=()=>{let e=useContext(Ge);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},$e=()=>{let e=useContext(Ke);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},Ae=()=>{let e=useContext(Qe);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};var Wt=()=>{let e=se(),t=$e();return {layout:e.layout,setLayout:e.setLayout,fullscreenPaneId:e.fullscreenPaneId,setFullscreenPaneId:t.setFullscreenPaneId,locked:e.locked,setLocked:t.setLocked,removePane:t.removePane,addTab:t.addTab,updateMetadata:t.updateMetadata,updatePaneLock:t.updatePaneLock,selectTab:t.selectTab,mergeTab:t.mergeTab,removeTab:t.removeTab,splitPane:t.splitPane,updateSplitPercentage:t.updateSplitPercentage,moveTab:t.moveTab,findPaneById:e.findPaneById,findPaneContainingTab:e.findPaneContainingTab,findTabById:e.findTabById,getTabMetadata:e.getTabMetadata,getActiveTabMetadata:e.getActiveTabMetadata}};var ze=class extends PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},Be=class extends TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};function He(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,_internalSetLayout:n,layoutBeforeDrag:o,setLayoutBeforeDrag:r,activeId:l,setActiveId:a,setActiveType:i,dismissIntentId:u,setDismissIntentId:d,setOverTabId:g,setOverTabPosition:b,containerRef:T,dragActivationDistance:D,enableDragToDismiss:h,dismissThreshold:A,onRemove:L,onDragStart:B,onDragEnd:p,onDismissIntentChange:C,removeTab:H}=e,N=useRef(null),P=ct(l),[W,J]=useState(false);ut(W);let O=useSensors(useSensor(ze,{activationConstraint:{distance:D}}),useSensor(Be,{activationConstraint:{delay:250,tolerance:5}})),M=useCallback(y=>{let x=y.active.id.toString().startsWith("tab-header-"),Z=pointerWithin(y),w=x?Z:Z.filter(c=>!c.id.toString().startsWith("tab-drop-"));if(w.length>0)return [...w].sort((V,I)=>{let v=V.id.toString(),q=I.id.toString();if(x){let G=v.startsWith("tab-drop-"),Q=q.startsWith("tab-drop-");if(G&&!Q)return -1;if(!G&&Q)return 1}let X=v.startsWith("drop-root-"),U=q.startsWith("drop-root-");return X&&!U?-1:!X&&U?1:0});if(x){let c=y.droppableContainers.filter(V=>V.id.toString().startsWith("tab-drop-"));return closestCenter({...y,droppableContainers:c})}return []},[]);return {sensors:O,collisionDetection:M,onDragStart:y=>{let F=y.active.id.toString(),x=F.startsWith("tab-header-"),Z=x?F.substring(11):F;a(Z),i(x?"tab":"pane"),g(null),b(null);let w=y.activatorEvent;P.current=He(w),h&&T.current?N.current=T.current.getBoundingClientRect():N.current=null;let c=t;if(x){let V=K(t,Z);V&&(c=ye(t,V.id,Z)||t);}r(c),x&&c!==t&&n(c),B&&B(Z);},onDragMove:y=>{let{over:F}=y,x=F?.id.toString()||"",Z=x.startsWith("drop-locked-");J(m=>m===Z?m:Z);let w=y.active.id.toString(),c=w.startsWith("tab-header-"),V=c?w.substring(11):w,I=x.match(/^tab-drop-(.+)$/);if(I&&F&&c){let[,m]=I;if(V!==m){let R="before",$=F.rect,oe=y.activatorEvent,te=null;if(P.current)te=P.current.x;else {let s=He(oe);s&&(te=s.x+y.delta.x);}if(te!==null){let s=$.left+$.width/2;te>s&&(R="after");}g(s=>s===m?s:m),b(s=>s===R?s:R);}else g(R=>R===null?R:null),b(R=>R===null?R:null);}else g(m=>m===null?m:null),b(m=>m===null?m:null);if(!h)return;let v=N.current;if(!v){u!==null&&(d(null),C?.(null));return}let q=y.activatorEvent,X=null,U=null;if(P.current)X=P.current.x,U=P.current.y;else {let m=He(q);m&&(X=m.x+y.delta.x,U=m.y+y.delta.y);}let G=0;if(X!==null&&U!==null){let m=0,R=0;X<v.left?m=v.left-X:X>v.right&&(m=X-v.right),U<v.top?R=v.top-U:U>v.bottom&&(R=U-v.bottom),G=Math.sqrt(m*m+R*R);}else {let m=y.active.rect.current.translated;if(m){let R=m.left+m.width/2,$=m.top+m.height/2,oe=0,te=0;R<v.left?oe=v.left-R:R>v.right&&(oe=R-v.right),$<v.top?te=v.top-$:$>v.bottom&&(te=$-v.bottom),G=Math.sqrt(oe*oe+te*te);}}G>A?u!==V&&(d(V),C?.(V)):u!==null&&(d(null),C?.(null));},onDragEnd:y=>{a(null),i(null),J(false),g(null),b(null);let{active:F,over:x}=y,Z=F.id.toString(),w=Z.startsWith("tab-header-"),c=w?Z.substring(11):Z,V=h&&u===c;d(null),C?.(null),N.current=null;let I=o||t;if(r(null),V){L?L(c):H(c),p&&p(c,null,null);return}if(!x){n(I),p&&p(c,null,null);return}let v=x.id.toString();if(v.startsWith("drop-locked-")){n(I),p&&p(c,null,null);return}let q=v.match(/^tab-drop-(.+)$/);if(q){if(!w){n(I),p&&p(c,null,null);return}let[,k]=q;if(c!==k){let E="before",z=x.rect,ie=y.activatorEvent,re=null;if(P.current)re=P.current.x;else {let ae=He(ie);ae&&(re=ae.x+y.delta.x);}if(re!==null){let ae=z.left+z.width/2;re>ae&&(E="after");}let fe=Me(I,c,k,E);n(fe),p&&p(c,k,{type:"move",position:"center"});}else n(I),p&&p(c,null,null);return}let X=v.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(X){let[,k,E]=X,z=E;z==="start"&&(z="left"),z==="end"&&(z="right");let ie=w?ue(I,c):me(I,c),re;if(w){let ae=K(I,c)?.tabsMetadata?.[c];re={type:"pane",id:ce(),tabs:[c],activeTabId:c,tabsMetadata:ae?{[c]:ae}:void 0};}else re=j(I,c)??{type:"pane",id:ce(),tabs:[c],activeTabId:c};if(ie===null)n(re);else {let fe=z==="left"||z==="right",ae=z==="left"||z==="top",Se=50;k==="1/4"?Se=ae?25:75:k==="1/3"&&(Se=ae?100/3:200/3),n({type:"split",direction:fe?"row":"column",first:ae?re:ie,second:ae?ie:re,splitPercentage:Se});}p&&p(c,"root",{type:"split",direction:z==="left"||z==="right"?"row":"column",position:z});return}let U=v.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!U){n(I),p&&p(c,null,null);return}let[,G,Q]=U,m=w?K(I,c):j(I,c),R=m&&m.id===Q,$=m&&m.tabs.length===1;if(c===Q||R&&$){n(I),p&&p(c,null,null);return}let oe=G==="left"||G==="right"?"row":"column",te;if(w){let E=K(I,c)?.tabsMetadata?.[c];te={type:"pane",id:ce(),tabs:[c],activeTabId:c,tabsMetadata:E?{[c]:E}:void 0};}else te=j(I,c)??{type:"pane",id:ce(),tabs:[c],activeTabId:c};let s=w?ue(I,c):me(I,c),f=xe(s,Q,oe,G,te);n(f),p&&p(c,Q,{type:"split",direction:oe,position:G});},onDragCancel:()=>{a(null),i(null),J(false),g(null),b(null),d(null),C?.(null),N.current=null,o!==null&&(n(o),r(null));}}}var Tt=({activeId:e,render:t,className:n})=>{let o=useRef(null);return useEffect(()=>{let r=l=>{o.current&&(o.current.style.transform=`translate(${l.clientX+12}px, ${l.clientY+12}px)`);};return document.addEventListener("pointermove",r),()=>document.removeEventListener("pointermove",r)},[]),jsx("div",{ref:o,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var Pt=tn.memo(({tabDetails:e,target:t,renderWidget:n})=>{let{id:o}=e,[r,l]=useState(false),a=useRef(null);if(useEffect(()=>{l(true);},[]),useEffect(()=>{if(!r||!a.current)return;let u=a.current;if(t)t.appendChild(u);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(u);}},[t,r]),useEffect(()=>()=>{a.current&&a.current.remove();},[]),!r)return null;a.current||(a.current=document.createElement("div"),a.current.className=`zeugma-portal-wrapper-${o}`,a.current.style.width="100%",a.current.style.height="100%");let i=a.current;return !i||!n?null:createPortal(n(e),i)},(e,t)=>e.target===t.target&&e.renderWidget===t.renderWidget&&e.tabDetails.id===t.tabDetails.id&&e.tabDetails.paneId===t.tabDetails.paneId&&e.tabDetails.isActive===t.tabDetails.isActive&&e.tabDetails.index===t.tabDetails.index&&e.tabDetails.metadata===t.tabDetails.metadata);function et({containerRef:e,isRow:t,direction:n,splitPercentage:o,resizerSize:r,snapThreshold:l,layout:a,currentNode:i,onLayoutChange:u,onResizeStart:d,onResizeEnd:g,parentLeft:b,parentTop:T,parentWidth:D,parentHeight:h}){let{onResizeStart:A,onResize:L,onResizeEnd:B,minSplitPercentage:p=5,maxSplitPercentage:C=95,locked:H=false}=se();return useCallback(N=>{if(H)return;N.preventDefault();let P=e.current;if(!P)return;d&&d(),A&&A(i);let W=P.getBoundingClientRect(),J=N.clientX,O=N.clientY,M=o,ne=N.currentTarget,ee=W.left+W.width*(b/100),_=W.top+W.height*(T/100),S=W.width*(D/100),y=W.height*(h/100),x=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(w=>w!==ne&&w.getAttribute("data-direction")===n).map(w=>{let c=w.getBoundingClientRect();return t?c.left+c.width/2:c.top+c.height/2}),Z=M;bt({cursor:t?"col-resize":"row-resize",resizerEl:ne,onMove:w=>{let c=t?(w.clientX-J)/S*100:(w.clientY-O)/y*100,V=M+c,I=t?ee+(S-r)*(V/100)+r/2:_+(y-r)*(V/100)+r/2,v=1/0,q=null;for(let Q of x){let m=Math.abs(I-Q);m<l&&m<v&&(v=m,q=Q);}let X=V;q!==null&&(X=t?(q-r/2-ee)/(S-r)*100:(q-r/2-_)/(y-r)*100);let U=Math.max(p,Math.min(C,X));Z=U;let G=he(a,i,U);if(G){let{panes:Q,splitters:m}=pe(G),R=e.current;if(R){for(let $ of Q)R.style.setProperty(`--pane-left-${$.paneId}`,`${$.left}%`),R.style.setProperty(`--pane-top-${$.paneId}`,`${$.top}%`),R.style.setProperty(`--pane-width-${$.paneId}`,`${$.width}%`),R.style.setProperty(`--pane-height-${$.paneId}`,`${$.height}%`);for(let $ of m)R.style.setProperty(`--splitter-pos-${$.id}`,`${$.direction==="row"?$.left:$.top}%`);}}L&&L(i,U);},onEnd:()=>{let w=he(a,i,Z),c=e.current;if(c){let{panes:V,splitters:I}=pe(w);for(let v of V)c.style.removeProperty(`--pane-left-${v.paneId}`),c.style.removeProperty(`--pane-top-${v.paneId}`),c.style.removeProperty(`--pane-width-${v.paneId}`),c.style.removeProperty(`--pane-height-${v.paneId}`);for(let v of I)c.style.removeProperty(`--splitter-pos-${v.id}`);}u(w),g&&g(),B&&B(i,Z);}});},[e,t,n,o,r,l,a,i,u,d,g,A,L,B,p,C,b,T,D,h])}var dn=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:o})=>{let{layout:r,setLayout:l,classNames:a,locked:i}=se(),[u,d]=useState(false),{currentNode:g,direction:b,left:T,top:D,width:h,height:A,parentLeft:L,parentTop:B,parentWidth:p,parentHeight:C}=e,H=b==="row",N=et({containerRef:o,isRow:H,direction:b,splitPercentage:g.splitPercentage,resizerSize:t,snapThreshold:n,layout:r,currentNode:g,onLayoutChange:l,onResizeStart:()=>d(true),onResizeEnd:()=>d(false),parentLeft:L,parentTop:B,parentWidth:p,parentHeight:C}),P=H?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${T}%) - ${t/2}px)`,top:`calc(${D}% + ${t/2}px)`,width:`${t}px`,height:`calc(${A}% - ${t}px)`,cursor:i?"default":"col-resize",pointerEvents:i?"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}, ${D}%) - ${t/2}px)`,width:`calc(${h}% - ${t}px)`,height:`${t}px`,cursor:i?"default":"row-resize",pointerEvents:i?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsx("div",{className:a.resizer||"","data-direction":b,"data-resizing":u||void 0,style:P,onPointerDown:N,role:"separator","aria-valuenow":g.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},pn=tn.memo(({paneId:e,renderPane:t})=>jsx(Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane),tt=({renderPane:e,tree:t,resizerSize:n=4,snapThreshold:o})=>{let{layout:r,activeId:l,dismissIntentId:a,setContainerRef:i,fullscreenPaneId:u,snapThreshold:d,locked:g,classNames:b}=se(),T=o!==void 0?o:d??8,D=t!==void 0?t:r,h=useRef(null),{panes:A,splitters:L}=useMemo(()=>D?pe(D):{panes:[],splitters:[]},[D]);if(!D)return null;let B=()=>jsxs(Fragment,{children:[A.map(p=>{let C=u===p.paneId;return jsx("div",{style:{position:"absolute",left:C?"0%":`var(--pane-left-${p.paneId}, ${p.left}%)`,top:C?"0%":`var(--pane-top-${p.paneId}, ${p.top}%)`,width:C?"100%":`var(--pane-width-${p.paneId}, ${p.width}%)`,height:C?"100%":`var(--pane-height-${p.paneId}, ${p.height}%)`,overflow:"hidden",zIndex:C?20:1,display:u&&!C?"none":"block",padding:C?"0px":`${n/2}px`,boxSizing:"border-box"},children:jsx(pn,{paneId:p.paneId,renderPane:e})},p.paneId)}),!u&&L.map(p=>jsx(dn,{splitter:p,resizerSize:n,snapThreshold:T,containerRef:h},p.id))]});if(t===void 0){let p=l!==null&&l===a,C=N=>{i(N),h.current=N;},H=`${b.dashboard||""} ${p&&b.dashboardDismissActive||""} ${g&&b.dashboardLocked||""}`.trim();return jsxs("div",{ref:C,className:H,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[B(),l!==null&&!g&&jsx(Rt,{activeClassName:b.rootDropPreview??b.dropPreview})]})}return jsx("div",{ref:h,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:B()})};var mn=e=>{let{controller:t,renderDragOverlay:n,classNames:o={},renderPane:r,resizerSize:l,dragActivationDistance:a=8,snapThreshold:i=8,minSplitPercentage:u=5,maxSplitPercentage:d=95,enableDragToDismiss:g=false,dismissThreshold:b=60,onRemove:T,onDragStart:D,onDragEnd:h,onResizeStart:A,onResize:L,onResizeEnd:B,onDismissIntentChange:p}=e,C=t,{layout:H,setLayout:N,_internalSetLayout:P,fullscreenPaneId:W,setFullscreenPaneId:J,locked:O,setLocked:M,findPaneById:ne,findPaneContainingTab:ee,findTabById:_,getTabMetadata:S,getActiveTabMetadata:y,activeId:F,setActiveId:x,activeType:Z,setActiveType:w,dismissIntentId:c,setDismissIntentId:V,containerRef:I,setContainerRef:v,layoutBeforeDrag:q,setLayoutBeforeDrag:X,removePane:U,addTab:G,updateMetadata:Q,updatePaneLock:m,selectTab:R,mergeTab:$,removeTab:oe,splitPane:te,updateSplitPercentage:s,moveTab:f}=C,{portalTargets:k,registerPortalTarget:E,registerRenderCallback:z,renderCallbacksRef:ie}=dt(),[re,fe]=useState(null),[ae,Se]=useState(null),at=ht({layout:H,_internalSetLayout:P,layoutBeforeDrag:q,setLayoutBeforeDrag:X,activeId:F,setActiveId:x,setActiveType:w,dismissIntentId:c,setDismissIntentId:V,setOverTabId:fe,setOverTabPosition:Se,containerRef:I,dragActivationDistance:a,enableDragToDismiss:g,dismissThreshold:b,onRemove:T,onDragStart:D,onDragEnd:h,onDismissIntentChange:p,removeTab:oe}),st=useMemo(()=>o,[o.dashboard,o.dashboardDismissActive,o.pane,o.paneLocked,o.dropPreview,o.rootDropPreview,o.dragOverlay,o.resizer,o.dismissPreview,o.dashboardLocked,o.lockedPreview,o.tabDropPreview,o.tabSeparator,o.tabsContainer,o.tab,o.paneContainer,o.paneHeader,o.paneControls,o.paneButton,o.tabCloseButton,o.dragHandle]),it=useCallback((le,ge)=>{B&&B(le,ge);},[B]),Zt=useMemo(()=>({layout:H,setLayout:N,activeId:F,activeType:Z,dismissIntentId:c,setContainerRef:v,fullscreenPaneId:W,classNames:st,onRemove:T,onFullscreenChange:J,snapThreshold:i,onResizeStart:A,onResize:L,onResizeEnd:it,minSplitPercentage:u,maxSplitPercentage:d,locked:O,setLocked:M,findPaneById:ne,findPaneContainingTab:ee,findTabById:_,getTabMetadata:S,getActiveTabMetadata:y,renderPane:r}),[H,F,Z,c,v,W,st,T,J,i,A,L,u,d,N,it,O,M,ne,ee,_,S,y,r]),$t=useMemo(()=>({overTabId:re,overTabPosition:ae}),[re,ae]),At=useMemo(()=>({removePane:U,addTab:G,updateMetadata:Q,updatePaneLock:m,selectTab:R,mergeTab:$,removeTab:oe,setFullscreenPaneId:J,setLocked:M,splitPane:te,updateSplitPercentage:s,moveTab:f}),[U,G,Q,m,R,$,oe,J,M,te,s,f]),zt=useMemo(()=>{let le=new Set;function ge(de){de&&(de.type==="pane"?de.tabs.forEach(Ht=>{le.add(Ht);}):de.type==="split"&&(ge(de.first),ge(de.second)));}return ge(H),q&&ge(q),Array.from(le).sort()},[H,F,q]),Bt=useMemo(()=>({registerPortalTarget:E,registerRenderCallback:z,renderCallbacksRef:ie}),[E,z,ie]);return jsx(Ke.Provider,{value:At,children:jsx(Ge.Provider,{value:Zt,children:jsx(Qe.Provider,{value:$t,children:jsxs(Ze.Provider,{value:Bt,children:[jsx(DndContext,{id:"zeugma-dnd-context",...at,children:jsx(tt,{renderPane:r,resizerSize:l,snapThreshold:i})}),F&&Z&&n&&jsx(Tt,{activeId:F,render:le=>n({type:Z,id:le,isDismissing:F===c}),className:`${o.dragOverlay||""} ${F===c&&o.dismissPreview||""}`.trim()}),jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:zt.map(le=>{let ge=k[le],de=_(le);return de?jsx(Pt,{tabDetails:de,target:ge||null,renderWidget:ie.current[le]},le):null})})]})})})})};var hn={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"}}},Tn={top:{"1/4":{top:0,left:0,width:"100%",height:"60px",borderBottomLeftRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderTopRightRadius:"0px"},"1/3":{top:0,left:0,width:"100%",height:"96px",borderBottomLeftRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderTopRightRadius:"0px"}},bottom:{"1/4":{bottom:0,left:0,width:"100%",height:"60px",borderTopLeftRadius:"12px",borderTopRightRadius:"12px",borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},"1/3":{bottom:0,left:0,width:"100%",height:"96px",borderTopLeftRadius:"12px",borderTopRightRadius:"12px",borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"}},left:{"1/4":{left:0,top:0,width:"60px",height:"100%",borderTopRightRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"},"1/3":{left:0,top:0,width:"96px",height:"100%",borderTopRightRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"}},right:{"1/4":{right:0,top:0,width:"60px",height:"100%",borderTopLeftRadius:"12px",borderBottomLeftRadius:"12px",borderTopRightRadius:"0px",borderBottomRightRadius:"0px"},"1/3":{right:0,top:0,width:"96px",height:"100%",borderTopLeftRadius:"12px",borderBottomLeftRadius:"12px",borderTopRightRadius:"0px",borderBottomRightRadius:"0px"}}},Pn=({id:e,fraction:t,edge:n,activeClassName:o})=>{let{setNodeRef:r,isOver:l}=useDroppable({id:e}),a={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...Tn[n][t]};return jsxs(Fragment,{children:[jsx("div",{ref:r,style:hn[n][t]}),l&&jsx("div",{className:o,style:a})]})},Rt=({activeClassName:e})=>jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:99,pointerEvents:"none"},children:[{id:"drop-root-1/4-top",fraction:"1/4",edge:"top"},{id:"drop-root-1/3-top",fraction:"1/3",edge:"top"},{id:"drop-root-1/4-bottom",fraction:"1/4",edge:"bottom"},{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=>jsx(Pn,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});var Oe=createContext(null);var Cn={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"}},Sn={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"}},nt=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:o,isOver:r}=useDroppable({id:e});return jsxs(Fragment,{children:[jsx("div",{ref:o,style:Cn[t]}),r&&jsx("div",{className:n,style:Sn[t]})]})};var St=({children:e,className:t,style:n})=>{let o=useContext(Oe);if(!o)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:r,...l}=o;return jsx("div",{className:t,style:{cursor:r?"default":"grab",userSelect:r?"auto":"none",touchAction:r?"auto":"none",...n},...r?{}:l,children:e})};var An=createContext(void 0);var Ie=({id:e,locked:t=false,children:n,className:o,style:r})=>{let{locked:l,classNames:a={},activeType:i}=se(),{overTabId:u}=Ae(),d=useContext(ot),g=t||l||(d?.locked??false),{attributes:b,listeners:T,setNodeRef:D,isDragging:h}=useDraggable({id:`tab-header-${e}`,disabled:g}),{setNodeRef:A,isOver:L}=useDroppable({id:`tab-drop-${e}`,disabled:g||i==="pane"}),B=_=>{D(_),A(_);},p=L&&u===e,C=d?.tabs||[],H=C.indexOf(e),N=d?.activeTabId,W=H>0&&e!==N&&C[H-1]!==N?jsx("div",{className:a.tabSeparator}):null,J=d?d.activeTabId===e:false,O=d?.tabsMetadata?.[e],M=useCallback(()=>{d?.selectTab(e);},[d,e]),ne=useCallback(()=>{d?.removeTab(e);},[d,e]),ee=useMemo(()=>({tabId:e,isActive:J,isDragging:h,isOver:p,metadata:O,locked:g,selectTab:M,removeTab:ne}),[e,J,h,p,O,g,M,ne]);return jsx(An.Provider,{value:ee,children:jsxs("div",{ref:B,className:o,style:{display:"inline-flex",position:"relative",cursor:g?"default":"grab",...r},...g?{}:T,...g?{}:b,children:[W,n({isDragging:h,isOver:p})]})})};var ot=createContext(void 0);var It=(e,t)=>typeof e=="function"?e(t):e,rt=({tabs:e,activeTabId:t,locked:n,tabsMetadata:o,selectTab:r,removeTab:l,renderTab:a,classNames:i,styles:u})=>{let d=useContext(Ve),g=e??d?.tabs??[],b=t??d?.activeTabId??"",T=n??d?.locked??false,D=o??d?.tabsMetadata,h=r??d?.selectTab??(()=>{}),A=l??d?.removeTab??(()=>{}),{classNames:L={},activeType:B}=se(),{overTabId:p,overTabPosition:C}=Ae(),H=useMemo(()=>({tabs:g,activeTabId:b,locked:T,tabsMetadata:D,selectTab:h,removeTab:A}),[g,b,T,D,h,A]),N=gt(g,B,p,C);return jsx(ot.Provider,{value:H,children:jsxs("div",{className:i?.container,style:{display:"flex",alignItems:"center",height:"100%",...u?.container},children:[g.map((P,W)=>{let J=D?.[P],O=It(i?.tab,P),M=It(u?.tab,P),ne=W===N;return jsxs(tn.Fragment,{children:[ne&&L.tabDropPreview&&jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsx("div",{className:L.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:W===0?"none":"translateX(-50%)"}})}),jsx(Ie,{id:P,locked:T,className:O,style:M,children:({isDragging:ee,isOver:_})=>a({tabId:P,activeTabId:b,isDragging:ee,isOver:_,metadata:J,onSelect:()=>h(P),onRemove:()=>A(P)})})]},P)}),N===g.length&&L.tabDropPreview&&jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsx("div",{className:L.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:"translateX(-100%)"}})})]})})};rt.Tab=Ie;var Lt=({className:e,style:t,children:n})=>jsx("div",{className:e,style:t,children:n});var Ve=createContext(void 0),kt=()=>{let e=useContext(Ve);if(!e)throw new Error("usePaneContext must be used within a Pane component");return e},Yn=({children:e,className:t,style:n})=>{let{activeTabId:o}=kt(),{classNames:r}=se(),l=useRef(null),a=useContext(Ze);if(!a)throw new Error("PaneContent must be used within a Zeugma provider");let{registerPortalTarget:i,registerRenderCallback:u}=a,d=useMemo(()=>typeof e=="function"?e:()=>e,[e]);return u(o,d),useEffect(()=>{let g=l.current;return i(o,g),()=>{i(o,null);}},[o,i]),jsx("div",{ref:l,id:`zeugma-tab-target-${o}`,className:`${r.tabContentWrapper||""} ${t||""}`.trim(),style:{height:"100%",width:"100%",...n}})},Ce=({id:e,children:t,style:n,locked:o=false})=>{let{layout:r,activeId:l,classNames:a,fullscreenPaneId:i,onFullscreenChange:u,locked:d}=se(),{removePane:g,updateMetadata:b,selectTab:T,removeTab:D}=$e(),h=useMemo(()=>j(r,e),[r,e]),A=h?.id??e,L=h?.tabs??[e],B=h?.activeTabId??e,p=h?.tabsMetadata,C=p?.[e],H=h?.locked??false,N=o||H,P=d||N,W=d||N,J=l!==null&&l!==e&&(!L.includes(l)||L.length>1)&&!W,{attributes:O,listeners:M,setNodeRef:ne}=useDraggable({id:e,disabled:P}),ee=l!==null&&L.includes(l),_=i===e,S=useMemo(()=>({isDragging:ee,isFullscreen:_,toggleFullscreen:()=>u?.(_?null:e),remove:()=>{_&&u?.(null),g(A);},metadata:C,updateMetadata:x=>{b(e,x);},locked:P,tabs:L,activeTabId:B,selectTab:x=>T(A,x),removeTab:x=>{_&&x===B&&u?.(null),D(x);},tabsMetadata:p,updateTabMetadata:(x,Z)=>{b(x,Z);}}),[ee,_,u,e,D,C,b,P,L,B,T,A,p]),y=useMemo(()=>P?{disabled:true}:{...M,...O},[M,O,P]),F=`${a.pane||""} ${N&&a.paneLocked||""}`.trim();return jsx(Ve.Provider,{value:{id:e,...S},children:jsx(Oe.Provider,{value:y,children:jsxs("div",{ref:ne,className:F,style:{position:"relative",width:"100%",height:"100%",...n},children:[t,J&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(x=>jsx(nt,{id:`drop-${x}-${e}`,position:x,activeClassName:a.dropPreview},x))}),l!==null&&l!==e&&W&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsx(nt,{id:`drop-locked-${e}`,position:"full",activeClassName:a.lockedPreview||""})})]})})})};Ce.Content=Yn;Ce.DragHandle=St;Ce.Tabs=rt;Ce.Tab=Ie;Ce.Controls=Lt;export{ao as DEFAULT_DRAG_ACTIVATION_DISTANCE,so as DEFAULT_RESIZER_SIZE,ro as DEFAULT_SNAP_THRESHOLD,Ce as Pane,tt as PaneTree,Ze as PortalRegistryContext,mn as Zeugma,Ke as ZeugmaActionsContext,Qe as ZeugmaDragContext,Ge as ZeugmaStateContext,bt as createDragSession,we as safeJsonStringify,kt as usePaneContext,et as useResizer,Vt as useZeugma,$e as useZeugmaActions,Wt as useZeugmaContext,Ae as useZeugmaDrag,se as useZeugmaState};//# sourceMappingURL=index.js.map
6
+ `,document.head.appendChild(o),t.setAttribute("data-resizing","true");let i=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",i),document.removeEventListener("pointerup",a),r();};document.addEventListener("pointermove",i),document.addEventListener("pointerup",a);}var ze=createContext(void 0),Qe=createContext(void 0),$e=createContext(void 0),je=createContext(void 0),se=()=>{let e=useContext(ze);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},Ae=()=>{let e=useContext(Qe);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},Be=()=>{let e=useContext(je);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};var Yt=()=>{let e=se(),t=Ae();return {layout:e.layout,setLayout:e.setLayout,fullscreenPaneId:e.fullscreenPaneId,setFullscreenPaneId:t.setFullscreenPaneId,locked:e.locked,setLocked:t.setLocked,removePane:t.removePane,addTab:t.addTab,updateMetadata:t.updateMetadata,updatePaneLock:t.updatePaneLock,selectTab:t.selectTab,mergeTab:t.mergeTab,removeTab:t.removeTab,splitPane:t.splitPane,updateSplitPercentage:t.updateSplitPercentage,moveTab:t.moveTab,findPaneById:e.findPaneById,findPaneContainingTab:e.findPaneContainingTab,findTabById:e.findTabById,getTabMetadata:e.getTabMetadata,getActiveTabMetadata:e.getActiveTabMetadata}};var He=class extends PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},Oe=class extends 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 Tt(e){let{layout:t,_internalSetLayout:n,layoutBeforeDrag:r,setLayoutBeforeDrag:o,activeId:i,setActiveId:a,setActiveType:l,dismissIntentId:c,setDismissIntentId:p,setOverTabId:g,setOverTabPosition:v,containerRef:D,dragActivationDistance:N,enableDragToDismiss:P,dismissThreshold:z,onRemove:I,onDragStart:$,onDragEnd:m,onDismissIntentChange:B,removeTab:U,removePane:E}=e,f=useRef(null),T=ut(i),[j,L]=useState(false);dt(j);let k=useSensors(useSensor(He,{activationConstraint:{distance:N}}),useSensor(Oe,{activationConstraint:{delay:250,tolerance:5}})),q=useCallback(Z=>{let A=Z.active.id.toString().startsWith("tab-header-"),w=pointerWithin(Z),R=A?w:w.filter(u=>!u.id.toString().startsWith("tab-drop-"));if(R.length>0)return [...R].sort((F,y)=>{let C=F.id.toString(),te=y.id.toString();if(A){let W=C.startsWith("tab-drop-"),_=te.startsWith("tab-drop-");if(W&&!_)return -1;if(!W&&_)return 1}let V=C.startsWith("drop-root-"),O=te.startsWith("drop-root-");return V&&!O?-1:!V&&O?1:0});if(A){let u=Z.droppableContainers.filter(F=>F.id.toString().startsWith("tab-drop-"));return closestCenter({...Z,droppableContainers:u})}return []},[]);return {sensors:k,collisionDetection:q,onDragStart:Z=>{let x=Z.active.id.toString(),A=x.startsWith("tab-header-"),w=A?x.substring(11):x;a(w),l(A?"tab":"pane"),g(null),v(null);let R=Z.activatorEvent;T.current=Fe(R),P&&D.current?f.current=D.current.getBoundingClientRect():f.current=null;let u=t;if(A){let F=K(t,w);F&&(u=Re(t,F.id,w)||t);}o(u),A&&u!==t&&n(u),$&&$(w);},onDragMove:Z=>{let{over:x}=Z,A=x?.id.toString()||"",w=A.startsWith("drop-locked-");L(b=>b===w?b:w);let R=Z.active.id.toString(),u=R.startsWith("tab-header-"),F=u?R.substring(11):R,y=A.match(/^tab-drop-(.+)$/);if(y&&x&&u){let[,b]=y;if(F!==b){let h="before",re=x.rect,ae=Z.activatorEvent,s=null;if(T.current)s=T.current.x;else {let d=Fe(ae);d&&(s=d.x+Z.delta.x);}if(s!==null){let d=re.left+re.width/2;s>d&&(h="after");}g(d=>d===b?d:b),v(d=>d===h?d:h);}else g(h=>h===null?h:null),v(h=>h===null?h:null);}else g(b=>b===null?b:null),v(b=>b===null?b:null);if(!P)return;let C=f.current;if(!C){c!==null&&(p(null),B?.(null));return}let te=Z.activatorEvent,V=null,O=null;if(T.current)V=T.current.x,O=T.current.y;else {let b=Fe(te);b&&(V=b.x+Z.delta.x,O=b.y+Z.delta.y);}let W=0;if(V!==null&&O!==null){let b=0,h=0;V<C.left?b=C.left-V:V>C.right&&(b=V-C.right),O<C.top?h=C.top-O:O>C.bottom&&(h=O-C.bottom),W=Math.sqrt(b*b+h*h);}else {let b=Z.active.rect.current.translated;if(b){let h=b.left+b.width/2,re=b.top+b.height/2,ae=0,s=0;h<C.left?ae=C.left-h:h>C.right&&(ae=h-C.right),re<C.top?s=C.top-re:re>C.bottom&&(s=re-C.bottom),W=Math.sqrt(ae*ae+s*s);}}W>z?c!==F&&(p(F),B?.(F)):c!==null&&(p(null),B?.(null));},onDragEnd:Z=>{a(null),l(null),L(false),g(null),v(null);let{active:x,over:A}=Z,w=x.id.toString(),R=w.startsWith("tab-header-"),u=R?w.substring(11):w,F=P&&c===u;p(null),B?.(null),f.current=null;let y=r||t;if(o(null),F){I?I(u):R?U(u):E(u),m&&m(u,null,null);return}if(!A){n(y),m&&m(u,null,null);return}let C=A.id.toString();if(C.startsWith("drop-locked-")){n(y),m&&m(u,null,null);return}let te=C.match(/^tab-drop-(.+)$/);if(te){if(!R){n(y),m&&m(u,null,null);return}let[,M]=te;if(u!==M){let G="before",X=A.rect,le=Z.activatorEvent,ne=null;if(T.current)ne=T.current.x;else {let oe=Fe(le);oe&&(ne=oe.x+Z.delta.x);}if(ne!==null){let oe=X.left+X.width/2;ne>oe&&(G="after");}let xe=Ze(y,u,M,G);n(xe),m&&m(u,M,{type:"move",position:"center"});}else n(y),m&&m(u,null,null);return}let V=C.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(V){let[,M,G]=V,X=G;X==="start"&&(X="left"),X==="end"&&(X="right");let le=R?pe(y,u):be(y,u),ne;if(R){let oe=K(y,u)?.tabsMetadata?.[u];ne={type:"pane",id:ue(),tabs:[u],activeTabId:u,tabsMetadata:oe?{[u]:oe}:void 0};}else ne=Q(y,u)??{type:"pane",id:ue(),tabs:[u],activeTabId:u};if(le===null)n(ne);else {let xe=X==="left"||X==="right",oe=X==="left"||X==="top",we=50;M==="1/4"?we=oe?25:75:M==="1/3"&&(we=oe?100/3:200/3),n({type:"split",direction:xe?"row":"column",first:oe?ne:le,second:oe?le:ne,splitPercentage:we});}m&&m(u,"root",{type:"split",direction:X==="left"||X==="right"?"row":"column",position:X});return}let O=C.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!O){n(y),m&&m(u,null,null);return}let[,W,_]=O,b=R?K(y,u):Q(y,u),h=b&&b.id===_,re=b&&b.tabs.length===1;if(u===_||h&&re){n(y),m&&m(u,null,null);return}let ae=W==="left"||W==="right"?"row":"column",s;if(R){let G=K(y,u)?.tabsMetadata?.[u];s={type:"pane",id:ue(),tabs:[u],activeTabId:u,tabsMetadata:G?{[u]:G}:void 0};}else s=Q(y,u)??{type:"pane",id:ue(),tabs:[u],activeTabId:u};let d=R?pe(y,u):be(y,u),H=ye(d,_,ae,W,s);n(H),m&&m(u,_,{type:"split",direction:ae,position:W});},onDragCancel:()=>{a(null),l(null),L(false),g(null),v(null),p(null),B?.(null),f.current=null,r!==null&&(n(r),o(null));}}}var Pt=({activeId:e,render:t,className:n})=>{let r=useRef(null);return useEffect(()=>{let o=i=>{r.current&&(r.current.style.transform=`translate(${i.clientX+12}px, ${i.clientY+12}px)`);};return document.addEventListener("pointermove",o),()=>document.removeEventListener("pointermove",o)},[]),jsx("div",{ref:r,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var xt=rn.memo(({tabDetails:e,target:t,renderWidget:n})=>{let{id:r}=e,[o,i]=useState(false),a=useRef(null);if(useEffect(()=>{i(true);},[]),useEffect(()=>{if(!o||!a.current)return;let c=a.current;if(t)t.appendChild(c);else {let p=document.getElementById("zeugma-hidden-portal-container");p||(p=document.createElement("div"),p.id="zeugma-hidden-portal-container",p.style.display="none",document.body.appendChild(p)),p.appendChild(c);}},[t,o]),useEffect(()=>()=>{a.current&&a.current.remove();},[]),!o)return null;a.current||(a.current=document.createElement("div"),a.current.className=`zeugma-portal-wrapper-${r}`,a.current.style.width="100%",a.current.style.height="100%");let l=a.current;return !l||!n?null:createPortal(n(e),l)},(e,t)=>e.target===t.target&&e.renderWidget===t.renderWidget&&e.tabDetails.id===t.tabDetails.id&&e.tabDetails.paneId===t.tabDetails.paneId&&e.tabDetails.isActive===t.tabDetails.isActive&&e.tabDetails.index===t.tabDetails.index&&e.tabDetails.metadata===t.tabDetails.metadata);function tt({containerRef:e,isRow:t,direction:n,splitPercentage:r,resizerSize:o,snapThreshold:i,layout:a,currentNode:l,onLayoutChange:c,onResizeStart:p,onResizeEnd:g,parentLeft:v,parentTop:D,parentWidth:N,parentHeight:P}){let{onResizeStart:z,onResize:I,onResizeEnd:$,minSplitPercentage:m=5,maxSplitPercentage:B=95,locked:U=false}=se();return useCallback(E=>{if(U)return;E.preventDefault();let f=e.current;if(!f)return;p&&p(),z&&z(l);let T=f.getBoundingClientRect(),j=E.clientX,L=E.clientY,k=r,q=E.currentTarget,ee=T.left+T.width*(v/100),J=T.top+T.height*(D/100),S=T.width*(N/100),ie=T.height*(P/100),x=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(w=>w!==q&&w.getAttribute("data-direction")===n).map(w=>{let R=w.getBoundingClientRect();return t?R.left+R.width/2:R.top+R.height/2}),A=k;vt({cursor:t?"col-resize":"row-resize",resizerEl:q,onMove:w=>{let R=t?(w.clientX-j)/S*100:(w.clientY-L)/ie*100,u=k+R,F=t?ee+(S-o)*(u/100)+o/2:J+(ie-o)*(u/100)+o/2,y=1/0,C=null;for(let W of x){let _=Math.abs(F-W);_<i&&_<y&&(y=_,C=W);}let te=u;C!==null&&(te=t?(C-o/2-ee)/(S-o)*100:(C-o/2-J)/(ie-o)*100);let V=Math.max(m,Math.min(B,te));A=V;let O=he(a,l,V);if(O){let{panes:W,splitters:_}=ge(O),b=e.current;if(b){for(let h of W)b.style.setProperty(`--pane-left-${h.paneId}`,`${h.left}%`),b.style.setProperty(`--pane-top-${h.paneId}`,`${h.top}%`),b.style.setProperty(`--pane-width-${h.paneId}`,`${h.width}%`),b.style.setProperty(`--pane-height-${h.paneId}`,`${h.height}%`);for(let h of _)b.style.setProperty(`--splitter-pos-${h.id}`,`${h.direction==="row"?h.left:h.top}%`);}}I&&I(l,V);},onEnd:()=>{let w=he(a,l,A),R=e.current;if(R){let{panes:u,splitters:F}=ge(w);for(let y of u)R.style.removeProperty(`--pane-left-${y.paneId}`),R.style.removeProperty(`--pane-top-${y.paneId}`),R.style.removeProperty(`--pane-width-${y.paneId}`),R.style.removeProperty(`--pane-height-${y.paneId}`);for(let y of F)R.style.removeProperty(`--splitter-pos-${y.id}`);}c(w),g&&g(),$&&$(l,A);}});},[e,t,n,r,o,i,a,l,c,p,g,z,I,$,m,B,v,D,N,P])}var gn=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:r})=>{let{layout:o,setLayout:i,classNames:a,locked:l}=se(),[c,p]=useState(false),{currentNode:g,direction:v,left:D,top:N,width:P,height:z,parentLeft:I,parentTop:$,parentWidth:m,parentHeight:B}=e,U=v==="row",E=tt({containerRef:r,isRow:U,direction:v,splitPercentage:g.splitPercentage,resizerSize:t,snapThreshold:n,layout:o,currentNode:g,onLayoutChange:i,onResizeStart:()=>p(true),onResizeEnd:()=>p(false),parentLeft:I,parentTop:$,parentWidth:m,parentHeight:B}),f=U?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${D}%) - ${t/2}px)`,top:`calc(${N}% + ${t/2}px)`,width:`${t}px`,height:`calc(${z}% - ${t}px)`,cursor:l?"default":"col-resize",pointerEvents:l?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${D}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${N}%) - ${t/2}px)`,width:`calc(${P}% - ${t}px)`,height:`${t}px`,cursor:l?"default":"row-resize",pointerEvents:l?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsx("div",{className:a.resizer||"","data-direction":v,"data-resizing":c||void 0,style:f,onPointerDown:E,role:"separator","aria-valuenow":g.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},mn=rn.memo(({paneId:e,renderPane:t})=>jsx(Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane),nt=({renderPane:e,tree:t,resizerSize:n,snapThreshold:r})=>{let{layout:o,activeId:i,dismissIntentId:a,setContainerRef:l,fullscreenPaneId:c,snapThreshold:p,locked:g,classNames:v,renderPane:D,resizerSize:N}=se(),P=r!==void 0?r:p??8,z=n!==void 0?n:N??4,I=e!==void 0?e:D;if(!I)throw new Error("PaneTree must be provided a renderPane prop or used within a Zeugma provider with renderPane.");let $=t!==void 0?t:o,m=useRef(null),{panes:B,splitters:U}=useMemo(()=>$?ge($):{panes:[],splitters:[]},[$]);if(!$)return null;let E=()=>jsxs(Fragment,{children:[B.map(f=>{let T=c===f.paneId;return jsx("div",{style:{position:"absolute",left:T?"0%":`var(--pane-left-${f.paneId}, ${f.left}%)`,top:T?"0%":`var(--pane-top-${f.paneId}, ${f.top}%)`,width:T?"100%":`var(--pane-width-${f.paneId}, ${f.width}%)`,height:T?"100%":`var(--pane-height-${f.paneId}, ${f.height}%)`,overflow:"hidden",zIndex:T?20:1,display:c&&!T?"none":"block",padding:T?"0px":`${z/2}px`,boxSizing:"border-box"},children:jsx(mn,{paneId:f.paneId,renderPane:I})},f.paneId)}),!c&&U.map(f=>jsx(gn,{splitter:f,resizerSize:z,snapThreshold:P,containerRef:m},f.id))]});if(t===void 0){let f=i!==null&&i===a,T=L=>{l(L),m.current=L;},j=`${v.dashboard||""} ${f&&v.dashboardDismissActive||""} ${g&&v.dashboardLocked||""}`.trim();return jsxs("div",{ref:T,className:j,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[E(),i!==null&&!g&&jsx(Ct,{activeClassName:v.rootDropPreview??v.dropPreview})]})}return jsx("div",{ref:m,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:E()})};var wt=e=>{let{controller:t,children:n,renderDragOverlay:r,classNames:o={},renderPane:i,resizerSize:a,dragActivationDistance:l=8,snapThreshold:c=8,minSplitPercentage:p=5,maxSplitPercentage:g=95,enableDragToDismiss:v=false,dismissThreshold:D=60,onRemove:N,onDragStart:P,onDragEnd:z,onResizeStart:I,onResize:$,onResizeEnd:m,onDismissIntentChange:B}=e,U=t,{layout:E,setLayout:f,_internalSetLayout:T,fullscreenPaneId:j,setFullscreenPaneId:L,locked:k,setLocked:q,findPaneById:ee,findPaneContainingTab:J,findTabById:S,getTabMetadata:ie,getActiveTabMetadata:Z,activeId:x,setActiveId:A,activeType:w,setActiveType:R,dismissIntentId:u,setDismissIntentId:F,containerRef:y,setContainerRef:C,layoutBeforeDrag:te,setLayoutBeforeDrag:V,removePane:O,addTab:W,updateMetadata:_,updatePaneLock:b,selectTab:h,mergeTab:re,removeTab:ae,splitPane:s,updateSplitPercentage:d,moveTab:H}=U,{portalTargets:M,registerPortalTarget:G,registerRenderCallback:X,renderCallbacksRef:le}=pt(),[ne,xe]=useState(null),[oe,we]=useState(null),st=Tt({layout:E,_internalSetLayout:T,layoutBeforeDrag:te,setLayoutBeforeDrag:V,activeId:x,setActiveId:A,setActiveType:R,dismissIntentId:u,setDismissIntentId:F,setOverTabId:xe,setOverTabPosition:we,containerRef:y,dragActivationDistance:l,enableDragToDismiss:v,dismissThreshold:D,onRemove:N,onDragStart:P,onDragEnd:z,onDismissIntentChange:B,removeTab:ae,removePane:O}),it=useMemo(()=>o,[o.dashboard,o.dashboardDismissActive,o.pane,o.paneLocked,o.dropPreview,o.rootDropPreview,o.dragOverlay,o.resizer,o.dismissPreview,o.dashboardLocked,o.lockedPreview,o.tabDropPreview,o.tabSeparator,o.tabsContainer,o.tab,o.paneContainer,o.paneHeader,o.paneControls,o.paneButton,o.tabCloseButton,o.dragHandle]),lt=useCallback((ce,me)=>{m&&m(ce,me);},[m]),At=useMemo(()=>({layout:E,setLayout:f,activeId:x,activeType:w,dismissIntentId:u,setContainerRef:C,fullscreenPaneId:j,classNames:it,onRemove:N,onFullscreenChange:L,snapThreshold:c,onResizeStart:I,onResize:$,onResizeEnd:lt,minSplitPercentage:p,maxSplitPercentage:g,locked:k,setLocked:q,findPaneById:ee,findPaneContainingTab:J,findTabById:S,getTabMetadata:ie,getActiveTabMetadata:Z,renderPane:i,resizerSize:a}),[E,x,w,u,C,j,it,N,L,c,I,$,p,g,f,lt,k,q,ee,J,S,ie,Z,i,a]),Bt=useMemo(()=>({overTabId:ne,overTabPosition:oe}),[ne,oe]),Ht=useMemo(()=>({removePane:O,addTab:W,updateMetadata:_,updatePaneLock:b,selectTab:h,mergeTab:re,removeTab:ae,setFullscreenPaneId:L,setLocked:q,splitPane:s,updateSplitPercentage:d,moveTab:H}),[O,W,_,b,h,re,ae,L,q,s,d,H]),Ot=useMemo(()=>{let ce=new Set;function me(fe){fe&&(fe.type==="pane"?fe.tabs.forEach(Vt=>{ce.add(Vt);}):fe.type==="split"&&(me(fe.first),me(fe.second)));}return me(E),te&&me(te),Array.from(ce).sort()},[E,x,te]),Ft=useMemo(()=>({registerPortalTarget:G,registerRenderCallback:X,renderCallbacksRef:le}),[G,X,le]);return jsx(Qe.Provider,{value:Ht,children:jsx(ze.Provider,{value:At,children:jsx(je.Provider,{value:Bt,children:jsxs($e.Provider,{value:Ft,children:[jsx(DndContext,{id:"zeugma-dnd-context",...st,children:n}),x&&w&&r&&jsx(Pt,{activeId:x,render:ce=>r({type:w,id:ce,isDismissing:x===u}),className:`${o.dragOverlay||""} ${x===u&&o.dismissPreview||""}`.trim()}),jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:Ot.map(ce=>{let me=M[ce],fe=S(ce);return fe?jsx(xt,{tabDetails:fe,target:me||null,renderWidget:le.current[ce]},ce):null})})]})})})})},St=({renderPane:e,resizerSize:t,snapThreshold:n})=>jsx(nt,{renderPane:e,resizerSize:t,snapThreshold:n}),Tn=e=>{if(!(useContext(ze)!==void 0)){let{controller:r,renderPane:o,...i}=e;if(!r)throw new Error("Zeugma component requires a controller when used standalone.");return jsx(wt,{controller:r,renderPane:o,...i,children:jsx(St,{...i})})}return jsx(St,{...e})};var yn={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"}}},Rn={top:{"1/4":{top:0,left:0,width:"100%",height:"60px",borderBottomLeftRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderTopRightRadius:"0px"},"1/3":{top:0,left:0,width:"100%",height:"96px",borderBottomLeftRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderTopRightRadius:"0px"}},bottom:{"1/4":{bottom:0,left:0,width:"100%",height:"60px",borderTopLeftRadius:"12px",borderTopRightRadius:"12px",borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},"1/3":{bottom:0,left:0,width:"100%",height:"96px",borderTopLeftRadius:"12px",borderTopRightRadius:"12px",borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"}},left:{"1/4":{left:0,top:0,width:"60px",height:"100%",borderTopRightRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"},"1/3":{left:0,top:0,width:"96px",height:"100%",borderTopRightRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"}},right:{"1/4":{right:0,top:0,width:"60px",height:"100%",borderTopLeftRadius:"12px",borderBottomLeftRadius:"12px",borderTopRightRadius:"0px",borderBottomRightRadius:"0px"},"1/3":{right:0,top:0,width:"96px",height:"100%",borderTopLeftRadius:"12px",borderBottomLeftRadius:"12px",borderTopRightRadius:"0px",borderBottomRightRadius:"0px"}}},Cn=({id:e,fraction:t,edge:n,activeClassName:r})=>{let{setNodeRef:o,isOver:i}=useDroppable({id:e}),a={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...Rn[n][t]};return jsxs(Fragment,{children:[jsx("div",{ref:o,style:yn[n][t]}),i&&jsx("div",{className:r,style:a})]})},Ct=({activeClassName:e})=>jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:99,pointerEvents:"none"},children:[{id:"drop-root-1/4-top",fraction:"1/4",edge:"top"},{id:"drop-root-1/3-top",fraction:"1/3",edge:"top"},{id:"drop-root-1/4-bottom",fraction:"1/4",edge:"bottom"},{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=>jsx(Cn,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});var We=createContext(null);var In={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"}},Ln={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"}},ot=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:r,isOver:o}=useDroppable({id:e});return jsxs(Fragment,{children:[jsx("div",{ref:r,style:In[t]}),o&&jsx("div",{className:n,style:Ln[t]})]})};var It=({children:e,className:t,style:n})=>{let r=useContext(We);if(!r)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:o,...i}=r;return jsx("div",{className:t,style:{cursor:o?"default":"grab",userSelect:o?"auto":"none",touchAction:o?"auto":"none",...n},...o?{}:i,children:e})};var On=createContext(void 0);var Le=({id:e,locked:t=false,children:n,className:r,style:o})=>{let{locked:i,classNames:a={},activeType:l}=se(),{overTabId:c}=Be(),p=useContext(rt),g=t||i||(p?.locked??false),{attributes:v,listeners:D,setNodeRef:N,isDragging:P}=useDraggable({id:`tab-header-${e}`,disabled:g}),{setNodeRef:z,isOver:I}=useDroppable({id:`tab-drop-${e}`,disabled:g||l==="pane"}),$=J=>{N(J),z(J);},m=I&&c===e,B=p?.tabs||[],U=B.indexOf(e),E=p?.activeTabId,T=U>0&&e!==E&&B[U-1]!==E?jsx("div",{className:a.tabSeparator}):null,j=p?p.activeTabId===e:false,L=p?.tabsMetadata?.[e],k=useCallback(()=>{p?.selectTab(e);},[p,e]),q=useCallback(()=>{p?.removeTab(e);},[p,e]),ee=useMemo(()=>({tabId:e,isActive:j,isDragging:P,isOver:m,metadata:L,locked:g,selectTab:k,removeTab:q}),[e,j,P,m,L,g,k,q]);return jsx(On.Provider,{value:ee,children:jsxs("div",{ref:$,className:r,style:{display:"inline-flex",position:"relative",cursor:g?"default":"grab",...o},...g?{}:D,...g?{}:v,children:[T,n({isDragging:P,isOver:m})]})})};var rt=createContext(void 0);var Mt=(e,t)=>typeof e=="function"?e(t):e,at=({tabs:e,activeTabId:t,locked:n,tabsMetadata:r,selectTab:o,removeTab:i,renderTab:a,classNames:l,styles:c})=>{let p=useContext(Ue),g=e??p?.tabs??[],v=t??p?.activeTabId??"",D=n??p?.locked??false,N=r??p?.tabsMetadata,P=o??p?.selectTab??(()=>{}),z=i??p?.removeTab??(()=>{}),{classNames:I={},activeType:$}=se(),{overTabId:m,overTabPosition:B}=Be(),U=useMemo(()=>({tabs:g,activeTabId:v,locked:D,tabsMetadata:N,selectTab:P,removeTab:z}),[g,v,D,N,P,z]),E=mt(g,$,m,B);return jsx(rt.Provider,{value:U,children:jsxs("div",{className:l?.container,style:{display:"flex",alignItems:"center",height:"100%",...c?.container},children:[g.map((f,T)=>{let j=N?.[f],L=Mt(l?.tab,f),k=Mt(c?.tab,f),q=T===E;return jsxs(rn.Fragment,{children:[q&&I.tabDropPreview&&jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsx("div",{className:I.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:T===0?"none":"translateX(-50%)"}})}),jsx(Le,{id:f,locked:D,className:L,style:k,children:({isDragging:ee,isOver:J})=>a({tabId:f,activeTabId:v,isDragging:ee,isOver:J,metadata:j,onSelect:()=>P(f),onRemove:()=>z(f)})})]},f)}),E===g.length&&I.tabDropPreview&&jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsx("div",{className:I.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:"translateX(-100%)"}})})]})})};at.Tab=Le;var kt=({className:e,style:t,children:n})=>jsx("div",{className:e,style:t,children:n});var Ue=createContext(void 0),$t=()=>{let e=useContext(Ue);if(!e)throw new Error("usePaneContext must be used within a Pane component");return e},Kn=({children:e,className:t,style:n})=>{let{activeTabId:r}=$t(),{classNames:o}=se(),i=useRef(null),a=useContext($e);if(!a)throw new Error("PaneContent must be used within a Zeugma provider");let{registerPortalTarget:l,registerRenderCallback:c}=a,p=useMemo(()=>typeof e=="function"?e:()=>e,[e]);return c(r,p),useEffect(()=>{let g=i.current;return l(r,g),()=>{l(r,null);}},[r,l]),jsx("div",{ref:i,id:`zeugma-tab-target-${r}`,className:`${o.tabContentWrapper||""} ${t||""}`.trim(),style:{height:"100%",width:"100%",...n}})},Se=({id:e,children:t,style:n,locked:r=false})=>{let{layout:o,activeId:i,classNames:a,fullscreenPaneId:l,onFullscreenChange:c,locked:p}=se(),{removePane:g,updateMetadata:v,selectTab:D,removeTab:N}=Ae(),P=useMemo(()=>Q(o,e),[o,e]),z=P?.id??e,I=P?.tabs??[e],$=P?.activeTabId??e,m=P?.tabsMetadata,B=m?.[e],U=P?.locked??false,E=r||U,f=p||E,T=p||E,j=i!==null&&i!==e&&(!I.includes(i)||I.length>1)&&!T,{attributes:L,listeners:k,setNodeRef:q}=useDraggable({id:e,disabled:f}),ee=i!==null&&I.includes(i),J=l===e,S=useMemo(()=>({isDragging:ee,isFullscreen:J,toggleFullscreen:()=>c?.(J?null:e),remove:()=>{J&&c?.(null),g(z);},metadata:B,updateMetadata:x=>{v(e,x);},locked:f,tabs:I,activeTabId:$,selectTab:x=>D(z,x),removeTab:x=>{J&&x===$&&c?.(null),N(x);},tabsMetadata:m,updateTabMetadata:(x,A)=>{v(x,A);}}),[ee,J,c,e,N,B,v,f,I,$,D,z,m]),ie=useMemo(()=>f?{disabled:true}:{...k,...L},[k,L,f]),Z=`${a.pane||""} ${E&&a.paneLocked||""}`.trim();return jsx(Ue.Provider,{value:{id:e,...S},children:jsx(We.Provider,{value:ie,children:jsxs("div",{ref:q,className:Z,style:{position:"relative",width:"100%",height:"100%",...n},children:[t,j&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(x=>jsx(ot,{id:`drop-${x}-${e}`,position:x,activeClassName:a.dropPreview},x))}),i!==null&&i!==e&&T&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsx(ot,{id:`drop-locked-${e}`,position:"full",activeClassName:a.lockedPreview||""})})]})})})};Se.Content=Kn;Se.DragHandle=It;Se.Tabs=at;Se.Tab=Le;Se.Controls=kt;export{Se as Pane,nt as PaneTree,Tn as Zeugma,wt as ZeugmaProvider,$t as usePaneContext,tt as useResizer,Xt as useZeugma,Yt as useZeugmaContext};//# sourceMappingURL=index.js.map
7
7
  //# sourceMappingURL=index.js.map