migrate: convert most components to svelte 5

This commit is contained in:
Xylight committed 2024-10-25 19:33:27 -07:00
1 parent d670f39f0a
commit 10ef4123da
225 files changed
+5441 -3341

No files matched your search

+25 -11
View File
@@ -1,14 +1,11 @@
<script lang="ts">
import { run } from 'svelte/legacy'
import { browser } from '$app/environment'
import { tick } from 'svelte'
export let label: string | undefined = undefined
export let value: string
export let required: boolean = false
let textarea: HTMLTextAreaElement = $state()
let textarea: HTMLTextAreaElement
$: adjustHeight(value)
async function adjustHeight(value: string) {
await tick()
if (textarea) {
@@ -16,8 +13,25 @@
textarea.style.height = `${textarea.scrollHeight}px` // Set height to the scrollHeight
}
}
let clazz: string = ''
export { clazz as class }
interface Props {
label?: string | undefined
value: string
required?: boolean
class?: string
[key: string]: any
}
let {
label = undefined,
value = $bindable(),
required = false,
class: clazz = '',
...rest
}: Props = $props()
run(() => {
adjustHeight(value)
})
</script>
<label class="w-full">
@@ -31,11 +45,11 @@
{/if}
<textarea
bind:this={textarea}
on:input={() => adjustHeight(value)}
oninput={() => adjustHeight(value)}
bind:value
{required}
{...$$restProps}
{...rest}
rows={1}
class="font-semibold text-2xl focus:outline-none w-full bg-transparent resize-none {clazz}"
/>
></textarea>
</label>