UNPKG

@tamagui/react-native-web-lite

Version:
48 lines (47 loc) 1.95 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: !0 }); }, __copyProps = (to, from, except, desc) => { if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod); var Clipboard_exports = {}; __export(Clipboard_exports, { default: () => Clipboard }); module.exports = __toCommonJS(Clipboard_exports); let clipboardAvailable; class Clipboard { static isAvailable() { return clipboardAvailable === void 0 && (clipboardAvailable = typeof document.queryCommandSupported == "function" && document.queryCommandSupported("copy")), clipboardAvailable; } static getString() { return Promise.resolve(""); } static setString(text) { let success = !1; const body = document.body; if (body) { const node = document.createElement("span"); node.textContent = text, node.style.opacity = "0", node.style.position = "absolute", node.style.whiteSpace = "pre-wrap", node.style.userSelect = "auto", body.appendChild(node); const selection = window.getSelection(); selection.removeAllRanges(); const range = document.createRange(); range.selectNodeContents(node), selection.addRange(range); try { document.execCommand("copy"), success = !0; } catch { } selection.removeAllRanges(), body.removeChild(node); } return success; } } //# sourceMappingURL=index.js.map