UNPKG

2.52 kBTypeScriptView Raw
1import React from 'react';
2import PropTypes from 'prop-types';
3import { SelectCallback, TransitionType } from './helpers';
4export interface TabContainerProps extends React.PropsWithChildren<unknown> {
5 id?: string;
6 transition?: TransitionType;
7 mountOnEnter?: boolean;
8 unmountOnExit?: boolean;
9 generateChildId?: (eventKey: unknown, type: 'tab' | 'pane') => string;
10 onSelect?: SelectCallback;
11 activeKey?: unknown;
12 defaultActiveKey?: unknown;
13}
14declare const TabContainer: {
15 (props: TabContainerProps): JSX.Element;
16 propTypes: {
17 /**
18 * HTML id attribute, required if no `generateChildId` prop
19 * is specified.
20 *
21 * @type {string}
22 */
23 id: PropTypes.Validator<string>;
24 /**
25 * Sets a default animation strategy for all children `<TabPane>`s.
26 * Defaults to `<Fade>` animation; else, use `false` to disable, or a
27 * custom react-transition-group `<Transition/>` component.
28 *
29 * @type {{Transition | false}}
30 * @default {Fade}
31 */
32 transition: PropTypes.Requireable<boolean | PropTypes.ReactComponentLike>;
33 /**
34 * Wait until the first "enter" transition to mount tabs (add them to the DOM)
35 */
36 mountOnEnter: PropTypes.Requireable<boolean>;
37 /**
38 * Unmount tabs (remove it from the DOM) when they are no longer visible
39 */
40 unmountOnExit: PropTypes.Requireable<boolean>;
41 /**
42 * A function that takes an `eventKey` and `type` and returns a unique id for
43 * child tab `<NavItem>`s and `<TabPane>`s. The function _must_ be a pure
44 * function, meaning it should always return the _same_ id for the same set
45 * of inputs. The default value requires that an `id` to be set for the
46 * `<TabContainer>`.
47 *
48 * The `type` argument will either be `"tab"` or `"pane"`.
49 *
50 * @defaultValue (eventKey, type) => `${props.id}-${type}-${eventKey}`
51 */
52 generateChildId: PropTypes.Requireable<(...args: any[]) => any>;
53 /**
54 * A callback fired when a tab is selected.
55 *
56 * @controllable activeKey
57 */
58 onSelect: PropTypes.Requireable<(...args: any[]) => any>;
59 /**
60 * The `eventKey` of the currently active tab.
61 *
62 * @controllable onSelect
63 */
64 activeKey: PropTypes.Requireable<any>;
65 };
66};
67export default TabContainer;