UNPKG

2.8 kBTypeScriptView Raw
1import * as React from 'react';
2import {StyletronComponent} from 'styletron-react';
3import {Override} from '../overrides';
4
5// constants
6
7export enum ORIENTATION {
8 horizontal = 'horizontal',
9 vertical = 'vertical',
10}
11
12export enum FILL {
13 intrinsic = 'intrinsic',
14 fixed = 'fixed',
15}
16
17export enum STATE_CHANGE_TYPE {
18 change = 'change',
19}
20
21// utils
22
23export const getTabId: (uid: string, key: React.Key) => string;
24export const getTabPanelId: (uid: string, key: React.Key) => string;
25export const isHorizontal: (orientation: ORIENTATION) => boolean;
26export const isVertical: (orientation: ORIENTATION) => boolean;
27export const isIntrinsic: (fill: FILL) => boolean;
28export const isFixed: (fill: FILL) => boolean;
29export const isRTL: (direction: string) => boolean;
30
31// styled-components
32
33export const StyledRoot: StyletronComponent<any>;
34export const StyledTabList: StyletronComponent<any>;
35export const StyledTab: StyletronComponent<any>;
36export const StyledArtworkContainer: StyletronComponent<any>;
37export const StyledTabBorder: StyletronComponent<any>;
38export const StyledTabHighlight: StyletronComponent<any>;
39export const StyledTabPanel: StyletronComponent<any>;
40
41// tabs
42
43interface TabsOverrides {
44 Root?: Override<{
45 $orientation?: ORIENTATION;
46 }>;
47 TabList?: Override<{
48 $fill?: FILL;
49 $orientation?: ORIENTATION;
50 }>;
51 TabHighlight?: Override<{
52 $orientation?: ORIENTATION;
53 $length?: number;
54 $distance?: number;
55 $animate?: boolean;
56 }>;
57 TabBorder?: Override<{
58 $orientation?: ORIENTATION;
59 }>;
60}
61
62interface TabsProps {
63 children: React.ReactNode;
64 activeKey?: React.Key;
65 disabled?: boolean;
66 fill?: FILL[keyof FILL];
67 orientation?: ORIENTATION[keyof ORIENTATION];
68 activateOnFocus?: boolean;
69 renderAll?: boolean;
70 onChange?: (params: {activeKey: React.Key}) => void;
71 overrides?: TabsOverrides;
72}
73
74export const Tabs: React.FC<TabsProps>;
75
76// tab
77
78interface TabOverrides {
79 Tab?: Override<{
80 $fill?: FILL;
81 $orientation?: ORIENTATION;
82 $focusVisible?: boolean;
83 }>;
84 ArtworkContainer?: Override<{
85 $orientation?: ORIENTATION;
86 }>;
87 TabPanel?: Override<{
88 $pad?: boolean;
89 }>;
90}
91
92interface TabProps {
93 title?: React.ReactNode;
94 key?: React.Key;
95 tabRef?: React.MutableRefObject<HTMLButtonElement | undefined>;
96 overrides?: TabOverrides;
97 artwork?: React.ReactNode;
98 children?: React.ReactNode;
99}
100
101export const Tab: React.FC<TabProps>;
102
103// stateful-tabs
104
105interface State {
106 activeKey: React.Key;
107}
108
109interface Action {
110 type: STATE_CHANGE_TYPE[keyof STATE_CHANGE_TYPE];
111 payload: React.Key;
112}
113
114type StateReducer = (state: State, action: Action) => State;
115
116type StatefulTabsProps = TabsProps & {
117 initialState?: State;
118 stateReducer?: StateReducer;
119};
120
121export const StatefulTabs: React.FC<StatefulTabsProps>;