kwikid-forms 0.5.12 → 0.5.13

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.
@@ -2884,12 +2884,25 @@ class KwikIDFormViewComponent {
2884
2884
  * This method is used to update the files array with the new file and it's state and response from the api of uploading the file.
2885
2885
  */
2886
2886
  updateFiles(file, state, key) {
2887
+ var _a;
2887
2888
  const fileWithState = mergeObjects(file, { state: state });
2888
- const updatedFiles = [
2889
- ...this.files[key].filter((f) => f.name !== fileWithState.name || f.size !== fileWithState.size),
2890
- fileWithState
2891
- ];
2892
- this.files[key] = filterDuplicatesFiles(updatedFiles);
2889
+ const field = getFormFieldByKey(this.formFields, key);
2890
+ if ((_a = field.properties) === null || _a === void 0 ? void 0 : _a.multiple) {
2891
+ // If field.properties?.multiple is true, it means multiple files are allowed for this field.
2892
+ // Update the existing files array for the specific key with the new file.
2893
+ const updatedFiles = [
2894
+ ...this.files[key].filter((f) => f.name !== fileWithState.name || f.size !== fileWithState.size),
2895
+ fileWithState
2896
+ ];
2897
+ // Apply the filterDuplicatesFiles function to ensure uniqueness in the updatedFiles array.
2898
+ this.files[key] = filterDuplicatesFiles(updatedFiles);
2899
+ }
2900
+ else {
2901
+ // If field.properties?.multiple is false, only one file is allowed for this field.
2902
+ // Replace the existing files array for the specific key with an array containing the new file.
2903
+ this.files[key] = [fileWithState];
2904
+ }
2905
+ // Update the formData and formGroup controls for the specific key with the normalFiles array.
2893
2906
  const normalFiles = this.files[key].filter((file) => {
2894
2907
  return file.state === "NORMAL";
2895
2908
  });