@svadmin/ui 0.0.1
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/package.json +44 -0
- package/src/app.css +113 -0
- package/src/components/AdminApp.svelte +127 -0
- package/src/components/AutoForm.svelte +192 -0
- package/src/components/AutoTable.svelte +343 -0
- package/src/components/Breadcrumbs.svelte +51 -0
- package/src/components/ConfirmDialog.svelte +45 -0
- package/src/components/EmptyState.svelte +41 -0
- package/src/components/ErrorBoundary.svelte +51 -0
- package/src/components/FieldRenderer.svelte +154 -0
- package/src/components/Header.svelte +66 -0
- package/src/components/Layout.svelte +66 -0
- package/src/components/PageHeader.svelte +39 -0
- package/src/components/ShowPage.svelte +71 -0
- package/src/components/Sidebar.svelte +169 -0
- package/src/components/StatsCard.svelte +49 -0
- package/src/components/Toast.svelte +48 -0
- package/src/components/ui/alert/alert-description.svelte +17 -0
- package/src/components/ui/alert/alert-title.svelte +17 -0
- package/src/components/ui/alert/alert.svelte +44 -0
- package/src/components/ui/alert/index.ts +14 -0
- package/src/components/ui/avatar/avatar.svelte +62 -0
- package/src/components/ui/avatar/index.ts +2 -0
- package/src/components/ui/badge/badge.svelte +49 -0
- package/src/components/ui/badge/index.ts +2 -0
- package/src/components/ui/button/button.svelte +82 -0
- package/src/components/ui/button/index.ts +17 -0
- package/src/components/ui/card/card-action.svelte +23 -0
- package/src/components/ui/card/card-content.svelte +20 -0
- package/src/components/ui/card/card-description.svelte +20 -0
- package/src/components/ui/card/card-footer.svelte +20 -0
- package/src/components/ui/card/card-header.svelte +23 -0
- package/src/components/ui/card/card-title.svelte +15 -0
- package/src/components/ui/card/card.svelte +22 -0
- package/src/components/ui/card/index.ts +25 -0
- package/src/components/ui/checkbox/checkbox.svelte +39 -0
- package/src/components/ui/checkbox/index.ts +6 -0
- package/src/components/ui/dialog/dialog-close.svelte +11 -0
- package/src/components/ui/dialog/dialog-content.svelte +48 -0
- package/src/components/ui/dialog/dialog-description.svelte +17 -0
- package/src/components/ui/dialog/dialog-footer.svelte +32 -0
- package/src/components/ui/dialog/dialog-header.svelte +20 -0
- package/src/components/ui/dialog/dialog-overlay.svelte +17 -0
- package/src/components/ui/dialog/dialog-portal.svelte +7 -0
- package/src/components/ui/dialog/dialog-title.svelte +17 -0
- package/src/components/ui/dialog/dialog-trigger.svelte +11 -0
- package/src/components/ui/dialog/dialog.svelte +7 -0
- package/src/components/ui/dialog/index.ts +34 -0
- package/src/components/ui/dropdown-menu/dropdown-menu-content.svelte +30 -0
- package/src/components/ui/dropdown-menu/dropdown-menu-item.svelte +36 -0
- package/src/components/ui/dropdown-menu/dropdown-menu-separator.svelte +10 -0
- package/src/components/ui/dropdown-menu/dropdown-menu.svelte +41 -0
- package/src/components/ui/dropdown-menu/index.ts +15 -0
- package/src/components/ui/input/index.ts +7 -0
- package/src/components/ui/input/input.svelte +48 -0
- package/src/components/ui/select/index.ts +2 -0
- package/src/components/ui/select/select.svelte +34 -0
- package/src/components/ui/separator/index.ts +7 -0
- package/src/components/ui/separator/separator.svelte +23 -0
- package/src/components/ui/sheet/index.ts +2 -0
- package/src/components/ui/sheet/sheet.svelte +77 -0
- package/src/components/ui/skeleton/index.ts +2 -0
- package/src/components/ui/skeleton/skeleton.svelte +21 -0
- package/src/components/ui/switch/index.ts +2 -0
- package/src/components/ui/switch/switch.svelte +49 -0
- package/src/components/ui/table/index.ts +28 -0
- package/src/components/ui/table/table-body.svelte +15 -0
- package/src/components/ui/table/table-caption.svelte +20 -0
- package/src/components/ui/table/table-cell.svelte +15 -0
- package/src/components/ui/table/table-footer.svelte +20 -0
- package/src/components/ui/table/table-head.svelte +15 -0
- package/src/components/ui/table/table-header.svelte +20 -0
- package/src/components/ui/table/table-row.svelte +15 -0
- package/src/components/ui/table/table.svelte +17 -0
- package/src/components/ui/tabs/index.ts +15 -0
- package/src/components/ui/tabs/tabs-content.svelte +30 -0
- package/src/components/ui/tabs/tabs-list.svelte +26 -0
- package/src/components/ui/tabs/tabs-trigger.svelte +37 -0
- package/src/components/ui/tabs/tabs.svelte +27 -0
- package/src/components/ui/textarea/index.ts +2 -0
- package/src/components/ui/textarea/textarea.svelte +24 -0
- package/src/components/ui/tooltip/index.ts +19 -0
- package/src/components/ui/tooltip/tooltip-content.svelte +52 -0
- package/src/components/ui/tooltip/tooltip-portal.svelte +7 -0
- package/src/components/ui/tooltip/tooltip-provider.svelte +7 -0
- package/src/components/ui/tooltip/tooltip-trigger.svelte +7 -0
- package/src/components/ui/tooltip/tooltip.svelte +10 -0
- package/src/index.ts +43 -0
- package/src/utils.ts +28 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { type VariantProps, tv } from "tailwind-variants";
|
|
3
|
+
|
|
4
|
+
export const badgeVariants = tv({
|
|
5
|
+
base: "h-5 gap-1 rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-3! focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive group/badge inline-flex w-fit shrink-0 items-center justify-center overflow-hidden whitespace-nowrap transition-colors focus-visible:ring-[3px] [&>svg]:pointer-events-none",
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
|
9
|
+
secondary: "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
|
|
10
|
+
destructive: "bg-destructive/10 [a]:hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 text-destructive dark:bg-destructive/20",
|
|
11
|
+
outline: "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
|
|
12
|
+
ghost: "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
|
|
13
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
defaultVariants: {
|
|
17
|
+
variant: "default",
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export type BadgeVariant = VariantProps<typeof badgeVariants>["variant"];
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<script lang="ts">
|
|
25
|
+
import type { HTMLAnchorAttributes } from "svelte/elements";
|
|
26
|
+
import { cn, type WithElementRef } from "../../../utils.js";
|
|
27
|
+
|
|
28
|
+
let {
|
|
29
|
+
ref = $bindable(null),
|
|
30
|
+
href,
|
|
31
|
+
class: className,
|
|
32
|
+
variant = "default",
|
|
33
|
+
children,
|
|
34
|
+
...restProps
|
|
35
|
+
}: WithElementRef<HTMLAnchorAttributes> & {
|
|
36
|
+
variant?: BadgeVariant;
|
|
37
|
+
} = $props();
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<svelte:element
|
|
41
|
+
this={href ? "a" : "span"}
|
|
42
|
+
bind:this={ref}
|
|
43
|
+
data-slot="badge"
|
|
44
|
+
{href}
|
|
45
|
+
class={cn(badgeVariants({ variant }), className)}
|
|
46
|
+
{...restProps}
|
|
47
|
+
>
|
|
48
|
+
{@render children?.()}
|
|
49
|
+
</svelte:element>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { cn, type WithElementRef } from "../../../utils.js";
|
|
3
|
+
import type { HTMLAnchorAttributes, HTMLButtonAttributes } from "svelte/elements";
|
|
4
|
+
import { type VariantProps, tv } from "tailwind-variants";
|
|
5
|
+
|
|
6
|
+
export const buttonVariants = tv({
|
|
7
|
+
base: "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 rounded-lg border border-transparent bg-clip-padding text-sm font-medium focus-visible:ring-3 active:translate-y-px aria-invalid:ring-3 [&_svg:not([class*='size-'])]:size-4 group/button inline-flex shrink-0 items-center justify-center whitespace-nowrap transition-all outline-none select-none disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
8
|
+
variants: {
|
|
9
|
+
variant: {
|
|
10
|
+
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
|
11
|
+
outline: "border-border bg-background hover:bg-muted hover:text-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 aria-expanded:bg-muted aria-expanded:text-foreground",
|
|
12
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
|
|
13
|
+
ghost: "hover:bg-muted hover:text-foreground dark:hover:bg-muted/50 aria-expanded:bg-muted aria-expanded:text-foreground",
|
|
14
|
+
destructive: "bg-destructive/10 hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/20 text-destructive focus-visible:border-destructive/40 dark:hover:bg-destructive/30",
|
|
15
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
16
|
+
},
|
|
17
|
+
size: {
|
|
18
|
+
default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
19
|
+
xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
20
|
+
sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
|
21
|
+
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",
|
|
22
|
+
icon: "size-8",
|
|
23
|
+
"icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
|
24
|
+
"icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
|
25
|
+
"icon-lg": "size-9",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
defaultVariants: {
|
|
29
|
+
variant: "default",
|
|
30
|
+
size: "default",
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export type ButtonVariant = VariantProps<typeof buttonVariants>["variant"];
|
|
35
|
+
export type ButtonSize = VariantProps<typeof buttonVariants>["size"];
|
|
36
|
+
|
|
37
|
+
export type ButtonProps = WithElementRef<HTMLButtonAttributes> &
|
|
38
|
+
WithElementRef<HTMLAnchorAttributes> & {
|
|
39
|
+
variant?: ButtonVariant;
|
|
40
|
+
size?: ButtonSize;
|
|
41
|
+
};
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<script lang="ts">
|
|
45
|
+
let {
|
|
46
|
+
class: className,
|
|
47
|
+
variant = "default",
|
|
48
|
+
size = "default",
|
|
49
|
+
ref = $bindable(null),
|
|
50
|
+
href = undefined,
|
|
51
|
+
type = "button",
|
|
52
|
+
disabled,
|
|
53
|
+
children,
|
|
54
|
+
...restProps
|
|
55
|
+
}: ButtonProps = $props();
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
{#if href}
|
|
59
|
+
<a
|
|
60
|
+
bind:this={ref}
|
|
61
|
+
data-slot="button"
|
|
62
|
+
class={cn(buttonVariants({ variant, size }), className)}
|
|
63
|
+
href={disabled ? undefined : href}
|
|
64
|
+
aria-disabled={disabled}
|
|
65
|
+
role={disabled ? "link" : undefined}
|
|
66
|
+
tabindex={disabled ? -1 : undefined}
|
|
67
|
+
{...restProps}
|
|
68
|
+
>
|
|
69
|
+
{@render children?.()}
|
|
70
|
+
</a>
|
|
71
|
+
{:else}
|
|
72
|
+
<button
|
|
73
|
+
bind:this={ref}
|
|
74
|
+
data-slot="button"
|
|
75
|
+
class={cn(buttonVariants({ variant, size }), className)}
|
|
76
|
+
{type}
|
|
77
|
+
{disabled}
|
|
78
|
+
{...restProps}
|
|
79
|
+
>
|
|
80
|
+
{@render children?.()}
|
|
81
|
+
</button>
|
|
82
|
+
{/if}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import Root, {
|
|
2
|
+
type ButtonProps,
|
|
3
|
+
type ButtonSize,
|
|
4
|
+
type ButtonVariant,
|
|
5
|
+
buttonVariants,
|
|
6
|
+
} from "./button.svelte";
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
Root,
|
|
10
|
+
type ButtonProps as Props,
|
|
11
|
+
//
|
|
12
|
+
Root as Button,
|
|
13
|
+
buttonVariants,
|
|
14
|
+
type ButtonProps,
|
|
15
|
+
type ButtonSize,
|
|
16
|
+
type ButtonVariant,
|
|
17
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
children,
|
|
9
|
+
...restProps
|
|
10
|
+
}: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div
|
|
14
|
+
bind:this={ref}
|
|
15
|
+
data-slot="card-action"
|
|
16
|
+
class={cn(
|
|
17
|
+
"cn-card-action col-start-2 row-span-2 row-start-1 self-start justify-self-end",
|
|
18
|
+
className
|
|
19
|
+
)}
|
|
20
|
+
{...restProps}
|
|
21
|
+
>
|
|
22
|
+
{@render children?.()}
|
|
23
|
+
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
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<HTMLDivElement>> = $props();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div
|
|
14
|
+
bind:this={ref}
|
|
15
|
+
data-slot="card-content"
|
|
16
|
+
class={cn("px-4 group-data-[size=sm]/card:px-3", className)}
|
|
17
|
+
{...restProps}
|
|
18
|
+
>
|
|
19
|
+
{@render children?.()}
|
|
20
|
+
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
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<HTMLParagraphElement>> = $props();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<p
|
|
14
|
+
bind:this={ref}
|
|
15
|
+
data-slot="card-description"
|
|
16
|
+
class={cn("text-muted-foreground text-sm", className)}
|
|
17
|
+
{...restProps}
|
|
18
|
+
>
|
|
19
|
+
{@render children?.()}
|
|
20
|
+
</p>
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
children,
|
|
9
|
+
...restProps
|
|
10
|
+
}: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div
|
|
14
|
+
bind:this={ref}
|
|
15
|
+
data-slot="card-footer"
|
|
16
|
+
class={cn("bg-muted/50 rounded-b-xl border-t p-4 group-data-[size=sm]/card:p-3 flex items-center", className)}
|
|
17
|
+
{...restProps}
|
|
18
|
+
>
|
|
19
|
+
{@render children?.()}
|
|
20
|
+
</div>
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
children,
|
|
9
|
+
...restProps
|
|
10
|
+
}: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div
|
|
14
|
+
bind:this={ref}
|
|
15
|
+
data-slot="card-header"
|
|
16
|
+
class={cn(
|
|
17
|
+
"gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]",
|
|
18
|
+
className
|
|
19
|
+
)}
|
|
20
|
+
{...restProps}
|
|
21
|
+
>
|
|
22
|
+
{@render children?.()}
|
|
23
|
+
</div>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
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<HTMLDivElement>> = $props();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div bind:this={ref} data-slot="card-title" class={cn("text-base leading-snug font-medium group-data-[size=sm]/card:text-sm", className)} {...restProps}>
|
|
14
|
+
{@render children?.()}
|
|
15
|
+
</div>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
import { cn, type WithElementRef } from "../../../utils.js";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
class: className,
|
|
8
|
+
children,
|
|
9
|
+
size = "default",
|
|
10
|
+
...restProps
|
|
11
|
+
}: WithElementRef<HTMLAttributes<HTMLDivElement>> & { size?: "default" | "sm" } = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<div
|
|
15
|
+
bind:this={ref}
|
|
16
|
+
data-slot="card"
|
|
17
|
+
data-size={size}
|
|
18
|
+
class={cn("ring-foreground/10 bg-card text-card-foreground gap-4 overflow-hidden rounded-xl py-4 text-sm ring-1 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl group/card flex flex-col", className)}
|
|
19
|
+
{...restProps}
|
|
20
|
+
>
|
|
21
|
+
{@render children?.()}
|
|
22
|
+
</div>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Root from "./card.svelte";
|
|
2
|
+
import Content from "./card-content.svelte";
|
|
3
|
+
import Description from "./card-description.svelte";
|
|
4
|
+
import Footer from "./card-footer.svelte";
|
|
5
|
+
import Header from "./card-header.svelte";
|
|
6
|
+
import Title from "./card-title.svelte";
|
|
7
|
+
import Action from "./card-action.svelte";
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
Root,
|
|
11
|
+
Content,
|
|
12
|
+
Description,
|
|
13
|
+
Footer,
|
|
14
|
+
Header,
|
|
15
|
+
Title,
|
|
16
|
+
Action,
|
|
17
|
+
//
|
|
18
|
+
Root as Card,
|
|
19
|
+
Content as CardContent,
|
|
20
|
+
Description as CardDescription,
|
|
21
|
+
Footer as CardFooter,
|
|
22
|
+
Header as CardHeader,
|
|
23
|
+
Title as CardTitle,
|
|
24
|
+
Action as CardAction,
|
|
25
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Checkbox as CheckboxPrimitive } from "bits-ui";
|
|
3
|
+
import { cn, type WithoutChildrenOrChild } from "../../../utils.js";
|
|
4
|
+
import CheckIcon from '@lucide/svelte/icons/check';
|
|
5
|
+
import MinusIcon from '@lucide/svelte/icons/minus';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
ref = $bindable(null),
|
|
9
|
+
checked = $bindable(false),
|
|
10
|
+
indeterminate = $bindable(false),
|
|
11
|
+
class: className,
|
|
12
|
+
...restProps
|
|
13
|
+
}: WithoutChildrenOrChild<CheckboxPrimitive.RootProps> = $props();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<CheckboxPrimitive.Root
|
|
17
|
+
bind:ref
|
|
18
|
+
data-slot="checkbox"
|
|
19
|
+
class={cn(
|
|
20
|
+
"border-input dark:bg-input/30 data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary data-checked:border-primary aria-invalid:aria-checked:border-primary aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 flex size-4 items-center justify-center rounded-[4px] border transition-colors group-has-disabled/field:opacity-50 focus-visible:ring-3 aria-invalid:ring-3 peer relative shrink-0 outline-none after:absolute after:-inset-x-3 after:-inset-y-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
21
|
+
className
|
|
22
|
+
)}
|
|
23
|
+
bind:checked
|
|
24
|
+
bind:indeterminate
|
|
25
|
+
{...restProps}
|
|
26
|
+
>
|
|
27
|
+
{#snippet children({ checked, indeterminate })}
|
|
28
|
+
<div
|
|
29
|
+
data-slot="checkbox-indicator"
|
|
30
|
+
class="[&>svg]:size-3.5 grid place-content-center text-current transition-none"
|
|
31
|
+
>
|
|
32
|
+
{#if checked}
|
|
33
|
+
<CheckIcon />
|
|
34
|
+
{:else if indeterminate}
|
|
35
|
+
<MinusIcon />
|
|
36
|
+
{/if}
|
|
37
|
+
</div>
|
|
38
|
+
{/snippet}
|
|
39
|
+
</CheckboxPrimitive.Root>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Dialog as DialogPrimitive } from "bits-ui";
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
ref = $bindable(null),
|
|
6
|
+
type = "button",
|
|
7
|
+
...restProps
|
|
8
|
+
}: DialogPrimitive.CloseProps = $props();
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<DialogPrimitive.Close bind:ref data-slot="dialog-close" {type} {...restProps} />
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Dialog as DialogPrimitive } from "bits-ui";
|
|
3
|
+
import DialogPortal from "./dialog-portal.svelte";
|
|
4
|
+
import type { Snippet } from "svelte";
|
|
5
|
+
import * as Dialog from "./index.js";
|
|
6
|
+
import { cn, type WithoutChildrenOrChild } from "../../../utils.js";
|
|
7
|
+
import type { ComponentProps } from "svelte";
|
|
8
|
+
import { Button } from "../../ui/button/index.js";
|
|
9
|
+
import XIcon from '@lucide/svelte/icons/x';
|
|
10
|
+
|
|
11
|
+
let {
|
|
12
|
+
ref = $bindable(null),
|
|
13
|
+
class: className,
|
|
14
|
+
portalProps,
|
|
15
|
+
children,
|
|
16
|
+
showCloseButton = true,
|
|
17
|
+
...restProps
|
|
18
|
+
}: WithoutChildrenOrChild<DialogPrimitive.ContentProps> & {
|
|
19
|
+
portalProps?: WithoutChildrenOrChild<ComponentProps<typeof DialogPortal>>;
|
|
20
|
+
children: Snippet;
|
|
21
|
+
showCloseButton?: boolean;
|
|
22
|
+
} = $props();
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<DialogPortal {...portalProps}>
|
|
26
|
+
<Dialog.Overlay />
|
|
27
|
+
<DialogPrimitive.Content
|
|
28
|
+
bind:ref
|
|
29
|
+
data-slot="dialog-content"
|
|
30
|
+
class={cn(
|
|
31
|
+
"bg-background data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 ring-foreground/10 grid max-w-[calc(100%-2rem)] gap-4 rounded-xl p-4 text-sm ring-1 duration-100 sm:max-w-sm fixed top-1/2 left-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 outline-none",
|
|
32
|
+
className
|
|
33
|
+
)}
|
|
34
|
+
{...restProps}
|
|
35
|
+
>
|
|
36
|
+
{@render children?.()}
|
|
37
|
+
{#if showCloseButton}
|
|
38
|
+
<DialogPrimitive.Close data-slot="dialog-close">
|
|
39
|
+
{#snippet child({ props })}
|
|
40
|
+
<Button variant="ghost" class="absolute top-2 right-2" size="icon-sm" {...props}>
|
|
41
|
+
<XIcon />
|
|
42
|
+
<span class="sr-only">Close</span>
|
|
43
|
+
</Button>
|
|
44
|
+
{/snippet}
|
|
45
|
+
</DialogPrimitive.Close>
|
|
46
|
+
{/if}
|
|
47
|
+
</DialogPrimitive.Content>
|
|
48
|
+
</DialogPortal>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Dialog as DialogPrimitive } from "bits-ui";
|
|
3
|
+
import { cn } from "../../../utils.js";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
class: className,
|
|
8
|
+
...restProps
|
|
9
|
+
}: DialogPrimitive.DescriptionProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<DialogPrimitive.Description
|
|
13
|
+
bind:ref
|
|
14
|
+
data-slot="dialog-description"
|
|
15
|
+
class={cn("text-muted-foreground *:[a]:hover:text-foreground text-sm *:[a]:underline *:[a]:underline-offset-3", className)}
|
|
16
|
+
{...restProps}
|
|
17
|
+
/>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn, type WithElementRef } from "../../../utils.js";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
import { Dialog as DialogPrimitive } from "bits-ui";
|
|
5
|
+
import { Button } from "../../ui/button/index.js";
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
ref = $bindable(null),
|
|
9
|
+
class: className,
|
|
10
|
+
children,
|
|
11
|
+
showCloseButton = false,
|
|
12
|
+
...restProps
|
|
13
|
+
}: WithElementRef<HTMLAttributes<HTMLDivElement>> & {
|
|
14
|
+
showCloseButton?: boolean;
|
|
15
|
+
} = $props();
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<div
|
|
19
|
+
bind:this={ref}
|
|
20
|
+
data-slot="dialog-footer"
|
|
21
|
+
class={cn("bg-muted/50 -mx-4 -mb-4 rounded-b-xl border-t p-4 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className)}
|
|
22
|
+
{...restProps}
|
|
23
|
+
>
|
|
24
|
+
{@render children?.()}
|
|
25
|
+
{#if showCloseButton}
|
|
26
|
+
<DialogPrimitive.Close>
|
|
27
|
+
{#snippet child({ props })}
|
|
28
|
+
<Button variant="outline" {...props}>Close</Button>
|
|
29
|
+
{/snippet}
|
|
30
|
+
</DialogPrimitive.Close>
|
|
31
|
+
{/if}
|
|
32
|
+
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
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<HTMLDivElement>> = $props();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div
|
|
14
|
+
bind:this={ref}
|
|
15
|
+
data-slot="dialog-header"
|
|
16
|
+
class={cn("gap-2 flex flex-col", className)}
|
|
17
|
+
{...restProps}
|
|
18
|
+
>
|
|
19
|
+
{@render children?.()}
|
|
20
|
+
</div>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Dialog as DialogPrimitive } from "bits-ui";
|
|
3
|
+
import { cn } from "../../../utils.js";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
class: className,
|
|
8
|
+
...restProps
|
|
9
|
+
}: DialogPrimitive.OverlayProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<DialogPrimitive.Overlay
|
|
13
|
+
bind:ref
|
|
14
|
+
data-slot="dialog-overlay"
|
|
15
|
+
class={cn("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 isolate z-50", className)}
|
|
16
|
+
{...restProps}
|
|
17
|
+
/>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Dialog as DialogPrimitive } from "bits-ui";
|
|
3
|
+
import { cn } from "../../../utils.js";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
class: className,
|
|
8
|
+
...restProps
|
|
9
|
+
}: DialogPrimitive.TitleProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<DialogPrimitive.Title
|
|
13
|
+
bind:ref
|
|
14
|
+
data-slot="dialog-title"
|
|
15
|
+
class={cn("text-base leading-none font-medium", className)}
|
|
16
|
+
{...restProps}
|
|
17
|
+
/>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Dialog as DialogPrimitive } from "bits-ui";
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
ref = $bindable(null),
|
|
6
|
+
type = "button",
|
|
7
|
+
...restProps
|
|
8
|
+
}: DialogPrimitive.TriggerProps = $props();
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<DialogPrimitive.Trigger bind:ref data-slot="dialog-trigger" {type} {...restProps} />
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import Root from "./dialog.svelte";
|
|
2
|
+
import Portal from "./dialog-portal.svelte";
|
|
3
|
+
import Title from "./dialog-title.svelte";
|
|
4
|
+
import Footer from "./dialog-footer.svelte";
|
|
5
|
+
import Header from "./dialog-header.svelte";
|
|
6
|
+
import Overlay from "./dialog-overlay.svelte";
|
|
7
|
+
import Content from "./dialog-content.svelte";
|
|
8
|
+
import Description from "./dialog-description.svelte";
|
|
9
|
+
import Trigger from "./dialog-trigger.svelte";
|
|
10
|
+
import Close from "./dialog-close.svelte";
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
Root,
|
|
14
|
+
Title,
|
|
15
|
+
Portal,
|
|
16
|
+
Footer,
|
|
17
|
+
Header,
|
|
18
|
+
Trigger,
|
|
19
|
+
Overlay,
|
|
20
|
+
Content,
|
|
21
|
+
Description,
|
|
22
|
+
Close,
|
|
23
|
+
//
|
|
24
|
+
Root as Dialog,
|
|
25
|
+
Title as DialogTitle,
|
|
26
|
+
Portal as DialogPortal,
|
|
27
|
+
Footer as DialogFooter,
|
|
28
|
+
Header as DialogHeader,
|
|
29
|
+
Trigger as DialogTrigger,
|
|
30
|
+
Overlay as DialogOverlay,
|
|
31
|
+
Content as DialogContent,
|
|
32
|
+
Description as DialogDescription,
|
|
33
|
+
Close as DialogClose,
|
|
34
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn, type WithElementRef } from "../../../utils.js";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
|
|
5
|
+
type Props = WithElementRef<HTMLAttributes<HTMLDivElement>> & {
|
|
6
|
+
align?: "start" | "center" | "end";
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
ref = $bindable(null),
|
|
11
|
+
align = "end",
|
|
12
|
+
class: className,
|
|
13
|
+
children,
|
|
14
|
+
...restProps
|
|
15
|
+
}: Props = $props();
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<div
|
|
19
|
+
bind:this={ref}
|
|
20
|
+
data-slot="dropdown-menu-content"
|
|
21
|
+
class={cn(
|
|
22
|
+
"bg-popover text-popover-foreground z-50 min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-lg",
|
|
23
|
+
"absolute mt-1 animate-in fade-in-0 zoom-in-95",
|
|
24
|
+
align === "end" ? "right-0" : align === "start" ? "left-0" : "left-1/2 -translate-x-1/2",
|
|
25
|
+
className
|
|
26
|
+
)}
|
|
27
|
+
{...restProps}
|
|
28
|
+
>
|
|
29
|
+
{@render children?.()}
|
|
30
|
+
</div>
|