@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 ADDED
@@ -0,0 +1,7 @@
1
+
2
+
3
+ ## [1.0.23] - 2021-10-07
4
+
5
+ ### Fixed
6
+ - preview maxWidth to limit max width of image
7
+ - Added accept attribute to input
@@ -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
- if (!e.target.files || e.target.files.length === 0) {
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 = e.target.files ? e.target.files[0] : e.dataTransfer.files[0];
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 });
@@ -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
- if (!e.target.files || e.target.files.length === 0) {
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 = e.target.files ? e.target.files[0] : e.dataTransfer.files[0];
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/upload",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",