42 lines
1.3 KiB
Svelte
42 lines
1.3 KiB
Svelte
<script lang="ts">
|
|
import { ContextMenu as ContextMenuPrimitive } from 'bits-ui';
|
|
import { cn, type WithoutChildrenOrChild } from '$lib/utils/format.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(
|
|
"relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
className
|
|
)}
|
|
{...restProps}
|
|
>
|
|
{#snippet children({ checked })}
|
|
<span class="pointer-events-none absolute right-2">
|
|
{#if checked}
|
|
<CheckIcon />
|
|
{/if}
|
|
</span>
|
|
{@render childrenProp?.()}
|
|
{/snippet}
|
|
</ContextMenuPrimitive.CheckboxItem>
|