@starwind-ui/core 1.7.3 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/dist/index.js +41 -23
  2. package/dist/index.js.map +1 -1
  3. package/dist/src/components/accordion/Accordion.astro +8 -2
  4. package/dist/src/components/accordion/AccordionContent.astro +2 -1
  5. package/dist/src/components/accordion/AccordionItem.astro +8 -2
  6. package/dist/src/components/accordion/AccordionTrigger.astro +2 -1
  7. package/dist/src/components/accordion/index.ts +7 -5
  8. package/dist/src/components/alert/Alert.astro +5 -2
  9. package/dist/src/components/alert/AlertDescription.astro +4 -4
  10. package/dist/src/components/alert/AlertTitle.astro +3 -3
  11. package/dist/src/components/alert/index.ts +6 -4
  12. package/dist/src/components/alert-dialog/AlertDialog.astro +273 -0
  13. package/dist/src/components/alert-dialog/AlertDialogAction.astro +44 -0
  14. package/dist/src/components/alert-dialog/AlertDialogCancel.astro +45 -0
  15. package/dist/src/components/alert-dialog/AlertDialogContent.astro +50 -0
  16. package/dist/src/components/alert-dialog/AlertDialogDescription.astro +18 -0
  17. package/dist/src/components/alert-dialog/AlertDialogFooter.astro +16 -0
  18. package/dist/src/components/alert-dialog/AlertDialogHeader.astro +14 -0
  19. package/dist/src/components/alert-dialog/AlertDialogTitle.astro +20 -0
  20. package/dist/src/components/alert-dialog/AlertDialogTrigger.astro +47 -0
  21. package/dist/src/components/alert-dialog/index.ts +46 -0
  22. package/dist/src/components/avatar/Avatar.astro +2 -2
  23. package/dist/src/components/avatar/AvatarFallback.astro +2 -2
  24. package/dist/src/components/avatar/AvatarImage.astro +13 -2
  25. package/dist/src/components/avatar/index.ts +6 -4
  26. package/dist/src/components/badge/Badge.astro +2 -2
  27. package/dist/src/components/badge/index.ts +4 -2
  28. package/dist/src/components/breadcrumb/Breadcrumb.astro +1 -1
  29. package/dist/src/components/breadcrumb/BreadcrumbEllipsis.astro +4 -1
  30. package/dist/src/components/breadcrumb/BreadcrumbItem.astro +2 -2
  31. package/dist/src/components/breadcrumb/BreadcrumbLink.astro +2 -2
  32. package/dist/src/components/breadcrumb/BreadcrumbList.astro +2 -2
  33. package/dist/src/components/breadcrumb/BreadcrumbPage.astro +2 -1
  34. package/dist/src/components/breadcrumb/BreadcrumbSeparator.astro +2 -1
  35. package/dist/src/components/breadcrumb/index.ts +16 -6
  36. package/dist/src/components/button/Button.astro +2 -2
  37. package/dist/src/components/button/index.ts +4 -2
  38. package/dist/src/components/card/Card.astro +2 -2
  39. package/dist/src/components/card/CardContent.astro +2 -2
  40. package/dist/src/components/card/CardDescription.astro +2 -2
  41. package/dist/src/components/card/CardFooter.astro +2 -2
  42. package/dist/src/components/card/CardHeader.astro +2 -2
  43. package/dist/src/components/card/CardTitle.astro +2 -2
  44. package/dist/src/components/card/index.ts +16 -7
  45. package/dist/src/components/carousel/Carousel.astro +55 -0
  46. package/dist/src/components/carousel/CarouselContent.astro +26 -0
  47. package/dist/src/components/carousel/CarouselItem.astro +26 -0
  48. package/dist/src/components/carousel/CarouselNext.astro +33 -0
  49. package/dist/src/components/carousel/CarouselPrevious.astro +33 -0
  50. package/dist/src/components/carousel/carousel-script.ts +191 -0
  51. package/dist/src/components/carousel/index.ts +32 -0
  52. package/dist/src/components/checkbox/Checkbox.astro +10 -3
  53. package/dist/src/components/checkbox/index.ts +4 -2
  54. package/dist/src/components/dialog/Dialog.astro +24 -11
  55. package/dist/src/components/dialog/DialogClose.astro +7 -2
  56. package/dist/src/components/dialog/DialogContent.astro +6 -3
  57. package/dist/src/components/dialog/DialogDescription.astro +2 -2
  58. package/dist/src/components/dialog/DialogFooter.astro +2 -2
  59. package/dist/src/components/dialog/DialogHeader.astro +2 -2
  60. package/dist/src/components/dialog/DialogTitle.astro +2 -2
  61. package/dist/src/components/dialog/DialogTrigger.astro +7 -1
  62. package/dist/src/components/dialog/index.ts +20 -5
  63. package/dist/src/components/dropdown/Dropdown.astro +1 -0
  64. package/dist/src/components/dropdown/DropdownContent.astro +2 -1
  65. package/dist/src/components/dropdown/DropdownItem.astro +2 -1
  66. package/dist/src/components/dropdown/DropdownLabel.astro +2 -2
  67. package/dist/src/components/dropdown/DropdownSeparator.astro +2 -1
  68. package/dist/src/components/dropdown/DropdownTrigger.astro +7 -2
  69. package/dist/src/components/dropdown/index.ts +14 -5
  70. package/dist/src/components/dropzone/Dropzone.astro +3 -2
  71. package/dist/src/components/dropzone/DropzoneFilesList.astro +3 -2
  72. package/dist/src/components/dropzone/DropzoneLoadingIndicator.astro +1 -1
  73. package/dist/src/components/dropzone/DropzoneUploadIndicator.astro +1 -1
  74. package/dist/src/components/dropzone/index.ts +14 -3
  75. package/dist/src/components/input/Input.astro +2 -2
  76. package/dist/src/components/input/index.ts +4 -2
  77. package/dist/src/components/label/Label.astro +2 -2
  78. package/dist/src/components/label/index.ts +4 -2
  79. package/dist/src/components/pagination/Pagination.astro +8 -2
  80. package/dist/src/components/pagination/PaginationContent.astro +2 -2
  81. package/dist/src/components/pagination/PaginationEllipsis.astro +7 -2
  82. package/dist/src/components/pagination/PaginationItem.astro +2 -2
  83. package/dist/src/components/pagination/PaginationLink.astro +2 -1
  84. package/dist/src/components/pagination/PaginationNext.astro +2 -1
  85. package/dist/src/components/pagination/PaginationPrevious.astro +2 -1
  86. package/dist/src/components/pagination/index.ts +18 -7
  87. package/dist/src/components/progress/Progress.astro +5 -2
  88. package/dist/src/components/progress/index.ts +7 -2
  89. package/dist/src/components/radio-group/RadioGroup.astro +2 -1
  90. package/dist/src/components/radio-group/RadioGroupItem.astro +7 -6
  91. package/dist/src/components/radio-group/index.ts +16 -3
  92. package/dist/src/components/select/Select.astro +1 -0
  93. package/dist/src/components/select/SelectContent.astro +3 -2
  94. package/dist/src/components/select/SelectGroup.astro +1 -1
  95. package/dist/src/components/select/SelectItem.astro +3 -2
  96. package/dist/src/components/select/SelectLabel.astro +2 -2
  97. package/dist/src/components/select/SelectSeparator.astro +2 -2
  98. package/dist/src/components/select/SelectTrigger.astro +2 -1
  99. package/dist/src/components/select/SelectValue.astro +2 -2
  100. package/dist/src/components/select/index.ts +18 -6
  101. package/dist/src/components/sheet/Sheet.astro +13 -0
  102. package/dist/src/components/sheet/SheetClose.astro +13 -0
  103. package/dist/src/components/sheet/SheetContent.astro +90 -0
  104. package/dist/src/components/sheet/SheetDescription.astro +16 -0
  105. package/dist/src/components/sheet/SheetFooter.astro +16 -0
  106. package/dist/src/components/sheet/SheetHeader.astro +16 -0
  107. package/dist/src/components/sheet/SheetTitle.astro +16 -0
  108. package/dist/src/components/sheet/SheetTrigger.astro +13 -0
  109. package/dist/src/components/sheet/index.ts +41 -0
  110. package/dist/src/components/skeleton/Skeleton.astro +2 -2
  111. package/dist/src/components/skeleton/index.ts +6 -2
  112. package/dist/src/components/switch/Switch.astro +6 -4
  113. package/dist/src/components/switch/index.ts +8 -2
  114. package/dist/src/components/table/Table.astro +3 -3
  115. package/dist/src/components/table/TableBody.astro +2 -2
  116. package/dist/src/components/table/TableCaption.astro +2 -2
  117. package/dist/src/components/table/TableCell.astro +2 -2
  118. package/dist/src/components/table/TableFoot.astro +2 -2
  119. package/dist/src/components/table/TableHead.astro +2 -2
  120. package/dist/src/components/table/TableHeader.astro +2 -2
  121. package/dist/src/components/table/TableRow.astro +2 -2
  122. package/dist/src/components/table/index.ts +30 -9
  123. package/dist/src/components/tabs/Tabs.astro +2 -1
  124. package/dist/src/components/tabs/TabsContent.astro +4 -1
  125. package/dist/src/components/tabs/TabsList.astro +8 -2
  126. package/dist/src/components/tabs/TabsTrigger.astro +2 -1
  127. package/dist/src/components/tabs/index.ts +12 -5
  128. package/dist/src/components/textarea/Textarea.astro +2 -2
  129. package/dist/src/components/textarea/index.ts +6 -2
  130. package/dist/src/components/tooltip/Tooltip.astro +2 -1
  131. package/dist/src/components/tooltip/TooltipContent.astro +2 -1
  132. package/dist/src/components/tooltip/TooltipTrigger.astro +1 -1
  133. package/dist/src/components/tooltip/index.ts +8 -3
  134. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6,29 +6,47 @@ import { fileURLToPath } from "url";
6
6
  var registry_default = {
7
7
  $schema: "https://starwind.dev/registry-schema.json",
8
8
  components: [
9
- { name: "accordion", type: "component", version: "1.1.0", dependencies: [] },
10
- { name: "alert", type: "component", version: "1.1.1", dependencies: [] },
11
- { name: "avatar", type: "component", version: "1.1.1", dependencies: [] },
12
- { name: "badge", type: "component", version: "1.1.1", dependencies: [] },
13
- { name: "breadcrumb", type: "component", version: "1.0.0", dependencies: [] },
14
- { name: "button", type: "component", version: "2.0.1", dependencies: [] },
15
- { name: "card", type: "component", version: "1.1.0", dependencies: [] },
16
- { name: "checkbox", type: "component", version: "1.2.0", dependencies: [] },
17
- { name: "dialog", type: "component", version: "1.2.0", dependencies: [] },
18
- { name: "dropdown", type: "component", version: "1.0.3", dependencies: [] },
19
- { name: "dropzone", type: "component", version: "1.0.0", dependencies: [] },
20
- { name: "input", type: "component", version: "1.1.1", dependencies: [] },
21
- { name: "label", type: "component", version: "1.1.1", dependencies: [] },
22
- { name: "pagination", type: "component", version: "2.0.1", dependencies: [] },
23
- { name: "progress", type: "component", version: "1.0.0", dependencies: [] },
24
- { name: "radio-group", type: "component", version: "1.0.0", dependencies: [] },
25
- { name: "select", type: "component", version: "1.4.1", dependencies: [] },
26
- { name: "skeleton", type: "component", version: "1.0.0", dependencies: [] },
27
- { name: "switch", type: "component", version: "1.1.0", dependencies: [] },
28
- { name: "table", type: "component", version: "1.0.0", dependencies: [] },
29
- { name: "tabs", type: "component", version: "1.2.0", dependencies: [] },
30
- { name: "textarea", type: "component", version: "1.1.1", dependencies: [] },
31
- { name: "tooltip", type: "component", version: "1.1.2", dependencies: [] }
9
+ { name: "accordion", type: "component", version: "1.2.0", dependencies: [] },
10
+ { name: "alert", type: "component", version: "1.2.0", dependencies: [] },
11
+ {
12
+ name: "alert-dialog",
13
+ type: "component",
14
+ version: "1.0.0",
15
+ dependencies: ["@starwind-ui/core/button@^2.1.0"]
16
+ },
17
+ { name: "avatar", type: "component", version: "1.2.0", dependencies: [] },
18
+ { name: "badge", type: "component", version: "1.2.0", dependencies: [] },
19
+ { name: "breadcrumb", type: "component", version: "1.1.0", dependencies: [] },
20
+ { name: "button", type: "component", version: "2.1.0", dependencies: [] },
21
+ { name: "card", type: "component", version: "1.2.0", dependencies: [] },
22
+ {
23
+ name: "carousel",
24
+ type: "component",
25
+ version: "1.0.0",
26
+ dependencies: ["@starwind-ui/core/button@^2.1.0", "embla-carousel@^8.6.0"]
27
+ },
28
+ { name: "checkbox", type: "component", version: "1.3.0", dependencies: [] },
29
+ { name: "dialog", type: "component", version: "1.3.0", dependencies: [] },
30
+ { name: "dropdown", type: "component", version: "1.1.0", dependencies: [] },
31
+ { name: "dropzone", type: "component", version: "1.1.0", dependencies: [] },
32
+ { name: "input", type: "component", version: "1.2.0", dependencies: [] },
33
+ { name: "label", type: "component", version: "1.2.0", dependencies: [] },
34
+ { name: "pagination", type: "component", version: "2.1.0", dependencies: [] },
35
+ { name: "progress", type: "component", version: "1.1.0", dependencies: [] },
36
+ { name: "radio-group", type: "component", version: "1.1.0", dependencies: [] },
37
+ { name: "select", type: "component", version: "1.5.0", dependencies: [] },
38
+ {
39
+ name: "sheet",
40
+ type: "component",
41
+ version: "1.0.0",
42
+ dependencies: ["@starwind-ui/core/dialog@^1.3.0"]
43
+ },
44
+ { name: "skeleton", type: "component", version: "1.1.0", dependencies: [] },
45
+ { name: "switch", type: "component", version: "1.2.0", dependencies: [] },
46
+ { name: "table", type: "component", version: "1.1.0", dependencies: [] },
47
+ { name: "tabs", type: "component", version: "1.3.0", dependencies: [] },
48
+ { name: "textarea", type: "component", version: "1.2.0", dependencies: [] },
49
+ { name: "tooltip", type: "component", version: "1.2.0", dependencies: [] }
32
50
  ]
33
51
  };
34
52
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/registry.json"],"sourcesContent":["import { join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport componentRegistry from \"./registry.json\" with { type: \"json\" };\n\n/**\n * Component metadata interface describing a Starwind UI component\n */\nexport interface ComponentMeta {\n name: string;\n version: string;\n type: \"component\";\n dependencies: string[];\n}\n\n/**\n * Registry interface containing all available components\n */\nexport interface Registry {\n components: ComponentMeta[];\n}\n\nconst __dirname = fileURLToPath(new URL(\".\", import.meta.url));\n\n/**\n * Get the absolute path to a component file\n * @param {string} componentName - The name of the component\n * @param {string} fileName - The name of the file within the component\n * @returns {string} The absolute path to the component file\n */\nexport const getComponentPath = (componentName: string, fileName: string): string => {\n // In production (when installed as a dependency), the components will be in dist/src/components\n // In development, they will be in src/components\n const componentsDir = __dirname.includes(\"dist\") ? \"src/components\" : \"src/components\";\n return join(__dirname, componentsDir, componentName, fileName);\n};\n\n/**\n * Map of all components and their metadata from registry\n */\nexport const registry = componentRegistry.components as ComponentMeta[];\n","{\n \"$schema\": \"https://starwind.dev/registry-schema.json\",\n \"components\": [\n { \"name\": \"accordion\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n { \"name\": \"alert\", \"type\": \"component\", \"version\": \"1.1.1\", \"dependencies\": [] },\n { \"name\": \"avatar\", \"type\": \"component\", \"version\": \"1.1.1\", \"dependencies\": [] },\n { \"name\": \"badge\", \"type\": \"component\", \"version\": \"1.1.1\", \"dependencies\": [] },\n { \"name\": \"breadcrumb\", \"type\": \"component\", \"version\": \"1.0.0\", \"dependencies\": [] },\n { \"name\": \"button\", \"type\": \"component\", \"version\": \"2.0.1\", \"dependencies\": [] },\n { \"name\": \"card\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n { \"name\": \"checkbox\", \"type\": \"component\", \"version\": \"1.2.0\", \"dependencies\": [] },\n { \"name\": \"dialog\", \"type\": \"component\", \"version\": \"1.2.0\", \"dependencies\": [] },\n { \"name\": \"dropdown\", \"type\": \"component\", \"version\": \"1.0.3\", \"dependencies\": [] },\n { \"name\": \"dropzone\", \"type\": \"component\", \"version\": \"1.0.0\", \"dependencies\": [] },\n { \"name\": \"input\", \"type\": \"component\", \"version\": \"1.1.1\", \"dependencies\": [] },\n { \"name\": \"label\", \"type\": \"component\", \"version\": \"1.1.1\", \"dependencies\": [] },\n { \"name\": \"pagination\", \"type\": \"component\", \"version\": \"2.0.1\", \"dependencies\": [] },\n { \"name\": \"progress\", \"type\": \"component\", \"version\": \"1.0.0\", \"dependencies\": [] },\n { \"name\": \"radio-group\", \"type\": \"component\", \"version\": \"1.0.0\", \"dependencies\": [] },\n { \"name\": \"select\", \"type\": \"component\", \"version\": \"1.4.1\", \"dependencies\": [] },\n { \"name\": \"skeleton\", \"type\": \"component\", \"version\": \"1.0.0\", \"dependencies\": [] },\n { \"name\": \"switch\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n { \"name\": \"table\", \"type\": \"component\", \"version\": \"1.0.0\", \"dependencies\": [] },\n { \"name\": \"tabs\", \"type\": \"component\", \"version\": \"1.2.0\", \"dependencies\": [] },\n { \"name\": \"textarea\", \"type\": \"component\", \"version\": \"1.1.1\", \"dependencies\": [] },\n { \"name\": \"tooltip\", \"type\": \"component\", \"version\": \"1.1.2\", \"dependencies\": [] }\n ]\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,qBAAqB;;;ACD9B;AAAA,EACE,SAAW;AAAA,EACX,YAAc;AAAA,IACZ,EAAE,MAAQ,aAAa,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IACnF,EAAE,MAAQ,SAAS,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAC/E,EAAE,MAAQ,UAAU,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAChF,EAAE,MAAQ,SAAS,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAC/E,EAAE,MAAQ,cAAc,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IACpF,EAAE,MAAQ,UAAU,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAChF,EAAE,MAAQ,QAAQ,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAC9E,EAAE,MAAQ,YAAY,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAClF,EAAE,MAAQ,UAAU,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAChF,EAAE,MAAQ,YAAY,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAClF,EAAE,MAAQ,YAAY,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAClF,EAAE,MAAQ,SAAS,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAC/E,EAAE,MAAQ,SAAS,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAC/E,EAAE,MAAQ,cAAc,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IACpF,EAAE,MAAQ,YAAY,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAClF,EAAE,MAAQ,eAAe,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IACrF,EAAE,MAAQ,UAAU,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAChF,EAAE,MAAQ,YAAY,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAClF,EAAE,MAAQ,UAAU,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAChF,EAAE,MAAQ,SAAS,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAC/E,EAAE,MAAQ,QAAQ,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAC9E,EAAE,MAAQ,YAAY,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAClF,EAAE,MAAQ,WAAW,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,EACnF;AACF;;;ADLA,IAAM,YAAY,cAAc,IAAI,IAAI,KAAK,YAAY,GAAG,CAAC;AAQtD,IAAM,mBAAmB,CAAC,eAAuB,aAA6B;AAGnF,QAAM,gBAAgB,UAAU,SAAS,MAAM,IAAI,mBAAmB;AACtE,SAAO,KAAK,WAAW,eAAe,eAAe,QAAQ;AAC/D;AAKO,IAAM,WAAW,iBAAkB;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/registry.json"],"sourcesContent":["import { join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport componentRegistry from \"./registry.json\" with { type: \"json\" };\n\n/**\n * Component metadata interface describing a Starwind UI component\n */\nexport interface ComponentMeta {\n name: string;\n version: string;\n type: \"component\";\n dependencies: string[];\n}\n\n/**\n * Registry interface containing all available components\n */\nexport interface Registry {\n components: ComponentMeta[];\n}\n\nconst __dirname = fileURLToPath(new URL(\".\", import.meta.url));\n\n/**\n * Get the absolute path to a component file\n * @param {string} componentName - The name of the component\n * @param {string} fileName - The name of the file within the component\n * @returns {string} The absolute path to the component file\n */\nexport const getComponentPath = (componentName: string, fileName: string): string => {\n // In production (when installed as a dependency), the components will be in dist/src/components\n // In development, they will be in src/components\n const componentsDir = __dirname.includes(\"dist\") ? \"src/components\" : \"src/components\";\n return join(__dirname, componentsDir, componentName, fileName);\n};\n\n/**\n * Map of all components and their metadata from registry\n */\nexport const registry = componentRegistry.components as ComponentMeta[];\n","{\n \"$schema\": \"https://starwind.dev/registry-schema.json\",\n \"components\": [\n { \"name\": \"accordion\", \"type\": \"component\", \"version\": \"1.2.0\", \"dependencies\": [] },\n { \"name\": \"alert\", \"type\": \"component\", \"version\": \"1.2.0\", \"dependencies\": [] },\n {\n \"name\": \"alert-dialog\",\n \"type\": \"component\",\n \"version\": \"1.0.0\",\n \"dependencies\": [\"@starwind-ui/core/button@^2.1.0\"]\n },\n { \"name\": \"avatar\", \"type\": \"component\", \"version\": \"1.2.0\", \"dependencies\": [] },\n { \"name\": \"badge\", \"type\": \"component\", \"version\": \"1.2.0\", \"dependencies\": [] },\n { \"name\": \"breadcrumb\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n { \"name\": \"button\", \"type\": \"component\", \"version\": \"2.1.0\", \"dependencies\": [] },\n { \"name\": \"card\", \"type\": \"component\", \"version\": \"1.2.0\", \"dependencies\": [] },\n {\n \"name\": \"carousel\",\n \"type\": \"component\",\n \"version\": \"1.0.0\",\n \"dependencies\": [\"@starwind-ui/core/button@^2.1.0\", \"embla-carousel@^8.6.0\"]\n },\n { \"name\": \"checkbox\", \"type\": \"component\", \"version\": \"1.3.0\", \"dependencies\": [] },\n { \"name\": \"dialog\", \"type\": \"component\", \"version\": \"1.3.0\", \"dependencies\": [] },\n { \"name\": \"dropdown\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n { \"name\": \"dropzone\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n { \"name\": \"input\", \"type\": \"component\", \"version\": \"1.2.0\", \"dependencies\": [] },\n { \"name\": \"label\", \"type\": \"component\", \"version\": \"1.2.0\", \"dependencies\": [] },\n { \"name\": \"pagination\", \"type\": \"component\", \"version\": \"2.1.0\", \"dependencies\": [] },\n { \"name\": \"progress\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n { \"name\": \"radio-group\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n { \"name\": \"select\", \"type\": \"component\", \"version\": \"1.5.0\", \"dependencies\": [] },\n {\n \"name\": \"sheet\",\n \"type\": \"component\",\n \"version\": \"1.0.0\",\n \"dependencies\": [\"@starwind-ui/core/dialog@^1.3.0\"]\n },\n { \"name\": \"skeleton\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n { \"name\": \"switch\", \"type\": \"component\", \"version\": \"1.2.0\", \"dependencies\": [] },\n { \"name\": \"table\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n { \"name\": \"tabs\", \"type\": \"component\", \"version\": \"1.3.0\", \"dependencies\": [] },\n { \"name\": \"textarea\", \"type\": \"component\", \"version\": \"1.2.0\", \"dependencies\": [] },\n { \"name\": \"tooltip\", \"type\": \"component\", \"version\": \"1.2.0\", \"dependencies\": [] }\n ]\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,qBAAqB;;;ACD9B;AAAA,EACE,SAAW;AAAA,EACX,YAAc;AAAA,IACZ,EAAE,MAAQ,aAAa,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IACnF,EAAE,MAAQ,SAAS,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAC/E;AAAA,MACE,MAAQ;AAAA,MACR,MAAQ;AAAA,MACR,SAAW;AAAA,MACX,cAAgB,CAAC,iCAAiC;AAAA,IACpD;AAAA,IACA,EAAE,MAAQ,UAAU,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAChF,EAAE,MAAQ,SAAS,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAC/E,EAAE,MAAQ,cAAc,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IACpF,EAAE,MAAQ,UAAU,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAChF,EAAE,MAAQ,QAAQ,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAC9E;AAAA,MACE,MAAQ;AAAA,MACR,MAAQ;AAAA,MACR,SAAW;AAAA,MACX,cAAgB,CAAC,mCAAmC,uBAAuB;AAAA,IAC7E;AAAA,IACA,EAAE,MAAQ,YAAY,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAClF,EAAE,MAAQ,UAAU,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAChF,EAAE,MAAQ,YAAY,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAClF,EAAE,MAAQ,YAAY,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAClF,EAAE,MAAQ,SAAS,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAC/E,EAAE,MAAQ,SAAS,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAC/E,EAAE,MAAQ,cAAc,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IACpF,EAAE,MAAQ,YAAY,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAClF,EAAE,MAAQ,eAAe,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IACrF,EAAE,MAAQ,UAAU,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAChF;AAAA,MACE,MAAQ;AAAA,MACR,MAAQ;AAAA,MACR,SAAW;AAAA,MACX,cAAgB,CAAC,iCAAiC;AAAA,IACpD;AAAA,IACA,EAAE,MAAQ,YAAY,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAClF,EAAE,MAAQ,UAAU,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAChF,EAAE,MAAQ,SAAS,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAC/E,EAAE,MAAQ,QAAQ,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAC9E,EAAE,MAAQ,YAAY,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAClF,EAAE,MAAQ,WAAW,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,EACnF;AACF;;;ADvBA,IAAM,YAAY,cAAc,IAAI,IAAI,KAAK,YAAY,GAAG,CAAC;AAQtD,IAAM,mBAAmB,CAAC,eAAuB,aAA6B;AAGnF,QAAM,gBAAgB,UAAU,SAAS,MAAM,IAAI,mBAAmB;AACtE,SAAO,KAAK,WAAW,eAAe,eAAe,QAAQ;AAC/D;AAKO,IAAM,WAAW,iBAAkB;","names":[]}
@@ -13,12 +13,18 @@ type Props = HTMLAttributes<"div"> & {
13
13
  defaultValue?: string;
14
14
  };
15
15
 
16
- const accordion = tv({ base: "starwind-accordion" });
16
+ export const accordion = tv({ base: "starwind-accordion" });
17
17
 
18
18
  const { type = "single", defaultValue, class: className, ...rest } = Astro.props;
19
19
  ---
20
20
 
21
- <div class={accordion({ class: className })} data-type={type} data-value={defaultValue} {...rest}>
21
+ <div
22
+ class={accordion({ class: className })}
23
+ data-type={type}
24
+ data-value={defaultValue}
25
+ data-slot="accordion"
26
+ {...rest}
27
+ >
22
28
  <slot />
23
29
  </div>
24
30
 
@@ -8,7 +8,7 @@ import { tv } from "tailwind-variants";
8
8
 
9
9
  type Props = HTMLAttributes<"div">;
10
10
 
11
- const accordionContent = tv({
11
+ export const accordionContent = tv({
12
12
  base: [
13
13
  "starwind-accordion-content",
14
14
  "transform-gpu overflow-hidden",
@@ -24,6 +24,7 @@ const { class: className, ...rest } = Astro.props;
24
24
  class={accordionContent({ class: className })}
25
25
  data-state="closed"
26
26
  style="animation: none;"
27
+ data-slot="accordion-content"
27
28
  {...rest}
28
29
  >
29
30
  <div class="overflow-hidden px-5 pt-0 pb-4">
@@ -9,13 +9,19 @@ type Props = HTMLAttributes<"div"> & {
9
9
  value: string;
10
10
  };
11
11
 
12
- const accordionItem = tv({
12
+ export const accordionItem = tv({
13
13
  base: "starwind-accordion-item border-x border-b first:rounded-t-lg first:border-t last:rounded-b-lg",
14
14
  });
15
15
 
16
16
  const { value, class: className, ...rest } = Astro.props;
17
17
  ---
18
18
 
19
- <div class={accordionItem({ class: className })} data-value={value} data-state="closed" {...rest}>
19
+ <div
20
+ class={accordionItem({ class: className })}
21
+ data-value={value}
22
+ data-state="closed"
23
+ data-slot="accordion-item"
24
+ {...rest}
25
+ >
20
26
  <slot />
21
27
  </div>
@@ -5,7 +5,7 @@ import { tv } from "tailwind-variants";
5
5
 
6
6
  type Props = HTMLAttributes<"button">;
7
7
 
8
- const accordionTrigger = tv({
8
+ export const accordionTrigger = tv({
9
9
  base: [
10
10
  "starwind-accordion-trigger",
11
11
  "flex w-full items-center justify-between gap-4 rounded-md px-5 py-4",
@@ -21,6 +21,7 @@ const { class: className, ...rest } = Astro.props;
21
21
  <button
22
22
  type="button"
23
23
  class={accordionTrigger({ class: className })}
24
+ data-slot="accordion-trigger"
24
25
  aria-expanded="false"
25
26
  {...rest}
26
27
  >
@@ -1,9 +1,11 @@
1
- import Accordion from "./Accordion.astro";
2
- import AccordionContent from "./AccordionContent.astro";
3
- import AccordionItem from "./AccordionItem.astro";
4
- import AccordionTrigger from "./AccordionTrigger.astro";
1
+ import Accordion, { accordion } from "./Accordion.astro";
2
+ import AccordionContent, { accordionContent } from "./AccordionContent.astro";
3
+ import AccordionItem, { accordionItem } from "./AccordionItem.astro";
4
+ import AccordionTrigger, { accordionTrigger } from "./AccordionTrigger.astro";
5
5
 
6
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger };
6
+ const AccordionVariants = { accordion, accordionContent, accordionItem, accordionTrigger };
7
+
8
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AccordionVariants };
7
9
 
8
10
  export default {
9
11
  Root: Accordion,
@@ -4,7 +4,7 @@ import { tv, type VariantProps } from "tailwind-variants";
4
4
 
5
5
  type Props = HTMLAttributes<"div"> & VariantProps<typeof alert>;
6
6
 
7
- const alert = tv({
7
+ export const alert = tv({
8
8
  base: "text-foreground relative w-full rounded-lg border p-4",
9
9
  variants: {
10
10
  variant: {
@@ -21,8 +21,11 @@ const alert = tv({
21
21
  });
22
22
 
23
23
  const { variant, class: className, ...rest } = Astro.props;
24
+
25
+ const inferredRole =
26
+ rest.role ?? (variant === "error" || variant === "warning" ? "alert" : "status");
24
27
  ---
25
28
 
26
- <div class={alert({ variant, class: className })} {...rest}>
29
+ <div class={alert({ variant, class: className })} data-slot="alert" role={inferredRole} {...rest}>
27
30
  <slot />
28
31
  </div>
@@ -2,13 +2,13 @@
2
2
  import type { HTMLAttributes } from "astro/types";
3
3
  import { tv } from "tailwind-variants";
4
4
 
5
- const alertDescription = tv({ base: "[&_p]:leading-relaxed" });
5
+ export const alertDescription = tv({ base: "leading-relaxed" });
6
6
 
7
- type Props = HTMLAttributes<"div">;
7
+ type Props = HTMLAttributes<"p">;
8
8
 
9
9
  const { class: className, ...rest } = Astro.props;
10
10
  ---
11
11
 
12
- <div class={alertDescription({ class: className })} {...rest}>
12
+ <p class={alertDescription({ class: className })} data-slot="alert-description" {...rest}>
13
13
  <slot />
14
- </div>
14
+ </p>
@@ -2,15 +2,15 @@
2
2
  import type { HTMLAttributes } from "astro/types";
3
3
  import { tv } from "tailwind-variants";
4
4
 
5
- const alertTitle = tv({
5
+ export const alertTitle = tv({
6
6
  base: "mb-2 flex items-center gap-2 text-lg leading-none font-medium tracking-tight",
7
7
  });
8
8
 
9
- type Props = HTMLAttributes<"div">;
9
+ type Props = HTMLAttributes<"h5">;
10
10
 
11
11
  const { class: className, ...rest } = Astro.props;
12
12
  ---
13
13
 
14
- <h5 class={alertTitle({ class: className })} {...rest}>
14
+ <h5 class={alertTitle({ class: className })} data-slot="alert-title" {...rest}>
15
15
  <slot />
16
16
  </h5>
@@ -1,8 +1,10 @@
1
- import Alert from "./Alert.astro";
2
- import AlertDescription from "./AlertDescription.astro";
3
- import AlertTitle from "./AlertTitle.astro";
1
+ import Alert, { alert } from "./Alert.astro";
2
+ import AlertDescription, { alertDescription } from "./AlertDescription.astro";
3
+ import AlertTitle, { alertTitle } from "./AlertTitle.astro";
4
4
 
5
- export { Alert, AlertDescription, AlertTitle };
5
+ const AlertVariants = { alert, alertDescription, alertTitle };
6
+
7
+ export { Alert, AlertDescription, AlertTitle, AlertVariants };
6
8
 
7
9
  export default {
8
10
  Root: Alert,
@@ -0,0 +1,273 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+
4
+ type Props = HTMLAttributes<"div">;
5
+
6
+ const { class: className, ...rest } = Astro.props;
7
+ ---
8
+
9
+ <div class:list={["starwind-alert-dialog", className]} data-slot="alert-dialog" {...rest}>
10
+ <slot />
11
+ </div>
12
+
13
+ <script>
14
+ class AlertDialogHandler {
15
+ private triggers: HTMLButtonElement[] = [];
16
+ private dialog: HTMLDialogElement | null = null;
17
+ private closeButtons: HTMLButtonElement[] = [];
18
+ private actionButtons: HTMLButtonElement[] = [];
19
+ private backdrop: HTMLElement | null = null;
20
+ private dialogId: string;
21
+ /**
22
+ * The duration of the animation in milliseconds. This is used to calculate the
23
+ * duration of close animation before hiding the dialog and backdrop
24
+ */
25
+ private animationDuration: number;
26
+
27
+ constructor(dialogWrapper: HTMLElement, dialogNumber: number) {
28
+ this.dialog = dialogWrapper.querySelector("dialog");
29
+ this.backdrop = dialogWrapper.querySelector(".starwind-alert-dialog-backdrop");
30
+ if (!this.dialog || !this.backdrop) {
31
+ throw new Error("AlertDialog: dialog or backdrop not found");
32
+ }
33
+
34
+ // if no ID was provided for the wrapper, generate one
35
+ if (dialogWrapper.id) {
36
+ this.dialogId = dialogWrapper.id;
37
+ } else {
38
+ this.dialogId = `starwind-alert-dialog${dialogNumber}`;
39
+ dialogWrapper.id = this.dialogId;
40
+ }
41
+
42
+ // animationDuration is set with inline styles through passed prop to DialogContent
43
+ const animationDurationString = this.dialog.style.animationDuration;
44
+ if (animationDurationString.endsWith("ms")) {
45
+ this.animationDuration = parseFloat(animationDurationString);
46
+ } else if (animationDurationString.endsWith("s")) {
47
+ // using something like @playform/compress might optimize to use "s" instead of "ms"
48
+ this.animationDuration = parseFloat(animationDurationString) * 1000;
49
+ } else {
50
+ this.animationDuration = 200;
51
+ }
52
+
53
+ // Find internal triggers and handle them
54
+ const internalTriggers = dialogWrapper.querySelectorAll(".starwind-alert-dialog-trigger");
55
+ internalTriggers.forEach((triggerElement) => {
56
+ const tempTrigger = triggerElement as HTMLElement;
57
+ let trigger: HTMLButtonElement;
58
+
59
+ if (tempTrigger?.hasAttribute("data-as-child")) {
60
+ trigger = tempTrigger.firstElementChild as HTMLButtonElement;
61
+ } else {
62
+ trigger = tempTrigger as HTMLButtonElement;
63
+ }
64
+
65
+ if (trigger) {
66
+ this.triggers.push(trigger);
67
+ }
68
+ });
69
+
70
+ // Find external triggers that target this dialog
71
+ this.findExternalTriggers();
72
+
73
+ // if closeButtons are set with asChild, swap the wrapper with its first child
74
+ const tempCloseButtons = dialogWrapper.querySelectorAll(
75
+ ".starwind-alert-dialog-close",
76
+ ) as NodeListOf<HTMLElement>;
77
+ tempCloseButtons.forEach((button: HTMLElement) => {
78
+ if (button.hasAttribute("data-as-child")) {
79
+ const childElement = button.firstElementChild;
80
+ if (childElement) {
81
+ childElement.classList.add("starwind-alert-dialog-close");
82
+ button.parentNode?.replaceChild(childElement, button);
83
+ }
84
+ }
85
+ return button;
86
+ });
87
+
88
+ // Convert NodeList to Array for consistency with triggers
89
+ this.closeButtons = Array.from(
90
+ dialogWrapper.querySelectorAll(".starwind-alert-dialog-close"),
91
+ ) as HTMLButtonElement[];
92
+
93
+ // if actionButtons are set with asChild, swap the wrapper with its first child
94
+ const tempActionButtons = dialogWrapper.querySelectorAll(
95
+ ".starwind-alert-dialog-action",
96
+ ) as NodeListOf<HTMLElement>;
97
+ tempActionButtons.forEach((button: HTMLElement) => {
98
+ if (button.hasAttribute("data-as-child")) {
99
+ const childElement = button.firstElementChild;
100
+ if (childElement) {
101
+ childElement.classList.add("starwind-alert-dialog-action");
102
+ button.parentNode?.replaceChild(childElement, button);
103
+ }
104
+ }
105
+ return button;
106
+ });
107
+
108
+ // Convert NodeList to Array for consistency with triggers
109
+ this.actionButtons = Array.from(
110
+ dialogWrapper.querySelectorAll(".starwind-alert-dialog-action"),
111
+ ) as HTMLButtonElement[];
112
+
113
+ // if essential elements are not there, exit
114
+ if (!this.dialog || !this.backdrop) return;
115
+
116
+ this.setupAccessibility(dialogNumber);
117
+ this.setupEvents();
118
+ }
119
+
120
+ private setupAccessibility(dialogNumber: number): void {
121
+ // get the first heading element in the dialog
122
+ const firstHeading = this.dialog?.querySelector("h1, h2, h3, h4, h5, h6");
123
+ if (firstHeading) {
124
+ // create a unique ID for the heading
125
+ firstHeading.id = `starwind-alert-dialog${dialogNumber}-heading`;
126
+ // set the aria-labelledby attribute to the first heading element
127
+ this.dialog?.setAttribute("aria-labelledby", firstHeading.id);
128
+ }
129
+ }
130
+
131
+ /**
132
+ * Find all external triggers that target this dialog
133
+ */
134
+ private findExternalTriggers(): void {
135
+ const externalTriggers = document.querySelectorAll(
136
+ `.starwind-alert-dialog-trigger[data-dialog-for="${this.dialogId}"]`,
137
+ );
138
+
139
+ externalTriggers.forEach((triggerElement) => {
140
+ // Skip if this is an internal trigger we already processed
141
+ const dialogWrapper = triggerElement.closest(".starwind-alert-dialog");
142
+ if (dialogWrapper && dialogWrapper.id === this.dialogId) {
143
+ return;
144
+ }
145
+
146
+ let trigger: HTMLButtonElement;
147
+ if (triggerElement.hasAttribute("data-as-child")) {
148
+ trigger = triggerElement.firstElementChild as HTMLButtonElement;
149
+ } else {
150
+ trigger = triggerElement as HTMLButtonElement;
151
+ }
152
+
153
+ if (trigger && !this.triggers.includes(trigger)) {
154
+ this.triggers.push(trigger);
155
+ }
156
+ });
157
+ }
158
+
159
+ private setupEvents(): void {
160
+ if (!this.dialog) return;
161
+ // Add click listeners to all triggers
162
+ this.triggers.forEach((trigger) => {
163
+ trigger.addEventListener("click", () => {
164
+ this.open();
165
+ });
166
+ });
167
+
168
+ // Add click handlers to all close buttons
169
+ this.closeButtons.forEach((button) => {
170
+ button.addEventListener("click", () => {
171
+ // Only close if this is the topmost dialog
172
+ const openDialogs = document.querySelectorAll("dialog[open]");
173
+ if (openDialogs.length > 0 && openDialogs[openDialogs.length - 1] === this.dialog) {
174
+ this.close();
175
+ }
176
+ });
177
+ });
178
+
179
+ // Add click handlers to all action buttons
180
+ this.actionButtons.forEach((button) => {
181
+ button.addEventListener("click", () => {
182
+ // Only close if this is the topmost dialog
183
+ const openDialogs = document.querySelectorAll("dialog[open]");
184
+ if (openDialogs.length > 0 && openDialogs[openDialogs.length - 1] === this.dialog) {
185
+ this.close();
186
+ }
187
+ });
188
+ });
189
+
190
+ // Handle escape key
191
+ this.dialog.addEventListener("keydown", (e) => {
192
+ if (e.key === "Escape") {
193
+ // prevent default dialog closing behavior so we can add closing animation
194
+ e.preventDefault();
195
+ // Only close if this is the topmost dialog
196
+ const openDialogs = document.querySelectorAll("dialog[open]");
197
+ if (openDialogs.length > 0 && openDialogs[openDialogs.length - 1] === this.dialog) {
198
+ this.close();
199
+ }
200
+ }
201
+ });
202
+
203
+ // Intercept form submissions to handle dialog close
204
+ const forms = this.dialog.querySelectorAll("form");
205
+ forms.forEach((form) => {
206
+ form.addEventListener("submit", (e) => {
207
+ /**
208
+ * Default form.method = "dialog" submissions cause the dialog to close
209
+ * Default form.method = "post" submissions do not close the dialog
210
+ * Here we intercept the form submission and manage the dialog closing if method = "dialog"
211
+ * so we can add closing animation
212
+ * Normal form event listeners for "submit" will still get the form data
213
+ */
214
+ if (form.method === "dialog") {
215
+ e.preventDefault();
216
+ // Only close if this is the topmost dialog
217
+ const openDialogs = document.querySelectorAll("dialog[open]");
218
+ if (openDialogs.length > 0 && openDialogs[openDialogs.length - 1] === this.dialog) {
219
+ this.close();
220
+ }
221
+ }
222
+ });
223
+ });
224
+ }
225
+
226
+ private open(): void {
227
+ if (!this.dialog || !this.backdrop) return;
228
+ this.dialog.showModal();
229
+ document.body.classList.add("overflow-hidden");
230
+ this.backdrop.classList.remove("hidden");
231
+ this.backdrop.dataset.state = "open";
232
+ this.dialog.dataset.state = "open";
233
+ }
234
+
235
+ private close(): void {
236
+ if (!this.dialog || !this.backdrop) return;
237
+ this.dialog.dataset.state = "closed";
238
+ this.backdrop.dataset.state = "closed";
239
+
240
+ // Wait for animation to finish before hiding backdrop
241
+ setTimeout(() => {
242
+ this.backdrop?.classList.add("hidden");
243
+ this.dialog?.close();
244
+ const stillOpen = document.querySelectorAll("dialog[open]").length;
245
+ if (stillOpen === 0) {
246
+ document.body.classList.remove("overflow-hidden");
247
+ }
248
+ }, this.animationDuration);
249
+ }
250
+ }
251
+
252
+ // Store instances in a WeakMap to avoid memory leaks
253
+ const alertDialogInstances = new WeakMap<HTMLElement, AlertDialogHandler>();
254
+
255
+ // Initialize all dialogs
256
+ const setupAlertDialogs = () => {
257
+ document.querySelectorAll(".starwind-alert-dialog").forEach((dialogWrapper, idx) => {
258
+ const wrapper = dialogWrapper as HTMLElement;
259
+ if (!alertDialogInstances.has(wrapper)) {
260
+ alertDialogInstances.set(wrapper, new AlertDialogHandler(wrapper, idx));
261
+ }
262
+ });
263
+ };
264
+
265
+ setupAlertDialogs();
266
+ document.addEventListener("astro:after-swap", setupAlertDialogs);
267
+ </script>
268
+
269
+ <style>
270
+ .overflow-hidden {
271
+ overflow: hidden;
272
+ }
273
+ </style>
@@ -0,0 +1,44 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+
4
+ import { ButtonVariants } from "@/components/starwind/button";
5
+
6
+ type Props = HTMLAttributes<"button"> & {
7
+ /**
8
+ * When true, the component will render its child element instead of a button
9
+ */
10
+ asChild?: boolean;
11
+ };
12
+
13
+ const { class: className, asChild = false, ...rest } = Astro.props;
14
+
15
+ // Get the first child element if asChild is true
16
+ let hasChildren = false;
17
+ if (Astro.slots.has("default")) {
18
+ hasChildren = true;
19
+ }
20
+ ---
21
+
22
+ {
23
+ asChild && hasChildren ? (
24
+ <div
25
+ class:list={["starwind-alert-dialog-action", className]}
26
+ data-slot="alert-dialog-action"
27
+ data-as-child
28
+ >
29
+ <slot />
30
+ </div>
31
+ ) : (
32
+ <button
33
+ type="button"
34
+ class={ButtonVariants.button({
35
+ variant: "default",
36
+ class: `starwind-alert-dialog-action ${className}`,
37
+ })}
38
+ data-slot="alert-dialog-action"
39
+ {...rest}
40
+ >
41
+ <slot />
42
+ </button>
43
+ )
44
+ }
@@ -0,0 +1,45 @@
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import { tv } from "tailwind-variants";
4
+
5
+ import { ButtonVariants } from "@/components/starwind/button";
6
+
7
+ type Props = HTMLAttributes<"button"> & {
8
+ /**
9
+ * When true, the component will render its child element instead of a button
10
+ */
11
+ asChild?: boolean;
12
+ };
13
+
14
+ const { class: className, asChild = false, ...rest } = Astro.props;
15
+
16
+ // Get the first child element if asChild is true
17
+ let hasChildren = false;
18
+ if (Astro.slots.has("default")) {
19
+ hasChildren = true;
20
+ }
21
+ ---
22
+
23
+ {
24
+ asChild && hasChildren ? (
25
+ <div
26
+ class:list={["starwind-alert-dialog-close", className]}
27
+ data-slot="alert-dialog-cancel"
28
+ data-as-child
29
+ >
30
+ <slot />
31
+ </div>
32
+ ) : (
33
+ <button
34
+ type="button"
35
+ class={ButtonVariants.button({
36
+ variant: "outline",
37
+ class: `starwind-alert-dialog-close ${className}`,
38
+ })}
39
+ data-slot="alert-dialog-cancel"
40
+ {...rest}
41
+ >
42
+ <slot />
43
+ </button>
44
+ )
45
+ }