@piying/view-svelte 1.5.6 → 1.5.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/component/piying-view.svelte +21 -20
- package/package.json +2 -2
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
type EffectRef
|
|
12
12
|
} from 'static-injector';
|
|
13
13
|
import type { Injector } from 'static-injector';
|
|
14
|
-
import { setContext
|
|
14
|
+
import { setContext } from 'svelte';
|
|
15
15
|
import { InjectorToken } from '../token';
|
|
16
16
|
import { SvelteSchemaHandle } from '../svelte-schema';
|
|
17
17
|
import { SvelteFormBuilder } from '../builder';
|
|
@@ -33,9 +33,14 @@
|
|
|
33
33
|
]
|
|
34
34
|
});
|
|
35
35
|
setContext(InjectorToken, rootInjector);
|
|
36
|
+
let injectorDispose: (() => any) | undefined;
|
|
37
|
+
|
|
36
38
|
const [field, subInjector] = $derived.by(() => {
|
|
37
39
|
const subInjector = createInjector({ providers: [], parent: rootInjector });
|
|
38
|
-
|
|
40
|
+
injectorDispose = () => {
|
|
41
|
+
subInjector.destroy();
|
|
42
|
+
injectorDispose = undefined;
|
|
43
|
+
};
|
|
39
44
|
const field = convert(props.schema as any, {
|
|
40
45
|
handle: SvelteSchemaHandle as any,
|
|
41
46
|
builder: SvelteFormBuilder,
|
|
@@ -49,32 +54,28 @@
|
|
|
49
54
|
});
|
|
50
55
|
return [field, subInjector];
|
|
51
56
|
});
|
|
57
|
+
$effect.pre(() => {
|
|
58
|
+
return () => {
|
|
59
|
+
subInjector.destroy();
|
|
60
|
+
};
|
|
61
|
+
});
|
|
52
62
|
$effect.pre(() => {
|
|
53
63
|
let ref: EffectRef | undefined;
|
|
54
64
|
if (field.form.control) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
props.modelChange?.(value);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
);
|
|
65
|
+
ref = initListen(props.model, field!.form.control!, subInjector as Injector, (value) => {
|
|
66
|
+
untracked(() => {
|
|
67
|
+
if (field!.form.control?.valueNoError$$()) {
|
|
68
|
+
props.modelChange?.(value);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
field!.form.control?.updateValue(props.model);
|
|
68
73
|
}
|
|
74
|
+
|
|
69
75
|
return () => {
|
|
70
|
-
subInjector.destroy();
|
|
71
76
|
ref?.destroy();
|
|
72
77
|
};
|
|
73
78
|
});
|
|
74
|
-
|
|
75
|
-
$effect.pre(() => {
|
|
76
|
-
field!.form.control?.updateValue(props.model);
|
|
77
|
-
});
|
|
78
79
|
</script>
|
|
79
80
|
|
|
80
81
|
<FieldTemplate {field}></FieldTemplate>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@piying/view-svelte",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.7",
|
|
4
4
|
"description": "Piying view For Svelte;Valibot to Component",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://piying-org.github.io/website/docs/client/intro",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
],
|
|
35
35
|
"license": "MIT",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@piying/view-core": "^1.5.
|
|
37
|
+
"@piying/view-core": "^1.5.7",
|
|
38
38
|
"static-injector": "^6.1.2"
|
|
39
39
|
},
|
|
40
40
|
"sideEffects": false,
|