Files
gpx.studio/website/src/lib/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte

45 lines
1.4 KiB
Svelte
Raw Normal View History

2024-04-08 17:12:39 +02:00
<script lang="ts">
2025-06-21 21:07:36 +02:00
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
2026-04-06 18:22:01 +02:00
import MinusIcon from '@lucide/svelte/icons/minus';
import CheckIcon from '@lucide/svelte/icons/check';
2025-06-21 21:07:36 +02:00
import { cn, type WithoutChildrenOrChild } from "$lib/utils.js";
2025-06-08 16:32:41 +02:00
import type { Snippet } from "svelte";
2024-04-08 17:12:39 +02:00
2025-06-08 16:32:41 +02:00
let {
ref = $bindable(null),
checked = $bindable(false),
indeterminate = $bindable(false),
class: className,
children: childrenProp,
...restProps
}: WithoutChildrenOrChild<DropdownMenuPrimitive.CheckboxItemProps> & {
children?: Snippet;
} = $props();
2024-04-08 17:12:39 +02:00
</script>
<DropdownMenuPrimitive.CheckboxItem
2025-06-08 16:32:41 +02:00
bind:ref
2024-04-08 17:12:39 +02:00
bind:checked
2025-06-08 16:32:41 +02:00
bind:indeterminate
2025-06-21 21:07:36 +02:00
data-slot="dropdown-menu-checkbox-item"
2024-04-08 17:12:39 +02:00
class={cn(
2026-04-06 18:22:01 +02:00
"focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm data-inset:pl-7 [&_svg:not([class*='size-'])]:size-4 relative flex cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
2024-04-08 17:12:39 +02:00
className
)}
2025-06-08 16:32:41 +02:00
{...restProps}
2024-04-08 17:12:39 +02:00
>
2025-06-08 16:32:41 +02:00
{#snippet children({ checked, indeterminate })}
2026-04-06 18:22:01 +02:00
<span
class="absolute right-2 flex items-center justify-center pointer-events-none"
data-slot="dropdown-menu-checkbox-item-indicator"
>
2025-06-08 16:32:41 +02:00
{#if indeterminate}
2026-04-06 18:22:01 +02:00
<MinusIcon />
{:else if checked}
<CheckIcon />
2025-06-08 16:32:41 +02:00
{/if}
</span>
{@render childrenProp?.()}
{/snippet}
2024-04-08 17:12:39 +02:00
</DropdownMenuPrimitive.CheckboxItem>