UNPKG

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