@coze-arch/cli 0.0.1-alpha.f74941 → 0.0.1-beta.6

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.
Files changed (112) hide show
  1. package/lib/__templates__/expo/.cozeproj/scripts/deploy_run.sh +1 -1
  2. package/lib/__templates__/expo/app.json +1 -1
  3. package/lib/__templates__/expo/client/index.js +2 -1
  4. package/lib/__templates__/expo/client/scripts/install-missing-deps.js +36 -12
  5. package/lib/__templates__/expo/metro.config.js +15 -15
  6. package/lib/__templates__/expo/package.json +14 -5
  7. package/lib/__templates__/expo/pnpm-lock.yaml +335 -4
  8. package/lib/__templates__/nextjs/.babelrc +15 -0
  9. package/lib/__templates__/nextjs/README.md +341 -19
  10. package/lib/__templates__/nextjs/components.json +21 -0
  11. package/lib/__templates__/nextjs/package.json +48 -1
  12. package/lib/__templates__/nextjs/pnpm-lock.yaml +6399 -1356
  13. package/lib/__templates__/nextjs/scripts/dev.sh +2 -1
  14. package/lib/__templates__/nextjs/server.mjs +50 -0
  15. package/lib/__templates__/nextjs/src/app/globals.css +99 -8
  16. package/lib/__templates__/nextjs/src/app/layout.tsx +4 -0
  17. package/lib/__templates__/nextjs/src/components/ui/accordion.tsx +66 -0
  18. package/lib/__templates__/nextjs/src/components/ui/alert-dialog.tsx +157 -0
  19. package/lib/__templates__/nextjs/src/components/ui/alert.tsx +66 -0
  20. package/lib/__templates__/nextjs/src/components/ui/aspect-ratio.tsx +11 -0
  21. package/lib/__templates__/nextjs/src/components/ui/avatar.tsx +53 -0
  22. package/lib/__templates__/nextjs/src/components/ui/badge.tsx +46 -0
  23. package/lib/__templates__/nextjs/src/components/ui/breadcrumb.tsx +109 -0
  24. package/lib/__templates__/nextjs/src/components/ui/button-group.tsx +83 -0
  25. package/lib/__templates__/nextjs/src/components/ui/button.tsx +62 -0
  26. package/lib/__templates__/nextjs/src/components/ui/calendar.tsx +220 -0
  27. package/lib/__templates__/nextjs/src/components/ui/card.tsx +92 -0
  28. package/lib/__templates__/nextjs/src/components/ui/carousel.tsx +241 -0
  29. package/lib/__templates__/nextjs/src/components/ui/chart.tsx +357 -0
  30. package/lib/__templates__/nextjs/src/components/ui/checkbox.tsx +32 -0
  31. package/lib/__templates__/nextjs/src/components/ui/collapsible.tsx +33 -0
  32. package/lib/__templates__/nextjs/src/components/ui/command.tsx +184 -0
  33. package/lib/__templates__/nextjs/src/components/ui/context-menu.tsx +252 -0
  34. package/lib/__templates__/nextjs/src/components/ui/dialog.tsx +143 -0
  35. package/lib/__templates__/nextjs/src/components/ui/drawer.tsx +135 -0
  36. package/lib/__templates__/nextjs/src/components/ui/dropdown-menu.tsx +257 -0
  37. package/lib/__templates__/nextjs/src/components/ui/empty.tsx +104 -0
  38. package/lib/__templates__/nextjs/src/components/ui/field.tsx +248 -0
  39. package/lib/__templates__/nextjs/src/components/ui/form.tsx +167 -0
  40. package/lib/__templates__/nextjs/src/components/ui/hover-card.tsx +44 -0
  41. package/lib/__templates__/nextjs/src/components/ui/input-group.tsx +170 -0
  42. package/lib/__templates__/nextjs/src/components/ui/input-otp.tsx +77 -0
  43. package/lib/__templates__/nextjs/src/components/ui/input.tsx +21 -0
  44. package/lib/__templates__/nextjs/src/components/ui/item.tsx +193 -0
  45. package/lib/__templates__/nextjs/src/components/ui/kbd.tsx +28 -0
  46. package/lib/__templates__/nextjs/src/components/ui/label.tsx +24 -0
  47. package/lib/__templates__/nextjs/src/components/ui/menubar.tsx +276 -0
  48. package/lib/__templates__/nextjs/src/components/ui/navigation-menu.tsx +168 -0
  49. package/lib/__templates__/nextjs/src/components/ui/pagination.tsx +127 -0
  50. package/lib/__templates__/nextjs/src/components/ui/popover.tsx +48 -0
  51. package/lib/__templates__/nextjs/src/components/ui/progress.tsx +31 -0
  52. package/lib/__templates__/nextjs/src/components/ui/radio-group.tsx +45 -0
  53. package/lib/__templates__/nextjs/src/components/ui/resizable.tsx +56 -0
  54. package/lib/__templates__/nextjs/src/components/ui/scroll-area.tsx +58 -0
  55. package/lib/__templates__/nextjs/src/components/ui/select.tsx +190 -0
  56. package/lib/__templates__/nextjs/src/components/ui/separator.tsx +28 -0
  57. package/lib/__templates__/nextjs/src/components/ui/sheet.tsx +139 -0
  58. package/lib/__templates__/nextjs/src/components/ui/sidebar.tsx +726 -0
  59. package/lib/__templates__/nextjs/src/components/ui/skeleton.tsx +13 -0
  60. package/lib/__templates__/nextjs/src/components/ui/slider.tsx +63 -0
  61. package/lib/__templates__/nextjs/src/components/ui/sonner.tsx +40 -0
  62. package/lib/__templates__/nextjs/src/components/ui/spinner.tsx +16 -0
  63. package/lib/__templates__/nextjs/src/components/ui/switch.tsx +31 -0
  64. package/lib/__templates__/nextjs/src/components/ui/table.tsx +116 -0
  65. package/lib/__templates__/nextjs/src/components/ui/tabs.tsx +66 -0
  66. package/lib/__templates__/nextjs/src/components/ui/textarea.tsx +18 -0
  67. package/lib/__templates__/nextjs/src/components/ui/toggle-group.tsx +83 -0
  68. package/lib/__templates__/nextjs/src/components/ui/toggle.tsx +47 -0
  69. package/lib/__templates__/nextjs/src/components/ui/tooltip.tsx +61 -0
  70. package/lib/__templates__/nextjs/src/hooks/use-mobile.ts +19 -0
  71. package/lib/__templates__/nextjs/src/lib/utils.ts +6 -0
  72. package/lib/__templates__/nextjs/template.config.js +1 -1
  73. package/lib/__templates__/templates.json +0 -38
  74. package/lib/__templates__/vite/template.config.js +1 -1
  75. package/lib/cli.js +19 -2
  76. package/package.json +2 -2
  77. package/lib/__templates__/react-rsbuild/.coze +0 -11
  78. package/lib/__templates__/react-rsbuild/.vscode/settings.json +0 -121
  79. package/lib/__templates__/react-rsbuild/README.md +0 -61
  80. package/lib/__templates__/react-rsbuild/_gitignore +0 -97
  81. package/lib/__templates__/react-rsbuild/_npmrc +0 -22
  82. package/lib/__templates__/react-rsbuild/package.json +0 -31
  83. package/lib/__templates__/react-rsbuild/pnpm-lock.yaml +0 -997
  84. package/lib/__templates__/react-rsbuild/rsbuild.config.ts +0 -13
  85. package/lib/__templates__/react-rsbuild/scripts/build.sh +0 -14
  86. package/lib/__templates__/react-rsbuild/scripts/dev.sh +0 -51
  87. package/lib/__templates__/react-rsbuild/scripts/start.sh +0 -15
  88. package/lib/__templates__/react-rsbuild/src/App.tsx +0 -60
  89. package/lib/__templates__/react-rsbuild/src/index.css +0 -21
  90. package/lib/__templates__/react-rsbuild/src/index.html +0 -12
  91. package/lib/__templates__/react-rsbuild/src/index.tsx +0 -16
  92. package/lib/__templates__/react-rsbuild/tailwind.config.js +0 -9
  93. package/lib/__templates__/react-rsbuild/template.config.js +0 -54
  94. package/lib/__templates__/react-rsbuild/tsconfig.json +0 -17
  95. package/lib/__templates__/rsbuild/.coze +0 -11
  96. package/lib/__templates__/rsbuild/.vscode/settings.json +0 -7
  97. package/lib/__templates__/rsbuild/README.md +0 -61
  98. package/lib/__templates__/rsbuild/_gitignore +0 -97
  99. package/lib/__templates__/rsbuild/_npmrc +0 -22
  100. package/lib/__templates__/rsbuild/package.json +0 -24
  101. package/lib/__templates__/rsbuild/pnpm-lock.yaml +0 -888
  102. package/lib/__templates__/rsbuild/rsbuild.config.ts +0 -12
  103. package/lib/__templates__/rsbuild/scripts/build.sh +0 -14
  104. package/lib/__templates__/rsbuild/scripts/dev.sh +0 -51
  105. package/lib/__templates__/rsbuild/scripts/start.sh +0 -15
  106. package/lib/__templates__/rsbuild/src/index.css +0 -21
  107. package/lib/__templates__/rsbuild/src/index.html +0 -12
  108. package/lib/__templates__/rsbuild/src/index.ts +0 -5
  109. package/lib/__templates__/rsbuild/src/main.ts +0 -65
  110. package/lib/__templates__/rsbuild/tailwind.config.js +0 -9
  111. package/lib/__templates__/rsbuild/template.config.js +0 -56
  112. package/lib/__templates__/rsbuild/tsconfig.json +0 -16
@@ -0,0 +1,241 @@
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
+ >
121
+ <div
122
+ onKeyDownCapture={handleKeyDown}
123
+ className={cn("relative", className)}
124
+ role="region"
125
+ aria-roledescription="carousel"
126
+ data-slot="carousel"
127
+ {...props}
128
+ >
129
+ {children}
130
+ </div>
131
+ </CarouselContext.Provider>
132
+ )
133
+ }
134
+
135
+ function CarouselContent({ className, ...props }: React.ComponentProps<"div">) {
136
+ const { carouselRef, orientation } = useCarousel()
137
+
138
+ return (
139
+ <div
140
+ ref={carouselRef}
141
+ className="overflow-hidden"
142
+ data-slot="carousel-content"
143
+ >
144
+ <div
145
+ className={cn(
146
+ "flex",
147
+ orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
148
+ className
149
+ )}
150
+ {...props}
151
+ />
152
+ </div>
153
+ )
154
+ }
155
+
156
+ function CarouselItem({ className, ...props }: React.ComponentProps<"div">) {
157
+ const { orientation } = useCarousel()
158
+
159
+ return (
160
+ <div
161
+ role="group"
162
+ aria-roledescription="slide"
163
+ data-slot="carousel-item"
164
+ className={cn(
165
+ "min-w-0 shrink-0 grow-0 basis-full",
166
+ orientation === "horizontal" ? "pl-4" : "pt-4",
167
+ className
168
+ )}
169
+ {...props}
170
+ />
171
+ )
172
+ }
173
+
174
+ function CarouselPrevious({
175
+ className,
176
+ variant = "outline",
177
+ size = "icon",
178
+ ...props
179
+ }: React.ComponentProps<typeof Button>) {
180
+ const { orientation, scrollPrev, canScrollPrev } = useCarousel()
181
+
182
+ return (
183
+ <Button
184
+ data-slot="carousel-previous"
185
+ variant={variant}
186
+ size={size}
187
+ className={cn(
188
+ "absolute size-8 rounded-full",
189
+ orientation === "horizontal"
190
+ ? "top-1/2 -left-12 -translate-y-1/2"
191
+ : "-top-12 left-1/2 -translate-x-1/2 rotate-90",
192
+ className
193
+ )}
194
+ disabled={!canScrollPrev}
195
+ onClick={scrollPrev}
196
+ {...props}
197
+ >
198
+ <ArrowLeft />
199
+ <span className="sr-only">Previous slide</span>
200
+ </Button>
201
+ )
202
+ }
203
+
204
+ function CarouselNext({
205
+ className,
206
+ variant = "outline",
207
+ size = "icon",
208
+ ...props
209
+ }: React.ComponentProps<typeof Button>) {
210
+ const { orientation, scrollNext, canScrollNext } = useCarousel()
211
+
212
+ return (
213
+ <Button
214
+ data-slot="carousel-next"
215
+ variant={variant}
216
+ size={size}
217
+ className={cn(
218
+ "absolute size-8 rounded-full",
219
+ orientation === "horizontal"
220
+ ? "top-1/2 -right-12 -translate-y-1/2"
221
+ : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
222
+ className
223
+ )}
224
+ disabled={!canScrollNext}
225
+ onClick={scrollNext}
226
+ {...props}
227
+ >
228
+ <ArrowRight />
229
+ <span className="sr-only">Next slide</span>
230
+ </Button>
231
+ )
232
+ }
233
+
234
+ export {
235
+ type CarouselApi,
236
+ Carousel,
237
+ CarouselContent,
238
+ CarouselItem,
239
+ CarouselPrevious,
240
+ CarouselNext,
241
+ }
@@ -0,0 +1,357 @@
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
+ >
63
+ <ChartStyle id={chartId} config={config} />
64
+ <RechartsPrimitive.ResponsiveContainer>
65
+ {children}
66
+ </RechartsPrimitive.ResponsiveContainer>
67
+ </div>
68
+ </ChartContext.Provider>
69
+ )
70
+ }
71
+
72
+ const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
73
+ const colorConfig = Object.entries(config).filter(
74
+ ([, config]) => config.theme || config.color
75
+ )
76
+
77
+ if (!colorConfig.length) {
78
+ return null
79
+ }
80
+
81
+ return (
82
+ <style
83
+ dangerouslySetInnerHTML={{
84
+ __html: Object.entries(THEMES)
85
+ .map(
86
+ ([theme, prefix]) => `
87
+ ${prefix} [data-chart=${id}] {
88
+ ${colorConfig
89
+ .map(([key, itemConfig]) => {
90
+ const color =
91
+ itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ||
92
+ itemConfig.color
93
+ return color ? ` --color-${key}: ${color};` : null
94
+ })
95
+ .join("\n")}
96
+ }
97
+ `
98
+ )
99
+ .join("\n"),
100
+ }}
101
+ />
102
+ )
103
+ }
104
+
105
+ const ChartTooltip = RechartsPrimitive.Tooltip
106
+
107
+ function ChartTooltipContent({
108
+ active,
109
+ payload,
110
+ className,
111
+ indicator = "dot",
112
+ hideLabel = false,
113
+ hideIndicator = false,
114
+ label,
115
+ labelFormatter,
116
+ labelClassName,
117
+ formatter,
118
+ color,
119
+ nameKey,
120
+ labelKey,
121
+ }: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
122
+ React.ComponentProps<"div"> & {
123
+ hideLabel?: boolean
124
+ hideIndicator?: boolean
125
+ indicator?: "line" | "dot" | "dashed"
126
+ nameKey?: string
127
+ labelKey?: string
128
+ }) {
129
+ const { config } = useChart()
130
+
131
+ const tooltipLabel = React.useMemo(() => {
132
+ if (hideLabel || !payload?.length) {
133
+ return null
134
+ }
135
+
136
+ const [item] = payload
137
+ const key = `${labelKey || item?.dataKey || item?.name || "value"}`
138
+ const itemConfig = getPayloadConfigFromPayload(config, item, key)
139
+ const value =
140
+ !labelKey && typeof label === "string"
141
+ ? config[label as keyof typeof config]?.label || label
142
+ : itemConfig?.label
143
+
144
+ if (labelFormatter) {
145
+ return (
146
+ <div className={cn("font-medium", labelClassName)}>
147
+ {labelFormatter(value, payload)}
148
+ </div>
149
+ )
150
+ }
151
+
152
+ if (!value) {
153
+ return null
154
+ }
155
+
156
+ return <div className={cn("font-medium", labelClassName)}>{value}</div>
157
+ }, [
158
+ label,
159
+ labelFormatter,
160
+ payload,
161
+ hideLabel,
162
+ labelClassName,
163
+ config,
164
+ labelKey,
165
+ ])
166
+
167
+ if (!active || !payload?.length) {
168
+ return null
169
+ }
170
+
171
+ const nestLabel = payload.length === 1 && indicator !== "dot"
172
+
173
+ return (
174
+ <div
175
+ className={cn(
176
+ "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",
177
+ className
178
+ )}
179
+ >
180
+ {!nestLabel ? tooltipLabel : null}
181
+ <div className="grid gap-1.5">
182
+ {payload
183
+ .filter((item) => item.type !== "none")
184
+ .map((item, index) => {
185
+ const key = `${nameKey || item.name || item.dataKey || "value"}`
186
+ const itemConfig = getPayloadConfigFromPayload(config, item, key)
187
+ const indicatorColor = color || item.payload.fill || item.color
188
+
189
+ return (
190
+ <div
191
+ key={item.dataKey}
192
+ className={cn(
193
+ "[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",
194
+ indicator === "dot" && "items-center"
195
+ )}
196
+ >
197
+ {formatter && item?.value !== undefined && item.name ? (
198
+ formatter(item.value, item.name, item, index, item.payload)
199
+ ) : (
200
+ <>
201
+ {itemConfig?.icon ? (
202
+ <itemConfig.icon />
203
+ ) : (
204
+ !hideIndicator && (
205
+ <div
206
+ className={cn(
207
+ "shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
208
+ {
209
+ "h-2.5 w-2.5": indicator === "dot",
210
+ "w-1": indicator === "line",
211
+ "w-0 border-[1.5px] border-dashed bg-transparent":
212
+ indicator === "dashed",
213
+ "my-0.5": nestLabel && indicator === "dashed",
214
+ }
215
+ )}
216
+ style={
217
+ {
218
+ "--color-bg": indicatorColor,
219
+ "--color-border": indicatorColor,
220
+ } as React.CSSProperties
221
+ }
222
+ />
223
+ )
224
+ )}
225
+ <div
226
+ className={cn(
227
+ "flex flex-1 justify-between leading-none",
228
+ nestLabel ? "items-end" : "items-center"
229
+ )}
230
+ >
231
+ <div className="grid gap-1.5">
232
+ {nestLabel ? tooltipLabel : null}
233
+ <span className="text-muted-foreground">
234
+ {itemConfig?.label || item.name}
235
+ </span>
236
+ </div>
237
+ {item.value && (
238
+ <span className="text-foreground font-mono font-medium tabular-nums">
239
+ {item.value.toLocaleString()}
240
+ </span>
241
+ )}
242
+ </div>
243
+ </>
244
+ )}
245
+ </div>
246
+ )
247
+ })}
248
+ </div>
249
+ </div>
250
+ )
251
+ }
252
+
253
+ const ChartLegend = RechartsPrimitive.Legend
254
+
255
+ function ChartLegendContent({
256
+ className,
257
+ hideIcon = false,
258
+ payload,
259
+ verticalAlign = "bottom",
260
+ nameKey,
261
+ }: React.ComponentProps<"div"> &
262
+ Pick<RechartsPrimitive.LegendProps, "payload" | "verticalAlign"> & {
263
+ hideIcon?: boolean
264
+ nameKey?: string
265
+ }) {
266
+ const { config } = useChart()
267
+
268
+ if (!payload?.length) {
269
+ return null
270
+ }
271
+
272
+ return (
273
+ <div
274
+ className={cn(
275
+ "flex items-center justify-center gap-4",
276
+ verticalAlign === "top" ? "pb-3" : "pt-3",
277
+ className
278
+ )}
279
+ >
280
+ {payload
281
+ .filter((item) => item.type !== "none")
282
+ .map((item) => {
283
+ const key = `${nameKey || item.dataKey || "value"}`
284
+ const itemConfig = getPayloadConfigFromPayload(config, item, key)
285
+
286
+ return (
287
+ <div
288
+ key={item.value}
289
+ className={cn(
290
+ "[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"
291
+ )}
292
+ >
293
+ {itemConfig?.icon && !hideIcon ? (
294
+ <itemConfig.icon />
295
+ ) : (
296
+ <div
297
+ className="h-2 w-2 shrink-0 rounded-[2px]"
298
+ style={{
299
+ backgroundColor: item.color,
300
+ }}
301
+ />
302
+ )}
303
+ {itemConfig?.label}
304
+ </div>
305
+ )
306
+ })}
307
+ </div>
308
+ )
309
+ }
310
+
311
+ // Helper to extract item config from a payload.
312
+ function getPayloadConfigFromPayload(
313
+ config: ChartConfig,
314
+ payload: unknown,
315
+ key: string
316
+ ) {
317
+ if (typeof payload !== "object" || payload === null) {
318
+ return undefined
319
+ }
320
+
321
+ const payloadPayload =
322
+ "payload" in payload &&
323
+ typeof payload.payload === "object" &&
324
+ payload.payload !== null
325
+ ? payload.payload
326
+ : undefined
327
+
328
+ let configLabelKey: string = key
329
+
330
+ if (
331
+ key in payload &&
332
+ typeof payload[key as keyof typeof payload] === "string"
333
+ ) {
334
+ configLabelKey = payload[key as keyof typeof payload] as string
335
+ } else if (
336
+ payloadPayload &&
337
+ key in payloadPayload &&
338
+ typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
339
+ ) {
340
+ configLabelKey = payloadPayload[
341
+ key as keyof typeof payloadPayload
342
+ ] as string
343
+ }
344
+
345
+ return configLabelKey in config
346
+ ? config[configLabelKey]
347
+ : config[key as keyof typeof config]
348
+ }
349
+
350
+ export {
351
+ ChartContainer,
352
+ ChartTooltip,
353
+ ChartTooltipContent,
354
+ ChartLegend,
355
+ ChartLegendContent,
356
+ ChartStyle,
357
+ }
@@ -0,0 +1,32 @@
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 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
+ >
22
+ <CheckboxPrimitive.Indicator
23
+ data-slot="checkbox-indicator"
24
+ className="grid place-content-center text-current transition-none"
25
+ >
26
+ <CheckIcon className="size-3.5" />
27
+ </CheckboxPrimitive.Indicator>
28
+ </CheckboxPrimitive.Root>
29
+ )
30
+ }
31
+
32
+ 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 }