UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

38 lines (37 loc) 1.74 kB
import type { ReactNode } from 'react'; import type { InternalLocale } from '../../shared/Context'; import type { UlAllProps } from '../../elements/Ul'; import type { OlAllProps } from '../../elements/Ol'; export type ListFormatProps = { /** * Locale used to format the value when variant is `text`. * Defaults to the shared Provider locale. */ locale?: InternalLocale; /** * Formatting options for the value when variant is `text`. See the [Intl.ListFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat) documentation. */ format?: Intl.ListFormatOptions; /** * Defines if the value should be displayed in list format (`ol`, `ul`) or regular text format in one line. Defaults to `text`. */ variant?: 'ol' | 'ul' | 'text'; /** * Defines the type of list styling used for list variants. Used together with variant `ol` and `ul`. Variant `ol`: `a`, `A`, `i`, `I` and `1`. Variant `ul`: `circle`, `disc` and `square`. Defaults to `undefined`. */ listType?: 'a' | 'A' | 'i' | 'I' | '1' | 'circle' | 'disc' | 'square' | 'unstyled' | undefined; /** * The value to format. Can be given as `children` instead. */ value?: Array<ReactNode>; /** * The children to format. */ children?: ReactNode; }; declare function ListFormat(localProps: Omit<UlAllProps, 'value'> & Omit<OlAllProps, 'value'> & ListFormatProps): string | any[] | import("react/jsx-runtime").JSX.Element; export declare function listFormat(list: Array<ReactNode>, { locale, format, }?: { locale?: InternalLocale; format?: ListFormatProps['format']; }): string | any[]; export default ListFormat;