@mzc-fe/design-system 0.0.1 → 0.0.2
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/components/accordion.d.ts +7 -0
- package/dist/components/alert-dialog.d.ts +14 -0
- package/dist/components/alert.d.ts +9 -0
- package/dist/components/aspect-ratio.d.ts +3 -0
- package/dist/components/avatar.d.ts +6 -0
- package/dist/components/badge.d.ts +9 -0
- package/dist/components/breadcrumb.d.ts +11 -0
- package/dist/components/button-group.d.ts +11 -0
- package/dist/components/button.d.ts +10 -0
- package/dist/components/calendar.d.ts +8 -0
- package/dist/components/card.d.ts +9 -0
- package/dist/components/carousel.d.ts +19 -0
- package/dist/components/chart.d.ts +40 -0
- package/dist/components/checkbox.d.ts +4 -0
- package/dist/components/collapsible.d.ts +5 -0
- package/dist/components/command.d.ts +18 -0
- package/dist/components/context-menu.d.ts +25 -0
- package/dist/components/dialog.d.ts +15 -0
- package/dist/components/drawer.d.ts +13 -0
- package/dist/components/dropdown-menu.d.ts +25 -0
- package/dist/components/empty.d.ts +11 -0
- package/dist/components/field.d.ts +24 -0
- package/dist/components/form.d.ts +24 -0
- package/dist/components/hover-card.d.ts +6 -0
- package/dist/components/input-group.d.ts +16 -0
- package/dist/components/input-otp.d.ts +11 -0
- package/dist/components/input.d.ts +3 -0
- package/dist/components/item.d.ts +23 -0
- package/dist/components/kbd.d.ts +3 -0
- package/dist/components/label.d.ts +4 -0
- package/dist/components/menubar.d.ts +26 -0
- package/dist/components/navigation-menu.d.ts +14 -0
- package/dist/components/pagination.d.ts +13 -0
- package/dist/components/popover.d.ts +7 -0
- package/dist/components/progress.d.ts +4 -0
- package/dist/components/radio-group.d.ts +5 -0
- package/dist/components/resizable.d.ts +8 -0
- package/dist/components/scroll-area.d.ts +5 -0
- package/dist/components/select.d.ts +15 -0
- package/dist/components/separator.d.ts +4 -0
- package/dist/components/sheet.d.ts +13 -0
- package/dist/components/sidebar.d.ts +69 -0
- package/dist/components/skeleton.d.ts +2 -0
- package/dist/components/slider.d.ts +4 -0
- package/dist/components/sonner.d.ts +3 -0
- package/dist/components/spinner.d.ts +2 -0
- package/dist/components/switch.d.ts +4 -0
- package/dist/components/table.d.ts +10 -0
- package/dist/components/tabs.d.ts +7 -0
- package/dist/components/textarea.d.ts +3 -0
- package/dist/components/toggle-group.d.ts +9 -0
- package/dist/components/toggle.d.ts +9 -0
- package/dist/components/tooltip.d.ts +7 -0
- package/dist/design-system.css +1 -0
- package/dist/design-system.es.js +30200 -0
- package/dist/design-system.umd.js +260 -0
- package/dist/foundations/ThemeProvider.d.ts +13 -0
- package/dist/hooks/use-mobile.d.ts +1 -0
- package/dist/index.d.ts +54 -0
- package/dist/lib/utils.d.ts +2 -0
- package/package.json +14 -1
- package/.husky/pre-push +0 -21
- package/.storybook/main.ts +0 -11
- package/.storybook/preview.tsx +0 -30
- package/.vscode/settings.json +0 -12
- package/.vscode/tailwind.json +0 -105
- package/bitbucket-pipelines.yml +0 -50
- package/components.json +0 -21
- package/eslint.config.js +0 -38
- package/src/components/accordion.stories.tsx +0 -258
- package/src/components/accordion.test.tsx +0 -390
- package/src/components/accordion.tsx +0 -64
- package/src/components/alert-dialog.stories.tsx +0 -213
- package/src/components/alert-dialog.test.tsx +0 -80
- package/src/components/alert-dialog.tsx +0 -155
- package/src/components/alert.stories.tsx +0 -84
- package/src/components/alert.test.tsx +0 -35
- package/src/components/alert.tsx +0 -66
- package/src/components/aspect-ratio.stories.tsx +0 -97
- package/src/components/aspect-ratio.test.tsx +0 -47
- package/src/components/aspect-ratio.tsx +0 -11
- package/src/components/avatar.stories.tsx +0 -76
- package/src/components/avatar.test.tsx +0 -50
- package/src/components/avatar.tsx +0 -51
- package/src/components/badge.stories.tsx +0 -64
- package/src/components/badge.test.tsx +0 -34
- package/src/components/badge.tsx +0 -46
- package/src/components/breadcrumb.stories.tsx +0 -86
- package/src/components/breadcrumb.test.tsx +0 -74
- package/src/components/breadcrumb.tsx +0 -109
- package/src/components/button-group.stories.tsx +0 -62
- package/src/components/button-group.tsx +0 -83
- package/src/components/button.stories.tsx +0 -118
- package/src/components/button.test.tsx +0 -64
- package/src/components/button.tsx +0 -62
- package/src/components/calendar.stories.tsx +0 -81
- package/src/components/calendar.tsx +0 -220
- package/src/components/card.stories.tsx +0 -110
- package/src/components/card.test.tsx +0 -56
- package/src/components/card.tsx +0 -92
- package/src/components/carousel.stories.tsx +0 -90
- package/src/components/carousel.tsx +0 -239
- package/src/components/chart.tsx +0 -357
- package/src/components/checkbox.stories.tsx +0 -108
- package/src/components/checkbox.test.tsx +0 -67
- package/src/components/checkbox.tsx +0 -32
- package/src/components/collapsible.stories.tsx +0 -106
- package/src/components/collapsible.test.tsx +0 -92
- package/src/components/collapsible.tsx +0 -31
- package/src/components/command.stories.tsx +0 -90
- package/src/components/command.tsx +0 -182
- package/src/components/context-menu.stories.tsx +0 -63
- package/src/components/context-menu.tsx +0 -252
- package/src/components/dialog.stories.tsx +0 -128
- package/src/components/dialog.tsx +0 -141
- package/src/components/drawer.stories.tsx +0 -104
- package/src/components/drawer.tsx +0 -135
- package/src/components/dropdown-menu.stories.tsx +0 -97
- package/src/components/dropdown-menu.tsx +0 -255
- package/src/components/empty.stories.tsx +0 -90
- package/src/components/empty.test.tsx +0 -55
- package/src/components/empty.tsx +0 -104
- package/src/components/field.tsx +0 -246
- package/src/components/form.tsx +0 -168
- package/src/components/hover-card.stories.tsx +0 -66
- package/src/components/hover-card.tsx +0 -44
- package/src/components/input-group.stories.tsx +0 -57
- package/src/components/input-group.test.tsx +0 -40
- package/src/components/input-group.tsx +0 -170
- package/src/components/input-otp.stories.tsx +0 -94
- package/src/components/input-otp.test.tsx +0 -60
- package/src/components/input-otp.tsx +0 -75
- package/src/components/input.stories.tsx +0 -94
- package/src/components/input.test.tsx +0 -53
- package/src/components/input.tsx +0 -21
- package/src/components/item.tsx +0 -193
- package/src/components/kbd.stories.tsx +0 -100
- package/src/components/kbd.test.tsx +0 -28
- package/src/components/kbd.tsx +0 -28
- package/src/components/label.stories.tsx +0 -48
- package/src/components/label.test.tsx +0 -28
- package/src/components/label.tsx +0 -24
- package/src/components/menubar.tsx +0 -274
- package/src/components/navigation-menu.tsx +0 -168
- package/src/components/pagination.stories.tsx +0 -107
- package/src/components/pagination.tsx +0 -127
- package/src/components/popover.stories.tsx +0 -102
- package/src/components/popover.tsx +0 -48
- package/src/components/progress.stories.tsx +0 -76
- package/src/components/progress.test.tsx +0 -36
- package/src/components/progress.tsx +0 -29
- package/src/components/radio-group.stories.tsx +0 -73
- package/src/components/radio-group.test.tsx +0 -74
- package/src/components/radio-group.tsx +0 -45
- package/src/components/resizable.stories.tsx +0 -120
- package/src/components/resizable.tsx +0 -54
- package/src/components/scroll-area.stories.tsx +0 -64
- package/src/components/scroll-area.test.tsx +0 -46
- package/src/components/scroll-area.tsx +0 -58
- package/src/components/select.stories.tsx +0 -111
- package/src/components/select.test.tsx +0 -90
- package/src/components/select.tsx +0 -188
- package/src/components/separator.stories.tsx +0 -76
- package/src/components/separator.test.tsx +0 -24
- package/src/components/separator.tsx +0 -28
- package/src/components/sheet.stories.tsx +0 -122
- package/src/components/sheet.tsx +0 -137
- package/src/components/sidebar.tsx +0 -726
- package/src/components/skeleton.stories.tsx +0 -53
- package/src/components/skeleton.test.tsx +0 -24
- package/src/components/skeleton.tsx +0 -13
- package/src/components/slider.stories.tsx +0 -97
- package/src/components/slider.test.tsx +0 -49
- package/src/components/slider.tsx +0 -63
- package/src/components/sonner.stories.tsx +0 -96
- package/src/components/sonner.tsx +0 -38
- package/src/components/spinner.stories.tsx +0 -54
- package/src/components/spinner.test.tsx +0 -30
- package/src/components/spinner.tsx +0 -16
- package/src/components/switch.stories.tsx +0 -108
- package/src/components/switch.test.tsx +0 -62
- package/src/components/switch.tsx +0 -31
- package/src/components/table.stories.tsx +0 -139
- package/src/components/table.test.tsx +0 -85
- package/src/components/table.tsx +0 -114
- package/src/components/tabs.stories.tsx +0 -99
- package/src/components/tabs.test.tsx +0 -64
- package/src/components/tabs.tsx +0 -66
- package/src/components/textarea.stories.tsx +0 -89
- package/src/components/textarea.test.tsx +0 -53
- package/src/components/textarea.tsx +0 -18
- package/src/components/toggle-group.stories.tsx +0 -108
- package/src/components/toggle-group.test.tsx +0 -66
- package/src/components/toggle-group.tsx +0 -81
- package/src/components/toggle.stories.tsx +0 -98
- package/src/components/toggle.test.tsx +0 -42
- package/src/components/toggle.tsx +0 -45
- package/src/components/tooltip.stories.tsx +0 -111
- package/src/components/tooltip.tsx +0 -61
- package/src/foundations/README.md +0 -141
- package/src/foundations/ThemeProvider.tsx +0 -77
- package/src/foundations/color.css +0 -232
- package/src/foundations/color.stories.tsx +0 -719
- package/src/foundations/palette.css +0 -249
- package/src/foundations/spacing.css +0 -8
- package/src/foundations/typography.css +0 -143
- package/src/foundations/typography.stories.tsx +0 -17
- package/src/hooks/use-mobile.ts +0 -19
- package/src/index.css +0 -176
- package/src/index.ts +0 -336
- package/src/lib/utils.ts +0 -6
- package/src/test/setup.ts +0 -8
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.app.json +0 -33
- package/tsconfig.json +0 -13
- package/tsconfig.node.json +0 -25
- package/vite.config.ts +0 -30
- package/vitest.config.ts +0 -25
- /package/{public → dist}/vite.svg +0 -0
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from "vitest";
|
|
2
|
-
import { render } from "@testing-library/react";
|
|
3
|
-
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import {
|
|
5
|
-
Collapsible,
|
|
6
|
-
CollapsibleTrigger,
|
|
7
|
-
CollapsibleContent,
|
|
8
|
-
} from "./collapsible";
|
|
9
|
-
|
|
10
|
-
describe("Collapsible", () => {
|
|
11
|
-
it("should render collapsible", () => {
|
|
12
|
-
const { container } = render(
|
|
13
|
-
<Collapsible>
|
|
14
|
-
<CollapsibleTrigger>Toggle</CollapsibleTrigger>
|
|
15
|
-
<CollapsibleContent>Content</CollapsibleContent>
|
|
16
|
-
</Collapsible>
|
|
17
|
-
);
|
|
18
|
-
const collapsible = container.querySelector('[data-slot="collapsible"]');
|
|
19
|
-
expect(collapsible).toBeInTheDocument();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("should render trigger and content", () => {
|
|
23
|
-
const { getByText, container } = render(
|
|
24
|
-
<Collapsible>
|
|
25
|
-
<CollapsibleTrigger>Toggle</CollapsibleTrigger>
|
|
26
|
-
<CollapsibleContent>Content</CollapsibleContent>
|
|
27
|
-
</Collapsible>
|
|
28
|
-
);
|
|
29
|
-
expect(getByText("Toggle")).toBeInTheDocument();
|
|
30
|
-
// Content is in DOM but may be hidden when closed
|
|
31
|
-
const content = container.querySelector(
|
|
32
|
-
'[data-slot="collapsible-content"]'
|
|
33
|
-
);
|
|
34
|
-
expect(content).toBeInTheDocument();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("should toggle content visibility when trigger is clicked", async () => {
|
|
38
|
-
const user = userEvent.setup();
|
|
39
|
-
const { getByText, container } = render(
|
|
40
|
-
<Collapsible>
|
|
41
|
-
<CollapsibleTrigger>Toggle</CollapsibleTrigger>
|
|
42
|
-
<CollapsibleContent>Content</CollapsibleContent>
|
|
43
|
-
</Collapsible>
|
|
44
|
-
);
|
|
45
|
-
const trigger = getByText("Toggle");
|
|
46
|
-
const contentElement = container.querySelector(
|
|
47
|
-
'[data-slot="collapsible-content"]'
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
// Content is in DOM but may be hidden when closed
|
|
51
|
-
expect(contentElement).toBeInTheDocument();
|
|
52
|
-
|
|
53
|
-
// Open
|
|
54
|
-
await user.click(trigger);
|
|
55
|
-
expect(contentElement).toBeInTheDocument();
|
|
56
|
-
expect(contentElement).toHaveAttribute("data-state", "open");
|
|
57
|
-
|
|
58
|
-
// Close
|
|
59
|
-
await user.click(trigger);
|
|
60
|
-
expect(contentElement).toBeInTheDocument();
|
|
61
|
-
expect(contentElement).toHaveAttribute("data-state", "closed");
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("should be open by default when defaultOpen is true", () => {
|
|
65
|
-
const { container } = render(
|
|
66
|
-
<Collapsible defaultOpen>
|
|
67
|
-
<CollapsibleTrigger>Toggle</CollapsibleTrigger>
|
|
68
|
-
<CollapsibleContent>Content</CollapsibleContent>
|
|
69
|
-
</Collapsible>
|
|
70
|
-
);
|
|
71
|
-
const content = container.querySelector(
|
|
72
|
-
'[data-slot="collapsible-content"]'
|
|
73
|
-
);
|
|
74
|
-
// Content should be in document and open when defaultOpen is true
|
|
75
|
-
expect(content).toBeInTheDocument();
|
|
76
|
-
expect(content).toHaveAttribute("data-state", "open");
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("should call onOpenChange when state changes", async () => {
|
|
80
|
-
const user = userEvent.setup();
|
|
81
|
-
const handleChange = vi.fn();
|
|
82
|
-
const { getByText } = render(
|
|
83
|
-
<Collapsible onOpenChange={handleChange}>
|
|
84
|
-
<CollapsibleTrigger>Toggle</CollapsibleTrigger>
|
|
85
|
-
<CollapsibleContent>Content</CollapsibleContent>
|
|
86
|
-
</Collapsible>
|
|
87
|
-
);
|
|
88
|
-
const trigger = getByText("Toggle");
|
|
89
|
-
await user.click(trigger);
|
|
90
|
-
expect(handleChange).toHaveBeenCalledWith(true);
|
|
91
|
-
});
|
|
92
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible"
|
|
2
|
-
|
|
3
|
-
function Collapsible({
|
|
4
|
-
...props
|
|
5
|
-
}: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
|
|
6
|
-
return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function CollapsibleTrigger({
|
|
10
|
-
...props
|
|
11
|
-
}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {
|
|
12
|
-
return (
|
|
13
|
-
<CollapsiblePrimitive.CollapsibleTrigger
|
|
14
|
-
data-slot="collapsible-trigger"
|
|
15
|
-
{...props}
|
|
16
|
-
/>
|
|
17
|
-
)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function CollapsibleContent({
|
|
21
|
-
...props
|
|
22
|
-
}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {
|
|
23
|
-
return (
|
|
24
|
-
<CollapsiblePrimitive.CollapsibleContent
|
|
25
|
-
data-slot="collapsible-content"
|
|
26
|
-
{...props}
|
|
27
|
-
/>
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { Collapsible, CollapsibleTrigger, CollapsibleContent }
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import {
|
|
4
|
-
Command,
|
|
5
|
-
CommandDialog,
|
|
6
|
-
CommandEmpty,
|
|
7
|
-
CommandGroup,
|
|
8
|
-
CommandInput,
|
|
9
|
-
CommandItem,
|
|
10
|
-
CommandList,
|
|
11
|
-
} from "./command";
|
|
12
|
-
import { Button } from "./button";
|
|
13
|
-
|
|
14
|
-
const meta = {
|
|
15
|
-
title: "Components/Command",
|
|
16
|
-
component: Command,
|
|
17
|
-
parameters: {
|
|
18
|
-
layout: "padded",
|
|
19
|
-
},
|
|
20
|
-
tags: ["autodocs"],
|
|
21
|
-
} satisfies Meta<typeof Command>;
|
|
22
|
-
|
|
23
|
-
export default meta;
|
|
24
|
-
type Story = StoryObj<typeof meta>;
|
|
25
|
-
|
|
26
|
-
export const Default: Story = {
|
|
27
|
-
render: () => (
|
|
28
|
-
<Command className="rounded-lg border shadow-md max-w-[450px]">
|
|
29
|
-
<CommandInput placeholder="Type a command or search..." />
|
|
30
|
-
<CommandList>
|
|
31
|
-
<CommandEmpty>No results found.</CommandEmpty>
|
|
32
|
-
<CommandGroup heading="Suggestions">
|
|
33
|
-
<CommandItem>Calendar</CommandItem>
|
|
34
|
-
<CommandItem>Search Emoji</CommandItem>
|
|
35
|
-
<CommandItem>Calculator</CommandItem>
|
|
36
|
-
</CommandGroup>
|
|
37
|
-
<CommandGroup heading="Settings">
|
|
38
|
-
<CommandItem>Profile</CommandItem>
|
|
39
|
-
<CommandItem>Billing</CommandItem>
|
|
40
|
-
<CommandItem>Settings</CommandItem>
|
|
41
|
-
</CommandGroup>
|
|
42
|
-
</CommandList>
|
|
43
|
-
</Command>
|
|
44
|
-
),
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export const Dialog: Story = {
|
|
48
|
-
render: () => {
|
|
49
|
-
const [open, setOpen] = useState(false);
|
|
50
|
-
return (
|
|
51
|
-
<>
|
|
52
|
-
<Button onClick={() => setOpen(true)}>Open Command</Button>
|
|
53
|
-
<CommandDialog open={open} onOpenChange={setOpen}>
|
|
54
|
-
<CommandInput placeholder="Type a command or search..." />
|
|
55
|
-
<CommandList>
|
|
56
|
-
<CommandEmpty>No results found.</CommandEmpty>
|
|
57
|
-
<CommandGroup heading="Suggestions">
|
|
58
|
-
<CommandItem>Calendar</CommandItem>
|
|
59
|
-
<CommandItem>Search Emoji</CommandItem>
|
|
60
|
-
<CommandItem>Calculator</CommandItem>
|
|
61
|
-
</CommandGroup>
|
|
62
|
-
<CommandGroup heading="Settings">
|
|
63
|
-
<CommandItem>Profile</CommandItem>
|
|
64
|
-
<CommandItem>Billing</CommandItem>
|
|
65
|
-
<CommandItem>Settings</CommandItem>
|
|
66
|
-
</CommandGroup>
|
|
67
|
-
</CommandList>
|
|
68
|
-
</CommandDialog>
|
|
69
|
-
</>
|
|
70
|
-
);
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export const WithIcons: Story = {
|
|
75
|
-
render: () => (
|
|
76
|
-
<Command className="rounded-lg border shadow-md max-w-[450px]">
|
|
77
|
-
<CommandInput placeholder="Type a command or search..." />
|
|
78
|
-
<CommandList>
|
|
79
|
-
<CommandEmpty>No results found.</CommandEmpty>
|
|
80
|
-
<CommandGroup heading="Fruits">
|
|
81
|
-
<CommandItem>🍎 Apple</CommandItem>
|
|
82
|
-
<CommandItem>🍌 Banana</CommandItem>
|
|
83
|
-
<CommandItem>🍊 Orange</CommandItem>
|
|
84
|
-
<CommandItem>🍇 Grape</CommandItem>
|
|
85
|
-
</CommandGroup>
|
|
86
|
-
</CommandList>
|
|
87
|
-
</Command>
|
|
88
|
-
),
|
|
89
|
-
};
|
|
90
|
-
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Command as CommandPrimitive } from "cmdk";
|
|
3
|
-
import { SearchIcon } from "lucide-react";
|
|
4
|
-
|
|
5
|
-
import { cn } from "@/lib/utils";
|
|
6
|
-
import {
|
|
7
|
-
Dialog,
|
|
8
|
-
DialogContent,
|
|
9
|
-
DialogDescription,
|
|
10
|
-
DialogHeader,
|
|
11
|
-
DialogTitle,
|
|
12
|
-
} from "@/components/dialog";
|
|
13
|
-
|
|
14
|
-
function Command({
|
|
15
|
-
className,
|
|
16
|
-
...props
|
|
17
|
-
}: React.ComponentProps<typeof CommandPrimitive>) {
|
|
18
|
-
return (
|
|
19
|
-
<CommandPrimitive
|
|
20
|
-
data-slot="command"
|
|
21
|
-
className={cn(
|
|
22
|
-
"bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",
|
|
23
|
-
className
|
|
24
|
-
)}
|
|
25
|
-
{...props}
|
|
26
|
-
/>
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function CommandDialog({
|
|
31
|
-
title = "Command Palette",
|
|
32
|
-
description = "Search for a command to run...",
|
|
33
|
-
children,
|
|
34
|
-
className,
|
|
35
|
-
showCloseButton = true,
|
|
36
|
-
...props
|
|
37
|
-
}: React.ComponentProps<typeof Dialog> & {
|
|
38
|
-
title?: string;
|
|
39
|
-
description?: string;
|
|
40
|
-
className?: string;
|
|
41
|
-
showCloseButton?: boolean;
|
|
42
|
-
}) {
|
|
43
|
-
return (
|
|
44
|
-
<Dialog {...props}>
|
|
45
|
-
<DialogHeader className="sr-only">
|
|
46
|
-
<DialogTitle>{title}</DialogTitle>
|
|
47
|
-
<DialogDescription>{description}</DialogDescription>
|
|
48
|
-
</DialogHeader>
|
|
49
|
-
<DialogContent
|
|
50
|
-
className={cn("overflow-hidden p-0", className)}
|
|
51
|
-
showCloseButton={showCloseButton}
|
|
52
|
-
>
|
|
53
|
-
<Command className="[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
|
|
54
|
-
{children}
|
|
55
|
-
</Command>
|
|
56
|
-
</DialogContent>
|
|
57
|
-
</Dialog>
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function CommandInput({
|
|
62
|
-
className,
|
|
63
|
-
...props
|
|
64
|
-
}: React.ComponentProps<typeof CommandPrimitive.Input>) {
|
|
65
|
-
return (
|
|
66
|
-
<div
|
|
67
|
-
data-slot="command-input-wrapper"
|
|
68
|
-
className="flex h-9 items-center gap-2 border-b px-3"
|
|
69
|
-
>
|
|
70
|
-
<SearchIcon className="size-4 shrink-0 opacity-50" />
|
|
71
|
-
<CommandPrimitive.Input
|
|
72
|
-
data-slot="command-input"
|
|
73
|
-
className={cn(
|
|
74
|
-
"placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
|
|
75
|
-
className
|
|
76
|
-
)}
|
|
77
|
-
{...props}
|
|
78
|
-
/>
|
|
79
|
-
</div>
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function CommandList({
|
|
84
|
-
className,
|
|
85
|
-
...props
|
|
86
|
-
}: React.ComponentProps<typeof CommandPrimitive.List>) {
|
|
87
|
-
return (
|
|
88
|
-
<CommandPrimitive.List
|
|
89
|
-
data-slot="command-list"
|
|
90
|
-
className={cn(
|
|
91
|
-
"max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",
|
|
92
|
-
className
|
|
93
|
-
)}
|
|
94
|
-
{...props}
|
|
95
|
-
/>
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function CommandEmpty({
|
|
100
|
-
...props
|
|
101
|
-
}: React.ComponentProps<typeof CommandPrimitive.Empty>) {
|
|
102
|
-
return (
|
|
103
|
-
<CommandPrimitive.Empty
|
|
104
|
-
data-slot="command-empty"
|
|
105
|
-
className="py-6 text-center text-sm"
|
|
106
|
-
{...props}
|
|
107
|
-
/>
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function CommandGroup({
|
|
112
|
-
className,
|
|
113
|
-
...props
|
|
114
|
-
}: React.ComponentProps<typeof CommandPrimitive.Group>) {
|
|
115
|
-
return (
|
|
116
|
-
<CommandPrimitive.Group
|
|
117
|
-
data-slot="command-group"
|
|
118
|
-
className={cn(
|
|
119
|
-
"text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",
|
|
120
|
-
className
|
|
121
|
-
)}
|
|
122
|
-
{...props}
|
|
123
|
-
/>
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function CommandSeparator({
|
|
128
|
-
className,
|
|
129
|
-
...props
|
|
130
|
-
}: React.ComponentProps<typeof CommandPrimitive.Separator>) {
|
|
131
|
-
return (
|
|
132
|
-
<CommandPrimitive.Separator
|
|
133
|
-
data-slot="command-separator"
|
|
134
|
-
className={cn("bg-border -mx-1 h-px", className)}
|
|
135
|
-
{...props}
|
|
136
|
-
/>
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function CommandItem({
|
|
141
|
-
className,
|
|
142
|
-
...props
|
|
143
|
-
}: React.ComponentProps<typeof CommandPrimitive.Item>) {
|
|
144
|
-
return (
|
|
145
|
-
<CommandPrimitive.Item
|
|
146
|
-
data-slot="command-item"
|
|
147
|
-
className={cn(
|
|
148
|
-
"data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
149
|
-
className
|
|
150
|
-
)}
|
|
151
|
-
{...props}
|
|
152
|
-
/>
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function CommandShortcut({
|
|
157
|
-
className,
|
|
158
|
-
...props
|
|
159
|
-
}: React.ComponentProps<"span">) {
|
|
160
|
-
return (
|
|
161
|
-
<span
|
|
162
|
-
data-slot="command-shortcut"
|
|
163
|
-
className={cn(
|
|
164
|
-
"text-muted-foreground ml-auto text-xs tracking-widest",
|
|
165
|
-
className
|
|
166
|
-
)}
|
|
167
|
-
{...props}
|
|
168
|
-
/>
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export {
|
|
173
|
-
Command,
|
|
174
|
-
CommandDialog,
|
|
175
|
-
CommandInput,
|
|
176
|
-
CommandList,
|
|
177
|
-
CommandEmpty,
|
|
178
|
-
CommandGroup,
|
|
179
|
-
CommandItem,
|
|
180
|
-
CommandShortcut,
|
|
181
|
-
CommandSeparator,
|
|
182
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
-
import {
|
|
3
|
-
ContextMenu,
|
|
4
|
-
ContextMenuContent,
|
|
5
|
-
ContextMenuItem,
|
|
6
|
-
ContextMenuLabel,
|
|
7
|
-
ContextMenuSeparator,
|
|
8
|
-
ContextMenuTrigger,
|
|
9
|
-
} from "./context-menu";
|
|
10
|
-
|
|
11
|
-
const meta = {
|
|
12
|
-
title: "Components/ContextMenu",
|
|
13
|
-
component: ContextMenu,
|
|
14
|
-
parameters: {
|
|
15
|
-
layout: "padded",
|
|
16
|
-
},
|
|
17
|
-
tags: ["autodocs"],
|
|
18
|
-
} satisfies Meta<typeof ContextMenu>;
|
|
19
|
-
|
|
20
|
-
export default meta;
|
|
21
|
-
type Story = StoryObj<typeof meta>;
|
|
22
|
-
|
|
23
|
-
export const Default: Story = {
|
|
24
|
-
render: () => (
|
|
25
|
-
<ContextMenu>
|
|
26
|
-
<ContextMenuTrigger className="flex h-[150px] w-[300px] items-center justify-center rounded-md border border-dashed text-sm">
|
|
27
|
-
Right click here
|
|
28
|
-
</ContextMenuTrigger>
|
|
29
|
-
<ContextMenuContent>
|
|
30
|
-
<ContextMenuItem>Back</ContextMenuItem>
|
|
31
|
-
<ContextMenuItem>Forward</ContextMenuItem>
|
|
32
|
-
<ContextMenuItem>Reload</ContextMenuItem>
|
|
33
|
-
<ContextMenuSeparator />
|
|
34
|
-
<ContextMenuItem>Save As...</ContextMenuItem>
|
|
35
|
-
<ContextMenuItem>Print</ContextMenuItem>
|
|
36
|
-
<ContextMenuSeparator />
|
|
37
|
-
<ContextMenuItem>View Page Source</ContextMenuItem>
|
|
38
|
-
</ContextMenuContent>
|
|
39
|
-
</ContextMenu>
|
|
40
|
-
),
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const WithGroups: Story = {
|
|
44
|
-
render: () => (
|
|
45
|
-
<ContextMenu>
|
|
46
|
-
<ContextMenuTrigger className="flex h-[150px] w-[300px] items-center justify-center rounded-md border border-dashed text-sm">
|
|
47
|
-
Right click for grouped menu
|
|
48
|
-
</ContextMenuTrigger>
|
|
49
|
-
<ContextMenuContent>
|
|
50
|
-
<ContextMenuLabel>File</ContextMenuLabel>
|
|
51
|
-
<ContextMenuItem>New</ContextMenuItem>
|
|
52
|
-
<ContextMenuItem>Open</ContextMenuItem>
|
|
53
|
-
<ContextMenuItem>Save</ContextMenuItem>
|
|
54
|
-
<ContextMenuSeparator />
|
|
55
|
-
<ContextMenuLabel>Edit</ContextMenuLabel>
|
|
56
|
-
<ContextMenuItem>Cut</ContextMenuItem>
|
|
57
|
-
<ContextMenuItem>Copy</ContextMenuItem>
|
|
58
|
-
<ContextMenuItem>Paste</ContextMenuItem>
|
|
59
|
-
</ContextMenuContent>
|
|
60
|
-
</ContextMenu>
|
|
61
|
-
),
|
|
62
|
-
};
|
|
63
|
-
|