pika-ux 1.0.0-beta.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/template-files/pnpm-workspace.yaml +3 -3
- package/dist/cli/template-files/src/App.svelte +1 -1
- package/package.json +13 -13
- package/src/.DS_Store +0 -0
- package/src/App.svelte +2 -4
- package/src/icons/lucide/index.d.ts +397 -40
- package/src/pika/confirm-dialog/confirm-dialog.svelte +1 -1
- package/src/pika/scrollable-tabs/README.md +192 -0
- package/src/pika/scrollable-tabs/add-button.svelte +33 -0
- package/src/pika/scrollable-tabs/content.svelte +23 -0
- package/src/pika/scrollable-tabs/context.svelte.ts +23 -0
- package/src/pika/scrollable-tabs/example.svelte +81 -0
- package/src/pika/scrollable-tabs/index.ts +31 -0
- package/src/pika/scrollable-tabs/list.svelte +15 -0
- package/src/pika/scrollable-tabs/overflow-menu.svelte +119 -0
- package/src/pika/scrollable-tabs/pinned-section.svelte +138 -0
- package/src/pika/scrollable-tabs/pinned-trigger.svelte +81 -0
- package/src/pika/scrollable-tabs/root.svelte +34 -0
- package/src/pika/scrollable-tabs/scrollable-section.svelte +120 -0
- package/src/pika/scrollable-tabs/trigger.svelte +82 -0
- package/src/shadcn/carousel/carousel-content.svelte +36 -31
- package/src/shadcn/carousel/carousel-item.svelte +22 -18
- package/src/shadcn/carousel/carousel-next.svelte +29 -22
- package/src/shadcn/carousel/carousel-previous.svelte +29 -22
- package/src/shadcn/carousel/carousel.svelte +77 -73
- package/src/shadcn/carousel/context.ts +37 -32
- package/src/shadcn/dropdown-menu/dropdown-menu-group.svelte +2 -3
- package/src/shadcn/dropdown-menu/dropdown-menu-item.svelte +1 -1
- package/src/shadcn/dropdown-menu/dropdown-menu-label.svelte +1 -7
- package/src/shadcn/dropdown-menu/dropdown-menu-radio-group.svelte +3 -13
- package/src/shadcn/dropdown-menu/dropdown-menu-radio-item.svelte +0 -1
- package/src/shadcn/dropdown-menu/dropdown-menu-separator.svelte +1 -7
- package/src/shadcn/dropdown-menu/dropdown-menu-shortcut.svelte +2 -13
- package/src/shadcn/dropdown-menu/dropdown-menu-sub-content.svelte +0 -1
- package/src/shadcn/dropdown-menu/dropdown-menu-sub-trigger.svelte +1 -2
- package/src/shadcn/dropdown-menu/dropdown-menu-trigger.svelte +2 -3
- package/src/shadcn/dropdown-menu/index.ts +44 -45
- package/src/shadcn/dropdown-menu copy/dropdown-menu-checkbox-item.svelte +41 -0
- package/src/shadcn/dropdown-menu copy/dropdown-menu-content.svelte +27 -0
- package/src/shadcn/dropdown-menu copy/dropdown-menu-group-heading.svelte +22 -0
- package/src/shadcn/dropdown-menu copy/dropdown-menu-group.svelte +7 -0
- package/src/shadcn/dropdown-menu copy/dropdown-menu-item.svelte +27 -0
- package/src/shadcn/dropdown-menu copy/dropdown-menu-label.svelte +24 -0
- package/src/shadcn/dropdown-menu copy/dropdown-menu-radio-group.svelte +16 -0
- package/src/shadcn/dropdown-menu copy/dropdown-menu-radio-item.svelte +26 -0
- package/src/shadcn/dropdown-menu copy/dropdown-menu-separator.svelte +13 -0
- package/src/shadcn/dropdown-menu copy/dropdown-menu-shortcut.svelte +20 -0
- package/src/shadcn/dropdown-menu copy/dropdown-menu-sub-content.svelte +16 -0
- package/src/shadcn/dropdown-menu copy/dropdown-menu-sub-trigger.svelte +29 -0
- package/src/shadcn/dropdown-menu copy/dropdown-menu-trigger.svelte +7 -0
- package/src/shadcn/spinner/index.ts +1 -0
- package/src/shadcn/spinner/spinner.svelte +9 -0
- package/src/shadcn/toggle-group/toggle-group.svelte +23 -28
- package/src/pika/index.ts +0 -29
- package/src/shadcn/index.ts +0 -40
- /package/dist/cli/template-files/src/lib/{Counter.svelte → counter.svelte} +0 -0
|
@@ -1,88 +1,92 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
type CarouselAPI,
|
|
4
|
+
type CarouselProps,
|
|
5
|
+
type EmblaContext,
|
|
6
|
+
setEmblaContext,
|
|
7
|
+
} from "./context.js";
|
|
8
|
+
import { cn } from "../utils.js";
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}: WithElementRef<CarouselProps> = $props();
|
|
10
|
+
let {
|
|
11
|
+
opts = {},
|
|
12
|
+
plugins = [],
|
|
13
|
+
setApi = () => {},
|
|
14
|
+
orientation = "horizontal",
|
|
15
|
+
class: className,
|
|
16
|
+
children,
|
|
17
|
+
...restProps
|
|
18
|
+
}: CarouselProps = $props();
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
let carouselState = $state<EmblaContext>({
|
|
21
|
+
api: undefined,
|
|
22
|
+
scrollPrev,
|
|
23
|
+
scrollNext,
|
|
24
|
+
orientation,
|
|
25
|
+
canScrollNext: false,
|
|
26
|
+
canScrollPrev: false,
|
|
27
|
+
handleKeyDown,
|
|
28
|
+
options: opts,
|
|
29
|
+
plugins,
|
|
30
|
+
onInit,
|
|
31
|
+
scrollSnaps: [],
|
|
32
|
+
selectedIndex: 0,
|
|
33
|
+
scrollTo,
|
|
34
|
+
});
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
setEmblaContext(carouselState);
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
function scrollPrev() {
|
|
39
|
+
carouselState.api?.scrollPrev();
|
|
40
|
+
}
|
|
41
|
+
function scrollNext() {
|
|
42
|
+
carouselState.api?.scrollNext();
|
|
43
|
+
}
|
|
44
|
+
function scrollTo(index: number, jump?: boolean) {
|
|
45
|
+
carouselState.api?.scrollTo(index, jump);
|
|
46
|
+
}
|
|
37
47
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
48
|
+
function onSelect(api: CarouselAPI) {
|
|
49
|
+
if (!api) return;
|
|
50
|
+
carouselState.canScrollPrev = api.canScrollPrev();
|
|
51
|
+
carouselState.canScrollNext = api.canScrollNext();
|
|
52
|
+
carouselState.selectedIndex = api.selectedScrollSnap();
|
|
53
|
+
}
|
|
41
54
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
55
|
+
$effect(() => {
|
|
56
|
+
if (carouselState.api) {
|
|
57
|
+
onSelect(carouselState.api);
|
|
58
|
+
carouselState.api.on("select", onSelect);
|
|
59
|
+
carouselState.api.on("reInit", onSelect);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
45
62
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
63
|
+
function handleKeyDown(e: KeyboardEvent) {
|
|
64
|
+
if (e.key === "ArrowLeft") {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
scrollPrev();
|
|
67
|
+
} else if (e.key === "ArrowRight") {
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
scrollNext();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
52
72
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
scrollPrev();
|
|
57
|
-
} else if (e.key === 'ArrowRight') {
|
|
58
|
-
e.preventDefault();
|
|
59
|
-
scrollNext();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
73
|
+
$effect(() => {
|
|
74
|
+
setApi(carouselState.api);
|
|
75
|
+
});
|
|
62
76
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
setApi(carouselState.api);
|
|
77
|
+
function onInit(event: CustomEvent<CarouselAPI>) {
|
|
78
|
+
carouselState.api = event.detail;
|
|
66
79
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
onSelect();
|
|
70
|
-
}
|
|
80
|
+
carouselState.scrollSnaps = carouselState.api.scrollSnapList();
|
|
81
|
+
}
|
|
71
82
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
83
|
+
$effect(() => {
|
|
84
|
+
return () => {
|
|
85
|
+
carouselState.api?.off("select", onSelect);
|
|
86
|
+
};
|
|
87
|
+
});
|
|
77
88
|
</script>
|
|
78
89
|
|
|
79
|
-
<div
|
|
80
|
-
|
|
81
|
-
data-slot="carousel"
|
|
82
|
-
class={cn('relative', className)}
|
|
83
|
-
role="region"
|
|
84
|
-
aria-roledescription="carousel"
|
|
85
|
-
{...restProps}
|
|
86
|
-
>
|
|
87
|
-
{@render children?.()}
|
|
90
|
+
<div class={cn("relative", className)} role="region" aria-roledescription="carousel" {...restProps}>
|
|
91
|
+
{@render children?.()}
|
|
88
92
|
</div>
|
|
@@ -1,51 +1,56 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type
|
|
3
|
-
import { getContext, hasContext, setContext } from
|
|
4
|
-
import type {
|
|
1
|
+
import type { EmblaCarouselSvelteType } from "embla-carousel-svelte";
|
|
2
|
+
import type emblaCarouselSvelte from "embla-carousel-svelte";
|
|
3
|
+
import { getContext, hasContext, setContext } from "svelte";
|
|
4
|
+
import type { WithElementRef } from "bits-ui";
|
|
5
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
5
6
|
|
|
6
7
|
export type CarouselAPI =
|
|
7
|
-
|
|
8
|
+
NonNullable<NonNullable<EmblaCarouselSvelteType["$$_attributes"]>["on:emblaInit"]> extends (
|
|
9
|
+
evt: CustomEvent<infer CarouselAPI>
|
|
10
|
+
) => void
|
|
11
|
+
? CarouselAPI
|
|
12
|
+
: never;
|
|
8
13
|
|
|
9
14
|
type EmblaCarouselConfig = NonNullable<Parameters<typeof emblaCarouselSvelte>[1]>;
|
|
10
15
|
|
|
11
|
-
export type CarouselOptions = EmblaCarouselConfig[
|
|
12
|
-
export type CarouselPlugins = EmblaCarouselConfig[
|
|
16
|
+
export type CarouselOptions = EmblaCarouselConfig["options"];
|
|
17
|
+
export type CarouselPlugins = EmblaCarouselConfig["plugins"];
|
|
13
18
|
|
|
14
19
|
////
|
|
15
20
|
|
|
16
21
|
export type CarouselProps = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
opts?: CarouselOptions;
|
|
23
|
+
plugins?: CarouselPlugins;
|
|
24
|
+
setApi?: (api: CarouselAPI | undefined) => void;
|
|
25
|
+
orientation?: "horizontal" | "vertical";
|
|
21
26
|
} & WithElementRef<HTMLAttributes<HTMLDivElement>>;
|
|
22
27
|
|
|
23
|
-
const EMBLA_CAROUSEL_CONTEXT = Symbol(
|
|
28
|
+
const EMBLA_CAROUSEL_CONTEXT = Symbol("EMBLA_CAROUSEL_CONTEXT");
|
|
24
29
|
|
|
25
30
|
export type EmblaContext = {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
api: CarouselAPI | undefined;
|
|
32
|
+
orientation: "horizontal" | "vertical";
|
|
33
|
+
scrollNext: () => void;
|
|
34
|
+
scrollPrev: () => void;
|
|
35
|
+
canScrollNext: boolean;
|
|
36
|
+
canScrollPrev: boolean;
|
|
37
|
+
handleKeyDown: (e: KeyboardEvent) => void;
|
|
38
|
+
options: CarouselOptions;
|
|
39
|
+
plugins: CarouselPlugins;
|
|
40
|
+
onInit: (e: CustomEvent<CarouselAPI>) => void;
|
|
41
|
+
scrollTo: (index: number, jump?: boolean) => void;
|
|
42
|
+
scrollSnaps: number[];
|
|
43
|
+
selectedIndex: number;
|
|
39
44
|
};
|
|
40
45
|
|
|
41
46
|
export function setEmblaContext(config: EmblaContext): EmblaContext {
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
setContext(EMBLA_CAROUSEL_CONTEXT, config);
|
|
48
|
+
return config;
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
export function getEmblaContext(name =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
export function getEmblaContext(name = "This component") {
|
|
52
|
+
if (!hasContext(EMBLA_CAROUSEL_CONTEXT)) {
|
|
53
|
+
throw new Error(`${name} must be used within a <Carousel.Root> component`);
|
|
54
|
+
}
|
|
55
|
+
return getContext<ReturnType<typeof setEmblaContext>>(EMBLA_CAROUSEL_CONTEXT);
|
|
51
56
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
let { ref = $bindable(null), ...restProps }: DropdownMenuPrimitive.GroupProps = $props();
|
|
2
|
+
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
|
3
|
+
let { ref = $bindable(null), ...restProps }: DropdownMenuPrimitive.GroupProps = $props();
|
|
5
4
|
</script>
|
|
6
5
|
|
|
7
6
|
<DropdownMenuPrimitive.Group bind:ref data-slot="dropdown-menu-group" {...restProps} />
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
data-inset={inset}
|
|
21
21
|
data-variant={variant}
|
|
22
22
|
class={cn(
|
|
23
|
-
"data-highlighted:bg-accent data-highlighted:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:data-highlighted:bg-destructive/10 dark:data-[variant=destructive]:data-highlighted:bg-destructive/20 data-[variant=destructive]:data-highlighted:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground outline-hidden relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm data-[disabled]:pointer-events-none data-[inset]:pl-8 data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
23
|
+
"data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:data-[highlighted]:bg-destructive/10 dark:data-[variant=destructive]:data-[highlighted]:bg-destructive/20 data-[variant=destructive]:data-[highlighted]:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground outline-hidden relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm data-[disabled]:pointer-events-none data-[inset]:pl-8 data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
24
24
|
className
|
|
25
25
|
)}
|
|
26
26
|
{...restProps}
|
|
@@ -13,12 +13,6 @@
|
|
|
13
13
|
} = $props();
|
|
14
14
|
</script>
|
|
15
15
|
|
|
16
|
-
<div
|
|
17
|
-
bind:this={ref}
|
|
18
|
-
data-slot="dropdown-menu-label"
|
|
19
|
-
data-inset={inset}
|
|
20
|
-
class={cn('px-2 py-1.5 text-sm font-semibold data-[inset]:pl-8', className)}
|
|
21
|
-
{...restProps}
|
|
22
|
-
>
|
|
16
|
+
<div bind:this={ref} data-slot="dropdown-menu-label" data-inset={inset} class={cn('px-2 py-1.5 text-sm font-semibold data-[inset]:pl-8', className)} {...restProps}>
|
|
23
17
|
{@render children?.()}
|
|
24
18
|
</div>
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
let {
|
|
5
|
-
ref = $bindable(null),
|
|
6
|
-
value = $bindable(),
|
|
7
|
-
...restProps
|
|
8
|
-
}: DropdownMenuPrimitive.RadioGroupProps = $props();
|
|
2
|
+
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
|
3
|
+
let { ref = $bindable(null), value = $bindable(), ...restProps }: DropdownMenuPrimitive.RadioGroupProps = $props();
|
|
9
4
|
</script>
|
|
10
5
|
|
|
11
|
-
<DropdownMenuPrimitive.RadioGroup
|
|
12
|
-
bind:ref
|
|
13
|
-
bind:value
|
|
14
|
-
data-slot="dropdown-menu-radio-group"
|
|
15
|
-
{...restProps}
|
|
16
|
-
/>
|
|
6
|
+
<DropdownMenuPrimitive.RadioGroup bind:ref bind:value data-slot="dropdown-menu-radio-group" {...restProps} />
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
|
3
3
|
import CircleIcon from '$icons/lucide/circle';
|
|
4
4
|
import { cn, type WithoutChild } from '../utils.js';
|
|
5
|
-
|
|
6
5
|
let { ref = $bindable(null), class: className, children: childrenProp, ...restProps }: WithoutChild<DropdownMenuPrimitive.RadioItemProps> = $props();
|
|
7
6
|
</script>
|
|
8
7
|
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
|
3
3
|
import { cn } from '../utils.js';
|
|
4
|
-
|
|
5
4
|
let { ref = $bindable(null), class: className, ...restProps }: DropdownMenuPrimitive.SeparatorProps = $props();
|
|
6
5
|
</script>
|
|
7
6
|
|
|
8
|
-
<DropdownMenuPrimitive.Separator
|
|
9
|
-
bind:ref
|
|
10
|
-
data-slot="dropdown-menu-separator"
|
|
11
|
-
class={cn('bg-border -mx-1 my-1 h-px', className)}
|
|
12
|
-
{...restProps}
|
|
13
|
-
/>
|
|
7
|
+
<DropdownMenuPrimitive.Separator bind:ref data-slot="dropdown-menu-separator" class={cn('bg-border -mx-1 my-1 h-px', className)} {...restProps} />
|
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
3
|
import { cn, type WithElementRef } from '../utils.js';
|
|
4
|
-
|
|
5
|
-
let {
|
|
6
|
-
ref = $bindable(null),
|
|
7
|
-
class: className,
|
|
8
|
-
children,
|
|
9
|
-
...restProps
|
|
10
|
-
}: WithElementRef<HTMLAttributes<HTMLSpanElement>> = $props();
|
|
4
|
+
let { ref = $bindable(null), class: className, children, ...restProps }: WithElementRef<HTMLAttributes<HTMLSpanElement>> = $props();
|
|
11
5
|
</script>
|
|
12
6
|
|
|
13
|
-
<span
|
|
14
|
-
bind:this={ref}
|
|
15
|
-
data-slot="dropdown-menu-shortcut"
|
|
16
|
-
class={cn('text-muted-foreground ml-auto text-xs tracking-widest', className)}
|
|
17
|
-
{...restProps}
|
|
18
|
-
>
|
|
7
|
+
<span bind:this={ref} data-slot="dropdown-menu-shortcut" class={cn('text-muted-foreground ml-auto text-xs tracking-widest', className)} {...restProps}>
|
|
19
8
|
{@render children?.()}
|
|
20
9
|
</span>
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
|
3
3
|
import ChevronRightIcon from '$icons/lucide/chevron-right';
|
|
4
4
|
import { cn } from '../utils.js';
|
|
5
|
-
|
|
6
5
|
let {
|
|
7
6
|
ref = $bindable(null),
|
|
8
7
|
class: className,
|
|
@@ -19,7 +18,7 @@
|
|
|
19
18
|
data-slot="dropdown-menu-sub-trigger"
|
|
20
19
|
data-inset={inset}
|
|
21
20
|
class={cn(
|
|
22
|
-
"data-highlighted:bg-accent data-highlighted:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground outline-hidden [&_svg:not([class*='text-'])]:text-muted-foreground flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm data-[disabled]:pointer-events-none data-[inset]:pl-8 data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
21
|
+
"data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground outline-hidden [&_svg:not([class*='text-'])]:text-muted-foreground flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm data-[disabled]:pointer-events-none data-[inset]:pl-8 data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
23
22
|
className
|
|
24
23
|
)}
|
|
25
24
|
{...restProps}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
let { ref = $bindable(null), ...restProps }: DropdownMenuPrimitive.TriggerProps = $props();
|
|
2
|
+
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
|
3
|
+
let { ref = $bindable(null), ...restProps }: DropdownMenuPrimitive.TriggerProps = $props();
|
|
5
4
|
</script>
|
|
6
5
|
|
|
7
6
|
<DropdownMenuPrimitive.Trigger bind:ref data-slot="dropdown-menu-trigger" {...restProps} />
|
|
@@ -1,49 +1,48 @@
|
|
|
1
|
-
import { DropdownMenu as DropdownMenuPrimitive } from
|
|
2
|
-
import CheckboxItem from
|
|
3
|
-
import Content from
|
|
4
|
-
import Group from
|
|
5
|
-
import Item from
|
|
6
|
-
import Label from
|
|
7
|
-
import RadioGroup from
|
|
8
|
-
import RadioItem from
|
|
9
|
-
import Separator from
|
|
10
|
-
import Shortcut from
|
|
11
|
-
import Trigger from
|
|
12
|
-
import SubContent from
|
|
13
|
-
import SubTrigger from
|
|
14
|
-
import GroupHeading from
|
|
1
|
+
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
|
2
|
+
import CheckboxItem from './dropdown-menu-checkbox-item.svelte';
|
|
3
|
+
import Content from './dropdown-menu-content.svelte';
|
|
4
|
+
import Group from './dropdown-menu-group.svelte';
|
|
5
|
+
import Item from './dropdown-menu-item.svelte';
|
|
6
|
+
import Label from './dropdown-menu-label.svelte';
|
|
7
|
+
import RadioGroup from './dropdown-menu-radio-group.svelte';
|
|
8
|
+
import RadioItem from './dropdown-menu-radio-item.svelte';
|
|
9
|
+
import Separator from './dropdown-menu-separator.svelte';
|
|
10
|
+
import Shortcut from './dropdown-menu-shortcut.svelte';
|
|
11
|
+
import Trigger from './dropdown-menu-trigger.svelte';
|
|
12
|
+
import SubContent from './dropdown-menu-sub-content.svelte';
|
|
13
|
+
import SubTrigger from './dropdown-menu-sub-trigger.svelte';
|
|
14
|
+
import GroupHeading from './dropdown-menu-group-heading.svelte';
|
|
15
15
|
const Sub = DropdownMenuPrimitive.Sub;
|
|
16
16
|
const Root = DropdownMenuPrimitive.Root;
|
|
17
|
-
|
|
18
17
|
export {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
18
|
+
CheckboxItem,
|
|
19
|
+
Content,
|
|
20
|
+
Root as DropdownMenu,
|
|
21
|
+
CheckboxItem as DropdownMenuCheckboxItem,
|
|
22
|
+
Content as DropdownMenuContent,
|
|
23
|
+
Group as DropdownMenuGroup,
|
|
24
|
+
Item as DropdownMenuItem,
|
|
25
|
+
Label as DropdownMenuLabel,
|
|
26
|
+
RadioGroup as DropdownMenuRadioGroup,
|
|
27
|
+
RadioItem as DropdownMenuRadioItem,
|
|
28
|
+
Separator as DropdownMenuSeparator,
|
|
29
|
+
Shortcut as DropdownMenuShortcut,
|
|
30
|
+
Sub as DropdownMenuSub,
|
|
31
|
+
SubContent as DropdownMenuSubContent,
|
|
32
|
+
SubTrigger as DropdownMenuSubTrigger,
|
|
33
|
+
Trigger as DropdownMenuTrigger,
|
|
34
|
+
GroupHeading as DropdownMenuGroupHeading,
|
|
35
|
+
Group,
|
|
36
|
+
GroupHeading,
|
|
37
|
+
Item,
|
|
38
|
+
Label,
|
|
39
|
+
RadioGroup,
|
|
40
|
+
RadioItem,
|
|
41
|
+
Root,
|
|
42
|
+
Separator,
|
|
43
|
+
Shortcut,
|
|
44
|
+
Sub,
|
|
45
|
+
SubContent,
|
|
46
|
+
SubTrigger,
|
|
47
|
+
Trigger
|
|
49
48
|
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
|
3
|
+
import CheckIcon from '$icons/lucide/check';
|
|
4
|
+
import MinusIcon from '$icons/lucide/minus';
|
|
5
|
+
import { cn, type WithoutChildrenOrChild } from '../utils.js';
|
|
6
|
+
import type { Snippet } from 'svelte';
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
ref = $bindable(null),
|
|
10
|
+
checked = $bindable(false),
|
|
11
|
+
indeterminate = $bindable(false),
|
|
12
|
+
class: className,
|
|
13
|
+
children: childrenProp,
|
|
14
|
+
...restProps
|
|
15
|
+
}: WithoutChildrenOrChild<DropdownMenuPrimitive.CheckboxItemProps> & {
|
|
16
|
+
children?: Snippet;
|
|
17
|
+
} = $props();
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<DropdownMenuPrimitive.CheckboxItem
|
|
21
|
+
bind:ref
|
|
22
|
+
bind:checked
|
|
23
|
+
bind:indeterminate
|
|
24
|
+
data-slot="dropdown-menu-checkbox-item"
|
|
25
|
+
class={cn(
|
|
26
|
+
"focus:bg-accent focus:text-accent-foreground outline-hidden relative flex cursor-default select-none items-center gap-2 rounded-sm py-1.5 pl-8 pr-2 text-sm data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
27
|
+
className
|
|
28
|
+
)}
|
|
29
|
+
{...restProps}
|
|
30
|
+
>
|
|
31
|
+
{#snippet children({ checked, indeterminate })}
|
|
32
|
+
<span class="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
|
33
|
+
{#if indeterminate}
|
|
34
|
+
<MinusIcon class="size-4" />
|
|
35
|
+
{:else}
|
|
36
|
+
<CheckIcon class={cn('size-4', !checked && 'text-transparent')} />
|
|
37
|
+
{/if}
|
|
38
|
+
</span>
|
|
39
|
+
{@render childrenProp?.()}
|
|
40
|
+
{/snippet}
|
|
41
|
+
</DropdownMenuPrimitive.CheckboxItem>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../utils.js';
|
|
3
|
+
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
sideOffset = 4,
|
|
8
|
+
portalProps,
|
|
9
|
+
class: className,
|
|
10
|
+
...restProps
|
|
11
|
+
}: DropdownMenuPrimitive.ContentProps & {
|
|
12
|
+
portalProps?: DropdownMenuPrimitive.PortalProps;
|
|
13
|
+
} = $props();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<DropdownMenuPrimitive.Portal {...portalProps}>
|
|
17
|
+
<DropdownMenuPrimitive.Content
|
|
18
|
+
bind:ref
|
|
19
|
+
data-slot="dropdown-menu-content"
|
|
20
|
+
{sideOffset}
|
|
21
|
+
class={cn(
|
|
22
|
+
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 max-h-(--bits-dropdown-menu-content-available-height) origin-(--bits-dropdown-menu-content-transform-origin) z-50 min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border p-1 shadow-md outline-none',
|
|
23
|
+
className
|
|
24
|
+
)}
|
|
25
|
+
{...restProps}
|
|
26
|
+
/>
|
|
27
|
+
</DropdownMenuPrimitive.Portal>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
|
3
|
+
import { cn } from '../utils.js';
|
|
4
|
+
import type { ComponentProps } from 'svelte';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
ref = $bindable(null),
|
|
8
|
+
class: className,
|
|
9
|
+
inset,
|
|
10
|
+
...restProps
|
|
11
|
+
}: ComponentProps<typeof DropdownMenuPrimitive.GroupHeading> & {
|
|
12
|
+
inset?: boolean;
|
|
13
|
+
} = $props();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<DropdownMenuPrimitive.GroupHeading
|
|
17
|
+
bind:ref
|
|
18
|
+
data-slot="dropdown-menu-group-heading"
|
|
19
|
+
data-inset={inset}
|
|
20
|
+
class={cn('px-2 py-1.5 text-sm font-semibold data-[inset]:pl-8', className)}
|
|
21
|
+
{...restProps}
|
|
22
|
+
/>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
|
|
3
|
+
|
|
4
|
+
let { ref = $bindable(null), ...restProps }: DropdownMenuPrimitive.GroupProps = $props();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<DropdownMenuPrimitive.Group bind:ref data-slot="dropdown-menu-group" {...restProps} />
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../utils.js';
|
|
3
|
+
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
class: className,
|
|
8
|
+
inset,
|
|
9
|
+
variant = 'default',
|
|
10
|
+
...restProps
|
|
11
|
+
}: DropdownMenuPrimitive.ItemProps & {
|
|
12
|
+
inset?: boolean;
|
|
13
|
+
variant?: 'default' | 'destructive';
|
|
14
|
+
} = $props();
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<DropdownMenuPrimitive.Item
|
|
18
|
+
bind:ref
|
|
19
|
+
data-slot="dropdown-menu-item"
|
|
20
|
+
data-inset={inset}
|
|
21
|
+
data-variant={variant}
|
|
22
|
+
class={cn(
|
|
23
|
+
"data-highlighted:bg-accent data-highlighted:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:data-highlighted:bg-destructive/10 dark:data-[variant=destructive]:data-highlighted:bg-destructive/20 data-[variant=destructive]:data-highlighted:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground outline-hidden relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm data-[disabled]:pointer-events-none data-[inset]:pl-8 data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
24
|
+
className
|
|
25
|
+
)}
|
|
26
|
+
{...restProps}
|
|
27
|
+
/>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn, type WithElementRef } from '../utils.js';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
class: className,
|
|
8
|
+
inset,
|
|
9
|
+
children,
|
|
10
|
+
...restProps
|
|
11
|
+
}: WithElementRef<HTMLAttributes<HTMLDivElement>> & {
|
|
12
|
+
inset?: boolean;
|
|
13
|
+
} = $props();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<div
|
|
17
|
+
bind:this={ref}
|
|
18
|
+
data-slot="dropdown-menu-label"
|
|
19
|
+
data-inset={inset}
|
|
20
|
+
class={cn('px-2 py-1.5 text-sm font-semibold data-[inset]:pl-8', className)}
|
|
21
|
+
{...restProps}
|
|
22
|
+
>
|
|
23
|
+
{@render children?.()}
|
|
24
|
+
</div>
|