react-dockable-desktop 4.3.0 → 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/dist/index.d.cts CHANGED
@@ -90,6 +90,8 @@ interface WindowManagerProps {
90
90
  taskbarVisibility?: TaskbarVisibility;
91
91
  /** Custom context menu renderer. Defaults to the built-in `DefaultContextMenuAdapter`. */
92
92
  contextMenuAdapter?: ContextMenuAdapter;
93
+ /** Enables the library's own transitions/animations (tab hover, dock preview, etc.). Never affects the consumer's own page. @default true */
94
+ animations?: boolean;
93
95
  }
94
96
  declare const WindowManager: React$1.FC<WindowManagerProps>;
95
97
 
@@ -142,6 +144,13 @@ interface WorkspaceClientConfig {
142
144
  * outer edge. Range 0.1–0.9. Default: 0.2.
143
145
  */
144
146
  defaultEdgeSplitRatio?: number;
147
+ /**
148
+ * Starting z-index for floating windows and the library's own chrome overlays
149
+ * (context menu, toolbar flyout, modal stack, toast, workspace edge zones),
150
+ * all of which shift together via `--rdd-z-base`. Set this above/below a host
151
+ * app's own modal z-index range to control stacking against it. Default: 1000.
152
+ */
153
+ zIndexBase?: number;
145
154
  }
146
155
  /**
147
156
  * WorkspaceClient is the central configuration and imperative API object for
@@ -181,7 +190,7 @@ declare class WorkspaceClient<TUserEvents extends Record<string, unknown> = Reco
181
190
  /** Serialised layout to restore on mount, or null to start with an empty canvas. */
182
191
  readonly initialState: string | null;
183
192
  /** Non-rendering configuration forwarded to the provider. */
184
- readonly config: Pick<WorkspaceClientConfig, 'formatMessage' | 'predefinedMessages' | 'dir' | 'defaultSplitRatio' | 'defaultEdgeSplitRatio'>;
193
+ readonly config: Pick<WorkspaceClientConfig, 'formatMessage' | 'predefinedMessages' | 'dir' | 'defaultSplitRatio' | 'defaultEdgeSplitRatio' | 'zIndexBase'>;
185
194
  private _actions;
186
195
  private _initialized;
187
196
  /** Calls queued before _connect() fires — replayed in order on first connect. */
@@ -222,6 +231,42 @@ declare class WorkspaceClient<TUserEvents extends Record<string, unknown> = Reco
222
231
  saveLayout(): string;
223
232
  loadLayout(json: string): boolean;
224
233
  setDirection(dir: 'ltr' | 'rtl'): void;
234
+ /** Updates the split-size fractions at the given grid path. */
235
+ updateSplitSizes(path: number[], sizes: number[]): void;
236
+ /** Updates position/size/anchor of a floating panel. */
237
+ updateFloatingPosition(id: string, updates: Partial<Pick<FloatingWindow, 'x' | 'y' | 'width' | 'height' | 'anchor'>>): void;
238
+ /** @internal Drives the drag-in-progress visual state; normally only the library's own drag UI calls this. */
239
+ setDraggedPanelId(id: string | null): void;
240
+ /** Docks a panel into an existing leaf group at the given drop position. */
241
+ dockPanelToGroup(id: string, targetLeafId: string, position: DropPosition): void;
242
+ /** Reorders a panel's tab within its leaf group. */
243
+ movePanelOrder(panelId: string, targetLeafId: string, targetIndex: number): void;
244
+ /** Closes an entire leaf group (all of its tabs) at once. */
245
+ closeLeafGroup(leafId: string): void;
246
+ /** Registers a guard that can veto closing the given panel. */
247
+ registerCloseGuard(id: string, guard: () => boolean | Promise<boolean>): void;
248
+ /** Removes a previously registered close guard. */
249
+ unregisterCloseGuard(id: string): void;
250
+ /** Sets/clears a panel's dirty (unsaved changes) flag. */
251
+ setPanelDirty(id: string, dirty: boolean, options?: DirtyStateOptions): void;
252
+ /** Updates a panel's displayed title. */
253
+ updatePanelTitle(id: string, title: string | ContextMenuPredefinedMessage): void;
254
+ /**
255
+ * Requests that a panel close, honoring its dirty flag and any registered close guard.
256
+ * Resolves once the close (or user cancellation) has been resolved.
257
+ *
258
+ * @remarks If called before the provider mounts, the request is queued and this
259
+ * returns an already-resolved promise immediately — the caller can't observe the
260
+ * eventual outcome of a queued call, only that the request was accepted.
261
+ */
262
+ requestClosePanel(id: string, options?: {
263
+ force?: boolean;
264
+ onConfirm?: (opts?: DirtyStateOptions) => Promise<boolean>;
265
+ }): Promise<void>;
266
+ /** Docks a panel to one of the workspace's outer edges. */
267
+ dockPanelToWorkspaceEdge(id: string, position: SplitDirection): void;
268
+ /** Shows a context menu using the app's configured ContextMenuAdapter. */
269
+ showContextMenu(options: ShowContextMenuOptions): void;
225
270
  publish<K extends keyof (TUserEvents & BuiltInPanelEvents)>(event: K, data: (TUserEvents & BuiltInPanelEvents)[K]): void;
226
271
  subscribe<K extends keyof (TUserEvents & BuiltInPanelEvents)>(event: K, callback: (data: (TUserEvents & BuiltInPanelEvents)[K]) => void): () => void;
227
272
  /** Subscribe to panel open events. Fires only for newly created panels. */
@@ -782,6 +827,19 @@ declare const useStyleClasses: () => StyleClasses;
782
827
  * ```
783
828
  */
784
829
  declare const useRegistry: () => PanelRegistryClass;
830
+ /** The on-disk shape produced by `saveLayout()` and accepted by `loadLayout()`/`initialState`. */
831
+ interface SerializedLayout {
832
+ /** Schema version — absent on layouts saved before this field was introduced (treated as 0). */
833
+ version?: number;
834
+ gridRoot: LayoutNode;
835
+ floating: FloatingWindow[];
836
+ minimized: {
837
+ id: string;
838
+ title: string | ContextMenuPredefinedMessage;
839
+ component: string;
840
+ }[];
841
+ panels: Record<string, PanelInfo>;
842
+ }
785
843
  /**
786
844
  * Props for `<DockableDesktopProvider>` and `<WindowManagerProvider>`.
787
845
  * Also exported as `DockableDesktopProviderProps` for consumers who use
@@ -814,6 +872,13 @@ interface WindowManagerProviderProps {
814
872
  windowClass?: string;
815
873
  /** CSS class applied to the inner content area of floating panel windows. */
816
874
  windowBodyClass?: string;
875
+ /**
876
+ * Starting z-index for floating windows and the library's own chrome overlays
877
+ * (context menu, toolbar flyout, modal stack, toast, workspace edge zones),
878
+ * all of which shift together via `--rdd-z-base`. Set this above/below a host
879
+ * app's own modal z-index range to control stacking against it. @default 1000
880
+ */
881
+ zIndexBase?: number;
817
882
  }
818
883
  declare const WindowManagerProvider: React$1.FC<WindowManagerProviderProps>;
819
884
  declare function useWindowManagerState(): WindowState;
@@ -1073,6 +1138,17 @@ declare const FormContainerProvider: Provider<FormContainerContract>;
1073
1138
  * (resize, close, minimize, restore, activate, deactivate, container-type changes).
1074
1139
  */
1075
1140
  declare const useFormContainer: () => FormContainerContract;
1141
+ /**
1142
+ * Reactive alternative to calling {@link FormContainerContract.getDimensions} yourself.
1143
+ * Returns the panel's current `{ width, height }`, or `null` before it has been laid
1144
+ * out, and re-renders whenever the panel's rendered box changes — including resizes
1145
+ * caused by the workspace itself (a grid split being dragged, docking, floating, or
1146
+ * tab activation), not just resizes of an element the panel created.
1147
+ */
1148
+ declare const usePanelSize: () => {
1149
+ width: number;
1150
+ height: number;
1151
+ } | null;
1076
1152
 
1077
1153
  /** Unique string identifier for panel/modal instances. */
1078
1154
  type PanelInstanceId = string;
@@ -1280,7 +1356,7 @@ interface SidebarProps {
1280
1356
  /** Which side the activity bar and drawer appear on. Default: 'right' */
1281
1357
  position?: 'left' | 'right';
1282
1358
  tabs: SidebarTab[];
1283
- /** Initial drawer width in pixels. Default: 220 */
1359
+ /** Initial drawer width in pixels. Default: 280 */
1284
1360
  defaultWidth?: number;
1285
1361
  /** Minimum drawer width in pixels during drag-resize. Default: 150 */
1286
1362
  minWidth?: number;
@@ -1302,8 +1378,6 @@ interface SidebarProps {
1302
1378
  onStripVisibilityChange?: (visible: boolean) => void;
1303
1379
  /** Main workspace content rendered alongside the sidebar. */
1304
1380
  children?: React$1.ReactNode;
1305
- /** @deprecated Use defaultWidth (number, pixels) instead. */
1306
- drawerWidth?: string;
1307
1381
  }
1308
1382
  /**
1309
1383
  * Imperative handle exposed by `<Sidebar ref={...}>`.
@@ -1344,14 +1418,14 @@ declare const Sidebar: React$1.ForwardRefExoticComponent<SidebarProps & React$1.
1344
1418
  * Returns sidebar control functions from anywhere inside a `<Sidebar>` tree,
1345
1419
  * including floating panels rendered via `{children}`.
1346
1420
  *
1347
- * Returns a no-op object with a console warning when called outside a Sidebar.
1421
+ * @throws Error if used outside of a {@link Sidebar}.
1348
1422
  */
1349
1423
  declare function useSidebar(): SidebarContextValue;
1350
1424
  /**
1351
1425
  * Returns tab-specific control functions for components rendered inside a
1352
1426
  * sidebar tab's `renderContent` tree.
1353
1427
  *
1354
- * Returns a no-op object with a console warning when called outside tab content.
1428
+ * @throws Error if used outside of a {@link Sidebar} tab's `renderContent` tree.
1355
1429
  */
1356
1430
  declare function useSidebarTab(): SidebarTabContextValue;
1357
1431
 
@@ -1380,7 +1454,7 @@ declare const ToolbarProvider: React$1.FC<{
1380
1454
  * Returns toolbar state and control functions from anywhere inside
1381
1455
  * a `<DockableDesktopProvider>` tree.
1382
1456
  *
1383
- * Returns a no-op object with a console warning when called outside the provider.
1457
+ * @throws Error if used outside of a {@link DockableDesktopProvider}.
1384
1458
  */
1385
1459
  declare function useToolbar(): ToolbarContextValue;
1386
1460
 
@@ -1417,8 +1491,8 @@ interface ToolbarRadioItem {
1417
1491
  /**
1418
1492
  * An independent on/off toggle modifier (e.g. snap-to-grid).
1419
1493
  *
1420
- * Supports both uncontrolled mode (omit `active` — state lives in
1421
- * ToolbarContext, keyed by `id`) and controlled mode (provide `active` —
1494
+ * Supports both uncontrolled mode (omit `rdd-active` — state lives in
1495
+ * ToolbarContext, keyed by `id`) and controlled mode (provide `rdd-active` —
1422
1496
  * the caller is the single source of truth and must update the prop in
1423
1497
  * response to `onToggle`). Controlled mode is what lets independent
1424
1498
  * instances of the same panel type report independent active state
@@ -1929,8 +2003,9 @@ declare const PanelContributionProvider: React$1.FC<{
1929
2003
  * `useMemo`/`useCallback`) to avoid republishing on every unrelated re-render.
1930
2004
  *
1931
2005
  * Contributions are only ever surfaced while this panel is `state.activePanelId` —
1932
- * see `useActivePanelContribution()`. No-op outside a `PanelContributionProvider` tree.
2006
+ * see `useActivePanelContribution()`.
1933
2007
  *
2008
+ * @throws Error if used outside of a {@link PanelContributionProvider}.
1934
2009
  * @example
1935
2010
  * function MapPanel() {
1936
2011
  * const [controller, setController] = useState<'pan' | 'draw' | 'measure'>('pan');
@@ -1950,6 +2025,8 @@ declare function usePanelContribution(contribution: PanelContribution): void;
1950
2025
  * via `usePanelContribution()`, or `null` if no panel is active or the active panel
1951
2026
  * hasn't contributed anything. Intended for the app shell to merge into its own
1952
2027
  * `<Toolbar items={...}>` / `<Sidebar tabs={...}>` calls.
2028
+ *
2029
+ * @throws Error if used outside of a {@link PanelContributionProvider}.
1953
2030
  */
1954
2031
  declare function useActivePanelContribution(): PanelContribution | null;
1955
2032
  /**
@@ -1975,4 +2052,83 @@ declare function useMergedToolbarItems(staticItems: ToolbarItem$1[]): ToolbarIte
1975
2052
  */
1976
2053
  declare function useMergedSidebarTabs(staticTabs: SidebarTab[], fallbackIcon?: React$1.ReactNode): SidebarTab[];
1977
2054
 
1978
- export { type BuiltInPanelEvents, type ButtonVariant, type CloseOptions, ConfirmationForm, type ConfirmationFormProps, ContextMenu, type ContextMenuAdapter, type ContextMenuCheckbox, type ContextMenuHandle, type ContextMenuItem, type ContextMenuLabel, type ContextMenuPredefinedMessage, type ContextMenuProps, ContextMenuProvider, type ContextMenuSeparator, type ContextMenuSimpleItem, type ContextMenuSubMenu, DefaultContextMenuAdapter, DockableDesktopProvider, type DockableDesktopProviderProps, type DropPosition, type DropTarget, type FloatAnchor, type FloatingWindow, FormContainerContext, type FormContainerContract, FormContainerProvider, type LayoutGridNode, type LayoutLeafNode, type LayoutNode, LeftPanelRenderer, type ManagedWindowConfig, type MenuItemAction, type MessageFormatter, type ModalOptions, ModalStackRenderer, type PanelActions, type PanelContribution, PanelContributionProvider, type PanelDefinition, PanelFloatingWindow, type PanelFloatingWindowManagerHandle, type PanelFloatingWindowProps, type PanelInfo, type PanelInstance, type PanelInstanceId, PanelOverlayRoot, type PanelOverlayRootProps, PanelProvider, PanelRegistry, PanelRegistryClass, type PanelRegistryEntry, type PanelSidebarSection, type PanelState, type PanelTitle, PanelToolbar, ToolbarItem as PanelToolbarItem, type PanelToolbarProps, ToolbarSeparator as PanelToolbarSeparator, type PredefinedMessageKey, type ResolvedToastOptions, RightPanelRenderer, type SearchResult, type ShowContextMenuOptions, type SidePanelOptions, SidePanelRenderer, type SidePanelRendererProps, Sidebar, type SidebarContextValue, type SidebarHandle, type SidebarProps, type SidebarTab, type SidebarTabContextValue, type SplitDirection, type SplitOrientation, type StyleClasses, type TaskbarVisibility, type ToastAdapter, ToastContainer, type ToastContainerProps, type ToastFunction, type ToastOptions, type ToastPosition, type ToastPromiseMessages, type ToastType, Toolbar, type ToolbarActionItem, ToolbarButton, type ToolbarButtonProps, ToolbarCenter, type ToolbarContextValue, type ToolbarGroupEntry, type ToolbarGroupItem, type ToolbarGroupSubItem, type ToolbarHandle, type ToolbarItem$1 as ToolbarItem, type ToolbarPosition, type ToolbarProps, ToolbarProvider, type ToolbarRadioItem, ToolbarSearchInput, type ToolbarSearchInputProps, type ToolbarSeparator$1 as ToolbarSeparator, ToolbarSpacer, ToolbarToggle, type ToolbarToggleItem, type ToolbarToggleProps, type ToolbarVariant, type UsePanelFloatingWindowReturn, type WindowActions, WindowManager, type WindowManagerProps, WindowManagerProvider, type WindowManagerProviderProps, type WindowState, WorkspaceClient, type WorkspaceClientConfig, defaultPredefinedMessages, formatLabel, sidebarSectionToTab, toast, useActivePanelContribution, useFormContainer, useFormatMessage, useMergedSidebarTabs, useMergedToolbarItems, usePanelActions, usePanelContext, usePanelContextMenu, usePanelContribution, usePanelFloatingWindow, usePanelFloatingWindowManager, usePanelId, usePanelState, usePredefinedMessages, useRegistry, useShowContextMenu, useSidebar, useSidebarTab, useStyleClasses, useToolbar, useWindowManagerActions, useWindowManagerState };
2055
+ /**
2056
+ * Shared pointer-drag-resize primitives.
2057
+ *
2058
+ * Extracted from four previously-independent implementations (the workspace grid
2059
+ * split resizer, the sidebar drawer resizer, and two floating-window resize-handle
2060
+ * implementations) that had quietly drifted apart in exactly the kind of detail
2061
+ * (an inline-style property present in one and missing in the other) that once
2062
+ * caused a real, user-visible bug. This file is the single place that mechanic now
2063
+ * lives, so it can't drift again.
2064
+ */
2065
+ interface PointerDragConfig<TStart> {
2066
+ /** The element to capture the pointer on — normally the handle the user grabbed. */
2067
+ element: HTMLElement;
2068
+ pointerId: number;
2069
+ /** The pointerdown event's clientX/clientY, used as the delta origin. */
2070
+ startClientX: number;
2071
+ startClientY: number;
2072
+ /** Snapshot whatever state the caller needs at drag start (sizes, positions, ...). */
2073
+ captureStart: () => TStart;
2074
+ /** Called on every pointermove with the delta from the drag's start position. */
2075
+ onMove: (dx: number, dy: number, start: TStart) => void;
2076
+ /** Called once when the drag ends (pointerup or pointercancel). */
2077
+ onEnd?: (start: TStart) => void;
2078
+ /** Classes toggled on the given elements for the duration of the drag. */
2079
+ activeClasses?: Array<{
2080
+ el: HTMLElement;
2081
+ classes: string[];
2082
+ }>;
2083
+ }
2084
+ /**
2085
+ * Starts a pointer-capture-based drag: captures the pointer on `element`, tracks
2086
+ * movement via listeners scoped to that element's own lifetime (not `window`), and
2087
+ * cleans up automatically on release or cancel.
2088
+ */
2089
+ declare function startPointerDrag<TStart>(config: PointerDragConfig<TStart>): void;
2090
+ type ResizeDir = 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw';
2091
+ interface ResizeRect {
2092
+ x: number;
2093
+ y: number;
2094
+ w: number;
2095
+ h: number;
2096
+ }
2097
+ interface ResizeConstraints {
2098
+ minW: number;
2099
+ minH: number;
2100
+ /** Upper bound on width — only applies to eastward growth (dir includes 'e'). */
2101
+ maxW?: number;
2102
+ /** Upper bound on height — only applies to southward growth (dir includes 's'). */
2103
+ maxH?: number;
2104
+ /** Lower bound on the resulting x — only applies to westward growth (dir includes 'w'). */
2105
+ minX?: number;
2106
+ /** Lower bound on the resulting y — only applies to northward growth (dir includes 'n'). */
2107
+ minY?: number;
2108
+ }
2109
+ /**
2110
+ * Pure function computing the new rect for an 8-directional resize handle drag.
2111
+ *
2112
+ * `maxW`/`maxH` and `minX`/`minY` are independent, direction-scoped constraints
2113
+ * rather than one "container bound" — a resize toward the fixed edge (e/s) is
2114
+ * naturally bounded by a maximum dimension, while a resize toward the moving edge
2115
+ * (w/n) is naturally bounded by a minimum position, and the two calling sites this
2116
+ * was extracted from need different subsets of these (see WindowManager.tsx's
2117
+ * `startResize`, which omits all four and lets a window grow unbounded and be
2118
+ * dragged fully off-screen, vs. PanelOverlay.tsx's `handleResizePointerDown`, which
2119
+ * supplies all four to keep windows within their container).
2120
+ */
2121
+ declare function computeResizedRect(dir: ResizeDir, dx: number, dy: number, start: ResizeRect, constraints: ResizeConstraints): ResizeRect;
2122
+
2123
+ /**
2124
+ * Reactively reads the workspace's current `data-color-scheme` attribute
2125
+ * (set on `document.documentElement` by `<WindowManager />`), returning
2126
+ * `'dark'` or `'light'` and re-rendering whenever it changes.
2127
+ *
2128
+ * Useful for panel content that needs to react to the same scheme the
2129
+ * workspace itself is using — e.g. swapping a map's tile layer or an
2130
+ * embedded editor's theme to match.
2131
+ */
2132
+ declare function useColorScheme(): 'dark' | 'light';
2133
+
2134
+ export { type BuiltInPanelEvents, type ButtonVariant, type CloseOptions, ConfirmationForm, type ConfirmationFormProps, ContextMenu, type ContextMenuAdapter, type ContextMenuCheckbox, type ContextMenuHandle, type ContextMenuItem, type ContextMenuLabel, type ContextMenuPredefinedMessage, type ContextMenuProps, ContextMenuProvider, type ContextMenuSeparator, type ContextMenuSimpleItem, type ContextMenuSubMenu, DefaultContextMenuAdapter, DockableDesktopProvider, type DockableDesktopProviderProps, type DropPosition, type DropTarget, type FloatAnchor, type FloatingWindow, FormContainerContext, type FormContainerContract, FormContainerProvider, type LayoutGridNode, type LayoutLeafNode, type LayoutNode, LeftPanelRenderer, type ManagedWindowConfig, type MenuItemAction, type MessageFormatter, type ModalOptions, ModalStackRenderer, type PanelActions, type PanelContribution, PanelContributionProvider, type PanelDefinition, PanelFloatingWindow, type PanelFloatingWindowManagerHandle, type PanelFloatingWindowProps, type PanelInfo, type PanelInstance, type PanelInstanceId, PanelOverlayRoot, type PanelOverlayRootProps, PanelProvider, PanelRegistry, PanelRegistryClass, type PanelRegistryEntry, type PanelSidebarSection, type PanelState, type PanelTitle, PanelToolbar, ToolbarItem as PanelToolbarItem, type PanelToolbarProps, ToolbarSeparator as PanelToolbarSeparator, type PointerDragConfig, type PredefinedMessageKey, type ResizeConstraints, type ResizeDir, type ResizeRect, type ResolvedToastOptions, RightPanelRenderer, type SearchResult, type SerializedLayout, type ShowContextMenuOptions, type SidePanelOptions, SidePanelRenderer, type SidePanelRendererProps, Sidebar, type SidebarContextValue, type SidebarHandle, type SidebarProps, type SidebarTab, type SidebarTabContextValue, type SplitDirection, type SplitOrientation, type StyleClasses, type TaskbarVisibility, type ToastAdapter, ToastContainer, type ToastContainerProps, type ToastFunction, type ToastOptions, type ToastPosition, type ToastPromiseMessages, type ToastType, Toolbar, type ToolbarActionItem, ToolbarButton, type ToolbarButtonProps, ToolbarCenter, type ToolbarContextValue, type ToolbarGroupEntry, type ToolbarGroupItem, type ToolbarGroupSubItem, type ToolbarHandle, type ToolbarItem$1 as ToolbarItem, type ToolbarPosition, type ToolbarProps, ToolbarProvider, type ToolbarRadioItem, ToolbarSearchInput, type ToolbarSearchInputProps, type ToolbarSeparator$1 as ToolbarSeparator, ToolbarSpacer, ToolbarToggle, type ToolbarToggleItem, type ToolbarToggleProps, type ToolbarVariant, type UsePanelFloatingWindowReturn, type WindowActions, WindowManager, type WindowManagerProps, WindowManagerProvider, type WindowManagerProviderProps, type WindowState, WorkspaceClient, type WorkspaceClientConfig, computeResizedRect, defaultPredefinedMessages, formatLabel, sidebarSectionToTab, startPointerDrag, toast, useActivePanelContribution, useColorScheme, useFormContainer, useFormatMessage, useMergedSidebarTabs, useMergedToolbarItems, usePanelActions, usePanelContext, usePanelContextMenu, usePanelContribution, usePanelFloatingWindow, usePanelFloatingWindowManager, usePanelId, usePanelSize, usePanelState, usePredefinedMessages, useRegistry, useShowContextMenu, useSidebar, useSidebarTab, useStyleClasses, useToolbar, useWindowManagerActions, useWindowManagerState };
package/dist/index.d.ts CHANGED
@@ -90,6 +90,8 @@ interface WindowManagerProps {
90
90
  taskbarVisibility?: TaskbarVisibility;
91
91
  /** Custom context menu renderer. Defaults to the built-in `DefaultContextMenuAdapter`. */
92
92
  contextMenuAdapter?: ContextMenuAdapter;
93
+ /** Enables the library's own transitions/animations (tab hover, dock preview, etc.). Never affects the consumer's own page. @default true */
94
+ animations?: boolean;
93
95
  }
94
96
  declare const WindowManager: React$1.FC<WindowManagerProps>;
95
97
 
@@ -142,6 +144,13 @@ interface WorkspaceClientConfig {
142
144
  * outer edge. Range 0.1–0.9. Default: 0.2.
143
145
  */
144
146
  defaultEdgeSplitRatio?: number;
147
+ /**
148
+ * Starting z-index for floating windows and the library's own chrome overlays
149
+ * (context menu, toolbar flyout, modal stack, toast, workspace edge zones),
150
+ * all of which shift together via `--rdd-z-base`. Set this above/below a host
151
+ * app's own modal z-index range to control stacking against it. Default: 1000.
152
+ */
153
+ zIndexBase?: number;
145
154
  }
146
155
  /**
147
156
  * WorkspaceClient is the central configuration and imperative API object for
@@ -181,7 +190,7 @@ declare class WorkspaceClient<TUserEvents extends Record<string, unknown> = Reco
181
190
  /** Serialised layout to restore on mount, or null to start with an empty canvas. */
182
191
  readonly initialState: string | null;
183
192
  /** Non-rendering configuration forwarded to the provider. */
184
- readonly config: Pick<WorkspaceClientConfig, 'formatMessage' | 'predefinedMessages' | 'dir' | 'defaultSplitRatio' | 'defaultEdgeSplitRatio'>;
193
+ readonly config: Pick<WorkspaceClientConfig, 'formatMessage' | 'predefinedMessages' | 'dir' | 'defaultSplitRatio' | 'defaultEdgeSplitRatio' | 'zIndexBase'>;
185
194
  private _actions;
186
195
  private _initialized;
187
196
  /** Calls queued before _connect() fires — replayed in order on first connect. */
@@ -222,6 +231,42 @@ declare class WorkspaceClient<TUserEvents extends Record<string, unknown> = Reco
222
231
  saveLayout(): string;
223
232
  loadLayout(json: string): boolean;
224
233
  setDirection(dir: 'ltr' | 'rtl'): void;
234
+ /** Updates the split-size fractions at the given grid path. */
235
+ updateSplitSizes(path: number[], sizes: number[]): void;
236
+ /** Updates position/size/anchor of a floating panel. */
237
+ updateFloatingPosition(id: string, updates: Partial<Pick<FloatingWindow, 'x' | 'y' | 'width' | 'height' | 'anchor'>>): void;
238
+ /** @internal Drives the drag-in-progress visual state; normally only the library's own drag UI calls this. */
239
+ setDraggedPanelId(id: string | null): void;
240
+ /** Docks a panel into an existing leaf group at the given drop position. */
241
+ dockPanelToGroup(id: string, targetLeafId: string, position: DropPosition): void;
242
+ /** Reorders a panel's tab within its leaf group. */
243
+ movePanelOrder(panelId: string, targetLeafId: string, targetIndex: number): void;
244
+ /** Closes an entire leaf group (all of its tabs) at once. */
245
+ closeLeafGroup(leafId: string): void;
246
+ /** Registers a guard that can veto closing the given panel. */
247
+ registerCloseGuard(id: string, guard: () => boolean | Promise<boolean>): void;
248
+ /** Removes a previously registered close guard. */
249
+ unregisterCloseGuard(id: string): void;
250
+ /** Sets/clears a panel's dirty (unsaved changes) flag. */
251
+ setPanelDirty(id: string, dirty: boolean, options?: DirtyStateOptions): void;
252
+ /** Updates a panel's displayed title. */
253
+ updatePanelTitle(id: string, title: string | ContextMenuPredefinedMessage): void;
254
+ /**
255
+ * Requests that a panel close, honoring its dirty flag and any registered close guard.
256
+ * Resolves once the close (or user cancellation) has been resolved.
257
+ *
258
+ * @remarks If called before the provider mounts, the request is queued and this
259
+ * returns an already-resolved promise immediately — the caller can't observe the
260
+ * eventual outcome of a queued call, only that the request was accepted.
261
+ */
262
+ requestClosePanel(id: string, options?: {
263
+ force?: boolean;
264
+ onConfirm?: (opts?: DirtyStateOptions) => Promise<boolean>;
265
+ }): Promise<void>;
266
+ /** Docks a panel to one of the workspace's outer edges. */
267
+ dockPanelToWorkspaceEdge(id: string, position: SplitDirection): void;
268
+ /** Shows a context menu using the app's configured ContextMenuAdapter. */
269
+ showContextMenu(options: ShowContextMenuOptions): void;
225
270
  publish<K extends keyof (TUserEvents & BuiltInPanelEvents)>(event: K, data: (TUserEvents & BuiltInPanelEvents)[K]): void;
226
271
  subscribe<K extends keyof (TUserEvents & BuiltInPanelEvents)>(event: K, callback: (data: (TUserEvents & BuiltInPanelEvents)[K]) => void): () => void;
227
272
  /** Subscribe to panel open events. Fires only for newly created panels. */
@@ -782,6 +827,19 @@ declare const useStyleClasses: () => StyleClasses;
782
827
  * ```
783
828
  */
784
829
  declare const useRegistry: () => PanelRegistryClass;
830
+ /** The on-disk shape produced by `saveLayout()` and accepted by `loadLayout()`/`initialState`. */
831
+ interface SerializedLayout {
832
+ /** Schema version — absent on layouts saved before this field was introduced (treated as 0). */
833
+ version?: number;
834
+ gridRoot: LayoutNode;
835
+ floating: FloatingWindow[];
836
+ minimized: {
837
+ id: string;
838
+ title: string | ContextMenuPredefinedMessage;
839
+ component: string;
840
+ }[];
841
+ panels: Record<string, PanelInfo>;
842
+ }
785
843
  /**
786
844
  * Props for `<DockableDesktopProvider>` and `<WindowManagerProvider>`.
787
845
  * Also exported as `DockableDesktopProviderProps` for consumers who use
@@ -814,6 +872,13 @@ interface WindowManagerProviderProps {
814
872
  windowClass?: string;
815
873
  /** CSS class applied to the inner content area of floating panel windows. */
816
874
  windowBodyClass?: string;
875
+ /**
876
+ * Starting z-index for floating windows and the library's own chrome overlays
877
+ * (context menu, toolbar flyout, modal stack, toast, workspace edge zones),
878
+ * all of which shift together via `--rdd-z-base`. Set this above/below a host
879
+ * app's own modal z-index range to control stacking against it. @default 1000
880
+ */
881
+ zIndexBase?: number;
817
882
  }
818
883
  declare const WindowManagerProvider: React$1.FC<WindowManagerProviderProps>;
819
884
  declare function useWindowManagerState(): WindowState;
@@ -1073,6 +1138,17 @@ declare const FormContainerProvider: Provider<FormContainerContract>;
1073
1138
  * (resize, close, minimize, restore, activate, deactivate, container-type changes).
1074
1139
  */
1075
1140
  declare const useFormContainer: () => FormContainerContract;
1141
+ /**
1142
+ * Reactive alternative to calling {@link FormContainerContract.getDimensions} yourself.
1143
+ * Returns the panel's current `{ width, height }`, or `null` before it has been laid
1144
+ * out, and re-renders whenever the panel's rendered box changes — including resizes
1145
+ * caused by the workspace itself (a grid split being dragged, docking, floating, or
1146
+ * tab activation), not just resizes of an element the panel created.
1147
+ */
1148
+ declare const usePanelSize: () => {
1149
+ width: number;
1150
+ height: number;
1151
+ } | null;
1076
1152
 
1077
1153
  /** Unique string identifier for panel/modal instances. */
1078
1154
  type PanelInstanceId = string;
@@ -1280,7 +1356,7 @@ interface SidebarProps {
1280
1356
  /** Which side the activity bar and drawer appear on. Default: 'right' */
1281
1357
  position?: 'left' | 'right';
1282
1358
  tabs: SidebarTab[];
1283
- /** Initial drawer width in pixels. Default: 220 */
1359
+ /** Initial drawer width in pixels. Default: 280 */
1284
1360
  defaultWidth?: number;
1285
1361
  /** Minimum drawer width in pixels during drag-resize. Default: 150 */
1286
1362
  minWidth?: number;
@@ -1302,8 +1378,6 @@ interface SidebarProps {
1302
1378
  onStripVisibilityChange?: (visible: boolean) => void;
1303
1379
  /** Main workspace content rendered alongside the sidebar. */
1304
1380
  children?: React$1.ReactNode;
1305
- /** @deprecated Use defaultWidth (number, pixels) instead. */
1306
- drawerWidth?: string;
1307
1381
  }
1308
1382
  /**
1309
1383
  * Imperative handle exposed by `<Sidebar ref={...}>`.
@@ -1344,14 +1418,14 @@ declare const Sidebar: React$1.ForwardRefExoticComponent<SidebarProps & React$1.
1344
1418
  * Returns sidebar control functions from anywhere inside a `<Sidebar>` tree,
1345
1419
  * including floating panels rendered via `{children}`.
1346
1420
  *
1347
- * Returns a no-op object with a console warning when called outside a Sidebar.
1421
+ * @throws Error if used outside of a {@link Sidebar}.
1348
1422
  */
1349
1423
  declare function useSidebar(): SidebarContextValue;
1350
1424
  /**
1351
1425
  * Returns tab-specific control functions for components rendered inside a
1352
1426
  * sidebar tab's `renderContent` tree.
1353
1427
  *
1354
- * Returns a no-op object with a console warning when called outside tab content.
1428
+ * @throws Error if used outside of a {@link Sidebar} tab's `renderContent` tree.
1355
1429
  */
1356
1430
  declare function useSidebarTab(): SidebarTabContextValue;
1357
1431
 
@@ -1380,7 +1454,7 @@ declare const ToolbarProvider: React$1.FC<{
1380
1454
  * Returns toolbar state and control functions from anywhere inside
1381
1455
  * a `<DockableDesktopProvider>` tree.
1382
1456
  *
1383
- * Returns a no-op object with a console warning when called outside the provider.
1457
+ * @throws Error if used outside of a {@link DockableDesktopProvider}.
1384
1458
  */
1385
1459
  declare function useToolbar(): ToolbarContextValue;
1386
1460
 
@@ -1417,8 +1491,8 @@ interface ToolbarRadioItem {
1417
1491
  /**
1418
1492
  * An independent on/off toggle modifier (e.g. snap-to-grid).
1419
1493
  *
1420
- * Supports both uncontrolled mode (omit `active` — state lives in
1421
- * ToolbarContext, keyed by `id`) and controlled mode (provide `active` —
1494
+ * Supports both uncontrolled mode (omit `rdd-active` — state lives in
1495
+ * ToolbarContext, keyed by `id`) and controlled mode (provide `rdd-active` —
1422
1496
  * the caller is the single source of truth and must update the prop in
1423
1497
  * response to `onToggle`). Controlled mode is what lets independent
1424
1498
  * instances of the same panel type report independent active state
@@ -1929,8 +2003,9 @@ declare const PanelContributionProvider: React$1.FC<{
1929
2003
  * `useMemo`/`useCallback`) to avoid republishing on every unrelated re-render.
1930
2004
  *
1931
2005
  * Contributions are only ever surfaced while this panel is `state.activePanelId` —
1932
- * see `useActivePanelContribution()`. No-op outside a `PanelContributionProvider` tree.
2006
+ * see `useActivePanelContribution()`.
1933
2007
  *
2008
+ * @throws Error if used outside of a {@link PanelContributionProvider}.
1934
2009
  * @example
1935
2010
  * function MapPanel() {
1936
2011
  * const [controller, setController] = useState<'pan' | 'draw' | 'measure'>('pan');
@@ -1950,6 +2025,8 @@ declare function usePanelContribution(contribution: PanelContribution): void;
1950
2025
  * via `usePanelContribution()`, or `null` if no panel is active or the active panel
1951
2026
  * hasn't contributed anything. Intended for the app shell to merge into its own
1952
2027
  * `<Toolbar items={...}>` / `<Sidebar tabs={...}>` calls.
2028
+ *
2029
+ * @throws Error if used outside of a {@link PanelContributionProvider}.
1953
2030
  */
1954
2031
  declare function useActivePanelContribution(): PanelContribution | null;
1955
2032
  /**
@@ -1975,4 +2052,83 @@ declare function useMergedToolbarItems(staticItems: ToolbarItem$1[]): ToolbarIte
1975
2052
  */
1976
2053
  declare function useMergedSidebarTabs(staticTabs: SidebarTab[], fallbackIcon?: React$1.ReactNode): SidebarTab[];
1977
2054
 
1978
- export { type BuiltInPanelEvents, type ButtonVariant, type CloseOptions, ConfirmationForm, type ConfirmationFormProps, ContextMenu, type ContextMenuAdapter, type ContextMenuCheckbox, type ContextMenuHandle, type ContextMenuItem, type ContextMenuLabel, type ContextMenuPredefinedMessage, type ContextMenuProps, ContextMenuProvider, type ContextMenuSeparator, type ContextMenuSimpleItem, type ContextMenuSubMenu, DefaultContextMenuAdapter, DockableDesktopProvider, type DockableDesktopProviderProps, type DropPosition, type DropTarget, type FloatAnchor, type FloatingWindow, FormContainerContext, type FormContainerContract, FormContainerProvider, type LayoutGridNode, type LayoutLeafNode, type LayoutNode, LeftPanelRenderer, type ManagedWindowConfig, type MenuItemAction, type MessageFormatter, type ModalOptions, ModalStackRenderer, type PanelActions, type PanelContribution, PanelContributionProvider, type PanelDefinition, PanelFloatingWindow, type PanelFloatingWindowManagerHandle, type PanelFloatingWindowProps, type PanelInfo, type PanelInstance, type PanelInstanceId, PanelOverlayRoot, type PanelOverlayRootProps, PanelProvider, PanelRegistry, PanelRegistryClass, type PanelRegistryEntry, type PanelSidebarSection, type PanelState, type PanelTitle, PanelToolbar, ToolbarItem as PanelToolbarItem, type PanelToolbarProps, ToolbarSeparator as PanelToolbarSeparator, type PredefinedMessageKey, type ResolvedToastOptions, RightPanelRenderer, type SearchResult, type ShowContextMenuOptions, type SidePanelOptions, SidePanelRenderer, type SidePanelRendererProps, Sidebar, type SidebarContextValue, type SidebarHandle, type SidebarProps, type SidebarTab, type SidebarTabContextValue, type SplitDirection, type SplitOrientation, type StyleClasses, type TaskbarVisibility, type ToastAdapter, ToastContainer, type ToastContainerProps, type ToastFunction, type ToastOptions, type ToastPosition, type ToastPromiseMessages, type ToastType, Toolbar, type ToolbarActionItem, ToolbarButton, type ToolbarButtonProps, ToolbarCenter, type ToolbarContextValue, type ToolbarGroupEntry, type ToolbarGroupItem, type ToolbarGroupSubItem, type ToolbarHandle, type ToolbarItem$1 as ToolbarItem, type ToolbarPosition, type ToolbarProps, ToolbarProvider, type ToolbarRadioItem, ToolbarSearchInput, type ToolbarSearchInputProps, type ToolbarSeparator$1 as ToolbarSeparator, ToolbarSpacer, ToolbarToggle, type ToolbarToggleItem, type ToolbarToggleProps, type ToolbarVariant, type UsePanelFloatingWindowReturn, type WindowActions, WindowManager, type WindowManagerProps, WindowManagerProvider, type WindowManagerProviderProps, type WindowState, WorkspaceClient, type WorkspaceClientConfig, defaultPredefinedMessages, formatLabel, sidebarSectionToTab, toast, useActivePanelContribution, useFormContainer, useFormatMessage, useMergedSidebarTabs, useMergedToolbarItems, usePanelActions, usePanelContext, usePanelContextMenu, usePanelContribution, usePanelFloatingWindow, usePanelFloatingWindowManager, usePanelId, usePanelState, usePredefinedMessages, useRegistry, useShowContextMenu, useSidebar, useSidebarTab, useStyleClasses, useToolbar, useWindowManagerActions, useWindowManagerState };
2055
+ /**
2056
+ * Shared pointer-drag-resize primitives.
2057
+ *
2058
+ * Extracted from four previously-independent implementations (the workspace grid
2059
+ * split resizer, the sidebar drawer resizer, and two floating-window resize-handle
2060
+ * implementations) that had quietly drifted apart in exactly the kind of detail
2061
+ * (an inline-style property present in one and missing in the other) that once
2062
+ * caused a real, user-visible bug. This file is the single place that mechanic now
2063
+ * lives, so it can't drift again.
2064
+ */
2065
+ interface PointerDragConfig<TStart> {
2066
+ /** The element to capture the pointer on — normally the handle the user grabbed. */
2067
+ element: HTMLElement;
2068
+ pointerId: number;
2069
+ /** The pointerdown event's clientX/clientY, used as the delta origin. */
2070
+ startClientX: number;
2071
+ startClientY: number;
2072
+ /** Snapshot whatever state the caller needs at drag start (sizes, positions, ...). */
2073
+ captureStart: () => TStart;
2074
+ /** Called on every pointermove with the delta from the drag's start position. */
2075
+ onMove: (dx: number, dy: number, start: TStart) => void;
2076
+ /** Called once when the drag ends (pointerup or pointercancel). */
2077
+ onEnd?: (start: TStart) => void;
2078
+ /** Classes toggled on the given elements for the duration of the drag. */
2079
+ activeClasses?: Array<{
2080
+ el: HTMLElement;
2081
+ classes: string[];
2082
+ }>;
2083
+ }
2084
+ /**
2085
+ * Starts a pointer-capture-based drag: captures the pointer on `element`, tracks
2086
+ * movement via listeners scoped to that element's own lifetime (not `window`), and
2087
+ * cleans up automatically on release or cancel.
2088
+ */
2089
+ declare function startPointerDrag<TStart>(config: PointerDragConfig<TStart>): void;
2090
+ type ResizeDir = 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw';
2091
+ interface ResizeRect {
2092
+ x: number;
2093
+ y: number;
2094
+ w: number;
2095
+ h: number;
2096
+ }
2097
+ interface ResizeConstraints {
2098
+ minW: number;
2099
+ minH: number;
2100
+ /** Upper bound on width — only applies to eastward growth (dir includes 'e'). */
2101
+ maxW?: number;
2102
+ /** Upper bound on height — only applies to southward growth (dir includes 's'). */
2103
+ maxH?: number;
2104
+ /** Lower bound on the resulting x — only applies to westward growth (dir includes 'w'). */
2105
+ minX?: number;
2106
+ /** Lower bound on the resulting y — only applies to northward growth (dir includes 'n'). */
2107
+ minY?: number;
2108
+ }
2109
+ /**
2110
+ * Pure function computing the new rect for an 8-directional resize handle drag.
2111
+ *
2112
+ * `maxW`/`maxH` and `minX`/`minY` are independent, direction-scoped constraints
2113
+ * rather than one "container bound" — a resize toward the fixed edge (e/s) is
2114
+ * naturally bounded by a maximum dimension, while a resize toward the moving edge
2115
+ * (w/n) is naturally bounded by a minimum position, and the two calling sites this
2116
+ * was extracted from need different subsets of these (see WindowManager.tsx's
2117
+ * `startResize`, which omits all four and lets a window grow unbounded and be
2118
+ * dragged fully off-screen, vs. PanelOverlay.tsx's `handleResizePointerDown`, which
2119
+ * supplies all four to keep windows within their container).
2120
+ */
2121
+ declare function computeResizedRect(dir: ResizeDir, dx: number, dy: number, start: ResizeRect, constraints: ResizeConstraints): ResizeRect;
2122
+
2123
+ /**
2124
+ * Reactively reads the workspace's current `data-color-scheme` attribute
2125
+ * (set on `document.documentElement` by `<WindowManager />`), returning
2126
+ * `'dark'` or `'light'` and re-rendering whenever it changes.
2127
+ *
2128
+ * Useful for panel content that needs to react to the same scheme the
2129
+ * workspace itself is using — e.g. swapping a map's tile layer or an
2130
+ * embedded editor's theme to match.
2131
+ */
2132
+ declare function useColorScheme(): 'dark' | 'light';
2133
+
2134
+ export { type BuiltInPanelEvents, type ButtonVariant, type CloseOptions, ConfirmationForm, type ConfirmationFormProps, ContextMenu, type ContextMenuAdapter, type ContextMenuCheckbox, type ContextMenuHandle, type ContextMenuItem, type ContextMenuLabel, type ContextMenuPredefinedMessage, type ContextMenuProps, ContextMenuProvider, type ContextMenuSeparator, type ContextMenuSimpleItem, type ContextMenuSubMenu, DefaultContextMenuAdapter, DockableDesktopProvider, type DockableDesktopProviderProps, type DropPosition, type DropTarget, type FloatAnchor, type FloatingWindow, FormContainerContext, type FormContainerContract, FormContainerProvider, type LayoutGridNode, type LayoutLeafNode, type LayoutNode, LeftPanelRenderer, type ManagedWindowConfig, type MenuItemAction, type MessageFormatter, type ModalOptions, ModalStackRenderer, type PanelActions, type PanelContribution, PanelContributionProvider, type PanelDefinition, PanelFloatingWindow, type PanelFloatingWindowManagerHandle, type PanelFloatingWindowProps, type PanelInfo, type PanelInstance, type PanelInstanceId, PanelOverlayRoot, type PanelOverlayRootProps, PanelProvider, PanelRegistry, PanelRegistryClass, type PanelRegistryEntry, type PanelSidebarSection, type PanelState, type PanelTitle, PanelToolbar, ToolbarItem as PanelToolbarItem, type PanelToolbarProps, ToolbarSeparator as PanelToolbarSeparator, type PointerDragConfig, type PredefinedMessageKey, type ResizeConstraints, type ResizeDir, type ResizeRect, type ResolvedToastOptions, RightPanelRenderer, type SearchResult, type SerializedLayout, type ShowContextMenuOptions, type SidePanelOptions, SidePanelRenderer, type SidePanelRendererProps, Sidebar, type SidebarContextValue, type SidebarHandle, type SidebarProps, type SidebarTab, type SidebarTabContextValue, type SplitDirection, type SplitOrientation, type StyleClasses, type TaskbarVisibility, type ToastAdapter, ToastContainer, type ToastContainerProps, type ToastFunction, type ToastOptions, type ToastPosition, type ToastPromiseMessages, type ToastType, Toolbar, type ToolbarActionItem, ToolbarButton, type ToolbarButtonProps, ToolbarCenter, type ToolbarContextValue, type ToolbarGroupEntry, type ToolbarGroupItem, type ToolbarGroupSubItem, type ToolbarHandle, type ToolbarItem$1 as ToolbarItem, type ToolbarPosition, type ToolbarProps, ToolbarProvider, type ToolbarRadioItem, ToolbarSearchInput, type ToolbarSearchInputProps, type ToolbarSeparator$1 as ToolbarSeparator, ToolbarSpacer, ToolbarToggle, type ToolbarToggleItem, type ToolbarToggleProps, type ToolbarVariant, type UsePanelFloatingWindowReturn, type WindowActions, WindowManager, type WindowManagerProps, WindowManagerProvider, type WindowManagerProviderProps, type WindowState, WorkspaceClient, type WorkspaceClientConfig, computeResizedRect, defaultPredefinedMessages, formatLabel, sidebarSectionToTab, startPointerDrag, toast, useActivePanelContribution, useColorScheme, useFormContainer, useFormatMessage, useMergedSidebarTabs, useMergedToolbarItems, usePanelActions, usePanelContext, usePanelContextMenu, usePanelContribution, usePanelFloatingWindow, usePanelFloatingWindowManager, usePanelId, usePanelSize, usePanelState, usePredefinedMessages, useRegistry, useShowContextMenu, useSidebar, useSidebarTab, useStyleClasses, useToolbar, useWindowManagerActions, useWindowManagerState };