mirror of
https://github.com/immich-app/immich.git
synced 2025-12-20 01:11:46 +03:00
chore(web): migration svelte 5 syntax (#13883)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user