UNPKG

@veracity/vui

Version:

Veracity UI is a React component library crafted for use within Veracity applications and pages. Based on Styled Components and @xstyled.

19 lines (17 loc) 627 B
import { useToast } from "../toast/useToast.js"; //#region src/copyToClipboard/useCopyToClipboard.ts const useCopyToClipboard = (copyText) => { const { showSuccess, showError } = useToast(); const isCopyDisabled = !window?.navigator?.clipboard?.writeText; const copy = () => { if (!isCopyDisabled) window?.navigator?.clipboard.writeText?.(copyText).then(() => showSuccess(`Copied to clipboard: ${copyText}`)).catch(() => showError("Copy failed")); }; return { copy, isCopyDisabled }; }; //#endregion export { useCopyToClipboard }; globalThis.__vuiVersion__ = "5.3.1" //# sourceMappingURL=useCopyToClipboard.js.map