import { ReactElement, ReactNode } from 'react'; export interface DynamicToolbarActionRenderOptions { showLabel: boolean; } export interface DynamicToolbarAction { id: string; label: string; onClick: () => void; icon?: ReactElement; disabled?: boolean; /** * Why the action is unavailable. With `disabled` the button or More-menu item stays focusable * and shows the reason on hover, focus and tap (disabled-states DIS-1…DIS-3). */ disabledReason?: ReactNode; /** * Busy: the button shows a spinner, sets `aria-busy` and ignores activation (disabled-states DIS-8). * In the More menu the item is disabled with the reason "In progress" in the toolbar locale. Pass a * boolean from the first render so the busy announcement region exists before it turns on. */ loading?: boolean; /** * Whether a `loading` action keeps the dialog around it open (no Esc, backdrop, X or Cancel), inline * and in the More menu; defaults to `true`, the rule for a running save (submit-buttons SUB-8). Pass * `false` for an action that is not a save, such as a preview or a lookup. */ holdsDialog?: boolean; hidden?: boolean; variant?: 'contained' | 'outlined' | 'text' | 'textGray' | 'textWhite'; /** Visual tone. `danger` renders the action in the destructive/red palette. */ tone?: 'default' | 'danger'; size?: 'large' | 'small' | 'medium'; /** * Higher priority resists overflow longer — lower-priority actions move * into the More menu first. Label collapse is positional (right to left). */ priority?: number; /** Never move into the More overflow menu. */ keepVisible?: boolean; /** Allow label + icon to collapse to icon-only. */ canHideLabel?: boolean; /** Allow moving into the More overflow menu. */ canOverflow?: boolean; dataTest?: string; estimatedWidthPx?: number; ariaLabel?: string; /** Custom inline renderer for richer actions such as popover triggers. */ render?: (options: DynamicToolbarActionRenderOptions) => ReactElement; /** * Skip the measurement strip for this action and plan with `estimatedWidthPx` * instead. For stateful renderers (widgets, stores, always-mounted dialogs) * that must mount exactly once. Combine with `keepVisible` so the single * mount stays in the visible row. */ measureInStrip?: boolean; } export interface PlannedToolbarAction { action: DynamicToolbarAction; showLabel: boolean; width: number; } export interface PlannedToolbarActions { inlineActions: PlannedToolbarAction[]; overflowActions: DynamicToolbarAction[]; showMoreMenu: boolean; } export declare const ACTION_GAP_PX = 8; /** Fallback width of the icon-only "More" overflow trigger button. */ export declare const MORE_BUTTON_PX = 40; /** * Supplies the real (measured) width of an action. Returning `undefined` * falls back to `estimateToolbarActionWidth`. */ export type ResolveToolbarActionWidth = (action: DynamicToolbarAction, showLabel: boolean) => number | undefined; export declare function estimateToolbarActionWidth(action: DynamicToolbarAction, showLabel: boolean): number; export declare function resolveToolbarActionWidth(action: DynamicToolbarAction, showLabel: boolean, resolveActionWidth?: ResolveToolbarActionWidth): number; export declare function planToolbarActions(options: { actions: DynamicToolbarAction[]; availableWidth: number; maxInlineActions?: number; collapseLabels?: boolean; resolveActionWidth?: ResolveToolbarActionWidth; moreButtonWidthPx?: number; }): PlannedToolbarActions; /** * Bulk actions overflow progressively: every action keeps its full label, * and the lowest-priority actions drop into the "More" menu until the * remaining inline strip fits the available width. */ export declare function planBulkToolbarActions(options: { actions: DynamicToolbarAction[]; availableWidth: number; maxVisibleBulkActions?: number; resolveActionWidth?: ResolveToolbarActionWidth; moreButtonWidthPx?: number; }): PlannedToolbarActions;