huply 0.0.7 → 0.0.11

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/huply.es.js CHANGED
@@ -41,7 +41,9 @@ class HttpRequestService {
41
41
  }
42
42
  request(method, url) {
43
43
  let request = new XMLHttpRequest();
44
- request.withCredentials = true;
44
+ if (this.store.options.withCredentials) {
45
+ request.withCredentials = this.store.options.withCredentials;
46
+ }
45
47
  request.open(method, url);
46
48
  if (isObject(this.store.options.headers)) {
47
49
  Object.entries(this.store.options.headers).forEach((item) => {
@@ -74,12 +76,12 @@ class UploadService {
74
76
  sendChunkedFile(fileItem, start) {
75
77
  var _a;
76
78
  if (this.store.options.chunkSize && fileItem.size && fileItem.data) {
77
- const sliceSize = this.store.options.chunkSize * 1024;
79
+ const sliceSize = this.store.options.chunkSize * 1024 * 1024;
78
80
  const sliceEnd = start + sliceSize;
81
+ const nextSlice = sliceEnd + 1;
79
82
  const chunkEnd = Math.min(sliceEnd, fileItem.size);
80
- const chunk = fileItem.data.slice(start, chunkEnd);
83
+ const chunk = fileItem.data.slice(start, nextSlice);
81
84
  let request = new HttpRequestService(this.store).request("POST", this.store.options.uploadUrl);
82
- request.setRequestHeader("accept", "application/json");
83
85
  const contentRange = "bytes " + start + "-" + chunkEnd + "/" + fileItem.size;
84
86
  request.setRequestHeader("Content-Range", contentRange);
85
87
  request.addEventListener("load", () => {
@@ -99,7 +101,7 @@ class UploadService {
99
101
  this.upload();
100
102
  } else {
101
103
  this.store.updateFileItem(fileItem);
102
- this.sendChunkedFile(fileItem, sliceEnd + 1);
104
+ this.sendChunkedFile(fileItem, nextSlice);
103
105
  }
104
106
  } else {
105
107
  fileItem.status = "error";
@@ -454,22 +456,23 @@ class FileDropzoneComponent {
454
456
  __publicField(this, "dropzone");
455
457
  __publicField(this, "headline");
456
458
  __publicField(this, "subline");
457
- __publicField(this, "icon");
459
+ __publicField(this, "uploadIcon");
458
460
  __publicField(this, "deleteIcon");
459
461
  __publicField(this, "descWrapper");
462
+ __publicField(this, "baseCssClass", "");
460
463
  this.store = store;
461
464
  if (!this.store.options.multiple) {
462
465
  store.events.subscribe("fileItemUpdate", (fileItem) => {
463
466
  this.updateHeadline(fileItem);
464
467
  this.updateSubline(fileItem);
465
- this.updateIcon(fileItem);
468
+ this.updateUploadIcon(fileItem);
466
469
  this.updateDeleteIcon(fileItem);
467
470
  this.updateDescriptionWrapper(fileItem);
468
471
  });
469
472
  store.events.subscribe("fileDeleted", (fileItem) => {
470
473
  this.updateHeadline(fileItem);
471
474
  this.updateSubline(fileItem);
472
- this.updateIcon(fileItem);
475
+ this.updateUploadIcon(fileItem);
473
476
  this.updateDeleteIcon(fileItem);
474
477
  this.updateDescriptionWrapper(fileItem);
475
478
  });
@@ -477,54 +480,58 @@ class FileDropzoneComponent {
477
480
  }
478
481
  render() {
479
482
  this.dropzone = document.createElement("div");
480
- this.dropzone.classList.add("huply-dropzone");
481
- this.dropzone.appendChild(this.getDeleteIcon());
482
- const dropzoneDescriptionWrapper = this.getDescriptionWrapper();
483
- dropzoneDescriptionWrapper.appendChild(this.getIcon());
484
- dropzoneDescriptionWrapper.appendChild(this.getHeadline());
485
- dropzoneDescriptionWrapper.appendChild(this.getSubline());
486
- this.dropzone.appendChild(dropzoneDescriptionWrapper);
487
- this.dropzone.addEventListener("click", () => {
488
- var _a;
489
- (_a = this.store.components.input) == null ? void 0 : _a.click();
490
- });
491
- this.dropzone.addEventListener("dragover", (e) => {
492
- var _a;
493
- e.preventDefault();
494
- (_a = this.dropzone) == null ? void 0 : _a.classList.add("is-dragover");
495
- });
496
- this.dropzone.addEventListener("dragleave", (e) => {
497
- var _a;
498
- e.preventDefault();
499
- (_a = this.dropzone) == null ? void 0 : _a.classList.remove("is-dragover");
500
- });
501
- this.dropzone.addEventListener("drop", (e) => {
502
- e.preventDefault();
503
- const uploadService = new UploadService(this.store);
504
- if (e.dataTransfer) {
505
- for (var i = 0; i < e.dataTransfer.items.length; i++) {
506
- const item = e.dataTransfer.items[i].getAsFile();
507
- if (item) {
508
- const validationService = new FileValidationService(this.store);
509
- const validationMsg = validationService.isValidFile(item);
510
- new FileService(this.store).generateFileItem(item).then((fileItem) => {
511
- this.store.addFileItem(fileItem);
512
- if (validationMsg.length !== 0) {
513
- fileItem.status = "error";
514
- fileItem.statusMsg = validationMsg.map((item2) => item2.msg).join(", ");
515
- this.store.updateFileItem(fileItem);
516
- }
517
- });
518
- uploadService.upload();
483
+ if (this.baseCssClass) {
484
+ this.dropzone.classList.add(this.baseCssClass);
485
+ }
486
+ this.getTemplate();
487
+ this.setEvents();
488
+ return this.dropzone;
489
+ }
490
+ getTemplate() {
491
+ }
492
+ setEvents() {
493
+ if (this.dropzone) {
494
+ this.dropzone.addEventListener("click", () => {
495
+ var _a;
496
+ (_a = this.store.components.input) == null ? void 0 : _a.click();
497
+ });
498
+ this.dropzone.addEventListener("dragover", (e) => {
499
+ var _a;
500
+ e.preventDefault();
501
+ (_a = this.dropzone) == null ? void 0 : _a.classList.add("is-dragover");
502
+ });
503
+ this.dropzone.addEventListener("dragleave", (e) => {
504
+ var _a;
505
+ e.preventDefault();
506
+ (_a = this.dropzone) == null ? void 0 : _a.classList.remove("is-dragover");
507
+ });
508
+ this.dropzone.addEventListener("drop", (e) => {
509
+ e.preventDefault();
510
+ const uploadService = new UploadService(this.store);
511
+ if (e.dataTransfer) {
512
+ for (var i = 0; i < e.dataTransfer.items.length; i++) {
513
+ const item = e.dataTransfer.items[i].getAsFile();
514
+ if (item) {
515
+ const validationService = new FileValidationService(this.store);
516
+ const validationMsg = validationService.isValidFile(item);
517
+ new FileService(this.store).generateFileItem(item).then((fileItem) => {
518
+ this.store.addFileItem(fileItem);
519
+ if (validationMsg.length !== 0) {
520
+ fileItem.status = "error";
521
+ fileItem.statusMsg = validationMsg.map((item2) => item2.msg).join(", ");
522
+ this.store.updateFileItem(fileItem);
523
+ }
524
+ uploadService.upload();
525
+ });
526
+ }
519
527
  }
520
528
  }
521
- }
522
- });
523
- return this.dropzone;
529
+ });
530
+ }
524
531
  }
525
532
  getDescriptionWrapper() {
526
533
  this.descWrapper = document.createElement("div");
527
- this.descWrapper.classList.add("huply-dropzone-desc");
534
+ this.descWrapper.classList.add(this.baseCssClass + "-desc");
528
535
  return this.descWrapper;
529
536
  }
530
537
  updateDescriptionWrapper(fileItem) {
@@ -544,31 +551,31 @@ class FileDropzoneComponent {
544
551
  }
545
552
  }
546
553
  }
547
- getIcon() {
548
- this.icon = document.createElement("div");
549
- this.icon.classList.add("huply-dropzone-icon-upload");
550
- this.icon.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path d="M303 175C312.4 165.7 327.6 165.7 336.1 175L416.1 255C426.3 264.4 426.3 279.6 416.1 288.1C407.6 298.3 392.4 298.3 383 288.1L344 249.9V384C344 397.3 333.3 408 320 408C306.7 408 296 397.3 296 384V249.9L256.1 288.1C247.6 298.3 232.4 298.3 223 288.1C213.7 279.6 213.7 264.4 223 255L303 175zM144 480C64.47 480 0 415.5 0 336C0 273.3 40.07 219.1 96 200.2V200C96 107.2 171.2 32 264 32C314.9 32 360.4 54.6 391.3 90.31C406.2 83.68 422.6 80 440 80C506.3 80 560 133.7 560 200C560 206.6 559.5 213 558.5 219.3C606.5 240.3 640 288.3 640 344C640 416.4 583.4 475.6 512 479.8V480H144zM264 80C197.7 80 144 133.7 144 200L144 234.1L111.1 245.5C74.64 258.7 48 294.3 48 336C48 389 90.98 432 144 432H506.6L509.2 431.8C555.4 429.2 592 390.8 592 344C592 308 570.4 276.9 539.2 263.3L505.1 248.4L511.1 211.7C511.7 207.9 512 204 512 200C512 160.2 479.8 128 440 128C429.5 128 419.6 130.2 410.8 134.2L378.2 148.7L354.9 121.7C332.8 96.08 300.3 80 263.1 80L264 80z"/></svg>`;
551
- return this.icon;
554
+ getUploadIcon() {
555
+ this.uploadIcon = document.createElement("div");
556
+ this.uploadIcon.classList.add(this.baseCssClass + "-icon-upload");
557
+ this.uploadIcon.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path d="M303 175C312.4 165.7 327.6 165.7 336.1 175L416.1 255C426.3 264.4 426.3 279.6 416.1 288.1C407.6 298.3 392.4 298.3 383 288.1L344 249.9V384C344 397.3 333.3 408 320 408C306.7 408 296 397.3 296 384V249.9L256.1 288.1C247.6 298.3 232.4 298.3 223 288.1C213.7 279.6 213.7 264.4 223 255L303 175zM144 480C64.47 480 0 415.5 0 336C0 273.3 40.07 219.1 96 200.2V200C96 107.2 171.2 32 264 32C314.9 32 360.4 54.6 391.3 90.31C406.2 83.68 422.6 80 440 80C506.3 80 560 133.7 560 200C560 206.6 559.5 213 558.5 219.3C606.5 240.3 640 288.3 640 344C640 416.4 583.4 475.6 512 479.8V480H144zM264 80C197.7 80 144 133.7 144 200L144 234.1L111.1 245.5C74.64 258.7 48 294.3 48 336C48 389 90.98 432 144 432H506.6L509.2 431.8C555.4 429.2 592 390.8 592 344C592 308 570.4 276.9 539.2 263.3L505.1 248.4L511.1 211.7C511.7 207.9 512 204 512 200C512 160.2 479.8 128 440 128C429.5 128 419.6 130.2 410.8 134.2L378.2 148.7L354.9 121.7C332.8 96.08 300.3 80 263.1 80L264 80z"/></svg>`;
558
+ return this.uploadIcon;
552
559
  }
553
- updateIcon(fileItem) {
554
- if (this.icon) {
560
+ updateUploadIcon(fileItem) {
561
+ if (this.uploadIcon) {
555
562
  if (fileItem.status === "uploading" && fileItem.uploadProcess === 0) {
556
- this.icon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M264 24C264 10.75 274.7 0 288 0C429.4 0 544 114.6 544 256C544 302.6 531.5 346.4 509.7 384C503.1 395.5 488.4 399.4 476.9 392.8C465.5 386.2 461.5 371.5 468.2 360C485.9 329.4 496 293.9 496 255.1C496 141.1 402.9 47.1 288 47.1C274.7 47.1 264 37.25 264 23.1V24z"/></svg>';
563
+ this.uploadIcon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M264 24C264 10.75 274.7 0 288 0C429.4 0 544 114.6 544 256C544 302.6 531.5 346.4 509.7 384C503.1 395.5 488.4 399.4 476.9 392.8C465.5 386.2 461.5 371.5 468.2 360C485.9 329.4 496 293.9 496 255.1C496 141.1 402.9 47.1 288 47.1C274.7 47.1 264 37.25 264 23.1V24z"/></svg>';
557
564
  } else if (fileItem.status === "error") {
558
- this.icon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M256 0C114.6 0 0 114.6 0 256s114.6 256 256 256s256-114.6 256-256S397.4 0 256 0zM256 464c-114.7 0-208-93.31-208-208S141.3 48 256 48s208 93.31 208 208S370.7 464 256 464zM256 304c13.25 0 24-10.75 24-24v-128C280 138.8 269.3 128 256 128S232 138.8 232 152v128C232 293.3 242.8 304 256 304zM256 337.1c-17.36 0-31.44 14.08-31.44 31.44C224.6 385.9 238.6 400 256 400s31.44-14.08 31.44-31.44C287.4 351.2 273.4 337.1 256 337.1z"/></svg>';
565
+ this.uploadIcon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M256 0C114.6 0 0 114.6 0 256s114.6 256 256 256s256-114.6 256-256S397.4 0 256 0zM256 464c-114.7 0-208-93.31-208-208S141.3 48 256 48s208 93.31 208 208S370.7 464 256 464zM256 304c13.25 0 24-10.75 24-24v-128C280 138.8 269.3 128 256 128S232 138.8 232 152v128C232 293.3 242.8 304 256 304zM256 337.1c-17.36 0-31.44 14.08-31.44 31.44C224.6 385.9 238.6 400 256 400s31.44-14.08 31.44-31.44C287.4 351.2 273.4 337.1 256 337.1z"/></svg>';
559
566
  } else if (fileItem.status === "uploaded") {
560
- this.icon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M243.8 339.8C232.9 350.7 215.1 350.7 204.2 339.8L140.2 275.8C129.3 264.9 129.3 247.1 140.2 236.2C151.1 225.3 168.9 225.3 179.8 236.2L224 280.4L332.2 172.2C343.1 161.3 360.9 161.3 371.8 172.2C382.7 183.1 382.7 200.9 371.8 211.8L243.8 339.8zM512 256C512 397.4 397.4 512 256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256zM256 48C141.1 48 48 141.1 48 256C48 370.9 141.1 464 256 464C370.9 464 464 370.9 464 256C464 141.1 370.9 48 256 48z"/></svg>';
567
+ this.uploadIcon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M243.8 339.8C232.9 350.7 215.1 350.7 204.2 339.8L140.2 275.8C129.3 264.9 129.3 247.1 140.2 236.2C151.1 225.3 168.9 225.3 179.8 236.2L224 280.4L332.2 172.2C343.1 161.3 360.9 161.3 371.8 172.2C382.7 183.1 382.7 200.9 371.8 211.8L243.8 339.8zM512 256C512 397.4 397.4 512 256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256zM256 48C141.1 48 48 141.1 48 256C48 370.9 141.1 464 256 464C370.9 464 464 370.9 464 256C464 141.1 370.9 48 256 48z"/></svg>';
561
568
  } else if (fileItem.status === "deleted" && this.store.getFilesUploading().length === 0) {
562
- this.icon.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path d="M303 175C312.4 165.7 327.6 165.7 336.1 175L416.1 255C426.3 264.4 426.3 279.6 416.1 288.1C407.6 298.3 392.4 298.3 383 288.1L344 249.9V384C344 397.3 333.3 408 320 408C306.7 408 296 397.3 296 384V249.9L256.1 288.1C247.6 298.3 232.4 298.3 223 288.1C213.7 279.6 213.7 264.4 223 255L303 175zM144 480C64.47 480 0 415.5 0 336C0 273.3 40.07 219.1 96 200.2V200C96 107.2 171.2 32 264 32C314.9 32 360.4 54.6 391.3 90.31C406.2 83.68 422.6 80 440 80C506.3 80 560 133.7 560 200C560 206.6 559.5 213 558.5 219.3C606.5 240.3 640 288.3 640 344C640 416.4 583.4 475.6 512 479.8V480H144zM264 80C197.7 80 144 133.7 144 200L144 234.1L111.1 245.5C74.64 258.7 48 294.3 48 336C48 389 90.98 432 144 432H506.6L509.2 431.8C555.4 429.2 592 390.8 592 344C592 308 570.4 276.9 539.2 263.3L505.1 248.4L511.1 211.7C511.7 207.9 512 204 512 200C512 160.2 479.8 128 440 128C429.5 128 419.6 130.2 410.8 134.2L378.2 148.7L354.9 121.7C332.8 96.08 300.3 80 263.1 80L264 80z"/></svg>`;
569
+ this.uploadIcon.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path d="M303 175C312.4 165.7 327.6 165.7 336.1 175L416.1 255C426.3 264.4 426.3 279.6 416.1 288.1C407.6 298.3 392.4 298.3 383 288.1L344 249.9V384C344 397.3 333.3 408 320 408C306.7 408 296 397.3 296 384V249.9L256.1 288.1C247.6 298.3 232.4 298.3 223 288.1C213.7 279.6 213.7 264.4 223 255L303 175zM144 480C64.47 480 0 415.5 0 336C0 273.3 40.07 219.1 96 200.2V200C96 107.2 171.2 32 264 32C314.9 32 360.4 54.6 391.3 90.31C406.2 83.68 422.6 80 440 80C506.3 80 560 133.7 560 200C560 206.6 559.5 213 558.5 219.3C606.5 240.3 640 288.3 640 344C640 416.4 583.4 475.6 512 479.8V480H144zM264 80C197.7 80 144 133.7 144 200L144 234.1L111.1 245.5C74.64 258.7 48 294.3 48 336C48 389 90.98 432 144 432H506.6L509.2 431.8C555.4 429.2 592 390.8 592 344C592 308 570.4 276.9 539.2 263.3L505.1 248.4L511.1 211.7C511.7 207.9 512 204 512 200C512 160.2 479.8 128 440 128C429.5 128 419.6 130.2 410.8 134.2L378.2 148.7L354.9 121.7C332.8 96.08 300.3 80 263.1 80L264 80z"/></svg>`;
563
570
  } else if (fileItem.status === "preloaded") {
564
- this.icon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M454.7 288.1c-12.78-3.75-26.06 3.594-29.75 16.31C403.3 379.9 333.8 432 255.1 432c-66.53 0-126.8-38.28-156.5-96h100.4c13.25 0 24-10.75 24-24S213.2 288 199.9 288h-160c-13.25 0-24 10.75-24 24v160c0 13.25 10.75 24 24 24s24-10.75 24-24v-102.1C103.7 436.4 176.1 480 255.1 480c99 0 187.4-66.31 215.1-161.3C474.8 305.1 467.4 292.7 454.7 288.1zM472 16C458.8 16 448 26.75 448 40v102.1C408.3 75.55 335.8 32 256 32C157 32 68.53 98.31 40.91 193.3C37.19 206 44.5 219.3 57.22 223c12.84 3.781 26.09-3.625 29.75-16.31C108.7 132.1 178.2 80 256 80c66.53 0 126.8 38.28 156.5 96H312C298.8 176 288 186.8 288 200S298.8 224 312 224h160c13.25 0 24-10.75 24-24v-160C496 26.75 485.3 16 472 16z"/></svg>';
571
+ this.uploadIcon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M454.7 288.1c-12.78-3.75-26.06 3.594-29.75 16.31C403.3 379.9 333.8 432 255.1 432c-66.53 0-126.8-38.28-156.5-96h100.4c13.25 0 24-10.75 24-24S213.2 288 199.9 288h-160c-13.25 0-24 10.75-24 24v160c0 13.25 10.75 24 24 24s24-10.75 24-24v-102.1C103.7 436.4 176.1 480 255.1 480c99 0 187.4-66.31 215.1-161.3C474.8 305.1 467.4 292.7 454.7 288.1zM472 16C458.8 16 448 26.75 448 40v102.1C408.3 75.55 335.8 32 256 32C157 32 68.53 98.31 40.91 193.3C37.19 206 44.5 219.3 57.22 223c12.84 3.781 26.09-3.625 29.75-16.31C108.7 132.1 178.2 80 256 80c66.53 0 126.8 38.28 156.5 96H312C298.8 176 288 186.8 288 200S298.8 224 312 224h160c13.25 0 24-10.75 24-24v-160C496 26.75 485.3 16 472 16z"/></svg>';
565
572
  }
566
573
  }
567
574
  }
568
575
  getDeleteIcon() {
569
576
  this.deleteIcon = document.createElement("a");
570
577
  this.deleteIcon.setAttribute("href", "#");
571
- this.deleteIcon.classList.add("huply-dropzone-icon-delete");
578
+ this.deleteIcon.classList.add(this.baseCssClass + "-icon-delete");
572
579
  this.deleteIcon.classList.add("is-hidden");
573
580
  this.deleteIcon.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M424 80C437.3 80 448 90.75 448 104C448 117.3 437.3 128 424 128H412.4L388.4 452.7C385.9 486.1 358.1 512 324.6 512H123.4C89.92 512 62.09 486.1 59.61 452.7L35.56 128H24C10.75 128 0 117.3 0 104C0 90.75 10.75 80 24 80H93.82L130.5 24.94C140.9 9.357 158.4 0 177.1 0H270.9C289.6 0 307.1 9.358 317.5 24.94L354.2 80H424zM177.1 48C174.5 48 171.1 49.34 170.5 51.56L151.5 80H296.5L277.5 51.56C276 49.34 273.5 48 270.9 48H177.1zM364.3 128H83.69L107.5 449.2C108.1 457.5 115.1 464 123.4 464H324.6C332.9 464 339.9 457.5 340.5 449.2L364.3 128z"/></svg>`;
574
581
  this.deleteIcon.addEventListener("click", (e) => {
@@ -596,7 +603,7 @@ class FileDropzoneComponent {
596
603
  }
597
604
  getHeadline() {
598
605
  this.headline = document.createElement("p");
599
- this.headline.classList.add("huply-dropzone-headline");
606
+ this.headline.classList.add(this.baseCssClass + "-headline");
600
607
  this.headline.innerHTML = this.getHeadlineText();
601
608
  return this.headline;
602
609
  }
@@ -616,7 +623,7 @@ class FileDropzoneComponent {
616
623
  getSubline() {
617
624
  this.subline = document.createElement("p");
618
625
  this.subline.innerText = this.getSublineText();
619
- this.subline.classList.add("huply-dropzone-subline");
626
+ this.subline.classList.add(this.baseCssClass + "-subline");
620
627
  return this.subline;
621
628
  }
622
629
  getSublineText() {
@@ -645,77 +652,46 @@ class FileDropzoneComponent {
645
652
  }
646
653
  }
647
654
  }
648
- class FileDropzoneSmallComponent {
655
+ class FileDropzoneLgComponent extends FileDropzoneComponent {
649
656
  constructor(store) {
650
- __publicField(this, "store");
651
- __publicField(this, "dropzone");
652
- __publicField(this, "headline");
653
- __publicField(this, "subline");
654
- __publicField(this, "uploadIcon");
655
- __publicField(this, "deleteIcon");
656
- __publicField(this, "descWrapper");
657
- this.store = store;
657
+ super(store);
658
+ __publicField(this, "baseCssClass", "huply-dropzone-lg");
659
+ }
660
+ getTemplate() {
661
+ if (this.dropzone) {
662
+ this.dropzone.appendChild(this.getDeleteIcon());
663
+ const dropzoneDescriptionWrapper = this.getDescriptionWrapper();
664
+ dropzoneDescriptionWrapper.appendChild(this.getUploadIcon());
665
+ dropzoneDescriptionWrapper.appendChild(this.getHeadline());
666
+ dropzoneDescriptionWrapper.appendChild(this.getSubline());
667
+ this.dropzone.appendChild(dropzoneDescriptionWrapper);
668
+ return this.dropzone;
669
+ }
670
+ }
671
+ }
672
+ class FileDropzoneSmallComponent extends FileDropzoneComponent {
673
+ constructor(store) {
674
+ super(store);
675
+ __publicField(this, "baseCssClass", "huply-dropzone-sm");
658
676
  if (!this.store.options.multiple) {
659
677
  store.events.subscribe("fileItemUpdate", (fileItem) => {
660
- this.updateHeadline(fileItem);
661
- this.updateSubline(fileItem);
662
- this.updateUploadIcon(fileItem);
663
- this.updateDeleteIcon(fileItem);
664
678
  this.updateWrapper(fileItem);
665
679
  });
666
680
  store.events.subscribe("fileDeleted", (fileItem) => {
667
- this.updateHeadline(fileItem);
668
- this.updateSubline(fileItem);
669
- this.updateUploadIcon(fileItem);
670
- this.updateDeleteIcon(fileItem);
671
681
  this.updateWrapper(fileItem);
672
682
  });
673
683
  }
674
684
  }
675
- render() {
676
- this.dropzone = document.createElement("div");
677
- this.dropzone.classList.add("huply-dropzone-sm");
678
- const dropzoneWrapper = this.getWrapper();
679
- dropzoneWrapper.appendChild(this.getHeadline());
680
- dropzoneWrapper.appendChild(this.getSubline());
681
- dropzoneWrapper.appendChild(this.getUploadIcon());
682
- dropzoneWrapper.appendChild(this.getDeleteIcon());
683
- this.dropzone.appendChild(dropzoneWrapper);
684
- this.dropzone.addEventListener("click", () => {
685
- var _a;
686
- (_a = this.store.components.input) == null ? void 0 : _a.click();
687
- });
688
- this.dropzone.addEventListener("dragover", () => {
689
- var _a;
690
- (_a = this.dropzone) == null ? void 0 : _a.classList.add("is-dragover");
691
- });
692
- this.dropzone.addEventListener("dragleave", () => {
693
- var _a;
694
- (_a = this.dropzone) == null ? void 0 : _a.classList.remove("is-dragover");
695
- });
696
- this.dropzone.addEventListener("drop", (e) => {
697
- e.preventDefault();
698
- const uploadService = new UploadService(this.store);
699
- if (e.dataTransfer) {
700
- for (var i = 0; i < e.dataTransfer.items.length; i++) {
701
- const item = e.dataTransfer.items[i].getAsFile();
702
- if (item) {
703
- const validationService = new FileValidationService(this.store);
704
- const validationMsg = validationService.isValidFile(item);
705
- new FileService(this.store).generateFileItem(item).then((fileItem) => {
706
- this.store.addFileItem(fileItem);
707
- if (validationMsg.length !== 0) {
708
- fileItem.status = "error";
709
- fileItem.statusMsg = validationMsg.map((item2) => item2.msg).join(", ");
710
- this.store.updateFileItem(fileItem);
711
- }
712
- uploadService.upload();
713
- });
714
- }
715
- }
716
- }
717
- });
718
- return this.dropzone;
685
+ getTemplate() {
686
+ if (this.dropzone) {
687
+ const dropzoneWrapper = this.getWrapper();
688
+ dropzoneWrapper.appendChild(this.getHeadline());
689
+ dropzoneWrapper.appendChild(this.getSubline());
690
+ dropzoneWrapper.appendChild(this.getUploadIcon());
691
+ dropzoneWrapper.appendChild(this.getDeleteIcon());
692
+ this.dropzone.appendChild(dropzoneWrapper);
693
+ return this.dropzone;
694
+ }
719
695
  }
720
696
  getWrapper() {
721
697
  this.descWrapper = document.createElement("div");
@@ -739,106 +715,6 @@ class FileDropzoneSmallComponent {
739
715
  }
740
716
  }
741
717
  }
742
- getDeleteIcon() {
743
- this.deleteIcon = document.createElement("a");
744
- this.deleteIcon.setAttribute("href", "#");
745
- this.deleteIcon.classList.add("huply-dropzone-sm-icon-delete");
746
- this.deleteIcon.classList.add("is-hidden");
747
- this.deleteIcon.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M424 80C437.3 80 448 90.75 448 104C448 117.3 437.3 128 424 128H412.4L388.4 452.7C385.9 486.1 358.1 512 324.6 512H123.4C89.92 512 62.09 486.1 59.61 452.7L35.56 128H24C10.75 128 0 117.3 0 104C0 90.75 10.75 80 24 80H93.82L130.5 24.94C140.9 9.357 158.4 0 177.1 0H270.9C289.6 0 307.1 9.358 317.5 24.94L354.2 80H424zM177.1 48C174.5 48 171.1 49.34 170.5 51.56L151.5 80H296.5L277.5 51.56C276 49.34 273.5 48 270.9 48H177.1zM364.3 128H83.69L107.5 449.2C108.1 457.5 115.1 464 123.4 464H324.6C332.9 464 339.9 457.5 340.5 449.2L364.3 128z"/></svg>`;
748
- this.deleteIcon.addEventListener("click", (e) => {
749
- e.preventDefault();
750
- e.stopPropagation();
751
- const fileIndex = this.store.files.findIndex((currentItem) => {
752
- var _a;
753
- return ((_a = this.deleteIcon) == null ? void 0 : _a.getAttribute("data-file-id")) == currentItem.id;
754
- });
755
- if (fileIndex !== -1) {
756
- this.store.deleteFileItem(this.store.files[fileIndex]);
757
- }
758
- });
759
- return this.deleteIcon;
760
- }
761
- updateDeleteIcon(fileItem) {
762
- if (this.deleteIcon) {
763
- if (fileItem.status === "uploaded" || fileItem.status === "preloaded") {
764
- this.deleteIcon.classList.remove("is-hidden");
765
- this.deleteIcon.setAttribute("data-file-id", fileItem.id);
766
- } else {
767
- this.deleteIcon.classList.add("is-hidden");
768
- }
769
- }
770
- }
771
- getUploadIcon() {
772
- this.uploadIcon = document.createElement("div");
773
- this.uploadIcon.classList.add("huply-dropzone-sm-icon-upload");
774
- this.uploadIcon.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path d="M303 175C312.4 165.7 327.6 165.7 336.1 175L416.1 255C426.3 264.4 426.3 279.6 416.1 288.1C407.6 298.3 392.4 298.3 383 288.1L344 249.9V384C344 397.3 333.3 408 320 408C306.7 408 296 397.3 296 384V249.9L256.1 288.1C247.6 298.3 232.4 298.3 223 288.1C213.7 279.6 213.7 264.4 223 255L303 175zM144 480C64.47 480 0 415.5 0 336C0 273.3 40.07 219.1 96 200.2V200C96 107.2 171.2 32 264 32C314.9 32 360.4 54.6 391.3 90.31C406.2 83.68 422.6 80 440 80C506.3 80 560 133.7 560 200C560 206.6 559.5 213 558.5 219.3C606.5 240.3 640 288.3 640 344C640 416.4 583.4 475.6 512 479.8V480H144zM264 80C197.7 80 144 133.7 144 200L144 234.1L111.1 245.5C74.64 258.7 48 294.3 48 336C48 389 90.98 432 144 432H506.6L509.2 431.8C555.4 429.2 592 390.8 592 344C592 308 570.4 276.9 539.2 263.3L505.1 248.4L511.1 211.7C511.7 207.9 512 204 512 200C512 160.2 479.8 128 440 128C429.5 128 419.6 130.2 410.8 134.2L378.2 148.7L354.9 121.7C332.8 96.08 300.3 80 263.1 80L264 80z"/></svg>`;
775
- return this.uploadIcon;
776
- }
777
- updateUploadIcon(fileItem) {
778
- if (this.uploadIcon) {
779
- if (fileItem.status === "uploading" && fileItem.uploadProcess === 0) {
780
- this.uploadIcon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M264 24C264 10.75 274.7 0 288 0C429.4 0 544 114.6 544 256C544 302.6 531.5 346.4 509.7 384C503.1 395.5 488.4 399.4 476.9 392.8C465.5 386.2 461.5 371.5 468.2 360C485.9 329.4 496 293.9 496 255.1C496 141.1 402.9 47.1 288 47.1C274.7 47.1 264 37.25 264 23.1V24z"/></svg>';
781
- } else if (fileItem.status === "error") {
782
- this.uploadIcon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M256 0C114.6 0 0 114.6 0 256s114.6 256 256 256s256-114.6 256-256S397.4 0 256 0zM256 464c-114.7 0-208-93.31-208-208S141.3 48 256 48s208 93.31 208 208S370.7 464 256 464zM256 304c13.25 0 24-10.75 24-24v-128C280 138.8 269.3 128 256 128S232 138.8 232 152v128C232 293.3 242.8 304 256 304zM256 337.1c-17.36 0-31.44 14.08-31.44 31.44C224.6 385.9 238.6 400 256 400s31.44-14.08 31.44-31.44C287.4 351.2 273.4 337.1 256 337.1z"/></svg>';
783
- } else if (fileItem.status === "uploaded") {
784
- this.uploadIcon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M243.8 339.8C232.9 350.7 215.1 350.7 204.2 339.8L140.2 275.8C129.3 264.9 129.3 247.1 140.2 236.2C151.1 225.3 168.9 225.3 179.8 236.2L224 280.4L332.2 172.2C343.1 161.3 360.9 161.3 371.8 172.2C382.7 183.1 382.7 200.9 371.8 211.8L243.8 339.8zM512 256C512 397.4 397.4 512 256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256zM256 48C141.1 48 48 141.1 48 256C48 370.9 141.1 464 256 464C370.9 464 464 370.9 464 256C464 141.1 370.9 48 256 48z"/></svg>';
785
- } else if (fileItem.status === "deleted" && this.store.getFilesUploading().length === 0) {
786
- this.uploadIcon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path d="M303 175C312.4 165.7 327.6 165.7 336.1 175L416.1 255C426.3 264.4 426.3 279.6 416.1 288.1C407.6 298.3 392.4 298.3 383 288.1L344 249.9V384C344 397.3 333.3 408 320 408C306.7 408 296 397.3 296 384V249.9L256.1 288.1C247.6 298.3 232.4 298.3 223 288.1C213.7 279.6 213.7 264.4 223 255L303 175zM144 480C64.47 480 0 415.5 0 336C0 273.3 40.07 219.1 96 200.2V200C96 107.2 171.2 32 264 32C314.9 32 360.4 54.6 391.3 90.31C406.2 83.68 422.6 80 440 80C506.3 80 560 133.7 560 200C560 206.6 559.5 213 558.5 219.3C606.5 240.3 640 288.3 640 344C640 416.4 583.4 475.6 512 479.8V480H144zM264 80C197.7 80 144 133.7 144 200L144 234.1L111.1 245.5C74.64 258.7 48 294.3 48 336C48 389 90.98 432 144 432H506.6L509.2 431.8C555.4 429.2 592 390.8 592 344C592 308 570.4 276.9 539.2 263.3L505.1 248.4L511.1 211.7C511.7 207.9 512 204 512 200C512 160.2 479.8 128 440 128C429.5 128 419.6 130.2 410.8 134.2L378.2 148.7L354.9 121.7C332.8 96.08 300.3 80 263.1 80L264 80z"/></svg>';
787
- } else if (fileItem.status === "preloaded") {
788
- this.uploadIcon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M454.7 288.1c-12.78-3.75-26.06 3.594-29.75 16.31C403.3 379.9 333.8 432 255.1 432c-66.53 0-126.8-38.28-156.5-96h100.4c13.25 0 24-10.75 24-24S213.2 288 199.9 288h-160c-13.25 0-24 10.75-24 24v160c0 13.25 10.75 24 24 24s24-10.75 24-24v-102.1C103.7 436.4 176.1 480 255.1 480c99 0 187.4-66.31 215.1-161.3C474.8 305.1 467.4 292.7 454.7 288.1zM472 16C458.8 16 448 26.75 448 40v102.1C408.3 75.55 335.8 32 256 32C157 32 68.53 98.31 40.91 193.3C37.19 206 44.5 219.3 57.22 223c12.84 3.781 26.09-3.625 29.75-16.31C108.7 132.1 178.2 80 256 80c66.53 0 126.8 38.28 156.5 96H312C298.8 176 288 186.8 288 200S298.8 224 312 224h160c13.25 0 24-10.75 24-24v-160C496 26.75 485.3 16 472 16z"/></svg>';
789
- }
790
- }
791
- }
792
- getHeadline() {
793
- this.headline = document.createElement("p");
794
- this.headline.classList.add("huply-dropzone-sm-headline");
795
- this.headline.innerHTML = this.getHeadlineText();
796
- return this.headline;
797
- }
798
- getHeadlineText() {
799
- var _a;
800
- return `<strong>${((_a = this.store) == null ? void 0 : _a.options.multiple) ? $t("chooseFiles") : $t("chooseFile")}</strong>`;
801
- }
802
- updateHeadline(fileItem) {
803
- if (this.headline) {
804
- if (fileItem.status === "deleted") {
805
- this.headline.innerHTML = this.getHeadlineText();
806
- } else {
807
- this.headline.innerHTML = `<strong>${fileItem.name}</strong>`;
808
- }
809
- }
810
- }
811
- getSubline() {
812
- this.subline = document.createElement("p");
813
- this.subline.innerText = this.getSublineText();
814
- this.subline.classList.add("huply-dropzone-sm-subline");
815
- return this.subline;
816
- }
817
- getSublineText() {
818
- var _a, _b;
819
- const sublineParts = [];
820
- sublineParts.push($t("allowedFileTypes", { allowedFileTypes: (_a = this.store) == null ? void 0 : _a.options.allowedFileTypes }));
821
- sublineParts.push($t("maxFileSize", { maxFileSize: (_b = this.store) == null ? void 0 : _b.options.maxFileSize }));
822
- return sublineParts.join(", ");
823
- }
824
- updateSubline(fileItem) {
825
- var _a;
826
- if (this.subline) {
827
- this.subline.classList.remove("is-uploading");
828
- this.subline.classList.remove("is-preloaded");
829
- this.subline.classList.remove("is-error");
830
- this.subline.classList.remove("is-uploaded");
831
- if (fileItem.status === "uploading" && fileItem.uploadProcess) {
832
- this.subline.innerHTML = $t("fileItemStatusUploading") + " (" + fileItem.uploadProcess.toFixed(0) + "%)";
833
- } else if (fileItem.status === "error") {
834
- this.subline.innerHTML = (_a = fileItem.statusMsg) != null ? _a : $t("fileItemStatusError");
835
- } else if (fileItem.status === "uploaded" || fileItem.status === "preloaded") {
836
- this.subline.textContent = fileItem.sizeMb && fileItem.sizeMb < 1 ? `${fileItem.sizeKb} KB` : `${fileItem.sizeMb} MB`;
837
- } else {
838
- this.subline.innerHTML = this.getSublineText();
839
- }
840
- }
841
- }
842
718
  }
843
719
  class FileInputHiddenComponent {
844
720
  constructor(el, store) {
@@ -881,7 +757,7 @@ class WrapperComponent {
881
757
  dropzoneComponent = new FileDropzoneSmallComponent(this.store);
882
758
  wrapper.appendChild(dropzoneComponent.render());
883
759
  } else {
884
- dropzoneComponent = new FileDropzoneComponent(this.store);
760
+ dropzoneComponent = new FileDropzoneLgComponent(this.store);
885
761
  wrapper.appendChild(dropzoneComponent.render());
886
762
  }
887
763
  const fileListComponent = new FileListComponent(this.store);
@@ -1103,7 +979,7 @@ class Huply {
1103
979
  lang: "de",
1104
980
  uploadUrl: "",
1105
981
  deleteUrl: "",
1106
- allowedFileTypes: [".jpg", ".jpeg", ".png", ".pdf"],
982
+ allowedFileTypes: [".jpg", ".jpeg", ".png", ".pdf", ".zip", ".mp4"],
1107
983
  dropzoneTheme: "lg"
1108
984
  };
1109
985
  if (isObject(options)) {