@volverjs/ui-vue 0.0.10-beta.16 → 0.0.10-beta.17
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/dist/components/VvInputFile/VvInputFile.es.js +39 -17
- package/dist/components/VvInputFile/VvInputFile.umd.js +1 -1
- package/dist/components/index.es.js +39 -17
- package/dist/components/index.umd.js +1 -1
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/package.json +1 -1
- package/src/assets/icons/detailed.json +1 -1
- package/src/assets/icons/normal.json +1 -1
- package/src/assets/icons/simple.json +1 -1
- package/src/components/VvInputFile/VvInputFile.vue +33 -10
|
@@ -155,14 +155,17 @@
|
|
|
155
155
|
localModelValue.value = toReturn
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
const currentFileIndex = ref(0)
|
|
158
159
|
const previewSrc = computed(() => {
|
|
159
160
|
if (files.value.length === 0) {
|
|
160
161
|
return
|
|
161
162
|
}
|
|
162
|
-
if (files.value[
|
|
163
|
-
return URL.createObjectURL(
|
|
163
|
+
if (files.value[currentFileIndex.value] instanceof File) {
|
|
164
|
+
return URL.createObjectURL(
|
|
165
|
+
files.value[currentFileIndex.value] as File,
|
|
166
|
+
)
|
|
164
167
|
}
|
|
165
|
-
return files.value[
|
|
168
|
+
return (files.value[currentFileIndex.value] as UploadedFile).url
|
|
166
169
|
})
|
|
167
170
|
|
|
168
171
|
onBeforeUnmount(() => {
|
|
@@ -177,6 +180,18 @@
|
|
|
177
180
|
}
|
|
178
181
|
return Math.floor(size / 1024)
|
|
179
182
|
}
|
|
183
|
+
|
|
184
|
+
const onClickDownloadFile = (file: File | UploadedFile) => {
|
|
185
|
+
const link = document.createElement('a')
|
|
186
|
+
if (file instanceof File) {
|
|
187
|
+
link.href = URL.createObjectURL(file)
|
|
188
|
+
} else if (file.url) {
|
|
189
|
+
link.href = file.url
|
|
190
|
+
}
|
|
191
|
+
link.setAttribute('download', file.name)
|
|
192
|
+
document.body.appendChild(link)
|
|
193
|
+
link.click()
|
|
194
|
+
}
|
|
180
195
|
</script>
|
|
181
196
|
|
|
182
197
|
<template>
|
|
@@ -201,7 +216,7 @@
|
|
|
201
216
|
:class="{
|
|
202
217
|
'absolute top-8 right-8': previewSrc,
|
|
203
218
|
}"
|
|
204
|
-
:icon="!previewSrc ? 'image' : 'edit'"
|
|
219
|
+
:icon="!previewSrc ? 'image' : isMultiple ? 'add' : 'edit'"
|
|
205
220
|
class="z-1"
|
|
206
221
|
@click.stop="onClick"
|
|
207
222
|
/>
|
|
@@ -209,7 +224,7 @@
|
|
|
209
224
|
<img
|
|
210
225
|
v-if="previewSrc"
|
|
211
226
|
:src="previewSrc"
|
|
212
|
-
:alt="files[
|
|
227
|
+
:alt="files[currentFileIndex].name"
|
|
213
228
|
/>
|
|
214
229
|
</picture>
|
|
215
230
|
</slot>
|
|
@@ -238,12 +253,20 @@
|
|
|
238
253
|
v-for="(file, index) in files"
|
|
239
254
|
:key="index"
|
|
240
255
|
class="vv-input-file__item"
|
|
256
|
+
@click.stop="currentFileIndex = index"
|
|
241
257
|
>
|
|
242
|
-
<
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
258
|
+
<button
|
|
259
|
+
type="button"
|
|
260
|
+
class="vv-input-file__item-icon cursor-pointer"
|
|
261
|
+
title="Download"
|
|
262
|
+
aria-label="download-file"
|
|
263
|
+
@click.stop="onClickDownloadFile(file)"
|
|
264
|
+
>
|
|
265
|
+
<VvIcon name="download" />
|
|
266
|
+
</button>
|
|
267
|
+
<div class="vv-input-file__item-name cursor-pointer">
|
|
268
|
+
{{ file.name }}
|
|
269
|
+
</div>
|
|
247
270
|
<small class="vv-input-file__item-info">
|
|
248
271
|
{{ sizeInKiB(file.size) }} KB
|
|
249
272
|
</small>
|