UNPKG

@payfit/unity-components

Version:

38 lines (37 loc) • 1.68 kB
import { ReactElement, ReactNode, RefAttributes } from 'react'; /** One item in a dynamic attachment group. */ export interface AttachmentGroupItem { id: string | number; } /** A labelled, scrollable collection of attachments. */ export type AttachmentGroupProps<T extends AttachmentGroupItem> = { /** * Lays out and scrolls items horizontally or vertically. * @default 'horizontal' */ orientation?: 'horizontal' | 'vertical'; /** Controls the size of the scroll area. */ className?: string; /** Accessible name for the keyboard-focusable group. */ 'aria-label': string; } & ({ items: Iterable<T>; children: (item: T) => ReactNode; } | { items?: never; children: ReactNode; }); /** * Groups static or dynamic attachments without taking ownership of their data. * * Supply static children or `items` with a render function; dynamic items need * stable `id` values. Choose `orientation` for horizontal or vertical layout, * and constrain the matching dimension with `className` when scrolling is needed. * Give the group an `aria-label` so its purpose is clear on keyboard focus. * The group exposes list semantics, receives keyboard focus for scrolling, and * shows fades at edges with more content. Its forwarded ref targets the native * scroll viewport; the caller chooses the available width or height. * @param props - Group label and static children or a dynamic collection. * @see {@link AttachmentGroupProps} for the collection contract. */ export declare const AttachmentGroup: <T extends AttachmentGroupItem>(props: AttachmentGroupProps<T> & RefAttributes<HTMLDivElement>) => ReactElement | null;