mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
chore(web): migration svelte 5 syntax (#13883)
This commit is contained in:
parent
9203a61709
commit
0b3742cf13
310 changed files with 6435 additions and 4176 deletions
|
|
@ -3,23 +3,23 @@
|
|||
import { shortcut } from '$lib/actions/shortcut';
|
||||
import { tick } from 'svelte';
|
||||
|
||||
export let content: string = '';
|
||||
let className: string = '';
|
||||
export { className as class };
|
||||
export let onContentUpdate: (newContent: string) => void = () => null;
|
||||
export let placeholder: string = '';
|
||||
interface Props {
|
||||
content?: string;
|
||||
class?: string;
|
||||
onContentUpdate?: (newContent: string) => void;
|
||||
placeholder?: string;
|
||||
}
|
||||
|
||||
let textarea: HTMLTextAreaElement;
|
||||
$: newContent = content;
|
||||
let { content = '', class: className = '', onContentUpdate = () => null, placeholder = '' }: Props = $props();
|
||||
|
||||
$: {
|
||||
// re-visit with svelte 5. runes will make this better.
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
||||
newContent;
|
||||
let textarea: HTMLTextAreaElement | undefined = $state();
|
||||
let newContent = $state(content);
|
||||
|
||||
$effect(() => {
|
||||
if (textarea && newContent.length > 0) {
|
||||
void tick().then(() => autoGrowHeight(textarea));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const updateContent = () => {
|
||||
if (content === newContent) {
|
||||
|
|
@ -32,8 +32,8 @@
|
|||
<textarea
|
||||
bind:this={textarea}
|
||||
class="resize-none {className}"
|
||||
on:focusout={updateContent}
|
||||
on:input={(e) => (newContent = e.currentTarget.value)}
|
||||
onfocusout={updateContent}
|
||||
oninput={(e) => (newContent = e.currentTarget.value)}
|
||||
{placeholder}
|
||||
use:shortcut={{
|
||||
shortcut: { key: 'Enter', ctrl: true },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue