interface.d.ts 2.4 KB

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