@georapbox/files-dropzone-element 2.1.1 → 3.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.
Files changed (49) hide show
  1. package/.editorconfig +15 -0
  2. package/.nvmrc +1 -0
  3. package/.prettierignore +6 -0
  4. package/.prettierrc +11 -0
  5. package/.vscode/extensions.json +8 -0
  6. package/.vscode/settings.json +8 -0
  7. package/.zed/settings.json +9 -0
  8. package/CHANGELOG.md +144 -0
  9. package/README.md +119 -103
  10. package/custom-elements-manifest.config.mjs +48 -0
  11. package/dist/custom-elements.json +509 -0
  12. package/dist/files-dropzone-defined.d.ts +1 -1
  13. package/dist/files-dropzone-defined.d.ts.map +1 -1
  14. package/dist/files-dropzone-defined.js +5 -5
  15. package/dist/files-dropzone-defined.js.map +4 -4
  16. package/dist/files-dropzone.d.ts +55 -68
  17. package/dist/files-dropzone.d.ts.map +1 -1
  18. package/dist/files-dropzone.js +5 -5
  19. package/dist/files-dropzone.js.map +4 -4
  20. package/dist/files-selector.d.ts +9 -0
  21. package/dist/files-selector.d.ts.map +1 -0
  22. package/dist/{utils/is-valid-file.d.ts → is-valid-file.d.ts} +1 -1
  23. package/dist/is-valid-file.d.ts.map +1 -0
  24. package/docs/css/main.css +190 -0
  25. package/docs/css/water.css +674 -0
  26. package/docs/favicon-32x32.png +0 -0
  27. package/docs/index.html +144 -0
  28. package/docs/js/main.js +154 -0
  29. package/docs/lib/files-dropzone.js +93 -0
  30. package/docs/lib/highlight/highlight-github.css +160 -0
  31. package/docs/lib/highlight/highlight.min.js +1160 -0
  32. package/eslint.config.mjs +42 -0
  33. package/package.json +52 -30
  34. package/scripts/build.mjs +32 -0
  35. package/scripts/copy-build-to-docs.mjs +17 -0
  36. package/scripts/dev.mjs +24 -0
  37. package/src/files-dropzone-defined.js +1 -1
  38. package/src/files-dropzone.js +70 -89
  39. package/test/files-dropzone-upgrade.test.js +39 -0
  40. package/test/files-dropzone.test.js +397 -0
  41. package/test/files-selector.test.js +96 -0
  42. package/test/is-valid-file.test.js +78 -0
  43. package/tsconfig.json +15 -0
  44. package/web-test-runner.config.js +13 -0
  45. package/dist/utils/files-selector.d.ts +0 -2
  46. package/dist/utils/files-selector.d.ts.map +0 -1
  47. package/dist/utils/is-valid-file.d.ts.map +0 -1
  48. /package/src/{utils/files-selector.js → files-selector.js} +0 -0
  49. /package/src/{utils/is-valid-file.js → is-valid-file.js} +0 -0
package/.editorconfig ADDED
@@ -0,0 +1,15 @@
1
+ # EditorConfig is awesome: https://EditorConfig.org
2
+
3
+ # top-most EditorConfig file
4
+ root = true
5
+
6
+ [*]
7
+ indent_style = space
8
+ indent_size = 2
9
+ end_of_line = lf
10
+ charset = utf-8
11
+ trim_trailing_whitespace = true
12
+ insert_final_newline = true
13
+
14
+ [*.md]
15
+ trim_trailing_whitespace = false
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ 24
@@ -0,0 +1,6 @@
1
+ **/*.html
2
+ **/*.css
3
+ **/*.md
4
+ docs/lib/**
5
+ .zed/
6
+ .vscode/
package/.prettierrc ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "arrowParens": "avoid",
3
+ "bracketSpacing": true,
4
+ "tabWidth": 2,
5
+ "useTabs": false,
6
+ "printWidth": 120,
7
+ "singleQuote": true,
8
+ "semi": true,
9
+ "trailingComma": "none",
10
+ "singleAttributePerLine": false
11
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "recommendations": [
3
+ "esbenp.prettier-vscode",
4
+ "dbaeumer.vscode-eslint",
5
+ "editorconfig.editorconfig",
6
+ "typescriptteam.native-preview"
7
+ ]
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
3
+ "editor.formatOnSave": true,
4
+ "eslint.enable": true,
5
+ "eslint.run": "onType",
6
+ "eslint.validate": ["javascript", "html"],
7
+ "js/ts.experimental.useTsgo": true
8
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "languages": {
3
+ "JavaScript": {
4
+ "language_servers": ["typescript-ls", "eslint"],
5
+ "formatter": "prettier",
6
+ "format_on_save": "on"
7
+ }
8
+ }
9
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,144 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [3.0.0] - 2026-11-07
11
+
12
+ ### Breaking Changes
13
+
14
+ - **Explicit Package Exports**: Added a formal `exports` map to `package.json`.
15
+ - **Supported entry points**: `@georapbox/files-dropzone-element`, `@georapbox/files-dropzone-element/define`, and `@georapbox/files-dropzone-element/custom-elements.json`.
16
+ - **Impact**: Direct imports from internal paths (e.g., `@georapbox/files-dropzone-element/dist/...`) are no longer part of the supported public API and may fail in environments that enforce package exports.
17
+ - **Method Renaming**: Renamed the static `defineCustomElement()` method to `define()`.
18
+ - **Action Required**: Replace calls to `FilesDropzone.defineCustomElement()` with `FilesDropzone.define()`.
19
+ - **Event Changes**:
20
+ - **Event Renaming**: Renamed all events from `files-dropzone-*` to `dropzone-*` (e.g., `files-dropzone-drop` to `dropzone-drop`).
21
+ - **Event Type Changes**: The `dropzone-dragenter`, `dropzone-dragover`, and `dropzone-dragleave` events are now dispatched as native `Event` instances instead of `CustomEvent` instances.
22
+ - **Action Required**: Update event listeners to use the new event names. Event handlers for drag events should no longer rely on `CustomEvent` or access `event.detail`.
23
+
24
+ ## [2.2.0] - 2026-02-16
25
+
26
+ ### Added
27
+
28
+ - **Custom Elements Manifest Support**: Added support for generating a Custom Elements Manifest (CEM) using `@custom-elements-manifest/analyzer`.
29
+ - **Script**: Added the `analyze` script for generating the manifest.
30
+ - **Configuration**: Added `custom-elements-manifest.config.js`.
31
+ - **Package Metadata**: Added the `customElements` field to `package.json`.
32
+
33
+ ### Changed
34
+
35
+ - **Node.js Version**: Updated `.nvmrc` to Node.js 24.
36
+ - **JSDoc Documentation**: Refined attribute documentation for improved tooling and editor support.
37
+
38
+ ## [2.1.1] - 2025-08-26
39
+
40
+ ### Fixed
41
+
42
+ - **File Dialog Compatibility**: Restored compatibility with browsers that do not support `HTMLInputElement.showPicker()` by falling back to programmatically clicking the hidden file input element.
43
+
44
+ ## [2.1.0] - 2025-08-24
45
+
46
+ ### Added
47
+
48
+ - **File Dialog Error Event**: Added the `files-dropzone-error` event when opening the file dialog fails (e.g., without a user activation gesture).
49
+ - **Error Codes**: Added a `code` field (stable error identifier) to the `files-dropzone-error` event detail.
50
+ - **Static Constants**: Exposed `ERROR_CODES` and `REJECTION_CODES` as static properties on the `FilesDropzone` class for consumer reference.
51
+
52
+ ### Changed
53
+
54
+ - **File Dialog Invocation**: Switched from `.click()` to `HTMLInputElement.showPicker()` for opening the file dialog.
55
+
56
+ ### Fixed
57
+
58
+ - **Firefox Android Compatibility**: Fixed an issue where clicking directly on the default slotted text did not open the file dialog (`NotAllowedError`).
59
+ - **Solution**: Wrapped the default slot content in a `<span>` element to ensure consistent user activation across browsers.
60
+
61
+ ### Maintenance
62
+
63
+ - **Event Dispatching**: Centralized custom event dispatch in a helper method to reduce code duplication.
64
+ - **Dependencies**: Updated development dependencies.
65
+
66
+ ## [2.0.1] - 2024-08-22
67
+
68
+ ### Changed
69
+
70
+ - **Build Tooling**: Replaced Parcel with esbuild for bundling.
71
+ - **Linting**: Updated ESLint to use flat configuration.
72
+ - **Formatting**: Switched to Prettier for code formatting.
73
+ - **Dependencies**: Updated development dependencies.
74
+
75
+ ## [2.0.0] - 2024-02-12
76
+
77
+ ### Breaking Changes
78
+
79
+ - **Removed Attributes**: Removed the `no-click`, `no-keyboard`, and `no-drag` attributes, as they are not recommended for accessibility or usability.
80
+ - **Reference**: See issue [#4](https://github.com/georapbox/files-dropzone-element/issues/4).
81
+
82
+ ### Changed
83
+
84
+ - **Focus Delegation**: Set `delegatesFocus` to `true` when attaching the shadow root to the host element, allowing focus to be delegated to the first focusable element in the shadow root.
85
+ - **Accessibility**: Improved the component's accessibility for screen readers.
86
+ - **Dependencies**: Updated development dependencies.
87
+
88
+ ## [1.2.1] - 2023-12-12
89
+
90
+ ### Added
91
+
92
+ - **MIME Type Support**: Added `.md` and `.markdown` file extensions to common MIME types.
93
+
94
+ ## [1.2.0] - 2023-12-11
95
+
96
+ ### Added
97
+
98
+ - **Transition Duration**: Added the `--dropzone-transition-duration` CSS custom property to control the dropzone's transition duration.
99
+ - **Backward Compatibility**: The existing `--transition-duration` property remains supported.
100
+ - **Hover Styling**: Added `--dropzone-border-color-hover`, `--dropzone-background-color-hover`, and `--dropzone-body-color-hover` CSS custom properties to customize the dropzone's hover state.
101
+ - **Focus Styling**: Added the `--dropzone-focus-box-shadow` CSS custom property to customize the dropzone's focus box shadow.
102
+ - **TypeScript Declarations**: Added a TypeScript declaration file.
103
+
104
+ ### Maintenance
105
+
106
+ - **Dependencies**: Updated development dependencies.
107
+
108
+ ## 1.1.1 - 2023-06-12
109
+
110
+ ### Added
111
+
112
+ - **MIME Type Support**: Added support for the `image/jxl` MIME type.
113
+
114
+ ### Maintenance
115
+
116
+ - **Dependencies**: Updated development dependencies.
117
+
118
+ ## 1.1.0 - 2023-04-03
119
+
120
+ ### Added
121
+
122
+ - **Auto Focus**: Added the `auto-focus` attribute to focus the dropzone when rendered.
123
+ - **Focus Styling**: Added the `--dropzone-focus-shadow-rgb` CSS custom property to customize the focus shadow color.
124
+ - **Transition Duration**: Added the `--transition-duration` CSS custom property to customize the dropzone's transition duration.
125
+
126
+ ### Changed
127
+
128
+ - **Default Border Colors**: Updated the default values of `--dropzone-border-color` and `--dropzone-border-color-dragover`.
129
+
130
+ ## 1.0.0 - 2023-02-01
131
+
132
+ ### Added
133
+
134
+ - **Initial Release**: First release of the project.
135
+
136
+ [Unreleased]: https://github.com/georapbox/files-dropzone-element/compare/v3.0.0...HEAD
137
+ [3.0.0]: https://github.com/georapbox/files-dropzone-element/compare/v2.2.0...v3.0.0
138
+ [2.2.0]: https://github.com/georapbox/files-dropzone-element/compare/v2.1.1...v2.2.0
139
+ [2.1.1]: https://github.com/georapbox/files-dropzone-element/compare/v2.1.0...v2.1.1
140
+ [2.1.0]: https://github.com/georapbox/files-dropzone-element/compare/v2.0.1...v2.1.0
141
+ [2.0.1]: https://github.com/georapbox/files-dropzone-element/compare/v2.0.0...v2.0.1
142
+ [2.0.0]: https://github.com/georapbox/files-dropzone-element/compare/v1.2.1...v2.0.0
143
+ [1.2.1]: https://github.com/georapbox/files-dropzone-element/compare/v1.2.0...v1.2.1
144
+ [1.2.0]: https://github.com/georapbox/files-dropzone-element/releases/tag/v1.2.0
package/README.md CHANGED
@@ -9,42 +9,136 @@
9
9
 
10
10
  A custom element that creates a drag and drop zone for files.
11
11
 
12
- 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.
12
+ > [!NOTE]
13
+ > The element does not provide any functionality for uploading files.
14
+ > Once files are dropped, you are free to process them however you like.
13
15
 
14
16
  [API documentation](#api) &bull; [Demo][demo]
15
17
 
16
- ## Install
18
+ ## Usage
19
+
20
+ ### Installation
17
21
 
18
22
  ```sh
19
23
  $ npm install --save @georapbox/files-dropzone-element
20
24
  ```
21
25
 
22
- ## Usage
26
+ ### Importing the component
27
+
28
+ By default, the package exports the element class without registering it. This lets the application decide when the custom element is defined.
23
29
 
24
- ### Script
30
+ #### Manual definition
25
31
 
26
32
  ```js
27
- import { FilesDropzone } from './node_modules/@georapbox/files-dropzone-element/dist/files-dropzone.js';
33
+ import { FilesDropzone } from '@georapbox/files-dropzone-element';
28
34
 
29
- // Manually define the element.
30
- FilesDropzone.defineCustomElement();
35
+ // Define using the default tag name
36
+ FilesDropzone.define();
31
37
  ```
32
38
 
33
- Alternatively, you can import the automatically defined custom element.
39
+ #### Auto-defined (convenience)
40
+
41
+ If you don't need control over registration, you can import the pre-defined build which immediately registers `<files-dropzone>`.
34
42
 
35
43
  ```js
36
- import './node_modules/@georapbox/files-dropzone-element/dist/files-dropzone-defined.js';
44
+ import '@georapbox/files-dropzone-element/define';
37
45
  ```
38
46
 
39
- ### Markup
47
+ ### Using the component in your HTML
48
+
49
+ Once registered, you can use the <files-dropzone> element in your HTML:
40
50
 
41
51
  ```html
42
52
  <files-dropzone accept="image/*,.txt,application/pdf" multiple></files-dropzone>
43
53
  ```
44
54
 
45
- ### Style
55
+ ### Component styling
56
+
57
+ The component comes with default styling that can be customized using [CSS Parts](#css-parts) and [CSS Custom Properties](#css-custom-properties).
58
+
59
+ ### Complete example
60
+
61
+ This example demonstrates how to customize the dropzone's appearance and handle accepted and rejected files.
62
+
63
+ #### Markup
64
+
65
+ ```html
66
+ <files-dropzone accept="image/png,image/jpeg" multiple>
67
+ <span>Drag 'n' drop files here, or click to select files</span>
68
+ <small>Accepted file types: <code>png</code>, <code>jpg</code></small>
69
+ </files-dropzone>
70
+
71
+ <h3>Accepted files</h3>
72
+ <ul id="accepted-files"></ul>
73
+
74
+ <h3>Rejected files</h3>
75
+ <ul id="rejected-files"></ul>
76
+ ```
77
+
78
+ #### Styling
79
+
80
+ Customize the component using CSS custom properties and the `dropzone` CSS part.
81
+
82
+ ```css
83
+ files-dropzone {
84
+ --dropzone-border-color: #dbdbdb;
85
+ --dropzone-border-color-dragover: #0096bfab;
86
+ --dropzone-background-color: #f7f7f7;
87
+ --dropzone-background-color-dragover: #efefef;
88
+ --dropzone-body-color: #363636;
89
+ --dropzone-body-color-dragover: #363636;
90
+ }
91
+
92
+ files-dropzone::part(dropzone) {
93
+ display: flex;
94
+ flex-direction: column;
95
+ gap: 0.5rem;
96
+ }
97
+
98
+ @media (prefers-color-scheme: dark) {
99
+ files-dropzone {
100
+ --dropzone-border-color: #526980;
101
+ --dropzone-border-color-dragover: #0096bfab;
102
+ --dropzone-background-color: #1a242f;
103
+ --dropzone-background-color-dragover: #161f27;
104
+ --dropzone-body-color: #dbdbdb;
105
+ --dropzone-body-color-dragover: #dbdbdb;
106
+ }
107
+ }
108
+ ```
109
+
110
+ ### Handling events
111
+
112
+ Listen for the `dropzone-drop` event to access accepted and rejected files.
113
+
114
+ ```js
115
+ import { FilesDropzone } from 'https://unpkg.com/@georapbox/files-dropzone-element';
116
+
117
+ FilesDropzone.define();
118
+
119
+ const drozone = document.querySelector('files-dropzone');
120
+ const acceptedFilesList = document.getElementById('accepted-files');
121
+ const rejectedFilesList = document.getElementById('rejected-files');
122
+
123
+ dropzone.addEventListener('dropzone-drop', evt => {
124
+ const { acceptedFiles, rejectedFiles } = evt.detail;
46
125
 
47
- 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).
126
+ acceptedFilesList.replaceChildren();
127
+ rejectedFilesList.replaceChildren();
128
+
129
+ acceptedFiles.forEach(file => {
130
+ const li = document.createElement('li');
131
+ li.textContent = `${file.name} - ${file.size} bytes`;
132
+ acceptedFilesList.appendChild(li);
133
+ });
134
+
135
+ rejectedFiles.forEach(({ file, errors }) => {
136
+ const li = document.createElement('li');
137
+ li.textContent = `${file.name} - ${file.size} bytes (${errors.map(error => error.message).join(', ')})`;
138
+ rejectedFilesList.appendChild(li);
139
+ });
140
+ });
141
+ ```
48
142
 
49
143
  ## API
50
144
 
@@ -103,10 +197,10 @@ By default, the component comes with basic styling. However, you can customise t
103
197
 
104
198
  | Name | Type | Description | Arguments |
105
199
  | ---- | ---- | ----------- | --------- |
106
- | `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' |
107
- | `openFileDialog`<sup>1</sup> | Instance | 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. | - |
200
+ | `define` | Static | Registers the custom element with the browser's CustomElementRegistry unless it has already been defined. | `tagName='files-dropzone'` |
201
+ | `openFileDialog` | Instance | 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. | - |
108
202
 
109
- <sup>1</sup> Instance methods are only available after the component has been defined. To ensure the component is defined, you can use `whenDefined` method of the `CustomElementRegistry` interface, eg `customElements.whenDefined('files-dropzone').then(() => { /* call methods here */ });`
203
+ Instance methods are only available after the custom element has been defined. Use [`customElements.whenDefined()`](https://developer.mozilla.org/docs/Web/API/CustomElementRegistry/whenDefined) to ensure the element is registered before calling these methods.
110
204
 
111
205
  ### Static Properties
112
206
 
@@ -119,93 +213,15 @@ Below are static properties exposed on the `FilesDropzone` class for consumer re
119
213
 
120
214
  ### Events
121
215
 
122
- | Name | Description | Event Detail |
123
- | ---- | ----------- | ------------ |
124
- | `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: FilesDropzoneRejectionCode, message: string}>}>}` |
125
- | `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>}` |
126
- | `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: FilesDropzoneRejectionCode, message: string}>}>}` |
127
- | `files-dropzone-dragenter` | Emitted on `dragenter` event. The event is not emitted if `disabled` attribute is set. | - |
128
- | `files-dropzone-dragover` | Emitted on `dragover` event. The event is not emitted if `disabled` attribute is set. | - |
129
- | `files-dropzone-dragleave` | Emitted on `dragleave` event. The event is not emitted if `disabled` attribute is set. | - |
130
- | `files-dropzone-error` | Emitted if there is any error in the process of reading dropped files or directories. | `{error: unknown, code: FilesDropzoneErrorCode}` |
131
-
132
- ## Usage example
133
-
134
- Below is a basic usage example of the custom element that also demonstrates styles customization.
135
-
136
- ```html
137
- <head>
138
- <style>
139
- files-dropzone {
140
- --dropzone-border-color: #dbdbdb;
141
- --dropzone-border-color-dragover: #0096bfab;
142
- --dropzone-background-color: #f7f7f7;
143
- --dropzone-background-color-dragover: #efefef;
144
- --dropzone-body-color: #363636;
145
- --dropzone-body-color-dragover: #363636;
146
- }
147
-
148
- files-dropzone::part(dropzone) {
149
- display: flex;
150
- flex-direction: column;
151
- gap: 0.5rem;
152
- }
153
-
154
- @media (prefers-color-scheme: dark) {
155
- files-dropzone {
156
- --dropzone-border-color: #526980;
157
- --dropzone-border-color-dragover: #0096bfab;
158
- --dropzone-background-color: #1a242f;
159
- --dropzone-background-color-dragover: #161f27;
160
- --dropzone-body-color: #dbdbdb;
161
- --dropzone-body-color-dragover: #dbdbdb;
162
- }
163
- }
164
- </style>
165
- </head>
166
-
167
- <body>
168
- <files-dropzone accept="image/png,image/jpg" multiple>
169
- <span>Drag 'n' drop files here, or click to select files</span>
170
- <small>Accepted file types: <code>png</code>, <code>jpg</code></small>
171
- </files-dropzone>
172
-
173
- <h3>Accepted files</h3>
174
- <ul id="accepted-files"></ul>
175
-
176
- <h3>Rejected files</h3>
177
- <ul id="rejected-files"></ul>
178
-
179
- <script type="module">
180
- import { FilesDropzone } from 'https://unpkg.com/@georapbox/files-dropzone-element';
181
-
182
- FilesDropzone.defineCustomElement();
183
-
184
- const drozone = document.querySelector('files-dropzone');
185
- const acceptedFilesList = document.getElementById('accepted-files');
186
- const rejectedFilesList = document.getElementById('rejected-files');
187
-
188
- dropzone.addEventListener('files-dropzone-drop', evt => {
189
- const { acceptedFiles, rejectedFiles } = evt.detail;
190
-
191
- acceptedFilesList.replaceChildren();
192
- rejectedFilesList.replaceChildren();
193
-
194
- acceptedFiles.forEach(file => {
195
- const li = document.createElement('li');
196
- li.textContent = `${file.name} - ${file.size} bytes`;
197
- acceptedFilesList.appendChild(li);
198
- });
199
-
200
- rejectedFiles.forEach(file => {
201
- const li = document.createElement('li');
202
- li.textContent = `${file.name} - ${file.size} bytes`;
203
- rejectedFilesList.appendChild(li);
204
- });
205
- });
206
- </script>
207
- </body>
208
- ```
216
+ | Name | Type | Description | Event Detail |
217
+ | ---- | ---- | ----------- | ------------ |
218
+ | `dropzone-drop` | CustomEvent | Dispatched 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: FilesDropzoneRejectionCode, message: string}>}>}` |
219
+ | `dropzone-drop-accepted` | CustomEvent | Dispatched when one or more dropped files are accepted. If no files are accepted, the event is not emitted at all. | `{acceptedFiles: Array<File>}` |
220
+ | `dropzone-drop-rejected` | CustomEvent | Dispatched 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: FilesDropzoneRejectionCode, message: string}>}>}` |
221
+ | `dropzone-dragenter` | Event | Dispatched on `dragenter` event. The event is not emitted if `disabled` attribute is set. | - |
222
+ | `dropzone-dragover` | Event | Dispatched on `dragover` event. The event is not emitted if `disabled` attribute is set. | - |
223
+ | `dropzone-dragleave` | Event | Dispatched on `dragleave` event. The event is not emitted if `disabled` attribute is set. | - |
224
+ | `dropzone-error` | CustomEvent | Dispatched if there is any error in the process of reading dropped files or directories. | `{error: unknown, code: FilesDropzoneErrorCode}` |
209
225
 
210
226
  ## Changelog
211
227
 
@@ -215,7 +231,7 @@ For API updates and breaking changes, check the [CHANGELOG][changelog].
215
231
 
216
232
  ### Prerequisites
217
233
 
218
- The project requires `Node.js` and `npm` to be installed on your environment. Preferrably, use [nvm](https://github.com/nvm-sh/nvm) Node Version Manager and use the version of Node.js specified in the `.nvmrc` file by running `nvm use`.
234
+ The project requires `Node.js` and `npm` to be installed on your environment. Preferably, use [nvm](https://github.com/nvm-sh/nvm) Node Version Manager and use the version of Node.js specified in the `.nvmrc` file by running `nvm use`.
219
235
 
220
236
  ### Install dependencies
221
237
 
@@ -0,0 +1,48 @@
1
+ // https://custom-elements-manifest.open-wc.org/analyzer/config/
2
+ export default {
3
+ /** Globs to analyze */
4
+ globs: ['src/files-dropzone.js'],
5
+ /** Globs to exclude */
6
+ exclude: [],
7
+ /** Directory to output CEM to */
8
+ outdir: 'dist',
9
+ /** Run in dev mode, provides extra logging */
10
+ dev: false,
11
+ /** Run in watch mode, runs on file changes */
12
+ watch: false,
13
+ /** Include third party custom elements manifests */
14
+ dependencies: false,
15
+ /** Output CEM path to `package.json`, defaults to true */
16
+ packagejson: true,
17
+ /** Enable special handling for litelement */
18
+ litelement: false,
19
+ /** Enable special handling for catalyst */
20
+ catalyst: false,
21
+ /** Enable special handling for fast */
22
+ fast: false,
23
+ /** Enable special handling for stencil */
24
+ stencil: false,
25
+ /** Provide custom plugins */
26
+ plugins: [
27
+ {
28
+ name: 'fix-dynamic-tag-name',
29
+ moduleLinkPhase({ moduleDoc }) {
30
+ moduleDoc.exports?.forEach(ex => {
31
+ if (ex.kind === 'custom-element-definition' && ex.name === 'elementName') {
32
+ ex.name = 'files-dropzone'; // Force the manifest to show the default tag name
33
+ }
34
+ });
35
+ }
36
+ }
37
+ ],
38
+ /**
39
+ * Resolution options when using `dependencies: true`
40
+ * For detailed information about each option, please refer to the [oxc-resolver documentation](https://github.com/oxc-project/oxc-resolver?tab=readme-ov-file#options).
41
+ */
42
+ resolutionOptions: {
43
+ extensions: ['.js', '.ts'],
44
+ mainFields: ['module', 'main'],
45
+ conditionNames: ['import', 'require']
46
+ // ... other oxc-resolver options
47
+ }
48
+ };