interface.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import React, { ComponentType, CSSProperties, MouseEvent, ReactNode } from 'react';
  2. import { Motion } from '../_base/base';
  3. export type TabType = 'line' | 'card' | 'button';
  4. export type TabSize = 'small' | 'medium' | 'large';
  5. export type TabPosition = 'top' | 'left';
  6. export interface PlainTab {
  7. disabled?: boolean;
  8. icon?: ReactNode;
  9. itemKey: string;
  10. tab?: ReactNode;
  11. closable?: boolean;
  12. }
  13. export interface TabsProps {
  14. activeKey?: string;
  15. children?: ReactNode | Array<ReactNode>;
  16. className?: string;
  17. collapsible?: boolean;
  18. contentStyle?: CSSProperties;
  19. defaultActiveKey?: string;
  20. keepDOM?: boolean;
  21. lazyRender?: boolean;
  22. onChange?: (activeKey: string) => void;
  23. onTabClick?: (activeKey: string, e: MouseEvent<Element>) => void;
  24. renderTabBar?: (tabBarProps: TabBarProps, defaultTabBar: ComponentType) => ReactNode;
  25. size?: TabSize;
  26. style?: CSSProperties;
  27. tabBarClassName?: string;
  28. tabBarExtraContent?: ReactNode;
  29. tabBarStyle?: CSSProperties;
  30. tabList?: PlainTab[];
  31. tabPaneMotion?: boolean;
  32. tabPosition?: TabPosition;
  33. type?: TabType;
  34. onTabClose?: (tabKey: string) => void;
  35. preventScroll?: boolean;
  36. }
  37. export interface TabBarProps {
  38. activeKey?: string;
  39. className?: string;
  40. collapsible?: boolean;
  41. list?: Array<PlainTab>;
  42. onTabClick?: (activeKey: string, event: MouseEvent<Element>) => void;
  43. size?: TabSize;
  44. style?: CSSProperties;
  45. tabBarExtraContent?: ReactNode;
  46. tabPosition?: TabPosition;
  47. type?: TabType;
  48. dropdownClassName?: string;
  49. dropdownStyle?: CSSProperties;
  50. closable?: boolean;
  51. deleteTabItem?: (tabKey: string, event: MouseEvent<Element>) => void;
  52. handleKeyDown?: (event: React.KeyboardEvent, itemKey: string, closable: boolean) => void;
  53. }
  54. export interface TabPaneProps {
  55. className?: string;
  56. children?: React.ReactNode | undefined;
  57. disabled?: boolean;
  58. icon?: ReactNode;
  59. itemKey?: string;
  60. style?: CSSProperties;
  61. tab?: ReactNode;
  62. closable?: boolean,
  63. }
  64. export interface TabPaneTransitionProps {
  65. [key: string]: any;
  66. children?: ((p: { transform?: string; opacity: number }) => ReactNode | undefined) | undefined;
  67. direction?: boolean;
  68. mode?: 'vertical' | 'horizontal';
  69. motion?: Motion;
  70. }
  71. export interface TabContextValue {
  72. activeKey?: string;
  73. lazyRender?: boolean;
  74. panes?: Array<PlainTab>;
  75. tabPaneMotion?: boolean;
  76. tabPosition?: TabPosition;
  77. }