import React, { forwardRef } from "react"; import { BaseAlert } from "../../base-alert"; import { GlobalAlertCloseButton, type GlobalAlertCloseButtonProps, } from "../close-button/GlobalAlertCloseButton"; import { GlobalAlertContent, type GlobalAlertContentProps, } from "../content/GlobalAlertContent"; import { GlobalAlertHeader, type GlobalAlertHeaderProps, } from "../header/GlobalAlertHeader"; import { GlobalAlertTitle, type GlobalAlertTitleProps, } from "../title/GlobalAlertTitle"; interface GlobalAlertProps extends Omit< BaseAlert.RootProps, "type" | "global" | "data-color" > { status: Exclude; /** * data-color has no effect on GlobalAlert. */ "data-color"?: never; /** * Whether title and content are centered or not. * @default true */ centered?: boolean; } interface GlobalAlertComponent extends React.ForwardRefExoticComponent< GlobalAlertProps & React.RefAttributes > { /** * @see 🏷️ {@link GlobalAlertHeaderProps} * @example * ```jsx * * * Info title * * * ``` */ Header: typeof GlobalAlertHeader; /** * Title component for GlobalAlert. Remember to use correct heading-level with the `as` prop. * @see 🏷️ {@link GlobalAlertTitleProps} * @example * ```jsx * * * Info title * * * ``` */ Title: typeof GlobalAlertTitle; /** * @see 🏷️ {@link GlobalAlertContentProps} * @example * ```jsx * * * Info title * * * Content * * ``` */ Content: typeof GlobalAlertContent; /** * @see 🏷️ {@link GlobalAlertCloseProps} * @example * ```jsx * * * Info title * alert("Closed!")} /> * * * ``` */ CloseButton: typeof GlobalAlertCloseButton; } /** * A component for displaying alerts about your app. * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/globalalert) * @see 🏷️ {@link GlobalAlertProps} * @example * ```jsx * * * Alert title * * Content * * ``` */ export const GlobalAlert = forwardRef( ({ centered = true, ...rest }: GlobalAlertProps, forwardedRef) => { return ( ); }, ) as GlobalAlertComponent; GlobalAlert.Header = GlobalAlertHeader; GlobalAlert.Title = GlobalAlertTitle; GlobalAlert.Content = GlobalAlertContent; GlobalAlert.CloseButton = GlobalAlertCloseButton; export default GlobalAlert; export { GlobalAlertCloseButton, GlobalAlertContent, GlobalAlertHeader, GlobalAlertTitle, }; export type { GlobalAlertCloseButtonProps, GlobalAlertContentProps, GlobalAlertHeaderProps, GlobalAlertProps, GlobalAlertTitleProps, };