@codefast/ui 0.3.9 → 0.3.10
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 +11 -0
- package/dist/components/accordion.cjs +97 -1
- package/dist/components/accordion.d.ts +4 -4
- package/dist/components/accordion.js +51 -1
- package/dist/components/alert-dialog.cjs +155 -1
- package/dist/components/alert-dialog.d.ts +11 -11
- package/dist/components/alert-dialog.js +94 -1
- package/dist/components/alert.cjs +84 -1
- package/dist/components/alert.d.ts +5 -5
- package/dist/components/alert.js +41 -1
- package/dist/components/aspect-ratio.cjs +43 -1
- package/dist/components/aspect-ratio.d.ts +2 -2
- package/dist/components/aspect-ratio.js +9 -1
- package/dist/components/avatar.cjs +65 -1
- package/dist/components/avatar.d.ts +2 -2
- package/dist/components/avatar.js +25 -1
- package/dist/components/badge.cjs +66 -1
- package/dist/components/badge.d.ts +3 -3
- package/dist/components/badge.js +29 -1
- package/dist/components/breadcrumb.cjs +126 -1
- package/dist/components/breadcrumb.d.ts +8 -8
- package/dist/components/breadcrumb.js +74 -1
- package/dist/components/button-group.cjs +86 -1
- package/dist/components/button-group.d.ts +5 -5
- package/dist/components/button-group.js +43 -1
- package/dist/components/button.cjs +92 -1
- package/dist/components/button.d.ts +6 -6
- package/dist/components/button.js +55 -1
- package/dist/components/calendar.cjs +150 -1
- package/dist/components/calendar.d.ts +12 -19
- package/dist/components/calendar.js +113 -1
- package/dist/components/card.cjs +105 -1
- package/dist/components/card.d.ts +8 -8
- package/dist/components/card.js +53 -1
- package/dist/components/carousel.cjs +210 -1
- package/dist/components/carousel.d.ts +10 -10
- package/dist/components/carousel.js +151 -1
- package/dist/components/chart.cjs +250 -3
- package/dist/components/chart.d.ts +9 -9
- package/dist/components/chart.js +198 -3
- package/dist/components/checkbox-cards.cjs +69 -1
- package/dist/components/checkbox-cards.d.ts +2 -2
- package/dist/components/checkbox-cards.js +32 -1
- package/dist/components/checkbox-group.cjs +63 -1
- package/dist/components/checkbox-group.d.ts +2 -2
- package/dist/components/checkbox-group.js +26 -1
- package/dist/components/checkbox.cjs +53 -1
- package/dist/components/checkbox.d.ts +2 -2
- package/dist/components/checkbox.js +19 -1
- package/dist/components/collapsible.cjs +61 -1
- package/dist/components/collapsible.d.ts +2 -2
- package/dist/components/collapsible.js +21 -1
- package/dist/components/command.cjs +167 -1
- package/dist/components/command.d.ts +4 -4
- package/dist/components/command.js +106 -1
- package/dist/components/context-menu.cjs +218 -1
- package/dist/components/context-menu.d.ts +4 -4
- package/dist/components/context-menu.js +142 -1
- package/dist/components/dialog.cjs +164 -1
- package/dist/components/dialog.d.ts +10 -10
- package/dist/components/dialog.js +106 -1
- package/dist/components/drawer.cjs +143 -1
- package/dist/components/drawer.d.ts +9 -9
- package/dist/components/drawer.js +85 -1
- package/dist/components/dropdown-menu.cjs +221 -1
- package/dist/components/dropdown-menu.d.ts +4 -4
- package/dist/components/dropdown-menu.js +145 -1
- package/dist/components/empty.cjs +113 -1
- package/dist/components/empty.d.ts +9 -9
- package/dist/components/empty.js +61 -1
- package/dist/components/field.cjs +193 -1
- package/dist/components/field.d.ts +14 -14
- package/dist/components/field.js +129 -1
- package/dist/components/form.cjs +151 -1
- package/dist/components/form.d.ts +10 -10
- package/dist/components/form.js +96 -1
- package/dist/components/hover-card.cjs +77 -1
- package/dist/components/hover-card.d.ts +2 -2
- package/dist/components/hover-card.js +34 -1
- package/dist/components/input-group.cjs +155 -1
- package/dist/components/input-group.d.ts +15 -15
- package/dist/components/input-group.js +97 -1
- package/dist/components/input-number.cjs +98 -1
- package/dist/components/input-number.d.ts +2 -2
- package/dist/components/input-number.js +64 -1
- package/dist/components/input-otp.cjs +101 -1
- package/dist/components/input-otp.d.ts +6 -6
- package/dist/components/input-otp.js +49 -1
- package/dist/components/input-password.cjs +71 -1
- package/dist/components/input-password.d.ts +3 -3
- package/dist/components/input-password.js +37 -1
- package/dist/components/input-search.cjs +80 -1
- package/dist/components/input-search.d.ts +3 -3
- package/dist/components/input-search.js +46 -1
- package/dist/components/input.cjs +45 -1
- package/dist/components/input.d.ts +2 -2
- package/dist/components/input.js +11 -1
- package/dist/components/item.cjs +186 -1
- package/dist/components/item.d.ts +12 -12
- package/dist/components/item.js +119 -1
- package/dist/components/kbd.cjs +54 -1
- package/dist/components/kbd.d.ts +3 -3
- package/dist/components/kbd.js +17 -1
- package/dist/components/label.cjs +45 -1
- package/dist/components/label.d.ts +2 -2
- package/dist/components/label.js +11 -1
- package/dist/components/menubar.cjs +232 -1
- package/dist/components/menubar.d.ts +4 -4
- package/dist/components/menubar.js +153 -1
- package/dist/components/native-select.cjs +75 -1
- package/dist/components/native-select.d.ts +4 -4
- package/dist/components/native-select.js +35 -1
- package/dist/components/navigation-menu.cjs +146 -2
- package/dist/components/navigation-menu.d.ts +2 -2
- package/dist/components/navigation-menu.js +94 -2
- package/dist/components/pagination.cjs +138 -1
- package/dist/components/pagination.d.ts +10 -10
- package/dist/components/pagination.js +86 -1
- package/dist/components/popover.cjs +86 -1
- package/dist/components/popover.d.ts +3 -3
- package/dist/components/popover.js +40 -1
- package/dist/components/progress-circle.cjs +184 -1
- package/dist/components/progress-circle.d.ts +5 -5
- package/dist/components/progress-circle.js +147 -1
- package/dist/components/progress.cjs +52 -1
- package/dist/components/progress.d.ts +2 -2
- package/dist/components/progress.js +18 -1
- package/dist/components/radio-cards.cjs +66 -1
- package/dist/components/radio-cards.d.ts +2 -2
- package/dist/components/radio-cards.js +29 -1
- package/dist/components/radio-group.cjs +59 -1
- package/dist/components/radio-group.d.ts +2 -2
- package/dist/components/radio-group.js +22 -1
- package/dist/components/radio.cjs +47 -1
- package/dist/components/radio.d.ts +2 -2
- package/dist/components/radio.js +13 -1
- package/dist/components/resizable.cjs +71 -1
- package/dist/components/resizable.d.ts +8 -8
- package/dist/components/resizable.js +31 -1
- package/dist/components/scroll-area.cjs +140 -1
- package/dist/components/scroll-area.d.ts +5 -5
- package/dist/components/scroll-area.js +100 -1
- package/dist/components/select.cjs +180 -1
- package/dist/components/select.d.ts +5 -5
- package/dist/components/select.js +119 -1
- package/dist/components/separator.cjs +82 -1
- package/dist/components/separator.d.ts +5 -5
- package/dist/components/separator.js +42 -1
- package/dist/components/sheet.cjs +184 -1
- package/dist/components/sheet.d.ts +9 -9
- package/dist/components/sheet.js +123 -1
- package/dist/components/sidebar.cjs +506 -1
- package/dist/components/sidebar.d.ts +31 -31
- package/dist/components/sidebar.js +400 -1
- package/dist/components/skeleton.cjs +44 -1
- package/dist/components/skeleton.d.ts +2 -2
- package/dist/components/skeleton.js +10 -1
- package/dist/components/slider.cjs +79 -1
- package/dist/components/slider.d.ts +2 -2
- package/dist/components/slider.js +45 -1
- package/dist/components/sonner.cjs +57 -1
- package/dist/components/sonner.d.ts +3 -3
- package/dist/components/sonner.js +17 -1
- package/dist/components/spinner.cjs +75 -1
- package/dist/components/spinner.d.ts +2 -2
- package/dist/components/spinner.js +41 -1
- package/dist/components/switch.cjs +49 -1
- package/dist/components/switch.d.ts +2 -2
- package/dist/components/switch.js +15 -1
- package/dist/components/table.cjs +118 -1
- package/dist/components/table.d.ts +9 -9
- package/dist/components/table.js +63 -1
- package/dist/components/tabs.cjs +75 -1
- package/dist/components/tabs.d.ts +3 -3
- package/dist/components/tabs.js +32 -1
- package/dist/components/textarea.cjs +44 -1
- package/dist/components/textarea.d.ts +2 -2
- package/dist/components/textarea.js +10 -1
- package/dist/components/toggle-group.cjs +90 -1
- package/dist/components/toggle-group.d.ts +10 -12
- package/dist/components/toggle-group.js +53 -1
- package/dist/components/toggle.cjs +71 -1
- package/dist/components/toggle.d.ts +10 -12
- package/dist/components/toggle.js +34 -1
- package/dist/components/tooltip.cjs +90 -1
- package/dist/components/tooltip.d.ts +3 -3
- package/dist/components/tooltip.js +44 -1
- package/dist/css/amber.css +95 -1
- package/dist/css/blue.css +95 -1
- package/dist/css/cyan.css +95 -1
- package/dist/css/emerald.css +95 -1
- package/dist/css/fuchsia.css +95 -1
- package/dist/css/gray.css +95 -1
- package/dist/css/green.css +95 -1
- package/dist/css/indigo.css +95 -1
- package/dist/css/lime.css +95 -1
- package/dist/css/neutral.css +95 -1
- package/dist/css/orange.css +95 -1
- package/dist/css/pink.css +95 -1
- package/dist/css/preset.css +118 -1
- package/dist/css/purple.css +95 -1
- package/dist/css/red.css +95 -1
- package/dist/css/rose.css +95 -1
- package/dist/css/sky.css +95 -1
- package/dist/css/slate.css +95 -1
- package/dist/css/stone.css +95 -1
- package/dist/css/style.css +3 -1
- package/dist/css/teal.css +95 -1
- package/dist/css/violet.css +95 -1
- package/dist/css/yellow.css +95 -1
- package/dist/css/zinc.css +95 -1
- package/dist/hooks/use-animated-value.cjs +74 -1
- package/dist/hooks/use-animated-value.d.ts +9 -10
- package/dist/hooks/use-animated-value.js +40 -1
- package/dist/hooks/use-copy-to-clipboard.cjs +57 -1
- package/dist/hooks/use-copy-to-clipboard.d.ts +18 -1
- package/dist/hooks/use-copy-to-clipboard.js +23 -1
- package/dist/hooks/use-is-mobile.cjs +39 -1
- package/dist/hooks/use-is-mobile.d.ts +15 -6
- package/dist/hooks/use-is-mobile.js +5 -1
- package/dist/hooks/use-media-query.cjs +56 -1
- package/dist/hooks/use-media-query.d.ts +11 -3
- package/dist/hooks/use-media-query.js +22 -1
- package/dist/hooks/use-mutation-observer.cjs +56 -1
- package/dist/hooks/use-mutation-observer.d.ts +8 -12
- package/dist/hooks/use-mutation-observer.js +22 -1
- package/dist/hooks/use-pagination.cjs +92 -1
- package/dist/hooks/use-pagination.d.ts +12 -10
- package/dist/hooks/use-pagination.js +55 -1
- package/dist/index.cjs +1081 -1
- package/dist/index.d.ts +130 -131
- package/dist/index.js +69 -1
- package/dist/primitives/checkbox-group.cjs +151 -1
- package/dist/primitives/checkbox-group.d.ts +11 -11
- package/dist/primitives/checkbox-group.js +99 -1
- package/dist/primitives/input-number.cjs +439 -1
- package/dist/primitives/input-number.d.ts +8 -8
- package/dist/primitives/input-number.js +381 -1
- package/dist/primitives/input.cjs +99 -1
- package/dist/primitives/input.d.ts +4 -4
- package/dist/primitives/input.js +53 -1
- package/dist/primitives/progress-circle.cjs +198 -1
- package/dist/primitives/progress-circle.d.ts +7 -7
- package/dist/primitives/progress-circle.js +128 -1
- package/package.json +385 -38
|
@@ -1,2 +1,152 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "@codefast/tailwind-variants";
|
|
4
|
+
import { createContextScope } from "@radix-ui/react-context";
|
|
5
|
+
import embla_carousel_react from "embla-carousel-react";
|
|
6
|
+
import { ArrowLeftIcon, ArrowRightIcon } from "lucide-react";
|
|
7
|
+
import { useCallback, useEffect, useState } from "react";
|
|
8
|
+
import { Button } from "./button.js";
|
|
9
|
+
const CAROUSEL_NAME = 'Carousel';
|
|
10
|
+
const [createCarouselContext, createCarouselScope] = createContextScope(CAROUSEL_NAME);
|
|
11
|
+
const [CarouselContextProvider, useCarouselContext] = createCarouselContext(CAROUSEL_NAME);
|
|
12
|
+
function Carousel({ __scopeCarousel, children, className, opts, orientation, plugins, setApi, ...props }) {
|
|
13
|
+
const [carouselRef, api] = embla_carousel_react({
|
|
14
|
+
...opts,
|
|
15
|
+
axis: 'vertical' === orientation ? 'y' : 'x'
|
|
16
|
+
}, plugins);
|
|
17
|
+
const [canScrollPrevious, setCanScrollPrevious] = useState(false);
|
|
18
|
+
const [canScrollNext, setCanScrollNext] = useState(false);
|
|
19
|
+
const onSelect = useCallback((carouselApi)=>{
|
|
20
|
+
if (!carouselApi) return;
|
|
21
|
+
setCanScrollPrevious(carouselApi.canScrollPrev());
|
|
22
|
+
setCanScrollNext(carouselApi.canScrollNext());
|
|
23
|
+
}, []);
|
|
24
|
+
const scrollPrevious = useCallback(()=>{
|
|
25
|
+
api?.scrollPrev();
|
|
26
|
+
}, [
|
|
27
|
+
api
|
|
28
|
+
]);
|
|
29
|
+
const scrollNext = useCallback(()=>{
|
|
30
|
+
api?.scrollNext();
|
|
31
|
+
}, [
|
|
32
|
+
api
|
|
33
|
+
]);
|
|
34
|
+
const handleKeyDown = useCallback((event)=>{
|
|
35
|
+
if ('ArrowLeft' === event.key) {
|
|
36
|
+
event.preventDefault();
|
|
37
|
+
scrollPrevious();
|
|
38
|
+
} else if ('ArrowRight' === event.key) {
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
scrollNext();
|
|
41
|
+
}
|
|
42
|
+
}, [
|
|
43
|
+
scrollPrevious,
|
|
44
|
+
scrollNext
|
|
45
|
+
]);
|
|
46
|
+
useEffect(()=>{
|
|
47
|
+
if (!api || !setApi) return;
|
|
48
|
+
setApi(api);
|
|
49
|
+
}, [
|
|
50
|
+
api,
|
|
51
|
+
setApi
|
|
52
|
+
]);
|
|
53
|
+
useEffect(()=>{
|
|
54
|
+
if (!api) return;
|
|
55
|
+
queueMicrotask(()=>{
|
|
56
|
+
onSelect(api);
|
|
57
|
+
});
|
|
58
|
+
api.on('reInit', onSelect);
|
|
59
|
+
api.on('select', onSelect);
|
|
60
|
+
return ()=>{
|
|
61
|
+
api.off('select', onSelect);
|
|
62
|
+
};
|
|
63
|
+
}, [
|
|
64
|
+
api,
|
|
65
|
+
onSelect
|
|
66
|
+
]);
|
|
67
|
+
return /*#__PURE__*/ jsx(CarouselContextProvider, {
|
|
68
|
+
api: api,
|
|
69
|
+
canScrollNext: canScrollNext,
|
|
70
|
+
canScrollPrev: canScrollPrevious,
|
|
71
|
+
carouselRef: carouselRef,
|
|
72
|
+
opts: opts,
|
|
73
|
+
orientation: orientation ?? (opts?.axis === 'y' ? 'vertical' : 'horizontal'),
|
|
74
|
+
scope: __scopeCarousel,
|
|
75
|
+
scrollNext: scrollNext,
|
|
76
|
+
scrollPrev: scrollPrevious,
|
|
77
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
78
|
+
className: cn('relative', className),
|
|
79
|
+
"data-slot": "carousel",
|
|
80
|
+
onKeyDownCapture: handleKeyDown,
|
|
81
|
+
...props,
|
|
82
|
+
children: children
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const CAROUSEL_CONTENT_NAME = 'CarouselContent';
|
|
87
|
+
function CarouselContent({ __scopeCarousel, className, classNames, ...props }) {
|
|
88
|
+
const { carouselRef, orientation } = useCarouselContext(CAROUSEL_CONTENT_NAME, __scopeCarousel);
|
|
89
|
+
return /*#__PURE__*/ jsx("div", {
|
|
90
|
+
ref: carouselRef,
|
|
91
|
+
className: cn('overflow-hidden', classNames?.wrapper),
|
|
92
|
+
"data-slot": "carousel-content",
|
|
93
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
94
|
+
className: cn('flex', 'horizontal' === orientation ? '-ml-4' : '-mt-4 flex-col', classNames?.content, className),
|
|
95
|
+
...props
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
const CAROUSEL_ITEM_NAME = 'CarouselItem';
|
|
100
|
+
function CarouselItem({ __scopeCarousel, className, ...props }) {
|
|
101
|
+
const { orientation } = useCarouselContext(CAROUSEL_ITEM_NAME, __scopeCarousel);
|
|
102
|
+
return /*#__PURE__*/ jsx("div", {
|
|
103
|
+
"aria-roledescription": "slide",
|
|
104
|
+
className: cn('min-w-0 shrink-0 grow-0 basis-full', 'horizontal' === orientation ? 'pl-4' : 'pt-4', className),
|
|
105
|
+
"data-slot": "carousel-item",
|
|
106
|
+
role: "group",
|
|
107
|
+
...props
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
const CAROUSEL_PREVIOUS_NAME = 'CarouselPrevious';
|
|
111
|
+
function CarouselPrevious({ __scopeCarousel, className, size = 'icon', variant = 'outline', ...props }) {
|
|
112
|
+
const { canScrollPrev, orientation, scrollPrev } = useCarouselContext(CAROUSEL_PREVIOUS_NAME, __scopeCarousel);
|
|
113
|
+
return /*#__PURE__*/ jsxs(Button, {
|
|
114
|
+
"aria-label": "Previous slide",
|
|
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
|
+
"data-slot": "carousel-previous",
|
|
117
|
+
disabled: !canScrollPrev,
|
|
118
|
+
size: size,
|
|
119
|
+
variant: variant,
|
|
120
|
+
onClick: scrollPrev,
|
|
121
|
+
...props,
|
|
122
|
+
children: [
|
|
123
|
+
/*#__PURE__*/ jsx(ArrowLeftIcon, {}),
|
|
124
|
+
/*#__PURE__*/ jsx("span", {
|
|
125
|
+
className: "sr-only",
|
|
126
|
+
children: "Previous slide"
|
|
127
|
+
})
|
|
128
|
+
]
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const CAROUSEL_NEXT_NAME = 'CarouselNext';
|
|
132
|
+
function CarouselNext({ __scopeCarousel, className, size = 'icon', variant = 'outline', ...props }) {
|
|
133
|
+
const { canScrollNext, orientation, scrollNext } = useCarouselContext(CAROUSEL_NEXT_NAME, __scopeCarousel);
|
|
134
|
+
return /*#__PURE__*/ jsxs(Button, {
|
|
135
|
+
"aria-label": "Next slide",
|
|
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
|
+
"data-slot": "carousel-next",
|
|
138
|
+
disabled: !canScrollNext,
|
|
139
|
+
size: size,
|
|
140
|
+
variant: variant,
|
|
141
|
+
onClick: scrollNext,
|
|
142
|
+
...props,
|
|
143
|
+
children: [
|
|
144
|
+
/*#__PURE__*/ jsx(ArrowRightIcon, {}),
|
|
145
|
+
/*#__PURE__*/ jsx("span", {
|
|
146
|
+
className: "sr-only",
|
|
147
|
+
children: "Next slide"
|
|
148
|
+
})
|
|
149
|
+
]
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
export { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, createCarouselScope };
|
|
@@ -1,4 +1,251 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
6
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: definition[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.r = (exports1)=>{
|
|
17
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
18
|
+
value: 'Module'
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
21
|
+
value: true
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
})();
|
|
25
|
+
var __webpack_exports__ = {};
|
|
26
|
+
__webpack_require__.r(__webpack_exports__);
|
|
27
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
28
|
+
ChartContainer: ()=>ChartContainer,
|
|
29
|
+
ChartLegend: ()=>ChartLegend,
|
|
30
|
+
ChartTooltipContent: ()=>ChartTooltipContent,
|
|
31
|
+
ChartLegendContent: ()=>ChartLegendContent,
|
|
32
|
+
createChartScope: ()=>createChartScope,
|
|
33
|
+
ChartTooltip: ()=>ChartTooltip,
|
|
34
|
+
ChartStyle: ()=>ChartStyle
|
|
35
|
+
});
|
|
36
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
37
|
+
const tailwind_variants_namespaceObject = require("@codefast/tailwind-variants");
|
|
38
|
+
const react_context_namespaceObject = require("@radix-ui/react-context");
|
|
39
|
+
const external_react_namespaceObject = require("react");
|
|
40
|
+
const external_recharts_namespaceObject = require("recharts");
|
|
41
|
+
const THEMES = {
|
|
42
|
+
dark: '.dark',
|
|
43
|
+
light: ''
|
|
44
|
+
};
|
|
45
|
+
const CHART_PROVIDER_NAME = 'ChartProvider';
|
|
46
|
+
const [createChartContext, createChartScope] = (0, react_context_namespaceObject.createContextScope)(CHART_PROVIDER_NAME);
|
|
47
|
+
const [ChartContextProvider, useChartContext] = createChartContext(CHART_PROVIDER_NAME);
|
|
48
|
+
function ChartContainer({ __scopeChart, children, className, config, id, ...props }) {
|
|
49
|
+
const uniqueId = (0, external_react_namespaceObject.useId)();
|
|
50
|
+
const chartId = `chart-${id ?? uniqueId}`;
|
|
51
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ChartContextProvider, {
|
|
52
|
+
config: config,
|
|
53
|
+
scope: __scopeChart,
|
|
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 flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden", className),
|
|
56
|
+
"data-chart": chartId,
|
|
57
|
+
"data-slot": "chart",
|
|
58
|
+
...props,
|
|
59
|
+
children: [
|
|
60
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ChartStyle, {
|
|
61
|
+
config: config,
|
|
62
|
+
id: chartId
|
|
63
|
+
}),
|
|
64
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_recharts_namespaceObject.ResponsiveContainer, {
|
|
65
|
+
children: children
|
|
66
|
+
})
|
|
67
|
+
]
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function ChartStyle({ config, id }) {
|
|
72
|
+
const colorConfig = Object.entries(config).filter(([, itemConfig])=>itemConfig.theme ?? itemConfig.color);
|
|
73
|
+
if (0 === colorConfig.length) return null;
|
|
74
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("style", {
|
|
75
|
+
dangerouslySetInnerHTML: {
|
|
76
|
+
__html: generateChartStyles(id, colorConfig)
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const ChartTooltip = external_recharts_namespaceObject.Tooltip;
|
|
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
|
+
const { config } = useChartContext(CHART_TOOLTIP_CONTENT_NAME, __scopeChart);
|
|
84
|
+
const tooltipLabel = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
85
|
+
if (hideLabel || 0 === payload.length) return null;
|
|
86
|
+
const [item] = payload;
|
|
87
|
+
const key = safeToString(labelKey ?? item.dataKey ?? item.name ?? 'value');
|
|
88
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
89
|
+
const value = labelKey || 'string' != typeof label ? itemConfig?.label : label in config ? config[label].label ?? label : label;
|
|
90
|
+
if (labelFormatter) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
91
|
+
className: (0, tailwind_variants_namespaceObject.cn)('font-medium', labelClassName),
|
|
92
|
+
children: labelFormatter(value, payload)
|
|
93
|
+
});
|
|
94
|
+
if (!value) return null;
|
|
95
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
96
|
+
className: (0, tailwind_variants_namespaceObject.cn)('font-medium', labelClassName),
|
|
97
|
+
children: value
|
|
98
|
+
});
|
|
99
|
+
}, [
|
|
100
|
+
label,
|
|
101
|
+
labelFormatter,
|
|
102
|
+
payload,
|
|
103
|
+
hideLabel,
|
|
104
|
+
labelClassName,
|
|
105
|
+
config,
|
|
106
|
+
labelKey
|
|
107
|
+
]);
|
|
108
|
+
if (!active || 0 === payload.length) return null;
|
|
109
|
+
const nestLabel = 1 === payload.length && 'dot' !== indicator;
|
|
110
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
111
|
+
className: (0, tailwind_variants_namespaceObject.cn)('border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl', className),
|
|
112
|
+
children: [
|
|
113
|
+
nestLabel ? null : tooltipLabel,
|
|
114
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
115
|
+
className: "grid gap-1.5",
|
|
116
|
+
children: payload.map((item, index)=>{
|
|
117
|
+
const key = safeToString(nameKey ?? item.name ?? item.dataKey ?? 'value');
|
|
118
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
119
|
+
const indicatorColor = color ?? (isRecord(item.payload) && 'fill' in item.payload && 'string' == typeof item.payload.fill ? item.payload.fill : void 0) ?? item.color;
|
|
120
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
121
|
+
className: (0, tailwind_variants_namespaceObject.cn)('[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:size-2.5', 'dot' === indicator && 'items-center'),
|
|
122
|
+
children: formatter && void 0 !== item.value && item.name ? formatter(item.value, item.name, item, index, [
|
|
123
|
+
item
|
|
124
|
+
]) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
125
|
+
children: [
|
|
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)('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
|
+
}),
|
|
133
|
+
style: {
|
|
134
|
+
'--color-bg': indicatorColor,
|
|
135
|
+
'--color-border': indicatorColor
|
|
136
|
+
}
|
|
137
|
+
}),
|
|
138
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
139
|
+
className: (0, tailwind_variants_namespaceObject.cn)('flex flex-1 justify-between leading-none', nestLabel ? 'items-end' : 'items-center'),
|
|
140
|
+
children: [
|
|
141
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
142
|
+
className: "grid gap-1.5",
|
|
143
|
+
children: [
|
|
144
|
+
nestLabel ? tooltipLabel : null,
|
|
145
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
146
|
+
className: "text-muted-foreground",
|
|
147
|
+
children: itemConfig?.label ?? item.name
|
|
148
|
+
})
|
|
149
|
+
]
|
|
150
|
+
}),
|
|
151
|
+
null != item.value && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
152
|
+
className: "text-foreground font-mono font-medium tabular-nums",
|
|
153
|
+
children: 'number' == typeof item.value ? item.value.toLocaleString() : safeToString(item.value)
|
|
154
|
+
})
|
|
155
|
+
]
|
|
156
|
+
})
|
|
157
|
+
]
|
|
158
|
+
})
|
|
159
|
+
}, key);
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
]
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
const ChartLegend = external_recharts_namespaceObject.Legend;
|
|
166
|
+
const CHART_LEGEND_CONTENT_NAME = 'ChartLegendContent';
|
|
167
|
+
function ChartLegendContent({ __scopeChart, className, hideIcon = false, nameKey, payload, verticalAlign = 'bottom' }) {
|
|
168
|
+
const { config } = useChartContext(CHART_LEGEND_CONTENT_NAME, __scopeChart);
|
|
169
|
+
if (!payload?.length) return null;
|
|
170
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
171
|
+
className: (0, tailwind_variants_namespaceObject.cn)('flex items-center justify-center gap-4', 'top' === verticalAlign ? 'pb-3' : 'pt-3', className),
|
|
172
|
+
children: payload.map((item)=>{
|
|
173
|
+
let key = 'value';
|
|
174
|
+
if (nameKey) key = nameKey;
|
|
175
|
+
else if (null != item.dataKey) key = safeToString(item.dataKey);
|
|
176
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
177
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
178
|
+
className: (0, tailwind_variants_namespaceObject.cn)('[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:size-3'),
|
|
179
|
+
children: [
|
|
180
|
+
itemConfig?.icon && !hideIcon ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(itemConfig.icon, {}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
181
|
+
className: "size-2 shrink-0 rounded-md",
|
|
182
|
+
style: {
|
|
183
|
+
backgroundColor: item.color
|
|
184
|
+
}
|
|
185
|
+
}),
|
|
186
|
+
itemConfig?.label
|
|
187
|
+
]
|
|
188
|
+
}, nameKey ? safeToString(itemConfig?.color ?? '') : safeToString(item.value ?? ''));
|
|
189
|
+
})
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
function isRecord(value) {
|
|
193
|
+
return 'object' == typeof value && null !== value;
|
|
194
|
+
}
|
|
195
|
+
function getStringValue(record, key) {
|
|
196
|
+
if (key in record) {
|
|
197
|
+
const value = record[key];
|
|
198
|
+
return 'string' == typeof value ? value : void 0;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function safeToString(value) {
|
|
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
|
+
}
|
|
210
|
+
function getPayloadConfigFromPayload(config, payload, key) {
|
|
211
|
+
if (!isRecord(payload)) return;
|
|
212
|
+
const payloadPayload = isRecord(payload.payload) ? payload.payload : void 0;
|
|
213
|
+
let configLabelKey = key;
|
|
214
|
+
const payloadValue = getStringValue(payload, key);
|
|
215
|
+
if (payloadValue) configLabelKey = payloadValue;
|
|
216
|
+
else if (payloadPayload) {
|
|
217
|
+
const nestedValue = getStringValue(payloadPayload, key);
|
|
218
|
+
if (nestedValue) configLabelKey = nestedValue;
|
|
219
|
+
}
|
|
220
|
+
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
221
|
+
}
|
|
222
|
+
function generateCssVariable(key, itemConfig, theme) {
|
|
223
|
+
const color = itemConfig.theme?.[theme] ?? itemConfig.color;
|
|
224
|
+
return color ? ` --color-${key}: ${color};` : null;
|
|
225
|
+
}
|
|
226
|
+
function generateThemeStyles(theme, prefix, id, colorConfig) {
|
|
227
|
+
const cssVariables = colorConfig.map(([key, itemConfig])=>generateCssVariable(key, itemConfig, theme)).filter(Boolean).join('\n');
|
|
228
|
+
return `${prefix} [data-chart=${id}] {\n${cssVariables}\n}`;
|
|
229
|
+
}
|
|
230
|
+
function generateChartStyles(id, colorConfig) {
|
|
231
|
+
return Object.entries(THEMES).map(([theme, prefix])=>generateThemeStyles(theme, prefix, id, colorConfig)).join('\n\n');
|
|
232
|
+
}
|
|
233
|
+
exports.ChartContainer = __webpack_exports__.ChartContainer;
|
|
234
|
+
exports.ChartLegend = __webpack_exports__.ChartLegend;
|
|
235
|
+
exports.ChartLegendContent = __webpack_exports__.ChartLegendContent;
|
|
236
|
+
exports.ChartStyle = __webpack_exports__.ChartStyle;
|
|
237
|
+
exports.ChartTooltip = __webpack_exports__.ChartTooltip;
|
|
238
|
+
exports.ChartTooltipContent = __webpack_exports__.ChartTooltipContent;
|
|
239
|
+
exports.createChartScope = __webpack_exports__.createChartScope;
|
|
240
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
241
|
+
"ChartContainer",
|
|
242
|
+
"ChartLegend",
|
|
243
|
+
"ChartLegendContent",
|
|
244
|
+
"ChartStyle",
|
|
245
|
+
"ChartTooltip",
|
|
246
|
+
"ChartTooltipContent",
|
|
247
|
+
"createChartScope"
|
|
248
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
249
|
+
Object.defineProperty(exports, '__esModule', {
|
|
250
|
+
value: true
|
|
251
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import
|
|
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 * as RechartsPrimitive from 'recharts';
|
|
5
5
|
type ExtractProps<T> = T extends (props: infer P) => ReactNode ? P : never;
|
|
6
6
|
type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
7
7
|
declare const THEMES: {
|
|
@@ -22,8 +22,8 @@ type ScopedProps<P> = P & {
|
|
|
22
22
|
__scopeChart?: Scope;
|
|
23
23
|
};
|
|
24
24
|
declare const createChartScope: import("@radix-ui/react-context").CreateScope;
|
|
25
|
-
interface ChartContainerProps extends ComponentProps<
|
|
26
|
-
children: ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>[
|
|
25
|
+
interface ChartContainerProps extends ComponentProps<'div'> {
|
|
26
|
+
children: ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>['children'];
|
|
27
27
|
config: ChartConfig;
|
|
28
28
|
}
|
|
29
29
|
declare function ChartContainer({ __scopeChart, children, className, config, id, ...props }: ScopedProps<ChartContainerProps>): JSX.Element;
|
|
@@ -34,10 +34,10 @@ interface ChartStyleProps {
|
|
|
34
34
|
declare function ChartStyle({ config, id }: ChartStyleProps): ReactNode;
|
|
35
35
|
type ChartTooltipProps<TValue extends ValueType, TName extends NameType> = ComponentProps<typeof RechartsPrimitive.Tooltip<TValue, TName>>;
|
|
36
36
|
declare const ChartTooltip: typeof RechartsPrimitive.Tooltip;
|
|
37
|
-
type ChartTooltipContentProps<TValue extends ValueType, TName extends NameType> = Omit<MakeOptional<ExtractProps<ComponentProps<typeof RechartsPrimitive.Tooltip<TValue, TName>>[
|
|
37
|
+
type ChartTooltipContentProps<TValue extends ValueType, TName extends NameType> = Omit<MakeOptional<ExtractProps<ComponentProps<typeof RechartsPrimitive.Tooltip<TValue, TName>>['content']>, 'accessibilityLayer' | 'active' | 'activeIndex' | 'coordinate' | 'payload'>, 'payload'> & {
|
|
38
38
|
hideIndicator?: boolean;
|
|
39
39
|
hideLabel?: boolean;
|
|
40
|
-
indicator?:
|
|
40
|
+
indicator?: 'dashed' | 'dot' | 'line';
|
|
41
41
|
labelKey?: string;
|
|
42
42
|
nameKey?: string;
|
|
43
43
|
color?: string | undefined;
|
|
@@ -47,7 +47,7 @@ type ChartTooltipContentProps<TValue extends ValueType, TName extends NameType>
|
|
|
47
47
|
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
48
|
type ChartLegendProps = ComponentProps<typeof RechartsPrimitive.Legend>;
|
|
49
49
|
declare const ChartLegend: typeof RechartsPrimitive.Legend;
|
|
50
|
-
type ChartLegendContentProps = ComponentProps<
|
|
50
|
+
type ChartLegendContentProps = ComponentProps<'div'> & ExtractProps<RechartsPrimitive.LegendProps['content']> & {
|
|
51
51
|
hideIcon?: boolean;
|
|
52
52
|
nameKey?: string;
|
|
53
53
|
};
|