@companix/utils-browser 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.cjs.js +1 -1
- package/dist/bundle.esm.js +1 -1
- package/dist/download.d.ts +6 -0
- package/package.json +1 -1
package/dist/bundle.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=(t,o)=>{if(o(t),t.children)for(const s of Array.from(t.children))"DIV"===s.tagName&&e(s,o)},t="undefined"!=typeof window&&!!window.document&&!!window.document.createElement,o=t&&!!window.addEventListener;function s(e){e||(e=t?navigator.userAgent:"");const o=w(e=e.toLowerCase()),s=o||e.includes("ipad"),i=!s&&-1!==e.search(/iphone|ipod/),n=i||s;let r=n&&e.match(/os ([\d_]+) like mac os x/i),a=0,c=0;o?(a=13,c=0):r&&(r=r[1].split("_"),a=+r[0],c=+r[1]),r=null;const h=a<13&&!(11===a&&c<3),d=n&&function(e){if(!t)return!1;const o=window.webkit;if(o&&o.messageHandlers)return!0;const s=/constructor/i.test(String(window.HTMLElement)),i=!!window.indexedDB;if(e.includes("safari")&&e.includes("version")&&!navigator.standalone);else if(!i&&s||!window.statusbar||!window.statusbar.visible);else if(!s||i)return!0;return!1}(e);let
|
|
1
|
+
"use strict";const e=(t,o)=>{if(o(t),t.children)for(const s of Array.from(t.children))"DIV"===s.tagName&&e(s,o)},t="undefined"!=typeof window&&!!window.document&&!!window.document.createElement,o=t&&!!window.addEventListener;function s(e){e||(e=t?navigator.userAgent:"");const o=w(e=e.toLowerCase()),s=o||e.includes("ipad"),i=!s&&-1!==e.search(/iphone|ipod/),n=i||s;let r=n&&e.match(/os ([\d_]+) like mac os x/i),a=0,c=0;o?(a=13,c=0):r&&(r=r[1].split("_"),a=+r[0],c=+r[1]),r=null;const h=a<13&&!(11===a&&c<3),d=n&&function(e){if(!t)return!1;const o=window.webkit;if(o&&o.messageHandlers)return!0;const s=/constructor/i.test(String(window.HTMLElement)),i=!!window.indexedDB;if(e.includes("safari")&&e.includes("version")&&!navigator.standalone);else if(!i&&s||!window.statusbar||!window.statusbar.visible);else if(!s||i)return!0;return!1}(e);let p=!1;t&&(p=n&&375===window.screen.width&&812===window.screen.height&&3===window.devicePixelRatio);return{isIPad:s,isIPhone:i,isIOS:n,isIPadOS:o,iosMajor:a,iosMinor:c,isWKWebView:d,isScrollBasedViewport:h,isIPhoneX:p,isIOSChrome:-1!==e.search(/crios/i)}}const i=s(),n=i.isIPad,r=i.isIPhone,a=i.isIOS,c=i.isIPadOS,h=i.iosMajor,d=i.iosMinor,p=i.isWKWebView,u=i.isScrollBasedViewport,l=i.isIPhoneX,x=i.isIOSChrome;function w(e){if(!t)return!1;const o=!/ipPad|iPhone|iPod/i.test(e),s=/Mac OS/i.test(e);return o&&s&&"ontouchend"in document}const m=(()=>{const e={hasMouse:!1,hasTouchEvents:!1,hasHover:!1,hasTouch:!1};if(!t)return e;if(a&&!c)e.hasMouse=!1,e.hasHover=!1,e.hasTouchEvents=!0,e.hasTouch=!0;else if(e.hasTouchEvents="ontouchstart"in document,e.hasTouch=e.hasTouchEvents||"maxTouchPoints"in navigator&&navigator.maxTouchPoints>0,e.hasTouch){const t=!/android|mobile|tablet/i.test(navigator.userAgent);e.hasMouse="function"==typeof window.matchMedia&&window.matchMedia("(pointer)").matches?matchMedia("(pointer: fine)").matches:t,e.hasHover=e.hasMouse&&("function"==typeof window.matchMedia&&window.matchMedia("(hover)").matches?matchMedia("(hover: hover)").matches:t)}else e.hasMouse=!0,e.hasHover=!0;return e})(),f=m.hasMouse,v=m.hasHover,O=m.hasTouchEvents,E=m.hasTouch;exports.Download=async(e,t)=>{const o=document.createElement("a"),s=URL.createObjectURL(e);o.href=s,o.setAttribute("download",t),o.click(),URL.revokeObjectURL(s)},exports.IOS_NO_KEYBOARD_ALLOWED_OFFSET=70,exports.IPHONE_KEYBOARD_REJECT_OFFSET=180,exports.IPHONE_SAFARI_BOTTOM_BAR=45,exports.IPHONE_X_SAFARI_BOTTOM_BAR=85,exports.attr=e=>e?"":void 0,exports.backgroundImage=e=>({backgroundImage:`url("${e}")`}),exports.box=(e=48,t)=>(t||(t=e),{width:t,minWidth:t,minHeight:e,height:e}),exports.callMultiple=(...e)=>(...t)=>e.filter(e=>"function"==typeof e).forEach(e=>e(...t)),exports.canUseDOM=t,exports.canUseEventListeners=o,exports.capitalize=e=>e[0].toUpperCase()+e.slice(1),exports.checkIPadOS=w,exports.clamp=(e,t,o)=>Math.max(t,Math.min(e,o)),exports.contains=(e,t)=>!(!e||!t)&&e.contains(t),exports.detectIOS=s,exports.generatePreview=e=>{const t=URL.createObjectURL(e);return{url:t,destroy:()=>{URL.revokeObjectURL(t)}}},exports.getActiveElementByAnotherElement=e=>e?e.ownerDocument.activeElement:null,exports.getContainers=e,exports.getFiles=e=>Array.from(e),exports.hasHover=v,exports.hasMouse=f,exports.hasTouch=E,exports.hasTouchEvents=O,exports.height=e=>({height:e,minHeight:e,maxHeight:e}),exports.iosMajor=h,exports.iosMinor=d,exports.isHTMLElement=e=>e.nodeType===Node.ELEMENT_NODE,exports.isIOS=a,exports.isIOSChrome=x,exports.isIPad=n,exports.isIPadOS=c,exports.isIPhone=r,exports.isIPhoneX=l,exports.isLandscapePhone=function(){return 90===Math.abs(window.orientation)&&!n},exports.isRetina=function(){return window.devicePixelRatio>=2},exports.isScrollBasedViewport=u,exports.isWKWebView=p,exports.onDOMLoaded=e=>{"loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",e)},exports.pc=e=>`${e}%`,exports.px=e=>`${e}px`,exports.setCssVariable=(e,t)=>{document.documentElement.style.setProperty(e,t)},exports.transport=e=>{const t=new FormData;return t.append("file",e),t.append("type","file"),t},exports.varToStyle=e=>e,exports.width=e=>({width:e,minWidth:e,maxWidth:e});
|
package/dist/bundle.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=e=>`${e}%`,t=e=>`${e}px`,o=e=>({width:e,minWidth:e,maxWidth:e}),
|
|
1
|
+
const e=e=>`${e}%`,t=e=>`${e}px`,o=e=>({width:e,minWidth:e,maxWidth:e}),n=e=>({height:e,minHeight:e,maxHeight:e}),i=(e=48,t)=>(t||(t=e),{width:t,minWidth:t,minHeight:e,height:e}),s=e=>({backgroundImage:`url("${e}")`}),a=(e,t)=>{document.documentElement.style.setProperty(e,t)},r=e=>e,c=e=>e[0].toUpperCase()+e.slice(1),d=e=>e?"":void 0,h=(e,t)=>{if(t(e),e.children)for(const o of Array.from(e.children))"DIV"===o.tagName&&h(o,t)},u="undefined"!=typeof window&&!!window.document&&!!window.document.createElement,w=u&&!!window.addEventListener,m=e=>{"loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",e)},l=(...e)=>(...t)=>e.filter(e=>"function"==typeof e).forEach(e=>e(...t)),f=e=>e?e.ownerDocument.activeElement:null,v=(e,t)=>!(!e||!t)&&e.contains(t),p=e=>e.nodeType===Node.ELEMENT_NODE,M=(e,t,o)=>Math.max(t,Math.min(e,o)),g=45,E=85,P=180,b=70;function T(e){e||(e=u?navigator.userAgent:"");const t=D(e=e.toLowerCase()),o=t||e.includes("ipad"),n=!o&&-1!==e.search(/iphone|ipod/),i=n||o;let s=i&&e.match(/os ([\d_]+) like mac os x/i),a=0,r=0;t?(a=13,r=0):s&&(s=s[1].split("_"),a=+s[0],r=+s[1]),s=null;const c=a<13&&!(11===a&&r<3),d=i&&function(e){if(!u)return!1;const t=window.webkit;if(t&&t.messageHandlers)return!0;const o=/constructor/i.test(String(window.HTMLElement)),n=!!window.indexedDB;if(e.includes("safari")&&e.includes("version")&&!navigator.standalone);else if(!n&&o||!window.statusbar||!window.statusbar.visible);else if(!o||n)return!0;return!1}(e);let h=!1;u&&(h=i&&375===window.screen.width&&812===window.screen.height&&3===window.devicePixelRatio);return{isIPad:o,isIPhone:n,isIOS:i,isIPadOS:t,iosMajor:a,iosMinor:r,isWKWebView:d,isScrollBasedViewport:c,isIPhoneX:h,isIOSChrome:-1!==e.search(/crios/i)}}const I=T(),L=I.isIPad,y=I.isIPhone,O=I.isIOS,x=I.isIPadOS,S=I.iosMajor,H=I.iosMinor,R=I.isWKWebView,U=I.isScrollBasedViewport,W=I.isIPhoneX,j=I.isIOSChrome;function k(){return 90===Math.abs(window.orientation)&&!L}function D(e){if(!u)return!1;const t=!/ipPad|iPhone|iPod/i.test(e),o=/Mac OS/i.test(e);return t&&o&&"ontouchend"in document}const A=(()=>{const e={hasMouse:!1,hasTouchEvents:!1,hasHover:!1,hasTouch:!1};if(!u)return e;if(O&&!x)e.hasMouse=!1,e.hasHover=!1,e.hasTouchEvents=!0,e.hasTouch=!0;else if(e.hasTouchEvents="ontouchstart"in document,e.hasTouch=e.hasTouchEvents||"maxTouchPoints"in navigator&&navigator.maxTouchPoints>0,e.hasTouch){const t=!/android|mobile|tablet/i.test(navigator.userAgent);e.hasMouse="function"==typeof window.matchMedia&&window.matchMedia("(pointer)").matches?matchMedia("(pointer: fine)").matches:t,e.hasHover=e.hasMouse&&("function"==typeof window.matchMedia&&window.matchMedia("(hover)").matches?matchMedia("(hover: hover)").matches:t)}else e.hasMouse=!0,e.hasHover=!0;return e})(),C=A.hasMouse,V=A.hasHover,N=A.hasTouchEvents,B=A.hasTouch;function $(){return window.devicePixelRatio>=2}const _=async(e,t)=>{const o=document.createElement("a"),n=URL.createObjectURL(e);o.href=n,o.setAttribute("download",t),o.click(),URL.revokeObjectURL(n)},K=e=>{const t=new FormData;return t.append("file",e),t.append("type","file"),t},X=e=>{const t=URL.createObjectURL(e);return{url:t,destroy:()=>{URL.revokeObjectURL(t)}}},F=e=>Array.from(e);export{_ as Download,b as IOS_NO_KEYBOARD_ALLOWED_OFFSET,P as IPHONE_KEYBOARD_REJECT_OFFSET,g as IPHONE_SAFARI_BOTTOM_BAR,E as IPHONE_X_SAFARI_BOTTOM_BAR,d as attr,s as backgroundImage,i as box,l as callMultiple,u as canUseDOM,w as canUseEventListeners,c as capitalize,D as checkIPadOS,M as clamp,v as contains,T as detectIOS,X as generatePreview,f as getActiveElementByAnotherElement,h as getContainers,F as getFiles,V as hasHover,C as hasMouse,B as hasTouch,N as hasTouchEvents,n as height,S as iosMajor,H as iosMinor,p as isHTMLElement,O as isIOS,j as isIOSChrome,L as isIPad,x as isIPadOS,y as isIPhone,W as isIPhoneX,k as isLandscapePhone,$ as isRetina,U as isScrollBasedViewport,R as isWKWebView,m as onDOMLoaded,e as pc,t as px,a as setCssVariable,K as transport,r as varToStyle,o as width};
|
package/dist/download.d.ts
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
1
|
export declare const Download: (blob: Blob, filename: string) => Promise<void>;
|
|
2
|
+
export declare const transport: (file: Blob) => FormData;
|
|
3
|
+
export declare const generatePreview: (file: File) => {
|
|
4
|
+
url: string;
|
|
5
|
+
destroy: () => void;
|
|
6
|
+
};
|
|
7
|
+
export declare const getFiles: (files: FileList) => File[];
|