import React from 'react'; import { type ButtonProps } from './Button.js'; export type CopyButtonState = 'idle' | 'copied' | 'failed'; export interface CopyButtonProps { /** * What is copied. A function is called at the moment of the press, for a * value read from somewhere that changes — the text in an editor. */ value: string | (() => string); /** Names the action — "Copy", "Copy run ID". Default "Copy". */ label?: string; /** Shown and announced once copied. Default "Copied". */ copiedLabel?: string; /** Shown and announced when the clipboard refused. Default "Couldn't copy". */ failedLabel?: string; /** * Draw only the icon. `label` becomes the name and the tooltip, so it must * say what is copied: "Copy run ID", not "Copy". */ isIconOnly?: boolean; /** Tertiary beside the value it copies; secondary among other actions. */ variant?: 'tertiary' | 'secondary'; size?: Exclude; isDisabled?: boolean; /** Milliseconds the confirmation stays before the button returns. Default 2000. */ resetAfter?: number; /** Copied — with the text that was. */ onCopy?: (text: string) => void; /** * The clipboard refused. Show `text` where it can be selected by hand; the * button has already said it failed. */ onCopyError?: (error: unknown, text: string) => void; id?: string; className?: string; } /** * CopyButton — copies a value, confirms in place, and says so. * * CONFIRMS WHERE THE EYE ALREADY IS. The icon becomes a check and the label * "Copied" for two seconds, then both return. A toast would confirm in a * corner the user is not looking at, and stack up when they copy three * things in a row. The labels share one cell, so the button is always as wide * as its longest one and nothing beside it moves. * * SAYS SO ONCE. A polite live region beside the button reads "Copied" on each * press. A changed name alone is not reliably announced, and not at all when * the button was pressed by a script or lost focus. Each press replaces the * region's text node, so a second copy is announced too. * * AND SAYS WHEN IT FAILED. A clipboard can be refused — a denied permission, * a non-secure origin with no fallback. The button then shows "Couldn't * copy" with an alert icon, and `onCopyError` receives the text so the caller * can put it where it can be selected by hand. It never claims a copy that * did not happen. */ export declare const CopyButton: React.ForwardRefExoticComponent>; //# sourceMappingURL=CopyButton.d.ts.map