@rimelight/ui 0.0.1
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/LICENSE +21 -0
- package/README.md +30 -0
- package/i18n-data.json +186 -0
- package/package.json +49 -0
- package/src/components/FormattedDate.astro +22 -0
- package/src/components/HeaderLink.astro +24 -0
- package/src/components/HttpObservatory.astro +103 -0
- package/src/components/LighthouseScores.astro +204 -0
- package/src/components/MissingTranslationBanner.astro +39 -0
- package/src/components/TableOfContents.astro +106 -0
- package/src/components/ThemeToggle.astro +71 -0
- package/src/components/accordion/Accordion.astro +257 -0
- package/src/components/accordion/AccordionContent.astro +34 -0
- package/src/components/accordion/AccordionItem.astro +29 -0
- package/src/components/accordion/AccordionTrigger.astro +33 -0
- package/src/components/alert/Alert.astro +34 -0
- package/src/components/alert/AlertDescription.astro +15 -0
- package/src/components/alert/AlertTitle.astro +17 -0
- package/src/components/alert-dialog/AlertDialog.astro +275 -0
- package/src/components/alert-dialog/AlertDialogAction.astro +46 -0
- package/src/components/alert-dialog/AlertDialogCancel.astro +46 -0
- package/src/components/alert-dialog/AlertDialogContent.astro +52 -0
- package/src/components/alert-dialog/AlertDialogDescription.astro +18 -0
- package/src/components/alert-dialog/AlertDialogFooter.astro +16 -0
- package/src/components/alert-dialog/AlertDialogHeader.astro +14 -0
- package/src/components/alert-dialog/AlertDialogTitle.astro +20 -0
- package/src/components/alert-dialog/AlertDialogTrigger.astro +47 -0
- package/src/components/aspect-ratio/AspectRatio.astro +32 -0
- package/src/components/avatar/Avatar.astro +29 -0
- package/src/components/avatar/AvatarFallback.astro +18 -0
- package/src/components/avatar/AvatarImage.astro +66 -0
- package/src/components/badge/Badge.astro +57 -0
- package/src/components/breadcrumb/Breadcrumb.astro +12 -0
- package/src/components/breadcrumb/BreadcrumbEllipsis.astro +29 -0
- package/src/components/breadcrumb/BreadcrumbItem.astro +15 -0
- package/src/components/breadcrumb/BreadcrumbLink.astro +24 -0
- package/src/components/breadcrumb/BreadcrumbList.astro +17 -0
- package/src/components/breadcrumb/BreadcrumbPage.astro +22 -0
- package/src/components/breadcrumb/BreadcrumbSeparator.astro +24 -0
- package/src/components/button/Button.astro +58 -0
- package/src/components/button-group/ButtonGroup.astro +64 -0
- package/src/components/button-group/ButtonGroupSeparator.astro +20 -0
- package/src/components/button-group/ButtonGroupText.astro +19 -0
- package/src/components/card/Card.astro +36 -0
- package/src/components/card/CardAction.astro +16 -0
- package/src/components/card/CardContent.astro +16 -0
- package/src/components/card/CardDescription.astro +16 -0
- package/src/components/card/CardFooter.astro +16 -0
- package/src/components/card/CardHeader.astro +19 -0
- package/src/components/card/CardTitle.astro +16 -0
- package/src/components/carousel/Carousel.astro +55 -0
- package/src/components/carousel/CarouselContent.astro +26 -0
- package/src/components/carousel/CarouselItem.astro +26 -0
- package/src/components/carousel/CarouselNext.astro +39 -0
- package/src/components/carousel/CarouselPrevious.astro +41 -0
- package/src/components/carousel/carousel-script.ts +188 -0
- package/src/components/carousel/index.ts +1 -0
- package/src/components/checkbox/Checkbox.astro +133 -0
- package/src/components/collapsible/Collapsible.astro +161 -0
- package/src/components/collapsible/CollapsibleContent.astro +22 -0
- package/src/components/collapsible/CollapsibleTrigger.astro +44 -0
- package/src/components/dialog/Dialog.astro +389 -0
- package/src/components/dialog/DialogClose.astro +35 -0
- package/src/components/dialog/DialogContent.astro +78 -0
- package/src/components/dialog/DialogDescription.astro +14 -0
- package/src/components/dialog/DialogFooter.astro +14 -0
- package/src/components/dialog/DialogHeader.astro +14 -0
- package/src/components/dialog/DialogTitle.astro +18 -0
- package/src/components/dialog/DialogTrigger.astro +47 -0
- package/src/components/dropdown/Dropdown.astro +604 -0
- package/src/components/dropdown/DropdownContent.astro +118 -0
- package/src/components/dropdown/DropdownItem.astro +48 -0
- package/src/components/dropdown/DropdownLabel.astro +29 -0
- package/src/components/dropdown/DropdownSeparator.astro +21 -0
- package/src/components/dropdown/DropdownShortcut.astro +17 -0
- package/src/components/dropdown/DropdownSub.astro +15 -0
- package/src/components/dropdown/DropdownSubContent.astro +39 -0
- package/src/components/dropdown/DropdownSubTrigger.astro +34 -0
- package/src/components/dropdown/DropdownTrigger.astro +52 -0
- package/src/components/dropzone/Dropzone.astro +236 -0
- package/src/components/dropzone/DropzoneFilesList.astro +26 -0
- package/src/components/dropzone/DropzoneLoadingIndicator.astro +10 -0
- package/src/components/dropzone/DropzoneUploadIndicator.astro +10 -0
- package/src/components/embeds/YoutubeEmbed.astro +94 -0
- package/src/components/hero/Hero.astro +166 -0
- package/src/components/icons/Flag.astro +62 -0
- package/src/components/image/ExtendedImage.astro +46 -0
- package/src/components/image/Image.astro +25 -0
- package/src/components/input/Input.astro +27 -0
- package/src/components/input-group/InputGroup.astro +28 -0
- package/src/components/input-group/InputGroupAddon.astro +76 -0
- package/src/components/input-group/InputGroupButton.astro +36 -0
- package/src/components/input-group/InputGroupInput.astro +18 -0
- package/src/components/input-group/InputGroupText.astro +17 -0
- package/src/components/input-group/InputGroupTextarea.astro +22 -0
- package/src/components/input-otp/InputOtp.astro +352 -0
- package/src/components/input-otp/InputOtpGroup.astro +16 -0
- package/src/components/input-otp/InputOtpSeparator.astro +25 -0
- package/src/components/input-otp/InputOtpSlot.astro +50 -0
- package/src/components/input-otp/InputOtpTypes.ts +6 -0
- package/src/components/item/Item.astro +52 -0
- package/src/components/item/ItemActions.astro +16 -0
- package/src/components/item/ItemContent.astro +16 -0
- package/src/components/item/ItemDescription.astro +19 -0
- package/src/components/item/ItemFooter.astro +16 -0
- package/src/components/item/ItemGroup.astro +16 -0
- package/src/components/item/ItemHeader.astro +16 -0
- package/src/components/item/ItemMedia.astro +40 -0
- package/src/components/item/ItemSeparator.astro +23 -0
- package/src/components/item/ItemTitle.astro +16 -0
- package/src/components/kbd/Kbd.astro +21 -0
- package/src/components/kbd/KbdGroup.astro +16 -0
- package/src/components/label/Label.astro +24 -0
- package/src/components/marquee/Marquee.astro +73 -0
- package/src/components/native-select/NativeSelect.astro +68 -0
- package/src/components/native-select/NativeSelectOptGroup.astro +15 -0
- package/src/components/native-select/NativeSelectOption.astro +15 -0
- package/src/components/pagination/Pagination.astro +20 -0
- package/src/components/pagination/PaginationContent.astro +16 -0
- package/src/components/pagination/PaginationEllipsis.astro +37 -0
- package/src/components/pagination/PaginationItem.astro +16 -0
- package/src/components/pagination/PaginationLink.astro +27 -0
- package/src/components/pagination/PaginationNext.astro +33 -0
- package/src/components/pagination/PaginationPrevious.astro +33 -0
- package/src/components/popover/Popover.astro +717 -0
- package/src/components/popover/PopoverContent.astro +102 -0
- package/src/components/popover/PopoverDescription.astro +14 -0
- package/src/components/popover/PopoverHeader.astro +14 -0
- package/src/components/popover/PopoverTitle.astro +14 -0
- package/src/components/popover/PopoverTrigger.astro +51 -0
- package/src/components/progress/Progress.astro +154 -0
- package/src/components/prose/Prose.astro +619 -0
- package/src/components/radio-group/RadioGroup.astro +162 -0
- package/src/components/radio-group/RadioGroupItem.astro +133 -0
- package/src/components/radio-group/RadioGroupTypes.ts +6 -0
- package/src/components/section/Section.astro +167 -0
- package/src/components/select/Select.astro +752 -0
- package/src/components/select/SelectContent.astro +94 -0
- package/src/components/select/SelectGroup.astro +9 -0
- package/src/components/select/SelectItem.astro +51 -0
- package/src/components/select/SelectLabel.astro +14 -0
- package/src/components/select/SelectSearch.astro +49 -0
- package/src/components/select/SelectSeparator.astro +12 -0
- package/src/components/select/SelectTrigger.astro +56 -0
- package/src/components/select/SelectTypes.ts +13 -0
- package/src/components/select/SelectValue.astro +19 -0
- package/src/components/separator/Separator.astro +36 -0
- package/src/components/sheet/Sheet.astro +15 -0
- package/src/components/sheet/SheetClose.astro +15 -0
- package/src/components/sheet/SheetContent.astro +89 -0
- package/src/components/sheet/SheetDescription.astro +16 -0
- package/src/components/sheet/SheetFooter.astro +16 -0
- package/src/components/sheet/SheetHeader.astro +16 -0
- package/src/components/sheet/SheetTitle.astro +16 -0
- package/src/components/sheet/SheetTrigger.astro +15 -0
- package/src/components/sidebar/Sidebar.astro +231 -0
- package/src/components/sidebar/SidebarContent.astro +25 -0
- package/src/components/sidebar/SidebarFooter.astro +22 -0
- package/src/components/sidebar/SidebarGroup.astro +22 -0
- package/src/components/sidebar/SidebarGroupContent.astro +22 -0
- package/src/components/sidebar/SidebarGroupLabel.astro +53 -0
- package/src/components/sidebar/SidebarHeader.astro +22 -0
- package/src/components/sidebar/SidebarInput.astro +24 -0
- package/src/components/sidebar/SidebarInset.astro +22 -0
- package/src/components/sidebar/SidebarMenu.astro +22 -0
- package/src/components/sidebar/SidebarMenuAction.astro +63 -0
- package/src/components/sidebar/SidebarMenuBadge.astro +31 -0
- package/src/components/sidebar/SidebarMenuButton.astro +124 -0
- package/src/components/sidebar/SidebarMenuItem.astro +22 -0
- package/src/components/sidebar/SidebarMenuSkeleton.astro +43 -0
- package/src/components/sidebar/SidebarMenuSub.astro +25 -0
- package/src/components/sidebar/SidebarMenuSubButton.astro +52 -0
- package/src/components/sidebar/SidebarMenuSubItem.astro +17 -0
- package/src/components/sidebar/SidebarProvider.astro +215 -0
- package/src/components/sidebar/SidebarRail.astro +72 -0
- package/src/components/sidebar/SidebarSeparator.astro +25 -0
- package/src/components/sidebar/SidebarTrigger.astro +69 -0
- package/src/components/skeleton/Skeleton.astro +14 -0
- package/src/components/slider/Slider.astro +425 -0
- package/src/components/spinner/Spinner.astro +23 -0
- package/src/components/switch/Switch.astro +192 -0
- package/src/components/switch/SwitchTypes.ts +6 -0
- package/src/components/table/Table.astro +20 -0
- package/src/components/table/TableBody.astro +18 -0
- package/src/components/table/TableCaption.astro +18 -0
- package/src/components/table/TableCell.astro +18 -0
- package/src/components/table/TableFoot.astro +18 -0
- package/src/components/table/TableHead.astro +18 -0
- package/src/components/table/TableHeader.astro +18 -0
- package/src/components/table/TableRow.astro +17 -0
- package/src/components/tabs/Tabs.astro +270 -0
- package/src/components/tabs/TabsContent.astro +28 -0
- package/src/components/tabs/TabsList.astro +23 -0
- package/src/components/tabs/TabsTrigger.astro +34 -0
- package/src/components/textarea/Textarea.astro +31 -0
- package/src/components/toast/ToastDescription.astro +22 -0
- package/src/components/toast/ToastItem.astro +56 -0
- package/src/components/toast/ToastTemplate.astro +27 -0
- package/src/components/toast/ToastTitle.astro +59 -0
- package/src/components/toast/Toaster.astro +981 -0
- package/src/components/toast/index.ts +1 -0
- package/src/components/toast/toast-manager.ts +234 -0
- package/src/components/toggle/Toggle.astro +174 -0
- package/src/components/toggle/ToggleTypes.ts +14 -0
- package/src/components/tooltip/Tooltip.astro +422 -0
- package/src/components/tooltip/TooltipContent.astro +83 -0
- package/src/components/tooltip/TooltipTrigger.astro +13 -0
- package/src/components/video/Video.astro +121 -0
- package/src/config/cookies.ts +5 -0
- package/src/config/index.ts +3 -0
- package/src/config/links.ts +4 -0
- package/src/config/site.config.ts +45 -0
- package/src/domain/cms/index.ts +1 -0
- package/src/domain/cms/types.ts +20 -0
- package/src/domain/i18n/constants.ts +21 -0
- package/src/domain/i18n/cookie-storage.ts +13 -0
- package/src/domain/i18n/country-to-locale-map.ts +67 -0
- package/src/domain/i18n/fallbacks.generated.ts +230 -0
- package/src/domain/i18n/fetcher.ts +268 -0
- package/src/domain/i18n/flags.ts +16 -0
- package/src/domain/i18n/format.ts +90 -0
- package/src/domain/i18n/index.ts +10 -0
- package/src/domain/i18n/middleware/i18n.ts +160 -0
- package/src/domain/i18n/resolve-locale.ts +55 -0
- package/src/domain/i18n/runtime-constants.ts +14 -0
- package/src/domain/i18n/schema.ts +29 -0
- package/src/domain/index.ts +4 -0
- package/src/domain/seo/constants.ts +20 -0
- package/src/domain/seo/index.ts +3 -0
- package/src/domain/seo/services/index.ts +3 -0
- package/src/domain/seo/services/llms.ts +53 -0
- package/src/domain/seo/services/robots.ts +12 -0
- package/src/domain/seo/services/sitemap.ts +56 -0
- package/src/domain/seo/utils.ts +37 -0
- package/src/domain/theme/constants.ts +6 -0
- package/src/domain/theme/index.ts +2 -0
- package/src/domain/theme/schema.ts +10 -0
- package/src/env.d.ts +49 -0
- package/src/i18n.generated.d.ts +202 -0
- package/src/lib/component-preview.ts +73 -0
- package/src/lib/index.ts +6 -0
- package/src/lib/remark/remark-modified-time.ts +13 -0
- package/src/lib/showcase-preview-elements.ts +408 -0
- package/src/lib/showcase-renderer.ts +218 -0
- package/src/lib/showcase-utils.ts +189 -0
- package/src/lib/turnstile.ts +35 -0
- package/src/lib/utils/starwind/positioning.ts +318 -0
- package/src/locales/de/blog.json +9 -0
- package/src/locales/de/common.json +19 -0
- package/src/locales/de/errors.json +6 -0
- package/src/locales/de/home.json +20 -0
- package/src/locales/de/messages.json +8 -0
- package/src/locales/de/nav.json +13 -0
- package/src/locales/de/projects.json +9 -0
- package/src/locales/de/services.json +43 -0
- package/src/locales/en/blog.json +9 -0
- package/src/locales/en/chat.json +29 -0
- package/src/locales/en/common.json +19 -0
- package/src/locales/en/cookie_notice.json +11 -0
- package/src/locales/en/editor.json +24 -0
- package/src/locales/en/errors.json +6 -0
- package/src/locales/en/home.json +20 -0
- package/src/locales/en/messages.json +8 -0
- package/src/locales/en/nav.json +13 -0
- package/src/locales/en/projects.json +9 -0
- package/src/locales/en/services.json +43 -0
- package/src/locales/es/blog.json +9 -0
- package/src/locales/es/common.json +19 -0
- package/src/locales/es/errors.json +6 -0
- package/src/locales/es/home.json +20 -0
- package/src/locales/es/messages.json +8 -0
- package/src/locales/es/nav.json +13 -0
- package/src/locales/es/projects.json +9 -0
- package/src/locales/es/services.json +43 -0
- package/src/locales/ja/blog.json +9 -0
- package/src/locales/ja/common.json +19 -0
- package/src/locales/ja/errors.json +6 -0
- package/src/locales/ja/home.json +20 -0
- package/src/locales/ja/messages.json +8 -0
- package/src/locales/ja/nav.json +13 -0
- package/src/locales/ja/projects.json +9 -0
- package/src/locales/ja/services.json +43 -0
- package/src/locales/pt/blog.json +9 -0
- package/src/locales/pt/chat.json +29 -0
- package/src/locales/pt/common.json +19 -0
- package/src/locales/pt/cookie_notice.json +11 -0
- package/src/locales/pt/editor.json +24 -0
- package/src/locales/pt/errors.json +6 -0
- package/src/locales/pt/home.json +20 -0
- package/src/locales/pt/messages.json +8 -0
- package/src/locales/pt/nav.json +13 -0
- package/src/locales/pt/projects.json +9 -0
- package/src/locales/pt/services.json +43 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/server/cookies.ts +98 -0
- package/src/utils/server/index.ts +1 -0
- package/src/utils/shared/deep-merge.ts +36 -0
- package/src/utils/shared/embed.ts +105 -0
- package/src/utils/shared/index.ts +3 -0
- package/src/utils/shared/parse-boolean.ts +14 -0
- package/worker-configuration.d.ts +14791 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamic Component Renderer for Showcase
|
|
3
|
+
*
|
|
4
|
+
* This module handles runtime prop updates for Astro components in the showcase. It works by
|
|
5
|
+
* re-rendering the component with updated props using Astro's client:only components.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface PropState {
|
|
9
|
+
value: any
|
|
10
|
+
omitted: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface PropDefinition {
|
|
14
|
+
name: string
|
|
15
|
+
type: string
|
|
16
|
+
default?: any
|
|
17
|
+
description?: string
|
|
18
|
+
kind: "string" | "number" | "boolean" | "enum" | "array" | "object" | "function"
|
|
19
|
+
enumValues?: string[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function makePropDefinition(
|
|
23
|
+
name: string,
|
|
24
|
+
type: string,
|
|
25
|
+
kind: PropDefinition["kind"],
|
|
26
|
+
defaultValue: any,
|
|
27
|
+
description: string | undefined,
|
|
28
|
+
enumValues: string[] | undefined
|
|
29
|
+
): PropDefinition {
|
|
30
|
+
const result: PropDefinition = {
|
|
31
|
+
name,
|
|
32
|
+
type,
|
|
33
|
+
kind
|
|
34
|
+
}
|
|
35
|
+
if (defaultValue !== undefined) result.default = defaultValue
|
|
36
|
+
if (description !== undefined) result.description = description
|
|
37
|
+
if (enumValues !== undefined) result.enumValues = enumValues
|
|
38
|
+
return result
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function assertPropInfo(
|
|
42
|
+
obj: unknown
|
|
43
|
+
): asserts obj is { type?: string; default?: unknown; description?: string } {
|
|
44
|
+
if (!obj || typeof obj !== "object") throw new Error("Expected prop info")
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Parse a component's props from its exported interface or default export This is a helper to
|
|
49
|
+
* extract prop metadata at build time
|
|
50
|
+
*/
|
|
51
|
+
export function parseComponentProps(_componentModule: any): PropDefinition[] {
|
|
52
|
+
const props: PropDefinition[] = []
|
|
53
|
+
|
|
54
|
+
// Try to get props from component's default export or metadata
|
|
55
|
+
if (_componentModule?.metadata?.props) {
|
|
56
|
+
const metadataProps = _componentModule.metadata.props
|
|
57
|
+
for (const [name, info] of Object.entries(metadataProps)) {
|
|
58
|
+
assertPropInfo(info)
|
|
59
|
+
const propInfo = info
|
|
60
|
+
props.push(
|
|
61
|
+
makePropDefinition(
|
|
62
|
+
name,
|
|
63
|
+
propInfo.type || "unknown",
|
|
64
|
+
inferPropKind(propInfo.type || "unknown"),
|
|
65
|
+
propInfo.default,
|
|
66
|
+
propInfo.description,
|
|
67
|
+
extractEnumValues(propInfo.type || "")
|
|
68
|
+
)
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return props
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Infer the prop kind from TypeScript type string
|
|
78
|
+
*/
|
|
79
|
+
function inferPropKind(typeString: string): PropDefinition["kind"] {
|
|
80
|
+
if (!typeString) return "string"
|
|
81
|
+
|
|
82
|
+
const type = typeString.toLowerCase()
|
|
83
|
+
|
|
84
|
+
if (type === "boolean") return "boolean"
|
|
85
|
+
if (type === "number") return "number"
|
|
86
|
+
if (type === "string") return "string"
|
|
87
|
+
if (type.includes("[]") || type === "array") return "array"
|
|
88
|
+
if (type.includes("|") && !type.includes("=>")) {
|
|
89
|
+
// Union type - likely an enum
|
|
90
|
+
return "enum"
|
|
91
|
+
}
|
|
92
|
+
if (type.includes("=>")) return "function"
|
|
93
|
+
if (type.startsWith("{") || type === "object" || type === "record") return "object"
|
|
94
|
+
|
|
95
|
+
return "string"
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Extract enum values from a union type string
|
|
100
|
+
*/
|
|
101
|
+
function extractEnumValues(typeString: string): string[] | undefined {
|
|
102
|
+
if (!typeString || !typeString.includes("|")) return undefined
|
|
103
|
+
|
|
104
|
+
// Parse union types like: "'default' | 'primary' | 'secondary'"
|
|
105
|
+
const matches = typeString.match(/'([^']+)'|"([^"]+)"/g)
|
|
106
|
+
if (matches) {
|
|
107
|
+
return matches.map((m) => m.replace(/['"]/g, ""))
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return undefined
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Generate default prop definitions for common component patterns
|
|
115
|
+
*/
|
|
116
|
+
export function generatePropDefinitions(
|
|
117
|
+
_componentName: string,
|
|
118
|
+
options: {
|
|
119
|
+
stringProps?: string[]
|
|
120
|
+
booleanProps?: string[]
|
|
121
|
+
enumProps?: Record<string, string[]>
|
|
122
|
+
defaultProps?: Record<string, any>
|
|
123
|
+
descriptions?: Record<string, string>
|
|
124
|
+
} = {}
|
|
125
|
+
): PropDefinition[] {
|
|
126
|
+
const props: PropDefinition[] = []
|
|
127
|
+
|
|
128
|
+
// Add string props
|
|
129
|
+
options.stringProps?.forEach((name) => {
|
|
130
|
+
props.push(
|
|
131
|
+
makePropDefinition(
|
|
132
|
+
name,
|
|
133
|
+
"string",
|
|
134
|
+
"string",
|
|
135
|
+
options.defaultProps?.[name],
|
|
136
|
+
options.descriptions?.[name],
|
|
137
|
+
undefined
|
|
138
|
+
)
|
|
139
|
+
)
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
// Add boolean props
|
|
143
|
+
options.booleanProps?.forEach((name) => {
|
|
144
|
+
props.push(
|
|
145
|
+
makePropDefinition(
|
|
146
|
+
name,
|
|
147
|
+
"boolean",
|
|
148
|
+
"boolean",
|
|
149
|
+
options.defaultProps?.[name],
|
|
150
|
+
options.descriptions?.[name],
|
|
151
|
+
undefined
|
|
152
|
+
)
|
|
153
|
+
)
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
// Add enum props
|
|
157
|
+
if (options.enumProps) {
|
|
158
|
+
Object.entries(options.enumProps).forEach(([name, values]) => {
|
|
159
|
+
props.push(
|
|
160
|
+
makePropDefinition(
|
|
161
|
+
name,
|
|
162
|
+
values.map((v) => `'${v}'`).join(" | "),
|
|
163
|
+
"enum",
|
|
164
|
+
options.defaultProps?.[name],
|
|
165
|
+
options.descriptions?.[name],
|
|
166
|
+
values
|
|
167
|
+
)
|
|
168
|
+
)
|
|
169
|
+
})
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return props
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Create a render function for a component This returns HTML string that can be injected into the
|
|
177
|
+
* preview container
|
|
178
|
+
*/
|
|
179
|
+
export function createRenderer(_componentModule: any) {
|
|
180
|
+
return function render(_props: Record<string, any>): string {
|
|
181
|
+
// For Astro components, we need to use their rendering mechanism
|
|
182
|
+
// This is a placeholder - actual implementation depends on how components are structured
|
|
183
|
+
return `<div data-component-render="true" data-props="${encodeURIComponent(JSON.stringify(_props))}"></div>`
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Helper to build common prop configurations
|
|
189
|
+
*/
|
|
190
|
+
export const PropConfigs = {
|
|
191
|
+
/**
|
|
192
|
+
* Standard variant/size props for UI components
|
|
193
|
+
*/
|
|
194
|
+
ui: {
|
|
195
|
+
variant: {
|
|
196
|
+
values: ["default", "primary", "secondary", "outline", "ghost"] as string[],
|
|
197
|
+
default: "default"
|
|
198
|
+
},
|
|
199
|
+
size: {
|
|
200
|
+
values: ["sm", "md", "lg"] as string[],
|
|
201
|
+
default: "md"
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Layout props
|
|
207
|
+
*/
|
|
208
|
+
layout: {
|
|
209
|
+
orientation: {
|
|
210
|
+
values: ["vertical", "horizontal"] as string[],
|
|
211
|
+
default: "vertical"
|
|
212
|
+
},
|
|
213
|
+
alignment: {
|
|
214
|
+
values: ["left", "center", "right"] as string[],
|
|
215
|
+
default: "center"
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Showcase Utilities
|
|
3
|
+
*
|
|
4
|
+
* Helper functions for defining component prop configurations
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface PropDef {
|
|
8
|
+
name: string
|
|
9
|
+
type: string
|
|
10
|
+
default?: any
|
|
11
|
+
description?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function makePropDef(
|
|
15
|
+
name: string,
|
|
16
|
+
type: string,
|
|
17
|
+
defaultValue: any,
|
|
18
|
+
description: string | undefined
|
|
19
|
+
): PropDef {
|
|
20
|
+
const result: PropDef = {
|
|
21
|
+
name,
|
|
22
|
+
type
|
|
23
|
+
}
|
|
24
|
+
if (defaultValue !== undefined) result.default = defaultValue
|
|
25
|
+
if (description !== undefined) result.description = description
|
|
26
|
+
return result
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Create prop definitions for string props
|
|
31
|
+
*/
|
|
32
|
+
export function stringProp(
|
|
33
|
+
name: string,
|
|
34
|
+
options: {
|
|
35
|
+
default?: string
|
|
36
|
+
description?: string
|
|
37
|
+
} = {}
|
|
38
|
+
): PropDef {
|
|
39
|
+
return makePropDef(name, "string", options.default, options.description)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Create prop definitions for boolean props
|
|
44
|
+
*/
|
|
45
|
+
export function booleanProp(
|
|
46
|
+
name: string,
|
|
47
|
+
options: {
|
|
48
|
+
default?: boolean
|
|
49
|
+
description?: string
|
|
50
|
+
} = {}
|
|
51
|
+
): PropDef {
|
|
52
|
+
return makePropDef(name, "boolean", options.default, options.description)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Create prop definitions for number props
|
|
57
|
+
*/
|
|
58
|
+
export function numberProp(
|
|
59
|
+
name: string,
|
|
60
|
+
options: {
|
|
61
|
+
default?: number
|
|
62
|
+
description?: string
|
|
63
|
+
} = {}
|
|
64
|
+
): PropDef {
|
|
65
|
+
return makePropDef(name, "number", options.default, options.description)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Create prop definitions for enum (union type) props
|
|
70
|
+
*/
|
|
71
|
+
export function enumProp(
|
|
72
|
+
name: string,
|
|
73
|
+
values: string[],
|
|
74
|
+
options: {
|
|
75
|
+
default?: string
|
|
76
|
+
description?: string
|
|
77
|
+
} = {}
|
|
78
|
+
): PropDef {
|
|
79
|
+
return makePropDef(
|
|
80
|
+
name,
|
|
81
|
+
values.map((v) => `'${v}'`).join(" | "),
|
|
82
|
+
options.default,
|
|
83
|
+
options.description
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Create prop definitions for array props
|
|
89
|
+
*/
|
|
90
|
+
export function arrayProp(
|
|
91
|
+
name: string,
|
|
92
|
+
options: {
|
|
93
|
+
default?: any[]
|
|
94
|
+
description?: string
|
|
95
|
+
} = {}
|
|
96
|
+
): PropDef {
|
|
97
|
+
return makePropDef(name, "array", options.default, options.description)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Create prop definitions for object props
|
|
102
|
+
*/
|
|
103
|
+
export function objectProp(
|
|
104
|
+
name: string,
|
|
105
|
+
options: {
|
|
106
|
+
default?: Record<string, any>
|
|
107
|
+
description?: string
|
|
108
|
+
} = {}
|
|
109
|
+
): PropDef {
|
|
110
|
+
return makePropDef(name, "object", options.default, options.description)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Build common UI component props (variant, size)
|
|
115
|
+
*/
|
|
116
|
+
export function uiProps(
|
|
117
|
+
options: {
|
|
118
|
+
variantValues?: string[]
|
|
119
|
+
sizeValues?: string[]
|
|
120
|
+
defaultVariant?: string
|
|
121
|
+
defaultSize?: string
|
|
122
|
+
} = {}
|
|
123
|
+
): PropDef[] {
|
|
124
|
+
const props: PropDef[] = []
|
|
125
|
+
|
|
126
|
+
if (options.variantValues) {
|
|
127
|
+
props.push(
|
|
128
|
+
enumProp("variant", options.variantValues, {
|
|
129
|
+
default: options.defaultVariant ?? "default",
|
|
130
|
+
description: "The visual style variant of the component."
|
|
131
|
+
})
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (options.sizeValues) {
|
|
136
|
+
props.push(
|
|
137
|
+
enumProp("size", options.sizeValues, {
|
|
138
|
+
default: options.defaultSize ?? "md",
|
|
139
|
+
description: "The size of the component."
|
|
140
|
+
})
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return props
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Build common layout props (orientation, alignment, inverted)
|
|
149
|
+
*/
|
|
150
|
+
export function layoutProps(
|
|
151
|
+
options: {
|
|
152
|
+
orientationValues?: string[]
|
|
153
|
+
alignmentValues?: string[]
|
|
154
|
+
defaultOrientation?: string
|
|
155
|
+
defaultAlignment?: string
|
|
156
|
+
includeInverted?: boolean
|
|
157
|
+
} = {}
|
|
158
|
+
): PropDef[] {
|
|
159
|
+
const props: PropDef[] = []
|
|
160
|
+
|
|
161
|
+
if (options.orientationValues) {
|
|
162
|
+
props.push(
|
|
163
|
+
enumProp("orientation", options.orientationValues, {
|
|
164
|
+
default: options.defaultOrientation ?? "vertical",
|
|
165
|
+
description: "The layout orientation of the component."
|
|
166
|
+
})
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (options.alignmentValues) {
|
|
171
|
+
props.push(
|
|
172
|
+
enumProp("alignment", options.alignmentValues, {
|
|
173
|
+
default: options.defaultAlignment ?? "center",
|
|
174
|
+
description: "The content alignment."
|
|
175
|
+
})
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (options.includeInverted) {
|
|
180
|
+
props.push(
|
|
181
|
+
booleanProp("inverted", {
|
|
182
|
+
default: false,
|
|
183
|
+
description: "Inverts the order of content."
|
|
184
|
+
})
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return props
|
|
189
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
interface TurnstileResponse {
|
|
2
|
+
"success": boolean
|
|
3
|
+
"challenge_ts"?: string
|
|
4
|
+
"hostname"?: string
|
|
5
|
+
"error-codes"?: string[]
|
|
6
|
+
"action"?: string
|
|
7
|
+
"cdata"?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Verify a Turnstile token with Cloudflare's API
|
|
12
|
+
*/
|
|
13
|
+
export async function verifyTurnstileToken(
|
|
14
|
+
token: string,
|
|
15
|
+
secretKey: string,
|
|
16
|
+
remoteIP?: string
|
|
17
|
+
): Promise<TurnstileResponse> {
|
|
18
|
+
const response = await fetch("https://challenges.cloudflare.com/turnstile/v0/siteverify", {
|
|
19
|
+
method: "POST",
|
|
20
|
+
headers: {
|
|
21
|
+
"Content-Type": "application/json"
|
|
22
|
+
},
|
|
23
|
+
body: JSON.stringify({
|
|
24
|
+
secret: secretKey,
|
|
25
|
+
response: token,
|
|
26
|
+
remoteip: remoteIP
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
if (!response.ok) {
|
|
31
|
+
throw new Error(`Turnstile API error: ${response.status}`)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return response.json()
|
|
35
|
+
}
|