UNPKG

@sjsf-lab/shadcn-extras-theme

Version:

The shadcn-svelte-extras based theme for svelte-jsonschema-form

50 lines (49 loc) 1.25 kB
type Options = { /** The time before the copied status is reset. */ delay: number; }; /** Use this hook to copy text to the clipboard and show a copied state. * * ## Usage * ```svelte * <script lang="ts"> * import { UseClipboard } from "./use-clipboard.svelte"; * * const clipboard = new UseClipboard(); * </script> * * <button onclick={clipboard.copy('Hello, World!')}> * {#if clipboard.copied === 'success'} * Copied! * {:else if clipboard.copied === 'failure'} * Failed to copy! * {:else} * Copy * {/if} * </button> * ``` * */ export declare class UseClipboard { #private; private delay; private timeout; constructor({ delay }?: Partial<Options>); /** Copies the given text to the users clipboard. * * ## Usage * ```ts * clipboard.copy('Hello, World!'); * ``` * * @param text * @returns */ copy(text: string): Promise<"success" | "failure">; /** true when the user has just copied to the clipboard. */ get copied(): boolean; /** Indicates whether a copy has occurred * and gives a status of either `success` or `failure`. */ get status(): "success" | "failure" | undefined; } export {};