react-dockable-desktop 7.8.0 → 7.10.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
@@ -135,6 +135,52 @@ interface DropTarget {
135
135
  leafId: string;
136
136
  position: DropPosition;
137
137
  }
138
+ /**
139
+ * Where a user is about to move a panel, as `canDrop` sees it (7.9.0). Positions are the ones the
140
+ * move applies: under RTL, a drop on the zone drawn on the screen's right is `'left'`.
141
+ * - `group`: into a group, on one side (a new split) or `'center'` (as a tab, also between tabs);
142
+ * - `edge`: along a workspace edge, as a full-width or full-height strip;
143
+ * - `float`: into a floating window, pinned to a corner, or free (`anchor: null`, a tab dropped
144
+ * on nothing).
145
+ */
146
+ type PanelDropTarget = {
147
+ kind: 'group';
148
+ leafId: string;
149
+ position: DropPosition;
150
+ } | {
151
+ kind: 'edge';
152
+ side: SplitDirection;
153
+ } | {
154
+ kind: 'float';
155
+ anchor: FloatAnchor | null;
156
+ };
157
+ /**
158
+ * What `renderTabContent` receives for each tab (7.10.0). `title` is already formatted and `icon`
159
+ * is the icon the built-in content shows, so the built-in content is one line to re-create:
160
+ * `<>{icon} {title}{dirty && ' *'}</>`.
161
+ */
162
+ interface TabContentProps {
163
+ /** The panel's instance id. */
164
+ panelId: string;
165
+ /** The panel's registered kind: branch on it for a per-type look. */
166
+ component: string;
167
+ /** The title, formatted: messages resolved, functions called. */
168
+ title: string;
169
+ /** The icon the built-in content shows: set at runtime, else the registration's, else the default. */
170
+ icon: React$1.ReactNode;
171
+ /** Has unsaved changes; the built-in content shows ` *`. */
172
+ dirty: boolean;
173
+ /** The tab shown in its group. */
174
+ selected: boolean;
175
+ /** The workspace's active panel. */
176
+ focused: boolean;
177
+ }
178
+ /** The argument `canDrop` receives: which panel, of which registered kind, is going where. (7.9.0) */
179
+ interface PanelDrop {
180
+ panelId: string;
181
+ component: string;
182
+ to: PanelDropTarget;
183
+ }
138
184
  /**
139
185
  * Grid layout branch node containing nested splits and relative flex sizes.
140
186
  */
@@ -634,6 +680,8 @@ interface InternalWindowActions extends WorkspaceActions {
634
680
  getPanelContextMenuItems: (panelId: string) => ContextMenuItem[];
635
681
  /** @internal */
636
682
  registerContextMenuFn: (fn: (options: ShowContextMenuOptions) => void) => () => void;
683
+ /** @internal Whether the user may move `panelId` to `to`: its type's rules, then `canDrop`. (7.9.0) */
684
+ isDropAllowed: (panelId: string, to: PanelDropTarget) => boolean;
637
685
  }
638
686
  /** Represents custom CSS classes injected into layout parts. */
639
687
  interface HostClasses {
@@ -708,6 +756,19 @@ interface PanelRegistryEntry {
708
756
  };
709
757
  /** Enables/disables window drag interactions. */
710
758
  canDrag?: boolean;
759
+ /**
760
+ * `false`: the user can't make this panel floating. A tab drag can't end in a floating window
761
+ * (dropped on nothing or on a corner, it stays where it was), and the "Float" and taskbar
762
+ * "Maximize" menu items are hidden. A window the app floated itself can still be moved. The
763
+ * app's own `floatPanel` always works. @default true (7.9.0)
764
+ */
765
+ canFloat?: boolean;
766
+ /**
767
+ * `false`: the user can't dock this panel. Dragging it offers no group, tab or edge targets
768
+ * (corners still anchor a floating window), so it stays floating. The app's own docking calls
769
+ * always work; give the type `initialTarget: 'floating'` so it opens floating. @default true (7.9.0)
770
+ */
771
+ canDock?: boolean;
711
772
  /** Enables/disables minimizing of the panel instance. */
712
773
  canMinimize?: boolean;
713
774
  /** Enables/disables closing actions for the tab/window. */
@@ -729,7 +790,8 @@ interface PanelRegistryEntry {
729
790
  * `false` unmounts the panel's component while it is hidden (an unselected tab, or minimized)
730
791
  * and mounts it afresh when it is shown, to free what a heavy, rarely shown panel holds. Its
731
792
  * own state is lost each time; its tab, title and lifecycle continue (`onClose` is not called),
732
- * and the taskbar shows a placeholder instead of a live preview. While it is unmounted,
793
+ * and the taskbar shows a placeholder instead of a live preview. While it is unmounted, a
794
+ * guard it registered with `useBeforeClose` is not active (its dirty flag still is), and
733
795
  * `saveLayout()` saves its open-time props. @default true: panels stay mounted and keep their
734
796
  * state, as they always have. (7.8.0)
735
797
  */
@@ -1090,6 +1152,24 @@ interface WorkspaceClientConfig {
1090
1152
  * app's own modal z-index range to control stacking against it. Default: 1000.
1091
1153
  */
1092
1154
  zIndexBase?: number;
1155
+ /**
1156
+ * Veto where users can move panels (7.9.0). Called for each place a dragged panel could go, and
1157
+ * for the built-in "Float" and "Maximize" menu items: return `false` and that target isn't
1158
+ * offered (its drop zone doesn't appear) and the move doesn't happen. It runs after the panel
1159
+ * type's own `canFloat` / `canDock`, and only for what the user does: the app's own calls
1160
+ * (`floatPanel`, `dockPanelToGroup`, `openPanel`) always work. Keep it fast and pure; it runs
1161
+ * while the pointer moves.
1162
+ *
1163
+ * @example
1164
+ * ```ts
1165
+ * createWorkspace({
1166
+ * panels,
1167
+ * // Nothing but tool panels in the left group.
1168
+ * canDrop: ({ component, to }) => !(to.kind === 'group' && to.leafId === 'tools' && component !== 'tool'),
1169
+ * });
1170
+ * ```
1171
+ */
1172
+ canDrop?: (drop: PanelDrop) => boolean;
1093
1173
  }
1094
1174
  /**
1095
1175
  * A workspace: the layout, every action on it, the panel registry and the event bus. Create one
@@ -1422,7 +1502,7 @@ declare const AlertForm: React$1.FC<RddAlertProps>;
1422
1502
  * with the internal components under their 7.0 names.
1423
1503
  */
1424
1504
 
1425
- /** Configuration for {@link createWorkspace}. */
1505
+ /** Configuration for `createWorkspace()`. */
1426
1506
  interface WorkspaceConfig extends Omit<WorkspaceClientConfig, 'predefinedMessages'> {
1427
1507
  /** Overrides any subset of the built-in message table. */
1428
1508
  messages?: Record<string, MessageDescriptor>;
@@ -1434,6 +1514,45 @@ interface WorkspaceConfig extends Omit<WorkspaceClientConfig, 'predefinedMessage
1434
1514
  */
1435
1515
  interface Workspace<TEvents extends object = Record<string, unknown>> extends WorkspaceClient<TEvents> {
1436
1516
  }
1517
+ /** The type-only mark {@link definePanels} puts on a map. No such value exists at runtime. */
1518
+ declare const panelsBrand: unique symbol;
1519
+ /** A panel map marked by {@link definePanels}, so `createWorkspace` types `openPanel` from it (7.10.0). */
1520
+ type PanelMap<TPanels extends Record<string, PanelDefinition> = Record<string, PanelDefinition>> = TPanels & {
1521
+ readonly [panelsBrand]: true;
1522
+ };
1523
+ /** The props `openPanel` passes to a registered panel: its component's props, without `panelId`. */
1524
+ type PanelPropsOf<TDefinition> = TDefinition extends {
1525
+ component: React$1.ComponentType<infer P>;
1526
+ } ? Omit<P, 'panelId'> : never;
1527
+ /**
1528
+ * Marks a panel map for typing (7.10.0). Returns it unchanged; a workspace created from it gets a
1529
+ * typed `openPanel`: only registered names, and `props` checked against that panel's component.
1530
+ *
1531
+ * @example
1532
+ * ```ts
1533
+ * const panels = definePanels({ map: { component: MapPanel }, chart: { component: ChartPanel } });
1534
+ * const workspace = createWorkspace({ panels });
1535
+ * workspace.openPanel('c1', 'chart', { props: { series: 3 } }); // checked against ChartPanel's props
1536
+ * ```
1537
+ */
1538
+ declare function definePanels<const TPanels extends Record<string, PanelDefinition>>(panels: TPanels): PanelMap<TPanels>;
1539
+ /**
1540
+ * A workspace created from {@link definePanels}: the same object, with `openPanel` typed from the
1541
+ * registry. Pass it anywhere a {@link Workspace} goes. `useWorkspace()` stays untyped; keep this
1542
+ * one for typed calls.
1543
+ */
1544
+ interface TypedWorkspace<TPanels extends Record<string, PanelDefinition>, TEvents extends object = Record<string, unknown>> extends Workspace<TEvents> {
1545
+ /** `openPanel`, typed: a registered name, and that panel's props. */
1546
+ openPanel<K extends keyof TPanels & string>(id: string, component: K, options?: OpenPanelOptions<PanelPropsOf<TPanels[K]>>): void;
1547
+ }
1548
+ /**
1549
+ * Creates a workspace from a map marked by {@link definePanels} (7.10.0): `openPanel` takes only
1550
+ * the registered names, with `props` checked against each panel's component. To name the events
1551
+ * as well, pass both type arguments: `createWorkspace<typeof panels, AppEvents>({ panels })`.
1552
+ */
1553
+ declare function createWorkspace<TPanels extends Record<string, PanelDefinition>, TEvents extends object = Record<string, unknown>>(config: WorkspaceConfig & {
1554
+ panels: PanelMap<TPanels>;
1555
+ }): TypedWorkspace<TPanels, TEvents>;
1437
1556
  /**
1438
1557
  * Creates a workspace. Pass it to `<DockableDesktopProvider workspace={…}>`.
1439
1558
  *
@@ -1716,6 +1835,13 @@ interface RddDesktopProps {
1716
1835
  * floating window can still be docked into it. Floating windows still show over it. (7.8.0)
1717
1836
  */
1718
1837
  emptyWorkspace?: React$1.ReactNode;
1838
+ /**
1839
+ * Your own content for each tab in the grid: an icon, the title, a badge, a status dot (7.10.0).
1840
+ * It replaces the built-in icon, title and dirty marker; the tab itself (dragging, keyboard,
1841
+ * accessibility, its context menu, header actions and close button) stays the library's.
1842
+ * Called with the tab's `TabContentProps`; branch on `component` for a per-type look.
1843
+ */
1844
+ renderTabContent?: (tab: TabContentProps) => React$1.ReactNode;
1719
1845
  }
1720
1846
  /**
1721
1847
  * The desktop itself: the docked grid of tab groups, the floating windows, the taskbar of
@@ -2718,6 +2844,11 @@ interface PointerDragConfig<TStart> {
2718
2844
  onMove: (dx: number, dy: number, start: TStart) => void;
2719
2845
  /** Called once when the drag ends (pointerup or pointercancel). */
2720
2846
  onEnd?: (start: TStart) => void;
2847
+ /**
2848
+ * Called instead of `onEnd` when the drag is cut short: the window loses focus, or the pointer
2849
+ * capture is lost (the element was removed mid-drag). Without it, `onEnd` is called. (7.9.0)
2850
+ */
2851
+ onCancel?: (start: TStart) => void;
2721
2852
  /** Classes toggled on the given elements for the duration of the drag. */
2722
2853
  activeClasses?: Array<{
2723
2854
  el: HTMLElement;
@@ -2727,7 +2858,8 @@ interface PointerDragConfig<TStart> {
2727
2858
  /**
2728
2859
  * Starts a pointer-capture-based drag: captures the pointer on `element`, tracks
2729
2860
  * movement via listeners scoped to that element's own lifetime (not `window`), and
2730
- * cleans up automatically on release or cancel.
2861
+ * cleans up automatically on release or cancel, and (7.9.0) when the window loses focus
2862
+ * or the capture is lost, so a drag can never outlive its element or leave its classes behind.
2731
2863
  */
2732
2864
  declare function startPointerDrag<TStart>(config: PointerDragConfig<TStart>): void;
2733
2865
  type ResizeDir = 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw';
@@ -2788,4 +2920,4 @@ declare function isElementRtl(el: HTMLElement | null): boolean;
2788
2920
  */
2789
2921
  declare function isComputedRtl(el: Element | null | undefined): boolean;
2790
2922
 
2791
- export { type AlertOptions, type BuiltInEvents, type ButtonVariant, type CloseOptions, type ConfirmOptions, type ContainerType, type ContextMenuAdapter, type ContextMenuCheckbox, type ContextMenuHandle, type ContextMenuItem, type ContextMenuLabel, type ContextMenuSeparator, type ContextMenuSimpleItem, type ContextMenuSubMenu, type DirtyStateOptions, DockableDesktopProvider, type DockableDesktopProviderProps, type DropPosition, type DropTarget, type FloatAnchor, type FloatingWidgetsApi, type FloatingWindow, type HostClasses, type LayoutGridNode, type LayoutLeafNode, type LayoutNode, type ManagedWidget, type MenuItemAction, type MessageDescriptor, type MessageFormatter, type MessageKey, type ModalOptions, type ModalsApi, type OpenPanelOptions, type OverlayId, type OverlayInstance, type OverlayState, type PanelContribution, type PanelDefinition, type PanelEvents, type PanelFloatPlacement, type PanelHandle, type PanelInfo, PanelRegistry, type PanelRegistryEntry, type PanelSidebarSection, type PanelState, type PanelTitle, type PanelTitleDescriptor, type PointerDragConfig, AlertForm as RddAlert, type RddAlertProps, ConfirmationForm as RddConfirm, type RddConfirmProps, RddContextMenu, type RddContextMenuProps, WindowManager as RddDesktop, type RddDesktopProps, PanelFloatingWindow as RddFloatingWidget, type RddFloatingWidgetProps, ModalStackRenderer as RddModals, PanelOverlayRoot as RddPanelOverlay, type RddPanelOverlayProps, PanelToolbar as RddPanelToolbar, type RddPanelToolbarProps, SecondarySidebar as RddSecondarySidebar, type RddSecondarySidebarProps, RddSidePanels, type RddSidePanelsProps, Sidebar as RddSidebar, type RddSidebarProps, ToastContainer as RddToasts, type RddToastsProps, Toolbar as RddToolbar, ToolbarButton as RddToolbarButton, type RddToolbarButtonProps, ToolbarCenter as RddToolbarCenter, ToolbarItem as RddToolbarItem, type RddToolbarProps, ToolbarSearchInput as RddToolbarSearch, type RddToolbarSearchProps, ToolbarSeparator as RddToolbarSeparator, ToolbarSpacer as RddToolbarSpacer, ToolbarToggle as RddToolbarToggle, type RddToolbarToggleProps, type ResizeConstraints, type ResizeDir, type ResizeRect, type ResolvedToastOptions, type SearchResult, type SerializedLayout, type ShowContextMenuOptions, type SidePanelOptions, type SidePanelsApi, type SidebarActionButton, type SidebarContextValue as SidebarContext, type SidebarCustomEntry, type SidebarHandle, type SidebarHeaderAction, type SidebarRailEntry, type SidebarTab, type SidebarTabContextValue as SidebarTabContext, type SplitDirection, type SplitOrientation, type Stretch, type TaskbarVisibility, type ToastAdapter, type ToastFunction, type ToastOptions, type ToastPosition, type ToastPromiseMessages, type ToastType, type ToolbarActionItem, type ToolbarContextValue, type ToolbarGroupEntry, type ToolbarGroupItem, type ToolbarGroupSubItem, type ToolbarHandle, type ToolbarItem$1 as ToolbarItem, type ToolbarPosition, type ToolbarRadioItem, type ToolbarSeparator$1 as ToolbarSeparator, type ToolbarToggleItem, type ToolbarVariant, type Workspace, type WorkspaceActions, type WorkspaceConfig, type WorkspaceState, computeResizedRect, createWorkspace, defaultPredefinedMessages as defaultMessages, formatLabel, isComputedRtl, isElementRtl, isSerializable, sidebarSectionToTab as sectionToTab, startPointerDrag, toast, useActivePanelContribution as useActiveContribution, useBeforeClose, useColorScheme, useShowContextMenu as useContextMenu, usePanelFloatingWindowManager as useFloatingWidgets, useFormatMessage, useStyleClasses as useHostClasses, useMergedSidebarTabs, useMergedToolbarItems, usePredefinedMessages as useMessages, useModals, usePanel, usePanelContextMenu, usePanelContribution, usePanelEvents, usePanelSize, useSaveState, useSidePanels, useSidebar, useSidebarTab, useToolbar, useWorkspace, useWindowManagerState as useWorkspaceState };
2923
+ export { type AlertOptions, type BuiltInEvents, type ButtonVariant, type CloseOptions, type ConfirmOptions, type ContainerType, type ContextMenuAdapter, type ContextMenuCheckbox, type ContextMenuHandle, type ContextMenuItem, type ContextMenuLabel, type ContextMenuSeparator, type ContextMenuSimpleItem, type ContextMenuSubMenu, type DirtyStateOptions, DockableDesktopProvider, type DockableDesktopProviderProps, type DropPosition, type DropTarget, type FloatAnchor, type FloatingWidgetsApi, type FloatingWindow, type HostClasses, type LayoutGridNode, type LayoutLeafNode, type LayoutNode, type ManagedWidget, type MenuItemAction, type MessageDescriptor, type MessageFormatter, type MessageKey, type ModalOptions, type ModalsApi, type OpenPanelOptions, type OverlayId, type OverlayInstance, type OverlayState, type PanelContribution, type PanelDefinition, type PanelDrop, type PanelDropTarget, type PanelEvents, type PanelFloatPlacement, type PanelHandle, type PanelInfo, type PanelMap, type PanelPropsOf, PanelRegistry, type PanelRegistryEntry, type PanelSidebarSection, type PanelState, type PanelTitle, type PanelTitleDescriptor, type PointerDragConfig, AlertForm as RddAlert, type RddAlertProps, ConfirmationForm as RddConfirm, type RddConfirmProps, RddContextMenu, type RddContextMenuProps, WindowManager as RddDesktop, type RddDesktopProps, PanelFloatingWindow as RddFloatingWidget, type RddFloatingWidgetProps, ModalStackRenderer as RddModals, PanelOverlayRoot as RddPanelOverlay, type RddPanelOverlayProps, PanelToolbar as RddPanelToolbar, type RddPanelToolbarProps, SecondarySidebar as RddSecondarySidebar, type RddSecondarySidebarProps, RddSidePanels, type RddSidePanelsProps, Sidebar as RddSidebar, type RddSidebarProps, ToastContainer as RddToasts, type RddToastsProps, Toolbar as RddToolbar, ToolbarButton as RddToolbarButton, type RddToolbarButtonProps, ToolbarCenter as RddToolbarCenter, ToolbarItem as RddToolbarItem, type RddToolbarProps, ToolbarSearchInput as RddToolbarSearch, type RddToolbarSearchProps, ToolbarSeparator as RddToolbarSeparator, ToolbarSpacer as RddToolbarSpacer, ToolbarToggle as RddToolbarToggle, type RddToolbarToggleProps, type ResizeConstraints, type ResizeDir, type ResizeRect, type ResolvedToastOptions, type SearchResult, type SerializedLayout, type ShowContextMenuOptions, type SidePanelOptions, type SidePanelsApi, type SidebarActionButton, type SidebarContextValue as SidebarContext, type SidebarCustomEntry, type SidebarHandle, type SidebarHeaderAction, type SidebarRailEntry, type SidebarTab, type SidebarTabContextValue as SidebarTabContext, type SplitDirection, type SplitOrientation, type Stretch, type TabContentProps, type TaskbarVisibility, type ToastAdapter, type ToastFunction, type ToastOptions, type ToastPosition, type ToastPromiseMessages, type ToastType, type ToolbarActionItem, type ToolbarContextValue, type ToolbarGroupEntry, type ToolbarGroupItem, type ToolbarGroupSubItem, type ToolbarHandle, type ToolbarItem$1 as ToolbarItem, type ToolbarPosition, type ToolbarRadioItem, type ToolbarSeparator$1 as ToolbarSeparator, type ToolbarToggleItem, type ToolbarVariant, type TypedWorkspace, type Workspace, type WorkspaceActions, type WorkspaceConfig, type WorkspaceState, computeResizedRect, createWorkspace, defaultPredefinedMessages as defaultMessages, definePanels, formatLabel, isComputedRtl, isElementRtl, isSerializable, sidebarSectionToTab as sectionToTab, startPointerDrag, toast, useActivePanelContribution as useActiveContribution, useBeforeClose, useColorScheme, useShowContextMenu as useContextMenu, usePanelFloatingWindowManager as useFloatingWidgets, useFormatMessage, useStyleClasses as useHostClasses, useMergedSidebarTabs, useMergedToolbarItems, usePredefinedMessages as useMessages, useModals, usePanel, usePanelContextMenu, usePanelContribution, usePanelEvents, usePanelSize, useSaveState, useSidePanels, useSidebar, useSidebarTab, useToolbar, useWorkspace, useWindowManagerState as useWorkspaceState };
package/dist/index.d.ts CHANGED
@@ -135,6 +135,52 @@ interface DropTarget {
135
135
  leafId: string;
136
136
  position: DropPosition;
137
137
  }
138
+ /**
139
+ * Where a user is about to move a panel, as `canDrop` sees it (7.9.0). Positions are the ones the
140
+ * move applies: under RTL, a drop on the zone drawn on the screen's right is `'left'`.
141
+ * - `group`: into a group, on one side (a new split) or `'center'` (as a tab, also between tabs);
142
+ * - `edge`: along a workspace edge, as a full-width or full-height strip;
143
+ * - `float`: into a floating window, pinned to a corner, or free (`anchor: null`, a tab dropped
144
+ * on nothing).
145
+ */
146
+ type PanelDropTarget = {
147
+ kind: 'group';
148
+ leafId: string;
149
+ position: DropPosition;
150
+ } | {
151
+ kind: 'edge';
152
+ side: SplitDirection;
153
+ } | {
154
+ kind: 'float';
155
+ anchor: FloatAnchor | null;
156
+ };
157
+ /**
158
+ * What `renderTabContent` receives for each tab (7.10.0). `title` is already formatted and `icon`
159
+ * is the icon the built-in content shows, so the built-in content is one line to re-create:
160
+ * `<>{icon} {title}{dirty && ' *'}</>`.
161
+ */
162
+ interface TabContentProps {
163
+ /** The panel's instance id. */
164
+ panelId: string;
165
+ /** The panel's registered kind: branch on it for a per-type look. */
166
+ component: string;
167
+ /** The title, formatted: messages resolved, functions called. */
168
+ title: string;
169
+ /** The icon the built-in content shows: set at runtime, else the registration's, else the default. */
170
+ icon: React$1.ReactNode;
171
+ /** Has unsaved changes; the built-in content shows ` *`. */
172
+ dirty: boolean;
173
+ /** The tab shown in its group. */
174
+ selected: boolean;
175
+ /** The workspace's active panel. */
176
+ focused: boolean;
177
+ }
178
+ /** The argument `canDrop` receives: which panel, of which registered kind, is going where. (7.9.0) */
179
+ interface PanelDrop {
180
+ panelId: string;
181
+ component: string;
182
+ to: PanelDropTarget;
183
+ }
138
184
  /**
139
185
  * Grid layout branch node containing nested splits and relative flex sizes.
140
186
  */
@@ -634,6 +680,8 @@ interface InternalWindowActions extends WorkspaceActions {
634
680
  getPanelContextMenuItems: (panelId: string) => ContextMenuItem[];
635
681
  /** @internal */
636
682
  registerContextMenuFn: (fn: (options: ShowContextMenuOptions) => void) => () => void;
683
+ /** @internal Whether the user may move `panelId` to `to`: its type's rules, then `canDrop`. (7.9.0) */
684
+ isDropAllowed: (panelId: string, to: PanelDropTarget) => boolean;
637
685
  }
638
686
  /** Represents custom CSS classes injected into layout parts. */
639
687
  interface HostClasses {
@@ -708,6 +756,19 @@ interface PanelRegistryEntry {
708
756
  };
709
757
  /** Enables/disables window drag interactions. */
710
758
  canDrag?: boolean;
759
+ /**
760
+ * `false`: the user can't make this panel floating. A tab drag can't end in a floating window
761
+ * (dropped on nothing or on a corner, it stays where it was), and the "Float" and taskbar
762
+ * "Maximize" menu items are hidden. A window the app floated itself can still be moved. The
763
+ * app's own `floatPanel` always works. @default true (7.9.0)
764
+ */
765
+ canFloat?: boolean;
766
+ /**
767
+ * `false`: the user can't dock this panel. Dragging it offers no group, tab or edge targets
768
+ * (corners still anchor a floating window), so it stays floating. The app's own docking calls
769
+ * always work; give the type `initialTarget: 'floating'` so it opens floating. @default true (7.9.0)
770
+ */
771
+ canDock?: boolean;
711
772
  /** Enables/disables minimizing of the panel instance. */
712
773
  canMinimize?: boolean;
713
774
  /** Enables/disables closing actions for the tab/window. */
@@ -729,7 +790,8 @@ interface PanelRegistryEntry {
729
790
  * `false` unmounts the panel's component while it is hidden (an unselected tab, or minimized)
730
791
  * and mounts it afresh when it is shown, to free what a heavy, rarely shown panel holds. Its
731
792
  * own state is lost each time; its tab, title and lifecycle continue (`onClose` is not called),
732
- * and the taskbar shows a placeholder instead of a live preview. While it is unmounted,
793
+ * and the taskbar shows a placeholder instead of a live preview. While it is unmounted, a
794
+ * guard it registered with `useBeforeClose` is not active (its dirty flag still is), and
733
795
  * `saveLayout()` saves its open-time props. @default true: panels stay mounted and keep their
734
796
  * state, as they always have. (7.8.0)
735
797
  */
@@ -1090,6 +1152,24 @@ interface WorkspaceClientConfig {
1090
1152
  * app's own modal z-index range to control stacking against it. Default: 1000.
1091
1153
  */
1092
1154
  zIndexBase?: number;
1155
+ /**
1156
+ * Veto where users can move panels (7.9.0). Called for each place a dragged panel could go, and
1157
+ * for the built-in "Float" and "Maximize" menu items: return `false` and that target isn't
1158
+ * offered (its drop zone doesn't appear) and the move doesn't happen. It runs after the panel
1159
+ * type's own `canFloat` / `canDock`, and only for what the user does: the app's own calls
1160
+ * (`floatPanel`, `dockPanelToGroup`, `openPanel`) always work. Keep it fast and pure; it runs
1161
+ * while the pointer moves.
1162
+ *
1163
+ * @example
1164
+ * ```ts
1165
+ * createWorkspace({
1166
+ * panels,
1167
+ * // Nothing but tool panels in the left group.
1168
+ * canDrop: ({ component, to }) => !(to.kind === 'group' && to.leafId === 'tools' && component !== 'tool'),
1169
+ * });
1170
+ * ```
1171
+ */
1172
+ canDrop?: (drop: PanelDrop) => boolean;
1093
1173
  }
1094
1174
  /**
1095
1175
  * A workspace: the layout, every action on it, the panel registry and the event bus. Create one
@@ -1422,7 +1502,7 @@ declare const AlertForm: React$1.FC<RddAlertProps>;
1422
1502
  * with the internal components under their 7.0 names.
1423
1503
  */
1424
1504
 
1425
- /** Configuration for {@link createWorkspace}. */
1505
+ /** Configuration for `createWorkspace()`. */
1426
1506
  interface WorkspaceConfig extends Omit<WorkspaceClientConfig, 'predefinedMessages'> {
1427
1507
  /** Overrides any subset of the built-in message table. */
1428
1508
  messages?: Record<string, MessageDescriptor>;
@@ -1434,6 +1514,45 @@ interface WorkspaceConfig extends Omit<WorkspaceClientConfig, 'predefinedMessage
1434
1514
  */
1435
1515
  interface Workspace<TEvents extends object = Record<string, unknown>> extends WorkspaceClient<TEvents> {
1436
1516
  }
1517
+ /** The type-only mark {@link definePanels} puts on a map. No such value exists at runtime. */
1518
+ declare const panelsBrand: unique symbol;
1519
+ /** A panel map marked by {@link definePanels}, so `createWorkspace` types `openPanel` from it (7.10.0). */
1520
+ type PanelMap<TPanels extends Record<string, PanelDefinition> = Record<string, PanelDefinition>> = TPanels & {
1521
+ readonly [panelsBrand]: true;
1522
+ };
1523
+ /** The props `openPanel` passes to a registered panel: its component's props, without `panelId`. */
1524
+ type PanelPropsOf<TDefinition> = TDefinition extends {
1525
+ component: React$1.ComponentType<infer P>;
1526
+ } ? Omit<P, 'panelId'> : never;
1527
+ /**
1528
+ * Marks a panel map for typing (7.10.0). Returns it unchanged; a workspace created from it gets a
1529
+ * typed `openPanel`: only registered names, and `props` checked against that panel's component.
1530
+ *
1531
+ * @example
1532
+ * ```ts
1533
+ * const panels = definePanels({ map: { component: MapPanel }, chart: { component: ChartPanel } });
1534
+ * const workspace = createWorkspace({ panels });
1535
+ * workspace.openPanel('c1', 'chart', { props: { series: 3 } }); // checked against ChartPanel's props
1536
+ * ```
1537
+ */
1538
+ declare function definePanels<const TPanels extends Record<string, PanelDefinition>>(panels: TPanels): PanelMap<TPanels>;
1539
+ /**
1540
+ * A workspace created from {@link definePanels}: the same object, with `openPanel` typed from the
1541
+ * registry. Pass it anywhere a {@link Workspace} goes. `useWorkspace()` stays untyped; keep this
1542
+ * one for typed calls.
1543
+ */
1544
+ interface TypedWorkspace<TPanels extends Record<string, PanelDefinition>, TEvents extends object = Record<string, unknown>> extends Workspace<TEvents> {
1545
+ /** `openPanel`, typed: a registered name, and that panel's props. */
1546
+ openPanel<K extends keyof TPanels & string>(id: string, component: K, options?: OpenPanelOptions<PanelPropsOf<TPanels[K]>>): void;
1547
+ }
1548
+ /**
1549
+ * Creates a workspace from a map marked by {@link definePanels} (7.10.0): `openPanel` takes only
1550
+ * the registered names, with `props` checked against each panel's component. To name the events
1551
+ * as well, pass both type arguments: `createWorkspace<typeof panels, AppEvents>({ panels })`.
1552
+ */
1553
+ declare function createWorkspace<TPanels extends Record<string, PanelDefinition>, TEvents extends object = Record<string, unknown>>(config: WorkspaceConfig & {
1554
+ panels: PanelMap<TPanels>;
1555
+ }): TypedWorkspace<TPanels, TEvents>;
1437
1556
  /**
1438
1557
  * Creates a workspace. Pass it to `<DockableDesktopProvider workspace={…}>`.
1439
1558
  *
@@ -1716,6 +1835,13 @@ interface RddDesktopProps {
1716
1835
  * floating window can still be docked into it. Floating windows still show over it. (7.8.0)
1717
1836
  */
1718
1837
  emptyWorkspace?: React$1.ReactNode;
1838
+ /**
1839
+ * Your own content for each tab in the grid: an icon, the title, a badge, a status dot (7.10.0).
1840
+ * It replaces the built-in icon, title and dirty marker; the tab itself (dragging, keyboard,
1841
+ * accessibility, its context menu, header actions and close button) stays the library's.
1842
+ * Called with the tab's `TabContentProps`; branch on `component` for a per-type look.
1843
+ */
1844
+ renderTabContent?: (tab: TabContentProps) => React$1.ReactNode;
1719
1845
  }
1720
1846
  /**
1721
1847
  * The desktop itself: the docked grid of tab groups, the floating windows, the taskbar of
@@ -2718,6 +2844,11 @@ interface PointerDragConfig<TStart> {
2718
2844
  onMove: (dx: number, dy: number, start: TStart) => void;
2719
2845
  /** Called once when the drag ends (pointerup or pointercancel). */
2720
2846
  onEnd?: (start: TStart) => void;
2847
+ /**
2848
+ * Called instead of `onEnd` when the drag is cut short: the window loses focus, or the pointer
2849
+ * capture is lost (the element was removed mid-drag). Without it, `onEnd` is called. (7.9.0)
2850
+ */
2851
+ onCancel?: (start: TStart) => void;
2721
2852
  /** Classes toggled on the given elements for the duration of the drag. */
2722
2853
  activeClasses?: Array<{
2723
2854
  el: HTMLElement;
@@ -2727,7 +2858,8 @@ interface PointerDragConfig<TStart> {
2727
2858
  /**
2728
2859
  * Starts a pointer-capture-based drag: captures the pointer on `element`, tracks
2729
2860
  * movement via listeners scoped to that element's own lifetime (not `window`), and
2730
- * cleans up automatically on release or cancel.
2861
+ * cleans up automatically on release or cancel, and (7.9.0) when the window loses focus
2862
+ * or the capture is lost, so a drag can never outlive its element or leave its classes behind.
2731
2863
  */
2732
2864
  declare function startPointerDrag<TStart>(config: PointerDragConfig<TStart>): void;
2733
2865
  type ResizeDir = 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw';
@@ -2788,4 +2920,4 @@ declare function isElementRtl(el: HTMLElement | null): boolean;
2788
2920
  */
2789
2921
  declare function isComputedRtl(el: Element | null | undefined): boolean;
2790
2922
 
2791
- export { type AlertOptions, type BuiltInEvents, type ButtonVariant, type CloseOptions, type ConfirmOptions, type ContainerType, type ContextMenuAdapter, type ContextMenuCheckbox, type ContextMenuHandle, type ContextMenuItem, type ContextMenuLabel, type ContextMenuSeparator, type ContextMenuSimpleItem, type ContextMenuSubMenu, type DirtyStateOptions, DockableDesktopProvider, type DockableDesktopProviderProps, type DropPosition, type DropTarget, type FloatAnchor, type FloatingWidgetsApi, type FloatingWindow, type HostClasses, type LayoutGridNode, type LayoutLeafNode, type LayoutNode, type ManagedWidget, type MenuItemAction, type MessageDescriptor, type MessageFormatter, type MessageKey, type ModalOptions, type ModalsApi, type OpenPanelOptions, type OverlayId, type OverlayInstance, type OverlayState, type PanelContribution, type PanelDefinition, type PanelEvents, type PanelFloatPlacement, type PanelHandle, type PanelInfo, PanelRegistry, type PanelRegistryEntry, type PanelSidebarSection, type PanelState, type PanelTitle, type PanelTitleDescriptor, type PointerDragConfig, AlertForm as RddAlert, type RddAlertProps, ConfirmationForm as RddConfirm, type RddConfirmProps, RddContextMenu, type RddContextMenuProps, WindowManager as RddDesktop, type RddDesktopProps, PanelFloatingWindow as RddFloatingWidget, type RddFloatingWidgetProps, ModalStackRenderer as RddModals, PanelOverlayRoot as RddPanelOverlay, type RddPanelOverlayProps, PanelToolbar as RddPanelToolbar, type RddPanelToolbarProps, SecondarySidebar as RddSecondarySidebar, type RddSecondarySidebarProps, RddSidePanels, type RddSidePanelsProps, Sidebar as RddSidebar, type RddSidebarProps, ToastContainer as RddToasts, type RddToastsProps, Toolbar as RddToolbar, ToolbarButton as RddToolbarButton, type RddToolbarButtonProps, ToolbarCenter as RddToolbarCenter, ToolbarItem as RddToolbarItem, type RddToolbarProps, ToolbarSearchInput as RddToolbarSearch, type RddToolbarSearchProps, ToolbarSeparator as RddToolbarSeparator, ToolbarSpacer as RddToolbarSpacer, ToolbarToggle as RddToolbarToggle, type RddToolbarToggleProps, type ResizeConstraints, type ResizeDir, type ResizeRect, type ResolvedToastOptions, type SearchResult, type SerializedLayout, type ShowContextMenuOptions, type SidePanelOptions, type SidePanelsApi, type SidebarActionButton, type SidebarContextValue as SidebarContext, type SidebarCustomEntry, type SidebarHandle, type SidebarHeaderAction, type SidebarRailEntry, type SidebarTab, type SidebarTabContextValue as SidebarTabContext, type SplitDirection, type SplitOrientation, type Stretch, type TaskbarVisibility, type ToastAdapter, type ToastFunction, type ToastOptions, type ToastPosition, type ToastPromiseMessages, type ToastType, type ToolbarActionItem, type ToolbarContextValue, type ToolbarGroupEntry, type ToolbarGroupItem, type ToolbarGroupSubItem, type ToolbarHandle, type ToolbarItem$1 as ToolbarItem, type ToolbarPosition, type ToolbarRadioItem, type ToolbarSeparator$1 as ToolbarSeparator, type ToolbarToggleItem, type ToolbarVariant, type Workspace, type WorkspaceActions, type WorkspaceConfig, type WorkspaceState, computeResizedRect, createWorkspace, defaultPredefinedMessages as defaultMessages, formatLabel, isComputedRtl, isElementRtl, isSerializable, sidebarSectionToTab as sectionToTab, startPointerDrag, toast, useActivePanelContribution as useActiveContribution, useBeforeClose, useColorScheme, useShowContextMenu as useContextMenu, usePanelFloatingWindowManager as useFloatingWidgets, useFormatMessage, useStyleClasses as useHostClasses, useMergedSidebarTabs, useMergedToolbarItems, usePredefinedMessages as useMessages, useModals, usePanel, usePanelContextMenu, usePanelContribution, usePanelEvents, usePanelSize, useSaveState, useSidePanels, useSidebar, useSidebarTab, useToolbar, useWorkspace, useWindowManagerState as useWorkspaceState };
2923
+ export { type AlertOptions, type BuiltInEvents, type ButtonVariant, type CloseOptions, type ConfirmOptions, type ContainerType, type ContextMenuAdapter, type ContextMenuCheckbox, type ContextMenuHandle, type ContextMenuItem, type ContextMenuLabel, type ContextMenuSeparator, type ContextMenuSimpleItem, type ContextMenuSubMenu, type DirtyStateOptions, DockableDesktopProvider, type DockableDesktopProviderProps, type DropPosition, type DropTarget, type FloatAnchor, type FloatingWidgetsApi, type FloatingWindow, type HostClasses, type LayoutGridNode, type LayoutLeafNode, type LayoutNode, type ManagedWidget, type MenuItemAction, type MessageDescriptor, type MessageFormatter, type MessageKey, type ModalOptions, type ModalsApi, type OpenPanelOptions, type OverlayId, type OverlayInstance, type OverlayState, type PanelContribution, type PanelDefinition, type PanelDrop, type PanelDropTarget, type PanelEvents, type PanelFloatPlacement, type PanelHandle, type PanelInfo, type PanelMap, type PanelPropsOf, PanelRegistry, type PanelRegistryEntry, type PanelSidebarSection, type PanelState, type PanelTitle, type PanelTitleDescriptor, type PointerDragConfig, AlertForm as RddAlert, type RddAlertProps, ConfirmationForm as RddConfirm, type RddConfirmProps, RddContextMenu, type RddContextMenuProps, WindowManager as RddDesktop, type RddDesktopProps, PanelFloatingWindow as RddFloatingWidget, type RddFloatingWidgetProps, ModalStackRenderer as RddModals, PanelOverlayRoot as RddPanelOverlay, type RddPanelOverlayProps, PanelToolbar as RddPanelToolbar, type RddPanelToolbarProps, SecondarySidebar as RddSecondarySidebar, type RddSecondarySidebarProps, RddSidePanels, type RddSidePanelsProps, Sidebar as RddSidebar, type RddSidebarProps, ToastContainer as RddToasts, type RddToastsProps, Toolbar as RddToolbar, ToolbarButton as RddToolbarButton, type RddToolbarButtonProps, ToolbarCenter as RddToolbarCenter, ToolbarItem as RddToolbarItem, type RddToolbarProps, ToolbarSearchInput as RddToolbarSearch, type RddToolbarSearchProps, ToolbarSeparator as RddToolbarSeparator, ToolbarSpacer as RddToolbarSpacer, ToolbarToggle as RddToolbarToggle, type RddToolbarToggleProps, type ResizeConstraints, type ResizeDir, type ResizeRect, type ResolvedToastOptions, type SearchResult, type SerializedLayout, type ShowContextMenuOptions, type SidePanelOptions, type SidePanelsApi, type SidebarActionButton, type SidebarContextValue as SidebarContext, type SidebarCustomEntry, type SidebarHandle, type SidebarHeaderAction, type SidebarRailEntry, type SidebarTab, type SidebarTabContextValue as SidebarTabContext, type SplitDirection, type SplitOrientation, type Stretch, type TabContentProps, type TaskbarVisibility, type ToastAdapter, type ToastFunction, type ToastOptions, type ToastPosition, type ToastPromiseMessages, type ToastType, type ToolbarActionItem, type ToolbarContextValue, type ToolbarGroupEntry, type ToolbarGroupItem, type ToolbarGroupSubItem, type ToolbarHandle, type ToolbarItem$1 as ToolbarItem, type ToolbarPosition, type ToolbarRadioItem, type ToolbarSeparator$1 as ToolbarSeparator, type ToolbarToggleItem, type ToolbarVariant, type TypedWorkspace, type Workspace, type WorkspaceActions, type WorkspaceConfig, type WorkspaceState, computeResizedRect, createWorkspace, defaultPredefinedMessages as defaultMessages, definePanels, formatLabel, isComputedRtl, isElementRtl, isSerializable, sidebarSectionToTab as sectionToTab, startPointerDrag, toast, useActivePanelContribution as useActiveContribution, useBeforeClose, useColorScheme, useShowContextMenu as useContextMenu, usePanelFloatingWindowManager as useFloatingWidgets, useFormatMessage, useStyleClasses as useHostClasses, useMergedSidebarTabs, useMergedToolbarItems, usePredefinedMessages as useMessages, useModals, usePanel, usePanelContextMenu, usePanelContribution, usePanelEvents, usePanelSize, useSaveState, useSidePanels, useSidebar, useSidebarTab, useToolbar, useWorkspace, useWindowManagerState as useWorkspaceState };