@adminforth/upload 1.0.23 → 1.0.25
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/ChangeLog.md +7 -0
- package/custom/uploader.vue +13 -4
- package/dist/custom/uploader.vue +13 -4
- package/package.json +1 -1
package/ChangeLog.md
ADDED
package/custom/uploader.vue
CHANGED
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
</div>
|
|
60
60
|
|
|
61
61
|
</div>
|
|
62
|
-
<input :id="inputId" type="file" class="hidden" @change="onFileChange" ref="uploadInputRef" />
|
|
62
|
+
<input :id="inputId" type="file" :accept="allowedExtensionsAttribute" class="hidden" @change="onFileChange" ref="uploadInputRef" />
|
|
63
63
|
</label>
|
|
64
64
|
</div>
|
|
65
65
|
|
|
@@ -134,6 +134,13 @@ const allowedExtensionsLabel = computed(() => {
|
|
|
134
134
|
return label
|
|
135
135
|
});
|
|
136
136
|
|
|
137
|
+
const allowedExtensionsAttribute = computed(() => {
|
|
138
|
+
const allowedExtensions = props.meta.allowedExtensions || [];
|
|
139
|
+
return allowedExtensions.length > 0
|
|
140
|
+
? allowedExtensions.map(ext => `.${ext}`).join(', ')
|
|
141
|
+
: '';
|
|
142
|
+
});
|
|
143
|
+
|
|
137
144
|
function clear() {
|
|
138
145
|
imgPreview.value = null;
|
|
139
146
|
progress.value = 0;
|
|
@@ -159,7 +166,9 @@ function humanifySize(size) {
|
|
|
159
166
|
|
|
160
167
|
const onFileChange = async (e) => {
|
|
161
168
|
// if empty then return
|
|
162
|
-
|
|
169
|
+
const files = e.target?.files || e.dataTransfer.files
|
|
170
|
+
|
|
171
|
+
if (!files || files.length === 0) {
|
|
163
172
|
return;
|
|
164
173
|
}
|
|
165
174
|
|
|
@@ -167,14 +176,14 @@ const onFileChange = async (e) => {
|
|
|
167
176
|
progress.value = 0;
|
|
168
177
|
uploaded.value = false;
|
|
169
178
|
|
|
170
|
-
const file =
|
|
179
|
+
const file = files[0];
|
|
171
180
|
|
|
172
181
|
// get filename, extension, size, mimeType
|
|
173
182
|
const { name, size, type } = file;
|
|
174
183
|
|
|
175
184
|
uploadedSize.value = size;
|
|
176
185
|
|
|
177
|
-
|
|
186
|
+
|
|
178
187
|
const extension = name.split('.').pop();
|
|
179
188
|
const nameNoExtension = name.replace(`.${extension}`, '');
|
|
180
189
|
console.log('File details:', { name, extension, size, type });
|
package/dist/custom/uploader.vue
CHANGED
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
</div>
|
|
60
60
|
|
|
61
61
|
</div>
|
|
62
|
-
<input :id="inputId" type="file" class="hidden" @change="onFileChange" ref="uploadInputRef" />
|
|
62
|
+
<input :id="inputId" type="file" :accept="allowedExtensionsAttribute" class="hidden" @change="onFileChange" ref="uploadInputRef" />
|
|
63
63
|
</label>
|
|
64
64
|
</div>
|
|
65
65
|
|
|
@@ -134,6 +134,13 @@ const allowedExtensionsLabel = computed(() => {
|
|
|
134
134
|
return label
|
|
135
135
|
});
|
|
136
136
|
|
|
137
|
+
const allowedExtensionsAttribute = computed(() => {
|
|
138
|
+
const allowedExtensions = props.meta.allowedExtensions || [];
|
|
139
|
+
return allowedExtensions.length > 0
|
|
140
|
+
? allowedExtensions.map(ext => `.${ext}`).join(', ')
|
|
141
|
+
: '';
|
|
142
|
+
});
|
|
143
|
+
|
|
137
144
|
function clear() {
|
|
138
145
|
imgPreview.value = null;
|
|
139
146
|
progress.value = 0;
|
|
@@ -159,7 +166,9 @@ function humanifySize(size) {
|
|
|
159
166
|
|
|
160
167
|
const onFileChange = async (e) => {
|
|
161
168
|
// if empty then return
|
|
162
|
-
|
|
169
|
+
const files = e.target?.files || e.dataTransfer.files
|
|
170
|
+
|
|
171
|
+
if (!files || files.length === 0) {
|
|
163
172
|
return;
|
|
164
173
|
}
|
|
165
174
|
|
|
@@ -167,14 +176,14 @@ const onFileChange = async (e) => {
|
|
|
167
176
|
progress.value = 0;
|
|
168
177
|
uploaded.value = false;
|
|
169
178
|
|
|
170
|
-
const file =
|
|
179
|
+
const file = files[0];
|
|
171
180
|
|
|
172
181
|
// get filename, extension, size, mimeType
|
|
173
182
|
const { name, size, type } = file;
|
|
174
183
|
|
|
175
184
|
uploadedSize.value = size;
|
|
176
185
|
|
|
177
|
-
|
|
186
|
+
|
|
178
187
|
const extension = name.split('.').pop();
|
|
179
188
|
const nameNoExtension = name.replace(`.${extension}`, '');
|
|
180
189
|
console.log('File details:', { name, extension, size, type });
|