wx-svelte-uploader 2.0.1 → 2.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wx-svelte-uploader",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "description": "A Svelte UI component for easy and intuitive file upload",
5
5
  "productTag": "uploader",
6
6
  "productTrial": false,
@@ -30,10 +30,10 @@
30
30
  "bugs": {
31
31
  "url": "https://forum.svar.dev"
32
32
  },
33
- "homepage": "https://svar.dev/svelte/uploader/",
33
+ "homepage": "https://svar.dev/svelte/core/",
34
34
  "dependencies": {
35
- "wx-svelte-core": "2.0.1",
36
- "wx-lib-dom": "0.7.1"
35
+ "wx-svelte-core": "2.1.0",
36
+ "wx-lib-dom": "0.8.0"
37
37
  },
38
38
  "files": [
39
39
  "src",
@@ -23,42 +23,36 @@
23
23
  let count = 0;
24
24
  let lastCtx = {};
25
25
 
26
- const api = {
27
- open: ctx => open(ctx),
28
- getState: () => getState(),
29
- droparea: (node, ctx) => {
30
- if (disabled) return;
31
-
32
- ctx = ctx || {};
33
- node.addEventListener("dragenter", () => {
34
- if (ctx.dragEnter) ctx.dragEnter();
35
- dragenter();
36
- });
37
- node.addEventListener("dragleave", () => {
38
- if (ctx.dragEnter) ctx.dragLeave();
39
- dragleave();
40
- });
26
+ export const droparea = (node, ctx) => {
27
+ if (disabled) return;
41
28
 
42
- node.addEventListener("dragover", ev => ev.preventDefault(), true);
43
- node.addEventListener(
44
- "drop",
45
- ev => {
46
- ev.preventDefault();
47
- lastCtx = ctx;
48
- drop(ev);
49
- if (ctx.dragEnter) ctx.dragLeave();
50
- },
51
- true
52
- );
53
- },
29
+ ctx = ctx || {};
30
+ node.addEventListener("dragenter", () => {
31
+ if (ctx.dragEnter) ctx.dragEnter();
32
+ dragenter();
33
+ });
34
+ node.addEventListener("dragleave", () => {
35
+ if (ctx.dragEnter) ctx.dragLeave();
36
+ dragleave();
37
+ });
38
+
39
+ node.addEventListener("dragover", ev => ev.preventDefault(), true);
40
+ node.addEventListener(
41
+ "drop",
42
+ ev => {
43
+ ev.preventDefault();
44
+ lastCtx = ctx;
45
+ drop(ev);
46
+ if (ctx.dragEnter) ctx.dragLeave();
47
+ },
48
+ true
49
+ );
54
50
  };
55
51
 
56
52
  onMount(() => {
57
53
  input.webkitdirectory = folder;
58
54
  });
59
55
 
60
- setContext(apiKey, api);
61
-
62
56
  function add(ev) {
63
57
  const files = Array.from(ev.target.files);
64
58
  files.forEach(f => addFile(f));
@@ -153,7 +147,7 @@
153
147
  // returns client if any file is being uploaded
154
148
  // returns error if any file has failed and no file is being uploaded
155
149
  // returns server if all files have been uploaded
156
- function getState() {
150
+ export function getState() {
157
151
  let status = "server";
158
152
  for (let i = 0; i < data.length; i++) {
159
153
  if (data[i].status === "client") return "client";
@@ -184,10 +178,12 @@
184
178
  if (count === 0) drag = false;
185
179
  }
186
180
 
187
- function open(ctx) {
181
+ export function open(ctx) {
188
182
  lastCtx = ctx || {};
189
183
  input.click();
190
184
  }
185
+
186
+ setContext(apiKey, { open, getState, droparea });
191
187
  </script>
192
188
 
193
189
  {#if apiOnly}
@@ -206,7 +202,7 @@
206
202
  class="label"
207
203
  class:active={drag}
208
204
  class:wx-disabled={disabled}
209
- use:api.droparea
205
+ use:droparea
210
206
  >
211
207
  <input
212
208
  type="file"
package/whatsnew.md CHANGED
@@ -1,19 +1,35 @@
1
- ### 2.0.1
1
+ ## 2.1.0
2
2
 
3
- - [add] svelte 5 support
3
+ - Using core@2.1.0
4
4
 
5
- ### 1.3.0
5
+ ## 2.0.2
6
6
 
7
- - [dev] using core@1.3.0
7
+ ### Fixes
8
8
 
9
- ### 0.2.1
9
+ - Restore ability to use api
10
10
 
11
- - [fix] disabled state was ignored by drag-n-drop operations
11
+ ## 2.0.1
12
12
 
13
- ### 0.2.0
13
+ ### New features
14
14
 
15
- - [add] disabled state
15
+ - Svelte 5 support
16
16
 
17
- ### 0.1.0
17
+ ## 1.3.0
18
+
19
+ - Using core@1.3.0
20
+
21
+ ## 0.2.1
22
+
23
+ ### Fixes
24
+
25
+ - Disabled state was ignored by drag-n-drop operations
26
+
27
+ ## 0.2.0
28
+
29
+ ### New features
30
+
31
+ - Disabled state
32
+
33
+ ## 0.1.0
18
34
 
19
35
  Initial version