UNPKG

lucide-react

Version:

A Lucide icon library package for React applications.

49 lines (45 loc) 1.77 kB
"use strict"; "use client"; /** * @license lucide-react v1.8.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */ import { forwardRef, createElement } from 'react'; import defaultAttributes from './defaultAttributes.js'; import { hasA11yProp } from './shared/src/utils/hasA11yProp.js'; import { mergeClasses } from './shared/src/utils/mergeClasses.js'; import { useLucideContext } from './context.js'; const Icon = forwardRef( ({ color, size, strokeWidth, absoluteStrokeWidth, className = "", children, iconNode, ...rest }, ref) => { const { size: contextSize = 24, strokeWidth: contextStrokeWidth = 2, absoluteStrokeWidth: contextAbsoluteStrokeWidth = false, color: contextColor = "currentColor", className: contextClass = "" } = useLucideContext() ?? {}; const calculatedStrokeWidth = absoluteStrokeWidth ?? contextAbsoluteStrokeWidth ? Number(strokeWidth ?? contextStrokeWidth) * 24 / Number(size ?? contextSize) : strokeWidth ?? contextStrokeWidth; return createElement( "svg", { ref, ...defaultAttributes, width: size ?? contextSize ?? defaultAttributes.width, height: size ?? contextSize ?? defaultAttributes.height, stroke: color ?? contextColor, strokeWidth: calculatedStrokeWidth, className: mergeClasses("lucide", contextClass, className), ...!children && !hasA11yProp(rest) && { "aria-hidden": "true" }, ...rest }, [ ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)), ...Array.isArray(children) ? children : [children] ] ); } ); export { Icon as default }; //# sourceMappingURL=Icon.js.map