@starwind-ui/core 1.12.1 → 1.12.2-next.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 (166) hide show
  1. package/dist/index.d.ts +28 -0
  2. package/dist/index.js +81 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/src/components/accordion/Accordion.astro +247 -0
  5. package/dist/src/components/accordion/AccordionContent.astro +33 -0
  6. package/dist/src/components/accordion/AccordionItem.astro +27 -0
  7. package/dist/src/components/accordion/AccordionTrigger.astro +32 -0
  8. package/dist/src/components/accordion/index.ts +15 -0
  9. package/dist/src/components/alert/Alert.astro +31 -0
  10. package/dist/src/components/alert/AlertDescription.astro +14 -0
  11. package/dist/src/components/alert/AlertTitle.astro +16 -0
  12. package/dist/src/components/alert/index.ts +13 -0
  13. package/dist/src/components/alert-dialog/AlertDialog.astro +273 -0
  14. package/dist/src/components/alert-dialog/AlertDialogAction.astro +44 -0
  15. package/dist/src/components/alert-dialog/AlertDialogCancel.astro +45 -0
  16. package/dist/src/components/alert-dialog/AlertDialogContent.astro +52 -0
  17. package/dist/src/components/alert-dialog/AlertDialogDescription.astro +18 -0
  18. package/dist/src/components/alert-dialog/AlertDialogFooter.astro +16 -0
  19. package/dist/src/components/alert-dialog/AlertDialogHeader.astro +14 -0
  20. package/dist/src/components/alert-dialog/AlertDialogTitle.astro +20 -0
  21. package/dist/src/components/alert-dialog/AlertDialogTrigger.astro +47 -0
  22. package/dist/src/components/alert-dialog/index.ts +46 -0
  23. package/dist/src/components/aspect-ratio/AspectRatio.astro +32 -0
  24. package/dist/src/components/aspect-ratio/index.ts +7 -0
  25. package/dist/src/components/avatar/Avatar.astro +29 -0
  26. package/dist/src/components/avatar/AvatarFallback.astro +18 -0
  27. package/dist/src/components/avatar/AvatarImage.astro +49 -0
  28. package/dist/src/components/avatar/index.ts +13 -0
  29. package/dist/src/components/badge/Badge.astro +51 -0
  30. package/dist/src/components/badge/index.ts +7 -0
  31. package/dist/src/components/breadcrumb/Breadcrumb.astro +11 -0
  32. package/dist/src/components/breadcrumb/BreadcrumbEllipsis.astro +28 -0
  33. package/dist/src/components/breadcrumb/BreadcrumbItem.astro +14 -0
  34. package/dist/src/components/breadcrumb/BreadcrumbLink.astro +22 -0
  35. package/dist/src/components/breadcrumb/BreadcrumbList.astro +16 -0
  36. package/dist/src/components/breadcrumb/BreadcrumbPage.astro +21 -0
  37. package/dist/src/components/breadcrumb/BreadcrumbSeparator.astro +23 -0
  38. package/dist/src/components/breadcrumb/index.ts +37 -0
  39. package/dist/src/components/button/Button.astro +53 -0
  40. package/dist/src/components/button/index.ts +7 -0
  41. package/dist/src/components/button-group/ButtonGroup.astro +62 -0
  42. package/dist/src/components/button-group/ButtonGroupSeparator.astro +27 -0
  43. package/dist/src/components/button-group/ButtonGroupText.astro +19 -0
  44. package/dist/src/components/button-group/index.ts +17 -0
  45. package/dist/src/components/card/Card.astro +14 -0
  46. package/dist/src/components/card/CardContent.astro +14 -0
  47. package/dist/src/components/card/CardDescription.astro +14 -0
  48. package/dist/src/components/card/CardFooter.astro +14 -0
  49. package/dist/src/components/card/CardHeader.astro +14 -0
  50. package/dist/src/components/card/CardTitle.astro +14 -0
  51. package/dist/src/components/card/index.ts +26 -0
  52. package/dist/src/components/carousel/Carousel.astro +55 -0
  53. package/dist/src/components/carousel/CarouselContent.astro +26 -0
  54. package/dist/src/components/carousel/CarouselItem.astro +26 -0
  55. package/dist/src/components/carousel/CarouselNext.astro +37 -0
  56. package/dist/src/components/carousel/CarouselPrevious.astro +37 -0
  57. package/dist/src/components/carousel/carousel-script.ts +191 -0
  58. package/dist/src/components/carousel/index.ts +32 -0
  59. package/dist/src/components/checkbox/Checkbox.astro +128 -0
  60. package/dist/src/components/checkbox/index.ts +7 -0
  61. package/dist/src/components/dialog/Dialog.astro +263 -0
  62. package/dist/src/components/dialog/DialogClose.astro +35 -0
  63. package/dist/src/components/dialog/DialogContent.astro +67 -0
  64. package/dist/src/components/dialog/DialogDescription.astro +14 -0
  65. package/dist/src/components/dialog/DialogFooter.astro +14 -0
  66. package/dist/src/components/dialog/DialogHeader.astro +14 -0
  67. package/dist/src/components/dialog/DialogTitle.astro +20 -0
  68. package/dist/src/components/dialog/DialogTrigger.astro +47 -0
  69. package/dist/src/components/dialog/index.ts +45 -0
  70. package/dist/src/components/dropdown/Dropdown.astro +375 -0
  71. package/dist/src/components/dropdown/DropdownContent.astro +81 -0
  72. package/dist/src/components/dropdown/DropdownItem.astro +48 -0
  73. package/dist/src/components/dropdown/DropdownLabel.astro +29 -0
  74. package/dist/src/components/dropdown/DropdownSeparator.astro +21 -0
  75. package/dist/src/components/dropdown/DropdownTrigger.astro +52 -0
  76. package/dist/src/components/dropdown/index.ts +33 -0
  77. package/dist/src/components/dropzone/Dropzone.astro +234 -0
  78. package/dist/src/components/dropzone/DropzoneFilesList.astro +26 -0
  79. package/dist/src/components/dropzone/DropzoneLoadingIndicator.astro +10 -0
  80. package/dist/src/components/dropzone/DropzoneUploadIndicator.astro +10 -0
  81. package/dist/src/components/dropzone/index.ts +24 -0
  82. package/dist/src/components/input/Input.astro +25 -0
  83. package/dist/src/components/input/index.ts +7 -0
  84. package/dist/src/components/item/Item.astro +52 -0
  85. package/dist/src/components/item/ItemActions.astro +16 -0
  86. package/dist/src/components/item/ItemContent.astro +16 -0
  87. package/dist/src/components/item/ItemDescription.astro +19 -0
  88. package/dist/src/components/item/ItemFooter.astro +16 -0
  89. package/dist/src/components/item/ItemGroup.astro +16 -0
  90. package/dist/src/components/item/ItemHeader.astro +16 -0
  91. package/dist/src/components/item/ItemMedia.astro +40 -0
  92. package/dist/src/components/item/ItemSeparator.astro +21 -0
  93. package/dist/src/components/item/ItemTitle.astro +16 -0
  94. package/dist/src/components/item/index.ts +50 -0
  95. package/dist/src/components/kbd/Kbd.astro +21 -0
  96. package/dist/src/components/kbd/KbdGroup.astro +16 -0
  97. package/dist/src/components/kbd/index.ts +11 -0
  98. package/dist/src/components/label/Label.astro +22 -0
  99. package/dist/src/components/label/index.ts +7 -0
  100. package/dist/src/components/pagination/Pagination.astro +20 -0
  101. package/dist/src/components/pagination/PaginationContent.astro +16 -0
  102. package/dist/src/components/pagination/PaginationEllipsis.astro +35 -0
  103. package/dist/src/components/pagination/PaginationItem.astro +16 -0
  104. package/dist/src/components/pagination/PaginationLink.astro +24 -0
  105. package/dist/src/components/pagination/PaginationNext.astro +30 -0
  106. package/dist/src/components/pagination/PaginationPrevious.astro +30 -0
  107. package/dist/src/components/pagination/index.ts +38 -0
  108. package/dist/src/components/progress/Progress.astro +154 -0
  109. package/dist/src/components/progress/index.ts +10 -0
  110. package/dist/src/components/radio-group/RadioGroup.astro +157 -0
  111. package/dist/src/components/radio-group/RadioGroupItem.astro +129 -0
  112. package/dist/src/components/radio-group/RadioGroupTypes.ts +6 -0
  113. package/dist/src/components/radio-group/index.ts +23 -0
  114. package/dist/src/components/select/Select.astro +746 -0
  115. package/dist/src/components/select/SelectContent.astro +94 -0
  116. package/dist/src/components/select/SelectGroup.astro +9 -0
  117. package/dist/src/components/select/SelectItem.astro +51 -0
  118. package/dist/src/components/select/SelectLabel.astro +14 -0
  119. package/dist/src/components/select/SelectSearch.astro +49 -0
  120. package/dist/src/components/select/SelectSeparator.astro +12 -0
  121. package/dist/src/components/select/SelectTrigger.astro +54 -0
  122. package/dist/src/components/select/SelectTypes.ts +13 -0
  123. package/dist/src/components/select/SelectValue.astro +19 -0
  124. package/dist/src/components/select/index.ts +49 -0
  125. package/dist/src/components/separator/Separator.astro +36 -0
  126. package/dist/src/components/separator/index.ts +7 -0
  127. package/dist/src/components/sheet/Sheet.astro +13 -0
  128. package/dist/src/components/sheet/SheetClose.astro +13 -0
  129. package/dist/src/components/sheet/SheetContent.astro +92 -0
  130. package/dist/src/components/sheet/SheetDescription.astro +16 -0
  131. package/dist/src/components/sheet/SheetFooter.astro +16 -0
  132. package/dist/src/components/sheet/SheetHeader.astro +16 -0
  133. package/dist/src/components/sheet/SheetTitle.astro +16 -0
  134. package/dist/src/components/sheet/SheetTrigger.astro +13 -0
  135. package/dist/src/components/sheet/index.ts +41 -0
  136. package/dist/src/components/skeleton/Skeleton.astro +14 -0
  137. package/dist/src/components/skeleton/index.ts +9 -0
  138. package/dist/src/components/spinner/Spinner.astro +21 -0
  139. package/dist/src/components/spinner/index.ts +7 -0
  140. package/dist/src/components/switch/Switch.astro +191 -0
  141. package/dist/src/components/switch/SwitchTypes.ts +6 -0
  142. package/dist/src/components/switch/index.ts +12 -0
  143. package/dist/src/components/table/Table.astro +18 -0
  144. package/dist/src/components/table/TableBody.astro +16 -0
  145. package/dist/src/components/table/TableCaption.astro +16 -0
  146. package/dist/src/components/table/TableCell.astro +16 -0
  147. package/dist/src/components/table/TableFoot.astro +16 -0
  148. package/dist/src/components/table/TableHead.astro +16 -0
  149. package/dist/src/components/table/TableHeader.astro +16 -0
  150. package/dist/src/components/table/TableRow.astro +16 -0
  151. package/dist/src/components/table/index.ts +42 -0
  152. package/dist/src/components/tabs/Tabs.astro +269 -0
  153. package/dist/src/components/tabs/TabsContent.astro +28 -0
  154. package/dist/src/components/tabs/TabsList.astro +22 -0
  155. package/dist/src/components/tabs/TabsTrigger.astro +34 -0
  156. package/dist/src/components/tabs/index.ts +20 -0
  157. package/dist/src/components/textarea/Textarea.astro +29 -0
  158. package/dist/src/components/textarea/index.ts +9 -0
  159. package/dist/src/components/toggle/Toggle.astro +172 -0
  160. package/dist/src/components/toggle/ToggleTypes.ts +14 -0
  161. package/dist/src/components/toggle/index.ts +8 -0
  162. package/dist/src/components/tooltip/Tooltip.astro +237 -0
  163. package/dist/src/components/tooltip/TooltipContent.astro +114 -0
  164. package/dist/src/components/tooltip/TooltipTrigger.astro +10 -0
  165. package/dist/src/components/tooltip/index.ts +16 -0
  166. package/package.json +1 -1
@@ -0,0 +1,9 @@
1
+ import Skeleton, { skeleton } from "./Skeleton.astro";
2
+
3
+ const SkeletonVariants = {
4
+ skeleton,
5
+ };
6
+
7
+ export { Skeleton, SkeletonVariants };
8
+
9
+ export default Skeleton;
@@ -0,0 +1,21 @@
1
+ ---
2
+ import Loader2 from "@tabler/icons/outline/loader-2.svg";
3
+ import type { HTMLAttributes } from "astro/types";
4
+ import { tv } from "tailwind-variants";
5
+
6
+ type Props = Omit<HTMLAttributes<"svg">, "role" | "aria-label">;
7
+
8
+ export const spinner = tv({
9
+ base: "size-4 animate-spin",
10
+ });
11
+
12
+ const { class: className, ...rest } = Astro.props;
13
+ ---
14
+
15
+ <Loader2
16
+ role="status"
17
+ aria-label="Loading"
18
+ class={spinner({ class: className })}
19
+ data-slot="spinner"
20
+ {...rest}
21
+ />
@@ -0,0 +1,7 @@
1
+ import Spinner, { spinner } from "./Spinner.astro";
2
+
3
+ const SpinnerVariants = { spinner };
4
+
5
+ export { Spinner, SpinnerVariants };
6
+
7
+ export default Spinner;
@@ -0,0 +1,191 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import { tv } from "tailwind-variants";
4
+
5
+ type Props = Omit<HTMLAttributes<"button">, "role" | "type" | "aria-checked"> & {
6
+ /**
7
+ * Unique identifier for the switch component.
8
+ */
9
+ id: string;
10
+ /**
11
+ * Optional text label to display alongside the switch.
12
+ */
13
+ label?: string;
14
+ /**
15
+ * Controls the checked state of the switch.
16
+ */
17
+ checked?: boolean;
18
+ /**
19
+ * Custom padding in pixels to apply around the switch.
20
+ */
21
+ padding?: number;
22
+ /**
23
+ * Size variant of the switch component.
24
+ */
25
+ size?: "sm" | "md" | "lg";
26
+ /**
27
+ * Visual style variant of the switch.
28
+ * @default "default"
29
+ */
30
+ variant?: "default" | "primary" | "secondary" | "info" | "success" | "warning" | "error";
31
+ };
32
+
33
+ const {
34
+ id,
35
+ label,
36
+ checked = false,
37
+ padding,
38
+ size = "md",
39
+ variant = "default",
40
+ class: className,
41
+ ...rest
42
+ } = Astro.props;
43
+
44
+ // if no specific padding is set, base it off of size
45
+ let newPadding = padding;
46
+ if (!padding) {
47
+ newPadding = size === "sm" ? 2.5 : size === "lg" ? 4 : 3;
48
+ }
49
+
50
+ const sizeMultiplier = size === "sm" ? 4 : size === "lg" ? 6 : 5;
51
+
52
+ let ariaLabel;
53
+ if (rest["aria-label"]) {
54
+ ariaLabel = rest["aria-label"];
55
+ delete rest["aria-label"];
56
+ } else if (label) {
57
+ ariaLabel = label;
58
+ } else {
59
+ ariaLabel = "switch";
60
+ }
61
+
62
+ export const switchButton = tv({
63
+ base: [
64
+ "border-input bg-muted inline-flex h-(--height) w-(--width) items-center rounded-full border",
65
+ "group peer ring-offset-background transition outline-none focus-visible:ring-3",
66
+ "not-disabled:cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",
67
+ ],
68
+ variants: {
69
+ variant: {
70
+ primary: "aria-checked:border-primary focus-visible:border-primary/70 focus:ring-primary/50",
71
+ secondary:
72
+ "aria-checked:border-secondary focus-visible:border-secondary/70 focus:ring-secondary/50",
73
+ default: "aria-checked:border-foreground focus-visible:border-outline focus:ring-outline/50",
74
+ info: "aria-checked:border-info focus-visible:border-info/70 focus:ring-info/50",
75
+ success: "aria-checked:border-success focus-visible:border-success/70 focus:ring-success/50",
76
+ warning: "aria-checked:border-warning focus-visible:border-warning/70 focus:ring-warning/50",
77
+ error: "aria-checked:border-error focus-visible:border-error/70 focus:ring-error/50",
78
+ },
79
+ },
80
+ defaultVariants: { variant: "default" },
81
+ });
82
+
83
+ export const switchToggle = tv({
84
+ base: [
85
+ "bg-foreground inline-block transform rounded-full transition-transform",
86
+ "group-aria-checked:translate-x-(--translation) group-aria-[checked=false]:translate-x-[calc(var(--padding)-var(--border-offset))]",
87
+ ],
88
+ variants: { size: { sm: "size-4", md: "size-5", lg: "size-6" } },
89
+ defaultVariants: { size: "md" },
90
+ });
91
+
92
+ export const switchLabel = tv({
93
+ base: "text-foreground ml-2 font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
94
+ variants: { size: { sm: "text-sm", md: "text-base", lg: "text-lg" } },
95
+ defaultVariants: { size: "md" },
96
+ });
97
+ ---
98
+
99
+ <div class="starwind-switch flex items-center">
100
+ <button
101
+ type="button"
102
+ id={id}
103
+ role="switch"
104
+ aria-checked={checked ? "true" : "false"}
105
+ aria-label={ariaLabel}
106
+ class={switchButton({ variant, class: className })}
107
+ style={{
108
+ "--padding": `${newPadding}px`,
109
+ "--height": `calc((var(--spacing) * ${sizeMultiplier}) + (var(--padding) * 2))`,
110
+ "--width": `calc((var(--spacing) * ${sizeMultiplier} * 2) + (var(--padding) * 3))`,
111
+ "--border-offset": "1px",
112
+ }}
113
+ data-slot="switch-button"
114
+ {...rest}
115
+ >
116
+ <span
117
+ class={switchToggle({ size })}
118
+ data-slot="switch-toggle"
119
+ style={{
120
+ "--translation": `calc((var(--spacing) * ${sizeMultiplier}) + (var(--padding) * 2) - var(--border-offset))`,
121
+ }}></span>
122
+ </button>
123
+ {
124
+ label && (
125
+ <label for={id} class={switchLabel({ size })} data-slot="switch-label">
126
+ {label}
127
+ </label>
128
+ )
129
+ }
130
+ </div>
131
+
132
+ <script>
133
+ import type { SwitchChangeEvent } from "./SwitchTypes";
134
+
135
+ class SwitchHandler {
136
+ private switchButton: HTMLButtonElement;
137
+
138
+ constructor(switchButton: HTMLButtonElement) {
139
+ this.switchButton = switchButton;
140
+ this.setupEventListeners();
141
+ }
142
+
143
+ private setupEventListeners(): void {
144
+ this.switchButton.addEventListener("click", () => this.handleStateChange());
145
+ this.switchButton.addEventListener("keydown", (event) => this.handleKeyDown(event));
146
+ }
147
+
148
+ private handleStateChange(): void {
149
+ if (this.switchButton.disabled) return;
150
+
151
+ const isChecked = this.switchButton.getAttribute("aria-checked") === "true";
152
+ const newState = !isChecked;
153
+
154
+ this.switchButton.setAttribute("aria-checked", newState.toString());
155
+
156
+ // Dispatch custom event with the new state
157
+ const event = new CustomEvent<SwitchChangeEvent["detail"]>("starwind-switch:change", {
158
+ detail: { checked: newState, switchId: this.switchButton.id },
159
+ bubbles: true,
160
+ cancelable: true,
161
+ });
162
+
163
+ this.switchButton.dispatchEvent(event);
164
+ }
165
+
166
+ private handleKeyDown(event: KeyboardEvent): void {
167
+ if (this.switchButton.disabled) return;
168
+
169
+ if (event.key === " " || event.key === "Enter") {
170
+ event.preventDefault();
171
+ this.handleStateChange();
172
+ }
173
+ }
174
+ }
175
+
176
+ // Store instances in a WeakMap to avoid memory leaks
177
+ const switchInstances = new WeakMap<HTMLButtonElement, SwitchHandler>();
178
+
179
+ const setupSwitches = () => {
180
+ document
181
+ .querySelectorAll<HTMLButtonElement>('.starwind-switch button[role="switch"]')
182
+ .forEach((switchButton) => {
183
+ if (!switchInstances.has(switchButton)) {
184
+ switchInstances.set(switchButton, new SwitchHandler(switchButton));
185
+ }
186
+ });
187
+ };
188
+
189
+ setupSwitches();
190
+ document.addEventListener("astro:after-swap", setupSwitches);
191
+ </script>
@@ -0,0 +1,6 @@
1
+ export interface SwitchChangeEvent extends CustomEvent {
2
+ detail: {
3
+ checked: boolean;
4
+ switchId: string;
5
+ };
6
+ }
@@ -0,0 +1,12 @@
1
+ import Switch, { switchButton, switchLabel, switchToggle } from "./Switch.astro";
2
+ import type { SwitchChangeEvent } from "./SwitchTypes";
3
+
4
+ const SwitchVariants = {
5
+ switchButton,
6
+ switchToggle,
7
+ switchLabel,
8
+ };
9
+
10
+ export { Switch, type SwitchChangeEvent, SwitchVariants };
11
+
12
+ export default Switch;
@@ -0,0 +1,18 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import { tv, type VariantProps } from "tailwind-variants";
4
+
5
+ type Props = HTMLAttributes<"table"> & VariantProps<typeof table>;
6
+
7
+ export const table = tv({
8
+ base: "w-full caption-bottom text-sm",
9
+ });
10
+
11
+ const { class: className, ...rest } = Astro.props;
12
+ ---
13
+
14
+ <div data-slot="table-container" class="relative w-full overflow-x-auto">
15
+ <table data-slot="table" class={table({ class: className })} {...rest} role="table">
16
+ <slot />
17
+ </table>
18
+ </div>
@@ -0,0 +1,16 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import { tv, type VariantProps } from "tailwind-variants";
4
+
5
+ type Props = HTMLAttributes<"tbody"> & VariantProps<typeof tableBody>;
6
+
7
+ export const tableBody = tv({
8
+ base: "[&_tr:last-child]:border-0",
9
+ });
10
+
11
+ const { class: className, ...rest } = Astro.props;
12
+ ---
13
+
14
+ <tbody data-slot="table-body" class={tableBody({ class: className })} {...rest}>
15
+ <slot />
16
+ </tbody>
@@ -0,0 +1,16 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import { tv, type VariantProps } from "tailwind-variants";
4
+
5
+ type Props = HTMLAttributes<"caption"> & VariantProps<typeof tableCaption>;
6
+
7
+ export const tableCaption = tv({
8
+ base: "text-muted-foreground mt-4 text-sm",
9
+ });
10
+
11
+ const { class: className, ...rest } = Astro.props;
12
+ ---
13
+
14
+ <caption data-slot="table-caption" class={tableCaption({ class: className })} {...rest}>
15
+ <slot />
16
+ </caption>
@@ -0,0 +1,16 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import { tv, type VariantProps } from "tailwind-variants";
4
+
5
+ type Props = HTMLAttributes<"td"> & VariantProps<typeof tableCell>;
6
+
7
+ export const tableCell = tv({
8
+ base: "p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
9
+ });
10
+
11
+ const { class: className, ...rest } = Astro.props;
12
+ ---
13
+
14
+ <td data-slot="table-cell" class={tableCell({ class: className })} {...rest}>
15
+ <slot />
16
+ </td>
@@ -0,0 +1,16 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import { tv, type VariantProps } from "tailwind-variants";
4
+
5
+ type Props = HTMLAttributes<"tfoot"> & VariantProps<typeof tableFoot>;
6
+
7
+ export const tableFoot = tv({
8
+ base: "bg-muted/50 border-t font-medium [&>tr]:last:border-b-0",
9
+ });
10
+
11
+ const { class: className, ...rest } = Astro.props;
12
+ ---
13
+
14
+ <tfoot data-slot="table-foot" class={tableFoot({ class: className })} {...rest}>
15
+ <slot />
16
+ </tfoot>
@@ -0,0 +1,16 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import { tv, type VariantProps } from "tailwind-variants";
4
+
5
+ type Props = HTMLAttributes<"th"> & VariantProps<typeof tableHead>;
6
+
7
+ export const tableHead = tv({
8
+ base: "text-muted-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
9
+ });
10
+
11
+ const { class: className, ...rest } = Astro.props;
12
+ ---
13
+
14
+ <th data-slot="table-head" class={tableHead({ class: className })} {...rest} role="columnheader">
15
+ <slot />
16
+ </th>
@@ -0,0 +1,16 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import { tv, type VariantProps } from "tailwind-variants";
4
+
5
+ type Props = HTMLAttributes<"thead"> & VariantProps<typeof tableHeader>;
6
+
7
+ export const tableHeader = tv({
8
+ base: "[&_tr]:border-b",
9
+ });
10
+
11
+ const { class: className, ...rest } = Astro.props;
12
+ ---
13
+
14
+ <thead data-slot="table-header" class={tableHeader({ class: className })} {...rest}>
15
+ <slot />
16
+ </thead>
@@ -0,0 +1,16 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import { tv, type VariantProps } from "tailwind-variants";
4
+
5
+ type Props = HTMLAttributes<"tr"> & VariantProps<typeof tableRow>;
6
+
7
+ export const tableRow = tv({
8
+ base: "hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",
9
+ });
10
+
11
+ const { class: className, ...rest } = Astro.props;
12
+ ---
13
+
14
+ <tr data-slot="table-row" class={tableRow({ class: className })} {...rest} role="row">
15
+ <slot />
16
+ </tr>
@@ -0,0 +1,42 @@
1
+ import Table, { table } from "./Table.astro";
2
+ import TableBody, { tableBody } from "./TableBody.astro";
3
+ import TableCaption, { tableCaption } from "./TableCaption.astro";
4
+ import TableCell, { tableCell } from "./TableCell.astro";
5
+ import TableFoot, { tableFoot } from "./TableFoot.astro";
6
+ import TableHead, { tableHead } from "./TableHead.astro";
7
+ import TableHeader, { tableHeader } from "./TableHeader.astro";
8
+ import TableRow, { tableRow } from "./TableRow.astro";
9
+
10
+ const TableVariants = {
11
+ table,
12
+ tableBody,
13
+ tableCaption,
14
+ tableCell,
15
+ tableFoot,
16
+ tableHead,
17
+ tableHeader,
18
+ tableRow,
19
+ };
20
+
21
+ export {
22
+ Table,
23
+ TableBody,
24
+ TableCaption,
25
+ TableCell,
26
+ TableFoot,
27
+ TableHead,
28
+ TableHeader,
29
+ TableRow,
30
+ TableVariants,
31
+ };
32
+
33
+ export default {
34
+ Root: Table,
35
+ Body: TableBody,
36
+ Caption: TableCaption,
37
+ Cell: TableCell,
38
+ Foot: TableFoot,
39
+ Head: TableHead,
40
+ Header: TableHeader,
41
+ Row: TableRow,
42
+ };