import React, { forwardRef, useContext } from "react"; import { BodyLong } from "../typography"; import { cl } from "../utils/helpers"; import { ListItem } from "./List.Item"; import { ListContext } from "./List.context"; import type { ListItemProps, ListProps } from "./List.types"; interface ListComponent extends React.ForwardRefExoticComponent< ListProps & React.RefAttributes > { /** * @see 🏷️ {@link ListItemProps} */ Item: typeof ListItem; } /** * A list component * * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/list) * @see 🏷️ {@link ListProps | Props} * * @example * ```jsx * * Coffee * Tea * Milk * * ``` */ export const List = forwardRef( ( { children, className, as: ListTag = "ul", size, "aria-label": _ariaLabel, "aria-labelledby": _ariaLabelledBy, ...rest }, ref, ) => { const { size: contextSize } = useContext(ListContext); const listSize = size ?? contextSize; return ( {children} ); }, ) as ListComponent; List.Item = ListItem; export default List; export { ListItem }; export type { ListProps, ListItemProps };