import React, { ReactNode, CSSProperties } from 'react';
export declare type ImageStatus = 'loading' | 'loaded' | 'init' | 'error';
export interface ImageProps {
/**
* 自定义样式
* @en Custom stylesheet
*/
style?: CSSProperties;
/**
* 自定义类名
* @en Custom classname
*/
className?: string;
/**
* 指定图片状态,staticLabel=false时有效
* @en The specified image state, valid when staticLabel=false
*/
status?: ImageStatus;
/**
* 图片链接
* @@en Image resource
* */
src: string;
/**
* 容器宽度,传数值,默认单位为px,传字符串则接受传入的单位
* @en Container width, when number is input, the default unit is px, if a string is input, the unit is accepted
* */
width?: string | number;
/**
* 容器高度,传数值,默认单位为px,传字符串则接受传入的单位
* @en Container height, when number is input, the default unit is px, if a string is input, the unit is accepted
* */
height?: string | number;
/**
* 替代文本
* @en Alternative text
* @default ""
*/
alt?: string;
/**
* 图片填充模式(object-fit),传preview-*为预览模式,预览模式仅staticLabel=false时有效
* @en Image fill mode (object-fit), preview-* is preview mode, preview mode is only valid when staticLabel=false
* @default "fill"
*/
fit?: CSSProperties['objectFit'] | 'preview-y' | 'preview-x';
/**
* 图片填充位置(object-position)
* @en Image fill position(object-position)
* @default "center"
*/
position?: CSSProperties['objectPosition'];
/**
* 图片圆角
* @en Image border radius
* */
radius?: string | number;
/**
* 是否加边框
* @en Whether to add a border
* */
bordered?: boolean;
/**
* 自定义展示加载中内容
* @en Custom display loading content, valid when staticLabel=false
* */
loadingArea?: ReactNode;
/**
* 自定义展示加载失败内容
* @en Custom display failed to load content, valid when staticLabel=false
* */
errorArea?: ReactNode;
/**
* 是否展示图片加载中提示
* @en Whether to display the image loading prompt, valid when staticLabel=false
* */
showLoading?: boolean;
/**
* 是否展示图片加载失败提示
* @en Whether to display the image loading failure prompt, valid when staticLabel=false
* */
showError?: boolean;
/**
* 加载完时展现动画时长,staticLabel=false时有效
* @en Display animation duration when loading is complete, valid when staticLabel=false
* @default 200
*/
animateDuration?: number;
/**
* 失败时自动重试次数
* @en Number of automatic retries on failure
* @default 0
*/
retryTime?: number;
/**
* 是否强制使用https
* @en Whether to force the use of https
* */
forceHttps?: boolean;
/**
* 预览模式下,父容器宽度
* @en In preview mode, the width of the parent container
* */
boxWidth?: number;
/**
* 预览模式下,父容器高度
* @en In preview mode, the height of the parent container
* */
boxHeight?: number;
/**
* 图片顶层内容
* @en Top-level content of the image
*/
topOverlap?: ReactNode;
/**
* 图片底层内容(placeholder),默认是灰色兜底,传null可移除
* @en The bottom content of the image (placeholder), the default is gray bottom, input null to remove
* */
bottomOverlap?: ReactNode;
/**
* 手动控制是否加载图片
* @en Manually control whether to load images
* */
showImage?: boolean;
/**
* 是否直接渲染
标签,不走加载图片流程
* @en Whether to render the
tag directly without going through the image loading process
* */
staticLabel?: boolean;
/**
* img标签原生属性,优先级低于单独设置
* @en Img tag native attributes, the priority is lower than the separate setting
*/
nativeProps?: React.DetailedHTMLProps, HTMLImageElement>;
/**
* 切换status时触发的回调
* @en Callback triggered when switching status
*/
onChange?: (status: string) => void;
/**
* 点击图片时触发的回调
* @en Callback when clicking image
*/
onClick?: (e: React.MouseEvent) => void;
/**
* 图片加载完毕时触发的回调
* @en Callback when the image is loaded
* */
onLoad?: (e: Event | null, image: HTMLImageElement) => void;
/**
* 图片加载失败时触发的回调,如果有自动重试则在重试最终失败后触发
* @en Callback when the image fails to load, triggered after the retry finally fails if there is an automatic retry
*/
onError?: (e: string | Event | null) => void;
/**
* 图片加载失败时自动重试触发的回调
* @en Callback triggered by automatic retry when image loading fails
*/
onAutoRetry?: (e: string | Event | null) => void;
}
export interface ImageRef {
/**
* 最外层元素 DOM
* @en The outermost element DOM
*/
dom: HTMLDivElement | null;
/**
* 原生图片元素 DOM
* @en Native image element DOM
*/
image: HTMLImageElement | null;
/**
* 手动重试图片加载
* @en Manually retry image loading
*/
retry: () => void;
}
/**
* 增强版的 img 标签,提供多种图片填充模式,支持图片加载中提示、加载失败提示。
* @en Enhanced img tag, provides a variety of image filling modes, and supports image loading prompts and loading failure prompts.
* @type 信息展示
* @type_en Data Display
* @name 图片
* @name_en Image
*/
export declare const BaseImage: React.ForwardRefExoticComponent>;
export default BaseImage;