@coze-arch/cli 0.0.1-alpha.77c1b0 → 0.0.1-alpha.a1ca15

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 (114) hide show
  1. package/lib/__templates__/expo/.cozeproj/scripts/deploy_build.sh +21 -15
  2. package/lib/__templates__/expo/.cozeproj/scripts/deploy_run.sh +28 -14
  3. package/lib/__templates__/expo/_npmrc +1 -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 +12 -2
  7. package/lib/__templates__/expo/pnpm-lock.yaml +131 -4
  8. package/lib/__templates__/nextjs/.coze +3 -3
  9. package/lib/__templates__/nextjs/README.md +341 -19
  10. package/lib/__templates__/nextjs/_npmrc +1 -1
  11. package/lib/__templates__/nextjs/components.json +21 -0
  12. package/lib/__templates__/nextjs/package.json +54 -1
  13. package/lib/__templates__/nextjs/pnpm-lock.yaml +7947 -1523
  14. package/lib/__templates__/nextjs/scripts/dev.sh +2 -1
  15. package/lib/__templates__/nextjs/src/app/globals.css +99 -8
  16. package/lib/__templates__/nextjs/src/components/ui/accordion.tsx +66 -0
  17. package/lib/__templates__/nextjs/src/components/ui/alert-dialog.tsx +157 -0
  18. package/lib/__templates__/nextjs/src/components/ui/alert.tsx +66 -0
  19. package/lib/__templates__/nextjs/src/components/ui/aspect-ratio.tsx +11 -0
  20. package/lib/__templates__/nextjs/src/components/ui/avatar.tsx +53 -0
  21. package/lib/__templates__/nextjs/src/components/ui/badge.tsx +46 -0
  22. package/lib/__templates__/nextjs/src/components/ui/breadcrumb.tsx +109 -0
  23. package/lib/__templates__/nextjs/src/components/ui/button-group.tsx +83 -0
  24. package/lib/__templates__/nextjs/src/components/ui/button.tsx +62 -0
  25. package/lib/__templates__/nextjs/src/components/ui/calendar.tsx +220 -0
  26. package/lib/__templates__/nextjs/src/components/ui/card.tsx +92 -0
  27. package/lib/__templates__/nextjs/src/components/ui/carousel.tsx +241 -0
  28. package/lib/__templates__/nextjs/src/components/ui/chart.tsx +357 -0
  29. package/lib/__templates__/nextjs/src/components/ui/checkbox.tsx +32 -0
  30. package/lib/__templates__/nextjs/src/components/ui/collapsible.tsx +33 -0
  31. package/lib/__templates__/nextjs/src/components/ui/command.tsx +184 -0
  32. package/lib/__templates__/nextjs/src/components/ui/context-menu.tsx +252 -0
  33. package/lib/__templates__/nextjs/src/components/ui/dialog.tsx +143 -0
  34. package/lib/__templates__/nextjs/src/components/ui/drawer.tsx +135 -0
  35. package/lib/__templates__/nextjs/src/components/ui/dropdown-menu.tsx +257 -0
  36. package/lib/__templates__/nextjs/src/components/ui/empty.tsx +104 -0
  37. package/lib/__templates__/nextjs/src/components/ui/field.tsx +248 -0
  38. package/lib/__templates__/nextjs/src/components/ui/form.tsx +167 -0
  39. package/lib/__templates__/nextjs/src/components/ui/hover-card.tsx +44 -0
  40. package/lib/__templates__/nextjs/src/components/ui/input-group.tsx +170 -0
  41. package/lib/__templates__/nextjs/src/components/ui/input-otp.tsx +77 -0
  42. package/lib/__templates__/nextjs/src/components/ui/input.tsx +21 -0
  43. package/lib/__templates__/nextjs/src/components/ui/item.tsx +193 -0
  44. package/lib/__templates__/nextjs/src/components/ui/kbd.tsx +28 -0
  45. package/lib/__templates__/nextjs/src/components/ui/label.tsx +24 -0
  46. package/lib/__templates__/nextjs/src/components/ui/menubar.tsx +276 -0
  47. package/lib/__templates__/nextjs/src/components/ui/navigation-menu.tsx +168 -0
  48. package/lib/__templates__/nextjs/src/components/ui/pagination.tsx +127 -0
  49. package/lib/__templates__/nextjs/src/components/ui/popover.tsx +48 -0
  50. package/lib/__templates__/nextjs/src/components/ui/progress.tsx +31 -0
  51. package/lib/__templates__/nextjs/src/components/ui/radio-group.tsx +45 -0
  52. package/lib/__templates__/nextjs/src/components/ui/resizable.tsx +56 -0
  53. package/lib/__templates__/nextjs/src/components/ui/scroll-area.tsx +58 -0
  54. package/lib/__templates__/nextjs/src/components/ui/select.tsx +190 -0
  55. package/lib/__templates__/nextjs/src/components/ui/separator.tsx +28 -0
  56. package/lib/__templates__/nextjs/src/components/ui/sheet.tsx +139 -0
  57. package/lib/__templates__/nextjs/src/components/ui/sidebar.tsx +726 -0
  58. package/lib/__templates__/nextjs/src/components/ui/skeleton.tsx +13 -0
  59. package/lib/__templates__/nextjs/src/components/ui/slider.tsx +63 -0
  60. package/lib/__templates__/nextjs/src/components/ui/sonner.tsx +40 -0
  61. package/lib/__templates__/nextjs/src/components/ui/spinner.tsx +16 -0
  62. package/lib/__templates__/nextjs/src/components/ui/switch.tsx +31 -0
  63. package/lib/__templates__/nextjs/src/components/ui/table.tsx +116 -0
  64. package/lib/__templates__/nextjs/src/components/ui/tabs.tsx +66 -0
  65. package/lib/__templates__/nextjs/src/components/ui/textarea.tsx +18 -0
  66. package/lib/__templates__/nextjs/src/components/ui/toggle-group.tsx +83 -0
  67. package/lib/__templates__/nextjs/src/components/ui/toggle.tsx +47 -0
  68. package/lib/__templates__/nextjs/src/components/ui/tooltip.tsx +61 -0
  69. package/lib/__templates__/nextjs/src/hooks/use-mobile.ts +19 -0
  70. package/lib/__templates__/nextjs/src/lib/utils.ts +6 -0
  71. package/lib/__templates__/nextjs/template.config.js +2 -2
  72. package/lib/__templates__/templates.json +1 -39
  73. package/lib/__templates__/vite/.coze +3 -3
  74. package/lib/__templates__/vite/README.md +204 -26
  75. package/lib/__templates__/vite/_npmrc +1 -1
  76. package/lib/__templates__/vite/template.config.js +3 -3
  77. package/lib/cli.js +367 -212
  78. package/package.json +5 -2
  79. package/lib/__templates__/react-rsbuild/.coze +0 -11
  80. package/lib/__templates__/react-rsbuild/.vscode/settings.json +0 -121
  81. package/lib/__templates__/react-rsbuild/README.md +0 -61
  82. package/lib/__templates__/react-rsbuild/_gitignore +0 -97
  83. package/lib/__templates__/react-rsbuild/_npmrc +0 -22
  84. package/lib/__templates__/react-rsbuild/package.json +0 -31
  85. package/lib/__templates__/react-rsbuild/pnpm-lock.yaml +0 -997
  86. package/lib/__templates__/react-rsbuild/rsbuild.config.ts +0 -13
  87. package/lib/__templates__/react-rsbuild/scripts/build.sh +0 -14
  88. package/lib/__templates__/react-rsbuild/scripts/dev.sh +0 -51
  89. package/lib/__templates__/react-rsbuild/scripts/start.sh +0 -15
  90. package/lib/__templates__/react-rsbuild/src/App.tsx +0 -60
  91. package/lib/__templates__/react-rsbuild/src/index.css +0 -21
  92. package/lib/__templates__/react-rsbuild/src/index.html +0 -12
  93. package/lib/__templates__/react-rsbuild/src/index.tsx +0 -16
  94. package/lib/__templates__/react-rsbuild/tailwind.config.js +0 -9
  95. package/lib/__templates__/react-rsbuild/template.config.js +0 -54
  96. package/lib/__templates__/react-rsbuild/tsconfig.json +0 -17
  97. package/lib/__templates__/rsbuild/.coze +0 -11
  98. package/lib/__templates__/rsbuild/.vscode/settings.json +0 -7
  99. package/lib/__templates__/rsbuild/README.md +0 -61
  100. package/lib/__templates__/rsbuild/_gitignore +0 -97
  101. package/lib/__templates__/rsbuild/_npmrc +0 -22
  102. package/lib/__templates__/rsbuild/package.json +0 -24
  103. package/lib/__templates__/rsbuild/pnpm-lock.yaml +0 -888
  104. package/lib/__templates__/rsbuild/rsbuild.config.ts +0 -12
  105. package/lib/__templates__/rsbuild/scripts/build.sh +0 -14
  106. package/lib/__templates__/rsbuild/scripts/dev.sh +0 -51
  107. package/lib/__templates__/rsbuild/scripts/start.sh +0 -15
  108. package/lib/__templates__/rsbuild/src/index.css +0 -21
  109. package/lib/__templates__/rsbuild/src/index.html +0 -12
  110. package/lib/__templates__/rsbuild/src/index.ts +0 -5
  111. package/lib/__templates__/rsbuild/src/main.ts +0 -65
  112. package/lib/__templates__/rsbuild/tailwind.config.js +0 -9
  113. package/lib/__templates__/rsbuild/template.config.js +0 -56
  114. package/lib/__templates__/rsbuild/tsconfig.json +0 -16
@@ -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 }
@@ -0,0 +1,184 @@
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
+ >
55
+ <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">
56
+ {children}
57
+ </Command>
58
+ </DialogContent>
59
+ </Dialog>
60
+ )
61
+ }
62
+
63
+ function CommandInput({
64
+ className,
65
+ ...props
66
+ }: React.ComponentProps<typeof CommandPrimitive.Input>) {
67
+ return (
68
+ <div
69
+ data-slot="command-input-wrapper"
70
+ className="flex h-9 items-center gap-2 border-b px-3"
71
+ >
72
+ <SearchIcon className="size-4 shrink-0 opacity-50" />
73
+ <CommandPrimitive.Input
74
+ data-slot="command-input"
75
+ className={cn(
76
+ "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",
77
+ className
78
+ )}
79
+ {...props}
80
+ />
81
+ </div>
82
+ )
83
+ }
84
+
85
+ function CommandList({
86
+ className,
87
+ ...props
88
+ }: React.ComponentProps<typeof CommandPrimitive.List>) {
89
+ return (
90
+ <CommandPrimitive.List
91
+ data-slot="command-list"
92
+ className={cn(
93
+ "max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",
94
+ className
95
+ )}
96
+ {...props}
97
+ />
98
+ )
99
+ }
100
+
101
+ function CommandEmpty({
102
+ ...props
103
+ }: React.ComponentProps<typeof CommandPrimitive.Empty>) {
104
+ return (
105
+ <CommandPrimitive.Empty
106
+ data-slot="command-empty"
107
+ className="py-6 text-center text-sm"
108
+ {...props}
109
+ />
110
+ )
111
+ }
112
+
113
+ function CommandGroup({
114
+ className,
115
+ ...props
116
+ }: React.ComponentProps<typeof CommandPrimitive.Group>) {
117
+ return (
118
+ <CommandPrimitive.Group
119
+ data-slot="command-group"
120
+ className={cn(
121
+ "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",
122
+ className
123
+ )}
124
+ {...props}
125
+ />
126
+ )
127
+ }
128
+
129
+ function CommandSeparator({
130
+ className,
131
+ ...props
132
+ }: React.ComponentProps<typeof CommandPrimitive.Separator>) {
133
+ return (
134
+ <CommandPrimitive.Separator
135
+ data-slot="command-separator"
136
+ className={cn("bg-border -mx-1 h-px", className)}
137
+ {...props}
138
+ />
139
+ )
140
+ }
141
+
142
+ function CommandItem({
143
+ className,
144
+ ...props
145
+ }: React.ComponentProps<typeof CommandPrimitive.Item>) {
146
+ return (
147
+ <CommandPrimitive.Item
148
+ data-slot="command-item"
149
+ className={cn(
150
+ "data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
151
+ className
152
+ )}
153
+ {...props}
154
+ />
155
+ )
156
+ }
157
+
158
+ function CommandShortcut({
159
+ className,
160
+ ...props
161
+ }: React.ComponentProps<"span">) {
162
+ return (
163
+ <span
164
+ data-slot="command-shortcut"
165
+ className={cn(
166
+ "text-muted-foreground ml-auto text-xs tracking-widest",
167
+ className
168
+ )}
169
+ {...props}
170
+ />
171
+ )
172
+ }
173
+
174
+ export {
175
+ Command,
176
+ CommandDialog,
177
+ CommandInput,
178
+ CommandList,
179
+ CommandEmpty,
180
+ CommandGroup,
181
+ CommandItem,
182
+ CommandShortcut,
183
+ CommandSeparator,
184
+ }