lucide-react-native
Version:
A Lucide icon library package for React Native applications.
64 lines (60 loc) • 1.92 kB
JavaScript
/**
* @license lucide-react-native v1.18.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 * as NativeSvg from 'react-native-svg';
import defaultAttributes, { childDefaultAttributes } from './defaultAttributes.mjs';
import { useLucideContext } from './context.mjs';
const Icon = forwardRef(
({
color,
size,
strokeWidth,
absoluteStrokeWidth,
children,
iconNode,
className,
testID,
...rest
}, ref) => {
const {
size: contextSize = 24,
strokeWidth: contextStrokeWidth = 2,
absoluteStrokeWidth: contextAbsoluteStrokeWidth = false,
color: contextColor = "currentColor"
} = useLucideContext() ?? {};
const calculatedStrokeWidth = absoluteStrokeWidth ?? contextAbsoluteStrokeWidth ? Number(strokeWidth ?? contextStrokeWidth) * 24 / Number(size ?? contextSize) : strokeWidth ?? contextStrokeWidth;
const customAttrs = {
stroke: color ?? contextColor ?? defaultAttributes.stroke,
strokeWidth: calculatedStrokeWidth,
...rest
};
return createElement(
NativeSvg.Svg,
{
ref,
...defaultAttributes,
width: size ?? contextSize ?? defaultAttributes.width,
height: size ?? contextSize ?? defaultAttributes.height,
"data-testid": testID,
className,
...customAttrs
},
[
...iconNode.map(([tag, attrs]) => {
const upperCasedTag = tag.charAt(0).toUpperCase() + tag.slice(1);
return createElement(
NativeSvg[upperCasedTag],
{ ...childDefaultAttributes, ...customAttrs, ...attrs }
);
}),
...(Array.isArray(children) ? children : [children]) || []
]
);
}
);
export { Icon as default };
//# sourceMappingURL=Icon.mjs.map