fuma 0.4.9 → 0.4.10
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/ui/form/Form.svelte +8 -3
- package/package.json +1 -1
package/dist/ui/form/Form.svelte
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
ReturnData extends Record<string, unknown> = FormDataInput<Shape>,
|
|
8
8
|
Data extends FormDataInput<Shape> = FormDataInput<Shape>
|
|
9
9
|
"
|
|
10
|
-
>import { createEventDispatcher, onMount } from "svelte";
|
|
10
|
+
>import { createEventDispatcher, onMount, tick } from "svelte";
|
|
11
11
|
import { fade } from "svelte/transition";
|
|
12
12
|
import { page } from "$app/stores";
|
|
13
13
|
import { contextContainer } from "../context.js";
|
|
@@ -36,8 +36,6 @@ export let options = {};
|
|
|
36
36
|
let dataInput = initData(fields);
|
|
37
37
|
export { dataInput as data };
|
|
38
38
|
let data = dataInput;
|
|
39
|
-
$:
|
|
40
|
-
$isDirty ? dataInput = data : data = dataInput;
|
|
41
39
|
export function set(key, value) {
|
|
42
40
|
isDirty.set(true);
|
|
43
41
|
data[key] = value;
|
|
@@ -66,6 +64,13 @@ const { enhance, setError } = useForm({
|
|
|
66
64
|
});
|
|
67
65
|
const { handleInput, isDirty } = useHandleInput({ model, setError });
|
|
68
66
|
onMount(lookupValueFromParams);
|
|
67
|
+
isDirty.subscribe(async (_isDirty) => {
|
|
68
|
+
await tick();
|
|
69
|
+
if (isDirty)
|
|
70
|
+
dataInput = data;
|
|
71
|
+
else
|
|
72
|
+
data = dataInput;
|
|
73
|
+
});
|
|
69
74
|
function lookupValueFromParams() {
|
|
70
75
|
fields.flat().forEach(({ key }) => {
|
|
71
76
|
if (data[key])
|