mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-10-06 17:59:03 +02:00
45 lines
1.5 KiB
Svelte
45 lines
1.5 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/style.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 relative flex cursor-default items-center gap-2.5 rounded-2xl py-2 pr-8 pl-3 text-sm font-medium outline-hidden select-none data-inset:pl-9.5 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, indeterminate })}
|
|
<span
|
|
class="pointer-events-none absolute right-2 flex items-center justify-center"
|
|
data-slot="dropdown-menu-checkbox-item-indicator"
|
|
>
|
|
{#if indeterminate}
|
|
<MinusIcon />
|
|
{:else if checked}
|
|
<CheckIcon />
|
|
{/if}
|
|
</span>
|
|
{@render childrenProp?.()}
|
|
{/snippet}
|
|
</DropdownMenuPrimitive.CheckboxItem>
|