import { type MouseEventHandler, type ReactNode } from 'react'; import type { ButtonProps } from '../Button/Button.types'; /** The action slot a `CardWidgetActionButton` was passed to, which is what determines its emphasis. */ export type CardWidgetActionSlot = 'action' | 'actionSecondary'; type CardWidgetActionButtonBase = Pick & { /** * `HTMLElement` rather than a narrower target, because an action is a `button` or an `a` * depending on whether `href` is set. * @default undefined */ onClick?: MouseEventHandler; /** * Rendered beside `label`, on the side set by `iconPosition`, or as the only content of an * unlabelled action. Size it yourself — 16px is expected in both cases. * @default undefined */ icon?: ReactNode; 'data-testid'?: string; }; /** An action with a visible label, rendered as a small button. */ type CardWidgetLabelledActionButton = CardWidgetActionButtonBase & { /** Non-rendering values are excluded, so an unlabelled action has to meet the icon-only rules. */ label: Exclude; /** * Side of the label the `icon` is rendered on. * @default 'end' */ iconPosition?: 'start' | 'end'; /** @default undefined */ 'aria-label'?: string; }; /** * An action with no visible label, rendered as a 32px icon button. The icon is * the only thing on screen and `aria-label` is the only accessible name, so * both are required. */ type CardWidgetIconActionButton = CardWidgetActionButtonBase & { label?: never; /** An unlabelled action has no label for the icon to sit beside. */ iconPosition?: never; icon: ReactNode; 'aria-label': string; }; /** * An action the `CardWidget` header renders as a button. With a `label` it is a small `Button`; without * one, a 32px `IconButton`, which requires both an `icon` and an `aria-label`. Emphasis is not * part of the object — it comes from the slot the action is passed to. */ export type CardWidgetActionButton = CardWidgetLabelledActionButton | CardWidgetIconActionButton; /** * Tells a `CardWidgetActionButton` object apart from any other node passed to an action slot. * Every button action has a `label` or an `icon`, which no React element, portal or array does. */ export declare const isCardWidgetActionButton: (value: unknown) => value is CardWidgetActionButton; /** Renders a `CardWidgetActionButton` at the emphasis of the slot it was passed to. */ declare const CardWidgetAction: ({ action: { label, icon, iconPosition, "aria-label": ariaLabel, "data-testid": dataTestId, href, target, onClick, disabled, }, slot, }: { action: CardWidgetActionButton; slot: CardWidgetActionSlot; }) => import("react").JSX.Element; export default CardWidgetAction; //# sourceMappingURL=CardWidgetAction.d.ts.map