2023-01-22 02:09:02 +00:00
|
|
|
<script lang="ts">
|
2023-07-01 00:50:47 -04:00
|
|
|
import { quintOut } from 'svelte/easing';
|
|
|
|
|
import { fly } from 'svelte/transition';
|
2024-06-24 15:50:01 +02:00
|
|
|
import { t } from 'svelte-i18n';
|
2024-08-26 21:05:23 -04:00
|
|
|
import Icon from '$lib/components/elements/icon.svelte';
|
|
|
|
|
import { mdiChevronDown } from '@mdi/js';
|
2023-01-22 02:09:02 +00:00
|
|
|
|
2023-08-08 09:39:51 -05:00
|
|
|
export let value: string | number;
|
|
|
|
|
export let options: { value: string | number; text: string }[];
|
2023-07-01 00:50:47 -04:00
|
|
|
export let label = '';
|
|
|
|
|
export let desc = '';
|
|
|
|
|
export let name = '';
|
|
|
|
|
export let isEdited = false;
|
2023-08-08 09:39:51 -05:00
|
|
|
export let number = false;
|
2023-08-25 19:44:52 +02:00
|
|
|
export let disabled = false;
|
2024-09-20 23:02:58 +02:00
|
|
|
export let onSelect: (setting: string | number) => void = () => {};
|
2024-01-26 18:02:56 +01:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
const handleChange = (e: Event) => {
|
|
|
|
|
value = (e.target as HTMLInputElement).value;
|
2023-08-08 09:39:51 -05:00
|
|
|
if (number) {
|
2024-02-02 04:18:00 +01:00
|
|
|
value = Number.parseInt(value);
|
2023-08-08 09:39:51 -05:00
|
|
|
}
|
2024-09-20 23:02:58 +02:00
|
|
|
onSelect(value);
|
2023-07-01 00:50:47 -04:00
|
|
|
};
|
2023-01-22 02:09:02 +00:00
|
|
|
</script>
|
|
|
|
|
|
2023-08-08 09:39:51 -05:00
|
|
|
<div class="mb-4 w-full">
|
2023-07-18 13:19:39 -05:00
|
|
|
<div class={`flex h-[26px] place-items-center gap-1`}>
|
2024-02-23 06:01:19 +01:00
|
|
|
<label class="font-medium text-immich-primary dark:text-immich-dark-primary text-sm" for="{name}-select"
|
|
|
|
|
>{label}</label
|
|
|
|
|
>
|
2023-01-22 02:09:02 +00:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
{#if isEdited}
|
|
|
|
|
<div
|
|
|
|
|
transition:fly={{ x: 10, duration: 200, easing: quintOut }}
|
2023-07-18 13:19:39 -05:00
|
|
|
class="rounded-full bg-orange-100 px-2 text-[10px] text-orange-900"
|
2023-07-01 00:50:47 -04:00
|
|
|
>
|
2024-06-24 15:50:01 +02:00
|
|
|
{$t('unsaved_change')}
|
2023-07-01 00:50:47 -04:00
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
2023-05-22 14:07:43 -04:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
{#if desc}
|
2023-08-08 09:39:51 -05:00
|
|
|
<p class="immich-form-label pb-2 text-sm" id="{name}-desc">
|
2023-07-01 00:50:47 -04:00
|
|
|
{desc}
|
|
|
|
|
</p>
|
|
|
|
|
{/if}
|
2023-05-22 14:07:43 -04:00
|
|
|
|
2024-08-26 21:05:23 -04:00
|
|
|
<div class="grid">
|
|
|
|
|
<Icon
|
|
|
|
|
path={mdiChevronDown}
|
|
|
|
|
size={'1.2em'}
|
|
|
|
|
ariaHidden={true}
|
|
|
|
|
class="pointer-events-none right-1 relative col-start-1 row-start-1 self-center justify-self-end {disabled
|
|
|
|
|
? 'text-immich-bg'
|
|
|
|
|
: 'text-immich-fg dark:text-immich-bg'}"
|
|
|
|
|
/>
|
|
|
|
|
<select
|
|
|
|
|
class="immich-form-input w-full appearance-none row-start-1 col-start-1 !pr-6"
|
|
|
|
|
{disabled}
|
|
|
|
|
aria-describedby={desc ? `${name}-desc` : undefined}
|
|
|
|
|
{name}
|
|
|
|
|
id="{name}-select"
|
|
|
|
|
bind:value
|
|
|
|
|
on:change={handleChange}
|
|
|
|
|
>
|
|
|
|
|
{#each options as option}
|
|
|
|
|
<option value={option.value}>{option.text}</option>
|
|
|
|
|
{/each}
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
2023-01-22 02:09:02 +00:00
|
|
|
</div>
|