index.d.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import * as React from 'react';
  2. import type { JSX } from 'react';
  3. import type { AutoSizeType } from 'rc-textarea';
  4. import type { TooltipProps } from '../../tooltip';
  5. import type { TypographyProps } from '../Typography';
  6. export type BaseType = 'secondary' | 'success' | 'warning' | 'danger';
  7. export interface CopyConfig {
  8. text?: string | (() => string | Promise<string>);
  9. onCopy?: (event?: React.MouseEvent<HTMLButtonElement>) => void;
  10. icon?: React.ReactNode;
  11. tooltips?: React.ReactNode;
  12. format?: 'text/plain' | 'text/html';
  13. tabIndex?: number;
  14. }
  15. interface EditConfig {
  16. text?: string;
  17. editing?: boolean;
  18. icon?: React.ReactNode;
  19. tooltip?: React.ReactNode;
  20. onStart?: () => void;
  21. onChange?: (value: string) => void;
  22. onCancel?: () => void;
  23. onEnd?: () => void;
  24. maxLength?: number;
  25. autoSize?: boolean | AutoSizeType;
  26. triggerType?: ('icon' | 'text')[];
  27. enterIcon?: React.ReactNode;
  28. tabIndex?: number;
  29. }
  30. export interface EllipsisConfig {
  31. rows?: number;
  32. expandable?: boolean | 'collapsible';
  33. suffix?: string;
  34. symbol?: React.ReactNode | ((expanded: boolean) => React.ReactNode);
  35. defaultExpanded?: boolean;
  36. expanded?: boolean;
  37. onExpand?: (e: React.MouseEvent<HTMLElement, MouseEvent>, info: {
  38. expanded: boolean;
  39. }) => void;
  40. onEllipsis?: (ellipsis: boolean) => void;
  41. tooltip?: React.ReactNode | TooltipProps;
  42. }
  43. export interface BlockProps<C extends keyof JSX.IntrinsicElements = keyof JSX.IntrinsicElements> extends TypographyProps<C> {
  44. title?: string;
  45. editable?: boolean | EditConfig;
  46. copyable?: boolean | CopyConfig;
  47. type?: BaseType;
  48. disabled?: boolean;
  49. ellipsis?: boolean | EllipsisConfig;
  50. code?: boolean;
  51. mark?: boolean;
  52. underline?: boolean;
  53. delete?: boolean;
  54. strong?: boolean;
  55. keyboard?: boolean;
  56. italic?: boolean;
  57. }
  58. declare const Base: React.ForwardRefExoticComponent<BlockProps<keyof JSX.IntrinsicElements> & React.RefAttributes<HTMLElement>>;
  59. export default Base;