interface.ts 2.7 KB

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