mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-04-21 19:11:17 +00:00
42 lines
1.2 KiB
Svelte
42 lines
1.2 KiB
Svelte
<script lang="ts">
|
|
import { ContextMenu as ContextMenuPrimitive } from "bits-ui";
|
|
import { cn, type WithoutChildrenOrChild } from "$lib/utils.js";
|
|
import type { Snippet } from "svelte";
|
|
import CheckIcon from '@lucide/svelte/icons/check';
|
|
|
|
let {
|
|
ref = $bindable(null),
|
|
checked = $bindable(false),
|
|
indeterminate = $bindable(false),
|
|
class: className,
|
|
inset,
|
|
children: childrenProp,
|
|
...restProps
|
|
}: WithoutChildrenOrChild<ContextMenuPrimitive.CheckboxItemProps> & {
|
|
inset?: boolean;
|
|
children?: Snippet;
|
|
} = $props();
|
|
</script>
|
|
|
|
<ContextMenuPrimitive.CheckboxItem
|
|
bind:ref
|
|
bind:checked
|
|
bind:indeterminate
|
|
data-slot="context-menu-checkbox-item"
|
|
data-inset={inset}
|
|
class={cn(
|
|
"focus:bg-accent 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 })}
|
|
<span class="absolute right-2 pointer-events-none">
|
|
{#if checked}
|
|
<CheckIcon />
|
|
{/if}
|
|
</span>
|
|
{@render childrenProp?.()}
|
|
{/snippet}
|
|
</ContextMenuPrimitive.CheckboxItem>
|