@cl-light-ds/ui 0.1.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 (254) hide show
  1. package/README.md +45 -0
  2. package/package.json +59 -0
  3. package/src/components/accordion/Accordion.astro +248 -0
  4. package/src/components/accordion/AccordionContent.astro +26 -0
  5. package/src/components/accordion/AccordionItem.astro +36 -0
  6. package/src/components/accordion/AccordionTrigger.astro +118 -0
  7. package/src/components/accordion/CHANGELOG.md +41 -0
  8. package/src/components/accordion/index.ts +4 -0
  9. package/src/components/alert/Alert.astro +167 -0
  10. package/src/components/alert/AlertDescription.astro +24 -0
  11. package/src/components/alert/AlertTitle.astro +24 -0
  12. package/src/components/alert/CHANGELOG.md +5 -0
  13. package/src/components/alert/index.ts +4 -0
  14. package/src/components/avatar/Avatar.astro +197 -0
  15. package/src/components/avatar/AvatarBadge.astro +44 -0
  16. package/src/components/avatar/AvatarFallback.astro +26 -0
  17. package/src/components/avatar/AvatarGroup.astro +26 -0
  18. package/src/components/avatar/AvatarGroupCount.astro +30 -0
  19. package/src/components/avatar/AvatarImage.astro +46 -0
  20. package/src/components/avatar/CHANGELOG.md +44 -0
  21. package/src/components/avatar/index.ts +6 -0
  22. package/src/components/badge/Badge.astro +167 -0
  23. package/src/components/badge/CHANGELOG.md +49 -0
  24. package/src/components/badge/index.ts +2 -0
  25. package/src/components/breadcrumb/Breadcrumb.astro +76 -0
  26. package/src/components/breadcrumb/BreadcrumbItem.astro +32 -0
  27. package/src/components/breadcrumb/BreadcrumbList.astro +26 -0
  28. package/src/components/breadcrumb/BreadcrumbSeparator.astro +26 -0
  29. package/src/components/breadcrumb/CHANGELOG.md +24 -0
  30. package/src/components/breadcrumb/index.ts +5 -0
  31. package/src/components/button/Button.astro +233 -0
  32. package/src/components/button/CHANGELOG.md +41 -0
  33. package/src/components/button/index.ts +2 -0
  34. package/src/components/button-group/ButtonGroup.astro +130 -0
  35. package/src/components/button-group/ButtonGroupSeparator.astro +30 -0
  36. package/src/components/button-group/ButtonGroupText.astro +21 -0
  37. package/src/components/button-group/CHANGELOG.md +34 -0
  38. package/src/components/button-group/index.ts +3 -0
  39. package/src/components/card/CHANGELOG.md +119 -0
  40. package/src/components/card/Card.astro +182 -0
  41. package/src/components/card/CardAction.astro +26 -0
  42. package/src/components/card/CardContent.astro +28 -0
  43. package/src/components/card/CardDescription.astro +28 -0
  44. package/src/components/card/CardFooter.astro +24 -0
  45. package/src/components/card/CardHeader.astro +30 -0
  46. package/src/components/card/CardMedia.astro +27 -0
  47. package/src/components/card/CardOverlay.astro +32 -0
  48. package/src/components/card/CardTitle.astro +21 -0
  49. package/src/components/card/index.ts +10 -0
  50. package/src/components/carousel/CHANGELOG.md +5 -0
  51. package/src/components/carousel/Carousel.astro +106 -0
  52. package/src/components/carousel/CarouselSlide.astro +22 -0
  53. package/src/components/carousel/index.ts +3 -0
  54. package/src/components/checkbox/CHANGELOG.md +58 -0
  55. package/src/components/checkbox/Checkbox.astro +159 -0
  56. package/src/components/checkbox/index.ts +1 -0
  57. package/src/components/collapsible/CHANGELOG.md +5 -0
  58. package/src/components/collapsible/Collapsible.astro +202 -0
  59. package/src/components/collapsible/CollapsibleContent.astro +36 -0
  60. package/src/components/collapsible/CollapsibleTrigger.astro +34 -0
  61. package/src/components/collapsible/index.ts +4 -0
  62. package/src/components/combobox/CHANGELOG.md +27 -0
  63. package/src/components/combobox/Combobox.astro +365 -0
  64. package/src/components/combobox/ComboboxContent.astro +37 -0
  65. package/src/components/combobox/ComboboxEmpty.astro +18 -0
  66. package/src/components/combobox/ComboboxGroup.astro +19 -0
  67. package/src/components/combobox/ComboboxInput.astro +74 -0
  68. package/src/components/combobox/ComboboxItem.astro +39 -0
  69. package/src/components/combobox/ComboboxLabel.astro +18 -0
  70. package/src/components/combobox/ComboboxList.astro +21 -0
  71. package/src/components/combobox/ComboboxSeparator.astro +17 -0
  72. package/src/components/combobox/ComboboxTrigger.astro +30 -0
  73. package/src/components/combobox/ComboboxValue.astro +22 -0
  74. package/src/components/combobox/index.ts +11 -0
  75. package/src/components/date/CHANGELOG.md +18 -0
  76. package/src/components/date/Date.astro +137 -0
  77. package/src/components/date/index.ts +2 -0
  78. package/src/components/dialog/CHANGELOG.md +39 -0
  79. package/src/components/dialog/Dialog.astro +196 -0
  80. package/src/components/dialog/DialogClose.astro +23 -0
  81. package/src/components/dialog/DialogContent.astro +42 -0
  82. package/src/components/dialog/DialogDescription.astro +18 -0
  83. package/src/components/dialog/DialogFooter.astro +18 -0
  84. package/src/components/dialog/DialogHeader.astro +18 -0
  85. package/src/components/dialog/DialogOverlay.astro +19 -0
  86. package/src/components/dialog/DialogTitle.astro +18 -0
  87. package/src/components/dialog/DialogTrigger.astro +37 -0
  88. package/src/components/dialog/index.ts +9 -0
  89. package/src/components/dropdown-menu/CHANGELOG.md +194 -0
  90. package/src/components/dropdown-menu/DropdownMenu.astro +226 -0
  91. package/src/components/dropdown-menu/DropdownMenuCheckboxItem.astro +114 -0
  92. package/src/components/dropdown-menu/DropdownMenuContent.astro +42 -0
  93. package/src/components/dropdown-menu/DropdownMenuGroup.astro +19 -0
  94. package/src/components/dropdown-menu/DropdownMenuItem.astro +220 -0
  95. package/src/components/dropdown-menu/DropdownMenuItemContent.astro +79 -0
  96. package/src/components/dropdown-menu/DropdownMenuLabel.astro +20 -0
  97. package/src/components/dropdown-menu/DropdownMenuPortal.astro +13 -0
  98. package/src/components/dropdown-menu/DropdownMenuRadioGroup.astro +13 -0
  99. package/src/components/dropdown-menu/DropdownMenuRadioItem.astro +101 -0
  100. package/src/components/dropdown-menu/DropdownMenuSeparator.astro +18 -0
  101. package/src/components/dropdown-menu/DropdownMenuShortcut.astro +18 -0
  102. package/src/components/dropdown-menu/DropdownMenuTrigger.astro +49 -0
  103. package/src/components/dropdown-menu/dropdown-menu-item-variants.ts +24 -0
  104. package/src/components/dropdown-menu/index.ts +12 -0
  105. package/src/components/field/CHANGELOG.md +33 -0
  106. package/src/components/field/Field.astro +664 -0
  107. package/src/components/field/FieldContent.astro +20 -0
  108. package/src/components/field/FieldDescription.astro +22 -0
  109. package/src/components/field/FieldError.astro +51 -0
  110. package/src/components/field/FieldGroup.astro +20 -0
  111. package/src/components/field/FieldLabel.astro +22 -0
  112. package/src/components/field/FieldLegend.astro +23 -0
  113. package/src/components/field/FieldSeparator.astro +30 -0
  114. package/src/components/field/FieldSet.astro +20 -0
  115. package/src/components/field/FieldTitle.astro +20 -0
  116. package/src/components/field/index.ts +10 -0
  117. package/src/components/hover-card/CHANGELOG.md +20 -0
  118. package/src/components/hover-card/HoverCard.astro +235 -0
  119. package/src/components/hover-card/HoverCardContent.astro +54 -0
  120. package/src/components/hover-card/HoverCardTrigger.astro +38 -0
  121. package/src/components/hover-card/index.ts +3 -0
  122. package/src/components/input/CHANGELOG.md +29 -0
  123. package/src/components/input/Input.astro +130 -0
  124. package/src/components/input/index.ts +2 -0
  125. package/src/components/input-group/CHANGELOG.md +49 -0
  126. package/src/components/input-group/InputGroup.astro +135 -0
  127. package/src/components/input-group/InputGroupAddon.astro +49 -0
  128. package/src/components/input-group/InputGroupButton.astro +58 -0
  129. package/src/components/input-group/InputGroupInput.astro +18 -0
  130. package/src/components/input-group/InputGroupText.astro +21 -0
  131. package/src/components/input-group/InputGroupTextarea.astro +17 -0
  132. package/src/components/input-group/controlClasses.ts +2 -0
  133. package/src/components/input-group/index.ts +6 -0
  134. package/src/components/item/CHANGELOG.md +27 -0
  135. package/src/components/item/Item.astro +122 -0
  136. package/src/components/item/ItemActions.astro +21 -0
  137. package/src/components/item/ItemContent.astro +25 -0
  138. package/src/components/item/ItemDescription.astro +25 -0
  139. package/src/components/item/ItemFooter.astro +24 -0
  140. package/src/components/item/ItemGroup.astro +24 -0
  141. package/src/components/item/ItemHeader.astro +24 -0
  142. package/src/components/item/ItemMedia.astro +47 -0
  143. package/src/components/item/ItemSeparator.astro +21 -0
  144. package/src/components/item/ItemTitle.astro +25 -0
  145. package/src/components/item/index.ts +10 -0
  146. package/src/components/kbd/CHANGELOG.md +5 -0
  147. package/src/components/kbd/Kbd.astro +145 -0
  148. package/src/components/kbd/KbdGroup.astro +55 -0
  149. package/src/components/kbd/index.ts +2 -0
  150. package/src/components/label/CHANGELOG.md +28 -0
  151. package/src/components/label/Label.astro +97 -0
  152. package/src/components/label/index.ts +2 -0
  153. package/src/components/link-group/CHANGELOG.md +75 -0
  154. package/src/components/link-group/LinkGroup.astro +67 -0
  155. package/src/components/link-group/LinkGroupItem.astro +32 -0
  156. package/src/components/link-group/LinkGroupList.astro +25 -0
  157. package/src/components/link-group/LinkGroupTitle.astro +22 -0
  158. package/src/components/link-group/index.ts +5 -0
  159. package/src/components/link-group/link-group-list-variants.ts +15 -0
  160. package/src/components/marquee/CHANGELOG.md +5 -0
  161. package/src/components/marquee/Marquee.astro +119 -0
  162. package/src/components/marquee/index.ts +2 -0
  163. package/src/components/native-select/CHANGELOG.md +5 -0
  164. package/src/components/native-select/NativeSelect.astro +125 -0
  165. package/src/components/native-select/NativeSelectOptGroup.astro +14 -0
  166. package/src/components/native-select/NativeSelectOption.astro +9 -0
  167. package/src/components/native-select/index.ts +3 -0
  168. package/src/components/navigation-menu/CHANGELOG.md +63 -0
  169. package/src/components/navigation-menu/NavigationMenu.astro +414 -0
  170. package/src/components/navigation-menu/NavigationMenuContent.astro +37 -0
  171. package/src/components/navigation-menu/NavigationMenuIndicator.astro +24 -0
  172. package/src/components/navigation-menu/NavigationMenuItem.astro +22 -0
  173. package/src/components/navigation-menu/NavigationMenuLink.astro +18 -0
  174. package/src/components/navigation-menu/NavigationMenuList.astro +21 -0
  175. package/src/components/navigation-menu/NavigationMenuPositioner.astro +44 -0
  176. package/src/components/navigation-menu/NavigationMenuTrigger.astro +30 -0
  177. package/src/components/navigation-menu/NavigationMenuViewport.astro +19 -0
  178. package/src/components/navigation-menu/index.ts +10 -0
  179. package/src/components/popover/CHANGELOG.md +5 -0
  180. package/src/components/popover/Popover.astro +210 -0
  181. package/src/components/popover/PopoverClose.astro +18 -0
  182. package/src/components/popover/PopoverContent.astro +49 -0
  183. package/src/components/popover/PopoverDescription.astro +18 -0
  184. package/src/components/popover/PopoverHeader.astro +18 -0
  185. package/src/components/popover/PopoverTitle.astro +18 -0
  186. package/src/components/popover/PopoverTrigger.astro +29 -0
  187. package/src/components/popover/index.ts +7 -0
  188. package/src/components/radio-group/CHANGELOG.md +9 -0
  189. package/src/components/radio-group/RadioGroup.astro +81 -0
  190. package/src/components/radio-group/RadioGroupItem.astro +42 -0
  191. package/src/components/radio-group/index.ts +3 -0
  192. package/src/components/select/CHANGELOG.md +39 -0
  193. package/src/components/select/Select.astro +373 -0
  194. package/src/components/select/SelectContent.astro +91 -0
  195. package/src/components/select/SelectGroup.astro +19 -0
  196. package/src/components/select/SelectItem.astro +48 -0
  197. package/src/components/select/SelectLabel.astro +18 -0
  198. package/src/components/select/SelectSeparator.astro +17 -0
  199. package/src/components/select/SelectTrigger.astro +34 -0
  200. package/src/components/select/SelectValue.astro +22 -0
  201. package/src/components/select/index.ts +8 -0
  202. package/src/components/separator/CHANGELOG.md +5 -0
  203. package/src/components/separator/Separator.astro +60 -0
  204. package/src/components/separator/index.ts +2 -0
  205. package/src/components/skeleton/CHANGELOG.md +5 -0
  206. package/src/components/skeleton/Skeleton.astro +121 -0
  207. package/src/components/skeleton/index.ts +1 -0
  208. package/src/components/slider/CHANGELOG.md +5 -0
  209. package/src/components/slider/Slider.astro +198 -0
  210. package/src/components/slider/index.ts +1 -0
  211. package/src/components/spinner/CHANGELOG.md +5 -0
  212. package/src/components/spinner/Spinner.astro +134 -0
  213. package/src/components/spinner/index.ts +1 -0
  214. package/src/components/sticky-surface/CHANGELOG.md +5 -0
  215. package/src/components/sticky-surface/StickySurface.astro +152 -0
  216. package/src/components/sticky-surface/index.ts +2 -0
  217. package/src/components/switch/CHANGELOG.md +9 -0
  218. package/src/components/switch/Switch.astro +106 -0
  219. package/src/components/switch/index.ts +1 -0
  220. package/src/components/table/CHANGELOG.md +5 -0
  221. package/src/components/table/Table.astro +250 -0
  222. package/src/components/table/TableBody.astro +18 -0
  223. package/src/components/table/TableCaption.astro +17 -0
  224. package/src/components/table/TableCell.astro +21 -0
  225. package/src/components/table/TableFooter.astro +21 -0
  226. package/src/components/table/TableHead.astro +21 -0
  227. package/src/components/table/TableHeader.astro +17 -0
  228. package/src/components/table/TableRow.astro +21 -0
  229. package/src/components/table/index.ts +9 -0
  230. package/src/components/tabs/CHANGELOG.md +5 -0
  231. package/src/components/tabs/Tabs.astro +306 -0
  232. package/src/components/tabs/TabsContent.astro +47 -0
  233. package/src/components/tabs/TabsList.astro +69 -0
  234. package/src/components/tabs/TabsTrigger.astro +40 -0
  235. package/src/components/tabs/index.ts +6 -0
  236. package/src/components/textarea/CHANGELOG.md +5 -0
  237. package/src/components/textarea/Textarea.astro +36 -0
  238. package/src/components/textarea/index.ts +2 -0
  239. package/src/components/toggle/CHANGELOG.md +5 -0
  240. package/src/components/toggle/Toggle.astro +138 -0
  241. package/src/components/toggle/index.ts +1 -0
  242. package/src/components/toggle-group/CHANGELOG.md +5 -0
  243. package/src/components/toggle-group/ToggleGroup.astro +224 -0
  244. package/src/components/toggle-group/ToggleGroupItem.astro +48 -0
  245. package/src/components/toggle-group/index.ts +2 -0
  246. package/src/components/tooltip/CHANGELOG.md +5 -0
  247. package/src/components/tooltip/Tooltip.astro +331 -0
  248. package/src/components/tooltip/TooltipContent.astro +60 -0
  249. package/src/components/tooltip/TooltipTrigger.astro +34 -0
  250. package/src/components/tooltip/index.ts +3 -0
  251. package/src/lib/toggle-group-controller.ts +113 -0
  252. package/src/lib/toggle-shared.ts +26 -0
  253. package/src/lib/utils.ts +6 -0
  254. package/src/styles/globals.css +177 -0
@@ -0,0 +1,152 @@
1
+ ---
2
+ /**
3
+ * @component StickySurface
4
+ * @title Sticky Surface
5
+ * @description A sticky surface component with scroll-based effects (border, shadow, surface swap, shrink, glass).
6
+ * @figmaUrl
7
+ *
8
+ * @preview
9
+ *
10
+ * <div class="overflow-y-auto max-h-[320px] w-full bg-border px-8 border-border">
11
+ * <div class="h-[1000px] bg-muted">
12
+ * <StickySurface effects={["line", "elevate"]} threshold="1rem" observeStuck class="bg-background p-4 flex justify-between items-center">
13
+ * <p>Scroll inside!</p>
14
+ * <div class="flex items-center gap-2">
15
+ * <Button size="sm" variant="outline" class="group-[.is-stuck]/surface:opacity-0 will-change-transform group-[.is-stuck]/surface:blur-sm transition-all duration-300 ease-out">Log in</Button>
16
+ * <Button size="sm" class="w-24 group-[.is-stuck]/surface:w-28 duration-500 ease-out">
17
+ * <span class="group-[.is-stuck]/surface:blur-sm group-[.is-stuck]/surface:opacity-0 absolute group-[.is-stuck]/surface:hidden transition-discrete duration-500 ease-out">Contact</span>
18
+ * <span class="group-[.is-stuck]/surface:blur-none group-[.is-stuck]/surface:opacity-100 group-[.is-stuck]/surface:delay-150 opacity-0 transition-all blur-sm duration-500 ease-out">Get a demo</span>
19
+ * </Button>
20
+ * </div>
21
+ * </StickySurface>
22
+ * </div>
23
+ * </div>
24
+ *
25
+ * @usage
26
+ *
27
+ * ```astro nocollapse
28
+ * ---
29
+ * import { StickySurface } from '@bejamas/ui/components/sticky-surface';
30
+ * ---
31
+ *
32
+ * <StickySurface effects={["line", "elevate"]} threshold="1rem">
33
+ * <!-- Your content here -->
34
+ * </StickySurface>
35
+ * ```
36
+ */
37
+
38
+ import type { HTMLTag } from "astro/types";
39
+ import { cva } from "class-variance-authority";
40
+ import { cn } from "@cl-light-ds/ui/lib/utils";
41
+
42
+ interface Props {
43
+ as?: HTMLTag;
44
+ threshold?: string | number;
45
+ effects?: Array<"line" | "elevate" | "backdrop">;
46
+ class?: string;
47
+ style?: string;
48
+ observeStuck?: boolean;
49
+ }
50
+
51
+ const {
52
+ as = "div",
53
+ threshold = "16px",
54
+ effects = [],
55
+ class: className = "",
56
+ style = "",
57
+ ...props
58
+ } = Astro.props as Props;
59
+
60
+ // Compose effect booleans for easier use
61
+ const hasLine = effects.includes("line");
62
+ const hasElevate = effects.includes("elevate");
63
+ const hasBackdrop = effects.includes("backdrop");
64
+
65
+ // CSS variable tokens (can be overridden via Tailwind arbitrary props)
66
+ const defaultVars = {
67
+ '--stuck-shadow': '0 2px 8px 0 rgb(0 0 0 / 0.06)',
68
+ '--stuck-threshold': typeof threshold === "number" ? `${threshold}px` : threshold,
69
+ };
70
+
71
+
72
+ const Tag = as;
73
+
74
+ // cva for sticky surface effects
75
+ const stickySurfaceVariants = cva(
76
+ [
77
+ "group/surface", "sticky", "top-0", "z-50", "w-full", "transition-all", "duration-300", "will-change-transform"
78
+ ],
79
+ {
80
+ variants: {
81
+ line: {
82
+ true: "after:content-[''] after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-black/15 after:opacity-0 supports-[animation-timeline:scroll()]:after:[animation:show-line_linear_both] supports-[animation-timeline:scroll()]:after:[animation-timeline:scroll(nearest_block)] supports-[animation-timeline:scroll()]:after:[animation-range:0_var(--stuck-threshold)]"
83
+ },
84
+ elevate: {
85
+ true: "shadow-none supports-[animation-timeline:scroll()]:[animation:stuck-shadow_linear_both] supports-[animation-timeline:scroll()]:[animation-timeline:scroll(nearest_block)] supports-[animation-timeline:scroll()]:[animation-range:0_var(--stuck-threshold)]"
86
+ },
87
+ backdrop: {
88
+ true: "backdrop-blur supports-[animation-timeline:scroll()]:[animation:stuck-backdrop_linear_both] supports-[animation-timeline:scroll()]:[animation-timeline:scroll(nearest_block)] supports-[animation-timeline:scroll()]:[animation-range:0_var(--stuck-threshold)]"
89
+ }
90
+ }
91
+ }
92
+ );
93
+
94
+ const effectClasses = cn(
95
+ "",
96
+ stickySurfaceVariants({
97
+ line: hasLine,
98
+ elevate: hasElevate,
99
+ backdrop: hasBackdrop
100
+ }),
101
+ className
102
+ );
103
+
104
+ const styleVars = Object.entries(defaultVars)
105
+ ?.map(([k, v]) => `${k}:${v}`)
106
+ ?.join(";");
107
+ ---
108
+
109
+ <Tag
110
+ class={effectClasses}
111
+ style={`${styleVars};${style}`}
112
+ data-sticky-surface
113
+ {...props}
114
+ >
115
+ <slot />
116
+ </Tag>
117
+
118
+ <style>
119
+ @supports (animation-timeline: scroll()) {
120
+ /* Line fade-in */
121
+ @keyframes show-line {
122
+ from { opacity: 0 }
123
+ to { opacity: 1 }
124
+ }
125
+ /* Shadow fade-in */
126
+ @keyframes stuck-shadow {
127
+ from { box-shadow: none }
128
+ to { box-shadow: var(--stuck-shadow) }
129
+ }
130
+ }
131
+ </style>
132
+
133
+
134
+ {Astro.props.observeStuck && (
135
+ <script is:inline>
136
+ (() => {
137
+ const surfaces = document.querySelectorAll('[data-sticky-surface]');
138
+ surfaces.forEach(surface => {
139
+ // Insert a 1px sentinel right before the sticky element
140
+ const sentinel = document.createElement('div');
141
+ sentinel.style.cssText = 'position:relative;height:0;opacity:0;visibility:hidden;';
142
+ surface.parentNode?.insertBefore(sentinel, surface);
143
+
144
+ const io = new IntersectionObserver(([e]) => {
145
+ surface.classList.toggle('is-stuck', !e.isIntersecting);
146
+ }, { threshold: [0, 1] });
147
+
148
+ io.observe(sentinel);
149
+ });
150
+ })();
151
+ </script>
152
+ )}
@@ -0,0 +1,2 @@
1
+ export { default as StickySurface } from "./StickySurface.astro";
2
+
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ All notable changes to the `Switch` component will be documented in this file.
4
+
5
+ ## Unreleased
6
+
7
+ ### Fixed
8
+
9
+ - Restored interactivity: `@data-slot/switch` (already the correct import in `Switch.astro`) was never added as a dependency and was aliased to a no-op stub so builds wouldn't crash, leaving Switch fully static. Added the real package as a dependency and removed the stub alias.
@@ -0,0 +1,106 @@
1
+ ---
2
+ /**
3
+ * @component Switch
4
+ * @title Switch
5
+ * @description A toggle control for switching between checked and unchecked states.
6
+ * @figmaUrl https://www.figma.com/design/koxai7zw5vIuBzuVxe5T2l/bejamas-ui?node-id=2509-4236&t=YFStJ3V8fXEO8QD8-4
7
+ *
8
+ * @status stable
9
+ * @since 0.1.0
10
+ *
11
+ * @preview
12
+ *
13
+ * <div class="flex items-center gap-3">
14
+ * <Switch id="notifications" />
15
+ * <Label for="notifications">Enable notifications</Label>
16
+ * </div>
17
+ *
18
+ * @usage
19
+ *
20
+ * ```astro nocollapse
21
+ * ---
22
+ * import { Switch } from '@bejamas/ui/components/switch';
23
+ * import { Label } from '@bejamas/ui/components/label';
24
+ * ---
25
+ *
26
+ * <div class="flex items-center gap-3">
27
+ * <Switch id="notifications" />
28
+ * <Label for="notifications">Enable notifications</Label>
29
+ * </div>
30
+ * ```
31
+ */
32
+
33
+ import type { HTMLAttributes } from "astro/types";
34
+ import { cn } from "@cl-light-ds/ui/lib/utils";
35
+
36
+ interface Props extends HTMLAttributes<"span"> {
37
+ class?: string;
38
+ id?: string;
39
+ size?: "sm" | "default";
40
+ checked?: boolean;
41
+ defaultChecked?: boolean;
42
+ name?: string;
43
+ value?: string;
44
+ uncheckedValue?: string;
45
+ disabled?: boolean;
46
+ readOnly?: boolean;
47
+ required?: boolean;
48
+ "aria-invalid"?: boolean | "true" | "false";
49
+ }
50
+
51
+ const {
52
+ class: className = "",
53
+ id = "",
54
+ size = "default",
55
+ checked,
56
+ defaultChecked,
57
+ name,
58
+ value,
59
+ uncheckedValue,
60
+ disabled = false,
61
+ readOnly = false,
62
+ required = false,
63
+ "aria-invalid": ariaInvalid,
64
+ ...rest
65
+ } = Astro.props as Props;
66
+
67
+ const initialChecked = checked ?? defaultChecked ?? false;
68
+ ---
69
+
70
+ <span
71
+ {...rest}
72
+ id={id}
73
+ data-slot="switch"
74
+ data-size={size}
75
+ data-default-checked={initialChecked ? "true" : undefined}
76
+ data-name={name}
77
+ data-value={value}
78
+ data-unchecked-value={uncheckedValue}
79
+ data-disabled={disabled ? "true" : undefined}
80
+ data-read-only={readOnly ? "true" : undefined}
81
+ data-required={required ? "true" : undefined}
82
+ data-checked={initialChecked ? "true" : undefined}
83
+ data-unchecked={initialChecked ? undefined : "true"}
84
+ aria-invalid={ariaInvalid}
85
+ class={cn(
86
+ "data-checked:bg-primary data-unchecked:bg-muted focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 dark:data-unchecked:bg-input/80 shrink-0 rounded-full border border-transparent shadow-xs focus-visible:ring-3 aria-invalid:ring-3 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] peer group/switch relative inline-flex items-center transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 data-disabled:cursor-not-allowed data-disabled:opacity-50",
87
+ className,
88
+ )}
89
+ >
90
+ <span
91
+ data-slot="switch-thumb"
92
+ data-checked={initialChecked ? "true" : undefined}
93
+ data-unchecked={initialChecked ? undefined : "true"}
94
+ data-disabled={disabled ? "true" : undefined}
95
+ data-readonly={readOnly ? "true" : undefined}
96
+ data-required={required ? "true" : undefined}
97
+ class="bg-background dark:data-unchecked:bg-foreground dark:data-checked:bg-primary-foreground rounded-full group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 pointer-events-none block ring-0 transition-transform"
98
+ aria-hidden="true"
99
+ ></span>
100
+ </span>
101
+
102
+ <script>
103
+ import { create } from "@data-slot/switch";
104
+
105
+ create();
106
+ </script>
@@ -0,0 +1 @@
1
+ export { default as Switch } from "./Switch.astro";
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ All notable changes to the `Table` component will be documented in this file.
4
+
5
+ ## Unreleased
@@ -0,0 +1,250 @@
1
+ ---
2
+ /**
3
+ * @component Table
4
+ * @title Table
5
+ * @description A responsive table component with compound parts for header, body, footer, and caption.
6
+ *
7
+ * @preview
8
+ *
9
+ * <Table>
10
+ * <TableCaption>A list of your recent invoices.</TableCaption>
11
+ * <TableHeader>
12
+ * <TableRow>
13
+ * <TableHead class="w-[100px]">Invoice</TableHead>
14
+ * <TableHead>Status</TableHead>
15
+ * <TableHead>Method</TableHead>
16
+ * <TableHead class="text-right">Amount</TableHead>
17
+ * </TableRow>
18
+ * </TableHeader>
19
+ * <TableBody>
20
+ * <TableRow>
21
+ * <TableCell class="font-medium">INV001</TableCell>
22
+ * <TableCell>Paid</TableCell>
23
+ * <TableCell>Credit Card</TableCell>
24
+ * <TableCell class="text-right">$250.00</TableCell>
25
+ * </TableRow>
26
+ * <TableRow>
27
+ * <TableCell class="font-medium">INV002</TableCell>
28
+ * <TableCell>Pending</TableCell>
29
+ * <TableCell>PayPal</TableCell>
30
+ * <TableCell class="text-right">$150.00</TableCell>
31
+ * </TableRow>
32
+ * <TableRow>
33
+ * <TableCell class="font-medium">INV003</TableCell>
34
+ * <TableCell>Unpaid</TableCell>
35
+ * <TableCell>Bank Transfer</TableCell>
36
+ * <TableCell class="text-right">$350.00</TableCell>
37
+ * </TableRow>
38
+ * <TableRow>
39
+ * <TableCell class="font-medium">INV004</TableCell>
40
+ * <TableCell>Paid</TableCell>
41
+ * <TableCell>Credit Card</TableCell>
42
+ * <TableCell class="text-right">$450.00</TableCell>
43
+ * </TableRow>
44
+ * <TableRow>
45
+ * <TableCell class="font-medium">INV005</TableCell>
46
+ * <TableCell>Paid</TableCell>
47
+ * <TableCell>PayPal</TableCell>
48
+ * <TableCell class="text-right">$550.00</TableCell>
49
+ * </TableRow>
50
+ * <TableRow>
51
+ * <TableCell class="font-medium">INV006</TableCell>
52
+ * <TableCell>Pending</TableCell>
53
+ * <TableCell>Bank Transfer</TableCell>
54
+ * <TableCell class="text-right">$200.00</TableCell>
55
+ * </TableRow>
56
+ * <TableRow>
57
+ * <TableCell class="font-medium">INV007</TableCell>
58
+ * <TableCell>Unpaid</TableCell>
59
+ * <TableCell>Credit Card</TableCell>
60
+ * <TableCell class="text-right">$300.00</TableCell>
61
+ * </TableRow>
62
+ * </TableBody>
63
+ * <TableFooter>
64
+ * <TableRow>
65
+ * <TableCell colspan={3}>Total</TableCell>
66
+ * <TableCell class="text-right">$2,500.00</TableCell>
67
+ * </TableRow>
68
+ * </TableFooter>
69
+ * </Table>
70
+ *
71
+ * @usage
72
+ *
73
+ * ```astro nocollapse
74
+ * ---
75
+ * import {
76
+ * Table,
77
+ * TableBody,
78
+ * TableCaption,
79
+ * TableCell,
80
+ * TableFooter,
81
+ * TableHead,
82
+ * TableHeader,
83
+ * TableRow,
84
+ * } from '@bejamas/ui/components/table';
85
+ *
86
+ * const invoices = [
87
+ * { invoice: "INV001", paymentStatus: "Paid", totalAmount: "$250.00", paymentMethod: "Credit Card" },
88
+ * { invoice: "INV002", paymentStatus: "Pending", totalAmount: "$150.00", paymentMethod: "PayPal" },
89
+ * { invoice: "INV003", paymentStatus: "Unpaid", totalAmount: "$350.00", paymentMethod: "Bank Transfer" },
90
+ * { invoice: "INV004", paymentStatus: "Paid", totalAmount: "$450.00", paymentMethod: "Credit Card" },
91
+ * { invoice: "INV005", paymentStatus: "Paid", totalAmount: "$550.00", paymentMethod: "PayPal" },
92
+ * { invoice: "INV006", paymentStatus: "Pending", totalAmount: "$200.00", paymentMethod: "Bank Transfer" },
93
+ * { invoice: "INV007", paymentStatus: "Unpaid", totalAmount: "$300.00", paymentMethod: "Credit Card" },
94
+ * ];
95
+ * ---
96
+ *
97
+ * <Table>
98
+ * <TableCaption>A list of your recent invoices.</TableCaption>
99
+ * <TableHeader>
100
+ * <TableRow>
101
+ * <TableHead class="w-[100px]">Invoice</TableHead>
102
+ * <TableHead>Status</TableHead>
103
+ * <TableHead>Method</TableHead>
104
+ * <TableHead class="text-right">Amount</TableHead>
105
+ * </TableRow>
106
+ * </TableHeader>
107
+ * <TableBody>
108
+ * {invoices.map((invoice) => (
109
+ * <TableRow>
110
+ * <TableCell class="font-medium">{invoice.invoice}</TableCell>
111
+ * <TableCell>{invoice.paymentStatus}</TableCell>
112
+ * <TableCell>{invoice.paymentMethod}</TableCell>
113
+ * <TableCell class="text-right">{invoice.totalAmount}</TableCell>
114
+ * </TableRow>
115
+ * ))}
116
+ * </TableBody>
117
+ * <TableFooter>
118
+ * <TableRow>
119
+ * <TableCell colspan={3}>Total</TableCell>
120
+ * <TableCell class="text-right">$2,500.00</TableCell>
121
+ * </TableRow>
122
+ * </TableFooter>
123
+ * </Table>
124
+ * ```
125
+ *
126
+ * @examples
127
+ *
128
+ * ### Footer
129
+ *
130
+ * Use the `<TableFooter />` component to add a footer to the table.
131
+ *
132
+ * <Table>
133
+ * <TableCaption>A list of your recent invoices.</TableCaption>
134
+ * <TableHeader>
135
+ * <TableRow>
136
+ * <TableHead class="w-[100px]">Invoice</TableHead>
137
+ * <TableHead>Status</TableHead>
138
+ * <TableHead>Method</TableHead>
139
+ * <TableHead class="text-right">Amount</TableHead>
140
+ * </TableRow>
141
+ * </TableHeader>
142
+ * <TableBody>
143
+ * <TableRow>
144
+ * <TableCell class="font-medium">INV001</TableCell>
145
+ * <TableCell>Paid</TableCell>
146
+ * <TableCell>Credit Card</TableCell>
147
+ * <TableCell class="text-right">$250.00</TableCell>
148
+ * </TableRow>
149
+ * <TableRow>
150
+ * <TableCell class="font-medium">INV002</TableCell>
151
+ * <TableCell>Pending</TableCell>
152
+ * <TableCell>PayPal</TableCell>
153
+ * <TableCell class="text-right">$150.00</TableCell>
154
+ * </TableRow>
155
+ * <TableRow>
156
+ * <TableCell class="font-medium">INV003</TableCell>
157
+ * <TableCell>Unpaid</TableCell>
158
+ * <TableCell>Bank Transfer</TableCell>
159
+ * <TableCell class="text-right">$350.00</TableCell>
160
+ * </TableRow>
161
+ * </TableBody>
162
+ * <TableFooter>
163
+ * <TableRow>
164
+ * <TableCell colspan={3}>Total</TableCell>
165
+ * <TableCell class="text-right">$2,500.00</TableCell>
166
+ * </TableRow>
167
+ * </TableFooter>
168
+ * </Table>
169
+ *
170
+ * ### Actions
171
+ *
172
+ * A table showing actions for each row using a `<DropdownMenu />` component.
173
+ *
174
+ * <Table>
175
+ * <TableHeader>
176
+ * <TableRow>
177
+ * <TableHead>Product</TableHead>
178
+ * <TableHead>Price</TableHead>
179
+ * <TableHead class="text-right">Actions</TableHead>
180
+ * </TableRow>
181
+ * </TableHeader>
182
+ * <TableBody>
183
+ * <TableRow>
184
+ * <TableCell class="font-medium">Wireless Mouse</TableCell>
185
+ * <TableCell>$29.99</TableCell>
186
+ * <TableCell class="text-right">
187
+ * <DropdownMenu>
188
+ * <DropdownMenuTrigger variant="ghost" size="icon" class="size-8"><EllipsisIcon /><span class="sr-only">Open menu</span></DropdownMenuTrigger>
189
+ * <DropdownMenuContent align="end">
190
+ * <DropdownMenuItem>Edit</DropdownMenuItem>
191
+ * <DropdownMenuItem>Duplicate</DropdownMenuItem>
192
+ * <DropdownMenuSeparator />
193
+ * <DropdownMenuItem class="text-destructive">Delete</DropdownMenuItem>
194
+ * </DropdownMenuContent>
195
+ * </DropdownMenu>
196
+ * </TableCell>
197
+ * </TableRow>
198
+ * <TableRow>
199
+ * <TableCell class="font-medium">Mechanical Keyboard</TableCell>
200
+ * <TableCell>$129.99</TableCell>
201
+ * <TableCell class="text-right">
202
+ * <DropdownMenu>
203
+ * <DropdownMenuTrigger variant="ghost" size="icon" class="size-8"><EllipsisIcon /><span class="sr-only">Open menu</span></DropdownMenuTrigger>
204
+ * <DropdownMenuContent align="end">
205
+ * <DropdownMenuItem>Edit</DropdownMenuItem>
206
+ * <DropdownMenuItem>Duplicate</DropdownMenuItem>
207
+ * <DropdownMenuSeparator />
208
+ * <DropdownMenuItem class="text-destructive">Delete</DropdownMenuItem>
209
+ * </DropdownMenuContent>
210
+ * </DropdownMenu>
211
+ * </TableCell>
212
+ * </TableRow>
213
+ * <TableRow>
214
+ * <TableCell class="font-medium">USB-C Hub</TableCell>
215
+ * <TableCell>$49.99</TableCell>
216
+ * <TableCell class="text-right">
217
+ * <DropdownMenu>
218
+ * <DropdownMenuTrigger variant="ghost" size="icon" class="size-8"><EllipsisIcon /><span class="sr-only">Open menu</span></DropdownMenuTrigger>
219
+ * <DropdownMenuContent align="end">
220
+ * <DropdownMenuItem>Edit</DropdownMenuItem>
221
+ * <DropdownMenuItem>Duplicate</DropdownMenuItem>
222
+ * <DropdownMenuSeparator />
223
+ * <DropdownMenuItem class="text-destructive">Delete</DropdownMenuItem>
224
+ * </DropdownMenuContent>
225
+ * </DropdownMenu>
226
+ * </TableCell>
227
+ * </TableRow>
228
+ * </TableBody>
229
+ * </Table>
230
+ */
231
+
232
+ import { cn } from "@cl-light-ds/ui/lib/utils";
233
+ import type { HTMLAttributes } from "astro/types";
234
+
235
+ interface Props extends HTMLAttributes<"table"> {
236
+ class?: string;
237
+ }
238
+
239
+ const { class: className = "", ...rest } = Astro.props as Props;
240
+ ---
241
+
242
+ <div data-slot="table-container" class="border border-border bg-background rounded-lg relative w-full overflow-x-auto">
243
+ <table
244
+ data-slot="table"
245
+ class={cn("w-full caption-bottom text-sm", "w-full caption-bottom text-sm", className)}
246
+ {...rest}
247
+ >
248
+ <slot />
249
+ </table>
250
+ </div>
@@ -0,0 +1,18 @@
1
+ ---
2
+ import { cn } from "@cl-light-ds/ui/lib/utils";
3
+ import type { HTMLAttributes } from "astro/types";
4
+
5
+ interface Props extends HTMLAttributes<"tbody"> {
6
+ class?: string;
7
+ }
8
+
9
+ const {
10
+ class: className = "",
11
+ ...rest
12
+ } = Astro.props as Props;
13
+ ---
14
+
15
+ <tbody data-slot="table-body" class={cn("[&_tr:last-child]:border-0", "[&_tr:last-child]:border-0", className)} {...rest}>
16
+ <slot />
17
+ </tbody>
18
+
@@ -0,0 +1,17 @@
1
+ ---
2
+ import { cn } from "@cl-light-ds/ui/lib/utils";
3
+ import type { HTMLAttributes } from "astro/types";
4
+
5
+ interface Props extends HTMLAttributes<"caption"> {
6
+ class?: string;
7
+ }
8
+
9
+ const {
10
+ class: className = "",
11
+ ...rest
12
+ } = Astro.props as Props;
13
+ ---
14
+
15
+ <caption data-slot="table-caption" class={cn("text-muted-foreground mt-4 text-sm", className)} {...rest}>
16
+ <slot />
17
+ </caption>
@@ -0,0 +1,21 @@
1
+ ---
2
+ import { cn } from "@cl-light-ds/ui/lib/utils";
3
+ import type { HTMLAttributes } from "astro/types";
4
+
5
+ interface Props extends HTMLAttributes<"td"> {
6
+ class?: string;
7
+ }
8
+
9
+ const {
10
+ class: className = "",
11
+ ...rest
12
+ } = Astro.props as Props;
13
+ ---
14
+
15
+ <td
16
+ data-slot="table-cell"
17
+ class={cn("p-2 align-middle whitespace-nowrap font-medium [&:has([role=checkbox])]:pr-0", className)}
18
+ {...rest}
19
+ >
20
+ <slot />
21
+ </td>
@@ -0,0 +1,21 @@
1
+ ---
2
+ import { cn } from "@cl-light-ds/ui/lib/utils";
3
+ import type { HTMLAttributes } from "astro/types";
4
+
5
+ interface Props extends HTMLAttributes<"tfoot"> {
6
+ class?: string;
7
+ }
8
+
9
+ const {
10
+ class: className = "",
11
+ ...rest
12
+ } = Astro.props as Props;
13
+ ---
14
+
15
+ <tfoot
16
+ data-slot="table-footer"
17
+ class={cn("bg-muted/50 border-t font-medium [&>tr]:last:border-b-0", className)}
18
+ {...rest}
19
+ >
20
+ <slot />
21
+ </tfoot>
@@ -0,0 +1,21 @@
1
+ ---
2
+ import { cn } from "@cl-light-ds/ui/lib/utils";
3
+ import type { HTMLAttributes } from "astro/types";
4
+
5
+ interface Props extends HTMLAttributes<"th"> {
6
+ class?: string;
7
+ }
8
+
9
+ const {
10
+ class: className = "",
11
+ ...rest
12
+ } = Astro.props as Props;
13
+ ---
14
+
15
+ <th
16
+ data-slot="table-head"
17
+ class={cn("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0", className)}
18
+ {...rest}
19
+ >
20
+ <slot />
21
+ </th>
@@ -0,0 +1,17 @@
1
+ ---
2
+ import { cn } from "@cl-light-ds/ui/lib/utils";
3
+ import type { HTMLAttributes } from "astro/types";
4
+
5
+ interface Props extends HTMLAttributes<"thead"> {
6
+ class?: string;
7
+ }
8
+
9
+ const {
10
+ class: className = "",
11
+ ...rest
12
+ } = Astro.props as Props;
13
+ ---
14
+
15
+ <thead data-slot="table-header" class={cn("[&_tr]:border-b", className)} {...rest}>
16
+ <slot />
17
+ </thead>
@@ -0,0 +1,21 @@
1
+ ---
2
+ import { cn } from "@cl-light-ds/ui/lib/utils";
3
+ import type { HTMLAttributes } from "astro/types";
4
+
5
+ interface Props extends HTMLAttributes<"tr"> {
6
+ class?: string;
7
+ }
8
+
9
+ const {
10
+ class: className = "",
11
+ ...rest
12
+ } = Astro.props as Props;
13
+ ---
14
+
15
+ <tr
16
+ data-slot="table-row"
17
+ class={cn("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors", className)}
18
+ {...rest}
19
+ >
20
+ <slot />
21
+ </tr>