@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,425 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { scv } from "css-variants";
4
-
5
- export const slider = scv({
6
- slots: ["root", "control", "track", "range", "thumb"],
7
- base: {
8
- root: "starwind-slider relative flex w-full touch-none items-center select-none data-[disabled]:op-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:w-auto",
9
- control:
10
- "starwind-slider-control relative w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-auto",
11
- track:
12
- "starwind-slider-track bg-muted relative overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5",
13
- range:
14
- "starwind-slider-range absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full",
15
- thumb:
16
- "starwind-slider-thumb absolute block size-4 shrink-0 rounded-full b bg-white shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:op-50 data-[orientation=horizontal]:top-1/2 data-[orientation=horizontal]:-translate-x-1/2 data-[orientation=horizontal]:-translate-y-1/2 data-[orientation=vertical]:left-1/2 data-[orientation=vertical]:-translate-x-1/2 data-[orientation=vertical]:translate-y-1/2",
17
- },
18
- variants: {
19
- variant: {
20
- default: {
21
- range: "bg-foreground",
22
- thumb: "border-foreground ring-outline/50",
23
- },
24
- primary: {
25
- range: "bg-primary",
26
- thumb: "border-primary ring-primary/50",
27
- },
28
- secondary: {
29
- range: "bg-secondary",
30
- thumb: "border-secondary ring-secondary/50",
31
- },
32
- info: {
33
- range: "bg-info",
34
- thumb: "border-info ring-info/50",
35
- },
36
- success: {
37
- range: "bg-success",
38
- thumb: "border-success ring-success/50",
39
- },
40
- warning: {
41
- range: "bg-warning",
42
- thumb: "border-warning ring-warning/50",
43
- },
44
- error: {
45
- range: "bg-error",
46
- thumb: "border-error ring-error/50",
47
- },
48
- },
49
- },
50
- defaultVariants: {
51
- variant: "default",
52
- },
53
- });
54
-
55
- type Variant = "default" | "primary" | "secondary" | "info" | "success" | "warning" | "error";
56
-
57
- type Props = HTMLAttributes<"div"> & {
58
- defaultValue?: number | number[];
59
- value?: number | number[];
60
- min?: number;
61
- max?: number;
62
- step?: number;
63
- largeStep?: number;
64
- orientation?: "horizontal" | "vertical";
65
- disabled?: boolean;
66
- name?: string;
67
- variant?: Variant;
68
- "aria-label"?: string;
69
- "aria-labelledby"?: string;
70
- };
71
-
72
- const {
73
- class: className,
74
- defaultValue = 0,
75
- value,
76
- min = 0,
77
- max = 100,
78
- step = 1,
79
- largeStep = 10,
80
- orientation = "horizontal",
81
- disabled = false,
82
- name,
83
- variant = "default",
84
- "aria-label": ariaLabel,
85
- "aria-labelledby": ariaLabelledby,
86
- ...rest
87
- } = Astro.props;
88
-
89
- const { root, control, track, range, thumb } = slider({ variant });
90
-
91
- const initialValue = value ?? defaultValue ?? min;
92
- const values = Array.isArray(initialValue) ? initialValue : [initialValue];
93
- const isRange = values.length > 1;
94
-
95
- function getPercentage(val: number): number {
96
- return ((val - min) / (max - min)) * 100;
97
- }
98
-
99
- const rangeStart = isRange ? getPercentage(Math.min(...(values as number[]))) : 0;
100
- const rangeEnd = isRange
101
- ? getPercentage(Math.max(...(values as number[])))
102
- : getPercentage((values[0] as number) ?? min);
103
- ---
104
-
105
- <div
106
- class:list={[root, className]}
107
- data-orientation={orientation}
108
- data-disabled={disabled ? "" : undefined}
109
- role="group"
110
- aria-labelledby={ariaLabelledby}
111
- data-min={min}
112
- data-max={max}
113
- data-step={step}
114
- data-large-step={largeStep}
115
- {...rest}
116
- data-slot="slider"
117
- >
118
- <div class={control} data-slot="slider-control" data-orientation={orientation}>
119
- <div class={track} data-slot="slider-track" data-orientation={orientation}>
120
- <div
121
- class={range}
122
- data-slot="slider-range"
123
- data-orientation={orientation}
124
- style={orientation === "horizontal"
125
- ? `left: ${rangeStart}%; width: ${rangeEnd - rangeStart}%`
126
- : `bottom: ${rangeStart}%; height: ${rangeEnd - rangeStart}%`}
127
- >
128
- </div>
129
- </div>
130
- {
131
- values.map((val, index) => (
132
- <div
133
- class={thumb}
134
- data-slot="slider-thumb"
135
- data-index={index}
136
- data-orientation={orientation}
137
- style={
138
- orientation === "horizontal"
139
- ? `left: ${getPercentage(val)}%`
140
- : `bottom: ${getPercentage(val)}%`
141
- }
142
- tabindex={disabled ? -1 : 0}
143
- role="slider"
144
- aria-label={ariaLabel}
145
- aria-valuemin={min}
146
- aria-valuemax={max}
147
- aria-valuenow={val}
148
- aria-orientation={orientation}
149
- aria-disabled={disabled}
150
- >
151
- <input
152
- type="range"
153
- min={min}
154
- max={max}
155
- step={step}
156
- value={val}
157
- name={name ? (isRange ? `${name}[${index}]` : name) : undefined}
158
- disabled={disabled}
159
- tabindex={-1}
160
- aria-hidden="true"
161
- class="sr-only"
162
- />
163
- </div>
164
- ))
165
- }
166
- </div>
167
- </div>
168
-
169
- <script>
170
- class StarwindSlider {
171
- private root: HTMLElement;
172
- private track: HTMLElement;
173
- private range: HTMLElement;
174
- private thumbs: HTMLElement[];
175
- private inputs: HTMLInputElement[];
176
- private min: number;
177
- private max: number;
178
- private step: number;
179
- private largeStep: number;
180
- private orientation: "horizontal" | "vertical";
181
- private disabled: boolean;
182
- private values: number[];
183
- private activeThumbIndex: number = -1;
184
- private dragging: boolean = false;
185
-
186
- constructor(root: HTMLElement) {
187
- this.root = root;
188
- this.track = root.querySelector('[data-slot="slider-track"]')!;
189
- this.range = root.querySelector('[data-slot="slider-range"]')!;
190
- this.thumbs = Array.from(root.querySelectorAll('[data-slot="slider-thumb"]'));
191
- this.inputs = Array.from(root.querySelectorAll('input[type="range"]'));
192
-
193
- this.min = Number(root.dataset.min) || 0;
194
- this.max = Number(root.dataset.max) || 100;
195
- this.step = Number(root.dataset.step) || 1;
196
- this.largeStep = Number(root.dataset.largeStep) || 10;
197
- this.orientation = (root.dataset.orientation as "horizontal" | "vertical") || "horizontal";
198
- this.disabled = root.hasAttribute("data-disabled");
199
-
200
- this.values = this.inputs.map((input) => Number(input.value));
201
-
202
- this.init();
203
- }
204
-
205
- private init(): void {
206
- if (this.disabled) return;
207
-
208
- this.thumbs.forEach((thumb, index) => {
209
- thumb.addEventListener("pointerdown", (e) => this.handleThumbPointerDown(e, index));
210
- thumb.addEventListener("keydown", (e) => this.handleKeyDown(e, index));
211
- thumb.addEventListener("focus", () => this.handleFocus(index));
212
- thumb.addEventListener("blur", () => this.handleBlur());
213
- });
214
-
215
- this.track.addEventListener("pointerdown", (e) => this.handleTrackClick(e));
216
-
217
- document.addEventListener("pointermove", (e) => this.handlePointerMove(e));
218
- document.addEventListener("pointerup", () => this.handlePointerUp());
219
- }
220
-
221
- private getPercentage(val: number): number {
222
- return ((val - this.min) / (this.max - this.min)) * 100;
223
- }
224
-
225
- private getValueFromPosition(clientX: number, clientY: number): number {
226
- const rect = this.track.getBoundingClientRect();
227
- let percentage: number;
228
-
229
- if (this.orientation === "horizontal") {
230
- percentage = (clientX - rect.left) / rect.width;
231
- } else {
232
- percentage = 1 - (clientY - rect.top) / rect.height;
233
- }
234
-
235
- percentage = Math.max(0, Math.min(1, percentage));
236
- const rawValue = this.min + percentage * (this.max - this.min);
237
- return this.snapToStep(rawValue);
238
- }
239
-
240
- private snapToStep(value: number): number {
241
- const snapped = Math.round((value - this.min) / this.step) * this.step + this.min;
242
- return Math.max(this.min, Math.min(this.max, snapped));
243
- }
244
-
245
- private updateValue(index: number, newValue: number): void {
246
- const isRange = this.values.length > 1;
247
-
248
- if (isRange) {
249
- if (index === 0 && newValue > this.values[1]!) {
250
- newValue = this.values[1]!;
251
- } else if (index === 1 && newValue < this.values[0]!) {
252
- newValue = this.values[0]!;
253
- }
254
- }
255
-
256
- this.values[index] = newValue;
257
- if (this.inputs[index]) {
258
- this.inputs[index]!.value = String(newValue);
259
- }
260
-
261
- this.updateVisuals();
262
- this.dispatchChangeEvent();
263
- }
264
-
265
- private updateVisuals(): void {
266
- const isRange = this.values.length > 1;
267
- const rangeStart = isRange ? this.getPercentage(Math.min(...this.values)) : 0;
268
- const rangeEnd = isRange
269
- ? this.getPercentage(Math.max(...this.values))
270
- : this.getPercentage(this.values[0]!);
271
-
272
- if (this.orientation === "horizontal") {
273
- this.range.style.left = `${rangeStart}%`;
274
- this.range.style.width = `${rangeEnd - rangeStart}%`;
275
- } else {
276
- this.range.style.bottom = `${rangeStart}%`;
277
- this.range.style.height = `${rangeEnd - rangeStart}%`;
278
- }
279
-
280
- this.thumbs.forEach((thumb, index) => {
281
- const val = this.values[index];
282
- if (val === undefined) return;
283
- const percentage = this.getPercentage(val);
284
- if (this.orientation === "horizontal") {
285
- thumb.style.left = `${percentage}%`;
286
- } else {
287
- thumb.style.bottom = `${percentage}%`;
288
- }
289
- thumb.setAttribute("aria-valuenow", String(this.values[index]));
290
- });
291
- }
292
-
293
- private dispatchChangeEvent(): void {
294
- const value = this.values.length === 1 ? this.values[0] : [...this.values];
295
- this.root.dispatchEvent(
296
- new CustomEvent("slider-change", {
297
- detail: { value },
298
- bubbles: true,
299
- }),
300
- );
301
- }
302
-
303
- private handleThumbPointerDown(e: PointerEvent, index: number): void {
304
- if (this.disabled) return;
305
- e.preventDefault();
306
- this.activeThumbIndex = index;
307
- this.dragging = true;
308
- this.root.setAttribute("data-dragging", "");
309
- if (this.thumbs[index]) {
310
- this.thumbs[index]!.setAttribute("data-dragging", "");
311
- this.thumbs[index]!.focus();
312
- }
313
- (e.target as HTMLElement).setPointerCapture(e.pointerId);
314
- }
315
-
316
- private handlePointerMove(e: PointerEvent): void {
317
- if (!this.dragging || this.activeThumbIndex === -1) return;
318
- const newValue = this.getValueFromPosition(e.clientX, e.clientY);
319
- this.updateValue(this.activeThumbIndex, newValue);
320
- }
321
-
322
- private handlePointerUp(): void {
323
- if (!this.dragging) return;
324
- this.dragging = false;
325
- this.root.removeAttribute("data-dragging");
326
- this.thumbs.forEach((thumb) => thumb.removeAttribute("data-dragging"));
327
-
328
- const value = this.values.length === 1 ? this.values[0] : [...this.values];
329
- this.root.dispatchEvent(
330
- new CustomEvent("slider-commit", {
331
- detail: { value },
332
- bubbles: true,
333
- }),
334
- );
335
-
336
- this.activeThumbIndex = -1;
337
- }
338
-
339
- private handleTrackClick(e: PointerEvent): void {
340
- if (this.disabled) return;
341
- const newValue = this.getValueFromPosition(e.clientX, e.clientY);
342
-
343
- let closestIndex = 0;
344
- if (this.values.length > 1) {
345
- const distances = this.values.map((v) => Math.abs(v - newValue));
346
- closestIndex = distances.indexOf(Math.min(...distances));
347
- }
348
-
349
- this.updateValue(closestIndex, newValue);
350
- this.thumbs[closestIndex]?.focus();
351
- }
352
-
353
- private handleKeyDown(e: KeyboardEvent, index: number): void {
354
- if (this.disabled) return;
355
-
356
- const val = this.values[index]!;
357
- if (val === undefined) return;
358
- let newValue = val;
359
- const isHorizontal = this.orientation === "horizontal";
360
-
361
- switch (e.key) {
362
- case "ArrowRight":
363
- case "ArrowUp":
364
- e.preventDefault();
365
- newValue += isHorizontal === (e.key === "ArrowRight") ? this.step : -this.step;
366
- if (e.shiftKey) newValue = val + this.largeStep;
367
- break;
368
- case "ArrowLeft":
369
- case "ArrowDown":
370
- e.preventDefault();
371
- newValue -= isHorizontal === (e.key === "ArrowLeft") ? this.step : -this.step;
372
- if (e.shiftKey) newValue = val - this.largeStep;
373
- break;
374
- case "PageUp":
375
- e.preventDefault();
376
- if (newValue === undefined) break;
377
- newValue += this.largeStep;
378
- break;
379
- case "PageDown":
380
- e.preventDefault();
381
- if (newValue === undefined) break;
382
- newValue -= this.largeStep;
383
- break;
384
- case "Home":
385
- e.preventDefault();
386
- newValue = this.min;
387
- break;
388
- case "End":
389
- e.preventDefault();
390
- newValue = this.max;
391
- break;
392
- default:
393
- return;
394
- }
395
-
396
- if (newValue === undefined) return;
397
- newValue = this.snapToStep(newValue);
398
- this.updateValue(index, newValue);
399
- }
400
-
401
- private handleFocus(index: number): void {
402
- this.root.setAttribute("data-focused", "");
403
- this.thumbs[index]?.setAttribute("data-focused", "");
404
- }
405
-
406
- private handleBlur(): void {
407
- this.root.removeAttribute("data-focused");
408
- this.thumbs.forEach((thumb) => thumb.removeAttribute("data-focused"));
409
- }
410
- }
411
-
412
- const sliderInstances = new WeakMap<HTMLElement, StarwindSlider>();
413
-
414
- function initSliders(): void {
415
- document.querySelectorAll<HTMLElement>('[data-slot="slider"]').forEach((slider) => {
416
- if (!sliderInstances.has(slider)) {
417
- sliderInstances.set(slider, new StarwindSlider(slider));
418
- }
419
- });
420
- }
421
-
422
- initSliders();
423
- document.addEventListener("astro:after-swap", initSliders);
424
- document.addEventListener("starwind:init", initSliders);
425
- </script>
@@ -1,23 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { cv } from "css-variants";
4
- import IconLoader from "~icons/lucide/loader";
5
-
6
- type Props = Omit<HTMLAttributes<"svg">, "role" | "aria-label">;
7
-
8
- export const spinner = cv({
9
- base: "size-4 animate-spin",
10
- });
11
-
12
- const { class: className, ...rest } = Astro.props;
13
- ---
14
-
15
- <span
16
- role="status"
17
- aria-label="Loading"
18
- class:list={[spinner(), className]}
19
- {...rest}
20
- data-slot="spinner"
21
- >
22
- <IconLoader />
23
- </span>
@@ -1,192 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { cv } from "css-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 = cv({
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:op-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 = cv({
84
- base: [
85
- "bg-foreground i-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 = cv({
93
- base: "text-foreground ml-3xs font-medium peer-disabled:cursor-not-allowed peer-disabled:op-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:list={[switchButton({ variant }), 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
- {...rest}
114
- data-slot="switch-button"
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
- document.addEventListener("starwind:init", setupSwitches);
192
- </script>
@@ -1,6 +0,0 @@
1
- export interface SwitchChangeEvent extends CustomEvent {
2
- detail: {
3
- checked: boolean
4
- switchId: string
5
- }
6
- }
@@ -1,20 +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
- type Props = HTMLAttributes<"table"> & VariantProps<typeof table>;
8
-
9
- export const table = cv({
10
- base: "w-full caption-bottom text-sm",
11
- });
12
-
13
- const { class: className, ...rest } = Astro.props;
14
- ---
15
-
16
- <div data-slot="table-container" class="relative w-full overflow-x-auto">
17
- <table class:list={[table(), className]} {...rest} data-slot="table">
18
- <slot />
19
- </table>
20
- </div>
@@ -1,18 +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
- type Props = HTMLAttributes<"tbody"> & VariantProps<typeof tableBody>;
8
-
9
- export const tableBody = cv({
10
- base: "[&_tr:last-child]:border-0",
11
- });
12
-
13
- const { class: className, ...rest } = Astro.props;
14
- ---
15
-
16
- <tbody class:list={[tableBody(), className]} {...rest} data-slot="table-body">
17
- <slot />
18
- </tbody>