diff --git a/packages/lucide-react/src/createLucideIcon.ts b/packages/lucide-react/src/createLucideIcon.ts index 46622afeeb..daf73e7e30 100644 --- a/packages/lucide-react/src/createLucideIcon.ts +++ b/packages/lucide-react/src/createLucideIcon.ts @@ -1,14 +1,21 @@ -import { forwardRef, createElement, ReactSVG, SVGProps, ForwardRefExoticComponent, RefAttributes } from 'react'; +import { + forwardRef, + createElement, + ReactSVG, + SVGProps, + ForwardRefExoticComponent, + RefAttributes, +} from 'react'; import defaultAttributes from './defaultAttributes'; -export type IconNode = [elementName: keyof ReactSVG, attrs: Record][] +export type IconNode = [elementName: keyof ReactSVG, attrs: Record][]; -export type SVGAttributes = Partial> -type ComponentAttributes = RefAttributes & SVGAttributes +export type SVGAttributes = Partial>; +type ComponentAttributes = RefAttributes & SVGAttributes; export interface LucideProps extends ComponentAttributes { - size?: string | number - absoluteStrokeWidth?: boolean + size?: string | number; + absoluteStrokeWidth?: boolean; } export type LucideIcon = ForwardRefExoticComponent; @@ -20,7 +27,11 @@ export type LucideIcon = ForwardRefExoticComponent; * @param {string} string * @returns {string} A kebabized string */ -export const toKebabCase = (string: string) => string.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase(); +export const toKebabCase = (string: string) => + string + .replace(/([a-z0-9])([A-Z])/g, '$1-$2') + .toLowerCase() + .trim(); const createLucideIcon = (iconName: string, iconNode: IconNode): LucideIcon => { const Component = forwardRef( @@ -39,11 +50,9 @@ const createLucideIcon = (iconName: string, iconNode: IconNode): LucideIcon => { }, [ ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)), - ...( - (Array.isArray(children) ? children : [children]) || [] - ) - ], - ), + ...(Array.isArray(children) ? children : [children]), + ] + ) ); Component.displayName = `${iconName}`; @@ -51,4 +60,4 @@ const createLucideIcon = (iconName: string, iconNode: IconNode): LucideIcon => { return Component; }; -export default createLucideIcon +export default createLucideIcon;