sveltekit-superforms
Advanced tools
Comparing version 2.10.2 to 2.10.3
@@ -104,4 +104,9 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
const dt = new DataTransfer(); | ||
if (files) | ||
files.forEach((file) => dt.items.add(file)); | ||
if (Array.isArray(files)) { | ||
if (files.length && files.every((f) => !f)) { | ||
formFiles.set([]); | ||
return; | ||
} | ||
files.filter((f) => !!f).forEach((file) => dt.items.add(file)); | ||
} | ||
filesProxy.set(dt.files); | ||
@@ -119,3 +124,6 @@ }); | ||
if (Array.isArray(files)) | ||
files.forEach((file) => dt.items.add(file)); | ||
files.forEach((file) => { | ||
if (file) | ||
dt.items.add(file); | ||
}); | ||
else | ||
@@ -122,0 +130,0 @@ formFiles.set(files); |
@@ -911,3 +911,3 @@ import { derived, get, readonly, writable } from 'svelte/store'; | ||
untaint: successResult, | ||
keepFiles: true | ||
keepFiles: !Form_shouldReset(true, true) | ||
}); | ||
@@ -914,0 +914,0 @@ } |
@@ -156,3 +156,4 @@ import { SuperFormError, SchemaError } from './errors.js'; | ||
if (info.types.includes('array') || info.types.includes('set')) { | ||
const items = property.items; | ||
// If no items, it could be a union containing the info | ||
const items = property.items ?? (info.union?.length == 1 ? info.union[0] : undefined); | ||
if (!items || typeof items == 'boolean' || (Array.isArray(items) && items.length != 1)) { | ||
@@ -166,3 +167,7 @@ throw new SchemaError('Arrays must have a single "items" property that defines its type.', key); | ||
continue; | ||
// Check for empty files being posted (and filtered) | ||
const isFileArray = entries.length && entries.some((e) => e && typeof e !== 'string'); | ||
const arrayData = entries.map((e) => parseSingleEntry(key, e, arrayInfo)); | ||
if (isFileArray && arrayData.every((file) => !file)) | ||
arrayData.length = 0; | ||
output[key] = info.types.includes('set') ? new Set(arrayData) : arrayData; | ||
@@ -169,0 +174,0 @@ } |
{ | ||
"name": "sveltekit-superforms", | ||
"version": "2.10.2", | ||
"version": "2.10.3", | ||
"author": "Andreas Söderlund <ciscoheat@gmail.com> (https://blog.encodeart.dev)", | ||
@@ -5,0 +5,0 @@ "description": "Making SvelteKit forms a pleasure to use!", |
267091
5651