@appcorp/shadcn 1.2.0 → 2.0.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/components/app-sidebar.js +16 -23
- package/components/audio.js +11 -19
- package/components/dashboard.js +27 -65
- package/components/drawer-generic.js +20 -28
- package/components/enhanced-checkbox.js +10 -57
- package/components/enhanced-combobox.js +99 -143
- package/components/enhanced-drawer-footer.js +22 -31
- package/components/enhanced-drawer-header.js +6 -14
- package/components/enhanced-dropzone-impl.d.ts +32 -0
- package/components/enhanced-dropzone-impl.js +218 -0
- package/components/enhanced-dropzone.d.ts +2 -63
- package/components/enhanced-dropzone.js +6 -294
- package/components/enhanced-input.js +10 -57
- package/components/enhanced-label.js +6 -52
- package/components/enhanced-radio.js +12 -20
- package/components/enhanced-select.js +13 -61
- package/components/enhanced-slider.js +11 -58
- package/components/enhanced-switch.js +11 -58
- package/components/enhanced-table-footer-action.js +11 -19
- package/components/enhanced-table-footer-page.js +16 -24
- package/components/enhanced-table-footer-pagination.js +11 -21
- package/components/enhanced-table-header-action.js +22 -30
- package/components/enhanced-table-header-search.js +9 -17
- package/components/enhanced-table.js +125 -153
- package/components/enhanced-textarea.js +10 -57
- package/components/field.d.ts +1 -1
- package/components/field.js +31 -88
- package/components/image-resize-dialog.js +61 -159
- package/components/nav-main.js +32 -78
- package/components/nav-projects.js +37 -48
- package/components/nav-user.js +41 -51
- package/components/show-toast.js +5 -9
- package/components/sidebar.d.ts +1 -1
- package/components/sidebar.js +115 -184
- package/components/team-switcher.js +36 -47
- package/components/theme-provider.js +36 -84
- package/components/timeline.js +12 -20
- package/components/tooltip.js +10 -59
- package/components/ui/accordion.js +17 -67
- package/components/ui/alert-dialog.js +32 -89
- package/components/ui/alert.d.ts +1 -1
- package/components/ui/alert.js +14 -63
- package/components/ui/area-chart-v1-impl.d.ts +19 -0
- package/components/ui/area-chart-v1-impl.js +75 -0
- package/components/ui/area-chart-v1.d.ts +2 -19
- package/components/ui/area-chart-v1.js +4 -113
- package/components/ui/aspect-ratio.js +3 -39
- package/components/ui/avatar.js +13 -62
- package/components/ui/badge.d.ts +2 -2
- package/components/ui/badge.js +7 -55
- package/components/ui/breadcrumb.js +27 -80
- package/components/ui/button.d.ts +2 -2
- package/components/ui/button.js +10 -58
- package/components/ui/calendar-impl.d.ts +8 -0
- package/components/ui/calendar-impl.js +55 -0
- package/components/ui/calendar.d.ts +2 -8
- package/components/ui/calendar.js +5 -108
- package/components/ui/card.js +21 -73
- package/components/ui/carousel-impl.d.ts +18 -0
- package/components/ui/carousel-impl.js +117 -0
- package/components/ui/carousel.d.ts +6 -18
- package/components/ui/carousel.js +8 -170
- package/components/ui/chart-impl.d.ts +62 -0
- package/components/ui/chart-impl.js +162 -0
- package/components/ui/chart.d.ts +7 -62
- package/components/ui/chart.js +9 -219
- package/components/ui/checkbox.js +10 -57
- package/components/ui/collapsible.js +5 -43
- package/components/ui/combobox.js +22 -58
- package/components/ui/command-impl.d.ts +80 -0
- package/components/ui/command-impl.js +63 -0
- package/components/ui/command.d.ts +9 -80
- package/components/ui/command.js +12 -117
- package/components/ui/context-menu.js +41 -102
- package/components/ui/dialog.js +28 -84
- package/components/ui/drawer-impl.d.ts +22 -0
- package/components/ui/drawer-impl.js +56 -0
- package/components/ui/drawer.d.ts +10 -22
- package/components/ui/drawer.js +13 -111
- package/components/ui/dropdown-menu.js +41 -102
- package/components/ui/form.d.ts +4 -2
- package/components/ui/form.js +41 -95
- package/components/ui/hover-card.js +9 -58
- package/components/ui/input-otp-impl.d.ts +34 -0
- package/components/ui/input-otp-impl.js +43 -0
- package/components/ui/input-otp.d.ts +4 -34
- package/components/ui/input-otp.js +7 -92
- package/components/ui/input.js +6 -53
- package/components/ui/label.d.ts +1 -1
- package/components/ui/label.js +9 -56
- package/components/ui/language-selector.js +17 -55
- package/components/ui/menubar.js +46 -108
- package/components/ui/navigation-menu.d.ts +1 -1
- package/components/ui/navigation-menu.js +29 -84
- package/components/ui/pagination.js +30 -83
- package/components/ui/popover.js +10 -60
- package/components/ui/progress.js +8 -55
- package/components/ui/radio-group.js +12 -60
- package/components/ui/resizable-impl.d.ts +24 -0
- package/components/ui/resizable-impl.js +27 -0
- package/components/ui/resizable.d.ts +3 -24
- package/components/ui/resizable.js +6 -78
- package/components/ui/scroll-area.js +10 -58
- package/components/ui/select.js +34 -90
- package/components/ui/separator.js +7 -54
- package/components/ui/sheet.d.ts +1 -1
- package/components/ui/sheet.js +30 -86
- package/components/ui/skeleton.js +5 -21
- package/components/ui/slider.js +10 -57
- package/components/ui/sonner.js +7 -24
- package/components/ui/switch.js +8 -55
- package/components/ui/table.js +27 -81
- package/components/ui/tabs.js +14 -64
- package/components/ui/textarea.js +6 -53
- package/components/ui/theme-switcher.js +41 -91
- package/components/ui/toggle.d.ts +2 -2
- package/components/ui/toggle.js +9 -57
- package/data/admin-dashboard.js +16 -19
- package/hooks/use-enhanced-combobox.js +47 -124
- package/hooks/use-mobile.js +8 -44
- package/hooks/use-outside-click.js +6 -10
- package/lib/themes.js +1 -4
- package/lib/toast-utils.js +78 -120
- package/lib/utils.js +4 -11
- package/package.json +9 -90
- package/utils/transform-breadcrumbs.js +4 -8
- package/utils/transform-navitems.js +7 -22
- package/components/aceternity-ui/apple-cards-carousel.d.ts +0 -35
- package/components/aceternity-ui/apple-cards-carousel.js +0 -263
- package/components/shadcn-example/ai-chat/chat-interface.d.ts +0 -11
- package/components/shadcn-example/ai-chat/chat-interface.js +0 -70
- package/components/shadcn-example/ai-chat/index.d.ts +0 -38
- package/components/shadcn-example/ai-chat/index.js +0 -66
- package/components/shadcn-example/ai-chat/sidebar.d.ts +0 -15
- package/components/shadcn-example/ai-chat/sidebar.js +0 -68
- package/components/shadcn-example/ai-chat/welcome-section.d.ts +0 -12
- package/components/shadcn-example/ai-chat/welcome-section.js +0 -26
- package/components/shadcn-example/authentication/index.d.ts +0 -24
- package/components/shadcn-example/authentication/index.js +0 -59
- package/components/shadcn-example/authentication/user-auth-form.d.ts +0 -11
- package/components/shadcn-example/authentication/user-auth-form.js +0 -54
- package/components/shadcn-example/blog-detail-page/comment-section.d.ts +0 -15
- package/components/shadcn-example/blog-detail-page/comment-section.js +0 -83
- package/components/shadcn-example/blog-detail-page/content.d.ts +0 -7
- package/components/shadcn-example/blog-detail-page/content.js +0 -15
- package/components/shadcn-example/blog-detail-page/header.d.ts +0 -11
- package/components/shadcn-example/blog-detail-page/header.js +0 -36
- package/components/shadcn-example/blog-detail-page/index.d.ts +0 -25
- package/components/shadcn-example/blog-detail-page/index.js +0 -74
- package/components/shadcn-example/blog-page/blog-post-card.d.ts +0 -13
- package/components/shadcn-example/blog-page/blog-post-card.js +0 -30
- package/components/shadcn-example/blog-page/featured-post-sidebar-item.d.ts +0 -10
- package/components/shadcn-example/blog-page/featured-post-sidebar-item.js +0 -19
- package/components/shadcn-example/blog-page/index.d.ts +0 -20
- package/components/shadcn-example/blog-page/index.js +0 -36
- package/components/shadcn-example/coming-soon/countdown.d.ts +0 -2
- package/components/shadcn-example/coming-soon/countdown.js +0 -82
- package/components/shadcn-example/coming-soon/index.d.ts +0 -10
- package/components/shadcn-example/coming-soon/index.js +0 -41
- package/components/shadcn-io/color-picker/index.d.ts +0 -43
- package/components/shadcn-io/color-picker/index.js +0 -304
- package/components/shadcn-io/copy-button/index.d.ts +0 -16
- package/components/shadcn-io/copy-button/index.js +0 -121
- package/components/shadcn-io/dropzone/index.d.ts +0 -19
- package/components/shadcn-io/dropzone/index.js +0 -131
- package/components/shadcn-io/gantt/index.d.ts +0 -145
- package/components/shadcn-io/gantt/index.js +0 -766
- package/components/shadcn-io/table/index.d.ts +0 -60
- package/components/shadcn-io/table/index.js +0 -138
- package/templates/appcorp-v1/footer/bottom-bar.d.ts +0 -6
- package/templates/appcorp-v1/footer/bottom-bar.js +0 -25
- package/templates/appcorp-v1/footer/cta.d.ts +0 -6
- package/templates/appcorp-v1/footer/cta.js +0 -21
- package/templates/appcorp-v1/footer/footer-grid.d.ts +0 -14
- package/templates/appcorp-v1/footer/footer-grid.js +0 -52
- package/templates/appcorp-v1/footer/index.d.ts +0 -3
- package/templates/appcorp-v1/footer/index.js +0 -28
- package/templates/appcorp-v1/footer/newsletter.d.ts +0 -11
- package/templates/appcorp-v1/footer/newsletter.js +0 -28
- package/templates/appcorp-v1/footer/stats.d.ts +0 -6
- package/templates/appcorp-v1/footer/stats.js +0 -15
- package/templates/appcorp-v1/header/announcement-bar.d.ts +0 -3
- package/templates/appcorp-v1/header/announcement-bar.js +0 -15
- package/templates/appcorp-v1/header/dropdown-panel.d.ts +0 -8
- package/templates/appcorp-v1/header/dropdown-panel.js +0 -72
- package/templates/appcorp-v1/header/index.d.ts +0 -12
- package/templates/appcorp-v1/header/index.js +0 -16
- package/templates/appcorp-v1/header/mobile-menu.d.ts +0 -14
- package/templates/appcorp-v1/header/mobile-menu.js +0 -101
- package/templates/appcorp-v1/header/navigation-bar.d.ts +0 -3
- package/templates/appcorp-v1/header/navigation-bar.js +0 -117
- package/templates/appcorp-v1/header/social-button.d.ts +0 -7
- package/templates/appcorp-v1/header/social-button.js +0 -48
- package/templates/appcorp-v1/home.d.ts +0 -3
- package/templates/appcorp-v1/home.js +0 -27
- package/templates/data/appcorp-v1.d.ts +0 -93
- package/templates/data/appcorp-v1.js +0 -348
- package/templates/data/edupilotpro-v1.d.ts +0 -33
- package/templates/data/edupilotpro-v1.js +0 -116
- package/templates/data/school-v1.d.ts +0 -328
- package/templates/data/school-v1.js +0 -1563
- package/templates/edupilotpro-v1/feature-card.d.ts +0 -13
- package/templates/edupilotpro-v1/feature-card.js +0 -28
- package/templates/edupilotpro-v1/mockups/dashboard-mockup.d.ts +0 -3
- package/templates/edupilotpro-v1/mockups/dashboard-mockup.js +0 -55
- package/templates/school-v1/footer.d.ts +0 -3
- package/templates/school-v1/footer.js +0 -75
- package/templates/school-v1/index.d.ts +0 -18
- package/templates/school-v1/index.js +0 -60
- package/templates/school-v1/navigation.d.ts +0 -3
- package/templates/school-v1/navigation.js +0 -123
- package/templates/school-v1/sections/about.d.ts +0 -3
- package/templates/school-v1/sections/about.js +0 -49
- package/templates/school-v1/sections/admissions.d.ts +0 -3
- package/templates/school-v1/sections/admissions.js +0 -77
- package/templates/school-v1/sections/contact.d.ts +0 -3
- package/templates/school-v1/sections/contact.js +0 -67
- package/templates/school-v1/sections/faqs.d.ts +0 -3
- package/templates/school-v1/sections/faqs.js +0 -50
- package/templates/school-v1/sections/hero.d.ts +0 -3
- package/templates/school-v1/sections/hero.js +0 -132
- package/templates/school-v1/sections/management.d.ts +0 -3
- package/templates/school-v1/sections/management.js +0 -34
- package/templates/school-v1/sections/policies.d.ts +0 -3
- package/templates/school-v1/sections/policies.js +0 -127
- package/templates/school-v1/sections/programs.d.ts +0 -3
- package/templates/school-v1/sections/programs.js +0 -107
- package/templates/school-v1/sections/testimonials.d.ts +0 -3
- package/templates/school-v1/sections/testimonials.js +0 -46
- package/templates/school-v1/sections/why-choose-us.d.ts +0 -3
- package/templates/school-v1/sections/why-choose-us.js +0 -57
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import * as React from "react";
|
|
14
|
+
import useEmblaCarousel from "embla-carousel-react";
|
|
15
|
+
import { cn } from "../../lib/utils";
|
|
16
|
+
import { Button } from "../ui/button";
|
|
17
|
+
import { ArrowLeftIcon, ArrowRightIcon } from "@radix-ui/react-icons";
|
|
18
|
+
const CarouselContext = React.createContext(null);
|
|
19
|
+
function useCarousel() {
|
|
20
|
+
const context = React.useContext(CarouselContext);
|
|
21
|
+
if (!context) {
|
|
22
|
+
throw new Error("useCarousel must be used within a <Carousel />");
|
|
23
|
+
}
|
|
24
|
+
return context;
|
|
25
|
+
}
|
|
26
|
+
const Carousel = React.forwardRef((_a, ref) => {
|
|
27
|
+
var { orientation = "horizontal", opts, setApi, plugins, className, children } = _a, props = __rest(_a, ["orientation", "opts", "setApi", "plugins", "className", "children"]);
|
|
28
|
+
const [carouselRef, api] = useEmblaCarousel(Object.assign(Object.assign({}, opts), { axis: orientation === "horizontal" ? "x" : "y" }), plugins);
|
|
29
|
+
const [canScrollPrev, setCanScrollPrev] = React.useState(false);
|
|
30
|
+
const [canScrollNext, setCanScrollNext] = React.useState(false);
|
|
31
|
+
const onSelect = React.useCallback((api) => {
|
|
32
|
+
if (!api) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
setCanScrollPrev(api.canScrollPrev());
|
|
36
|
+
setCanScrollNext(api.canScrollNext());
|
|
37
|
+
}, []);
|
|
38
|
+
const scrollPrev = React.useCallback(() => {
|
|
39
|
+
api === null || api === void 0 ? void 0 : api.scrollPrev();
|
|
40
|
+
}, [api]);
|
|
41
|
+
const scrollNext = React.useCallback(() => {
|
|
42
|
+
api === null || api === void 0 ? void 0 : api.scrollNext();
|
|
43
|
+
}, [api]);
|
|
44
|
+
const handleKeyDown = React.useCallback((event) => {
|
|
45
|
+
if (event.key === "ArrowLeft") {
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
scrollPrev();
|
|
48
|
+
}
|
|
49
|
+
else if (event.key === "ArrowRight") {
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
scrollNext();
|
|
52
|
+
}
|
|
53
|
+
}, [scrollPrev, scrollNext]);
|
|
54
|
+
React.useEffect(() => {
|
|
55
|
+
if (!api || !setApi) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
setApi(api);
|
|
59
|
+
}, [api, setApi]);
|
|
60
|
+
React.useEffect(() => {
|
|
61
|
+
if (!api) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
onSelect(api);
|
|
65
|
+
api.on("reInit", onSelect);
|
|
66
|
+
api.on("select", onSelect);
|
|
67
|
+
return () => {
|
|
68
|
+
api === null || api === void 0 ? void 0 : api.off("select", onSelect);
|
|
69
|
+
};
|
|
70
|
+
}, [api, onSelect]);
|
|
71
|
+
return (React.createElement(CarouselContext.Provider, { value: {
|
|
72
|
+
carouselRef,
|
|
73
|
+
api: api,
|
|
74
|
+
opts,
|
|
75
|
+
orientation: orientation || ((opts === null || opts === void 0 ? void 0 : opts.axis) === "y" ? "vertical" : "horizontal"),
|
|
76
|
+
scrollPrev,
|
|
77
|
+
scrollNext,
|
|
78
|
+
canScrollPrev,
|
|
79
|
+
canScrollNext,
|
|
80
|
+
} },
|
|
81
|
+
React.createElement("div", Object.assign({ ref: ref, onKeyDownCapture: handleKeyDown, className: cn("relative", className), role: "region", "aria-roledescription": "carousel" }, props), children)));
|
|
82
|
+
});
|
|
83
|
+
Carousel.displayName = "Carousel";
|
|
84
|
+
const CarouselContent = React.forwardRef((_a, ref) => {
|
|
85
|
+
var { className } = _a, props = __rest(_a, ["className"]);
|
|
86
|
+
const { carouselRef, orientation } = useCarousel();
|
|
87
|
+
return (React.createElement("div", { ref: carouselRef, className: "overflow-hidden" },
|
|
88
|
+
React.createElement("div", Object.assign({ ref: ref, className: cn("flex", orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col", className) }, props))));
|
|
89
|
+
});
|
|
90
|
+
CarouselContent.displayName = "CarouselContent";
|
|
91
|
+
const CarouselItem = React.forwardRef((_a, ref) => {
|
|
92
|
+
var { className } = _a, props = __rest(_a, ["className"]);
|
|
93
|
+
const { orientation } = useCarousel();
|
|
94
|
+
return (React.createElement("div", Object.assign({ ref: ref, role: "group", "aria-roledescription": "slide", className: cn("min-w-0 shrink-0 grow-0 basis-full", orientation === "horizontal" ? "pl-4" : "pt-4", className) }, props)));
|
|
95
|
+
});
|
|
96
|
+
CarouselItem.displayName = "CarouselItem";
|
|
97
|
+
const CarouselPrevious = React.forwardRef((_a, ref) => {
|
|
98
|
+
var { className, variant = "outline", size = "icon" } = _a, props = __rest(_a, ["className", "variant", "size"]);
|
|
99
|
+
const { orientation, scrollPrev, canScrollPrev } = useCarousel();
|
|
100
|
+
return (React.createElement(Button, Object.assign({ ref: ref, variant: variant, size: size, className: cn("absolute h-8 w-8 rounded-full", orientation === "horizontal"
|
|
101
|
+
? "-left-12 top-1/2 -translate-y-1/2"
|
|
102
|
+
: "-top-12 left-1/2 -translate-x-1/2 rotate-90", className), disabled: !canScrollPrev, onClick: scrollPrev }, props),
|
|
103
|
+
React.createElement(ArrowLeftIcon, { className: "h-4 w-4" }),
|
|
104
|
+
React.createElement("span", { className: "sr-only" }, "Previous slide")));
|
|
105
|
+
});
|
|
106
|
+
CarouselPrevious.displayName = "CarouselPrevious";
|
|
107
|
+
const CarouselNext = React.forwardRef((_a, ref) => {
|
|
108
|
+
var { className, variant = "outline", size = "icon" } = _a, props = __rest(_a, ["className", "variant", "size"]);
|
|
109
|
+
const { orientation, scrollNext, canScrollNext } = useCarousel();
|
|
110
|
+
return (React.createElement(Button, Object.assign({ ref: ref, variant: variant, size: size, className: cn("absolute h-8 w-8 rounded-full", orientation === "horizontal"
|
|
111
|
+
? "-right-12 top-1/2 -translate-y-1/2"
|
|
112
|
+
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90", className), disabled: !canScrollNext, onClick: scrollNext }, props),
|
|
113
|
+
React.createElement(ArrowRightIcon, { className: "h-4 w-4" }),
|
|
114
|
+
React.createElement("span", { className: "sr-only" }, "Next slide")));
|
|
115
|
+
});
|
|
116
|
+
CarouselNext.displayName = "CarouselNext";
|
|
117
|
+
export { Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext, };
|
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
type CarouselProps = {
|
|
8
|
-
opts?: CarouselOptions;
|
|
9
|
-
plugins?: CarouselPlugin;
|
|
10
|
-
orientation?: "horizontal" | "vertical";
|
|
11
|
-
setApi?: (api: CarouselApi) => void;
|
|
12
|
-
};
|
|
13
|
-
declare const Carousel: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & CarouselProps & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
-
declare const CarouselContent: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
15
|
-
declare const CarouselItem: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
16
|
-
declare const CarouselPrevious: React.ForwardRefExoticComponent<Omit<import("../ui/button").ButtonProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
17
|
-
declare const CarouselNext: React.ForwardRefExoticComponent<Omit<import("../ui/button").ButtonProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
18
|
-
export { type CarouselApi, Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext, };
|
|
1
|
+
export type { CarouselApi } from "./carousel-impl";
|
|
2
|
+
export declare const Carousel: typeof import("./carousel-impl")["Carousel"];
|
|
3
|
+
export declare const CarouselContent: typeof import("./carousel-impl")["CarouselContent"];
|
|
4
|
+
export declare const CarouselItem: typeof import("./carousel-impl")["CarouselItem"];
|
|
5
|
+
export declare const CarouselPrevious: typeof import("./carousel-impl")["CarouselPrevious"];
|
|
6
|
+
export declare const CarouselNext: typeof import("./carousel-impl")["CarouselNext"];
|
|
@@ -1,171 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
return __assign.apply(this, arguments);
|
|
13
|
-
};
|
|
14
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
|
-
}
|
|
20
|
-
Object.defineProperty(o, k2, desc);
|
|
21
|
-
}) : (function(o, m, k, k2) {
|
|
22
|
-
if (k2 === undefined) k2 = k;
|
|
23
|
-
o[k2] = m[k];
|
|
24
|
-
}));
|
|
25
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
26
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
27
|
-
}) : function(o, v) {
|
|
28
|
-
o["default"] = v;
|
|
29
|
-
});
|
|
30
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
31
|
-
var ownKeys = function(o) {
|
|
32
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
33
|
-
var ar = [];
|
|
34
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
35
|
-
return ar;
|
|
36
|
-
};
|
|
37
|
-
return ownKeys(o);
|
|
38
|
-
};
|
|
39
|
-
return function (mod) {
|
|
40
|
-
if (mod && mod.__esModule) return mod;
|
|
41
|
-
var result = {};
|
|
42
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
43
|
-
__setModuleDefault(result, mod);
|
|
44
|
-
return result;
|
|
45
|
-
};
|
|
46
|
-
})();
|
|
47
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
48
|
-
var t = {};
|
|
49
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
50
|
-
t[p] = s[p];
|
|
51
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
52
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
53
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
54
|
-
t[p[i]] = s[p[i]];
|
|
55
|
-
}
|
|
56
|
-
return t;
|
|
57
|
-
};
|
|
58
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
59
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
|
-
};
|
|
61
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
-
exports.CarouselNext = exports.CarouselPrevious = exports.CarouselItem = exports.CarouselContent = exports.Carousel = void 0;
|
|
63
|
-
var React = __importStar(require("react"));
|
|
64
|
-
var embla_carousel_react_1 = __importDefault(require("embla-carousel-react"));
|
|
65
|
-
var utils_1 = require("../../lib/utils");
|
|
66
|
-
var button_1 = require("../ui/button");
|
|
67
|
-
var react_icons_1 = require("@radix-ui/react-icons");
|
|
68
|
-
var CarouselContext = React.createContext(null);
|
|
69
|
-
function useCarousel() {
|
|
70
|
-
var context = React.useContext(CarouselContext);
|
|
71
|
-
if (!context) {
|
|
72
|
-
throw new Error("useCarousel must be used within a <Carousel />");
|
|
73
|
-
}
|
|
74
|
-
return context;
|
|
75
|
-
}
|
|
76
|
-
var Carousel = React.forwardRef(function (_a, ref) {
|
|
77
|
-
var _b = _a.orientation, orientation = _b === void 0 ? "horizontal" : _b, opts = _a.opts, setApi = _a.setApi, plugins = _a.plugins, className = _a.className, children = _a.children, props = __rest(_a, ["orientation", "opts", "setApi", "plugins", "className", "children"]);
|
|
78
|
-
var _c = (0, embla_carousel_react_1.default)(__assign(__assign({}, opts), { axis: orientation === "horizontal" ? "x" : "y" }), plugins), carouselRef = _c[0], api = _c[1];
|
|
79
|
-
var _d = React.useState(false), canScrollPrev = _d[0], setCanScrollPrev = _d[1];
|
|
80
|
-
var _e = React.useState(false), canScrollNext = _e[0], setCanScrollNext = _e[1];
|
|
81
|
-
var onSelect = React.useCallback(function (api) {
|
|
82
|
-
if (!api) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
setCanScrollPrev(api.canScrollPrev());
|
|
86
|
-
setCanScrollNext(api.canScrollNext());
|
|
87
|
-
}, []);
|
|
88
|
-
var scrollPrev = React.useCallback(function () {
|
|
89
|
-
api === null || api === void 0 ? void 0 : api.scrollPrev();
|
|
90
|
-
}, [api]);
|
|
91
|
-
var scrollNext = React.useCallback(function () {
|
|
92
|
-
api === null || api === void 0 ? void 0 : api.scrollNext();
|
|
93
|
-
}, [api]);
|
|
94
|
-
var handleKeyDown = React.useCallback(function (event) {
|
|
95
|
-
if (event.key === "ArrowLeft") {
|
|
96
|
-
event.preventDefault();
|
|
97
|
-
scrollPrev();
|
|
98
|
-
}
|
|
99
|
-
else if (event.key === "ArrowRight") {
|
|
100
|
-
event.preventDefault();
|
|
101
|
-
scrollNext();
|
|
102
|
-
}
|
|
103
|
-
}, [scrollPrev, scrollNext]);
|
|
104
|
-
React.useEffect(function () {
|
|
105
|
-
if (!api || !setApi) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
setApi(api);
|
|
109
|
-
}, [api, setApi]);
|
|
110
|
-
React.useEffect(function () {
|
|
111
|
-
if (!api) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
onSelect(api);
|
|
115
|
-
api.on("reInit", onSelect);
|
|
116
|
-
api.on("select", onSelect);
|
|
117
|
-
return function () {
|
|
118
|
-
api === null || api === void 0 ? void 0 : api.off("select", onSelect);
|
|
119
|
-
};
|
|
120
|
-
}, [api, onSelect]);
|
|
121
|
-
return (React.createElement(CarouselContext.Provider, { value: {
|
|
122
|
-
carouselRef: carouselRef,
|
|
123
|
-
api: api,
|
|
124
|
-
opts: opts,
|
|
125
|
-
orientation: orientation || ((opts === null || opts === void 0 ? void 0 : opts.axis) === "y" ? "vertical" : "horizontal"),
|
|
126
|
-
scrollPrev: scrollPrev,
|
|
127
|
-
scrollNext: scrollNext,
|
|
128
|
-
canScrollPrev: canScrollPrev,
|
|
129
|
-
canScrollNext: canScrollNext,
|
|
130
|
-
} },
|
|
131
|
-
React.createElement("div", __assign({ ref: ref, onKeyDownCapture: handleKeyDown, className: (0, utils_1.cn)("relative", className), role: "region", "aria-roledescription": "carousel" }, props), children)));
|
|
132
|
-
});
|
|
133
|
-
exports.Carousel = Carousel;
|
|
134
|
-
Carousel.displayName = "Carousel";
|
|
135
|
-
var CarouselContent = React.forwardRef(function (_a, ref) {
|
|
136
|
-
var className = _a.className, props = __rest(_a, ["className"]);
|
|
137
|
-
var _b = useCarousel(), carouselRef = _b.carouselRef, orientation = _b.orientation;
|
|
138
|
-
return (React.createElement("div", { ref: carouselRef, className: "overflow-hidden" },
|
|
139
|
-
React.createElement("div", __assign({ ref: ref, className: (0, utils_1.cn)("flex", orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col", className) }, props))));
|
|
140
|
-
});
|
|
141
|
-
exports.CarouselContent = CarouselContent;
|
|
142
|
-
CarouselContent.displayName = "CarouselContent";
|
|
143
|
-
var CarouselItem = React.forwardRef(function (_a, ref) {
|
|
144
|
-
var className = _a.className, props = __rest(_a, ["className"]);
|
|
145
|
-
var orientation = useCarousel().orientation;
|
|
146
|
-
return (React.createElement("div", __assign({ ref: ref, role: "group", "aria-roledescription": "slide", className: (0, utils_1.cn)("min-w-0 shrink-0 grow-0 basis-full", orientation === "horizontal" ? "pl-4" : "pt-4", className) }, props)));
|
|
147
|
-
});
|
|
148
|
-
exports.CarouselItem = CarouselItem;
|
|
149
|
-
CarouselItem.displayName = "CarouselItem";
|
|
150
|
-
var CarouselPrevious = React.forwardRef(function (_a, ref) {
|
|
151
|
-
var className = _a.className, _b = _a.variant, variant = _b === void 0 ? "outline" : _b, _c = _a.size, size = _c === void 0 ? "icon" : _c, props = __rest(_a, ["className", "variant", "size"]);
|
|
152
|
-
var _d = useCarousel(), orientation = _d.orientation, scrollPrev = _d.scrollPrev, canScrollPrev = _d.canScrollPrev;
|
|
153
|
-
return (React.createElement(button_1.Button, __assign({ ref: ref, variant: variant, size: size, className: (0, utils_1.cn)("absolute h-8 w-8 rounded-full", orientation === "horizontal"
|
|
154
|
-
? "-left-12 top-1/2 -translate-y-1/2"
|
|
155
|
-
: "-top-12 left-1/2 -translate-x-1/2 rotate-90", className), disabled: !canScrollPrev, onClick: scrollPrev }, props),
|
|
156
|
-
React.createElement(react_icons_1.ArrowLeftIcon, { className: "h-4 w-4" }),
|
|
157
|
-
React.createElement("span", { className: "sr-only" }, "Previous slide")));
|
|
158
|
-
});
|
|
159
|
-
exports.CarouselPrevious = CarouselPrevious;
|
|
160
|
-
CarouselPrevious.displayName = "CarouselPrevious";
|
|
161
|
-
var CarouselNext = React.forwardRef(function (_a, ref) {
|
|
162
|
-
var className = _a.className, _b = _a.variant, variant = _b === void 0 ? "outline" : _b, _c = _a.size, size = _c === void 0 ? "icon" : _c, props = __rest(_a, ["className", "variant", "size"]);
|
|
163
|
-
var _d = useCarousel(), orientation = _d.orientation, scrollNext = _d.scrollNext, canScrollNext = _d.canScrollNext;
|
|
164
|
-
return (React.createElement(button_1.Button, __assign({ ref: ref, variant: variant, size: size, className: (0, utils_1.cn)("absolute h-8 w-8 rounded-full", orientation === "horizontal"
|
|
165
|
-
? "-right-12 top-1/2 -translate-y-1/2"
|
|
166
|
-
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90", className), disabled: !canScrollNext, onClick: scrollNext }, props),
|
|
167
|
-
React.createElement(react_icons_1.ArrowRightIcon, { className: "h-4 w-4" }),
|
|
168
|
-
React.createElement("span", { className: "sr-only" }, "Next slide")));
|
|
169
|
-
});
|
|
170
|
-
exports.CarouselNext = CarouselNext;
|
|
171
|
-
CarouselNext.displayName = "CarouselNext";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
const module = import("./carousel-impl");
|
|
4
|
+
const lazy = (name) => React.lazy(() => module.then((m) => ({ default: m[name] })));
|
|
5
|
+
export const Carousel = lazy("Carousel");
|
|
6
|
+
export const CarouselContent = lazy("CarouselContent");
|
|
7
|
+
export const CarouselItem = lazy("CarouselItem");
|
|
8
|
+
export const CarouselPrevious = lazy("CarouselPrevious");
|
|
9
|
+
export const CarouselNext = lazy("CarouselNext");
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as RechartsPrimitive from "recharts";
|
|
3
|
+
declare const THEMES: {
|
|
4
|
+
readonly light: "";
|
|
5
|
+
readonly dark: ".dark";
|
|
6
|
+
};
|
|
7
|
+
export type ChartConfig = {
|
|
8
|
+
[k in string]: {
|
|
9
|
+
label?: React.ReactNode;
|
|
10
|
+
icon?: React.ComponentType;
|
|
11
|
+
} & ({
|
|
12
|
+
color?: string;
|
|
13
|
+
theme?: never;
|
|
14
|
+
} | {
|
|
15
|
+
color?: never;
|
|
16
|
+
theme: Record<keyof typeof THEMES, string>;
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
declare const ChartContainer: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
20
|
+
config: ChartConfig;
|
|
21
|
+
children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];
|
|
22
|
+
}, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
23
|
+
declare const ChartStyle: ({ id, config }: {
|
|
24
|
+
id: string;
|
|
25
|
+
config: ChartConfig;
|
|
26
|
+
}) => React.JSX.Element | null;
|
|
27
|
+
declare const ChartTooltip: typeof RechartsPrimitive.Tooltip;
|
|
28
|
+
declare const ChartTooltipContent: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
29
|
+
active?: boolean;
|
|
30
|
+
payload?: Array<{
|
|
31
|
+
name?: string;
|
|
32
|
+
dataKey?: string;
|
|
33
|
+
value?: number;
|
|
34
|
+
type?: string;
|
|
35
|
+
color?: string;
|
|
36
|
+
payload?: Record<string, unknown>;
|
|
37
|
+
fill?: string;
|
|
38
|
+
}>;
|
|
39
|
+
label?: string;
|
|
40
|
+
labelFormatter?: (label: string, payload: unknown[]) => React.ReactNode;
|
|
41
|
+
formatter?: (value: unknown, name: string, item: unknown, index: number, payload: unknown) => React.ReactNode;
|
|
42
|
+
hideLabel?: boolean;
|
|
43
|
+
hideIndicator?: boolean;
|
|
44
|
+
indicator?: "line" | "dot" | "dashed";
|
|
45
|
+
nameKey?: string;
|
|
46
|
+
labelKey?: string;
|
|
47
|
+
labelClassName?: string;
|
|
48
|
+
color?: string;
|
|
49
|
+
}, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
50
|
+
declare const ChartLegend: React.MemoExoticComponent<(outsideProps: RechartsPrimitive.LegendProps) => React.ReactPortal | null>;
|
|
51
|
+
declare const ChartLegendContent: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
52
|
+
payload?: Array<{
|
|
53
|
+
value?: string;
|
|
54
|
+
dataKey?: string;
|
|
55
|
+
type?: string;
|
|
56
|
+
color?: string;
|
|
57
|
+
}>;
|
|
58
|
+
verticalAlign?: "top" | "bottom";
|
|
59
|
+
hideIcon?: boolean;
|
|
60
|
+
nameKey?: string;
|
|
61
|
+
}, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
62
|
+
export { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle, };
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import * as React from "react";
|
|
14
|
+
import * as RechartsPrimitive from "recharts";
|
|
15
|
+
import { cn } from "../../lib/utils";
|
|
16
|
+
// Format: { THEME_NAME: CSS_SELECTOR }
|
|
17
|
+
const THEMES = { light: "", dark: ".dark" };
|
|
18
|
+
const ChartContext = React.createContext(null);
|
|
19
|
+
function useChart() {
|
|
20
|
+
const context = React.useContext(ChartContext);
|
|
21
|
+
if (!context) {
|
|
22
|
+
throw new Error("useChart must be used within a <ChartContainer />");
|
|
23
|
+
}
|
|
24
|
+
return context;
|
|
25
|
+
}
|
|
26
|
+
const ChartContainer = React.forwardRef((_a, ref) => {
|
|
27
|
+
var { id, className, children, config } = _a, props = __rest(_a, ["id", "className", "children", "config"]);
|
|
28
|
+
const uniqueId = React.useId();
|
|
29
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
|
|
30
|
+
return (React.createElement(ChartContext.Provider, { value: { config } },
|
|
31
|
+
React.createElement("div", Object.assign({ "data-chart": chartId, ref: ref, className: cn("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", className) }, props),
|
|
32
|
+
React.createElement(ChartStyle, { id: chartId, config: config }),
|
|
33
|
+
React.createElement(RechartsPrimitive.ResponsiveContainer, null, children))));
|
|
34
|
+
});
|
|
35
|
+
ChartContainer.displayName = "Chart";
|
|
36
|
+
const ChartStyle = ({ id, config }) => {
|
|
37
|
+
const colorConfig = Object.entries(config).filter(([, config]) => config.theme || config.color);
|
|
38
|
+
if (!colorConfig.length) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
return (React.createElement("style", { dangerouslySetInnerHTML: {
|
|
42
|
+
__html: Object.entries(THEMES)
|
|
43
|
+
.map(([theme, prefix]) => `
|
|
44
|
+
${prefix} [data-chart=${id}] {
|
|
45
|
+
${colorConfig
|
|
46
|
+
.map(([key, itemConfig]) => {
|
|
47
|
+
var _a;
|
|
48
|
+
const color = ((_a = itemConfig.theme) === null || _a === void 0 ? void 0 : _a[theme]) ||
|
|
49
|
+
itemConfig.color;
|
|
50
|
+
return color ? ` --color-${key}: ${color};` : null;
|
|
51
|
+
})
|
|
52
|
+
.join("\n")}
|
|
53
|
+
}
|
|
54
|
+
`)
|
|
55
|
+
.join("\n"),
|
|
56
|
+
} }));
|
|
57
|
+
};
|
|
58
|
+
const ChartTooltip = RechartsPrimitive.Tooltip;
|
|
59
|
+
const ChartTooltipContent = React.forwardRef(({ active, payload, className, indicator = "dot", hideLabel = false, hideIndicator = false, label, labelFormatter, labelClassName, formatter, color, nameKey, labelKey, }, ref) => {
|
|
60
|
+
const { config } = useChart();
|
|
61
|
+
const tooltipLabel = React.useMemo(() => {
|
|
62
|
+
var _a;
|
|
63
|
+
if (hideLabel || !(payload === null || payload === void 0 ? void 0 : payload.length)) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
const [item] = payload;
|
|
67
|
+
const key = `${labelKey || (item === null || item === void 0 ? void 0 : item.dataKey) || (item === null || item === void 0 ? void 0 : item.name) || "value"}`;
|
|
68
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
69
|
+
const value = !labelKey && typeof label === "string"
|
|
70
|
+
? ((_a = config[label]) === null || _a === void 0 ? void 0 : _a.label) || label
|
|
71
|
+
: itemConfig === null || itemConfig === void 0 ? void 0 : itemConfig.label;
|
|
72
|
+
if (labelFormatter) {
|
|
73
|
+
return (React.createElement("div", { className: cn("font-medium", labelClassName) }, labelFormatter(String(value !== null && value !== void 0 ? value : ""), payload !== null && payload !== void 0 ? payload : [])));
|
|
74
|
+
}
|
|
75
|
+
if (!value) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
return React.createElement("div", { className: cn("font-medium", labelClassName) }, value);
|
|
79
|
+
}, [
|
|
80
|
+
label,
|
|
81
|
+
labelFormatter,
|
|
82
|
+
payload,
|
|
83
|
+
hideLabel,
|
|
84
|
+
labelClassName,
|
|
85
|
+
config,
|
|
86
|
+
labelKey,
|
|
87
|
+
]);
|
|
88
|
+
if (!active || !(payload === null || payload === void 0 ? void 0 : payload.length)) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
92
|
+
return (React.createElement("div", { ref: ref, className: cn("grid min-w-32 items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl", className) },
|
|
93
|
+
!nestLabel ? tooltipLabel : null,
|
|
94
|
+
React.createElement("div", { className: "grid gap-1.5" }, payload
|
|
95
|
+
.filter((item) => item.type !== "none")
|
|
96
|
+
.map((item, index) => {
|
|
97
|
+
var _a;
|
|
98
|
+
const key = `${nameKey || item.name || item.dataKey || "value"}`;
|
|
99
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
100
|
+
const indicatorColor = color || ((_a = item.payload) === null || _a === void 0 ? void 0 : _a.fill) || item.color;
|
|
101
|
+
return (React.createElement("div", { key: item.dataKey, className: cn("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground", indicator === "dot" && "items-center") }, formatter && (item === null || item === void 0 ? void 0 : item.value) !== undefined && item.name ? (formatter(item.value, item.name, item, index, item.payload)) : (React.createElement(React.Fragment, null,
|
|
102
|
+
(itemConfig === null || itemConfig === void 0 ? void 0 : itemConfig.icon) ? (React.createElement(itemConfig.icon, null)) : (!hideIndicator && (React.createElement("div", { className: cn("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]", {
|
|
103
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
104
|
+
"w-1": indicator === "line",
|
|
105
|
+
"w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
|
|
106
|
+
"my-0.5": nestLabel && indicator === "dashed",
|
|
107
|
+
}), style: {
|
|
108
|
+
"--color-bg": indicatorColor,
|
|
109
|
+
"--color-border": indicatorColor,
|
|
110
|
+
} }))),
|
|
111
|
+
React.createElement("div", { className: cn("flex flex-1 justify-between leading-none", nestLabel ? "items-end" : "items-center") },
|
|
112
|
+
React.createElement("div", { className: "grid gap-1.5" },
|
|
113
|
+
nestLabel ? tooltipLabel : null,
|
|
114
|
+
React.createElement("span", { className: "text-muted-foreground" }, (itemConfig === null || itemConfig === void 0 ? void 0 : itemConfig.label) || item.name)),
|
|
115
|
+
item.value && (React.createElement("span", { className: "font-mono font-medium tabular-nums text-foreground" }, item.value.toLocaleString())))))));
|
|
116
|
+
}))));
|
|
117
|
+
});
|
|
118
|
+
ChartTooltipContent.displayName = "ChartTooltip";
|
|
119
|
+
const ChartLegend = RechartsPrimitive.Legend;
|
|
120
|
+
const ChartLegendContent = React.forwardRef(({ className, hideIcon = false, payload, verticalAlign = "bottom", nameKey }, ref) => {
|
|
121
|
+
const { config } = useChart();
|
|
122
|
+
if (!(payload === null || payload === void 0 ? void 0 : payload.length)) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
return (React.createElement("div", { ref: ref, className: cn("flex items-center justify-center gap-4", verticalAlign === "top" ? "pb-3" : "pt-3", className) }, payload
|
|
126
|
+
.filter((item) => item.type !== "none")
|
|
127
|
+
.map((item) => {
|
|
128
|
+
const key = `${nameKey || item.dataKey || "value"}`;
|
|
129
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
130
|
+
return (React.createElement("div", { key: item.value, className: cn("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground") },
|
|
131
|
+
(itemConfig === null || itemConfig === void 0 ? void 0 : itemConfig.icon) && !hideIcon ? (React.createElement(itemConfig.icon, null)) : (React.createElement("div", { className: "h-2 w-2 shrink-0 rounded-[2px]", style: {
|
|
132
|
+
backgroundColor: item.color,
|
|
133
|
+
} })), itemConfig === null || itemConfig === void 0 ? void 0 :
|
|
134
|
+
itemConfig.label));
|
|
135
|
+
})));
|
|
136
|
+
});
|
|
137
|
+
ChartLegendContent.displayName = "ChartLegend";
|
|
138
|
+
// Helper to extract item config from a payload.
|
|
139
|
+
function getPayloadConfigFromPayload(config, payload, key) {
|
|
140
|
+
if (typeof payload !== "object" || payload === null) {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
const payloadPayload = "payload" in payload &&
|
|
144
|
+
typeof payload.payload === "object" &&
|
|
145
|
+
payload.payload !== null
|
|
146
|
+
? payload.payload
|
|
147
|
+
: undefined;
|
|
148
|
+
let configLabelKey = key;
|
|
149
|
+
if (key in payload &&
|
|
150
|
+
typeof payload[key] === "string") {
|
|
151
|
+
configLabelKey = payload[key];
|
|
152
|
+
}
|
|
153
|
+
else if (payloadPayload &&
|
|
154
|
+
key in payloadPayload &&
|
|
155
|
+
typeof payloadPayload[key] === "string") {
|
|
156
|
+
configLabelKey = payloadPayload[key];
|
|
157
|
+
}
|
|
158
|
+
return configLabelKey in config
|
|
159
|
+
? config[configLabelKey]
|
|
160
|
+
: config[key];
|
|
161
|
+
}
|
|
162
|
+
export { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle, };
|
package/components/ui/chart.d.ts
CHANGED
|
@@ -1,62 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
declare const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
[k in string]: {
|
|
9
|
-
label?: React.ReactNode;
|
|
10
|
-
icon?: React.ComponentType;
|
|
11
|
-
} & ({
|
|
12
|
-
color?: string;
|
|
13
|
-
theme?: never;
|
|
14
|
-
} | {
|
|
15
|
-
color?: never;
|
|
16
|
-
theme: Record<keyof typeof THEMES, string>;
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
declare const ChartContainer: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
20
|
-
config: ChartConfig;
|
|
21
|
-
children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];
|
|
22
|
-
}, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
23
|
-
declare const ChartStyle: ({ id, config }: {
|
|
24
|
-
id: string;
|
|
25
|
-
config: ChartConfig;
|
|
26
|
-
}) => React.JSX.Element | null;
|
|
27
|
-
declare const ChartTooltip: typeof RechartsPrimitive.Tooltip;
|
|
28
|
-
declare const ChartTooltipContent: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
29
|
-
active?: boolean;
|
|
30
|
-
payload?: Array<{
|
|
31
|
-
name?: string;
|
|
32
|
-
dataKey?: string;
|
|
33
|
-
value?: number;
|
|
34
|
-
type?: string;
|
|
35
|
-
color?: string;
|
|
36
|
-
payload?: Record<string, unknown>;
|
|
37
|
-
fill?: string;
|
|
38
|
-
}>;
|
|
39
|
-
label?: string;
|
|
40
|
-
labelFormatter?: (label: string, payload: unknown[]) => React.ReactNode;
|
|
41
|
-
formatter?: (value: unknown, name: string, item: unknown, index: number, payload: unknown) => React.ReactNode;
|
|
42
|
-
hideLabel?: boolean;
|
|
43
|
-
hideIndicator?: boolean;
|
|
44
|
-
indicator?: "line" | "dot" | "dashed";
|
|
45
|
-
nameKey?: string;
|
|
46
|
-
labelKey?: string;
|
|
47
|
-
labelClassName?: string;
|
|
48
|
-
color?: string;
|
|
49
|
-
}, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
50
|
-
declare const ChartLegend: React.MemoExoticComponent<(outsideProps: RechartsPrimitive.LegendProps) => React.ReactPortal | null>;
|
|
51
|
-
declare const ChartLegendContent: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
52
|
-
payload?: Array<{
|
|
53
|
-
value?: string;
|
|
54
|
-
dataKey?: string;
|
|
55
|
-
type?: string;
|
|
56
|
-
color?: string;
|
|
57
|
-
}>;
|
|
58
|
-
verticalAlign?: "top" | "bottom";
|
|
59
|
-
hideIcon?: boolean;
|
|
60
|
-
nameKey?: string;
|
|
61
|
-
}, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
62
|
-
export { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle, };
|
|
1
|
+
export type { ChartConfig } from "./chart-impl";
|
|
2
|
+
export declare const ChartContainer: typeof import("./chart-impl")["ChartContainer"];
|
|
3
|
+
export declare const ChartTooltip: typeof import("./chart-impl")["ChartTooltip"];
|
|
4
|
+
export declare const ChartTooltipContent: typeof import("./chart-impl")["ChartTooltipContent"];
|
|
5
|
+
export declare const ChartLegend: typeof import("./chart-impl")["ChartLegend"];
|
|
6
|
+
export declare const ChartLegendContent: typeof import("./chart-impl")["ChartLegendContent"];
|
|
7
|
+
export declare const ChartStyle: typeof import("./chart-impl")["ChartStyle"];
|