@yoobic/yobi 8.2.0-57 → 8.2.0-58

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.
@@ -46,6 +46,7 @@ const YooFormAutocompleteComponent = class {
46
46
  this.values = [];
47
47
  this.pageSize = 20;
48
48
  this.readonlyDisplay = 'inline';
49
+ this.preventUpload = false;
49
50
  this.showDropdownContent = false;
50
51
  this.selection = [];
51
52
  this.showEmptyItemsAddNewTag = false;
@@ -731,6 +732,9 @@ const YooFormAutocompleteComponent = class {
731
732
  let files = [].concat((ev === null || ev === void 0 ? void 0 : ev.detail) || []);
732
733
  files = files.filter((f) => !f.invalid);
733
734
  await this.uploadFiles(files);
735
+ if (this.preventUpload) {
736
+ this.fileUploader.removeFiles();
737
+ }
734
738
  }
735
739
  onFileSelect(ev) {
736
740
  if (ev) {
@@ -749,11 +753,11 @@ const YooFormAutocompleteComponent = class {
749
753
  promise = showImageCropper({ file }).then((retVal) => retVal);
750
754
  }
751
755
  else {
752
- promise = resizeImage(file, this.maxWidth, this.maxHeight).then(f => f);
756
+ promise = resizeImage(file, this.maxWidth, this.maxHeight).then(f => this.preventUpload ? f : { data: f });
753
757
  }
754
758
  }
755
759
  else {
756
- promise = Promise.resolve(file);
760
+ promise = Promise.resolve(this.preventUpload ? file : { data: file });
757
761
  }
758
762
  }
759
763
  else {
@@ -769,11 +773,28 @@ const YooFormAutocompleteComponent = class {
769
773
  }
770
774
  const filePromises = files.map((file) => {
771
775
  file.filename = getRandomFileName(file.filename);
772
- file.tag = FormFieldType.documentuploader;
776
+ if (this.preventUpload) {
777
+ file.tag = FormFieldType.documentuploader;
778
+ }
773
779
  return () => imageProcessPromise(file);
774
780
  });
775
781
  return asyncWaterfall(filePromises)
776
- .then(retVal => this.setValueAndValidateInput(this.multiple ? retVal : retVal[0]))
782
+ .then(retVal => {
783
+ if (retVal && !this.preventUpload) {
784
+ if (this.multiple) {
785
+ this.fetchCustomData.emit(retVal === null || retVal === void 0 ? void 0 : retVal.map((item) => (item === null || item === void 0 ? void 0 : item.data) || item));
786
+ }
787
+ else if (retVal[0]) {
788
+ this.fetchCustomData.emit(retVal[0].data || retVal[0]);
789
+ }
790
+ if (files === null || files === void 0 ? void 0 : files.length) {
791
+ this.isUploading = true;
792
+ }
793
+ }
794
+ else if (retVal) {
795
+ this.setValueAndValidateInput(this.multiple ? [...(this.selection || []), ...retVal] : retVal[0]);
796
+ }
797
+ })
777
798
  .catch(async () => await showAlert(translate('FILE'), [translate('YOOBICOK')], translate('FILEERROR')));
778
799
  }
779
800
  getReadonlyItemSelection() {
@@ -3416,7 +3416,8 @@ const YooFormDynamicComponent = class {
3416
3416
  'extraClass',
3417
3417
  'dynamicOrdering',
3418
3418
  'origin',
3419
- 'entityMapping'
3419
+ 'entityMapping',
3420
+ 'preventUpload'
3420
3421
  ];
3421
3422
  let extraClass = this.isLivePreview() ? 'live-preview-autocomplete' : null;
3422
3423
  if (this.isPdf) {
@@ -4095,7 +4096,7 @@ const YooFormDynamicComponent = class {
4095
4096
  }
4096
4097
  else {
4097
4098
  TagType = 'yoo-form-document';
4098
- const document = (field.type === FormFieldType.document || field.type === FormFieldType.podcast ? field.document : field.image) || value;
4099
+ const document = (field.type === FormFieldType.document || field.type === FormFieldType.podcast ? field.document : field.image) || (isObject(value) ? value : null);
4099
4100
  extraAttrs = {
4100
4101
  allowOrientation: this.isLesson(),
4101
4102
  type: field.type === FormFieldType.document || field.type === FormFieldType.podcast ? 'document' : 'image',