interface.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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' | 'slash';
  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. interface TabsDropDownProps {
  17. start: DropdownProps;
  18. end: DropdownProps
  19. }
  20. export interface TabsProps {
  21. activeKey?: string;
  22. children?: ReactNode | Array<ReactNode>;
  23. className?: string;
  24. collapsible?: boolean;
  25. contentStyle?: CSSProperties;
  26. defaultActiveKey?: string;
  27. keepDOM?: boolean;
  28. lazyRender?: boolean;
  29. onChange?: (activeKey: string) => void;
  30. onTabClick?: (activeKey: string, e: MouseEvent<Element>) => void;
  31. renderTabBar?: (tabBarProps: TabBarProps, defaultTabBar: typeof TabBar) => ReactNode;
  32. showRestInDropdown?: boolean;
  33. size?: TabSize;
  34. style?: CSSProperties;
  35. tabBarClassName?: string;
  36. tabBarExtraContent?: ReactNode;
  37. tabBarStyle?: CSSProperties;
  38. tabList?: PlainTab[];
  39. tabPaneMotion?: boolean;
  40. tabPosition?: TabPosition;
  41. type?: TabType;
  42. onTabClose?: (tabKey: string) => void;
  43. preventScroll?: boolean;
  44. more?: number | { count: number; render?: () => ReactNode; dropdownProps?: DropdownProps };
  45. onVisibleTabsChange?: TabBarProps["onVisibleTabsChange"];
  46. visibleTabsStyle?: TabBarProps['visibleTabsStyle'];
  47. arrowPosition?: TabBarProps['arrowPosition'];
  48. renderArrow?: TabBarProps['renderArrow'];
  49. dropdownProps?: TabsDropDownProps
  50. }
  51. export interface TabBarProps {
  52. activeKey?: string;
  53. className?: string;
  54. collapsible?: boolean;
  55. list?: Array<PlainTab>;
  56. onTabClick?: (activeKey: string, event: MouseEvent<Element>) => void;
  57. showRestInDropdown?: boolean;
  58. size?: TabSize;
  59. style?: CSSProperties;
  60. tabBarExtraContent?: ReactNode;
  61. tabPosition?: TabPosition;
  62. type?: TabType;
  63. dropdownClassName?: string;
  64. dropdownStyle?: CSSProperties;
  65. closable?: boolean;
  66. deleteTabItem?: (tabKey: string, event: MouseEvent<Element>) => void;
  67. handleKeyDown?: (event: React.KeyboardEvent, itemKey: string, closable: boolean) => void;
  68. more?: TabsProps['more'];
  69. onVisibleTabsChange?: (visibleState: Map<string, boolean>) => void;
  70. visibleTabsStyle?: CSSProperties;
  71. arrowPosition?: OverflowListProps['overflowRenderDirection'];
  72. renderArrow?: (items: OverflowItem[], pos: "start"|"end", handleArrowClick: () => void, defaultNode: ReactNode) => ReactNode;
  73. dropdownProps?: TabsDropDownProps
  74. }
  75. export interface TabPaneProps {
  76. className?: string;
  77. children?: React.ReactNode;
  78. disabled?: boolean;
  79. icon?: ReactNode;
  80. itemKey?: string;
  81. style?: CSSProperties;
  82. tab?: ReactNode;
  83. closable?: boolean;
  84. tabIndex?: number
  85. }
  86. export interface TabPaneTransitionProps {
  87. [key: string]: any;
  88. children?: ((p: { transform?: string; opacity: number }) => ReactNode | undefined) | undefined;
  89. direction?: boolean;
  90. mode?: 'vertical' | 'horizontal';
  91. motion?: Motion
  92. }
  93. export interface TabContextValue {
  94. activeKey?: string;
  95. lazyRender?: boolean;
  96. panes?: Array<PlainTab>;
  97. tabPaneMotion?: boolean;
  98. tabPosition?: TabPosition;
  99. prevActiveKey?: string | null;
  100. forceDisableMotion?: boolean
  101. }