react-resizable-panels 4.22.0 → 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.
@@ -70,6 +70,27 @@ declare type BasePanelAttributes = Omit<HTMLAttributes<HTMLDivElement>, "onResiz
70
70
 
71
71
  declare type BaseSeparatorAttributes = Omit<HTMLAttributes<HTMLDivElement>, "role" | "tabIndex">;
72
72
 
73
+ /**
74
+ * A change that the user is about to make to the model, passed to the Workspace's `onBeforeModelChange` prop.
75
+ */
76
+ export declare type BeforeModelChangeArgs<TabData = unknown, TabsetData = unknown> = {
77
+ /** The model as it will be if the change is allowed */
78
+ model: WorkspaceModel<TabData, TabsetData>;
79
+ /** The model as it is */
80
+ prevModel: WorkspaceModel<TabData, TabsetData>;
81
+ /** Which change would be made (see `WorkspaceChangedMeta.reason`) */
82
+ reason: WorkspaceChangeReason;
83
+ /**
84
+ * The tabs the change would remove from the workspace, e.g. the tab (or the tabs of the tabset) the user is closing;
85
+ * empty if it doesn't remove any.
86
+ */
87
+ removedTabs: TabNode<TabData>[];
88
+ /** For a tab (or tabset) dropped in from another workspace, that workspace's `dragSourceInfo` prop (see `WorkspaceChangedMeta.sourceInfo`) */
89
+ sourceInfo?: unknown;
90
+ /** For a tab (or tabset) dropped in from another workspace, that workspace's id (see `WorkspaceChangedMeta.sourceWorkspaceId`) */
91
+ sourceWorkspaceId?: string | undefined;
92
+ };
93
+
73
94
  /**
74
95
  * A Cell occupies one or more tracks (columns and rows) within a Grid.
75
96
  * Cells are resized along with the tracks they occupy.
@@ -159,6 +180,20 @@ export declare type DisableDropArgs<TabData = unknown, TabsetData = unknown> = {
159
180
  * - `"new"`: outside of any workspace, for a tab that's created when it's dropped (see the `startExternalDrag` method and the `acceptExternalDrop` prop)
160
181
  */
161
182
  source: "external" | "local" | "new";
183
+ /**
184
+ * The `dragSourceInfo` prop of the workspace the tab (or tabset) is dragged from (this workspace's own, for `"local"` drags);
185
+ * `undefined` for `"new"` tabs, or if that workspace doesn't have the prop.
186
+ *
187
+ * ℹ️ e.g. to only accept tabs from workspaces of the same kind, or from a version of the application whose tab data this one understands:
188
+ * `disableDrop={({ source, sourceInfo }) => source === "external" && sourceInfo?.app !== "reports"}`
189
+ */
190
+ sourceInfo: unknown;
191
+ /**
192
+ * The id of the workspace the tab (or tabset) is dragged from (see the Workspace's `id` prop); `undefined` for `"new"` tabs (and for drags from another page that uses an earlier release of this library).
193
+ *
194
+ * ⚠️ Ids are only unique within a copy of the application (e.g. ids from `useId` may be the same in another browser tab), so use `sourceInfo` to tell copies apart.
195
+ */
196
+ sourceWorkspaceId: string | undefined;
162
197
  /**
163
198
  * The tab being dropped.
164
199
  *
@@ -776,11 +811,15 @@ export declare type GroupProps = HTMLAttributes<HTMLDivElement> & {
776
811
  };
777
812
 
778
813
  /**
779
- * What happens to the content of tabs that are not selected:
814
+ * What happens to the content of tabs that aren't visible (see `ParentTabState.isVisible`), once it has been mounted (see the Workspace's `lazyTabContent` prop):
780
815
  * - `"keep-mounted"`: content stays mounted (and its effects keep running)
781
- * - `"activity"`: content stays mounted but is rendered within a hidden React `<Activity>` boundary, so its effects are unmounted;
816
+ * - `"activity"`: content stays mounted but is rendered within a hidden React `<Activity>` boundary, so its effects are unmounted (and it's re-rendered at a low priority);
782
817
  * requires React 19.2 (falls back to `"keep-mounted"` otherwise)
783
818
  * - `"unmount"`: content is unmounted
819
+ *
820
+ * ℹ️ 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).
821
+ * `"activity"` and `"unmount"` hide content when its tabset is collapsed (in the model) or covered by a maximized tabset,
822
+ * but not while it's only shown collapsed temporarily (e.g. while dragging a separator, or when collapsed to fit).
784
823
  */
785
824
  export declare type HiddenTabBehavior = "activity" | "keep-mounted" | "unmount";
786
825
 
@@ -1180,13 +1219,17 @@ export declare type ParentTab = {
1180
1219
  */
1181
1220
  export declare type ParentTabset<TabData = unknown> = {
1182
1221
  /**
1183
- * Add a tab to this tabset.
1222
+ * Add a tab to this tabset, or (with `region`) in a new tabset beside it.
1184
1223
  *
1224
+ * @param options.region Where to add the tab (see `TabDropRegion`): `"center"` adds it to this tabset, and edge regions split this tabset
1225
+ * @param options.size Size of the new tabset, for edge regions (see `WorkspaceImperativeHandle.addTab`); its space comes from this tabset, by default half of it
1185
1226
  * @return `true` if the tab was added (see `WorkspaceImperativeHandle.addTab`)
1186
1227
  */
1187
1228
  addTab: (tab: TabNode<TabData>, options?: {
1188
1229
  index?: number | undefined;
1230
+ region?: TabDropRegion | undefined;
1189
1231
  select?: boolean | undefined;
1232
+ size?: number | string | undefined;
1190
1233
  }) => boolean;
1191
1234
  /**
1192
1235
  * Close the tabset, along with any tabs it contains (see `WorkspaceImperativeHandle.closeTabset`).
@@ -1326,7 +1369,7 @@ export declare type ParentTabState = {
1326
1369
  */
1327
1370
  isSelected: boolean;
1328
1371
  /**
1329
- * The tab is selected, and its tabset is neither collapsed nor covered by another, maximized tabset.
1372
+ * The tab is selected, and its tabset is neither collapsed nor covered by another, maximized tabset (floating tabsets are shown above a maximized tabset, so they're never covered).
1330
1373
  *
1331
1374
  * ℹ️ 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),
1332
1375
  * which the model only reflects once the drag ends; it also reflects tabsets that are collapsed to fit (see `TabsetNode.collapsible`).
@@ -1672,6 +1715,8 @@ export declare type TabDropTarget = {
1672
1715
  edge: WorkspaceDropEdge;
1673
1716
  };
1674
1717
 
1718
+ declare type TabElementValue<Value, TabData> = WorkspaceElementValue<Value, [tab: TabNode<TabData>, state: ParentTabState]> | undefined;
1719
+
1675
1720
  /**
1676
1721
  * Options for which tabs count as out of view (see `useTabListOverflow`).
1677
1722
  */
@@ -1820,6 +1865,11 @@ export declare type TabsetDragHandleState = {
1820
1865
  isDisabled: boolean;
1821
1866
  };
1822
1867
 
1868
+ declare type TabsetElementValue<Value, TabData, TabsetData> = WorkspaceElementValue<Value, [
1869
+ tabset: TabsetNode<TabData, TabsetData>,
1870
+ state: ParentTabsetState
1871
+ ]> | undefined;
1872
+
1823
1873
  /**
1824
1874
  * Maximizes (or restores) the tabset it is rendered within; render it within the content returned by the Workspace's `renderTabsetToolbar` prop.
1825
1875
  * 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:
@@ -2386,6 +2436,17 @@ export declare type WorkspaceChangedMeta = {
2386
2436
  * ⚠️ New reasons may be added in later versions, so code that switches on this value should handle unrecognized values.
2387
2437
  */
2388
2438
  reason: WorkspaceChangeReason;
2439
+ /**
2440
+ * For a tab (or tabset) dropped in from another workspace (`"transfer"` and `"copy"` changes reported by the workspace it was dropped into),
2441
+ * the `dragSourceInfo` prop of that workspace (see `DisableDropArgs.sourceInfo`), e.g. to migrate the tab's data from an older version of the application.
2442
+ * `undefined` otherwise.
2443
+ */
2444
+ sourceInfo?: unknown;
2445
+ /**
2446
+ * For a tab (or tabset) dropped in from another workspace (`"transfer"` and `"copy"` changes reported by the workspace it was dropped into),
2447
+ * that workspace's id (see `DisableDropArgs.sourceWorkspaceId`). `undefined` otherwise.
2448
+ */
2449
+ sourceWorkspaceId?: string | undefined;
2389
2450
  };
2390
2451
 
2391
2452
  /**
@@ -2399,37 +2460,57 @@ export declare type WorkspaceChangeReason = "add" | "close" | "collapse" | "copy
2399
2460
 
2400
2461
  /**
2401
2462
  * CSS class names for the elements a Workspace renders (see the Workspace's `classNames` prop).
2463
+ *
2464
+ * Entries for the elements of a tabset, tab, or split can be functions of it (and its state), e.g. to style tabsets by their `data`:
2465
+ *
2466
+ * ```tsx
2467
+ * classNames={{
2468
+ * header: (tabset) => (tabset.data?.compact ? "compact-header" : undefined),
2469
+ * tab: (tab, { isSelected }) => (tab.data.isDirty && !isSelected ? "dirty-tab" : undefined)
2470
+ * }}
2471
+ * ```
2472
+ *
2473
+ * ℹ️ Functions are called when the element renders (which, for tabs, includes when their tabset re-renders);
2474
+ * keep them cheap, and (like the rest of this object) define them outside of the component or memoize them.
2402
2475
  */
2403
- export declare type WorkspaceClassNames = {
2476
+ export declare type WorkspaceClassNames<TabData = unknown, TabsetData = unknown> = {
2404
2477
  dragPreview?: string | undefined;
2405
2478
  dropIndicator?: string | undefined;
2406
2479
  /**
2407
2480
  * The element that positions each floating tabset (with a `data-floating-tabset` attribute, and a `data-tabset-collapsed` attribute while its tabset is collapsed), around the tabset itself, e.g. for a shadow.
2408
2481
  */
2409
- floatingTabset?: string | undefined;
2482
+ floatingTabset?: WorkspaceElementValue<string | undefined, [
2483
+ tabset: FloatingTabsetNode<TabData, TabsetData>,
2484
+ state: ParentTabsetState
2485
+ ]> | undefined;
2410
2486
  /**
2411
2487
  * Each of the handles along the edges (and at the corners) of a floating tabset that resize it,
2412
2488
  * with a `data-floating-resize-handle` attribute naming its edge (e.g. "bottom" or "bottom-right").
2413
2489
  *
2414
2490
  * ℹ️ The handles are positioned (and given resize cursors) by the workspace, but they're transparent.
2415
2491
  */
2416
- floatingResizeHandle?: string | undefined;
2417
- header?: string | undefined;
2492
+ floatingResizeHandle?: WorkspaceElementValue<string | undefined, [
2493
+ tabset: FloatingTabsetNode<TabData, TabsetData>,
2494
+ state: ParentTabsetState
2495
+ ]> | undefined;
2496
+ header?: TabsetElementValue<string | undefined, TabData, TabsetData>;
2418
2497
  /**
2419
2498
  * Each split (a Group with `data-split` and `data-split-id` attributes); for example, its `gap` adds space between tabsets.
2420
2499
  *
2421
2500
  * ℹ️ Gaps count toward the split's minimum size, like its separators.
2422
2501
  */
2423
- split?: string | undefined;
2424
- tab?: string | undefined;
2425
- tabContent?: string | undefined;
2426
- tabList?: string | undefined;
2427
- tabPanels?: string | undefined;
2428
- tabset?: string | undefined;
2429
- toolbar?: string | undefined;
2502
+ split?: WorkspaceElementValue<string | undefined, [
2503
+ split: SplitNode<TabData, TabsetData>
2504
+ ]> | undefined;
2505
+ tab?: TabElementValue<string | undefined, TabData>;
2506
+ tabContent?: TabElementValue<string | undefined, TabData>;
2507
+ tabList?: TabsetElementValue<string | undefined, TabData, TabsetData>;
2508
+ tabPanels?: TabsetElementValue<string | undefined, TabData, TabsetData>;
2509
+ tabset?: TabsetElementValue<string | undefined, TabData, TabsetData>;
2510
+ toolbar?: TabsetElementValue<string | undefined, TabData, TabsetData>;
2430
2511
  };
2431
2512
 
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;
2513
+ declare function WorkspaceComponent<TabData = unknown, TabsetData = unknown>({ acceptExternalDrop, className, classNames, copyTab, copyTabset, defaultModel, disabled, disableDragBetweenApps, disableDrop, dragGroup, dragSourceInfo, elementRef: elementRefProp, hiddenTabBehavior, id: idProp, lazyTabContent, onBeforeModelChange, onModelChanged, onTearOff, renderDragPreview, renderEmptyTabset, renderSeparator, renderTab, renderTabContent, renderTabsetDragPreview, renderTabsetToolbar, resizePreviewMode, serverRenderTabContent, style, styles, tabPlacement, tabRemovalSelectionBehavior, tabsetMinHeight, tabsetMinWidth, workspaceRef, ...rest }: WorkspaceProps<TabData, TabsetData>): JSX.Element;
2433
2514
 
2434
2515
  /**
2435
2516
  * Edge of the workspace.
@@ -2438,6 +2519,11 @@ declare function WorkspaceComponent<TabData = unknown, TabsetData = unknown>({ a
2438
2519
  */
2439
2520
  export declare type WorkspaceDropEdge = "bottom" | "left" | "right" | "top";
2440
2521
 
2522
+ /**
2523
+ * An entry of the Workspace's `classNames` or `styles` props: a value, or a function that returns one, given the node the element belongs to.
2524
+ */
2525
+ export declare type WorkspaceElementValue<Value, Args extends unknown[]> = Value | ((...args: Args) => Value);
2526
+
2441
2527
  /**
2442
2528
  * Imperative Workspace API.
2443
2529
  *
@@ -2447,20 +2533,30 @@ export declare type WorkspaceDropEdge = "bottom" | "left" | "right" | "top";
2447
2533
  */
2448
2534
  export declare interface WorkspaceImperativeHandle<TabData = unknown, TabsetData = unknown> {
2449
2535
  /**
2450
- * Add a tab to a tabset.
2536
+ * Add a tab to a tabset, or in a new tabset at any target `moveTab` accepts (e.g. in a new split below a tabset, or at an edge of the workspace).
2451
2537
  *
2452
2538
  * ℹ️ If a tab with the same id already exists, it is selected instead (and its data is not changed).
2453
2539
  *
2540
+ * ℹ️ A tab added in a new tabset is that tabset's selected tab (so `select` doesn't apply); like a moved tab, it's added to a floating tabset rather than splitting it.
2541
+ *
2454
2542
  * @param tab Tab to add
2455
2543
  * @param options.tabsetId Tabset to add the tab to; defaults to the active tabset
2456
2544
  * @param options.index Position within the tabset; defaults to the end
2457
2545
  * @param options.select Select the new tab; defaults to true
2546
+ * @param options.target Where to add the tab (see `TabDropTarget`); takes precedence over `tabsetId` and `index`
2547
+ * @param options.size Size of the new tabset, when `target` creates one (an edge region of a tabset, or an edge of the workspace), as its share of the split it's in.
2548
+ * Numbers are percentages (as in the model, see `TabsetNode.size`); strings may have units (e.g. `"200px"`), and are converted to percentages of the split's current size.
2549
+ * 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.
2550
+ * 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.
2551
+ * Invalid sizes (e.g. `NaN` or `"abc"`) are ignored, with a warning in development.
2458
2552
  * @return `true` if the tab was added
2459
2553
  */
2460
2554
  addTab: (tab: TabNode<TabData>, options?: {
2461
2555
  index?: number | undefined;
2462
2556
  select?: boolean | undefined;
2557
+ size?: number | string | undefined;
2463
2558
  tabsetId?: string | undefined;
2559
+ target?: TabDropTarget | undefined;
2464
2560
  }) => boolean;
2465
2561
  /**
2466
2562
  * Close a tab.
@@ -2573,6 +2669,28 @@ export declare interface WorkspaceImperativeHandle<TabData = unknown, TabsetData
2573
2669
  * 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 `"center"` region).
2574
2670
  */
2575
2671
  moveTabset: (tabsetId: string, target: TabDropTarget) => void;
2672
+ /**
2673
+ * Set the sizes of a split's children (tabsets and splits) by id, e.g. to apply a saved preset without replacing the model.
2674
+ * Reported to `onModelChanged` with the `"resize"` reason.
2675
+ *
2676
+ * e.g. `resizeSplit("root", { sidebar: 30, main: 70 })` applies a 30/70 preset, and `resizeSplit("root", { sidebar: "250px" })` makes the sidebar 250 pixels wide (at the split's current size) and gives the rest to the other children.
2677
+ * The "Sizing tabsets" docs have examples.
2678
+ *
2679
+ * Numbers are percentages. Strings may have units (e.g. `"250px"`), which are converted to a percentage of the split's current size (like the `size` option of `addTab`);
2680
+ * like the model's sizes, they scale with the workspace afterwards (see `TabsetNode.size`). A size that can't be converted (e.g. the split isn't mounted) is stored as it is.
2681
+ * Children that aren't listed share what the others leave, in proportion to their current sizes.
2682
+ * Sizes are applied like the model's sizes are, e.g. limited by tabsets' minimum and maximum sizes.
2683
+ *
2684
+ * ℹ️ A collapsed tabset's size is the size it expands to; this doesn't collapse or expand tabsets (see `collapseTabset` and `expandTabset`).
2685
+ *
2686
+ * ⚠️ Splits that don't exist, ids that aren't children of the split, and invalid sizes (e.g. `NaN` or `"abc"`) are ignored, with a warning in development.
2687
+ *
2688
+ * @param splitId Id of the split (see `SplitNode.id`)
2689
+ * @param sizes Sizes of the split's children, by child id
2690
+ */
2691
+ resizeSplit: (splitId: string, sizes: {
2692
+ [childId: string]: number | string;
2693
+ }) => void;
2576
2694
  /**
2577
2695
  * Restore the maximized tabset (if there is one).
2578
2696
  */
@@ -2760,7 +2878,7 @@ export declare type WorkspaceProps<TabData = unknown, TabsetData = unknown> = Om
2760
2878
  * ℹ️ Like the render props, this object is part of what tabsets re-render for;
2761
2879
  * in large workspaces, define it outside of the component (or memoize it) rather than inline.
2762
2880
  */
2763
- classNames?: WorkspaceClassNames | undefined;
2881
+ classNames?: WorkspaceClassNames<TabData, TabsetData> | undefined;
2764
2882
  /**
2765
2883
  * Initial layout of the workspace.
2766
2884
  *
@@ -2852,12 +2970,22 @@ export declare type WorkspaceProps<TabData = unknown, TabsetData = unknown> = Om
2852
2970
  * 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.
2853
2971
  */
2854
2972
  dragGroup?: string | undefined;
2973
+ /**
2974
+ * Information about this workspace that's sent with the tabs (and tabsets) dragged from it (see the `dragGroup` prop),
2975
+ * so that the workspaces they're dragged into can tell where they came from (see `DisableDropArgs.sourceInfo` and `WorkspaceChangedMeta.sourceInfo`),
2976
+ * e.g. `{ app: "reports", schemaVersion: 3 }`.
2977
+ *
2978
+ * ⚠️ It's sent to other copies of the application with the structured clone algorithm (like tab data; see `dragGroup`), so it must be cloneable;
2979
+ * drags whose source info can't be cloned can only be dropped within their copy of the application.
2980
+ * It's read when a drag starts, so changes during a drag don't apply to it.
2981
+ */
2982
+ dragSourceInfo?: unknown;
2855
2983
  /**
2856
2984
  * Ref attached to the root `HTMLDivElement`.
2857
2985
  */
2858
2986
  elementRef?: Ref<HTMLDivElement | null> | undefined;
2859
2987
  /**
2860
- * What happens to the content of tabs that are not selected.
2988
+ * What happens to the content of tabs that aren't visible, once it has been mounted (see `lazyTabContent`).
2861
2989
  * Can be a function to choose per tab (e.g. based on its data).
2862
2990
  *
2863
2991
  * - `"keep-mounted"`: content stays mounted (and its effects keep running)
@@ -2865,7 +2993,11 @@ export declare type WorkspaceProps<TabData = unknown, TabsetData = unknown> = Om
2865
2993
  * requires React 19.2 (falls back to `"keep-mounted"` otherwise)
2866
2994
  * - `"unmount"`: content is unmounted
2867
2995
  *
2868
- * ℹ️ Moving a tab never remounts its content.
2996
+ * ℹ️ 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);
2997
+ * so e.g. collapsing a tabset hides its selected tab's content, and maximizing one hides the others'.
2998
+ * Temporary collapsed states (e.g. while dragging a separator, or when collapsed to fit) don't hide content.
2999
+ *
3000
+ * ℹ️ Moving a tab never remounts its content (unless the move hides it and `hiddenTabBehavior` is `"unmount"`).
2869
3001
  *
2870
3002
  * ⚠️ Its React state is preserved, but its elements are moved within the document, which resets some browser state:
2871
3003
  * iframes are reloaded, playing media is paused, and focused elements are blurred.
@@ -2880,6 +3012,39 @@ export declare type WorkspaceProps<TabData = unknown, TabsetData = unknown> = Om
2880
3012
  * ℹ️ This value will also be assigned to the `id` and `data-testid` attributes (an explicit `data-testid` prop will take precedence).
2881
3013
  */
2882
3014
  id?: string | number | undefined;
3015
+ /**
3016
+ * 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);
3017
+ * otherwise every tab's content is mounted along with the workspace.
3018
+ * Can be a function to choose per tab (e.g. based on its data), e.g. `(tab) => tab.data.isExpensive`.
3019
+ *
3020
+ * Once mounted, content that isn't visible is kept mounted, hidden in an `Activity`, or unmounted, as `hiddenTabBehavior` says.
3021
+ *
3022
+ * ℹ️ 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).
3023
+ *
3024
+ * @default false
3025
+ */
3026
+ lazyTabContent?: boolean | ((tab: TabNode<TabData>) => boolean) | undefined;
3027
+ /**
3028
+ * Called before a change the user makes (e.g. closing a tab, or dropping a tab that was dragged) is applied to the model;
3029
+ * return `false` to block it, which leaves the model as it is (and `onModelChanged` isn't called).
3030
+ *
3031
+ * 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):
3032
+ * `onBeforeModelChange={({ reason }) => !isLocked || ["select", "expand", "raise", "maximize", "restore"].includes(reason)}`
3033
+ *
3034
+ * Or to keep tabs with unsaved changes from being closed (however they're closed, e.g. with their close buttons or the Delete key):
3035
+ * `onBeforeModelChange={({ reason, removedTabs }) => reason !== "close" || !removedTabs.some((tab) => tab.data.isDirty)}`
3036
+ *
3037
+ * ℹ️ 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. `closeTab`) if they confirm.
3038
+ *
3039
+ * ℹ️ Changes made with the imperative API (including the handles returned by hooks like `useParentTab`, e.g. from a custom close button) aren't passed to it, since the application makes those itself.
3040
+ * Neither is the removal of a tab (or tabset) that another workspace has accepted (see the `dragGroup` prop), or one that was torn off (see `onTearOff`),
3041
+ * since it has already been added elsewhere; use `disableDrop` (or the `disableDrag` flags) to keep tabs from being dragged out instead.
3042
+ * A workspace that a tab is dropped into can block the drop, in which case it stays in the workspace it was dragged from.
3043
+ *
3044
+ * ℹ️ Blocked resizes are undone (e.g. a separator dragged by the user moves back). Drops are blocked when the pointer is released,
3045
+ * so use `disableDrop` to show while dragging that a target doesn't accept drops.
3046
+ */
3047
+ onBeforeModelChange?: ((args: BeforeModelChangeArgs<TabData, TabsetData>) => boolean | void) | undefined;
2883
3048
  /**
2884
3049
  * Called after the model has changed (e.g. a tab was moved, selected, or closed, or a tabset was resized).
2885
3050
  *
@@ -2958,8 +3123,9 @@ export declare type WorkspaceProps<TabData = unknown, TabsetData = unknown> = Om
2958
3123
  * ⚠️ Merge `className` and `style` rather than replacing them (e.g. `style={{ ...props.style, padding: 4 }}`):
2959
3124
  * they include the `tab` entries of the `classNames` and `styles` props, and `style` includes the `touch-action` that touch dragging depends on.
2960
3125
  *
2961
- * ℹ️ Pointer and keyboard events from interactive descendants (`button` elements, `role="button"`, or elements with a `data-tab-ignore` attribute) are ignored,
2962
- * so clicking a button within a tab doesn't select or drag it.
3126
+ * ℹ️ Pointer events from interactive descendants (`button` elements, form controls such as `input` (and the `label` elements of form controls), editable content, elements with a `button` or form control role such as `role="checkbox"`, or elements with a `data-tab-ignore` attribute) are ignored,
3127
+ * so clicking a button within a tab doesn't select or drag it, and pressing within an input (e.g. one used to rename the tab) doesn't start a drag.
3128
+ * Keys pressed within any descendant (rather than the tab itself) are left to it, so they don't move focus between tabs or close the tab.
2963
3129
  *
2964
3130
  * ℹ️ When this prop is not provided, tabs show their title (or id) followed by a `TabCloseButton`.
2965
3131
  */
@@ -3007,7 +3173,7 @@ export declare type WorkspaceProps<TabData = unknown, TabsetData = unknown> = Om
3007
3173
  /**
3008
3174
  * CSS properties for the elements the workspace renders within its root element (see `classNames`).
3009
3175
  */
3010
- styles?: WorkspaceStyles | undefined;
3176
+ styles?: WorkspaceStyles<TabData, TabsetData> | undefined;
3011
3177
  /**
3012
3178
  * Where tabs are placed relative to tab content.
3013
3179
  *
@@ -3066,10 +3232,36 @@ export declare type WorkspaceProps<TabData = unknown, TabsetData = unknown> = Om
3066
3232
  };
3067
3233
 
3068
3234
  /**
3069
- * CSS properties for the elements a Workspace renders (see the Workspace's `classNames` prop).
3235
+ * CSS properties for the elements a Workspace renders (see the Workspace's `classNames` prop);
3236
+ * like class names, entries for the elements of a tabset, tab, or split can be functions of it (and its state).
3237
+ *
3238
+ * ```tsx
3239
+ * styles={{
3240
+ * tabset: (tabset) => ({ "--accent": tabset.data?.accent } as CSSProperties)
3241
+ * }}
3242
+ * ```
3070
3243
  */
3071
- export declare type WorkspaceStyles = {
3072
- [Element in keyof WorkspaceClassNames]?: CSSProperties | undefined;
3244
+ export declare type WorkspaceStyles<TabData = unknown, TabsetData = unknown> = {
3245
+ dragPreview?: CSSProperties | undefined;
3246
+ dropIndicator?: CSSProperties | undefined;
3247
+ floatingTabset?: WorkspaceElementValue<CSSProperties | undefined, [
3248
+ tabset: FloatingTabsetNode<TabData, TabsetData>,
3249
+ state: ParentTabsetState
3250
+ ]> | undefined;
3251
+ floatingResizeHandle?: WorkspaceElementValue<CSSProperties | undefined, [
3252
+ tabset: FloatingTabsetNode<TabData, TabsetData>,
3253
+ state: ParentTabsetState
3254
+ ]> | undefined;
3255
+ header?: TabsetElementValue<CSSProperties | undefined, TabData, TabsetData>;
3256
+ split?: WorkspaceElementValue<CSSProperties | undefined, [
3257
+ split: SplitNode<TabData, TabsetData>
3258
+ ]> | undefined;
3259
+ tab?: TabElementValue<CSSProperties | undefined, TabData>;
3260
+ tabContent?: TabElementValue<CSSProperties | undefined, TabData>;
3261
+ tabList?: TabsetElementValue<CSSProperties | undefined, TabData, TabsetData>;
3262
+ tabPanels?: TabsetElementValue<CSSProperties | undefined, TabData, TabsetData>;
3263
+ tabset?: TabsetElementValue<CSSProperties | undefined, TabData, TabsetData>;
3264
+ toolbar?: TabsetElementValue<CSSProperties | undefined, TabData, TabsetData>;
3073
3265
  };
3074
3266
 
3075
3267
  export { }