vue-chunk-uploader 1.3.0 → 1.4.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 +70 -3
- package/dist/ant-design.cjs +1 -0
- package/dist/ant-design.js +84 -0
- package/dist/naive.cjs +1 -0
- package/dist/naive.js +94 -0
- package/dist/vue-chunk-uploader.css +1 -1
- package/package.json +23 -2
- package/src/index.js +2 -0
- package/src/ui/ant-design/ChunkUploader.vue +106 -0
- package/src/ui/ant-design/index.js +17 -0
- package/src/ui/naive/ChunkUploader.vue +106 -0
- package/src/ui/naive/index.js +17 -0
package/README.md
CHANGED
|
@@ -12,10 +12,12 @@ The upload core is UI-agnostic — you choose which adapter to use.
|
|
|
12
12
|
| `vue-chunk-uploader/vuetify` | Vuetify 3 | `vuetify` |
|
|
13
13
|
| `vue-chunk-uploader/reka` | [Reka UI](https://reka-ui.com/) | `reka-ui` |
|
|
14
14
|
| `vue-chunk-uploader/element-plus` | [Element Plus](https://element-plus.org/) | `element-plus` |
|
|
15
|
+
| `vue-chunk-uploader/ant-design` | [Ant Design Vue](https://antdv.com/) | `ant-design-vue` |
|
|
16
|
+
| `vue-chunk-uploader/naive` | [Naive UI](https://www.naiveui.com/) | `naive-ui` |
|
|
15
17
|
| `vue-chunk-uploader/native` | Plain HTML | — |
|
|
16
18
|
| `vue-chunk-uploader` | Core only (no UI) | — |
|
|
17
19
|
|
|
18
|
-
> **Note about MUI:** Material UI is for React. In the Vue ecosystem, the closest equivalent is **Vuetify**. For other UIs
|
|
20
|
+
> **Note about MUI:** Material UI is for React. In the Vue ecosystem, the closest equivalent is **Vuetify**. For other UIs, use `native`, `reka`, or the `useChunkUpload` composable and build your own UI.
|
|
19
21
|
|
|
20
22
|
## Install
|
|
21
23
|
|
|
@@ -37,6 +39,12 @@ npm install reka-ui
|
|
|
37
39
|
|
|
38
40
|
# or Element Plus
|
|
39
41
|
npm install element-plus
|
|
42
|
+
|
|
43
|
+
# or Ant Design Vue
|
|
44
|
+
npm install ant-design-vue
|
|
45
|
+
|
|
46
|
+
# or Naive UI
|
|
47
|
+
npm install naive-ui
|
|
40
48
|
```
|
|
41
49
|
|
|
42
50
|
## Usage — Quasar
|
|
@@ -126,6 +134,65 @@ const file = ref(null)
|
|
|
126
134
|
</script>
|
|
127
135
|
```
|
|
128
136
|
|
|
137
|
+
## Usage — Ant Design Vue
|
|
138
|
+
|
|
139
|
+
```js
|
|
140
|
+
import Antd from 'ant-design-vue'
|
|
141
|
+
import 'ant-design-vue/dist/reset.css'
|
|
142
|
+
import VueChunkUploader from 'vue-chunk-uploader/ant-design'
|
|
143
|
+
|
|
144
|
+
app.use(Antd)
|
|
145
|
+
app.use(VueChunkUploader, { httpClient: api })
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
```vue
|
|
149
|
+
<template>
|
|
150
|
+
<ChunkUploader
|
|
151
|
+
v-model="file"
|
|
152
|
+
url="/api/document/chunk/upload"
|
|
153
|
+
button-label="Select file"
|
|
154
|
+
accept=".pdf,.png"
|
|
155
|
+
@onSuccess="onSuccess"
|
|
156
|
+
/>
|
|
157
|
+
</template>
|
|
158
|
+
|
|
159
|
+
<script setup>
|
|
160
|
+
import { ref } from 'vue'
|
|
161
|
+
import { ChunkUploader } from 'vue-chunk-uploader/ant-design'
|
|
162
|
+
|
|
163
|
+
const file = ref(null)
|
|
164
|
+
</script>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Usage — Naive UI
|
|
168
|
+
|
|
169
|
+
```js
|
|
170
|
+
import naive from 'naive-ui'
|
|
171
|
+
import VueChunkUploader from 'vue-chunk-uploader/naive'
|
|
172
|
+
|
|
173
|
+
app.use(naive)
|
|
174
|
+
app.use(VueChunkUploader, { httpClient: api })
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
```vue
|
|
178
|
+
<template>
|
|
179
|
+
<ChunkUploader
|
|
180
|
+
v-model="file"
|
|
181
|
+
url="/api/document/chunk/upload"
|
|
182
|
+
button-label="Select file"
|
|
183
|
+
accept=".pdf,.png"
|
|
184
|
+
@onSuccess="onSuccess"
|
|
185
|
+
/>
|
|
186
|
+
</template>
|
|
187
|
+
|
|
188
|
+
<script setup>
|
|
189
|
+
import { ref } from 'vue'
|
|
190
|
+
import { ChunkUploader } from 'vue-chunk-uploader/naive'
|
|
191
|
+
|
|
192
|
+
const file = ref(null)
|
|
193
|
+
</script>
|
|
194
|
+
```
|
|
195
|
+
|
|
129
196
|
## Usage — Reka UI
|
|
130
197
|
|
|
131
198
|
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).
|
|
@@ -246,9 +313,9 @@ await chunk(
|
|
|
246
313
|
| `maxRequestsPerMinute` | `number` | `80` | Client-side rate limit |
|
|
247
314
|
| `rateLimitWindowMs` | `number` | `60000` | Rate-limit window |
|
|
248
315
|
| `label` | `string` | `''` | Label text (Reka adapter) |
|
|
249
|
-
| `buttonLabel` | `string` | `'Select file'` | Button text (Element Plus
|
|
316
|
+
| `buttonLabel` | `string` | `'Select file'` | Button text (Element Plus / Ant Design / Naive UI adapters) |
|
|
250
317
|
|
|
251
|
-
UI-specific attrs are forwarded as well (e.g. `q-file`, `v-file-input`, `el-upload`, or native `input[type=file]` attrs).
|
|
318
|
+
UI-specific attrs are forwarded as well (e.g. `q-file`, `v-file-input`, `el-upload`, `a-upload`, `n-upload`, or native `input[type=file]` attrs).
|
|
252
319
|
|
|
253
320
|
## Events
|
|
254
321
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),u=require("ant-design-vue"),o=require("./createPlugin-DoOjwZfd.cjs"),v=require("./_plugin-vue_export-helper-BHFhmbuH.cjs"),C={class:"vue-chunk-uploader-ant-design","data-ui":"ant-design"},V={key:0,class:"vue-chunk-uploader-ant-design__status"},U=Object.assign({inheritAttrs:!1},{__name:"ChunkUploader",props:{...o.chunkUploaderProps,buttonLabel:{type:String,default:"Select file"}},emits:o.chunkUploaderEmits,setup(l,{expose:d,emit:p}){const n=l,s=p,{hasError:a,progress:t,uploadFile:f,clear:k}=o.useChunkUpload(n,s),m=e.computed(()=>a.value?"error":t.value>=100?"success":"processing"),h=e.computed(()=>{if(!n.modelValue)return[];let r="done";return a.value?r="error":t.value>0&&t.value<100?r="uploading":t.value>=100?r="done":r="ready",[{uid:"-1",name:n.modelValue.name,status:r,percent:t.value,originFileObj:n.modelValue}]}),g=r=>(s("update:modelValue",r),!1),_=()=>(k(),!0);return d({uploadFile:f}),(r,x)=>(e.openBlock(),e.createElementBlock("div",C,[e.createVNode(e.unref(u.Upload),e.mergeProps(r.$attrs,{"file-list":h.value,"before-upload":g,"max-count":1,onRemove:_}),{default:e.withCtx(()=>[e.createVNode(e.unref(u.Button),{type:"primary"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(l.buttonLabel),1)]),_:1})]),_:1},16,["file-list"]),e.unref(t)>0?(e.openBlock(),e.createElementBlock("div",V,[e.createVNode(e.unref(u.Tag),{color:m.value},{default:e.withCtx(()=>[e.unref(t)<100?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(e.unref(t))+"%",1)],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode("Done")],64))]),_:1},8,["color"])])):e.createCommentVNode("",!0),e.unref(t)>0&&e.unref(t)<100?(e.openBlock(),e.createBlock(e.unref(u.Progress),{key:1,class:"vue-chunk-uploader-ant-design__progress",percent:e.unref(t),status:e.unref(a)?"exception":"active","stroke-width":6,size:"small"},null,8,["percent","status"])):e.createCommentVNode("",!0)]))}}),c=v._export_sfc(U,[["__scopeId","data-v-feea6628"]]),i=o.createChunkUploaderPlugin(c);exports.chunk=o.chunk;exports.chunkUploader=o.chunkUploader;exports.setDefaultHttpClient=o.setDefaultHttpClient;exports.useChunkUpload=o.useChunkUpload;exports.ChunkUploader=c;exports.VueChunkUploader=i;exports.default=i;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { computed as p, openBlock as o, createElementBlock as s, createVNode as n, unref as t, mergeProps as x, withCtx as u, createTextVNode as c, toDisplayString as m, Fragment as f, createCommentVNode as k, createBlock as V } from "vue";
|
|
2
|
+
import { Upload as B, Button as P, Tag as D, Progress as E } from "ant-design-vue";
|
|
3
|
+
import { d as F, e as L, u as N, c as S } from "./createPlugin-DZ7dugEN.js";
|
|
4
|
+
import { a as K, b as M, s as Q } from "./createPlugin-DZ7dugEN.js";
|
|
5
|
+
import { _ as j } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
6
|
+
const w = {
|
|
7
|
+
class: "vue-chunk-uploader-ant-design",
|
|
8
|
+
"data-ui": "ant-design"
|
|
9
|
+
}, O = {
|
|
10
|
+
key: 0,
|
|
11
|
+
class: "vue-chunk-uploader-ant-design__status"
|
|
12
|
+
}, R = /* @__PURE__ */ Object.assign({ inheritAttrs: !1 }, {
|
|
13
|
+
__name: "ChunkUploader",
|
|
14
|
+
props: {
|
|
15
|
+
...L,
|
|
16
|
+
buttonLabel: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: "Select file"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
emits: F,
|
|
22
|
+
setup(i, { expose: h, emit: _ }) {
|
|
23
|
+
const r = i, d = _, { hasError: l, progress: e, uploadFile: v, clear: g } = N(r, d), U = p(() => l.value ? "error" : e.value >= 100 ? "success" : "processing"), b = p(() => {
|
|
24
|
+
if (!r.modelValue) return [];
|
|
25
|
+
let a = "done";
|
|
26
|
+
return l.value ? a = "error" : e.value > 0 && e.value < 100 ? a = "uploading" : e.value >= 100 ? a = "done" : a = "ready", [
|
|
27
|
+
{
|
|
28
|
+
uid: "-1",
|
|
29
|
+
name: r.modelValue.name,
|
|
30
|
+
status: a,
|
|
31
|
+
percent: e.value,
|
|
32
|
+
originFileObj: r.modelValue
|
|
33
|
+
}
|
|
34
|
+
];
|
|
35
|
+
}), y = (a) => (d("update:modelValue", a), !1), C = () => (g(), !0);
|
|
36
|
+
return h({ uploadFile: v }), (a, z) => (o(), s("div", w, [
|
|
37
|
+
n(t(B), x(a.$attrs, {
|
|
38
|
+
"file-list": b.value,
|
|
39
|
+
"before-upload": y,
|
|
40
|
+
"max-count": 1,
|
|
41
|
+
onRemove: C
|
|
42
|
+
}), {
|
|
43
|
+
default: u(() => [
|
|
44
|
+
n(t(P), { type: "primary" }, {
|
|
45
|
+
default: u(() => [
|
|
46
|
+
c(m(i.buttonLabel), 1)
|
|
47
|
+
]),
|
|
48
|
+
_: 1
|
|
49
|
+
})
|
|
50
|
+
]),
|
|
51
|
+
_: 1
|
|
52
|
+
}, 16, ["file-list"]),
|
|
53
|
+
t(e) > 0 ? (o(), s("div", O, [
|
|
54
|
+
n(t(D), { color: U.value }, {
|
|
55
|
+
default: u(() => [
|
|
56
|
+
t(e) < 100 ? (o(), s(f, { key: 0 }, [
|
|
57
|
+
c(m(t(e)) + "%", 1)
|
|
58
|
+
], 64)) : (o(), s(f, { key: 1 }, [
|
|
59
|
+
c("Done")
|
|
60
|
+
], 64))
|
|
61
|
+
]),
|
|
62
|
+
_: 1
|
|
63
|
+
}, 8, ["color"])
|
|
64
|
+
])) : k("", !0),
|
|
65
|
+
t(e) > 0 && t(e) < 100 ? (o(), V(t(E), {
|
|
66
|
+
key: 1,
|
|
67
|
+
class: "vue-chunk-uploader-ant-design__progress",
|
|
68
|
+
percent: t(e),
|
|
69
|
+
status: t(l) ? "exception" : "active",
|
|
70
|
+
"stroke-width": 6,
|
|
71
|
+
size: "small"
|
|
72
|
+
}, null, 8, ["percent", "status"])) : k("", !0)
|
|
73
|
+
]));
|
|
74
|
+
}
|
|
75
|
+
}), T = /* @__PURE__ */ j(R, [["__scopeId", "data-v-feea6628"]]), q = S(T);
|
|
76
|
+
export {
|
|
77
|
+
T as ChunkUploader,
|
|
78
|
+
q as VueChunkUploader,
|
|
79
|
+
K as chunk,
|
|
80
|
+
M as chunkUploader,
|
|
81
|
+
q as default,
|
|
82
|
+
Q as setDefaultHttpClient,
|
|
83
|
+
N as useChunkUpload
|
|
84
|
+
};
|
package/dist/naive.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),a=require("naive-ui"),r=require("./createPlugin-DoOjwZfd.cjs"),_=require("./_plugin-vue_export-helper-BHFhmbuH.cjs"),C={class:"vue-chunk-uploader-naive","data-ui":"naive"},U={key:0,class:"vue-chunk-uploader-naive__status"},V=Object.assign({inheritAttrs:!1},{__name:"ChunkUploader",props:{...r.chunkUploaderProps,buttonLabel:{type:String,default:"Select file"}},emits:r.chunkUploaderEmits,setup(l,{expose:i,emit:p}){const u=l,s=p,{hasError:o,progress:n,uploadFile:f,clear:h}=r.useChunkUpload(u,s),k=e.computed(()=>o.value?"error":n.value>=100?"success":"info"),m=e.computed(()=>{if(!u.modelValue)return[];let t="pending";return o.value?t="error":n.value>=100?t="finished":n.value>0&&(t="uploading"),[{id:"vue-chunk-uploader",name:u.modelValue.name,status:t,percentage:n.value,file:u.modelValue}]}),v=({file:t})=>{(t==null?void 0:t.status)!=="removed"&&s("update:modelValue",(t==null?void 0:t.file)??null)},g=()=>{h()};return i({uploadFile:f}),(t,y)=>(e.openBlock(),e.createElementBlock("div",C,[e.createVNode(e.unref(a.NUpload),e.mergeProps(t.$attrs,{"file-list":m.value,"default-upload":!1,max:1,onChange:v,onRemove:g}),{default:e.withCtx(()=>[e.createVNode(e.unref(a.NButton),{type:"primary"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(l.buttonLabel),1)]),_:1})]),_:1},16,["file-list"]),e.unref(n)>0?(e.openBlock(),e.createElementBlock("div",U,[e.createVNode(e.unref(a.NTag),{type:k.value,size:"small",round:""},{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"])])):e.createCommentVNode("",!0),e.unref(n)>0&&e.unref(n)<100?(e.openBlock(),e.createBlock(e.unref(a.NProgress),{key:1,class:"vue-chunk-uploader-naive__progress",type:"line",percentage:e.unref(n),status:e.unref(o)?"error":void 0,height:6,"show-indicator":!1},null,8,["percentage","status"])):e.createCommentVNode("",!0)]))}}),c=_._export_sfc(V,[["__scopeId","data-v-6f64a1ad"]]),d=r.createChunkUploaderPlugin(c);exports.chunk=r.chunk;exports.chunkUploader=r.chunkUploader;exports.setDefaultHttpClient=r.setDefaultHttpClient;exports.useChunkUpload=r.useChunkUpload;exports.ChunkUploader=c;exports.VueChunkUploader=d;exports.default=d;
|
package/dist/naive.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { computed as p, openBlock as r, createElementBlock as s, createVNode as u, unref as t, mergeProps as x, withCtx as l, createTextVNode as c, toDisplayString as m, Fragment as f, createCommentVNode as h, createBlock as N } from "vue";
|
|
2
|
+
import { NUpload as b, NButton as B, NTag as P, NProgress as D } from "naive-ui";
|
|
3
|
+
import { d as E, e as L, u as S, c as T } from "./createPlugin-DZ7dugEN.js";
|
|
4
|
+
import { a as K, b as M, s as Q } from "./createPlugin-DZ7dugEN.js";
|
|
5
|
+
import { _ as w } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
6
|
+
const F = {
|
|
7
|
+
class: "vue-chunk-uploader-naive",
|
|
8
|
+
"data-ui": "naive"
|
|
9
|
+
}, R = {
|
|
10
|
+
key: 0,
|
|
11
|
+
class: "vue-chunk-uploader-naive__status"
|
|
12
|
+
}, j = /* @__PURE__ */ Object.assign({ inheritAttrs: !1 }, {
|
|
13
|
+
__name: "ChunkUploader",
|
|
14
|
+
props: {
|
|
15
|
+
...L,
|
|
16
|
+
buttonLabel: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: "Select file"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
emits: E,
|
|
22
|
+
setup(d, { expose: v, emit: k }) {
|
|
23
|
+
const o = d, i = k, { hasError: n, progress: a, uploadFile: _, clear: g } = S(o, i), y = p(() => n.value ? "error" : a.value >= 100 ? "success" : "info"), C = p(() => {
|
|
24
|
+
if (!o.modelValue) return [];
|
|
25
|
+
let e = "pending";
|
|
26
|
+
return n.value ? e = "error" : a.value >= 100 ? e = "finished" : a.value > 0 && (e = "uploading"), [
|
|
27
|
+
{
|
|
28
|
+
id: "vue-chunk-uploader",
|
|
29
|
+
name: o.modelValue.name,
|
|
30
|
+
status: e,
|
|
31
|
+
percentage: a.value,
|
|
32
|
+
file: o.modelValue
|
|
33
|
+
}
|
|
34
|
+
];
|
|
35
|
+
}), U = ({ file: e }) => {
|
|
36
|
+
(e == null ? void 0 : e.status) !== "removed" && i("update:modelValue", (e == null ? void 0 : e.file) ?? null);
|
|
37
|
+
}, V = () => {
|
|
38
|
+
g();
|
|
39
|
+
};
|
|
40
|
+
return v({ uploadFile: _ }), (e, A) => (r(), s("div", F, [
|
|
41
|
+
u(t(b), x(e.$attrs, {
|
|
42
|
+
"file-list": C.value,
|
|
43
|
+
"default-upload": !1,
|
|
44
|
+
max: 1,
|
|
45
|
+
onChange: U,
|
|
46
|
+
onRemove: V
|
|
47
|
+
}), {
|
|
48
|
+
default: l(() => [
|
|
49
|
+
u(t(B), { type: "primary" }, {
|
|
50
|
+
default: l(() => [
|
|
51
|
+
c(m(d.buttonLabel), 1)
|
|
52
|
+
]),
|
|
53
|
+
_: 1
|
|
54
|
+
})
|
|
55
|
+
]),
|
|
56
|
+
_: 1
|
|
57
|
+
}, 16, ["file-list"]),
|
|
58
|
+
t(a) > 0 ? (r(), s("div", R, [
|
|
59
|
+
u(t(P), {
|
|
60
|
+
type: y.value,
|
|
61
|
+
size: "small",
|
|
62
|
+
round: ""
|
|
63
|
+
}, {
|
|
64
|
+
default: l(() => [
|
|
65
|
+
t(a) < 100 ? (r(), s(f, { key: 0 }, [
|
|
66
|
+
c(m(t(a)) + "%", 1)
|
|
67
|
+
], 64)) : (r(), s(f, { key: 1 }, [
|
|
68
|
+
c("Done")
|
|
69
|
+
], 64))
|
|
70
|
+
]),
|
|
71
|
+
_: 1
|
|
72
|
+
}, 8, ["type"])
|
|
73
|
+
])) : h("", !0),
|
|
74
|
+
t(a) > 0 && t(a) < 100 ? (r(), N(t(D), {
|
|
75
|
+
key: 1,
|
|
76
|
+
class: "vue-chunk-uploader-naive__progress",
|
|
77
|
+
type: "line",
|
|
78
|
+
percentage: t(a),
|
|
79
|
+
status: t(n) ? "error" : void 0,
|
|
80
|
+
height: 6,
|
|
81
|
+
"show-indicator": !1
|
|
82
|
+
}, null, 8, ["percentage", "status"])) : h("", !0)
|
|
83
|
+
]));
|
|
84
|
+
}
|
|
85
|
+
}), z = /* @__PURE__ */ w(j, [["__scopeId", "data-v-6f64a1ad"]]), q = T(z);
|
|
86
|
+
export {
|
|
87
|
+
z as ChunkUploader,
|
|
88
|
+
q as VueChunkUploader,
|
|
89
|
+
K as chunk,
|
|
90
|
+
M as chunkUploader,
|
|
91
|
+
q as default,
|
|
92
|
+
Q as setDefaultHttpClient,
|
|
93
|
+
S as useChunkUpload
|
|
94
|
+
};
|
|
@@ -1 +1 @@
|
|
|
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}
|
|
1
|
+
.vue-chunk-uploader-ant-design__status[data-v-feea6628]{margin-top:.25rem}.vue-chunk-uploader-ant-design__progress[data-v-feea6628]{margin-top:.5rem}.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-naive__status[data-v-6f64a1ad]{margin-top:.25rem}.vue-chunk-uploader-naive__progress[data-v-6f64a1ad]{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, Reka UI, Element Plus, native)",
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"description": "Vue 3 chunked/resumable file uploader with selectable UI adapters (Quasar, Vuetify, Reka UI, Element Plus, Ant Design Vue, Naive UI, native)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -30,6 +30,14 @@
|
|
|
30
30
|
"import": "./dist/element-plus.js",
|
|
31
31
|
"require": "./dist/element-plus.cjs"
|
|
32
32
|
},
|
|
33
|
+
"./ant-design": {
|
|
34
|
+
"import": "./dist/ant-design.js",
|
|
35
|
+
"require": "./dist/ant-design.cjs"
|
|
36
|
+
},
|
|
37
|
+
"./naive": {
|
|
38
|
+
"import": "./dist/naive.js",
|
|
39
|
+
"require": "./dist/naive.cjs"
|
|
40
|
+
},
|
|
33
41
|
"./style.css": "./dist/vue-chunk-uploader.css"
|
|
34
42
|
},
|
|
35
43
|
"files": [
|
|
@@ -51,6 +59,9 @@
|
|
|
51
59
|
"vuetify",
|
|
52
60
|
"reka-ui",
|
|
53
61
|
"element-plus",
|
|
62
|
+
"ant-design-vue",
|
|
63
|
+
"ant-design",
|
|
64
|
+
"naive-ui",
|
|
54
65
|
"uploader",
|
|
55
66
|
"chunk",
|
|
56
67
|
"resumable",
|
|
@@ -68,8 +79,10 @@
|
|
|
68
79
|
},
|
|
69
80
|
"homepage": "https://github.com/akbarjoody/vue-chunk-uploader#readme",
|
|
70
81
|
"peerDependencies": {
|
|
82
|
+
"ant-design-vue": "^4.0.0",
|
|
71
83
|
"axios": "^1.0.0",
|
|
72
84
|
"element-plus": "^2.0.0",
|
|
85
|
+
"naive-ui": "^2.0.0",
|
|
73
86
|
"quasar": "^2.0.0",
|
|
74
87
|
"reka-ui": "^2.0.0",
|
|
75
88
|
"vue": "^3.2.0",
|
|
@@ -87,12 +100,20 @@
|
|
|
87
100
|
},
|
|
88
101
|
"element-plus": {
|
|
89
102
|
"optional": true
|
|
103
|
+
},
|
|
104
|
+
"ant-design-vue": {
|
|
105
|
+
"optional": true
|
|
106
|
+
},
|
|
107
|
+
"naive-ui": {
|
|
108
|
+
"optional": true
|
|
90
109
|
}
|
|
91
110
|
},
|
|
92
111
|
"devDependencies": {
|
|
93
112
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
113
|
+
"ant-design-vue": "^4.2.6",
|
|
94
114
|
"axios": "^1.9.0",
|
|
95
115
|
"element-plus": "^2.9.0",
|
|
116
|
+
"naive-ui": "^2.45.3",
|
|
96
117
|
"quasar": "^2.18.5",
|
|
97
118
|
"reka-ui": "^2.10.4",
|
|
98
119
|
"vite": "^6.2.0",
|
package/src/index.js
CHANGED
|
@@ -13,6 +13,8 @@ import { createChunkUploaderPlugin } from './core/createPlugin.js'
|
|
|
13
13
|
* import ... from 'vue-chunk-uploader/quasar'
|
|
14
14
|
* import ... from 'vue-chunk-uploader/vuetify'
|
|
15
15
|
* import ... from 'vue-chunk-uploader/native'
|
|
16
|
+
* import ... from 'vue-chunk-uploader/ant-design'
|
|
17
|
+
* import ... from 'vue-chunk-uploader/naive'
|
|
16
18
|
*/
|
|
17
19
|
export {
|
|
18
20
|
chunkUploader,
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="vue-chunk-uploader-ant-design" data-ui="ant-design">
|
|
3
|
+
<a-upload
|
|
4
|
+
v-bind="$attrs"
|
|
5
|
+
:file-list="fileList"
|
|
6
|
+
:before-upload="beforeUpload"
|
|
7
|
+
:max-count="1"
|
|
8
|
+
@remove="onRemove"
|
|
9
|
+
>
|
|
10
|
+
<a-button type="primary">
|
|
11
|
+
{{ buttonLabel }}
|
|
12
|
+
</a-button>
|
|
13
|
+
</a-upload>
|
|
14
|
+
|
|
15
|
+
<div
|
|
16
|
+
v-if="progress > 0"
|
|
17
|
+
class="vue-chunk-uploader-ant-design__status"
|
|
18
|
+
>
|
|
19
|
+
<a-tag :color="statusColor">
|
|
20
|
+
<template v-if="progress < 100">{{ progress }}%</template>
|
|
21
|
+
<template v-else>Done</template>
|
|
22
|
+
</a-tag>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<a-progress
|
|
26
|
+
v-if="progress > 0 && progress < 100"
|
|
27
|
+
class="vue-chunk-uploader-ant-design__progress"
|
|
28
|
+
:percent="progress"
|
|
29
|
+
:status="hasError ? 'exception' : 'active'"
|
|
30
|
+
:stroke-width="6"
|
|
31
|
+
size="small"
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script setup>
|
|
37
|
+
import { computed } from 'vue'
|
|
38
|
+
import { Button as AButton, Progress as AProgress, Tag as ATag, Upload as AUpload } from 'ant-design-vue'
|
|
39
|
+
import {
|
|
40
|
+
chunkUploaderProps,
|
|
41
|
+
chunkUploaderEmits,
|
|
42
|
+
useChunkUpload,
|
|
43
|
+
} from '../../core/useChunkUpload.js'
|
|
44
|
+
|
|
45
|
+
defineOptions({ inheritAttrs: false })
|
|
46
|
+
|
|
47
|
+
const props = defineProps({
|
|
48
|
+
...chunkUploaderProps,
|
|
49
|
+
buttonLabel: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: 'Select file',
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const emit = defineEmits(chunkUploaderEmits)
|
|
56
|
+
|
|
57
|
+
const { hasError, progress, uploadFile, clear } = useChunkUpload(props, emit)
|
|
58
|
+
|
|
59
|
+
const statusColor = computed(() => {
|
|
60
|
+
if (hasError.value) return 'error'
|
|
61
|
+
if (progress.value >= 100) return 'success'
|
|
62
|
+
return 'processing'
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const fileList = computed(() => {
|
|
66
|
+
if (!props.modelValue) return []
|
|
67
|
+
|
|
68
|
+
let status = 'done'
|
|
69
|
+
if (hasError.value) status = 'error'
|
|
70
|
+
else if (progress.value > 0 && progress.value < 100) status = 'uploading'
|
|
71
|
+
else if (progress.value >= 100) status = 'done'
|
|
72
|
+
else status = 'ready'
|
|
73
|
+
|
|
74
|
+
return [
|
|
75
|
+
{
|
|
76
|
+
uid: '-1',
|
|
77
|
+
name: props.modelValue.name,
|
|
78
|
+
status,
|
|
79
|
+
percent: progress.value,
|
|
80
|
+
originFileObj: props.modelValue,
|
|
81
|
+
},
|
|
82
|
+
]
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
const beforeUpload = (file) => {
|
|
86
|
+
emit('update:modelValue', file)
|
|
87
|
+
return false
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const onRemove = () => {
|
|
91
|
+
clear()
|
|
92
|
+
return true
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
defineExpose({ uploadFile })
|
|
96
|
+
</script>
|
|
97
|
+
|
|
98
|
+
<style scoped>
|
|
99
|
+
.vue-chunk-uploader-ant-design__status {
|
|
100
|
+
margin-top: 0.25rem;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.vue-chunk-uploader-ant-design__progress {
|
|
104
|
+
margin-top: 0.5rem;
|
|
105
|
+
}
|
|
106
|
+
</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,106 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="vue-chunk-uploader-naive" data-ui="naive">
|
|
3
|
+
<n-upload
|
|
4
|
+
v-bind="$attrs"
|
|
5
|
+
:file-list="fileList"
|
|
6
|
+
:default-upload="false"
|
|
7
|
+
:max="1"
|
|
8
|
+
@change="onChange"
|
|
9
|
+
@remove="onRemove"
|
|
10
|
+
>
|
|
11
|
+
<n-button type="primary">
|
|
12
|
+
{{ buttonLabel }}
|
|
13
|
+
</n-button>
|
|
14
|
+
</n-upload>
|
|
15
|
+
|
|
16
|
+
<div
|
|
17
|
+
v-if="progress > 0"
|
|
18
|
+
class="vue-chunk-uploader-naive__status"
|
|
19
|
+
>
|
|
20
|
+
<n-tag :type="statusType" size="small" round>
|
|
21
|
+
<template v-if="progress < 100">{{ progress }}%</template>
|
|
22
|
+
<template v-else>Done</template>
|
|
23
|
+
</n-tag>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<n-progress
|
|
27
|
+
v-if="progress > 0 && progress < 100"
|
|
28
|
+
class="vue-chunk-uploader-naive__progress"
|
|
29
|
+
type="line"
|
|
30
|
+
:percentage="progress"
|
|
31
|
+
:status="hasError ? 'error' : undefined"
|
|
32
|
+
:height="6"
|
|
33
|
+
:show-indicator="false"
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
</template>
|
|
37
|
+
|
|
38
|
+
<script setup>
|
|
39
|
+
import { computed } from 'vue'
|
|
40
|
+
import { NButton, NProgress, NTag, NUpload } from 'naive-ui'
|
|
41
|
+
import {
|
|
42
|
+
chunkUploaderProps,
|
|
43
|
+
chunkUploaderEmits,
|
|
44
|
+
useChunkUpload,
|
|
45
|
+
} from '../../core/useChunkUpload.js'
|
|
46
|
+
|
|
47
|
+
defineOptions({ inheritAttrs: false })
|
|
48
|
+
|
|
49
|
+
const props = defineProps({
|
|
50
|
+
...chunkUploaderProps,
|
|
51
|
+
buttonLabel: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: 'Select file',
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
const emit = defineEmits(chunkUploaderEmits)
|
|
58
|
+
|
|
59
|
+
const { hasError, progress, uploadFile, clear } = useChunkUpload(props, emit)
|
|
60
|
+
|
|
61
|
+
const statusType = computed(() => {
|
|
62
|
+
if (hasError.value) return 'error'
|
|
63
|
+
if (progress.value >= 100) return 'success'
|
|
64
|
+
return 'info'
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
const fileList = computed(() => {
|
|
68
|
+
if (!props.modelValue) return []
|
|
69
|
+
|
|
70
|
+
let status = 'pending'
|
|
71
|
+
if (hasError.value) status = 'error'
|
|
72
|
+
else if (progress.value >= 100) status = 'finished'
|
|
73
|
+
else if (progress.value > 0) status = 'uploading'
|
|
74
|
+
|
|
75
|
+
return [
|
|
76
|
+
{
|
|
77
|
+
id: 'vue-chunk-uploader',
|
|
78
|
+
name: props.modelValue.name,
|
|
79
|
+
status,
|
|
80
|
+
percentage: progress.value,
|
|
81
|
+
file: props.modelValue,
|
|
82
|
+
},
|
|
83
|
+
]
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
const onChange = ({ file }) => {
|
|
87
|
+
if (file?.status === 'removed') return
|
|
88
|
+
emit('update:modelValue', file?.file ?? null)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const onRemove = () => {
|
|
92
|
+
clear()
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
defineExpose({ uploadFile })
|
|
96
|
+
</script>
|
|
97
|
+
|
|
98
|
+
<style scoped>
|
|
99
|
+
.vue-chunk-uploader-naive__status {
|
|
100
|
+
margin-top: 0.25rem;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.vue-chunk-uploader-naive__progress {
|
|
104
|
+
margin-top: 0.5rem;
|
|
105
|
+
}
|
|
106
|
+
</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
|