import React from 'react'; import PropTypes from 'prop-types'; import Panel from './Panel'; import { ComponentProps } from '../utils/types'; /** @public */ type TabLayoutChangeHandler = (event: React.MouseEvent | React.FocusEvent, data: { activePanelId?: string; }) => void; interface TabLayoutPropsBase { /** If `true`, tabs will trigger the `onChange` callback when they receive focus. */ autoActivate?: boolean; /** * Must be `TabLayout.Panel`. */ children?: React.ReactNode; /** * Sets the active panel on the initial render. It must match the `panelId` of one of * the child `TabLayout.Panel`s. Only use `defaultActivePanelId` when using `TabLayout` * as an uncontrolled component. */ defaultActivePanelId?: string; /** * A React ref which is set to the DOM element when the component mounts and null when it unmounts. */ elementRef?: React.Ref; /** * Position of icon in `TabBar.Tab` if it has an icon. Defaults to "left". * @deprecated This prop is deprecated and will be removed in the next major version. */ iconPosition?: 'above' | 'left'; /** * The layout direction for tabs. */ layout?: 'horizontal' | 'vertical'; /** Max width of each `TabBar.Tab` in pixels. Leave blank for auto max width. */ maxTabWidth?: number; /** * A callback that receives the event and data (`selectedPanelId`). If activePanelId is set, * this callback is required. */ onChange?: TabLayoutChangeHandler; /** * The `panelId` of the `TabLayout.Panel` to activate. If set, an `onChange` callback is required. */ activePanelId?: string; } interface TabLayoutPropsBaseControlled extends TabLayoutPropsBase { defaultActivePanelId?: never; onChange: TabLayoutChangeHandler; activePanelId?: string; } interface TabLayoutPropsBaseUncontrolled extends TabLayoutPropsBase { defaultActivePanelId?: string; activePanelId?: never; } type TabLayoutProps = ComponentProps; /** * The `TabLayout` is a group of managed `Panels`. Only one panel can be open at a time. * `TabLayout` supports both the controlled and uncontrolled patterns. */ declare function TabLayout({ autoActivate, activePanelId: activePanelIdProp, children, defaultActivePanelId, elementRef, iconPosition, layout, maxTabWidth, onChange, ...otherProps }: TabLayoutProps): React.JSX.Element; declare namespace TabLayout { var Panel: typeof import("./Panel").default; var propTypes: { autoActivate: PropTypes.Requireable; activePanelId: PropTypes.Requireable; children: PropTypes.Requireable; defaultActivePanelId: PropTypes.Requireable; elementRef: PropTypes.Requireable; iconPosition: PropTypes.Requireable; layout: PropTypes.Requireable; maxTabWidth: PropTypes.Requireable; onChange: PropTypes.Requireable<(...args: any[]) => any>; }; } export default TabLayout; export { Panel, TabLayoutChangeHandler };