react-zeugma 6.3.0 → 6.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +133 -157
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +69 -52
- package/dist/index.d.ts +69 -52
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/{types-Diujkc-H.d.cts → types-B9LrYapR.d.cts} +109 -131
- package/dist/{types-Diujkc-H.d.ts → types-B9LrYapR.d.ts} +109 -131
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +17 -10
- package/dist/utils.d.ts +17 -10
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { P as PortalRegistryValue, Z as ZeugmaActionsValue, a as ZeugmaDragStateValue, b as ZeugmaStateValue, U as UseZeugmaOptions, c as ZeugmaController, d as ZeugmaContextValue, e as ZeugmaProps, S as SplitDirection, T as TreeNode, f as SplitNode } from './types-Diujkc-H.cjs';
|
|
2
|
-
export { L as LeafNode, g as PaneNode, h as TabDetails, W as WidgetNode, i as ZeugmaClassNames } from './types-Diujkc-H.cjs';
|
|
3
1
|
import * as React from 'react';
|
|
4
|
-
import React__default
|
|
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
5
|
|
|
6
6
|
declare const DEFAULT_SNAP_THRESHOLD = 8;
|
|
7
7
|
declare const DEFAULT_DRAG_ACTIVATION_DISTANCE = 8;
|
|
@@ -44,7 +44,7 @@ declare const useZeugmaDrag: () => ZeugmaDragStateValue;
|
|
|
44
44
|
|
|
45
45
|
declare function useZeugma(options: UseZeugmaOptions): ZeugmaController;
|
|
46
46
|
|
|
47
|
-
declare const useZeugmaContext: () =>
|
|
47
|
+
declare const useZeugmaContext: () => ZeugmaController;
|
|
48
48
|
|
|
49
49
|
declare const Zeugma: React__default.FC<ZeugmaProps>;
|
|
50
50
|
|
|
@@ -68,6 +68,8 @@ interface UseResizerProps {
|
|
|
68
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;
|
|
69
69
|
|
|
70
70
|
interface PaneTreeProps {
|
|
71
|
+
/** Render function mapping unique pane nodes to React elements. Usually renders a <Pane> wrapper. */
|
|
72
|
+
renderPane: (paneId: string) => React__default.ReactNode;
|
|
71
73
|
/** The layout subtree node to render. If not specified, defaults to the root layout tree from the Zeugma context. */
|
|
72
74
|
tree?: TreeNode | null;
|
|
73
75
|
/** Size/thickness of the split handle resizer bars in pixels (default 4). */
|
|
@@ -106,26 +108,8 @@ interface PaneRenderProps extends BaseLeafRenderProps {
|
|
|
106
108
|
tabsMetadata: Record<string, Record<string, unknown>> | undefined;
|
|
107
109
|
/** Updates the metadata of a specific tab. */
|
|
108
110
|
updateTabMetadata: (tabId: string, updater: (current: Record<string, unknown> | undefined) => Record<string, unknown> | undefined) => void;
|
|
109
|
-
/** Renders the target placeholder element for the currently active tab in the pane. */
|
|
110
|
-
renderActiveTab: () => ReactNode;
|
|
111
|
-
}
|
|
112
|
-
interface WidgetRenderProps extends BaseLeafRenderProps {
|
|
113
|
-
/** Renders the target placeholder element for the widget content. */
|
|
114
|
-
renderActiveWidget: () => ReactNode;
|
|
115
111
|
}
|
|
116
112
|
|
|
117
|
-
interface PaneProps {
|
|
118
|
-
/** The unique ID of the pane, matching a `paneId` in the layout tree schema. */
|
|
119
|
-
id: string;
|
|
120
|
-
/** Render prop function providing pane state (isDragging, isFullscreen, etc.) and handlers. */
|
|
121
|
-
children: (props: PaneRenderProps) => React__default.ReactNode;
|
|
122
|
-
/** Optional inline CSS styles applied to the pane outer container. */
|
|
123
|
-
style?: React__default.CSSProperties;
|
|
124
|
-
/** Optional override to lock this specific pane. */
|
|
125
|
-
locked?: boolean;
|
|
126
|
-
}
|
|
127
|
-
declare const Pane: React__default.FC<PaneProps>;
|
|
128
|
-
|
|
129
113
|
interface DragHandleProps {
|
|
130
114
|
/** The children elements that will trigger dragging when held and dragged. */
|
|
131
115
|
children?: React__default.ReactNode;
|
|
@@ -136,19 +120,37 @@ interface DragHandleProps {
|
|
|
136
120
|
}
|
|
137
121
|
declare const DragHandle: React__default.FC<DragHandleProps>;
|
|
138
122
|
|
|
123
|
+
interface TabRenderProps {
|
|
124
|
+
isDragging: boolean;
|
|
125
|
+
isOver: boolean;
|
|
126
|
+
}
|
|
127
|
+
interface TabProps {
|
|
128
|
+
/** The unique ID of the tab, which corresponds to the pane/widget ID. */
|
|
129
|
+
id: string;
|
|
130
|
+
/** Whether dragging is locked on this tab. */
|
|
131
|
+
locked?: boolean;
|
|
132
|
+
/** Render prop child function. */
|
|
133
|
+
children: (props: TabRenderProps) => React__default.ReactNode;
|
|
134
|
+
/** Custom CSS class applied to the tab wrapper. */
|
|
135
|
+
className?: string;
|
|
136
|
+
/** Custom inline CSS style applied to the tab wrapper. */
|
|
137
|
+
style?: React__default.CSSProperties;
|
|
138
|
+
}
|
|
139
|
+
declare const Tab: React__default.FC<TabProps>;
|
|
140
|
+
|
|
139
141
|
interface TabsProps {
|
|
140
142
|
/** The list of tab IDs in this pane. */
|
|
141
|
-
tabs
|
|
143
|
+
tabs?: string[];
|
|
142
144
|
/** The currently active tab ID. */
|
|
143
|
-
activeTabId
|
|
145
|
+
activeTabId?: string;
|
|
144
146
|
/** Whether dragging is locked on these tabs. */
|
|
145
147
|
locked?: boolean;
|
|
146
148
|
/** Metadata for the tabs. */
|
|
147
149
|
tabsMetadata?: Record<string, Record<string, unknown>>;
|
|
148
150
|
/** Callback when a tab is selected. */
|
|
149
|
-
selectTab
|
|
151
|
+
selectTab?: (id: string) => void;
|
|
150
152
|
/** Callback when a tab is closed/removed. */
|
|
151
|
-
removeTab
|
|
153
|
+
removeTab?: (id: string) => void;
|
|
152
154
|
/** Render function for each individual tab content. */
|
|
153
155
|
renderTab: (props: {
|
|
154
156
|
tabId: string;
|
|
@@ -156,8 +158,8 @@ interface TabsProps {
|
|
|
156
158
|
isDragging: boolean;
|
|
157
159
|
isOver: boolean;
|
|
158
160
|
metadata?: Record<string, unknown>;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
+
onSelect: () => void;
|
|
162
|
+
onRemove: () => void;
|
|
161
163
|
}) => React__default.ReactNode;
|
|
162
164
|
/** Custom CSS classes for Tabs container and tab wrappers. */
|
|
163
165
|
classNames?: {
|
|
@@ -170,34 +172,49 @@ interface TabsProps {
|
|
|
170
172
|
tab?: React__default.CSSProperties | ((tabId: string) => React__default.CSSProperties);
|
|
171
173
|
};
|
|
172
174
|
}
|
|
173
|
-
declare const Tabs: React__default.FC<TabsProps
|
|
175
|
+
declare const Tabs: React__default.FC<TabsProps> & {
|
|
176
|
+
Tab: typeof Tab;
|
|
177
|
+
};
|
|
174
178
|
|
|
175
|
-
interface
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
selectTab: () => void;
|
|
183
|
-
removeTab: () => void;
|
|
184
|
-
}
|
|
185
|
-
declare const useTabContext: () => TabContextValue;
|
|
186
|
-
interface TabRenderProps {
|
|
187
|
-
isDragging: boolean;
|
|
188
|
-
isOver: boolean;
|
|
179
|
+
interface PaneControlsProps {
|
|
180
|
+
/** Custom CSS class applied to the controls container. */
|
|
181
|
+
className?: string;
|
|
182
|
+
/** Custom inline CSS style applied to the controls container. */
|
|
183
|
+
style?: React__default.CSSProperties;
|
|
184
|
+
/** The children elements (e.g. close and fullscreen buttons) to render inside the controls container. */
|
|
185
|
+
children?: React__default.ReactNode;
|
|
189
186
|
}
|
|
187
|
+
declare const PaneControls: React__default.FC<PaneControlsProps>;
|
|
190
188
|
|
|
191
|
-
interface
|
|
192
|
-
/** The unique ID of the widget, matching a `id` in the layout tree schema. */
|
|
189
|
+
interface PaneContextValue extends PaneRenderProps {
|
|
193
190
|
id: string;
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
191
|
+
}
|
|
192
|
+
declare const usePaneContext: () => PaneContextValue;
|
|
193
|
+
interface PaneContentProps {
|
|
194
|
+
/** 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);
|
|
196
|
+
/** Custom CSS class applied to the tab content wrapper. */
|
|
197
|
+
className?: string;
|
|
198
|
+
/** Custom inline CSS style applied to the tab content wrapper. */
|
|
199
|
+
style?: React__default.CSSProperties;
|
|
200
|
+
}
|
|
201
|
+
declare const PaneContent: React__default.FC<PaneContentProps>;
|
|
202
|
+
interface PaneProps {
|
|
203
|
+
/** The unique ID of the pane, matching a `paneId` in the layout tree schema. */
|
|
204
|
+
id: string;
|
|
205
|
+
/** The children elements inside the pane (e.g. headers, tabs, content). */
|
|
206
|
+
children: React__default.ReactNode;
|
|
207
|
+
/** Optional inline CSS styles applied to the pane outer container. */
|
|
197
208
|
style?: React__default.CSSProperties;
|
|
198
|
-
/** Optional override to lock this specific
|
|
209
|
+
/** Optional override to lock this specific pane. */
|
|
199
210
|
locked?: boolean;
|
|
200
211
|
}
|
|
201
|
-
declare const
|
|
202
|
-
|
|
203
|
-
|
|
212
|
+
declare const Pane: React__default.FC<PaneProps> & {
|
|
213
|
+
Content: typeof PaneContent;
|
|
214
|
+
DragHandle: typeof DragHandle;
|
|
215
|
+
Tabs: typeof Tabs;
|
|
216
|
+
Tab: typeof Tab;
|
|
217
|
+
Controls: typeof PaneControls;
|
|
218
|
+
};
|
|
219
|
+
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { P as PortalRegistryValue, Z as ZeugmaActionsValue, a as ZeugmaDragStateValue, b as ZeugmaStateValue, U as UseZeugmaOptions, c as ZeugmaController, d as ZeugmaContextValue, e as ZeugmaProps, S as SplitDirection, T as TreeNode, f as SplitNode } from './types-Diujkc-H.js';
|
|
2
|
-
export { L as LeafNode, g as PaneNode, h as TabDetails, W as WidgetNode, i as ZeugmaClassNames } from './types-Diujkc-H.js';
|
|
3
1
|
import * as React from 'react';
|
|
4
|
-
import React__default
|
|
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
5
|
|
|
6
6
|
declare const DEFAULT_SNAP_THRESHOLD = 8;
|
|
7
7
|
declare const DEFAULT_DRAG_ACTIVATION_DISTANCE = 8;
|
|
@@ -44,7 +44,7 @@ declare const useZeugmaDrag: () => ZeugmaDragStateValue;
|
|
|
44
44
|
|
|
45
45
|
declare function useZeugma(options: UseZeugmaOptions): ZeugmaController;
|
|
46
46
|
|
|
47
|
-
declare const useZeugmaContext: () =>
|
|
47
|
+
declare const useZeugmaContext: () => ZeugmaController;
|
|
48
48
|
|
|
49
49
|
declare const Zeugma: React__default.FC<ZeugmaProps>;
|
|
50
50
|
|
|
@@ -68,6 +68,8 @@ interface UseResizerProps {
|
|
|
68
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;
|
|
69
69
|
|
|
70
70
|
interface PaneTreeProps {
|
|
71
|
+
/** Render function mapping unique pane nodes to React elements. Usually renders a <Pane> wrapper. */
|
|
72
|
+
renderPane: (paneId: string) => React__default.ReactNode;
|
|
71
73
|
/** The layout subtree node to render. If not specified, defaults to the root layout tree from the Zeugma context. */
|
|
72
74
|
tree?: TreeNode | null;
|
|
73
75
|
/** Size/thickness of the split handle resizer bars in pixels (default 4). */
|
|
@@ -106,26 +108,8 @@ interface PaneRenderProps extends BaseLeafRenderProps {
|
|
|
106
108
|
tabsMetadata: Record<string, Record<string, unknown>> | undefined;
|
|
107
109
|
/** Updates the metadata of a specific tab. */
|
|
108
110
|
updateTabMetadata: (tabId: string, updater: (current: Record<string, unknown> | undefined) => Record<string, unknown> | undefined) => void;
|
|
109
|
-
/** Renders the target placeholder element for the currently active tab in the pane. */
|
|
110
|
-
renderActiveTab: () => ReactNode;
|
|
111
|
-
}
|
|
112
|
-
interface WidgetRenderProps extends BaseLeafRenderProps {
|
|
113
|
-
/** Renders the target placeholder element for the widget content. */
|
|
114
|
-
renderActiveWidget: () => ReactNode;
|
|
115
111
|
}
|
|
116
112
|
|
|
117
|
-
interface PaneProps {
|
|
118
|
-
/** The unique ID of the pane, matching a `paneId` in the layout tree schema. */
|
|
119
|
-
id: string;
|
|
120
|
-
/** Render prop function providing pane state (isDragging, isFullscreen, etc.) and handlers. */
|
|
121
|
-
children: (props: PaneRenderProps) => React__default.ReactNode;
|
|
122
|
-
/** Optional inline CSS styles applied to the pane outer container. */
|
|
123
|
-
style?: React__default.CSSProperties;
|
|
124
|
-
/** Optional override to lock this specific pane. */
|
|
125
|
-
locked?: boolean;
|
|
126
|
-
}
|
|
127
|
-
declare const Pane: React__default.FC<PaneProps>;
|
|
128
|
-
|
|
129
113
|
interface DragHandleProps {
|
|
130
114
|
/** The children elements that will trigger dragging when held and dragged. */
|
|
131
115
|
children?: React__default.ReactNode;
|
|
@@ -136,19 +120,37 @@ interface DragHandleProps {
|
|
|
136
120
|
}
|
|
137
121
|
declare const DragHandle: React__default.FC<DragHandleProps>;
|
|
138
122
|
|
|
123
|
+
interface TabRenderProps {
|
|
124
|
+
isDragging: boolean;
|
|
125
|
+
isOver: boolean;
|
|
126
|
+
}
|
|
127
|
+
interface TabProps {
|
|
128
|
+
/** The unique ID of the tab, which corresponds to the pane/widget ID. */
|
|
129
|
+
id: string;
|
|
130
|
+
/** Whether dragging is locked on this tab. */
|
|
131
|
+
locked?: boolean;
|
|
132
|
+
/** Render prop child function. */
|
|
133
|
+
children: (props: TabRenderProps) => React__default.ReactNode;
|
|
134
|
+
/** Custom CSS class applied to the tab wrapper. */
|
|
135
|
+
className?: string;
|
|
136
|
+
/** Custom inline CSS style applied to the tab wrapper. */
|
|
137
|
+
style?: React__default.CSSProperties;
|
|
138
|
+
}
|
|
139
|
+
declare const Tab: React__default.FC<TabProps>;
|
|
140
|
+
|
|
139
141
|
interface TabsProps {
|
|
140
142
|
/** The list of tab IDs in this pane. */
|
|
141
|
-
tabs
|
|
143
|
+
tabs?: string[];
|
|
142
144
|
/** The currently active tab ID. */
|
|
143
|
-
activeTabId
|
|
145
|
+
activeTabId?: string;
|
|
144
146
|
/** Whether dragging is locked on these tabs. */
|
|
145
147
|
locked?: boolean;
|
|
146
148
|
/** Metadata for the tabs. */
|
|
147
149
|
tabsMetadata?: Record<string, Record<string, unknown>>;
|
|
148
150
|
/** Callback when a tab is selected. */
|
|
149
|
-
selectTab
|
|
151
|
+
selectTab?: (id: string) => void;
|
|
150
152
|
/** Callback when a tab is closed/removed. */
|
|
151
|
-
removeTab
|
|
153
|
+
removeTab?: (id: string) => void;
|
|
152
154
|
/** Render function for each individual tab content. */
|
|
153
155
|
renderTab: (props: {
|
|
154
156
|
tabId: string;
|
|
@@ -156,8 +158,8 @@ interface TabsProps {
|
|
|
156
158
|
isDragging: boolean;
|
|
157
159
|
isOver: boolean;
|
|
158
160
|
metadata?: Record<string, unknown>;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
+
onSelect: () => void;
|
|
162
|
+
onRemove: () => void;
|
|
161
163
|
}) => React__default.ReactNode;
|
|
162
164
|
/** Custom CSS classes for Tabs container and tab wrappers. */
|
|
163
165
|
classNames?: {
|
|
@@ -170,34 +172,49 @@ interface TabsProps {
|
|
|
170
172
|
tab?: React__default.CSSProperties | ((tabId: string) => React__default.CSSProperties);
|
|
171
173
|
};
|
|
172
174
|
}
|
|
173
|
-
declare const Tabs: React__default.FC<TabsProps
|
|
175
|
+
declare const Tabs: React__default.FC<TabsProps> & {
|
|
176
|
+
Tab: typeof Tab;
|
|
177
|
+
};
|
|
174
178
|
|
|
175
|
-
interface
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
selectTab: () => void;
|
|
183
|
-
removeTab: () => void;
|
|
184
|
-
}
|
|
185
|
-
declare const useTabContext: () => TabContextValue;
|
|
186
|
-
interface TabRenderProps {
|
|
187
|
-
isDragging: boolean;
|
|
188
|
-
isOver: boolean;
|
|
179
|
+
interface PaneControlsProps {
|
|
180
|
+
/** Custom CSS class applied to the controls container. */
|
|
181
|
+
className?: string;
|
|
182
|
+
/** Custom inline CSS style applied to the controls container. */
|
|
183
|
+
style?: React__default.CSSProperties;
|
|
184
|
+
/** The children elements (e.g. close and fullscreen buttons) to render inside the controls container. */
|
|
185
|
+
children?: React__default.ReactNode;
|
|
189
186
|
}
|
|
187
|
+
declare const PaneControls: React__default.FC<PaneControlsProps>;
|
|
190
188
|
|
|
191
|
-
interface
|
|
192
|
-
/** The unique ID of the widget, matching a `id` in the layout tree schema. */
|
|
189
|
+
interface PaneContextValue extends PaneRenderProps {
|
|
193
190
|
id: string;
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
191
|
+
}
|
|
192
|
+
declare const usePaneContext: () => PaneContextValue;
|
|
193
|
+
interface PaneContentProps {
|
|
194
|
+
/** 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);
|
|
196
|
+
/** Custom CSS class applied to the tab content wrapper. */
|
|
197
|
+
className?: string;
|
|
198
|
+
/** Custom inline CSS style applied to the tab content wrapper. */
|
|
199
|
+
style?: React__default.CSSProperties;
|
|
200
|
+
}
|
|
201
|
+
declare const PaneContent: React__default.FC<PaneContentProps>;
|
|
202
|
+
interface PaneProps {
|
|
203
|
+
/** The unique ID of the pane, matching a `paneId` in the layout tree schema. */
|
|
204
|
+
id: string;
|
|
205
|
+
/** The children elements inside the pane (e.g. headers, tabs, content). */
|
|
206
|
+
children: React__default.ReactNode;
|
|
207
|
+
/** Optional inline CSS styles applied to the pane outer container. */
|
|
197
208
|
style?: React__default.CSSProperties;
|
|
198
|
-
/** Optional override to lock this specific
|
|
209
|
+
/** Optional override to lock this specific pane. */
|
|
199
210
|
locked?: boolean;
|
|
200
211
|
}
|
|
201
|
-
declare const
|
|
202
|
-
|
|
203
|
-
|
|
212
|
+
declare const Pane: React__default.FC<PaneProps> & {
|
|
213
|
+
Content: typeof PaneContent;
|
|
214
|
+
DragHandle: typeof DragHandle;
|
|
215
|
+
Tabs: typeof Tabs;
|
|
216
|
+
Tab: typeof Tab;
|
|
217
|
+
Controls: typeof PaneControls;
|
|
218
|
+
};
|
|
219
|
+
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
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=`
|
|
2
2
|
* {
|
|
3
3
|
cursor: ${e} !important;
|
|
4
4
|
user-select: none !important;
|
|
5
5
|
}
|
|
6
|
-
`,document.head.appendChild(o),t.setAttribute("data-resizing","true");let r=a=>{n(a);},i=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let a=document.getElementById("zeugma-global-cursor-style");a&&a.remove(),document.removeEventListener("pointermove",r),document.removeEventListener("pointerup",i),s();};document.addEventListener("pointermove",r),document.addEventListener("pointerup",i);}var Xe=createContext(void 0),Ye=createContext(void 0),Re=createContext(void 0),Je=createContext(void 0),re=()=>{let e=useContext(Xe);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},De=()=>{let e=useContext(Ye);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},Fe=()=>{let e=useContext(Je);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};var At=()=>{let e=re(),t=De();return {...e,...t}};var Oe=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 We(e){if(e instanceof MouseEvent||e instanceof PointerEvent)return {x:e.clientX,y:e.clientY};if(typeof TouchEvent<"u"&&e instanceof TouchEvent){let t=e.touches[0]||e.changedTouches[0];if(t)return {x:t.clientX,y:t.clientY}}return null}function gt(e){let{layout:t,_internalSetLayout:n,layoutBeforeDrag:s,setLayoutBeforeDrag:o,activeId:r,setActiveId:i,setActiveType:a,dismissIntentId:c,setDismissIntentId:p,setOverTabId:f,setOverTabPosition:h,containerRef:R,dragActivationDistance:w,enableDragToDismiss:x,dismissThreshold:E,onRemove:M,onDragStart:N,onDragEnd:u,onDismissIntentChange:T,removeTab:L}=e,C=useRef(null),z=nt(r),[_,U]=useState(false);ot(_);let F=useSensors(useSensor(Oe,{activationConstraint:{distance:w}}),useSensor(Be,{activationConstraint:{delay:250,tolerance:5}})),q=useCallback(g=>{let A=g.active.id.toString().startsWith("tab-header-"),H=pointerWithin(g),D=A?H:H.filter(l=>!l.id.toString().startsWith("tab-drop-"));if(D.length>0)return [...D].sort((P,y)=>{let v=P.id.toString(),X=y.id.toString();if(A){let B=v.startsWith("tab-drop-"),Q=X.startsWith("tab-drop-");if(B&&!Q)return -1;if(!B&&Q)return 1}let O=v.startsWith("drop-root-"),m=X.startsWith("drop-root-");return O&&!m?-1:!O&&m?1:0});if(A){let l=g.droppableContainers.filter(P=>P.id.toString().startsWith("tab-drop-"));return closestCenter({...g,droppableContainers:l})}return []},[]);return {sensors:F,collisionDetection:q,onDragStart:g=>{let Z=g.active.id.toString(),A=Z.startsWith("tab-header-"),H=A?Z.substring(11):Z;i(H),a(A?"tab":"pane"),f(null),h(null);let D=g.activatorEvent;z.current=We(D),x&&R.current?C.current=R.current.getBoundingClientRect():C.current=null;let l=t;if(A){let P=ee(t,H);P&&(l=ye(t,P.id,H)||t);}o(l),A&&l!==t&&n(l),N&&N(H);},onDragMove:g=>{let{over:Z}=g,A=Z?.id.toString()||"",H=A.startsWith("drop-locked-");U(b=>b===H?b:H);let D=g.active.id.toString(),l=D.startsWith("tab-header-"),P=l?D.substring(11):D,y=A.match(/^tab-drop-(.+)$/);if(y&&Z&&l){let[,b]=y;if(P!==b){let S="before",$=Z.rect,se=g.activatorEvent,j=null;if(z.current)j=z.current.x;else {let te=We(se);te&&(j=te.x+g.delta.x);}if(j!==null){let te=$.left+$.width/2;j>te&&(S="after");}f(te=>te===b?te:b),h(te=>te===S?te:S);}else f(S=>S===null?S:null),h(S=>S===null?S:null);}else f(b=>b===null?b:null),h(b=>b===null?b:null);if(!x)return;let v=C.current;if(!v){c!==null&&(p(null),T?.(null));return}let X=g.activatorEvent,O=null,m=null;if(z.current)O=z.current.x,m=z.current.y;else {let b=We(X);b&&(O=b.x+g.delta.x,m=b.y+g.delta.y);}let B=0;if(O!==null&&m!==null){let b=0,S=0;O<v.left?b=v.left-O:O>v.right&&(b=O-v.right),m<v.top?S=v.top-m:m>v.bottom&&(S=m-v.bottom),B=Math.sqrt(b*b+S*S);}else {let b=g.active.rect.current.translated;if(b){let S=b.left+b.width/2,$=b.top+b.height/2,se=0,j=0;S<v.left?se=v.left-S:S>v.right&&(se=S-v.right),$<v.top?j=v.top-$:$>v.bottom&&(j=$-v.bottom),B=Math.sqrt(se*se+j*j);}}B>E?c!==P&&(p(P),T?.(P)):c!==null&&(p(null),T?.(null));},onDragEnd:g=>{i(null),a(null),U(false),f(null),h(null);let{active:Z,over:A}=g,H=Z.id.toString(),D=H.startsWith("tab-header-"),l=D?H.substring(11):H,P=x&&c===l;p(null),T?.(null),C.current=null;let y=s||t;if(o(null),P){M?M(l):L(l),u&&u(l,null,null);return}if(!A){n(y),u&&u(l,null,null);return}let v=A.id.toString();if(v.startsWith("drop-locked-")){n(y),u&&u(l,null,null);return}let X=v.match(/^tab-drop-(.+)$/);if(X){if(!D){n(y),u&&u(l,null,null);return}let[,ce]=X;if(l!==ce){let ue="before",k=A.rect,ie=g.activatorEvent,W=null;if(z.current)W=z.current.x;else {let ae=We(ie);ae&&(W=ae.x+g.delta.x);}if(W!==null){let ae=k.left+k.width/2;W>ae&&(ue="after");}let ge=ze(y,l,ce,ue);n(ge),u&&u(l,ce,{type:"move",position:"center"});}else n(y),u&&u(l,null,null);return}let O=v.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(O){let[,ce,ue]=O,k=ue;k==="start"&&(k="left"),k==="end"&&(k="right");let ie=D?pe(y,l):be(y,l),W;if(D){let ae=ee(y,l)?.tabsMetadata?.[l];W={type:"pane",id:de(),tabs:[l],activeTabId:l,tabsMetadata:ae?{[l]:ae}:void 0};}else W=ne(y,l)??{type:"pane",id:de(),tabs:[l],activeTabId:l};if(ie===null)n(W);else {let ge=k==="left"||k==="right",ae=k==="left"||k==="top",Me=50;ce==="1/4"?Me=ae?25:75:ce==="1/3"&&(Me=ae?100/3:200/3),n({type:"split",direction:ge?"row":"column",first:ae?W:ie,second:ae?ie:W,splitPercentage:Me});}u&&u(l,"root",{type:"split",direction:k==="left"||k==="right"?"row":"column",position:k});return}let m=v.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!m){n(y),u&&u(l,null,null);return}let[,B,Q]=m,b=D?ee(y,l):ne(y,l),S=b&&b.id===Q,$=b&&(b.type==="widget"||b.tabs.length===1);if(l===Q||S&&$){n(y),u&&u(l,null,null);return}let se=B==="left"||B==="right"?"row":"column",j;if(D){let ue=ee(y,l)?.tabsMetadata?.[l];j={type:"pane",id:de(),tabs:[l],activeTabId:l,tabsMetadata:ue?{[l]:ue}:void 0};}else j=ne(y,l)??{type:"pane",id:de(),tabs:[l],activeTabId:l};let te=D?pe(y,l):be(y,l),Ie=Pe(te,Q,se,B,j);n(Ie),u&&u(l,Q,{type:"split",direction:se,position:B});},onDragCancel:()=>{i(null),a(null),U(false),f(null),h(null),p(null),T?.(null),C.current=null,s!==null&&(n(s),o(null));}}}var mt=({activeId:e,render:t,className:n})=>{let s=useRef(null);return useEffect(()=>{let o=r=>{s.current&&(s.current.style.transform=`translate(${r.clientX+12}px, ${r.clientY+12}px)`);};return document.addEventListener("pointermove",o),()=>document.removeEventListener("pointermove",o)},[]),jsx("div",{ref:s,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var bt=qt.memo(({tabId:e,target:t,renderWidget:n})=>{let[s,o]=useState(false),r=useRef(null);if(useEffect(()=>{o(true);},[]),useEffect(()=>{if(!s||!r.current)return;let a=r.current;if(t)t.appendChild(a);else {let c=document.getElementById("zeugma-hidden-portal-container");c||(c=document.createElement("div"),c.id="zeugma-hidden-portal-container",c.style.display="none",document.body.appendChild(c)),c.appendChild(a);}},[t,s]),useEffect(()=>()=>{r.current&&r.current.remove();},[]),!s)return null;r.current||(r.current=document.createElement("div"),r.current.className=`zeugma-portal-wrapper-${e}`,r.current.style.width="100%",r.current.style.height="100%");let i=r.current;return !i||!n?null:createPortal(n(e),i)});var en=e=>{let t=e,{renderPane:n,renderWidget:s,renderDragOverlay:o,classNames:r={},children:i,layout:a,setLayout:c,fullscreenPaneId:p,setFullscreenPaneId:f,locked:h,setLocked:R,findPaneById:w,findPaneContainingTab:x,findTabById:E,activeId:M,activeType:N,dismissIntentId:u,setContainerRef:T,layoutBeforeDrag:L,snapThreshold:C,minSplitPercentage:z,maxSplitPercentage:_,onRemove:U,onResizeStart:F,onResize:q,onResizeEnd:G,removePane:oe,addWidget:K,addTab:le,updateMetadata:g,updatePaneLock:Z,selectTab:A,mergeTab:H,removeTab:D,splitPane:l,updateSplitPercentage:P,moveTab:y}=t,{portalTargets:v,registerPortalTarget:X}=rt(),[O,m]=useState(null),[B,Q]=useState(null),b=gt({...t,setOverTabId:m,setOverTabPosition:Q}),S=useCallback(k=>n(k),[n]),$=useMemo(()=>r,[r.dashboard,r.dashboardDismissActive,r.pane,r.paneLocked,r.dropPreview,r.rootDropPreview,r.dragOverlay,r.resizer,r.dismissPreview,r.dashboardLocked,r.lockedPreview,r.tabDropPreview,r.tabSeparator]),se=useCallback((k,ie)=>{G&&G(k,ie);},[G]),j=useMemo(()=>({layout:a,setLayout:c,renderPane:S,activeId:M,activeType:N,dismissIntentId:u,setContainerRef:T,fullscreenPaneId:p,classNames:$,onRemove:U,onFullscreenChange:f,snapThreshold:C,onResizeStart:F,onResize:q,onResizeEnd:se,minSplitPercentage:z,maxSplitPercentage:_,locked:h,setLocked:R,findPaneById:w,findPaneContainingTab:x,findTabById:E}),[a,M,N,u,T,p,$,U,f,C,F,q,z,_,c,S,se,h,R,w,x,E]),te=useMemo(()=>({overTabId:O,overTabPosition:B}),[O,B]),Ie=useMemo(()=>({removePane:oe,addWidget:K,addTab:le,updateMetadata:g,updatePaneLock:Z,selectTab:A,mergeTab:H,removeTab:D,setFullscreenPaneId:f,setLocked:R,splitPane:l,updateSplitPercentage:P,moveTab:y}),[oe,K,le,g,Z,A,H,D,f,R,l,P,y]),ce=useMemo(()=>{let k=new Set;function ie(W){W&&(W.type==="pane"?W.tabs.forEach(ge=>{k.add(ge);}):W.type==="widget"?k.add(W.id):W.type==="split"&&(ie(W.first),ie(W.second)));}return ie(a),L&&ie(L),Array.from(k).sort()},[a,M,L]),ue=useMemo(()=>({registerPortalTarget:X}),[X]);return jsx(Ye.Provider,{value:Ie,children:jsx(Xe.Provider,{value:j,children:jsx(Je.Provider,{value:te,children:jsxs(Re.Provider,{value:ue,children:[jsx(DndContext,{id:"zeugma-dnd-context",...b,children:i}),M&&N&&o&&jsx(mt,{activeId:M,render:k=>o(k,N),className:`${r.dragOverlay||""} ${M===u&&r.dismissPreview||""}`.trim()}),jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:ce.map(k=>jsx(bt,{tabId:k,target:v[k]||null,renderWidget:s},k))})]})})})})};var on={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"}}},sn=({id:e,fraction:t,edge:n,activeClassName:s})=>{let{setNodeRef:o,isOver:r}=useDroppable({id:e}),i={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...rn[n][t]};return jsxs(Fragment,{children:[jsx("div",{ref:o,style:on[n][t]}),r&&jsx("div",{className:s,style:i})]})},xt=({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(sn,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});function Ge({containerRef:e,isRow:t,direction:n,splitPercentage:s,resizerSize:o,snapThreshold:r,layout:i,currentNode:a,onLayoutChange:c,onResizeStart:p,onResizeEnd:f,parentLeft:h,parentTop:R,parentWidth:w,parentHeight:x}){let{onResizeStart:E,onResize:M,onResizeEnd:N,minSplitPercentage:u=5,maxSplitPercentage:T=95,locked:L=false}=re();return useCallback(C=>{if(L)return;C.preventDefault();let z=e.current;if(!z)return;p&&p(),E&&E(a);let _=z.getBoundingClientRect(),U=C.clientX,F=C.clientY,q=s,G=C.currentTarget,oe=_.left+_.width*(h/100),K=_.top+_.height*(R/100),le=_.width*(w/100),g=_.height*(x/100),A=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(D=>D!==G&&D.getAttribute("data-direction")===n).map(D=>{let l=D.getBoundingClientRect();return t?l.left+l.width/2:l.top+l.height/2}),H=q;pt({cursor:t?"col-resize":"row-resize",resizerEl:G,onMove:D=>{let l=t?(D.clientX-U)/le*100:(D.clientY-F)/g*100,P=q+l,y=t?oe+(le-o)*(P/100)+o/2:K+(g-o)*(P/100)+o/2,v=1/0,X=null;for(let Q of A){let b=Math.abs(y-Q);b<r&&b<v&&(v=b,X=Q);}let O=P;X!==null&&(O=t?(X-o/2-oe)/(le-o)*100:(X-o/2-K)/(g-o)*100);let m=Math.max(u,Math.min(T,O));H=m;let B=ve(i,a,m);if(B){let{panes:Q,splitters:b}=fe(B),S=e.current;if(S){for(let $ of Q)S.style.setProperty(`--pane-left-${$.paneId}`,`${$.left}%`),S.style.setProperty(`--pane-top-${$.paneId}`,`${$.top}%`),S.style.setProperty(`--pane-width-${$.paneId}`,`${$.width}%`),S.style.setProperty(`--pane-height-${$.paneId}`,`${$.height}%`);for(let $ of b)S.style.setProperty(`--splitter-pos-${$.id}`,`${$.direction==="row"?$.left:$.top}%`);}}M&&M(a,m);},onEnd:()=>{let D=ve(i,a,H),l=e.current;if(l){let{panes:P,splitters:y}=fe(D);for(let v of P)l.style.removeProperty(`--pane-left-${v.paneId}`),l.style.removeProperty(`--pane-top-${v.paneId}`),l.style.removeProperty(`--pane-width-${v.paneId}`),l.style.removeProperty(`--pane-height-${v.paneId}`);for(let v of y)l.style.removeProperty(`--splitter-pos-${v.id}`);}c(D),f&&f(),N&&N(a,H);}});},[e,t,n,s,o,r,i,a,c,p,f,E,M,N,u,T,h,R,w,x])}var gn=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:s})=>{let{layout:o,setLayout:r,classNames:i,locked:a}=re(),[c,p]=useState(false),{currentNode:f,direction:h,left:R,top:w,width:x,height:E,parentLeft:M,parentTop:N,parentWidth:u,parentHeight:T}=e,L=h==="row",C=Ge({containerRef:s,isRow:L,direction:h,splitPercentage:f.splitPercentage,resizerSize:t,snapThreshold:n,layout:o,currentNode:f,onLayoutChange:r,onResizeStart:()=>p(true),onResizeEnd:()=>p(false),parentLeft:M,parentTop:N,parentWidth:u,parentHeight:T}),z=L?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${R}%) - ${t/2}px)`,top:`calc(${w}% + ${t/2}px)`,width:`${t}px`,height:`calc(${E}% - ${t}px)`,cursor:a?"default":"col-resize",pointerEvents:a?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${R}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${w}%) - ${t/2}px)`,width:`calc(${x}% - ${t}px)`,height:`${t}px`,cursor:a?"default":"row-resize",pointerEvents:a?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsx("div",{className:i.resizer||"","data-direction":h,"data-resizing":c||void 0,style:z,onPointerDown:C,role:"separator","aria-valuenow":f.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},mn=qt.memo(({paneId:e,renderPane:t})=>jsx(Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane),bn=({tree:e,resizerSize:t=4,snapThreshold:n})=>{let{layout:s,renderPane:o,activeId:r,dismissIntentId:i,setContainerRef:a,fullscreenPaneId:c,snapThreshold:p,locked:f,classNames:h}=re(),R=n!==void 0?n:p??8,w=e!==void 0?e:s,x=useRef(null),{panes:E,splitters:M}=useMemo(()=>w?fe(w):{panes:[],splitters:[]},[w]);if(!w)return null;let N=()=>jsxs(Fragment,{children:[E.map(u=>{let T=c===u.paneId;return jsx("div",{style:{position:"absolute",left:T?"0%":`var(--pane-left-${u.paneId}, ${u.left}%)`,top:T?"0%":`var(--pane-top-${u.paneId}, ${u.top}%)`,width:T?"100%":`var(--pane-width-${u.paneId}, ${u.width}%)`,height:T?"100%":`var(--pane-height-${u.paneId}, ${u.height}%)`,overflow:"hidden",zIndex:T?20:1,display:c&&!T?"none":"block",padding:T?"0px":`${t/2}px`,boxSizing:"border-box"},children:jsx(mn,{paneId:u.paneId,renderPane:o})},u.paneId)}),!c&&M.map(u=>jsx(gn,{splitter:u,resizerSize:t,snapThreshold:R,containerRef:x},u.id))]});if(e===void 0){let u=r!==null&&r===i,T=C=>{a(C),x.current=C;},L=`${h.dashboard||""} ${u&&h.dashboardDismissActive||""} ${f&&h.dashboardLocked||""}`.trim();return jsxs("div",{ref:T,className:L,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[N(),r!==null&&!f&&jsx(xt,{activeClassName:h.rootDropPreview??h.dropPreview})]})}return jsx("div",{ref:x,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:N()})};var Ce=createContext(null);var xn={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"}},Tn={top:{position:"absolute",top:0,left:0,right:0,height:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},bottom:{position:"absolute",bottom:0,left:0,right:0,height:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},left:{position:"absolute",top:0,bottom:0,left:0,width:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},right:{position:"absolute",top:0,bottom:0,right:0,width:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:21,pointerEvents:"none",boxSizing:"border-box"}},Se=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:s,isOver:o}=useDroppable({id:e});return jsxs(Fragment,{children:[jsx("div",{ref:s,style:xn[t]}),o&&jsx("div",{className:n,style:Tn[t]})]})};var Nn=({id:e,children:t,style:n,locked:s=false})=>{let o=useRef(null),{layout:r,activeId:i,classNames:a,fullscreenPaneId:c,onFullscreenChange:p,locked:f}=re(),{removePane:h,updateMetadata:R,selectTab:w,removeTab:x}=De(),E=useContext(Re);if(!E)throw new Error("Pane must be used within a Zeugma provider");let{registerPortalTarget:M}=E,N=useMemo(()=>ne(r,e),[r,e]),u=N?.id??e,T=N?.tabs??[e],L=N?.activeTabId??e,C=N?.tabsMetadata,z=C?.[e],_=N?.locked??false,U=s||_,F=f||U,q=f||U,G=i!==null&&i!==e&&(!T.includes(i)||T.length>1)&&!q,{attributes:oe,listeners:K,setNodeRef:le}=useDraggable({id:e,disabled:F}),g=i!==null&&T.includes(i),Z=c===e,A=useCallback(()=>jsx("div",{ref:o,id:`zeugma-tab-target-${L}`,className:"zeugma-tab-content-wrapper",style:{height:"100%",width:"100%"}}),[L]);useEffect(()=>{let P=o.current;return M(L,P),()=>{M(L,null);}},[L,M]);let H=useMemo(()=>({isDragging:g,isFullscreen:Z,toggleFullscreen:()=>p?.(Z?null:e),remove:()=>{Z&&p?.(null),h(u);},metadata:z,updateMetadata:P=>{R(e,P);},locked:F,tabs:T,activeTabId:L,selectTab:P=>w(u,P),removeTab:P=>{Z&&P===L&&p?.(null),x(P);},tabsMetadata:C,updateTabMetadata:(P,y)=>{R(P,y);},renderActiveTab:A}),[g,Z,p,e,x,z,R,F,T,L,w,u,C,A]),D=useMemo(()=>F?{disabled:true}:{...K,...oe},[K,oe,F]),l=`${a.pane||""} ${U&&a.paneLocked||""}`.trim();return jsx(Ce.Provider,{value:D,children:jsxs("div",{ref:le,className:l,style:{position:"relative",width:"100%",height:"100%",...n},children:[t(H),G&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(P=>jsx(Se,{id:`drop-${P}-${e}`,position:P,activeClassName:a.dropPreview},P))}),i!==null&&i!==e&&q&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsx(Se,{id:`drop-locked-${e}`,position:"full",activeClassName:a.lockedPreview||""})})]})})};var In=({children:e,className:t,style:n})=>{let s=useContext(Ce);if(!s)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:o,...r}=s;return jsx("div",{className:t,style:{cursor:o?"default":"grab",userSelect:o?"auto":"none",touchAction:o?"auto":"none",...n},...o?{}:r,children:e})};var Ct=createContext(void 0),An=()=>{let e=useContext(Ct);if(!e)throw new Error("useTabContext must be used within a Tab component");return e},St=({id:e,locked:t=false,children:n,className:s,style:o})=>{let{locked:r,classNames:i={},activeType:a}=re(),{overTabId:c}=Fe(),p=useContext(Qe),f=t||r||(p?.locked??false),{attributes:h,listeners:R,setNodeRef:w,isDragging:x}=useDraggable({id:`tab-header-${e}`,disabled:f}),{setNodeRef:E,isOver:M}=useDroppable({id:`tab-drop-${e}`,disabled:f||a==="pane"}),N=K=>{w(K),E(K);},u=M&&c===e,T=p?.tabs||[],L=T.indexOf(e),C=p?.activeTabId,_=L>0&&e!==C&&T[L-1]!==C?jsx("div",{className:i.tabSeparator}):null,U=p?p.activeTabId===e:false,F=p?.tabsMetadata?.[e],q=useCallback(()=>{p?.selectTab(e);},[p,e]),G=useCallback(()=>{p?.removeTab(e);},[p,e]),oe=useMemo(()=>({tabId:e,isActive:U,isDragging:x,isOver:u,metadata:F,locked:f,selectTab:q,removeTab:G}),[e,U,x,u,F,f,q,G]);return jsx(Ct.Provider,{value:oe,children:jsxs("div",{ref:N,className:s,style:{display:"inline-flex",position:"relative",cursor:f?"default":"grab",...o},...f?{}:R,...f?{}:h,children:[_,n({isDragging:x,isOver:u})]})})};var Qe=createContext(void 0);var Nt=(e,t)=>typeof e=="function"?e(t):e,Wn=({tabs:e,activeTabId:t,locked:n=false,tabsMetadata:s,selectTab:o,removeTab:r,renderTab:i,classNames:a,styles:c})=>{let{classNames:p={},activeType:f}=re(),{overTabId:h,overTabPosition:R}=Fe(),w=useMemo(()=>({tabs:e,activeTabId:t,locked:n,tabsMetadata:s,selectTab:o,removeTab:r}),[e,t,n,s,o,r]),x=ut(e,f,h,R);return jsx(Qe.Provider,{value:w,children:jsxs("div",{className:a?.container,style:{display:"flex",alignItems:"center",height:"100%",...c?.container},children:[e.map((E,M)=>{let N=s?.[E],u=Nt(a?.tab,E),T=Nt(c?.tab,E),L=M===x;return jsxs(qt.Fragment,{children:[L&&p.tabDropPreview&&jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsx("div",{className:p.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:M===0?"none":"translateX(-50%)"}})}),jsx(St,{id:E,locked:n,className:u,style:T,children:({isDragging:C,isOver:z})=>i({tabId:E,activeTabId:t,isDragging:C,isOver:z,metadata:N,selectTab:o,removeTab:r})})]},E)}),x===e.length&&p.tabDropPreview&&jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsx("div",{className:p.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:"translateX(-100%)"}})})]})})};var Jn=({id:e,children:t,style:n,locked:s=false})=>{let o=useRef(null),{layout:r,activeId:i,classNames:a,fullscreenPaneId:c,onFullscreenChange:p,locked:f}=re(),{removePane:h,updateMetadata:R}=De(),w=useContext(Re);if(!w)throw new Error("Widget must be used within a Zeugma provider");let{registerPortalTarget:x}=w,E=useMemo(()=>{if(!r)return null;if(r.type!=="split"&&r.id===e)return r;function g(Z){return Z?Z.type!=="split"&&Z.id===e?Z:Z.type==="split"?g(Z.first)??g(Z.second):null:null}return g(r)},[r,e]),M=E?.locked??false,N=s||M,u=f||N,T=f||N,L=i!==null&&i!==e&&!T,{attributes:C,listeners:z,setNodeRef:_}=useDraggable({id:e,disabled:u}),U=i===e,F=c===e,q=useCallback(()=>jsx("div",{ref:o,id:`zeugma-widget-target-${e}`,className:"zeugma-widget-content-wrapper",style:{height:"100%",width:"100%"}}),[e]);useEffect(()=>{let g=o.current;return x(e,g),()=>{x(e,null);}},[e,x]);let G=E&&"metadata"in E?E.metadata:void 0,oe=useMemo(()=>({isDragging:U,isFullscreen:F,toggleFullscreen:()=>p?.(F?null:e),remove:()=>{F&&p?.(null),h(e);},metadata:G,updateMetadata:g=>{R(e,g);},locked:u,renderActiveWidget:q}),[U,F,p,e,h,G,R,u,q]),K=useMemo(()=>u?{disabled:true}:{...z,...C},[z,C,u]),le=`${a.pane||""} ${N&&a.paneLocked||""}`.trim();return jsx(Ce.Provider,{value:K,children:jsxs("div",{ref:_,className:le,style:{position:"relative",width:"100%",height:"100%",...n},children:[t(oe),L&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(g=>jsx(Se,{id:`drop-${g}-${e}`,position:g,activeClassName:a.dropPreview},g))}),i!==null&&i!==e&&T&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsx(Se,{id:`drop-locked-${e}`,position:"full",activeClassName:a.lockedPreview||""})})]})})};export{$t as DEFAULT_DRAG_ACTIVATION_DISTANCE,Qn as DEFAULT_RESIZER_SIZE,kt as DEFAULT_SNAP_THRESHOLD,In as DragHandle,Nn as Pane,bn as PaneTree,Re as PortalRegistryContext,Wn as Tabs,Jn as Widget,en as Zeugma,Ye as ZeugmaActionsContext,Je as ZeugmaDragContext,Xe as ZeugmaStateContext,pt as createDragSession,Ze as safeJsonStringify,Ge as useResizer,An as useTabContext,zt as useZeugma,De as useZeugmaActions,At as useZeugmaContext,Fe as useZeugmaDrag,re as useZeugmaState};//# sourceMappingURL=index.js.map
|
|
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
|
|
7
7
|
//# sourceMappingURL=index.js.map
|