import { SvelteComponentTyped } from "svelte"; import type { SvelteHTMLElements } from "svelte/elements"; type $RestProps = SvelteHTMLElements["input"]; type $Props = { /** * Specify the value to display and copy. * @default "" */ value?: string; /** * Set to `"password"` to obscure the value. * Use `revealMode` to reveal the value on interaction. * @default "text" */ type?: "text" | "password"; /** * Specify the text to show in place of `value`, such as an API key * masked to `sk_live_••••4f2a`. The copy button still copies `value`, * and `revealMode` shows `value` on interaction. * Unlike `type="password"`, browsers don't offer to save it. */ maskedValue?: string | undefined; /** * Control when a `type="password"` value or a `maskedValue` is revealed. * Has no effect unless `type` is `"password"` or `maskedValue` is set. * - `"focus"`: reveal while the input is focused. * - `"hover-focus"`: reveal while the input is hovered or focused. * When unset, the value stays obscured; the copy button still copies the full value. */ revealMode?: "focus" | "hover-focus" | undefined; /** * Set to `true` to select the full value when the input receives focus. * @default false */ selectTextOnFocus?: boolean; /** * Set the size of the input. * Inherits the parent `Form` size when unset. * Also accepts Carbon v11's `"md"` (the 40px default, which overrides a * `Form` size) and `"lg"` (`"xl"`). */ size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined; /** * Set to `true` to disable the input and copy button. The copy button is * also disabled while `value` is empty, unless `copy` is overridden. * @default false */ disabled?: boolean; /** * Set to `true` to use the inline variant * @default false */ inline?: boolean; /** * Set to `true` to use the fluid variant. * Inherited from the parent `FluidForm` context, * so it does not need to be set when used inside `FluidForm`. * Cannot be combined with the inline variant. * @default false */ fluid?: boolean; /** * Specify the label text * @default "" */ labelText?: string; /** * Set to `true` to visually hide the label text * @default false */ hideLabel?: boolean; /** * Specify the helper text * @default "" */ helperText?: string; /** * Set an id for the input element * @default uniqueId() */ id?: string; /** * Specify a name attribute for the input. */ name?: string | undefined; /** * Obtain a reference to the input HTML element. * @default null */ ref?: null | HTMLInputElement; /** * Set the feedback text shown after clicking the copy button * @default "Copied!" */ feedback?: string; /** * Set the feedback text shown when copying fails * @default "Failed to copy" */ errorFeedback?: string; /** * Specify an icon to render during the feedback window (for example, after copying). * When unset, the copy icon is always shown. */ feedbackIcon?: Icon | undefined; /** * Set the timeout duration (ms) to display the feedback text * @default 2000 */ feedbackTimeout?: number; /** * Set the title and ARIA label for the copy button * @default "Copy to clipboard" */ iconDescription?: string; /** * Override the default copy behavior (`navigator.clipboard.writeText` with * a `document.execCommand("copy")` fallback). Failures reject so the control * can show `errorFeedback` and dispatch `copy:error`. * @default copyText */ 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`. */ 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 copy button's tooltip. * @deprecated use `tooltipAlign` * @default "bottom" */ tooltipPosition?: "top" | "right" | "bottom" | "left"; /** * Set the alignment of the copy button's tooltip. * @deprecated use `tooltipAlign` * @default "end" */ tooltipAlignment?: "start" | "center" | "end"; labelChildren?: (this: void) => void; [key: `data-${string}`]: unknown; }; export type CopyInputProps = Omit<$RestProps, keyof $Props> & $Props; export default class CopyInput extends SvelteComponentTyped< CopyInputProps, { blur: WindowEventMap["blur"]; click: WindowEventMap["click"]; copy: CustomEvent; "copy:error": CustomEvent<{ error: unknown }>; focus: WindowEventMap["focus"]; mouseenter: WindowEventMap["mouseenter"]; "mouseenter:copy-button": CustomEvent; mouseleave: WindowEventMap["mouseleave"]; "mouseleave:copy-button": CustomEvent; mouseover: WindowEventMap["mouseover"]; }, { labelChildren: Record } > {}