Preview.d.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import type { DialogProps as IDialogPropTypes } from 'rc-dialog';
  2. import React from 'react';
  3. import type { ImgInfo } from './Image';
  4. import type { TransformAction, TransformType } from './hooks/useImageTransform';
  5. export type ToolbarRenderInfoType = {
  6. icons: {
  7. prevIcon?: React.ReactNode;
  8. nextIcon?: React.ReactNode;
  9. flipYIcon: React.ReactNode;
  10. flipXIcon: React.ReactNode;
  11. rotateLeftIcon: React.ReactNode;
  12. rotateRightIcon: React.ReactNode;
  13. zoomOutIcon: React.ReactNode;
  14. zoomInIcon: React.ReactNode;
  15. };
  16. actions: {
  17. onActive?: (offset: number) => void;
  18. onFlipY: () => void;
  19. onFlipX: () => void;
  20. onRotateLeft: () => void;
  21. onRotateRight: () => void;
  22. onZoomOut: () => void;
  23. onZoomIn: () => void;
  24. onClose: () => void;
  25. onReset: () => void;
  26. };
  27. transform: TransformType;
  28. current: number;
  29. total: number;
  30. image: ImgInfo;
  31. };
  32. export interface PreviewProps extends Omit<IDialogPropTypes, 'onClose'> {
  33. imgCommonProps?: React.ImgHTMLAttributes<HTMLImageElement>;
  34. src?: string;
  35. alt?: string;
  36. imageInfo?: {
  37. width: number | string;
  38. height: number | string;
  39. };
  40. fallback?: string;
  41. movable?: boolean;
  42. rootClassName?: string;
  43. icons?: {
  44. rotateLeft?: React.ReactNode;
  45. rotateRight?: React.ReactNode;
  46. zoomIn?: React.ReactNode;
  47. zoomOut?: React.ReactNode;
  48. close?: React.ReactNode;
  49. left?: React.ReactNode;
  50. right?: React.ReactNode;
  51. flipX?: React.ReactNode;
  52. flipY?: React.ReactNode;
  53. };
  54. current?: number;
  55. count?: number;
  56. closeIcon?: React.ReactNode;
  57. countRender?: (current: number, total: number) => React.ReactNode;
  58. scaleStep?: number;
  59. minScale?: number;
  60. maxScale?: number;
  61. imageRender?: (originalNode: React.ReactElement, info: {
  62. transform: TransformType;
  63. current?: number;
  64. image?: ImgInfo;
  65. }) => React.ReactNode;
  66. onClose?: () => void;
  67. onTransform?: (info: {
  68. transform: TransformType;
  69. action: TransformAction;
  70. }) => void;
  71. toolbarRender?: (originalNode: React.ReactElement, info: ToolbarRenderInfoType) => React.ReactNode;
  72. onChange?: (current: any, prev: any) => void;
  73. }
  74. declare const Preview: React.FC<PreviewProps>;
  75. export default Preview;