UNPKG

@lobehub/ui

Version:

Lobe UI is an open-source UI component library for building AIGC web apps

1 lines 1.31 kB
{"version":3,"file":"index.mjs","names":["Img: FC<ImgProps>"],"sources":["../../src/Img/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ImageProps } from 'antd';\nimport { type ElementType, type FC, type Ref, createElement, memo, use, useMemo } from 'react';\n\nimport { ConfigContext } from '@/ConfigProvider';\nimport type { ImgProps as HtmlImgeProps } from '@/types';\n\nconst createContainer = (as: ElementType) => memo((props: any) => createElement(as, props));\n\ntype ImgProps = HtmlImgeProps & ImageProps & { ref?: Ref<HTMLImageElement>; unoptimized?: boolean };\n\nconst Img: FC<ImgProps> = ({ unoptimized, ...rest }) => {\n const config = use(ConfigContext);\n const render = config?.imgAs || 'img';\n\n const ImgContainer = useMemo(() => createContainer(render), [render]);\n\n return (\n <ImgContainer\n unoptimized={unoptimized === undefined ? config?.imgUnoptimized : unoptimized}\n {...rest}\n />\n );\n};\n\nImg.displayName = 'Img';\n\nexport default Img;\n"],"mappings":";;;;;;;AAQA,MAAM,mBAAmB,OAAoB,MAAM,UAAe,cAAc,IAAI,MAAM,CAAC;AAI3F,MAAMA,OAAqB,EAAE,aAAa,GAAG,WAAW;CACtD,MAAM,SAAS,IAAI,cAAc;CACjC,MAAM,SAAS,QAAQ,SAAS;AAIhC,QACE,oBAHmB,cAAc,gBAAgB,OAAO,EAAE,CAAC,OAAO,CAAC;EAIjE,aAAa,gBAAgB,SAAY,QAAQ,iBAAiB;EAClE,GAAI;GACJ;;AAIN,IAAI,cAAc;AAElB,kBAAe"}