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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
310 changed files with 6435 additions and 4176 deletions

View file

@ -7,16 +7,6 @@
import { searchPerson, type PersonResponseDto } from '@immich/sdk';
import { t } from 'svelte-i18n';
export let searchName: string;
export let searchedPeopleLocal: PersonResponseDto[];
export let type: 'searchBar' | 'input';
export let numberPeopleToSearch: number = maximumLengthSearchPeople;
export let inputClass: string = 'w-full gap-2 bg-immich-bg dark:bg-immich-dark-bg';
export let showLoadingSpinner: boolean = false;
export let placeholder: string = $t('name_or_nickname');
export let onReset = () => {};
export let onSearch = () => {};
let searchedPeople: PersonResponseDto[] = [];
let searchWord: string;
let abortController: AbortController | null = null;
@ -43,7 +33,36 @@
}
};
export let handleSearch = async (force?: boolean, name?: string) => {
interface Props {
searchName: string;
searchedPeopleLocal: PersonResponseDto[];
type: 'searchBar' | 'input';
numberPeopleToSearch?: number;
inputClass?: string;
showLoadingSpinner?: boolean;
placeholder?: string;
onReset?: () => void;
onSearch?: () => void;
}
let {
searchName = $bindable(),
searchedPeopleLocal = $bindable(),
type,
numberPeopleToSearch = maximumLengthSearchPeople,
inputClass = 'w-full gap-2 bg-immich-bg dark:bg-immich-dark-bg',
showLoadingSpinner = $bindable(false),
placeholder = $t('name_or_nickname'),
onReset = () => {},
onSearch = () => {},
}: Props = $props();
const handleReset = () => {
reset();
onReset();
};
export async function searchPeople(force?: boolean, name?: string) {
searchName = name ?? searchName;
onSearch();
if (searchName === '') {
@ -70,12 +89,7 @@
showLoadingSpinner = false;
search();
}
};
const handleReset = () => {
reset();
onReset();
};
}
</script>
{#if type === 'searchBar'}
@ -84,7 +98,7 @@
{showLoadingSpinner}
{placeholder}
onReset={handleReset}
onSearch={({ force }) => handleSearch(force ?? false)}
onSearch={({ force }) => searchPeople(force ?? false)}
/>
{:else}
<input
@ -92,7 +106,7 @@
type="text"
{placeholder}
bind:value={searchName}
on:input={() => handleSearch(false)}
oninput={() => searchPeople(false)}
use:initInput
/>
{/if}