interface.ts 2.5 KB

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