@coston/ui 0.1.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 +87 -0
- package/dist/button-BEd6_-lL.d.ts +16 -0
- package/dist/button-BEd6_-lL.d.ts.map +1 -0
- package/dist/button-CJvoztqg.js +46 -0
- package/dist/button-CJvoztqg.js.map +1 -0
- package/dist/components/accordion.d.ts +11 -0
- package/dist/components/accordion.d.ts.map +1 -0
- package/dist/components/accordion.js +38 -0
- package/dist/components/accordion.js.map +1 -0
- package/dist/components/alert-dialog.d.ts +31 -0
- package/dist/components/alert-dialog.d.ts.map +1 -0
- package/dist/components/alert-dialog.js +60 -0
- package/dist/components/alert-dialog.js.map +1 -0
- package/dist/components/alert.d.ts +13 -0
- package/dist/components/alert.d.ts.map +1 -0
- package/dist/components/alert.js +36 -0
- package/dist/components/alert.js.map +1 -0
- package/dist/components/aspect-ratio.d.ts +8 -0
- package/dist/components/aspect-ratio.d.ts.map +1 -0
- package/dist/components/aspect-ratio.js +8 -0
- package/dist/components/aspect-ratio.js.map +1 -0
- package/dist/components/avatar.d.ts +10 -0
- package/dist/components/avatar.d.ts.map +1 -0
- package/dist/components/avatar.js +28 -0
- package/dist/components/avatar.js.map +1 -0
- package/dist/components/badge.d.ts +18 -0
- package/dist/components/badge.d.ts.map +1 -0
- package/dist/components/badge.js +25 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/breadcrumb.d.ts +31 -0
- package/dist/components/breadcrumb.d.ts.map +1 -0
- package/dist/components/breadcrumb.js +66 -0
- package/dist/components/breadcrumb.js.map +1 -0
- package/dist/components/button.d.ts +2 -0
- package/dist/components/button.js +4 -0
- package/dist/components/calendar.d.ts +17 -0
- package/dist/components/calendar.d.ts.map +1 -0
- package/dist/components/calendar.js +46 -0
- package/dist/components/calendar.js.map +1 -0
- package/dist/components/card.d.ts +12 -0
- package/dist/components/card.d.ts.map +1 -0
- package/dist/components/card.js +46 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/carousel.d.ts +23 -0
- package/dist/components/carousel.d.ts.map +1 -0
- package/dist/components/carousel.js +139 -0
- package/dist/components/carousel.js.map +1 -0
- package/dist/components/chart.d.ts +32 -0
- package/dist/components/chart.d.ts.map +1 -0
- package/dist/components/chart.js +115 -0
- package/dist/components/chart.js.map +1 -0
- package/dist/components/checkbox.d.ts +8 -0
- package/dist/components/checkbox.d.ts.map +1 -0
- package/dist/components/checkbox.js +21 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/collapsible.d.ts +10 -0
- package/dist/components/collapsible.d.ts.map +1 -0
- package/dist/components/collapsible.js +13 -0
- package/dist/components/collapsible.js.map +1 -0
- package/dist/components/command.d.ts +26 -0
- package/dist/components/command.d.ts.map +1 -0
- package/dist/components/command.js +77 -0
- package/dist/components/command.js.map +1 -0
- package/dist/components/context-menu.d.ts +35 -0
- package/dist/components/context-menu.d.ts.map +1 -0
- package/dist/components/context-menu.js +82 -0
- package/dist/components/context-menu.js.map +1 -0
- package/dist/components/dialog.d.ts +30 -0
- package/dist/components/dialog.d.ts.map +1 -0
- package/dist/components/dialog.js +4 -0
- package/dist/components/drawer.d.ts +36 -0
- package/dist/components/drawer.d.ts.map +1 -0
- package/dist/components/drawer.js +53 -0
- package/dist/components/drawer.js.map +1 -0
- package/dist/components/dropdown-menu.d.ts +35 -0
- package/dist/components/dropdown-menu.d.ts.map +1 -0
- package/dist/components/dropdown-menu.js +83 -0
- package/dist/components/dropdown-menu.js.map +1 -0
- package/dist/components/hover-card.d.ts +10 -0
- package/dist/components/hover-card.d.ts.map +1 -0
- package/dist/components/hover-card.js +20 -0
- package/dist/components/hover-card.js.map +1 -0
- package/dist/components/input.d.ts +8 -0
- package/dist/components/input.d.ts.map +1 -0
- package/dist/components/input.js +18 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/label.d.ts +10 -0
- package/dist/components/label.d.ts.map +1 -0
- package/dist/components/label.js +18 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/menubar.d.ts +42 -0
- package/dist/components/menubar.d.ts.map +1 -0
- package/dist/components/menubar.js +96 -0
- package/dist/components/menubar.js.map +1 -0
- package/dist/components/navigation-menu.d.ts +17 -0
- package/dist/components/navigation-menu.d.ts.map +1 -0
- package/dist/components/navigation-menu.js +64 -0
- package/dist/components/navigation-menu.js.map +1 -0
- package/dist/components/pagination.d.ts +50 -0
- package/dist/components/pagination.d.ts.map +1 -0
- package/dist/components/pagination.js +65 -0
- package/dist/components/pagination.js.map +1 -0
- package/dist/components/popover.d.ts +10 -0
- package/dist/components/popover.d.ts.map +1 -0
- package/dist/components/popover.js +20 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/progress.d.ts +8 -0
- package/dist/components/progress.d.ts.map +1 -0
- package/dist/components/progress.js +20 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/radio-group.d.ts +9 -0
- package/dist/components/radio-group.d.ts.map +1 -0
- package/dist/components/radio-group.js +31 -0
- package/dist/components/radio-group.js.map +1 -0
- package/dist/components/resizable.d.ts +20 -0
- package/dist/components/resizable.d.ts.map +1 -0
- package/dist/components/resizable.js +24 -0
- package/dist/components/resizable.js.map +1 -0
- package/dist/components/scroll-area.d.ts +9 -0
- package/dist/components/scroll-area.d.ts.map +1 -0
- package/dist/components/scroll-area.js +32 -0
- package/dist/components/scroll-area.js.map +1 -0
- package/dist/components/select.d.ts +17 -0
- package/dist/components/select.d.ts.map +1 -0
- package/dist/components/select.js +75 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/separator.d.ts +8 -0
- package/dist/components/separator.d.ts.map +1 -0
- package/dist/components/separator.js +4 -0
- package/dist/components/sheet.d.ts +36 -0
- package/dist/components/sheet.d.ts.map +1 -0
- package/dist/components/sheet.js +69 -0
- package/dist/components/sheet.js.map +1 -0
- package/dist/components/sidebar.d.ts +54 -0
- package/dist/components/sidebar.d.ts.map +1 -0
- package/dist/components/sidebar.js +267 -0
- package/dist/components/sidebar.js.map +1 -0
- package/dist/components/skeleton.d.ts +10 -0
- package/dist/components/skeleton.d.ts.map +1 -0
- package/dist/components/skeleton.js +14 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/slider.d.ts +8 -0
- package/dist/components/slider.d.ts.map +1 -0
- package/dist/components/slider.js +20 -0
- package/dist/components/slider.js.map +1 -0
- package/dist/components/sonner.d.ts +11 -0
- package/dist/components/sonner.d.ts.map +1 -0
- package/dist/components/sonner.js +22 -0
- package/dist/components/sonner.js.map +1 -0
- package/dist/components/switch.d.ts +8 -0
- package/dist/components/switch.d.ts.map +1 -0
- package/dist/components/switch.js +17 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/table.d.ts +14 -0
- package/dist/components/table.d.ts.map +1 -0
- package/dist/components/table.js +61 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/tabs.d.ts +11 -0
- package/dist/components/tabs.d.ts.map +1 -0
- package/dist/components/tabs.js +29 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/textarea.d.ts +7 -0
- package/dist/components/textarea.d.ts.map +1 -0
- package/dist/components/textarea.js +17 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/components/toggle-group.d.ts +17 -0
- package/dist/components/toggle-group.d.ts.map +1 -0
- package/dist/components/toggle-group.js +41 -0
- package/dist/components/toggle-group.js.map +1 -0
- package/dist/components/toggle.d.ts +17 -0
- package/dist/components/toggle.d.ts.map +1 -0
- package/dist/components/toggle.js +4 -0
- package/dist/components/tooltip.d.ts +2 -0
- package/dist/components/tooltip.js +4 -0
- package/dist/dialog-B_8jhMOs.js +56 -0
- package/dist/dialog-B_8jhMOs.js.map +1 -0
- package/dist/hooks/use-mobile.d.ts +7 -0
- package/dist/hooks/use-mobile.d.ts.map +1 -0
- package/dist/hooks/use-mobile.js +3 -0
- package/dist/lib/utils.d.ts +9 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +3 -0
- package/dist/separator-9lzFsfCC.js +18 -0
- package/dist/separator-9lzFsfCC.js.map +1 -0
- package/dist/toggle-BpKiTVe4.js +38 -0
- package/dist/toggle-BpKiTVe4.js.map +1 -0
- package/dist/tooltip-CXS6wR7g.js +20 -0
- package/dist/tooltip-CXS6wR7g.js.map +1 -0
- package/dist/tooltip-DPcgBDyX.d.ts +11 -0
- package/dist/tooltip-DPcgBDyX.d.ts.map +1 -0
- package/dist/use-mobile-CixTQBWA.js +21 -0
- package/dist/use-mobile-CixTQBWA.js.map +1 -0
- package/dist/utils-C0f9Ma6r.js +11 -0
- package/dist/utils-C0f9Ma6r.js.map +1 -0
- package/package.json +168 -0
- package/src/components/accordion.tsx +51 -0
- package/src/components/alert-dialog.tsx +115 -0
- package/src/components/alert.tsx +49 -0
- package/src/components/aspect-ratio.tsx +5 -0
- package/src/components/avatar.tsx +44 -0
- package/src/components/badge.tsx +32 -0
- package/src/components/breadcrumb.tsx +101 -0
- package/src/components/button.tsx +48 -0
- package/src/components/calendar.tsx +76 -0
- package/src/components/card.tsx +60 -0
- package/src/components/carousel.tsx +240 -0
- package/src/components/chart.tsx +232 -0
- package/src/components/checkbox.tsx +25 -0
- package/src/components/collapsible.tsx +11 -0
- package/src/components/command.tsx +136 -0
- package/src/components/context-menu.tsx +187 -0
- package/src/components/dialog.tsx +105 -0
- package/src/components/drawer.tsx +98 -0
- package/src/components/dropdown-menu.tsx +185 -0
- package/src/components/hover-card.tsx +29 -0
- package/src/components/input.tsx +24 -0
- package/src/components/label.tsx +19 -0
- package/src/components/menubar.tsx +219 -0
- package/src/components/navigation-menu.tsx +120 -0
- package/src/components/pagination.tsx +98 -0
- package/src/components/popover.tsx +27 -0
- package/src/components/progress.tsx +23 -0
- package/src/components/radio-group.tsx +35 -0
- package/src/components/resizable.tsx +38 -0
- package/src/components/scroll-area.tsx +43 -0
- package/src/components/select.tsx +147 -0
- package/src/components/separator.tsx +23 -0
- package/src/components/sheet.tsx +122 -0
- package/src/components/sidebar.tsx +507 -0
- package/src/components/skeleton.tsx +7 -0
- package/src/components/slider.tsx +23 -0
- package/src/components/sonner.tsx +26 -0
- package/src/components/switch.tsx +26 -0
- package/src/components/table.tsx +95 -0
- package/src/components/tabs.tsx +53 -0
- package/src/components/textarea.tsx +20 -0
- package/src/components/toggle-group.tsx +54 -0
- package/src/components/toggle.tsx +40 -0
- package/src/components/tooltip.tsx +27 -0
- package/src/hooks/use-mobile.tsx +19 -0
- package/src/lib/utils.ts +6 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
|
3
|
+
import { DayPicker, getDefaultClassNames } from 'react-day-picker';
|
|
4
|
+
|
|
5
|
+
import { cn } from '../lib/utils';
|
|
6
|
+
|
|
7
|
+
export type CalendarProps = React.ComponentProps<typeof DayPicker>;
|
|
8
|
+
|
|
9
|
+
function Calendar({ className, classNames, ...props }: CalendarProps) {
|
|
10
|
+
const defaultClassNames = getDefaultClassNames();
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<DayPicker
|
|
14
|
+
className={cn('p-3', className)}
|
|
15
|
+
classNames={{
|
|
16
|
+
...defaultClassNames,
|
|
17
|
+
root: cn(defaultClassNames.root, className),
|
|
18
|
+
months: cn(defaultClassNames.months, 'relative'),
|
|
19
|
+
month: cn(defaultClassNames.month, 'space-y-4'),
|
|
20
|
+
month_caption: cn(
|
|
21
|
+
defaultClassNames.month_caption,
|
|
22
|
+
'flex justify-center pt-1 relative items-center mb-2 h-7'
|
|
23
|
+
),
|
|
24
|
+
caption_label: cn(defaultClassNames.caption_label, 'text-sm font-medium'),
|
|
25
|
+
nav: cn(
|
|
26
|
+
defaultClassNames.nav,
|
|
27
|
+
'absolute inset-x-1 top-0 flex items-center justify-between h-7'
|
|
28
|
+
),
|
|
29
|
+
button_previous: cn(
|
|
30
|
+
defaultClassNames.button_previous,
|
|
31
|
+
'inline-flex h-7 w-7 items-center justify-center rounded-md border border-input bg-transparent opacity-50 hover:opacity-100'
|
|
32
|
+
),
|
|
33
|
+
button_next: cn(
|
|
34
|
+
defaultClassNames.button_next,
|
|
35
|
+
'inline-flex h-7 w-7 items-center justify-center rounded-md border border-input bg-transparent opacity-50 hover:opacity-100'
|
|
36
|
+
),
|
|
37
|
+
month_grid: cn(defaultClassNames.month_grid, 'w-full border-collapse'),
|
|
38
|
+
weekdays: cn(defaultClassNames.weekdays, 'flex'),
|
|
39
|
+
weekday: cn(
|
|
40
|
+
defaultClassNames.weekday,
|
|
41
|
+
'text-muted-foreground rounded-md w-9 font-normal text-[0.8rem] text-center'
|
|
42
|
+
),
|
|
43
|
+
week: cn(defaultClassNames.week, 'flex w-full mt-2'),
|
|
44
|
+
day: cn(defaultClassNames.day, 'h-9 w-9 text-center text-sm p-0 relative'),
|
|
45
|
+
day_button: cn(
|
|
46
|
+
defaultClassNames.day_button,
|
|
47
|
+
'inline-flex h-9 w-9 items-center justify-center rounded-md text-sm font-normal hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring'
|
|
48
|
+
),
|
|
49
|
+
selected: cn(
|
|
50
|
+
defaultClassNames.selected,
|
|
51
|
+
'bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground rounded-md'
|
|
52
|
+
),
|
|
53
|
+
today: cn(defaultClassNames.today, 'bg-accent text-accent-foreground rounded-md'),
|
|
54
|
+
outside: cn(defaultClassNames.outside, 'text-muted-foreground opacity-50'),
|
|
55
|
+
disabled: cn(defaultClassNames.disabled, 'text-muted-foreground opacity-50'),
|
|
56
|
+
hidden: cn(defaultClassNames.hidden, 'invisible'),
|
|
57
|
+
range_start: cn(defaultClassNames.range_start, 'rounded-l-md'),
|
|
58
|
+
range_end: cn(defaultClassNames.range_end, 'rounded-r-md'),
|
|
59
|
+
range_middle: cn(defaultClassNames.range_middle, 'bg-accent text-accent-foreground'),
|
|
60
|
+
...classNames,
|
|
61
|
+
}}
|
|
62
|
+
components={{
|
|
63
|
+
Chevron: ({ orientation }) =>
|
|
64
|
+
orientation === 'left' ? (
|
|
65
|
+
<ChevronLeft className="h-4 w-4" />
|
|
66
|
+
) : (
|
|
67
|
+
<ChevronRight className="h-4 w-4" />
|
|
68
|
+
),
|
|
69
|
+
}}
|
|
70
|
+
{...props}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
Calendar.displayName = 'Calendar';
|
|
75
|
+
|
|
76
|
+
export { Calendar };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { cn } from '../lib/utils';
|
|
4
|
+
|
|
5
|
+
const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
6
|
+
({ className, ...props }, ref) => (
|
|
7
|
+
<div
|
|
8
|
+
ref={ref}
|
|
9
|
+
data-slot="card"
|
|
10
|
+
className={cn(
|
|
11
|
+
'rounded-lg border border-border bg-card text-card-foreground shadow-sm',
|
|
12
|
+
className
|
|
13
|
+
)}
|
|
14
|
+
{...props}
|
|
15
|
+
/>
|
|
16
|
+
)
|
|
17
|
+
);
|
|
18
|
+
Card.displayName = 'Card';
|
|
19
|
+
|
|
20
|
+
const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
21
|
+
({ className, ...props }, ref) => (
|
|
22
|
+
<div ref={ref} className={cn('flex flex-col space-y-1.5 p-6', className)} {...props} />
|
|
23
|
+
)
|
|
24
|
+
);
|
|
25
|
+
CardHeader.displayName = 'CardHeader';
|
|
26
|
+
|
|
27
|
+
const CardTitle = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLHeadingElement>>(
|
|
28
|
+
({ className, ...props }, ref) => (
|
|
29
|
+
<h3
|
|
30
|
+
ref={ref}
|
|
31
|
+
className={cn('text-2xl font-semibold leading-none tracking-tight', className)}
|
|
32
|
+
{...props}
|
|
33
|
+
/>
|
|
34
|
+
)
|
|
35
|
+
);
|
|
36
|
+
CardTitle.displayName = 'CardTitle';
|
|
37
|
+
|
|
38
|
+
const CardDescription = React.forwardRef<
|
|
39
|
+
HTMLParagraphElement,
|
|
40
|
+
React.HTMLAttributes<HTMLParagraphElement>
|
|
41
|
+
>(({ className, ...props }, ref) => (
|
|
42
|
+
<p ref={ref} className={cn('text-sm text-muted-foreground', className)} {...props} />
|
|
43
|
+
));
|
|
44
|
+
CardDescription.displayName = 'CardDescription';
|
|
45
|
+
|
|
46
|
+
const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
47
|
+
({ className, ...props }, ref) => (
|
|
48
|
+
<div ref={ref} className={cn('p-6 pt-0', className)} {...props} />
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
CardContent.displayName = 'CardContent';
|
|
52
|
+
|
|
53
|
+
const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
54
|
+
({ className, ...props }, ref) => (
|
|
55
|
+
<div ref={ref} className={cn('flex items-center p-6 pt-0', className)} {...props} />
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
CardFooter.displayName = 'CardFooter';
|
|
59
|
+
|
|
60
|
+
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import useEmblaCarousel, { type UseEmblaCarouselType } from 'embla-carousel-react';
|
|
3
|
+
import { ArrowLeft, ArrowRight } from 'lucide-react';
|
|
4
|
+
|
|
5
|
+
import { cn } from '../lib/utils';
|
|
6
|
+
import { Button } from './button';
|
|
7
|
+
|
|
8
|
+
type CarouselApi = UseEmblaCarouselType[1];
|
|
9
|
+
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
|
|
10
|
+
type CarouselOptions = UseCarouselParameters[0];
|
|
11
|
+
type CarouselPlugin = UseCarouselParameters[1];
|
|
12
|
+
|
|
13
|
+
type CarouselProps = {
|
|
14
|
+
opts?: CarouselOptions;
|
|
15
|
+
plugins?: CarouselPlugin;
|
|
16
|
+
orientation?: 'horizontal' | 'vertical';
|
|
17
|
+
setApi?: (api: CarouselApi) => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type CarouselContextProps = {
|
|
21
|
+
carouselRef: ReturnType<typeof useEmblaCarousel>[0];
|
|
22
|
+
api: ReturnType<typeof useEmblaCarousel>[1];
|
|
23
|
+
scrollPrev: () => void;
|
|
24
|
+
scrollNext: () => void;
|
|
25
|
+
canScrollPrev: boolean;
|
|
26
|
+
canScrollNext: boolean;
|
|
27
|
+
} & CarouselProps;
|
|
28
|
+
|
|
29
|
+
const CarouselContext = React.createContext<CarouselContextProps | null>(null);
|
|
30
|
+
|
|
31
|
+
function useCarousel() {
|
|
32
|
+
const context = React.useContext(CarouselContext);
|
|
33
|
+
|
|
34
|
+
if (!context) {
|
|
35
|
+
throw new Error('useCarousel must be used within a <Carousel />');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return context;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const Carousel = React.forwardRef<
|
|
42
|
+
HTMLDivElement,
|
|
43
|
+
React.HTMLAttributes<HTMLDivElement> & CarouselProps
|
|
44
|
+
>(({ orientation = 'horizontal', opts, setApi, plugins, className, children, ...props }, ref) => {
|
|
45
|
+
const [carouselRef, api] = useEmblaCarousel(
|
|
46
|
+
{
|
|
47
|
+
...opts,
|
|
48
|
+
axis: orientation === 'horizontal' ? 'x' : 'y',
|
|
49
|
+
},
|
|
50
|
+
plugins
|
|
51
|
+
);
|
|
52
|
+
const [canScrollPrev, setCanScrollPrev] = React.useState(false);
|
|
53
|
+
const [canScrollNext, setCanScrollNext] = React.useState(false);
|
|
54
|
+
|
|
55
|
+
const onSelect = React.useCallback((api: CarouselApi) => {
|
|
56
|
+
if (!api) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
setCanScrollPrev(api.canScrollPrev());
|
|
61
|
+
setCanScrollNext(api.canScrollNext());
|
|
62
|
+
}, []);
|
|
63
|
+
|
|
64
|
+
const scrollPrev = React.useCallback(() => {
|
|
65
|
+
api?.scrollPrev();
|
|
66
|
+
}, [api]);
|
|
67
|
+
|
|
68
|
+
const scrollNext = React.useCallback(() => {
|
|
69
|
+
api?.scrollNext();
|
|
70
|
+
}, [api]);
|
|
71
|
+
|
|
72
|
+
const handleKeyDown = React.useCallback(
|
|
73
|
+
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
74
|
+
if (event.key === 'ArrowLeft') {
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
scrollPrev();
|
|
77
|
+
} else if (event.key === 'ArrowRight') {
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
scrollNext();
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
[scrollPrev, scrollNext]
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
React.useEffect(() => {
|
|
86
|
+
if (!api || !setApi) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
setApi(api);
|
|
91
|
+
}, [api, setApi]);
|
|
92
|
+
|
|
93
|
+
React.useEffect(() => {
|
|
94
|
+
if (!api) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
onSelect(api);
|
|
99
|
+
api.on('reInit', onSelect);
|
|
100
|
+
api.on('select', onSelect);
|
|
101
|
+
|
|
102
|
+
return () => {
|
|
103
|
+
api?.off('select', onSelect);
|
|
104
|
+
};
|
|
105
|
+
}, [api, onSelect]);
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<CarouselContext.Provider
|
|
109
|
+
value={{
|
|
110
|
+
carouselRef,
|
|
111
|
+
api: api,
|
|
112
|
+
opts,
|
|
113
|
+
orientation: orientation || (opts?.axis === 'y' ? 'vertical' : 'horizontal'),
|
|
114
|
+
scrollPrev,
|
|
115
|
+
scrollNext,
|
|
116
|
+
canScrollPrev,
|
|
117
|
+
canScrollNext,
|
|
118
|
+
}}
|
|
119
|
+
>
|
|
120
|
+
<div
|
|
121
|
+
ref={ref}
|
|
122
|
+
onKeyDownCapture={handleKeyDown}
|
|
123
|
+
className={cn('relative', className)}
|
|
124
|
+
role="region"
|
|
125
|
+
aria-roledescription="carousel"
|
|
126
|
+
{...props}
|
|
127
|
+
>
|
|
128
|
+
{children}
|
|
129
|
+
</div>
|
|
130
|
+
</CarouselContext.Provider>
|
|
131
|
+
);
|
|
132
|
+
});
|
|
133
|
+
Carousel.displayName = 'Carousel';
|
|
134
|
+
|
|
135
|
+
const CarouselContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
136
|
+
({ className, ...props }, ref) => {
|
|
137
|
+
const { carouselRef, orientation } = useCarousel();
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<div ref={carouselRef} className="overflow-hidden">
|
|
141
|
+
<div
|
|
142
|
+
ref={ref}
|
|
143
|
+
className={cn(
|
|
144
|
+
'flex',
|
|
145
|
+
orientation === 'horizontal' ? '-ml-4' : '-mt-4 flex-col',
|
|
146
|
+
className
|
|
147
|
+
)}
|
|
148
|
+
{...props}
|
|
149
|
+
/>
|
|
150
|
+
</div>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
CarouselContent.displayName = 'CarouselContent';
|
|
155
|
+
|
|
156
|
+
const CarouselItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
157
|
+
({ className, ...props }, ref) => {
|
|
158
|
+
const { orientation } = useCarousel();
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<div
|
|
162
|
+
ref={ref}
|
|
163
|
+
role="group"
|
|
164
|
+
aria-roledescription="slide"
|
|
165
|
+
className={cn(
|
|
166
|
+
'min-w-0 shrink-0 grow-0 basis-full',
|
|
167
|
+
orientation === 'horizontal' ? 'pl-4' : 'pt-4',
|
|
168
|
+
className
|
|
169
|
+
)}
|
|
170
|
+
{...props}
|
|
171
|
+
/>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
CarouselItem.displayName = 'CarouselItem';
|
|
176
|
+
|
|
177
|
+
const CarouselPrevious = React.forwardRef<HTMLButtonElement, React.ComponentProps<typeof Button>>(
|
|
178
|
+
({ className, variant = 'outline', size = 'icon', ...props }, ref) => {
|
|
179
|
+
const { orientation, scrollPrev, canScrollPrev } = useCarousel();
|
|
180
|
+
|
|
181
|
+
return (
|
|
182
|
+
<Button
|
|
183
|
+
ref={ref}
|
|
184
|
+
variant={variant}
|
|
185
|
+
size={size}
|
|
186
|
+
className={cn(
|
|
187
|
+
'absolute h-8 w-8 rounded-full',
|
|
188
|
+
orientation === 'horizontal'
|
|
189
|
+
? 'left-2 top-1/2 -translate-y-1/2'
|
|
190
|
+
: 'top-2 left-1/2 -translate-x-1/2 rotate-90',
|
|
191
|
+
className
|
|
192
|
+
)}
|
|
193
|
+
disabled={!canScrollPrev}
|
|
194
|
+
onClick={scrollPrev}
|
|
195
|
+
{...props}
|
|
196
|
+
>
|
|
197
|
+
<ArrowLeft className="h-4 w-4" />
|
|
198
|
+
<span className="sr-only">Previous slide</span>
|
|
199
|
+
</Button>
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
);
|
|
203
|
+
CarouselPrevious.displayName = 'CarouselPrevious';
|
|
204
|
+
|
|
205
|
+
const CarouselNext = React.forwardRef<HTMLButtonElement, React.ComponentProps<typeof Button>>(
|
|
206
|
+
({ className, variant = 'outline', size = 'icon', ...props }, ref) => {
|
|
207
|
+
const { orientation, scrollNext, canScrollNext } = useCarousel();
|
|
208
|
+
|
|
209
|
+
return (
|
|
210
|
+
<Button
|
|
211
|
+
ref={ref}
|
|
212
|
+
variant={variant}
|
|
213
|
+
size={size}
|
|
214
|
+
className={cn(
|
|
215
|
+
'absolute h-8 w-8 rounded-full',
|
|
216
|
+
orientation === 'horizontal'
|
|
217
|
+
? 'right-2 top-1/2 -translate-y-1/2'
|
|
218
|
+
: 'bottom-2 left-1/2 -translate-x-1/2 rotate-90',
|
|
219
|
+
className
|
|
220
|
+
)}
|
|
221
|
+
disabled={!canScrollNext}
|
|
222
|
+
onClick={scrollNext}
|
|
223
|
+
{...props}
|
|
224
|
+
>
|
|
225
|
+
<ArrowRight className="h-4 w-4" />
|
|
226
|
+
<span className="sr-only">Next slide</span>
|
|
227
|
+
</Button>
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
);
|
|
231
|
+
CarouselNext.displayName = 'CarouselNext';
|
|
232
|
+
|
|
233
|
+
export {
|
|
234
|
+
type CarouselApi,
|
|
235
|
+
Carousel,
|
|
236
|
+
CarouselContent,
|
|
237
|
+
CarouselItem,
|
|
238
|
+
CarouselPrevious,
|
|
239
|
+
CarouselNext,
|
|
240
|
+
};
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as RechartsPrimitive from 'recharts';
|
|
3
|
+
import { cn } from '../lib/utils';
|
|
4
|
+
|
|
5
|
+
export type ChartConfig = {
|
|
6
|
+
[k in string]: {
|
|
7
|
+
label?: React.ReactNode;
|
|
8
|
+
icon?: React.ComponentType;
|
|
9
|
+
color?: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type ChartContextProps = {
|
|
14
|
+
config: ChartConfig;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const ChartContext = React.createContext<ChartContextProps | null>(null);
|
|
18
|
+
|
|
19
|
+
function useChart() {
|
|
20
|
+
const context = React.useContext(ChartContext);
|
|
21
|
+
if (!context) {
|
|
22
|
+
throw new Error('useChart must be used within a <ChartContainer />');
|
|
23
|
+
}
|
|
24
|
+
return context;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const ChartContainer = React.forwardRef<
|
|
28
|
+
HTMLDivElement,
|
|
29
|
+
React.ComponentProps<'div'> & {
|
|
30
|
+
config: ChartConfig;
|
|
31
|
+
children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>['children'];
|
|
32
|
+
}
|
|
33
|
+
>(({ id, className, children, config, ...props }, ref) => {
|
|
34
|
+
const uniqueId = React.useId();
|
|
35
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, '')}`;
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<ChartContext.Provider value={{ config }}>
|
|
39
|
+
<div
|
|
40
|
+
data-chart={chartId}
|
|
41
|
+
ref={ref}
|
|
42
|
+
className={cn(
|
|
43
|
+
"flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",
|
|
44
|
+
className
|
|
45
|
+
)}
|
|
46
|
+
style={
|
|
47
|
+
{
|
|
48
|
+
...Object.entries(config).reduce(
|
|
49
|
+
(vars, [key, value]) => {
|
|
50
|
+
if (value.color) {
|
|
51
|
+
vars[`--color-${key}`] = value.color;
|
|
52
|
+
}
|
|
53
|
+
return vars;
|
|
54
|
+
},
|
|
55
|
+
{} as Record<string, string>
|
|
56
|
+
),
|
|
57
|
+
} as React.CSSProperties
|
|
58
|
+
}
|
|
59
|
+
{...props}
|
|
60
|
+
>
|
|
61
|
+
<RechartsPrimitive.ResponsiveContainer>{children}</RechartsPrimitive.ResponsiveContainer>
|
|
62
|
+
</div>
|
|
63
|
+
</ChartContext.Provider>
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
ChartContainer.displayName = 'ChartContainer';
|
|
67
|
+
|
|
68
|
+
const ChartTooltip = RechartsPrimitive.Tooltip;
|
|
69
|
+
|
|
70
|
+
interface ChartTooltipContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
71
|
+
active?: boolean;
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
|
+
payload?: any[];
|
|
74
|
+
label?: string;
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
|
+
labelFormatter?: (value: any, payload: any[]) => React.ReactNode;
|
|
77
|
+
labelClassName?: string;
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
|
+
formatter?: (value: any, name: any, item: any, index: any, payload: any) => React.ReactNode;
|
|
80
|
+
color?: string;
|
|
81
|
+
hideLabel?: boolean;
|
|
82
|
+
hideIndicator?: boolean;
|
|
83
|
+
indicator?: 'line' | 'dot' | 'dashed';
|
|
84
|
+
nameKey?: string;
|
|
85
|
+
labelKey?: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const ChartTooltipContent = React.forwardRef<HTMLDivElement, ChartTooltipContentProps>(
|
|
89
|
+
(
|
|
90
|
+
{
|
|
91
|
+
active,
|
|
92
|
+
payload,
|
|
93
|
+
className,
|
|
94
|
+
indicator = 'dot',
|
|
95
|
+
hideLabel = false,
|
|
96
|
+
hideIndicator = false,
|
|
97
|
+
label,
|
|
98
|
+
labelFormatter,
|
|
99
|
+
labelClassName,
|
|
100
|
+
formatter,
|
|
101
|
+
color,
|
|
102
|
+
nameKey,
|
|
103
|
+
labelKey,
|
|
104
|
+
},
|
|
105
|
+
ref
|
|
106
|
+
) => {
|
|
107
|
+
const { config } = useChart();
|
|
108
|
+
|
|
109
|
+
const tooltipLabel = React.useMemo(() => {
|
|
110
|
+
if (hideLabel || !payload?.length) return null;
|
|
111
|
+
|
|
112
|
+
const [item] = payload;
|
|
113
|
+
const key = `${labelKey || item?.dataKey || item?.name || 'value'}`;
|
|
114
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
115
|
+
const value =
|
|
116
|
+
!labelKey && typeof label === 'string'
|
|
117
|
+
? config[label as keyof typeof config]?.label || label
|
|
118
|
+
: itemConfig?.label;
|
|
119
|
+
|
|
120
|
+
if (labelFormatter) {
|
|
121
|
+
return (
|
|
122
|
+
<div className={cn('font-medium', labelClassName)}>{labelFormatter(value, payload)}</div>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (!value) return null;
|
|
127
|
+
|
|
128
|
+
return <div className={cn('font-medium', labelClassName)}>{value}</div>;
|
|
129
|
+
}, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
|
|
130
|
+
|
|
131
|
+
if (!active || !payload?.length) return null;
|
|
132
|
+
|
|
133
|
+
const nestLabel = payload.length === 1 && indicator !== 'dot';
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<div
|
|
137
|
+
ref={ref}
|
|
138
|
+
className={cn(
|
|
139
|
+
'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',
|
|
140
|
+
className
|
|
141
|
+
)}
|
|
142
|
+
>
|
|
143
|
+
{!nestLabel ? tooltipLabel : null}
|
|
144
|
+
<div className="grid gap-1.5">
|
|
145
|
+
{/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}
|
|
146
|
+
{payload.map((item: any, index: number) => {
|
|
147
|
+
const key = `${nameKey || item.name || item.dataKey || 'value'}`;
|
|
148
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
149
|
+
const indicatorColor = color || item.payload?.fill || item.color;
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<div
|
|
153
|
+
key={item.dataKey || index}
|
|
154
|
+
className={cn(
|
|
155
|
+
'flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground',
|
|
156
|
+
indicator === 'dot' && 'items-center'
|
|
157
|
+
)}
|
|
158
|
+
>
|
|
159
|
+
{formatter && item?.value !== undefined && item.name ? (
|
|
160
|
+
formatter(item.value, item.name, item, index, item.payload)
|
|
161
|
+
) : (
|
|
162
|
+
<>
|
|
163
|
+
{!hideIndicator && (
|
|
164
|
+
<div
|
|
165
|
+
className={cn(
|
|
166
|
+
'shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]',
|
|
167
|
+
{
|
|
168
|
+
'h-2.5 w-2.5': indicator === 'dot',
|
|
169
|
+
'w-1': indicator === 'line',
|
|
170
|
+
'w-0 border-[1.5px] border-dashed bg-transparent':
|
|
171
|
+
indicator === 'dashed',
|
|
172
|
+
'my-0.5': nestLabel && indicator === 'dashed',
|
|
173
|
+
}
|
|
174
|
+
)}
|
|
175
|
+
style={
|
|
176
|
+
{
|
|
177
|
+
'--color-bg': indicatorColor,
|
|
178
|
+
'--color-border': indicatorColor,
|
|
179
|
+
} as React.CSSProperties
|
|
180
|
+
}
|
|
181
|
+
/>
|
|
182
|
+
)}
|
|
183
|
+
<div
|
|
184
|
+
className={cn(
|
|
185
|
+
'flex flex-1 justify-between leading-none',
|
|
186
|
+
nestLabel ? 'items-end' : 'items-center'
|
|
187
|
+
)}
|
|
188
|
+
>
|
|
189
|
+
<div className="grid gap-1.5">
|
|
190
|
+
{nestLabel ? tooltipLabel : null}
|
|
191
|
+
<span className="text-muted-foreground">
|
|
192
|
+
{itemConfig?.label || item.name}
|
|
193
|
+
</span>
|
|
194
|
+
</div>
|
|
195
|
+
{item.value !== undefined && (
|
|
196
|
+
<span className="font-mono font-medium tabular-nums text-foreground">
|
|
197
|
+
{item.value.toLocaleString()}
|
|
198
|
+
</span>
|
|
199
|
+
)}
|
|
200
|
+
</div>
|
|
201
|
+
</>
|
|
202
|
+
)}
|
|
203
|
+
</div>
|
|
204
|
+
);
|
|
205
|
+
})}
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
ChartTooltipContent.displayName = 'ChartTooltipContent';
|
|
212
|
+
|
|
213
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
214
|
+
function getPayloadConfigFromPayload(config: ChartConfig, payload: any, key: string) {
|
|
215
|
+
if (typeof payload !== 'object' || payload === null) return undefined;
|
|
216
|
+
|
|
217
|
+
const payloadPayload = payload?.payload;
|
|
218
|
+
|
|
219
|
+
let configLabelKey: string = key;
|
|
220
|
+
|
|
221
|
+
if (key in config) {
|
|
222
|
+
configLabelKey = key;
|
|
223
|
+
} else if (payloadPayload && typeof payloadPayload === 'object') {
|
|
224
|
+
if (typeof payloadPayload[key] === 'string' && payloadPayload[key] in config) {
|
|
225
|
+
configLabelKey = payloadPayload[key] as string;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export { ChartContainer, ChartTooltip, ChartTooltipContent };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
3
|
+
import { Check } from 'lucide-react';
|
|
4
|
+
import { cn } from '../lib/utils';
|
|
5
|
+
|
|
6
|
+
const Checkbox = React.forwardRef<
|
|
7
|
+
React.ComponentRef<typeof CheckboxPrimitive.Root>,
|
|
8
|
+
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
|
|
9
|
+
>(({ className, ...props }, ref) => (
|
|
10
|
+
<CheckboxPrimitive.Root
|
|
11
|
+
ref={ref}
|
|
12
|
+
className={cn(
|
|
13
|
+
'peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground',
|
|
14
|
+
className
|
|
15
|
+
)}
|
|
16
|
+
{...props}
|
|
17
|
+
>
|
|
18
|
+
<CheckboxPrimitive.Indicator className={cn('flex items-center justify-center text-current')}>
|
|
19
|
+
<Check className="h-4 w-4" />
|
|
20
|
+
</CheckboxPrimitive.Indicator>
|
|
21
|
+
</CheckboxPrimitive.Root>
|
|
22
|
+
));
|
|
23
|
+
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
|
|
24
|
+
|
|
25
|
+
export { Checkbox };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
4
|
+
|
|
5
|
+
const Collapsible = CollapsiblePrimitive.Root;
|
|
6
|
+
|
|
7
|
+
const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger;
|
|
8
|
+
|
|
9
|
+
const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent;
|
|
10
|
+
|
|
11
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent };
|