@starwind-ui/core 1.11.2 → 1.12.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 +1 -1
- package/dist/index.d.ts +0 -28
- package/dist/index.js +0 -74
- package/dist/index.js.map +0 -1
- package/dist/src/components/accordion/Accordion.astro +0 -247
- package/dist/src/components/accordion/AccordionContent.astro +0 -33
- package/dist/src/components/accordion/AccordionItem.astro +0 -27
- package/dist/src/components/accordion/AccordionTrigger.astro +0 -32
- package/dist/src/components/accordion/index.ts +0 -15
- package/dist/src/components/alert/Alert.astro +0 -31
- package/dist/src/components/alert/AlertDescription.astro +0 -14
- package/dist/src/components/alert/AlertTitle.astro +0 -16
- package/dist/src/components/alert/index.ts +0 -13
- package/dist/src/components/alert-dialog/AlertDialog.astro +0 -273
- package/dist/src/components/alert-dialog/AlertDialogAction.astro +0 -44
- package/dist/src/components/alert-dialog/AlertDialogCancel.astro +0 -45
- package/dist/src/components/alert-dialog/AlertDialogContent.astro +0 -52
- package/dist/src/components/alert-dialog/AlertDialogDescription.astro +0 -18
- package/dist/src/components/alert-dialog/AlertDialogFooter.astro +0 -16
- package/dist/src/components/alert-dialog/AlertDialogHeader.astro +0 -14
- package/dist/src/components/alert-dialog/AlertDialogTitle.astro +0 -20
- package/dist/src/components/alert-dialog/AlertDialogTrigger.astro +0 -47
- package/dist/src/components/alert-dialog/index.ts +0 -46
- package/dist/src/components/aspect-ratio/AspectRatio.astro +0 -32
- package/dist/src/components/aspect-ratio/index.ts +0 -7
- package/dist/src/components/avatar/Avatar.astro +0 -29
- package/dist/src/components/avatar/AvatarFallback.astro +0 -18
- package/dist/src/components/avatar/AvatarImage.astro +0 -49
- package/dist/src/components/avatar/index.ts +0 -13
- package/dist/src/components/badge/Badge.astro +0 -51
- package/dist/src/components/badge/index.ts +0 -7
- package/dist/src/components/breadcrumb/Breadcrumb.astro +0 -11
- package/dist/src/components/breadcrumb/BreadcrumbEllipsis.astro +0 -28
- package/dist/src/components/breadcrumb/BreadcrumbItem.astro +0 -14
- package/dist/src/components/breadcrumb/BreadcrumbLink.astro +0 -22
- package/dist/src/components/breadcrumb/BreadcrumbList.astro +0 -16
- package/dist/src/components/breadcrumb/BreadcrumbPage.astro +0 -21
- package/dist/src/components/breadcrumb/BreadcrumbSeparator.astro +0 -23
- package/dist/src/components/breadcrumb/index.ts +0 -37
- package/dist/src/components/button/Button.astro +0 -53
- package/dist/src/components/button/index.ts +0 -7
- package/dist/src/components/card/Card.astro +0 -14
- package/dist/src/components/card/CardContent.astro +0 -14
- package/dist/src/components/card/CardDescription.astro +0 -14
- package/dist/src/components/card/CardFooter.astro +0 -14
- package/dist/src/components/card/CardHeader.astro +0 -14
- package/dist/src/components/card/CardTitle.astro +0 -14
- package/dist/src/components/card/index.ts +0 -26
- package/dist/src/components/carousel/Carousel.astro +0 -55
- package/dist/src/components/carousel/CarouselContent.astro +0 -26
- package/dist/src/components/carousel/CarouselItem.astro +0 -26
- package/dist/src/components/carousel/CarouselNext.astro +0 -37
- package/dist/src/components/carousel/CarouselPrevious.astro +0 -37
- package/dist/src/components/carousel/carousel-script.ts +0 -191
- package/dist/src/components/carousel/index.ts +0 -32
- package/dist/src/components/checkbox/Checkbox.astro +0 -127
- package/dist/src/components/checkbox/index.ts +0 -7
- package/dist/src/components/dialog/Dialog.astro +0 -263
- package/dist/src/components/dialog/DialogClose.astro +0 -35
- package/dist/src/components/dialog/DialogContent.astro +0 -67
- package/dist/src/components/dialog/DialogDescription.astro +0 -14
- package/dist/src/components/dialog/DialogFooter.astro +0 -14
- package/dist/src/components/dialog/DialogHeader.astro +0 -14
- package/dist/src/components/dialog/DialogTitle.astro +0 -20
- package/dist/src/components/dialog/DialogTrigger.astro +0 -47
- package/dist/src/components/dialog/index.ts +0 -45
- package/dist/src/components/dropdown/Dropdown.astro +0 -375
- package/dist/src/components/dropdown/DropdownContent.astro +0 -81
- package/dist/src/components/dropdown/DropdownItem.astro +0 -48
- package/dist/src/components/dropdown/DropdownLabel.astro +0 -29
- package/dist/src/components/dropdown/DropdownSeparator.astro +0 -21
- package/dist/src/components/dropdown/DropdownTrigger.astro +0 -52
- package/dist/src/components/dropdown/index.ts +0 -33
- package/dist/src/components/dropzone/Dropzone.astro +0 -233
- package/dist/src/components/dropzone/DropzoneFilesList.astro +0 -26
- package/dist/src/components/dropzone/DropzoneLoadingIndicator.astro +0 -10
- package/dist/src/components/dropzone/DropzoneUploadIndicator.astro +0 -10
- package/dist/src/components/dropzone/index.ts +0 -24
- package/dist/src/components/input/Input.astro +0 -24
- package/dist/src/components/input/index.ts +0 -7
- package/dist/src/components/item/Item.astro +0 -52
- package/dist/src/components/item/ItemActions.astro +0 -16
- package/dist/src/components/item/ItemContent.astro +0 -16
- package/dist/src/components/item/ItemDescription.astro +0 -19
- package/dist/src/components/item/ItemFooter.astro +0 -16
- package/dist/src/components/item/ItemGroup.astro +0 -16
- package/dist/src/components/item/ItemHeader.astro +0 -16
- package/dist/src/components/item/ItemMedia.astro +0 -40
- package/dist/src/components/item/ItemSeparator.astro +0 -21
- package/dist/src/components/item/ItemTitle.astro +0 -16
- package/dist/src/components/item/index.ts +0 -50
- package/dist/src/components/kbd/Kbd.astro +0 -21
- package/dist/src/components/kbd/KbdGroup.astro +0 -16
- package/dist/src/components/kbd/index.ts +0 -11
- package/dist/src/components/label/Label.astro +0 -22
- package/dist/src/components/label/index.ts +0 -7
- package/dist/src/components/pagination/Pagination.astro +0 -20
- package/dist/src/components/pagination/PaginationContent.astro +0 -16
- package/dist/src/components/pagination/PaginationEllipsis.astro +0 -25
- package/dist/src/components/pagination/PaginationItem.astro +0 -16
- package/dist/src/components/pagination/PaginationLink.astro +0 -24
- package/dist/src/components/pagination/PaginationNext.astro +0 -26
- package/dist/src/components/pagination/PaginationPrevious.astro +0 -26
- package/dist/src/components/pagination/index.ts +0 -38
- package/dist/src/components/progress/Progress.astro +0 -154
- package/dist/src/components/progress/index.ts +0 -10
- package/dist/src/components/radio-group/RadioGroup.astro +0 -157
- package/dist/src/components/radio-group/RadioGroupItem.astro +0 -129
- package/dist/src/components/radio-group/RadioGroupTypes.ts +0 -6
- package/dist/src/components/radio-group/index.ts +0 -23
- package/dist/src/components/select/Select.astro +0 -534
- package/dist/src/components/select/SelectContent.astro +0 -83
- package/dist/src/components/select/SelectGroup.astro +0 -9
- package/dist/src/components/select/SelectItem.astro +0 -49
- package/dist/src/components/select/SelectLabel.astro +0 -14
- package/dist/src/components/select/SelectSeparator.astro +0 -12
- package/dist/src/components/select/SelectTrigger.astro +0 -48
- package/dist/src/components/select/SelectTypes.ts +0 -13
- package/dist/src/components/select/SelectValue.astro +0 -19
- package/dist/src/components/select/index.ts +0 -45
- package/dist/src/components/separator/Separator.astro +0 -36
- package/dist/src/components/separator/index.ts +0 -7
- package/dist/src/components/sheet/Sheet.astro +0 -13
- package/dist/src/components/sheet/SheetClose.astro +0 -13
- package/dist/src/components/sheet/SheetContent.astro +0 -92
- package/dist/src/components/sheet/SheetDescription.astro +0 -16
- package/dist/src/components/sheet/SheetFooter.astro +0 -16
- package/dist/src/components/sheet/SheetHeader.astro +0 -16
- package/dist/src/components/sheet/SheetTitle.astro +0 -16
- package/dist/src/components/sheet/SheetTrigger.astro +0 -13
- package/dist/src/components/sheet/index.ts +0 -41
- package/dist/src/components/skeleton/Skeleton.astro +0 -14
- package/dist/src/components/skeleton/index.ts +0 -9
- package/dist/src/components/spinner/Spinner.astro +0 -21
- package/dist/src/components/spinner/index.ts +0 -7
- package/dist/src/components/switch/Switch.astro +0 -191
- package/dist/src/components/switch/SwitchTypes.ts +0 -6
- package/dist/src/components/switch/index.ts +0 -12
- package/dist/src/components/table/Table.astro +0 -18
- package/dist/src/components/table/TableBody.astro +0 -16
- package/dist/src/components/table/TableCaption.astro +0 -16
- package/dist/src/components/table/TableCell.astro +0 -16
- package/dist/src/components/table/TableFoot.astro +0 -16
- package/dist/src/components/table/TableHead.astro +0 -16
- package/dist/src/components/table/TableHeader.astro +0 -16
- package/dist/src/components/table/TableRow.astro +0 -16
- package/dist/src/components/table/index.ts +0 -42
- package/dist/src/components/tabs/Tabs.astro +0 -269
- package/dist/src/components/tabs/TabsContent.astro +0 -28
- package/dist/src/components/tabs/TabsList.astro +0 -22
- package/dist/src/components/tabs/TabsTrigger.astro +0 -34
- package/dist/src/components/tabs/index.ts +0 -20
- package/dist/src/components/textarea/Textarea.astro +0 -28
- package/dist/src/components/textarea/index.ts +0 -9
- package/dist/src/components/tooltip/Tooltip.astro +0 -237
- package/dist/src/components/tooltip/TooltipContent.astro +0 -114
- package/dist/src/components/tooltip/TooltipTrigger.astro +0 -10
- package/dist/src/components/tooltip/index.ts +0 -16
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { HTMLAttributes } from "astro/types";
|
|
3
|
-
import { tv } from "tailwind-variants";
|
|
4
|
-
|
|
5
|
-
type Props = HTMLAttributes<"div"> & {
|
|
6
|
-
/**
|
|
7
|
-
* Time in milliseconds to wait before showing the tooltip
|
|
8
|
-
*/
|
|
9
|
-
openDelay?: number;
|
|
10
|
-
/**
|
|
11
|
-
* Time in milliseconds to wait before hiding the tooltip
|
|
12
|
-
*/
|
|
13
|
-
closeDelay?: number;
|
|
14
|
-
/**
|
|
15
|
-
* When true, prevents the tooltip from staying open when hovering over its content
|
|
16
|
-
*/
|
|
17
|
-
disableHoverableContent?: boolean;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const tooltip = tv({ base: "starwind-tooltip relative inline-block" });
|
|
21
|
-
|
|
22
|
-
const {
|
|
23
|
-
openDelay = 200,
|
|
24
|
-
closeDelay = 200,
|
|
25
|
-
disableHoverableContent = false,
|
|
26
|
-
class: className,
|
|
27
|
-
} = Astro.props;
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
<div
|
|
31
|
-
class={tooltip({ class: className })}
|
|
32
|
-
data-slot="tooltip"
|
|
33
|
-
data-state="closed"
|
|
34
|
-
data-open-delay={openDelay}
|
|
35
|
-
data-close-delay={closeDelay}
|
|
36
|
-
{...!disableHoverableContent && { "data-content-hoverable": "" }}
|
|
37
|
-
>
|
|
38
|
-
<slot />
|
|
39
|
-
</div>
|
|
40
|
-
|
|
41
|
-
<script>
|
|
42
|
-
class TooltipHandler {
|
|
43
|
-
private tooltip: HTMLElement;
|
|
44
|
-
private trigger: HTMLElement | null;
|
|
45
|
-
private content: HTMLElement | null;
|
|
46
|
-
private openTimerRef: number | null = null;
|
|
47
|
-
private closeTimerRef: number | null = null;
|
|
48
|
-
private contentId: string;
|
|
49
|
-
private animationDuration = 150;
|
|
50
|
-
|
|
51
|
-
constructor(tooltip: HTMLElement, idx: number) {
|
|
52
|
-
this.contentId = `starwind-tooltip${idx}`;
|
|
53
|
-
this.tooltip = tooltip;
|
|
54
|
-
this.content = tooltip.querySelector(".starwind-tooltip-content");
|
|
55
|
-
|
|
56
|
-
// if tooltip.firstElementChild is this.content, then get the next element
|
|
57
|
-
this.trigger = tooltip.firstElementChild as HTMLElement;
|
|
58
|
-
if (this.trigger === this.content) {
|
|
59
|
-
this.trigger = this.trigger.nextElementSibling as HTMLElement;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
this.trigger.classList.add("starwind-tooltip-trigger");
|
|
63
|
-
|
|
64
|
-
if (!this.trigger || !this.content) return;
|
|
65
|
-
|
|
66
|
-
// animationDuration is set with inline styles through passed prop to TooltipContent
|
|
67
|
-
const animationDurationString = this.content.style.animationDuration;
|
|
68
|
-
if (animationDurationString.endsWith("ms")) {
|
|
69
|
-
this.animationDuration = parseFloat(animationDurationString);
|
|
70
|
-
} else if (animationDurationString.endsWith("s")) {
|
|
71
|
-
// using something like @playform/compress might optimize to use "s" instead of "ms"
|
|
72
|
-
this.animationDuration = parseFloat(animationDurationString) * 1000;
|
|
73
|
-
}
|
|
74
|
-
this.init();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
private init() {
|
|
78
|
-
this.setupAccessibility();
|
|
79
|
-
this.setupEvents();
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
private setupAccessibility() {
|
|
83
|
-
if (!this.trigger || !this.content) return;
|
|
84
|
-
this.trigger.setAttribute("aria-describedby", this.contentId);
|
|
85
|
-
this.content.id = this.contentId;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
private setupEvents() {
|
|
89
|
-
if (!this.trigger || !this.content) return;
|
|
90
|
-
|
|
91
|
-
// Trigger events
|
|
92
|
-
this.trigger.addEventListener("mouseenter", () => this.show());
|
|
93
|
-
this.trigger.addEventListener("mouseleave", () => this.hide());
|
|
94
|
-
this.trigger.addEventListener("focus", () => this.show(true));
|
|
95
|
-
this.trigger.addEventListener("blur", () => this.hide(true));
|
|
96
|
-
|
|
97
|
-
// Content events
|
|
98
|
-
if (this.tooltip.hasAttribute("data-content-hoverable")) {
|
|
99
|
-
this.content.addEventListener("mouseenter", () => this.show());
|
|
100
|
-
this.content.addEventListener("mouseleave", () => this.hide());
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// if data-avoid-collisions exists, add resize listener to reset any translations
|
|
104
|
-
if (this.content.hasAttribute("data-avoid-collisions")) {
|
|
105
|
-
window.addEventListener(
|
|
106
|
-
"resize",
|
|
107
|
-
() => {
|
|
108
|
-
if (!this.content) return;
|
|
109
|
-
this.content.style.transform = "";
|
|
110
|
-
},
|
|
111
|
-
{ passive: true },
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Document events
|
|
116
|
-
document.addEventListener("keydown", (e) => {
|
|
117
|
-
if (e.key === "Escape" && this.tooltip.getAttribute("data-state") === "open") {
|
|
118
|
-
this.hide(true);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
document.addEventListener("click", (e) => {
|
|
123
|
-
if (
|
|
124
|
-
!this.tooltip.contains(e.target as Node) &&
|
|
125
|
-
this.tooltip.getAttribute("data-state") === "open"
|
|
126
|
-
) {
|
|
127
|
-
this.hide(true);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
private show(immediate: boolean = false) {
|
|
133
|
-
if (!this.content || !this.trigger) return;
|
|
134
|
-
if (immediate) {
|
|
135
|
-
this.tooltip.setAttribute("data-state", "open");
|
|
136
|
-
this.content.setAttribute("data-state", "open");
|
|
137
|
-
this.content.style.display = "block";
|
|
138
|
-
this.checkBoundary(this.content);
|
|
139
|
-
this.clearOpenTimer();
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
this.clearCloseTimer();
|
|
144
|
-
|
|
145
|
-
const delay = parseInt(this.tooltip.getAttribute("data-open-delay") || "700");
|
|
146
|
-
this.openTimerRef = window.setTimeout(() => {
|
|
147
|
-
if (!this.content || !this.trigger) return;
|
|
148
|
-
this.tooltip.setAttribute("data-state", "open");
|
|
149
|
-
this.content.setAttribute("data-state", "open");
|
|
150
|
-
this.content.style.display = "block";
|
|
151
|
-
this.checkBoundary(this.content);
|
|
152
|
-
this.openTimerRef = null;
|
|
153
|
-
}, delay);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
private hide(immediate: boolean = false) {
|
|
157
|
-
if (!this.content || !this.trigger) return;
|
|
158
|
-
this.clearOpenTimer();
|
|
159
|
-
|
|
160
|
-
if (immediate) {
|
|
161
|
-
this.clearCloseTimer();
|
|
162
|
-
this.tooltip.setAttribute("data-state", "closed");
|
|
163
|
-
setTimeout(() => {
|
|
164
|
-
if (!this.content) return;
|
|
165
|
-
this.content.style.display = "none";
|
|
166
|
-
}, this.animationDuration);
|
|
167
|
-
this.content.setAttribute("data-state", "closed");
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
this.closeTimerRef = window.setTimeout(
|
|
172
|
-
() => {
|
|
173
|
-
this.tooltip.setAttribute("data-state", "closed");
|
|
174
|
-
setTimeout(() => {
|
|
175
|
-
if (!this.content) return;
|
|
176
|
-
this.content.style.display = "none";
|
|
177
|
-
}, this.animationDuration);
|
|
178
|
-
if (!this.content) return;
|
|
179
|
-
this.content.setAttribute("data-state", "closed");
|
|
180
|
-
this.closeTimerRef = null;
|
|
181
|
-
},
|
|
182
|
-
parseInt(this.tooltip.getAttribute("data-close-delay") || "300"),
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
private checkBoundary(tooltipElement: HTMLElement) {
|
|
187
|
-
if (!tooltipElement) return;
|
|
188
|
-
|
|
189
|
-
// if data-avoid-collisions does not exist, return
|
|
190
|
-
if (!tooltipElement.hasAttribute("data-avoid-collisions")) return;
|
|
191
|
-
|
|
192
|
-
const viewportWidth = window.innerWidth;
|
|
193
|
-
const tooltipRect = tooltipElement.getBoundingClientRect();
|
|
194
|
-
const padding = 16; // Add some padding from viewport edges
|
|
195
|
-
|
|
196
|
-
// Check if tooltip extends beyond right edge of viewport
|
|
197
|
-
if (tooltipRect.right > viewportWidth - padding) {
|
|
198
|
-
const overflow = tooltipRect.right - (viewportWidth - padding);
|
|
199
|
-
tooltipElement.style.transform = `translateX(-${overflow + padding}px)`;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// Check if tooltip extends beyond left edge of viewport
|
|
203
|
-
if (tooltipRect.left < padding) {
|
|
204
|
-
const overflow = padding - tooltipRect.left;
|
|
205
|
-
tooltipElement.style.transform = `translateX(${overflow + padding}px)`;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
private clearOpenTimer() {
|
|
210
|
-
if (this.openTimerRef) {
|
|
211
|
-
window.clearTimeout(this.openTimerRef);
|
|
212
|
-
this.openTimerRef = null;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
private clearCloseTimer() {
|
|
217
|
-
if (this.closeTimerRef) {
|
|
218
|
-
window.clearTimeout(this.closeTimerRef);
|
|
219
|
-
this.closeTimerRef = null;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// Store instances in a WeakMap to avoid memory leaks
|
|
225
|
-
const tooltipInstances = new WeakMap<HTMLElement, TooltipHandler>();
|
|
226
|
-
|
|
227
|
-
const setupTooltips = () => {
|
|
228
|
-
document.querySelectorAll<HTMLElement>(".starwind-tooltip").forEach((tooltip, idx) => {
|
|
229
|
-
if (!tooltipInstances.has(tooltip)) {
|
|
230
|
-
tooltipInstances.set(tooltip, new TooltipHandler(tooltip, idx));
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
setupTooltips();
|
|
236
|
-
document.addEventListener("astro:after-swap", setupTooltips);
|
|
237
|
-
</script>
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import CaretUp from "@tabler/icons/filled/caret-up.svg";
|
|
3
|
-
import type { HTMLAttributes } from "astro/types";
|
|
4
|
-
import { tv } from "tailwind-variants";
|
|
5
|
-
|
|
6
|
-
type Props = HTMLAttributes<"div"> & {
|
|
7
|
-
/**
|
|
8
|
-
* Side of the tooltip
|
|
9
|
-
* @default top
|
|
10
|
-
*/
|
|
11
|
-
side?: "top" | "right" | "bottom" | "left";
|
|
12
|
-
/**
|
|
13
|
-
* Alignment of the tooltip
|
|
14
|
-
* @default center
|
|
15
|
-
*/
|
|
16
|
-
align?: "start" | "center" | "end";
|
|
17
|
-
/**
|
|
18
|
-
* Offset distance in pixels
|
|
19
|
-
* @default 8
|
|
20
|
-
*/
|
|
21
|
-
sideOffset?: number;
|
|
22
|
-
/**
|
|
23
|
-
* Prevent the tooltip from colliding with other elements
|
|
24
|
-
* @default true
|
|
25
|
-
*/
|
|
26
|
-
avoidCollisions?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Open and close animation duration in milliseconds
|
|
29
|
-
* @default 150
|
|
30
|
-
*/
|
|
31
|
-
animationDuration?: number;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const tooltipContent = tv({
|
|
35
|
-
base: [
|
|
36
|
-
"starwind-tooltip-content",
|
|
37
|
-
"absolute z-50 hidden px-3 py-1.5 whitespace-nowrap shadow-xs will-change-transform",
|
|
38
|
-
"bg-foreground text-background rounded-md",
|
|
39
|
-
"animate-in fade-in zoom-in-95",
|
|
40
|
-
"data-[state=closed]:animate-out data-[state=closed]:fill-mode-forwards fade-out zoom-out-95",
|
|
41
|
-
],
|
|
42
|
-
variants: {
|
|
43
|
-
side: {
|
|
44
|
-
left: "slide-in-from-right-2 right-(--tooltip-offset)",
|
|
45
|
-
right: "slide-in-from-left-2 left-(--tooltip-offset)",
|
|
46
|
-
bottom: "slide-in-from-top-2 top-(--tooltip-offset)",
|
|
47
|
-
top: "slide-in-from-bottom-2 bottom-(--tooltip-offset)",
|
|
48
|
-
},
|
|
49
|
-
align: { center: "", start: "", end: "" },
|
|
50
|
-
sideAlign: {
|
|
51
|
-
"top-center": "left-[50%] translate-x-[-50%]",
|
|
52
|
-
"bottom-center": "left-[50%] translate-x-[-50%]",
|
|
53
|
-
"left-center": "top-[50%] translate-y-[-50%]",
|
|
54
|
-
"right-center": "top-[50%] translate-y-[-50%]",
|
|
55
|
-
"top-start": "left-0",
|
|
56
|
-
"bottom-start": "left-0",
|
|
57
|
-
"top-end": "right-0",
|
|
58
|
-
"bottom-end": "right-0",
|
|
59
|
-
"left-start": "top-0",
|
|
60
|
-
"right-start": "top-0",
|
|
61
|
-
"left-end": "bottom-0",
|
|
62
|
-
"right-end": "bottom-0",
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
defaultVariants: { side: "top", align: "center" },
|
|
66
|
-
compoundVariants: [
|
|
67
|
-
{ side: ["top", "bottom"], align: "center", class: "left-[50%] translate-x-[-50%]" },
|
|
68
|
-
{ side: ["left", "right"], align: "center", class: "top-[50%] translate-y-[-50%]" },
|
|
69
|
-
{ side: ["top", "bottom"], align: "start", class: "left-0" },
|
|
70
|
-
{ side: ["top", "bottom"], align: "end", class: "right-0" },
|
|
71
|
-
{ side: ["left", "right"], align: "start", class: "top-0" },
|
|
72
|
-
{ side: ["left", "right"], align: "end", class: "bottom-0" },
|
|
73
|
-
],
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
export const tooltipCaret = tv({
|
|
77
|
-
base: ["text-foreground absolute z-50 size-4"],
|
|
78
|
-
variants: {
|
|
79
|
-
side: {
|
|
80
|
-
top: "bottom-0 left-1/2 -translate-x-1/2 translate-y-[calc(50%+1px)] rotate-180",
|
|
81
|
-
bottom: "top-0 left-1/2 -translate-x-1/2 -translate-y-[calc(50%+1px)]",
|
|
82
|
-
left: "top-1/2 right-0 translate-x-[calc(50%+1px)] -translate-y-1/2 rotate-90",
|
|
83
|
-
right: "top-1/2 left-0 -translate-x-[calc(50%+1px)] -translate-y-1/2 -rotate-90",
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
defaultVariants: { side: "top" },
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
const {
|
|
90
|
-
side = "top",
|
|
91
|
-
align = "center",
|
|
92
|
-
sideOffset = 8,
|
|
93
|
-
avoidCollisions = true,
|
|
94
|
-
animationDuration = 150,
|
|
95
|
-
class: className,
|
|
96
|
-
} = Astro.props;
|
|
97
|
-
---
|
|
98
|
-
|
|
99
|
-
<div
|
|
100
|
-
class={tooltipContent({ side, align, class: className })}
|
|
101
|
-
data-slot="tooltip-content"
|
|
102
|
-
data-state="closed"
|
|
103
|
-
data-side={side}
|
|
104
|
-
data-align={align}
|
|
105
|
-
{...avoidCollisions && { "data-avoid-collisions": "" }}
|
|
106
|
-
role="tooltip"
|
|
107
|
-
style={{
|
|
108
|
-
"--tooltip-offset": `calc(100% + ${sideOffset}px)`,
|
|
109
|
-
animationDuration: `${animationDuration}ms`,
|
|
110
|
-
}}
|
|
111
|
-
>
|
|
112
|
-
<slot> My tooltip! </slot>
|
|
113
|
-
<CaretUp class={tooltipCaret({ side })} />
|
|
114
|
-
</div>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import Tooltip, { tooltip } from "./Tooltip.astro";
|
|
2
|
-
import TooltipContent, { tooltipContent } from "./TooltipContent.astro";
|
|
3
|
-
import TooltipTrigger from "./TooltipTrigger.astro";
|
|
4
|
-
|
|
5
|
-
const TooltipVariants = {
|
|
6
|
-
tooltip,
|
|
7
|
-
tooltipContent,
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export { Tooltip, TooltipContent, TooltipTrigger, TooltipVariants };
|
|
11
|
-
|
|
12
|
-
export default {
|
|
13
|
-
Root: Tooltip,
|
|
14
|
-
Trigger: TooltipTrigger,
|
|
15
|
-
Content: TooltipContent,
|
|
16
|
-
};
|