interface.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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;
  58. disabled?: boolean;
  59. icon?: ReactNode;
  60. itemKey?: string;
  61. style?: CSSProperties;
  62. tab?: ReactNode;
  63. closable?: boolean;
  64. tabIndex?: number
  65. }
  66. export interface TabPaneTransitionProps {
  67. [key: string]: any;
  68. children?: ((p: { transform?: string; opacity: number }) => ReactNode | undefined) | undefined;
  69. direction?: boolean;
  70. mode?: 'vertical' | 'horizontal';
  71. motion?: Motion
  72. }
  73. export interface TabContextValue {
  74. activeKey?: string;
  75. lazyRender?: boolean;
  76. panes?: Array<PlainTab>;
  77. tabPaneMotion?: boolean;
  78. tabPosition?: TabPosition;
  79. prevActiveKey?: string|null;
  80. forceDisableMotion?: boolean
  81. }