image.d.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import React from 'react';
  2. declare const VALID_LOADING_VALUES: readonly ["lazy", "eager", undefined];
  3. declare type LoadingValue = typeof VALID_LOADING_VALUES[number];
  4. export declare type ImageLoader = (resolverProps: ImageLoaderProps) => string;
  5. export declare type ImageLoaderProps = {
  6. src: string;
  7. width: number;
  8. quality?: number;
  9. };
  10. declare const VALID_LAYOUT_VALUES: readonly ["fill", "fixed", "intrinsic", "responsive", undefined];
  11. declare type LayoutValue = typeof VALID_LAYOUT_VALUES[number];
  12. declare type PlaceholderValue = 'blur' | 'empty';
  13. declare type OnLoadingComplete = (result: {
  14. naturalWidth: number;
  15. naturalHeight: number;
  16. }) => void;
  17. declare type ImgElementStyle = NonNullable<JSX.IntrinsicElements['img']['style']>;
  18. export interface StaticImageData {
  19. src: string;
  20. height: number;
  21. width: number;
  22. blurDataURL?: string;
  23. }
  24. interface StaticRequire {
  25. default: StaticImageData;
  26. }
  27. declare type StaticImport = StaticRequire | StaticImageData;
  28. export declare type ImageProps = Omit<JSX.IntrinsicElements['img'], 'src' | 'srcSet' | 'ref' | 'width' | 'height' | 'loading'> & {
  29. src: string | StaticImport;
  30. width?: number | string;
  31. height?: number | string;
  32. layout?: LayoutValue;
  33. loader?: ImageLoader;
  34. quality?: number | string;
  35. priority?: boolean;
  36. loading?: LoadingValue;
  37. lazyRoot?: React.RefObject<HTMLElement> | null;
  38. lazyBoundary?: string;
  39. placeholder?: PlaceholderValue;
  40. blurDataURL?: string;
  41. unoptimized?: boolean;
  42. objectFit?: ImgElementStyle['objectFit'];
  43. objectPosition?: ImgElementStyle['objectPosition'];
  44. onLoadingComplete?: OnLoadingComplete;
  45. };
  46. export default function Image({ src, sizes, unoptimized, priority, loading, lazyRoot, lazyBoundary, className, quality, width, height, style, objectFit, objectPosition, onLoadingComplete, placeholder, blurDataURL, ...all }: ImageProps): JSX.Element;
  47. export {};