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.

38 lines (36 loc) 1.2 kB
import { cs } from "../utils/styles.js"; import vui from "../core/vui.js"; import { Button } from "../button/button.js"; import { useCopyToClipboard } from "./useCopyToClipboard.js"; import { jsx } from "react/jsx-runtime"; //#region src/copyToClipboard/copyToClipboard.tsx const defaultIcon = "falCopy"; /** * A helper button component. * * Copies the provided text to clipboard. * * Copying is available only for a secure environment (https://), otherwise the button is disabled. * */ const CopyToClipboard = vui((props, ref) => { const { disabled, copyText, className, icon = defaultIcon, size = "sm", variant = "tertiary", intent = "brand", ...rest } = props; const { copy, isCopyDisabled } = useCopyToClipboard(copyText); return /* @__PURE__ */ jsx(Button, { "aria-label": `Copy to clipboard ${copyText}`, className: cs("vui-copy-to-clipboard", className), disabled: disabled || isCopyDisabled, icon, intent, onClick: () => copy(), ref, size, variant, ...rest }); }); CopyToClipboard.displayName = "CopyToClipboard"; //#endregion export { CopyToClipboard, CopyToClipboard as default }; globalThis.__vuiVersion__ = "5.3.1" //# sourceMappingURL=copyToClipboard.js.map