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

@ -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 },