forge-admin 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/README.md +73 -0
  2. package/app.db +0 -0
  3. package/components.json +20 -0
  4. package/dist/assets/index-BPVmexx_.css +1 -0
  5. package/dist/assets/index-BtNewH3n.js +258 -0
  6. package/dist/favicon.ico +0 -0
  7. package/dist/index.html +27 -0
  8. package/dist/placeholder.svg +1 -0
  9. package/dist/robots.txt +14 -0
  10. package/eslint.config.js +26 -0
  11. package/index.html +26 -0
  12. package/package.json +107 -0
  13. package/postcss.config.js +6 -0
  14. package/public/favicon.ico +0 -0
  15. package/public/placeholder.svg +1 -0
  16. package/public/robots.txt +14 -0
  17. package/src/App.css +42 -0
  18. package/src/App.tsx +32 -0
  19. package/src/admin/convertSchema.ts +83 -0
  20. package/src/admin/factory.ts +12 -0
  21. package/src/admin/introspecter.ts +6 -0
  22. package/src/admin/router.ts +38 -0
  23. package/src/admin/schema.ts +17 -0
  24. package/src/admin/sqlite.ts +73 -0
  25. package/src/admin/types.ts +35 -0
  26. package/src/components/AdminLayout.tsx +19 -0
  27. package/src/components/AdminSidebar.tsx +102 -0
  28. package/src/components/DataTable.tsx +166 -0
  29. package/src/components/ModelForm.tsx +221 -0
  30. package/src/components/NavLink.tsx +28 -0
  31. package/src/components/StatCard.tsx +32 -0
  32. package/src/components/ui/accordion.tsx +52 -0
  33. package/src/components/ui/alert-dialog.tsx +104 -0
  34. package/src/components/ui/alert.tsx +43 -0
  35. package/src/components/ui/aspect-ratio.tsx +5 -0
  36. package/src/components/ui/avatar.tsx +38 -0
  37. package/src/components/ui/badge.tsx +29 -0
  38. package/src/components/ui/breadcrumb.tsx +90 -0
  39. package/src/components/ui/button.tsx +47 -0
  40. package/src/components/ui/calendar.tsx +54 -0
  41. package/src/components/ui/card.tsx +43 -0
  42. package/src/components/ui/carousel.tsx +224 -0
  43. package/src/components/ui/chart.tsx +303 -0
  44. package/src/components/ui/checkbox.tsx +26 -0
  45. package/src/components/ui/collapsible.tsx +9 -0
  46. package/src/components/ui/command.tsx +132 -0
  47. package/src/components/ui/context-menu.tsx +178 -0
  48. package/src/components/ui/dialog.tsx +95 -0
  49. package/src/components/ui/drawer.tsx +87 -0
  50. package/src/components/ui/dropdown-menu.tsx +179 -0
  51. package/src/components/ui/form.tsx +129 -0
  52. package/src/components/ui/hover-card.tsx +27 -0
  53. package/src/components/ui/input-otp.tsx +61 -0
  54. package/src/components/ui/input.tsx +22 -0
  55. package/src/components/ui/label.tsx +17 -0
  56. package/src/components/ui/menubar.tsx +207 -0
  57. package/src/components/ui/navigation-menu.tsx +120 -0
  58. package/src/components/ui/pagination.tsx +81 -0
  59. package/src/components/ui/popover.tsx +29 -0
  60. package/src/components/ui/progress.tsx +23 -0
  61. package/src/components/ui/radio-group.tsx +36 -0
  62. package/src/components/ui/resizable.tsx +37 -0
  63. package/src/components/ui/scroll-area.tsx +38 -0
  64. package/src/components/ui/select.tsx +143 -0
  65. package/src/components/ui/separator.tsx +20 -0
  66. package/src/components/ui/sheet.tsx +107 -0
  67. package/src/components/ui/sidebar.tsx +637 -0
  68. package/src/components/ui/skeleton.tsx +7 -0
  69. package/src/components/ui/slider.tsx +23 -0
  70. package/src/components/ui/sonner.tsx +27 -0
  71. package/src/components/ui/switch.tsx +27 -0
  72. package/src/components/ui/table.tsx +72 -0
  73. package/src/components/ui/tabs.tsx +53 -0
  74. package/src/components/ui/textarea.tsx +21 -0
  75. package/src/components/ui/toast.tsx +111 -0
  76. package/src/components/ui/toaster.tsx +24 -0
  77. package/src/components/ui/toggle-group.tsx +49 -0
  78. package/src/components/ui/toggle.tsx +37 -0
  79. package/src/components/ui/tooltip.tsx +28 -0
  80. package/src/components/ui/use-toast.ts +3 -0
  81. package/src/config/define.ts +6 -0
  82. package/src/config/index.ts +0 -0
  83. package/src/config/load.ts +45 -0
  84. package/src/config/types.ts +5 -0
  85. package/src/hooks/use-mobile.tsx +19 -0
  86. package/src/hooks/use-toast.ts +186 -0
  87. package/src/index.css +142 -0
  88. package/src/lib/models.ts +138 -0
  89. package/src/lib/utils.ts +6 -0
  90. package/src/main.tsx +5 -0
  91. package/src/orm/cli/makemigrations.ts +63 -0
  92. package/src/orm/cli/migrate.ts +127 -0
  93. package/src/orm/cli.ts +30 -0
  94. package/src/orm/core/base-model.ts +6 -0
  95. package/src/orm/core/manager.ts +27 -0
  96. package/src/orm/core/query-builder.ts +74 -0
  97. package/src/orm/db/connection.ts +0 -0
  98. package/src/orm/db/sql-types.ts +72 -0
  99. package/src/orm/db/sqlite.ts +4 -0
  100. package/src/orm/decorators/field.ts +80 -0
  101. package/src/orm/decorators/model.ts +36 -0
  102. package/src/orm/decorators/relations.ts +0 -0
  103. package/src/orm/metadata/field-metadata.ts +0 -0
  104. package/src/orm/metadata/field-types.ts +12 -0
  105. package/src/orm/metadata/get-meta.ts +9 -0
  106. package/src/orm/metadata/index.ts +15 -0
  107. package/src/orm/metadata/keys.ts +2 -0
  108. package/src/orm/metadata/model-registry.ts +53 -0
  109. package/src/orm/metadata/modifiers.ts +26 -0
  110. package/src/orm/metadata/types.ts +45 -0
  111. package/src/orm/migration-engine/diff.ts +243 -0
  112. package/src/orm/migration-engine/operations.ts +186 -0
  113. package/src/orm/schema/build.ts +138 -0
  114. package/src/orm/schema/state.ts +23 -0
  115. package/src/orm/schema/writeMigrations.ts +21 -0
  116. package/src/orm/syncdb.ts +25 -0
  117. package/src/pages/Dashboard.tsx +127 -0
  118. package/src/pages/Index.tsx +18 -0
  119. package/src/pages/ModelPage.tsx +177 -0
  120. package/src/pages/NotFound.tsx +24 -0
  121. package/src/pages/SchemaEditor.tsx +170 -0
  122. package/src/pages/Settings.tsx +166 -0
  123. package/src/server.ts +69 -0
  124. package/src/vite-env.d.ts +1 -0
  125. package/tailwind.config.js +112 -0
  126. package/tailwind.config.ts +114 -0
  127. package/tsconfig.app.json +30 -0
  128. package/tsconfig.json +16 -0
  129. package/tsconfig.node.json +22 -0
  130. package/vite.config.js +23 -0
  131. package/vite.config.ts +18 -0
@@ -0,0 +1,303 @@
1
+ import * as React from "react";
2
+ import * as RechartsPrimitive from "recharts";
3
+
4
+ import { cn } from "@/lib/utils";
5
+
6
+ // Format: { THEME_NAME: CSS_SELECTOR }
7
+ const THEMES = { light: "", dark: ".dark" } as const;
8
+
9
+ export type ChartConfig = {
10
+ [k in string]: {
11
+ label?: React.ReactNode;
12
+ icon?: React.ComponentType;
13
+ } & ({ color?: string; theme?: never } | { color?: never; theme: Record<keyof typeof THEMES, string> });
14
+ };
15
+
16
+ type ChartContextProps = {
17
+ config: ChartConfig;
18
+ };
19
+
20
+ const ChartContext = React.createContext<ChartContextProps | null>(null);
21
+
22
+ function useChart() {
23
+ const context = React.useContext(ChartContext);
24
+
25
+ if (!context) {
26
+ throw new Error("useChart must be used within a <ChartContainer />");
27
+ }
28
+
29
+ return context;
30
+ }
31
+
32
+ const ChartContainer = React.forwardRef<
33
+ HTMLDivElement,
34
+ React.ComponentProps<"div"> & {
35
+ config: ChartConfig;
36
+ children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];
37
+ }
38
+ >(({ id, className, children, config, ...props }, ref) => {
39
+ const uniqueId = React.useId();
40
+ const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
41
+
42
+ return (
43
+ <ChartContext.Provider value={{ config }}>
44
+ <div
45
+ data-chart={chartId}
46
+ ref={ref}
47
+ className={cn(
48
+ "flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",
49
+ className,
50
+ )}
51
+ {...props}
52
+ >
53
+ <ChartStyle id={chartId} config={config} />
54
+ <RechartsPrimitive.ResponsiveContainer>{children}</RechartsPrimitive.ResponsiveContainer>
55
+ </div>
56
+ </ChartContext.Provider>
57
+ );
58
+ });
59
+ ChartContainer.displayName = "Chart";
60
+
61
+ const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
62
+ const colorConfig = Object.entries(config).filter(([_, config]) => config.theme || config.color);
63
+
64
+ if (!colorConfig.length) {
65
+ return null;
66
+ }
67
+
68
+ return (
69
+ <style
70
+ dangerouslySetInnerHTML={{
71
+ __html: Object.entries(THEMES)
72
+ .map(
73
+ ([theme, prefix]) => `
74
+ ${prefix} [data-chart=${id}] {
75
+ ${colorConfig
76
+ .map(([key, itemConfig]) => {
77
+ const color = itemConfig.theme?.[theme as keyof typeof itemConfig.theme] || itemConfig.color;
78
+ return color ? ` --color-${key}: ${color};` : null;
79
+ })
80
+ .join("\n")}
81
+ }
82
+ `,
83
+ )
84
+ .join("\n"),
85
+ }}
86
+ />
87
+ );
88
+ };
89
+
90
+ const ChartTooltip = RechartsPrimitive.Tooltip;
91
+
92
+ const ChartTooltipContent = React.forwardRef<
93
+ HTMLDivElement,
94
+ React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
95
+ React.ComponentProps<"div"> & {
96
+ hideLabel?: boolean;
97
+ hideIndicator?: boolean;
98
+ indicator?: "line" | "dot" | "dashed";
99
+ nameKey?: string;
100
+ labelKey?: string;
101
+ }
102
+ >(
103
+ (
104
+ {
105
+ active,
106
+ payload,
107
+ className,
108
+ indicator = "dot",
109
+ hideLabel = false,
110
+ hideIndicator = false,
111
+ label,
112
+ labelFormatter,
113
+ labelClassName,
114
+ formatter,
115
+ color,
116
+ nameKey,
117
+ labelKey,
118
+ },
119
+ ref,
120
+ ) => {
121
+ const { config } = useChart();
122
+
123
+ const tooltipLabel = React.useMemo(() => {
124
+ if (hideLabel || !payload?.length) {
125
+ return null;
126
+ }
127
+
128
+ const [item] = payload;
129
+ const key = `${labelKey || item.dataKey || item.name || "value"}`;
130
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
131
+ const value =
132
+ !labelKey && typeof label === "string"
133
+ ? config[label as keyof typeof config]?.label || label
134
+ : itemConfig?.label;
135
+
136
+ if (labelFormatter) {
137
+ return <div className={cn("font-medium", labelClassName)}>{labelFormatter(value, payload)}</div>;
138
+ }
139
+
140
+ if (!value) {
141
+ return null;
142
+ }
143
+
144
+ return <div className={cn("font-medium", labelClassName)}>{value}</div>;
145
+ }, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
146
+
147
+ if (!active || !payload?.length) {
148
+ return null;
149
+ }
150
+
151
+ const nestLabel = payload.length === 1 && indicator !== "dot";
152
+
153
+ return (
154
+ <div
155
+ ref={ref}
156
+ className={cn(
157
+ "grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",
158
+ className,
159
+ )}
160
+ >
161
+ {!nestLabel ? tooltipLabel : null}
162
+ <div className="grid gap-1.5">
163
+ {payload.map((item, index) => {
164
+ const key = `${nameKey || item.name || item.dataKey || "value"}`;
165
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
166
+ const indicatorColor = color || item.payload.fill || item.color;
167
+
168
+ return (
169
+ <div
170
+ key={item.dataKey}
171
+ className={cn(
172
+ "flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
173
+ indicator === "dot" && "items-center",
174
+ )}
175
+ >
176
+ {formatter && item?.value !== undefined && item.name ? (
177
+ formatter(item.value, item.name, item, index, item.payload)
178
+ ) : (
179
+ <>
180
+ {itemConfig?.icon ? (
181
+ <itemConfig.icon />
182
+ ) : (
183
+ !hideIndicator && (
184
+ <div
185
+ className={cn("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]", {
186
+ "h-2.5 w-2.5": indicator === "dot",
187
+ "w-1": indicator === "line",
188
+ "w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
189
+ "my-0.5": nestLabel && indicator === "dashed",
190
+ })}
191
+ style={
192
+ {
193
+ "--color-bg": indicatorColor,
194
+ "--color-border": indicatorColor,
195
+ } as React.CSSProperties
196
+ }
197
+ />
198
+ )
199
+ )}
200
+ <div
201
+ className={cn(
202
+ "flex flex-1 justify-between leading-none",
203
+ nestLabel ? "items-end" : "items-center",
204
+ )}
205
+ >
206
+ <div className="grid gap-1.5">
207
+ {nestLabel ? tooltipLabel : null}
208
+ <span className="text-muted-foreground">{itemConfig?.label || item.name}</span>
209
+ </div>
210
+ {item.value && (
211
+ <span className="font-mono font-medium tabular-nums text-foreground">
212
+ {item.value.toLocaleString()}
213
+ </span>
214
+ )}
215
+ </div>
216
+ </>
217
+ )}
218
+ </div>
219
+ );
220
+ })}
221
+ </div>
222
+ </div>
223
+ );
224
+ },
225
+ );
226
+ ChartTooltipContent.displayName = "ChartTooltip";
227
+
228
+ const ChartLegend = RechartsPrimitive.Legend;
229
+
230
+ const ChartLegendContent = React.forwardRef<
231
+ HTMLDivElement,
232
+ React.ComponentProps<"div"> &
233
+ Pick<RechartsPrimitive.LegendProps, "payload" | "verticalAlign"> & {
234
+ hideIcon?: boolean;
235
+ nameKey?: string;
236
+ }
237
+ >(({ className, hideIcon = false, payload, verticalAlign = "bottom", nameKey }, ref) => {
238
+ const { config } = useChart();
239
+
240
+ if (!payload?.length) {
241
+ return null;
242
+ }
243
+
244
+ return (
245
+ <div
246
+ ref={ref}
247
+ className={cn("flex items-center justify-center gap-4", verticalAlign === "top" ? "pb-3" : "pt-3", className)}
248
+ >
249
+ {payload.map((item) => {
250
+ const key = `${nameKey || item.dataKey || "value"}`;
251
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
252
+
253
+ return (
254
+ <div
255
+ key={item.value}
256
+ className={cn("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground")}
257
+ >
258
+ {itemConfig?.icon && !hideIcon ? (
259
+ <itemConfig.icon />
260
+ ) : (
261
+ <div
262
+ className="h-2 w-2 shrink-0 rounded-[2px]"
263
+ style={{
264
+ backgroundColor: item.color,
265
+ }}
266
+ />
267
+ )}
268
+ {itemConfig?.label}
269
+ </div>
270
+ );
271
+ })}
272
+ </div>
273
+ );
274
+ });
275
+ ChartLegendContent.displayName = "ChartLegend";
276
+
277
+ // Helper to extract item config from a payload.
278
+ function getPayloadConfigFromPayload(config: ChartConfig, payload: unknown, key: string) {
279
+ if (typeof payload !== "object" || payload === null) {
280
+ return undefined;
281
+ }
282
+
283
+ const payloadPayload =
284
+ "payload" in payload && typeof payload.payload === "object" && payload.payload !== null
285
+ ? payload.payload
286
+ : undefined;
287
+
288
+ let configLabelKey: string = key;
289
+
290
+ if (key in payload && typeof payload[key as keyof typeof payload] === "string") {
291
+ configLabelKey = payload[key as keyof typeof payload] as string;
292
+ } else if (
293
+ payloadPayload &&
294
+ key in payloadPayload &&
295
+ typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
296
+ ) {
297
+ configLabelKey = payloadPayload[key as keyof typeof payloadPayload] as string;
298
+ }
299
+
300
+ return configLabelKey in config ? config[configLabelKey] : config[key as keyof typeof config];
301
+ }
302
+
303
+ export { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle };
@@ -0,0 +1,26 @@
1
+ import * as React from "react";
2
+ import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
3
+ import { Check } from "lucide-react";
4
+
5
+ import { cn } from "@/lib/utils";
6
+
7
+ const Checkbox = React.forwardRef<
8
+ React.ElementRef<typeof CheckboxPrimitive.Root>,
9
+ React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
10
+ >(({ className, ...props }, ref) => (
11
+ <CheckboxPrimitive.Root
12
+ ref={ref}
13
+ className={cn(
14
+ "peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
15
+ className,
16
+ )}
17
+ {...props}
18
+ >
19
+ <CheckboxPrimitive.Indicator className={cn("flex items-center justify-center text-current")}>
20
+ <Check className="h-4 w-4" />
21
+ </CheckboxPrimitive.Indicator>
22
+ </CheckboxPrimitive.Root>
23
+ ));
24
+ Checkbox.displayName = CheckboxPrimitive.Root.displayName;
25
+
26
+ export { Checkbox };
@@ -0,0 +1,9 @@
1
+ import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
2
+
3
+ const Collapsible = CollapsiblePrimitive.Root;
4
+
5
+ const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger;
6
+
7
+ const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent;
8
+
9
+ export { Collapsible, CollapsibleTrigger, CollapsibleContent };
@@ -0,0 +1,132 @@
1
+ import * as React from "react";
2
+ import { type DialogProps } from "@radix-ui/react-dialog";
3
+ import { Command as CommandPrimitive } from "cmdk";
4
+ import { Search } from "lucide-react";
5
+
6
+ import { cn } from "@/lib/utils";
7
+ import { Dialog, DialogContent } from "@/components/ui/dialog";
8
+
9
+ const Command = React.forwardRef<
10
+ React.ElementRef<typeof CommandPrimitive>,
11
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive>
12
+ >(({ className, ...props }, ref) => (
13
+ <CommandPrimitive
14
+ ref={ref}
15
+ className={cn(
16
+ "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
17
+ className,
18
+ )}
19
+ {...props}
20
+ />
21
+ ));
22
+ Command.displayName = CommandPrimitive.displayName;
23
+
24
+ interface CommandDialogProps extends DialogProps {}
25
+
26
+ const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
27
+ return (
28
+ <Dialog {...props}>
29
+ <DialogContent className="overflow-hidden p-0 shadow-lg">
30
+ <Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[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">
31
+ {children}
32
+ </Command>
33
+ </DialogContent>
34
+ </Dialog>
35
+ );
36
+ };
37
+
38
+ const CommandInput = React.forwardRef<
39
+ React.ElementRef<typeof CommandPrimitive.Input>,
40
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
41
+ >(({ className, ...props }, ref) => (
42
+ <div className="flex items-center border-b px-3" cmdk-input-wrapper="">
43
+ <Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
44
+ <CommandPrimitive.Input
45
+ ref={ref}
46
+ className={cn(
47
+ "flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
48
+ className,
49
+ )}
50
+ {...props}
51
+ />
52
+ </div>
53
+ ));
54
+
55
+ CommandInput.displayName = CommandPrimitive.Input.displayName;
56
+
57
+ const CommandList = React.forwardRef<
58
+ React.ElementRef<typeof CommandPrimitive.List>,
59
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
60
+ >(({ className, ...props }, ref) => (
61
+ <CommandPrimitive.List
62
+ ref={ref}
63
+ className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}
64
+ {...props}
65
+ />
66
+ ));
67
+
68
+ CommandList.displayName = CommandPrimitive.List.displayName;
69
+
70
+ const CommandEmpty = React.forwardRef<
71
+ React.ElementRef<typeof CommandPrimitive.Empty>,
72
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
73
+ >((props, ref) => <CommandPrimitive.Empty ref={ref} className="py-6 text-center text-sm" {...props} />);
74
+
75
+ CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
76
+
77
+ const CommandGroup = React.forwardRef<
78
+ React.ElementRef<typeof CommandPrimitive.Group>,
79
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
80
+ >(({ className, ...props }, ref) => (
81
+ <CommandPrimitive.Group
82
+ ref={ref}
83
+ className={cn(
84
+ "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
85
+ className,
86
+ )}
87
+ {...props}
88
+ />
89
+ ));
90
+
91
+ CommandGroup.displayName = CommandPrimitive.Group.displayName;
92
+
93
+ const CommandSeparator = React.forwardRef<
94
+ React.ElementRef<typeof CommandPrimitive.Separator>,
95
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
96
+ >(({ className, ...props }, ref) => (
97
+ <CommandPrimitive.Separator ref={ref} className={cn("-mx-1 h-px bg-border", className)} {...props} />
98
+ ));
99
+ CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
100
+
101
+ const CommandItem = React.forwardRef<
102
+ React.ElementRef<typeof CommandPrimitive.Item>,
103
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
104
+ >(({ className, ...props }, ref) => (
105
+ <CommandPrimitive.Item
106
+ ref={ref}
107
+ className={cn(
108
+ "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",
109
+ className,
110
+ )}
111
+ {...props}
112
+ />
113
+ ));
114
+
115
+ CommandItem.displayName = CommandPrimitive.Item.displayName;
116
+
117
+ const CommandShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
118
+ return <span className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)} {...props} />;
119
+ };
120
+ CommandShortcut.displayName = "CommandShortcut";
121
+
122
+ export {
123
+ Command,
124
+ CommandDialog,
125
+ CommandInput,
126
+ CommandList,
127
+ CommandEmpty,
128
+ CommandGroup,
129
+ CommandItem,
130
+ CommandShortcut,
131
+ CommandSeparator,
132
+ };
@@ -0,0 +1,178 @@
1
+ import * as React from "react";
2
+ import * as ContextMenuPrimitive from "@radix-ui/react-context-menu";
3
+ import { Check, ChevronRight, Circle } from "lucide-react";
4
+
5
+ import { cn } from "@/lib/utils";
6
+
7
+ const ContextMenu = ContextMenuPrimitive.Root;
8
+
9
+ const ContextMenuTrigger = ContextMenuPrimitive.Trigger;
10
+
11
+ const ContextMenuGroup = ContextMenuPrimitive.Group;
12
+
13
+ const ContextMenuPortal = ContextMenuPrimitive.Portal;
14
+
15
+ const ContextMenuSub = ContextMenuPrimitive.Sub;
16
+
17
+ const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;
18
+
19
+ const ContextMenuSubTrigger = React.forwardRef<
20
+ React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,
21
+ React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & {
22
+ inset?: boolean;
23
+ }
24
+ >(({ className, inset, children, ...props }, ref) => (
25
+ <ContextMenuPrimitive.SubTrigger
26
+ ref={ref}
27
+ className={cn(
28
+ "flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent data-[state=open]:text-accent-foreground focus:bg-accent focus:text-accent-foreground",
29
+ inset && "pl-8",
30
+ className,
31
+ )}
32
+ {...props}
33
+ >
34
+ {children}
35
+ <ChevronRight className="ml-auto h-4 w-4" />
36
+ </ContextMenuPrimitive.SubTrigger>
37
+ ));
38
+ ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName;
39
+
40
+ const ContextMenuSubContent = React.forwardRef<
41
+ React.ElementRef<typeof ContextMenuPrimitive.SubContent>,
42
+ React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>
43
+ >(({ className, ...props }, ref) => (
44
+ <ContextMenuPrimitive.SubContent
45
+ ref={ref}
46
+ className={cn(
47
+ "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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",
48
+ className,
49
+ )}
50
+ {...props}
51
+ />
52
+ ));
53
+ ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName;
54
+
55
+ const ContextMenuContent = React.forwardRef<
56
+ React.ElementRef<typeof ContextMenuPrimitive.Content>,
57
+ React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>
58
+ >(({ className, ...props }, ref) => (
59
+ <ContextMenuPrimitive.Portal>
60
+ <ContextMenuPrimitive.Content
61
+ ref={ref}
62
+ className={cn(
63
+ "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 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",
64
+ className,
65
+ )}
66
+ {...props}
67
+ />
68
+ </ContextMenuPrimitive.Portal>
69
+ ));
70
+ ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName;
71
+
72
+ const ContextMenuItem = React.forwardRef<
73
+ React.ElementRef<typeof ContextMenuPrimitive.Item>,
74
+ React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {
75
+ inset?: boolean;
76
+ }
77
+ >(({ className, inset, ...props }, ref) => (
78
+ <ContextMenuPrimitive.Item
79
+ ref={ref}
80
+ className={cn(
81
+ "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
82
+ inset && "pl-8",
83
+ className,
84
+ )}
85
+ {...props}
86
+ />
87
+ ));
88
+ ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName;
89
+
90
+ const ContextMenuCheckboxItem = React.forwardRef<
91
+ React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,
92
+ React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>
93
+ >(({ className, children, checked, ...props }, ref) => (
94
+ <ContextMenuPrimitive.CheckboxItem
95
+ ref={ref}
96
+ className={cn(
97
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
98
+ className,
99
+ )}
100
+ checked={checked}
101
+ {...props}
102
+ >
103
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
104
+ <ContextMenuPrimitive.ItemIndicator>
105
+ <Check className="h-4 w-4" />
106
+ </ContextMenuPrimitive.ItemIndicator>
107
+ </span>
108
+ {children}
109
+ </ContextMenuPrimitive.CheckboxItem>
110
+ ));
111
+ ContextMenuCheckboxItem.displayName = ContextMenuPrimitive.CheckboxItem.displayName;
112
+
113
+ const ContextMenuRadioItem = React.forwardRef<
114
+ React.ElementRef<typeof ContextMenuPrimitive.RadioItem>,
115
+ React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem>
116
+ >(({ className, children, ...props }, ref) => (
117
+ <ContextMenuPrimitive.RadioItem
118
+ ref={ref}
119
+ className={cn(
120
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",
121
+ className,
122
+ )}
123
+ {...props}
124
+ >
125
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
126
+ <ContextMenuPrimitive.ItemIndicator>
127
+ <Circle className="h-2 w-2 fill-current" />
128
+ </ContextMenuPrimitive.ItemIndicator>
129
+ </span>
130
+ {children}
131
+ </ContextMenuPrimitive.RadioItem>
132
+ ));
133
+ ContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName;
134
+
135
+ const ContextMenuLabel = React.forwardRef<
136
+ React.ElementRef<typeof ContextMenuPrimitive.Label>,
137
+ React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & {
138
+ inset?: boolean;
139
+ }
140
+ >(({ className, inset, ...props }, ref) => (
141
+ <ContextMenuPrimitive.Label
142
+ ref={ref}
143
+ className={cn("px-2 py-1.5 text-sm font-semibold text-foreground", inset && "pl-8", className)}
144
+ {...props}
145
+ />
146
+ ));
147
+ ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName;
148
+
149
+ const ContextMenuSeparator = React.forwardRef<
150
+ React.ElementRef<typeof ContextMenuPrimitive.Separator>,
151
+ React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>
152
+ >(({ className, ...props }, ref) => (
153
+ <ContextMenuPrimitive.Separator ref={ref} className={cn("-mx-1 my-1 h-px bg-border", className)} {...props} />
154
+ ));
155
+ ContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName;
156
+
157
+ const ContextMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
158
+ return <span className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)} {...props} />;
159
+ };
160
+ ContextMenuShortcut.displayName = "ContextMenuShortcut";
161
+
162
+ export {
163
+ ContextMenu,
164
+ ContextMenuTrigger,
165
+ ContextMenuContent,
166
+ ContextMenuItem,
167
+ ContextMenuCheckboxItem,
168
+ ContextMenuRadioItem,
169
+ ContextMenuLabel,
170
+ ContextMenuSeparator,
171
+ ContextMenuShortcut,
172
+ ContextMenuGroup,
173
+ ContextMenuPortal,
174
+ ContextMenuSub,
175
+ ContextMenuSubContent,
176
+ ContextMenuSubTrigger,
177
+ ContextMenuRadioGroup,
178
+ };