UNPKG

@payfit/unity-components

Version:

125 lines (124 loc) 5.34 kB
import { ReactElement, ReactNode } from 'react'; import { ToggleButtonProps as AriaToggleButtonProps } from 'react-aria-components/ToggleButton'; export type AITriggerButtonBrandSlotProps = { /** Resolved brand appearance for the trigger's enabled or disabled state. */ appearance: 'color' | 'grayscale'; /** Resolved brand size for the trigger density. */ size: number; /** Applies the trigger-owned brand hover motion. */ className: string; /** Keeps the brand decorative because the button label names the control. */ 'aria-hidden': true; }; export type AITriggerButtonProps = Omit<AriaToggleButtonProps, 'aria-expanded' | 'children' | 'className' | 'isPending'> & { /** * Provides the visible and accessible name for the AI assistant surface. * The label remains available to assistive technology when `iconOnly` is * true. */ children: ReactNode; /** * Renders only the brand mark and exposes `children` in a tooltip. * @default false */ iconOnly?: boolean; /** * Selects the button density. * @default 'default' */ mode?: 'default' | 'compact'; /** * Prevents selection changes and applies the disabled brand treatment while * the assistant surface is loading. * @default false */ isLoading?: boolean; /** * Renders the PayFit AI brand inside a consumer-owned composition, such as * an `Anchor` with a notification `Pill`. Forward every supplied property * to `PayfitAIBrand` to retain the trigger's state treatment and motion. */ brandSlot?: (props: AITriggerButtonBrandSlotProps) => ReactElement; }; /** * Toggles a PayFit AI assistant surface from a compact, recognizable entry * point. * Use `AITriggerButton` with `aria-controls` to associate the trigger with * the panel it reveals. Control it with `isSelected` and `onChange`, or pass * `defaultSelected` for uncontrolled selection. Set `iconOnly` when space is * limited; the label stays available as the button's accessible name and is * shown in a tooltip. * @param props - React Aria toggle-button props and AI trigger appearance * options. * @param props.children - The visible label and accessible name for the AI * assistant surface. The component keeps this label available to assistive * technology when `iconOnly` is `true`. * @param props.iconOnly - Renders only the PayFit AI brand mark and shows the * label in a tooltip. Defaults to `false`. * @param props.mode - Selects the trigger density: `default` uses a 24px brand * mark and `compact` uses a 20px mark. Defaults to `default`. * @param props.isLoading - Disables the trigger and applies its loading brand * treatment while the assistant surface loads. Defaults to `false`. * @param props.brandSlot - Renders a consumer-owned brand composition instead * of `PayfitAIBrand`. It receives `appearance`, `size`, `className`, and * `aria-hidden`; forward every property to the rendered brand to preserve the * trigger's visual state and motion. * @param props.defaultSelected - Sets the initial selected state for an * uncontrolled trigger. * @param props.isSelected - Controls the selected state. Pass this with * `onChange` for a controlled trigger. * @param props.onChange - Receives the next selected state after the user * toggles the trigger. * @param props.isDisabled - Prevents the user from toggling the trigger. * @param props.aria-controls - Identifies the assistant panel that this * trigger reveals. * @see {@link AITriggerButtonProps} for the AI-specific props. * @example * ```tsx * import { AITriggerButton } from '@payfit/unity-components/ai-kit' * * export function AssistantTrigger() { * return ( * <AITriggerButton aria-controls="assistant-panel"> * Payfit AI * </AITriggerButton> * ) * } * ``` * @remarks * - The component renders a native button with React Aria toggle-button * semantics. * - Activate the trigger with Enter or Space. * - The trigger exposes `aria-pressed` and mirrors its selected state through * `aria-expanded` for the associated disclosure. */ export declare const AITriggerButton: import('react').ForwardRefExoticComponent<Omit<AriaToggleButtonProps, "children" | "aria-expanded" | "className" | "isPending"> & { /** * Provides the visible and accessible name for the AI assistant surface. * The label remains available to assistive technology when `iconOnly` is * true. */ children: ReactNode; /** * Renders only the brand mark and exposes `children` in a tooltip. * @default false */ iconOnly?: boolean; /** * Selects the button density. * @default 'default' */ mode?: "default" | "compact"; /** * Prevents selection changes and applies the disabled brand treatment while * the assistant surface is loading. * @default false */ isLoading?: boolean; /** * Renders the PayFit AI brand inside a consumer-owned composition, such as * an `Anchor` with a notification `Pill`. Forward every supplied property * to `PayfitAIBrand` to retain the trigger's state treatment and motion. */ brandSlot?: (props: AITriggerButtonBrandSlotProps) => ReactElement; } & import('react').RefAttributes<HTMLButtonElement>>;