@orbitkit/components 0.1.0 → 0.2.0-beta.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/README.md +25 -25
- package/dist/astro/accordion/Accordion.astro +34 -0
- package/dist/astro/accordion/AccordionItem.astro +16 -0
- package/dist/astro/accordion/AccordionTrigger.astro +33 -0
- package/dist/astro/accordion/AcordionContent.astro +26 -0
- package/dist/astro/accordion/accordion.ts +125 -0
- package/dist/astro/accordion/index.ts +6 -0
- package/dist/astro/alert/Alert.astro +30 -30
- package/dist/astro/alert/AlertDescription.astro +10 -10
- package/dist/astro/alert/AlertTitle.astro +15 -15
- package/dist/astro/alert/alertVariants.ts +51 -51
- package/dist/astro/alert/index.ts +6 -6
- package/dist/astro/avatar/Avatar.astro +16 -16
- package/dist/astro/avatar/AvatarFallback.astro +18 -18
- package/dist/astro/avatar/AvatarImage.astro +14 -14
- package/dist/astro/avatar/avatarVariants.ts +23 -23
- package/dist/astro/avatar/index.ts +6 -6
- package/dist/astro/badge/Badge.astro +22 -22
- package/dist/astro/badge/badgeVariants.ts +37 -37
- package/dist/astro/badge/index.ts +4 -4
- package/dist/astro/breadcrumb/Breadcrumb.astro +12 -12
- package/dist/astro/breadcrumb/BreadcrumbEllipsis.astro +20 -20
- package/dist/astro/breadcrumb/BreadcrumbItem.astro +15 -15
- package/dist/astro/breadcrumb/BreadcrumbLink.astro +18 -18
- package/dist/astro/breadcrumb/BreadcrumbList.astro +18 -18
- package/dist/astro/breadcrumb/BreadcrumbPage.astro +18 -18
- package/dist/astro/breadcrumb/BreadcrumbSeparator.astro +17 -17
- package/dist/astro/breadcrumb/index.ts +17 -17
- package/dist/astro/button/Button.astro +29 -29
- package/dist/astro/button/buttonVariants.ts +61 -61
- package/dist/astro/button/index.ts +4 -4
- package/dist/astro/card/Card.astro +18 -18
- package/dist/astro/card/CardContent.astro +12 -12
- package/dist/astro/card/CardDescription.astro +12 -12
- package/dist/astro/card/CardFooter.astro +15 -15
- package/dist/astro/card/CardHeader.astro +12 -12
- package/dist/astro/card/CardTitle.astro +18 -18
- package/dist/astro/card/index.ts +15 -15
- package/dist/astro/checkbox/Checkbox.astro +38 -38
- package/dist/astro/checkbox/index.ts +3 -3
- package/dist/astro/collapsible/Collapsible.astro +34 -0
- package/dist/astro/collapsible/CollapsibleContent.astro +20 -0
- package/dist/astro/collapsible/collapsible.ts +81 -0
- package/dist/astro/collapsible/index.ts +4 -0
- package/dist/astro/divider/Divider.astro +22 -22
- package/dist/astro/divider/index.ts +3 -3
- package/dist/astro/drawer/Drawer.astro +19 -0
- package/dist/astro/drawer/DrawerContent.astro +74 -0
- package/dist/astro/drawer/DrawerDescription.astro +12 -0
- package/dist/astro/drawer/DrawerFooter.astro +15 -0
- package/dist/astro/drawer/DrawerHeader.astro +12 -0
- package/dist/astro/drawer/DrawerTitle.astro +18 -0
- package/dist/astro/drawer/drawer.ts +104 -0
- package/dist/astro/drawer/drawerVariants.ts +83 -0
- package/dist/astro/drawer/index.ts +15 -0
- package/dist/astro/dropdown/DropdownMenu.astro +19 -0
- package/dist/astro/dropdown/DropdownMenuContent.astro +42 -0
- package/dist/astro/dropdown/DropdownMenuGroup.astro +3 -0
- package/dist/astro/dropdown/DropdownMenuItem.astro +27 -0
- package/dist/astro/dropdown/DropdownMenuLabel.astro +3 -0
- package/dist/astro/dropdown/DropdownMenuSeparator.astro +6 -0
- package/dist/astro/dropdown/dropdown.ts +157 -0
- package/dist/astro/dropdown/dropdownVariants.ts +134 -0
- package/dist/astro/dropdown/index.ts +15 -0
- package/dist/astro/input/Input.astro +18 -18
- package/dist/astro/input/index.ts +4 -4
- package/dist/astro/input/inputVariants.ts +30 -30
- package/dist/astro/kbd/Kbd.astro +18 -0
- package/dist/astro/kbd/index.ts +3 -0
- package/dist/astro/label/Label.astro +14 -14
- package/dist/astro/label/index.ts +3 -3
- package/dist/astro/list/List.astro +25 -25
- package/dist/astro/list/ListItem.astro +39 -39
- package/dist/astro/list/ListVariants.ts +65 -65
- package/dist/astro/list/index.ts +5 -5
- package/dist/astro/modal/Modal.astro +19 -0
- package/dist/astro/modal/ModalContent.astro +71 -0
- package/dist/astro/modal/ModalDescription.astro +12 -0
- package/dist/astro/modal/ModalFooter.astro +15 -0
- package/dist/astro/modal/ModalHeader.astro +12 -0
- package/dist/astro/modal/ModalTitle.astro +18 -0
- package/dist/astro/modal/index.ts +15 -0
- package/dist/astro/modal/modal.ts +101 -0
- package/dist/astro/pagination/Pagination.astro +12 -0
- package/dist/astro/pagination/PaginationContent.astro +15 -0
- package/dist/astro/pagination/PaginationEllipsis.astro +33 -0
- package/dist/astro/pagination/PaginationItem.astro +12 -0
- package/dist/astro/pagination/PaginationLink.astro +21 -0
- package/dist/astro/pagination/PaginationNext.astro +29 -0
- package/dist/astro/pagination/PaginationPrevious.astro +34 -0
- package/dist/astro/pagination/index.ts +13 -0
- package/dist/astro/pagination/paginationVariants.ts +26 -0
- package/dist/astro/popover/Popover.astro +17 -0
- package/dist/astro/popover/PopoverContent.astro +39 -0
- package/dist/astro/popover/index.ts +4 -0
- package/dist/astro/popover/popover.ts +113 -0
- package/dist/astro/popover/popoverVariants.ts +115 -0
- package/dist/astro/progress/Progress.astro +23 -23
- package/dist/astro/progress/index.ts +4 -4
- package/dist/astro/progress/progressContainer.astro +17 -17
- package/dist/astro/radio/Radio.astro +26 -26
- package/dist/astro/radio/index.ts +3 -3
- package/dist/astro/select/Option.astro +11 -11
- package/dist/astro/select/Select.astro +39 -39
- package/dist/astro/select/index.ts +5 -5
- package/dist/astro/select/selectVariants.ts +30 -30
- package/dist/astro/skeleton/Skeleton.astro +12 -12
- package/dist/astro/skeleton/SkeletonItem.astro +18 -18
- package/dist/astro/skeleton/index.ts +4 -4
- package/dist/astro/stat/Stat.astro +12 -0
- package/dist/astro/stat/StatDescription.astro +12 -0
- package/dist/astro/stat/StatTitle.astro +18 -0
- package/dist/astro/stat/StatValue.astro +12 -0
- package/dist/astro/stat/index.ts +6 -0
- package/dist/astro/switch/Switch.astro +19 -19
- package/dist/astro/switch/index.ts +3 -3
- package/dist/astro/tab/Tab.astro +33 -0
- package/dist/astro/tab/TabContent.astro +19 -0
- package/dist/astro/tab/TabList.astro +19 -0
- package/dist/astro/tab/TabTrigger.astro +24 -0
- package/dist/astro/tab/index.ts +6 -0
- package/dist/astro/tab/tab.ts +142 -0
- package/dist/astro/textarea/Textarea.astro +19 -19
- package/dist/astro/textarea/TextareaVariants.ts +30 -30
- package/dist/astro/textarea/index.ts +4 -4
- package/dist/astro/tooltip/Tooltip.astro +40 -0
- package/dist/astro/tooltip/TooltipContent.astro +39 -0
- package/dist/astro/tooltip/index.ts +6 -0
- package/dist/astro/tooltip/tooltip.ts +137 -0
- package/dist/astro/tooltip/tooltipVariants.ts +115 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -1
- package/package.json +54 -54
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { cn } from "@/utils/cn";
|
|
3
|
+
import type { HTMLAttributes } from "astro/types";
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLAttributes<"nav"> {}
|
|
6
|
+
|
|
7
|
+
const { class: className, ...attrs } = Astro.props;
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
<nav role="navigation" aria-label="pagination" class={cn(className)} {...attrs}>
|
|
11
|
+
<slot />
|
|
12
|
+
</nav>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { cn } from "@/utils/cn";
|
|
3
|
+
import type { HTMLAttributes } from "astro/types";
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLAttributes<"ul"> {}
|
|
6
|
+
|
|
7
|
+
const { class: className, ...attrs } = Astro.props;
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
<ul
|
|
11
|
+
class={cn("inline-flex justify-center items-center gap-2", className)}
|
|
12
|
+
{...attrs}
|
|
13
|
+
>
|
|
14
|
+
<slot />
|
|
15
|
+
</ul>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { cn } from "@/utils/cn";
|
|
3
|
+
import type { HTMLAttributes } from "astro/types";
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLAttributes<"nav"> {}
|
|
6
|
+
|
|
7
|
+
const { class: className, ...attrs } = Astro.props;
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
<span
|
|
11
|
+
aria-hidden="true"
|
|
12
|
+
class={cn("flex items-center justify-center", className)}
|
|
13
|
+
{...attrs}
|
|
14
|
+
>
|
|
15
|
+
<slot>
|
|
16
|
+
<svg
|
|
17
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
18
|
+
viewBox="0 0 24 24"
|
|
19
|
+
fill="none"
|
|
20
|
+
stroke="currentColor"
|
|
21
|
+
stroke-width="2"
|
|
22
|
+
stroke-linecap="round"
|
|
23
|
+
stroke-linejoin="round"
|
|
24
|
+
class="size-4"
|
|
25
|
+
>
|
|
26
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
|
27
|
+
<path d="M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"></path>
|
|
28
|
+
<path d="M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"></path>
|
|
29
|
+
<path d="M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"></path>
|
|
30
|
+
</svg>
|
|
31
|
+
</slot>
|
|
32
|
+
<span class="sr-only">More pages</span>
|
|
33
|
+
</span>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { cn } from "@/utils/cn";
|
|
3
|
+
import type { HTMLAttributes } from "astro/types";
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLAttributes<"nav"> {}
|
|
6
|
+
|
|
7
|
+
const { class: className, ...attrs } = Astro.props;
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
<li class={cn(className)} {...attrs}>
|
|
11
|
+
<slot />
|
|
12
|
+
</li>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { cn } from "@/utils/cn";
|
|
3
|
+
import type { HTMLAttributes } from "astro/types";
|
|
4
|
+
import type { VariantProps } from "class-variance-authority";
|
|
5
|
+
import { paginationLinkVariants } from "./paginationVariants";
|
|
6
|
+
|
|
7
|
+
interface Props
|
|
8
|
+
extends HTMLAttributes<"a">,
|
|
9
|
+
VariantProps<typeof paginationLinkVariants> {}
|
|
10
|
+
|
|
11
|
+
const { class: className, isActive, size, ...attrs } = Astro.props;
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
<a
|
|
15
|
+
data-active={isActive}
|
|
16
|
+
aria-current={isActive ? "page" : undefined}
|
|
17
|
+
class={cn(paginationLinkVariants({ isActive, size, className }))}
|
|
18
|
+
{...attrs}
|
|
19
|
+
>
|
|
20
|
+
<slot />
|
|
21
|
+
</a>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { cn } from "@/utils/cn";
|
|
3
|
+
import type { HTMLAttributes } from "astro/types";
|
|
4
|
+
import type { VariantProps } from "class-variance-authority";
|
|
5
|
+
import PaginationLink from "./PaginationLink.astro";
|
|
6
|
+
import type { paginationLinkVariants } from "./paginationVariants";
|
|
7
|
+
|
|
8
|
+
interface Props
|
|
9
|
+
extends HTMLAttributes<"a">,
|
|
10
|
+
Omit<VariantProps<typeof paginationLinkVariants>, "isActive"> {}
|
|
11
|
+
|
|
12
|
+
const { class: className, size } = Astro.props;
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
<PaginationLink size={size} aria-label="Go to next page" class={cn(className)}>
|
|
16
|
+
<slot />
|
|
17
|
+
<svg
|
|
18
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
19
|
+
viewBox="0 0 24 24"
|
|
20
|
+
fill="none"
|
|
21
|
+
stroke="currentColor"
|
|
22
|
+
stroke-width="2"
|
|
23
|
+
stroke-linecap="round"
|
|
24
|
+
stroke-linejoin="round"
|
|
25
|
+
>
|
|
26
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
|
27
|
+
<path d="M9 6l6 6l-6 6"></path></svg
|
|
28
|
+
>
|
|
29
|
+
</PaginationLink>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { cn } from "@/utils/cn";
|
|
3
|
+
import type { HTMLAttributes } from "astro/types";
|
|
4
|
+
import type { VariantProps } from "class-variance-authority";
|
|
5
|
+
import PaginationLink from "./PaginationLink.astro";
|
|
6
|
+
import type { paginationLinkVariants } from "./paginationVariants";
|
|
7
|
+
|
|
8
|
+
interface Props
|
|
9
|
+
extends HTMLAttributes<"a">,
|
|
10
|
+
Omit<VariantProps<typeof paginationLinkVariants>, "isActive"> {}
|
|
11
|
+
|
|
12
|
+
const { class: className, size, ...attrs } = Astro.props;
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
<PaginationLink
|
|
16
|
+
aria-label="Go to previous page"
|
|
17
|
+
size={size}
|
|
18
|
+
class={cn(className)}
|
|
19
|
+
{...attrs}
|
|
20
|
+
>
|
|
21
|
+
<svg
|
|
22
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
23
|
+
viewBox="0 0 24 24"
|
|
24
|
+
fill="none"
|
|
25
|
+
stroke="currentColor"
|
|
26
|
+
stroke-width="2"
|
|
27
|
+
stroke-linecap="round"
|
|
28
|
+
stroke-linejoin="round"
|
|
29
|
+
>
|
|
30
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
|
31
|
+
<path d="M15 6l-6 6l6 6"></path>
|
|
32
|
+
</svg>
|
|
33
|
+
<slot />
|
|
34
|
+
</PaginationLink>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Pagination from "./Pagination.astro";
|
|
2
|
+
import PaginationContent from "./PaginationContent.astro";
|
|
3
|
+
import PaginationEllipsis from "./PaginationEllipsis.astro";
|
|
4
|
+
import PaginationItem from "./PaginationItem.astro";
|
|
5
|
+
import PaginationLink from "./PaginationLink.astro";
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
Pagination,
|
|
9
|
+
PaginationContent,
|
|
10
|
+
PaginationEllipsis,
|
|
11
|
+
PaginationItem,
|
|
12
|
+
PaginationLink,
|
|
13
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
|
|
3
|
+
const baseClass =
|
|
4
|
+
"inline-flex justify-center gap-1.5 items-center rounded-lg font-medium cursor-pointer outline-none whitespace-nowrap [&_svg]:pointer-events-none [&_svg]:shrink-0";
|
|
5
|
+
|
|
6
|
+
const paginationLinkVariants = cva(baseClass, {
|
|
7
|
+
variants: {
|
|
8
|
+
isActive: {
|
|
9
|
+
true: "border border-border",
|
|
10
|
+
false: "hover:bg-foreground/5",
|
|
11
|
+
},
|
|
12
|
+
size: {
|
|
13
|
+
xs: "px-3 py-2 text-xs [&_svg]:size-3.5",
|
|
14
|
+
sm: "px-3 py-2 text-sm [&_svg]:size-4",
|
|
15
|
+
md: "px-5 py-2.5 text-sm [&_svg]:size-4",
|
|
16
|
+
lg: "px-5 py-3 text-base [&_svg]:size-[18px]",
|
|
17
|
+
xl: "px-6 py-3.5 text-base [&_svg]:size-[18px]",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
size: "sm",
|
|
22
|
+
isActive: false,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export { paginationLinkVariants };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<div class="relative" data-popover>
|
|
2
|
+
<slot />
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
import { Popover } from "./popover";
|
|
7
|
+
|
|
8
|
+
function init() {
|
|
9
|
+
const popovers = document.querySelectorAll<HTMLElement>("[data-popover]");
|
|
10
|
+
popovers.forEach((dropdown) => {
|
|
11
|
+
new Popover(dropdown);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
init();
|
|
16
|
+
document.addEventListener("astro:page-load", () => init());
|
|
17
|
+
</script>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { cn } from "@/utils/cn";
|
|
3
|
+
import type { HTMLAttributes } from "astro/types";
|
|
4
|
+
import type { VariantProps } from "class-variance-authority";
|
|
5
|
+
import { popoverArrowVariants, popoverVariants } from "./popoverVariants";
|
|
6
|
+
|
|
7
|
+
interface Props
|
|
8
|
+
extends HTMLAttributes<"div">,
|
|
9
|
+
VariantProps<typeof popoverVariants> {
|
|
10
|
+
sideOffset?: number;
|
|
11
|
+
arrow?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const {
|
|
15
|
+
class: className,
|
|
16
|
+
side,
|
|
17
|
+
alignment,
|
|
18
|
+
sideOffset = 2,
|
|
19
|
+
arrow = false,
|
|
20
|
+
...attrs
|
|
21
|
+
} = Astro.props;
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
<div
|
|
25
|
+
{...attrs}
|
|
26
|
+
role="dialog"
|
|
27
|
+
data-popover-content
|
|
28
|
+
aria-hidden="true"
|
|
29
|
+
data-state="closed"
|
|
30
|
+
data-side={sideOffset}
|
|
31
|
+
data-alignment={alignment}
|
|
32
|
+
class={cn(popoverVariants({ side, alignment, className }))}
|
|
33
|
+
style={{
|
|
34
|
+
"--tooltip-offset": `calc(var(--spacing) * ${sideOffset})`,
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
<slot />
|
|
38
|
+
{arrow && <span class={cn(popoverArrowVariants({ side, alignment }))} />}
|
|
39
|
+
</div>
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export class Popover {
|
|
2
|
+
// References to tooltip elements
|
|
3
|
+
private dropdownMenu: HTMLElement;
|
|
4
|
+
private trigger: HTMLElement | null;
|
|
5
|
+
private content: HTMLElement | null;
|
|
6
|
+
|
|
7
|
+
constructor(dropowndMenu: HTMLElement) {
|
|
8
|
+
this.dropdownMenu = dropowndMenu;
|
|
9
|
+
this.content = this.dropdownMenu.querySelector("[data-popover-content]");
|
|
10
|
+
this.trigger = this.dropdownMenu.querySelector("[data-trigger]");
|
|
11
|
+
|
|
12
|
+
if (!this.content || !this.trigger) {
|
|
13
|
+
console.error("Popover not initialized properly", {
|
|
14
|
+
content: this.content,
|
|
15
|
+
trigger: this.trigger,
|
|
16
|
+
});
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
this.init();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private init() {
|
|
24
|
+
this.setupAccessibility();
|
|
25
|
+
this.setupEventListeners();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private setupAccessibility() {
|
|
29
|
+
if (!this.trigger || !this.content) return;
|
|
30
|
+
|
|
31
|
+
const id =
|
|
32
|
+
this.content.id ||
|
|
33
|
+
`popover-id-${Math.random().toString(36).substring(2, 9)}`;
|
|
34
|
+
this.content.id = id;
|
|
35
|
+
this.trigger.setAttribute("aria-describedby", id);
|
|
36
|
+
this.setState("closed");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private setupEventListeners() {
|
|
40
|
+
if (!this.trigger || !this.content) return;
|
|
41
|
+
|
|
42
|
+
this.trigger.addEventListener("click", () => this.popoverToggle());
|
|
43
|
+
|
|
44
|
+
this.content.addEventListener("click", (e) => {
|
|
45
|
+
const target = e.target as HTMLElement;
|
|
46
|
+
const item = target.closest('[role="menuitem"]') as HTMLElement;
|
|
47
|
+
|
|
48
|
+
if (item && item.dataset.disabled !== "true") {
|
|
49
|
+
this.closePopover();
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
document.addEventListener("click", (e) => {
|
|
54
|
+
const target = e.target as HTMLElement;
|
|
55
|
+
if (
|
|
56
|
+
this.content &&
|
|
57
|
+
!this.content.contains(target) &&
|
|
58
|
+
target !== this.trigger
|
|
59
|
+
) {
|
|
60
|
+
this.closePopover();
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
this.trigger.addEventListener("keydown", (e) => {
|
|
65
|
+
const isOpen = this.content?.dataset.state === "open";
|
|
66
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
67
|
+
e.preventDefault();
|
|
68
|
+
this.popoverToggle();
|
|
69
|
+
} else if (e.key === "Escape" && isOpen) {
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
this.closePopover();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
document.addEventListener("keydown", (e) => this.handleKeydown(e));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private popoverToggle() {
|
|
79
|
+
if (this.content?.dataset.state === "open") {
|
|
80
|
+
this.closePopover();
|
|
81
|
+
} else {
|
|
82
|
+
this.openPopover();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private openPopover() {
|
|
87
|
+
this.content?.classList.remove("hidden");
|
|
88
|
+
|
|
89
|
+
window.setTimeout(() => {
|
|
90
|
+
this.setState("open");
|
|
91
|
+
}, 0);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private closePopover() {
|
|
95
|
+
this.trigger?.focus();
|
|
96
|
+
this.setState("closed");
|
|
97
|
+
window.setTimeout(() => {
|
|
98
|
+
this.content?.classList.add("hidden");
|
|
99
|
+
}, 100);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private setState(state: "open" | "closed") {
|
|
103
|
+
this.content?.setAttribute("aria-hidden", `${state === "closed"}`);
|
|
104
|
+
this.content?.setAttribute("data-state", state);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private handleKeydown = (event: KeyboardEvent) => {
|
|
108
|
+
if (event.key === "Escape" && this.content!.dataset.state === "open") {
|
|
109
|
+
this.closePopover();
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
|
|
3
|
+
const baseClass = [
|
|
4
|
+
"hidden absolute z-50 bg-surface border border-border p-4 rounded-md",
|
|
5
|
+
"transform duration-100 transition-all ease-in data-[state=closed]:opacity-0 data-[state=closed]:scale-95 data[state=open]:opacity-100 data[state=open]:scale-100",
|
|
6
|
+
];
|
|
7
|
+
|
|
8
|
+
const popoverVariants = cva(baseClass, {
|
|
9
|
+
variants: {
|
|
10
|
+
side: {
|
|
11
|
+
top: "bottom-full mb-(--tooltip-offset)",
|
|
12
|
+
bottom: "top-full mt-(--tooltip-offset)",
|
|
13
|
+
left: "right-full mr-(--tooltip-offset)",
|
|
14
|
+
right: "left-full ml-(--tooltip-offset)",
|
|
15
|
+
},
|
|
16
|
+
alignment: {
|
|
17
|
+
start: "",
|
|
18
|
+
center: "",
|
|
19
|
+
end: "",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
compoundVariants: [
|
|
23
|
+
{
|
|
24
|
+
side: ["top", "bottom"],
|
|
25
|
+
alignment: "start",
|
|
26
|
+
class: "left-0",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
side: ["top", "bottom"],
|
|
30
|
+
alignment: "end",
|
|
31
|
+
class: "left-full -translate-x-full",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
side: ["top", "bottom"],
|
|
35
|
+
alignment: "center",
|
|
36
|
+
class: "left-1/2 -translate-x-1/2",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
side: ["left", "right"],
|
|
40
|
+
alignment: "start",
|
|
41
|
+
class: "top-0 -translate-y-0",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
side: ["left", "right"],
|
|
45
|
+
alignment: "center",
|
|
46
|
+
class: "top-1/2 -translate-y-1/2",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
side: ["left", "right"],
|
|
50
|
+
alignment: "end",
|
|
51
|
+
class: "top-full -translate-y-full",
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
defaultVariants: {
|
|
55
|
+
side: "bottom",
|
|
56
|
+
alignment: "center",
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const arrowClass =
|
|
61
|
+
"absolute w-0 h-0 transition-all transform ease-in size-2 bg-surface transform rotate-45 border-border";
|
|
62
|
+
|
|
63
|
+
const popoverArrowVariants = cva(arrowClass, {
|
|
64
|
+
variants: {
|
|
65
|
+
side: {
|
|
66
|
+
top: "top-full -mt-1 border-b border-r",
|
|
67
|
+
bottom: "bottom-full -mb-1 border-t border-l",
|
|
68
|
+
left: "left-full -ml-1 border-t border-r",
|
|
69
|
+
right: "right-full -mr-1 border-b border-l",
|
|
70
|
+
},
|
|
71
|
+
alignment: {
|
|
72
|
+
start: "",
|
|
73
|
+
center: "",
|
|
74
|
+
end: "",
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
compoundVariants: [
|
|
78
|
+
{
|
|
79
|
+
side: ["top", "bottom"],
|
|
80
|
+
alignment: "start",
|
|
81
|
+
class: "left-0 ml-3 ",
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
side: ["top", "bottom"],
|
|
85
|
+
alignment: "end",
|
|
86
|
+
class: "right-0 mr-3",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
side: ["top", "bottom"],
|
|
90
|
+
alignment: "center",
|
|
91
|
+
class: "left-1/2 -translate-x-1/2",
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
side: ["left", "right"],
|
|
95
|
+
alignment: "start",
|
|
96
|
+
class: "top-0 mt-3",
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
side: ["left", "right"],
|
|
100
|
+
alignment: "center",
|
|
101
|
+
class: "top-1/2 -translate-y-1/2",
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
side: ["left", "right"],
|
|
105
|
+
alignment: "end",
|
|
106
|
+
class: "bottom-0 mb-3",
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
defaultVariants: {
|
|
110
|
+
side: "bottom",
|
|
111
|
+
alignment: "center",
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
export { popoverArrowVariants, popoverVariants };
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
---
|
|
2
|
-
import { cn } from "@/utils/cn";
|
|
3
|
-
import { type HTMLAttributes } from "astro/types";
|
|
4
|
-
|
|
5
|
-
interface Props extends HTMLAttributes<"div"> {
|
|
6
|
-
value?: number;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const { class: className, value = 50 } = Astro.props;
|
|
10
|
-
|
|
11
|
-
if (value < 0 || value > 100) {
|
|
12
|
-
throw new Error("Value must be between 0 and 100");
|
|
13
|
-
}
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
<div
|
|
17
|
-
class={cn(
|
|
18
|
-
"flex items-center justify-center h-full overflow-hidden text-primary-foreground break-all bg-primary rounded-full",
|
|
19
|
-
className,
|
|
20
|
-
)}
|
|
21
|
-
style={{ width: `${value}%` }}
|
|
22
|
-
>
|
|
23
|
-
</div>
|
|
1
|
+
---
|
|
2
|
+
import { cn } from "@/utils/cn";
|
|
3
|
+
import { type HTMLAttributes } from "astro/types";
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLAttributes<"div"> {
|
|
6
|
+
value?: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const { class: className, value = 50 } = Astro.props;
|
|
10
|
+
|
|
11
|
+
if (value < 0 || value > 100) {
|
|
12
|
+
throw new Error("Value must be between 0 and 100");
|
|
13
|
+
}
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
<div
|
|
17
|
+
class={cn(
|
|
18
|
+
"flex items-center justify-center h-full overflow-hidden text-primary-foreground break-all bg-primary rounded-full",
|
|
19
|
+
className,
|
|
20
|
+
)}
|
|
21
|
+
style={{ width: `${value}%` }}
|
|
22
|
+
>
|
|
23
|
+
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Progress from "./Progress.astro";
|
|
2
|
-
import ProgressContainer from "./progressContainer.astro";
|
|
3
|
-
|
|
4
|
-
export { Progress, ProgressContainer };
|
|
1
|
+
import Progress from "./Progress.astro";
|
|
2
|
+
import ProgressContainer from "./progressContainer.astro";
|
|
3
|
+
|
|
4
|
+
export { Progress, ProgressContainer };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
---
|
|
2
|
-
import { cn } from "@/utils/cn";
|
|
3
|
-
import { type HTMLAttributes } from "astro/types";
|
|
4
|
-
|
|
5
|
-
interface Props extends HTMLAttributes<"div"> {}
|
|
6
|
-
|
|
7
|
-
const { class: className } = Astro.props;
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
<div
|
|
11
|
-
class={cn(
|
|
12
|
-
"flex-start flex h-2.5 w-full overflow-hidden rounded-full bg-muted font-sans text-xs font-medium",
|
|
13
|
-
className,
|
|
14
|
-
)}
|
|
15
|
-
>
|
|
16
|
-
<slot />
|
|
17
|
-
</div>
|
|
1
|
+
---
|
|
2
|
+
import { cn } from "@/utils/cn";
|
|
3
|
+
import { type HTMLAttributes } from "astro/types";
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLAttributes<"div"> {}
|
|
6
|
+
|
|
7
|
+
const { class: className } = Astro.props;
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
<div
|
|
11
|
+
class={cn(
|
|
12
|
+
"flex-start flex h-2.5 w-full overflow-hidden rounded-full bg-muted font-sans text-xs font-medium",
|
|
13
|
+
className,
|
|
14
|
+
)}
|
|
15
|
+
>
|
|
16
|
+
<slot />
|
|
17
|
+
</div>
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
---
|
|
2
|
-
import { cn } from "@/utils/cn";
|
|
3
|
-
import { type HTMLAttributes } from "astro/types";
|
|
4
|
-
|
|
5
|
-
interface Props extends Omit<HTMLAttributes<"input">, "type"> {}
|
|
6
|
-
|
|
7
|
-
const { class: className, id, ...attrs } = Astro.props;
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
<div class="inline-flex items-center">
|
|
11
|
-
<label class="relative flex cursor-pointer items-center" for={id}>
|
|
12
|
-
<input
|
|
13
|
-
{...attrs}
|
|
14
|
-
id={id}
|
|
15
|
-
type="radio"
|
|
16
|
-
class="border-input-border checked:border-primary peer h-5 w-5 cursor-pointer appearance-none rounded-full border transition-all"
|
|
17
|
-
/>
|
|
18
|
-
<span
|
|
19
|
-
class={cn(
|
|
20
|
-
"absolute bg-primary w-3 h-3 rounded-full opacity-0 peer-checked:opacity-100 transition-opacity duration-200 top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
|
21
|
-
className,
|
|
22
|
-
)}
|
|
23
|
-
>
|
|
24
|
-
</span>
|
|
25
|
-
</label>
|
|
26
|
-
</div>
|
|
1
|
+
---
|
|
2
|
+
import { cn } from "@/utils/cn";
|
|
3
|
+
import { type HTMLAttributes } from "astro/types";
|
|
4
|
+
|
|
5
|
+
interface Props extends Omit<HTMLAttributes<"input">, "type"> {}
|
|
6
|
+
|
|
7
|
+
const { class: className, id, ...attrs } = Astro.props;
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
<div class="inline-flex items-center">
|
|
11
|
+
<label class="relative flex cursor-pointer items-center" for={id}>
|
|
12
|
+
<input
|
|
13
|
+
{...attrs}
|
|
14
|
+
id={id}
|
|
15
|
+
type="radio"
|
|
16
|
+
class="border-input-border checked:border-primary peer h-5 w-5 cursor-pointer appearance-none rounded-full border transition-all"
|
|
17
|
+
/>
|
|
18
|
+
<span
|
|
19
|
+
class={cn(
|
|
20
|
+
"absolute bg-primary w-3 h-3 rounded-full opacity-0 peer-checked:opacity-100 transition-opacity duration-200 top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
|
21
|
+
className,
|
|
22
|
+
)}
|
|
23
|
+
>
|
|
24
|
+
</span>
|
|
25
|
+
</label>
|
|
26
|
+
</div>
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import Radio from "./Radio.astro";
|
|
2
|
-
|
|
3
|
-
export { Radio };
|
|
1
|
+
import Radio from "./Radio.astro";
|
|
2
|
+
|
|
3
|
+
export { Radio };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
---
|
|
2
|
-
import { type HTMLAttributes } from "astro/types";
|
|
3
|
-
|
|
4
|
-
interface Props extends HTMLAttributes<"option"> {}
|
|
5
|
-
|
|
6
|
-
const { ...attrs } = Astro.props;
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
<option {...attrs}>
|
|
10
|
-
<slot />
|
|
11
|
-
</option>
|
|
1
|
+
---
|
|
2
|
+
import { type HTMLAttributes } from "astro/types";
|
|
3
|
+
|
|
4
|
+
interface Props extends HTMLAttributes<"option"> {}
|
|
5
|
+
|
|
6
|
+
const { ...attrs } = Astro.props;
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
<option {...attrs}>
|
|
10
|
+
<slot />
|
|
11
|
+
</option>
|