UNPKG

5.29 kBTypeScriptView Raw
1/// <reference types="node" />
2import * as React from 'react';
3import { PickOptional } from '../../helpers/typeUtils';
4import { OUIAProps } from '../../helpers';
5export declare enum TabsComponent {
6 div = "div",
7 nav = "nav"
8}
9export interface TabsProps extends Omit<React.HTMLProps<HTMLElement | HTMLDivElement>, 'onSelect'>, OUIAProps {
10 /** Content rendered inside the tabs component. Must be React.ReactElement<TabProps>[] */
11 children: React.ReactNode;
12 /** Additional classes added to the tabs */
13 className?: string;
14 /** Tabs background color variant */
15 variant?: 'default' | 'light300';
16 /** The index of the active tab */
17 activeKey?: number | string;
18 /** The index of the default active tab. Set this for uncontrolled Tabs */
19 defaultActiveKey?: number | string;
20 /** Callback to handle tab selection */
21 onSelect?: (event: React.MouseEvent<HTMLElement, MouseEvent>, eventKey: number | string) => void;
22 /** @beta Callback to handle tab closing */
23 onClose?: (event: React.MouseEvent<HTMLElement, MouseEvent>, eventKey: number | string) => void;
24 /** @beta Callback for the add button. Passing this property inserts the add button */
25 onAdd?: () => void;
26 /** @beta Aria-label for the add button */
27 addButtonAriaLabel?: string;
28 /** Uniquely identifies the tabs */
29 id?: string;
30 /** Enables the filled tab list layout */
31 isFilled?: boolean;
32 /** Enables secondary tab styling */
33 isSecondary?: boolean;
34 /** Enables box styling to the tab component */
35 isBox?: boolean;
36 /** Enables vertical tab styling */
37 isVertical?: boolean;
38 /** Enables border bottom tab styling on tabs. Defaults to true. To remove the bottom border, set this prop to false. */
39 hasBorderBottom?: boolean;
40 /** Enables border bottom styling for secondary tabs */
41 hasSecondaryBorderBottom?: boolean;
42 /** Aria-label for the left scroll button */
43 leftScrollAriaLabel?: string;
44 /** Aria-label for the right scroll button */
45 rightScrollAriaLabel?: string;
46 /** Determines what tag is used around the tabs. Use "nav" to define the tabs inside a navigation region */
47 component?: 'div' | 'nav';
48 /** Provides an accessible label for the tabs. Labels should be unique for each set of tabs that are present on a page. When component is set to nav, this prop should be defined to differentiate the tabs from other navigation regions on the page. */
49 'aria-label'?: string;
50 /** Waits until the first "enter" transition to mount tab children (add them to the DOM) */
51 mountOnEnter?: boolean;
52 /** Unmounts tab children (removes them from the DOM) when they are no longer visible */
53 unmountOnExit?: boolean;
54 /** Flag indicates that the tabs should use page insets. */
55 usePageInsets?: boolean;
56 /** Insets at various breakpoints. */
57 inset?: {
58 default?: 'insetNone' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl';
59 sm?: 'insetNone' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl';
60 md?: 'insetNone' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl';
61 lg?: 'insetNone' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl';
62 xl?: 'insetNone' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl';
63 '2xl'?: 'insetNone' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl';
64 };
65 /** Enable expandable vertical tabs at various breakpoints. (isVertical should be set to true for this to work) */
66 expandable?: {
67 default?: 'expandable' | 'nonExpandable';
68 sm?: 'expandable' | 'nonExpandable';
69 md?: 'expandable' | 'nonExpandable';
70 lg?: 'expandable' | 'nonExpandable';
71 xl?: 'expandable' | 'nonExpandable';
72 '2xl'?: 'expandable' | 'nonExpandable';
73 };
74 /** Flag to indicate if the vertical tabs are expanded */
75 isExpanded?: boolean;
76 /** Flag indicating the default expanded state for uncontrolled expand/collapse of */
77 defaultIsExpanded?: boolean;
78 /** Text that appears in the expandable toggle */
79 toggleText?: string;
80 /** Aria-label for the expandable toggle */
81 toggleAriaLabel?: string;
82 /** Callback function to toggle the expandable tabs. */
83 onToggle?: (isExpanded: boolean) => void;
84}
85interface TabsState {
86 showScrollButtons: boolean;
87 disableLeftScrollButton: boolean;
88 disableRightScrollButton: boolean;
89 shownKeys: (string | number)[];
90 uncontrolledActiveKey: number | string;
91 uncontrolledIsExpandedLocal: boolean;
92 ouiaStateId: string;
93}
94export declare class Tabs extends React.Component<TabsProps, TabsState> {
95 static displayName: string;
96 tabList: React.RefObject<HTMLUListElement>;
97 constructor(props: TabsProps);
98 scrollTimeout: NodeJS.Timeout;
99 static defaultProps: PickOptional<TabsProps>;
100 handleTabClick(event: React.MouseEvent<HTMLElement, MouseEvent>, eventKey: number | string, tabContentRef: React.RefObject<any>): void;
101 handleScrollButtons: () => void;
102 scrollLeft: () => void;
103 scrollRight: () => void;
104 componentDidMount(): void;
105 componentWillUnmount(): void;
106 componentDidUpdate(prevProps: TabsProps): void;
107 render(): JSX.Element;
108}
109export {};
110//# sourceMappingURL=Tabs.d.ts.map
\No newline at end of file