UNPKG

@lobehub/ui

Version:

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

39 lines (36 loc) 1.45 kB
'use client'; import { useIconContext } from "./components/IconProvider.mjs"; import { calcSize } from "./components/utils.mjs"; import { variants } from "./style.mjs"; import { isValidElement, memo, useMemo } from "react"; import { jsx } from "react/jsx-runtime"; import { cx } from "antd-style"; //#region src/Icon/Icon.tsx const Icon = memo(({ icon, size: iconSize, color, fill = "transparent", className, focusable, spin, fillRule, fillOpacity, ref, ...rest }) => { const { color: colorConfig, fill: fillConfig, fillOpacity: fillOpacityConfig, fillRule: fillRuleConfig, focusable: focusableConfig, className: classNameConfig, size: sizeConfig, ...restConfig } = useIconContext(); const { size, strokeWidth } = useMemo(() => calcSize(iconSize || sizeConfig), [iconSize, sizeConfig]); const SvgIcon = icon; return /* @__PURE__ */ jsx("span", { className: cx(variants({ spin }), classNameConfig, className), role: "img", ...restConfig, ...rest, children: icon && (isValidElement(icon) ? icon : /* @__PURE__ */ jsx(SvgIcon, { color: color || colorConfig, fill: fill || fillConfig, fillOpacity: fillOpacity || fillOpacityConfig, fillRule: fillRule || fillRuleConfig, focusable: focusable || focusableConfig, height: size, ref, size, strokeWidth, width: size })) }); }); Icon.displayName = "Icon"; var Icon_default = Icon; //#endregion export { Icon_default as default }; //# sourceMappingURL=Icon.mjs.map