@rimelight/ui 0.0.4 → 0.0.6
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/package.json +36 -6
- package/src/components/BlogPost.astro +181 -0
- package/src/components/DynamicShowcase.astro +681 -0
- package/src/components/ExtendedCarousel.astro +107 -0
- package/src/components/Head.astro +150 -0
- package/src/components/LanguageSwitcher.astro +128 -0
- package/src/components/ProjectPost.astro +183 -0
- package/src/components/RLHead.astro +3 -0
- package/src/components/ThemeToggle.astro +30 -42
- package/src/components/astro/RLAButton.astro +85 -0
- package/src/components/astro/RLAHeader.astro +75 -0
- package/src/components/vue/RLVButton.vue +90 -0
- package/src/components/vue/RLVHeader.vue +78 -0
- package/src/composables/index.ts +1 -0
- package/src/composables/useUi.ts +27 -0
- package/src/config/index.ts +0 -2
- package/src/config/site.config.ts +1 -1
- package/src/env.d.ts +9 -42
- package/src/integrations/index.ts +2 -0
- package/src/integrations/ui.ts +87 -0
- package/src/themes/button.theme.ts +361 -0
- package/src/themes/header.theme.ts +33 -0
- package/src/themes/index.ts +13 -0
- package/src/utils/index.ts +3 -2
- package/i18n-data.json +0 -186
- package/src/components/accordion/Accordion.astro +0 -257
- package/src/components/accordion/AccordionContent.astro +0 -34
- package/src/components/accordion/AccordionItem.astro +0 -29
- package/src/components/accordion/AccordionTrigger.astro +0 -33
- package/src/components/alert/Alert.astro +0 -34
- package/src/components/alert/AlertDescription.astro +0 -15
- package/src/components/alert/AlertTitle.astro +0 -17
- package/src/components/alert-dialog/AlertDialog.astro +0 -275
- package/src/components/alert-dialog/AlertDialogAction.astro +0 -46
- package/src/components/alert-dialog/AlertDialogCancel.astro +0 -46
- package/src/components/alert-dialog/AlertDialogContent.astro +0 -52
- package/src/components/alert-dialog/AlertDialogDescription.astro +0 -18
- package/src/components/alert-dialog/AlertDialogFooter.astro +0 -16
- package/src/components/alert-dialog/AlertDialogHeader.astro +0 -14
- package/src/components/alert-dialog/AlertDialogTitle.astro +0 -20
- package/src/components/alert-dialog/AlertDialogTrigger.astro +0 -47
- package/src/components/aspect-ratio/AspectRatio.astro +0 -32
- package/src/components/avatar/Avatar.astro +0 -29
- package/src/components/avatar/AvatarFallback.astro +0 -18
- package/src/components/avatar/AvatarImage.astro +0 -66
- package/src/components/badge/Badge.astro +0 -57
- package/src/components/breadcrumb/Breadcrumb.astro +0 -12
- package/src/components/breadcrumb/BreadcrumbEllipsis.astro +0 -29
- package/src/components/breadcrumb/BreadcrumbItem.astro +0 -15
- package/src/components/breadcrumb/BreadcrumbLink.astro +0 -24
- package/src/components/breadcrumb/BreadcrumbList.astro +0 -17
- package/src/components/breadcrumb/BreadcrumbPage.astro +0 -22
- package/src/components/breadcrumb/BreadcrumbSeparator.astro +0 -24
- package/src/components/button/Button.astro +0 -58
- package/src/components/button-group/ButtonGroup.astro +0 -64
- package/src/components/button-group/ButtonGroupSeparator.astro +0 -20
- package/src/components/button-group/ButtonGroupText.astro +0 -19
- package/src/components/card/Card.astro +0 -36
- package/src/components/card/CardAction.astro +0 -16
- package/src/components/card/CardContent.astro +0 -16
- package/src/components/card/CardDescription.astro +0 -16
- package/src/components/card/CardFooter.astro +0 -16
- package/src/components/card/CardHeader.astro +0 -19
- package/src/components/card/CardTitle.astro +0 -16
- package/src/components/carousel/Carousel.astro +0 -55
- package/src/components/carousel/CarouselContent.astro +0 -26
- package/src/components/carousel/CarouselItem.astro +0 -26
- package/src/components/carousel/CarouselNext.astro +0 -39
- package/src/components/carousel/CarouselPrevious.astro +0 -41
- package/src/components/carousel/carousel-script.ts +0 -188
- package/src/components/carousel/index.ts +0 -1
- package/src/components/checkbox/Checkbox.astro +0 -133
- package/src/components/collapsible/Collapsible.astro +0 -161
- package/src/components/collapsible/CollapsibleContent.astro +0 -22
- package/src/components/collapsible/CollapsibleTrigger.astro +0 -44
- package/src/components/dialog/Dialog.astro +0 -389
- package/src/components/dialog/DialogClose.astro +0 -35
- package/src/components/dialog/DialogContent.astro +0 -78
- package/src/components/dialog/DialogDescription.astro +0 -14
- package/src/components/dialog/DialogFooter.astro +0 -14
- package/src/components/dialog/DialogHeader.astro +0 -14
- package/src/components/dialog/DialogTitle.astro +0 -18
- package/src/components/dialog/DialogTrigger.astro +0 -47
- package/src/components/dropdown/Dropdown.astro +0 -604
- package/src/components/dropdown/DropdownContent.astro +0 -118
- package/src/components/dropdown/DropdownItem.astro +0 -48
- package/src/components/dropdown/DropdownLabel.astro +0 -29
- package/src/components/dropdown/DropdownSeparator.astro +0 -21
- package/src/components/dropdown/DropdownShortcut.astro +0 -17
- package/src/components/dropdown/DropdownSub.astro +0 -15
- package/src/components/dropdown/DropdownSubContent.astro +0 -39
- package/src/components/dropdown/DropdownSubTrigger.astro +0 -34
- package/src/components/dropdown/DropdownTrigger.astro +0 -52
- package/src/components/dropzone/Dropzone.astro +0 -236
- package/src/components/dropzone/DropzoneFilesList.astro +0 -26
- package/src/components/dropzone/DropzoneLoadingIndicator.astro +0 -10
- package/src/components/dropzone/DropzoneUploadIndicator.astro +0 -10
- package/src/components/embeds/YoutubeEmbed.astro +0 -94
- package/src/components/hero/Hero.astro +0 -166
- package/src/components/icons/Flag.astro +0 -62
- package/src/components/image/ExtendedImage.astro +0 -46
- package/src/components/image/Image.astro +0 -25
- package/src/components/input/Input.astro +0 -27
- package/src/components/input-group/InputGroup.astro +0 -28
- package/src/components/input-group/InputGroupAddon.astro +0 -76
- package/src/components/input-group/InputGroupButton.astro +0 -36
- package/src/components/input-group/InputGroupInput.astro +0 -18
- package/src/components/input-group/InputGroupText.astro +0 -17
- package/src/components/input-group/InputGroupTextarea.astro +0 -22
- package/src/components/input-otp/InputOtp.astro +0 -352
- package/src/components/input-otp/InputOtpGroup.astro +0 -16
- package/src/components/input-otp/InputOtpSeparator.astro +0 -25
- package/src/components/input-otp/InputOtpSlot.astro +0 -50
- package/src/components/input-otp/InputOtpTypes.ts +0 -6
- package/src/components/item/Item.astro +0 -52
- package/src/components/item/ItemActions.astro +0 -16
- package/src/components/item/ItemContent.astro +0 -16
- package/src/components/item/ItemDescription.astro +0 -19
- package/src/components/item/ItemFooter.astro +0 -16
- package/src/components/item/ItemGroup.astro +0 -16
- package/src/components/item/ItemHeader.astro +0 -16
- package/src/components/item/ItemMedia.astro +0 -40
- package/src/components/item/ItemSeparator.astro +0 -23
- package/src/components/item/ItemTitle.astro +0 -16
- package/src/components/kbd/Kbd.astro +0 -21
- package/src/components/kbd/KbdGroup.astro +0 -16
- package/src/components/label/Label.astro +0 -24
- package/src/components/marquee/Marquee.astro +0 -73
- package/src/components/native-select/NativeSelect.astro +0 -68
- package/src/components/native-select/NativeSelectOptGroup.astro +0 -15
- package/src/components/native-select/NativeSelectOption.astro +0 -15
- package/src/components/pagination/Pagination.astro +0 -20
- package/src/components/pagination/PaginationContent.astro +0 -16
- package/src/components/pagination/PaginationEllipsis.astro +0 -37
- package/src/components/pagination/PaginationItem.astro +0 -16
- package/src/components/pagination/PaginationLink.astro +0 -27
- package/src/components/pagination/PaginationNext.astro +0 -33
- package/src/components/pagination/PaginationPrevious.astro +0 -33
- package/src/components/popover/Popover.astro +0 -717
- package/src/components/popover/PopoverContent.astro +0 -102
- package/src/components/popover/PopoverDescription.astro +0 -14
- package/src/components/popover/PopoverHeader.astro +0 -14
- package/src/components/popover/PopoverTitle.astro +0 -14
- package/src/components/popover/PopoverTrigger.astro +0 -51
- package/src/components/progress/Progress.astro +0 -154
- package/src/components/prose/Prose.astro +0 -619
- package/src/components/radio-group/RadioGroup.astro +0 -162
- package/src/components/radio-group/RadioGroupItem.astro +0 -133
- package/src/components/radio-group/RadioGroupTypes.ts +0 -6
- package/src/components/section/Section.astro +0 -167
- package/src/components/select/Select.astro +0 -752
- package/src/components/select/SelectContent.astro +0 -94
- package/src/components/select/SelectGroup.astro +0 -9
- package/src/components/select/SelectItem.astro +0 -51
- package/src/components/select/SelectLabel.astro +0 -14
- package/src/components/select/SelectSearch.astro +0 -49
- package/src/components/select/SelectSeparator.astro +0 -12
- package/src/components/select/SelectTrigger.astro +0 -56
- package/src/components/select/SelectTypes.ts +0 -13
- package/src/components/select/SelectValue.astro +0 -19
- package/src/components/separator/Separator.astro +0 -36
- package/src/components/sheet/Sheet.astro +0 -15
- package/src/components/sheet/SheetClose.astro +0 -15
- package/src/components/sheet/SheetContent.astro +0 -89
- package/src/components/sheet/SheetDescription.astro +0 -16
- package/src/components/sheet/SheetFooter.astro +0 -16
- package/src/components/sheet/SheetHeader.astro +0 -16
- package/src/components/sheet/SheetTitle.astro +0 -16
- package/src/components/sheet/SheetTrigger.astro +0 -15
- package/src/components/sidebar/Sidebar.astro +0 -231
- package/src/components/sidebar/SidebarContent.astro +0 -25
- package/src/components/sidebar/SidebarFooter.astro +0 -22
- package/src/components/sidebar/SidebarGroup.astro +0 -22
- package/src/components/sidebar/SidebarGroupContent.astro +0 -22
- package/src/components/sidebar/SidebarGroupLabel.astro +0 -53
- package/src/components/sidebar/SidebarHeader.astro +0 -22
- package/src/components/sidebar/SidebarInput.astro +0 -24
- package/src/components/sidebar/SidebarInset.astro +0 -22
- package/src/components/sidebar/SidebarMenu.astro +0 -22
- package/src/components/sidebar/SidebarMenuAction.astro +0 -63
- package/src/components/sidebar/SidebarMenuBadge.astro +0 -31
- package/src/components/sidebar/SidebarMenuButton.astro +0 -124
- package/src/components/sidebar/SidebarMenuItem.astro +0 -22
- package/src/components/sidebar/SidebarMenuSkeleton.astro +0 -43
- package/src/components/sidebar/SidebarMenuSub.astro +0 -25
- package/src/components/sidebar/SidebarMenuSubButton.astro +0 -52
- package/src/components/sidebar/SidebarMenuSubItem.astro +0 -17
- package/src/components/sidebar/SidebarProvider.astro +0 -215
- package/src/components/sidebar/SidebarRail.astro +0 -72
- package/src/components/sidebar/SidebarSeparator.astro +0 -25
- package/src/components/sidebar/SidebarTrigger.astro +0 -69
- package/src/components/skeleton/Skeleton.astro +0 -14
- package/src/components/slider/Slider.astro +0 -425
- package/src/components/spinner/Spinner.astro +0 -23
- package/src/components/switch/Switch.astro +0 -192
- package/src/components/switch/SwitchTypes.ts +0 -6
- package/src/components/table/Table.astro +0 -20
- package/src/components/table/TableBody.astro +0 -18
- package/src/components/table/TableCaption.astro +0 -18
- package/src/components/table/TableCell.astro +0 -18
- package/src/components/table/TableFoot.astro +0 -18
- package/src/components/table/TableHead.astro +0 -18
- package/src/components/table/TableHeader.astro +0 -18
- package/src/components/table/TableRow.astro +0 -17
- package/src/components/tabs/Tabs.astro +0 -270
- package/src/components/tabs/TabsContent.astro +0 -28
- package/src/components/tabs/TabsList.astro +0 -23
- package/src/components/tabs/TabsTrigger.astro +0 -34
- package/src/components/textarea/Textarea.astro +0 -31
- package/src/components/toast/ToastDescription.astro +0 -22
- package/src/components/toast/ToastItem.astro +0 -56
- package/src/components/toast/ToastTemplate.astro +0 -27
- package/src/components/toast/ToastTitle.astro +0 -59
- package/src/components/toast/Toaster.astro +0 -981
- package/src/components/toast/index.ts +0 -1
- package/src/components/toast/toast-manager.ts +0 -234
- package/src/components/toggle/Toggle.astro +0 -174
- package/src/components/toggle/ToggleTypes.ts +0 -14
- package/src/components/tooltip/Tooltip.astro +0 -422
- package/src/components/tooltip/TooltipContent.astro +0 -83
- package/src/components/tooltip/TooltipTrigger.astro +0 -13
- package/src/components/video/Video.astro +0 -121
- package/src/config/cookies.ts +0 -5
- package/src/config/links.ts +0 -4
- package/src/domain/cms/index.ts +0 -1
- package/src/domain/cms/types.ts +0 -20
- package/src/domain/i18n/constants.ts +0 -21
- package/src/domain/i18n/cookie-storage.ts +0 -13
- package/src/domain/i18n/country-to-locale-map.ts +0 -67
- package/src/domain/i18n/fallbacks.generated.ts +0 -230
- package/src/domain/i18n/fetcher.ts +0 -278
- package/src/domain/i18n/flags.ts +0 -16
- package/src/domain/i18n/format.ts +0 -90
- package/src/domain/i18n/index.ts +0 -10
- package/src/domain/i18n/middleware/i18n.ts +0 -161
- package/src/domain/i18n/resolve-locale.ts +0 -55
- package/src/domain/i18n/runtime-constants.ts +0 -14
- package/src/domain/i18n/schema.ts +0 -29
- package/src/domain/index.ts +0 -4
- package/src/domain/seo/constants.ts +0 -6
- package/src/domain/seo/index.ts +0 -3
- package/src/domain/seo/services/index.ts +0 -3
- package/src/domain/seo/services/llms.ts +0 -56
- package/src/domain/seo/services/robots.ts +0 -12
- package/src/domain/seo/services/sitemap.ts +0 -56
- package/src/domain/seo/utils.ts +0 -36
- package/src/domain/theme/constants.ts +0 -6
- package/src/domain/theme/index.ts +0 -2
- package/src/domain/theme/schema.ts +0 -10
- package/src/i18n.generated.d.ts +0 -202
- package/src/lib/component-preview.ts +0 -73
- package/src/lib/index.ts +0 -6
- package/src/lib/remark/remark-modified-time.ts +0 -13
- package/src/lib/showcase-preview-elements.ts +0 -408
- package/src/lib/showcase-renderer.ts +0 -218
- package/src/lib/showcase-utils.ts +0 -189
- package/src/lib/turnstile.ts +0 -35
- package/src/lib/utils/starwind/positioning.ts +0 -318
- package/src/locales/de/blog.json +0 -9
- package/src/locales/de/common.json +0 -19
- package/src/locales/de/errors.json +0 -6
- package/src/locales/de/home.json +0 -20
- package/src/locales/de/messages.json +0 -8
- package/src/locales/de/nav.json +0 -13
- package/src/locales/de/projects.json +0 -9
- package/src/locales/de/services.json +0 -43
- package/src/locales/en/blog.json +0 -9
- package/src/locales/en/chat.json +0 -29
- package/src/locales/en/common.json +0 -19
- package/src/locales/en/cookie_notice.json +0 -11
- package/src/locales/en/editor.json +0 -24
- package/src/locales/en/errors.json +0 -6
- package/src/locales/en/home.json +0 -20
- package/src/locales/en/messages.json +0 -8
- package/src/locales/en/nav.json +0 -13
- package/src/locales/en/projects.json +0 -9
- package/src/locales/en/services.json +0 -43
- package/src/locales/es/blog.json +0 -9
- package/src/locales/es/common.json +0 -19
- package/src/locales/es/errors.json +0 -6
- package/src/locales/es/home.json +0 -20
- package/src/locales/es/messages.json +0 -8
- package/src/locales/es/nav.json +0 -13
- package/src/locales/es/projects.json +0 -9
- package/src/locales/es/services.json +0 -43
- package/src/locales/ja/blog.json +0 -9
- package/src/locales/ja/common.json +0 -19
- package/src/locales/ja/errors.json +0 -6
- package/src/locales/ja/home.json +0 -20
- package/src/locales/ja/messages.json +0 -8
- package/src/locales/ja/nav.json +0 -13
- package/src/locales/ja/projects.json +0 -9
- package/src/locales/ja/services.json +0 -43
- package/src/locales/pt/blog.json +0 -9
- package/src/locales/pt/chat.json +0 -29
- package/src/locales/pt/common.json +0 -19
- package/src/locales/pt/cookie_notice.json +0 -11
- package/src/locales/pt/editor.json +0 -24
- package/src/locales/pt/errors.json +0 -6
- package/src/locales/pt/home.json +0 -20
- package/src/locales/pt/messages.json +0 -8
- package/src/locales/pt/nav.json +0 -13
- package/src/locales/pt/projects.json +0 -9
- package/src/locales/pt/services.json +0 -43
- package/src/utils/server/cookies.ts +0 -98
- package/src/utils/server/index.ts +0 -1
- package/src/utils/shared/index.ts +0 -3
- /package/src/utils/{shared/deep-merge.ts → deep-merge.ts} +0 -0
- /package/src/utils/{shared/embed.ts → embed.ts} +0 -0
- /package/src/utils/{shared/parse-boolean.ts → parse-boolean.ts} +0 -0
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { HTMLAttributes } from "astro/types";
|
|
3
|
-
import { cv } from "css-variants";
|
|
4
|
-
|
|
5
|
-
export const carouselContent = cv({
|
|
6
|
-
base: "overflow-hidden",
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
const carouselContainer = cv({
|
|
10
|
-
base: [
|
|
11
|
-
"flex group-data-[axis=y]/carousel:flex-col",
|
|
12
|
-
"group-data-[axis=x]/carousel:-ml-4",
|
|
13
|
-
"group-data-[axis=y]/carousel:-mt-4",
|
|
14
|
-
],
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
type Props = HTMLAttributes<"div">;
|
|
18
|
-
|
|
19
|
-
const { class: className = "", ...rest } = Astro.props;
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
<div class={carouselContent()} {...rest} data-slot="carousel-content">
|
|
23
|
-
<div class:list={[carouselContainer(), className]} data-slot="carousel-container">
|
|
24
|
-
<slot />
|
|
25
|
-
</div>
|
|
26
|
-
</div>
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { HTMLAttributes } from "astro/types";
|
|
3
|
-
import { cv } from "css-variants";
|
|
4
|
-
|
|
5
|
-
export const carouselItem = cv({
|
|
6
|
-
base: [
|
|
7
|
-
"min-w-0 shrink-0 grow-0 basis-full",
|
|
8
|
-
"group-data-[axis=x]/carousel:pl-4",
|
|
9
|
-
"group-data-[axis=y]/carousel:pt-4",
|
|
10
|
-
],
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
type Props = HTMLAttributes<"div">;
|
|
14
|
-
|
|
15
|
-
const { class: className = "", ...rest } = Astro.props;
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
<div
|
|
19
|
-
role="group"
|
|
20
|
-
aria-roledescription="slide"
|
|
21
|
-
class:list={[carouselItem(), className]}
|
|
22
|
-
{...rest}
|
|
23
|
-
data-slot="carousel-item"
|
|
24
|
-
>
|
|
25
|
-
<slot />
|
|
26
|
-
</div>
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { ComponentProps } from "astro/types";
|
|
3
|
-
import { cv } from "css-variants";
|
|
4
|
-
import IconArrowRight from "~icons/lucide/arrow-right";
|
|
5
|
-
|
|
6
|
-
// eslint-disable-next-line typescript/consistent-type-imports
|
|
7
|
-
import Button from "../button/Button.astro";
|
|
8
|
-
|
|
9
|
-
export const carouselNext = cv({
|
|
10
|
-
base: [
|
|
11
|
-
"starwind-carousel-next absolute size-8 rounded-full",
|
|
12
|
-
// Horizontal positioning
|
|
13
|
-
"group-data-[axis=x]/carousel:top-1/2 group-data-[axis=x]/carousel:-right-12 group-data-[axis=x]/carousel:-translate-y-1/2",
|
|
14
|
-
// Vertical positioning
|
|
15
|
-
"group-data-[axis=y]/carousel:-bottom-12 group-data-[axis=y]/carousel:left-1/2 group-data-[axis=y]/carousel:-translate-x-1/2 group-data-[axis=y]/carousel:rotate-90",
|
|
16
|
-
],
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
type Props = ComponentProps<typeof Button> & { orientation?: "horizontal" | "vertical" };
|
|
20
|
-
|
|
21
|
-
const { class: className = "", variant = "outline", size = "icon", orientation = "horizontal", ...rest } = Astro.props;
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
<Button
|
|
25
|
-
variant={variant}
|
|
26
|
-
size={size}
|
|
27
|
-
class:list={[carouselNext({ orientation }), className]}
|
|
28
|
-
aria-label="Next slide"
|
|
29
|
-
{...rest}
|
|
30
|
-
data-slot="carousel-next"
|
|
31
|
-
>
|
|
32
|
-
<slot name="icon">
|
|
33
|
-
<IconArrowRight />
|
|
34
|
-
</slot>
|
|
35
|
-
<slot>
|
|
36
|
-
<span class="sr-only">Next slide</span>
|
|
37
|
-
</slot>
|
|
38
|
-
</Button>
|
|
39
|
-
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { ComponentProps } from "astro/types";
|
|
3
|
-
import { cv } from "css-variants";
|
|
4
|
-
import IconArrowLeft from "~icons/lucide/arrow-left";
|
|
5
|
-
|
|
6
|
-
// eslint-disable-next-line typescript/consistent-type-imports
|
|
7
|
-
import Button from "../button/Button.astro";
|
|
8
|
-
|
|
9
|
-
export const carouselPrevious = cv({
|
|
10
|
-
base: [
|
|
11
|
-
"starwind-carousel-previous absolute size-8 rounded-full",
|
|
12
|
-
// Horizontal positioning
|
|
13
|
-
"group-data-[axis=x]/carousel:top-1/2 group-data-[axis=x]/carousel:-left-12 group-data-[axis=x]/carousel:-translate-y-1/2",
|
|
14
|
-
// Vertical positioning
|
|
15
|
-
"group-data-[axis=y]/carousel:-top-12 group-data-[axis=y]/carousel:left-1/2 group-data-[axis=y]/carousel:-translate-x-1/2 group-data-[axis=y]/carousel:rotate-90",
|
|
16
|
-
],
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
type Props = ComponentProps<typeof Button> & {
|
|
20
|
-
orientation?: "horizontal" | "vertical";
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const { class: className = "", variant = "outline", size = "icon", orientation = "horizontal", ...rest } = Astro.props;
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
<Button
|
|
27
|
-
variant={variant}
|
|
28
|
-
size={size}
|
|
29
|
-
class:list={[carouselPrevious({ orientation }), className]}
|
|
30
|
-
aria-label="Previous slide"
|
|
31
|
-
{...rest}
|
|
32
|
-
data-slot="carousel-previous"
|
|
33
|
-
>
|
|
34
|
-
<slot name="icon">
|
|
35
|
-
<IconArrowLeft />
|
|
36
|
-
</slot>
|
|
37
|
-
<slot>
|
|
38
|
-
<span class="sr-only">Previous slide</span>
|
|
39
|
-
</slot>
|
|
40
|
-
</Button>
|
|
41
|
-
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import EmblaCarousel, {
|
|
2
|
-
type EmblaCarouselType,
|
|
3
|
-
type EmblaOptionsType,
|
|
4
|
-
type EmblaPluginType
|
|
5
|
-
} from "embla-carousel"
|
|
6
|
-
|
|
7
|
-
export type CarouselApi = EmblaCarouselType
|
|
8
|
-
|
|
9
|
-
export interface CarouselOptions {
|
|
10
|
-
opts?: EmblaOptionsType
|
|
11
|
-
plugins?: EmblaPluginType[]
|
|
12
|
-
setApi?: (api: CarouselApi) => void
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface CarouselManager {
|
|
16
|
-
api: CarouselApi
|
|
17
|
-
scrollPrev: () => void
|
|
18
|
-
scrollNext: () => void
|
|
19
|
-
canScrollPrev: () => boolean
|
|
20
|
-
canScrollNext: () => boolean
|
|
21
|
-
destroy: () => void
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function initCarousel(
|
|
25
|
-
carouselElement: HTMLElement,
|
|
26
|
-
options: CarouselOptions = {}
|
|
27
|
-
): CarouselManager | null {
|
|
28
|
-
// don't re-initialize if already initialized
|
|
29
|
-
if (carouselElement.dataset.initialized === "true") return null
|
|
30
|
-
carouselElement.dataset.initialized = "true"
|
|
31
|
-
|
|
32
|
-
if (!carouselElement) {
|
|
33
|
-
console.warn("Carousel element not found")
|
|
34
|
-
return null
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Find content element - Embla expects the viewport element, not the container
|
|
38
|
-
const viewportElement = carouselElement.querySelector('[data-slot="carousel-content"]')
|
|
39
|
-
|
|
40
|
-
if (!(viewportElement instanceof HTMLElement)) {
|
|
41
|
-
console.warn("Carousel content element not found")
|
|
42
|
-
return null
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Get configuration from data attributes
|
|
46
|
-
const axisData = carouselElement.dataset.axis
|
|
47
|
-
const axis: EmblaOptionsType["axis"] = axisData === "y" ? "y" : "x"
|
|
48
|
-
|
|
49
|
-
// Safely parse data options
|
|
50
|
-
let dataOpts = {}
|
|
51
|
-
try {
|
|
52
|
-
const optsString = carouselElement.dataset.opts
|
|
53
|
-
if (optsString && optsString !== "undefined" && optsString !== "null") {
|
|
54
|
-
dataOpts = JSON.parse(optsString)
|
|
55
|
-
}
|
|
56
|
-
} catch (e) {
|
|
57
|
-
console.warn("Failed to parse carousel opts:", e)
|
|
58
|
-
dataOpts = {}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Ensure dataOpts is a valid object
|
|
62
|
-
if (!dataOpts || typeof dataOpts !== "object") {
|
|
63
|
-
dataOpts = {}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Merge options - ensure we always have a valid object
|
|
67
|
-
const emblaOptions: EmblaOptionsType = {
|
|
68
|
-
axis,
|
|
69
|
-
...dataOpts,
|
|
70
|
-
...options.opts
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Handle plugins - EmblaCarousel expects undefined when no plugins, not empty array
|
|
74
|
-
const plugins = options.plugins && options.plugins.length > 0 ? options.plugins : undefined
|
|
75
|
-
|
|
76
|
-
// console.log("ID:", carouselElement.id);
|
|
77
|
-
// console.log("Plugins:", plugins);
|
|
78
|
-
// console.log("Options:", emblaOptions);
|
|
79
|
-
|
|
80
|
-
// Find navigation buttons
|
|
81
|
-
const prevButton = carouselElement.querySelector(".starwind-carousel-previous")
|
|
82
|
-
const nextButton = carouselElement.querySelector(".starwind-carousel-next")
|
|
83
|
-
|
|
84
|
-
const prevButtonEl = prevButton instanceof HTMLButtonElement ? prevButton : null
|
|
85
|
-
const nextButtonEl = nextButton instanceof HTMLButtonElement ? nextButton : null
|
|
86
|
-
|
|
87
|
-
// Initialize Embla
|
|
88
|
-
let emblaApi: EmblaCarouselType
|
|
89
|
-
if (plugins) {
|
|
90
|
-
emblaApi = EmblaCarousel(viewportElement, emblaOptions, plugins)
|
|
91
|
-
} else {
|
|
92
|
-
emblaApi = EmblaCarousel(viewportElement, emblaOptions)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Update button states
|
|
96
|
-
const updateButtons = () => {
|
|
97
|
-
const canScrollPrev = emblaApi.canScrollPrev()
|
|
98
|
-
const canScrollNext = emblaApi.canScrollNext()
|
|
99
|
-
|
|
100
|
-
if (prevButtonEl) {
|
|
101
|
-
prevButtonEl.disabled = !canScrollPrev
|
|
102
|
-
prevButtonEl.setAttribute("aria-disabled", (!canScrollPrev).toString())
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (nextButtonEl) {
|
|
106
|
-
nextButtonEl.disabled = !canScrollNext
|
|
107
|
-
nextButtonEl.setAttribute("aria-disabled", (!canScrollNext).toString())
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Event handlers for cleanup
|
|
112
|
-
const prevClickHandler = () => emblaApi.scrollPrev()
|
|
113
|
-
const nextClickHandler = () => emblaApi.scrollNext()
|
|
114
|
-
const keydownHandler = (event: KeyboardEvent) => {
|
|
115
|
-
if (axis === "y") {
|
|
116
|
-
// Vertical axis: ArrowUp = previous, ArrowDown = next
|
|
117
|
-
if (event.key === "ArrowUp") {
|
|
118
|
-
event.preventDefault()
|
|
119
|
-
emblaApi.scrollPrev()
|
|
120
|
-
} else if (event.key === "ArrowDown") {
|
|
121
|
-
event.preventDefault()
|
|
122
|
-
emblaApi.scrollNext()
|
|
123
|
-
}
|
|
124
|
-
} else {
|
|
125
|
-
// Horizontal axis (default): ArrowLeft = previous, ArrowRight = next
|
|
126
|
-
if (event.key === "ArrowLeft") {
|
|
127
|
-
event.preventDefault()
|
|
128
|
-
emblaApi.scrollPrev()
|
|
129
|
-
} else if (event.key === "ArrowRight") {
|
|
130
|
-
event.preventDefault()
|
|
131
|
-
emblaApi.scrollNext()
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Setup event listeners
|
|
137
|
-
const setupEventListeners = () => {
|
|
138
|
-
// Navigation button listeners
|
|
139
|
-
prevButtonEl?.addEventListener("click", prevClickHandler)
|
|
140
|
-
nextButtonEl?.addEventListener("click", nextClickHandler)
|
|
141
|
-
|
|
142
|
-
// Keyboard navigation
|
|
143
|
-
carouselElement.addEventListener("keydown", keydownHandler)
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// Setup user API callback
|
|
147
|
-
const setupUserCallbacks = () => {
|
|
148
|
-
if (options.setApi) {
|
|
149
|
-
options.setApi(emblaApi)
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Initialize everything
|
|
154
|
-
updateButtons()
|
|
155
|
-
setupEventListeners()
|
|
156
|
-
setupUserCallbacks()
|
|
157
|
-
|
|
158
|
-
// Setup internal event listeners
|
|
159
|
-
emblaApi.on("select", updateButtons)
|
|
160
|
-
emblaApi.on("init", () => {
|
|
161
|
-
updateButtons()
|
|
162
|
-
})
|
|
163
|
-
emblaApi.on("reInit", () => {
|
|
164
|
-
updateButtons()
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
// Return manager interface
|
|
168
|
-
return {
|
|
169
|
-
api: emblaApi,
|
|
170
|
-
scrollPrev: () => emblaApi.scrollPrev(),
|
|
171
|
-
scrollNext: () => emblaApi.scrollNext(),
|
|
172
|
-
canScrollPrev: () => emblaApi.canScrollPrev(),
|
|
173
|
-
canScrollNext: () => emblaApi.canScrollNext(),
|
|
174
|
-
destroy: () => {
|
|
175
|
-
// Remove event listeners to prevent memory leaks
|
|
176
|
-
if (prevButtonEl) {
|
|
177
|
-
prevButtonEl.removeEventListener("click", prevClickHandler)
|
|
178
|
-
}
|
|
179
|
-
if (nextButtonEl) {
|
|
180
|
-
nextButtonEl.removeEventListener("click", nextClickHandler)
|
|
181
|
-
}
|
|
182
|
-
carouselElement.removeEventListener("keydown", keydownHandler)
|
|
183
|
-
|
|
184
|
-
// Destroy the Embla instance
|
|
185
|
-
emblaApi.destroy()
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./carousel-script"
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { HTMLAttributes } from "astro/types";
|
|
3
|
-
import { scv } from "css-variants";
|
|
4
|
-
import IconCheck from "~icons/lucide/check";
|
|
5
|
-
|
|
6
|
-
type VariantProps<T extends (...args: any) => any> = NonNullable<Parameters<T>[0]>;
|
|
7
|
-
|
|
8
|
-
type Props = Omit<HTMLAttributes<"input">, "type"> &
|
|
9
|
-
VariantProps<typeof checkbox> & {
|
|
10
|
-
/**
|
|
11
|
-
* Optional label text to display next to the checkbox
|
|
12
|
-
*/
|
|
13
|
-
label?: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const checkbox = scv({
|
|
17
|
-
slots: ["base", "input", "icon", "label"],
|
|
18
|
-
base: {
|
|
19
|
-
base: "starwind-checkbox relative flex items-center space-x-2",
|
|
20
|
-
input: [
|
|
21
|
-
"peer border-input bg-background dark:bg-input/30 shrink-0 transform-gpu rounded-sm border",
|
|
22
|
-
"transition-all focus-visible:ring-3",
|
|
23
|
-
"outline-0 focus:ring-0 focus:ring-offset-0",
|
|
24
|
-
"not-disabled:cursor-pointer disabled:cursor-not-allowed disabled:op-50",
|
|
25
|
-
"aria-invalid:border-error aria-invalid:focus-visible:ring-error/40",
|
|
26
|
-
],
|
|
27
|
-
icon: [
|
|
28
|
-
"pointer-events-none absolute stroke-3 p-0.5 op-0 transition-op peer-checked:op-100",
|
|
29
|
-
"starwind-check-icon",
|
|
30
|
-
],
|
|
31
|
-
label:
|
|
32
|
-
"font-medium peer-not-disabled:cursor-pointer peer-disabled:cursor-not-allowed peer-disabled:op-70",
|
|
33
|
-
},
|
|
34
|
-
variants: {
|
|
35
|
-
size: {
|
|
36
|
-
sm: { input: "size-4", icon: "size-4", label: "text-sm" },
|
|
37
|
-
md: { input: "size-5", icon: "size-5", label: "text-base" },
|
|
38
|
-
lg: { input: "size-6", icon: "size-6", label: "text-lg" },
|
|
39
|
-
},
|
|
40
|
-
variant: {
|
|
41
|
-
default: {
|
|
42
|
-
input: "checked:bg-foreground focus-visible:ring-outline/50 focus-visible:border-outline",
|
|
43
|
-
icon: "text-background",
|
|
44
|
-
},
|
|
45
|
-
primary: {
|
|
46
|
-
input:
|
|
47
|
-
"checked:bg-primary checked:border-primary focus-visible:ring-primary/50 focus-visible:border-primary",
|
|
48
|
-
icon: "text-primary-foreground",
|
|
49
|
-
},
|
|
50
|
-
secondary: {
|
|
51
|
-
input:
|
|
52
|
-
"checked:bg-secondary checked:border-secondary focus-visible:ring-secondary/50 focus-visible:border-secondary",
|
|
53
|
-
icon: "text-secondary-foreground",
|
|
54
|
-
},
|
|
55
|
-
info: {
|
|
56
|
-
input:
|
|
57
|
-
"checked:bg-info checked:border-info focus-visible:ring-info/50 focus-visible:border-info",
|
|
58
|
-
icon: "text-info-foreground",
|
|
59
|
-
},
|
|
60
|
-
success: {
|
|
61
|
-
input:
|
|
62
|
-
"checked:bg-success checked:border-success focus-visible:ring-success/50 focus-visible:border-success",
|
|
63
|
-
icon: "text-success-foreground",
|
|
64
|
-
},
|
|
65
|
-
warning: {
|
|
66
|
-
input:
|
|
67
|
-
"checked:bg-warning checked:border-warning focus-visible:ring-warning/50 focus-visible:border-warning",
|
|
68
|
-
icon: "text-warning-foreground",
|
|
69
|
-
},
|
|
70
|
-
error: {
|
|
71
|
-
input:
|
|
72
|
-
"checked:bg-error checked:border-error focus-visible:ring-error/50 focus-visible:border-error",
|
|
73
|
-
icon: "text-error-foreground",
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
defaultVariants: { size: "md", variant: "default" },
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
const { id, label, checked, size, variant, class: className, ...rest } = Astro.props;
|
|
81
|
-
|
|
82
|
-
const { base, input, icon, label: labelClass } = checkbox({ size, variant });
|
|
83
|
-
---
|
|
84
|
-
|
|
85
|
-
<div class={base}>
|
|
86
|
-
<input
|
|
87
|
-
type="checkbox"
|
|
88
|
-
id={id}
|
|
89
|
-
class:list={[input, className]}
|
|
90
|
-
{checked}
|
|
91
|
-
{...rest}
|
|
92
|
-
data-slot="checkbox-input"
|
|
93
|
-
/>
|
|
94
|
-
<span class={icon}>
|
|
95
|
-
<IconCheck />
|
|
96
|
-
</span>
|
|
97
|
-
{
|
|
98
|
-
label && (
|
|
99
|
-
<label for={id} class={labelClass} data-slot="checkbox-label">
|
|
100
|
-
{label}
|
|
101
|
-
</label>
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
</div>
|
|
105
|
-
|
|
106
|
-
<style>
|
|
107
|
-
.starwind-checkbox input[type="checkbox"]:checked {
|
|
108
|
-
background-image: none;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/* Check drawing animation */
|
|
112
|
-
.starwind-check-icon {
|
|
113
|
-
stroke-dasharray: 65;
|
|
114
|
-
stroke-dashoffset: 65;
|
|
115
|
-
opacity: 0;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
.starwind-checkbox input[type="checkbox"]:checked + .starwind-check-icon {
|
|
119
|
-
animation: draw-check 0.3s ease forwards;
|
|
120
|
-
animation-delay: 0.15s;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
@keyframes draw-check {
|
|
124
|
-
0% {
|
|
125
|
-
stroke-dashoffset: 65;
|
|
126
|
-
opacity: 1;
|
|
127
|
-
}
|
|
128
|
-
100% {
|
|
129
|
-
stroke-dashoffset: 0;
|
|
130
|
-
opacity: 1;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
</style>
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { HTMLAttributes } from "astro/types";
|
|
3
|
-
import { cv } from "css-variants";
|
|
4
|
-
|
|
5
|
-
type Props = HTMLAttributes<"div"> & {
|
|
6
|
-
/**
|
|
7
|
-
* Whether the collapsible panel is initially open
|
|
8
|
-
*/
|
|
9
|
-
defaultOpen?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Whether the component should ignore user interaction
|
|
12
|
-
*/
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const collapsible = cv({ base: "starwind-collapsible" });
|
|
17
|
-
|
|
18
|
-
const { defaultOpen = false, disabled = false, class: className, ...rest } = Astro.props;
|
|
19
|
-
|
|
20
|
-
// Keys owned by the runtime that should not be spread from rest
|
|
21
|
-
const runtimeOwnedKeys = ["id", "data-state", "data-disabled", "class"] as const;
|
|
22
|
-
const sanitizedRest = Object.fromEntries(
|
|
23
|
-
Object.entries(rest).filter(
|
|
24
|
-
([key]) => !runtimeOwnedKeys.includes(key as (typeof runtimeOwnedKeys)[number]),
|
|
25
|
-
),
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
// Compute final values, preferring consumer-provided values
|
|
29
|
-
const finalDataState =
|
|
30
|
-
(rest as Record<string, unknown>)["data-state"] ?? (defaultOpen ? "open" : "closed");
|
|
31
|
-
const finalDataDisabled =
|
|
32
|
-
(rest as Record<string, unknown>)["data-disabled"] ?? (disabled ? "" : undefined);
|
|
33
|
-
const finalId = (rest as Record<string, unknown>)["id"] as string | undefined;
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
<div
|
|
37
|
-
id={finalId}
|
|
38
|
-
class:list={[collapsible(), className]}
|
|
39
|
-
data-state={finalDataState}
|
|
40
|
-
data-disabled={finalDataDisabled}
|
|
41
|
-
{...sanitizedRest}
|
|
42
|
-
data-slot="collapsible"
|
|
43
|
-
>
|
|
44
|
-
<slot />
|
|
45
|
-
</div>
|
|
46
|
-
|
|
47
|
-
<script>
|
|
48
|
-
type CollapsibleState = "open" | "closed";
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Handles the functionality of a collapsible component.
|
|
52
|
-
* Manages open/close state and accessibility attributes.
|
|
53
|
-
*/
|
|
54
|
-
class CollapsibleHandler {
|
|
55
|
-
private root: HTMLElement;
|
|
56
|
-
private trigger: HTMLElement | null;
|
|
57
|
-
private content: HTMLElement | null;
|
|
58
|
-
private collapsibleId: string;
|
|
59
|
-
|
|
60
|
-
constructor(root: HTMLElement, idx: number) {
|
|
61
|
-
this.root = root;
|
|
62
|
-
this.collapsibleId = `starwind-collapsible-${idx}`;
|
|
63
|
-
|
|
64
|
-
this.trigger = root.querySelector<HTMLElement>(".starwind-collapsible-trigger");
|
|
65
|
-
this.content = root.querySelector<HTMLElement>(".starwind-collapsible-content");
|
|
66
|
-
|
|
67
|
-
if (this.trigger && this.content) {
|
|
68
|
-
this.setupAccessibility();
|
|
69
|
-
this.setupEventListeners();
|
|
70
|
-
this.setInitialState();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
private setupAccessibility(): void {
|
|
75
|
-
if (!this.trigger || !this.content) return;
|
|
76
|
-
|
|
77
|
-
const triggerId = `${this.collapsibleId}-trigger`;
|
|
78
|
-
const contentId = `${this.collapsibleId}-content`;
|
|
79
|
-
|
|
80
|
-
// Use "set if missing" semantics for IDs
|
|
81
|
-
if (!this.trigger.id) this.trigger.id = triggerId;
|
|
82
|
-
if (!this.content.id) this.content.id = contentId;
|
|
83
|
-
|
|
84
|
-
// Use actual IDs (consumer-provided or generated) for ARIA
|
|
85
|
-
this.trigger.setAttribute("aria-controls", this.content.id);
|
|
86
|
-
this.content.setAttribute("aria-labelledby", this.trigger.id);
|
|
87
|
-
this.content.setAttribute("role", "region");
|
|
88
|
-
|
|
89
|
-
this.updateAriaExpanded();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
private setInitialState(): void {
|
|
93
|
-
const isOpen = this.root.dataset.state === "open";
|
|
94
|
-
this.setState(isOpen);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
private setupEventListeners(): void {
|
|
98
|
-
if (!this.trigger) return;
|
|
99
|
-
|
|
100
|
-
this.trigger.addEventListener("click", () => {
|
|
101
|
-
if (this.root.dataset.disabled !== undefined) return;
|
|
102
|
-
this.toggle();
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
private toggle(): void {
|
|
107
|
-
const isOpen = this.root.dataset.state === "open";
|
|
108
|
-
this.setState(!isOpen);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
private setState(isOpen: boolean): void {
|
|
112
|
-
const state: CollapsibleState = isOpen ? "open" : "closed";
|
|
113
|
-
|
|
114
|
-
this.root.dataset.state = state;
|
|
115
|
-
|
|
116
|
-
if (this.trigger) {
|
|
117
|
-
this.trigger.dataset.state = state;
|
|
118
|
-
if (isOpen) {
|
|
119
|
-
this.trigger.dataset.panelOpen = "";
|
|
120
|
-
} else {
|
|
121
|
-
delete this.trigger.dataset.panelOpen;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (this.content) {
|
|
126
|
-
this.content.dataset.state = state;
|
|
127
|
-
if (isOpen) {
|
|
128
|
-
this.content.hidden = false;
|
|
129
|
-
} else {
|
|
130
|
-
this.content.hidden = true;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
this.updateAriaExpanded();
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
private updateAriaExpanded(): void {
|
|
138
|
-
if (!this.trigger) return;
|
|
139
|
-
const isOpen = this.root.dataset.state === "open";
|
|
140
|
-
this.trigger.setAttribute("aria-expanded", isOpen.toString());
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const collapsibleInstances = new WeakMap<HTMLElement, CollapsibleHandler>();
|
|
145
|
-
let collapsibleCounter = 0;
|
|
146
|
-
|
|
147
|
-
const setupCollapsibles = () => {
|
|
148
|
-
document.querySelectorAll<HTMLElement>(".starwind-collapsible").forEach((collapsible) => {
|
|
149
|
-
if (!collapsibleInstances.has(collapsible)) {
|
|
150
|
-
collapsibleInstances.set(
|
|
151
|
-
collapsible,
|
|
152
|
-
new CollapsibleHandler(collapsible, collapsibleCounter++),
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
setupCollapsibles();
|
|
159
|
-
document.addEventListener("astro:after-swap", setupCollapsibles);
|
|
160
|
-
document.addEventListener("starwind:init", setupCollapsibles);
|
|
161
|
-
</script>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { HTMLAttributes } from "astro/types";
|
|
3
|
-
import { cv } from "css-variants";
|
|
4
|
-
|
|
5
|
-
type Props = HTMLAttributes<"div">;
|
|
6
|
-
|
|
7
|
-
export const collapsibleContent = cv({
|
|
8
|
-
base: "starwind-collapsible-content",
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
const { class: className, ...rest } = Astro.props;
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
<div
|
|
15
|
-
class:list={[collapsibleContent(), className]}
|
|
16
|
-
data-state="closed"
|
|
17
|
-
hidden
|
|
18
|
-
{...rest}
|
|
19
|
-
data-slot="collapsible-content"
|
|
20
|
-
>
|
|
21
|
-
<slot />
|
|
22
|
-
</div>
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { HTMLAttributes } from "astro/types";
|
|
3
|
-
import { cv } from "css-variants";
|
|
4
|
-
|
|
5
|
-
type Props = HTMLAttributes<"button"> & {
|
|
6
|
-
/**
|
|
7
|
-
* When true, renders as a wrapper div instead of a button,
|
|
8
|
-
* allowing a custom trigger element as a child
|
|
9
|
-
*/
|
|
10
|
-
asChild?: boolean;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const collapsibleTrigger = cv({
|
|
14
|
-
base: "starwind-collapsible-trigger",
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
const { class: className, asChild = false, ...rest } = Astro.props;
|
|
18
|
-
|
|
19
|
-
let hasChildren = false;
|
|
20
|
-
if (Astro.slots.has("default")) {
|
|
21
|
-
hasChildren = true;
|
|
22
|
-
}
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
{
|
|
26
|
-
asChild && hasChildren ? (
|
|
27
|
-
<div
|
|
28
|
-
class:list={[collapsibleTrigger(), className]}
|
|
29
|
-
data-slot="collapsible-trigger"
|
|
30
|
-
data-as-child
|
|
31
|
-
>
|
|
32
|
-
<slot />
|
|
33
|
-
</div>
|
|
34
|
-
) : (
|
|
35
|
-
<button
|
|
36
|
-
type="button"
|
|
37
|
-
class:list={[collapsibleTrigger(), className]}
|
|
38
|
-
{...rest}
|
|
39
|
-
data-slot="collapsible-trigger"
|
|
40
|
-
>
|
|
41
|
-
<slot />
|
|
42
|
-
</button>
|
|
43
|
-
)
|
|
44
|
-
}
|