@zeyolabs/ui 2026.11.53 → 2026.11.54
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.
- package/form/Form.svelte +14 -0
- package/package.json +1 -1
- package/turnstile/Turnstile.svelte +4 -0
- package/turnstile/load.ts +2 -0
package/form/Form.svelte
CHANGED
|
@@ -71,6 +71,19 @@
|
|
|
71
71
|
hidden ? Object.entries(hidden).filter(([, value]) => value != null && value !== '') : []
|
|
72
72
|
);
|
|
73
73
|
|
|
74
|
+
// A browser extension (autofill, translation) may add its own named inputs to the form, and
|
|
75
|
+
// SvelteKit throws `form_field_unbound` on any field not bound to the remote form. Every
|
|
76
|
+
// `FormData` built from the form fires `formdata` first, so drop those entries there. Bound
|
|
77
|
+
// names end with `/<form id>`; the action carries the id, plus `/<key>` for a `.for(key)` form.
|
|
78
|
+
function dropUnboundFields(event: FormDataEvent) {
|
|
79
|
+
const action = new URLSearchParams(remote.action.split('?')[1] ?? '').get('/remote');
|
|
80
|
+
if (!action) return;
|
|
81
|
+
const suffix = '/' + action.split('/').slice(0, 2).join('/');
|
|
82
|
+
for (const name of new Set(event.formData.keys())) {
|
|
83
|
+
if (!name.replace(/\.[xy]$/, '').endsWith(suffix)) event.formData.delete(name);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
74
87
|
// Force enctype after the remote-form spread applies (which sets its own enctype).
|
|
75
88
|
// Defaults to multipart when the form contains file inputs, so consumers can't forget it.
|
|
76
89
|
function applyEnctype(node: HTMLFormElement) {
|
|
@@ -83,6 +96,7 @@
|
|
|
83
96
|
<form
|
|
84
97
|
class={className}
|
|
85
98
|
novalidate
|
|
99
|
+
onformdata={dropUnboundFields}
|
|
86
100
|
oninput={(event) => {
|
|
87
101
|
remote.validate();
|
|
88
102
|
dirty = true;
|
package/package.json
CHANGED
|
@@ -34,6 +34,10 @@
|
|
|
34
34
|
};
|
|
35
35
|
widgetId = turnstile.render(container, {
|
|
36
36
|
callback: (token) => onToken(token),
|
|
37
|
+
// Without it Turnstile throws each failed challenge (e.g. 600010 from a bot or a
|
|
38
|
+
// locked-down browser) as an uncaught error; it retries by itself and the widget
|
|
39
|
+
// shows the failure.
|
|
40
|
+
'error-callback': () => true,
|
|
37
41
|
'expired-callback': restart,
|
|
38
42
|
'response-field': false,
|
|
39
43
|
sitekey: siteKey,
|
package/turnstile/load.ts
CHANGED
|
@@ -5,6 +5,8 @@ export type TurnstileApi = {
|
|
|
5
5
|
container: HTMLElement,
|
|
6
6
|
options: {
|
|
7
7
|
callback: (token: string) => void;
|
|
8
|
+
/** Return true to mark the error handled, so Turnstile doesn't throw it. */
|
|
9
|
+
'error-callback': (code: string) => boolean;
|
|
8
10
|
'expired-callback': () => void;
|
|
9
11
|
'response-field': boolean;
|
|
10
12
|
sitekey: string;
|