react-resizable-panels 4.16.1 → 4.18.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.
|
@@ -111,9 +111,24 @@ export declare type CellProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
111
111
|
style?: CSSProperties | undefined;
|
|
112
112
|
};
|
|
113
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Arguments passed to the Workspace's `disableDrop` prop.
|
|
116
|
+
*
|
|
117
|
+
* While a tabset is dragged, `disableDrop` is called once for each of its tabs (with the target that tab would be dropped at),
|
|
118
|
+
* and the target is rejected if any call returns `true`.
|
|
119
|
+
*/
|
|
114
120
|
export declare type DisableDropArgs<TabData = unknown, TabsetData = unknown> = {
|
|
115
121
|
model: WorkspaceModel<TabData, TabsetData>;
|
|
116
|
-
|
|
122
|
+
/**
|
|
123
|
+
* The tab being dropped.
|
|
124
|
+
*
|
|
125
|
+
* ⚠️ This is `undefined` when a tabset without tabs (one with the `keepWhenEmpty` flag) is dragged.
|
|
126
|
+
*/
|
|
127
|
+
tab: TabNode<TabData> | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* The tabset being dragged, when a whole tabset is dragged (rather than a single tab).
|
|
130
|
+
*/
|
|
131
|
+
tabset: TabsetNode<TabData, TabsetData> | undefined;
|
|
117
132
|
target: TabDropTarget;
|
|
118
133
|
};
|
|
119
134
|
|
|
@@ -681,6 +696,26 @@ export declare type LayoutChangedMeta<RequestedLayout = Layout> = {
|
|
|
681
696
|
|
|
682
697
|
export declare type LayoutStorage = Pick<Storage, "getItem" | "setItem">;
|
|
683
698
|
|
|
699
|
+
/**
|
|
700
|
+
* Validates a model (e.g. one saved from `onModelChanged` and loaded from storage) and tidies it,
|
|
701
|
+
* the same way the `defaultModel` prop and the `setModel` method do:
|
|
702
|
+
* - Removes empty tabsets (other than an empty root tabset, and tabsets with the `keepWhenEmpty` flag)
|
|
703
|
+
* - Replaces splits with a single child with that child, and merges splits into parent splits with the same orientation
|
|
704
|
+
* - Scales sizes so they add up to 100 (when all siblings have percentage sizes)
|
|
705
|
+
* - Fixes selections (and recently selected tabs) of tabs that no longer exist
|
|
706
|
+
* - Expands tabsets that can't be collapsed (e.g. the only tabset in the workspace)
|
|
707
|
+
* - Clears the maximized tabset if it no longer exists
|
|
708
|
+
* - Assigns ids to splits and tabsets that don't have them
|
|
709
|
+
*
|
|
710
|
+
* ℹ️ The optional `mapTab` function is called for each tab before the model is tidied,
|
|
711
|
+
* e.g. to refresh a saved tab's title and flags from code; tabs it returns `null` for are removed.
|
|
712
|
+
*
|
|
713
|
+
* @returns The tidied model, or `null` if the value isn't a model (e.g. saved data that's corrupt, or saved by an unsupported version)
|
|
714
|
+
*/
|
|
715
|
+
export declare function normalizeWorkspaceModel<TabData = unknown, TabsetData = unknown>(value: unknown, { mapTab }?: {
|
|
716
|
+
mapTab?: ((tab: TabNode<TabData>) => TabNode<TabData> | null) | undefined;
|
|
717
|
+
}): WorkspaceModel<TabData, TabsetData> | null;
|
|
718
|
+
|
|
684
719
|
export declare type OnGroupLayoutChange = GroupProps["onLayoutChange"];
|
|
685
720
|
|
|
686
721
|
export declare type OnPanelResize = PanelProps["onResize"];
|
|
@@ -1026,10 +1061,25 @@ export declare type ParentTabset<TabData = unknown> = {
|
|
|
1026
1061
|
* Close the tabset, along with any tabs it contains (see `WorkspaceImperativeHandle.closeTabset`).
|
|
1027
1062
|
*/
|
|
1028
1063
|
close: () => void;
|
|
1064
|
+
/**
|
|
1065
|
+
* Collapse the tabset to just its header (see `WorkspaceImperativeHandle.collapseTabset`).
|
|
1066
|
+
*/
|
|
1067
|
+
collapse: () => void;
|
|
1068
|
+
/**
|
|
1069
|
+
* Expand the tabset if it is collapsed (see `WorkspaceImperativeHandle.expandTabset`).
|
|
1070
|
+
*/
|
|
1071
|
+
expand: () => void;
|
|
1029
1072
|
/**
|
|
1030
1073
|
* Id of the tabset.
|
|
1031
1074
|
*/
|
|
1032
1075
|
id: string;
|
|
1076
|
+
/**
|
|
1077
|
+
* The tabset is currently collapsed (in the model).
|
|
1078
|
+
*
|
|
1079
|
+
* ℹ️ A tabset may be shown collapsed (or expanded) unlike the model: while a separator is being dragged (before the model changes),
|
|
1080
|
+
* and when it's collapsed to fit (see `TabsetNode.collapsible`); `useParentTabsetState().isCollapsed` reflects how it's shown.
|
|
1081
|
+
*/
|
|
1082
|
+
isCollapsed: () => boolean;
|
|
1033
1083
|
/**
|
|
1034
1084
|
* The tabset is currently maximized.
|
|
1035
1085
|
*/
|
|
@@ -1058,6 +1108,37 @@ export declare type ParentTabsetState = {
|
|
|
1058
1108
|
* The user most recently interacted with this tabset (by pointer or focus).
|
|
1059
1109
|
*/
|
|
1060
1110
|
isActive: boolean;
|
|
1111
|
+
/**
|
|
1112
|
+
* The tabset is collapsed to just its header.
|
|
1113
|
+
*
|
|
1114
|
+
* ℹ️ While a separator is being dragged, this reflects how the tabset is shown (e.g. collapsed as soon as it reaches its collapsed size),
|
|
1115
|
+
* which the model (and `useParentTabset().isCollapsed()`) only reflects once the drag ends.
|
|
1116
|
+
*
|
|
1117
|
+
* ℹ️ A tabset that's collapsed to fit (see `isCollapsedToFit`) is collapsed, although the model has it expanded.
|
|
1118
|
+
*
|
|
1119
|
+
* ℹ️ A maximized tabset is shown expanded, but it's still collapsed when it is restored.
|
|
1120
|
+
*/
|
|
1121
|
+
isCollapsed: boolean;
|
|
1122
|
+
/**
|
|
1123
|
+
* The tabset is collapsed only because it doesn't fit (e.g. the workspace is narrower than its tabsets' minimum sizes; see `TabsetNode.collapsible`).
|
|
1124
|
+
* The model has it expanded, and it's shown expanded again once it fits.
|
|
1125
|
+
*
|
|
1126
|
+
* ℹ️ It can't be expanded until then (e.g. `useParentTabset().expand()` does nothing), so a toolbar can hide (or disable) its "expand" button.
|
|
1127
|
+
*/
|
|
1128
|
+
isCollapsedToFit: boolean;
|
|
1129
|
+
/**
|
|
1130
|
+
* The tabset can be collapsed (or is collapsed, and can be expanded), e.g. to show or hide a toolbar button:
|
|
1131
|
+
* it has the `collapsible` flag, isn't the only tabset in the workspace, and has a sibling that isn't collapsed.
|
|
1132
|
+
*/
|
|
1133
|
+
isCollapsible: boolean;
|
|
1134
|
+
/**
|
|
1135
|
+
* The user cannot drag the tabset as a whole, because:
|
|
1136
|
+
* - It has the `disableDrag` flag, or one of its tabs does
|
|
1137
|
+
* - The Workspace has the `disabled` prop
|
|
1138
|
+
* - It's the only tabset in the workspace (see `isRoot`)
|
|
1139
|
+
* - A tabset is maximized
|
|
1140
|
+
*/
|
|
1141
|
+
isDragDisabled: boolean;
|
|
1061
1142
|
/**
|
|
1062
1143
|
* The tabset is maximized.
|
|
1063
1144
|
*/
|
|
@@ -1093,7 +1174,10 @@ export declare type ParentTabState = {
|
|
|
1093
1174
|
*/
|
|
1094
1175
|
isSelected: boolean;
|
|
1095
1176
|
/**
|
|
1096
|
-
* The tab is selected, and its tabset is
|
|
1177
|
+
* The tab is selected, and its tabset is neither collapsed nor covered by another, maximized tabset.
|
|
1178
|
+
*
|
|
1179
|
+
* ℹ️ While a separator is being dragged, this reflects how the tab's tabset is shown (e.g. collapsed as soon as it reaches its collapsed size),
|
|
1180
|
+
* which the model only reflects once the drag ends; it also reflects tabsets that are collapsed to fit (see `TabsetNode.collapsible`).
|
|
1097
1181
|
*
|
|
1098
1182
|
* ⚠️ This value does not account for the Workspace itself being hidden.
|
|
1099
1183
|
*/
|
|
@@ -1249,13 +1333,14 @@ export declare type SplitNodeInput<TabData = unknown, TabsetData = unknown> = Om
|
|
|
1249
1333
|
* renderTab={(tab, props) => (
|
|
1250
1334
|
* <div {...props}>
|
|
1251
1335
|
* {tab.title}
|
|
1252
|
-
* <TabCloseButton
|
|
1336
|
+
* <TabCloseButton>×</TabCloseButton>
|
|
1253
1337
|
* </div>
|
|
1254
1338
|
* )}
|
|
1255
1339
|
* ```
|
|
1256
1340
|
*
|
|
1257
1341
|
* The button renders nothing if closing is disabled (by the tab's `disableClose` flag or the Workspace's `disabled` prop).
|
|
1258
|
-
* Its
|
|
1342
|
+
* Its content defaults to "×" (e.g. it can be replaced with an icon),
|
|
1343
|
+
* and its default `aria-label` is "Close" followed by the tab's title (or id).
|
|
1259
1344
|
*
|
|
1260
1345
|
* To keep the tab open (e.g. to confirm unsaved changes first), call `event.preventDefault()` in an `onClick` handler:
|
|
1261
1346
|
*
|
|
@@ -1334,6 +1419,13 @@ export declare type TabNode<TabData = unknown> = {
|
|
|
1334
1419
|
disableDrag?: boolean | undefined;
|
|
1335
1420
|
};
|
|
1336
1421
|
|
|
1422
|
+
/**
|
|
1423
|
+
* Which tab is selected when a tabset's selected tab is removed (closed, or dragged to another tabset):
|
|
1424
|
+
* - `"adjacent"`: the tab after it (or before it, if it was the last tab)
|
|
1425
|
+
* - `"recent"`: the tabset's most recently selected tab (falling back to `"adjacent"` if none of its other tabs has been selected)
|
|
1426
|
+
*/
|
|
1427
|
+
export declare type TabRemovalSelectionBehavior = "adjacent" | "recent";
|
|
1428
|
+
|
|
1337
1429
|
/**
|
|
1338
1430
|
* Props passed to the Workspace's `renderTab` prop, to be spread onto the element it returns.
|
|
1339
1431
|
*/
|
|
@@ -1342,6 +1434,30 @@ export declare type TabRenderProps = Pick<HTMLAttributes<HTMLElement>, "aria-con
|
|
|
1342
1434
|
[dataAttribute: `data-${string}`]: string | boolean | undefined;
|
|
1343
1435
|
};
|
|
1344
1436
|
|
|
1437
|
+
/**
|
|
1438
|
+
* Drags the tabset it is rendered within; render it within the content returned by the Workspace's `renderTabsetToolbar` prop:
|
|
1439
|
+
*
|
|
1440
|
+
* ```tsx
|
|
1441
|
+
* renderTabsetToolbar={() => (
|
|
1442
|
+
* <TabsetDragHandle>⠿</TabsetDragHandle>
|
|
1443
|
+
* )}
|
|
1444
|
+
* ```
|
|
1445
|
+
*
|
|
1446
|
+
* By default, a tabset is dragged by the empty space in its header;
|
|
1447
|
+
* once its header contains a drag handle, only the handle drags it.
|
|
1448
|
+
* Any element with a `data-tabset-drag-handle` attribute is a drag handle;
|
|
1449
|
+
* this component also sets `touch-action: none`, so that it can be dragged by touch.
|
|
1450
|
+
*
|
|
1451
|
+
* The handle has a `data-disabled` attribute when the tabset can't be dragged (see `useParentTabsetState`), e.g. to hide it.
|
|
1452
|
+
*/
|
|
1453
|
+
export declare const TabsetDragHandle: typeof TabsetDragHandleComponent & {
|
|
1454
|
+
displayName: string;
|
|
1455
|
+
};
|
|
1456
|
+
|
|
1457
|
+
declare function TabsetDragHandleComponent({ style, ...rest }: TabsetDragHandleProps): JSX.Element;
|
|
1458
|
+
|
|
1459
|
+
export declare type TabsetDragHandleProps = HTMLAttributes<HTMLDivElement>;
|
|
1460
|
+
|
|
1345
1461
|
/**
|
|
1346
1462
|
* A set of tabs, only one of which is shown at a time.
|
|
1347
1463
|
*/
|
|
@@ -1367,6 +1483,9 @@ export declare type TabsetNode<TabData = unknown, TabsetData = unknown> = {
|
|
|
1367
1483
|
*
|
|
1368
1484
|
* ⚠️ String sizes are only initial sizes: they're converted to percentages when the user resizes the split,
|
|
1369
1485
|
* and (like percentages) they scale with the workspace when it's resized.
|
|
1486
|
+
*
|
|
1487
|
+
* ℹ️ A tabset is shown within its minimum and maximum sizes (see `minWidth` and `maxWidth`), even if its size is outside of them
|
|
1488
|
+
* (e.g. a model saved in a wider window); its size isn't changed, so it's shown at its size again once that fits.
|
|
1370
1489
|
*/
|
|
1371
1490
|
size?: number | string | undefined;
|
|
1372
1491
|
/**
|
|
@@ -1387,6 +1506,30 @@ export declare type TabsetNode<TabData = unknown, TabsetData = unknown> = {
|
|
|
1387
1506
|
* - Percentages (and strings without units) are not allowed
|
|
1388
1507
|
*/
|
|
1389
1508
|
minHeight?: string | undefined;
|
|
1509
|
+
/**
|
|
1510
|
+
* Maximum width of the tabset's content area (not including its header).
|
|
1511
|
+
*
|
|
1512
|
+
* ℹ️ Interpretation rules:
|
|
1513
|
+
* - Strings must specify a unit: "px", "em", "rem", "vh", or "vw" (e.g. `maxWidth: "400px"`)
|
|
1514
|
+
* - Percentages (and strings without units) are not allowed
|
|
1515
|
+
* - If the tabset's minimum width is larger, the minimum is used
|
|
1516
|
+
*
|
|
1517
|
+
* ⚠️ A maximum only applies if something else can take up the rest of the space, e.g. another tabset in the same split without a maximum width;
|
|
1518
|
+
* otherwise it's ignored (e.g. if every tabset in a split has a maximum, or the tabset fills the workspace).
|
|
1519
|
+
*/
|
|
1520
|
+
maxWidth?: string | undefined;
|
|
1521
|
+
/**
|
|
1522
|
+
* Maximum height of the tabset's content area (not including its header).
|
|
1523
|
+
*
|
|
1524
|
+
* ℹ️ Interpretation rules:
|
|
1525
|
+
* - Strings must specify a unit: "px", "em", "rem", "vh", or "vw" (e.g. `maxHeight: "400px"`)
|
|
1526
|
+
* - Percentages (and strings without units) are not allowed
|
|
1527
|
+
* - If the tabset's minimum height is larger, the minimum is used
|
|
1528
|
+
*
|
|
1529
|
+
* ⚠️ A maximum only applies if something else can take up the rest of the space, e.g. another tabset in the same split without a maximum height;
|
|
1530
|
+
* otherwise it's ignored (e.g. if every tabset in a split has a maximum, or the tabset fills the workspace).
|
|
1531
|
+
*/
|
|
1532
|
+
maxHeight?: string | undefined;
|
|
1390
1533
|
/**
|
|
1391
1534
|
* Where the tabset's tabs are placed relative to its content.
|
|
1392
1535
|
* Overrides the Workspace's `tabPlacement` prop.
|
|
@@ -1405,10 +1548,50 @@ export declare type TabsetNode<TabData = unknown, TabsetData = unknown> = {
|
|
|
1405
1548
|
* ℹ️ Tabsets created by the workspace (e.g. by dropping a tab onto the edge of another tabset) don't keep this flag.
|
|
1406
1549
|
*/
|
|
1407
1550
|
keepWhenEmpty?: boolean | undefined;
|
|
1551
|
+
/**
|
|
1552
|
+
* The tabset can be collapsed to just its header (its tab list and toolbar), e.g. a bottom panel or a sidebar.
|
|
1553
|
+
*
|
|
1554
|
+
* ℹ️ Tabsets are collapsed by dragging a separator past their minimum size (like collapsible Panels),
|
|
1555
|
+
* or with the imperative API (e.g. a button rendered by `renderTabsetToolbar`, see `useParentTabset`);
|
|
1556
|
+
* clicking a tab (or the empty space in the header) of a collapsed tabset expands it, as does dropping tabs into it from another tabset.
|
|
1557
|
+
*
|
|
1558
|
+
* ℹ️ The only tabset in a workspace (the root) can't be collapsed, and neither can a tabset whose siblings are all collapsed.
|
|
1559
|
+
*
|
|
1560
|
+
* ℹ️ When tabsets don't fit (e.g. the workspace is made narrower than their minimum sizes), a collapsible tabset may be collapsed to fit.
|
|
1561
|
+
* It's shown collapsed (see `useParentTabsetState().isCollapsedToFit`), but the model isn't changed, so it's shown expanded again once it fits.
|
|
1562
|
+
* Until then, it can't be expanded: clicking one of its tabs selects the tab, and `expandTabset` does nothing.
|
|
1563
|
+
* A resize of its split doesn't change it either (it stays expanded in the model, with its size), unless the resize expands it.
|
|
1564
|
+
*
|
|
1565
|
+
* ℹ️ Tabsets created by the workspace (e.g. by dropping a tab onto the edge of another tabset) don't keep this flag.
|
|
1566
|
+
*/
|
|
1567
|
+
collapsible?: boolean | undefined;
|
|
1568
|
+
/**
|
|
1569
|
+
* The tabset is collapsed to just its header.
|
|
1570
|
+
*
|
|
1571
|
+
* ℹ️ A collapsed tabset's `size` is the size it expands to; its siblings share the rest of the split.
|
|
1572
|
+
*
|
|
1573
|
+
* ℹ️ A collapsed tabset's header runs along its split (e.g. tabs placed on top are shown on the left while a tabset in a horizontal split is collapsed);
|
|
1574
|
+
* this doesn't change its `tabPlacement`.
|
|
1575
|
+
*/
|
|
1576
|
+
collapsed?: boolean | undefined;
|
|
1577
|
+
/**
|
|
1578
|
+
* The user cannot drag the tabset as a whole (by the empty space in its header, or by a `TabsetDragHandle`).
|
|
1579
|
+
*
|
|
1580
|
+
* ℹ️ Its tabs can still be dragged individually (unless they have their own `disableDrag` flags),
|
|
1581
|
+
* and the tabset can still be moved using the imperative API.
|
|
1582
|
+
*/
|
|
1583
|
+
disableDrag?: boolean | undefined;
|
|
1408
1584
|
/**
|
|
1409
1585
|
* Id of the selected tab.
|
|
1410
1586
|
*/
|
|
1411
1587
|
selectedId?: string | undefined;
|
|
1588
|
+
/**
|
|
1589
|
+
* Ids of the tabset's tabs that have been selected, most recently selected first;
|
|
1590
|
+
* used to choose which tab to select when the selected tab is removed (see the Workspace's `tabRemovalSelectionBehavior` prop).
|
|
1591
|
+
*
|
|
1592
|
+
* ℹ️ This field is maintained by the workspace, and only when `tabRemovalSelectionBehavior` is `"recent"`.
|
|
1593
|
+
*/
|
|
1594
|
+
recentTabIds?: string[] | undefined;
|
|
1412
1595
|
/**
|
|
1413
1596
|
* Application data for the tabset.
|
|
1414
1597
|
*
|
|
@@ -1607,6 +1790,17 @@ export declare function useParentTabState(): ParentTabState | null;
|
|
|
1607
1790
|
*/
|
|
1608
1791
|
export declare function useParentWorkspace<TabData = unknown, TabsetData = unknown>(): ParentWorkspace<TabData, TabsetData> | null;
|
|
1609
1792
|
|
|
1793
|
+
/**
|
|
1794
|
+
* Returns the space (in pixels) in the nearest ancestor tabset's tab list that its tabs don't use (negative once they overflow),
|
|
1795
|
+
* e.g. for a toolbar (see `renderTabsetToolbar`) that moves items into an overflow menu when the tabset's header runs out of room;
|
|
1796
|
+
* see `WorkspaceImperativeHandle.getTabListFreeSpace`.
|
|
1797
|
+
*
|
|
1798
|
+
* ℹ️ The component re-renders when the free space changes, before the browser paints.
|
|
1799
|
+
*
|
|
1800
|
+
* @returns The free space, or `undefined` if the component is not rendered within a tabset (or the tab list hasn't been measured yet, e.g. while server rendering, or right after the tabset is first rendered)
|
|
1801
|
+
*/
|
|
1802
|
+
export declare function useTabListFreeSpace(): number | undefined;
|
|
1803
|
+
|
|
1610
1804
|
/**
|
|
1611
1805
|
* Convenience hook to return a properly typed ref callback for the Workspace component.
|
|
1612
1806
|
*
|
|
@@ -1655,6 +1849,9 @@ export declare type WorkspaceChangedMeta = {
|
|
|
1655
1849
|
/**
|
|
1656
1850
|
* Which change was made.
|
|
1657
1851
|
*
|
|
1852
|
+
* ℹ️ A resize that collapses or expands tabsets is reported as `"collapse"` or `"expand"` (as `"expand"` if it does both);
|
|
1853
|
+
* dropping tabs into a collapsed tabset expands it, but is reported as `"move"`.
|
|
1854
|
+
*
|
|
1658
1855
|
* ⚠️ New reasons may be added in later versions, so code that switches on this value should handle unrecognized values.
|
|
1659
1856
|
*/
|
|
1660
1857
|
reason: WorkspaceChangeReason;
|
|
@@ -1665,7 +1862,7 @@ export declare type WorkspaceChangedMeta = {
|
|
|
1665
1862
|
*
|
|
1666
1863
|
* ⚠️ New reasons may be added in later versions.
|
|
1667
1864
|
*/
|
|
1668
|
-
export declare type WorkspaceChangeReason = "add" | "close" | "maximize" | "move" | "resize" | "restore" | "select" | "set-model" | "update";
|
|
1865
|
+
export declare type WorkspaceChangeReason = "add" | "close" | "collapse" | "expand" | "maximize" | "move" | "resize" | "restore" | "select" | "set-model" | "update";
|
|
1669
1866
|
|
|
1670
1867
|
/**
|
|
1671
1868
|
* CSS class names for the elements a Workspace renders (see the Workspace's `classNames` prop).
|
|
@@ -1688,7 +1885,7 @@ export declare type WorkspaceClassNames = {
|
|
|
1688
1885
|
toolbar?: string | undefined;
|
|
1689
1886
|
};
|
|
1690
1887
|
|
|
1691
|
-
declare function WorkspaceComponent<TabData = unknown, TabsetData = unknown>({ className, classNames, defaultModel, disabled, disableDrop, elementRef: elementRefProp, hiddenTabBehavior, id: idProp, onModelChanged, renderDragPreview, renderEmptyTabset, renderSeparator, renderTab, renderTabContent, renderTabsetToolbar, resizePreviewMode, serverRenderTabContent, style, styles, tabPlacement, tabsetMinHeight, tabsetMinWidth, workspaceRef, ...rest }: WorkspaceProps<TabData, TabsetData>): JSX.Element;
|
|
1888
|
+
declare function WorkspaceComponent<TabData = unknown, TabsetData = unknown>({ className, classNames, defaultModel, disabled, disableDrop, elementRef: elementRefProp, hiddenTabBehavior, id: idProp, onModelChanged, renderDragPreview, renderEmptyTabset, renderSeparator, renderTab, renderTabContent, renderTabsetDragPreview, renderTabsetToolbar, resizePreviewMode, serverRenderTabContent, style, styles, tabPlacement, tabRemovalSelectionBehavior, tabsetMinHeight, tabsetMinWidth, workspaceRef, ...rest }: WorkspaceProps<TabData, TabsetData>): JSX.Element;
|
|
1692
1889
|
|
|
1693
1890
|
/**
|
|
1694
1891
|
* Imperative Workspace API.
|
|
@@ -1725,6 +1922,21 @@ export declare interface WorkspaceImperativeHandle<TabData = unknown, TabsetData
|
|
|
1725
1922
|
* If the root tabset is closed, the workspace is left with an empty root tabset.
|
|
1726
1923
|
*/
|
|
1727
1924
|
closeTabset: (tabsetId: string) => void;
|
|
1925
|
+
/**
|
|
1926
|
+
* Collapse a tabset to just its header.
|
|
1927
|
+
*
|
|
1928
|
+
* ℹ️ This has no effect unless the tabset has the `collapsible` flag;
|
|
1929
|
+
* the only tabset in a workspace, and tabsets whose siblings are all collapsed, can't be collapsed.
|
|
1930
|
+
*/
|
|
1931
|
+
collapseTabset: (tabsetId: string) => void;
|
|
1932
|
+
/**
|
|
1933
|
+
* Expand a collapsed tabset to its previous size.
|
|
1934
|
+
*
|
|
1935
|
+
* ℹ️ Tabsets are shown at least at their minimum sizes (if they fit), even if the model's sizes are smaller (see `TabsetNode.size`).
|
|
1936
|
+
*
|
|
1937
|
+
* ℹ️ This has no effect on a tabset that's only collapsed to fit, which is expanded once it fits (see `TabsetNode.collapsible`).
|
|
1938
|
+
*/
|
|
1939
|
+
expandTabset: (tabsetId: string) => void;
|
|
1728
1940
|
/**
|
|
1729
1941
|
* Id of the tabset the user most recently interacted with (by pointer or focus).
|
|
1730
1942
|
*/
|
|
@@ -1733,6 +1945,21 @@ export declare interface WorkspaceImperativeHandle<TabData = unknown, TabsetData
|
|
|
1733
1945
|
* Get the current model.
|
|
1734
1946
|
*/
|
|
1735
1947
|
getModel: () => WorkspaceModel<TabData, TabsetData>;
|
|
1948
|
+
/**
|
|
1949
|
+
* Space (in pixels) in a tabset's tab list that its tabs don't use, e.g. how much a toolbar beside the tabs could grow
|
|
1950
|
+
* before they overflow (and how much space an overflow menu needs to free up, once it's negative).
|
|
1951
|
+
*
|
|
1952
|
+
* ℹ️ The space is measured along the tab list: its width, or its height if its tabs are placed on the left or right
|
|
1953
|
+
* (or the tabset is collapsed to a vertical strip).
|
|
1954
|
+
*
|
|
1955
|
+
* ℹ️ The tab list's `--tab-list-free-space` custom property has the same value (e.g. "120px").
|
|
1956
|
+
*
|
|
1957
|
+
* ℹ️ Within a tabset (e.g. its toolbar), the `useTabListFreeSpace` hook returns this value (and re-renders when it changes).
|
|
1958
|
+
*
|
|
1959
|
+
* @returns The free space, or `undefined` if the tabset isn't rendered (or hasn't been measured yet, e.g. while server rendering,
|
|
1960
|
+
* or right after the tabset is first rendered: it's measured after React commits, before the browser paints)
|
|
1961
|
+
*/
|
|
1962
|
+
getTabListFreeSpace: (tabsetId: string) => number | undefined;
|
|
1736
1963
|
/**
|
|
1737
1964
|
* Maximize a tabset, so that it covers the rest of the workspace.
|
|
1738
1965
|
*
|
|
@@ -1744,6 +1971,13 @@ export declare interface WorkspaceImperativeHandle<TabData = unknown, TabsetData
|
|
|
1744
1971
|
* Move a tab to a position within a tabset's tab list, or to a region of a tabset's content area.
|
|
1745
1972
|
*/
|
|
1746
1973
|
moveTab: (tabId: string, target: TabDropTarget) => void;
|
|
1974
|
+
/**
|
|
1975
|
+
* Move a tabset beside another tabset (by dropping it onto a region at the edge of that tabset's content area),
|
|
1976
|
+
* or move its tabs into another tabset (at an `index` within its tab list, or onto the `"center"` of its content area).
|
|
1977
|
+
*
|
|
1978
|
+
* ℹ️ When its tabs are moved, the emptied tabset is removed (unless it has the `keepWhenEmpty` flag).
|
|
1979
|
+
*/
|
|
1980
|
+
moveTabset: (tabsetId: string, target: TabDropTarget) => void;
|
|
1747
1981
|
/**
|
|
1748
1982
|
* Restore the maximized tabset (if there is one).
|
|
1749
1983
|
*/
|
|
@@ -1758,6 +1992,18 @@ export declare interface WorkspaceImperativeHandle<TabData = unknown, TabsetData
|
|
|
1758
1992
|
* @return Applied model (after normalization)
|
|
1759
1993
|
*/
|
|
1760
1994
|
setModel: (model: WorkspaceModelInput<TabData, TabsetData>) => WorkspaceModel<TabData, TabsetData>;
|
|
1995
|
+
/**
|
|
1996
|
+
* Subscribe to changes to the free space in a tabset's tab list (see `getTabListFreeSpace`),
|
|
1997
|
+
* e.g. from a toolbar rendered outside of the Workspace.
|
|
1998
|
+
*
|
|
1999
|
+
* ℹ️ The listener is called synchronously when the tab list is measured (when it or its tabs change size, or tabs are added or removed),
|
|
2000
|
+
* before the browser paints; changes it makes to the DOM (e.g. with `flushSync`) are shown in the same frame.
|
|
2001
|
+
*
|
|
2002
|
+
* ℹ️ The listener is called with `undefined` when the tabset is removed (e.g. closed, or merged into another tabset).
|
|
2003
|
+
*
|
|
2004
|
+
* @returns A function that unsubscribes the listener
|
|
2005
|
+
*/
|
|
2006
|
+
subscribeToTabListFreeSpace: (tabsetId: string, listener: (freeSpace: number | undefined) => void) => () => void;
|
|
1761
2007
|
/**
|
|
1762
2008
|
* Update a tab; fields that are not specified are not changed.
|
|
1763
2009
|
*
|
|
@@ -1775,11 +2021,15 @@ export declare interface WorkspaceImperativeHandle<TabData = unknown, TabsetData
|
|
|
1775
2021
|
* ℹ️ `data` is replaced rather than merged.
|
|
1776
2022
|
*
|
|
1777
2023
|
* ℹ️ Setting `minHeight`, `minWidth`, or `tabPlacement` to `undefined` removes the tabset's override,
|
|
1778
|
-
* so the corresponding Workspace prop is used.
|
|
2024
|
+
* so the corresponding Workspace prop is used; setting `maxHeight` or `maxWidth` to `undefined` removes the maximum.
|
|
1779
2025
|
*/
|
|
1780
2026
|
updateTabset: (tabsetId: string, changes: {
|
|
2027
|
+
collapsible?: boolean | undefined;
|
|
1781
2028
|
data?: TabsetData;
|
|
2029
|
+
disableDrag?: boolean | undefined;
|
|
1782
2030
|
keepWhenEmpty?: boolean | undefined;
|
|
2031
|
+
maxHeight?: string | undefined;
|
|
2032
|
+
maxWidth?: string | undefined;
|
|
1783
2033
|
minHeight?: string | undefined;
|
|
1784
2034
|
minWidth?: string | undefined;
|
|
1785
2035
|
tabPlacement?: TabsetNode["tabPlacement"];
|
|
@@ -1835,9 +2085,10 @@ export declare type WorkspaceProps<TabData = unknown, TabsetData = unknown> = Om
|
|
|
1835
2085
|
* - `tabPanels`: contains a tabset's tab content (`data-tab-panels`)
|
|
1836
2086
|
* - `tabContent`: the element each tab's content is rendered into (`data-tab-content`)
|
|
1837
2087
|
* - `dropIndicator`: shows where a dragged tab will be dropped within a tabset's panels (`data-drop-indicator`)
|
|
1838
|
-
* - `dragPreview`: follows the pointer while a tab is dragged (`data-drag-preview`)
|
|
2088
|
+
* - `dragPreview`: follows the pointer while a tab or tabset is dragged (`data-drag-preview`)
|
|
1839
2089
|
*
|
|
1840
|
-
* ℹ️ Elements expose their state as data attributes (e.g. `data-tab-selected`), which can be used for styling.
|
|
2090
|
+
* ℹ️ Elements expose their state as data attributes (e.g. `data-tab-selected`, or `data-tabset-dragging` while a tabset is dragged), which can be used for styling.
|
|
2091
|
+
* Elements within a collapsed tabset have a `data-tabset-collapsed` attribute.
|
|
1841
2092
|
* Elements within a tabset also have a `data-tab-placement` attribute (see `tabPlacement`).
|
|
1842
2093
|
*
|
|
1843
2094
|
* ℹ️ Like the render props, this object is part of what tabsets re-render for;
|
|
@@ -1860,10 +2111,13 @@ export declare type WorkspaceProps<TabData = unknown, TabsetData = unknown> = Om
|
|
|
1860
2111
|
*/
|
|
1861
2112
|
disabled?: boolean | undefined;
|
|
1862
2113
|
/**
|
|
1863
|
-
* Prevents tabs from being dropped onto some (or all) targets.
|
|
2114
|
+
* Prevents tabs (and tabsets) from being dropped onto some (or all) targets.
|
|
1864
2115
|
*
|
|
1865
2116
|
* Functions are called when the target under the pointer changes;
|
|
1866
2117
|
* returning `true` rejects the target.
|
|
2118
|
+
*
|
|
2119
|
+
* ℹ️ While a tabset is dragged, this function is called for each of its tabs (see `DisableDropArgs`),
|
|
2120
|
+
* so restrictions on where tabs can be dropped apply to dragged tabsets too.
|
|
1867
2121
|
*/
|
|
1868
2122
|
disableDrop?: boolean | ((args: DisableDropArgs<TabData, TabsetData>) => boolean) | undefined;
|
|
1869
2123
|
/**
|
|
@@ -1906,6 +2160,13 @@ export declare type WorkspaceProps<TabData = unknown, TabsetData = unknown> = Om
|
|
|
1906
2160
|
* Defaults to the tab's title (or id).
|
|
1907
2161
|
*/
|
|
1908
2162
|
renderDragPreview?: ((tab: TabNode<TabData>) => ReactNode) | undefined;
|
|
2163
|
+
/**
|
|
2164
|
+
* Content of the element that follows the pointer while a whole tabset is being dragged.
|
|
2165
|
+
* Defaults to the title (or id) of its selected tab followed by the number of other tabs being dragged (e.g. "One (+2)"), or the selected tab's `renderDragPreview` when that prop is set, or the tabset's id if it has no tabs.
|
|
2166
|
+
*
|
|
2167
|
+
* ℹ️ The element has a `data-drag-type` attribute: `"tabset"` while a tabset is dragged, and `"tab"` while a tab is.
|
|
2168
|
+
*/
|
|
2169
|
+
renderTabsetDragPreview?: ((tabset: TabsetNode<TabData, TabsetData>) => ReactNode) | undefined;
|
|
1909
2170
|
/**
|
|
1910
2171
|
* Content shown in the panels of a tabset that has no tabs (e.g. "Drag a tab here"):
|
|
1911
2172
|
* the root tabset of an empty workspace, or a tabset with the `keepWhenEmpty` flag.
|
|
@@ -2004,6 +2265,18 @@ export declare type WorkspaceProps<TabData = unknown, TabsetData = unknown> = Om
|
|
|
2004
2265
|
* @default "top"
|
|
2005
2266
|
*/
|
|
2006
2267
|
tabPlacement?: "bottom" | "left" | "right" | "top" | undefined;
|
|
2268
|
+
/**
|
|
2269
|
+
* Which tab is selected when a tabset's selected tab is removed (closed, or dragged to another tabset):
|
|
2270
|
+
* - `"adjacent"`: the tab after it (or before it, if it was the last tab)
|
|
2271
|
+
* - `"recent"`: the tabset's most recently selected tab (like an IDE's editor groups),
|
|
2272
|
+
* falling back to `"adjacent"` if none of its other tabs has been selected
|
|
2273
|
+
*
|
|
2274
|
+
* ℹ️ In `"recent"` mode, each tabset's recently selected tabs are saved in the model (see `TabsetNode.recentTabIds`),
|
|
2275
|
+
* so they're restored with the rest of the layout.
|
|
2276
|
+
*
|
|
2277
|
+
* @default "adjacent"
|
|
2278
|
+
*/
|
|
2279
|
+
tabRemovalSelectionBehavior?: TabRemovalSelectionBehavior | undefined;
|
|
2007
2280
|
/**
|
|
2008
2281
|
* Minimum height of each tabset's content area (not including its header).
|
|
2009
2282
|
*
|