@nebulit/embuilder 0.1.39
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/README.md +254 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +138 -0
- package/package.json +49 -0
- package/templates/.claude/hooks/QUICKSTART.md +256 -0
- package/templates/.claude/hooks/README.md +533 -0
- package/templates/.claude/hooks/analyze-commit.sh +22 -0
- package/templates/.claude/hooks/analyze-commit.ts +518 -0
- package/templates/.claude/hooks/analyzers/README.md +198 -0
- package/templates/.claude/hooks/analyzers/code-quality-checker.ts +154 -0
- package/templates/.claude/hooks/analyzers/code-quality.md +54 -0
- package/templates/.claude/hooks/analyzers/commit-blocker-example.ts.disabled +110 -0
- package/templates/.claude/hooks/analyzers/commit-policy.md +49 -0
- package/templates/.claude/hooks/analyzers/event-model-validator.md +49 -0
- package/templates/.claude/hooks/analyzers/event-model-validator.ts +169 -0
- package/templates/.claude/hooks/analyzers/example-logger.ts +70 -0
- package/templates/.claude/hooks/analyzers/slice-scope-validator.md +81 -0
- package/templates/.claude/hooks/check-review-result.sh +47 -0
- package/templates/.claude/hooks/prepare-review.sh +34 -0
- package/templates/.claude/hooks/review-agent-prompt.md +42 -0
- package/templates/.claude/hooks/run-review-agent.sh +124 -0
- package/templates/.claude/settings.local.json +37 -0
- package/templates/.claude/skills/help/README.md +84 -0
- package/templates/.claude/skills/help/SKILL.md +393 -0
- package/templates/.claude/skills/help/templates/demo-config.json +6753 -0
- package/templates/.claude/skills/sample-slices/SKILL.md +8 -0
- package/templates/.claude/skills/sample-slices/templates/.slices/Library/addbook/code-slice.json +124 -0
- package/templates/.claude/skills/sample-slices/templates/.slices/Library/addbook/slice.json +255 -0
- package/templates/.claude/skills/sample-slices/templates/.slices/Library/availablebooks/slice.json +107 -0
- package/templates/.claude/skills/sample-slices/templates/.slices/index.json +20 -0
- package/templates/.claude/skills/sample-slices/templates/Cart/additem/slice.json +979 -0
- package/templates/.claude/skills/sample-slices/templates/Cart/archiveitem/slice.json +529 -0
- package/templates/.claude/skills/sample-slices/templates/Cart/cartitems/slice.json +1072 -0
- package/templates/.claude/skills/sample-slices/templates/Cart/cartwithproducts/slice.json +394 -0
- package/templates/.claude/skills/sample-slices/templates/Cart/changedprices/slice.json +88 -0
- package/templates/.claude/skills/sample-slices/templates/Cart/changeinventory/slice.json +264 -0
- package/templates/.claude/skills/sample-slices/templates/Cart/changeprice/slice.json +308 -0
- package/templates/.claude/skills/sample-slices/templates/Cart/clearcart/slice.json +358 -0
- package/templates/.claude/skills/sample-slices/templates/Cart/inventories/slice.json +203 -0
- package/templates/.claude/skills/sample-slices/templates/Cart/publishcart/slice.json +876 -0
- package/templates/.claude/skills/sample-slices/templates/Cart/removeitem/slice.json +560 -0
- package/templates/.claude/skills/sample-slices/templates/Cart/submitcart/slice.json +708 -0
- package/templates/.claude/skills/sample-slices/templates/Cart/submittedcartdata/slice.json +399 -0
- package/templates/.claude/skills/sample-slices/templates/index.json +108 -0
- package/templates/.claude/skills/slice-automation/SKILL.md +49 -0
- package/templates/.claude/skills/slice-state-change/SKILL.md +369 -0
- package/templates/.claude/skills/slice-state-change/templates/AddLocation/AddLocation.test.ts.sample +76 -0
- package/templates/.claude/skills/slice-state-change/templates/AddLocation/AddLocationCommand.ts.sample +84 -0
- package/templates/.claude/skills/slice-state-change/templates/AddLocation/routes.ts.sample +73 -0
- package/templates/.claude/skills/slice-state-change/templates/README.md +46 -0
- package/templates/.claude/skills/slice-state-view/SKILL.md +336 -0
- package/templates/.claude/skills/slice-state-view/templates/Locations/Locations.test.ts.sample +84 -0
- package/templates/.claude/skills/slice-state-view/templates/Locations/LocationsProjection.ts.sample +50 -0
- package/templates/.claude/skills/slice-state-view/templates/Locations/routes.ts.sample +46 -0
- package/templates/.claude/skills/slice-state-view/templates/README.md +109 -0
- package/templates/.claude/skills/slice-state-view/templates/Tables/Tables.test.ts.sample +104 -0
- package/templates/.claude/skills/slice-state-view/templates/Tables/TablesProjection.ts.sample +59 -0
- package/templates/.claude/skills/slice-state-view/templates/Tables/routes.ts.sample +46 -0
- package/templates/.claude/skills/slice-state-view/templates/V2__tables.sql +7 -0
- package/templates/.claude/skills/slice-state-view/templates/V8__locations.sql +7 -0
- package/templates/.claude/skills/test-analyzer/SKILL.md +373 -0
- package/templates/.claude/skills/test-analyzer/examples/specification-format.md +143 -0
- package/templates/.claude/skills/test-analyzer/examples/state-change-example.md +111 -0
- package/templates/.claude/skills/test-analyzer/examples/state-view-example.md +122 -0
- package/templates/AGENTS.md +110 -0
- package/templates/Claude.md +58 -0
- package/templates/README.md +178 -0
- package/templates/backend/.env +9 -0
- package/templates/backend/BACKEND_AUTH_SETUP.md +183 -0
- package/templates/backend/SWAGGER.md +213 -0
- package/templates/backend/eslint.config.mjs +31 -0
- package/templates/backend/flyway.conf +17 -0
- package/templates/backend/package.json +44 -0
- package/templates/backend/prd.json.example +64 -0
- package/templates/backend/public/assets/images/banner.png +0 -0
- package/templates/backend/public/assets/logo.png +0 -0
- package/templates/backend/public/file.svg +4 -0
- package/templates/backend/public/globe.svg +12 -0
- package/templates/backend/public/next.svg +6 -0
- package/templates/backend/public/vercel.svg +3 -0
- package/templates/backend/public/window.svg +5 -0
- package/templates/backend/server.ts +129 -0
- package/templates/backend/setup-env.sh +50 -0
- package/templates/backend/src/common/assertions.ts +6 -0
- package/templates/backend/src/common/db.ts +1 -0
- package/templates/backend/src/common/loadPostgresEventstore.ts +16 -0
- package/templates/backend/src/common/parseEndpoint.ts +51 -0
- package/templates/backend/src/common/replay.ts +9 -0
- package/templates/backend/src/common/routes.ts +19 -0
- package/templates/backend/src/common/testHelpers.ts +53 -0
- package/templates/backend/src/core/readmodel.ts +28 -0
- package/templates/backend/src/core/types.ts +26 -0
- package/templates/backend/src/process/process.ts +53 -0
- package/templates/backend/src/supabase/LoginHandler.ts +36 -0
- package/templates/backend/src/supabase/ProtectedPageProps.ts +21 -0
- package/templates/backend/src/supabase/README.md +171 -0
- package/templates/backend/src/supabase/api.ts +63 -0
- package/templates/backend/src/supabase/authMiddleware.ts +53 -0
- package/templates/backend/src/supabase/component.ts +12 -0
- package/templates/backend/src/supabase/requireUser.ts +72 -0
- package/templates/backend/src/supabase/serverProps.ts +25 -0
- package/templates/backend/src/supabase/staticProps.ts +10 -0
- package/templates/backend/src/swagger.ts +34 -0
- package/templates/backend/src/util/assertions.ts +6 -0
- package/templates/backend/supabase/config.toml +295 -0
- package/templates/backend/supabase/migrations/20260121155918593_catalogentries.sql.sample +23 -0
- package/templates/backend/supabase/seed.sql +1 -0
- package/templates/backend/tsconfig.json +31 -0
- package/templates/frontend/.env.development +3 -0
- package/templates/frontend/AGENTS.md +7 -0
- package/templates/frontend/README.md +73 -0
- package/templates/frontend/components.json +20 -0
- package/templates/frontend/eslint.config.js +26 -0
- package/templates/frontend/index.html +18 -0
- package/templates/frontend/package-lock.json +8347 -0
- package/templates/frontend/package.json +94 -0
- package/templates/frontend/postcss.config.js +6 -0
- package/templates/frontend/public/favicon.ico +0 -0
- package/templates/frontend/public/logo.png +0 -0
- package/templates/frontend/public/placeholder.svg +1 -0
- package/templates/frontend/public/robots.txt +14 -0
- package/templates/frontend/src/App.css +42 -0
- package/templates/frontend/src/App.tsx +47 -0
- package/templates/frontend/src/components/NavLink.tsx +28 -0
- package/templates/frontend/src/components/ProtectedRoute.tsx +24 -0
- package/templates/frontend/src/components/calendar/Calendar.tsx +302 -0
- package/templates/frontend/src/components/layout/DashboardLayout.tsx +21 -0
- package/templates/frontend/src/components/layout/Header.tsx +45 -0
- package/templates/frontend/src/components/layout/Sidebar.tsx +82 -0
- package/templates/frontend/src/components/tables/ReservationTemplates.tsx +189 -0
- package/templates/frontend/src/components/ui/accordion.tsx +52 -0
- package/templates/frontend/src/components/ui/alert-dialog.tsx +104 -0
- package/templates/frontend/src/components/ui/alert.tsx +43 -0
- package/templates/frontend/src/components/ui/aspect-ratio.tsx +5 -0
- package/templates/frontend/src/components/ui/avatar.tsx +38 -0
- package/templates/frontend/src/components/ui/badge.tsx +29 -0
- package/templates/frontend/src/components/ui/breadcrumb.tsx +90 -0
- package/templates/frontend/src/components/ui/button.tsx +47 -0
- package/templates/frontend/src/components/ui/calendar.tsx +54 -0
- package/templates/frontend/src/components/ui/card.tsx +43 -0
- package/templates/frontend/src/components/ui/carousel.tsx +224 -0
- package/templates/frontend/src/components/ui/chart.tsx +303 -0
- package/templates/frontend/src/components/ui/checkbox.tsx +26 -0
- package/templates/frontend/src/components/ui/collapsible.tsx +9 -0
- package/templates/frontend/src/components/ui/command.tsx +132 -0
- package/templates/frontend/src/components/ui/context-menu.tsx +178 -0
- package/templates/frontend/src/components/ui/dialog.tsx +95 -0
- package/templates/frontend/src/components/ui/drawer.tsx +87 -0
- package/templates/frontend/src/components/ui/dropdown-menu.tsx +179 -0
- package/templates/frontend/src/components/ui/form.tsx +129 -0
- package/templates/frontend/src/components/ui/hover-card.tsx +27 -0
- package/templates/frontend/src/components/ui/input-otp.tsx +61 -0
- package/templates/frontend/src/components/ui/input.tsx +22 -0
- package/templates/frontend/src/components/ui/label.tsx +17 -0
- package/templates/frontend/src/components/ui/menubar.tsx +207 -0
- package/templates/frontend/src/components/ui/navigation-menu.tsx +120 -0
- package/templates/frontend/src/components/ui/pagination.tsx +81 -0
- package/templates/frontend/src/components/ui/popover.tsx +29 -0
- package/templates/frontend/src/components/ui/progress.tsx +23 -0
- package/templates/frontend/src/components/ui/radio-group.tsx +36 -0
- package/templates/frontend/src/components/ui/resizable.tsx +37 -0
- package/templates/frontend/src/components/ui/scroll-area.tsx +38 -0
- package/templates/frontend/src/components/ui/select.tsx +143 -0
- package/templates/frontend/src/components/ui/separator.tsx +20 -0
- package/templates/frontend/src/components/ui/sheet.tsx +107 -0
- package/templates/frontend/src/components/ui/sidebar.tsx +637 -0
- package/templates/frontend/src/components/ui/skeleton.tsx +7 -0
- package/templates/frontend/src/components/ui/slider.tsx +23 -0
- package/templates/frontend/src/components/ui/sonner.tsx +27 -0
- package/templates/frontend/src/components/ui/stat-card.tsx +44 -0
- package/templates/frontend/src/components/ui/switch.tsx +27 -0
- package/templates/frontend/src/components/ui/table.tsx +72 -0
- package/templates/frontend/src/components/ui/tabs.tsx +53 -0
- package/templates/frontend/src/components/ui/textarea.tsx +21 -0
- package/templates/frontend/src/components/ui/toast.tsx +111 -0
- package/templates/frontend/src/components/ui/toaster.tsx +24 -0
- package/templates/frontend/src/components/ui/toggle-group.tsx +49 -0
- package/templates/frontend/src/components/ui/toggle.tsx +37 -0
- package/templates/frontend/src/components/ui/tooltip.tsx +28 -0
- package/templates/frontend/src/components/ui/use-toast.ts +3 -0
- package/templates/frontend/src/contexts/AuthContext.tsx +94 -0
- package/templates/frontend/src/contexts/RefreshContext.tsx +236 -0
- package/templates/frontend/src/hooks/api/index.ts +2 -0
- package/templates/frontend/src/hooks/api/useLocations.ts +15 -0
- package/templates/frontend/src/hooks/use-mobile.tsx +19 -0
- package/templates/frontend/src/hooks/use-toast.ts +186 -0
- package/templates/frontend/src/hooks/useApiContext.ts +11 -0
- package/templates/frontend/src/index.css +118 -0
- package/templates/frontend/src/integrations/supabase/client.ts +9 -0
- package/templates/frontend/src/lib/api-client.ts +136 -0
- package/templates/frontend/src/lib/api.ts +1028 -0
- package/templates/frontend/src/lib/utils.ts +6 -0
- package/templates/frontend/src/main.tsx +5 -0
- package/templates/frontend/src/pages/Auth.tsx +408 -0
- package/templates/frontend/src/pages/Dashboard.tsx +168 -0
- package/templates/frontend/src/pages/Menus.tsx +224 -0
- package/templates/frontend/src/pages/NotFound.tsx +24 -0
- package/templates/frontend/src/pages/Register.tsx +285 -0
- package/templates/frontend/src/test/example.test.ts +0 -0
- package/templates/frontend/src/test/setup.ts +15 -0
- package/templates/frontend/src/types/index.ts +8 -0
- package/templates/frontend/src/vite-env.d.ts +1 -0
- package/templates/frontend/tailwind.config.ts +101 -0
- package/templates/frontend/tsconfig.app.json +31 -0
- package/templates/frontend/tsconfig.json +16 -0
- package/templates/frontend/tsconfig.node.json +22 -0
- package/templates/frontend/vite.config.ts +21 -0
- package/templates/frontend/vitest.config.ts +16 -0
- package/templates/init.sh +1 -0
- package/templates/prompt.md +139 -0
- package/templates/ralph.sh +120 -0
- package/templates/server.mjs +505 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
3
|
+
import { DayPicker } from "react-day-picker";
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils";
|
|
6
|
+
import { buttonVariants } from "@/components/ui/button";
|
|
7
|
+
|
|
8
|
+
export type CalendarProps = React.ComponentProps<typeof DayPicker>;
|
|
9
|
+
|
|
10
|
+
function Calendar({ className, classNames, showOutsideDays = true, ...props }: CalendarProps) {
|
|
11
|
+
return (
|
|
12
|
+
<DayPicker
|
|
13
|
+
showOutsideDays={showOutsideDays}
|
|
14
|
+
className={cn("p-3", className)}
|
|
15
|
+
classNames={{
|
|
16
|
+
months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
|
|
17
|
+
month: "space-y-4",
|
|
18
|
+
caption: "flex justify-center pt-1 relative items-center",
|
|
19
|
+
caption_label: "text-sm font-medium",
|
|
20
|
+
nav: "space-x-1 flex items-center",
|
|
21
|
+
nav_button: cn(
|
|
22
|
+
buttonVariants({ variant: "outline" }),
|
|
23
|
+
"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100",
|
|
24
|
+
),
|
|
25
|
+
nav_button_previous: "absolute left-1",
|
|
26
|
+
nav_button_next: "absolute right-1",
|
|
27
|
+
table: "w-full border-collapse space-y-1",
|
|
28
|
+
head_row: "flex",
|
|
29
|
+
head_cell: "text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",
|
|
30
|
+
row: "flex w-full mt-2",
|
|
31
|
+
cell: "h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",
|
|
32
|
+
day: cn(buttonVariants({ variant: "ghost" }), "h-9 w-9 p-0 font-normal aria-selected:opacity-100"),
|
|
33
|
+
day_range_end: "day-range-end",
|
|
34
|
+
day_selected:
|
|
35
|
+
"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
|
|
36
|
+
day_today: "bg-accent text-accent-foreground",
|
|
37
|
+
day_outside:
|
|
38
|
+
"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",
|
|
39
|
+
day_disabled: "text-muted-foreground opacity-50",
|
|
40
|
+
day_range_middle: "aria-selected:bg-accent aria-selected:text-accent-foreground",
|
|
41
|
+
day_hidden: "invisible",
|
|
42
|
+
...classNames,
|
|
43
|
+
}}
|
|
44
|
+
components={{
|
|
45
|
+
IconLeft: ({ ..._props }) => <ChevronLeft className="h-4 w-4" />,
|
|
46
|
+
IconRight: ({ ..._props }) => <ChevronRight className="h-4 w-4" />,
|
|
47
|
+
}}
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
Calendar.displayName = "Calendar";
|
|
53
|
+
|
|
54
|
+
export { Calendar };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
4
|
+
|
|
5
|
+
const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (
|
|
6
|
+
<div ref={ref} className={cn("rounded-lg border bg-card text-card-foreground shadow-sm", className)} {...props} />
|
|
7
|
+
));
|
|
8
|
+
Card.displayName = "Card";
|
|
9
|
+
|
|
10
|
+
const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
11
|
+
({ className, ...props }, ref) => (
|
|
12
|
+
<div ref={ref} className={cn("flex flex-col space-y-1.5 p-6", className)} {...props} />
|
|
13
|
+
),
|
|
14
|
+
);
|
|
15
|
+
CardHeader.displayName = "CardHeader";
|
|
16
|
+
|
|
17
|
+
const CardTitle = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLHeadingElement>>(
|
|
18
|
+
({ className, ...props }, ref) => (
|
|
19
|
+
<h3 ref={ref} className={cn("text-2xl font-semibold leading-none tracking-tight", className)} {...props} />
|
|
20
|
+
),
|
|
21
|
+
);
|
|
22
|
+
CardTitle.displayName = "CardTitle";
|
|
23
|
+
|
|
24
|
+
const CardDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
|
|
25
|
+
({ className, ...props }, ref) => (
|
|
26
|
+
<p ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
|
27
|
+
),
|
|
28
|
+
);
|
|
29
|
+
CardDescription.displayName = "CardDescription";
|
|
30
|
+
|
|
31
|
+
const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
32
|
+
({ className, ...props }, ref) => <div ref={ref} className={cn("p-6 pt-0", className)} {...props} />,
|
|
33
|
+
);
|
|
34
|
+
CardContent.displayName = "CardContent";
|
|
35
|
+
|
|
36
|
+
const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
37
|
+
({ className, ...props }, ref) => (
|
|
38
|
+
<div ref={ref} className={cn("flex items-center p-6 pt-0", className)} {...props} />
|
|
39
|
+
),
|
|
40
|
+
);
|
|
41
|
+
CardFooter.displayName = "CardFooter";
|
|
42
|
+
|
|
43
|
+
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import useEmblaCarousel, { type UseEmblaCarouselType } from "embla-carousel-react";
|
|
3
|
+
import { ArrowLeft, ArrowRight } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils";
|
|
6
|
+
import { Button } from "@/components/ui/button";
|
|
7
|
+
|
|
8
|
+
type CarouselApi = UseEmblaCarouselType[1];
|
|
9
|
+
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
|
|
10
|
+
type CarouselOptions = UseCarouselParameters[0];
|
|
11
|
+
type CarouselPlugin = UseCarouselParameters[1];
|
|
12
|
+
|
|
13
|
+
type CarouselProps = {
|
|
14
|
+
opts?: CarouselOptions;
|
|
15
|
+
plugins?: CarouselPlugin;
|
|
16
|
+
orientation?: "horizontal" | "vertical";
|
|
17
|
+
setApi?: (api: CarouselApi) => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type CarouselContextProps = {
|
|
21
|
+
carouselRef: ReturnType<typeof useEmblaCarousel>[0];
|
|
22
|
+
api: ReturnType<typeof useEmblaCarousel>[1];
|
|
23
|
+
scrollPrev: () => void;
|
|
24
|
+
scrollNext: () => void;
|
|
25
|
+
canScrollPrev: boolean;
|
|
26
|
+
canScrollNext: boolean;
|
|
27
|
+
} & CarouselProps;
|
|
28
|
+
|
|
29
|
+
const CarouselContext = React.createContext<CarouselContextProps | null>(null);
|
|
30
|
+
|
|
31
|
+
function useCarousel() {
|
|
32
|
+
const context = React.useContext(CarouselContext);
|
|
33
|
+
|
|
34
|
+
if (!context) {
|
|
35
|
+
throw new Error("useCarousel must be used within a <Carousel />");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return context;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const Carousel = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement> & CarouselProps>(
|
|
42
|
+
({ orientation = "horizontal", opts, setApi, plugins, className, children, ...props }, ref) => {
|
|
43
|
+
const [carouselRef, api] = useEmblaCarousel(
|
|
44
|
+
{
|
|
45
|
+
...opts,
|
|
46
|
+
axis: orientation === "horizontal" ? "x" : "y",
|
|
47
|
+
},
|
|
48
|
+
plugins,
|
|
49
|
+
);
|
|
50
|
+
const [canScrollPrev, setCanScrollPrev] = React.useState(false);
|
|
51
|
+
const [canScrollNext, setCanScrollNext] = React.useState(false);
|
|
52
|
+
|
|
53
|
+
const onSelect = React.useCallback((api: CarouselApi) => {
|
|
54
|
+
if (!api) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
setCanScrollPrev(api.canScrollPrev());
|
|
59
|
+
setCanScrollNext(api.canScrollNext());
|
|
60
|
+
}, []);
|
|
61
|
+
|
|
62
|
+
const scrollPrev = React.useCallback(() => {
|
|
63
|
+
api?.scrollPrev();
|
|
64
|
+
}, [api]);
|
|
65
|
+
|
|
66
|
+
const scrollNext = React.useCallback(() => {
|
|
67
|
+
api?.scrollNext();
|
|
68
|
+
}, [api]);
|
|
69
|
+
|
|
70
|
+
const handleKeyDown = React.useCallback(
|
|
71
|
+
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
72
|
+
if (event.key === "ArrowLeft") {
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
scrollPrev();
|
|
75
|
+
} else if (event.key === "ArrowRight") {
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
scrollNext();
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
[scrollPrev, scrollNext],
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
React.useEffect(() => {
|
|
84
|
+
if (!api || !setApi) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
setApi(api);
|
|
89
|
+
}, [api, setApi]);
|
|
90
|
+
|
|
91
|
+
React.useEffect(() => {
|
|
92
|
+
if (!api) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
onSelect(api);
|
|
97
|
+
api.on("reInit", onSelect);
|
|
98
|
+
api.on("select", onSelect);
|
|
99
|
+
|
|
100
|
+
return () => {
|
|
101
|
+
api?.off("select", onSelect);
|
|
102
|
+
};
|
|
103
|
+
}, [api, onSelect]);
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<CarouselContext.Provider
|
|
107
|
+
value={{
|
|
108
|
+
carouselRef,
|
|
109
|
+
api: api,
|
|
110
|
+
opts,
|
|
111
|
+
orientation: orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
|
|
112
|
+
scrollPrev,
|
|
113
|
+
scrollNext,
|
|
114
|
+
canScrollPrev,
|
|
115
|
+
canScrollNext,
|
|
116
|
+
}}
|
|
117
|
+
>
|
|
118
|
+
<div
|
|
119
|
+
ref={ref}
|
|
120
|
+
onKeyDownCapture={handleKeyDown}
|
|
121
|
+
className={cn("relative", className)}
|
|
122
|
+
role="region"
|
|
123
|
+
aria-roledescription="carousel"
|
|
124
|
+
{...props}
|
|
125
|
+
>
|
|
126
|
+
{children}
|
|
127
|
+
</div>
|
|
128
|
+
</CarouselContext.Provider>
|
|
129
|
+
);
|
|
130
|
+
},
|
|
131
|
+
);
|
|
132
|
+
Carousel.displayName = "Carousel";
|
|
133
|
+
|
|
134
|
+
const CarouselContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
135
|
+
({ className, ...props }, ref) => {
|
|
136
|
+
const { carouselRef, orientation } = useCarousel();
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<div ref={carouselRef} className="overflow-hidden">
|
|
140
|
+
<div
|
|
141
|
+
ref={ref}
|
|
142
|
+
className={cn("flex", orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col", className)}
|
|
143
|
+
{...props}
|
|
144
|
+
/>
|
|
145
|
+
</div>
|
|
146
|
+
);
|
|
147
|
+
},
|
|
148
|
+
);
|
|
149
|
+
CarouselContent.displayName = "CarouselContent";
|
|
150
|
+
|
|
151
|
+
const CarouselItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
152
|
+
({ className, ...props }, ref) => {
|
|
153
|
+
const { orientation } = useCarousel();
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<div
|
|
157
|
+
ref={ref}
|
|
158
|
+
role="group"
|
|
159
|
+
aria-roledescription="slide"
|
|
160
|
+
className={cn("min-w-0 shrink-0 grow-0 basis-full", orientation === "horizontal" ? "pl-4" : "pt-4", className)}
|
|
161
|
+
{...props}
|
|
162
|
+
/>
|
|
163
|
+
);
|
|
164
|
+
},
|
|
165
|
+
);
|
|
166
|
+
CarouselItem.displayName = "CarouselItem";
|
|
167
|
+
|
|
168
|
+
const CarouselPrevious = React.forwardRef<HTMLButtonElement, React.ComponentProps<typeof Button>>(
|
|
169
|
+
({ className, variant = "outline", size = "icon", ...props }, ref) => {
|
|
170
|
+
const { orientation, scrollPrev, canScrollPrev } = useCarousel();
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<Button
|
|
174
|
+
ref={ref}
|
|
175
|
+
variant={variant}
|
|
176
|
+
size={size}
|
|
177
|
+
className={cn(
|
|
178
|
+
"absolute h-8 w-8 rounded-full",
|
|
179
|
+
orientation === "horizontal"
|
|
180
|
+
? "-left-12 top-1/2 -translate-y-1/2"
|
|
181
|
+
: "-top-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
182
|
+
className,
|
|
183
|
+
)}
|
|
184
|
+
disabled={!canScrollPrev}
|
|
185
|
+
onClick={scrollPrev}
|
|
186
|
+
{...props}
|
|
187
|
+
>
|
|
188
|
+
<ArrowLeft className="h-4 w-4" />
|
|
189
|
+
<span className="sr-only">Previous slide</span>
|
|
190
|
+
</Button>
|
|
191
|
+
);
|
|
192
|
+
},
|
|
193
|
+
);
|
|
194
|
+
CarouselPrevious.displayName = "CarouselPrevious";
|
|
195
|
+
|
|
196
|
+
const CarouselNext = React.forwardRef<HTMLButtonElement, React.ComponentProps<typeof Button>>(
|
|
197
|
+
({ className, variant = "outline", size = "icon", ...props }, ref) => {
|
|
198
|
+
const { orientation, scrollNext, canScrollNext } = useCarousel();
|
|
199
|
+
|
|
200
|
+
return (
|
|
201
|
+
<Button
|
|
202
|
+
ref={ref}
|
|
203
|
+
variant={variant}
|
|
204
|
+
size={size}
|
|
205
|
+
className={cn(
|
|
206
|
+
"absolute h-8 w-8 rounded-full",
|
|
207
|
+
orientation === "horizontal"
|
|
208
|
+
? "-right-12 top-1/2 -translate-y-1/2"
|
|
209
|
+
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
210
|
+
className,
|
|
211
|
+
)}
|
|
212
|
+
disabled={!canScrollNext}
|
|
213
|
+
onClick={scrollNext}
|
|
214
|
+
{...props}
|
|
215
|
+
>
|
|
216
|
+
<ArrowRight className="h-4 w-4" />
|
|
217
|
+
<span className="sr-only">Next slide</span>
|
|
218
|
+
</Button>
|
|
219
|
+
);
|
|
220
|
+
},
|
|
221
|
+
);
|
|
222
|
+
CarouselNext.displayName = "CarouselNext";
|
|
223
|
+
|
|
224
|
+
export { type CarouselApi, Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext };
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as RechartsPrimitive from "recharts";
|
|
3
|
+
|
|
4
|
+
import { cn } from "@/lib/utils";
|
|
5
|
+
|
|
6
|
+
// Format: { THEME_NAME: CSS_SELECTOR }
|
|
7
|
+
const THEMES = { light: "", dark: ".dark" } as const;
|
|
8
|
+
|
|
9
|
+
export type ChartConfig = {
|
|
10
|
+
[k in string]: {
|
|
11
|
+
label?: React.ReactNode;
|
|
12
|
+
icon?: React.ComponentType;
|
|
13
|
+
} & ({ color?: string; theme?: never } | { color?: never; theme: Record<keyof typeof THEMES, string> });
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type ChartContextProps = {
|
|
17
|
+
config: ChartConfig;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const ChartContext = React.createContext<ChartContextProps | null>(null);
|
|
21
|
+
|
|
22
|
+
function useChart() {
|
|
23
|
+
const context = React.useContext(ChartContext);
|
|
24
|
+
|
|
25
|
+
if (!context) {
|
|
26
|
+
throw new Error("useChart must be used within a <ChartContainer />");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return context;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const ChartContainer = React.forwardRef<
|
|
33
|
+
HTMLDivElement,
|
|
34
|
+
React.ComponentProps<"div"> & {
|
|
35
|
+
config: ChartConfig;
|
|
36
|
+
children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];
|
|
37
|
+
}
|
|
38
|
+
>(({ id, className, children, config, ...props }, ref) => {
|
|
39
|
+
const uniqueId = React.useId();
|
|
40
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<ChartContext.Provider value={{ config }}>
|
|
44
|
+
<div
|
|
45
|
+
data-chart={chartId}
|
|
46
|
+
ref={ref}
|
|
47
|
+
className={cn(
|
|
48
|
+
"flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",
|
|
49
|
+
className,
|
|
50
|
+
)}
|
|
51
|
+
{...props}
|
|
52
|
+
>
|
|
53
|
+
<ChartStyle id={chartId} config={config} />
|
|
54
|
+
<RechartsPrimitive.ResponsiveContainer>{children}</RechartsPrimitive.ResponsiveContainer>
|
|
55
|
+
</div>
|
|
56
|
+
</ChartContext.Provider>
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
ChartContainer.displayName = "Chart";
|
|
60
|
+
|
|
61
|
+
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
|
62
|
+
const colorConfig = Object.entries(config).filter(([_, config]) => config.theme || config.color);
|
|
63
|
+
|
|
64
|
+
if (!colorConfig.length) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<style
|
|
70
|
+
dangerouslySetInnerHTML={{
|
|
71
|
+
__html: Object.entries(THEMES)
|
|
72
|
+
.map(
|
|
73
|
+
([theme, prefix]) => `
|
|
74
|
+
${prefix} [data-chart=${id}] {
|
|
75
|
+
${colorConfig
|
|
76
|
+
.map(([key, itemConfig]) => {
|
|
77
|
+
const color = itemConfig.theme?.[theme as keyof typeof itemConfig.theme] || itemConfig.color;
|
|
78
|
+
return color ? ` --color-${key}: ${color};` : null;
|
|
79
|
+
})
|
|
80
|
+
.join("\n")}
|
|
81
|
+
}
|
|
82
|
+
`,
|
|
83
|
+
)
|
|
84
|
+
.join("\n"),
|
|
85
|
+
}}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const ChartTooltip = RechartsPrimitive.Tooltip;
|
|
91
|
+
|
|
92
|
+
const ChartTooltipContent = React.forwardRef<
|
|
93
|
+
HTMLDivElement,
|
|
94
|
+
React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
|
|
95
|
+
React.ComponentProps<"div"> & {
|
|
96
|
+
hideLabel?: boolean;
|
|
97
|
+
hideIndicator?: boolean;
|
|
98
|
+
indicator?: "line" | "dot" | "dashed";
|
|
99
|
+
nameKey?: string;
|
|
100
|
+
labelKey?: string;
|
|
101
|
+
}
|
|
102
|
+
>(
|
|
103
|
+
(
|
|
104
|
+
{
|
|
105
|
+
active,
|
|
106
|
+
payload,
|
|
107
|
+
className,
|
|
108
|
+
indicator = "dot",
|
|
109
|
+
hideLabel = false,
|
|
110
|
+
hideIndicator = false,
|
|
111
|
+
label,
|
|
112
|
+
labelFormatter,
|
|
113
|
+
labelClassName,
|
|
114
|
+
formatter,
|
|
115
|
+
color,
|
|
116
|
+
nameKey,
|
|
117
|
+
labelKey,
|
|
118
|
+
},
|
|
119
|
+
ref,
|
|
120
|
+
) => {
|
|
121
|
+
const { config } = useChart();
|
|
122
|
+
|
|
123
|
+
const tooltipLabel = React.useMemo(() => {
|
|
124
|
+
if (hideLabel || !payload?.length) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const [item] = payload;
|
|
129
|
+
const key = `${labelKey || item.dataKey || item.name || "value"}`;
|
|
130
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
131
|
+
const value =
|
|
132
|
+
!labelKey && typeof label === "string"
|
|
133
|
+
? config[label as keyof typeof config]?.label || label
|
|
134
|
+
: itemConfig?.label;
|
|
135
|
+
|
|
136
|
+
if (labelFormatter) {
|
|
137
|
+
return <div className={cn("font-medium", labelClassName)}>{labelFormatter(value, payload)}</div>;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (!value) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return <div className={cn("font-medium", labelClassName)}>{value}</div>;
|
|
145
|
+
}, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
|
|
146
|
+
|
|
147
|
+
if (!active || !payload?.length) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<div
|
|
155
|
+
ref={ref}
|
|
156
|
+
className={cn(
|
|
157
|
+
"grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",
|
|
158
|
+
className,
|
|
159
|
+
)}
|
|
160
|
+
>
|
|
161
|
+
{!nestLabel ? tooltipLabel : null}
|
|
162
|
+
<div className="grid gap-1.5">
|
|
163
|
+
{payload.map((item, index) => {
|
|
164
|
+
const key = `${nameKey || item.name || item.dataKey || "value"}`;
|
|
165
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
166
|
+
const indicatorColor = color || item.payload.fill || item.color;
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<div
|
|
170
|
+
key={item.dataKey}
|
|
171
|
+
className={cn(
|
|
172
|
+
"flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
|
|
173
|
+
indicator === "dot" && "items-center",
|
|
174
|
+
)}
|
|
175
|
+
>
|
|
176
|
+
{formatter && item?.value !== undefined && item.name ? (
|
|
177
|
+
formatter(item.value, item.name, item, index, item.payload)
|
|
178
|
+
) : (
|
|
179
|
+
<>
|
|
180
|
+
{itemConfig?.icon ? (
|
|
181
|
+
<itemConfig.icon />
|
|
182
|
+
) : (
|
|
183
|
+
!hideIndicator && (
|
|
184
|
+
<div
|
|
185
|
+
className={cn("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]", {
|
|
186
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
187
|
+
"w-1": indicator === "line",
|
|
188
|
+
"w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
|
|
189
|
+
"my-0.5": nestLabel && indicator === "dashed",
|
|
190
|
+
})}
|
|
191
|
+
style={
|
|
192
|
+
{
|
|
193
|
+
"--color-bg": indicatorColor,
|
|
194
|
+
"--color-border": indicatorColor,
|
|
195
|
+
} as React.CSSProperties
|
|
196
|
+
}
|
|
197
|
+
/>
|
|
198
|
+
)
|
|
199
|
+
)}
|
|
200
|
+
<div
|
|
201
|
+
className={cn(
|
|
202
|
+
"flex flex-1 justify-between leading-none",
|
|
203
|
+
nestLabel ? "items-end" : "items-center",
|
|
204
|
+
)}
|
|
205
|
+
>
|
|
206
|
+
<div className="grid gap-1.5">
|
|
207
|
+
{nestLabel ? tooltipLabel : null}
|
|
208
|
+
<span className="text-muted-foreground">{itemConfig?.label || item.name}</span>
|
|
209
|
+
</div>
|
|
210
|
+
{item.value && (
|
|
211
|
+
<span className="font-mono font-medium tabular-nums text-foreground">
|
|
212
|
+
{item.value.toLocaleString()}
|
|
213
|
+
</span>
|
|
214
|
+
)}
|
|
215
|
+
</div>
|
|
216
|
+
</>
|
|
217
|
+
)}
|
|
218
|
+
</div>
|
|
219
|
+
);
|
|
220
|
+
})}
|
|
221
|
+
</div>
|
|
222
|
+
</div>
|
|
223
|
+
);
|
|
224
|
+
},
|
|
225
|
+
);
|
|
226
|
+
ChartTooltipContent.displayName = "ChartTooltip";
|
|
227
|
+
|
|
228
|
+
const ChartLegend = RechartsPrimitive.Legend;
|
|
229
|
+
|
|
230
|
+
const ChartLegendContent = React.forwardRef<
|
|
231
|
+
HTMLDivElement,
|
|
232
|
+
React.ComponentProps<"div"> &
|
|
233
|
+
Pick<RechartsPrimitive.LegendProps, "payload" | "verticalAlign"> & {
|
|
234
|
+
hideIcon?: boolean;
|
|
235
|
+
nameKey?: string;
|
|
236
|
+
}
|
|
237
|
+
>(({ className, hideIcon = false, payload, verticalAlign = "bottom", nameKey }, ref) => {
|
|
238
|
+
const { config } = useChart();
|
|
239
|
+
|
|
240
|
+
if (!payload?.length) {
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return (
|
|
245
|
+
<div
|
|
246
|
+
ref={ref}
|
|
247
|
+
className={cn("flex items-center justify-center gap-4", verticalAlign === "top" ? "pb-3" : "pt-3", className)}
|
|
248
|
+
>
|
|
249
|
+
{payload.map((item) => {
|
|
250
|
+
const key = `${nameKey || item.dataKey || "value"}`;
|
|
251
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
252
|
+
|
|
253
|
+
return (
|
|
254
|
+
<div
|
|
255
|
+
key={item.value}
|
|
256
|
+
className={cn("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground")}
|
|
257
|
+
>
|
|
258
|
+
{itemConfig?.icon && !hideIcon ? (
|
|
259
|
+
<itemConfig.icon />
|
|
260
|
+
) : (
|
|
261
|
+
<div
|
|
262
|
+
className="h-2 w-2 shrink-0 rounded-[2px]"
|
|
263
|
+
style={{
|
|
264
|
+
backgroundColor: item.color,
|
|
265
|
+
}}
|
|
266
|
+
/>
|
|
267
|
+
)}
|
|
268
|
+
{itemConfig?.label}
|
|
269
|
+
</div>
|
|
270
|
+
);
|
|
271
|
+
})}
|
|
272
|
+
</div>
|
|
273
|
+
);
|
|
274
|
+
});
|
|
275
|
+
ChartLegendContent.displayName = "ChartLegend";
|
|
276
|
+
|
|
277
|
+
// Helper to extract item config from a payload.
|
|
278
|
+
function getPayloadConfigFromPayload(config: ChartConfig, payload: unknown, key: string) {
|
|
279
|
+
if (typeof payload !== "object" || payload === null) {
|
|
280
|
+
return undefined;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const payloadPayload =
|
|
284
|
+
"payload" in payload && typeof payload.payload === "object" && payload.payload !== null
|
|
285
|
+
? payload.payload
|
|
286
|
+
: undefined;
|
|
287
|
+
|
|
288
|
+
let configLabelKey: string = key;
|
|
289
|
+
|
|
290
|
+
if (key in payload && typeof payload[key as keyof typeof payload] === "string") {
|
|
291
|
+
configLabelKey = payload[key as keyof typeof payload] as string;
|
|
292
|
+
} else if (
|
|
293
|
+
payloadPayload &&
|
|
294
|
+
key in payloadPayload &&
|
|
295
|
+
typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
|
|
296
|
+
) {
|
|
297
|
+
configLabelKey = payloadPayload[key as keyof typeof payloadPayload] as string;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
return configLabelKey in config ? config[configLabelKey] : config[key as keyof typeof config];
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
3
|
+
import { Check } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils";
|
|
6
|
+
|
|
7
|
+
const Checkbox = React.forwardRef<
|
|
8
|
+
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
|
9
|
+
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
|
|
10
|
+
>(({ className, ...props }, ref) => (
|
|
11
|
+
<CheckboxPrimitive.Root
|
|
12
|
+
ref={ref}
|
|
13
|
+
className={cn(
|
|
14
|
+
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
15
|
+
className,
|
|
16
|
+
)}
|
|
17
|
+
{...props}
|
|
18
|
+
>
|
|
19
|
+
<CheckboxPrimitive.Indicator className={cn("flex items-center justify-center text-current")}>
|
|
20
|
+
<Check className="h-4 w-4" />
|
|
21
|
+
</CheckboxPrimitive.Indicator>
|
|
22
|
+
</CheckboxPrimitive.Root>
|
|
23
|
+
));
|
|
24
|
+
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
|
|
25
|
+
|
|
26
|
+
export { Checkbox };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
|
2
|
+
|
|
3
|
+
const Collapsible = CollapsiblePrimitive.Root;
|
|
4
|
+
|
|
5
|
+
const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger;
|
|
6
|
+
|
|
7
|
+
const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent;
|
|
8
|
+
|
|
9
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent };
|