Skip to content

Commit 878fef6

Browse files
committed
[docs] Add sveltekit guide progressive enhancement block
1 parent 3af0637 commit 878fef6

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

apps/docs/src/content/docs/integrations/sveltekit.mdx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ sidebar:
55
---
66

77
import { Code, Tabs, TabItem } from "@astrojs/starlight/components";
8+
import { DEFAULT_ID_SEPARATOR, DEFAULT_PSEUDO_ID_SEPARATOR } from '@sjsf/form';
89

910
import Npm from '@/components/npm.astro';
1011

@@ -107,5 +108,28 @@ According to Svelte documentation your form should always use `POST` requests.
107108

108109
You should always use `enhance` action on your forms.
109110

110-
But if you really want the form to work with `JavaScript` disabled, then check out the list of restrictions.
111-
111+
But if you really want the form to work with `JavaScript` disabled, you should consider the following limitation:
112+
113+
- `validateForm` should be called with `sendData: true`
114+
- Form elements for `oneOf`, `anyOf`, `dependencies`, `additionalProperties` and `additionalItems`
115+
will not update their state.
116+
- Some widgets (like multiselect, depends on the theme) may will not work, because they require `JavaScript`.
117+
- Conversion from `FormData` to `JSON` can happen with data loss.
118+
This conversion relies on the fields id computation algorithm and
119+
it may lead to ambiguous results if the following conditions are violated:
120+
- Id prefix and separators:
121+
- Must be non empty, non numeric string
122+
- Must not include each other
123+
- Property names and keys of default object values in your schema must not contain the separators.
124+
If they do you can change the default separators with `idSeparator` and `isPseudoSeparator` options.
125+
Default separator values:
126+
- `idSeparator` - <code>{DEFAULT_ID_SEPARATOR}</code>
127+
- `isPseudoSeparator` - <code>{DEFAULT_PSEUDO_ID_SEPARATOR}</code>
128+
- If your schema contains `additionalProperties`:
129+
- Keys of initial object values must not contain the separators.
130+
- If you provide some initial value for `additionalProperties` or `JavaScript` is enabled but the form is used without `enhance`:
131+
- You should provide `additionalPropertyKeyValidationError` or `additionalPropertyKeyValidator` options to `useSvelteKitForm` for preventing the user to input invalid keys.
132+
- You may produce these checks at runtime with the `staticAnalysis` and other functions from `@sjsf/form/static-analysis` submodule.
133+
Functions from this submodule returns an iterable of errors, so you can:
134+
- Throw an error on the first error or list all errors (in a dev environment)
135+
- Check if the data in the server action is correct and save the original form data if there are errors (in a production environment)

0 commit comments

Comments
 (0)