2023-10-23 11:38:41 -07:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { quintOut } from 'svelte/easing';
|
|
|
|
|
import { fly } from 'svelte/transition';
|
2024-06-24 15:50:01 +02:00
|
|
|
import { t } from 'svelte-i18n';
|
2023-10-23 11:38:41 -07:00
|
|
|
|
|
|
|
|
export let value: string;
|
|
|
|
|
export let label = '';
|
|
|
|
|
export let desc = '';
|
|
|
|
|
export let required = false;
|
|
|
|
|
export let disabled = false;
|
|
|
|
|
export let isEdited = false;
|
|
|
|
|
|
|
|
|
|
const handleInput = (e: Event) => {
|
|
|
|
|
value = (e.target as HTMLInputElement).value;
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div class="mb-4 w-full">
|
|
|
|
|
<div class={`flex h-[26px] place-items-center gap-1`}>
|
2024-06-14 07:32:41 +00:00
|
|
|
<label class="font-medium text-immich-primary dark:text-immich-dark-primary text-sm" for={label}>{label}</label>
|
2023-10-23 11:38:41 -07:00
|
|
|
{#if required}
|
|
|
|
|
<div class="text-red-400">*</div>
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
{#if isEdited}
|
|
|
|
|
<div
|
|
|
|
|
transition:fly={{ x: 10, duration: 200, easing: quintOut }}
|
|
|
|
|
class="rounded-full bg-orange-100 px-2 text-[10px] text-orange-900"
|
|
|
|
|
>
|
2024-06-24 15:50:01 +02:00
|
|
|
{$t('unsaved_change')}
|
2023-10-23 11:38:41 -07:00
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{#if desc}
|
|
|
|
|
<p class="immich-form-label pb-2 text-sm" id="{label}-desc">
|
|
|
|
|
{desc}
|
|
|
|
|
</p>
|
|
|
|
|
{:else}
|
|
|
|
|
<slot name="desc" />
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
<textarea
|
|
|
|
|
class="immich-form-input w-full pb-2"
|
|
|
|
|
aria-describedby={desc ? `${label}-desc` : undefined}
|
|
|
|
|
aria-labelledby="{label}-label"
|
|
|
|
|
id={label}
|
|
|
|
|
name={label}
|
|
|
|
|
{required}
|
|
|
|
|
{value}
|
|
|
|
|
on:input={handleInput}
|
|
|
|
|
{disabled}
|
2024-11-02 16:49:07 +01:00
|
|
|
></textarea>
|
2023-10-23 11:38:41 -07:00
|
|
|
</div>
|