react-zeugma 6.2.2 → 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 -484
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -47
- package/dist/index.d.ts +82 -47
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/{types-Yvj0Isvy.d.cts → types-B9LrYapR.d.cts} +113 -128
- package/dist/{types-Yvj0Isvy.d.ts → types-B9LrYapR.d.ts} +113 -128
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +24 -9
- package/dist/utils.d.ts +24 -9
- 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-Yvj0Isvy.cjs';
|
|
2
|
-
export { g as PaneNode, h as TabDetails, i as ZeugmaClassNames } from './types-Yvj0Isvy.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). */
|
|
@@ -77,21 +79,23 @@ interface PaneTreeProps {
|
|
|
77
79
|
}
|
|
78
80
|
declare const PaneTree: React__default.FC<PaneTreeProps>;
|
|
79
81
|
|
|
80
|
-
interface
|
|
81
|
-
/** True if the
|
|
82
|
+
interface BaseLeafRenderProps {
|
|
83
|
+
/** True if the leaf is actively being dragged. */
|
|
82
84
|
isDragging: boolean;
|
|
83
|
-
/** True if the
|
|
85
|
+
/** True if the leaf currently occupies the fullscreen view. */
|
|
84
86
|
isFullscreen: boolean;
|
|
85
|
-
/** Toggles the
|
|
87
|
+
/** Toggles the leaf to and from fullscreen/zoomed mode. */
|
|
86
88
|
toggleFullscreen: () => void;
|
|
87
|
-
/** Closes and removes the
|
|
89
|
+
/** Closes and removes the leaf from the layout tree. */
|
|
88
90
|
remove: () => void;
|
|
89
|
-
/** The metadata values associated with
|
|
91
|
+
/** The metadata values associated with this leaf, or undefined. */
|
|
90
92
|
metadata: Record<string, unknown> | undefined;
|
|
91
|
-
/** Updates the metadata of
|
|
93
|
+
/** Updates the metadata of this leaf using an updater function. */
|
|
92
94
|
updateMetadata: (updater: (current: Record<string, unknown> | undefined) => Record<string, unknown> | undefined) => void;
|
|
93
|
-
/** True if this specific
|
|
95
|
+
/** True if this specific leaf or the dashboard globally is locked. */
|
|
94
96
|
locked: boolean;
|
|
97
|
+
}
|
|
98
|
+
interface PaneRenderProps extends BaseLeafRenderProps {
|
|
95
99
|
/** The array of tab IDs in this pane. */
|
|
96
100
|
tabs: string[];
|
|
97
101
|
/** The currently active tab ID. */
|
|
@@ -104,22 +108,8 @@ interface PaneRenderProps {
|
|
|
104
108
|
tabsMetadata: Record<string, Record<string, unknown>> | undefined;
|
|
105
109
|
/** Updates the metadata of a specific tab. */
|
|
106
110
|
updateTabMetadata: (tabId: string, updater: (current: Record<string, unknown> | undefined) => Record<string, unknown> | undefined) => void;
|
|
107
|
-
/** Renders the target placeholder element for the currently active tab in the pane. */
|
|
108
|
-
renderActiveTab: () => ReactNode;
|
|
109
111
|
}
|
|
110
112
|
|
|
111
|
-
interface PaneProps {
|
|
112
|
-
/** The unique ID of the pane, matching a `paneId` in the layout tree schema. */
|
|
113
|
-
id: string;
|
|
114
|
-
/** Render prop function providing pane state (isDragging, isFullscreen, etc.) and handlers. */
|
|
115
|
-
children: (props: PaneRenderProps) => React__default.ReactNode;
|
|
116
|
-
/** Optional inline CSS styles applied to the pane outer container. */
|
|
117
|
-
style?: React__default.CSSProperties;
|
|
118
|
-
/** Optional override to lock this specific pane. */
|
|
119
|
-
locked?: boolean;
|
|
120
|
-
}
|
|
121
|
-
declare const Pane: React__default.FC<PaneProps>;
|
|
122
|
-
|
|
123
113
|
interface DragHandleProps {
|
|
124
114
|
/** The children elements that will trigger dragging when held and dragged. */
|
|
125
115
|
children?: React__default.ReactNode;
|
|
@@ -130,19 +120,37 @@ interface DragHandleProps {
|
|
|
130
120
|
}
|
|
131
121
|
declare const DragHandle: React__default.FC<DragHandleProps>;
|
|
132
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
|
+
|
|
133
141
|
interface TabsProps {
|
|
134
142
|
/** The list of tab IDs in this pane. */
|
|
135
|
-
tabs
|
|
143
|
+
tabs?: string[];
|
|
136
144
|
/** The currently active tab ID. */
|
|
137
|
-
activeTabId
|
|
145
|
+
activeTabId?: string;
|
|
138
146
|
/** Whether dragging is locked on these tabs. */
|
|
139
147
|
locked?: boolean;
|
|
140
148
|
/** Metadata for the tabs. */
|
|
141
149
|
tabsMetadata?: Record<string, Record<string, unknown>>;
|
|
142
150
|
/** Callback when a tab is selected. */
|
|
143
|
-
selectTab
|
|
151
|
+
selectTab?: (id: string) => void;
|
|
144
152
|
/** Callback when a tab is closed/removed. */
|
|
145
|
-
removeTab
|
|
153
|
+
removeTab?: (id: string) => void;
|
|
146
154
|
/** Render function for each individual tab content. */
|
|
147
155
|
renderTab: (props: {
|
|
148
156
|
tabId: string;
|
|
@@ -150,8 +158,8 @@ interface TabsProps {
|
|
|
150
158
|
isDragging: boolean;
|
|
151
159
|
isOver: boolean;
|
|
152
160
|
metadata?: Record<string, unknown>;
|
|
153
|
-
|
|
154
|
-
|
|
161
|
+
onSelect: () => void;
|
|
162
|
+
onRemove: () => void;
|
|
155
163
|
}) => React__default.ReactNode;
|
|
156
164
|
/** Custom CSS classes for Tabs container and tab wrappers. */
|
|
157
165
|
classNames?: {
|
|
@@ -164,22 +172,49 @@ interface TabsProps {
|
|
|
164
172
|
tab?: React__default.CSSProperties | ((tabId: string) => React__default.CSSProperties);
|
|
165
173
|
};
|
|
166
174
|
}
|
|
167
|
-
declare const Tabs: React__default.FC<TabsProps
|
|
175
|
+
declare const Tabs: React__default.FC<TabsProps> & {
|
|
176
|
+
Tab: typeof Tab;
|
|
177
|
+
};
|
|
168
178
|
|
|
169
|
-
interface
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
selectTab: () => void;
|
|
177
|
-
removeTab: () => void;
|
|
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;
|
|
178
186
|
}
|
|
179
|
-
declare const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
187
|
+
declare const PaneControls: React__default.FC<PaneControlsProps>;
|
|
188
|
+
|
|
189
|
+
interface PaneContextValue extends PaneRenderProps {
|
|
190
|
+
id: string;
|
|
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. */
|
|
208
|
+
style?: React__default.CSSProperties;
|
|
209
|
+
/** Optional override to lock this specific pane. */
|
|
210
|
+
locked?: boolean;
|
|
183
211
|
}
|
|
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
|
+
};
|
|
184
219
|
|
|
185
|
-
export { DEFAULT_DRAG_ACTIVATION_DISTANCE, DEFAULT_RESIZER_SIZE, DEFAULT_SNAP_THRESHOLD,
|
|
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-Yvj0Isvy.js';
|
|
2
|
-
export { g as PaneNode, h as TabDetails, i as ZeugmaClassNames } from './types-Yvj0Isvy.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). */
|
|
@@ -77,21 +79,23 @@ interface PaneTreeProps {
|
|
|
77
79
|
}
|
|
78
80
|
declare const PaneTree: React__default.FC<PaneTreeProps>;
|
|
79
81
|
|
|
80
|
-
interface
|
|
81
|
-
/** True if the
|
|
82
|
+
interface BaseLeafRenderProps {
|
|
83
|
+
/** True if the leaf is actively being dragged. */
|
|
82
84
|
isDragging: boolean;
|
|
83
|
-
/** True if the
|
|
85
|
+
/** True if the leaf currently occupies the fullscreen view. */
|
|
84
86
|
isFullscreen: boolean;
|
|
85
|
-
/** Toggles the
|
|
87
|
+
/** Toggles the leaf to and from fullscreen/zoomed mode. */
|
|
86
88
|
toggleFullscreen: () => void;
|
|
87
|
-
/** Closes and removes the
|
|
89
|
+
/** Closes and removes the leaf from the layout tree. */
|
|
88
90
|
remove: () => void;
|
|
89
|
-
/** The metadata values associated with
|
|
91
|
+
/** The metadata values associated with this leaf, or undefined. */
|
|
90
92
|
metadata: Record<string, unknown> | undefined;
|
|
91
|
-
/** Updates the metadata of
|
|
93
|
+
/** Updates the metadata of this leaf using an updater function. */
|
|
92
94
|
updateMetadata: (updater: (current: Record<string, unknown> | undefined) => Record<string, unknown> | undefined) => void;
|
|
93
|
-
/** True if this specific
|
|
95
|
+
/** True if this specific leaf or the dashboard globally is locked. */
|
|
94
96
|
locked: boolean;
|
|
97
|
+
}
|
|
98
|
+
interface PaneRenderProps extends BaseLeafRenderProps {
|
|
95
99
|
/** The array of tab IDs in this pane. */
|
|
96
100
|
tabs: string[];
|
|
97
101
|
/** The currently active tab ID. */
|
|
@@ -104,22 +108,8 @@ interface PaneRenderProps {
|
|
|
104
108
|
tabsMetadata: Record<string, Record<string, unknown>> | undefined;
|
|
105
109
|
/** Updates the metadata of a specific tab. */
|
|
106
110
|
updateTabMetadata: (tabId: string, updater: (current: Record<string, unknown> | undefined) => Record<string, unknown> | undefined) => void;
|
|
107
|
-
/** Renders the target placeholder element for the currently active tab in the pane. */
|
|
108
|
-
renderActiveTab: () => ReactNode;
|
|
109
111
|
}
|
|
110
112
|
|
|
111
|
-
interface PaneProps {
|
|
112
|
-
/** The unique ID of the pane, matching a `paneId` in the layout tree schema. */
|
|
113
|
-
id: string;
|
|
114
|
-
/** Render prop function providing pane state (isDragging, isFullscreen, etc.) and handlers. */
|
|
115
|
-
children: (props: PaneRenderProps) => React__default.ReactNode;
|
|
116
|
-
/** Optional inline CSS styles applied to the pane outer container. */
|
|
117
|
-
style?: React__default.CSSProperties;
|
|
118
|
-
/** Optional override to lock this specific pane. */
|
|
119
|
-
locked?: boolean;
|
|
120
|
-
}
|
|
121
|
-
declare const Pane: React__default.FC<PaneProps>;
|
|
122
|
-
|
|
123
113
|
interface DragHandleProps {
|
|
124
114
|
/** The children elements that will trigger dragging when held and dragged. */
|
|
125
115
|
children?: React__default.ReactNode;
|
|
@@ -130,19 +120,37 @@ interface DragHandleProps {
|
|
|
130
120
|
}
|
|
131
121
|
declare const DragHandle: React__default.FC<DragHandleProps>;
|
|
132
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
|
+
|
|
133
141
|
interface TabsProps {
|
|
134
142
|
/** The list of tab IDs in this pane. */
|
|
135
|
-
tabs
|
|
143
|
+
tabs?: string[];
|
|
136
144
|
/** The currently active tab ID. */
|
|
137
|
-
activeTabId
|
|
145
|
+
activeTabId?: string;
|
|
138
146
|
/** Whether dragging is locked on these tabs. */
|
|
139
147
|
locked?: boolean;
|
|
140
148
|
/** Metadata for the tabs. */
|
|
141
149
|
tabsMetadata?: Record<string, Record<string, unknown>>;
|
|
142
150
|
/** Callback when a tab is selected. */
|
|
143
|
-
selectTab
|
|
151
|
+
selectTab?: (id: string) => void;
|
|
144
152
|
/** Callback when a tab is closed/removed. */
|
|
145
|
-
removeTab
|
|
153
|
+
removeTab?: (id: string) => void;
|
|
146
154
|
/** Render function for each individual tab content. */
|
|
147
155
|
renderTab: (props: {
|
|
148
156
|
tabId: string;
|
|
@@ -150,8 +158,8 @@ interface TabsProps {
|
|
|
150
158
|
isDragging: boolean;
|
|
151
159
|
isOver: boolean;
|
|
152
160
|
metadata?: Record<string, unknown>;
|
|
153
|
-
|
|
154
|
-
|
|
161
|
+
onSelect: () => void;
|
|
162
|
+
onRemove: () => void;
|
|
155
163
|
}) => React__default.ReactNode;
|
|
156
164
|
/** Custom CSS classes for Tabs container and tab wrappers. */
|
|
157
165
|
classNames?: {
|
|
@@ -164,22 +172,49 @@ interface TabsProps {
|
|
|
164
172
|
tab?: React__default.CSSProperties | ((tabId: string) => React__default.CSSProperties);
|
|
165
173
|
};
|
|
166
174
|
}
|
|
167
|
-
declare const Tabs: React__default.FC<TabsProps
|
|
175
|
+
declare const Tabs: React__default.FC<TabsProps> & {
|
|
176
|
+
Tab: typeof Tab;
|
|
177
|
+
};
|
|
168
178
|
|
|
169
|
-
interface
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
selectTab: () => void;
|
|
177
|
-
removeTab: () => void;
|
|
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;
|
|
178
186
|
}
|
|
179
|
-
declare const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
187
|
+
declare const PaneControls: React__default.FC<PaneControlsProps>;
|
|
188
|
+
|
|
189
|
+
interface PaneContextValue extends PaneRenderProps {
|
|
190
|
+
id: string;
|
|
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. */
|
|
208
|
+
style?: React__default.CSSProperties;
|
|
209
|
+
/** Optional override to lock this specific pane. */
|
|
210
|
+
locked?: boolean;
|
|
183
211
|
}
|
|
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
|
+
};
|
|
184
219
|
|
|
185
|
-
export { DEFAULT_DRAG_ACTIVATION_DISTANCE, DEFAULT_RESIZER_SIZE, DEFAULT_SNAP_THRESHOLD,
|
|
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=l=>{n(l);},a=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let l=document.getElementById("zeugma-global-cursor-style");l&&l.remove(),document.removeEventListener("pointermove",r),document.removeEventListener("pointerup",a),s();};document.addEventListener("pointermove",r),document.addEventListener("pointerup",a);}var Ye=createContext(void 0),Je=createContext(void 0),ze=createContext(void 0),qe=createContext(void 0),ae=()=>{let e=useContext(Ye);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},Ae=()=>{let e=useContext(Je);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},He=()=>{let e=useContext(qe);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};var kt=()=>{let e=ae(),t=Ae();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 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 pt(e){let{layout:t,_internalSetLayout:n,layoutBeforeDrag:s,setLayoutBeforeDrag:o,activeId:r,setActiveId:a,setActiveType:l,dismissIntentId:d,setDismissIntentId:p,setOverTabId:g,setOverTabPosition:x,containerRef:y,dragActivationDistance:S,enableDragToDismiss:P,dismissThreshold:k,onRemove:I,onDragStart:M,onDragEnd:u,onDismissIntentChange:T,removeTab:N}=e,E=useRef(null),A=nt(r),[J,q]=useState(false);ot(J);let V=useSensors(useSensor(Oe,{activationConstraint:{distance:S}}),useSensor(Be,{activationConstraint:{delay:250,tolerance:5}})),ee=useCallback(D=>{let $=D.active.id.toString().startsWith("tab-header-"),z=pointerWithin(D),R=$?z:z.filter(i=>!i.id.toString().startsWith("tab-drop-"));if(R.length>0)return [...R].sort((h,v)=>{let b=h.id.toString(),W=v.id.toString();if($){let F=b.startsWith("tab-drop-"),G=W.startsWith("tab-drop-");if(F&&!G)return -1;if(!F&&G)return 1}let B=b.startsWith("drop-root-"),f=W.startsWith("drop-root-");return B&&!f?-1:!B&&f?1:0});if($){let i=D.droppableContainers.filter(h=>h.id.toString().startsWith("tab-drop-"));return closestCenter({...D,droppableContainers:i})}return []},[]);return {sensors:V,collisionDetection:ee,onDragStart:D=>{let O=D.active.id.toString(),$=O.startsWith("tab-header-"),z=$?O.substring(11):O;a(z),l($?"tab":"pane"),g(null),x(null);let R=D.activatorEvent;A.current=Fe(R),P&&y.current?E.current=y.current.getBoundingClientRect():E.current=null;let i=t;if($){let h=_(t,z);h&&(i=ye(t,h.id,z)||t);}o(i),$&&i!==t&&n(i),M&&M(z);},onDragMove:D=>{let{over:O}=D,$=O?.id.toString()||"",z=$.startsWith("drop-locked-");q(m=>m===z?m:z);let R=D.active.id.toString(),i=R.startsWith("tab-header-"),h=i?R.substring(11):R,v=$.match(/^tab-drop-(.+)$/);if(v&&O&&i){let[,m]=v;if(h!==m){let C="before",Z=O.rect,oe=D.activatorEvent,K=null;if(A.current)K=A.current.x;else {let Q=Fe(oe);Q&&(K=Q.x+D.delta.x);}if(K!==null){let Q=Z.left+Z.width/2;K>Q&&(C="after");}g(Q=>Q===m?Q:m),x(Q=>Q===C?Q:C);}else g(C=>C===null?C:null),x(C=>C===null?C:null);}else g(m=>m===null?m:null),x(m=>m===null?m:null);if(!P)return;let b=E.current;if(!b){d!==null&&(p(null),T?.(null));return}let W=D.activatorEvent,B=null,f=null;if(A.current)B=A.current.x,f=A.current.y;else {let m=Fe(W);m&&(B=m.x+D.delta.x,f=m.y+D.delta.y);}let F=0;if(B!==null&&f!==null){let m=0,C=0;B<b.left?m=b.left-B:B>b.right&&(m=B-b.right),f<b.top?C=b.top-f:f>b.bottom&&(C=f-b.bottom),F=Math.sqrt(m*m+C*C);}else {let m=D.active.rect.current.translated;if(m){let C=m.left+m.width/2,Z=m.top+m.height/2,oe=0,K=0;C<b.left?oe=b.left-C:C>b.right&&(oe=C-b.right),Z<b.top?K=b.top-Z:Z>b.bottom&&(K=Z-b.bottom),F=Math.sqrt(oe*oe+K*K);}}F>k?d!==h&&(p(h),T?.(h)):d!==null&&(p(null),T?.(null));},onDragEnd:D=>{a(null),l(null),q(false),g(null),x(null);let{active:O,over:$}=D,z=O.id.toString(),R=z.startsWith("tab-header-"),i=R?z.substring(11):z,h=P&&d===i;p(null),T?.(null),E.current=null;let v=s||t;if(o(null),h){I?I(i):N(i),u&&u(i,null,null);return}if(!$){n(v),u&&u(i,null,null);return}let b=$.id.toString();if(b.startsWith("drop-locked-")){n(v),u&&u(i,null,null);return}let W=b.match(/^tab-drop-(.+)$/);if(W){if(!R){n(v),u&&u(i,null,null);return}let[,ce]=W;if(i!==ce){let ue="before",L=$.rect,re=D.activatorEvent,Y=null;if(A.current)Y=A.current.x;else {let se=Fe(re);se&&(Y=se.x+D.delta.x);}if(Y!==null){let se=L.left+L.width/2;Y>se&&(ue="after");}let me=Ze(v,i,ce,ue);n(me),u&&u(i,ce,{type:"move",position:"center"});}else n(v),u&&u(i,null,null);return}let B=b.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(B){let[,ce,ue]=B,L=ue;L==="start"&&(L="left"),L==="end"&&(L="right");let re=R?fe(v,i):be(v,i),Y;if(R){let se=_(v,i)?.tabsMetadata?.[i];Y={type:"pane",id:de(),tabs:[i],activeTabId:i,tabsMetadata:se?{[i]:se}:void 0};}else Y=j(v,i)??{type:"pane",id:de(),tabs:[i],activeTabId:i};if(re===null)n(Y);else {let me=L==="left"||L==="right",se=L==="left"||L==="top",we=50;ce==="1/4"?we=se?25:75:ce==="1/3"&&(we=se?100/3:200/3),n({type:"split",direction:me?"row":"column",first:se?Y:re,second:se?re:Y,splitPercentage:we});}u&&u(i,"root",{type:"split",direction:L==="left"||L==="right"?"row":"column",position:L});return}let f=b.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!f){n(v),u&&u(i,null,null);return}let[,F,G]=f,m=R?_(v,i):j(v,i),C=m&&m.id===G,Z=m&&m.tabs.length===1;if(i===G||C&&Z){n(v),u&&u(i,null,null);return}let oe=F==="left"||F==="right"?"row":"column",K;if(R){let ue=_(v,i)?.tabsMetadata?.[i];K={type:"pane",id:de(),tabs:[i],activeTabId:i,tabsMetadata:ue?{[i]:ue}:void 0};}else K=j(v,i)??{type:"pane",id:de(),tabs:[i],activeTabId:i};let Q=R?fe(v,i):be(v,i),Se=Re(Q,G,oe,F,K);n(Se),u&&u(i,G,{type:"split",direction:oe,position:F});},onDragCancel:()=>{a(null),l(null),q(false),g(null),x(null),p(null),T?.(null),E.current=null,s!==null&&(n(s),o(null));}}}var ft=({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 gt=Xt.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 l=r.current;if(t)t.appendChild(l);else {let d=document.getElementById("zeugma-hidden-portal-container");d||(d=document.createElement("div"),d.id="zeugma-hidden-portal-container",d.style.display="none",document.body.appendChild(d)),d.appendChild(l);}},[t,s]),useEffect(()=>()=>{r.current&&r.current.remove();},[]),!s)return null;r.current||(r.current=document.createElement("div"),r.current.className=`zeugma-portal-wrapper-${e}`,r.current.style.width="100%",r.current.style.height="100%");let a=r.current;return !a||!n?null:createPortal(n(e),a)});var Kt=e=>{let t=e,{renderPane:n,renderWidget:s,renderDragOverlay:o,classNames:r={},children:a,layout:l,setLayout:d,fullscreenPaneId:p,setFullscreenPaneId:g,locked:x,setLocked:y,findPaneById:S,findPaneContainingTab:P,findTabById:k,activeId:I,activeType:M,dismissIntentId:u,setContainerRef:T,layoutBeforeDrag:N,snapThreshold:E,minSplitPercentage:A,maxSplitPercentage:J,onRemove:q,onResizeStart:V,onResize:ee,onResizeEnd:te,removePane:ie,addPane:ne,addTab:le,updateTabMetadata:D,updatePaneLock:O,selectTab:$,mergeTab:z,removeTab:R,splitPane:i,updateSplitPercentage:h,moveTab:v}=t,{portalTargets:b,registerPortalTarget:W}=rt(),[B,f]=useState(null),[F,G]=useState(null),m=pt({...t,setOverTabId:f,setOverTabPosition:G}),C=useCallback(L=>n(L),[n]),Z=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]),oe=useCallback((L,re)=>{te&&te(L,re);},[te]),K=useMemo(()=>({layout:l,setLayout:d,renderPane:C,activeId:I,activeType:M,dismissIntentId:u,setContainerRef:T,fullscreenPaneId:p,classNames:Z,onRemove:q,onFullscreenChange:g,snapThreshold:E,onResizeStart:V,onResize:ee,onResizeEnd:oe,minSplitPercentage:A,maxSplitPercentage:J,locked:x,setLocked:y,findPaneById:S,findPaneContainingTab:P,findTabById:k}),[l,I,M,u,T,p,Z,q,g,E,V,ee,A,J,d,C,oe,x,y,S,P,k]),Q=useMemo(()=>({overTabId:B,overTabPosition:F}),[B,F]),Se=useMemo(()=>({removePane:ie,addPane:ne,addTab:le,updateTabMetadata:D,updatePaneLock:O,selectTab:$,mergeTab:z,removeTab:R,setFullscreenPaneId:g,setLocked:y,splitPane:i,updateSplitPercentage:h,moveTab:v}),[ie,ne,le,D,O,$,z,R,g,y,i,h,v]),ce=useMemo(()=>{let L=new Set;function re(Y){Y&&(Y.type==="pane"?Y.tabs.forEach(me=>{L.add(me);}):(re(Y.first),re(Y.second)));}return re(l),N&&re(N),Array.from(L).sort()},[l,I,N]),ue=useMemo(()=>({registerPortalTarget:W}),[W]);return jsx(Je.Provider,{value:Se,children:jsx(Ye.Provider,{value:K,children:jsx(qe.Provider,{value:Q,children:jsxs(ze.Provider,{value:ue,children:[jsx(DndContext,{id:"zeugma-dnd-context",...m,children:a}),I&&M&&o&&jsx(ft,{activeId:I,render:L=>o(L,M),className:`${r.dragOverlay||""} ${I===u&&r.dismissPreview||""}`.trim()}),jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:ce.map(L=>jsx(gt,{tabId:L,target:b[L]||null,renderWidget:s},L))})]})})})})};var en={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"}}},nn=({id:e,fraction:t,edge:n,activeClassName:s})=>{let{setNodeRef:o,isOver:r}=useDroppable({id:e}),a={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...tn[n][t]};return jsxs(Fragment,{children:[jsx("div",{ref:o,style:en[n][t]}),r&&jsx("div",{className:s,style:a})]})},ht=({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(nn,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});function Ke({containerRef:e,isRow:t,direction:n,splitPercentage:s,resizerSize:o,snapThreshold:r,layout:a,currentNode:l,onLayoutChange:d,onResizeStart:p,onResizeEnd:g,parentLeft:x,parentTop:y,parentWidth:S,parentHeight:P}){let{onResizeStart:k,onResize:I,onResizeEnd:M,minSplitPercentage:u=5,maxSplitPercentage:T=95,locked:N=false}=ae();return useCallback(E=>{if(N)return;E.preventDefault();let A=e.current;if(!A)return;p&&p(),k&&k(l);let J=A.getBoundingClientRect(),q=E.clientX,V=E.clientY,ee=s,te=E.currentTarget,ie=J.left+J.width*(x/100),ne=J.top+J.height*(y/100),le=J.width*(S/100),D=J.height*(P/100),$=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(R=>R!==te&&R.getAttribute("data-direction")===n).map(R=>{let i=R.getBoundingClientRect();return t?i.left+i.width/2:i.top+i.height/2}),z=ee;ut({cursor:t?"col-resize":"row-resize",resizerEl:te,onMove:R=>{let i=t?(R.clientX-q)/le*100:(R.clientY-V)/D*100,h=ee+i,v=t?ie+(le-o)*(h/100)+o/2:ne+(D-o)*(h/100)+o/2,b=1/0,W=null;for(let G of $){let m=Math.abs(v-G);m<r&&m<b&&(b=m,W=G);}let B=h;W!==null&&(B=t?(W-o/2-ie)/(le-o)*100:(W-o/2-ne)/(D-o)*100);let f=Math.max(u,Math.min(T,B));z=f;let F=xe(a,l,f);if(F){let{panes:G,splitters:m}=ge(F),C=e.current;if(C){for(let Z of G)C.style.setProperty(`--pane-left-${Z.paneId}`,`${Z.left}%`),C.style.setProperty(`--pane-top-${Z.paneId}`,`${Z.top}%`),C.style.setProperty(`--pane-width-${Z.paneId}`,`${Z.width}%`),C.style.setProperty(`--pane-height-${Z.paneId}`,`${Z.height}%`);for(let Z of m)C.style.setProperty(`--splitter-pos-${Z.id}`,`${Z.direction==="row"?Z.left:Z.top}%`);}}I&&I(l,f);},onEnd:()=>{let R=xe(a,l,z),i=e.current;if(i){let{panes:h,splitters:v}=ge(R);for(let b of h)i.style.removeProperty(`--pane-left-${b.paneId}`),i.style.removeProperty(`--pane-top-${b.paneId}`),i.style.removeProperty(`--pane-width-${b.paneId}`),i.style.removeProperty(`--pane-height-${b.paneId}`);for(let b of v)i.style.removeProperty(`--splitter-pos-${b.id}`);}d(R),g&&g(),M&&M(l,z);}});},[e,t,n,s,o,r,a,l,d,p,g,k,I,M,u,T,x,y,S,P])}var dn=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:s})=>{let{layout:o,setLayout:r,classNames:a,locked:l}=ae(),[d,p]=useState(false),{currentNode:g,direction:x,left:y,top:S,width:P,height:k,parentLeft:I,parentTop:M,parentWidth:u,parentHeight:T}=e,N=x==="row",E=Ke({containerRef:s,isRow:N,direction:x,splitPercentage:g.splitPercentage,resizerSize:t,snapThreshold:n,layout:o,currentNode:g,onLayoutChange:r,onResizeStart:()=>p(true),onResizeEnd:()=>p(false),parentLeft:I,parentTop:M,parentWidth:u,parentHeight:T}),A=N?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${y}%) - ${t/2}px)`,top:`calc(${S}% + ${t/2}px)`,width:`${t}px`,height:`calc(${k}% - ${t}px)`,cursor:l?"default":"col-resize",pointerEvents:l?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${y}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${S}%) - ${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":x,"data-resizing":d||void 0,style:A,onPointerDown:E,role:"separator","aria-valuenow":g.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},pn=Xt.memo(({paneId:e,renderPane:t})=>jsx(Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane),fn=({tree:e,resizerSize:t=4,snapThreshold:n})=>{let{layout:s,renderPane:o,activeId:r,dismissIntentId:a,setContainerRef:l,fullscreenPaneId:d,snapThreshold:p,locked:g,classNames:x}=ae(),y=n!==void 0?n:p??8,S=e!==void 0?e:s,P=useRef(null),{panes:k,splitters:I}=useMemo(()=>S?ge(S):{panes:[],splitters:[]},[S]);if(!S)return null;let M=()=>jsxs(Fragment,{children:[k.map(u=>{let T=d===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:d&&!T?"none":"block",padding:T?"0px":`${t/2}px`,boxSizing:"border-box"},children:jsx(pn,{paneId:u.paneId,renderPane:o})},u.paneId)}),!d&&I.map(u=>jsx(dn,{splitter:u,resizerSize:t,snapThreshold:y,containerRef:P},u.id))]});if(e===void 0){let u=r!==null&&r===a,T=E=>{l(E),P.current=E;},N=`${x.dashboard||""} ${u&&x.dashboardDismissActive||""} ${g&&x.dashboardLocked||""}`.trim();return jsxs("div",{ref:T,className:N,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[M(),r!==null&&!g&&jsx(ht,{activeClassName:x.rootDropPreview??x.dropPreview})]})}return jsx("div",{ref:P,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:M()})};var We=createContext(null);var Pn={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"}},Rn={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"}},Tt=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:s,isOver:o}=useDroppable({id:e});return jsxs(Fragment,{children:[jsx("div",{ref:s,style:Pn[t]}),o&&jsx("div",{className:n,style:Rn[t]})]})},yn=({id:e,children:t,style:n,locked:s=false})=>{let o=useRef(null),{layout:r,activeId:a,classNames:l,fullscreenPaneId:d,onFullscreenChange:p,locked:g}=ae(),{removePane:x,updateTabMetadata:y,selectTab:S,removeTab:P}=Ae(),k=useContext(ze);if(!k)throw new Error("Pane must be used within a Zeugma provider");let{registerPortalTarget:I}=k,M=useMemo(()=>j(r,e),[r,e]),u=M?.id??e,T=M?.tabs??[e],N=M?.activeTabId??e,E=M?.tabsMetadata,A=E?.[e],J=M?.locked??false,q=s||J,V=g||q,ee=g||q,te=a!==null&&a!==e&&(!T.includes(a)||T.length>1)&&!ee,{attributes:ie,listeners:ne,setNodeRef:le}=useDraggable({id:e,disabled:V}),D=a!==null&&T.includes(a),O=d===e,$=useCallback(()=>jsx("div",{ref:o,id:`zeugma-tab-target-${N}`,className:"zeugma-tab-content-wrapper",style:{height:"100%",width:"100%"}}),[N]);useEffect(()=>{let h=o.current;return I(N,h),()=>{I(N,null);}},[N,I]);let z=useMemo(()=>({isDragging:D,isFullscreen:O,toggleFullscreen:()=>p?.(O?null:e),remove:()=>{O&&p?.(null),x(u);},metadata:A,updateMetadata:h=>{y(e,h);},locked:V,tabs:T,activeTabId:N,selectTab:h=>S(u,h),removeTab:h=>{O&&h===N&&p?.(null),P(h);},tabsMetadata:E,updateTabMetadata:(h,v)=>{y(h,v);},renderActiveTab:$}),[D,O,p,e,P,A,y,V,T,N,S,u,E,$]),R=useMemo(()=>V?{disabled:true}:{...ne,...ie},[ne,ie,V]),i=`${l.pane||""} ${q&&l.paneLocked||""}`.trim();return jsx(We.Provider,{value:R,children:jsxs("div",{ref:le,className:i,style:{position:"relative",width:"100%",height:"100%",...n},children:[t(z),te&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(h=>jsx(Tt,{id:`drop-${h}-${e}`,position:h,activeClassName:l.dropPreview},h))}),a!==null&&a!==e&&ee&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsx(Tt,{id:`drop-locked-${e}`,position:"full",activeClassName:l.lockedPreview||""})})]})})};var Sn=({children:e,className:t,style:n})=>{let s=useContext(We);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),Mn=()=>{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:a={},activeType:l}=ae(),{overTabId:d}=He(),p=useContext(je),g=t||r||(p?.locked??false),{attributes:x,listeners:y,setNodeRef:S,isDragging:P}=useDraggable({id:`tab-header-${e}`,disabled:g}),{setNodeRef:k,isOver:I}=useDroppable({id:`tab-drop-${e}`,disabled:g||l==="pane"}),M=ne=>{S(ne),k(ne);},u=I&&d===e,T=p?.tabs||[],N=T.indexOf(e),E=p?.activeTabId,J=N>0&&e!==E&&T[N-1]!==E?jsx("div",{className:a.tabSeparator}):null,q=p?p.activeTabId===e:false,V=p?.tabsMetadata?.[e],ee=useCallback(()=>{p?.selectTab(e);},[p,e]),te=useCallback(()=>{p?.removeTab(e);},[p,e]),ie=useMemo(()=>({tabId:e,isActive:q,isDragging:P,isOver:u,metadata:V,locked:g,selectTab:ee,removeTab:te}),[e,q,P,u,V,g,ee,te]);return jsx(Ct.Provider,{value:ie,children:jsxs("div",{ref:M,className:s,style:{display:"inline-flex",position:"relative",cursor:g?"default":"grab",...o},...g?{}:y,...g?{}:x,children:[J,n({isDragging:P,isOver:u})]})})};var je=createContext(void 0);var wt=(e,t)=>typeof e=="function"?e(t):e,An=({tabs:e,activeTabId:t,locked:n=false,tabsMetadata:s,selectTab:o,removeTab:r,renderTab:a,classNames:l,styles:d})=>{let{classNames:p={},activeType:g}=ae(),{overTabId:x,overTabPosition:y}=He(),S=useMemo(()=>({tabs:e,activeTabId:t,locked:n,tabsMetadata:s,selectTab:o,removeTab:r}),[e,t,n,s,o,r]),P=lt(e,g,x,y);return jsx(je.Provider,{value:S,children:jsxs("div",{className:l?.container,style:{display:"flex",alignItems:"center",height:"100%",...d?.container},children:[e.map((k,I)=>{let M=s?.[k],u=wt(l?.tab,k),T=wt(d?.tab,k),N=I===P;return jsxs(Xt.Fragment,{children:[N&&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:I===0?"none":"translateX(-50%)"}})}),jsx(St,{id:k,locked:n,className:u,style:T,children:({isDragging:E,isOver:A})=>a({tabId:k,activeTabId:t,isDragging:E,isOver:A,metadata:M,selectTab:o,removeTab:r})})]},k)}),P===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%)"}})})]})})};export{Mt as DEFAULT_DRAG_ACTIVATION_DISTANCE,Bn as DEFAULT_RESIZER_SIZE,It as DEFAULT_SNAP_THRESHOLD,Sn as DragHandle,yn as Pane,fn as PaneTree,ze as PortalRegistryContext,An as Tabs,Kt as Zeugma,Je as ZeugmaActionsContext,qe as ZeugmaDragContext,Ye as ZeugmaStateContext,ut as createDragSession,Ee as safeJsonStringify,Ke as useResizer,Mn as useTabContext,Zt as useZeugma,Ae as useZeugmaActions,kt as useZeugmaContext,He as useZeugmaDrag,ae 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
|