vue-chunk-uploader 1.1.0 → 1.3.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/README.md +73 -2
- package/dist/_plugin-vue_export-helper-BHFhmbuH.cjs +1 -0
- package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
- package/dist/element-plus.cjs +1 -0
- package/dist/element-plus.js +94 -0
- package/dist/native.cjs +1 -1
- package/dist/native.js +36 -40
- package/dist/reka.cjs +1 -0
- package/dist/reka.js +100 -0
- package/dist/vue-chunk-uploader.css +1 -1
- package/package.json +22 -2
- package/src/ui/element-plus/ChunkUploader.vue +107 -0
- package/src/ui/element-plus/index.js +17 -0
- package/src/ui/reka/ChunkUploader.vue +150 -0
- package/src/ui/reka/index.js +17 -0
package/README.md
CHANGED
|
@@ -10,10 +10,12 @@ The upload core is UI-agnostic — you choose which adapter to use.
|
|
|
10
10
|
|--------|----|---------------------|
|
|
11
11
|
| `vue-chunk-uploader/quasar` | Quasar | `quasar` |
|
|
12
12
|
| `vue-chunk-uploader/vuetify` | Vuetify 3 | `vuetify` |
|
|
13
|
+
| `vue-chunk-uploader/reka` | [Reka UI](https://reka-ui.com/) | `reka-ui` |
|
|
14
|
+
| `vue-chunk-uploader/element-plus` | [Element Plus](https://element-plus.org/) | `element-plus` |
|
|
13
15
|
| `vue-chunk-uploader/native` | Plain HTML | — |
|
|
14
16
|
| `vue-chunk-uploader` | Core only (no UI) | — |
|
|
15
17
|
|
|
16
|
-
> **Note about MUI:** Material UI is for React. In the Vue ecosystem, the closest equivalent is **Vuetify**. For other UIs (
|
|
18
|
+
> **Note about MUI:** Material UI is for React. In the Vue ecosystem, the closest equivalent is **Vuetify**. For other UIs (Naive UI, MUI/React, etc.), use `native`, `reka`, or the `useChunkUpload` composable and build your own UI.
|
|
17
19
|
|
|
18
20
|
## Install
|
|
19
21
|
|
|
@@ -29,6 +31,12 @@ npm install quasar
|
|
|
29
31
|
|
|
30
32
|
# or Vuetify
|
|
31
33
|
npm install vuetify
|
|
34
|
+
|
|
35
|
+
# or Reka UI
|
|
36
|
+
npm install reka-ui
|
|
37
|
+
|
|
38
|
+
# or Element Plus
|
|
39
|
+
npm install element-plus
|
|
32
40
|
```
|
|
33
41
|
|
|
34
42
|
## Usage — Quasar
|
|
@@ -88,6 +96,67 @@ app.use(VueChunkUploader, { httpClient: api })
|
|
|
88
96
|
</template>
|
|
89
97
|
```
|
|
90
98
|
|
|
99
|
+
## Usage — Element Plus
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
import ElementPlus from 'element-plus'
|
|
103
|
+
import 'element-plus/dist/index.css'
|
|
104
|
+
import VueChunkUploader from 'vue-chunk-uploader/element-plus'
|
|
105
|
+
|
|
106
|
+
app.use(ElementPlus)
|
|
107
|
+
app.use(VueChunkUploader, { httpClient: api })
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
```vue
|
|
111
|
+
<template>
|
|
112
|
+
<ChunkUploader
|
|
113
|
+
v-model="file"
|
|
114
|
+
url="/api/document/chunk/upload"
|
|
115
|
+
button-label="Select file"
|
|
116
|
+
accept=".pdf,.png"
|
|
117
|
+
@onSuccess="onSuccess"
|
|
118
|
+
/>
|
|
119
|
+
</template>
|
|
120
|
+
|
|
121
|
+
<script setup>
|
|
122
|
+
import { ref } from 'vue'
|
|
123
|
+
import { ChunkUploader } from 'vue-chunk-uploader/element-plus'
|
|
124
|
+
|
|
125
|
+
const file = ref(null)
|
|
126
|
+
</script>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Usage — Reka UI
|
|
130
|
+
|
|
131
|
+
Uses accessible [Reka UI](https://reka-ui.com/) primitives (`Label`, `Progress`, `Primitive`). Since Reka is unstyled, import the package CSS (or override with your own styles).
|
|
132
|
+
|
|
133
|
+
```js
|
|
134
|
+
import VueChunkUploader from 'vue-chunk-uploader/reka'
|
|
135
|
+
import 'vue-chunk-uploader/style.css'
|
|
136
|
+
|
|
137
|
+
app.use(VueChunkUploader, { httpClient: api })
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
```vue
|
|
141
|
+
<template>
|
|
142
|
+
<ChunkUploader
|
|
143
|
+
v-model="file"
|
|
144
|
+
url="/api/document/chunk/upload"
|
|
145
|
+
label="File"
|
|
146
|
+
accept=".pdf,.png"
|
|
147
|
+
@onSuccess="onSuccess"
|
|
148
|
+
/>
|
|
149
|
+
</template>
|
|
150
|
+
|
|
151
|
+
<script setup>
|
|
152
|
+
import { ref } from 'vue'
|
|
153
|
+
import { ChunkUploader } from 'vue-chunk-uploader/reka'
|
|
154
|
+
import 'vue-chunk-uploader/style.css'
|
|
155
|
+
|
|
156
|
+
const file = ref(null)
|
|
157
|
+
</script>
|
|
158
|
+
```
|
|
159
|
+
|
|
91
160
|
## Usage — Native (no UI framework)
|
|
92
161
|
|
|
93
162
|
```js
|
|
@@ -176,8 +245,10 @@ await chunk(
|
|
|
176
245
|
| `chunkSize` | `number` | `1MB` | Chunk size |
|
|
177
246
|
| `maxRequestsPerMinute` | `number` | `80` | Client-side rate limit |
|
|
178
247
|
| `rateLimitWindowMs` | `number` | `60000` | Rate-limit window |
|
|
248
|
+
| `label` | `string` | `''` | Label text (Reka adapter) |
|
|
249
|
+
| `buttonLabel` | `string` | `'Select file'` | Button text (Element Plus adapter) |
|
|
179
250
|
|
|
180
|
-
UI-specific attrs are forwarded as well (e.g. `q-file
|
|
251
|
+
UI-specific attrs are forwarded as well (e.g. `q-file`, `v-file-input`, `el-upload`, or native `input[type=file]` attrs).
|
|
181
252
|
|
|
182
253
|
## Events
|
|
183
254
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=(t,o)=>{const c=t.__vccOpts||t;for(const[r,s]of o)c[r]=s;return c};exports._export_sfc=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),o=require("element-plus"),u=require("./createPlugin-DoOjwZfd.cjs"),v=require("./_plugin-vue_export-helper-BHFhmbuH.cjs"),V={class:"vue-chunk-uploader-element-plus","data-ui":"element-plus"},U={class:"el-upload__tip vue-chunk-uploader-element-plus__status"},x=Object.assign({inheritAttrs:!1},{__name:"ChunkUploader",props:{...u.chunkUploaderProps,buttonLabel:{type:String,default:"Select file"}},emits:u.chunkUploaderEmits,setup(c,{expose:i,emit:f}){const l=c,r=f,{hasError:a,progress:n,uploadFile:m,clear:h}=u.useChunkUpload(l,r),k=e.computed(()=>{if(!l.modelValue)return[];let t="ready";return a.value?t="fail":n.value>=100?t="success":n.value>0&&(t="uploading"),[{name:l.modelValue.name,raw:l.modelValue,status:t,percentage:n.value}]}),_=t=>{r("update:modelValue",(t==null?void 0:t.raw)??null)},g=()=>{h()},C=t=>{const s=t==null?void 0:t[0];s&&r("update:modelValue",s)};return i({uploadFile:m}),(t,s)=>(e.openBlock(),e.createElementBlock("div",V,[e.createVNode(e.unref(o.ElUpload),e.mergeProps(t.$attrs,{action:"#","auto-upload":!1,limit:1,"file-list":k.value,"on-change":_,"on-remove":g,"on-exceed":C}),{tip:e.withCtx(()=>[e.createElementVNode("div",U,[e.createVNode(e.unref(o.ElTag),{size:"small",type:e.unref(a)?"danger":e.unref(n)>=100?"success":"info"},{default:e.withCtx(()=>[e.unref(n)<100?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(e.unref(n))+"%",1)],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode("Done")],64))]),_:1},8,["type"])])]),default:e.withCtx(()=>[e.createVNode(e.unref(o.ElButton),{type:"primary"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.buttonLabel),1)]),_:1})]),_:1},16,["file-list"]),e.unref(n)>0&&e.unref(n)<100?(e.openBlock(),e.createBlock(e.unref(o.ElProgress),{key:0,class:"vue-chunk-uploader-element-plus__progress",percentage:e.unref(n),status:e.unref(a)?"exception":void 0,"stroke-width":6},null,8,["percentage","status"])):e.createCommentVNode("",!0)]))}}),p=v._export_sfc(x,[["__scopeId","data-v-94616f6c"]]),d=u.createChunkUploaderPlugin(p);exports.chunk=u.chunk;exports.chunkUploader=u.chunkUploader;exports.setDefaultHttpClient=u.setDefaultHttpClient;exports.useChunkUpload=u.useChunkUpload;exports.ChunkUploader=p;exports.VueChunkUploader=d;exports.default=d;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { computed as C, openBlock as s, createElementBlock as c, createVNode as p, unref as t, mergeProps as E, withCtx as l, createTextVNode as d, toDisplayString as m, createElementVNode as U, Fragment as f, createBlock as b, createCommentVNode as w } from "vue";
|
|
2
|
+
import { ElUpload as B, ElButton as N, ElTag as P, ElProgress as D } from "element-plus";
|
|
3
|
+
import { d as L, e as S, u as T, c as j } from "./createPlugin-DZ7dugEN.js";
|
|
4
|
+
import { a as Q, b as W, s as X } from "./createPlugin-DZ7dugEN.js";
|
|
5
|
+
import { _ as z } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
6
|
+
const A = {
|
|
7
|
+
class: "vue-chunk-uploader-element-plus",
|
|
8
|
+
"data-ui": "element-plus"
|
|
9
|
+
}, H = { class: "el-upload__tip vue-chunk-uploader-element-plus__status" }, I = /* @__PURE__ */ Object.assign({ inheritAttrs: !1 }, {
|
|
10
|
+
__name: "ChunkUploader",
|
|
11
|
+
props: {
|
|
12
|
+
...S,
|
|
13
|
+
buttonLabel: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: "Select file"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
emits: L,
|
|
19
|
+
setup(i, { expose: h, emit: _ }) {
|
|
20
|
+
const o = i, n = _, { hasError: r, progress: a, uploadFile: k, clear: g } = T(o, n), v = C(() => {
|
|
21
|
+
if (!o.modelValue) return [];
|
|
22
|
+
let e = "ready";
|
|
23
|
+
return r.value ? e = "fail" : a.value >= 100 ? e = "success" : a.value > 0 && (e = "uploading"), [
|
|
24
|
+
{
|
|
25
|
+
name: o.modelValue.name,
|
|
26
|
+
raw: o.modelValue,
|
|
27
|
+
status: e,
|
|
28
|
+
percentage: a.value
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
}), y = (e) => {
|
|
32
|
+
n("update:modelValue", (e == null ? void 0 : e.raw) ?? null);
|
|
33
|
+
}, V = () => {
|
|
34
|
+
g();
|
|
35
|
+
}, x = (e) => {
|
|
36
|
+
const u = e == null ? void 0 : e[0];
|
|
37
|
+
u && n("update:modelValue", u);
|
|
38
|
+
};
|
|
39
|
+
return h({ uploadFile: k }), (e, u) => (s(), c("div", A, [
|
|
40
|
+
p(t(B), E(e.$attrs, {
|
|
41
|
+
action: "#",
|
|
42
|
+
"auto-upload": !1,
|
|
43
|
+
limit: 1,
|
|
44
|
+
"file-list": v.value,
|
|
45
|
+
"on-change": y,
|
|
46
|
+
"on-remove": V,
|
|
47
|
+
"on-exceed": x
|
|
48
|
+
}), {
|
|
49
|
+
tip: l(() => [
|
|
50
|
+
U("div", H, [
|
|
51
|
+
p(t(P), {
|
|
52
|
+
size: "small",
|
|
53
|
+
type: t(r) ? "danger" : t(a) >= 100 ? "success" : "info"
|
|
54
|
+
}, {
|
|
55
|
+
default: l(() => [
|
|
56
|
+
t(a) < 100 ? (s(), c(f, { key: 0 }, [
|
|
57
|
+
d(m(t(a)) + "%", 1)
|
|
58
|
+
], 64)) : (s(), c(f, { key: 1 }, [
|
|
59
|
+
d("Done")
|
|
60
|
+
], 64))
|
|
61
|
+
]),
|
|
62
|
+
_: 1
|
|
63
|
+
}, 8, ["type"])
|
|
64
|
+
])
|
|
65
|
+
]),
|
|
66
|
+
default: l(() => [
|
|
67
|
+
p(t(N), { type: "primary" }, {
|
|
68
|
+
default: l(() => [
|
|
69
|
+
d(m(i.buttonLabel), 1)
|
|
70
|
+
]),
|
|
71
|
+
_: 1
|
|
72
|
+
})
|
|
73
|
+
]),
|
|
74
|
+
_: 1
|
|
75
|
+
}, 16, ["file-list"]),
|
|
76
|
+
t(a) > 0 && t(a) < 100 ? (s(), b(t(D), {
|
|
77
|
+
key: 0,
|
|
78
|
+
class: "vue-chunk-uploader-element-plus__progress",
|
|
79
|
+
percentage: t(a),
|
|
80
|
+
status: t(r) ? "exception" : void 0,
|
|
81
|
+
"stroke-width": 6
|
|
82
|
+
}, null, 8, ["percentage", "status"])) : w("", !0)
|
|
83
|
+
]));
|
|
84
|
+
}
|
|
85
|
+
}), O = /* @__PURE__ */ z(I, [["__scopeId", "data-v-94616f6c"]]), J = j(O);
|
|
86
|
+
export {
|
|
87
|
+
O as ChunkUploader,
|
|
88
|
+
J as VueChunkUploader,
|
|
89
|
+
Q as chunk,
|
|
90
|
+
W as chunkUploader,
|
|
91
|
+
J as default,
|
|
92
|
+
X as setDefaultHttpClient,
|
|
93
|
+
T as useChunkUpload
|
|
94
|
+
};
|
package/dist/native.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),t=require("./createPlugin-DoOjwZfd.cjs"),g=(
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),t=require("./createPlugin-DoOjwZfd.cjs"),g=require("./_plugin-vue_export-helper-BHFhmbuH.cjs"),C={class:"vue-chunk-uploader-native","data-ui":"native"},U={class:"vue-chunk-uploader-native__row"},V=["data-error","data-done"],B=["value"],E=Object.assign({inheritAttrs:!1},{__name:"ChunkUploader",props:t.chunkUploaderProps,emits:t.chunkUploaderEmits,setup(d,{expose:p,emit:i}){const k=d,a=i,r=e.ref(null),{hasError:h,progress:n,uploadFile:_,clear:f}=t.useChunkUpload(k,a),m=o=>{var l;const u=((l=o.target.files)==null?void 0:l[0])??null;a("update:modelValue",u)},v=()=>{r.value&&(r.value.value=""),f()};return p({uploadFile:_}),(o,u)=>(e.openBlock(),e.createElementBlock("div",C,[e.createElementVNode("div",U,[e.createElementVNode("input",e.mergeProps({ref_key:"inputRef",ref:r,type:"file"},o.$attrs,{onChange:m}),null,16),o.modelValue?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"vue-chunk-uploader-native__clear",onClick:v}," × ")):e.createCommentVNode("",!0),e.createElementVNode("span",{class:"vue-chunk-uploader-native__badge","data-error":e.unref(h)||void 0,"data-done":e.unref(n)>=100||void 0},[e.unref(n)<100?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(e.unref(n))+"%",1)],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode("✓")],64))],8,V)]),e.unref(n)>0&&e.unref(n)<100?(e.openBlock(),e.createElementBlock("progress",{key:0,class:"vue-chunk-uploader-native__progress",value:e.unref(n),max:"100"},null,8,B)):e.createCommentVNode("",!0)]))}}),c=g._export_sfc(E,[["__scopeId","data-v-0be4ee9c"]]),s=t.createChunkUploaderPlugin(c);exports.chunk=t.chunk;exports.chunkUploader=t.chunkUploader;exports.setDefaultHttpClient=t.setDefaultHttpClient;exports.useChunkUpload=t.useChunkUpload;exports.ChunkUploader=c;exports.VueChunkUploader=s;exports.default=s;
|
package/dist/native.js
CHANGED
|
@@ -1,66 +1,62 @@
|
|
|
1
|
-
import { ref as U, openBlock as
|
|
1
|
+
import { ref as U, openBlock as t, createElementBlock as o, createElementVNode as s, mergeProps as b, createCommentVNode as d, unref as e, Fragment as p, createTextVNode as i, toDisplayString as V } from "vue";
|
|
2
2
|
import { d as x, e as E, u as N, c as P } from "./createPlugin-DZ7dugEN.js";
|
|
3
|
-
import { a as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
for (const [c, s] of l)
|
|
7
|
-
r[c] = s;
|
|
8
|
-
return r;
|
|
9
|
-
}, D = {
|
|
3
|
+
import { a as q, b as z, s as G } from "./createPlugin-DZ7dugEN.js";
|
|
4
|
+
import { _ as B } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
5
|
+
const D = {
|
|
10
6
|
class: "vue-chunk-uploader-native",
|
|
11
7
|
"data-ui": "native"
|
|
12
|
-
}, F = { class: "vue-chunk-uploader-native__row" },
|
|
8
|
+
}, F = { class: "vue-chunk-uploader-native__row" }, R = ["data-error", "data-done"], j = ["value"], w = /* @__PURE__ */ Object.assign({ inheritAttrs: !1 }, {
|
|
13
9
|
__name: "ChunkUploader",
|
|
14
10
|
props: E,
|
|
15
11
|
emits: x,
|
|
16
|
-
setup(
|
|
17
|
-
const
|
|
18
|
-
var
|
|
19
|
-
const
|
|
20
|
-
|
|
12
|
+
setup(_, { expose: h, emit: k }) {
|
|
13
|
+
const m = _, u = k, r = U(null), { hasError: f, progress: a, uploadFile: v, clear: g } = N(m, u), C = (n) => {
|
|
14
|
+
var c;
|
|
15
|
+
const l = ((c = n.target.files) == null ? void 0 : c[0]) ?? null;
|
|
16
|
+
u("update:modelValue", l);
|
|
21
17
|
}, y = () => {
|
|
22
|
-
|
|
18
|
+
r.value && (r.value.value = ""), g();
|
|
23
19
|
};
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
return h({ uploadFile: v }), (n, l) => (t(), o("div", D, [
|
|
21
|
+
s("div", F, [
|
|
22
|
+
s("input", b({
|
|
27
23
|
ref_key: "inputRef",
|
|
28
|
-
ref:
|
|
24
|
+
ref: r,
|
|
29
25
|
type: "file"
|
|
30
|
-
},
|
|
31
|
-
|
|
26
|
+
}, n.$attrs, { onChange: C }), null, 16),
|
|
27
|
+
n.modelValue ? (t(), o("button", {
|
|
32
28
|
key: 0,
|
|
33
29
|
type: "button",
|
|
34
30
|
class: "vue-chunk-uploader-native__clear",
|
|
35
31
|
onClick: y
|
|
36
|
-
}, " × ")) :
|
|
37
|
-
|
|
32
|
+
}, " × ")) : d("", !0),
|
|
33
|
+
s("span", {
|
|
38
34
|
class: "vue-chunk-uploader-native__badge",
|
|
39
|
-
"data-error": e(
|
|
40
|
-
"data-done": e(
|
|
35
|
+
"data-error": e(f) || void 0,
|
|
36
|
+
"data-done": e(a) >= 100 || void 0
|
|
41
37
|
}, [
|
|
42
|
-
e(
|
|
43
|
-
|
|
44
|
-
], 64)) : (
|
|
45
|
-
|
|
38
|
+
e(a) < 100 ? (t(), o(p, { key: 0 }, [
|
|
39
|
+
i(V(e(a)) + "%", 1)
|
|
40
|
+
], 64)) : (t(), o(p, { key: 1 }, [
|
|
41
|
+
i("✓")
|
|
46
42
|
], 64))
|
|
47
|
-
], 8,
|
|
43
|
+
], 8, R)
|
|
48
44
|
]),
|
|
49
|
-
e(
|
|
45
|
+
e(a) > 0 && e(a) < 100 ? (t(), o("progress", {
|
|
50
46
|
key: 0,
|
|
51
47
|
class: "vue-chunk-uploader-native__progress",
|
|
52
|
-
value: e(
|
|
48
|
+
value: e(a),
|
|
53
49
|
max: "100"
|
|
54
|
-
}, null, 8,
|
|
50
|
+
}, null, 8, j)) : d("", !0)
|
|
55
51
|
]));
|
|
56
52
|
}
|
|
57
|
-
}),
|
|
53
|
+
}), A = /* @__PURE__ */ B(w, [["__scopeId", "data-v-0be4ee9c"]]), S = P(A);
|
|
58
54
|
export {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
A as ChunkUploader,
|
|
56
|
+
S as VueChunkUploader,
|
|
57
|
+
q as chunk,
|
|
58
|
+
z as chunkUploader,
|
|
59
|
+
S as default,
|
|
60
|
+
G as setDefaultHttpClient,
|
|
65
61
|
N as useChunkUpload
|
|
66
62
|
};
|
package/dist/reka.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),a=require("reka-ui"),t=require("./createPlugin-DoOjwZfd.cjs"),V=require("./_plugin-vue_export-helper-BHFhmbuH.cjs"),y={class:"vue-chunk-uploader-reka","data-ui":"reka"},U={class:"vue-chunk-uploader-reka__row"},b=Object.assign({inheritAttrs:!1},{__name:"ChunkUploader",props:{...t.chunkUploaderProps,label:{type:String,default:""}},emits:t.chunkUploaderEmits,setup(l,{expose:k,emit:f}){const h=l,c=f,u=e.ref(null),s=`vue-chunk-uploader-reka-${Math.random().toString(36).slice(2,9)}`,{hasError:m,progress:r,uploadFile:_,clear:C}=t.useChunkUpload(h,c),g=n=>{var d;const o=((d=n.target.files)==null?void 0:d[0])??null;c("update:modelValue",o)},v=()=>{u.value&&(u.value.value=""),C()};return k({uploadFile:_}),(n,o)=>(e.openBlock(),e.createElementBlock("div",y,[e.createElementVNode("div",U,[l.label?(e.openBlock(),e.createBlock(e.unref(a.Label),{key:0,class:"vue-chunk-uploader-reka__label",for:s},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(l.label),1)]),_:1})):e.createCommentVNode("",!0),e.createElementVNode("input",e.mergeProps({id:s,ref_key:"inputRef",ref:u,type:"file",class:"vue-chunk-uploader-reka__input"},n.$attrs,{onChange:g}),null,16),n.modelValue?(e.openBlock(),e.createBlock(e.unref(a.Primitive),{key:1,as:"button",type:"button",class:"vue-chunk-uploader-reka__clear","aria-label":"Clear file",onClick:v},{default:e.withCtx(()=>[...o[0]||(o[0]=[e.createTextVNode(" × ",-1)])]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(a.Primitive),{as:"span",class:"vue-chunk-uploader-reka__badge","data-error":e.unref(m)||void 0,"data-done":e.unref(r)>=100||void 0},{default:e.withCtx(()=>[e.unref(r)<100?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(e.unref(r))+"%",1)],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode("✓")],64))]),_:1},8,["data-error","data-done"])]),e.unref(r)>0&&e.unref(r)<100?(e.openBlock(),e.createBlock(e.unref(a.ProgressRoot),{key:0,class:"vue-chunk-uploader-reka__progress","model-value":e.unref(r),max:100},{default:e.withCtx(()=>[e.createVNode(e.unref(a.ProgressIndicator),{class:"vue-chunk-uploader-reka__progress-indicator",style:e.normalizeStyle({transform:`translateX(-${100-e.unref(r)}%)`})},null,8,["style"])]),_:1},8,["model-value"])):e.createCommentVNode("",!0)]))}}),i=V._export_sfc(b,[["__scopeId","data-v-14def290"]]),p=t.createChunkUploaderPlugin(i);exports.chunk=t.chunk;exports.chunkUploader=t.chunkUploader;exports.setDefaultHttpClient=t.setDefaultHttpClient;exports.useChunkUpload=t.useChunkUpload;exports.ChunkUploader=i;exports.VueChunkUploader=p;exports.default=p;
|
package/dist/reka.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { ref as N, openBlock as r, createElementBlock as d, createElementVNode as m, createBlock as c, unref as e, withCtx as l, createTextVNode as n, toDisplayString as _, createCommentVNode as i, mergeProps as S, createVNode as h, Fragment as v, normalizeStyle as B } from "vue";
|
|
2
|
+
import { Label as I, Primitive as g, ProgressRoot as R, ProgressIndicator as $ } from "reka-ui";
|
|
3
|
+
import { d as w, e as D, u as F, c as j } from "./createPlugin-DZ7dugEN.js";
|
|
4
|
+
import { a as Q, b as W, s as Y } from "./createPlugin-DZ7dugEN.js";
|
|
5
|
+
import { _ as z } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
6
|
+
const A = {
|
|
7
|
+
class: "vue-chunk-uploader-reka",
|
|
8
|
+
"data-ui": "reka"
|
|
9
|
+
}, H = { class: "vue-chunk-uploader-reka__row" }, L = /* @__PURE__ */ Object.assign({ inheritAttrs: !1 }, {
|
|
10
|
+
__name: "ChunkUploader",
|
|
11
|
+
props: {
|
|
12
|
+
...D,
|
|
13
|
+
label: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: ""
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
emits: w,
|
|
19
|
+
setup(s, { expose: y, emit: C }) {
|
|
20
|
+
const b = s, p = C, u = N(null), k = `vue-chunk-uploader-reka-${Math.random().toString(36).slice(2, 9)}`, { hasError: U, progress: a, uploadFile: V, clear: x } = F(b, p), P = (t) => {
|
|
21
|
+
var f;
|
|
22
|
+
const o = ((f = t.target.files) == null ? void 0 : f[0]) ?? null;
|
|
23
|
+
p("update:modelValue", o);
|
|
24
|
+
}, E = () => {
|
|
25
|
+
u.value && (u.value.value = ""), x();
|
|
26
|
+
};
|
|
27
|
+
return y({ uploadFile: V }), (t, o) => (r(), d("div", A, [
|
|
28
|
+
m("div", H, [
|
|
29
|
+
s.label ? (r(), c(e(I), {
|
|
30
|
+
key: 0,
|
|
31
|
+
class: "vue-chunk-uploader-reka__label",
|
|
32
|
+
for: k
|
|
33
|
+
}, {
|
|
34
|
+
default: l(() => [
|
|
35
|
+
n(_(s.label), 1)
|
|
36
|
+
]),
|
|
37
|
+
_: 1
|
|
38
|
+
})) : i("", !0),
|
|
39
|
+
m("input", S({
|
|
40
|
+
id: k,
|
|
41
|
+
ref_key: "inputRef",
|
|
42
|
+
ref: u,
|
|
43
|
+
type: "file",
|
|
44
|
+
class: "vue-chunk-uploader-reka__input"
|
|
45
|
+
}, t.$attrs, { onChange: P }), null, 16),
|
|
46
|
+
t.modelValue ? (r(), c(e(g), {
|
|
47
|
+
key: 1,
|
|
48
|
+
as: "button",
|
|
49
|
+
type: "button",
|
|
50
|
+
class: "vue-chunk-uploader-reka__clear",
|
|
51
|
+
"aria-label": "Clear file",
|
|
52
|
+
onClick: E
|
|
53
|
+
}, {
|
|
54
|
+
default: l(() => [...o[0] || (o[0] = [
|
|
55
|
+
n(" × ", -1)
|
|
56
|
+
])]),
|
|
57
|
+
_: 1
|
|
58
|
+
})) : i("", !0),
|
|
59
|
+
h(e(g), {
|
|
60
|
+
as: "span",
|
|
61
|
+
class: "vue-chunk-uploader-reka__badge",
|
|
62
|
+
"data-error": e(U) || void 0,
|
|
63
|
+
"data-done": e(a) >= 100 || void 0
|
|
64
|
+
}, {
|
|
65
|
+
default: l(() => [
|
|
66
|
+
e(a) < 100 ? (r(), d(v, { key: 0 }, [
|
|
67
|
+
n(_(e(a)) + "%", 1)
|
|
68
|
+
], 64)) : (r(), d(v, { key: 1 }, [
|
|
69
|
+
n("✓")
|
|
70
|
+
], 64))
|
|
71
|
+
]),
|
|
72
|
+
_: 1
|
|
73
|
+
}, 8, ["data-error", "data-done"])
|
|
74
|
+
]),
|
|
75
|
+
e(a) > 0 && e(a) < 100 ? (r(), c(e(R), {
|
|
76
|
+
key: 0,
|
|
77
|
+
class: "vue-chunk-uploader-reka__progress",
|
|
78
|
+
"model-value": e(a),
|
|
79
|
+
max: 100
|
|
80
|
+
}, {
|
|
81
|
+
default: l(() => [
|
|
82
|
+
h(e($), {
|
|
83
|
+
class: "vue-chunk-uploader-reka__progress-indicator",
|
|
84
|
+
style: B({ transform: `translateX(-${100 - e(a)}%)` })
|
|
85
|
+
}, null, 8, ["style"])
|
|
86
|
+
]),
|
|
87
|
+
_: 1
|
|
88
|
+
}, 8, ["model-value"])) : i("", !0)
|
|
89
|
+
]));
|
|
90
|
+
}
|
|
91
|
+
}), M = /* @__PURE__ */ z(L, [["__scopeId", "data-v-14def290"]]), G = j(M);
|
|
92
|
+
export {
|
|
93
|
+
M as ChunkUploader,
|
|
94
|
+
G as VueChunkUploader,
|
|
95
|
+
Q as chunk,
|
|
96
|
+
W as chunkUploader,
|
|
97
|
+
G as default,
|
|
98
|
+
Y as setDefaultHttpClient,
|
|
99
|
+
F as useChunkUpload
|
|
100
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.vue-chunk-uploader-native__row[data-v-0be4ee9c]{display:flex;align-items:center;gap:.5rem}.vue-chunk-uploader-native__badge[data-v-0be4ee9c]{display:inline-flex;align-items:center;justify-content:center;min-width:3rem;padding:.15rem .5rem;border-radius:999px;font-size:.85rem;background:#16a34a;color:#fff}.vue-chunk-uploader-native__badge[data-error][data-v-0be4ee9c]{background:#dc2626}.vue-chunk-uploader-native__clear[data-v-0be4ee9c]{border:0;background:transparent;cursor:pointer;font-size:1.25rem;line-height:1}.vue-chunk-uploader-native__progress[data-v-0be4ee9c]{display:block;width:100%;margin-top:.5rem;height:.5rem}
|
|
1
|
+
.vue-chunk-uploader-element-plus__status[data-v-94616f6c]{margin-top:.25rem}.vue-chunk-uploader-element-plus__progress[data-v-94616f6c]{margin-top:.5rem}.vue-chunk-uploader-native__row[data-v-0be4ee9c]{display:flex;align-items:center;gap:.5rem}.vue-chunk-uploader-native__badge[data-v-0be4ee9c]{display:inline-flex;align-items:center;justify-content:center;min-width:3rem;padding:.15rem .5rem;border-radius:999px;font-size:.85rem;background:#16a34a;color:#fff}.vue-chunk-uploader-native__badge[data-error][data-v-0be4ee9c]{background:#dc2626}.vue-chunk-uploader-native__clear[data-v-0be4ee9c]{border:0;background:transparent;cursor:pointer;font-size:1.25rem;line-height:1}.vue-chunk-uploader-native__progress[data-v-0be4ee9c]{display:block;width:100%;margin-top:.5rem;height:.5rem}.vue-chunk-uploader-reka__row[data-v-14def290]{display:flex;align-items:center;flex-wrap:wrap;gap:.5rem}.vue-chunk-uploader-reka__label[data-v-14def290]{font-size:.875rem}.vue-chunk-uploader-reka__badge[data-v-14def290]{display:inline-flex;align-items:center;justify-content:center;min-width:3rem;padding:.15rem .5rem;border-radius:999px;font-size:.85rem;background:#16a34a;color:#fff}.vue-chunk-uploader-reka__badge[data-error][data-v-14def290]{background:#dc2626}.vue-chunk-uploader-reka__clear[data-v-14def290]{border:0;background:transparent;cursor:pointer;font-size:1.25rem;line-height:1}.vue-chunk-uploader-reka__progress[data-v-14def290]{position:relative;overflow:hidden;width:100%;height:.5rem;margin-top:.5rem;border-radius:999px;background:#e5e7eb}.vue-chunk-uploader-reka__progress-indicator[data-v-14def290]{width:100%;height:100%;background:#16a34a;transition:transform .16s ease}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-chunk-uploader",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Vue 3 chunked/resumable file uploader with selectable UI adapters (Quasar, Vuetify, native)",
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "Vue 3 chunked/resumable file uploader with selectable UI adapters (Quasar, Vuetify, Reka UI, Element Plus, native)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -22,6 +22,14 @@
|
|
|
22
22
|
"import": "./dist/native.js",
|
|
23
23
|
"require": "./dist/native.cjs"
|
|
24
24
|
},
|
|
25
|
+
"./reka": {
|
|
26
|
+
"import": "./dist/reka.js",
|
|
27
|
+
"require": "./dist/reka.cjs"
|
|
28
|
+
},
|
|
29
|
+
"./element-plus": {
|
|
30
|
+
"import": "./dist/element-plus.js",
|
|
31
|
+
"require": "./dist/element-plus.cjs"
|
|
32
|
+
},
|
|
25
33
|
"./style.css": "./dist/vue-chunk-uploader.css"
|
|
26
34
|
},
|
|
27
35
|
"files": [
|
|
@@ -41,6 +49,8 @@
|
|
|
41
49
|
"vue3",
|
|
42
50
|
"quasar",
|
|
43
51
|
"vuetify",
|
|
52
|
+
"reka-ui",
|
|
53
|
+
"element-plus",
|
|
44
54
|
"uploader",
|
|
45
55
|
"chunk",
|
|
46
56
|
"resumable",
|
|
@@ -59,7 +69,9 @@
|
|
|
59
69
|
"homepage": "https://github.com/akbarjoody/vue-chunk-uploader#readme",
|
|
60
70
|
"peerDependencies": {
|
|
61
71
|
"axios": "^1.0.0",
|
|
72
|
+
"element-plus": "^2.0.0",
|
|
62
73
|
"quasar": "^2.0.0",
|
|
74
|
+
"reka-ui": "^2.0.0",
|
|
63
75
|
"vue": "^3.2.0",
|
|
64
76
|
"vuetify": "^3.0.0"
|
|
65
77
|
},
|
|
@@ -69,12 +81,20 @@
|
|
|
69
81
|
},
|
|
70
82
|
"vuetify": {
|
|
71
83
|
"optional": true
|
|
84
|
+
},
|
|
85
|
+
"reka-ui": {
|
|
86
|
+
"optional": true
|
|
87
|
+
},
|
|
88
|
+
"element-plus": {
|
|
89
|
+
"optional": true
|
|
72
90
|
}
|
|
73
91
|
},
|
|
74
92
|
"devDependencies": {
|
|
75
93
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
76
94
|
"axios": "^1.9.0",
|
|
95
|
+
"element-plus": "^2.9.0",
|
|
77
96
|
"quasar": "^2.18.5",
|
|
97
|
+
"reka-ui": "^2.10.4",
|
|
78
98
|
"vite": "^6.2.0",
|
|
79
99
|
"vue": "^3.5.13",
|
|
80
100
|
"vuetify": "^3.7.0"
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="vue-chunk-uploader-element-plus" data-ui="element-plus">
|
|
3
|
+
<el-upload
|
|
4
|
+
v-bind="$attrs"
|
|
5
|
+
action="#"
|
|
6
|
+
:auto-upload="false"
|
|
7
|
+
:limit="1"
|
|
8
|
+
:file-list="fileList"
|
|
9
|
+
:on-change="onChange"
|
|
10
|
+
:on-remove="onRemove"
|
|
11
|
+
:on-exceed="onExceed"
|
|
12
|
+
>
|
|
13
|
+
<el-button type="primary">
|
|
14
|
+
{{ buttonLabel }}
|
|
15
|
+
</el-button>
|
|
16
|
+
|
|
17
|
+
<template #tip>
|
|
18
|
+
<div class="el-upload__tip vue-chunk-uploader-element-plus__status">
|
|
19
|
+
<el-tag
|
|
20
|
+
size="small"
|
|
21
|
+
:type="hasError ? 'danger' : progress >= 100 ? 'success' : 'info'"
|
|
22
|
+
>
|
|
23
|
+
<template v-if="progress < 100">{{ progress }}%</template>
|
|
24
|
+
<template v-else>Done</template>
|
|
25
|
+
</el-tag>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
</el-upload>
|
|
29
|
+
|
|
30
|
+
<el-progress
|
|
31
|
+
v-if="progress > 0 && progress < 100"
|
|
32
|
+
class="vue-chunk-uploader-element-plus__progress"
|
|
33
|
+
:percentage="progress"
|
|
34
|
+
:status="hasError ? 'exception' : undefined"
|
|
35
|
+
:stroke-width="6"
|
|
36
|
+
/>
|
|
37
|
+
</div>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<script setup>
|
|
41
|
+
import { computed } from 'vue'
|
|
42
|
+
import { ElButton, ElProgress, ElTag, ElUpload } from 'element-plus'
|
|
43
|
+
import {
|
|
44
|
+
chunkUploaderProps,
|
|
45
|
+
chunkUploaderEmits,
|
|
46
|
+
useChunkUpload,
|
|
47
|
+
} from '../../core/useChunkUpload.js'
|
|
48
|
+
|
|
49
|
+
defineOptions({ inheritAttrs: false })
|
|
50
|
+
|
|
51
|
+
const props = defineProps({
|
|
52
|
+
...chunkUploaderProps,
|
|
53
|
+
buttonLabel: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: 'Select file',
|
|
56
|
+
},
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const emit = defineEmits(chunkUploaderEmits)
|
|
60
|
+
|
|
61
|
+
const { hasError, progress, uploadFile, clear } = useChunkUpload(props, emit)
|
|
62
|
+
|
|
63
|
+
const fileList = computed(() => {
|
|
64
|
+
if (!props.modelValue) return []
|
|
65
|
+
|
|
66
|
+
let status = 'ready'
|
|
67
|
+
if (hasError.value) status = 'fail'
|
|
68
|
+
else if (progress.value >= 100) status = 'success'
|
|
69
|
+
else if (progress.value > 0) status = 'uploading'
|
|
70
|
+
|
|
71
|
+
return [
|
|
72
|
+
{
|
|
73
|
+
name: props.modelValue.name,
|
|
74
|
+
raw: props.modelValue,
|
|
75
|
+
status,
|
|
76
|
+
percentage: progress.value,
|
|
77
|
+
},
|
|
78
|
+
]
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
const onChange = (uploadFile) => {
|
|
82
|
+
emit('update:modelValue', uploadFile?.raw ?? null)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const onRemove = () => {
|
|
86
|
+
clear()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const onExceed = (files) => {
|
|
90
|
+
const file = files?.[0]
|
|
91
|
+
if (file) {
|
|
92
|
+
emit('update:modelValue', file)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
defineExpose({ uploadFile })
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<style scoped>
|
|
100
|
+
.vue-chunk-uploader-element-plus__status {
|
|
101
|
+
margin-top: 0.25rem;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.vue-chunk-uploader-element-plus__progress {
|
|
105
|
+
margin-top: 0.5rem;
|
|
106
|
+
}
|
|
107
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import ChunkUploader from './ChunkUploader.vue'
|
|
2
|
+
import { createChunkUploaderPlugin } from '../../core/createPlugin.js'
|
|
3
|
+
import chunkUploader, { chunk, setDefaultHttpClient } from '../../core/chunkUploader.js'
|
|
4
|
+
import { useChunkUpload } from '../../core/useChunkUpload.js'
|
|
5
|
+
|
|
6
|
+
const VueChunkUploader = createChunkUploaderPlugin(ChunkUploader)
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
ChunkUploader,
|
|
10
|
+
VueChunkUploader,
|
|
11
|
+
chunkUploader,
|
|
12
|
+
chunk,
|
|
13
|
+
setDefaultHttpClient,
|
|
14
|
+
useChunkUpload,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default VueChunkUploader
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="vue-chunk-uploader-reka" data-ui="reka">
|
|
3
|
+
<div class="vue-chunk-uploader-reka__row">
|
|
4
|
+
<Label
|
|
5
|
+
v-if="label"
|
|
6
|
+
class="vue-chunk-uploader-reka__label"
|
|
7
|
+
:for="inputId"
|
|
8
|
+
>
|
|
9
|
+
{{ label }}
|
|
10
|
+
</Label>
|
|
11
|
+
|
|
12
|
+
<input
|
|
13
|
+
:id="inputId"
|
|
14
|
+
ref="inputRef"
|
|
15
|
+
type="file"
|
|
16
|
+
class="vue-chunk-uploader-reka__input"
|
|
17
|
+
v-bind="$attrs"
|
|
18
|
+
@change="onChange"
|
|
19
|
+
/>
|
|
20
|
+
|
|
21
|
+
<Primitive
|
|
22
|
+
v-if="modelValue"
|
|
23
|
+
as="button"
|
|
24
|
+
type="button"
|
|
25
|
+
class="vue-chunk-uploader-reka__clear"
|
|
26
|
+
aria-label="Clear file"
|
|
27
|
+
@click="onClear"
|
|
28
|
+
>
|
|
29
|
+
×
|
|
30
|
+
</Primitive>
|
|
31
|
+
|
|
32
|
+
<Primitive
|
|
33
|
+
as="span"
|
|
34
|
+
class="vue-chunk-uploader-reka__badge"
|
|
35
|
+
:data-error="hasError || undefined"
|
|
36
|
+
:data-done="progress >= 100 || undefined"
|
|
37
|
+
>
|
|
38
|
+
<template v-if="progress < 100">{{ progress }}%</template>
|
|
39
|
+
<template v-else>✓</template>
|
|
40
|
+
</Primitive>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<ProgressRoot
|
|
44
|
+
v-if="progress > 0 && progress < 100"
|
|
45
|
+
class="vue-chunk-uploader-reka__progress"
|
|
46
|
+
:model-value="progress"
|
|
47
|
+
:max="100"
|
|
48
|
+
>
|
|
49
|
+
<ProgressIndicator
|
|
50
|
+
class="vue-chunk-uploader-reka__progress-indicator"
|
|
51
|
+
:style="{ transform: `translateX(-${100 - progress}%)` }"
|
|
52
|
+
/>
|
|
53
|
+
</ProgressRoot>
|
|
54
|
+
</div>
|
|
55
|
+
</template>
|
|
56
|
+
|
|
57
|
+
<script setup>
|
|
58
|
+
import { ref } from 'vue'
|
|
59
|
+
import { Label, Primitive, ProgressIndicator, ProgressRoot } from 'reka-ui'
|
|
60
|
+
import {
|
|
61
|
+
chunkUploaderProps,
|
|
62
|
+
chunkUploaderEmits,
|
|
63
|
+
useChunkUpload,
|
|
64
|
+
} from '../../core/useChunkUpload.js'
|
|
65
|
+
|
|
66
|
+
defineOptions({ inheritAttrs: false })
|
|
67
|
+
|
|
68
|
+
const props = defineProps({
|
|
69
|
+
...chunkUploaderProps,
|
|
70
|
+
label: {
|
|
71
|
+
type: String,
|
|
72
|
+
default: '',
|
|
73
|
+
},
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
const emit = defineEmits(chunkUploaderEmits)
|
|
77
|
+
|
|
78
|
+
const inputRef = ref(null)
|
|
79
|
+
const inputId = `vue-chunk-uploader-reka-${Math.random().toString(36).slice(2, 9)}`
|
|
80
|
+
|
|
81
|
+
const { hasError, progress, uploadFile, clear } = useChunkUpload(props, emit)
|
|
82
|
+
|
|
83
|
+
const onChange = (event) => {
|
|
84
|
+
const file = event.target.files?.[0] ?? null
|
|
85
|
+
emit('update:modelValue', file)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const onClear = () => {
|
|
89
|
+
if (inputRef.value) {
|
|
90
|
+
inputRef.value.value = ''
|
|
91
|
+
}
|
|
92
|
+
clear()
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
defineExpose({ uploadFile })
|
|
96
|
+
</script>
|
|
97
|
+
|
|
98
|
+
<style scoped>
|
|
99
|
+
.vue-chunk-uploader-reka__row {
|
|
100
|
+
display: flex;
|
|
101
|
+
align-items: center;
|
|
102
|
+
flex-wrap: wrap;
|
|
103
|
+
gap: 0.5rem;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.vue-chunk-uploader-reka__label {
|
|
107
|
+
font-size: 0.875rem;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.vue-chunk-uploader-reka__badge {
|
|
111
|
+
display: inline-flex;
|
|
112
|
+
align-items: center;
|
|
113
|
+
justify-content: center;
|
|
114
|
+
min-width: 3rem;
|
|
115
|
+
padding: 0.15rem 0.5rem;
|
|
116
|
+
border-radius: 999px;
|
|
117
|
+
font-size: 0.85rem;
|
|
118
|
+
background: #16a34a;
|
|
119
|
+
color: #fff;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.vue-chunk-uploader-reka__badge[data-error] {
|
|
123
|
+
background: #dc2626;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.vue-chunk-uploader-reka__clear {
|
|
127
|
+
border: 0;
|
|
128
|
+
background: transparent;
|
|
129
|
+
cursor: pointer;
|
|
130
|
+
font-size: 1.25rem;
|
|
131
|
+
line-height: 1;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.vue-chunk-uploader-reka__progress {
|
|
135
|
+
position: relative;
|
|
136
|
+
overflow: hidden;
|
|
137
|
+
width: 100%;
|
|
138
|
+
height: 0.5rem;
|
|
139
|
+
margin-top: 0.5rem;
|
|
140
|
+
border-radius: 999px;
|
|
141
|
+
background: #e5e7eb;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.vue-chunk-uploader-reka__progress-indicator {
|
|
145
|
+
width: 100%;
|
|
146
|
+
height: 100%;
|
|
147
|
+
background: #16a34a;
|
|
148
|
+
transition: transform 160ms ease;
|
|
149
|
+
}
|
|
150
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import ChunkUploader from './ChunkUploader.vue'
|
|
2
|
+
import { createChunkUploaderPlugin } from '../../core/createPlugin.js'
|
|
3
|
+
import chunkUploader, { chunk, setDefaultHttpClient } from '../../core/chunkUploader.js'
|
|
4
|
+
import { useChunkUpload } from '../../core/useChunkUpload.js'
|
|
5
|
+
|
|
6
|
+
const VueChunkUploader = createChunkUploaderPlugin(ChunkUploader)
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
ChunkUploader,
|
|
10
|
+
VueChunkUploader,
|
|
11
|
+
chunkUploader,
|
|
12
|
+
chunk,
|
|
13
|
+
setDefaultHttpClient,
|
|
14
|
+
useChunkUpload,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default VueChunkUploader
|