import React, { forwardRef } from "react"; import { BaseAlert } from "../../base-alert"; import { InfoCardContent, type InfoCardContentProps, } from "../content/InfoCardContent"; import { InfoCardHeader, type InfoCardHeaderProps, } from "../header/InfoCardHeader"; import { InfoCardMessage, type InfoCardMessageProps, } from "../message/InfoCardMessage"; import { InfoCardTitle, type InfoCardTitleProps } from "../title/InfoCardTitle"; type InfoCardProps = Omit< BaseAlert.RootProps, "type" | "global" | "status" | "as" > & { /** * Changes the HTML element used for the root element. * * **When using `section`, provide either `aria-label` or `aria-labelledby` for better accessibility.** * `axe-core` might warn about unique landmarks if you have multiple InfoCards on page with the same label. * In those cases consider updating to unique `aria-label` or `aria-labelledby` props. * @see [📝 Landmarks unique](https://dequeuniversity.com/rules/axe/4.6/landmark-unique) * @default "div" */ as?: "div" | "section"; }; interface InfoCardComponent extends React.ForwardRefExoticComponent< InfoCardProps & React.RefAttributes > { /** * @see 🏷️ {@link InfoCardHeaderProps} * @example * ```jsx * * }> * Info title * * * ``` */ Header: typeof InfoCardHeader; /** * Title component for InfoCard. Remember to use correct heading-level with the `as` prop. * @see 🏷️ {@link InfoCardTitleProps} * @example * ```jsx * * * Info title * * * ``` */ Title: typeof InfoCardTitle; /** * @see 🏷️ {@link InfoCardContentProps} * @example * ```jsx * * * Info title * * * Content * * ``` */ Content: typeof InfoCardContent; /** * @see 🏷️ {@link InfoCardMessageProps} * @example * ```jsx * * }> * Message contents * * * ``` */ Message: typeof InfoCardMessage; } /** * A component for displaying informational content in a card format. * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/infocard) * @see 🏷️ {@link InfoCardProps} * @example * ```jsx * * }> * Info title * * Content * * ``` */ export const InfoCard = forwardRef( ( { "data-color": dataColor = "info", as = "div", ...restProps }: InfoCardProps, forwardedRef, ) => { return ( ); }, ) as InfoCardComponent; InfoCard.Header = InfoCardHeader; InfoCard.Title = InfoCardTitle; InfoCard.Content = InfoCardContent; InfoCard.Message = InfoCardMessage; export default InfoCard; export { InfoCardContent, InfoCardHeader, InfoCardTitle, InfoCardMessage }; export type { InfoCardProps, InfoCardHeaderProps, InfoCardTitleProps, InfoCardContentProps, InfoCardMessageProps, };