Skip to content

Commit a0c679b

Browse files
committed
refactoring; removed ua-parser, added opts
1 parent 53acb8f commit a0c679b

File tree

10 files changed

+408
-324
lines changed

10 files changed

+408
-324
lines changed

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,25 @@ dropfile comes with both a component and an action. The component is basically a
7474
| `multiple` | sets the file input to `multiple`. See [HTML attribute: multiple on MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/multiple) for more information. | `boolean` | `true` |
7575
| `disabled` | disables the action/component, removing all event listeners | `boolean` | `false` |
7676
| `windowDrop` | determines whether or not files can be dropped anywhere in the window. A value of `false` would require that the files be droppped within the `<FileDrop>` component or the element with `use:filedrop`. | `boolean` | `true` |
77-
| `clickToUpload` | causes the containing element to be treated as the input. Disabling this does not change the `tabindex` of the container or remove the `keydown` eventListener | `boolean` | `true` |
78-
| `input` | allows you to explicitly pass the file `HTMLInputElement` as a parameter. If this `undefined`, the action will search for `input[type="file"]`. If one is not found, it will be appeneded to the element with `use:filedrop` | `HTMLInputElement` | `undefined` |
77+
| `clickToUpload` | causes the containing element to be treated as the input. If hideInput is true or undefined, disabling this does not change the `tabindex` of the container or remove the `keydown` eventListener | `boolean` | `true` |
78+
| `tabIndex` | tab index of the container. if `disabled` is `true` then this is set to `-1`. If `clickToUpload` is `true` or `undefined`, this defaults to 0. | `number` | `0` |
79+
| `hideInput` | if true or undefined, input[type='file'] will be set to display:none | `boolean` | `true` |
80+
| `input` | allows you to explicitly pass a reference to the file `HTMLInputElement` as a parameter. If `undefined`, the action will search for `input[type="file"]`. If one is not found, it will be appeneded to the element with `use:filedrop` | `HTMLInputElement` | `undefined` |
81+
82+
### Events
83+
84+
| event | description | `event.detail` |
85+
| ------------------- | ------------------------------------------------------------------------------------------------------------------------ | --------------------- |
86+
| filedrop | one or more files has been selected in the file dialog or drag-and-dropped | `FileDropSelectEvent` |
87+
| filedragenter | a dragenter event has occurred on the container element containnig one or more files | `FileDropDragEvent` |
88+
| filedragleave | a dragleave event has occurred on the container element containing one or more files | `FileDropDragEvent` |
89+
| filedragover | a dragover event has occurred on the container element containing one or more files | `FileDropDragEvent` |
90+
| filedialogcancel | the file dialog has been canceled without selecting files | `FileDropEvent` |
91+
| filedialogclose | the file dialog has been closed with files selected | `FileDropEvent` |
92+
| filedialogopen | the file dialog has been opened | `FileDropEvent` |
93+
| windowfiledragenter | a dragenter event has occurred on the document (event is named windowfiledragenter so not to confuse document with file) | `FileDropDragEvent` |
94+
| windowfiledragleave | a dragleave event has occurred on the document (event is named windowfiledragleave so not to confuse document with file) | `FileDropDragEvent` |
95+
| windowfiledragover | a dragover event has occurred on the document (event is named windowfiledragover so not to confuse document with file) | `FileDropDragEvent` |
7996

8097
### Errors
8198

@@ -99,7 +116,6 @@ dropfile comes with both a component and an action. The component is basically a
99116
- [attr-accept](https://github.com/react-dropzone/attr-accept)
100117
- [file-selector](https://github.com/react-dropzone/file-selector)
101118
- [filesize](https://github.com/avoidwork/filesize.js)
102-
- [ua-parser-js](https://github.com/faisalman/ua-parser-js)
103119

104120
## Todo
105121

package-lock.json

Lines changed: 3 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"devDependencies": {
3333
"@playwright/test": "^1.13.0",
3434
"@sveltejs/kit": "next",
35-
"@types/ua-parser-js": "^0.7.36",
3635
"@typescript-eslint/eslint-plugin": "^4.19.0",
3736
"@typescript-eslint/parser": "^4.19.0",
3837
"eslint": "^7.22.0",
@@ -50,7 +49,6 @@
5049
"typescript": "^4.0.0"
5150
},
5251
"dependencies": {
53-
"ua-parser-js": "^0.7.28",
5452
"file-selector": "^0.2.4",
5553
"filesize": "^7.0.0",
5654
"attr-accept": "^2.2.2"

0 commit comments

Comments
 (0)