@tioelvis/next-template 2.0.8 → 2.1.4
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/package.json +8 -1
- package/src/app/components/ui/carousel.json +6 -0
- package/src/app/components/ui/carousel.tsx +236 -0
- package/src/app/components/ui/chart.json +6 -0
- package/src/app/components/ui/chart.tsx +347 -0
- package/src/app/components/ui/checkbox.json +6 -0
- package/src/app/components/ui/checkbox.tsx +30 -0
- package/src/app/components/ui/collapsible.json +6 -0
- package/src/app/components/ui/collapsible.tsx +33 -0
- package/src/app/components/ui/command.json +6 -0
- package/src/app/components/ui/command.tsx +182 -0
- package/src/app/components/ui/context-menu.json +6 -0
- package/src/app/components/ui/context-menu.tsx +249 -0
- package/src/app/components/ui/dialog.json +6 -0
- package/src/app/components/ui/dialog.tsx +141 -0
- package/src/constants.js +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tioelvis/next-template",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"description": "CLI to scaffold a Next.js + Tailwind project using shadcn/ui components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -34,6 +34,10 @@
|
|
|
34
34
|
"@radix-ui/react-alert-dialog": "^1.1.14",
|
|
35
35
|
"@radix-ui/react-aspect-ratio": "^1.1.7",
|
|
36
36
|
"@radix-ui/react-avatar": "^1.1.10",
|
|
37
|
+
"@radix-ui/react-checkbox": "^1.3.2",
|
|
38
|
+
"@radix-ui/react-collapsible": "^1.1.11",
|
|
39
|
+
"@radix-ui/react-context-menu": "^2.2.15",
|
|
40
|
+
"@radix-ui/react-dialog": "^1.1.14",
|
|
37
41
|
"@radix-ui/react-dropdown-menu": "^2.1.15",
|
|
38
42
|
"@tailwindcss/postcss": "^4.1.11",
|
|
39
43
|
"@tanstack/react-query": "^5.83.0",
|
|
@@ -43,8 +47,10 @@
|
|
|
43
47
|
"axios": "^1.11.0",
|
|
44
48
|
"class-variance-authority": "^0.7.1",
|
|
45
49
|
"clsx": "^2.1.1",
|
|
50
|
+
"cmdk": "^1.1.1",
|
|
46
51
|
"cookies-next": "^6.1.0",
|
|
47
52
|
"date-fns": "^4.1.0",
|
|
53
|
+
"embla-carousel-react": "^8.6.0",
|
|
48
54
|
"eslint": "^9.32.0",
|
|
49
55
|
"eslint-config-next": "^15.4.4",
|
|
50
56
|
"lucide-react": "^0.532.0",
|
|
@@ -54,6 +60,7 @@
|
|
|
54
60
|
"react": "^19.1.0",
|
|
55
61
|
"react-day-picker": "^9.8.1",
|
|
56
62
|
"react-dom": "^19.1.0",
|
|
63
|
+
"recharts": "^2.15.4",
|
|
57
64
|
"tailwind-merge": "^3.3.1",
|
|
58
65
|
"tailwindcss": "^4.1.11",
|
|
59
66
|
"tw-animate-css": "^1.3.6",
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import useEmblaCarousel, {
|
|
5
|
+
type UseEmblaCarouselType,
|
|
6
|
+
} from "embla-carousel-react";
|
|
7
|
+
import { ArrowLeft, ArrowRight } from "lucide-react";
|
|
8
|
+
|
|
9
|
+
import { cn } from "@/lib/utils";
|
|
10
|
+
import { Button } from "@/components/ui/button";
|
|
11
|
+
|
|
12
|
+
type CarouselApi = UseEmblaCarouselType[1];
|
|
13
|
+
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
|
|
14
|
+
type CarouselOptions = UseCarouselParameters[0];
|
|
15
|
+
type CarouselPlugin = UseCarouselParameters[1];
|
|
16
|
+
|
|
17
|
+
type CarouselProps = {
|
|
18
|
+
opts?: CarouselOptions;
|
|
19
|
+
plugins?: CarouselPlugin;
|
|
20
|
+
orientation?: "horizontal" | "vertical";
|
|
21
|
+
setApi?: (api: CarouselApi) => void;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type CarouselContextProps = {
|
|
25
|
+
carouselRef: ReturnType<typeof useEmblaCarousel>[0];
|
|
26
|
+
api: ReturnType<typeof useEmblaCarousel>[1];
|
|
27
|
+
scrollPrev: () => void;
|
|
28
|
+
scrollNext: () => void;
|
|
29
|
+
canScrollPrev: boolean;
|
|
30
|
+
canScrollNext: boolean;
|
|
31
|
+
} & CarouselProps;
|
|
32
|
+
|
|
33
|
+
const CarouselContext = React.createContext<CarouselContextProps | null>(null);
|
|
34
|
+
|
|
35
|
+
function useCarousel() {
|
|
36
|
+
const context = React.useContext(CarouselContext);
|
|
37
|
+
|
|
38
|
+
if (!context) {
|
|
39
|
+
throw new Error("useCarousel must be used within a <Carousel />");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return context;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function Carousel({
|
|
46
|
+
orientation = "horizontal",
|
|
47
|
+
opts,
|
|
48
|
+
setApi,
|
|
49
|
+
plugins,
|
|
50
|
+
className,
|
|
51
|
+
children,
|
|
52
|
+
...props
|
|
53
|
+
}: React.ComponentProps<"div"> & CarouselProps) {
|
|
54
|
+
const [carouselRef, api] = useEmblaCarousel(
|
|
55
|
+
{
|
|
56
|
+
...opts,
|
|
57
|
+
axis: orientation === "horizontal" ? "x" : "y",
|
|
58
|
+
},
|
|
59
|
+
plugins
|
|
60
|
+
);
|
|
61
|
+
const [canScrollPrev, setCanScrollPrev] = React.useState(false);
|
|
62
|
+
const [canScrollNext, setCanScrollNext] = React.useState(false);
|
|
63
|
+
|
|
64
|
+
const onSelect = React.useCallback((api: CarouselApi) => {
|
|
65
|
+
if (!api) return;
|
|
66
|
+
setCanScrollPrev(api.canScrollPrev());
|
|
67
|
+
setCanScrollNext(api.canScrollNext());
|
|
68
|
+
}, []);
|
|
69
|
+
|
|
70
|
+
const scrollPrev = React.useCallback(() => {
|
|
71
|
+
api?.scrollPrev();
|
|
72
|
+
}, [api]);
|
|
73
|
+
|
|
74
|
+
const scrollNext = React.useCallback(() => {
|
|
75
|
+
api?.scrollNext();
|
|
76
|
+
}, [api]);
|
|
77
|
+
|
|
78
|
+
const handleKeyDown = React.useCallback(
|
|
79
|
+
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
80
|
+
if (event.key === "ArrowLeft") {
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
scrollPrev();
|
|
83
|
+
} else if (event.key === "ArrowRight") {
|
|
84
|
+
event.preventDefault();
|
|
85
|
+
scrollNext();
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
[scrollPrev, scrollNext]
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
React.useEffect(() => {
|
|
92
|
+
if (!api || !setApi) return;
|
|
93
|
+
setApi(api);
|
|
94
|
+
}, [api, setApi]);
|
|
95
|
+
|
|
96
|
+
React.useEffect(() => {
|
|
97
|
+
if (!api) return;
|
|
98
|
+
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:
|
|
114
|
+
orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
|
|
115
|
+
scrollPrev,
|
|
116
|
+
scrollNext,
|
|
117
|
+
canScrollPrev,
|
|
118
|
+
canScrollNext,
|
|
119
|
+
}}>
|
|
120
|
+
<div
|
|
121
|
+
onKeyDownCapture={handleKeyDown}
|
|
122
|
+
className={cn("relative", className)}
|
|
123
|
+
role="region"
|
|
124
|
+
aria-roledescription="carousel"
|
|
125
|
+
data-slot="carousel"
|
|
126
|
+
{...props}>
|
|
127
|
+
{children}
|
|
128
|
+
</div>
|
|
129
|
+
</CarouselContext.Provider>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function CarouselContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
134
|
+
const { carouselRef, orientation } = useCarousel();
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<div
|
|
138
|
+
ref={carouselRef}
|
|
139
|
+
className="overflow-hidden"
|
|
140
|
+
data-slot="carousel-content">
|
|
141
|
+
<div
|
|
142
|
+
className={cn(
|
|
143
|
+
"flex",
|
|
144
|
+
orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
|
|
145
|
+
className
|
|
146
|
+
)}
|
|
147
|
+
{...props}
|
|
148
|
+
/>
|
|
149
|
+
</div>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function CarouselItem({ className, ...props }: React.ComponentProps<"div">) {
|
|
154
|
+
const { orientation } = useCarousel();
|
|
155
|
+
|
|
156
|
+
return (
|
|
157
|
+
<div
|
|
158
|
+
role="group"
|
|
159
|
+
aria-roledescription="slide"
|
|
160
|
+
data-slot="carousel-item"
|
|
161
|
+
className={cn(
|
|
162
|
+
"min-w-0 shrink-0 grow-0 basis-full",
|
|
163
|
+
orientation === "horizontal" ? "pl-4" : "pt-4",
|
|
164
|
+
className
|
|
165
|
+
)}
|
|
166
|
+
{...props}
|
|
167
|
+
/>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function CarouselPrevious({
|
|
172
|
+
className,
|
|
173
|
+
variant = "outline",
|
|
174
|
+
size = "icon",
|
|
175
|
+
...props
|
|
176
|
+
}: React.ComponentProps<typeof Button>) {
|
|
177
|
+
const { orientation, scrollPrev, canScrollPrev } = useCarousel();
|
|
178
|
+
|
|
179
|
+
return (
|
|
180
|
+
<Button
|
|
181
|
+
data-slot="carousel-previous"
|
|
182
|
+
variant={variant}
|
|
183
|
+
size={size}
|
|
184
|
+
className={cn(
|
|
185
|
+
"absolute size-8 rounded-full",
|
|
186
|
+
orientation === "horizontal"
|
|
187
|
+
? "top-1/2 -left-12 -translate-y-1/2"
|
|
188
|
+
: "-top-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
189
|
+
className
|
|
190
|
+
)}
|
|
191
|
+
disabled={!canScrollPrev}
|
|
192
|
+
onClick={scrollPrev}
|
|
193
|
+
{...props}>
|
|
194
|
+
<ArrowLeft />
|
|
195
|
+
<span className="sr-only">Previous slide</span>
|
|
196
|
+
</Button>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function CarouselNext({
|
|
201
|
+
className,
|
|
202
|
+
variant = "outline",
|
|
203
|
+
size = "icon",
|
|
204
|
+
...props
|
|
205
|
+
}: React.ComponentProps<typeof Button>) {
|
|
206
|
+
const { orientation, scrollNext, canScrollNext } = useCarousel();
|
|
207
|
+
|
|
208
|
+
return (
|
|
209
|
+
<Button
|
|
210
|
+
data-slot="carousel-next"
|
|
211
|
+
variant={variant}
|
|
212
|
+
size={size}
|
|
213
|
+
className={cn(
|
|
214
|
+
"absolute size-8 rounded-full",
|
|
215
|
+
orientation === "horizontal"
|
|
216
|
+
? "top-1/2 -right-12 -translate-y-1/2"
|
|
217
|
+
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
218
|
+
className
|
|
219
|
+
)}
|
|
220
|
+
disabled={!canScrollNext}
|
|
221
|
+
onClick={scrollNext}
|
|
222
|
+
{...props}>
|
|
223
|
+
<ArrowRight />
|
|
224
|
+
<span className="sr-only">Next slide</span>
|
|
225
|
+
</Button>
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export {
|
|
230
|
+
type CarouselApi,
|
|
231
|
+
Carousel,
|
|
232
|
+
CarouselContent,
|
|
233
|
+
CarouselItem,
|
|
234
|
+
CarouselPrevious,
|
|
235
|
+
CarouselNext,
|
|
236
|
+
};
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as RechartsPrimitive from "recharts";
|
|
5
|
+
|
|
6
|
+
import { cn } from "@/lib/utils";
|
|
7
|
+
|
|
8
|
+
// Format: { THEME_NAME: CSS_SELECTOR }
|
|
9
|
+
const THEMES = { light: "", dark: ".dark" } as const;
|
|
10
|
+
|
|
11
|
+
export type ChartConfig = {
|
|
12
|
+
[k in string]: {
|
|
13
|
+
label?: React.ReactNode;
|
|
14
|
+
icon?: React.ComponentType;
|
|
15
|
+
} & (
|
|
16
|
+
| { color?: string; theme?: never }
|
|
17
|
+
| { color?: never; theme: Record<keyof typeof THEMES, string> }
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type ChartContextProps = {
|
|
22
|
+
config: ChartConfig;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const ChartContext = React.createContext<ChartContextProps | null>(null);
|
|
26
|
+
|
|
27
|
+
function useChart() {
|
|
28
|
+
const context = React.useContext(ChartContext);
|
|
29
|
+
|
|
30
|
+
if (!context) {
|
|
31
|
+
throw new Error("useChart must be used within a <ChartContainer />");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return context;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function ChartContainer({
|
|
38
|
+
id,
|
|
39
|
+
className,
|
|
40
|
+
children,
|
|
41
|
+
config,
|
|
42
|
+
...props
|
|
43
|
+
}: React.ComponentProps<"div"> & {
|
|
44
|
+
config: ChartConfig;
|
|
45
|
+
children: React.ComponentProps<
|
|
46
|
+
typeof RechartsPrimitive.ResponsiveContainer
|
|
47
|
+
>["children"];
|
|
48
|
+
}) {
|
|
49
|
+
const uniqueId = React.useId();
|
|
50
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<ChartContext.Provider value={{ config }}>
|
|
54
|
+
<div
|
|
55
|
+
data-slot="chart"
|
|
56
|
+
data-chart={chartId}
|
|
57
|
+
className={cn(
|
|
58
|
+
"[&_.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",
|
|
59
|
+
className
|
|
60
|
+
)}
|
|
61
|
+
{...props}>
|
|
62
|
+
<ChartStyle id={chartId} config={config} />
|
|
63
|
+
<RechartsPrimitive.ResponsiveContainer>
|
|
64
|
+
{children}
|
|
65
|
+
</RechartsPrimitive.ResponsiveContainer>
|
|
66
|
+
</div>
|
|
67
|
+
</ChartContext.Provider>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
|
72
|
+
const colorConfig = Object.entries(config).filter(
|
|
73
|
+
([, config]) => config.theme || config.color
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
if (!colorConfig.length) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<style
|
|
82
|
+
dangerouslySetInnerHTML={{
|
|
83
|
+
__html: Object.entries(THEMES)
|
|
84
|
+
.map(
|
|
85
|
+
([theme, prefix]) => `
|
|
86
|
+
${prefix} [data-chart=${id}] {
|
|
87
|
+
${colorConfig
|
|
88
|
+
.map(([key, itemConfig]) => {
|
|
89
|
+
const color =
|
|
90
|
+
itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ||
|
|
91
|
+
itemConfig.color;
|
|
92
|
+
return color ? ` --color-${key}: ${color};` : null;
|
|
93
|
+
})
|
|
94
|
+
.join("\n")}
|
|
95
|
+
}
|
|
96
|
+
`
|
|
97
|
+
)
|
|
98
|
+
.join("\n"),
|
|
99
|
+
}}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const ChartTooltip = RechartsPrimitive.Tooltip;
|
|
105
|
+
|
|
106
|
+
function ChartTooltipContent({
|
|
107
|
+
active,
|
|
108
|
+
payload,
|
|
109
|
+
className,
|
|
110
|
+
indicator = "dot",
|
|
111
|
+
hideLabel = false,
|
|
112
|
+
hideIndicator = false,
|
|
113
|
+
label,
|
|
114
|
+
labelFormatter,
|
|
115
|
+
labelClassName,
|
|
116
|
+
formatter,
|
|
117
|
+
color,
|
|
118
|
+
nameKey,
|
|
119
|
+
labelKey,
|
|
120
|
+
}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
|
|
121
|
+
React.ComponentProps<"div"> & {
|
|
122
|
+
hideLabel?: boolean;
|
|
123
|
+
hideIndicator?: boolean;
|
|
124
|
+
indicator?: "line" | "dot" | "dashed";
|
|
125
|
+
nameKey?: string;
|
|
126
|
+
labelKey?: string;
|
|
127
|
+
}) {
|
|
128
|
+
const { config } = useChart();
|
|
129
|
+
|
|
130
|
+
const tooltipLabel = React.useMemo(() => {
|
|
131
|
+
if (hideLabel || !payload?.length) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const [item] = payload;
|
|
136
|
+
const key = `${labelKey || item?.dataKey || item?.name || "value"}`;
|
|
137
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
138
|
+
const value =
|
|
139
|
+
!labelKey && typeof label === "string"
|
|
140
|
+
? config[label as keyof typeof config]?.label || label
|
|
141
|
+
: itemConfig?.label;
|
|
142
|
+
|
|
143
|
+
if (labelFormatter) {
|
|
144
|
+
return (
|
|
145
|
+
<div className={cn("font-medium", labelClassName)}>
|
|
146
|
+
{labelFormatter(value, payload)}
|
|
147
|
+
</div>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (!value) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return <div className={cn("font-medium", labelClassName)}>{value}</div>;
|
|
156
|
+
}, [
|
|
157
|
+
label,
|
|
158
|
+
labelFormatter,
|
|
159
|
+
payload,
|
|
160
|
+
hideLabel,
|
|
161
|
+
labelClassName,
|
|
162
|
+
config,
|
|
163
|
+
labelKey,
|
|
164
|
+
]);
|
|
165
|
+
|
|
166
|
+
if (!active || !payload?.length) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<div
|
|
174
|
+
className={cn(
|
|
175
|
+
"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",
|
|
176
|
+
className
|
|
177
|
+
)}>
|
|
178
|
+
{!nestLabel ? tooltipLabel : null}
|
|
179
|
+
<div className="grid gap-1.5">
|
|
180
|
+
{payload.map((item, index) => {
|
|
181
|
+
const key = `${nameKey || item.name || item.dataKey || "value"}`;
|
|
182
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
183
|
+
const indicatorColor = color || item.payload.fill || item.color;
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<div
|
|
187
|
+
key={item.dataKey}
|
|
188
|
+
className={cn(
|
|
189
|
+
"[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",
|
|
190
|
+
indicator === "dot" && "items-center"
|
|
191
|
+
)}>
|
|
192
|
+
{formatter && item?.value !== undefined && item.name ? (
|
|
193
|
+
formatter(item.value, item.name, item, index, item.payload)
|
|
194
|
+
) : (
|
|
195
|
+
<>
|
|
196
|
+
{itemConfig?.icon ? (
|
|
197
|
+
<itemConfig.icon />
|
|
198
|
+
) : (
|
|
199
|
+
!hideIndicator && (
|
|
200
|
+
<div
|
|
201
|
+
className={cn(
|
|
202
|
+
"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
|
|
203
|
+
{
|
|
204
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
205
|
+
"w-1": indicator === "line",
|
|
206
|
+
"w-0 border-[1.5px] border-dashed bg-transparent":
|
|
207
|
+
indicator === "dashed",
|
|
208
|
+
"my-0.5": nestLabel && indicator === "dashed",
|
|
209
|
+
}
|
|
210
|
+
)}
|
|
211
|
+
style={
|
|
212
|
+
{
|
|
213
|
+
"--color-bg": indicatorColor,
|
|
214
|
+
"--color-border": indicatorColor,
|
|
215
|
+
} as React.CSSProperties
|
|
216
|
+
}
|
|
217
|
+
/>
|
|
218
|
+
)
|
|
219
|
+
)}
|
|
220
|
+
<div
|
|
221
|
+
className={cn(
|
|
222
|
+
"flex flex-1 justify-between leading-none",
|
|
223
|
+
nestLabel ? "items-end" : "items-center"
|
|
224
|
+
)}>
|
|
225
|
+
<div className="grid gap-1.5">
|
|
226
|
+
{nestLabel ? tooltipLabel : null}
|
|
227
|
+
<span className="text-muted-foreground">
|
|
228
|
+
{itemConfig?.label || item.name}
|
|
229
|
+
</span>
|
|
230
|
+
</div>
|
|
231
|
+
{item.value && (
|
|
232
|
+
<span className="text-foreground font-mono font-medium tabular-nums">
|
|
233
|
+
{item.value.toLocaleString()}
|
|
234
|
+
</span>
|
|
235
|
+
)}
|
|
236
|
+
</div>
|
|
237
|
+
</>
|
|
238
|
+
)}
|
|
239
|
+
</div>
|
|
240
|
+
);
|
|
241
|
+
})}
|
|
242
|
+
</div>
|
|
243
|
+
</div>
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const ChartLegend = RechartsPrimitive.Legend;
|
|
248
|
+
|
|
249
|
+
function ChartLegendContent({
|
|
250
|
+
className,
|
|
251
|
+
hideIcon = false,
|
|
252
|
+
payload,
|
|
253
|
+
verticalAlign = "bottom",
|
|
254
|
+
nameKey,
|
|
255
|
+
}: React.ComponentProps<"div"> &
|
|
256
|
+
Pick<RechartsPrimitive.LegendProps, "payload" | "verticalAlign"> & {
|
|
257
|
+
hideIcon?: boolean;
|
|
258
|
+
nameKey?: string;
|
|
259
|
+
}) {
|
|
260
|
+
const { config } = useChart();
|
|
261
|
+
|
|
262
|
+
if (!payload?.length) {
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return (
|
|
267
|
+
<div
|
|
268
|
+
className={cn(
|
|
269
|
+
"flex items-center justify-center gap-4",
|
|
270
|
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
|
271
|
+
className
|
|
272
|
+
)}>
|
|
273
|
+
{payload.map((item) => {
|
|
274
|
+
const key = `${nameKey || item.dataKey || "value"}`;
|
|
275
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
276
|
+
|
|
277
|
+
return (
|
|
278
|
+
<div
|
|
279
|
+
key={item.value}
|
|
280
|
+
className={cn(
|
|
281
|
+
"[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"
|
|
282
|
+
)}>
|
|
283
|
+
{itemConfig?.icon && !hideIcon ? (
|
|
284
|
+
<itemConfig.icon />
|
|
285
|
+
) : (
|
|
286
|
+
<div
|
|
287
|
+
className="h-2 w-2 shrink-0 rounded-[2px]"
|
|
288
|
+
style={{
|
|
289
|
+
backgroundColor: item.color,
|
|
290
|
+
}}
|
|
291
|
+
/>
|
|
292
|
+
)}
|
|
293
|
+
{itemConfig?.label}
|
|
294
|
+
</div>
|
|
295
|
+
);
|
|
296
|
+
})}
|
|
297
|
+
</div>
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// Helper to extract item config from a payload.
|
|
302
|
+
function getPayloadConfigFromPayload(
|
|
303
|
+
config: ChartConfig,
|
|
304
|
+
payload: unknown,
|
|
305
|
+
key: string
|
|
306
|
+
) {
|
|
307
|
+
if (typeof payload !== "object" || payload === null) {
|
|
308
|
+
return undefined;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const payloadPayload =
|
|
312
|
+
"payload" in payload &&
|
|
313
|
+
typeof payload.payload === "object" &&
|
|
314
|
+
payload.payload !== null
|
|
315
|
+
? payload.payload
|
|
316
|
+
: undefined;
|
|
317
|
+
|
|
318
|
+
let configLabelKey: string = key;
|
|
319
|
+
|
|
320
|
+
if (
|
|
321
|
+
key in payload &&
|
|
322
|
+
typeof payload[key as keyof typeof payload] === "string"
|
|
323
|
+
) {
|
|
324
|
+
configLabelKey = payload[key as keyof typeof payload] as string;
|
|
325
|
+
} else if (
|
|
326
|
+
payloadPayload &&
|
|
327
|
+
key in payloadPayload &&
|
|
328
|
+
typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
|
|
329
|
+
) {
|
|
330
|
+
configLabelKey = payloadPayload[
|
|
331
|
+
key as keyof typeof payloadPayload
|
|
332
|
+
] as string;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
return configLabelKey in config
|
|
336
|
+
? config[configLabelKey]
|
|
337
|
+
: config[key as keyof typeof config];
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export {
|
|
341
|
+
ChartContainer,
|
|
342
|
+
ChartTooltip,
|
|
343
|
+
ChartTooltipContent,
|
|
344
|
+
ChartLegend,
|
|
345
|
+
ChartLegendContent,
|
|
346
|
+
ChartStyle,
|
|
347
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
5
|
+
import { CheckIcon } from "lucide-react";
|
|
6
|
+
|
|
7
|
+
import { cn } from "@/lib/utils";
|
|
8
|
+
|
|
9
|
+
function Checkbox({
|
|
10
|
+
className,
|
|
11
|
+
...props
|
|
12
|
+
}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
|
|
13
|
+
return (
|
|
14
|
+
<CheckboxPrimitive.Root
|
|
15
|
+
data-slot="checkbox"
|
|
16
|
+
className={cn(
|
|
17
|
+
"peer border-input cursor-pointer dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
|
|
18
|
+
className
|
|
19
|
+
)}
|
|
20
|
+
{...props}>
|
|
21
|
+
<CheckboxPrimitive.Indicator
|
|
22
|
+
data-slot="checkbox-indicator"
|
|
23
|
+
className="flex items-center justify-center text-current transition-none ">
|
|
24
|
+
<CheckIcon className="size-3.5" />
|
|
25
|
+
</CheckboxPrimitive.Indicator>
|
|
26
|
+
</CheckboxPrimitive.Root>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { Checkbox };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
|
4
|
+
|
|
5
|
+
function Collapsible({
|
|
6
|
+
...props
|
|
7
|
+
}: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
|
|
8
|
+
return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function CollapsibleTrigger({
|
|
12
|
+
...props
|
|
13
|
+
}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {
|
|
14
|
+
return (
|
|
15
|
+
<CollapsiblePrimitive.CollapsibleTrigger
|
|
16
|
+
data-slot="collapsible-trigger"
|
|
17
|
+
{...props}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function CollapsibleContent({
|
|
23
|
+
...props
|
|
24
|
+
}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {
|
|
25
|
+
return (
|
|
26
|
+
<CollapsiblePrimitive.CollapsibleContent
|
|
27
|
+
data-slot="collapsible-content"
|
|
28
|
+
{...props}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent };
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Command as CommandPrimitive } from "cmdk";
|
|
5
|
+
import { SearchIcon } from "lucide-react";
|
|
6
|
+
|
|
7
|
+
import { cn } from "@/lib/utils";
|
|
8
|
+
import {
|
|
9
|
+
Dialog,
|
|
10
|
+
DialogContent,
|
|
11
|
+
DialogDescription,
|
|
12
|
+
DialogHeader,
|
|
13
|
+
DialogTitle,
|
|
14
|
+
} from "@/components/ui/dialog";
|
|
15
|
+
|
|
16
|
+
function Command({
|
|
17
|
+
className,
|
|
18
|
+
...props
|
|
19
|
+
}: React.ComponentProps<typeof CommandPrimitive>) {
|
|
20
|
+
return (
|
|
21
|
+
<CommandPrimitive
|
|
22
|
+
data-slot="command"
|
|
23
|
+
className={cn(
|
|
24
|
+
"bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",
|
|
25
|
+
className
|
|
26
|
+
)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function CommandDialog({
|
|
33
|
+
title = "Command Palette",
|
|
34
|
+
description = "Search for a command to run...",
|
|
35
|
+
children,
|
|
36
|
+
className,
|
|
37
|
+
showCloseButton = true,
|
|
38
|
+
...props
|
|
39
|
+
}: React.ComponentProps<typeof Dialog> & {
|
|
40
|
+
title?: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
className?: string;
|
|
43
|
+
showCloseButton?: boolean;
|
|
44
|
+
}) {
|
|
45
|
+
return (
|
|
46
|
+
<Dialog {...props}>
|
|
47
|
+
<DialogHeader className="sr-only">
|
|
48
|
+
<DialogTitle>{title}</DialogTitle>
|
|
49
|
+
<DialogDescription>{description}</DialogDescription>
|
|
50
|
+
</DialogHeader>
|
|
51
|
+
<DialogContent
|
|
52
|
+
className={cn("overflow-hidden p-0", className)}
|
|
53
|
+
showCloseButton={showCloseButton}>
|
|
54
|
+
<Command className="[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
|
|
55
|
+
{children}
|
|
56
|
+
</Command>
|
|
57
|
+
</DialogContent>
|
|
58
|
+
</Dialog>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function CommandInput({
|
|
63
|
+
className,
|
|
64
|
+
...props
|
|
65
|
+
}: React.ComponentProps<typeof CommandPrimitive.Input>) {
|
|
66
|
+
return (
|
|
67
|
+
<div
|
|
68
|
+
data-slot="command-input-wrapper"
|
|
69
|
+
className="flex h-9 items-center gap-2 border-b px-3">
|
|
70
|
+
<SearchIcon className="size-4 shrink-0 opacity-50" />
|
|
71
|
+
<CommandPrimitive.Input
|
|
72
|
+
data-slot="command-input"
|
|
73
|
+
className={cn(
|
|
74
|
+
"placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
|
|
75
|
+
className
|
|
76
|
+
)}
|
|
77
|
+
{...props}
|
|
78
|
+
/>
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function CommandList({
|
|
84
|
+
className,
|
|
85
|
+
...props
|
|
86
|
+
}: React.ComponentProps<typeof CommandPrimitive.List>) {
|
|
87
|
+
return (
|
|
88
|
+
<CommandPrimitive.List
|
|
89
|
+
data-slot="command-list"
|
|
90
|
+
className={cn(
|
|
91
|
+
"max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",
|
|
92
|
+
className
|
|
93
|
+
)}
|
|
94
|
+
{...props}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function CommandEmpty({
|
|
100
|
+
...props
|
|
101
|
+
}: React.ComponentProps<typeof CommandPrimitive.Empty>) {
|
|
102
|
+
return (
|
|
103
|
+
<CommandPrimitive.Empty
|
|
104
|
+
data-slot="command-empty"
|
|
105
|
+
className="py-6 text-center text-sm"
|
|
106
|
+
{...props}
|
|
107
|
+
/>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function CommandGroup({
|
|
112
|
+
className,
|
|
113
|
+
...props
|
|
114
|
+
}: React.ComponentProps<typeof CommandPrimitive.Group>) {
|
|
115
|
+
return (
|
|
116
|
+
<CommandPrimitive.Group
|
|
117
|
+
data-slot="command-group"
|
|
118
|
+
className={cn(
|
|
119
|
+
"text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",
|
|
120
|
+
className
|
|
121
|
+
)}
|
|
122
|
+
{...props}
|
|
123
|
+
/>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function CommandSeparator({
|
|
128
|
+
className,
|
|
129
|
+
...props
|
|
130
|
+
}: React.ComponentProps<typeof CommandPrimitive.Separator>) {
|
|
131
|
+
return (
|
|
132
|
+
<CommandPrimitive.Separator
|
|
133
|
+
data-slot="command-separator"
|
|
134
|
+
className={cn("bg-border -mx-1 h-px", className)}
|
|
135
|
+
{...props}
|
|
136
|
+
/>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function CommandItem({
|
|
141
|
+
className,
|
|
142
|
+
...props
|
|
143
|
+
}: React.ComponentProps<typeof CommandPrimitive.Item>) {
|
|
144
|
+
return (
|
|
145
|
+
<CommandPrimitive.Item
|
|
146
|
+
data-slot="command-item"
|
|
147
|
+
className={cn(
|
|
148
|
+
"data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
149
|
+
className
|
|
150
|
+
)}
|
|
151
|
+
{...props}
|
|
152
|
+
/>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function CommandShortcut({
|
|
157
|
+
className,
|
|
158
|
+
...props
|
|
159
|
+
}: React.ComponentProps<"span">) {
|
|
160
|
+
return (
|
|
161
|
+
<span
|
|
162
|
+
data-slot="command-shortcut"
|
|
163
|
+
className={cn(
|
|
164
|
+
"text-muted-foreground ml-auto text-xs tracking-widest",
|
|
165
|
+
className
|
|
166
|
+
)}
|
|
167
|
+
{...props}
|
|
168
|
+
/>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export {
|
|
173
|
+
Command,
|
|
174
|
+
CommandDialog,
|
|
175
|
+
CommandInput,
|
|
176
|
+
CommandList,
|
|
177
|
+
CommandEmpty,
|
|
178
|
+
CommandGroup,
|
|
179
|
+
CommandItem,
|
|
180
|
+
CommandShortcut,
|
|
181
|
+
CommandSeparator,
|
|
182
|
+
};
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as ContextMenuPrimitive from "@radix-ui/react-context-menu";
|
|
5
|
+
import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react";
|
|
6
|
+
|
|
7
|
+
import { cn } from "@/lib/utils";
|
|
8
|
+
|
|
9
|
+
function ContextMenu({
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Root>) {
|
|
12
|
+
return <ContextMenuPrimitive.Root data-slot="context-menu" {...props} />;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function ContextMenuTrigger({
|
|
16
|
+
...props
|
|
17
|
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Trigger>) {
|
|
18
|
+
return (
|
|
19
|
+
<ContextMenuPrimitive.Trigger data-slot="context-menu-trigger" {...props} />
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function ContextMenuGroup({
|
|
24
|
+
...props
|
|
25
|
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Group>) {
|
|
26
|
+
return (
|
|
27
|
+
<ContextMenuPrimitive.Group data-slot="context-menu-group" {...props} />
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function ContextMenuPortal({
|
|
32
|
+
...props
|
|
33
|
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Portal>) {
|
|
34
|
+
return (
|
|
35
|
+
<ContextMenuPrimitive.Portal data-slot="context-menu-portal" {...props} />
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function ContextMenuSub({
|
|
40
|
+
...props
|
|
41
|
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Sub>) {
|
|
42
|
+
return <ContextMenuPrimitive.Sub data-slot="context-menu-sub" {...props} />;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function ContextMenuRadioGroup({
|
|
46
|
+
...props
|
|
47
|
+
}: React.ComponentProps<typeof ContextMenuPrimitive.RadioGroup>) {
|
|
48
|
+
return (
|
|
49
|
+
<ContextMenuPrimitive.RadioGroup
|
|
50
|
+
data-slot="context-menu-radio-group"
|
|
51
|
+
{...props}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function ContextMenuSubTrigger({
|
|
57
|
+
className,
|
|
58
|
+
inset,
|
|
59
|
+
children,
|
|
60
|
+
...props
|
|
61
|
+
}: React.ComponentProps<typeof ContextMenuPrimitive.SubTrigger> & {
|
|
62
|
+
inset?: boolean;
|
|
63
|
+
}) {
|
|
64
|
+
return (
|
|
65
|
+
<ContextMenuPrimitive.SubTrigger
|
|
66
|
+
data-slot="context-menu-sub-trigger"
|
|
67
|
+
data-inset={inset}
|
|
68
|
+
className={cn(
|
|
69
|
+
"focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
70
|
+
className
|
|
71
|
+
)}
|
|
72
|
+
{...props}>
|
|
73
|
+
{children}
|
|
74
|
+
<ChevronRightIcon className="ml-auto" />
|
|
75
|
+
</ContextMenuPrimitive.SubTrigger>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function ContextMenuSubContent({
|
|
80
|
+
className,
|
|
81
|
+
...props
|
|
82
|
+
}: React.ComponentProps<typeof ContextMenuPrimitive.SubContent>) {
|
|
83
|
+
return (
|
|
84
|
+
<ContextMenuPrimitive.SubContent
|
|
85
|
+
data-slot="context-menu-sub-content"
|
|
86
|
+
className={cn(
|
|
87
|
+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-context-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg",
|
|
88
|
+
className
|
|
89
|
+
)}
|
|
90
|
+
{...props}
|
|
91
|
+
/>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function ContextMenuContent({
|
|
96
|
+
className,
|
|
97
|
+
...props
|
|
98
|
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Content>) {
|
|
99
|
+
return (
|
|
100
|
+
<ContextMenuPrimitive.Portal>
|
|
101
|
+
<ContextMenuPrimitive.Content
|
|
102
|
+
data-slot="context-menu-content"
|
|
103
|
+
className={cn(
|
|
104
|
+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-context-menu-content-available-height) min-w-[8rem] origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",
|
|
105
|
+
className
|
|
106
|
+
)}
|
|
107
|
+
{...props}
|
|
108
|
+
/>
|
|
109
|
+
</ContextMenuPrimitive.Portal>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function ContextMenuItem({
|
|
114
|
+
className,
|
|
115
|
+
inset,
|
|
116
|
+
variant = "default",
|
|
117
|
+
...props
|
|
118
|
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Item> & {
|
|
119
|
+
inset?: boolean;
|
|
120
|
+
variant?: "default" | "destructive";
|
|
121
|
+
}) {
|
|
122
|
+
return (
|
|
123
|
+
<ContextMenuPrimitive.Item
|
|
124
|
+
data-slot="context-menu-item"
|
|
125
|
+
data-inset={inset}
|
|
126
|
+
data-variant={variant}
|
|
127
|
+
className={cn(
|
|
128
|
+
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
129
|
+
className
|
|
130
|
+
)}
|
|
131
|
+
{...props}
|
|
132
|
+
/>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function ContextMenuCheckboxItem({
|
|
137
|
+
className,
|
|
138
|
+
children,
|
|
139
|
+
checked,
|
|
140
|
+
...props
|
|
141
|
+
}: React.ComponentProps<typeof ContextMenuPrimitive.CheckboxItem>) {
|
|
142
|
+
return (
|
|
143
|
+
<ContextMenuPrimitive.CheckboxItem
|
|
144
|
+
data-slot="context-menu-checkbox-item"
|
|
145
|
+
className={cn(
|
|
146
|
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
147
|
+
className
|
|
148
|
+
)}
|
|
149
|
+
checked={checked}
|
|
150
|
+
{...props}>
|
|
151
|
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
|
152
|
+
<ContextMenuPrimitive.ItemIndicator>
|
|
153
|
+
<CheckIcon className="size-4" />
|
|
154
|
+
</ContextMenuPrimitive.ItemIndicator>
|
|
155
|
+
</span>
|
|
156
|
+
{children}
|
|
157
|
+
</ContextMenuPrimitive.CheckboxItem>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function ContextMenuRadioItem({
|
|
162
|
+
className,
|
|
163
|
+
children,
|
|
164
|
+
...props
|
|
165
|
+
}: React.ComponentProps<typeof ContextMenuPrimitive.RadioItem>) {
|
|
166
|
+
return (
|
|
167
|
+
<ContextMenuPrimitive.RadioItem
|
|
168
|
+
data-slot="context-menu-radio-item"
|
|
169
|
+
className={cn(
|
|
170
|
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
171
|
+
className
|
|
172
|
+
)}
|
|
173
|
+
{...props}>
|
|
174
|
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
|
175
|
+
<ContextMenuPrimitive.ItemIndicator>
|
|
176
|
+
<CircleIcon className="size-2 fill-current" />
|
|
177
|
+
</ContextMenuPrimitive.ItemIndicator>
|
|
178
|
+
</span>
|
|
179
|
+
{children}
|
|
180
|
+
</ContextMenuPrimitive.RadioItem>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function ContextMenuLabel({
|
|
185
|
+
className,
|
|
186
|
+
inset,
|
|
187
|
+
...props
|
|
188
|
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Label> & {
|
|
189
|
+
inset?: boolean;
|
|
190
|
+
}) {
|
|
191
|
+
return (
|
|
192
|
+
<ContextMenuPrimitive.Label
|
|
193
|
+
data-slot="context-menu-label"
|
|
194
|
+
data-inset={inset}
|
|
195
|
+
className={cn(
|
|
196
|
+
"text-foreground px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",
|
|
197
|
+
className
|
|
198
|
+
)}
|
|
199
|
+
{...props}
|
|
200
|
+
/>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function ContextMenuSeparator({
|
|
205
|
+
className,
|
|
206
|
+
...props
|
|
207
|
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Separator>) {
|
|
208
|
+
return (
|
|
209
|
+
<ContextMenuPrimitive.Separator
|
|
210
|
+
data-slot="context-menu-separator"
|
|
211
|
+
className={cn("bg-border -mx-1 my-1 h-px", className)}
|
|
212
|
+
{...props}
|
|
213
|
+
/>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function ContextMenuShortcut({
|
|
218
|
+
className,
|
|
219
|
+
...props
|
|
220
|
+
}: React.ComponentProps<"span">) {
|
|
221
|
+
return (
|
|
222
|
+
<span
|
|
223
|
+
data-slot="context-menu-shortcut"
|
|
224
|
+
className={cn(
|
|
225
|
+
"text-muted-foreground ml-auto text-xs tracking-widest",
|
|
226
|
+
className
|
|
227
|
+
)}
|
|
228
|
+
{...props}
|
|
229
|
+
/>
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export {
|
|
234
|
+
ContextMenu,
|
|
235
|
+
ContextMenuTrigger,
|
|
236
|
+
ContextMenuContent,
|
|
237
|
+
ContextMenuItem,
|
|
238
|
+
ContextMenuCheckboxItem,
|
|
239
|
+
ContextMenuRadioItem,
|
|
240
|
+
ContextMenuLabel,
|
|
241
|
+
ContextMenuSeparator,
|
|
242
|
+
ContextMenuShortcut,
|
|
243
|
+
ContextMenuGroup,
|
|
244
|
+
ContextMenuPortal,
|
|
245
|
+
ContextMenuSub,
|
|
246
|
+
ContextMenuSubContent,
|
|
247
|
+
ContextMenuSubTrigger,
|
|
248
|
+
ContextMenuRadioGroup,
|
|
249
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
5
|
+
import { XIcon } from "lucide-react";
|
|
6
|
+
|
|
7
|
+
import { cn } from "@/lib/utils";
|
|
8
|
+
|
|
9
|
+
function Dialog({
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
|
12
|
+
return <DialogPrimitive.Root data-slot="dialog" {...props} />;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function DialogTrigger({
|
|
16
|
+
...props
|
|
17
|
+
}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
|
|
18
|
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function DialogPortal({
|
|
22
|
+
...props
|
|
23
|
+
}: React.ComponentProps<typeof DialogPrimitive.Portal>) {
|
|
24
|
+
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function DialogClose({
|
|
28
|
+
...props
|
|
29
|
+
}: React.ComponentProps<typeof DialogPrimitive.Close>) {
|
|
30
|
+
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function DialogOverlay({
|
|
34
|
+
className,
|
|
35
|
+
...props
|
|
36
|
+
}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
|
37
|
+
return (
|
|
38
|
+
<DialogPrimitive.Overlay
|
|
39
|
+
data-slot="dialog-overlay"
|
|
40
|
+
className={cn(
|
|
41
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
|
|
42
|
+
className
|
|
43
|
+
)}
|
|
44
|
+
{...props}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function DialogContent({
|
|
50
|
+
className,
|
|
51
|
+
children,
|
|
52
|
+
showCloseButton = true,
|
|
53
|
+
...props
|
|
54
|
+
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
55
|
+
showCloseButton?: boolean;
|
|
56
|
+
}) {
|
|
57
|
+
return (
|
|
58
|
+
<DialogPortal data-slot="dialog-portal">
|
|
59
|
+
<DialogOverlay />
|
|
60
|
+
<DialogPrimitive.Content
|
|
61
|
+
data-slot="dialog-content"
|
|
62
|
+
className={cn(
|
|
63
|
+
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
|
|
64
|
+
className
|
|
65
|
+
)}
|
|
66
|
+
{...props}>
|
|
67
|
+
{children}
|
|
68
|
+
{showCloseButton && (
|
|
69
|
+
<DialogPrimitive.Close
|
|
70
|
+
data-slot="dialog-close"
|
|
71
|
+
className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4">
|
|
72
|
+
<XIcon />
|
|
73
|
+
<span className="sr-only">Close</span>
|
|
74
|
+
</DialogPrimitive.Close>
|
|
75
|
+
)}
|
|
76
|
+
</DialogPrimitive.Content>
|
|
77
|
+
</DialogPortal>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
82
|
+
return (
|
|
83
|
+
<div
|
|
84
|
+
data-slot="dialog-header"
|
|
85
|
+
className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
|
|
86
|
+
{...props}
|
|
87
|
+
/>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
92
|
+
return (
|
|
93
|
+
<div
|
|
94
|
+
data-slot="dialog-footer"
|
|
95
|
+
className={cn(
|
|
96
|
+
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
|
97
|
+
className
|
|
98
|
+
)}
|
|
99
|
+
{...props}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function DialogTitle({
|
|
105
|
+
className,
|
|
106
|
+
...props
|
|
107
|
+
}: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
|
108
|
+
return (
|
|
109
|
+
<DialogPrimitive.Title
|
|
110
|
+
data-slot="dialog-title"
|
|
111
|
+
className={cn("text-lg leading-none font-semibold", className)}
|
|
112
|
+
{...props}
|
|
113
|
+
/>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function DialogDescription({
|
|
118
|
+
className,
|
|
119
|
+
...props
|
|
120
|
+
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
|
121
|
+
return (
|
|
122
|
+
<DialogPrimitive.Description
|
|
123
|
+
data-slot="dialog-description"
|
|
124
|
+
className={cn("text-muted-foreground text-sm", className)}
|
|
125
|
+
{...props}
|
|
126
|
+
/>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export {
|
|
131
|
+
Dialog,
|
|
132
|
+
DialogClose,
|
|
133
|
+
DialogContent,
|
|
134
|
+
DialogDescription,
|
|
135
|
+
DialogFooter,
|
|
136
|
+
DialogHeader,
|
|
137
|
+
DialogOverlay,
|
|
138
|
+
DialogPortal,
|
|
139
|
+
DialogTitle,
|
|
140
|
+
DialogTrigger,
|
|
141
|
+
};
|