import { SvelteComponentTyped } from "svelte"; import type { SvelteHTMLElements } from "svelte/elements"; type $RestProps = SvelteHTMLElements["button"]; type $Props = { /** * Set the feedback text shown after clicking the button * @default "Copied!" */ feedback?: string; /** * Set the timeout duration (ms) to display feedback text * @default 2000 */ feedbackTimeout?: number; /** * Specify an icon to render during the feedback window (for example, after copying). * When unset, the copy icon is always shown. * @default undefined */ feedbackIcon?: Icon; /** * Set the title and ARIA label for the copy button * @default "Copy to clipboard" */ iconDescription?: string; /** * Specify the text to copy. * @default undefined */ text?: string; /** * Override the default copy behavior (navigator.clipboard.writeText). */ copy?: (text: string) => void | Promise; /** * Set to `true` to render the feedback tooltip in a portal, * preventing it from being clipped by `overflow: hidden` containers. * By default, the tooltip is portalled when inside a `Modal`. * @default undefined */ portalTooltip?: boolean | undefined; /** * Obtain a reference to the underlying button element. * @default null */ ref?: null | HTMLButtonElement; [key: `data-${string}`]: unknown; }; export type CopyButtonProps = Omit<$RestProps, keyof $Props> & $Props; export default class CopyButton extends SvelteComponentTyped< CopyButtonProps, { animationend: WindowEventMap["animationend"]; blur: WindowEventMap["blur"]; click: WindowEventMap["click"]; copy: CustomEvent; "copy:error": CustomEvent; focus: WindowEventMap["focus"]; mouseenter: WindowEventMap["mouseenter"]; mouseleave: WindowEventMap["mouseleave"]; }, Record > {}