@focuson/form_components
Version:
Components that can be used by @focuson/forms
17 lines (16 loc) • 1.62 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CopyToClipboard = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
function CopyToClipboard(props) {
let copied = false;
function onClick() {
copied = true;
navigator.clipboard.writeText(props.textToCopy);
}
function onBlur() {
copied = false;
}
return ((0, jsx_runtime_1.jsx)("button", Object.assign({ type: "button", className: "button-copy", role: "button", title: "Copy", onClick: onClick, onBlur: onBlur }, { children: (0, jsx_runtime_1.jsxs)("span", Object.assign({ className: "icon-copy", title: "Copy to clipboard" }, { children: [(0, jsx_runtime_1.jsxs)("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", className: copied ? "hide-copy-icon" : "show-copy-icon", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "#417505", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, { children: [(0, jsx_runtime_1.jsx)("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }), (0, jsx_runtime_1.jsx)("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })] })), (0, jsx_runtime_1.jsx)("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", className: copied ? "show-copy-icon" : "hide-copy-icon", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "#417505", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, { children: (0, jsx_runtime_1.jsx)("polyline", { points: "20 6 9 17 4 12" }) }))] })) })));
}
exports.CopyToClipboard = CopyToClipboard;