@starwind-ui/core 1.6.1 → 1.7.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 (101) hide show
  1. package/dist/index.js +5 -1
  2. package/dist/index.js.map +1 -1
  3. package/dist/src/components/accordion/Accordion.astro +224 -224
  4. package/dist/src/components/accordion/AccordionContent.astro +13 -13
  5. package/dist/src/components/accordion/AccordionItem.astro +6 -6
  6. package/dist/src/components/accordion/AccordionTrigger.astro +13 -13
  7. package/dist/src/components/accordion/index.ts +4 -4
  8. package/dist/src/components/alert/Alert.astro +15 -15
  9. package/dist/src/components/alert/AlertDescription.astro +1 -1
  10. package/dist/src/components/alert/AlertTitle.astro +2 -2
  11. package/dist/src/components/alert/index.ts +3 -3
  12. package/dist/src/components/avatar/Avatar.astro +16 -16
  13. package/dist/src/components/avatar/AvatarFallback.astro +3 -3
  14. package/dist/src/components/avatar/AvatarImage.astro +12 -12
  15. package/dist/src/components/avatar/index.ts +4 -4
  16. package/dist/src/components/badge/Badge.astro +33 -33
  17. package/dist/src/components/breadcrumb/Breadcrumb.astro +1 -1
  18. package/dist/src/components/breadcrumb/BreadcrumbEllipsis.astro +6 -6
  19. package/dist/src/components/breadcrumb/BreadcrumbItem.astro +1 -1
  20. package/dist/src/components/breadcrumb/BreadcrumbLink.astro +8 -8
  21. package/dist/src/components/breadcrumb/BreadcrumbList.astro +2 -2
  22. package/dist/src/components/breadcrumb/BreadcrumbPage.astro +6 -6
  23. package/dist/src/components/breadcrumb/BreadcrumbSeparator.astro +7 -7
  24. package/dist/src/components/breadcrumb/index.ts +14 -14
  25. package/dist/src/components/button/Button.astro +38 -38
  26. package/dist/src/components/card/Card.astro +1 -1
  27. package/dist/src/components/card/CardContent.astro +1 -1
  28. package/dist/src/components/card/CardDescription.astro +1 -1
  29. package/dist/src/components/card/CardFooter.astro +1 -1
  30. package/dist/src/components/card/CardHeader.astro +1 -1
  31. package/dist/src/components/card/CardTitle.astro +1 -1
  32. package/dist/src/components/card/index.ts +7 -7
  33. package/dist/src/components/checkbox/Checkbox.astro +89 -89
  34. package/dist/src/components/dialog/Dialog.astro +178 -178
  35. package/dist/src/components/dialog/DialogClose.astro +14 -14
  36. package/dist/src/components/dialog/DialogContent.astro +32 -32
  37. package/dist/src/components/dialog/DialogDescription.astro +1 -1
  38. package/dist/src/components/dialog/DialogFooter.astro +1 -1
  39. package/dist/src/components/dialog/DialogHeader.astro +1 -1
  40. package/dist/src/components/dialog/DialogTitle.astro +6 -6
  41. package/dist/src/components/dialog/DialogTrigger.astro +19 -19
  42. package/dist/src/components/dialog/index.ts +16 -16
  43. package/dist/src/components/dropdown/Dropdown.astro +359 -359
  44. package/dist/src/components/dropdown/DropdownContent.astro +63 -63
  45. package/dist/src/components/dropdown/DropdownItem.astro +31 -31
  46. package/dist/src/components/dropdown/DropdownLabel.astro +14 -14
  47. package/dist/src/components/dropdown/DropdownSeparator.astro +5 -5
  48. package/dist/src/components/dropdown/DropdownTrigger.astro +26 -26
  49. package/dist/src/components/dropdown/index.ts +12 -12
  50. package/dist/src/components/dropzone/Dropzone.astro +232 -0
  51. package/dist/src/components/dropzone/DropzoneFilesList.astro +25 -0
  52. package/dist/src/components/dropzone/DropzoneLoadingIndicator.astro +10 -0
  53. package/dist/src/components/dropzone/DropzoneUploadIndicator.astro +10 -0
  54. package/dist/src/components/dropzone/index.ts +13 -0
  55. package/dist/src/components/input/Input.astro +12 -12
  56. package/dist/src/components/label/Label.astro +8 -8
  57. package/dist/src/components/pagination/Pagination.astro +1 -1
  58. package/dist/src/components/pagination/PaginationContent.astro +3 -3
  59. package/dist/src/components/pagination/PaginationEllipsis.astro +2 -2
  60. package/dist/src/components/pagination/PaginationItem.astro +3 -3
  61. package/dist/src/components/pagination/PaginationLink.astro +27 -27
  62. package/dist/src/components/pagination/PaginationNext.astro +7 -6
  63. package/dist/src/components/pagination/PaginationPrevious.astro +7 -6
  64. package/dist/src/components/pagination/index.ts +14 -14
  65. package/dist/src/components/progress/Progress.astro +151 -0
  66. package/dist/src/components/progress/index.ts +5 -0
  67. package/dist/src/components/radio-group/RadioGroup.astro +156 -0
  68. package/dist/src/components/radio-group/RadioGroupItem.astro +125 -0
  69. package/dist/src/components/radio-group/RadioGroupTypes.ts +6 -0
  70. package/dist/src/components/radio-group/index.ts +10 -0
  71. package/dist/src/components/select/Select.astro +475 -463
  72. package/dist/src/components/select/SelectContent.astro +62 -62
  73. package/dist/src/components/select/SelectItem.astro +27 -27
  74. package/dist/src/components/select/SelectLabel.astro +1 -1
  75. package/dist/src/components/select/SelectTrigger.astro +28 -28
  76. package/dist/src/components/select/SelectTypes.ts +5 -5
  77. package/dist/src/components/select/SelectValue.astro +5 -5
  78. package/dist/src/components/select/index.ts +16 -16
  79. package/dist/src/components/skeleton/Skeleton.astro +14 -0
  80. package/dist/src/components/skeleton/index.ts +5 -0
  81. package/dist/src/components/switch/Switch.astro +150 -150
  82. package/dist/src/components/switch/SwitchTypes.ts +4 -4
  83. package/dist/src/components/table/Table.astro +5 -5
  84. package/dist/src/components/table/TableBody.astro +3 -3
  85. package/dist/src/components/table/TableCaption.astro +3 -3
  86. package/dist/src/components/table/TableCell.astro +3 -3
  87. package/dist/src/components/table/TableFoot.astro +3 -3
  88. package/dist/src/components/table/TableHead.astro +3 -3
  89. package/dist/src/components/table/TableHeader.astro +3 -3
  90. package/dist/src/components/table/TableRow.astro +3 -3
  91. package/dist/src/components/table/index.ts +8 -8
  92. package/dist/src/components/tabs/Tabs.astro +250 -250
  93. package/dist/src/components/tabs/TabsContent.astro +10 -10
  94. package/dist/src/components/tabs/TabsList.astro +2 -2
  95. package/dist/src/components/tabs/TabsTrigger.astro +15 -15
  96. package/dist/src/components/tabs/index.ts +4 -4
  97. package/dist/src/components/textarea/Textarea.astro +16 -16
  98. package/dist/src/components/tooltip/Tooltip.astro +217 -217
  99. package/dist/src/components/tooltip/TooltipContent.astro +81 -81
  100. package/dist/src/components/tooltip/index.ts +3 -3
  101. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -16,10 +16,14 @@ var registry_default = {
16
16
  { name: "checkbox", type: "component", version: "1.2.0", dependencies: [] },
17
17
  { name: "dialog", type: "component", version: "1.1.3", dependencies: [] },
18
18
  { name: "dropdown", type: "component", version: "1.0.3", dependencies: [] },
19
+ { name: "dropzone", type: "component", version: "1.0.0", dependencies: [] },
19
20
  { name: "input", type: "component", version: "1.1.1", dependencies: [] },
20
21
  { name: "label", type: "component", version: "1.1.1", dependencies: [] },
21
22
  { name: "pagination", type: "component", version: "2.0.1", dependencies: [] },
22
- { name: "select", type: "component", version: "1.3.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.3.2", dependencies: [] },
26
+ { name: "skeleton", type: "component", version: "1.0.0", dependencies: [] },
23
27
  { name: "switch", type: "component", version: "1.1.0", dependencies: [] },
24
28
  { name: "table", type: "component", version: "1.0.0", dependencies: [] },
25
29
  { name: "tabs", type: "component", version: "1.2.0", dependencies: [] },
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\";\nimport componentRegistry from \"./registry.json\" with { type: \"json\" };\n\n/**\n * Component metadata interface describing a Starwind UI component\n */\nexport interface ComponentMeta {\n\tname: string;\n\tversion: string;\n\ttype: \"component\";\n\tdependencies: string[];\n}\n\n/**\n * Registry interface containing all available components\n */\nexport interface Registry {\n\tcomponents: 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\t// In production (when installed as a dependency), the components will be in dist/src/components\n\t// In development, they will be in src/components\n\tconst componentsDir = __dirname.includes(\"dist\") ? \"src/components\" : \"src/components\";\n\treturn 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\t\"$schema\": \"https://starwind.dev/registry-schema.json\",\n\t\"components\": [\n\t\t{ \"name\": \"accordion\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"alert\", \"type\": \"component\", \"version\": \"1.1.1\", \"dependencies\": [] },\n\t\t{ \"name\": \"avatar\", \"type\": \"component\", \"version\": \"1.1.1\", \"dependencies\": [] },\n\t\t{ \"name\": \"badge\", \"type\": \"component\", \"version\": \"1.1.1\", \"dependencies\": [] },\n\t\t{ \"name\": \"breadcrumb\", \"type\": \"component\", \"version\": \"1.0.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"button\", \"type\": \"component\", \"version\": \"2.0.1\", \"dependencies\": [] },\n\t\t{ \"name\": \"card\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"checkbox\", \"type\": \"component\", \"version\": \"1.2.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"dialog\", \"type\": \"component\", \"version\": \"1.1.3\", \"dependencies\": [] },\n\t\t{ \"name\": \"dropdown\", \"type\": \"component\", \"version\": \"1.0.3\", \"dependencies\": [] },\n\t\t{ \"name\": \"input\", \"type\": \"component\", \"version\": \"1.1.1\", \"dependencies\": [] },\n\t\t{ \"name\": \"label\", \"type\": \"component\", \"version\": \"1.1.1\", \"dependencies\": [] },\n\t\t{ \"name\": \"pagination\", \"type\": \"component\", \"version\": \"2.0.1\", \"dependencies\": [] },\n\t\t{ \"name\": \"select\", \"type\": \"component\", \"version\": \"1.3.1\", \"dependencies\": [] },\n\t\t{ \"name\": \"switch\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"table\", \"type\": \"component\", \"version\": \"1.0.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"tabs\", \"type\": \"component\", \"version\": \"1.2.0\", \"dependencies\": [] },\n\t\t{ \"name\": \"textarea\", \"type\": \"component\", \"version\": \"1.1.1\", \"dependencies\": [] },\n\t\t{ \"name\": \"tooltip\", \"type\": \"component\", \"version\": \"1.1.2\", \"dependencies\": [] }\n\t]\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,qBAAqB;;;ACD9B;AAAA,EACC,SAAW;AAAA,EACX,YAAc;AAAA,IACb,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,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,UAAU,MAAQ,aAAa,SAAW,SAAS,cAAgB,CAAC,EAAE;AAAA,IAChF,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,EAClF;AACD;;;ADFA,IAAM,YAAY,cAAc,IAAI,IAAI,KAAK,YAAY,GAAG,CAAC;AAQtD,IAAM,mBAAmB,CAAC,eAAuB,aAA6B;AAGpF,QAAM,gBAAgB,UAAU,SAAS,MAAM,IAAI,mBAAmB;AACtE,SAAO,KAAK,WAAW,eAAe,eAAe,QAAQ;AAC9D;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.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.1.3\", \"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.3.2\", \"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":[]}
@@ -3,14 +3,14 @@ import type { HTMLAttributes } from "astro/types";
3
3
  import { tv } from "tailwind-variants";
4
4
 
5
5
  type Props = HTMLAttributes<"div"> & {
6
- /**
7
- * The type of accordion. If "single", only one item can be open at a time.
8
- */
9
- type?: "single" | "multiple";
10
- /**
11
- * The value of the item that should be open by default
12
- */
13
- defaultValue?: string;
6
+ /**
7
+ * The type of accordion. If "single", only one item can be open at a time.
8
+ */
9
+ type?: "single" | "multiple";
10
+ /**
11
+ * The value of the item that should be open by default
12
+ */
13
+ defaultValue?: string;
14
14
  };
15
15
 
16
16
  const accordion = tv({ base: "starwind-accordion" });
@@ -19,223 +19,223 @@ const { type = "single", defaultValue, class: className, ...rest } = Astro.props
19
19
  ---
20
20
 
21
21
  <div class={accordion({ class: className })} data-type={type} data-value={defaultValue} {...rest}>
22
- <slot />
22
+ <slot />
23
23
  </div>
24
24
 
25
25
  <script>
26
- type AccordionType = "single" | "multiple";
27
- type AccordionState = "open" | "closed";
28
-
29
- /** Represents a single accordion item with its associated elements */
30
- interface AccordionItem {
31
- element: HTMLElement;
32
- trigger: HTMLElement;
33
- content: HTMLElement;
34
- value: string;
35
- }
36
-
37
- /**
38
- * Handles the functionality of an accordion component.
39
- * Supports single and multiple open items, keyboard navigation,
40
- * and maintains ARIA accessibility standards.
41
- */
42
- class AccordionHandler {
43
- private accordion: HTMLElement;
44
- private type: AccordionType;
45
- private items: AccordionItem[];
46
- private itemsByValue: Map<string, AccordionItem>;
47
- private accordionId: string;
48
-
49
- /**
50
- * Creates a new AccordionHandler instance
51
- * @param accordion - The root accordion element
52
- * @param idx - Unique index for this accordion instance
53
- */
54
- constructor(accordion: HTMLElement, idx: number) {
55
- this.accordion = accordion;
56
- this.type = (accordion.dataset.type || "single") as AccordionType;
57
- this.accordionId = `starwind-accordion${idx}`;
58
-
59
- // Cache all items and create lookup maps
60
- this.items = this.initializeItems();
61
- this.itemsByValue = new Map(this.items.map((item) => [item.value, item]));
62
-
63
- this.setupItems();
64
- this.setInitialState();
65
- }
66
-
67
- /**
68
- * Initializes accordion items by querying the DOM and setting up data structures
69
- * @returns Array of AccordionItem objects
70
- */
71
- private initializeItems(): AccordionItem[] {
72
- return Array.from(this.accordion.querySelectorAll<HTMLElement>(".starwind-accordion-item"))
73
- .map((element, idx) => {
74
- const trigger = element.querySelector<HTMLElement>(".starwind-accordion-trigger");
75
- const content = element.querySelector<HTMLElement>(".starwind-accordion-content");
76
- const value = element.getAttribute("data-value") || String(idx);
77
-
78
- if (!trigger || !content) return null;
79
-
80
- return { element, trigger, content, value };
81
- })
82
- .filter((item): item is AccordionItem => item !== null);
83
- }
84
-
85
- /**
86
- * Sets up initial state and event listeners for all accordion items
87
- */
88
- private setupItems(): void {
89
- this.items.forEach((item, idx) => {
90
- this.setupAccessibility(item, idx);
91
- this.setContentHeight(item.content);
92
- this.setupEventListeners(item);
93
- });
94
- }
95
-
96
- /**
97
- * Sets up ARIA attributes and IDs for accessibility
98
- * @param item - The accordion item to setup
99
- * @param idx - Index of the item
100
- */
101
- private setupAccessibility(item: AccordionItem, idx: number): void {
102
- const triggerId = `${this.accordionId}-t${idx}`;
103
- const contentId = `${this.accordionId}-c${idx}`;
104
-
105
- item.trigger.id = triggerId;
106
- item.trigger.setAttribute("aria-controls", contentId);
107
- item.trigger.setAttribute("aria-expanded", "false");
108
-
109
- item.content.id = contentId;
110
- item.content.setAttribute("aria-labelledby", triggerId);
111
- item.content.setAttribute("role", "region");
112
- }
113
-
114
- /**
115
- * Calculates and sets the content height CSS variable for animations
116
- * @param content - The content element to measure
117
- */
118
- private setContentHeight(content: HTMLElement): void {
119
- const contentInner = content.firstElementChild as HTMLElement;
120
- if (contentInner) {
121
- const height = contentInner.getBoundingClientRect().height;
122
- content.style.setProperty("--starwind-accordion-content-height", `${height}px`);
123
- }
124
- }
125
-
126
- /**
127
- * Sets the initial state based on the default value attribute
128
- */
129
- private setInitialState(): void {
130
- const defaultValue = this.accordion.dataset.value;
131
- if (defaultValue) {
132
- const item = this.itemsByValue.get(defaultValue);
133
- if (item) {
134
- this.setItemState(item, true);
135
- }
136
- }
137
- }
138
-
139
- /**
140
- * Sets up click and keyboard event listeners for an accordion item
141
- * @param item - The accordion item to setup listeners for
142
- */
143
- private setupEventListeners(item: AccordionItem): void {
144
- item.trigger.addEventListener("click", () => this.handleClick(item));
145
- item.trigger.addEventListener("keydown", (e) => this.handleKeyDown(e, item));
146
- }
147
-
148
- /**
149
- * Handles click events on accordion triggers
150
- * @param item - The clicked accordion item
151
- */
152
- private handleClick(item: AccordionItem): void {
153
- const isOpen = item.element.getAttribute("data-state") === "open";
154
- this.toggleItem(item, !isOpen);
155
- }
156
-
157
- /**
158
- * Handles keyboard navigation events
159
- * @param event - The keyboard event
160
- * @param item - The current accordion item
161
- */
162
- private handleKeyDown(event: KeyboardEvent, item: AccordionItem): void {
163
- const index = this.items.indexOf(item);
164
-
165
- const keyActions: Record<string, () => void> = {
166
- ArrowDown: () => this.focusItem(index + 1),
167
- ArrowUp: () => this.focusItem(index - 1),
168
- Home: () => this.focusItem(0),
169
- End: () => this.focusItem(this.items.length - 1),
170
- };
171
-
172
- const action = keyActions[event.key];
173
- if (action) {
174
- event.preventDefault();
175
- action();
176
- }
177
- }
178
-
179
- /**
180
- * Focuses an accordion item by index with wrapping
181
- * @param index - The target index to focus
182
- */
183
- private focusItem(index: number): void {
184
- const targetIndex = (index + this.items.length) % this.items.length;
185
- this.items[targetIndex].trigger.focus();
186
- }
187
-
188
- /**
189
- * Toggles an accordion item's state
190
- * @param item - The item to toggle
191
- * @param shouldOpen - Whether the item should be opened
192
- */
193
- private toggleItem(item: AccordionItem, shouldOpen: boolean): void {
194
- if (this.type === "single" && shouldOpen) {
195
- // Close other items if in single mode
196
- this.items.forEach((otherItem) => {
197
- if (otherItem !== item && otherItem.element.getAttribute("data-state") === "open") {
198
- this.setItemState(otherItem, false);
199
- }
200
- });
201
- }
202
-
203
- this.setItemState(item, shouldOpen);
204
- }
205
-
206
- /**
207
- * Sets the state of an accordion item
208
- * @param item - The item to update
209
- * @param isOpen - Whether the item should be open
210
- */
211
- private setItemState(item: AccordionItem, isOpen: boolean): void {
212
- const state: AccordionState = isOpen ? "open" : "closed";
213
-
214
- if (isOpen) {
215
- item.content.style.removeProperty("animation");
216
- }
217
-
218
- // Set content height variable for animations
219
- this.setContentHeight(item.content);
220
-
221
- item.element.setAttribute("data-state", state);
222
- item.content.setAttribute("data-state", state);
223
- item.trigger.setAttribute("data-state", state);
224
- item.trigger.setAttribute("aria-expanded", isOpen.toString());
225
- }
226
- }
227
-
228
- // Store instances in a WeakMap to avoid memory leaks
229
- const accordionInstances = new WeakMap<HTMLElement, AccordionHandler>();
230
-
231
- const setupAccordions = () => {
232
- document.querySelectorAll<HTMLElement>(".starwind-accordion").forEach((accordion, idx) => {
233
- if (!accordionInstances.has(accordion)) {
234
- accordionInstances.set(accordion, new AccordionHandler(accordion, idx));
235
- }
236
- });
237
- };
238
-
239
- setupAccordions();
240
- document.addEventListener("astro:after-swap", setupAccordions);
26
+ type AccordionType = "single" | "multiple";
27
+ type AccordionState = "open" | "closed";
28
+
29
+ /** Represents a single accordion item with its associated elements */
30
+ interface AccordionItem {
31
+ element: HTMLElement;
32
+ trigger: HTMLElement;
33
+ content: HTMLElement;
34
+ value: string;
35
+ }
36
+
37
+ /**
38
+ * Handles the functionality of an accordion component.
39
+ * Supports single and multiple open items, keyboard navigation,
40
+ * and maintains ARIA accessibility standards.
41
+ */
42
+ class AccordionHandler {
43
+ private accordion: HTMLElement;
44
+ private type: AccordionType;
45
+ private items: AccordionItem[];
46
+ private itemsByValue: Map<string, AccordionItem>;
47
+ private accordionId: string;
48
+
49
+ /**
50
+ * Creates a new AccordionHandler instance
51
+ * @param accordion - The root accordion element
52
+ * @param idx - Unique index for this accordion instance
53
+ */
54
+ constructor(accordion: HTMLElement, idx: number) {
55
+ this.accordion = accordion;
56
+ this.type = (accordion.dataset.type || "single") as AccordionType;
57
+ this.accordionId = `starwind-accordion${idx}`;
58
+
59
+ // Cache all items and create lookup maps
60
+ this.items = this.initializeItems();
61
+ this.itemsByValue = new Map(this.items.map((item) => [item.value, item]));
62
+
63
+ this.setupItems();
64
+ this.setInitialState();
65
+ }
66
+
67
+ /**
68
+ * Initializes accordion items by querying the DOM and setting up data structures
69
+ * @returns Array of AccordionItem objects
70
+ */
71
+ private initializeItems(): AccordionItem[] {
72
+ return Array.from(this.accordion.querySelectorAll<HTMLElement>(".starwind-accordion-item"))
73
+ .map((element, idx) => {
74
+ const trigger = element.querySelector<HTMLElement>(".starwind-accordion-trigger");
75
+ const content = element.querySelector<HTMLElement>(".starwind-accordion-content");
76
+ const value = element.getAttribute("data-value") || String(idx);
77
+
78
+ if (!trigger || !content) return null;
79
+
80
+ return { element, trigger, content, value };
81
+ })
82
+ .filter((item): item is AccordionItem => item !== null);
83
+ }
84
+
85
+ /**
86
+ * Sets up initial state and event listeners for all accordion items
87
+ */
88
+ private setupItems(): void {
89
+ this.items.forEach((item, idx) => {
90
+ this.setupAccessibility(item, idx);
91
+ this.setContentHeight(item.content);
92
+ this.setupEventListeners(item);
93
+ });
94
+ }
95
+
96
+ /**
97
+ * Sets up ARIA attributes and IDs for accessibility
98
+ * @param item - The accordion item to setup
99
+ * @param idx - Index of the item
100
+ */
101
+ private setupAccessibility(item: AccordionItem, idx: number): void {
102
+ const triggerId = `${this.accordionId}-t${idx}`;
103
+ const contentId = `${this.accordionId}-c${idx}`;
104
+
105
+ item.trigger.id = triggerId;
106
+ item.trigger.setAttribute("aria-controls", contentId);
107
+ item.trigger.setAttribute("aria-expanded", "false");
108
+
109
+ item.content.id = contentId;
110
+ item.content.setAttribute("aria-labelledby", triggerId);
111
+ item.content.setAttribute("role", "region");
112
+ }
113
+
114
+ /**
115
+ * Calculates and sets the content height CSS variable for animations
116
+ * @param content - The content element to measure
117
+ */
118
+ private setContentHeight(content: HTMLElement): void {
119
+ const contentInner = content.firstElementChild as HTMLElement;
120
+ if (contentInner) {
121
+ const height = contentInner.getBoundingClientRect().height;
122
+ content.style.setProperty("--starwind-accordion-content-height", `${height}px`);
123
+ }
124
+ }
125
+
126
+ /**
127
+ * Sets the initial state based on the default value attribute
128
+ */
129
+ private setInitialState(): void {
130
+ const defaultValue = this.accordion.dataset.value;
131
+ if (defaultValue) {
132
+ const item = this.itemsByValue.get(defaultValue);
133
+ if (item) {
134
+ this.setItemState(item, true);
135
+ }
136
+ }
137
+ }
138
+
139
+ /**
140
+ * Sets up click and keyboard event listeners for an accordion item
141
+ * @param item - The accordion item to setup listeners for
142
+ */
143
+ private setupEventListeners(item: AccordionItem): void {
144
+ item.trigger.addEventListener("click", () => this.handleClick(item));
145
+ item.trigger.addEventListener("keydown", (e) => this.handleKeyDown(e, item));
146
+ }
147
+
148
+ /**
149
+ * Handles click events on accordion triggers
150
+ * @param item - The clicked accordion item
151
+ */
152
+ private handleClick(item: AccordionItem): void {
153
+ const isOpen = item.element.getAttribute("data-state") === "open";
154
+ this.toggleItem(item, !isOpen);
155
+ }
156
+
157
+ /**
158
+ * Handles keyboard navigation events
159
+ * @param event - The keyboard event
160
+ * @param item - The current accordion item
161
+ */
162
+ private handleKeyDown(event: KeyboardEvent, item: AccordionItem): void {
163
+ const index = this.items.indexOf(item);
164
+
165
+ const keyActions: Record<string, () => void> = {
166
+ ArrowDown: () => this.focusItem(index + 1),
167
+ ArrowUp: () => this.focusItem(index - 1),
168
+ Home: () => this.focusItem(0),
169
+ End: () => this.focusItem(this.items.length - 1),
170
+ };
171
+
172
+ const action = keyActions[event.key];
173
+ if (action) {
174
+ event.preventDefault();
175
+ action();
176
+ }
177
+ }
178
+
179
+ /**
180
+ * Focuses an accordion item by index with wrapping
181
+ * @param index - The target index to focus
182
+ */
183
+ private focusItem(index: number): void {
184
+ const targetIndex = (index + this.items.length) % this.items.length;
185
+ this.items[targetIndex].trigger.focus();
186
+ }
187
+
188
+ /**
189
+ * Toggles an accordion item's state
190
+ * @param item - The item to toggle
191
+ * @param shouldOpen - Whether the item should be opened
192
+ */
193
+ private toggleItem(item: AccordionItem, shouldOpen: boolean): void {
194
+ if (this.type === "single" && shouldOpen) {
195
+ // Close other items if in single mode
196
+ this.items.forEach((otherItem) => {
197
+ if (otherItem !== item && otherItem.element.getAttribute("data-state") === "open") {
198
+ this.setItemState(otherItem, false);
199
+ }
200
+ });
201
+ }
202
+
203
+ this.setItemState(item, shouldOpen);
204
+ }
205
+
206
+ /**
207
+ * Sets the state of an accordion item
208
+ * @param item - The item to update
209
+ * @param isOpen - Whether the item should be open
210
+ */
211
+ private setItemState(item: AccordionItem, isOpen: boolean): void {
212
+ const state: AccordionState = isOpen ? "open" : "closed";
213
+
214
+ if (isOpen) {
215
+ item.content.style.removeProperty("animation");
216
+ }
217
+
218
+ // Set content height variable for animations
219
+ this.setContentHeight(item.content);
220
+
221
+ item.element.setAttribute("data-state", state);
222
+ item.content.setAttribute("data-state", state);
223
+ item.trigger.setAttribute("data-state", state);
224
+ item.trigger.setAttribute("aria-expanded", isOpen.toString());
225
+ }
226
+ }
227
+
228
+ // Store instances in a WeakMap to avoid memory leaks
229
+ const accordionInstances = new WeakMap<HTMLElement, AccordionHandler>();
230
+
231
+ const setupAccordions = () => {
232
+ document.querySelectorAll<HTMLElement>(".starwind-accordion").forEach((accordion, idx) => {
233
+ if (!accordionInstances.has(accordion)) {
234
+ accordionInstances.set(accordion, new AccordionHandler(accordion, idx));
235
+ }
236
+ });
237
+ };
238
+
239
+ setupAccordions();
240
+ document.addEventListener("astro:after-swap", setupAccordions);
241
241
  </script>
@@ -9,24 +9,24 @@ import { tv } from "tailwind-variants";
9
9
  type Props = HTMLAttributes<"div">;
10
10
 
11
11
  const accordionContent = tv({
12
- base: [
13
- "starwind-accordion-content",
14
- "transform-gpu overflow-hidden",
15
- "data-[state=closed]:animate-accordion-up data-[state=closed]:h-0",
16
- "data-[state=open]:animate-accordion-down",
17
- ],
12
+ base: [
13
+ "starwind-accordion-content",
14
+ "transform-gpu overflow-hidden",
15
+ "data-[state=closed]:animate-accordion-up data-[state=closed]:h-0",
16
+ "data-[state=open]:animate-accordion-down",
17
+ ],
18
18
  });
19
19
 
20
20
  const { class: className, ...rest } = Astro.props;
21
21
  ---
22
22
 
23
23
  <div
24
- class={accordionContent({ class: className })}
25
- data-state="closed"
26
- style="animation: none;"
27
- {...rest}
24
+ class={accordionContent({ class: className })}
25
+ data-state="closed"
26
+ style="animation: none;"
27
+ {...rest}
28
28
  >
29
- <div class="overflow-hidden px-5 pt-0 pb-4">
30
- <slot />
31
- </div>
29
+ <div class="overflow-hidden px-5 pt-0 pb-4">
30
+ <slot />
31
+ </div>
32
32
  </div>
@@ -3,19 +3,19 @@ import type { HTMLAttributes } from "astro/types";
3
3
  import { tv } from "tailwind-variants";
4
4
 
5
5
  type Props = HTMLAttributes<"div"> & {
6
- /**
7
- * The value of the item
8
- */
9
- value: string;
6
+ /**
7
+ * The value of the item
8
+ */
9
+ value: string;
10
10
  };
11
11
 
12
12
  const accordionItem = tv({
13
- base: "starwind-accordion-item border-x border-b first:rounded-t-lg first:border-t last:rounded-b-lg",
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
19
  <div class={accordionItem({ class: className })} data-value={value} data-state="closed" {...rest}>
20
- <slot />
20
+ <slot />
21
21
  </div>
@@ -6,24 +6,24 @@ import { tv } from "tailwind-variants";
6
6
  type Props = HTMLAttributes<"button">;
7
7
 
8
8
  const accordionTrigger = tv({
9
- base: [
10
- "starwind-accordion-trigger",
11
- "flex w-full items-center justify-between gap-4 rounded-md px-5 py-4",
12
- "starwind-transition-colors hover:text-muted-foreground text-left font-medium",
13
- "[&[data-state=open]>svg]:rotate-180",
14
- "focus-visible:outline-outline focus-visible:outline-2 focus-visible:outline-offset-0",
15
- ],
9
+ base: [
10
+ "starwind-accordion-trigger",
11
+ "flex w-full items-center justify-between gap-4 rounded-md px-5 py-4",
12
+ "starwind-transition-colors hover:text-muted-foreground text-left font-medium",
13
+ "[&[data-state=open]>svg]:rotate-180",
14
+ "focus-visible:outline-outline focus-visible:outline-2 focus-visible:outline-offset-0",
15
+ ],
16
16
  });
17
17
 
18
18
  const { class: className, ...rest } = Astro.props;
19
19
  ---
20
20
 
21
21
  <button
22
- type="button"
23
- class={accordionTrigger({ class: className })}
24
- aria-expanded="false"
25
- {...rest}
22
+ type="button"
23
+ class={accordionTrigger({ class: className })}
24
+ aria-expanded="false"
25
+ {...rest}
26
26
  >
27
- <slot />
28
- <ChevronDown class="size-5 shrink-0 transition-transform duration-200" />
27
+ <slot />
28
+ <ChevronDown class="size-5 shrink-0 transition-transform duration-200" />
29
29
  </button>
@@ -6,8 +6,8 @@ import AccordionTrigger from "./AccordionTrigger.astro";
6
6
  export { Accordion, AccordionContent, AccordionItem, AccordionTrigger };
7
7
 
8
8
  export default {
9
- Root: Accordion,
10
- Content: AccordionContent,
11
- Item: AccordionItem,
12
- Trigger: AccordionTrigger,
9
+ Root: Accordion,
10
+ Content: AccordionContent,
11
+ Item: AccordionItem,
12
+ Trigger: AccordionTrigger,
13
13
  };