@georapbox/files-dropzone-element 1.1.0 → 1.1.1
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.
|
@@ -1,2 +1,69 @@
|
|
|
1
|
-
var e,t,i,o;function n(e,t,i){if(!t.has(e))throw new TypeError("attempted to "+i+" private field on non-instance");return t.get(e)}function s(e,t){return t.get?t.get.call(e):t.value}function a(e,t){return s(e,n(e,t,"get"))}function r(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function l(e,t,i){r(e,t),t.set(e,i)}function d(e,t,i){if(t.set)t.set.call(e,i);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=i}}function c(e,t,i){return d(e,n(e,t,"set"),i),i}function p(e,t,i){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return i}function h(e,t){r(e,t),t.add(e)}function u(e,t=""){if(!t)return!0;const i=[...new Set(t.split(",").map((e=>e.trim())).filter(Boolean))],o=e.type,n=o.replace(/\/.*$/,"");for(const t of i)if("."===t.charAt(0)){if(-1!==e.name.toLowerCase().indexOf(t.toLowerCase(),e.name.length-t.length))return!0}else if(/\/\*$/.test(t)){if(n===t.replace(/\/.*$/,""))return!0}else if(o===t)return!0;return!1}e={},t="FilesDropzone",i=function(){return N},Object.defineProperty(e,t,{get:i,set:o,enumerable:!0,configurable:!0});const m=new Map([["aac","audio/aac"],["abw","application/x-abiword"],["arc","application/x-freearc"],["avif","image/avif"],["avi","video/x-msvideo"],["azw","application/vnd.amazon.ebook"],["bin","application/octet-stream"],["bmp","image/bmp"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["cda","application/x-cdf"],["csh","application/x-csh"],["css","text/css"],["csv","text/csv"],["doc","application/msword"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["eot","application/vnd.ms-fontobject"],["epub","application/epub+zip"],["gz","application/gzip"],["gif","image/gif"],["heic","image/heic"],["heif","image/heif"],["htm","text/html"],["html","text/html"],["ico","image/vnd.microsoft.icon"],["ics","text/calendar"],["jar","application/java-archive"],["jpeg","image/jpeg"],["jpg","image/jpeg"],["js","text/javascript"],["json","application/json"],["jsonld","application/ld+json"],["mid","audio/midi"],["midi","audio/midi"],["mjs","text/javascript"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mpeg","video/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["opus","audio/opus"],["otf","font/otf"],["png","image/png"],["pdf","application/pdf"],["php","application/x-httpd-php"],["ppt","application/vnd.ms-powerpoint"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["rar","application/vnd.rar"],["rtf","application/rtf"],["sh","application/x-sh"],["svg","image/svg+xml"],["swf","application/x-shockwave-flash"],["tar","application/x-tar"],["tif","image/tiff"],["tiff","image/tiff"],["ts","video/mp2t"],["ttf","font/ttf"],["txt","text/plain"],["vsd","application/vnd.visio"],["wav","audio/wav"],["weba","audio/webm"],["webm","video/webm"],["webp","image/webp"],["woff","font/woff"],["woff2","font/woff2"],["xhtml","application/xhtml+xml"],["xls","application/vnd.ms-excel"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xml","application/xml"],["xul","application/vnd.mozilla.xul+xml"],["zip","application/zip"],["7z","application/x-7z-compressed"],["mkv","video/x-matroska"],["mov","video/quicktime"],["msg","application/vnd.ms-outlook"]]),b=[".DS_Store","Thumbs.db"],f=(e,t)=>{const i=(e=>{const{name:t}=e;if(t&&-1!==t.lastIndexOf(".")&&!e.type){const i=t.split(".").pop().toLowerCase(),o=m.get(i);o&&Object.defineProperty(e,"type",{value:o,writable:!1,configurable:!1,enumerable:!0})}return e})(e);if("string"!=typeof i.path){const{webkitRelativePath:o}=e;Object.defineProperty(i,"path",{value:"string"==typeof t?t:o||e.name,writable:!1,configurable:!1,enumerable:!0})}return i},v=async e=>await new Promise(((t,i)=>{e.readEntries(t,i)})),g=async e=>{const t=[];let i=await v(e);for(;i.length>0;)t.push(...i),i=await v(e);return t},w=e=>new Promise(((t,i)=>{e.file((i=>t(f(i,e.fullPath))),i)})),y=async e=>{const t=[];for(const i of e)-1===b.indexOf(i.name)&&t.push(f(i));return t},x=async e=>e.dataTransfer?e.dataTransfer.items?await(async e=>{const t=[],i=[];for(const t of e){if("file"!==t.kind)continue;const e=t.getAsEntry?t.getAsEntry():t.webkitGetAsEntry();i.push(e)}for(;i.length>0;){const e=i.shift();if(e)if(e.isFile){const i=await w(e);-1===b.indexOf(i.name)&&t.push(i)}else e.isDirectory&&i.push(...await g(e.createReader()))}return t})(e.dataTransfer.items):await y(e.dataTransfer.files):await y(e.target.files),z="files-dropzone",E="TOO_MANY_FILES",k=document.createElement("template");k.innerHTML='\n <style>\n *,\n *::before,\n *::after {\n box-sizing: border-box;\n }\n\n :host([hidden]),\n [hidden] {\n display: none !important;\n }\n\n :host {\n --dropzone-border-width: 2px;\n --dropzone-border-style: dashed;\n --dropzone-border-radius: 0.25rem;\n --dropzone-border-color: #6c757d;\n --dropzone-border-color-dragover: #0d6efd;\n --dropzone-background-color: #ffffff;\n --dropzone-background-color-dragover: #f4f4f5;\n --dropzone-body-color: #3f3f46;\n --dropzone-body-color-dragover: var(--dropzone-body-color);\n --dropzone-focus-shadow-rgb: 49,132,253;\n --transition-duration: 0.2s;\n\n display: block;\n }\n\n :host(:not([no-style])) .dropzone {\n border: var(--dropzone-border-width) var(--dropzone-border-style) var(--dropzone-border-color);\n border-radius: var(--dropzone-border-radius);\n padding: 3rem 1rem;\n overflow: hidden;\n background-color: var(--dropzone-background-color);\n color: var(--dropzone-body-color);\n text-align: center;\n cursor: pointer;\n transition: border var(--transition-duration) ease-in-out, background-color var(--transition-duration) ease-in-out, color var(--transition-duration) ease-in-out, box-shadow var(--transition-duration) ease-in-out;\n }\n\n :host(:not([no-style])[no-click]) .dropzone {\n cursor: default;\n }\n\n :host(:not([no-style])[disabled]) .dropzone {\n opacity: 0.8;\n cursor: not-allowed;\n }\n\n :host(:not([no-style]):not([disabled])) .dropzone--dragover {\n border-color: var(--dropzone-border-color-dragover);\n background-color: var(--dropzone-background-color-dragover);\n color: var(--dropzone-body-color-dragover);\n }\n\n :host(:not([no-style]):not([disabled])) .dropzone:focus-visible {\n outline: none;\n box-shadow: 0 0 0 0.25rem rgba(var(--dropzone-focus-shadow-rgb), 0.5);\n }\n </style>\n\n <input type="file" id="fileInput" hidden>\n\n <div part="dropzone" class="dropzone" id="dropzoneEl" tabindex="0" role="presentation">\n <slot>Drag \'n\' drop files here, or click to select files</slot>\n </div>\n';var A=new WeakMap,L=new WeakMap,F=new WeakMap,j=new WeakMap,S=new WeakMap,C=new WeakMap,T=new WeakMap,M=new WeakMap,$=new WeakMap,O=new WeakSet,D=new WeakSet;class N extends HTMLElement{static get observedAttributes(){return["accept","disabled","multiple","no-keyboard"]}attributeChangedCallback(e,t,i){"accept"===e&&t!==i&&a(this,A)&&(a(this,A).accept=this.accept),"disabled"===e&&t!==i&&a(this,A)&&(a(this,A).disabled=this.disabled,this.disabled?a(this,L).removeAttribute("tabindex"):a(this,L).setAttribute("tabindex","0")),"multiple"===e&&t!==i&&a(this,A)&&(a(this,A).multiple=this.multiple),"no-keyboard"===e&&t!==i&&a(this,L)&&(this.noKeyboard?a(this,L).removeAttribute("tabindex"):a(this,L).setAttribute("tabindex","0"))}connectedCallback(){p(this,D,W).call(this,"accept"),p(this,D,W).call(this,"disabled"),p(this,D,W).call(this,"maxFiles"),p(this,D,W).call(this,"maxSize"),p(this,D,W).call(this,"minSize"),p(this,D,W).call(this,"multiple"),p(this,D,W).call(this,"noClick"),p(this,D,W).call(this,"noDrag"),p(this,D,W).call(this,"noKeyboard"),p(this,D,W).call(this,"autoFocus"),p(this,D,W).call(this,"noStyle"),a(this,A).addEventListener("change",a(this,F)),a(this,L).addEventListener("dragenter",a(this,j)),a(this,L).addEventListener("dragover",a(this,S)),a(this,L).addEventListener("dragleave",a(this,C)),a(this,L).addEventListener("drop",a(this,T)),a(this,L).addEventListener("click",a(this,M)),a(this,L).addEventListener("keyup",a(this,$)),this.autoFocus&&a(this,L).focus()}disconnectedCallback(){a(this,A).removeEventListener("change",a(this,F)),a(this,L).removeEventListener("dragenter",a(this,j)),a(this,L).removeEventListener("dragover",a(this,S)),a(this,L).removeEventListener("dragleave",a(this,C)),a(this,L).removeEventListener("drop",a(this,T)),a(this,L).removeEventListener("click",a(this,M)),a(this,L).removeEventListener("keyup",a(this,$))}get accept(){return this.getAttribute("accept")}set accept(e){this.setAttribute("accept",e)}get disabled(){return this.hasAttribute("disabled")}set disabled(e){e?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get maxFiles(){const e=Number(this.getAttribute("max-files"))||0;return e<=0?1/0:Math.floor(Math.abs(e))}set maxFiles(e){this.setAttribute("max-files",e)}get maxSize(){const e=this.getAttribute("max-size");if(null===e)return 1/0;const t=Number(e);return Number.isNaN(t)?1/0:t}set maxSize(e){this.setAttribute("max-size",e)}get minSize(){const e=this.getAttribute("min-size");if(null===e)return 0;const t=Number(e);return Number.isNaN(t)?0:t}set minSize(e){this.setAttribute("min-size",e)}get multiple(){return this.hasAttribute("multiple")}set multiple(e){e?this.setAttribute("multiple",""):this.removeAttribute("multiple")}get noClick(){return this.hasAttribute("no-click")}set noClick(e){e?this.setAttribute("no-click",""):this.removeAttribute("no-click")}get noDrag(){return this.hasAttribute("no-drag")}set noDrag(e){e?this.setAttribute("no-drag",""):this.removeAttribute("no-drag")}get noKeyboard(){return this.hasAttribute("no-keyboard")}set noKeyboard(e){e?this.setAttribute("no-keyboard",""):this.removeAttribute("no-keyboard")}get autoFocus(){return this.hasAttribute("auto-focus")}set autoFocus(e){e?this.setAttribute("auto-focus",""):this.removeAttribute("auto-focus")}get noStyle(){return this.hasAttribute("no-style")}set noStyle(e){e?this.setAttribute("no-style",""):this.removeAttribute("no-style")}openFileDialog(){this.disabled||a(this,A).click()}static defineCustomElement(e=z){"undefined"==typeof window||window.customElements.get(e)||window.customElements.define(e,N)}constructor(){super(),h(this,O),h(this,D),l(this,A,{writable:!0,value:void 0}),l(this,L,{writable:!0,value:void 0}),l(this,F,{writable:!0,value:async e=>{try{p(this,O,I).call(this,await x(e))}catch(e){this.dispatchEvent(new CustomEvent(`${z}-error`,{bubbles:!0,composed:!0,detail:{error:e}}))}}}),l(this,j,{writable:!0,value:()=>{this.disabled||this.noDrag||this.dispatchEvent(new Event(`${z}-dragenter`,{bubbles:!0,composed:!0}))}}),l(this,S,{writable:!0,value:e=>{e.preventDefault(),this.disabled||this.noDrag?e.dataTransfer.dropEffect="none":(e.dataTransfer.dropEffect="copy",a(this,L).classList.add("dropzone--dragover"),a(this,L).part.add("dropzone--dragover"),this.dispatchEvent(new Event(`${z}-dragover`,{bubbles:!0,composed:!0})))}}),l(this,C,{writable:!0,value:()=>{this.disabled||this.noDrag||(a(this,L).classList.remove("dropzone--dragover"),a(this,L).part.remove("dropzone--dragover"),this.dispatchEvent(new Event(`${z}-dragleave`,{bubbles:!0,composed:!0})))}}),l(this,T,{writable:!0,value:async e=>{if(!this.disabled&&!this.noDrag){e.preventDefault(),a(this,L).classList.remove("dropzone--dragover"),a(this,L).part.remove("dropzone--dragover");try{p(this,O,I).call(this,await x(e))}catch(e){this.dispatchEvent(new CustomEvent(`${z}-error`,{bubbles:!0,composed:!0,detail:{error:e}}))}}}}),l(this,M,{writable:!0,value:()=>{this.disabled||this.noClick||a(this,A).click()}}),l(this,$,{writable:!0,value:e=>{this.disabled||this.noKeyboard||" "!==e.key&&"Enter"!==e.key||a(this,A).click()}}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(k.content.cloneNode(!0))),c(this,A,this.shadowRoot.getElementById("fileInput")),c(this,L,this.shadowRoot.getElementById("dropzoneEl"))}}function I(e){if(!Array.isArray(e)||!e.length)return;const t=[],i=[],o=e.length;if(!this.multiple&&o>1)for(const t of e)i.push({file:t,errors:[{code:E,message:"Too many files selected. Only 1 file is allowed."}]});else if(this.multiple&&o>this.maxFiles)for(const t of e)i.push({file:t,errors:[{code:E,message:`Too many files selected. Only ${this.maxFiles} ${this.maxFiles>1?"files are":"file is"} allowed.`}]});else for(const o of e){const e=u(o,this.accept),n=o.size>this.maxSize,s=o.size<this.minSize;if(!e||n||s){const t=[];e||t.push({code:"INVALID_MIME_TYPE",message:`File type "${o.type}" is not accepted.`}),n&&t.push({code:"FILE_TOO_LARGE",message:`File size ${o.size} exceeds the maximum size of ${this.maxSize}.`}),s&&t.push({code:"FILE_TOO_SMALL",message:`File size ${o.size} is smaller than the minimum size of ${this.minSize}.`}),i.push({file:o,errors:t})}else t.push(o)}this.dispatchEvent(new CustomEvent(`${z}-drop`,{bubbles:!0,composed:!0,detail:{acceptedFiles:t,rejectedFiles:i}})),t.length>0&&this.dispatchEvent(new CustomEvent(`${z}-drop-accepted`,{bubbles:!0,composed:!0,detail:{acceptedFiles:t}})),i.length>0&&this.dispatchEvent(new CustomEvent(`${z}-drop-rejected`,{bubbles:!0,composed:!0,detail:{rejectedFiles:i}})),a(this,A).value=a(this,A).defaultValue}function W(e){if(Object.prototype.hasOwnProperty.call(this,e)){const t=this[e];delete this[e],this[e]=t}}N.defineCustomElement();export{N as FilesDropzone};
|
|
1
|
+
Object.defineProperty({},"FilesDropzone",{get:function(){return u},set:void 0,enumerable:!0,configurable:!0});let e=new Map([["aac","audio/aac"],["abw","application/x-abiword"],["arc","application/x-freearc"],["avif","image/avif"],["avi","video/x-msvideo"],["azw","application/vnd.amazon.ebook"],["bin","application/octet-stream"],["bmp","image/bmp"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["cda","application/x-cdf"],["csh","application/x-csh"],["css","text/css"],["csv","text/csv"],["doc","application/msword"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["eot","application/vnd.ms-fontobject"],["epub","application/epub+zip"],["gz","application/gzip"],["gif","image/gif"],["heic","image/heic"],["heif","image/heif"],["htm","text/html"],["html","text/html"],["ico","image/vnd.microsoft.icon"],["ics","text/calendar"],["jar","application/java-archive"],["jpeg","image/jpeg"],["jpg","image/jpeg"],["jxl","image/jxl"],["js","text/javascript"],["json","application/json"],["jsonld","application/ld+json"],["mid","audio/midi"],["midi","audio/midi"],["mjs","text/javascript"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mpeg","video/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["opus","audio/opus"],["otf","font/otf"],["png","image/png"],["pdf","application/pdf"],["php","application/x-httpd-php"],["ppt","application/vnd.ms-powerpoint"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["rar","application/vnd.rar"],["rtf","application/rtf"],["sh","application/x-sh"],["svg","image/svg+xml"],["swf","application/x-shockwave-flash"],["tar","application/x-tar"],["tif","image/tiff"],["tiff","image/tiff"],["ts","video/mp2t"],["ttf","font/ttf"],["txt","text/plain"],["vsd","application/vnd.visio"],["wav","audio/wav"],["weba","audio/webm"],["webm","video/webm"],["webp","image/webp"],["woff","font/woff"],["woff2","font/woff2"],["xhtml","application/xhtml+xml"],["xls","application/vnd.ms-excel"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xml","application/xml"],["xul","application/vnd.mozilla.xul+xml"],["zip","application/zip"],["7z","application/x-7z-compressed"],["mkv","video/x-matroska"],["mov","video/quicktime"],["msg","application/vnd.ms-outlook"]]),t=[".DS_Store","Thumbs.db"],o=t=>{let{name:o}=t,i=o&&-1!==o.lastIndexOf(".");if(i&&!t.type){let i=o.split(".").pop().toLowerCase(),r=e.get(i);r&&Object.defineProperty(t,"type",{value:r,writable:!1,configurable:!1,enumerable:!0})}return t},i=(e,t)=>{let i=o(e);if("string"!=typeof i.path){let{webkitRelativePath:o}=e;Object.defineProperty(i,"path",{value:"string"==typeof t?t:o||e.name,writable:!1,configurable:!1,enumerable:!0})}return i},r=async e=>await new Promise((t,o)=>{e.readEntries(t,o)}),a=async e=>{let t=[],o=await r(e);for(;o.length>0;)t.push(...o),o=await r(e);return t},s=e=>new Promise((t,o)=>{e.file(o=>t(i(o,e.fullPath)),o)}),n=async e=>{let o=[],i=[];for(let t of e){if("file"!==t.kind)continue;let e=t.getAsEntry?t.getAsEntry():t.webkitGetAsEntry();i.push(e)}for(;i.length>0;){let e=i.shift();if(e){if(e.isFile){let i=await s(e);-1===t.indexOf(i.name)&&o.push(i)}else e.isDirectory&&i.push(...await a(e.createReader()))}}return o},d=async e=>{let o=[];for(let r of e)-1===t.indexOf(r.name)&&o.push(i(r));return o},l=async e=>e.dataTransfer?e.dataTransfer.items?await n(e.dataTransfer.items):await d(e.dataTransfer.files):await d(e.target.files),p="files-dropzone",c="TOO_MANY_FILES",h=document.createElement("template");h.innerHTML=`
|
|
2
|
+
<style>
|
|
3
|
+
*,
|
|
4
|
+
*::before,
|
|
5
|
+
*::after {
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
:host([hidden]),
|
|
10
|
+
[hidden] {
|
|
11
|
+
display: none !important;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
:host {
|
|
15
|
+
--dropzone-border-width: 2px;
|
|
16
|
+
--dropzone-border-style: dashed;
|
|
17
|
+
--dropzone-border-radius: 0.25rem;
|
|
18
|
+
--dropzone-border-color: #6c757d;
|
|
19
|
+
--dropzone-border-color-dragover: #0d6efd;
|
|
20
|
+
--dropzone-background-color: #ffffff;
|
|
21
|
+
--dropzone-background-color-dragover: #f4f4f5;
|
|
22
|
+
--dropzone-body-color: #3f3f46;
|
|
23
|
+
--dropzone-body-color-dragover: var(--dropzone-body-color);
|
|
24
|
+
--dropzone-focus-shadow-rgb: 49,132,253;
|
|
25
|
+
--transition-duration: 0.2s;
|
|
26
|
+
|
|
27
|
+
display: block;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
:host(:not([no-style])) .dropzone {
|
|
31
|
+
border: var(--dropzone-border-width) var(--dropzone-border-style) var(--dropzone-border-color);
|
|
32
|
+
border-radius: var(--dropzone-border-radius);
|
|
33
|
+
padding: 3rem 1rem;
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
background-color: var(--dropzone-background-color);
|
|
36
|
+
color: var(--dropzone-body-color);
|
|
37
|
+
text-align: center;
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
transition: border var(--transition-duration) ease-in-out, background-color var(--transition-duration) ease-in-out, color var(--transition-duration) ease-in-out, box-shadow var(--transition-duration) ease-in-out;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
:host(:not([no-style])[no-click]) .dropzone {
|
|
43
|
+
cursor: default;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
:host(:not([no-style])[disabled]) .dropzone {
|
|
47
|
+
opacity: 0.8;
|
|
48
|
+
cursor: not-allowed;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
:host(:not([no-style]):not([disabled])) .dropzone--dragover {
|
|
52
|
+
border-color: var(--dropzone-border-color-dragover);
|
|
53
|
+
background-color: var(--dropzone-background-color-dragover);
|
|
54
|
+
color: var(--dropzone-body-color-dragover);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
:host(:not([no-style]):not([disabled])) .dropzone:focus-visible {
|
|
58
|
+
outline: none;
|
|
59
|
+
box-shadow: 0 0 0 0.25rem rgba(var(--dropzone-focus-shadow-rgb), 0.5);
|
|
60
|
+
}
|
|
61
|
+
</style>
|
|
62
|
+
|
|
63
|
+
<input type="file" id="fileInput" hidden>
|
|
64
|
+
|
|
65
|
+
<div part="dropzone" class="dropzone" id="dropzoneEl" tabindex="0" role="presentation">
|
|
66
|
+
<slot>Drag 'n' drop files here, or click to select files</slot>
|
|
67
|
+
</div>
|
|
68
|
+
`;class u extends HTMLElement{#e;#t;constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(h.content.cloneNode(!0))),this.#e=this.shadowRoot.getElementById("fileInput"),this.#t=this.shadowRoot.getElementById("dropzoneEl")}static get observedAttributes(){return["accept","disabled","multiple","no-keyboard"]}attributeChangedCallback(e,t,o){"accept"===e&&t!==o&&this.#e&&(this.#e.accept=this.accept),"disabled"===e&&t!==o&&this.#e&&(this.#e.disabled=this.disabled,this.disabled?this.#t.removeAttribute("tabindex"):this.#t.setAttribute("tabindex","0")),"multiple"===e&&t!==o&&this.#e&&(this.#e.multiple=this.multiple),"no-keyboard"===e&&t!==o&&this.#t&&(this.noKeyboard?this.#t.removeAttribute("tabindex"):this.#t.setAttribute("tabindex","0"))}connectedCallback(){this.#o("accept"),this.#o("disabled"),this.#o("maxFiles"),this.#o("maxSize"),this.#o("minSize"),this.#o("multiple"),this.#o("noClick"),this.#o("noDrag"),this.#o("noKeyboard"),this.#o("autoFocus"),this.#o("noStyle"),this.#e.addEventListener("change",this.#i),this.#t.addEventListener("dragenter",this.#r),this.#t.addEventListener("dragover",this.#a),this.#t.addEventListener("dragleave",this.#s),this.#t.addEventListener("drop",this.#n),this.#t.addEventListener("click",this.#d),this.#t.addEventListener("keyup",this.#l),this.autoFocus&&this.#t.focus()}disconnectedCallback(){this.#e.removeEventListener("change",this.#i),this.#t.removeEventListener("dragenter",this.#r),this.#t.removeEventListener("dragover",this.#a),this.#t.removeEventListener("dragleave",this.#s),this.#t.removeEventListener("drop",this.#n),this.#t.removeEventListener("click",this.#d),this.#t.removeEventListener("keyup",this.#l)}get accept(){return this.getAttribute("accept")}set accept(e){this.setAttribute("accept",e)}get disabled(){return this.hasAttribute("disabled")}set disabled(e){e?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get maxFiles(){let e=Number(this.getAttribute("max-files"))||0;return e<=0?1/0:Math.floor(Math.abs(e))}set maxFiles(e){this.setAttribute("max-files",e)}get maxSize(){let e=this.getAttribute("max-size");if(null===e)return 1/0;let t=Number(e);return Number.isNaN(t)?1/0:t}set maxSize(e){this.setAttribute("max-size",e)}get minSize(){let e=this.getAttribute("min-size");if(null===e)return 0;let t=Number(e);return Number.isNaN(t)?0:t}set minSize(e){this.setAttribute("min-size",e)}get multiple(){return this.hasAttribute("multiple")}set multiple(e){e?this.setAttribute("multiple",""):this.removeAttribute("multiple")}get noClick(){return this.hasAttribute("no-click")}set noClick(e){e?this.setAttribute("no-click",""):this.removeAttribute("no-click")}get noDrag(){return this.hasAttribute("no-drag")}set noDrag(e){e?this.setAttribute("no-drag",""):this.removeAttribute("no-drag")}get noKeyboard(){return this.hasAttribute("no-keyboard")}set noKeyboard(e){e?this.setAttribute("no-keyboard",""):this.removeAttribute("no-keyboard")}get autoFocus(){return this.hasAttribute("auto-focus")}set autoFocus(e){e?this.setAttribute("auto-focus",""):this.removeAttribute("auto-focus")}get noStyle(){return this.hasAttribute("no-style")}set noStyle(e){e?this.setAttribute("no-style",""):this.removeAttribute("no-style")}#i=async e=>{try{this.#p(await l(e))}catch(e){this.dispatchEvent(new CustomEvent(`${p}-error`,{bubbles:!0,composed:!0,detail:{error:e}}))}};#r=()=>{this.disabled||this.noDrag||this.dispatchEvent(new Event(`${p}-dragenter`,{bubbles:!0,composed:!0}))};#a=e=>{if(e.preventDefault(),this.disabled||this.noDrag){e.dataTransfer.dropEffect="none";return}e.dataTransfer.dropEffect="copy",this.#t.classList.add("dropzone--dragover"),this.#t.part.add("dropzone--dragover"),this.dispatchEvent(new Event(`${p}-dragover`,{bubbles:!0,composed:!0}))};#s=()=>{this.disabled||this.noDrag||(this.#t.classList.remove("dropzone--dragover"),this.#t.part.remove("dropzone--dragover"),this.dispatchEvent(new Event(`${p}-dragleave`,{bubbles:!0,composed:!0})))};#n=async e=>{if(!this.disabled&&!this.noDrag){e.preventDefault(),this.#t.classList.remove("dropzone--dragover"),this.#t.part.remove("dropzone--dragover");try{this.#p(await l(e))}catch(e){this.dispatchEvent(new CustomEvent(`${p}-error`,{bubbles:!0,composed:!0,detail:{error:e}}))}}};#d=()=>{this.disabled||this.noClick||this.#e.click()};#l=e=>{this.disabled||this.noKeyboard||" "!==e.key&&"Enter"!==e.key||this.#e.click()};#p(e){if(!Array.isArray(e)||!e.length)return;let t=[],o=[],i=e.length;if(!this.multiple&&i>1)for(let t of e)o.push({file:t,errors:[{code:c,message:"Too many files selected. Only 1 file is allowed."}]});else if(this.multiple&&i>this.maxFiles)for(let t of e)o.push({file:t,errors:[{code:c,message:`Too many files selected. Only ${this.maxFiles} ${this.maxFiles>1?"files are":"file is"} allowed.`}]});else for(let i of e){let e=function(e,t=""){if(!t)return!0;let o=[...new Set(t.split(",").map(e=>e.trim()).filter(Boolean))],i=e.type,r=i.replace(/\/.*$/,"");for(let t of o)if("."===t.charAt(0)){if(-1!==e.name.toLowerCase().indexOf(t.toLowerCase(),e.name.length-t.length))return!0}else if(/\/\*$/.test(t)){if(r===t.replace(/\/.*$/,""))return!0}else if(i===t)return!0;return!1}(i,this.accept),r=i.size>this.maxSize,a=i.size<this.minSize;if(!e||r||a){let t=[];e||t.push({code:"INVALID_MIME_TYPE",message:`File type "${i.type}" is not accepted.`}),r&&t.push({code:"FILE_TOO_LARGE",message:`File size ${i.size} exceeds the maximum size of ${this.maxSize}.`}),a&&t.push({code:"FILE_TOO_SMALL",message:`File size ${i.size} is smaller than the minimum size of ${this.minSize}.`}),o.push({file:i,errors:t})}else t.push(i)}this.dispatchEvent(new CustomEvent(`${p}-drop`,{bubbles:!0,composed:!0,detail:{acceptedFiles:t,rejectedFiles:o}})),t.length>0&&this.dispatchEvent(new CustomEvent(`${p}-drop-accepted`,{bubbles:!0,composed:!0,detail:{acceptedFiles:t}})),o.length>0&&this.dispatchEvent(new CustomEvent(`${p}-drop-rejected`,{bubbles:!0,composed:!0,detail:{rejectedFiles:o}})),this.#e.value=this.#e.defaultValue}openFileDialog(){this.disabled||this.#e.click()}#o(e){if(Object.prototype.hasOwnProperty.call(this,e)){let t=this[e];delete this[e],this[e]=t}}static defineCustomElement(e=p){"undefined"==typeof window||window.customElements.get(e)||window.customElements.define(e,u)}}u.defineCustomElement();export{u as FilesDropzone};
|
|
2
69
|
//# sourceMappingURL=files-dropzone-defined.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"YAAe,SAAAA,EAAsCC,EAAUC,EAAYC,GACzE,IAAKD,EAAWE,IAAIH,GAClB,MAAM,IAAII,UAAU,gBAAkBF,EAAS,kCAEjD,OAAOD,EAAWI,IAAIL,EACxB,CCLe,SAAAM,EAAkCN,EAAUO,GACzD,OAAIA,EAAWF,IACNE,EAAWF,IAAIG,KAAKR,GAEtBO,EAAWE,KACpB,CCFe,SAAAC,EAA+BV,EAAUC,GAEtD,OAAOK,EAAwBN,EADdD,EAA4BC,EAAUC,EAAY,OAErE,CCNe,SAAAU,EAAoCC,EAAKC,GACtD,GAAIA,EAAkBV,IAAIS,GACxB,MAAM,IAAIR,UAAU,iEAExB,CCFe,SAAAU,EAAgCF,EAAKX,EAAYQ,GAC9DE,EAA2BC,EAAKX,GAChCA,EAAWc,IAAIH,EAAKH,EACtB,CCLe,SAAAO,EAAkChB,EAAUO,EAAYE,GACrE,GAAIF,EAAWQ,IACbR,EAAWQ,IAAIP,KAAKR,EAAUS,OACzB,CACL,IAAKF,EAAWU,SAId,MAAM,IAAIb,UAAU,4CAEtBG,EAAWE,MAAQA,CACrB,CACF,CCTe,SAAAS,EAA+BlB,EAAUC,EAAYQ,GAGlE,OADAO,EAAwBhB,EADPD,EAA4BC,EAAUC,EAAY,OACrBQ,GACvCA,CACT,CCPe,SAAAU,EAAgCnB,EAAUoB,EAAYC,GACnE,IAAKD,EAAWjB,IAAIH,GAClB,MAAM,IAAII,UAAU,kDAGtB,OAAOiB,CACT,CCJe,SAAAC,EAAiCV,EAAKQ,GACnDT,EAA2BC,EAAKQ,GAChCA,EAAWG,IAAIX,EACjB,CCEA,SAAgBY,EAAYC,EAAMC,EAAyB,IACzD,IAA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rE,KAAKuB,aAIpE+C,GACFN,EAAOjH,KAAK,CACVkH,KAjcS,iBAkcTC,QAAS,aAAahK,EAAKmK,4CAA4CrE,KAAKyB,aAIhFqC,EAAc/G,KAAK,C,KAAE7C,E,OAAM8J,GAC7B,MA1BEH,EAAc9G,KAAK7C,EA2BvB,CAGF8F,KAAKwC,cAAc,IAAIC,YAAY,GAAGlE,SAAuB,CAC3DmE,SAAS,EACTC,UAAU,EACVC,OAAQ,C,cACNiB,E,cACAC,MAIAD,EAAcxI,OAAS,GACzB2E,KAAKwC,cAAc,IAAIC,YAAY,GAAGlE,kBAAgC,CACpEmE,SAAS,EACTC,UAAU,EACVC,OAAQ,C,cACNiB,MAKFC,EAAczI,OAAS,GACzB2E,KAAKwC,cAAc,IAAIC,YAAY,GAAGlE,kBAAgC,CACpEmE,SAAS,EACTC,UAAU,EACVC,OAAQ,C,cACNkB,MAKN3K,EAAA6G,KAAMnB,GAAU3F,MAAQC,EAAA6G,KAAMnB,GAAU0F,YAC1C,CAgBA,SAAA/D,EAAiBgE,GACf,GAAIxI,OAAOyI,UAAUC,eAAezL,KAAK+G,KAAMwE,GAAO,CACpD,MAAMtL,EAAQ8G,KAAKwE,UACZxE,KAAKwE,GACZxE,KAAKwE,GAAQtL,CACf,CACF,CCngBFwG,EAAciF,6B","sources":["node_modules/@swc/helpers/src/_class_extract_field_descriptor.mjs","node_modules/@swc/helpers/src/_class_apply_descriptor_get.mjs","node_modules/@swc/helpers/src/_class_private_field_get.mjs","node_modules/@swc/helpers/src/_check_private_redeclaration.mjs","node_modules/@swc/helpers/src/_class_private_field_init.mjs","node_modules/@swc/helpers/src/_class_apply_descriptor_set.mjs","node_modules/@swc/helpers/src/_class_private_field_set.mjs","node_modules/@swc/helpers/src/_class_private_method_get.mjs","node_modules/@swc/helpers/src/_class_private_method_init.mjs","src/utils/is-valid-file.js","src/utils/files-selector.js","src/files-dropzone.js","src/files-dropzone-defined.js"],"sourcesContent":["export default function _classExtractFieldDescriptor(receiver, privateMap, action) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to \" + action + \" private field on non-instance\");\n }\n return privateMap.get(receiver);\n}\n","export default function _classApplyDescriptorGet(receiver, descriptor) {\n if (descriptor.get) {\n return descriptor.get.call(receiver);\n }\n return descriptor.value;\n}\n","import classExtractFieldDescriptor from './_class_extract_field_descriptor.mjs';\nimport classApplyDescriptorGet from './_class_apply_descriptor_get.mjs';\n\nexport default function _classPrivateFieldGet(receiver, privateMap) {\n var descriptor = classExtractFieldDescriptor(receiver, privateMap, \"get\");\n return classApplyDescriptorGet(receiver, descriptor);\n}\n","export default function _checkPrivateRedeclaration(obj, privateCollection) {\n if (privateCollection.has(obj)) {\n throw new TypeError(\"Cannot initialize the same private elements twice on an object\");\n }\n}\n","import _checkPrivateRedeclaration from \"./_check_private_redeclaration.mjs\";\n\nexport default function _classPrivateFieldInit(obj, privateMap, value) {\n _checkPrivateRedeclaration(obj, privateMap);\n privateMap.set(obj, value);\n}\n","export default function _classApplyDescriptorSet(receiver, descriptor, value) {\n if (descriptor.set) {\n descriptor.set.call(receiver, value);\n } else {\n if (!descriptor.writable) {\n // This should only throw in strict mode, but class bodies are\n // always strict and private fields can only be used inside\n // class bodies.\n throw new TypeError(\"attempted to set read only private field\");\n }\n descriptor.value = value;\n }\n}\n","import classExtractFieldDescriptor from './_class_extract_field_descriptor.mjs';\nimport classApplyDescriptorSet from './_class_apply_descriptor_set.mjs';\n\nexport default function _classPrivateFieldSet(receiver, privateMap, value) {\n var descriptor = classExtractFieldDescriptor(receiver, privateMap, \"set\");\n classApplyDescriptorSet(receiver, descriptor, value);\n return value;\n}\n","export default function _classPrivateMethodGet(receiver, privateSet, fn) {\n if (!privateSet.has(receiver)) {\n throw new TypeError(\"attempted to get private field on non-instance\");\n }\n\n return fn;\n}\n","import _checkPrivateRedeclaration from \"./_check_private_redeclaration.mjs\";\n\nexport default function _classPrivateMethodInit(obj, privateSet) {\n _checkPrivateRedeclaration(obj, privateSet);\n privateSet.add(obj);\n}\n","/**\n * Checks if a file is valid based on the accepted file type specifiers.\n *\n * @param {File} file The File object to validate.\n * @param {String} [acceptedTypeSpecifiers=''] The accepted file type specifiers.\n * @returns {Boolean} True if the file is valid, false otherwise.\n */\nexport function isValidFile(file, acceptedTypeSpecifiers = '') {\n if (!acceptedTypeSpecifiers) {\n return true;\n }\n\n const acceptedMimeTypesList = [\n ...new Set(acceptedTypeSpecifiers.split(',').map(v => v.trim()).filter(Boolean))\n ];\n\n const fileMimeType = file.type;\n const baseMimeType = fileMimeType.replace(/\\/.*$/, '');\n\n for (const validType of acceptedMimeTypesList) {\n if (validType.charAt(0) === '.') {\n if (file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.length - validType.length) !== -1) {\n return true;\n }\n } else if (/\\/\\*$/.test(validType)) {\n // Check for mime type that looks like \"image/*\" or similar.\n if (baseMimeType === validType.replace(/\\/.*$/, '')) {\n return true;\n }\n } else {\n if (fileMimeType === validType) {\n return true;\n }\n }\n }\n\n return false;\n}\n","const COMMON_MIME_TYPES = new Map([\n // https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types\n ['aac', 'audio/aac'],\n ['abw', 'application/x-abiword'],\n ['arc', 'application/x-freearc'],\n ['avif', 'image/avif'],\n ['avi', 'video/x-msvideo'],\n ['azw', 'application/vnd.amazon.ebook'],\n ['bin', 'application/octet-stream'],\n ['bmp', 'image/bmp'],\n ['bz', 'application/x-bzip'],\n ['bz2', 'application/x-bzip2'],\n ['cda', 'application/x-cdf'],\n ['csh', 'application/x-csh'],\n ['css', 'text/css'],\n ['csv', 'text/csv'],\n ['doc', 'application/msword'],\n ['docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],\n ['eot', 'application/vnd.ms-fontobject'],\n ['epub', 'application/epub+zip'],\n ['gz', 'application/gzip'],\n ['gif', 'image/gif'],\n ['heic', 'image/heic'],\n ['heif', 'image/heif'],\n ['htm', 'text/html'],\n ['html', 'text/html'],\n ['ico', 'image/vnd.microsoft.icon'],\n ['ics', 'text/calendar'],\n ['jar', 'application/java-archive'],\n ['jpeg', 'image/jpeg'],\n ['jpg', 'image/jpeg'],\n ['js', 'text/javascript'],\n ['json', 'application/json'],\n ['jsonld', 'application/ld+json'],\n ['mid', 'audio/midi'],\n ['midi', 'audio/midi'],\n ['mjs', 'text/javascript'],\n ['mp3', 'audio/mpeg'],\n ['mp4', 'video/mp4'],\n ['mpeg', 'video/mpeg'],\n ['mpkg', 'application/vnd.apple.installer+xml'],\n ['odp', 'application/vnd.oasis.opendocument.presentation'],\n ['ods', 'application/vnd.oasis.opendocument.spreadsheet'],\n ['odt', 'application/vnd.oasis.opendocument.text'],\n ['oga', 'audio/ogg'],\n ['ogv', 'video/ogg'],\n ['ogx', 'application/ogg'],\n ['opus', 'audio/opus'],\n ['otf', 'font/otf'],\n ['png', 'image/png'],\n ['pdf', 'application/pdf'],\n ['php', 'application/x-httpd-php'],\n ['ppt', 'application/vnd.ms-powerpoint'],\n ['pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'],\n ['rar', 'application/vnd.rar'],\n ['rtf', 'application/rtf'],\n ['sh', 'application/x-sh'],\n ['svg', 'image/svg+xml'],\n ['swf', 'application/x-shockwave-flash'],\n ['tar', 'application/x-tar'],\n ['tif', 'image/tiff'],\n ['tiff', 'image/tiff'],\n ['ts', 'video/mp2t'],\n ['ttf', 'font/ttf'],\n ['txt', 'text/plain'],\n ['vsd', 'application/vnd.visio'],\n ['wav', 'audio/wav'],\n ['weba', 'audio/webm'],\n ['webm', 'video/webm'],\n ['webp', 'image/webp'],\n ['woff', 'font/woff'],\n ['woff2', 'font/woff2'],\n ['xhtml', 'application/xhtml+xml'],\n ['xls', 'application/vnd.ms-excel'],\n ['xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],\n ['xml', 'application/xml'],\n ['xul', 'application/vnd.mozilla.xul+xml'],\n ['zip', 'application/zip'],\n ['7z', 'application/x-7z-compressed'],\n\n // Others\n ['mkv', 'video/x-matroska'],\n ['mov', 'video/quicktime'],\n ['msg', 'application/vnd.ms-outlook']\n]);\n\nconst FILES_TO_IGNORE = [\n // Thumbnail cache files for macOS and Windows\n '.DS_Store', // macOs\n 'Thumbs.db' // Windows\n];\n\n/**\n * Adds a `type` property to the file object if it doesn't have one and the file has an extension.\n * This is needed because Firefox doesn't add a type property to files dragged from the desktop.\n * @bug https://bugzilla.mozilla.org/show_bug.cgi?id=1424689\n *\n * @param {File} file The file object to add the type property to.\n * @returns {File} The file object with the type property added.\n */\nconst toFileWithMimeType = file => {\n const { name } = file;\n const hasExtension = name && name.lastIndexOf('.') !== -1;\n\n if (hasExtension && !file.type) {\n const extension = name.split('.').pop().toLowerCase();\n const type = COMMON_MIME_TYPES.get(extension);\n\n if (type) {\n Object.defineProperty(file, 'type', {\n value: type,\n writable: false,\n configurable: false,\n enumerable: true\n });\n }\n }\n\n return file;\n};\n\n/**\n * Adds a `path` property to the file object if it doesn't have one.\n * If `path` is not provided, the `webkitRelativePath` property of the file will be used\n * or the file's name if `webkitRelativePath` is not available.\n *\n * @param {File} file The file object to add the path property to.\n * @param {String} [path] The path to set on the file object.\n * @returns {File} The file object with the path property added.\n */\nconst toFileWithPath = (file, path) => {\n const fileWithMimeType = toFileWithMimeType(file);\n\n if (typeof fileWithMimeType.path !== 'string') {\n const { webkitRelativePath } = file;\n\n Object.defineProperty(fileWithMimeType, 'path', {\n value: typeof path === 'string' ? path : webkitRelativePath || file.name,\n writable: false,\n configurable: false,\n enumerable: true\n });\n }\n\n return fileWithMimeType;\n};\n\n/**\n * Wrap `FileSystemDirectoryReader.readEntries` in a promise to make working with read entries easier.\n * https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryReader/readEntries\n *\n * @param {FileSystemDirectoryReader} directoryReader The directory reader to read entries from.\n * @returns {Promise<FileSystemFileEntry[]>} A promise that resolves with an array of `FileSystemFileEntry` objects.\n */\nconst readEntriesPromise = async directoryReader => {\n return await new Promise((resolve, reject) => {\n directoryReader.readEntries(resolve, reject);\n });\n};\n\n/**\n * Read all entries in a directory or sub-directory\n * by calling `readEntries` until it returns an empty array.\n *\n * @param {FileSystemDirectoryReader} directoryReader The directory reader to read entries from.\n * @returns {Promise<FileSystemFileEntry[]>} A promise that resolves with an array of `FileSystemFileEntry` objects.\n */\nconst readAllDirectoryEntries = async directoryReader => {\n const entries = [];\n let readEntries = await readEntriesPromise(directoryReader);\n\n while (readEntries.length > 0) {\n entries.push(...readEntries);\n readEntries = await readEntriesPromise(directoryReader);\n }\n\n return entries;\n};\n\n/**\n * Get a `File` object from a `FileSystemFileEntry` object.\n *\n * @param {FileSystemFileEntry} fileEntry The file entry to get a `File` object from.\n * @returns {Promise<File>} A promise that resolves with a `File` object.\n */\nconst getFileFromFileEntry = fileEntry => {\n return new Promise((resolve, reject) => {\n fileEntry.file(file => resolve(toFileWithPath(file, fileEntry.fullPath)), reject);\n });\n};\n\n/**\n * Get an array of `File` objects from a `DataTransferItemList` object.\n *\n * @param {DataTransferItemList} dataTransferItemList The item list to get an array of `File` objects from.\n * @returns {Promise<File[]>} A promise that resolves with an array of `File` objects.\n */\nconst getFilesFromDataTransferItemList = async dataTransferItemList => {\n const files = [];\n\n // Chromium browsers read only 100 files at a time as per the spec, so we need to use\n // BFS (Breadth-first search) to traverse the entire directory/file structure.\n // https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/webkitGetAsEntry#javascript_content\n const queue = [];\n\n for (const item of dataTransferItemList) {\n if (item.kind !== 'file') {\n // Ignore non-file items, such as links.\n continue;\n }\n\n // https://developer.mozilla.org/docs/Web/API/DataTransferItem/webkitGetAsEntry\n // This function is implemented as `webkitGetAsEntry()` in non-WebKit browsers\n // including Firefox at this time but it may be renamed to `getAsEntry()` in the future.\n const entry = item.getAsEntry ? item.getAsEntry() : item.webkitGetAsEntry();\n\n queue.push(entry);\n }\n\n while (queue.length > 0) {\n const entry = queue.shift();\n\n if (!entry) {\n continue;\n } else if (entry.isFile) {\n const file = await getFileFromFileEntry(entry);\n\n if (FILES_TO_IGNORE.indexOf(file.name) === -1) {\n files.push(file);\n }\n } else if (entry.isDirectory) {\n queue.push(...await readAllDirectoryEntries(entry.createReader()));\n }\n }\n\n return files;\n};\n\n/**\n * Get an array of `File` objects from a `FileList` object.\n *\n * @param {FileList} fileList The file list to get an array of `File` objects from.\n * @returns {Promise<File[]>} A promise that resolves with an array of `File` objects.\n */\nconst getFilesFromFileList = async fileList => {\n const files = [];\n\n for (const file of fileList) {\n if (FILES_TO_IGNORE.indexOf(file.name) === -1) {\n files.push(toFileWithPath(file));\n }\n }\n\n return files;\n};\n\n/**\n * Get an array of `File` objects from an event.\n * This function supports both `drop` and `change` events.\n *\n * @param {DragEvent | Event} evt The event to get an array of `File` objects from.\n * @returns {Promise<File[]>} A promise that resolves with an array of `File` objects.\n */\nexport const getFilesFromEvent = async evt => {\n if (evt.dataTransfer) {\n return evt.dataTransfer.items\n ? await getFilesFromDataTransferItemList(evt.dataTransfer.items)\n : await getFilesFromFileList(evt.dataTransfer.files);\n }\n\n return await getFilesFromFileList(evt.target.files);\n};\n","import { isValidFile } from './utils/is-valid-file.js';\nimport { getFilesFromEvent } from './utils/files-selector.js';\n\nconst COMPONENT_NAME = 'files-dropzone';\nconst TOO_MANY_FILES = 'TOO_MANY_FILES';\nconst FILE_TOO_LARGE = 'FILE_TOO_LARGE';\nconst FILE_TOO_SMALL = 'FILE_TOO_SMALL';\nconst INVALID_MIME_TYPE = 'INVALID_MIME_TYPE';\nconst template = document.createElement('template');\n\ntemplate.innerHTML = /* html */`\n <style>\n *,\n *::before,\n *::after {\n box-sizing: border-box;\n }\n\n :host([hidden]),\n [hidden] {\n display: none !important;\n }\n\n :host {\n --dropzone-border-width: 2px;\n --dropzone-border-style: dashed;\n --dropzone-border-radius: 0.25rem;\n --dropzone-border-color: #6c757d;\n --dropzone-border-color-dragover: #0d6efd;\n --dropzone-background-color: #ffffff;\n --dropzone-background-color-dragover: #f4f4f5;\n --dropzone-body-color: #3f3f46;\n --dropzone-body-color-dragover: var(--dropzone-body-color);\n --dropzone-focus-shadow-rgb: 49,132,253;\n --transition-duration: 0.2s;\n\n display: block;\n }\n\n :host(:not([no-style])) .dropzone {\n border: var(--dropzone-border-width) var(--dropzone-border-style) var(--dropzone-border-color);\n border-radius: var(--dropzone-border-radius);\n padding: 3rem 1rem;\n overflow: hidden;\n background-color: var(--dropzone-background-color);\n color: var(--dropzone-body-color);\n text-align: center;\n cursor: pointer;\n transition: border var(--transition-duration) ease-in-out, background-color var(--transition-duration) ease-in-out, color var(--transition-duration) ease-in-out, box-shadow var(--transition-duration) ease-in-out;\n }\n\n :host(:not([no-style])[no-click]) .dropzone {\n cursor: default;\n }\n\n :host(:not([no-style])[disabled]) .dropzone {\n opacity: 0.8;\n cursor: not-allowed;\n }\n\n :host(:not([no-style]):not([disabled])) .dropzone--dragover {\n border-color: var(--dropzone-border-color-dragover);\n background-color: var(--dropzone-background-color-dragover);\n color: var(--dropzone-body-color-dragover);\n }\n\n :host(:not([no-style]):not([disabled])) .dropzone:focus-visible {\n outline: none;\n box-shadow: 0 0 0 0.25rem rgba(var(--dropzone-focus-shadow-rgb), 0.5);\n }\n </style>\n\n <input type=\"file\" id=\"fileInput\" hidden>\n\n <div part=\"dropzone\" class=\"dropzone\" id=\"dropzoneEl\" tabindex=\"0\" role=\"presentation\">\n <slot>Drag 'n' drop files here, or click to select files</slot>\n </div>\n`;\n\nclass FilesDropzone extends HTMLElement {\n #fileInput;\n #dropzoneEl;\n\n constructor() {\n super();\n\n if (!this.shadowRoot) {\n this.attachShadow({ mode: 'open' });\n this.shadowRoot.appendChild(template.content.cloneNode(true));\n }\n\n this.#fileInput = this.shadowRoot.getElementById('fileInput');\n this.#dropzoneEl = this.shadowRoot.getElementById('dropzoneEl');\n }\n\n static get observedAttributes() {\n return ['accept', 'disabled', 'multiple', 'no-keyboard'];\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n if (name === 'accept' && oldValue !== newValue && this.#fileInput) {\n this.#fileInput.accept = this.accept;\n }\n\n if (name === 'disabled' && oldValue !== newValue && this.#fileInput) {\n this.#fileInput.disabled = this.disabled;\n\n if (this.disabled) {\n this.#dropzoneEl.removeAttribute('tabindex');\n } else {\n this.#dropzoneEl.setAttribute('tabindex', '0');\n }\n }\n\n if (name === 'multiple' && oldValue !== newValue && this.#fileInput) {\n this.#fileInput.multiple = this.multiple;\n }\n\n if (name === 'no-keyboard' && oldValue !== newValue && this.#dropzoneEl) {\n if (this.noKeyboard) {\n this.#dropzoneEl.removeAttribute('tabindex');\n } else {\n this.#dropzoneEl.setAttribute('tabindex', '0');\n }\n }\n }\n\n connectedCallback() {\n this.#upgradeProperty('accept');\n this.#upgradeProperty('disabled');\n this.#upgradeProperty('maxFiles');\n this.#upgradeProperty('maxSize');\n this.#upgradeProperty('minSize');\n this.#upgradeProperty('multiple');\n this.#upgradeProperty('noClick');\n this.#upgradeProperty('noDrag');\n this.#upgradeProperty('noKeyboard');\n this.#upgradeProperty('autoFocus');\n this.#upgradeProperty('noStyle');\n\n this.#fileInput.addEventListener('change', this.#onFileInputChange);\n this.#dropzoneEl.addEventListener('dragenter', this.#onDragEnter);\n this.#dropzoneEl.addEventListener('dragover', this.#onDragOver);\n this.#dropzoneEl.addEventListener('dragleave', this.#onDragLeave);\n this.#dropzoneEl.addEventListener('drop', this.#onDrop);\n this.#dropzoneEl.addEventListener('click', this.#onClick);\n this.#dropzoneEl.addEventListener('keyup', this.#onKeyUp);\n\n this.autoFocus && this.#dropzoneEl.focus();\n }\n\n disconnectedCallback() {\n this.#fileInput.removeEventListener('change', this.#onFileInputChange);\n this.#dropzoneEl.removeEventListener('dragenter', this.#onDragEnter);\n this.#dropzoneEl.removeEventListener('dragover', this.#onDragOver);\n this.#dropzoneEl.removeEventListener('dragleave', this.#onDragLeave);\n this.#dropzoneEl.removeEventListener('drop', this.#onDrop);\n this.#dropzoneEl.removeEventListener('click', this.#onClick);\n this.#dropzoneEl.removeEventListener('keyup', this.#onKeyUp);\n }\n\n get accept() {\n return this.getAttribute('accept');\n }\n\n set accept(value) {\n this.setAttribute('accept', value);\n }\n\n get disabled() {\n return this.hasAttribute('disabled');\n }\n\n set disabled(value) {\n if (value) {\n this.setAttribute('disabled', '');\n } else {\n this.removeAttribute('disabled');\n }\n }\n\n get maxFiles() {\n const num = Number(this.getAttribute('max-files')) || 0;\n\n if (num <= 0) {\n return Infinity;\n }\n\n return Math.floor(Math.abs(num));\n }\n\n set maxFiles(value) {\n this.setAttribute('max-files', value);\n }\n\n get maxSize() {\n const value = this.getAttribute('max-size');\n\n if (value === null) {\n return Infinity;\n }\n\n const num = Number(value);\n\n return Number.isNaN(num) ? Infinity : num;\n }\n\n set maxSize(value) {\n this.setAttribute('max-size', value);\n }\n\n get minSize() {\n const value = this.getAttribute('min-size');\n\n if (value === null) {\n return 0;\n }\n\n const num = Number(value);\n\n return Number.isNaN(num) ? 0 : num;\n }\n\n set minSize(value) {\n this.setAttribute('min-size', value);\n }\n\n get multiple() {\n return this.hasAttribute('multiple');\n }\n\n set multiple(value) {\n if (value) {\n this.setAttribute('multiple', '');\n } else {\n this.removeAttribute('multiple');\n }\n }\n\n get noClick() {\n return this.hasAttribute('no-click');\n }\n\n set noClick(value) {\n if (value) {\n this.setAttribute('no-click', '');\n } else {\n this.removeAttribute('no-click');\n }\n }\n\n get noDrag() {\n return this.hasAttribute('no-drag');\n }\n\n set noDrag(value) {\n if (value) {\n this.setAttribute('no-drag', '');\n } else {\n this.removeAttribute('no-drag');\n }\n }\n\n get noKeyboard() {\n return this.hasAttribute('no-keyboard');\n }\n\n set noKeyboard(value) {\n if (value) {\n this.setAttribute('no-keyboard', '');\n } else {\n this.removeAttribute('no-keyboard');\n }\n }\n\n get autoFocus() {\n return this.hasAttribute('auto-focus');\n }\n\n set autoFocus(value) {\n if (value) {\n this.setAttribute('auto-focus', '');\n } else {\n this.removeAttribute('auto-focus');\n }\n }\n\n get noStyle() {\n return this.hasAttribute('no-style');\n }\n\n set noStyle(value) {\n if (value) {\n this.setAttribute('no-style', '');\n } else {\n this.removeAttribute('no-style');\n }\n }\n\n #onFileInputChange = async evt => {\n try {\n this.#handleFilesSelect(await getFilesFromEvent(evt));\n } catch (error) {\n this.dispatchEvent(new CustomEvent(`${COMPONENT_NAME}-error`, {\n bubbles: true,\n composed: true,\n detail: { error }\n }));\n }\n };\n\n #onDragEnter = () => {\n if (this.disabled || this.noDrag) {\n return;\n }\n\n this.dispatchEvent(new Event(`${COMPONENT_NAME}-dragenter`, {\n bubbles: true,\n composed: true\n }));\n };\n\n #onDragOver = evt => {\n evt.preventDefault();\n\n if (this.disabled || this.noDrag) {\n evt.dataTransfer.dropEffect = 'none';\n return;\n }\n\n evt.dataTransfer.dropEffect = 'copy';\n\n this.#dropzoneEl.classList.add('dropzone--dragover');\n this.#dropzoneEl.part.add('dropzone--dragover');\n\n this.dispatchEvent(new Event(`${COMPONENT_NAME}-dragover`, {\n bubbles: true,\n composed: true\n }));\n };\n\n #onDragLeave = () => {\n if (this.disabled || this.noDrag) {\n return;\n }\n\n this.#dropzoneEl.classList.remove('dropzone--dragover');\n this.#dropzoneEl.part.remove('dropzone--dragover');\n\n this.dispatchEvent(new Event(`${COMPONENT_NAME}-dragleave`, {\n bubbles: true,\n composed: true\n }));\n };\n\n #onDrop = async evt => {\n if (this.disabled || this.noDrag) {\n return;\n }\n\n evt.preventDefault();\n\n this.#dropzoneEl.classList.remove('dropzone--dragover');\n this.#dropzoneEl.part.remove('dropzone--dragover');\n\n try {\n this.#handleFilesSelect(await getFilesFromEvent(evt));\n } catch (error) {\n this.dispatchEvent(new CustomEvent(`${COMPONENT_NAME}-error`, {\n bubbles: true,\n composed: true,\n detail: { error }\n }));\n }\n };\n\n #onClick = () => {\n if (this.disabled || this.noClick) {\n return;\n }\n\n this.#fileInput.click();\n };\n\n #onKeyUp = evt => {\n if (this.disabled || this.noKeyboard) {\n return;\n }\n\n if (evt.key === ' ' || evt.key === 'Enter') {\n this.#fileInput.click();\n }\n };\n\n #handleFilesSelect(files) {\n if (!Array.isArray(files) || !files.length) {\n return;\n }\n\n const acceptedFiles = [];\n const rejectedFiles = [];\n const filesLength = files.length;\n\n // If the component is not in multiple mode, reject all files.\n if (!this.multiple && filesLength > 1) {\n for (const file of files) {\n rejectedFiles.push({\n file,\n errors: [{\n code: TOO_MANY_FILES,\n message: `Too many files selected. Only 1 file is allowed.`\n }]\n });\n }\n } else if (this.multiple && filesLength > this.maxFiles) {\n // If the component is in multiple mode, but the number of files exceeds\n // the maxFiles attribute, reject all files.\n for (const file of files) {\n rejectedFiles.push({\n file,\n errors: [{\n code: TOO_MANY_FILES,\n message: `Too many files selected. Only ${this.maxFiles} ${this.maxFiles > 1 ? 'files are' : 'file is'} allowed.`\n }]\n });\n }\n } else {\n // Validate each file. If it's valid, add it to the accepted files array,\n // otherwise add it to the rejected files array.\n for (const file of files) {\n const fileHasValidType = isValidFile(file, this.accept);\n const fileExceedsMaxSize = file.size > this.maxSize;\n const fileIsSmallerThanMinSize = file.size < this.minSize;\n\n if (fileHasValidType && !fileExceedsMaxSize && !fileIsSmallerThanMinSize) {\n acceptedFiles.push(file);\n } else {\n const errors = [];\n\n if (!fileHasValidType) {\n errors.push({\n code: INVALID_MIME_TYPE,\n message: `File type \"${file.type}\" is not accepted.`\n });\n }\n\n if (fileExceedsMaxSize) {\n errors.push({\n code: FILE_TOO_LARGE,\n message: `File size ${file.size} exceeds the maximum size of ${this.maxSize}.`\n });\n }\n\n if (fileIsSmallerThanMinSize) {\n errors.push({\n code: FILE_TOO_SMALL,\n message: `File size ${file.size} is smaller than the minimum size of ${this.minSize}.`\n });\n }\n\n rejectedFiles.push({ file, errors });\n }\n }\n }\n\n this.dispatchEvent(new CustomEvent(`${COMPONENT_NAME}-drop`, {\n bubbles: true,\n composed: true,\n detail: {\n acceptedFiles,\n rejectedFiles\n }\n }));\n\n if (acceptedFiles.length > 0) {\n this.dispatchEvent(new CustomEvent(`${COMPONENT_NAME}-drop-accepted`, {\n bubbles: true,\n composed: true,\n detail: {\n acceptedFiles\n }\n }));\n }\n\n if (rejectedFiles.length > 0) {\n this.dispatchEvent(new CustomEvent(`${COMPONENT_NAME}-drop-rejected`, {\n bubbles: true,\n composed: true,\n detail: {\n rejectedFiles\n }\n }));\n }\n\n this.#fileInput.value = this.#fileInput.defaultValue;\n }\n\n openFileDialog() {\n if (this.disabled) {\n return;\n }\n\n this.#fileInput.click();\n }\n\n /**\n * https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties\n * This is to safe guard against cases where, for instance, a framework may have added the element to the page and set a\n * value on one of its properties, but lazy loaded its definition. Without this guard, the upgraded element would miss that\n * property and the instance property would prevent the class property setter from ever being called.\n */\n #upgradeProperty(prop) {\n if (Object.prototype.hasOwnProperty.call(this, prop)) {\n const value = this[prop];\n delete this[prop];\n this[prop] = value;\n }\n }\n\n static defineCustomElement(elementName = COMPONENT_NAME) {\n if (typeof window !== 'undefined' && !window.customElements.get(elementName)) {\n window.customElements.define(elementName, FilesDropzone);\n }\n }\n}\n\nexport { FilesDropzone };\n","import { FilesDropzone } from './files-dropzone.js';\n\nFilesDropzone.defineCustomElement();\n\nexport { FilesDropzone };\n"],"names":["$54e5dea46d3d830b$export$2e2bcd8739ae039","receiver","privateMap","action","has","TypeError","get","$4a9af28d8c332738$export$2e2bcd8739ae039","descriptor","call","value","$0ebd1ade8fb3d51f$export$2e2bcd8739ae039","$ce94785d052866a0$export$2e2bcd8739ae039","obj","privateCollection","$96b9e3133fa8e43f$export$2e2bcd8739ae039","set","$a5f62c39645bb2ba$export$2e2bcd8739ae039","writable","$6108fbe778b62371$export$2e2bcd8739ae039","$1b12450ac511053e$export$2e2bcd8739ae039","privateSet","fn","$39719070878026a5$export$2e2bcd8739ae039","add","$38f222170fd4d21a$export$7c47054fed488f80","file","acceptedTypeSpecifiers","acceptedMimeTypesList","Set","split","map","v","trim","filter","Boolean","fileMimeType","type","baseMimeType","replace","validType","charAt","name","toLowerCase","indexOf","length","test","$f31161edf38949e9$var$COMMON_MIME_TYPES","Map","$f31161edf38949e9$var$FILES_TO_IGNORE","$f31161edf38949e9$var$toFileWithPath","path","fileWithMimeType","lastIndexOf","extension","pop","Object","defineProperty","configurable","enumerable","$f31161edf38949e9$var$toFileWithMimeType","webkitRelativePath","$f31161edf38949e9$var$readEntriesPromise","async","directoryReader","Promise","resolve","reject","readEntries","$f31161edf38949e9$var$readAllDirectoryEntries","entries","push","$f31161edf38949e9$var$getFileFromFileEntry","fileEntry","fullPath","$f31161edf38949e9$var$getFilesFromFileList","fileList","files","$f31161edf38949e9$export$6d52664cd15c442","evt","dataTransfer","items","dataTransferItemList","queue","item","kind","entry","getAsEntry","webkitGetAsEntry","shift","isFile","isDirectory","createReader","$f31161edf38949e9$var$getFilesFromDataTransferItemList","target","$862aa3736b0514bc$var$COMPONENT_NAME","$862aa3736b0514bc$var$TOO_MANY_FILES","$862aa3736b0514bc$var$template","document","createElement","innerHTML","$862aa3736b0514bc$var$_fileInput","WeakMap","$862aa3736b0514bc$var$_dropzoneEl","$862aa3736b0514bc$var$_onFileInputChange","$862aa3736b0514bc$var$_onDragEnter","$862aa3736b0514bc$var$_onDragOver","$862aa3736b0514bc$var$_onDragLeave","$862aa3736b0514bc$var$_onDrop","$862aa3736b0514bc$var$_onClick","$862aa3736b0514bc$var$_onKeyUp","$862aa3736b0514bc$var$_handleFilesSelect","WeakSet","$862aa3736b0514bc$var$_upgradeProperty","$862aa3736b0514bc$export$6ccd1735166caad9","HTMLElement","observedAttributes","attributeChangedCallback","oldValue","newValue","this","accept","disabled","removeAttribute","setAttribute","multiple","noKeyboard","connectedCallback","$862aa3736b0514bc$var$upgradeProperty","addEventListener","autoFocus","focus","disconnectedCallback","removeEventListener","getAttribute","hasAttribute","maxFiles","num","Number","Infinity","Math","floor","abs","maxSize","isNaN","minSize","noClick","noDrag","noStyle","openFileDialog","click","static","elementName","window","customElements","define","constructor","super","$862aa3736b0514bc$var$handleFilesSelect","error","dispatchEvent","CustomEvent","bubbles","composed","detail","Event","preventDefault","dropEffect","classList","part","remove","key","shadowRoot","attachShadow","mode","appendChild","content","cloneNode","getElementById","Array","isArray","acceptedFiles","rejectedFiles","filesLength","errors","code","message","fileHasValidType","fileExceedsMaxSize","size","fileIsSmallerThanMinSize","defaultValue","prop","prototype","hasOwnProperty","defineCustomElement"],"version":3,"file":"files-dropzone-defined.js.map"}
|
|
1
|
+
{"mappings":"A,O,e,C,E,gB,C,I,W,O,C,E,I,K,E,W,C,E,a,C,C,GIAA,IAAM,EAAoB,IAAI,IAAI,CAEhC,CAAC,MAAO,YAAY,CACpB,CAAC,MAAO,wBAAwB,CAChC,CAAC,MAAO,wBAAwB,CAChC,CAAC,OAAQ,aAAa,CACtB,CAAC,MAAO,kBAAkB,CAC1B,CAAC,MAAO,+BAA+B,CACvC,CAAC,MAAO,2BAA2B,CACnC,CAAC,MAAO,YAAY,CACpB,CAAC,KAAM,qBAAqB,CAC5B,CAAC,MAAO,sBAAsB,CAC9B,CAAC,MAAO,oBAAoB,CAC5B,CAAC,MAAO,oBAAoB,CAC5B,CAAC,MAAO,WAAW,CACnB,CAAC,MAAO,WAAW,CACnB,CAAC,MAAO,qBAAqB,CAC7B,CAAC,OAAQ,0EAA0E,CACnF,CAAC,MAAO,gCAAgC,CACxC,CAAC,OAAQ,uBAAuB,CAChC,CAAC,KAAM,mBAAmB,CAC1B,CAAC,MAAO,YAAY,CACpB,CAAC,OAAQ,aAAa,CACtB,CAAC,OAAQ,aAAa,CACtB,CAAC,MAAO,YAAY,CACpB,CAAC,OAAQ,YAAY,CACrB,CAAC,MAAO,2BAA2B,CACnC,CAAC,MAAO,gBAAgB,CACxB,CAAC,MAAO,2BAA2B,CACnC,CAAC,OAAQ,aAAa,CACtB,CAAC,MAAO,aAAa,CACrB,CAAC,MAAO,YAAY,CACpB,CAAC,KAAM,kBAAkB,CACzB,CAAC,OAAQ,mBAAmB,CAC5B,CAAC,SAAU,sBAAsB,CACjC,CAAC,MAAO,aAA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AA,EAAc,6B,K,a","sources":["<anon>","src/files-dropzone-defined.js","src/files-dropzone.js","src/utils/is-valid-file.js","src/utils/files-selector.js"],"sourcesContent":["function $parcel$export(e, n, v, s) {\n Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});\n}\nvar $862aa3736b0514bc$exports = {};\n\n$parcel$export($862aa3736b0514bc$exports, \"FilesDropzone\", function () { return $862aa3736b0514bc$export$6ccd1735166caad9; });\n/**\n * Checks if a file is valid based on the accepted file type specifiers.\n *\n * @param {File} file The File object to validate.\n * @param {String} [acceptedTypeSpecifiers=''] The accepted file type specifiers.\n * @returns {Boolean} True if the file is valid, false otherwise.\n */ function $38f222170fd4d21a$export$7c47054fed488f80(file, acceptedTypeSpecifiers = \"\") {\n if (!acceptedTypeSpecifiers) return true;\n const acceptedMimeTypesList = [\n ...new Set(acceptedTypeSpecifiers.split(\",\").map((v)=>v.trim()).filter(Boolean))\n ];\n const fileMimeType = file.type;\n const baseMimeType = fileMimeType.replace(/\\/.*$/, \"\");\n for (const validType of acceptedMimeTypesList){\n if (validType.charAt(0) === \".\") {\n if (file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.length - validType.length) !== -1) return true;\n } else if (/\\/\\*$/.test(validType)) {\n // Check for mime type that looks like \"image/*\" or similar.\n if (baseMimeType === validType.replace(/\\/.*$/, \"\")) return true;\n } else {\n if (fileMimeType === validType) return true;\n }\n }\n return false;\n}\n\n\nconst $f31161edf38949e9$var$COMMON_MIME_TYPES = new Map([\n // https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types\n [\n \"aac\",\n \"audio/aac\"\n ],\n [\n \"abw\",\n \"application/x-abiword\"\n ],\n [\n \"arc\",\n \"application/x-freearc\"\n ],\n [\n \"avif\",\n \"image/avif\"\n ],\n [\n \"avi\",\n \"video/x-msvideo\"\n ],\n [\n \"azw\",\n \"application/vnd.amazon.ebook\"\n ],\n [\n \"bin\",\n \"application/octet-stream\"\n ],\n [\n \"bmp\",\n \"image/bmp\"\n ],\n [\n \"bz\",\n \"application/x-bzip\"\n ],\n [\n \"bz2\",\n \"application/x-bzip2\"\n ],\n [\n \"cda\",\n \"application/x-cdf\"\n ],\n [\n \"csh\",\n \"application/x-csh\"\n ],\n [\n \"css\",\n \"text/css\"\n ],\n [\n \"csv\",\n \"text/csv\"\n ],\n [\n \"doc\",\n \"application/msword\"\n ],\n [\n \"docx\",\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\"\n ],\n [\n \"eot\",\n \"application/vnd.ms-fontobject\"\n ],\n [\n \"epub\",\n \"application/epub+zip\"\n ],\n [\n \"gz\",\n \"application/gzip\"\n ],\n [\n \"gif\",\n \"image/gif\"\n ],\n [\n \"heic\",\n \"image/heic\"\n ],\n [\n \"heif\",\n \"image/heif\"\n ],\n [\n \"htm\",\n \"text/html\"\n ],\n [\n \"html\",\n \"text/html\"\n ],\n [\n \"ico\",\n \"image/vnd.microsoft.icon\"\n ],\n [\n \"ics\",\n \"text/calendar\"\n ],\n [\n \"jar\",\n \"application/java-archive\"\n ],\n [\n \"jpeg\",\n \"image/jpeg\"\n ],\n [\n \"jpg\",\n \"image/jpeg\"\n ],\n [\n \"jxl\",\n \"image/jxl\"\n ],\n [\n \"js\",\n \"text/javascript\"\n ],\n [\n \"json\",\n \"application/json\"\n ],\n [\n \"jsonld\",\n \"application/ld+json\"\n ],\n [\n \"mid\",\n \"audio/midi\"\n ],\n [\n \"midi\",\n \"audio/midi\"\n ],\n [\n \"mjs\",\n \"text/javascript\"\n ],\n [\n \"mp3\",\n \"audio/mpeg\"\n ],\n [\n \"mp4\",\n \"video/mp4\"\n ],\n [\n \"mpeg\",\n \"video/mpeg\"\n ],\n [\n \"mpkg\",\n \"application/vnd.apple.installer+xml\"\n ],\n [\n \"odp\",\n \"application/vnd.oasis.opendocument.presentation\"\n ],\n [\n \"ods\",\n \"application/vnd.oasis.opendocument.spreadsheet\"\n ],\n [\n \"odt\",\n \"application/vnd.oasis.opendocument.text\"\n ],\n [\n \"oga\",\n \"audio/ogg\"\n ],\n [\n \"ogv\",\n \"video/ogg\"\n ],\n [\n \"ogx\",\n \"application/ogg\"\n ],\n [\n \"opus\",\n \"audio/opus\"\n ],\n [\n \"otf\",\n \"font/otf\"\n ],\n [\n \"png\",\n \"image/png\"\n ],\n [\n \"pdf\",\n \"application/pdf\"\n ],\n [\n \"php\",\n \"application/x-httpd-php\"\n ],\n [\n \"ppt\",\n \"application/vnd.ms-powerpoint\"\n ],\n [\n \"pptx\",\n \"application/vnd.openxmlformats-officedocument.presentationml.presentation\"\n ],\n [\n \"rar\",\n \"application/vnd.rar\"\n ],\n [\n \"rtf\",\n \"application/rtf\"\n ],\n [\n \"sh\",\n \"application/x-sh\"\n ],\n [\n \"svg\",\n \"image/svg+xml\"\n ],\n [\n \"swf\",\n \"application/x-shockwave-flash\"\n ],\n [\n \"tar\",\n \"application/x-tar\"\n ],\n [\n \"tif\",\n \"image/tiff\"\n ],\n [\n \"tiff\",\n \"image/tiff\"\n ],\n [\n \"ts\",\n \"video/mp2t\"\n ],\n [\n \"ttf\",\n \"font/ttf\"\n ],\n [\n \"txt\",\n \"text/plain\"\n ],\n [\n \"vsd\",\n \"application/vnd.visio\"\n ],\n [\n \"wav\",\n \"audio/wav\"\n ],\n [\n \"weba\",\n \"audio/webm\"\n ],\n [\n \"webm\",\n \"video/webm\"\n ],\n [\n \"webp\",\n \"image/webp\"\n ],\n [\n \"woff\",\n \"font/woff\"\n ],\n [\n \"woff2\",\n \"font/woff2\"\n ],\n [\n \"xhtml\",\n \"application/xhtml+xml\"\n ],\n [\n \"xls\",\n \"application/vnd.ms-excel\"\n ],\n [\n \"xlsx\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"\n ],\n [\n \"xml\",\n \"application/xml\"\n ],\n [\n \"xul\",\n \"application/vnd.mozilla.xul+xml\"\n ],\n [\n \"zip\",\n \"application/zip\"\n ],\n [\n \"7z\",\n \"application/x-7z-compressed\"\n ],\n // Others\n [\n \"mkv\",\n \"video/x-matroska\"\n ],\n [\n \"mov\",\n \"video/quicktime\"\n ],\n [\n \"msg\",\n \"application/vnd.ms-outlook\"\n ]\n]);\nconst $f31161edf38949e9$var$FILES_TO_IGNORE = [\n // Thumbnail cache files for macOS and Windows\n \".DS_Store\",\n \"Thumbs.db\" // Windows\n];\n/**\n * Adds a `type` property to the file object if it doesn't have one and the file has an extension.\n * This is needed because Firefox doesn't add a type property to files dragged from the desktop.\n * @bug https://bugzilla.mozilla.org/show_bug.cgi?id=1424689\n *\n * @param {File} file The file object to add the type property to.\n * @returns {File} The file object with the type property added.\n */ const $f31161edf38949e9$var$toFileWithMimeType = (file)=>{\n const { name: name } = file;\n const hasExtension = name && name.lastIndexOf(\".\") !== -1;\n if (hasExtension && !file.type) {\n const extension = name.split(\".\").pop().toLowerCase();\n const type = $f31161edf38949e9$var$COMMON_MIME_TYPES.get(extension);\n if (type) Object.defineProperty(file, \"type\", {\n value: type,\n writable: false,\n configurable: false,\n enumerable: true\n });\n }\n return file;\n};\n/**\n * Adds a `path` property to the file object if it doesn't have one.\n * If `path` is not provided, the `webkitRelativePath` property of the file will be used\n * or the file's name if `webkitRelativePath` is not available.\n *\n * @param {File} file The file object to add the path property to.\n * @param {String} [path] The path to set on the file object.\n * @returns {File} The file object with the path property added.\n */ const $f31161edf38949e9$var$toFileWithPath = (file, path)=>{\n const fileWithMimeType = $f31161edf38949e9$var$toFileWithMimeType(file);\n if (typeof fileWithMimeType.path !== \"string\") {\n const { webkitRelativePath: webkitRelativePath } = file;\n Object.defineProperty(fileWithMimeType, \"path\", {\n value: typeof path === \"string\" ? path : webkitRelativePath || file.name,\n writable: false,\n configurable: false,\n enumerable: true\n });\n }\n return fileWithMimeType;\n};\n/**\n * Wrap `FileSystemDirectoryReader.readEntries` in a promise to make working with read entries easier.\n * https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryReader/readEntries\n *\n * @param {FileSystemDirectoryReader} directoryReader The directory reader to read entries from.\n * @returns {Promise<FileSystemFileEntry[]>} A promise that resolves with an array of `FileSystemFileEntry` objects.\n */ const $f31161edf38949e9$var$readEntriesPromise = async (directoryReader)=>{\n return await new Promise((resolve, reject)=>{\n directoryReader.readEntries(resolve, reject);\n });\n};\n/**\n * Read all entries in a directory or sub-directory\n * by calling `readEntries` until it returns an empty array.\n *\n * @param {FileSystemDirectoryReader} directoryReader The directory reader to read entries from.\n * @returns {Promise<FileSystemFileEntry[]>} A promise that resolves with an array of `FileSystemFileEntry` objects.\n */ const $f31161edf38949e9$var$readAllDirectoryEntries = async (directoryReader)=>{\n const entries = [];\n let readEntries = await $f31161edf38949e9$var$readEntriesPromise(directoryReader);\n while(readEntries.length > 0){\n entries.push(...readEntries);\n readEntries = await $f31161edf38949e9$var$readEntriesPromise(directoryReader);\n }\n return entries;\n};\n/**\n * Get a `File` object from a `FileSystemFileEntry` object.\n *\n * @param {FileSystemFileEntry} fileEntry The file entry to get a `File` object from.\n * @returns {Promise<File>} A promise that resolves with a `File` object.\n */ const $f31161edf38949e9$var$getFileFromFileEntry = (fileEntry)=>{\n return new Promise((resolve, reject)=>{\n fileEntry.file((file)=>resolve($f31161edf38949e9$var$toFileWithPath(file, fileEntry.fullPath)), reject);\n });\n};\n/**\n * Get an array of `File` objects from a `DataTransferItemList` object.\n *\n * @param {DataTransferItemList} dataTransferItemList The item list to get an array of `File` objects from.\n * @returns {Promise<File[]>} A promise that resolves with an array of `File` objects.\n */ const $f31161edf38949e9$var$getFilesFromDataTransferItemList = async (dataTransferItemList)=>{\n const files = [];\n // Chromium browsers read only 100 files at a time as per the spec, so we need to use\n // BFS (Breadth-first search) to traverse the entire directory/file structure.\n // https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/webkitGetAsEntry#javascript_content\n const queue = [];\n for (const item of dataTransferItemList){\n if (item.kind !== \"file\") continue;\n // https://developer.mozilla.org/docs/Web/API/DataTransferItem/webkitGetAsEntry\n // This function is implemented as `webkitGetAsEntry()` in non-WebKit browsers\n // including Firefox at this time but it may be renamed to `getAsEntry()` in the future.\n const entry = item.getAsEntry ? item.getAsEntry() : item.webkitGetAsEntry();\n queue.push(entry);\n }\n while(queue.length > 0){\n const entry = queue.shift();\n if (!entry) continue;\n else if (entry.isFile) {\n const file = await $f31161edf38949e9$var$getFileFromFileEntry(entry);\n if ($f31161edf38949e9$var$FILES_TO_IGNORE.indexOf(file.name) === -1) files.push(file);\n } else if (entry.isDirectory) queue.push(...await $f31161edf38949e9$var$readAllDirectoryEntries(entry.createReader()));\n }\n return files;\n};\n/**\n * Get an array of `File` objects from a `FileList` object.\n *\n * @param {FileList} fileList The file list to get an array of `File` objects from.\n * @returns {Promise<File[]>} A promise that resolves with an array of `File` objects.\n */ const $f31161edf38949e9$var$getFilesFromFileList = async (fileList)=>{\n const files = [];\n for (const file of fileList)if ($f31161edf38949e9$var$FILES_TO_IGNORE.indexOf(file.name) === -1) files.push($f31161edf38949e9$var$toFileWithPath(file));\n return files;\n};\nconst $f31161edf38949e9$export$6d52664cd15c442 = async (evt)=>{\n if (evt.dataTransfer) return evt.dataTransfer.items ? await $f31161edf38949e9$var$getFilesFromDataTransferItemList(evt.dataTransfer.items) : await $f31161edf38949e9$var$getFilesFromFileList(evt.dataTransfer.files);\n return await $f31161edf38949e9$var$getFilesFromFileList(evt.target.files);\n};\n\n\nconst $862aa3736b0514bc$var$COMPONENT_NAME = \"files-dropzone\";\nconst $862aa3736b0514bc$var$TOO_MANY_FILES = \"TOO_MANY_FILES\";\nconst $862aa3736b0514bc$var$FILE_TOO_LARGE = \"FILE_TOO_LARGE\";\nconst $862aa3736b0514bc$var$FILE_TOO_SMALL = \"FILE_TOO_SMALL\";\nconst $862aa3736b0514bc$var$INVALID_MIME_TYPE = \"INVALID_MIME_TYPE\";\nconst $862aa3736b0514bc$var$template = document.createElement(\"template\");\n$862aa3736b0514bc$var$template.innerHTML = /* html */ `\n <style>\n *,\n *::before,\n *::after {\n box-sizing: border-box;\n }\n\n :host([hidden]),\n [hidden] {\n display: none !important;\n }\n\n :host {\n --dropzone-border-width: 2px;\n --dropzone-border-style: dashed;\n --dropzone-border-radius: 0.25rem;\n --dropzone-border-color: #6c757d;\n --dropzone-border-color-dragover: #0d6efd;\n --dropzone-background-color: #ffffff;\n --dropzone-background-color-dragover: #f4f4f5;\n --dropzone-body-color: #3f3f46;\n --dropzone-body-color-dragover: var(--dropzone-body-color);\n --dropzone-focus-shadow-rgb: 49,132,253;\n --transition-duration: 0.2s;\n\n display: block;\n }\n\n :host(:not([no-style])) .dropzone {\n border: var(--dropzone-border-width) var(--dropzone-border-style) var(--dropzone-border-color);\n border-radius: var(--dropzone-border-radius);\n padding: 3rem 1rem;\n overflow: hidden;\n background-color: var(--dropzone-background-color);\n color: var(--dropzone-body-color);\n text-align: center;\n cursor: pointer;\n transition: border var(--transition-duration) ease-in-out, background-color var(--transition-duration) ease-in-out, color var(--transition-duration) ease-in-out, box-shadow var(--transition-duration) ease-in-out;\n }\n\n :host(:not([no-style])[no-click]) .dropzone {\n cursor: default;\n }\n\n :host(:not([no-style])[disabled]) .dropzone {\n opacity: 0.8;\n cursor: not-allowed;\n }\n\n :host(:not([no-style]):not([disabled])) .dropzone--dragover {\n border-color: var(--dropzone-border-color-dragover);\n background-color: var(--dropzone-background-color-dragover);\n color: var(--dropzone-body-color-dragover);\n }\n\n :host(:not([no-style]):not([disabled])) .dropzone:focus-visible {\n outline: none;\n box-shadow: 0 0 0 0.25rem rgba(var(--dropzone-focus-shadow-rgb), 0.5);\n }\n </style>\n\n <input type=\"file\" id=\"fileInput\" hidden>\n\n <div part=\"dropzone\" class=\"dropzone\" id=\"dropzoneEl\" tabindex=\"0\" role=\"presentation\">\n <slot>Drag 'n' drop files here, or click to select files</slot>\n </div>\n`;\nclass $862aa3736b0514bc$export$6ccd1735166caad9 extends HTMLElement {\n #fileInput;\n #dropzoneEl;\n constructor(){\n super();\n if (!this.shadowRoot) {\n this.attachShadow({\n mode: \"open\"\n });\n this.shadowRoot.appendChild($862aa3736b0514bc$var$template.content.cloneNode(true));\n }\n this.#fileInput = this.shadowRoot.getElementById(\"fileInput\");\n this.#dropzoneEl = this.shadowRoot.getElementById(\"dropzoneEl\");\n }\n static get observedAttributes() {\n return [\n \"accept\",\n \"disabled\",\n \"multiple\",\n \"no-keyboard\"\n ];\n }\n attributeChangedCallback(name, oldValue, newValue) {\n if (name === \"accept\" && oldValue !== newValue && this.#fileInput) this.#fileInput.accept = this.accept;\n if (name === \"disabled\" && oldValue !== newValue && this.#fileInput) {\n this.#fileInput.disabled = this.disabled;\n if (this.disabled) this.#dropzoneEl.removeAttribute(\"tabindex\");\n else this.#dropzoneEl.setAttribute(\"tabindex\", \"0\");\n }\n if (name === \"multiple\" && oldValue !== newValue && this.#fileInput) this.#fileInput.multiple = this.multiple;\n if (name === \"no-keyboard\" && oldValue !== newValue && this.#dropzoneEl) {\n if (this.noKeyboard) this.#dropzoneEl.removeAttribute(\"tabindex\");\n else this.#dropzoneEl.setAttribute(\"tabindex\", \"0\");\n }\n }\n connectedCallback() {\n this.#upgradeProperty(\"accept\");\n this.#upgradeProperty(\"disabled\");\n this.#upgradeProperty(\"maxFiles\");\n this.#upgradeProperty(\"maxSize\");\n this.#upgradeProperty(\"minSize\");\n this.#upgradeProperty(\"multiple\");\n this.#upgradeProperty(\"noClick\");\n this.#upgradeProperty(\"noDrag\");\n this.#upgradeProperty(\"noKeyboard\");\n this.#upgradeProperty(\"autoFocus\");\n this.#upgradeProperty(\"noStyle\");\n this.#fileInput.addEventListener(\"change\", this.#onFileInputChange);\n this.#dropzoneEl.addEventListener(\"dragenter\", this.#onDragEnter);\n this.#dropzoneEl.addEventListener(\"dragover\", this.#onDragOver);\n this.#dropzoneEl.addEventListener(\"dragleave\", this.#onDragLeave);\n this.#dropzoneEl.addEventListener(\"drop\", this.#onDrop);\n this.#dropzoneEl.addEventListener(\"click\", this.#onClick);\n this.#dropzoneEl.addEventListener(\"keyup\", this.#onKeyUp);\n this.autoFocus && this.#dropzoneEl.focus();\n }\n disconnectedCallback() {\n this.#fileInput.removeEventListener(\"change\", this.#onFileInputChange);\n this.#dropzoneEl.removeEventListener(\"dragenter\", this.#onDragEnter);\n this.#dropzoneEl.removeEventListener(\"dragover\", this.#onDragOver);\n this.#dropzoneEl.removeEventListener(\"dragleave\", this.#onDragLeave);\n this.#dropzoneEl.removeEventListener(\"drop\", this.#onDrop);\n this.#dropzoneEl.removeEventListener(\"click\", this.#onClick);\n this.#dropzoneEl.removeEventListener(\"keyup\", this.#onKeyUp);\n }\n get accept() {\n return this.getAttribute(\"accept\");\n }\n set accept(value) {\n this.setAttribute(\"accept\", value);\n }\n get disabled() {\n return this.hasAttribute(\"disabled\");\n }\n set disabled(value) {\n if (value) this.setAttribute(\"disabled\", \"\");\n else this.removeAttribute(\"disabled\");\n }\n get maxFiles() {\n const num = Number(this.getAttribute(\"max-files\")) || 0;\n if (num <= 0) return Infinity;\n return Math.floor(Math.abs(num));\n }\n set maxFiles(value) {\n this.setAttribute(\"max-files\", value);\n }\n get maxSize() {\n const value = this.getAttribute(\"max-size\");\n if (value === null) return Infinity;\n const num = Number(value);\n return Number.isNaN(num) ? Infinity : num;\n }\n set maxSize(value) {\n this.setAttribute(\"max-size\", value);\n }\n get minSize() {\n const value = this.getAttribute(\"min-size\");\n if (value === null) return 0;\n const num = Number(value);\n return Number.isNaN(num) ? 0 : num;\n }\n set minSize(value) {\n this.setAttribute(\"min-size\", value);\n }\n get multiple() {\n return this.hasAttribute(\"multiple\");\n }\n set multiple(value) {\n if (value) this.setAttribute(\"multiple\", \"\");\n else this.removeAttribute(\"multiple\");\n }\n get noClick() {\n return this.hasAttribute(\"no-click\");\n }\n set noClick(value) {\n if (value) this.setAttribute(\"no-click\", \"\");\n else this.removeAttribute(\"no-click\");\n }\n get noDrag() {\n return this.hasAttribute(\"no-drag\");\n }\n set noDrag(value) {\n if (value) this.setAttribute(\"no-drag\", \"\");\n else this.removeAttribute(\"no-drag\");\n }\n get noKeyboard() {\n return this.hasAttribute(\"no-keyboard\");\n }\n set noKeyboard(value) {\n if (value) this.setAttribute(\"no-keyboard\", \"\");\n else this.removeAttribute(\"no-keyboard\");\n }\n get autoFocus() {\n return this.hasAttribute(\"auto-focus\");\n }\n set autoFocus(value) {\n if (value) this.setAttribute(\"auto-focus\", \"\");\n else this.removeAttribute(\"auto-focus\");\n }\n get noStyle() {\n return this.hasAttribute(\"no-style\");\n }\n set noStyle(value) {\n if (value) this.setAttribute(\"no-style\", \"\");\n else this.removeAttribute(\"no-style\");\n }\n #onFileInputChange = async (evt)=>{\n try {\n this.#handleFilesSelect(await (0, $f31161edf38949e9$export$6d52664cd15c442)(evt));\n } catch (error) {\n this.dispatchEvent(new CustomEvent(`${$862aa3736b0514bc$var$COMPONENT_NAME}-error`, {\n bubbles: true,\n composed: true,\n detail: {\n error: error\n }\n }));\n }\n };\n #onDragEnter = ()=>{\n if (this.disabled || this.noDrag) return;\n this.dispatchEvent(new Event(`${$862aa3736b0514bc$var$COMPONENT_NAME}-dragenter`, {\n bubbles: true,\n composed: true\n }));\n };\n #onDragOver = (evt)=>{\n evt.preventDefault();\n if (this.disabled || this.noDrag) {\n evt.dataTransfer.dropEffect = \"none\";\n return;\n }\n evt.dataTransfer.dropEffect = \"copy\";\n this.#dropzoneEl.classList.add(\"dropzone--dragover\");\n this.#dropzoneEl.part.add(\"dropzone--dragover\");\n this.dispatchEvent(new Event(`${$862aa3736b0514bc$var$COMPONENT_NAME}-dragover`, {\n bubbles: true,\n composed: true\n }));\n };\n #onDragLeave = ()=>{\n if (this.disabled || this.noDrag) return;\n this.#dropzoneEl.classList.remove(\"dropzone--dragover\");\n this.#dropzoneEl.part.remove(\"dropzone--dragover\");\n this.dispatchEvent(new Event(`${$862aa3736b0514bc$var$COMPONENT_NAME}-dragleave`, {\n bubbles: true,\n composed: true\n }));\n };\n #onDrop = async (evt)=>{\n if (this.disabled || this.noDrag) return;\n evt.preventDefault();\n this.#dropzoneEl.classList.remove(\"dropzone--dragover\");\n this.#dropzoneEl.part.remove(\"dropzone--dragover\");\n try {\n this.#handleFilesSelect(await (0, $f31161edf38949e9$export$6d52664cd15c442)(evt));\n } catch (error) {\n this.dispatchEvent(new CustomEvent(`${$862aa3736b0514bc$var$COMPONENT_NAME}-error`, {\n bubbles: true,\n composed: true,\n detail: {\n error: error\n }\n }));\n }\n };\n #onClick = ()=>{\n if (this.disabled || this.noClick) return;\n this.#fileInput.click();\n };\n #onKeyUp = (evt)=>{\n if (this.disabled || this.noKeyboard) return;\n if (evt.key === \" \" || evt.key === \"Enter\") this.#fileInput.click();\n };\n #handleFilesSelect(files) {\n if (!Array.isArray(files) || !files.length) return;\n const acceptedFiles = [];\n const rejectedFiles = [];\n const filesLength = files.length;\n // If the component is not in multiple mode, reject all files.\n if (!this.multiple && filesLength > 1) for (const file of files)rejectedFiles.push({\n file: file,\n errors: [\n {\n code: $862aa3736b0514bc$var$TOO_MANY_FILES,\n message: `Too many files selected. Only 1 file is allowed.`\n }\n ]\n });\n else if (this.multiple && filesLength > this.maxFiles) // If the component is in multiple mode, but the number of files exceeds\n // the maxFiles attribute, reject all files.\n for (const file of files)rejectedFiles.push({\n file: file,\n errors: [\n {\n code: $862aa3736b0514bc$var$TOO_MANY_FILES,\n message: `Too many files selected. Only ${this.maxFiles} ${this.maxFiles > 1 ? \"files are\" : \"file is\"} allowed.`\n }\n ]\n });\n else // Validate each file. If it's valid, add it to the accepted files array,\n // otherwise add it to the rejected files array.\n for (const file of files){\n const fileHasValidType = (0, $38f222170fd4d21a$export$7c47054fed488f80)(file, this.accept);\n const fileExceedsMaxSize = file.size > this.maxSize;\n const fileIsSmallerThanMinSize = file.size < this.minSize;\n if (fileHasValidType && !fileExceedsMaxSize && !fileIsSmallerThanMinSize) acceptedFiles.push(file);\n else {\n const errors = [];\n if (!fileHasValidType) errors.push({\n code: $862aa3736b0514bc$var$INVALID_MIME_TYPE,\n message: `File type \"${file.type}\" is not accepted.`\n });\n if (fileExceedsMaxSize) errors.push({\n code: $862aa3736b0514bc$var$FILE_TOO_LARGE,\n message: `File size ${file.size} exceeds the maximum size of ${this.maxSize}.`\n });\n if (fileIsSmallerThanMinSize) errors.push({\n code: $862aa3736b0514bc$var$FILE_TOO_SMALL,\n message: `File size ${file.size} is smaller than the minimum size of ${this.minSize}.`\n });\n rejectedFiles.push({\n file: file,\n errors: errors\n });\n }\n }\n this.dispatchEvent(new CustomEvent(`${$862aa3736b0514bc$var$COMPONENT_NAME}-drop`, {\n bubbles: true,\n composed: true,\n detail: {\n acceptedFiles: acceptedFiles,\n rejectedFiles: rejectedFiles\n }\n }));\n if (acceptedFiles.length > 0) this.dispatchEvent(new CustomEvent(`${$862aa3736b0514bc$var$COMPONENT_NAME}-drop-accepted`, {\n bubbles: true,\n composed: true,\n detail: {\n acceptedFiles: acceptedFiles\n }\n }));\n if (rejectedFiles.length > 0) this.dispatchEvent(new CustomEvent(`${$862aa3736b0514bc$var$COMPONENT_NAME}-drop-rejected`, {\n bubbles: true,\n composed: true,\n detail: {\n rejectedFiles: rejectedFiles\n }\n }));\n this.#fileInput.value = this.#fileInput.defaultValue;\n }\n openFileDialog() {\n if (this.disabled) return;\n this.#fileInput.click();\n }\n /**\n * https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties\n * This is to safe guard against cases where, for instance, a framework may have added the element to the page and set a\n * value on one of its properties, but lazy loaded its definition. Without this guard, the upgraded element would miss that\n * property and the instance property would prevent the class property setter from ever being called.\n */ #upgradeProperty(prop) {\n if (Object.prototype.hasOwnProperty.call(this, prop)) {\n const value = this[prop];\n delete this[prop];\n this[prop] = value;\n }\n }\n static defineCustomElement(elementName = $862aa3736b0514bc$var$COMPONENT_NAME) {\n if (typeof window !== \"undefined\" && !window.customElements.get(elementName)) window.customElements.define(elementName, $862aa3736b0514bc$export$6ccd1735166caad9);\n }\n}\n\n\n(0, $862aa3736b0514bc$export$6ccd1735166caad9).defineCustomElement();\n\n\nexport {$862aa3736b0514bc$export$6ccd1735166caad9 as FilesDropzone};\n//# sourceMappingURL=files-dropzone-defined.js.map\n","import { FilesDropzone } from './files-dropzone.js';\n\nFilesDropzone.defineCustomElement();\n\nexport { FilesDropzone };\n","import { isValidFile } from './utils/is-valid-file.js';\nimport { getFilesFromEvent } from './utils/files-selector.js';\n\nconst COMPONENT_NAME = 'files-dropzone';\nconst TOO_MANY_FILES = 'TOO_MANY_FILES';\nconst FILE_TOO_LARGE = 'FILE_TOO_LARGE';\nconst FILE_TOO_SMALL = 'FILE_TOO_SMALL';\nconst INVALID_MIME_TYPE = 'INVALID_MIME_TYPE';\nconst template = document.createElement('template');\n\ntemplate.innerHTML = /* html */`\n <style>\n *,\n *::before,\n *::after {\n box-sizing: border-box;\n }\n\n :host([hidden]),\n [hidden] {\n display: none !important;\n }\n\n :host {\n --dropzone-border-width: 2px;\n --dropzone-border-style: dashed;\n --dropzone-border-radius: 0.25rem;\n --dropzone-border-color: #6c757d;\n --dropzone-border-color-dragover: #0d6efd;\n --dropzone-background-color: #ffffff;\n --dropzone-background-color-dragover: #f4f4f5;\n --dropzone-body-color: #3f3f46;\n --dropzone-body-color-dragover: var(--dropzone-body-color);\n --dropzone-focus-shadow-rgb: 49,132,253;\n --transition-duration: 0.2s;\n\n display: block;\n }\n\n :host(:not([no-style])) .dropzone {\n border: var(--dropzone-border-width) var(--dropzone-border-style) var(--dropzone-border-color);\n border-radius: var(--dropzone-border-radius);\n padding: 3rem 1rem;\n overflow: hidden;\n background-color: var(--dropzone-background-color);\n color: var(--dropzone-body-color);\n text-align: center;\n cursor: pointer;\n transition: border var(--transition-duration) ease-in-out, background-color var(--transition-duration) ease-in-out, color var(--transition-duration) ease-in-out, box-shadow var(--transition-duration) ease-in-out;\n }\n\n :host(:not([no-style])[no-click]) .dropzone {\n cursor: default;\n }\n\n :host(:not([no-style])[disabled]) .dropzone {\n opacity: 0.8;\n cursor: not-allowed;\n }\n\n :host(:not([no-style]):not([disabled])) .dropzone--dragover {\n border-color: var(--dropzone-border-color-dragover);\n background-color: var(--dropzone-background-color-dragover);\n color: var(--dropzone-body-color-dragover);\n }\n\n :host(:not([no-style]):not([disabled])) .dropzone:focus-visible {\n outline: none;\n box-shadow: 0 0 0 0.25rem rgba(var(--dropzone-focus-shadow-rgb), 0.5);\n }\n </style>\n\n <input type=\"file\" id=\"fileInput\" hidden>\n\n <div part=\"dropzone\" class=\"dropzone\" id=\"dropzoneEl\" tabindex=\"0\" role=\"presentation\">\n <slot>Drag 'n' drop files here, or click to select files</slot>\n </div>\n`;\n\nclass FilesDropzone extends HTMLElement {\n #fileInput;\n #dropzoneEl;\n\n constructor() {\n super();\n\n if (!this.shadowRoot) {\n this.attachShadow({ mode: 'open' });\n this.shadowRoot.appendChild(template.content.cloneNode(true));\n }\n\n this.#fileInput = this.shadowRoot.getElementById('fileInput');\n this.#dropzoneEl = this.shadowRoot.getElementById('dropzoneEl');\n }\n\n static get observedAttributes() {\n return ['accept', 'disabled', 'multiple', 'no-keyboard'];\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n if (name === 'accept' && oldValue !== newValue && this.#fileInput) {\n this.#fileInput.accept = this.accept;\n }\n\n if (name === 'disabled' && oldValue !== newValue && this.#fileInput) {\n this.#fileInput.disabled = this.disabled;\n\n if (this.disabled) {\n this.#dropzoneEl.removeAttribute('tabindex');\n } else {\n this.#dropzoneEl.setAttribute('tabindex', '0');\n }\n }\n\n if (name === 'multiple' && oldValue !== newValue && this.#fileInput) {\n this.#fileInput.multiple = this.multiple;\n }\n\n if (name === 'no-keyboard' && oldValue !== newValue && this.#dropzoneEl) {\n if (this.noKeyboard) {\n this.#dropzoneEl.removeAttribute('tabindex');\n } else {\n this.#dropzoneEl.setAttribute('tabindex', '0');\n }\n }\n }\n\n connectedCallback() {\n this.#upgradeProperty('accept');\n this.#upgradeProperty('disabled');\n this.#upgradeProperty('maxFiles');\n this.#upgradeProperty('maxSize');\n this.#upgradeProperty('minSize');\n this.#upgradeProperty('multiple');\n this.#upgradeProperty('noClick');\n this.#upgradeProperty('noDrag');\n this.#upgradeProperty('noKeyboard');\n this.#upgradeProperty('autoFocus');\n this.#upgradeProperty('noStyle');\n\n this.#fileInput.addEventListener('change', this.#onFileInputChange);\n this.#dropzoneEl.addEventListener('dragenter', this.#onDragEnter);\n this.#dropzoneEl.addEventListener('dragover', this.#onDragOver);\n this.#dropzoneEl.addEventListener('dragleave', this.#onDragLeave);\n this.#dropzoneEl.addEventListener('drop', this.#onDrop);\n this.#dropzoneEl.addEventListener('click', this.#onClick);\n this.#dropzoneEl.addEventListener('keyup', this.#onKeyUp);\n\n this.autoFocus && this.#dropzoneEl.focus();\n }\n\n disconnectedCallback() {\n this.#fileInput.removeEventListener('change', this.#onFileInputChange);\n this.#dropzoneEl.removeEventListener('dragenter', this.#onDragEnter);\n this.#dropzoneEl.removeEventListener('dragover', this.#onDragOver);\n this.#dropzoneEl.removeEventListener('dragleave', this.#onDragLeave);\n this.#dropzoneEl.removeEventListener('drop', this.#onDrop);\n this.#dropzoneEl.removeEventListener('click', this.#onClick);\n this.#dropzoneEl.removeEventListener('keyup', this.#onKeyUp);\n }\n\n get accept() {\n return this.getAttribute('accept');\n }\n\n set accept(value) {\n this.setAttribute('accept', value);\n }\n\n get disabled() {\n return this.hasAttribute('disabled');\n }\n\n set disabled(value) {\n if (value) {\n this.setAttribute('disabled', '');\n } else {\n this.removeAttribute('disabled');\n }\n }\n\n get maxFiles() {\n const num = Number(this.getAttribute('max-files')) || 0;\n\n if (num <= 0) {\n return Infinity;\n }\n\n return Math.floor(Math.abs(num));\n }\n\n set maxFiles(value) {\n this.setAttribute('max-files', value);\n }\n\n get maxSize() {\n const value = this.getAttribute('max-size');\n\n if (value === null) {\n return Infinity;\n }\n\n const num = Number(value);\n\n return Number.isNaN(num) ? Infinity : num;\n }\n\n set maxSize(value) {\n this.setAttribute('max-size', value);\n }\n\n get minSize() {\n const value = this.getAttribute('min-size');\n\n if (value === null) {\n return 0;\n }\n\n const num = Number(value);\n\n return Number.isNaN(num) ? 0 : num;\n }\n\n set minSize(value) {\n this.setAttribute('min-size', value);\n }\n\n get multiple() {\n return this.hasAttribute('multiple');\n }\n\n set multiple(value) {\n if (value) {\n this.setAttribute('multiple', '');\n } else {\n this.removeAttribute('multiple');\n }\n }\n\n get noClick() {\n return this.hasAttribute('no-click');\n }\n\n set noClick(value) {\n if (value) {\n this.setAttribute('no-click', '');\n } else {\n this.removeAttribute('no-click');\n }\n }\n\n get noDrag() {\n return this.hasAttribute('no-drag');\n }\n\n set noDrag(value) {\n if (value) {\n this.setAttribute('no-drag', '');\n } else {\n this.removeAttribute('no-drag');\n }\n }\n\n get noKeyboard() {\n return this.hasAttribute('no-keyboard');\n }\n\n set noKeyboard(value) {\n if (value) {\n this.setAttribute('no-keyboard', '');\n } else {\n this.removeAttribute('no-keyboard');\n }\n }\n\n get autoFocus() {\n return this.hasAttribute('auto-focus');\n }\n\n set autoFocus(value) {\n if (value) {\n this.setAttribute('auto-focus', '');\n } else {\n this.removeAttribute('auto-focus');\n }\n }\n\n get noStyle() {\n return this.hasAttribute('no-style');\n }\n\n set noStyle(value) {\n if (value) {\n this.setAttribute('no-style', '');\n } else {\n this.removeAttribute('no-style');\n }\n }\n\n #onFileInputChange = async evt => {\n try {\n this.#handleFilesSelect(await getFilesFromEvent(evt));\n } catch (error) {\n this.dispatchEvent(new CustomEvent(`${COMPONENT_NAME}-error`, {\n bubbles: true,\n composed: true,\n detail: { error }\n }));\n }\n };\n\n #onDragEnter = () => {\n if (this.disabled || this.noDrag) {\n return;\n }\n\n this.dispatchEvent(new Event(`${COMPONENT_NAME}-dragenter`, {\n bubbles: true,\n composed: true\n }));\n };\n\n #onDragOver = evt => {\n evt.preventDefault();\n\n if (this.disabled || this.noDrag) {\n evt.dataTransfer.dropEffect = 'none';\n return;\n }\n\n evt.dataTransfer.dropEffect = 'copy';\n\n this.#dropzoneEl.classList.add('dropzone--dragover');\n this.#dropzoneEl.part.add('dropzone--dragover');\n\n this.dispatchEvent(new Event(`${COMPONENT_NAME}-dragover`, {\n bubbles: true,\n composed: true\n }));\n };\n\n #onDragLeave = () => {\n if (this.disabled || this.noDrag) {\n return;\n }\n\n this.#dropzoneEl.classList.remove('dropzone--dragover');\n this.#dropzoneEl.part.remove('dropzone--dragover');\n\n this.dispatchEvent(new Event(`${COMPONENT_NAME}-dragleave`, {\n bubbles: true,\n composed: true\n }));\n };\n\n #onDrop = async evt => {\n if (this.disabled || this.noDrag) {\n return;\n }\n\n evt.preventDefault();\n\n this.#dropzoneEl.classList.remove('dropzone--dragover');\n this.#dropzoneEl.part.remove('dropzone--dragover');\n\n try {\n this.#handleFilesSelect(await getFilesFromEvent(evt));\n } catch (error) {\n this.dispatchEvent(new CustomEvent(`${COMPONENT_NAME}-error`, {\n bubbles: true,\n composed: true,\n detail: { error }\n }));\n }\n };\n\n #onClick = () => {\n if (this.disabled || this.noClick) {\n return;\n }\n\n this.#fileInput.click();\n };\n\n #onKeyUp = evt => {\n if (this.disabled || this.noKeyboard) {\n return;\n }\n\n if (evt.key === ' ' || evt.key === 'Enter') {\n this.#fileInput.click();\n }\n };\n\n #handleFilesSelect(files) {\n if (!Array.isArray(files) || !files.length) {\n return;\n }\n\n const acceptedFiles = [];\n const rejectedFiles = [];\n const filesLength = files.length;\n\n // If the component is not in multiple mode, reject all files.\n if (!this.multiple && filesLength > 1) {\n for (const file of files) {\n rejectedFiles.push({\n file,\n errors: [{\n code: TOO_MANY_FILES,\n message: `Too many files selected. Only 1 file is allowed.`\n }]\n });\n }\n } else if (this.multiple && filesLength > this.maxFiles) {\n // If the component is in multiple mode, but the number of files exceeds\n // the maxFiles attribute, reject all files.\n for (const file of files) {\n rejectedFiles.push({\n file,\n errors: [{\n code: TOO_MANY_FILES,\n message: `Too many files selected. Only ${this.maxFiles} ${this.maxFiles > 1 ? 'files are' : 'file is'} allowed.`\n }]\n });\n }\n } else {\n // Validate each file. If it's valid, add it to the accepted files array,\n // otherwise add it to the rejected files array.\n for (const file of files) {\n const fileHasValidType = isValidFile(file, this.accept);\n const fileExceedsMaxSize = file.size > this.maxSize;\n const fileIsSmallerThanMinSize = file.size < this.minSize;\n\n if (fileHasValidType && !fileExceedsMaxSize && !fileIsSmallerThanMinSize) {\n acceptedFiles.push(file);\n } else {\n const errors = [];\n\n if (!fileHasValidType) {\n errors.push({\n code: INVALID_MIME_TYPE,\n message: `File type \"${file.type}\" is not accepted.`\n });\n }\n\n if (fileExceedsMaxSize) {\n errors.push({\n code: FILE_TOO_LARGE,\n message: `File size ${file.size} exceeds the maximum size of ${this.maxSize}.`\n });\n }\n\n if (fileIsSmallerThanMinSize) {\n errors.push({\n code: FILE_TOO_SMALL,\n message: `File size ${file.size} is smaller than the minimum size of ${this.minSize}.`\n });\n }\n\n rejectedFiles.push({ file, errors });\n }\n }\n }\n\n this.dispatchEvent(new CustomEvent(`${COMPONENT_NAME}-drop`, {\n bubbles: true,\n composed: true,\n detail: {\n acceptedFiles,\n rejectedFiles\n }\n }));\n\n if (acceptedFiles.length > 0) {\n this.dispatchEvent(new CustomEvent(`${COMPONENT_NAME}-drop-accepted`, {\n bubbles: true,\n composed: true,\n detail: {\n acceptedFiles\n }\n }));\n }\n\n if (rejectedFiles.length > 0) {\n this.dispatchEvent(new CustomEvent(`${COMPONENT_NAME}-drop-rejected`, {\n bubbles: true,\n composed: true,\n detail: {\n rejectedFiles\n }\n }));\n }\n\n this.#fileInput.value = this.#fileInput.defaultValue;\n }\n\n openFileDialog() {\n if (this.disabled) {\n return;\n }\n\n this.#fileInput.click();\n }\n\n /**\n * https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties\n * This is to safe guard against cases where, for instance, a framework may have added the element to the page and set a\n * value on one of its properties, but lazy loaded its definition. Without this guard, the upgraded element would miss that\n * property and the instance property would prevent the class property setter from ever being called.\n */\n #upgradeProperty(prop) {\n if (Object.prototype.hasOwnProperty.call(this, prop)) {\n const value = this[prop];\n delete this[prop];\n this[prop] = value;\n }\n }\n\n static defineCustomElement(elementName = COMPONENT_NAME) {\n if (typeof window !== 'undefined' && !window.customElements.get(elementName)) {\n window.customElements.define(elementName, FilesDropzone);\n }\n }\n}\n\nexport { FilesDropzone };\n","/**\n * Checks if a file is valid based on the accepted file type specifiers.\n *\n * @param {File} file The File object to validate.\n * @param {String} [acceptedTypeSpecifiers=''] The accepted file type specifiers.\n * @returns {Boolean} True if the file is valid, false otherwise.\n */\nexport function isValidFile(file, acceptedTypeSpecifiers = '') {\n if (!acceptedTypeSpecifiers) {\n return true;\n }\n\n const acceptedMimeTypesList = [\n ...new Set(acceptedTypeSpecifiers.split(',').map(v => v.trim()).filter(Boolean))\n ];\n\n const fileMimeType = file.type;\n const baseMimeType = fileMimeType.replace(/\\/.*$/, '');\n\n for (const validType of acceptedMimeTypesList) {\n if (validType.charAt(0) === '.') {\n if (file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.length - validType.length) !== -1) {\n return true;\n }\n } else if (/\\/\\*$/.test(validType)) {\n // Check for mime type that looks like \"image/*\" or similar.\n if (baseMimeType === validType.replace(/\\/.*$/, '')) {\n return true;\n }\n } else {\n if (fileMimeType === validType) {\n return true;\n }\n }\n }\n\n return false;\n}\n","const COMMON_MIME_TYPES = new Map([\n // https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types\n ['aac', 'audio/aac'],\n ['abw', 'application/x-abiword'],\n ['arc', 'application/x-freearc'],\n ['avif', 'image/avif'],\n ['avi', 'video/x-msvideo'],\n ['azw', 'application/vnd.amazon.ebook'],\n ['bin', 'application/octet-stream'],\n ['bmp', 'image/bmp'],\n ['bz', 'application/x-bzip'],\n ['bz2', 'application/x-bzip2'],\n ['cda', 'application/x-cdf'],\n ['csh', 'application/x-csh'],\n ['css', 'text/css'],\n ['csv', 'text/csv'],\n ['doc', 'application/msword'],\n ['docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],\n ['eot', 'application/vnd.ms-fontobject'],\n ['epub', 'application/epub+zip'],\n ['gz', 'application/gzip'],\n ['gif', 'image/gif'],\n ['heic', 'image/heic'],\n ['heif', 'image/heif'],\n ['htm', 'text/html'],\n ['html', 'text/html'],\n ['ico', 'image/vnd.microsoft.icon'],\n ['ics', 'text/calendar'],\n ['jar', 'application/java-archive'],\n ['jpeg', 'image/jpeg'],\n ['jpg', 'image/jpeg'],\n ['jxl', 'image/jxl'],\n ['js', 'text/javascript'],\n ['json', 'application/json'],\n ['jsonld', 'application/ld+json'],\n ['mid', 'audio/midi'],\n ['midi', 'audio/midi'],\n ['mjs', 'text/javascript'],\n ['mp3', 'audio/mpeg'],\n ['mp4', 'video/mp4'],\n ['mpeg', 'video/mpeg'],\n ['mpkg', 'application/vnd.apple.installer+xml'],\n ['odp', 'application/vnd.oasis.opendocument.presentation'],\n ['ods', 'application/vnd.oasis.opendocument.spreadsheet'],\n ['odt', 'application/vnd.oasis.opendocument.text'],\n ['oga', 'audio/ogg'],\n ['ogv', 'video/ogg'],\n ['ogx', 'application/ogg'],\n ['opus', 'audio/opus'],\n ['otf', 'font/otf'],\n ['png', 'image/png'],\n ['pdf', 'application/pdf'],\n ['php', 'application/x-httpd-php'],\n ['ppt', 'application/vnd.ms-powerpoint'],\n ['pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'],\n ['rar', 'application/vnd.rar'],\n ['rtf', 'application/rtf'],\n ['sh', 'application/x-sh'],\n ['svg', 'image/svg+xml'],\n ['swf', 'application/x-shockwave-flash'],\n ['tar', 'application/x-tar'],\n ['tif', 'image/tiff'],\n ['tiff', 'image/tiff'],\n ['ts', 'video/mp2t'],\n ['ttf', 'font/ttf'],\n ['txt', 'text/plain'],\n ['vsd', 'application/vnd.visio'],\n ['wav', 'audio/wav'],\n ['weba', 'audio/webm'],\n ['webm', 'video/webm'],\n ['webp', 'image/webp'],\n ['woff', 'font/woff'],\n ['woff2', 'font/woff2'],\n ['xhtml', 'application/xhtml+xml'],\n ['xls', 'application/vnd.ms-excel'],\n ['xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],\n ['xml', 'application/xml'],\n ['xul', 'application/vnd.mozilla.xul+xml'],\n ['zip', 'application/zip'],\n ['7z', 'application/x-7z-compressed'],\n\n // Others\n ['mkv', 'video/x-matroska'],\n ['mov', 'video/quicktime'],\n ['msg', 'application/vnd.ms-outlook']\n]);\n\nconst FILES_TO_IGNORE = [\n // Thumbnail cache files for macOS and Windows\n '.DS_Store', // macOs\n 'Thumbs.db' // Windows\n];\n\n/**\n * Adds a `type` property to the file object if it doesn't have one and the file has an extension.\n * This is needed because Firefox doesn't add a type property to files dragged from the desktop.\n * @bug https://bugzilla.mozilla.org/show_bug.cgi?id=1424689\n *\n * @param {File} file The file object to add the type property to.\n * @returns {File} The file object with the type property added.\n */\nconst toFileWithMimeType = file => {\n const { name } = file;\n const hasExtension = name && name.lastIndexOf('.') !== -1;\n\n if (hasExtension && !file.type) {\n const extension = name.split('.').pop().toLowerCase();\n const type = COMMON_MIME_TYPES.get(extension);\n\n if (type) {\n Object.defineProperty(file, 'type', {\n value: type,\n writable: false,\n configurable: false,\n enumerable: true\n });\n }\n }\n\n return file;\n};\n\n/**\n * Adds a `path` property to the file object if it doesn't have one.\n * If `path` is not provided, the `webkitRelativePath` property of the file will be used\n * or the file's name if `webkitRelativePath` is not available.\n *\n * @param {File} file The file object to add the path property to.\n * @param {String} [path] The path to set on the file object.\n * @returns {File} The file object with the path property added.\n */\nconst toFileWithPath = (file, path) => {\n const fileWithMimeType = toFileWithMimeType(file);\n\n if (typeof fileWithMimeType.path !== 'string') {\n const { webkitRelativePath } = file;\n\n Object.defineProperty(fileWithMimeType, 'path', {\n value: typeof path === 'string' ? path : webkitRelativePath || file.name,\n writable: false,\n configurable: false,\n enumerable: true\n });\n }\n\n return fileWithMimeType;\n};\n\n/**\n * Wrap `FileSystemDirectoryReader.readEntries` in a promise to make working with read entries easier.\n * https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryReader/readEntries\n *\n * @param {FileSystemDirectoryReader} directoryReader The directory reader to read entries from.\n * @returns {Promise<FileSystemFileEntry[]>} A promise that resolves with an array of `FileSystemFileEntry` objects.\n */\nconst readEntriesPromise = async directoryReader => {\n return await new Promise((resolve, reject) => {\n directoryReader.readEntries(resolve, reject);\n });\n};\n\n/**\n * Read all entries in a directory or sub-directory\n * by calling `readEntries` until it returns an empty array.\n *\n * @param {FileSystemDirectoryReader} directoryReader The directory reader to read entries from.\n * @returns {Promise<FileSystemFileEntry[]>} A promise that resolves with an array of `FileSystemFileEntry` objects.\n */\nconst readAllDirectoryEntries = async directoryReader => {\n const entries = [];\n let readEntries = await readEntriesPromise(directoryReader);\n\n while (readEntries.length > 0) {\n entries.push(...readEntries);\n readEntries = await readEntriesPromise(directoryReader);\n }\n\n return entries;\n};\n\n/**\n * Get a `File` object from a `FileSystemFileEntry` object.\n *\n * @param {FileSystemFileEntry} fileEntry The file entry to get a `File` object from.\n * @returns {Promise<File>} A promise that resolves with a `File` object.\n */\nconst getFileFromFileEntry = fileEntry => {\n return new Promise((resolve, reject) => {\n fileEntry.file(file => resolve(toFileWithPath(file, fileEntry.fullPath)), reject);\n });\n};\n\n/**\n * Get an array of `File` objects from a `DataTransferItemList` object.\n *\n * @param {DataTransferItemList} dataTransferItemList The item list to get an array of `File` objects from.\n * @returns {Promise<File[]>} A promise that resolves with an array of `File` objects.\n */\nconst getFilesFromDataTransferItemList = async dataTransferItemList => {\n const files = [];\n\n // Chromium browsers read only 100 files at a time as per the spec, so we need to use\n // BFS (Breadth-first search) to traverse the entire directory/file structure.\n // https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/webkitGetAsEntry#javascript_content\n const queue = [];\n\n for (const item of dataTransferItemList) {\n if (item.kind !== 'file') {\n // Ignore non-file items, such as links.\n continue;\n }\n\n // https://developer.mozilla.org/docs/Web/API/DataTransferItem/webkitGetAsEntry\n // This function is implemented as `webkitGetAsEntry()` in non-WebKit browsers\n // including Firefox at this time but it may be renamed to `getAsEntry()` in the future.\n const entry = item.getAsEntry ? item.getAsEntry() : item.webkitGetAsEntry();\n\n queue.push(entry);\n }\n\n while (queue.length > 0) {\n const entry = queue.shift();\n\n if (!entry) {\n continue;\n } else if (entry.isFile) {\n const file = await getFileFromFileEntry(entry);\n\n if (FILES_TO_IGNORE.indexOf(file.name) === -1) {\n files.push(file);\n }\n } else if (entry.isDirectory) {\n queue.push(...await readAllDirectoryEntries(entry.createReader()));\n }\n }\n\n return files;\n};\n\n/**\n * Get an array of `File` objects from a `FileList` object.\n *\n * @param {FileList} fileList The file list to get an array of `File` objects from.\n * @returns {Promise<File[]>} A promise that resolves with an array of `File` objects.\n */\nconst getFilesFromFileList = async fileList => {\n const files = [];\n\n for (const file of fileList) {\n if (FILES_TO_IGNORE.indexOf(file.name) === -1) {\n files.push(toFileWithPath(file));\n }\n }\n\n return files;\n};\n\n/**\n * Get an array of `File` objects from an event.\n * This function supports both `drop` and `change` events.\n *\n * @param {DragEvent | Event} evt The event to get an array of `File` objects from.\n * @returns {Promise<File[]>} A promise that resolves with an array of `File` objects.\n */\nexport const getFilesFromEvent = async evt => {\n if (evt.dataTransfer) {\n return evt.dataTransfer.items\n ? await getFilesFromDataTransferItemList(evt.dataTransfer.items)\n : await getFilesFromFileList(evt.dataTransfer.files);\n }\n\n return await getFilesFromFileList(evt.target.files);\n};\n"],"names":["Object","defineProperty","get","$862aa3736b0514bc$export$6ccd1735166caad9","set","s","enumerable","configurable","$f31161edf38949e9$var$COMMON_MIME_TYPES","Map","$f31161edf38949e9$var$FILES_TO_IGNORE","$f31161edf38949e9$var$toFileWithMimeType","file","name","hasExtension","lastIndexOf","type","extension","split","pop","toLowerCase","value","writable","$f31161edf38949e9$var$toFileWithPath","path","fileWithMimeType","webkitRelativePath","$f31161edf38949e9$var$readEntriesPromise","directoryReader","Promise","resolve","reject","readEntries","$f31161edf38949e9$var$readAllDirectoryEntries","entries","length","push","$f31161edf38949e9$var$getFileFromFileEntry","fileEntry","fullPath","$f31161edf38949e9$var$getFilesFromDataTransferItemList","dataTransferItemList","files","queue","item","kind","entry","getAsEntry","webkitGetAsEntry","shift","isFile","indexOf","isDirectory","createReader","$f31161edf38949e9$var$getFilesFromFileList","fileList","$f31161edf38949e9$export$6d52664cd15c442","evt","dataTransfer","items","target","$862aa3736b0514bc$var$COMPONENT_NAME","$862aa3736b0514bc$var$TOO_MANY_FILES","$862aa3736b0514bc$var$template","document","createElement","innerHTML","HTMLElement","fileInput","dropzoneEl","constructor","shadowRoot","attachShadow","mode","appendChild","content","cloneNode","getElementById","observedAttributes","attributeChangedCallback","oldValue","newValue","accept","disabled","removeAttribute","setAttribute","multiple","noKeyboard","connectedCallback","upgradeProperty","addEventListener","onFileInputChange","onDragEnter","onDragOver","onDragLeave","onDrop","onClick","onKeyUp","autoFocus","focus","disconnectedCallback","removeEventListener","getAttribute","hasAttribute","maxFiles","num","Number","Infinity","Math","floor","abs","maxSize","isNaN","minSize","noClick","noDrag","noStyle","handleFilesSelect","error","dispatchEvent","CustomEvent","bubbles","composed","detail","Event","preventDefault","dropEffect","classList","add","part","remove","click","key","Array","isArray","acceptedFiles","rejectedFiles","filesLength","errors","code","message","fileHasValidType","acceptedTypeSpecifiers","acceptedMimeTypesList","Set","map","v","trim","filter","Boolean","fileMimeType","baseMimeType","replace","validType","charAt","test","fileExceedsMaxSize","size","fileIsSmallerThanMinSize","defaultValue","openFileDialog","prop","prototype","hasOwnProperty","call","defineCustomElement","elementName","window","customElements","define","FilesDropzone"],"version":3,"file":"files-dropzone-defined.js.map"}
|
package/dist/files-dropzone.js
CHANGED
|
@@ -1,2 +1,69 @@
|
|
|
1
|
-
function e(e,t,i){if(!t.has(e))throw new TypeError("attempted to "+i+" private field on non-instance");return t.get(e)}function t(e,t){return t.get?t.get.call(e):t.value}function i(i,o){return t(i,e(i,o,"get"))}function o(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function n(e,t,i){o(e,t),t.set(e,i)}function s(e,t,i){if(t.set)t.set.call(e,i);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=i}}function a(t,i,o){return s(t,e(t,i,"set"),o),o}function r(e,t,i){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return i}function l(e,t){o(e,t),t.add(e)}function d(e,t=""){if(!t)return!0;const i=[...new Set(t.split(",").map((e=>e.trim())).filter(Boolean))],o=e.type,n=o.replace(/\/.*$/,"");for(const t of i)if("."===t.charAt(0)){if(-1!==e.name.toLowerCase().indexOf(t.toLowerCase(),e.name.length-t.length))return!0}else if(/\/\*$/.test(t)){if(n===t.replace(/\/.*$/,""))return!0}else if(o===t)return!0;return!1}const c=new Map([["aac","audio/aac"],["abw","application/x-abiword"],["arc","application/x-freearc"],["avif","image/avif"],["avi","video/x-msvideo"],["azw","application/vnd.amazon.ebook"],["bin","application/octet-stream"],["bmp","image/bmp"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["cda","application/x-cdf"],["csh","application/x-csh"],["css","text/css"],["csv","text/csv"],["doc","application/msword"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["eot","application/vnd.ms-fontobject"],["epub","application/epub+zip"],["gz","application/gzip"],["gif","image/gif"],["heic","image/heic"],["heif","image/heif"],["htm","text/html"],["html","text/html"],["ico","image/vnd.microsoft.icon"],["ics","text/calendar"],["jar","application/java-archive"],["jpeg","image/jpeg"],["jpg","image/jpeg"],["js","text/javascript"],["json","application/json"],["jsonld","application/ld+json"],["mid","audio/midi"],["midi","audio/midi"],["mjs","text/javascript"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mpeg","video/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["opus","audio/opus"],["otf","font/otf"],["png","image/png"],["pdf","application/pdf"],["php","application/x-httpd-php"],["ppt","application/vnd.ms-powerpoint"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["rar","application/vnd.rar"],["rtf","application/rtf"],["sh","application/x-sh"],["svg","image/svg+xml"],["swf","application/x-shockwave-flash"],["tar","application/x-tar"],["tif","image/tiff"],["tiff","image/tiff"],["ts","video/mp2t"],["ttf","font/ttf"],["txt","text/plain"],["vsd","application/vnd.visio"],["wav","audio/wav"],["weba","audio/webm"],["webm","video/webm"],["webp","image/webp"],["woff","font/woff"],["woff2","font/woff2"],["xhtml","application/xhtml+xml"],["xls","application/vnd.ms-excel"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xml","application/xml"],["xul","application/vnd.mozilla.xul+xml"],["zip","application/zip"],["7z","application/x-7z-compressed"],["mkv","video/x-matroska"],["mov","video/quicktime"],["msg","application/vnd.ms-outlook"]]),p=[".DS_Store","Thumbs.db"],h=(e,t)=>{const i=(e=>{const{name:t}=e;if(t&&-1!==t.lastIndexOf(".")&&!e.type){const i=t.split(".").pop().toLowerCase(),o=c.get(i);o&&Object.defineProperty(e,"type",{value:o,writable:!1,configurable:!1,enumerable:!0})}return e})(e);if("string"!=typeof i.path){const{webkitRelativePath:o}=e;Object.defineProperty(i,"path",{value:"string"==typeof t?t:o||e.name,writable:!1,configurable:!1,enumerable:!0})}return i},u=async e=>await new Promise(((t,i)=>{e.readEntries(t,i)})),m=async e=>{const t=[];let i=await u(e);for(;i.length>0;)t.push(...i),i=await u(e);return t},b=e=>new Promise(((t,i)=>{e.file((i=>t(h(i,e.fullPath))),i)})),f=async e=>{const t=[];for(const i of e)-1===p.indexOf(i.name)&&t.push(h(i));return t},v=async e=>e.dataTransfer?e.dataTransfer.items?await(async e=>{const t=[],i=[];for(const t of e){if("file"!==t.kind)continue;const e=t.getAsEntry?t.getAsEntry():t.webkitGetAsEntry();i.push(e)}for(;i.length>0;){const e=i.shift();if(e)if(e.isFile){const i=await b(e);-1===p.indexOf(i.name)&&t.push(i)}else e.isDirectory&&i.push(...await m(e.createReader()))}return t})(e.dataTransfer.items):await f(e.dataTransfer.files):await f(e.target.files),g="files-dropzone",w="TOO_MANY_FILES",x=document.createElement("template");x.innerHTML='\n <style>\n *,\n *::before,\n *::after {\n box-sizing: border-box;\n }\n\n :host([hidden]),\n [hidden] {\n display: none !important;\n }\n\n :host {\n --dropzone-border-width: 2px;\n --dropzone-border-style: dashed;\n --dropzone-border-radius: 0.25rem;\n --dropzone-border-color: #6c757d;\n --dropzone-border-color-dragover: #0d6efd;\n --dropzone-background-color: #ffffff;\n --dropzone-background-color-dragover: #f4f4f5;\n --dropzone-body-color: #3f3f46;\n --dropzone-body-color-dragover: var(--dropzone-body-color);\n --dropzone-focus-shadow-rgb: 49,132,253;\n --transition-duration: 0.2s;\n\n display: block;\n }\n\n :host(:not([no-style])) .dropzone {\n border: var(--dropzone-border-width) var(--dropzone-border-style) var(--dropzone-border-color);\n border-radius: var(--dropzone-border-radius);\n padding: 3rem 1rem;\n overflow: hidden;\n background-color: var(--dropzone-background-color);\n color: var(--dropzone-body-color);\n text-align: center;\n cursor: pointer;\n transition: border var(--transition-duration) ease-in-out, background-color var(--transition-duration) ease-in-out, color var(--transition-duration) ease-in-out, box-shadow var(--transition-duration) ease-in-out;\n }\n\n :host(:not([no-style])[no-click]) .dropzone {\n cursor: default;\n }\n\n :host(:not([no-style])[disabled]) .dropzone {\n opacity: 0.8;\n cursor: not-allowed;\n }\n\n :host(:not([no-style]):not([disabled])) .dropzone--dragover {\n border-color: var(--dropzone-border-color-dragover);\n background-color: var(--dropzone-background-color-dragover);\n color: var(--dropzone-body-color-dragover);\n }\n\n :host(:not([no-style]):not([disabled])) .dropzone:focus-visible {\n outline: none;\n box-shadow: 0 0 0 0.25rem rgba(var(--dropzone-focus-shadow-rgb), 0.5);\n }\n </style>\n\n <input type="file" id="fileInput" hidden>\n\n <div part="dropzone" class="dropzone" id="dropzoneEl" tabindex="0" role="presentation">\n <slot>Drag \'n\' drop files here, or click to select files</slot>\n </div>\n';var y=new WeakMap,z=new WeakMap,E=new WeakMap,k=new WeakMap,A=new WeakMap,L=new WeakMap,F=new WeakMap,j=new WeakMap,S=new WeakMap,C=new WeakSet,T=new WeakSet;class M extends HTMLElement{static get observedAttributes(){return["accept","disabled","multiple","no-keyboard"]}attributeChangedCallback(e,t,o){"accept"===e&&t!==o&&i(this,y)&&(i(this,y).accept=this.accept),"disabled"===e&&t!==o&&i(this,y)&&(i(this,y).disabled=this.disabled,this.disabled?i(this,z).removeAttribute("tabindex"):i(this,z).setAttribute("tabindex","0")),"multiple"===e&&t!==o&&i(this,y)&&(i(this,y).multiple=this.multiple),"no-keyboard"===e&&t!==o&&i(this,z)&&(this.noKeyboard?i(this,z).removeAttribute("tabindex"):i(this,z).setAttribute("tabindex","0"))}connectedCallback(){r(this,T,O).call(this,"accept"),r(this,T,O).call(this,"disabled"),r(this,T,O).call(this,"maxFiles"),r(this,T,O).call(this,"maxSize"),r(this,T,O).call(this,"minSize"),r(this,T,O).call(this,"multiple"),r(this,T,O).call(this,"noClick"),r(this,T,O).call(this,"noDrag"),r(this,T,O).call(this,"noKeyboard"),r(this,T,O).call(this,"autoFocus"),r(this,T,O).call(this,"noStyle"),i(this,y).addEventListener("change",i(this,E)),i(this,z).addEventListener("dragenter",i(this,k)),i(this,z).addEventListener("dragover",i(this,A)),i(this,z).addEventListener("dragleave",i(this,L)),i(this,z).addEventListener("drop",i(this,F)),i(this,z).addEventListener("click",i(this,j)),i(this,z).addEventListener("keyup",i(this,S)),this.autoFocus&&i(this,z).focus()}disconnectedCallback(){i(this,y).removeEventListener("change",i(this,E)),i(this,z).removeEventListener("dragenter",i(this,k)),i(this,z).removeEventListener("dragover",i(this,A)),i(this,z).removeEventListener("dragleave",i(this,L)),i(this,z).removeEventListener("drop",i(this,F)),i(this,z).removeEventListener("click",i(this,j)),i(this,z).removeEventListener("keyup",i(this,S))}get accept(){return this.getAttribute("accept")}set accept(e){this.setAttribute("accept",e)}get disabled(){return this.hasAttribute("disabled")}set disabled(e){e?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get maxFiles(){const e=Number(this.getAttribute("max-files"))||0;return e<=0?1/0:Math.floor(Math.abs(e))}set maxFiles(e){this.setAttribute("max-files",e)}get maxSize(){const e=this.getAttribute("max-size");if(null===e)return 1/0;const t=Number(e);return Number.isNaN(t)?1/0:t}set maxSize(e){this.setAttribute("max-size",e)}get minSize(){const e=this.getAttribute("min-size");if(null===e)return 0;const t=Number(e);return Number.isNaN(t)?0:t}set minSize(e){this.setAttribute("min-size",e)}get multiple(){return this.hasAttribute("multiple")}set multiple(e){e?this.setAttribute("multiple",""):this.removeAttribute("multiple")}get noClick(){return this.hasAttribute("no-click")}set noClick(e){e?this.setAttribute("no-click",""):this.removeAttribute("no-click")}get noDrag(){return this.hasAttribute("no-drag")}set noDrag(e){e?this.setAttribute("no-drag",""):this.removeAttribute("no-drag")}get noKeyboard(){return this.hasAttribute("no-keyboard")}set noKeyboard(e){e?this.setAttribute("no-keyboard",""):this.removeAttribute("no-keyboard")}get autoFocus(){return this.hasAttribute("auto-focus")}set autoFocus(e){e?this.setAttribute("auto-focus",""):this.removeAttribute("auto-focus")}get noStyle(){return this.hasAttribute("no-style")}set noStyle(e){e?this.setAttribute("no-style",""):this.removeAttribute("no-style")}openFileDialog(){this.disabled||i(this,y).click()}static defineCustomElement(e=g){"undefined"==typeof window||window.customElements.get(e)||window.customElements.define(e,M)}constructor(){super(),l(this,C),l(this,T),n(this,y,{writable:!0,value:void 0}),n(this,z,{writable:!0,value:void 0}),n(this,E,{writable:!0,value:async e=>{try{r(this,C,$).call(this,await v(e))}catch(e){this.dispatchEvent(new CustomEvent(`${g}-error`,{bubbles:!0,composed:!0,detail:{error:e}}))}}}),n(this,k,{writable:!0,value:()=>{this.disabled||this.noDrag||this.dispatchEvent(new Event(`${g}-dragenter`,{bubbles:!0,composed:!0}))}}),n(this,A,{writable:!0,value:e=>{e.preventDefault(),this.disabled||this.noDrag?e.dataTransfer.dropEffect="none":(e.dataTransfer.dropEffect="copy",i(this,z).classList.add("dropzone--dragover"),i(this,z).part.add("dropzone--dragover"),this.dispatchEvent(new Event(`${g}-dragover`,{bubbles:!0,composed:!0})))}}),n(this,L,{writable:!0,value:()=>{this.disabled||this.noDrag||(i(this,z).classList.remove("dropzone--dragover"),i(this,z).part.remove("dropzone--dragover"),this.dispatchEvent(new Event(`${g}-dragleave`,{bubbles:!0,composed:!0})))}}),n(this,F,{writable:!0,value:async e=>{if(!this.disabled&&!this.noDrag){e.preventDefault(),i(this,z).classList.remove("dropzone--dragover"),i(this,z).part.remove("dropzone--dragover");try{r(this,C,$).call(this,await v(e))}catch(e){this.dispatchEvent(new CustomEvent(`${g}-error`,{bubbles:!0,composed:!0,detail:{error:e}}))}}}}),n(this,j,{writable:!0,value:()=>{this.disabled||this.noClick||i(this,y).click()}}),n(this,S,{writable:!0,value:e=>{this.disabled||this.noKeyboard||" "!==e.key&&"Enter"!==e.key||i(this,y).click()}}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(x.content.cloneNode(!0))),a(this,y,this.shadowRoot.getElementById("fileInput")),a(this,z,this.shadowRoot.getElementById("dropzoneEl"))}}function $(e){if(!Array.isArray(e)||!e.length)return;const t=[],o=[],n=e.length;if(!this.multiple&&n>1)for(const t of e)o.push({file:t,errors:[{code:w,message:"Too many files selected. Only 1 file is allowed."}]});else if(this.multiple&&n>this.maxFiles)for(const t of e)o.push({file:t,errors:[{code:w,message:`Too many files selected. Only ${this.maxFiles} ${this.maxFiles>1?"files are":"file is"} allowed.`}]});else for(const i of e){const e=d(i,this.accept),n=i.size>this.maxSize,s=i.size<this.minSize;if(!e||n||s){const t=[];e||t.push({code:"INVALID_MIME_TYPE",message:`File type "${i.type}" is not accepted.`}),n&&t.push({code:"FILE_TOO_LARGE",message:`File size ${i.size} exceeds the maximum size of ${this.maxSize}.`}),s&&t.push({code:"FILE_TOO_SMALL",message:`File size ${i.size} is smaller than the minimum size of ${this.minSize}.`}),o.push({file:i,errors:t})}else t.push(i)}this.dispatchEvent(new CustomEvent(`${g}-drop`,{bubbles:!0,composed:!0,detail:{acceptedFiles:t,rejectedFiles:o}})),t.length>0&&this.dispatchEvent(new CustomEvent(`${g}-drop-accepted`,{bubbles:!0,composed:!0,detail:{acceptedFiles:t}})),o.length>0&&this.dispatchEvent(new CustomEvent(`${g}-drop-rejected`,{bubbles:!0,composed:!0,detail:{rejectedFiles:o}})),i(this,y).value=i(this,y).defaultValue}function O(e){if(Object.prototype.hasOwnProperty.call(this,e)){const t=this[e];delete this[e],this[e]=t}}export{M as FilesDropzone};
|
|
1
|
+
let e=new Map([["aac","audio/aac"],["abw","application/x-abiword"],["arc","application/x-freearc"],["avif","image/avif"],["avi","video/x-msvideo"],["azw","application/vnd.amazon.ebook"],["bin","application/octet-stream"],["bmp","image/bmp"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["cda","application/x-cdf"],["csh","application/x-csh"],["css","text/css"],["csv","text/csv"],["doc","application/msword"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["eot","application/vnd.ms-fontobject"],["epub","application/epub+zip"],["gz","application/gzip"],["gif","image/gif"],["heic","image/heic"],["heif","image/heif"],["htm","text/html"],["html","text/html"],["ico","image/vnd.microsoft.icon"],["ics","text/calendar"],["jar","application/java-archive"],["jpeg","image/jpeg"],["jpg","image/jpeg"],["jxl","image/jxl"],["js","text/javascript"],["json","application/json"],["jsonld","application/ld+json"],["mid","audio/midi"],["midi","audio/midi"],["mjs","text/javascript"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mpeg","video/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["opus","audio/opus"],["otf","font/otf"],["png","image/png"],["pdf","application/pdf"],["php","application/x-httpd-php"],["ppt","application/vnd.ms-powerpoint"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["rar","application/vnd.rar"],["rtf","application/rtf"],["sh","application/x-sh"],["svg","image/svg+xml"],["swf","application/x-shockwave-flash"],["tar","application/x-tar"],["tif","image/tiff"],["tiff","image/tiff"],["ts","video/mp2t"],["ttf","font/ttf"],["txt","text/plain"],["vsd","application/vnd.visio"],["wav","audio/wav"],["weba","audio/webm"],["webm","video/webm"],["webp","image/webp"],["woff","font/woff"],["woff2","font/woff2"],["xhtml","application/xhtml+xml"],["xls","application/vnd.ms-excel"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xml","application/xml"],["xul","application/vnd.mozilla.xul+xml"],["zip","application/zip"],["7z","application/x-7z-compressed"],["mkv","video/x-matroska"],["mov","video/quicktime"],["msg","application/vnd.ms-outlook"]]),t=[".DS_Store","Thumbs.db"],o=t=>{let{name:o}=t,i=o&&-1!==o.lastIndexOf(".");if(i&&!t.type){let i=o.split(".").pop().toLowerCase(),r=e.get(i);r&&Object.defineProperty(t,"type",{value:r,writable:!1,configurable:!1,enumerable:!0})}return t},i=(e,t)=>{let i=o(e);if("string"!=typeof i.path){let{webkitRelativePath:o}=e;Object.defineProperty(i,"path",{value:"string"==typeof t?t:o||e.name,writable:!1,configurable:!1,enumerable:!0})}return i},r=async e=>await new Promise((t,o)=>{e.readEntries(t,o)}),a=async e=>{let t=[],o=await r(e);for(;o.length>0;)t.push(...o),o=await r(e);return t},s=e=>new Promise((t,o)=>{e.file(o=>t(i(o,e.fullPath)),o)}),n=async e=>{let o=[],i=[];for(let t of e){if("file"!==t.kind)continue;let e=t.getAsEntry?t.getAsEntry():t.webkitGetAsEntry();i.push(e)}for(;i.length>0;){let e=i.shift();if(e){if(e.isFile){let i=await s(e);-1===t.indexOf(i.name)&&o.push(i)}else e.isDirectory&&i.push(...await a(e.createReader()))}}return o},d=async e=>{let o=[];for(let r of e)-1===t.indexOf(r.name)&&o.push(i(r));return o},l=async e=>e.dataTransfer?e.dataTransfer.items?await n(e.dataTransfer.items):await d(e.dataTransfer.files):await d(e.target.files),p="files-dropzone",c="TOO_MANY_FILES",h=document.createElement("template");h.innerHTML=`
|
|
2
|
+
<style>
|
|
3
|
+
*,
|
|
4
|
+
*::before,
|
|
5
|
+
*::after {
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
:host([hidden]),
|
|
10
|
+
[hidden] {
|
|
11
|
+
display: none !important;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
:host {
|
|
15
|
+
--dropzone-border-width: 2px;
|
|
16
|
+
--dropzone-border-style: dashed;
|
|
17
|
+
--dropzone-border-radius: 0.25rem;
|
|
18
|
+
--dropzone-border-color: #6c757d;
|
|
19
|
+
--dropzone-border-color-dragover: #0d6efd;
|
|
20
|
+
--dropzone-background-color: #ffffff;
|
|
21
|
+
--dropzone-background-color-dragover: #f4f4f5;
|
|
22
|
+
--dropzone-body-color: #3f3f46;
|
|
23
|
+
--dropzone-body-color-dragover: var(--dropzone-body-color);
|
|
24
|
+
--dropzone-focus-shadow-rgb: 49,132,253;
|
|
25
|
+
--transition-duration: 0.2s;
|
|
26
|
+
|
|
27
|
+
display: block;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
:host(:not([no-style])) .dropzone {
|
|
31
|
+
border: var(--dropzone-border-width) var(--dropzone-border-style) var(--dropzone-border-color);
|
|
32
|
+
border-radius: var(--dropzone-border-radius);
|
|
33
|
+
padding: 3rem 1rem;
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
background-color: var(--dropzone-background-color);
|
|
36
|
+
color: var(--dropzone-body-color);
|
|
37
|
+
text-align: center;
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
transition: border var(--transition-duration) ease-in-out, background-color var(--transition-duration) ease-in-out, color var(--transition-duration) ease-in-out, box-shadow var(--transition-duration) ease-in-out;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
:host(:not([no-style])[no-click]) .dropzone {
|
|
43
|
+
cursor: default;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
:host(:not([no-style])[disabled]) .dropzone {
|
|
47
|
+
opacity: 0.8;
|
|
48
|
+
cursor: not-allowed;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
:host(:not([no-style]):not([disabled])) .dropzone--dragover {
|
|
52
|
+
border-color: var(--dropzone-border-color-dragover);
|
|
53
|
+
background-color: var(--dropzone-background-color-dragover);
|
|
54
|
+
color: var(--dropzone-body-color-dragover);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
:host(:not([no-style]):not([disabled])) .dropzone:focus-visible {
|
|
58
|
+
outline: none;
|
|
59
|
+
box-shadow: 0 0 0 0.25rem rgba(var(--dropzone-focus-shadow-rgb), 0.5);
|
|
60
|
+
}
|
|
61
|
+
</style>
|
|
62
|
+
|
|
63
|
+
<input type="file" id="fileInput" hidden>
|
|
64
|
+
|
|
65
|
+
<div part="dropzone" class="dropzone" id="dropzoneEl" tabindex="0" role="presentation">
|
|
66
|
+
<slot>Drag 'n' drop files here, or click to select files</slot>
|
|
67
|
+
</div>
|
|
68
|
+
`;class u extends HTMLElement{#e;#t;constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(h.content.cloneNode(!0))),this.#e=this.shadowRoot.getElementById("fileInput"),this.#t=this.shadowRoot.getElementById("dropzoneEl")}static get observedAttributes(){return["accept","disabled","multiple","no-keyboard"]}attributeChangedCallback(e,t,o){"accept"===e&&t!==o&&this.#e&&(this.#e.accept=this.accept),"disabled"===e&&t!==o&&this.#e&&(this.#e.disabled=this.disabled,this.disabled?this.#t.removeAttribute("tabindex"):this.#t.setAttribute("tabindex","0")),"multiple"===e&&t!==o&&this.#e&&(this.#e.multiple=this.multiple),"no-keyboard"===e&&t!==o&&this.#t&&(this.noKeyboard?this.#t.removeAttribute("tabindex"):this.#t.setAttribute("tabindex","0"))}connectedCallback(){this.#o("accept"),this.#o("disabled"),this.#o("maxFiles"),this.#o("maxSize"),this.#o("minSize"),this.#o("multiple"),this.#o("noClick"),this.#o("noDrag"),this.#o("noKeyboard"),this.#o("autoFocus"),this.#o("noStyle"),this.#e.addEventListener("change",this.#i),this.#t.addEventListener("dragenter",this.#r),this.#t.addEventListener("dragover",this.#a),this.#t.addEventListener("dragleave",this.#s),this.#t.addEventListener("drop",this.#n),this.#t.addEventListener("click",this.#d),this.#t.addEventListener("keyup",this.#l),this.autoFocus&&this.#t.focus()}disconnectedCallback(){this.#e.removeEventListener("change",this.#i),this.#t.removeEventListener("dragenter",this.#r),this.#t.removeEventListener("dragover",this.#a),this.#t.removeEventListener("dragleave",this.#s),this.#t.removeEventListener("drop",this.#n),this.#t.removeEventListener("click",this.#d),this.#t.removeEventListener("keyup",this.#l)}get accept(){return this.getAttribute("accept")}set accept(e){this.setAttribute("accept",e)}get disabled(){return this.hasAttribute("disabled")}set disabled(e){e?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get maxFiles(){let e=Number(this.getAttribute("max-files"))||0;return e<=0?1/0:Math.floor(Math.abs(e))}set maxFiles(e){this.setAttribute("max-files",e)}get maxSize(){let e=this.getAttribute("max-size");if(null===e)return 1/0;let t=Number(e);return Number.isNaN(t)?1/0:t}set maxSize(e){this.setAttribute("max-size",e)}get minSize(){let e=this.getAttribute("min-size");if(null===e)return 0;let t=Number(e);return Number.isNaN(t)?0:t}set minSize(e){this.setAttribute("min-size",e)}get multiple(){return this.hasAttribute("multiple")}set multiple(e){e?this.setAttribute("multiple",""):this.removeAttribute("multiple")}get noClick(){return this.hasAttribute("no-click")}set noClick(e){e?this.setAttribute("no-click",""):this.removeAttribute("no-click")}get noDrag(){return this.hasAttribute("no-drag")}set noDrag(e){e?this.setAttribute("no-drag",""):this.removeAttribute("no-drag")}get noKeyboard(){return this.hasAttribute("no-keyboard")}set noKeyboard(e){e?this.setAttribute("no-keyboard",""):this.removeAttribute("no-keyboard")}get autoFocus(){return this.hasAttribute("auto-focus")}set autoFocus(e){e?this.setAttribute("auto-focus",""):this.removeAttribute("auto-focus")}get noStyle(){return this.hasAttribute("no-style")}set noStyle(e){e?this.setAttribute("no-style",""):this.removeAttribute("no-style")}#i=async e=>{try{this.#p(await l(e))}catch(e){this.dispatchEvent(new CustomEvent(`${p}-error`,{bubbles:!0,composed:!0,detail:{error:e}}))}};#r=()=>{this.disabled||this.noDrag||this.dispatchEvent(new Event(`${p}-dragenter`,{bubbles:!0,composed:!0}))};#a=e=>{if(e.preventDefault(),this.disabled||this.noDrag){e.dataTransfer.dropEffect="none";return}e.dataTransfer.dropEffect="copy",this.#t.classList.add("dropzone--dragover"),this.#t.part.add("dropzone--dragover"),this.dispatchEvent(new Event(`${p}-dragover`,{bubbles:!0,composed:!0}))};#s=()=>{this.disabled||this.noDrag||(this.#t.classList.remove("dropzone--dragover"),this.#t.part.remove("dropzone--dragover"),this.dispatchEvent(new Event(`${p}-dragleave`,{bubbles:!0,composed:!0})))};#n=async e=>{if(!this.disabled&&!this.noDrag){e.preventDefault(),this.#t.classList.remove("dropzone--dragover"),this.#t.part.remove("dropzone--dragover");try{this.#p(await l(e))}catch(e){this.dispatchEvent(new CustomEvent(`${p}-error`,{bubbles:!0,composed:!0,detail:{error:e}}))}}};#d=()=>{this.disabled||this.noClick||this.#e.click()};#l=e=>{this.disabled||this.noKeyboard||" "!==e.key&&"Enter"!==e.key||this.#e.click()};#p(e){if(!Array.isArray(e)||!e.length)return;let t=[],o=[],i=e.length;if(!this.multiple&&i>1)for(let t of e)o.push({file:t,errors:[{code:c,message:"Too many files selected. Only 1 file is allowed."}]});else if(this.multiple&&i>this.maxFiles)for(let t of e)o.push({file:t,errors:[{code:c,message:`Too many files selected. Only ${this.maxFiles} ${this.maxFiles>1?"files are":"file is"} allowed.`}]});else for(let i of e){let e=function(e,t=""){if(!t)return!0;let o=[...new Set(t.split(",").map(e=>e.trim()).filter(Boolean))],i=e.type,r=i.replace(/\/.*$/,"");for(let t of o)if("."===t.charAt(0)){if(-1!==e.name.toLowerCase().indexOf(t.toLowerCase(),e.name.length-t.length))return!0}else if(/\/\*$/.test(t)){if(r===t.replace(/\/.*$/,""))return!0}else if(i===t)return!0;return!1}(i,this.accept),r=i.size>this.maxSize,a=i.size<this.minSize;if(!e||r||a){let t=[];e||t.push({code:"INVALID_MIME_TYPE",message:`File type "${i.type}" is not accepted.`}),r&&t.push({code:"FILE_TOO_LARGE",message:`File size ${i.size} exceeds the maximum size of ${this.maxSize}.`}),a&&t.push({code:"FILE_TOO_SMALL",message:`File size ${i.size} is smaller than the minimum size of ${this.minSize}.`}),o.push({file:i,errors:t})}else t.push(i)}this.dispatchEvent(new CustomEvent(`${p}-drop`,{bubbles:!0,composed:!0,detail:{acceptedFiles:t,rejectedFiles:o}})),t.length>0&&this.dispatchEvent(new CustomEvent(`${p}-drop-accepted`,{bubbles:!0,composed:!0,detail:{acceptedFiles:t}})),o.length>0&&this.dispatchEvent(new CustomEvent(`${p}-drop-rejected`,{bubbles:!0,composed:!0,detail:{rejectedFiles:o}})),this.#e.value=this.#e.defaultValue}openFileDialog(){this.disabled||this.#e.click()}#o(e){if(Object.prototype.hasOwnProperty.call(this,e)){let t=this[e];delete this[e],this[e]=t}}static defineCustomElement(e=p){"undefined"==typeof window||window.customElements.get(e)||window.customElements.define(e,u)}}export{u as FilesDropzone};
|
|
2
69
|
//# sourceMappingURL=files-dropzone.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAe,SAAAA,EAAsCC,EAAUC,EAAYC,GACzE,IAAKD,EAAWE,IAAIH,GAClB,MAAM,IAAII,UAAU,gBAAkBF,EAAS,kCAEjD,OAAOD,EAAWI,IAAIL,EACxB,CCLe,SAAAM,EAAkCN,EAAUO,GACzD,OAAIA,EAAWF,IACNE,EAAWF,IAAIG,KAAKR,GAEtBO,EAAWE,KACpB,CCFe,SAAAC,EAA+BV,EAAUC,GAEtD,OAAOK,EAAwBN,EADdD,EAA4BC,EAAUC,EAAY,OAErE,CCNe,SAAAU,EAAoCC,EAAKC,GACtD,GAAIA,EAAkBV,IAAIS,GACxB,MAAM,IAAIR,UAAU,i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nB,GAAU0F,YAC1C,CAgBA,SAAA/D,EAAiBgE,GACf,GAAIxI,OAAOyI,UAAUC,eAAezL,KAAK+G,KAAMwE,GAAO,CACpD,MAAMtL,EAAQ8G,KAAKwE,UACZxE,KAAKwE,GACZxE,KAAKwE,GAAQtL,CACf,CACF,Q","sources":["node_modules/@swc/helpers/src/_class_extract_field_descriptor.mjs","node_modules/@swc/helpers/src/_class_apply_descriptor_get.mjs","node_modules/@swc/helpers/src/_class_private_field_get.mjs","node_modules/@swc/helpers/src/_check_private_redeclaration.mjs","node_modules/@swc/helpers/src/_class_private_field_init.mjs","node_modules/@swc/helpers/src/_class_apply_descriptor_set.mjs","node_modules/@swc/helpers/src/_class_private_field_set.mjs","node_modules/@swc/helpers/src/_class_private_method_get.mjs","node_modules/@swc/helpers/src/_class_private_method_init.mjs","src/utils/is-valid-file.js","src/utils/files-selector.js","src/files-dropzone.js"],"sourcesContent":["export default function _classExtractFieldDescriptor(receiver, privateMap, action) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to \" + action + \" private field on non-instance\");\n }\n return privateMap.get(receiver);\n}\n","export default function _classApplyDescriptorGet(receiver, descriptor) {\n if (descriptor.get) {\n return descriptor.get.call(receiver);\n }\n return descriptor.value;\n}\n","import classExtractFieldDescriptor from './_class_extract_field_descriptor.mjs';\nimport classApplyDescriptorGet from './_class_apply_descriptor_get.mjs';\n\nexport default function _classPrivateFieldGet(receiver, privateMap) {\n var descriptor = classExtractFieldDescriptor(receiver, privateMap, \"get\");\n return classApplyDescriptorGet(receiver, descriptor);\n}\n","export default function _checkPrivateRedeclaration(obj, privateCollection) {\n if (privateCollection.has(obj)) {\n throw new TypeError(\"Cannot initialize the same private elements twice on an object\");\n }\n}\n","import _checkPrivateRedeclaration from \"./_check_private_redeclaration.mjs\";\n\nexport default function _classPrivateFieldInit(obj, privateMap, value) {\n _checkPrivateRedeclaration(obj, privateMap);\n privateMap.set(obj, value);\n}\n","export default function _classApplyDescriptorSet(receiver, descriptor, value) {\n if (descriptor.set) {\n descriptor.set.call(receiver, value);\n } else {\n if (!descriptor.writable) {\n // This should only throw in strict mode, but class bodies are\n // always strict and private fields can only be used inside\n // class bodies.\n throw new TypeError(\"attempted to set read only private field\");\n }\n descriptor.value = value;\n }\n}\n","import classExtractFieldDescriptor from './_class_extract_field_descriptor.mjs';\nimport classApplyDescriptorSet from './_class_apply_descriptor_set.mjs';\n\nexport default function _classPrivateFieldSet(receiver, privateMap, value) {\n var descriptor = classExtractFieldDescriptor(receiver, privateMap, \"set\");\n classApplyDescriptorSet(receiver, descriptor, value);\n return value;\n}\n","export default function _classPrivateMethodGet(receiver, privateSet, fn) {\n if (!privateSet.has(receiver)) {\n throw new TypeError(\"attempted to get private field on non-instance\");\n }\n\n return fn;\n}\n","import _checkPrivateRedeclaration from \"./_check_private_redeclaration.mjs\";\n\nexport default function _classPrivateMethodInit(obj, privateSet) {\n _checkPrivateRedeclaration(obj, privateSet);\n privateSet.add(obj);\n}\n","/**\n * Checks if a file is valid based on the accepted file type specifiers.\n *\n * @param {File} file The File object to validate.\n * @param {String} [acceptedTypeSpecifiers=''] The accepted file type specifiers.\n * @returns {Boolean} True if the file is valid, false otherwise.\n */\nexport function isValidFile(file, acceptedTypeSpecifiers = '') {\n if (!acceptedTypeSpecifiers) {\n return true;\n }\n\n const acceptedMimeTypesList = [\n ...new Set(acceptedTypeSpecifiers.split(',').map(v => v.trim()).filter(Boolean))\n ];\n\n const fileMimeType = file.type;\n const baseMimeType = fileMimeType.replace(/\\/.*$/, '');\n\n for (const validType of acceptedMimeTypesList) {\n if (validType.charAt(0) === '.') {\n if (file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.length - validType.length) !== -1) {\n return true;\n }\n } else if (/\\/\\*$/.test(validType)) {\n // Check for mime type that looks like \"image/*\" or similar.\n if (baseMimeType === validType.replace(/\\/.*$/, '')) {\n return true;\n }\n } else {\n if (fileMimeType === validType) {\n return true;\n }\n }\n }\n\n return false;\n}\n","const COMMON_MIME_TYPES = new Map([\n // https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types\n ['aac', 'audio/aac'],\n ['abw', 'application/x-abiword'],\n ['arc', 'application/x-freearc'],\n ['avif', 'image/avif'],\n ['avi', 'video/x-msvideo'],\n ['azw', 'application/vnd.amazon.ebook'],\n ['bin', 'application/octet-stream'],\n ['bmp', 'image/bmp'],\n ['bz', 'application/x-bzip'],\n ['bz2', 'application/x-bzip2'],\n ['cda', 'application/x-cdf'],\n ['csh', 'application/x-csh'],\n ['css', 'text/css'],\n ['csv', 'text/csv'],\n ['doc', 'application/msword'],\n ['docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],\n ['eot', 'application/vnd.ms-fontobject'],\n ['epub', 'application/epub+zip'],\n ['gz', 'application/gzip'],\n ['gif', 'image/gif'],\n ['heic', 'image/heic'],\n ['heif', 'image/heif'],\n ['htm', 'text/html'],\n ['html', 'text/html'],\n ['ico', 'image/vnd.microsoft.icon'],\n ['ics', 'text/calendar'],\n ['jar', 'application/java-archive'],\n ['jpeg', 'image/jpeg'],\n ['jpg', 'image/jpeg'],\n ['js', 'text/javascript'],\n ['json', 'application/json'],\n ['jsonld', 'application/ld+json'],\n ['mid', 'audio/midi'],\n ['midi', 'audio/midi'],\n ['mjs', 'text/javascript'],\n ['mp3', 'audio/mpeg'],\n ['mp4', 'video/mp4'],\n ['mpeg', 'video/mpeg'],\n ['mpkg', 'application/vnd.apple.installer+xml'],\n ['odp', 'application/vnd.oasis.opendocument.presentation'],\n ['ods', 'application/vnd.oasis.opendocument.spreadsheet'],\n ['odt', 'application/vnd.oasis.opendocument.text'],\n ['oga', 'audio/ogg'],\n ['ogv', 'video/ogg'],\n ['ogx', 'application/ogg'],\n ['opus', 'audio/opus'],\n ['otf', 'font/otf'],\n ['png', 'image/png'],\n ['pdf', 'application/pdf'],\n ['php', 'application/x-httpd-php'],\n ['ppt', 'application/vnd.ms-powerpoint'],\n ['pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'],\n ['rar', 'application/vnd.rar'],\n ['rtf', 'application/rtf'],\n ['sh', 'application/x-sh'],\n ['svg', 'image/svg+xml'],\n ['swf', 'application/x-shockwave-flash'],\n ['tar', 'application/x-tar'],\n ['tif', 'image/tiff'],\n ['tiff', 'image/tiff'],\n ['ts', 'video/mp2t'],\n ['ttf', 'font/ttf'],\n ['txt', 'text/plain'],\n ['vsd', 'application/vnd.visio'],\n ['wav', 'audio/wav'],\n ['weba', 'audio/webm'],\n ['webm', 'video/webm'],\n ['webp', 'image/webp'],\n ['woff', 'font/woff'],\n ['woff2', 'font/woff2'],\n ['xhtml', 'application/xhtml+xml'],\n ['xls', 'application/vnd.ms-excel'],\n ['xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],\n ['xml', 'application/xml'],\n ['xul', 'application/vnd.mozilla.xul+xml'],\n ['zip', 'application/zip'],\n ['7z', 'application/x-7z-compressed'],\n\n // Others\n ['mkv', 'video/x-matroska'],\n ['mov', 'video/quicktime'],\n ['msg', 'application/vnd.ms-outlook']\n]);\n\nconst FILES_TO_IGNORE = [\n // Thumbnail cache files for macOS and Windows\n '.DS_Store', // macOs\n 'Thumbs.db' // Windows\n];\n\n/**\n * Adds a `type` property to the file object if it doesn't have one and the file has an extension.\n * This is needed because Firefox doesn't add a type property to files dragged from the desktop.\n * @bug https://bugzilla.mozilla.org/show_bug.cgi?id=1424689\n *\n * @param {File} file The file object to add the type property to.\n * @returns {File} The file object with the type property added.\n */\nconst toFileWithMimeType = file => {\n const { name } = file;\n const hasExtension = name && name.lastIndexOf('.') !== -1;\n\n if (hasExtension && !file.type) {\n const extension = name.split('.').pop().toLowerCase();\n const type = COMMON_MIME_TYPES.get(extension);\n\n if (type) {\n Object.defineProperty(file, 'type', {\n value: type,\n writable: false,\n configurable: false,\n enumerable: true\n });\n }\n }\n\n return file;\n};\n\n/**\n * Adds a `path` property to the file object if it doesn't have one.\n * If `path` is not provided, the `webkitRelativePath` property of the file will be used\n * or the file's name if `webkitRelativePath` is not available.\n *\n * @param {File} file The file object to add the path property to.\n * @param {String} [path] The path to set on the file object.\n * @returns {File} The file object with the path property added.\n */\nconst toFileWithPath = (file, path) => {\n const fileWithMimeType = toFileWithMimeType(file);\n\n if (typeof fileWithMimeType.path !== 'string') {\n const { webkitRelativePath } = file;\n\n Object.defineProperty(fileWithMimeType, 'path', {\n value: typeof path === 'string' ? path : webkitRelativePath || file.name,\n writable: false,\n configurable: false,\n enumerable: true\n });\n }\n\n return fileWithMimeType;\n};\n\n/**\n * Wrap `FileSystemDirectoryReader.readEntries` in a promise to make working with read entries easier.\n * https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryReader/readEntries\n *\n * @param {FileSystemDirectoryReader} directoryReader The directory reader to read entries from.\n * @returns {Promise<FileSystemFileEntry[]>} A promise that resolves with an array of `FileSystemFileEntry` objects.\n */\nconst readEntriesPromise = async directoryReader => {\n return await new Promise((resolve, reject) => {\n directoryReader.readEntries(resolve, reject);\n });\n};\n\n/**\n * Read all entries in a directory or sub-directory\n * by calling `readEntries` until it returns an empty array.\n *\n * @param {FileSystemDirectoryReader} directoryReader The directory reader to read entries from.\n * @returns {Promise<FileSystemFileEntry[]>} A promise that resolves with an array of `FileSystemFileEntry` objects.\n */\nconst readAllDirectoryEntries = async directoryReader => {\n const entries = [];\n let readEntries = await readEntriesPromise(directoryReader);\n\n while (readEntries.length > 0) {\n entries.push(...readEntries);\n readEntries = await readEntriesPromise(directoryReader);\n }\n\n return entries;\n};\n\n/**\n * Get a `File` object from a `FileSystemFileEntry` object.\n *\n * @param {FileSystemFileEntry} fileEntry The file entry to get a `File` object from.\n * @returns {Promise<File>} A promise that resolves with a `File` object.\n */\nconst getFileFromFileEntry = fileEntry => {\n return new Promise((resolve, reject) => {\n fileEntry.file(file => resolve(toFileWithPath(file, fileEntry.fullPath)), reject);\n });\n};\n\n/**\n * Get an array of `File` objects from a `DataTransferItemList` object.\n *\n * @param {DataTransferItemList} dataTransferItemList The item list to get an array of `File` objects from.\n * @returns {Promise<File[]>} A promise that resolves with an array of `File` objects.\n */\nconst getFilesFromDataTransferItemList = async dataTransferItemList => {\n const files = [];\n\n // Chromium browsers read only 100 files at a time as per the spec, so we need to use\n // BFS (Breadth-first search) to traverse the entire directory/file structure.\n // https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/webkitGetAsEntry#javascript_content\n const queue = [];\n\n for (const item of dataTransferItemList) {\n if (item.kind !== 'file') {\n // Ignore non-file items, such as links.\n continue;\n }\n\n // https://developer.mozilla.org/docs/Web/API/DataTransferItem/webkitGetAsEntry\n // This function is implemented as `webkitGetAsEntry()` in non-WebKit browsers\n // including Firefox at this time but it may be renamed to `getAsEntry()` in the future.\n const entry = item.getAsEntry ? item.getAsEntry() : item.webkitGetAsEntry();\n\n queue.push(entry);\n }\n\n while (queue.length > 0) {\n const entry = queue.shift();\n\n if (!entry) {\n continue;\n } else if (entry.isFile) {\n const file = await getFileFromFileEntry(entry);\n\n if (FILES_TO_IGNORE.indexOf(file.name) === -1) {\n files.push(file);\n }\n } else if (entry.isDirectory) {\n queue.push(...await readAllDirectoryEntries(entry.createReader()));\n }\n }\n\n return files;\n};\n\n/**\n * Get an array of `File` objects from a `FileList` object.\n *\n * @param {FileList} fileList The file list to get an array of `File` objects from.\n * @returns {Promise<File[]>} A promise that resolves with an array of `File` objects.\n */\nconst getFilesFromFileList = async fileList => {\n const files = [];\n\n for (const file of fileList) {\n if (FILES_TO_IGNORE.indexOf(file.name) === -1) {\n files.push(toFileWithPath(file));\n }\n }\n\n return files;\n};\n\n/**\n * Get an array of `File` objects from an event.\n * This function supports both `drop` and `change` events.\n *\n * @param {DragEvent | Event} evt The event to get an array of `File` objects from.\n * @returns {Promise<File[]>} A promise that resolves with an array of `File` objects.\n */\nexport const getFilesFromEvent = async evt => {\n if (evt.dataTransfer) {\n return evt.dataTransfer.items\n ? await getFilesFromDataTransferItemList(evt.dataTransfer.items)\n : await getFilesFromFileList(evt.dataTransfer.files);\n }\n\n return await getFilesFromFileList(evt.target.files);\n};\n","import { isValidFile } from './utils/is-valid-file.js';\nimport { getFilesFromEvent } from './utils/files-selector.js';\n\nconst COMPONENT_NAME = 'files-dropzone';\nconst TOO_MANY_FILES = 'TOO_MANY_FILES';\nconst FILE_TOO_LARGE = 'FILE_TOO_LARGE';\nconst FILE_TOO_SMALL = 'FILE_TOO_SMALL';\nconst INVALID_MIME_TYPE = 'INVALID_MIME_TYPE';\nconst template = document.createElement('template');\n\ntemplate.innerHTML = /* html */`\n <style>\n *,\n *::before,\n *::after {\n box-sizing: border-box;\n }\n\n :host([hidden]),\n [hidden] {\n display: none !important;\n }\n\n :host {\n --dropzone-border-width: 2px;\n --dropzone-border-style: dashed;\n --dropzone-border-radius: 0.25rem;\n --dropzone-border-color: #6c757d;\n --dropzone-border-color-dragover: #0d6efd;\n --dropzone-background-color: #ffffff;\n --dropzone-background-color-dragover: #f4f4f5;\n --dropzone-body-color: #3f3f46;\n --dropzone-body-color-dragover: var(--dropzone-body-color);\n --dropzone-focus-shadow-rgb: 49,132,253;\n --transition-duration: 0.2s;\n\n display: block;\n }\n\n :host(:not([no-style])) .dropzone {\n border: var(--dropzone-border-width) var(--dropzone-border-style) var(--dropzone-border-color);\n border-radius: var(--dropzone-border-radius);\n padding: 3rem 1rem;\n overflow: hidden;\n background-color: var(--dropzone-background-color);\n color: var(--dropzone-body-color);\n text-align: center;\n cursor: pointer;\n transition: border var(--transition-duration) ease-in-out, background-color var(--transition-duration) ease-in-out, color var(--transition-duration) ease-in-out, box-shadow var(--transition-duration) ease-in-out;\n }\n\n :host(:not([no-style])[no-click]) .dropzone {\n cursor: default;\n }\n\n :host(:not([no-style])[disabled]) .dropzone {\n opacity: 0.8;\n cursor: not-allowed;\n }\n\n :host(:not([no-style]):not([disabled])) .dropzone--dragover {\n border-color: var(--dropzone-border-color-dragover);\n background-color: var(--dropzone-background-color-dragover);\n color: var(--dropzone-body-color-dragover);\n }\n\n :host(:not([no-style]):not([disabled])) .dropzone:focus-visible {\n outline: none;\n box-shadow: 0 0 0 0.25rem rgba(var(--dropzone-focus-shadow-rgb), 0.5);\n }\n </style>\n\n <input type=\"file\" id=\"fileInput\" hidden>\n\n <div part=\"dropzone\" class=\"dropzone\" id=\"dropzoneEl\" tabindex=\"0\" role=\"presentation\">\n <slot>Drag 'n' drop files here, or click to select files</slot>\n </div>\n`;\n\nclass FilesDropzone extends HTMLElement {\n #fileInput;\n #dropzoneEl;\n\n constructor() {\n super();\n\n if (!this.shadowRoot) {\n this.attachShadow({ mode: 'open' });\n this.shadowRoot.appendChild(template.content.cloneNode(true));\n }\n\n this.#fileInput = this.shadowRoot.getElementById('fileInput');\n this.#dropzoneEl = this.shadowRoot.getElementById('dropzoneEl');\n }\n\n static get observedAttributes() {\n return ['accept', 'disabled', 'multiple', 'no-keyboard'];\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n if (name === 'accept' && oldValue !== newValue && this.#fileInput) {\n this.#fileInput.accept = this.accept;\n }\n\n if (name === 'disabled' && oldValue !== newValue && this.#fileInput) {\n this.#fileInput.disabled = this.disabled;\n\n if (this.disabled) {\n this.#dropzoneEl.removeAttribute('tabindex');\n } else {\n this.#dropzoneEl.setAttribute('tabindex', '0');\n }\n }\n\n if (name === 'multiple' && oldValue !== newValue && this.#fileInput) {\n this.#fileInput.multiple = this.multiple;\n }\n\n if (name === 'no-keyboard' && oldValue !== newValue && this.#dropzoneEl) {\n if (this.noKeyboard) {\n this.#dropzoneEl.removeAttribute('tabindex');\n } else {\n this.#dropzoneEl.setAttribute('tabindex', '0');\n }\n }\n }\n\n connectedCallback() {\n this.#upgradeProperty('accept');\n this.#upgradeProperty('disabled');\n this.#upgradeProperty('maxFiles');\n this.#upgradeProperty('maxSize');\n this.#upgradeProperty('minSize');\n this.#upgradeProperty('multiple');\n this.#upgradeProperty('noClick');\n this.#upgradeProperty('noDrag');\n this.#upgradeProperty('noKeyboard');\n this.#upgradeProperty('autoFocus');\n this.#upgradeProperty('noStyle');\n\n this.#fileInput.addEventListener('change', this.#onFileInputChange);\n this.#dropzoneEl.addEventListener('dragenter', this.#onDragEnter);\n this.#dropzoneEl.addEventListener('dragover', this.#onDragOver);\n this.#dropzoneEl.addEventListener('dragleave', this.#onDragLeave);\n this.#dropzoneEl.addEventListener('drop', this.#onDrop);\n this.#dropzoneEl.addEventListener('click', this.#onClick);\n this.#dropzoneEl.addEventListener('keyup', this.#onKeyUp);\n\n this.autoFocus && this.#dropzoneEl.focus();\n }\n\n disconnectedCallback() {\n this.#fileInput.removeEventListener('change', this.#onFileInputChange);\n this.#dropzoneEl.removeEventListener('dragenter', this.#onDragEnter);\n this.#dropzoneEl.removeEventListener('dragover', this.#onDragOver);\n this.#dropzoneEl.removeEventListener('dragleave', this.#onDragLeave);\n this.#dropzoneEl.removeEventListener('drop', this.#onDrop);\n this.#dropzoneEl.removeEventListener('click', this.#onClick);\n this.#dropzoneEl.removeEventListener('keyup', this.#onKeyUp);\n }\n\n get accept() {\n return this.getAttribute('accept');\n }\n\n set accept(value) {\n this.setAttribute('accept', value);\n }\n\n get disabled() {\n return this.hasAttribute('disabled');\n }\n\n set disabled(value) {\n if (value) {\n this.setAttribute('disabled', '');\n } else {\n this.removeAttribute('disabled');\n }\n }\n\n get maxFiles() {\n const num = Number(this.getAttribute('max-files')) || 0;\n\n if (num <= 0) {\n return Infinity;\n }\n\n return Math.floor(Math.abs(num));\n }\n\n set maxFiles(value) {\n this.setAttribute('max-files', value);\n }\n\n get maxSize() {\n const value = this.getAttribute('max-size');\n\n if (value === null) {\n return Infinity;\n }\n\n const num = Number(value);\n\n return Number.isNaN(num) ? Infinity : num;\n }\n\n set maxSize(value) {\n this.setAttribute('max-size', value);\n }\n\n get minSize() {\n const value = this.getAttribute('min-size');\n\n if (value === null) {\n return 0;\n }\n\n const num = Number(value);\n\n return Number.isNaN(num) ? 0 : num;\n }\n\n set minSize(value) {\n this.setAttribute('min-size', value);\n }\n\n get multiple() {\n return this.hasAttribute('multiple');\n }\n\n set multiple(value) {\n if (value) {\n this.setAttribute('multiple', '');\n } else {\n this.removeAttribute('multiple');\n }\n }\n\n get noClick() {\n return this.hasAttribute('no-click');\n }\n\n set noClick(value) {\n if (value) {\n this.setAttribute('no-click', '');\n } else {\n this.removeAttribute('no-click');\n }\n }\n\n get noDrag() {\n return this.hasAttribute('no-drag');\n }\n\n set noDrag(value) {\n if (value) {\n this.setAttribute('no-drag', '');\n } else {\n this.removeAttribute('no-drag');\n }\n }\n\n get noKeyboard() {\n return this.hasAttribute('no-keyboard');\n }\n\n set noKeyboard(value) {\n if (value) {\n this.setAttribute('no-keyboard', '');\n } else {\n this.removeAttribute('no-keyboard');\n }\n }\n\n get autoFocus() {\n return this.hasAttribute('auto-focus');\n }\n\n set autoFocus(value) {\n if (value) {\n this.setAttribute('auto-focus', '');\n } else {\n this.removeAttribute('auto-focus');\n }\n }\n\n get noStyle() {\n return this.hasAttribute('no-style');\n }\n\n set noStyle(value) {\n if (value) {\n this.setAttribute('no-style', '');\n } else {\n this.removeAttribute('no-style');\n }\n }\n\n #onFileInputChange = async evt => {\n try {\n this.#handleFilesSelect(await getFilesFromEvent(evt));\n } catch (error) {\n this.dispatchEvent(new CustomEvent(`${COMPONENT_NAME}-error`, {\n bubbles: true,\n composed: true,\n detail: { error }\n }));\n }\n };\n\n #onDragEnter = () => {\n if (this.disabled || this.noDrag) {\n return;\n }\n\n this.dispatchEvent(new Event(`${COMPONENT_NAME}-dragenter`, {\n bubbles: true,\n composed: true\n }));\n };\n\n #onDragOver = evt => {\n evt.preventDefault();\n\n if (this.disabled || this.noDrag) {\n evt.dataTransfer.dropEffect = 'none';\n return;\n }\n\n evt.dataTransfer.dropEffect = 'copy';\n\n this.#dropzoneEl.classList.add('dropzone--dragover');\n this.#dropzoneEl.part.add('dropzone--dragover');\n\n this.dispatchEvent(new Event(`${COMPONENT_NAME}-dragover`, {\n bubbles: true,\n composed: true\n }));\n };\n\n #onDragLeave = () => {\n if (this.disabled || this.noDrag) {\n return;\n }\n\n this.#dropzoneEl.classList.remove('dropzone--dragover');\n this.#dropzoneEl.part.remove('dropzone--dragover');\n\n this.dispatchEvent(new Event(`${COMPONENT_NAME}-dragleave`, {\n bubbles: true,\n composed: true\n }));\n };\n\n #onDrop = async evt => {\n if (this.disabled || this.noDrag) {\n return;\n }\n\n evt.preventDefault();\n\n this.#dropzoneEl.classList.remove('dropzone--dragover');\n this.#dropzoneEl.part.remove('dropzone--dragover');\n\n try {\n this.#handleFilesSelect(await getFilesFromEvent(evt));\n } catch (error) {\n this.dispatchEvent(new CustomEvent(`${COMPONENT_NAME}-error`, {\n bubbles: true,\n composed: true,\n detail: { error }\n }));\n }\n };\n\n #onClick = () => {\n if (this.disabled || this.noClick) {\n return;\n }\n\n this.#fileInput.click();\n };\n\n #onKeyUp = evt => {\n if (this.disabled || this.noKeyboard) {\n return;\n }\n\n if (evt.key === ' ' || evt.key === 'Enter') {\n this.#fileInput.click();\n }\n };\n\n #handleFilesSelect(files) {\n if (!Array.isArray(files) || !files.length) {\n return;\n }\n\n const acceptedFiles = [];\n const rejectedFiles = [];\n const filesLength = files.length;\n\n // If the component is not in multiple mode, reject all files.\n if (!this.multiple && filesLength > 1) {\n for (const file of files) {\n rejectedFiles.push({\n file,\n errors: [{\n code: TOO_MANY_FILES,\n message: `Too many files selected. Only 1 file is allowed.`\n }]\n });\n }\n } else if (this.multiple && filesLength > this.maxFiles) {\n // If the component is in multiple mode, but the number of files exceeds\n // the maxFiles attribute, reject all files.\n for (const file of files) {\n rejectedFiles.push({\n file,\n errors: [{\n code: TOO_MANY_FILES,\n message: `Too many files selected. Only ${this.maxFiles} ${this.maxFiles > 1 ? 'files are' : 'file is'} allowed.`\n }]\n });\n }\n } else {\n // Validate each file. If it's valid, add it to the accepted files array,\n // otherwise add it to the rejected files array.\n for (const file of files) {\n const fileHasValidType = isValidFile(file, this.accept);\n const fileExceedsMaxSize = file.size > this.maxSize;\n const fileIsSmallerThanMinSize = file.size < this.minSize;\n\n if (fileHasValidType && !fileExceedsMaxSize && !fileIsSmallerThanMinSize) {\n acceptedFiles.push(file);\n } else {\n const errors = [];\n\n if (!fileHasValidType) {\n errors.push({\n code: INVALID_MIME_TYPE,\n message: `File type \"${file.type}\" is not accepted.`\n });\n }\n\n if (fileExceedsMaxSize) {\n errors.push({\n code: FILE_TOO_LARGE,\n message: `File size ${file.size} exceeds the maximum size of ${this.maxSize}.`\n });\n }\n\n if (fileIsSmallerThanMinSize) {\n errors.push({\n code: FILE_TOO_SMALL,\n message: `File size ${file.size} is smaller than the minimum size of ${this.minSize}.`\n });\n }\n\n rejectedFiles.push({ file, errors });\n }\n }\n }\n\n this.dispatchEvent(new CustomEvent(`${COMPONENT_NAME}-drop`, {\n bubbles: true,\n composed: true,\n detail: {\n acceptedFiles,\n rejectedFiles\n }\n }));\n\n if (acceptedFiles.length > 0) {\n this.dispatchEvent(new CustomEvent(`${COMPONENT_NAME}-drop-accepted`, {\n bubbles: true,\n composed: true,\n detail: {\n acceptedFiles\n }\n }));\n }\n\n if (rejectedFiles.length > 0) {\n this.dispatchEvent(new CustomEvent(`${COMPONENT_NAME}-drop-rejected`, {\n bubbles: true,\n composed: true,\n detail: {\n rejectedFiles\n }\n }));\n }\n\n this.#fileInput.value = this.#fileInput.defaultValue;\n }\n\n openFileDialog() {\n if (this.disabled) {\n return;\n }\n\n this.#fileInput.click();\n }\n\n /**\n * https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties\n * This is to safe guard against cases where, for instance, a framework may have added the element to the page and set a\n * value on one of its properties, but lazy loaded its definition. Without this guard, the upgraded element would miss that\n * property and the instance property would prevent the class property setter from ever being called.\n */\n #upgradeProperty(prop) {\n if (Object.prototype.hasOwnProperty.call(this, prop)) {\n const value = this[prop];\n delete this[prop];\n this[prop] = value;\n }\n }\n\n static defineCustomElement(elementName = COMPONENT_NAME) {\n if (typeof window !== 'undefined' && !window.customElements.get(elementName)) {\n window.customElements.define(elementName, FilesDropzone);\n }\n }\n}\n\nexport { FilesDropzone };\n"],"names":["$54e5dea46d3d830b$export$2e2bcd8739ae039","receiver","privateMap","action","has","TypeError","get","$4a9af28d8c332738$export$2e2bcd8739ae039","descriptor","call","value","$0ebd1ade8fb3d51f$export$2e2bcd8739ae039","$ce94785d052866a0$export$2e2bcd8739ae039","obj","privateCollection","$96b9e3133fa8e43f$export$2e2bcd8739ae039","set","$a5f62c39645bb2ba$export$2e2bcd8739ae039","writable","$6108fbe778b62371$export$2e2bcd8739ae039","$1b12450ac511053e$export$2e2bcd8739ae039","privateSet","fn","$39719070878026a5$export$2e2bcd8739ae039","add","$38f222170fd4d21a$export$7c47054fed488f80","file","acceptedTypeSpecifiers","acceptedMimeTypesList","Set","split","map","v","trim","filter","Boolean","fileMimeType","type","baseMimeType","replace","validType","charAt","name","toLowerCase","indexOf","length","test","$f31161edf38949e9$var$COMMON_MIME_TYPES","Map","$f31161edf38949e9$var$FILES_TO_IGNORE","$f31161edf38949e9$var$toFileWithPath","path","fileWithMimeType","lastIndexOf","extension","pop","Object","defineProperty","configurable","enumerable","$f31161edf38949e9$var$toFileWithMimeType","webkitRelativePath","$f31161edf38949e9$var$readEntriesPromise","async","directoryReader","Promise","resolve","reject","readEntries","$f31161edf38949e9$var$readAllDirectoryEntries","entries","push","$f31161edf38949e9$var$getFileFromFileEntry","fileEntry","fullPath","$f31161edf38949e9$var$getFilesFromFileList","fileList","files","$f31161edf38949e9$export$6d52664cd15c442","evt","dataTransfer","items","dataTransferItemList","queue","item","kind","entry","getAsEntry","webkitGetAsEntry","shift","isFile","isDirectory","createReader","$f31161edf38949e9$var$getFilesFromDataTransferItemList","target","$862aa3736b0514bc$var$COMPONENT_NAME","$862aa3736b0514bc$var$TOO_MANY_FILES","$862aa3736b0514bc$var$template","document","createElement","innerHTML","$862aa3736b0514bc$var$_fileInput","WeakMap","$862aa3736b0514bc$var$_dropzoneEl","$862aa3736b0514bc$var$_onFileInputChange","$862aa3736b0514bc$var$_onDragEnter","$862aa3736b0514bc$var$_onDragOver","$862aa3736b0514bc$var$_onDragLeave","$862aa3736b0514bc$var$_onDrop","$862aa3736b0514bc$var$_onClick","$862aa3736b0514bc$var$_onKeyUp","$862aa3736b0514bc$var$_handleFilesSelect","WeakSet","$862aa3736b0514bc$var$_upgradeProperty","$862aa3736b0514bc$export$6ccd1735166caad9","HTMLElement","observedAttributes","attributeChangedCallback","oldValue","newValue","this","accept","disabled","removeAttribute","setAttribute","multiple","noKeyboard","connectedCallback","$862aa3736b0514bc$var$upgradeProperty","addEventListener","autoFocus","focus","disconnectedCallback","removeEventListener","getAttribute","hasAttribute","maxFiles","num","Number","Infinity","Math","floor","abs","maxSize","isNaN","minSize","noClick","noDrag","noStyle","openFileDialog","click","static","elementName","window","customElements","define","constructor","super","$862aa3736b0514bc$var$handleFilesSelect","error","dispatchEvent","CustomEvent","bubbles","composed","detail","Event","preventDefault","dropEffect","classList","part","remove","key","shadowRoot","attachShadow","mode","appendChild","content","cloneNode","getElementById","Array","isArray","acceptedFiles","rejectedFiles","filesLength","errors","code","message","fileHasValidType","fileExceedsMaxSize","size","fileIsSmallerThanMinSize","defaultValue","prop","prototype","hasOwnProperty"],"version":3,"file":"files-dropzone.js.map"}
|
|
1
|
+
{"mappings":"AGAA,IAAM,EAAoB,IAAI,IAAI,CAEhC,CAAC,MAAO,YAAY,CACpB,CAAC,MAAO,wBAAwB,CAChC,CAAC,MAAO,wBAAwB,CAChC,CAAC,OAAQ,aAAa,CACtB,CAAC,MAAO,kBAAkB,CAC1B,CAAC,MAAO,+BAA+B,CACvC,CAAC,MAAO,2BAA2B,CACnC,CAAC,MAAO,YAAY,CACpB,CAAC,KAAM,qBAAqB,CAC5B,CAAC,MAAO,sBAAsB,CAC9B,CAAC,MAAO,oBAAoB,CAC5B,CAAC,MAAO,oBAAoB,CAC5B,CAAC,MAAO,WAAW,CACnB,CAAC,MAAO,WAAW,CACnB,CAAC,MAAO,qBAAqB,CAC7B,CAAC,OAAQ,0EAA0E,CACnF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AAS,CAAC,MAAQ,IAAI,CAAC,CAAC,CAAS,CAAC,YAC1C,CAEA,gBAAiB,CACX,IAAI,CAAC,UAIT,IAAI,CAAC,CAAC,CAAS,CAAC,OAClB,CAQA,CAAC,CAAe,CAAC,CAAI,EACnB,GAAI,OAAO,UAAU,eAAe,KAAK,IAAI,CAAE,GAAO,CACpD,IAAM,EAAQ,IAAI,CAAC,EAAK,AACxB,QAAO,IAAI,CAAC,EAAK,CACjB,IAAI,CAAC,EAAK,CAAG,CACf,CACF,CAEA,OAAO,oBAAoB,EAAc,CAAc,CAAE,CACjC,aAAlB,OAAO,QAA2B,OAAO,eAAe,IAAI,IAC9D,OAAO,eAAe,OAAO,EAAa,EAE9C,CACF,Q,K,a","sources":["<anon>","src/files-dropzone.js","src/utils/is-valid-file.js","src/utils/files-selector.js"],"sourcesContent":["/**\n * Checks if a file is valid based on the accepted file type specifiers.\n *\n * @param {File} file The File object to validate.\n * @param {String} [acceptedTypeSpecifiers=''] The accepted file type specifiers.\n * @returns {Boolean} True if the file is valid, false otherwise.\n */ function $38f222170fd4d21a$export$7c47054fed488f80(file, acceptedTypeSpecifiers = \"\") {\n if (!acceptedTypeSpecifiers) return true;\n const acceptedMimeTypesList = [\n ...new Set(acceptedTypeSpecifiers.split(\",\").map((v)=>v.trim()).filter(Boolean))\n ];\n const fileMimeType = file.type;\n const baseMimeType = fileMimeType.replace(/\\/.*$/, \"\");\n for (const validType of acceptedMimeTypesList){\n if (validType.charAt(0) === \".\") {\n if (file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.length - validType.length) !== -1) return true;\n } else if (/\\/\\*$/.test(validType)) {\n // Check for mime type that looks like \"image/*\" or similar.\n if (baseMimeType === validType.replace(/\\/.*$/, \"\")) return true;\n } else {\n if (fileMimeType === validType) return true;\n }\n }\n return false;\n}\n\n\nconst $f31161edf38949e9$var$COMMON_MIME_TYPES = new Map([\n // https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types\n [\n \"aac\",\n \"audio/aac\"\n ],\n [\n \"abw\",\n \"application/x-abiword\"\n ],\n [\n \"arc\",\n \"application/x-freearc\"\n ],\n [\n \"avif\",\n \"image/avif\"\n ],\n [\n \"avi\",\n \"video/x-msvideo\"\n ],\n [\n \"azw\",\n \"application/vnd.amazon.ebook\"\n ],\n [\n \"bin\",\n \"application/octet-stream\"\n ],\n [\n \"bmp\",\n \"image/bmp\"\n ],\n [\n \"bz\",\n \"application/x-bzip\"\n ],\n [\n \"bz2\",\n \"application/x-bzip2\"\n ],\n [\n \"cda\",\n \"application/x-cdf\"\n ],\n [\n \"csh\",\n \"application/x-csh\"\n ],\n [\n \"css\",\n \"text/css\"\n ],\n [\n \"csv\",\n \"text/csv\"\n ],\n [\n \"doc\",\n \"application/msword\"\n ],\n [\n \"docx\",\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\"\n ],\n [\n \"eot\",\n \"application/vnd.ms-fontobject\"\n ],\n [\n \"epub\",\n \"application/epub+zip\"\n ],\n [\n \"gz\",\n \"application/gzip\"\n ],\n [\n \"gif\",\n \"image/gif\"\n ],\n [\n \"heic\",\n \"image/heic\"\n ],\n [\n \"heif\",\n \"image/heif\"\n ],\n [\n \"htm\",\n \"text/html\"\n ],\n [\n \"html\",\n \"text/html\"\n ],\n [\n \"ico\",\n \"image/vnd.microsoft.icon\"\n ],\n [\n \"ics\",\n \"text/calendar\"\n ],\n [\n \"jar\",\n \"application/java-archive\"\n ],\n [\n \"jpeg\",\n \"image/jpeg\"\n ],\n [\n \"jpg\",\n \"image/jpeg\"\n ],\n [\n \"jxl\",\n \"image/jxl\"\n ],\n [\n \"js\",\n \"text/javascript\"\n ],\n [\n \"json\",\n \"application/json\"\n ],\n [\n \"jsonld\",\n \"application/ld+json\"\n ],\n [\n \"mid\",\n \"audio/midi\"\n ],\n [\n \"midi\",\n \"audio/midi\"\n ],\n [\n \"mjs\",\n \"text/javascript\"\n ],\n [\n \"mp3\",\n \"audio/mpeg\"\n ],\n [\n \"mp4\",\n \"video/mp4\"\n ],\n [\n \"mpeg\",\n \"video/mpeg\"\n ],\n [\n \"mpkg\",\n \"application/vnd.apple.installer+xml\"\n ],\n [\n \"odp\",\n \"application/vnd.oasis.opendocument.presentation\"\n ],\n [\n \"ods\",\n \"application/vnd.oasis.opendocument.spreadsheet\"\n ],\n [\n \"odt\",\n \"application/vnd.oasis.opendocument.text\"\n ],\n [\n \"oga\",\n \"audio/ogg\"\n ],\n [\n \"ogv\",\n \"video/ogg\"\n ],\n [\n \"ogx\",\n \"application/ogg\"\n ],\n [\n \"opus\",\n \"audio/opus\"\n ],\n [\n \"otf\",\n \"font/otf\"\n ],\n [\n \"png\",\n \"image/png\"\n ],\n [\n \"pdf\",\n \"application/pdf\"\n ],\n [\n \"php\",\n \"application/x-httpd-php\"\n ],\n [\n \"ppt\",\n \"application/vnd.ms-powerpoint\"\n ],\n [\n \"pptx\",\n \"application/vnd.openxmlformats-officedocument.presentationml.presentation\"\n ],\n [\n \"rar\",\n \"application/vnd.rar\"\n ],\n [\n \"rtf\",\n \"application/rtf\"\n ],\n [\n \"sh\",\n \"application/x-sh\"\n ],\n [\n \"svg\",\n \"image/svg+xml\"\n ],\n [\n \"swf\",\n \"application/x-shockwave-flash\"\n ],\n [\n \"tar\",\n \"application/x-tar\"\n ],\n [\n \"tif\",\n \"image/tiff\"\n ],\n [\n \"tiff\",\n \"image/tiff\"\n ],\n [\n \"ts\",\n \"video/mp2t\"\n ],\n [\n \"ttf\",\n \"font/ttf\"\n ],\n [\n \"txt\",\n \"text/plain\"\n ],\n [\n \"vsd\",\n \"application/vnd.visio\"\n ],\n [\n \"wav\",\n \"audio/wav\"\n ],\n [\n \"weba\",\n \"audio/webm\"\n ],\n [\n \"webm\",\n \"video/webm\"\n ],\n [\n \"webp\",\n \"image/webp\"\n ],\n [\n \"woff\",\n \"font/woff\"\n ],\n [\n \"woff2\",\n \"font/woff2\"\n ],\n [\n \"xhtml\",\n \"application/xhtml+xml\"\n ],\n [\n \"xls\",\n \"application/vnd.ms-excel\"\n ],\n [\n \"xlsx\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"\n ],\n [\n \"xml\",\n \"application/xml\"\n ],\n [\n \"xul\",\n \"application/vnd.mozilla.xul+xml\"\n ],\n [\n \"zip\",\n \"application/zip\"\n ],\n [\n \"7z\",\n \"application/x-7z-compressed\"\n ],\n // Others\n [\n \"mkv\",\n \"video/x-matroska\"\n ],\n [\n \"mov\",\n \"video/quicktime\"\n ],\n [\n \"msg\",\n \"application/vnd.ms-outlook\"\n ]\n]);\nconst $f31161edf38949e9$var$FILES_TO_IGNORE = [\n // Thumbnail cache files for macOS and Windows\n \".DS_Store\",\n \"Thumbs.db\" // Windows\n];\n/**\n * Adds a `type` property to the file object if it doesn't have one and the file has an extension.\n * This is needed because Firefox doesn't add a type property to files dragged from the desktop.\n * @bug https://bugzilla.mozilla.org/show_bug.cgi?id=1424689\n *\n * @param {File} file The file object to add the type property to.\n * @returns {File} The file object with the type property added.\n */ const $f31161edf38949e9$var$toFileWithMimeType = (file)=>{\n const { name: name } = file;\n const hasExtension = name && name.lastIndexOf(\".\") !== -1;\n if (hasExtension && !file.type) {\n const extension = name.split(\".\").pop().toLowerCase();\n const type = $f31161edf38949e9$var$COMMON_MIME_TYPES.get(extension);\n if (type) Object.defineProperty(file, \"type\", {\n value: type,\n writable: false,\n configurable: false,\n enumerable: true\n });\n }\n return file;\n};\n/**\n * Adds a `path` property to the file object if it doesn't have one.\n * If `path` is not provided, the `webkitRelativePath` property of the file will be used\n * or the file's name if `webkitRelativePath` is not available.\n *\n * @param {File} file The file object to add the path property to.\n * @param {String} [path] The path to set on the file object.\n * @returns {File} The file object with the path property added.\n */ const $f31161edf38949e9$var$toFileWithPath = (file, path)=>{\n const fileWithMimeType = $f31161edf38949e9$var$toFileWithMimeType(file);\n if (typeof fileWithMimeType.path !== \"string\") {\n const { webkitRelativePath: webkitRelativePath } = file;\n Object.defineProperty(fileWithMimeType, \"path\", {\n value: typeof path === \"string\" ? path : webkitRelativePath || file.name,\n writable: false,\n configurable: false,\n enumerable: true\n });\n }\n return fileWithMimeType;\n};\n/**\n * Wrap `FileSystemDirectoryReader.readEntries` in a promise to make working with read entries easier.\n * https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryReader/readEntries\n *\n * @param {FileSystemDirectoryReader} directoryReader The directory reader to read entries from.\n * @returns {Promise<FileSystemFileEntry[]>} A promise that resolves with an array of `FileSystemFileEntry` objects.\n */ const $f31161edf38949e9$var$readEntriesPromise = async (directoryReader)=>{\n return await new Promise((resolve, reject)=>{\n directoryReader.readEntries(resolve, reject);\n });\n};\n/**\n * Read all entries in a directory or sub-directory\n * by calling `readEntries` until it returns an empty array.\n *\n * @param {FileSystemDirectoryReader} directoryReader The directory reader to read entries from.\n * @returns {Promise<FileSystemFileEntry[]>} A promise that resolves with an array of `FileSystemFileEntry` objects.\n */ const $f31161edf38949e9$var$readAllDirectoryEntries = async (directoryReader)=>{\n const entries = [];\n let readEntries = await $f31161edf38949e9$var$readEntriesPromise(directoryReader);\n while(readEntries.length > 0){\n entries.push(...readEntries);\n readEntries = await $f31161edf38949e9$var$readEntriesPromise(directoryReader);\n }\n return entries;\n};\n/**\n * Get a `File` object from a `FileSystemFileEntry` object.\n *\n * @param {FileSystemFileEntry} fileEntry The file entry to get a `File` object from.\n * @returns {Promise<File>} A promise that resolves with a `File` object.\n */ const $f31161edf38949e9$var$getFileFromFileEntry = (fileEntry)=>{\n return new Promise((resolve, reject)=>{\n fileEntry.file((file)=>resolve($f31161edf38949e9$var$toFileWithPath(file, fileEntry.fullPath)), reject);\n });\n};\n/**\n * Get an array of `File` objects from a `DataTransferItemList` object.\n *\n * @param {DataTransferItemList} dataTransferItemList The item list to get an array of `File` objects from.\n * @returns {Promise<File[]>} A promise that resolves with an array of `File` objects.\n */ const $f31161edf38949e9$var$getFilesFromDataTransferItemList = async (dataTransferItemList)=>{\n const files = [];\n // Chromium browsers read only 100 files at a time as per the spec, so we need to use\n // BFS (Breadth-first search) to traverse the entire directory/file structure.\n // https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/webkitGetAsEntry#javascript_content\n const queue = [];\n for (const item of dataTransferItemList){\n if (item.kind !== \"file\") continue;\n // https://developer.mozilla.org/docs/Web/API/DataTransferItem/webkitGetAsEntry\n // This function is implemented as `webkitGetAsEntry()` in non-WebKit browsers\n // including Firefox at this time but it may be renamed to `getAsEntry()` in the future.\n const entry = item.getAsEntry ? item.getAsEntry() : item.webkitGetAsEntry();\n queue.push(entry);\n }\n while(queue.length > 0){\n const entry = queue.shift();\n if (!entry) continue;\n else if (entry.isFile) {\n const file = await $f31161edf38949e9$var$getFileFromFileEntry(entry);\n if ($f31161edf38949e9$var$FILES_TO_IGNORE.indexOf(file.name) === -1) files.push(file);\n } else if (entry.isDirectory) queue.push(...await $f31161edf38949e9$var$readAllDirectoryEntries(entry.createReader()));\n }\n return files;\n};\n/**\n * Get an array of `File` objects from a `FileList` object.\n *\n * @param {FileList} fileList The file list to get an array of `File` objects from.\n * @returns {Promise<File[]>} A promise that resolves with an array of `File` objects.\n */ const $f31161edf38949e9$var$getFilesFromFileList = async (fileList)=>{\n const files = [];\n for (const file of fileList)if ($f31161edf38949e9$var$FILES_TO_IGNORE.indexOf(file.name) === -1) files.push($f31161edf38949e9$var$toFileWithPath(file));\n return files;\n};\nconst $f31161edf38949e9$export$6d52664cd15c442 = async (evt)=>{\n if (evt.dataTransfer) return evt.dataTransfer.items ? await $f31161edf38949e9$var$getFilesFromDataTransferItemList(evt.dataTransfer.items) : await $f31161edf38949e9$var$getFilesFromFileList(evt.dataTransfer.files);\n return await $f31161edf38949e9$var$getFilesFromFileList(evt.target.files);\n};\n\n\nconst $862aa3736b0514bc$var$COMPONENT_NAME = \"files-dropzone\";\nconst $862aa3736b0514bc$var$TOO_MANY_FILES = \"TOO_MANY_FILES\";\nconst $862aa3736b0514bc$var$FILE_TOO_LARGE = \"FILE_TOO_LARGE\";\nconst $862aa3736b0514bc$var$FILE_TOO_SMALL = \"FILE_TOO_SMALL\";\nconst $862aa3736b0514bc$var$INVALID_MIME_TYPE = \"INVALID_MIME_TYPE\";\nconst $862aa3736b0514bc$var$template = document.createElement(\"template\");\n$862aa3736b0514bc$var$template.innerHTML = /* html */ `\n <style>\n *,\n *::before,\n *::after {\n box-sizing: border-box;\n }\n\n :host([hidden]),\n [hidden] {\n display: none !important;\n }\n\n :host {\n --dropzone-border-width: 2px;\n --dropzone-border-style: dashed;\n --dropzone-border-radius: 0.25rem;\n --dropzone-border-color: #6c757d;\n --dropzone-border-color-dragover: #0d6efd;\n --dropzone-background-color: #ffffff;\n --dropzone-background-color-dragover: #f4f4f5;\n --dropzone-body-color: #3f3f46;\n --dropzone-body-color-dragover: var(--dropzone-body-color);\n --dropzone-focus-shadow-rgb: 49,132,253;\n --transition-duration: 0.2s;\n\n display: block;\n }\n\n :host(:not([no-style])) .dropzone {\n border: var(--dropzone-border-width) var(--dropzone-border-style) var(--dropzone-border-color);\n border-radius: var(--dropzone-border-radius);\n padding: 3rem 1rem;\n overflow: hidden;\n background-color: var(--dropzone-background-color);\n color: var(--dropzone-body-color);\n text-align: center;\n cursor: pointer;\n transition: border var(--transition-duration) ease-in-out, background-color var(--transition-duration) ease-in-out, color var(--transition-duration) ease-in-out, box-shadow var(--transition-duration) ease-in-out;\n }\n\n :host(:not([no-style])[no-click]) .dropzone {\n cursor: default;\n }\n\n :host(:not([no-style])[disabled]) .dropzone {\n opacity: 0.8;\n cursor: not-allowed;\n }\n\n :host(:not([no-style]):not([disabled])) .dropzone--dragover {\n border-color: var(--dropzone-border-color-dragover);\n background-color: var(--dropzone-background-color-dragover);\n color: var(--dropzone-body-color-dragover);\n }\n\n :host(:not([no-style]):not([disabled])) .dropzone:focus-visible {\n outline: none;\n box-shadow: 0 0 0 0.25rem rgba(var(--dropzone-focus-shadow-rgb), 0.5);\n }\n </style>\n\n <input type=\"file\" id=\"fileInput\" hidden>\n\n <div part=\"dropzone\" class=\"dropzone\" id=\"dropzoneEl\" tabindex=\"0\" role=\"presentation\">\n <slot>Drag 'n' drop files here, or click to select files</slot>\n </div>\n`;\nclass $862aa3736b0514bc$export$6ccd1735166caad9 extends HTMLElement {\n #fileInput;\n #dropzoneEl;\n constructor(){\n super();\n if (!this.shadowRoot) {\n this.attachShadow({\n mode: \"open\"\n });\n this.shadowRoot.appendChild($862aa3736b0514bc$var$template.content.cloneNode(true));\n }\n this.#fileInput = this.shadowRoot.getElementById(\"fileInput\");\n this.#dropzoneEl = this.shadowRoot.getElementById(\"dropzoneEl\");\n }\n static get observedAttributes() {\n return [\n \"accept\",\n \"disabled\",\n \"multiple\",\n \"no-keyboard\"\n ];\n }\n attributeChangedCallback(name, oldValue, newValue) {\n if (name === \"accept\" && oldValue !== newValue && this.#fileInput) this.#fileInput.accept = this.accept;\n if (name === \"disabled\" && oldValue !== newValue && this.#fileInput) {\n this.#fileInput.disabled = this.disabled;\n if (this.disabled) this.#dropzoneEl.removeAttribute(\"tabindex\");\n else this.#dropzoneEl.setAttribute(\"tabindex\", \"0\");\n }\n if (name === \"multiple\" && oldValue !== newValue && this.#fileInput) this.#fileInput.multiple = this.multiple;\n if (name === \"no-keyboard\" && oldValue !== newValue && this.#dropzoneEl) {\n if (this.noKeyboard) this.#dropzoneEl.removeAttribute(\"tabindex\");\n else this.#dropzoneEl.setAttribute(\"tabindex\", \"0\");\n }\n }\n connectedCallback() {\n this.#upgradeProperty(\"accept\");\n this.#upgradeProperty(\"disabled\");\n this.#upgradeProperty(\"maxFiles\");\n this.#upgradeProperty(\"maxSize\");\n this.#upgradeProperty(\"minSize\");\n this.#upgradeProperty(\"multiple\");\n this.#upgradeProperty(\"noClick\");\n this.#upgradeProperty(\"noDrag\");\n this.#upgradeProperty(\"noKeyboard\");\n this.#upgradeProperty(\"autoFocus\");\n this.#upgradeProperty(\"noStyle\");\n this.#fileInput.addEventListener(\"change\", this.#onFileInputChange);\n this.#dropzoneEl.addEventListener(\"dragenter\", this.#onDragEnter);\n this.#dropzoneEl.addEventListener(\"dragover\", this.#onDragOver);\n this.#dropzoneEl.addEventListener(\"dragleave\", this.#onDragLeave);\n this.#dropzoneEl.addEventListener(\"drop\", this.#onDrop);\n this.#dropzoneEl.addEventListener(\"click\", this.#onClick);\n this.#dropzoneEl.addEventListener(\"keyup\", this.#onKeyUp);\n this.autoFocus && this.#dropzoneEl.focus();\n }\n disconnectedCallback() {\n this.#fileInput.removeEventListener(\"change\", this.#onFileInputChange);\n this.#dropzoneEl.removeEventListener(\"dragenter\", this.#onDragEnter);\n this.#dropzoneEl.removeEventListener(\"dragover\", this.#onDragOver);\n this.#dropzoneEl.removeEventListener(\"dragleave\", this.#onDragLeave);\n this.#dropzoneEl.removeEventListener(\"drop\", this.#onDrop);\n this.#dropzoneEl.removeEventListener(\"click\", this.#onClick);\n this.#dropzoneEl.removeEventListener(\"keyup\", this.#onKeyUp);\n }\n get accept() {\n return this.getAttribute(\"accept\");\n }\n set accept(value) {\n this.setAttribute(\"accept\", value);\n }\n get disabled() {\n return this.hasAttribute(\"disabled\");\n }\n set disabled(value) {\n if (value) this.setAttribute(\"disabled\", \"\");\n else this.removeAttribute(\"disabled\");\n }\n get maxFiles() {\n const num = Number(this.getAttribute(\"max-files\")) || 0;\n if (num <= 0) return Infinity;\n return Math.floor(Math.abs(num));\n }\n set maxFiles(value) {\n this.setAttribute(\"max-files\", value);\n }\n get maxSize() {\n const value = this.getAttribute(\"max-size\");\n if (value === null) return Infinity;\n const num = Number(value);\n return Number.isNaN(num) ? Infinity : num;\n }\n set maxSize(value) {\n this.setAttribute(\"max-size\", value);\n }\n get minSize() {\n const value = this.getAttribute(\"min-size\");\n if (value === null) return 0;\n const num = Number(value);\n return Number.isNaN(num) ? 0 : num;\n }\n set minSize(value) {\n this.setAttribute(\"min-size\", value);\n }\n get multiple() {\n return this.hasAttribute(\"multiple\");\n }\n set multiple(value) {\n if (value) this.setAttribute(\"multiple\", \"\");\n else this.removeAttribute(\"multiple\");\n }\n get noClick() {\n return this.hasAttribute(\"no-click\");\n }\n set noClick(value) {\n if (value) this.setAttribute(\"no-click\", \"\");\n else this.removeAttribute(\"no-click\");\n }\n get noDrag() {\n return this.hasAttribute(\"no-drag\");\n }\n set noDrag(value) {\n if (value) this.setAttribute(\"no-drag\", \"\");\n else this.removeAttribute(\"no-drag\");\n }\n get noKeyboard() {\n return this.hasAttribute(\"no-keyboard\");\n }\n set noKeyboard(value) {\n if (value) this.setAttribute(\"no-keyboard\", \"\");\n else this.removeAttribute(\"no-keyboard\");\n }\n get autoFocus() {\n return this.hasAttribute(\"auto-focus\");\n }\n set autoFocus(value) {\n if (value) this.setAttribute(\"auto-focus\", \"\");\n else this.removeAttribute(\"auto-focus\");\n }\n get noStyle() {\n return this.hasAttribute(\"no-style\");\n }\n set noStyle(value) {\n if (value) this.setAttribute(\"no-style\", \"\");\n else this.removeAttribute(\"no-style\");\n }\n #onFileInputChange = async (evt)=>{\n try {\n this.#handleFilesSelect(await (0, $f31161edf38949e9$export$6d52664cd15c442)(evt));\n } catch (error) {\n this.dispatchEvent(new CustomEvent(`${$862aa3736b0514bc$var$COMPONENT_NAME}-error`, {\n bubbles: true,\n composed: true,\n detail: {\n error: error\n }\n }));\n }\n };\n #onDragEnter = ()=>{\n if (this.disabled || this.noDrag) return;\n this.dispatchEvent(new Event(`${$862aa3736b0514bc$var$COMPONENT_NAME}-dragenter`, {\n bubbles: true,\n composed: true\n }));\n };\n #onDragOver = (evt)=>{\n evt.preventDefault();\n if (this.disabled || this.noDrag) {\n evt.dataTransfer.dropEffect = \"none\";\n return;\n }\n evt.dataTransfer.dropEffect = \"copy\";\n this.#dropzoneEl.classList.add(\"dropzone--dragover\");\n this.#dropzoneEl.part.add(\"dropzone--dragover\");\n this.dispatchEvent(new Event(`${$862aa3736b0514bc$var$COMPONENT_NAME}-dragover`, {\n bubbles: true,\n composed: true\n }));\n };\n #onDragLeave = ()=>{\n if (this.disabled || this.noDrag) return;\n this.#dropzoneEl.classList.remove(\"dropzone--dragover\");\n this.#dropzoneEl.part.remove(\"dropzone--dragover\");\n this.dispatchEvent(new Event(`${$862aa3736b0514bc$var$COMPONENT_NAME}-dragleave`, {\n bubbles: true,\n composed: true\n }));\n };\n #onDrop = async (evt)=>{\n if (this.disabled || this.noDrag) return;\n evt.preventDefault();\n this.#dropzoneEl.classList.remove(\"dropzone--dragover\");\n this.#dropzoneEl.part.remove(\"dropzone--dragover\");\n try {\n this.#handleFilesSelect(await (0, $f31161edf38949e9$export$6d52664cd15c442)(evt));\n } catch (error) {\n this.dispatchEvent(new CustomEvent(`${$862aa3736b0514bc$var$COMPONENT_NAME}-error`, {\n bubbles: true,\n composed: true,\n detail: {\n error: error\n }\n }));\n }\n };\n #onClick = ()=>{\n if (this.disabled || this.noClick) return;\n this.#fileInput.click();\n };\n #onKeyUp = (evt)=>{\n if (this.disabled || this.noKeyboard) return;\n if (evt.key === \" \" || evt.key === \"Enter\") this.#fileInput.click();\n };\n #handleFilesSelect(files) {\n if (!Array.isArray(files) || !files.length) return;\n const acceptedFiles = [];\n const rejectedFiles = [];\n const filesLength = files.length;\n // If the component is not in multiple mode, reject all files.\n if (!this.multiple && filesLength > 1) for (const file of files)rejectedFiles.push({\n file: file,\n errors: [\n {\n code: $862aa3736b0514bc$var$TOO_MANY_FILES,\n message: `Too many files selected. Only 1 file is allowed.`\n }\n ]\n });\n else if (this.multiple && filesLength > this.maxFiles) // If the component is in multiple mode, but the number of files exceeds\n // the maxFiles attribute, reject all files.\n for (const file of files)rejectedFiles.push({\n file: file,\n errors: [\n {\n code: $862aa3736b0514bc$var$TOO_MANY_FILES,\n message: `Too many files selected. Only ${this.maxFiles} ${this.maxFiles > 1 ? \"files are\" : \"file is\"} allowed.`\n }\n ]\n });\n else // Validate each file. If it's valid, add it to the accepted files array,\n // otherwise add it to the rejected files array.\n for (const file of files){\n const fileHasValidType = (0, $38f222170fd4d21a$export$7c47054fed488f80)(file, this.accept);\n const fileExceedsMaxSize = file.size > this.maxSize;\n const fileIsSmallerThanMinSize = file.size < this.minSize;\n if (fileHasValidType && !fileExceedsMaxSize && !fileIsSmallerThanMinSize) acceptedFiles.push(file);\n else {\n const errors = [];\n if (!fileHasValidType) errors.push({\n code: $862aa3736b0514bc$var$INVALID_MIME_TYPE,\n message: `File type \"${file.type}\" is not accepted.`\n });\n if (fileExceedsMaxSize) errors.push({\n code: $862aa3736b0514bc$var$FILE_TOO_LARGE,\n message: `File size ${file.size} exceeds the maximum size of ${this.maxSize}.`\n });\n if (fileIsSmallerThanMinSize) errors.push({\n code: $862aa3736b0514bc$var$FILE_TOO_SMALL,\n message: `File size ${file.size} is smaller than the minimum size of ${this.minSize}.`\n });\n rejectedFiles.push({\n file: file,\n errors: errors\n });\n }\n }\n this.dispatchEvent(new CustomEvent(`${$862aa3736b0514bc$var$COMPONENT_NAME}-drop`, {\n bubbles: true,\n composed: true,\n detail: {\n acceptedFiles: acceptedFiles,\n rejectedFiles: rejectedFiles\n }\n }));\n if (acceptedFiles.length > 0) this.dispatchEvent(new CustomEvent(`${$862aa3736b0514bc$var$COMPONENT_NAME}-drop-accepted`, {\n bubbles: true,\n composed: true,\n detail: {\n acceptedFiles: acceptedFiles\n }\n }));\n if (rejectedFiles.length > 0) this.dispatchEvent(new CustomEvent(`${$862aa3736b0514bc$var$COMPONENT_NAME}-drop-rejected`, {\n bubbles: true,\n composed: true,\n detail: {\n rejectedFiles: rejectedFiles\n }\n }));\n this.#fileInput.value = this.#fileInput.defaultValue;\n }\n openFileDialog() {\n if (this.disabled) return;\n this.#fileInput.click();\n }\n /**\n * https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties\n * This is to safe guard against cases where, for instance, a framework may have added the element to the page and set a\n * value on one of its properties, but lazy loaded its definition. Without this guard, the upgraded element would miss that\n * property and the instance property would prevent the class property setter from ever being called.\n */ #upgradeProperty(prop) {\n if (Object.prototype.hasOwnProperty.call(this, prop)) {\n const value = this[prop];\n delete this[prop];\n this[prop] = value;\n }\n }\n static defineCustomElement(elementName = $862aa3736b0514bc$var$COMPONENT_NAME) {\n if (typeof window !== \"undefined\" && !window.customElements.get(elementName)) window.customElements.define(elementName, $862aa3736b0514bc$export$6ccd1735166caad9);\n }\n}\n\n\nexport {$862aa3736b0514bc$export$6ccd1735166caad9 as FilesDropzone};\n//# sourceMappingURL=files-dropzone.js.map\n","import { isValidFile } from './utils/is-valid-file.js';\nimport { getFilesFromEvent } from './utils/files-selector.js';\n\nconst COMPONENT_NAME = 'files-dropzone';\nconst TOO_MANY_FILES = 'TOO_MANY_FILES';\nconst FILE_TOO_LARGE = 'FILE_TOO_LARGE';\nconst FILE_TOO_SMALL = 'FILE_TOO_SMALL';\nconst INVALID_MIME_TYPE = 'INVALID_MIME_TYPE';\nconst template = document.createElement('template');\n\ntemplate.innerHTML = /* html */`\n <style>\n *,\n *::before,\n *::after {\n box-sizing: border-box;\n }\n\n :host([hidden]),\n [hidden] {\n display: none !important;\n }\n\n :host {\n --dropzone-border-width: 2px;\n --dropzone-border-style: dashed;\n --dropzone-border-radius: 0.25rem;\n --dropzone-border-color: #6c757d;\n --dropzone-border-color-dragover: #0d6efd;\n --dropzone-background-color: #ffffff;\n --dropzone-background-color-dragover: #f4f4f5;\n --dropzone-body-color: #3f3f46;\n --dropzone-body-color-dragover: var(--dropzone-body-color);\n --dropzone-focus-shadow-rgb: 49,132,253;\n --transition-duration: 0.2s;\n\n display: block;\n }\n\n :host(:not([no-style])) .dropzone {\n border: var(--dropzone-border-width) var(--dropzone-border-style) var(--dropzone-border-color);\n border-radius: var(--dropzone-border-radius);\n padding: 3rem 1rem;\n overflow: hidden;\n background-color: var(--dropzone-background-color);\n color: var(--dropzone-body-color);\n text-align: center;\n cursor: pointer;\n transition: border var(--transition-duration) ease-in-out, background-color var(--transition-duration) ease-in-out, color var(--transition-duration) ease-in-out, box-shadow var(--transition-duration) ease-in-out;\n }\n\n :host(:not([no-style])[no-click]) .dropzone {\n cursor: default;\n }\n\n :host(:not([no-style])[disabled]) .dropzone {\n opacity: 0.8;\n cursor: not-allowed;\n }\n\n :host(:not([no-style]):not([disabled])) .dropzone--dragover {\n border-color: var(--dropzone-border-color-dragover);\n background-color: var(--dropzone-background-color-dragover);\n color: var(--dropzone-body-color-dragover);\n }\n\n :host(:not([no-style]):not([disabled])) .dropzone:focus-visible {\n outline: none;\n box-shadow: 0 0 0 0.25rem rgba(var(--dropzone-focus-shadow-rgb), 0.5);\n }\n </style>\n\n <input type=\"file\" id=\"fileInput\" hidden>\n\n <div part=\"dropzone\" class=\"dropzone\" id=\"dropzoneEl\" tabindex=\"0\" role=\"presentation\">\n <slot>Drag 'n' drop files here, or click to select files</slot>\n </div>\n`;\n\nclass FilesDropzone extends HTMLElement {\n #fileInput;\n #dropzoneEl;\n\n constructor() {\n super();\n\n if (!this.shadowRoot) {\n this.attachShadow({ mode: 'open' });\n this.shadowRoot.appendChild(template.content.cloneNode(true));\n }\n\n this.#fileInput = this.shadowRoot.getElementById('fileInput');\n this.#dropzoneEl = this.shadowRoot.getElementById('dropzoneEl');\n }\n\n static get observedAttributes() {\n return ['accept', 'disabled', 'multiple', 'no-keyboard'];\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n if (name === 'accept' && oldValue !== newValue && this.#fileInput) {\n this.#fileInput.accept = this.accept;\n }\n\n if (name === 'disabled' && oldValue !== newValue && this.#fileInput) {\n this.#fileInput.disabled = this.disabled;\n\n if (this.disabled) {\n this.#dropzoneEl.removeAttribute('tabindex');\n } else {\n this.#dropzoneEl.setAttribute('tabindex', '0');\n }\n }\n\n if (name === 'multiple' && oldValue !== newValue && this.#fileInput) {\n this.#fileInput.multiple = this.multiple;\n }\n\n if (name === 'no-keyboard' && oldValue !== newValue && this.#dropzoneEl) {\n if (this.noKeyboard) {\n this.#dropzoneEl.removeAttribute('tabindex');\n } else {\n this.#dropzoneEl.setAttribute('tabindex', '0');\n }\n }\n }\n\n connectedCallback() {\n this.#upgradeProperty('accept');\n this.#upgradeProperty('disabled');\n this.#upgradeProperty('maxFiles');\n this.#upgradeProperty('maxSize');\n this.#upgradeProperty('minSize');\n this.#upgradeProperty('multiple');\n this.#upgradeProperty('noClick');\n this.#upgradeProperty('noDrag');\n this.#upgradeProperty('noKeyboard');\n this.#upgradeProperty('autoFocus');\n this.#upgradeProperty('noStyle');\n\n this.#fileInput.addEventListener('change', this.#onFileInputChange);\n this.#dropzoneEl.addEventListener('dragenter', this.#onDragEnter);\n this.#dropzoneEl.addEventListener('dragover', this.#onDragOver);\n this.#dropzoneEl.addEventListener('dragleave', this.#onDragLeave);\n this.#dropzoneEl.addEventListener('drop', this.#onDrop);\n this.#dropzoneEl.addEventListener('click', this.#onClick);\n this.#dropzoneEl.addEventListener('keyup', this.#onKeyUp);\n\n this.autoFocus && this.#dropzoneEl.focus();\n }\n\n disconnectedCallback() {\n this.#fileInput.removeEventListener('change', this.#onFileInputChange);\n this.#dropzoneEl.removeEventListener('dragenter', this.#onDragEnter);\n this.#dropzoneEl.removeEventListener('dragover', this.#onDragOver);\n this.#dropzoneEl.removeEventListener('dragleave', this.#onDragLeave);\n this.#dropzoneEl.removeEventListener('drop', this.#onDrop);\n this.#dropzoneEl.removeEventListener('click', this.#onClick);\n this.#dropzoneEl.removeEventListener('keyup', this.#onKeyUp);\n }\n\n get accept() {\n return this.getAttribute('accept');\n }\n\n set accept(value) {\n this.setAttribute('accept', value);\n }\n\n get disabled() {\n return this.hasAttribute('disabled');\n }\n\n set disabled(value) {\n if (value) {\n this.setAttribute('disabled', '');\n } else {\n this.removeAttribute('disabled');\n }\n }\n\n get maxFiles() {\n const num = Number(this.getAttribute('max-files')) || 0;\n\n if (num <= 0) {\n return Infinity;\n }\n\n return Math.floor(Math.abs(num));\n }\n\n set maxFiles(value) {\n this.setAttribute('max-files', value);\n }\n\n get maxSize() {\n const value = this.getAttribute('max-size');\n\n if (value === null) {\n return Infinity;\n }\n\n const num = Number(value);\n\n return Number.isNaN(num) ? Infinity : num;\n }\n\n set maxSize(value) {\n this.setAttribute('max-size', value);\n }\n\n get minSize() {\n const value = this.getAttribute('min-size');\n\n if (value === null) {\n return 0;\n }\n\n const num = Number(value);\n\n return Number.isNaN(num) ? 0 : num;\n }\n\n set minSize(value) {\n this.setAttribute('min-size', value);\n }\n\n get multiple() {\n return this.hasAttribute('multiple');\n }\n\n set multiple(value) {\n if (value) {\n this.setAttribute('multiple', '');\n } else {\n this.removeAttribute('multiple');\n }\n }\n\n get noClick() {\n return this.hasAttribute('no-click');\n }\n\n set noClick(value) {\n if (value) {\n this.setAttribute('no-click', '');\n } else {\n this.removeAttribute('no-click');\n }\n }\n\n get noDrag() {\n return this.hasAttribute('no-drag');\n }\n\n set noDrag(value) {\n if (value) {\n this.setAttribute('no-drag', '');\n } else {\n this.removeAttribute('no-drag');\n }\n }\n\n get noKeyboard() {\n return this.hasAttribute('no-keyboard');\n }\n\n set noKeyboard(value) {\n if (value) {\n this.setAttribute('no-keyboard', '');\n } else {\n this.removeAttribute('no-keyboard');\n }\n }\n\n get autoFocus() {\n return this.hasAttribute('auto-focus');\n }\n\n set autoFocus(value) {\n if (value) {\n this.setAttribute('auto-focus', '');\n } else {\n this.removeAttribute('auto-focus');\n }\n }\n\n get noStyle() {\n return this.hasAttribute('no-style');\n }\n\n set noStyle(value) {\n if (value) {\n this.setAttribute('no-style', '');\n } else {\n this.removeAttribute('no-style');\n }\n }\n\n #onFileInputChange = async evt => {\n try {\n this.#handleFilesSelect(await getFilesFromEvent(evt));\n } catch (error) {\n this.dispatchEvent(new CustomEvent(`${COMPONENT_NAME}-error`, {\n bubbles: true,\n composed: true,\n detail: { error }\n }));\n }\n };\n\n #onDragEnter = () => {\n if (this.disabled || this.noDrag) {\n return;\n }\n\n this.dispatchEvent(new Event(`${COMPONENT_NAME}-dragenter`, {\n bubbles: true,\n composed: true\n }));\n };\n\n #onDragOver = evt => {\n evt.preventDefault();\n\n if (this.disabled || this.noDrag) {\n evt.dataTransfer.dropEffect = 'none';\n return;\n }\n\n evt.dataTransfer.dropEffect = 'copy';\n\n this.#dropzoneEl.classList.add('dropzone--dragover');\n this.#dropzoneEl.part.add('dropzone--dragover');\n\n this.dispatchEvent(new Event(`${COMPONENT_NAME}-dragover`, {\n bubbles: true,\n composed: true\n }));\n };\n\n #onDragLeave = () => {\n if (this.disabled || this.noDrag) {\n return;\n }\n\n this.#dropzoneEl.classList.remove('dropzone--dragover');\n this.#dropzoneEl.part.remove('dropzone--dragover');\n\n this.dispatchEvent(new Event(`${COMPONENT_NAME}-dragleave`, {\n bubbles: true,\n composed: true\n }));\n };\n\n #onDrop = async evt => {\n if (this.disabled || this.noDrag) {\n return;\n }\n\n evt.preventDefault();\n\n this.#dropzoneEl.classList.remove('dropzone--dragover');\n this.#dropzoneEl.part.remove('dropzone--dragover');\n\n try {\n this.#handleFilesSelect(await getFilesFromEvent(evt));\n } catch (error) {\n this.dispatchEvent(new CustomEvent(`${COMPONENT_NAME}-error`, {\n bubbles: true,\n composed: true,\n detail: { error }\n }));\n }\n };\n\n #onClick = () => {\n if (this.disabled || this.noClick) {\n return;\n }\n\n this.#fileInput.click();\n };\n\n #onKeyUp = evt => {\n if (this.disabled || this.noKeyboard) {\n return;\n }\n\n if (evt.key === ' ' || evt.key === 'Enter') {\n this.#fileInput.click();\n }\n };\n\n #handleFilesSelect(files) {\n if (!Array.isArray(files) || !files.length) {\n return;\n }\n\n const acceptedFiles = [];\n const rejectedFiles = [];\n const filesLength = files.length;\n\n // If the component is not in multiple mode, reject all files.\n if (!this.multiple && filesLength > 1) {\n for (const file of files) {\n rejectedFiles.push({\n file,\n errors: [{\n code: TOO_MANY_FILES,\n message: `Too many files selected. Only 1 file is allowed.`\n }]\n });\n }\n } else if (this.multiple && filesLength > this.maxFiles) {\n // If the component is in multiple mode, but the number of files exceeds\n // the maxFiles attribute, reject all files.\n for (const file of files) {\n rejectedFiles.push({\n file,\n errors: [{\n code: TOO_MANY_FILES,\n message: `Too many files selected. Only ${this.maxFiles} ${this.maxFiles > 1 ? 'files are' : 'file is'} allowed.`\n }]\n });\n }\n } else {\n // Validate each file. If it's valid, add it to the accepted files array,\n // otherwise add it to the rejected files array.\n for (const file of files) {\n const fileHasValidType = isValidFile(file, this.accept);\n const fileExceedsMaxSize = file.size > this.maxSize;\n const fileIsSmallerThanMinSize = file.size < this.minSize;\n\n if (fileHasValidType && !fileExceedsMaxSize && !fileIsSmallerThanMinSize) {\n acceptedFiles.push(file);\n } else {\n const errors = [];\n\n if (!fileHasValidType) {\n errors.push({\n code: INVALID_MIME_TYPE,\n message: `File type \"${file.type}\" is not accepted.`\n });\n }\n\n if (fileExceedsMaxSize) {\n errors.push({\n code: FILE_TOO_LARGE,\n message: `File size ${file.size} exceeds the maximum size of ${this.maxSize}.`\n });\n }\n\n if (fileIsSmallerThanMinSize) {\n errors.push({\n code: FILE_TOO_SMALL,\n message: `File size ${file.size} is smaller than the minimum size of ${this.minSize}.`\n });\n }\n\n rejectedFiles.push({ file, errors });\n }\n }\n }\n\n this.dispatchEvent(new CustomEvent(`${COMPONENT_NAME}-drop`, {\n bubbles: true,\n composed: true,\n detail: {\n acceptedFiles,\n rejectedFiles\n }\n }));\n\n if (acceptedFiles.length > 0) {\n this.dispatchEvent(new CustomEvent(`${COMPONENT_NAME}-drop-accepted`, {\n bubbles: true,\n composed: true,\n detail: {\n acceptedFiles\n }\n }));\n }\n\n if (rejectedFiles.length > 0) {\n this.dispatchEvent(new CustomEvent(`${COMPONENT_NAME}-drop-rejected`, {\n bubbles: true,\n composed: true,\n detail: {\n rejectedFiles\n }\n }));\n }\n\n this.#fileInput.value = this.#fileInput.defaultValue;\n }\n\n openFileDialog() {\n if (this.disabled) {\n return;\n }\n\n this.#fileInput.click();\n }\n\n /**\n * https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties\n * This is to safe guard against cases where, for instance, a framework may have added the element to the page and set a\n * value on one of its properties, but lazy loaded its definition. Without this guard, the upgraded element would miss that\n * property and the instance property would prevent the class property setter from ever being called.\n */\n #upgradeProperty(prop) {\n if (Object.prototype.hasOwnProperty.call(this, prop)) {\n const value = this[prop];\n delete this[prop];\n this[prop] = value;\n }\n }\n\n static defineCustomElement(elementName = COMPONENT_NAME) {\n if (typeof window !== 'undefined' && !window.customElements.get(elementName)) {\n window.customElements.define(elementName, FilesDropzone);\n }\n }\n}\n\nexport { FilesDropzone };\n","/**\n * Checks if a file is valid based on the accepted file type specifiers.\n *\n * @param {File} file The File object to validate.\n * @param {String} [acceptedTypeSpecifiers=''] The accepted file type specifiers.\n * @returns {Boolean} True if the file is valid, false otherwise.\n */\nexport function isValidFile(file, acceptedTypeSpecifiers = '') {\n if (!acceptedTypeSpecifiers) {\n return true;\n }\n\n const acceptedMimeTypesList = [\n ...new Set(acceptedTypeSpecifiers.split(',').map(v => v.trim()).filter(Boolean))\n ];\n\n const fileMimeType = file.type;\n const baseMimeType = fileMimeType.replace(/\\/.*$/, '');\n\n for (const validType of acceptedMimeTypesList) {\n if (validType.charAt(0) === '.') {\n if (file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.length - validType.length) !== -1) {\n return true;\n }\n } else if (/\\/\\*$/.test(validType)) {\n // Check for mime type that looks like \"image/*\" or similar.\n if (baseMimeType === validType.replace(/\\/.*$/, '')) {\n return true;\n }\n } else {\n if (fileMimeType === validType) {\n return true;\n }\n }\n }\n\n return false;\n}\n","const COMMON_MIME_TYPES = new Map([\n // https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types\n ['aac', 'audio/aac'],\n ['abw', 'application/x-abiword'],\n ['arc', 'application/x-freearc'],\n ['avif', 'image/avif'],\n ['avi', 'video/x-msvideo'],\n ['azw', 'application/vnd.amazon.ebook'],\n ['bin', 'application/octet-stream'],\n ['bmp', 'image/bmp'],\n ['bz', 'application/x-bzip'],\n ['bz2', 'application/x-bzip2'],\n ['cda', 'application/x-cdf'],\n ['csh', 'application/x-csh'],\n ['css', 'text/css'],\n ['csv', 'text/csv'],\n ['doc', 'application/msword'],\n ['docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],\n ['eot', 'application/vnd.ms-fontobject'],\n ['epub', 'application/epub+zip'],\n ['gz', 'application/gzip'],\n ['gif', 'image/gif'],\n ['heic', 'image/heic'],\n ['heif', 'image/heif'],\n ['htm', 'text/html'],\n ['html', 'text/html'],\n ['ico', 'image/vnd.microsoft.icon'],\n ['ics', 'text/calendar'],\n ['jar', 'application/java-archive'],\n ['jpeg', 'image/jpeg'],\n ['jpg', 'image/jpeg'],\n ['jxl', 'image/jxl'],\n ['js', 'text/javascript'],\n ['json', 'application/json'],\n ['jsonld', 'application/ld+json'],\n ['mid', 'audio/midi'],\n ['midi', 'audio/midi'],\n ['mjs', 'text/javascript'],\n ['mp3', 'audio/mpeg'],\n ['mp4', 'video/mp4'],\n ['mpeg', 'video/mpeg'],\n ['mpkg', 'application/vnd.apple.installer+xml'],\n ['odp', 'application/vnd.oasis.opendocument.presentation'],\n ['ods', 'application/vnd.oasis.opendocument.spreadsheet'],\n ['odt', 'application/vnd.oasis.opendocument.text'],\n ['oga', 'audio/ogg'],\n ['ogv', 'video/ogg'],\n ['ogx', 'application/ogg'],\n ['opus', 'audio/opus'],\n ['otf', 'font/otf'],\n ['png', 'image/png'],\n ['pdf', 'application/pdf'],\n ['php', 'application/x-httpd-php'],\n ['ppt', 'application/vnd.ms-powerpoint'],\n ['pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'],\n ['rar', 'application/vnd.rar'],\n ['rtf', 'application/rtf'],\n ['sh', 'application/x-sh'],\n ['svg', 'image/svg+xml'],\n ['swf', 'application/x-shockwave-flash'],\n ['tar', 'application/x-tar'],\n ['tif', 'image/tiff'],\n ['tiff', 'image/tiff'],\n ['ts', 'video/mp2t'],\n ['ttf', 'font/ttf'],\n ['txt', 'text/plain'],\n ['vsd', 'application/vnd.visio'],\n ['wav', 'audio/wav'],\n ['weba', 'audio/webm'],\n ['webm', 'video/webm'],\n ['webp', 'image/webp'],\n ['woff', 'font/woff'],\n ['woff2', 'font/woff2'],\n ['xhtml', 'application/xhtml+xml'],\n ['xls', 'application/vnd.ms-excel'],\n ['xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],\n ['xml', 'application/xml'],\n ['xul', 'application/vnd.mozilla.xul+xml'],\n ['zip', 'application/zip'],\n ['7z', 'application/x-7z-compressed'],\n\n // Others\n ['mkv', 'video/x-matroska'],\n ['mov', 'video/quicktime'],\n ['msg', 'application/vnd.ms-outlook']\n]);\n\nconst FILES_TO_IGNORE = [\n // Thumbnail cache files for macOS and Windows\n '.DS_Store', // macOs\n 'Thumbs.db' // Windows\n];\n\n/**\n * Adds a `type` property to the file object if it doesn't have one and the file has an extension.\n * This is needed because Firefox doesn't add a type property to files dragged from the desktop.\n * @bug https://bugzilla.mozilla.org/show_bug.cgi?id=1424689\n *\n * @param {File} file The file object to add the type property to.\n * @returns {File} The file object with the type property added.\n */\nconst toFileWithMimeType = file => {\n const { name } = file;\n const hasExtension = name && name.lastIndexOf('.') !== -1;\n\n if (hasExtension && !file.type) {\n const extension = name.split('.').pop().toLowerCase();\n const type = COMMON_MIME_TYPES.get(extension);\n\n if (type) {\n Object.defineProperty(file, 'type', {\n value: type,\n writable: false,\n configurable: false,\n enumerable: true\n });\n }\n }\n\n return file;\n};\n\n/**\n * Adds a `path` property to the file object if it doesn't have one.\n * If `path` is not provided, the `webkitRelativePath` property of the file will be used\n * or the file's name if `webkitRelativePath` is not available.\n *\n * @param {File} file The file object to add the path property to.\n * @param {String} [path] The path to set on the file object.\n * @returns {File} The file object with the path property added.\n */\nconst toFileWithPath = (file, path) => {\n const fileWithMimeType = toFileWithMimeType(file);\n\n if (typeof fileWithMimeType.path !== 'string') {\n const { webkitRelativePath } = file;\n\n Object.defineProperty(fileWithMimeType, 'path', {\n value: typeof path === 'string' ? path : webkitRelativePath || file.name,\n writable: false,\n configurable: false,\n enumerable: true\n });\n }\n\n return fileWithMimeType;\n};\n\n/**\n * Wrap `FileSystemDirectoryReader.readEntries` in a promise to make working with read entries easier.\n * https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryReader/readEntries\n *\n * @param {FileSystemDirectoryReader} directoryReader The directory reader to read entries from.\n * @returns {Promise<FileSystemFileEntry[]>} A promise that resolves with an array of `FileSystemFileEntry` objects.\n */\nconst readEntriesPromise = async directoryReader => {\n return await new Promise((resolve, reject) => {\n directoryReader.readEntries(resolve, reject);\n });\n};\n\n/**\n * Read all entries in a directory or sub-directory\n * by calling `readEntries` until it returns an empty array.\n *\n * @param {FileSystemDirectoryReader} directoryReader The directory reader to read entries from.\n * @returns {Promise<FileSystemFileEntry[]>} A promise that resolves with an array of `FileSystemFileEntry` objects.\n */\nconst readAllDirectoryEntries = async directoryReader => {\n const entries = [];\n let readEntries = await readEntriesPromise(directoryReader);\n\n while (readEntries.length > 0) {\n entries.push(...readEntries);\n readEntries = await readEntriesPromise(directoryReader);\n }\n\n return entries;\n};\n\n/**\n * Get a `File` object from a `FileSystemFileEntry` object.\n *\n * @param {FileSystemFileEntry} fileEntry The file entry to get a `File` object from.\n * @returns {Promise<File>} A promise that resolves with a `File` object.\n */\nconst getFileFromFileEntry = fileEntry => {\n return new Promise((resolve, reject) => {\n fileEntry.file(file => resolve(toFileWithPath(file, fileEntry.fullPath)), reject);\n });\n};\n\n/**\n * Get an array of `File` objects from a `DataTransferItemList` object.\n *\n * @param {DataTransferItemList} dataTransferItemList The item list to get an array of `File` objects from.\n * @returns {Promise<File[]>} A promise that resolves with an array of `File` objects.\n */\nconst getFilesFromDataTransferItemList = async dataTransferItemList => {\n const files = [];\n\n // Chromium browsers read only 100 files at a time as per the spec, so we need to use\n // BFS (Breadth-first search) to traverse the entire directory/file structure.\n // https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/webkitGetAsEntry#javascript_content\n const queue = [];\n\n for (const item of dataTransferItemList) {\n if (item.kind !== 'file') {\n // Ignore non-file items, such as links.\n continue;\n }\n\n // https://developer.mozilla.org/docs/Web/API/DataTransferItem/webkitGetAsEntry\n // This function is implemented as `webkitGetAsEntry()` in non-WebKit browsers\n // including Firefox at this time but it may be renamed to `getAsEntry()` in the future.\n const entry = item.getAsEntry ? item.getAsEntry() : item.webkitGetAsEntry();\n\n queue.push(entry);\n }\n\n while (queue.length > 0) {\n const entry = queue.shift();\n\n if (!entry) {\n continue;\n } else if (entry.isFile) {\n const file = await getFileFromFileEntry(entry);\n\n if (FILES_TO_IGNORE.indexOf(file.name) === -1) {\n files.push(file);\n }\n } else if (entry.isDirectory) {\n queue.push(...await readAllDirectoryEntries(entry.createReader()));\n }\n }\n\n return files;\n};\n\n/**\n * Get an array of `File` objects from a `FileList` object.\n *\n * @param {FileList} fileList The file list to get an array of `File` objects from.\n * @returns {Promise<File[]>} A promise that resolves with an array of `File` objects.\n */\nconst getFilesFromFileList = async fileList => {\n const files = [];\n\n for (const file of fileList) {\n if (FILES_TO_IGNORE.indexOf(file.name) === -1) {\n files.push(toFileWithPath(file));\n }\n }\n\n return files;\n};\n\n/**\n * Get an array of `File` objects from an event.\n * This function supports both `drop` and `change` events.\n *\n * @param {DragEvent | Event} evt The event to get an array of `File` objects from.\n * @returns {Promise<File[]>} A promise that resolves with an array of `File` objects.\n */\nexport const getFilesFromEvent = async evt => {\n if (evt.dataTransfer) {\n return evt.dataTransfer.items\n ? await getFilesFromDataTransferItemList(evt.dataTransfer.items)\n : await getFilesFromFileList(evt.dataTransfer.files);\n }\n\n return await getFilesFromFileList(evt.target.files);\n};\n"],"names":["$f31161edf38949e9$var$COMMON_MIME_TYPES","Map","$f31161edf38949e9$var$FILES_TO_IGNORE","$f31161edf38949e9$var$toFileWithMimeType","file","name","hasExtension","lastIndexOf","type","extension","split","pop","toLowerCase","get","Object","defineProperty","value","writable","configurable","enumerable","$f31161edf38949e9$var$toFileWithPath","path","fileWithMimeType","webkitRelativePath","$f31161edf38949e9$var$readEntriesPromise","directoryReader","Promise","resolve","reject","readEntries","$f31161edf38949e9$var$readAllDirectoryEntries","entries","length","push","$f31161edf38949e9$var$getFileFromFileEntry","fileEntry","fullPath","$f31161edf38949e9$var$getFilesFromDataTransferItemList","dataTransferItemList","files","queue","item","kind","entry","getAsEntry","webkitGetAsEntry","shift","isFile","indexOf","isDirectory","createReader","$f31161edf38949e9$var$getFilesFromFileList","fileList","$f31161edf38949e9$export$6d52664cd15c442","evt","dataTransfer","items","target","$862aa3736b0514bc$var$COMPONENT_NAME","$862aa3736b0514bc$var$TOO_MANY_FILES","$862aa3736b0514bc$var$template","document","createElement","innerHTML","$862aa3736b0514bc$export$6ccd1735166caad9","HTMLElement","fileInput","dropzoneEl","constructor","shadowRoot","attachShadow","mode","appendChild","content","cloneNode","getElementById","observedAttributes","attributeChangedCallback","oldValue","newValue","accept","disabled","removeAttribute","setAttribute","multiple","noKeyboard","connectedCallback","upgradeProperty","addEventListener","onFileInputChange","onDragEnter","onDragOver","onDragLeave","onDrop","onClick","onKeyUp","autoFocus","focus","disconnectedCallback","removeEventListener","getAttribute","hasAttribute","maxFiles","num","Number","Infinity","Math","floor","abs","maxSize","isNaN","minSize","noClick","noDrag","noStyle","handleFilesSelect","error","dispatchEvent","CustomEvent","bubbles","composed","detail","Event","preventDefault","dropEffect","classList","add","part","remove","click","key","Array","isArray","acceptedFiles","rejectedFiles","filesLength","errors","code","message","fileHasValidType","acceptedTypeSpecifiers","acceptedMimeTypesList","Set","map","v","trim","filter","Boolean","fileMimeType","baseMimeType","replace","validType","charAt","test","fileExceedsMaxSize","size","fileIsSmallerThanMinSize","defaultValue","openFileDialog","prop","prototype","hasOwnProperty","call","defineCustomElement","elementName","window","customElements","define","FilesDropzone"],"version":3,"file":"files-dropzone.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@georapbox/files-dropzone-element",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "A custom element that creates a drag and drop zone for files",
|
|
5
5
|
"main": "dist/files-dropzone.js",
|
|
6
6
|
"module": "dist/files-dropzone.js",
|
|
@@ -66,14 +66,14 @@
|
|
|
66
66
|
"homepage": "https://github.com/georapbox/files-dropzone-element#readme",
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@esm-bundle/chai": "~4.3.4-fix.0",
|
|
69
|
-
"@open-wc/testing": "~3.
|
|
70
|
-
"@web/test-runner": "~0.
|
|
71
|
-
"@web/test-runner-playwright": "~0.
|
|
72
|
-
"eslint": "~8.
|
|
73
|
-
"eslint-plugin-wc": "~1.
|
|
69
|
+
"@open-wc/testing": "~3.2.0",
|
|
70
|
+
"@web/test-runner": "~0.16.1",
|
|
71
|
+
"@web/test-runner-playwright": "~0.10.1",
|
|
72
|
+
"eslint": "~8.42.0",
|
|
73
|
+
"eslint-plugin-wc": "~1.5.0",
|
|
74
74
|
"npm-run-all": "~4.1.5",
|
|
75
|
-
"parcel": "~2.
|
|
76
|
-
"rimraf": "~
|
|
77
|
-
"sinon": "~15.0
|
|
75
|
+
"parcel": "~2.9.2",
|
|
76
|
+
"rimraf": "~5.0.1",
|
|
77
|
+
"sinon": "~15.1.0"
|
|
78
78
|
}
|
|
79
79
|
}
|