flowbite-react
Version:
Official React components built for Flowbite and Tailwind CSS
1 lines • 4.83 kB
Source Map (JSON)
{"version":3,"file":"Alert.cjs","sources":["../../../src/components/Alert/Alert.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, type ComponentProps, type FC, type ReactNode } from \"react\";\nimport { get } from \"../../helpers/get\";\nimport { resolveProps } from \"../../helpers/resolve-props\";\nimport { useResolveTheme } from \"../../helpers/resolve-theme\";\nimport { twMerge } from \"../../helpers/tailwind-merge\";\nimport { XIcon } from \"../../icons/x-icon\";\nimport { useThemeProvider } from \"../../theme/provider\";\nimport type { DynamicStringEnumKeysOf, FlowbiteColors, ThemingProps } from \"../../types\";\nimport { alertTheme } from \"./theme\";\n\nexport interface AlertTheme {\n base: string;\n borderAccent: string;\n closeButton: AlertCloseButtonTheme;\n color: FlowbiteColors;\n icon: string;\n rounded: string;\n wrapper: string;\n}\n\nexport interface AlertCloseButtonTheme {\n base: string;\n color: FlowbiteColors;\n icon: string;\n}\n\nexport interface AlertProps extends Omit<ComponentProps<\"div\">, \"color\">, ThemingProps<AlertTheme> {\n additionalContent?: ReactNode;\n color?: DynamicStringEnumKeysOf<FlowbiteColors>;\n icon?: FC<ComponentProps<\"svg\">>;\n onDismiss?: ComponentProps<\"button\">[\"onClick\"];\n rounded?: boolean;\n withBorderAccent?: boolean;\n}\n\nexport const Alert = forwardRef<HTMLDivElement, AlertProps>((props, ref) => {\n const provider = useThemeProvider();\n const theme = useResolveTheme(\n [alertTheme, provider.theme?.alert, props.theme],\n [get(provider.clearTheme, \"alert\"), props.clearTheme],\n [get(provider.applyTheme, \"alert\"), props.applyTheme],\n );\n\n const {\n additionalContent,\n children,\n className,\n color = \"info\",\n icon: Icon,\n onDismiss,\n rounded = true,\n withBorderAccent,\n ...restProps\n } = resolveProps(props, provider.props?.alert);\n\n return (\n <div\n ref={ref}\n className={twMerge(\n theme.base,\n theme.color[color],\n rounded && theme.rounded,\n withBorderAccent && theme.borderAccent,\n className,\n )}\n role=\"alert\"\n {...restProps}\n >\n <div className={theme.wrapper} data-testid=\"flowbite-alert-wrapper\">\n {Icon && <Icon className={theme.icon} data-testid=\"flowbite-alert-icon\" />}\n <div>{children}</div>\n {typeof onDismiss === \"function\" && (\n <button\n aria-label=\"Dismiss\"\n className={twMerge(theme.closeButton.base, theme.closeButton.color[color])}\n onClick={onDismiss}\n type=\"button\"\n >\n <XIcon aria-hidden className={theme.closeButton.icon} />\n </button>\n )}\n </div>\n {additionalContent && <div>{additionalContent}</div>}\n </div>\n );\n});\n\nAlert.displayName = \"Alert\";\n"],"names":["forwardRef","provider","useThemeProvider","theme","useResolveTheme","alertTheme","get","resolveProps","jsxs","twMerge","jsx","XIcon"],"mappings":";;;;;;;;;;;;AAWY,MAAC,KAAK,GAAGA,gBAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AAChD,EAAE,MAAMC,UAAQ,GAAGC,yBAAgB,EAAE;AACrC,EAAE,MAAMC,OAAK,GAAGC,4BAAe;AAC/B,IAAI,CAACC,gBAAU,EAAEJ,UAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;AACpD,IAAI,CAACK,OAAG,CAACL,UAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC;AACzD,IAAI,CAACK,OAAG,CAACL,UAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,UAAU;AACxD,GAAG;AACH,EAAE,MAAM;AACR,IAAI,iBAAiB;AACrB,IAAI,QAAQ;AACZ,IAAI,SAAS;AACb,IAAI,KAAK,GAAG,MAAM;AAClB,IAAI,IAAI,EAAE,IAAI;AACd,IAAI,SAAS;AACb,IAAI,OAAO,GAAG,IAAI;AAClB,IAAI,gBAAgB;AACpB,IAAI,GAAG;AACP,GAAG,GAAGM,yBAAY,CAAC,KAAK,EAAEN,UAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;AAChD,EAAE,uBAAuBO,eAA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