import { Box } from "../../box" ; import { ComponentProps , ElementType , SVGProps , forwardRef , useCallback } from "react" ; import { FillProp , HeightProp , StrokeProp , StyledSystemProps , WidthProp } from "../../styling" ; import { InternalProps , OmitInternalProps , SlotProps , isNil , mergeProps , slot , useMergedRefs } from "../../shared" ; type OverlappingStyleProps = "fill" | "height" | "stroke" | "width" ; export interface InnerSvgImageProps extends Omit < StyledSystemProps , OverlappingStyleProps > , SlotProps , Omit < InternalProps , "as" > , Omit < SVGProps < SVGSVGElement > , keyof StyledSystemProps | OverlappingStyleProps > { /**
     * See [WCAG](https://www.w3.org/TR/WCAG20-TECHS/ARIA14.html).
     */ "aria-label" : string ; /**
     * See [MDN](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill).
     */ fill ? : FillProp ; /**
    * The image height.
    */ height ? : HeightProp ; /**
     * An SVG as a component.
     */ src : ElementType ; /**
     * See [MDN](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke).
     */ stroke ? : StrokeProp ; /**
    * The image width.
    */ width ? : WidthProp ; } export function InnerSvgImage ( { forwardedRef , src , ... rest } ) { const hideUseElement = useCallback ( ( element ) => { if ( ! isNil ( element ) ) { const titleElement = element . querySelector ( "title" ) ; if ( ! isNil ( titleElement ) ) { titleElement . remove ( ) ; } element . querySelector ( "use" ) ?. setAttribute ( "aria-hidden" , "true" ) ; element . querySelectorAll ( "path" ) . forEach ( ( x ) => { x . setAttribute ( "aria-hidden" , "true" ) ; } ) ; } } , [ ] ) ; const ref = useMergedRefs ( forwardedRef , hideUseElement ) ; return ( < Box { ... mergeProps ( rest , { as : src , focusable : false , ref , role : "img" } ) } / > ) ; } export const SvgImage = slot ( "image" , forwardRef < any , OmitInternalProps < InnerSvgImageProps > > ( ( props , ref ) => ( < InnerSvgImage { ... props } forwardedRef = { ref } / > ) ) ) ; export type SvgImageProps = ComponentProps < typeof SvgImage > ;