{"version":3,"file":"Icon.cjs","sources":["../../../../src/components/icon/Icon.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React from \"react\";\nimport type {\n    PolymorphicPropsWithRef,\n    PolymorphicRef,\n} from \"../../utilities/polymorphism/polymorphism.js\";\nimport type { IconVariant } from \"./types.js\";\n\ntype IconComponentProps<\n    ElementType extends \"span\" | \"div\",\n> = PolymorphicPropsWithRef<\n    ElementType,\n    {\n        \"data-testid\"?: string;\n        /**\n         * Størrelsesvarianten til ikonet. `\"small\"` er 16px med 20px bounding box, og `\"medium\"` er 20px med 24px bounding box.\n         * `\"inherit\"` setter størrelsen til ikonet (ikke bounding box) lik skriftstørrelsen (1em).\n         */\n        variant?: IconVariant;\n        /**\n         * Angir om ikonet skal vises i fet versjon\n         * @default false\n         */\n        bold?: boolean;\n        filled?: boolean;\n        className?: string;\n        style?: React.CSSProperties;\n    }\n>;\n\nexport type IconComponent = (<\n    ElementType extends \"span\" | \"div\" = \"span\",\n>(\n    props: IconComponentProps<ElementType>,\n) => React.ReactElement | null) & { displayName?: string };\n\nexport const Icon: IconComponent = React.forwardRef(function Icon<\n    ElementType extends \"span\" | \"div\" = \"span\",\n>(props: IconComponentProps<ElementType>, ref?: PolymorphicRef<ElementType>) {\n    const {\n        as = \"span\",\n        bold,\n        children,\n        className,\n        filled,\n        variant,\n        ...iconProps\n    } = props;\n    const iconClassName = clsx(\"jkl-icon\", className, {\n        \"jkl-icon--filled\": filled,\n        \"jkl-icon--bold\": bold,\n    });\n\n    if (as === \"div\") {\n        return (\n            <div\n                aria-hidden\n                ref={ref as PolymorphicRef<\"div\">}\n                className={iconClassName}\n                {...(iconProps as React.HTMLAttributes<HTMLDivElement>)}\n            >\n                {children}\n            </div>\n        );\n    }\n\n    return (\n        <span\n            aria-hidden\n            ref={ref as PolymorphicRef<\"span\">}\n            className={iconClassName}\n            {...(iconProps as React.HTMLAttributes<HTMLSpanElement>)}\n        >\n            {children}\n        </span>\n    );\n}) as IconComponent;\n"],"names":["Icon","forwardRef","props","ref","as","bold","children","className","filled","variant","iconProps","iconClassName","clsx","jsx"],"mappings":"6JAoCaA,mBAA4BC,WAAW,SAElDC,EAAwCC,GACtC,MACIC,GAAAA,EAAK,OACLC,KAAAA,EACAC,SAAAA,EACAC,UAAAA,EACAC,OAAAA,EACAC,QAAAA,KACGC,GACHR,EACES,EAAgBC,EAAAA,KAAK,WAAYL,EAAW,CAC9C,mBAAoBC,EACpB,iBAAkBH,IAGtB,MAAW,QAAPD,EAEIS,EAAAA,IAAC,MAAA,CACG,eAAW,EACXV,IAAAA,EACAI,UAAWI,KACND,EAEJJ,SAAAA,IAMTO,EAAAA,IAAC,OAAA,CACG,eAAW,EACXV,IAAAA,EACAI,UAAWI,KACND,EAEJJ,SAAAA,GAGb"}