react-resizable-panels 4.20.0 → 4.21.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.
|
@@ -1408,6 +1408,30 @@ export declare type SplitNodeInput<TabData = unknown, TabsetData = unknown> = Om
|
|
|
1408
1408
|
id?: string | undefined;
|
|
1409
1409
|
};
|
|
1410
1410
|
|
|
1411
|
+
declare type StatefulButtonProps<State> = Omit<ButtonHTMLAttributes<HTMLButtonElement>, keyof StatefulProps<State>> & StatefulProps<State>;
|
|
1412
|
+
|
|
1413
|
+
/**
|
|
1414
|
+
* Props of the Workspace's buttons and handles (see `TabCloseButton`) whose values can depend on the component's state.
|
|
1415
|
+
*/
|
|
1416
|
+
export declare type StatefulProps<State> = {
|
|
1417
|
+
/**
|
|
1418
|
+
* Content of the element, or a function that returns it (given the component's state).
|
|
1419
|
+
*/
|
|
1420
|
+
children?: ValueOrFunction<ReactNode, State>;
|
|
1421
|
+
/**
|
|
1422
|
+
* Class name of the element, or a function that returns it (given the component's state).
|
|
1423
|
+
*/
|
|
1424
|
+
className?: ValueOrFunction<string | undefined, State>;
|
|
1425
|
+
/**
|
|
1426
|
+
* Inline styles of the element, or a function that returns them (given the component's state).
|
|
1427
|
+
*/
|
|
1428
|
+
style?: ValueOrFunction<CSSProperties | undefined, State>;
|
|
1429
|
+
/**
|
|
1430
|
+
* Tooltip of the element, or a function that returns it (given the component's state).
|
|
1431
|
+
*/
|
|
1432
|
+
title?: ValueOrFunction<string | undefined, State>;
|
|
1433
|
+
};
|
|
1434
|
+
|
|
1411
1435
|
/**
|
|
1412
1436
|
* Closes the tab it is rendered within; render it within the element returned by the Workspace's `renderTab` prop:
|
|
1413
1437
|
*
|
|
@@ -1424,6 +1448,12 @@ export declare type SplitNodeInput<TabData = unknown, TabsetData = unknown> = Om
|
|
|
1424
1448
|
* Its content defaults to "×" (e.g. it can be replaced with an icon),
|
|
1425
1449
|
* and its default `aria-label` is "Close" followed by the tab's title (or id).
|
|
1426
1450
|
*
|
|
1451
|
+
* Its `children`, `className`, `style`, and `title` can also be functions of its state (see `TabCloseButtonState`):
|
|
1452
|
+
*
|
|
1453
|
+
* ```tsx
|
|
1454
|
+
* <TabCloseButton title={({ tabTitle }) => `Close ${tabTitle}`} />
|
|
1455
|
+
* ```
|
|
1456
|
+
*
|
|
1427
1457
|
* To keep the tab open (e.g. to confirm unsaved changes first), call `event.preventDefault()` in an `onClick` handler:
|
|
1428
1458
|
*
|
|
1429
1459
|
* ```tsx
|
|
@@ -1443,9 +1473,19 @@ export declare const TabCloseButton: typeof TabCloseButtonComponent & {
|
|
|
1443
1473
|
displayName: string;
|
|
1444
1474
|
};
|
|
1445
1475
|
|
|
1446
|
-
declare function TabCloseButtonComponent({ "aria-label": ariaLabel, children, onClick, ...rest }: TabCloseButtonProps): JSX.Element | null;
|
|
1476
|
+
declare function TabCloseButtonComponent({ "aria-label": ariaLabel, children, className, onClick, style, title, ...rest }: TabCloseButtonProps): JSX.Element | null;
|
|
1477
|
+
|
|
1478
|
+
export declare type TabCloseButtonProps = StatefulButtonProps<TabCloseButtonState>;
|
|
1447
1479
|
|
|
1448
|
-
|
|
1480
|
+
/**
|
|
1481
|
+
* State of a `TabCloseButton`, passed to its function props (see `StatefulProps`).
|
|
1482
|
+
*/
|
|
1483
|
+
export declare type TabCloseButtonState = {
|
|
1484
|
+
/**
|
|
1485
|
+
* The title of the tab the button closes (or its id, if it doesn't have one).
|
|
1486
|
+
*/
|
|
1487
|
+
tabTitle: string;
|
|
1488
|
+
};
|
|
1449
1489
|
|
|
1450
1490
|
/**
|
|
1451
1491
|
* Edge (or center) of a tabset's content area.
|
|
@@ -1521,6 +1561,51 @@ export declare type TabRenderProps = Pick<HTMLAttributes<HTMLElement>, "aria-con
|
|
|
1521
1561
|
[dataAttribute: `data-${string}`]: string | boolean | undefined;
|
|
1522
1562
|
};
|
|
1523
1563
|
|
|
1564
|
+
/**
|
|
1565
|
+
* Collapses (or expands) the tabset it is rendered within; render it within the content returned by the Workspace's `renderTabsetToolbar` prop.
|
|
1566
|
+
* 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:
|
|
1567
|
+
*
|
|
1568
|
+
* ```tsx
|
|
1569
|
+
* renderTabsetToolbar={() => (
|
|
1570
|
+
* <TabsetCollapseButton title={({ isCollapsed }) => (isCollapsed ? "Expand" : "Collapse")}>
|
|
1571
|
+
* {({ isCollapsed }) => (isCollapsed ? "▸" : "▾")}
|
|
1572
|
+
* </TabsetCollapseButton>
|
|
1573
|
+
* )}
|
|
1574
|
+
* ```
|
|
1575
|
+
*
|
|
1576
|
+
* The button renders nothing if the tabset can't be collapsed (see `ParentTabsetState.isCollapsible`), or while it's maximized.
|
|
1577
|
+
* 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"`.
|
|
1578
|
+
*
|
|
1579
|
+
* Its `aria-expanded` attribute reflects whether the tabset is expanded, and its `aria-controls` attribute refers to the selected tab's panel;
|
|
1580
|
+
* its default `aria-label` ("Collapse tabset") doesn't change, since `aria-expanded` describes the state.
|
|
1581
|
+
*
|
|
1582
|
+
* To keep the tabset as it is, call `event.preventDefault()` in an `onClick` handler.
|
|
1583
|
+
*
|
|
1584
|
+
* ℹ️ Clicking a tab of a collapsed tabset also expands it.
|
|
1585
|
+
*/
|
|
1586
|
+
export declare const TabsetCollapseButton: typeof TabsetCollapseButtonComponent & {
|
|
1587
|
+
displayName: string;
|
|
1588
|
+
};
|
|
1589
|
+
|
|
1590
|
+
declare function TabsetCollapseButtonComponent({ "aria-label": ariaLabel, children, className, onClick, style, title, ...rest }: TabsetCollapseButtonProps): JSX.Element | null;
|
|
1591
|
+
|
|
1592
|
+
export declare type TabsetCollapseButtonProps = StatefulButtonProps<TabsetCollapseButtonState>;
|
|
1593
|
+
|
|
1594
|
+
/**
|
|
1595
|
+
* State of a `TabsetCollapseButton`, passed to its function props (see `StatefulProps`).
|
|
1596
|
+
*/
|
|
1597
|
+
export declare type TabsetCollapseButtonState = {
|
|
1598
|
+
/**
|
|
1599
|
+
* The tabset is collapsed to just its header (see `ParentTabsetState.isCollapsed`).
|
|
1600
|
+
*/
|
|
1601
|
+
isCollapsed: boolean;
|
|
1602
|
+
/**
|
|
1603
|
+
* The tabset is collapsed only because it doesn't fit, so it can't be expanded until it does (see `ParentTabsetState.isCollapsedToFit`);
|
|
1604
|
+
* the button is disabled (with `aria-disabled`) until then.
|
|
1605
|
+
*/
|
|
1606
|
+
isCollapsedToFit: boolean;
|
|
1607
|
+
};
|
|
1608
|
+
|
|
1524
1609
|
/**
|
|
1525
1610
|
* Drags the tabset it is rendered within; render it within the content returned by the Workspace's `renderTabsetToolbar` prop:
|
|
1526
1611
|
*
|
|
@@ -1536,14 +1621,68 @@ export declare type TabRenderProps = Pick<HTMLAttributes<HTMLElement>, "aria-con
|
|
|
1536
1621
|
* this component also sets `touch-action: none`, so that it can be dragged by touch.
|
|
1537
1622
|
*
|
|
1538
1623
|
* The handle has a `data-disabled` attribute when the tabset can't be dragged (see `useParentTabsetState`), e.g. to hide it.
|
|
1624
|
+
* Its `children`, `className`, `style`, and `title` can also be functions of its state (see `TabsetDragHandleState`):
|
|
1625
|
+
*
|
|
1626
|
+
* ```tsx
|
|
1627
|
+
* <TabsetDragHandle title={({ isDisabled }) => (isDisabled ? undefined : "Drag tabset")}>
|
|
1628
|
+
* ⠿
|
|
1629
|
+
* </TabsetDragHandle>
|
|
1630
|
+
* ```
|
|
1539
1631
|
*/
|
|
1540
1632
|
export declare const TabsetDragHandle: typeof TabsetDragHandleComponent & {
|
|
1541
1633
|
displayName: string;
|
|
1542
1634
|
};
|
|
1543
1635
|
|
|
1544
|
-
declare function TabsetDragHandleComponent({ style, ...rest }: TabsetDragHandleProps): JSX.Element;
|
|
1636
|
+
declare function TabsetDragHandleComponent({ children, className, style, title, ...rest }: TabsetDragHandleProps): JSX.Element;
|
|
1545
1637
|
|
|
1546
|
-
export declare type TabsetDragHandleProps = HTMLAttributes<HTMLDivElement>;
|
|
1638
|
+
export declare type TabsetDragHandleProps = Omit<HTMLAttributes<HTMLDivElement>, keyof StatefulProps<TabsetDragHandleState>> & StatefulProps<TabsetDragHandleState>;
|
|
1639
|
+
|
|
1640
|
+
/**
|
|
1641
|
+
* State of a `TabsetDragHandle`, passed to its function props (see `StatefulProps`).
|
|
1642
|
+
*/
|
|
1643
|
+
export declare type TabsetDragHandleState = {
|
|
1644
|
+
/**
|
|
1645
|
+
* The tabset can't be dragged (see `ParentTabsetState.isDragDisabled`).
|
|
1646
|
+
*/
|
|
1647
|
+
isDisabled: boolean;
|
|
1648
|
+
};
|
|
1649
|
+
|
|
1650
|
+
/**
|
|
1651
|
+
* Maximizes (or restores) the tabset it is rendered within; render it within the content returned by the Workspace's `renderTabsetToolbar` prop.
|
|
1652
|
+
* 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:
|
|
1653
|
+
*
|
|
1654
|
+
* ```tsx
|
|
1655
|
+
* renderTabsetToolbar={() => (
|
|
1656
|
+
* <TabsetMaximizeButton title={({ isMaximized }) => (isMaximized ? "Restore" : "Maximize")}>
|
|
1657
|
+
* {({ isMaximized }) => (isMaximized ? "Restore" : "Maximize")}
|
|
1658
|
+
* </TabsetMaximizeButton>
|
|
1659
|
+
* )}
|
|
1660
|
+
* ```
|
|
1661
|
+
*
|
|
1662
|
+
* The button renders nothing for the only tabset in a workspace (see `ParentTabsetState.isRoot`) and for floating tabsets, which can't be maximized.
|
|
1663
|
+
*
|
|
1664
|
+
* Its `aria-pressed` attribute reflects whether the tabset is maximized;
|
|
1665
|
+
* its default `aria-label` ("Maximize tabset") doesn't change, since `aria-pressed` describes the state.
|
|
1666
|
+
*
|
|
1667
|
+
* To keep the tabset as it is, call `event.preventDefault()` in an `onClick` handler.
|
|
1668
|
+
*/
|
|
1669
|
+
export declare const TabsetMaximizeButton: typeof TabsetMaximizeButtonComponent & {
|
|
1670
|
+
displayName: string;
|
|
1671
|
+
};
|
|
1672
|
+
|
|
1673
|
+
declare function TabsetMaximizeButtonComponent({ "aria-label": ariaLabel, children, className, onClick, style, title, ...rest }: TabsetMaximizeButtonProps): JSX.Element | null;
|
|
1674
|
+
|
|
1675
|
+
export declare type TabsetMaximizeButtonProps = StatefulButtonProps<TabsetMaximizeButtonState>;
|
|
1676
|
+
|
|
1677
|
+
/**
|
|
1678
|
+
* State of a `TabsetMaximizeButton`, passed to its function props (see `StatefulProps`).
|
|
1679
|
+
*/
|
|
1680
|
+
export declare type TabsetMaximizeButtonState = {
|
|
1681
|
+
/**
|
|
1682
|
+
* The tabset is maximized (see `ParentTabsetState.isMaximized`).
|
|
1683
|
+
*/
|
|
1684
|
+
isMaximized: boolean;
|
|
1685
|
+
};
|
|
1547
1686
|
|
|
1548
1687
|
/**
|
|
1549
1688
|
* A set of tabs, only one of which is shown at a time.
|
|
@@ -1947,6 +2086,11 @@ export declare function useWorkspaceCallbackRef<TabData = unknown, TabsetData =
|
|
|
1947
2086
|
*/
|
|
1948
2087
|
export declare function useWorkspaceRef<TabData = unknown, TabsetData = unknown>(): RefObject<WorkspaceImperativeHandle<TabData, TabsetData> | null>;
|
|
1949
2088
|
|
|
2089
|
+
/**
|
|
2090
|
+
* 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).
|
|
2091
|
+
*/
|
|
2092
|
+
export declare type ValueOrFunction<Value, State> = Value | ((state: State) => Value);
|
|
2093
|
+
|
|
1950
2094
|
/**
|
|
1951
2095
|
* A Workspace arranges tabsets that users can rearrange by dragging tabs:
|
|
1952
2096
|
* between tabsets, within a tabset's list of tabs, or onto the edge of a tabset to split it.
|