flowbite-react
Version:
Official React components built for Flowbite and Tailwind CSS
1 lines • 2.88 kB
Source Map (JSON)
{"version":3,"file":"ModalHeader.mjs","sources":["../../../../src/components/Modal/ModalHeader.tsx"],"sourcesContent":["\"use client\";\n\nimport { useId, useLayoutEffect, type ComponentProps, type ElementType, type FC } from \"react\";\nimport { HiOutlineX } from \"react-icons/hi\";\nimport { twMerge } from \"tailwind-merge\";\nimport { mergeDeep } from \"../../helpers/merge-deep\";\nimport type { DeepPartial } from \"../../types\";\nimport { useModalContext } from \"./ModalContext\";\n\nexport interface FlowbiteModalHeaderTheme {\n base: string;\n popup: string;\n title: string;\n close: {\n base: string;\n icon: string;\n };\n}\n\nexport interface ModalHeaderProps extends ComponentProps<\"div\"> {\n as?: ElementType;\n theme?: DeepPartial<FlowbiteModalHeaderTheme>;\n}\n\nexport const ModalHeader: FC<ModalHeaderProps> = ({\n as: Component = \"h3\",\n children,\n className,\n theme: customTheme = {},\n id,\n ...props\n}) => {\n const innerHeaderId = useId();\n const headerId = id || innerHeaderId;\n\n const { theme: rootTheme, popup, onClose, setHeaderId } = useModalContext();\n\n const theme = mergeDeep(rootTheme.header, customTheme);\n\n useLayoutEffect(() => {\n setHeaderId(headerId);\n\n return () => setHeaderId(undefined);\n }, [headerId, setHeaderId]);\n\n return (\n <div className={twMerge(theme.base, popup && theme.popup, className)} {...props}>\n <Component id={headerId} className={theme.title}>\n {children}\n </Component>\n <button aria-label=\"Close\" className={theme.close.base} type=\"button\" onClick={onClose}>\n <HiOutlineX aria-hidden className={theme.close.icon} />\n </button>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAQY,MAAC,WAAW,GAAG,CAAC;AAC5B,EAAE,EAAE,EAAE,SAAS,GAAG,IAAI;AACtB,EAAE,QAAQ;AACV,EAAE,SAAS;AACX,EAAE,KAAK,EAAE,WAAW,GAAG,EAAE;AACzB,EAAE,EAAE;AACJ,EAAE,GAAG,KAAK;AACV,CAAC,KAAK;AACN,EAAE,MAAM,aAA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