import React, { forwardRef } from "react"; import { BaseAlert } from "../../base-alert"; import { LocalAlertCloseButton, type LocalAlertCloseButtonProps, } from "../close-button/LocalAlertCloseButton"; import { LocalAlertContent, type LocalAlertContentProps, } from "../content/LocalAlertContent"; import { LocalAlertHeader, type LocalAlertHeaderProps, } from "../header/LocalAlertHeader"; import { LocalAlertTitle, type LocalAlertTitleProps, } from "../title/LocalAlertTitle"; interface LocalAlertProps extends Omit< BaseAlert.RootProps, "type" | "global" | "data-color" > { status: Exclude; /** * data-color has no effect on LocalAlert. */ "data-color"?: never; } interface LocalAlertComponent extends React.ForwardRefExoticComponent< LocalAlertProps & React.RefAttributes > { /** * @see 🏷️ {@link LocalAlertHeaderProps} * @example * ```jsx * * * Info title * * * ``` */ Header: typeof LocalAlertHeader; /** * Title component for LocalAlert. Remember to use correct heading-level with the `as` prop. * @see 🏷️ {@link LocalAlertTitleProps} * @example * ```jsx * * * Info title * * * ``` */ Title: typeof LocalAlertTitle; /** * @see 🏷️ {@link LocalAlertContentProps} * @example * ```jsx * * * Info title * * * Content * * ``` */ Content: typeof LocalAlertContent; /** * @see 🏷️ {@link LocalAlertCloseProps} * @example * ```jsx * * * Info title * alert("Closed!")} /> * * * ``` */ CloseButton: typeof LocalAlertCloseButton; } /** * A component for displaying important messages about a certain part of the page. * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/localalert) * @see 🏷️ {@link LocalAlertProps} * @example * ```jsx * * * Alert title * * Content * * ``` */ export const LocalAlert = forwardRef( ({ status, ...restProps }: LocalAlertProps, forwardedRef) => { return ( ); }, ) as LocalAlertComponent; LocalAlert.Header = LocalAlertHeader; LocalAlert.Title = LocalAlertTitle; LocalAlert.Content = LocalAlertContent; LocalAlert.CloseButton = LocalAlertCloseButton; export default LocalAlert; export { LocalAlertContent, LocalAlertHeader, LocalAlertTitle, LocalAlertCloseButton, }; export type { LocalAlertProps, LocalAlertContentProps, LocalAlertHeaderProps, LocalAlertTitleProps, LocalAlertCloseButtonProps, };