react-dockable-desktop 6.4.0 → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -119
- package/dist/index.cjs +10 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +700 -796
- package/dist/index.d.ts +700 -796
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/dist/styles.css +360 -366
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,341 +1,4 @@
|
|
|
1
|
-
import React$1, { ComponentType
|
|
2
|
-
|
|
3
|
-
interface ContextMenuPredefinedMessage$1 {
|
|
4
|
-
id: string;
|
|
5
|
-
defaultMessage?: string;
|
|
6
|
-
values?: Record<string, string | number>;
|
|
7
|
-
}
|
|
8
|
-
type MessageFormatter$1 = (msg: ContextMenuPredefinedMessage$1) => string;
|
|
9
|
-
type ContextMenuLabel = string | ContextMenuPredefinedMessage$1;
|
|
10
|
-
type MenuItemAction = () => void;
|
|
11
|
-
|
|
12
|
-
interface ContextMenuCheckbox {
|
|
13
|
-
/** Whether the checkbox column renders at all (default: true). */
|
|
14
|
-
active?: boolean;
|
|
15
|
-
/** Whether the item is interactive (default: true). Prefer top-level `disabled` on the item instead. */
|
|
16
|
-
enabled?: boolean;
|
|
17
|
-
/** Current checked state. */
|
|
18
|
-
value: boolean;
|
|
19
|
-
}
|
|
20
|
-
interface ContextMenuSimpleItem {
|
|
21
|
-
label: ContextMenuLabel;
|
|
22
|
-
icon?: React$1.ReactNode;
|
|
23
|
-
title?: ContextMenuLabel;
|
|
24
|
-
checkbox?: ContextMenuCheckbox;
|
|
25
|
-
action?: MenuItemAction;
|
|
26
|
-
cyAction?: string;
|
|
27
|
-
disabled?: boolean;
|
|
28
|
-
}
|
|
29
|
-
interface ContextMenuSeparator {
|
|
30
|
-
separator: true;
|
|
31
|
-
}
|
|
32
|
-
interface ContextMenuSubMenu {
|
|
33
|
-
label: ContextMenuLabel;
|
|
34
|
-
title?: ContextMenuLabel;
|
|
35
|
-
items?: ContextMenuItem[];
|
|
36
|
-
}
|
|
37
|
-
type ContextMenuItem = ContextMenuSimpleItem | ContextMenuSeparator | ContextMenuSubMenu;
|
|
38
|
-
interface ShowContextMenuOptions {
|
|
39
|
-
event?: React$1.MouseEvent | React$1.TouchEvent | MouseEvent | TouchEvent;
|
|
40
|
-
x?: number;
|
|
41
|
-
y?: number;
|
|
42
|
-
items: ContextMenuItem[];
|
|
43
|
-
}
|
|
44
|
-
interface ContextMenuHandle {
|
|
45
|
-
show(options: ShowContextMenuOptions): void;
|
|
46
|
-
}
|
|
47
|
-
interface ContextMenuProps {
|
|
48
|
-
theme?: string;
|
|
49
|
-
animation?: string;
|
|
50
|
-
formatMessageProvider?: MessageFormatter$1;
|
|
51
|
-
onShow?: () => void;
|
|
52
|
-
onHide?: () => void;
|
|
53
|
-
onOpenChange?: (open: boolean) => void;
|
|
54
|
-
className?: string;
|
|
55
|
-
style?: React$1.CSSProperties;
|
|
56
|
-
}
|
|
57
|
-
interface ContextMenuAdapter {
|
|
58
|
-
Component: React$1.ForwardRefExoticComponent<ContextMenuProps & React$1.RefAttributes<ContextMenuHandle>>;
|
|
59
|
-
}
|
|
60
|
-
declare const ContextMenu: React$1.ForwardRefExoticComponent<ContextMenuProps & React$1.RefAttributes<ContextMenuHandle>>;
|
|
61
|
-
declare const DefaultContextMenuAdapter: ContextMenuAdapter;
|
|
62
|
-
declare const ContextMenuProvider: React$1.FC<{
|
|
63
|
-
adapter?: ContextMenuAdapter;
|
|
64
|
-
children: React$1.ReactNode;
|
|
65
|
-
} & ContextMenuProps>;
|
|
66
|
-
declare function useShowContextMenu(): (options: ShowContextMenuOptions) => void;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* @file WindowManager.tsx
|
|
70
|
-
* @description Core component for react-dockable-desktop layout engine.
|
|
71
|
-
* Renders the workspace desktop containing docked splits, tabbed panels, floated windows,
|
|
72
|
-
* resize handles, context menus, and taskbar docks. Exposes lifecycle event listeners.
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
|
-
/** Controls when the minimized-panel taskbar is visible. */
|
|
76
|
-
type TaskbarVisibility = 'always' | 'compact' | 'autohide';
|
|
77
|
-
/** Props for `<WindowManager>`. */
|
|
78
|
-
interface WindowManagerProps {
|
|
79
|
-
/** Built-in skin name or a custom skin key registered via CSS. @default 'vscode' */
|
|
80
|
-
skin?: string;
|
|
81
|
-
/** Fallback icon shown in panel tabs when no panel-specific icon is provided. */
|
|
82
|
-
defaultPanelIcon?: React$1.ReactNode;
|
|
83
|
-
/**
|
|
84
|
-
* Controls taskbar visibility.
|
|
85
|
-
* - `'always'` — permanent bar at the bottom (default)
|
|
86
|
-
* - `'compact'` — only visible when minimized panels exist
|
|
87
|
-
* - `'autohide'` — overlay bar with 8 px peek strip
|
|
88
|
-
* @default 'always'
|
|
89
|
-
*/
|
|
90
|
-
taskbarVisibility?: TaskbarVisibility;
|
|
91
|
-
/** Custom context menu renderer. Defaults to the built-in `DefaultContextMenuAdapter`. */
|
|
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;
|
|
95
|
-
}
|
|
96
|
-
declare const WindowManager: React$1.FC<WindowManagerProps>;
|
|
97
|
-
|
|
98
|
-
/** Built-in lifecycle events always available on the WorkspaceClient event bus. */
|
|
99
|
-
interface BuiltInPanelEvents {
|
|
100
|
-
'panel:opened': {
|
|
101
|
-
id: string;
|
|
102
|
-
component: string;
|
|
103
|
-
};
|
|
104
|
-
'panel:closed': {
|
|
105
|
-
id: string;
|
|
106
|
-
};
|
|
107
|
-
'panel:minimized': {
|
|
108
|
-
id: string;
|
|
109
|
-
};
|
|
110
|
-
'panel:restored': {
|
|
111
|
-
id: string;
|
|
112
|
-
};
|
|
113
|
-
/**
|
|
114
|
-
* Fires whenever something `saveLayout()` would capture changes — open/close/minimize/restore,
|
|
115
|
-
* float/dock/re-order/dock-to-edge, closing a group, maximizing a minimized panel, and an
|
|
116
|
-
* `openPanel` `dedupeKey` redirect. Coalesces those into one signal for autosave-style
|
|
117
|
-
* consumers, so they don't need to subscribe to separate events. Does **not** cover a
|
|
118
|
-
* `registerStateProvider` callback's return value changing on its own — that's a pull, there's
|
|
119
|
-
* no way to observe it changing without the panel separately notifying — nor resize/split-ratio
|
|
120
|
-
* drag, which has no hook yet.
|
|
121
|
-
*/
|
|
122
|
-
'layout:changed': Record<string, never>;
|
|
123
|
-
/**
|
|
124
|
-
* Fires from inside `saveLayout()` itself, only when that specific call excluded at least one
|
|
125
|
-
* panel (a panel whose current `props` — static or from a `registerStateProvider` — failed
|
|
126
|
-
* {@link isSerializable}). A passive `PanelInfo.serializable` flag alone isn't enough for this:
|
|
127
|
-
* nobody may be polling it at the exact moment a save happens and something silently drops out
|
|
128
|
-
* (e.g. a floating window rendering data from a live class instance). This is deliberately just
|
|
129
|
-
* a signal, not a UI opinion — decide for yourself whether that becomes a toast, a console
|
|
130
|
-
* warning, or nothing.
|
|
131
|
-
*/
|
|
132
|
-
'layout:panels-excluded': {
|
|
133
|
-
panels: {
|
|
134
|
-
id: string;
|
|
135
|
-
component: string;
|
|
136
|
-
}[];
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
/** Per-panel definition supplied to WorkspaceClient constructor. */
|
|
140
|
-
interface PanelDefinition {
|
|
141
|
-
component: ComponentType<any>;
|
|
142
|
-
defaultOptions?: PanelRegistryEntry['defaultOptions'];
|
|
143
|
-
}
|
|
144
|
-
/** Configuration object accepted by the WorkspaceClient constructor. */
|
|
145
|
-
interface WorkspaceClientConfig {
|
|
146
|
-
/**
|
|
147
|
-
* Declarative panel catalog. Replaces imperative PanelRegistry.register() calls.
|
|
148
|
-
* Keys are the component identifiers used in openPanel() and serialised layouts.
|
|
149
|
-
*/
|
|
150
|
-
panels?: Record<string, PanelDefinition>;
|
|
151
|
-
/**
|
|
152
|
-
* Serialised layout produced by a previous saveLayout() call.
|
|
153
|
-
* Pass null or omit to start with an empty canvas.
|
|
154
|
-
*
|
|
155
|
-
* Parsed synchronously before the first render. The restored `activePanelId` is the one the
|
|
156
|
-
* snapshot recorded, or — for layouts saved before that was persisted — the selected tab of
|
|
157
|
-
* the first leaf in the grid.
|
|
158
|
-
*/
|
|
159
|
-
initialState?: string | null;
|
|
160
|
-
/** Custom i18n formatter for all internal strings. */
|
|
161
|
-
formatMessage?: MessageFormatter;
|
|
162
|
-
/** Override any subset of the built-in predefined message catalog. */
|
|
163
|
-
predefinedMessages?: Record<string, ContextMenuPredefinedMessage>;
|
|
164
|
-
/** Initial layout direction. */
|
|
165
|
-
dir?: 'ltr' | 'rtl';
|
|
166
|
-
/**
|
|
167
|
-
* Fraction of the target panel the new panel takes when dropped on a panel's
|
|
168
|
-
* top/bottom/left/right cross target. Range 0.1–0.9. Default: 0.5.
|
|
169
|
-
*/
|
|
170
|
-
defaultSplitRatio?: number;
|
|
171
|
-
/**
|
|
172
|
-
* Fraction of the workspace the new panel takes when dropped on the workspace
|
|
173
|
-
* outer edge. Range 0.1–0.9. Default: 0.2.
|
|
174
|
-
*/
|
|
175
|
-
defaultEdgeSplitRatio?: number;
|
|
176
|
-
/**
|
|
177
|
-
* Starting z-index for floating windows and the library's own chrome overlays
|
|
178
|
-
* (context menu, toolbar flyout, modal stack, toast, workspace edge zones),
|
|
179
|
-
* all of which shift together via `--rdd-z-base`. Set this above/below a host
|
|
180
|
-
* app's own modal z-index range to control stacking against it. Default: 1000.
|
|
181
|
-
*/
|
|
182
|
-
zIndexBase?: number;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* WorkspaceClient is the central configuration and imperative API object for
|
|
186
|
-
* react-dockable-desktop. Create one instance outside the React tree and pass
|
|
187
|
-
* it to `<WindowManagerProvider client={client}>`.
|
|
188
|
-
*
|
|
189
|
-
* Pattern: TanStack QueryClient / Redux store — configuration and imperative
|
|
190
|
-
* access live on the client; rendering is delegated to the thin React provider.
|
|
191
|
-
*
|
|
192
|
-
* @remarks
|
|
193
|
-
* Calls made before the provider mounts are queued and replayed automatically
|
|
194
|
-
* in order once `_connect()` fires. Duplicate `openPanel` calls for the same
|
|
195
|
-
* ID are deduplicated while queued. Subscriptions made before mount are
|
|
196
|
-
* buffered and re-registered on each connect/reconnect.
|
|
197
|
-
*
|
|
198
|
-
* @example
|
|
199
|
-
* const workspace = new WorkspaceClient<MyEvents>({
|
|
200
|
-
* panels: {
|
|
201
|
-
* map: { component: MapPanel },
|
|
202
|
-
* editor: { component: EditorPanel, defaultOptions: { title: 'Code Editor' } },
|
|
203
|
-
* },
|
|
204
|
-
* initialState: localStorage.getItem('layout'),
|
|
205
|
-
* });
|
|
206
|
-
*
|
|
207
|
-
* <WindowManagerProvider client={workspace}>
|
|
208
|
-
* <WindowManager />
|
|
209
|
-
* </WindowManagerProvider>
|
|
210
|
-
*
|
|
211
|
-
* // Imperative access from anywhere:
|
|
212
|
-
* workspace.saveLayout();
|
|
213
|
-
* workspace.openPanel('map-1', 'map');
|
|
214
|
-
* workspace.focusPanel('map-1');
|
|
215
|
-
*/
|
|
216
|
-
declare class WorkspaceClient<TUserEvents extends object = Record<string, unknown>> {
|
|
217
|
-
/** Scoped panel registry — fully independent from the global singleton. */
|
|
218
|
-
readonly registry: PanelRegistryClass;
|
|
219
|
-
/** Serialised layout to restore on mount, or null to start with an empty canvas. */
|
|
220
|
-
readonly initialState: string | null;
|
|
221
|
-
/** Non-rendering configuration forwarded to the provider. */
|
|
222
|
-
readonly config: Pick<WorkspaceClientConfig, 'formatMessage' | 'predefinedMessages' | 'dir' | 'defaultSplitRatio' | 'defaultEdgeSplitRatio' | 'zIndexBase'>;
|
|
223
|
-
private _actions;
|
|
224
|
-
private _initialized;
|
|
225
|
-
/** Calls queued before _connect() fires — replayed in order on first connect. */
|
|
226
|
-
private _pendingCalls;
|
|
227
|
-
/** Tracks openPanel IDs in the pending queue to prevent duplicates before mount. */
|
|
228
|
-
private _pendingOpenPanelIds;
|
|
229
|
-
/** Subscriptions buffered before connect — re-registered on every connect/reconnect. */
|
|
230
|
-
private _pendingSubscriptions;
|
|
231
|
-
/** Timer that emits an error if _connect() is never called with pending work. */
|
|
232
|
-
private _disconnectedWarnTimer;
|
|
233
|
-
constructor(config?: WorkspaceClientConfig);
|
|
234
|
-
/** @internal Called by WindowManagerProvider after mount. */
|
|
235
|
-
_connect(actions: WindowActions): void;
|
|
236
|
-
/** @internal Called by WindowManagerProvider on unmount. */
|
|
237
|
-
_disconnect(): void;
|
|
238
|
-
/** True while the provider is mounted and React state is accessible. */
|
|
239
|
-
get isConnected(): boolean;
|
|
240
|
-
private _startWarnTimer;
|
|
241
|
-
private _dispatch;
|
|
242
|
-
private _subscribeRaw;
|
|
243
|
-
openPanel(...args: Parameters<WindowActions['openPanel']>): void;
|
|
244
|
-
closePanel(id: string): void;
|
|
245
|
-
minimizePanel(id: string): void;
|
|
246
|
-
restorePanel(...args: Parameters<WindowActions['restorePanel']>): void;
|
|
247
|
-
floatPanel(...args: Parameters<WindowActions['floatPanel']>): void;
|
|
248
|
-
dockPanel(...args: Parameters<WindowActions['dockPanel']>): void;
|
|
249
|
-
maximizePanel(id: string): void;
|
|
250
|
-
/**
|
|
251
|
-
* Activates the given panel regardless of its current state.
|
|
252
|
-
* For floating panels: raises z-index so the window appears on top.
|
|
253
|
-
* For docked panels: selects the tab within its leaf group.
|
|
254
|
-
*/
|
|
255
|
-
focusPanel(id: string): void;
|
|
256
|
-
/** Returns `true` if a panel with this ID is currently open. */
|
|
257
|
-
isOpen(id: string): boolean;
|
|
258
|
-
/** Returns the IDs of all currently open panels. */
|
|
259
|
-
getOpenPanelIds(): string[];
|
|
260
|
-
/** Finds an already-open panel of the given component with a matching `dedupeKey` (set via
|
|
261
|
-
* `openPanel`'s `dedupeKey` option). Returns `null` if none is open. */
|
|
262
|
-
findPanelId(component: string, dedupeKey: string): string | null;
|
|
263
|
-
saveLayout(): string;
|
|
264
|
-
loadLayout(json: string): boolean;
|
|
265
|
-
setDirection(dir: 'ltr' | 'rtl'): void;
|
|
266
|
-
/** Updates the split-size fractions at the given grid path. */
|
|
267
|
-
updateSplitSizes(path: number[], sizes: number[]): void;
|
|
268
|
-
/** Updates position/size/anchor of a floating panel. */
|
|
269
|
-
updateFloatingPosition(id: string, updates: Partial<Pick<FloatingWindow, 'x' | 'y' | 'width' | 'height' | 'anchor'>>): void;
|
|
270
|
-
/** @internal Drives the drag-in-progress visual state; normally only the library's own drag UI calls this. */
|
|
271
|
-
setDraggedPanelId(id: string | null): void;
|
|
272
|
-
/** Docks a panel into an existing leaf group at the given drop position. */
|
|
273
|
-
dockPanelToGroup(id: string, targetLeafId: string, position: DropPosition): void;
|
|
274
|
-
/** Reorders a panel's tab within its leaf group. */
|
|
275
|
-
movePanelOrder(panelId: string, targetLeafId: string, targetIndex: number): void;
|
|
276
|
-
/**
|
|
277
|
-
* Closes a leaf group: each of its tabs is closed through the guarded close path, then the
|
|
278
|
-
* group is removed once empty. A tab whose close guard refuses — or a dirty tab that
|
|
279
|
-
* `onConfirm` doesn't approve — stays open, and so does its group.
|
|
280
|
-
* Resolves once every close request has been settled.
|
|
281
|
-
*
|
|
282
|
-
* @remarks If called before the provider mounts, the request is queued and this returns an
|
|
283
|
-
* already-resolved promise, as `requestClosePanel` does.
|
|
284
|
-
*/
|
|
285
|
-
closeLeafGroup(leafId: string, options?: {
|
|
286
|
-
onConfirm?: (opts?: DirtyStateOptions) => Promise<boolean>;
|
|
287
|
-
}): Promise<void>;
|
|
288
|
-
/** Registers a guard that can veto closing the given panel. */
|
|
289
|
-
registerCloseGuard(id: string, guard: () => boolean | Promise<boolean>): void;
|
|
290
|
-
/** Removes a previously registered close guard. */
|
|
291
|
-
unregisterCloseGuard(id: string): void;
|
|
292
|
-
/** Registers a callback reporting a panel's current restorable state, pulled fresh on every
|
|
293
|
-
* `saveLayout()` call — see {@link BuiltInPanelEvents}'s `'layout:panels-excluded'` doc and
|
|
294
|
-
* `FormContainerContract.registerStateProvider`. */
|
|
295
|
-
registerStateProvider(id: string, provider: () => unknown): void;
|
|
296
|
-
/** Removes a previously registered state provider. */
|
|
297
|
-
unregisterStateProvider(id: string): void;
|
|
298
|
-
/** Sets/clears a panel's dirty (unsaved changes) flag. */
|
|
299
|
-
setPanelDirty(id: string, dirty: boolean, options?: DirtyStateOptions): void;
|
|
300
|
-
/** Updates a panel's displayed title. */
|
|
301
|
-
updatePanelTitle(id: string, title: string | ContextMenuPredefinedMessage): void;
|
|
302
|
-
/**
|
|
303
|
-
* Requests that a panel close, honoring its dirty flag and any registered close guard.
|
|
304
|
-
* Resolves once the close (or user cancellation) has been resolved.
|
|
305
|
-
*
|
|
306
|
-
* @remarks If called before the provider mounts, the request is queued and this
|
|
307
|
-
* returns an already-resolved promise immediately — the caller can't observe the
|
|
308
|
-
* eventual outcome of a queued call, only that the request was accepted.
|
|
309
|
-
*/
|
|
310
|
-
requestClosePanel(id: string, options?: {
|
|
311
|
-
force?: boolean;
|
|
312
|
-
onConfirm?: (opts?: DirtyStateOptions) => Promise<boolean>;
|
|
313
|
-
}): Promise<void>;
|
|
314
|
-
/** Docks a panel to one of the workspace's outer edges. */
|
|
315
|
-
dockPanelToWorkspaceEdge(id: string, position: SplitDirection): void;
|
|
316
|
-
/** Shows a context menu using the app's configured ContextMenuAdapter. */
|
|
317
|
-
showContextMenu(options: ShowContextMenuOptions): void;
|
|
318
|
-
publish<K extends keyof (TUserEvents & BuiltInPanelEvents)>(event: K, data: (TUserEvents & BuiltInPanelEvents)[K]): void;
|
|
319
|
-
subscribe<K extends keyof (TUserEvents & BuiltInPanelEvents)>(event: K, callback: (data: (TUserEvents & BuiltInPanelEvents)[K]) => void): () => void;
|
|
320
|
-
/** Subscribe to panel open events. Fires only for newly created panels. */
|
|
321
|
-
onPanelOpen(callback: (id: string, component: string) => void): () => void;
|
|
322
|
-
/** Subscribe to panel close events. */
|
|
323
|
-
onPanelClose(callback: (id: string) => void): () => void;
|
|
324
|
-
/** Subscribe to panel minimize events. */
|
|
325
|
-
onPanelMinimize(callback: (id: string) => void): () => void;
|
|
326
|
-
/** Subscribe to panel restore events. */
|
|
327
|
-
onPanelRestore(callback: (id: string) => void): () => void;
|
|
328
|
-
/** Subscribe to the coalesced layout-change signal — see {@link BuiltInPanelEvents}'s
|
|
329
|
-
* `'layout:changed'` doc for exactly what it covers (and doesn't). */
|
|
330
|
-
onLayoutChanged(callback: () => void): () => void;
|
|
331
|
-
/** Subscribe to notification that a `saveLayout()` call excluded one or more panels because
|
|
332
|
-
* their current props weren't serializable — see {@link BuiltInPanelEvents}'s
|
|
333
|
-
* `'layout:panels-excluded'` doc. */
|
|
334
|
-
onPanelsExcluded(callback: (panels: {
|
|
335
|
-
id: string;
|
|
336
|
-
component: string;
|
|
337
|
-
}[]) => void): () => void;
|
|
338
|
-
}
|
|
1
|
+
import React$1, { ComponentType } from 'react';
|
|
339
2
|
|
|
340
3
|
/**
|
|
341
4
|
* @file predefinedMessages.ts
|
|
@@ -346,8 +9,8 @@ declare class WorkspaceClient<TUserEvents extends object = Record<string, unknow
|
|
|
346
9
|
* define in their IntlProvider messages table. The `defaultMessage` is used
|
|
347
10
|
* as a fallback when no external formatter is provided.
|
|
348
11
|
*
|
|
349
|
-
* Pass a partial or full override
|
|
350
|
-
* to customise labels without replacing the whole table.
|
|
12
|
+
* Pass a partial or full override as `createWorkspace({ messages })` or
|
|
13
|
+
* `<DockableDesktopProvider messages={…}>` to customise labels without replacing the whole table.
|
|
351
14
|
*/
|
|
352
15
|
declare const defaultPredefinedMessages: {
|
|
353
16
|
readonly floatWindow: {
|
|
@@ -500,16 +163,16 @@ declare const defaultPredefinedMessages: {
|
|
|
500
163
|
};
|
|
501
164
|
};
|
|
502
165
|
/**
|
|
503
|
-
* Union of every key in `
|
|
166
|
+
* Union of every key in `defaultMessages`.
|
|
504
167
|
*
|
|
505
168
|
* Import this type in your i18n message tables to get a compile-time
|
|
506
169
|
* guarantee that all keys are present and no typos exist:
|
|
507
170
|
*
|
|
508
|
-
* import type {
|
|
171
|
+
* import type { MessageKey } from 'react-dockable-desktop';
|
|
509
172
|
*
|
|
510
|
-
* const myMessages: Record<
|
|
173
|
+
* const myMessages: Record<MessageKey, string> = { ... };
|
|
511
174
|
*/
|
|
512
|
-
type
|
|
175
|
+
type MessageKey = keyof typeof defaultPredefinedMessages;
|
|
513
176
|
|
|
514
177
|
/**
|
|
515
178
|
* @file dirtyOptions.ts
|
|
@@ -524,12 +187,12 @@ interface DirtyStateOptions {
|
|
|
524
187
|
* Custom header title text or localizable message descriptor.
|
|
525
188
|
* Replaces the default "Unsaved Changes" title.
|
|
526
189
|
*/
|
|
527
|
-
title?: string |
|
|
190
|
+
title?: string | MessageDescriptor;
|
|
528
191
|
/**
|
|
529
192
|
* Custom warning explanation text or localizable message descriptor.
|
|
530
193
|
* Replaces the standard default message body templates.
|
|
531
194
|
*/
|
|
532
|
-
message?: string |
|
|
195
|
+
message?: string | MessageDescriptor;
|
|
533
196
|
/**
|
|
534
197
|
* Optional custom alert notification banner text.
|
|
535
198
|
* Typically lists missing validation field requirements or backup statuses.
|
|
@@ -542,10 +205,69 @@ interface DirtyStateOptions {
|
|
|
542
205
|
alertType?: 'info' | 'warning' | 'success' | 'danger';
|
|
543
206
|
}
|
|
544
207
|
|
|
208
|
+
interface MessageDescriptor$1 {
|
|
209
|
+
id: string;
|
|
210
|
+
defaultMessage?: string;
|
|
211
|
+
values?: Record<string, string | number>;
|
|
212
|
+
}
|
|
213
|
+
type MessageFormatter$1 = (msg: MessageDescriptor$1) => string;
|
|
214
|
+
type ContextMenuLabel = string | MessageDescriptor$1;
|
|
215
|
+
type MenuItemAction = () => void;
|
|
216
|
+
|
|
217
|
+
interface ContextMenuCheckbox {
|
|
218
|
+
/** Whether the checkbox column renders at all (default: true). */
|
|
219
|
+
active?: boolean;
|
|
220
|
+
/** Whether the item is interactive (default: true). Prefer top-level `disabled` on the item instead. */
|
|
221
|
+
enabled?: boolean;
|
|
222
|
+
/** Current checked state. */
|
|
223
|
+
value: boolean;
|
|
224
|
+
}
|
|
225
|
+
interface ContextMenuSimpleItem {
|
|
226
|
+
label: ContextMenuLabel;
|
|
227
|
+
icon?: React$1.ReactNode;
|
|
228
|
+
title?: ContextMenuLabel;
|
|
229
|
+
checkbox?: ContextMenuCheckbox;
|
|
230
|
+
action?: MenuItemAction;
|
|
231
|
+
cyAction?: string;
|
|
232
|
+
disabled?: boolean;
|
|
233
|
+
}
|
|
234
|
+
interface ContextMenuSeparator {
|
|
235
|
+
separator: true;
|
|
236
|
+
}
|
|
237
|
+
interface ContextMenuSubMenu {
|
|
238
|
+
label: ContextMenuLabel;
|
|
239
|
+
title?: ContextMenuLabel;
|
|
240
|
+
items?: ContextMenuItem[];
|
|
241
|
+
}
|
|
242
|
+
type ContextMenuItem = ContextMenuSimpleItem | ContextMenuSeparator | ContextMenuSubMenu;
|
|
243
|
+
interface ShowContextMenuOptions {
|
|
244
|
+
event?: React$1.MouseEvent | React$1.TouchEvent | MouseEvent | TouchEvent;
|
|
245
|
+
x?: number;
|
|
246
|
+
y?: number;
|
|
247
|
+
items: ContextMenuItem[];
|
|
248
|
+
}
|
|
249
|
+
interface ContextMenuHandle {
|
|
250
|
+
show(options: ShowContextMenuOptions): void;
|
|
251
|
+
}
|
|
252
|
+
interface ContextMenuProps {
|
|
253
|
+
theme?: string;
|
|
254
|
+
animation?: string;
|
|
255
|
+
formatMessageProvider?: MessageFormatter$1;
|
|
256
|
+
onShow?: () => void;
|
|
257
|
+
onHide?: () => void;
|
|
258
|
+
onOpenChange?: (open: boolean) => void;
|
|
259
|
+
className?: string;
|
|
260
|
+
style?: React$1.CSSProperties;
|
|
261
|
+
}
|
|
262
|
+
interface ContextMenuAdapter {
|
|
263
|
+
Component: React$1.ForwardRefExoticComponent<ContextMenuProps & React$1.RefAttributes<ContextMenuHandle>>;
|
|
264
|
+
}
|
|
265
|
+
declare function useShowContextMenu(): (options: ShowContextMenuOptions) => void;
|
|
266
|
+
|
|
545
267
|
/**
|
|
546
268
|
* Structure representing localizable message descriptors used in context menus.
|
|
547
269
|
*/
|
|
548
|
-
interface
|
|
270
|
+
interface MessageDescriptor {
|
|
549
271
|
/** Translation dictionary key. */
|
|
550
272
|
id: string;
|
|
551
273
|
/** Fallback label text if translation key is missing. */
|
|
@@ -554,7 +276,7 @@ interface ContextMenuPredefinedMessage {
|
|
|
554
276
|
values?: Record<string, string | number>;
|
|
555
277
|
}
|
|
556
278
|
/** Function type interface responsible for resolving localizable messages to flat strings. */
|
|
557
|
-
type MessageFormatter = (msg:
|
|
279
|
+
type MessageFormatter = (msg: MessageDescriptor) => string;
|
|
558
280
|
/** Orientation modifier indicating split directions. */
|
|
559
281
|
type SplitOrientation = 'horizontal' | 'vertical';
|
|
560
282
|
/** The four cardinal directions a panel can be docked relative to another. */
|
|
@@ -635,8 +357,8 @@ interface PanelInfo {
|
|
|
635
357
|
/** Unique panel identifier. */
|
|
636
358
|
id: string;
|
|
637
359
|
/** Plain text label or localizable message descriptor. */
|
|
638
|
-
title: string |
|
|
639
|
-
/** String matching the component registration ID in the {@link PanelRegistry}. */
|
|
360
|
+
title: string | MessageDescriptor;
|
|
361
|
+
/** String matching the component registration ID in the workspace's {@link PanelRegistry}. */
|
|
640
362
|
component: string;
|
|
641
363
|
/** Current workspace placement mode. */
|
|
642
364
|
state: 'docked' | 'floating' | 'minimized';
|
|
@@ -658,7 +380,7 @@ interface PanelInfo {
|
|
|
658
380
|
dirtyOptions?: DirtyStateOptions;
|
|
659
381
|
/** Custom per-instance data passed via `openPanel(id, component, { props })`. Unconstrained —
|
|
660
382
|
* any value is accepted, but only a value that passes {@link isSerializable} is actually
|
|
661
|
-
* included in {@link
|
|
383
|
+
* included in {@link WorkspaceActions.saveLayout}'s output. See {@link PanelInfo.serializable}. */
|
|
662
384
|
props?: Record<string, unknown>;
|
|
663
385
|
/** Whether this panel's current `props` can round-trip through `saveLayout()`/`loadLayout()`.
|
|
664
386
|
* Computed automatically — `true` when no `props` were passed, or when they were and passed
|
|
@@ -668,15 +390,15 @@ interface PanelInfo {
|
|
|
668
390
|
serializable: boolean;
|
|
669
391
|
/** Optional dedup key. If another open panel of the same `component` already has this exact
|
|
670
392
|
* key, `openPanel` focuses that existing panel instead of creating a new one — see
|
|
671
|
-
* {@link
|
|
393
|
+
* {@link WorkspaceActions.openPanel}'s `dedupeKey` option and {@link WorkspaceActions.findPanelId}. */
|
|
672
394
|
dedupeKey?: string;
|
|
673
395
|
}
|
|
674
396
|
/**
|
|
675
|
-
* Options accepted by {@link
|
|
397
|
+
* Options accepted by {@link WorkspaceActions.openPanel}.
|
|
676
398
|
*/
|
|
677
399
|
interface OpenPanelOptions<P extends object = Record<string, unknown>> {
|
|
678
400
|
/** Override the panel tab/window title. Accepts a plain string or an i18n message descriptor. */
|
|
679
|
-
title?: string |
|
|
401
|
+
title?: string | MessageDescriptor;
|
|
680
402
|
/** Initial placement: `'floating'`, `'docked'` (default when a grid exists), or `'tabbed'`. */
|
|
681
403
|
initialTarget?: 'floating' | 'docked' | 'tabbed';
|
|
682
404
|
/** Pin the new floating window to a workspace corner on creation. Has no effect when
|
|
@@ -698,14 +420,14 @@ interface OpenPanelOptions<P extends object = Record<string, unknown>> {
|
|
|
698
420
|
* passed to *this* call are ignored in that case, the same way re-opening an already-open exact
|
|
699
421
|
* `id` already focuses it instead of duplicating it. Use this when multiple call sites might
|
|
700
422
|
* not agree on the same literal `id` for what is semantically the same entity (e.g. "the panel
|
|
701
|
-
* for the document at this path"). See also {@link
|
|
423
|
+
* for the document at this path"). See also {@link WorkspaceActions.findPanelId}.
|
|
702
424
|
*/
|
|
703
425
|
dedupeKey?: string;
|
|
704
426
|
}
|
|
705
427
|
/**
|
|
706
428
|
* Global window manager state tree representing grid nodes, windows, and panels.
|
|
707
429
|
*/
|
|
708
|
-
interface
|
|
430
|
+
interface WorkspaceState {
|
|
709
431
|
/** Root branch node representing the grid. */
|
|
710
432
|
gridRoot: LayoutNode;
|
|
711
433
|
/** Array of active floated windows. */
|
|
@@ -713,7 +435,7 @@ interface WindowState {
|
|
|
713
435
|
/** Array of minimized panels waiting in the taskbar dock. */
|
|
714
436
|
minimized: {
|
|
715
437
|
id: string;
|
|
716
|
-
title: string |
|
|
438
|
+
title: string | MessageDescriptor;
|
|
717
439
|
component: string;
|
|
718
440
|
}[];
|
|
719
441
|
/** Map indexing panel metadata descriptors. */
|
|
@@ -722,7 +444,7 @@ interface WindowState {
|
|
|
722
444
|
draggedPanelId: string | null;
|
|
723
445
|
/**
|
|
724
446
|
* The ID of the active/focused panel — the one contributions are read from
|
|
725
|
-
* (see `
|
|
447
|
+
* (see `useActiveContribution`) and the one drawn with focused chrome.
|
|
726
448
|
*
|
|
727
449
|
* Always a panel the user can actually see: the selected tab of its leaf, or a floating
|
|
728
450
|
* window. Never a minimized panel, except when an app explicitly calls `focusPanel()` on
|
|
@@ -740,22 +462,20 @@ interface WindowState {
|
|
|
740
462
|
edgeSplitRatio: number;
|
|
741
463
|
}
|
|
742
464
|
/**
|
|
743
|
-
*
|
|
744
|
-
* exposed by the `WindowManagerProvider`.
|
|
465
|
+
* Every layout action, the event bus, and layout serialization — the methods of a workspace.
|
|
745
466
|
*
|
|
746
|
-
*
|
|
747
|
-
*
|
|
467
|
+
* Call them on the workspace from `useWorkspace()` inside a component, or on the object
|
|
468
|
+
* `createWorkspace()` returned, from anywhere.
|
|
748
469
|
*
|
|
749
|
-
* @group Hooks
|
|
750
470
|
* @example
|
|
751
471
|
* ```tsx
|
|
752
|
-
* function
|
|
753
|
-
* const
|
|
754
|
-
* return <button onClick={() =>
|
|
472
|
+
* function OpenMapButton() {
|
|
473
|
+
* const { openPanel } = useWorkspace();
|
|
474
|
+
* return <button onClick={() => openPanel('map-1', 'map')}>Open Map</button>;
|
|
755
475
|
* }
|
|
756
476
|
* ```
|
|
757
477
|
*/
|
|
758
|
-
interface
|
|
478
|
+
interface WorkspaceActions {
|
|
759
479
|
/**
|
|
760
480
|
* Opens a registered panel into the workspace.
|
|
761
481
|
* If the panel ID is already open, the panel is focused instead of duplicated.
|
|
@@ -991,7 +711,7 @@ interface WindowActions {
|
|
|
991
711
|
* @param id - Panel instance ID.
|
|
992
712
|
* @param title - New title string or localizable message descriptor.
|
|
993
713
|
*/
|
|
994
|
-
updatePanelTitle: (id: string, title: string |
|
|
714
|
+
updatePanelTitle: (id: string, title: string | MessageDescriptor) => void;
|
|
995
715
|
/**
|
|
996
716
|
* Closes a panel, first running any registered close guards.
|
|
997
717
|
* If the panel is dirty, shows the built-in unsaved-changes confirmation dialog.
|
|
@@ -1015,13 +735,29 @@ interface WindowActions {
|
|
|
1015
735
|
setDirection: (dir: 'ltr' | 'rtl') => void;
|
|
1016
736
|
/**
|
|
1017
737
|
* Imperatively shows the workspace context menu at the given position.
|
|
1018
|
-
*
|
|
1019
|
-
*
|
|
738
|
+
* Uses the workspace's context menu (the `contextMenuAdapter` given to
|
|
739
|
+
* `<DockableDesktopProvider>`, or an enclosing `<RddContextMenu>`).
|
|
1020
740
|
*/
|
|
1021
741
|
showContextMenu: (options: ShowContextMenuOptions) => void;
|
|
1022
742
|
}
|
|
743
|
+
/**
|
|
744
|
+
* Extension of {@link WorkspaceActions} used internally by WindowManager components.
|
|
745
|
+
* `setActivePanel` is not part of the public API — it is a low-level tab-focus
|
|
746
|
+
* primitive used exclusively within this library's rendering layer.
|
|
747
|
+
* @internal
|
|
748
|
+
*/
|
|
749
|
+
interface InternalWindowActions extends WorkspaceActions {
|
|
750
|
+
/** @internal */
|
|
751
|
+
setActivePanel: (id: string | null) => void;
|
|
752
|
+
/** @internal */
|
|
753
|
+
registerPanelContextMenu: (panelId: string, getItems: () => ContextMenuItem[]) => () => void;
|
|
754
|
+
/** @internal */
|
|
755
|
+
getPanelContextMenuItems: (panelId: string) => ContextMenuItem[];
|
|
756
|
+
/** @internal */
|
|
757
|
+
registerContextMenuFn: (fn: (options: ShowContextMenuOptions) => void) => () => void;
|
|
758
|
+
}
|
|
1023
759
|
/** Represents custom CSS classes injected into layout parts. */
|
|
1024
|
-
interface
|
|
760
|
+
interface HostClasses {
|
|
1025
761
|
modalClass?: string;
|
|
1026
762
|
modalBodyClass?: string;
|
|
1027
763
|
sidePanelClass?: string;
|
|
@@ -1030,24 +766,7 @@ interface StyleClasses {
|
|
|
1030
766
|
windowBodyClass?: string;
|
|
1031
767
|
}
|
|
1032
768
|
/** Custom hook to read configured style class contexts. */
|
|
1033
|
-
declare const useStyleClasses: () =>
|
|
1034
|
-
/**
|
|
1035
|
-
* React hook to read the scoped {@link PanelRegistryClass} for the current provider.
|
|
1036
|
-
* When the provider was created with a {@link WorkspaceClient}, this returns the client's
|
|
1037
|
-
* private registry. Otherwise it returns the global `PanelRegistry` singleton.
|
|
1038
|
-
*
|
|
1039
|
-
* @group Hooks
|
|
1040
|
-
* @returns The panel registry instance in scope.
|
|
1041
|
-
* @example
|
|
1042
|
-
* ```tsx
|
|
1043
|
-
* function MyComponent() {
|
|
1044
|
-
* const registry = useRegistry();
|
|
1045
|
-
* const entry = registry.get('map');
|
|
1046
|
-
* return entry ? <entry.Component panelId="preview" /> : null;
|
|
1047
|
-
* }
|
|
1048
|
-
* ```
|
|
1049
|
-
*/
|
|
1050
|
-
declare const useRegistry: () => PanelRegistryClass;
|
|
769
|
+
declare const useStyleClasses: () => HostClasses;
|
|
1051
770
|
/** The on-disk shape produced by `saveLayout()` and accepted by `loadLayout()`/`initialState`. */
|
|
1052
771
|
interface SerializedLayout {
|
|
1053
772
|
/** Schema version — absent on layouts saved before this field was introduced (treated as 0). */
|
|
@@ -1056,7 +775,7 @@ interface SerializedLayout {
|
|
|
1056
775
|
* The globally active panel at save time — the one the user was actually looking at.
|
|
1057
776
|
*
|
|
1058
777
|
* Omitted when nothing was active, and when the active panel didn't survive this snapshot's
|
|
1059
|
-
* serializability pruning (see {@link
|
|
778
|
+
* serializability pruning (see {@link WorkspaceActions.saveLayout}) — so it never names a panel
|
|
1060
779
|
* absent from this payload's own `panels`. Absent on every layout saved before this field
|
|
1061
780
|
* existed, in which case the restore derives it from `gridRoot`'s own per-leaf selection
|
|
1062
781
|
* instead; a present-but-no-longer-valid value falls back to the same derivation. `version`
|
|
@@ -1068,72 +787,24 @@ interface SerializedLayout {
|
|
|
1068
787
|
floating: FloatingWindow[];
|
|
1069
788
|
minimized: {
|
|
1070
789
|
id: string;
|
|
1071
|
-
title: string |
|
|
790
|
+
title: string | MessageDescriptor;
|
|
1072
791
|
component: string;
|
|
1073
792
|
}[];
|
|
1074
793
|
panels: Record<string, PanelInfo>;
|
|
1075
794
|
}
|
|
1076
|
-
/**
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
*/
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
client?: WorkspaceClient;
|
|
1087
|
-
/** Custom i18n formatter. Receives a `{ id, defaultMessage }` descriptor and returns
|
|
1088
|
-
* the translated string. When omitted, `defaultMessage` is used as-is. */
|
|
1089
|
-
formatMessage?: MessageFormatter;
|
|
1090
|
-
/** Override the built-in predefined UI strings (confirm button labels, close tooltips, etc.).
|
|
1091
|
-
* Merge with or replace `defaultPredefinedMessages` to localise system strings. */
|
|
1092
|
-
predefinedMessages?: Record<string, ContextMenuPredefinedMessage>;
|
|
1093
|
-
/** Layout direction. `'rtl'` mirrors all controls, tab order, and drop zones.
|
|
1094
|
-
* Can also be changed at runtime via `WorkspaceClient.setDirection()`. @default 'ltr' */
|
|
1095
|
-
dir?: 'ltr' | 'rtl';
|
|
1096
|
-
/** CSS class applied to the outer wrapper element of every modal overlay. */
|
|
1097
|
-
modalClass?: string;
|
|
1098
|
-
/** CSS class applied to the inner content area of every modal overlay. */
|
|
1099
|
-
modalBodyClass?: string;
|
|
1100
|
-
/** CSS class applied to the outer wrapper of left/right side-panel drawers. */
|
|
1101
|
-
sidePanelClass?: string;
|
|
1102
|
-
/** CSS class applied to the inner content area of side-panel drawers. */
|
|
1103
|
-
sidePanelBodyClass?: string;
|
|
1104
|
-
/** CSS class applied to the outer wrapper of floating panel windows. */
|
|
1105
|
-
windowClass?: string;
|
|
1106
|
-
/** CSS class applied to the inner content area of floating panel windows. */
|
|
1107
|
-
windowBodyClass?: string;
|
|
1108
|
-
/**
|
|
1109
|
-
* Starting z-index for floating windows and the library's own chrome overlays
|
|
1110
|
-
* (context menu, toolbar flyout, modal stack, toast, workspace edge zones),
|
|
1111
|
-
* all of which shift together via `--rdd-z-base`. Set this above/below a host
|
|
1112
|
-
* app's own modal z-index range to control stacking against it. @default 1000
|
|
1113
|
-
*/
|
|
1114
|
-
zIndexBase?: number;
|
|
795
|
+
/** @internal What a workspace store exposes: its actions, and a subscribable snapshot. */
|
|
796
|
+
interface WorkspaceCore {
|
|
797
|
+
actions: InternalWindowActions;
|
|
798
|
+
getSnapshot: () => WorkspaceState;
|
|
799
|
+
subscribeToState: (cb: () => void) => () => void;
|
|
800
|
+
/** Provider props fill in what the workspace's own config left unset (dir, zIndexBase). */
|
|
801
|
+
applyProviderDefaults: (defaults: {
|
|
802
|
+
dir?: 'ltr' | 'rtl';
|
|
803
|
+
zIndexBase?: number;
|
|
804
|
+
}) => void;
|
|
1115
805
|
}
|
|
1116
|
-
declare
|
|
1117
|
-
declare function useWindowManagerState():
|
|
1118
|
-
declare function useWindowManagerState<T>(selector: (state: WindowState) => T): T;
|
|
1119
|
-
/**
|
|
1120
|
-
* React hook to retrieve all layout mutation actions.
|
|
1121
|
-
* Returns the public {@link WindowActions} interface.
|
|
1122
|
-
*
|
|
1123
|
-
* @group Hooks
|
|
1124
|
-
* @returns The full set of workspace mutation methods.
|
|
1125
|
-
* @throws Error if used outside of a {@link WindowManagerProvider}.
|
|
1126
|
-
* @example
|
|
1127
|
-
* ```tsx
|
|
1128
|
-
* function Toolbar() {
|
|
1129
|
-
* const actions = useWindowManagerActions();
|
|
1130
|
-
* return (
|
|
1131
|
-
* <button onClick={() => actions.openPanel('map-1', 'map')}>Open Map</button>
|
|
1132
|
-
* );
|
|
1133
|
-
* }
|
|
1134
|
-
* ```
|
|
1135
|
-
*/
|
|
1136
|
-
declare const useWindowManagerActions: () => WindowActions;
|
|
806
|
+
declare function useWindowManagerState(): WorkspaceState;
|
|
807
|
+
declare function useWindowManagerState<T>(selector: (state: WorkspaceState) => T): T;
|
|
1137
808
|
/**
|
|
1138
809
|
* React hook to retrieve the active i18n formatter.
|
|
1139
810
|
*/
|
|
@@ -1141,36 +812,15 @@ declare const useFormatMessage: () => MessageFormatter;
|
|
|
1141
812
|
/**
|
|
1142
813
|
* Helper to resolve dynamic label strings or localizable descriptor objects into text.
|
|
1143
814
|
*/
|
|
1144
|
-
declare const formatLabel: (label: string |
|
|
1145
|
-
/**
|
|
1146
|
-
* React hook providing pub-sub helper methods for inter-panel event messaging.
|
|
1147
|
-
*/
|
|
1148
|
-
declare const usePanelContext: () => Pick<WindowActions, "publish" | "subscribe">;
|
|
815
|
+
declare const formatLabel: (label: string | MessageDescriptor | undefined, formatter: MessageFormatter) => string;
|
|
1149
816
|
/**
|
|
1150
817
|
* React hook to fetch the localizable predefined message map catalog.
|
|
1151
818
|
*/
|
|
1152
|
-
declare const usePredefinedMessages: () => Record<
|
|
1153
|
-
/**
|
|
1154
|
-
* React hook to retrieve the panel instance ID for the component currently rendered inside
|
|
1155
|
-
* the dockable desktop. Works for docked, floating, modal, and side-panel containers.
|
|
1156
|
-
* Opt-in — components that don't need the ID require no changes.
|
|
1157
|
-
*
|
|
1158
|
-
* @group Hooks
|
|
1159
|
-
* @returns The unique panel instance ID string.
|
|
1160
|
-
* @example
|
|
1161
|
-
* ```tsx
|
|
1162
|
-
* function MyPanel() {
|
|
1163
|
-
* const panelId = usePanelId();
|
|
1164
|
-
* const { closePanel } = useWindowManagerActions();
|
|
1165
|
-
* return <button onClick={() => closePanel(panelId)}>Close</button>;
|
|
1166
|
-
* }
|
|
1167
|
-
* ```
|
|
1168
|
-
*/
|
|
1169
|
-
declare const usePanelId: () => string;
|
|
819
|
+
declare const usePredefinedMessages: () => Record<MessageKey, MessageDescriptor>;
|
|
1170
820
|
/**
|
|
1171
821
|
* React hook for injecting custom context menu items into a panel's context menu from inside the panel component.
|
|
1172
822
|
* Items are dynamic — the array is re-read each time the menu opens, so state-driven changes (enable/disable, add/remove) work automatically.
|
|
1173
|
-
* The hook
|
|
823
|
+
* The hook knows which panel it is in — no id needed.
|
|
1174
824
|
*
|
|
1175
825
|
* @param items - Array of `ContextMenuItem` entries (simple items, separators, submenus).
|
|
1176
826
|
* @example
|
|
@@ -1231,9 +881,9 @@ interface PanelRegistryEntry {
|
|
|
1231
881
|
/**
|
|
1232
882
|
* Registry mapping catalog entries to allow programmatic panel instantiation
|
|
1233
883
|
* inside dynamic layout cells or floating windows.
|
|
1234
|
-
* Exported so
|
|
884
|
+
* Exported so `createWorkspace()` can create scoped, per-instance registries.
|
|
1235
885
|
*/
|
|
1236
|
-
declare class
|
|
886
|
+
declare class PanelRegistry {
|
|
1237
887
|
private registry;
|
|
1238
888
|
/**
|
|
1239
889
|
* Register a new component to the panel catalog registry.
|
|
@@ -1251,66 +901,226 @@ declare class PanelRegistryClass {
|
|
|
1251
901
|
*/
|
|
1252
902
|
getRegisteredIds(): string[];
|
|
1253
903
|
}
|
|
1254
|
-
/** Global singleton instance of the Panel Registry. */
|
|
1255
|
-
declare const PanelRegistry: PanelRegistryClass;
|
|
1256
904
|
|
|
1257
|
-
/**
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
905
|
+
/** Built-in lifecycle events always available on the workspace event bus. */
|
|
906
|
+
interface BuiltInEvents {
|
|
907
|
+
'panel:opened': {
|
|
908
|
+
id: string;
|
|
909
|
+
component: string;
|
|
910
|
+
};
|
|
911
|
+
'panel:closed': {
|
|
912
|
+
id: string;
|
|
913
|
+
};
|
|
914
|
+
'panel:minimized': {
|
|
915
|
+
id: string;
|
|
916
|
+
};
|
|
917
|
+
'panel:restored': {
|
|
918
|
+
id: string;
|
|
919
|
+
};
|
|
1262
920
|
/**
|
|
1263
|
-
*
|
|
1264
|
-
*
|
|
1265
|
-
*
|
|
921
|
+
* Fires whenever something `saveLayout()` would capture changes — open/close/minimize/restore,
|
|
922
|
+
* float/dock/re-order/dock-to-edge, closing a group, maximizing a minimized panel, and an
|
|
923
|
+
* `openPanel` `dedupeKey` redirect. Coalesces those into one signal for autosave-style
|
|
924
|
+
* consumers, so they don't need to subscribe to separate events. Does **not** cover a
|
|
925
|
+
* `registerStateProvider` callback's return value changing on its own — that's a pull, there's
|
|
926
|
+
* no way to observe it changing without the panel separately notifying — nor resize/split-ratio
|
|
927
|
+
* drag, which has no hook yet.
|
|
928
|
+
*/
|
|
929
|
+
'layout:changed': Record<string, never>;
|
|
930
|
+
/**
|
|
931
|
+
* Fires from inside `saveLayout()` itself, only when that specific call excluded at least one
|
|
932
|
+
* panel (a panel whose current `props` — static or from a `registerStateProvider` — failed
|
|
933
|
+
* {@link isSerializable}). A passive `PanelInfo.serializable` flag alone isn't enough for this:
|
|
934
|
+
* nobody may be polling it at the exact moment a save happens and something silently drops out
|
|
935
|
+
* (e.g. a floating window rendering data from a live class instance). This is deliberately just
|
|
936
|
+
* a signal, not a UI opinion — decide for yourself whether that becomes a toast, a console
|
|
937
|
+
* warning, or nothing.
|
|
938
|
+
*/
|
|
939
|
+
'layout:panels-excluded': {
|
|
940
|
+
panels: {
|
|
941
|
+
id: string;
|
|
942
|
+
component: string;
|
|
943
|
+
}[];
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
/** Per-panel definition supplied to `createWorkspace({ panels })`. */
|
|
947
|
+
interface PanelDefinition {
|
|
948
|
+
component: ComponentType<any>;
|
|
949
|
+
defaultOptions?: PanelRegistryEntry['defaultOptions'];
|
|
950
|
+
}
|
|
951
|
+
/** Configuration object accepted by `createWorkspace()`. */
|
|
952
|
+
interface WorkspaceClientConfig {
|
|
953
|
+
/**
|
|
954
|
+
* Declarative panel catalog. Replaces imperative globalPanelRegistry.register() calls.
|
|
955
|
+
* Keys are the component identifiers used in openPanel() and serialised layouts.
|
|
956
|
+
*/
|
|
957
|
+
panels?: Record<string, PanelDefinition>;
|
|
958
|
+
/**
|
|
959
|
+
* Serialised layout produced by a previous saveLayout() call.
|
|
960
|
+
* Pass null or omit to start with an empty canvas.
|
|
961
|
+
*
|
|
962
|
+
* Parsed synchronously before the first render. The restored `activePanelId` is the one the
|
|
963
|
+
* snapshot recorded, or — for layouts saved before that was persisted — the selected tab of
|
|
964
|
+
* the first leaf in the grid.
|
|
965
|
+
*/
|
|
966
|
+
initialState?: string | null;
|
|
967
|
+
/** Custom i18n formatter for all internal strings. */
|
|
968
|
+
formatMessage?: MessageFormatter;
|
|
969
|
+
/** Override any subset of the built-in predefined message catalog. */
|
|
970
|
+
predefinedMessages?: Record<string, MessageDescriptor>;
|
|
971
|
+
/** Initial layout direction. */
|
|
972
|
+
dir?: 'ltr' | 'rtl';
|
|
973
|
+
/**
|
|
974
|
+
* Fraction of the target panel the new panel takes when dropped on a panel's
|
|
975
|
+
* top/bottom/left/right cross target. Range 0.1–0.9. Default: 0.5.
|
|
976
|
+
*/
|
|
977
|
+
defaultSplitRatio?: number;
|
|
978
|
+
/**
|
|
979
|
+
* Fraction of the workspace the new panel takes when dropped on the workspace
|
|
980
|
+
* outer edge. Range 0.1–0.9. Default: 0.2.
|
|
981
|
+
*/
|
|
982
|
+
defaultEdgeSplitRatio?: number;
|
|
983
|
+
/**
|
|
984
|
+
* Starting z-index for floating windows and the library's own chrome overlays
|
|
985
|
+
* (context menu, toolbar flyout, modal stack, toast, workspace edge zones),
|
|
986
|
+
* all of which shift together via `--rdd-z-base`. Set this above/below a host
|
|
987
|
+
* app's own modal z-index range to control stacking against it. Default: 1000.
|
|
1266
988
|
*/
|
|
1267
|
-
|
|
989
|
+
zIndexBase?: number;
|
|
1268
990
|
}
|
|
1269
991
|
/**
|
|
1270
|
-
*
|
|
1271
|
-
*
|
|
1272
|
-
* `
|
|
1273
|
-
* `showContextMenu()` and `useShowContextMenu()` work from any component in the tree —
|
|
1274
|
-
* including siblings of `<WindowManager>` such as `<Sidebar>`, `<SidePanelRenderer>`,
|
|
1275
|
-
* and `<ModalStackRenderer>`.
|
|
992
|
+
* A workspace: the layout, every action on it, the panel registry and the event bus. Create one
|
|
993
|
+
* with `createWorkspace()` outside the React tree and pass it to
|
|
994
|
+
* `<DockableDesktopProvider workspace={…}>`; inside the tree, `useWorkspace()` returns it.
|
|
1276
995
|
*
|
|
1277
|
-
*
|
|
996
|
+
* Pattern: TanStack QueryClient / Redux store — configuration and imperative access live on the
|
|
997
|
+
* workspace; rendering is delegated to the thin React provider.
|
|
1278
998
|
*
|
|
1279
|
-
*
|
|
1280
|
-
*
|
|
999
|
+
* @remarks
|
|
1000
|
+
* The workspace is live from the moment it is created: calls made before any provider mounts
|
|
1001
|
+
* apply immediately, and a provider that mounts later shows the result.
|
|
1281
1002
|
*
|
|
1282
1003
|
* @example
|
|
1283
|
-
*
|
|
1284
|
-
*
|
|
1285
|
-
*
|
|
1286
|
-
*
|
|
1287
|
-
*
|
|
1288
|
-
*
|
|
1289
|
-
*
|
|
1290
|
-
* </DockableDesktopProvider>
|
|
1291
|
-
* ```
|
|
1292
|
-
*/
|
|
1293
|
-
declare const DockableDesktopProvider: React$1.FC<DockableDesktopProviderProps>;
|
|
1294
|
-
|
|
1295
|
-
/**
|
|
1296
|
-
* Recursively checks whether a value can round-trip through `JSON.stringify`/`JSON.parse`
|
|
1297
|
-
* without silently losing information.
|
|
1298
|
-
*
|
|
1299
|
-
* Deliberately **not** a `JSON.stringify` try/catch — that call doesn't throw for the actual
|
|
1300
|
-
* failure case this guards against: a function-valued property is simply dropped by
|
|
1301
|
-
* `JSON.stringify`, not rejected. This walks the value tree instead, returning `false` as soon as
|
|
1302
|
-
* it finds a function, symbol, `undefined`, React element, or any non-plain object (a class
|
|
1303
|
-
* instance, `Map`, `Set`, `RegExp`, etc.).
|
|
1004
|
+
* const workspace = createWorkspace<MyEvents>({
|
|
1005
|
+
* panels: {
|
|
1006
|
+
* map: { component: MapPanel },
|
|
1007
|
+
* editor: { component: EditorPanel, defaultOptions: { title: 'Code Editor' } },
|
|
1008
|
+
* },
|
|
1009
|
+
* initialState: localStorage.getItem('layout'),
|
|
1010
|
+
* });
|
|
1304
1011
|
*
|
|
1305
|
-
*
|
|
1306
|
-
*
|
|
1307
|
-
*
|
|
1308
|
-
* than treated as a disqualifying case.
|
|
1012
|
+
* <DockableDesktopProvider workspace={workspace}>
|
|
1013
|
+
* <RddDesktop />
|
|
1014
|
+
* </DockableDesktopProvider>
|
|
1309
1015
|
*
|
|
1310
|
-
*
|
|
1311
|
-
*
|
|
1016
|
+
* // Imperative access from anywhere:
|
|
1017
|
+
* workspace.saveLayout();
|
|
1018
|
+
* workspace.openPanel('map-1', 'map');
|
|
1019
|
+
* workspace.focusPanel('map-1');
|
|
1312
1020
|
*/
|
|
1313
|
-
declare
|
|
1021
|
+
declare class WorkspaceClient<TUserEvents extends object = Record<string, unknown>> {
|
|
1022
|
+
/** Scoped panel registry — fully independent from the global singleton. */
|
|
1023
|
+
readonly registry: PanelRegistry;
|
|
1024
|
+
/** Serialised layout to restore on mount, or null to start with an empty canvas. */
|
|
1025
|
+
readonly initialState: string | null;
|
|
1026
|
+
/** Non-rendering configuration forwarded to the provider. */
|
|
1027
|
+
readonly config: Pick<WorkspaceClientConfig, 'formatMessage' | 'predefinedMessages' | 'dir' | 'defaultSplitRatio' | 'defaultEdgeSplitRatio' | 'zIndexBase'>;
|
|
1028
|
+
/** @internal The workspace store. Live from construction; a provider only subscribes to it. */
|
|
1029
|
+
readonly _core: WorkspaceCore;
|
|
1030
|
+
/** The store's actions, to which every method below forwards. */
|
|
1031
|
+
private get _actions();
|
|
1032
|
+
constructor(config?: WorkspaceClientConfig);
|
|
1033
|
+
private _dispatch;
|
|
1034
|
+
private _subscribeRaw;
|
|
1035
|
+
openPanel(...args: Parameters<WorkspaceActions['openPanel']>): void;
|
|
1036
|
+
closePanel(id: string): void;
|
|
1037
|
+
minimizePanel(id: string): void;
|
|
1038
|
+
restorePanel(...args: Parameters<WorkspaceActions['restorePanel']>): void;
|
|
1039
|
+
floatPanel(...args: Parameters<WorkspaceActions['floatPanel']>): void;
|
|
1040
|
+
dockPanel(...args: Parameters<WorkspaceActions['dockPanel']>): void;
|
|
1041
|
+
maximizePanel(id: string): void;
|
|
1042
|
+
/**
|
|
1043
|
+
* Activates the given panel regardless of its current state.
|
|
1044
|
+
* For floating panels: raises z-index so the window appears on top.
|
|
1045
|
+
* For docked panels: selects the tab within its leaf group.
|
|
1046
|
+
*/
|
|
1047
|
+
focusPanel(id: string): void;
|
|
1048
|
+
/** Returns `true` if a panel with this ID is currently open. */
|
|
1049
|
+
isOpen(id: string): boolean;
|
|
1050
|
+
/** Returns the IDs of all currently open panels. */
|
|
1051
|
+
getOpenPanelIds(): string[];
|
|
1052
|
+
/** Finds an already-open panel of the given component with a matching `dedupeKey` (set via
|
|
1053
|
+
* `openPanel`'s `dedupeKey` option). Returns `null` if none is open. */
|
|
1054
|
+
findPanelId(component: string, dedupeKey: string): string | null;
|
|
1055
|
+
saveLayout(): string;
|
|
1056
|
+
loadLayout(json: string): boolean;
|
|
1057
|
+
setDirection(dir: 'ltr' | 'rtl'): void;
|
|
1058
|
+
/** Updates the split-size fractions at the given grid path. */
|
|
1059
|
+
updateSplitSizes(path: number[], sizes: number[]): void;
|
|
1060
|
+
/** Updates position/size/anchor of a floating panel. */
|
|
1061
|
+
updateFloatingPosition(id: string, updates: Partial<Pick<FloatingWindow, 'x' | 'y' | 'width' | 'height' | 'anchor'>>): void;
|
|
1062
|
+
/** @internal Drives the drag-in-progress visual state; normally only the library's own drag UI calls this. */
|
|
1063
|
+
setDraggedPanelId(id: string | null): void;
|
|
1064
|
+
/** Docks a panel into an existing leaf group at the given drop position. */
|
|
1065
|
+
dockPanelToGroup(id: string, targetLeafId: string, position: DropPosition): void;
|
|
1066
|
+
/** Reorders a panel's tab within its leaf group. */
|
|
1067
|
+
movePanelOrder(panelId: string, targetLeafId: string, targetIndex: number): void;
|
|
1068
|
+
/**
|
|
1069
|
+
* Closes a leaf group: each of its tabs is closed through the guarded close path, then the
|
|
1070
|
+
* group is removed once empty. A tab whose close guard refuses — or a dirty tab that
|
|
1071
|
+
* `onConfirm` doesn't approve — stays open, and so does its group.
|
|
1072
|
+
* Resolves once every close request has been settled.
|
|
1073
|
+
*/
|
|
1074
|
+
closeLeafGroup(leafId: string, options?: {
|
|
1075
|
+
onConfirm?: (opts?: DirtyStateOptions) => Promise<boolean>;
|
|
1076
|
+
}): Promise<void>;
|
|
1077
|
+
/** Registers a guard that can veto closing the given panel. */
|
|
1078
|
+
registerCloseGuard(id: string, guard: () => boolean | Promise<boolean>): void;
|
|
1079
|
+
/** Removes a previously registered close guard. */
|
|
1080
|
+
unregisterCloseGuard(id: string): void;
|
|
1081
|
+
/** Registers a callback reporting a panel's current restorable state, pulled fresh on every
|
|
1082
|
+
* `saveLayout()` call — see {@link BuiltInEvents}'s `'layout:panels-excluded'` doc and
|
|
1083
|
+
* `FormContainerContract.registerStateProvider`. */
|
|
1084
|
+
registerStateProvider(id: string, provider: () => unknown): void;
|
|
1085
|
+
/** Removes a previously registered state provider. */
|
|
1086
|
+
unregisterStateProvider(id: string): void;
|
|
1087
|
+
/** Sets/clears a panel's dirty (unsaved changes) flag. */
|
|
1088
|
+
setPanelDirty(id: string, dirty: boolean, options?: DirtyStateOptions): void;
|
|
1089
|
+
/** Updates a panel's displayed title. */
|
|
1090
|
+
updatePanelTitle(id: string, title: string | MessageDescriptor): void;
|
|
1091
|
+
/**
|
|
1092
|
+
* Requests that a panel close, honoring its dirty flag and any registered close guard.
|
|
1093
|
+
* Resolves once the close (or user cancellation) has been resolved.
|
|
1094
|
+
*/
|
|
1095
|
+
requestClosePanel(id: string, options?: {
|
|
1096
|
+
force?: boolean;
|
|
1097
|
+
onConfirm?: (opts?: DirtyStateOptions) => Promise<boolean>;
|
|
1098
|
+
}): Promise<void>;
|
|
1099
|
+
/** Docks a panel to one of the workspace's outer edges. */
|
|
1100
|
+
dockPanelToWorkspaceEdge(id: string, position: SplitDirection): void;
|
|
1101
|
+
/** Shows a context menu using the app's configured ContextMenuAdapter. */
|
|
1102
|
+
showContextMenu(options: ShowContextMenuOptions): void;
|
|
1103
|
+
publish<K extends keyof (TUserEvents & BuiltInEvents)>(event: K, data: (TUserEvents & BuiltInEvents)[K]): void;
|
|
1104
|
+
subscribe<K extends keyof (TUserEvents & BuiltInEvents)>(event: K, callback: (data: (TUserEvents & BuiltInEvents)[K]) => void): () => void;
|
|
1105
|
+
/** Subscribe to panel open events. Fires only for newly created panels. */
|
|
1106
|
+
onPanelOpen(callback: (id: string, component: string) => void): () => void;
|
|
1107
|
+
/** Subscribe to panel close events. */
|
|
1108
|
+
onPanelClose(callback: (id: string) => void): () => void;
|
|
1109
|
+
/** Subscribe to panel minimize events. */
|
|
1110
|
+
onPanelMinimize(callback: (id: string) => void): () => void;
|
|
1111
|
+
/** Subscribe to panel restore events. */
|
|
1112
|
+
onPanelRestore(callback: (id: string) => void): () => void;
|
|
1113
|
+
/** Subscribe to the coalesced layout-change signal — see {@link BuiltInEvents}'s
|
|
1114
|
+
* `'layout:changed'` doc for exactly what it covers (and doesn't). */
|
|
1115
|
+
onLayoutChanged(callback: () => void): () => void;
|
|
1116
|
+
/** Subscribe to notification that a `saveLayout()` call excluded one or more panels because
|
|
1117
|
+
* their current props weren't serializable — see {@link BuiltInEvents}'s
|
|
1118
|
+
* `'layout:panels-excluded'` doc. */
|
|
1119
|
+
onPanelsExcluded(callback: (panels: {
|
|
1120
|
+
id: string;
|
|
1121
|
+
component: string;
|
|
1122
|
+
}[]) => void): () => void;
|
|
1123
|
+
}
|
|
1314
1124
|
|
|
1315
1125
|
/**
|
|
1316
1126
|
* Options used when requesting to close a container.
|
|
@@ -1322,88 +1132,7 @@ interface CloseOptions {
|
|
|
1322
1132
|
/** Represents the type of container context a panel/form is currently rendered inside. */
|
|
1323
1133
|
type ContainerType = 'left-panel' | 'right-panel' | 'modal' | 'dockable-panel' | 'floating-window' | 'standalone';
|
|
1324
1134
|
/**
|
|
1325
|
-
*
|
|
1326
|
-
* to its children forms, enabling them to control or listen to container events.
|
|
1327
|
-
*/
|
|
1328
|
-
interface FormContainerContract {
|
|
1329
|
-
/** Request the container to close itself. Bypassed by default unless options.force is true. */
|
|
1330
|
-
requestClose: (options?: CloseOptions) => void;
|
|
1331
|
-
/** Mark the form's content as dirty (having unsaved changes), triggering alert dialogs on close. */
|
|
1332
|
-
setDirty: (dirty: boolean, options?: DirtyStateOptions) => void;
|
|
1333
|
-
/** Register a custom close guard handler. Returning false or a promise resolving to false blocks closing. */
|
|
1334
|
-
onCloseRequested: (handler: () => boolean | Promise<boolean>) => (() => void);
|
|
1335
|
-
/**
|
|
1336
|
-
* Registers a callback reporting this panel's *current* restorable state, pulled fresh by
|
|
1337
|
-
* `WorkspaceClient.saveLayout()` every time it's called — for panels whose static open-time
|
|
1338
|
-
* props can't capture state accumulated after opening (scroll position, an in-progress edit, a
|
|
1339
|
-
* view-mode toggle). Only meaningful for docked/floating panels — left/right side panels and
|
|
1340
|
-
* modals already have a complete answer to this via `openLeftPanel`/`openRightPanel`/
|
|
1341
|
-
* `openModal`'s own `props` argument plus `updateInstance`, so this is `undefined` there.
|
|
1342
|
-
* The returned value must be synchronous — `saveLayout()` itself never returns a `Promise`.
|
|
1343
|
-
* Return `undefined` to fall back to the static `props` this panel was opened with.
|
|
1344
|
-
*/
|
|
1345
|
-
registerStateProvider?: (getState: () => unknown) => (() => void);
|
|
1346
|
-
/** Change the display title of the containing tab or window dynamically. */
|
|
1347
|
-
setTitle: (title: string | {
|
|
1348
|
-
id: string;
|
|
1349
|
-
defaultMessage: string;
|
|
1350
|
-
values?: Record<string, any>;
|
|
1351
|
-
}) => void;
|
|
1352
|
-
/** Change the tab or window icon dynamically. */
|
|
1353
|
-
setIcon?: (icon: React.ReactNode) => void;
|
|
1354
|
-
/** The type of container the panel is mounted in. Reflects the state at mount time; subscribe to {@link onContainerTypeChange} for live updates. */
|
|
1355
|
-
containerType?: ContainerType;
|
|
1356
|
-
/** Unique identifier of the panel or window instance. */
|
|
1357
|
-
instanceId: string;
|
|
1358
|
-
/** Subscribe to the container's close event. Returns an unsubscribe function. */
|
|
1359
|
-
onClose?: (handler: () => void) => () => void;
|
|
1360
|
-
/** Subscribe to the container's minimize event. Returns an unsubscribe function. */
|
|
1361
|
-
onMinimize?: (handler: () => void) => () => void;
|
|
1362
|
-
/** Subscribe to the container's restore event. Returns an unsubscribe function. */
|
|
1363
|
-
onRestore?: (handler: () => void) => () => void;
|
|
1364
|
-
/** Subscribe to the container's window resize event, returning width and height. Returns an unsubscribe function. */
|
|
1365
|
-
onResize?: (handler: (width: number, height: number) => void) => () => void;
|
|
1366
|
-
/** Request the container to minimize itself to the taskbar. No-op if the container type does not support minimize. */
|
|
1367
|
-
requestMinimize?: () => void;
|
|
1368
|
-
/** Returns the current rendered dimensions of this panel, or `null` if the panel has not been laid out yet. */
|
|
1369
|
-
getDimensions?: () => {
|
|
1370
|
-
width: number;
|
|
1371
|
-
height: number;
|
|
1372
|
-
} | null;
|
|
1373
|
-
/**
|
|
1374
|
-
* Subscribe to this panel becoming the globally active panel.
|
|
1375
|
-
* Fires when `activePanelId` transitions to this panel's id.
|
|
1376
|
-
* Returns an unsubscribe function.
|
|
1377
|
-
*/
|
|
1378
|
-
onActivate?: (handler: () => void) => () => void;
|
|
1379
|
-
/**
|
|
1380
|
-
* Subscribe to this panel losing active status.
|
|
1381
|
-
* Fires when `activePanelId` transitions away from this panel's id,
|
|
1382
|
-
* and also fires if the panel is destroyed while it is active.
|
|
1383
|
-
* Returns an unsubscribe function.
|
|
1384
|
-
*/
|
|
1385
|
-
onDeactivate?: (handler: () => void) => () => void;
|
|
1386
|
-
/**
|
|
1387
|
-
* Subscribe to changes in the panel's container type (e.g. docked ↔ floating).
|
|
1388
|
-
* Does not fire for minimize/restore cycles — use {@link onMinimize} / {@link onRestore} for those.
|
|
1389
|
-
* Returns an unsubscribe function.
|
|
1390
|
-
*/
|
|
1391
|
-
onContainerTypeChange?: (handler: (type: ContainerType) => void) => () => void;
|
|
1392
|
-
}
|
|
1393
|
-
/**
|
|
1394
|
-
* Context that supplies the {@link FormContainerContract} to panels inside the Window Manager.
|
|
1395
|
-
*/
|
|
1396
|
-
declare const FormContainerContext: Context<FormContainerContract>;
|
|
1397
|
-
declare const FormContainerProvider: Provider<FormContainerContract>;
|
|
1398
|
-
/**
|
|
1399
|
-
* React hook to retrieve the current {@link FormContainerContract} from context.
|
|
1400
|
-
* Enables sub-forms to trigger close/minimize requests, mark themselves dirty,
|
|
1401
|
-
* rename their tabs, query dimensions, or subscribe to lifecycle events
|
|
1402
|
-
* (resize, close, minimize, restore, activate, deactivate, container-type changes).
|
|
1403
|
-
*/
|
|
1404
|
-
declare const useFormContainer: () => FormContainerContract;
|
|
1405
|
-
/**
|
|
1406
|
-
* Reactive alternative to calling {@link FormContainerContract.getDimensions} yourself.
|
|
1135
|
+
* Reactive alternative to measuring the panel's container yourself.
|
|
1407
1136
|
* Returns the panel's current `{ width, height }`, or `null` before it has been laid
|
|
1408
1137
|
* out, and re-renders whenever the panel's rendered box changes — including resizes
|
|
1409
1138
|
* caused by the workspace itself (a grid split being dragged, docking, floating, or
|
|
@@ -1415,7 +1144,7 @@ declare const usePanelSize: () => {
|
|
|
1415
1144
|
} | null;
|
|
1416
1145
|
|
|
1417
1146
|
/** Unique string identifier for panel/modal instances. */
|
|
1418
|
-
type
|
|
1147
|
+
type OverlayId = string;
|
|
1419
1148
|
/**
|
|
1420
1149
|
* Descriptor object for localizable panel titles, supporting context translation systems.
|
|
1421
1150
|
*/
|
|
@@ -1464,9 +1193,9 @@ interface ModalOptions {
|
|
|
1464
1193
|
/**
|
|
1465
1194
|
* Represents a rendered instance of a panel or modal in the layout.
|
|
1466
1195
|
*/
|
|
1467
|
-
interface
|
|
1196
|
+
interface OverlayInstance {
|
|
1468
1197
|
/** Unique ID generated for this instance. */
|
|
1469
|
-
id:
|
|
1198
|
+
id: OverlayId;
|
|
1470
1199
|
/** React Component to mount inside the panel. */
|
|
1471
1200
|
Component: ComponentType<any>;
|
|
1472
1201
|
/** Property props passed to the Component. */
|
|
@@ -1481,89 +1210,295 @@ interface PanelInstance {
|
|
|
1481
1210
|
dirtyOptions?: DirtyStateOptions;
|
|
1482
1211
|
}
|
|
1483
1212
|
/** Stores the active layout structures for floating overlays. */
|
|
1484
|
-
interface
|
|
1213
|
+
interface OverlayState {
|
|
1485
1214
|
/** The currently open left drawer panel instance, or null. */
|
|
1486
|
-
leftPanel:
|
|
1215
|
+
leftPanel: OverlayInstance | null;
|
|
1487
1216
|
/** The currently open right drawer panel instance, or null. */
|
|
1488
|
-
rightPanel:
|
|
1217
|
+
rightPanel: OverlayInstance | null;
|
|
1489
1218
|
/** Stack containing all active floating modal instances. */
|
|
1490
|
-
modals:
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
closeAllModals: () => void;
|
|
1506
|
-
/** Retrieves metadata for an active instance by ID. */
|
|
1507
|
-
getInstance: (id: PanelInstanceId) => PanelInstance | undefined;
|
|
1508
|
-
/** Updates the props, configuration options, or dirty flag of an active panel. */
|
|
1509
|
-
updateInstance: (id: PanelInstanceId, updates: Partial<Pick<PanelInstance, 'props' | 'options' | 'dirty' | 'dirtyOptions'>>) => void;
|
|
1510
|
-
/** Flags an instance as dirty (contains unsaved changes). */
|
|
1511
|
-
setDirty: (id: PanelInstanceId, dirty: boolean, options?: DirtyStateOptions) => void;
|
|
1512
|
-
/** Subscribes a custom close confirmation intercept handler. */
|
|
1513
|
-
registerCloseHandler: (id: PanelInstanceId, handler: () => Promise<boolean>) => void;
|
|
1514
|
-
/** Unsubscribes close confirmation handler. */
|
|
1515
|
-
unregisterCloseHandler: (id: PanelInstanceId) => void;
|
|
1219
|
+
modals: OverlayInstance[];
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
/**
|
|
1223
|
+
* The 7.0 public API layer: `createWorkspace()`, the hooks a panel or an app component uses, and
|
|
1224
|
+
* the two components that replace several 6.x ones (`RddSidePanels`, `RddContextMenu`).
|
|
1225
|
+
*
|
|
1226
|
+
* Everything here is built on the library's internal modules; `src/index.ts` exports it together
|
|
1227
|
+
* with the internal components under their 7.0 names.
|
|
1228
|
+
*/
|
|
1229
|
+
|
|
1230
|
+
/** Configuration for {@link createWorkspace}. */
|
|
1231
|
+
interface WorkspaceConfig extends Omit<WorkspaceClientConfig, 'predefinedMessages'> {
|
|
1232
|
+
/** Overrides any subset of the built-in message table. */
|
|
1233
|
+
messages?: Record<string, MessageDescriptor>;
|
|
1516
1234
|
}
|
|
1517
1235
|
/**
|
|
1518
|
-
*
|
|
1519
|
-
*
|
|
1236
|
+
* A workspace: the layout, every action on it, the panel registry and the event bus. It is live
|
|
1237
|
+
* from the moment it is created — calls made before any `<DockableDesktopProvider>` mounts apply
|
|
1238
|
+
* immediately.
|
|
1520
1239
|
*/
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
}>;
|
|
1240
|
+
interface Workspace<TEvents extends object = Record<string, unknown>> extends WorkspaceClient<TEvents> {
|
|
1241
|
+
}
|
|
1524
1242
|
/**
|
|
1525
|
-
*
|
|
1526
|
-
*
|
|
1243
|
+
* Creates a workspace. Pass it to `<DockableDesktopProvider workspace={…}>`.
|
|
1244
|
+
*
|
|
1245
|
+
* @example
|
|
1246
|
+
* ```ts
|
|
1247
|
+
* interface AppEvents { 'layer:select': { layerId: string } }
|
|
1248
|
+
* export const workspace = createWorkspace<AppEvents>({
|
|
1249
|
+
* panels: { map: { component: MapPanel } },
|
|
1250
|
+
* initialState: localStorage.getItem('layout'),
|
|
1251
|
+
* });
|
|
1252
|
+
* ```
|
|
1527
1253
|
*/
|
|
1528
|
-
declare
|
|
1254
|
+
declare function createWorkspace<TEvents extends object = Record<string, unknown>>(config?: WorkspaceConfig): Workspace<TEvents>;
|
|
1529
1255
|
/**
|
|
1530
|
-
*
|
|
1531
|
-
*
|
|
1256
|
+
* The workspace of the nearest `<DockableDesktopProvider>`. A stable object: it never changes, so
|
|
1257
|
+
* a component that only calls actions never re-renders because of it.
|
|
1532
1258
|
*/
|
|
1533
|
-
declare
|
|
1534
|
-
|
|
1259
|
+
declare function useWorkspace<TEvents extends object = Record<string, unknown>>(): Workspace<TEvents>;
|
|
1260
|
+
/** The state of a workspace panel: where it is. */
|
|
1261
|
+
type PanelState = PanelInfo['state'];
|
|
1535
1262
|
/**
|
|
1536
|
-
*
|
|
1537
|
-
*
|
|
1263
|
+
* What a panel component knows about, and can do to, its own container. See {@link usePanel}.
|
|
1264
|
+
*
|
|
1265
|
+
* **Identity.** `id` and the five functions (`close`, `minimize`, `setDirty`, `setTitle`,
|
|
1266
|
+
* `setIcon`) never change identity for the panel's lifetime. The handle object itself changes
|
|
1267
|
+
* when `containerType`, `isActive`, `isMinimized` or `isFloating` does. So don't list the handle
|
|
1268
|
+
* in a dependency array: depend on the function you call, or on the values you write.
|
|
1538
1269
|
*/
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1270
|
+
interface PanelHandle {
|
|
1271
|
+
/** This panel's instance id. */
|
|
1272
|
+
id: string;
|
|
1273
|
+
/** Where it is rendered. Updates live (a docked panel that is floated re-renders as `'floating-window'`). */
|
|
1274
|
+
containerType: ContainerType;
|
|
1275
|
+
/** A workspace panel that is the globally active one. Always false in a modal or drawer. */
|
|
1276
|
+
isActive: boolean;
|
|
1277
|
+
/** A workspace panel that is minimized to the taskbar. */
|
|
1278
|
+
isMinimized: boolean;
|
|
1279
|
+
/** A workspace panel shown as a floating window. */
|
|
1280
|
+
isFloating: boolean;
|
|
1281
|
+
/** Asks the container to close, honouring close guards and the dirty flag. */
|
|
1282
|
+
close: (options?: CloseOptions) => void;
|
|
1283
|
+
/** Minimizes a workspace panel. No effect in a modal or drawer. */
|
|
1284
|
+
minimize: () => void;
|
|
1285
|
+
/** Marks the panel as having unsaved changes. */
|
|
1286
|
+
setDirty: (dirty: boolean, options?: DirtyStateOptions) => void;
|
|
1287
|
+
/** Changes the title shown on the tab, window or modal. */
|
|
1288
|
+
setTitle: (title: string | MessageDescriptor) => void;
|
|
1542
1289
|
/**
|
|
1543
|
-
*
|
|
1544
|
-
*
|
|
1545
|
-
*
|
|
1290
|
+
* Changes the icon shown in a modal's or drawer's header. A docked or floating panel shows the
|
|
1291
|
+
* icon from its registration (`defaultOptions.icon`); there this does nothing, and warns once in
|
|
1292
|
+
* development.
|
|
1546
1293
|
*/
|
|
1294
|
+
setIcon: (icon: React$1.ReactNode) => void;
|
|
1295
|
+
}
|
|
1296
|
+
/**
|
|
1297
|
+
* The panel's own container: its id, where it is, and what it can do. Works in docked panels,
|
|
1298
|
+
* floating windows, modals and side drawers.
|
|
1299
|
+
*
|
|
1300
|
+
* The functions on the handle are stable; the handle object is not (see {@link PanelHandle}).
|
|
1301
|
+
* To keep the tab title in step with a document:
|
|
1302
|
+
*
|
|
1303
|
+
* ```tsx
|
|
1304
|
+
* const { setTitle, setDirty } = usePanel();
|
|
1305
|
+
* useEffect(() => { setTitle(doc.title); setDirty(doc.dirty); }, [setTitle, setDirty, doc.title, doc.dirty]);
|
|
1306
|
+
* ```
|
|
1307
|
+
*/
|
|
1308
|
+
declare function usePanel(): PanelHandle;
|
|
1309
|
+
/** Lifecycle callbacks for {@link usePanelEvents}. Each is called at the moment it describes. */
|
|
1310
|
+
interface PanelEvents {
|
|
1311
|
+
onActivate?: () => void;
|
|
1312
|
+
onDeactivate?: () => void;
|
|
1313
|
+
onMinimize?: () => void;
|
|
1314
|
+
onRestore?: () => void;
|
|
1315
|
+
onClose?: () => void;
|
|
1316
|
+
onResize?: (width: number, height: number) => void;
|
|
1317
|
+
onContainerTypeChange?: (type: ContainerType) => void;
|
|
1318
|
+
}
|
|
1319
|
+
/**
|
|
1320
|
+
* Subscribes to the panel's lifecycle. Call it at the top level of the panel component; it always
|
|
1321
|
+
* calls the latest callbacks passed in and cleans up on unmount — no dependency array.
|
|
1322
|
+
*/
|
|
1323
|
+
declare function usePanelEvents(events: PanelEvents): void;
|
|
1324
|
+
/**
|
|
1325
|
+
* Registers a close guard: resolve `false` to keep the panel open (ask the user, save first, …).
|
|
1326
|
+
* Pass `null` to register none. Always calls the latest guard passed in.
|
|
1327
|
+
*/
|
|
1328
|
+
declare function useBeforeClose(guard: (() => boolean | Promise<boolean>) | null): void;
|
|
1329
|
+
/**
|
|
1330
|
+
* Reports the panel's restorable state, pulled fresh on every `saveLayout()` and saved as the
|
|
1331
|
+
* panel's props. Pass `null` to report none. Always calls the latest function passed in.
|
|
1332
|
+
*/
|
|
1333
|
+
declare function useSaveState(getState: (() => unknown) | null): void;
|
|
1334
|
+
type OverlayUpdate = Partial<Pick<OverlayInstance, 'props' | 'options' | 'dirty' | 'dirtyOptions'>>;
|
|
1335
|
+
/** Returned by {@link useModals}. */
|
|
1336
|
+
interface ModalsApi {
|
|
1337
|
+
/** Open modals, bottom to top. */
|
|
1338
|
+
stack: OverlayInstance[];
|
|
1339
|
+
/** The top modal, or null. */
|
|
1340
|
+
topmost: OverlayInstance | null;
|
|
1341
|
+
open: <P extends object>(component: React$1.ComponentType<P>, props: P, options?: ModalOptions) => OverlayId;
|
|
1342
|
+
close: (id: OverlayId) => void;
|
|
1343
|
+
closeAll: () => void;
|
|
1344
|
+
get: (id: OverlayId) => OverlayInstance | undefined;
|
|
1345
|
+
update: (id: OverlayId, updates: OverlayUpdate) => void;
|
|
1346
|
+
setDirty: (id: OverlayId, dirty: boolean, options?: DirtyStateOptions) => void;
|
|
1347
|
+
}
|
|
1348
|
+
/** Returned by {@link useSidePanels}. */
|
|
1349
|
+
interface SidePanelsApi {
|
|
1350
|
+
left: OverlayInstance | null;
|
|
1351
|
+
right: OverlayInstance | null;
|
|
1352
|
+
openLeft: <P extends object>(component: React$1.ComponentType<P>, props: P, options?: SidePanelOptions) => Promise<OverlayId | null>;
|
|
1353
|
+
openRight: <P extends object>(component: React$1.ComponentType<P>, props: P, options?: SidePanelOptions) => Promise<OverlayId | null>;
|
|
1354
|
+
close: (id: OverlayId) => void;
|
|
1355
|
+
/** Closes both drawers. */
|
|
1356
|
+
closeAll: () => void;
|
|
1357
|
+
get: (id: OverlayId) => OverlayInstance | undefined;
|
|
1358
|
+
update: (id: OverlayId, updates: OverlayUpdate) => void;
|
|
1359
|
+
setDirty: (id: OverlayId, dirty: boolean, options?: DirtyStateOptions) => void;
|
|
1360
|
+
}
|
|
1361
|
+
/** Opens and tracks modals. */
|
|
1362
|
+
declare function useModals(): ModalsApi;
|
|
1363
|
+
/** Opens and tracks the left and right side drawers. */
|
|
1364
|
+
declare function useSidePanels(): SidePanelsApi;
|
|
1365
|
+
/** Props for {@link RddSidePanels}. */
|
|
1366
|
+
interface RddSidePanelsProps {
|
|
1367
|
+
/** Render only one side's drawer. Omit to render both. */
|
|
1368
|
+
side?: 'left' | 'right';
|
|
1369
|
+
/** Width used when an `openLeft`/`openRight` call doesn't give one. Number = px. @default 400 */
|
|
1547
1370
|
defaultWidth?: number | string;
|
|
1548
1371
|
}
|
|
1372
|
+
/** Renders the side drawers opened through {@link useSidePanels}. */
|
|
1373
|
+
declare function RddSidePanels({ side, defaultWidth }: RddSidePanelsProps): React$1.ReactElement;
|
|
1374
|
+
/** Props for {@link RddContextMenu}. */
|
|
1375
|
+
type RddContextMenuProps = ContextMenuProps & {
|
|
1376
|
+
/** With children: the context-menu implementation for them. @default the built-in menu */
|
|
1377
|
+
adapter?: ContextMenuAdapter;
|
|
1378
|
+
/**
|
|
1379
|
+
* With children, `RddContextMenu` provides a context menu to them (`useContextMenu()` inside
|
|
1380
|
+
* shows it) — for a surface outside `<DockableDesktopProvider>`, or to override the menu for a
|
|
1381
|
+
* subtree. Without children, it is a single menu you drive through its `ref`.
|
|
1382
|
+
*/
|
|
1383
|
+
children?: React$1.ReactNode;
|
|
1384
|
+
};
|
|
1385
|
+
/**
|
|
1386
|
+
* A context menu. Inside `<DockableDesktopProvider>` one is already provided — use
|
|
1387
|
+
* `useContextMenu()` or `showContextMenu()` and you need no `RddContextMenu` at all.
|
|
1388
|
+
*/
|
|
1389
|
+
declare const RddContextMenu: React$1.ForwardRefExoticComponent<RddContextMenuProps & React$1.RefAttributes<ContextMenuHandle>>;
|
|
1390
|
+
|
|
1391
|
+
/** Props for `<DockableDesktopProvider>`. */
|
|
1392
|
+
interface DockableDesktopProviderProps {
|
|
1393
|
+
children: React$1.ReactNode;
|
|
1394
|
+
/**
|
|
1395
|
+
* The workspace to render, from `createWorkspace()`. Omit it and the provider creates an empty
|
|
1396
|
+
* one of its own (register panels through `useWorkspace().registry`).
|
|
1397
|
+
*/
|
|
1398
|
+
workspace?: Workspace<object>;
|
|
1399
|
+
/** Translates every built-in label. Overridden by the workspace's own `formatMessage`. */
|
|
1400
|
+
formatMessage?: MessageFormatter;
|
|
1401
|
+
/** Overrides any subset of the built-in message table. Overridden by the workspace's own `messages`. */
|
|
1402
|
+
messages?: Record<string, MessageDescriptor>;
|
|
1403
|
+
/** Initial layout direction, when the workspace doesn't set one. */
|
|
1404
|
+
dir?: 'ltr' | 'rtl';
|
|
1405
|
+
/** CSS class for the outer wrapper of every modal. */
|
|
1406
|
+
modalClass?: string;
|
|
1407
|
+
/** CSS class for the content area of every modal. */
|
|
1408
|
+
modalBodyClass?: string;
|
|
1409
|
+
/** CSS class for the outer wrapper of the side drawers. */
|
|
1410
|
+
sidePanelClass?: string;
|
|
1411
|
+
/** CSS class for the content area of the side drawers. */
|
|
1412
|
+
sidePanelBodyClass?: string;
|
|
1413
|
+
/** CSS class for the outer wrapper of floating windows. */
|
|
1414
|
+
windowClass?: string;
|
|
1415
|
+
/** CSS class for the content area of floating windows. */
|
|
1416
|
+
windowBodyClass?: string;
|
|
1417
|
+
/**
|
|
1418
|
+
* Starting z-index for floating windows and all of the library's chrome overlays, which shift
|
|
1419
|
+
* together via `--rdd-z-base`. @default 1000
|
|
1420
|
+
*/
|
|
1421
|
+
zIndexBase?: number;
|
|
1422
|
+
/** Context menu implementation. Defaults to the built-in menu. */
|
|
1423
|
+
contextMenuAdapter?: ContextMenuAdapter;
|
|
1424
|
+
}
|
|
1425
|
+
/**
|
|
1426
|
+
* The one provider. Place it above everything from this library: `<RddDesktop>`, `<RddSidebar>`,
|
|
1427
|
+
* `<RddToolbar>`, `<RddSidePanels>`, `<RddModals>`.
|
|
1428
|
+
*
|
|
1429
|
+
* @example
|
|
1430
|
+
* ```tsx
|
|
1431
|
+
* const workspace = createWorkspace({ panels: { map: { component: MapPanel } } });
|
|
1432
|
+
*
|
|
1433
|
+
* <DockableDesktopProvider workspace={workspace}>
|
|
1434
|
+
* <RddSidebar tabs={tabs}>
|
|
1435
|
+
* <RddDesktop />
|
|
1436
|
+
* </RddSidebar>
|
|
1437
|
+
* <RddSidePanels />
|
|
1438
|
+
* <RddModals />
|
|
1439
|
+
* </DockableDesktopProvider>
|
|
1440
|
+
* ```
|
|
1441
|
+
*/
|
|
1442
|
+
declare const DockableDesktopProvider: React$1.FC<DockableDesktopProviderProps>;
|
|
1443
|
+
|
|
1549
1444
|
/**
|
|
1550
|
-
*
|
|
1551
|
-
*
|
|
1445
|
+
* Recursively checks whether a value can round-trip through `JSON.stringify`/`JSON.parse`
|
|
1446
|
+
* without silently losing information.
|
|
1447
|
+
*
|
|
1448
|
+
* Deliberately **not** a `JSON.stringify` try/catch — that call doesn't throw for the actual
|
|
1449
|
+
* failure case this guards against: a function-valued property is simply dropped by
|
|
1450
|
+
* `JSON.stringify`, not rejected. This walks the value tree instead, returning `false` as soon as
|
|
1451
|
+
* it finds a function, symbol, `undefined`, React element, or any non-plain object (a class
|
|
1452
|
+
* instance, `Map`, `Set`, `RegExp`, etc.).
|
|
1453
|
+
*
|
|
1454
|
+
* `Date` is treated as an explicit exception — serializable-enough, matching `JSON.stringify`'s
|
|
1455
|
+
* own behavior — even though it doesn't round-trip back to a `Date` instance on parse. That's a
|
|
1456
|
+
* smaller, more tolerable gotcha than a silently-vanishing function, so it's documented rather
|
|
1457
|
+
* than treated as a disqualifying case.
|
|
1458
|
+
*
|
|
1459
|
+
* Used to decide whether a docked/floating panel's `props` can be included in
|
|
1460
|
+
* the workspace's `saveLayout()` output — see {@link PanelInfo.serializable}.
|
|
1552
1461
|
*/
|
|
1553
|
-
declare
|
|
1462
|
+
declare function isSerializable(value: unknown): boolean;
|
|
1463
|
+
|
|
1554
1464
|
/**
|
|
1555
|
-
*
|
|
1465
|
+
* @file WindowManager.tsx
|
|
1466
|
+
* @description Core component for react-dockable-desktop layout engine.
|
|
1467
|
+
* Renders the workspace desktop containing docked splits, tabbed panels, floated windows,
|
|
1468
|
+
* resize handles, context menus, and taskbar docks. Exposes lifecycle event listeners.
|
|
1556
1469
|
*/
|
|
1557
|
-
|
|
1470
|
+
|
|
1471
|
+
/** Controls when the minimized-panel taskbar is visible. */
|
|
1472
|
+
type TaskbarVisibility = 'always' | 'compact' | 'autohide';
|
|
1473
|
+
/** Props for `<RddDesktop>`. */
|
|
1474
|
+
interface RddDesktopProps {
|
|
1475
|
+
/** Built-in skin name or a custom skin key registered via CSS. @default 'vscode' */
|
|
1476
|
+
skin?: string;
|
|
1477
|
+
/** Fallback icon shown in panel tabs when no panel-specific icon is provided. */
|
|
1478
|
+
defaultPanelIcon?: React$1.ReactNode;
|
|
1479
|
+
/**
|
|
1480
|
+
* Controls taskbar visibility.
|
|
1481
|
+
* - `'always'` — permanent bar at the bottom
|
|
1482
|
+
* - `'compact'` — only visible when minimized panels exist
|
|
1483
|
+
* - `'autohide'` — overlay bar with 8 px peek strip (default)
|
|
1484
|
+
* @default 'autohide'
|
|
1485
|
+
*/
|
|
1486
|
+
taskbarVisibility?: TaskbarVisibility;
|
|
1487
|
+
/** Enables the library's own transitions/animations (tab hover, dock preview, etc.). Never affects the consumer's own page. @default true */
|
|
1488
|
+
animations?: boolean;
|
|
1489
|
+
}
|
|
1490
|
+
declare const WindowManager: React$1.FC<RddDesktopProps>;
|
|
1491
|
+
|
|
1558
1492
|
/**
|
|
1559
|
-
*
|
|
1493
|
+
* Renders the modals opened through `useModals()`, stacked, topmost last. Mount one, inside
|
|
1494
|
+
* `<DockableDesktopProvider>`.
|
|
1560
1495
|
*/
|
|
1561
|
-
declare const
|
|
1496
|
+
declare const ModalStackRenderer: React$1.FC;
|
|
1562
1497
|
|
|
1563
1498
|
/**
|
|
1564
|
-
* Props for the {@link
|
|
1499
|
+
* Props for the {@link RddConfirm} component.
|
|
1565
1500
|
*/
|
|
1566
|
-
interface
|
|
1501
|
+
interface RddConfirmProps {
|
|
1567
1502
|
/** Optional custom title text or localizable descriptor for the dialog container. */
|
|
1568
1503
|
title?: string | {
|
|
1569
1504
|
id: string;
|
|
@@ -1588,10 +1523,10 @@ interface ConfirmationFormProps {
|
|
|
1588
1523
|
onCancel?: () => void;
|
|
1589
1524
|
}
|
|
1590
1525
|
/**
|
|
1591
|
-
*
|
|
1526
|
+
* RddConfirm component renders a standard dialog content layout,
|
|
1592
1527
|
* allowing users to confirm actions or abort them. Exposes action callbacks.
|
|
1593
1528
|
*/
|
|
1594
|
-
declare const ConfirmationForm: React$1.FC<
|
|
1529
|
+
declare const ConfirmationForm: React$1.FC<RddConfirmProps>;
|
|
1595
1530
|
|
|
1596
1531
|
/**
|
|
1597
1532
|
* @file Sidebar.tsx
|
|
@@ -1638,11 +1573,11 @@ interface SidebarTab {
|
|
|
1638
1573
|
renderContent: (tabId: string, onClose: () => void, onOpen: () => void) => React$1.ReactNode;
|
|
1639
1574
|
}
|
|
1640
1575
|
/**
|
|
1641
|
-
* Simple case for `
|
|
1576
|
+
* Simple case for `RddSidebarProps.headerAction`/`footerAction`: the library renders a
|
|
1642
1577
|
* default-styled icon button (visually consistent with the regular tab buttons) and forwards
|
|
1643
1578
|
* the click.
|
|
1644
1579
|
*/
|
|
1645
|
-
interface
|
|
1580
|
+
interface SidebarActionButton {
|
|
1646
1581
|
/** Only needed when used inside a `SidebarRailEntry[]` array, for the React key. */
|
|
1647
1582
|
id?: string;
|
|
1648
1583
|
icon: React$1.ReactNode;
|
|
@@ -1652,12 +1587,12 @@ interface SidebarHeaderActionButton {
|
|
|
1652
1587
|
disabled?: boolean;
|
|
1653
1588
|
}
|
|
1654
1589
|
/**
|
|
1655
|
-
* Full-control case for `
|
|
1590
|
+
* Full-control case for `RddSidebarProps.headerAction`/`footerAction`: the consumer supplies their
|
|
1656
1591
|
* own markup (a Material UI `IconButton`, a Bootstrap `Button`, a Tailwind-styled `<button>`, or
|
|
1657
1592
|
* anything else) wholesale. The library renders exactly what this returns, unwrapped, so the
|
|
1658
1593
|
* consumer's own hover/active/focus/ripple behavior and click handling are untouched.
|
|
1659
1594
|
*/
|
|
1660
|
-
interface
|
|
1595
|
+
interface SidebarCustomEntry {
|
|
1661
1596
|
/** Only needed when used inside a `SidebarRailEntry[]` array, for the React key. */
|
|
1662
1597
|
id?: string;
|
|
1663
1598
|
render: () => React$1.ReactNode;
|
|
@@ -1668,15 +1603,15 @@ interface SidebarHeaderActionCustom {
|
|
|
1668
1603
|
* it and forwards the click; what happens next (opening a side panel, a modal, anything else)
|
|
1669
1604
|
* is entirely up to the consumer.
|
|
1670
1605
|
*/
|
|
1671
|
-
type SidebarHeaderAction =
|
|
1606
|
+
type SidebarHeaderAction = SidebarActionButton | SidebarCustomEntry;
|
|
1672
1607
|
/**
|
|
1673
|
-
* A single entry inside `
|
|
1608
|
+
* A single entry inside `RddSidebarProps.headerAction`/`footerAction` when used as an array: either
|
|
1674
1609
|
* a non-toggling action button/custom render (see `SidebarHeaderAction`), or a real `SidebarTab`
|
|
1675
1610
|
* that behaves exactly like a main-list tab — it mounts, activates, and closes through the same
|
|
1676
1611
|
* lifecycle, so e.g. a "Settings" entry pinned to the footer can expand like any other tab.
|
|
1677
1612
|
*/
|
|
1678
|
-
type SidebarRailEntry = SidebarTab |
|
|
1679
|
-
interface
|
|
1613
|
+
type SidebarRailEntry = SidebarTab | SidebarActionButton | SidebarCustomEntry;
|
|
1614
|
+
interface RddSidebarProps {
|
|
1680
1615
|
/** Which side the activity bar and drawer appear on. Default: 'right' */
|
|
1681
1616
|
position?: 'left' | 'right';
|
|
1682
1617
|
tabs: SidebarTab[];
|
|
@@ -1755,7 +1690,7 @@ interface SidebarProps {
|
|
|
1755
1690
|
renderHeader?: (tab: SidebarTab, onClose: () => void, onOpen: () => void) => React$1.ReactNode;
|
|
1756
1691
|
/**
|
|
1757
1692
|
* @internal Marks this instance as a secondary sidebar for context-broadcasting
|
|
1758
|
-
* purposes. Set automatically by `<
|
|
1693
|
+
* purposes. Set automatically by `<RddSecondarySidebar>` — do not pass this directly.
|
|
1759
1694
|
* Default: false
|
|
1760
1695
|
*/
|
|
1761
1696
|
isSecondary?: boolean;
|
|
@@ -1763,7 +1698,7 @@ interface SidebarProps {
|
|
|
1763
1698
|
children?: React$1.ReactNode;
|
|
1764
1699
|
}
|
|
1765
1700
|
/**
|
|
1766
|
-
* Imperative handle exposed by `<
|
|
1701
|
+
* Imperative handle exposed by `<RddSidebar ref={...}>`.
|
|
1767
1702
|
*/
|
|
1768
1703
|
interface SidebarHandle {
|
|
1769
1704
|
openTab: (tabId: string) => void;
|
|
@@ -1779,7 +1714,7 @@ interface SidebarHandle {
|
|
|
1779
1714
|
}
|
|
1780
1715
|
/**
|
|
1781
1716
|
* Value provided by `useSidebar()`. Available to any component inside the
|
|
1782
|
-
* `<
|
|
1717
|
+
* `<RddSidebar>` React tree, including panels rendered via `{children}`.
|
|
1783
1718
|
*/
|
|
1784
1719
|
interface SidebarContextValue {
|
|
1785
1720
|
openTab: (tabId: string) => void;
|
|
@@ -1787,7 +1722,7 @@ interface SidebarContextValue {
|
|
|
1787
1722
|
getActiveTab: () => string | null;
|
|
1788
1723
|
/** Which side this Sidebar instance is rendering on. */
|
|
1789
1724
|
position: 'left' | 'right';
|
|
1790
|
-
/** True if this instance is a `<
|
|
1725
|
+
/** True if this instance is a `<RddSecondarySidebar>`, false for a primary `<RddSidebar>`. */
|
|
1791
1726
|
isSecondary: boolean;
|
|
1792
1727
|
}
|
|
1793
1728
|
/**
|
|
@@ -1800,13 +1735,13 @@ interface SidebarTabContextValue {
|
|
|
1800
1735
|
onClose: () => void;
|
|
1801
1736
|
openTab: (tabId: string) => void;
|
|
1802
1737
|
}
|
|
1803
|
-
declare const Sidebar: React$1.ForwardRefExoticComponent<
|
|
1738
|
+
declare const Sidebar: React$1.ForwardRefExoticComponent<RddSidebarProps & React$1.RefAttributes<SidebarHandle>>;
|
|
1804
1739
|
/**
|
|
1805
|
-
* Props for {@link
|
|
1740
|
+
* Props for {@link RddSecondarySidebar} — identical to {@link RddSidebarProps} except
|
|
1806
1741
|
* `position` (always the opposite of whatever primary `Sidebar` it's nested inside)
|
|
1807
1742
|
* and `isSecondary` (always `true`) are not settable.
|
|
1808
1743
|
*/
|
|
1809
|
-
type
|
|
1744
|
+
type RddSecondarySidebarProps = Omit<RddSidebarProps, 'position' | 'isSecondary'>;
|
|
1810
1745
|
/**
|
|
1811
1746
|
* A second, independent `Sidebar` instance for the opposite edge of the screen —
|
|
1812
1747
|
* same component, same behavior, zero forked code. Must be rendered inside a
|
|
@@ -1814,12 +1749,12 @@ type SecondarySidebarProps = Omit<SidebarProps, 'position' | 'isSecondary'>;
|
|
|
1814
1749
|
* isn't using, so the side is never specified directly.
|
|
1815
1750
|
*
|
|
1816
1751
|
* @throws Error if rendered without an ancestor `Sidebar`, or nested inside another
|
|
1817
|
-
* `
|
|
1752
|
+
* `RddSecondarySidebar` — this library supports exactly one primary and one secondary,
|
|
1818
1753
|
* nothing deeper.
|
|
1819
1754
|
*/
|
|
1820
|
-
declare const SecondarySidebar: React$1.ForwardRefExoticComponent<
|
|
1755
|
+
declare const SecondarySidebar: React$1.ForwardRefExoticComponent<RddSecondarySidebarProps & React$1.RefAttributes<SidebarHandle>>;
|
|
1821
1756
|
/**
|
|
1822
|
-
* Returns sidebar control functions from anywhere inside a `<
|
|
1757
|
+
* Returns sidebar control functions from anywhere inside a `<RddSidebar>` tree,
|
|
1823
1758
|
* including floating panels rendered via `{children}`.
|
|
1824
1759
|
*
|
|
1825
1760
|
* @throws Error if used outside of a {@link Sidebar}.
|
|
@@ -1851,9 +1786,6 @@ interface ToolbarContextValue {
|
|
|
1851
1786
|
/** Flip a toggle modifier between active and inactive. */
|
|
1852
1787
|
toggleModifier: (id: string) => void;
|
|
1853
1788
|
}
|
|
1854
|
-
declare const ToolbarProvider: React$1.FC<{
|
|
1855
|
-
children: React$1.ReactNode;
|
|
1856
|
-
}>;
|
|
1857
1789
|
/**
|
|
1858
1790
|
* Returns toolbar state and control functions from anywhere inside
|
|
1859
1791
|
* a `<DockableDesktopProvider>` tree.
|
|
@@ -1976,7 +1908,7 @@ interface ToolbarGroupItem {
|
|
|
1976
1908
|
onActiveItemChange?: (id: string) => void;
|
|
1977
1909
|
}
|
|
1978
1910
|
type ToolbarItem$1 = ToolbarActionItem | ToolbarRadioItem | ToolbarToggleItem | ToolbarGroupItem | ToolbarSeparator$1;
|
|
1979
|
-
interface
|
|
1911
|
+
interface RddToolbarProps {
|
|
1980
1912
|
/** Side the strip is attached to. Controls strip orientation. Default: 'left' */
|
|
1981
1913
|
position?: 'left' | 'right' | 'top' | 'bottom';
|
|
1982
1914
|
/** Ordered list of items to render. */
|
|
@@ -1993,15 +1925,15 @@ interface ToolbarHandle {
|
|
|
1993
1925
|
hide(): void;
|
|
1994
1926
|
toggle(): void;
|
|
1995
1927
|
}
|
|
1996
|
-
declare const Toolbar: React$1.ForwardRefExoticComponent<
|
|
1928
|
+
declare const Toolbar: React$1.ForwardRefExoticComponent<RddToolbarProps & React$1.RefAttributes<ToolbarHandle>>;
|
|
1997
1929
|
|
|
1998
1930
|
/** Visual type of a toast notification. Determines the icon and accent color. */
|
|
1999
1931
|
type ToastType = 'info' | 'success' | 'warning' | 'error';
|
|
2000
|
-
/** Corner position of the `<
|
|
1932
|
+
/** Corner position of the `<RddToasts>` relative to the viewport. */
|
|
2001
1933
|
type ToastPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
2002
1934
|
/**
|
|
2003
1935
|
* Per-notification options passed to `toast()`, `toast.info()`, etc.
|
|
2004
|
-
* All fields are optional and fall back to `<
|
|
1936
|
+
* All fields are optional and fall back to `<RddToasts>` defaults when unset.
|
|
2005
1937
|
*/
|
|
2006
1938
|
interface ToastOptions {
|
|
2007
1939
|
/** Visual type. Overridden by the `toast.info/success/warning/error` shorthands. @default 'info' */
|
|
@@ -2033,11 +1965,11 @@ interface ResolvedToastOptions {
|
|
|
2033
1965
|
onClose?: () => void;
|
|
2034
1966
|
}
|
|
2035
1967
|
/**
|
|
2036
|
-
* Props for `<
|
|
1968
|
+
* Props for `<RddToasts>`. Mount one instance at your app root, alongside `<RddModals>`.
|
|
2037
1969
|
* @example
|
|
2038
|
-
* <
|
|
1970
|
+
* <RddToasts position="top-right" progressBar />
|
|
2039
1971
|
*/
|
|
2040
|
-
interface
|
|
1972
|
+
interface RddToastsProps {
|
|
2041
1973
|
/** Where notifications appear in the viewport. @default 'top-right' */
|
|
2042
1974
|
position?: ToastPosition;
|
|
2043
1975
|
/** Maximum number of notifications shown simultaneously. Extras are queued. @default 3 */
|
|
@@ -2074,9 +2006,9 @@ interface ToastPromiseMessages<T> {
|
|
|
2074
2006
|
}
|
|
2075
2007
|
/**
|
|
2076
2008
|
* Strategy interface for replacing the built-in toast renderer with an external library.
|
|
2077
|
-
* Pass an instance via `<
|
|
2009
|
+
* Pass an instance via `<RddToasts adapter={...} />` to redirect all `toast.*` calls
|
|
2078
2010
|
* without changing any call sites in your application.
|
|
2079
|
-
* @see
|
|
2011
|
+
* @see RddToastsProps.adapter
|
|
2080
2012
|
*/
|
|
2081
2013
|
interface ToastAdapter {
|
|
2082
2014
|
/** Called when a new notification is requested. */
|
|
@@ -2086,8 +2018,8 @@ interface ToastAdapter {
|
|
|
2086
2018
|
/** Called to dismiss one notification (`id` provided) or all active notifications (no `id`). */
|
|
2087
2019
|
dismiss(id?: string): void;
|
|
2088
2020
|
/**
|
|
2089
|
-
* `null` means the adapter manages its own DOM and `<
|
|
2090
|
-
* A component causes `<
|
|
2021
|
+
* `null` means the adapter manages its own DOM and `<RddToasts>` renders nothing.
|
|
2022
|
+
* A component causes `<RddToasts>` to portal-render it with a `position` prop.
|
|
2091
2023
|
*/
|
|
2092
2024
|
Container: React$1.ComponentType<{
|
|
2093
2025
|
position: ToastPosition;
|
|
@@ -2121,7 +2053,7 @@ interface ToastFunction {
|
|
|
2121
2053
|
}
|
|
2122
2054
|
/**
|
|
2123
2055
|
* Imperative notification singleton. Call from anywhere — inside or outside React.
|
|
2124
|
-
* Mount `<
|
|
2056
|
+
* Mount `<RddToasts>` once at your app root to activate the renderer.
|
|
2125
2057
|
* @example
|
|
2126
2058
|
* toast.success('File saved.');
|
|
2127
2059
|
* toast.error('Upload failed.', { duration: 0 }); // sticky
|
|
@@ -2132,9 +2064,9 @@ declare const toast: ToastFunction;
|
|
|
2132
2064
|
* Portal-rendered notification host. Mount once at your app root, outside the workspace
|
|
2133
2065
|
* container. All `toast.*` calls are routed here automatically via the internal event emitter.
|
|
2134
2066
|
* @example
|
|
2135
|
-
* <
|
|
2067
|
+
* <RddToasts position="top-right" progressBar />
|
|
2136
2068
|
*/
|
|
2137
|
-
declare function ToastContainer({ position, maxVisible, defaultDuration, defaultClosable, pauseOnHover, animation, newestOnTop, progressBar, width, adapter, }:
|
|
2069
|
+
declare function ToastContainer({ position, maxVisible, defaultDuration, defaultClosable, pauseOnHover, animation, newestOnTop, progressBar, width, adapter, }: RddToastsProps): React$1.ReactElement | null;
|
|
2138
2070
|
|
|
2139
2071
|
/** Edge of a panel to which a `PanelToolbar` attaches. */
|
|
2140
2072
|
type ToolbarPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
@@ -2161,10 +2093,9 @@ interface PanelFloatPlacement {
|
|
|
2161
2093
|
stretch: Stretch | null;
|
|
2162
2094
|
}
|
|
2163
2095
|
/**
|
|
2164
|
-
* Configuration for a
|
|
2165
|
-
* @see usePanelFloatingWindowManager
|
|
2096
|
+
* Configuration for a widget spawned imperatively via `useFloatingWidgets().open()`.
|
|
2166
2097
|
*/
|
|
2167
|
-
interface
|
|
2098
|
+
interface ManagedWidget {
|
|
2168
2099
|
/**
|
|
2169
2100
|
* Text shown in the window's header bar. Accepts a plain string or an i18n message descriptor.
|
|
2170
2101
|
*
|
|
@@ -2190,32 +2121,32 @@ interface ManagedWindowConfig {
|
|
|
2190
2121
|
*/
|
|
2191
2122
|
stretch?: Stretch;
|
|
2192
2123
|
}
|
|
2193
|
-
/** Props for `<
|
|
2194
|
-
interface
|
|
2124
|
+
/** Props for `<RddPanelOverlay>`. */
|
|
2125
|
+
interface RddPanelOverlayProps {
|
|
2195
2126
|
children: React$1.ReactNode;
|
|
2196
2127
|
className?: string;
|
|
2197
2128
|
style?: React$1.CSSProperties;
|
|
2198
2129
|
}
|
|
2199
2130
|
/**
|
|
2200
2131
|
* Context provider and layout root for the Panel Overlay system. Wrap your panel content
|
|
2201
|
-
* with this to enable `
|
|
2132
|
+
* with this to enable `RddPanelToolbar`, `RddFloatingWidget`, and `useFloatingWidgets`.
|
|
2202
2133
|
* @example
|
|
2203
2134
|
* function MyPanel() {
|
|
2204
2135
|
* return (
|
|
2205
|
-
* <
|
|
2206
|
-
* <
|
|
2207
|
-
* <div className="panel-body">content</div>
|
|
2208
|
-
* </
|
|
2136
|
+
* <RddPanelOverlay style={{ position: 'relative', width: '100%', height: '100%' }}>
|
|
2137
|
+
* <RddPanelToolbar position="top">...</RddPanelToolbar>
|
|
2138
|
+
* <div className="my-panel-body">content</div>
|
|
2139
|
+
* </RddPanelOverlay>
|
|
2209
2140
|
* );
|
|
2210
2141
|
* }
|
|
2211
2142
|
*/
|
|
2212
|
-
declare function PanelOverlayRoot({ children, className, style }:
|
|
2143
|
+
declare function PanelOverlayRoot({ children, className, style }: RddPanelOverlayProps): React$1.ReactElement;
|
|
2213
2144
|
/** Background style of a `PanelToolbar`. */
|
|
2214
2145
|
type ToolbarVariant = 'transparent' | 'frosted' | 'solid';
|
|
2215
2146
|
/** Visual style applied to `ToolbarButton` and `ToolbarToggle` components. */
|
|
2216
2147
|
type ButtonVariant = 'ghost' | 'soft' | 'outlined' | 'filled';
|
|
2217
|
-
/** Props for `<
|
|
2218
|
-
interface
|
|
2148
|
+
/** Props for `<RddPanelToolbar>`. */
|
|
2149
|
+
interface RddPanelToolbarProps {
|
|
2219
2150
|
/** Edge of the panel overlay to attach to. @see ToolbarPosition */
|
|
2220
2151
|
position: ToolbarPosition;
|
|
2221
2152
|
/** Background style of the toolbar strip. @default 'transparent' */
|
|
@@ -2229,18 +2160,18 @@ interface PanelToolbarProps {
|
|
|
2229
2160
|
children?: React$1.ReactNode;
|
|
2230
2161
|
}
|
|
2231
2162
|
/**
|
|
2232
|
-
* Toolbar strip that attaches to any edge of
|
|
2163
|
+
* Toolbar strip that attaches to any edge of an `RddPanelOverlay`.
|
|
2233
2164
|
* Left/right toolbars inset automatically to avoid overlapping top/bottom toolbars.
|
|
2234
2165
|
* RTL layouts are detected and handled automatically.
|
|
2235
2166
|
* @example
|
|
2236
|
-
* <
|
|
2237
|
-
* <
|
|
2238
|
-
* <
|
|
2239
|
-
* </
|
|
2240
|
-
*/
|
|
2241
|
-
declare function PanelToolbar({ position, variant, buttonVariant, buttonSize, style, className, children }:
|
|
2242
|
-
/** Props for `<
|
|
2243
|
-
interface
|
|
2167
|
+
* <RddPanelToolbar position="top" variant="frosted">
|
|
2168
|
+
* <RddToolbarButton icon={<SaveIcon />} title="Save" onClick={save} />
|
|
2169
|
+
* <RddToolbarToggle icon={<GridIcon />} title="Grid" active={grid} onToggle={() => setGrid(v => !v)} />
|
|
2170
|
+
* </RddPanelToolbar>
|
|
2171
|
+
*/
|
|
2172
|
+
declare function PanelToolbar({ position, variant, buttonVariant, buttonSize, style, className, children }: RddPanelToolbarProps): React$1.ReactElement;
|
|
2173
|
+
/** Props for `<RddToolbarButton>`. */
|
|
2174
|
+
interface RddToolbarButtonProps {
|
|
2244
2175
|
/** Button icon — typically a small SVG component. */
|
|
2245
2176
|
icon: React$1.ReactNode;
|
|
2246
2177
|
/** Click handler. */
|
|
@@ -2252,9 +2183,9 @@ interface ToolbarButtonProps {
|
|
|
2252
2183
|
variant?: ButtonVariant;
|
|
2253
2184
|
}
|
|
2254
2185
|
/** Icon button for use inside a `PanelToolbar`. */
|
|
2255
|
-
declare function ToolbarButton({ icon, onClick, disabled, title, variant }:
|
|
2256
|
-
/** Props for `<
|
|
2257
|
-
interface
|
|
2186
|
+
declare function ToolbarButton({ icon, onClick, disabled, title, variant }: RddToolbarButtonProps): React$1.ReactElement;
|
|
2187
|
+
/** Props for `<RddToolbarToggle>`. */
|
|
2188
|
+
interface RddToolbarToggleProps {
|
|
2258
2189
|
/** Button icon — typically a small SVG component. */
|
|
2259
2190
|
icon: React$1.ReactNode;
|
|
2260
2191
|
/** Whether the toggle is in the active/pressed state. Sets `aria-pressed` automatically. */
|
|
@@ -2268,7 +2199,7 @@ interface ToolbarToggleProps {
|
|
|
2268
2199
|
variant?: ButtonVariant;
|
|
2269
2200
|
}
|
|
2270
2201
|
/** Two-state icon toggle button for use inside a `PanelToolbar`. Sets `aria-pressed` automatically. */
|
|
2271
|
-
declare function ToolbarToggle({ icon, active, onToggle, disabled, title, variant }:
|
|
2202
|
+
declare function ToolbarToggle({ icon, active, onToggle, disabled, title, variant }: RddToolbarToggleProps): React$1.ReactElement;
|
|
2272
2203
|
/** Vertical (or horizontal) divider line between groups of toolbar items. */
|
|
2273
2204
|
declare function ToolbarSeparator(): React$1.ReactElement;
|
|
2274
2205
|
/** Flex-grow spacer that pushes subsequent toolbar items to the far edge. */
|
|
@@ -2281,7 +2212,7 @@ declare function ToolbarItem({ children }: {
|
|
|
2281
2212
|
declare function ToolbarCenter({ children }: {
|
|
2282
2213
|
children: React$1.ReactNode;
|
|
2283
2214
|
}): React$1.ReactElement;
|
|
2284
|
-
/** A single result item returned by `
|
|
2215
|
+
/** A single result item returned by `RddToolbarSearchProps.onSearch`. */
|
|
2285
2216
|
interface SearchResult {
|
|
2286
2217
|
/** Unique identifier for this result — passed to `onSelect`. */
|
|
2287
2218
|
id: string;
|
|
@@ -2294,8 +2225,8 @@ interface SearchResult {
|
|
|
2294
2225
|
/** Optional icon shown to the left of the label. */
|
|
2295
2226
|
icon?: React$1.ReactNode;
|
|
2296
2227
|
}
|
|
2297
|
-
/** Props for `<
|
|
2298
|
-
interface
|
|
2228
|
+
/** Props for `<RddToolbarSearch>`. */
|
|
2229
|
+
interface RddToolbarSearchProps {
|
|
2299
2230
|
/** Placeholder text shown in the expanded input field. @default the `searchPlaceholder` message ('Search…') */
|
|
2300
2231
|
placeholder?: string;
|
|
2301
2232
|
/**
|
|
@@ -2318,9 +2249,9 @@ interface ToolbarSearchInputProps {
|
|
|
2318
2249
|
* onSelect={result => workspace.focusLayer(result.id)}
|
|
2319
2250
|
* />
|
|
2320
2251
|
*/
|
|
2321
|
-
declare function ToolbarSearchInput({ placeholder, onSearch, onSelect }:
|
|
2322
|
-
/** Props for `<
|
|
2323
|
-
interface
|
|
2252
|
+
declare function ToolbarSearchInput({ placeholder, onSearch, onSelect }: RddToolbarSearchProps): React$1.ReactElement;
|
|
2253
|
+
/** Props for `<RddFloatingWidget>`. */
|
|
2254
|
+
interface RddFloatingWidgetProps {
|
|
2324
2255
|
/** Unique identifier within the panel overlay. Used for z-order and stack tracking. */
|
|
2325
2256
|
id: string;
|
|
2326
2257
|
/** Text shown in the window's header bar. Accepts a plain string or an i18n message descriptor. */
|
|
@@ -2346,7 +2277,7 @@ interface PanelFloatingWindowProps {
|
|
|
2346
2277
|
defaultStretch?: Stretch;
|
|
2347
2278
|
/**
|
|
2348
2279
|
* Controlled stretch state. When provided — **including as `null`** — the caller is the single
|
|
2349
|
-
* source of truth: gestures report through {@link
|
|
2280
|
+
* source of truth: gestures report through {@link RddFloatingWidgetProps.onPlacementChange}
|
|
2350
2281
|
* instead of updating internally, and the caller must echo the new value back. Omit entirely
|
|
2351
2282
|
* (`undefined`) for uncontrolled behaviour, matching `ToolbarToggleItem.active` and
|
|
2352
2283
|
* `Sidebar.activeTabId`.
|
|
@@ -2369,65 +2300,46 @@ interface PanelFloatingWindowProps {
|
|
|
2369
2300
|
children?: React$1.ReactNode;
|
|
2370
2301
|
}
|
|
2371
2302
|
/**
|
|
2372
|
-
*
|
|
2303
|
+
* A floating widget inside a panel — anchored within an `RddPanelOverlay`.
|
|
2373
2304
|
*
|
|
2374
2305
|
* Docks to any corner, drags free of it, and drops back onto one. Windows sharing a corner stack
|
|
2375
2306
|
* along the block axis with animated offsets. An axis can also **span the panel** instead of
|
|
2376
2307
|
* carrying a fixed size, so the window tracks the panel as it resizes — see
|
|
2377
|
-
* {@link
|
|
2308
|
+
* {@link RddFloatingWidgetProps.defaultStretch} and {@link Stretch}.
|
|
2378
2309
|
*
|
|
2379
2310
|
* Resize handles follow what is actually movable: a free-floating window is pinned by nothing and
|
|
2380
2311
|
* offers all eight, while a docked one offers only its free edges — plus both ends of any spanning
|
|
2381
2312
|
* axis, either of which releases it.
|
|
2382
2313
|
*
|
|
2383
2314
|
* @example
|
|
2384
|
-
* const
|
|
2385
|
-
* <
|
|
2315
|
+
* const [infoOpen, setInfoOpen] = useState(false);
|
|
2316
|
+
* <RddFloatingWidget
|
|
2386
2317
|
* id="layer-info" title="Layer Info"
|
|
2387
|
-
* open={
|
|
2318
|
+
* open={infoOpen} onClose={() => setInfoOpen(false)}
|
|
2388
2319
|
* defaultAnchor="top-right" defaultWidth={300} defaultHeight={200}
|
|
2389
2320
|
* >
|
|
2390
2321
|
* <LayerInfoContent />
|
|
2391
|
-
* </
|
|
2322
|
+
* </RddFloatingWidget>
|
|
2392
2323
|
*
|
|
2393
2324
|
* @example
|
|
2394
2325
|
* // A full-width status strip along the bottom, tracking the panel's width.
|
|
2395
2326
|
* // defaultHeight still applies; defaultWidth is what the inline axis returns to if released.
|
|
2396
|
-
* <
|
|
2327
|
+
* <RddFloatingWidget
|
|
2397
2328
|
* id="timeline" title="Timeline"
|
|
2398
2329
|
* open onClose={close}
|
|
2399
2330
|
* defaultAnchor="bottom-left" defaultStretch="width"
|
|
2400
2331
|
* defaultWidth={240} defaultHeight={120}
|
|
2401
2332
|
* >
|
|
2402
2333
|
* <TimelineContent />
|
|
2403
|
-
* </
|
|
2404
|
-
*/
|
|
2405
|
-
declare function PanelFloatingWindow(props: PanelFloatingWindowProps): React$1.ReactElement | null;
|
|
2406
|
-
/** Return type of `usePanelFloatingWindow`. @see usePanelFloatingWindow */
|
|
2407
|
-
interface UsePanelFloatingWindowReturn {
|
|
2408
|
-
/** Whether the floating window is currently open. */
|
|
2409
|
-
isOpen: boolean;
|
|
2410
|
-
/** Open the floating window. */
|
|
2411
|
-
open(): void;
|
|
2412
|
-
/** Close the floating window. */
|
|
2413
|
-
close(): void;
|
|
2414
|
-
}
|
|
2415
|
-
/**
|
|
2416
|
-
* Manages the open/close boolean state for a single `PanelFloatingWindow`.
|
|
2417
|
-
* Pass `isOpen` to `open`, `close` to `onClose` on the component directly.
|
|
2418
|
-
* @returns A stable `UsePanelFloatingWindowReturn` object.
|
|
2419
|
-
* @example
|
|
2420
|
-
* const info = usePanelFloatingWindow();
|
|
2421
|
-
* <PanelFloatingWindow id="info" open={info.isOpen} onClose={info.close} ... />
|
|
2334
|
+
* </RddFloatingWidget>
|
|
2422
2335
|
*/
|
|
2423
|
-
declare function
|
|
2336
|
+
declare function PanelFloatingWindow(props: RddFloatingWidgetProps): React$1.ReactElement | null;
|
|
2424
2337
|
/**
|
|
2425
|
-
*
|
|
2426
|
-
* @see usePanelFloatingWindowManager
|
|
2338
|
+
* What `useFloatingWidgets()` returns.
|
|
2427
2339
|
*/
|
|
2428
|
-
interface
|
|
2340
|
+
interface FloatingWidgetsApi {
|
|
2429
2341
|
/** Spawn or reconfigure a named window. Safe to call with an already-open ID to update config. */
|
|
2430
|
-
open(id: string, config:
|
|
2342
|
+
open(id: string, config: ManagedWidget): void;
|
|
2431
2343
|
/** Close a named window by ID. No-op if the window is not open. */
|
|
2432
2344
|
close(id: string): void;
|
|
2433
2345
|
/** Close all managed windows. */
|
|
@@ -2439,28 +2351,28 @@ interface PanelFloatingWindowManagerHandle {
|
|
|
2439
2351
|
}
|
|
2440
2352
|
/**
|
|
2441
2353
|
* Imperative hook for spawning N named floating windows at runtime from data or event handlers.
|
|
2442
|
-
* All
|
|
2443
|
-
* and accept the same placement options — including {@link
|
|
2354
|
+
* All widgets share z-ordering, drag, and corner-docking infrastructure of the `RddPanelOverlay`,
|
|
2355
|
+
* and accept the same placement options — including {@link ManagedWidget.stretch} to span an
|
|
2444
2356
|
* axis of the panel.
|
|
2445
2357
|
*
|
|
2446
|
-
* Must be called inside a **descendant** of `
|
|
2447
|
-
* @returns A stable `
|
|
2358
|
+
* Must be called inside a **descendant** of `RddPanelOverlay`, not in the component that renders it.
|
|
2359
|
+
* @returns A stable `FloatingWidgetsApi`.
|
|
2448
2360
|
* @example
|
|
2449
|
-
* const manager =
|
|
2361
|
+
* const manager = useFloatingWidgets();
|
|
2450
2362
|
* manager.open('feature-42', { title: 'Feature 42', content: <FeatureDetail id={42} />, anchor: 'top-right' });
|
|
2451
2363
|
*
|
|
2452
2364
|
* // A full-width strip along the bottom edge:
|
|
2453
2365
|
* manager.open('timeline', { title: 'Timeline', content: <Timeline />, anchor: 'bottom-left', stretch: 'width', height: 120 });
|
|
2454
2366
|
*/
|
|
2455
|
-
declare function usePanelFloatingWindowManager():
|
|
2367
|
+
declare function usePanelFloatingWindowManager(): FloatingWidgetsApi;
|
|
2456
2368
|
|
|
2457
2369
|
/**
|
|
2458
2370
|
* @file PanelContributionContext.tsx
|
|
2459
2371
|
* @description Lets any panel publish toolbar items and/or sidebar sections that
|
|
2460
2372
|
* should only be surfaced while it is the globally active panel (`state.activePanelId`).
|
|
2461
2373
|
* Optional, additive module — `DockableDesktopProvider` wires it up automatically.
|
|
2462
|
-
* Neither `<
|
|
2463
|
-
* merges `
|
|
2374
|
+
* Neither `<RddToolbar>` nor `<RddSidebar>` reads from this automatically; the app shell
|
|
2375
|
+
* merges `useActiveContribution()`'s result into its own `items`/`tabs` calls.
|
|
2464
2376
|
*/
|
|
2465
2377
|
|
|
2466
2378
|
/** A single named, labeled slot of content a panel contributes to the app's Sidebar while active. */
|
|
@@ -2480,14 +2392,6 @@ interface PanelContribution {
|
|
|
2480
2392
|
toolbarItems?: ToolbarItem$1[];
|
|
2481
2393
|
sidebarSections?: PanelSidebarSection[];
|
|
2482
2394
|
}
|
|
2483
|
-
/**
|
|
2484
|
-
* Provider enabling `usePanelContribution()` / `useActivePanelContribution()`.
|
|
2485
|
-
* Mounted automatically by `DockableDesktopProvider` — only needed manually when
|
|
2486
|
-
* composing `WindowManagerProvider` directly without it.
|
|
2487
|
-
*/
|
|
2488
|
-
declare const PanelContributionProvider: React$1.FC<{
|
|
2489
|
-
children: React$1.ReactNode;
|
|
2490
|
-
}>;
|
|
2491
2395
|
/**
|
|
2492
2396
|
* Publish this panel's toolbar items and/or sidebar sections. Call on every render —
|
|
2493
2397
|
* republishes automatically whenever `contribution` changes, and is cleared when the
|
|
@@ -2495,9 +2399,9 @@ declare const PanelContributionProvider: React$1.FC<{
|
|
|
2495
2399
|
* `useMemo`/`useCallback`) to avoid republishing on every unrelated re-render.
|
|
2496
2400
|
*
|
|
2497
2401
|
* Contributions are only ever surfaced while this panel is `state.activePanelId` —
|
|
2498
|
-
* see `
|
|
2402
|
+
* see `useActiveContribution()`.
|
|
2499
2403
|
*
|
|
2500
|
-
* @throws Error if used outside of a {@link
|
|
2404
|
+
* @throws Error if used outside of a {@link DockableDesktopProvider}.
|
|
2501
2405
|
* @example
|
|
2502
2406
|
* function MapPanel() {
|
|
2503
2407
|
* const [controller, setController] = useState<'pan' | 'draw' | 'measure'>('pan');
|
|
@@ -2516,13 +2420,13 @@ declare function usePanelContribution(contribution: PanelContribution): void;
|
|
|
2516
2420
|
* Returns whatever the currently active panel (`state.activePanelId`) has published
|
|
2517
2421
|
* via `usePanelContribution()`, or `null` if no panel is active or the active panel
|
|
2518
2422
|
* hasn't contributed anything. Intended for the app shell to merge into its own
|
|
2519
|
-
* `<
|
|
2423
|
+
* `<RddToolbar items={...}>` / `<RddSidebar tabs={...}>` calls.
|
|
2520
2424
|
*
|
|
2521
|
-
* @throws Error if used outside of a {@link
|
|
2425
|
+
* @throws Error if used outside of a {@link DockableDesktopProvider}.
|
|
2522
2426
|
*/
|
|
2523
2427
|
declare function useActivePanelContribution(): PanelContribution | null;
|
|
2524
2428
|
/**
|
|
2525
|
-
* Converts a contributed sidebar section into a `SidebarTab` for `<
|
|
2429
|
+
* Converts a contributed sidebar section into a `SidebarTab` for `<RddSidebar tabs={...}>`.
|
|
2526
2430
|
* `SidebarTab.icon` is optional but recommended unless the tab is `hidden`; supply
|
|
2527
2431
|
* `fallbackIcon` for sections that omit one.
|
|
2528
2432
|
* `eagerMount`/`preserveState` have no contribution-side equivalent — a contribution
|
|
@@ -2530,16 +2434,16 @@ declare function useActivePanelContribution(): PanelContribution | null;
|
|
|
2530
2434
|
*/
|
|
2531
2435
|
declare function sidebarSectionToTab(section: PanelSidebarSection, fallbackIcon?: React$1.ReactNode): SidebarTab;
|
|
2532
2436
|
/**
|
|
2533
|
-
* Convenience wrapper around `
|
|
2437
|
+
* Convenience wrapper around `useActiveContribution()` for the common case:
|
|
2534
2438
|
* append the active panel's contributed toolbar items (behind a separator) to a
|
|
2535
2439
|
* static list. Returns `staticItems` unchanged when there's nothing to add.
|
|
2536
2440
|
* For manual control (a different merge position, no separator, etc.), call
|
|
2537
|
-
* `
|
|
2441
|
+
* `useActiveContribution()` directly instead.
|
|
2538
2442
|
*/
|
|
2539
2443
|
declare function useMergedToolbarItems(staticItems: ToolbarItem$1[]): ToolbarItem$1[];
|
|
2540
2444
|
/**
|
|
2541
|
-
* Convenience wrapper around `
|
|
2542
|
-
* append the active panel's contributed sidebar sections (via `
|
|
2445
|
+
* Convenience wrapper around `useActiveContribution()` for the common case:
|
|
2446
|
+
* append the active panel's contributed sidebar sections (via `sectionToTab`)
|
|
2543
2447
|
* to a static tab list, as dynamic tabs that appear only while their panel is active.
|
|
2544
2448
|
* Returns `staticTabs` unchanged when there's nothing to add.
|
|
2545
2449
|
*/
|
|
@@ -2616,7 +2520,7 @@ declare function computeResizedRect(dir: ResizeDir, dx: number, dy: number, star
|
|
|
2616
2520
|
type ColorScheme = 'dark' | 'light';
|
|
2617
2521
|
/**
|
|
2618
2522
|
* Reactively reads the workspace's current `data-color-scheme` attribute
|
|
2619
|
-
* (set on `document.documentElement` by `<
|
|
2523
|
+
* (set on `document.documentElement` by `<RddDesktop />`), returning
|
|
2620
2524
|
* `'dark'` or `'light'` and re-rendering whenever it changes.
|
|
2621
2525
|
*
|
|
2622
2526
|
* Useful for panel content that needs to react to the same scheme the
|
|
@@ -2638,4 +2542,4 @@ declare function isElementRtl(el: HTMLElement | null): boolean;
|
|
|
2638
2542
|
*/
|
|
2639
2543
|
declare function isComputedRtl(el: Element | null | undefined): boolean;
|
|
2640
2544
|
|
|
2641
|
-
export { type
|
|
2545
|
+
export { type BuiltInEvents, type ButtonVariant, type CloseOptions, 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, 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 };
|