interface.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import React, { ComponentType, CSSProperties, MouseEvent, ReactNode } from 'react';
  2. import { Motion } from '../_base/base';
  3. import TabBar, { OverflowItem } from './TabBar';
  4. import { DropdownProps } from "../dropdown";
  5. import { OverflowListProps } from "../overflowList";
  6. export type TabType = 'line' | 'card' | 'button';
  7. export type TabSize = 'small' | 'medium' | 'large';
  8. export type TabPosition = 'top' | 'left';
  9. export interface PlainTab {
  10. disabled?: boolean;
  11. icon?: ReactNode;
  12. itemKey: string;
  13. tab?: ReactNode;
  14. closable?: boolean
  15. }
  16. export interface TabsProps {
  17. activeKey?: string;
  18. children?: ReactNode | Array<ReactNode>;
  19. className?: string;
  20. collapsible?: boolean;
  21. contentStyle?: CSSProperties;
  22. defaultActiveKey?: string;
  23. keepDOM?: boolean;
  24. lazyRender?: boolean;
  25. onChange?: (activeKey: string) => void;
  26. onTabClick?: (activeKey: string, e: MouseEvent<Element>) => void;
  27. renderTabBar?: (tabBarProps: TabBarProps, defaultTabBar: typeof TabBar) => ReactNode;
  28. size?: TabSize;
  29. style?: CSSProperties;
  30. tabBarClassName?: string;
  31. tabBarExtraContent?: ReactNode;
  32. tabBarStyle?: CSSProperties;
  33. tabList?: PlainTab[];
  34. tabPaneMotion?: boolean;
  35. tabPosition?: TabPosition;
  36. type?: TabType;
  37. onTabClose?: (tabKey: string) => void;
  38. preventScroll?: boolean;
  39. more?: number | { count: number; render?: () => ReactNode; dropdownProps?: DropdownProps };
  40. overflowVisibleStateChange?: TabBarProps["overflowVisibleStateChange"];
  41. collapsibleWrapperStyle?: TabBarProps['collapsibleWrapperStyle'];
  42. arrowRenderPosition?: TabBarProps['arrowRenderPosition'];
  43. renderArrow?: TabBarProps['renderArrow']
  44. }
  45. export interface TabBarProps {
  46. activeKey?: string;
  47. className?: string;
  48. collapsible?: boolean;
  49. list?: Array<PlainTab>;
  50. onTabClick?: (activeKey: string, event: MouseEvent<Element>) => void;
  51. size?: TabSize;
  52. style?: CSSProperties;
  53. tabBarExtraContent?: ReactNode;
  54. tabPosition?: TabPosition;
  55. type?: TabType;
  56. dropdownClassName?: string;
  57. dropdownStyle?: CSSProperties;
  58. closable?: boolean;
  59. deleteTabItem?: (tabKey: string, event: MouseEvent<Element>) => void;
  60. handleKeyDown?: (event: React.KeyboardEvent, itemKey: string, closable: boolean) => void;
  61. more?: TabsProps['more'];
  62. overflowVisibleStateChange?: (visibleState: Map<string, boolean>) => void;
  63. collapsibleWrapperStyle?: CSSProperties;
  64. arrowRenderPosition?: OverflowListProps['overflowRenderDirection'];
  65. renderArrow?: (items: OverflowItem[], pos: "start"|"end", handleArrowClick: () => void) => ReactNode
  66. }
  67. export interface TabPaneProps {
  68. className?: string;
  69. children?: React.ReactNode;
  70. disabled?: boolean;
  71. icon?: ReactNode;
  72. itemKey?: string;
  73. style?: CSSProperties;
  74. tab?: ReactNode;
  75. closable?: boolean;
  76. tabIndex?: number
  77. }
  78. export interface TabPaneTransitionProps {
  79. [key: string]: any;
  80. children?: ((p: { transform?: string; opacity: number }) => ReactNode | undefined) | undefined;
  81. direction?: boolean;
  82. mode?: 'vertical' | 'horizontal';
  83. motion?: Motion
  84. }
  85. export interface TabContextValue {
  86. activeKey?: string;
  87. lazyRender?: boolean;
  88. panes?: Array<PlainTab>;
  89. tabPaneMotion?: boolean;
  90. tabPosition?: TabPosition;
  91. prevActiveKey?: string | null;
  92. forceDisableMotion?: boolean
  93. }