@samuel-charpentier/sform 0.0.5 → 0.0.7
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/dist/Sform/Sfield.svelte +12 -4
- package/dist/Sform/Sform.svelte +1 -5
- package/dist/Sform/types.d.ts +6 -2
- package/package.json +1 -1
package/dist/Sform/Sfield.svelte
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
TypedSfieldProps
|
|
7
7
|
} from './types.js';
|
|
8
8
|
import { getSformContext } from './context.svelte.js';
|
|
9
|
+
import { tick } from 'svelte';
|
|
9
10
|
import TextInput from './inputs/TextInput.svelte';
|
|
10
11
|
import NumberInput from './inputs/NumberInput.svelte';
|
|
11
12
|
import TextareaInput from './inputs/TextareaInput.svelte';
|
|
@@ -56,8 +57,15 @@
|
|
|
56
57
|
const issues = $derived(showIssues ? field.issues() : []);
|
|
57
58
|
const hasIssues = $derived(issues && issues instanceof Array && issues.length > 0);
|
|
58
59
|
|
|
59
|
-
function handleBlur() {
|
|
60
|
+
async function handleBlur() {
|
|
60
61
|
context.markTouched(name);
|
|
62
|
+
// Wait a tick - if submission started, pending will be > 0 by then
|
|
63
|
+
// This prevents stale data validation when blur fires during Enter submission
|
|
64
|
+
await tick();
|
|
65
|
+
const formState = context.getFormState();
|
|
66
|
+
if (formState.pending) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
61
69
|
// Trigger validation with includeUntouched so blur mode shows issues
|
|
62
70
|
context.triggerValidation();
|
|
63
71
|
}
|
|
@@ -156,7 +164,7 @@
|
|
|
156
164
|
{/if}
|
|
157
165
|
|
|
158
166
|
{#if props.hint}
|
|
159
|
-
<div class=
|
|
167
|
+
<div class={classes.hint}>
|
|
160
168
|
{#if typeof props.hint === 'string'}
|
|
161
169
|
{props.hint}
|
|
162
170
|
{:else}
|
|
@@ -166,9 +174,9 @@
|
|
|
166
174
|
{/if}
|
|
167
175
|
|
|
168
176
|
{#if hasIssues}
|
|
169
|
-
<div class={classes.
|
|
177
|
+
<div class={classes.issues}>
|
|
170
178
|
{#each issues as issue, i (i)}
|
|
171
|
-
<p>{issue.message}</p>
|
|
179
|
+
<p class={classes.issue}>{issue.message}</p>
|
|
172
180
|
{/each}
|
|
173
181
|
</div>
|
|
174
182
|
{/if}
|
package/dist/Sform/Sform.svelte
CHANGED
|
@@ -57,10 +57,7 @@
|
|
|
57
57
|
() => validateOn,
|
|
58
58
|
getFieldNames,
|
|
59
59
|
triggerValidation,
|
|
60
|
-
() =>
|
|
61
|
-
// Use setTimeout to ensure we're outside the current event loop
|
|
62
|
-
setTimeout(() => formElement?.requestSubmit(), 0);
|
|
63
|
-
},
|
|
60
|
+
() => formElement?.requestSubmit(),
|
|
64
61
|
() => form
|
|
65
62
|
);
|
|
66
63
|
|
|
@@ -89,7 +86,6 @@
|
|
|
89
86
|
});
|
|
90
87
|
|
|
91
88
|
function handleInput() {
|
|
92
|
-
// Always include untouched to preserve issues on fields that were already validated
|
|
93
89
|
form.validate({ includeUntouched: true });
|
|
94
90
|
}
|
|
95
91
|
|
package/dist/Sform/types.d.ts
CHANGED
|
@@ -37,8 +37,12 @@ export interface SfieldClasses {
|
|
|
37
37
|
label?: string;
|
|
38
38
|
/** Input element class */
|
|
39
39
|
input?: string;
|
|
40
|
-
/**
|
|
41
|
-
|
|
40
|
+
/** Hint element class */
|
|
41
|
+
hint?: string;
|
|
42
|
+
/** Issues container class */
|
|
43
|
+
issues?: string;
|
|
44
|
+
/** Individual issue element class */
|
|
45
|
+
issue?: string;
|
|
42
46
|
}
|
|
43
47
|
/**
|
|
44
48
|
* Maps Sfield input types to the value types they handle.
|