@slipmatio/toolbelt
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -31,3 +31,18 @@ function storageAvailable(type) { | ||
} | ||
export { getCookie, storageAvailable }; | ||
function copyToClipboard(content) { | ||
const d = document; | ||
try { | ||
const el = document.createElement("input"); | ||
el.setAttribute("style", "opacity:0;"); | ||
el.setAttribute("value", content); | ||
d.body.appendChild(el); | ||
el.select(); | ||
d.execCommand("copy"); | ||
d.body.removeChild(el); | ||
return true; | ||
} catch { | ||
return false; | ||
} | ||
} | ||
export { copyToClipboard, getCookie, storageAvailable }; | ||
//# sourceMappingURL=index.es.js.map |
@@ -1,2 +0,2 @@ | ||
(function(t,n){typeof exports=="object"&&typeof module!="undefined"?n(exports):typeof define=="function"&&define.amd?define(["exports"],n):(t=typeof globalThis!="undefined"?globalThis:t||self,n(t.toolbelt={}))})(this,function(t){"use strict";function n(i){let o;i==="localStorage"?o=window.localStorage:o=window.sessionStorage;try{const e="__storage_test__";return o.setItem(e,e),o.removeItem(e),!0}catch(e){return e instanceof DOMException&&(e.code===22||e.code===1014||e.name==="QuotaExceededError"||e.name==="NS_ERROR_DOM_QUOTA_REACHED")&&o&&o.length!==0}}function c(i){let o=null;if(document.cookie&&document.cookie!==""){const e=document.cookie.split(";");for(let l=0;l<e.length;l++){const s=e[l].trim();if(s.substring(0,i.length+1)===i+"="){o=decodeURIComponent(s.substring(i.length+1));break}}}return o}t.getCookie=c,t.storageAvailable=n,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); | ||
(function(o,i){typeof exports=="object"&&typeof module!="undefined"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(o=typeof globalThis!="undefined"?globalThis:o||self,i(o.toolbelt={}))})(this,function(o){"use strict";function i(n){let t;n==="localStorage"?t=window.localStorage:t=window.sessionStorage;try{const e="__storage_test__";return t.setItem(e,e),t.removeItem(e),!0}catch(e){return e instanceof DOMException&&(e.code===22||e.code===1014||e.name==="QuotaExceededError"||e.name==="NS_ERROR_DOM_QUOTA_REACHED")&&t&&t.length!==0}}function r(n){let t=null;if(document.cookie&&document.cookie!==""){const e=document.cookie.split(";");for(let c=0;c<e.length;c++){const l=e[c].trim();if(l.substring(0,n.length+1)===n+"="){t=decodeURIComponent(l.substring(n.length+1));break}}}return t}function u(n){const t=document;try{const e=document.createElement("input");return e.setAttribute("style","opacity:0;"),e.setAttribute("value",n),t.body.appendChild(e),e.select(),t.execCommand("copy"),t.body.removeChild(e),!0}catch{return!1}}o.copyToClipboard=u,o.getCookie=r,o.storageAvailable=i,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); | ||
//# sourceMappingURL=index.umd.js.map |
@@ -9,1 +9,5 @@ /** | ||
export declare function getCookie(name: string): string | null; | ||
/** | ||
* Simple clipboard copy for modern browsers. Returns true if successful. | ||
*/ | ||
export declare function copyToClipboard(content: string): boolean; |
@@ -1,1 +0,1 @@ | ||
export { storageAvailable, getCookie } from './browser'; | ||
export { storageAvailable, getCookie, copyToClipboard } from './browser'; |
{ | ||
"name": "@slipmatio/toolbelt", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"main": "dist/index.es.js", | ||
@@ -55,3 +55,3 @@ "module": "dist/index.es.js", | ||
"vite-plugin-istanbul": "^2.5.0", | ||
"vitest": "~0.5", | ||
"vitest": "~0.6", | ||
"vue": "~3.2", | ||
@@ -58,0 +58,0 @@ "wait-on": "~6.0" |
@@ -10,4 +10,5 @@ # Slipmat Toolbelt | ||
- `copyToClipboard(content: string): boolean` | ||
- `getCookie(name: string): string | null` | ||
- `storageAvailable(type: 'localStorage' | 'sessionStorage'): boolean` | ||
- `getCookie(name: string): string | null` | ||
@@ -14,0 +15,0 @@ ## Installation |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
13307
66
42