@starwind-ui/core 1.15.1 → 1.15.2
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/dist/index.d.ts +28 -0
- package/dist/index.js +108 -0
- package/dist/index.js.map +1 -0
- package/dist/src/components/accordion/Accordion.astro +254 -0
- package/dist/src/components/accordion/AccordionContent.astro +33 -0
- package/dist/src/components/accordion/AccordionItem.astro +27 -0
- package/dist/src/components/accordion/AccordionTrigger.astro +32 -0
- package/dist/src/components/accordion/index.ts +15 -0
- package/dist/src/components/alert/Alert.astro +31 -0
- package/dist/src/components/alert/AlertDescription.astro +14 -0
- package/dist/src/components/alert/AlertTitle.astro +16 -0
- package/dist/src/components/alert/index.ts +13 -0
- package/dist/src/components/alert-dialog/AlertDialog.astro +275 -0
- package/dist/src/components/alert-dialog/AlertDialogAction.astro +44 -0
- package/dist/src/components/alert-dialog/AlertDialogCancel.astro +45 -0
- package/dist/src/components/alert-dialog/AlertDialogContent.astro +52 -0
- package/dist/src/components/alert-dialog/AlertDialogDescription.astro +18 -0
- package/dist/src/components/alert-dialog/AlertDialogFooter.astro +16 -0
- package/dist/src/components/alert-dialog/AlertDialogHeader.astro +14 -0
- package/dist/src/components/alert-dialog/AlertDialogTitle.astro +20 -0
- package/dist/src/components/alert-dialog/AlertDialogTrigger.astro +47 -0
- package/dist/src/components/alert-dialog/index.ts +46 -0
- package/dist/src/components/aspect-ratio/AspectRatio.astro +32 -0
- package/dist/src/components/aspect-ratio/index.ts +7 -0
- package/dist/src/components/avatar/Avatar.astro +29 -0
- package/dist/src/components/avatar/AvatarFallback.astro +18 -0
- package/dist/src/components/avatar/AvatarImage.astro +49 -0
- package/dist/src/components/avatar/index.ts +13 -0
- package/dist/src/components/badge/Badge.astro +55 -0
- package/dist/src/components/badge/index.ts +7 -0
- package/dist/src/components/breadcrumb/Breadcrumb.astro +11 -0
- package/dist/src/components/breadcrumb/BreadcrumbEllipsis.astro +28 -0
- package/dist/src/components/breadcrumb/BreadcrumbItem.astro +14 -0
- package/dist/src/components/breadcrumb/BreadcrumbLink.astro +22 -0
- package/dist/src/components/breadcrumb/BreadcrumbList.astro +16 -0
- package/dist/src/components/breadcrumb/BreadcrumbPage.astro +21 -0
- package/dist/src/components/breadcrumb/BreadcrumbSeparator.astro +23 -0
- package/dist/src/components/breadcrumb/index.ts +37 -0
- package/dist/src/components/button/Button.astro +55 -0
- package/dist/src/components/button/index.ts +7 -0
- package/dist/src/components/button-group/ButtonGroup.astro +62 -0
- package/dist/src/components/button-group/ButtonGroupSeparator.astro +27 -0
- package/dist/src/components/button-group/ButtonGroupText.astro +19 -0
- package/dist/src/components/button-group/index.ts +17 -0
- package/dist/src/components/card/Card.astro +14 -0
- package/dist/src/components/card/CardContent.astro +14 -0
- package/dist/src/components/card/CardDescription.astro +14 -0
- package/dist/src/components/card/CardFooter.astro +14 -0
- package/dist/src/components/card/CardHeader.astro +14 -0
- package/dist/src/components/card/CardTitle.astro +14 -0
- package/dist/src/components/card/index.ts +26 -0
- package/dist/src/components/carousel/Carousel.astro +55 -0
- package/dist/src/components/carousel/CarouselContent.astro +26 -0
- package/dist/src/components/carousel/CarouselItem.astro +26 -0
- package/dist/src/components/carousel/CarouselNext.astro +37 -0
- package/dist/src/components/carousel/CarouselPrevious.astro +37 -0
- package/dist/src/components/carousel/carousel-script.ts +191 -0
- package/dist/src/components/carousel/index.ts +32 -0
- package/dist/src/components/checkbox/Checkbox.astro +128 -0
- package/dist/src/components/checkbox/index.ts +7 -0
- package/dist/src/components/collapsible/Collapsible.astro +161 -0
- package/dist/src/components/collapsible/CollapsibleContent.astro +22 -0
- package/dist/src/components/collapsible/CollapsibleTrigger.astro +44 -0
- package/dist/src/components/collapsible/index.ts +13 -0
- package/dist/src/components/dialog/Dialog.astro +389 -0
- package/dist/src/components/dialog/DialogClose.astro +35 -0
- package/dist/src/components/dialog/DialogContent.astro +78 -0
- package/dist/src/components/dialog/DialogDescription.astro +14 -0
- package/dist/src/components/dialog/DialogFooter.astro +14 -0
- package/dist/src/components/dialog/DialogHeader.astro +14 -0
- package/dist/src/components/dialog/DialogTitle.astro +22 -0
- package/dist/src/components/dialog/DialogTrigger.astro +47 -0
- package/dist/src/components/dialog/index.ts +45 -0
- package/dist/src/components/dropdown/Dropdown.astro +377 -0
- package/dist/src/components/dropdown/DropdownContent.astro +81 -0
- package/dist/src/components/dropdown/DropdownItem.astro +48 -0
- package/dist/src/components/dropdown/DropdownLabel.astro +29 -0
- package/dist/src/components/dropdown/DropdownSeparator.astro +21 -0
- package/dist/src/components/dropdown/DropdownTrigger.astro +52 -0
- package/dist/src/components/dropdown/index.ts +33 -0
- package/dist/src/components/dropzone/Dropzone.astro +236 -0
- package/dist/src/components/dropzone/DropzoneFilesList.astro +26 -0
- package/dist/src/components/dropzone/DropzoneLoadingIndicator.astro +10 -0
- package/dist/src/components/dropzone/DropzoneUploadIndicator.astro +10 -0
- package/dist/src/components/dropzone/index.ts +24 -0
- package/dist/src/components/image/Image.astro +24 -0
- package/dist/src/components/image/index.ts +9 -0
- package/dist/src/components/input/Input.astro +25 -0
- package/dist/src/components/input/index.ts +7 -0
- package/dist/src/components/input-otp/InputOtp.astro +352 -0
- package/dist/src/components/input-otp/InputOtpGroup.astro +16 -0
- package/dist/src/components/input-otp/InputOtpSeparator.astro +25 -0
- package/dist/src/components/input-otp/InputOtpSlot.astro +48 -0
- package/dist/src/components/input-otp/InputOtpTypes.ts +6 -0
- package/dist/src/components/input-otp/index.ts +33 -0
- package/dist/src/components/item/Item.astro +52 -0
- package/dist/src/components/item/ItemActions.astro +16 -0
- package/dist/src/components/item/ItemContent.astro +16 -0
- package/dist/src/components/item/ItemDescription.astro +19 -0
- package/dist/src/components/item/ItemFooter.astro +16 -0
- package/dist/src/components/item/ItemGroup.astro +16 -0
- package/dist/src/components/item/ItemHeader.astro +16 -0
- package/dist/src/components/item/ItemMedia.astro +40 -0
- package/dist/src/components/item/ItemSeparator.astro +21 -0
- package/dist/src/components/item/ItemTitle.astro +16 -0
- package/dist/src/components/item/index.ts +50 -0
- package/dist/src/components/kbd/Kbd.astro +21 -0
- package/dist/src/components/kbd/KbdGroup.astro +16 -0
- package/dist/src/components/kbd/index.ts +11 -0
- package/dist/src/components/label/Label.astro +22 -0
- package/dist/src/components/label/index.ts +7 -0
- package/dist/src/components/pagination/Pagination.astro +20 -0
- package/dist/src/components/pagination/PaginationContent.astro +16 -0
- package/dist/src/components/pagination/PaginationEllipsis.astro +35 -0
- package/dist/src/components/pagination/PaginationItem.astro +16 -0
- package/dist/src/components/pagination/PaginationLink.astro +24 -0
- package/dist/src/components/pagination/PaginationNext.astro +30 -0
- package/dist/src/components/pagination/PaginationPrevious.astro +30 -0
- package/dist/src/components/pagination/index.ts +38 -0
- package/dist/src/components/progress/Progress.astro +155 -0
- package/dist/src/components/progress/index.ts +10 -0
- package/dist/src/components/prose/Prose.astro +617 -0
- package/dist/src/components/prose/index.ts +9 -0
- package/dist/src/components/radio-group/RadioGroup.astro +162 -0
- package/dist/src/components/radio-group/RadioGroupItem.astro +129 -0
- package/dist/src/components/radio-group/RadioGroupTypes.ts +6 -0
- package/dist/src/components/radio-group/index.ts +23 -0
- package/dist/src/components/select/Select.astro +752 -0
- package/dist/src/components/select/SelectContent.astro +94 -0
- package/dist/src/components/select/SelectGroup.astro +9 -0
- package/dist/src/components/select/SelectItem.astro +51 -0
- package/dist/src/components/select/SelectLabel.astro +14 -0
- package/dist/src/components/select/SelectSearch.astro +49 -0
- package/dist/src/components/select/SelectSeparator.astro +12 -0
- package/dist/src/components/select/SelectTrigger.astro +54 -0
- package/dist/src/components/select/SelectTypes.ts +13 -0
- package/dist/src/components/select/SelectValue.astro +19 -0
- package/dist/src/components/select/index.ts +49 -0
- package/dist/src/components/separator/Separator.astro +36 -0
- package/dist/src/components/separator/index.ts +7 -0
- package/dist/src/components/sheet/Sheet.astro +13 -0
- package/dist/src/components/sheet/SheetClose.astro +13 -0
- package/dist/src/components/sheet/SheetContent.astro +92 -0
- package/dist/src/components/sheet/SheetDescription.astro +16 -0
- package/dist/src/components/sheet/SheetFooter.astro +16 -0
- package/dist/src/components/sheet/SheetHeader.astro +16 -0
- package/dist/src/components/sheet/SheetTitle.astro +16 -0
- package/dist/src/components/sheet/SheetTrigger.astro +13 -0
- package/dist/src/components/sheet/index.ts +41 -0
- package/dist/src/components/sidebar/Sidebar.astro +213 -0
- package/dist/src/components/sidebar/SidebarContent.astro +24 -0
- package/dist/src/components/sidebar/SidebarFooter.astro +21 -0
- package/dist/src/components/sidebar/SidebarGroup.astro +21 -0
- package/dist/src/components/sidebar/SidebarGroupContent.astro +21 -0
- package/dist/src/components/sidebar/SidebarGroupLabel.astro +52 -0
- package/dist/src/components/sidebar/SidebarHeader.astro +21 -0
- package/dist/src/components/sidebar/SidebarInput.astro +22 -0
- package/dist/src/components/sidebar/SidebarInset.astro +21 -0
- package/dist/src/components/sidebar/SidebarMenu.astro +21 -0
- package/dist/src/components/sidebar/SidebarMenuAction.astro +59 -0
- package/dist/src/components/sidebar/SidebarMenuBadge.astro +30 -0
- package/dist/src/components/sidebar/SidebarMenuButton.astro +129 -0
- package/dist/src/components/sidebar/SidebarMenuItem.astro +21 -0
- package/dist/src/components/sidebar/SidebarMenuSkeleton.astro +40 -0
- package/dist/src/components/sidebar/SidebarMenuSub.astro +24 -0
- package/dist/src/components/sidebar/SidebarMenuSubButton.astro +49 -0
- package/dist/src/components/sidebar/SidebarMenuSubItem.astro +16 -0
- package/dist/src/components/sidebar/SidebarProvider.astro +213 -0
- package/dist/src/components/sidebar/SidebarRail.astro +71 -0
- package/dist/src/components/sidebar/SidebarSeparator.astro +22 -0
- package/dist/src/components/sidebar/SidebarTrigger.astro +66 -0
- package/dist/src/components/sidebar/index.ts +103 -0
- package/dist/src/components/skeleton/Skeleton.astro +14 -0
- package/dist/src/components/skeleton/index.ts +9 -0
- package/dist/src/components/slider/Slider.astro +411 -0
- package/dist/src/components/slider/index.ts +9 -0
- package/dist/src/components/spinner/Spinner.astro +21 -0
- package/dist/src/components/spinner/index.ts +7 -0
- package/dist/src/components/switch/Switch.astro +192 -0
- package/dist/src/components/switch/SwitchTypes.ts +6 -0
- package/dist/src/components/switch/index.ts +12 -0
- package/dist/src/components/table/Table.astro +18 -0
- package/dist/src/components/table/TableBody.astro +16 -0
- package/dist/src/components/table/TableCaption.astro +16 -0
- package/dist/src/components/table/TableCell.astro +16 -0
- package/dist/src/components/table/TableFoot.astro +16 -0
- package/dist/src/components/table/TableHead.astro +16 -0
- package/dist/src/components/table/TableHeader.astro +16 -0
- package/dist/src/components/table/TableRow.astro +16 -0
- package/dist/src/components/table/index.ts +42 -0
- package/dist/src/components/tabs/Tabs.astro +271 -0
- package/dist/src/components/tabs/TabsContent.astro +28 -0
- package/dist/src/components/tabs/TabsList.astro +22 -0
- package/dist/src/components/tabs/TabsTrigger.astro +34 -0
- package/dist/src/components/tabs/index.ts +20 -0
- package/dist/src/components/textarea/Textarea.astro +29 -0
- package/dist/src/components/textarea/index.ts +9 -0
- package/dist/src/components/theme-toggle/ThemeToggle.astro +208 -0
- package/dist/src/components/theme-toggle/index.ts +7 -0
- package/dist/src/components/toast/ToastDescription.astro +21 -0
- package/dist/src/components/toast/ToastItem.astro +54 -0
- package/dist/src/components/toast/ToastTemplate.astro +25 -0
- package/dist/src/components/toast/ToastTitle.astro +57 -0
- package/dist/src/components/toast/Toaster.astro +982 -0
- package/dist/src/components/toast/index.ts +29 -0
- package/dist/src/components/toast/toast-manager.ts +216 -0
- package/dist/src/components/toggle/Toggle.astro +174 -0
- package/dist/src/components/toggle/ToggleTypes.ts +14 -0
- package/dist/src/components/toggle/index.ts +8 -0
- package/dist/src/components/tooltip/Tooltip.astro +282 -0
- package/dist/src/components/tooltip/TooltipContent.astro +89 -0
- package/dist/src/components/tooltip/TooltipTrigger.astro +10 -0
- package/dist/src/components/tooltip/index.ts +16 -0
- package/dist/src/components/video/Video.astro +120 -0
- package/dist/src/components/video/index.ts +9 -0
- package/package.json +1 -1
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from "astro/types";
|
|
3
|
+
import { tv } from "tailwind-variants";
|
|
4
|
+
|
|
5
|
+
type Props = HTMLAttributes<"fieldset"> & {
|
|
6
|
+
/**
|
|
7
|
+
* Value for the radio group
|
|
8
|
+
*/
|
|
9
|
+
value?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Default value for the radio group
|
|
12
|
+
*/
|
|
13
|
+
defaultValue?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Legend for the radio group
|
|
16
|
+
*/
|
|
17
|
+
legend?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the radio group is disabled
|
|
20
|
+
*/
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Orientation of the radio group
|
|
24
|
+
*/
|
|
25
|
+
orientation?: "horizontal" | "vertical";
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const radioGroup = tv({
|
|
29
|
+
base: "starwind-radio-group disabled:cursor-not-allowed disabled:opacity-70",
|
|
30
|
+
variants: {
|
|
31
|
+
orientation: {
|
|
32
|
+
vertical: "grid gap-3",
|
|
33
|
+
horizontal: "flex flex-row items-center gap-3",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
defaultVariants: {
|
|
37
|
+
orientation: "vertical",
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const {
|
|
42
|
+
class: className,
|
|
43
|
+
value,
|
|
44
|
+
defaultValue,
|
|
45
|
+
legend,
|
|
46
|
+
disabled = false,
|
|
47
|
+
orientation = "vertical",
|
|
48
|
+
...rest
|
|
49
|
+
} = Astro.props;
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
<fieldset
|
|
53
|
+
class:list={[radioGroup({ orientation, class: className })]}
|
|
54
|
+
data-value={value || defaultValue}
|
|
55
|
+
disabled={disabled}
|
|
56
|
+
data-slot="radio-group"
|
|
57
|
+
{...rest}
|
|
58
|
+
>
|
|
59
|
+
{legend && <legend class="sr-only">{legend}</legend>}
|
|
60
|
+
<slot />
|
|
61
|
+
</fieldset>
|
|
62
|
+
|
|
63
|
+
<script>
|
|
64
|
+
import type { RadioGroupChangeEvent } from "./RadioGroupTypes";
|
|
65
|
+
|
|
66
|
+
class RadioGroupHandler {
|
|
67
|
+
private radioGroup: HTMLFieldSetElement;
|
|
68
|
+
private radioInputs: NodeListOf<HTMLInputElement> | undefined;
|
|
69
|
+
private radioGroupId: string | undefined;
|
|
70
|
+
|
|
71
|
+
constructor(radioGroup: HTMLFieldSetElement, idx: number) {
|
|
72
|
+
this.radioGroup = radioGroup;
|
|
73
|
+
this.radioGroupId = radioGroup.id || `starwind-radio-group-${idx}`;
|
|
74
|
+
this.radioInputs = radioGroup.querySelectorAll<HTMLInputElement>('input[type="radio"]');
|
|
75
|
+
this.init();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private init() {
|
|
79
|
+
// Initialize checked state based on data-value
|
|
80
|
+
this.syncWithDataValue();
|
|
81
|
+
|
|
82
|
+
// Setup event listeners
|
|
83
|
+
this.setupEvents();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private syncWithDataValue() {
|
|
87
|
+
const initialValue = this.radioGroup.dataset.value;
|
|
88
|
+
if (!initialValue || !this.radioInputs) return;
|
|
89
|
+
|
|
90
|
+
// Find the radio input with the matching value and check it
|
|
91
|
+
this.radioInputs.forEach((input) => {
|
|
92
|
+
if (input.value === initialValue) {
|
|
93
|
+
input.checked = true;
|
|
94
|
+
} else {
|
|
95
|
+
input.checked = false;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private setupEvents() {
|
|
101
|
+
// Listen for changes to update the fieldset's data-value attribute
|
|
102
|
+
this.radioGroup.addEventListener("change", this.handleChange.bind(this));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private handleChange(e: Event) {
|
|
106
|
+
const target = e.target as HTMLInputElement;
|
|
107
|
+
// console.log("target", target);
|
|
108
|
+
if (target.type !== "radio") return;
|
|
109
|
+
|
|
110
|
+
// Update the data-value attribute
|
|
111
|
+
this.radioGroup.dataset.value = target.value;
|
|
112
|
+
|
|
113
|
+
// Ensure all other radio buttons in the group are unchecked
|
|
114
|
+
if (this.radioInputs) {
|
|
115
|
+
this.radioInputs.forEach((radio) => {
|
|
116
|
+
if (radio !== target) {
|
|
117
|
+
radio.checked = false;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Explicitly mark the clicked radio as checked
|
|
123
|
+
target.checked = true;
|
|
124
|
+
|
|
125
|
+
// Dispatch custom event for external listeners
|
|
126
|
+
this.dispatchChangeEvent(target.value);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private dispatchChangeEvent(value: string) {
|
|
130
|
+
const event = new CustomEvent<RadioGroupChangeEvent["detail"]>("starwind:value-change", {
|
|
131
|
+
bubbles: true,
|
|
132
|
+
detail: {
|
|
133
|
+
value: value,
|
|
134
|
+
radioGroupId: this.radioGroupId,
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
this.radioGroup.dispatchEvent(event);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Store instances in a WeakMap to avoid memory leaks
|
|
142
|
+
const radioGroupInstances = new WeakMap<HTMLElement, RadioGroupHandler>();
|
|
143
|
+
let radioGroupCounter = 0;
|
|
144
|
+
|
|
145
|
+
const setupRadioGroups = () => {
|
|
146
|
+
document
|
|
147
|
+
.querySelectorAll<HTMLFieldSetElement>(".starwind-radio-group")
|
|
148
|
+
.forEach((radioGroup) => {
|
|
149
|
+
if (!radioGroupInstances.has(radioGroup)) {
|
|
150
|
+
radioGroupInstances.set(
|
|
151
|
+
radioGroup,
|
|
152
|
+
new RadioGroupHandler(radioGroup, radioGroupCounter++),
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// Initialize on page load and after Astro view transitions
|
|
159
|
+
setupRadioGroups();
|
|
160
|
+
document.addEventListener("astro:after-swap", setupRadioGroups);
|
|
161
|
+
document.addEventListener("starwind:init", setupRadioGroups);
|
|
162
|
+
</script>
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
---
|
|
2
|
+
import CircleFilled from "@tabler/icons/filled/circle.svg";
|
|
3
|
+
import type { HTMLAttributes } from "astro/types";
|
|
4
|
+
import { tv, type VariantProps } from "tailwind-variants";
|
|
5
|
+
|
|
6
|
+
type Props = HTMLAttributes<"input"> &
|
|
7
|
+
VariantProps<typeof radioWrapper> &
|
|
8
|
+
VariantProps<typeof radioControl> & {
|
|
9
|
+
/**
|
|
10
|
+
* Value of the radio item
|
|
11
|
+
*/
|
|
12
|
+
value: string;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the radio is disabled
|
|
15
|
+
*/
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Optional ID for the radio item
|
|
19
|
+
*/
|
|
20
|
+
id?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Name to group radio inputs
|
|
23
|
+
*/
|
|
24
|
+
name?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the radio is checked (only for initial state)
|
|
27
|
+
*/
|
|
28
|
+
checked?: boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const radioWrapper = tv({
|
|
32
|
+
base: "relative isolate flex shrink-0",
|
|
33
|
+
variants: {
|
|
34
|
+
size: {
|
|
35
|
+
sm: "size-4",
|
|
36
|
+
md: "size-5",
|
|
37
|
+
lg: "size-6",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
defaultVariants: {
|
|
41
|
+
size: "md",
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export const radioItem = tv({
|
|
46
|
+
base: [
|
|
47
|
+
"starwind-radio-item peer z-10 h-full w-full",
|
|
48
|
+
"absolute inset-0 cursor-pointer opacity-0 outline-none focus:outline-none focus-visible:outline-none",
|
|
49
|
+
"disabled:cursor-not-allowed",
|
|
50
|
+
],
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export const radioControl = tv({
|
|
54
|
+
base: [
|
|
55
|
+
"starwind-radio-control",
|
|
56
|
+
"border-input bg-background dark:bg-input/30",
|
|
57
|
+
"outline-none peer-focus-visible:ring-3",
|
|
58
|
+
"absolute inset-0 rounded-full border shadow-xs",
|
|
59
|
+
"transition-[color,box-shadow] peer-checked:[&>svg]:opacity-100",
|
|
60
|
+
"peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
|
61
|
+
"peer-aria-invalid:border-error peer-focus-visible:peer-aria-invalid:ring-error/40",
|
|
62
|
+
"flex items-center justify-center",
|
|
63
|
+
],
|
|
64
|
+
variants: {
|
|
65
|
+
variant: {
|
|
66
|
+
default:
|
|
67
|
+
"peer-checked:border-foreground [&>svg]:fill-foreground peer-focus-visible:ring-outline/50",
|
|
68
|
+
primary:
|
|
69
|
+
"peer-checked:border-primary [&>svg]:fill-primary peer-focus-visible:ring-primary/50",
|
|
70
|
+
secondary:
|
|
71
|
+
"peer-checked:border-secondary [&>svg]:fill-secondary peer-focus-visible:ring-secondary/50",
|
|
72
|
+
info: "peer-checked:border-info [&>svg]:fill-info peer-focus-visible:ring-info/50",
|
|
73
|
+
success:
|
|
74
|
+
"peer-checked:border-success [&>svg]:fill-success peer-focus-visible:ring-success/50",
|
|
75
|
+
warning:
|
|
76
|
+
"peer-checked:border-warning [&>svg]:fill-warning peer-focus-visible:ring-warning/50",
|
|
77
|
+
error: "peer-checked:border-error [&>svg]:fill-error peer-focus-visible:ring-error/50",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
defaultVariants: {
|
|
81
|
+
variant: "primary",
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export const radioIndicator = tv({
|
|
86
|
+
base: ["starwind-radio-indicator", "opacity-0 transition-opacity"],
|
|
87
|
+
variants: {
|
|
88
|
+
size: {
|
|
89
|
+
sm: "size-2",
|
|
90
|
+
md: "size-3",
|
|
91
|
+
lg: "size-4",
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
defaultVariants: {
|
|
95
|
+
size: "md",
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const {
|
|
100
|
+
value,
|
|
101
|
+
name,
|
|
102
|
+
disabled = false,
|
|
103
|
+
checked = false,
|
|
104
|
+
id,
|
|
105
|
+
class: className,
|
|
106
|
+
size = "md",
|
|
107
|
+
variant = "default",
|
|
108
|
+
...rest
|
|
109
|
+
} = Astro.props;
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
<div class={radioWrapper({ size })} data-slot="radio-group-item-wrapper">
|
|
113
|
+
<input
|
|
114
|
+
type="radio"
|
|
115
|
+
class={radioItem()}
|
|
116
|
+
name={name}
|
|
117
|
+
id={id}
|
|
118
|
+
value={value}
|
|
119
|
+
checked={checked}
|
|
120
|
+
disabled={disabled}
|
|
121
|
+
data-slot="radio-group-item"
|
|
122
|
+
{...rest}
|
|
123
|
+
/>
|
|
124
|
+
<span class={radioControl({ variant, class: className })} data-slot="radio-group-item-control">
|
|
125
|
+
<slot name="icon">
|
|
126
|
+
<CircleFilled class={radioIndicator({ size })} />
|
|
127
|
+
</slot>
|
|
128
|
+
</span>
|
|
129
|
+
</div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import RadioGroup, { radioGroup } from "./RadioGroup.astro";
|
|
2
|
+
import RadioGroupItem, {
|
|
3
|
+
radioControl,
|
|
4
|
+
radioIndicator,
|
|
5
|
+
radioItem,
|
|
6
|
+
radioWrapper,
|
|
7
|
+
} from "./RadioGroupItem.astro";
|
|
8
|
+
import type { RadioGroupChangeEvent } from "./RadioGroupTypes";
|
|
9
|
+
|
|
10
|
+
const RadioGroupVariants = {
|
|
11
|
+
radioGroup,
|
|
12
|
+
radioWrapper,
|
|
13
|
+
radioItem,
|
|
14
|
+
radioControl,
|
|
15
|
+
radioIndicator,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { RadioGroup, type RadioGroupChangeEvent, RadioGroupItem, RadioGroupVariants };
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
Root: RadioGroup,
|
|
22
|
+
Item: RadioGroupItem,
|
|
23
|
+
};
|