@yoobic/yobi 8.5.0-19 → 8.5.0-20

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.
Files changed (24) hide show
  1. package/dist/cjs/yoo-card-list.cjs.entry.js +4 -1
  2. package/dist/cjs/yoo-form-capture.cjs.entry.js +56 -115
  3. package/dist/cjs/yoo-form-dynamic.cjs.entry.js +1 -1
  4. package/dist/cjs/yoo-form-hotzones.cjs.entry.js +2 -1
  5. package/dist/cjs/yoo-form-text-area.cjs.entry.js +1 -1
  6. package/dist/collection/components/entities/card-list/default/card-list.js +5 -2
  7. package/dist/collection/components/form/form-capture/form-capture.js +57 -119
  8. package/dist/collection/components/form/form-dynamic/form-dynamic.js +1 -1
  9. package/dist/collection/components/form/form-hotzones/form-hotzones.js +2 -1
  10. package/dist/collection/components/form/form-text-area/form-text-area.js +1 -1
  11. package/dist/design-system/yoo-card-list.entry.js +5 -2
  12. package/dist/design-system/yoo-form-capture.entry.js +57 -116
  13. package/dist/design-system/yoo-form-dynamic.entry.js +1 -1
  14. package/dist/design-system/yoo-form-hotzones.entry.js +2 -1
  15. package/dist/design-system/yoo-form-text-area.entry.js +1 -1
  16. package/dist/esm/yoo-card-list.entry.js +5 -2
  17. package/dist/esm/yoo-form-capture.entry.js +57 -116
  18. package/dist/esm/yoo-form-dynamic.entry.js +1 -1
  19. package/dist/esm/yoo-form-hotzones.entry.js +2 -1
  20. package/dist/esm/yoo-form-text-area.entry.js +1 -1
  21. package/dist/types/components/form/form-capture/form-capture.d.ts +4 -4
  22. package/dist/types/components.d.ts +1 -1
  23. package/dist/types/home/runner/work/yoobic-ng-6/yoobic-ng-6/design-system/stencil/.stencil/shared/interfaces/src/ui/device/device.interface.d.ts +2 -0
  24. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, i as createEvent, h, j as Build, e as Host, g as getElement } from './index-0a59e2a1.js';
2
2
  import { P as PictureSourceType, M as MediaType, i as importMultipleFromLibrary, g as getPicture, b as getVideo, s as showAudioRecorder, c as MediaCapture, a as getVideoDevices } from './camera-helpers-b0eccbf9.js';
3
- import { t as translate, b5 as showToast, dL as getFormCapturedFileSize, ae as showAlert, ar as pipes, X as isNullOrUndefined, aV as isImageUrl, ah as isGif, dG as isUnsplashUrl, A as isWeb, ai as isImage, ag as isVideo, dF as isAudio, j as isNativeMobile, cm as addFilePrefix, k as isAndroid, cp as moveToImageDirectory, a3 as getSession, z as showModal, H as isIOS, G as isIphoneX, b$ as StatusBar, dM as isLenovo, af as showActionSheet, dN as updatePathSessionId, bS as isSafari, P as getAsyncExtraData, dx as asyncWaterfall, cn as read, R as isNativeFilePath, aj as downloadFile, an as isFile, dO as getMimeType, bn as isOffline, dP as hasLargeFile, Z as translateMulti, aD as showContextMenu, ay as isPhotoEdited, du as images, dQ as audios, dv as videos, az as changeExtension, av as isCloudinaryLink } from './overlays-7248256e.js';
3
+ import { t as translate, b5 as showToast, dL as getFormCapturedFileSize, ae as showAlert, ar as pipes, X as isNullOrUndefined, ai as isImage, ah as isGif, dG as isUnsplashUrl, A as isWeb, ag as isVideo, dF as isAudio, j as isNativeMobile, aV as isImageUrl, cm as addFilePrefix, k as isAndroid, cp as moveToImageDirectory, a3 as getSession, z as showModal, H as isIOS, G as isIphoneX, b$ as StatusBar, dM as isLenovo, af as showActionSheet, dN as updatePathSessionId, bS as isSafari, P as getAsyncExtraData, dx as asyncWaterfall, cn as read, R as isNativeFilePath, aj as downloadFile, an as isFile, dO as getMimeType, bn as isOffline, dP as hasLargeFile, Z as translateMulti, aD as showContextMenu, ay as isPhotoEdited, du as images, dQ as audios, dv as videos, az as changeExtension, av as isCloudinaryLink } from './overlays-7248256e.js';
4
4
  import './index-e88a94c1.js';
5
5
  import { k as keys, z as intersection, a as isNumber, i as isArray, a4 as assignInWith, s as assign, n as compact, t as clone, E as isUndefined } from './lodash-653c0bcd.js';
6
6
  import { c as querySelectorAllDeep, q as querySelectorDeep, i as showImageCropper, e as showPhotoEditor, a as showSlidesMedia, g as getAppContext } from './common-helpers-edb2f727.js';
@@ -58,15 +58,9 @@ const YooFormCaptureComponent = class {
58
58
  this.updateExtraData(extraData);
59
59
  }
60
60
  /** If there is index, the field is a multiphoto */
61
- async setFieldValue(index, data) {
62
- if (index === undefined) {
63
- setValueAndValidateInput(data, this);
64
- }
65
- else {
66
- const newValue = this.value ? [...this.value] : [];
67
- newValue[index] = data;
68
- setValueAndValidateInput(newValue, this);
69
- }
61
+ async setFieldValue(data) {
62
+ this.multiple ? this.value.push(data) : this.value = data;
63
+ setValueAndValidateInput(this.value, this);
70
64
  }
71
65
  async stopImageRecognitionProcess(isCancelled = false) {
72
66
  this.imageRecoCancelled = isCancelled;
@@ -258,7 +252,7 @@ const YooFormCaptureComponent = class {
258
252
  }
259
253
  allowCrop(file) {
260
254
  var _a;
261
- return (((_a = this.cropperOptions) === null || _a === void 0 ? void 0 : _a.cropRatio) > 0 || this.showCropper) && isImageUrl(file) && !isGif(file) && (!(typeof file === 'string' && isUnsplashUrl(file)) || isWeb(this.host));
255
+ return (((_a = this.cropperOptions) === null || _a === void 0 ? void 0 : _a.cropRatio) > 0 || this.showCropper) && isImage(file) && !isGif(file) && (!(typeof file === 'string' && isUnsplashUrl(file)) || isWeb(this.host));
262
256
  }
263
257
  removeAllCapture() {
264
258
  this.value = [];
@@ -317,50 +311,34 @@ const YooFormCaptureComponent = class {
317
311
  }
318
312
  }
319
313
  }
320
- processMediaData(mediaData, index, preventUpdateValue = false) {
321
- let promise;
322
- if (!mediaData) {
323
- return (promise = Promise.resolve(mediaData));
324
- }
325
- if (mediaData && mediaData.indexOf('?') > 0) {
314
+ async processMediaData(mediaData, index) {
315
+ if (mediaData === null || mediaData === void 0 ? void 0 : mediaData.includes('?')) {
326
316
  mediaData = mediaData.substring(0, mediaData.indexOf('?'));
327
317
  }
328
- if (mediaData && mediaData.startsWith && mediaData.startsWith('data:image')) {
329
- promise = Promise.resolve(mediaData);
330
- }
331
- else {
318
+ else if (mediaData && !isImageUrl(mediaData)) {
332
319
  mediaData = addFilePrefix(mediaData);
333
- if (isAndroid() && mediaData.indexOf('tmp') < 0 && mediaData.indexOf('cache') < 0) {
334
- promise = Promise.resolve(mediaData);
335
- }
336
- else {
337
- promise = moveToImageDirectory(mediaData, getSession().user ? getSession().user.disablePhotoOrientationAutoFix : false);
320
+ if (!isAndroid() && ['cache', 'tmp'].includes(mediaData)) {
321
+ try {
322
+ mediaData = await moveToImageDirectory(mediaData, getSession().user ? getSession().user.disablePhotoOrientationAutoFix : false);
323
+ }
324
+ catch (err) {
325
+ throw new Error(err);
326
+ }
338
327
  }
339
328
  }
340
- return promise.then((newPath) => {
341
- if (preventUpdateValue) {
342
- return Promise.resolve(newPath);
343
- }
329
+ try {
344
330
  if (this.shouldTagImage()) {
345
- this.showPhotoTagDialog(newPath).then((tag) => {
346
- if (!isNullOrUndefined(tag === null || tag === void 0 ? void 0 : tag.data)) {
347
- this.updateTagData(tag, index);
348
- this.setFieldValue(index, newPath);
349
- this.clearPhotoEdit(index);
350
- if (this.saveGeoloc) {
351
- this.captureGeoloc(index);
352
- }
353
- }
354
- });
355
- }
356
- else {
357
- this.setFieldValue(index, newPath);
358
- this.clearPhotoEdit(index);
359
- if (this.saveGeoloc) {
360
- this.captureGeoloc(index);
361
- }
331
+ const tag = await this.showPhotoTagDialog(mediaData);
332
+ (tag === null || tag === void 0 ? void 0 : tag.data) && this.updateTagData(tag, index);
362
333
  }
363
- });
334
+ await this.setFieldValue(mediaData);
335
+ this.clearPhotoEdit(index);
336
+ this.saveGeoloc && this.captureGeoloc(index);
337
+ }
338
+ catch (err) {
339
+ throw new Error(err);
340
+ }
341
+ return mediaData;
364
342
  }
365
343
  showPhotoTagDialog(imageSrc, value) {
366
344
  const imageTag = document.createElement('yoo-form-capture-tag-dialog');
@@ -487,75 +465,37 @@ const YooFormCaptureComponent = class {
487
465
  this.showImageLoader = false;
488
466
  return;
489
467
  }
490
- return promise.then((imageData) => {
491
- var _a, _b;
492
- const imagesData = Array.isArray(imageData) ? imageData : [imageData];
493
- const hasUnsplash = imagesData.some(d => isUnsplashUrl(d));
494
- if (!imageData && this.showImageLoader) {
468
+ try {
469
+ const res = await promise;
470
+ if (!res && this.showImageLoader) {
495
471
  this.showImageLoader = false;
496
472
  }
497
- if (!hasUnsplash && (this.cropperOptions || this.showCropper)) {
498
- return Promise.all(imagesData.map((data) => this.onOpenCropper(data)))
499
- .then(resolvedData => {
500
- resolvedData === null || resolvedData === void 0 ? void 0 : resolvedData.forEach((res, i) => {
501
- var _a, _b;
502
- this.setFieldValue((_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : i, res);
503
- this.clearPhotoEdit(null);
504
- });
505
- this.showImageLoader = false;
506
- }).catch(() => {
507
- this.showImageLoader = false;
508
- });
509
- }
510
- else {
511
- let newIndex = index;
512
- if (index < 0) {
513
- newIndex = (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
514
- }
515
- if (isMultiMode || useMediaCapture) {
516
- const promises = imageData.map((d, ind) => {
517
- return this.processMediaData(d.fullPath, newIndex >= 0 ? ind + newIndex : newIndex);
518
- });
519
- return Promise.all(promises).then(() => { });
520
- }
521
- else if (isArray(imageData)) {
522
- const newArr = [];
523
- let promises = [];
524
- const preventUpdate = imageData.length !== 1;
525
- if (preventUpdate) {
526
- promises = imageData.map((imageSrc, i) => {
527
- return this.processMediaData(imageSrc, null, preventUpdate).then((newImageSrc) => {
528
- newArr[i] = newImageSrc;
529
- });
530
- });
531
- }
532
- else {
533
- promises = imageData.map((d, ind) => {
534
- return this.processMediaData(d, ind + newIndex);
535
- });
536
- }
537
- return Promise.all(promises).then(() => {
538
- if (preventUpdate) {
539
- this.value = [...[].concat(this.value), ...newArr];
540
- setValueAndValidateInput(this.value, this);
473
+ const imagesData = Array.isArray(res) ? res : [res];
474
+ const hasUnsplash = imagesData.some(d => isUnsplashUrl(d));
475
+ const processImage = async (imageData, index) => {
476
+ var _a;
477
+ try {
478
+ let extractedData = (imageData === null || imageData === void 0 ? void 0 : imageData['data']) || (imageData === null || imageData === void 0 ? void 0 : imageData['path']) || (imageData === null || imageData === void 0 ? void 0 : imageData['fullPath']) || imageData;
479
+ if (!this.shouldTagImage()) {
480
+ const shouldOpenCropper = !hasUnsplash && imagesData.length === 1 && this.allowCrop(imageData);
481
+ const newIndex = Array.isArray(this.value) ? (_a = this.value) === null || _a === void 0 ? void 0 : _a.length : index;
482
+ if (shouldOpenCropper) {
483
+ extractedData = await this.onOpenCropper(imageData);
541
484
  }
542
- this.showImageLoader = false;
543
- });
485
+ await this.processMediaData(extractedData, newIndex);
486
+ }
544
487
  }
545
- else {
488
+ catch (err) {
546
489
  this.showImageLoader = false;
547
- if (imageData && imageData['data']) {
548
- return this.processMediaData(imageData['data'], newIndex);
549
- }
550
- if (imageData && imageData['path']) {
551
- return this.processMediaData(imageData['path'], newIndex);
552
- }
553
- return this.processMediaData(imageData, newIndex);
554
490
  }
555
- }
556
- }).catch(() => {
491
+ };
492
+ await Promise.all(imagesData.map((data, index) => processImage(data, index)));
557
493
  this.showImageLoader = false;
558
- });
494
+ }
495
+ catch (err) {
496
+ this.showImageLoader = false;
497
+ throw new Error(err);
498
+ }
559
499
  }
560
500
  captureVideo(index) {
561
501
  const options = { limit: 1, duration: this.duration || 60, saveToPhotoAlbum: true };
@@ -623,7 +563,7 @@ const YooFormCaptureComponent = class {
623
563
  this.showPhotoTagDialog(ret.data).then((tag) => {
624
564
  if (!isNullOrUndefined(tag === null || tag === void 0 ? void 0 : tag.data)) {
625
565
  this.updateTagData(tag, index);
626
- this.setFieldValue(index, ret.data);
566
+ this.setFieldValue(ret.data);
627
567
  this.clearPhotoEdit(index);
628
568
  if (this.saveGeoloc) {
629
569
  this.captureGeoloc();
@@ -632,7 +572,7 @@ const YooFormCaptureComponent = class {
632
572
  });
633
573
  }
634
574
  else {
635
- this.setFieldValue(index, ret.data);
575
+ this.setFieldValue(ret.data);
636
576
  this.clearPhotoEdit(index);
637
577
  if (this.saveGeoloc) {
638
578
  this.captureGeoloc();
@@ -732,7 +672,7 @@ const YooFormCaptureComponent = class {
732
672
  }
733
673
  else {
734
674
  if (this.multiple && (newImages === null || newImages === void 0 ? void 0 : newImages.length) > 0) {
735
- this.setFieldValue(captureIndex, newImages);
675
+ this.setFieldValue(newImages);
736
676
  }
737
677
  else if (newImages === null || newImages === void 0 ? void 0 : newImages.length) {
738
678
  this.value = newImages[0];
@@ -795,17 +735,17 @@ const YooFormCaptureComponent = class {
795
735
  const tag = await this.showPhotoTagDialog(data);
796
736
  if (!isNullOrUndefined(tag === null || tag === void 0 ? void 0 : tag.data)) {
797
737
  this.updateTagData(tag, index);
798
- this.setFieldValue(index, data);
738
+ this.setFieldValue(data);
799
739
  this.clearPhotoEdit(index);
800
740
  }
801
741
  }
802
742
  else {
803
- this.setFieldValue(index, data);
743
+ this.setFieldValue(data);
804
744
  this.clearPhotoEdit(index);
805
745
  }
806
746
  }
807
747
  else {
808
- this.setFieldValue(index, f);
748
+ this.setFieldValue(f);
809
749
  this.clearPhotoEdit(index);
810
750
  }
811
751
  targetElement.value = null;
@@ -1051,6 +991,7 @@ const YooFormCaptureComponent = class {
1051
991
  }
1052
992
  async onShowActionSheet(value, index, event) {
1053
993
  var _a, _b, _c;
994
+ event === null || event === void 0 ? void 0 : event.stopImmediatePropagation();
1054
995
  if (index && index < 0 && this.max && this.value && this.value.length === this.max) {
1055
996
  this.onShowMaximumCaptureReached();
1056
997
  return;
@@ -491,7 +491,7 @@ const YooFormDynamicComponent = class {
491
491
  const videoValue = fieldData.value;
492
492
  const videoElement = el;
493
493
  if (videoValue) {
494
- videoElement.setFieldValue(undefined, videoValue);
494
+ videoElement.setFieldValue(videoValue);
495
495
  }
496
496
  break;
497
497
  }
@@ -91,8 +91,9 @@ const YooFormHotzonesComponent = class {
91
91
  }
92
92
  }
93
93
  initDraggableTarget() {
94
+ var _a;
94
95
  let draggable;
95
- const imgElement = this.boundElement.querySelector('yoo-img');
96
+ const imgElement = (_a = this.boundElement) === null || _a === void 0 ? void 0 : _a.querySelector('yoo-img');
96
97
  const onDrag = () => {
97
98
  const isHit = draggable.hitTest(imgElement, '50%');
98
99
  this.targetElement.setAttribute('hit', isHit);
@@ -165,7 +165,7 @@ const YooFormTextAreaComponent = class {
165
165
  }
166
166
  }
167
167
  //Timeout here to wait until the content on the textarea get loaded and the textarea got its final size (to be refactored alongside with the component later on
168
- setTimeout(() => {
168
+ !this.isRichText && setTimeout(() => {
169
169
  this.updateTextareaSize();
170
170
  }, 1000);
171
171
  if (this.focusOnRendered) {
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, i as createEvent, h, e as Host, g as getElement } from './index-0a59e2a1.js';
2
2
  import './index-e88a94c1.js';
3
- import { n as compact, y as isEmpty, q as isString, a as isNumber } from './lodash-653c0bcd.js';
3
+ import { n as compact, y as isEmpty, q as isString, a as isNumber, A as isEqual } from './lodash-653c0bcd.js';
4
4
  import { t as toggleElementTapped } from './card-list-helpers-4e01192d.js';
5
5
  import { e as showPhotoEditor, r as removeHtmlFromString, h as execHandlerAndStopEvent, g as getAppContext } from './common-helpers-edb2f727.js';
6
6
  import { ai as isImage, ag as isVideo, aj as downloadFile, t as translate, A as isWeb, Z as translateMulti, ap as replaceAllLinks, av as isCloudinaryLink, dG as isUnsplashUrl, a3 as getSession, ax as parseMarkDown, aI as isPresent, U as Cloudinary, ej as isFieldWithNoValue, X as isNullOrUndefined, dT as isFirefox } from './overlays-7248256e.js';
@@ -272,8 +272,11 @@ const YooCardListComponent = class {
272
272
  !((_e = (_d = this.host) === null || _d === void 0 ? void 0 : _d.classList) === null || _e === void 0 ? void 0 : _e.contains('map')) &&
273
273
  !((_g = (_f = this.host) === null || _f === void 0 ? void 0 : _f.classList) === null || _g === void 0 ? void 0 : _g.contains('grid-cell'))) {
274
274
  return (h("div", { class: "uifield-container" }, h("yoo-form-dynamic", { class: "inline in-card secondary transparent", scrollable: false, forceReadonly: !((_j = (_h = this.host) === null || _h === void 0 ? void 0 : _h.classList) === null || _j === void 0 ? void 0 : _j.contains('form')), slides: [{ title: '', items: this.entry.uiFields.fields }], data: this.entry.uiFields.data, suffix: this.entry.uiFieldsSuffix, showTabs: false, formInputSize: "medium", showRecap: false, isPdf: this.entry.isPdf, onDataChanged: (ev) => {
275
+ var _a, _b;
275
276
  ev.stopPropagation();
276
- this.uiFieldsChanged.emit({ newdata: ev.detail });
277
+ if (!isEqual((_b = (_a = this.entry) === null || _a === void 0 ? void 0 : _a.uiFields) === null || _b === void 0 ? void 0 : _b.data, ev === null || ev === void 0 ? void 0 : ev.detail)) {
278
+ this.uiFieldsChanged.emit({ newdata: ev.detail });
279
+ }
277
280
  } })));
278
281
  }
279
282
  }
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, i as createEvent, h, j as Build, e as Host, g as getElement } from './index-0a59e2a1.js';
2
2
  import { P as PictureSourceType, M as MediaType, i as importMultipleFromLibrary, g as getPicture, b as getVideo, s as showAudioRecorder, c as MediaCapture, a as getVideoDevices } from './camera-helpers-b0eccbf9.js';
3
- import { t as translate, b5 as showToast, dL as getFormCapturedFileSize, ae as showAlert, ar as pipes, X as isNullOrUndefined, aV as isImageUrl, ah as isGif, dG as isUnsplashUrl, A as isWeb, ai as isImage, ag as isVideo, dF as isAudio, j as isNativeMobile, cm as addFilePrefix, k as isAndroid, cp as moveToImageDirectory, a3 as getSession, z as showModal, H as isIOS, G as isIphoneX, b$ as StatusBar, dM as isLenovo, af as showActionSheet, dN as updatePathSessionId, bS as isSafari, P as getAsyncExtraData, dx as asyncWaterfall, cn as read, R as isNativeFilePath, aj as downloadFile, an as isFile, dO as getMimeType, bn as isOffline, dP as hasLargeFile, Z as translateMulti, aD as showContextMenu, ay as isPhotoEdited, du as images, dQ as audios, dv as videos, az as changeExtension, av as isCloudinaryLink } from './overlays-7248256e.js';
3
+ import { t as translate, b5 as showToast, dL as getFormCapturedFileSize, ae as showAlert, ar as pipes, X as isNullOrUndefined, ai as isImage, ah as isGif, dG as isUnsplashUrl, A as isWeb, ag as isVideo, dF as isAudio, j as isNativeMobile, aV as isImageUrl, cm as addFilePrefix, k as isAndroid, cp as moveToImageDirectory, a3 as getSession, z as showModal, H as isIOS, G as isIphoneX, b$ as StatusBar, dM as isLenovo, af as showActionSheet, dN as updatePathSessionId, bS as isSafari, P as getAsyncExtraData, dx as asyncWaterfall, cn as read, R as isNativeFilePath, aj as downloadFile, an as isFile, dO as getMimeType, bn as isOffline, dP as hasLargeFile, Z as translateMulti, aD as showContextMenu, ay as isPhotoEdited, du as images, dQ as audios, dv as videos, az as changeExtension, av as isCloudinaryLink } from './overlays-7248256e.js';
4
4
  import './index-e88a94c1.js';
5
5
  import { k as keys, z as intersection, a as isNumber, i as isArray, a4 as assignInWith, s as assign, n as compact, t as clone, E as isUndefined } from './lodash-653c0bcd.js';
6
6
  import { c as querySelectorAllDeep, q as querySelectorDeep, i as showImageCropper, e as showPhotoEditor, a as showSlidesMedia, g as getAppContext } from './common-helpers-edb2f727.js';
@@ -58,15 +58,9 @@ const YooFormCaptureComponent = class {
58
58
  this.updateExtraData(extraData);
59
59
  }
60
60
  /** If there is index, the field is a multiphoto */
61
- async setFieldValue(index, data) {
62
- if (index === undefined) {
63
- setValueAndValidateInput(data, this);
64
- }
65
- else {
66
- const newValue = this.value ? [...this.value] : [];
67
- newValue[index] = data;
68
- setValueAndValidateInput(newValue, this);
69
- }
61
+ async setFieldValue(data) {
62
+ this.multiple ? this.value.push(data) : this.value = data;
63
+ setValueAndValidateInput(this.value, this);
70
64
  }
71
65
  async stopImageRecognitionProcess(isCancelled = false) {
72
66
  this.imageRecoCancelled = isCancelled;
@@ -258,7 +252,7 @@ const YooFormCaptureComponent = class {
258
252
  }
259
253
  allowCrop(file) {
260
254
  var _a;
261
- return (((_a = this.cropperOptions) === null || _a === void 0 ? void 0 : _a.cropRatio) > 0 || this.showCropper) && isImageUrl(file) && !isGif(file) && (!(typeof file === 'string' && isUnsplashUrl(file)) || isWeb(this.host));
255
+ return (((_a = this.cropperOptions) === null || _a === void 0 ? void 0 : _a.cropRatio) > 0 || this.showCropper) && isImage(file) && !isGif(file) && (!(typeof file === 'string' && isUnsplashUrl(file)) || isWeb(this.host));
262
256
  }
263
257
  removeAllCapture() {
264
258
  this.value = [];
@@ -317,50 +311,34 @@ const YooFormCaptureComponent = class {
317
311
  }
318
312
  }
319
313
  }
320
- processMediaData(mediaData, index, preventUpdateValue = false) {
321
- let promise;
322
- if (!mediaData) {
323
- return (promise = Promise.resolve(mediaData));
324
- }
325
- if (mediaData && mediaData.indexOf('?') > 0) {
314
+ async processMediaData(mediaData, index) {
315
+ if (mediaData === null || mediaData === void 0 ? void 0 : mediaData.includes('?')) {
326
316
  mediaData = mediaData.substring(0, mediaData.indexOf('?'));
327
317
  }
328
- if (mediaData && mediaData.startsWith && mediaData.startsWith('data:image')) {
329
- promise = Promise.resolve(mediaData);
330
- }
331
- else {
318
+ else if (mediaData && !isImageUrl(mediaData)) {
332
319
  mediaData = addFilePrefix(mediaData);
333
- if (isAndroid() && mediaData.indexOf('tmp') < 0 && mediaData.indexOf('cache') < 0) {
334
- promise = Promise.resolve(mediaData);
335
- }
336
- else {
337
- promise = moveToImageDirectory(mediaData, getSession().user ? getSession().user.disablePhotoOrientationAutoFix : false);
320
+ if (!isAndroid() && ['cache', 'tmp'].includes(mediaData)) {
321
+ try {
322
+ mediaData = await moveToImageDirectory(mediaData, getSession().user ? getSession().user.disablePhotoOrientationAutoFix : false);
323
+ }
324
+ catch (err) {
325
+ throw new Error(err);
326
+ }
338
327
  }
339
328
  }
340
- return promise.then((newPath) => {
341
- if (preventUpdateValue) {
342
- return Promise.resolve(newPath);
343
- }
329
+ try {
344
330
  if (this.shouldTagImage()) {
345
- this.showPhotoTagDialog(newPath).then((tag) => {
346
- if (!isNullOrUndefined(tag === null || tag === void 0 ? void 0 : tag.data)) {
347
- this.updateTagData(tag, index);
348
- this.setFieldValue(index, newPath);
349
- this.clearPhotoEdit(index);
350
- if (this.saveGeoloc) {
351
- this.captureGeoloc(index);
352
- }
353
- }
354
- });
355
- }
356
- else {
357
- this.setFieldValue(index, newPath);
358
- this.clearPhotoEdit(index);
359
- if (this.saveGeoloc) {
360
- this.captureGeoloc(index);
361
- }
331
+ const tag = await this.showPhotoTagDialog(mediaData);
332
+ (tag === null || tag === void 0 ? void 0 : tag.data) && this.updateTagData(tag, index);
362
333
  }
363
- });
334
+ await this.setFieldValue(mediaData);
335
+ this.clearPhotoEdit(index);
336
+ this.saveGeoloc && this.captureGeoloc(index);
337
+ }
338
+ catch (err) {
339
+ throw new Error(err);
340
+ }
341
+ return mediaData;
364
342
  }
365
343
  showPhotoTagDialog(imageSrc, value) {
366
344
  const imageTag = document.createElement('yoo-form-capture-tag-dialog');
@@ -487,75 +465,37 @@ const YooFormCaptureComponent = class {
487
465
  this.showImageLoader = false;
488
466
  return;
489
467
  }
490
- return promise.then((imageData) => {
491
- var _a, _b;
492
- const imagesData = Array.isArray(imageData) ? imageData : [imageData];
493
- const hasUnsplash = imagesData.some(d => isUnsplashUrl(d));
494
- if (!imageData && this.showImageLoader) {
468
+ try {
469
+ const res = await promise;
470
+ if (!res && this.showImageLoader) {
495
471
  this.showImageLoader = false;
496
472
  }
497
- if (!hasUnsplash && (this.cropperOptions || this.showCropper)) {
498
- return Promise.all(imagesData.map((data) => this.onOpenCropper(data)))
499
- .then(resolvedData => {
500
- resolvedData === null || resolvedData === void 0 ? void 0 : resolvedData.forEach((res, i) => {
501
- var _a, _b;
502
- this.setFieldValue((_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : i, res);
503
- this.clearPhotoEdit(null);
504
- });
505
- this.showImageLoader = false;
506
- }).catch(() => {
507
- this.showImageLoader = false;
508
- });
509
- }
510
- else {
511
- let newIndex = index;
512
- if (index < 0) {
513
- newIndex = (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
514
- }
515
- if (isMultiMode || useMediaCapture) {
516
- const promises = imageData.map((d, ind) => {
517
- return this.processMediaData(d.fullPath, newIndex >= 0 ? ind + newIndex : newIndex);
518
- });
519
- return Promise.all(promises).then(() => { });
520
- }
521
- else if (isArray(imageData)) {
522
- const newArr = [];
523
- let promises = [];
524
- const preventUpdate = imageData.length !== 1;
525
- if (preventUpdate) {
526
- promises = imageData.map((imageSrc, i) => {
527
- return this.processMediaData(imageSrc, null, preventUpdate).then((newImageSrc) => {
528
- newArr[i] = newImageSrc;
529
- });
530
- });
531
- }
532
- else {
533
- promises = imageData.map((d, ind) => {
534
- return this.processMediaData(d, ind + newIndex);
535
- });
536
- }
537
- return Promise.all(promises).then(() => {
538
- if (preventUpdate) {
539
- this.value = [...[].concat(this.value), ...newArr];
540
- setValueAndValidateInput(this.value, this);
473
+ const imagesData = Array.isArray(res) ? res : [res];
474
+ const hasUnsplash = imagesData.some(d => isUnsplashUrl(d));
475
+ const processImage = async (imageData, index) => {
476
+ var _a;
477
+ try {
478
+ let extractedData = (imageData === null || imageData === void 0 ? void 0 : imageData['data']) || (imageData === null || imageData === void 0 ? void 0 : imageData['path']) || (imageData === null || imageData === void 0 ? void 0 : imageData['fullPath']) || imageData;
479
+ if (!this.shouldTagImage()) {
480
+ const shouldOpenCropper = !hasUnsplash && imagesData.length === 1 && this.allowCrop(imageData);
481
+ const newIndex = Array.isArray(this.value) ? (_a = this.value) === null || _a === void 0 ? void 0 : _a.length : index;
482
+ if (shouldOpenCropper) {
483
+ extractedData = await this.onOpenCropper(imageData);
541
484
  }
542
- this.showImageLoader = false;
543
- });
485
+ await this.processMediaData(extractedData, newIndex);
486
+ }
544
487
  }
545
- else {
488
+ catch (err) {
546
489
  this.showImageLoader = false;
547
- if (imageData && imageData['data']) {
548
- return this.processMediaData(imageData['data'], newIndex);
549
- }
550
- if (imageData && imageData['path']) {
551
- return this.processMediaData(imageData['path'], newIndex);
552
- }
553
- return this.processMediaData(imageData, newIndex);
554
490
  }
555
- }
556
- }).catch(() => {
491
+ };
492
+ await Promise.all(imagesData.map((data, index) => processImage(data, index)));
557
493
  this.showImageLoader = false;
558
- });
494
+ }
495
+ catch (err) {
496
+ this.showImageLoader = false;
497
+ throw new Error(err);
498
+ }
559
499
  }
560
500
  captureVideo(index) {
561
501
  const options = { limit: 1, duration: this.duration || 60, saveToPhotoAlbum: true };
@@ -623,7 +563,7 @@ const YooFormCaptureComponent = class {
623
563
  this.showPhotoTagDialog(ret.data).then((tag) => {
624
564
  if (!isNullOrUndefined(tag === null || tag === void 0 ? void 0 : tag.data)) {
625
565
  this.updateTagData(tag, index);
626
- this.setFieldValue(index, ret.data);
566
+ this.setFieldValue(ret.data);
627
567
  this.clearPhotoEdit(index);
628
568
  if (this.saveGeoloc) {
629
569
  this.captureGeoloc();
@@ -632,7 +572,7 @@ const YooFormCaptureComponent = class {
632
572
  });
633
573
  }
634
574
  else {
635
- this.setFieldValue(index, ret.data);
575
+ this.setFieldValue(ret.data);
636
576
  this.clearPhotoEdit(index);
637
577
  if (this.saveGeoloc) {
638
578
  this.captureGeoloc();
@@ -732,7 +672,7 @@ const YooFormCaptureComponent = class {
732
672
  }
733
673
  else {
734
674
  if (this.multiple && (newImages === null || newImages === void 0 ? void 0 : newImages.length) > 0) {
735
- this.setFieldValue(captureIndex, newImages);
675
+ this.setFieldValue(newImages);
736
676
  }
737
677
  else if (newImages === null || newImages === void 0 ? void 0 : newImages.length) {
738
678
  this.value = newImages[0];
@@ -795,17 +735,17 @@ const YooFormCaptureComponent = class {
795
735
  const tag = await this.showPhotoTagDialog(data);
796
736
  if (!isNullOrUndefined(tag === null || tag === void 0 ? void 0 : tag.data)) {
797
737
  this.updateTagData(tag, index);
798
- this.setFieldValue(index, data);
738
+ this.setFieldValue(data);
799
739
  this.clearPhotoEdit(index);
800
740
  }
801
741
  }
802
742
  else {
803
- this.setFieldValue(index, data);
743
+ this.setFieldValue(data);
804
744
  this.clearPhotoEdit(index);
805
745
  }
806
746
  }
807
747
  else {
808
- this.setFieldValue(index, f);
748
+ this.setFieldValue(f);
809
749
  this.clearPhotoEdit(index);
810
750
  }
811
751
  targetElement.value = null;
@@ -1051,6 +991,7 @@ const YooFormCaptureComponent = class {
1051
991
  }
1052
992
  async onShowActionSheet(value, index, event) {
1053
993
  var _a, _b, _c;
994
+ event === null || event === void 0 ? void 0 : event.stopImmediatePropagation();
1054
995
  if (index && index < 0 && this.max && this.value && this.value.length === this.max) {
1055
996
  this.onShowMaximumCaptureReached();
1056
997
  return;
@@ -491,7 +491,7 @@ const YooFormDynamicComponent = class {
491
491
  const videoValue = fieldData.value;
492
492
  const videoElement = el;
493
493
  if (videoValue) {
494
- videoElement.setFieldValue(undefined, videoValue);
494
+ videoElement.setFieldValue(videoValue);
495
495
  }
496
496
  break;
497
497
  }
@@ -91,8 +91,9 @@ const YooFormHotzonesComponent = class {
91
91
  }
92
92
  }
93
93
  initDraggableTarget() {
94
+ var _a;
94
95
  let draggable;
95
- const imgElement = this.boundElement.querySelector('yoo-img');
96
+ const imgElement = (_a = this.boundElement) === null || _a === void 0 ? void 0 : _a.querySelector('yoo-img');
96
97
  const onDrag = () => {
97
98
  const isHit = draggable.hitTest(imgElement, '50%');
98
99
  this.targetElement.setAttribute('hit', isHit);
@@ -165,7 +165,7 @@ const YooFormTextAreaComponent = class {
165
165
  }
166
166
  }
167
167
  //Timeout here to wait until the content on the textarea get loaded and the textarea got its final size (to be refactored alongside with the component later on
168
- setTimeout(() => {
168
+ !this.isRichText && setTimeout(() => {
169
169
  this.updateTextareaSize();
170
170
  }, 1000);
171
171
  if (this.focusOnRendered) {
@@ -100,7 +100,7 @@ export declare class YooFormCaptureComponent implements IFormCapture {
100
100
  updateAutocompleteValues(tags: any): Promise<void>;
101
101
  updateData(value: any, extraData: any): Promise<void>;
102
102
  /** If there is index, the field is a multiphoto */
103
- setFieldValue(index: number, data: any): Promise<void>;
103
+ setFieldValue(data: any): Promise<void>;
104
104
  stopImageRecognitionProcess(isCancelled?: boolean): Promise<void>;
105
105
  onPhotoUploadComplete(): Promise<void>;
106
106
  onPhotoUploadProgressUpdate(progress: number, index: number): Promise<void>;
@@ -126,7 +126,7 @@ export declare class YooFormCaptureComponent implements IFormCapture {
126
126
  isMedia(file: any): boolean;
127
127
  /** for webcam, choose which device to take photo/video */
128
128
  capture(device: any, index?: number): void;
129
- processMediaData(mediaData: any, index: any, preventUpdateValue?: boolean): Promise<any>;
129
+ processMediaData(mediaData: string, index: number): Promise<string>;
130
130
  showPhotoTagDialog(imageSrc: string, value?: any): Promise<import("@shared/interfaces").IOverlayEventDetail<any>>;
131
131
  updateTagData(tag: any, index?: number): void;
132
132
  updateStitchDirection(direction: StitchDirection, index: number): void;
@@ -140,9 +140,9 @@ export declare class YooFormCaptureComponent implements IFormCapture {
140
140
  regularMode?: boolean;
141
141
  stitchDirection?: StitchDirection;
142
142
  }): Promise<any>;
143
- capturePhoto(useLibrary: boolean, index?: number): Promise<any>;
143
+ capturePhoto(useLibrary: boolean, index?: number): Promise<void>;
144
144
  captureVideo(index: number): Promise<void>;
145
- captureAudio(index: number): Promise<any>;
145
+ captureAudio(index: number): Promise<string | void>;
146
146
  noAudio(): void;
147
147
  fixSessionIdPath(): void;
148
148
  fixPathAndGetValue(files: MediaFile[]): string;
@@ -2012,7 +2012,7 @@ export namespace Components {
2012
2012
  /**
2013
2013
  * If there is index, the field is a multiphoto
2014
2014
  */
2015
- "setFieldValue": (index: number, data: any) => Promise<void>;
2015
+ "setFieldValue": (data: any) => Promise<void>;
2016
2016
  "showCropper": boolean;
2017
2017
  "size"?: TSize;
2018
2018
  "stopImageRecognitionProcess": (isCancelled?: boolean) => Promise<void>;