react-dockable-desktop 7.8.0 → 7.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,91 @@ replacement and the version that removes the old API.
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [7.10.0] — 2026-10-07
14
+
15
+ Your own tab content, and an opt-in typed panel registry. Both opt-in: without them nothing changes.
16
+
17
+ ### Added
18
+
19
+ - **`renderTabContent` on `<RddDesktop>`: your own tab content.** `renderTabContent={(tab) => …}`
20
+ replaces what's inside every tab in the grid: the icon, the title and the dirty marker. It receives
21
+ a `TabContentProps`: `{ panelId, component, title, icon, dirty, selected, focused }`, with `title`
22
+ already formatted and `icon` the one the built-in content shows, so the built-in look is one line
23
+ to start from. Branch on `component` for a per-type look. The tab itself stays the library's:
24
+ dragging, keyboard navigation, `role="tab"`, its context menu, state attributes and classes, the
25
+ header actions and the close button. Floating-window title bars and the taskbar are unchanged.
26
+ New type: `TabContentProps`.
27
+ - **`definePanels()`: a typed panel registry, opt-in.** Wrap the `panels` map in `definePanels({…})`
28
+ and the workspace `createWorkspace` returns has a typed `openPanel`: only registered names are
29
+ accepted, and `props` is checked against that panel's component (without `panelId`). It returns its
30
+ argument unchanged; the typing is compile-time only. With typed events too, pass both:
31
+ `createWorkspace<typeof panels, AppEvents>({ panels })`. `useWorkspace()` stays untyped. A plain map
32
+ keeps its types exactly, so existing code is unaffected. New types: `TypedWorkspace`, `PanelMap`,
33
+ `PanelPropsOf`; `createWorkspace` gains an overload for marked maps.
34
+
35
+ ## [7.9.0] — 2026-10-06
36
+
37
+ Control over where users can move panels: per-panel-type rules and an app-wide veto, all opt-in.
38
+ Without them nothing changes, and the app's own API calls are never restricted.
39
+
40
+ ### Added
41
+
42
+ - **`canFloat` and `canDock` per panel type**, next to `canDrag`, `canMinimize` and `canClose`.
43
+ `canFloat: false` keeps a panel in the grid: a tab drag can't end in a floating window (dropped on
44
+ nothing or on a corner, it stays where it was), and "Float Window" and the taskbar's "Maximize" are
45
+ hidden. `canDock: false` keeps a panel floating: dragging it offers no group, tab or edge targets.
46
+ - **`canDrop`, an app-wide veto.** `createWorkspace({ canDrop: ({ panelId, component, to }) => boolean })`
47
+ is asked for every place a dragged panel could go, and for the "Float" and "Maximize" menu items.
48
+ `to` is a `PanelDropTarget`: a group (`leafId` and a `position`, `'center'` also covering a drop
49
+ between tabs), a workspace `edge`, or a `float` (a corner `anchor`, or `null` for a tab dropped on
50
+ nothing). A forbidden target isn't offered: its drop zone, edge or corner doesn't appear, and
51
+ releasing there does nothing. It's asked again at release, so a rule that changes mid-drag holds.
52
+ Positions are the ones the move applies: under RTL, the zone drawn on the screen's right is `'left'`.
53
+ If it throws, the move is allowed and the error is logged. New types: `PanelDrop`, `PanelDropTarget`.
54
+ - Both apply only to what the user does. `floatPanel`, `dockPanelToGroup`, `openPanel` and the other
55
+ calls always work.
56
+ - **`startPointerDrag` takes an optional `onCancel`**, called instead of `onEnd` when the drag is cut
57
+ short (see Fixed).
58
+
59
+ ### Fixed
60
+
61
+ - **A drag built on `startPointerDrag` could outlive its element.** It ended only on pointerup or
62
+ pointercancel, so a window losing focus mid-drag, or the dragged element being removed (an overlay
63
+ widget closed during its own drag, a panel closed during a splitter drag), left its listeners
64
+ attached and its classes on the page, such as the resize cursor. It now also ends on window blur
65
+ and on a lost pointer capture (listened for on the document, where browsers fire it when the
66
+ capturing element is removed). The built-in splitters, window resize handles, sidebar resizer and
67
+ overlay widgets all use it.
68
+ - **The API check missed part of the public API.** Types the API refers to without exporting
69
+ (the workspace config's own type behind `WorkspaceConfig`, among others) were left out of
70
+ `api/react-dockable-desktop.api.md`, so a member removed from them would not have failed CI. The
71
+ report now includes them (`includeForgottenExports`), and `scripts/api-check.mjs` compares them by
72
+ name: 172 declarations are tracked instead of 161. Found while checking that `canDrop` appeared
73
+ in the report.
74
+
75
+ ### Docs
76
+
77
+ - **`keepAlive: false`:** a guard the panel registered with `useBeforeClose` is not active while the
78
+ panel is unmounted (it goes with the component); its dirty flag still is, so closing a hidden
79
+ dirty panel still asks first. Now said in the Panel Registry guide and the option's TSDoc.
80
+
81
+ ### Tests
82
+
83
+ - `ReleaseB.test.tsx` (16 tests): `canFloat` (no float on nothing, no corners, no "Float Window", the
84
+ app's `floatPanel` still works), `canDock` (no group or edge targets, only corners; the app can
85
+ still dock it), `canDrop` (its argument, vetoed zones and edges not offered, RTL positions, tab
86
+ insertion into a vetoed group, a rule changed mid-drag in a tab drag and in a window drag, a
87
+ throwing `canDrop`, no rules meaning every target), and `startPointerDrag` ending on blur and on a
88
+ lost capture. Each rule was seen failing with it broken; the two safety layers (not offered while
89
+ hovering, asked again at release) are pinned separately.
90
+ - `dockZones.browser.ts` (18 tests, real Chrome): a tab dropped on each group zone and each workspace
91
+ edge lands where the user pointed, on screen, in LTR and RTL. With the RTL flip removed, exactly the
92
+ RTL left/right cases fail.
93
+ - `ReleaseA.test.tsx`: empty groups inside a split keep the built-in message; only the root group
94
+ shows the `emptyWorkspace` view. 7.8.0 behaved this way, but no test pinned it. A redundant
95
+ root-only check in `WorkspaceGrid` was removed: nested grids never receive the prop, which is
96
+ what the new test now proves. (Found while porting 7.8.0 to vdd.)
97
+
13
98
  ## [7.8.0] — 2026-10-06
14
99
 
15
100
  More control over how the desktop looks and where panels open, all opt-in: without the new options,
@@ -1106,7 +1191,9 @@ All of the above is additive and backward-compatible: every new field is optiona
1106
1191
 
1107
1192
  ---
1108
1193
 
1109
- [Unreleased]: https://github.com/felipecarrillo100/react-dockable-desktop/compare/v7.8.0...HEAD
1194
+ [Unreleased]: https://github.com/felipecarrillo100/react-dockable-desktop/compare/v7.10.0...HEAD
1195
+ [7.10.0]: https://github.com/felipecarrillo100/react-dockable-desktop/compare/v7.9.0...v7.10.0
1196
+ [7.9.0]: https://github.com/felipecarrillo100/react-dockable-desktop/compare/v7.8.0...v7.9.0
1110
1197
  [7.8.0]: https://github.com/felipecarrillo100/react-dockable-desktop/compare/v7.7.4...v7.8.0
1111
1198
  [7.7.4]: https://github.com/felipecarrillo100/react-dockable-desktop/compare/v7.7.3...v7.7.4
1112
1199
  [7.7.3]: https://github.com/felipecarrillo100/react-dockable-desktop/compare/v7.7.2...v7.7.3
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # React Dockable Desktop
2
2
 
3
- [![npm version](https://img.shields.io/badge/npm-v7.8.0-blue.svg)](https://www.npmjs.com/package/react-dockable-desktop)
3
+ [![npm version](https://img.shields.io/badge/npm-v7.10.0-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)
@@ -25,12 +25,15 @@ serialised layout format**, so a layout saved by either library loads in the oth
25
25
 
26
26
  - **Split-Docking Grid** — drag panels to split any zone into rows/columns or group into tabbed containers
27
27
  - **Workspace Edge Docking** — drag to the outer edges to dock a panel as a full-width or full-height strip
28
+ - **Docking Rules** — keep a panel type in the grid (`canFloat: false`) or floating (`canDock: false`), and veto any move with one `canDrop` function; forbidden targets simply aren't offered
28
29
  - **Floating Windows** — pop panels into freely resizable floating windows; 8-direction resize handles (N/NE/E/SE/S/SW/W/NW), maximize, minimize; drag to a workspace corner to anchor it there — anchored windows stack with 8 px gaps and reposition when the viewport resizes
29
30
  - **Panel Overlay** — per-panel overlay layer with anchored toolbars (`RddPanelToolbar`, `RddToolbarButton`, `RddToolbarToggle`, async search) and corner-anchored floating windows that stack, drag, and dock; an axis can span the panel instead of carrying a fixed size, so a strip or column tracks the panel as it resizes — set declaratively or by dragging an edge out until it snaps; `useFloatingWidgets()` opens N named windows dynamically from data or event handlers
30
31
  - **Touch & Mobile Ready** — full iPad and Android support: long-press to drag tabs, touch resize, 44px coarse-pointer targets throughout
31
32
  - **Zero-Unmount DOM Persistence** — panel DOM nodes are moved, never destroyed, across docking, floating, and tab-switching alike, all by default; WebGL, maps, terminals, and forms retain full state with zero integration work (a heavy, rarely shown panel type can opt out with `keepAlive: false`)
32
33
  - **i18n & RTL** — full Right-to-Left layout support; `dir="rtl"` flips every control, tab order, and drop zone automatically
33
34
  - **Inter-Panel Pub/Sub** — lightweight typed event bus for decoupled panel-to-panel communication
35
+ - **Your Own Tab Content** — `renderTabContent` puts your icon, title, badge or status dot in every tab; dragging, keyboard and accessibility stay the library's
36
+ - **Typed Panel Registry** — wrap the panel map in `definePanels()` and `openPanel` accepts only registered names, with props checked against each panel's component
34
37
  - **Imperative API** — the workspace from `createWorkspace()` opens, closes, focuses, and serializes panels from anywhere — inside or outside React; `dockTo` opens a panel beside another, on any side or as a tab
35
38
  - **Layout Serialization** — save and restore the full workspace as a JSON string; survives page reloads
36
39
  - **7 Built-in Skins** — VSCode, macOS, Chrome, Slate, Nord, Obsidian, Tokyo — all fully themeable via CSS variables