@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.
Files changed (120) hide show
  1. package/dist/astro/accordion/Accordion.astro +34 -34
  2. package/dist/astro/accordion/AccordionItem.astro +19 -19
  3. package/dist/astro/accordion/AccordionTrigger.astro +33 -33
  4. package/dist/astro/accordion/AcordionContent.astro +23 -23
  5. package/dist/astro/accordion/accordion.ts +151 -151
  6. package/dist/astro/accordion/index.ts +6 -6
  7. package/dist/astro/ambient-image/AmbientFigcaption.astro +15 -0
  8. package/dist/astro/ambient-image/AmbientImage.astro +70 -0
  9. package/dist/astro/ambient-image/index.ts +4 -0
  10. package/dist/astro/button-group/ButtonGroup.astro +21 -0
  11. package/dist/astro/button-group/buttonGroupVariants.ts +34 -0
  12. package/dist/astro/button-group/index.ts +3 -0
  13. package/dist/astro/collapsible/Collapsible.astro +34 -34
  14. package/dist/astro/collapsible/CollapsibleContent.astro +20 -20
  15. package/dist/astro/collapsible/collapsible.ts +81 -81
  16. package/dist/astro/collapsible/index.ts +4 -4
  17. package/dist/astro/diff/Diff.astro +55 -0
  18. package/dist/astro/diff/DiffItem.astro +21 -0
  19. package/dist/astro/diff/index.ts +4 -0
  20. package/dist/astro/drawer/DrawerContent.astro +74 -74
  21. package/dist/astro/drawer/drawer.ts +104 -104
  22. package/dist/astro/drawer/index.ts +17 -17
  23. package/dist/astro/dropdown/DropdownMenu.astro +19 -19
  24. package/dist/astro/dropdown/DropdownMenuContent.astro +42 -42
  25. package/dist/astro/dropdown/DropdownMenuGroup.astro +3 -3
  26. package/dist/astro/dropdown/DropdownMenuItem.astro +27 -27
  27. package/dist/astro/dropdown/DropdownMenuLabel.astro +3 -3
  28. package/dist/astro/dropdown/DropdownMenuSeparator.astro +6 -6
  29. package/dist/astro/dropdown/dropdown.ts +157 -157
  30. package/dist/astro/dropdown/dropdownVariants.ts +134 -134
  31. package/dist/astro/dropdown/index.ts +23 -23
  32. package/dist/astro/loader/Loader.astro +16 -0
  33. package/dist/astro/loader/index.ts +6 -0
  34. package/dist/astro/loader/loaders/12-dots-scale-rotate.svg +1 -0
  35. package/dist/astro/loader/loaders/180-ring-with-bg.svg +1 -0
  36. package/dist/astro/loader/loaders/180-ring.svg +1 -0
  37. package/dist/astro/loader/loaders/270-ring-with-bg.svg +1 -0
  38. package/dist/astro/loader/loaders/270-ring.svg +1 -0
  39. package/dist/astro/loader/loaders/3-dots-bounce.svg +1 -0
  40. package/dist/astro/loader/loaders/3-dots-fade.svg +1 -0
  41. package/dist/astro/loader/loaders/3-dots-move.svg +1 -0
  42. package/dist/astro/loader/loaders/3-dots-rotate.svg +1 -0
  43. package/dist/astro/loader/loaders/3-dots-scale-middle.svg +1 -0
  44. package/dist/astro/loader/loaders/3-dots-scale.svg +1 -0
  45. package/dist/astro/loader/loaders/6-dots-rotate.svg +1 -0
  46. package/dist/astro/loader/loaders/6-dots-scale-middle.svg +1 -0
  47. package/dist/astro/loader/loaders/6-dots-scale.svg +1 -0
  48. package/dist/astro/loader/loaders/8-dots-rotate.svg +1 -0
  49. package/dist/astro/loader/loaders/90-ring-with-bg.svg +1 -0
  50. package/dist/astro/loader/loaders/90-ring.svg +1 -0
  51. package/dist/astro/loader/loaders/bars-fade.svg +1 -0
  52. package/dist/astro/loader/loaders/bars-rotate-fade.svg +1 -0
  53. package/dist/astro/loader/loaders/bars-scale-fade.svg +1 -0
  54. package/dist/astro/loader/loaders/bars-scale-middle.svg +1 -0
  55. package/dist/astro/loader/loaders/bars-scale.svg +1 -0
  56. package/dist/astro/loader/loaders/blocks-scale.svg +1 -0
  57. package/dist/astro/loader/loaders/blocks-shuffle-2.svg +1 -0
  58. package/dist/astro/loader/loaders/blocks-shuffle-3.svg +1 -0
  59. package/dist/astro/loader/loaders/blocks-wave.svg +1 -0
  60. package/dist/astro/loader/loaders/bouncing-ball.svg +1 -0
  61. package/dist/astro/loader/loaders/clock.svg +1 -0
  62. package/dist/astro/loader/loaders/dot-revolve.svg +1 -0
  63. package/dist/astro/loader/loaders/eclipse-half.svg +1 -0
  64. package/dist/astro/loader/loaders/eclipse.svg +1 -0
  65. package/dist/astro/loader/loaders/gooey-balls-1.svg +1 -0
  66. package/dist/astro/loader/loaders/gooey-balls-2.svg +1 -0
  67. package/dist/astro/loader/loaders/index.ts +99 -0
  68. package/dist/astro/loader/loaders/pulse-2.svg +1 -0
  69. package/dist/astro/loader/loaders/pulse-3.svg +1 -0
  70. package/dist/astro/loader/loaders/pulse-multiple.svg +1 -0
  71. package/dist/astro/loader/loaders/pulse-ring.svg +1 -0
  72. package/dist/astro/loader/loaders/pulse-rings-2.svg +1 -0
  73. package/dist/astro/loader/loaders/pulse-rings-3.svg +1 -0
  74. package/dist/astro/loader/loaders/pulse-rings-multiple.svg +1 -0
  75. package/dist/astro/loader/loaders/pulse.svg +1 -0
  76. package/dist/astro/loader/loaders/ring-resize.svg +1 -0
  77. package/dist/astro/loader/loaders/tadpole.svg +1 -0
  78. package/dist/astro/loader/loaders/wifi-fade.svg +1 -0
  79. package/dist/astro/loader/loaders/wifi.svg +1 -0
  80. package/dist/astro/loader/loaders/wind-toy.svg +1 -0
  81. package/dist/astro/marquee/Marquee.astro +53 -0
  82. package/dist/astro/marquee/index.ts +3 -0
  83. package/dist/astro/modal/Modal.astro +19 -19
  84. package/dist/astro/modal/ModalContent.astro +71 -71
  85. package/dist/astro/modal/ModalDescription.astro +12 -12
  86. package/dist/astro/modal/ModalFooter.astro +15 -15
  87. package/dist/astro/modal/ModalHeader.astro +12 -12
  88. package/dist/astro/modal/ModalTitle.astro +18 -18
  89. package/dist/astro/modal/index.ts +15 -15
  90. package/dist/astro/modal/modal.ts +101 -101
  91. package/dist/astro/pagination/index.ts +15 -15
  92. package/dist/astro/popover/Popover.astro +17 -17
  93. package/dist/astro/popover/PopoverContent.astro +39 -39
  94. package/dist/astro/popover/index.ts +5 -5
  95. package/dist/astro/popover/popover.ts +113 -113
  96. package/dist/astro/popover/popoverVariants.ts +115 -115
  97. package/dist/astro/scroll-progress/ScrollProgress.astro +41 -0
  98. package/dist/astro/scroll-progress/ScrollProgressBar.astro +19 -0
  99. package/dist/astro/scroll-progress/index.ts +4 -0
  100. package/dist/astro/stat/Stat.astro +12 -12
  101. package/dist/astro/stat/StatDescription.astro +12 -12
  102. package/dist/astro/stat/StatTitle.astro +18 -18
  103. package/dist/astro/stat/StatValue.astro +12 -12
  104. package/dist/astro/stat/index.ts +6 -6
  105. package/dist/astro/tab/TabList.astro +19 -19
  106. package/dist/astro/toast/Toast.astro +36 -0
  107. package/dist/astro/toast/ToastDescription.astro +10 -0
  108. package/dist/astro/toast/ToastTitle.astro +18 -0
  109. package/dist/astro/toast/Toaster.astro +78 -0
  110. package/dist/astro/toast/assets.ts +6 -0
  111. package/dist/astro/toast/index.ts +30 -0
  112. package/dist/astro/toast/toast.ts +277 -0
  113. package/dist/astro/tooltip/Tooltip.astro +40 -40
  114. package/dist/astro/tooltip/TooltipContent.astro +39 -39
  115. package/dist/astro/tooltip/index.ts +5 -5
  116. package/dist/astro/tooltip/tooltip.ts +137 -137
  117. package/dist/astro/tooltip/tooltipVariants.ts +115 -115
  118. package/dist/index.js +30 -2
  119. package/dist/index.js.map +1 -1
  120. package/package.json +9 -8
@@ -1,157 +1,157 @@
1
- export class DowndownMenu {
2
- // References to tooltip elements
3
- private dropdownMenu: HTMLElement;
4
- private trigger: HTMLElement | null;
5
- private content: HTMLElement | null;
6
- private menuItems: HTMLElement[] = [];
7
-
8
- constructor(dropowndMenu: HTMLElement) {
9
- this.dropdownMenu = dropowndMenu;
10
- this.content = this.dropdownMenu.querySelector("[data-dropdown-content]");
11
- this.trigger = this.dropdownMenu.querySelector("[data-trigger]");
12
- this.menuItems = Array.from(
13
- this.content?.querySelectorAll(
14
- '[role="menuitem"]:not([data-disabled="true"])',
15
- ) || [],
16
- );
17
-
18
- if (!this.content || !this.trigger) {
19
- console.error("Dropdown not initialized properly", {
20
- content: this.content,
21
- trigger: this.trigger,
22
- });
23
- return;
24
- }
25
-
26
- this.init();
27
- }
28
-
29
- private init() {
30
- this.setupAccessibility();
31
- this.setupEventListeners();
32
- }
33
-
34
- private setupAccessibility() {
35
- if (!this.trigger || !this.content) return;
36
-
37
- const id =
38
- this.content.id ||
39
- `dropdown-id-${Math.random().toString(36).substring(2, 9)}`;
40
- this.content.id = id;
41
- this.trigger.setAttribute("aria-describedby", id);
42
- this.setState("closed");
43
- }
44
-
45
- private setupEventListeners() {
46
- if (!this.trigger || !this.content) return;
47
-
48
- this.trigger.addEventListener("click", () => this.toggleDropdown());
49
-
50
- this.content.addEventListener("click", (e) => {
51
- const target = e.target as HTMLElement;
52
- const item = target.closest('[role="menuitem"]') as HTMLElement;
53
-
54
- if (item && item.dataset.disabled !== "true") {
55
- this.closeDropdown();
56
- }
57
- });
58
-
59
- document.addEventListener("click", (e) => {
60
- const target = e.target as HTMLElement;
61
- if (
62
- this.content &&
63
- !this.content.contains(target) &&
64
- target !== this.trigger
65
- ) {
66
- this.closeDropdown();
67
- }
68
- });
69
-
70
- this.trigger.addEventListener("keydown", (e) => {
71
- const isOpen = this.content?.dataset.state === "open";
72
- if (e.key === "Enter" || e.key === " ") {
73
- e.preventDefault();
74
- this.toggleDropdown();
75
- } else if (e.key === "Escape" && isOpen) {
76
- e.preventDefault();
77
- this.closeDropdown();
78
- } else if (isOpen && e.key === "ArrowDown") {
79
- e.preventDefault();
80
- this.setFocusItem(0);
81
- } else if (isOpen && e.key === "ArrowUp") {
82
- e.preventDefault();
83
- this.setFocusItem(this.menuItems.length - 1);
84
- }
85
- });
86
-
87
- this.menuItems.forEach((menuItem) => {
88
- menuItem.addEventListener("keydown", (e) =>
89
- this.handleMenuKeydown(e, menuItem),
90
- );
91
- });
92
- document.addEventListener("keydown", (e) => this.handleKeydown(e));
93
- }
94
-
95
- private toggleDropdown() {
96
- if (this.content?.dataset.state === "open") {
97
- this.closeDropdown();
98
- } else {
99
- this.openDropdown();
100
- }
101
- }
102
-
103
- private openDropdown() {
104
- this.content?.classList.remove("hidden");
105
-
106
- window.setTimeout(() => {
107
- this.setState("open");
108
- }, 0);
109
- }
110
-
111
- private closeDropdown() {
112
- this.trigger?.focus();
113
- this.setState("closed");
114
- window.setTimeout(() => {
115
- this.content?.classList.add("hidden");
116
- }, 100);
117
- }
118
-
119
- private setState(state: "open" | "closed") {
120
- this.content?.setAttribute("aria-hidden", `${state === "closed"}`);
121
- this.content?.setAttribute("data-state", state);
122
- }
123
-
124
- private handleKeydown = (event: KeyboardEvent) => {
125
- if (event.key === "Escape" && this.content!.dataset.state === "open") {
126
- this.closeDropdown();
127
- event.preventDefault();
128
- }
129
- };
130
-
131
- private handleMenuKeydown(event: KeyboardEvent, item: HTMLElement) {
132
- const currentItemIndex = this.menuItems.indexOf(item);
133
-
134
- const keyActions: Record<string, () => void> = {
135
- ArrowDown: () => this.setFocusItem(currentItemIndex + 1),
136
- ArrowUp: () => this.setFocusItem(currentItemIndex - 1),
137
- Home: () => this.setFocusItem(0),
138
- End: () => this.setFocusItem(this.menuItems.length - 1),
139
- Enter: () => item.click(),
140
- " ": () => item.click(),
141
- };
142
-
143
- const action = keyActions[event.key];
144
- if (action) {
145
- event.preventDefault();
146
- action();
147
- }
148
- }
149
-
150
- private setFocusItem(index: number) {
151
- const newIndex = (index + this.menuItems.length) % this.menuItems.length;
152
-
153
- if (this.menuItems[newIndex]) {
154
- this.menuItems[newIndex].focus();
155
- }
156
- }
157
- }
1
+ export class DowndownMenu {
2
+ // References to tooltip elements
3
+ private dropdownMenu: HTMLElement;
4
+ private trigger: HTMLElement | null;
5
+ private content: HTMLElement | null;
6
+ private menuItems: HTMLElement[] = [];
7
+
8
+ constructor(dropowndMenu: HTMLElement) {
9
+ this.dropdownMenu = dropowndMenu;
10
+ this.content = this.dropdownMenu.querySelector("[data-dropdown-content]");
11
+ this.trigger = this.dropdownMenu.querySelector("[data-trigger]");
12
+ this.menuItems = Array.from(
13
+ this.content?.querySelectorAll(
14
+ '[role="menuitem"]:not([data-disabled="true"])',
15
+ ) || [],
16
+ );
17
+
18
+ if (!this.content || !this.trigger) {
19
+ console.error("Dropdown not initialized properly", {
20
+ content: this.content,
21
+ trigger: this.trigger,
22
+ });
23
+ return;
24
+ }
25
+
26
+ this.init();
27
+ }
28
+
29
+ private init() {
30
+ this.setupAccessibility();
31
+ this.setupEventListeners();
32
+ }
33
+
34
+ private setupAccessibility() {
35
+ if (!this.trigger || !this.content) return;
36
+
37
+ const id =
38
+ this.content.id ||
39
+ `dropdown-id-${Math.random().toString(36).substring(2, 9)}`;
40
+ this.content.id = id;
41
+ this.trigger.setAttribute("aria-describedby", id);
42
+ this.setState("closed");
43
+ }
44
+
45
+ private setupEventListeners() {
46
+ if (!this.trigger || !this.content) return;
47
+
48
+ this.trigger.addEventListener("click", () => this.toggleDropdown());
49
+
50
+ this.content.addEventListener("click", (e) => {
51
+ const target = e.target as HTMLElement;
52
+ const item = target.closest('[role="menuitem"]') as HTMLElement;
53
+
54
+ if (item && item.dataset.disabled !== "true") {
55
+ this.closeDropdown();
56
+ }
57
+ });
58
+
59
+ document.addEventListener("click", (e) => {
60
+ const target = e.target as HTMLElement;
61
+ if (
62
+ this.content &&
63
+ !this.content.contains(target) &&
64
+ target !== this.trigger
65
+ ) {
66
+ this.closeDropdown();
67
+ }
68
+ });
69
+
70
+ this.trigger.addEventListener("keydown", (e) => {
71
+ const isOpen = this.content?.dataset.state === "open";
72
+ if (e.key === "Enter" || e.key === " ") {
73
+ e.preventDefault();
74
+ this.toggleDropdown();
75
+ } else if (e.key === "Escape" && isOpen) {
76
+ e.preventDefault();
77
+ this.closeDropdown();
78
+ } else if (isOpen && e.key === "ArrowDown") {
79
+ e.preventDefault();
80
+ this.setFocusItem(0);
81
+ } else if (isOpen && e.key === "ArrowUp") {
82
+ e.preventDefault();
83
+ this.setFocusItem(this.menuItems.length - 1);
84
+ }
85
+ });
86
+
87
+ this.menuItems.forEach((menuItem) => {
88
+ menuItem.addEventListener("keydown", (e) =>
89
+ this.handleMenuKeydown(e, menuItem),
90
+ );
91
+ });
92
+ document.addEventListener("keydown", (e) => this.handleKeydown(e));
93
+ }
94
+
95
+ private toggleDropdown() {
96
+ if (this.content?.dataset.state === "open") {
97
+ this.closeDropdown();
98
+ } else {
99
+ this.openDropdown();
100
+ }
101
+ }
102
+
103
+ private openDropdown() {
104
+ this.content?.classList.remove("hidden");
105
+
106
+ window.setTimeout(() => {
107
+ this.setState("open");
108
+ }, 0);
109
+ }
110
+
111
+ private closeDropdown() {
112
+ this.trigger?.focus();
113
+ this.setState("closed");
114
+ window.setTimeout(() => {
115
+ this.content?.classList.add("hidden");
116
+ }, 100);
117
+ }
118
+
119
+ private setState(state: "open" | "closed") {
120
+ this.content?.setAttribute("aria-hidden", `${state === "closed"}`);
121
+ this.content?.setAttribute("data-state", state);
122
+ }
123
+
124
+ private handleKeydown = (event: KeyboardEvent) => {
125
+ if (event.key === "Escape" && this.content!.dataset.state === "open") {
126
+ this.closeDropdown();
127
+ event.preventDefault();
128
+ }
129
+ };
130
+
131
+ private handleMenuKeydown(event: KeyboardEvent, item: HTMLElement) {
132
+ const currentItemIndex = this.menuItems.indexOf(item);
133
+
134
+ const keyActions: Record<string, () => void> = {
135
+ ArrowDown: () => this.setFocusItem(currentItemIndex + 1),
136
+ ArrowUp: () => this.setFocusItem(currentItemIndex - 1),
137
+ Home: () => this.setFocusItem(0),
138
+ End: () => this.setFocusItem(this.menuItems.length - 1),
139
+ Enter: () => item.click(),
140
+ " ": () => item.click(),
141
+ };
142
+
143
+ const action = keyActions[event.key];
144
+ if (action) {
145
+ event.preventDefault();
146
+ action();
147
+ }
148
+ }
149
+
150
+ private setFocusItem(index: number) {
151
+ const newIndex = (index + this.menuItems.length) % this.menuItems.length;
152
+
153
+ if (this.menuItems[newIndex]) {
154
+ this.menuItems[newIndex].focus();
155
+ }
156
+ }
157
+ }
@@ -1,134 +1,134 @@
1
- import { cva } from "class-variance-authority";
2
-
3
- const baseClass = [
4
- "hidden absolute z-50 bg-surface border border-border p-1 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 dropdownMenuVariants = 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 dropdownMenuItemBaseClass =
61
- "flex justify-between items-center gap-2 px-2 py-1.5 text-sm cursor-default rounded-md outline-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg]:size-4";
62
-
63
- const dropdownMenuItemVariants = cva(dropdownMenuItemBaseClass, {
64
- variants: {
65
- disabled: {
66
- false: "hover:bg-foreground/5 focus:bg-foreground/5 ",
67
- true: "opacity-70 pointer-events-none",
68
- },
69
- },
70
- defaultVariants: {
71
- disabled: false,
72
- },
73
- });
74
-
75
- const arrowClass =
76
- "absolute w-0 h-0 transition-all transform ease-in size-2 bg-surface transform rotate-45 border-border";
77
-
78
- const dropdownArrowVariants = cva(arrowClass, {
79
- variants: {
80
- side: {
81
- top: "top-full -mt-1 border-b border-r",
82
- bottom: "bottom-full -mb-1 border-t border-l",
83
- left: "left-full -ml-1 border-t border-r",
84
- right: "right-full -mr-1 border-b border-l",
85
- },
86
- alignment: {
87
- start: "",
88
- center: "",
89
- end: "",
90
- },
91
- },
92
- compoundVariants: [
93
- {
94
- side: ["top", "bottom"],
95
- alignment: "start",
96
- class: "left-0 ml-3 ",
97
- },
98
- {
99
- side: ["top", "bottom"],
100
- alignment: "end",
101
- class: "right-0 mr-3",
102
- },
103
- {
104
- side: ["top", "bottom"],
105
- alignment: "center",
106
- class: "left-1/2 -translate-x-1/2",
107
- },
108
- {
109
- side: ["left", "right"],
110
- alignment: "start",
111
- class: "top-0 mt-3",
112
- },
113
- {
114
- side: ["left", "right"],
115
- alignment: "center",
116
- class: "top-1/2 -translate-y-1/2",
117
- },
118
- {
119
- side: ["left", "right"],
120
- alignment: "end",
121
- class: "bottom-0 mb-3",
122
- },
123
- ],
124
- defaultVariants: {
125
- side: "bottom",
126
- alignment: "center",
127
- },
128
- });
129
-
130
- export {
131
- dropdownArrowVariants,
132
- dropdownMenuItemVariants,
133
- dropdownMenuVariants,
134
- };
1
+ import { cva } from "class-variance-authority";
2
+
3
+ const baseClass = [
4
+ "hidden absolute z-50 bg-surface border border-border p-1 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 dropdownMenuVariants = 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 dropdownMenuItemBaseClass =
61
+ "flex justify-between items-center gap-2 px-2 py-1.5 text-sm cursor-default rounded-md outline-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg]:size-4";
62
+
63
+ const dropdownMenuItemVariants = cva(dropdownMenuItemBaseClass, {
64
+ variants: {
65
+ disabled: {
66
+ false: "hover:bg-foreground/5 focus:bg-foreground/5 ",
67
+ true: "opacity-70 pointer-events-none",
68
+ },
69
+ },
70
+ defaultVariants: {
71
+ disabled: false,
72
+ },
73
+ });
74
+
75
+ const arrowClass =
76
+ "absolute w-0 h-0 transition-all transform ease-in size-2 bg-surface transform rotate-45 border-border";
77
+
78
+ const dropdownArrowVariants = cva(arrowClass, {
79
+ variants: {
80
+ side: {
81
+ top: "top-full -mt-1 border-b border-r",
82
+ bottom: "bottom-full -mb-1 border-t border-l",
83
+ left: "left-full -ml-1 border-t border-r",
84
+ right: "right-full -mr-1 border-b border-l",
85
+ },
86
+ alignment: {
87
+ start: "",
88
+ center: "",
89
+ end: "",
90
+ },
91
+ },
92
+ compoundVariants: [
93
+ {
94
+ side: ["top", "bottom"],
95
+ alignment: "start",
96
+ class: "left-0 ml-3 ",
97
+ },
98
+ {
99
+ side: ["top", "bottom"],
100
+ alignment: "end",
101
+ class: "right-0 mr-3",
102
+ },
103
+ {
104
+ side: ["top", "bottom"],
105
+ alignment: "center",
106
+ class: "left-1/2 -translate-x-1/2",
107
+ },
108
+ {
109
+ side: ["left", "right"],
110
+ alignment: "start",
111
+ class: "top-0 mt-3",
112
+ },
113
+ {
114
+ side: ["left", "right"],
115
+ alignment: "center",
116
+ class: "top-1/2 -translate-y-1/2",
117
+ },
118
+ {
119
+ side: ["left", "right"],
120
+ alignment: "end",
121
+ class: "bottom-0 mb-3",
122
+ },
123
+ ],
124
+ defaultVariants: {
125
+ side: "bottom",
126
+ alignment: "center",
127
+ },
128
+ });
129
+
130
+ export {
131
+ dropdownArrowVariants,
132
+ dropdownMenuItemVariants,
133
+ dropdownMenuVariants,
134
+ };
@@ -1,23 +1,23 @@
1
- import DropdownMenu from "./DropdownMenu.astro";
2
- import DropdownMenuContent from "./DropdownMenuContent.astro";
3
- import DropdownMenuGroup from "./DropdownMenuGroup.astro";
4
- import DropdownMenuItem from "./DropdownMenuItem.astro";
5
- import DropdownMenuLabel from "./DropdownMenuLabel.astro";
6
- import DropdownMenuSeparator from "./DropdownMenuSeparator.astro";
7
- import {
8
- dropdownArrowVariants,
9
- dropdownMenuItemVariants,
10
- dropdownMenuVariants,
11
- } from "./dropdownVariants";
12
-
13
- export {
14
- dropdownArrowVariants,
15
- DropdownMenu,
16
- DropdownMenuContent,
17
- DropdownMenuGroup,
18
- DropdownMenuItem,
19
- dropdownMenuItemVariants,
20
- DropdownMenuLabel,
21
- DropdownMenuSeparator,
22
- dropdownMenuVariants,
23
- };
1
+ import DropdownMenu from "./DropdownMenu.astro";
2
+ import DropdownMenuContent from "./DropdownMenuContent.astro";
3
+ import DropdownMenuGroup from "./DropdownMenuGroup.astro";
4
+ import DropdownMenuItem from "./DropdownMenuItem.astro";
5
+ import DropdownMenuLabel from "./DropdownMenuLabel.astro";
6
+ import DropdownMenuSeparator from "./DropdownMenuSeparator.astro";
7
+ import {
8
+ dropdownArrowVariants,
9
+ dropdownMenuItemVariants,
10
+ dropdownMenuVariants,
11
+ } from "./dropdownVariants";
12
+
13
+ export {
14
+ dropdownArrowVariants,
15
+ DropdownMenu,
16
+ DropdownMenuContent,
17
+ DropdownMenuGroup,
18
+ DropdownMenuItem,
19
+ dropdownMenuItemVariants,
20
+ DropdownMenuLabel,
21
+ DropdownMenuSeparator,
22
+ dropdownMenuVariants,
23
+ };
@@ -0,0 +1,16 @@
1
+ ---
2
+ import { cn } from "@/utils/cn";
3
+ import type { HTMLAttributes } from "astro/types";
4
+ import { loaders, type LoaderType } from "./loaders";
5
+
6
+ interface Props extends HTMLAttributes<"svg"> {
7
+ type?: LoaderType;
8
+ size?: number;
9
+ }
10
+
11
+ const { class: className, type, size = 32, ...attrs } = Astro.props;
12
+
13
+ const LoaderIcon = loaders[type || "180-ring"];
14
+ ---
15
+
16
+ <LoaderIcon class={cn(className)} width={size} height={size} {...attrs} />
@@ -0,0 +1,6 @@
1
+ import Loader from "./Loader.astro";
2
+ import { type LoaderType, loaders } from "./loaders";
3
+
4
+ export { Loader, loaders };
5
+
6
+ export type { LoaderType };
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><g><circle cx="12" cy="3" r="1" fill="currentColor"><animate id="SVGelgoqhuA" attributeName="r" begin="0;SVGSRzJybSJ.end-0.5s" calcMode="spline" dur="0.6s" keySplines=".27,.42,.37,.99;.53,0,.61,.73" values="1;2;1"/></circle><circle cx="16.5" cy="4.21" r="1" fill="currentColor"><animate id="SVGBcQu6cCi" attributeName="r" begin="SVGelgoqhuA.begin+0.1s" calcMode="spline" dur="0.6s" keySplines=".27,.42,.37,.99;.53,0,.61,.73" values="1;2;1"/></circle><circle cx="7.5" cy="4.21" r="1" fill="currentColor"><animate id="SVGSRzJybSJ" attributeName="r" begin="SVGeZGzNdVZ.begin+0.1s" calcMode="spline" dur="0.6s" keySplines=".27,.42,.37,.99;.53,0,.61,.73" values="1;2;1"/></circle><circle cx="19.79" cy="7.5" r="1" fill="currentColor"><animate id="SVGG5Q0fe0M" attributeName="r" begin="SVGBcQu6cCi.begin+0.1s" calcMode="spline" dur="0.6s" keySplines=".27,.42,.37,.99;.53,0,.61,.73" values="1;2;1"/></circle><circle cx="4.21" cy="7.5" r="1" fill="currentColor"><animate id="SVGeZGzNdVZ" attributeName="r" begin="SVGUTnihcal.begin+0.1s" calcMode="spline" dur="0.6s" keySplines=".27,.42,.37,.99;.53,0,.61,.73" values="1;2;1"/></circle><circle cx="21" cy="12" r="1" fill="currentColor"><animate id="SVG8aQG8dpc" attributeName="r" begin="SVGG5Q0fe0M.begin+0.1s" calcMode="spline" dur="0.6s" keySplines=".27,.42,.37,.99;.53,0,.61,.73" values="1;2;1"/></circle><circle cx="3" cy="12" r="1" fill="currentColor"><animate id="SVGUTnihcal" attributeName="r" begin="SVGHktsvT5Q.begin+0.1s" calcMode="spline" dur="0.6s" keySplines=".27,.42,.37,.99;.53,0,.61,.73" values="1;2;1"/></circle><circle cx="19.79" cy="16.5" r="1" fill="currentColor"><animate id="SVGqCF3Scrd" attributeName="r" begin="SVG8aQG8dpc.begin+0.1s" calcMode="spline" dur="0.6s" keySplines=".27,.42,.37,.99;.53,0,.61,.73" values="1;2;1"/></circle><circle cx="4.21" cy="16.5" r="1" fill="currentColor"><animate id="SVGHktsvT5Q" attributeName="r" begin="SVGSFNCBbxb.begin+0.1s" calcMode="spline" dur="0.6s" keySplines=".27,.42,.37,.99;.53,0,.61,.73" values="1;2;1"/></circle><circle cx="16.5" cy="19.79" r="1" fill="currentColor"><animate id="SVGMFYo1cJN" attributeName="r" begin="SVGqCF3Scrd.begin+0.1s" calcMode="spline" dur="0.6s" keySplines=".27,.42,.37,.99;.53,0,.61,.73" values="1;2;1"/></circle><circle cx="7.5" cy="19.79" r="1" fill="currentColor"><animate id="SVGSFNCBbxb" attributeName="r" begin="SVGLSoLpdOI.begin+0.1s" calcMode="spline" dur="0.6s" keySplines=".27,.42,.37,.99;.53,0,.61,.73" values="1;2;1"/></circle><circle cx="12" cy="21" r="1" fill="currentColor"><animate id="SVGLSoLpdOI" attributeName="r" begin="SVGMFYo1cJN.begin+0.1s" calcMode="spline" dur="0.6s" keySplines=".27,.42,.37,.99;.53,0,.61,.73" values="1;2;1"/></circle><animateTransform attributeName="transform" dur="6s" repeatCount="indefinite" type="rotate" values="360 12 12;0 12 12"/></g></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z" opacity="0.25"/><path fill="currentColor" d="M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"><animateTransform attributeName="transform" dur="0.75s" repeatCount="indefinite" type="rotate" values="0 12 12;360 12 12"/></path></svg>