import React, { ReactNode } from 'react'; import { CarouselProps } from '../carousel'; import { ImageProps } from '../image'; export * from './methods'; export interface PreviewImageProps { /** * 图片地址 * @en Image resource */ src: string; /** * 图片布局方式,preview-y为宽度撑满高度溢出滚动,preview-x为高度撑满宽度溢出滚动 * @en Image layout, preview-y is overflow scrolling with full width and height, preview-x is overflow scrolling with full width and height */ fit?: 'preview-y' | 'preview-x'; /** * 过渡图url * @en Transition image url */ fallbackSrc?: string; /** * 过渡图到原图放大动效完成后,移除过渡图的延迟时间(ms),一般当原图过大时有调整需求 * @en After the transition image to the original image enlargement effect is completed, the delay time (ms) before the transition image is removed * @default 30 */ transitionEndDelay?: number; /** * 缩略图填充方式(backgroundPosition),默认top center * @en Thumbnail fill mode (backgroundPosition), default value is top center */ thumbPosition?: string; /** * 自定义DOM * @en Custom dom */ extraNode?: ReactNode; } export interface ImagePreviewProps extends Pick { /** * 自定义样式 * @en Custom stylesheet */ style?: React.CSSProperties; /** * 自定义类名 * @en Custom classname */ className?: string; /** * 图片信息数组 * @en Image List */ images: PreviewImageProps[]; /** * 打开时展示的index,在images范围内会展示弹窗,否则隐藏弹窗 * @en The index displayed when it is opened, the popup will be displayed within the scope of images, otherwise the popup will be hidden */ openIndex: number; /** * 是否可循环滑动 * @en Whether it can be swiped circularly * @default false */ loop?: boolean; /** * 图片布局方式,preview-y为宽度撑满高度溢出滚动,preview-x为高度撑满宽度溢出滚动 * @en Image layout, preview-y is overflow scrolling with full width and height, preview-x is overflow scrolling with full width and height * @default "preview-y" */ fit?: PreviewImageProps['fit']; /** * 打开和关闭时的过渡动画 * @en Transition animation on opening and closing * @default 300 */ displayDuration?: number; /** * 是否在原图加载完成后将过渡图动画替换为原图动画 * @en Whether to replace the transition image animation with the original image animation after the original image is loaded */ replaceFallbackWhenLoaded?: boolean; /** * 图片不可选中,屏蔽系统默认事件 * @en The image cannot be selected, and the system default event is blocked * @default true */ noselect?: boolean; /** * 图片横向间距 * @en Horizontal spacing of images */ spaceBetween?: number; /** * 自定义展示加载中内容 * @en Custom display loading content */ loadingArea?: ReactNode; /** * 自定义展示加载失败内容 * @en Custom display loading failure content */ errorArea?: ReactNode; /** * 是否展示图片加载中提示 * @en Whether to display the image loading prompt * @default true */ showLoading?: boolean; /** * 是否展示图片加载失败提示 * @en Whether to display the image loading failure prompt * @default true */ showError?: boolean; /** * 失败时自动重试次数 * @en Number of automatic retries on failure */ retryTime?: number; /** * 是否直接渲染标签,不走加载图片流程 * @en Whether to render the tag directly without going through the image loading process */ staticLabel?: boolean; /** * 长图滚动变化曲线 * @en Scrolling change curve of long image */ scrollBezier?: [number, number, number, number]; /** * 只加载当前页相邻的n个内容,为0时会销毁所有相邻内容 * @en Only load n content adjacent to the current page, when it is 0, all adjacent content will be destroyed * @default 1 */ lazyloadCount?: number; /** * 当图片滚动到边缘时,继续滑动是否关闭预览 * @en When the image is scrolled to the edge, whether to close the preview when continuing to swipe * @default true */ swipeToClose?: boolean; /** * 轮播索引位置 * @en Carousel indicator position * @default "start" */ indicatorPos?: CarouselProps['indicatorPos']; /** * 渲染自定义元素,如自定义关闭按钮 * @en Render custom elements such as custom close buttons */ extra?: ReactNode; /** * 图片捏合时最小缩放倍数,松手后仍会恢复到1的状态,默认为0.7 * @en The minimum zoom factor when the image is pinched, it will still return to the state of 1 after letting go, the default is 0.7 */ getMinScale?: (image: HTMLImageElement | null, imageIndex: number) => number; /** * 图片最大缩放倍数,默认根据图片尺寸调节 * @en The maximum zoom factor of the image, the default is adjusted according to the picture size */ getMaxScale?: (image: HTMLImageElement | null, imageIndex: number) => number; /** * 当双击图片时,图片应缩放的倍数 * @en The zoom factor of the image when double-clicking the image */ getDoubleClickScale?: (currentScale: number, maxScale: number, image: HTMLImageElement | null, imageIndex: number) => number; /** * 获取挂载容器 * @en Get mounted container */ getContainer?: () => HTMLElement; /** * 自定义索引内容 * @en Custom indicator content */ renderIndicator?: CarouselProps['renderIndicator']; /** * 获取缩略图定位 * @en Get the thumbnail image Positioning */ getThumbBounds?: (index: number) => ClientRect; /** * 索引发生改变时回调 * @en Callback when index changes */ onChange?: CarouselProps['onChange']; /** * 索引切换,动画完成后触发 * @en Callback after animation is completed when the index toggles */ onAfterChange?: (index: number) => void; /** * 关闭弹窗 * @en close popup */ close: (e: React.MouseEvent | TouchEvent) => void; /** * 关闭弹窗回调(动画执行完成后) * @en Callback when closing the popup (after the animation is completed) */ onClose?: () => void; /** * 点击图片回调,如果返回true则阻止关闭弹窗 * @en Callback when clicking the image, if it returns true, it will prevent the popup from closing */ onImageClick?: (index: number, e: React.MouseEvent) => boolean | void; /** * 双击图片回调 * @en Callback when double clicking the image */ onImageDoubleClick?: (index: number, e: React.MouseEvent) => void; /** * 长按图片回调 * @en Callback when long pressing image */ onImageLongTap?: (index: number, image: HTMLImageElement | null, e: TouchEvent) => void; /** * 弹窗内容touchstart事件 * @en Popup content touchstart event */ onTouchStart?: (e: TouchEvent, index: number) => void | boolean; /** * 弹窗内容touchmove事件 * @en Popup content touchmove event */ onTouchMove?: (e: TouchEvent, index: number) => void | boolean; /** * 弹窗内容touchend / touchcancel事件 * @en Popup content touchend / touchcancel events */ onTouchEnd?: (e: TouchEvent, index: number) => void | boolean; } export interface ImagePreviewRef { /** * 最外层元素 DOM * @en The outermost element DOM */ dom: HTMLDivElement | null; /** * 原生图片 DOM 列表 * @en Native image DOM array */ imageDoms: (HTMLImageElement | null)[]; } export interface PreviewImageStatus { firstLoaded?: boolean; loaded?: boolean; animated?: boolean; originWidth?: number; originHeight?: number; originTop?: number; originLeft?: number; hasOverflow?: boolean; } export interface PreviewTransImageInfo { src: string; fit: PreviewImageProps['fit']; index: number; movingImage: HTMLImageElement; onLoad: ImageProps['onLoad']; onError: ImageProps['onError']; } export declare function methodsGenerator

(Comp: React.FunctionComponent

): { /** * 打开图片预览 * @desc {en} Open image preview * @param {ImagePreviewProps} config configuration * @returns {{ close: () => void; update: (newConfig: ImagePreviewProps) => void; }} */ open: (config: Pick>, context?: import("../context-provider").GlobalContextParams | undefined) => { close: () => void; update: (newConfig: Pick>) => void; }; }; declare const _default: React.ForwardRefExoticComponent> & { /** * 打开图片预览 * @desc {en} Open image preview * @param {ImagePreviewProps} config configuration * @returns {{ close: () => void; update: (newConfig: ImagePreviewProps) => void; }} */ open: (config: Pick>, "ref" | "className" | "style" | "context" | "key" | "swipeable" | "lazyloadCount" | "onChange" | "onAfterChange" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "getContainer" | "onClose" | "fit" | "loadingArea" | "errorArea" | "showLoading" | "showError" | "retryTime" | "staticLabel" | "animateDurationSlide" | "loop" | "renderIndicator" | "indicatorPos" | "showIndicator" | "hideSingleIndicator" | "spaceBetween" | "offsetBetween" | "percentToChange" | "distanceToChange" | "speedToChange" | "renderExtra" | "extra" | "images" | "openIndex" | "displayDuration" | "replaceFallbackWhenLoaded" | "noselect" | "scrollBezier" | "swipeToClose" | "getMinScale" | "getMaxScale" | "getDoubleClickScale" | "getThumbBounds" | "onImageClick" | "onImageDoubleClick" | "onImageLongTap">, context?: import("../context-provider").GlobalContextParams | undefined) => { close: () => void; update: (newConfig: Pick>, "ref" | "className" | "style" | "context" | "key" | "swipeable" | "lazyloadCount" | "onChange" | "onAfterChange" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "getContainer" | "onClose" | "fit" | "loadingArea" | "errorArea" | "showLoading" | "showError" | "retryTime" | "staticLabel" | "animateDurationSlide" | "loop" | "renderIndicator" | "indicatorPos" | "showIndicator" | "hideSingleIndicator" | "spaceBetween" | "offsetBetween" | "percentToChange" | "distanceToChange" | "speedToChange" | "renderExtra" | "extra" | "images" | "openIndex" | "displayDuration" | "replaceFallbackWhenLoaded" | "noselect" | "scrollBezier" | "swipeToClose" | "getMinScale" | "getMaxScale" | "getDoubleClickScale" | "getThumbBounds" | "onImageClick" | "onImageDoubleClick" | "onImageLongTap">) => void; }; }; /** * 图片预览组件,支持循环轮播、双指/双击缩放、缩略图放大效果。 * @en The image preview, supports circular rotation, two-finger/double-tap zoom, and thumbnail zoom effects. * @type 信息展示 * @type_en Data Display * @name 图片预览 * @name_en ImagePreview */ export default _default;