react-dockable-desktop 7.1.2 → 7.1.3

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 CHANGED
@@ -1,6 +1,6 @@
1
- # React Dockable Desktop
1
+ # React Dockable Desktop
2
2
 
3
- [![npm version](https://img.shields.io/badge/npm-v7.1.2-blue.svg)](https://www.npmjs.com/package/react-dockable-desktop)
3
+ [![npm version](https://img.shields.io/badge/npm-v7.1.3-blue.svg)](https://www.npmjs.com/package/react-dockable-desktop)
4
4
  [![TypeScript](https://img.shields.io/badge/TypeScript-first-3178c6.svg)](https://www.typescriptlang.org/)
5
5
  [![Touch Ready](https://img.shields.io/badge/touch-iPad%20%7C%20Android-success.svg)](#touch--mobile)
6
6
  [![license](https://img.shields.io/badge/license-MIT-green.svg)](#license)
@@ -195,7 +195,7 @@ Call these inside any component within the `DockableDesktopProvider` tree:
195
195
  | `useActiveContribution()` | `PanelContribution \| null` | Read the active panel's published contribution, to merge manually |
196
196
  | `useMergedToolbarItems(staticItems)` | `ToolbarItem[]` | `staticItems` + the active panel's contributed toolbar items, ready for `<RddToolbar items={...}>` |
197
197
  | `useMergedSidebarTabs(staticTabs)` | `SidebarTab[]` | `staticTabs` + the active panel's contributed sections as dynamic tabs, ready for `<RddSidebar tabs={...}>` |
198
- | `useColorScheme()` | `'dark' \| 'light'` | Reactively read the workspace's current color scheme from your own panel content |
198
+ | `useColorScheme()` | `'dark' \| 'light'` | Reactively read the color scheme — the `data-color-scheme` your app sets on `<html>` (dark when absent) — from your own panel content |
199
199
 
200
200
  **State selectors** prevent unnecessary re-renders:
201
201
 
@@ -210,22 +210,37 @@ const panelCount = useWorkspaceState(s => Object.keys(s.panels).length);
210
210
  ## Workspace Reference
211
211
 
212
212
  ```ts
213
- const workspace = createWorkspace({ panels, initialState?, formatMessage?, messages?, dir? });
213
+ const workspace = createWorkspace({
214
+ panels, initialState?, formatMessage?, messages?, dir?,
215
+ defaultSplitRatio?, defaultEdgeSplitRatio?, zIndexBase?,
216
+ });
214
217
 
215
218
  // Panel lifecycle
216
- workspace.openPanel(id, component, options?) // options: title, initialTarget, anchor
217
- workspace.closePanel(id)
219
+ workspace.openPanel(id, component, options?) // options: title, initialTarget, anchor, focus (default true), props, dedupeKey
220
+ workspace.closePanel(id) // closes immediately — no guard, no dirty check
221
+ workspace.requestClosePanel(id, { force?, onConfirm? }) // guarded close; a dirty panel closes only if onConfirm resolves true
218
222
  workspace.focusPanel(id) // raises floating / selects tab for docked
219
223
  workspace.floatPanel(id, rect?, anchor?) // detach to a floating window; optional corner anchor
220
224
  workspace.dockPanel(id) // return floating to the grid
221
225
  workspace.minimizePanel(id)
222
- workspace.restorePanel(id)
223
- workspace.maximizePanel(id) // a minimized panel is restored and maximized
226
+ workspace.restorePanel(id, { focus? })
227
+ workspace.maximizePanel(id) // toggles a floating window; a minimized panel is restored and maximized
224
228
  workspace.closeLeafGroup(leafId, opts?) // closes each tab (guards apply), then the group; returns a Promise
225
229
 
230
+ // Placement
231
+ workspace.dockPanelToGroup(id, leafId, position) // position: 'top' | 'bottom' | 'left' | 'right' | 'center'
232
+ workspace.dockPanelToWorkspaceEdge(id, side) // 'top' | 'bottom' | 'left' | 'right'
233
+ workspace.movePanelOrder(id, leafId, index) // move a tab within or between groups
234
+
235
+ // Title, icon and dirty state (from outside the panel; inside it, use usePanel())
236
+ workspace.updatePanelTitle(id, title)
237
+ workspace.setPanelIcon(id, icon) // null restores the registration's icon; never saved
238
+ workspace.setPanelDirty(id, dirty, options?)
239
+
226
240
  // Synchronous state queries (no hook needed)
227
241
  workspace.isOpen(id) // → boolean
228
242
  workspace.getOpenPanelIds() // → string[]
243
+ workspace.findPanelId(component, dedupeKey) // → id | null
229
244
 
230
245
  // Layout persistence
231
246
  workspace.saveLayout() // → JSON string
@@ -238,11 +253,16 @@ workspace.onPanelOpen(cb)
238
253
  workspace.onPanelClose(cb)
239
254
  workspace.onPanelMinimize(cb)
240
255
  workspace.onPanelRestore(cb)
256
+ workspace.onLayoutChanged(cb)
257
+ workspace.onPanelsExcluded(cb) // saveLayout() left out non-serializable panels
241
258
 
242
- // Direction
259
+ // Direction and menus
243
260
  workspace.setDirection('ltr' | 'rtl')
261
+ workspace.showContextMenu({ x, y, items }) // the shared menu, opened from code
244
262
  ```
245
263
 
264
+ Lower-level methods (close guards, state providers, split and floating-window geometry) are listed in the [Workspace guide](https://felipecarrillo100.github.io/react-dockable-desktop/guide/workspace-client).
265
+
246
266
  ---
247
267
 
248
268
  ## PanelHandle Reference
@@ -273,7 +293,7 @@ type ContainerType =
273
293
  | 'standalone'; // rendered outside the desktop (default / no context)
274
294
  ```
275
295
 
276
- Minimize/restore cycles do **not** change `containerType` or fire `onContainerTypeChange`; use `usePanelEvents({ onMinimize, onRestore })` for those.
296
+ Minimizing and restoring don't fire `onContainerTypeChange`; use `usePanelEvents({ onMinimize, onRestore })` for those. (While minimized, a panel's `containerType` reads `'dockable-panel'` — also for a panel that was floating, which reads `'floating-window'` again once restored; check `usePanel().isMinimized` if you need to tell.)
277
297
 
278
298
  ---
279
299
 
@@ -326,7 +346,7 @@ sidePanels.openRight(PropertiesPanel, { nodeId }, { title: 'Properties', width:
326
346
 
327
347
  ## Touch & Mobile
328
348
 
329
- Touch support is built in for v3.1.0+. No extra setup required:
349
+ Touch support is built in. No extra setup required:
330
350
 
331
351
  - **Tab drag** — long-press (300ms) on any tab to start dragging; haptic feedback on supported devices
332
352
  - **Floating window drag** — long-press the titlebar, then drag
@@ -338,16 +358,16 @@ Touch support is built in for v3.1.0+. No extra setup required:
338
358
 
339
359
  ## i18n & RTL
340
360
 
341
- The library does **not** auto-detect direction — the consuming app owns it. Two things must be wired together:
361
+ The library does **not** auto-detect the workspace's direction — the consuming app owns it. Two things must be wired together:
342
362
 
343
363
  ```tsx
344
- // 1. Keep html[dir] in sync for portals (context menu, flyout, toasts)
345
- // that render into document.body and need CSS direction inheritance.
364
+ // 1. Keep html[dir] in sync for what sits outside the workspace — RddSidebar and toasts —
365
+ // which take their direction from the page.
346
366
  useEffect(() => {
347
367
  document.documentElement.dir = isRtl ? 'rtl' : 'ltr';
348
368
  }, [isRtl]);
349
369
 
350
- // 2. Pass dir prop to the provider — controls workspace layout engine.
370
+ // 2. Pass dir to the provider — the workspace, and the menus and flyouts opened from it.
351
371
  <DockableDesktopProvider
352
372
  dir={isRtl ? 'rtl' : 'ltr'}
353
373
  workspace={workspace}
@@ -356,7 +376,7 @@ useEffect(() => {
356
376
  >
357
377
  ```
358
378
 
359
- `dir` can be `'ltr'` (default) or `'rtl'`. All layout, split directions, tab ordering, floating window controls, drop zones, sidebars, and context menus flip automatically.
379
+ `dir` can be `'ltr'` (default) or `'rtl'`. The workspace's layout, split directions, tab ordering, floating window controls, drop zones and context menus flip automatically; the sidebars and toasts follow `html[dir]` (step 1).
360
380
 
361
381
  Direction is **independent of locale** — you can have Arabic translations with LTR layout, or RTL without locale changes.
362
382