UNPKG

2.26 kBTypeScriptView Raw
1import type React from 'react';
2import type { CSSMotionProps } from 'rc-motion';
3import type { TabNavListProps } from './TabNavList';
4import type { TabPaneProps } from './TabPanelList/TabPane';
5export type SizeInfo = [width: number, height: number];
6export type TabSizeMap = Map<React.Key, {
7 width: number;
8 height: number;
9 left: number;
10 top: number;
11}>;
12export interface TabOffset {
13 width: number;
14 height: number;
15 left: number;
16 right: number;
17 top: number;
18}
19export type TabOffsetMap = Map<React.Key, TabOffset>;
20export type TabPosition = 'left' | 'right' | 'top' | 'bottom';
21export interface Tab extends Omit<TabPaneProps, 'tab'> {
22 key: string;
23 label: React.ReactNode;
24}
25type RenderTabBarProps = {
26 id: string;
27 activeKey: string;
28 animated: AnimatedConfig;
29 tabPosition: TabPosition;
30 rtl: boolean;
31 mobile: boolean;
32 editable: EditableConfig;
33 locale: TabsLocale;
34 moreIcon: React.ReactNode;
35 moreTransitionName: string;
36 tabBarGutter: number;
37 onTabClick: (key: string, e: React.MouseEvent | React.KeyboardEvent) => void;
38 onTabScroll: OnTabScroll;
39 extra: TabBarExtraContent;
40 style: React.CSSProperties;
41 /** @deprecated It do not pass real TabPane node. Only for compatible usage. */
42 panes: React.ReactNode;
43};
44export type RenderTabBar = (props: RenderTabBarProps, DefaultTabBar: React.ComponentType<TabNavListProps>) => React.ReactElement;
45export interface TabsLocale {
46 dropdownAriaLabel?: string;
47 removeAriaLabel?: string;
48 addAriaLabel?: string;
49}
50export interface EditableConfig {
51 onEdit: (type: 'add' | 'remove', info: {
52 key?: string;
53 event: React.MouseEvent | React.KeyboardEvent;
54 }) => void;
55 showAdd?: boolean;
56 removeIcon?: React.ReactNode;
57 addIcon?: React.ReactNode;
58}
59export interface AnimatedConfig {
60 inkBar?: boolean;
61 tabPane?: boolean;
62 tabPaneMotion?: CSSMotionProps;
63}
64export type OnTabScroll = (info: {
65 direction: 'left' | 'right' | 'top' | 'bottom';
66}) => void;
67export type TabBarExtraPosition = 'left' | 'right';
68export type TabBarExtraMap = Partial<Record<TabBarExtraPosition, React.ReactNode>>;
69export type TabBarExtraContent = React.ReactNode | TabBarExtraMap;
70export {};