@cl-light-ds/ui 0.1.0 → 0.2.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 (171) 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/alert/Alert.astro +167 -167
  8. package/src/components/alert/AlertDescription.astro +24 -24
  9. package/src/components/alert/AlertTitle.astro +24 -24
  10. package/src/components/avatar/Avatar.astro +197 -197
  11. package/src/components/avatar/AvatarBadge.astro +44 -44
  12. package/src/components/avatar/AvatarFallback.astro +26 -26
  13. package/src/components/avatar/AvatarGroup.astro +26 -26
  14. package/src/components/avatar/AvatarGroupCount.astro +30 -30
  15. package/src/components/avatar/AvatarImage.astro +46 -46
  16. package/src/components/badge/Badge.astro +167 -167
  17. package/src/components/breadcrumb/Breadcrumb.astro +76 -76
  18. package/src/components/breadcrumb/BreadcrumbItem.astro +32 -32
  19. package/src/components/breadcrumb/BreadcrumbList.astro +26 -26
  20. package/src/components/breadcrumb/BreadcrumbSeparator.astro +26 -26
  21. package/src/components/button/Button.astro +233 -233
  22. package/src/components/button-group/ButtonGroup.astro +130 -130
  23. package/src/components/button-group/ButtonGroupSeparator.astro +30 -30
  24. package/src/components/button-group/ButtonGroupText.astro +21 -21
  25. package/src/components/card/Card.astro +182 -182
  26. package/src/components/card/CardAction.astro +26 -26
  27. package/src/components/card/CardContent.astro +28 -28
  28. package/src/components/card/CardDescription.astro +28 -28
  29. package/src/components/card/CardFooter.astro +24 -24
  30. package/src/components/card/CardHeader.astro +30 -30
  31. package/src/components/card/CardMedia.astro +27 -27
  32. package/src/components/card/CardOverlay.astro +32 -32
  33. package/src/components/card/CardTitle.astro +21 -21
  34. package/src/components/carousel/Carousel.astro +106 -106
  35. package/src/components/carousel/CarouselSlide.astro +22 -22
  36. package/src/components/checkbox/Checkbox.astro +159 -159
  37. package/src/components/collapsible/Collapsible.astro +202 -202
  38. package/src/components/collapsible/CollapsibleContent.astro +36 -36
  39. package/src/components/collapsible/CollapsibleTrigger.astro +34 -34
  40. package/src/components/combobox/Combobox.astro +365 -365
  41. package/src/components/combobox/ComboboxContent.astro +37 -37
  42. package/src/components/combobox/ComboboxEmpty.astro +18 -18
  43. package/src/components/combobox/ComboboxGroup.astro +19 -19
  44. package/src/components/combobox/ComboboxInput.astro +74 -74
  45. package/src/components/combobox/ComboboxItem.astro +39 -39
  46. package/src/components/combobox/ComboboxLabel.astro +18 -18
  47. package/src/components/combobox/ComboboxList.astro +21 -21
  48. package/src/components/combobox/ComboboxSeparator.astro +17 -17
  49. package/src/components/combobox/ComboboxTrigger.astro +30 -30
  50. package/src/components/combobox/ComboboxValue.astro +22 -22
  51. package/src/components/date/Date.astro +137 -137
  52. package/src/components/dialog/Dialog.astro +196 -196
  53. package/src/components/dialog/DialogClose.astro +23 -23
  54. package/src/components/dialog/DialogContent.astro +42 -42
  55. package/src/components/dialog/DialogDescription.astro +18 -18
  56. package/src/components/dialog/DialogFooter.astro +18 -18
  57. package/src/components/dialog/DialogHeader.astro +18 -18
  58. package/src/components/dialog/DialogOverlay.astro +19 -19
  59. package/src/components/dialog/DialogTitle.astro +18 -18
  60. package/src/components/dialog/DialogTrigger.astro +37 -37
  61. package/src/components/dropdown-menu/DropdownMenu.astro +226 -226
  62. package/src/components/dropdown-menu/DropdownMenuCheckboxItem.astro +114 -114
  63. package/src/components/dropdown-menu/DropdownMenuContent.astro +42 -42
  64. package/src/components/dropdown-menu/DropdownMenuGroup.astro +19 -19
  65. package/src/components/dropdown-menu/DropdownMenuItem.astro +220 -220
  66. package/src/components/dropdown-menu/DropdownMenuLabel.astro +20 -20
  67. package/src/components/dropdown-menu/DropdownMenuRadioItem.astro +101 -101
  68. package/src/components/dropdown-menu/DropdownMenuSeparator.astro +18 -18
  69. package/src/components/dropdown-menu/DropdownMenuShortcut.astro +18 -18
  70. package/src/components/dropdown-menu/DropdownMenuTrigger.astro +49 -49
  71. package/src/components/field/Field.astro +664 -664
  72. package/src/components/field/FieldContent.astro +20 -20
  73. package/src/components/field/FieldDescription.astro +22 -22
  74. package/src/components/field/FieldError.astro +51 -51
  75. package/src/components/field/FieldGroup.astro +20 -20
  76. package/src/components/field/FieldLabel.astro +22 -22
  77. package/src/components/field/FieldLegend.astro +23 -23
  78. package/src/components/field/FieldSeparator.astro +30 -30
  79. package/src/components/field/FieldSet.astro +20 -20
  80. package/src/components/field/FieldTitle.astro +20 -20
  81. package/src/components/hover-card/HoverCard.astro +235 -235
  82. package/src/components/hover-card/HoverCardContent.astro +54 -54
  83. package/src/components/hover-card/HoverCardTrigger.astro +38 -38
  84. package/src/components/input/Input.astro +130 -130
  85. package/src/components/input-group/InputGroup.astro +135 -135
  86. package/src/components/input-group/InputGroupAddon.astro +49 -49
  87. package/src/components/input-group/InputGroupButton.astro +58 -58
  88. package/src/components/input-group/InputGroupInput.astro +18 -18
  89. package/src/components/input-group/InputGroupText.astro +21 -21
  90. package/src/components/input-group/InputGroupTextarea.astro +17 -17
  91. package/src/components/item/Item.astro +122 -122
  92. package/src/components/item/ItemActions.astro +21 -21
  93. package/src/components/item/ItemContent.astro +25 -25
  94. package/src/components/item/ItemDescription.astro +25 -25
  95. package/src/components/item/ItemFooter.astro +24 -24
  96. package/src/components/item/ItemGroup.astro +24 -24
  97. package/src/components/item/ItemHeader.astro +24 -24
  98. package/src/components/item/ItemMedia.astro +47 -47
  99. package/src/components/item/ItemSeparator.astro +21 -21
  100. package/src/components/item/ItemTitle.astro +25 -25
  101. package/src/components/kbd/Kbd.astro +145 -145
  102. package/src/components/kbd/KbdGroup.astro +55 -55
  103. package/src/components/label/Label.astro +97 -97
  104. package/src/components/link-group/LinkGroup.astro +67 -67
  105. package/src/components/link-group/LinkGroupItem.astro +32 -32
  106. package/src/components/link-group/LinkGroupList.astro +25 -25
  107. package/src/components/link-group/LinkGroupTitle.astro +22 -22
  108. package/src/components/marquee/Marquee.astro +119 -119
  109. package/src/components/native-select/NativeSelect.astro +125 -125
  110. package/src/components/native-select/NativeSelectOptGroup.astro +14 -14
  111. package/src/components/navigation-menu/NavigationMenu.astro +414 -414
  112. package/src/components/navigation-menu/NavigationMenuContent.astro +37 -37
  113. package/src/components/navigation-menu/NavigationMenuIndicator.astro +24 -24
  114. package/src/components/navigation-menu/NavigationMenuItem.astro +22 -22
  115. package/src/components/navigation-menu/NavigationMenuLink.astro +18 -18
  116. package/src/components/navigation-menu/NavigationMenuList.astro +21 -21
  117. package/src/components/navigation-menu/NavigationMenuPositioner.astro +44 -44
  118. package/src/components/navigation-menu/NavigationMenuTrigger.astro +30 -30
  119. package/src/components/navigation-menu/NavigationMenuViewport.astro +19 -19
  120. package/src/components/popover/CHANGELOG.md +17 -2
  121. package/src/components/popover/Popover.astro +211 -210
  122. package/src/components/popover/PopoverClose.astro +18 -18
  123. package/src/components/popover/PopoverContent.astro +50 -49
  124. package/src/components/popover/PopoverDescription.astro +18 -18
  125. package/src/components/popover/PopoverHeader.astro +18 -18
  126. package/src/components/popover/PopoverTitle.astro +18 -18
  127. package/src/components/popover/PopoverTrigger.astro +35 -29
  128. package/src/components/radio-group/CHANGELOG.md +23 -1
  129. package/src/components/radio-group/RadioGroup.astro +81 -81
  130. package/src/components/radio-group/RadioGroupItem.astro +51 -42
  131. package/src/components/select/Select.astro +373 -373
  132. package/src/components/select/SelectContent.astro +91 -91
  133. package/src/components/select/SelectGroup.astro +19 -19
  134. package/src/components/select/SelectItem.astro +48 -48
  135. package/src/components/select/SelectLabel.astro +18 -18
  136. package/src/components/select/SelectSeparator.astro +17 -17
  137. package/src/components/select/SelectTrigger.astro +34 -34
  138. package/src/components/select/SelectValue.astro +22 -22
  139. package/src/components/separator/Separator.astro +60 -60
  140. package/src/components/skeleton/Skeleton.astro +121 -121
  141. package/src/components/slider/Slider.astro +198 -198
  142. package/src/components/spinner/CHANGELOG.md +14 -1
  143. package/src/components/spinner/Spinner.astro +135 -134
  144. package/src/components/sticky-surface/StickySurface.astro +152 -152
  145. package/src/components/switch/CHANGELOG.md +20 -0
  146. package/src/components/switch/Switch.astro +106 -106
  147. package/src/components/table/CHANGELOG.md +21 -2
  148. package/src/components/table/Table.astro +251 -250
  149. package/src/components/table/TableBody.astro +18 -18
  150. package/src/components/table/TableCaption.astro +17 -17
  151. package/src/components/table/TableCell.astro +21 -21
  152. package/src/components/table/TableFooter.astro +21 -21
  153. package/src/components/table/TableHead.astro +21 -21
  154. package/src/components/table/TableHeader.astro +17 -17
  155. package/src/components/table/TableRow.astro +21 -21
  156. package/src/components/tabs/Tabs.astro +306 -306
  157. package/src/components/tabs/TabsContent.astro +47 -47
  158. package/src/components/tabs/TabsList.astro +69 -69
  159. package/src/components/tabs/TabsTrigger.astro +40 -40
  160. package/src/components/textarea/CHANGELOG.md +18 -1
  161. package/src/components/textarea/Textarea.astro +58 -36
  162. package/src/components/toggle/CHANGELOG.md +19 -1
  163. package/src/components/toggle/Toggle.astro +150 -138
  164. package/src/components/toggle-group/CHANGELOG.md +14 -1
  165. package/src/components/toggle-group/ToggleGroup.astro +236 -224
  166. package/src/components/toggle-group/ToggleGroupItem.astro +48 -48
  167. package/src/components/tooltip/CHANGELOG.md +19 -2
  168. package/src/components/tooltip/Tooltip.astro +357 -331
  169. package/src/components/tooltip/TooltipContent.astro +85 -60
  170. package/src/components/tooltip/TooltipTrigger.astro +34 -34
  171. package/src/lib/toggle-shared.ts +3 -2
@@ -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>