@vendure/dashboard 3.3.8-master-202507220240 → 3.3.8-master-202507231129
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 +39 -26
- package/src/lib/components/ui/aspect-ratio.tsx +9 -0
- package/src/lib/components/ui/avatar.tsx +53 -0
- package/src/lib/components/ui/carousel.tsx +241 -0
- package/src/lib/components/ui/chart.tsx +351 -0
- package/src/lib/components/ui/context-menu.tsx +252 -0
- package/src/lib/components/ui/drawer.tsx +133 -0
- package/src/lib/components/ui/input-otp.tsx +77 -0
- package/src/lib/components/ui/menubar.tsx +274 -0
- package/src/lib/components/ui/navigation-menu.tsx +168 -0
- package/src/lib/components/ui/progress.tsx +29 -0
- package/src/lib/components/ui/radio-group.tsx +45 -0
- package/src/lib/components/ui/resizable.tsx +54 -0
- package/src/lib/components/ui/slider.tsx +63 -0
- package/src/lib/components/ui/toggle-group.tsx +73 -0
- package/src/lib/components/ui/toggle.tsx +45 -0
- package/src/lib/index.ts +19 -0
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as RechartsPrimitive from "recharts"
|
|
3
|
+
|
|
4
|
+
import { cn } from "@/vdb/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
|
+
} & (
|
|
14
|
+
| { color?: string; theme?: never }
|
|
15
|
+
| { color?: never; theme: Record<keyof typeof THEMES, string> }
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type ChartContextProps = {
|
|
20
|
+
config: ChartConfig
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const ChartContext = React.createContext<ChartContextProps | null>(null)
|
|
24
|
+
|
|
25
|
+
function useChart() {
|
|
26
|
+
const context = React.useContext(ChartContext)
|
|
27
|
+
|
|
28
|
+
if (!context) {
|
|
29
|
+
throw new Error("useChart must be used within a <ChartContainer />")
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return context
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function ChartContainer({
|
|
36
|
+
id,
|
|
37
|
+
className,
|
|
38
|
+
children,
|
|
39
|
+
config,
|
|
40
|
+
...props
|
|
41
|
+
}: React.ComponentProps<"div"> & {
|
|
42
|
+
config: ChartConfig
|
|
43
|
+
children: React.ComponentProps<
|
|
44
|
+
typeof RechartsPrimitive.ResponsiveContainer
|
|
45
|
+
>["children"]
|
|
46
|
+
}) {
|
|
47
|
+
const uniqueId = React.useId()
|
|
48
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<ChartContext.Provider value={{ config }}>
|
|
52
|
+
<div
|
|
53
|
+
data-slot="chart"
|
|
54
|
+
data-chart={chartId}
|
|
55
|
+
className={cn(
|
|
56
|
+
"[&_.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",
|
|
57
|
+
className
|
|
58
|
+
)}
|
|
59
|
+
{...props}
|
|
60
|
+
>
|
|
61
|
+
<ChartStyle id={chartId} config={config} />
|
|
62
|
+
<RechartsPrimitive.ResponsiveContainer>
|
|
63
|
+
{children}
|
|
64
|
+
</RechartsPrimitive.ResponsiveContainer>
|
|
65
|
+
</div>
|
|
66
|
+
</ChartContext.Provider>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
|
71
|
+
const colorConfig = Object.entries(config).filter(
|
|
72
|
+
([, config]) => config.theme || config.color
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
if (!colorConfig.length) {
|
|
76
|
+
return null
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<style
|
|
81
|
+
dangerouslySetInnerHTML={{
|
|
82
|
+
__html: Object.entries(THEMES)
|
|
83
|
+
.map(
|
|
84
|
+
([theme, prefix]) => `
|
|
85
|
+
${prefix} [data-chart=${id}] {
|
|
86
|
+
${colorConfig
|
|
87
|
+
.map(([key, itemConfig]) => {
|
|
88
|
+
const color =
|
|
89
|
+
itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ||
|
|
90
|
+
itemConfig.color
|
|
91
|
+
return color ? ` --color-${key}: ${color};` : null
|
|
92
|
+
})
|
|
93
|
+
.join("\n")}
|
|
94
|
+
}
|
|
95
|
+
`
|
|
96
|
+
)
|
|
97
|
+
.join("\n"),
|
|
98
|
+
}}
|
|
99
|
+
/>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const ChartTooltip = RechartsPrimitive.Tooltip
|
|
104
|
+
|
|
105
|
+
function ChartTooltipContent({
|
|
106
|
+
active,
|
|
107
|
+
payload,
|
|
108
|
+
className,
|
|
109
|
+
indicator = "dot",
|
|
110
|
+
hideLabel = false,
|
|
111
|
+
hideIndicator = false,
|
|
112
|
+
label,
|
|
113
|
+
labelFormatter,
|
|
114
|
+
labelClassName,
|
|
115
|
+
formatter,
|
|
116
|
+
color,
|
|
117
|
+
nameKey,
|
|
118
|
+
labelKey,
|
|
119
|
+
}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
|
|
120
|
+
React.ComponentProps<"div"> & {
|
|
121
|
+
hideLabel?: boolean
|
|
122
|
+
hideIndicator?: boolean
|
|
123
|
+
indicator?: "line" | "dot" | "dashed"
|
|
124
|
+
nameKey?: string
|
|
125
|
+
labelKey?: string
|
|
126
|
+
}) {
|
|
127
|
+
const { config } = useChart()
|
|
128
|
+
|
|
129
|
+
const tooltipLabel = React.useMemo(() => {
|
|
130
|
+
if (hideLabel || !payload?.length) {
|
|
131
|
+
return null
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const [item] = payload
|
|
135
|
+
const key = `${labelKey || item?.dataKey || item?.name || "value"}`
|
|
136
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
137
|
+
const value =
|
|
138
|
+
!labelKey && typeof label === "string"
|
|
139
|
+
? config[label as keyof typeof config]?.label || label
|
|
140
|
+
: itemConfig?.label
|
|
141
|
+
|
|
142
|
+
if (labelFormatter) {
|
|
143
|
+
return (
|
|
144
|
+
<div className={cn("font-medium", labelClassName)}>
|
|
145
|
+
{labelFormatter(value, payload)}
|
|
146
|
+
</div>
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (!value) {
|
|
151
|
+
return null
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return <div className={cn("font-medium", labelClassName)}>{value}</div>
|
|
155
|
+
}, [
|
|
156
|
+
label,
|
|
157
|
+
labelFormatter,
|
|
158
|
+
payload,
|
|
159
|
+
hideLabel,
|
|
160
|
+
labelClassName,
|
|
161
|
+
config,
|
|
162
|
+
labelKey,
|
|
163
|
+
])
|
|
164
|
+
|
|
165
|
+
if (!active || !payload?.length) {
|
|
166
|
+
return null
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const nestLabel = payload.length === 1 && indicator !== "dot"
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<div
|
|
173
|
+
className={cn(
|
|
174
|
+
"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",
|
|
175
|
+
className
|
|
176
|
+
)}
|
|
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
|
+
>
|
|
193
|
+
{formatter && item?.value !== undefined && item.name ? (
|
|
194
|
+
formatter(item.value, item.name, item, index, item.payload)
|
|
195
|
+
) : (
|
|
196
|
+
<>
|
|
197
|
+
{itemConfig?.icon ? (
|
|
198
|
+
<itemConfig.icon />
|
|
199
|
+
) : (
|
|
200
|
+
!hideIndicator && (
|
|
201
|
+
<div
|
|
202
|
+
className={cn(
|
|
203
|
+
"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
|
|
204
|
+
{
|
|
205
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
206
|
+
"w-1": indicator === "line",
|
|
207
|
+
"w-0 border-[1.5px] border-dashed bg-transparent":
|
|
208
|
+
indicator === "dashed",
|
|
209
|
+
"my-0.5": nestLabel && indicator === "dashed",
|
|
210
|
+
}
|
|
211
|
+
)}
|
|
212
|
+
style={
|
|
213
|
+
{
|
|
214
|
+
"--color-bg": indicatorColor,
|
|
215
|
+
"--color-border": indicatorColor,
|
|
216
|
+
} as React.CSSProperties
|
|
217
|
+
}
|
|
218
|
+
/>
|
|
219
|
+
)
|
|
220
|
+
)}
|
|
221
|
+
<div
|
|
222
|
+
className={cn(
|
|
223
|
+
"flex flex-1 justify-between leading-none",
|
|
224
|
+
nestLabel ? "items-end" : "items-center"
|
|
225
|
+
)}
|
|
226
|
+
>
|
|
227
|
+
<div className="grid gap-1.5">
|
|
228
|
+
{nestLabel ? tooltipLabel : null}
|
|
229
|
+
<span className="text-muted-foreground">
|
|
230
|
+
{itemConfig?.label || item.name}
|
|
231
|
+
</span>
|
|
232
|
+
</div>
|
|
233
|
+
{item.value && (
|
|
234
|
+
<span className="text-foreground font-mono font-medium tabular-nums">
|
|
235
|
+
{item.value.toLocaleString()}
|
|
236
|
+
</span>
|
|
237
|
+
)}
|
|
238
|
+
</div>
|
|
239
|
+
</>
|
|
240
|
+
)}
|
|
241
|
+
</div>
|
|
242
|
+
)
|
|
243
|
+
})}
|
|
244
|
+
</div>
|
|
245
|
+
</div>
|
|
246
|
+
)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const ChartLegend = RechartsPrimitive.Legend
|
|
250
|
+
|
|
251
|
+
function ChartLegendContent({
|
|
252
|
+
className,
|
|
253
|
+
hideIcon = false,
|
|
254
|
+
payload,
|
|
255
|
+
verticalAlign = "bottom",
|
|
256
|
+
nameKey,
|
|
257
|
+
}: React.ComponentProps<"div"> &
|
|
258
|
+
Pick<RechartsPrimitive.LegendProps, "payload" | "verticalAlign"> & {
|
|
259
|
+
hideIcon?: boolean
|
|
260
|
+
nameKey?: string
|
|
261
|
+
}) {
|
|
262
|
+
const { config } = useChart()
|
|
263
|
+
|
|
264
|
+
if (!payload?.length) {
|
|
265
|
+
return null
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return (
|
|
269
|
+
<div
|
|
270
|
+
className={cn(
|
|
271
|
+
"flex items-center justify-center gap-4",
|
|
272
|
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
|
273
|
+
className
|
|
274
|
+
)}
|
|
275
|
+
>
|
|
276
|
+
{payload.map((item) => {
|
|
277
|
+
const key = `${nameKey || item.dataKey || "value"}`
|
|
278
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
279
|
+
|
|
280
|
+
return (
|
|
281
|
+
<div
|
|
282
|
+
key={item.value}
|
|
283
|
+
className={cn(
|
|
284
|
+
"[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"
|
|
285
|
+
)}
|
|
286
|
+
>
|
|
287
|
+
{itemConfig?.icon && !hideIcon ? (
|
|
288
|
+
<itemConfig.icon />
|
|
289
|
+
) : (
|
|
290
|
+
<div
|
|
291
|
+
className="h-2 w-2 shrink-0 rounded-[2px]"
|
|
292
|
+
style={{
|
|
293
|
+
backgroundColor: item.color,
|
|
294
|
+
}}
|
|
295
|
+
/>
|
|
296
|
+
)}
|
|
297
|
+
{itemConfig?.label}
|
|
298
|
+
</div>
|
|
299
|
+
)
|
|
300
|
+
})}
|
|
301
|
+
</div>
|
|
302
|
+
)
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Helper to extract item config from a payload.
|
|
306
|
+
function getPayloadConfigFromPayload(
|
|
307
|
+
config: ChartConfig,
|
|
308
|
+
payload: unknown,
|
|
309
|
+
key: string
|
|
310
|
+
) {
|
|
311
|
+
if (typeof payload !== "object" || payload === null) {
|
|
312
|
+
return undefined
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
const payloadPayload =
|
|
316
|
+
"payload" in payload &&
|
|
317
|
+
typeof payload.payload === "object" &&
|
|
318
|
+
payload.payload !== null
|
|
319
|
+
? payload.payload
|
|
320
|
+
: undefined
|
|
321
|
+
|
|
322
|
+
let configLabelKey: string = key
|
|
323
|
+
|
|
324
|
+
if (
|
|
325
|
+
key in payload &&
|
|
326
|
+
typeof payload[key as keyof typeof payload] === "string"
|
|
327
|
+
) {
|
|
328
|
+
configLabelKey = payload[key as keyof typeof payload] as string
|
|
329
|
+
} else if (
|
|
330
|
+
payloadPayload &&
|
|
331
|
+
key in payloadPayload &&
|
|
332
|
+
typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
|
|
333
|
+
) {
|
|
334
|
+
configLabelKey = payloadPayload[
|
|
335
|
+
key as keyof typeof payloadPayload
|
|
336
|
+
] as string
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return configLabelKey in config
|
|
340
|
+
? config[configLabelKey]
|
|
341
|
+
: config[key as keyof typeof config]
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export {
|
|
345
|
+
ChartContainer,
|
|
346
|
+
ChartTooltip,
|
|
347
|
+
ChartTooltipContent,
|
|
348
|
+
ChartLegend,
|
|
349
|
+
ChartLegendContent,
|
|
350
|
+
ChartStyle,
|
|
351
|
+
}
|
|
@@ -0,0 +1,252 @@
|
|
|
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 "@/vdb/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-default 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
|
+
>
|
|
74
|
+
{children}
|
|
75
|
+
<ChevronRightIcon className="ml-auto" />
|
|
76
|
+
</ContextMenuPrimitive.SubTrigger>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function ContextMenuSubContent({
|
|
81
|
+
className,
|
|
82
|
+
...props
|
|
83
|
+
}: React.ComponentProps<typeof ContextMenuPrimitive.SubContent>) {
|
|
84
|
+
return (
|
|
85
|
+
<ContextMenuPrimitive.SubContent
|
|
86
|
+
data-slot="context-menu-sub-content"
|
|
87
|
+
className={cn(
|
|
88
|
+
"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",
|
|
89
|
+
className
|
|
90
|
+
)}
|
|
91
|
+
{...props}
|
|
92
|
+
/>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function ContextMenuContent({
|
|
97
|
+
className,
|
|
98
|
+
...props
|
|
99
|
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Content>) {
|
|
100
|
+
return (
|
|
101
|
+
<ContextMenuPrimitive.Portal>
|
|
102
|
+
<ContextMenuPrimitive.Content
|
|
103
|
+
data-slot="context-menu-content"
|
|
104
|
+
className={cn(
|
|
105
|
+
"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",
|
|
106
|
+
className
|
|
107
|
+
)}
|
|
108
|
+
{...props}
|
|
109
|
+
/>
|
|
110
|
+
</ContextMenuPrimitive.Portal>
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function ContextMenuItem({
|
|
115
|
+
className,
|
|
116
|
+
inset,
|
|
117
|
+
variant = "default",
|
|
118
|
+
...props
|
|
119
|
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Item> & {
|
|
120
|
+
inset?: boolean
|
|
121
|
+
variant?: "default" | "destructive"
|
|
122
|
+
}) {
|
|
123
|
+
return (
|
|
124
|
+
<ContextMenuPrimitive.Item
|
|
125
|
+
data-slot="context-menu-item"
|
|
126
|
+
data-inset={inset}
|
|
127
|
+
data-variant={variant}
|
|
128
|
+
className={cn(
|
|
129
|
+
"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-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
130
|
+
className
|
|
131
|
+
)}
|
|
132
|
+
{...props}
|
|
133
|
+
/>
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function ContextMenuCheckboxItem({
|
|
138
|
+
className,
|
|
139
|
+
children,
|
|
140
|
+
checked,
|
|
141
|
+
...props
|
|
142
|
+
}: React.ComponentProps<typeof ContextMenuPrimitive.CheckboxItem>) {
|
|
143
|
+
return (
|
|
144
|
+
<ContextMenuPrimitive.CheckboxItem
|
|
145
|
+
data-slot="context-menu-checkbox-item"
|
|
146
|
+
className={cn(
|
|
147
|
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
148
|
+
className
|
|
149
|
+
)}
|
|
150
|
+
checked={checked}
|
|
151
|
+
{...props}
|
|
152
|
+
>
|
|
153
|
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
|
154
|
+
<ContextMenuPrimitive.ItemIndicator>
|
|
155
|
+
<CheckIcon className="size-4" />
|
|
156
|
+
</ContextMenuPrimitive.ItemIndicator>
|
|
157
|
+
</span>
|
|
158
|
+
{children}
|
|
159
|
+
</ContextMenuPrimitive.CheckboxItem>
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function ContextMenuRadioItem({
|
|
164
|
+
className,
|
|
165
|
+
children,
|
|
166
|
+
...props
|
|
167
|
+
}: React.ComponentProps<typeof ContextMenuPrimitive.RadioItem>) {
|
|
168
|
+
return (
|
|
169
|
+
<ContextMenuPrimitive.RadioItem
|
|
170
|
+
data-slot="context-menu-radio-item"
|
|
171
|
+
className={cn(
|
|
172
|
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
173
|
+
className
|
|
174
|
+
)}
|
|
175
|
+
{...props}
|
|
176
|
+
>
|
|
177
|
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
|
178
|
+
<ContextMenuPrimitive.ItemIndicator>
|
|
179
|
+
<CircleIcon className="size-2 fill-current" />
|
|
180
|
+
</ContextMenuPrimitive.ItemIndicator>
|
|
181
|
+
</span>
|
|
182
|
+
{children}
|
|
183
|
+
</ContextMenuPrimitive.RadioItem>
|
|
184
|
+
)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function ContextMenuLabel({
|
|
188
|
+
className,
|
|
189
|
+
inset,
|
|
190
|
+
...props
|
|
191
|
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Label> & {
|
|
192
|
+
inset?: boolean
|
|
193
|
+
}) {
|
|
194
|
+
return (
|
|
195
|
+
<ContextMenuPrimitive.Label
|
|
196
|
+
data-slot="context-menu-label"
|
|
197
|
+
data-inset={inset}
|
|
198
|
+
className={cn(
|
|
199
|
+
"text-foreground px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",
|
|
200
|
+
className
|
|
201
|
+
)}
|
|
202
|
+
{...props}
|
|
203
|
+
/>
|
|
204
|
+
)
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function ContextMenuSeparator({
|
|
208
|
+
className,
|
|
209
|
+
...props
|
|
210
|
+
}: React.ComponentProps<typeof ContextMenuPrimitive.Separator>) {
|
|
211
|
+
return (
|
|
212
|
+
<ContextMenuPrimitive.Separator
|
|
213
|
+
data-slot="context-menu-separator"
|
|
214
|
+
className={cn("bg-border -mx-1 my-1 h-px", className)}
|
|
215
|
+
{...props}
|
|
216
|
+
/>
|
|
217
|
+
)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function ContextMenuShortcut({
|
|
221
|
+
className,
|
|
222
|
+
...props
|
|
223
|
+
}: React.ComponentProps<"span">) {
|
|
224
|
+
return (
|
|
225
|
+
<span
|
|
226
|
+
data-slot="context-menu-shortcut"
|
|
227
|
+
className={cn(
|
|
228
|
+
"text-muted-foreground ml-auto text-xs tracking-widest",
|
|
229
|
+
className
|
|
230
|
+
)}
|
|
231
|
+
{...props}
|
|
232
|
+
/>
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export {
|
|
237
|
+
ContextMenu,
|
|
238
|
+
ContextMenuTrigger,
|
|
239
|
+
ContextMenuContent,
|
|
240
|
+
ContextMenuItem,
|
|
241
|
+
ContextMenuCheckboxItem,
|
|
242
|
+
ContextMenuRadioItem,
|
|
243
|
+
ContextMenuLabel,
|
|
244
|
+
ContextMenuSeparator,
|
|
245
|
+
ContextMenuShortcut,
|
|
246
|
+
ContextMenuGroup,
|
|
247
|
+
ContextMenuPortal,
|
|
248
|
+
ContextMenuSub,
|
|
249
|
+
ContextMenuSubContent,
|
|
250
|
+
ContextMenuSubTrigger,
|
|
251
|
+
ContextMenuRadioGroup,
|
|
252
|
+
}
|