wx-svelte-uploader 2.1.0 → 2.2.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.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "A Svelte UI component for easy and intuitive file upload",
|
|
5
5
|
"productTag": "uploader",
|
|
6
6
|
"productTrial": false,
|
|
@@ -32,8 +32,9 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://svar.dev/svelte/core/",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"wx-svelte-core": "2.
|
|
36
|
-
"wx-lib-dom": "0.
|
|
35
|
+
"wx-svelte-core": "2.2.0",
|
|
36
|
+
"wx-lib-dom": "0.9.1",
|
|
37
|
+
"wx-uploader-locales": "2.2.0"
|
|
37
38
|
},
|
|
38
39
|
"files": [
|
|
39
40
|
"src",
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { uid } from "wx-lib-dom";
|
|
3
|
-
import { onMount, setContext } from "svelte";
|
|
3
|
+
import { onMount, setContext, getContext } from "svelte";
|
|
4
4
|
import { apiKey } from "../helpers/consts";
|
|
5
5
|
|
|
6
|
+
import { locale } from "wx-lib-dom";
|
|
7
|
+
import { en } from "wx-uploader-locales";
|
|
8
|
+
|
|
6
9
|
let {
|
|
7
10
|
data = $bindable([]),
|
|
8
11
|
ready = $bindable(new Promise(() => ({}))),
|
|
@@ -23,6 +26,14 @@
|
|
|
23
26
|
let count = 0;
|
|
24
27
|
let lastCtx = {};
|
|
25
28
|
|
|
29
|
+
// set locale
|
|
30
|
+
let l = getContext("wx-i18n");
|
|
31
|
+
if (!l) {
|
|
32
|
+
l = locale(en);
|
|
33
|
+
setContext("wx-i18n", l);
|
|
34
|
+
}
|
|
35
|
+
const _ = getContext("wx-i18n").getGroup("uploader");
|
|
36
|
+
|
|
26
37
|
export const droparea = (node, ctx) => {
|
|
27
38
|
if (disabled) return;
|
|
28
39
|
|
|
@@ -216,10 +227,12 @@
|
|
|
216
227
|
{#if children}{@render children({ open })}{:else}
|
|
217
228
|
<div class="dropzone">
|
|
218
229
|
<span>
|
|
219
|
-
Drop files here or
|
|
230
|
+
{_("Drop files here or")}
|
|
220
231
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
221
232
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
222
|
-
<span class="action" onclick={open}
|
|
233
|
+
<span class="action" onclick={open}
|
|
234
|
+
>{_("select files")}</span
|
|
235
|
+
>
|
|
223
236
|
</span>
|
|
224
237
|
</div>
|
|
225
238
|
{/if}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
<script>
|
|
2
|
+
import { getContext } from "svelte";
|
|
3
|
+
|
|
2
4
|
let { data = $bindable([]) } = $props();
|
|
3
5
|
|
|
4
|
-
const
|
|
6
|
+
const _ = getContext("wx-i18n").getGroup("uploader");
|
|
7
|
+
|
|
8
|
+
const fileSize = ["B", "KB", "MB", "GB", "TB", "PB", "EB"];
|
|
5
9
|
|
|
6
10
|
function removeAll() {
|
|
7
11
|
data = [];
|
|
@@ -17,7 +21,7 @@
|
|
|
17
21
|
index++;
|
|
18
22
|
size = size / 1024;
|
|
19
23
|
}
|
|
20
|
-
return Math.round(size * 100) / 100 + " " + fileSize[index];
|
|
24
|
+
return Math.round(size * 100) / 100 + " " + _(fileSize[index]);
|
|
21
25
|
}
|
|
22
26
|
</script>
|
|
23
27
|
|