react-resizable-panels 4.20.0 → 4.22.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 +1027 -418
- package/dist/react-resizable-panels.cjs +2 -1
- package/dist/react-resizable-panels.cjs.map +1 -1
- package/dist/react-resizable-panels.d.ts +502 -11
- package/dist/react-resizable-panels.js +4600 -3789
- package/dist/react-resizable-panels.js.map +1 -1
- package/package.json +2 -2
|
@@ -3,12 +3,39 @@ import { CSSProperties } from 'react';
|
|
|
3
3
|
import { Dispatch } from 'react';
|
|
4
4
|
import { HTMLAttributes } from 'react';
|
|
5
5
|
import { JSX } from 'react/jsx-runtime';
|
|
6
|
+
import { PointerEvent as PointerEvent_2 } from 'react';
|
|
6
7
|
import { ReactNode } from 'react';
|
|
7
8
|
import { Ref } from 'react';
|
|
8
9
|
import { RefCallback } from 'react';
|
|
9
10
|
import { RefObject } from 'react';
|
|
10
11
|
import { SetStateAction } from 'react';
|
|
11
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Accepts drags that use the browser's drag and drop from outside of the workspace (e.g. elements with the `draggable` attribute, or files),
|
|
15
|
+
* creating a tab where they're dropped (see the Workspace's `acceptExternalDrop` prop).
|
|
16
|
+
*/
|
|
17
|
+
export declare type AcceptExternalDrop<TabData = unknown> = {
|
|
18
|
+
/**
|
|
19
|
+
* Creates the tab to add, when a drag is dropped.
|
|
20
|
+
* Returning `null` (or `undefined`) rejects the drop.
|
|
21
|
+
*
|
|
22
|
+
* ℹ️ The drag's data can be read here (e.g. with `dataTransfer.getData`), since browsers only let it be read when it's dropped.
|
|
23
|
+
*
|
|
24
|
+
* ℹ️ The tab can't be added to a workspace that already has a node with its id, and is checked by `disableDrop` (with the `"new"` source) before it's added.
|
|
25
|
+
*
|
|
26
|
+
* @param dataTransfer The drop event's `DataTransfer`
|
|
27
|
+
* @param target Where the drag was dropped
|
|
28
|
+
*/
|
|
29
|
+
createTab: (dataTransfer: DataTransfer, target: TabDropTarget) => TabNode<TabData> | null | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Drag data types (e.g. `"application/x-my-widget"`, or `"Files"` for files) that are accepted; a drag is accepted if it has any of them.
|
|
32
|
+
*
|
|
33
|
+
* ℹ️ While a drag is in progress, browsers only let its types be read (not its data), so they decide where the drop indicator is shown.
|
|
34
|
+
* Data types are compared case-insensitively, since browsers lowercase them.
|
|
35
|
+
*/
|
|
36
|
+
types: string[];
|
|
37
|
+
};
|
|
38
|
+
|
|
12
39
|
declare type BaseGridlineProps = {
|
|
13
40
|
/**
|
|
14
41
|
* Gridline contents (e.g. a drag handle icon).
|
|
@@ -118,13 +145,20 @@ export declare type CellProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
118
145
|
* and the target is rejected if any call returns `true`.
|
|
119
146
|
*/
|
|
120
147
|
export declare type DisableDropArgs<TabData = unknown, TabsetData = unknown> = {
|
|
148
|
+
/**
|
|
149
|
+
* `true` if a copy would be dropped (rather than the tab or tabset itself), since the copy modifier key is held; see the `copyTab` and `copyTabset` props.
|
|
150
|
+
*
|
|
151
|
+
* ℹ️ The tab (or tabset) passed is the one being dragged, since the copy is only made when it's dropped.
|
|
152
|
+
*/
|
|
153
|
+
isCopy: boolean;
|
|
121
154
|
model: WorkspaceModel<TabData, TabsetData>;
|
|
122
155
|
/**
|
|
123
156
|
* Where the tab (or tabset) is dragged from:
|
|
124
157
|
* - `"local"`: this workspace
|
|
125
158
|
* - `"external"`: another workspace with the same `dragGroup` (e.g. in another window)
|
|
159
|
+
* - `"new"`: outside of any workspace, for a tab that's created when it's dropped (see the `startExternalDrag` method and the `acceptExternalDrop` prop)
|
|
126
160
|
*/
|
|
127
|
-
source: "external" | "local";
|
|
161
|
+
source: "external" | "local" | "new";
|
|
128
162
|
/**
|
|
129
163
|
* The tab being dropped.
|
|
130
164
|
*
|
|
@@ -142,15 +176,45 @@ export declare type DisableDropArgs<TabData = unknown, TabsetData = unknown> = {
|
|
|
142
176
|
* State passed to the Workspace's `renderDragPreview` and `renderTabsetDragPreview` props.
|
|
143
177
|
*/
|
|
144
178
|
export declare type DragPreviewState = {
|
|
179
|
+
/**
|
|
180
|
+
* `true` while dropping would add a copy of the tab (or tabset), rather than moving it, since the copy modifier key is held; see the `copyTab` and `copyTabset` props.
|
|
181
|
+
*/
|
|
182
|
+
isCopy: boolean;
|
|
145
183
|
/**
|
|
146
184
|
* `true` while the pointer is outside of the window and releasing it would tear off the tab (or tabset);
|
|
147
185
|
* only when the Workspace has an `onTearOff` prop.
|
|
148
186
|
*
|
|
149
187
|
* ℹ️ This is never set for mouse drags when the Workspace has a `dragGroup` prop, since the pointer can't be followed outside of the window then.
|
|
188
|
+
*
|
|
189
|
+
* @deprecated Along with the Workspace's `onTearOff` prop; this will be removed in the next major version.
|
|
150
190
|
*/
|
|
151
191
|
isTearOff: boolean;
|
|
152
192
|
};
|
|
153
193
|
|
|
194
|
+
/**
|
|
195
|
+
* Options for the imperative `startExternalDrag` method.
|
|
196
|
+
*/
|
|
197
|
+
export declare type ExternalDragOptions<TabData = unknown> = {
|
|
198
|
+
/**
|
|
199
|
+
* Content of the element that follows the pointer while dragging.
|
|
200
|
+
* Defaults to what the Workspace's `renderDragPreview` prop renders for the tab (or the tab's title).
|
|
201
|
+
*/
|
|
202
|
+
preview?: ReactNode | undefined;
|
|
203
|
+
/**
|
|
204
|
+
* The tab to add where it's dropped; it's only added if the drop is accepted.
|
|
205
|
+
*
|
|
206
|
+
* ℹ️ Like tabs dragged in from other workspaces, it can't be dropped into a workspace that already has a node with its id.
|
|
207
|
+
*/
|
|
208
|
+
tab: TabNode<TabData>;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* The result of the imperative `startExternalDrag` method: where the tab was dropped (as passed to `disableDrop`), or `null` if it wasn't.
|
|
213
|
+
*/
|
|
214
|
+
export declare type ExternalDragResult = {
|
|
215
|
+
target: TabDropTarget;
|
|
216
|
+
} | null;
|
|
217
|
+
|
|
154
218
|
/**
|
|
155
219
|
* A tabset that floats above the workspace's layout (see `WorkspaceModel.floating`), e.g. a notepad that can be moved out of the way of the content beneath it.
|
|
156
220
|
*
|
|
@@ -1169,6 +1233,12 @@ export declare type ParentTabset<TabData = unknown> = {
|
|
|
1169
1233
|
* Restore the tabset if it is maximized.
|
|
1170
1234
|
*/
|
|
1171
1235
|
restore: () => void;
|
|
1236
|
+
/**
|
|
1237
|
+
* Select a tab within this tabset (e.g. from an overflow menu; see `useTabListOverflow`).
|
|
1238
|
+
*
|
|
1239
|
+
* ℹ️ This has no effect if the tab isn't in this tabset; use `WorkspaceImperativeHandle.selectTab` to select a tab in any tabset.
|
|
1240
|
+
*/
|
|
1241
|
+
selectTab: (tabId: string) => void;
|
|
1172
1242
|
/**
|
|
1173
1243
|
* Id of the Workspace that contains the tabset.
|
|
1174
1244
|
*/
|
|
@@ -1280,6 +1350,98 @@ export declare type ParentWorkspace<TabData = unknown, TabsetData = unknown> = W
|
|
|
1280
1350
|
id: string;
|
|
1281
1351
|
};
|
|
1282
1352
|
|
|
1353
|
+
/**
|
|
1354
|
+
* A popout window opened by `usePopoutWindows`.
|
|
1355
|
+
*/
|
|
1356
|
+
export declare type PopoutWindow = {
|
|
1357
|
+
/**
|
|
1358
|
+
* The element (created by the popup's document, within its body) that the popout's content is rendered into.
|
|
1359
|
+
*/
|
|
1360
|
+
container: HTMLElement;
|
|
1361
|
+
/**
|
|
1362
|
+
* Unique id of the popout (e.g. a React key).
|
|
1363
|
+
*/
|
|
1364
|
+
id: string;
|
|
1365
|
+
/**
|
|
1366
|
+
* The popup window.
|
|
1367
|
+
*/
|
|
1368
|
+
window: Window;
|
|
1369
|
+
};
|
|
1370
|
+
|
|
1371
|
+
/**
|
|
1372
|
+
* Where a popout window is on screen (in screen coordinates) and how big its content is (in pixels); see `usePopoutWindows`.
|
|
1373
|
+
*/
|
|
1374
|
+
export declare type PopoutWindowRect = {
|
|
1375
|
+
/** Height of the window's content, in pixels */
|
|
1376
|
+
height: number;
|
|
1377
|
+
/** Horizontal position of the window on the screen */
|
|
1378
|
+
screenX: number;
|
|
1379
|
+
/** Vertical position of the window on the screen */
|
|
1380
|
+
screenY: number;
|
|
1381
|
+
/** Width of the window's content, in pixels */
|
|
1382
|
+
width: number;
|
|
1383
|
+
};
|
|
1384
|
+
|
|
1385
|
+
/**
|
|
1386
|
+
* Returned by `usePopoutWindows`.
|
|
1387
|
+
*/
|
|
1388
|
+
export declare type PopoutWindows<TabData = unknown, TabsetData = unknown> = {
|
|
1389
|
+
/**
|
|
1390
|
+
* Close every popout window (without moving their tabs back to the main workspace).
|
|
1391
|
+
*/
|
|
1392
|
+
closeAll: () => void;
|
|
1393
|
+
/**
|
|
1394
|
+
* Each popout window's current model and where it is on screen, e.g. to save them (and open them again later with `open`).
|
|
1395
|
+
*
|
|
1396
|
+
* ℹ️ A popup that reports the opener's exact position as its own (e.g. in Brave) is reported where it was opened instead.
|
|
1397
|
+
*/
|
|
1398
|
+
getState: () => PopoutWindowState<TabData, TabsetData>[];
|
|
1399
|
+
/**
|
|
1400
|
+
* Open a popout window showing a model (e.g. from a button that pops out a tab, or to restore a saved popout).
|
|
1401
|
+
*
|
|
1402
|
+
* ⚠️ Browsers block popup windows that aren't opened in response to user input (e.g. a click),
|
|
1403
|
+
* and some block all but the first one opened for each input.
|
|
1404
|
+
*
|
|
1405
|
+
* @returns `true` if the window was opened, or `false` if it was blocked (or the model has no tabs, in which case no window is opened)
|
|
1406
|
+
*/
|
|
1407
|
+
open: (model: WorkspaceModelInput<TabData, TabsetData>, rect: PopoutWindowRect) => boolean;
|
|
1408
|
+
/**
|
|
1409
|
+
* The open popout windows.
|
|
1410
|
+
*/
|
|
1411
|
+
popouts: PopoutWindow[];
|
|
1412
|
+
/**
|
|
1413
|
+
* Render the popout windows' content (each into its window's container, with a portal); render the result alongside the main Workspace.
|
|
1414
|
+
*
|
|
1415
|
+
* @param renderWorkspace Renders a popout's Workspace; spread the given props onto it (along with the same `dragGroup` as the main Workspace, to drag tabs between windows)
|
|
1416
|
+
*/
|
|
1417
|
+
render: (renderWorkspace: (props: PopoutWorkspaceProps<TabData, TabsetData>, popout: PopoutWindow) => ReactNode) => ReactNode;
|
|
1418
|
+
};
|
|
1419
|
+
|
|
1420
|
+
/**
|
|
1421
|
+
* A popout window's model and where it is on screen, e.g. to save the popouts and open them again later (see `usePopoutWindows`).
|
|
1422
|
+
*/
|
|
1423
|
+
export declare type PopoutWindowState<TabData = unknown, TabsetData = unknown> = {
|
|
1424
|
+
/** The popout's current model */
|
|
1425
|
+
model: WorkspaceModel<TabData, TabsetData>;
|
|
1426
|
+
/** Where the popout is on screen, and its size */
|
|
1427
|
+
rect: PopoutWindowRect;
|
|
1428
|
+
};
|
|
1429
|
+
|
|
1430
|
+
/**
|
|
1431
|
+
* Props for the Workspace rendered into a popout window (see `PopoutWindows.render`).
|
|
1432
|
+
*
|
|
1433
|
+
* ℹ️ The popout window is closed once its workspace has no tabs left (e.g. its last tab is dragged back to the main window);
|
|
1434
|
+
* if the Workspace needs its own `onModelChanged` prop, call this one from it.
|
|
1435
|
+
*/
|
|
1436
|
+
export declare type PopoutWorkspaceProps<TabData = unknown, TabsetData = unknown> = {
|
|
1437
|
+
/** The popout's initial model */
|
|
1438
|
+
defaultModel: WorkspaceModel<TabData, TabsetData>;
|
|
1439
|
+
/** Closes the popout window once its workspace has no tabs left */
|
|
1440
|
+
onModelChanged: (model: WorkspaceModel<TabData, TabsetData>, meta: WorkspaceChangedMeta) => void;
|
|
1441
|
+
/** Used to read the popout's current model (e.g. when it's closed) */
|
|
1442
|
+
workspaceRef: RefObject<WorkspaceImperativeHandle<TabData, TabsetData> | null>;
|
|
1443
|
+
};
|
|
1444
|
+
|
|
1283
1445
|
declare type ResizePreviewMode = "panel" | "separator";
|
|
1284
1446
|
|
|
1285
1447
|
/**
|
|
@@ -1408,6 +1570,30 @@ export declare type SplitNodeInput<TabData = unknown, TabsetData = unknown> = Om
|
|
|
1408
1570
|
id?: string | undefined;
|
|
1409
1571
|
};
|
|
1410
1572
|
|
|
1573
|
+
declare type StatefulButtonProps<State> = Omit<ButtonHTMLAttributes<HTMLButtonElement>, keyof StatefulProps<State>> & StatefulProps<State>;
|
|
1574
|
+
|
|
1575
|
+
/**
|
|
1576
|
+
* Props of the Workspace's buttons and handles (see `TabCloseButton`) whose values can depend on the component's state.
|
|
1577
|
+
*/
|
|
1578
|
+
export declare type StatefulProps<State> = {
|
|
1579
|
+
/**
|
|
1580
|
+
* Content of the element, or a function that returns it (given the component's state).
|
|
1581
|
+
*/
|
|
1582
|
+
children?: ValueOrFunction<ReactNode, State>;
|
|
1583
|
+
/**
|
|
1584
|
+
* Class name of the element, or a function that returns it (given the component's state).
|
|
1585
|
+
*/
|
|
1586
|
+
className?: ValueOrFunction<string | undefined, State>;
|
|
1587
|
+
/**
|
|
1588
|
+
* Inline styles of the element, or a function that returns them (given the component's state).
|
|
1589
|
+
*/
|
|
1590
|
+
style?: ValueOrFunction<CSSProperties | undefined, State>;
|
|
1591
|
+
/**
|
|
1592
|
+
* Tooltip of the element, or a function that returns it (given the component's state).
|
|
1593
|
+
*/
|
|
1594
|
+
title?: ValueOrFunction<string | undefined, State>;
|
|
1595
|
+
};
|
|
1596
|
+
|
|
1411
1597
|
/**
|
|
1412
1598
|
* Closes the tab it is rendered within; render it within the element returned by the Workspace's `renderTab` prop:
|
|
1413
1599
|
*
|
|
@@ -1424,6 +1610,12 @@ export declare type SplitNodeInput<TabData = unknown, TabsetData = unknown> = Om
|
|
|
1424
1610
|
* Its content defaults to "×" (e.g. it can be replaced with an icon),
|
|
1425
1611
|
* and its default `aria-label` is "Close" followed by the tab's title (or id).
|
|
1426
1612
|
*
|
|
1613
|
+
* Its `children`, `className`, `style`, and `title` can also be functions of its state (see `TabCloseButtonState`):
|
|
1614
|
+
*
|
|
1615
|
+
* ```tsx
|
|
1616
|
+
* <TabCloseButton title={({ tabTitle }) => `Close ${tabTitle}`} />
|
|
1617
|
+
* ```
|
|
1618
|
+
*
|
|
1427
1619
|
* To keep the tab open (e.g. to confirm unsaved changes first), call `event.preventDefault()` in an `onClick` handler:
|
|
1428
1620
|
*
|
|
1429
1621
|
* ```tsx
|
|
@@ -1443,9 +1635,19 @@ export declare const TabCloseButton: typeof TabCloseButtonComponent & {
|
|
|
1443
1635
|
displayName: string;
|
|
1444
1636
|
};
|
|
1445
1637
|
|
|
1446
|
-
declare function TabCloseButtonComponent({ "aria-label": ariaLabel, children, onClick, ...rest }: TabCloseButtonProps): JSX.Element | null;
|
|
1638
|
+
declare function TabCloseButtonComponent({ "aria-label": ariaLabel, children, className, onClick, style, title, ...rest }: TabCloseButtonProps): JSX.Element | null;
|
|
1447
1639
|
|
|
1448
|
-
export declare type TabCloseButtonProps =
|
|
1640
|
+
export declare type TabCloseButtonProps = StatefulButtonProps<TabCloseButtonState>;
|
|
1641
|
+
|
|
1642
|
+
/**
|
|
1643
|
+
* State of a `TabCloseButton`, passed to its function props (see `StatefulProps`).
|
|
1644
|
+
*/
|
|
1645
|
+
export declare type TabCloseButtonState = {
|
|
1646
|
+
/**
|
|
1647
|
+
* The title of the tab the button closes (or its id, if it doesn't have one).
|
|
1648
|
+
*/
|
|
1649
|
+
tabTitle: string;
|
|
1650
|
+
};
|
|
1449
1651
|
|
|
1450
1652
|
/**
|
|
1451
1653
|
* Edge (or center) of a tabset's content area.
|
|
@@ -1470,6 +1672,17 @@ export declare type TabDropTarget = {
|
|
|
1470
1672
|
edge: WorkspaceDropEdge;
|
|
1471
1673
|
};
|
|
1472
1674
|
|
|
1675
|
+
/**
|
|
1676
|
+
* Options for which tabs count as out of view (see `useTabListOverflow`).
|
|
1677
|
+
*/
|
|
1678
|
+
export declare type TabListOverflowOptions = {
|
|
1679
|
+
/**
|
|
1680
|
+
* Also include tabs that are only partly visible (cut off by an edge of the tab list), e.g. for an overflow menu that lists them too.
|
|
1681
|
+
* By default, only tabs that are entirely out of view are included.
|
|
1682
|
+
*/
|
|
1683
|
+
includePartiallyVisible?: boolean | undefined;
|
|
1684
|
+
};
|
|
1685
|
+
|
|
1473
1686
|
/**
|
|
1474
1687
|
* A tab within a tabset.
|
|
1475
1688
|
*/
|
|
@@ -1521,6 +1734,51 @@ export declare type TabRenderProps = Pick<HTMLAttributes<HTMLElement>, "aria-con
|
|
|
1521
1734
|
[dataAttribute: `data-${string}`]: string | boolean | undefined;
|
|
1522
1735
|
};
|
|
1523
1736
|
|
|
1737
|
+
/**
|
|
1738
|
+
* Collapses (or expands) the tabset it is rendered within; render it within the content returned by the Workspace's `renderTabsetToolbar` prop.
|
|
1739
|
+
* Its `children`, `className`, `style`, and `title` can be functions of its state (see `TabsetCollapseButtonState`), e.g. to show a different icon while the tabset is collapsed:
|
|
1740
|
+
*
|
|
1741
|
+
* ```tsx
|
|
1742
|
+
* renderTabsetToolbar={() => (
|
|
1743
|
+
* <TabsetCollapseButton title={({ isCollapsed }) => (isCollapsed ? "Expand" : "Collapse")}>
|
|
1744
|
+
* {({ isCollapsed }) => (isCollapsed ? "▸" : "▾")}
|
|
1745
|
+
* </TabsetCollapseButton>
|
|
1746
|
+
* )}
|
|
1747
|
+
* ```
|
|
1748
|
+
*
|
|
1749
|
+
* The button renders nothing if the tabset can't be collapsed (see `ParentTabsetState.isCollapsible`), or while it's maximized.
|
|
1750
|
+
* While the tabset is collapsed only because it doesn't fit (see `ParentTabsetState.isCollapsedToFit`), it can't be expanded, so the button has `aria-disabled="true"`.
|
|
1751
|
+
*
|
|
1752
|
+
* Its `aria-expanded` attribute reflects whether the tabset is expanded, and its `aria-controls` attribute refers to the selected tab's panel;
|
|
1753
|
+
* its default `aria-label` ("Collapse tabset") doesn't change, since `aria-expanded` describes the state.
|
|
1754
|
+
*
|
|
1755
|
+
* To keep the tabset as it is, call `event.preventDefault()` in an `onClick` handler.
|
|
1756
|
+
*
|
|
1757
|
+
* ℹ️ Clicking a tab of a collapsed tabset also expands it.
|
|
1758
|
+
*/
|
|
1759
|
+
export declare const TabsetCollapseButton: typeof TabsetCollapseButtonComponent & {
|
|
1760
|
+
displayName: string;
|
|
1761
|
+
};
|
|
1762
|
+
|
|
1763
|
+
declare function TabsetCollapseButtonComponent({ "aria-label": ariaLabel, children, className, onClick, style, title, ...rest }: TabsetCollapseButtonProps): JSX.Element | null;
|
|
1764
|
+
|
|
1765
|
+
export declare type TabsetCollapseButtonProps = StatefulButtonProps<TabsetCollapseButtonState>;
|
|
1766
|
+
|
|
1767
|
+
/**
|
|
1768
|
+
* State of a `TabsetCollapseButton`, passed to its function props (see `StatefulProps`).
|
|
1769
|
+
*/
|
|
1770
|
+
export declare type TabsetCollapseButtonState = {
|
|
1771
|
+
/**
|
|
1772
|
+
* The tabset is collapsed to just its header (see `ParentTabsetState.isCollapsed`).
|
|
1773
|
+
*/
|
|
1774
|
+
isCollapsed: boolean;
|
|
1775
|
+
/**
|
|
1776
|
+
* The tabset is collapsed only because it doesn't fit, so it can't be expanded until it does (see `ParentTabsetState.isCollapsedToFit`);
|
|
1777
|
+
* the button is disabled (with `aria-disabled`) until then.
|
|
1778
|
+
*/
|
|
1779
|
+
isCollapsedToFit: boolean;
|
|
1780
|
+
};
|
|
1781
|
+
|
|
1524
1782
|
/**
|
|
1525
1783
|
* Drags the tabset it is rendered within; render it within the content returned by the Workspace's `renderTabsetToolbar` prop:
|
|
1526
1784
|
*
|
|
@@ -1536,14 +1794,68 @@ export declare type TabRenderProps = Pick<HTMLAttributes<HTMLElement>, "aria-con
|
|
|
1536
1794
|
* this component also sets `touch-action: none`, so that it can be dragged by touch.
|
|
1537
1795
|
*
|
|
1538
1796
|
* The handle has a `data-disabled` attribute when the tabset can't be dragged (see `useParentTabsetState`), e.g. to hide it.
|
|
1797
|
+
* Its `children`, `className`, `style`, and `title` can also be functions of its state (see `TabsetDragHandleState`):
|
|
1798
|
+
*
|
|
1799
|
+
* ```tsx
|
|
1800
|
+
* <TabsetDragHandle title={({ isDisabled }) => (isDisabled ? undefined : "Drag tabset")}>
|
|
1801
|
+
* ⠿
|
|
1802
|
+
* </TabsetDragHandle>
|
|
1803
|
+
* ```
|
|
1539
1804
|
*/
|
|
1540
1805
|
export declare const TabsetDragHandle: typeof TabsetDragHandleComponent & {
|
|
1541
1806
|
displayName: string;
|
|
1542
1807
|
};
|
|
1543
1808
|
|
|
1544
|
-
declare function TabsetDragHandleComponent({ style, ...rest }: TabsetDragHandleProps): JSX.Element;
|
|
1809
|
+
declare function TabsetDragHandleComponent({ children, className, style, title, ...rest }: TabsetDragHandleProps): JSX.Element;
|
|
1545
1810
|
|
|
1546
|
-
export declare type TabsetDragHandleProps = HTMLAttributes<HTMLDivElement>;
|
|
1811
|
+
export declare type TabsetDragHandleProps = Omit<HTMLAttributes<HTMLDivElement>, keyof StatefulProps<TabsetDragHandleState>> & StatefulProps<TabsetDragHandleState>;
|
|
1812
|
+
|
|
1813
|
+
/**
|
|
1814
|
+
* State of a `TabsetDragHandle`, passed to its function props (see `StatefulProps`).
|
|
1815
|
+
*/
|
|
1816
|
+
export declare type TabsetDragHandleState = {
|
|
1817
|
+
/**
|
|
1818
|
+
* The tabset can't be dragged (see `ParentTabsetState.isDragDisabled`).
|
|
1819
|
+
*/
|
|
1820
|
+
isDisabled: boolean;
|
|
1821
|
+
};
|
|
1822
|
+
|
|
1823
|
+
/**
|
|
1824
|
+
* Maximizes (or restores) the tabset it is rendered within; render it within the content returned by the Workspace's `renderTabsetToolbar` prop.
|
|
1825
|
+
* Its `children`, `className`, `style`, and `title` can be functions of its state (see `TabsetMaximizeButtonState`), e.g. to show a different icon while the tabset is maximized:
|
|
1826
|
+
*
|
|
1827
|
+
* ```tsx
|
|
1828
|
+
* renderTabsetToolbar={() => (
|
|
1829
|
+
* <TabsetMaximizeButton title={({ isMaximized }) => (isMaximized ? "Restore" : "Maximize")}>
|
|
1830
|
+
* {({ isMaximized }) => (isMaximized ? "Restore" : "Maximize")}
|
|
1831
|
+
* </TabsetMaximizeButton>
|
|
1832
|
+
* )}
|
|
1833
|
+
* ```
|
|
1834
|
+
*
|
|
1835
|
+
* The button renders nothing for the only tabset in a workspace (see `ParentTabsetState.isRoot`) and for floating tabsets, which can't be maximized.
|
|
1836
|
+
*
|
|
1837
|
+
* Its `aria-pressed` attribute reflects whether the tabset is maximized;
|
|
1838
|
+
* its default `aria-label` ("Maximize tabset") doesn't change, since `aria-pressed` describes the state.
|
|
1839
|
+
*
|
|
1840
|
+
* To keep the tabset as it is, call `event.preventDefault()` in an `onClick` handler.
|
|
1841
|
+
*/
|
|
1842
|
+
export declare const TabsetMaximizeButton: typeof TabsetMaximizeButtonComponent & {
|
|
1843
|
+
displayName: string;
|
|
1844
|
+
};
|
|
1845
|
+
|
|
1846
|
+
declare function TabsetMaximizeButtonComponent({ "aria-label": ariaLabel, children, className, onClick, style, title, ...rest }: TabsetMaximizeButtonProps): JSX.Element | null;
|
|
1847
|
+
|
|
1848
|
+
export declare type TabsetMaximizeButtonProps = StatefulButtonProps<TabsetMaximizeButtonState>;
|
|
1849
|
+
|
|
1850
|
+
/**
|
|
1851
|
+
* State of a `TabsetMaximizeButton`, passed to its function props (see `StatefulProps`).
|
|
1852
|
+
*/
|
|
1853
|
+
export declare type TabsetMaximizeButtonState = {
|
|
1854
|
+
/**
|
|
1855
|
+
* The tabset is maximized (see `ParentTabsetState.isMaximized`).
|
|
1856
|
+
*/
|
|
1857
|
+
isMaximized: boolean;
|
|
1858
|
+
};
|
|
1547
1859
|
|
|
1548
1860
|
/**
|
|
1549
1861
|
* A set of tabs, only one of which is shown at a time.
|
|
@@ -1704,6 +2016,10 @@ export declare type TabsetNodeInput<TabData = unknown, TabsetData = unknown> = O
|
|
|
1704
2016
|
/**
|
|
1705
2017
|
* Arguments passed to the Workspace's `onTearOff` prop: the tab (or whole tabset) dropped outside of the window,
|
|
1706
2018
|
* and a model for showing it in a new workspace (e.g. in a popup window).
|
|
2019
|
+
*
|
|
2020
|
+
* @deprecated Browsers don't reliably report where a drag that leaves the window ends (so a popup can't be opened where the tab was released),
|
|
2021
|
+
* and some block popups opened at the end of a drag. Open popout windows from a button instead (see `usePopoutWindows`).
|
|
2022
|
+
* This will be removed in the next major version.
|
|
1707
2023
|
*/
|
|
1708
2024
|
export declare type TearOffArgs<TabData = unknown, TabsetData = unknown> = ({
|
|
1709
2025
|
/**
|
|
@@ -1924,6 +2240,60 @@ export declare function useParentTabState(): ParentTabState | null;
|
|
|
1924
2240
|
*/
|
|
1925
2241
|
export declare function useParentWorkspace<TabData = unknown, TabsetData = unknown>(): ParentWorkspace<TabData, TabsetData> | null;
|
|
1926
2242
|
|
|
2243
|
+
/**
|
|
2244
|
+
* Opens tabs (and tabsets) in popout windows, with the returned `open` function (e.g. from a button that pops out a tab).
|
|
2245
|
+
* Each popout window shows its own Workspace, rendered by the returned `render` function.
|
|
2246
|
+
*
|
|
2247
|
+
* - The page's stylesheets are copied into each popout window (see `copyStyles`)
|
|
2248
|
+
* - When the user closes a popout window, its tabs are moved back to the main workspace (see `onClose`)
|
|
2249
|
+
* - A popout window is closed once its last tab is moved out of it (e.g. dragged back to the main window; see the Workspace's `dragGroup` prop)
|
|
2250
|
+
* - Popout windows are closed when the page that opened them is closed, or the component that uses this hook unmounts (since it renders their content); see `onCloseAll`
|
|
2251
|
+
*/
|
|
2252
|
+
export declare function usePopoutWindows<TabData = unknown, TabsetData = unknown>(options: UsePopoutWindowsOptions<TabData, TabsetData>): PopoutWindows<TabData, TabsetData>;
|
|
2253
|
+
|
|
2254
|
+
/**
|
|
2255
|
+
* Options for `usePopoutWindows`.
|
|
2256
|
+
*/
|
|
2257
|
+
export declare type UsePopoutWindowsOptions<TabData = unknown, TabsetData = unknown> = {
|
|
2258
|
+
/**
|
|
2259
|
+
* Copy the page's stylesheets into each popout window when it's opened (and stylesheets added to the page's head afterward).
|
|
2260
|
+
* Defaults to `true`; if `false`, none of the page's styles (including plain stylesheets) are copied.
|
|
2261
|
+
*
|
|
2262
|
+
* ℹ️ The rules of `<style>` elements are copied (including rules inserted with `CSSStyleSheet.insertRule`, e.g. by CSS-in-JS libraries)
|
|
2263
|
+
* as they are when the window opens; rules inserted into them later (and stylesheets edited or removed afterward) aren't.
|
|
2264
|
+
* Libraries that insert rules as components render (e.g. Emotion) can usually be configured to insert them into the popup's document instead.
|
|
2265
|
+
*/
|
|
2266
|
+
copyStyles?: boolean | undefined;
|
|
2267
|
+
/**
|
|
2268
|
+
* Called with each popout window's model and position when the page that opened them is closed (or reloaded),
|
|
2269
|
+
* or the component that uses the hook unmounts, just before the popout windows are closed;
|
|
2270
|
+
* e.g. to save them (and open them again later with `open`).
|
|
2271
|
+
* It isn't called if there are no popout windows.
|
|
2272
|
+
*/
|
|
2273
|
+
onCloseAll?: ((state: PopoutWindowState<TabData, TabsetData>[]) => void) | undefined;
|
|
2274
|
+
/**
|
|
2275
|
+
* What happens to the tabs in a popout window when the user closes it:
|
|
2276
|
+
* - `"dock"` (the default) adds them back to the main workspace (see `workspaceRef`)
|
|
2277
|
+
* - `"discard"` closes them
|
|
2278
|
+
* - A function is called with the popout's model instead (e.g. to save its tabs)
|
|
2279
|
+
*
|
|
2280
|
+
* ℹ️ When docking, a tab is skipped (with a development warning) if the main workspace already has a tab with the same id (its data is not updated, and it isn't selected),
|
|
2281
|
+
* and only the selected tab of the popout's first tabset (that has one) is selected.
|
|
2282
|
+
*
|
|
2283
|
+
* ℹ️ It isn't called when the popout closes because its last tab was moved out of it, or when it's closed by `closeAll`
|
|
2284
|
+
* (or because the page that opened it is closed, or the component that uses this hook unmounts; see `onCloseAll`).
|
|
2285
|
+
*/
|
|
2286
|
+
onClose?: "discard" | "dock" | ((model: WorkspaceModel<TabData, TabsetData>) => void) | undefined;
|
|
2287
|
+
/**
|
|
2288
|
+
* Called when a popout window is opened, before its content is rendered, e.g. to set its title or style its container.
|
|
2289
|
+
*/
|
|
2290
|
+
onOpen?: ((popout: PopoutWindow) => void) | undefined;
|
|
2291
|
+
/**
|
|
2292
|
+
* The main workspace, which tabs are added back to when a popout window is closed (see `onClose`).
|
|
2293
|
+
*/
|
|
2294
|
+
workspaceRef: RefObject<WorkspaceImperativeHandle<TabData, TabsetData> | null>;
|
|
2295
|
+
};
|
|
2296
|
+
|
|
1927
2297
|
/**
|
|
1928
2298
|
* Returns the space (in pixels) in the nearest ancestor tabset's tab list that its tabs don't use (negative once they overflow),
|
|
1929
2299
|
* e.g. for a toolbar (see `renderTabsetToolbar`) that moves items into an overflow menu when the tabset's header runs out of room;
|
|
@@ -1935,6 +2305,19 @@ export declare function useParentWorkspace<TabData = unknown, TabsetData = unkno
|
|
|
1935
2305
|
*/
|
|
1936
2306
|
export declare function useTabListFreeSpace(): number | undefined;
|
|
1937
2307
|
|
|
2308
|
+
/**
|
|
2309
|
+
* Returns the ids of the nearest ancestor tabset's tabs that are out of view (scrolled out of its tab list, which overflows),
|
|
2310
|
+
* in the order they're shown; e.g. for an overflow menu in its toolbar (see `renderTabsetToolbar`) that lists them.
|
|
2311
|
+
* See `WorkspaceImperativeHandle.getTabListOverflow`.
|
|
2312
|
+
*
|
|
2313
|
+
* ℹ️ The component re-renders when they change (e.g. when the tab list is scrolled or resized, or tabs are added or removed), before the browser paints.
|
|
2314
|
+
* The same array is returned until then.
|
|
2315
|
+
*
|
|
2316
|
+
* @param options.includePartiallyVisible Also include tabs that are only partly visible (cut off by an edge of the tab list)
|
|
2317
|
+
* @returns The ids of the tabs that are out of view; none 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)
|
|
2318
|
+
*/
|
|
2319
|
+
export declare function useTabListOverflow({ includePartiallyVisible }?: TabListOverflowOptions): string[];
|
|
2320
|
+
|
|
1938
2321
|
/**
|
|
1939
2322
|
* Convenience hook to return a properly typed ref callback for the Workspace component.
|
|
1940
2323
|
*
|
|
@@ -1947,6 +2330,11 @@ export declare function useWorkspaceCallbackRef<TabData = unknown, TabsetData =
|
|
|
1947
2330
|
*/
|
|
1948
2331
|
export declare function useWorkspaceRef<TabData = unknown, TabsetData = unknown>(): RefObject<WorkspaceImperativeHandle<TabData, TabsetData> | null>;
|
|
1949
2332
|
|
|
2333
|
+
/**
|
|
2334
|
+
* A prop that's either a value or a function that returns one, given the state of the component (e.g. whether a tabset is collapsed).
|
|
2335
|
+
*/
|
|
2336
|
+
export declare type ValueOrFunction<Value, State> = Value | ((state: State) => Value);
|
|
2337
|
+
|
|
1950
2338
|
/**
|
|
1951
2339
|
* A Workspace arranges tabsets that users can rearrange by dragging tabs:
|
|
1952
2340
|
* between tabsets, within a tabset's list of tabs, or onto the edge of a tabset to split it.
|
|
@@ -1989,6 +2377,9 @@ export declare type WorkspaceChangedMeta = {
|
|
|
1989
2377
|
* ℹ️ A tab (or tabset) dragged to another workspace (see the `dragGroup` prop) is reported as `"transfer"` by both workspaces:
|
|
1990
2378
|
* the one it was dropped into (which added it) and the one it was dragged from (which removed it).
|
|
1991
2379
|
*
|
|
2380
|
+
* ℹ️ A copy of a tab (or tabset) dropped while the copy modifier key was held (see the `copyTab` and `copyTabset` props) is reported as `"copy"` by the workspace it was dropped into;
|
|
2381
|
+
* the workspace it was dragged from (if that's another one) doesn't change.
|
|
2382
|
+
*
|
|
1992
2383
|
* ℹ️ Floating tabsets (see `WorkspaceModel.floating`) are reported as `"float"` when they're created, `"move"` and `"resize"` when they're dragged by their headers and edges,
|
|
1993
2384
|
* and `"raise"` when they're brought to the front (e.g. by pressing one that's behind another).
|
|
1994
2385
|
*
|
|
@@ -2001,8 +2392,10 @@ export declare type WorkspaceChangedMeta = {
|
|
|
2001
2392
|
* Which change caused `onModelChanged` to be called.
|
|
2002
2393
|
*
|
|
2003
2394
|
* ⚠️ New reasons may be added in later versions.
|
|
2395
|
+
*
|
|
2396
|
+
* ℹ️ `"tear-off"` is only reported with the deprecated `onTearOff` prop, and will be removed along with it.
|
|
2004
2397
|
*/
|
|
2005
|
-
export declare type WorkspaceChangeReason = "add" | "close" | "collapse" | "expand" | "float" | "maximize" | "move" | "raise" | "resize" | "restore" | "select" | "set-model" | "tear-off" | "transfer" | "update";
|
|
2398
|
+
export declare type WorkspaceChangeReason = "add" | "close" | "collapse" | "copy" | "expand" | "float" | "maximize" | "move" | "raise" | "resize" | "restore" | "select" | "set-model" | "tear-off" | "transfer" | "update";
|
|
2006
2399
|
|
|
2007
2400
|
/**
|
|
2008
2401
|
* CSS class names for the elements a Workspace renders (see the Workspace's `classNames` prop).
|
|
@@ -2036,7 +2429,7 @@ export declare type WorkspaceClassNames = {
|
|
|
2036
2429
|
toolbar?: string | undefined;
|
|
2037
2430
|
};
|
|
2038
2431
|
|
|
2039
|
-
declare function WorkspaceComponent<TabData = unknown, TabsetData = unknown>({ className, classNames, defaultModel, disabled, disableDragBetweenApps, disableDrop, dragGroup, elementRef: elementRefProp, hiddenTabBehavior, id: idProp, onModelChanged, onTearOff, renderDragPreview, renderEmptyTabset, renderSeparator, renderTab, renderTabContent, renderTabsetDragPreview, renderTabsetToolbar, resizePreviewMode, serverRenderTabContent, style, styles, tabPlacement, tabRemovalSelectionBehavior, tabsetMinHeight, tabsetMinWidth, workspaceRef, ...rest }: WorkspaceProps<TabData, TabsetData>): JSX.Element;
|
|
2432
|
+
declare function WorkspaceComponent<TabData = unknown, TabsetData = unknown>({ acceptExternalDrop, className, classNames, copyTab, copyTabset, defaultModel, disabled, disableDragBetweenApps, disableDrop, dragGroup, elementRef: elementRefProp, hiddenTabBehavior, id: idProp, onModelChanged, onTearOff, renderDragPreview, renderEmptyTabset, renderSeparator, renderTab, renderTabContent, renderTabsetDragPreview, renderTabsetToolbar, resizePreviewMode, serverRenderTabContent, style, styles, tabPlacement, tabRemovalSelectionBehavior, tabsetMinHeight, tabsetMinWidth, workspaceRef, ...rest }: WorkspaceProps<TabData, TabsetData>): JSX.Element;
|
|
2040
2433
|
|
|
2041
2434
|
/**
|
|
2042
2435
|
* Edge of the workspace.
|
|
@@ -2139,6 +2532,19 @@ export declare interface WorkspaceImperativeHandle<TabData = unknown, TabsetData
|
|
|
2139
2532
|
* or right after the tabset is first rendered: it's measured after React commits, before the browser paints)
|
|
2140
2533
|
*/
|
|
2141
2534
|
getTabListFreeSpace: (tabsetId: string) => number | undefined;
|
|
2535
|
+
/**
|
|
2536
|
+
* Ids of a tabset's tabs that are out of view (scrolled out of its tab list, which overflows), in the order they're shown;
|
|
2537
|
+
* e.g. to list them in an overflow menu.
|
|
2538
|
+
*
|
|
2539
|
+
* ℹ️ The same array is returned until the tabs out of view change.
|
|
2540
|
+
* Tabs that aren't rendered at all (e.g. hidden with `display: none`) aren't included.
|
|
2541
|
+
*
|
|
2542
|
+
* ℹ️ Within a tabset (e.g. its toolbar), the `useTabListOverflow` hook returns this value (and re-renders when it changes).
|
|
2543
|
+
*
|
|
2544
|
+
* @returns The ids of the tabs that are out of view, or `undefined` if the tabset isn't rendered (or hasn't been measured yet, e.g. while server rendering,
|
|
2545
|
+
* or right after the tabset is first rendered: it's measured after React commits, before the browser paints)
|
|
2546
|
+
*/
|
|
2547
|
+
getTabListOverflow: (tabsetId: string, options?: TabListOverflowOptions) => string[] | undefined;
|
|
2142
2548
|
/**
|
|
2143
2549
|
* Maximize a tabset, so that it covers the rest of the workspace.
|
|
2144
2550
|
*
|
|
@@ -2173,6 +2579,8 @@ export declare interface WorkspaceImperativeHandle<TabData = unknown, TabsetData
|
|
|
2173
2579
|
restoreTabset: () => void;
|
|
2174
2580
|
/**
|
|
2175
2581
|
* Select a tab within its tabset.
|
|
2582
|
+
*
|
|
2583
|
+
* ℹ️ Like a tab selected any other way, it's scrolled into view if its tab list overflows.
|
|
2176
2584
|
*/
|
|
2177
2585
|
selectTab: (tabId: string) => void;
|
|
2178
2586
|
/**
|
|
@@ -2181,6 +2589,24 @@ export declare interface WorkspaceImperativeHandle<TabData = unknown, TabsetData
|
|
|
2181
2589
|
* @return Applied model (after normalization)
|
|
2182
2590
|
*/
|
|
2183
2591
|
setModel: (model: WorkspaceModelInput<TabData, TabsetData>) => WorkspaceModel<TabData, TabsetData>;
|
|
2592
|
+
/**
|
|
2593
|
+
* Start dragging a tab that isn't in the workspace yet, from an element outside of it (e.g. an item in a palette of widgets);
|
|
2594
|
+
* call it from the element's `pointerdown` handler.
|
|
2595
|
+
* The tab is dragged like tabs within the workspace are (with the same drop targets, drop indicator, and `disableDrop` checks, with the `"new"` source),
|
|
2596
|
+
* and is added where it's dropped (reported to `onModelChanged` with the `"add"` reason).
|
|
2597
|
+
*
|
|
2598
|
+
* The drag starts once the pointer has moved a few pixels, so a press that doesn't move (e.g. a click) does nothing;
|
|
2599
|
+
* the click that follows a drag is suppressed. Pressing Escape cancels the drag.
|
|
2600
|
+
*
|
|
2601
|
+
* ℹ️ Unlike other imperative methods, the drop is restricted by `disabled` and `disableDrop`, since the user chooses where it goes.
|
|
2602
|
+
*
|
|
2603
|
+
* ℹ️ The element must be in the same document as the workspace.
|
|
2604
|
+
* Like tabs, it should have `touch-action: none` (e.g. with CSS), so that touch input drags it rather than scrolling the page.
|
|
2605
|
+
*
|
|
2606
|
+
* @param event The `pointerdown` event of the pressed element
|
|
2607
|
+
* @return A promise that resolves when the drag ends: with where the tab was dropped, or `null` if it wasn't (e.g. the pointer isn't pressed or the press isn't the primary button, the drag was canceled, or it was released outside of the workspace)
|
|
2608
|
+
*/
|
|
2609
|
+
startExternalDrag: (event: PointerEvent | PointerEvent_2<Element>, options: ExternalDragOptions<TabData>) => Promise<ExternalDragResult>;
|
|
2184
2610
|
/**
|
|
2185
2611
|
* Subscribe to changes to the free space in a tabset's tab list (see `getTabListFreeSpace`),
|
|
2186
2612
|
* e.g. from a toolbar rendered outside of the Workspace.
|
|
@@ -2193,6 +2619,18 @@ export declare interface WorkspaceImperativeHandle<TabData = unknown, TabsetData
|
|
|
2193
2619
|
* @returns A function that unsubscribes the listener
|
|
2194
2620
|
*/
|
|
2195
2621
|
subscribeToTabListFreeSpace: (tabsetId: string, listener: (freeSpace: number | undefined) => void) => () => void;
|
|
2622
|
+
/**
|
|
2623
|
+
* Subscribe to changes to which of a tabset's tabs are out of view (see `getTabListOverflow`),
|
|
2624
|
+
* e.g. from an overflow menu rendered outside of the Workspace.
|
|
2625
|
+
*
|
|
2626
|
+
* ℹ️ The listener is called synchronously when the tab list is measured (when it's scrolled, when it or its tabs change size, or when tabs are added or removed),
|
|
2627
|
+
* before the browser paints, except while the user scrolls the list (it's reported in the scroll event, and the browser may show the new position first).
|
|
2628
|
+
*
|
|
2629
|
+
* ℹ️ The listener is called with `undefined` when the tabset is removed (e.g. closed, or merged into another tabset).
|
|
2630
|
+
*
|
|
2631
|
+
* @returns A function that unsubscribes the listener
|
|
2632
|
+
*/
|
|
2633
|
+
subscribeToTabListOverflow: (tabsetId: string, listener: (tabIds: string[] | undefined) => void, options?: TabListOverflowOptions) => () => void;
|
|
2196
2634
|
/**
|
|
2197
2635
|
* Update a tab; fields that are not specified are not changed.
|
|
2198
2636
|
*
|
|
@@ -2280,6 +2718,20 @@ export declare type WorkspaceNode<TabData = unknown, TabsetData = unknown> = Spl
|
|
|
2280
2718
|
export declare type WorkspaceNodeInput<TabData = unknown, TabsetData = unknown> = SplitNodeInput<TabData, TabsetData> | TabsetNodeInput<TabData, TabsetData>;
|
|
2281
2719
|
|
|
2282
2720
|
export declare type WorkspaceProps<TabData = unknown, TabsetData = unknown> = Omit<HTMLAttributes<HTMLDivElement>, "children" | "defaultValue"> & {
|
|
2721
|
+
/**
|
|
2722
|
+
* Lets the workspace accept drags that use the browser's drag and drop from outside of any workspace
|
|
2723
|
+
* (e.g. an element of the application with the `draggable` attribute, a file, or a link from another application),
|
|
2724
|
+
* showing the drop indicator while the drag is over the workspace, and creating a tab where it's dropped.
|
|
2725
|
+
* The new tab is reported to `onModelChanged` with the `"add"` reason.
|
|
2726
|
+
*
|
|
2727
|
+
* ℹ️ `disableDrop` can't be called until the tab is created (when the drag is dropped), so a target it rejects is shown as accepted while dragging;
|
|
2728
|
+
* the drop is ignored then. Drag sources within the application can use the imperative `startExternalDrag` method instead, which doesn't have this limitation.
|
|
2729
|
+
*
|
|
2730
|
+
* ℹ️ Elements within the workspace's tab content that handle the same drags themselves (by canceling the `dragover` and `drop` events) take precedence.
|
|
2731
|
+
*
|
|
2732
|
+
* ℹ️ This object is read when drag events are handled, so it doesn't need to be memoized.
|
|
2733
|
+
*/
|
|
2734
|
+
acceptExternalDrop?: AcceptExternalDrop<TabData> | undefined;
|
|
2283
2735
|
/**
|
|
2284
2736
|
* CSS class name.
|
|
2285
2737
|
*/
|
|
@@ -2317,6 +2769,42 @@ export declare type WorkspaceProps<TabData = unknown, TabsetData = unknown> = Om
|
|
|
2317
2769
|
* ℹ️ This value is only used when the Workspace mounts; use the imperative `setModel` method to replace it later.
|
|
2318
2770
|
*/
|
|
2319
2771
|
defaultModel: WorkspaceModelInput<TabData, TabsetData>;
|
|
2772
|
+
/**
|
|
2773
|
+
* Lets tabs be copied by dragging them: a tab dropped while the copy modifier key is held (Option on macOS, Ctrl elsewhere) adds the copy this function returns,
|
|
2774
|
+
* leaving the dragged tab where it was. The change is reported to `onModelChanged` with the `"copy"` reason.
|
|
2775
|
+
*
|
|
2776
|
+
* Returning `null` (or `undefined`) moves the dragged tab instead. If that move isn't allowed either (the `disableDrop` prop rejects it, the ids conflict, or it isn't a valid place to move the tab), nothing happens.
|
|
2777
|
+
*
|
|
2778
|
+
* ℹ️ The copy needs an id that isn't used by any other node of the workspace (e.g. `crypto.randomUUID()`); copies with ids that are in use are rejected (and the tab is moved instead).
|
|
2779
|
+
*
|
|
2780
|
+
* ℹ️ The workspace the tab is dropped into makes the copy, so a tab dragged from another workspace (see the `dragGroup` prop) is copied by the workspace it's dropped into
|
|
2781
|
+
* (and is only copied if that workspace has this prop).
|
|
2782
|
+
*
|
|
2783
|
+
* @param tab The tab being dragged
|
|
2784
|
+
* @param target Where the copy will be dropped
|
|
2785
|
+
*/
|
|
2786
|
+
copyTab?: ((tab: TabNode<TabData>, target: TabDropTarget) => TabNode<TabData> | null | undefined) | undefined;
|
|
2787
|
+
/**
|
|
2788
|
+
* Lets tabsets be copied by dragging them (by their headers), like the `copyTab` prop does for tabs: a tabset dropped while the copy modifier key is held adds the copy this function returns,
|
|
2789
|
+
* leaving the dragged tabset where it was. The change is reported to `onModelChanged` with the `"copy"` reason.
|
|
2790
|
+
*
|
|
2791
|
+
* The copy includes its tabs, which need ids that aren't used by any other node of the workspace too; the `copyTab` argument copies a tab:
|
|
2792
|
+
*
|
|
2793
|
+
* ```tsx
|
|
2794
|
+
* copyTabset={(tabset, copyTab) => ({ ...tabset, id: crypto.randomUUID(), tabs: tabset.tabs.map(copyTab) })}
|
|
2795
|
+
* ```
|
|
2796
|
+
*
|
|
2797
|
+
* Returning `null` (or `undefined`) moves the dragged tabset instead. If that move isn't allowed either (the `disableDrop` prop rejects it, the ids conflict, a `keepWhenEmpty` tabset is dropped into another workspace, or it isn't a valid place to move the tabset), nothing happens.
|
|
2798
|
+
*
|
|
2799
|
+
* ℹ️ The copy's selected tab is the copy of the dragged tabset's selected tab (matched by position), unless the copy selects one of its own tabs.
|
|
2800
|
+
*
|
|
2801
|
+
* ℹ️ A copy dropped into a tab list (or onto the center of another tabset) only adds its tabs; its id and data are only used where it's added as a tabset.
|
|
2802
|
+
*
|
|
2803
|
+
* @param tabset The tabset being dragged
|
|
2804
|
+
* @param copyTab Copies a tab with the `copyTab` prop (and the same drop target); without that prop (or if it returns `null`), the copy is a shallow copy of the tab with a new id
|
|
2805
|
+
* @param target Where the copy will be dropped
|
|
2806
|
+
*/
|
|
2807
|
+
copyTabset?: ((tabset: TabsetNode<TabData, TabsetData>, copyTab: (tab: TabNode<TabData>) => TabNode<TabData>, target: TabDropTarget) => TabsetNode<TabData, TabsetData> | null | undefined) | undefined;
|
|
2320
2808
|
/**
|
|
2321
2809
|
* Locks the arrangement: tabs cannot be resized, dragged, dropped, or closed by the user.
|
|
2322
2810
|
* Selecting tabs and maximizing tabsets still work.
|
|
@@ -2362,8 +2850,6 @@ export declare type WorkspaceProps<TabData = unknown, TabsetData = unknown> = Om
|
|
|
2362
2850
|
* ⚠️ A tab dragged to another copy of the application is sent there with the structured clone algorithm (like `postMessage`), so its data must be cloneable (e.g. no functions);
|
|
2363
2851
|
* tabs whose data can't be cloned (and tabsets containing them) can only be dragged within their copy of the application.
|
|
2364
2852
|
* 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.
|
|
2365
|
-
*
|
|
2366
|
-
* ⚠️ Tabs (and tabsets) can still be torn off (see `onTearOff`), but some browsers (e.g. Safari) block popup windows opened at the end of a drag that uses the browser's drag and drop.
|
|
2367
2853
|
*/
|
|
2368
2854
|
dragGroup?: string | undefined;
|
|
2369
2855
|
/**
|
|
@@ -2415,13 +2901,18 @@ export declare type WorkspaceProps<TabData = unknown, TabsetData = unknown> = Om
|
|
|
2415
2901
|
* ℹ️ This is called while the release of the pointer is being handled (which browsers treat as user input), so a popup can be opened from it.
|
|
2416
2902
|
* With the `dragGroup` prop, a tab is torn off when it's dropped outside of every window in the group; the end of those drags isn't treated as user input,
|
|
2417
2903
|
* so browsers block popups opened then unless the drag started a few seconds earlier at most (and Safari blocks them always).
|
|
2904
|
+
*
|
|
2905
|
+
* ⚠️ Deprecated: browsers don't reliably report where a drag that leaves the window ends, and some block popups opened at the end of a drag.
|
|
2906
|
+
* Open popout windows from a button instead (see `usePopoutWindows`). This will be removed in the next major version.
|
|
2907
|
+
*
|
|
2908
|
+
* @deprecated Open popout windows from a button instead (see `usePopoutWindows`).
|
|
2418
2909
|
*/
|
|
2419
2910
|
onTearOff?: ((args: TearOffArgs<TabData, TabsetData>) => boolean) | undefined;
|
|
2420
2911
|
/**
|
|
2421
2912
|
* Content of the element that follows the pointer while a tab is being dragged.
|
|
2422
2913
|
* Defaults to the tab's title (or id).
|
|
2423
2914
|
*
|
|
2424
|
-
* ℹ️ The element has a `data-tear-off` attribute while releasing the pointer would tear off the tab (see `onTearOff`).
|
|
2915
|
+
* ℹ️ The element has a `data-tear-off` attribute while releasing the pointer would tear off the tab (see the deprecated `onTearOff` prop).
|
|
2425
2916
|
*/
|
|
2426
2917
|
renderDragPreview?: ((tab: TabNode<TabData>, state: DragPreviewState) => ReactNode) | undefined;
|
|
2427
2918
|
/**
|
|
@@ -2429,7 +2920,7 @@ export declare type WorkspaceProps<TabData = unknown, TabsetData = unknown> = Om
|
|
|
2429
2920
|
* 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.
|
|
2430
2921
|
*
|
|
2431
2922
|
* ℹ️ The element has a `data-drag-type` attribute: `"tabset"` while a tabset is dragged, and `"tab"` while a tab is.
|
|
2432
|
-
* It also has a `data-tear-off` attribute while releasing the pointer would tear off the tabset (see `onTearOff`).
|
|
2923
|
+
* It also has a `data-tear-off` attribute while releasing the pointer would tear off the tabset (see the deprecated `onTearOff` prop).
|
|
2433
2924
|
*/
|
|
2434
2925
|
renderTabsetDragPreview?: ((tabset: TabsetNode<TabData, TabsetData>, state: DragPreviewState) => ReactNode) | undefined;
|
|
2435
2926
|
/**
|