dap-design-system 0.61.6 → 0.61.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/file-input/file-input.component.d.ts +29 -1
- package/dist/components/file-input/file-input.component.js +226 -173
- package/dist/components/file-input/file-input.component.js.map +1 -1
- package/dist/manifest/types/vue/index.d.ts +1245 -1245
- package/dist/manifest/vscode.html-custom-data.json +664 -664
- package/dist/manifest/web-types.json +2383 -2383
- package/dist/react/index.d.ts +47 -47
- package/dist/react-types.ts +48 -48
- package/dist/react.js +264 -264
- package/package.json +1 -1
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
var
|
|
1
|
+
var B = Object.defineProperty, P = Object.defineProperties;
|
|
2
2
|
var U = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var E = Object.getOwnPropertySymbols;
|
|
4
4
|
var I = Object.prototype.hasOwnProperty, R = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var k = (
|
|
5
|
+
var k = (u, e, t) => e in u ? B(u, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : u[e] = t, w = (u, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
I.call(e, t) && k(
|
|
7
|
+
I.call(e, t) && k(u, t, e[t]);
|
|
8
8
|
if (E)
|
|
9
9
|
for (var t of E(e))
|
|
10
|
-
R.call(e, t) && k(
|
|
11
|
-
return
|
|
12
|
-
}, L = (
|
|
13
|
-
var
|
|
14
|
-
var
|
|
10
|
+
R.call(e, t) && k(u, t, e[t]);
|
|
11
|
+
return u;
|
|
12
|
+
}, L = (u, e) => P(u, U(e));
|
|
13
|
+
var F = (u, e, t) => new Promise((i, s) => {
|
|
14
|
+
var l = (h) => {
|
|
15
15
|
try {
|
|
16
|
-
|
|
17
|
-
} catch (
|
|
18
|
-
s(
|
|
16
|
+
d(t.next(h));
|
|
17
|
+
} catch (c) {
|
|
18
|
+
s(c);
|
|
19
19
|
}
|
|
20
20
|
}, r = (h) => {
|
|
21
21
|
try {
|
|
22
|
-
|
|
23
|
-
} catch (
|
|
24
|
-
s(
|
|
22
|
+
d(t.throw(h));
|
|
23
|
+
} catch (c) {
|
|
24
|
+
s(c);
|
|
25
25
|
}
|
|
26
|
-
},
|
|
27
|
-
|
|
26
|
+
}, d = (h) => h.done ? i(h.value) : Promise.resolve(h.value).then(l, r);
|
|
27
|
+
d((t = t.apply(u, e)).next());
|
|
28
28
|
});
|
|
29
29
|
import { clsx as D } from "../../node_modules/clsx/dist/clsx.js";
|
|
30
30
|
import "../../node_modules/@lit/reactive-element/reactive-element.js";
|
|
31
31
|
import { nothing as y, html as m } from "../../node_modules/lit-html/lit-html.js";
|
|
32
32
|
import "../../node_modules/lit-element/lit-element.js";
|
|
33
|
-
import { property as
|
|
33
|
+
import { property as n } from "../../node_modules/@lit/reactive-element/decorators/property.js";
|
|
34
34
|
import { state as v } from "../../node_modules/@lit/reactive-element/decorators/state.js";
|
|
35
35
|
import { query as O } from "../../node_modules/@lit/reactive-element/decorators/query.js";
|
|
36
36
|
import { ifDefined as b } from "../../node_modules/lit-html/directives/if-defined.js";
|
|
37
|
-
import { HttpError as S, FileError as
|
|
37
|
+
import { HttpError as S, FileError as $ } from "../../common/errors.js";
|
|
38
38
|
import { GenericFormElement as H } from "../../internal/mixin/genericFormElement.js";
|
|
39
39
|
import "../../localization/localization.js";
|
|
40
40
|
import q from "../button/button.component.js";
|
|
41
41
|
import M from "../feedback/feedback.component.js";
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
-
import
|
|
42
|
+
import N from "../form/form-label/form-label.component.js";
|
|
43
|
+
import V from "../icon/icon.component.js";
|
|
44
|
+
import j from "../icon-button/icon-button.component.js";
|
|
45
45
|
import A from "../modal/modal.component.js";
|
|
46
46
|
import J from "../tooltip/tooltip.component.js";
|
|
47
47
|
import W from "../typography/typography.component.js";
|
|
48
48
|
import K from "./file-input.scss.js";
|
|
49
|
-
import
|
|
49
|
+
import C, { t as T } from "../../node_modules/i18next/dist/esm/i18next.js";
|
|
50
50
|
import { unsafeCSS as X, css as G } from "../../node_modules/@lit/reactive-element/css-tag.js";
|
|
51
51
|
import { translate as g } from "../../node_modules/lit-i18n/src/lit-i18n.js";
|
|
52
|
-
var Q = Object.defineProperty, Y = Object.getOwnPropertyDescriptor, a = (
|
|
53
|
-
for (var s = i > 1 ? void 0 : i ? Y(e, t) : e,
|
|
54
|
-
(r =
|
|
52
|
+
var Q = Object.defineProperty, Y = Object.getOwnPropertyDescriptor, a = (u, e, t, i) => {
|
|
53
|
+
for (var s = i > 1 ? void 0 : i ? Y(e, t) : e, l = u.length - 1, r; l >= 0; l--)
|
|
54
|
+
(r = u[l]) && (s = (i ? r(e, t, s) : r(s)) || s);
|
|
55
55
|
return i && s && Q(e, t, s), s;
|
|
56
56
|
};
|
|
57
57
|
const z = class z extends H {
|
|
@@ -88,48 +88,48 @@ const z = class z extends H {
|
|
|
88
88
|
* Validates a file list against all constraints (count, size, type)
|
|
89
89
|
*/
|
|
90
90
|
validateFiles(e) {
|
|
91
|
-
const t = [];
|
|
92
|
-
if (this.maxFiles && e.length +
|
|
93
|
-
for (const
|
|
91
|
+
const t = [], i = this.keepValue ? this._files.length : 0;
|
|
92
|
+
if (this.maxFiles && e.length + i > this.maxFiles)
|
|
93
|
+
for (const l of e)
|
|
94
94
|
t.push({
|
|
95
|
-
file:
|
|
95
|
+
file: l,
|
|
96
96
|
meta: {
|
|
97
97
|
maxFiles: this.maxFiles,
|
|
98
|
-
totalFiles: e.length +
|
|
98
|
+
totalFiles: e.length + i
|
|
99
99
|
},
|
|
100
100
|
message: this.maxFileAmountErrorText || T("fileInput.error.fileAmount", {
|
|
101
101
|
count: this.maxFiles
|
|
102
102
|
}),
|
|
103
103
|
type: "maxFiles"
|
|
104
104
|
});
|
|
105
|
-
let
|
|
106
|
-
for (const
|
|
107
|
-
this.validateFileType(
|
|
108
|
-
file:
|
|
105
|
+
let s = 0;
|
|
106
|
+
for (const l of e)
|
|
107
|
+
this.validateFileType(l) || t.push({
|
|
108
|
+
file: l,
|
|
109
109
|
meta: {
|
|
110
110
|
type: this.accept,
|
|
111
|
-
fileType:
|
|
111
|
+
fileType: l.type
|
|
112
112
|
},
|
|
113
113
|
message: this.fileTypeErrorText || T("fileInput.error.fileType", {
|
|
114
114
|
type: this.accept
|
|
115
115
|
}),
|
|
116
116
|
type: "fileType"
|
|
117
|
-
}), this.maxSizePerFile &&
|
|
118
|
-
file:
|
|
117
|
+
}), this.maxSizePerFile && l.size > this.maxSizePerFile && t.push({
|
|
118
|
+
file: l,
|
|
119
119
|
meta: {
|
|
120
120
|
maxSizePerFile: this.maxSizePerFile,
|
|
121
|
-
fileSize:
|
|
121
|
+
fileSize: l.size
|
|
122
122
|
},
|
|
123
123
|
message: this.maxSizePerFileErrorText || T("fileInput.error.perFileSize", {
|
|
124
124
|
size: Math.round(this.maxSizePerFile / 1024 / 1024)
|
|
125
125
|
}),
|
|
126
126
|
type: "maxSizePerFile"
|
|
127
|
-
}),
|
|
128
|
-
file:
|
|
127
|
+
}), s += l.size, this.maxFileSize && s > this.maxFileSize && t.push({
|
|
128
|
+
file: l,
|
|
129
129
|
meta: {
|
|
130
130
|
maxFileSize: this.maxFileSize,
|
|
131
|
-
totalSize:
|
|
132
|
-
fileSize:
|
|
131
|
+
totalSize: s,
|
|
132
|
+
fileSize: l.size
|
|
133
133
|
},
|
|
134
134
|
message: this.maxFileSizeErrorText || T("fileInput.error.fileSize", {
|
|
135
135
|
size: Math.round(this.maxFileSize / 1024 / 1024)
|
|
@@ -141,14 +141,52 @@ const z = class z extends H {
|
|
|
141
141
|
errors: t.length > 0 ? t : void 0
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
/**
|
|
145
|
+
* Removes a single file from the file input and frees up a slot in the
|
|
146
|
+
* `maxFiles` budget.
|
|
147
|
+
*
|
|
148
|
+
* @param fileData The file to remove. It is matched against the selected files
|
|
149
|
+
* by name, size, type and lastModified, so a structurally equal file also works.
|
|
150
|
+
* @param options.skipConfirm Skips the built-in confirmation dialog for this
|
|
151
|
+
* call only, without having to change the `confirmRemove` property. Useful when
|
|
152
|
+
* the host application renders its own file list and already confirmed removal.
|
|
153
|
+
*/
|
|
154
|
+
removeFile(e, t) {
|
|
155
|
+
return this.confirmRemove && !(t != null && t.skipConfirm) ? new Promise((i, s) => {
|
|
156
|
+
this._removeResolve = i, this._removeReject = s, this._showRemoveDialog = !0, this._fileToRemove = e;
|
|
147
157
|
}).then(() => this.performFileRemoval(e)).catch(() => {
|
|
148
158
|
}) : this.performFileRemoval(e);
|
|
149
159
|
}
|
|
150
|
-
|
|
151
|
-
|
|
160
|
+
/**
|
|
161
|
+
* Removes every selected file, so the whole `maxFiles` budget becomes
|
|
162
|
+
* available again.
|
|
163
|
+
*
|
|
164
|
+
* This is a programmatic API, so it never shows the confirmation dialog.
|
|
165
|
+
* Files already uploaded are deleted from the server when `deleteUrl` is set,
|
|
166
|
+
* and in-flight uploads are aborted.
|
|
167
|
+
*/
|
|
168
|
+
clearFiles() {
|
|
169
|
+
return F(this, null, function* () {
|
|
170
|
+
const e = [...this._files];
|
|
171
|
+
if (e.length !== 0) {
|
|
172
|
+
this.abortAllUploads();
|
|
173
|
+
for (const t of e)
|
|
174
|
+
yield this.deleteUploadedFileFromServer(t);
|
|
175
|
+
this._files = [], this.value = void 0, this.syncNativeInput(), e.forEach((t) => this.emit("dds-file-removed", { file: t })), this.emit("dds-file-change", {
|
|
176
|
+
newFiles: [],
|
|
177
|
+
files: this._files,
|
|
178
|
+
canceledFiles: /* @__PURE__ */ new Set(),
|
|
179
|
+
currentFiles: this._files
|
|
180
|
+
}), this.setValidity(), this.emit("dds-files-accepted", { files: this._files });
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Deletes an already uploaded file from the server when a deleteUrl is set.
|
|
186
|
+
* Delete failures are reported but never block the local removal.
|
|
187
|
+
*/
|
|
188
|
+
deleteUploadedFileFromServer(e) {
|
|
189
|
+
return F(this, null, function* () {
|
|
152
190
|
const t = e.name;
|
|
153
191
|
if (this._uploadedFiles.has(t))
|
|
154
192
|
try {
|
|
@@ -157,9 +195,24 @@ const z = class z extends H {
|
|
|
157
195
|
} catch (i) {
|
|
158
196
|
this.emit("dds-file-delete-error", { file: e, error: i });
|
|
159
197
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
/** Keeps the native input element in sync with the current file list */
|
|
201
|
+
syncNativeInput() {
|
|
202
|
+
if (!this.input) return;
|
|
203
|
+
if (this._files.length === 0) {
|
|
204
|
+
this.input.value = "";
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (typeof DataTransfer == "undefined") return;
|
|
208
|
+
const e = new DataTransfer();
|
|
209
|
+
this._files.forEach((t) => e.items.add(t)), this.input.files = e.files;
|
|
210
|
+
}
|
|
211
|
+
performFileRemoval(e) {
|
|
212
|
+
return F(this, null, function* () {
|
|
213
|
+
this.abortUpload(e.name), yield this.deleteUploadedFileFromServer(e), this._files = this._files.filter(
|
|
214
|
+
(t) => !this.checkFileEquality(t, e)
|
|
215
|
+
), this.syncNativeInput(), this._files.length === 0 && this.required && (this.value = void 0), this.emit("dds-file-removed", { file: e }), this.emit("dds-file-change", {
|
|
163
216
|
newFiles: [],
|
|
164
217
|
files: this._files,
|
|
165
218
|
canceledFiles: /* @__PURE__ */ new Set(),
|
|
@@ -168,16 +221,16 @@ const z = class z extends H {
|
|
|
168
221
|
});
|
|
169
222
|
}
|
|
170
223
|
connectedCallback() {
|
|
171
|
-
super.connectedCallback(),
|
|
224
|
+
super.connectedCallback(), C.on("languageChanged", this.languageChangeHandler), this.addEventListener("dds-file-remove", (e) => {
|
|
172
225
|
const t = e;
|
|
173
226
|
this.removeFile(t.detail.file);
|
|
174
227
|
});
|
|
175
228
|
}
|
|
176
229
|
disconnectedCallback() {
|
|
177
|
-
super.disconnectedCallback(),
|
|
230
|
+
super.disconnectedCallback(), C.off("languageChanged", this.languageChangeHandler);
|
|
178
231
|
}
|
|
179
232
|
onConfirmDelete() {
|
|
180
|
-
return
|
|
233
|
+
return F(this, null, function* () {
|
|
181
234
|
this._removeResolve && this._removeResolve(!0), this._showRemoveDialog = !1, this._fileToRemove = null, this._removeResolve = null, this._removeReject = null;
|
|
182
235
|
});
|
|
183
236
|
}
|
|
@@ -208,7 +261,7 @@ const z = class z extends H {
|
|
|
208
261
|
const t = this._activeUploads.get(e);
|
|
209
262
|
if (t) {
|
|
210
263
|
t.abort(), this._uploadingFiles.delete(e), this._activeUploads.delete(e);
|
|
211
|
-
const i =
|
|
264
|
+
const i = w({}, this._uploadProgress);
|
|
212
265
|
delete i[e], this._uploadProgress = i;
|
|
213
266
|
}
|
|
214
267
|
}
|
|
@@ -230,15 +283,15 @@ const z = class z extends H {
|
|
|
230
283
|
* Delete an uploaded file from the server
|
|
231
284
|
*/
|
|
232
285
|
deleteUploadedFile(e, t) {
|
|
233
|
-
return
|
|
286
|
+
return F(this, null, function* () {
|
|
234
287
|
if (!this.deleteUrl) {
|
|
235
288
|
console.error("Delete URL is not configured");
|
|
236
289
|
return;
|
|
237
290
|
}
|
|
238
291
|
const i = new XMLHttpRequest();
|
|
239
|
-
return i.withCredentials = this.withCredentials, new Promise((s,
|
|
292
|
+
return i.withCredentials = this.withCredentials, new Promise((s, l) => {
|
|
240
293
|
i.onload = () => {
|
|
241
|
-
i.status >= 200 && i.status < 300 ? s() :
|
|
294
|
+
i.status >= 200 && i.status < 300 ? s() : l(
|
|
242
295
|
new S(
|
|
243
296
|
`HTTP error! status: ${i.status}`,
|
|
244
297
|
i.response,
|
|
@@ -246,7 +299,7 @@ const z = class z extends H {
|
|
|
246
299
|
)
|
|
247
300
|
);
|
|
248
301
|
}, i.onerror = () => {
|
|
249
|
-
|
|
302
|
+
l(new Error("Network error during file deletion"));
|
|
250
303
|
};
|
|
251
304
|
let r = this.deleteUrl;
|
|
252
305
|
if (r = r.replace(
|
|
@@ -266,11 +319,11 @@ const z = class z extends H {
|
|
|
266
319
|
encodeURIComponent(t.location)
|
|
267
320
|
))), i.open(this.deleteMethod, r), this.deleteHeaders)
|
|
268
321
|
try {
|
|
269
|
-
const
|
|
270
|
-
Object.entries(
|
|
271
|
-
i.setRequestHeader(h,
|
|
322
|
+
const d = JSON.parse(this.deleteHeaders);
|
|
323
|
+
Object.entries(d).forEach(([h, c]) => {
|
|
324
|
+
i.setRequestHeader(h, c);
|
|
272
325
|
});
|
|
273
|
-
} catch (
|
|
326
|
+
} catch (d) {
|
|
274
327
|
console.warn("Invalid deleteHeaders JSON:", this.deleteHeaders);
|
|
275
328
|
}
|
|
276
329
|
this.deleteMethod === "DELETE" ? t && (t.ETag || t.VersionId) ? (i.setRequestHeader("Content-Type", "application/json"), i.send(
|
|
@@ -283,7 +336,7 @@ const z = class z extends H {
|
|
|
283
336
|
});
|
|
284
337
|
}
|
|
285
338
|
uploadFiles(e) {
|
|
286
|
-
return
|
|
339
|
+
return F(this, null, function* () {
|
|
287
340
|
if (!this.uploadUrl) {
|
|
288
341
|
console.error("Upload URL is not configured");
|
|
289
342
|
return;
|
|
@@ -291,25 +344,25 @@ const z = class z extends H {
|
|
|
291
344
|
const t = e.length;
|
|
292
345
|
let i = 0;
|
|
293
346
|
for (const s of e) {
|
|
294
|
-
const
|
|
295
|
-
|
|
347
|
+
const l = new FormData();
|
|
348
|
+
l.append(this.uploadProperty, s);
|
|
296
349
|
try {
|
|
297
350
|
let r;
|
|
298
|
-
this._uploadingFiles.add(s.name), this._uploadProgress = L(
|
|
299
|
-
const
|
|
300
|
-
if (
|
|
351
|
+
this._uploadingFiles.add(s.name), this._uploadProgress = L(w({}, this._uploadProgress), { [s.name]: 0 }), this.emit("dds-upload-start", { file: s });
|
|
352
|
+
const d = new XMLHttpRequest();
|
|
353
|
+
if (d.withCredentials = this.withCredentials, this._activeUploads.set(s.name, d), d.open(this.uploadMethod, this.uploadUrl), this.uploadHeaders)
|
|
301
354
|
try {
|
|
302
355
|
const f = JSON.parse(this.uploadHeaders);
|
|
303
356
|
Object.entries(f).forEach(([_, x]) => {
|
|
304
|
-
|
|
357
|
+
d.setRequestHeader(_, x);
|
|
305
358
|
});
|
|
306
359
|
} catch (f) {
|
|
307
360
|
console.warn("Invalid uploadHeaders JSON:", this.uploadHeaders);
|
|
308
361
|
}
|
|
309
|
-
|
|
362
|
+
d.upload.onprogress = (f) => {
|
|
310
363
|
if (f.lengthComputable) {
|
|
311
364
|
const _ = f.loaded / f.total * 100;
|
|
312
|
-
this._uploadProgress = L(
|
|
365
|
+
this._uploadProgress = L(w({}, this._uploadProgress), {
|
|
313
366
|
[s.name]: _
|
|
314
367
|
}), this.fileList && (r = this.setFileLoadingState(s, !0)), this.emit("dds-upload-progress", {
|
|
315
368
|
file: s,
|
|
@@ -319,39 +372,39 @@ const z = class z extends H {
|
|
|
319
372
|
}
|
|
320
373
|
};
|
|
321
374
|
const h = yield new Promise((f, _) => {
|
|
322
|
-
|
|
323
|
-
if (
|
|
324
|
-
f(
|
|
375
|
+
d.onload = () => {
|
|
376
|
+
if (d.status >= 200 && d.status < 300)
|
|
377
|
+
f(d.response);
|
|
325
378
|
else {
|
|
326
379
|
const x = new S(
|
|
327
|
-
`HTTP error! status: ${
|
|
328
|
-
|
|
329
|
-
|
|
380
|
+
`HTTP error! status: ${d.status}`,
|
|
381
|
+
d.response,
|
|
382
|
+
d.status
|
|
330
383
|
);
|
|
331
384
|
_(x);
|
|
332
385
|
}
|
|
333
|
-
},
|
|
386
|
+
}, d.onerror = () => {
|
|
334
387
|
this.fileList && (r = this.setFileLoadingState(s, !1)), _(new Error("Network error"));
|
|
335
|
-
},
|
|
336
|
-
}),
|
|
388
|
+
}, d.send(l);
|
|
389
|
+
}), c = JSON.parse(h);
|
|
337
390
|
this.fileList && (r = this.setFileLoadingState(s, !1)), this._uploadingFiles.delete(s.name), this._activeUploads.delete(s.name);
|
|
338
|
-
const
|
|
339
|
-
delete
|
|
391
|
+
const p = w({}, this._uploadProgress);
|
|
392
|
+
delete p[s.name], this._uploadProgress = p, this._uploadedFiles.set(s.name, c), this.emit("dds-upload-complete", { file: s, item: r, result: c }), i++, i === t && this.emit("dds-all-uploads-complete");
|
|
340
393
|
} catch (r) {
|
|
341
394
|
this._uploadingFiles.delete(s.name), this._activeUploads.delete(s.name);
|
|
342
|
-
const
|
|
343
|
-
delete
|
|
344
|
-
const h = r instanceof
|
|
395
|
+
const d = w({}, this._uploadProgress);
|
|
396
|
+
delete d[s.name], this._uploadProgress = d;
|
|
397
|
+
const h = r instanceof $ ? r : new $(
|
|
345
398
|
r instanceof Error ? r.message : String(r),
|
|
346
399
|
s,
|
|
347
400
|
r instanceof S ? "http" : "upload",
|
|
348
401
|
r instanceof S ? { status: r.status, response: r.response } : void 0
|
|
349
402
|
);
|
|
350
403
|
if (this.fileList) {
|
|
351
|
-
const
|
|
404
|
+
const c = this.setFileLoadingState(s, !1);
|
|
352
405
|
this.emit("dds-upload-error", {
|
|
353
406
|
file: s,
|
|
354
|
-
item:
|
|
407
|
+
item: c,
|
|
355
408
|
errors: [h]
|
|
356
409
|
});
|
|
357
410
|
} else
|
|
@@ -378,14 +431,14 @@ const z = class z extends H {
|
|
|
378
431
|
handleFileList(e) {
|
|
379
432
|
var s;
|
|
380
433
|
const t = [...this._files];
|
|
381
|
-
this.keepValue && ((s = this._files) != null && s.length) ? (Object.values(e).forEach((
|
|
434
|
+
this.keepValue && ((s = this._files) != null && s.length) ? (Object.values(e).forEach((l) => {
|
|
382
435
|
!!this._files.find(
|
|
383
|
-
(
|
|
384
|
-
) || t.push(
|
|
436
|
+
(d) => this.checkFileEquality(d, l)
|
|
437
|
+
) || t.push(l);
|
|
385
438
|
}), this._files = t) : this._files = e ? Object.values(e) : [];
|
|
386
439
|
const i = new DataTransfer();
|
|
387
|
-
this._files.forEach((
|
|
388
|
-
i.items.add(
|
|
440
|
+
this._files.forEach((l) => {
|
|
441
|
+
i.items.add(l);
|
|
389
442
|
}), this.input.files = i.files, this.autoupload && this.uploadFiles(this._files);
|
|
390
443
|
}
|
|
391
444
|
onChange(e) {
|
|
@@ -397,32 +450,32 @@ const z = class z extends H {
|
|
|
397
450
|
if (i) {
|
|
398
451
|
const h = this.validateFiles(i);
|
|
399
452
|
if (!h.isValid && h.errors) {
|
|
400
|
-
const
|
|
401
|
-
if (
|
|
402
|
-
return new
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
453
|
+
const c = h.errors.map((p) => {
|
|
454
|
+
if (p.file)
|
|
455
|
+
return new $(
|
|
456
|
+
p.message,
|
|
457
|
+
p.file,
|
|
458
|
+
p.type,
|
|
459
|
+
p.meta
|
|
407
460
|
);
|
|
408
461
|
{
|
|
409
462
|
const f = i.length > 0 ? i[0] : new File([], "unknown");
|
|
410
|
-
return new
|
|
411
|
-
|
|
463
|
+
return new $(
|
|
464
|
+
p.message,
|
|
412
465
|
f,
|
|
413
|
-
|
|
414
|
-
|
|
466
|
+
p.type,
|
|
467
|
+
p.meta
|
|
415
468
|
);
|
|
416
469
|
}
|
|
417
470
|
});
|
|
418
|
-
this.emit("dds-upload-error", { errors:
|
|
471
|
+
this.emit("dds-upload-error", { errors: c });
|
|
419
472
|
return;
|
|
420
473
|
}
|
|
421
474
|
}
|
|
422
|
-
const s = i ? Array.from(i) : [],
|
|
475
|
+
const s = i ? Array.from(i) : [], l = this.calculateNewFileList(i), r = /* @__PURE__ */ new Set();
|
|
423
476
|
if (this.emit(
|
|
424
477
|
"dds-file-change",
|
|
425
|
-
{ newFiles: s, files:
|
|
478
|
+
{ newFiles: s, files: l, canceledFiles: r, currentFiles: this._files },
|
|
426
479
|
{ cancelable: !0 }
|
|
427
480
|
).defaultPrevented) {
|
|
428
481
|
this.input.value = "";
|
|
@@ -430,9 +483,9 @@ const z = class z extends H {
|
|
|
430
483
|
}
|
|
431
484
|
if (r.size > 0 && i) {
|
|
432
485
|
const h = Array.from(i).filter(
|
|
433
|
-
(
|
|
434
|
-
),
|
|
435
|
-
h.forEach((
|
|
486
|
+
(p) => !r.has(p)
|
|
487
|
+
), c = new DataTransfer();
|
|
488
|
+
h.forEach((p) => c.items.add(p)), this.value = this.input.value, this.handleFileList(c.files), this.setValidity(), this.emit("dds-files-accepted", { files: this._files });
|
|
436
489
|
} else
|
|
437
490
|
this.value = this.input.value, this.handleFileList(i), this.setValidity(), this.emit("dds-files-accepted", { files: this._files });
|
|
438
491
|
}
|
|
@@ -446,46 +499,46 @@ const z = class z extends H {
|
|
|
446
499
|
this.disabled || (e.preventDefault(), this.contains(e.relatedTarget) || (this._isDragOver = !1));
|
|
447
500
|
}
|
|
448
501
|
onDrop(e) {
|
|
449
|
-
var
|
|
502
|
+
var d;
|
|
450
503
|
if (this.disabled) return;
|
|
451
504
|
e.preventDefault(), this._isDragOver = !1;
|
|
452
|
-
const t = (
|
|
505
|
+
const t = (d = e.dataTransfer) == null ? void 0 : d.files;
|
|
453
506
|
if (t) {
|
|
454
507
|
const h = this.validateFiles(t);
|
|
455
508
|
if (!h.isValid && h.errors) {
|
|
456
|
-
const
|
|
457
|
-
if (
|
|
458
|
-
return new
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
509
|
+
const c = h.errors.map((p) => {
|
|
510
|
+
if (p.file)
|
|
511
|
+
return new $(
|
|
512
|
+
p.message,
|
|
513
|
+
p.file,
|
|
514
|
+
p.type,
|
|
515
|
+
p.meta
|
|
463
516
|
);
|
|
464
517
|
{
|
|
465
518
|
const f = t.length > 0 ? t[0] : new File([], "unknown");
|
|
466
|
-
return new
|
|
467
|
-
|
|
519
|
+
return new $(
|
|
520
|
+
p.message,
|
|
468
521
|
f,
|
|
469
|
-
|
|
470
|
-
|
|
522
|
+
p.type,
|
|
523
|
+
p.meta
|
|
471
524
|
);
|
|
472
525
|
}
|
|
473
526
|
});
|
|
474
|
-
this.emit("dds-upload-error", { errors:
|
|
527
|
+
this.emit("dds-upload-error", { errors: c });
|
|
475
528
|
return;
|
|
476
529
|
}
|
|
477
530
|
}
|
|
478
|
-
const i = t ? Array.from(t) : [], s = this.calculateNewFileList(t != null ? t : null),
|
|
531
|
+
const i = t ? Array.from(t) : [], s = this.calculateNewFileList(t != null ? t : null), l = /* @__PURE__ */ new Set();
|
|
479
532
|
if (!this.emit(
|
|
480
533
|
"dds-file-change",
|
|
481
|
-
{ newFiles: i, files: s, canceledFiles:
|
|
534
|
+
{ newFiles: i, files: s, canceledFiles: l, currentFiles: this._files },
|
|
482
535
|
{ cancelable: !0 }
|
|
483
536
|
).defaultPrevented)
|
|
484
|
-
if (
|
|
537
|
+
if (l.size > 0 && t) {
|
|
485
538
|
const h = Array.from(t).filter(
|
|
486
|
-
(
|
|
487
|
-
),
|
|
488
|
-
h.forEach((
|
|
539
|
+
(p) => !l.has(p)
|
|
540
|
+
), c = new DataTransfer();
|
|
541
|
+
h.forEach((p) => c.items.add(p)), this.handleFileList(c.files), this.setValidity(), this.emit("dds-files-accepted", { files: this._files });
|
|
489
542
|
} else
|
|
490
543
|
this.handleFileList(t != null ? t : null), this.setValidity(), this.emit("dds-files-accepted", { files: this._files });
|
|
491
544
|
}
|
|
@@ -638,12 +691,12 @@ const z = class z extends H {
|
|
|
638
691
|
</span>
|
|
639
692
|
${!this.fileList && this._uploadingFiles.size > 0 ? m`
|
|
640
693
|
<div class="upload-progress" part="upload-progress">
|
|
641
|
-
${Array.from(this._uploadingFiles).map((
|
|
642
|
-
const r = this._uploadProgress[
|
|
694
|
+
${Array.from(this._uploadingFiles).map((l) => {
|
|
695
|
+
const r = this._uploadProgress[l] || 0;
|
|
643
696
|
return m`
|
|
644
697
|
<div class="upload-progress__item">
|
|
645
698
|
<dap-ds-typography variant="caption">
|
|
646
|
-
${
|
|
699
|
+
${l} - ${Math.round(r)}%
|
|
647
700
|
</dap-ds-typography>
|
|
648
701
|
<div class="upload-progress__bar">
|
|
649
702
|
<div
|
|
@@ -687,10 +740,10 @@ const z = class z extends H {
|
|
|
687
740
|
}
|
|
688
741
|
};
|
|
689
742
|
z.tagName = "dap-ds-file-input", z.dependencies = {
|
|
690
|
-
"dap-ds-form-label":
|
|
743
|
+
"dap-ds-form-label": N,
|
|
691
744
|
"dap-ds-tooltip": J,
|
|
692
|
-
"dap-ds-icon-button":
|
|
693
|
-
"dap-ds-icon":
|
|
745
|
+
"dap-ds-icon-button": j,
|
|
746
|
+
"dap-ds-icon": V,
|
|
694
747
|
"dap-ds-typography": W,
|
|
695
748
|
"dap-ds-button": q,
|
|
696
749
|
"dap-ds-modal": A,
|
|
@@ -703,118 +756,118 @@ a([
|
|
|
703
756
|
O("#input")
|
|
704
757
|
], o.prototype, "input", 2);
|
|
705
758
|
a([
|
|
706
|
-
|
|
759
|
+
n()
|
|
707
760
|
], o.prototype, "uploadButtonLabel", 2);
|
|
708
761
|
a([
|
|
709
|
-
|
|
762
|
+
n()
|
|
710
763
|
], o.prototype, "browseButtonLabel", 2);
|
|
711
764
|
a([
|
|
712
|
-
|
|
765
|
+
n()
|
|
713
766
|
], o.prototype, "browseButtonTestId", 2);
|
|
714
767
|
a([
|
|
715
|
-
|
|
768
|
+
n()
|
|
716
769
|
], o.prototype, "uploadButtonTestId", 2);
|
|
717
770
|
a([
|
|
718
|
-
|
|
771
|
+
n({ type: Boolean })
|
|
719
772
|
], o.prototype, "showDropzone", 2);
|
|
720
773
|
a([
|
|
721
|
-
|
|
774
|
+
n()
|
|
722
775
|
], o.prototype, "dropzoneText", 2);
|
|
723
776
|
a([
|
|
724
|
-
|
|
777
|
+
n({ type: Boolean })
|
|
725
778
|
], o.prototype, "showFileList", 2);
|
|
726
779
|
a([
|
|
727
|
-
|
|
780
|
+
n({ type: Boolean })
|
|
728
781
|
], o.prototype, "confirmRemove", 2);
|
|
729
782
|
a([
|
|
730
|
-
|
|
783
|
+
n({ type: String })
|
|
731
784
|
], o.prototype, "showUploadButton", 2);
|
|
732
785
|
a([
|
|
733
|
-
|
|
786
|
+
n({ type: String })
|
|
734
787
|
], o.prototype, "showBrowseButton", 2);
|
|
735
788
|
a([
|
|
736
|
-
|
|
789
|
+
n()
|
|
737
790
|
], o.prototype, "accept", 2);
|
|
738
791
|
a([
|
|
739
|
-
|
|
792
|
+
n({ type: Boolean })
|
|
740
793
|
], o.prototype, "multiple", 2);
|
|
741
794
|
a([
|
|
742
|
-
|
|
795
|
+
n({ type: Boolean })
|
|
743
796
|
], o.prototype, "keepValue", 2);
|
|
744
797
|
a([
|
|
745
|
-
|
|
798
|
+
n()
|
|
746
799
|
], o.prototype, "uploadUrl", 2);
|
|
747
800
|
a([
|
|
748
|
-
|
|
801
|
+
n({ type: Boolean })
|
|
749
802
|
], o.prototype, "autoupload", 2);
|
|
750
803
|
a([
|
|
751
|
-
|
|
804
|
+
n()
|
|
752
805
|
], o.prototype, "uploadProperty", 2);
|
|
753
806
|
a([
|
|
754
|
-
|
|
807
|
+
n()
|
|
755
808
|
], o.prototype, "uploadMethod", 2);
|
|
756
809
|
a([
|
|
757
|
-
|
|
810
|
+
n()
|
|
758
811
|
], o.prototype, "deleteUrl", 2);
|
|
759
812
|
a([
|
|
760
|
-
|
|
813
|
+
n()
|
|
761
814
|
], o.prototype, "deleteMethod", 2);
|
|
762
815
|
a([
|
|
763
|
-
|
|
816
|
+
n({ type: Boolean })
|
|
764
817
|
], o.prototype, "withCredentials", 2);
|
|
765
818
|
a([
|
|
766
|
-
|
|
819
|
+
n()
|
|
767
820
|
], o.prototype, "uploadHeaders", 2);
|
|
768
821
|
a([
|
|
769
|
-
|
|
822
|
+
n()
|
|
770
823
|
], o.prototype, "deleteHeaders", 2);
|
|
771
824
|
a([
|
|
772
|
-
|
|
825
|
+
n({ attribute: !1 })
|
|
773
826
|
], o.prototype, "fileList", 2);
|
|
774
827
|
a([
|
|
775
|
-
|
|
828
|
+
n({ type: Number })
|
|
776
829
|
], o.prototype, "maxFiles", 2);
|
|
777
830
|
a([
|
|
778
|
-
|
|
831
|
+
n({ type: Number })
|
|
779
832
|
], o.prototype, "maxFileSize", 2);
|
|
780
833
|
a([
|
|
781
|
-
|
|
834
|
+
n({ type: Number })
|
|
782
835
|
], o.prototype, "maxSizePerFile", 2);
|
|
783
836
|
a([
|
|
784
|
-
|
|
837
|
+
n({ type: String })
|
|
785
838
|
], o.prototype, "maxFileSizeErrorText", 2);
|
|
786
839
|
a([
|
|
787
|
-
|
|
840
|
+
n({ type: String })
|
|
788
841
|
], o.prototype, "maxSizePerFileErrorText", 2);
|
|
789
842
|
a([
|
|
790
|
-
|
|
843
|
+
n({ type: String })
|
|
791
844
|
], o.prototype, "maxFileAmountErrorText", 2);
|
|
792
845
|
a([
|
|
793
|
-
|
|
846
|
+
n({ type: String })
|
|
794
847
|
], o.prototype, "fileTypeErrorText", 2);
|
|
795
848
|
a([
|
|
796
|
-
|
|
849
|
+
n()
|
|
797
850
|
], o.prototype, "removeButtonLabel", 2);
|
|
798
851
|
a([
|
|
799
|
-
|
|
852
|
+
n()
|
|
800
853
|
], o.prototype, "cancelButtonLabel", 2);
|
|
801
854
|
a([
|
|
802
|
-
|
|
855
|
+
n({ type: String })
|
|
803
856
|
], o.prototype, "removeButtonDanger", 2);
|
|
804
857
|
a([
|
|
805
|
-
|
|
858
|
+
n({ type: String })
|
|
806
859
|
], o.prototype, "showThumbnail", 2);
|
|
807
860
|
a([
|
|
808
|
-
|
|
861
|
+
n()
|
|
809
862
|
], o.prototype, "dropzoneAriaLabel", 2);
|
|
810
863
|
a([
|
|
811
|
-
|
|
864
|
+
n({ type: String })
|
|
812
865
|
], o.prototype, "dropzoneFocusable", 2);
|
|
813
866
|
a([
|
|
814
|
-
|
|
867
|
+
n({ type: String })
|
|
815
868
|
], o.prototype, "thumbnailSize", 2);
|
|
816
869
|
a([
|
|
817
|
-
|
|
870
|
+
n({ type: Array, attribute: !1 })
|
|
818
871
|
], o.prototype, "files", 1);
|
|
819
872
|
a([
|
|
820
873
|
v()
|