@orbitkit/components 0.2.0 → 0.4.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/astro/accordion/Accordion.astro +34 -34
- package/dist/astro/accordion/AccordionItem.astro +19 -19
- package/dist/astro/accordion/AccordionTrigger.astro +33 -33
- package/dist/astro/accordion/AcordionContent.astro +23 -23
- package/dist/astro/accordion/accordion.ts +151 -151
- package/dist/astro/accordion/index.ts +6 -6
- package/dist/astro/ambient-image/AmbientFigcaption.astro +15 -0
- package/dist/astro/ambient-image/AmbientImage.astro +70 -0
- package/dist/astro/ambient-image/index.ts +4 -0
- package/dist/astro/button-group/ButtonGroup.astro +21 -0
- package/dist/astro/button-group/buttonGroupVariants.ts +34 -0
- package/dist/astro/button-group/index.ts +3 -0
- package/dist/astro/collapsible/Collapsible.astro +34 -34
- package/dist/astro/collapsible/CollapsibleContent.astro +20 -20
- package/dist/astro/collapsible/collapsible.ts +81 -81
- package/dist/astro/collapsible/index.ts +4 -4
- package/dist/astro/diff/Diff.astro +55 -0
- package/dist/astro/diff/DiffItem.astro +21 -0
- package/dist/astro/diff/index.ts +4 -0
- package/dist/astro/drawer/DrawerContent.astro +74 -74
- package/dist/astro/drawer/drawer.ts +104 -104
- package/dist/astro/drawer/index.ts +17 -17
- package/dist/astro/dropdown/DropdownMenu.astro +19 -19
- package/dist/astro/dropdown/DropdownMenuContent.astro +42 -42
- package/dist/astro/dropdown/DropdownMenuGroup.astro +3 -3
- package/dist/astro/dropdown/DropdownMenuItem.astro +27 -27
- package/dist/astro/dropdown/DropdownMenuLabel.astro +3 -3
- package/dist/astro/dropdown/DropdownMenuSeparator.astro +6 -6
- package/dist/astro/dropdown/dropdown.ts +157 -157
- package/dist/astro/dropdown/dropdownVariants.ts +134 -134
- package/dist/astro/dropdown/index.ts +23 -23
- package/dist/astro/loader/Loader.astro +16 -0
- package/dist/astro/loader/index.ts +6 -0
- package/dist/astro/loader/loaders/12-dots-scale-rotate.svg +1 -0
- package/dist/astro/loader/loaders/180-ring-with-bg.svg +1 -0
- package/dist/astro/loader/loaders/180-ring.svg +1 -0
- package/dist/astro/loader/loaders/270-ring-with-bg.svg +1 -0
- package/dist/astro/loader/loaders/270-ring.svg +1 -0
- package/dist/astro/loader/loaders/3-dots-bounce.svg +1 -0
- package/dist/astro/loader/loaders/3-dots-fade.svg +1 -0
- package/dist/astro/loader/loaders/3-dots-move.svg +1 -0
- package/dist/astro/loader/loaders/3-dots-rotate.svg +1 -0
- package/dist/astro/loader/loaders/3-dots-scale-middle.svg +1 -0
- package/dist/astro/loader/loaders/3-dots-scale.svg +1 -0
- package/dist/astro/loader/loaders/6-dots-rotate.svg +1 -0
- package/dist/astro/loader/loaders/6-dots-scale-middle.svg +1 -0
- package/dist/astro/loader/loaders/6-dots-scale.svg +1 -0
- package/dist/astro/loader/loaders/8-dots-rotate.svg +1 -0
- package/dist/astro/loader/loaders/90-ring-with-bg.svg +1 -0
- package/dist/astro/loader/loaders/90-ring.svg +1 -0
- package/dist/astro/loader/loaders/bars-fade.svg +1 -0
- package/dist/astro/loader/loaders/bars-rotate-fade.svg +1 -0
- package/dist/astro/loader/loaders/bars-scale-fade.svg +1 -0
- package/dist/astro/loader/loaders/bars-scale-middle.svg +1 -0
- package/dist/astro/loader/loaders/bars-scale.svg +1 -0
- package/dist/astro/loader/loaders/blocks-scale.svg +1 -0
- package/dist/astro/loader/loaders/blocks-shuffle-2.svg +1 -0
- package/dist/astro/loader/loaders/blocks-shuffle-3.svg +1 -0
- package/dist/astro/loader/loaders/blocks-wave.svg +1 -0
- package/dist/astro/loader/loaders/bouncing-ball.svg +1 -0
- package/dist/astro/loader/loaders/clock.svg +1 -0
- package/dist/astro/loader/loaders/dot-revolve.svg +1 -0
- package/dist/astro/loader/loaders/eclipse-half.svg +1 -0
- package/dist/astro/loader/loaders/eclipse.svg +1 -0
- package/dist/astro/loader/loaders/gooey-balls-1.svg +1 -0
- package/dist/astro/loader/loaders/gooey-balls-2.svg +1 -0
- package/dist/astro/loader/loaders/index.ts +99 -0
- package/dist/astro/loader/loaders/pulse-2.svg +1 -0
- package/dist/astro/loader/loaders/pulse-3.svg +1 -0
- package/dist/astro/loader/loaders/pulse-multiple.svg +1 -0
- package/dist/astro/loader/loaders/pulse-ring.svg +1 -0
- package/dist/astro/loader/loaders/pulse-rings-2.svg +1 -0
- package/dist/astro/loader/loaders/pulse-rings-3.svg +1 -0
- package/dist/astro/loader/loaders/pulse-rings-multiple.svg +1 -0
- package/dist/astro/loader/loaders/pulse.svg +1 -0
- package/dist/astro/loader/loaders/ring-resize.svg +1 -0
- package/dist/astro/loader/loaders/tadpole.svg +1 -0
- package/dist/astro/loader/loaders/wifi-fade.svg +1 -0
- package/dist/astro/loader/loaders/wifi.svg +1 -0
- package/dist/astro/loader/loaders/wind-toy.svg +1 -0
- package/dist/astro/marquee/Marquee.astro +53 -0
- package/dist/astro/marquee/index.ts +3 -0
- package/dist/astro/modal/Modal.astro +19 -19
- package/dist/astro/modal/ModalContent.astro +71 -71
- package/dist/astro/modal/ModalDescription.astro +12 -12
- package/dist/astro/modal/ModalFooter.astro +15 -15
- package/dist/astro/modal/ModalHeader.astro +12 -12
- package/dist/astro/modal/ModalTitle.astro +18 -18
- package/dist/astro/modal/index.ts +15 -15
- package/dist/astro/modal/modal.ts +101 -101
- package/dist/astro/pagination/index.ts +15 -15
- package/dist/astro/popover/Popover.astro +17 -17
- package/dist/astro/popover/PopoverContent.astro +39 -39
- package/dist/astro/popover/index.ts +5 -5
- package/dist/astro/popover/popover.ts +113 -113
- package/dist/astro/popover/popoverVariants.ts +115 -115
- package/dist/astro/scroll-progress/ScrollProgress.astro +41 -0
- package/dist/astro/scroll-progress/ScrollProgressBar.astro +19 -0
- package/dist/astro/scroll-progress/index.ts +4 -0
- package/dist/astro/stat/Stat.astro +12 -12
- package/dist/astro/stat/StatDescription.astro +12 -12
- package/dist/astro/stat/StatTitle.astro +18 -18
- package/dist/astro/stat/StatValue.astro +12 -12
- package/dist/astro/stat/index.ts +6 -6
- package/dist/astro/tab/TabList.astro +19 -19
- package/dist/astro/toast/Toast.astro +36 -0
- package/dist/astro/toast/ToastDescription.astro +10 -0
- package/dist/astro/toast/ToastTitle.astro +18 -0
- package/dist/astro/toast/Toaster.astro +78 -0
- package/dist/astro/toast/assets.ts +6 -0
- package/dist/astro/toast/index.ts +30 -0
- package/dist/astro/toast/toast.ts +277 -0
- package/dist/astro/tooltip/Tooltip.astro +40 -40
- package/dist/astro/tooltip/TooltipContent.astro +39 -39
- package/dist/astro/tooltip/index.ts +5 -5
- package/dist/astro/tooltip/tooltip.ts +137 -137
- package/dist/astro/tooltip/tooltipVariants.ts +115 -115
- package/dist/index.js +30 -2
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
---
|
|
2
|
-
import { cn } from "@/utils/cn";
|
|
3
|
-
import type { HTMLAttributes } from "astro/types";
|
|
4
|
-
|
|
5
|
-
interface Props extends HTMLAttributes<"div"> {
|
|
6
|
-
showCloseButton?: boolean;
|
|
7
|
-
backdrop?: boolean;
|
|
8
|
-
allowOutsideClick?: boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const {
|
|
12
|
-
class: className,
|
|
13
|
-
showCloseButton = true,
|
|
14
|
-
backdrop = true,
|
|
15
|
-
allowOutsideClick = true,
|
|
16
|
-
...attrs
|
|
17
|
-
} = Astro.props;
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
{
|
|
21
|
-
backdrop && (
|
|
22
|
-
<div
|
|
23
|
-
class="bg-background fixed inset-0 left-0 top-0 z-50 hidden h-dvh w-full transition-opacity duration-100 data-[state=closed]:opacity-0 data-[state=open]:opacity-80"
|
|
24
|
-
aria-hidden="true"
|
|
25
|
-
data-state="closed"
|
|
26
|
-
data-backdrop
|
|
27
|
-
/>
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
<div
|
|
32
|
-
data-modal
|
|
33
|
-
role="dialog"
|
|
34
|
-
aria-hidden="true"
|
|
35
|
-
data-state="closed"
|
|
36
|
-
data-show-close-button={showCloseButton}
|
|
37
|
-
data-allow-outside-click={allowOutsideClick}
|
|
38
|
-
class={cn(
|
|
39
|
-
"hidden fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-50 bg-surface text-foreground border-border border rounded-lg shadow-sm p-6 w-full max-w-[calc(100%-2rem)] sm:max-w-md transform transition-all ease-in data-[state=closed]:opacity-0 data-[state=closed]:scale-95 data-[state=open]:opacity-100 data-[state=open]:scale-100",
|
|
40
|
-
className,
|
|
41
|
-
)}
|
|
42
|
-
{...attrs}
|
|
43
|
-
>
|
|
44
|
-
{
|
|
45
|
-
showCloseButton && (
|
|
46
|
-
<button
|
|
47
|
-
class="text-foreground hover:bg-muted absolute right-3 top-3 cursor-pointer rounded-lg p-1 transition-colors duration-150"
|
|
48
|
-
aria-label="close modal"
|
|
49
|
-
data-close-modal
|
|
50
|
-
>
|
|
51
|
-
<svg
|
|
52
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
53
|
-
viewBox="0 0 24 24"
|
|
54
|
-
fill="none"
|
|
55
|
-
stroke="currentColor"
|
|
56
|
-
stroke-width="2"
|
|
57
|
-
stroke-linecap="round"
|
|
58
|
-
stroke-linejoin="round"
|
|
59
|
-
class="size-4"
|
|
60
|
-
>
|
|
61
|
-
<>
|
|
62
|
-
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
63
|
-
<path d="M18 6l-12 12" />
|
|
64
|
-
<path d="M6 6l12 12" />
|
|
65
|
-
</>
|
|
66
|
-
</svg>
|
|
67
|
-
</button>
|
|
68
|
-
)
|
|
69
|
-
}
|
|
70
|
-
<slot />
|
|
71
|
-
</div>
|
|
1
|
+
---
|
|
2
|
+
import { cn } from "@/utils/cn";
|
|
3
|
+
import type { HTMLAttributes } from "astro/types";
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLAttributes<"div"> {
|
|
6
|
+
showCloseButton?: boolean;
|
|
7
|
+
backdrop?: boolean;
|
|
8
|
+
allowOutsideClick?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const {
|
|
12
|
+
class: className,
|
|
13
|
+
showCloseButton = true,
|
|
14
|
+
backdrop = true,
|
|
15
|
+
allowOutsideClick = true,
|
|
16
|
+
...attrs
|
|
17
|
+
} = Astro.props;
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
{
|
|
21
|
+
backdrop && (
|
|
22
|
+
<div
|
|
23
|
+
class="bg-background fixed inset-0 left-0 top-0 z-50 hidden h-dvh w-full transition-opacity duration-100 data-[state=closed]:opacity-0 data-[state=open]:opacity-80"
|
|
24
|
+
aria-hidden="true"
|
|
25
|
+
data-state="closed"
|
|
26
|
+
data-backdrop
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
<div
|
|
32
|
+
data-modal
|
|
33
|
+
role="dialog"
|
|
34
|
+
aria-hidden="true"
|
|
35
|
+
data-state="closed"
|
|
36
|
+
data-show-close-button={showCloseButton}
|
|
37
|
+
data-allow-outside-click={allowOutsideClick}
|
|
38
|
+
class={cn(
|
|
39
|
+
"hidden fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-50 bg-surface text-foreground border-border border rounded-lg shadow-sm p-6 w-full max-w-[calc(100%-2rem)] sm:max-w-md transform transition-all ease-in data-[state=closed]:opacity-0 data-[state=closed]:scale-95 data-[state=open]:opacity-100 data-[state=open]:scale-100",
|
|
40
|
+
className,
|
|
41
|
+
)}
|
|
42
|
+
{...attrs}
|
|
43
|
+
>
|
|
44
|
+
{
|
|
45
|
+
showCloseButton && (
|
|
46
|
+
<button
|
|
47
|
+
class="text-foreground hover:bg-muted absolute right-3 top-3 cursor-pointer rounded-lg p-1 transition-colors duration-150"
|
|
48
|
+
aria-label="close modal"
|
|
49
|
+
data-close-modal
|
|
50
|
+
>
|
|
51
|
+
<svg
|
|
52
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
53
|
+
viewBox="0 0 24 24"
|
|
54
|
+
fill="none"
|
|
55
|
+
stroke="currentColor"
|
|
56
|
+
stroke-width="2"
|
|
57
|
+
stroke-linecap="round"
|
|
58
|
+
stroke-linejoin="round"
|
|
59
|
+
class="size-4"
|
|
60
|
+
>
|
|
61
|
+
<>
|
|
62
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
63
|
+
<path d="M18 6l-12 12" />
|
|
64
|
+
<path d="M6 6l12 12" />
|
|
65
|
+
</>
|
|
66
|
+
</svg>
|
|
67
|
+
</button>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
<slot />
|
|
71
|
+
</div>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
---
|
|
2
|
-
import { cn } from "@/utils/cn";
|
|
3
|
-
import { type HTMLAttributes } from "astro/types";
|
|
4
|
-
|
|
5
|
-
interface Props extends HTMLAttributes<"p"> {}
|
|
6
|
-
|
|
7
|
-
const { class: className, ...attrs } = Astro.props;
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
<p {...attrs} class={cn("font-normal text-muted-foreground", className)}>
|
|
11
|
-
<slot />
|
|
12
|
-
</p>
|
|
1
|
+
---
|
|
2
|
+
import { cn } from "@/utils/cn";
|
|
3
|
+
import { type HTMLAttributes } from "astro/types";
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLAttributes<"p"> {}
|
|
6
|
+
|
|
7
|
+
const { class: className, ...attrs } = Astro.props;
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
<p {...attrs} class={cn("font-normal text-muted-foreground", className)}>
|
|
11
|
+
<slot />
|
|
12
|
+
</p>
|
|
@@ -1,15 +1,15 @@
|
|
|
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, ...attrs } = Astro.props;
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
<div
|
|
11
|
-
{...attrs}
|
|
12
|
-
class={cn("pt-4 flex items-center justify-end gap-2", className)}
|
|
13
|
-
>
|
|
14
|
-
<slot />
|
|
15
|
-
</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, ...attrs } = Astro.props;
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
<div
|
|
11
|
+
{...attrs}
|
|
12
|
+
class={cn("pt-4 flex items-center justify-end gap-2", className)}
|
|
13
|
+
>
|
|
14
|
+
<slot />
|
|
15
|
+
</div>
|
|
@@ -1,12 +1,12 @@
|
|
|
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, ...attrs } = Astro.props;
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
<div {...attrs} class={cn("flex flex-col gap-1 pb-4", className)}>
|
|
11
|
-
<slot />
|
|
12
|
-
</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, ...attrs } = Astro.props;
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
<div {...attrs} class={cn("flex flex-col gap-1 pb-4", className)}>
|
|
11
|
+
<slot />
|
|
12
|
+
</div>
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
---
|
|
2
|
-
import { cn } from "@/utils/cn";
|
|
3
|
-
import { type HTMLAttributes } from "astro/types";
|
|
4
|
-
|
|
5
|
-
interface Props extends HTMLAttributes<"h2"> {}
|
|
6
|
-
|
|
7
|
-
const { class: className, ...attrs } = Astro.props;
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
<h2
|
|
11
|
-
{...attrs}
|
|
12
|
-
class={cn(
|
|
13
|
-
"flex items-center justify-start gap-2 text-2xl font-semibold tracking-tight",
|
|
14
|
-
className,
|
|
15
|
-
)}
|
|
16
|
-
>
|
|
17
|
-
<slot />
|
|
18
|
-
</h2>
|
|
1
|
+
---
|
|
2
|
+
import { cn } from "@/utils/cn";
|
|
3
|
+
import { type HTMLAttributes } from "astro/types";
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLAttributes<"h2"> {}
|
|
6
|
+
|
|
7
|
+
const { class: className, ...attrs } = Astro.props;
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
<h2
|
|
11
|
+
{...attrs}
|
|
12
|
+
class={cn(
|
|
13
|
+
"flex items-center justify-start gap-2 text-2xl font-semibold tracking-tight",
|
|
14
|
+
className,
|
|
15
|
+
)}
|
|
16
|
+
>
|
|
17
|
+
<slot />
|
|
18
|
+
</h2>
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import Modal from "./Modal.astro";
|
|
2
|
-
import ModalContent from "./ModalContent.astro";
|
|
3
|
-
import ModalDescription from "./ModalDescription.astro";
|
|
4
|
-
import ModalFooter from "./ModalFooter.astro";
|
|
5
|
-
import ModalHeader from "./ModalHeader.astro";
|
|
6
|
-
import ModalTitle from "./ModalTitle.astro";
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
Modal,
|
|
10
|
-
ModalContent,
|
|
11
|
-
ModalDescription,
|
|
12
|
-
ModalFooter,
|
|
13
|
-
ModalHeader,
|
|
14
|
-
ModalTitle,
|
|
15
|
-
};
|
|
1
|
+
import Modal from "./Modal.astro";
|
|
2
|
+
import ModalContent from "./ModalContent.astro";
|
|
3
|
+
import ModalDescription from "./ModalDescription.astro";
|
|
4
|
+
import ModalFooter from "./ModalFooter.astro";
|
|
5
|
+
import ModalHeader from "./ModalHeader.astro";
|
|
6
|
+
import ModalTitle from "./ModalTitle.astro";
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
Modal,
|
|
10
|
+
ModalContent,
|
|
11
|
+
ModalDescription,
|
|
12
|
+
ModalFooter,
|
|
13
|
+
ModalHeader,
|
|
14
|
+
ModalTitle,
|
|
15
|
+
};
|
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
export class Modal {
|
|
2
|
-
private wrapper: HTMLElement;
|
|
3
|
-
private modal: HTMLElement | null;
|
|
4
|
-
private trigger: HTMLElement | null;
|
|
5
|
-
private backdrop: HTMLElement | null;
|
|
6
|
-
private closeButtons: NodeListOf<HTMLElement> | null;
|
|
7
|
-
|
|
8
|
-
constructor(wrapper: HTMLElement) {
|
|
9
|
-
this.wrapper = wrapper;
|
|
10
|
-
this.modal = this.wrapper.querySelector("[data-modal]");
|
|
11
|
-
this.backdrop = this.wrapper.querySelector("[data-backdrop]");
|
|
12
|
-
this.trigger = this.wrapper.querySelector("[data-trigger]");
|
|
13
|
-
this.closeButtons = this.wrapper.querySelectorAll("[data-close]");
|
|
14
|
-
|
|
15
|
-
if (!this.modal || !this.trigger) {
|
|
16
|
-
console.error("Modal not initialized properly", {
|
|
17
|
-
modal: this.modal,
|
|
18
|
-
});
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
this.init();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
private init() {
|
|
26
|
-
this.setupAccessibility();
|
|
27
|
-
this.setupEventListeners();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
private setupAccessibility() {
|
|
31
|
-
const title = this.modal?.querySelector<HTMLElement>(
|
|
32
|
-
"h1, h2, h3, h4, h5, h6",
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
if (title) {
|
|
36
|
-
const id =
|
|
37
|
-
title.id || `modal-id-${Math.random().toString(36).substring(2, 9)}`;
|
|
38
|
-
title.id = id;
|
|
39
|
-
this.modal?.setAttribute("aria-describedby", id);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
this.setState("closed");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
private setupEventListeners() {
|
|
46
|
-
this.trigger!.addEventListener("click", () => this.open());
|
|
47
|
-
|
|
48
|
-
if (this.modal?.dataset.allowOutsideClick === "true") {
|
|
49
|
-
this.backdrop?.addEventListener("click", () => this.closeModal());
|
|
50
|
-
document.addEventListener("click", (e) => {
|
|
51
|
-
const target = e.target as HTMLElement;
|
|
52
|
-
if (
|
|
53
|
-
this.modal &&
|
|
54
|
-
!this.modal.contains(target) &&
|
|
55
|
-
target !== this.trigger
|
|
56
|
-
) {
|
|
57
|
-
this.closeModal();
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
this.closeButtons?.forEach((trigger) => {
|
|
63
|
-
trigger.addEventListener("click", () => this.closeModal());
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
document.addEventListener("keydown", (e) => this.handleKeyDown(e));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private open() {
|
|
70
|
-
this.backdrop?.classList.remove("hidden");
|
|
71
|
-
this.modal?.classList.remove("hidden");
|
|
72
|
-
document.body.classList.add("overflow-hidden");
|
|
73
|
-
setTimeout(() => {
|
|
74
|
-
this.setState("open");
|
|
75
|
-
}, 0);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
private closeModal() {
|
|
79
|
-
this.setState("closed");
|
|
80
|
-
setTimeout(() => {
|
|
81
|
-
this.backdrop?.classList.add("hidden");
|
|
82
|
-
this.modal?.classList.add("hidden");
|
|
83
|
-
document.body.classList.remove("overflow-hidden");
|
|
84
|
-
}, 200);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
private setState(state: "open" | "closed") {
|
|
88
|
-
this.trigger?.focus();
|
|
89
|
-
this.modal?.setAttribute("aria-hidden", `${state === "closed"}`);
|
|
90
|
-
this.modal?.setAttribute("data-state", state);
|
|
91
|
-
this.backdrop?.setAttribute("aria-hidden", `${state === "closed"}`);
|
|
92
|
-
this.backdrop?.setAttribute("data-state", state);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
private handleKeyDown = (event: KeyboardEvent) => {
|
|
96
|
-
if (event.key === "Escape" && this.modal!.dataset.status === "open") {
|
|
97
|
-
this.closeModal();
|
|
98
|
-
event.preventDefault();
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
}
|
|
1
|
+
export class Modal {
|
|
2
|
+
private wrapper: HTMLElement;
|
|
3
|
+
private modal: HTMLElement | null;
|
|
4
|
+
private trigger: HTMLElement | null;
|
|
5
|
+
private backdrop: HTMLElement | null;
|
|
6
|
+
private closeButtons: NodeListOf<HTMLElement> | null;
|
|
7
|
+
|
|
8
|
+
constructor(wrapper: HTMLElement) {
|
|
9
|
+
this.wrapper = wrapper;
|
|
10
|
+
this.modal = this.wrapper.querySelector("[data-modal]");
|
|
11
|
+
this.backdrop = this.wrapper.querySelector("[data-backdrop]");
|
|
12
|
+
this.trigger = this.wrapper.querySelector("[data-trigger]");
|
|
13
|
+
this.closeButtons = this.wrapper.querySelectorAll("[data-close]");
|
|
14
|
+
|
|
15
|
+
if (!this.modal || !this.trigger) {
|
|
16
|
+
console.error("Modal not initialized properly", {
|
|
17
|
+
modal: this.modal,
|
|
18
|
+
});
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
this.init();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private init() {
|
|
26
|
+
this.setupAccessibility();
|
|
27
|
+
this.setupEventListeners();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private setupAccessibility() {
|
|
31
|
+
const title = this.modal?.querySelector<HTMLElement>(
|
|
32
|
+
"h1, h2, h3, h4, h5, h6",
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
if (title) {
|
|
36
|
+
const id =
|
|
37
|
+
title.id || `modal-id-${Math.random().toString(36).substring(2, 9)}`;
|
|
38
|
+
title.id = id;
|
|
39
|
+
this.modal?.setAttribute("aria-describedby", id);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
this.setState("closed");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private setupEventListeners() {
|
|
46
|
+
this.trigger!.addEventListener("click", () => this.open());
|
|
47
|
+
|
|
48
|
+
if (this.modal?.dataset.allowOutsideClick === "true") {
|
|
49
|
+
this.backdrop?.addEventListener("click", () => this.closeModal());
|
|
50
|
+
document.addEventListener("click", (e) => {
|
|
51
|
+
const target = e.target as HTMLElement;
|
|
52
|
+
if (
|
|
53
|
+
this.modal &&
|
|
54
|
+
!this.modal.contains(target) &&
|
|
55
|
+
target !== this.trigger
|
|
56
|
+
) {
|
|
57
|
+
this.closeModal();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
this.closeButtons?.forEach((trigger) => {
|
|
63
|
+
trigger.addEventListener("click", () => this.closeModal());
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
document.addEventListener("keydown", (e) => this.handleKeyDown(e));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private open() {
|
|
70
|
+
this.backdrop?.classList.remove("hidden");
|
|
71
|
+
this.modal?.classList.remove("hidden");
|
|
72
|
+
document.body.classList.add("overflow-hidden");
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
this.setState("open");
|
|
75
|
+
}, 0);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private closeModal() {
|
|
79
|
+
this.setState("closed");
|
|
80
|
+
setTimeout(() => {
|
|
81
|
+
this.backdrop?.classList.add("hidden");
|
|
82
|
+
this.modal?.classList.add("hidden");
|
|
83
|
+
document.body.classList.remove("overflow-hidden");
|
|
84
|
+
}, 200);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private setState(state: "open" | "closed") {
|
|
88
|
+
this.trigger?.focus();
|
|
89
|
+
this.modal?.setAttribute("aria-hidden", `${state === "closed"}`);
|
|
90
|
+
this.modal?.setAttribute("data-state", state);
|
|
91
|
+
this.backdrop?.setAttribute("aria-hidden", `${state === "closed"}`);
|
|
92
|
+
this.backdrop?.setAttribute("data-state", state);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private handleKeyDown = (event: KeyboardEvent) => {
|
|
96
|
+
if (event.key === "Escape" && this.modal!.dataset.status === "open") {
|
|
97
|
+
this.closeModal();
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
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
|
-
import { paginationLinkVariants } from "./paginationVariants";
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
Pagination,
|
|
10
|
-
PaginationContent,
|
|
11
|
-
PaginationEllipsis,
|
|
12
|
-
PaginationItem,
|
|
13
|
-
PaginationLink,
|
|
14
|
-
paginationLinkVariants,
|
|
15
|
-
};
|
|
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
|
+
import { paginationLinkVariants } from "./paginationVariants";
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
Pagination,
|
|
10
|
+
PaginationContent,
|
|
11
|
+
PaginationEllipsis,
|
|
12
|
+
PaginationItem,
|
|
13
|
+
PaginationLink,
|
|
14
|
+
paginationLinkVariants,
|
|
15
|
+
};
|
|
@@ -1,17 +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>
|
|
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>
|
|
@@ -1,39 +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>
|
|
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>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Popover from "./Popover.astro";
|
|
2
|
-
import PopoverContent from "./PopoverContent.astro";
|
|
3
|
-
import { popoverArrowVariants, popoverVariants } from "./popoverVariants";
|
|
4
|
-
|
|
5
|
-
export { Popover, popoverArrowVariants, PopoverContent, popoverVariants };
|
|
1
|
+
import Popover from "./Popover.astro";
|
|
2
|
+
import PopoverContent from "./PopoverContent.astro";
|
|
3
|
+
import { popoverArrowVariants, popoverVariants } from "./popoverVariants";
|
|
4
|
+
|
|
5
|
+
export { Popover, popoverArrowVariants, PopoverContent, popoverVariants };
|