import { SvelteComponentTyped } from "svelte"; import type { SvelteHTMLElements } from "svelte/elements"; type $RestProps = SvelteHTMLElements["span"]; type $Props = { /** * Specify the text to copy. * Also rendered as the value when the default slot is empty. * When unset, the rendered value text is copied at click time. */ text?: string | undefined; /** * Set the title and ARIA label for the copy button * @default "Copy to clipboard" */ iconDescription?: string; /** * Set the feedback text shown after clicking the button * @default "Copied!" */ feedback?: string; /** * Set the feedback text shown when copying fails * @default "Failed to copy" */ errorFeedback?: string; /** * Set the timeout duration (ms) to display feedback text * @default 2000 */ feedbackTimeout?: number; /** * Override the default copy behavior (`navigator.clipboard.writeText` with * a `document.execCommand("copy")` fallback). * @default copyText */ copy?: (text: string) => void | Promise; /** * Set how the "Copied!" feedback tooltip is rendered. * See `CopyButton` for details. */ portalTooltip?: boolean | undefined; /** * Set the tooltip placement in floating-ui form: the side, then `start` * or `end` along it, as Popover's `align` takes. Above and below, * `start` and `end` name inline sides, so they swap under `dir="rtl"`. * When set, takes precedence over `tooltipPosition` and `tooltipAlignment`. */ tooltipAlign?: "top" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "left-start" | "left-end" | "right" | "right-start" | "right-end" | undefined; /** * Set the position of the tooltip relative to the button. * @deprecated use `tooltipAlign` * @default "bottom" */ tooltipPosition?: "top" | "right" | "bottom" | "left"; /** * Set the alignment of the tooltip relative to the button. * @deprecated use `tooltipAlign` * @default "center" */ tooltipAlignment?: "start" | "center" | "end"; /** * Obtain a reference to the root element. * @default null */ ref?: null | HTMLSpanElement; children?: (this: void) => void; [key: `data-${string}`]: unknown; }; export type CopyTextProps = Omit<$RestProps, keyof $Props> & $Props; export default class CopyText extends SvelteComponentTyped< CopyTextProps, { copy: CustomEvent; "copy:error": CustomEvent<{ error: unknown }>; }, { default: Record } > {}