Skip to content

Commit cbee596

Browse files
committed
cleanup
1 parent 8b024e8 commit cbee596

File tree

5 files changed

+103
-241
lines changed

5 files changed

+103
-241
lines changed

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "filedrop-svelte",
3-
"version": "0.0.6",
3+
"version": "0.0.7",
44
"author": {
55
"name": "chance dinkins",
66
"email": "[email protected]"
@@ -13,9 +13,10 @@
1313
"keywords": [
1414
"svelte",
1515
"sveltekit",
16-
"typescript",
1716
"dropzone",
18-
"drag and drop"
17+
"drag and drop",
18+
"file upload",
19+
"drag-and-drop"
1920
],
2021
"description": "svelte component and action to create drag-and-drop file dropzones.",
2122
"scripts": {

src/lib/actions/filedrop.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ export const filedrop = function (node: HTMLElement, opts?: FileDropOptions): Ac
330330

331331
function init(opts: FileDropOptions) {
332332
options = configOptions(node, opts);
333-
console.log(options);
334333
input = options.input;
335334
node.tabIndex = options.tabIndex;
336335

src/lib/event.ts

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,51 @@ export interface FileDropSelectEvent extends FileDropEvent {
2121
}
2222

2323
export interface Events {
24-
// one or more files has been selected in the file dialog or drag-and-dropped
24+
/**
25+
* one or more files has been selected in the file dialog or drag-and-dropped
26+
*/
2527
filedrop: FileDropSelectEvent;
26-
// a dragenter event has occurred on the container element containnig one or more files
28+
/**
29+
* a dragenter event has occurred on the container element containnig one or more files
30+
*/
2731
filedragenter: FileDropDragEvent;
28-
// a dragleave event has occurred on the container element containing one or more files
32+
/**
33+
* a dragleave event has occurred on the container element containing one or more files
34+
*/
2935
filedragleave: FileDropDragEvent;
30-
// a dragover event has occurred on the container element containing one or more files
36+
/**
37+
* a dragover event has occurred on the container element containing one or more files
38+
*/
3139
filedragover: FileDropDragEvent;
32-
// the file dialog has been canceled without selecting files
40+
/**
41+
* the file dialog has been canceled without selecting files
42+
*/
3343
filedialogcancel: FileDropEvent;
34-
// the file dialog has been closed with files selected
44+
/**
45+
* the file dialog has been closed with files selected
46+
*/
3547
filedialogclose: FileDropEvent;
36-
// the file dialog has been opened
48+
/**
49+
* the file dialog has been opened
50+
*/
3751
filedialogopen: FileDropEvent;
38-
// a dragenter event has occurred on the document (event is named windowfiledragenter so not to confuse document with file)
52+
/**
53+
* a dragenter event has occurred on the `document`
54+
*
55+
* Note: event is named windowfiledragenter so not to confuse `document` with file
56+
*/
3957
windowfiledragenter: FileDropDragEvent;
40-
// a dragleave event has occurred on the document (event is named windowfiledragleave so not to confuse document with file)
58+
/**
59+
* a dragleave event has occurred on the `document`
60+
*
61+
* Note: event is named windowfiledragleave so not to confuse document with file
62+
*/
4163
windowfiledragleave: FileDropDragEvent;
42-
// a dragover event has occurred on the document (event is named windowfiledragover so not to confuse document with file)
64+
/**
65+
* a dragover event has occurred on the `document`
66+
*
67+
* Note: event is named windowfiledragover so not to confuse document with file
68+
*/
4369
windowfiledragover: FileDropDragEvent;
4470
}
4571

@@ -87,32 +113,3 @@ export async function getFilesFromEvent(ev: Event, opts: FileDropOptions): Promi
87113
export function isNode(target: EventTarget | Node): target is Node {
88114
return "childNodes" in target;
89115
}
90-
91-
// type FileDropEventType = keyof Events;
92-
93-
// type FileDragEventType = Extract<
94-
// FileDropEventType,
95-
// | "filedragover"
96-
// | "filedragenter"
97-
// | "filedragleave"
98-
// | "windowfiledragenter"
99-
// | "windowfiledragleave"
100-
// | "windowfiledragover"
101-
// >;
102-
103-
// type FileDialogEventType = Extract<
104-
// FileDropEventType,
105-
// "filedialogopen" | "filedialogclose" | "filedialogcancel"
106-
// >;
107-
108-
// export class FileDropEvent<T extends FileDropEventDetail = FileDropEventDetail> extends CustomEvent<T> {
109-
// constructor(type: FileDropEventType, detail: T) {
110-
// super(type, { detail });
111-
// }
112-
// }
113-
114-
// export class FileDropDragEvent extends FileDropEvent<FileDropDragEventDetail> {
115-
// constructor(type: FileDragEventType, detail: FileDropDragEventDetail) {
116-
// super(type, detail);
117-
// }
118-
// }

src/lib/options.ts

Lines changed: 63 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,77 @@
1-
// Options for FileDrop component & action
1+
/**
2+
* Options for FileDrop component & action
3+
*/
24
export interface FileDropOptions {
3-
// specify file types to accept. See [HTML attribute: accept on MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept) for more information.
5+
/**
6+
* specify file types to accept.
7+
*
8+
* See [HTML attribute: accept on MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept) for more information.
9+
*/
410
accept?: string | string[];
5-
// the maximum size a file can be in bytes.
11+
/**
12+
* the maximum size a file can be in bytes.
13+
*/
614
maxSize?: number;
7-
// the minimum size a file can be in bytes.
15+
/**
16+
* the minimum size a file can be in bytes.
17+
*/
818
minSize?: number;
9-
// total number of files allowed in a transaction. A value of 0 disables the action/component, 1 turns multiple off, and any other value enables multiple. Any attempt to upload more files than allowed will result in the files being placed in rejections
19+
/**
20+
* total number of files allowed in a transaction.
21+
*
22+
* A value of 0 disables the action/component, 1 turns multiple off, and any other value enables multiple.
23+
*
24+
* Any attempt to upload more files than allowed will result in the files being placed in rejections
25+
*/
1026
fileLimit?: number;
11-
// 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.
27+
/**
28+
* sets the file input to `multiple`.
29+
*
30+
* See [HTML attribute: multiple on MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/multiple) for more information.
31+
*/
1232
multiple?: boolean;
13-
// disables the action/component, removing all event listeners
33+
/**
34+
* disables the action/component, removing all event listeners
35+
*/
1436
disabled?: boolean;
15-
// 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`.
37+
/**
38+
* determines whether or not files can be dropped anywhere in the window.
39+
*
40+
* A value of `false` would require that the files be droppped within the `<FileDrop>` component or the element with `use:filedrop`.
41+
*/
1642
windowDrop?: boolean;
17-
// 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
43+
/**
44+
* causes the containing element to be treated as the input.
45+
*
46+
* If hideInput is `true` or `undefined`, disabling this does not change the `tabindex` of the container or remove the `keydown` eventListener
47+
*/
1848
clickToUpload?: boolean;
19-
20-
tabIndex?: number; // if clickToUpload is true or undefined, this defaults to 0.
21-
// if true or undefined, input[type='file'] will be set to display:none
49+
/**
50+
* tab index of the container.
51+
*
52+
* If `disabled` is `true` then this is set to `-1`.
53+
*
54+
* If `clickToUpload` is `true` or `undefined`, this defaults to 0.
55+
*/
56+
tabIndex?: number;
57+
/**
58+
* if true or undefined, input[type='file'] will be set to display:none
59+
*/
2260
hideInput?: boolean;
23-
// style applied to the node
61+
/**
62+
* style applied to the node
63+
*/
2464
style?: string;
25-
// id of the node
65+
/**
66+
* id of the node
67+
*/
2668
id?: string;
27-
// 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`
69+
/**
70+
* allows you to explicitly pass the file `HTMLInputElement` as a parameter.
71+
*
72+
* If this `undefined`, the action will search for `input[type="file"]`.
73+
*
74+
* If an `input[type="file"]` is not found, it will be appeneded to the element with `use:filedrop`
75+
*/
2876
input?: HTMLInputElement;
2977
}

0 commit comments

Comments
 (0)