@dmitryvim/form-builder 0.1.7 → 0.1.8

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.
@@ -564,9 +564,19 @@
564
564
  }
565
565
 
566
566
  for (const file of picker.files) {
567
- const rid = await makeResourceIdFromFile(file);
568
- resourceIndex.set(rid, { name: file.name, type: file.type, size: file.size });
569
- arr.push(rid);
567
+ try {
568
+ let resourceId;
569
+ if (config.uploadFile && typeof config.uploadFile === 'function') {
570
+ resourceId = await config.uploadFile(file);
571
+ } else {
572
+ resourceId = await makeResourceIdFromFile(file);
573
+ }
574
+ resourceIndex.set(resourceId, { name: file.name, type: file.type, size: file.size });
575
+ arr.push(resourceId);
576
+ } catch (error) {
577
+ markValidity(picker, `Upload failed: ${error.message}`);
578
+ return;
579
+ }
570
580
  }
571
581
 
572
582
  hid.value = JSON.stringify(arr);
@@ -690,9 +700,19 @@
690
700
  }
691
701
  }
692
702
  for (const file of picker.files) {
693
- const rid = await makeResourceIdFromFile(file);
694
- resourceIndex.set(rid, { name: file.name, type: file.type, size: file.size });
695
- arr.push(rid);
703
+ try {
704
+ let resourceId;
705
+ if (config.uploadFile && typeof config.uploadFile === 'function') {
706
+ resourceId = await config.uploadFile(file);
707
+ } else {
708
+ resourceId = await makeResourceIdFromFile(file);
709
+ }
710
+ resourceIndex.set(resourceId, { name: file.name, type: file.type, size: file.size });
711
+ arr.push(resourceId);
712
+ } catch (error) {
713
+ markValidity(picker, `Upload failed: ${error.message}`);
714
+ return;
715
+ }
696
716
  }
697
717
  hid.value = JSON.stringify(arr);
698
718
  renderVideos(arr);
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.1.7",
6
+ "version": "0.1.8",
7
7
  "description": "A reusable JSON schema form builder library",
8
8
  "main": "dist/form-builder.js",
9
9
  "files": [