@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,173 @@
1
+ import { ScrollLock } from "@dogsbay/primitives/scroll-lock";
2
+ import { FocusTrap } from "@dogsbay/primitives/focus-trap";
3
+ import { markOthersInert } from "@dogsbay/primitives/inert";
4
+ import { createPortal } from "@dogsbay/primitives/portal";
5
+
6
+ interface SheetInstance {
7
+ root: HTMLElement;
8
+ content: HTMLElement;
9
+ backdrop: HTMLElement;
10
+ focusTrap: FocusTrap;
11
+ cleanupPortal: (() => void) | null;
12
+ cleanupInert: (() => void) | null;
13
+ open: boolean;
14
+ openedBy: HTMLElement | null;
15
+ }
16
+
17
+ const instances = new WeakMap<HTMLElement, SheetInstance>();
18
+
19
+ let idCounter = 0;
20
+ function uniqueId(prefix: string) {
21
+ return `${prefix}-${++idCounter}`;
22
+ }
23
+
24
+ function ownParts(root: HTMLElement, selector: string): HTMLElement[] {
25
+ return Array.from(root.querySelectorAll(selector)).filter(
26
+ (el) => el.closest("[data-component='sheet']") === root,
27
+ ) as HTMLElement[];
28
+ }
29
+
30
+ function initSheet(root: HTMLElement) {
31
+ if (instances.has(root)) return;
32
+
33
+ const content = ownParts(root, "[data-part='content']")[0] as HTMLElement | undefined;
34
+ const backdrop = ownParts(root, "[data-part='backdrop']")[0] as HTMLElement | undefined;
35
+
36
+ if (!content) return;
37
+
38
+ // Generate IDs
39
+ const sheetId = uniqueId("base-sheet");
40
+ if (!content.id) content.id = `${sheetId}-content`;
41
+
42
+ // Link title for aria-labelledby
43
+ const title = ownParts(root, "[data-part='title']")[0] as HTMLElement | undefined;
44
+ if (title) {
45
+ if (!title.id) title.id = `${sheetId}-title`;
46
+ content.setAttribute("aria-labelledby", title.id);
47
+ }
48
+
49
+ const instance: SheetInstance = {
50
+ root,
51
+ content,
52
+ backdrop: backdrop!,
53
+ focusTrap: new FocusTrap(content),
54
+ cleanupPortal: null,
55
+ cleanupInert: null,
56
+ open: false,
57
+ openedBy: null,
58
+ };
59
+
60
+ instances.set(root, instance);
61
+
62
+ // Escape key — use capture phase to run before other handlers
63
+ document.addEventListener("keydown", (e) => {
64
+ if (e.key === "Escape" && instance.open) {
65
+ e.preventDefault();
66
+ e.stopImmediatePropagation();
67
+ closeSheet(root);
68
+ }
69
+ }, true);
70
+
71
+ // Bind triggers
72
+ ownParts(root, "[data-part='trigger']").forEach((trigger) => {
73
+ const actualTrigger = trigger.hasAttribute("data-as-child")
74
+ ? (trigger.firstElementChild as HTMLElement) || trigger
75
+ : trigger;
76
+
77
+ actualTrigger.addEventListener("click", () => {
78
+ instance.openedBy = actualTrigger;
79
+ openSheet(root);
80
+ });
81
+ });
82
+
83
+ // Bind close buttons
84
+ ownParts(root, "[data-part='close']").forEach((close) => {
85
+ const actualClose = close.hasAttribute("data-as-child")
86
+ ? (close.firstElementChild as HTMLElement) || close
87
+ : close;
88
+
89
+ actualClose.addEventListener("click", () => closeSheet(root));
90
+ });
91
+
92
+ // Backdrop click
93
+ if (backdrop) {
94
+ backdrop.addEventListener("click", () => closeSheet(root));
95
+ }
96
+
97
+ }
98
+
99
+ function openSheet(root: HTMLElement) {
100
+ const instance = instances.get(root);
101
+ if (!instance || instance.open) return;
102
+ instance.open = true;
103
+
104
+ // Portal
105
+ instance.cleanupPortal = createPortal(instance.content, instance.content.id);
106
+ if (instance.backdrop) {
107
+ createPortal(instance.backdrop, `${instance.content.id}-backdrop`);
108
+ }
109
+
110
+ // Show
111
+ instance.content.hidden = false;
112
+ instance.content.setAttribute("data-state", "open");
113
+ if (instance.backdrop) {
114
+ instance.backdrop.hidden = false;
115
+ instance.backdrop.setAttribute("data-state", "open");
116
+ }
117
+
118
+ // Lock scroll
119
+ ScrollLock.activate();
120
+
121
+ // Focus first focusable element
122
+ requestAnimationFrame(() => {
123
+ const focusable = instance.content.querySelector(
124
+ 'a, button, input, [tabindex]:not([tabindex="-1"])',
125
+ ) as HTMLElement | null;
126
+ focusable?.focus();
127
+ });
128
+ }
129
+
130
+ function closeSheet(root: HTMLElement) {
131
+ const instance = instances.get(root);
132
+ if (!instance || !instance.open) return;
133
+ instance.open = false;
134
+
135
+ // Unlock scroll
136
+ ScrollLock.deactivate();
137
+
138
+ // Hide
139
+ instance.content.setAttribute("data-state", "closed");
140
+ instance.content.hidden = true;
141
+ if (instance.backdrop) {
142
+ instance.backdrop.setAttribute("data-state", "closed");
143
+ instance.backdrop.hidden = true;
144
+ }
145
+
146
+ // Cleanup portal
147
+ if (instance.cleanupPortal) {
148
+ instance.cleanupPortal();
149
+ instance.cleanupPortal = null;
150
+ }
151
+
152
+ // Return focus
153
+ instance.openedBy?.focus();
154
+ instance.openedBy = null;
155
+ }
156
+
157
+ // Auto-initialize
158
+ function init() {
159
+ document
160
+ .querySelectorAll("[data-component='sheet']")
161
+ .forEach((el) => {
162
+ initSheet(el as HTMLElement);
163
+ });
164
+ }
165
+
166
+ if (document.readyState === "loading") {
167
+ document.addEventListener("DOMContentLoaded", init);
168
+ } else {
169
+ init();
170
+ }
171
+ document.addEventListener("astro:page-load", init);
172
+
173
+ export { initSheet, openSheet, closeSheet };
@@ -0,0 +1,113 @@
1
+ ---
2
+ import { tv } from "tailwind-variants";
3
+
4
+ const sidebarOuter = tv({
5
+ base: "group peer text-sidebar-foreground max-md:hidden",
6
+ });
7
+
8
+ const sidebarGap = tv({
9
+ base: "relative w-[var(--sidebar-width)] bg-transparent transition-[width] duration-200 ease-linear group-data-[collapsible=offcanvas]:w-0 group-data-[side=right]:rotate-180",
10
+ });
11
+
12
+ const sidebarContainer = tv({
13
+ base: "fixed inset-y-0 z-10 h-svh w-[var(--sidebar-width)] transition-[left,right,width] duration-200 ease-linear max-md:hidden md:flex",
14
+ });
15
+
16
+ const sidebarInner = tv({
17
+ base: "flex size-full flex-col bg-sidebar",
18
+ });
19
+
20
+ interface Props {
21
+ side?: "left" | "right";
22
+ variant?: "sidebar" | "floating" | "inset";
23
+ collapsible?: "offcanvas" | "icon" | "none";
24
+ defaultOpen?: boolean;
25
+ class?: string;
26
+ [key: string]: unknown;
27
+ }
28
+
29
+ const {
30
+ side = "left",
31
+ variant = "sidebar",
32
+ collapsible = "offcanvas",
33
+ defaultOpen = true,
34
+ class: className,
35
+ ...rest
36
+ } = Astro.props;
37
+
38
+ // Determine gap class based on variant
39
+ const isFloatingOrInset = variant === "floating" || variant === "inset";
40
+ const gapIconClass = isFloatingOrInset
41
+ ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+1rem+2px)]"
42
+ : "group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)]";
43
+
44
+ // Container border/padding based on variant
45
+ const containerVariantClass = isFloatingOrInset
46
+ ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+1rem+2px)]"
47
+ : `group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)] ${side === "left" ? "group-data-[side=left]:border-r" : ""} ${side === "right" ? "group-data-[side=right]:border-l" : ""}`;
48
+
49
+ // Inner variant styling
50
+ const innerVariantClass = isFloatingOrInset
51
+ ? "group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border"
52
+ : "";
53
+
54
+ // Side positioning
55
+ const sideClass = side === "left"
56
+ ? "data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
57
+ : "data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]";
58
+
59
+ const mobileSideClass = side === "left" ? "left-0" : "right-0";
60
+ ---
61
+
62
+ {collapsible === "none" ? (
63
+ <div
64
+ data-component="sidebar"
65
+ data-collapsible="none"
66
+ data-side={side}
67
+ data-variant={variant}
68
+ data-default-open={String(defaultOpen)}
69
+ class={`flex h-full w-[var(--sidebar-width)] flex-col bg-sidebar text-sidebar-foreground ${className || ""}`}
70
+ {...rest}
71
+ >
72
+ <slot />
73
+ </div>
74
+ ) : (
75
+ <div
76
+ data-component="sidebar"
77
+ data-collapsible={collapsible}
78
+ data-side={side}
79
+ data-variant={variant}
80
+ data-default-open={String(defaultOpen)}
81
+ >
82
+ {/* Desktop sidebar */}
83
+ <div
84
+ class={sidebarOuter()}
85
+ data-sidebar-desktop
86
+ data-state="expanded"
87
+ data-collapsible=""
88
+ data-variant={variant}
89
+ data-side={side}
90
+ >
91
+ <div class={`${sidebarGap()} ${gapIconClass}`} />
92
+ <div
93
+ class={`${sidebarContainer()} ${containerVariantClass} ${sideClass} ${className || ""}`}
94
+ data-side={side}
95
+ {...rest}
96
+ >
97
+ <div class={`${sidebarInner()} ${innerVariantClass}`} data-sidebar="sidebar-inner">
98
+ <slot />
99
+ </div>
100
+ </div>
101
+ </div>
102
+
103
+ {/* Mobile backdrop + sidebar shell (content moved here by JS) */}
104
+ <div class="fixed inset-0 z-50 bg-black/80" data-sidebar-mobile-backdrop hidden></div>
105
+ <div
106
+ class={`fixed inset-y-0 z-50 flex h-svh w-[18rem] flex-col bg-sidebar p-0 text-sidebar-foreground ${mobileSideClass}`}
107
+ data-sidebar-mobile
108
+ data-state="closed"
109
+ hidden
110
+ >
111
+ </div>
112
+ </div>
113
+ )}
@@ -0,0 +1,18 @@
1
+ ---
2
+ import { tv } from "tailwind-variants";
3
+
4
+ const sidebarContent = tv({
5
+ base: "flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]",
6
+ });
7
+
8
+ interface Props {
9
+ class?: string;
10
+ [key: string]: unknown;
11
+ }
12
+
13
+ const { class: className, ...rest } = Astro.props;
14
+ ---
15
+
16
+ <div class={sidebarContent({ class: className })} data-sidebar="content" {...rest}>
17
+ <slot />
18
+ </div>
@@ -0,0 +1,18 @@
1
+ ---
2
+ import { tv } from "tailwind-variants";
3
+
4
+ const sidebarFooter = tv({
5
+ base: "flex flex-col gap-2 p-2",
6
+ });
7
+
8
+ interface Props {
9
+ class?: string;
10
+ [key: string]: unknown;
11
+ }
12
+
13
+ const { class: className, ...rest } = Astro.props;
14
+ ---
15
+
16
+ <div class={sidebarFooter({ class: className })} data-sidebar="footer" {...rest}>
17
+ <slot />
18
+ </div>
@@ -0,0 +1,18 @@
1
+ ---
2
+ import { tv } from "tailwind-variants";
3
+
4
+ const sidebarGroup = tv({
5
+ base: "relative flex w-full min-w-0 flex-col p-2",
6
+ });
7
+
8
+ interface Props {
9
+ class?: string;
10
+ [key: string]: unknown;
11
+ }
12
+
13
+ const { class: className, ...rest } = Astro.props;
14
+ ---
15
+
16
+ <div class={sidebarGroup({ class: className })} data-sidebar="group" {...rest}>
17
+ <slot />
18
+ </div>
@@ -0,0 +1,18 @@
1
+ ---
2
+ import { tv } from "tailwind-variants";
3
+
4
+ const sidebarGroupContent = tv({
5
+ base: "w-full text-sm",
6
+ });
7
+
8
+ interface Props {
9
+ class?: string;
10
+ [key: string]: unknown;
11
+ }
12
+
13
+ const { class: className, ...rest } = Astro.props;
14
+ ---
15
+
16
+ <div class={sidebarGroupContent({ class: className })} data-sidebar="group-content" {...rest}>
17
+ <slot />
18
+ </div>
@@ -0,0 +1,18 @@
1
+ ---
2
+ import { tv } from "tailwind-variants";
3
+
4
+ const sidebarGroupLabel = tv({
5
+ base: "flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
6
+ });
7
+
8
+ interface Props {
9
+ class?: string;
10
+ [key: string]: unknown;
11
+ }
12
+
13
+ const { class: className, ...rest } = Astro.props;
14
+ ---
15
+
16
+ <div class={sidebarGroupLabel({ class: className })} data-sidebar="group-label" {...rest}>
17
+ <slot />
18
+ </div>
@@ -0,0 +1,18 @@
1
+ ---
2
+ import { tv } from "tailwind-variants";
3
+
4
+ const sidebarHeader = tv({
5
+ base: "flex flex-col gap-2 p-2",
6
+ });
7
+
8
+ interface Props {
9
+ class?: string;
10
+ [key: string]: unknown;
11
+ }
12
+
13
+ const { class: className, ...rest } = Astro.props;
14
+ ---
15
+
16
+ <div class={sidebarHeader({ class: className })} data-sidebar="header" {...rest}>
17
+ <slot />
18
+ </div>
@@ -0,0 +1,18 @@
1
+ ---
2
+ import { tv } from "tailwind-variants";
3
+
4
+ const sidebarInset = tv({
5
+ base: "relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
6
+ });
7
+
8
+ interface Props {
9
+ class?: string;
10
+ [key: string]: unknown;
11
+ }
12
+
13
+ const { class: className, ...rest } = Astro.props;
14
+ ---
15
+
16
+ <div class={sidebarInset({ class: className })} {...rest}>
17
+ <slot />
18
+ </div>
@@ -0,0 +1,18 @@
1
+ ---
2
+ import { tv } from "tailwind-variants";
3
+
4
+ const sidebarMenu = tv({
5
+ base: "flex w-full min-w-0 flex-col gap-0",
6
+ });
7
+
8
+ interface Props {
9
+ class?: string;
10
+ [key: string]: unknown;
11
+ }
12
+
13
+ const { class: className, ...rest } = Astro.props;
14
+ ---
15
+
16
+ <ul class={sidebarMenu({ class: className })} data-sidebar="menu" {...rest}>
17
+ <slot />
18
+ </ul>
@@ -0,0 +1,18 @@
1
+ ---
2
+ import { tv } from "tailwind-variants";
3
+
4
+ const sidebarMenuBadge = tv({
5
+ base: "pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-[active]/menu-button:text-sidebar-accent-foreground",
6
+ });
7
+
8
+ interface Props {
9
+ class?: string;
10
+ [key: string]: unknown;
11
+ }
12
+
13
+ const { class: className, ...rest } = Astro.props;
14
+ ---
15
+
16
+ <div class={sidebarMenuBadge({ class: className })} data-sidebar="menu-badge" {...rest}>
17
+ <slot />
18
+ </div>
@@ -0,0 +1,71 @@
1
+ ---
2
+ import { tv, type VariantProps } from "tailwind-variants";
3
+
4
+ const sidebarMenuButton = tv({
5
+ base: "peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active]:bg-sidebar-accent data-[active]:font-medium data-[active]:text-sidebar-accent-foreground [&>span:last-child]:truncate [&_svg]:size-4 [&_svg]:shrink-0 group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2",
6
+ variants: {
7
+ variant: {
8
+ default: "",
9
+ outline:
10
+ "bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]",
11
+ },
12
+ size: {
13
+ default: "h-8 text-sm",
14
+ sm: "h-7 text-xs",
15
+ lg: "h-12 text-sm group-data-[collapsible=icon]:!p-0",
16
+ },
17
+ },
18
+ defaultVariants: {
19
+ variant: "default",
20
+ size: "default",
21
+ },
22
+ });
23
+
24
+ type MenuButtonVariants = VariantProps<typeof sidebarMenuButton>;
25
+
26
+ interface Props {
27
+ variant?: MenuButtonVariants["variant"];
28
+ size?: MenuButtonVariants["size"];
29
+ isActive?: boolean;
30
+ href?: string;
31
+ class?: string;
32
+ [key: string]: unknown;
33
+ }
34
+
35
+ const {
36
+ variant = "default",
37
+ size = "default",
38
+ isActive = false,
39
+ href,
40
+ class: className,
41
+ ...rest
42
+ } = Astro.props;
43
+
44
+ const classes = sidebarMenuButton({ variant, size, class: className });
45
+ ---
46
+
47
+ {
48
+ href ? (
49
+ <a
50
+ class={classes}
51
+ href={href}
52
+ data-sidebar="menu-button"
53
+ data-size={size}
54
+ data-active={isActive || undefined}
55
+ {...rest}
56
+ >
57
+ <slot />
58
+ </a>
59
+ ) : (
60
+ <button
61
+ class={classes}
62
+ data-sidebar="menu-button"
63
+ data-size={size}
64
+ data-active={isActive || undefined}
65
+ type="button"
66
+ {...rest}
67
+ >
68
+ <slot />
69
+ </button>
70
+ )
71
+ }
@@ -0,0 +1,18 @@
1
+ ---
2
+ import { tv } from "tailwind-variants";
3
+
4
+ const sidebarMenuItem = tv({
5
+ base: "group/menu-item relative",
6
+ });
7
+
8
+ interface Props {
9
+ class?: string;
10
+ [key: string]: unknown;
11
+ }
12
+
13
+ const { class: className, ...rest } = Astro.props;
14
+ ---
15
+
16
+ <li class={sidebarMenuItem({ class: className })} data-sidebar="menu-item" {...rest}>
17
+ <slot />
18
+ </li>
@@ -0,0 +1,18 @@
1
+ ---
2
+ import { tv } from "tailwind-variants";
3
+
4
+ const sidebarMenuSub = tv({
5
+ base: "mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden",
6
+ });
7
+
8
+ interface Props {
9
+ class?: string;
10
+ [key: string]: unknown;
11
+ }
12
+
13
+ const { class: className, ...rest } = Astro.props;
14
+ ---
15
+
16
+ <ul class={sidebarMenuSub({ class: className })} data-sidebar="menu-sub" {...rest}>
17
+ <slot />
18
+ </ul>
@@ -0,0 +1,45 @@
1
+ ---
2
+ import { tv, type VariantProps } from "tailwind-variants";
3
+
4
+ const sidebarMenuSubButton = tv({
5
+ base: "flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active]:bg-sidebar-accent data-[active]:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground group-data-[collapsible=icon]:hidden",
6
+ variants: {
7
+ size: {
8
+ sm: "text-xs",
9
+ md: "text-sm",
10
+ },
11
+ },
12
+ defaultVariants: {
13
+ size: "md",
14
+ },
15
+ });
16
+
17
+ type SubButtonVariants = VariantProps<typeof sidebarMenuSubButton>;
18
+
19
+ interface Props {
20
+ size?: SubButtonVariants["size"];
21
+ isActive?: boolean;
22
+ href?: string;
23
+ class?: string;
24
+ [key: string]: unknown;
25
+ }
26
+
27
+ const {
28
+ size = "md",
29
+ isActive = false,
30
+ href,
31
+ class: className,
32
+ ...rest
33
+ } = Astro.props;
34
+ ---
35
+
36
+ <a
37
+ class={sidebarMenuSubButton({ size, class: className })}
38
+ href={href || "#"}
39
+ data-sidebar="menu-sub-button"
40
+ data-size={size}
41
+ data-active={isActive || undefined}
42
+ {...rest}
43
+ >
44
+ <slot />
45
+ </a>
@@ -0,0 +1,12 @@
1
+ ---
2
+ interface Props {
3
+ class?: string;
4
+ [key: string]: unknown;
5
+ }
6
+
7
+ const { class: className, ...rest } = Astro.props;
8
+ ---
9
+
10
+ <li class={className} data-sidebar="menu-sub-item" {...rest}>
11
+ <slot />
12
+ </li>