mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-04-07 20:30:22 +00:00
45 lines
1.4 KiB
Svelte
45 lines
1.4 KiB
Svelte
<script lang="ts">
|
|
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
|
|
import MinusIcon from '@lucide/svelte/icons/minus';
|
|
import CheckIcon from '@lucide/svelte/icons/check';
|
|
import { cn, type WithoutChildrenOrChild } from "$lib/utils.js";
|
|
import type { Snippet } from "svelte";
|
|
|
|
let {
|
|
ref = $bindable(null),
|
|
checked = $bindable(false),
|
|
indeterminate = $bindable(false),
|
|
class: className,
|
|
children: childrenProp,
|
|
...restProps
|
|
}: WithoutChildrenOrChild<DropdownMenuPrimitive.CheckboxItemProps> & {
|
|
children?: Snippet;
|
|
} = $props();
|
|
</script>
|
|
|
|
<DropdownMenuPrimitive.CheckboxItem
|
|
bind:ref
|
|
bind:checked
|
|
bind:indeterminate
|
|
data-slot="dropdown-menu-checkbox-item"
|
|
class={cn(
|
|
"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",
|
|
className
|
|
)}
|
|
{...restProps}
|
|
>
|
|
{#snippet children({ checked, indeterminate })}
|
|
<span
|
|
class="absolute right-2 flex items-center justify-center pointer-events-none"
|
|
data-slot="dropdown-menu-checkbox-item-indicator"
|
|
>
|
|
{#if indeterminate}
|
|
<MinusIcon />
|
|
{:else if checked}
|
|
<CheckIcon />
|
|
{/if}
|
|
</span>
|
|
{@render childrenProp?.()}
|
|
{/snippet}
|
|
</DropdownMenuPrimitive.CheckboxItem>
|