@dogsbay/ui 0.2.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. package/package.json +38 -0
  2. package/src/accordion/Accordion.astro +38 -0
  3. package/src/accordion/AccordionContent.astro +25 -0
  4. package/src/accordion/AccordionItem.astro +26 -0
  5. package/src/accordion/AccordionTrigger.astro +38 -0
  6. package/src/accordion/accordion.ts +189 -0
  7. package/src/accordion/index.ts +4 -0
  8. package/src/alert/Alert.astro +69 -0
  9. package/src/alert/AlertDescription.astro +17 -0
  10. package/src/alert/AlertTitle.astro +21 -0
  11. package/src/alert/CollapsibleAlert.astro +103 -0
  12. package/src/alert/icon.ts +32 -0
  13. package/src/alert/index.ts +4 -0
  14. package/src/alert/variants.ts +29 -0
  15. package/src/alert-dialog/AlertDialog.astro +16 -0
  16. package/src/alert-dialog/AlertDialogAction.astro +23 -0
  17. package/src/alert-dialog/AlertDialogCancel.astro +23 -0
  18. package/src/alert-dialog/AlertDialogContent.astro +37 -0
  19. package/src/alert-dialog/AlertDialogDescription.astro +18 -0
  20. package/src/alert-dialog/AlertDialogFooter.astro +18 -0
  21. package/src/alert-dialog/AlertDialogHeader.astro +18 -0
  22. package/src/alert-dialog/AlertDialogTitle.astro +18 -0
  23. package/src/alert-dialog/AlertDialogTrigger.astro +24 -0
  24. package/src/alert-dialog/alert-dialog.ts +154 -0
  25. package/src/alert-dialog/index.ts +9 -0
  26. package/src/api-doc/ApiDoc.astro +52 -0
  27. package/src/api-doc/index.ts +1 -0
  28. package/src/api-layout/ApiCodePanel.astro +21 -0
  29. package/src/api-layout/ApiLayout.astro +29 -0
  30. package/src/api-layout/ExampleBlock.astro +63 -0
  31. package/src/api-params/ApiParams.astro +96 -0
  32. package/src/api-params/index.ts +1 -0
  33. package/src/api-source/ApiSource.astro +20 -0
  34. package/src/api-source/api-source.css +32 -0
  35. package/src/api-source/index.ts +1 -0
  36. package/src/api-symbol/ApiSymbol.astro +48 -0
  37. package/src/api-symbol/api-symbol.css +89 -0
  38. package/src/api-symbol/index.ts +1 -0
  39. package/src/api-url-bar/ApiUrlBar.astro +63 -0
  40. package/src/avatar/Avatar.astro +57 -0
  41. package/src/avatar/index.ts +1 -0
  42. package/src/badge/Badge.astro +37 -0
  43. package/src/badge/index.ts +1 -0
  44. package/src/breadcrumb/Breadcrumb.astro +32 -0
  45. package/src/breadcrumb/BreadcrumbEllipsis.astro +32 -0
  46. package/src/breadcrumb/BreadcrumbItem.astro +41 -0
  47. package/src/breadcrumb/BreadcrumbSeparator.astro +33 -0
  48. package/src/breadcrumb/index.ts +4 -0
  49. package/src/button/Button.astro +70 -0
  50. package/src/button/index.ts +1 -0
  51. package/src/card/Card.astro +17 -0
  52. package/src/card/CardContent.astro +17 -0
  53. package/src/card/CardDescription.astro +17 -0
  54. package/src/card/CardFooter.astro +17 -0
  55. package/src/card/CardHeader.astro +17 -0
  56. package/src/card/CardTitle.astro +17 -0
  57. package/src/card/index.ts +6 -0
  58. package/src/checkbox/Checkbox.astro +70 -0
  59. package/src/checkbox/index.ts +1 -0
  60. package/src/checkbox-group/CheckboxGroup.astro +38 -0
  61. package/src/checkbox-group/checkbox-group.ts +53 -0
  62. package/src/checkbox-group/index.ts +1 -0
  63. package/src/code-block/CodeBlock.astro +160 -0
  64. package/src/code-rich/CodeRich.astro +267 -0
  65. package/src/code-rich/code-rich.css +68 -0
  66. package/src/code-rich/index.ts +1 -0
  67. package/src/code-samples/CodeSamples.astro +59 -0
  68. package/src/collapsible/Collapsible.astro +35 -0
  69. package/src/collapsible/CollapsibleContent.astro +24 -0
  70. package/src/collapsible/CollapsibleTrigger.astro +23 -0
  71. package/src/collapsible/collapsible.ts +42 -0
  72. package/src/collapsible/index.ts +3 -0
  73. package/src/combobox/Combobox.astro +53 -0
  74. package/src/combobox/ComboboxEmpty.astro +18 -0
  75. package/src/combobox/ComboboxItem.astro +28 -0
  76. package/src/combobox/combobox.ts +179 -0
  77. package/src/combobox/index.ts +3 -0
  78. package/src/command/Command.astro +22 -0
  79. package/src/command/CommandEmpty.astro +18 -0
  80. package/src/command/CommandGroup.astro +24 -0
  81. package/src/command/CommandInput.astro +49 -0
  82. package/src/command/CommandItem.astro +26 -0
  83. package/src/command/CommandList.astro +19 -0
  84. package/src/command/CommandSeparator.astro +16 -0
  85. package/src/command/CommandShortcut.astro +18 -0
  86. package/src/command/command.ts +212 -0
  87. package/src/command/index.ts +8 -0
  88. package/src/content-renderer/ContentRenderer.astro +410 -0
  89. package/src/content-renderer/InlineRenderer.astro +149 -0
  90. package/src/context-menu/ContextMenu.astro +22 -0
  91. package/src/context-menu/ContextMenuContent.astro +24 -0
  92. package/src/context-menu/ContextMenuItem.astro +49 -0
  93. package/src/context-menu/ContextMenuSeparator.astro +14 -0
  94. package/src/context-menu/ContextMenuShortcut.astro +14 -0
  95. package/src/context-menu/ContextMenuTrigger.astro +22 -0
  96. package/src/context-menu/context-menu.ts +238 -0
  97. package/src/context-menu/index.ts +6 -0
  98. package/src/copy-button/CopyButton.astro +88 -0
  99. package/src/copy-button/index.ts +1 -0
  100. package/src/diagram/Diagram.astro +15 -0
  101. package/src/diagram/index.ts +1 -0
  102. package/src/dialog/Dialog.astro +22 -0
  103. package/src/dialog/DialogClose.astro +32 -0
  104. package/src/dialog/DialogContent.astro +37 -0
  105. package/src/dialog/DialogDescription.astro +22 -0
  106. package/src/dialog/DialogFooter.astro +18 -0
  107. package/src/dialog/DialogHeader.astro +18 -0
  108. package/src/dialog/DialogTitle.astro +18 -0
  109. package/src/dialog/DialogTrigger.astro +33 -0
  110. package/src/dialog/dialog.ts +291 -0
  111. package/src/dialog/index.ts +8 -0
  112. package/src/docs-footer/DocsFooter.astro +50 -0
  113. package/src/docs-header/DocsHeader.astro +32 -0
  114. package/src/docs-layout/DocsLayout.astro +187 -0
  115. package/src/docs-layout/index.ts +1 -0
  116. package/src/drawer/Drawer.astro +12 -0
  117. package/src/drawer/DrawerClose.astro +12 -0
  118. package/src/drawer/DrawerContent.astro +46 -0
  119. package/src/drawer/DrawerDescription.astro +10 -0
  120. package/src/drawer/DrawerFooter.astro +10 -0
  121. package/src/drawer/DrawerHandle.astro +16 -0
  122. package/src/drawer/DrawerHeader.astro +10 -0
  123. package/src/drawer/DrawerTitle.astro +10 -0
  124. package/src/drawer/DrawerTrigger.astro +25 -0
  125. package/src/drawer/drawer.ts +262 -0
  126. package/src/drawer/index.ts +9 -0
  127. package/src/dropdown-menu/DropdownMenu.astro +22 -0
  128. package/src/dropdown-menu/DropdownMenuContent.astro +33 -0
  129. package/src/dropdown-menu/DropdownMenuGroup.astro +17 -0
  130. package/src/dropdown-menu/DropdownMenuItem.astro +48 -0
  131. package/src/dropdown-menu/DropdownMenuLabel.astro +28 -0
  132. package/src/dropdown-menu/DropdownMenuSeparator.astro +21 -0
  133. package/src/dropdown-menu/DropdownMenuShortcut.astro +18 -0
  134. package/src/dropdown-menu/DropdownMenuTrigger.astro +34 -0
  135. package/src/dropdown-menu/dropdown-menu.ts +348 -0
  136. package/src/dropdown-menu/index.ts +8 -0
  137. package/src/endpoint-card/EndpointCard.astro +60 -0
  138. package/src/endpoint-card/EndpointCardSection.astro +22 -0
  139. package/src/endpoint-card/EndpointSection.astro +35 -0
  140. package/src/field/Field.astro +31 -0
  141. package/src/field/FieldDescription.astro +22 -0
  142. package/src/field/FieldLabel.astro +24 -0
  143. package/src/field/field.ts +61 -0
  144. package/src/field/index.ts +3 -0
  145. package/src/fieldset/Fieldset.astro +24 -0
  146. package/src/fieldset/FieldsetLegend.astro +18 -0
  147. package/src/fieldset/index.ts +2 -0
  148. package/src/footnote/Footnote.astro +37 -0
  149. package/src/footnote/footnote.ts +79 -0
  150. package/src/footnote/index.ts +1 -0
  151. package/src/form/Form.astro +27 -0
  152. package/src/form/form.ts +160 -0
  153. package/src/form/index.ts +1 -0
  154. package/src/grid/Grid.astro +117 -0
  155. package/src/grid/GridItem.astro +95 -0
  156. package/src/grid/index.ts +2 -0
  157. package/src/image/Image.astro +115 -0
  158. package/src/image/index.ts +1 -0
  159. package/src/input/Input.astro +34 -0
  160. package/src/input/index.ts +1 -0
  161. package/src/kbd/Kbd.astro +17 -0
  162. package/src/kbd/index.ts +1 -0
  163. package/src/label/Label.astro +17 -0
  164. package/src/label/index.ts +1 -0
  165. package/src/link-card/LinkCard.astro +47 -0
  166. package/src/link-card/index.ts +1 -0
  167. package/src/map-view/MapView.astro +88 -0
  168. package/src/map-view/index.ts +1 -0
  169. package/src/map-view/map-view.ts +194 -0
  170. package/src/markdown-example/MarkdownExample.astro +138 -0
  171. package/src/markdown-example/index.ts +1 -0
  172. package/src/math/MathKatex.astro +35 -0
  173. package/src/math/index.ts +1 -0
  174. package/src/menubar/Menubar.astro +25 -0
  175. package/src/menubar/MenubarContent.astro +24 -0
  176. package/src/menubar/MenubarItem.astro +26 -0
  177. package/src/menubar/MenubarMenu.astro +12 -0
  178. package/src/menubar/MenubarSeparator.astro +11 -0
  179. package/src/menubar/MenubarShortcut.astro +11 -0
  180. package/src/menubar/MenubarTrigger.astro +27 -0
  181. package/src/menubar/index.ts +7 -0
  182. package/src/menubar/menubar.ts +258 -0
  183. package/src/meter/Meter.astro +75 -0
  184. package/src/meter/index.ts +1 -0
  185. package/src/method-badge/MethodBadge.astro +32 -0
  186. package/src/navigation-menu/NavigationMenu.astro +24 -0
  187. package/src/navigation-menu/NavigationMenuContent.astro +24 -0
  188. package/src/navigation-menu/NavigationMenuItem.astro +22 -0
  189. package/src/navigation-menu/NavigationMenuLink.astro +26 -0
  190. package/src/navigation-menu/NavigationMenuList.astro +22 -0
  191. package/src/navigation-menu/NavigationMenuTrigger.astro +40 -0
  192. package/src/navigation-menu/index.ts +6 -0
  193. package/src/navigation-menu/navigation-menu.ts +192 -0
  194. package/src/number-field/NumberField.astro +84 -0
  195. package/src/number-field/index.ts +1 -0
  196. package/src/number-field/number-field.ts +68 -0
  197. package/src/pagination/Pagination.astro +59 -0
  198. package/src/pagination/index.ts +1 -0
  199. package/src/parameter-table/ParameterTable.astro +75 -0
  200. package/src/popover/Popover.astro +21 -0
  201. package/src/popover/PopoverContent.astro +31 -0
  202. package/src/popover/PopoverTrigger.astro +31 -0
  203. package/src/popover/index.ts +3 -0
  204. package/src/popover/popover.ts +144 -0
  205. package/src/preview-card/PreviewCard.astro +24 -0
  206. package/src/preview-card/PreviewCardContent.astro +24 -0
  207. package/src/preview-card/PreviewCardTrigger.astro +23 -0
  208. package/src/preview-card/index.ts +3 -0
  209. package/src/preview-card/preview-card.ts +91 -0
  210. package/src/progress/Progress.astro +61 -0
  211. package/src/progress/index.ts +1 -0
  212. package/src/property-item/PropertyItem.astro +183 -0
  213. package/src/property-list/PropertyList.astro +68 -0
  214. package/src/radio-group/RadioGroup.astro +41 -0
  215. package/src/radio-group/RadioGroupItem.astro +36 -0
  216. package/src/radio-group/index.ts +2 -0
  217. package/src/radio-group/radio-group.ts +126 -0
  218. package/src/response-tabs/ResponseTabs.astro +60 -0
  219. package/src/schema-viewer/SchemaViewer.astro +42 -0
  220. package/src/scroll-area/ScrollArea.astro +44 -0
  221. package/src/scroll-area/index.ts +1 -0
  222. package/src/scroll-area/scroll-area.ts +176 -0
  223. package/src/select/Select.astro +34 -0
  224. package/src/select/SelectContent.astro +24 -0
  225. package/src/select/SelectGroup.astro +23 -0
  226. package/src/select/SelectItem.astro +28 -0
  227. package/src/select/SelectLabel.astro +18 -0
  228. package/src/select/SelectSeparator.astro +22 -0
  229. package/src/select/SelectTrigger.astro +28 -0
  230. package/src/select/SelectValue.astro +18 -0
  231. package/src/select/index.ts +8 -0
  232. package/src/select/select.ts +381 -0
  233. package/src/separator/Separator.astro +35 -0
  234. package/src/separator/index.ts +1 -0
  235. package/src/sheet/Sheet.astro +12 -0
  236. package/src/sheet/SheetClose.astro +35 -0
  237. package/src/sheet/SheetContent.astro +52 -0
  238. package/src/sheet/SheetDescription.astro +18 -0
  239. package/src/sheet/SheetFooter.astro +18 -0
  240. package/src/sheet/SheetHeader.astro +18 -0
  241. package/src/sheet/SheetTitle.astro +18 -0
  242. package/src/sheet/SheetTrigger.astro +32 -0
  243. package/src/sheet/index.ts +8 -0
  244. package/src/sheet/sheet.ts +173 -0
  245. package/src/sidebar/Sidebar.astro +113 -0
  246. package/src/sidebar/SidebarContent.astro +18 -0
  247. package/src/sidebar/SidebarFooter.astro +18 -0
  248. package/src/sidebar/SidebarGroup.astro +18 -0
  249. package/src/sidebar/SidebarGroupContent.astro +18 -0
  250. package/src/sidebar/SidebarGroupLabel.astro +18 -0
  251. package/src/sidebar/SidebarHeader.astro +18 -0
  252. package/src/sidebar/SidebarInset.astro +18 -0
  253. package/src/sidebar/SidebarMenu.astro +18 -0
  254. package/src/sidebar/SidebarMenuBadge.astro +18 -0
  255. package/src/sidebar/SidebarMenuButton.astro +71 -0
  256. package/src/sidebar/SidebarMenuItem.astro +18 -0
  257. package/src/sidebar/SidebarMenuSub.astro +18 -0
  258. package/src/sidebar/SidebarMenuSubButton.astro +45 -0
  259. package/src/sidebar/SidebarMenuSubItem.astro +12 -0
  260. package/src/sidebar/SidebarNavTree.astro +106 -0
  261. package/src/sidebar/SidebarProvider.astro +23 -0
  262. package/src/sidebar/SidebarRail.astro +25 -0
  263. package/src/sidebar/SidebarSeparator.astro +21 -0
  264. package/src/sidebar/SidebarTrigger.astro +40 -0
  265. package/src/sidebar/index.ts +19 -0
  266. package/src/sidebar/sidebar.ts +265 -0
  267. package/src/skeleton/Skeleton.astro +16 -0
  268. package/src/skeleton/index.ts +1 -0
  269. package/src/skip-link/SkipLink.astro +24 -0
  270. package/src/slider/Slider.astro +61 -0
  271. package/src/slider/index.ts +1 -0
  272. package/src/slider/slider.ts +111 -0
  273. package/src/spinner/Spinner.astro +54 -0
  274. package/src/spinner/index.ts +1 -0
  275. package/src/steps/Step.astro +16 -0
  276. package/src/steps/Steps.astro +122 -0
  277. package/src/steps/SubSteps.astro +73 -0
  278. package/src/switch/Switch.astro +52 -0
  279. package/src/switch/index.ts +1 -0
  280. package/src/switch/switch.ts +109 -0
  281. package/src/table/Table.astro +24 -0
  282. package/src/table/TableBody.astro +18 -0
  283. package/src/table/TableCaption.astro +18 -0
  284. package/src/table/TableCell.astro +18 -0
  285. package/src/table/TableFooter.astro +18 -0
  286. package/src/table/TableHead.astro +18 -0
  287. package/src/table/TableHeader.astro +18 -0
  288. package/src/table/TableRow.astro +18 -0
  289. package/src/table/index.ts +8 -0
  290. package/src/tabs/Tabs.astro +37 -0
  291. package/src/tabs/TabsContent.astro +32 -0
  292. package/src/tabs/TabsList.astro +23 -0
  293. package/src/tabs/TabsTrigger.astro +29 -0
  294. package/src/tabs/index.ts +4 -0
  295. package/src/tabs/tabs.ts +220 -0
  296. package/src/textarea/Textarea.astro +25 -0
  297. package/src/textarea/index.ts +1 -0
  298. package/src/theme-toggle/ThemeToggle.astro +67 -0
  299. package/src/theme-toggle/index.ts +1 -0
  300. package/src/toast/Toaster.astro +39 -0
  301. package/src/toast/index.ts +3 -0
  302. package/src/toast/toast.ts +104 -0
  303. package/src/toc/TableOfContents.astro +225 -0
  304. package/src/toggle/Toggle.astro +56 -0
  305. package/src/toggle/index.ts +1 -0
  306. package/src/toggle/toggle.ts +38 -0
  307. package/src/toggle-group/ToggleGroup.astro +39 -0
  308. package/src/toggle-group/ToggleGroupItem.astro +56 -0
  309. package/src/toggle-group/index.ts +2 -0
  310. package/src/toggle-group/toggle-group.ts +121 -0
  311. package/src/toolbar/Toolbar.astro +26 -0
  312. package/src/toolbar/ToolbarButton.astro +29 -0
  313. package/src/toolbar/ToolbarSeparator.astro +14 -0
  314. package/src/toolbar/index.ts +3 -0
  315. package/src/toolbar/toolbar.ts +65 -0
  316. package/src/tooltip/Tooltip.astro +21 -0
  317. package/src/tooltip/TooltipContent.astro +25 -0
  318. package/src/tooltip/TooltipTrigger.astro +31 -0
  319. package/src/tooltip/index.ts +3 -0
  320. package/src/tooltip/tooltip.ts +156 -0
  321. package/src/youtube/YouTube.astro +119 -0
  322. package/src/youtube/index.ts +1 -0
@@ -0,0 +1,225 @@
1
+ ---
2
+ import { tv } from "tailwind-variants";
3
+
4
+ const tocNav = tv({
5
+ base: "text-sm",
6
+ variants: {
7
+ sticky: {
8
+ true: "sticky top-4 max-h-[calc(100vh-2rem)] overflow-y-auto",
9
+ },
10
+ },
11
+ defaultVariants: {
12
+ sticky: true,
13
+ },
14
+ });
15
+
16
+ const tocTitle = tv({
17
+ base: "mb-3 text-sm font-medium text-foreground",
18
+ });
19
+
20
+ interface TocItem {
21
+ depth: number;
22
+ slug: string;
23
+ text: string;
24
+ /** Symbol kind for API reference entries (class, meth, attr, func, module) */
25
+ kind?: string;
26
+ }
27
+
28
+ interface Props {
29
+ /** Array of heading items to display */
30
+ headings: TocItem[];
31
+ /** Minimum heading level to include (default: 2) */
32
+ minLevel?: number;
33
+ /** Maximum heading level to include (default: 3) */
34
+ maxLevel?: number;
35
+ /** Title text (default: "On this page") */
36
+ title?: string;
37
+ /** Stick to viewport while scrolling (default: true) */
38
+ sticky?: boolean;
39
+ class?: string;
40
+ [key: string]: unknown;
41
+ }
42
+
43
+ const {
44
+ headings,
45
+ minLevel = 2,
46
+ maxLevel = 3,
47
+ title = "On this page",
48
+ sticky = true,
49
+ class: className,
50
+ ...rest
51
+ } = Astro.props;
52
+
53
+ const filtered = headings.filter(
54
+ (h) => h.depth >= minLevel && h.depth <= maxLevel,
55
+ );
56
+ ---
57
+
58
+ {filtered.length > 0 && (
59
+ <nav
60
+ class={tocNav({ sticky, class: className })}
61
+ data-component="toc"
62
+ aria-label={title}
63
+ {...rest}
64
+ >
65
+ <h2 class={tocTitle()}>{title}</h2>
66
+ <ul class="space-y-1">
67
+ {filtered.map((heading) => (
68
+ <li
69
+ style={`padding-left: ${(heading.depth - minLevel) * 0.75}rem`}
70
+ >
71
+ <a
72
+ href={`#${heading.slug}`}
73
+ class="block py-1 text-muted-foreground transition-colors hover:text-foreground data-[active]:font-medium data-[active]:text-foreground"
74
+ data-toc-link
75
+ data-toc-slug={heading.slug}
76
+ >
77
+ {heading.kind && (
78
+ <span class={`toc-kind toc-kind-${heading.kind}`}>{heading.kind}</span>
79
+ )}
80
+ {heading.text}
81
+ </a>
82
+ </li>
83
+ ))}
84
+ </ul>
85
+ </nav>
86
+ )}
87
+
88
+ <style>
89
+ .toc-kind {
90
+ display: inline-block;
91
+ border-radius: 0.25rem;
92
+ padding: 0 0.3rem;
93
+ font-size: 0.6rem;
94
+ font-weight: 600;
95
+ letter-spacing: 0.02em;
96
+ text-transform: lowercase;
97
+ vertical-align: middle;
98
+ margin-right: 0.35rem;
99
+ line-height: 1.4;
100
+ }
101
+ .toc-kind-class {
102
+ background-color: oklch(0.55 0.18 265 / 0.15);
103
+ color: oklch(0.55 0.18 265);
104
+ }
105
+ :global(.dark) .toc-kind-class {
106
+ background-color: oklch(0.7 0.15 265 / 0.2);
107
+ color: oklch(0.7 0.15 265);
108
+ }
109
+ .toc-kind-meth {
110
+ background-color: oklch(0.55 0.15 155 / 0.15);
111
+ color: oklch(0.55 0.15 155);
112
+ }
113
+ :global(.dark) .toc-kind-meth {
114
+ background-color: oklch(0.7 0.15 155 / 0.2);
115
+ color: oklch(0.7 0.15 155);
116
+ }
117
+ .toc-kind-attr {
118
+ background-color: oklch(0.6 0.15 55 / 0.15);
119
+ color: oklch(0.6 0.15 55);
120
+ }
121
+ :global(.dark) .toc-kind-attr {
122
+ background-color: oklch(0.75 0.15 55 / 0.2);
123
+ color: oklch(0.75 0.15 55);
124
+ }
125
+ .toc-kind-func {
126
+ background-color: oklch(0.55 0.18 330 / 0.15);
127
+ color: oklch(0.55 0.18 330);
128
+ }
129
+ :global(.dark) .toc-kind-func {
130
+ background-color: oklch(0.7 0.15 330 / 0.2);
131
+ color: oklch(0.7 0.15 330);
132
+ }
133
+ .toc-kind-module {
134
+ background-color: oklch(0.5 0.12 200 / 0.15);
135
+ color: oklch(0.5 0.12 200);
136
+ }
137
+ :global(.dark) .toc-kind-module {
138
+ background-color: oklch(0.65 0.12 200 / 0.2);
139
+ color: oklch(0.65 0.12 200);
140
+ }
141
+ </style>
142
+
143
+ <script>
144
+ function setupToc() {
145
+ const tocNav = document.querySelector("[data-component='toc']");
146
+ if (!tocNav) return;
147
+
148
+ const links = Array.from(
149
+ tocNav.querySelectorAll<HTMLAnchorElement>("[data-toc-link]"),
150
+ );
151
+ if (links.length === 0) return;
152
+
153
+ // Collect heading elements matching TOC links
154
+ const headings = links
155
+ .map((link) => {
156
+ const slug = link.getAttribute("data-toc-slug");
157
+ return slug ? document.getElementById(slug) : null;
158
+ })
159
+ .filter(Boolean) as HTMLElement[];
160
+
161
+ if (headings.length === 0) return;
162
+
163
+ let activeSlug: string | null = null;
164
+
165
+ function setActive(slug: string | null) {
166
+ if (slug === activeSlug) return;
167
+ activeSlug = slug;
168
+ links.forEach((link) => {
169
+ if (link.getAttribute("data-toc-slug") === slug) {
170
+ link.setAttribute("data-active", "");
171
+ } else {
172
+ link.removeAttribute("data-active");
173
+ }
174
+ });
175
+ }
176
+
177
+ // Use IntersectionObserver to track which heading is in view
178
+ const observer = new IntersectionObserver(
179
+ (entries) => {
180
+ // Find the first heading that is intersecting (visible)
181
+ for (const entry of entries) {
182
+ if (entry.isIntersecting) {
183
+ setActive(entry.target.id);
184
+ return;
185
+ }
186
+ }
187
+
188
+ // If none are intersecting, find the last heading above the viewport
189
+ const scrollY = window.scrollY;
190
+ let closest: HTMLElement | null = null;
191
+ for (const heading of headings) {
192
+ if (heading.offsetTop <= scrollY + 100) {
193
+ closest = heading;
194
+ }
195
+ }
196
+ if (closest) {
197
+ setActive(closest.id);
198
+ }
199
+ },
200
+ {
201
+ rootMargin: "-80px 0px -80% 0px",
202
+ threshold: 0,
203
+ },
204
+ );
205
+
206
+ headings.forEach((heading) => observer.observe(heading));
207
+
208
+ // Set initial active
209
+ const scrollY = window.scrollY;
210
+ let initial: HTMLElement | null = null;
211
+ for (const heading of headings) {
212
+ if (heading.offsetTop <= scrollY + 100) {
213
+ initial = heading;
214
+ }
215
+ }
216
+ if (initial) {
217
+ setActive(initial.id);
218
+ } else if (headings[0]) {
219
+ setActive(headings[0].id);
220
+ }
221
+ }
222
+
223
+ setupToc();
224
+ document.addEventListener("astro:after-swap", setupToc);
225
+ </script>
@@ -0,0 +1,56 @@
1
+ ---
2
+ import { tv, type VariantProps } from "tailwind-variants";
3
+
4
+ const toggle = tv({
5
+ base: "inline-flex cursor-pointer items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",
6
+ variants: {
7
+ variant: {
8
+ default: "bg-transparent",
9
+ outline: "border border-input bg-transparent",
10
+ },
11
+ size: {
12
+ default: "h-10 w-10",
13
+ sm: "h-9 w-9",
14
+ lg: "h-11 w-11",
15
+ },
16
+ },
17
+ defaultVariants: {
18
+ variant: "default",
19
+ size: "default",
20
+ },
21
+ });
22
+
23
+ type ToggleVariants = VariantProps<typeof toggle>;
24
+
25
+ interface Props {
26
+ defaultPressed?: boolean;
27
+ disabled?: boolean;
28
+ variant?: ToggleVariants["variant"];
29
+ size?: ToggleVariants["size"];
30
+ class?: string;
31
+ [key: string]: unknown;
32
+ }
33
+
34
+ const {
35
+ defaultPressed = false,
36
+ disabled = false,
37
+ variant = "default",
38
+ size = "default",
39
+ class: className,
40
+ ...rest
41
+ } = Astro.props;
42
+ ---
43
+
44
+ <button
45
+ class={toggle({ variant, size, class: className })}
46
+ data-component="toggle"
47
+ type="button"
48
+ aria-pressed={String(defaultPressed)}
49
+ disabled={disabled || undefined}
50
+ data-state={defaultPressed ? "on" : "off"}
51
+ data-variant={variant}
52
+ data-size={size}
53
+ {...rest}
54
+ >
55
+ <slot />
56
+ </button>
@@ -0,0 +1 @@
1
+ export { default as Toggle } from "./Toggle.astro";
@@ -0,0 +1,38 @@
1
+ const instances = new WeakSet<HTMLElement>();
2
+
3
+ function initToggle(root: HTMLElement) {
4
+ if (instances.has(root)) return;
5
+ instances.add(root);
6
+
7
+ root.addEventListener("click", () => {
8
+ if (root.hasAttribute("disabled")) return;
9
+
10
+ const pressed = root.getAttribute("aria-pressed") === "true";
11
+ const next = !pressed;
12
+
13
+ root.setAttribute("aria-pressed", String(next));
14
+ root.setAttribute("data-state", next ? "on" : "off");
15
+
16
+ root.dispatchEvent(
17
+ new CustomEvent("base-toggle:change", {
18
+ detail: { pressed: next },
19
+ bubbles: true,
20
+ }),
21
+ );
22
+ });
23
+ }
24
+
25
+ function init() {
26
+ document.querySelectorAll("[data-component='toggle']").forEach((el) => {
27
+ initToggle(el as HTMLElement);
28
+ });
29
+ }
30
+
31
+ if (document.readyState === "loading") {
32
+ document.addEventListener("DOMContentLoaded", init);
33
+ } else {
34
+ init();
35
+ }
36
+ document.addEventListener("astro:page-load", init);
37
+
38
+ export { initToggle };
@@ -0,0 +1,39 @@
1
+ ---
2
+ import { tv } from "tailwind-variants";
3
+
4
+ const toggleGroup = tv({
5
+ base: "inline-flex items-center justify-center gap-1 rounded-md",
6
+ });
7
+
8
+ interface Props {
9
+ type?: "single" | "multiple";
10
+ defaultValue?: string | string[];
11
+ disabled?: boolean;
12
+ class?: string;
13
+ [key: string]: unknown;
14
+ }
15
+
16
+ const {
17
+ type = "single",
18
+ defaultValue,
19
+ disabled = false,
20
+ class: className,
21
+ ...rest
22
+ } = Astro.props;
23
+
24
+ const defaultStr = Array.isArray(defaultValue)
25
+ ? defaultValue.join(",")
26
+ : defaultValue || "";
27
+ ---
28
+
29
+ <div
30
+ class={toggleGroup({ class: className })}
31
+ data-component="toggle-group"
32
+ data-type={type}
33
+ data-default-value={defaultStr}
34
+ data-disabled={disabled || undefined}
35
+ role="group"
36
+ {...rest}
37
+ >
38
+ <slot />
39
+ </div>
@@ -0,0 +1,56 @@
1
+ ---
2
+ import { tv, type VariantProps } from "tailwind-variants";
3
+
4
+ const toggleGroupItem = tv({
5
+ base: "inline-flex cursor-pointer items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",
6
+ variants: {
7
+ variant: {
8
+ default: "bg-transparent",
9
+ outline: "border border-input bg-transparent",
10
+ },
11
+ size: {
12
+ default: "h-10 w-10",
13
+ sm: "h-9 w-9",
14
+ lg: "h-11 w-11",
15
+ },
16
+ },
17
+ defaultVariants: {
18
+ variant: "default",
19
+ size: "default",
20
+ },
21
+ });
22
+
23
+ type Variants = VariantProps<typeof toggleGroupItem>;
24
+
25
+ interface Props {
26
+ value: string;
27
+ disabled?: boolean;
28
+ variant?: Variants["variant"];
29
+ size?: Variants["size"];
30
+ class?: string;
31
+ [key: string]: unknown;
32
+ }
33
+
34
+ const {
35
+ value,
36
+ disabled = false,
37
+ variant = "default",
38
+ size = "default",
39
+ class: className,
40
+ ...rest
41
+ } = Astro.props;
42
+ ---
43
+
44
+ <button
45
+ class={toggleGroupItem({ variant, size, class: className })}
46
+ data-part="item"
47
+ data-value={value}
48
+ type="button"
49
+ aria-pressed="false"
50
+ data-state="off"
51
+ disabled={disabled || undefined}
52
+ tabindex="-1"
53
+ {...rest}
54
+ >
55
+ <slot />
56
+ </button>
@@ -0,0 +1,2 @@
1
+ export { default as ToggleGroup } from "./ToggleGroup.astro";
2
+ export { default as ToggleGroupItem } from "./ToggleGroupItem.astro";
@@ -0,0 +1,121 @@
1
+ function init(root: HTMLElement) {
2
+ if (root.hasAttribute("data-initialized")) return;
3
+ root.setAttribute("data-initialized", "");
4
+
5
+ const type = root.getAttribute("data-type") || "single";
6
+ const disabled = root.hasAttribute("data-disabled");
7
+
8
+ const items = () =>
9
+ Array.from(root.querySelectorAll<HTMLElement>("[data-part='item']:not([disabled])"));
10
+
11
+ function setPressed(item: HTMLElement, pressed: boolean) {
12
+ item.setAttribute("aria-pressed", String(pressed));
13
+ item.setAttribute("data-state", pressed ? "on" : "off");
14
+ }
15
+
16
+ function getPressed(): Set<string> {
17
+ const result = new Set<string>();
18
+ root.querySelectorAll<HTMLElement>("[data-part='item']").forEach((el) => {
19
+ if (el.getAttribute("aria-pressed") === "true") {
20
+ result.add(el.getAttribute("data-value") || "");
21
+ }
22
+ });
23
+ return result;
24
+ }
25
+
26
+ function select(item: HTMLElement) {
27
+ const value = item.getAttribute("data-value") || "";
28
+ const isPressed = item.getAttribute("aria-pressed") === "true";
29
+
30
+ if (type === "single") {
31
+ // Deselect all, select this (or deselect if already selected)
32
+ root.querySelectorAll<HTMLElement>("[data-part='item']").forEach((el) =>
33
+ setPressed(el, false),
34
+ );
35
+ if (!isPressed) setPressed(item, true);
36
+ } else {
37
+ // Toggle this item
38
+ setPressed(item, !isPressed);
39
+ }
40
+
41
+ root.dispatchEvent(
42
+ new CustomEvent("change", {
43
+ detail: { value: type === "single" ? (getPressed().values().next().value ?? "") : [...getPressed()] },
44
+ bubbles: true,
45
+ }),
46
+ );
47
+ }
48
+
49
+ // Click
50
+ root.addEventListener("click", (e) => {
51
+ if (disabled) return;
52
+ const item = (e.target as HTMLElement).closest<HTMLElement>(
53
+ "[data-part='item']:not([disabled])",
54
+ );
55
+ if (!item) return;
56
+ select(item);
57
+ });
58
+
59
+ // Keyboard
60
+ root.addEventListener("keydown", (e) => {
61
+ const item = (e.target as HTMLElement).closest<HTMLElement>("[data-part='item']");
62
+ if (!item) return;
63
+
64
+ const enabled = items();
65
+ const idx = enabled.indexOf(item);
66
+ if (idx === -1) return;
67
+
68
+ let next: number | null = null;
69
+ switch (e.key) {
70
+ case "ArrowRight":
71
+ case "ArrowDown":
72
+ next = (idx + 1) % enabled.length;
73
+ break;
74
+ case "ArrowLeft":
75
+ case "ArrowUp":
76
+ next = (idx - 1 + enabled.length) % enabled.length;
77
+ break;
78
+ case "Home":
79
+ next = 0;
80
+ break;
81
+ case "End":
82
+ next = enabled.length - 1;
83
+ break;
84
+ default:
85
+ return;
86
+ }
87
+
88
+ e.preventDefault();
89
+ enabled[next].focus();
90
+ enabled[next].setAttribute("tabindex", "0");
91
+ item.setAttribute("tabindex", "-1");
92
+ });
93
+
94
+ // Initialize defaults
95
+ const defaultValue = root.getAttribute("data-default-value") || "";
96
+ const defaults = defaultValue ? defaultValue.split(",") : [];
97
+
98
+ root.querySelectorAll<HTMLElement>("[data-part='item']").forEach((el) => {
99
+ const val = el.getAttribute("data-value") || "";
100
+ if (defaults.includes(val)) setPressed(el, true);
101
+ if (disabled) {
102
+ el.setAttribute("disabled", "");
103
+ el.setAttribute("aria-disabled", "true");
104
+ }
105
+ });
106
+
107
+ // First enabled item gets tabindex 0
108
+ const first = items()[0];
109
+ if (first) first.setAttribute("tabindex", "0");
110
+ }
111
+
112
+ function initAll() {
113
+ document.querySelectorAll<HTMLElement>("[data-component='toggle-group']").forEach(init);
114
+ }
115
+
116
+ if (document.readyState === "loading") {
117
+ document.addEventListener("DOMContentLoaded", initAll);
118
+ } else {
119
+ initAll();
120
+ }
121
+ document.addEventListener("astro:page-load", initAll);
@@ -0,0 +1,26 @@
1
+ ---
2
+ import { tv } from "tailwind-variants";
3
+
4
+ const toolbar = tv({
5
+ base: "flex items-center gap-1 rounded-md border bg-background p-1",
6
+ });
7
+
8
+ interface Props {
9
+ orientation?: "horizontal" | "vertical";
10
+ class?: string;
11
+ [key: string]: unknown;
12
+ }
13
+
14
+ const { orientation = "horizontal", class: className, ...rest } = Astro.props;
15
+ ---
16
+
17
+ <div
18
+ class={toolbar({ class: className })}
19
+ data-component="toolbar"
20
+ data-orientation={orientation}
21
+ role="toolbar"
22
+ aria-orientation={orientation}
23
+ {...rest}
24
+ >
25
+ <slot />
26
+ </div>
@@ -0,0 +1,29 @@
1
+ ---
2
+ import { tv } from "tailwind-variants";
3
+
4
+ const toolbarButton = tv({
5
+ base: "inline-flex h-9 w-9 items-center justify-center rounded-md text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",
6
+ });
7
+
8
+ interface Props {
9
+ pressed?: boolean;
10
+ disabled?: boolean;
11
+ class?: string;
12
+ [key: string]: unknown;
13
+ }
14
+
15
+ const { pressed, disabled = false, class: className, ...rest } = Astro.props;
16
+ ---
17
+
18
+ <button
19
+ class={toolbarButton({ class: className })}
20
+ data-part="button"
21
+ type="button"
22
+ tabindex="-1"
23
+ disabled={disabled || undefined}
24
+ aria-pressed={pressed !== undefined ? String(pressed) : undefined}
25
+ data-state={pressed ? "on" : undefined}
26
+ {...rest}
27
+ >
28
+ <slot />
29
+ </button>
@@ -0,0 +1,14 @@
1
+ ---
2
+ import { tv } from "tailwind-variants";
3
+
4
+ const sep = tv({ base: "mx-1 h-6 w-px bg-border" });
5
+
6
+ interface Props {
7
+ class?: string;
8
+ [key: string]: unknown;
9
+ }
10
+
11
+ const { class: className, ...rest } = Astro.props;
12
+ ---
13
+
14
+ <div class={sep({ class: className })} role="separator" aria-orientation="vertical" {...rest}></div>
@@ -0,0 +1,3 @@
1
+ export { default as Toolbar } from "./Toolbar.astro";
2
+ export { default as ToolbarButton } from "./ToolbarButton.astro";
3
+ export { default as ToolbarSeparator } from "./ToolbarSeparator.astro";
@@ -0,0 +1,65 @@
1
+ function init(root: HTMLElement) {
2
+ if (root.hasAttribute("data-initialized")) return;
3
+ root.setAttribute("data-initialized", "");
4
+
5
+ const orientation = root.getAttribute("data-orientation") || "horizontal";
6
+
7
+ const items = () =>
8
+ Array.from(
9
+ root.querySelectorAll<HTMLElement>(
10
+ "[data-part='button']:not([disabled])",
11
+ ),
12
+ );
13
+
14
+ // First item gets tabindex 0
15
+ const first = items()[0];
16
+ if (first) first.setAttribute("tabindex", "0");
17
+
18
+ root.addEventListener("keydown", (e) => {
19
+ const target = (e.target as HTMLElement).closest<HTMLElement>(
20
+ "[data-part='button']",
21
+ );
22
+ if (!target) return;
23
+
24
+ const enabled = items();
25
+ const idx = enabled.indexOf(target);
26
+ if (idx === -1) return;
27
+
28
+ const nextKey = orientation === "horizontal" ? "ArrowRight" : "ArrowDown";
29
+ const prevKey = orientation === "horizontal" ? "ArrowLeft" : "ArrowUp";
30
+
31
+ let next: number | null = null;
32
+ switch (e.key) {
33
+ case nextKey:
34
+ next = (idx + 1) % enabled.length;
35
+ break;
36
+ case prevKey:
37
+ next = (idx - 1 + enabled.length) % enabled.length;
38
+ break;
39
+ case "Home":
40
+ next = 0;
41
+ break;
42
+ case "End":
43
+ next = enabled.length - 1;
44
+ break;
45
+ default:
46
+ return;
47
+ }
48
+
49
+ e.preventDefault();
50
+ target.setAttribute("tabindex", "-1");
51
+ enabled[next].setAttribute("tabindex", "0");
52
+ enabled[next].focus();
53
+ });
54
+ }
55
+
56
+ function initAll() {
57
+ document.querySelectorAll<HTMLElement>("[data-component='toolbar']").forEach(init);
58
+ }
59
+
60
+ if (document.readyState === "loading") {
61
+ document.addEventListener("DOMContentLoaded", initAll);
62
+ } else {
63
+ initAll();
64
+ }
65
+ document.addEventListener("astro:page-load", initAll);