summaryrefslogtreecommitdiff
path: root/frontend/src/lib/components/ui/select/select-item.svelte
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/lib/components/ui/select/select-item.svelte')
-rw-r--r--frontend/src/lib/components/ui/select/select-item.svelte42
1 files changed, 42 insertions, 0 deletions
diff --git a/frontend/src/lib/components/ui/select/select-item.svelte b/frontend/src/lib/components/ui/select/select-item.svelte
new file mode 100644
index 0000000..446dfdc
--- /dev/null
+++ b/frontend/src/lib/components/ui/select/select-item.svelte
@@ -0,0 +1,42 @@
+<script lang="ts">
+ import { Select as SelectPrimitive } from "bits-ui";
+ import CheckIcon from '@lucide/svelte/icons/check';
+ import { cn, type WithoutChild } from "$lib/utils.js";
+
+ let {
+ ref = $bindable(null),
+ class: className,
+ value,
+ label,
+ children: childrenProp,
+ ...restProps
+ }: WithoutChild<SelectPrimitive.ItemProps> = $props();
+</script>
+
+<SelectPrimitive.Item
+ bind:ref
+ {value}
+ {label}
+ data-slot="select-item"
+ class={cn(
+ "focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground min-h-7 gap-2 rounded-md px-2 py-1 text-xs/relaxed [&_svg:not([class*='size-'])]:size-3.5 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2 relative flex w-full cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
+ "data-highlighted:bg-accent data-highlighted:text-accent-foreground",
+ className
+ )}
+ {...restProps}
+>
+ {#snippet children({ selected, highlighted })}
+ <span class="pointer-events-none absolute right-2 flex items-center justify-center">
+ {#if selected}
+ <CheckIcon class="pointer-events-none" />
+ {/if}
+ </span>
+ <span class="flex flex-1 gap-2 shrink-0 whitespace-nowrap">
+ {#if childrenProp}
+ {@render childrenProp({ selected, highlighted })}
+ {:else}
+ {label || value}
+ {/if}
+ </span>
+ {/snippet}
+</SelectPrimitive.Item>