huply 0.0.9 → 0.1.0

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
@@ -76,13 +76,12 @@ class UploadService {
76
76
  sendChunkedFile(fileItem, start) {
77
77
  var _a;
78
78
  if (this.store.options.chunkSize && fileItem.size && fileItem.data) {
79
- const sliceSize = this.store.options.chunkSize * 1e3 * 1024;
79
+ const sliceSize = this.store.options.chunkSize * 1024 * 1024;
80
80
  const sliceEnd = start + sliceSize;
81
- const chunkEnd = Math.min(sliceEnd, fileItem.size);
82
- const chunk = fileItem.data.slice(start, chunkEnd);
83
81
  const nextSlice = sliceEnd + 1;
82
+ const chunkEnd = Math.min(sliceEnd, fileItem.size);
83
+ const chunk = fileItem.data.slice(start, nextSlice);
84
84
  let request = new HttpRequestService(this.store).request("POST", this.store.options.uploadUrl);
85
- request.setRequestHeader("accept", "application/json");
86
85
  const contentRange = "bytes " + start + "-" + chunkEnd + "/" + fileItem.size;
87
86
  request.setRequestHeader("Content-Range", contentRange);
88
87
  request.addEventListener("load", () => {
@@ -457,22 +456,23 @@ class FileDropzoneComponent {
457
456
  __publicField(this, "dropzone");
458
457
  __publicField(this, "headline");
459
458
  __publicField(this, "subline");
460
- __publicField(this, "icon");
459
+ __publicField(this, "uploadIcon");
461
460
  __publicField(this, "deleteIcon");
462
461
  __publicField(this, "descWrapper");
462
+ __publicField(this, "baseCssClass", "");
463
463
  this.store = store;
464
464
  if (!this.store.options.multiple) {
465
465
  store.events.subscribe("fileItemUpdate", (fileItem) => {
466
466
  this.updateHeadline(fileItem);
467
467
  this.updateSubline(fileItem);
468
- this.updateIcon(fileItem);
468
+ this.updateUploadIcon(fileItem);
469
469
  this.updateDeleteIcon(fileItem);
470
470
  this.updateDescriptionWrapper(fileItem);
471
471
  });
472
472
  store.events.subscribe("fileDeleted", (fileItem) => {
473
473
  this.updateHeadline(fileItem);
474
474
  this.updateSubline(fileItem);
475
- this.updateIcon(fileItem);
475
+ this.updateUploadIcon(fileItem);
476
476
  this.updateDeleteIcon(fileItem);
477
477
  this.updateDescriptionWrapper(fileItem);
478
478
  });
@@ -480,54 +480,58 @@ class FileDropzoneComponent {
480
480
  }
481
481
  render() {
482
482
  this.dropzone = document.createElement("div");
483
- this.dropzone.classList.add("huply-dropzone");
484
- this.dropzone.appendChild(this.getDeleteIcon());
485
- const dropzoneDescriptionWrapper = this.getDescriptionWrapper();
486
- dropzoneDescriptionWrapper.appendChild(this.getIcon());
487
- dropzoneDescriptionWrapper.appendChild(this.getHeadline());
488
- dropzoneDescriptionWrapper.appendChild(this.getSubline());
489
- this.dropzone.appendChild(dropzoneDescriptionWrapper);
490
- this.dropzone.addEventListener("click", () => {
491
- var _a;
492
- (_a = this.store.components.input) == null ? void 0 : _a.click();
493
- });
494
- this.dropzone.addEventListener("dragover", (e) => {
495
- var _a;
496
- e.preventDefault();
497
- (_a = this.dropzone) == null ? void 0 : _a.classList.add("is-dragover");
498
- });
499
- this.dropzone.addEventListener("dragleave", (e) => {
500
- var _a;
501
- e.preventDefault();
502
- (_a = this.dropzone) == null ? void 0 : _a.classList.remove("is-dragover");
503
- });
504
- this.dropzone.addEventListener("drop", (e) => {
505
- e.preventDefault();
506
- const uploadService = new UploadService(this.store);
507
- if (e.dataTransfer) {
508
- for (var i = 0; i < e.dataTransfer.items.length; i++) {
509
- const item = e.dataTransfer.items[i].getAsFile();
510
- if (item) {
511
- const validationService = new FileValidationService(this.store);
512
- const validationMsg = validationService.isValidFile(item);
513
- new FileService(this.store).generateFileItem(item).then((fileItem) => {
514
- this.store.addFileItem(fileItem);
515
- if (validationMsg.length !== 0) {
516
- fileItem.status = "error";
517
- fileItem.statusMsg = validationMsg.map((item2) => item2.msg).join(", ");
518
- this.store.updateFileItem(fileItem);
519
- }
520
- });
521
- 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
+ }
522
527
  }
523
528
  }
524
- }
525
- });
526
- return this.dropzone;
529
+ });
530
+ }
527
531
  }
528
532
  getDescriptionWrapper() {
529
533
  this.descWrapper = document.createElement("div");
530
- this.descWrapper.classList.add("huply-dropzone-desc");
534
+ this.descWrapper.classList.add(this.baseCssClass + "-desc");
531
535
  return this.descWrapper;
532
536
  }
533
537
  updateDescriptionWrapper(fileItem) {
@@ -547,31 +551,31 @@ class FileDropzoneComponent {
547
551
  }
548
552
  }
549
553
  }
550
- getIcon() {
551
- this.icon = document.createElement("div");
552
- this.icon.classList.add("huply-dropzone-icon-upload");
553
- 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>`;
554
- 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;
555
559
  }
556
- updateIcon(fileItem) {
557
- if (this.icon) {
560
+ updateUploadIcon(fileItem) {
561
+ if (this.uploadIcon) {
558
562
  if (fileItem.status === "uploading" && fileItem.uploadProcess === 0) {
559
- 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>';
560
564
  } else if (fileItem.status === "error") {
561
- 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>';
562
566
  } else if (fileItem.status === "uploaded") {
563
- 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>';
564
568
  } else if (fileItem.status === "deleted" && this.store.getFilesUploading().length === 0) {
565
- 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>`;
566
570
  } else if (fileItem.status === "preloaded") {
567
- 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>';
568
572
  }
569
573
  }
570
574
  }
571
575
  getDeleteIcon() {
572
576
  this.deleteIcon = document.createElement("a");
573
577
  this.deleteIcon.setAttribute("href", "#");
574
- this.deleteIcon.classList.add("huply-dropzone-icon-delete");
578
+ this.deleteIcon.classList.add(this.baseCssClass + "-icon-delete");
575
579
  this.deleteIcon.classList.add("is-hidden");
576
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>`;
577
581
  this.deleteIcon.addEventListener("click", (e) => {
@@ -599,7 +603,7 @@ class FileDropzoneComponent {
599
603
  }
600
604
  getHeadline() {
601
605
  this.headline = document.createElement("p");
602
- this.headline.classList.add("huply-dropzone-headline");
606
+ this.headline.classList.add(this.baseCssClass + "-headline");
603
607
  this.headline.innerHTML = this.getHeadlineText();
604
608
  return this.headline;
605
609
  }
@@ -619,7 +623,7 @@ class FileDropzoneComponent {
619
623
  getSubline() {
620
624
  this.subline = document.createElement("p");
621
625
  this.subline.innerText = this.getSublineText();
622
- this.subline.classList.add("huply-dropzone-subline");
626
+ this.subline.classList.add(this.baseCssClass + "-subline");
623
627
  return this.subline;
624
628
  }
625
629
  getSublineText() {
@@ -648,77 +652,46 @@ class FileDropzoneComponent {
648
652
  }
649
653
  }
650
654
  }
651
- class FileDropzoneSmallComponent {
655
+ class FileDropzoneLgComponent extends FileDropzoneComponent {
652
656
  constructor(store) {
653
- __publicField(this, "store");
654
- __publicField(this, "dropzone");
655
- __publicField(this, "headline");
656
- __publicField(this, "subline");
657
- __publicField(this, "uploadIcon");
658
- __publicField(this, "deleteIcon");
659
- __publicField(this, "descWrapper");
660
- 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");
661
676
  if (!this.store.options.multiple) {
662
677
  store.events.subscribe("fileItemUpdate", (fileItem) => {
663
- this.updateHeadline(fileItem);
664
- this.updateSubline(fileItem);
665
- this.updateUploadIcon(fileItem);
666
- this.updateDeleteIcon(fileItem);
667
678
  this.updateWrapper(fileItem);
668
679
  });
669
680
  store.events.subscribe("fileDeleted", (fileItem) => {
670
- this.updateHeadline(fileItem);
671
- this.updateSubline(fileItem);
672
- this.updateUploadIcon(fileItem);
673
- this.updateDeleteIcon(fileItem);
674
681
  this.updateWrapper(fileItem);
675
682
  });
676
683
  }
677
684
  }
678
- render() {
679
- this.dropzone = document.createElement("div");
680
- this.dropzone.classList.add("huply-dropzone-sm");
681
- const dropzoneWrapper = this.getWrapper();
682
- dropzoneWrapper.appendChild(this.getHeadline());
683
- dropzoneWrapper.appendChild(this.getSubline());
684
- dropzoneWrapper.appendChild(this.getUploadIcon());
685
- dropzoneWrapper.appendChild(this.getDeleteIcon());
686
- this.dropzone.appendChild(dropzoneWrapper);
687
- this.dropzone.addEventListener("click", () => {
688
- var _a;
689
- (_a = this.store.components.input) == null ? void 0 : _a.click();
690
- });
691
- this.dropzone.addEventListener("dragover", () => {
692
- var _a;
693
- (_a = this.dropzone) == null ? void 0 : _a.classList.add("is-dragover");
694
- });
695
- this.dropzone.addEventListener("dragleave", () => {
696
- var _a;
697
- (_a = this.dropzone) == null ? void 0 : _a.classList.remove("is-dragover");
698
- });
699
- this.dropzone.addEventListener("drop", (e) => {
700
- e.preventDefault();
701
- const uploadService = new UploadService(this.store);
702
- if (e.dataTransfer) {
703
- for (var i = 0; i < e.dataTransfer.items.length; i++) {
704
- const item = e.dataTransfer.items[i].getAsFile();
705
- if (item) {
706
- const validationService = new FileValidationService(this.store);
707
- const validationMsg = validationService.isValidFile(item);
708
- new FileService(this.store).generateFileItem(item).then((fileItem) => {
709
- this.store.addFileItem(fileItem);
710
- if (validationMsg.length !== 0) {
711
- fileItem.status = "error";
712
- fileItem.statusMsg = validationMsg.map((item2) => item2.msg).join(", ");
713
- this.store.updateFileItem(fileItem);
714
- }
715
- uploadService.upload();
716
- });
717
- }
718
- }
719
- }
720
- });
721
- 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
+ }
722
695
  }
723
696
  getWrapper() {
724
697
  this.descWrapper = document.createElement("div");
@@ -742,106 +715,6 @@ class FileDropzoneSmallComponent {
742
715
  }
743
716
  }
744
717
  }
745
- getDeleteIcon() {
746
- this.deleteIcon = document.createElement("a");
747
- this.deleteIcon.setAttribute("href", "#");
748
- this.deleteIcon.classList.add("huply-dropzone-sm-icon-delete");
749
- this.deleteIcon.classList.add("is-hidden");
750
- 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>`;
751
- this.deleteIcon.addEventListener("click", (e) => {
752
- e.preventDefault();
753
- e.stopPropagation();
754
- const fileIndex = this.store.files.findIndex((currentItem) => {
755
- var _a;
756
- return ((_a = this.deleteIcon) == null ? void 0 : _a.getAttribute("data-file-id")) == currentItem.id;
757
- });
758
- if (fileIndex !== -1) {
759
- this.store.deleteFileItem(this.store.files[fileIndex]);
760
- }
761
- });
762
- return this.deleteIcon;
763
- }
764
- updateDeleteIcon(fileItem) {
765
- if (this.deleteIcon) {
766
- if (fileItem.status === "uploaded" || fileItem.status === "preloaded") {
767
- this.deleteIcon.classList.remove("is-hidden");
768
- this.deleteIcon.setAttribute("data-file-id", fileItem.id);
769
- } else {
770
- this.deleteIcon.classList.add("is-hidden");
771
- }
772
- }
773
- }
774
- getUploadIcon() {
775
- this.uploadIcon = document.createElement("div");
776
- this.uploadIcon.classList.add("huply-dropzone-sm-icon-upload");
777
- 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>`;
778
- return this.uploadIcon;
779
- }
780
- updateUploadIcon(fileItem) {
781
- if (this.uploadIcon) {
782
- if (fileItem.status === "uploading" && fileItem.uploadProcess === 0) {
783
- 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>';
784
- } else if (fileItem.status === "error") {
785
- 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>';
786
- } else if (fileItem.status === "uploaded") {
787
- 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>';
788
- } else if (fileItem.status === "deleted" && this.store.getFilesUploading().length === 0) {
789
- 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>';
790
- } else if (fileItem.status === "preloaded") {
791
- 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>';
792
- }
793
- }
794
- }
795
- getHeadline() {
796
- this.headline = document.createElement("p");
797
- this.headline.classList.add("huply-dropzone-sm-headline");
798
- this.headline.innerHTML = this.getHeadlineText();
799
- return this.headline;
800
- }
801
- getHeadlineText() {
802
- var _a;
803
- return `<strong>${((_a = this.store) == null ? void 0 : _a.options.multiple) ? $t("chooseFiles") : $t("chooseFile")}</strong>`;
804
- }
805
- updateHeadline(fileItem) {
806
- if (this.headline) {
807
- if (fileItem.status === "deleted") {
808
- this.headline.innerHTML = this.getHeadlineText();
809
- } else {
810
- this.headline.innerHTML = `<strong>${fileItem.name}</strong>`;
811
- }
812
- }
813
- }
814
- getSubline() {
815
- this.subline = document.createElement("p");
816
- this.subline.innerText = this.getSublineText();
817
- this.subline.classList.add("huply-dropzone-sm-subline");
818
- return this.subline;
819
- }
820
- getSublineText() {
821
- var _a, _b;
822
- const sublineParts = [];
823
- sublineParts.push($t("allowedFileTypes", { allowedFileTypes: (_a = this.store) == null ? void 0 : _a.options.allowedFileTypes }));
824
- sublineParts.push($t("maxFileSize", { maxFileSize: (_b = this.store) == null ? void 0 : _b.options.maxFileSize }));
825
- return sublineParts.join(", ");
826
- }
827
- updateSubline(fileItem) {
828
- var _a;
829
- if (this.subline) {
830
- this.subline.classList.remove("is-uploading");
831
- this.subline.classList.remove("is-preloaded");
832
- this.subline.classList.remove("is-error");
833
- this.subline.classList.remove("is-uploaded");
834
- if (fileItem.status === "uploading" && fileItem.uploadProcess) {
835
- this.subline.innerHTML = $t("fileItemStatusUploading") + " (" + fileItem.uploadProcess.toFixed(0) + "%)";
836
- } else if (fileItem.status === "error") {
837
- this.subline.innerHTML = (_a = fileItem.statusMsg) != null ? _a : $t("fileItemStatusError");
838
- } else if (fileItem.status === "uploaded" || fileItem.status === "preloaded") {
839
- this.subline.textContent = fileItem.sizeMb && fileItem.sizeMb < 1 ? `${fileItem.sizeKb} KB` : `${fileItem.sizeMb} MB`;
840
- } else {
841
- this.subline.innerHTML = this.getSublineText();
842
- }
843
- }
844
- }
845
718
  }
846
719
  class FileInputHiddenComponent {
847
720
  constructor(el, store) {
@@ -884,7 +757,7 @@ class WrapperComponent {
884
757
  dropzoneComponent = new FileDropzoneSmallComponent(this.store);
885
758
  wrapper.appendChild(dropzoneComponent.render());
886
759
  } else {
887
- dropzoneComponent = new FileDropzoneComponent(this.store);
760
+ dropzoneComponent = new FileDropzoneLgComponent(this.store);
888
761
  wrapper.appendChild(dropzoneComponent.render());
889
762
  }
890
763
  const fileListComponent = new FileListComponent(this.store);
@@ -1106,7 +979,7 @@ class Huply {
1106
979
  lang: "de",
1107
980
  uploadUrl: "",
1108
981
  deleteUrl: "",
1109
- allowedFileTypes: [".jpg", ".jpeg", ".png", ".pdf"],
982
+ allowedFileTypes: [".jpg", ".jpeg", ".png", ".pdf", ".zip", ".mp4"],
1110
983
  dropzoneTheme: "lg"
1111
984
  };
1112
985
  if (isObject(options)) {
@@ -1139,7 +1012,12 @@ class Huply {
1139
1012
  }
1140
1013
  const preloadedFiles = (_h = this.el) == null ? void 0 : _h.getAttribute("data-preloaded-files");
1141
1014
  if (preloadedFiles) {
1142
- defaultOptions.preloadedFiles = JSON.parse(preloadedFiles);
1015
+ try {
1016
+ const decodedFiles = atob(preloadedFiles);
1017
+ defaultOptions.preloadedFiles = JSON.parse(decodedFiles);
1018
+ } catch {
1019
+ defaultOptions.preloadedFiles = [];
1020
+ }
1143
1021
  }
1144
1022
  const lang = (_i = this.el) == null ? void 0 : _i.getAttribute("data-lang");
1145
1023
  if (lang) {