chore(web): migration svelte 5 syntax (#13883)

This commit is contained in:
Alex
2024-11-14 08:43:25 -06:00
committed by GitHub
parent 9203a61709
commit 0b3742cf13
310 changed files with 6435 additions and 4176 deletions

View File

@@ -5,15 +5,29 @@
import { onMount } from 'svelte';
import { t } from 'svelte-i18n';
export let importPath: string | null;
export let importPaths: string[] = [];
export let title = $t('import_path');
export let cancelText = $t('cancel');
export let submitText = $t('save');
export let isEditing = false;
export let onCancel: () => void;
export let onSubmit: (importPath: string | null) => void;
export let onDelete: () => void = () => {};
interface Props {
importPath: string | null;
importPaths?: string[];
title?: string;
cancelText?: string;
submitText?: string;
isEditing?: boolean;
onCancel: () => void;
onSubmit: (importPath: string | null) => void;
onDelete?: () => void;
}
let {
importPath = $bindable(),
importPaths = $bindable([]),
title = $t('import_path'),
cancelText = $t('cancel'),
submitText = $t('save'),
isEditing = false,
onCancel,
onSubmit,
onDelete,
}: Props = $props();
onMount(() => {
if (isEditing) {
@@ -21,12 +35,19 @@
}
});
$: isDuplicate = importPath !== null && importPaths.includes(importPath);
$: canSubmit = importPath !== '' && importPath !== null && !importPaths.includes(importPath);
let isDuplicate = $derived(importPath !== null && importPaths.includes(importPath));
let canSubmit = $derived(importPath !== '' && importPath !== null && !importPaths.includes(importPath));
const onsubmit = (event: Event) => {
event.preventDefault();
if (canSubmit) {
onSubmit(importPath);
}
};
</script>
<FullScreenModal {title} icon={mdiFolderSync} onClose={onCancel}>
<form on:submit|preventDefault={() => onSubmit(importPath)} autocomplete="off" id="library-import-path-form">
<form {onsubmit} autocomplete="off" id="library-import-path-form">
<p class="py-5 text-sm">{$t('admin.library_import_path_description')}</p>
<div class="my-4 flex flex-col gap-2">
@@ -40,11 +61,12 @@
{/if}
</div>
</form>
<svelte:fragment slot="sticky-bottom">
<Button color="gray" fullwidth on:click={onCancel}>{cancelText}</Button>
{#snippet stickyBottom()}
<Button color="gray" fullwidth onclick={onCancel}>{cancelText}</Button>
{#if isEditing}
<Button color="red" fullwidth on:click={onDelete}>{$t('delete')}</Button>
<Button color="red" fullwidth onclick={onDelete}>{$t('delete')}</Button>
{/if}
<Button type="submit" disabled={!canSubmit} fullwidth form="library-import-path-form">{submitText}</Button>
</svelte:fragment>
{/snippet}
</FullScreenModal>