mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 02:45:39 -04:00
- Delete lib/api/errors.ts and lib/api/auth-guard.ts, inline NextResponse.json() error responses directly in route handlers - Replace non-standard amber CSS variables with primary/primary-foreground - Regenerate shadcn UI components with biome-ignore comments - Add CLAUDE.md for repository guidance - Update dependencies and pnpm lockfile Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
272 lines
8.2 KiB
TypeScript
272 lines
8.2 KiB
TypeScript
"use client";
|
|
|
|
import { ContextMenu as ContextMenuPrimitive } from "@base-ui/react/context-menu";
|
|
import { IconCheck, IconChevronRight } from "@tabler/icons-react";
|
|
import type * as React from "react";
|
|
import { cn } from "@/lib/utils";
|
|
|
|
function ContextMenu({ ...props }: ContextMenuPrimitive.Root.Props) {
|
|
return <ContextMenuPrimitive.Root data-slot="context-menu" {...props} />;
|
|
}
|
|
|
|
function ContextMenuPortal({ ...props }: ContextMenuPrimitive.Portal.Props) {
|
|
return (
|
|
<ContextMenuPrimitive.Portal data-slot="context-menu-portal" {...props} />
|
|
);
|
|
}
|
|
|
|
function ContextMenuTrigger({
|
|
className,
|
|
...props
|
|
}: ContextMenuPrimitive.Trigger.Props) {
|
|
return (
|
|
<ContextMenuPrimitive.Trigger
|
|
data-slot="context-menu-trigger"
|
|
className={cn("select-none", className)}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|
|
|
|
function ContextMenuContent({
|
|
className,
|
|
align = "start",
|
|
alignOffset = 4,
|
|
side = "right",
|
|
sideOffset = 0,
|
|
...props
|
|
}: ContextMenuPrimitive.Popup.Props &
|
|
Pick<
|
|
ContextMenuPrimitive.Positioner.Props,
|
|
"align" | "alignOffset" | "side" | "sideOffset"
|
|
>) {
|
|
return (
|
|
<ContextMenuPrimitive.Portal>
|
|
<ContextMenuPrimitive.Positioner
|
|
className="isolate z-50 outline-none"
|
|
align={align}
|
|
alignOffset={alignOffset}
|
|
side={side}
|
|
sideOffset={sideOffset}
|
|
>
|
|
<ContextMenuPrimitive.Popup
|
|
data-slot="context-menu-content"
|
|
className={cn(
|
|
"data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-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 ring-foreground/10 bg-popover text-popover-foreground data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2 z-50 max-h-(--available-height) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg p-1 shadow-md ring-1 duration-100 outline-none",
|
|
className,
|
|
)}
|
|
{...props}
|
|
/>
|
|
</ContextMenuPrimitive.Positioner>
|
|
</ContextMenuPrimitive.Portal>
|
|
);
|
|
}
|
|
|
|
function ContextMenuGroup({ ...props }: ContextMenuPrimitive.Group.Props) {
|
|
return (
|
|
<ContextMenuPrimitive.Group data-slot="context-menu-group" {...props} />
|
|
);
|
|
}
|
|
|
|
function ContextMenuLabel({
|
|
className,
|
|
inset,
|
|
...props
|
|
}: ContextMenuPrimitive.GroupLabel.Props & {
|
|
inset?: boolean;
|
|
}) {
|
|
return (
|
|
<ContextMenuPrimitive.GroupLabel
|
|
data-slot="context-menu-label"
|
|
data-inset={inset}
|
|
className={cn(
|
|
"text-muted-foreground px-2 py-1.5 text-xs data-inset:pl-7.5",
|
|
className,
|
|
)}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|
|
|
|
function ContextMenuItem({
|
|
className,
|
|
inset,
|
|
variant = "default",
|
|
...props
|
|
}: ContextMenuPrimitive.Item.Props & {
|
|
inset?: boolean;
|
|
variant?: "default" | "destructive";
|
|
}) {
|
|
return (
|
|
<ContextMenuPrimitive.Item
|
|
data-slot="context-menu-item"
|
|
data-inset={inset}
|
|
data-variant={variant}
|
|
className={cn(
|
|
"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 not-data-[variant=destructive]:focus:**:text-accent-foreground group/context-menu-item relative flex min-h-7 cursor-default items-center gap-2 rounded-md px-2 py-1 text-xs/relaxed outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-7.5 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",
|
|
className,
|
|
)}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|
|
|
|
function ContextMenuSub({ ...props }: ContextMenuPrimitive.SubmenuRoot.Props) {
|
|
return (
|
|
<ContextMenuPrimitive.SubmenuRoot data-slot="context-menu-sub" {...props} />
|
|
);
|
|
}
|
|
|
|
function ContextMenuSubTrigger({
|
|
className,
|
|
inset,
|
|
children,
|
|
...props
|
|
}: ContextMenuPrimitive.SubmenuTrigger.Props & {
|
|
inset?: boolean;
|
|
}) {
|
|
return (
|
|
<ContextMenuPrimitive.SubmenuTrigger
|
|
data-slot="context-menu-sub-trigger"
|
|
data-inset={inset}
|
|
className={cn(
|
|
"focus:bg-accent focus:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground flex min-h-7 cursor-default items-center gap-2 rounded-md px-2 py-1 text-xs outline-hidden select-none data-inset:pl-7.5 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",
|
|
className,
|
|
)}
|
|
{...props}
|
|
>
|
|
{children}
|
|
<IconChevronRight className="ml-auto" />
|
|
</ContextMenuPrimitive.SubmenuTrigger>
|
|
);
|
|
}
|
|
|
|
function ContextMenuSubContent({
|
|
...props
|
|
}: React.ComponentProps<typeof ContextMenuContent>) {
|
|
return (
|
|
<ContextMenuContent
|
|
data-slot="context-menu-sub-content"
|
|
className="shadow-lg"
|
|
side="right"
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|
|
|
|
function ContextMenuCheckboxItem({
|
|
className,
|
|
children,
|
|
checked,
|
|
inset,
|
|
...props
|
|
}: ContextMenuPrimitive.CheckboxItem.Props & {
|
|
inset?: boolean;
|
|
}) {
|
|
return (
|
|
<ContextMenuPrimitive.CheckboxItem
|
|
data-slot="context-menu-checkbox-item"
|
|
data-inset={inset}
|
|
className={cn(
|
|
"focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground relative flex min-h-7 cursor-default items-center gap-2 rounded-md py-1.5 pr-8 pl-2 text-xs outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-7.5 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",
|
|
className,
|
|
)}
|
|
checked={checked}
|
|
{...props}
|
|
>
|
|
<span className="pointer-events-none absolute right-2 flex items-center justify-center">
|
|
<ContextMenuPrimitive.CheckboxItemIndicator>
|
|
<IconCheck />
|
|
</ContextMenuPrimitive.CheckboxItemIndicator>
|
|
</span>
|
|
{children}
|
|
</ContextMenuPrimitive.CheckboxItem>
|
|
);
|
|
}
|
|
|
|
function ContextMenuRadioGroup({
|
|
...props
|
|
}: ContextMenuPrimitive.RadioGroup.Props) {
|
|
return (
|
|
<ContextMenuPrimitive.RadioGroup
|
|
data-slot="context-menu-radio-group"
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|
|
|
|
function ContextMenuRadioItem({
|
|
className,
|
|
children,
|
|
inset,
|
|
...props
|
|
}: ContextMenuPrimitive.RadioItem.Props & {
|
|
inset?: boolean;
|
|
}) {
|
|
return (
|
|
<ContextMenuPrimitive.RadioItem
|
|
data-slot="context-menu-radio-item"
|
|
data-inset={inset}
|
|
className={cn(
|
|
"focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground relative flex min-h-7 cursor-default items-center gap-2 rounded-md py-1.5 pr-8 pl-2 text-xs outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-7.5 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",
|
|
className,
|
|
)}
|
|
{...props}
|
|
>
|
|
<span className="pointer-events-none absolute right-2 flex items-center justify-center">
|
|
<ContextMenuPrimitive.RadioItemIndicator>
|
|
<IconCheck />
|
|
</ContextMenuPrimitive.RadioItemIndicator>
|
|
</span>
|
|
{children}
|
|
</ContextMenuPrimitive.RadioItem>
|
|
);
|
|
}
|
|
|
|
function ContextMenuSeparator({
|
|
className,
|
|
...props
|
|
}: ContextMenuPrimitive.Separator.Props) {
|
|
return (
|
|
<ContextMenuPrimitive.Separator
|
|
data-slot="context-menu-separator"
|
|
className={cn("bg-border/50 -mx-1 my-1 h-px", className)}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|
|
|
|
function ContextMenuShortcut({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<"span">) {
|
|
return (
|
|
<span
|
|
data-slot="context-menu-shortcut"
|
|
className={cn(
|
|
"text-muted-foreground group-focus/context-menu-item:text-accent-foreground ml-auto text-[0.625rem] tracking-widest",
|
|
className,
|
|
)}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export {
|
|
ContextMenu,
|
|
ContextMenuTrigger,
|
|
ContextMenuContent,
|
|
ContextMenuItem,
|
|
ContextMenuCheckboxItem,
|
|
ContextMenuRadioItem,
|
|
ContextMenuLabel,
|
|
ContextMenuSeparator,
|
|
ContextMenuShortcut,
|
|
ContextMenuGroup,
|
|
ContextMenuPortal,
|
|
ContextMenuSub,
|
|
ContextMenuSubContent,
|
|
ContextMenuSubTrigger,
|
|
ContextMenuRadioGroup,
|
|
};
|