react-zeugma 4.1.1 → 5.0.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 +38 -6
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +180 -155
- package/dist/index.d.ts +180 -155
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { Dispatch, SetStateAction, ReactNode, RefObject } from 'react';
|
|
3
|
+
|
|
4
|
+
declare const DEFAULT_SNAP_THRESHOLD = 8;
|
|
5
|
+
declare const DEFAULT_DRAG_ACTIVATION_DISTANCE = 8;
|
|
6
|
+
declare const DEFAULT_RESIZER_SIZE = 4;
|
|
2
7
|
|
|
3
8
|
type SplitDirection = 'row' | 'column';
|
|
4
9
|
interface SplitNode {
|
|
@@ -17,13 +22,12 @@ interface PaneNode {
|
|
|
17
22
|
tabsMetadata?: Record<string, Record<string, unknown>>;
|
|
18
23
|
}
|
|
19
24
|
type TreeNode = SplitNode | PaneNode;
|
|
20
|
-
|
|
21
25
|
interface UseZeugmaOptions {
|
|
22
26
|
/** Initial layout tree model defining pane organization for uncontrolled mode. Only used on initial mount. */
|
|
23
27
|
initialLayout?: TreeNode | null;
|
|
24
28
|
/** Controlled layout tree model. If provided, the hook will run in controlled mode and sync with this value. */
|
|
25
29
|
layout?: TreeNode | null;
|
|
26
|
-
/** Callback triggered when the layout changes via drag-and-drop actions, splits,
|
|
30
|
+
/** Callback triggered when the layout changes via drag-and-drop actions, splits, moves, or resizes. */
|
|
27
31
|
onChange?: (newLayout: TreeNode | null) => void;
|
|
28
32
|
/** The ID of the pane that is currently taking up the full dashboard area. Null if no pane is fullscreen. */
|
|
29
33
|
fullscreenPaneId?: string | null;
|
|
@@ -47,9 +51,9 @@ interface UseZeugmaOptions {
|
|
|
47
51
|
onRemove?: (paneId: string) => void;
|
|
48
52
|
/** Callback triggered when dragging starts for a pane. */
|
|
49
53
|
onDragStart?: (activeId: string) => void;
|
|
50
|
-
/** Callback triggered when dragging ends, providing details on target pane and drop action (split or
|
|
54
|
+
/** Callback triggered when dragging ends, providing details on target pane and drop action (split or move). */
|
|
51
55
|
onDragEnd?: (activeId: string, overId: string | null, dropAction: {
|
|
52
|
-
type: 'split' | '
|
|
56
|
+
type: 'split' | 'move';
|
|
53
57
|
direction?: SplitDirection;
|
|
54
58
|
position?: 'top' | 'bottom' | 'left' | 'right' | 'center';
|
|
55
59
|
} | null) => void;
|
|
@@ -63,12 +67,35 @@ interface UseZeugmaOptions {
|
|
|
63
67
|
onDismissIntentChange?: (paneId: string | null) => void;
|
|
64
68
|
}
|
|
65
69
|
interface ZeugmaController {
|
|
70
|
+
/** The current active layout tree structure, or null if empty. */
|
|
66
71
|
layout: TreeNode | null;
|
|
72
|
+
/** Updates the layout tree. */
|
|
67
73
|
setLayout: Dispatch<SetStateAction<TreeNode | null>>;
|
|
74
|
+
/** The ID of the pane currently zoomed to fullscreen, or null. */
|
|
68
75
|
fullscreenPaneId: string | null;
|
|
76
|
+
/** Programmatically sets the fullscreen pane ID. */
|
|
69
77
|
setFullscreenPaneId: (paneId: string | null) => void;
|
|
78
|
+
/** Whether the layout is globally locked. */
|
|
70
79
|
locked: boolean;
|
|
80
|
+
/** Programmatically updates the global locked status. */
|
|
71
81
|
setLocked: Dispatch<SetStateAction<boolean>>;
|
|
82
|
+
/** Removes the specified pane from the layout tree and collapses its parent split. */
|
|
83
|
+
removePane: (paneId: string) => void;
|
|
84
|
+
/** Appends/inserts a pane at the bottom-rightmost leaf of the layout tree. */
|
|
85
|
+
addPane: (paneId: string) => void;
|
|
86
|
+
/** Stable callback to update metadata for a specific tab. */
|
|
87
|
+
updateTabMetadata: (tabId: string, updater: (current: Record<string, unknown> | undefined) => Record<string, unknown> | undefined) => void;
|
|
88
|
+
/** Stable callback to update the locked status of a specific pane in the layout tree. */
|
|
89
|
+
updatePaneLock: (paneId: string, locked: boolean) => void;
|
|
90
|
+
/** Stable callback to activate a tab within a pane. */
|
|
91
|
+
selectTab: (paneId: string, tabId: string) => void;
|
|
92
|
+
/** Stable callback to merge a dragged tab/pane into another pane's tab list. */
|
|
93
|
+
mergeTab: (draggedTabId: string, targetPaneId: string) => void;
|
|
94
|
+
/** Stable callback to remove/close a specific tab from the layout. */
|
|
95
|
+
removeTab: (tabId: string) => void;
|
|
96
|
+
}
|
|
97
|
+
/** @internal */
|
|
98
|
+
interface ZeugmaInternalController extends ZeugmaController {
|
|
72
99
|
activeId: string | null;
|
|
73
100
|
setActiveId: Dispatch<SetStateAction<string | null>>;
|
|
74
101
|
activeType: 'pane' | 'tab' | null;
|
|
@@ -86,7 +113,7 @@ interface ZeugmaController {
|
|
|
86
113
|
onRemove?: (paneId: string) => void;
|
|
87
114
|
onDragStart?: (activeId: string) => void;
|
|
88
115
|
onDragEnd?: (activeId: string, overId: string | null, dropAction: {
|
|
89
|
-
type: 'split' | '
|
|
116
|
+
type: 'split' | 'move';
|
|
90
117
|
direction?: SplitDirection;
|
|
91
118
|
position?: 'top' | 'bottom' | 'left' | 'right' | 'center';
|
|
92
119
|
} | null) => void;
|
|
@@ -94,18 +121,15 @@ interface ZeugmaController {
|
|
|
94
121
|
onResize?: (currentNode: SplitNode, percentage: number) => void;
|
|
95
122
|
onResizeEnd?: (currentNode: SplitNode, percentage: number) => void;
|
|
96
123
|
onDismissIntentChange?: (paneId: string | null) => void;
|
|
97
|
-
removePane: (paneId: string) => void;
|
|
98
|
-
addPane: (paneId: string) => void;
|
|
99
124
|
splitPane: (targetId: string, direction: SplitDirection, splitType: 'left' | 'right' | 'top' | 'bottom', paneToAdd: string) => void;
|
|
100
125
|
updateSplitPercentage: (currentNode: SplitNode, percentage: number) => void;
|
|
101
|
-
updateTabMetadata: (tabId: string, updater: (current: Record<string, unknown> | undefined) => Record<string, unknown> | undefined) => void;
|
|
102
|
-
updatePaneLock: (paneId: string, locked: boolean) => void;
|
|
103
|
-
selectTab: (paneId: string, tabId: string) => void;
|
|
104
|
-
mergeTab: (draggedTabId: string, targetPaneId: string) => void;
|
|
105
126
|
moveTab: (draggedTabId: string, targetTabId: string, position?: 'before' | 'after') => void;
|
|
106
|
-
removeTab: (tabId: string) => void;
|
|
107
127
|
}
|
|
108
128
|
interface ZeugmaClassNames {
|
|
129
|
+
/** CSS class applied to the root dashboard container. */
|
|
130
|
+
dashboard?: string;
|
|
131
|
+
/** CSS class applied to the root dashboard container when a drag-out dismiss is active. */
|
|
132
|
+
dashboardDismissActive?: string;
|
|
109
133
|
/** CSS class applied to the outer container div of each `<Pane>`. */
|
|
110
134
|
pane?: string;
|
|
111
135
|
/** CSS class applied to the pane container when locked. */
|
|
@@ -122,13 +146,15 @@ interface ZeugmaClassNames {
|
|
|
122
146
|
dashboardLocked?: string;
|
|
123
147
|
/** CSS class applied to drop zone indicator when hovering over a locked pane. */
|
|
124
148
|
lockedPreview?: string;
|
|
149
|
+
/** CSS class applied to tab container when dragging a tab over it. */
|
|
150
|
+
tabDropPreview?: string;
|
|
125
151
|
}
|
|
126
152
|
interface ZeugmaProps extends ZeugmaController {
|
|
127
153
|
/** Render function mapping unique pane IDs to React elements. Usually renders a <Pane> wrapper. */
|
|
128
154
|
renderPane: (paneId: string) => ReactNode;
|
|
129
155
|
/** Custom overlay renderer function used to customize the cursor-following drag preview for an active pane or tab. */
|
|
130
156
|
renderDragOverlay?: (activeId: string, type: 'pane' | 'tab') => ReactNode;
|
|
131
|
-
/** Optional CSS class name mapping overrides for custom styles of components like panes, drop
|
|
157
|
+
/** Optional CSS class name mapping overrides for custom styles of components like panes, drop previews, overlays, etc. */
|
|
132
158
|
classNames?: ZeugmaClassNames;
|
|
133
159
|
/** Render function mapping tab IDs to React elements. Used to render tab widgets inside portals. */
|
|
134
160
|
renderWidget?: (tabId: string) => ReactNode;
|
|
@@ -143,37 +169,33 @@ interface ZeugmaStateValue {
|
|
|
143
169
|
/** The current active layout tree structure, or null if empty. */
|
|
144
170
|
layout: TreeNode | null;
|
|
145
171
|
/** Callback to update the layout tree. */
|
|
146
|
-
|
|
172
|
+
setLayout: Dispatch<SetStateAction<TreeNode | null>>;
|
|
147
173
|
/** Renders the inner content of a pane given its unique ID. */
|
|
148
174
|
renderPane: (paneId: string) => ReactNode;
|
|
149
|
-
/** The ID of the pane currently being dragged, or null. */
|
|
150
|
-
activeId: string | null;
|
|
151
|
-
/** The ID of the pane currently targeted for dismiss/drag-out, or null. */
|
|
152
|
-
dismissIntentId: string | null;
|
|
153
|
-
/** Ref setter to measure and track the dashboard root container element. */
|
|
154
|
-
setContainerRef: (element: HTMLElement | null) => void;
|
|
155
175
|
/** The ID of the pane currently zoomed to fullscreen, or null. */
|
|
156
176
|
fullscreenPaneId: string | null;
|
|
157
177
|
/** Normalized or overridden CSS classes for custom layout styling. */
|
|
158
178
|
classNames: ZeugmaClassNames;
|
|
159
|
-
/**
|
|
179
|
+
/** Whether the layout is globally locked. */
|
|
180
|
+
locked: boolean;
|
|
181
|
+
}
|
|
182
|
+
/** @internal */
|
|
183
|
+
interface ZeugmaInternalStateValue extends ZeugmaStateValue {
|
|
184
|
+
/** The ID of the tab currently hovered over during a tab drag, or null. */
|
|
185
|
+
overTabId: string | null;
|
|
186
|
+
/** The position of the tab drop preview relative to the hovered tab ('before' | 'after'). */
|
|
187
|
+
overTabPosition: 'before' | 'after' | null;
|
|
188
|
+
activeId: string | null;
|
|
189
|
+
dismissIntentId: string | null;
|
|
190
|
+
setContainerRef: (element: HTMLElement | null) => void;
|
|
160
191
|
onRemove?: (paneId: string) => void;
|
|
161
|
-
/** Callback triggered to toggle fullscreen status for a pane. */
|
|
162
192
|
onFullscreenChange?: (paneId: string | null) => void;
|
|
163
|
-
/** Threshold in pixels to snap layout resizers to adjacent edges. */
|
|
164
193
|
snapThreshold?: number;
|
|
165
|
-
/** Callback triggered when a split pane starts being resized. */
|
|
166
194
|
onResizeStart?: (currentNode: SplitNode) => void;
|
|
167
|
-
/** Callback triggered continuously during a split pane resize. */
|
|
168
195
|
onResize?: (currentNode: SplitNode, percentage: number) => void;
|
|
169
|
-
/** Callback triggered when a split pane resize action is completed. */
|
|
170
196
|
onResizeEnd?: (currentNode: SplitNode, percentage: number) => void;
|
|
171
|
-
/** Minimum split percentage allowed when resizing. */
|
|
172
197
|
minSplitPercentage?: number;
|
|
173
|
-
/** Maximum split percentage allowed when resizing. */
|
|
174
198
|
maxSplitPercentage?: number;
|
|
175
|
-
/** Whether the layout is globally locked. */
|
|
176
|
-
locked: boolean;
|
|
177
199
|
}
|
|
178
200
|
/**
|
|
179
201
|
* Actions context — holds stable dispatch functions with permanent identity.
|
|
@@ -184,10 +206,6 @@ interface ZeugmaActionsValue {
|
|
|
184
206
|
removePane: (paneId: string) => void;
|
|
185
207
|
/** Appends/inserts a pane at the bottom-rightmost leaf of the layout tree. */
|
|
186
208
|
addPane: (paneId: string) => void;
|
|
187
|
-
/** Splits a target pane with a new pane in the specified direction and side. */
|
|
188
|
-
splitPane: (targetId: string, direction: SplitDirection, splitType: 'left' | 'right' | 'top' | 'bottom', paneToAdd: string) => void;
|
|
189
|
-
/** Updates the split percentage of a specific split branch node. */
|
|
190
|
-
updateSplitPercentage: (currentNode: SplitNode, percentage: number) => void;
|
|
191
209
|
/** Stable callback to update metadata for a specific tab. */
|
|
192
210
|
updateTabMetadata: (tabId: string, updater: (current: Record<string, unknown> | undefined) => Record<string, unknown> | undefined) => void;
|
|
193
211
|
/** Stable callback to update the locked status of a specific pane in the layout tree. */
|
|
@@ -196,22 +214,131 @@ interface ZeugmaActionsValue {
|
|
|
196
214
|
selectTab: (paneId: string, tabId: string) => void;
|
|
197
215
|
/** Stable callback to merge a dragged tab/pane into another pane's tab list. */
|
|
198
216
|
mergeTab: (draggedTabId: string, targetPaneId: string) => void;
|
|
199
|
-
/** Stable callback to move/reorder a tab to another pane next to a target tab. */
|
|
200
|
-
moveTab: (draggedTabId: string, targetTabId: string, position?: 'before' | 'after') => void;
|
|
201
217
|
/** Stable callback to remove/close a specific tab from the layout. */
|
|
202
218
|
removeTab: (tabId: string) => void;
|
|
203
219
|
}
|
|
204
220
|
interface ZeugmaContextValue extends ZeugmaStateValue, ZeugmaActionsValue {
|
|
205
221
|
}
|
|
222
|
+
interface PortalRegistryValue {
|
|
223
|
+
registerPortalTarget: (tabId: string, el: HTMLDivElement | null) => void;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
declare function generateUniqueId(): string;
|
|
227
|
+
/**
|
|
228
|
+
* Tree Helper: Remove a pane container and consolidate the tree structure.
|
|
229
|
+
*/
|
|
230
|
+
declare function removePane(tree: TreeNode | null, paneId: string): TreeNode | null;
|
|
231
|
+
/**
|
|
232
|
+
* Tree Helper: Remove a tab from a pane and consolidate the tree structure if no tabs remain.
|
|
233
|
+
*/
|
|
234
|
+
declare function removeTab(tree: TreeNode | null, tabId: string): TreeNode | null;
|
|
235
|
+
/**
|
|
236
|
+
* Tree Helper: Insert a pane by splitting an existing target node.
|
|
237
|
+
*/
|
|
238
|
+
declare function splitPane(tree: TreeNode | null, targetId: string, direction: SplitDirection, splitType: 'left' | 'right' | 'top' | 'bottom', paneToAdd: string | PaneNode): TreeNode | null;
|
|
239
|
+
/**
|
|
240
|
+
* Tree Helper: Add a pane by recursively splitting the rightmost/bottommost pane in the tree.
|
|
241
|
+
*/
|
|
242
|
+
declare function addPane(tree: TreeNode | null, paneToAdd: string): TreeNode;
|
|
243
|
+
/**
|
|
244
|
+
* Tree Helper: Update split percentage recursively.
|
|
245
|
+
*/
|
|
246
|
+
declare function updateSplitPercentage(tree: TreeNode | null, target: SplitNode, newPercentage: number): TreeNode | null;
|
|
247
|
+
/**
|
|
248
|
+
* Find a PaneNode by its ID.
|
|
249
|
+
*/
|
|
250
|
+
declare function findPaneById(tree: TreeNode | null, paneId: string): PaneNode | null;
|
|
251
|
+
/**
|
|
252
|
+
* Find a PaneNode containing the given tab ID.
|
|
253
|
+
*/
|
|
254
|
+
declare function findPaneContainingTab(tree: TreeNode | null, tabId: string): PaneNode | null;
|
|
255
|
+
/**
|
|
256
|
+
* Update metadata on a specific tab node using an updater function.
|
|
257
|
+
*/
|
|
258
|
+
declare function updateTabMetadata(tree: TreeNode | null, tabId: string, updater: (current: Record<string, unknown> | undefined) => Record<string, unknown> | undefined): TreeNode | null;
|
|
259
|
+
/**
|
|
260
|
+
* Update the locked status on a specific pane node in the layout tree.
|
|
261
|
+
*/
|
|
262
|
+
declare function updatePaneLock(tree: TreeNode | null, paneId: string, locked: boolean): TreeNode | null;
|
|
263
|
+
/**
|
|
264
|
+
* Tree Helper: Activate a tab within a pane.
|
|
265
|
+
*/
|
|
266
|
+
declare function selectTab(tree: TreeNode | null, paneId: string, tabId: string): TreeNode | null;
|
|
267
|
+
/**
|
|
268
|
+
* Tree Helper: Merge a tab into a target pane node.
|
|
269
|
+
*/
|
|
270
|
+
declare function mergeTab(tree: TreeNode | null, draggedTabId: string, targetPaneId: string): TreeNode | null;
|
|
271
|
+
/**
|
|
272
|
+
* Tree Helper: Move/reorder a tab inside or to a target pane next to a target tab.
|
|
273
|
+
*/
|
|
274
|
+
declare function moveTab(tree: TreeNode | null, draggedTabId: string, targetTabId: string, position?: 'before' | 'after'): TreeNode | null;
|
|
275
|
+
interface ComputedPane {
|
|
276
|
+
paneId: string;
|
|
277
|
+
left: number;
|
|
278
|
+
top: number;
|
|
279
|
+
width: number;
|
|
280
|
+
height: number;
|
|
281
|
+
node: PaneNode;
|
|
282
|
+
}
|
|
283
|
+
interface ComputedSplitter {
|
|
284
|
+
id: string;
|
|
285
|
+
currentNode: SplitNode;
|
|
286
|
+
direction: SplitDirection;
|
|
287
|
+
left: number;
|
|
288
|
+
top: number;
|
|
289
|
+
width: number;
|
|
290
|
+
height: number;
|
|
291
|
+
parentLeft: number;
|
|
292
|
+
parentTop: number;
|
|
293
|
+
parentWidth: number;
|
|
294
|
+
parentHeight: number;
|
|
295
|
+
}
|
|
296
|
+
declare function computeLayout(node: TreeNode | null, left?: number, top?: number, width?: number, height?: number, path?: string): {
|
|
297
|
+
panes: ComputedPane[];
|
|
298
|
+
splitters: ComputedSplitter[];
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Shared drag-session lifecycle utility.
|
|
303
|
+
*
|
|
304
|
+
* Handles the common boilerplate for pointer-based resize operations:
|
|
305
|
+
* - Adds `zeugma-resizing` class to `document.body`
|
|
306
|
+
* - Injects a global `cursor` style so the resize cursor stays active
|
|
307
|
+
* even when the pointer leaves the handle element
|
|
308
|
+
* - Sets `data-resizing` on the resizer element
|
|
309
|
+
* - Attaches `pointermove` / `pointerup` listeners to `document`
|
|
310
|
+
* - Cleans everything up on pointer-up
|
|
311
|
+
*
|
|
312
|
+
* Consumers provide domain-specific `onMove` and `onEnd` callbacks.
|
|
313
|
+
*/
|
|
314
|
+
interface DragSessionConfig {
|
|
315
|
+
/** CSS cursor to enforce globally during the drag */
|
|
316
|
+
cursor: 'col-resize' | 'row-resize';
|
|
317
|
+
/** The resizer DOM element (receives `data-resizing` attribute) */
|
|
318
|
+
resizerEl: HTMLElement;
|
|
319
|
+
/** Called on every `pointermove` during the drag */
|
|
320
|
+
onMove: (e: PointerEvent) => void;
|
|
321
|
+
/** Called once on `pointerup` — after cleanup has already run */
|
|
322
|
+
onEnd: () => void;
|
|
323
|
+
}
|
|
324
|
+
declare function createDragSession({ cursor, resizerEl, onMove, onEnd }: DragSessionConfig): void;
|
|
325
|
+
|
|
326
|
+
declare function safeJsonStringify(val: unknown): string;
|
|
327
|
+
|
|
328
|
+
declare const ZeugmaStateContext: React.Context<ZeugmaInternalStateValue | undefined>;
|
|
329
|
+
declare const ZeugmaActionsContext: React.Context<ZeugmaActionsValue | undefined>;
|
|
330
|
+
declare const PortalRegistryContext: React.Context<PortalRegistryValue | undefined>;
|
|
331
|
+
declare const useZeugmaState: () => ZeugmaStateValue;
|
|
332
|
+
declare const useZeugmaActions: () => ZeugmaActionsValue;
|
|
206
333
|
|
|
207
334
|
declare function useZeugma(options: UseZeugmaOptions): ZeugmaController;
|
|
208
335
|
|
|
209
336
|
declare const useZeugmaContext: () => ZeugmaContextValue;
|
|
210
337
|
|
|
211
|
-
declare const Zeugma:
|
|
338
|
+
declare const Zeugma: React__default.FC<ZeugmaProps>;
|
|
212
339
|
|
|
213
340
|
interface UseResizerProps {
|
|
214
|
-
containerRef:
|
|
341
|
+
containerRef: React__default.RefObject<HTMLDivElement | null>;
|
|
215
342
|
isRow: boolean;
|
|
216
343
|
direction: SplitDirection;
|
|
217
344
|
splitPercentage: number;
|
|
@@ -227,7 +354,7 @@ interface UseResizerProps {
|
|
|
227
354
|
parentWidth: number;
|
|
228
355
|
parentHeight: number;
|
|
229
356
|
}
|
|
230
|
-
declare function useResizer({ containerRef, isRow, direction, splitPercentage, resizerSize, snapThreshold, layout, currentNode, onLayoutChange, onResizeStart: localOnResizeStart, onResizeEnd: localOnResizeEnd, parentLeft, parentTop, parentWidth, parentHeight, }: UseResizerProps): (e:
|
|
357
|
+
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;
|
|
231
358
|
|
|
232
359
|
interface PaneTreeProps {
|
|
233
360
|
/** The layout subtree node to render. If not specified, defaults to the root layout tree from the Zeugma context. */
|
|
@@ -237,10 +364,10 @@ interface PaneTreeProps {
|
|
|
237
364
|
/** Threshold distance in pixels to snap layout resizers to adjacent edges (default 8). */
|
|
238
365
|
snapThreshold?: number;
|
|
239
366
|
}
|
|
240
|
-
declare const PaneTree:
|
|
367
|
+
declare const PaneTree: React__default.FC<PaneTreeProps>;
|
|
241
368
|
|
|
242
369
|
interface ResizableContainerProps {
|
|
243
|
-
children:
|
|
370
|
+
children: React__default.ReactNode;
|
|
244
371
|
/** Whether the resizable container is active. When false, acts as a normal 100% height container. */
|
|
245
372
|
active?: boolean;
|
|
246
373
|
/** Current height in pixels (controlled mode) or default/initial height */
|
|
@@ -262,7 +389,7 @@ interface ResizableContainerProps {
|
|
|
262
389
|
/** CSS class applied to the resizer handle */
|
|
263
390
|
resizerClassName?: string;
|
|
264
391
|
}
|
|
265
|
-
declare const ResizableContainer:
|
|
392
|
+
declare const ResizableContainer: React__default.FC<ResizableContainerProps>;
|
|
266
393
|
|
|
267
394
|
interface PaneRenderProps {
|
|
268
395
|
/** True if the pane is actively being dragged. */
|
|
@@ -299,23 +426,23 @@ interface PaneProps {
|
|
|
299
426
|
/** The unique ID of the pane, matching a `paneId` in the layout tree schema. */
|
|
300
427
|
id: string;
|
|
301
428
|
/** Render prop function providing pane state (isDragging, isFullscreen, etc.) and handlers. */
|
|
302
|
-
children: (props: PaneRenderProps) =>
|
|
429
|
+
children: (props: PaneRenderProps) => React__default.ReactNode;
|
|
303
430
|
/** Optional inline CSS styles applied to the pane outer container. */
|
|
304
|
-
style?:
|
|
431
|
+
style?: React__default.CSSProperties;
|
|
305
432
|
/** Optional override to lock this specific pane. */
|
|
306
433
|
locked?: boolean;
|
|
307
434
|
}
|
|
308
|
-
declare const Pane:
|
|
435
|
+
declare const Pane: React__default.FC<PaneProps>;
|
|
309
436
|
|
|
310
437
|
interface DragHandleProps {
|
|
311
438
|
/** The children elements that will trigger dragging when held and dragged. */
|
|
312
|
-
children?:
|
|
439
|
+
children?: React__default.ReactNode;
|
|
313
440
|
/** Custom CSS class applied to the drag handle element. */
|
|
314
441
|
className?: string;
|
|
315
442
|
/** Optional inline CSS styles applied to the drag handle. */
|
|
316
|
-
style?:
|
|
443
|
+
style?: React__default.CSSProperties;
|
|
317
444
|
}
|
|
318
|
-
declare const DragHandle:
|
|
445
|
+
declare const DragHandle: React__default.FC<DragHandleProps>;
|
|
319
446
|
|
|
320
447
|
interface TabRenderProps {
|
|
321
448
|
isDragging: boolean;
|
|
@@ -327,114 +454,12 @@ interface TabProps {
|
|
|
327
454
|
/** Whether dragging is locked on this tab. */
|
|
328
455
|
locked?: boolean;
|
|
329
456
|
/** Render prop child function. */
|
|
330
|
-
children: (props: TabRenderProps) =>
|
|
457
|
+
children: (props: TabRenderProps) => React__default.ReactNode;
|
|
331
458
|
/** Custom CSS class applied to the tab wrapper. */
|
|
332
459
|
className?: string;
|
|
333
460
|
/** Custom inline CSS style applied to the tab wrapper. */
|
|
334
|
-
style?:
|
|
461
|
+
style?: React__default.CSSProperties;
|
|
335
462
|
}
|
|
336
|
-
declare const Tab:
|
|
337
|
-
|
|
338
|
-
declare const DEFAULT_SNAP_THRESHOLD = 8;
|
|
339
|
-
declare const DEFAULT_DRAG_ACTIVATION_DISTANCE = 8;
|
|
340
|
-
declare const DEFAULT_RESIZER_SIZE = 4;
|
|
341
|
-
|
|
342
|
-
declare function generateUniqueId(): string;
|
|
343
|
-
/**
|
|
344
|
-
* Tree Helper: Remove a pane container and consolidate the tree structure.
|
|
345
|
-
*/
|
|
346
|
-
declare function removePane(tree: TreeNode | null, paneId: string): TreeNode | null;
|
|
347
|
-
/**
|
|
348
|
-
* Tree Helper: Remove a tab from a pane and consolidate the tree structure if no tabs remain.
|
|
349
|
-
*/
|
|
350
|
-
declare function removeTab(tree: TreeNode | null, tabId: string): TreeNode | null;
|
|
351
|
-
/**
|
|
352
|
-
* Tree Helper: Insert a pane by splitting an existing target node.
|
|
353
|
-
*/
|
|
354
|
-
declare function splitPane(tree: TreeNode | null, targetId: string, direction: SplitDirection, splitType: 'left' | 'right' | 'top' | 'bottom', paneToAdd: string | PaneNode): TreeNode | null;
|
|
355
|
-
/**
|
|
356
|
-
* Tree Helper: Add a pane by recursively splitting the rightmost/bottommost pane in the tree.
|
|
357
|
-
*/
|
|
358
|
-
declare function addPane(tree: TreeNode | null, paneToAdd: string): TreeNode;
|
|
359
|
-
/**
|
|
360
|
-
* Tree Helper: Update split percentage recursively.
|
|
361
|
-
*/
|
|
362
|
-
declare function updateSplitPercentage(tree: TreeNode | null, target: SplitNode, newPercentage: number): TreeNode | null;
|
|
363
|
-
/**
|
|
364
|
-
* Find a PaneNode by its ID or by any of its tab IDs.
|
|
365
|
-
*/
|
|
366
|
-
declare function findPane(tree: TreeNode | null, paneId: string): PaneNode | null;
|
|
367
|
-
/**
|
|
368
|
-
* Update metadata on a specific tab node using an updater function.
|
|
369
|
-
*/
|
|
370
|
-
declare function updateTabMetadata(tree: TreeNode | null, tabId: string, updater: (current: Record<string, unknown> | undefined) => Record<string, unknown> | undefined): TreeNode | null;
|
|
371
|
-
/**
|
|
372
|
-
* Update the locked status on a specific pane node in the layout tree.
|
|
373
|
-
*/
|
|
374
|
-
declare function updatePaneLock(tree: TreeNode | null, paneId: string, locked: boolean): TreeNode | null;
|
|
375
|
-
/**
|
|
376
|
-
* Tree Helper: Activate a tab within a pane.
|
|
377
|
-
*/
|
|
378
|
-
declare function selectTab(tree: TreeNode | null, paneId: string, tabId: string): TreeNode | null;
|
|
379
|
-
/**
|
|
380
|
-
* Tree Helper: Merge a tab into a target pane node.
|
|
381
|
-
*/
|
|
382
|
-
declare function mergeTab(tree: TreeNode | null, draggedTabId: string, targetPaneId: string): TreeNode | null;
|
|
383
|
-
/**
|
|
384
|
-
* Tree Helper: Move/reorder a tab inside or to a target pane next to a target tab.
|
|
385
|
-
*/
|
|
386
|
-
declare function moveTab(tree: TreeNode | null, draggedTabId: string, targetTabId: string, position?: 'before' | 'after'): TreeNode | null;
|
|
387
|
-
interface ComputedPane {
|
|
388
|
-
paneId: string;
|
|
389
|
-
left: number;
|
|
390
|
-
top: number;
|
|
391
|
-
width: number;
|
|
392
|
-
height: number;
|
|
393
|
-
node: PaneNode;
|
|
394
|
-
}
|
|
395
|
-
interface ComputedSplitter {
|
|
396
|
-
id: string;
|
|
397
|
-
currentNode: SplitNode;
|
|
398
|
-
direction: SplitDirection;
|
|
399
|
-
left: number;
|
|
400
|
-
top: number;
|
|
401
|
-
width: number;
|
|
402
|
-
height: number;
|
|
403
|
-
parentLeft: number;
|
|
404
|
-
parentTop: number;
|
|
405
|
-
parentWidth: number;
|
|
406
|
-
parentHeight: number;
|
|
407
|
-
}
|
|
408
|
-
declare function computeLayout(node: TreeNode | null, left?: number, top?: number, width?: number, height?: number, path?: string): {
|
|
409
|
-
panes: ComputedPane[];
|
|
410
|
-
splitters: ComputedSplitter[];
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Shared drag-session lifecycle utility.
|
|
415
|
-
*
|
|
416
|
-
* Handles the common boilerplate for pointer-based resize operations:
|
|
417
|
-
* - Adds `zeugma-resizing` class to `document.body`
|
|
418
|
-
* - Injects a global `cursor` style so the resize cursor stays active
|
|
419
|
-
* even when the pointer leaves the handle element
|
|
420
|
-
* - Sets `data-resizing` on the resizer element
|
|
421
|
-
* - Attaches `pointermove` / `pointerup` listeners to `document`
|
|
422
|
-
* - Cleans everything up on pointer-up
|
|
423
|
-
*
|
|
424
|
-
* Consumers provide domain-specific `onMove` and `onEnd` callbacks.
|
|
425
|
-
*/
|
|
426
|
-
interface DragSessionConfig {
|
|
427
|
-
/** CSS cursor to enforce globally during the drag */
|
|
428
|
-
cursor: 'col-resize' | 'row-resize';
|
|
429
|
-
/** The resizer DOM element (receives `data-resizing` attribute) */
|
|
430
|
-
resizerEl: HTMLElement;
|
|
431
|
-
/** Called on every `pointermove` during the drag */
|
|
432
|
-
onMove: (e: PointerEvent) => void;
|
|
433
|
-
/** Called once on `pointerup` — after cleanup has already run */
|
|
434
|
-
onEnd: () => void;
|
|
435
|
-
}
|
|
436
|
-
declare function createDragSession({ cursor, resizerEl, onMove, onEnd }: DragSessionConfig): void;
|
|
437
|
-
|
|
438
|
-
declare function safeJsonStringify(val: unknown): string;
|
|
463
|
+
declare const Tab: React__default.FC<TabProps>;
|
|
439
464
|
|
|
440
|
-
export { type ComputedPane, type ComputedSplitter, DEFAULT_DRAG_ACTIVATION_DISTANCE, DEFAULT_RESIZER_SIZE, DEFAULT_SNAP_THRESHOLD, DragHandle, type DragHandleProps, type DragSessionConfig, Pane, type PaneNode, type PaneProps, type PaneRenderProps, PaneTree, ResizableContainer, type ResizableContainerProps, type SplitDirection, type SplitNode, Tab, type TabProps, type TabRenderProps, type TreeNode, type UseZeugmaOptions, Zeugma, type ZeugmaClassNames, type ZeugmaContextValue, type ZeugmaController, type ZeugmaProps, addPane, computeLayout, createDragSession,
|
|
465
|
+
export { type ComputedPane, type ComputedSplitter, DEFAULT_DRAG_ACTIVATION_DISTANCE, DEFAULT_RESIZER_SIZE, DEFAULT_SNAP_THRESHOLD, DragHandle, type DragHandleProps, type DragSessionConfig, Pane, type PaneNode, type PaneProps, type PaneRenderProps, PaneTree, PortalRegistryContext, type PortalRegistryValue, ResizableContainer, type ResizableContainerProps, type SplitDirection, type SplitNode, Tab, type TabProps, type TabRenderProps, type TreeNode, type UseZeugmaOptions, Zeugma, ZeugmaActionsContext, type ZeugmaActionsValue, type ZeugmaClassNames, type ZeugmaContextValue, type ZeugmaController, type ZeugmaInternalController, type ZeugmaInternalStateValue, type ZeugmaProps, ZeugmaStateContext, type ZeugmaStateValue, addPane, computeLayout, createDragSession, findPaneById, findPaneContainingTab, generateUniqueId, mergeTab, moveTab, removePane, removeTab, safeJsonStringify, selectTab, splitPane, updatePaneLock, updateSplitPercentage, updateTabMetadata, useResizer, useZeugma, useZeugmaActions, useZeugmaContext, useZeugmaState };
|