@stubber/form-fields 1.4.5 → 1.4.6

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.
@@ -49,7 +49,7 @@
49
49
  signaturePad = new SignaturePad(pad);
50
50
  signaturePad.addEventListener("endStroke", handleStroke);
51
51
  setTimeout(() => {
52
- let d = _.isArray($field.data?.base) ? $field.data?.base : [];
52
+ let d = _.isArray($field.data?.base?.data) ? $field.data?.base?.data : [];
53
53
  signaturePad.fromData(d);
54
54
  }, 0);
55
55
 
@@ -91,10 +91,12 @@
91
91
  let upload_res = await form.uploadFiles(null, filesForm);
92
92
  let { uploaded_files } = upload_res;
93
93
  if (uploaded_files?.length) {
94
+ if ($internal.value.file && $internal.value.file.fileuuid) {
95
+ form.removeAttachment($internal.value.file);
96
+ }
97
+
94
98
  $internal.value.file = uploaded_files[0];
95
- uploaded_files.forEach((a) => {
96
- form.appendAttachment(a);
97
- });
99
+ form.appendAttachment(uploaded_files[0]);
98
100
  } else {
99
101
  console.warn("Failed to upload file");
100
102
  }
@@ -102,6 +104,8 @@
102
104
  return true;
103
105
  }
104
106
 
107
+ const debounced_upload = _.debounce(uploadFile, 1000);
108
+
105
109
  function clear() {
106
110
  signaturePad.clear();
107
111
  $field.data.base = {
@@ -117,7 +121,7 @@
117
121
 
118
122
  if (!deepEqual(comparison, $internal)) {
119
123
  $internal = comparison;
120
- uploadFile();
124
+ debounced_upload();
121
125
  }
122
126
  }
123
127
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stubber/form-fields",
3
- "version": "1.4.5",
3
+ "version": "1.4.6",
4
4
  "description": "An automatic form builder based on field specifications",
5
5
  "keywords": [
6
6
  "components",