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,29 +1,35 @@
<script lang="ts">
import type { HTMLInputAttributes } from 'svelte/elements';
interface $$Props extends HTMLInputAttributes {
interface Props {
type: 'date' | 'datetime-local';
value?: string;
min?: string;
max?: string;
class?: string;
id?: string;
name?: string;
placeholder?: string;
}
export let type: $$Props['type'];
export let value: $$Props['value'] = undefined;
export let max: $$Props['max'] = undefined;
let { type, value = $bindable(), max = undefined, ...rest }: Props = $props();
$: fallbackMax = type === 'date' ? '9999-12-31' : '9999-12-31T23:59';
let fallbackMax = $derived(type === 'date' ? '9999-12-31' : '9999-12-31T23:59');
// Updating `value` directly causes the date input to reset itself or
// interfere with user changes.
$: updatedValue = value;
let updatedValue = $state<string>();
$effect(() => {
updatedValue = value;
});
</script>
<input
{...$$restProps}
{...rest}
{type}
{value}
max={max || fallbackMax}
on:input={(e) => (updatedValue = e.currentTarget.value)}
on:blur={() => (value = updatedValue)}
on:keydown={(e) => {
oninput={(e) => (updatedValue = e.currentTarget.value)}
onblur={() => (value = updatedValue)}
onkeydown={(e) => {
if (e.key === 'Enter') {
value = updatedValue;
}