@starwind-ui/core 1.8.0 → 1.10.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.
- package/dist/index.js +50 -23
- package/dist/index.js.map +1 -1
- package/dist/src/components/accordion/Accordion.astro +8 -2
- package/dist/src/components/accordion/AccordionContent.astro +2 -1
- package/dist/src/components/accordion/AccordionItem.astro +8 -2
- package/dist/src/components/accordion/AccordionTrigger.astro +4 -3
- package/dist/src/components/accordion/index.ts +7 -5
- package/dist/src/components/alert/Alert.astro +6 -3
- package/dist/src/components/alert/AlertDescription.astro +4 -4
- package/dist/src/components/alert/AlertTitle.astro +3 -3
- package/dist/src/components/alert/index.ts +6 -4
- package/dist/src/components/alert-dialog/AlertDialog.astro +273 -0
- package/dist/src/components/alert-dialog/AlertDialogAction.astro +44 -0
- package/dist/src/components/alert-dialog/AlertDialogCancel.astro +45 -0
- package/dist/src/components/alert-dialog/AlertDialogContent.astro +50 -0
- package/dist/src/components/alert-dialog/AlertDialogDescription.astro +18 -0
- package/dist/src/components/alert-dialog/AlertDialogFooter.astro +16 -0
- package/dist/src/components/alert-dialog/AlertDialogHeader.astro +14 -0
- package/dist/src/components/alert-dialog/AlertDialogTitle.astro +20 -0
- package/dist/src/components/alert-dialog/AlertDialogTrigger.astro +47 -0
- package/dist/src/components/alert-dialog/index.ts +46 -0
- package/dist/src/components/aspect-ratio/AspectRatio.astro +32 -0
- package/dist/src/components/aspect-ratio/index.ts +7 -0
- package/dist/src/components/avatar/Avatar.astro +2 -2
- package/dist/src/components/avatar/AvatarFallback.astro +2 -2
- package/dist/src/components/avatar/AvatarImage.astro +13 -2
- package/dist/src/components/avatar/index.ts +6 -4
- package/dist/src/components/badge/Badge.astro +15 -12
- package/dist/src/components/badge/index.ts +4 -2
- package/dist/src/components/breadcrumb/Breadcrumb.astro +1 -1
- package/dist/src/components/breadcrumb/BreadcrumbEllipsis.astro +4 -1
- package/dist/src/components/breadcrumb/BreadcrumbItem.astro +2 -2
- package/dist/src/components/breadcrumb/BreadcrumbLink.astro +2 -2
- package/dist/src/components/breadcrumb/BreadcrumbList.astro +2 -2
- package/dist/src/components/breadcrumb/BreadcrumbPage.astro +2 -1
- package/dist/src/components/breadcrumb/BreadcrumbSeparator.astro +2 -1
- package/dist/src/components/breadcrumb/index.ts +16 -6
- package/dist/src/components/button/Button.astro +15 -15
- package/dist/src/components/button/index.ts +4 -2
- package/dist/src/components/card/Card.astro +2 -2
- package/dist/src/components/card/CardContent.astro +2 -2
- package/dist/src/components/card/CardDescription.astro +2 -2
- package/dist/src/components/card/CardFooter.astro +2 -2
- package/dist/src/components/card/CardHeader.astro +2 -2
- package/dist/src/components/card/CardTitle.astro +2 -2
- package/dist/src/components/card/index.ts +16 -7
- package/dist/src/components/carousel/Carousel.astro +55 -0
- package/dist/src/components/carousel/CarouselContent.astro +26 -0
- package/dist/src/components/carousel/CarouselItem.astro +26 -0
- package/dist/src/components/carousel/CarouselNext.astro +33 -0
- package/dist/src/components/carousel/CarouselPrevious.astro +33 -0
- package/dist/src/components/carousel/carousel-script.ts +191 -0
- package/dist/src/components/carousel/index.ts +32 -0
- package/dist/src/components/checkbox/Checkbox.astro +28 -12
- package/dist/src/components/checkbox/index.ts +4 -2
- package/dist/src/components/dialog/Dialog.astro +24 -11
- package/dist/src/components/dialog/DialogClose.astro +7 -2
- package/dist/src/components/dialog/DialogContent.astro +9 -6
- package/dist/src/components/dialog/DialogDescription.astro +2 -2
- package/dist/src/components/dialog/DialogFooter.astro +2 -2
- package/dist/src/components/dialog/DialogHeader.astro +2 -2
- package/dist/src/components/dialog/DialogTitle.astro +2 -2
- package/dist/src/components/dialog/DialogTrigger.astro +7 -1
- package/dist/src/components/dialog/index.ts +20 -5
- package/dist/src/components/dropdown/Dropdown.astro +1 -0
- package/dist/src/components/dropdown/DropdownContent.astro +2 -1
- package/dist/src/components/dropdown/DropdownItem.astro +2 -1
- package/dist/src/components/dropdown/DropdownLabel.astro +2 -2
- package/dist/src/components/dropdown/DropdownSeparator.astro +3 -2
- package/dist/src/components/dropdown/DropdownTrigger.astro +9 -3
- package/dist/src/components/dropdown/index.ts +14 -5
- package/dist/src/components/dropzone/Dropzone.astro +7 -6
- package/dist/src/components/dropzone/DropzoneFilesList.astro +3 -2
- package/dist/src/components/dropzone/DropzoneLoadingIndicator.astro +1 -1
- package/dist/src/components/dropzone/DropzoneUploadIndicator.astro +1 -1
- package/dist/src/components/dropzone/index.ts +14 -3
- package/dist/src/components/input/Input.astro +4 -4
- package/dist/src/components/input/index.ts +4 -2
- package/dist/src/components/item/Item.astro +52 -0
- package/dist/src/components/item/ItemActions.astro +16 -0
- package/dist/src/components/item/ItemContent.astro +16 -0
- package/dist/src/components/item/ItemDescription.astro +19 -0
- package/dist/src/components/item/ItemFooter.astro +16 -0
- package/dist/src/components/item/ItemGroup.astro +16 -0
- package/dist/src/components/item/ItemHeader.astro +16 -0
- package/dist/src/components/item/ItemMedia.astro +40 -0
- package/dist/src/components/item/ItemSeparator.astro +21 -0
- package/dist/src/components/item/ItemTitle.astro +16 -0
- package/dist/src/components/item/index.ts +50 -0
- package/dist/src/components/label/Label.astro +2 -2
- package/dist/src/components/label/index.ts +4 -2
- package/dist/src/components/pagination/Pagination.astro +8 -2
- package/dist/src/components/pagination/PaginationContent.astro +2 -2
- package/dist/src/components/pagination/PaginationEllipsis.astro +7 -2
- package/dist/src/components/pagination/PaginationItem.astro +2 -2
- package/dist/src/components/pagination/PaginationLink.astro +10 -29
- package/dist/src/components/pagination/PaginationNext.astro +2 -1
- package/dist/src/components/pagination/PaginationPrevious.astro +2 -1
- package/dist/src/components/pagination/index.ts +18 -7
- package/dist/src/components/progress/Progress.astro +6 -3
- package/dist/src/components/progress/index.ts +7 -2
- package/dist/src/components/radio-group/RadioGroup.astro +2 -1
- package/dist/src/components/radio-group/RadioGroupItem.astro +17 -15
- package/dist/src/components/radio-group/index.ts +16 -3
- package/dist/src/components/select/Select.astro +1 -0
- package/dist/src/components/select/SelectContent.astro +3 -2
- package/dist/src/components/select/SelectGroup.astro +1 -1
- package/dist/src/components/select/SelectItem.astro +3 -2
- package/dist/src/components/select/SelectLabel.astro +2 -2
- package/dist/src/components/select/SelectSeparator.astro +2 -2
- package/dist/src/components/select/SelectTrigger.astro +4 -3
- package/dist/src/components/select/SelectValue.astro +2 -2
- package/dist/src/components/select/index.ts +18 -6
- package/dist/src/components/separator/Separator.astro +36 -0
- package/dist/src/components/separator/index.ts +7 -0
- package/dist/src/components/sheet/Sheet.astro +13 -0
- package/dist/src/components/sheet/SheetClose.astro +13 -0
- package/dist/src/components/sheet/SheetContent.astro +88 -0
- package/dist/src/components/sheet/SheetDescription.astro +16 -0
- package/dist/src/components/sheet/SheetFooter.astro +16 -0
- package/dist/src/components/sheet/SheetHeader.astro +16 -0
- package/dist/src/components/sheet/SheetTitle.astro +16 -0
- package/dist/src/components/sheet/SheetTrigger.astro +13 -0
- package/dist/src/components/sheet/index.ts +41 -0
- package/dist/src/components/skeleton/Skeleton.astro +3 -3
- package/dist/src/components/skeleton/index.ts +6 -2
- package/dist/src/components/spinner/Spinner.astro +21 -0
- package/dist/src/components/spinner/index.ts +7 -0
- package/dist/src/components/switch/Switch.astro +16 -13
- package/dist/src/components/switch/index.ts +8 -2
- package/dist/src/components/table/Table.astro +3 -3
- package/dist/src/components/table/TableBody.astro +2 -2
- package/dist/src/components/table/TableCaption.astro +2 -2
- package/dist/src/components/table/TableCell.astro +2 -2
- package/dist/src/components/table/TableFoot.astro +2 -2
- package/dist/src/components/table/TableHead.astro +2 -2
- package/dist/src/components/table/TableHeader.astro +2 -2
- package/dist/src/components/table/TableRow.astro +2 -2
- package/dist/src/components/table/index.ts +30 -9
- package/dist/src/components/tabs/Tabs.astro +2 -1
- package/dist/src/components/tabs/TabsContent.astro +4 -1
- package/dist/src/components/tabs/TabsList.astro +9 -3
- package/dist/src/components/tabs/TabsTrigger.astro +6 -3
- package/dist/src/components/tabs/index.ts +12 -5
- package/dist/src/components/textarea/Textarea.astro +4 -4
- package/dist/src/components/textarea/index.ts +6 -2
- package/dist/src/components/tooltip/Tooltip.astro +2 -1
- package/dist/src/components/tooltip/TooltipContent.astro +21 -5
- package/dist/src/components/tooltip/TooltipTrigger.astro +1 -1
- package/dist/src/components/tooltip/index.ts +8 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,29 +6,56 @@ 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.
|
|
10
|
-
{ name: "alert", type: "component", version: "1.
|
|
11
|
-
{
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
{ name: "
|
|
18
|
-
{ name: "
|
|
19
|
-
{ name: "
|
|
20
|
-
{ name: "
|
|
21
|
-
{ name: "
|
|
22
|
-
{ name: "
|
|
23
|
-
{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
{ name: "
|
|
30
|
-
{ name: "
|
|
31
|
-
{ name: "
|
|
9
|
+
{ name: "accordion", type: "component", version: "1.3.0", dependencies: [] },
|
|
10
|
+
{ name: "alert", type: "component", version: "1.3.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: "aspect-ratio", type: "component", version: "1.0.0", dependencies: [] },
|
|
18
|
+
{ name: "avatar", type: "component", version: "1.2.0", dependencies: [] },
|
|
19
|
+
{ name: "badge", type: "component", version: "1.3.0", dependencies: [] },
|
|
20
|
+
{ name: "breadcrumb", type: "component", version: "1.1.0", dependencies: [] },
|
|
21
|
+
{ name: "button", type: "component", version: "2.2.0", dependencies: [] },
|
|
22
|
+
{ name: "card", type: "component", version: "1.3.0", dependencies: [] },
|
|
23
|
+
{
|
|
24
|
+
name: "carousel",
|
|
25
|
+
type: "component",
|
|
26
|
+
version: "1.0.0",
|
|
27
|
+
dependencies: ["@starwind-ui/core/button@^2.1.0", "embla-carousel@^8.6.0"]
|
|
28
|
+
},
|
|
29
|
+
{ name: "checkbox", type: "component", version: "1.4.0", dependencies: [] },
|
|
30
|
+
{ name: "dialog", type: "component", version: "1.4.0", dependencies: [] },
|
|
31
|
+
{ name: "dropdown", type: "component", version: "1.2.0", dependencies: [] },
|
|
32
|
+
{ name: "dropzone", type: "component", version: "1.1.0", dependencies: [] },
|
|
33
|
+
{ name: "input", type: "component", version: "1.3.0", dependencies: [] },
|
|
34
|
+
{
|
|
35
|
+
name: "item",
|
|
36
|
+
type: "component",
|
|
37
|
+
version: "1.0.0",
|
|
38
|
+
dependencies: ["@starwind-ui/core/separator@^1.0.0"]
|
|
39
|
+
},
|
|
40
|
+
{ name: "label", type: "component", version: "1.2.0", dependencies: [] },
|
|
41
|
+
{ name: "pagination", type: "component", version: "3.0.0", dependencies: [] },
|
|
42
|
+
{ name: "progress", type: "component", version: "1.1.0", dependencies: [] },
|
|
43
|
+
{ name: "radio-group", type: "component", version: "1.2.0", dependencies: [] },
|
|
44
|
+
{ name: "select", type: "component", version: "1.6.0", dependencies: [] },
|
|
45
|
+
{ name: "separator", type: "component", version: "1.0.0", dependencies: [] },
|
|
46
|
+
{
|
|
47
|
+
name: "sheet",
|
|
48
|
+
type: "component",
|
|
49
|
+
version: "1.1.0",
|
|
50
|
+
dependencies: ["@starwind-ui/core/dialog@^1.3.0"]
|
|
51
|
+
},
|
|
52
|
+
{ name: "skeleton", type: "component", version: "1.2.0", dependencies: [] },
|
|
53
|
+
{ name: "spinner", type: "component", version: "1.0.0", dependencies: [] },
|
|
54
|
+
{ name: "switch", type: "component", version: "1.3.0", dependencies: [] },
|
|
55
|
+
{ name: "table", type: "component", version: "1.1.0", dependencies: [] },
|
|
56
|
+
{ name: "tabs", type: "component", version: "1.4.0", dependencies: [] },
|
|
57
|
+
{ name: "textarea", type: "component", version: "1.3.0", dependencies: [] },
|
|
58
|
+
{ name: "tooltip", type: "component", version: "1.3.0", dependencies: [] }
|
|
32
59
|
]
|
|
33
60
|
};
|
|
34
61
|
|
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
|
+
{"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.3.0\", \"dependencies\": [] },\n { \"name\": \"alert\", \"type\": \"component\", \"version\": \"1.3.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\": \"aspect-ratio\", \"type\": \"component\", \"version\": \"1.0.0\", \"dependencies\": [] },\n { \"name\": \"avatar\", \"type\": \"component\", \"version\": \"1.2.0\", \"dependencies\": [] },\n { \"name\": \"badge\", \"type\": \"component\", \"version\": \"1.3.0\", \"dependencies\": [] },\n { \"name\": \"breadcrumb\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n { \"name\": \"button\", \"type\": \"component\", \"version\": \"2.2.0\", \"dependencies\": [] },\n { \"name\": \"card\", \"type\": \"component\", \"version\": \"1.3.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.4.0\", \"dependencies\": [] },\n { \"name\": \"dialog\", \"type\": \"component\", \"version\": \"1.4.0\", \"dependencies\": [] },\n { \"name\": \"dropdown\", \"type\": \"component\", \"version\": \"1.2.0\", \"dependencies\": [] },\n { \"name\": \"dropzone\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n { \"name\": \"input\", \"type\": \"component\", \"version\": \"1.3.0\", \"dependencies\": [] },\n {\n \"name\": \"item\",\n \"type\": \"component\",\n \"version\": \"1.0.0\",\n \"dependencies\": [\"@starwind-ui/core/separator@^1.0.0\"]\n },\n { \"name\": \"label\", \"type\": \"component\", \"version\": \"1.2.0\", \"dependencies\": [] },\n { \"name\": \"pagination\", \"type\": \"component\", \"version\": \"3.0.0\", \"dependencies\": [] },\n { \"name\": \"progress\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n { \"name\": \"radio-group\", \"type\": \"component\", \"version\": \"1.2.0\", \"dependencies\": [] },\n { \"name\": \"select\", \"type\": \"component\", \"version\": \"1.6.0\", \"dependencies\": [] },\n { \"name\": \"separator\", \"type\": \"component\", \"version\": \"1.0.0\", \"dependencies\": [] },\n {\n \"name\": \"sheet\",\n \"type\": \"component\",\n \"version\": \"1.1.0\",\n \"dependencies\": [\"@starwind-ui/core/dialog@^1.3.0\"]\n },\n { \"name\": \"skeleton\", \"type\": \"component\", \"version\": \"1.2.0\", \"dependencies\": [] },\n { \"name\": \"spinner\", \"type\": \"component\", \"version\": \"1.0.0\", \"dependencies\": [] },\n { \"name\": \"switch\", \"type\": \"component\", \"version\": \"1.3.0\", \"dependencies\": [] },\n { \"name\": \"table\", \"type\": \"component\", \"version\": \"1.1.0\", \"dependencies\": [] },\n { \"name\": \"tabs\", \"type\": \"component\", \"version\": \"1.4.0\", \"dependencies\": [] },\n { \"name\": \"textarea\", \"type\": \"component\", \"version\": \"1.3.0\", \"dependencies\": [] },\n { \"name\": \"tooltip\", \"type\": \"component\", \"version\": \"1.3.0\", \"dependencies\": [] }\n ]\n}\n"],"mappings":"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","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
|
|
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
|
|
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,13 +5,13 @@ 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",
|
|
12
|
-
"
|
|
12
|
+
"hover:text-muted-foreground text-left font-medium transition-all",
|
|
13
13
|
"[&[data-state=open]>svg]:rotate-180",
|
|
14
|
-
"focus-visible:
|
|
14
|
+
"focus-visible:border-outline focus-visible:ring-outline/50 outline-none focus-visible:ring-3",
|
|
15
15
|
],
|
|
16
16
|
});
|
|
17
17
|
|
|
@@ -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
|
-
|
|
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,11 +4,11 @@ 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: {
|
|
11
|
-
default: "bg-background [&>h5>svg]:text-foreground",
|
|
11
|
+
default: "bg-background dark:bg-input/30 [&>h5>svg]:text-foreground",
|
|
12
12
|
primary: "border-primary bg-primary/7 [&>h5>svg]:text-primary",
|
|
13
13
|
secondary: "border-secondary bg-secondary/7 [&>h5>svg]:text-secondary",
|
|
14
14
|
info: "border-info bg-info/7 [&>h5>svg]:text-info",
|
|
@@ -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: "
|
|
5
|
+
export const alertDescription = tv({ base: "leading-relaxed" });
|
|
6
6
|
|
|
7
|
-
type Props = HTMLAttributes<"
|
|
7
|
+
type Props = HTMLAttributes<"p">;
|
|
8
8
|
|
|
9
9
|
const { class: className, ...rest } = Astro.props;
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
<
|
|
12
|
+
<p class={alertDescription({ class: className })} data-slot="alert-description" {...rest}>
|
|
13
13
|
<slot />
|
|
14
|
-
</
|
|
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<"
|
|
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
|
-
|
|
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
|
+
}
|