Skip to content

Commit

Permalink
WIP: FormModal.svelte to 5
Browse files Browse the repository at this point in the history
  • Loading branch information
danielo515 committed Jul 8, 2024
1 parent 01dc8c8 commit 8f2e1e7
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/FormModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,24 @@
import { App } from "obsidian";
import { FormDefinition } from "src/core/formDefinition";
import { makeFormEngine } from "src/store/formStore";
import { onMount } from "svelte";
import RenderField from "./views/components/Form/RenderField.svelte";
export let app: App;
export let reportFormErrors: (errors: string[]) => void;
export let formEngine: ReturnType<typeof makeFormEngine>;
export let fields: FormDefinition["fields"];
$: errors = formEngine.errors;
$: $errors.length && reportFormErrors($errors);
const {
app,
reportFormErrors,
formEngine,
fields,
}: {
app: App;
reportFormErrors: (errors: string[]) => void;
formEngine: ReturnType<typeof makeFormEngine>;
fields: FormDefinition["fields"];
} = $props();
onMount(() =>
formEngine.errors.subscribe((errors) => {
if (errors.length > 0) reportFormErrors(errors);
}),
);
</script>

{#each fields as definition}
Expand Down

0 comments on commit 8f2e1e7

Please sign in to comment.