@enya-learning/nova 0.4.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/Readme.md +418 -0
- package/changelog.md +44 -0
- package/components.json +23 -0
- package/dist/chunks/button-npy7isi3nsvlhf86.js +81 -0
- package/dist/chunks/button-npy7isi3nsvlhf86.js.map +1 -0
- package/dist/chunks/rolldown-runtime-fifbipqm1abz4ydz.js +30 -0
- package/dist/chunks/utils-kyb5nny4y41y7hd8.js +10 -0
- package/dist/chunks/utils-kyb5nny4y41y7hd8.js.map +1 -0
- package/dist/chunks/vendor-base-ui-efqwzv4oinwg1f0d.js +16049 -0
- package/dist/chunks/vendor-base-ui-efqwzv4oinwg1f0d.js.map +1 -0
- package/dist/chunks/vendor-styling-eeiy57tyznmxsfky.js +1744 -0
- package/dist/chunks/vendor-styling-eeiy57tyznmxsfky.js.map +1 -0
- package/dist/components/button.js +6 -0
- package/dist/components/enya-logo.js +191 -0
- package/dist/components/enya-logo.js.map +1 -0
- package/dist/index.js +23499 -0
- package/dist/index.js.map +1 -0
- package/dist/src/components/accordion/accordion.d.ts +6 -0
- package/dist/src/components/accordion/index.d.ts +1 -0
- package/dist/src/components/alert/alert.d.ts +10 -0
- package/dist/src/components/alert/index.d.ts +1 -0
- package/dist/src/components/alert-dialog/alert-dialog.d.ts +18 -0
- package/dist/src/components/alert-dialog/index.d.ts +1 -0
- package/dist/src/components/aspect-ratio/aspect-ratio.d.ts +4 -0
- package/dist/src/components/aspect-ratio/index.d.ts +1 -0
- package/dist/src/components/avatar/avatar.d.ts +11 -0
- package/dist/src/components/avatar/index.d.ts +1 -0
- package/dist/src/components/badge/badge.d.ts +7 -0
- package/dist/src/components/badge/index.d.ts +1 -0
- package/dist/src/components/breadcrumb/breadcrumb.d.ts +10 -0
- package/dist/src/components/breadcrumb/index.d.ts +1 -0
- package/dist/src/components/button/button.d.ts +8 -0
- package/dist/src/components/button/index.d.ts +1 -0
- package/dist/src/components/button-group/button-group.d.ts +10 -0
- package/dist/src/components/button-group/index.d.ts +1 -0
- package/dist/src/components/calendar/calendar.d.ts +10 -0
- package/dist/src/components/calendar/index.d.ts +1 -0
- package/dist/src/components/card/card.d.ts +11 -0
- package/dist/src/components/card/index.d.ts +1 -0
- package/dist/src/components/carousel/carousel.d.ts +28 -0
- package/dist/src/components/carousel/index.d.ts +1 -0
- package/dist/src/components/chart/chart.d.ts +44 -0
- package/dist/src/components/chart/index.d.ts +1 -0
- package/dist/src/components/checkbox/checkbox.d.ts +3 -0
- package/dist/src/components/checkbox/index.d.ts +1 -0
- package/dist/src/components/collapsible/collapsible.d.ts +5 -0
- package/dist/src/components/collapsible/index.d.ts +1 -0
- package/dist/src/components/combobox/combobox.d.ts +24 -0
- package/dist/src/components/combobox/index.d.ts +1 -0
- package/dist/src/components/command/command.d.ts +19 -0
- package/dist/src/components/command/index.d.ts +1 -0
- package/dist/src/components/context-menu/context-menu.d.ts +29 -0
- package/dist/src/components/context-menu/index.d.ts +1 -0
- package/dist/src/components/dialog/dialog.d.ts +17 -0
- package/dist/src/components/dialog/index.d.ts +1 -0
- package/dist/src/components/direction/direction.d.ts +1 -0
- package/dist/src/components/direction/index.d.ts +1 -0
- package/dist/src/components/drawer/drawer.d.ts +13 -0
- package/dist/src/components/drawer/index.d.ts +1 -0
- package/dist/src/components/dropdown-menu/dropdown-menu.d.ts +29 -0
- package/dist/src/components/dropdown-menu/index.d.ts +1 -0
- package/dist/src/components/empty/empty.d.ts +11 -0
- package/dist/src/components/empty/index.d.ts +1 -0
- package/dist/src/components/enya-logo/enya-logo.d.ts +121 -0
- package/dist/src/components/enya-logo/index.d.ts +1 -0
- package/dist/src/components/field/field.d.ts +24 -0
- package/dist/src/components/field/index.d.ts +1 -0
- package/dist/src/components/hover-card/hover-card.d.ts +5 -0
- package/dist/src/components/hover-card/index.d.ts +1 -0
- package/dist/src/components/input/index.d.ts +1 -0
- package/dist/src/components/input/input.d.ts +3 -0
- package/dist/src/components/input-group/index.d.ts +1 -0
- package/dist/src/components/input-group/input-group.d.ts +18 -0
- package/dist/src/components/input-otp/index.d.ts +1 -0
- package/dist/src/components/input-otp/input-otp.d.ts +11 -0
- package/dist/src/components/item/index.d.ts +1 -0
- package/dist/src/components/item/item.d.ts +22 -0
- package/dist/src/components/kbd/index.d.ts +1 -0
- package/dist/src/components/kbd/kbd.d.ts +3 -0
- package/dist/src/components/label/index.d.ts +1 -0
- package/dist/src/components/label/label.d.ts +3 -0
- package/dist/src/components/menubar/index.d.ts +1 -0
- package/dist/src/components/menubar/menubar.d.ts +29 -0
- package/dist/src/components/native-select/index.d.ts +1 -0
- package/dist/src/components/native-select/native-select.d.ts +8 -0
- package/dist/src/components/navigation-menu/index.d.ts +1 -0
- package/dist/src/components/navigation-menu/navigation-menu.d.ts +11 -0
- package/dist/src/components/pagination/index.d.ts +1 -0
- package/dist/src/components/pagination/pagination.d.ts +17 -0
- package/dist/src/components/popover/index.d.ts +1 -0
- package/dist/src/components/popover/popover.d.ts +9 -0
- package/dist/src/components/progress/index.d.ts +1 -0
- package/dist/src/components/progress/progress.d.ts +7 -0
- package/dist/src/components/radio-group/index.d.ts +1 -0
- package/dist/src/components/radio-group/radio-group.d.ts +5 -0
- package/dist/src/components/resizable/index.d.ts +1 -0
- package/dist/src/components/resizable/resizable.d.ts +7 -0
- package/dist/src/components/scroll-area/index.d.ts +1 -0
- package/dist/src/components/scroll-area/scroll-area.d.ts +4 -0
- package/dist/src/components/select/index.d.ts +1 -0
- package/dist/src/components/select/select.d.ts +15 -0
- package/dist/src/components/separator/index.d.ts +1 -0
- package/dist/src/components/separator/separator.d.ts +3 -0
- package/dist/src/components/sheet/index.d.ts +1 -0
- package/dist/src/components/sheet/sheet.d.ts +14 -0
- package/dist/src/components/sidebar/index.d.ts +1 -0
- package/dist/src/components/sidebar/sidebar.d.ts +63 -0
- package/dist/src/components/skeleton/index.d.ts +1 -0
- package/dist/src/components/skeleton/skeleton.d.ts +2 -0
- package/dist/src/components/slider/index.d.ts +1 -0
- package/dist/src/components/slider/slider.d.ts +3 -0
- package/dist/src/components/sonner/index.d.ts +1 -0
- package/dist/src/components/sonner/sonner.d.ts +3 -0
- package/dist/src/components/spinner/index.d.ts +1 -0
- package/dist/src/components/spinner/spinner.d.ts +2 -0
- package/dist/src/components/switch/index.d.ts +1 -0
- package/dist/src/components/switch/switch.d.ts +5 -0
- package/dist/src/components/table/index.d.ts +1 -0
- package/dist/src/components/table/table.d.ts +10 -0
- package/dist/src/components/tabs/index.d.ts +1 -0
- package/dist/src/components/tabs/tabs.d.ts +10 -0
- package/dist/src/components/textarea/index.d.ts +1 -0
- package/dist/src/components/textarea/textarea.d.ts +3 -0
- package/dist/src/components/toggle/index.d.ts +1 -0
- package/dist/src/components/toggle/toggle.d.ts +8 -0
- package/dist/src/components/toggle-group/index.d.ts +1 -0
- package/dist/src/components/toggle-group/toggle-group.d.ts +10 -0
- package/dist/src/components/tooltip/index.d.ts +1 -0
- package/dist/src/components/tooltip/tooltip.d.ts +6 -0
- package/dist/src/hooks/use-mobile.d.ts +1 -0
- package/dist/src/index.d.ts +57 -0
- package/dist/src/lib/utils.d.ts +2 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/styles/nova-binding.css +290 -0
- package/dist/styles/nova.css +58 -0
- package/dist/styles/theme-nova.css +201 -0
- package/dist/styles/typography.css +215 -0
- package/dist/utils.js +5 -0
- package/eslint.config.js +30 -0
- package/package.json +94 -0
- package/plopfile.mjs +49 -0
- package/src/components/.gitkeep +0 -0
- package/src/components/accordion/accordion.mdx +83 -0
- package/src/components/accordion/accordion.tsx +81 -0
- package/src/components/accordion/index.ts +1 -0
- package/src/components/alert/alert.tsx +76 -0
- package/src/components/alert/index.ts +1 -0
- package/src/components/alert-dialog/alert-dialog.tsx +187 -0
- package/src/components/alert-dialog/index.ts +1 -0
- package/src/components/aspect-ratio/aspect-ratio.tsx +22 -0
- package/src/components/aspect-ratio/index.ts +1 -0
- package/src/components/avatar/avatar.tsx +107 -0
- package/src/components/avatar/index.ts +1 -0
- package/src/components/badge/badge.tsx +52 -0
- package/src/components/badge/index.ts +1 -0
- package/src/components/breadcrumb/breadcrumb.tsx +122 -0
- package/src/components/breadcrumb/index.ts +1 -0
- package/src/components/button/button.mdx +255 -0
- package/src/components/button/button.tsx +59 -0
- package/src/components/button/index.ts +1 -0
- package/src/components/button-group/button-group.tsx +87 -0
- package/src/components/button-group/index.ts +1 -0
- package/src/components/calendar/calendar.tsx +228 -0
- package/src/components/calendar/index.ts +1 -0
- package/src/components/card/card.tsx +100 -0
- package/src/components/card/index.ts +1 -0
- package/src/components/carousel/carousel.tsx +243 -0
- package/src/components/carousel/index.ts +1 -0
- package/src/components/chart/chart.tsx +371 -0
- package/src/components/chart/index.ts +1 -0
- package/src/components/checkbox/checkbox.tsx +28 -0
- package/src/components/checkbox/index.ts +1 -0
- package/src/components/collapsible/collapsible.tsx +19 -0
- package/src/components/collapsible/index.ts +1 -0
- package/src/components/combobox/combobox.tsx +298 -0
- package/src/components/combobox/index.ts +1 -0
- package/src/components/command/command.tsx +193 -0
- package/src/components/command/index.ts +1 -0
- package/src/components/context-menu/context-menu.tsx +272 -0
- package/src/components/context-menu/index.ts +1 -0
- package/src/components/dialog/dialog.tsx +157 -0
- package/src/components/dialog/index.ts +1 -0
- package/src/components/direction/direction.tsx +4 -0
- package/src/components/direction/index.ts +1 -0
- package/src/components/drawer/drawer.tsx +134 -0
- package/src/components/drawer/index.ts +1 -0
- package/src/components/dropdown-menu/dropdown-menu.tsx +270 -0
- package/src/components/dropdown-menu/index.ts +1 -0
- package/src/components/empty/empty.tsx +104 -0
- package/src/components/empty/index.ts +1 -0
- package/src/components/enya-logo/enya-logo.mdx +174 -0
- package/src/components/enya-logo/enya-logo.tsx +383 -0
- package/src/components/enya-logo/index.ts +1 -0
- package/src/components/field/field.tsx +236 -0
- package/src/components/field/index.ts +1 -0
- package/src/components/hover-card/hover-card.tsx +51 -0
- package/src/components/hover-card/index.ts +1 -0
- package/src/components/input/index.ts +1 -0
- package/src/components/input/input.tsx +20 -0
- package/src/components/input-group/index.ts +1 -0
- package/src/components/input-group/input-group.tsx +157 -0
- package/src/components/input-otp/index.ts +1 -0
- package/src/components/input-otp/input-otp.tsx +84 -0
- package/src/components/item/index.ts +1 -0
- package/src/components/item/item.tsx +201 -0
- package/src/components/kbd/index.ts +1 -0
- package/src/components/kbd/kbd.tsx +26 -0
- package/src/components/label/index.ts +1 -0
- package/src/components/label/label.tsx +20 -0
- package/src/components/menubar/index.ts +1 -0
- package/src/components/menubar/menubar.tsx +281 -0
- package/src/components/native-select/index.ts +1 -0
- package/src/components/native-select/native-select.tsx +65 -0
- package/src/components/navigation-menu/index.ts +1 -0
- package/src/components/navigation-menu/navigation-menu.tsx +171 -0
- package/src/components/pagination/index.ts +1 -0
- package/src/components/pagination/pagination.tsx +133 -0
- package/src/components/popover/index.ts +1 -0
- package/src/components/popover/popover.tsx +88 -0
- package/src/components/progress/index.ts +1 -0
- package/src/components/progress/progress.tsx +83 -0
- package/src/components/radio-group/index.ts +1 -0
- package/src/components/radio-group/radio-group.tsx +36 -0
- package/src/components/resizable/index.ts +1 -0
- package/src/components/resizable/resizable.tsx +50 -0
- package/src/components/scroll-area/index.ts +1 -0
- package/src/components/scroll-area/scroll-area.tsx +53 -0
- package/src/components/select/index.ts +1 -0
- package/src/components/select/select.tsx +205 -0
- package/src/components/separator/index.ts +1 -0
- package/src/components/separator/separator.tsx +23 -0
- package/src/components/sheet/index.ts +1 -0
- package/src/components/sheet/sheet.tsx +137 -0
- package/src/components/sidebar/index.ts +1 -0
- package/src/components/sidebar/sidebar.tsx +722 -0
- package/src/components/skeleton/index.ts +1 -0
- package/src/components/skeleton/skeleton.tsx +13 -0
- package/src/components/slider/index.ts +1 -0
- package/src/components/slider/slider.tsx +52 -0
- package/src/components/sonner/index.ts +1 -0
- package/src/components/sonner/sonner.tsx +45 -0
- package/src/components/spinner/index.ts +1 -0
- package/src/components/spinner/spinner.tsx +15 -0
- package/src/components/switch/index.ts +1 -0
- package/src/components/switch/switch.tsx +30 -0
- package/src/components/table/index.ts +1 -0
- package/src/components/table/table.tsx +116 -0
- package/src/components/tabs/index.ts +1 -0
- package/src/components/tabs/tabs.tsx +80 -0
- package/src/components/textarea/index.ts +1 -0
- package/src/components/textarea/textarea.tsx +18 -0
- package/src/components/toggle/index.ts +1 -0
- package/src/components/toggle/toggle.tsx +45 -0
- package/src/components/toggle-group/index.ts +1 -0
- package/src/components/toggle-group/toggle-group.tsx +87 -0
- package/src/components/tooltip/index.ts +1 -0
- package/src/components/tooltip/tooltip.tsx +64 -0
- package/src/eslint/index.js +13 -0
- package/src/eslint/no-primitive-colors.js +158 -0
- package/src/hooks/use-mobile.ts +21 -0
- package/src/index.ts +58 -0
- package/src/lib/.gitkeep +0 -0
- package/src/lib/utils.ts +6 -0
- package/src/styles/globals.css +77 -0
- package/src/styles/nova-binding.css +290 -0
- package/src/styles/nova.css +58 -0
- package/src/styles/theme-nova.css +201 -0
- package/src/styles/typography.css +215 -0
- package/src/utils/index.ts +1 -0
- package/templates/component/component.tsx.hbs +16 -0
- package/templates/component/index.ts.hbs +1 -0
- package/templates/component/stories.tsx.hbs +13 -0
- package/tsconfig.json +18 -0
- package/tsconfig.lint.json +14 -0
- package/vite.config.ts +101 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../lib/utils"
|
|
4
|
+
|
|
5
|
+
function Card({
|
|
6
|
+
className,
|
|
7
|
+
size = "default",
|
|
8
|
+
...props
|
|
9
|
+
}: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
|
|
10
|
+
return (
|
|
11
|
+
<div
|
|
12
|
+
data-slot="card"
|
|
13
|
+
data-size={size}
|
|
14
|
+
className={cn(
|
|
15
|
+
"group/card flex flex-col gap-6 overflow-hidden rounded-2xl bg-card py-6 text-sm text-card-foreground ring-1 ring-foreground/10 has-[>img:first-child]:pt-0 data-[size=sm]:gap-4 data-[size=sm]:py-4 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
|
|
16
|
+
className
|
|
17
|
+
)}
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
24
|
+
return (
|
|
25
|
+
<div
|
|
26
|
+
data-slot="card-header"
|
|
27
|
+
className={cn(
|
|
28
|
+
"group/card-header @container/card-header grid auto-rows-min items-start gap-2 rounded-t-xl px-6 group-data-[size=sm]/card:px-4 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-6 group-data-[size=sm]/card:[.border-b]:pb-4",
|
|
29
|
+
className
|
|
30
|
+
)}
|
|
31
|
+
{...props}
|
|
32
|
+
/>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
data-slot="card-title"
|
|
40
|
+
className={cn("font-heading text-base font-medium", className)}
|
|
41
|
+
{...props}
|
|
42
|
+
/>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
|
47
|
+
return (
|
|
48
|
+
<div
|
|
49
|
+
data-slot="card-description"
|
|
50
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
51
|
+
{...props}
|
|
52
|
+
/>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
|
57
|
+
return (
|
|
58
|
+
<div
|
|
59
|
+
data-slot="card-action"
|
|
60
|
+
className={cn(
|
|
61
|
+
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
|
|
62
|
+
className
|
|
63
|
+
)}
|
|
64
|
+
{...props}
|
|
65
|
+
/>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
70
|
+
return (
|
|
71
|
+
<div
|
|
72
|
+
data-slot="card-content"
|
|
73
|
+
className={cn("px-6 group-data-[size=sm]/card:px-4", className)}
|
|
74
|
+
{...props}
|
|
75
|
+
/>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
80
|
+
return (
|
|
81
|
+
<div
|
|
82
|
+
data-slot="card-footer"
|
|
83
|
+
className={cn(
|
|
84
|
+
"flex items-center rounded-b-xl px-6 group-data-[size=sm]/card:px-4 [.border-t]:pt-6 group-data-[size=sm]/card:[.border-t]:pt-4",
|
|
85
|
+
className
|
|
86
|
+
)}
|
|
87
|
+
{...props}
|
|
88
|
+
/>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export {
|
|
93
|
+
Card,
|
|
94
|
+
CardHeader,
|
|
95
|
+
CardFooter,
|
|
96
|
+
CardTitle,
|
|
97
|
+
CardAction,
|
|
98
|
+
CardDescription,
|
|
99
|
+
CardContent,
|
|
100
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./card"
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import useEmblaCarousel, {
|
|
5
|
+
type UseEmblaCarouselType,
|
|
6
|
+
} from "embla-carousel-react"
|
|
7
|
+
|
|
8
|
+
import { cn } from "../../lib/utils"
|
|
9
|
+
import { Button } from "../button"
|
|
10
|
+
import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
|
|
11
|
+
|
|
12
|
+
type CarouselApi = UseEmblaCarouselType[1]
|
|
13
|
+
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
|
|
14
|
+
type CarouselOptions = UseCarouselParameters[0]
|
|
15
|
+
type CarouselPlugin = UseCarouselParameters[1]
|
|
16
|
+
|
|
17
|
+
type CarouselProps = {
|
|
18
|
+
opts?: CarouselOptions
|
|
19
|
+
plugins?: CarouselPlugin
|
|
20
|
+
orientation?: "horizontal" | "vertical"
|
|
21
|
+
setApi?: (api: CarouselApi) => void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type CarouselContextProps = {
|
|
25
|
+
carouselRef: ReturnType<typeof useEmblaCarousel>[0]
|
|
26
|
+
api: ReturnType<typeof useEmblaCarousel>[1]
|
|
27
|
+
scrollPrev: () => void
|
|
28
|
+
scrollNext: () => void
|
|
29
|
+
canScrollPrev: boolean
|
|
30
|
+
canScrollNext: boolean
|
|
31
|
+
} & CarouselProps
|
|
32
|
+
|
|
33
|
+
const CarouselContext = React.createContext<CarouselContextProps | null>(null)
|
|
34
|
+
|
|
35
|
+
function useCarousel() {
|
|
36
|
+
const context = React.useContext(CarouselContext)
|
|
37
|
+
|
|
38
|
+
if (!context) {
|
|
39
|
+
throw new Error("useCarousel must be used within a <Carousel />")
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return context
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function Carousel({
|
|
46
|
+
orientation = "horizontal",
|
|
47
|
+
opts,
|
|
48
|
+
setApi,
|
|
49
|
+
plugins,
|
|
50
|
+
className,
|
|
51
|
+
children,
|
|
52
|
+
...props
|
|
53
|
+
}: React.ComponentProps<"div"> & CarouselProps) {
|
|
54
|
+
const [carouselRef, api] = useEmblaCarousel(
|
|
55
|
+
{
|
|
56
|
+
...opts,
|
|
57
|
+
axis: orientation === "horizontal" ? "x" : "y",
|
|
58
|
+
},
|
|
59
|
+
plugins
|
|
60
|
+
)
|
|
61
|
+
const [canScrollPrev, setCanScrollPrev] = React.useState(false)
|
|
62
|
+
const [canScrollNext, setCanScrollNext] = React.useState(false)
|
|
63
|
+
|
|
64
|
+
const onSelect = React.useCallback((api: CarouselApi) => {
|
|
65
|
+
if (!api) return
|
|
66
|
+
setCanScrollPrev(api.canScrollPrev())
|
|
67
|
+
setCanScrollNext(api.canScrollNext())
|
|
68
|
+
}, [])
|
|
69
|
+
|
|
70
|
+
const scrollPrev = React.useCallback(() => {
|
|
71
|
+
api?.scrollPrev()
|
|
72
|
+
}, [api])
|
|
73
|
+
|
|
74
|
+
const scrollNext = React.useCallback(() => {
|
|
75
|
+
api?.scrollNext()
|
|
76
|
+
}, [api])
|
|
77
|
+
|
|
78
|
+
const handleKeyDown = React.useCallback(
|
|
79
|
+
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
80
|
+
if (event.key === "ArrowLeft") {
|
|
81
|
+
event.preventDefault()
|
|
82
|
+
scrollPrev()
|
|
83
|
+
} else if (event.key === "ArrowRight") {
|
|
84
|
+
event.preventDefault()
|
|
85
|
+
scrollNext()
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
[scrollPrev, scrollNext]
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
React.useEffect(() => {
|
|
92
|
+
if (!api || !setApi) return
|
|
93
|
+
setApi(api)
|
|
94
|
+
}, [api, setApi])
|
|
95
|
+
|
|
96
|
+
React.useEffect(() => {
|
|
97
|
+
if (!api) return
|
|
98
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
99
|
+
onSelect(api)
|
|
100
|
+
api.on("reInit", onSelect)
|
|
101
|
+
api.on("select", onSelect)
|
|
102
|
+
|
|
103
|
+
return () => {
|
|
104
|
+
api?.off("select", onSelect)
|
|
105
|
+
}
|
|
106
|
+
}, [api, onSelect])
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<CarouselContext.Provider
|
|
110
|
+
value={{
|
|
111
|
+
carouselRef,
|
|
112
|
+
api: api,
|
|
113
|
+
opts,
|
|
114
|
+
orientation:
|
|
115
|
+
orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
|
|
116
|
+
scrollPrev,
|
|
117
|
+
scrollNext,
|
|
118
|
+
canScrollPrev,
|
|
119
|
+
canScrollNext,
|
|
120
|
+
}}
|
|
121
|
+
>
|
|
122
|
+
<div
|
|
123
|
+
onKeyDownCapture={handleKeyDown}
|
|
124
|
+
className={cn("relative", className)}
|
|
125
|
+
role="region"
|
|
126
|
+
aria-roledescription="carousel"
|
|
127
|
+
data-slot="carousel"
|
|
128
|
+
{...props}
|
|
129
|
+
>
|
|
130
|
+
{children}
|
|
131
|
+
</div>
|
|
132
|
+
</CarouselContext.Provider>
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function CarouselContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
137
|
+
const { carouselRef, orientation } = useCarousel()
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<div
|
|
141
|
+
ref={carouselRef}
|
|
142
|
+
className="overflow-hidden"
|
|
143
|
+
data-slot="carousel-content"
|
|
144
|
+
>
|
|
145
|
+
<div
|
|
146
|
+
className={cn(
|
|
147
|
+
"flex",
|
|
148
|
+
orientation === "horizontal" ? "-ms-4" : "-mt-4 flex-col",
|
|
149
|
+
className
|
|
150
|
+
)}
|
|
151
|
+
{...props}
|
|
152
|
+
/>
|
|
153
|
+
</div>
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function CarouselItem({ className, ...props }: React.ComponentProps<"div">) {
|
|
158
|
+
const { orientation } = useCarousel()
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<div
|
|
162
|
+
role="group"
|
|
163
|
+
aria-roledescription="slide"
|
|
164
|
+
data-slot="carousel-item"
|
|
165
|
+
className={cn(
|
|
166
|
+
"min-w-0 shrink-0 grow-0 basis-full",
|
|
167
|
+
orientation === "horizontal" ? "ps-4" : "pt-4",
|
|
168
|
+
className
|
|
169
|
+
)}
|
|
170
|
+
{...props}
|
|
171
|
+
/>
|
|
172
|
+
)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function CarouselPrevious({
|
|
176
|
+
className,
|
|
177
|
+
variant = "outline",
|
|
178
|
+
size = "icon-sm",
|
|
179
|
+
...props
|
|
180
|
+
}: React.ComponentProps<typeof Button>) {
|
|
181
|
+
const { orientation, scrollPrev, canScrollPrev } = useCarousel()
|
|
182
|
+
|
|
183
|
+
return (
|
|
184
|
+
<Button
|
|
185
|
+
data-slot="carousel-previous"
|
|
186
|
+
variant={variant}
|
|
187
|
+
size={size}
|
|
188
|
+
className={cn(
|
|
189
|
+
"absolute touch-manipulation rounded-full",
|
|
190
|
+
orientation === "horizontal"
|
|
191
|
+
? "-start-12 top-1/2 -translate-y-1/2"
|
|
192
|
+
: "start-1/2 -top-12 -translate-x-1/2 rotate-90 rtl:translate-x-1/2",
|
|
193
|
+
className
|
|
194
|
+
)}
|
|
195
|
+
disabled={!canScrollPrev}
|
|
196
|
+
onClick={scrollPrev}
|
|
197
|
+
{...props}
|
|
198
|
+
>
|
|
199
|
+
<ChevronLeftIcon className="rtl:rotate-180" />
|
|
200
|
+
<span className="sr-only">Previous slide</span>
|
|
201
|
+
</Button>
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function CarouselNext({
|
|
206
|
+
className,
|
|
207
|
+
variant = "outline",
|
|
208
|
+
size = "icon-sm",
|
|
209
|
+
...props
|
|
210
|
+
}: React.ComponentProps<typeof Button>) {
|
|
211
|
+
const { orientation, scrollNext, canScrollNext } = useCarousel()
|
|
212
|
+
|
|
213
|
+
return (
|
|
214
|
+
<Button
|
|
215
|
+
data-slot="carousel-next"
|
|
216
|
+
variant={variant}
|
|
217
|
+
size={size}
|
|
218
|
+
className={cn(
|
|
219
|
+
"absolute touch-manipulation rounded-full",
|
|
220
|
+
orientation === "horizontal"
|
|
221
|
+
? "-end-12 top-1/2 -translate-y-1/2"
|
|
222
|
+
: "start-1/2 -bottom-12 -translate-x-1/2 rotate-90 rtl:translate-x-1/2",
|
|
223
|
+
className
|
|
224
|
+
)}
|
|
225
|
+
disabled={!canScrollNext}
|
|
226
|
+
onClick={scrollNext}
|
|
227
|
+
{...props}
|
|
228
|
+
>
|
|
229
|
+
<ChevronRightIcon className="rtl:rotate-180" />
|
|
230
|
+
<span className="sr-only">Next slide</span>
|
|
231
|
+
</Button>
|
|
232
|
+
)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export {
|
|
236
|
+
type CarouselApi,
|
|
237
|
+
Carousel,
|
|
238
|
+
CarouselContent,
|
|
239
|
+
CarouselItem,
|
|
240
|
+
CarouselPrevious,
|
|
241
|
+
CarouselNext,
|
|
242
|
+
useCarousel,
|
|
243
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./carousel"
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as RechartsPrimitive from "recharts"
|
|
3
|
+
import type { TooltipValueType } from "recharts"
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../lib/utils"
|
|
6
|
+
|
|
7
|
+
// Format: { THEME_NAME: CSS_SELECTOR }
|
|
8
|
+
const THEMES = { light: "", dark: ".dark" } as const
|
|
9
|
+
|
|
10
|
+
const INITIAL_DIMENSION = { width: 320, height: 200 } as const
|
|
11
|
+
type TooltipNameType = number | string
|
|
12
|
+
|
|
13
|
+
export type ChartConfig = Record<
|
|
14
|
+
string,
|
|
15
|
+
{
|
|
16
|
+
label?: React.ReactNode
|
|
17
|
+
icon?: React.ComponentType
|
|
18
|
+
} & (
|
|
19
|
+
| { color?: string; theme?: never }
|
|
20
|
+
| { color?: never; theme: Record<keyof typeof THEMES, string> }
|
|
21
|
+
)
|
|
22
|
+
>
|
|
23
|
+
|
|
24
|
+
type ChartContextProps = {
|
|
25
|
+
config: ChartConfig
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const ChartContext = React.createContext<ChartContextProps | null>(null)
|
|
29
|
+
|
|
30
|
+
function useChart() {
|
|
31
|
+
const context = React.useContext(ChartContext)
|
|
32
|
+
|
|
33
|
+
if (!context) {
|
|
34
|
+
throw new Error("useChart must be used within a <ChartContainer />")
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return context
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function ChartContainer({
|
|
41
|
+
id,
|
|
42
|
+
className,
|
|
43
|
+
children,
|
|
44
|
+
config,
|
|
45
|
+
initialDimension = INITIAL_DIMENSION,
|
|
46
|
+
...props
|
|
47
|
+
}: React.ComponentProps<"div"> & {
|
|
48
|
+
config: ChartConfig
|
|
49
|
+
children: React.ComponentProps<
|
|
50
|
+
typeof RechartsPrimitive.ResponsiveContainer
|
|
51
|
+
>["children"]
|
|
52
|
+
initialDimension?: {
|
|
53
|
+
width: number
|
|
54
|
+
height: number
|
|
55
|
+
}
|
|
56
|
+
}) {
|
|
57
|
+
const uniqueId = React.useId()
|
|
58
|
+
const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}`
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<ChartContext.Provider value={{ config }}>
|
|
62
|
+
<div
|
|
63
|
+
data-slot="chart"
|
|
64
|
+
data-chart={chartId}
|
|
65
|
+
className={cn(
|
|
66
|
+
"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-hidden [&_.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]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
|
|
67
|
+
className
|
|
68
|
+
)}
|
|
69
|
+
{...props}
|
|
70
|
+
>
|
|
71
|
+
<ChartStyle id={chartId} config={config} />
|
|
72
|
+
<RechartsPrimitive.ResponsiveContainer
|
|
73
|
+
initialDimension={initialDimension}
|
|
74
|
+
>
|
|
75
|
+
{children}
|
|
76
|
+
</RechartsPrimitive.ResponsiveContainer>
|
|
77
|
+
</div>
|
|
78
|
+
</ChartContext.Provider>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
|
83
|
+
const colorConfig = Object.entries(config).filter(
|
|
84
|
+
([, config]) => config.theme ?? config.color
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
if (!colorConfig.length) {
|
|
88
|
+
return null
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<style
|
|
93
|
+
dangerouslySetInnerHTML={{
|
|
94
|
+
__html: Object.entries(THEMES)
|
|
95
|
+
.map(
|
|
96
|
+
([theme, prefix]) => `
|
|
97
|
+
${prefix} [data-chart=${id}] {
|
|
98
|
+
${colorConfig
|
|
99
|
+
.map(([key, itemConfig]) => {
|
|
100
|
+
const color =
|
|
101
|
+
itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ??
|
|
102
|
+
itemConfig.color
|
|
103
|
+
return color ? ` --color-${key}: ${color};` : null
|
|
104
|
+
})
|
|
105
|
+
.join("\n")}
|
|
106
|
+
}
|
|
107
|
+
`
|
|
108
|
+
)
|
|
109
|
+
.join("\n"),
|
|
110
|
+
}}
|
|
111
|
+
/>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const ChartTooltip = RechartsPrimitive.Tooltip
|
|
116
|
+
|
|
117
|
+
function ChartTooltipContent({
|
|
118
|
+
active,
|
|
119
|
+
payload,
|
|
120
|
+
className,
|
|
121
|
+
indicator = "dot",
|
|
122
|
+
hideLabel = false,
|
|
123
|
+
hideIndicator = false,
|
|
124
|
+
label,
|
|
125
|
+
labelFormatter,
|
|
126
|
+
labelClassName,
|
|
127
|
+
formatter,
|
|
128
|
+
color,
|
|
129
|
+
nameKey,
|
|
130
|
+
labelKey,
|
|
131
|
+
}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
|
|
132
|
+
React.ComponentProps<"div"> & {
|
|
133
|
+
hideLabel?: boolean
|
|
134
|
+
hideIndicator?: boolean
|
|
135
|
+
indicator?: "line" | "dot" | "dashed"
|
|
136
|
+
nameKey?: string
|
|
137
|
+
labelKey?: string
|
|
138
|
+
} & Omit<
|
|
139
|
+
RechartsPrimitive.DefaultTooltipContentProps<
|
|
140
|
+
TooltipValueType,
|
|
141
|
+
TooltipNameType
|
|
142
|
+
>,
|
|
143
|
+
"accessibilityLayer"
|
|
144
|
+
>) {
|
|
145
|
+
const { config } = useChart()
|
|
146
|
+
|
|
147
|
+
const tooltipLabel = React.useMemo(() => {
|
|
148
|
+
if (hideLabel || !payload?.length) {
|
|
149
|
+
return null
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const [item] = payload
|
|
153
|
+
const key = `${labelKey ?? item?.dataKey ?? item?.name ?? "value"}`
|
|
154
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
155
|
+
const value =
|
|
156
|
+
!labelKey && typeof label === "string"
|
|
157
|
+
? (config[label]?.label ?? label)
|
|
158
|
+
: itemConfig?.label
|
|
159
|
+
|
|
160
|
+
if (labelFormatter) {
|
|
161
|
+
return (
|
|
162
|
+
<div className={cn("font-medium", labelClassName)}>
|
|
163
|
+
{labelFormatter(value, payload)}
|
|
164
|
+
</div>
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (!value) {
|
|
169
|
+
return null
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return <div className={cn("font-medium", labelClassName)}>{value}</div>
|
|
173
|
+
}, [
|
|
174
|
+
label,
|
|
175
|
+
labelFormatter,
|
|
176
|
+
payload,
|
|
177
|
+
hideLabel,
|
|
178
|
+
labelClassName,
|
|
179
|
+
config,
|
|
180
|
+
labelKey,
|
|
181
|
+
])
|
|
182
|
+
|
|
183
|
+
if (!active || !payload?.length) {
|
|
184
|
+
return null
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const nestLabel = payload.length === 1 && indicator !== "dot"
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<div
|
|
191
|
+
className={cn(
|
|
192
|
+
"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",
|
|
193
|
+
className
|
|
194
|
+
)}
|
|
195
|
+
>
|
|
196
|
+
{!nestLabel ? tooltipLabel : null}
|
|
197
|
+
<div className="grid gap-1.5">
|
|
198
|
+
{payload
|
|
199
|
+
.filter((item) => item.type !== "none")
|
|
200
|
+
.map((item, index) => {
|
|
201
|
+
const key = `${nameKey ?? item.name ?? item.dataKey ?? "value"}`
|
|
202
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
203
|
+
const indicatorColor = color ?? item.payload?.fill ?? item.color
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
<div
|
|
207
|
+
key={index}
|
|
208
|
+
className={cn(
|
|
209
|
+
"flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
|
|
210
|
+
indicator === "dot" && "items-center"
|
|
211
|
+
)}
|
|
212
|
+
>
|
|
213
|
+
{formatter && item?.value !== undefined && item.name ? (
|
|
214
|
+
formatter(item.value, item.name, item, index, item.payload)
|
|
215
|
+
) : (
|
|
216
|
+
<>
|
|
217
|
+
{itemConfig?.icon ? (
|
|
218
|
+
<itemConfig.icon />
|
|
219
|
+
) : (
|
|
220
|
+
!hideIndicator && (
|
|
221
|
+
<div
|
|
222
|
+
className={cn(
|
|
223
|
+
"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
|
|
224
|
+
{
|
|
225
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
226
|
+
"w-1": indicator === "line",
|
|
227
|
+
"w-0 border-[1.5px] border-dashed bg-transparent":
|
|
228
|
+
indicator === "dashed",
|
|
229
|
+
"my-0.5": nestLabel && indicator === "dashed",
|
|
230
|
+
}
|
|
231
|
+
)}
|
|
232
|
+
style={
|
|
233
|
+
{
|
|
234
|
+
"--color-bg": indicatorColor,
|
|
235
|
+
"--color-border": indicatorColor,
|
|
236
|
+
} as React.CSSProperties
|
|
237
|
+
}
|
|
238
|
+
/>
|
|
239
|
+
)
|
|
240
|
+
)}
|
|
241
|
+
<div
|
|
242
|
+
className={cn(
|
|
243
|
+
"flex flex-1 justify-between leading-none",
|
|
244
|
+
nestLabel ? "items-end" : "items-center"
|
|
245
|
+
)}
|
|
246
|
+
>
|
|
247
|
+
<div className="grid gap-1.5">
|
|
248
|
+
{nestLabel ? tooltipLabel : null}
|
|
249
|
+
<span className="text-muted-foreground">
|
|
250
|
+
{itemConfig?.label ?? item.name}
|
|
251
|
+
</span>
|
|
252
|
+
</div>
|
|
253
|
+
{item.value != null && (
|
|
254
|
+
<span className="font-mono font-medium text-foreground tabular-nums">
|
|
255
|
+
{typeof item.value === "number"
|
|
256
|
+
? item.value.toLocaleString()
|
|
257
|
+
: String(item.value)}
|
|
258
|
+
</span>
|
|
259
|
+
)}
|
|
260
|
+
</div>
|
|
261
|
+
</>
|
|
262
|
+
)}
|
|
263
|
+
</div>
|
|
264
|
+
)
|
|
265
|
+
})}
|
|
266
|
+
</div>
|
|
267
|
+
</div>
|
|
268
|
+
)
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const ChartLegend = RechartsPrimitive.Legend
|
|
272
|
+
|
|
273
|
+
function ChartLegendContent({
|
|
274
|
+
className,
|
|
275
|
+
hideIcon = false,
|
|
276
|
+
payload,
|
|
277
|
+
verticalAlign = "bottom",
|
|
278
|
+
nameKey,
|
|
279
|
+
}: React.ComponentProps<"div"> & {
|
|
280
|
+
hideIcon?: boolean
|
|
281
|
+
nameKey?: string
|
|
282
|
+
} & RechartsPrimitive.DefaultLegendContentProps) {
|
|
283
|
+
const { config } = useChart()
|
|
284
|
+
|
|
285
|
+
if (!payload?.length) {
|
|
286
|
+
return null
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return (
|
|
290
|
+
<div
|
|
291
|
+
className={cn(
|
|
292
|
+
"flex items-center justify-center gap-4",
|
|
293
|
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
|
294
|
+
className
|
|
295
|
+
)}
|
|
296
|
+
>
|
|
297
|
+
{payload
|
|
298
|
+
.filter((item) => item.type !== "none")
|
|
299
|
+
.map((item, index) => {
|
|
300
|
+
const key = `${nameKey ?? item.dataKey ?? "value"}`
|
|
301
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
302
|
+
|
|
303
|
+
return (
|
|
304
|
+
<div
|
|
305
|
+
key={index}
|
|
306
|
+
className={cn(
|
|
307
|
+
"flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"
|
|
308
|
+
)}
|
|
309
|
+
>
|
|
310
|
+
{itemConfig?.icon && !hideIcon ? (
|
|
311
|
+
<itemConfig.icon />
|
|
312
|
+
) : (
|
|
313
|
+
<div
|
|
314
|
+
className="h-2 w-2 shrink-0 rounded-[2px]"
|
|
315
|
+
style={{
|
|
316
|
+
backgroundColor: item.color,
|
|
317
|
+
}}
|
|
318
|
+
/>
|
|
319
|
+
)}
|
|
320
|
+
{itemConfig?.label}
|
|
321
|
+
</div>
|
|
322
|
+
)
|
|
323
|
+
})}
|
|
324
|
+
</div>
|
|
325
|
+
)
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function getPayloadConfigFromPayload(
|
|
329
|
+
config: ChartConfig,
|
|
330
|
+
payload: unknown,
|
|
331
|
+
key: string
|
|
332
|
+
) {
|
|
333
|
+
if (typeof payload !== "object" || payload === null) {
|
|
334
|
+
return undefined
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const payloadPayload =
|
|
338
|
+
"payload" in payload &&
|
|
339
|
+
typeof payload.payload === "object" &&
|
|
340
|
+
payload.payload !== null
|
|
341
|
+
? payload.payload
|
|
342
|
+
: undefined
|
|
343
|
+
|
|
344
|
+
let configLabelKey: string = key
|
|
345
|
+
|
|
346
|
+
if (
|
|
347
|
+
key in payload &&
|
|
348
|
+
typeof payload[key as keyof typeof payload] === "string"
|
|
349
|
+
) {
|
|
350
|
+
configLabelKey = payload[key as keyof typeof payload] as string
|
|
351
|
+
} else if (
|
|
352
|
+
payloadPayload &&
|
|
353
|
+
key in payloadPayload &&
|
|
354
|
+
typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
|
|
355
|
+
) {
|
|
356
|
+
configLabelKey = payloadPayload[
|
|
357
|
+
key as keyof typeof payloadPayload
|
|
358
|
+
] as string
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return configLabelKey in config ? config[configLabelKey] : config[key]
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export {
|
|
365
|
+
ChartContainer,
|
|
366
|
+
ChartTooltip,
|
|
367
|
+
ChartTooltipContent,
|
|
368
|
+
ChartLegend,
|
|
369
|
+
ChartLegendContent,
|
|
370
|
+
ChartStyle,
|
|
371
|
+
}
|