@cl-light-ds/ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -0
- package/package.json +59 -0
- package/src/components/accordion/Accordion.astro +248 -0
- package/src/components/accordion/AccordionContent.astro +26 -0
- package/src/components/accordion/AccordionItem.astro +36 -0
- package/src/components/accordion/AccordionTrigger.astro +118 -0
- package/src/components/accordion/CHANGELOG.md +41 -0
- package/src/components/accordion/index.ts +4 -0
- package/src/components/alert/Alert.astro +167 -0
- package/src/components/alert/AlertDescription.astro +24 -0
- package/src/components/alert/AlertTitle.astro +24 -0
- package/src/components/alert/CHANGELOG.md +5 -0
- package/src/components/alert/index.ts +4 -0
- package/src/components/avatar/Avatar.astro +197 -0
- package/src/components/avatar/AvatarBadge.astro +44 -0
- package/src/components/avatar/AvatarFallback.astro +26 -0
- package/src/components/avatar/AvatarGroup.astro +26 -0
- package/src/components/avatar/AvatarGroupCount.astro +30 -0
- package/src/components/avatar/AvatarImage.astro +46 -0
- package/src/components/avatar/CHANGELOG.md +44 -0
- package/src/components/avatar/index.ts +6 -0
- package/src/components/badge/Badge.astro +167 -0
- package/src/components/badge/CHANGELOG.md +49 -0
- package/src/components/badge/index.ts +2 -0
- package/src/components/breadcrumb/Breadcrumb.astro +76 -0
- package/src/components/breadcrumb/BreadcrumbItem.astro +32 -0
- package/src/components/breadcrumb/BreadcrumbList.astro +26 -0
- package/src/components/breadcrumb/BreadcrumbSeparator.astro +26 -0
- package/src/components/breadcrumb/CHANGELOG.md +24 -0
- package/src/components/breadcrumb/index.ts +5 -0
- package/src/components/button/Button.astro +233 -0
- package/src/components/button/CHANGELOG.md +41 -0
- package/src/components/button/index.ts +2 -0
- package/src/components/button-group/ButtonGroup.astro +130 -0
- package/src/components/button-group/ButtonGroupSeparator.astro +30 -0
- package/src/components/button-group/ButtonGroupText.astro +21 -0
- package/src/components/button-group/CHANGELOG.md +34 -0
- package/src/components/button-group/index.ts +3 -0
- package/src/components/card/CHANGELOG.md +119 -0
- package/src/components/card/Card.astro +182 -0
- package/src/components/card/CardAction.astro +26 -0
- package/src/components/card/CardContent.astro +28 -0
- package/src/components/card/CardDescription.astro +28 -0
- package/src/components/card/CardFooter.astro +24 -0
- package/src/components/card/CardHeader.astro +30 -0
- package/src/components/card/CardMedia.astro +27 -0
- package/src/components/card/CardOverlay.astro +32 -0
- package/src/components/card/CardTitle.astro +21 -0
- package/src/components/card/index.ts +10 -0
- package/src/components/carousel/CHANGELOG.md +5 -0
- package/src/components/carousel/Carousel.astro +106 -0
- package/src/components/carousel/CarouselSlide.astro +22 -0
- package/src/components/carousel/index.ts +3 -0
- package/src/components/checkbox/CHANGELOG.md +58 -0
- package/src/components/checkbox/Checkbox.astro +159 -0
- package/src/components/checkbox/index.ts +1 -0
- package/src/components/collapsible/CHANGELOG.md +5 -0
- package/src/components/collapsible/Collapsible.astro +202 -0
- package/src/components/collapsible/CollapsibleContent.astro +36 -0
- package/src/components/collapsible/CollapsibleTrigger.astro +34 -0
- package/src/components/collapsible/index.ts +4 -0
- package/src/components/combobox/CHANGELOG.md +27 -0
- package/src/components/combobox/Combobox.astro +365 -0
- package/src/components/combobox/ComboboxContent.astro +37 -0
- package/src/components/combobox/ComboboxEmpty.astro +18 -0
- package/src/components/combobox/ComboboxGroup.astro +19 -0
- package/src/components/combobox/ComboboxInput.astro +74 -0
- package/src/components/combobox/ComboboxItem.astro +39 -0
- package/src/components/combobox/ComboboxLabel.astro +18 -0
- package/src/components/combobox/ComboboxList.astro +21 -0
- package/src/components/combobox/ComboboxSeparator.astro +17 -0
- package/src/components/combobox/ComboboxTrigger.astro +30 -0
- package/src/components/combobox/ComboboxValue.astro +22 -0
- package/src/components/combobox/index.ts +11 -0
- package/src/components/date/CHANGELOG.md +18 -0
- package/src/components/date/Date.astro +137 -0
- package/src/components/date/index.ts +2 -0
- package/src/components/dialog/CHANGELOG.md +39 -0
- package/src/components/dialog/Dialog.astro +196 -0
- package/src/components/dialog/DialogClose.astro +23 -0
- package/src/components/dialog/DialogContent.astro +42 -0
- package/src/components/dialog/DialogDescription.astro +18 -0
- package/src/components/dialog/DialogFooter.astro +18 -0
- package/src/components/dialog/DialogHeader.astro +18 -0
- package/src/components/dialog/DialogOverlay.astro +19 -0
- package/src/components/dialog/DialogTitle.astro +18 -0
- package/src/components/dialog/DialogTrigger.astro +37 -0
- package/src/components/dialog/index.ts +9 -0
- package/src/components/dropdown-menu/CHANGELOG.md +194 -0
- package/src/components/dropdown-menu/DropdownMenu.astro +226 -0
- package/src/components/dropdown-menu/DropdownMenuCheckboxItem.astro +114 -0
- package/src/components/dropdown-menu/DropdownMenuContent.astro +42 -0
- package/src/components/dropdown-menu/DropdownMenuGroup.astro +19 -0
- package/src/components/dropdown-menu/DropdownMenuItem.astro +220 -0
- package/src/components/dropdown-menu/DropdownMenuItemContent.astro +79 -0
- package/src/components/dropdown-menu/DropdownMenuLabel.astro +20 -0
- package/src/components/dropdown-menu/DropdownMenuPortal.astro +13 -0
- package/src/components/dropdown-menu/DropdownMenuRadioGroup.astro +13 -0
- package/src/components/dropdown-menu/DropdownMenuRadioItem.astro +101 -0
- package/src/components/dropdown-menu/DropdownMenuSeparator.astro +18 -0
- package/src/components/dropdown-menu/DropdownMenuShortcut.astro +18 -0
- package/src/components/dropdown-menu/DropdownMenuTrigger.astro +49 -0
- package/src/components/dropdown-menu/dropdown-menu-item-variants.ts +24 -0
- package/src/components/dropdown-menu/index.ts +12 -0
- package/src/components/field/CHANGELOG.md +33 -0
- package/src/components/field/Field.astro +664 -0
- package/src/components/field/FieldContent.astro +20 -0
- package/src/components/field/FieldDescription.astro +22 -0
- package/src/components/field/FieldError.astro +51 -0
- package/src/components/field/FieldGroup.astro +20 -0
- package/src/components/field/FieldLabel.astro +22 -0
- package/src/components/field/FieldLegend.astro +23 -0
- package/src/components/field/FieldSeparator.astro +30 -0
- package/src/components/field/FieldSet.astro +20 -0
- package/src/components/field/FieldTitle.astro +20 -0
- package/src/components/field/index.ts +10 -0
- package/src/components/hover-card/CHANGELOG.md +20 -0
- package/src/components/hover-card/HoverCard.astro +235 -0
- package/src/components/hover-card/HoverCardContent.astro +54 -0
- package/src/components/hover-card/HoverCardTrigger.astro +38 -0
- package/src/components/hover-card/index.ts +3 -0
- package/src/components/input/CHANGELOG.md +29 -0
- package/src/components/input/Input.astro +130 -0
- package/src/components/input/index.ts +2 -0
- package/src/components/input-group/CHANGELOG.md +49 -0
- package/src/components/input-group/InputGroup.astro +135 -0
- package/src/components/input-group/InputGroupAddon.astro +49 -0
- package/src/components/input-group/InputGroupButton.astro +58 -0
- package/src/components/input-group/InputGroupInput.astro +18 -0
- package/src/components/input-group/InputGroupText.astro +21 -0
- package/src/components/input-group/InputGroupTextarea.astro +17 -0
- package/src/components/input-group/controlClasses.ts +2 -0
- package/src/components/input-group/index.ts +6 -0
- package/src/components/item/CHANGELOG.md +27 -0
- package/src/components/item/Item.astro +122 -0
- package/src/components/item/ItemActions.astro +21 -0
- package/src/components/item/ItemContent.astro +25 -0
- package/src/components/item/ItemDescription.astro +25 -0
- package/src/components/item/ItemFooter.astro +24 -0
- package/src/components/item/ItemGroup.astro +24 -0
- package/src/components/item/ItemHeader.astro +24 -0
- package/src/components/item/ItemMedia.astro +47 -0
- package/src/components/item/ItemSeparator.astro +21 -0
- package/src/components/item/ItemTitle.astro +25 -0
- package/src/components/item/index.ts +10 -0
- package/src/components/kbd/CHANGELOG.md +5 -0
- package/src/components/kbd/Kbd.astro +145 -0
- package/src/components/kbd/KbdGroup.astro +55 -0
- package/src/components/kbd/index.ts +2 -0
- package/src/components/label/CHANGELOG.md +28 -0
- package/src/components/label/Label.astro +97 -0
- package/src/components/label/index.ts +2 -0
- package/src/components/link-group/CHANGELOG.md +75 -0
- package/src/components/link-group/LinkGroup.astro +67 -0
- package/src/components/link-group/LinkGroupItem.astro +32 -0
- package/src/components/link-group/LinkGroupList.astro +25 -0
- package/src/components/link-group/LinkGroupTitle.astro +22 -0
- package/src/components/link-group/index.ts +5 -0
- package/src/components/link-group/link-group-list-variants.ts +15 -0
- package/src/components/marquee/CHANGELOG.md +5 -0
- package/src/components/marquee/Marquee.astro +119 -0
- package/src/components/marquee/index.ts +2 -0
- package/src/components/native-select/CHANGELOG.md +5 -0
- package/src/components/native-select/NativeSelect.astro +125 -0
- package/src/components/native-select/NativeSelectOptGroup.astro +14 -0
- package/src/components/native-select/NativeSelectOption.astro +9 -0
- package/src/components/native-select/index.ts +3 -0
- package/src/components/navigation-menu/CHANGELOG.md +63 -0
- package/src/components/navigation-menu/NavigationMenu.astro +414 -0
- package/src/components/navigation-menu/NavigationMenuContent.astro +37 -0
- package/src/components/navigation-menu/NavigationMenuIndicator.astro +24 -0
- package/src/components/navigation-menu/NavigationMenuItem.astro +22 -0
- package/src/components/navigation-menu/NavigationMenuLink.astro +18 -0
- package/src/components/navigation-menu/NavigationMenuList.astro +21 -0
- package/src/components/navigation-menu/NavigationMenuPositioner.astro +44 -0
- package/src/components/navigation-menu/NavigationMenuTrigger.astro +30 -0
- package/src/components/navigation-menu/NavigationMenuViewport.astro +19 -0
- package/src/components/navigation-menu/index.ts +10 -0
- package/src/components/popover/CHANGELOG.md +5 -0
- package/src/components/popover/Popover.astro +210 -0
- package/src/components/popover/PopoverClose.astro +18 -0
- package/src/components/popover/PopoverContent.astro +49 -0
- package/src/components/popover/PopoverDescription.astro +18 -0
- package/src/components/popover/PopoverHeader.astro +18 -0
- package/src/components/popover/PopoverTitle.astro +18 -0
- package/src/components/popover/PopoverTrigger.astro +29 -0
- package/src/components/popover/index.ts +7 -0
- package/src/components/radio-group/CHANGELOG.md +9 -0
- package/src/components/radio-group/RadioGroup.astro +81 -0
- package/src/components/radio-group/RadioGroupItem.astro +42 -0
- package/src/components/radio-group/index.ts +3 -0
- package/src/components/select/CHANGELOG.md +39 -0
- package/src/components/select/Select.astro +373 -0
- package/src/components/select/SelectContent.astro +91 -0
- package/src/components/select/SelectGroup.astro +19 -0
- package/src/components/select/SelectItem.astro +48 -0
- package/src/components/select/SelectLabel.astro +18 -0
- package/src/components/select/SelectSeparator.astro +17 -0
- package/src/components/select/SelectTrigger.astro +34 -0
- package/src/components/select/SelectValue.astro +22 -0
- package/src/components/select/index.ts +8 -0
- package/src/components/separator/CHANGELOG.md +5 -0
- package/src/components/separator/Separator.astro +60 -0
- package/src/components/separator/index.ts +2 -0
- package/src/components/skeleton/CHANGELOG.md +5 -0
- package/src/components/skeleton/Skeleton.astro +121 -0
- package/src/components/skeleton/index.ts +1 -0
- package/src/components/slider/CHANGELOG.md +5 -0
- package/src/components/slider/Slider.astro +198 -0
- package/src/components/slider/index.ts +1 -0
- package/src/components/spinner/CHANGELOG.md +5 -0
- package/src/components/spinner/Spinner.astro +134 -0
- package/src/components/spinner/index.ts +1 -0
- package/src/components/sticky-surface/CHANGELOG.md +5 -0
- package/src/components/sticky-surface/StickySurface.astro +152 -0
- package/src/components/sticky-surface/index.ts +2 -0
- package/src/components/switch/CHANGELOG.md +9 -0
- package/src/components/switch/Switch.astro +106 -0
- package/src/components/switch/index.ts +1 -0
- package/src/components/table/CHANGELOG.md +5 -0
- package/src/components/table/Table.astro +250 -0
- package/src/components/table/TableBody.astro +18 -0
- package/src/components/table/TableCaption.astro +17 -0
- package/src/components/table/TableCell.astro +21 -0
- package/src/components/table/TableFooter.astro +21 -0
- package/src/components/table/TableHead.astro +21 -0
- package/src/components/table/TableHeader.astro +17 -0
- package/src/components/table/TableRow.astro +21 -0
- package/src/components/table/index.ts +9 -0
- package/src/components/tabs/CHANGELOG.md +5 -0
- package/src/components/tabs/Tabs.astro +306 -0
- package/src/components/tabs/TabsContent.astro +47 -0
- package/src/components/tabs/TabsList.astro +69 -0
- package/src/components/tabs/TabsTrigger.astro +40 -0
- package/src/components/tabs/index.ts +6 -0
- package/src/components/textarea/CHANGELOG.md +5 -0
- package/src/components/textarea/Textarea.astro +36 -0
- package/src/components/textarea/index.ts +2 -0
- package/src/components/toggle/CHANGELOG.md +5 -0
- package/src/components/toggle/Toggle.astro +138 -0
- package/src/components/toggle/index.ts +1 -0
- package/src/components/toggle-group/CHANGELOG.md +5 -0
- package/src/components/toggle-group/ToggleGroup.astro +224 -0
- package/src/components/toggle-group/ToggleGroupItem.astro +48 -0
- package/src/components/toggle-group/index.ts +2 -0
- package/src/components/tooltip/CHANGELOG.md +5 -0
- package/src/components/tooltip/Tooltip.astro +331 -0
- package/src/components/tooltip/TooltipContent.astro +60 -0
- package/src/components/tooltip/TooltipTrigger.astro +34 -0
- package/src/components/tooltip/index.ts +3 -0
- package/src/lib/toggle-group-controller.ts +113 -0
- package/src/lib/toggle-shared.ts +26 -0
- package/src/lib/utils.ts +6 -0
- package/src/styles/globals.css +177 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as Table } from "./Table.astro";
|
|
2
|
+
export { default as TableHeader } from "./TableHeader.astro";
|
|
3
|
+
export { default as TableBody } from "./TableBody.astro";
|
|
4
|
+
export { default as TableFooter } from "./TableFooter.astro";
|
|
5
|
+
export { default as TableHead } from "./TableHead.astro";
|
|
6
|
+
export { default as TableRow } from "./TableRow.astro";
|
|
7
|
+
export { default as TableCell } from "./TableCell.astro";
|
|
8
|
+
export { default as TableCaption } from "./TableCaption.astro";
|
|
9
|
+
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* @component Tabs
|
|
4
|
+
* @title Tabs
|
|
5
|
+
* @description Organize content into tabbed panels, rendering one panel at a time.
|
|
6
|
+
* @figmaUrl https://www.figma.com/design/koxai7zw5vIuBzuVxe5T2l/bejamas-ui?node-id=2523-6067&t=YFStJ3V8fXEO8QD8-4
|
|
7
|
+
*
|
|
8
|
+
* @preview
|
|
9
|
+
*
|
|
10
|
+
* <Tabs defaultValue="overview" class="w-full max-w-[400px]">
|
|
11
|
+
* <TabsList>
|
|
12
|
+
* <TabsTrigger value="overview">Overview</TabsTrigger>
|
|
13
|
+
* <TabsTrigger value="analytics">Analytics</TabsTrigger>
|
|
14
|
+
* <TabsTrigger value="reports">Reports</TabsTrigger>
|
|
15
|
+
* <TabsTrigger value="settings">Settings</TabsTrigger>
|
|
16
|
+
* </TabsList>
|
|
17
|
+
* <TabsContent value="overview">
|
|
18
|
+
* <Card>
|
|
19
|
+
* <CardHeader>
|
|
20
|
+
* <CardTitle>Overview</CardTitle>
|
|
21
|
+
* <CardDescription>
|
|
22
|
+
* View key metrics and recent activity across active projects.
|
|
23
|
+
* </CardDescription>
|
|
24
|
+
* </CardHeader>
|
|
25
|
+
* <CardContent class="text-sm text-muted-foreground">
|
|
26
|
+
* You have 12 active projects and 3 pending tasks.
|
|
27
|
+
* </CardContent>
|
|
28
|
+
* </Card>
|
|
29
|
+
* </TabsContent>
|
|
30
|
+
* <TabsContent value="analytics">
|
|
31
|
+
* <Card>
|
|
32
|
+
* <CardHeader>
|
|
33
|
+
* <CardTitle>Analytics</CardTitle>
|
|
34
|
+
* <CardDescription>
|
|
35
|
+
* Track engagement trends and performance over time.
|
|
36
|
+
* </CardDescription>
|
|
37
|
+
* </CardHeader>
|
|
38
|
+
* <CardContent class="text-sm text-muted-foreground">
|
|
39
|
+
* Page views are up 25% compared to last month.
|
|
40
|
+
* </CardContent>
|
|
41
|
+
* </Card>
|
|
42
|
+
* </TabsContent>
|
|
43
|
+
* <TabsContent value="reports">
|
|
44
|
+
* <Card>
|
|
45
|
+
* <CardHeader>
|
|
46
|
+
* <CardTitle>Reports</CardTitle>
|
|
47
|
+
* <CardDescription>
|
|
48
|
+
* Generate detailed exports for sharing and analysis.
|
|
49
|
+
* </CardDescription>
|
|
50
|
+
* </CardHeader>
|
|
51
|
+
* <CardContent class="text-sm text-muted-foreground">
|
|
52
|
+
* You have 5 reports ready to export.
|
|
53
|
+
* </CardContent>
|
|
54
|
+
* </Card>
|
|
55
|
+
* </TabsContent>
|
|
56
|
+
* <TabsContent value="settings">
|
|
57
|
+
* <Card>
|
|
58
|
+
* <CardHeader>
|
|
59
|
+
* <CardTitle>Settings</CardTitle>
|
|
60
|
+
* <CardDescription>
|
|
61
|
+
* Manage account preferences and personalization options.
|
|
62
|
+
* </CardDescription>
|
|
63
|
+
* </CardHeader>
|
|
64
|
+
* <CardContent class="text-sm text-muted-foreground">
|
|
65
|
+
* Configure notifications, security, and themes.
|
|
66
|
+
* </CardContent>
|
|
67
|
+
* </Card>
|
|
68
|
+
* </TabsContent>
|
|
69
|
+
* </Tabs>
|
|
70
|
+
*
|
|
71
|
+
* @usage
|
|
72
|
+
*
|
|
73
|
+
* ```astro nocollapse
|
|
74
|
+
* ---
|
|
75
|
+
* import { Tabs, TabsList, TabsTrigger, TabsContent } from '@bejamas/ui/components/tabs';
|
|
76
|
+
* ---
|
|
77
|
+
*
|
|
78
|
+
* <Tabs defaultValue="overview">
|
|
79
|
+
* <TabsList>
|
|
80
|
+
* <TabsTrigger value="overview">Overview</TabsTrigger>
|
|
81
|
+
* <TabsTrigger value="analytics">Analytics</TabsTrigger>
|
|
82
|
+
* </TabsList>
|
|
83
|
+
* <TabsContent value="overview">Overview content...</TabsContent>
|
|
84
|
+
* <TabsContent value="analytics">Analytics content...</TabsContent>
|
|
85
|
+
* </Tabs>
|
|
86
|
+
*
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @examples
|
|
90
|
+
*
|
|
91
|
+
* ### Line Animated
|
|
92
|
+
*
|
|
93
|
+
* <Tabs defaultValue="overview">
|
|
94
|
+
* <TabsList variant="line-animated" class="mb-4">
|
|
95
|
+
* <TabsTrigger value="overview">Overview</TabsTrigger>
|
|
96
|
+
* <TabsTrigger value="analytics">Analytics</TabsTrigger>
|
|
97
|
+
* <TabsTrigger value="reports">Reports</TabsTrigger>
|
|
98
|
+
* </TabsList>
|
|
99
|
+
* <TabsContent value="overview">Line variant content.</TabsContent>
|
|
100
|
+
* <TabsContent value="analytics">Analytics content.</TabsContent>
|
|
101
|
+
* <TabsContent value="reports">Reports content.</TabsContent>
|
|
102
|
+
* </Tabs>
|
|
103
|
+
*
|
|
104
|
+
* ### Vertical
|
|
105
|
+
*
|
|
106
|
+
* <Tabs defaultValue="profile" orientation="vertical" class="w-full max-w-xl">
|
|
107
|
+
* <TabsList class="min-w-40">
|
|
108
|
+
* <TabsTrigger value="profile" class="justify-start px-3">Profile</TabsTrigger>
|
|
109
|
+
* <TabsTrigger value="billing" class="justify-start px-3">Billing</TabsTrigger>
|
|
110
|
+
* <TabsTrigger value="notifications" class="justify-start px-3">Notifications</TabsTrigger>
|
|
111
|
+
* </TabsList>
|
|
112
|
+
* <TabsContent value="profile" class="rounded-lg border p-4">
|
|
113
|
+
* Profile settings content.
|
|
114
|
+
* </TabsContent>
|
|
115
|
+
* <TabsContent value="billing" class="rounded-lg border p-4">
|
|
116
|
+
* Billing settings content.
|
|
117
|
+
* </TabsContent>
|
|
118
|
+
* <TabsContent value="notifications" class="rounded-lg border p-4">
|
|
119
|
+
* Notifications settings content.
|
|
120
|
+
* </TabsContent>
|
|
121
|
+
* </Tabs>
|
|
122
|
+
*
|
|
123
|
+
* ### Disabled
|
|
124
|
+
*
|
|
125
|
+
* <Tabs defaultValue="active">
|
|
126
|
+
* <TabsList>
|
|
127
|
+
* <TabsTrigger value="active">Active</TabsTrigger>
|
|
128
|
+
* <TabsTrigger value="disabled" disabled>Disabled</TabsTrigger>
|
|
129
|
+
* <TabsTrigger value="secondary">Secondary</TabsTrigger>
|
|
130
|
+
* </TabsList>
|
|
131
|
+
* <TabsContent value="active">Active tab content.</TabsContent>
|
|
132
|
+
* <TabsContent value="disabled">Disabled tab content.</TabsContent>
|
|
133
|
+
* <TabsContent value="secondary">Secondary tab content.</TabsContent>
|
|
134
|
+
* </Tabs>
|
|
135
|
+
*
|
|
136
|
+
* ### Overflow
|
|
137
|
+
*
|
|
138
|
+
* <Tabs defaultValue="monday">
|
|
139
|
+
* <TabsList class="w-full max-w-[20rem] justify-start overflow-x-auto whitespace-nowrap">
|
|
140
|
+
* <TabsTrigger value="monday" class="shrink-0">Monday</TabsTrigger>
|
|
141
|
+
* <TabsTrigger value="tuesday" class="shrink-0">Tuesday</TabsTrigger>
|
|
142
|
+
* <TabsTrigger value="wednesday" class="shrink-0">Wednesday</TabsTrigger>
|
|
143
|
+
* <TabsTrigger value="thursday" class="shrink-0">Thursday</TabsTrigger>
|
|
144
|
+
* <TabsTrigger value="friday" class="shrink-0">Friday</TabsTrigger>
|
|
145
|
+
* <TabsTrigger value="saturday" class="shrink-0">Saturday</TabsTrigger>
|
|
146
|
+
* <TabsTrigger value="sunday" class="shrink-0">Sunday</TabsTrigger>
|
|
147
|
+
* </TabsList>
|
|
148
|
+
* <TabsContent value="monday">Monday content.</TabsContent>
|
|
149
|
+
* <TabsContent value="tuesday">Tuesday content.</TabsContent>
|
|
150
|
+
* <TabsContent value="wednesday">Wednesday content.</TabsContent>
|
|
151
|
+
* <TabsContent value="thursday">Thursday content.</TabsContent>
|
|
152
|
+
* <TabsContent value="friday">Friday content.</TabsContent>
|
|
153
|
+
* <TabsContent value="saturday">Saturday content.</TabsContent>
|
|
154
|
+
* <TabsContent value="sunday">Sunday content.</TabsContent>
|
|
155
|
+
* </Tabs>
|
|
156
|
+
*
|
|
157
|
+
* ### Direction Animation
|
|
158
|
+
*
|
|
159
|
+
* <Tabs defaultValue="overview">
|
|
160
|
+
* <TabsList>
|
|
161
|
+
* <TabsTrigger value="overview">Overview</TabsTrigger>
|
|
162
|
+
* <TabsTrigger value="analytics">Analytics</TabsTrigger>
|
|
163
|
+
* <TabsTrigger value="reports">Reports</TabsTrigger>
|
|
164
|
+
* </TabsList>
|
|
165
|
+
* <TabsContent value="overview" animation="direction">Direction-aware overview.</TabsContent>
|
|
166
|
+
* <TabsContent value="analytics" animation="direction">Direction-aware analytics.</TabsContent>
|
|
167
|
+
* <TabsContent value="reports" animation="direction">Direction-aware reports.</TabsContent>
|
|
168
|
+
* </Tabs>
|
|
169
|
+
*
|
|
170
|
+
* ### Sizes
|
|
171
|
+
*
|
|
172
|
+
* <div class="space-y-4">
|
|
173
|
+
* <Tabs defaultValue="sm-account">
|
|
174
|
+
* <TabsList size="sm">
|
|
175
|
+
* <TabsTrigger value="sm-account" class="text-xs px-2">Account</TabsTrigger>
|
|
176
|
+
* <TabsTrigger value="sm-password" class="text-xs px-2">Password</TabsTrigger>
|
|
177
|
+
* </TabsList>
|
|
178
|
+
* </Tabs>
|
|
179
|
+
*
|
|
180
|
+
* <Tabs defaultValue="md-account">
|
|
181
|
+
* <TabsList size="default">
|
|
182
|
+
* <TabsTrigger value="md-account">Account</TabsTrigger>
|
|
183
|
+
* <TabsTrigger value="md-password">Password</TabsTrigger>
|
|
184
|
+
* </TabsList>
|
|
185
|
+
* </Tabs>
|
|
186
|
+
*
|
|
187
|
+
* <Tabs defaultValue="lg-account">
|
|
188
|
+
* <TabsList size="lg">
|
|
189
|
+
* <TabsTrigger value="lg-account" class="text-base px-4">Account</TabsTrigger>
|
|
190
|
+
* <TabsTrigger value="lg-password" class="text-base px-4">Password</TabsTrigger>
|
|
191
|
+
* </TabsList>
|
|
192
|
+
* </Tabs>
|
|
193
|
+
* </div>
|
|
194
|
+
*
|
|
195
|
+
* @api
|
|
196
|
+
*
|
|
197
|
+
* ### Events
|
|
198
|
+
*
|
|
199
|
+
* The tabs component emits custom events that you can listen to:
|
|
200
|
+
*
|
|
201
|
+
* | Event | Detail | Description |
|
|
202
|
+
* |-------|--------|-------------|
|
|
203
|
+
* | `tabs:change` | `{ value: string }` | Fired when the selected tab changes |
|
|
204
|
+
*
|
|
205
|
+
* ```astro nocollapse console
|
|
206
|
+
* <Tabs id="my-tabs" defaultValue="tab1">
|
|
207
|
+
* <TabsList>
|
|
208
|
+
* <TabsTrigger value="tab1">Tab 1</TabsTrigger>
|
|
209
|
+
* <TabsTrigger value="tab2">Tab 2</TabsTrigger>
|
|
210
|
+
* </TabsList>
|
|
211
|
+
* <TabsContent value="tab1">Content 1</TabsContent>
|
|
212
|
+
* <TabsContent value="tab2">Content 2</TabsContent>
|
|
213
|
+
* </Tabs>
|
|
214
|
+
* ```
|
|
215
|
+
*
|
|
216
|
+
* ```js nocollapse
|
|
217
|
+
* const tabs = document.getElementById('my-tabs');
|
|
218
|
+
*
|
|
219
|
+
* tabs.addEventListener('tabs:change', (e) => {
|
|
220
|
+
* console.log('Selected tab:', e.detail.value);
|
|
221
|
+
* });
|
|
222
|
+
* ```
|
|
223
|
+
*
|
|
224
|
+
* ### Programmatic Control
|
|
225
|
+
*
|
|
226
|
+
* You can control the tabs programmatically by dispatching a `tabs:set` event:
|
|
227
|
+
*
|
|
228
|
+
* ```js nocollapse
|
|
229
|
+
* const tabs = document.getElementById('my-tabs');
|
|
230
|
+
*
|
|
231
|
+
* // Select a tab
|
|
232
|
+
* tabs.dispatchEvent(new CustomEvent('tabs:set', {
|
|
233
|
+
* detail: { value: 'tab2' }
|
|
234
|
+
* }));
|
|
235
|
+
* ```
|
|
236
|
+
*
|
|
237
|
+
* ### Variants
|
|
238
|
+
*
|
|
239
|
+
* | Prop | Element | Values | Default |
|
|
240
|
+
* |------|---------|--------|---------|
|
|
241
|
+
* | `variant` | tabs-list | `indicator`, `default`, `line`, `line-animated` | `indicator` |
|
|
242
|
+
* | `size` | tabs-list | `sm`, `default`, `lg` | `default` |
|
|
243
|
+
* | `animation` | tabs-content | `none`, `fade`, `slide`, `direction` | `none` |
|
|
244
|
+
*
|
|
245
|
+
* ### Data Attributes
|
|
246
|
+
*
|
|
247
|
+
* The tabs component sets these data attributes that you can use for styling or querying state:
|
|
248
|
+
*
|
|
249
|
+
* | Attribute | Element | Description |
|
|
250
|
+
* |-----------|---------|-------------|
|
|
251
|
+
* | `data-orientation` | tabs | Current orientation (`horizontal` or `vertical`) |
|
|
252
|
+
* | `data-variant` | tabs-list | Current list variant (`indicator`, `default`, `line`, or `line-animated`) |
|
|
253
|
+
* | `data-activation-direction` | tabs-content | Last activation direction after tab change (`left`, `right`, `up`, or `down`, not set on initial mount) |
|
|
254
|
+
* | `data-state` | tabs-trigger | Current state (`active` or `inactive`) |
|
|
255
|
+
*
|
|
256
|
+
* ### CSS Variables
|
|
257
|
+
*
|
|
258
|
+
* The tabs indicator exposes CSS variables for animation:
|
|
259
|
+
*
|
|
260
|
+
* | Variable | Element | Description |
|
|
261
|
+
* |----------|---------|-------------|
|
|
262
|
+
* | `--active-tab-left` | tabs-indicator | Left position of active tab |
|
|
263
|
+
* | `--active-tab-width` | tabs-indicator | Width of active tab |
|
|
264
|
+
* | `--active-tab-top` | tabs-indicator | Top position of active tab |
|
|
265
|
+
* | `--active-tab-height` | tabs-indicator | Height of active tab |
|
|
266
|
+
*/
|
|
267
|
+
|
|
268
|
+
import type { HTMLAttributes } from "astro/types";
|
|
269
|
+
import { cn } from "@cl-light-ds/ui/lib/utils";
|
|
270
|
+
|
|
271
|
+
interface Props extends HTMLAttributes<"div"> {
|
|
272
|
+
class?: string;
|
|
273
|
+
orientation?: "horizontal" | "vertical";
|
|
274
|
+
defaultValue?: string;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const {
|
|
278
|
+
class: className = "",
|
|
279
|
+
orientation = "horizontal",
|
|
280
|
+
defaultValue,
|
|
281
|
+
...rest
|
|
282
|
+
} = Astro.props as Props;
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
<div
|
|
286
|
+
{...rest}
|
|
287
|
+
data-slot="tabs"
|
|
288
|
+
data-orientation={orientation}
|
|
289
|
+
data-default-value={defaultValue}
|
|
290
|
+
data-horizontal={orientation === "horizontal" ? "true" : undefined}
|
|
291
|
+
data-vertical={orientation === "vertical" ? "true" : undefined}
|
|
292
|
+
class={cn(
|
|
293
|
+
"gap-2",
|
|
294
|
+
"group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",
|
|
295
|
+
className,
|
|
296
|
+
)}
|
|
297
|
+
>
|
|
298
|
+
<slot />
|
|
299
|
+
</div>
|
|
300
|
+
|
|
301
|
+
<script>
|
|
302
|
+
import { createTabs } from "@data-slot/tabs";
|
|
303
|
+
document
|
|
304
|
+
.querySelectorAll('[data-slot="tabs"]')
|
|
305
|
+
.forEach((el) => createTabs(el));
|
|
306
|
+
</script>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { cn } from "@cl-light-ds/ui/lib/utils";
|
|
4
|
+
import type { HTMLAttributes } from "astro/types";
|
|
5
|
+
|
|
6
|
+
export const tabsContentVariants = cva(
|
|
7
|
+
"flex-1 outline-none hidden data-[state=active]:block",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
animation: {
|
|
11
|
+
none: "",
|
|
12
|
+
fade: "data-[state=active]:animate-in data-[state=active]:fade-in-0 data-[state=active]:duration-200",
|
|
13
|
+
slide:
|
|
14
|
+
"data-[state=active]:animate-in data-[state=active]:fade-in-0 data-[state=active]:slide-in-from-bottom-2 data-[state=active]:duration-200",
|
|
15
|
+
direction:
|
|
16
|
+
"data-[state=active]:animate-in data-[state=active]:duration-200 data-[activation-direction=left]:slide-in-from-left-2 data-[activation-direction=right]:slide-in-from-right-2 data-[activation-direction=up]:slide-in-from-top-2 data-[activation-direction=down]:slide-in-from-bottom-2 data-[activation-direction=left]:fade-in-0 data-[activation-direction=right]:fade-in-0 data-[activation-direction=up]:fade-in-0 data-[activation-direction=down]:fade-in-0",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {
|
|
20
|
+
animation: "none",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
interface Props extends VariantProps<typeof tabsContentVariants>, HTMLAttributes<"div"> {
|
|
26
|
+
value: string;
|
|
27
|
+
class?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const {
|
|
31
|
+
value,
|
|
32
|
+
animation = "none",
|
|
33
|
+
class: className = "",
|
|
34
|
+
...rest
|
|
35
|
+
} = Astro.props as Props;
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
<div
|
|
39
|
+
{...rest}
|
|
40
|
+
role="tabpanel"
|
|
41
|
+
data-slot="tabs-content"
|
|
42
|
+
data-value={value}
|
|
43
|
+
tabindex="0"
|
|
44
|
+
class={cn("text-sm", tabsContentVariants({ animation }), className)}
|
|
45
|
+
>
|
|
46
|
+
<slot />
|
|
47
|
+
</div>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { cn } from "@cl-light-ds/ui/lib/utils";
|
|
4
|
+
import type { HTMLAttributes } from "astro/types";
|
|
5
|
+
|
|
6
|
+
export const tabsListVariants = cva(
|
|
7
|
+
"group/tabs-list text-muted-foreground relative inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
indicator: "rounded-lg bg-muted p-[2px] [--tabs-indicator-radius:calc(var(--radius)_-_2px)]",
|
|
12
|
+
default: "rounded-lg bg-muted p-[3px]",
|
|
13
|
+
line: "rounded-none gap-1 bg-transparent p-0",
|
|
14
|
+
"line-animated":
|
|
15
|
+
"rounded-none gap-1 bg-transparent p-0",
|
|
16
|
+
},
|
|
17
|
+
size: {
|
|
18
|
+
default: "group-data-horizontal/tabs:h-9",
|
|
19
|
+
sm: "group-data-horizontal/tabs:h-8",
|
|
20
|
+
lg: "group-data-horizontal/tabs:h-10",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: {
|
|
24
|
+
variant: "indicator",
|
|
25
|
+
size: "default",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
interface Props
|
|
31
|
+
extends VariantProps<typeof tabsListVariants>, HTMLAttributes<"div"> {
|
|
32
|
+
class?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const {
|
|
36
|
+
variant = "indicator",
|
|
37
|
+
size = "default",
|
|
38
|
+
class: className = "",
|
|
39
|
+
...rest
|
|
40
|
+
} = Astro.props as Props;
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
<div
|
|
44
|
+
{...rest}
|
|
45
|
+
role="tablist"
|
|
46
|
+
data-slot="tabs-list"
|
|
47
|
+
data-variant={variant}
|
|
48
|
+
class={cn("", tabsListVariants({ variant, size }), className)}
|
|
49
|
+
>
|
|
50
|
+
{
|
|
51
|
+
variant === "indicator" && (
|
|
52
|
+
<div
|
|
53
|
+
aria-hidden="true"
|
|
54
|
+
data-slot="tabs-indicator"
|
|
55
|
+
class="gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg:not([class*='size-'])]:size-4 pointer-events-none absolute top-(--active-tab-top) left-(--active-tab-left) z-0 h-(--active-tab-height) w-(--active-tab-width) bg-background shadow-sm transition-all duration-150 ease dark:border-input dark:bg-input/30"
|
|
56
|
+
/>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
{
|
|
60
|
+
variant === "line-animated" && (
|
|
61
|
+
<div
|
|
62
|
+
aria-hidden="true"
|
|
63
|
+
data-slot="tabs-indicator"
|
|
64
|
+
class="pointer-events-none absolute z-0 rounded-full bg-foreground transition-all duration-150 ease group-data-[orientation=horizontal]/tabs:left-[var(--active-tab-left)] group-data-[orientation=horizontal]/tabs:top-[calc(var(--active-tab-top)+var(--active-tab-height)-2px)] group-data-[orientation=horizontal]/tabs:h-0.5 group-data-[orientation=horizontal]/tabs:w-[var(--active-tab-width)] group-data-[orientation=vertical]/tabs:top-[var(--active-tab-top)] group-data-[orientation=vertical]/tabs:left-[calc(var(--active-tab-left)+var(--active-tab-width)-2px)] group-data-[orientation=vertical]/tabs:h-[var(--active-tab-height)] group-data-[orientation=vertical]/tabs:w-0.5"
|
|
65
|
+
/>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
<slot />
|
|
69
|
+
</div>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { cn } from "@cl-light-ds/ui/lib/utils";
|
|
3
|
+
import type { HTMLAttributes } from "astro/types";
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLAttributes<"button"> {
|
|
6
|
+
value: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
class?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const {
|
|
12
|
+
value,
|
|
13
|
+
disabled = false,
|
|
14
|
+
class: className = "",
|
|
15
|
+
...rest
|
|
16
|
+
} = Astro.props as Props;
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
<button
|
|
20
|
+
{...rest}
|
|
21
|
+
type="button"
|
|
22
|
+
disabled={disabled}
|
|
23
|
+
role="tab"
|
|
24
|
+
data-slot="tabs-trigger"
|
|
25
|
+
data-value={value}
|
|
26
|
+
class={cn(
|
|
27
|
+
"gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg:not([class*='size-'])]:size-4",
|
|
28
|
+
"relative z-10 inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center whitespace-nowrap outline-none transition-all disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start",
|
|
29
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 text-foreground/60 hover:text-foreground data-[state=active]:text-foreground focus-visible:ring-[3px] focus-visible:outline-1 focus-visible:outline-ring dark:text-muted-foreground dark:hover:text-foreground",
|
|
30
|
+
"group-data-[variant=default]/tabs-list:data-[state=active]:bg-background dark:group-data-[variant=default]/tabs-list:data-[state=active]:border-input dark:group-data-[variant=default]/tabs-list:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground",
|
|
31
|
+
"group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm",
|
|
32
|
+
"group-data-[variant=indicator]/tabs-list:data-[state=active]:bg-transparent group-data-[variant=indicator]/tabs-list:data-[state=active]:shadow-none",
|
|
33
|
+
"group-data-[variant=line]/tabs-list:rounded-none group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none",
|
|
34
|
+
"group-data-[variant=line-animated]/tabs-list:rounded-none group-data-[variant=line-animated]/tabs-list:bg-transparent group-data-[variant=line-animated]/tabs-list:data-[state=active]:bg-transparent group-data-[variant=line-animated]/tabs-list:data-[state=active]:shadow-none",
|
|
35
|
+
"after:pointer-events-none after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=default]/tabs-list:after:hidden group-data-[variant=indicator]/tabs-list:after:hidden group-data-[variant=line-animated]/tabs-list:after:hidden group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",
|
|
36
|
+
className,
|
|
37
|
+
)}
|
|
38
|
+
>
|
|
39
|
+
<slot />
|
|
40
|
+
</button>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Tabs } from "./Tabs.astro";
|
|
2
|
+
export { default as TabsList } from "./TabsList.astro";
|
|
3
|
+
export { default as TabsTrigger } from "./TabsTrigger.astro";
|
|
4
|
+
export { default as TabsContent } from "./TabsContent.astro";
|
|
5
|
+
export { tabsListVariants } from "./TabsList.astro";
|
|
6
|
+
export { tabsContentVariants } from "./TabsContent.astro";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* @component Textarea
|
|
4
|
+
* @title Textarea
|
|
5
|
+
* @description A multi-line input field for longer user content.
|
|
6
|
+
* @figmaUrl https://www.figma.com/design/koxai7zw5vIuBzuVxe5T2l/bejamas-ui?node-id=2508-2555&t=YFStJ3V8fXEO8QD8-4
|
|
7
|
+
* @status stable
|
|
8
|
+
* @since 0.1.0
|
|
9
|
+
*
|
|
10
|
+
* @preview
|
|
11
|
+
*
|
|
12
|
+
* <Textarea placeholder="Type your message here..." />
|
|
13
|
+
*
|
|
14
|
+
* @usage
|
|
15
|
+
*
|
|
16
|
+
* ```astro nocollapse
|
|
17
|
+
* ---
|
|
18
|
+
* import { Textarea } from '@bejamas/ui/components/textarea';
|
|
19
|
+
* ---
|
|
20
|
+
*
|
|
21
|
+
* <Textarea placeholder="Type your message here..." />
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const { class: className = "", ...props } = Astro.props;
|
|
26
|
+
|
|
27
|
+
const baseClass =
|
|
28
|
+
"flex field-sizing-content min-h-16 w-full outline-none disabled:cursor-not-allowed disabled:opacity-50";
|
|
29
|
+
|
|
30
|
+
import { cn } from "@cl-light-ds/ui/lib/utils";
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
<textarea
|
|
34
|
+
data-slot={props["data-slot"] ?? "textarea"}
|
|
35
|
+
class={cn("border-input dark:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 rounded-lg border bg-transparent px-2.5 py-2 text-base font-semibold shadow-xs transition-[color,box-shadow] focus-visible:ring-3 aria-invalid:ring-3 md:text-sm px-3", baseClass, className)}
|
|
36
|
+
{...props}></textarea>
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* @component Toggle
|
|
4
|
+
* @title Toggle
|
|
5
|
+
* @description A two-state button that can be either on or off.
|
|
6
|
+
*
|
|
7
|
+
* @preview
|
|
8
|
+
*
|
|
9
|
+
* <Toggle aria-label="Toggle bookmark" variant="outline">
|
|
10
|
+
* <BookmarkIcon class="group-aria-pressed/toggle:fill-foreground" />
|
|
11
|
+
* Bookmark
|
|
12
|
+
* </Toggle>
|
|
13
|
+
*
|
|
14
|
+
* @usage
|
|
15
|
+
*
|
|
16
|
+
* ```astro nocollapse
|
|
17
|
+
* ---
|
|
18
|
+
* import { Toggle } from '@bejamas/ui/components/toggle';
|
|
19
|
+
* import { BoldIcon } from '@lucide/astro';
|
|
20
|
+
* ---
|
|
21
|
+
*
|
|
22
|
+
* <Toggle aria-label="Toggle bold">
|
|
23
|
+
* <BoldIcon />
|
|
24
|
+
* </Toggle>
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @api
|
|
28
|
+
*
|
|
29
|
+
* ### Events
|
|
30
|
+
*
|
|
31
|
+
* | Event | Detail | Description |
|
|
32
|
+
* |-------|--------|-------------|
|
|
33
|
+
* | `toggle:change` | `{ pressed: boolean }` | Fired when the toggle state changes |
|
|
34
|
+
*
|
|
35
|
+
* ### Programmatic Control
|
|
36
|
+
*
|
|
37
|
+
* ```js nocollapse
|
|
38
|
+
* // Set toggle state programmatically
|
|
39
|
+
* element.dispatchEvent(new CustomEvent('toggle:set', { detail: { value: true } }));
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* ### Data Attributes
|
|
43
|
+
*
|
|
44
|
+
* | Attribute | Element | Description |
|
|
45
|
+
* |-----------|---------|-------------|
|
|
46
|
+
* | `data-state` | toggle | Current state: `on` or `off` |
|
|
47
|
+
* | `data-disabled` | toggle | Present when toggle is disabled |
|
|
48
|
+
*
|
|
49
|
+
* @examples
|
|
50
|
+
*
|
|
51
|
+
* ### Outline
|
|
52
|
+
*
|
|
53
|
+
* <div class="flex items-center gap-2">
|
|
54
|
+
* <Toggle variant="outline" aria-label="Toggle bold">
|
|
55
|
+
* <BoldIcon />
|
|
56
|
+
* Bold
|
|
57
|
+
* </Toggle>
|
|
58
|
+
* <Toggle variant="outline" aria-label="Toggle italic">
|
|
59
|
+
* <ItalicIcon />
|
|
60
|
+
* Italic
|
|
61
|
+
* </Toggle>
|
|
62
|
+
* </div>
|
|
63
|
+
*
|
|
64
|
+
* ### With Text
|
|
65
|
+
*
|
|
66
|
+
* <Toggle variant="outline" aria-label="Toggle italic">
|
|
67
|
+
* <ItalicIcon />
|
|
68
|
+
* Italic
|
|
69
|
+
* </Toggle>
|
|
70
|
+
*
|
|
71
|
+
* ### Sizes
|
|
72
|
+
*
|
|
73
|
+
* <div class="flex items-center gap-2">
|
|
74
|
+
* <Toggle size="sm" variant="outline" aria-label="Toggle small">
|
|
75
|
+
* Small
|
|
76
|
+
* </Toggle>
|
|
77
|
+
* <Toggle size="default" variant="outline" aria-label="Toggle default">
|
|
78
|
+
* Default
|
|
79
|
+
* </Toggle>
|
|
80
|
+
* <Toggle size="lg" variant="outline" aria-label="Toggle large">
|
|
81
|
+
* Large
|
|
82
|
+
* </Toggle>
|
|
83
|
+
* </div>
|
|
84
|
+
*
|
|
85
|
+
* ### Disabled
|
|
86
|
+
*
|
|
87
|
+
* <div class="flex items-center gap-2">
|
|
88
|
+
* <Toggle disabled aria-label="Toggle bold">
|
|
89
|
+
* Disabled
|
|
90
|
+
* </Toggle>
|
|
91
|
+
* <Toggle disabled variant="outline" aria-label="Toggle italic">
|
|
92
|
+
* Disabled
|
|
93
|
+
* </Toggle>
|
|
94
|
+
* </div>
|
|
95
|
+
*
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
import type { HTMLAttributes } from "astro/types";
|
|
99
|
+
import { cn } from "@cl-light-ds/ui/lib/utils";
|
|
100
|
+
import {
|
|
101
|
+
toggleVariants,
|
|
102
|
+
type ToggleVariantProps,
|
|
103
|
+
} from "@cl-light-ds/ui/lib/toggle-shared";
|
|
104
|
+
|
|
105
|
+
interface Props extends ToggleVariantProps, Omit<HTMLAttributes<"button">, "class"> {
|
|
106
|
+
defaultPressed?: boolean;
|
|
107
|
+
disabled?: boolean;
|
|
108
|
+
class?: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const {
|
|
112
|
+
variant = "default",
|
|
113
|
+
size = "default",
|
|
114
|
+
defaultPressed,
|
|
115
|
+
disabled,
|
|
116
|
+
class: className = "",
|
|
117
|
+
...rest
|
|
118
|
+
} = Astro.props as Props;
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
<button
|
|
122
|
+
type="button"
|
|
123
|
+
data-slot="toggle"
|
|
124
|
+
data-default-pressed={defaultPressed ? "" : undefined}
|
|
125
|
+
data-disabled={disabled ? "true" : undefined}
|
|
126
|
+
disabled={disabled}
|
|
127
|
+
class={cn(toggleVariants({ variant, size }), className)}
|
|
128
|
+
{...rest}
|
|
129
|
+
>
|
|
130
|
+
<slot />
|
|
131
|
+
</button>
|
|
132
|
+
|
|
133
|
+
<script>
|
|
134
|
+
import { createToggle } from "@data-slot/toggle";
|
|
135
|
+
document
|
|
136
|
+
.querySelectorAll<HTMLElement>('[data-slot="toggle"]')
|
|
137
|
+
.forEach((el) => createToggle(el));
|
|
138
|
+
</script>
|