@codefast/ui 0.3.10 → 0.3.11-canary.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/CHANGELOG.md +19 -0
- package/README.md +277 -167
- package/dist/components/accordion.cjs +5 -5
- package/dist/components/accordion.d.ts +4 -4
- package/dist/components/accordion.js +5 -5
- package/dist/components/alert-dialog.cjs +9 -9
- package/dist/components/alert-dialog.d.ts +11 -11
- package/dist/components/alert-dialog.js +9 -9
- package/dist/components/alert.cjs +5 -5
- package/dist/components/alert.d.ts +5 -5
- package/dist/components/alert.js +5 -5
- package/dist/components/aspect-ratio.d.ts +2 -2
- package/dist/components/avatar.cjs +3 -3
- package/dist/components/avatar.d.ts +2 -2
- package/dist/components/avatar.js +3 -3
- package/dist/components/badge.cjs +7 -7
- package/dist/components/badge.d.ts +3 -3
- package/dist/components/badge.js +7 -7
- package/dist/components/breadcrumb.cjs +6 -8
- package/dist/components/breadcrumb.d.ts +8 -8
- package/dist/components/breadcrumb.js +6 -8
- package/dist/components/button-group.cjs +8 -8
- package/dist/components/button-group.d.ts +5 -5
- package/dist/components/button-group.js +8 -8
- package/dist/components/button.cjs +17 -17
- package/dist/components/button.d.ts +6 -6
- package/dist/components/button.js +17 -17
- package/dist/components/calendar.cjs +35 -35
- package/dist/components/calendar.d.ts +5 -5
- package/dist/components/calendar.js +35 -35
- package/dist/components/card.cjs +7 -7
- package/dist/components/card.d.ts +8 -8
- package/dist/components/card.js +7 -7
- package/dist/components/carousel.cjs +20 -20
- package/dist/components/carousel.d.ts +10 -10
- package/dist/components/carousel.js +20 -20
- package/dist/components/chart.cjs +42 -42
- package/dist/components/chart.d.ts +12 -11
- package/dist/components/chart.js +42 -42
- package/dist/components/checkbox-cards.cjs +2 -2
- package/dist/components/checkbox-cards.d.ts +2 -2
- package/dist/components/checkbox-cards.js +2 -2
- package/dist/components/checkbox-group.cjs +2 -2
- package/dist/components/checkbox-group.d.ts +2 -2
- package/dist/components/checkbox-group.js +2 -2
- package/dist/components/checkbox.cjs +1 -1
- package/dist/components/checkbox.d.ts +2 -2
- package/dist/components/checkbox.js +1 -1
- package/dist/components/collapsible.d.ts +2 -2
- package/dist/components/command.cjs +10 -10
- package/dist/components/command.d.ts +4 -4
- package/dist/components/command.js +10 -10
- package/dist/components/context-menu.cjs +10 -10
- package/dist/components/context-menu.d.ts +4 -4
- package/dist/components/context-menu.js +10 -10
- package/dist/components/dialog.cjs +12 -12
- package/dist/components/dialog.d.ts +10 -10
- package/dist/components/dialog.js +12 -12
- package/dist/components/drawer.cjs +9 -9
- package/dist/components/drawer.d.ts +9 -9
- package/dist/components/drawer.js +9 -9
- package/dist/components/dropdown-menu.cjs +10 -10
- package/dist/components/dropdown-menu.d.ts +4 -4
- package/dist/components/dropdown-menu.js +10 -10
- package/dist/components/empty.cjs +10 -10
- package/dist/components/empty.d.ts +9 -9
- package/dist/components/empty.js +10 -10
- package/dist/components/field.cjs +17 -17
- package/dist/components/field.d.ts +14 -14
- package/dist/components/field.js +17 -17
- package/dist/components/form.cjs +8 -8
- package/dist/components/form.d.ts +10 -10
- package/dist/components/form.js +8 -8
- package/dist/components/hover-card.cjs +3 -3
- package/dist/components/hover-card.d.ts +2 -2
- package/dist/components/hover-card.js +3 -3
- package/dist/components/input-group.cjs +20 -20
- package/dist/components/input-group.d.ts +15 -15
- package/dist/components/input-group.js +20 -20
- package/dist/components/input-number.cjs +7 -7
- package/dist/components/input-number.d.ts +2 -2
- package/dist/components/input-number.js +7 -7
- package/dist/components/input-otp.cjs +4 -4
- package/dist/components/input-otp.d.ts +6 -6
- package/dist/components/input-otp.js +4 -4
- package/dist/components/input-password.cjs +6 -6
- package/dist/components/input-password.d.ts +3 -3
- package/dist/components/input-password.js +6 -6
- package/dist/components/input-search.cjs +4 -4
- package/dist/components/input-search.d.ts +3 -3
- package/dist/components/input-search.js +4 -4
- package/dist/components/input.cjs +1 -1
- package/dist/components/input.d.ts +2 -2
- package/dist/components/input.js +1 -1
- package/dist/components/item.cjs +23 -23
- package/dist/components/item.d.ts +12 -12
- package/dist/components/item.js +23 -23
- package/dist/components/kbd.cjs +2 -2
- package/dist/components/kbd.d.ts +3 -3
- package/dist/components/kbd.js +2 -2
- package/dist/components/label.cjs +1 -1
- package/dist/components/label.d.ts +2 -2
- package/dist/components/label.js +1 -1
- package/dist/components/menubar.cjs +13 -13
- package/dist/components/menubar.d.ts +4 -4
- package/dist/components/menubar.js +13 -13
- package/dist/components/native-select.cjs +2 -2
- package/dist/components/native-select.d.ts +4 -4
- package/dist/components/native-select.js +2 -2
- package/dist/components/navigation-menu.cjs +10 -10
- package/dist/components/navigation-menu.d.ts +2 -2
- package/dist/components/navigation-menu.js +10 -10
- package/dist/components/pagination.cjs +6 -6
- package/dist/components/pagination.d.ts +10 -10
- package/dist/components/pagination.js +6 -6
- package/dist/components/popover.cjs +3 -3
- package/dist/components/popover.d.ts +3 -3
- package/dist/components/popover.js +3 -3
- package/dist/components/progress-circle.cjs +22 -22
- package/dist/components/progress-circle.d.ts +5 -5
- package/dist/components/progress-circle.js +22 -22
- package/dist/components/progress.cjs +2 -2
- package/dist/components/progress.d.ts +2 -2
- package/dist/components/progress.js +2 -2
- package/dist/components/radio-cards.cjs +3 -3
- package/dist/components/radio-cards.d.ts +2 -2
- package/dist/components/radio-cards.js +3 -3
- package/dist/components/radio-group.cjs +3 -3
- package/dist/components/radio-group.d.ts +2 -2
- package/dist/components/radio-group.js +3 -3
- package/dist/components/radio.cjs +1 -1
- package/dist/components/radio.d.ts +2 -2
- package/dist/components/radio.js +1 -1
- package/dist/components/resizable.cjs +3 -3
- package/dist/components/resizable.d.ts +2 -2
- package/dist/components/resizable.js +3 -3
- package/dist/components/scroll-area.cjs +31 -31
- package/dist/components/scroll-area.d.ts +5 -5
- package/dist/components/scroll-area.js +31 -31
- package/dist/components/select.cjs +9 -9
- package/dist/components/select.d.ts +5 -5
- package/dist/components/select.js +9 -9
- package/dist/components/separator.cjs +9 -9
- package/dist/components/separator.d.ts +5 -5
- package/dist/components/separator.js +9 -9
- package/dist/components/sheet.cjs +17 -17
- package/dist/components/sheet.d.ts +9 -9
- package/dist/components/sheet.js +17 -17
- package/dist/components/sidebar.cjs +65 -65
- package/dist/components/sidebar.d.ts +31 -31
- package/dist/components/sidebar.js +65 -65
- package/dist/components/skeleton.cjs +1 -1
- package/dist/components/skeleton.d.ts +2 -2
- package/dist/components/skeleton.js +1 -1
- package/dist/components/slider.cjs +4 -4
- package/dist/components/slider.d.ts +2 -2
- package/dist/components/slider.js +4 -4
- package/dist/components/sonner.cjs +4 -4
- package/dist/components/sonner.d.ts +3 -3
- package/dist/components/sonner.js +4 -4
- package/dist/components/spinner.cjs +5 -5
- package/dist/components/spinner.d.ts +2 -2
- package/dist/components/spinner.js +5 -5
- package/dist/components/switch.cjs +2 -2
- package/dist/components/switch.d.ts +2 -2
- package/dist/components/switch.js +2 -2
- package/dist/components/table.cjs +8 -8
- package/dist/components/table.d.ts +9 -9
- package/dist/components/table.js +8 -8
- package/dist/components/tabs.cjs +4 -4
- package/dist/components/tabs.d.ts +2 -2
- package/dist/components/tabs.js +4 -4
- package/dist/components/textarea.cjs +1 -1
- package/dist/components/textarea.d.ts +2 -2
- package/dist/components/textarea.js +1 -1
- package/dist/components/toggle-group.cjs +5 -5
- package/dist/components/toggle-group.d.ts +4 -4
- package/dist/components/toggle-group.js +5 -5
- package/dist/components/toggle.cjs +8 -8
- package/dist/components/toggle.d.ts +3 -3
- package/dist/components/toggle.js +8 -8
- package/dist/components/tooltip.cjs +2 -2
- package/dist/components/tooltip.d.ts +3 -3
- package/dist/components/tooltip.js +2 -2
- package/dist/css/preset.css +4 -4
- package/dist/css/style.css +3 -3
- package/dist/hooks/use-copy-to-clipboard.cjs +1 -1
- package/dist/hooks/use-copy-to-clipboard.d.ts +1 -1
- package/dist/hooks/use-copy-to-clipboard.js +1 -1
- package/dist/hooks/use-media-query.cjs +3 -3
- package/dist/hooks/use-media-query.js +3 -3
- package/dist/hooks/use-mutation-observer.d.ts +1 -1
- package/dist/hooks/use-pagination.cjs +1 -1
- package/dist/hooks/use-pagination.js +1 -1
- package/dist/index.d.ts +130 -130
- package/dist/primitives/checkbox-group.cjs +3 -3
- package/dist/primitives/checkbox-group.d.ts +11 -11
- package/dist/primitives/checkbox-group.js +3 -3
- package/dist/primitives/input-number.cjs +46 -46
- package/dist/primitives/input-number.d.ts +8 -8
- package/dist/primitives/input-number.js +46 -46
- package/dist/primitives/input.cjs +7 -7
- package/dist/primitives/input.d.ts +4 -4
- package/dist/primitives/input.js +7 -7
- package/dist/primitives/progress-circle.cjs +8 -8
- package/dist/primitives/progress-circle.d.ts +7 -7
- package/dist/primitives/progress-circle.js +8 -8
- package/package.json +38 -42
package/dist/components/card.js
CHANGED
|
@@ -2,21 +2,21 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { cn } from "@codefast/tailwind-variants";
|
|
3
3
|
function Card({ className, ...props }) {
|
|
4
4
|
return /*#__PURE__*/ jsx("div", {
|
|
5
|
-
className: cn(
|
|
5
|
+
className: cn("flex flex-col gap-6 overflow-auto rounded-xl border bg-card py-6 text-card-foreground shadow-sm", className),
|
|
6
6
|
"data-slot": "card",
|
|
7
7
|
...props
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
10
|
function CardHeader({ className, ...props }) {
|
|
11
11
|
return /*#__PURE__*/ jsx("div", {
|
|
12
|
-
className: cn(
|
|
12
|
+
className: cn("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-[data-slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6", className),
|
|
13
13
|
"data-slot": "card-header",
|
|
14
14
|
...props
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
function CardTitle({ children, className, ...props }) {
|
|
18
18
|
return /*#__PURE__*/ jsx("div", {
|
|
19
|
-
className: cn(
|
|
19
|
+
className: cn("leading-none font-semibold", className),
|
|
20
20
|
"data-slot": "card-title",
|
|
21
21
|
...props,
|
|
22
22
|
children: children
|
|
@@ -24,28 +24,28 @@ function CardTitle({ children, className, ...props }) {
|
|
|
24
24
|
}
|
|
25
25
|
function CardDescription({ className, ...props }) {
|
|
26
26
|
return /*#__PURE__*/ jsx("div", {
|
|
27
|
-
className: cn(
|
|
27
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
28
28
|
"data-slot": "card-description",
|
|
29
29
|
...props
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
function CardContent({ className, ...props }) {
|
|
33
33
|
return /*#__PURE__*/ jsx("div", {
|
|
34
|
-
className: cn(
|
|
34
|
+
className: cn("px-6", className),
|
|
35
35
|
"data-slot": "card-content",
|
|
36
36
|
...props
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
function CardFooter({ className, ...props }) {
|
|
40
40
|
return /*#__PURE__*/ jsx("div", {
|
|
41
|
-
className: cn(
|
|
41
|
+
className: cn("flex items-center px-6 [.border-t]:pt-6", className),
|
|
42
42
|
"data-slot": "card-footer",
|
|
43
43
|
...props
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
function CardAction({ className, ...props }) {
|
|
47
47
|
return /*#__PURE__*/ jsx("div", {
|
|
48
|
-
className: cn(
|
|
48
|
+
className: cn("col-start-2 row-span-2 row-start-1 self-start justify-self-end", className),
|
|
49
49
|
"data-slot": "card-action",
|
|
50
50
|
...props
|
|
51
51
|
});
|
|
@@ -49,13 +49,13 @@ var external_embla_carousel_react_default = /*#__PURE__*/ __webpack_require__.n(
|
|
|
49
49
|
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
50
50
|
const external_react_namespaceObject = require("react");
|
|
51
51
|
const external_button_cjs_namespaceObject = require("./button.cjs");
|
|
52
|
-
const CAROUSEL_NAME =
|
|
52
|
+
const CAROUSEL_NAME = "Carousel";
|
|
53
53
|
const [createCarouselContext, createCarouselScope] = (0, react_context_namespaceObject.createContextScope)(CAROUSEL_NAME);
|
|
54
54
|
const [CarouselContextProvider, useCarouselContext] = createCarouselContext(CAROUSEL_NAME);
|
|
55
55
|
function Carousel({ __scopeCarousel, children, className, opts, orientation, plugins, setApi, ...props }) {
|
|
56
56
|
const [carouselRef, api] = external_embla_carousel_react_default()({
|
|
57
57
|
...opts,
|
|
58
|
-
axis:
|
|
58
|
+
axis: "vertical" === orientation ? "y" : "x"
|
|
59
59
|
}, plugins);
|
|
60
60
|
const [canScrollPrevious, setCanScrollPrevious] = (0, external_react_namespaceObject.useState)(false);
|
|
61
61
|
const [canScrollNext, setCanScrollNext] = (0, external_react_namespaceObject.useState)(false);
|
|
@@ -75,10 +75,10 @@ function Carousel({ __scopeCarousel, children, className, opts, orientation, plu
|
|
|
75
75
|
api
|
|
76
76
|
]);
|
|
77
77
|
const handleKeyDown = (0, external_react_namespaceObject.useCallback)((event)=>{
|
|
78
|
-
if (
|
|
78
|
+
if ("ArrowLeft" === event.key) {
|
|
79
79
|
event.preventDefault();
|
|
80
80
|
scrollPrevious();
|
|
81
|
-
} else if (
|
|
81
|
+
} else if ("ArrowRight" === event.key) {
|
|
82
82
|
event.preventDefault();
|
|
83
83
|
scrollNext();
|
|
84
84
|
}
|
|
@@ -98,10 +98,10 @@ function Carousel({ __scopeCarousel, children, className, opts, orientation, plu
|
|
|
98
98
|
queueMicrotask(()=>{
|
|
99
99
|
onSelect(api);
|
|
100
100
|
});
|
|
101
|
-
api.on(
|
|
102
|
-
api.on(
|
|
101
|
+
api.on("reInit", onSelect);
|
|
102
|
+
api.on("select", onSelect);
|
|
103
103
|
return ()=>{
|
|
104
|
-
api.off(
|
|
104
|
+
api.off("select", onSelect);
|
|
105
105
|
};
|
|
106
106
|
}, [
|
|
107
107
|
api,
|
|
@@ -113,12 +113,12 @@ function Carousel({ __scopeCarousel, children, className, opts, orientation, plu
|
|
|
113
113
|
canScrollPrev: canScrollPrevious,
|
|
114
114
|
carouselRef: carouselRef,
|
|
115
115
|
opts: opts,
|
|
116
|
-
orientation: orientation ?? (opts?.axis ===
|
|
116
|
+
orientation: orientation ?? (opts?.axis === "y" ? "vertical" : "horizontal"),
|
|
117
117
|
scope: __scopeCarousel,
|
|
118
118
|
scrollNext: scrollNext,
|
|
119
119
|
scrollPrev: scrollPrevious,
|
|
120
120
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
121
|
-
className: (0, tailwind_variants_namespaceObject.cn)(
|
|
121
|
+
className: (0, tailwind_variants_namespaceObject.cn)("relative", className),
|
|
122
122
|
"data-slot": "carousel",
|
|
123
123
|
onKeyDownCapture: handleKeyDown,
|
|
124
124
|
...props,
|
|
@@ -126,36 +126,36 @@ function Carousel({ __scopeCarousel, children, className, opts, orientation, plu
|
|
|
126
126
|
})
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
|
-
const CAROUSEL_CONTENT_NAME =
|
|
129
|
+
const CAROUSEL_CONTENT_NAME = "CarouselContent";
|
|
130
130
|
function CarouselContent({ __scopeCarousel, className, classNames, ...props }) {
|
|
131
131
|
const { carouselRef, orientation } = useCarouselContext(CAROUSEL_CONTENT_NAME, __scopeCarousel);
|
|
132
132
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
133
133
|
ref: carouselRef,
|
|
134
|
-
className: (0, tailwind_variants_namespaceObject.cn)(
|
|
134
|
+
className: (0, tailwind_variants_namespaceObject.cn)("overflow-hidden", classNames?.wrapper),
|
|
135
135
|
"data-slot": "carousel-content",
|
|
136
136
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
137
|
-
className: (0, tailwind_variants_namespaceObject.cn)(
|
|
137
|
+
className: (0, tailwind_variants_namespaceObject.cn)("flex", "horizontal" === orientation ? "-ml-4" : "-mt-4 flex-col", classNames?.content, className),
|
|
138
138
|
...props
|
|
139
139
|
})
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
|
-
const CAROUSEL_ITEM_NAME =
|
|
142
|
+
const CAROUSEL_ITEM_NAME = "CarouselItem";
|
|
143
143
|
function CarouselItem({ __scopeCarousel, className, ...props }) {
|
|
144
144
|
const { orientation } = useCarouselContext(CAROUSEL_ITEM_NAME, __scopeCarousel);
|
|
145
145
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
146
146
|
"aria-roledescription": "slide",
|
|
147
|
-
className: (0, tailwind_variants_namespaceObject.cn)(
|
|
147
|
+
className: (0, tailwind_variants_namespaceObject.cn)("min-w-0 shrink-0 grow-0 basis-full", "horizontal" === orientation ? "pl-4" : "pt-4", className),
|
|
148
148
|
"data-slot": "carousel-item",
|
|
149
149
|
role: "group",
|
|
150
150
|
...props
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
|
-
const CAROUSEL_PREVIOUS_NAME =
|
|
154
|
-
function CarouselPrevious({ __scopeCarousel, className, size =
|
|
153
|
+
const CAROUSEL_PREVIOUS_NAME = "CarouselPrevious";
|
|
154
|
+
function CarouselPrevious({ __scopeCarousel, className, size = "icon", variant = "outline", ...props }) {
|
|
155
155
|
const { canScrollPrev, orientation, scrollPrev } = useCarouselContext(CAROUSEL_PREVIOUS_NAME, __scopeCarousel);
|
|
156
156
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_button_cjs_namespaceObject.Button, {
|
|
157
157
|
"aria-label": "Previous slide",
|
|
158
|
-
className: (0, tailwind_variants_namespaceObject.cn)(
|
|
158
|
+
className: (0, tailwind_variants_namespaceObject.cn)("absolute size-8 shadow-none", "horizontal" === orientation ? "top-1/2 -left-12 -translate-y-1/2" : "-top-12 left-1/2 -translate-x-1/2 rotate-90", className),
|
|
159
159
|
"data-slot": "carousel-previous",
|
|
160
160
|
disabled: !canScrollPrev,
|
|
161
161
|
size: size,
|
|
@@ -171,12 +171,12 @@ function CarouselPrevious({ __scopeCarousel, className, size = 'icon', variant =
|
|
|
171
171
|
]
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
|
-
const CAROUSEL_NEXT_NAME =
|
|
175
|
-
function CarouselNext({ __scopeCarousel, className, size =
|
|
174
|
+
const CAROUSEL_NEXT_NAME = "CarouselNext";
|
|
175
|
+
function CarouselNext({ __scopeCarousel, className, size = "icon", variant = "outline", ...props }) {
|
|
176
176
|
const { canScrollNext, orientation, scrollNext } = useCarouselContext(CAROUSEL_NEXT_NAME, __scopeCarousel);
|
|
177
177
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_button_cjs_namespaceObject.Button, {
|
|
178
178
|
"aria-label": "Next slide",
|
|
179
|
-
className: (0, tailwind_variants_namespaceObject.cn)(
|
|
179
|
+
className: (0, tailwind_variants_namespaceObject.cn)("absolute size-8 shadow-none", "horizontal" === orientation ? "top-1/2 -right-12 -translate-y-1/2" : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90", className),
|
|
180
180
|
"data-slot": "carousel-next",
|
|
181
181
|
disabled: !canScrollNext,
|
|
182
182
|
size: size,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Scope } from
|
|
2
|
-
import type { UseEmblaCarouselType } from
|
|
3
|
-
import type { ComponentProps, JSX } from
|
|
4
|
-
import useEmblaCarousel from
|
|
5
|
-
import { Button } from
|
|
1
|
+
import type { Scope } from "@radix-ui/react-context";
|
|
2
|
+
import type { UseEmblaCarouselType } from "embla-carousel-react";
|
|
3
|
+
import type { ComponentProps, JSX } from "react";
|
|
4
|
+
import useEmblaCarousel from "embla-carousel-react";
|
|
5
|
+
import { Button } from "./button";
|
|
6
6
|
type ScopedProps<P> = P & {
|
|
7
7
|
__scopeCarousel?: Scope;
|
|
8
8
|
};
|
|
@@ -13,25 +13,25 @@ type CarouselOptions = UseCarouselParameters[0];
|
|
|
13
13
|
type CarouselPlugin = UseCarouselParameters[1];
|
|
14
14
|
interface BaseCarouselProps {
|
|
15
15
|
opts?: CarouselOptions;
|
|
16
|
-
orientation?:
|
|
16
|
+
orientation?: "horizontal" | "vertical";
|
|
17
17
|
plugins?: CarouselPlugin;
|
|
18
18
|
setApi?: (api: CarouselApi) => void;
|
|
19
19
|
}
|
|
20
|
-
interface CarouselProps extends BaseCarouselProps, ComponentProps<
|
|
20
|
+
interface CarouselProps extends BaseCarouselProps, ComponentProps<"div"> {
|
|
21
21
|
}
|
|
22
22
|
declare function Carousel({ __scopeCarousel, children, className, opts, orientation, plugins, setApi, ...props }: ScopedProps<CarouselProps>): JSX.Element;
|
|
23
|
-
interface CarouselContentProps extends ComponentProps<
|
|
23
|
+
interface CarouselContentProps extends ComponentProps<"div"> {
|
|
24
24
|
classNames?: {
|
|
25
25
|
content?: string;
|
|
26
26
|
wrapper?: string;
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
declare function CarouselContent({ __scopeCarousel, className, classNames, ...props }: ScopedProps<CarouselContentProps>): JSX.Element;
|
|
30
|
-
type CarouselItemProps = ComponentProps<
|
|
30
|
+
type CarouselItemProps = ComponentProps<"div">;
|
|
31
31
|
declare function CarouselItem({ __scopeCarousel, className, ...props }: ScopedProps<CarouselItemProps>): JSX.Element;
|
|
32
32
|
type CarouselPreviousProps = ComponentProps<typeof Button>;
|
|
33
33
|
declare function CarouselPrevious({ __scopeCarousel, className, size, variant, ...props }: ScopedProps<CarouselPreviousProps>): JSX.Element;
|
|
34
34
|
type CarouselNextProps = ComponentProps<typeof Button>;
|
|
35
35
|
declare function CarouselNext({ __scopeCarousel, className, size, variant, ...props }: ScopedProps<CarouselNextProps>): JSX.Element;
|
|
36
36
|
export type { CarouselApi, CarouselContentProps, CarouselItemProps, CarouselNextProps, CarouselPreviousProps, CarouselProps, };
|
|
37
|
-
export { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, createCarouselScope };
|
|
37
|
+
export { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, createCarouselScope, };
|
|
@@ -6,13 +6,13 @@ import embla_carousel_react from "embla-carousel-react";
|
|
|
6
6
|
import { ArrowLeftIcon, ArrowRightIcon } from "lucide-react";
|
|
7
7
|
import { useCallback, useEffect, useState } from "react";
|
|
8
8
|
import { Button } from "./button.js";
|
|
9
|
-
const CAROUSEL_NAME =
|
|
9
|
+
const CAROUSEL_NAME = "Carousel";
|
|
10
10
|
const [createCarouselContext, createCarouselScope] = createContextScope(CAROUSEL_NAME);
|
|
11
11
|
const [CarouselContextProvider, useCarouselContext] = createCarouselContext(CAROUSEL_NAME);
|
|
12
12
|
function Carousel({ __scopeCarousel, children, className, opts, orientation, plugins, setApi, ...props }) {
|
|
13
13
|
const [carouselRef, api] = embla_carousel_react({
|
|
14
14
|
...opts,
|
|
15
|
-
axis:
|
|
15
|
+
axis: "vertical" === orientation ? "y" : "x"
|
|
16
16
|
}, plugins);
|
|
17
17
|
const [canScrollPrevious, setCanScrollPrevious] = useState(false);
|
|
18
18
|
const [canScrollNext, setCanScrollNext] = useState(false);
|
|
@@ -32,10 +32,10 @@ function Carousel({ __scopeCarousel, children, className, opts, orientation, plu
|
|
|
32
32
|
api
|
|
33
33
|
]);
|
|
34
34
|
const handleKeyDown = useCallback((event)=>{
|
|
35
|
-
if (
|
|
35
|
+
if ("ArrowLeft" === event.key) {
|
|
36
36
|
event.preventDefault();
|
|
37
37
|
scrollPrevious();
|
|
38
|
-
} else if (
|
|
38
|
+
} else if ("ArrowRight" === event.key) {
|
|
39
39
|
event.preventDefault();
|
|
40
40
|
scrollNext();
|
|
41
41
|
}
|
|
@@ -55,10 +55,10 @@ function Carousel({ __scopeCarousel, children, className, opts, orientation, plu
|
|
|
55
55
|
queueMicrotask(()=>{
|
|
56
56
|
onSelect(api);
|
|
57
57
|
});
|
|
58
|
-
api.on(
|
|
59
|
-
api.on(
|
|
58
|
+
api.on("reInit", onSelect);
|
|
59
|
+
api.on("select", onSelect);
|
|
60
60
|
return ()=>{
|
|
61
|
-
api.off(
|
|
61
|
+
api.off("select", onSelect);
|
|
62
62
|
};
|
|
63
63
|
}, [
|
|
64
64
|
api,
|
|
@@ -70,12 +70,12 @@ function Carousel({ __scopeCarousel, children, className, opts, orientation, plu
|
|
|
70
70
|
canScrollPrev: canScrollPrevious,
|
|
71
71
|
carouselRef: carouselRef,
|
|
72
72
|
opts: opts,
|
|
73
|
-
orientation: orientation ?? (opts?.axis ===
|
|
73
|
+
orientation: orientation ?? (opts?.axis === "y" ? "vertical" : "horizontal"),
|
|
74
74
|
scope: __scopeCarousel,
|
|
75
75
|
scrollNext: scrollNext,
|
|
76
76
|
scrollPrev: scrollPrevious,
|
|
77
77
|
children: /*#__PURE__*/ jsx("div", {
|
|
78
|
-
className: cn(
|
|
78
|
+
className: cn("relative", className),
|
|
79
79
|
"data-slot": "carousel",
|
|
80
80
|
onKeyDownCapture: handleKeyDown,
|
|
81
81
|
...props,
|
|
@@ -83,36 +83,36 @@ function Carousel({ __scopeCarousel, children, className, opts, orientation, plu
|
|
|
83
83
|
})
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
-
const CAROUSEL_CONTENT_NAME =
|
|
86
|
+
const CAROUSEL_CONTENT_NAME = "CarouselContent";
|
|
87
87
|
function CarouselContent({ __scopeCarousel, className, classNames, ...props }) {
|
|
88
88
|
const { carouselRef, orientation } = useCarouselContext(CAROUSEL_CONTENT_NAME, __scopeCarousel);
|
|
89
89
|
return /*#__PURE__*/ jsx("div", {
|
|
90
90
|
ref: carouselRef,
|
|
91
|
-
className: cn(
|
|
91
|
+
className: cn("overflow-hidden", classNames?.wrapper),
|
|
92
92
|
"data-slot": "carousel-content",
|
|
93
93
|
children: /*#__PURE__*/ jsx("div", {
|
|
94
|
-
className: cn(
|
|
94
|
+
className: cn("flex", "horizontal" === orientation ? "-ml-4" : "-mt-4 flex-col", classNames?.content, className),
|
|
95
95
|
...props
|
|
96
96
|
})
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
|
-
const CAROUSEL_ITEM_NAME =
|
|
99
|
+
const CAROUSEL_ITEM_NAME = "CarouselItem";
|
|
100
100
|
function CarouselItem({ __scopeCarousel, className, ...props }) {
|
|
101
101
|
const { orientation } = useCarouselContext(CAROUSEL_ITEM_NAME, __scopeCarousel);
|
|
102
102
|
return /*#__PURE__*/ jsx("div", {
|
|
103
103
|
"aria-roledescription": "slide",
|
|
104
|
-
className: cn(
|
|
104
|
+
className: cn("min-w-0 shrink-0 grow-0 basis-full", "horizontal" === orientation ? "pl-4" : "pt-4", className),
|
|
105
105
|
"data-slot": "carousel-item",
|
|
106
106
|
role: "group",
|
|
107
107
|
...props
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
const CAROUSEL_PREVIOUS_NAME =
|
|
111
|
-
function CarouselPrevious({ __scopeCarousel, className, size =
|
|
110
|
+
const CAROUSEL_PREVIOUS_NAME = "CarouselPrevious";
|
|
111
|
+
function CarouselPrevious({ __scopeCarousel, className, size = "icon", variant = "outline", ...props }) {
|
|
112
112
|
const { canScrollPrev, orientation, scrollPrev } = useCarouselContext(CAROUSEL_PREVIOUS_NAME, __scopeCarousel);
|
|
113
113
|
return /*#__PURE__*/ jsxs(Button, {
|
|
114
114
|
"aria-label": "Previous slide",
|
|
115
|
-
className: cn(
|
|
115
|
+
className: cn("absolute size-8 shadow-none", "horizontal" === orientation ? "top-1/2 -left-12 -translate-y-1/2" : "-top-12 left-1/2 -translate-x-1/2 rotate-90", className),
|
|
116
116
|
"data-slot": "carousel-previous",
|
|
117
117
|
disabled: !canScrollPrev,
|
|
118
118
|
size: size,
|
|
@@ -128,12 +128,12 @@ function CarouselPrevious({ __scopeCarousel, className, size = 'icon', variant =
|
|
|
128
128
|
]
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
const CAROUSEL_NEXT_NAME =
|
|
132
|
-
function CarouselNext({ __scopeCarousel, className, size =
|
|
131
|
+
const CAROUSEL_NEXT_NAME = "CarouselNext";
|
|
132
|
+
function CarouselNext({ __scopeCarousel, className, size = "icon", variant = "outline", ...props }) {
|
|
133
133
|
const { canScrollNext, orientation, scrollNext } = useCarouselContext(CAROUSEL_NEXT_NAME, __scopeCarousel);
|
|
134
134
|
return /*#__PURE__*/ jsxs(Button, {
|
|
135
135
|
"aria-label": "Next slide",
|
|
136
|
-
className: cn(
|
|
136
|
+
className: cn("absolute size-8 shadow-none", "horizontal" === orientation ? "top-1/2 -right-12 -translate-y-1/2" : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90", className),
|
|
137
137
|
"data-slot": "carousel-next",
|
|
138
138
|
disabled: !canScrollNext,
|
|
139
139
|
size: size,
|
|
@@ -39,10 +39,10 @@ const react_context_namespaceObject = require("@radix-ui/react-context");
|
|
|
39
39
|
const external_react_namespaceObject = require("react");
|
|
40
40
|
const external_recharts_namespaceObject = require("recharts");
|
|
41
41
|
const THEMES = {
|
|
42
|
-
dark:
|
|
43
|
-
light:
|
|
42
|
+
dark: ".dark",
|
|
43
|
+
light: ""
|
|
44
44
|
};
|
|
45
|
-
const CHART_PROVIDER_NAME =
|
|
45
|
+
const CHART_PROVIDER_NAME = "ChartProvider";
|
|
46
46
|
const [createChartContext, createChartScope] = (0, react_context_namespaceObject.createContextScope)(CHART_PROVIDER_NAME);
|
|
47
47
|
const [ChartContextProvider, useChartContext] = createChartContext(CHART_PROVIDER_NAME);
|
|
48
48
|
function ChartContainer({ __scopeChart, children, className, config, id, ...props }) {
|
|
@@ -52,7 +52,7 @@ function ChartContainer({ __scopeChart, children, className, config, id, ...prop
|
|
|
52
52
|
config: config,
|
|
53
53
|
scope: __scopeChart,
|
|
54
54
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
55
|
-
className: (0, tailwind_variants_namespaceObject.cn)("[&_.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-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
|
|
55
|
+
className: (0, tailwind_variants_namespaceObject.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-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", className),
|
|
56
56
|
"data-chart": chartId,
|
|
57
57
|
"data-slot": "chart",
|
|
58
58
|
...props,
|
|
@@ -78,22 +78,22 @@ function ChartStyle({ config, id }) {
|
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
const ChartTooltip = external_recharts_namespaceObject.Tooltip;
|
|
81
|
-
const CHART_TOOLTIP_CONTENT_NAME =
|
|
82
|
-
function ChartTooltipContent({ __scopeChart, active, className, color, formatter, hideIndicator = false, hideLabel = false, indicator =
|
|
81
|
+
const CHART_TOOLTIP_CONTENT_NAME = "ChartTooltipContent";
|
|
82
|
+
function ChartTooltipContent({ __scopeChart, active, className, color, formatter, hideIndicator = false, hideLabel = false, indicator = "dot", label, labelClassName, labelFormatter, labelKey, nameKey, payload = [] }) {
|
|
83
83
|
const { config } = useChartContext(CHART_TOOLTIP_CONTENT_NAME, __scopeChart);
|
|
84
84
|
const tooltipLabel = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
85
85
|
if (hideLabel || 0 === payload.length) return null;
|
|
86
86
|
const [item] = payload;
|
|
87
|
-
const key = safeToString(labelKey ?? item.dataKey ?? item.name ??
|
|
87
|
+
const key = safeToString(labelKey ?? item.dataKey ?? item.name ?? "value");
|
|
88
88
|
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
89
|
-
const value = labelKey ||
|
|
89
|
+
const value = labelKey || "string" != typeof label ? itemConfig?.label : label in config ? config[label].label ?? label : label;
|
|
90
90
|
if (labelFormatter) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
91
|
-
className: (0, tailwind_variants_namespaceObject.cn)(
|
|
91
|
+
className: (0, tailwind_variants_namespaceObject.cn)("font-medium", labelClassName),
|
|
92
92
|
children: labelFormatter(value, payload)
|
|
93
93
|
});
|
|
94
94
|
if (!value) return null;
|
|
95
95
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
96
|
-
className: (0, tailwind_variants_namespaceObject.cn)(
|
|
96
|
+
className: (0, tailwind_variants_namespaceObject.cn)("font-medium", labelClassName),
|
|
97
97
|
children: value
|
|
98
98
|
});
|
|
99
99
|
}, [
|
|
@@ -106,37 +106,37 @@ function ChartTooltipContent({ __scopeChart, active, className, color, formatter
|
|
|
106
106
|
labelKey
|
|
107
107
|
]);
|
|
108
108
|
if (!active || 0 === payload.length) return null;
|
|
109
|
-
const nestLabel = 1 === payload.length &&
|
|
109
|
+
const nestLabel = 1 === payload.length && "dot" !== indicator;
|
|
110
110
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
111
|
-
className: (0, tailwind_variants_namespaceObject.cn)(
|
|
111
|
+
className: (0, tailwind_variants_namespaceObject.cn)("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", className),
|
|
112
112
|
children: [
|
|
113
113
|
nestLabel ? null : tooltipLabel,
|
|
114
114
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
115
115
|
className: "grid gap-1.5",
|
|
116
116
|
children: payload.map((item, index)=>{
|
|
117
|
-
const key = safeToString(nameKey ?? item.name ?? item.dataKey ??
|
|
117
|
+
const key = safeToString(nameKey ?? item.name ?? item.dataKey ?? "value");
|
|
118
118
|
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
119
|
-
const indicatorColor = color ?? (isRecord(item.payload) &&
|
|
119
|
+
const indicatorColor = color ?? (isRecord(item.payload) && "fill" in item.payload && "string" == typeof item.payload.fill ? item.payload.fill : void 0) ?? item.color;
|
|
120
120
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
121
|
-
className: (0, tailwind_variants_namespaceObject.cn)(
|
|
121
|
+
className: (0, tailwind_variants_namespaceObject.cn)("flex w-full flex-wrap items-stretch gap-2 [&>svg]:size-2.5 [&>svg]:text-muted-foreground", "dot" === indicator && "items-center"),
|
|
122
122
|
children: formatter && void 0 !== item.value && item.name ? formatter(item.value, item.name, item, index, [
|
|
123
123
|
item
|
|
124
124
|
]) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
125
125
|
children: [
|
|
126
126
|
itemConfig?.icon ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(itemConfig.icon, {}) : !hideIndicator && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
127
|
-
className: (0, tailwind_variants_namespaceObject.cn)(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
127
|
+
className: (0, tailwind_variants_namespaceObject.cn)("shrink-0 rounded-xs border-(--color-border) bg-(--color-bg)", {
|
|
128
|
+
"h-2.5 w-2.5": "dot" === indicator,
|
|
129
|
+
"my-0.5": nestLabel && "dashed" === indicator,
|
|
130
|
+
"border-1.5 w-0 border-dashed bg-transparent": "dashed" === indicator,
|
|
131
|
+
"w-1": "line" === indicator
|
|
132
132
|
}),
|
|
133
133
|
style: {
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
"--color-bg": indicatorColor,
|
|
135
|
+
"--color-border": indicatorColor
|
|
136
136
|
}
|
|
137
137
|
}),
|
|
138
138
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
139
|
-
className: (0, tailwind_variants_namespaceObject.cn)(
|
|
139
|
+
className: (0, tailwind_variants_namespaceObject.cn)("flex flex-1 justify-between leading-none", nestLabel ? "items-end" : "items-center"),
|
|
140
140
|
children: [
|
|
141
141
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
142
142
|
className: "grid gap-1.5",
|
|
@@ -149,8 +149,8 @@ function ChartTooltipContent({ __scopeChart, active, className, color, formatter
|
|
|
149
149
|
]
|
|
150
150
|
}),
|
|
151
151
|
null != item.value && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
152
|
-
className: "
|
|
153
|
-
children:
|
|
152
|
+
className: "font-mono font-medium text-foreground tabular-nums",
|
|
153
|
+
children: "number" == typeof item.value ? item.value.toLocaleString() : safeToString(item.value)
|
|
154
154
|
})
|
|
155
155
|
]
|
|
156
156
|
})
|
|
@@ -163,19 +163,19 @@ function ChartTooltipContent({ __scopeChart, active, className, color, formatter
|
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
const ChartLegend = external_recharts_namespaceObject.Legend;
|
|
166
|
-
const CHART_LEGEND_CONTENT_NAME =
|
|
167
|
-
function ChartLegendContent({ __scopeChart, className, hideIcon = false, nameKey, payload, verticalAlign =
|
|
166
|
+
const CHART_LEGEND_CONTENT_NAME = "ChartLegendContent";
|
|
167
|
+
function ChartLegendContent({ __scopeChart, className, hideIcon = false, nameKey, payload, verticalAlign = "bottom" }) {
|
|
168
168
|
const { config } = useChartContext(CHART_LEGEND_CONTENT_NAME, __scopeChart);
|
|
169
169
|
if (!payload?.length) return null;
|
|
170
170
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
171
|
-
className: (0, tailwind_variants_namespaceObject.cn)(
|
|
171
|
+
className: (0, tailwind_variants_namespaceObject.cn)("flex items-center justify-center gap-4", "top" === verticalAlign ? "pb-3" : "pt-3", className),
|
|
172
172
|
children: payload.map((item)=>{
|
|
173
|
-
let key =
|
|
173
|
+
let key = "value";
|
|
174
174
|
if (nameKey) key = nameKey;
|
|
175
175
|
else if (null != item.dataKey) key = safeToString(item.dataKey);
|
|
176
176
|
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
177
177
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
178
|
-
className: (0, tailwind_variants_namespaceObject.cn)(
|
|
178
|
+
className: (0, tailwind_variants_namespaceObject.cn)("flex items-center gap-1.5 [&>svg]:size-3 [&>svg]:text-muted-foreground"),
|
|
179
179
|
children: [
|
|
180
180
|
itemConfig?.icon && !hideIcon ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(itemConfig.icon, {}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
181
181
|
className: "size-2 shrink-0 rounded-md",
|
|
@@ -185,27 +185,27 @@ function ChartLegendContent({ __scopeChart, className, hideIcon = false, nameKey
|
|
|
185
185
|
}),
|
|
186
186
|
itemConfig?.label
|
|
187
187
|
]
|
|
188
|
-
}, nameKey ? safeToString(itemConfig?.color ??
|
|
188
|
+
}, nameKey ? safeToString(itemConfig?.color ?? "") : safeToString(item.value ?? ""));
|
|
189
189
|
})
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
192
|
function isRecord(value) {
|
|
193
|
-
return
|
|
193
|
+
return "object" == typeof value && null !== value;
|
|
194
194
|
}
|
|
195
195
|
function getStringValue(record, key) {
|
|
196
196
|
if (key in record) {
|
|
197
197
|
const value = record[key];
|
|
198
|
-
return
|
|
198
|
+
return "string" == typeof value ? value : void 0;
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
function safeToString(value) {
|
|
202
|
-
if (
|
|
203
|
-
if (
|
|
204
|
-
if (null == value) return
|
|
205
|
-
if (
|
|
206
|
-
if (
|
|
207
|
-
if (
|
|
208
|
-
return
|
|
202
|
+
if ("string" == typeof value) return value;
|
|
203
|
+
if ("number" == typeof value) return value.toString();
|
|
204
|
+
if (null == value) return "";
|
|
205
|
+
if ("boolean" == typeof value) return value.toString();
|
|
206
|
+
if ("bigint" == typeof value) return value.toString();
|
|
207
|
+
if ("symbol" == typeof value) return value.toString();
|
|
208
|
+
return "";
|
|
209
209
|
}
|
|
210
210
|
function getPayloadConfigFromPayload(config, payload, key) {
|
|
211
211
|
if (!isRecord(payload)) return;
|
|
@@ -224,11 +224,11 @@ function generateCssVariable(key, itemConfig, theme) {
|
|
|
224
224
|
return color ? ` --color-${key}: ${color};` : null;
|
|
225
225
|
}
|
|
226
226
|
function generateThemeStyles(theme, prefix, id, colorConfig) {
|
|
227
|
-
const cssVariables = colorConfig.map(([key, itemConfig])=>generateCssVariable(key, itemConfig, theme)).filter(Boolean).join(
|
|
227
|
+
const cssVariables = colorConfig.map(([key, itemConfig])=>generateCssVariable(key, itemConfig, theme)).filter(Boolean).join("\n");
|
|
228
228
|
return `${prefix} [data-chart=${id}] {\n${cssVariables}\n}`;
|
|
229
229
|
}
|
|
230
230
|
function generateChartStyles(id, colorConfig) {
|
|
231
|
-
return Object.entries(THEMES).map(([theme, prefix])=>generateThemeStyles(theme, prefix, id, colorConfig)).join(
|
|
231
|
+
return Object.entries(THEMES).map(([theme, prefix])=>generateThemeStyles(theme, prefix, id, colorConfig)).join("\n\n");
|
|
232
232
|
}
|
|
233
233
|
exports.ChartContainer = __webpack_exports__.ChartContainer;
|
|
234
234
|
exports.ChartLegend = __webpack_exports__.ChartLegend;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { Scope } from
|
|
2
|
-
import type { ComponentProps, ComponentType, JSX, ReactNode } from
|
|
3
|
-
import type { NameType, Payload, ValueType } from
|
|
4
|
-
import
|
|
1
|
+
import type { Scope } from "@radix-ui/react-context";
|
|
2
|
+
import type { ComponentProps, ComponentType, JSX, ReactNode } from "react";
|
|
3
|
+
import type { NameType, Payload, ValueType } from "recharts/types/component/DefaultTooltipContent";
|
|
4
|
+
import type { TooltipContentProps, TooltipProps } from "recharts";
|
|
5
|
+
import * as RechartsPrimitive from "recharts";
|
|
5
6
|
type ExtractProps<T> = T extends (props: infer P) => ReactNode ? P : never;
|
|
6
7
|
type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
7
8
|
declare const THEMES: {
|
|
@@ -22,8 +23,8 @@ type ScopedProps<P> = P & {
|
|
|
22
23
|
__scopeChart?: Scope;
|
|
23
24
|
};
|
|
24
25
|
declare const createChartScope: import("@radix-ui/react-context").CreateScope;
|
|
25
|
-
interface ChartContainerProps extends ComponentProps<
|
|
26
|
-
children: ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>[
|
|
26
|
+
interface ChartContainerProps extends ComponentProps<"div"> {
|
|
27
|
+
children: ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];
|
|
27
28
|
config: ChartConfig;
|
|
28
29
|
}
|
|
29
30
|
declare function ChartContainer({ __scopeChart, children, className, config, id, ...props }: ScopedProps<ChartContainerProps>): JSX.Element;
|
|
@@ -32,12 +33,12 @@ interface ChartStyleProps {
|
|
|
32
33
|
id: string;
|
|
33
34
|
}
|
|
34
35
|
declare function ChartStyle({ config, id }: ChartStyleProps): ReactNode;
|
|
35
|
-
type ChartTooltipProps<TValue extends ValueType, TName extends NameType> =
|
|
36
|
+
type ChartTooltipProps<TValue extends ValueType, TName extends NameType> = TooltipProps<TValue, TName>;
|
|
36
37
|
declare const ChartTooltip: typeof RechartsPrimitive.Tooltip;
|
|
37
|
-
type ChartTooltipContentProps<TValue extends ValueType, TName extends NameType> = Omit<MakeOptional<
|
|
38
|
+
type ChartTooltipContentProps<TValue extends ValueType, TName extends NameType> = Omit<MakeOptional<TooltipContentProps<TValue, TName>, "accessibilityLayer" | "active" | "activeIndex" | "coordinate" | "payload">, "payload"> & {
|
|
38
39
|
hideIndicator?: boolean;
|
|
39
40
|
hideLabel?: boolean;
|
|
40
|
-
indicator?:
|
|
41
|
+
indicator?: "dashed" | "dot" | "line";
|
|
41
42
|
labelKey?: string;
|
|
42
43
|
nameKey?: string;
|
|
43
44
|
color?: string | undefined;
|
|
@@ -46,8 +47,8 @@ type ChartTooltipContentProps<TValue extends ValueType, TName extends NameType>
|
|
|
46
47
|
};
|
|
47
48
|
declare function ChartTooltipContent<TValue extends ValueType, TName extends NameType>({ __scopeChart, active, className, color, formatter, hideIndicator, hideLabel, indicator, label, labelClassName, labelFormatter, labelKey, nameKey, payload, }: ScopedProps<ChartTooltipContentProps<TValue, TName>>): ReactNode;
|
|
48
49
|
type ChartLegendProps = ComponentProps<typeof RechartsPrimitive.Legend>;
|
|
49
|
-
declare const ChartLegend:
|
|
50
|
-
type ChartLegendContentProps = ComponentProps<
|
|
50
|
+
declare const ChartLegend: import("react").MemoExoticComponent<(outsideProps: RechartsPrimitive.LegendProps) => React.ReactPortal | null>;
|
|
51
|
+
type ChartLegendContentProps = ComponentProps<"div"> & ExtractProps<RechartsPrimitive.LegendProps["content"]> & {
|
|
51
52
|
hideIcon?: boolean;
|
|
52
53
|
nameKey?: string;
|
|
53
54
|
};
|