New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sveltekit-superforms

Package Overview
Dependencies
Maintainers
1
Versions
215
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sveltekit-superforms - npm Package Compare versions

Comparing version

to
0.5.6

38

dist/client/index.js
import { enhance, applyAction } from '$app/forms';
import { beforeNavigate, invalidateAll } from '$app/navigation';
import { page } from '$app/stores';
//import { getFlash, updateFlash } from 'sveltekit-flash-message/client';
import { isElementInViewport, scrollToAndCenter } from './elements';

@@ -11,2 +10,3 @@ import { derived, get, writable } from 'svelte/store';

import { deepEqual } from '..';
import { getFlash, updateFlash } from 'sveltekit-flash-message/client';
var FetchStatus;

@@ -125,3 +125,2 @@ (function (FetchStatus) {

}
let flashLibrary;
/**

@@ -139,16 +138,2 @@ * Initializes a SvelteKit form, for convenient handling of values, errors and sumbitting data.

options = { ...defaultFormOptions, ...options };
/*
if (options.flashMessage && !flashLibrary) {
try {
const lib = ['sveltekit-flash-message', 'client'];
import(lib.join('/'))
.then((flash) => (flashLibrary = flash))
.catch(function () {
//
});
} catch {
//
}
}
*/
function emptyForm() {

@@ -465,12 +450,6 @@ return {

}
if (flashLibrary &&
options.flashMessage &&
if (options.flashMessage &&
(options.clearOnSubmit == 'errors-and-message' ||
options.clearOnSubmit == 'message')) {
try {
flashLibrary.getFlash(page).set(undefined);
}
catch {
//
}
getFlash(page).set(undefined);
}

@@ -545,3 +524,3 @@ //d('Submitting');

}
if (flashLibrary && options.flashMessage) {
if (options.flashMessage) {
if (result.type == 'error') {

@@ -554,3 +533,3 @@ if (errorMessage &&

}
flashLibrary.getFlash(page).set(options.flashMessage({
getFlash(page).set(options.flashMessage({
...result,

@@ -561,8 +540,3 @@ status: result.status ?? status

else {
try {
await flashLibrary.updateFlash(page);
}
catch {
//
}
updateFlash(page);
}

@@ -569,0 +543,0 @@ }

8

dist/server/index.js

@@ -80,3 +80,3 @@ import { fail, json } from '@sveltejs/kit';

/*
d(field, value, {
console.log(field, value, {
...newValue,

@@ -153,5 +153,5 @@ type: newValue.type.constructor.name

//let i = 0;
//d(field);
//console.log(field);
while (wrapped) {
//d(' '.repeat(++i * 2) + zodType.constructor.name);
//console.log(' '.repeat(++i * 2) + zodType.constructor.name);
if (zodType instanceof ZodNullable) {

@@ -177,3 +177,3 @@ isNullable = true;

/*
d(field, {
console.log(field, {
zodType: zodType.constructor.name,

@@ -180,0 +180,0 @@ isNullable,

{
"name": "sveltekit-superforms",
"version": "0.5.5",
"version": "0.5.6",
"author": "Andreas Söderlund <ciscoheat@gmail.com> (https://blog.encodeart.dev)",

@@ -5,0 +5,0 @@ "description": "Supercharge your SvelteKit forms with this powerhouse of a library!",

@@ -311,4 +311,6 @@ # sveltekit-superforms 💥

As you see, another difference is that the form isn't resetted by default. This should also be opt-in to avoid data loss, and this isn't always wanted, especially in backend interfaces, where the form data should be persisted. In any case, since we're binding the fields to `$form`, the html form reset behavior doesn't make much sense, so in `sveltekit-superforms` resetting means going back to the initial state of the form data, usually the contents of `form` in `PageData`. If you're depending heavily on default values, this may not always be what you want.
As you see, another difference is that the form isn't resetted by default. This should also be opt-in to avoid data loss, and this isn't always wanted, especially in backend interfaces, where the form data should be persisted.
In any case, since we're binding the fields to `$form`, the html form reset behavior doesn't make much sense, so in `sveltekit-superforms` resetting means _going back to the initial state of the form data_, usually the contents of `form` in `PageData`. This may not be exactly what you needed, in which case you can use an event to clear the form instead.
## More options: Client-side validators

@@ -672,3 +674,3 @@

implicitDefaults = true; // See further down for default entity values
noErrors = false; // See noErrors() reference further down
noErrors = false; // See noErrors() reference
}

@@ -857,6 +859,20 @@ ): Promise<Validation<T>>

## Feedback wanted!
This whole behavior can be turned off if you pass `options.implicitDefaults = false` to `superValidate`, which means that you must add `default` to all required fields of your schema.
## Non-supported defaults
Some Zod types like `ZodEnum` and `ZodUnion` can't use the above default values, so an exception will be thrown if you don't set a default value for them yourself, for example:
```ts
const schema = z.object({
fish: z.enum(['Salmon', 'Tuna', 'Trout']).default('Salmon')
});
```
Let me know if you find something that could or should be supported regarding this.
# Feedback wanted!
The library is quite stable so don't expect any major changes, but there could still be minor breaking changes until version 1.0, mostly variable naming.
Ideas, feedback, bug reports, PR:s, etc, are very welcome as a [github issue](https://github.com/ciscoheat/sveltekit-superforms/issues).