@starwind-ui/core 1.12.0 → 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.
Files changed (166) hide show
  1. package/package.json +1 -1
  2. package/dist/index.d.ts +0 -28
  3. package/dist/index.js +0 -81
  4. package/dist/index.js.map +0 -1
  5. package/dist/src/components/accordion/Accordion.astro +0 -247
  6. package/dist/src/components/accordion/AccordionContent.astro +0 -33
  7. package/dist/src/components/accordion/AccordionItem.astro +0 -27
  8. package/dist/src/components/accordion/AccordionTrigger.astro +0 -32
  9. package/dist/src/components/accordion/index.ts +0 -15
  10. package/dist/src/components/alert/Alert.astro +0 -31
  11. package/dist/src/components/alert/AlertDescription.astro +0 -14
  12. package/dist/src/components/alert/AlertTitle.astro +0 -16
  13. package/dist/src/components/alert/index.ts +0 -13
  14. package/dist/src/components/alert-dialog/AlertDialog.astro +0 -273
  15. package/dist/src/components/alert-dialog/AlertDialogAction.astro +0 -44
  16. package/dist/src/components/alert-dialog/AlertDialogCancel.astro +0 -45
  17. package/dist/src/components/alert-dialog/AlertDialogContent.astro +0 -52
  18. package/dist/src/components/alert-dialog/AlertDialogDescription.astro +0 -18
  19. package/dist/src/components/alert-dialog/AlertDialogFooter.astro +0 -16
  20. package/dist/src/components/alert-dialog/AlertDialogHeader.astro +0 -14
  21. package/dist/src/components/alert-dialog/AlertDialogTitle.astro +0 -20
  22. package/dist/src/components/alert-dialog/AlertDialogTrigger.astro +0 -47
  23. package/dist/src/components/alert-dialog/index.ts +0 -46
  24. package/dist/src/components/aspect-ratio/AspectRatio.astro +0 -32
  25. package/dist/src/components/aspect-ratio/index.ts +0 -7
  26. package/dist/src/components/avatar/Avatar.astro +0 -29
  27. package/dist/src/components/avatar/AvatarFallback.astro +0 -18
  28. package/dist/src/components/avatar/AvatarImage.astro +0 -49
  29. package/dist/src/components/avatar/index.ts +0 -13
  30. package/dist/src/components/badge/Badge.astro +0 -51
  31. package/dist/src/components/badge/index.ts +0 -7
  32. package/dist/src/components/breadcrumb/Breadcrumb.astro +0 -11
  33. package/dist/src/components/breadcrumb/BreadcrumbEllipsis.astro +0 -28
  34. package/dist/src/components/breadcrumb/BreadcrumbItem.astro +0 -14
  35. package/dist/src/components/breadcrumb/BreadcrumbLink.astro +0 -22
  36. package/dist/src/components/breadcrumb/BreadcrumbList.astro +0 -16
  37. package/dist/src/components/breadcrumb/BreadcrumbPage.astro +0 -21
  38. package/dist/src/components/breadcrumb/BreadcrumbSeparator.astro +0 -23
  39. package/dist/src/components/breadcrumb/index.ts +0 -37
  40. package/dist/src/components/button/Button.astro +0 -53
  41. package/dist/src/components/button/index.ts +0 -7
  42. package/dist/src/components/button-group/ButtonGroup.astro +0 -62
  43. package/dist/src/components/button-group/ButtonGroupSeparator.astro +0 -27
  44. package/dist/src/components/button-group/ButtonGroupText.astro +0 -19
  45. package/dist/src/components/button-group/index.ts +0 -17
  46. package/dist/src/components/card/Card.astro +0 -14
  47. package/dist/src/components/card/CardContent.astro +0 -14
  48. package/dist/src/components/card/CardDescription.astro +0 -14
  49. package/dist/src/components/card/CardFooter.astro +0 -14
  50. package/dist/src/components/card/CardHeader.astro +0 -14
  51. package/dist/src/components/card/CardTitle.astro +0 -14
  52. package/dist/src/components/card/index.ts +0 -26
  53. package/dist/src/components/carousel/Carousel.astro +0 -55
  54. package/dist/src/components/carousel/CarouselContent.astro +0 -26
  55. package/dist/src/components/carousel/CarouselItem.astro +0 -26
  56. package/dist/src/components/carousel/CarouselNext.astro +0 -37
  57. package/dist/src/components/carousel/CarouselPrevious.astro +0 -37
  58. package/dist/src/components/carousel/carousel-script.ts +0 -191
  59. package/dist/src/components/carousel/index.ts +0 -32
  60. package/dist/src/components/checkbox/Checkbox.astro +0 -127
  61. package/dist/src/components/checkbox/index.ts +0 -7
  62. package/dist/src/components/dialog/Dialog.astro +0 -263
  63. package/dist/src/components/dialog/DialogClose.astro +0 -35
  64. package/dist/src/components/dialog/DialogContent.astro +0 -67
  65. package/dist/src/components/dialog/DialogDescription.astro +0 -14
  66. package/dist/src/components/dialog/DialogFooter.astro +0 -14
  67. package/dist/src/components/dialog/DialogHeader.astro +0 -14
  68. package/dist/src/components/dialog/DialogTitle.astro +0 -20
  69. package/dist/src/components/dialog/DialogTrigger.astro +0 -47
  70. package/dist/src/components/dialog/index.ts +0 -45
  71. package/dist/src/components/dropdown/Dropdown.astro +0 -375
  72. package/dist/src/components/dropdown/DropdownContent.astro +0 -81
  73. package/dist/src/components/dropdown/DropdownItem.astro +0 -48
  74. package/dist/src/components/dropdown/DropdownLabel.astro +0 -29
  75. package/dist/src/components/dropdown/DropdownSeparator.astro +0 -21
  76. package/dist/src/components/dropdown/DropdownTrigger.astro +0 -52
  77. package/dist/src/components/dropdown/index.ts +0 -33
  78. package/dist/src/components/dropzone/Dropzone.astro +0 -233
  79. package/dist/src/components/dropzone/DropzoneFilesList.astro +0 -26
  80. package/dist/src/components/dropzone/DropzoneLoadingIndicator.astro +0 -10
  81. package/dist/src/components/dropzone/DropzoneUploadIndicator.astro +0 -10
  82. package/dist/src/components/dropzone/index.ts +0 -24
  83. package/dist/src/components/input/Input.astro +0 -24
  84. package/dist/src/components/input/index.ts +0 -7
  85. package/dist/src/components/item/Item.astro +0 -52
  86. package/dist/src/components/item/ItemActions.astro +0 -16
  87. package/dist/src/components/item/ItemContent.astro +0 -16
  88. package/dist/src/components/item/ItemDescription.astro +0 -19
  89. package/dist/src/components/item/ItemFooter.astro +0 -16
  90. package/dist/src/components/item/ItemGroup.astro +0 -16
  91. package/dist/src/components/item/ItemHeader.astro +0 -16
  92. package/dist/src/components/item/ItemMedia.astro +0 -40
  93. package/dist/src/components/item/ItemSeparator.astro +0 -21
  94. package/dist/src/components/item/ItemTitle.astro +0 -16
  95. package/dist/src/components/item/index.ts +0 -50
  96. package/dist/src/components/kbd/Kbd.astro +0 -21
  97. package/dist/src/components/kbd/KbdGroup.astro +0 -16
  98. package/dist/src/components/kbd/index.ts +0 -11
  99. package/dist/src/components/label/Label.astro +0 -22
  100. package/dist/src/components/label/index.ts +0 -7
  101. package/dist/src/components/pagination/Pagination.astro +0 -20
  102. package/dist/src/components/pagination/PaginationContent.astro +0 -16
  103. package/dist/src/components/pagination/PaginationEllipsis.astro +0 -35
  104. package/dist/src/components/pagination/PaginationItem.astro +0 -16
  105. package/dist/src/components/pagination/PaginationLink.astro +0 -24
  106. package/dist/src/components/pagination/PaginationNext.astro +0 -30
  107. package/dist/src/components/pagination/PaginationPrevious.astro +0 -30
  108. package/dist/src/components/pagination/index.ts +0 -38
  109. package/dist/src/components/progress/Progress.astro +0 -154
  110. package/dist/src/components/progress/index.ts +0 -10
  111. package/dist/src/components/radio-group/RadioGroup.astro +0 -157
  112. package/dist/src/components/radio-group/RadioGroupItem.astro +0 -129
  113. package/dist/src/components/radio-group/RadioGroupTypes.ts +0 -6
  114. package/dist/src/components/radio-group/index.ts +0 -23
  115. package/dist/src/components/select/Select.astro +0 -696
  116. package/dist/src/components/select/SelectContent.astro +0 -94
  117. package/dist/src/components/select/SelectGroup.astro +0 -9
  118. package/dist/src/components/select/SelectItem.astro +0 -51
  119. package/dist/src/components/select/SelectLabel.astro +0 -14
  120. package/dist/src/components/select/SelectSearch.astro +0 -49
  121. package/dist/src/components/select/SelectSeparator.astro +0 -12
  122. package/dist/src/components/select/SelectTrigger.astro +0 -58
  123. package/dist/src/components/select/SelectTypes.ts +0 -13
  124. package/dist/src/components/select/SelectValue.astro +0 -19
  125. package/dist/src/components/select/index.ts +0 -49
  126. package/dist/src/components/separator/Separator.astro +0 -36
  127. package/dist/src/components/separator/index.ts +0 -7
  128. package/dist/src/components/sheet/Sheet.astro +0 -13
  129. package/dist/src/components/sheet/SheetClose.astro +0 -13
  130. package/dist/src/components/sheet/SheetContent.astro +0 -92
  131. package/dist/src/components/sheet/SheetDescription.astro +0 -16
  132. package/dist/src/components/sheet/SheetFooter.astro +0 -16
  133. package/dist/src/components/sheet/SheetHeader.astro +0 -16
  134. package/dist/src/components/sheet/SheetTitle.astro +0 -16
  135. package/dist/src/components/sheet/SheetTrigger.astro +0 -13
  136. package/dist/src/components/sheet/index.ts +0 -41
  137. package/dist/src/components/skeleton/Skeleton.astro +0 -14
  138. package/dist/src/components/skeleton/index.ts +0 -9
  139. package/dist/src/components/spinner/Spinner.astro +0 -21
  140. package/dist/src/components/spinner/index.ts +0 -7
  141. package/dist/src/components/switch/Switch.astro +0 -191
  142. package/dist/src/components/switch/SwitchTypes.ts +0 -6
  143. package/dist/src/components/switch/index.ts +0 -12
  144. package/dist/src/components/table/Table.astro +0 -18
  145. package/dist/src/components/table/TableBody.astro +0 -16
  146. package/dist/src/components/table/TableCaption.astro +0 -16
  147. package/dist/src/components/table/TableCell.astro +0 -16
  148. package/dist/src/components/table/TableFoot.astro +0 -16
  149. package/dist/src/components/table/TableHead.astro +0 -16
  150. package/dist/src/components/table/TableHeader.astro +0 -16
  151. package/dist/src/components/table/TableRow.astro +0 -16
  152. package/dist/src/components/table/index.ts +0 -42
  153. package/dist/src/components/tabs/Tabs.astro +0 -269
  154. package/dist/src/components/tabs/TabsContent.astro +0 -28
  155. package/dist/src/components/tabs/TabsList.astro +0 -22
  156. package/dist/src/components/tabs/TabsTrigger.astro +0 -34
  157. package/dist/src/components/tabs/index.ts +0 -20
  158. package/dist/src/components/textarea/Textarea.astro +0 -28
  159. package/dist/src/components/textarea/index.ts +0 -9
  160. package/dist/src/components/toggle/Toggle.astro +0 -172
  161. package/dist/src/components/toggle/ToggleTypes.ts +0 -14
  162. package/dist/src/components/toggle/index.ts +0 -8
  163. package/dist/src/components/tooltip/Tooltip.astro +0 -237
  164. package/dist/src/components/tooltip/TooltipContent.astro +0 -114
  165. package/dist/src/components/tooltip/TooltipTrigger.astro +0 -10
  166. package/dist/src/components/tooltip/index.ts +0 -16
@@ -1,263 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
-
4
- type Props = HTMLAttributes<"div">;
5
-
6
- const { class: className, ...rest } = Astro.props;
7
- ---
8
-
9
- <div class:list={["starwind-dialog", className]} data-slot="dialog" {...rest}>
10
- <slot />
11
- </div>
12
-
13
- <script>
14
- class DialogHandler {
15
- private triggers: HTMLButtonElement[] = [];
16
- private dialog: HTMLDialogElement | null = null;
17
- private closeButtons: HTMLButtonElement[] = [];
18
- private backdrop: HTMLElement | null = null;
19
- private dialogId: string;
20
- /**
21
- * The duration of the animation in milliseconds. This is used to calculate the
22
- * duration of close animation before hiding the dialog and backdrop
23
- */
24
- private animationDuration: number;
25
-
26
- constructor(dialogWrapper: HTMLElement, dialogNumber: number) {
27
- this.dialog = dialogWrapper.querySelector("dialog");
28
- this.backdrop = dialogWrapper.querySelector(".starwind-dialog-backdrop");
29
- if (!this.dialog || !this.backdrop) {
30
- throw new Error("Dialog: dialog or backdrop not found");
31
- }
32
-
33
- // if no ID was provided for the wrapper, generate one
34
- if (dialogWrapper.id) {
35
- this.dialogId = dialogWrapper.id;
36
- } else {
37
- this.dialogId = `starwind-dialog${dialogNumber}`;
38
- dialogWrapper.id = this.dialogId;
39
- }
40
-
41
- // animationDuration is set with inline styles through passed prop to DialogContent
42
- // if no animationDuration, check data-close-duration
43
- const animationDurationString = this.dialog.style.animationDuration;
44
- if (animationDurationString.endsWith("ms")) {
45
- this.animationDuration = parseFloat(animationDurationString);
46
- } else if (animationDurationString.endsWith("s")) {
47
- // using something like @playform/compress might optimize to use "s" instead of "ms"
48
- this.animationDuration = parseFloat(animationDurationString) * 1000;
49
- } else {
50
- this.animationDuration = this.dialog.dataset.closeDuration
51
- ? parseFloat(this.dialog.dataset.closeDuration)
52
- : 200;
53
- }
54
-
55
- // Find internal triggers and handle them
56
- const internalTriggers = dialogWrapper.querySelectorAll(".starwind-dialog-trigger");
57
- internalTriggers.forEach((triggerElement) => {
58
- const tempTrigger = triggerElement as HTMLElement;
59
- let trigger: HTMLButtonElement;
60
-
61
- if (tempTrigger?.hasAttribute("data-as-child")) {
62
- trigger = tempTrigger.firstElementChild as HTMLButtonElement;
63
- } else {
64
- trigger = tempTrigger as HTMLButtonElement;
65
- }
66
-
67
- if (trigger) {
68
- this.triggers.push(trigger);
69
- }
70
- });
71
-
72
- // Find external triggers that target this dialog
73
- this.findExternalTriggers();
74
-
75
- // if closeButtons are set with asChild, swap the wrapper with its first child
76
- const tempCloseButtons = dialogWrapper.querySelectorAll(
77
- ".starwind-dialog-close",
78
- ) as NodeListOf<HTMLElement>;
79
- tempCloseButtons.forEach((button: HTMLElement) => {
80
- if (button.hasAttribute("data-as-child")) {
81
- const childElement = button.firstElementChild;
82
- if (childElement) {
83
- childElement.classList.add("starwind-dialog-close");
84
- button.parentNode?.replaceChild(childElement, button);
85
- }
86
- }
87
- return button;
88
- });
89
-
90
- // Convert NodeList to Array for consistency with triggers
91
- this.closeButtons = Array.from(
92
- dialogWrapper.querySelectorAll(".starwind-dialog-close"),
93
- ) as HTMLButtonElement[];
94
-
95
- // if essential elements are not there, exit
96
- if (!this.dialog || !this.backdrop) return;
97
-
98
- this.setupAccessibility(dialogNumber);
99
- this.setupEvents();
100
- }
101
-
102
- private setupAccessibility(dialogNumber: number): void {
103
- // get the first heading element in the dialog
104
- const firstHeading = this.dialog?.querySelector("h1, h2, h3, h4, h5, h6");
105
- if (firstHeading) {
106
- // create a unique ID for the heading
107
- firstHeading.id = `starwind-dialog${dialogNumber}-heading`;
108
- // set the aria-labelledby attribute to the first heading element
109
- this.dialog?.setAttribute("aria-labelledby", firstHeading.id);
110
- }
111
- }
112
-
113
- /**
114
- * Find all external triggers that target this dialog
115
- */
116
- private findExternalTriggers(): void {
117
- const externalTriggers = document.querySelectorAll(
118
- `.starwind-dialog-trigger[data-dialog-for="${this.dialogId}"]`,
119
- );
120
-
121
- externalTriggers.forEach((triggerElement) => {
122
- // Skip if this is an internal trigger we already processed
123
- const dialogWrapper = triggerElement.closest(".starwind-dialog");
124
- if (dialogWrapper && dialogWrapper.id === this.dialogId) {
125
- return;
126
- }
127
-
128
- let trigger: HTMLButtonElement;
129
- if (triggerElement.hasAttribute("data-as-child")) {
130
- trigger = triggerElement.firstElementChild as HTMLButtonElement;
131
- } else {
132
- trigger = triggerElement as HTMLButtonElement;
133
- }
134
-
135
- if (trigger && !this.triggers.includes(trigger)) {
136
- this.triggers.push(trigger);
137
- }
138
- });
139
- }
140
-
141
- private setupEvents(): void {
142
- if (!this.dialog) return;
143
- // Add click listeners to all triggers
144
- this.triggers.forEach((trigger) => {
145
- trigger.addEventListener("click", () => {
146
- this.open();
147
- });
148
- });
149
-
150
- // Add click handlers to all close buttons
151
- this.closeButtons?.forEach((button) => {
152
- button.addEventListener("click", () => {
153
- // Only close if this is the topmost dialog
154
- const openDialogs = document.querySelectorAll("dialog[open]");
155
- if (openDialogs.length > 0 && openDialogs[openDialogs.length - 1] === this.dialog) {
156
- this.close();
157
- }
158
- });
159
- });
160
-
161
- // Close on click outside
162
- this.dialog.addEventListener("click", (e) => {
163
- if (!this.dialog) return;
164
- const dialogDimensions = this.dialog.getBoundingClientRect();
165
- const clickedInDialog =
166
- e.clientX >= dialogDimensions.left &&
167
- e.clientX <= dialogDimensions.right &&
168
- e.clientY >= dialogDimensions.top &&
169
- e.clientY <= dialogDimensions.bottom;
170
-
171
- if (!clickedInDialog) {
172
- // Only close if this is the topmost dialog
173
- const openDialogs = document.querySelectorAll("dialog[open]");
174
- if (openDialogs.length > 0 && openDialogs[openDialogs.length - 1] === this.dialog) {
175
- this.close();
176
- }
177
- }
178
- });
179
-
180
- // Handle escape key
181
- this.dialog.addEventListener("keydown", (e) => {
182
- if (e.key === "Escape") {
183
- // prevent default dialog closing behavior so we can add closing animation
184
- e.preventDefault();
185
- // Only close if this is the topmost dialog
186
- const openDialogs = document.querySelectorAll("dialog[open]");
187
- if (openDialogs.length > 0 && openDialogs[openDialogs.length - 1] === this.dialog) {
188
- this.close();
189
- }
190
- }
191
- });
192
-
193
- // Intercept form submissions to handle dialog close
194
- const forms = this.dialog.querySelectorAll("form");
195
- forms.forEach((form) => {
196
- form.addEventListener("submit", (e) => {
197
- /**
198
- * Default form.method = "dialog" submissions cause the dialog to close
199
- * Default form.method = "post" submissions do not close the dialog
200
- * Here we intercept the form submission and manage the dialog closing if method = "dialog"
201
- * so we can add closing animation
202
- * Normal form event listeners for "submit" will still get the form data
203
- */
204
- if (form.method === "dialog") {
205
- e.preventDefault();
206
- // Only close if this is the topmost dialog
207
- const openDialogs = document.querySelectorAll("dialog[open]");
208
- if (openDialogs.length > 0 && openDialogs[openDialogs.length - 1] === this.dialog) {
209
- this.close();
210
- }
211
- }
212
- });
213
- });
214
- }
215
-
216
- private open(): void {
217
- if (!this.dialog || !this.backdrop) return;
218
- this.dialog.showModal();
219
- document.body.classList.add("overflow-hidden");
220
- this.backdrop.classList.remove("hidden");
221
- this.backdrop.dataset.state = "open";
222
- this.dialog.dataset.state = "open";
223
- }
224
-
225
- private close(): void {
226
- if (!this.dialog || !this.backdrop) return;
227
- this.dialog.dataset.state = "closed";
228
- this.backdrop.dataset.state = "closed";
229
-
230
- // Wait for animation to finish before hiding backdrop
231
- setTimeout(() => {
232
- this.backdrop?.classList.add("hidden");
233
- this.dialog?.close();
234
- const stillOpen = document.querySelectorAll("dialog[open]").length;
235
- if (stillOpen === 0) {
236
- document.body.classList.remove("overflow-hidden");
237
- }
238
- }, this.animationDuration);
239
- }
240
- }
241
-
242
- // Store instances in a WeakMap to avoid memory leaks
243
- const dialogInstances = new WeakMap<HTMLElement, DialogHandler>();
244
-
245
- // Initialize all dialogs
246
- const setupDialogs = () => {
247
- document.querySelectorAll(".starwind-dialog").forEach((dialogWrapper, idx) => {
248
- const wrapper = dialogWrapper as HTMLElement;
249
- if (!dialogInstances.has(wrapper)) {
250
- dialogInstances.set(wrapper, new DialogHandler(wrapper, idx));
251
- }
252
- });
253
- };
254
-
255
- setupDialogs();
256
- document.addEventListener("astro:after-swap", setupDialogs);
257
- </script>
258
-
259
- <style>
260
- .overflow-hidden {
261
- overflow: hidden;
262
- }
263
- </style>
@@ -1,35 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
-
4
- type Props = HTMLAttributes<"button"> & {
5
- /**
6
- * When true, the component will render its child element instead of a button
7
- */
8
- asChild?: boolean;
9
- };
10
-
11
- const { class: className, asChild = false, ...rest } = Astro.props;
12
-
13
- // Get the first child element if asChild is true
14
- let hasChildren = false;
15
- if (Astro.slots.has("default")) {
16
- hasChildren = true;
17
- }
18
- ---
19
-
20
- {
21
- asChild && hasChildren ? (
22
- <div class="starwind-dialog-close" data-slot="dialog-close" data-as-child>
23
- <slot />
24
- </div>
25
- ) : (
26
- <button
27
- type="button"
28
- class:list={["starwind-dialog-close", className]}
29
- data-slot="dialog-close"
30
- {...rest}
31
- >
32
- <slot>Demo close button</slot>
33
- </button>
34
- )
35
- }
@@ -1,67 +0,0 @@
1
- ---
2
- import X from "@tabler/icons/outline/x.svg";
3
- import type { HTMLAttributes } from "astro/types";
4
- import { tv } from "tailwind-variants";
5
-
6
- type Props = HTMLAttributes<"dialog"> & {
7
- /**
8
- * Open and close animation duration in milliseconds
9
- */
10
- animationDuration?: number;
11
- };
12
-
13
- export const dialogBackdrop = tv({
14
- base: [
15
- "starwind-dialog-backdrop fixed inset-0 top-0 left-0 z-50 hidden h-screen w-screen bg-black/80",
16
- "data-[state=open]:animate-in fade-in",
17
- "data-[state=closed]:animate-out data-[state=closed]:fill-mode-forwards fade-out",
18
- ],
19
- });
20
-
21
- export const dialogContent = tv({
22
- base: [
23
- "fixed top-16 left-[50%] z-50 translate-x-[-50%] sm:top-[50%] sm:translate-y-[-50%]",
24
- "bg-background w-full max-w-md border p-8 shadow-lg sm:rounded-lg",
25
- "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fill-mode-forwards",
26
- "fade-in zoom-in-95 slide-in-from-bottom-2",
27
- "fade-out zoom-out-95 slide-out-to-bottom-2",
28
- ],
29
- });
30
-
31
- export const dialogCloseButton = tv({
32
- base: [
33
- "starwind-dialog-close text-muted-foreground",
34
- "absolute top-5.5 right-5.5 rounded-sm [&>svg]:opacity-70 hover:[&>svg]:opacity-100",
35
- "focus-visible:ring-outline/50 transition-[color,box-shadow] outline-none focus-visible:ring-3",
36
- ],
37
- });
38
-
39
- const { class: className, animationDuration = 200, ...rest } = Astro.props;
40
- ---
41
-
42
- <!-- dialog overlay -->
43
- <slot name="backdrop">
44
- <div
45
- class={dialogBackdrop()}
46
- data-state="closed"
47
- data-slot="dialog-backdrop"
48
- style={{ animationDuration: `${animationDuration}ms` }}
49
- >
50
- </div>
51
- </slot>
52
-
53
- <dialog
54
- class={dialogContent({ class: className })}
55
- data-state="closed"
56
- data-slot="dialog-content"
57
- {...rest}
58
- style={{ animationDuration: `${animationDuration}ms` }}
59
- >
60
- <slot />
61
- <button type="button" class={dialogCloseButton()} data-dialog-close aria-label="Close dialog">
62
- <slot name="icon">
63
- <X class="size-5 transition-opacity" />
64
- </slot>
65
- <span class="sr-only">Close</span>
66
- </button>
67
- </dialog>
@@ -1,14 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { tv } from "tailwind-variants";
4
-
5
- type Props = HTMLAttributes<"p">;
6
-
7
- export const dialogDescription = tv({ base: "text-muted-foreground" });
8
-
9
- const { class: className, ...rest } = Astro.props;
10
- ---
11
-
12
- <p class={dialogDescription({ class: className })} data-slot="dialog-description" {...rest}>
13
- <slot />
14
- </p>
@@ -1,14 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { tv } from "tailwind-variants";
4
-
5
- type Props = HTMLAttributes<"div">;
6
-
7
- export const dialogFooter = tv({ base: "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end" });
8
-
9
- const { class: className, ...rest } = Astro.props;
10
- ---
11
-
12
- <div class={dialogFooter({ class: className })} data-slot="dialog-footer" {...rest}>
13
- <slot />
14
- </div>
@@ -1,14 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { tv } from "tailwind-variants";
4
-
5
- type Props = HTMLAttributes<"div">;
6
-
7
- export const dialogHeader = tv({ base: "flex flex-col space-y-2 text-center sm:text-left" });
8
-
9
- const { class: className, ...rest } = Astro.props;
10
- ---
11
-
12
- <div class={dialogHeader({ class: className })} data-slot="dialog-header" {...rest}>
13
- <slot />
14
- </div>
@@ -1,20 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { tv } from "tailwind-variants";
4
-
5
- type Props = Omit<HTMLAttributes<"h2">, "id"> & {
6
- /**
7
- * The content to be rendered inside the dialog title
8
- */
9
-
10
- children: any;
11
- };
12
-
13
- export const dialogTitle = tv({ base: "text-xl leading-none font-semibold tracking-tight" });
14
-
15
- const { class: className, ...rest } = Astro.props;
16
- ---
17
-
18
- <h2 class={dialogTitle({ class: className })} data-slot="dialog-title" {...rest}>
19
- <slot />
20
- </h2>
@@ -1,47 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
-
4
- type Props = HTMLAttributes<"button"> & {
5
- /**
6
- * When true, the component will render its child element with a simple wrapper instead of a button component
7
- */
8
- asChild?: boolean;
9
- /**
10
- * Optional ID of the dialog to trigger. If not provided and the trigger is inside a Dialog component,
11
- * it will automatically target that dialog. Required when used outside a Dialog component.
12
- */
13
- for?: string;
14
- };
15
-
16
- const { class: className, asChild = false, for: dialogFor, ...rest } = Astro.props;
17
-
18
- // Get the first child element if asChild is true
19
- let hasChildren = false;
20
- if (Astro.slots.has("default")) {
21
- hasChildren = true;
22
- }
23
- ---
24
-
25
- {
26
- asChild && hasChildren ? (
27
- <div
28
- class:list={["starwind-dialog-trigger", className]}
29
- data-slot="dialog-trigger"
30
- data-as-child
31
- data-dialog-for={dialogFor}
32
- >
33
- <slot />
34
- </div>
35
- ) : (
36
- <button
37
- type="button"
38
- aria-haspopup="dialog"
39
- class:list={["starwind-dialog-trigger", className]}
40
- data-slot="dialog-trigger"
41
- data-dialog-for={dialogFor}
42
- {...rest}
43
- >
44
- <slot />
45
- </button>
46
- )
47
- }
@@ -1,45 +0,0 @@
1
- import Dialog from "./Dialog.astro";
2
- import DialogClose from "./DialogClose.astro";
3
- import DialogContent, {
4
- dialogBackdrop,
5
- dialogCloseButton,
6
- dialogContent,
7
- } from "./DialogContent.astro";
8
- import DialogDescription, { dialogDescription } from "./DialogDescription.astro";
9
- import DialogFooter, { dialogFooter } from "./DialogFooter.astro";
10
- import DialogHeader, { dialogHeader } from "./DialogHeader.astro";
11
- import DialogTitle, { dialogTitle } from "./DialogTitle.astro";
12
- import DialogTrigger from "./DialogTrigger.astro";
13
-
14
- const DialogVariants = {
15
- dialogBackdrop,
16
- dialogContent,
17
- dialogCloseButton,
18
- dialogDescription,
19
- dialogFooter,
20
- dialogHeader,
21
- dialogTitle,
22
- };
23
-
24
- export {
25
- Dialog,
26
- DialogClose,
27
- DialogContent,
28
- DialogDescription,
29
- DialogFooter,
30
- DialogHeader,
31
- DialogTitle,
32
- DialogTrigger,
33
- DialogVariants,
34
- };
35
-
36
- export default {
37
- Root: Dialog,
38
- Trigger: DialogTrigger,
39
- Content: DialogContent,
40
- Header: DialogHeader,
41
- Footer: DialogFooter,
42
- Title: DialogTitle,
43
- Description: DialogDescription,
44
- Close: DialogClose,
45
- };