@rimelight/ui 0.0.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 (301) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +30 -0
  3. package/i18n-data.json +186 -0
  4. package/package.json +49 -0
  5. package/src/components/FormattedDate.astro +22 -0
  6. package/src/components/HeaderLink.astro +24 -0
  7. package/src/components/HttpObservatory.astro +103 -0
  8. package/src/components/LighthouseScores.astro +204 -0
  9. package/src/components/MissingTranslationBanner.astro +39 -0
  10. package/src/components/TableOfContents.astro +106 -0
  11. package/src/components/ThemeToggle.astro +71 -0
  12. package/src/components/accordion/Accordion.astro +257 -0
  13. package/src/components/accordion/AccordionContent.astro +34 -0
  14. package/src/components/accordion/AccordionItem.astro +29 -0
  15. package/src/components/accordion/AccordionTrigger.astro +33 -0
  16. package/src/components/alert/Alert.astro +34 -0
  17. package/src/components/alert/AlertDescription.astro +15 -0
  18. package/src/components/alert/AlertTitle.astro +17 -0
  19. package/src/components/alert-dialog/AlertDialog.astro +275 -0
  20. package/src/components/alert-dialog/AlertDialogAction.astro +46 -0
  21. package/src/components/alert-dialog/AlertDialogCancel.astro +46 -0
  22. package/src/components/alert-dialog/AlertDialogContent.astro +52 -0
  23. package/src/components/alert-dialog/AlertDialogDescription.astro +18 -0
  24. package/src/components/alert-dialog/AlertDialogFooter.astro +16 -0
  25. package/src/components/alert-dialog/AlertDialogHeader.astro +14 -0
  26. package/src/components/alert-dialog/AlertDialogTitle.astro +20 -0
  27. package/src/components/alert-dialog/AlertDialogTrigger.astro +47 -0
  28. package/src/components/aspect-ratio/AspectRatio.astro +32 -0
  29. package/src/components/avatar/Avatar.astro +29 -0
  30. package/src/components/avatar/AvatarFallback.astro +18 -0
  31. package/src/components/avatar/AvatarImage.astro +66 -0
  32. package/src/components/badge/Badge.astro +57 -0
  33. package/src/components/breadcrumb/Breadcrumb.astro +12 -0
  34. package/src/components/breadcrumb/BreadcrumbEllipsis.astro +29 -0
  35. package/src/components/breadcrumb/BreadcrumbItem.astro +15 -0
  36. package/src/components/breadcrumb/BreadcrumbLink.astro +24 -0
  37. package/src/components/breadcrumb/BreadcrumbList.astro +17 -0
  38. package/src/components/breadcrumb/BreadcrumbPage.astro +22 -0
  39. package/src/components/breadcrumb/BreadcrumbSeparator.astro +24 -0
  40. package/src/components/button/Button.astro +58 -0
  41. package/src/components/button-group/ButtonGroup.astro +64 -0
  42. package/src/components/button-group/ButtonGroupSeparator.astro +20 -0
  43. package/src/components/button-group/ButtonGroupText.astro +19 -0
  44. package/src/components/card/Card.astro +36 -0
  45. package/src/components/card/CardAction.astro +16 -0
  46. package/src/components/card/CardContent.astro +16 -0
  47. package/src/components/card/CardDescription.astro +16 -0
  48. package/src/components/card/CardFooter.astro +16 -0
  49. package/src/components/card/CardHeader.astro +19 -0
  50. package/src/components/card/CardTitle.astro +16 -0
  51. package/src/components/carousel/Carousel.astro +55 -0
  52. package/src/components/carousel/CarouselContent.astro +26 -0
  53. package/src/components/carousel/CarouselItem.astro +26 -0
  54. package/src/components/carousel/CarouselNext.astro +39 -0
  55. package/src/components/carousel/CarouselPrevious.astro +41 -0
  56. package/src/components/carousel/carousel-script.ts +188 -0
  57. package/src/components/carousel/index.ts +1 -0
  58. package/src/components/checkbox/Checkbox.astro +133 -0
  59. package/src/components/collapsible/Collapsible.astro +161 -0
  60. package/src/components/collapsible/CollapsibleContent.astro +22 -0
  61. package/src/components/collapsible/CollapsibleTrigger.astro +44 -0
  62. package/src/components/dialog/Dialog.astro +389 -0
  63. package/src/components/dialog/DialogClose.astro +35 -0
  64. package/src/components/dialog/DialogContent.astro +78 -0
  65. package/src/components/dialog/DialogDescription.astro +14 -0
  66. package/src/components/dialog/DialogFooter.astro +14 -0
  67. package/src/components/dialog/DialogHeader.astro +14 -0
  68. package/src/components/dialog/DialogTitle.astro +18 -0
  69. package/src/components/dialog/DialogTrigger.astro +47 -0
  70. package/src/components/dropdown/Dropdown.astro +604 -0
  71. package/src/components/dropdown/DropdownContent.astro +118 -0
  72. package/src/components/dropdown/DropdownItem.astro +48 -0
  73. package/src/components/dropdown/DropdownLabel.astro +29 -0
  74. package/src/components/dropdown/DropdownSeparator.astro +21 -0
  75. package/src/components/dropdown/DropdownShortcut.astro +17 -0
  76. package/src/components/dropdown/DropdownSub.astro +15 -0
  77. package/src/components/dropdown/DropdownSubContent.astro +39 -0
  78. package/src/components/dropdown/DropdownSubTrigger.astro +34 -0
  79. package/src/components/dropdown/DropdownTrigger.astro +52 -0
  80. package/src/components/dropzone/Dropzone.astro +236 -0
  81. package/src/components/dropzone/DropzoneFilesList.astro +26 -0
  82. package/src/components/dropzone/DropzoneLoadingIndicator.astro +10 -0
  83. package/src/components/dropzone/DropzoneUploadIndicator.astro +10 -0
  84. package/src/components/embeds/YoutubeEmbed.astro +94 -0
  85. package/src/components/hero/Hero.astro +166 -0
  86. package/src/components/icons/Flag.astro +62 -0
  87. package/src/components/image/ExtendedImage.astro +46 -0
  88. package/src/components/image/Image.astro +25 -0
  89. package/src/components/input/Input.astro +27 -0
  90. package/src/components/input-group/InputGroup.astro +28 -0
  91. package/src/components/input-group/InputGroupAddon.astro +76 -0
  92. package/src/components/input-group/InputGroupButton.astro +36 -0
  93. package/src/components/input-group/InputGroupInput.astro +18 -0
  94. package/src/components/input-group/InputGroupText.astro +17 -0
  95. package/src/components/input-group/InputGroupTextarea.astro +22 -0
  96. package/src/components/input-otp/InputOtp.astro +352 -0
  97. package/src/components/input-otp/InputOtpGroup.astro +16 -0
  98. package/src/components/input-otp/InputOtpSeparator.astro +25 -0
  99. package/src/components/input-otp/InputOtpSlot.astro +50 -0
  100. package/src/components/input-otp/InputOtpTypes.ts +6 -0
  101. package/src/components/item/Item.astro +52 -0
  102. package/src/components/item/ItemActions.astro +16 -0
  103. package/src/components/item/ItemContent.astro +16 -0
  104. package/src/components/item/ItemDescription.astro +19 -0
  105. package/src/components/item/ItemFooter.astro +16 -0
  106. package/src/components/item/ItemGroup.astro +16 -0
  107. package/src/components/item/ItemHeader.astro +16 -0
  108. package/src/components/item/ItemMedia.astro +40 -0
  109. package/src/components/item/ItemSeparator.astro +23 -0
  110. package/src/components/item/ItemTitle.astro +16 -0
  111. package/src/components/kbd/Kbd.astro +21 -0
  112. package/src/components/kbd/KbdGroup.astro +16 -0
  113. package/src/components/label/Label.astro +24 -0
  114. package/src/components/marquee/Marquee.astro +73 -0
  115. package/src/components/native-select/NativeSelect.astro +68 -0
  116. package/src/components/native-select/NativeSelectOptGroup.astro +15 -0
  117. package/src/components/native-select/NativeSelectOption.astro +15 -0
  118. package/src/components/pagination/Pagination.astro +20 -0
  119. package/src/components/pagination/PaginationContent.astro +16 -0
  120. package/src/components/pagination/PaginationEllipsis.astro +37 -0
  121. package/src/components/pagination/PaginationItem.astro +16 -0
  122. package/src/components/pagination/PaginationLink.astro +27 -0
  123. package/src/components/pagination/PaginationNext.astro +33 -0
  124. package/src/components/pagination/PaginationPrevious.astro +33 -0
  125. package/src/components/popover/Popover.astro +717 -0
  126. package/src/components/popover/PopoverContent.astro +102 -0
  127. package/src/components/popover/PopoverDescription.astro +14 -0
  128. package/src/components/popover/PopoverHeader.astro +14 -0
  129. package/src/components/popover/PopoverTitle.astro +14 -0
  130. package/src/components/popover/PopoverTrigger.astro +51 -0
  131. package/src/components/progress/Progress.astro +154 -0
  132. package/src/components/prose/Prose.astro +619 -0
  133. package/src/components/radio-group/RadioGroup.astro +162 -0
  134. package/src/components/radio-group/RadioGroupItem.astro +133 -0
  135. package/src/components/radio-group/RadioGroupTypes.ts +6 -0
  136. package/src/components/section/Section.astro +167 -0
  137. package/src/components/select/Select.astro +752 -0
  138. package/src/components/select/SelectContent.astro +94 -0
  139. package/src/components/select/SelectGroup.astro +9 -0
  140. package/src/components/select/SelectItem.astro +51 -0
  141. package/src/components/select/SelectLabel.astro +14 -0
  142. package/src/components/select/SelectSearch.astro +49 -0
  143. package/src/components/select/SelectSeparator.astro +12 -0
  144. package/src/components/select/SelectTrigger.astro +56 -0
  145. package/src/components/select/SelectTypes.ts +13 -0
  146. package/src/components/select/SelectValue.astro +19 -0
  147. package/src/components/separator/Separator.astro +36 -0
  148. package/src/components/sheet/Sheet.astro +15 -0
  149. package/src/components/sheet/SheetClose.astro +15 -0
  150. package/src/components/sheet/SheetContent.astro +89 -0
  151. package/src/components/sheet/SheetDescription.astro +16 -0
  152. package/src/components/sheet/SheetFooter.astro +16 -0
  153. package/src/components/sheet/SheetHeader.astro +16 -0
  154. package/src/components/sheet/SheetTitle.astro +16 -0
  155. package/src/components/sheet/SheetTrigger.astro +15 -0
  156. package/src/components/sidebar/Sidebar.astro +231 -0
  157. package/src/components/sidebar/SidebarContent.astro +25 -0
  158. package/src/components/sidebar/SidebarFooter.astro +22 -0
  159. package/src/components/sidebar/SidebarGroup.astro +22 -0
  160. package/src/components/sidebar/SidebarGroupContent.astro +22 -0
  161. package/src/components/sidebar/SidebarGroupLabel.astro +53 -0
  162. package/src/components/sidebar/SidebarHeader.astro +22 -0
  163. package/src/components/sidebar/SidebarInput.astro +24 -0
  164. package/src/components/sidebar/SidebarInset.astro +22 -0
  165. package/src/components/sidebar/SidebarMenu.astro +22 -0
  166. package/src/components/sidebar/SidebarMenuAction.astro +63 -0
  167. package/src/components/sidebar/SidebarMenuBadge.astro +31 -0
  168. package/src/components/sidebar/SidebarMenuButton.astro +124 -0
  169. package/src/components/sidebar/SidebarMenuItem.astro +22 -0
  170. package/src/components/sidebar/SidebarMenuSkeleton.astro +43 -0
  171. package/src/components/sidebar/SidebarMenuSub.astro +25 -0
  172. package/src/components/sidebar/SidebarMenuSubButton.astro +52 -0
  173. package/src/components/sidebar/SidebarMenuSubItem.astro +17 -0
  174. package/src/components/sidebar/SidebarProvider.astro +215 -0
  175. package/src/components/sidebar/SidebarRail.astro +72 -0
  176. package/src/components/sidebar/SidebarSeparator.astro +25 -0
  177. package/src/components/sidebar/SidebarTrigger.astro +69 -0
  178. package/src/components/skeleton/Skeleton.astro +14 -0
  179. package/src/components/slider/Slider.astro +425 -0
  180. package/src/components/spinner/Spinner.astro +23 -0
  181. package/src/components/switch/Switch.astro +192 -0
  182. package/src/components/switch/SwitchTypes.ts +6 -0
  183. package/src/components/table/Table.astro +20 -0
  184. package/src/components/table/TableBody.astro +18 -0
  185. package/src/components/table/TableCaption.astro +18 -0
  186. package/src/components/table/TableCell.astro +18 -0
  187. package/src/components/table/TableFoot.astro +18 -0
  188. package/src/components/table/TableHead.astro +18 -0
  189. package/src/components/table/TableHeader.astro +18 -0
  190. package/src/components/table/TableRow.astro +17 -0
  191. package/src/components/tabs/Tabs.astro +270 -0
  192. package/src/components/tabs/TabsContent.astro +28 -0
  193. package/src/components/tabs/TabsList.astro +23 -0
  194. package/src/components/tabs/TabsTrigger.astro +34 -0
  195. package/src/components/textarea/Textarea.astro +31 -0
  196. package/src/components/toast/ToastDescription.astro +22 -0
  197. package/src/components/toast/ToastItem.astro +56 -0
  198. package/src/components/toast/ToastTemplate.astro +27 -0
  199. package/src/components/toast/ToastTitle.astro +59 -0
  200. package/src/components/toast/Toaster.astro +981 -0
  201. package/src/components/toast/index.ts +1 -0
  202. package/src/components/toast/toast-manager.ts +234 -0
  203. package/src/components/toggle/Toggle.astro +174 -0
  204. package/src/components/toggle/ToggleTypes.ts +14 -0
  205. package/src/components/tooltip/Tooltip.astro +422 -0
  206. package/src/components/tooltip/TooltipContent.astro +83 -0
  207. package/src/components/tooltip/TooltipTrigger.astro +13 -0
  208. package/src/components/video/Video.astro +121 -0
  209. package/src/config/cookies.ts +5 -0
  210. package/src/config/index.ts +3 -0
  211. package/src/config/links.ts +4 -0
  212. package/src/config/site.config.ts +45 -0
  213. package/src/domain/cms/index.ts +1 -0
  214. package/src/domain/cms/types.ts +20 -0
  215. package/src/domain/i18n/constants.ts +21 -0
  216. package/src/domain/i18n/cookie-storage.ts +13 -0
  217. package/src/domain/i18n/country-to-locale-map.ts +67 -0
  218. package/src/domain/i18n/fallbacks.generated.ts +230 -0
  219. package/src/domain/i18n/fetcher.ts +268 -0
  220. package/src/domain/i18n/flags.ts +16 -0
  221. package/src/domain/i18n/format.ts +90 -0
  222. package/src/domain/i18n/index.ts +10 -0
  223. package/src/domain/i18n/middleware/i18n.ts +160 -0
  224. package/src/domain/i18n/resolve-locale.ts +55 -0
  225. package/src/domain/i18n/runtime-constants.ts +14 -0
  226. package/src/domain/i18n/schema.ts +29 -0
  227. package/src/domain/index.ts +4 -0
  228. package/src/domain/seo/constants.ts +20 -0
  229. package/src/domain/seo/index.ts +3 -0
  230. package/src/domain/seo/services/index.ts +3 -0
  231. package/src/domain/seo/services/llms.ts +53 -0
  232. package/src/domain/seo/services/robots.ts +12 -0
  233. package/src/domain/seo/services/sitemap.ts +56 -0
  234. package/src/domain/seo/utils.ts +37 -0
  235. package/src/domain/theme/constants.ts +6 -0
  236. package/src/domain/theme/index.ts +2 -0
  237. package/src/domain/theme/schema.ts +10 -0
  238. package/src/env.d.ts +49 -0
  239. package/src/i18n.generated.d.ts +202 -0
  240. package/src/lib/component-preview.ts +73 -0
  241. package/src/lib/index.ts +6 -0
  242. package/src/lib/remark/remark-modified-time.ts +13 -0
  243. package/src/lib/showcase-preview-elements.ts +408 -0
  244. package/src/lib/showcase-renderer.ts +218 -0
  245. package/src/lib/showcase-utils.ts +189 -0
  246. package/src/lib/turnstile.ts +35 -0
  247. package/src/lib/utils/starwind/positioning.ts +318 -0
  248. package/src/locales/de/blog.json +9 -0
  249. package/src/locales/de/common.json +19 -0
  250. package/src/locales/de/errors.json +6 -0
  251. package/src/locales/de/home.json +20 -0
  252. package/src/locales/de/messages.json +8 -0
  253. package/src/locales/de/nav.json +13 -0
  254. package/src/locales/de/projects.json +9 -0
  255. package/src/locales/de/services.json +43 -0
  256. package/src/locales/en/blog.json +9 -0
  257. package/src/locales/en/chat.json +29 -0
  258. package/src/locales/en/common.json +19 -0
  259. package/src/locales/en/cookie_notice.json +11 -0
  260. package/src/locales/en/editor.json +24 -0
  261. package/src/locales/en/errors.json +6 -0
  262. package/src/locales/en/home.json +20 -0
  263. package/src/locales/en/messages.json +8 -0
  264. package/src/locales/en/nav.json +13 -0
  265. package/src/locales/en/projects.json +9 -0
  266. package/src/locales/en/services.json +43 -0
  267. package/src/locales/es/blog.json +9 -0
  268. package/src/locales/es/common.json +19 -0
  269. package/src/locales/es/errors.json +6 -0
  270. package/src/locales/es/home.json +20 -0
  271. package/src/locales/es/messages.json +8 -0
  272. package/src/locales/es/nav.json +13 -0
  273. package/src/locales/es/projects.json +9 -0
  274. package/src/locales/es/services.json +43 -0
  275. package/src/locales/ja/blog.json +9 -0
  276. package/src/locales/ja/common.json +19 -0
  277. package/src/locales/ja/errors.json +6 -0
  278. package/src/locales/ja/home.json +20 -0
  279. package/src/locales/ja/messages.json +8 -0
  280. package/src/locales/ja/nav.json +13 -0
  281. package/src/locales/ja/projects.json +9 -0
  282. package/src/locales/ja/services.json +43 -0
  283. package/src/locales/pt/blog.json +9 -0
  284. package/src/locales/pt/chat.json +29 -0
  285. package/src/locales/pt/common.json +19 -0
  286. package/src/locales/pt/cookie_notice.json +11 -0
  287. package/src/locales/pt/editor.json +24 -0
  288. package/src/locales/pt/errors.json +6 -0
  289. package/src/locales/pt/home.json +20 -0
  290. package/src/locales/pt/messages.json +8 -0
  291. package/src/locales/pt/nav.json +13 -0
  292. package/src/locales/pt/projects.json +9 -0
  293. package/src/locales/pt/services.json +43 -0
  294. package/src/utils/index.ts +2 -0
  295. package/src/utils/server/cookies.ts +98 -0
  296. package/src/utils/server/index.ts +1 -0
  297. package/src/utils/shared/deep-merge.ts +36 -0
  298. package/src/utils/shared/embed.ts +105 -0
  299. package/src/utils/shared/index.ts +3 -0
  300. package/src/utils/shared/parse-boolean.ts +14 -0
  301. package/worker-configuration.d.ts +14791 -0
@@ -0,0 +1,118 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import { cv } from "css-variants";
4
+
5
+ type Props = HTMLAttributes<"div"> & {
6
+ /**
7
+ * Side of the dropdown
8
+ * @default bottom
9
+ */
10
+ side?: "top" | "bottom" | "left" | "right";
11
+ /**
12
+ * Alignment of the dropdown
13
+ * @default start
14
+ */
15
+ align?: "start" | "center" | "end";
16
+ /**
17
+ * Offset distance in pixels
18
+ * @default 4
19
+ */
20
+ sideOffset?: number;
21
+ /**
22
+ * Open and close animation duration in milliseconds
23
+ * @default 150
24
+ */
25
+ animationDuration?: number;
26
+ };
27
+
28
+ export const dropdownContent = cv({
29
+ base: [
30
+ "starwind-dropdown-content",
31
+ "bg-popover text-popover-foreground z-50 min-w-5xl max-w-4xl overflow-x-hidden overflow-y-auto rounded-md b p-5xs shadow-md",
32
+ "data-[state=open]:animate-in fade-in zoom-in-95",
33
+ "data-[state=closed]:animate-out data-[state=closed]:fill-mode-forwards fade-out zoom-out-95",
34
+ "absolute will-change-transform",
35
+ ],
36
+ variants: {
37
+ side: {
38
+ bottom: "slide-in-from-top-2 slide-out-to-top-2 top-full",
39
+ top: "slide-in-from-bottom-2 slide-out-to-bottom-2 bottom-full",
40
+ right: "slide-in-from-left-2 slide-out-to-left-2 top-0 left-full",
41
+ left: "slide-in-from-right-2 slide-out-to-right-2 top-0 right-full",
42
+ },
43
+ align: {
44
+ start: "",
45
+ center: "",
46
+ end: "",
47
+ },
48
+ },
49
+ compoundVariants: [
50
+ {
51
+ side: ["top", "bottom"],
52
+ align: "start",
53
+ className: "slide-in-from-left-1 slide-out-to-left-1 left-0",
54
+ },
55
+ {
56
+ side: ["top", "bottom"],
57
+ align: "center",
58
+ className: "left-1/2 -translate-x-1/2",
59
+ },
60
+ {
61
+ side: ["top", "bottom"],
62
+ align: "end",
63
+ className: "slide-in-from-right-1 slide-out-to-right-1 right-0",
64
+ },
65
+ {
66
+ side: ["left", "right"],
67
+ align: "start",
68
+ className: "top-0",
69
+ },
70
+ {
71
+ side: ["left", "right"],
72
+ align: "center",
73
+ className: "top-1/2 -translate-y-1/2",
74
+ },
75
+ {
76
+ side: ["left", "right"],
77
+ align: "end",
78
+ className: "bottom-0",
79
+ },
80
+ ],
81
+ defaultVariants: {
82
+ side: "bottom",
83
+ align: "start",
84
+ },
85
+ });
86
+
87
+ const {
88
+ class: className,
89
+ side = "bottom",
90
+ align = "start",
91
+ sideOffset = 4,
92
+ animationDuration = 150,
93
+ ...rest
94
+ } = Astro.props;
95
+ ---
96
+
97
+ <div
98
+ class:list={[dropdownContent({ side, align }), className]}
99
+ role="menu"
100
+ data-side={side}
101
+ data-align={align}
102
+ data-state="closed"
103
+ tabindex="-1"
104
+ aria-orientation="vertical"
105
+ style={{
106
+ display: "none",
107
+ animationDuration: `${animationDuration}ms`,
108
+ maxWidth: "min(256px, 100vw - 1rem)",
109
+ marginTop: side === "bottom" ? `${sideOffset}px` : undefined,
110
+ marginBottom: side === "top" ? `${sideOffset}px` : undefined,
111
+ marginLeft: side === "right" ? `${sideOffset}px` : undefined,
112
+ marginRight: side === "left" ? `${sideOffset}px` : undefined,
113
+ }}
114
+ {...rest}
115
+ data-slot="dropdown-content"
116
+ >
117
+ <slot />
118
+ </div>
@@ -0,0 +1,48 @@
1
+ ---
2
+ import type { HTMLTag, Polymorphic } from "astro/types";
3
+ import { cv } from "css-variants";
4
+
5
+ type Props<Tag extends HTMLTag> = Polymorphic<{ as: Tag }> & {
6
+ /**
7
+ * Whether the item is inset (has left padding)
8
+ */
9
+ inset?: boolean;
10
+ /**
11
+ * Whether the item is disabled
12
+ */
13
+ disabled?: boolean;
14
+ };
15
+
16
+ export const dropdownItem = cv({
17
+ base: [
18
+ "focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-3xs rounded-sm px-3xs py-5xs transition-colors outline-none select-none",
19
+ "data-[disabled]:pointer-events-none data-[disabled]:op-50",
20
+ "group/dropdown-item [&>svg]:size-4 [&>svg]:shrink-0",
21
+ ],
22
+ variants: {
23
+ inset: {
24
+ true: "pl-3xl",
25
+ },
26
+ disabled: {
27
+ true: "pointer-events-none op-50",
28
+ },
29
+ },
30
+ defaultVariants: {
31
+ inset: false,
32
+ disabled: false,
33
+ },
34
+ });
35
+
36
+ const { class: className, inset = false, disabled = false, as: Tag = "div", ...rest } = Astro.props;
37
+ ---
38
+
39
+ <Tag
40
+ class:list={[dropdownItem({ inset, disabled }), className]}
41
+ role="menuitem"
42
+ tabindex={disabled ? "-1" : "0"}
43
+ data-disabled={disabled ? "true" : undefined}
44
+ data-slot="dropdown-item"
45
+ {...rest}
46
+ >
47
+ <slot />
48
+ </Tag>
@@ -0,0 +1,29 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import { cv } from "css-variants";
4
+
5
+ type Props = HTMLAttributes<"div"> & {
6
+ /**
7
+ * Whether the label is inset (has left padding)
8
+ */
9
+ inset?: boolean;
10
+ };
11
+
12
+ export const dropdownLabel = cv({
13
+ base: ["text-muted-foreground px-3xs py-5xs text-sm font-medium"],
14
+ variants: {
15
+ inset: {
16
+ true: "pl-3xl",
17
+ },
18
+ },
19
+ defaultVariants: {
20
+ inset: false,
21
+ },
22
+ });
23
+
24
+ const { class: className, inset = false, ...rest } = Astro.props;
25
+ ---
26
+
27
+ <div class:list={[dropdownLabel({ inset }), className]} {...rest} data-slot="dropdown-label">
28
+ <slot />
29
+ </div>
@@ -0,0 +1,21 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import { cv } from "css-variants";
4
+
5
+ type Props = HTMLAttributes<"div">;
6
+
7
+ export const dropdownSeparator = cv({
8
+ base: "bg-border -mx-5xs my-5xs h-6xs",
9
+ });
10
+
11
+ const { class: className, ...rest } = Astro.props;
12
+ ---
13
+
14
+ <div
15
+ class:list={[dropdownSeparator(), className]}
16
+ role="separator"
17
+ aria-orientation="horizontal"
18
+ {...rest}
19
+ data-slot="dropdown-separator"
20
+ >
21
+ </div>
@@ -0,0 +1,17 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+
4
+ type Props = HTMLAttributes<"span">;
5
+
6
+ const { class: className, ...rest } = Astro.props;
7
+ ---
8
+
9
+ <span
10
+ class:list={[
11
+ "group-focus/dropdown-item:text-accent-foreground text-muted-foreground ml-auto text-sm tracking-widest transition-colors",
12
+ className,
13
+ ]}
14
+ {...rest}
15
+ >
16
+ <slot />
17
+ </span>
@@ -0,0 +1,15 @@
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
10
+ class:list={["starwind-dropdown-sub", "relative", className]}
11
+ {...rest}
12
+ data-slot="dropdown-sub"
13
+ >
14
+ <slot />
15
+ </div>
@@ -0,0 +1,39 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+
4
+ import { dropdownContent } from "./DropdownContent.astro";
5
+
6
+ type Props = HTMLAttributes<"div"> & {
7
+ /**
8
+ * Open and close animation duration in milliseconds
9
+ * @default 150
10
+ */
11
+ animationDuration?: number;
12
+ };
13
+
14
+ const { class: className, animationDuration = 150, ...rest } = Astro.props;
15
+ ---
16
+
17
+ <div
18
+ class:list={[
19
+ dropdownContent({
20
+ side: "right",
21
+ align: "start",
22
+ }),
23
+ "starwind-dropdown-sub-content",
24
+ className,
25
+ ]}
26
+ data-sub-content
27
+ role="menu"
28
+ data-state="closed"
29
+ tabindex="-1"
30
+ aria-orientation="vertical"
31
+ style={{
32
+ display: "none",
33
+ animationDuration: `${animationDuration}ms`,
34
+ }}
35
+ {...rest}
36
+ data-slot="dropdown-content"
37
+ >
38
+ <slot />
39
+ </div>
@@ -0,0 +1,34 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import IconChevronRight from "~icons/lucide/chevron-right";
4
+
5
+ import { dropdownItem } from "./DropdownItem.astro";
6
+
7
+ type Props = HTMLAttributes<"div"> & {
8
+ /**
9
+ * Whether the item is inset (has left padding)
10
+ */
11
+ inset?: boolean;
12
+ /**
13
+ * Whether the item is disabled
14
+ */
15
+ disabled?: boolean;
16
+ };
17
+
18
+ const { class: className, inset = false, disabled = false, ...rest } = Astro.props;
19
+ ---
20
+
21
+ <div
22
+ class:list={[dropdownItem({ inset, disabled }), "starwind-dropdown-sub-trigger", className]}
23
+ role="menuitem"
24
+ aria-haspopup="true"
25
+ aria-expanded="false"
26
+ tabindex={disabled ? "-1" : "0"}
27
+ data-disabled={disabled ? "true" : undefined}
28
+ data-sub-trigger
29
+ {...rest}
30
+ data-slot="dropdown-item"
31
+ >
32
+ <slot />
33
+ <IconChevronRight class="ml-auto size-4" />
34
+ </div>
@@ -0,0 +1,52 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import { cv } from "css-variants";
4
+
5
+ type Props = Omit<HTMLAttributes<"button">, "role" | "type"> & {
6
+ /**
7
+ * When true, the component will render its child element with a simple wrapper instead of a button component
8
+ */
9
+ asChild?: boolean;
10
+ };
11
+
12
+ export const dropdownTrigger = cv({
13
+ base: [
14
+ "starwind-dropdown-trigger",
15
+ "inline-flex items-center justify-center",
16
+ "focus-visible:ring-outline/50 transition-[color,box-shadow] outline-none focus-visible:ring-3",
17
+ "disabled:pointer-events-none",
18
+ ],
19
+ });
20
+
21
+ const { class: className, asChild = false, ...rest } = Astro.props;
22
+
23
+ // Get the first child element if asChild is true
24
+ let hasChildren = false;
25
+ if (Astro.slots.has("default")) {
26
+ hasChildren = true;
27
+ }
28
+ ---
29
+
30
+ {
31
+ asChild && hasChildren ? (
32
+ <div
33
+ class:list={["starwind-dropdown-trigger", className]}
34
+ data-slot="dropdown-trigger"
35
+ data-as-child
36
+ >
37
+ <slot />
38
+ </div>
39
+ ) : (
40
+ <button
41
+ class:list={[dropdownTrigger(), className]}
42
+ type="button"
43
+ aria-haspopup="true"
44
+ aria-expanded="false"
45
+ data-state="closed"
46
+ {...rest}
47
+ data-slot="dropdown-trigger"
48
+ >
49
+ <slot />
50
+ </button>
51
+ )
52
+ }
@@ -0,0 +1,236 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import { cv } from "css-variants";
4
+
5
+ import DropzoneFilesList from "./DropzoneFilesList.astro";
6
+ import DropzoneLoadingIndicator from "./DropzoneLoadingIndicator.astro";
7
+ import DropzoneUploadIndicator from "./DropzoneUploadIndicator.astro";
8
+
9
+ type Props = HTMLAttributes<"input"> & {
10
+ /**
11
+ * Whether to show the loading indicator initially
12
+ */
13
+ isUploading?: boolean;
14
+ };
15
+
16
+ // extract id separately so it can be used in the label. The input will get the same id with "-input" suffix.
17
+ const { class: className, id, isUploading = false, ...rest } = Astro.props as Props;
18
+
19
+ export const dropzone = cv({
20
+ base: [
21
+ "starwind-dropzone",
22
+ "relative flex w-full flex-col items-center justify-center gap-1 rounded-lg px-6 py-12 shadow-xs",
23
+ "bg-background dark:bg-input/30 text-muted-foreground b-input cursor-pointer b b-dashed text-center text-sm",
24
+ "data-[is-uploading=false]:hover:bg-muted data-[drag-active=true]:bg-muted transition",
25
+ "focus-visible:border-outline focus-visible:ring-outline/50 outline-none focus-visible:ring-3",
26
+ "aria-invalid:border-error aria-invalid:focus-visible:ring-error/40",
27
+ "disabled:cursor-not-allowed disabled:op-50",
28
+ ],
29
+ });
30
+ ---
31
+
32
+ <label
33
+ id={id}
34
+ tabindex="0"
35
+ class:list={[dropzone(), className]}
36
+ data-slot="dropzone"
37
+ data-drag-active="false"
38
+ data-has-files="false"
39
+ data-is-uploading={String(isUploading)}
40
+ >
41
+ <slot>
42
+ <DropzoneUploadIndicator />
43
+ <DropzoneLoadingIndicator />
44
+ <DropzoneFilesList />
45
+ </slot>
46
+
47
+ <input tabindex="-1" type="file" class="sr-only" {...rest} />
48
+ </label>
49
+
50
+ <script>
51
+ const fileSvg = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-file"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M14 3v4a1 1 0 0 0 1 1h4" /><path d="M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z" /></svg>`;
52
+ class FileInputHandler {
53
+ private label: HTMLLabelElement;
54
+ private input: HTMLInputElement;
55
+ private uploadIndicator: HTMLElement | null;
56
+ private loadingIndicator: HTMLElement | null;
57
+ private filesList: HTMLElement | null;
58
+ private files: File[] = [];
59
+ private isUploading: boolean = false;
60
+ private observer: MutationObserver | null = null;
61
+
62
+ constructor(label: HTMLLabelElement, idx: number) {
63
+ this.label = label;
64
+ const maybeInput = label.querySelector<HTMLInputElement>('input[type="file"]');
65
+ if (!maybeInput) {
66
+ throw new Error("No file input found inside starwind-dropzone");
67
+ }
68
+ this.input = maybeInput;
69
+ this.uploadIndicator = label.querySelector(".starwind-upload-indicator");
70
+ this.loadingIndicator = label.querySelector(".starwind-loading-indicator");
71
+ this.filesList = label.querySelector(".starwind-files-list");
72
+
73
+ // generate ID
74
+ if (this.label.id) {
75
+ const inputId = this.label.id + "-input";
76
+ this.input.id = inputId;
77
+ this.label.htmlFor = inputId;
78
+ } else {
79
+ const generatedId = `starwind-dropzone-${idx}`;
80
+ this.input.id = generatedId;
81
+ this.label.htmlFor = generatedId;
82
+ }
83
+
84
+ // Setup event handlers
85
+ this.setupEvents();
86
+ }
87
+
88
+ private setActive(active: boolean) {
89
+ this.label.dataset.dragActive = String(active);
90
+ }
91
+
92
+ // Set up mutation observer to watch for external attribute changes
93
+ private observeAttributeChanges() {
94
+ this.observer = new MutationObserver((mutations) => {
95
+ mutations.forEach((mutation) => {
96
+ if (mutation.type === "attributes" && mutation.attributeName === "data-is-uploading") {
97
+ this.handleAttributeChange();
98
+ }
99
+ });
100
+ });
101
+
102
+ this.observer.observe(this.label, {
103
+ attributes: true,
104
+ attributeFilter: ["data-is-uploading"],
105
+ });
106
+ }
107
+
108
+ // Handle attribute changes from external sources
109
+ private handleAttributeChange() {
110
+ const isUploading = this.label.dataset.isUploading === "true";
111
+
112
+ // Only update internal state if it's different
113
+ if (isUploading !== this.isUploading) {
114
+ this.isUploading = isUploading;
115
+
116
+ // Update UI
117
+ if (this.uploadIndicator && this.loadingIndicator) {
118
+ if (isUploading) {
119
+ this.uploadIndicator.classList.add("hidden");
120
+ this.loadingIndicator.classList.remove("hidden");
121
+ } else {
122
+ this.loadingIndicator.classList.add("hidden");
123
+ this.uploadIndicator.classList.remove("hidden");
124
+ }
125
+ }
126
+ }
127
+ }
128
+
129
+ private updateFilesList() {
130
+ if (!this.filesList) return;
131
+
132
+ const hasFiles = this.files.length > 0;
133
+ this.label.dataset.hasFiles = String(hasFiles);
134
+
135
+ if (hasFiles) {
136
+ this.filesList.classList.remove("invisible");
137
+
138
+ // Clear previous files
139
+ this.filesList.innerHTML = "";
140
+
141
+ // Create file list
142
+ this.files.forEach((file) => {
143
+ const fileItem = document.createElement("div");
144
+
145
+ // Insert SVG directly
146
+ fileItem.innerHTML = fileSvg;
147
+
148
+ const fileText = document.createElement("span");
149
+ fileText.textContent = file.name;
150
+
151
+ // Append text after the SVG
152
+ fileItem.appendChild(fileText);
153
+
154
+ // Use non-null assertion since we already checked at the beginning of the method
155
+ this.filesList!.appendChild(fileItem);
156
+ });
157
+ } else {
158
+ this.filesList.classList.add("invisible");
159
+ }
160
+ }
161
+
162
+ private handleFiles(files: FileList | null) {
163
+ if (!files || files.length === 0) return;
164
+
165
+ this.files = Array.from(files);
166
+ this.updateFilesList();
167
+ }
168
+
169
+ private setupEvents() {
170
+ this.label.addEventListener("dragover", (e) => {
171
+ e.preventDefault();
172
+ this.setActive(true);
173
+ });
174
+
175
+ this.label.addEventListener("dragleave", () => {
176
+ this.setActive(false);
177
+ });
178
+
179
+ this.label.addEventListener("drop", (e) => {
180
+ e.preventDefault();
181
+ this.setActive(false);
182
+
183
+ const { files } = e.dataTransfer || {};
184
+ if (files && files.length) {
185
+ const dt = new DataTransfer();
186
+ Array.from(files).forEach((file) => dt.items.add(file));
187
+ this.input.files = dt.files;
188
+ this.input.dispatchEvent(new Event("change", { bubbles: true }));
189
+
190
+ this.handleFiles(files);
191
+ }
192
+ });
193
+
194
+ // Handle file selection from dialog
195
+ this.input.addEventListener("change", () => {
196
+ this.handleFiles(this.input.files);
197
+ });
198
+
199
+ // Add keyboard accessibility for Enter and Space keys
200
+ this.label.addEventListener("keydown", (e) => {
201
+ // Handle Enter (13) and Space (32) keys
202
+ if (e.key === "Enter" || e.key === " ") {
203
+ e.preventDefault();
204
+ this.input.click(); // Trigger the native file dialog
205
+ }
206
+ });
207
+
208
+ if (this.loadingIndicator) {
209
+ // Watch for external changes to data-is-uploading attribute
210
+ this.observeAttributeChanges();
211
+ // Initialize based on current attribute values
212
+ this.handleAttributeChange();
213
+ }
214
+ }
215
+ }
216
+
217
+ // Store instances in a WeakMap to avoid memory leaks
218
+ const fileInputInstances = new WeakMap<HTMLElement, FileInputHandler>();
219
+ let dropzoneCounter = 0;
220
+
221
+ const setupFileInputs = () => {
222
+ document.querySelectorAll<HTMLLabelElement>(".starwind-dropzone").forEach((label) => {
223
+ if (!fileInputInstances.has(label)) {
224
+ try {
225
+ fileInputInstances.set(label, new FileInputHandler(label, dropzoneCounter++));
226
+ } catch {
227
+ /* ignore labels without inputs */
228
+ }
229
+ }
230
+ });
231
+ };
232
+
233
+ setupFileInputs();
234
+ document.addEventListener("astro:after-swap", setupFileInputs);
235
+ document.addEventListener("starwind:init", setupFileInputs);
236
+ </script>
@@ -0,0 +1,26 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import { cv } from "css-variants";
4
+
5
+ type Props = HTMLAttributes<"div">;
6
+
7
+ const { class: className, ...rest } = Astro.props;
8
+
9
+ export const dropzoneFilesList = cv({
10
+ base: [
11
+ "starwind-files-list",
12
+ "mt-2xs -mb-3xs min-h-3xs",
13
+ "bg-muted invisible flex flex-col items-center justify-center gap-2xs rounded-md px-2 py-1 text-sm",
14
+ "[&_div]:flex [&_div]:items-center [&_div]:gap-1 [&_svg]:size-3.5",
15
+ ],
16
+ });
17
+ ---
18
+
19
+ <div
20
+ class:list={[dropzoneFilesList(), className]}
21
+ aria-live="polite"
22
+ aria-label="Uploaded files"
23
+ {...rest}
24
+ data-slot="dropzone-files-list"
25
+ >
26
+ </div>
@@ -0,0 +1,10 @@
1
+ ---
2
+ import IconLoader from "~icons/lucide/loader";
3
+ ---
4
+
5
+ <div class="starwind-loading-indicator hidden" data-slot="dropzone-loading-indicator">
6
+ <slot>
7
+ <IconLoader class="mx-auto size-10 animate-spin" aria-hidden="true" />
8
+ <p class="mt-1 text-sm">Uploading file(s)...</p>
9
+ </slot>
10
+ </div>
@@ -0,0 +1,10 @@
1
+ ---
2
+ import IconCloudUpload from "~icons/lucide/cloud-upload";
3
+ ---
4
+
5
+ <div class="starwind-upload-indicator" data-slot="dropzone-upload-indicator">
6
+ <slot>
7
+ <IconCloudUpload class="mx-auto size-10" aria-hidden="true" />
8
+ <p class="mt-1 text-sm">Click to upload or drag and drop</p>
9
+ </slot>
10
+ </div>