@georapbox/files-dropzone-element 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 George Raptis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,204 @@
1
+ [![npm version](https://img.shields.io/npm/v/@georapbox/files-dropzone-element.svg)](https://www.npmjs.com/package/@georapbox/files-dropzone-element)
2
+ [![npm license](https://img.shields.io/npm/l/@georapbox/files-dropzone-element.svg)](https://www.npmjs.com/package/@georapbox/files-dropzone-element)
3
+
4
+ [demo]: https://georapbox.github.io/files-dropzone-element/
5
+ [getUserMedia]: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia
6
+ [MediaDevices]: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices
7
+ [constraints]: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#parameters
8
+ [license]: https://georapbox.mit-license.org/@2023
9
+ [changelog]: https://github.com/georapbox/files-dropzone-element/blob/main/CHANGELOG.md
10
+
11
+ # <files-dropzone>
12
+
13
+ A custom element that creates a drag and drop zone for files.
14
+
15
+ Note that the element does not provide any functionality for uploading files. Once files are dropped, you are free to process them however you like.
16
+
17
+ [API documentation](#api) • [Demo][demo]
18
+
19
+ ## Install
20
+
21
+ ```sh
22
+ $ npm install --save @georapbox/files-dropzone-element
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ### Script
28
+
29
+ ```js
30
+ import { FilesDropzone } from './node_modules/@georapbox/files-dropzone-element/dist/files-dropzone.js';
31
+
32
+ // Manually define the element.
33
+ FilesDropzone.defineCustomElement();
34
+ ```
35
+
36
+ Alternatively, you can import the automatically defined custom element.
37
+
38
+ ```js
39
+ import './node_modules/@georapbox/files-dropzone-element/dist/files-dropzone-defined.js';
40
+ ```
41
+
42
+ ### Markup
43
+
44
+ ```html
45
+ <files-dropzone accept="image/*,.txt,application/pdf" multiple></files-dropzone>
46
+ ```
47
+
48
+ ### Style
49
+
50
+ By default, the component comes with basic styling. However, you can customise the styles of the various elements of the component using either [CSS Parts](#css-parts) or [CSS Custom Properties](#css-custom-properties).
51
+
52
+ ## API
53
+
54
+ ### Properties
55
+ | Name | Reflects | Type | Required | Default | Description |
56
+ | ---- | -------- | ---- | -------- | ------- | ----------- |
57
+ | `accept`<sup>1</sup> | ✓ | String | - | `null` | A string containing one or more of unique file type specifiers, separated by commas. Files that do not match one of the accepted file type specifiers, will be rejected. |
58
+ | `disabled` | ✓ | Boolean | - | `false` | Disables the dropzone. |
59
+ | `maxFiles`<br>*`max-files`* | ✓ | Number | - | `Infinity` | Maximum accepted number of files. Note that this property has effect only when `multiple` is set to true. If its value is set to `0` or any negative number, it will allow any number of files. If the number of dropped files is greater than the value set, all of the files will be rejected to avoid making unsafe assumptions on which files to accept. |
60
+ | `maxSize`<br>*`max-size`* | ✓ | Number | - | `Infinity` | Maximum file size (in bytes). |
61
+ | `minSize`<br>*`min-size`* | ✓ | Number | - | `0` | Minimum file size (in bytes). |
62
+ | `multiple` | ✓ | Boolean | - | `false` | If set, allows drag 'n' drop (or selection from the file dialog) of multiple files. If it is not set and many files are dropped, all of them will be rejected to avoid making unsafe assumptions on which files to accept. |
63
+ | `noClick`<br>*`no-click`* | ✓ | Boolean | - | `false` | If set, disables the ability to select files by clicking on the dropzone area, using the native file dialog. |
64
+ |`noDrag`<br>*`no-drag`*| ✓ | Boolean | - | `false` | If set, disables drag 'n' drop. |
65
+ | `noKeyboard`<br>*`no-keyboard`* | ✓ | Boolean | - | `false` | If set, disables the ability to select files using the SPACE/ENTER keys and also disables the ability to focus on the element using the keyboard. |
66
+ | `noStyle`<br>*`no-style`* | ✓ | Boolean | - | `false` | If set, it will remove all default styling. It can be useful in cases you want to style the component's parts from scratch. Note that the available [CSS Custom Properties](#css-custom-properties) can still be used. |
67
+
68
+ <sup>1</sup> Each unique file type specifier may take one of the following forms:
69
+ - A valid case-insensitive filename extension, starting with a period (".") character. For example: `.jpg`, `.pdf`, or `.doc`.
70
+ - A valid MIME type string, with no extensions.
71
+ - A string to match any file of a specific type. For example: `image/*` for image files, `audio/*` for audio files, etc.
72
+ - Any comination of the above. For example: `image/*,.docx,application/pdf`
73
+
74
+ ### Slots
75
+
76
+ | Name | Description |
77
+ | ---- | ----------- |
78
+ | (default) | Un-named slot to override the default content of the dropzone area. |
79
+
80
+ ### CSS Parts
81
+
82
+ | Name | Description |
83
+ | ---- | ----------- |
84
+ | `dropzone` | The dropzone area. |
85
+ | `dropzone--dragover` | The state of the dropzone when dragging over it. |
86
+
87
+ ### CSS Custom Properties
88
+
89
+ | Name | Description | Default |
90
+ | ---- | ----------- | ------- |
91
+ | `--dropzone-border-radius` | The border radius of the dropzone area. | `0.25rem` |
92
+ | `--dropzone-border-width` | The border width of the dropzone area. | `2px` |
93
+ | `--dropzone-border-style` | The border style of the dropzone area. | `dashed` |
94
+ | `--dropzone-border-color` | The border color of the dropzone area. | `#71717a` |
95
+ | `--dropzone-border-color-dragover` | The border color of the dropzone area in dragover state. | `#38bdf8` |
96
+ | `--dropzone-background-color` | The background color of the dropzone area. | `#ffffff` |
97
+ | `--dropzone-background-color-dragover` | The background color of the dropzone area in dragover state. | `#f4f4f5` |
98
+ | `--dropzone-body-color` | The text color of the dropzone area. | `#3f3f46` |
99
+ | `--dropzone-body-color-dragover` | The text color of the dropzone area in dragover state. | `#3f3f46` |
100
+
101
+ ### Methods
102
+
103
+ | Name | Type | Description | Arguments |
104
+ | ---- | ---- | ----------- | --------- |
105
+ | `defineCustomElement` | Static | Defines/registers the custom element with the name provided. If no name is provided, the default name is used. The method checks if the element is already defined, hence will skip trying to redefine it. | elementName='files-dropzone' |
106
+ | `openFileDialog` | Prototype | Opens the native file dialog programmatically. The method will fail silently if the dropzone is disabled. Note that most browsers require a direct user interaction with the document, to open the file dialog, for security reasons. Therefore, if you are trying to call this method asynchronously, there's a good chance it's going to be blocked by the browser. For example in Safari 15.x, invoking this method inside a `setTimeout` with more that 1000ms delay, the dialog will not open. | - |
107
+
108
+ ### Events
109
+
110
+ | Name | Description | Event Detail |
111
+ | ---- | ----------- | ------------ |
112
+ | `files-dropzone-drop` | Emitted when one or more files are selected, either by using the native file dialog or dropping files in the dropzone area. The event is emitted regardless if the dropped files are accepted or rejected. Files are accepted or rejected based on the `accept`, `max-files`, `max-size`, `min-size` and `multiple` attributes. | `{acceptedFiles: Array<File>, rejectedFiles: Array<{file: File, errors: Array<{code: 'TOO_MANY_FILES' \| 'FILE_TOO_LARGE' \| FILE_TOO_SMALL \| 'INVALID_MIME_TYPE', message: string}>}>}` |
113
+ | `files-dropzone-drop-accepted` | Emitted when one or more dropped files are accepted. If no files are accepted, the event is not emitted at all. | `{acceptedFiles: Array<File>}` |
114
+ | `files-dropzone-drop-rejected` | Emitted when one or more dropped files are rejected. If no files are rejected, the event is not emitted at all. | `{rejectedFiles: Array<{file: File, errors: Array<{code: 'TOO_MANY_FILES' \| 'FILE_TOO_LARGE' \| FILE_TOO_SMALL \| 'INVALID_MIME_TYPE', message: string}>}>}` |
115
+ | `files-dropzone-dragenter` | Emitted on `dragenter` event. The event is not emitted if `disabled` or `no-drag` attributes are set. | - |
116
+ | `files-dropzone-dragover` | Emitted on `dragover` event. The event is not emitted if `disabled` or `no-drag` attributes are set. | - |
117
+ | `files-dropzone-dragleave` | Emitted on `dragleave` event. The event is not emitted if `disabled` or `no-drag` attributes are set. | - |
118
+ | `files-dropzone-error` | Emitted if there is any error in the process of reading dropped files or directories. | `{error: any}` |
119
+
120
+ ## Usage example
121
+
122
+ Below is a basic usage example of the custom element that also demonstrates styles customization.
123
+
124
+ ```html
125
+ <head>
126
+ <style>
127
+ files-dropzone {
128
+ --dropzone-border-color: #dbdbdb;
129
+ --dropzone-border-color-dragover: #0096bfab;
130
+ --dropzone-background-color: #f7f7f7;
131
+ --dropzone-background-color-dragover: #efefef;
132
+ --dropzone-body-color: #363636;
133
+ --dropzone-body-color-dragover: #363636;
134
+ }
135
+
136
+ files-dropzone::part(dropzone) {
137
+ display: flex;
138
+ flex-direction: column;
139
+ gap: 0.5rem;
140
+ }
141
+
142
+ @media (prefers-color-scheme: dark) {
143
+ files-dropzone {
144
+ --dropzone-border-color: #526980;
145
+ --dropzone-border-color-dragover: #0096bfab;
146
+ --dropzone-background-color: #1a242f;
147
+ --dropzone-background-color-dragover: #161f27;
148
+ --dropzone-body-color: #dbdbdb;
149
+ --dropzone-body-color-dragover: #dbdbdb;
150
+ }
151
+ }
152
+ </style>
153
+ </head>
154
+
155
+ <body>
156
+ <files-dropzone accept="image/png,image/jpg" multiple>
157
+ <span>Drag 'n' drop files here, or click to select files</span>
158
+ <small>Accepted file types: <code>png</code>, <code>jpg</code></small>
159
+ </files-dropzone>
160
+
161
+ <h3>Accepted files</h3>
162
+ <ul id="accepted-files"></ul>
163
+
164
+ <h3>Rejected files</h3>
165
+ <ul id="rejected-files"></ul>
166
+
167
+ <script type="module">
168
+ import { FilesDropzone } from 'https://unpkg.com/@georapbox/files-dropzone-element';
169
+
170
+ FilesDropzone.defineCustomElement();
171
+
172
+ const drozone = document.querySelector('files-dropzone');
173
+ const acceptedFilesList = document.getElementById('accepted-files');
174
+ const rejectedFilesList = document.getElementById('rejected-files');
175
+
176
+ dropzone.addEventListener('files-dropzone-drop', evt => {
177
+ const { acceptedFiles, rejectedFiles } = evt.detail;
178
+
179
+ acceptedFilesList.replaceChildren();
180
+ rejectedFilesList.replaceChildren();
181
+
182
+ acceptedFiles.forEach(file => {
183
+ const li = document.createElement('li');
184
+ li.textContent = `${file.name} - ${file.size} bytes`;
185
+ acceptedFilesList.appendChild(li);
186
+ });
187
+
188
+ rejectedFiles.forEach(file => {
189
+ const li = document.createElement('li');
190
+ li.textContent = `${file.name} - ${file.size} bytes`;
191
+ rejectedFilesList.appendChild(li);
192
+ });
193
+ });
194
+ </script>
195
+ </body>
196
+ ```
197
+
198
+ ## Changelog
199
+
200
+ For API updates and breaking changes, check the [CHANGELOG][changelog].
201
+
202
+ ## License
203
+
204
+ [The MIT License (MIT)][license]
@@ -0,0 +1,2 @@
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 p(e,t,i){return d(e,n(e,t,"set"),i),i}function c(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: #71717a;\n --dropzone-border-color-dragover: #0ea5e9;\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\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 0.2s ease-in-out, background-color 0.2s ease-in-out, color 0.2s 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 </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,j=new WeakMap,S=new WeakMap,C=new WeakMap,F=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(){c(this,D,W).call(this,"accept"),c(this,D,W).call(this,"disabled"),c(this,D,W).call(this,"maxFiles"),c(this,D,W).call(this,"maxSize"),c(this,D,W).call(this,"minSize"),c(this,D,W).call(this,"multiple"),c(this,D,W).call(this,"noClick"),c(this,D,W).call(this,"noDrag"),c(this,D,W).call(this,"noKeyboard"),c(this,D,W).call(this,"noStyle"),a(this,A).addEventListener("change",a(this,j)),a(this,L).addEventListener("dragenter",a(this,S)),a(this,L).addEventListener("dragover",a(this,C)),a(this,L).addEventListener("dragleave",a(this,F)),a(this,L).addEventListener("drop",a(this,T)),a(this,L).addEventListener("click",a(this,M)),a(this,L).addEventListener("keyup",a(this,$))}disconnectedCallback(){a(this,A).removeEventListener("change",a(this,j)),a(this,L).removeEventListener("dragenter",a(this,S)),a(this,L).removeEventListener("dragover",a(this,C)),a(this,L).removeEventListener("dragleave",a(this,F)),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 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,j,{writable:!0,value:async e=>{try{c(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,S,{writable:!0,value:()=>{this.disabled||this.noDrag||this.dispatchEvent(new Event(`${z}-dragenter`,{bubbles:!0,composed:!0}))}}),l(this,C,{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,F,{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{c(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))),p(this,A,this.shadowRoot.getElementById("fileInput")),p(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};
2
+ //# sourceMappingURL=files-dropzone-defined.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"YAAe,SAAAA,EAAsCC,EAAUC,EAAYC,GACzE,IAAKD,EAAWE,IAAIH,GAClB,MAAM,IAAII,UA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CACpEiE,SAAS,EACTC,UAAU,EACVC,OAAQ,C,cACNkB,MAKNzK,EAAA6G,KAAMnB,GAAU3F,MAAQC,EAAA6G,KAAMnB,GAAUwF,YAC1C,CAgBA,SAAA7D,EAAiB8D,GACf,GAAItI,OAAOuI,UAAUC,eAAevL,KAAK+G,KAAMsE,GAAO,CACpD,MAAMpL,EAAQ8G,KAAKsE,UACZtE,KAAKsE,GACZtE,KAAKsE,GAAQpL,CACf,CACF,CC7eFwG,EAAc+E,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: #71717a;\n --dropzone-border-color-dragover: #0ea5e9;\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\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 0.2s ease-in-out, background-color 0.2s ease-in-out, color 0.2s 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 </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('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\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 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","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"}
@@ -0,0 +1,2 @@
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 p=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"]]),c=[".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=p.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},m=async e=>await new Promise(((t,i)=>{e.readEntries(t,i)})),u=async e=>{const t=[];let i=await m(e);for(;i.length>0;)t.push(...i),i=await m(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===c.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===c.indexOf(i.name)&&t.push(i)}else e.isDirectory&&i.push(...await u(e.createReader()))}return t})(e.dataTransfer.items):await f(e.dataTransfer.files):await f(e.target.files),g="files-dropzone",w="TOO_MANY_FILES",y=document.createElement("template");y.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: #71717a;\n --dropzone-border-color-dragover: #0ea5e9;\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\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 0.2s ease-in-out, background-color 0.2s ease-in-out, color 0.2s 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 </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 x=new WeakMap,z=new WeakMap,E=new WeakMap,k=new WeakMap,A=new WeakMap,L=new WeakMap,j=new WeakMap,S=new WeakMap,C=new WeakMap,F=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,x)&&(i(this,x).accept=this.accept),"disabled"===e&&t!==o&&i(this,x)&&(i(this,x).disabled=this.disabled,this.disabled?i(this,z).removeAttribute("tabindex"):i(this,z).setAttribute("tabindex","0")),"multiple"===e&&t!==o&&i(this,x)&&(i(this,x).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,"noStyle"),i(this,x).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,j)),i(this,z).addEventListener("click",i(this,S)),i(this,z).addEventListener("keyup",i(this,C))}disconnectedCallback(){i(this,x).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,j)),i(this,z).removeEventListener("click",i(this,S)),i(this,z).removeEventListener("keyup",i(this,C))}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 noStyle(){return this.hasAttribute("no-style")}set noStyle(e){e?this.setAttribute("no-style",""):this.removeAttribute("no-style")}openFileDialog(){this.disabled||i(this,x).click()}static defineCustomElement(e=g){"undefined"==typeof window||window.customElements.get(e)||window.customElements.define(e,M)}constructor(){super(),l(this,F),l(this,T),n(this,x,{writable:!0,value:void 0}),n(this,z,{writable:!0,value:void 0}),n(this,E,{writable:!0,value:async e=>{try{r(this,F,$).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,j,{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,F,$).call(this,await v(e))}catch(e){this.dispatchEvent(new CustomEvent(`${g}-error`,{bubbles:!0,composed:!0,detail:{error:e}}))}}}}),n(this,S,{writable:!0,value:()=>{this.disabled||this.noClick||i(this,x).click()}}),n(this,C,{writable:!0,value:e=>{this.disabled||this.noKeyboard||" "!==e.key&&"Enter"!==e.key||i(this,x).click()}}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(y.content.cloneNode(!0))),a(this,x,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,x).value=i(this,x).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};
2
+ //# sourceMappingURL=files-dropzone.js.map
@@ -0,0 +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,EAA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G,KAAKsE,UACZtE,KAAKsE,GACZtE,KAAKsE,GAAQpL,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: #71717a;\n --dropzone-border-color-dragover: #0ea5e9;\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\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 0.2s ease-in-out, background-color 0.2s ease-in-out, color 0.2s 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 </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('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\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 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","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"}
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "@georapbox/files-dropzone-element",
3
+ "version": "1.0.0",
4
+ "description": "A custom element that creates a drag and drop zone for files",
5
+ "main": "dist/files-dropzone.js",
6
+ "module": "dist/files-dropzone.js",
7
+ "unpkg": "dist/files-dropzone.js",
8
+ "type": "module",
9
+ "targets": {
10
+ "files-dropzone": {
11
+ "context": "browser",
12
+ "outputFormat": "esmodule",
13
+ "source": "src/files-dropzone.js",
14
+ "optimize": true,
15
+ "isLibrary": true,
16
+ "distDir": "dist",
17
+ "engines": {
18
+ "browsers": "> 0.5%, last 2 versions, not dead"
19
+ }
20
+ },
21
+ "files-dropzone-defined": {
22
+ "context": "browser",
23
+ "outputFormat": "esmodule",
24
+ "source": "src/files-dropzone-defined.js",
25
+ "optimize": true,
26
+ "isLibrary": true,
27
+ "distDir": "dist",
28
+ "engines": {
29
+ "browsers": "> 0.5%, last 2 versions, not dead"
30
+ }
31
+ }
32
+ },
33
+ "files": [
34
+ "/src",
35
+ "/dist"
36
+ ],
37
+ "scripts": {
38
+ "lint": "eslint . --ext .js",
39
+ "test": "web-test-runner",
40
+ "test:watch": "npm run test -- --watch",
41
+ "test:coverage": "npm run test -- --coverage",
42
+ "dev:parcel": "parcel watch",
43
+ "dev": "npm-run-all clean dev:parcel",
44
+ "build:parcel": "parcel build",
45
+ "build": "npm-run-all clean build:parcel",
46
+ "clean": "rimraf dist .parcel-cache",
47
+ "prepare": "npm-run-all clean lint test build"
48
+ },
49
+ "keywords": [
50
+ "custom element",
51
+ "web component",
52
+ "files dropzone"
53
+ ],
54
+ "author": {
55
+ "name": "George Raptis",
56
+ "email": "georapbox@gmail.com"
57
+ },
58
+ "repository": {
59
+ "type": "git",
60
+ "url": "git+https://github.com/georapbox/files-dropzone-element.git"
61
+ },
62
+ "license": "MIT",
63
+ "bugs": {
64
+ "url": "https://github.com/georapbox/files-dropzone-element/issues"
65
+ },
66
+ "homepage": "https://github.com/georapbox/files-dropzone-element#readme",
67
+ "devDependencies": {
68
+ "@esm-bundle/chai": "~4.3.4-fix.0",
69
+ "@open-wc/testing": "~3.1.7",
70
+ "@web/test-runner": "~0.15.0",
71
+ "@web/test-runner-playwright": "~0.9.0",
72
+ "eslint": "~8.33.0",
73
+ "eslint-plugin-wc": "~1.4.0",
74
+ "npm-run-all": "~4.1.5",
75
+ "parcel": "~2.8.3",
76
+ "rimraf": "~4.1.2",
77
+ "sinon": "~15.0.1"
78
+ }
79
+ }
@@ -0,0 +1,5 @@
1
+ import { FilesDropzone } from './files-dropzone.js';
2
+
3
+ FilesDropzone.defineCustomElement();
4
+
5
+ export { FilesDropzone };