import { type ReactNode } from 'react'; import { type VariantProps } from 'class-variance-authority'; import { type DashboardWidgetLayout } from './dashboard-grid-engine'; export type { DashboardWidgetLayout } from './dashboard-grid-engine'; declare const dashboardGridVariants: (props?: ({ stacked?: boolean | null | undefined; } & import("class-variance-authority/types").ClassProp) | undefined) => string; export interface DashboardGridProps extends Omit, 'stacked'> { /** Accessible name for the board region. Required. */ 'aria-label': string; /** Opaque instance id — emitted as `data-component-id` for the agent registry. */ id?: string; /** Logical column count. Defaults to 12. */ cols?: number; /** Row height in px (one `h` unit). Defaults to 96. */ rowHeight?: number; /** Controlled layout. Entries are matched to widgets by `id`. */ layout?: DashboardWidgetLayout[]; /** Uncontrolled initial layout. */ defaultLayout?: DashboardWidgetLayout[]; /** * Fired after every committed change — move, resize, remove pruning, and * the auto-placement of widgets that had no layout entry. Persist this. */ onLayoutChange?: (next: DashboardWidgetLayout[]) => void; /** Edit mode: shows move/resize/remove chrome and the add tile. */ editing?: boolean; /** * Called when the user activates a widget's remove button. The kit * commits the entry removal (one `onLayoutChange`) and manages focus; * the consumer unmounts the child. Omit to hide the remove button. */ onRemoveWidget?: (id: string) => void; /** * Called when the user activates the add tile (rendered in edit mode * only when this is provided). The consumer appends a new * `DashboardGrid.Widget`; it is auto-placed first-fit and reported via * `onLayoutChange`. */ onRequestAdd?: () => void; /** * Opt-in narrow mode. When the board's OWN inline size (px, measured with * a ResizeObserver, not the viewport) is below this value, the widgets * render as one full-width, read-only column in reading order (`y`, then * logical `x`), each at least its grid height (see `stackedHeight`). No * move/resize/remove chrome or add tile shows, even while `editing` is * on, and `onLayoutChange` never fires because of stacking: the saved * layout is untouched and the grid returns exactly once the board is at * least `stackBelow + 24` px wide (the 24 px band stops a width hovering * on the threshold, or a page scrollbar, from flipping the board). Unset: * the board never stacks. * * Give the board a container whose width does not depend on its content * (normal block flow, or a stretched flex/grid item). In a shrink-to-fit * host the narrower stacked column can keep the board stacked. * Switching between unset and set at runtime remounts the widgets. * * SSR: the server render and the first client render show the grid; the * board measures itself in a layout effect, before the first client * paint. A server-rendered page shows the grid until hydration. */ stackBelow?: number; /** * Fired when the board enters (`true`) or leaves (`false`) the stacked * column, before that mode is painted, so the host can hide its own * customise control. Not fired for the initial unstacked state, nor on * unmount. */ onStackedChange?: (stacked: boolean) => void; /** * Marks one widget, for example while its settings are open: it gets the * inset --primary edge and `aria-current="true"`. Unset, none is marked. */ selectedId?: string; /** * Block size of each widget while the board is stacked (`stackBelow`). * `'grid'` (the default, unchanged) keeps at least the widget's grid * height, so a widget showing one figure leaves empty space below it on a * phone. `'content'` makes each stacked widget as tall as its content. * A chart that fills its container has no height of its own and would * collapse: give its widget a `minStackedHeight`. The grid itself is * unchanged either way. */ stackedHeight?: 'grid' | 'content'; /** * Opt-in heading level for every widget title. Unset (the default), a * title is plain text, as before. Set it to one level below the heading * that introduces the board, so screen-reader users can jump between * widgets by heading. A title cut short by the widget's width is * focusable and shows the full title in a Tooltip either way. */ widgetHeadingLevel?: 2 | 3 | 4 | 5 | 6; /** `DashboardGrid.Widget` children. */ children: ReactNode; className?: string; } export interface DashboardGridHandle { /** * Move a widget to a cell. False when not editing, while stacked, or * when the id is unknown. */ moveWidgetTo: (id: string, x: number, y: number) => boolean; /** * Resize a widget to a span. False when not editing, while stacked, or * when the id is unknown. */ resizeWidgetTo: (id: string, w: number, h: number) => boolean; /** * Scroll a widget into view (its nearest scrolling ancestor and the * window) and highlight it briefly. Safe to call in the same tick that * adds the widget: it waits until the widget is laid out. Resolves true * once revealed, false if the widget has not appeared within a second. */ revealWidget: (id: string) => Promise; /** Current geometry + mode. */ getGridState: () => { cols: number; /** The `editing` prop as the host set it. */ editing: boolean; /** * True while the board is narrower than `stackBelow` and shows one * read-only column. Editing is unavailable until it is false again. */ stacked: boolean; /** The saved grid layout; stacking never changes it. */ layout: DashboardWidgetLayout[]; /** The `selectedId` prop, or null. */ selectedId: string | null; /** Ids of the widgets whose `loading` is set, in render order. */ loadingIds: string[]; }; } /** A header action that folds into the "More actions" menu when narrow. */ export interface DashboardWidgetAction { /** Stable key. */ id: string; /** Accessible name of the button, and the menu item's text. Translated. */ label: string; /** Glyph for the icon button shown on wide widgets. */ icon: ReactNode; onSelect: () => void; } export interface DashboardGridWidgetProps { /** Stable widget id — matches a `layout` entry. */ id: string; /** Visible widget title (consumer-translated). */ title: string; /** Cell span used when the widget has no layout entry yet. */ defaultW?: number; defaultH?: number; /** * Smallest span (columns, rows) the widget can be resized to. Applied on * render only: the board never writes `minW` / `minH` into the layout it * reports through `onLayoutChange`, so a saved layout stays constraint * free. A saved entry narrower than this renders at the minimum and is * reported at that size on the next change. */ minW?: number; minH?: number; /** * Minimum block size in px while the board is stacked with * `stackedHeight="content"`; ignored otherwise. A chart that fills its * container needs it, or it collapses to nothing: the body fills this * height, less the title row. Content taller than it still grows. */ minStackedHeight?: number; /** * Header actions such as a widget's settings, in view and edit mode. Each * is an icon button; on a narrow widget (under 300 px) they fold, with * the remove button, into one "More actions" menu so the title keeps its * room. Prefer this over `actionsSlot`. */ actions?: DashboardWidgetAction[]; /** Extra header content, always shown as given (never folded). */ actionsSlot?: ReactNode; /** * The widget's figures are on their way. The frame, title, header * actions and saved place stay as they are, the widget carries * `aria-busy="true"`, and the body shows `children` as given: pass a * placeholder such as ``. Moving and resizing still * work. Keep the same widget (same `id` and `key`) and swap only its * children when the figures arrive: nothing moves, and the new content * fades in. */ loading?: boolean; /** * One line under the body while `loading`, for example "Preparing * figures" (consumer-translated). Cut with an ellipsis when too long, * and read in full as the widget's description. Without it, assistive * technology hears the kit's "Loading" instead. */ loadingCaption?: string; children?: ReactNode; } declare function DashboardGridWidget({ id, title, minStackedHeight, actions, actionsSlot, loading: loadingProp, loadingCaption, children, }: DashboardGridWidgetProps): import("react/jsx-runtime").JSX.Element | null; declare namespace DashboardGridWidget { var displayName: string; } export declare const DashboardGrid: import("react").ForwardRefExoticComponent> & { Widget: typeof DashboardGridWidget; }; //# sourceMappingURL=dashboard-grid.d.ts.map