UNPKG

@tamagui/react-native-web-lite

Version:
64 lines 2.02 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: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__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: true }), mod); var Clipboard_exports = {}; __export(Clipboard_exports, { Clipboard: () => Clipboard }); module.exports = __toCommonJS(Clipboard_exports); let clipboardAvailable; class Clipboard { static isAvailable() { if (clipboardAvailable === void 0) { clipboardAvailable = typeof document.queryCommandSupported === "function" && document.queryCommandSupported("copy"); } return clipboardAvailable; } static getString() { return Promise.resolve(""); } static setString(text) { let success = false; 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 = true; } catch (e) {} selection.removeAllRanges(); body.removeChild(node); } return success; } }