react-dockable-desktop 3.0.0 → 3.2.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
@@ -1,4 +1,6 @@
1
1
  import React$1, { ComponentType, Context, Provider, ReactNode } from 'react';
2
+ import { ContextMenuItem } from 'replace-react-contexify';
3
+ export { ContextMenuItem, ContextMenuSeparator, ContextMenuSimpleItem, ContextMenuSubMenu } from 'replace-react-contexify';
2
4
 
3
5
  /**
4
6
  * @file WindowManager.tsx
@@ -10,6 +12,7 @@ import React$1, { ComponentType, Context, Provider, ReactNode } from 'react';
10
12
  interface WindowManagerProps {
11
13
  skin?: string;
12
14
  defaultPanelIcon?: React$1.ReactNode;
15
+ taskbarVisibility?: 'always' | 'compact' | 'autohide';
13
16
  }
14
17
  declare const WindowManager: React$1.FC<WindowManagerProps>;
15
18
 
@@ -681,6 +684,27 @@ declare const usePredefinedMessages: () => Record<PredefinedMessageKey, ContextM
681
684
  * ```
682
685
  */
683
686
  declare const usePanelId: () => string;
687
+ /**
688
+ * React hook for injecting custom context menu items into a panel's context menu from inside the panel component.
689
+ * Items are dynamic — the array is re-read each time the menu opens, so state-driven changes (enable/disable, add/remove) work automatically.
690
+ * The hook reads the panel ID internally via {@link usePanelId} — no prop needed.
691
+ *
692
+ * @param items - Array of `ContextMenuItem` entries (simple items, separators, submenus).
693
+ * @example
694
+ * ```tsx
695
+ * import { usePanelContextMenu } from 'dockable-windows';
696
+ *
697
+ * function MyPanel() {
698
+ * const [dirty, setDirty] = useState(false);
699
+ * usePanelContextMenu([
700
+ * { label: 'Save', action: () => save() },
701
+ * { label: 'Revert', action: () => revert() },
702
+ * ]);
703
+ * return <Editor onChange={() => setDirty(true)} />;
704
+ * }
705
+ * ```
706
+ */
707
+ declare function usePanelContextMenu(items: ContextMenuItem[]): void;
684
708
 
685
709
  /** Built-in lifecycle events always available on the WorkspaceClient event bus. */
686
710
  interface BuiltInPanelEvents {
@@ -1051,8 +1075,10 @@ declare const ConfirmationForm: React$1.FC<ConfirmationFormProps>;
1051
1075
 
1052
1076
  /**
1053
1077
  * @file Sidebar.tsx
1054
- * @description Sidebar navigation strip and drawer container component.
1055
- * Supports eager/lazy mounting, state preservation (display: none), and positioning (left/right).
1078
+ * @description Sidebar activity bar (strip) and resizable content drawer.
1079
+ * The strip and drawer are independently controllable via `visible` and
1080
+ * `stripVisible`. Drawer width is pixel-based and user-draggable using the
1081
+ * same pointer-capture interaction as the panel grid resizer.
1056
1082
  */
1057
1083
 
1058
1084
  /**
@@ -1065,16 +1091,12 @@ interface SidebarTab {
1065
1091
  /**
1066
1092
  * Mount immediately when the Sidebar first renders, not on first user click.
1067
1093
  * Implies `preserveState: true`.
1068
- * Use when other parts of the app need to interact with the panel before
1069
- * the user has opened it (e.g. push data into a context, warm up a WebGL map).
1070
1094
  * Default: false
1071
1095
  */
1072
1096
  eagerMount?: boolean;
1073
1097
  /**
1074
- * Once mounted for the first time, keep the component alive in the DOM
1075
- * behind `display: none` when closed instead of unmounting it.
1076
- * Use for panels with expensive local state (long forms, WebGL scenes, etc.).
1077
- * Ignored when `eagerMount` is true (eagerly mounted panels are always preserved).
1098
+ * Keep the component alive behind `display: none` when closed instead of
1099
+ * unmounting it. Use for panels with expensive local state.
1078
1100
  * Default: false
1079
1101
  */
1080
1102
  preserveState?: boolean;
@@ -1082,41 +1104,234 @@ interface SidebarTab {
1082
1104
  * Called to obtain the drawer content for this tab.
1083
1105
  * @param tabId - the id of this tab
1084
1106
  * @param onClose - call to collapse the sidebar drawer
1085
- * @param onOpen - call to expand the drawer and select this tab programmatically
1086
- * (useful when the panel itself detects it has new data to show)
1107
+ * @param onOpen - call to expand the drawer and select this tab
1087
1108
  */
1088
1109
  renderContent: (tabId: string, onClose: () => void, onOpen: () => void) => React$1.ReactNode;
1089
1110
  }
1090
1111
  interface SidebarProps {
1091
- /** Which side the tab strip and drawer appear on. Default: 'right' */
1112
+ /** Which side the activity bar and drawer appear on. Default: 'right' */
1092
1113
  position?: 'left' | 'right';
1093
1114
  tabs: SidebarTab[];
1094
- /** Width of the open drawer. Default: '220px' */
1095
- drawerWidth?: string;
1096
- /** Controlled active tab id. Leave undefined to use internal state. */
1115
+ /** Initial drawer width in pixels. Default: 220 */
1116
+ defaultWidth?: number;
1117
+ /** Minimum drawer width in pixels during drag-resize. Default: 150 */
1118
+ minWidth?: number;
1119
+ /** Maximum drawer width in pixels during drag-resize. Default: 600 */
1120
+ maxWidth?: number;
1121
+ /** Called during drag resize and on setWidth() with the new pixel width. */
1122
+ onWidthChange?: (px: number) => void;
1123
+ /** Controlled active tab id. Omit to use internal state. */
1097
1124
  activeTabId?: string | null;
1098
- /** Called when the active tab changes in uncontrolled mode. */
1125
+ /** Called when the active tab changes. */
1099
1126
  onActiveTabChange?: (tabId: string | null) => void;
1100
- /** Main workspace content, rendered between the strip and drawer (or around them). */
1127
+ /** Collapse the entire sidebar (strip + drawer). Default: true */
1128
+ visible?: boolean;
1129
+ /** Called when show/hide/toggle is invoked on the imperative handle. */
1130
+ onVisibilityChange?: (visible: boolean) => void;
1131
+ /** Collapse only the activity bar strip, leaving the drawer unaffected. Default: true */
1132
+ stripVisible?: boolean;
1133
+ /** Called when showStrip/hideStrip is invoked on the imperative handle. */
1134
+ onStripVisibilityChange?: (visible: boolean) => void;
1135
+ /** Main workspace content rendered alongside the sidebar. */
1101
1136
  children?: React$1.ReactNode;
1137
+ /** @deprecated Use defaultWidth (number, pixels) instead. */
1138
+ drawerWidth?: string;
1102
1139
  }
1103
1140
  /**
1104
- * Imperative handle exposed by `<Sidebar ref={...}>` via forwardRef.
1105
- * Allows external components (outside the sidebar tree) to control
1106
- * which tab is open without prop drilling.
1141
+ * Imperative handle exposed by `<Sidebar ref={...}>`.
1107
1142
  */
1108
1143
  interface SidebarHandle {
1109
- /** Expand the drawer and activate the tab with the given id. */
1110
1144
  openTab: (tabId: string) => void;
1111
- /** Collapse the drawer (equivalent to clicking the active tab icon). */
1112
1145
  closeDrawer: () => void;
1113
- /** Returns the currently active tab id, or null if the drawer is collapsed. */
1114
1146
  getActiveTab: () => string | null;
1147
+ show: () => void;
1148
+ hide: () => void;
1149
+ toggle: () => void;
1150
+ showStrip: () => void;
1151
+ hideStrip: () => void;
1152
+ setWidth: (px: number) => void;
1153
+ getWidth: () => number;
1115
1154
  }
1116
1155
  /**
1117
- * Sidebar component rendering a tab strip and a collapsible content drawer.
1118
- * Supports imperative method bindings like openTab and closeDrawer via forwardRef.
1156
+ * Value provided by `useSidebar()`. Available to any component inside the
1157
+ * `<Sidebar>` React tree, including panels rendered via `{children}`.
1119
1158
  */
1159
+ interface SidebarContextValue {
1160
+ openTab: (tabId: string) => void;
1161
+ closeDrawer: () => void;
1162
+ getActiveTab: () => string | null;
1163
+ }
1164
+ /**
1165
+ * Value provided by `useSidebarTab()`. Available only to components rendered
1166
+ * inside a sidebar tab's `renderContent` tree.
1167
+ */
1168
+ interface SidebarTabContextValue {
1169
+ tabId: string;
1170
+ onOpen: () => void;
1171
+ onClose: () => void;
1172
+ openTab: (tabId: string) => void;
1173
+ }
1120
1174
  declare const Sidebar: React$1.ForwardRefExoticComponent<SidebarProps & React$1.RefAttributes<SidebarHandle>>;
1175
+ /**
1176
+ * Returns sidebar control functions from anywhere inside a `<Sidebar>` tree,
1177
+ * including floating panels rendered via `{children}`.
1178
+ *
1179
+ * Returns a no-op object with a console warning when called outside a Sidebar.
1180
+ */
1181
+ declare function useSidebar(): SidebarContextValue;
1182
+ /**
1183
+ * Returns tab-specific control functions for components rendered inside a
1184
+ * sidebar tab's `renderContent` tree.
1185
+ *
1186
+ * Returns a no-op object with a console warning when called outside tab content.
1187
+ */
1188
+ declare function useSidebarTab(): SidebarTabContextValue;
1189
+
1190
+ /**
1191
+ * @file ToolbarContext.tsx
1192
+ * @description Toolbar state context — radio group selection and toggle modifier state.
1193
+ * Provided by DockableDesktopProvider; consumed via useToolbar() from anywhere in the tree.
1194
+ */
1195
+
1196
+ interface ToolbarContextValue {
1197
+ /** Returns the active item id in a radio group, or null if none. */
1198
+ getActiveInGroup: (group: string) => string | null;
1199
+ /** Set the active item in a radio group (pass null to deselect all). */
1200
+ setActiveInGroup: (group: string, id: string | null) => void;
1201
+ /** Returns whether a toggle modifier is currently active. */
1202
+ isModifierActive: (id: string) => boolean;
1203
+ /** Explicitly set a toggle modifier's active state. */
1204
+ setModifierActive: (id: string, active: boolean) => void;
1205
+ /** Flip a toggle modifier between active and inactive. */
1206
+ toggleModifier: (id: string) => void;
1207
+ }
1208
+ declare const ToolbarProvider: React$1.FC<{
1209
+ children: React$1.ReactNode;
1210
+ }>;
1211
+ /**
1212
+ * Returns toolbar state and control functions from anywhere inside
1213
+ * a `<DockableDesktopProvider>` tree.
1214
+ *
1215
+ * Returns a no-op object with a console warning when called outside the provider.
1216
+ */
1217
+ declare function useToolbar(): ToolbarContextValue;
1218
+
1219
+ /**
1220
+ * @file Toolbar.tsx
1221
+ * @description Vertical or horizontal toolbar strip hosting action buttons,
1222
+ * mutually-exclusive radio tool groups, independent toggle modifiers,
1223
+ * and collapsible sub-tool group flyouts.
1224
+ * State is library-wide via DockableDesktopProvider / ToolbarContext.
1225
+ */
1226
+
1227
+ /** A one-shot action button. */
1228
+ interface ToolbarActionItem {
1229
+ type: 'action';
1230
+ id: string;
1231
+ label: string;
1232
+ icon: React$1.ReactNode;
1233
+ onClick: () => void;
1234
+ disabled?: boolean;
1235
+ }
1236
+ /** A mutually-exclusive radio button within a named group. */
1237
+ interface ToolbarRadioItem {
1238
+ type: 'radio';
1239
+ id: string;
1240
+ group: string;
1241
+ label: string;
1242
+ icon: React$1.ReactNode;
1243
+ /** Keyboard shortcut hint — displayed in the group flyout; reserved for future custom tooltip. */
1244
+ shortcut?: string;
1245
+ /** Called when this item becomes active. */
1246
+ onActivate?: (id: string) => void;
1247
+ disabled?: boolean;
1248
+ }
1249
+ /** An independent on/off toggle modifier (e.g. snap-to-grid). */
1250
+ interface ToolbarToggleItem {
1251
+ type: 'toggle';
1252
+ id: string;
1253
+ label: string;
1254
+ icon: React$1.ReactNode;
1255
+ /** Keyboard shortcut hint — reserved for future custom tooltip. */
1256
+ shortcut?: string;
1257
+ /** Called after the toggle flips; receives the new active state. */
1258
+ onToggle?: (active: boolean) => void;
1259
+ disabled?: boolean;
1260
+ }
1261
+ /** A visual divider between button groups. */
1262
+ interface ToolbarSeparator {
1263
+ type: 'separator';
1264
+ }
1265
+ /**
1266
+ * A single selectable sub-tool inside a group flyout.
1267
+ * All sub-items in the same ToolbarGroupItem share one radio group
1268
+ * keyed by the parent ToolbarGroupItem's `id`.
1269
+ */
1270
+ interface ToolbarGroupSubItem {
1271
+ id: string;
1272
+ label: string;
1273
+ icon: React$1.ReactNode;
1274
+ /** Keyboard shortcut displayed in the flyout panel. */
1275
+ shortcut?: string;
1276
+ disabled?: boolean;
1277
+ /** Called when this sub-item is selected. */
1278
+ onActivate?: (id: string) => void;
1279
+ }
1280
+ /** An entry inside a group flyout — either a sub-item or a separator. */
1281
+ type ToolbarGroupEntry = ToolbarGroupSubItem | {
1282
+ type: 'separator';
1283
+ };
1284
+ /**
1285
+ * A collapsed tool-family button that opens a flyout panel listing all
1286
+ * sub-tools. Only one sub-tool may be active at a time (radio semantics).
1287
+ * The parent button's icon morphs to show the currently active sub-tool.
1288
+ *
1289
+ * Supports both uncontrolled mode (omit activeItemId — state lives in
1290
+ * ToolbarContext) and controlled mode (provide activeItemId — the caller
1291
+ * is the single source of truth and must update the prop in response to
1292
+ * onActiveItemChange).
1293
+ */
1294
+ interface ToolbarGroupItem {
1295
+ type: 'group';
1296
+ /** Serves as both the button ID and the radio group key in ToolbarContext. */
1297
+ id: string;
1298
+ /** Tooltip / aria-label shown when no sub-item is active. */
1299
+ label: string;
1300
+ /** Icon shown when no sub-item is active. */
1301
+ defaultIcon: React$1.ReactNode;
1302
+ items: ToolbarGroupEntry[];
1303
+ disabled?: boolean;
1304
+ /**
1305
+ * Controlled active sub-item id. When provided (even as null), the
1306
+ * component reads this prop instead of ToolbarContext and fires
1307
+ * onActiveItemChange on click instead of updating context.
1308
+ * Omit (undefined) for uncontrolled behaviour.
1309
+ */
1310
+ activeItemId?: string | null;
1311
+ /**
1312
+ * Called when the user selects a sub-item in controlled mode.
1313
+ * The toolbar does not update itself — the caller must update activeItemId.
1314
+ */
1315
+ onActiveItemChange?: (id: string) => void;
1316
+ }
1317
+ type ToolbarItem = ToolbarActionItem | ToolbarRadioItem | ToolbarToggleItem | ToolbarGroupItem | ToolbarSeparator;
1318
+ interface ToolbarProps {
1319
+ /** Side the strip is attached to. Controls strip orientation. Default: 'left' */
1320
+ position?: 'left' | 'right' | 'top' | 'bottom';
1321
+ /** Ordered list of items to render. */
1322
+ items: ToolbarItem[];
1323
+ /** Collapse the strip to zero width/height. State is preserved — no unmount. */
1324
+ visible?: boolean;
1325
+ /** Called when show/hide/toggle is invoked on the imperative handle. */
1326
+ onVisibilityChange?: (visible: boolean) => void;
1327
+ className?: string;
1328
+ style?: React$1.CSSProperties;
1329
+ }
1330
+ interface ToolbarHandle {
1331
+ show(): void;
1332
+ hide(): void;
1333
+ toggle(): void;
1334
+ }
1335
+ declare const Toolbar: React$1.ForwardRefExoticComponent<ToolbarProps & React$1.RefAttributes<ToolbarHandle>>;
1121
1336
 
1122
- export { type BuiltInPanelEvents, type CloseOptions, ConfirmationForm, type ConfirmationFormProps, type ContextMenuPredefinedMessage, DockableDesktopProvider, type DropPosition, type DropTarget, type FloatingWindow, FormContainerContext, type FormContainerContract, FormContainerProvider, type LayoutGridNode, type LayoutLeafNode, type LayoutNode, LeftPanelRenderer, type MessageFormatter, type ModalOptions, ModalStackRenderer, type PanelActions, type PanelDefinition, type PanelInfo, type PanelInstance, type PanelInstanceId, PanelProvider, PanelRegistry, PanelRegistryClass, type PanelRegistryEntry, type PanelState, type PanelTitle, type PredefinedMessageKey, RightPanelRenderer, type SidePanelOptions, SidePanelRenderer, type SidePanelRendererProps, Sidebar, type SidebarHandle, type SidebarProps, type SidebarTab, type SplitDirection, type SplitOrientation, type StyleClasses, type WindowActions, WindowManager, WindowManagerProvider, type WindowState, WorkspaceClient, type WorkspaceClientConfig, defaultPredefinedMessages, formatLabel, useFormContainer, useFormatMessage, usePanelActions, usePanelContext, usePanelId, usePanelState, usePredefinedMessages, useRegistry, useStyleClasses, useWindowManagerActions, useWindowManagerState };
1337
+ export { type BuiltInPanelEvents, type CloseOptions, ConfirmationForm, type ConfirmationFormProps, type ContextMenuPredefinedMessage, DockableDesktopProvider, type DropPosition, type DropTarget, type FloatingWindow, FormContainerContext, type FormContainerContract, FormContainerProvider, type LayoutGridNode, type LayoutLeafNode, type LayoutNode, LeftPanelRenderer, type MessageFormatter, type ModalOptions, ModalStackRenderer, type PanelActions, type PanelDefinition, type PanelInfo, type PanelInstance, type PanelInstanceId, PanelProvider, PanelRegistry, PanelRegistryClass, type PanelRegistryEntry, type PanelState, type PanelTitle, type PredefinedMessageKey, RightPanelRenderer, type SidePanelOptions, SidePanelRenderer, type SidePanelRendererProps, Sidebar, type SidebarContextValue, type SidebarHandle, type SidebarProps, type SidebarTab, type SidebarTabContextValue, type SplitDirection, type SplitOrientation, type StyleClasses, Toolbar, type ToolbarActionItem, type ToolbarContextValue, type ToolbarGroupEntry, type ToolbarGroupItem, type ToolbarGroupSubItem, type ToolbarHandle, type ToolbarItem, type ToolbarProps, ToolbarProvider, type ToolbarRadioItem, type ToolbarSeparator, type ToolbarToggleItem, type WindowActions, WindowManager, WindowManagerProvider, type WindowState, WorkspaceClient, type WorkspaceClientConfig, defaultPredefinedMessages, formatLabel, useFormContainer, useFormatMessage, usePanelActions, usePanelContext, usePanelContextMenu, usePanelId, usePanelState, usePredefinedMessages, useRegistry, useSidebar, useSidebarTab, useStyleClasses, useToolbar, useWindowManagerActions, useWindowManagerState };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import React$1, { ComponentType, Context, Provider, ReactNode } from 'react';
2
+ import { ContextMenuItem } from 'replace-react-contexify';
3
+ export { ContextMenuItem, ContextMenuSeparator, ContextMenuSimpleItem, ContextMenuSubMenu } from 'replace-react-contexify';
2
4
 
3
5
  /**
4
6
  * @file WindowManager.tsx
@@ -10,6 +12,7 @@ import React$1, { ComponentType, Context, Provider, ReactNode } from 'react';
10
12
  interface WindowManagerProps {
11
13
  skin?: string;
12
14
  defaultPanelIcon?: React$1.ReactNode;
15
+ taskbarVisibility?: 'always' | 'compact' | 'autohide';
13
16
  }
14
17
  declare const WindowManager: React$1.FC<WindowManagerProps>;
15
18
 
@@ -681,6 +684,27 @@ declare const usePredefinedMessages: () => Record<PredefinedMessageKey, ContextM
681
684
  * ```
682
685
  */
683
686
  declare const usePanelId: () => string;
687
+ /**
688
+ * React hook for injecting custom context menu items into a panel's context menu from inside the panel component.
689
+ * Items are dynamic — the array is re-read each time the menu opens, so state-driven changes (enable/disable, add/remove) work automatically.
690
+ * The hook reads the panel ID internally via {@link usePanelId} — no prop needed.
691
+ *
692
+ * @param items - Array of `ContextMenuItem` entries (simple items, separators, submenus).
693
+ * @example
694
+ * ```tsx
695
+ * import { usePanelContextMenu } from 'dockable-windows';
696
+ *
697
+ * function MyPanel() {
698
+ * const [dirty, setDirty] = useState(false);
699
+ * usePanelContextMenu([
700
+ * { label: 'Save', action: () => save() },
701
+ * { label: 'Revert', action: () => revert() },
702
+ * ]);
703
+ * return <Editor onChange={() => setDirty(true)} />;
704
+ * }
705
+ * ```
706
+ */
707
+ declare function usePanelContextMenu(items: ContextMenuItem[]): void;
684
708
 
685
709
  /** Built-in lifecycle events always available on the WorkspaceClient event bus. */
686
710
  interface BuiltInPanelEvents {
@@ -1051,8 +1075,10 @@ declare const ConfirmationForm: React$1.FC<ConfirmationFormProps>;
1051
1075
 
1052
1076
  /**
1053
1077
  * @file Sidebar.tsx
1054
- * @description Sidebar navigation strip and drawer container component.
1055
- * Supports eager/lazy mounting, state preservation (display: none), and positioning (left/right).
1078
+ * @description Sidebar activity bar (strip) and resizable content drawer.
1079
+ * The strip and drawer are independently controllable via `visible` and
1080
+ * `stripVisible`. Drawer width is pixel-based and user-draggable using the
1081
+ * same pointer-capture interaction as the panel grid resizer.
1056
1082
  */
1057
1083
 
1058
1084
  /**
@@ -1065,16 +1091,12 @@ interface SidebarTab {
1065
1091
  /**
1066
1092
  * Mount immediately when the Sidebar first renders, not on first user click.
1067
1093
  * Implies `preserveState: true`.
1068
- * Use when other parts of the app need to interact with the panel before
1069
- * the user has opened it (e.g. push data into a context, warm up a WebGL map).
1070
1094
  * Default: false
1071
1095
  */
1072
1096
  eagerMount?: boolean;
1073
1097
  /**
1074
- * Once mounted for the first time, keep the component alive in the DOM
1075
- * behind `display: none` when closed instead of unmounting it.
1076
- * Use for panels with expensive local state (long forms, WebGL scenes, etc.).
1077
- * Ignored when `eagerMount` is true (eagerly mounted panels are always preserved).
1098
+ * Keep the component alive behind `display: none` when closed instead of
1099
+ * unmounting it. Use for panels with expensive local state.
1078
1100
  * Default: false
1079
1101
  */
1080
1102
  preserveState?: boolean;
@@ -1082,41 +1104,234 @@ interface SidebarTab {
1082
1104
  * Called to obtain the drawer content for this tab.
1083
1105
  * @param tabId - the id of this tab
1084
1106
  * @param onClose - call to collapse the sidebar drawer
1085
- * @param onOpen - call to expand the drawer and select this tab programmatically
1086
- * (useful when the panel itself detects it has new data to show)
1107
+ * @param onOpen - call to expand the drawer and select this tab
1087
1108
  */
1088
1109
  renderContent: (tabId: string, onClose: () => void, onOpen: () => void) => React$1.ReactNode;
1089
1110
  }
1090
1111
  interface SidebarProps {
1091
- /** Which side the tab strip and drawer appear on. Default: 'right' */
1112
+ /** Which side the activity bar and drawer appear on. Default: 'right' */
1092
1113
  position?: 'left' | 'right';
1093
1114
  tabs: SidebarTab[];
1094
- /** Width of the open drawer. Default: '220px' */
1095
- drawerWidth?: string;
1096
- /** Controlled active tab id. Leave undefined to use internal state. */
1115
+ /** Initial drawer width in pixels. Default: 220 */
1116
+ defaultWidth?: number;
1117
+ /** Minimum drawer width in pixels during drag-resize. Default: 150 */
1118
+ minWidth?: number;
1119
+ /** Maximum drawer width in pixels during drag-resize. Default: 600 */
1120
+ maxWidth?: number;
1121
+ /** Called during drag resize and on setWidth() with the new pixel width. */
1122
+ onWidthChange?: (px: number) => void;
1123
+ /** Controlled active tab id. Omit to use internal state. */
1097
1124
  activeTabId?: string | null;
1098
- /** Called when the active tab changes in uncontrolled mode. */
1125
+ /** Called when the active tab changes. */
1099
1126
  onActiveTabChange?: (tabId: string | null) => void;
1100
- /** Main workspace content, rendered between the strip and drawer (or around them). */
1127
+ /** Collapse the entire sidebar (strip + drawer). Default: true */
1128
+ visible?: boolean;
1129
+ /** Called when show/hide/toggle is invoked on the imperative handle. */
1130
+ onVisibilityChange?: (visible: boolean) => void;
1131
+ /** Collapse only the activity bar strip, leaving the drawer unaffected. Default: true */
1132
+ stripVisible?: boolean;
1133
+ /** Called when showStrip/hideStrip is invoked on the imperative handle. */
1134
+ onStripVisibilityChange?: (visible: boolean) => void;
1135
+ /** Main workspace content rendered alongside the sidebar. */
1101
1136
  children?: React$1.ReactNode;
1137
+ /** @deprecated Use defaultWidth (number, pixels) instead. */
1138
+ drawerWidth?: string;
1102
1139
  }
1103
1140
  /**
1104
- * Imperative handle exposed by `<Sidebar ref={...}>` via forwardRef.
1105
- * Allows external components (outside the sidebar tree) to control
1106
- * which tab is open without prop drilling.
1141
+ * Imperative handle exposed by `<Sidebar ref={...}>`.
1107
1142
  */
1108
1143
  interface SidebarHandle {
1109
- /** Expand the drawer and activate the tab with the given id. */
1110
1144
  openTab: (tabId: string) => void;
1111
- /** Collapse the drawer (equivalent to clicking the active tab icon). */
1112
1145
  closeDrawer: () => void;
1113
- /** Returns the currently active tab id, or null if the drawer is collapsed. */
1114
1146
  getActiveTab: () => string | null;
1147
+ show: () => void;
1148
+ hide: () => void;
1149
+ toggle: () => void;
1150
+ showStrip: () => void;
1151
+ hideStrip: () => void;
1152
+ setWidth: (px: number) => void;
1153
+ getWidth: () => number;
1115
1154
  }
1116
1155
  /**
1117
- * Sidebar component rendering a tab strip and a collapsible content drawer.
1118
- * Supports imperative method bindings like openTab and closeDrawer via forwardRef.
1156
+ * Value provided by `useSidebar()`. Available to any component inside the
1157
+ * `<Sidebar>` React tree, including panels rendered via `{children}`.
1119
1158
  */
1159
+ interface SidebarContextValue {
1160
+ openTab: (tabId: string) => void;
1161
+ closeDrawer: () => void;
1162
+ getActiveTab: () => string | null;
1163
+ }
1164
+ /**
1165
+ * Value provided by `useSidebarTab()`. Available only to components rendered
1166
+ * inside a sidebar tab's `renderContent` tree.
1167
+ */
1168
+ interface SidebarTabContextValue {
1169
+ tabId: string;
1170
+ onOpen: () => void;
1171
+ onClose: () => void;
1172
+ openTab: (tabId: string) => void;
1173
+ }
1120
1174
  declare const Sidebar: React$1.ForwardRefExoticComponent<SidebarProps & React$1.RefAttributes<SidebarHandle>>;
1175
+ /**
1176
+ * Returns sidebar control functions from anywhere inside a `<Sidebar>` tree,
1177
+ * including floating panels rendered via `{children}`.
1178
+ *
1179
+ * Returns a no-op object with a console warning when called outside a Sidebar.
1180
+ */
1181
+ declare function useSidebar(): SidebarContextValue;
1182
+ /**
1183
+ * Returns tab-specific control functions for components rendered inside a
1184
+ * sidebar tab's `renderContent` tree.
1185
+ *
1186
+ * Returns a no-op object with a console warning when called outside tab content.
1187
+ */
1188
+ declare function useSidebarTab(): SidebarTabContextValue;
1189
+
1190
+ /**
1191
+ * @file ToolbarContext.tsx
1192
+ * @description Toolbar state context — radio group selection and toggle modifier state.
1193
+ * Provided by DockableDesktopProvider; consumed via useToolbar() from anywhere in the tree.
1194
+ */
1195
+
1196
+ interface ToolbarContextValue {
1197
+ /** Returns the active item id in a radio group, or null if none. */
1198
+ getActiveInGroup: (group: string) => string | null;
1199
+ /** Set the active item in a radio group (pass null to deselect all). */
1200
+ setActiveInGroup: (group: string, id: string | null) => void;
1201
+ /** Returns whether a toggle modifier is currently active. */
1202
+ isModifierActive: (id: string) => boolean;
1203
+ /** Explicitly set a toggle modifier's active state. */
1204
+ setModifierActive: (id: string, active: boolean) => void;
1205
+ /** Flip a toggle modifier between active and inactive. */
1206
+ toggleModifier: (id: string) => void;
1207
+ }
1208
+ declare const ToolbarProvider: React$1.FC<{
1209
+ children: React$1.ReactNode;
1210
+ }>;
1211
+ /**
1212
+ * Returns toolbar state and control functions from anywhere inside
1213
+ * a `<DockableDesktopProvider>` tree.
1214
+ *
1215
+ * Returns a no-op object with a console warning when called outside the provider.
1216
+ */
1217
+ declare function useToolbar(): ToolbarContextValue;
1218
+
1219
+ /**
1220
+ * @file Toolbar.tsx
1221
+ * @description Vertical or horizontal toolbar strip hosting action buttons,
1222
+ * mutually-exclusive radio tool groups, independent toggle modifiers,
1223
+ * and collapsible sub-tool group flyouts.
1224
+ * State is library-wide via DockableDesktopProvider / ToolbarContext.
1225
+ */
1226
+
1227
+ /** A one-shot action button. */
1228
+ interface ToolbarActionItem {
1229
+ type: 'action';
1230
+ id: string;
1231
+ label: string;
1232
+ icon: React$1.ReactNode;
1233
+ onClick: () => void;
1234
+ disabled?: boolean;
1235
+ }
1236
+ /** A mutually-exclusive radio button within a named group. */
1237
+ interface ToolbarRadioItem {
1238
+ type: 'radio';
1239
+ id: string;
1240
+ group: string;
1241
+ label: string;
1242
+ icon: React$1.ReactNode;
1243
+ /** Keyboard shortcut hint — displayed in the group flyout; reserved for future custom tooltip. */
1244
+ shortcut?: string;
1245
+ /** Called when this item becomes active. */
1246
+ onActivate?: (id: string) => void;
1247
+ disabled?: boolean;
1248
+ }
1249
+ /** An independent on/off toggle modifier (e.g. snap-to-grid). */
1250
+ interface ToolbarToggleItem {
1251
+ type: 'toggle';
1252
+ id: string;
1253
+ label: string;
1254
+ icon: React$1.ReactNode;
1255
+ /** Keyboard shortcut hint — reserved for future custom tooltip. */
1256
+ shortcut?: string;
1257
+ /** Called after the toggle flips; receives the new active state. */
1258
+ onToggle?: (active: boolean) => void;
1259
+ disabled?: boolean;
1260
+ }
1261
+ /** A visual divider between button groups. */
1262
+ interface ToolbarSeparator {
1263
+ type: 'separator';
1264
+ }
1265
+ /**
1266
+ * A single selectable sub-tool inside a group flyout.
1267
+ * All sub-items in the same ToolbarGroupItem share one radio group
1268
+ * keyed by the parent ToolbarGroupItem's `id`.
1269
+ */
1270
+ interface ToolbarGroupSubItem {
1271
+ id: string;
1272
+ label: string;
1273
+ icon: React$1.ReactNode;
1274
+ /** Keyboard shortcut displayed in the flyout panel. */
1275
+ shortcut?: string;
1276
+ disabled?: boolean;
1277
+ /** Called when this sub-item is selected. */
1278
+ onActivate?: (id: string) => void;
1279
+ }
1280
+ /** An entry inside a group flyout — either a sub-item or a separator. */
1281
+ type ToolbarGroupEntry = ToolbarGroupSubItem | {
1282
+ type: 'separator';
1283
+ };
1284
+ /**
1285
+ * A collapsed tool-family button that opens a flyout panel listing all
1286
+ * sub-tools. Only one sub-tool may be active at a time (radio semantics).
1287
+ * The parent button's icon morphs to show the currently active sub-tool.
1288
+ *
1289
+ * Supports both uncontrolled mode (omit activeItemId — state lives in
1290
+ * ToolbarContext) and controlled mode (provide activeItemId — the caller
1291
+ * is the single source of truth and must update the prop in response to
1292
+ * onActiveItemChange).
1293
+ */
1294
+ interface ToolbarGroupItem {
1295
+ type: 'group';
1296
+ /** Serves as both the button ID and the radio group key in ToolbarContext. */
1297
+ id: string;
1298
+ /** Tooltip / aria-label shown when no sub-item is active. */
1299
+ label: string;
1300
+ /** Icon shown when no sub-item is active. */
1301
+ defaultIcon: React$1.ReactNode;
1302
+ items: ToolbarGroupEntry[];
1303
+ disabled?: boolean;
1304
+ /**
1305
+ * Controlled active sub-item id. When provided (even as null), the
1306
+ * component reads this prop instead of ToolbarContext and fires
1307
+ * onActiveItemChange on click instead of updating context.
1308
+ * Omit (undefined) for uncontrolled behaviour.
1309
+ */
1310
+ activeItemId?: string | null;
1311
+ /**
1312
+ * Called when the user selects a sub-item in controlled mode.
1313
+ * The toolbar does not update itself — the caller must update activeItemId.
1314
+ */
1315
+ onActiveItemChange?: (id: string) => void;
1316
+ }
1317
+ type ToolbarItem = ToolbarActionItem | ToolbarRadioItem | ToolbarToggleItem | ToolbarGroupItem | ToolbarSeparator;
1318
+ interface ToolbarProps {
1319
+ /** Side the strip is attached to. Controls strip orientation. Default: 'left' */
1320
+ position?: 'left' | 'right' | 'top' | 'bottom';
1321
+ /** Ordered list of items to render. */
1322
+ items: ToolbarItem[];
1323
+ /** Collapse the strip to zero width/height. State is preserved — no unmount. */
1324
+ visible?: boolean;
1325
+ /** Called when show/hide/toggle is invoked on the imperative handle. */
1326
+ onVisibilityChange?: (visible: boolean) => void;
1327
+ className?: string;
1328
+ style?: React$1.CSSProperties;
1329
+ }
1330
+ interface ToolbarHandle {
1331
+ show(): void;
1332
+ hide(): void;
1333
+ toggle(): void;
1334
+ }
1335
+ declare const Toolbar: React$1.ForwardRefExoticComponent<ToolbarProps & React$1.RefAttributes<ToolbarHandle>>;
1121
1336
 
1122
- export { type BuiltInPanelEvents, type CloseOptions, ConfirmationForm, type ConfirmationFormProps, type ContextMenuPredefinedMessage, DockableDesktopProvider, type DropPosition, type DropTarget, type FloatingWindow, FormContainerContext, type FormContainerContract, FormContainerProvider, type LayoutGridNode, type LayoutLeafNode, type LayoutNode, LeftPanelRenderer, type MessageFormatter, type ModalOptions, ModalStackRenderer, type PanelActions, type PanelDefinition, type PanelInfo, type PanelInstance, type PanelInstanceId, PanelProvider, PanelRegistry, PanelRegistryClass, type PanelRegistryEntry, type PanelState, type PanelTitle, type PredefinedMessageKey, RightPanelRenderer, type SidePanelOptions, SidePanelRenderer, type SidePanelRendererProps, Sidebar, type SidebarHandle, type SidebarProps, type SidebarTab, type SplitDirection, type SplitOrientation, type StyleClasses, type WindowActions, WindowManager, WindowManagerProvider, type WindowState, WorkspaceClient, type WorkspaceClientConfig, defaultPredefinedMessages, formatLabel, useFormContainer, useFormatMessage, usePanelActions, usePanelContext, usePanelId, usePanelState, usePredefinedMessages, useRegistry, useStyleClasses, useWindowManagerActions, useWindowManagerState };
1337
+ export { type BuiltInPanelEvents, type CloseOptions, ConfirmationForm, type ConfirmationFormProps, type ContextMenuPredefinedMessage, DockableDesktopProvider, type DropPosition, type DropTarget, type FloatingWindow, FormContainerContext, type FormContainerContract, FormContainerProvider, type LayoutGridNode, type LayoutLeafNode, type LayoutNode, LeftPanelRenderer, type MessageFormatter, type ModalOptions, ModalStackRenderer, type PanelActions, type PanelDefinition, type PanelInfo, type PanelInstance, type PanelInstanceId, PanelProvider, PanelRegistry, PanelRegistryClass, type PanelRegistryEntry, type PanelState, type PanelTitle, type PredefinedMessageKey, RightPanelRenderer, type SidePanelOptions, SidePanelRenderer, type SidePanelRendererProps, Sidebar, type SidebarContextValue, type SidebarHandle, type SidebarProps, type SidebarTab, type SidebarTabContextValue, type SplitDirection, type SplitOrientation, type StyleClasses, Toolbar, type ToolbarActionItem, type ToolbarContextValue, type ToolbarGroupEntry, type ToolbarGroupItem, type ToolbarGroupSubItem, type ToolbarHandle, type ToolbarItem, type ToolbarProps, ToolbarProvider, type ToolbarRadioItem, type ToolbarSeparator, type ToolbarToggleItem, type WindowActions, WindowManager, WindowManagerProvider, type WindowState, WorkspaceClient, type WorkspaceClientConfig, defaultPredefinedMessages, formatLabel, useFormContainer, useFormatMessage, usePanelActions, usePanelContext, usePanelContextMenu, usePanelId, usePanelState, usePredefinedMessages, useRegistry, useSidebar, useSidebarTab, useStyleClasses, useToolbar, useWindowManagerActions, useWindowManagerState };