- update-Nitrov3.sh: build CMS into .next-staging and swap atomically so a failed build never takes the live site down; auto-merge new variables from .env.example; validate env for duplicates/broken lines; restart the emulator/CMS only when rebuilt or unhealthy; fix step renumbering - next.config.ts: support NEXT_DIST_DIR for staged production builds - fix all TS errors (unused imports, missing tryDownloadCandidates helper) so tsc and the production build pass clean - add Dockerfile/.dockerignore and switch docker-compose to a CMS container - include prevailing UI/refactor changes (SurfaceCard, ticketing, tsconfig)
181 lines
5.4 KiB
TypeScript
181 lines
5.4 KiB
TypeScript
"use client";
|
|
|
|
import { Select as SelectPrimitive } from "@base-ui/react/select";
|
|
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react";
|
|
import type * as React from "react";
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
type SelectProps = Omit<SelectPrimitive.Root.Props<string>, "onValueChange"> & {
|
|
onValueChange?: (value: string) => void;
|
|
};
|
|
|
|
function Select({ onValueChange, ...props }: SelectProps) {
|
|
return (
|
|
<SelectPrimitive.Root
|
|
data-slot="select"
|
|
onValueChange={(value) => {
|
|
if (value == null) return;
|
|
onValueChange?.(value);
|
|
}}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|
|
|
|
function SelectValue({ className, ...props }: SelectPrimitive.Value.Props) {
|
|
return (
|
|
<SelectPrimitive.Value
|
|
data-slot="select-value"
|
|
className={cn(className)}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|
|
|
|
function SelectTrigger({
|
|
className,
|
|
size = "default",
|
|
children,
|
|
...props
|
|
}: SelectPrimitive.Trigger.Props & {
|
|
size?: "sm" | "default";
|
|
}) {
|
|
return (
|
|
<SelectPrimitive.Trigger
|
|
data-slot="select-trigger"
|
|
data-size={size}
|
|
className={cn(
|
|
"border-input data-placeholder:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive bg-background dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
className,
|
|
)}
|
|
{...props}
|
|
>
|
|
{children}
|
|
<SelectPrimitive.Icon
|
|
render={<ChevronDownIcon className="size-4 opacity-50" />}
|
|
/>
|
|
</SelectPrimitive.Trigger>
|
|
);
|
|
}
|
|
|
|
function SelectContent({
|
|
className,
|
|
children,
|
|
side = "bottom",
|
|
sideOffset = 4,
|
|
align = "center",
|
|
alignOffset = 0,
|
|
alignItemWithTrigger = true,
|
|
position: _position,
|
|
...props
|
|
}: SelectPrimitive.Popup.Props &
|
|
Pick<
|
|
SelectPrimitive.Positioner.Props,
|
|
"align" | "alignOffset" | "side" | "sideOffset" | "alignItemWithTrigger"
|
|
> & {
|
|
/** @deprecated Radix compat — ignored */
|
|
position?: "popper" | "item-aligned";
|
|
}) {
|
|
return (
|
|
<SelectPrimitive.Portal>
|
|
<SelectPrimitive.Positioner
|
|
side={side}
|
|
sideOffset={sideOffset}
|
|
align={align}
|
|
alignOffset={alignOffset}
|
|
alignItemWithTrigger={alignItemWithTrigger}
|
|
className="isolate z-50"
|
|
>
|
|
<SelectPrimitive.Popup
|
|
data-slot="select-content"
|
|
className={cn(
|
|
"bg-popover text-popover-foreground 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 relative z-50 max-h-(--available-height) min-w-[8rem] w-(--anchor-width) origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
|
|
className,
|
|
)}
|
|
{...props}
|
|
>
|
|
<SelectScrollUpButton />
|
|
<SelectPrimitive.List className="p-1">
|
|
{children}
|
|
</SelectPrimitive.List>
|
|
<SelectScrollDownButton />
|
|
</SelectPrimitive.Popup>
|
|
</SelectPrimitive.Positioner>
|
|
</SelectPrimitive.Portal>
|
|
);
|
|
}
|
|
|
|
function SelectItem({
|
|
className,
|
|
children,
|
|
...props
|
|
}: SelectPrimitive.Item.Props) {
|
|
return (
|
|
<SelectPrimitive.Item
|
|
data-slot="select-item"
|
|
className={cn(
|
|
"focus:bg-accent focus:text-accent-foreground data-highlighted:bg-accent data-highlighted:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 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 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
|
|
className,
|
|
)}
|
|
{...props}
|
|
>
|
|
<span
|
|
data-slot="select-item-indicator"
|
|
className="absolute right-2 flex size-3.5 items-center justify-center"
|
|
>
|
|
<SelectPrimitive.ItemIndicator>
|
|
<CheckIcon className="size-4" />
|
|
</SelectPrimitive.ItemIndicator>
|
|
</span>
|
|
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
|
</SelectPrimitive.Item>
|
|
);
|
|
}
|
|
|
|
function SelectScrollUpButton({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<typeof SelectPrimitive.ScrollUpArrow>) {
|
|
return (
|
|
<SelectPrimitive.ScrollUpArrow
|
|
data-slot="select-scroll-up-button"
|
|
className={cn(
|
|
"flex cursor-default items-center justify-center py-1",
|
|
className,
|
|
)}
|
|
{...props}
|
|
>
|
|
<ChevronUpIcon className="size-4" />
|
|
</SelectPrimitive.ScrollUpArrow>
|
|
);
|
|
}
|
|
|
|
function SelectScrollDownButton({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<typeof SelectPrimitive.ScrollDownArrow>) {
|
|
return (
|
|
<SelectPrimitive.ScrollDownArrow
|
|
data-slot="select-scroll-down-button"
|
|
className={cn(
|
|
"flex cursor-default items-center justify-center py-1",
|
|
className,
|
|
)}
|
|
{...props}
|
|
>
|
|
<ChevronDownIcon className="size-4" />
|
|
</SelectPrimitive.ScrollDownArrow>
|
|
);
|
|
}
|
|
|
|
export {
|
|
Select,
|
|
SelectContent,
|
|
SelectItem,
|
|
SelectScrollDownButton,
|
|
SelectScrollUpButton,
|
|
SelectTrigger,
|
|
SelectValue,
|
|
};
|