react-resizable-panels 4.22.1 → 4.23.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/README.md
CHANGED
|
@@ -1208,6 +1208,16 @@ A tab dragged to another workspace is rendered by that workspace, so its content
|
|
|
1208
1208
|
<p>⚠️ A tab dragged to another copy of the application is sent there with the structured clone algorithm (like <code>postMessage</code>), so its data must be cloneable (e.g. no functions);
|
|
1209
1209
|
tabs whose data can't be cloned (and tabsets containing them) can only be dragged within their copy of the application.
|
|
1210
1210
|
Copies loaded at different times may be running different versions of the application, so the other copy may need to handle tab data it doesn't recognize.</p>
|
|
1211
|
+
</td>
|
|
1212
|
+
</tr>
|
|
1213
|
+
<tr>
|
|
1214
|
+
<td>dragSourceInfo</td>
|
|
1215
|
+
<td><p>Information about this workspace that's sent with the tabs (and tabsets) dragged from it (see the <code>dragGroup</code> prop),
|
|
1216
|
+
so that the workspaces they're dragged into can tell where they came from (see <code>DisableDropArgs.sourceInfo</code> and <code>WorkspaceChangedMeta.sourceInfo</code>),
|
|
1217
|
+
e.g. <code>{ app: "reports", schemaVersion: 3 }</code>.</p>
|
|
1218
|
+
<p>⚠️ It's sent to other copies of the application with the structured clone algorithm (like tab data; see <code>dragGroup</code>), so it must be cloneable;
|
|
1219
|
+
drags whose source info can't be cloned can only be dropped within their copy of the application.
|
|
1220
|
+
It's read when a drag starts, so changes during a drag don't apply to it.</p>
|
|
1211
1221
|
</td>
|
|
1212
1222
|
</tr>
|
|
1213
1223
|
<tr>
|
|
@@ -1217,7 +1227,7 @@ Copies loaded at different times may be running different versions of the applic
|
|
|
1217
1227
|
</tr>
|
|
1218
1228
|
<tr>
|
|
1219
1229
|
<td>hiddenTabBehavior</td>
|
|
1220
|
-
<td><p>What happens to the content of tabs that
|
|
1230
|
+
<td><p>What happens to the content of tabs that aren't visible, once it has been mounted (see <code>lazyTabContent</code>).
|
|
1221
1231
|
Can be a function to choose per tab (e.g. based on its data).</p>
|
|
1222
1232
|
<ul>
|
|
1223
1233
|
<li><code>"keep-mounted"</code>: content stays mounted (and its effects keep running)</li>
|
|
@@ -1225,9 +1235,38 @@ Can be a function to choose per tab (e.g. based on its data).</p>
|
|
|
1225
1235
|
requires React 19.2 (falls back to <code>"keep-mounted"</code> otherwise)</li>
|
|
1226
1236
|
<li><code>"unmount"</code>: content is unmounted</li>
|
|
1227
1237
|
</ul>
|
|
1228
|
-
<p>ℹ️
|
|
1238
|
+
<p>ℹ️ A tab is visible when it's selected, in a tabset that isn't collapsed or covered by a maximized tabset (floating tabsets aren't covered);
|
|
1239
|
+
so e.g. collapsing a tabset hides its selected tab's content, and maximizing one hides the others'.
|
|
1240
|
+
Temporary collapsed states (e.g. while dragging a separator, or when collapsed to fit) don't hide content.</p>
|
|
1241
|
+
<p>ℹ️ Moving a tab never remounts its content (unless the move hides it and <code>hiddenTabBehavior</code> is <code>"unmount"</code>).</p>
|
|
1229
1242
|
<p>⚠️ Its React state is preserved, but its elements are moved within the document, which resets some browser state:
|
|
1230
1243
|
iframes are reloaded, playing media is paused, and focused elements are blurred.</p>
|
|
1244
|
+
</td>
|
|
1245
|
+
</tr>
|
|
1246
|
+
<tr>
|
|
1247
|
+
<td>lazyTabContent</td>
|
|
1248
|
+
<td><p>Don't mount a tab's content until the tab is first visible (e.g. for expensive content in tabsets with many tabs, or in tabsets that start collapsed);
|
|
1249
|
+
otherwise every tab's content is mounted along with the workspace.
|
|
1250
|
+
Can be a function to choose per tab (e.g. based on its data), e.g. <code>(tab) => tab.data.isExpensive</code>.</p>
|
|
1251
|
+
<p>Once mounted, content that isn't visible is kept mounted, hidden in an <code>Activity</code>, or unmounted, as <code>hiddenTabBehavior</code> says.</p>
|
|
1252
|
+
<p>ℹ️ A tab is visible when it's selected, in a tabset that isn't collapsed or covered by a maximized tabset (floating tabsets aren't covered).</p>
|
|
1253
|
+
</td>
|
|
1254
|
+
</tr>
|
|
1255
|
+
<tr>
|
|
1256
|
+
<td>onBeforeModelChange</td>
|
|
1257
|
+
<td><p>Called before a change the user makes (e.g. closing a tab, or dropping a tab that was dragged) is applied to the model;
|
|
1258
|
+
return <code>false</code> to block it, which leaves the model as it is (and <code>onModelChanged</code> isn't called).</p>
|
|
1259
|
+
<p>e.g. to lock the layout while only allowing some interactions (selecting a tab in a collapsed tabset is an "expand" change, and pressing a floating tabset is a "raise" change):
|
|
1260
|
+
<code>onBeforeModelChange={({ reason }) => !isLocked || ["select", "expand", "raise", "maximize", "restore"].includes(reason)}</code></p>
|
|
1261
|
+
<p>Or to keep tabs with unsaved changes from being closed (however they're closed, e.g. with their close buttons or the Delete key):
|
|
1262
|
+
<code>onBeforeModelChange={({ reason, removedTabs }) => reason !== "close" || !removedTabs.some((tab) => tab.data.isDirty)}</code></p>
|
|
1263
|
+
<p>ℹ️ It's called synchronously; to ask the user first (e.g. "Save changes before closing?"), block the change and then make it with the imperative API (e.g. <code>closeTab</code>) if they confirm.</p>
|
|
1264
|
+
<p>ℹ️ Changes made with the imperative API (including the handles returned by hooks like <code>useParentTab</code>, e.g. from a custom close button) aren't passed to it, since the application makes those itself.
|
|
1265
|
+
Neither is the removal of a tab (or tabset) that another workspace has accepted (see the <code>dragGroup</code> prop), or one that was torn off (see <code>onTearOff</code>),
|
|
1266
|
+
since it has already been added elsewhere; use <code>disableDrop</code> (or the <code>disableDrag</code> flags) to keep tabs from being dragged out instead.
|
|
1267
|
+
A workspace that a tab is dropped into can block the drop, in which case it stays in the workspace it was dragged from.</p>
|
|
1268
|
+
<p>ℹ️ Blocked resizes are undone (e.g. a separator dragged by the user moves back). Drops are blocked when the pointer is released,
|
|
1269
|
+
so use <code>disableDrop</code> to show while dragging that a target doesn't accept drops.</p>
|
|
1231
1270
|
</td>
|
|
1232
1271
|
</tr>
|
|
1233
1272
|
<tr>
|
|
@@ -1624,13 +1663,20 @@ The easiest way to interact with this API is to use the `useWorkspaceRef` and `u
|
|
|
1624
1663
|
<tbody>
|
|
1625
1664
|
<tr>
|
|
1626
1665
|
<td>addTab</td>
|
|
1627
|
-
<td><p>Add a tab to a tabset.</p>
|
|
1666
|
+
<td><p>Add a tab to a tabset, or in a new tabset at any target <code>moveTab</code> accepts (e.g. in a new split below a tabset, or at an edge of the workspace).</p>
|
|
1628
1667
|
<p>ℹ️ If a tab with the same id already exists, it is selected instead (and its data is not changed).</p>
|
|
1668
|
+
<p>ℹ️ A tab added in a new tabset is that tabset's selected tab (so <code>select</code> doesn't apply); like a moved tab, it's added to a floating tabset rather than splitting it.</p>
|
|
1629
1669
|
<ul>
|
|
1630
1670
|
<li><code>tab</code> Tab to add</li>
|
|
1631
|
-
<li><code>options</code>
|
|
1632
|
-
<li><code>options</code>
|
|
1633
|
-
<li><code>options</code>
|
|
1671
|
+
<li><code>options.tabsetId</code> Tabset to add the tab to; defaults to the active tabset</li>
|
|
1672
|
+
<li><code>options.index</code> Position within the tabset; defaults to the end</li>
|
|
1673
|
+
<li><code>options.select</code> Select the new tab; defaults to true</li>
|
|
1674
|
+
<li><code>options.target</code> Where to add the tab (see <code>TabDropTarget</code>); takes precedence over <code>tabsetId</code> and <code>index</code></li>
|
|
1675
|
+
<li><code>options.size</code> Size of the new tabset, when <code>target</code> creates one (an edge region of a tabset, or an edge of the workspace), as its share of the split it's in.
|
|
1676
|
+
Numbers are percentages (as in the model, see <code>TabsetNode.size</code>); strings may have units (e.g. <code>"200px"</code>), and are converted to percentages of the split's current size.
|
|
1677
|
+
For an edge region, the new tabset takes its space from the tabset it splits (so its siblings keep their sizes); if that tabset doesn't have enough room, its siblings shrink in proportion to their sizes instead.
|
|
1678
|
+
Defaults to half of the tabset it splits; at an edge of the workspace, an equal share of the root split (if it's in the same direction), or else half of the workspace.
|
|
1679
|
+
Invalid sizes (e.g. <code>NaN</code> or <code>"abc"</code>) are ignored, with a warning in development.</li>
|
|
1634
1680
|
</ul>
|
|
1635
1681
|
</td>
|
|
1636
1682
|
</tr>
|
|
@@ -1734,6 +1780,10 @@ The <code>"left"</code> and <code>"right"</code> regions (an
|
|
|
1734
1780
|
Floating tabsets can't be split, so a tabset moved to an edge region of one has its tabs moved into it instead (like the <code>"center"</code> region).</p>
|
|
1735
1781
|
</td>
|
|
1736
1782
|
</tr>
|
|
1783
|
+
<tr>
|
|
1784
|
+
<td>resizeSplit</td>
|
|
1785
|
+
<td></td>
|
|
1786
|
+
</tr>
|
|
1737
1787
|
<tr>
|
|
1738
1788
|
<td>restoreTabset</td>
|
|
1739
1789
|
<td><p>Restore the maximized tabset (if there is one).</p>
|