@progress/kendo-vue-upload 8.3.0 → 8.4.0-develop.2
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/Upload.d.ts +6 -6
- package/Upload.js +1 -1
- package/Upload.mjs +151 -118
- package/dist/cdn/js/kendo-vue-upload.js +1 -1
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +6 -7
- package/utils/connectionUtils.d.ts +8 -2
- package/utils/connectionUtils.js +1 -1
- package/utils/connectionUtils.mjs +41 -35
package/Upload.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { GroupedFiles } from './interfaces/FileGroup';
|
|
9
9
|
import { UploadFileInfo } from './interfaces/UploadFileInfo';
|
|
10
10
|
import { UploadFileStatus } from './interfaces/UploadFileStatus';
|
|
11
|
-
import {
|
|
11
|
+
import { XHRResponseData } from './utils/connectionUtils';
|
|
12
12
|
import { PropType } from 'vue';
|
|
13
13
|
/**
|
|
14
14
|
* @hidden
|
|
@@ -150,12 +150,12 @@ declare const Upload: import('vue').DefineComponent<import('vue').ExtractPropTyp
|
|
|
150
150
|
removeFiles(filesForRemove: GroupedFiles): void;
|
|
151
151
|
onUpload(): void;
|
|
152
152
|
onAdd(files: FileList): void;
|
|
153
|
-
onUploadProgress(uid: string, event: ProgressEvent
|
|
154
|
-
onUploadSuccess(uid: string, event?:
|
|
155
|
-
onUploadError(uid: string, event?:
|
|
153
|
+
onUploadProgress(uid: string, event: ProgressEvent): void;
|
|
154
|
+
onUploadSuccess(uid: string, event?: XHRResponseData): void;
|
|
155
|
+
onUploadError(uid: string, event?: XHRResponseData): void;
|
|
156
156
|
onRemove(uid: string): void;
|
|
157
|
-
onRemoveSuccess(uid: string, event?:
|
|
158
|
-
onRemoveError(uid: string, event?:
|
|
157
|
+
onRemoveSuccess(uid: string, event?: XHRResponseData): void;
|
|
158
|
+
onRemoveError(uid: string, event?: XHRResponseData): void;
|
|
159
159
|
onRetry(uid: string): void;
|
|
160
160
|
onCancel(uid: string): void;
|
|
161
161
|
onClear(): void;
|
package/Upload.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("vue"),v=require("@progress/kendo-vue-common"),h=require("./interfaces/UploadFileStatus.js"),q=require("./UploadNavigation.js"),y=require("./utils/utils.js"),u=require("./utils/stateUtils.js"),p=require("./utils/connectionUtils.js"),D=require("./utils/validationUtils.js"),x=require("./package-metadata.js"),A=S.defineComponent({name:"KendoVueUpload",props:{autoUpload:{type:Boolean,default:!0},batch:{type:Boolean,default:!1},withCredentials:{type:Boolean,default:!0},saveField:{type:String,default:function(){return"files"}},saveHeaders:{type:[String,Function,Object],default:function(){return{}}},saveMethod:{type:String,default:function(){return"POST"}},saveUrl:{type:[String,Function],default:function(){return""}},responseType:{type:String,default:function(){return"json"}},removeField:{type:String,default:function(){return"fileNames"}},removeHeaders:{type:[String,Function,Object],default:function(){return{}}},removeMethod:{type:String,default:function(){return"POST"}},removeUrl:{type:[String,Function],default:function(){return""}},multiple:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},showFileList:{type:Boolean,default:!0},showActionButtons:{type:Boolean,default:!0},actionsLayout:{type:String,default:function(){return"end"}},tabIndex:Number,accept:String,list:[String,Function,Object],restrictions:{type:Object,default:function(){return{allowedExtensions:[],maxFileSize:0,minFileSize:0}}},validateFile:Function,files:Array,defaultFiles:Array},emits:{add:null,beforeremove:null,beforeupload:null,cancel:null,statuschange:null,progress:null,remove:null},created(){this._httpSubscriptions={},v.validatePackage(x.packageMetadata),this.$props.defaultFiles&&(this.currentFiles=this.$props.defaultFiles)},data(){return{currentFiles:[]}},computed:{computedAsync(){const{autoUpload:s,batch:e,removeField:t,removeHeaders:i,removeMethod:n,removeUrl:o,responseType:l,saveField:c,saveHeaders:d,saveMethod:f,saveUrl:a,withCredentials:r}=this.$props;return{autoUpload:s,batch:e,removeField:t,removeHeaders:i,removeMethod:n,removeUrl:o,responseType:l,saveField:c,saveHeaders:d,saveMethod:f,saveUrl:a,withCredentials:r}},computedFiles(){return(this.isControlled?this.$props.files:this.currentFiles)||[]},isControlled(){return!this.$props.defaultFiles},isCustomSave(){return this.$props.saveUrl&&typeof this.$props.saveUrl=="function"},isCustomRemove(){return this.$props.removeUrl&&typeof this.$props.removeUrl=="function"},fileStateCopy(){return u.copyState(this.computedFiles)},actionElement(){if(this._uploadNavigation)return this._uploadNavigation.actionElement}},mounted(){this._uploadNavigation=this.uploadNavigationRef},methods:{focus(){this._uploadNavigation&&this._uploadNavigation.focus()},uploadFiles(s){const e=this.computedAsync;u.setFilesStatus(s,h.UploadFileStatus.Uploading),u.groupForEach(s,(t,i)=>{var f;const n=p.cloneRequestHeaders(e.saveHeaders||{}),l={target:this,files:t,headers:n,additionalData:{}};this.$emit("beforeupload",l);const c=p.populateRequestOptions(l.headers,this.computedAsync),d=p.populateUploadFormData(t,e.saveField,l.additionalData);if(this.isCustomSave)this.$props.saveUrl(t,{formData:d,requestOptions:c},this.onUploadProgress).then(a=>this.onUploadSuccess(a.uid)).catch(a=>this.onUploadError(a.uid));else{const a=new XMLHttpRequest;this._httpSubscriptions[i]=()=>a.abort(),a.open(e.saveMethod,e.saveUrl,!0),a.withCredentials=(f=c.withCredentials)!=null?f:!0,a.responseType=c.responseType||"json",Object.entries(c.headers||{}).forEach(([r,m])=>{a.setRequestHeader(r,m)}),a.upload.onprogress=r=>this.onUploadProgress(i,r),a.onload=()=>{a.status>=200&&a.status<300?this.onUploadSuccess(i,{response:a.response,status:a.status,statusText:a.statusText,request:a}):this.onUploadError(i,{response:a.response,status:a.status,statusText:a.statusText,request:a})},a.onerror=()=>this.onUploadError(i,{response:a.response,status:a.status,statusText:a.statusText,request:a}),a.onabort=()=>{},a.send(d)}})},removeFiles(s){const e=this.computedAsync;u.groupForEach(s,(t,i)=>{var a;const n=p.cloneRequestHeaders(e.removeHeaders||{}),l={target:this,files:t,headers:n,additionalData:{}};this.$emit("beforeremove",l);const c=t.map(r=>r.name),d=p.populateRequestOptions(l.headers,this.computedAsync),f=p.populateRemoveFormData(c,e.removeField,l.additionalData);if(this.isCustomRemove)this.$props.removeUrl(t,{formData:f,requestOptions:d}).then(r=>this.onRemoveSuccess(r.uid)).catch(r=>this.onRemoveError(r.uid));else{const r=new XMLHttpRequest;r.open(e.removeMethod,e.removeUrl,!0),r.withCredentials=(a=d.withCredentials)!=null?a:!0,r.responseType=d.responseType||"json",Object.entries(d.headers||{}).forEach(([m,g])=>{r.setRequestHeader(m,g)}),r.onload=()=>{r.status>=200&&r.status<300?this.onRemoveSuccess(i,{response:r.response,status:r.status,statusText:r.statusText,request:r}):this.onRemoveError(i,{response:r.response,status:r.status,statusText:r.statusText,request:r})},r.onerror=()=>this.onRemoveError(i,{response:r.response,status:r.status,statusText:r.statusText,request:r}),r.send(f)}})},onUpload(){const s=this.fileStateCopy,e=u.groupFilesByUid(s),t=u.filesForUpload(e);this.uploadFiles(t);const i=()=>{const n={target:this,newState:s,affectedFiles:u.flatFileGroup(t)};this.$emit("statuschange",n)};this.isControlled||(this.currentFiles=s),i()},onAdd(s){let e=y.getAllFileInfo(s),t;if(e=y.assignGuidToFiles(e,this.computedAsync.batch),D.validateFiles(e,this.$props.restrictions,this.validateFile),this.$props.multiple?t=this.fileStateCopy:t=[],u.addMany(e,t),this.computedAsync.autoUpload){const n=u.groupFilesByUid(t);this.uploadFiles(u.filesForUpload(n))}const i=()=>{const n={target:this,newState:t,affectedFiles:e};this.$emit("add",n)};this.isControlled||(this.currentFiles=t),i()},onUploadProgress(s,e){const t=e.total?Math.round(100*e.loaded/e.total):0,i=this.fileStateCopy,n=i.filter(l=>l.uid===s);if(!n.length)return;n.forEach(l=>{l.progress=t});const o=()=>{const l={target:this,newState:i,affectedFiles:n};this.$emit("progress",l)};this.isControlled||(this.currentFiles=i),o()},onUploadSuccess(s,e){const t=this.fileStateCopy,i=t.filter(o=>o.uid===s);i.forEach(o=>{o.status=h.UploadFileStatus.Uploaded,o.progress=100}),delete this._httpSubscriptions[s];const n=()=>{const o={target:this,newState:t,affectedFiles:i,response:e?p.convertResponse(e):void 0};this.$emit("statuschange",o)};this.isControlled||(this.currentFiles=t),n()},onUploadError(s,e){const t=this.fileStateCopy,i=t.filter(o=>o.uid===s);if(i.forEach(o=>{o.status=h.UploadFileStatus.UploadFailed}),delete this._httpSubscriptions[s],!i.length)return;const n=()=>{const o={target:this,newState:t,affectedFiles:i,response:e?p.convertResponse(e):void 0};this.$emit("statuschange",o)};this.isControlled||(this.currentFiles=t),n()},onRemove(s){const e=this.fileStateCopy,t=e.filter(o=>o.uid===s),i=e.filter(o=>o.uid!==s),n=[h.UploadFileStatus.Uploaded,h.UploadFileStatus.Initial,h.UploadFileStatus.RemoveFailed];if(t[0]&&n.indexOf(t[0].status)>-1){const o={[s]:t};u.setFilesStatus(o,h.UploadFileStatus.Removing),this.removeFiles(o);const l=()=>{const c={target:this,newState:e,affectedFiles:t};this.$emit("statuschange",c)};this.isControlled||(this.currentFiles=e),l()}else{const o=()=>{const l={target:this,newState:i,affectedFiles:t};this.$emit("remove",l)};this.isControlled||(this.currentFiles=i),o()}},onRemoveSuccess(s,e){const t=this.fileStateCopy,i=t.filter(l=>l.uid===s),n=t.filter(l=>l.uid!==s),o=()=>{const l={target:this,newState:n,affectedFiles:i,response:e?p.convertResponse(e):void 0};this.$emit("remove",l)};this.isControlled||(this.currentFiles=n),o()},onRemoveError(s,e){const t=this.fileStateCopy,i=t.filter(o=>o.uid===s);i.forEach(o=>{o.status=h.UploadFileStatus.RemoveFailed});const n=()=>{const o={target:this,newState:t,affectedFiles:i,response:e?p.convertResponse(e):void 0};this.$emit("statuschange",o)};this.isControlled||(this.currentFiles=t),n()},onRetry(s){const e=this.fileStateCopy,t=u.groupFilesByUid(e.filter(n=>n.uid===s));u.setFilesStatus(t,h.UploadFileStatus.Uploading),this.uploadFiles(t);const i=()=>{const n={target:this,newState:e,affectedFiles:u.flatFileGroup(t)};this.$emit("statuschange",n)};this.isControlled||(this.currentFiles=e),i()},onCancel(s){const e=this.fileStateCopy,t=e.filter(l=>l.uid!==s),i=e.filter(l=>l.uid===s);this._httpSubscriptions[s]&&(this._httpSubscriptions[s](),delete this._httpSubscriptions[s]);const n={target:this,uid:s};this.$emit("cancel",n);const o=()=>{const l={target:this,newState:t,affectedFiles:i};this.$emit("remove",l)};this.isControlled||(this.currentFiles=e),o()},onClear(){if(!this.computedFiles.length)return;Object.keys(this._httpSubscriptions).forEach(e=>{this._httpSubscriptions[e]()}),this._httpSubscriptions={};const s=()=>{const e={target:this,newState:[],affectedFiles:this.fileStateCopy};this.$emit("remove",e)};this.isControlled||(this.currentFiles=[]),s()}},render(){const{showFileList:s,autoUpload:e,showActionButtons:t,actionsLayout:i,tabIndex:n,disabled:o,batch:l,withCredentials:c,saveField:d,saveHeaders:f,saveMethod:a,saveUrl:r,responseType:m,removeField:g,removeHeaders:O,removeMethod:M,removeUrl:N,multiple:U,accept:C,restrictions:R,files:b,defaultFiles:E}=this.$props,$=v.templateRendering.call(this,this.$props.list,v.getListeners.call(this)),F=u.groupFilesByUid(this.computedFiles),w=u.filesForUpload(F);return S.createVNode(q.UploadNavigation,{groupedFiles:F,className:this.$props.className,showFileList:s&&!!Object.keys(F).length,showActionButtons:t&&!e&&!!Object.keys(w).length,actionsLayout:i,disabled:o,onAdd:this.onAdd,onRemove:this.onRemove,onClear:this.onClear,onUpload:this.onUpload,onRetry:this.onRetry,onCancel:this.onCancel,tabIndex:v.getTabIndex(n,o),ref:T=>{this.uploadNavigationRef=T},multiple:U,accept:C,list:$,restrictions:R,files:b,defaultFiles:E,async:this.computedAsync},null)}});exports.Upload=A;
|
package/Upload.mjs
CHANGED
|
@@ -5,17 +5,16 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { defineComponent as
|
|
9
|
-
import { templateRendering as
|
|
10
|
-
import { UploadFileStatus as
|
|
11
|
-
import { UploadNavigation as
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import r from "./utils/stateUtils.mjs";
|
|
8
|
+
import { defineComponent as w, createVNode as T } from "vue";
|
|
9
|
+
import { templateRendering as D, getListeners as x, getTabIndex as A, validatePackage as q } from "@progress/kendo-vue-common";
|
|
10
|
+
import { UploadFileStatus as h } from "./interfaces/UploadFileStatus.mjs";
|
|
11
|
+
import { UploadNavigation as O } from "./UploadNavigation.mjs";
|
|
12
|
+
import g from "./utils/utils.mjs";
|
|
13
|
+
import u from "./utils/stateUtils.mjs";
|
|
15
14
|
import d from "./utils/connectionUtils.mjs";
|
|
16
|
-
import
|
|
17
|
-
import { packageMetadata as
|
|
18
|
-
const
|
|
15
|
+
import _ from "./utils/validationUtils.mjs";
|
|
16
|
+
import { packageMetadata as B } from "./package-metadata.mjs";
|
|
17
|
+
const X = /* @__PURE__ */ w({
|
|
19
18
|
name: "KendoVueUpload",
|
|
20
19
|
props: {
|
|
21
20
|
autoUpload: {
|
|
@@ -133,7 +132,7 @@ const Q = /* @__PURE__ */ E({
|
|
|
133
132
|
remove: null
|
|
134
133
|
},
|
|
135
134
|
created() {
|
|
136
|
-
this._httpSubscriptions = {}, B
|
|
135
|
+
this._httpSubscriptions = {}, q(B), this.$props.defaultFiles && (this.currentFiles = this.$props.defaultFiles);
|
|
137
136
|
},
|
|
138
137
|
data() {
|
|
139
138
|
return {
|
|
@@ -149,12 +148,12 @@ const Q = /* @__PURE__ */ E({
|
|
|
149
148
|
removeHeaders: i,
|
|
150
149
|
removeMethod: n,
|
|
151
150
|
removeUrl: o,
|
|
152
|
-
responseType:
|
|
153
|
-
saveField:
|
|
154
|
-
saveHeaders:
|
|
155
|
-
saveMethod:
|
|
156
|
-
saveUrl:
|
|
157
|
-
withCredentials:
|
|
151
|
+
responseType: l,
|
|
152
|
+
saveField: c,
|
|
153
|
+
saveHeaders: p,
|
|
154
|
+
saveMethod: f,
|
|
155
|
+
saveUrl: a,
|
|
156
|
+
withCredentials: r
|
|
158
157
|
} = this.$props;
|
|
159
158
|
return {
|
|
160
159
|
autoUpload: s,
|
|
@@ -163,12 +162,12 @@ const Q = /* @__PURE__ */ E({
|
|
|
163
162
|
removeHeaders: i,
|
|
164
163
|
removeMethod: n,
|
|
165
164
|
removeUrl: o,
|
|
166
|
-
responseType:
|
|
167
|
-
saveField:
|
|
168
|
-
saveHeaders:
|
|
169
|
-
saveMethod:
|
|
170
|
-
saveUrl:
|
|
171
|
-
withCredentials:
|
|
165
|
+
responseType: l,
|
|
166
|
+
saveField: c,
|
|
167
|
+
saveHeaders: p,
|
|
168
|
+
saveMethod: f,
|
|
169
|
+
saveUrl: a,
|
|
170
|
+
withCredentials: r
|
|
172
171
|
};
|
|
173
172
|
},
|
|
174
173
|
computedFiles() {
|
|
@@ -184,7 +183,7 @@ const Q = /* @__PURE__ */ E({
|
|
|
184
183
|
return this.$props.removeUrl && typeof this.$props.removeUrl == "function";
|
|
185
184
|
},
|
|
186
185
|
fileStateCopy() {
|
|
187
|
-
return
|
|
186
|
+
return u.copyState(this.computedFiles);
|
|
188
187
|
},
|
|
189
188
|
actionElement() {
|
|
190
189
|
if (this._uploadNavigation)
|
|
@@ -200,73 +199,107 @@ const Q = /* @__PURE__ */ E({
|
|
|
200
199
|
},
|
|
201
200
|
uploadFiles(s) {
|
|
202
201
|
const e = this.computedAsync;
|
|
203
|
-
|
|
204
|
-
|
|
202
|
+
u.setFilesStatus(s, h.Uploading), u.groupForEach(s, (t, i) => {
|
|
203
|
+
var f;
|
|
204
|
+
const n = d.cloneRequestHeaders(e.saveHeaders || {}), l = {
|
|
205
205
|
target: this,
|
|
206
206
|
files: t,
|
|
207
207
|
headers: n,
|
|
208
208
|
additionalData: {}
|
|
209
209
|
};
|
|
210
|
-
this.$emit("beforeupload",
|
|
211
|
-
const
|
|
210
|
+
this.$emit("beforeupload", l);
|
|
211
|
+
const c = d.populateRequestOptions(l.headers, this.computedAsync), p = d.populateUploadFormData(t, e.saveField, l.additionalData);
|
|
212
212
|
if (this.isCustomSave)
|
|
213
213
|
this.$props.saveUrl(t, {
|
|
214
|
-
formData:
|
|
215
|
-
requestOptions:
|
|
216
|
-
}, this.onUploadProgress).then((
|
|
214
|
+
formData: p,
|
|
215
|
+
requestOptions: c
|
|
216
|
+
}, this.onUploadProgress).then((a) => this.onUploadSuccess(a.uid)).catch((a) => this.onUploadError(a.uid));
|
|
217
217
|
else {
|
|
218
|
-
const
|
|
219
|
-
this._httpSubscriptions[i] = c,
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
218
|
+
const a = new XMLHttpRequest();
|
|
219
|
+
this._httpSubscriptions[i] = () => a.abort(), a.open(e.saveMethod, e.saveUrl, !0), a.withCredentials = (f = c.withCredentials) != null ? f : !0, a.responseType = c.responseType || "json", Object.entries(c.headers || {}).forEach(([r, m]) => {
|
|
220
|
+
a.setRequestHeader(r, m);
|
|
221
|
+
}), a.upload.onprogress = (r) => this.onUploadProgress(i, r), a.onload = () => {
|
|
222
|
+
a.status >= 200 && a.status < 300 ? this.onUploadSuccess(i, {
|
|
223
|
+
response: a.response,
|
|
224
|
+
status: a.status,
|
|
225
|
+
statusText: a.statusText,
|
|
226
|
+
request: a
|
|
227
|
+
}) : this.onUploadError(i, {
|
|
228
|
+
response: a.response,
|
|
229
|
+
status: a.status,
|
|
230
|
+
statusText: a.statusText,
|
|
231
|
+
request: a
|
|
232
|
+
});
|
|
233
|
+
}, a.onerror = () => this.onUploadError(i, {
|
|
234
|
+
response: a.response,
|
|
235
|
+
status: a.status,
|
|
236
|
+
statusText: a.statusText,
|
|
237
|
+
request: a
|
|
238
|
+
}), a.onabort = () => {
|
|
239
|
+
}, a.send(p);
|
|
227
240
|
}
|
|
228
241
|
});
|
|
229
242
|
},
|
|
230
243
|
removeFiles(s) {
|
|
231
244
|
const e = this.computedAsync;
|
|
232
|
-
|
|
233
|
-
|
|
245
|
+
u.groupForEach(s, (t, i) => {
|
|
246
|
+
var a;
|
|
247
|
+
const n = d.cloneRequestHeaders(e.removeHeaders || {}), l = {
|
|
234
248
|
target: this,
|
|
235
249
|
files: t,
|
|
236
250
|
headers: n,
|
|
237
251
|
additionalData: {}
|
|
238
252
|
};
|
|
239
|
-
this.$emit("beforeremove",
|
|
240
|
-
const
|
|
241
|
-
this.isCustomRemove
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
253
|
+
this.$emit("beforeremove", l);
|
|
254
|
+
const c = t.map((r) => r.name), p = d.populateRequestOptions(l.headers, this.computedAsync), f = d.populateRemoveFormData(c, e.removeField, l.additionalData);
|
|
255
|
+
if (this.isCustomRemove)
|
|
256
|
+
this.$props.removeUrl(t, {
|
|
257
|
+
formData: f,
|
|
258
|
+
requestOptions: p
|
|
259
|
+
}).then((r) => this.onRemoveSuccess(r.uid)).catch((r) => this.onRemoveError(r.uid));
|
|
260
|
+
else {
|
|
261
|
+
const r = new XMLHttpRequest();
|
|
262
|
+
r.open(e.removeMethod, e.removeUrl, !0), r.withCredentials = (a = p.withCredentials) != null ? a : !0, r.responseType = p.responseType || "json", Object.entries(p.headers || {}).forEach(([m, F]) => {
|
|
263
|
+
r.setRequestHeader(m, F);
|
|
264
|
+
}), r.onload = () => {
|
|
265
|
+
r.status >= 200 && r.status < 300 ? this.onRemoveSuccess(i, {
|
|
266
|
+
response: r.response,
|
|
267
|
+
status: r.status,
|
|
268
|
+
statusText: r.statusText,
|
|
269
|
+
request: r
|
|
270
|
+
}) : this.onRemoveError(i, {
|
|
271
|
+
response: r.response,
|
|
272
|
+
status: r.status,
|
|
273
|
+
statusText: r.statusText,
|
|
274
|
+
request: r
|
|
275
|
+
});
|
|
276
|
+
}, r.onerror = () => this.onRemoveError(i, {
|
|
277
|
+
response: r.response,
|
|
278
|
+
status: r.status,
|
|
279
|
+
statusText: r.statusText,
|
|
280
|
+
request: r
|
|
281
|
+
}), r.send(f);
|
|
282
|
+
}
|
|
250
283
|
});
|
|
251
284
|
},
|
|
252
285
|
onUpload() {
|
|
253
|
-
const s = this.fileStateCopy, e =
|
|
286
|
+
const s = this.fileStateCopy, e = u.groupFilesByUid(s), t = u.filesForUpload(e);
|
|
254
287
|
this.uploadFiles(t);
|
|
255
288
|
const i = () => {
|
|
256
289
|
const n = {
|
|
257
290
|
target: this,
|
|
258
291
|
newState: s,
|
|
259
|
-
affectedFiles:
|
|
292
|
+
affectedFiles: u.flatFileGroup(t)
|
|
260
293
|
};
|
|
261
294
|
this.$emit("statuschange", n);
|
|
262
295
|
};
|
|
263
296
|
this.isControlled || (this.currentFiles = s), i();
|
|
264
297
|
},
|
|
265
298
|
onAdd(s) {
|
|
266
|
-
let e =
|
|
267
|
-
if (e =
|
|
268
|
-
const n =
|
|
269
|
-
this.uploadFiles(
|
|
299
|
+
let e = g.getAllFileInfo(s), t;
|
|
300
|
+
if (e = g.assignGuidToFiles(e, this.computedAsync.batch), _.validateFiles(e, this.$props.restrictions, this.validateFile), this.$props.multiple ? t = this.fileStateCopy : t = [], u.addMany(e, t), this.computedAsync.autoUpload) {
|
|
301
|
+
const n = u.groupFilesByUid(t);
|
|
302
|
+
this.uploadFiles(u.filesForUpload(n));
|
|
270
303
|
}
|
|
271
304
|
const i = () => {
|
|
272
305
|
const n = {
|
|
@@ -279,33 +312,33 @@ const Q = /* @__PURE__ */ E({
|
|
|
279
312
|
this.isControlled || (this.currentFiles = t), i();
|
|
280
313
|
},
|
|
281
314
|
onUploadProgress(s, e) {
|
|
282
|
-
const t = e.total ? Math.round(100 * e.loaded / e.total) : 0, i = this.fileStateCopy, n = i.filter((
|
|
315
|
+
const t = e.total ? Math.round(100 * e.loaded / e.total) : 0, i = this.fileStateCopy, n = i.filter((l) => l.uid === s);
|
|
283
316
|
if (!n.length)
|
|
284
317
|
return;
|
|
285
|
-
n.forEach((
|
|
286
|
-
|
|
318
|
+
n.forEach((l) => {
|
|
319
|
+
l.progress = t;
|
|
287
320
|
});
|
|
288
321
|
const o = () => {
|
|
289
|
-
const
|
|
322
|
+
const l = {
|
|
290
323
|
target: this,
|
|
291
324
|
newState: i,
|
|
292
325
|
affectedFiles: n
|
|
293
326
|
};
|
|
294
|
-
this.$emit("progress",
|
|
327
|
+
this.$emit("progress", l);
|
|
295
328
|
};
|
|
296
329
|
this.isControlled || (this.currentFiles = i), o();
|
|
297
330
|
},
|
|
298
331
|
onUploadSuccess(s, e) {
|
|
299
332
|
const t = this.fileStateCopy, i = t.filter((o) => o.uid === s);
|
|
300
333
|
i.forEach((o) => {
|
|
301
|
-
o.status =
|
|
334
|
+
o.status = h.Uploaded, o.progress = 100;
|
|
302
335
|
}), delete this._httpSubscriptions[s];
|
|
303
336
|
const n = () => {
|
|
304
337
|
const o = {
|
|
305
338
|
target: this,
|
|
306
339
|
newState: t,
|
|
307
340
|
affectedFiles: i,
|
|
308
|
-
response: e ? d.
|
|
341
|
+
response: e ? d.convertResponse(e) : void 0
|
|
309
342
|
};
|
|
310
343
|
this.$emit("statuschange", o);
|
|
311
344
|
};
|
|
@@ -314,7 +347,7 @@ const Q = /* @__PURE__ */ E({
|
|
|
314
347
|
onUploadError(s, e) {
|
|
315
348
|
const t = this.fileStateCopy, i = t.filter((o) => o.uid === s);
|
|
316
349
|
if (i.forEach((o) => {
|
|
317
|
-
o.status =
|
|
350
|
+
o.status = h.UploadFailed;
|
|
318
351
|
}), delete this._httpSubscriptions[s], !i.length)
|
|
319
352
|
return;
|
|
320
353
|
const n = () => {
|
|
@@ -322,96 +355,96 @@ const Q = /* @__PURE__ */ E({
|
|
|
322
355
|
target: this,
|
|
323
356
|
newState: t,
|
|
324
357
|
affectedFiles: i,
|
|
325
|
-
response: e ? d.
|
|
358
|
+
response: e ? d.convertResponse(e) : void 0
|
|
326
359
|
};
|
|
327
360
|
this.$emit("statuschange", o);
|
|
328
361
|
};
|
|
329
362
|
this.isControlled || (this.currentFiles = t), n();
|
|
330
363
|
},
|
|
331
364
|
onRemove(s) {
|
|
332
|
-
const e = this.fileStateCopy, t = e.filter((o) => o.uid === s), i = e.filter((o) => o.uid !== s), n = [
|
|
365
|
+
const e = this.fileStateCopy, t = e.filter((o) => o.uid === s), i = e.filter((o) => o.uid !== s), n = [h.Uploaded, h.Initial, h.RemoveFailed];
|
|
333
366
|
if (t[0] && n.indexOf(t[0].status) > -1) {
|
|
334
367
|
const o = {
|
|
335
368
|
[s]: t
|
|
336
369
|
};
|
|
337
|
-
|
|
338
|
-
const
|
|
339
|
-
const
|
|
370
|
+
u.setFilesStatus(o, h.Removing), this.removeFiles(o);
|
|
371
|
+
const l = () => {
|
|
372
|
+
const c = {
|
|
340
373
|
target: this,
|
|
341
374
|
newState: e,
|
|
342
375
|
affectedFiles: t
|
|
343
376
|
};
|
|
344
|
-
this.$emit("statuschange",
|
|
377
|
+
this.$emit("statuschange", c);
|
|
345
378
|
};
|
|
346
|
-
this.isControlled || (this.currentFiles = e),
|
|
379
|
+
this.isControlled || (this.currentFiles = e), l();
|
|
347
380
|
} else {
|
|
348
381
|
const o = () => {
|
|
349
|
-
const
|
|
382
|
+
const l = {
|
|
350
383
|
target: this,
|
|
351
384
|
newState: i,
|
|
352
385
|
affectedFiles: t
|
|
353
386
|
};
|
|
354
|
-
this.$emit("remove",
|
|
387
|
+
this.$emit("remove", l);
|
|
355
388
|
};
|
|
356
389
|
this.isControlled || (this.currentFiles = i), o();
|
|
357
390
|
}
|
|
358
391
|
},
|
|
359
392
|
onRemoveSuccess(s, e) {
|
|
360
|
-
const t = this.fileStateCopy, i = t.filter((
|
|
361
|
-
const
|
|
393
|
+
const t = this.fileStateCopy, i = t.filter((l) => l.uid === s), n = t.filter((l) => l.uid !== s), o = () => {
|
|
394
|
+
const l = {
|
|
362
395
|
target: this,
|
|
363
396
|
newState: n,
|
|
364
397
|
affectedFiles: i,
|
|
365
|
-
response: e ? d.
|
|
398
|
+
response: e ? d.convertResponse(e) : void 0
|
|
366
399
|
};
|
|
367
|
-
this.$emit("remove",
|
|
400
|
+
this.$emit("remove", l);
|
|
368
401
|
};
|
|
369
402
|
this.isControlled || (this.currentFiles = n), o();
|
|
370
403
|
},
|
|
371
404
|
onRemoveError(s, e) {
|
|
372
405
|
const t = this.fileStateCopy, i = t.filter((o) => o.uid === s);
|
|
373
406
|
i.forEach((o) => {
|
|
374
|
-
o.status =
|
|
407
|
+
o.status = h.RemoveFailed;
|
|
375
408
|
});
|
|
376
409
|
const n = () => {
|
|
377
410
|
const o = {
|
|
378
411
|
target: this,
|
|
379
412
|
newState: t,
|
|
380
413
|
affectedFiles: i,
|
|
381
|
-
response: e ? d.
|
|
414
|
+
response: e ? d.convertResponse(e) : void 0
|
|
382
415
|
};
|
|
383
416
|
this.$emit("statuschange", o);
|
|
384
417
|
};
|
|
385
418
|
this.isControlled || (this.currentFiles = t), n();
|
|
386
419
|
},
|
|
387
420
|
onRetry(s) {
|
|
388
|
-
const e = this.fileStateCopy, t =
|
|
389
|
-
|
|
421
|
+
const e = this.fileStateCopy, t = u.groupFilesByUid(e.filter((n) => n.uid === s));
|
|
422
|
+
u.setFilesStatus(t, h.Uploading), this.uploadFiles(t);
|
|
390
423
|
const i = () => {
|
|
391
424
|
const n = {
|
|
392
425
|
target: this,
|
|
393
426
|
newState: e,
|
|
394
|
-
affectedFiles:
|
|
427
|
+
affectedFiles: u.flatFileGroup(t)
|
|
395
428
|
};
|
|
396
429
|
this.$emit("statuschange", n);
|
|
397
430
|
};
|
|
398
431
|
this.isControlled || (this.currentFiles = e), i();
|
|
399
432
|
},
|
|
400
433
|
onCancel(s) {
|
|
401
|
-
const e = this.fileStateCopy, t = e.filter((
|
|
402
|
-
this._httpSubscriptions[s] && (this._httpSubscriptions[s]
|
|
434
|
+
const e = this.fileStateCopy, t = e.filter((l) => l.uid !== s), i = e.filter((l) => l.uid === s);
|
|
435
|
+
this._httpSubscriptions[s] && (this._httpSubscriptions[s](), delete this._httpSubscriptions[s]);
|
|
403
436
|
const n = {
|
|
404
437
|
target: this,
|
|
405
438
|
uid: s
|
|
406
439
|
};
|
|
407
440
|
this.$emit("cancel", n);
|
|
408
441
|
const o = () => {
|
|
409
|
-
const
|
|
442
|
+
const l = {
|
|
410
443
|
target: this,
|
|
411
444
|
newState: t,
|
|
412
445
|
affectedFiles: i
|
|
413
446
|
};
|
|
414
|
-
this.$emit("remove",
|
|
447
|
+
this.$emit("remove", l);
|
|
415
448
|
};
|
|
416
449
|
this.isControlled || (this.currentFiles = e), o();
|
|
417
450
|
},
|
|
@@ -419,7 +452,7 @@ const Q = /* @__PURE__ */ E({
|
|
|
419
452
|
if (!this.computedFiles.length)
|
|
420
453
|
return;
|
|
421
454
|
Object.keys(this._httpSubscriptions).forEach((e) => {
|
|
422
|
-
this._httpSubscriptions[e]
|
|
455
|
+
this._httpSubscriptions[e]();
|
|
423
456
|
}), this._httpSubscriptions = {};
|
|
424
457
|
const s = () => {
|
|
425
458
|
const e = {
|
|
@@ -440,28 +473,28 @@ const Q = /* @__PURE__ */ E({
|
|
|
440
473
|
actionsLayout: i,
|
|
441
474
|
tabIndex: n,
|
|
442
475
|
disabled: o,
|
|
443
|
-
batch:
|
|
444
|
-
withCredentials:
|
|
445
|
-
saveField:
|
|
446
|
-
saveHeaders:
|
|
447
|
-
saveMethod:
|
|
448
|
-
saveUrl:
|
|
449
|
-
responseType:
|
|
450
|
-
removeField:
|
|
476
|
+
batch: l,
|
|
477
|
+
withCredentials: c,
|
|
478
|
+
saveField: p,
|
|
479
|
+
saveHeaders: f,
|
|
480
|
+
saveMethod: a,
|
|
481
|
+
saveUrl: r,
|
|
482
|
+
responseType: m,
|
|
483
|
+
removeField: F,
|
|
451
484
|
removeHeaders: H,
|
|
452
|
-
removeMethod:
|
|
453
|
-
removeUrl:
|
|
454
|
-
multiple:
|
|
455
|
-
accept:
|
|
456
|
-
restrictions:
|
|
457
|
-
files:
|
|
458
|
-
defaultFiles:
|
|
459
|
-
} = this.$props,
|
|
460
|
-
return
|
|
461
|
-
groupedFiles:
|
|
485
|
+
removeMethod: N,
|
|
486
|
+
removeUrl: M,
|
|
487
|
+
multiple: S,
|
|
488
|
+
accept: y,
|
|
489
|
+
restrictions: U,
|
|
490
|
+
files: C,
|
|
491
|
+
defaultFiles: R
|
|
492
|
+
} = this.$props, b = D.call(this, this.$props.list, x.call(this)), v = u.groupFilesByUid(this.computedFiles), E = u.filesForUpload(v);
|
|
493
|
+
return T(O, {
|
|
494
|
+
groupedFiles: v,
|
|
462
495
|
className: this.$props.className,
|
|
463
|
-
showFileList: s && !!Object.keys(
|
|
464
|
-
showActionButtons: t && !e && !!Object.keys(
|
|
496
|
+
showFileList: s && !!Object.keys(v).length,
|
|
497
|
+
showActionButtons: t && !e && !!Object.keys(E).length,
|
|
465
498
|
actionsLayout: i,
|
|
466
499
|
disabled: o,
|
|
467
500
|
onAdd: this.onAdd,
|
|
@@ -470,20 +503,20 @@ const Q = /* @__PURE__ */ E({
|
|
|
470
503
|
onUpload: this.onUpload,
|
|
471
504
|
onRetry: this.onRetry,
|
|
472
505
|
onCancel: this.onCancel,
|
|
473
|
-
tabIndex:
|
|
506
|
+
tabIndex: A(n, o),
|
|
474
507
|
ref: ($) => {
|
|
475
508
|
this.uploadNavigationRef = $;
|
|
476
509
|
},
|
|
477
|
-
multiple:
|
|
478
|
-
accept:
|
|
479
|
-
list:
|
|
480
|
-
restrictions:
|
|
481
|
-
files:
|
|
482
|
-
defaultFiles:
|
|
510
|
+
multiple: S,
|
|
511
|
+
accept: y,
|
|
512
|
+
list: b,
|
|
513
|
+
restrictions: U,
|
|
514
|
+
files: C,
|
|
515
|
+
defaultFiles: R,
|
|
483
516
|
async: this.computedAsync
|
|
484
517
|
}, null);
|
|
485
518
|
}
|
|
486
519
|
});
|
|
487
520
|
export {
|
|
488
|
-
|
|
521
|
+
X as Upload
|
|
489
522
|
};
|
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
13
13
|
*-------------------------------------------------------------------------------------------
|
|
14
14
|
*/
|
|
15
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue"),require("@progress/kendo-vue-common"),require("@progress/kendo-vue-intl"),require("@progress/kendo-vue-progressbars"),require("@progress/kendo-vue-buttons"),require("@progress/kendo-svg-icons"),require("axios")):"function"==typeof define&&define.amd?define(["exports","vue","@progress/kendo-vue-common","@progress/kendo-vue-intl","@progress/kendo-vue-progressbars","@progress/kendo-vue-buttons","@progress/kendo-svg-icons","axios"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoVueUpload={},e.Vue,e.KendoVueCommon,e.KendoVueIntl,e.KendoVueProgressbars,e.KendoVueButtons,e.KendoSVGIcons,e.axios)}(this,function(e,t,n,i,o,s,a,l){"use strict";var r=(e=>(e[e.UploadFailed=0]="UploadFailed",e[e.Initial=1]="Initial",e[e.Selected=2]="Selected",e[e.Uploading=3]="Uploading",e[e.Uploaded=4]="Uploaded",e[e.RemoveFailed=5]="RemoveFailed",e[e.Removing=6]="Removing",e))(r||{});const d="upload.cancel",c="upload.clearSelectedFiles",u="upload.dropFileHere",p="upload.dropFilesHere",h="upload.headerStatusUploaded",m="upload.headerStatusUploading",f="upload.invalidFileExtension",g="upload.invalidFiles",v="upload.invalidMaxFileSize",y="upload.invalidMinFileSize",b="upload.remove",F="upload.retry",S="upload.select",k="upload.selectSingle",I="upload.selectTitle",x="upload.selectNoFilesTitle",C="upload.uploadSelectedFiles",N="upload.total",B="upload.files",D="upload.statusUploaded",E="upload.statusUploadFailed",$="upload.dropZoneHint",U="upload.dropZoneNote",R={[d]:"Cancel",[c]:"Clear",[u]:"Drop a file here to upload",[p]:"Drop files here to upload",[h]:"Done",[m]:"Uploading...",[f]:"File type not allowed.",[g]:"Invalid file(s). Please check file upload requirements.",[v]:"File size too large.",[y]:"File size too small.",[b]:"Remove",[F]:"Retry",[S]:"Select files...",[k]:"Select file...",[I]:"Press to select more files",[x]:"No files selected",[C]:"Upload",[N]:"Total",[B]:"files",[D]:"File(s) successfully uploaded.",[E]:"File(s) failed to upload.",[$]:"Drag and drop files here to upload.",[U]:"Only JPEG and PNG files are allowed."},L=/&/g,V=/</g,w=/"/g,O=/'/g,A=/>/g,z=e=>(""+e).replace(L,"&").replace(V,"<").replace(A,">").replace(w,""").replace(O,"'"),j=e=>{const t=e.match(/\.([^\.]+)$/);return t?t[0]:""},_=e=>{const t=e.name,n=e.size;return{extension:j(t),name:z(t),getRawFile:()=>e,size:n,status:r.Selected,progress:0,uid:""}},T=e=>!!(e.validationErrors&&e.validationErrors.length>0),K={fileHasValidationErrors:T,filesHaveValidationErrors:e=>{for(const t of e)if(T(t))return!0;return!1},getTotalFilesSizeMessage:e=>{let t,n=0;if("number"!=typeof e[0].size)return"";for(t=0;t<e.length;t++)e[t].size&&(n+=e[t].size||0);return n/=1024,n<1024?n.toFixed(2)+" KB":(n/1024).toFixed(2)+" MB"},getAllFileInfo:e=>{const t=new Array;let n;for(n=0;n<e.length;n++)t.push(_(e[n]));return t},getFileInfo:_,getFileExtension:j,htmlEncode:z,assignGuidToFiles:(e,t)=>{const i=n.guid();return e.map(e=>(e.uid=t?i:n.guid(),e))},getFileStatus:e=>{let t=!1,n=!1,i=!1,o=!1;const s=e=>{e.forEach(e=>{e.status===r.Uploading&&(t=!0),e.status===r.Uploaded&&(n=!0),e.status===r.UploadFailed&&(i=!0),T(e)&&(o=!0)})};return Array.isArray(e)?s(e):Object.keys(e).forEach(t=>{s(e[t])}),[t,n,i,o]}},M=t.defineComponent({name:"KendoVueUploadListActionButton",props:{progress:Number,uid:String,status:Number,async:Object,disabled:Boolean,files:Array},emits:{cancel:null,retry:null,remove:null},inject:{kendoLocalizationService:{default:null}},data:()=>({retryFocused:!1,actionFocused:!1}),methods:{actionButtonTitle:(e,t)=>e===r.Uploading?t.toLanguageString(d,R[d]):t.toLanguageString(b,R[b]),retryButtonTitle:e=>e.toLanguageString(F,R[F]),buttonClassNames(e){return n.classNames(this.actionFocused&&"action"===e||this.retryFocused&&"retry"===e?"k-focus":"")},onRetryFocus(){this.retryFocused=!0},onRetryBlur(){this.retryFocused=!1},onActionFocus(){this.actionFocused=!0},onActionBlur(){this.actionFocused=!1},onActionClick(){const{status:e,uid:t,disabled:n}=this.$props;n||e===r.Removing||(e===r.Uploading?this.$emit("cancel",t):this.$emit("remove",t))},onRetryClick(){const{uid:e,disabled:t}=this.$props;t||this.$emit("retry",e)}},setup:()=>({kendoLocalizationService:t.inject("kendoLocalizationService",{})}),render(){const{status:e,progress:n}=this.$props,o=e===r.UploadFailed,l=e===r.Uploading,d=(e===r.Uploaded||e===r.Initial)&&!this.$props.async.removeUrl,c=i.provideLocalizationService(this);return t.createVNode("div",{class:"k-upload-actions"},[l?t.createVNode("span",{class:"k-upload-pct"},[n,"%"]):void 0,o?t.createVNode(s.Button,{type:"button",fillMode:"flat",tabIndex:-1,disabled:this.disabled,class:this.buttonClassNames("retry"),icon:"arrow-rotate-cw-small",svgIcon:a.arrowRotateCwSmallIcon,iconClass:"k-retry",ariaLabel:this.retryButtonTitle(c),title:this.retryButtonTitle(c),onFocus:this.onRetryFocus,onBlur:this.onRetryBlur,onClick:this.onRetryClick},null):void 0,d?void 0:t.createVNode(s.Button,{type:"button",fillMode:"flat",tabIndex:-1,disabled:this.disabled,class:this.buttonClassNames("action"),onFocus:this.onActionFocus,onBlur:this.onActionBlur,onClick:this.onActionClick,icon:e===r.Uploading?"cancel":"x",svgIcon:l?a.cancelIcon:a.xIcon,ariaLabel:this.actionButtonTitle(e,c),title:this.actionButtonTitle(e,c)},null)])}}),Z=t.defineComponent({name:"KendoVueUploadListSingleItem",props:{files:Array,disabled:Boolean,async:Object},emits:{cancel:null,retry:null,remove:null},inject:{kendoLocalizationService:{default:null}},methods:{onRetry(e){this.$emit("retry",e)},onRemove(e){this.$emit("remove",e)},onCancel(e){this.$emit("cancel",e)},getFileExtension:e=>e.extension?e.extension.substring(1):"",getFileValidationMessage(e,t){const n=i.provideLocalizationService(this);let o="";if(t)o=n.toLanguageString(E,R[E]);else if(e.validationErrors&&e.validationErrors.length>0){const t=`upload.${e.validationErrors[0]}`;o=n.toLanguageString(t,R[t])}return o},getFileExtensionName(e){switch(e.extension){case".png":case".jpg":case".jpeg":case".tiff":case".bmp":case".gif":return"file-image";case".mp3":case".mp4":case".wav":return"file-audio";case".mkv":case".webm":case".flv":case".gifv":case".avi":case".wmv":return"file-video";case".txt":return"file-txt";case".pdf":return"file-pdf";case".ppt":case".pptx":return"file-presentation";case".csv":case".xls":case".xlsx":return"file-data";case".html":case".css":case".js":case".ts":return"file-programming";case".exe":return"file-config";case".zip":case".rar":return"file-zip";default:return"file"}},getFileExtensionSVG(e){switch(e.extension){case".png":case".jpg":case".jpeg":case".tiff":case".bmp":case".gif":return a.fileImageIcon;case".mp3":case".mp4":case".wav":return a.fileAudioIcon;case".mkv":case".webm":case".flv":case".gifv":case".avi":case".wmv":return a.fileVideoIcon;case".txt":return a.fileTxtIcon;case".pdf":return a.filePdfIcon;case".ppt":case".pptx":return a.filePresentationIcon;case".csv":case".xls":case".xlsx":return a.fileDataIcon;case".html":case".css":case".js":case".ts":return a.fileProgrammingIcon;case".exe":return a.fileConfigIcon;case".zip":case".rar":return a.fileZipIcon;default:return a.fileIcon}}},setup:()=>({kendoLocalizationService:t.inject("kendoLocalizationService",{})}),render(){const{files:e,disabled:s,async:a}=this.$props,l=e[0],r=n.classNames("k-file-single"),[,d,c,u]=K.getFileStatus([l]),p=!u&&!d&&!c;return t.createVNode("div",{class:r},[p&&t.createVNode(o.ProgressBar,{value:l.progress||0,labelVisible:!1},null),t.createVNode("span",{class:"k-file-icon-wrapper",key:"1"},[t.createVNode(n.Icon,{name:this.getFileExtensionName(l),icon:this.getFileExtensionSVG(l),size:"xxxlarge",class:"k-file-icon"},null),t.createVNode("span",{class:"k-file-state"},null)]),u||c?function(e,n){return t.createVNode("span",{class:"k-file-info",key:"2"},[t.createVNode("span",{class:"k-file-name",title:e.name},[e.name]),t.createVNode("span",{class:"k-file-validation-message"},[this.getFileValidationMessage(e,n)])])}.call(this,l,c):function(e){const n=i.provideLocalizationService(this).toLanguageString(D,R[D]);return t.createVNode("span",{class:"k-file-info",key:"2"},[t.createVNode("span",{class:"k-file-name",title:e.name},[e.name]),100!==e.progress?t.createVNode("span",{class:"k-file-size"},[K.getTotalFilesSizeMessage([e])]):t.createVNode("span",{class:"k-file-validation-message"},[n])])}.call(this,l),t.createVNode(M,{uid:l.uid,status:l.status,progress:l.progress,files:e,disabled:s,async:a,onCancel:this.onCancel,onRemove:this.onRemove,onRetry:this.onRetry},null)])}}),H=t.defineComponent({name:"KendoVueUploadListMultiItem",props:{files:Array,disabled:Boolean,async:Object},emits:{cancel:null,retry:null,remove:null},inject:{kendoLocalizationService:{default:null}},methods:{onRetry(e){this.$emit("retry",e)},onRemove(e){this.$emit("remove",e)},onCancel(e){this.$emit("cancel",e)},getFileValidationMessage(e){const t=i.provideLocalizationService(this);let n="";if(e.validationErrors&&e.validationErrors.length>0){const i=`upload.${e.validationErrors[0]}`;n=t.toLanguageString(i,R[i])}return n},progress(){const{files:e}=this.$props;let t=0;return e.forEach(e=>{t+=e.progress||0}),t/e.length}},setup:()=>({kendoLocalizationService:t.inject("kendoLocalizationService",{})}),render(){const{files:e,disabled:s,async:l}=this.$props,r=n.classNames("k-file-multiple"),[,d,c,u]=K.getFileStatus(e),p=i.provideLocalizationService(this),h=p.toLanguageString(N,R[N]),m=p.toLanguageString(B,R[B]),f=p.toLanguageString(E,R[E]),g=p.toLanguageString(D,R[D]),v=this.progress(),y=!u&&!d&&!c;return t.createVNode("div",{class:r},[y&&t.createVNode(o.ProgressBar,{value:v||0,labelVisible:!1},null),t.createVNode("span",{class:"k-file-icon-wrapper"},[t.createVNode(n.Icon,{name:"copy",icon:a.copyIcon,size:"xxxlarge",class:"k-file-icon"},null)]),t.createVNode("span",{class:"k-multiple-files-wrapper"},[function(){return e.map(function(e){return t.createVNode("span",{key:e.name,class:"k-file-info"},[t.createVNode("span",{class:"k-file-name",title:e.name},[e.name]),K.fileHasValidationErrors(e)?t.createVNode("span",{class:"k-file-validation-message"},[this.getFileValidationMessage(e)]):t.createVNode("span",{key:`${e.name}-size`,class:"k-file-size"},[K.getTotalFilesSizeMessage([e])])])},this)}.call(this),c?t.createVNode("span",{class:"k-file-validation-message"},[`${e.length} ${f}`]):100!==v?t.createVNode("span",{class:"k-file-summary"},[`${h}: ${e.length} ${m}, ${K.getTotalFilesSizeMessage(e)}`]):t.createVNode("span",{class:"k-file-summary k-text-success"},[`${e.length} ${g}`])]),t.createVNode(M,{uid:e[0].uid,status:e[0].status,progress:v,files:e,disabled:s,async:l,onCancel:this.onCancel,onRemove:this.onRemove,onRetry:this.onRetry},null)])}}),P=t.defineComponent({name:"KendoVueUploadListGroup",props:{files:Array,async:Object,disabled:Boolean,navigationIndex:Number,list:[String,Function,Object],index:Number},emits:{cancel:null,click:null,retry:null,remove:null},mounted(){this._element=this.elementRef},updated(){const{navigationIndex:e,index:t}=this.$props;e===t&&this._element&&n.canUseDOM&&document.activeElement!==this._element&&this._element.focus()},methods:{onClick(){this.$emit("click",this.$props.index)},onRetry(e){this.$emit("retry",e)},onRemove(e){this.$emit("remove",e)},onCancel(e){this.$emit("cancel",e)}},setup:()=>({elementRef:t.ref(null)}),render(){const{files:e,async:i,disabled:o,navigationIndex:s,index:a}=this.$props,l=e[0],d=l.status===r.Uploaded||l.status===r.Initial,c=K.filesHaveValidationErrors(e),u=l.status===r.UploadFailed||l.status===r.RemoveFailed,p=n.classNames("k-file",{"k-file-invalid":c,"k-file-error":u||c,"k-file-progress":l.status===r.Uploading,"k-file-success":d,"k-focus":s===a});let h;const m=1===e.length?t.createVNode(Z,{files:e,async:i,disabled:o,onCancel:this.onCancel,onRemove:this.onRemove,onRetry:this.onRetry},null):t.createVNode(H,{files:e,async:i,disabled:o,onCancel:this.onCancel,onRemove:this.onRemove,onRetry:this.onRetry},null);return h=n.getTemplate.call(this,{h:t.h,template:this.$props.list,defaultRendering:m,additionalProps:this.$props,additionalListeners:{retry:this.onRetry,remove:this.onRemove,cancel:this.onCancel}}),t.createVNode("li",{ref:n.setRef(this,"element"),class:p,"data-uid":l.uid,tabindex:-1,onClick:this.onClick},[h])}}),G=t.defineComponent({name:"KendoVueUploadList",props:{groupedFiles:Object,async:Object,disabled:Boolean,navigationIndex:{type:Number,default:void 0},list:[String,Function,Object]},emits:{cancel:null,click:null,retry:null,remove:null},methods:{onClick(e){this.$emit("click",e)},onRetry(e){this.$emit("retry",e)},onRemove(e){this.$emit("remove",e)},onCancel(e){this.$emit("cancel",e)}},render(){const{groupedFiles:e,navigationIndex:i,async:o,disabled:s,list:a}=this.$props,l=n.classNames("k-upload-files","k-reset");return t.createVNode("ul",{class:l},[Object.keys(e).map(function(n,l){const r=e[n];return t.createVNode(P,{key:n,files:r,index:l,navigationIndex:i,async:o,disabled:s,list:a,onCancel:this.onCancel,onClick:this.onClick,onRemove:this.onRemove,onRetry:this.onRetry},null)},this)])}});function q(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!t.isVNode(e)}const J=t.defineComponent({name:"KendoVueUploadActionButtons",props:{disabled:Boolean,navigationIndex:Number,clearButtonIndex:Number,uploadButtonIndex:Number,actionsLayout:String},inject:{kendoLocalizationService:{default:null}},emits:{clear:null,click:null,upload:null},created(){this._prevNavigationIndex=void 0},setup:()=>({uploadElementRef:t.ref(null),clearElementRef:t.ref(null),kendoLocalizationService:t.inject("kendoLocalizationService",{})}),mounted(){this._clearElement=this.clearElementRef,this._uploadElement=this.uploadElementRef},watch:{navigationIndex:function(e,t){this._prevNavigationIndex=t}},updated(){const{navigationIndex:e,clearButtonIndex:t,uploadButtonIndex:n}=this.$props;e!==this._prevNavigationIndex&&(e===t&&this._clearElement&&this._clearElement.focus(),e===n&&this._uploadElement&&this._uploadElement.focus())},methods:{onClearClick(){this.$props.disabled||this.$emit("clear")},onUploadClick(){this.$props.disabled||(this.$emit("click",this.$props.uploadButtonIndex),this.$emit("upload"))}},render(){let e,o;const{disabled:a,navigationIndex:l,clearButtonIndex:r,uploadButtonIndex:d,actionsLayout:u}=this.$props,p=i.provideLocalizationService(this),h=n.classNames("k-actions",{"k-actions-start":"start"===u,"k-actions-center":"center"===u,"k-actions-end":"end"===u,"k-actions-stretched":"stretched"===u}),m=n.classNames("k-clear-selected",l===r?"k-focus":""),f=n.classNames("k-upload-selected",l===d?"k-focus":"");return t.createVNode("div",{class:h},[t.createVNode(s.Button,{type:"button",ref:e=>{this.clearElementRef=e},disabled:a,class:m,tabIndex:-1,onClick:this.onClearClick},q(e=p.toLanguageString(c,R[c]))?e:{default:()=>[e]}),t.createVNode(s.Button,{type:"button",ref:e=>{this.uploadElementRef=e},disabled:a,themeColor:"primary",class:f,tabIndex:-1,onClick:this.onUploadClick},q(o=p.toLanguageString(C,R[C]))?o:{default:()=>[o]})])}}),Q=/(chrome)[ \/]([\w.]+)/i,W=/(webkit)[ \/]([\w.]+)/i,X=t.defineComponent({name:"KendoVueUploadInput",props:{async:Object,id:String,multiple:{type:Boolean,default:void 0},disabled:{type:Boolean,default:void 0},accept:{type:String,default:void 0},hasFiles:{type:Boolean,default:!1},ariaLabelledBy:{type:String,default:void 0},ariaDescribedBy:{type:String,default:void 0}},emits:{mousedown:null,add:null},inject:{kendoLocalizationService:{default:null}},mounted(){this._input=this.inputRef},methods:{onMouseDown(e){this.$emit("mousedown",e)},onAdd(){const e=navigator.userAgent,t=this._input;t&&(t.files&&this.$emit("add",t.files),!e.match(Q)&&e.match(W)||(t.type="",t.type="file"))},actionElement(){return this._input}},setup:()=>({inputRef:t.ref(null)}),render(){const{multiple:e,async:o,disabled:s,accept:a,hasFiles:l,ariaLabelledBy:r,ariaDescribedBy:d}=this.$props,c=i.provideLocalizationService(this),u=l?I:x,p=c.toLanguageString(u,R[u]),h=c.toLanguageString(S,R[S]);return t.createVNode("input",{ref:n.setRef(this,"input"),id:this.id,class:"k-hidden",autocomplete:"off",name:o.saveField,accept:a,type:"file",tabindex:-1,multiple:e,disabled:s,onChange:this.onAdd,onMousedown:this.onMouseDown,title:p,"aria-label":void 0!==r?void 0:h,"aria-labelledby":r,"aria-describedby":d},null)}});function Y(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!t.isVNode(e)}const ee=t.defineComponent({name:"KendoVueUploadAddButton",props:{addButtonIndex:Number,navigationIndex:Number,notFocusedIndex:Number,tabIndex:Number,async:Object,multiple:Boolean,disabled:Boolean,accept:String,id:String,ariaLabelledBy:String,ariaDescribedBy:String},inject:{kendoLocalizationService:{default:null}},emits:{add:null,click:null},setup:()=>({elementRef:t.ref(null),uploadInputRef:t.ref(null),kendoLocalizationService:t.inject("kendoLocalizationService",{})}),created(){this.uploadInputId=n.guid()},mounted(){this.element=this.elementRef,this.uploadInput=this.uploadInputRef},watch:{navigationIndex:function(e,t){this._prevNavigationIndex=t}},updated(){const{navigationIndex:e,addButtonIndex:t,notFocusedIndex:n}=this.$props;e!==this._prevNavigationIndex&&this._prevNavigationIndex!==n&&e===t&&this.element&&this.element.focus()},methods:{focus(){this.element&&this.element.focus()},onClick(){this.actionElement()&&this.actionElement().click(),this.$emit("click",this.$props.addButtonIndex)},onAdd(e){this.$emit("add",e)},onInputMouseDown(e){this.element&&(e.preventDefault(),this.element.focus())},actionElement(){if(this.uploadInput)return this.uploadInput.actionElement()}},render(){const{navigationIndex:e,addButtonIndex:o,tabIndex:a,id:l,async:r,multiple:d,disabled:c,accept:u,ariaLabelledBy:p,ariaDescribedBy:h}=this.$props,m=i.provideLocalizationService(this),f=d?m.toLanguageString(S,R[S]):m.toLanguageString(k,R[k]),g=n.classNames("k-upload-button",e===o?"k-focus":"");return t.createVNode("div",{class:"k-upload-button-wrap"},[t.createVNode(s.Button,{id:l,ref:n.setRef(this,"element"),role:"button",type:"button",disabled:c,ariaLabel:f,class:g,tabIndex:a,"aria-labelledby":p,"aria-describedby":h,onClick:this.onClick},Y(f)?f:{default:()=>[f]}),t.createVNode(X,{id:this.uploadInputId,async:r,multiple:d,disabled:c,accept:u,onMousedown:this.onInputMouseDown,onAdd:this.onAdd,ref:e=>{this.uploadInputRef=e}},null)])}}),te=t.defineComponent({props:{isUploading:Boolean,isUploaded:Boolean,isUploadFailed:Boolean},inject:{kendoLocalizationService:{default:null}},setup:()=>({kendoLocalizationService:t.inject("kendoLocalizationService",{})}),render(){const{isUploading:e,isUploaded:o,isUploadFailed:s}=this.$props;let l="";const r=i.provideLocalizationService(this);return e?l=r.toLanguageString(m,R[m]):(o||s)&&(l=r.toLanguageString(h,R[h])),t.createVNode("div",{class:n.classNames("k-upload-status")},[t.createVNode(n.Icon,{name:e||s||!o?!e&&s?"exclamation-circle":e?"upload":"":"check",icon:e||s||!o?!e&&s?a.exclamationCircleIcon:e?a.uploadIcon:{}:a.checkIcon},null),l])}}),ne=t.defineComponent({name:"KendoVueUploadDropZone",props:{addButtonIndex:Number,async:Object,multiple:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},showFileList:Boolean,showActionButtons:Boolean,actionsLayout:{type:String,default:function(){return"end"}},tabIndex:Number,accept:String,groupedFiles:{type:Object,default:function(){return{}}},navigationIndex:Number,notFocusedIndex:Number,list:[String,Function,Object],id:String,ariaLabelledBy:String,ariaDescribedBy:String,fileGroup:Object},emits:{add:null,click:null},inject:{kendoLocalizationService:{default:null}},data:()=>({currentDocumentActive:!1,currentElementActive:!1}),created(){this.currentElementActive=!1},mounted(){this.uploadAddButton=this.uploadAddButtonRef,document.addEventListener("dragenter",this.onDocumentDragEnter),document.addEventListener("dragover",this.onDocumentDragOver)},unmounted(){document.removeEventListener("dragenter",this.onDocumentDragEnter),document.removeEventListener("dragover",this.onDocumentDragOver)},setup:()=>({uploadAddButtonRef:t.ref(null),kendoLocalizationService:t.inject("kendoLocalizationService",{})}),computed:{dropZoneClasses(){return{"k-dropzone":!0,"k-upload-dropzone":!0,"k-active":this.currentDocumentActive,"k-hover":this.currentElementActive}}},methods:{actionElement(){if(this.uploadAddButton)return this.uploadAddButton.uploadInput},focus(){if(this.uploadAddButton)return this.uploadAddButton.focus()},onDocumentDragEnter(){if(!this.currentDocumentActive){this.currentDocumentActive=!0;const e=()=>{this.isDragOver(this._lastDocumentDragOver)&&(this.currentDocumentActive=!1,clearInterval(this._documentInterval),this._documentInterval=null,this._lastDocumentDragOver=null)};this._documentInterval=setInterval(e,100)}},onDocumentDragOver(){this._lastDocumentDragOver=new Date},onElementDragEnter(){if(!this.currentElementActive){this.currentElementActive=!0;const e=()=>{this.isDragOver(this._lastElementDragOver)&&(this.currentElementActive=!1,clearInterval(this._elementInterval),this._elementInterval=null,this._lastElementDragOver=null)};this._elementInterval=setInterval(e,100)}},onElementDragOver(e){e.preventDefault(),this._lastElementDragOver=new Date},onDrop(e){e.preventDefault();let t=e.dataTransfer.files;t.length>0&&!this.$props.disabled&&this.$emit("add",t)},isDragOver:e=>(new Date).getTime()-(e||new Date).getTime()>100,onClick(e){this.$emit("click",e)},onAdd(e){this.$emit("add",e)}},render(){const{multiple:e,disabled:o,tabIndex:s,fileGroup:a,accept:l,navigationIndex:r,notFocusedIndex:d,id:c,ariaLabelledBy:h,ariaDescribedBy:m}=this.$props,f=i.provideLocalizationService(this),g=e?f.toLanguageString(p,R[p]):f.toLanguageString(u,R[u]),[v,y,b,F]=K.getFileStatus(a),S=n.classNames("k-dropzone-hint",{});return t.createVNode("div",{class:this.dropZoneClasses,onDrop:this.onDrop,onDragenter:this.onElementDragEnter,onDragover:this.onElementDragOver},[function(){return t.createVNode(ee,{id:c,ariaLabelledBy:h,ariaDescribedBy:m,ref:e=>{this.uploadAddButtonRef=e},accept:l,async:this.async,addButtonIndex:this.addButtonIndex,navigationIndex:r,notFocusedIndex:d,tabIndex:s,multiple:e,disabled:o,onClick:this.onClick,onAdd:this.onAdd},null)}.call(this),v||y||b||F?t.createVNode(te,{isUploading:v,isUploaded:y,isUploadFailed:b},null):t.createVNode("div",{class:S},[g])])}}),ie=t.defineComponent({name:"KendoVueUploadUI",props:{async:Object,className:String,multiple:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},showFileList:Boolean,showActionButtons:Boolean,actionsLayout:{type:String,default:function(){return"end"}},tabIndex:Number,accept:String,groupedFiles:{type:Object,default:function(){return{}}},navigationIndex:Number,notFocusedIndex:Number,list:[String,Function,Object],id:String,ariaLabelledBy:String,ariaDescribedBy:String},computed:{groupsCount(){return Object.keys(this.$props.groupedFiles).length},lastGroupIndex(){return this.groupsCount-1},addButtonIndex:()=>-1,clearButtonIndex(){return this.lastGroupIndex+1},uploadButtonIndex(){return this.lastGroupIndex+2},isRtl(){return this._container&&"rtl"===getComputedStyle(this._container).direction||!1}},methods:{actionElement(){if(this.uploadDropZone)return this.uploadDropZone.actionElement()},focus(){if(this.uploadDropZone)return this.uploadDropZone.focus()},onAdd(e){this.$emit("add",e)},onRetry(e){this.$emit("retry",e)},onCancel(e){this.$emit("cancel",e)},onClear(){this.$emit("clear")},onUpload(){this.$emit("upload")},onRemove(e){this.$emit("remove",e)},onKeyDown(e){this.$emit("keydown",e,this.isRtl)},onFocus(e){this.$emit("focus",e)},onBlur(e){this.$emit("blur",e)},onClick(e){this.$emit("click",e)}},emits:{add:null,retry:null,cancel:null,clear:null,upload:null,remove:null,keydown:null,click:null,focus:null,blur:null},mounted(){this._container=this.containerRef,this.uploadDropZone=this.uploadDropZoneRef},setup:()=>({containerRef:t.ref(null),uploadDropZoneRef:t.ref(null)}),render(){const{multiple:e,disabled:i,tabIndex:o,accept:s,showFileList:a,groupedFiles:l,navigationIndex:r,showActionButtons:d,actionsLayout:c,notFocusedIndex:u,list:p,id:h,ariaLabelledBy:m,ariaDescribedBy:f,async:g}=this.$props,v=n.classNames("k-upload","k-upload-async",this.$props.className,i?"k-disabled":"");return t.createVNode("div",{ref:n.setRef(this,"container"),class:v,onKeydown:this.onKeyDown,onFocus:this.onFocus,onBlur:this.onBlur},[t.createVNode(ne,{id:h,ariaLabelledBy:m,ariaDescribedBy:f,ref:e=>{this.uploadDropZoneRef=e},accept:s,async:g,addButtonIndex:this.addButtonIndex,navigationIndex:r,notFocusedIndex:u,tabIndex:o,multiple:e,onClick:this.onClick,onAdd:this.onAdd,fileGroup:l,disabled:i},null),a?t.createVNode(G,{groupedFiles:l,disabled:i,async:g,navigationIndex:r,list:p,onCancel:this.onCancel,onRemove:this.onRemove,onRetry:this.onRetry,onClick:this.onClick},null):void 0,d?t.createVNode(J,{disabled:i,navigationIndex:r,clearButtonIndex:this.clearButtonIndex,uploadButtonIndex:this.uploadButtonIndex,actionsLayout:c,onUpload:this.onUpload,onClear:this.onClear,onClick:this.onClick},null):void 0])}}),oe=-2,se=-1,ae=t.defineComponent({name:"KendoVueUploadNavigation",props:{async:Object,className:String,multiple:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},showFileList:Boolean,showActionButtons:Boolean,actionsLayout:{type:String,default:function(){return"end"}},tabIndex:Number,accept:String,groupedFiles:{type:Object,default:function(){return{}}},notFocusedIndex:Number,list:[String,Function,Object],id:String,ariaLabelledBy:String,ariaDescribedBy:String,restrictions:Object,files:Array,defaultFiles:Array},emits:{add:null,cancel:null,clear:null,upload:null,retry:null,remove:null},data:()=>({currentNavIndex:oe}),updated(){},methods:{actionElement(){if(this._uploadUI)return this._uploadUI.actionElement()},navIndex(e){if(void 0===e)return this.currentNavIndex;const t=this.navIndex;this.currentNavIndex=e,e!==t&&this.$forceUpdate()},focus(){this._uploadUI&&this._uploadUI.focus()},onKeyDown(e,t){var i;const o=this.navIndex(),s=Object.keys(this.$props.groupedFiles),a=s.length-1,l=this.$props.autoUpload||0===s.length?a:a+1,r=a+1,d=r+1,c=o===oe?se:o;let u=o;switch(e.keyCode){case n.Keys.up:e.preventDefault(),o>-1&&(u=c-1);break;case n.Keys.down:e.preventDefault(),o<l&&(u=c+1);break;case n.Keys.left:e.preventDefault(),t?o===r&&(u=c+1):o===d&&(u=c-1);break;case n.Keys.right:e.preventDefault(),t?o===d&&(u=c-1):o===r&&(u=c+1);break;case n.Keys.enter:(o===se||o===oe)&&this.actionElement()&&n.canUseDOM&&-1===(null==(i=document.activeElement)?void 0:i.className.indexOf("k-upload-button"))&&this.actionElement().$el.click(),o>=0&&o<=a&&this.onRetry(s[o]);break;case n.Keys.space:e.preventDefault(),(o===se||o===oe)&&this.actionElement()&&this.actionElement().$el.click();break;case n.Keys.tab:u=oe;break;case n.Keys.delete:o>=0&&o<=a&&(u=c-1,this.onRemove(s[o]));break;case n.Keys.esc:o>=0&&o<=a&&(u=c-1,this.onCancel(s[o]))}this.navIndex(u)},onCancel(e){this.$emit("cancel",e)},onClear(){this.navIndex(se),this.$emit("clear")},onUpload(){this.navIndex(se),this.$emit("upload")},onRetry(e){this.$emit("retry",e)},onRemove(e){this.navIndex(this.navIndex()>se?this.navIndex()-1:se),this.$emit("remove",e)},onAdd(e){this.navIndex(se),this.$emit("add",e)},onClick(e){this.navIndex(e)},onFocus(){this._blurTimeout&&(clearTimeout(this._blurTimeout),this._blurTimeout=void 0)},onBlurTimeout(){this.navIndex(oe),this._blurTimeout=void 0},onBlur(){clearTimeout(this._blurTimeout),this._blurTimeout=window.setTimeout(this.onBlurTimeout)}},mounted(){this._uploadUI=this.uploadUIRef},setup:()=>({uploadUIRef:t.ref(null)}),render(){const{multiple:e,disabled:n,showFileList:i,showActionButtons:o,actionsLayout:s,tabIndex:a,accept:l,groupedFiles:r,list:d,id:c,ariaLabelledBy:u,ariaDescribedBy:p,async:h}=this.$props;return t.createVNode(ie,{ref:e=>{this.uploadUIRef=e},class:this.$props.className,onKeydown:this.onKeyDown,navigationIndex:this.currentNavIndex,notFocusedIndex:oe,onAdd:this.onAdd,onClear:this.onClear,onUpload:this.onUpload,onRemove:this.onRemove,onRetry:this.onRetry,onCancel:this.onCancel,onClick:this.onClick,onFocus:this.onFocus,onBlur:this.onBlur,multiple:e,disabled:n,showFileList:i,showActionButtons:o,actionsLayout:s,tabIndex:a,accept:l,groupedFiles:r,list:d,id:c,ariaLabelledBy:u,ariaDescribedBy:p,async:h},null)}}),le=(e,t)=>{t.push(e)},re=(e,t)=>{Object.keys(e).forEach(n=>{t(e[n],n)})},de={copyState:e=>(e||[]).map(e=>({...e})),addMany:(e,t)=>{e.forEach(e=>le(e,t))},add:le,groupFilesByUid:e=>{const t={};return e.forEach(e=>{t[e.uid]?t[e.uid].push(e):t[e.uid]=[e]}),t},filesForUpload:e=>{const t={};return re(e,(e,n)=>{let i=!0;e.forEach(e=>{(e.status!==r.Selected||e.validationErrors&&e.validationErrors.length>0)&&(i=!1)}),i&&(t[n]=e)}),t},setFilesStatus:(e,t)=>{re(e,e=>{e.forEach(e=>{e.status=t})})},flatFileGroup:e=>{const t=[];return re(e,e=>{t.push.apply(t,e)}),t},groupForEach:re},ce=(e,t)=>{Object.keys(t).forEach(n=>{e.append(n,t[n])})},ue=(e,t,n)=>{const i=new FormData;return ce(i,n),e.forEach(e=>{const n=e.getRawFile?e.getRawFile():"";n?i.append(t,n,e.name):i.append(t,n)}),i},pe=(e,t,n)=>{const i=new FormData;return ce(i,n),e.forEach(e=>{i.append(t,e)}),i},he=(e,t)=>({headers:e,responseType:t.responseType,withCredentials:t.withCredentials}),me=e=>{const t={};return Object.keys(e).forEach(n=>{t[n]=e[n]}),t},fe=e=>{const{data:t,config:n,...i}=e;return{response:t,...i}},ge="invalidMaxFileSize",ve="invalidMinFileSize",ye="invalidFileExtension",be=(e,t)=>{t.length>0&&t.indexOf((e.extension||"").toLowerCase())<0&&(e.validationErrors=e.validationErrors||[],e.validationErrors.indexOf(ye)<0&&e.validationErrors.push(ye))},Fe=(e,t,n)=>{0!==t&&(e.size||0)<t&&(e.validationErrors=e.validationErrors||[],e.validationErrors.indexOf(ve)<0&&e.validationErrors.push(ve)),0!==n&&(e.size||0)>n&&(e.validationErrors=e.validationErrors||[],e.validationErrors.indexOf(ge)<0&&e.validationErrors.push(ge))},Se=(e,t,n)=>{const i=(e=>e.map(e=>("."===e.substring(0,1)?e:"."+e).toLowerCase()))(t.allowedExtensions||[]),o=t.maxFileSize||0,s=t.minFileSize||0;let a;for(a=0;a<e.length;a++)be(e[a],i),Fe(e[a],s,o),n&&n(e[a])},ke={name:"@progress/kendo-vue-upload",productName:"Kendo UI for Vue",productCode:"KENDOUIVUE",productCodes:["KENDOUIVUE"],publishDate:1619764257,version:"8.3.0",licensingDocsUrl:"https://www.telerik.com/kendo-vue-ui/my-license/?utm_medium=product&utm_source=kendovue&utm_campaign=kendo-ui-vue-purchase-license-keys-warning"},Ie=t.defineComponent({name:"KendoVueUpload",props:{autoUpload:{type:Boolean,default:!0},batch:{type:Boolean,default:!1},withCredentials:{type:Boolean,default:!0},saveField:{type:String,default:function(){return"files"}},saveHeaders:{type:[String,Function,Object],default:function(){return{}}},saveMethod:{type:String,default:function(){return"POST"}},saveUrl:{type:[String,Function],default:function(){return""}},responseType:{type:String,default:function(){return"json"}},removeField:{type:String,default:function(){return"fileNames"}},removeHeaders:{type:[String,Function,Object],default:function(){return{}}},removeMethod:{type:String,default:function(){return"POST"}},removeUrl:{type:[String,Function],default:function(){return""}},multiple:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},showFileList:{type:Boolean,default:!0},showActionButtons:{type:Boolean,default:!0},actionsLayout:{type:String,default:function(){return"end"}},tabIndex:Number,accept:String,list:[String,Function,Object],restrictions:{type:Object,default:function(){return{allowedExtensions:[],maxFileSize:0,minFileSize:0}}},validateFile:Function,files:Array,defaultFiles:Array},emits:{add:null,beforeremove:null,beforeupload:null,cancel:null,statuschange:null,progress:null,remove:null},created(){this._httpSubscriptions={},n.validatePackage(ke),this.$props.defaultFiles&&(this.currentFiles=this.$props.defaultFiles)},data:()=>({currentFiles:[]}),computed:{computedAsync(){const{autoUpload:e,batch:t,removeField:n,removeHeaders:i,removeMethod:o,removeUrl:s,responseType:a,saveField:l,saveHeaders:r,saveMethod:d,saveUrl:c,withCredentials:u}=this.$props;return{autoUpload:e,batch:t,removeField:n,removeHeaders:i,removeMethod:o,removeUrl:s,responseType:a,saveField:l,saveHeaders:r,saveMethod:d,saveUrl:c,withCredentials:u}},computedFiles(){return(this.isControlled?this.$props.files:this.currentFiles)||[]},isControlled(){return!this.$props.defaultFiles},isCustomSave(){return this.$props.saveUrl&&"function"==typeof this.$props.saveUrl},isCustomRemove(){return this.$props.removeUrl&&"function"==typeof this.$props.removeUrl},fileStateCopy(){return de.copyState(this.computedFiles)},actionElement(){if(this._uploadNavigation)return this._uploadNavigation.actionElement}},mounted(){this._uploadNavigation=this.uploadNavigationRef},methods:{focus(){this._uploadNavigation&&this._uploadNavigation.focus()},uploadFiles(e){const t=this.computedAsync;de.setFilesStatus(e,r.Uploading),de.groupForEach(e,(e,n)=>{const i={target:this,files:e,headers:me(t.saveHeaders||{}),additionalData:{}};this.$emit("beforeupload",i);const o=he(i.headers,this.computedAsync),s=ue(e,t.saveField,i.additionalData);if(this.isCustomSave)this.$props.saveUrl(e,{formData:s,requestOptions:o},this.onUploadProgress).then(e=>this.onUploadSuccess(e.uid)).catch(e=>this.onUploadError(e.uid));else{const e=l.CancelToken.source();this._httpSubscriptions[n]=e,l({method:t.saveMethod,url:t.saveUrl,data:s,cancelToken:e.token,...o,onUploadProgress:e=>this.onUploadProgress(n,e)}).then(e=>this.onUploadSuccess(n,e)).catch(e=>this.onUploadError(n,e))}})},removeFiles(e){const t=this.computedAsync;de.groupForEach(e,(e,n)=>{const i={target:this,files:e,headers:me(t.removeHeaders||{}),additionalData:{}};this.$emit("beforeremove",i);const o=e.map(e=>e.name),s=he(i.headers,this.computedAsync),a=pe(o,t.removeField,i.additionalData);this.isCustomRemove?this.$props.removeUrl(e,{formData:a,requestOptions:s}).then(e=>this.onRemoveSuccess(e.uid)).catch(e=>this.onRemoveError(e.uid)):l({method:t.removeMethod,url:t.removeUrl,data:a,...s}).then(e=>this.onRemoveSuccess(n,e)).catch(e=>this.onRemoveError(n,e))})},onUpload(){const e=this.fileStateCopy,t=de.groupFilesByUid(e),n=de.filesForUpload(t);this.uploadFiles(n);this.isControlled||(this.currentFiles=e),(()=>{const t={target:this,newState:e,affectedFiles:de.flatFileGroup(n)};this.$emit("statuschange",t)})()},onAdd(e){let t,n=K.getAllFileInfo(e);if(n=K.assignGuidToFiles(n,this.computedAsync.batch),Se(n,this.$props.restrictions,this.validateFile),t=this.$props.multiple?this.fileStateCopy:[],de.addMany(n,t),this.computedAsync.autoUpload){const e=de.groupFilesByUid(t);this.uploadFiles(de.filesForUpload(e))}this.isControlled||(this.currentFiles=t),(()=>{const e={target:this,newState:t,affectedFiles:n};this.$emit("add",e)})()},onUploadProgress(e,t){const n=t.total?Math.round(100*t.loaded/t.total):0,i=this.fileStateCopy,o=i.filter(t=>t.uid===e);if(!o.length)return;o.forEach(e=>{e.progress=n});this.isControlled||(this.currentFiles=i),(()=>{const e={target:this,newState:i,affectedFiles:o};this.$emit("progress",e)})()},onUploadSuccess(e,t){const n=this.fileStateCopy,i=n.filter(t=>t.uid===e);i.forEach(e=>{e.status=r.Uploaded}),delete this._httpSubscriptions[e];this.isControlled||(this.currentFiles=n),(()=>{const e={target:this,newState:n,affectedFiles:i,response:t?fe(t):void 0};this.$emit("statuschange",e)})()},onUploadError(e,t){const n=this.fileStateCopy,i=n.filter(t=>t.uid===e);if(i.forEach(e=>{e.status=r.UploadFailed}),delete this._httpSubscriptions[e],!i.length)return;this.isControlled||(this.currentFiles=n),(()=>{const e={target:this,newState:n,affectedFiles:i,response:t?fe(t):void 0};this.$emit("statuschange",e)})()},onRemove(e){const t=this.fileStateCopy,n=t.filter(t=>t.uid===e),i=t.filter(t=>t.uid!==e),o=[r.Uploaded,r.Initial,r.RemoveFailed];if(n[0]&&o.indexOf(n[0].status)>-1){const i={[e]:n};de.setFilesStatus(i,r.Removing),this.removeFiles(i);const o=()=>{const e={target:this,newState:t,affectedFiles:n};this.$emit("statuschange",e)};this.isControlled||(this.currentFiles=t),o()}else{const e=()=>{const e={target:this,newState:i,affectedFiles:n};this.$emit("remove",e)};this.isControlled||(this.currentFiles=i),e()}},onRemoveSuccess(e,t){const n=this.fileStateCopy,i=n.filter(t=>t.uid===e),o=n.filter(t=>t.uid!==e);this.isControlled||(this.currentFiles=o),(()=>{const e={target:this,newState:o,affectedFiles:i,response:t?fe(t):void 0};this.$emit("remove",e)})()},onRemoveError(e,t){const n=this.fileStateCopy,i=n.filter(t=>t.uid===e);i.forEach(e=>{e.status=r.RemoveFailed});this.isControlled||(this.currentFiles=n),(()=>{const e={target:this,newState:n,affectedFiles:i,response:t?fe(t):void 0};this.$emit("statuschange",e)})()},onRetry(e){const t=this.fileStateCopy,n=de.groupFilesByUid(t.filter(t=>t.uid===e));de.setFilesStatus(n,r.Uploading),this.uploadFiles(n);this.isControlled||(this.currentFiles=t),(()=>{const e={target:this,newState:t,affectedFiles:de.flatFileGroup(n)};this.$emit("statuschange",e)})()},onCancel(e){const t=this.fileStateCopy,n=t.filter(t=>t.uid!==e),i=t.filter(t=>t.uid===e);this._httpSubscriptions[e]&&(this._httpSubscriptions[e].cancel(),delete this._httpSubscriptions[e]);const o={target:this,uid:e};this.$emit("cancel",o);this.isControlled||(this.currentFiles=t),(()=>{const e={target:this,newState:n,affectedFiles:i};this.$emit("remove",e)})()},onClear(){if(!this.computedFiles.length)return;Object.keys(this._httpSubscriptions).forEach(e=>{this._httpSubscriptions[e].cancel()}),this._httpSubscriptions={};this.isControlled||(this.currentFiles=[]),(()=>{const e={target:this,newState:[],affectedFiles:this.fileStateCopy};this.$emit("remove",e)})()}},render(){const{showFileList:e,autoUpload:i,showActionButtons:o,actionsLayout:s,tabIndex:a,disabled:l,batch:r,withCredentials:d,saveField:c,saveHeaders:u,saveMethod:p,saveUrl:h,responseType:m,removeField:f,removeHeaders:g,removeMethod:v,removeUrl:y,multiple:b,accept:F,restrictions:S,files:k,defaultFiles:I}=this.$props,x=n.templateRendering.call(this,this.$props.list,n.getListeners.call(this)),C=de.groupFilesByUid(this.computedFiles),N=de.filesForUpload(C);return t.createVNode(ae,{groupedFiles:C,className:this.$props.className,showFileList:e&&!!Object.keys(C).length,showActionButtons:o&&!i&&!!Object.keys(N).length,actionsLayout:s,disabled:l,onAdd:this.onAdd,onRemove:this.onRemove,onClear:this.onClear,onUpload:this.onUpload,onRetry:this.onRetry,onCancel:this.onCancel,tabIndex:n.getTabIndex(a,l),ref:e=>{this.uploadNavigationRef=e},multiple:b,accept:F,list:x,restrictions:S,files:k,defaultFiles:I,async:this.computedAsync},null)}}),xe=t.defineComponent({name:"KendoVueExternalDropZone",props:{id:String,tabIndex:Number,innerStyle:Object,uploadRef:[String,Function,Object],disabled:Boolean,customHint:[String,Function,Object],customNote:[String,Function,Object]},inject:{kendoLocalizationService:{default:null}},created(){n.validatePackage(ke),this.elementInterval=null,this.elementActive=!1,this.lastElementDragOverRef=null},data:()=>({overDropZone:!1}),mounted(){this.externalDropZone=this.externalDropZoneRef},methods:{focus(){this.externalDropZone&&this.externalDropZone.focus&&this.externalDropZone.focus()},isDragOver:e=>(new Date).getTime()-(e||new Date).getTime()>100,handleOnDrop(e){e.preventDefault();let t=e.dataTransfer.files,n=this.$parent.$refs[this.$props.uploadRef];t.length>0&&!this.$props.disabled&&n&&n.onAdd&&(e.preventDefault(),n.onAdd(t))},handleOnElementDragEnter(){this.elementActive=!0;this.elementInterval=setInterval(()=>{this.isDragOver(this.lastElementDragOver)&&(this.overDropZone=!1,this.elementActive=!1,clearInterval(this.elementInterval),this.elementInterval=null,this.lastElementDragOver=null)},100)},handleOnElementDragOver(e){e.preventDefault(),this.lastElementDragOver=new Date,this.overDropZone=!0}},setup:()=>({externalDropZoneRef:t.ref(null),kendoLocalizationService:t.inject("kendoLocalizationService",{})}),render(){const{customNote:e,customHint:o}=this.$props,s=i.provideLocalizationService(this),l=s.toLanguageString($,R[$]),r=s.toLanguageString(U,R[U]),d=n.templateRendering.call(this,o,n.getListeners.call(this)),c=n.templateRendering.call(this,e,n.getListeners.call(this));let u;const p=t.createVNode("span",null,[l]);let h;u=n.getTemplate.call(this,{h:t.h,template:d,defaultRendering:p});const m=t.createVNode("span",null,[r]);return h=n.getTemplate.call(this,{h:t.h,template:c,defaultRendering:m}),t.createVNode("div",{ref:n.setRef(this,"externalDropZone"),id:this.$props.id,class:n.classNames("k-external-dropzone",{"k-external-dropzone-hover":this.overDropZone,"k-disabled":this.$props.disabled},this.$props.className),tabindex:n.getTabIndex(this.$props.tabIndex,this.$props.disabled,void 0),onDrop:this.handleOnDrop,onDragenter:this.handleOnElementDragEnter,onDragover:this.handleOnElementDragOver},[t.createVNode("div",{style:this.$props.innerStyle,class:"k-dropzone-inner"},[t.createVNode(n.Icon,{name:"upload",icon:a.uploadIcon,class:"k-dropzone-icon",size:"xxxlarge"},null),t.createVNode("span",{class:"k-dropzone-hint"},[u]),t.createVNode("span",{class:"k-dropzone-note"},[h])]),t.createVNode("div",{class:"k-upload"},null)])}});e.ExternalDropZone=xe,e.Upload=Ie,e.UploadFileStatus=r,e.UploadListActionButton=M,e.UploadListMultiItem=H,e.UploadListSingleItem=Z,e.UploadUI=ie,e.messages=R,e.utils=K});
|
|
15
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue"),require("@progress/kendo-vue-common"),require("@progress/kendo-vue-intl"),require("@progress/kendo-vue-progressbars"),require("@progress/kendo-vue-buttons"),require("@progress/kendo-svg-icons")):"function"==typeof define&&define.amd?define(["exports","vue","@progress/kendo-vue-common","@progress/kendo-vue-intl","@progress/kendo-vue-progressbars","@progress/kendo-vue-buttons","@progress/kendo-svg-icons"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoVueUpload={},e.Vue,e.KendoVueCommon,e.KendoVueIntl,e.KendoVueProgressbars,e.KendoVueButtons,e.KendoSVGIcons)}(this,function(e,t,n,i,o,s,a){"use strict";var l=(e=>(e[e.UploadFailed=0]="UploadFailed",e[e.Initial=1]="Initial",e[e.Selected=2]="Selected",e[e.Uploading=3]="Uploading",e[e.Uploaded=4]="Uploaded",e[e.RemoveFailed=5]="RemoveFailed",e[e.Removing=6]="Removing",e))(l||{});const r="upload.cancel",d="upload.clearSelectedFiles",c="upload.dropFileHere",u="upload.dropFilesHere",p="upload.headerStatusUploaded",h="upload.headerStatusUploading",m="upload.invalidFileExtension",f="upload.invalidFiles",g="upload.invalidMaxFileSize",v="upload.invalidMinFileSize",y="upload.remove",b="upload.retry",F="upload.select",x="upload.selectSingle",S="upload.selectTitle",k="upload.selectNoFilesTitle",I="upload.uploadSelectedFiles",C="upload.total",N="upload.files",B="upload.statusUploaded",E="upload.statusUploadFailed",D="upload.dropZoneHint",$="upload.dropZoneNote",R={[r]:"Cancel",[d]:"Clear",[c]:"Drop a file here to upload",[u]:"Drop files here to upload",[p]:"Done",[h]:"Uploading...",[m]:"File type not allowed.",[f]:"Invalid file(s). Please check file upload requirements.",[g]:"File size too large.",[v]:"File size too small.",[y]:"Remove",[b]:"Retry",[F]:"Select files...",[x]:"Select file...",[S]:"Press to select more files",[k]:"No files selected",[I]:"Upload",[C]:"Total",[N]:"files",[B]:"File(s) successfully uploaded.",[E]:"File(s) failed to upload.",[D]:"Drag and drop files here to upload.",[$]:"Only JPEG and PNG files are allowed."},U=/&/g,L=/</g,w=/"/g,V=/'/g,O=/>/g,A=e=>(""+e).replace(U,"&").replace(L,"<").replace(O,">").replace(w,""").replace(V,"'"),z=e=>{const t=e.match(/\.([^\.]+)$/);return t?t[0]:""},j=e=>{const t=e.name,n=e.size;return{extension:z(t),name:A(t),getRawFile:()=>e,size:n,status:l.Selected,progress:0,uid:""}},T=e=>!!(e.validationErrors&&e.validationErrors.length>0),_={fileHasValidationErrors:T,filesHaveValidationErrors:e=>{for(const t of e)if(T(t))return!0;return!1},getTotalFilesSizeMessage:e=>{let t,n=0;if("number"!=typeof e[0].size)return"";for(t=0;t<e.length;t++)e[t].size&&(n+=e[t].size||0);return n/=1024,n<1024?n.toFixed(2)+" KB":(n/1024).toFixed(2)+" MB"},getAllFileInfo:e=>{const t=new Array;let n;for(n=0;n<e.length;n++)t.push(j(e[n]));return t},getFileInfo:j,getFileExtension:z,htmlEncode:A,assignGuidToFiles:(e,t)=>{const i=n.guid();return e.map(e=>(e.uid=t?i:n.guid(),e))},getFileStatus:e=>{let t=!1,n=!1,i=!1,o=!1;const s=e=>{e.forEach(e=>{e.status===l.Uploading&&(t=!0),e.status===l.Uploaded&&(n=!0),e.status===l.UploadFailed&&(i=!0),T(e)&&(o=!0)})};return Array.isArray(e)?s(e):Object.keys(e).forEach(t=>{s(e[t])}),[t,n,i,o]}},M=t.defineComponent({name:"KendoVueUploadListActionButton",props:{progress:Number,uid:String,status:Number,async:Object,disabled:Boolean,files:Array},emits:{cancel:null,retry:null,remove:null},inject:{kendoLocalizationService:{default:null}},data:()=>({retryFocused:!1,actionFocused:!1}),methods:{actionButtonTitle:(e,t)=>e===l.Uploading?t.toLanguageString(r,R[r]):t.toLanguageString(y,R[y]),retryButtonTitle:e=>e.toLanguageString(b,R[b]),buttonClassNames(e){return n.classNames(this.actionFocused&&"action"===e||this.retryFocused&&"retry"===e?"k-focus":"")},onRetryFocus(){this.retryFocused=!0},onRetryBlur(){this.retryFocused=!1},onActionFocus(){this.actionFocused=!0},onActionBlur(){this.actionFocused=!1},onActionClick(){const{status:e,uid:t,disabled:n}=this.$props;n||e===l.Removing||(e===l.Uploading?this.$emit("cancel",t):this.$emit("remove",t))},onRetryClick(){const{uid:e,disabled:t}=this.$props;t||this.$emit("retry",e)}},setup:()=>({kendoLocalizationService:t.inject("kendoLocalizationService",{})}),render(){const{status:e,progress:n}=this.$props,o=e===l.UploadFailed,r=e===l.Uploading,d=(e===l.Uploaded||e===l.Initial)&&!this.$props.async.removeUrl,c=i.provideLocalizationService(this);return t.createVNode("div",{class:"k-upload-actions"},[r?t.createVNode("span",{class:"k-upload-pct"},[n,"%"]):void 0,o?t.createVNode(s.Button,{type:"button",fillMode:"flat",tabIndex:-1,disabled:this.disabled,class:this.buttonClassNames("retry"),icon:"arrow-rotate-cw-small",svgIcon:a.arrowRotateCwSmallIcon,iconClass:"k-retry",ariaLabel:this.retryButtonTitle(c),title:this.retryButtonTitle(c),onFocus:this.onRetryFocus,onBlur:this.onRetryBlur,onClick:this.onRetryClick},null):void 0,d?void 0:t.createVNode(s.Button,{type:"button",fillMode:"flat",tabIndex:-1,disabled:this.disabled,class:this.buttonClassNames("action"),onFocus:this.onActionFocus,onBlur:this.onActionBlur,onClick:this.onActionClick,icon:e===l.Uploading?"cancel":"x",svgIcon:r?a.cancelIcon:a.xIcon,ariaLabel:this.actionButtonTitle(e,c),title:this.actionButtonTitle(e,c)},null)])}}),K=t.defineComponent({name:"KendoVueUploadListSingleItem",props:{files:Array,disabled:Boolean,async:Object},emits:{cancel:null,retry:null,remove:null},inject:{kendoLocalizationService:{default:null}},methods:{onRetry(e){this.$emit("retry",e)},onRemove(e){this.$emit("remove",e)},onCancel(e){this.$emit("cancel",e)},getFileExtension:e=>e.extension?e.extension.substring(1):"",getFileValidationMessage(e,t){const n=i.provideLocalizationService(this);let o="";if(t)o=n.toLanguageString(E,R[E]);else if(e.validationErrors&&e.validationErrors.length>0){const t=`upload.${e.validationErrors[0]}`;o=n.toLanguageString(t,R[t])}return o},getFileExtensionName(e){switch(e.extension){case".png":case".jpg":case".jpeg":case".tiff":case".bmp":case".gif":return"file-image";case".mp3":case".mp4":case".wav":return"file-audio";case".mkv":case".webm":case".flv":case".gifv":case".avi":case".wmv":return"file-video";case".txt":return"file-txt";case".pdf":return"file-pdf";case".ppt":case".pptx":return"file-presentation";case".csv":case".xls":case".xlsx":return"file-data";case".html":case".css":case".js":case".ts":return"file-programming";case".exe":return"file-config";case".zip":case".rar":return"file-zip";default:return"file"}},getFileExtensionSVG(e){switch(e.extension){case".png":case".jpg":case".jpeg":case".tiff":case".bmp":case".gif":return a.fileImageIcon;case".mp3":case".mp4":case".wav":return a.fileAudioIcon;case".mkv":case".webm":case".flv":case".gifv":case".avi":case".wmv":return a.fileVideoIcon;case".txt":return a.fileTxtIcon;case".pdf":return a.filePdfIcon;case".ppt":case".pptx":return a.filePresentationIcon;case".csv":case".xls":case".xlsx":return a.fileDataIcon;case".html":case".css":case".js":case".ts":return a.fileProgrammingIcon;case".exe":return a.fileConfigIcon;case".zip":case".rar":return a.fileZipIcon;default:return a.fileIcon}}},setup:()=>({kendoLocalizationService:t.inject("kendoLocalizationService",{})}),render(){const{files:e,disabled:s,async:a}=this.$props,l=e[0],r=n.classNames("k-file-single"),[,d,c,u]=_.getFileStatus([l]),p=!u&&!d&&!c;return t.createVNode("div",{class:r},[p&&t.createVNode(o.ProgressBar,{value:l.progress||0,labelVisible:!1},null),t.createVNode("span",{class:"k-file-icon-wrapper",key:"1"},[t.createVNode(n.Icon,{name:this.getFileExtensionName(l),icon:this.getFileExtensionSVG(l),size:"xxxlarge",class:"k-file-icon"},null),t.createVNode("span",{class:"k-file-state"},null)]),u||c?function(e,n){return t.createVNode("span",{class:"k-file-info",key:"2"},[t.createVNode("span",{class:"k-file-name",title:e.name},[e.name]),t.createVNode("span",{class:"k-file-validation-message"},[this.getFileValidationMessage(e,n)])])}.call(this,l,c):function(e){const n=i.provideLocalizationService(this).toLanguageString(B,R[B]);return t.createVNode("span",{class:"k-file-info",key:"2"},[t.createVNode("span",{class:"k-file-name",title:e.name},[e.name]),100!==e.progress?t.createVNode("span",{class:"k-file-size"},[_.getTotalFilesSizeMessage([e])]):t.createVNode("span",{class:"k-file-validation-message"},[n])])}.call(this,l),t.createVNode(M,{uid:l.uid,status:l.status,progress:l.progress,files:e,disabled:s,async:a,onCancel:this.onCancel,onRemove:this.onRemove,onRetry:this.onRetry},null)])}}),Z=t.defineComponent({name:"KendoVueUploadListMultiItem",props:{files:Array,disabled:Boolean,async:Object},emits:{cancel:null,retry:null,remove:null},inject:{kendoLocalizationService:{default:null}},methods:{onRetry(e){this.$emit("retry",e)},onRemove(e){this.$emit("remove",e)},onCancel(e){this.$emit("cancel",e)},getFileValidationMessage(e){const t=i.provideLocalizationService(this);let n="";if(e.validationErrors&&e.validationErrors.length>0){const i=`upload.${e.validationErrors[0]}`;n=t.toLanguageString(i,R[i])}return n},progress(){const{files:e}=this.$props;let t=0;return e.forEach(e=>{t+=e.progress||0}),t/e.length}},setup:()=>({kendoLocalizationService:t.inject("kendoLocalizationService",{})}),render(){const{files:e,disabled:s,async:l}=this.$props,r=n.classNames("k-file-multiple"),[,d,c,u]=_.getFileStatus(e),p=i.provideLocalizationService(this),h=p.toLanguageString(C,R[C]),m=p.toLanguageString(N,R[N]),f=p.toLanguageString(E,R[E]),g=p.toLanguageString(B,R[B]),v=this.progress(),y=!u&&!d&&!c;return t.createVNode("div",{class:r},[y&&t.createVNode(o.ProgressBar,{value:v||0,labelVisible:!1},null),t.createVNode("span",{class:"k-file-icon-wrapper"},[t.createVNode(n.Icon,{name:"copy",icon:a.copyIcon,size:"xxxlarge",class:"k-file-icon"},null)]),t.createVNode("span",{class:"k-multiple-files-wrapper"},[function(){return e.map(function(e){return t.createVNode("span",{key:e.name,class:"k-file-info"},[t.createVNode("span",{class:"k-file-name",title:e.name},[e.name]),_.fileHasValidationErrors(e)?t.createVNode("span",{class:"k-file-validation-message"},[this.getFileValidationMessage(e)]):t.createVNode("span",{key:`${e.name}-size`,class:"k-file-size"},[_.getTotalFilesSizeMessage([e])])])},this)}.call(this),c?t.createVNode("span",{class:"k-file-validation-message"},[`${e.length} ${f}`]):100!==v?t.createVNode("span",{class:"k-file-summary"},[`${h}: ${e.length} ${m}, ${_.getTotalFilesSizeMessage(e)}`]):t.createVNode("span",{class:"k-file-summary k-text-success"},[`${e.length} ${g}`])]),t.createVNode(M,{uid:e[0].uid,status:e[0].status,progress:v,files:e,disabled:s,async:l,onCancel:this.onCancel,onRemove:this.onRemove,onRetry:this.onRetry},null)])}}),q=t.defineComponent({name:"KendoVueUploadListGroup",props:{files:Array,async:Object,disabled:Boolean,navigationIndex:Number,list:[String,Function,Object],index:Number},emits:{cancel:null,click:null,retry:null,remove:null},mounted(){this._element=this.elementRef},updated(){const{navigationIndex:e,index:t}=this.$props;e===t&&this._element&&n.canUseDOM&&document.activeElement!==this._element&&this._element.focus()},methods:{onClick(){this.$emit("click",this.$props.index)},onRetry(e){this.$emit("retry",e)},onRemove(e){this.$emit("remove",e)},onCancel(e){this.$emit("cancel",e)}},setup:()=>({elementRef:t.ref(null)}),render(){const{files:e,async:i,disabled:o,navigationIndex:s,index:a}=this.$props,r=e[0],d=r.status===l.Uploaded||r.status===l.Initial,c=_.filesHaveValidationErrors(e),u=r.status===l.UploadFailed||r.status===l.RemoveFailed,p=n.classNames("k-file",{"k-file-invalid":c,"k-file-error":u||c,"k-file-progress":r.status===l.Uploading,"k-file-success":d,"k-focus":s===a});let h;const m=1===e.length?t.createVNode(K,{files:e,async:i,disabled:o,onCancel:this.onCancel,onRemove:this.onRemove,onRetry:this.onRetry},null):t.createVNode(Z,{files:e,async:i,disabled:o,onCancel:this.onCancel,onRemove:this.onRemove,onRetry:this.onRetry},null);return h=n.getTemplate.call(this,{h:t.h,template:this.$props.list,defaultRendering:m,additionalProps:this.$props,additionalListeners:{retry:this.onRetry,remove:this.onRemove,cancel:this.onCancel}}),t.createVNode("li",{ref:n.setRef(this,"element"),class:p,"data-uid":r.uid,tabindex:-1,onClick:this.onClick},[h])}}),H=t.defineComponent({name:"KendoVueUploadList",props:{groupedFiles:Object,async:Object,disabled:Boolean,navigationIndex:{type:Number,default:void 0},list:[String,Function,Object]},emits:{cancel:null,click:null,retry:null,remove:null},methods:{onClick(e){this.$emit("click",e)},onRetry(e){this.$emit("retry",e)},onRemove(e){this.$emit("remove",e)},onCancel(e){this.$emit("cancel",e)}},render(){const{groupedFiles:e,navigationIndex:i,async:o,disabled:s,list:a}=this.$props,l=n.classNames("k-upload-files","k-reset");return t.createVNode("ul",{class:l},[Object.keys(e).map(function(n,l){const r=e[n];return t.createVNode(q,{key:n,files:r,index:l,navigationIndex:i,async:o,disabled:s,list:a,onCancel:this.onCancel,onClick:this.onClick,onRemove:this.onRemove,onRetry:this.onRetry},null)},this)])}});function P(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!t.isVNode(e)}const G=t.defineComponent({name:"KendoVueUploadActionButtons",props:{disabled:Boolean,navigationIndex:Number,clearButtonIndex:Number,uploadButtonIndex:Number,actionsLayout:String},inject:{kendoLocalizationService:{default:null}},emits:{clear:null,click:null,upload:null},created(){this._prevNavigationIndex=void 0},setup:()=>({uploadElementRef:t.ref(null),clearElementRef:t.ref(null),kendoLocalizationService:t.inject("kendoLocalizationService",{})}),mounted(){this._clearElement=this.clearElementRef,this._uploadElement=this.uploadElementRef},watch:{navigationIndex:function(e,t){this._prevNavigationIndex=t}},updated(){const{navigationIndex:e,clearButtonIndex:t,uploadButtonIndex:n}=this.$props;e!==this._prevNavigationIndex&&(e===t&&this._clearElement&&this._clearElement.focus(),e===n&&this._uploadElement&&this._uploadElement.focus())},methods:{onClearClick(){this.$props.disabled||this.$emit("clear")},onUploadClick(){this.$props.disabled||(this.$emit("click",this.$props.uploadButtonIndex),this.$emit("upload"))}},render(){let e,o;const{disabled:a,navigationIndex:l,clearButtonIndex:r,uploadButtonIndex:c,actionsLayout:u}=this.$props,p=i.provideLocalizationService(this),h=n.classNames("k-actions",{"k-actions-start":"start"===u,"k-actions-center":"center"===u,"k-actions-end":"end"===u,"k-actions-stretched":"stretched"===u}),m=n.classNames("k-clear-selected",l===r?"k-focus":""),f=n.classNames("k-upload-selected",l===c?"k-focus":"");return t.createVNode("div",{class:h},[t.createVNode(s.Button,{type:"button",ref:e=>{this.clearElementRef=e},disabled:a,class:m,tabIndex:-1,onClick:this.onClearClick},P(e=p.toLanguageString(d,R[d]))?e:{default:()=>[e]}),t.createVNode(s.Button,{type:"button",ref:e=>{this.uploadElementRef=e},disabled:a,themeColor:"primary",class:f,tabIndex:-1,onClick:this.onUploadClick},P(o=p.toLanguageString(I,R[I]))?o:{default:()=>[o]})])}}),X=/(chrome)[ \/]([\w.]+)/i,J=/(webkit)[ \/]([\w.]+)/i,Q=t.defineComponent({name:"KendoVueUploadInput",props:{async:Object,id:String,multiple:{type:Boolean,default:void 0},disabled:{type:Boolean,default:void 0},accept:{type:String,default:void 0},hasFiles:{type:Boolean,default:!1},ariaLabelledBy:{type:String,default:void 0},ariaDescribedBy:{type:String,default:void 0}},emits:{mousedown:null,add:null},inject:{kendoLocalizationService:{default:null}},mounted(){this._input=this.inputRef},methods:{onMouseDown(e){this.$emit("mousedown",e)},onAdd(){const e=navigator.userAgent,t=this._input;t&&(t.files&&this.$emit("add",t.files),!e.match(X)&&e.match(J)||(t.type="",t.type="file"))},actionElement(){return this._input}},setup:()=>({inputRef:t.ref(null)}),render(){const{multiple:e,async:o,disabled:s,accept:a,hasFiles:l,ariaLabelledBy:r,ariaDescribedBy:d}=this.$props,c=i.provideLocalizationService(this),u=l?S:k,p=c.toLanguageString(u,R[u]),h=c.toLanguageString(F,R[F]);return t.createVNode("input",{ref:n.setRef(this,"input"),id:this.id,class:"k-hidden",autocomplete:"off",name:o.saveField,accept:a,type:"file",tabindex:-1,multiple:e,disabled:s,onChange:this.onAdd,onMousedown:this.onMouseDown,title:p,"aria-label":void 0!==r?void 0:h,"aria-labelledby":r,"aria-describedby":d},null)}});function W(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!t.isVNode(e)}const Y=t.defineComponent({name:"KendoVueUploadAddButton",props:{addButtonIndex:Number,navigationIndex:Number,notFocusedIndex:Number,tabIndex:Number,async:Object,multiple:Boolean,disabled:Boolean,accept:String,id:String,ariaLabelledBy:String,ariaDescribedBy:String},inject:{kendoLocalizationService:{default:null}},emits:{add:null,click:null},setup:()=>({elementRef:t.ref(null),uploadInputRef:t.ref(null),kendoLocalizationService:t.inject("kendoLocalizationService",{})}),created(){this.uploadInputId=n.guid()},mounted(){this.element=this.elementRef,this.uploadInput=this.uploadInputRef},watch:{navigationIndex:function(e,t){this._prevNavigationIndex=t}},updated(){const{navigationIndex:e,addButtonIndex:t,notFocusedIndex:n}=this.$props;e!==this._prevNavigationIndex&&this._prevNavigationIndex!==n&&e===t&&this.element&&this.element.focus()},methods:{focus(){this.element&&this.element.focus()},onClick(){this.actionElement()&&this.actionElement().click(),this.$emit("click",this.$props.addButtonIndex)},onAdd(e){this.$emit("add",e)},onInputMouseDown(e){this.element&&(e.preventDefault(),this.element.focus())},actionElement(){if(this.uploadInput)return this.uploadInput.actionElement()}},render(){const{navigationIndex:e,addButtonIndex:o,tabIndex:a,id:l,async:r,multiple:d,disabled:c,accept:u,ariaLabelledBy:p,ariaDescribedBy:h}=this.$props,m=i.provideLocalizationService(this),f=d?m.toLanguageString(F,R[F]):m.toLanguageString(x,R[x]),g=n.classNames("k-upload-button",e===o?"k-focus":"");return t.createVNode("div",{class:"k-upload-button-wrap"},[t.createVNode(s.Button,{id:l,ref:n.setRef(this,"element"),role:"button",type:"button",disabled:c,ariaLabel:f,class:g,tabIndex:a,"aria-labelledby":p,"aria-describedby":h,onClick:this.onClick},W(f)?f:{default:()=>[f]}),t.createVNode(Q,{id:this.uploadInputId,async:r,multiple:d,disabled:c,accept:u,onMousedown:this.onInputMouseDown,onAdd:this.onAdd,ref:e=>{this.uploadInputRef=e}},null)])}}),ee=t.defineComponent({props:{isUploading:Boolean,isUploaded:Boolean,isUploadFailed:Boolean},inject:{kendoLocalizationService:{default:null}},setup:()=>({kendoLocalizationService:t.inject("kendoLocalizationService",{})}),render(){const{isUploading:e,isUploaded:o,isUploadFailed:s}=this.$props;let l="";const r=i.provideLocalizationService(this);return e?l=r.toLanguageString(h,R[h]):(o||s)&&(l=r.toLanguageString(p,R[p])),t.createVNode("div",{class:n.classNames("k-upload-status")},[t.createVNode(n.Icon,{name:e||s||!o?!e&&s?"exclamation-circle":e?"upload":"":"check",icon:e||s||!o?!e&&s?a.exclamationCircleIcon:e?a.uploadIcon:{}:a.checkIcon},null),l])}}),te=t.defineComponent({name:"KendoVueUploadDropZone",props:{addButtonIndex:Number,async:Object,multiple:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},showFileList:Boolean,showActionButtons:Boolean,actionsLayout:{type:String,default:function(){return"end"}},tabIndex:Number,accept:String,groupedFiles:{type:Object,default:function(){return{}}},navigationIndex:Number,notFocusedIndex:Number,list:[String,Function,Object],id:String,ariaLabelledBy:String,ariaDescribedBy:String,fileGroup:Object},emits:{add:null,click:null},inject:{kendoLocalizationService:{default:null}},data:()=>({currentDocumentActive:!1,currentElementActive:!1}),created(){this.currentElementActive=!1},mounted(){this.uploadAddButton=this.uploadAddButtonRef,document.addEventListener("dragenter",this.onDocumentDragEnter),document.addEventListener("dragover",this.onDocumentDragOver)},unmounted(){document.removeEventListener("dragenter",this.onDocumentDragEnter),document.removeEventListener("dragover",this.onDocumentDragOver)},setup:()=>({uploadAddButtonRef:t.ref(null),kendoLocalizationService:t.inject("kendoLocalizationService",{})}),computed:{dropZoneClasses(){return{"k-dropzone":!0,"k-upload-dropzone":!0,"k-active":this.currentDocumentActive,"k-hover":this.currentElementActive}}},methods:{actionElement(){if(this.uploadAddButton)return this.uploadAddButton.uploadInput},focus(){if(this.uploadAddButton)return this.uploadAddButton.focus()},onDocumentDragEnter(){if(!this.currentDocumentActive){this.currentDocumentActive=!0;const e=()=>{this.isDragOver(this._lastDocumentDragOver)&&(this.currentDocumentActive=!1,clearInterval(this._documentInterval),this._documentInterval=null,this._lastDocumentDragOver=null)};this._documentInterval=setInterval(e,100)}},onDocumentDragOver(){this._lastDocumentDragOver=new Date},onElementDragEnter(){if(!this.currentElementActive){this.currentElementActive=!0;const e=()=>{this.isDragOver(this._lastElementDragOver)&&(this.currentElementActive=!1,clearInterval(this._elementInterval),this._elementInterval=null,this._lastElementDragOver=null)};this._elementInterval=setInterval(e,100)}},onElementDragOver(e){e.preventDefault(),this._lastElementDragOver=new Date},onDrop(e){e.preventDefault();let t=e.dataTransfer.files;t.length>0&&!this.$props.disabled&&this.$emit("add",t)},isDragOver:e=>(new Date).getTime()-(e||new Date).getTime()>100,onClick(e){this.$emit("click",e)},onAdd(e){this.$emit("add",e)}},render(){const{multiple:e,disabled:o,tabIndex:s,fileGroup:a,accept:l,navigationIndex:r,notFocusedIndex:d,id:p,ariaLabelledBy:h,ariaDescribedBy:m}=this.$props,f=i.provideLocalizationService(this),g=e?f.toLanguageString(u,R[u]):f.toLanguageString(c,R[c]),[v,y,b,F]=_.getFileStatus(a),x=n.classNames("k-dropzone-hint",{});return t.createVNode("div",{class:this.dropZoneClasses,onDrop:this.onDrop,onDragenter:this.onElementDragEnter,onDragover:this.onElementDragOver},[function(){return t.createVNode(Y,{id:p,ariaLabelledBy:h,ariaDescribedBy:m,ref:e=>{this.uploadAddButtonRef=e},accept:l,async:this.async,addButtonIndex:this.addButtonIndex,navigationIndex:r,notFocusedIndex:d,tabIndex:s,multiple:e,disabled:o,onClick:this.onClick,onAdd:this.onAdd},null)}.call(this),v||y||b||F?t.createVNode(ee,{isUploading:v,isUploaded:y,isUploadFailed:b},null):t.createVNode("div",{class:x},[g])])}}),ne=t.defineComponent({name:"KendoVueUploadUI",props:{async:Object,className:String,multiple:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},showFileList:Boolean,showActionButtons:Boolean,actionsLayout:{type:String,default:function(){return"end"}},tabIndex:Number,accept:String,groupedFiles:{type:Object,default:function(){return{}}},navigationIndex:Number,notFocusedIndex:Number,list:[String,Function,Object],id:String,ariaLabelledBy:String,ariaDescribedBy:String},computed:{groupsCount(){return Object.keys(this.$props.groupedFiles).length},lastGroupIndex(){return this.groupsCount-1},addButtonIndex:()=>-1,clearButtonIndex(){return this.lastGroupIndex+1},uploadButtonIndex(){return this.lastGroupIndex+2},isRtl(){return this._container&&"rtl"===getComputedStyle(this._container).direction||!1}},methods:{actionElement(){if(this.uploadDropZone)return this.uploadDropZone.actionElement()},focus(){if(this.uploadDropZone)return this.uploadDropZone.focus()},onAdd(e){this.$emit("add",e)},onRetry(e){this.$emit("retry",e)},onCancel(e){this.$emit("cancel",e)},onClear(){this.$emit("clear")},onUpload(){this.$emit("upload")},onRemove(e){this.$emit("remove",e)},onKeyDown(e){this.$emit("keydown",e,this.isRtl)},onFocus(e){this.$emit("focus",e)},onBlur(e){this.$emit("blur",e)},onClick(e){this.$emit("click",e)}},emits:{add:null,retry:null,cancel:null,clear:null,upload:null,remove:null,keydown:null,click:null,focus:null,blur:null},mounted(){this._container=this.containerRef,this.uploadDropZone=this.uploadDropZoneRef},setup:()=>({containerRef:t.ref(null),uploadDropZoneRef:t.ref(null)}),render(){const{multiple:e,disabled:i,tabIndex:o,accept:s,showFileList:a,groupedFiles:l,navigationIndex:r,showActionButtons:d,actionsLayout:c,notFocusedIndex:u,list:p,id:h,ariaLabelledBy:m,ariaDescribedBy:f,async:g}=this.$props,v=n.classNames("k-upload","k-upload-async",this.$props.className,i?"k-disabled":"");return t.createVNode("div",{ref:n.setRef(this,"container"),class:v,onKeydown:this.onKeyDown,onFocus:this.onFocus,onBlur:this.onBlur},[t.createVNode(te,{id:h,ariaLabelledBy:m,ariaDescribedBy:f,ref:e=>{this.uploadDropZoneRef=e},accept:s,async:g,addButtonIndex:this.addButtonIndex,navigationIndex:r,notFocusedIndex:u,tabIndex:o,multiple:e,onClick:this.onClick,onAdd:this.onAdd,fileGroup:l,disabled:i},null),a?t.createVNode(H,{groupedFiles:l,disabled:i,async:g,navigationIndex:r,list:p,onCancel:this.onCancel,onRemove:this.onRemove,onRetry:this.onRetry,onClick:this.onClick},null):void 0,d?t.createVNode(G,{disabled:i,navigationIndex:r,clearButtonIndex:this.clearButtonIndex,uploadButtonIndex:this.uploadButtonIndex,actionsLayout:c,onUpload:this.onUpload,onClear:this.onClear,onClick:this.onClick},null):void 0])}}),ie=-2,oe=-1,se=t.defineComponent({name:"KendoVueUploadNavigation",props:{async:Object,className:String,multiple:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},showFileList:Boolean,showActionButtons:Boolean,actionsLayout:{type:String,default:function(){return"end"}},tabIndex:Number,accept:String,groupedFiles:{type:Object,default:function(){return{}}},notFocusedIndex:Number,list:[String,Function,Object],id:String,ariaLabelledBy:String,ariaDescribedBy:String,restrictions:Object,files:Array,defaultFiles:Array},emits:{add:null,cancel:null,clear:null,upload:null,retry:null,remove:null},data:()=>({currentNavIndex:ie}),updated(){},methods:{actionElement(){if(this._uploadUI)return this._uploadUI.actionElement()},navIndex(e){if(void 0===e)return this.currentNavIndex;const t=this.navIndex;this.currentNavIndex=e,e!==t&&this.$forceUpdate()},focus(){this._uploadUI&&this._uploadUI.focus()},onKeyDown(e,t){var i;const o=this.navIndex(),s=Object.keys(this.$props.groupedFiles),a=s.length-1,l=this.$props.autoUpload||0===s.length?a:a+1,r=a+1,d=r+1,c=o===ie?oe:o;let u=o;switch(e.keyCode){case n.Keys.up:e.preventDefault(),o>-1&&(u=c-1);break;case n.Keys.down:e.preventDefault(),o<l&&(u=c+1);break;case n.Keys.left:e.preventDefault(),t?o===r&&(u=c+1):o===d&&(u=c-1);break;case n.Keys.right:e.preventDefault(),t?o===d&&(u=c-1):o===r&&(u=c+1);break;case n.Keys.enter:(o===oe||o===ie)&&this.actionElement()&&n.canUseDOM&&-1===(null==(i=document.activeElement)?void 0:i.className.indexOf("k-upload-button"))&&this.actionElement().$el.click(),o>=0&&o<=a&&this.onRetry(s[o]);break;case n.Keys.space:e.preventDefault(),(o===oe||o===ie)&&this.actionElement()&&this.actionElement().$el.click();break;case n.Keys.tab:u=ie;break;case n.Keys.delete:o>=0&&o<=a&&(u=c-1,this.onRemove(s[o]));break;case n.Keys.esc:o>=0&&o<=a&&(u=c-1,this.onCancel(s[o]))}this.navIndex(u)},onCancel(e){this.$emit("cancel",e)},onClear(){this.navIndex(oe),this.$emit("clear")},onUpload(){this.navIndex(oe),this.$emit("upload")},onRetry(e){this.$emit("retry",e)},onRemove(e){this.navIndex(this.navIndex()>oe?this.navIndex()-1:oe),this.$emit("remove",e)},onAdd(e){this.navIndex(oe),this.$emit("add",e)},onClick(e){this.navIndex(e)},onFocus(){this._blurTimeout&&(clearTimeout(this._blurTimeout),this._blurTimeout=void 0)},onBlurTimeout(){this.navIndex(ie),this._blurTimeout=void 0},onBlur(){clearTimeout(this._blurTimeout),this._blurTimeout=window.setTimeout(this.onBlurTimeout)}},mounted(){this._uploadUI=this.uploadUIRef},setup:()=>({uploadUIRef:t.ref(null)}),render(){const{multiple:e,disabled:n,showFileList:i,showActionButtons:o,actionsLayout:s,tabIndex:a,accept:l,groupedFiles:r,list:d,id:c,ariaLabelledBy:u,ariaDescribedBy:p,async:h}=this.$props;return t.createVNode(ne,{ref:e=>{this.uploadUIRef=e},class:this.$props.className,onKeydown:this.onKeyDown,navigationIndex:this.currentNavIndex,notFocusedIndex:ie,onAdd:this.onAdd,onClear:this.onClear,onUpload:this.onUpload,onRemove:this.onRemove,onRetry:this.onRetry,onCancel:this.onCancel,onClick:this.onClick,onFocus:this.onFocus,onBlur:this.onBlur,multiple:e,disabled:n,showFileList:i,showActionButtons:o,actionsLayout:s,tabIndex:a,accept:l,groupedFiles:r,list:d,id:c,ariaLabelledBy:u,ariaDescribedBy:p,async:h},null)}}),ae=(e,t)=>{t.push(e)},le=(e,t)=>{Object.keys(e).forEach(n=>{t(e[n],n)})},re={copyState:e=>(e||[]).map(e=>({...e})),addMany:(e,t)=>{e.forEach(e=>ae(e,t))},add:ae,groupFilesByUid:e=>{const t={};return e.forEach(e=>{t[e.uid]?t[e.uid].push(e):t[e.uid]=[e]}),t},filesForUpload:e=>{const t={};return le(e,(e,n)=>{let i=!0;e.forEach(e=>{(e.status!==l.Selected||e.validationErrors&&e.validationErrors.length>0)&&(i=!1)}),i&&(t[n]=e)}),t},setFilesStatus:(e,t)=>{le(e,e=>{e.forEach(e=>{e.status=t})})},flatFileGroup:e=>{const t=[];return le(e,e=>{t.push.apply(t,e)}),t},groupForEach:le},de=(e,t)=>{Object.keys(t).forEach(n=>{e.append(n,t[n])})},ce=e=>{const t=e.getAllResponseHeaders(),n={};return t&&t.trim().split(/[\r\n]+/).forEach(e=>{const t=e.indexOf(":");t>0&&(n[e.substring(0,t).trim().toLowerCase()]=e.substring(t+1).trim())}),n},ue=(e,t,n)=>{const i=new FormData;return de(i,n),e.forEach(e=>{const n=e.getRawFile?e.getRawFile():"";n?i.append(t,n,e.name):i.append(t,n)}),i},pe=(e,t,n)=>{const i=new FormData;return de(i,n),e.forEach(e=>{i.append(t,e)}),i},he=(e,t)=>({headers:e,responseType:t.responseType,withCredentials:t.withCredentials}),me=e=>{const t={};return Object.keys(e).forEach(n=>{t[n]=e[n]}),t},fe=e=>({response:e.response,status:e.status,statusText:e.statusText,headers:e.request?ce(e.request):e.headers||{},request:e.request}),ge="invalidMaxFileSize",ve="invalidMinFileSize",ye="invalidFileExtension",be=(e,t)=>{t.length>0&&t.indexOf((e.extension||"").toLowerCase())<0&&(e.validationErrors=e.validationErrors||[],e.validationErrors.indexOf(ye)<0&&e.validationErrors.push(ye))},Fe=(e,t,n)=>{0!==t&&(e.size||0)<t&&(e.validationErrors=e.validationErrors||[],e.validationErrors.indexOf(ve)<0&&e.validationErrors.push(ve)),0!==n&&(e.size||0)>n&&(e.validationErrors=e.validationErrors||[],e.validationErrors.indexOf(ge)<0&&e.validationErrors.push(ge))},xe=(e,t,n)=>{const i=(e=>e.map(e=>("."===e.substring(0,1)?e:"."+e).toLowerCase()))(t.allowedExtensions||[]),o=t.maxFileSize||0,s=t.minFileSize||0;let a;for(a=0;a<e.length;a++)be(e[a],i),Fe(e[a],s,o),n&&n(e[a])},Se={name:"@progress/kendo-vue-upload",productName:"Kendo UI for Vue",productCode:"KENDOUIVUE",productCodes:["KENDOUIVUE"],publishDate:1619764257,version:"8.4.0-develop.2",licensingDocsUrl:"https://www.telerik.com/kendo-vue-ui/my-license/?utm_medium=product&utm_source=kendovue&utm_campaign=kendo-ui-vue-purchase-license-keys-warning"},ke=t.defineComponent({name:"KendoVueUpload",props:{autoUpload:{type:Boolean,default:!0},batch:{type:Boolean,default:!1},withCredentials:{type:Boolean,default:!0},saveField:{type:String,default:function(){return"files"}},saveHeaders:{type:[String,Function,Object],default:function(){return{}}},saveMethod:{type:String,default:function(){return"POST"}},saveUrl:{type:[String,Function],default:function(){return""}},responseType:{type:String,default:function(){return"json"}},removeField:{type:String,default:function(){return"fileNames"}},removeHeaders:{type:[String,Function,Object],default:function(){return{}}},removeMethod:{type:String,default:function(){return"POST"}},removeUrl:{type:[String,Function],default:function(){return""}},multiple:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},showFileList:{type:Boolean,default:!0},showActionButtons:{type:Boolean,default:!0},actionsLayout:{type:String,default:function(){return"end"}},tabIndex:Number,accept:String,list:[String,Function,Object],restrictions:{type:Object,default:function(){return{allowedExtensions:[],maxFileSize:0,minFileSize:0}}},validateFile:Function,files:Array,defaultFiles:Array},emits:{add:null,beforeremove:null,beforeupload:null,cancel:null,statuschange:null,progress:null,remove:null},created(){this._httpSubscriptions={},n.validatePackage(Se),this.$props.defaultFiles&&(this.currentFiles=this.$props.defaultFiles)},data:()=>({currentFiles:[]}),computed:{computedAsync(){const{autoUpload:e,batch:t,removeField:n,removeHeaders:i,removeMethod:o,removeUrl:s,responseType:a,saveField:l,saveHeaders:r,saveMethod:d,saveUrl:c,withCredentials:u}=this.$props;return{autoUpload:e,batch:t,removeField:n,removeHeaders:i,removeMethod:o,removeUrl:s,responseType:a,saveField:l,saveHeaders:r,saveMethod:d,saveUrl:c,withCredentials:u}},computedFiles(){return(this.isControlled?this.$props.files:this.currentFiles)||[]},isControlled(){return!this.$props.defaultFiles},isCustomSave(){return this.$props.saveUrl&&"function"==typeof this.$props.saveUrl},isCustomRemove(){return this.$props.removeUrl&&"function"==typeof this.$props.removeUrl},fileStateCopy(){return re.copyState(this.computedFiles)},actionElement(){if(this._uploadNavigation)return this._uploadNavigation.actionElement}},mounted(){this._uploadNavigation=this.uploadNavigationRef},methods:{focus(){this._uploadNavigation&&this._uploadNavigation.focus()},uploadFiles(e){const t=this.computedAsync;re.setFilesStatus(e,l.Uploading),re.groupForEach(e,(e,n)=>{var i;const o={target:this,files:e,headers:me(t.saveHeaders||{}),additionalData:{}};this.$emit("beforeupload",o);const s=he(o.headers,this.computedAsync),a=ue(e,t.saveField,o.additionalData);if(this.isCustomSave)this.$props.saveUrl(e,{formData:a,requestOptions:s},this.onUploadProgress).then(e=>this.onUploadSuccess(e.uid)).catch(e=>this.onUploadError(e.uid));else{const e=new XMLHttpRequest;this._httpSubscriptions[n]=()=>e.abort(),e.open(t.saveMethod,t.saveUrl,!0),e.withCredentials=null==(i=s.withCredentials)||i,e.responseType=s.responseType||"json",Object.entries(s.headers||{}).forEach(([t,n])=>{e.setRequestHeader(t,n)}),e.upload.onprogress=e=>this.onUploadProgress(n,e),e.onload=()=>{e.status>=200&&e.status<300?this.onUploadSuccess(n,{response:e.response,status:e.status,statusText:e.statusText,request:e}):this.onUploadError(n,{response:e.response,status:e.status,statusText:e.statusText,request:e})},e.onerror=()=>this.onUploadError(n,{response:e.response,status:e.status,statusText:e.statusText,request:e}),e.onabort=()=>{},e.send(a)}})},removeFiles(e){const t=this.computedAsync;re.groupForEach(e,(e,n)=>{var i;const o={target:this,files:e,headers:me(t.removeHeaders||{}),additionalData:{}};this.$emit("beforeremove",o);const s=e.map(e=>e.name),a=he(o.headers,this.computedAsync),l=pe(s,t.removeField,o.additionalData);if(this.isCustomRemove)this.$props.removeUrl(e,{formData:l,requestOptions:a}).then(e=>this.onRemoveSuccess(e.uid)).catch(e=>this.onRemoveError(e.uid));else{const e=new XMLHttpRequest;e.open(t.removeMethod,t.removeUrl,!0),e.withCredentials=null==(i=a.withCredentials)||i,e.responseType=a.responseType||"json",Object.entries(a.headers||{}).forEach(([t,n])=>{e.setRequestHeader(t,n)}),e.onload=()=>{e.status>=200&&e.status<300?this.onRemoveSuccess(n,{response:e.response,status:e.status,statusText:e.statusText,request:e}):this.onRemoveError(n,{response:e.response,status:e.status,statusText:e.statusText,request:e})},e.onerror=()=>this.onRemoveError(n,{response:e.response,status:e.status,statusText:e.statusText,request:e}),e.send(l)}})},onUpload(){const e=this.fileStateCopy,t=re.groupFilesByUid(e),n=re.filesForUpload(t);this.uploadFiles(n);this.isControlled||(this.currentFiles=e),(()=>{const t={target:this,newState:e,affectedFiles:re.flatFileGroup(n)};this.$emit("statuschange",t)})()},onAdd(e){let t,n=_.getAllFileInfo(e);if(n=_.assignGuidToFiles(n,this.computedAsync.batch),xe(n,this.$props.restrictions,this.validateFile),t=this.$props.multiple?this.fileStateCopy:[],re.addMany(n,t),this.computedAsync.autoUpload){const e=re.groupFilesByUid(t);this.uploadFiles(re.filesForUpload(e))}this.isControlled||(this.currentFiles=t),(()=>{const e={target:this,newState:t,affectedFiles:n};this.$emit("add",e)})()},onUploadProgress(e,t){const n=t.total?Math.round(100*t.loaded/t.total):0,i=this.fileStateCopy,o=i.filter(t=>t.uid===e);if(!o.length)return;o.forEach(e=>{e.progress=n});this.isControlled||(this.currentFiles=i),(()=>{const e={target:this,newState:i,affectedFiles:o};this.$emit("progress",e)})()},onUploadSuccess(e,t){const n=this.fileStateCopy,i=n.filter(t=>t.uid===e);i.forEach(e=>{e.status=l.Uploaded,e.progress=100}),delete this._httpSubscriptions[e];this.isControlled||(this.currentFiles=n),(()=>{const e={target:this,newState:n,affectedFiles:i,response:t?fe(t):void 0};this.$emit("statuschange",e)})()},onUploadError(e,t){const n=this.fileStateCopy,i=n.filter(t=>t.uid===e);if(i.forEach(e=>{e.status=l.UploadFailed}),delete this._httpSubscriptions[e],!i.length)return;this.isControlled||(this.currentFiles=n),(()=>{const e={target:this,newState:n,affectedFiles:i,response:t?fe(t):void 0};this.$emit("statuschange",e)})()},onRemove(e){const t=this.fileStateCopy,n=t.filter(t=>t.uid===e),i=t.filter(t=>t.uid!==e),o=[l.Uploaded,l.Initial,l.RemoveFailed];if(n[0]&&o.indexOf(n[0].status)>-1){const i={[e]:n};re.setFilesStatus(i,l.Removing),this.removeFiles(i);const o=()=>{const e={target:this,newState:t,affectedFiles:n};this.$emit("statuschange",e)};this.isControlled||(this.currentFiles=t),o()}else{const e=()=>{const e={target:this,newState:i,affectedFiles:n};this.$emit("remove",e)};this.isControlled||(this.currentFiles=i),e()}},onRemoveSuccess(e,t){const n=this.fileStateCopy,i=n.filter(t=>t.uid===e),o=n.filter(t=>t.uid!==e);this.isControlled||(this.currentFiles=o),(()=>{const e={target:this,newState:o,affectedFiles:i,response:t?fe(t):void 0};this.$emit("remove",e)})()},onRemoveError(e,t){const n=this.fileStateCopy,i=n.filter(t=>t.uid===e);i.forEach(e=>{e.status=l.RemoveFailed});this.isControlled||(this.currentFiles=n),(()=>{const e={target:this,newState:n,affectedFiles:i,response:t?fe(t):void 0};this.$emit("statuschange",e)})()},onRetry(e){const t=this.fileStateCopy,n=re.groupFilesByUid(t.filter(t=>t.uid===e));re.setFilesStatus(n,l.Uploading),this.uploadFiles(n);this.isControlled||(this.currentFiles=t),(()=>{const e={target:this,newState:t,affectedFiles:re.flatFileGroup(n)};this.$emit("statuschange",e)})()},onCancel(e){const t=this.fileStateCopy,n=t.filter(t=>t.uid!==e),i=t.filter(t=>t.uid===e);this._httpSubscriptions[e]&&(this._httpSubscriptions[e](),delete this._httpSubscriptions[e]);const o={target:this,uid:e};this.$emit("cancel",o);this.isControlled||(this.currentFiles=t),(()=>{const e={target:this,newState:n,affectedFiles:i};this.$emit("remove",e)})()},onClear(){if(!this.computedFiles.length)return;Object.keys(this._httpSubscriptions).forEach(e=>{this._httpSubscriptions[e]()}),this._httpSubscriptions={};this.isControlled||(this.currentFiles=[]),(()=>{const e={target:this,newState:[],affectedFiles:this.fileStateCopy};this.$emit("remove",e)})()}},render(){const{showFileList:e,autoUpload:i,showActionButtons:o,actionsLayout:s,tabIndex:a,disabled:l,batch:r,withCredentials:d,saveField:c,saveHeaders:u,saveMethod:p,saveUrl:h,responseType:m,removeField:f,removeHeaders:g,removeMethod:v,removeUrl:y,multiple:b,accept:F,restrictions:x,files:S,defaultFiles:k}=this.$props,I=n.templateRendering.call(this,this.$props.list,n.getListeners.call(this)),C=re.groupFilesByUid(this.computedFiles),N=re.filesForUpload(C);return t.createVNode(se,{groupedFiles:C,className:this.$props.className,showFileList:e&&!!Object.keys(C).length,showActionButtons:o&&!i&&!!Object.keys(N).length,actionsLayout:s,disabled:l,onAdd:this.onAdd,onRemove:this.onRemove,onClear:this.onClear,onUpload:this.onUpload,onRetry:this.onRetry,onCancel:this.onCancel,tabIndex:n.getTabIndex(a,l),ref:e=>{this.uploadNavigationRef=e},multiple:b,accept:F,list:I,restrictions:x,files:S,defaultFiles:k,async:this.computedAsync},null)}}),Ie=t.defineComponent({name:"KendoVueExternalDropZone",props:{id:String,tabIndex:Number,innerStyle:Object,uploadRef:[String,Function,Object],disabled:Boolean,customHint:[String,Function,Object],customNote:[String,Function,Object]},inject:{kendoLocalizationService:{default:null}},created(){n.validatePackage(Se),this.elementInterval=null,this.elementActive=!1,this.lastElementDragOverRef=null},data:()=>({overDropZone:!1}),mounted(){this.externalDropZone=this.externalDropZoneRef},methods:{focus(){this.externalDropZone&&this.externalDropZone.focus&&this.externalDropZone.focus()},isDragOver:e=>(new Date).getTime()-(e||new Date).getTime()>100,handleOnDrop(e){e.preventDefault();let t=e.dataTransfer.files,n=this.$parent.$refs[this.$props.uploadRef];t.length>0&&!this.$props.disabled&&n&&n.onAdd&&(e.preventDefault(),n.onAdd(t))},handleOnElementDragEnter(){this.elementActive=!0;this.elementInterval=setInterval(()=>{this.isDragOver(this.lastElementDragOver)&&(this.overDropZone=!1,this.elementActive=!1,clearInterval(this.elementInterval),this.elementInterval=null,this.lastElementDragOver=null)},100)},handleOnElementDragOver(e){e.preventDefault(),this.lastElementDragOver=new Date,this.overDropZone=!0}},setup:()=>({externalDropZoneRef:t.ref(null),kendoLocalizationService:t.inject("kendoLocalizationService",{})}),render(){const{customNote:e,customHint:o}=this.$props,s=i.provideLocalizationService(this),l=s.toLanguageString(D,R[D]),r=s.toLanguageString($,R[$]),d=n.templateRendering.call(this,o,n.getListeners.call(this)),c=n.templateRendering.call(this,e,n.getListeners.call(this));let u;const p=t.createVNode("span",null,[l]);let h;u=n.getTemplate.call(this,{h:t.h,template:d,defaultRendering:p});const m=t.createVNode("span",null,[r]);return h=n.getTemplate.call(this,{h:t.h,template:c,defaultRendering:m}),t.createVNode("div",{ref:n.setRef(this,"externalDropZone"),id:this.$props.id,class:n.classNames("k-external-dropzone",{"k-external-dropzone-hover":this.overDropZone,"k-disabled":this.$props.disabled},this.$props.className),tabindex:n.getTabIndex(this.$props.tabIndex,this.$props.disabled,void 0),onDrop:this.handleOnDrop,onDragenter:this.handleOnElementDragEnter,onDragover:this.handleOnElementDragOver},[t.createVNode("div",{style:this.$props.innerStyle,class:"k-dropzone-inner"},[t.createVNode(n.Icon,{name:"upload",icon:a.uploadIcon,class:"k-dropzone-icon",size:"xxxlarge"},null),t.createVNode("span",{class:"k-dropzone-hint"},[u]),t.createVNode("span",{class:"k-dropzone-note"},[h])]),t.createVNode("div",{class:"k-upload"},null)])}});e.ExternalDropZone=Ie,e.Upload=ke,e.UploadFileStatus=l,e.UploadListActionButton=M,e.UploadListMultiItem=Z,e.UploadListSingleItem=K,e.UploadUI=ne,e.messages=R,e.utils=_});
|
package/package-metadata.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={name:"@progress/kendo-vue-upload",productName:"Kendo UI for Vue",productCode:"KENDOUIVUE",productCodes:["KENDOUIVUE"],publishDate:
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={name:"@progress/kendo-vue-upload",productName:"Kendo UI for Vue",productCode:"KENDOUIVUE",productCodes:["KENDOUIVUE"],publishDate: 1778759457,version:"8.4.0-develop.2",licensingDocsUrl:"https://www.telerik.com/kendo-vue-ui/my-license/?utm_medium=product&utm_source=kendovue&utm_campaign=kendo-ui-vue-purchase-license-keys-warning"};exports.packageMetadata=e;
|
package/package-metadata.mjs
CHANGED
|
@@ -10,8 +10,8 @@ const e = {
|
|
|
10
10
|
productName: "Kendo UI for Vue",
|
|
11
11
|
productCode: "KENDOUIVUE",
|
|
12
12
|
productCodes: ["KENDOUIVUE"],
|
|
13
|
-
publishDate:
|
|
14
|
-
version: "8.
|
|
13
|
+
publishDate: 1778759457,
|
|
14
|
+
version: "8.4.0-develop.2",
|
|
15
15
|
licensingDocsUrl: "https://www.telerik.com/kendo-vue-ui/my-license/?utm_medium=product&utm_source=kendovue&utm_campaign=kendo-ui-vue-purchase-license-keys-warning"
|
|
16
16
|
};
|
|
17
17
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-vue-upload",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.0-develop.2",
|
|
4
4
|
"description": "TODO",
|
|
5
5
|
"author": "Progress",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -25,12 +25,11 @@
|
|
|
25
25
|
"sideEffects": false,
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@progress/kendo-licensing": "^1.7.2",
|
|
28
|
-
"@progress/kendo-vue-buttons": "8.
|
|
29
|
-
"@progress/kendo-vue-common": "8.
|
|
30
|
-
"@progress/kendo-vue-intl": "8.
|
|
31
|
-
"@progress/kendo-vue-progressbars": "8.
|
|
28
|
+
"@progress/kendo-vue-buttons": "8.4.0-develop.2",
|
|
29
|
+
"@progress/kendo-vue-common": "8.4.0-develop.2",
|
|
30
|
+
"@progress/kendo-vue-intl": "8.4.0-develop.2",
|
|
31
|
+
"@progress/kendo-vue-progressbars": "8.4.0-develop.2",
|
|
32
32
|
"@progress/kendo-svg-icons": "^4.4.0",
|
|
33
|
-
"axios": "^1.16.0",
|
|
34
33
|
"vue": "^3.0.2"
|
|
35
34
|
},
|
|
36
35
|
"dependencies": {},
|
|
@@ -50,7 +49,7 @@
|
|
|
50
49
|
"package": {
|
|
51
50
|
"productName": "Kendo UI for Vue",
|
|
52
51
|
"productCode": "KENDOUIVUE",
|
|
53
|
-
"publishDate":
|
|
52
|
+
"publishDate": 1778759457,
|
|
54
53
|
"licensingDocsUrl": "https://www.telerik.com/kendo-vue-ui/my-license/?utm_medium=product&utm_source=kendovue&utm_campaign=kendo-ui-vue-purchase-license-keys-warning"
|
|
55
54
|
}
|
|
56
55
|
},
|
|
@@ -8,8 +8,14 @@
|
|
|
8
8
|
import { UploadFileInfo } from '../interfaces/UploadFileInfo';
|
|
9
9
|
import { UploadAsyncProps } from '../interfaces/UploadAsyncProps';
|
|
10
10
|
import { UploadHttpHeaders } from '../interfaces/UploadHttpHeaders';
|
|
11
|
-
import { AxiosResponse } from 'axios';
|
|
12
11
|
import { UploadResponse } from '../interfaces/UploadResponse';
|
|
12
|
+
export interface XHRResponseData {
|
|
13
|
+
response: any;
|
|
14
|
+
status: number;
|
|
15
|
+
statusText: string;
|
|
16
|
+
headers?: any;
|
|
17
|
+
request?: XMLHttpRequest;
|
|
18
|
+
}
|
|
13
19
|
/**
|
|
14
20
|
* @hidden
|
|
15
21
|
*/
|
|
@@ -19,6 +25,6 @@ declare const _default: {
|
|
|
19
25
|
populateRemoveFormData: (fileNames: string[], removeField: string, clientData: Object) => FormData;
|
|
20
26
|
populateRequestOptions: (headers: UploadHttpHeaders, async: UploadAsyncProps) => any;
|
|
21
27
|
cloneRequestHeaders: (headers: UploadHttpHeaders) => UploadHttpHeaders;
|
|
22
|
-
|
|
28
|
+
convertResponse: (event: XHRResponseData) => UploadResponse;
|
|
23
29
|
};
|
|
24
30
|
export default _default;
|
package/utils/connectionUtils.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";const
|
|
8
|
+
"use strict";const n=(t,e)=>{Object.keys(e).forEach(s=>{t.append(s,e[s])})},p=(t,e,s)=>{const r=new FormData;return n(r,s),t.forEach(o=>{const a=o.getRawFile?o.getRawFile():"";a?r.append(e,a,o.name):r.append(e,a)}),r},c=(t,e,s)=>{const r=new FormData;return n(r,s),t.forEach(o=>{r.append(e,o)}),r},u=(t,e)=>({headers:t,responseType:e.responseType,withCredentials:e.withCredentials}),i=t=>{const e={};return Object.keys(t).forEach(s=>{e[s]=t[s]}),e},d=t=>{const e=t.getAllResponseHeaders(),s={};return e&&e.trim().split(/[\r\n]+/).forEach(r=>{const o=r.indexOf(":");o>0&&(s[r.substring(0,o).trim().toLowerCase()]=r.substring(o+1).trim())}),s},l=t=>({response:t.response,status:t.status,statusText:t.statusText,headers:t.request?d(t.request):t.headers||{},request:t.request}),m={populateClientFormData:n,populateUploadFormData:p,populateRemoveFormData:c,populateRequestOptions:u,cloneRequestHeaders:i,convertResponse:l};module.exports=m;
|
|
@@ -5,44 +5,50 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
const
|
|
9
|
-
Object.keys(
|
|
10
|
-
|
|
8
|
+
const n = (e, t) => {
|
|
9
|
+
Object.keys(t).forEach((s) => {
|
|
10
|
+
e.append(s, t[s]);
|
|
11
11
|
});
|
|
12
|
-
}, p = (
|
|
13
|
-
const
|
|
14
|
-
return r
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
}),
|
|
18
|
-
}, c = (
|
|
19
|
-
const
|
|
20
|
-
return r
|
|
21
|
-
|
|
22
|
-
}),
|
|
23
|
-
},
|
|
24
|
-
headers:
|
|
25
|
-
responseType:
|
|
26
|
-
withCredentials:
|
|
27
|
-
}),
|
|
28
|
-
const
|
|
29
|
-
return Object.keys(
|
|
30
|
-
|
|
31
|
-
}),
|
|
32
|
-
},
|
|
33
|
-
const
|
|
34
|
-
return {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
|
|
12
|
+
}, p = (e, t, s) => {
|
|
13
|
+
const r = new FormData();
|
|
14
|
+
return n(r, s), e.forEach((o) => {
|
|
15
|
+
const a = o.getRawFile ? o.getRawFile() : "";
|
|
16
|
+
a ? r.append(t, a, o.name) : r.append(t, a);
|
|
17
|
+
}), r;
|
|
18
|
+
}, c = (e, t, s) => {
|
|
19
|
+
const r = new FormData();
|
|
20
|
+
return n(r, s), e.forEach((o) => {
|
|
21
|
+
r.append(t, o);
|
|
22
|
+
}), r;
|
|
23
|
+
}, u = (e, t) => ({
|
|
24
|
+
headers: e,
|
|
25
|
+
responseType: t.responseType,
|
|
26
|
+
withCredentials: t.withCredentials
|
|
27
|
+
}), d = (e) => {
|
|
28
|
+
const t = {};
|
|
29
|
+
return Object.keys(e).forEach((s) => {
|
|
30
|
+
t[s] = e[s];
|
|
31
|
+
}), t;
|
|
32
|
+
}, i = (e) => {
|
|
33
|
+
const t = e.getAllResponseHeaders(), s = {};
|
|
34
|
+
return t && t.trim().split(/[\r\n]+/).forEach((r) => {
|
|
35
|
+
const o = r.indexOf(":");
|
|
36
|
+
o > 0 && (s[r.substring(0, o).trim().toLowerCase()] = r.substring(o + 1).trim());
|
|
37
|
+
}), s;
|
|
38
|
+
}, l = (e) => ({
|
|
39
|
+
response: e.response,
|
|
40
|
+
status: e.status,
|
|
41
|
+
statusText: e.statusText,
|
|
42
|
+
headers: e.request ? i(e.request) : e.headers || {},
|
|
43
|
+
request: e.request
|
|
44
|
+
}), m = {
|
|
45
|
+
populateClientFormData: n,
|
|
40
46
|
populateUploadFormData: p,
|
|
41
47
|
populateRemoveFormData: c,
|
|
42
|
-
populateRequestOptions:
|
|
43
|
-
cloneRequestHeaders:
|
|
44
|
-
|
|
48
|
+
populateRequestOptions: u,
|
|
49
|
+
cloneRequestHeaders: d,
|
|
50
|
+
convertResponse: l
|
|
45
51
|
};
|
|
46
52
|
export {
|
|
47
|
-
|
|
53
|
+
m as default
|
|
48
54
|
};
|