@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.
Files changed (310) hide show
  1. package/package.json +36 -6
  2. package/src/components/BlogPost.astro +181 -0
  3. package/src/components/DynamicShowcase.astro +681 -0
  4. package/src/components/ExtendedCarousel.astro +107 -0
  5. package/src/components/Head.astro +150 -0
  6. package/src/components/LanguageSwitcher.astro +128 -0
  7. package/src/components/ProjectPost.astro +183 -0
  8. package/src/components/RLHead.astro +3 -0
  9. package/src/components/ThemeToggle.astro +30 -42
  10. package/src/components/astro/RLAButton.astro +85 -0
  11. package/src/components/astro/RLAHeader.astro +75 -0
  12. package/src/components/vue/RLVButton.vue +90 -0
  13. package/src/components/vue/RLVHeader.vue +78 -0
  14. package/src/composables/index.ts +1 -0
  15. package/src/composables/useUi.ts +27 -0
  16. package/src/config/index.ts +0 -2
  17. package/src/config/site.config.ts +1 -1
  18. package/src/env.d.ts +9 -42
  19. package/src/integrations/index.ts +2 -0
  20. package/src/integrations/ui.ts +87 -0
  21. package/src/themes/button.theme.ts +361 -0
  22. package/src/themes/header.theme.ts +33 -0
  23. package/src/themes/index.ts +13 -0
  24. package/src/utils/index.ts +3 -2
  25. package/i18n-data.json +0 -186
  26. package/src/components/accordion/Accordion.astro +0 -257
  27. package/src/components/accordion/AccordionContent.astro +0 -34
  28. package/src/components/accordion/AccordionItem.astro +0 -29
  29. package/src/components/accordion/AccordionTrigger.astro +0 -33
  30. package/src/components/alert/Alert.astro +0 -34
  31. package/src/components/alert/AlertDescription.astro +0 -15
  32. package/src/components/alert/AlertTitle.astro +0 -17
  33. package/src/components/alert-dialog/AlertDialog.astro +0 -275
  34. package/src/components/alert-dialog/AlertDialogAction.astro +0 -46
  35. package/src/components/alert-dialog/AlertDialogCancel.astro +0 -46
  36. package/src/components/alert-dialog/AlertDialogContent.astro +0 -52
  37. package/src/components/alert-dialog/AlertDialogDescription.astro +0 -18
  38. package/src/components/alert-dialog/AlertDialogFooter.astro +0 -16
  39. package/src/components/alert-dialog/AlertDialogHeader.astro +0 -14
  40. package/src/components/alert-dialog/AlertDialogTitle.astro +0 -20
  41. package/src/components/alert-dialog/AlertDialogTrigger.astro +0 -47
  42. package/src/components/aspect-ratio/AspectRatio.astro +0 -32
  43. package/src/components/avatar/Avatar.astro +0 -29
  44. package/src/components/avatar/AvatarFallback.astro +0 -18
  45. package/src/components/avatar/AvatarImage.astro +0 -66
  46. package/src/components/badge/Badge.astro +0 -57
  47. package/src/components/breadcrumb/Breadcrumb.astro +0 -12
  48. package/src/components/breadcrumb/BreadcrumbEllipsis.astro +0 -29
  49. package/src/components/breadcrumb/BreadcrumbItem.astro +0 -15
  50. package/src/components/breadcrumb/BreadcrumbLink.astro +0 -24
  51. package/src/components/breadcrumb/BreadcrumbList.astro +0 -17
  52. package/src/components/breadcrumb/BreadcrumbPage.astro +0 -22
  53. package/src/components/breadcrumb/BreadcrumbSeparator.astro +0 -24
  54. package/src/components/button/Button.astro +0 -58
  55. package/src/components/button-group/ButtonGroup.astro +0 -64
  56. package/src/components/button-group/ButtonGroupSeparator.astro +0 -20
  57. package/src/components/button-group/ButtonGroupText.astro +0 -19
  58. package/src/components/card/Card.astro +0 -36
  59. package/src/components/card/CardAction.astro +0 -16
  60. package/src/components/card/CardContent.astro +0 -16
  61. package/src/components/card/CardDescription.astro +0 -16
  62. package/src/components/card/CardFooter.astro +0 -16
  63. package/src/components/card/CardHeader.astro +0 -19
  64. package/src/components/card/CardTitle.astro +0 -16
  65. package/src/components/carousel/Carousel.astro +0 -55
  66. package/src/components/carousel/CarouselContent.astro +0 -26
  67. package/src/components/carousel/CarouselItem.astro +0 -26
  68. package/src/components/carousel/CarouselNext.astro +0 -39
  69. package/src/components/carousel/CarouselPrevious.astro +0 -41
  70. package/src/components/carousel/carousel-script.ts +0 -188
  71. package/src/components/carousel/index.ts +0 -1
  72. package/src/components/checkbox/Checkbox.astro +0 -133
  73. package/src/components/collapsible/Collapsible.astro +0 -161
  74. package/src/components/collapsible/CollapsibleContent.astro +0 -22
  75. package/src/components/collapsible/CollapsibleTrigger.astro +0 -44
  76. package/src/components/dialog/Dialog.astro +0 -389
  77. package/src/components/dialog/DialogClose.astro +0 -35
  78. package/src/components/dialog/DialogContent.astro +0 -78
  79. package/src/components/dialog/DialogDescription.astro +0 -14
  80. package/src/components/dialog/DialogFooter.astro +0 -14
  81. package/src/components/dialog/DialogHeader.astro +0 -14
  82. package/src/components/dialog/DialogTitle.astro +0 -18
  83. package/src/components/dialog/DialogTrigger.astro +0 -47
  84. package/src/components/dropdown/Dropdown.astro +0 -604
  85. package/src/components/dropdown/DropdownContent.astro +0 -118
  86. package/src/components/dropdown/DropdownItem.astro +0 -48
  87. package/src/components/dropdown/DropdownLabel.astro +0 -29
  88. package/src/components/dropdown/DropdownSeparator.astro +0 -21
  89. package/src/components/dropdown/DropdownShortcut.astro +0 -17
  90. package/src/components/dropdown/DropdownSub.astro +0 -15
  91. package/src/components/dropdown/DropdownSubContent.astro +0 -39
  92. package/src/components/dropdown/DropdownSubTrigger.astro +0 -34
  93. package/src/components/dropdown/DropdownTrigger.astro +0 -52
  94. package/src/components/dropzone/Dropzone.astro +0 -236
  95. package/src/components/dropzone/DropzoneFilesList.astro +0 -26
  96. package/src/components/dropzone/DropzoneLoadingIndicator.astro +0 -10
  97. package/src/components/dropzone/DropzoneUploadIndicator.astro +0 -10
  98. package/src/components/embeds/YoutubeEmbed.astro +0 -94
  99. package/src/components/hero/Hero.astro +0 -166
  100. package/src/components/icons/Flag.astro +0 -62
  101. package/src/components/image/ExtendedImage.astro +0 -46
  102. package/src/components/image/Image.astro +0 -25
  103. package/src/components/input/Input.astro +0 -27
  104. package/src/components/input-group/InputGroup.astro +0 -28
  105. package/src/components/input-group/InputGroupAddon.astro +0 -76
  106. package/src/components/input-group/InputGroupButton.astro +0 -36
  107. package/src/components/input-group/InputGroupInput.astro +0 -18
  108. package/src/components/input-group/InputGroupText.astro +0 -17
  109. package/src/components/input-group/InputGroupTextarea.astro +0 -22
  110. package/src/components/input-otp/InputOtp.astro +0 -352
  111. package/src/components/input-otp/InputOtpGroup.astro +0 -16
  112. package/src/components/input-otp/InputOtpSeparator.astro +0 -25
  113. package/src/components/input-otp/InputOtpSlot.astro +0 -50
  114. package/src/components/input-otp/InputOtpTypes.ts +0 -6
  115. package/src/components/item/Item.astro +0 -52
  116. package/src/components/item/ItemActions.astro +0 -16
  117. package/src/components/item/ItemContent.astro +0 -16
  118. package/src/components/item/ItemDescription.astro +0 -19
  119. package/src/components/item/ItemFooter.astro +0 -16
  120. package/src/components/item/ItemGroup.astro +0 -16
  121. package/src/components/item/ItemHeader.astro +0 -16
  122. package/src/components/item/ItemMedia.astro +0 -40
  123. package/src/components/item/ItemSeparator.astro +0 -23
  124. package/src/components/item/ItemTitle.astro +0 -16
  125. package/src/components/kbd/Kbd.astro +0 -21
  126. package/src/components/kbd/KbdGroup.astro +0 -16
  127. package/src/components/label/Label.astro +0 -24
  128. package/src/components/marquee/Marquee.astro +0 -73
  129. package/src/components/native-select/NativeSelect.astro +0 -68
  130. package/src/components/native-select/NativeSelectOptGroup.astro +0 -15
  131. package/src/components/native-select/NativeSelectOption.astro +0 -15
  132. package/src/components/pagination/Pagination.astro +0 -20
  133. package/src/components/pagination/PaginationContent.astro +0 -16
  134. package/src/components/pagination/PaginationEllipsis.astro +0 -37
  135. package/src/components/pagination/PaginationItem.astro +0 -16
  136. package/src/components/pagination/PaginationLink.astro +0 -27
  137. package/src/components/pagination/PaginationNext.astro +0 -33
  138. package/src/components/pagination/PaginationPrevious.astro +0 -33
  139. package/src/components/popover/Popover.astro +0 -717
  140. package/src/components/popover/PopoverContent.astro +0 -102
  141. package/src/components/popover/PopoverDescription.astro +0 -14
  142. package/src/components/popover/PopoverHeader.astro +0 -14
  143. package/src/components/popover/PopoverTitle.astro +0 -14
  144. package/src/components/popover/PopoverTrigger.astro +0 -51
  145. package/src/components/progress/Progress.astro +0 -154
  146. package/src/components/prose/Prose.astro +0 -619
  147. package/src/components/radio-group/RadioGroup.astro +0 -162
  148. package/src/components/radio-group/RadioGroupItem.astro +0 -133
  149. package/src/components/radio-group/RadioGroupTypes.ts +0 -6
  150. package/src/components/section/Section.astro +0 -167
  151. package/src/components/select/Select.astro +0 -752
  152. package/src/components/select/SelectContent.astro +0 -94
  153. package/src/components/select/SelectGroup.astro +0 -9
  154. package/src/components/select/SelectItem.astro +0 -51
  155. package/src/components/select/SelectLabel.astro +0 -14
  156. package/src/components/select/SelectSearch.astro +0 -49
  157. package/src/components/select/SelectSeparator.astro +0 -12
  158. package/src/components/select/SelectTrigger.astro +0 -56
  159. package/src/components/select/SelectTypes.ts +0 -13
  160. package/src/components/select/SelectValue.astro +0 -19
  161. package/src/components/separator/Separator.astro +0 -36
  162. package/src/components/sheet/Sheet.astro +0 -15
  163. package/src/components/sheet/SheetClose.astro +0 -15
  164. package/src/components/sheet/SheetContent.astro +0 -89
  165. package/src/components/sheet/SheetDescription.astro +0 -16
  166. package/src/components/sheet/SheetFooter.astro +0 -16
  167. package/src/components/sheet/SheetHeader.astro +0 -16
  168. package/src/components/sheet/SheetTitle.astro +0 -16
  169. package/src/components/sheet/SheetTrigger.astro +0 -15
  170. package/src/components/sidebar/Sidebar.astro +0 -231
  171. package/src/components/sidebar/SidebarContent.astro +0 -25
  172. package/src/components/sidebar/SidebarFooter.astro +0 -22
  173. package/src/components/sidebar/SidebarGroup.astro +0 -22
  174. package/src/components/sidebar/SidebarGroupContent.astro +0 -22
  175. package/src/components/sidebar/SidebarGroupLabel.astro +0 -53
  176. package/src/components/sidebar/SidebarHeader.astro +0 -22
  177. package/src/components/sidebar/SidebarInput.astro +0 -24
  178. package/src/components/sidebar/SidebarInset.astro +0 -22
  179. package/src/components/sidebar/SidebarMenu.astro +0 -22
  180. package/src/components/sidebar/SidebarMenuAction.astro +0 -63
  181. package/src/components/sidebar/SidebarMenuBadge.astro +0 -31
  182. package/src/components/sidebar/SidebarMenuButton.astro +0 -124
  183. package/src/components/sidebar/SidebarMenuItem.astro +0 -22
  184. package/src/components/sidebar/SidebarMenuSkeleton.astro +0 -43
  185. package/src/components/sidebar/SidebarMenuSub.astro +0 -25
  186. package/src/components/sidebar/SidebarMenuSubButton.astro +0 -52
  187. package/src/components/sidebar/SidebarMenuSubItem.astro +0 -17
  188. package/src/components/sidebar/SidebarProvider.astro +0 -215
  189. package/src/components/sidebar/SidebarRail.astro +0 -72
  190. package/src/components/sidebar/SidebarSeparator.astro +0 -25
  191. package/src/components/sidebar/SidebarTrigger.astro +0 -69
  192. package/src/components/skeleton/Skeleton.astro +0 -14
  193. package/src/components/slider/Slider.astro +0 -425
  194. package/src/components/spinner/Spinner.astro +0 -23
  195. package/src/components/switch/Switch.astro +0 -192
  196. package/src/components/switch/SwitchTypes.ts +0 -6
  197. package/src/components/table/Table.astro +0 -20
  198. package/src/components/table/TableBody.astro +0 -18
  199. package/src/components/table/TableCaption.astro +0 -18
  200. package/src/components/table/TableCell.astro +0 -18
  201. package/src/components/table/TableFoot.astro +0 -18
  202. package/src/components/table/TableHead.astro +0 -18
  203. package/src/components/table/TableHeader.astro +0 -18
  204. package/src/components/table/TableRow.astro +0 -17
  205. package/src/components/tabs/Tabs.astro +0 -270
  206. package/src/components/tabs/TabsContent.astro +0 -28
  207. package/src/components/tabs/TabsList.astro +0 -23
  208. package/src/components/tabs/TabsTrigger.astro +0 -34
  209. package/src/components/textarea/Textarea.astro +0 -31
  210. package/src/components/toast/ToastDescription.astro +0 -22
  211. package/src/components/toast/ToastItem.astro +0 -56
  212. package/src/components/toast/ToastTemplate.astro +0 -27
  213. package/src/components/toast/ToastTitle.astro +0 -59
  214. package/src/components/toast/Toaster.astro +0 -981
  215. package/src/components/toast/index.ts +0 -1
  216. package/src/components/toast/toast-manager.ts +0 -234
  217. package/src/components/toggle/Toggle.astro +0 -174
  218. package/src/components/toggle/ToggleTypes.ts +0 -14
  219. package/src/components/tooltip/Tooltip.astro +0 -422
  220. package/src/components/tooltip/TooltipContent.astro +0 -83
  221. package/src/components/tooltip/TooltipTrigger.astro +0 -13
  222. package/src/components/video/Video.astro +0 -121
  223. package/src/config/cookies.ts +0 -5
  224. package/src/config/links.ts +0 -4
  225. package/src/domain/cms/index.ts +0 -1
  226. package/src/domain/cms/types.ts +0 -20
  227. package/src/domain/i18n/constants.ts +0 -21
  228. package/src/domain/i18n/cookie-storage.ts +0 -13
  229. package/src/domain/i18n/country-to-locale-map.ts +0 -67
  230. package/src/domain/i18n/fallbacks.generated.ts +0 -230
  231. package/src/domain/i18n/fetcher.ts +0 -278
  232. package/src/domain/i18n/flags.ts +0 -16
  233. package/src/domain/i18n/format.ts +0 -90
  234. package/src/domain/i18n/index.ts +0 -10
  235. package/src/domain/i18n/middleware/i18n.ts +0 -161
  236. package/src/domain/i18n/resolve-locale.ts +0 -55
  237. package/src/domain/i18n/runtime-constants.ts +0 -14
  238. package/src/domain/i18n/schema.ts +0 -29
  239. package/src/domain/index.ts +0 -4
  240. package/src/domain/seo/constants.ts +0 -6
  241. package/src/domain/seo/index.ts +0 -3
  242. package/src/domain/seo/services/index.ts +0 -3
  243. package/src/domain/seo/services/llms.ts +0 -56
  244. package/src/domain/seo/services/robots.ts +0 -12
  245. package/src/domain/seo/services/sitemap.ts +0 -56
  246. package/src/domain/seo/utils.ts +0 -36
  247. package/src/domain/theme/constants.ts +0 -6
  248. package/src/domain/theme/index.ts +0 -2
  249. package/src/domain/theme/schema.ts +0 -10
  250. package/src/i18n.generated.d.ts +0 -202
  251. package/src/lib/component-preview.ts +0 -73
  252. package/src/lib/index.ts +0 -6
  253. package/src/lib/remark/remark-modified-time.ts +0 -13
  254. package/src/lib/showcase-preview-elements.ts +0 -408
  255. package/src/lib/showcase-renderer.ts +0 -218
  256. package/src/lib/showcase-utils.ts +0 -189
  257. package/src/lib/turnstile.ts +0 -35
  258. package/src/lib/utils/starwind/positioning.ts +0 -318
  259. package/src/locales/de/blog.json +0 -9
  260. package/src/locales/de/common.json +0 -19
  261. package/src/locales/de/errors.json +0 -6
  262. package/src/locales/de/home.json +0 -20
  263. package/src/locales/de/messages.json +0 -8
  264. package/src/locales/de/nav.json +0 -13
  265. package/src/locales/de/projects.json +0 -9
  266. package/src/locales/de/services.json +0 -43
  267. package/src/locales/en/blog.json +0 -9
  268. package/src/locales/en/chat.json +0 -29
  269. package/src/locales/en/common.json +0 -19
  270. package/src/locales/en/cookie_notice.json +0 -11
  271. package/src/locales/en/editor.json +0 -24
  272. package/src/locales/en/errors.json +0 -6
  273. package/src/locales/en/home.json +0 -20
  274. package/src/locales/en/messages.json +0 -8
  275. package/src/locales/en/nav.json +0 -13
  276. package/src/locales/en/projects.json +0 -9
  277. package/src/locales/en/services.json +0 -43
  278. package/src/locales/es/blog.json +0 -9
  279. package/src/locales/es/common.json +0 -19
  280. package/src/locales/es/errors.json +0 -6
  281. package/src/locales/es/home.json +0 -20
  282. package/src/locales/es/messages.json +0 -8
  283. package/src/locales/es/nav.json +0 -13
  284. package/src/locales/es/projects.json +0 -9
  285. package/src/locales/es/services.json +0 -43
  286. package/src/locales/ja/blog.json +0 -9
  287. package/src/locales/ja/common.json +0 -19
  288. package/src/locales/ja/errors.json +0 -6
  289. package/src/locales/ja/home.json +0 -20
  290. package/src/locales/ja/messages.json +0 -8
  291. package/src/locales/ja/nav.json +0 -13
  292. package/src/locales/ja/projects.json +0 -9
  293. package/src/locales/ja/services.json +0 -43
  294. package/src/locales/pt/blog.json +0 -9
  295. package/src/locales/pt/chat.json +0 -29
  296. package/src/locales/pt/common.json +0 -19
  297. package/src/locales/pt/cookie_notice.json +0 -11
  298. package/src/locales/pt/editor.json +0 -24
  299. package/src/locales/pt/errors.json +0 -6
  300. package/src/locales/pt/home.json +0 -20
  301. package/src/locales/pt/messages.json +0 -8
  302. package/src/locales/pt/nav.json +0 -13
  303. package/src/locales/pt/projects.json +0 -9
  304. package/src/locales/pt/services.json +0 -43
  305. package/src/utils/server/cookies.ts +0 -98
  306. package/src/utils/server/index.ts +0 -1
  307. package/src/utils/shared/index.ts +0 -3
  308. /package/src/utils/{shared/deep-merge.ts → deep-merge.ts} +0 -0
  309. /package/src/utils/{shared/embed.ts → embed.ts} +0 -0
  310. /package/src/utils/{shared/parse-boolean.ts → parse-boolean.ts} +0 -0
@@ -1,352 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { cv } from "css-variants";
4
-
5
- type Props = HTMLAttributes<"div"> & {
6
- maxLength?: number;
7
- value?: string;
8
- defaultValue?: string;
9
- disabled?: boolean;
10
- pattern?: RegExp | string;
11
- name?: string;
12
- id?: string;
13
- required?: boolean;
14
- };
15
-
16
- export const inputOtp = cv({
17
- base: "starwind-input-otp flex items-center gap-md outline-none has-disabled:op-50",
18
- });
19
-
20
- const {
21
- maxLength = 6,
22
- value,
23
- defaultValue,
24
- disabled = false,
25
- pattern,
26
- name,
27
- id,
28
- required,
29
- class: className,
30
- ...rest
31
- } = Astro.props;
32
-
33
- let patternStr = "\\d";
34
- if (pattern) {
35
- const stripAnchorsRegex = /^\^|\$$/g;
36
- if (pattern instanceof RegExp) {
37
- patternStr = pattern.source.replace(stripAnchorsRegex, "");
38
- } else {
39
- patternStr = pattern.replace(stripAnchorsRegex, "");
40
- }
41
- }
42
-
43
- const numericPatterns = ["\\d", "[0-9]", "\\d+", "[0-9]+"];
44
- const isNumericOnly = numericPatterns.includes(patternStr);
45
- const inputMode = isNumericOnly ? "numeric" : "text";
46
- ---
47
-
48
- <div
49
- class:list={[inputOtp(), className]}
50
- data-max-length={maxLength}
51
- data-value={value || defaultValue || ""}
52
- data-disabled={disabled}
53
- data-pattern={patternStr}
54
- tabindex={disabled ? "-1" : "0"}
55
- {...rest}
56
- data-slot="input-otp"
57
- >
58
- <input
59
- autocomplete="one-time-code"
60
- inputmode={inputMode}
61
- tabindex="-1"
62
- name={name}
63
- id={id}
64
- class="sr-only"
65
- required={required}
66
- maxlength={maxLength.toString()}
67
- value={value || defaultValue || ""}
68
- disabled={disabled}
69
- data-otp-hidden-input
70
- />
71
- <slot />
72
- </div>
73
-
74
- <script>
75
- import type { InputOtpChangeEvent } from "./InputOtpTypes";
76
-
77
- class InputOtpHandler {
78
- private container: HTMLElement;
79
- private slots: HTMLElement[];
80
- private hiddenInput: HTMLInputElement | null;
81
- private maxLength: number;
82
- private containerId: string;
83
- private pattern: RegExp;
84
- private observer: MutationObserver | null = null;
85
- private currentIndex: number = 0;
86
- private values: string[] = [];
87
-
88
- constructor(container: HTMLElement, idx: number) {
89
- this.container = container;
90
- this.containerId = container.id || `starwind-input-otp-${idx}`;
91
- if (!container.id) {
92
- container.id = this.containerId;
93
- }
94
- this.maxLength = parseInt(container.dataset.maxLength || "6", 10);
95
- const patternStr = container.dataset.pattern || "\\d";
96
- this.pattern = new RegExp(`^${patternStr}$`);
97
- this.slots = Array.from(container.querySelectorAll<HTMLElement>("[data-otp-slot]"));
98
- this.hiddenInput = container.querySelector<HTMLInputElement>("input[data-otp-hidden-input]");
99
- this.values = Array.from({ length: this.slots.length }, () => "");
100
- this.init();
101
- }
102
-
103
- private init() {
104
- if (this.slots.length === 0) return;
105
-
106
- const isDisabled = this.container.dataset.disabled === "true";
107
- if (isDisabled) {
108
- this.container.setAttribute("tabindex", "-1");
109
- return;
110
- }
111
-
112
- const initialValue = this.container.dataset.value || "";
113
- if (initialValue) {
114
- this.setValue(initialValue);
115
- }
116
-
117
- this.setupEventListeners();
118
- this.setupValueSync();
119
- this.updateSlots();
120
- }
121
-
122
- private setupValueSync() {
123
- this.observer = new MutationObserver(() => {
124
- const containerValue = this.container.dataset.value || "";
125
- const currentValue = this.getValue();
126
- if (containerValue !== currentValue) {
127
- this.setValue(containerValue);
128
- }
129
- });
130
-
131
- this.observer.observe(this.container, {
132
- attributes: true,
133
- attributeFilter: ["data-value"],
134
- });
135
- }
136
-
137
- private setupEventListeners() {
138
- this.container.addEventListener("keydown", (e) => this.handleKeyDown(e));
139
- this.container.addEventListener("focus", () => this.handleContainerFocus());
140
- this.container.addEventListener("blur", () => this.handleContainerBlur());
141
- this.container.addEventListener("paste", (e) => this.handlePaste(e));
142
- this.container.addEventListener("click", (e) => this.handleClick(e));
143
-
144
- if (this.hiddenInput) {
145
- this.hiddenInput.addEventListener("input", (e) => this.handleHiddenInput(e));
146
- this.hiddenInput.addEventListener("focus", () => this.updateSlots());
147
- this.hiddenInput.addEventListener("blur", () => this.updateSlots());
148
- }
149
- }
150
-
151
- private handleKeyDown(e: KeyboardEvent) {
152
- const isDisabled = this.container.dataset.disabled === "true";
153
- if (isDisabled) return;
154
-
155
- if (e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) {
156
- e.preventDefault();
157
- const char = e.key;
158
- if (this.pattern.test(char)) {
159
- this.setSlotValue(this.currentIndex, char);
160
- if (this.currentIndex < this.slots.length - 1) {
161
- this.currentIndex++;
162
- }
163
- this.updateSlots();
164
- this.updateValue();
165
- }
166
- } else if (e.key === "Backspace") {
167
- e.preventDefault();
168
- if (this.values[this.currentIndex]) {
169
- this.setSlotValue(this.currentIndex, "");
170
- } else if (this.currentIndex > 0) {
171
- this.currentIndex--;
172
- this.setSlotValue(this.currentIndex, "");
173
- }
174
- this.updateSlots();
175
- this.updateValue();
176
- } else if (e.key === "ArrowLeft") {
177
- e.preventDefault();
178
- if (this.currentIndex > 0) {
179
- this.currentIndex--;
180
- this.updateSlots();
181
- }
182
- } else if (e.key === "ArrowRight") {
183
- e.preventDefault();
184
- if (this.currentIndex < this.slots.length - 1) {
185
- this.currentIndex++;
186
- this.updateSlots();
187
- }
188
- } else if (e.key === "Delete") {
189
- e.preventDefault();
190
- this.setSlotValue(this.currentIndex, "");
191
- this.updateSlots();
192
- this.updateValue();
193
- }
194
- }
195
-
196
- private handlePaste(e: ClipboardEvent) {
197
- const isDisabled = this.container.dataset.disabled === "true";
198
- if (isDisabled) return;
199
-
200
- e.preventDefault();
201
- const pastedData = e.clipboardData?.getData("text") || "";
202
- const matchedChars = this.filterByPattern(pastedData).slice(0, this.maxLength);
203
-
204
- if (matchedChars.length === 0) return;
205
-
206
- for (let i = 0; i < matchedChars.length && this.currentIndex + i < this.slots.length; i++) {
207
- this.setSlotValue(this.currentIndex + i, matchedChars[i]!);
208
- }
209
-
210
- this.currentIndex = Math.min(this.currentIndex + matchedChars.length, this.slots.length - 1);
211
- this.updateSlots();
212
- this.updateValue();
213
- }
214
-
215
- private handleClick(_e: MouseEvent) {
216
- const isDisabled = this.container.dataset.disabled === "true";
217
- if (isDisabled) return;
218
-
219
- this.currentIndex = this.getNextEmptyIndex();
220
- this.updateSlots();
221
- this.focusHiddenInput();
222
- }
223
-
224
- private getNextEmptyIndex(): number {
225
- const firstEmptyIndex = this.values.findIndex((v) => !v);
226
- if (firstEmptyIndex !== -1) {
227
- return firstEmptyIndex;
228
- }
229
- return this.slots.length - 1;
230
- }
231
-
232
- private handleHiddenInput(e: Event) {
233
- const input = e.target as HTMLInputElement;
234
- const newValue = input.value;
235
- const matchedChars = this.filterByPattern(newValue).slice(0, this.maxLength);
236
-
237
- for (let i = 0; i < this.slots.length; i++) {
238
- this.values[i] = matchedChars[i] || "";
239
- }
240
-
241
- this.currentIndex = Math.min(matchedChars.length, this.slots.length - 1);
242
- if (matchedChars.length === this.slots.length) {
243
- this.currentIndex = this.slots.length - 1;
244
- }
245
-
246
- this.updateSlots();
247
- this.updateValue();
248
- }
249
-
250
- private focusHiddenInput() {
251
- if (this.hiddenInput) {
252
- this.hiddenInput.focus();
253
- }
254
- }
255
-
256
- private handleContainerFocus() {
257
- this.focusHiddenInput();
258
- }
259
-
260
- private handleContainerBlur() {
261
- this.updateSlots();
262
- }
263
-
264
- private setSlotValue(index: number, value: string) {
265
- if (index >= 0 && index < this.values.length) {
266
- this.values[index] = value;
267
- }
268
- }
269
-
270
- private updateSlots() {
271
- const isFocused =
272
- document.activeElement === this.container || document.activeElement === this.hiddenInput;
273
-
274
- this.slots.forEach((slot, index) => {
275
- const charElement = slot.querySelector("[data-otp-char]");
276
- const caretElement = slot.querySelector("[data-otp-caret]");
277
- const char = this.values[index] || "";
278
-
279
- if (charElement) {
280
- charElement.textContent = char;
281
- }
282
-
283
- const isActive = isFocused && index === this.currentIndex;
284
- slot.setAttribute("data-active", isActive ? "true" : "false");
285
-
286
- if (caretElement) {
287
- if (isActive && !char) {
288
- caretElement.classList.remove("hidden");
289
- caretElement.classList.add("flex");
290
- } else {
291
- caretElement.classList.add("hidden");
292
- caretElement.classList.remove("flex");
293
- }
294
- }
295
- });
296
- }
297
-
298
- private filterByPattern(value: string): string[] {
299
- return value.split("").filter((char) => this.pattern.test(char));
300
- }
301
-
302
- private setValue(value: string) {
303
- const matchedChars = this.filterByPattern(value).slice(0, this.maxLength);
304
- for (let i = 0; i < this.slots.length; i++) {
305
- this.values[i] = matchedChars[i] || "";
306
- }
307
- this.currentIndex = Math.min(matchedChars.length, this.slots.length - 1);
308
- this.updateSlots();
309
- }
310
-
311
- private updateValue() {
312
- const value = this.values.join("");
313
- this.container.dataset.value = value;
314
-
315
- if (this.hiddenInput) {
316
- this.hiddenInput.value = value;
317
- }
318
-
319
- this.dispatchChangeEvent(value);
320
- }
321
-
322
- public getValue(): string {
323
- return this.values.join("");
324
- }
325
-
326
- private dispatchChangeEvent(value: string) {
327
- const event = new CustomEvent<InputOtpChangeEvent["detail"]>("starwind-input-otp:change", {
328
- bubbles: true,
329
- detail: {
330
- value,
331
- inputOtpId: this.containerId,
332
- },
333
- });
334
- this.container.dispatchEvent(event);
335
- }
336
- }
337
-
338
- const inputOtpInstances = new WeakMap<HTMLElement, InputOtpHandler>();
339
- let inputOtpCounter = 0;
340
-
341
- const setupInputOtps = () => {
342
- document.querySelectorAll<HTMLElement>(".starwind-input-otp").forEach((container) => {
343
- if (!inputOtpInstances.has(container)) {
344
- inputOtpInstances.set(container, new InputOtpHandler(container, inputOtpCounter++));
345
- }
346
- });
347
- };
348
-
349
- setupInputOtps();
350
- document.addEventListener("astro:after-swap", setupInputOtps);
351
- document.addEventListener("starwind:init", setupInputOtps);
352
- </script>
@@ -1,16 +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 inputOtpGroup = cv({
8
- base: "flex items-center",
9
- });
10
-
11
- const { class: className, ...rest } = Astro.props;
12
- ---
13
-
14
- <div class:list={[inputOtpGroup(), className]} {...rest} data-slot="input-otp-group">
15
- <slot />
16
- </div>
@@ -1,25 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { cv } from "css-variants";
4
- import IconMinus from "~icons/lucide/minus";
5
-
6
- type Props = HTMLAttributes<"div">;
7
-
8
- export const inputOtpSeparator = cv({
9
- base: "text-muted-foreground",
10
- });
11
-
12
- const { class: className, ...rest } = Astro.props;
13
- ---
14
-
15
- <div
16
- aria-hidden="true"
17
- class:list={[inputOtpSeparator(), className]}
18
- role="separator"
19
- {...rest}
20
- data-slot="input-otp-separator"
21
- >
22
- <slot name="icon">
23
- <IconMinus class="size-6" />
24
- </slot>
25
- </div>
@@ -1,50 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { cv } from "css-variants";
4
-
5
- type VariantProps<T extends (...args: any) => any> = NonNullable<Parameters<T>[0]>;
6
-
7
- type Props = HTMLAttributes<"div"> &
8
- VariantProps<typeof inputOtpSlot> & {
9
- index?: number;
10
- };
11
-
12
- export const inputOtpSlot = cv({
13
- base: [
14
- "border-input dark:bg-input/30 text-foreground b bg-transparent text-center shadow-xs",
15
- "relative flex items-center justify-center border-y border-r text-sm transition-all outline-none",
16
- "first:rounded-l-md first:border-l last:rounded-r-md disabled:cursor-not-allowed disabled:op-50",
17
- "data-[active=true]:border-outline data-[active=true]:ring-outline/50 data-[active=true]:z-10 data-[active=true]:ring-3",
18
- "data-[active=true]:aria-invalid:ring-error/40",
19
- "aria-invalid:border-error data-[active=true]:aria-invalid:border-error",
20
- ],
21
- variants: {
22
- size: {
23
- sm: "size-9 text-sm",
24
- md: "size-11 text-base",
25
- lg: "size-12 text-lg",
26
- },
27
- },
28
- defaultVariants: { size: "md" },
29
- });
30
-
31
- const { size, index, class: className, ...rest } = Astro.props;
32
- ---
33
-
34
- <div
35
- class:list={[inputOtpSlot({ size }), className]}
36
- data-otp-slot
37
- data-index={index}
38
- {...rest}
39
- data-slot="input-otp-slot"
40
- >
41
- <span data-otp-char></span>
42
- <div
43
- class="pointer-events-none absolute inset-0 hidden items-center justify-center"
44
- data-otp-caret
45
- >
46
- <slot name="caret">
47
- <div class="animate-caret-blink bg-foreground h-4 w-px duration-1000"></div>
48
- </slot>
49
- </div>
50
- </div>
@@ -1,6 +0,0 @@
1
- export interface InputOtpChangeEvent extends CustomEvent {
2
- detail: {
3
- value: string
4
- inputOtpId?: string
5
- }
6
- }
@@ -1,52 +0,0 @@
1
- ---
2
- import type { HTMLTag, Polymorphic } from "astro/types";
3
- import { cv } from "css-variants";
4
-
5
- type Props<Tag extends HTMLTag> = Polymorphic<{ as: Tag }> & {
6
- /**
7
- * Variant of the item
8
- * @default "default"
9
- */
10
- variant?: "default" | "outline" | "muted";
11
- /**
12
- * Size of the item
13
- * @default "default"
14
- */
15
- size?: "default" | "sm";
16
- };
17
-
18
- export const item = cv({
19
- base: [
20
- "group/item flex flex-wrap items-center rounded-md b border-transparent text-sm transition-colors",
21
- "[a]:hover:bg-accent/50 [a]:transition-colors",
22
- "focus-visible:border-ring focus-visible:ring-outline/50 outline-none focus-visible:ring-4xs",
23
- ],
24
- variants: {
25
- variant: {
26
- default: "bg-transparent",
27
- outline: "border-border",
28
- muted: "bg-muted/50",
29
- },
30
- size: {
31
- default: "gap-3xs p-3xs",
32
- sm: "gap-2xs px-4 py-3",
33
- },
34
- },
35
- defaultVariants: {
36
- variant: "default",
37
- size: "default",
38
- },
39
- });
40
-
41
- const {
42
- variant = "default",
43
- size = "default",
44
- class: className,
45
- as: Tag = "div",
46
- ...rest
47
- } = Astro.props;
48
- ---
49
-
50
- <Tag class:list={[item({ variant, size }), className]} data-slot="item" {...rest}>
51
- <slot />
52
- </Tag>
@@ -1,16 +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 itemActions = cv({
8
- base: "flex items-center gap-3xs",
9
- });
10
-
11
- const { class: className, ...rest } = Astro.props;
12
- ---
13
-
14
- <div class:list={[itemActions(), className]} {...rest} data-slot="item-actions">
15
- <slot />
16
- </div>
@@ -1,16 +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 itemContent = cv({
8
- base: "flex flex-1 flex-col gap-1.5 [&+[data-slot=item-content]]:flex-none",
9
- });
10
-
11
- const { class: className, ...rest } = Astro.props;
12
- ---
13
-
14
- <div class:list={[itemContent(), className]} {...rest} data-slot="item-content">
15
- <slot />
16
- </div>
@@ -1,19 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { cv } from "css-variants";
4
-
5
- type Props = HTMLAttributes<"p">;
6
-
7
- export const itemDescription = cv({
8
- base: [
9
- "text-muted-foreground line-clamp-2 leading-snug font-normal text-balance",
10
- "[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4",
11
- ],
12
- });
13
-
14
- const { class: className, ...rest } = Astro.props;
15
- ---
16
-
17
- <p class:list={[itemDescription(), className]} {...rest} data-slot="item-description">
18
- <slot />
19
- </p>
@@ -1,16 +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 itemFooter = cv({
8
- base: "flex basis-full items-center justify-between gap-3xs",
9
- });
10
-
11
- const { class: className, ...rest } = Astro.props;
12
- ---
13
-
14
- <div class:list={[itemFooter(), className]} {...rest} data-slot="item-footer">
15
- <slot />
16
- </div>
@@ -1,16 +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 itemGroup = cv({
8
- base: "group/item-group flex flex-col",
9
- });
10
-
11
- const { class: className, ...rest } = Astro.props;
12
- ---
13
-
14
- <div role="list" class:list={[itemGroup(), className]} {...rest} data-slot="item-group">
15
- <slot />
16
- </div>
@@ -1,16 +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 itemHeader = cv({
8
- base: "flex basis-full items-center justify-between gap-3xs",
9
- });
10
-
11
- const { class: className, ...rest } = Astro.props;
12
- ---
13
-
14
- <div class:list={[itemHeader(), className]} {...rest} data-slot="item-header">
15
- <slot />
16
- </div>
@@ -1,40 +0,0 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { cv } from "css-variants";
4
-
5
- type Props = HTMLAttributes<"div"> & {
6
- /**
7
- * Variant of the item media
8
- * @default "default"
9
- */
10
- variant?: "default" | "icon" | "image";
11
- };
12
-
13
- export const itemMedia = cv({
14
- base: [
15
- "flex shrink-0 items-center justify-center gap-md [&_svg]:pointer-events-none",
16
- "group-has-[[data-slot=item-description]]/item:translate-y-0.5 group-has-[[data-slot=item-description]]/item:self-start",
17
- ],
18
- variants: {
19
- variant: {
20
- default: "bg-transparent",
21
- icon: "bg-muted size-8 rounded-sm b [&_svg:not([class*='size-'])]:size-4",
22
- image: "size-10 overflow-hidden rounded-sm [&_img]:size-full [&_img]:object-cover",
23
- },
24
- },
25
- defaultVariants: {
26
- variant: "default",
27
- },
28
- });
29
-
30
- const { variant = "default", class: className, ...rest } = Astro.props;
31
- ---
32
-
33
- <div
34
- class:list={[itemMedia({ variant }), className]}
35
- data-variant={variant}
36
- {...rest}
37
- data-slot="item-media"
38
- >
39
- <slot />
40
- </div>
@@ -1,23 +0,0 @@
1
- ---
2
- import type { ComponentProps } from "astro/types";
3
- import { cv } from "css-variants";
4
-
5
- // eslint-disable-next-line typescript/consistent-type-imports
6
- import Separator from "../separator/Separator.astro";
7
-
8
- type Props = ComponentProps<typeof Separator>;
9
-
10
- export const itemSeparator = cv({
11
- base: "my-0",
12
- });
13
-
14
- const { class: className, orientation = "horizontal", ...rest } = Astro.props;
15
- ---
16
-
17
- <Separator
18
- orientation={orientation}
19
- class:list={[itemSeparator(), className]}
20
- {...rest}
21
- data-slot="item-separator"
22
- />
23
-
@@ -1,16 +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 itemTitle = cv({
8
- base: "flex w-fit items-center gap-md leading-snug font-medium",
9
- });
10
-
11
- const { class: className, ...rest } = Astro.props;
12
- ---
13
-
14
- <div class:list={[itemTitle(), className]} {...rest} data-slot="item-title">
15
- <slot />
16
- </div>