2024-01-26 18:02:56 +01:00
|
|
|
<script lang="ts">
|
2024-04-26 06:18:19 +00:00
|
|
|
import Checkbox from '$lib/components/elements/checkbox.svelte';
|
2024-01-26 18:02:56 +01:00
|
|
|
import { quintOut } from 'svelte/easing';
|
|
|
|
|
import { fly } from 'svelte/transition';
|
|
|
|
|
|
|
|
|
|
export let value: string[];
|
|
|
|
|
export let options: { value: string; text: string }[];
|
|
|
|
|
export let label = '';
|
|
|
|
|
export let desc = '';
|
|
|
|
|
export let name = '';
|
|
|
|
|
export let isEdited = false;
|
|
|
|
|
export let disabled = false;
|
|
|
|
|
|
|
|
|
|
function handleCheckboxChange(option: string) {
|
2024-02-02 04:18:00 +01:00
|
|
|
value = value.includes(option) ? value.filter((item) => item !== option) : [...value, option];
|
2024-01-26 18:02:56 +01:00
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div class="mb-4 w-full">
|
|
|
|
|
<div class={`flex h-[26px] place-items-center gap-1`}>
|
|
|
|
|
<label class={`immich-form-label text-sm`} for="{name}-select">{label}</label>
|
|
|
|
|
|
|
|
|
|
{#if isEdited}
|
|
|
|
|
<div
|
|
|
|
|
transition:fly={{ x: 10, duration: 200, easing: quintOut }}
|
|
|
|
|
class="rounded-full bg-orange-100 px-2 text-[10px] text-orange-900"
|
|
|
|
|
>
|
|
|
|
|
Unsaved change
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{#if desc}
|
|
|
|
|
<p class="immich-form-label pb-2 text-sm" id="{name}-desc">
|
|
|
|
|
{desc}
|
|
|
|
|
</p>
|
|
|
|
|
{/if}
|
2024-04-26 06:18:19 +00:00
|
|
|
<div class="flex flex-col gap-2">
|
|
|
|
|
{#each options as option}
|
|
|
|
|
<Checkbox
|
|
|
|
|
id="{option.value}-checkbox"
|
|
|
|
|
label={option.text}
|
2024-01-26 18:02:56 +01:00
|
|
|
checked={value.includes(option.value)}
|
2024-04-26 06:18:19 +00:00
|
|
|
{disabled}
|
|
|
|
|
labelClass="text-gray-500 dark:text-gray-300"
|
2024-01-26 18:02:56 +01:00
|
|
|
on:change={() => handleCheckboxChange(option.value)}
|
|
|
|
|
/>
|
2024-04-26 06:18:19 +00:00
|
|
|
{/each}
|
|
|
|
|
</div>
|
2024-01-26 18:02:56 +01:00
|
|
|
</div>
|