@metamask/design-system-react-native
Version:
1 lines • 2.61 kB
Source Map (JSON)
{"version":3,"file":"ImageOrSvg.types.mjs","sourceRoot":"","sources":["../../../../src/components/temp-components/ImageOrSvg/ImageOrSvg.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ImageErrorEventData,\n ImageLoadEventData,\n NativeSyntheticEvent,\n StyleProp,\n ImageStyle,\n ImageProps,\n} from 'react-native';\nimport type { SvgProps } from 'react-native-svg';\n\n/**\n * Base props common to all variations.\n */\nexport type ImageOrSvgBaseProps = {\n /**\n * Optional prop to set the width of the image/SVG.\n * Accepts numbers (pixels) or string values (like percentages).\n */\n width?: number | string;\n /**\n * Optional prop to set the height of the image/SVG.\n * Accepts numbers (pixels) or string values (like percentages).\n */\n height?: number | string;\n /**\n * Optional prop to set callback triggered when the image has loaded successfully.\n */\n onImageLoad?: (event: NativeSyntheticEvent<ImageLoadEventData>) => void;\n /**\n * Optional prop to set callback triggered when there is an error rendering the image.\n */\n onImageError?: (\n errorEvent: NativeSyntheticEvent<ImageErrorEventData>,\n ) => void;\n /**\n * Optional prop to set callback triggered when there is an error rendering the SVG.\n */\n onSvgError?: (error: Error) => void;\n /**\n * Optional prop for style overrides for the image/SVG container.\n */\n style?: StyleProp<ImageStyle>;\n /**\n * Additional props to pass to the Image component, excluding\n * the 'source' prop (which is handled separately).\n */\n imageProps?: Omit<ImageProps, 'source'>;\n /**\n * Additional props to pass to the Svg component, excluding\n * the 'uri' prop (which is handled separately).\n */\n svgProps?: Omit<SvgProps, 'uri'>;\n};\n\n/**\n * Defines the source type for an image or SVG.\n *\n * The source can be one of the following:\n * - A number representing a locally imported image resource.\n * - A React component (with SvgProps) representing a locally imported SVG.\n * - An object with an optional `uri` property for remote images or SVGs.\n */\nexport type ImageOrSvgSrc =\n | number // For local imported image\n | React.ComponentType<SvgProps> // For local imported svg\n | { uri?: string }; // For remote image or SVG (with a uri property)\n\nexport type ImageOrSvgProps = ImageOrSvgBaseProps & {\n /**\n * Required prop for the source of the image or SVG.\n * This prop determines whether a local image, a local SVG component,\n * or a remote image/SVG (via URI) is rendered.\n */\n src: ImageOrSvgSrc;\n};\n"]}