@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
@@ -276,8 +276,11 @@ const YooCardListComponent = class {
276
276
  !((_e = (_d = this.host) === null || _d === void 0 ? void 0 : _d.classList) === null || _e === void 0 ? void 0 : _e.contains('map')) &&
277
277
  !((_g = (_f = this.host) === null || _f === void 0 ? void 0 : _f.classList) === null || _g === void 0 ? void 0 : _g.contains('grid-cell'))) {
278
278
  return (index.h("div", { class: "uifield-container" }, index.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) => {
279
+ var _a, _b;
279
280
  ev.stopPropagation();
280
- this.uiFieldsChanged.emit({ newdata: ev.detail });
281
+ if (!lodash.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)) {
282
+ this.uiFieldsChanged.emit({ newdata: ev.detail });
283
+ }
281
284
  } })));
282
285
  }
283
286
  }
@@ -62,15 +62,9 @@ const YooFormCaptureComponent = class {
62
62
  this.updateExtraData(extraData);
63
63
  }
64
64
  /** If there is index, the field is a multiphoto */
65
- async setFieldValue(index, data) {
66
- if (index === undefined) {
67
- formInputHelpers.setValueAndValidateInput(data, this);
68
- }
69
- else {
70
- const newValue = this.value ? [...this.value] : [];
71
- newValue[index] = data;
72
- formInputHelpers.setValueAndValidateInput(newValue, this);
73
- }
65
+ async setFieldValue(data) {
66
+ this.multiple ? this.value.push(data) : this.value = data;
67
+ formInputHelpers.setValueAndValidateInput(this.value, this);
74
68
  }
75
69
  async stopImageRecognitionProcess(isCancelled = false) {
76
70
  this.imageRecoCancelled = isCancelled;
@@ -262,7 +256,7 @@ const YooFormCaptureComponent = class {
262
256
  }
263
257
  allowCrop(file) {
264
258
  var _a;
265
- return (((_a = this.cropperOptions) === null || _a === void 0 ? void 0 : _a.cropRatio) > 0 || this.showCropper) && overlays.isImageUrl(file) && !overlays.isGif(file) && (!(typeof file === 'string' && overlays.isUnsplashUrl(file)) || overlays.isWeb(this.host));
259
+ return (((_a = this.cropperOptions) === null || _a === void 0 ? void 0 : _a.cropRatio) > 0 || this.showCropper) && overlays.isImage(file) && !overlays.isGif(file) && (!(typeof file === 'string' && overlays.isUnsplashUrl(file)) || overlays.isWeb(this.host));
266
260
  }
267
261
  removeAllCapture() {
268
262
  this.value = [];
@@ -321,50 +315,34 @@ const YooFormCaptureComponent = class {
321
315
  }
322
316
  }
323
317
  }
324
- processMediaData(mediaData, index, preventUpdateValue = false) {
325
- let promise;
326
- if (!mediaData) {
327
- return (promise = Promise.resolve(mediaData));
328
- }
329
- if (mediaData && mediaData.indexOf('?') > 0) {
318
+ async processMediaData(mediaData, index) {
319
+ if (mediaData === null || mediaData === void 0 ? void 0 : mediaData.includes('?')) {
330
320
  mediaData = mediaData.substring(0, mediaData.indexOf('?'));
331
321
  }
332
- if (mediaData && mediaData.startsWith && mediaData.startsWith('data:image')) {
333
- promise = Promise.resolve(mediaData);
334
- }
335
- else {
322
+ else if (mediaData && !overlays.isImageUrl(mediaData)) {
336
323
  mediaData = overlays.addFilePrefix(mediaData);
337
- if (overlays.isAndroid() && mediaData.indexOf('tmp') < 0 && mediaData.indexOf('cache') < 0) {
338
- promise = Promise.resolve(mediaData);
339
- }
340
- else {
341
- promise = overlays.moveToImageDirectory(mediaData, overlays.getSession().user ? overlays.getSession().user.disablePhotoOrientationAutoFix : false);
324
+ if (!overlays.isAndroid() && ['cache', 'tmp'].includes(mediaData)) {
325
+ try {
326
+ mediaData = await overlays.moveToImageDirectory(mediaData, overlays.getSession().user ? overlays.getSession().user.disablePhotoOrientationAutoFix : false);
327
+ }
328
+ catch (err) {
329
+ throw new Error(err);
330
+ }
342
331
  }
343
332
  }
344
- return promise.then((newPath) => {
345
- if (preventUpdateValue) {
346
- return Promise.resolve(newPath);
347
- }
333
+ try {
348
334
  if (this.shouldTagImage()) {
349
- this.showPhotoTagDialog(newPath).then((tag) => {
350
- if (!overlays.isNullOrUndefined(tag === null || tag === void 0 ? void 0 : tag.data)) {
351
- this.updateTagData(tag, index);
352
- this.setFieldValue(index, newPath);
353
- this.clearPhotoEdit(index);
354
- if (this.saveGeoloc) {
355
- this.captureGeoloc(index);
356
- }
357
- }
358
- });
359
- }
360
- else {
361
- this.setFieldValue(index, newPath);
362
- this.clearPhotoEdit(index);
363
- if (this.saveGeoloc) {
364
- this.captureGeoloc(index);
365
- }
335
+ const tag = await this.showPhotoTagDialog(mediaData);
336
+ (tag === null || tag === void 0 ? void 0 : tag.data) && this.updateTagData(tag, index);
366
337
  }
367
- });
338
+ await this.setFieldValue(mediaData);
339
+ this.clearPhotoEdit(index);
340
+ this.saveGeoloc && this.captureGeoloc(index);
341
+ }
342
+ catch (err) {
343
+ throw new Error(err);
344
+ }
345
+ return mediaData;
368
346
  }
369
347
  showPhotoTagDialog(imageSrc, value) {
370
348
  const imageTag = document.createElement('yoo-form-capture-tag-dialog');
@@ -491,75 +469,37 @@ const YooFormCaptureComponent = class {
491
469
  this.showImageLoader = false;
492
470
  return;
493
471
  }
494
- return promise.then((imageData) => {
495
- var _a, _b;
496
- const imagesData = Array.isArray(imageData) ? imageData : [imageData];
497
- const hasUnsplash = imagesData.some(d => overlays.isUnsplashUrl(d));
498
- if (!imageData && this.showImageLoader) {
472
+ try {
473
+ const res = await promise;
474
+ if (!res && this.showImageLoader) {
499
475
  this.showImageLoader = false;
500
476
  }
501
- if (!hasUnsplash && (this.cropperOptions || this.showCropper)) {
502
- return Promise.all(imagesData.map((data) => this.onOpenCropper(data)))
503
- .then(resolvedData => {
504
- resolvedData === null || resolvedData === void 0 ? void 0 : resolvedData.forEach((res, i) => {
505
- var _a, _b;
506
- this.setFieldValue((_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : i, res);
507
- this.clearPhotoEdit(null);
508
- });
509
- this.showImageLoader = false;
510
- }).catch(() => {
511
- this.showImageLoader = false;
512
- });
513
- }
514
- else {
515
- let newIndex = index;
516
- if (index < 0) {
517
- newIndex = (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
518
- }
519
- if (isMultiMode || useMediaCapture) {
520
- const promises = imageData.map((d, ind) => {
521
- return this.processMediaData(d.fullPath, newIndex >= 0 ? ind + newIndex : newIndex);
522
- });
523
- return Promise.all(promises).then(() => { });
524
- }
525
- else if (lodash.isArray(imageData)) {
526
- const newArr = [];
527
- let promises = [];
528
- const preventUpdate = imageData.length !== 1;
529
- if (preventUpdate) {
530
- promises = imageData.map((imageSrc, i) => {
531
- return this.processMediaData(imageSrc, null, preventUpdate).then((newImageSrc) => {
532
- newArr[i] = newImageSrc;
533
- });
534
- });
535
- }
536
- else {
537
- promises = imageData.map((d, ind) => {
538
- return this.processMediaData(d, ind + newIndex);
539
- });
540
- }
541
- return Promise.all(promises).then(() => {
542
- if (preventUpdate) {
543
- this.value = [...[].concat(this.value), ...newArr];
544
- formInputHelpers.setValueAndValidateInput(this.value, this);
477
+ const imagesData = Array.isArray(res) ? res : [res];
478
+ const hasUnsplash = imagesData.some(d => overlays.isUnsplashUrl(d));
479
+ const processImage = async (imageData, index) => {
480
+ var _a;
481
+ try {
482
+ 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;
483
+ if (!this.shouldTagImage()) {
484
+ const shouldOpenCropper = !hasUnsplash && imagesData.length === 1 && this.allowCrop(imageData);
485
+ const newIndex = Array.isArray(this.value) ? (_a = this.value) === null || _a === void 0 ? void 0 : _a.length : index;
486
+ if (shouldOpenCropper) {
487
+ extractedData = await this.onOpenCropper(imageData);
545
488
  }
546
- this.showImageLoader = false;
547
- });
489
+ await this.processMediaData(extractedData, newIndex);
490
+ }
548
491
  }
549
- else {
492
+ catch (err) {
550
493
  this.showImageLoader = false;
551
- if (imageData && imageData['data']) {
552
- return this.processMediaData(imageData['data'], newIndex);
553
- }
554
- if (imageData && imageData['path']) {
555
- return this.processMediaData(imageData['path'], newIndex);
556
- }
557
- return this.processMediaData(imageData, newIndex);
558
494
  }
559
- }
560
- }).catch(() => {
495
+ };
496
+ await Promise.all(imagesData.map((data, index) => processImage(data, index)));
561
497
  this.showImageLoader = false;
562
- });
498
+ }
499
+ catch (err) {
500
+ this.showImageLoader = false;
501
+ throw new Error(err);
502
+ }
563
503
  }
564
504
  captureVideo(index) {
565
505
  const options = { limit: 1, duration: this.duration || 60, saveToPhotoAlbum: true };
@@ -627,7 +567,7 @@ const YooFormCaptureComponent = class {
627
567
  this.showPhotoTagDialog(ret.data).then((tag) => {
628
568
  if (!overlays.isNullOrUndefined(tag === null || tag === void 0 ? void 0 : tag.data)) {
629
569
  this.updateTagData(tag, index);
630
- this.setFieldValue(index, ret.data);
570
+ this.setFieldValue(ret.data);
631
571
  this.clearPhotoEdit(index);
632
572
  if (this.saveGeoloc) {
633
573
  this.captureGeoloc();
@@ -636,7 +576,7 @@ const YooFormCaptureComponent = class {
636
576
  });
637
577
  }
638
578
  else {
639
- this.setFieldValue(index, ret.data);
579
+ this.setFieldValue(ret.data);
640
580
  this.clearPhotoEdit(index);
641
581
  if (this.saveGeoloc) {
642
582
  this.captureGeoloc();
@@ -736,7 +676,7 @@ const YooFormCaptureComponent = class {
736
676
  }
737
677
  else {
738
678
  if (this.multiple && (newImages === null || newImages === void 0 ? void 0 : newImages.length) > 0) {
739
- this.setFieldValue(captureIndex, newImages);
679
+ this.setFieldValue(newImages);
740
680
  }
741
681
  else if (newImages === null || newImages === void 0 ? void 0 : newImages.length) {
742
682
  this.value = newImages[0];
@@ -799,17 +739,17 @@ const YooFormCaptureComponent = class {
799
739
  const tag = await this.showPhotoTagDialog(data);
800
740
  if (!overlays.isNullOrUndefined(tag === null || tag === void 0 ? void 0 : tag.data)) {
801
741
  this.updateTagData(tag, index);
802
- this.setFieldValue(index, data);
742
+ this.setFieldValue(data);
803
743
  this.clearPhotoEdit(index);
804
744
  }
805
745
  }
806
746
  else {
807
- this.setFieldValue(index, data);
747
+ this.setFieldValue(data);
808
748
  this.clearPhotoEdit(index);
809
749
  }
810
750
  }
811
751
  else {
812
- this.setFieldValue(index, f);
752
+ this.setFieldValue(f);
813
753
  this.clearPhotoEdit(index);
814
754
  }
815
755
  targetElement.value = null;
@@ -1055,6 +995,7 @@ const YooFormCaptureComponent = class {
1055
995
  }
1056
996
  async onShowActionSheet(value, index, event) {
1057
997
  var _a, _b, _c;
998
+ event === null || event === void 0 ? void 0 : event.stopImmediatePropagation();
1058
999
  if (index && index < 0 && this.max && this.value && this.value.length === this.max) {
1059
1000
  this.onShowMaximumCaptureReached();
1060
1001
  return;
@@ -495,7 +495,7 @@ const YooFormDynamicComponent = class {
495
495
  const videoValue = fieldData.value;
496
496
  const videoElement = el;
497
497
  if (videoValue) {
498
- videoElement.setFieldValue(undefined, videoValue);
498
+ videoElement.setFieldValue(videoValue);
499
499
  }
500
500
  break;
501
501
  }
@@ -95,8 +95,9 @@ const YooFormHotzonesComponent = class {
95
95
  }
96
96
  }
97
97
  initDraggableTarget() {
98
+ var _a;
98
99
  let draggable;
99
- const imgElement = this.boundElement.querySelector('yoo-img');
100
+ const imgElement = (_a = this.boundElement) === null || _a === void 0 ? void 0 : _a.querySelector('yoo-img');
100
101
  const onDrag = () => {
101
102
  const isHit = draggable.hitTest(imgElement, '50%');
102
103
  this.targetElement.setAttribute('hit', isHit);
@@ -169,7 +169,7 @@ const YooFormTextAreaComponent = class {
169
169
  }
170
170
  }
171
171
  //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
172
- setTimeout(() => {
172
+ !this.isRichText && setTimeout(() => {
173
173
  this.updateTextareaSize();
174
174
  }, 1000);
175
175
  if (this.focusOnRendered) {
@@ -1,6 +1,6 @@
1
1
  import { Cloudinary, downloadFile, getSession, isCloudinaryLink, isFieldWithNoValue, isFirefox, isImage, isNullOrUndefined, isPresent, isUnsplashUrl, isVideo, isWeb, parseMarkDown, replaceAllLinks, translate, translateMulti } from '@shared/utils';
2
2
  import { h, Host } from '@stencil/core';
3
- import { compact, isEmpty, isNumber, isString } from 'lodash-es';
3
+ import { compact, isEmpty, isEqual, isNumber, isString } from 'lodash-es';
4
4
  import { toggleElementTapped } from '../../../../utils/helpers/card-list-helpers';
5
5
  import { execHandlerAndStopEvent, getAppContext, removeHtmlFromString, showPhotoEditor } from '../../../../utils/helpers/common-helpers';
6
6
  const MAX_AVATAR_DISPLAY = 3;
@@ -264,8 +264,11 @@ export class YooCardListComponent {
264
264
  !((_e = (_d = this.host) === null || _d === void 0 ? void 0 : _d.classList) === null || _e === void 0 ? void 0 : _e.contains('map')) &&
265
265
  !((_g = (_f = this.host) === null || _f === void 0 ? void 0 : _f.classList) === null || _g === void 0 ? void 0 : _g.contains('grid-cell'))) {
266
266
  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) => {
267
+ var _a, _b;
267
268
  ev.stopPropagation();
268
- this.uiFieldsChanged.emit({ newdata: ev.detail });
269
+ 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)) {
270
+ this.uiFieldsChanged.emit({ newdata: ev.detail });
271
+ }
269
272
  } })));
270
273
  }
271
274
  }
@@ -37,15 +37,9 @@ export class YooFormCaptureComponent {
37
37
  this.updateExtraData(extraData);
38
38
  }
39
39
  /** If there is index, the field is a multiphoto */
40
- async setFieldValue(index, data) {
41
- if (index === undefined) {
42
- setValueAndValidateInput(data, this);
43
- }
44
- else {
45
- const newValue = this.value ? [...this.value] : [];
46
- newValue[index] = data;
47
- setValueAndValidateInput(newValue, this);
48
- }
40
+ async setFieldValue(data) {
41
+ this.multiple ? this.value.push(data) : this.value = data;
42
+ setValueAndValidateInput(this.value, this);
49
43
  }
50
44
  async stopImageRecognitionProcess(isCancelled = false) {
51
45
  this.imageRecoCancelled = isCancelled;
@@ -237,7 +231,7 @@ export class YooFormCaptureComponent {
237
231
  }
238
232
  allowCrop(file) {
239
233
  var _a;
240
- 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));
234
+ 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));
241
235
  }
242
236
  removeAllCapture() {
243
237
  this.value = [];
@@ -296,50 +290,34 @@ export class YooFormCaptureComponent {
296
290
  }
297
291
  }
298
292
  }
299
- processMediaData(mediaData, index, preventUpdateValue = false) {
300
- let promise;
301
- if (!mediaData) {
302
- return (promise = Promise.resolve(mediaData));
303
- }
304
- if (mediaData && mediaData.indexOf('?') > 0) {
293
+ async processMediaData(mediaData, index) {
294
+ if (mediaData === null || mediaData === void 0 ? void 0 : mediaData.includes('?')) {
305
295
  mediaData = mediaData.substring(0, mediaData.indexOf('?'));
306
296
  }
307
- if (mediaData && mediaData.startsWith && mediaData.startsWith('data:image')) {
308
- promise = Promise.resolve(mediaData);
309
- }
310
- else {
297
+ else if (mediaData && !isImageUrl(mediaData)) {
311
298
  mediaData = addFilePrefix(mediaData);
312
- if (isAndroid() && mediaData.indexOf('tmp') < 0 && mediaData.indexOf('cache') < 0) {
313
- promise = Promise.resolve(mediaData);
314
- }
315
- else {
316
- promise = moveToImageDirectory(mediaData, getSession().user ? getSession().user.disablePhotoOrientationAutoFix : false);
299
+ if (!isAndroid() && ['cache', 'tmp'].includes(mediaData)) {
300
+ try {
301
+ mediaData = await moveToImageDirectory(mediaData, getSession().user ? getSession().user.disablePhotoOrientationAutoFix : false);
302
+ }
303
+ catch (err) {
304
+ throw new Error(err);
305
+ }
317
306
  }
318
307
  }
319
- return promise.then((newPath) => {
320
- if (preventUpdateValue) {
321
- return Promise.resolve(newPath);
322
- }
308
+ try {
323
309
  if (this.shouldTagImage()) {
324
- this.showPhotoTagDialog(newPath).then((tag) => {
325
- if (!isNullOrUndefined(tag === null || tag === void 0 ? void 0 : tag.data)) {
326
- this.updateTagData(tag, index);
327
- this.setFieldValue(index, newPath);
328
- this.clearPhotoEdit(index);
329
- if (this.saveGeoloc) {
330
- this.captureGeoloc(index);
331
- }
332
- }
333
- });
334
- }
335
- else {
336
- this.setFieldValue(index, newPath);
337
- this.clearPhotoEdit(index);
338
- if (this.saveGeoloc) {
339
- this.captureGeoloc(index);
340
- }
310
+ const tag = await this.showPhotoTagDialog(mediaData);
311
+ (tag === null || tag === void 0 ? void 0 : tag.data) && this.updateTagData(tag, index);
341
312
  }
342
- });
313
+ await this.setFieldValue(mediaData);
314
+ this.clearPhotoEdit(index);
315
+ this.saveGeoloc && this.captureGeoloc(index);
316
+ }
317
+ catch (err) {
318
+ throw new Error(err);
319
+ }
320
+ return mediaData;
343
321
  }
344
322
  showPhotoTagDialog(imageSrc, value) {
345
323
  const imageTag = document.createElement('yoo-form-capture-tag-dialog');
@@ -466,75 +444,37 @@ export class YooFormCaptureComponent {
466
444
  this.showImageLoader = false;
467
445
  return;
468
446
  }
469
- return promise.then((imageData) => {
470
- var _a, _b;
471
- const imagesData = Array.isArray(imageData) ? imageData : [imageData];
472
- const hasUnsplash = imagesData.some(d => isUnsplashUrl(d));
473
- if (!imageData && this.showImageLoader) {
447
+ try {
448
+ const res = await promise;
449
+ if (!res && this.showImageLoader) {
474
450
  this.showImageLoader = false;
475
451
  }
476
- if (!hasUnsplash && (this.cropperOptions || this.showCropper)) {
477
- return Promise.all(imagesData.map((data) => this.onOpenCropper(data)))
478
- .then(resolvedData => {
479
- resolvedData === null || resolvedData === void 0 ? void 0 : resolvedData.forEach((res, i) => {
480
- var _a, _b;
481
- this.setFieldValue((_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : i, res);
482
- this.clearPhotoEdit(null);
483
- });
484
- this.showImageLoader = false;
485
- }).catch(() => {
486
- this.showImageLoader = false;
487
- });
488
- }
489
- else {
490
- let newIndex = index;
491
- if (index < 0) {
492
- newIndex = (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
493
- }
494
- if (isMultiMode || useMediaCapture) {
495
- const promises = imageData.map((d, ind) => {
496
- return this.processMediaData(d.fullPath, newIndex >= 0 ? ind + newIndex : newIndex);
497
- });
498
- return Promise.all(promises).then(() => { });
499
- }
500
- else if (isArray(imageData)) {
501
- const newArr = [];
502
- let promises = [];
503
- const preventUpdate = imageData.length !== 1;
504
- if (preventUpdate) {
505
- promises = imageData.map((imageSrc, i) => {
506
- return this.processMediaData(imageSrc, null, preventUpdate).then((newImageSrc) => {
507
- newArr[i] = newImageSrc;
508
- });
509
- });
510
- }
511
- else {
512
- promises = imageData.map((d, ind) => {
513
- return this.processMediaData(d, ind + newIndex);
514
- });
515
- }
516
- return Promise.all(promises).then(() => {
517
- if (preventUpdate) {
518
- this.value = [...[].concat(this.value), ...newArr];
519
- setValueAndValidateInput(this.value, this);
452
+ const imagesData = Array.isArray(res) ? res : [res];
453
+ const hasUnsplash = imagesData.some(d => isUnsplashUrl(d));
454
+ const processImage = async (imageData, index) => {
455
+ var _a;
456
+ try {
457
+ 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;
458
+ if (!this.shouldTagImage()) {
459
+ const shouldOpenCropper = !hasUnsplash && imagesData.length === 1 && this.allowCrop(imageData);
460
+ const newIndex = Array.isArray(this.value) ? (_a = this.value) === null || _a === void 0 ? void 0 : _a.length : index;
461
+ if (shouldOpenCropper) {
462
+ extractedData = await this.onOpenCropper(imageData);
520
463
  }
521
- this.showImageLoader = false;
522
- });
464
+ await this.processMediaData(extractedData, newIndex);
465
+ }
523
466
  }
524
- else {
467
+ catch (err) {
525
468
  this.showImageLoader = false;
526
- if (imageData && imageData['data']) {
527
- return this.processMediaData(imageData['data'], newIndex);
528
- }
529
- if (imageData && imageData['path']) {
530
- return this.processMediaData(imageData['path'], newIndex);
531
- }
532
- return this.processMediaData(imageData, newIndex);
533
469
  }
534
- }
535
- }).catch(() => {
470
+ };
471
+ await Promise.all(imagesData.map((data, index) => processImage(data, index)));
536
472
  this.showImageLoader = false;
537
- });
473
+ }
474
+ catch (err) {
475
+ this.showImageLoader = false;
476
+ throw new Error(err);
477
+ }
538
478
  }
539
479
  captureVideo(index) {
540
480
  const options = { limit: 1, duration: this.duration || 60, saveToPhotoAlbum: true };
@@ -602,7 +542,7 @@ export class YooFormCaptureComponent {
602
542
  this.showPhotoTagDialog(ret.data).then((tag) => {
603
543
  if (!isNullOrUndefined(tag === null || tag === void 0 ? void 0 : tag.data)) {
604
544
  this.updateTagData(tag, index);
605
- this.setFieldValue(index, ret.data);
545
+ this.setFieldValue(ret.data);
606
546
  this.clearPhotoEdit(index);
607
547
  if (this.saveGeoloc) {
608
548
  this.captureGeoloc();
@@ -611,7 +551,7 @@ export class YooFormCaptureComponent {
611
551
  });
612
552
  }
613
553
  else {
614
- this.setFieldValue(index, ret.data);
554
+ this.setFieldValue(ret.data);
615
555
  this.clearPhotoEdit(index);
616
556
  if (this.saveGeoloc) {
617
557
  this.captureGeoloc();
@@ -711,7 +651,7 @@ export class YooFormCaptureComponent {
711
651
  }
712
652
  else {
713
653
  if (this.multiple && (newImages === null || newImages === void 0 ? void 0 : newImages.length) > 0) {
714
- this.setFieldValue(captureIndex, newImages);
654
+ this.setFieldValue(newImages);
715
655
  }
716
656
  else if (newImages === null || newImages === void 0 ? void 0 : newImages.length) {
717
657
  this.value = newImages[0];
@@ -774,17 +714,17 @@ export class YooFormCaptureComponent {
774
714
  const tag = await this.showPhotoTagDialog(data);
775
715
  if (!isNullOrUndefined(tag === null || tag === void 0 ? void 0 : tag.data)) {
776
716
  this.updateTagData(tag, index);
777
- this.setFieldValue(index, data);
717
+ this.setFieldValue(data);
778
718
  this.clearPhotoEdit(index);
779
719
  }
780
720
  }
781
721
  else {
782
- this.setFieldValue(index, data);
722
+ this.setFieldValue(data);
783
723
  this.clearPhotoEdit(index);
784
724
  }
785
725
  }
786
726
  else {
787
- this.setFieldValue(index, f);
727
+ this.setFieldValue(f);
788
728
  this.clearPhotoEdit(index);
789
729
  }
790
730
  targetElement.value = null;
@@ -1030,6 +970,7 @@ export class YooFormCaptureComponent {
1030
970
  }
1031
971
  async onShowActionSheet(value, index, event) {
1032
972
  var _a, _b, _c;
973
+ event === null || event === void 0 ? void 0 : event.stopImmediatePropagation();
1033
974
  if (index && index < 0 && this.max && this.value && this.value.length === this.max) {
1034
975
  this.onShowMaximumCaptureReached();
1035
976
  return;
@@ -2773,13 +2714,10 @@ export class YooFormCaptureComponent {
2773
2714
  },
2774
2715
  "setFieldValue": {
2775
2716
  "complexType": {
2776
- "signature": "(index: number, data: any) => Promise<void>",
2717
+ "signature": "(data: any) => Promise<void>",
2777
2718
  "parameters": [{
2778
2719
  "tags": [],
2779
2720
  "text": ""
2780
- }, {
2781
- "tags": [],
2782
- "text": ""
2783
2721
  }],
2784
2722
  "references": {
2785
2723
  "Promise": {
@@ -295,7 +295,7 @@ export class YooFormDynamicComponent {
295
295
  const videoValue = fieldData.value;
296
296
  const videoElement = el;
297
297
  if (videoValue) {
298
- videoElement.setFieldValue(undefined, videoValue);
298
+ videoElement.setFieldValue(videoValue);
299
299
  }
300
300
  break;
301
301
  }
@@ -82,8 +82,9 @@ export class YooFormHotzonesComponent {
82
82
  }
83
83
  }
84
84
  initDraggableTarget() {
85
+ var _a;
85
86
  let draggable;
86
- const imgElement = this.boundElement.querySelector('yoo-img');
87
+ const imgElement = (_a = this.boundElement) === null || _a === void 0 ? void 0 : _a.querySelector('yoo-img');
87
88
  const onDrag = () => {
88
89
  const isHit = draggable.hitTest(imgElement, '50%');
89
90
  this.targetElement.setAttribute('hit', isHit);
@@ -150,7 +150,7 @@ export class YooFormTextAreaComponent {
150
150
  }
151
151
  }
152
152
  //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
153
- setTimeout(() => {
153
+ !this.isRichText && setTimeout(() => {
154
154
  this.updateTextareaSize();
155
155
  }, 1000);
156
156
  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
  }