UNPKG

lucide-react-native

Version:

A Lucide icon library package for React Native applications.

85 lines (78 loc) 2.45 kB
/** * @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. */ 'use strict'; var react = require('react'); var NativeSvg = require('react-native-svg'); var defaultAttributes = require('./defaultAttributes.js'); var context = require('./context.js'); function _interopNamespaceDefault(e) { var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { if (k !== 'default') { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: function () { return e[k]; } }); } }); } n.default = e; return Object.freeze(n); } var NativeSvg__namespace = /*#__PURE__*/_interopNamespaceDefault(NativeSvg); const Icon = react.forwardRef( ({ color, size, strokeWidth, absoluteStrokeWidth, children, iconNode, className, testID, ...rest }, ref) => { const { size: contextSize = 24, strokeWidth: contextStrokeWidth = 2, absoluteStrokeWidth: contextAbsoluteStrokeWidth = false, color: contextColor = "currentColor" } = context.useLucideContext() ?? {}; const calculatedStrokeWidth = absoluteStrokeWidth ?? contextAbsoluteStrokeWidth ? Number(strokeWidth ?? contextStrokeWidth) * 24 / Number(size ?? contextSize) : strokeWidth ?? contextStrokeWidth; const customAttrs = { stroke: color ?? contextColor ?? defaultAttributes.default.stroke, strokeWidth: calculatedStrokeWidth, ...rest }; return react.createElement( NativeSvg__namespace.Svg, { ref, ...defaultAttributes.default, width: size ?? contextSize ?? defaultAttributes.default.width, height: size ?? contextSize ?? defaultAttributes.default.height, "data-testid": testID, className, ...customAttrs }, [ ...iconNode.map(([tag, attrs]) => { const upperCasedTag = tag.charAt(0).toUpperCase() + tag.slice(1); return react.createElement( NativeSvg__namespace[upperCasedTag], { ...defaultAttributes.childDefaultAttributes, ...customAttrs, ...attrs } ); }), ...(Array.isArray(children) ? children : [children]) || [] ] ); } ); module.exports = Icon; //# sourceMappingURL=Icon.js.map