@cl-light-ds/ui 0.2.0 → 0.3.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 (283) hide show
  1. package/README.md +45 -45
  2. package/package.json +1 -1
  3. package/src/components/accordion/Accordion.astro +248 -248
  4. package/src/components/accordion/AccordionContent.astro +26 -26
  5. package/src/components/accordion/AccordionItem.astro +36 -36
  6. package/src/components/accordion/AccordionTrigger.astro +118 -118
  7. package/src/components/accordion/CHANGELOG.md +41 -41
  8. package/src/components/accordion/index.ts +4 -4
  9. package/src/components/alert/Alert.astro +167 -167
  10. package/src/components/alert/AlertDescription.astro +24 -24
  11. package/src/components/alert/AlertTitle.astro +24 -24
  12. package/src/components/alert/CHANGELOG.md +5 -5
  13. package/src/components/alert/index.ts +4 -4
  14. package/src/components/avatar/Avatar.astro +197 -197
  15. package/src/components/avatar/AvatarBadge.astro +44 -44
  16. package/src/components/avatar/AvatarFallback.astro +26 -26
  17. package/src/components/avatar/AvatarGroup.astro +26 -26
  18. package/src/components/avatar/AvatarGroupCount.astro +30 -30
  19. package/src/components/avatar/AvatarImage.astro +46 -46
  20. package/src/components/avatar/CHANGELOG.md +44 -44
  21. package/src/components/avatar/index.ts +6 -6
  22. package/src/components/badge/Badge.astro +167 -167
  23. package/src/components/badge/CHANGELOG.md +49 -49
  24. package/src/components/badge/index.ts +2 -2
  25. package/src/components/breadcrumb/Breadcrumb.astro +76 -76
  26. package/src/components/breadcrumb/BreadcrumbItem.astro +32 -32
  27. package/src/components/breadcrumb/BreadcrumbList.astro +26 -26
  28. package/src/components/breadcrumb/BreadcrumbSeparator.astro +26 -26
  29. package/src/components/breadcrumb/CHANGELOG.md +24 -24
  30. package/src/components/breadcrumb/index.ts +5 -5
  31. package/src/components/button/Button.astro +233 -233
  32. package/src/components/button/CHANGELOG.md +41 -41
  33. package/src/components/button/index.ts +2 -2
  34. package/src/components/button-group/ButtonGroup.astro +130 -130
  35. package/src/components/button-group/ButtonGroupSeparator.astro +30 -30
  36. package/src/components/button-group/ButtonGroupText.astro +21 -21
  37. package/src/components/button-group/CHANGELOG.md +34 -34
  38. package/src/components/button-group/index.ts +3 -3
  39. package/src/components/card/CHANGELOG.md +162 -119
  40. package/src/components/card/Card.astro +197 -182
  41. package/src/components/card/CardAction.astro +26 -26
  42. package/src/components/card/CardContent.astro +28 -28
  43. package/src/components/card/CardDescription.astro +28 -28
  44. package/src/components/card/CardFooter.astro +24 -24
  45. package/src/components/card/CardHeader.astro +30 -30
  46. package/src/components/card/CardMedia.astro +27 -27
  47. package/src/components/card/CardMediaActions.astro +21 -0
  48. package/src/components/card/CardMediaSelect.astro +21 -0
  49. package/src/components/card/CardOverlay.astro +32 -32
  50. package/src/components/card/CardTitle.astro +21 -21
  51. package/src/components/card/index.ts +12 -10
  52. package/src/components/carousel/CHANGELOG.md +5 -5
  53. package/src/components/carousel/Carousel.astro +106 -106
  54. package/src/components/carousel/CarouselSlide.astro +22 -22
  55. package/src/components/carousel/index.ts +3 -3
  56. package/src/components/checkbox/CHANGELOG.md +58 -58
  57. package/src/components/checkbox/Checkbox.astro +159 -159
  58. package/src/components/checkbox/index.ts +1 -1
  59. package/src/components/collapsible/CHANGELOG.md +5 -5
  60. package/src/components/collapsible/Collapsible.astro +202 -202
  61. package/src/components/collapsible/CollapsibleContent.astro +36 -36
  62. package/src/components/collapsible/CollapsibleTrigger.astro +34 -34
  63. package/src/components/collapsible/index.ts +4 -4
  64. package/src/components/combobox/CHANGELOG.md +27 -27
  65. package/src/components/combobox/Combobox.astro +365 -365
  66. package/src/components/combobox/ComboboxContent.astro +37 -37
  67. package/src/components/combobox/ComboboxEmpty.astro +18 -18
  68. package/src/components/combobox/ComboboxGroup.astro +19 -19
  69. package/src/components/combobox/ComboboxInput.astro +74 -74
  70. package/src/components/combobox/ComboboxItem.astro +39 -39
  71. package/src/components/combobox/ComboboxLabel.astro +18 -18
  72. package/src/components/combobox/ComboboxList.astro +21 -21
  73. package/src/components/combobox/ComboboxSeparator.astro +17 -17
  74. package/src/components/combobox/ComboboxTrigger.astro +30 -30
  75. package/src/components/combobox/ComboboxValue.astro +22 -22
  76. package/src/components/combobox/index.ts +11 -11
  77. package/src/components/date/CHANGELOG.md +18 -18
  78. package/src/components/date/Date.astro +137 -137
  79. package/src/components/date/index.ts +2 -2
  80. package/src/components/dialog/CHANGELOG.md +39 -39
  81. package/src/components/dialog/Dialog.astro +196 -196
  82. package/src/components/dialog/DialogClose.astro +23 -23
  83. package/src/components/dialog/DialogContent.astro +42 -42
  84. package/src/components/dialog/DialogDescription.astro +18 -18
  85. package/src/components/dialog/DialogFooter.astro +18 -18
  86. package/src/components/dialog/DialogHeader.astro +18 -18
  87. package/src/components/dialog/DialogOverlay.astro +19 -19
  88. package/src/components/dialog/DialogTitle.astro +18 -18
  89. package/src/components/dialog/DialogTrigger.astro +37 -37
  90. package/src/components/dialog/index.ts +9 -9
  91. package/src/components/dropdown-menu/CHANGELOG.md +194 -194
  92. package/src/components/dropdown-menu/DropdownMenu.astro +226 -226
  93. package/src/components/dropdown-menu/DropdownMenuCheckboxItem.astro +114 -114
  94. package/src/components/dropdown-menu/DropdownMenuContent.astro +42 -42
  95. package/src/components/dropdown-menu/DropdownMenuGroup.astro +19 -19
  96. package/src/components/dropdown-menu/DropdownMenuItem.astro +220 -220
  97. package/src/components/dropdown-menu/DropdownMenuItemContent.astro +79 -79
  98. package/src/components/dropdown-menu/DropdownMenuLabel.astro +20 -20
  99. package/src/components/dropdown-menu/DropdownMenuPortal.astro +13 -13
  100. package/src/components/dropdown-menu/DropdownMenuRadioGroup.astro +13 -13
  101. package/src/components/dropdown-menu/DropdownMenuRadioItem.astro +101 -101
  102. package/src/components/dropdown-menu/DropdownMenuSeparator.astro +18 -18
  103. package/src/components/dropdown-menu/DropdownMenuShortcut.astro +18 -18
  104. package/src/components/dropdown-menu/DropdownMenuTrigger.astro +49 -49
  105. package/src/components/dropdown-menu/dropdown-menu-item-variants.ts +24 -24
  106. package/src/components/dropdown-menu/index.ts +12 -12
  107. package/src/components/field/CHANGELOG.md +33 -33
  108. package/src/components/field/Field.astro +664 -664
  109. package/src/components/field/FieldContent.astro +20 -20
  110. package/src/components/field/FieldDescription.astro +22 -22
  111. package/src/components/field/FieldError.astro +51 -51
  112. package/src/components/field/FieldGroup.astro +20 -20
  113. package/src/components/field/FieldLabel.astro +22 -22
  114. package/src/components/field/FieldLegend.astro +23 -23
  115. package/src/components/field/FieldSeparator.astro +30 -30
  116. package/src/components/field/FieldSet.astro +20 -20
  117. package/src/components/field/FieldTitle.astro +20 -20
  118. package/src/components/field/index.ts +10 -10
  119. package/src/components/hover-card/CHANGELOG.md +20 -20
  120. package/src/components/hover-card/HoverCard.astro +235 -235
  121. package/src/components/hover-card/HoverCardContent.astro +54 -54
  122. package/src/components/hover-card/HoverCardTrigger.astro +38 -38
  123. package/src/components/hover-card/index.ts +3 -3
  124. package/src/components/input/CHANGELOG.md +29 -29
  125. package/src/components/input/Input.astro +130 -130
  126. package/src/components/input/index.ts +2 -2
  127. package/src/components/input-group/CHANGELOG.md +49 -49
  128. package/src/components/input-group/InputGroup.astro +135 -135
  129. package/src/components/input-group/InputGroupAddon.astro +49 -49
  130. package/src/components/input-group/InputGroupButton.astro +58 -58
  131. package/src/components/input-group/InputGroupInput.astro +18 -18
  132. package/src/components/input-group/InputGroupText.astro +21 -21
  133. package/src/components/input-group/InputGroupTextarea.astro +17 -17
  134. package/src/components/input-group/controlClasses.ts +2 -2
  135. package/src/components/input-group/index.ts +6 -6
  136. package/src/components/item/CHANGELOG.md +27 -27
  137. package/src/components/item/Item.astro +122 -122
  138. package/src/components/item/ItemActions.astro +21 -21
  139. package/src/components/item/ItemContent.astro +25 -25
  140. package/src/components/item/ItemDescription.astro +25 -25
  141. package/src/components/item/ItemFooter.astro +24 -24
  142. package/src/components/item/ItemGroup.astro +24 -24
  143. package/src/components/item/ItemHeader.astro +24 -24
  144. package/src/components/item/ItemMedia.astro +47 -47
  145. package/src/components/item/ItemSeparator.astro +21 -21
  146. package/src/components/item/ItemTitle.astro +25 -25
  147. package/src/components/item/index.ts +10 -10
  148. package/src/components/kbd/CHANGELOG.md +5 -5
  149. package/src/components/kbd/Kbd.astro +145 -145
  150. package/src/components/kbd/KbdGroup.astro +55 -55
  151. package/src/components/kbd/index.ts +2 -2
  152. package/src/components/label/CHANGELOG.md +28 -28
  153. package/src/components/label/Label.astro +97 -97
  154. package/src/components/label/index.ts +2 -2
  155. package/src/components/link-group/CHANGELOG.md +75 -75
  156. package/src/components/link-group/LinkGroup.astro +67 -67
  157. package/src/components/link-group/LinkGroupItem.astro +32 -32
  158. package/src/components/link-group/LinkGroupList.astro +25 -25
  159. package/src/components/link-group/LinkGroupTitle.astro +22 -22
  160. package/src/components/link-group/index.ts +5 -5
  161. package/src/components/link-group/link-group-list-variants.ts +15 -15
  162. package/src/components/marquee/CHANGELOG.md +5 -5
  163. package/src/components/marquee/Marquee.astro +119 -119
  164. package/src/components/marquee/index.ts +2 -2
  165. package/src/components/native-select/CHANGELOG.md +5 -5
  166. package/src/components/native-select/NativeSelect.astro +125 -125
  167. package/src/components/native-select/NativeSelectOptGroup.astro +14 -14
  168. package/src/components/native-select/NativeSelectOption.astro +9 -9
  169. package/src/components/native-select/index.ts +3 -3
  170. package/src/components/navigation-menu/CHANGELOG.md +63 -63
  171. package/src/components/navigation-menu/NavigationMenu.astro +414 -414
  172. package/src/components/navigation-menu/NavigationMenuContent.astro +37 -37
  173. package/src/components/navigation-menu/NavigationMenuIndicator.astro +24 -24
  174. package/src/components/navigation-menu/NavigationMenuItem.astro +22 -22
  175. package/src/components/navigation-menu/NavigationMenuLink.astro +18 -18
  176. package/src/components/navigation-menu/NavigationMenuList.astro +21 -21
  177. package/src/components/navigation-menu/NavigationMenuPositioner.astro +44 -44
  178. package/src/components/navigation-menu/NavigationMenuTrigger.astro +30 -30
  179. package/src/components/navigation-menu/NavigationMenuViewport.astro +19 -19
  180. package/src/components/navigation-menu/index.ts +10 -10
  181. package/src/components/organisms/lightning-sidebar-nav/CHANGELOG.md +50 -0
  182. package/src/components/organisms/lightning-sidebar-nav/LightningSidebarNav.astro +176 -0
  183. package/src/components/organisms/lightning-sidebar-nav/SidebarNav.astro +50 -0
  184. package/src/components/organisms/lightning-sidebar-nav/SidebarNavGroup.astro +74 -0
  185. package/src/components/organisms/lightning-sidebar-nav/SidebarNavItem.astro +94 -0
  186. package/src/components/organisms/lightning-sidebar-nav/SidebarNavProBadge.astro +26 -0
  187. package/src/components/organisms/lightning-sidebar-nav/SidebarNavSection.astro +71 -0
  188. package/src/components/organisms/lightning-sidebar-nav/SidebarNavSkeleton.astro +67 -0
  189. package/src/components/organisms/lightning-sidebar-nav/SidebarNavSubItem.astro +69 -0
  190. package/src/components/organisms/lightning-sidebar-nav/SidebarNavUsage.astro +78 -0
  191. package/src/components/organisms/lightning-sidebar-nav/SidebarNavWorkspaceAvatar.astro +46 -0
  192. package/src/components/organisms/lightning-sidebar-nav/SidebarNavWorkspaceSwitcher.astro +130 -0
  193. package/src/components/organisms/lightning-sidebar-nav/icons.ts +46 -0
  194. package/src/components/organisms/lightning-sidebar-nav/index.ts +18 -0
  195. package/src/components/organisms/lightning-sidebar-nav/types.ts +77 -0
  196. package/src/components/popover/CHANGELOG.md +20 -20
  197. package/src/components/popover/Popover.astro +211 -211
  198. package/src/components/popover/PopoverClose.astro +18 -18
  199. package/src/components/popover/PopoverContent.astro +50 -50
  200. package/src/components/popover/PopoverDescription.astro +18 -18
  201. package/src/components/popover/PopoverHeader.astro +18 -18
  202. package/src/components/popover/PopoverTitle.astro +18 -18
  203. package/src/components/popover/PopoverTrigger.astro +35 -35
  204. package/src/components/popover/index.ts +7 -7
  205. package/src/components/radio-group/CHANGELOG.md +31 -31
  206. package/src/components/radio-group/RadioGroup.astro +81 -81
  207. package/src/components/radio-group/RadioGroupItem.astro +51 -51
  208. package/src/components/radio-group/index.ts +3 -3
  209. package/src/components/select/CHANGELOG.md +39 -39
  210. package/src/components/select/Select.astro +373 -373
  211. package/src/components/select/SelectContent.astro +91 -91
  212. package/src/components/select/SelectGroup.astro +19 -19
  213. package/src/components/select/SelectItem.astro +48 -48
  214. package/src/components/select/SelectLabel.astro +18 -18
  215. package/src/components/select/SelectSeparator.astro +17 -17
  216. package/src/components/select/SelectTrigger.astro +34 -34
  217. package/src/components/select/SelectValue.astro +22 -22
  218. package/src/components/select/index.ts +8 -8
  219. package/src/components/separator/CHANGELOG.md +5 -5
  220. package/src/components/separator/Separator.astro +60 -60
  221. package/src/components/separator/index.ts +2 -2
  222. package/src/components/skeleton/CHANGELOG.md +5 -5
  223. package/src/components/skeleton/Skeleton.astro +121 -121
  224. package/src/components/skeleton/index.ts +1 -1
  225. package/src/components/slider/CHANGELOG.md +5 -5
  226. package/src/components/slider/Slider.astro +198 -198
  227. package/src/components/slider/index.ts +1 -1
  228. package/src/components/spinner/CHANGELOG.md +18 -18
  229. package/src/components/spinner/Spinner.astro +135 -135
  230. package/src/components/spinner/index.ts +1 -1
  231. package/src/components/sticky-surface/CHANGELOG.md +5 -5
  232. package/src/components/sticky-surface/StickySurface.astro +152 -152
  233. package/src/components/sticky-surface/index.ts +2 -2
  234. package/src/components/switch/CHANGELOG.md +29 -29
  235. package/src/components/switch/Switch.astro +106 -106
  236. package/src/components/switch/index.ts +1 -1
  237. package/src/components/table/CHANGELOG.md +24 -24
  238. package/src/components/table/Table.astro +358 -251
  239. package/src/components/table/TableBody.astro +17 -18
  240. package/src/components/table/TableBulkToolbar.astro +37 -0
  241. package/src/components/table/TableCaption.astro +17 -17
  242. package/src/components/table/TableCell.astro +45 -21
  243. package/src/components/table/TableCellText.astro +17 -0
  244. package/src/components/table/TableColumnMenu.astro +50 -0
  245. package/src/components/table/TableEditableCell.astro +287 -0
  246. package/src/components/table/TableEmpty.astro +17 -0
  247. package/src/components/table/TableFolderCell.astro +38 -0
  248. package/src/components/table/TableFooter.astro +21 -21
  249. package/src/components/table/TableHead.astro +90 -21
  250. package/src/components/table/TableHeader.astro +17 -17
  251. package/src/components/table/TablePagination.astro +57 -0
  252. package/src/components/table/TableRow.astro +52 -21
  253. package/src/components/table/TableSelectAllBanner.astro +34 -0
  254. package/src/components/table/TableSelectCell.astro +50 -0
  255. package/src/components/table/TableSkeletonRow.astro +21 -0
  256. package/src/components/table/index.ts +19 -9
  257. package/src/components/table/table-cell-variants.ts +29 -0
  258. package/src/components/tabs/CHANGELOG.md +5 -5
  259. package/src/components/tabs/Tabs.astro +306 -306
  260. package/src/components/tabs/TabsContent.astro +47 -47
  261. package/src/components/tabs/TabsList.astro +69 -69
  262. package/src/components/tabs/TabsTrigger.astro +40 -40
  263. package/src/components/tabs/index.ts +6 -6
  264. package/src/components/textarea/CHANGELOG.md +22 -22
  265. package/src/components/textarea/Textarea.astro +58 -58
  266. package/src/components/textarea/index.ts +2 -2
  267. package/src/components/toggle/CHANGELOG.md +23 -23
  268. package/src/components/toggle/Toggle.astro +150 -150
  269. package/src/components/toggle/index.ts +1 -1
  270. package/src/components/toggle-group/CHANGELOG.md +18 -18
  271. package/src/components/toggle-group/ToggleGroup.astro +236 -236
  272. package/src/components/toggle-group/ToggleGroupItem.astro +48 -48
  273. package/src/components/toggle-group/index.ts +2 -2
  274. package/src/components/tooltip/CHANGELOG.md +22 -22
  275. package/src/components/tooltip/Tooltip.astro +357 -357
  276. package/src/components/tooltip/TooltipContent.astro +85 -85
  277. package/src/components/tooltip/TooltipTrigger.astro +34 -34
  278. package/src/components/tooltip/index.ts +3 -3
  279. package/src/lib/table-controller.ts +1090 -0
  280. package/src/lib/toggle-group-controller.ts +113 -113
  281. package/src/lib/toggle-shared.ts +27 -27
  282. package/src/lib/utils.ts +6 -6
  283. package/src/styles/globals.css +197 -177
@@ -1,664 +1,664 @@
1
- ---
2
- /**
3
- * @component Field
4
- * @title Field
5
- * @description Composable form layout primitives for labels, descriptions, grouped controls, separators, and validation messages.
6
- *
7
- * @preview
8
- *
9
- * <div class="w-full max-w-md">
10
- * <form>
11
- * <FieldGroup>
12
- * <FieldSet>
13
- * <FieldLegend>Payment Method</FieldLegend>
14
- * <FieldDescription>
15
- * All transactions are secure and encrypted
16
- * </FieldDescription>
17
- * <FieldGroup>
18
- * <Field>
19
- * <FieldLabel for="checkout-7j9-card-name-43j">Name on Card</FieldLabel>
20
- * <Input id="checkout-7j9-card-name-43j" placeholder="Evil Rabbit" required />
21
- * </Field>
22
- * <Field>
23
- * <FieldLabel for="checkout-7j9-card-number-uw1">Card Number</FieldLabel>
24
- * <Input id="checkout-7j9-card-number-uw1" placeholder="1234 5678 9012 3456" required />
25
- * <FieldDescription>Enter your 16-digit card number</FieldDescription>
26
- * </Field>
27
- * <div class="grid grid-cols-3 gap-4">
28
- * <Field>
29
- * <FieldLabel for="checkout-exp-month-ts6">Month</FieldLabel>
30
- * <Select>
31
- * <SelectTrigger id="checkout-exp-month-ts6">
32
- * <SelectValue placeholder="MM" />
33
- * </SelectTrigger>
34
- * <SelectContent>
35
- * <SelectGroup>
36
- * <SelectItem value="01">01</SelectItem>
37
- * <SelectItem value="02">02</SelectItem>
38
- * <SelectItem value="03">03</SelectItem>
39
- * <SelectItem value="04">04</SelectItem>
40
- * <SelectItem value="05">05</SelectItem>
41
- * <SelectItem value="06">06</SelectItem>
42
- * <SelectItem value="07">07</SelectItem>
43
- * <SelectItem value="08">08</SelectItem>
44
- * <SelectItem value="09">09</SelectItem>
45
- * <SelectItem value="10">10</SelectItem>
46
- * <SelectItem value="11">11</SelectItem>
47
- * <SelectItem value="12">12</SelectItem>
48
- * </SelectGroup>
49
- * </SelectContent>
50
- * </Select>
51
- * </Field>
52
- * <Field>
53
- * <FieldLabel for="checkout-7j9-exp-year-f59">Year</FieldLabel>
54
- * <Select>
55
- * <SelectTrigger id="checkout-7j9-exp-year-f59">
56
- * <SelectValue placeholder="YYYY" />
57
- * </SelectTrigger>
58
- * <SelectContent>
59
- * <SelectGroup>
60
- * <SelectItem value="2024">2024</SelectItem>
61
- * <SelectItem value="2025">2025</SelectItem>
62
- * <SelectItem value="2026">2026</SelectItem>
63
- * <SelectItem value="2027">2027</SelectItem>
64
- * <SelectItem value="2028">2028</SelectItem>
65
- * <SelectItem value="2029">2029</SelectItem>
66
- * </SelectGroup>
67
- * </SelectContent>
68
- * </Select>
69
- * </Field>
70
- * <Field>
71
- * <FieldLabel for="checkout-7j9-cvv">CVV</FieldLabel>
72
- * <Input id="checkout-7j9-cvv" placeholder="123" required />
73
- * </Field>
74
- * </div>
75
- * </FieldGroup>
76
- * </FieldSet>
77
- *
78
- * <FieldSeparator />
79
- *
80
- * <FieldSet>
81
- * <FieldLegend>Billing Address</FieldLegend>
82
- * <FieldDescription>
83
- * The billing address associated with your payment method
84
- * </FieldDescription>
85
- * <FieldGroup>
86
- * <Field orientation="horizontal">
87
- * <Checkbox id="checkout-7j9-same-as-shipping-wgm" checked />
88
- * <FieldLabel for="checkout-7j9-same-as-shipping-wgm" class="font-normal">
89
- * Same as shipping address
90
- * </FieldLabel>
91
- * </Field>
92
- * </FieldGroup>
93
- * </FieldSet>
94
- *
95
- * <FieldSet>
96
- * <FieldGroup>
97
- * <Field>
98
- * <FieldLabel for="checkout-7j9-optional-comments">Comments</FieldLabel>
99
- * <Textarea
100
- * id="checkout-7j9-optional-comments"
101
- * placeholder="Add any additional comments"
102
- * class="resize-none"
103
- * />
104
- * </Field>
105
- * </FieldGroup>
106
- * </FieldSet>
107
- *
108
- * <Field orientation="horizontal">
109
- * <Button type="submit">Submit</Button>
110
- * <Button variant="outline" type="button">Cancel</Button>
111
- * </Field>
112
- * </FieldGroup>
113
- * </form>
114
- * </div>
115
- *
116
- * @usage
117
- *
118
- * ```astro nocollapse
119
- * ---
120
- * import {
121
- * Field,
122
- * FieldContent,
123
- * FieldDescription,
124
- * FieldError,
125
- * FieldGroup,
126
- * FieldLabel,
127
- * FieldLegend,
128
- * FieldSeparator,
129
- * FieldSet,
130
- * FieldTitle,
131
- * } from '@bejamas/ui/components/field';
132
- * ---
133
- *
134
- * <FieldGroup>
135
- * <FieldSet>
136
- * <FieldLegend>Account</FieldLegend>
137
- * <Field>
138
- * <FieldLabel for="email">Email</FieldLabel>
139
- * <Input id="email" type="email" />
140
- * <FieldError errors={[{ message: 'Email is required' }]} />
141
- * </Field>
142
- * </FieldSet>
143
- * </FieldGroup>
144
- * ```
145
- *
146
- * @api
147
- *
148
- * ### FieldSet
149
- *
150
- * Container that renders a semantic `fieldset` with spacing presets.
151
- *
152
- * | Prop | Type | Default |
153
- * |------|------|---------|
154
- * | `class` | `string` | - |
155
- *
156
- * ```astro nocollapse
157
- * <FieldSet>
158
- * <FieldLegend>Delivery</FieldLegend>
159
- * <FieldGroup>
160
- * <Field>
161
- * <FieldLabel for="address">Address</FieldLabel>
162
- * <Input id="address" />
163
- * </Field>
164
- * </FieldGroup>
165
- * </FieldSet>
166
- * ```
167
- *
168
- * ### FieldLegend
169
- *
170
- * Legend element for a `FieldSet`. Use the `label` variant to align with label sizing.
171
- *
172
- * | Prop | Type | Default |
173
- * |------|------|---------|
174
- * | `variant` | `"legend" \| "label"` | `"legend"` |
175
- * | `class` | `string` | - |
176
- *
177
- * ```astro nocollapse
178
- * <FieldLegend variant="label">Notification Preferences</FieldLegend>
179
- * ```
180
- *
181
- * ### FieldGroup
182
- *
183
- * Layout wrapper that stacks `Field` components and enables container-query
184
- * responsive orientations.
185
- *
186
- * | Prop | Type | Default |
187
- * |------|------|---------|
188
- * | `class` | `string` | - |
189
- *
190
- * ```astro nocollapse
191
- * <FieldGroup class="@container/field-group flex flex-col gap-6">
192
- * <Field>...</Field>
193
- * <Field>...</Field>
194
- * </FieldGroup>
195
- * ```
196
- *
197
- * ### Field
198
- *
199
- * Core wrapper for a single field. Provides orientation control, invalid-state
200
- * styling, and spacing.
201
- *
202
- * | Prop | Type | Default |
203
- * |------|------|---------|
204
- * | `orientation` | `"vertical" \| "horizontal" \| "responsive"` | `"vertical"` |
205
- * | `class` | `string` | - |
206
- * | `data-invalid` | `"true" \| "false"` | - |
207
- *
208
- * ```astro nocollapse
209
- * <Field orientation="horizontal">
210
- * <FieldLabel for="remember">Remember me</FieldLabel>
211
- * <Switch id="remember" />
212
- * </Field>
213
- * ```
214
- *
215
- * ### FieldContent
216
- *
217
- * Flex column for grouping control and descriptions when label/content are split.
218
- *
219
- * | Prop | Type | Default |
220
- * |------|------|---------|
221
- * | `class` | `string` | - |
222
- *
223
- * ```astro nocollapse
224
- * <Field orientation="horizontal">
225
- * <Checkbox id="notifications" />
226
- * <FieldContent>
227
- * <FieldLabel for="notifications">Notifications</FieldLabel>
228
- * <FieldDescription>Email, SMS, and push options.</FieldDescription>
229
- * </FieldContent>
230
- * </Field>
231
- * ```
232
- *
233
- * ### FieldLabel
234
- *
235
- * Label styled for both direct controls and nested `Field` children.
236
- *
237
- * | Prop | Type | Default |
238
- * |------|------|---------|
239
- * | `class` | `string` | - |
240
- * | `for` | `string` | - |
241
- *
242
- * ```astro nocollapse
243
- * <FieldLabel for="email">Email</FieldLabel>
244
- * ```
245
- *
246
- * ### FieldTitle
247
- *
248
- * Title text styled for use inside `FieldContent`.
249
- *
250
- * | Prop | Type | Default |
251
- * |------|------|---------|
252
- * | `class` | `string` | - |
253
- *
254
- * ```astro nocollapse
255
- * <FieldContent>
256
- * <FieldTitle>Enable Touch ID</FieldTitle>
257
- * <FieldDescription>Unlock your device faster.</FieldDescription>
258
- * </FieldContent>
259
- * ```
260
- *
261
- * ### FieldDescription
262
- *
263
- * Helper text slot that supports links and balanced wrapping in horizontal layouts.
264
- *
265
- * | Prop | Type | Default |
266
- * |------|------|---------|
267
- * | `class` | `string` | - |
268
- *
269
- * ```astro nocollapse
270
- * <FieldDescription>We never share your email with anyone.</FieldDescription>
271
- * ```
272
- *
273
- * ### FieldSeparator
274
- *
275
- * Visual divider for sections inside a `FieldGroup`. Supports optional inline
276
- * content through its default slot.
277
- *
278
- * | Prop | Type | Default |
279
- * |------|------|---------|
280
- * | `class` | `string` | - |
281
- *
282
- * ```astro nocollapse
283
- * <FieldSeparator>Or continue with</FieldSeparator>
284
- * ```
285
- *
286
- * ### FieldError
287
- *
288
- * Accessible error container. Renders slot content if provided; otherwise it
289
- * derives output from the `errors` array.
290
- *
291
- * | Prop | Type | Default |
292
- * |------|------|---------|
293
- * | `errors` | `Array<{ message?: string } \| undefined>` | `[]` |
294
- * | `forceMount` | `boolean` | `false` |
295
- * | `class` | `string` | - |
296
- *
297
- * ```astro nocollapse
298
- * <FieldError errors={[{ message: "Username is required" }]} />
299
- * ```
300
- *
301
- * When `errors` contains multiple unique messages, the component renders a list
302
- * automatically.
303
- *
304
- * For client-side script flows in Astro, mount once and toggle visibility:
305
- *
306
- * ```astro nocollapse
307
- * <FieldError forceMount class="hidden" data-error-for="email" />
308
- * ```
309
- *
310
- * @examples
311
- *
312
- * ### Input
313
- *
314
- * <FieldSet class="w-full max-w-xs">
315
- * <FieldGroup>
316
- * <Field>
317
- * <FieldLabel for="username">Username</FieldLabel>
318
- * <Input id="username" type="text" placeholder="Max Leiter" />
319
- * <FieldDescription>
320
- * Choose a unique username for your account.
321
- * </FieldDescription>
322
- * </Field>
323
- * <Field>
324
- * <FieldLabel for="password">Password</FieldLabel>
325
- * <FieldDescription>
326
- * Must be at least 8 characters long.
327
- * </FieldDescription>
328
- * <Input id="password" type="password" placeholder="••••••••" />
329
- * </Field>
330
- * </FieldGroup>
331
- * </FieldSet>
332
- *
333
- * ### Textarea
334
- *
335
- * <FieldSet class="w-full max-w-xs">
336
- * <FieldGroup>
337
- * <Field>
338
- * <FieldLabel for="feedback">Feedback</FieldLabel>
339
- * <Textarea
340
- * id="feedback"
341
- * placeholder="Your feedback helps us improve..."
342
- * rows={4}
343
- * />
344
- * <FieldDescription>
345
- * Share your thoughts about our service.
346
- * </FieldDescription>
347
- * </Field>
348
- * </FieldGroup>
349
- * </FieldSet>
350
- *
351
- * ### Select
352
- *
353
- * <Field class="w-full max-w-xs">
354
- * <FieldLabel for="department">Department</FieldLabel>
355
- * <Select>
356
- * <SelectTrigger id="department">
357
- * <SelectValue placeholder="Choose department" />
358
- * </SelectTrigger>
359
- * <SelectContent>
360
- * <SelectGroup>
361
- * <SelectItem value="engineering">Engineering</SelectItem>
362
- * <SelectItem value="design">Design</SelectItem>
363
- * <SelectItem value="marketing">Marketing</SelectItem>
364
- * <SelectItem value="sales">Sales</SelectItem>
365
- * <SelectItem value="support">Customer Support</SelectItem>
366
- * <SelectItem value="hr">Human Resources</SelectItem>
367
- * <SelectItem value="finance">Finance</SelectItem>
368
- * <SelectItem value="operations">Operations</SelectItem>
369
- * </SelectGroup>
370
- * </SelectContent>
371
- * </Select>
372
- * <FieldDescription>
373
- * Select your department or area of work.
374
- * </FieldDescription>
375
- * </Field>
376
- *
377
- * ### Slider
378
- *
379
- * <Field class="w-full max-w-xs">
380
- * <FieldTitle>Price Range</FieldTitle>
381
- * <FieldDescription>
382
- * Set your budget range between $200 and $800.
383
- * </FieldDescription>
384
- * <Slider
385
- * defaultValue={[200, 800]}
386
- * max={1000}
387
- * min={0}
388
- * step={10}
389
- * class="mt-2 w-full"
390
- * aria-label="Price Range"
391
- * />
392
- * </Field>
393
- *
394
- * ### Fieldset
395
- *
396
- * <FieldSet class="w-full max-w-sm">
397
- * <FieldLegend>Address Information</FieldLegend>
398
- * <FieldDescription>
399
- * We need your address to deliver your order.
400
- * </FieldDescription>
401
- * <FieldGroup>
402
- * <Field>
403
- * <FieldLabel for="street">Street Address</FieldLabel>
404
- * <Input id="street" type="text" placeholder="123 Main St" />
405
- * </Field>
406
- * <div class="grid grid-cols-2 gap-4">
407
- * <Field>
408
- * <FieldLabel for="city">City</FieldLabel>
409
- * <Input id="city" type="text" placeholder="New York" />
410
- * </Field>
411
- * <Field>
412
- * <FieldLabel for="zip">Postal Code</FieldLabel>
413
- * <Input id="zip" type="text" placeholder="90502" />
414
- * </Field>
415
- * </div>
416
- * </FieldGroup>
417
- * </FieldSet>
418
- *
419
- * ### Checkbox
420
- *
421
- * <FieldGroup class="w-full max-w-xs">
422
- * <FieldSet>
423
- * <FieldLegend variant="label">
424
- * Show these items on the desktop
425
- * </FieldLegend>
426
- * <FieldDescription>
427
- * Select the items you want to show on the desktop.
428
- * </FieldDescription>
429
- * <FieldGroup class="gap-3">
430
- * <Field orientation="horizontal">
431
- * <Checkbox id="finder-pref-9k2-hard-disks-ljj" checked />
432
- * <FieldLabel
433
- * for="finder-pref-9k2-hard-disks-ljj"
434
- * class="font-normal"
435
- * >
436
- * Hard disks
437
- * </FieldLabel>
438
- * </Field>
439
- * <Field orientation="horizontal">
440
- * <Checkbox id="finder-pref-9k2-external-disks-1yg" />
441
- * <FieldLabel
442
- * for="finder-pref-9k2-external-disks-1yg"
443
- * class="font-normal"
444
- * >
445
- * External disks
446
- * </FieldLabel>
447
- * </Field>
448
- * <Field orientation="horizontal">
449
- * <Checkbox id="finder-pref-9k2-cds-dvds-fzt" />
450
- * <FieldLabel
451
- * for="finder-pref-9k2-cds-dvds-fzt"
452
- * class="font-normal"
453
- * >
454
- * CDs, DVDs, and iPods
455
- * </FieldLabel>
456
- * </Field>
457
- * <Field orientation="horizontal">
458
- * <Checkbox id="finder-pref-9k2-connected-servers-6l2" />
459
- * <FieldLabel
460
- * for="finder-pref-9k2-connected-servers-6l2"
461
- * class="font-normal"
462
- * >
463
- * Connected servers
464
- * </FieldLabel>
465
- * </Field>
466
- * </FieldGroup>
467
- * </FieldSet>
468
- * <FieldSeparator />
469
- * <Field orientation="horizontal">
470
- * <Checkbox id="finder-pref-9k2-sync-folders-nep" checked />
471
- * <FieldContent>
472
- * <FieldLabel for="finder-pref-9k2-sync-folders-nep">
473
- * Sync Desktop & Documents folders
474
- * </FieldLabel>
475
- * <FieldDescription>
476
- * Your Desktop & Documents folders are being synced with iCloud Drive.
477
- * You can access them from other devices.
478
- * </FieldDescription>
479
- * </FieldContent>
480
- * </Field>
481
- * </FieldGroup>
482
- *
483
- * ### Radio
484
- *
485
- * <FieldSet class="w-full max-w-xs">
486
- * <FieldLegend variant="label">Subscription Plan</FieldLegend>
487
- * <FieldDescription>
488
- * Yearly and lifetime plans offer significant savings.
489
- * </FieldDescription>
490
- * <RadioGroup name="subscription-plan" defaultValue="monthly">
491
- * <Field orientation="horizontal">
492
- * <RadioGroupItem
493
- * value="monthly"
494
- * id="plan-monthly"
495
- * />
496
- * <FieldLabel for="plan-monthly" class="font-normal">
497
- * Monthly ($9.99/month)
498
- * </FieldLabel>
499
- * </Field>
500
- * <Field orientation="horizontal">
501
- * <RadioGroupItem
502
- * name="subscription-plan"
503
- * value="yearly"
504
- * id="plan-yearly"
505
- * />
506
- * <FieldLabel for="plan-yearly" class="font-normal">
507
- * Yearly ($99.99/year)
508
- * </FieldLabel>
509
- * </Field>
510
- * <Field orientation="horizontal">
511
- * <RadioGroupItem
512
- * name="subscription-plan"
513
- * value="lifetime"
514
- * id="plan-lifetime"
515
- * />
516
- * <FieldLabel for="plan-lifetime" class="font-normal">
517
- * Lifetime ($299.99)
518
- * </FieldLabel>
519
- * </Field>
520
- * </RadioGroup>
521
- * </FieldSet>
522
- *
523
- * ### Switch
524
- *
525
- * <Field orientation="horizontal" class="w-fit">
526
- * <FieldLabel for="2fa">Multi-factor authentication</FieldLabel>
527
- * <Switch id="2fa" />
528
- * </Field>
529
- *
530
- * ### Choice Card
531
- *
532
- * Wrap `Field` components inside `FieldLabel` to create selectable field groups.
533
- * This works with `RadioGroupItem`, `Checkbox`, and `Switch` components.
534
- *
535
- * <FieldGroup class="w-full max-w-xs">
536
- * <FieldSet>
537
- * <FieldLegend variant="label">Compute Environment</FieldLegend>
538
- * <FieldDescription>
539
- * Select the compute environment for your cluster.
540
- * </FieldDescription>
541
- * <RadioGroup
542
- * name="compute-environment"
543
- * defaultValue="kubernetes"
544
- * >
545
- * <FieldLabel for="kubernetes-r2h">
546
- * <Field orientation="horizontal">
547
- * <FieldContent>
548
- * <FieldTitle>Kubernetes</FieldTitle>
549
- * <FieldDescription>
550
- * Run GPU workloads on a K8s cluster.
551
- * </FieldDescription>
552
- * </FieldContent>
553
- * <RadioGroupItem
554
- * value="kubernetes"
555
- * id="kubernetes-r2h"
556
- * />
557
- * </Field>
558
- * </FieldLabel>
559
- * <FieldLabel for="vm-z4k">
560
- * <Field orientation="horizontal">
561
- * <FieldContent>
562
- * <FieldTitle>Virtual Machine</FieldTitle>
563
- * <FieldDescription>
564
- * Access a cluster to run GPU workloads.
565
- * </FieldDescription>
566
- * </FieldContent>
567
- * <RadioGroupItem
568
- * value="vm"
569
- * id="vm-z4k"
570
- * />
571
- * </Field>
572
- * </FieldLabel>
573
- * </RadioGroup>
574
- * </FieldSet>
575
- * </FieldGroup>
576
- *
577
- * ### Field Group
578
- *
579
- * Stack `Field` components with `FieldGroup`. Add `FieldSeparator` to divide
580
- * them.
581
- *
582
- * <FieldGroup class="w-full max-w-xs">
583
- * <FieldSet>
584
- * <FieldLabel>Responses</FieldLabel>
585
- * <FieldDescription>
586
- * Get notified when ChatGPT responds to requests that take time, like
587
- * research or image generation.
588
- * </FieldDescription>
589
- * <FieldGroup data-slot="checkbox-group" class="">
590
- * <Field orientation="horizontal">
591
- * <Checkbox id="push" checked disabled />
592
- * <FieldLabel for="push" class="font-normal">
593
- * Push notifications
594
- * </FieldLabel>
595
- * </Field>
596
- * </FieldGroup>
597
- * </FieldSet>
598
- * <FieldSeparator />
599
- * <FieldSet>
600
- * <FieldLabel>Tasks</FieldLabel>
601
- * <FieldDescription>
602
- * Get notified when tasks you've created have updates.
603
- * <a href="#">Manage tasks</a>
604
- * </FieldDescription>
605
- * <FieldGroup data-slot="checkbox-group" class="">
606
- * <Field orientation="horizontal">
607
- * <Checkbox id="push-tasks" />
608
- * <FieldLabel for="push-tasks" class="font-normal">
609
- * Push notifications
610
- * </FieldLabel>
611
- * </Field>
612
- * <Field orientation="horizontal">
613
- * <Checkbox id="email-tasks" />
614
- * <FieldLabel for="email-tasks" class="font-normal">
615
- * Email notifications
616
- * </FieldLabel>
617
- * </Field>
618
- * </FieldGroup>
619
- * </FieldSet>
620
- * </FieldGroup>
621
- */
622
-
623
- import type { HTMLAttributes } from "astro/types";
624
- import { cva, type VariantProps } from "class-variance-authority";
625
- import { cn } from "@cl-light-ds/ui/lib/utils";
626
-
627
- const fieldVariants = cva(
628
- "data-[invalid=true]:text-destructive gap-2 group/field flex w-full",
629
- {
630
- variants: {
631
- orientation: {
632
- vertical: "flex-col *:w-full [&>.sr-only]:w-auto",
633
- horizontal:
634
- "flex-row items-center *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&_[role=checkbox],&_[role=radio],&_[data-slot=checkbox],&_[data-slot=radio-group-item]]:mt-0.5",
635
- responsive:
636
- "flex-col *:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:*:data-[slot=field-label]:flex-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&_[role=checkbox],&_[role=radio],&_[data-slot=checkbox],&_[data-slot=radio-group-item]]:mt-0.5",
637
- },
638
- },
639
- defaultVariants: {
640
- orientation: "vertical",
641
- },
642
- },
643
- );
644
-
645
- type FieldVariantProps = VariantProps<typeof fieldVariants>;
646
-
647
- interface Props extends FieldVariantProps, HTMLAttributes<"div"> {}
648
-
649
- const {
650
- class: className = "",
651
- orientation = "vertical",
652
- ...rest
653
- } = Astro.props as Props;
654
- ---
655
-
656
- <div
657
- role="group"
658
- data-slot="field"
659
- data-orientation={orientation}
660
- class={cn("data-[invalid=true]:text-destructive gap-3", fieldVariants({ orientation }), className)}
661
- {...rest}
662
- >
663
- <slot />
664
- </div>
1
+ ---
2
+ /**
3
+ * @component Field
4
+ * @title Field
5
+ * @description Composable form layout primitives for labels, descriptions, grouped controls, separators, and validation messages.
6
+ *
7
+ * @preview
8
+ *
9
+ * <div class="w-full max-w-md">
10
+ * <form>
11
+ * <FieldGroup>
12
+ * <FieldSet>
13
+ * <FieldLegend>Payment Method</FieldLegend>
14
+ * <FieldDescription>
15
+ * All transactions are secure and encrypted
16
+ * </FieldDescription>
17
+ * <FieldGroup>
18
+ * <Field>
19
+ * <FieldLabel for="checkout-7j9-card-name-43j">Name on Card</FieldLabel>
20
+ * <Input id="checkout-7j9-card-name-43j" placeholder="Evil Rabbit" required />
21
+ * </Field>
22
+ * <Field>
23
+ * <FieldLabel for="checkout-7j9-card-number-uw1">Card Number</FieldLabel>
24
+ * <Input id="checkout-7j9-card-number-uw1" placeholder="1234 5678 9012 3456" required />
25
+ * <FieldDescription>Enter your 16-digit card number</FieldDescription>
26
+ * </Field>
27
+ * <div class="grid grid-cols-3 gap-4">
28
+ * <Field>
29
+ * <FieldLabel for="checkout-exp-month-ts6">Month</FieldLabel>
30
+ * <Select>
31
+ * <SelectTrigger id="checkout-exp-month-ts6">
32
+ * <SelectValue placeholder="MM" />
33
+ * </SelectTrigger>
34
+ * <SelectContent>
35
+ * <SelectGroup>
36
+ * <SelectItem value="01">01</SelectItem>
37
+ * <SelectItem value="02">02</SelectItem>
38
+ * <SelectItem value="03">03</SelectItem>
39
+ * <SelectItem value="04">04</SelectItem>
40
+ * <SelectItem value="05">05</SelectItem>
41
+ * <SelectItem value="06">06</SelectItem>
42
+ * <SelectItem value="07">07</SelectItem>
43
+ * <SelectItem value="08">08</SelectItem>
44
+ * <SelectItem value="09">09</SelectItem>
45
+ * <SelectItem value="10">10</SelectItem>
46
+ * <SelectItem value="11">11</SelectItem>
47
+ * <SelectItem value="12">12</SelectItem>
48
+ * </SelectGroup>
49
+ * </SelectContent>
50
+ * </Select>
51
+ * </Field>
52
+ * <Field>
53
+ * <FieldLabel for="checkout-7j9-exp-year-f59">Year</FieldLabel>
54
+ * <Select>
55
+ * <SelectTrigger id="checkout-7j9-exp-year-f59">
56
+ * <SelectValue placeholder="YYYY" />
57
+ * </SelectTrigger>
58
+ * <SelectContent>
59
+ * <SelectGroup>
60
+ * <SelectItem value="2024">2024</SelectItem>
61
+ * <SelectItem value="2025">2025</SelectItem>
62
+ * <SelectItem value="2026">2026</SelectItem>
63
+ * <SelectItem value="2027">2027</SelectItem>
64
+ * <SelectItem value="2028">2028</SelectItem>
65
+ * <SelectItem value="2029">2029</SelectItem>
66
+ * </SelectGroup>
67
+ * </SelectContent>
68
+ * </Select>
69
+ * </Field>
70
+ * <Field>
71
+ * <FieldLabel for="checkout-7j9-cvv">CVV</FieldLabel>
72
+ * <Input id="checkout-7j9-cvv" placeholder="123" required />
73
+ * </Field>
74
+ * </div>
75
+ * </FieldGroup>
76
+ * </FieldSet>
77
+ *
78
+ * <FieldSeparator />
79
+ *
80
+ * <FieldSet>
81
+ * <FieldLegend>Billing Address</FieldLegend>
82
+ * <FieldDescription>
83
+ * The billing address associated with your payment method
84
+ * </FieldDescription>
85
+ * <FieldGroup>
86
+ * <Field orientation="horizontal">
87
+ * <Checkbox id="checkout-7j9-same-as-shipping-wgm" checked />
88
+ * <FieldLabel for="checkout-7j9-same-as-shipping-wgm" class="font-normal">
89
+ * Same as shipping address
90
+ * </FieldLabel>
91
+ * </Field>
92
+ * </FieldGroup>
93
+ * </FieldSet>
94
+ *
95
+ * <FieldSet>
96
+ * <FieldGroup>
97
+ * <Field>
98
+ * <FieldLabel for="checkout-7j9-optional-comments">Comments</FieldLabel>
99
+ * <Textarea
100
+ * id="checkout-7j9-optional-comments"
101
+ * placeholder="Add any additional comments"
102
+ * class="resize-none"
103
+ * />
104
+ * </Field>
105
+ * </FieldGroup>
106
+ * </FieldSet>
107
+ *
108
+ * <Field orientation="horizontal">
109
+ * <Button type="submit">Submit</Button>
110
+ * <Button variant="outline" type="button">Cancel</Button>
111
+ * </Field>
112
+ * </FieldGroup>
113
+ * </form>
114
+ * </div>
115
+ *
116
+ * @usage
117
+ *
118
+ * ```astro nocollapse
119
+ * ---
120
+ * import {
121
+ * Field,
122
+ * FieldContent,
123
+ * FieldDescription,
124
+ * FieldError,
125
+ * FieldGroup,
126
+ * FieldLabel,
127
+ * FieldLegend,
128
+ * FieldSeparator,
129
+ * FieldSet,
130
+ * FieldTitle,
131
+ * } from '@bejamas/ui/components/field';
132
+ * ---
133
+ *
134
+ * <FieldGroup>
135
+ * <FieldSet>
136
+ * <FieldLegend>Account</FieldLegend>
137
+ * <Field>
138
+ * <FieldLabel for="email">Email</FieldLabel>
139
+ * <Input id="email" type="email" />
140
+ * <FieldError errors={[{ message: 'Email is required' }]} />
141
+ * </Field>
142
+ * </FieldSet>
143
+ * </FieldGroup>
144
+ * ```
145
+ *
146
+ * @api
147
+ *
148
+ * ### FieldSet
149
+ *
150
+ * Container that renders a semantic `fieldset` with spacing presets.
151
+ *
152
+ * | Prop | Type | Default |
153
+ * |------|------|---------|
154
+ * | `class` | `string` | - |
155
+ *
156
+ * ```astro nocollapse
157
+ * <FieldSet>
158
+ * <FieldLegend>Delivery</FieldLegend>
159
+ * <FieldGroup>
160
+ * <Field>
161
+ * <FieldLabel for="address">Address</FieldLabel>
162
+ * <Input id="address" />
163
+ * </Field>
164
+ * </FieldGroup>
165
+ * </FieldSet>
166
+ * ```
167
+ *
168
+ * ### FieldLegend
169
+ *
170
+ * Legend element for a `FieldSet`. Use the `label` variant to align with label sizing.
171
+ *
172
+ * | Prop | Type | Default |
173
+ * |------|------|---------|
174
+ * | `variant` | `"legend" \| "label"` | `"legend"` |
175
+ * | `class` | `string` | - |
176
+ *
177
+ * ```astro nocollapse
178
+ * <FieldLegend variant="label">Notification Preferences</FieldLegend>
179
+ * ```
180
+ *
181
+ * ### FieldGroup
182
+ *
183
+ * Layout wrapper that stacks `Field` components and enables container-query
184
+ * responsive orientations.
185
+ *
186
+ * | Prop | Type | Default |
187
+ * |------|------|---------|
188
+ * | `class` | `string` | - |
189
+ *
190
+ * ```astro nocollapse
191
+ * <FieldGroup class="@container/field-group flex flex-col gap-6">
192
+ * <Field>...</Field>
193
+ * <Field>...</Field>
194
+ * </FieldGroup>
195
+ * ```
196
+ *
197
+ * ### Field
198
+ *
199
+ * Core wrapper for a single field. Provides orientation control, invalid-state
200
+ * styling, and spacing.
201
+ *
202
+ * | Prop | Type | Default |
203
+ * |------|------|---------|
204
+ * | `orientation` | `"vertical" \| "horizontal" \| "responsive"` | `"vertical"` |
205
+ * | `class` | `string` | - |
206
+ * | `data-invalid` | `"true" \| "false"` | - |
207
+ *
208
+ * ```astro nocollapse
209
+ * <Field orientation="horizontal">
210
+ * <FieldLabel for="remember">Remember me</FieldLabel>
211
+ * <Switch id="remember" />
212
+ * </Field>
213
+ * ```
214
+ *
215
+ * ### FieldContent
216
+ *
217
+ * Flex column for grouping control and descriptions when label/content are split.
218
+ *
219
+ * | Prop | Type | Default |
220
+ * |------|------|---------|
221
+ * | `class` | `string` | - |
222
+ *
223
+ * ```astro nocollapse
224
+ * <Field orientation="horizontal">
225
+ * <Checkbox id="notifications" />
226
+ * <FieldContent>
227
+ * <FieldLabel for="notifications">Notifications</FieldLabel>
228
+ * <FieldDescription>Email, SMS, and push options.</FieldDescription>
229
+ * </FieldContent>
230
+ * </Field>
231
+ * ```
232
+ *
233
+ * ### FieldLabel
234
+ *
235
+ * Label styled for both direct controls and nested `Field` children.
236
+ *
237
+ * | Prop | Type | Default |
238
+ * |------|------|---------|
239
+ * | `class` | `string` | - |
240
+ * | `for` | `string` | - |
241
+ *
242
+ * ```astro nocollapse
243
+ * <FieldLabel for="email">Email</FieldLabel>
244
+ * ```
245
+ *
246
+ * ### FieldTitle
247
+ *
248
+ * Title text styled for use inside `FieldContent`.
249
+ *
250
+ * | Prop | Type | Default |
251
+ * |------|------|---------|
252
+ * | `class` | `string` | - |
253
+ *
254
+ * ```astro nocollapse
255
+ * <FieldContent>
256
+ * <FieldTitle>Enable Touch ID</FieldTitle>
257
+ * <FieldDescription>Unlock your device faster.</FieldDescription>
258
+ * </FieldContent>
259
+ * ```
260
+ *
261
+ * ### FieldDescription
262
+ *
263
+ * Helper text slot that supports links and balanced wrapping in horizontal layouts.
264
+ *
265
+ * | Prop | Type | Default |
266
+ * |------|------|---------|
267
+ * | `class` | `string` | - |
268
+ *
269
+ * ```astro nocollapse
270
+ * <FieldDescription>We never share your email with anyone.</FieldDescription>
271
+ * ```
272
+ *
273
+ * ### FieldSeparator
274
+ *
275
+ * Visual divider for sections inside a `FieldGroup`. Supports optional inline
276
+ * content through its default slot.
277
+ *
278
+ * | Prop | Type | Default |
279
+ * |------|------|---------|
280
+ * | `class` | `string` | - |
281
+ *
282
+ * ```astro nocollapse
283
+ * <FieldSeparator>Or continue with</FieldSeparator>
284
+ * ```
285
+ *
286
+ * ### FieldError
287
+ *
288
+ * Accessible error container. Renders slot content if provided; otherwise it
289
+ * derives output from the `errors` array.
290
+ *
291
+ * | Prop | Type | Default |
292
+ * |------|------|---------|
293
+ * | `errors` | `Array<{ message?: string } \| undefined>` | `[]` |
294
+ * | `forceMount` | `boolean` | `false` |
295
+ * | `class` | `string` | - |
296
+ *
297
+ * ```astro nocollapse
298
+ * <FieldError errors={[{ message: "Username is required" }]} />
299
+ * ```
300
+ *
301
+ * When `errors` contains multiple unique messages, the component renders a list
302
+ * automatically.
303
+ *
304
+ * For client-side script flows in Astro, mount once and toggle visibility:
305
+ *
306
+ * ```astro nocollapse
307
+ * <FieldError forceMount class="hidden" data-error-for="email" />
308
+ * ```
309
+ *
310
+ * @examples
311
+ *
312
+ * ### Input
313
+ *
314
+ * <FieldSet class="w-full max-w-xs">
315
+ * <FieldGroup>
316
+ * <Field>
317
+ * <FieldLabel for="username">Username</FieldLabel>
318
+ * <Input id="username" type="text" placeholder="Max Leiter" />
319
+ * <FieldDescription>
320
+ * Choose a unique username for your account.
321
+ * </FieldDescription>
322
+ * </Field>
323
+ * <Field>
324
+ * <FieldLabel for="password">Password</FieldLabel>
325
+ * <FieldDescription>
326
+ * Must be at least 8 characters long.
327
+ * </FieldDescription>
328
+ * <Input id="password" type="password" placeholder="••••••••" />
329
+ * </Field>
330
+ * </FieldGroup>
331
+ * </FieldSet>
332
+ *
333
+ * ### Textarea
334
+ *
335
+ * <FieldSet class="w-full max-w-xs">
336
+ * <FieldGroup>
337
+ * <Field>
338
+ * <FieldLabel for="feedback">Feedback</FieldLabel>
339
+ * <Textarea
340
+ * id="feedback"
341
+ * placeholder="Your feedback helps us improve..."
342
+ * rows={4}
343
+ * />
344
+ * <FieldDescription>
345
+ * Share your thoughts about our service.
346
+ * </FieldDescription>
347
+ * </Field>
348
+ * </FieldGroup>
349
+ * </FieldSet>
350
+ *
351
+ * ### Select
352
+ *
353
+ * <Field class="w-full max-w-xs">
354
+ * <FieldLabel for="department">Department</FieldLabel>
355
+ * <Select>
356
+ * <SelectTrigger id="department">
357
+ * <SelectValue placeholder="Choose department" />
358
+ * </SelectTrigger>
359
+ * <SelectContent>
360
+ * <SelectGroup>
361
+ * <SelectItem value="engineering">Engineering</SelectItem>
362
+ * <SelectItem value="design">Design</SelectItem>
363
+ * <SelectItem value="marketing">Marketing</SelectItem>
364
+ * <SelectItem value="sales">Sales</SelectItem>
365
+ * <SelectItem value="support">Customer Support</SelectItem>
366
+ * <SelectItem value="hr">Human Resources</SelectItem>
367
+ * <SelectItem value="finance">Finance</SelectItem>
368
+ * <SelectItem value="operations">Operations</SelectItem>
369
+ * </SelectGroup>
370
+ * </SelectContent>
371
+ * </Select>
372
+ * <FieldDescription>
373
+ * Select your department or area of work.
374
+ * </FieldDescription>
375
+ * </Field>
376
+ *
377
+ * ### Slider
378
+ *
379
+ * <Field class="w-full max-w-xs">
380
+ * <FieldTitle>Price Range</FieldTitle>
381
+ * <FieldDescription>
382
+ * Set your budget range between $200 and $800.
383
+ * </FieldDescription>
384
+ * <Slider
385
+ * defaultValue={[200, 800]}
386
+ * max={1000}
387
+ * min={0}
388
+ * step={10}
389
+ * class="mt-2 w-full"
390
+ * aria-label="Price Range"
391
+ * />
392
+ * </Field>
393
+ *
394
+ * ### Fieldset
395
+ *
396
+ * <FieldSet class="w-full max-w-sm">
397
+ * <FieldLegend>Address Information</FieldLegend>
398
+ * <FieldDescription>
399
+ * We need your address to deliver your order.
400
+ * </FieldDescription>
401
+ * <FieldGroup>
402
+ * <Field>
403
+ * <FieldLabel for="street">Street Address</FieldLabel>
404
+ * <Input id="street" type="text" placeholder="123 Main St" />
405
+ * </Field>
406
+ * <div class="grid grid-cols-2 gap-4">
407
+ * <Field>
408
+ * <FieldLabel for="city">City</FieldLabel>
409
+ * <Input id="city" type="text" placeholder="New York" />
410
+ * </Field>
411
+ * <Field>
412
+ * <FieldLabel for="zip">Postal Code</FieldLabel>
413
+ * <Input id="zip" type="text" placeholder="90502" />
414
+ * </Field>
415
+ * </div>
416
+ * </FieldGroup>
417
+ * </FieldSet>
418
+ *
419
+ * ### Checkbox
420
+ *
421
+ * <FieldGroup class="w-full max-w-xs">
422
+ * <FieldSet>
423
+ * <FieldLegend variant="label">
424
+ * Show these items on the desktop
425
+ * </FieldLegend>
426
+ * <FieldDescription>
427
+ * Select the items you want to show on the desktop.
428
+ * </FieldDescription>
429
+ * <FieldGroup class="gap-3">
430
+ * <Field orientation="horizontal">
431
+ * <Checkbox id="finder-pref-9k2-hard-disks-ljj" checked />
432
+ * <FieldLabel
433
+ * for="finder-pref-9k2-hard-disks-ljj"
434
+ * class="font-normal"
435
+ * >
436
+ * Hard disks
437
+ * </FieldLabel>
438
+ * </Field>
439
+ * <Field orientation="horizontal">
440
+ * <Checkbox id="finder-pref-9k2-external-disks-1yg" />
441
+ * <FieldLabel
442
+ * for="finder-pref-9k2-external-disks-1yg"
443
+ * class="font-normal"
444
+ * >
445
+ * External disks
446
+ * </FieldLabel>
447
+ * </Field>
448
+ * <Field orientation="horizontal">
449
+ * <Checkbox id="finder-pref-9k2-cds-dvds-fzt" />
450
+ * <FieldLabel
451
+ * for="finder-pref-9k2-cds-dvds-fzt"
452
+ * class="font-normal"
453
+ * >
454
+ * CDs, DVDs, and iPods
455
+ * </FieldLabel>
456
+ * </Field>
457
+ * <Field orientation="horizontal">
458
+ * <Checkbox id="finder-pref-9k2-connected-servers-6l2" />
459
+ * <FieldLabel
460
+ * for="finder-pref-9k2-connected-servers-6l2"
461
+ * class="font-normal"
462
+ * >
463
+ * Connected servers
464
+ * </FieldLabel>
465
+ * </Field>
466
+ * </FieldGroup>
467
+ * </FieldSet>
468
+ * <FieldSeparator />
469
+ * <Field orientation="horizontal">
470
+ * <Checkbox id="finder-pref-9k2-sync-folders-nep" checked />
471
+ * <FieldContent>
472
+ * <FieldLabel for="finder-pref-9k2-sync-folders-nep">
473
+ * Sync Desktop & Documents folders
474
+ * </FieldLabel>
475
+ * <FieldDescription>
476
+ * Your Desktop & Documents folders are being synced with iCloud Drive.
477
+ * You can access them from other devices.
478
+ * </FieldDescription>
479
+ * </FieldContent>
480
+ * </Field>
481
+ * </FieldGroup>
482
+ *
483
+ * ### Radio
484
+ *
485
+ * <FieldSet class="w-full max-w-xs">
486
+ * <FieldLegend variant="label">Subscription Plan</FieldLegend>
487
+ * <FieldDescription>
488
+ * Yearly and lifetime plans offer significant savings.
489
+ * </FieldDescription>
490
+ * <RadioGroup name="subscription-plan" defaultValue="monthly">
491
+ * <Field orientation="horizontal">
492
+ * <RadioGroupItem
493
+ * value="monthly"
494
+ * id="plan-monthly"
495
+ * />
496
+ * <FieldLabel for="plan-monthly" class="font-normal">
497
+ * Monthly ($9.99/month)
498
+ * </FieldLabel>
499
+ * </Field>
500
+ * <Field orientation="horizontal">
501
+ * <RadioGroupItem
502
+ * name="subscription-plan"
503
+ * value="yearly"
504
+ * id="plan-yearly"
505
+ * />
506
+ * <FieldLabel for="plan-yearly" class="font-normal">
507
+ * Yearly ($99.99/year)
508
+ * </FieldLabel>
509
+ * </Field>
510
+ * <Field orientation="horizontal">
511
+ * <RadioGroupItem
512
+ * name="subscription-plan"
513
+ * value="lifetime"
514
+ * id="plan-lifetime"
515
+ * />
516
+ * <FieldLabel for="plan-lifetime" class="font-normal">
517
+ * Lifetime ($299.99)
518
+ * </FieldLabel>
519
+ * </Field>
520
+ * </RadioGroup>
521
+ * </FieldSet>
522
+ *
523
+ * ### Switch
524
+ *
525
+ * <Field orientation="horizontal" class="w-fit">
526
+ * <FieldLabel for="2fa">Multi-factor authentication</FieldLabel>
527
+ * <Switch id="2fa" />
528
+ * </Field>
529
+ *
530
+ * ### Choice Card
531
+ *
532
+ * Wrap `Field` components inside `FieldLabel` to create selectable field groups.
533
+ * This works with `RadioGroupItem`, `Checkbox`, and `Switch` components.
534
+ *
535
+ * <FieldGroup class="w-full max-w-xs">
536
+ * <FieldSet>
537
+ * <FieldLegend variant="label">Compute Environment</FieldLegend>
538
+ * <FieldDescription>
539
+ * Select the compute environment for your cluster.
540
+ * </FieldDescription>
541
+ * <RadioGroup
542
+ * name="compute-environment"
543
+ * defaultValue="kubernetes"
544
+ * >
545
+ * <FieldLabel for="kubernetes-r2h">
546
+ * <Field orientation="horizontal">
547
+ * <FieldContent>
548
+ * <FieldTitle>Kubernetes</FieldTitle>
549
+ * <FieldDescription>
550
+ * Run GPU workloads on a K8s cluster.
551
+ * </FieldDescription>
552
+ * </FieldContent>
553
+ * <RadioGroupItem
554
+ * value="kubernetes"
555
+ * id="kubernetes-r2h"
556
+ * />
557
+ * </Field>
558
+ * </FieldLabel>
559
+ * <FieldLabel for="vm-z4k">
560
+ * <Field orientation="horizontal">
561
+ * <FieldContent>
562
+ * <FieldTitle>Virtual Machine</FieldTitle>
563
+ * <FieldDescription>
564
+ * Access a cluster to run GPU workloads.
565
+ * </FieldDescription>
566
+ * </FieldContent>
567
+ * <RadioGroupItem
568
+ * value="vm"
569
+ * id="vm-z4k"
570
+ * />
571
+ * </Field>
572
+ * </FieldLabel>
573
+ * </RadioGroup>
574
+ * </FieldSet>
575
+ * </FieldGroup>
576
+ *
577
+ * ### Field Group
578
+ *
579
+ * Stack `Field` components with `FieldGroup`. Add `FieldSeparator` to divide
580
+ * them.
581
+ *
582
+ * <FieldGroup class="w-full max-w-xs">
583
+ * <FieldSet>
584
+ * <FieldLabel>Responses</FieldLabel>
585
+ * <FieldDescription>
586
+ * Get notified when ChatGPT responds to requests that take time, like
587
+ * research or image generation.
588
+ * </FieldDescription>
589
+ * <FieldGroup data-slot="checkbox-group" class="">
590
+ * <Field orientation="horizontal">
591
+ * <Checkbox id="push" checked disabled />
592
+ * <FieldLabel for="push" class="font-normal">
593
+ * Push notifications
594
+ * </FieldLabel>
595
+ * </Field>
596
+ * </FieldGroup>
597
+ * </FieldSet>
598
+ * <FieldSeparator />
599
+ * <FieldSet>
600
+ * <FieldLabel>Tasks</FieldLabel>
601
+ * <FieldDescription>
602
+ * Get notified when tasks you've created have updates.
603
+ * <a href="#">Manage tasks</a>
604
+ * </FieldDescription>
605
+ * <FieldGroup data-slot="checkbox-group" class="">
606
+ * <Field orientation="horizontal">
607
+ * <Checkbox id="push-tasks" />
608
+ * <FieldLabel for="push-tasks" class="font-normal">
609
+ * Push notifications
610
+ * </FieldLabel>
611
+ * </Field>
612
+ * <Field orientation="horizontal">
613
+ * <Checkbox id="email-tasks" />
614
+ * <FieldLabel for="email-tasks" class="font-normal">
615
+ * Email notifications
616
+ * </FieldLabel>
617
+ * </Field>
618
+ * </FieldGroup>
619
+ * </FieldSet>
620
+ * </FieldGroup>
621
+ */
622
+
623
+ import type { HTMLAttributes } from "astro/types";
624
+ import { cva, type VariantProps } from "class-variance-authority";
625
+ import { cn } from "@cl-light-ds/ui/lib/utils";
626
+
627
+ const fieldVariants = cva(
628
+ "data-[invalid=true]:text-destructive gap-2 group/field flex w-full",
629
+ {
630
+ variants: {
631
+ orientation: {
632
+ vertical: "flex-col *:w-full [&>.sr-only]:w-auto",
633
+ horizontal:
634
+ "flex-row items-center *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&_[role=checkbox],&_[role=radio],&_[data-slot=checkbox],&_[data-slot=radio-group-item]]:mt-0.5",
635
+ responsive:
636
+ "flex-col *:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:*:data-[slot=field-label]:flex-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&_[role=checkbox],&_[role=radio],&_[data-slot=checkbox],&_[data-slot=radio-group-item]]:mt-0.5",
637
+ },
638
+ },
639
+ defaultVariants: {
640
+ orientation: "vertical",
641
+ },
642
+ },
643
+ );
644
+
645
+ type FieldVariantProps = VariantProps<typeof fieldVariants>;
646
+
647
+ interface Props extends FieldVariantProps, HTMLAttributes<"div"> {}
648
+
649
+ const {
650
+ class: className = "",
651
+ orientation = "vertical",
652
+ ...rest
653
+ } = Astro.props as Props;
654
+ ---
655
+
656
+ <div
657
+ role="group"
658
+ data-slot="field"
659
+ data-orientation={orientation}
660
+ class={cn("data-[invalid=true]:text-destructive gap-3", fieldVariants({ orientation }), className)}
661
+ {...rest}
662
+ >
663
+ <slot />
664
+ </div>