@rimelight/ui 0.0.4 → 0.0.6

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 (310) hide show
  1. package/package.json +36 -6
  2. package/src/components/BlogPost.astro +181 -0
  3. package/src/components/DynamicShowcase.astro +681 -0
  4. package/src/components/ExtendedCarousel.astro +107 -0
  5. package/src/components/Head.astro +150 -0
  6. package/src/components/LanguageSwitcher.astro +128 -0
  7. package/src/components/ProjectPost.astro +183 -0
  8. package/src/components/RLHead.astro +3 -0
  9. package/src/components/ThemeToggle.astro +30 -42
  10. package/src/components/astro/RLAButton.astro +85 -0
  11. package/src/components/astro/RLAHeader.astro +75 -0
  12. package/src/components/vue/RLVButton.vue +90 -0
  13. package/src/components/vue/RLVHeader.vue +78 -0
  14. package/src/composables/index.ts +1 -0
  15. package/src/composables/useUi.ts +27 -0
  16. package/src/config/index.ts +0 -2
  17. package/src/config/site.config.ts +1 -1
  18. package/src/env.d.ts +9 -42
  19. package/src/integrations/index.ts +2 -0
  20. package/src/integrations/ui.ts +87 -0
  21. package/src/themes/button.theme.ts +361 -0
  22. package/src/themes/header.theme.ts +33 -0
  23. package/src/themes/index.ts +13 -0
  24. package/src/utils/index.ts +3 -2
  25. package/i18n-data.json +0 -186
  26. package/src/components/accordion/Accordion.astro +0 -257
  27. package/src/components/accordion/AccordionContent.astro +0 -34
  28. package/src/components/accordion/AccordionItem.astro +0 -29
  29. package/src/components/accordion/AccordionTrigger.astro +0 -33
  30. package/src/components/alert/Alert.astro +0 -34
  31. package/src/components/alert/AlertDescription.astro +0 -15
  32. package/src/components/alert/AlertTitle.astro +0 -17
  33. package/src/components/alert-dialog/AlertDialog.astro +0 -275
  34. package/src/components/alert-dialog/AlertDialogAction.astro +0 -46
  35. package/src/components/alert-dialog/AlertDialogCancel.astro +0 -46
  36. package/src/components/alert-dialog/AlertDialogContent.astro +0 -52
  37. package/src/components/alert-dialog/AlertDialogDescription.astro +0 -18
  38. package/src/components/alert-dialog/AlertDialogFooter.astro +0 -16
  39. package/src/components/alert-dialog/AlertDialogHeader.astro +0 -14
  40. package/src/components/alert-dialog/AlertDialogTitle.astro +0 -20
  41. package/src/components/alert-dialog/AlertDialogTrigger.astro +0 -47
  42. package/src/components/aspect-ratio/AspectRatio.astro +0 -32
  43. package/src/components/avatar/Avatar.astro +0 -29
  44. package/src/components/avatar/AvatarFallback.astro +0 -18
  45. package/src/components/avatar/AvatarImage.astro +0 -66
  46. package/src/components/badge/Badge.astro +0 -57
  47. package/src/components/breadcrumb/Breadcrumb.astro +0 -12
  48. package/src/components/breadcrumb/BreadcrumbEllipsis.astro +0 -29
  49. package/src/components/breadcrumb/BreadcrumbItem.astro +0 -15
  50. package/src/components/breadcrumb/BreadcrumbLink.astro +0 -24
  51. package/src/components/breadcrumb/BreadcrumbList.astro +0 -17
  52. package/src/components/breadcrumb/BreadcrumbPage.astro +0 -22
  53. package/src/components/breadcrumb/BreadcrumbSeparator.astro +0 -24
  54. package/src/components/button/Button.astro +0 -58
  55. package/src/components/button-group/ButtonGroup.astro +0 -64
  56. package/src/components/button-group/ButtonGroupSeparator.astro +0 -20
  57. package/src/components/button-group/ButtonGroupText.astro +0 -19
  58. package/src/components/card/Card.astro +0 -36
  59. package/src/components/card/CardAction.astro +0 -16
  60. package/src/components/card/CardContent.astro +0 -16
  61. package/src/components/card/CardDescription.astro +0 -16
  62. package/src/components/card/CardFooter.astro +0 -16
  63. package/src/components/card/CardHeader.astro +0 -19
  64. package/src/components/card/CardTitle.astro +0 -16
  65. package/src/components/carousel/Carousel.astro +0 -55
  66. package/src/components/carousel/CarouselContent.astro +0 -26
  67. package/src/components/carousel/CarouselItem.astro +0 -26
  68. package/src/components/carousel/CarouselNext.astro +0 -39
  69. package/src/components/carousel/CarouselPrevious.astro +0 -41
  70. package/src/components/carousel/carousel-script.ts +0 -188
  71. package/src/components/carousel/index.ts +0 -1
  72. package/src/components/checkbox/Checkbox.astro +0 -133
  73. package/src/components/collapsible/Collapsible.astro +0 -161
  74. package/src/components/collapsible/CollapsibleContent.astro +0 -22
  75. package/src/components/collapsible/CollapsibleTrigger.astro +0 -44
  76. package/src/components/dialog/Dialog.astro +0 -389
  77. package/src/components/dialog/DialogClose.astro +0 -35
  78. package/src/components/dialog/DialogContent.astro +0 -78
  79. package/src/components/dialog/DialogDescription.astro +0 -14
  80. package/src/components/dialog/DialogFooter.astro +0 -14
  81. package/src/components/dialog/DialogHeader.astro +0 -14
  82. package/src/components/dialog/DialogTitle.astro +0 -18
  83. package/src/components/dialog/DialogTrigger.astro +0 -47
  84. package/src/components/dropdown/Dropdown.astro +0 -604
  85. package/src/components/dropdown/DropdownContent.astro +0 -118
  86. package/src/components/dropdown/DropdownItem.astro +0 -48
  87. package/src/components/dropdown/DropdownLabel.astro +0 -29
  88. package/src/components/dropdown/DropdownSeparator.astro +0 -21
  89. package/src/components/dropdown/DropdownShortcut.astro +0 -17
  90. package/src/components/dropdown/DropdownSub.astro +0 -15
  91. package/src/components/dropdown/DropdownSubContent.astro +0 -39
  92. package/src/components/dropdown/DropdownSubTrigger.astro +0 -34
  93. package/src/components/dropdown/DropdownTrigger.astro +0 -52
  94. package/src/components/dropzone/Dropzone.astro +0 -236
  95. package/src/components/dropzone/DropzoneFilesList.astro +0 -26
  96. package/src/components/dropzone/DropzoneLoadingIndicator.astro +0 -10
  97. package/src/components/dropzone/DropzoneUploadIndicator.astro +0 -10
  98. package/src/components/embeds/YoutubeEmbed.astro +0 -94
  99. package/src/components/hero/Hero.astro +0 -166
  100. package/src/components/icons/Flag.astro +0 -62
  101. package/src/components/image/ExtendedImage.astro +0 -46
  102. package/src/components/image/Image.astro +0 -25
  103. package/src/components/input/Input.astro +0 -27
  104. package/src/components/input-group/InputGroup.astro +0 -28
  105. package/src/components/input-group/InputGroupAddon.astro +0 -76
  106. package/src/components/input-group/InputGroupButton.astro +0 -36
  107. package/src/components/input-group/InputGroupInput.astro +0 -18
  108. package/src/components/input-group/InputGroupText.astro +0 -17
  109. package/src/components/input-group/InputGroupTextarea.astro +0 -22
  110. package/src/components/input-otp/InputOtp.astro +0 -352
  111. package/src/components/input-otp/InputOtpGroup.astro +0 -16
  112. package/src/components/input-otp/InputOtpSeparator.astro +0 -25
  113. package/src/components/input-otp/InputOtpSlot.astro +0 -50
  114. package/src/components/input-otp/InputOtpTypes.ts +0 -6
  115. package/src/components/item/Item.astro +0 -52
  116. package/src/components/item/ItemActions.astro +0 -16
  117. package/src/components/item/ItemContent.astro +0 -16
  118. package/src/components/item/ItemDescription.astro +0 -19
  119. package/src/components/item/ItemFooter.astro +0 -16
  120. package/src/components/item/ItemGroup.astro +0 -16
  121. package/src/components/item/ItemHeader.astro +0 -16
  122. package/src/components/item/ItemMedia.astro +0 -40
  123. package/src/components/item/ItemSeparator.astro +0 -23
  124. package/src/components/item/ItemTitle.astro +0 -16
  125. package/src/components/kbd/Kbd.astro +0 -21
  126. package/src/components/kbd/KbdGroup.astro +0 -16
  127. package/src/components/label/Label.astro +0 -24
  128. package/src/components/marquee/Marquee.astro +0 -73
  129. package/src/components/native-select/NativeSelect.astro +0 -68
  130. package/src/components/native-select/NativeSelectOptGroup.astro +0 -15
  131. package/src/components/native-select/NativeSelectOption.astro +0 -15
  132. package/src/components/pagination/Pagination.astro +0 -20
  133. package/src/components/pagination/PaginationContent.astro +0 -16
  134. package/src/components/pagination/PaginationEllipsis.astro +0 -37
  135. package/src/components/pagination/PaginationItem.astro +0 -16
  136. package/src/components/pagination/PaginationLink.astro +0 -27
  137. package/src/components/pagination/PaginationNext.astro +0 -33
  138. package/src/components/pagination/PaginationPrevious.astro +0 -33
  139. package/src/components/popover/Popover.astro +0 -717
  140. package/src/components/popover/PopoverContent.astro +0 -102
  141. package/src/components/popover/PopoverDescription.astro +0 -14
  142. package/src/components/popover/PopoverHeader.astro +0 -14
  143. package/src/components/popover/PopoverTitle.astro +0 -14
  144. package/src/components/popover/PopoverTrigger.astro +0 -51
  145. package/src/components/progress/Progress.astro +0 -154
  146. package/src/components/prose/Prose.astro +0 -619
  147. package/src/components/radio-group/RadioGroup.astro +0 -162
  148. package/src/components/radio-group/RadioGroupItem.astro +0 -133
  149. package/src/components/radio-group/RadioGroupTypes.ts +0 -6
  150. package/src/components/section/Section.astro +0 -167
  151. package/src/components/select/Select.astro +0 -752
  152. package/src/components/select/SelectContent.astro +0 -94
  153. package/src/components/select/SelectGroup.astro +0 -9
  154. package/src/components/select/SelectItem.astro +0 -51
  155. package/src/components/select/SelectLabel.astro +0 -14
  156. package/src/components/select/SelectSearch.astro +0 -49
  157. package/src/components/select/SelectSeparator.astro +0 -12
  158. package/src/components/select/SelectTrigger.astro +0 -56
  159. package/src/components/select/SelectTypes.ts +0 -13
  160. package/src/components/select/SelectValue.astro +0 -19
  161. package/src/components/separator/Separator.astro +0 -36
  162. package/src/components/sheet/Sheet.astro +0 -15
  163. package/src/components/sheet/SheetClose.astro +0 -15
  164. package/src/components/sheet/SheetContent.astro +0 -89
  165. package/src/components/sheet/SheetDescription.astro +0 -16
  166. package/src/components/sheet/SheetFooter.astro +0 -16
  167. package/src/components/sheet/SheetHeader.astro +0 -16
  168. package/src/components/sheet/SheetTitle.astro +0 -16
  169. package/src/components/sheet/SheetTrigger.astro +0 -15
  170. package/src/components/sidebar/Sidebar.astro +0 -231
  171. package/src/components/sidebar/SidebarContent.astro +0 -25
  172. package/src/components/sidebar/SidebarFooter.astro +0 -22
  173. package/src/components/sidebar/SidebarGroup.astro +0 -22
  174. package/src/components/sidebar/SidebarGroupContent.astro +0 -22
  175. package/src/components/sidebar/SidebarGroupLabel.astro +0 -53
  176. package/src/components/sidebar/SidebarHeader.astro +0 -22
  177. package/src/components/sidebar/SidebarInput.astro +0 -24
  178. package/src/components/sidebar/SidebarInset.astro +0 -22
  179. package/src/components/sidebar/SidebarMenu.astro +0 -22
  180. package/src/components/sidebar/SidebarMenuAction.astro +0 -63
  181. package/src/components/sidebar/SidebarMenuBadge.astro +0 -31
  182. package/src/components/sidebar/SidebarMenuButton.astro +0 -124
  183. package/src/components/sidebar/SidebarMenuItem.astro +0 -22
  184. package/src/components/sidebar/SidebarMenuSkeleton.astro +0 -43
  185. package/src/components/sidebar/SidebarMenuSub.astro +0 -25
  186. package/src/components/sidebar/SidebarMenuSubButton.astro +0 -52
  187. package/src/components/sidebar/SidebarMenuSubItem.astro +0 -17
  188. package/src/components/sidebar/SidebarProvider.astro +0 -215
  189. package/src/components/sidebar/SidebarRail.astro +0 -72
  190. package/src/components/sidebar/SidebarSeparator.astro +0 -25
  191. package/src/components/sidebar/SidebarTrigger.astro +0 -69
  192. package/src/components/skeleton/Skeleton.astro +0 -14
  193. package/src/components/slider/Slider.astro +0 -425
  194. package/src/components/spinner/Spinner.astro +0 -23
  195. package/src/components/switch/Switch.astro +0 -192
  196. package/src/components/switch/SwitchTypes.ts +0 -6
  197. package/src/components/table/Table.astro +0 -20
  198. package/src/components/table/TableBody.astro +0 -18
  199. package/src/components/table/TableCaption.astro +0 -18
  200. package/src/components/table/TableCell.astro +0 -18
  201. package/src/components/table/TableFoot.astro +0 -18
  202. package/src/components/table/TableHead.astro +0 -18
  203. package/src/components/table/TableHeader.astro +0 -18
  204. package/src/components/table/TableRow.astro +0 -17
  205. package/src/components/tabs/Tabs.astro +0 -270
  206. package/src/components/tabs/TabsContent.astro +0 -28
  207. package/src/components/tabs/TabsList.astro +0 -23
  208. package/src/components/tabs/TabsTrigger.astro +0 -34
  209. package/src/components/textarea/Textarea.astro +0 -31
  210. package/src/components/toast/ToastDescription.astro +0 -22
  211. package/src/components/toast/ToastItem.astro +0 -56
  212. package/src/components/toast/ToastTemplate.astro +0 -27
  213. package/src/components/toast/ToastTitle.astro +0 -59
  214. package/src/components/toast/Toaster.astro +0 -981
  215. package/src/components/toast/index.ts +0 -1
  216. package/src/components/toast/toast-manager.ts +0 -234
  217. package/src/components/toggle/Toggle.astro +0 -174
  218. package/src/components/toggle/ToggleTypes.ts +0 -14
  219. package/src/components/tooltip/Tooltip.astro +0 -422
  220. package/src/components/tooltip/TooltipContent.astro +0 -83
  221. package/src/components/tooltip/TooltipTrigger.astro +0 -13
  222. package/src/components/video/Video.astro +0 -121
  223. package/src/config/cookies.ts +0 -5
  224. package/src/config/links.ts +0 -4
  225. package/src/domain/cms/index.ts +0 -1
  226. package/src/domain/cms/types.ts +0 -20
  227. package/src/domain/i18n/constants.ts +0 -21
  228. package/src/domain/i18n/cookie-storage.ts +0 -13
  229. package/src/domain/i18n/country-to-locale-map.ts +0 -67
  230. package/src/domain/i18n/fallbacks.generated.ts +0 -230
  231. package/src/domain/i18n/fetcher.ts +0 -278
  232. package/src/domain/i18n/flags.ts +0 -16
  233. package/src/domain/i18n/format.ts +0 -90
  234. package/src/domain/i18n/index.ts +0 -10
  235. package/src/domain/i18n/middleware/i18n.ts +0 -161
  236. package/src/domain/i18n/resolve-locale.ts +0 -55
  237. package/src/domain/i18n/runtime-constants.ts +0 -14
  238. package/src/domain/i18n/schema.ts +0 -29
  239. package/src/domain/index.ts +0 -4
  240. package/src/domain/seo/constants.ts +0 -6
  241. package/src/domain/seo/index.ts +0 -3
  242. package/src/domain/seo/services/index.ts +0 -3
  243. package/src/domain/seo/services/llms.ts +0 -56
  244. package/src/domain/seo/services/robots.ts +0 -12
  245. package/src/domain/seo/services/sitemap.ts +0 -56
  246. package/src/domain/seo/utils.ts +0 -36
  247. package/src/domain/theme/constants.ts +0 -6
  248. package/src/domain/theme/index.ts +0 -2
  249. package/src/domain/theme/schema.ts +0 -10
  250. package/src/i18n.generated.d.ts +0 -202
  251. package/src/lib/component-preview.ts +0 -73
  252. package/src/lib/index.ts +0 -6
  253. package/src/lib/remark/remark-modified-time.ts +0 -13
  254. package/src/lib/showcase-preview-elements.ts +0 -408
  255. package/src/lib/showcase-renderer.ts +0 -218
  256. package/src/lib/showcase-utils.ts +0 -189
  257. package/src/lib/turnstile.ts +0 -35
  258. package/src/lib/utils/starwind/positioning.ts +0 -318
  259. package/src/locales/de/blog.json +0 -9
  260. package/src/locales/de/common.json +0 -19
  261. package/src/locales/de/errors.json +0 -6
  262. package/src/locales/de/home.json +0 -20
  263. package/src/locales/de/messages.json +0 -8
  264. package/src/locales/de/nav.json +0 -13
  265. package/src/locales/de/projects.json +0 -9
  266. package/src/locales/de/services.json +0 -43
  267. package/src/locales/en/blog.json +0 -9
  268. package/src/locales/en/chat.json +0 -29
  269. package/src/locales/en/common.json +0 -19
  270. package/src/locales/en/cookie_notice.json +0 -11
  271. package/src/locales/en/editor.json +0 -24
  272. package/src/locales/en/errors.json +0 -6
  273. package/src/locales/en/home.json +0 -20
  274. package/src/locales/en/messages.json +0 -8
  275. package/src/locales/en/nav.json +0 -13
  276. package/src/locales/en/projects.json +0 -9
  277. package/src/locales/en/services.json +0 -43
  278. package/src/locales/es/blog.json +0 -9
  279. package/src/locales/es/common.json +0 -19
  280. package/src/locales/es/errors.json +0 -6
  281. package/src/locales/es/home.json +0 -20
  282. package/src/locales/es/messages.json +0 -8
  283. package/src/locales/es/nav.json +0 -13
  284. package/src/locales/es/projects.json +0 -9
  285. package/src/locales/es/services.json +0 -43
  286. package/src/locales/ja/blog.json +0 -9
  287. package/src/locales/ja/common.json +0 -19
  288. package/src/locales/ja/errors.json +0 -6
  289. package/src/locales/ja/home.json +0 -20
  290. package/src/locales/ja/messages.json +0 -8
  291. package/src/locales/ja/nav.json +0 -13
  292. package/src/locales/ja/projects.json +0 -9
  293. package/src/locales/ja/services.json +0 -43
  294. package/src/locales/pt/blog.json +0 -9
  295. package/src/locales/pt/chat.json +0 -29
  296. package/src/locales/pt/common.json +0 -19
  297. package/src/locales/pt/cookie_notice.json +0 -11
  298. package/src/locales/pt/editor.json +0 -24
  299. package/src/locales/pt/errors.json +0 -6
  300. package/src/locales/pt/home.json +0 -20
  301. package/src/locales/pt/messages.json +0 -8
  302. package/src/locales/pt/nav.json +0 -13
  303. package/src/locales/pt/projects.json +0 -9
  304. package/src/locales/pt/services.json +0 -43
  305. package/src/utils/server/cookies.ts +0 -98
  306. package/src/utils/server/index.ts +0 -1
  307. package/src/utils/shared/index.ts +0 -3
  308. /package/src/utils/{shared/deep-merge.ts → deep-merge.ts} +0 -0
  309. /package/src/utils/{shared/embed.ts → embed.ts} +0 -0
  310. /package/src/utils/{shared/parse-boolean.ts → parse-boolean.ts} +0 -0
@@ -1,34 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { cv } from "css-variants";
4
-
5
- type VariantProps<T extends (...args: any) => any> = NonNullable<Parameters<T>[0]>;
6
-
7
- export interface AlertProps extends HTMLAttributes<"div">, VariantProps<typeof alert> {}
8
- type Props = AlertProps;
9
-
10
- export const alert = cv({
11
- base: "text-foreground relative w-full rounded-lg b p-2xs",
12
- variants: {
13
- variant: {
14
- default: "bg-background dark:bg-input/30 [&>h5>svg]:text-foreground",
15
- primary: "border-primary bg-primary/7 [&>h5>svg]:text-primary",
16
- secondary: "border-secondary bg-secondary/7 [&>h5>svg]:text-secondary",
17
- info: "border-info bg-info/7 [&>h5>svg]:text-info",
18
- success: "border-success bg-success/7 [&>h5>svg]:text-success",
19
- warning: "border-warning bg-warning/7 [&>h5>svg]:text-warning",
20
- error: "border-error bg-error/7 [&>h5>svg]:text-error",
21
- },
22
- },
23
- defaultVariants: { variant: "default" },
24
- });
25
-
26
- const { variant, class: className, ...rest } = Astro.props;
27
-
28
- const inferredRole =
29
- rest.role ?? (variant === "error" || variant === "warning" ? "alert" : "status");
30
- ---
31
-
32
- <div class:list={[alert({ variant }), className]} role={inferredRole} {...rest} data-slot="alert">
33
- <slot />
34
- </div>
@@ -1,15 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { cv } from "css-variants";
4
-
5
- export const alertDescription = cv({ base: "leading-relaxed" });
6
-
7
- export interface AlertDescriptionProps extends HTMLAttributes<"p"> {}
8
- type Props = AlertDescriptionProps;
9
-
10
- const { class: className, ...rest } = Astro.props;
11
- ---
12
-
13
- <p class:list={[alertDescription(), className]} {...rest} data-slot="alert-description">
14
- <slot />
15
- </p>
@@ -1,17 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { cv } from "css-variants";
4
-
5
- export const alertTitle = cv({
6
- base: "font-heading mb-3xs flex items-center gap-3xs text-lg leading-none font-medium tracking-tight",
7
- });
8
-
9
- export interface AlertTitleProps extends HTMLAttributes<"h5"> {}
10
- type Props = AlertTitleProps;
11
-
12
- const { class: className, ...rest } = Astro.props;
13
- ---
14
-
15
- <h5 class:list={[alertTitle(), className]} {...rest} data-slot="alert-title">
16
- <slot />
17
- </h5>
@@ -1,275 +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-alert-dialog", className]} {...rest} data-slot="alert-dialog">
10
- <slot />
11
- </div>
12
-
13
- <script>
14
- class AlertDialogHandler {
15
- private triggers: HTMLButtonElement[] = [];
16
- private dialog: HTMLDialogElement | null = null;
17
- private closeButtons: HTMLButtonElement[] = [];
18
- private actionButtons: HTMLButtonElement[] = [];
19
- private backdrop: HTMLElement | null = null;
20
- private dialogId: string;
21
- /**
22
- * The duration of the animation in milliseconds. This is used to calculate the
23
- * duration of close animation before hiding the dialog and backdrop
24
- */
25
- private animationDuration: number;
26
-
27
- constructor(dialogWrapper: HTMLElement, dialogNumber: number) {
28
- this.dialog = dialogWrapper.querySelector("dialog");
29
- this.backdrop = dialogWrapper.querySelector(".starwind-alert-dialog-backdrop");
30
- if (!this.dialog || !this.backdrop) {
31
- throw new Error("AlertDialog: dialog or backdrop not found");
32
- }
33
-
34
- // if no ID was provided for the wrapper, generate one
35
- if (dialogWrapper.id) {
36
- this.dialogId = dialogWrapper.id;
37
- } else {
38
- this.dialogId = `starwind-alert-dialog${dialogNumber}`;
39
- dialogWrapper.id = this.dialogId;
40
- }
41
-
42
- // animationDuration is set with inline styles through passed prop to DialogContent
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 = 200;
51
- }
52
-
53
- // Find internal triggers and handle them
54
- const internalTriggers = dialogWrapper.querySelectorAll(".starwind-alert-dialog-trigger");
55
- internalTriggers.forEach((triggerElement) => {
56
- const tempTrigger = triggerElement as HTMLElement;
57
- let trigger: HTMLButtonElement;
58
-
59
- if (tempTrigger?.hasAttribute("data-as-child")) {
60
- trigger = tempTrigger.firstElementChild as HTMLButtonElement;
61
- } else {
62
- trigger = tempTrigger as HTMLButtonElement;
63
- }
64
-
65
- if (trigger) {
66
- this.triggers.push(trigger);
67
- }
68
- });
69
-
70
- // Find external triggers that target this dialog
71
- this.findExternalTriggers();
72
-
73
- // if closeButtons are set with asChild, swap the wrapper with its first child
74
- const tempCloseButtons = dialogWrapper.querySelectorAll(
75
- ".starwind-alert-dialog-close",
76
- ) as NodeListOf<HTMLElement>;
77
- tempCloseButtons.forEach((button: HTMLElement) => {
78
- if (button.hasAttribute("data-as-child")) {
79
- const childElement = button.firstElementChild;
80
- if (childElement) {
81
- childElement.classList.add("starwind-alert-dialog-close");
82
- button.parentNode?.replaceChild(childElement, button);
83
- }
84
- }
85
- return button;
86
- });
87
-
88
- // Convert NodeList to Array for consistency with triggers
89
- this.closeButtons = Array.from(
90
- dialogWrapper.querySelectorAll(".starwind-alert-dialog-close"),
91
- ) as HTMLButtonElement[];
92
-
93
- // if actionButtons are set with asChild, swap the wrapper with its first child
94
- const tempActionButtons = dialogWrapper.querySelectorAll(
95
- ".starwind-alert-dialog-action",
96
- ) as NodeListOf<HTMLElement>;
97
- tempActionButtons.forEach((button: HTMLElement) => {
98
- if (button.hasAttribute("data-as-child")) {
99
- const childElement = button.firstElementChild;
100
- if (childElement) {
101
- childElement.classList.add("starwind-alert-dialog-action");
102
- button.parentNode?.replaceChild(childElement, button);
103
- }
104
- }
105
- return button;
106
- });
107
-
108
- // Convert NodeList to Array for consistency with triggers
109
- this.actionButtons = Array.from(
110
- dialogWrapper.querySelectorAll(".starwind-alert-dialog-action"),
111
- ) as HTMLButtonElement[];
112
-
113
- // if essential elements are not there, exit
114
- if (!this.dialog || !this.backdrop) return;
115
-
116
- this.setupAccessibility(dialogNumber);
117
- this.setupEvents();
118
- }
119
-
120
- private setupAccessibility(dialogNumber: number): void {
121
- // get the first heading element in the dialog
122
- const firstHeading = this.dialog?.querySelector("h1, h2, h3, h4, h5, h6");
123
- if (firstHeading) {
124
- // create a unique ID for the heading
125
- firstHeading.id = `starwind-alert-dialog${dialogNumber}-heading`;
126
- // set the aria-labelledby attribute to the first heading element
127
- this.dialog?.setAttribute("aria-labelledby", firstHeading.id);
128
- }
129
- }
130
-
131
- /**
132
- * Find all external triggers that target this dialog
133
- */
134
- private findExternalTriggers(): void {
135
- const externalTriggers = document.querySelectorAll(
136
- `.starwind-alert-dialog-trigger[data-dialog-for="${this.dialogId}"]`,
137
- );
138
-
139
- externalTriggers.forEach((triggerElement) => {
140
- // Skip if this is an internal trigger we already processed
141
- const dialogWrapper = triggerElement.closest(".starwind-alert-dialog");
142
- if (dialogWrapper && dialogWrapper.id === this.dialogId) {
143
- return;
144
- }
145
-
146
- let trigger: HTMLButtonElement;
147
- if (triggerElement.hasAttribute("data-as-child")) {
148
- trigger = triggerElement.firstElementChild as HTMLButtonElement;
149
- } else {
150
- trigger = triggerElement as HTMLButtonElement;
151
- }
152
-
153
- if (trigger && !this.triggers.includes(trigger)) {
154
- this.triggers.push(trigger);
155
- }
156
- });
157
- }
158
-
159
- private setupEvents(): void {
160
- if (!this.dialog) return;
161
- // Add click listeners to all triggers
162
- this.triggers.forEach((trigger) => {
163
- trigger.addEventListener("click", () => {
164
- this.open();
165
- });
166
- });
167
-
168
- // Add click handlers to all close buttons
169
- this.closeButtons.forEach((button) => {
170
- button.addEventListener("click", () => {
171
- // Only close if this is the topmost dialog
172
- const openDialogs = document.querySelectorAll("dialog[open]");
173
- if (openDialogs.length > 0 && openDialogs[openDialogs.length - 1] === this.dialog) {
174
- this.close();
175
- }
176
- });
177
- });
178
-
179
- // Add click handlers to all action buttons
180
- this.actionButtons.forEach((button) => {
181
- button.addEventListener("click", () => {
182
- // Only close if this is the topmost dialog
183
- const openDialogs = document.querySelectorAll("dialog[open]");
184
- if (openDialogs.length > 0 && openDialogs[openDialogs.length - 1] === this.dialog) {
185
- this.close();
186
- }
187
- });
188
- });
189
-
190
- // Handle escape key
191
- this.dialog.addEventListener("keydown", (e) => {
192
- if (e.key === "Escape") {
193
- // prevent default dialog closing behavior so we can add closing animation
194
- e.preventDefault();
195
- // Only close if this is the topmost dialog
196
- const openDialogs = document.querySelectorAll("dialog[open]");
197
- if (openDialogs.length > 0 && openDialogs[openDialogs.length - 1] === this.dialog) {
198
- this.close();
199
- }
200
- }
201
- });
202
-
203
- // Intercept form submissions to handle dialog close
204
- const forms = this.dialog.querySelectorAll("form");
205
- forms.forEach((form) => {
206
- form.addEventListener("submit", (e) => {
207
- /**
208
- * Default form.method = "dialog" submissions cause the dialog to close
209
- * Default form.method = "post" submissions do not close the dialog
210
- * Here we intercept the form submission and manage the dialog closing if method = "dialog"
211
- * so we can add closing animation
212
- * Normal form event listeners for "submit" will still get the form data
213
- */
214
- if (form.method === "dialog") {
215
- e.preventDefault();
216
- // Only close if this is the topmost dialog
217
- const openDialogs = document.querySelectorAll("dialog[open]");
218
- if (openDialogs.length > 0 && openDialogs[openDialogs.length - 1] === this.dialog) {
219
- this.close();
220
- }
221
- }
222
- });
223
- });
224
- }
225
-
226
- private open(): void {
227
- if (!this.dialog || !this.backdrop) return;
228
- this.dialog.showModal();
229
- document.body.classList.add("overflow-hidden");
230
- this.backdrop.classList.remove("hidden");
231
- this.backdrop.dataset.state = "open";
232
- this.dialog.dataset.state = "open";
233
- }
234
-
235
- private close(): void {
236
- if (!this.dialog || !this.backdrop) return;
237
- this.dialog.dataset.state = "closed";
238
- this.backdrop.dataset.state = "closed";
239
-
240
- // Wait for animation to finish before hiding backdrop
241
- setTimeout(() => {
242
- this.backdrop?.classList.add("hidden");
243
- this.dialog?.close();
244
- const stillOpen = document.querySelectorAll("dialog[open]").length;
245
- if (stillOpen === 0) {
246
- document.body.classList.remove("overflow-hidden");
247
- }
248
- }, this.animationDuration);
249
- }
250
- }
251
-
252
- // Store instances in a WeakMap to avoid memory leaks
253
- const alertDialogInstances = new WeakMap<HTMLElement, AlertDialogHandler>();
254
- let alertDialogCounter = 0;
255
-
256
- // Initialize all dialogs
257
- const setupAlertDialogs = () => {
258
- document.querySelectorAll(".starwind-alert-dialog").forEach((dialogWrapper) => {
259
- const wrapper = dialogWrapper as HTMLElement;
260
- if (!alertDialogInstances.has(wrapper)) {
261
- alertDialogInstances.set(wrapper, new AlertDialogHandler(wrapper, alertDialogCounter++));
262
- }
263
- });
264
- };
265
-
266
- setupAlertDialogs();
267
- document.addEventListener("astro:after-swap", setupAlertDialogs);
268
- document.addEventListener("starwind:init", setupAlertDialogs);
269
- </script>
270
-
271
- <style>
272
- .overflow-hidden {
273
- overflow: hidden;
274
- }
275
- </style>
@@ -1,46 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
-
4
- import { button } from "../button/Button.astro";
5
-
6
- type Props = HTMLAttributes<"button"> & {
7
- /**
8
- * When true, the component will render its child element instead of a button
9
- */
10
- asChild?: boolean;
11
- };
12
-
13
- const { class: className, asChild = false, ...rest } = Astro.props;
14
-
15
- // Get the first child element if asChild is true
16
- let hasChildren = false;
17
- if (Astro.slots.has("default")) {
18
- hasChildren = true;
19
- }
20
- ---
21
-
22
- {
23
- asChild && hasChildren ? (
24
- <div
25
- class:list={["starwind-alert-dialog-action", className]}
26
- data-slot="alert-dialog-action"
27
- data-as-child
28
- >
29
- <slot />
30
- </div>
31
- ) : (
32
- <button
33
- type="button"
34
- class:list={[
35
- button({ variant: "default" }),
36
- "starwind-alert-dialog-action",
37
- className,
38
- ]}
39
- {...rest}
40
- data-slot="alert-dialog-action"
41
- >
42
- <slot />
43
- </button>
44
- )
45
- }
46
-
@@ -1,46 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
-
4
- import { button } from "../button/Button.astro";
5
-
6
- type Props = HTMLAttributes<"button"> & {
7
- /**
8
- * When true, the component will render its child element instead of a button
9
- */
10
- asChild?: boolean;
11
- };
12
-
13
- const { class: className, asChild = false, ...rest } = Astro.props;
14
-
15
- // Get the first child element if asChild is true
16
- let hasChildren = false;
17
- if (Astro.slots.has("default")) {
18
- hasChildren = true;
19
- }
20
- ---
21
-
22
- {
23
- asChild && hasChildren ? (
24
- <div
25
- class:list={["starwind-alert-dialog-close", className]}
26
- data-slot="alert-dialog-cancel"
27
- data-as-child
28
- >
29
- <slot />
30
- </div>
31
- ) : (
32
- <button
33
- type="button"
34
- class:list={[
35
- button({ variant: "outline" }),
36
- "starwind-alert-dialog-close",
37
- className,
38
- ]}
39
- {...rest}
40
- data-slot="alert-dialog-cancel"
41
- >
42
- <slot />
43
- </button>
44
- )
45
- }
46
-
@@ -1,52 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { cv } from "css-variants";
4
-
5
- type Props = HTMLAttributes<"dialog"> & {
6
- /**
7
- * Open and close animation duration in milliseconds
8
- */
9
- animationDuration?: number;
10
- };
11
-
12
- export const alertDialogBackdrop = cv({
13
- base: [
14
- "starwind-alert-dialog-backdrop fixed inset-0 z-50 hidden bg-black/50",
15
- "data-[state=open]:animate-in fade-in",
16
- "data-[state=closed]:animate-out data-[state=closed]:fill-mode-forwards fade-out",
17
- ],
18
- });
19
-
20
- export const alertDialogContent = cv({
21
- base: [
22
- "bg-background space-y-4 rounded-lg b p-xl shadow-lg sm:max-w-lg",
23
- "fixed top-[50%] left-[50%] z-50 w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%]",
24
- "data-[state=open]:animate-in fade-in zoom-in-95 will-change-transform",
25
- "data-[state=closed]:animate-out data-[state=closed]:fill-mode-forwards fade-out zoom-out-95",
26
- ],
27
- });
28
-
29
- const { class: className, animationDuration = 200, ...rest } = Astro.props;
30
- ---
31
-
32
- <!-- dialog overlay -->
33
- <slot name="backdrop">
34
- <div
35
- class={alertDialogBackdrop()}
36
- data-state="closed"
37
- style={{ animationDuration: `${animationDuration}ms` }}
38
- data-slot="alert-dialog-backdrop"
39
- >
40
- </div>
41
- </slot>
42
-
43
- <dialog
44
- class:list={[alertDialogContent(), className]}
45
- data-state="closed"
46
- role="alertdialog"
47
- style={{ animationDuration: `${animationDuration}ms` }}
48
- {...rest}
49
- data-slot="alert-dialog-content"
50
- >
51
- <slot />
52
- </dialog>
@@ -1,18 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { cv } from "css-variants";
4
-
5
- type Props = HTMLAttributes<"p">;
6
-
7
- export const alertDialogDescription = cv({ base: "text-muted-foreground" });
8
-
9
- const { class: className, ...rest } = Astro.props;
10
- ---
11
-
12
- <p
13
- class:list={[alertDialogDescription(), className]}
14
- {...rest}
15
- data-slot="alert-dialog-description"
16
- >
17
- <slot />
18
- </p>
@@ -1,16 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { cv } from "css-variants";
4
-
5
- type Props = HTMLAttributes<"div">;
6
-
7
- export const alertDialogFooter = cv({
8
- base: "flex flex-col-reverse gap-3xs sm:flex-row sm:justify-end",
9
- });
10
-
11
- const { class: className, ...rest } = Astro.props;
12
- ---
13
-
14
- <div class:list={[alertDialogFooter(), className]} {...rest} data-slot="alert-dialog-footer">
15
- <slot />
16
- </div>
@@ -1,14 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { cv } from "css-variants";
4
-
5
- type Props = HTMLAttributes<"div">;
6
-
7
- export const alertDialogHeader = cv({ base: "flex flex-col gap-3xs text-center sm:text-left" });
8
-
9
- const { class: className, ...rest } = Astro.props;
10
- ---
11
-
12
- <div class:list={[alertDialogHeader(), className]} {...rest} data-slot="alert-dialog-header">
13
- <slot />
14
- </div>
@@ -1,20 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { cv } from "css-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 alertDialogTitle = cv({ base: "font-heading text-xl font-semibold" });
14
-
15
- const { class: className, ...rest } = Astro.props;
16
- ---
17
-
18
- <h2 class:list={[alertDialogTitle(), className]} {...rest} data-slot="alert-dialog-title">
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-alert-dialog-trigger", className]}
29
- data-slot="alert-dialog-trigger"
30
- data-dialog-for={dialogFor}
31
- data-as-child
32
- >
33
- <slot />
34
- </div>
35
- ) : (
36
- <button
37
- type="button"
38
- aria-haspopup="dialog"
39
- class:list={["starwind-alert-dialog-trigger", className]}
40
- data-dialog-for={dialogFor}
41
- {...rest}
42
- data-slot="alert-dialog-trigger"
43
- >
44
- <slot />
45
- </button>
46
- )
47
- }
@@ -1,32 +0,0 @@
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
- * The aspect ratio of the container (e.g., 16/9, 4/3, 1)
8
- * @default 1
9
- */
10
- ratio?: number;
11
- };
12
-
13
- export const aspectRatioWrapper = cv({
14
- base: "relative w-full",
15
- });
16
-
17
- export const aspectRatio = cv({
18
- base: "absolute inset-0",
19
- });
20
-
21
- const { ratio = 1, class: className, as: Tag = "div", ...rest } = Astro.props;
22
- ---
23
-
24
- <div
25
- class={aspectRatioWrapper()}
26
- style={`padding-bottom: ${100 / ratio}%`}
27
- data-slot="aspect-ratio-wrapper"
28
- >
29
- <Tag class:list={[aspectRatio(), className]} data-slot="aspect-ratio" {...rest}>
30
- <slot />
31
- </Tag>
32
- </div>
@@ -1,29 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { cv } from "css-variants";
4
-
5
- interface Props extends HTMLAttributes<"div">, NonNullable<Parameters<typeof avatar>[0]> {}
6
-
7
- export const avatar = cv({
8
- base: "text-foreground bg-muted relative overflow-hidden rounded-full border-2",
9
- variants: {
10
- variant: {
11
- default: "border-border",
12
- primary: "border-primary",
13
- secondary: "border-secondary",
14
- info: "border-info",
15
- success: "border-success",
16
- warning: "border-warning",
17
- error: "border-error",
18
- },
19
- size: { sm: "h-2xl w-2xl text-xs", md: "h-3xl w-3xl text-sm", lg: "h-3xl w-3xl text-base" },
20
- },
21
- defaultVariants: { variant: "default", size: "md" },
22
- });
23
-
24
- const { variant, size, class: className, ...rest } = Astro.props;
25
- ---
26
-
27
- <figure class:list={[avatar({ variant, size }), className]} {...rest} data-slot="avatar">
28
- <slot />
29
- </figure>