1
0
mirror of https://github.com/immich-app/immich.git synced 2025-06-26 05:01:05 +02:00

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

@ -1,4 +1,4 @@
<script lang="ts" context="module">
<script lang="ts" module>
// Necessary for eslint
/* eslint-disable @typescript-eslint/no-explicit-any */
type T = any;
@ -20,19 +20,31 @@
import { clickOutside } from '$lib/actions/click-outside';
import { fly } from 'svelte/transition';
let className = '';
export { className as class };
interface Props {
class?: string;
options: T[];
selectedOption?: any;
showMenu?: boolean;
controlable?: boolean;
hideTextOnSmallScreen?: boolean;
title?: string | undefined;
onSelect: (option: T) => void;
onClickOutside?: () => void;
render?: (item: T) => string | RenderedOption;
}
export let options: T[];
export let selectedOption = options[0];
export let showMenu = false;
export let controlable = false;
export let hideTextOnSmallScreen = true;
export let title: string | undefined = undefined;
export let onSelect: (option: T) => void;
export let onClickOutside: () => void = () => {};
export let render: (item: T) => string | RenderedOption = String;
let {
class: className = '',
options,
selectedOption = $bindable(options[0]),
showMenu = $bindable(false),
controlable = false,
hideTextOnSmallScreen = true,
title = undefined,
onSelect,
onClickOutside = () => {},
render = String,
}: Props = $props();
const handleClickOutside = () => {
if (!controlable) {
@ -65,12 +77,12 @@
}
};
$: renderedSelectedOption = renderOption(selectedOption);
let renderedSelectedOption = $derived(renderOption(selectedOption));
</script>
<div use:clickOutside={{ onOutclick: handleClickOutside, onEscape: handleClickOutside }}>
<!-- BUTTON TITLE -->
<LinkButton on:click={() => (showMenu = true)} fullwidth {title}>
<LinkButton onclick={() => (showMenu = true)} fullwidth {title}>
<div class="flex place-items-center gap-2 text-sm">
{#if renderedSelectedOption?.icon}
<Icon path={renderedSelectedOption.icon} size="18" />
@ -92,7 +104,7 @@
type="button"
class="grid grid-cols-[36px,1fr] place-items-center p-2 disabled:opacity-40 {buttonStyle}"
disabled={renderedOption.disabled}
on:click={() => !renderedOption.disabled && handleSelectOption(option)}
onclick={() => !renderedOption.disabled && handleSelectOption(option)}
>
{#if isEqual(selectedOption, option)}
<div class="text-immich-primary dark:text-immich-dark-primary">