chore(web): migrate UI primitives to Base UI
This commit is contained in:
parent
0038295bbc
commit
9c3bd44a1b
54 changed files with 631 additions and 1620 deletions
|
|
@ -17,6 +17,7 @@
|
|||
"test:coverage": "vitest run --coverage"
|
||||
},
|
||||
"dependencies": {
|
||||
"@base-ui/react": "^1.6.0",
|
||||
"@codemirror/autocomplete": "^6.20.3",
|
||||
"@codemirror/commands": "^6.10.4",
|
||||
"@codemirror/lang-markdown": "^6.5.0",
|
||||
|
|
@ -28,17 +29,6 @@
|
|||
"@github/relative-time-element": "^5.0.0",
|
||||
"@lezer/highlight": "^1.2.3",
|
||||
"@lezer/markdown": "^1.6.4",
|
||||
"@radix-ui/react-checkbox": "^1.3.3",
|
||||
"@radix-ui/react-dialog": "^1.1.15",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
||||
"@radix-ui/react-label": "^2.1.8",
|
||||
"@radix-ui/react-popover": "^1.1.15",
|
||||
"@radix-ui/react-radio-group": "^1.3.8",
|
||||
"@radix-ui/react-select": "^2.2.6",
|
||||
"@radix-ui/react-separator": "^1.1.8",
|
||||
"@radix-ui/react-slot": "^1.2.4",
|
||||
"@radix-ui/react-switch": "^1.2.6",
|
||||
"@radix-ui/react-tooltip": "^1.2.8",
|
||||
"@tailwindcss/vite": "^4.2.4",
|
||||
"@tanstack/react-query": "^5.100.9",
|
||||
"@tanstack/react-query-devtools": "^5.100.9",
|
||||
|
|
|
|||
1069
web/pnpm-lock.yaml
1069
web/pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
|
|
@ -71,7 +71,7 @@ export const CalendarCell = memo((props: CalendarCellProps) => {
|
|||
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>{button}</TooltipTrigger>
|
||||
<TooltipTrigger render={button} />
|
||||
<TooltipContent side="top">
|
||||
<p>{tooltipText}</p>
|
||||
</TooltipContent>
|
||||
|
|
|
|||
|
|
@ -73,15 +73,13 @@ export const AttachmentOpenButton = ({ className, href }: AttachmentOpenButtonPr
|
|||
|
||||
return (
|
||||
<Button
|
||||
asChild
|
||||
render={<a href={href} target="_blank" rel="noreferrer" />}
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className={cn("size-7 shrink-0 rounded-full text-muted-foreground hover:text-foreground", className)}
|
||||
>
|
||||
<a href={href} target="_blank" rel="noreferrer">
|
||||
<ExternalLinkIcon className="h-3.5 w-3.5" />
|
||||
<span className="sr-only">{t("attachment-library.actions.open")}</span>
|
||||
</a>
|
||||
<ExternalLinkIcon className="h-3.5 w-3.5" />
|
||||
<span className="sr-only">{t("attachment-library.actions.open")}</span>
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -252,9 +252,14 @@ function FormField({
|
|||
);
|
||||
}
|
||||
|
||||
const identityProviderTypeOptions = [...new Set(templateList.map((template) => template.type))].map((kind) => ({
|
||||
value: String(kind),
|
||||
label: IdentityProvider_Type[kind] || String(kind),
|
||||
}));
|
||||
const templateOptions = templateList.map((template) => ({ value: template.title, label: template.title }));
|
||||
|
||||
function CreateIdentityProviderDialog({ open, onOpenChange, identityProvider, onSuccess }: Props) {
|
||||
const t = useTranslate();
|
||||
const identityProviderTypes = [...new Set(templateList.map((template) => template.type))];
|
||||
const [basicInfo, setBasicInfo] = useState<BasicInfoState>(createEmptyBasicInfo);
|
||||
const [type, setType] = useState<IdentityProvider_Type>(IdentityProvider_Type.OAUTH2);
|
||||
const [oauth2Config, setOAuth2Config] = useState<OAuth2Config>(createEmptyOAuth2Config);
|
||||
|
|
@ -411,14 +416,18 @@ function CreateIdentityProviderDialog({ open, onOpenChange, identityProvider, on
|
|||
{isCreating ? (
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
<FormField label={t("common.type")} required>
|
||||
<Select value={String(type)} onValueChange={(value) => setType(Number(value) as IdentityProvider_Type)}>
|
||||
<Select
|
||||
value={String(type)}
|
||||
items={identityProviderTypeOptions}
|
||||
onValueChange={(value) => setType(Number(value) as IdentityProvider_Type)}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{identityProviderTypes.map((kind) => (
|
||||
<SelectItem key={kind} value={String(kind)}>
|
||||
{IdentityProvider_Type[kind] || kind}
|
||||
{identityProviderTypeOptions.map((option) => (
|
||||
<SelectItem key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
|
|
@ -426,14 +435,14 @@ function CreateIdentityProviderDialog({ open, onOpenChange, identityProvider, on
|
|||
</FormField>
|
||||
|
||||
<FormField label={t("setting.sso.template")} required description={t("setting.sso.template-description")}>
|
||||
<Select value={selectedTemplate} onValueChange={setSelectedTemplate}>
|
||||
<Select value={selectedTemplate} items={templateOptions} onValueChange={setSelectedTemplate}>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{templateList.map((template) => (
|
||||
<SelectItem key={template.title} value={template.title}>
|
||||
{template.title}
|
||||
{templateOptions.map((option) => (
|
||||
<SelectItem key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
|
|
|
|||
|
|
@ -15,10 +15,8 @@ const LearnMore: React.FC<Props> = (props: Props) => {
|
|||
return (
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<a className={`text-muted-foreground hover:text-primary ${className}`} href={url} target="_blank">
|
||||
<ExternalLinkIcon className="w-4 h-auto" />
|
||||
</a>
|
||||
<TooltipTrigger render={<a className={`text-muted-foreground hover:text-primary ${className}`} href={url} target="_blank" />}>
|
||||
<ExternalLinkIcon className="w-4 h-auto" />
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p>{title ?? t("common.learn-more")}</p>
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export const LocaleSearchList = (props: LocaleSearchListProps) => {
|
|||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"flex max-h-[min(24rem,calc(100vh-2rem))] w-[var(--radix-popover-trigger-width)] min-w-48 max-w-[calc(100vw-2rem)] flex-col",
|
||||
"flex max-h-[min(24rem,calc(100vh-2rem))] w-[var(--anchor-width)] min-w-48 max-w-[calc(100vw-2rem)] flex-col",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
|
|
@ -98,14 +98,12 @@ const LocalePicker = (props: LocalePickerProps) => {
|
|||
|
||||
return (
|
||||
<Popover open={open} onOpenChange={setOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
<Button type="button" variant="outline" className={cn("w-full justify-between", className)}>
|
||||
<span className="flex min-w-0 flex-1 items-center gap-2">
|
||||
<GlobeIcon className="size-4 shrink-0 text-muted-foreground" />
|
||||
<span className="truncate">{getLocaleDisplayName(value)}</span>
|
||||
</span>
|
||||
<ChevronDownIcon className="size-4 shrink-0 text-muted-foreground" />
|
||||
</Button>
|
||||
<PopoverTrigger render={<Button type="button" variant="outline" className={cn("w-full justify-between", className)} />}>
|
||||
<span className="flex min-w-0 flex-1 items-center gap-2">
|
||||
<GlobeIcon className="size-4 shrink-0 text-muted-foreground" />
|
||||
<span className="truncate">{getLocaleDisplayName(value)}</span>
|
||||
</span>
|
||||
<ChevronDownIcon className="size-4 shrink-0 text-muted-foreground" />
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="start" className="p-0">
|
||||
<LocaleSearchList value={value} onChange={handleChange} />
|
||||
|
|
|
|||
|
|
@ -65,10 +65,8 @@ const MemoActionMenu = (props: MemoActionMenuProps) => {
|
|||
|
||||
return (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="ghost" size="icon" className="size-4">
|
||||
<MoreVerticalIcon className="text-muted-foreground" />
|
||||
</Button>
|
||||
<DropdownMenuTrigger render={<Button variant="ghost" size="icon" className="size-4" />}>
|
||||
<MoreVerticalIcon className="text-muted-foreground" />
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" sideOffset={2}>
|
||||
{/* Edit actions (non-readonly, non-archived) */}
|
||||
|
|
|
|||
|
|
@ -21,10 +21,8 @@ const MemoDetailSidebarDrawer = ({ memo, onShareImageOpen }: Props) => {
|
|||
|
||||
return (
|
||||
<Sheet open={open} onOpenChange={setOpen}>
|
||||
<SheetTrigger asChild>
|
||||
<Button variant="ghost" size="sm" className="px-2">
|
||||
<GanttChartIcon className="w-5 h-auto text-muted-foreground" />
|
||||
</Button>
|
||||
<SheetTrigger render={<Button variant="ghost" size="sm" className="px-2" />}>
|
||||
<GanttChartIcon className="w-5 h-auto text-muted-foreground" />
|
||||
</SheetTrigger>
|
||||
<SheetContent side="right" className="w-full sm:w-80 px-4 bg-background">
|
||||
<MemoDetailSidebar className="py-4" memo={memo} onShareImageOpen={onShareImageOpen} />
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { timestampDate } from "@bufbuild/protobuf/wkt";
|
||||
import { ConnectError } from "@connectrpc/connect";
|
||||
import { CheckIcon, CopyIcon, LinkIcon, Loader2Icon, Trash2Icon } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { useMemo, useState } from "react";
|
||||
import { toast } from "react-hot-toast";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
|
|
@ -90,6 +90,16 @@ const MemoSharePanel = ({ open, onClose, memoName }: MemoSharePanelProps) => {
|
|||
const { data: shares = [], isLoading } = useMemoShares(memoName, { enabled: open });
|
||||
const createShare = useCreateMemoShare();
|
||||
|
||||
const expiryOptions = useMemo(
|
||||
() => [
|
||||
{ value: "never", label: t("memo.share.expiry-never") },
|
||||
{ value: "1d", label: t("memo.share.expiry-1-day") },
|
||||
{ value: "7d", label: t("memo.share.expiry-7-days") },
|
||||
{ value: "30d", label: t("memo.share.expiry-30-days") },
|
||||
],
|
||||
[t],
|
||||
);
|
||||
|
||||
const handleCreate = async () => {
|
||||
try {
|
||||
await createShare.mutateAsync({ memoName, expireTime: getExpireDate(expiry) });
|
||||
|
|
@ -127,15 +137,16 @@ const MemoSharePanel = ({ open, onClose, memoName }: MemoSharePanelProps) => {
|
|||
|
||||
{/* Create new link */}
|
||||
<div className="flex items-center gap-2">
|
||||
<Select value={expiry} onValueChange={(v) => setExpiry(v as ExpiryOption)}>
|
||||
<Select value={expiry} items={expiryOptions} onValueChange={(v) => setExpiry(v as ExpiryOption)}>
|
||||
<SelectTrigger className="w-36">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="never">{t("memo.share.expiry-never")}</SelectItem>
|
||||
<SelectItem value="1d">{t("memo.share.expiry-1-day")}</SelectItem>
|
||||
<SelectItem value="7d">{t("memo.share.expiry-7-days")}</SelectItem>
|
||||
<SelectItem value="30d">{t("memo.share.expiry-30-days")}</SelectItem>
|
||||
{expiryOptions.map((option) => (
|
||||
<SelectItem key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Button onClick={handleCreate} disabled={createShare.isPending} className="flex-1">
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { Columns2Icon, Columns3Icon, InfinityIcon, type LucideIcon, Rows3Icon, Settings2Icon } from "lucide-react";
|
||||
import { useMemo } from "react";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
|
|
@ -39,6 +40,21 @@ function MemoDisplaySettingMenu({ className }: Props) {
|
|||
// there; it only becomes a real choice at a single column.
|
||||
const compactLocked = maxColumns !== 1;
|
||||
|
||||
const timeBasisOptions = useMemo(
|
||||
() => [
|
||||
{ value: "create_time", label: t("common.created-at") },
|
||||
{ value: "update_time", label: t("common.last-updated-at") },
|
||||
],
|
||||
[t],
|
||||
);
|
||||
const sortOrderOptions = useMemo(
|
||||
() => [
|
||||
{ value: "false", label: t("memo.newest-first") },
|
||||
{ value: "true", label: t("memo.oldest-first") },
|
||||
],
|
||||
[t],
|
||||
);
|
||||
|
||||
return (
|
||||
<Popover>
|
||||
<PopoverTrigger className={cn(className, "opacity-40 hover:opacity-100 transition-opacity")}>
|
||||
|
|
@ -48,13 +64,20 @@ function MemoDisplaySettingMenu({ className }: Props) {
|
|||
<div className="flex flex-col gap-2 p-1">
|
||||
<div className="w-full flex flex-row justify-between items-center">
|
||||
<span className="text-sm shrink-0 mr-3 text-foreground">{t("memo.shown-time")}</span>
|
||||
<Select value={timeBasis} onValueChange={(value) => setTimeBasis(value === "update_time" ? "update_time" : "create_time")}>
|
||||
<Select
|
||||
value={timeBasis}
|
||||
items={timeBasisOptions}
|
||||
onValueChange={(value) => setTimeBasis(value === "update_time" ? "update_time" : "create_time")}
|
||||
>
|
||||
<SelectTrigger size="sm" className="w-32">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="create_time">{t("common.created-at")}</SelectItem>
|
||||
<SelectItem value="update_time">{t("common.last-updated-at")}</SelectItem>
|
||||
{timeBasisOptions.map((option) => (
|
||||
<SelectItem key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
|
@ -62,6 +85,7 @@ function MemoDisplaySettingMenu({ className }: Props) {
|
|||
<span className="text-sm shrink-0 mr-3 text-foreground">{t("memo.order")}</span>
|
||||
<Select
|
||||
value={orderByTimeAsc.toString()}
|
||||
items={sortOrderOptions}
|
||||
onValueChange={(value) => {
|
||||
if ((value === "true") !== orderByTimeAsc) {
|
||||
toggleSortOrder();
|
||||
|
|
@ -72,8 +96,11 @@ function MemoDisplaySettingMenu({ className }: Props) {
|
|||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="false">{t("memo.newest-first")}</SelectItem>
|
||||
<SelectItem value="true">{t("memo.oldest-first")}</SelectItem>
|
||||
{sortOrderOptions.map((option) => (
|
||||
<SelectItem key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
|
@ -116,22 +143,26 @@ function MemoDisplaySettingMenu({ className }: Props) {
|
|||
const active = maxColumns === value;
|
||||
return (
|
||||
<Tooltip key={value}>
|
||||
<TooltipTrigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
role="radio"
|
||||
aria-checked={active}
|
||||
aria-label={label}
|
||||
tabIndex={active ? 0 : -1}
|
||||
data-value={value}
|
||||
onClick={() => setMaxColumns(value)}
|
||||
className={cn(
|
||||
"grid h-6 w-7 place-items-center rounded-md transition-colors",
|
||||
active ? "bg-accent text-accent-foreground" : "text-muted-foreground/70 hover:bg-accent/50 hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
<Icon className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<button
|
||||
type="button"
|
||||
role="radio"
|
||||
aria-checked={active}
|
||||
aria-label={label}
|
||||
tabIndex={active ? 0 : -1}
|
||||
data-value={value}
|
||||
onClick={() => setMaxColumns(value)}
|
||||
className={cn(
|
||||
"grid h-6 w-7 place-items-center rounded-md transition-colors",
|
||||
active
|
||||
? "bg-accent text-accent-foreground"
|
||||
: "text-muted-foreground/70 hover:bg-accent/50 hover:text-foreground",
|
||||
)}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Icon className="w-3.5 h-3.5" />
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p className="font-medium">{label}</p>
|
||||
|
|
|
|||
|
|
@ -71,9 +71,9 @@ export function FormattingToolbar({ controllerRef, onExit, className }: Formatti
|
|||
|
||||
// Menus grab focus while open and hand it back to their trigger on close; send
|
||||
// it to the editor instead so the user can keep typing after a pick.
|
||||
const returnFocusToEditor = (event: Event) => {
|
||||
event.preventDefault();
|
||||
const returnFocusToEditor = () => {
|
||||
controllerRef.current?.focus();
|
||||
return false;
|
||||
};
|
||||
|
||||
// Map a catalog command to a toolbar button.
|
||||
|
|
@ -98,10 +98,8 @@ export function FormattingToolbar({ controllerRef, onExit, className }: Formatti
|
|||
aria-label={t("editor.format.heading")}
|
||||
>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<SegmentButton Icon={HeadingGlyph} label={t("editor.format.heading")} />
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="start" onCloseAutoFocus={returnFocusToEditor}>
|
||||
<DropdownMenuTrigger render={<SegmentButton Icon={HeadingGlyph} label={t("editor.format.heading")} />} />
|
||||
<DropdownMenuContent align="start" finalFocus={returnFocusToEditor}>
|
||||
{HEADING_COMMANDS.map((command) => (
|
||||
<DropdownMenuItem key={command.id} onClick={() => run(command.id)}>
|
||||
{t(command.labelKey)}
|
||||
|
|
@ -120,10 +118,8 @@ export function FormattingToolbar({ controllerRef, onExit, className }: Formatti
|
|||
|
||||
{compact ? (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<SegmentButton Icon={MoreHorizontalIcon} label={t("editor.format.more")} />
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="start" onCloseAutoFocus={returnFocusToEditor}>
|
||||
<DropdownMenuTrigger render={<SegmentButton Icon={MoreHorizontalIcon} label={t("editor.format.more")} />} />
|
||||
<DropdownMenuContent align="start" finalFocus={returnFocusToEditor}>
|
||||
{blockButtons.map((button) => (
|
||||
<DropdownMenuItem key={button.label} onClick={button.onClick}>
|
||||
{button.label}
|
||||
|
|
@ -160,7 +156,7 @@ interface SegmentButtonProps extends ComponentPropsWithoutRef<"button"> {
|
|||
}
|
||||
|
||||
// The one segment element, shared by command toggles and dropdown triggers.
|
||||
// Forwards ref + rest props so it also works as a Radix `asChild` trigger
|
||||
// Forwards ref + rest props so it also works as a Base UI `render` trigger.
|
||||
// (which injects its own onClick/aria attributes).
|
||||
const SegmentButton = forwardRef<HTMLButtonElement, SegmentButtonProps>(({ Icon, label, active, className, ...rest }, ref) => (
|
||||
<button
|
||||
|
|
|
|||
|
|
@ -134,10 +134,8 @@ const InsertMenu = (props: InsertMenuProps) => {
|
|||
return (
|
||||
<>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="secondary" size="icon" disabled={isUploading}>
|
||||
{isUploading ? <LoaderIcon className="size-4 animate-spin" /> : <PlusIcon className="size-4" />}
|
||||
</Button>
|
||||
<DropdownMenuTrigger render={<Button variant="secondary" size="icon" disabled={isUploading} />}>
|
||||
{isUploading ? <LoaderIcon className="size-4 animate-spin" /> : <PlusIcon className="size-4" />}
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="start">
|
||||
{insertItems.map((item) => (
|
||||
|
|
|
|||
|
|
@ -19,12 +19,14 @@ const VisibilitySelector = (props: VisibilitySelectorProps) => {
|
|||
|
||||
return (
|
||||
<DropdownMenu onOpenChange={props.onOpenChange}>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button className="inline-flex items-center h-8 px-2 rounded-md text-sm text-muted-foreground hover:bg-accent transition-colors">
|
||||
<VisibilityIcon visibility={value} className="opacity-60 mr-1.5" />
|
||||
<span>{currentLabel}</span>
|
||||
<ChevronDownIcon className="ml-0.5 w-4 h-4 opacity-60" />
|
||||
</button>
|
||||
<DropdownMenuTrigger
|
||||
render={
|
||||
<button className="inline-flex items-center h-8 px-2 rounded-md text-sm text-muted-foreground hover:bg-accent transition-colors" />
|
||||
}
|
||||
>
|
||||
<VisibilityIcon visibility={value} className="opacity-60 mr-1.5" />
|
||||
<span>{currentLabel}</span>
|
||||
<ChevronDownIcon className="ml-0.5 w-4 h-4 opacity-60" />
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="start">
|
||||
{visibilityOptions.map((option) => (
|
||||
|
|
|
|||
|
|
@ -63,20 +63,18 @@ export const AudioRecorderPanel: FC<AudioRecorderPanelProps> = ({
|
|||
</Button>
|
||||
{canTranscribe && (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<span className="-ml-2 inline-flex">
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="rounded-full"
|
||||
onClick={onTranscribe}
|
||||
disabled={isTranscribeDisabled}
|
||||
aria-label={t("editor.audio-recorder.transcribe")}
|
||||
>
|
||||
<AudioWaveformIcon className="size-4" />
|
||||
</Button>
|
||||
</span>
|
||||
<TooltipTrigger render={<span className="-ml-2 inline-flex" />}>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="rounded-full"
|
||||
onClick={onTranscribe}
|
||||
disabled={isTranscribeDisabled}
|
||||
aria-label={t("editor.audio-recorder.transcribe")}
|
||||
>
|
||||
<AudioWaveformIcon className="size-4" />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="top">
|
||||
<p>{t("editor.audio-recorder.transcribe")}</p>
|
||||
|
|
|
|||
|
|
@ -65,13 +65,15 @@ export const TimestampPopover: FC = () => {
|
|||
|
||||
return (
|
||||
<Popover>
|
||||
<PopoverTrigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
className="w-auto text-sm text-muted-foreground text-left hover:text-foreground transition-colors cursor-pointer"
|
||||
>
|
||||
{formatDate(createTime)}
|
||||
</button>
|
||||
<PopoverTrigger
|
||||
render={
|
||||
<button
|
||||
type="button"
|
||||
className="w-auto text-sm text-muted-foreground text-left hover:text-foreground transition-colors cursor-pointer"
|
||||
/>
|
||||
}
|
||||
>
|
||||
{formatDate(createTime)}
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="start" className="w-auto p-2 pt-1 space-y-1">
|
||||
<TimestampInput
|
||||
|
|
|
|||
|
|
@ -24,10 +24,8 @@ const MemoExplorerDrawer = (props: Props) => {
|
|||
|
||||
return (
|
||||
<Sheet open={open} onOpenChange={setOpen}>
|
||||
<SheetTrigger asChild>
|
||||
<Button variant="ghost">
|
||||
<MenuIcon className="size-5 text-foreground" />
|
||||
</Button>
|
||||
<SheetTrigger render={<Button variant="ghost" />}>
|
||||
<MenuIcon className="size-5 text-foreground" />
|
||||
</SheetTrigger>
|
||||
<SheetContent side="right" className="w-80 max-w-full bg-background">
|
||||
<SheetHeader>
|
||||
|
|
|
|||
|
|
@ -55,9 +55,7 @@ function ShortcutsSection() {
|
|||
<span>{t("common.shortcuts")}</span>
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<PlusIcon className="w-4 h-auto cursor-pointer" onClick={handleCreateShortcut} />
|
||||
</TooltipTrigger>
|
||||
<TooltipTrigger render={<PlusIcon className="w-4 h-auto cursor-pointer" onClick={handleCreateShortcut} />} />
|
||||
<TooltipContent>
|
||||
<p>{t("common.create")}</p>
|
||||
</TooltipContent>
|
||||
|
|
@ -84,9 +82,10 @@ function ShortcutsSection() {
|
|||
{title.trim()}
|
||||
</span>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<MoreVerticalIcon className="w-4 h-auto shrink-0 text-muted-foreground cursor-pointer hover:text-foreground" />
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuTrigger
|
||||
nativeButton={false}
|
||||
render={<MoreVerticalIcon className="w-4 h-auto shrink-0 text-muted-foreground cursor-pointer hover:text-foreground" />}
|
||||
/>
|
||||
<DropdownMenuContent align="end" alignOffset={-12}>
|
||||
<DropdownMenuItem onClick={() => handleEditShortcut(shortcut)}>
|
||||
<Edit3Icon className="w-4 h-auto" />
|
||||
|
|
|
|||
|
|
@ -20,16 +20,18 @@ const LocationDisplayView = ({ location }: LocationDisplayViewProps) => {
|
|||
|
||||
return (
|
||||
<Popover open={popoverOpen} onOpenChange={setPopoverOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
title={displayText}
|
||||
className="inline-flex max-w-full min-w-0 items-center gap-1 h-7 px-2 rounded-md border border-border bg-background text-sm font-medium shadow-xs transition-all hover:bg-accent hover:text-accent-foreground"
|
||||
>
|
||||
<MapPinIcon className="w-3.5 h-3.5 shrink-0 text-muted-foreground" />
|
||||
<span className="shrink-0 text-nowrap opacity-80">[{getLocationCoordinatesText(location, 2)}]</span>
|
||||
<span className="min-w-0 truncate">{displayText}</span>
|
||||
</button>
|
||||
<PopoverTrigger
|
||||
render={
|
||||
<button
|
||||
type="button"
|
||||
title={displayText}
|
||||
className="inline-flex max-w-full min-w-0 items-center gap-1 h-7 px-2 rounded-md border border-border bg-background text-sm font-medium shadow-xs transition-all hover:bg-accent hover:text-accent-foreground"
|
||||
/>
|
||||
}
|
||||
>
|
||||
<MapPinIcon className="w-3.5 h-3.5 shrink-0 text-muted-foreground" />
|
||||
<span className="shrink-0 text-nowrap opacity-80">[{getLocationCoordinatesText(location, 2)}]</span>
|
||||
<span className="min-w-0 truncate">{displayText}</span>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="start">
|
||||
<div className="min-w-80 sm:w-lg flex flex-col justify-start items-start">
|
||||
|
|
|
|||
|
|
@ -29,15 +29,18 @@ const ReactionSelector = (props: Props) => {
|
|||
|
||||
return (
|
||||
<Popover open={open} onOpenChange={handleOpenChange}>
|
||||
<PopoverTrigger asChild>
|
||||
<span
|
||||
className={cn(
|
||||
"h-7 w-7 flex justify-center items-center rounded-full border cursor-pointer transition-all hover:opacity-80",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<SmilePlusIcon className="w-4 h-4 mx-auto text-muted-foreground" />
|
||||
</span>
|
||||
<PopoverTrigger
|
||||
nativeButton={false}
|
||||
render={
|
||||
<span
|
||||
className={cn(
|
||||
"h-7 w-7 flex justify-center items-center rounded-full border cursor-pointer transition-all hover:opacity-80",
|
||||
className,
|
||||
)}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<SmilePlusIcon className="w-4 h-4 mx-auto text-muted-foreground" />
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="center" className="max-w-[90vw] sm:max-w-md">
|
||||
<div className="grid grid-cols-4 sm:grid-cols-6 md:grid-cols-8 gap-1 max-h-64 overflow-y-auto">
|
||||
|
|
|
|||
|
|
@ -30,22 +30,24 @@ const ReactionView = (props: Props) => {
|
|||
return (
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
className={cn(
|
||||
"h-7 border px-2 py-0.5 rounded-full flex flex-row justify-center items-center gap-1",
|
||||
"text-sm text-muted-foreground",
|
||||
isClickable && "cursor-pointer",
|
||||
!isClickable && "cursor-default",
|
||||
hasReaction && "bg-accent border-border",
|
||||
)}
|
||||
onClick={handleClick}
|
||||
disabled={!isClickable}
|
||||
>
|
||||
<span>{reactionType}</span>
|
||||
<span className="opacity-60">{users.length}</span>
|
||||
</button>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<button
|
||||
type="button"
|
||||
className={cn(
|
||||
"h-7 border px-2 py-0.5 rounded-full flex flex-row justify-center items-center gap-1",
|
||||
"text-sm text-muted-foreground",
|
||||
isClickable && "cursor-pointer",
|
||||
!isClickable && "cursor-default",
|
||||
hasReaction && "bg-accent border-border",
|
||||
)}
|
||||
onClick={handleClick}
|
||||
disabled={!isClickable}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<span>{reactionType}</span>
|
||||
<span className="opacity-60">{users.length}</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p>{formatReactionTooltip(users, reactionType)}</p>
|
||||
|
|
|
|||
|
|
@ -93,10 +93,8 @@ const MemoHeader: React.FC<MemoHeaderProps> = ({ showCreator, showVisibility, sh
|
|||
{showPinned && memo.pinned && (
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<span className="cursor-pointer">
|
||||
<BookmarkIcon className="w-4 h-auto text-primary" onClick={unpinMemo} />
|
||||
</span>
|
||||
<TooltipTrigger render={<span className="cursor-pointer" />}>
|
||||
<BookmarkIcon className="w-4 h-auto text-primary" onClick={unpinMemo} />
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p>{t("common.unpin")}</p>
|
||||
|
|
@ -150,7 +148,7 @@ interface TimeTooltipContent {
|
|||
|
||||
const TimeTooltip = ({ children, content }: { children: React.ReactElement; content: TimeTooltipContent }) => (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>{children}</TooltipTrigger>
|
||||
<TooltipTrigger render={children} />
|
||||
<TooltipContent align="start" className="flex flex-col items-start gap-0.5 whitespace-nowrap text-left">
|
||||
{content.createdAt && <span>{content.createdAt}</span>}
|
||||
{content.updatedAt && <span>{content.updatedAt}</span>}
|
||||
|
|
|
|||
|
|
@ -107,9 +107,7 @@ const Navigation = (props: Props) => {
|
|||
>
|
||||
{props.collapsed ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<div>{navLink.icon}</div>
|
||||
</TooltipTrigger>
|
||||
<TooltipTrigger render={<div />}>{navLink.icon}</TooltipTrigger>
|
||||
<TooltipContent side="right">
|
||||
<p>{navLink.title}</p>
|
||||
</TooltipContent>
|
||||
|
|
|
|||
|
|
@ -19,11 +19,9 @@ const NavigationDrawer = () => {
|
|||
|
||||
return (
|
||||
<Sheet open={open} onOpenChange={setOpen}>
|
||||
<SheetTrigger asChild>
|
||||
<Button variant="ghost" className="px-2">
|
||||
<UserAvatar className="shrink-0 w-6 h-6 rounded-md" avatarUrl={avatarUrl} />
|
||||
<span className="font-bold text-lg leading-10 text-ellipsis overflow-hidden text-foreground">{title}</span>
|
||||
</Button>
|
||||
<SheetTrigger render={<Button variant="ghost" className="px-2" />}>
|
||||
<UserAvatar className="shrink-0 w-6 h-6 rounded-md" avatarUrl={avatarUrl} />
|
||||
<span className="font-bold text-lg leading-10 text-ellipsis overflow-hidden text-foreground">{title}</span>
|
||||
</SheetTrigger>
|
||||
<SheetContent side="left" className="w-80 max-w-full overflow-auto px-2 bg-background">
|
||||
<SheetHeader>
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ const getProviderTypeLabel = (type: InstanceSetting_AIProviderType) => {
|
|||
return InstanceSetting_AIProviderType[type] ?? "UNKNOWN";
|
||||
};
|
||||
|
||||
const providerTypeSelectOptions = providerTypeOptions.map((type) => ({ value: String(type), label: getProviderTypeLabel(type) }));
|
||||
|
||||
const toLocalProvider = (provider: InstanceSetting_AIProviderConfig): LocalAIProvider => ({
|
||||
id: provider.id,
|
||||
title: provider.title,
|
||||
|
|
@ -295,10 +297,8 @@ const AISection = () => {
|
|||
className: "text-right",
|
||||
render: (_, provider: LocalAIProvider) => (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="outline" size="sm">
|
||||
<MoreVerticalIcon className="w-4 h-auto" />
|
||||
</Button>
|
||||
<DropdownMenuTrigger render={<Button variant="outline" size="sm" />}>
|
||||
<MoreVerticalIcon className="w-4 h-auto" />
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" sideOffset={2}>
|
||||
<DropdownMenuItem onClick={() => handleEditProvider(provider)}>{t("common.edit")}</DropdownMenuItem>
|
||||
|
|
@ -364,6 +364,14 @@ const TranscriptionForm = ({ providers, transcription, referencedProvider, onCha
|
|||
const t = useTranslate();
|
||||
const noProviders = providers.length === 0;
|
||||
|
||||
const providerOptions = useMemo(
|
||||
() => [
|
||||
{ value: "__none__", label: t("setting.ai.transcription-no-provider") },
|
||||
...providers.map((provider) => ({ value: provider.id, label: provider.title || provider.id })),
|
||||
],
|
||||
[providers, t],
|
||||
);
|
||||
|
||||
const update = (partial: Partial<LocalTranscription>) => {
|
||||
onChange({ ...transcription, ...partial });
|
||||
};
|
||||
|
|
@ -381,6 +389,7 @@ const TranscriptionForm = ({ providers, transcription, referencedProvider, onCha
|
|||
<Label>{t("setting.ai.transcription-provider")}</Label>
|
||||
<Select
|
||||
value={transcription.providerId || "__none__"}
|
||||
items={providerOptions}
|
||||
onValueChange={(value) => update({ providerId: value === "__none__" ? "" : value })}
|
||||
disabled={noProviders}
|
||||
>
|
||||
|
|
@ -388,10 +397,9 @@ const TranscriptionForm = ({ providers, transcription, referencedProvider, onCha
|
|||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="__none__">{t("setting.ai.transcription-no-provider")}</SelectItem>
|
||||
{providers.map((provider) => (
|
||||
<SelectItem key={provider.id} value={provider.id}>
|
||||
{provider.title || provider.id}
|
||||
{providerOptions.map((option) => (
|
||||
<SelectItem key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
|
|
@ -483,15 +491,16 @@ const AIProviderDialog = ({ provider, onOpenChange, onSave }: AIProviderDialogPr
|
|||
<Label>{t("setting.ai.provider-type")}</Label>
|
||||
<Select
|
||||
value={String(draft.type)}
|
||||
items={providerTypeSelectOptions}
|
||||
onValueChange={(value) => updateDraft({ type: Number(value) as InstanceSetting_AIProviderType })}
|
||||
>
|
||||
<SelectTrigger className="w-full">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{providerTypeOptions.map((type) => (
|
||||
<SelectItem key={type} value={String(type)}>
|
||||
{getProviderTypeLabel(type)}
|
||||
{providerTypeSelectOptions.map((option) => (
|
||||
<SelectItem key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
|
|
|
|||
|
|
@ -27,11 +27,7 @@ const InfoChip = ({ label, value, tooltip, className }: Props) => {
|
|||
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<span className="inline-flex" tabIndex={0} aria-label={tooltip}>
|
||||
{chip}
|
||||
</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipTrigger render={<span className="inline-flex" tabIndex={0} aria-label={tooltip} />}>{chip}</TooltipTrigger>
|
||||
<TooltipContent className="max-w-xs whitespace-pre-wrap break-words">{tooltip}</TooltipContent>
|
||||
</Tooltip>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { create } from "@bufbuild/protobuf";
|
||||
import { isEqual } from "lodash-es";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { toast } from "react-hot-toast";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
|
|
@ -43,6 +43,15 @@ const InstanceSection = () => {
|
|||
fetchIdentityProviderList();
|
||||
}, []);
|
||||
|
||||
const weekStartDayOptions = useMemo(
|
||||
() => [
|
||||
{ value: "-1", label: t("setting.instance.saturday") },
|
||||
{ value: "0", label: t("setting.instance.sunday") },
|
||||
{ value: "1", label: t("setting.instance.monday") },
|
||||
],
|
||||
[t],
|
||||
);
|
||||
|
||||
const updatePartialSetting = (partial: Partial<InstanceSetting_GeneralSetting>) => {
|
||||
setInstanceGeneralSetting(
|
||||
create(InstanceSetting_GeneralSettingSchema, {
|
||||
|
|
@ -143,6 +152,7 @@ const InstanceSection = () => {
|
|||
<SettingListItem label={t("setting.instance.week-start-day")} description={t("setting.instance.week-start-day-description")}>
|
||||
<Select
|
||||
value={instanceGeneralSetting.weekStartDayOffset.toString()}
|
||||
items={weekStartDayOptions}
|
||||
onValueChange={(value) => {
|
||||
updatePartialSetting({ weekStartDayOffset: parseInt(value) || 0 });
|
||||
}}
|
||||
|
|
@ -151,9 +161,11 @@ const InstanceSection = () => {
|
|||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="-1">{t("setting.instance.saturday")}</SelectItem>
|
||||
<SelectItem value="0">{t("setting.instance.sunday")}</SelectItem>
|
||||
<SelectItem value="1">{t("setting.instance.monday")}</SelectItem>
|
||||
{weekStartDayOptions.map((option) => (
|
||||
<SelectItem key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</SettingListItem>
|
||||
|
|
|
|||
|
|
@ -168,10 +168,8 @@ const MemberSection = () => {
|
|||
render: (_, user: User) =>
|
||||
currentUser?.name === user.name ? null : (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="outline" size="sm">
|
||||
<MoreVerticalIcon className="w-4 h-auto" />
|
||||
</Button>
|
||||
<DropdownMenuTrigger render={<Button variant="outline" size="sm" />}>
|
||||
<MoreVerticalIcon className="w-4 h-auto" />
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" sideOffset={2}>
|
||||
<DropdownMenuItem onClick={() => handleEditUser(user)}>{t("common.update")}</DropdownMenuItem>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { create } from "@bufbuild/protobuf";
|
||||
import { useMemo } from "react";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { useAuth } from "@/contexts/AuthContext";
|
||||
import { useUpdateUserGeneralSetting } from "@/hooks/useUserQueries";
|
||||
|
|
@ -33,6 +34,15 @@ const PreferencesSection = () => {
|
|||
);
|
||||
};
|
||||
|
||||
const visibilityOptions = useMemo(
|
||||
() =>
|
||||
[Visibility.PRIVATE, Visibility.PROTECTED, Visibility.PUBLIC].map((v) => {
|
||||
const value = convertVisibilityToString(v);
|
||||
return { value, label: t(`memo.visibility.${value.toLowerCase() as Lowercase<typeof value>}`) };
|
||||
}),
|
||||
[t],
|
||||
);
|
||||
|
||||
const handleDefaultMemoVisibilityChanged = (value: string) => {
|
||||
updateUserGeneralSetting(
|
||||
{ generalSetting: { memoVisibility: value }, updateMask: ["memo_visibility"] },
|
||||
|
|
@ -91,7 +101,11 @@ const PreferencesSection = () => {
|
|||
label={t("setting.preference.default-memo-visibility")}
|
||||
description={t("setting.preference.default-memo-visibility-description")}
|
||||
>
|
||||
<Select value={setting.memoVisibility || "PRIVATE"} onValueChange={handleDefaultMemoVisibilityChanged}>
|
||||
<Select
|
||||
value={setting.memoVisibility || "PRIVATE"}
|
||||
items={visibilityOptions}
|
||||
onValueChange={handleDefaultMemoVisibilityChanged}
|
||||
>
|
||||
<SelectTrigger className="min-w-fit">
|
||||
<div className="flex items-center gap-2">
|
||||
<VisibilityIcon visibility={convertVisibilityFromString(setting.memoVisibility)} />
|
||||
|
|
@ -99,13 +113,11 @@ const PreferencesSection = () => {
|
|||
</div>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{[Visibility.PRIVATE, Visibility.PROTECTED, Visibility.PUBLIC]
|
||||
.map((v) => convertVisibilityToString(v))
|
||||
.map((item) => (
|
||||
<SelectItem key={item} value={item} className="whitespace-nowrap">
|
||||
{t(`memo.visibility.${item.toLowerCase() as Lowercase<typeof item>}`)}
|
||||
</SelectItem>
|
||||
))}
|
||||
{visibilityOptions.map((option) => (
|
||||
<SelectItem key={option.value} value={option.value} className="whitespace-nowrap">
|
||||
{option.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</SettingListItem>
|
||||
|
|
|
|||
|
|
@ -161,10 +161,8 @@ const SSOSection = () => {
|
|||
className: "w-px text-right",
|
||||
render: (_, row: IdentityProviderRow) => (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="outline" size="sm">
|
||||
<MoreVerticalIcon className="w-4 h-auto" />
|
||||
</Button>
|
||||
<DropdownMenuTrigger render={<Button variant="outline" size="sm" />}>
|
||||
<MoreVerticalIcon className="w-4 h-auto" />
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" sideOffset={2}>
|
||||
<DropdownMenuItem onClick={() => handleEditIdentityProvider(row.provider)}>{t("common.edit")}</DropdownMenuItem>
|
||||
|
|
|
|||
|
|
@ -27,9 +27,7 @@ const SettingRow: React.FC<SettingRowProps> = ({ label, description, tooltip, ch
|
|||
{tooltip && (
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<HelpCircleIcon className="w-4 h-4 text-muted-foreground cursor-help" />
|
||||
</TooltipTrigger>
|
||||
<TooltipTrigger render={<HelpCircleIcon className="w-4 h-4 text-muted-foreground cursor-help" />} />
|
||||
<TooltipContent>
|
||||
<p className="max-w-xs">{tooltip}</p>
|
||||
</TooltipContent>
|
||||
|
|
|
|||
|
|
@ -45,13 +45,15 @@ export const MonthNavigator = memo(({ visibleMonth, onMonthChange, activityStats
|
|||
return (
|
||||
<header className="w-full mb-2 flex items-center justify-between gap-2">
|
||||
<Dialog open={isOpen} onOpenChange={setIsOpen}>
|
||||
<DialogTrigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
className="py-0.5 text-sm text-foreground font-medium transition-colors hover:text-foreground/80 select-none"
|
||||
>
|
||||
{monthLabel}
|
||||
</button>
|
||||
<DialogTrigger
|
||||
render={
|
||||
<button
|
||||
type="button"
|
||||
className="py-0.5 text-sm text-foreground font-medium transition-colors hover:text-foreground/80 select-none"
|
||||
/>
|
||||
}
|
||||
>
|
||||
{monthLabel}
|
||||
</DialogTrigger>
|
||||
<DialogContent
|
||||
className="p-0 border border-border/20 bg-background md:max-w-6xl w-[min(100vw-24px,1200px)] max-h-[85vh] overflow-y-auto rounded-xl shadow-xl"
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ const ThemeSelect = ({ value, onValueChange, className, compact = false }: Theme
|
|||
};
|
||||
|
||||
return (
|
||||
<Select value={currentTheme} onValueChange={handleThemeChange}>
|
||||
<Select value={currentTheme} items={THEME_OPTIONS} onValueChange={handleThemeChange}>
|
||||
<SelectTrigger className={className}>
|
||||
<div className="flex min-w-0 flex-1 items-center gap-2">
|
||||
{compact && THEME_ICONS[currentTheme]}
|
||||
|
|
|
|||
|
|
@ -104,34 +104,42 @@ const UserMenu = (props: Props) => {
|
|||
|
||||
return (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild disabled={!currentUser}>
|
||||
<div className={cn("w-auto flex flex-row justify-start items-center cursor-pointer text-foreground", collapsed ? "px-1" : "px-3")}>
|
||||
<div className="relative shrink-0">
|
||||
{currentUser?.avatarUrl ? (
|
||||
<UserAvatar avatarUrl={currentUser?.avatarUrl} />
|
||||
) : (
|
||||
<User2Icon className="w-6 mx-auto h-auto text-muted-foreground" />
|
||||
)}
|
||||
{sseStatus !== "connected" && (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<DropdownMenuTrigger
|
||||
nativeButton={false}
|
||||
disabled={!currentUser}
|
||||
render={
|
||||
<div
|
||||
className={cn("w-auto flex flex-row justify-start items-center cursor-pointer text-foreground", collapsed ? "px-1" : "px-3")}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<div className="relative shrink-0">
|
||||
{currentUser?.avatarUrl ? (
|
||||
<UserAvatar avatarUrl={currentUser?.avatarUrl} />
|
||||
) : (
|
||||
<User2Icon className="w-6 mx-auto h-auto text-muted-foreground" />
|
||||
)}
|
||||
{sseStatus !== "connected" && (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<span
|
||||
className={cn(
|
||||
"absolute -bottom-0.5 -right-0.5 size-2.5 rounded-full border-2 border-background",
|
||||
sseStatus === "connecting" ? "bg-muted-foreground animate-pulse" : "bg-destructive",
|
||||
)}
|
||||
/>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right">{t(`live-update.${sseStatus}` as Parameters<typeof t>[0])}</TooltipContent>
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
{!collapsed && (
|
||||
<span className="ml-2 text-lg font-medium text-foreground grow truncate">
|
||||
{currentUser?.displayName || currentUser?.username}
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
<TooltipContent side="right">{t(`live-update.${sseStatus}` as Parameters<typeof t>[0])}</TooltipContent>
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
{!collapsed && (
|
||||
<span className="ml-2 text-lg font-medium text-foreground grow truncate">
|
||||
{currentUser?.displayName || currentUser?.username}
|
||||
</span>
|
||||
)}
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="start">
|
||||
<DropdownMenuItem onClick={() => navigateTo(`/u/${encodeURIComponent(currentUser?.username ?? "")}`)}>
|
||||
|
|
@ -151,7 +159,7 @@ const UserMenu = (props: Props) => {
|
|||
<GlobeIcon className="size-4 text-muted-foreground" />
|
||||
{t("common.language")}
|
||||
</DropdownMenuSubTrigger>
|
||||
<DropdownMenuSubContent className="max-h-[min(24rem,var(--radix-dropdown-menu-content-available-height))] overflow-y-auto p-0">
|
||||
<DropdownMenuSubContent className="max-h-[min(24rem,var(--available-height))] overflow-y-auto p-0">
|
||||
<LocaleSearchList value={currentLocale} onChange={handleLocaleChange} className="w-64" />
|
||||
</DropdownMenuSubContent>
|
||||
</DropdownMenuSub>
|
||||
|
|
|
|||
|
|
@ -22,11 +22,7 @@ const OverflowTip = ({ children, className }: Props) => {
|
|||
return (
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<div ref={textElementRef} className={cn("truncate", className)}>
|
||||
{children}
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
<TooltipTrigger render={<div ref={textElementRef} className={cn("truncate", className)} />}>{children}</TooltipTrigger>
|
||||
{isOverflowed && (
|
||||
<TooltipContent>
|
||||
<p>{children}</p>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { Slot } from "@radix-ui/react-slot";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
import * as React from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
|
@ -26,16 +25,8 @@ const badgeVariants = cva(
|
|||
},
|
||||
);
|
||||
|
||||
function Badge({
|
||||
className,
|
||||
variant,
|
||||
shape,
|
||||
asChild = false,
|
||||
...props
|
||||
}: React.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
|
||||
const Comp = asChild ? Slot : "span";
|
||||
|
||||
return <Comp data-slot="badge" className={cn(badgeVariants({ variant, shape }), className)} {...props} />;
|
||||
function Badge({ className, variant, shape, ...props }: React.ComponentProps<"span"> & VariantProps<typeof badgeVariants>) {
|
||||
return <span data-slot="badge" className={cn(badgeVariants({ variant, shape }), className)} {...props} />;
|
||||
}
|
||||
|
||||
export { Badge, badgeVariants };
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Slot } from "@radix-ui/react-slot";
|
||||
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
import * as React from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
|
@ -30,17 +30,11 @@ const buttonVariants = cva(
|
|||
},
|
||||
);
|
||||
|
||||
const Button = React.forwardRef<
|
||||
HTMLButtonElement,
|
||||
React.ComponentProps<"button"> &
|
||||
VariantProps<typeof buttonVariants> & {
|
||||
asChild?: boolean;
|
||||
}
|
||||
>(({ className, variant, size, asChild = false, ...props }, ref) => {
|
||||
const Comp = asChild ? Slot : "button";
|
||||
|
||||
return <Comp ref={ref} data-slot="button" className={cn(buttonVariants({ variant, size, className }))} {...props} />;
|
||||
});
|
||||
const Button = React.forwardRef<HTMLElement, ButtonPrimitive.Props & VariantProps<typeof buttonVariants>>(
|
||||
({ className, variant, size, ...props }, ref) => (
|
||||
<ButtonPrimitive ref={ref} data-slot="button" className={cn(buttonVariants({ variant, size, className }))} {...props} />
|
||||
),
|
||||
);
|
||||
Button.displayName = "Button";
|
||||
|
||||
export { Button, buttonVariants };
|
||||
|
|
|
|||
|
|
@ -1,18 +1,15 @@
|
|||
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
||||
import { Checkbox as CheckboxPrimitive } from "@base-ui/react/checkbox";
|
||||
import { CheckIcon } from "lucide-react";
|
||||
import * as React from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const Checkbox = React.forwardRef<
|
||||
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
|
||||
>(({ className, ...props }, ref) => {
|
||||
const Checkbox = React.forwardRef<HTMLSpanElement, CheckboxPrimitive.Root.Props>(({ className, ...props }, ref) => {
|
||||
return (
|
||||
<CheckboxPrimitive.Root
|
||||
ref={ref}
|
||||
data-slot="checkbox"
|
||||
className={cn(
|
||||
"peer border-border data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=checked]:border-primary size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow disabled:cursor-not-allowed disabled:opacity-50",
|
||||
"peer border-border data-checked:bg-primary data-checked:text-primary-foreground data-checked:border-primary size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow data-disabled:cursor-not-allowed data-disabled:opacity-50",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
||||
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
import { XIcon } from "lucide-react";
|
||||
import * as React from "react";
|
||||
|
|
@ -12,24 +12,21 @@ const DialogPortal = DialogPrimitive.Portal;
|
|||
|
||||
const DialogClose = DialogPrimitive.Close;
|
||||
|
||||
const DialogOverlay = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DialogPrimitive.Overlay
|
||||
const DialogOverlay = React.forwardRef<HTMLDivElement, DialogPrimitive.Backdrop.Props>(({ className, ...props }, ref) => (
|
||||
<DialogPrimitive.Backdrop
|
||||
ref={ref}
|
||||
data-slot="dialog-overlay"
|
||||
className={cn(
|
||||
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-overlay bg-foreground/50",
|
||||
"fixed inset-0 z-overlay bg-foreground/50 transition-opacity duration-200 data-starting-style:opacity-0 data-ending-style:opacity-0",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
||||
DialogOverlay.displayName = "DialogOverlay";
|
||||
|
||||
const dialogContentVariants = cva(
|
||||
"bg-background 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 fixed top-[50%] left-[50%] z-overlay flex flex-col translate-x-[-50%] translate-y-[-50%] rounded-lg border shadow-lg duration-200 max-h-[calc(100vh-2rem)] sm:max-h-[calc(100vh-3rem)] md:max-h-[calc(100vh-4rem)]",
|
||||
"bg-background fixed top-[50%] left-[50%] z-overlay flex max-h-[calc(100vh-2rem)] translate-x-[-50%] translate-y-[-50%] flex-col rounded-lg border shadow-lg transition-[opacity,scale] duration-200 data-starting-style:scale-95 data-starting-style:opacity-0 data-ending-style:scale-95 data-ending-style:opacity-0 sm:max-h-[calc(100vh-3rem)] md:max-h-[calc(100vh-4rem)]",
|
||||
{
|
||||
variants: {
|
||||
size: {
|
||||
|
|
@ -50,37 +47,32 @@ const dialogContentVariants = cva(
|
|||
);
|
||||
|
||||
const DialogContent = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> &
|
||||
HTMLDivElement,
|
||||
DialogPrimitive.Popup.Props &
|
||||
VariantProps<typeof dialogContentVariants> & {
|
||||
showCloseButton?: boolean;
|
||||
}
|
||||
>(({ className, children, showCloseButton = true, size, ...props }, ref) => (
|
||||
<DialogPortal>
|
||||
<DialogOverlay />
|
||||
<DialogPrimitive.Content
|
||||
<DialogPrimitive.Popup
|
||||
ref={ref}
|
||||
className={cn(dialogContentVariants({ size }), className)}
|
||||
onOpenAutoFocus={(e) => {
|
||||
e.preventDefault();
|
||||
}}
|
||||
onCloseAutoFocus={(e) => {
|
||||
e.preventDefault();
|
||||
document.body.style.pointerEvents = "auto";
|
||||
}}
|
||||
initialFocus={false}
|
||||
finalFocus={false}
|
||||
{...props}
|
||||
>
|
||||
<div className="overflow-y-auto overflow-x-hidden flex-1 flex flex-col gap-4">{children}</div>
|
||||
{showCloseButton && (
|
||||
<DialogPrimitive.Close className="ring-offset-background data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4">
|
||||
<DialogPrimitive.Close className="ring-offset-background absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4">
|
||||
<XIcon />
|
||||
<span className="sr-only">Close</span>
|
||||
</DialogPrimitive.Close>
|
||||
)}
|
||||
</DialogPrimitive.Content>
|
||||
</DialogPrimitive.Popup>
|
||||
</DialogPortal>
|
||||
));
|
||||
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
||||
DialogContent.displayName = "DialogContent";
|
||||
|
||||
const DialogHeader = React.forwardRef<React.ElementRef<"div">, React.ComponentPropsWithoutRef<"div">>(({ className, ...props }, ref) => (
|
||||
<div ref={ref} className={cn("flex flex-col gap-2 text-center sm:text-left", className)} {...props} />
|
||||
|
|
@ -92,21 +84,15 @@ const DialogFooter = React.forwardRef<React.ElementRef<"div">, React.ComponentPr
|
|||
));
|
||||
DialogFooter.displayName = "DialogFooter";
|
||||
|
||||
const DialogTitle = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Title>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
||||
>(({ className, ...props }, ref) => (
|
||||
const DialogTitle = React.forwardRef<HTMLHeadingElement, DialogPrimitive.Title.Props>(({ className, ...props }, ref) => (
|
||||
<DialogPrimitive.Title ref={ref} className={cn("text-lg leading-none font-semibold", className)} {...props} />
|
||||
));
|
||||
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
||||
DialogTitle.displayName = "DialogTitle";
|
||||
|
||||
const DialogDescription = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Description>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
||||
>(({ className, ...props }, ref) => (
|
||||
const DialogDescription = React.forwardRef<HTMLParagraphElement, DialogPrimitive.Description.Props>(({ className, ...props }, ref) => (
|
||||
<DialogPrimitive.Description ref={ref} className={cn("text-muted-foreground text-sm", className)} {...props} />
|
||||
));
|
||||
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
||||
DialogDescription.displayName = "DialogDescription";
|
||||
|
||||
export {
|
||||
Dialog,
|
||||
|
|
|
|||
|
|
@ -1,47 +1,52 @@
|
|||
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
||||
import { Menu as DropdownMenuPrimitive } from "@base-ui/react/menu";
|
||||
import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react";
|
||||
import * as React from "react";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { popupMotionClasses } from "./popup";
|
||||
|
||||
const DropdownMenu = ({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) => {
|
||||
const DropdownMenu = ({ ...props }: DropdownMenuPrimitive.Root.Props) => {
|
||||
return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" modal={false} {...props} />;
|
||||
};
|
||||
|
||||
const DropdownMenuPortal = ({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) => {
|
||||
return <DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />;
|
||||
};
|
||||
const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
||||
|
||||
const DropdownMenuTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Trigger>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Trigger>
|
||||
>(({ ...props }, ref) => {
|
||||
const DropdownMenuTrigger = React.forwardRef<HTMLButtonElement, DropdownMenuPrimitive.Trigger.Props>(({ ...props }, ref) => {
|
||||
return <DropdownMenuPrimitive.Trigger ref={ref} data-slot="dropdown-menu-trigger" {...props} />;
|
||||
});
|
||||
DropdownMenuTrigger.displayName = "DropdownMenuTrigger";
|
||||
|
||||
const DropdownMenuContent = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
|
||||
>(({ className, sideOffset = 4, ...props }, ref) => {
|
||||
return (
|
||||
<DropdownMenuPrimitive.Portal>
|
||||
<DropdownMenuPrimitive.Content
|
||||
ref={ref}
|
||||
data-slot="dropdown-menu-content"
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"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-dropdown max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</DropdownMenuPrimitive.Portal>
|
||||
);
|
||||
});
|
||||
type DropdownMenuContentProps = DropdownMenuPrimitive.Popup.Props &
|
||||
Pick<DropdownMenuPrimitive.Positioner.Props, "align" | "alignOffset" | "side" | "sideOffset">;
|
||||
|
||||
const DropdownMenuContent = React.forwardRef<HTMLDivElement, DropdownMenuContentProps>(
|
||||
({ className, align, alignOffset, side, sideOffset = 4, ...props }, ref) => {
|
||||
return (
|
||||
<DropdownMenuPrimitive.Portal>
|
||||
<DropdownMenuPrimitive.Positioner
|
||||
align={align}
|
||||
alignOffset={alignOffset}
|
||||
side={side}
|
||||
sideOffset={sideOffset}
|
||||
className="isolate z-dropdown outline-none"
|
||||
>
|
||||
<DropdownMenuPrimitive.Popup
|
||||
ref={ref}
|
||||
data-slot="dropdown-menu-content"
|
||||
className={cn(
|
||||
"bg-popover text-popover-foreground z-dropdown max-h-(--available-height) min-w-[8rem] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md outline-none",
|
||||
popupMotionClasses,
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</DropdownMenuPrimitive.Positioner>
|
||||
</DropdownMenuPrimitive.Portal>
|
||||
);
|
||||
},
|
||||
);
|
||||
DropdownMenuContent.displayName = "DropdownMenuContent";
|
||||
|
||||
function DropdownMenuGroup({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
|
||||
function DropdownMenuGroup({ ...props }: DropdownMenuPrimitive.Group.Props) {
|
||||
return <DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />;
|
||||
}
|
||||
|
||||
|
|
@ -50,7 +55,7 @@ function DropdownMenuItem({
|
|||
inset,
|
||||
variant = "default",
|
||||
...props
|
||||
}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
|
||||
}: DropdownMenuPrimitive.Item.Props & {
|
||||
inset?: boolean;
|
||||
variant?: "default" | "destructive";
|
||||
}) {
|
||||
|
|
@ -60,7 +65,7 @@ function DropdownMenuItem({
|
|||
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 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",
|
||||
"data-highlighted:bg-accent data-highlighted:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:data-highlighted:bg-destructive/10 data-[variant=destructive]:data-highlighted: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",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
|
@ -68,50 +73,45 @@ function DropdownMenuItem({
|
|||
);
|
||||
}
|
||||
|
||||
function DropdownMenuCheckboxItem({
|
||||
className,
|
||||
children,
|
||||
checked,
|
||||
...props
|
||||
}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>) {
|
||||
function DropdownMenuCheckboxItem({ className, children, checked, ...props }: DropdownMenuPrimitive.CheckboxItem.Props) {
|
||||
return (
|
||||
<DropdownMenuPrimitive.CheckboxItem
|
||||
data-slot="dropdown-menu-checkbox-item"
|
||||
className={cn(
|
||||
"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",
|
||||
"data-highlighted:bg-accent data-highlighted: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",
|
||||
className,
|
||||
)}
|
||||
checked={checked}
|
||||
{...props}
|
||||
>
|
||||
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
||||
<DropdownMenuPrimitive.ItemIndicator>
|
||||
<DropdownMenuPrimitive.CheckboxItemIndicator>
|
||||
<CheckIcon className="size-4" />
|
||||
</DropdownMenuPrimitive.ItemIndicator>
|
||||
</DropdownMenuPrimitive.CheckboxItemIndicator>
|
||||
</span>
|
||||
{children}
|
||||
</DropdownMenuPrimitive.CheckboxItem>
|
||||
);
|
||||
}
|
||||
|
||||
function DropdownMenuRadioGroup({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {
|
||||
function DropdownMenuRadioGroup({ ...props }: DropdownMenuPrimitive.RadioGroup.Props) {
|
||||
return <DropdownMenuPrimitive.RadioGroup data-slot="dropdown-menu-radio-group" {...props} />;
|
||||
}
|
||||
|
||||
function DropdownMenuRadioItem({ className, children, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>) {
|
||||
function DropdownMenuRadioItem({ className, children, ...props }: DropdownMenuPrimitive.RadioItem.Props) {
|
||||
return (
|
||||
<DropdownMenuPrimitive.RadioItem
|
||||
data-slot="dropdown-menu-radio-item"
|
||||
className={cn(
|
||||
"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",
|
||||
"data-highlighted:bg-accent data-highlighted: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",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
||||
<DropdownMenuPrimitive.ItemIndicator>
|
||||
<DropdownMenuPrimitive.RadioItemIndicator>
|
||||
<CircleIcon className="size-2 fill-current" />
|
||||
</DropdownMenuPrimitive.ItemIndicator>
|
||||
</DropdownMenuPrimitive.RadioItemIndicator>
|
||||
</span>
|
||||
{children}
|
||||
</DropdownMenuPrimitive.RadioItem>
|
||||
|
|
@ -122,11 +122,11 @@ function DropdownMenuLabel({
|
|||
className,
|
||||
inset,
|
||||
...props
|
||||
}: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
|
||||
}: DropdownMenuPrimitive.GroupLabel.Props & {
|
||||
inset?: boolean;
|
||||
}) {
|
||||
return (
|
||||
<DropdownMenuPrimitive.Label
|
||||
<DropdownMenuPrimitive.GroupLabel
|
||||
data-slot="dropdown-menu-label"
|
||||
data-inset={inset}
|
||||
className={cn("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8", className)}
|
||||
|
|
@ -135,7 +135,7 @@ function DropdownMenuLabel({
|
|||
);
|
||||
}
|
||||
|
||||
function DropdownMenuSeparator({ className, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {
|
||||
function DropdownMenuSeparator({ className, ...props }: DropdownMenuPrimitive.Separator.Props) {
|
||||
return (
|
||||
<DropdownMenuPrimitive.Separator
|
||||
data-slot="dropdown-menu-separator"
|
||||
|
|
@ -155,8 +155,8 @@ function DropdownMenuShortcut({ className, ...props }: React.ComponentProps<"spa
|
|||
);
|
||||
}
|
||||
|
||||
function DropdownMenuSub({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {
|
||||
return <DropdownMenuPrimitive.Sub data-slot="dropdown-menu-sub" {...props} />;
|
||||
function DropdownMenuSub({ ...props }: DropdownMenuPrimitive.SubmenuRoot.Props) {
|
||||
return <DropdownMenuPrimitive.SubmenuRoot {...props} />;
|
||||
}
|
||||
|
||||
function DropdownMenuSubTrigger({
|
||||
|
|
@ -164,88 +164,27 @@ function DropdownMenuSubTrigger({
|
|||
inset,
|
||||
children,
|
||||
...props
|
||||
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
|
||||
}: DropdownMenuPrimitive.SubmenuTrigger.Props & {
|
||||
inset?: boolean;
|
||||
}) {
|
||||
return (
|
||||
<DropdownMenuPrimitive.SubTrigger
|
||||
<DropdownMenuPrimitive.SubmenuTrigger
|
||||
data-slot="dropdown-menu-sub-trigger"
|
||||
data-inset={inset}
|
||||
className={cn(
|
||||
"focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]: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-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
"data-highlighted:bg-accent data-highlighted:text-accent-foreground data-popup-open:bg-accent data-popup-open: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-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<ChevronRightIcon className="ml-auto size-4" />
|
||||
</DropdownMenuPrimitive.SubTrigger>
|
||||
</DropdownMenuPrimitive.SubmenuTrigger>
|
||||
);
|
||||
}
|
||||
|
||||
function DropdownMenuSubContent({ className, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {
|
||||
return (
|
||||
<DropdownMenuPrimitive.SubContent
|
||||
data-slot="dropdown-menu-sub-content"
|
||||
className={cn(
|
||||
"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-dropdown min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for managing submenu hover behavior with delayed close.
|
||||
* Prevents accidental submenu closure on quick mouse movements.
|
||||
*
|
||||
* @param closeDelay - Delay in ms before closing submenu when leaving trigger/content
|
||||
* @param onOpenChange - Callback to update submenu open state
|
||||
* @returns Object with event handlers and state management utilities
|
||||
*/
|
||||
function useDropdownMenuSubHoverDelay(closeDelay = 150, onOpenChange?: (open: boolean) => void) {
|
||||
const closeTimeoutRef = useRef<number | null>(null);
|
||||
|
||||
const clearCloseTimeout = () => {
|
||||
if (closeTimeoutRef.current) {
|
||||
clearTimeout(closeTimeoutRef.current);
|
||||
closeTimeoutRef.current = null;
|
||||
}
|
||||
};
|
||||
|
||||
const scheduleClose = (delay = 0) => {
|
||||
clearCloseTimeout();
|
||||
closeTimeoutRef.current = window.setTimeout(() => onOpenChange?.(false), delay);
|
||||
};
|
||||
|
||||
const handleTriggerEnter = () => {
|
||||
clearCloseTimeout();
|
||||
onOpenChange?.(true);
|
||||
};
|
||||
|
||||
const handleTriggerLeave = () => {
|
||||
scheduleClose(closeDelay);
|
||||
};
|
||||
|
||||
const handleContentEnter = () => {
|
||||
clearCloseTimeout();
|
||||
};
|
||||
|
||||
const handleContentLeave = () => {
|
||||
scheduleClose();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
return () => clearCloseTimeout();
|
||||
}, []);
|
||||
|
||||
return {
|
||||
handleTriggerEnter,
|
||||
handleTriggerLeave,
|
||||
handleContentEnter,
|
||||
handleContentLeave,
|
||||
};
|
||||
function DropdownMenuSubContent({ className, ...props }: DropdownMenuContentProps) {
|
||||
return <DropdownMenuContent align="start" alignOffset={-3} side="right" sideOffset={0} className={cn("w-auto", className)} {...props} />;
|
||||
}
|
||||
|
||||
export {
|
||||
|
|
@ -264,5 +203,4 @@ export {
|
|||
DropdownMenuSubContent,
|
||||
DropdownMenuSubTrigger,
|
||||
DropdownMenuTrigger,
|
||||
useDropdownMenuSubHoverDelay,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import * as LabelPrimitive from "@radix-ui/react-label";
|
||||
import * as React from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
function Label({ className, ...props }: React.ComponentProps<typeof LabelPrimitive.Root>) {
|
||||
function Label({ className, ...props }: React.ComponentProps<"label">) {
|
||||
return (
|
||||
<LabelPrimitive.Root
|
||||
<label
|
||||
data-slot="label"
|
||||
className={cn(
|
||||
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
||||
|
|
|
|||
|
|
@ -1,47 +1,44 @@
|
|||
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
||||
import { Popover as PopoverPrimitive } from "@base-ui/react/popover";
|
||||
import * as React from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { popupMotionClasses } from "./popup";
|
||||
|
||||
const Popover = ({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Root>) => {
|
||||
const Popover = ({ ...props }: PopoverPrimitive.Root.Props) => {
|
||||
return <PopoverPrimitive.Root data-slot="popover" {...props} />;
|
||||
};
|
||||
|
||||
const PopoverTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof PopoverPrimitive.Trigger>,
|
||||
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Trigger>
|
||||
>(({ ...props }, ref) => {
|
||||
const PopoverTrigger = React.forwardRef<HTMLButtonElement, PopoverPrimitive.Trigger.Props>(({ ...props }, ref) => {
|
||||
return <PopoverPrimitive.Trigger ref={ref} data-slot="popover-trigger" {...props} />;
|
||||
});
|
||||
PopoverTrigger.displayName = "PopoverTrigger";
|
||||
|
||||
const PopoverContent = React.forwardRef<
|
||||
React.ElementRef<typeof PopoverPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
|
||||
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => {
|
||||
HTMLDivElement,
|
||||
PopoverPrimitive.Popup.Props & Pick<PopoverPrimitive.Positioner.Props, "align" | "alignOffset" | "side" | "sideOffset">
|
||||
>(({ className, align = "center", alignOffset, side, sideOffset = 4, ...props }, ref) => {
|
||||
return (
|
||||
<PopoverPrimitive.Portal>
|
||||
<PopoverPrimitive.Content
|
||||
ref={ref}
|
||||
data-slot="popover-content"
|
||||
<PopoverPrimitive.Positioner
|
||||
align={align}
|
||||
alignOffset={alignOffset}
|
||||
side={side}
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"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-dropdown w-auto origin-(--radix-popover-content-transform-origin) rounded-md border p-1 shadow-md outline-hidden",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
className="isolate z-dropdown"
|
||||
>
|
||||
<PopoverPrimitive.Popup
|
||||
ref={ref}
|
||||
data-slot="popover-content"
|
||||
className={cn(
|
||||
"bg-popover text-popover-foreground z-dropdown w-auto origin-(--transform-origin) rounded-md border p-1 shadow-md outline-hidden",
|
||||
popupMotionClasses,
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</PopoverPrimitive.Positioner>
|
||||
</PopoverPrimitive.Portal>
|
||||
);
|
||||
});
|
||||
PopoverContent.displayName = "PopoverContent";
|
||||
|
||||
const PopoverAnchor = React.forwardRef<
|
||||
React.ElementRef<typeof PopoverPrimitive.Anchor>,
|
||||
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Anchor>
|
||||
>(({ ...props }, ref) => {
|
||||
return <PopoverPrimitive.Anchor ref={ref} data-slot="popover-anchor" {...props} />;
|
||||
});
|
||||
PopoverAnchor.displayName = "PopoverAnchor";
|
||||
|
||||
export { Popover, PopoverAnchor, PopoverContent, PopoverTrigger };
|
||||
export { Popover, PopoverContent, PopoverTrigger };
|
||||
|
|
|
|||
5
web/src/components/ui/popup.ts
Normal file
5
web/src/components/ui/popup.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// Shared enter/exit motion for popup surfaces (dropdown menu, popover, tooltip), driven by
|
||||
// Base UI's data-starting-style/data-ending-style attributes. Keep in one place so all
|
||||
// popups animate identically; select.tsx uses a closer-range variant of the same pattern.
|
||||
export const popupMotionClasses =
|
||||
"transition-[opacity,scale,translate] duration-150 data-starting-style:scale-95 data-starting-style:opacity-0 data-ending-style:scale-95 data-ending-style:opacity-0 data-[side=bottom]:data-starting-style:-translate-y-2 data-[side=bottom]:data-ending-style:-translate-y-2 data-[side=left]:data-starting-style:translate-x-2 data-[side=left]:data-ending-style:translate-x-2 data-[side=right]:data-starting-style:-translate-x-2 data-[side=right]:data-ending-style:-translate-x-2 data-[side=top]:data-starting-style:translate-y-2 data-[side=top]:data-ending-style:translate-y-2";
|
||||
|
|
@ -1,26 +1,26 @@
|
|||
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
||||
import { Radio } from "@base-ui/react/radio";
|
||||
import { RadioGroup as RadioGroupPrimitive } from "@base-ui/react/radio-group";
|
||||
import { CircleIcon } from "lucide-react";
|
||||
import * as React from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
function RadioGroup({ className, ...props }: React.ComponentProps<typeof RadioGroupPrimitive.Root>) {
|
||||
return <RadioGroupPrimitive.Root data-slot="radio-group" className={cn("grid gap-3", className)} {...props} />;
|
||||
function RadioGroup({ className, ...props }: RadioGroupPrimitive.Props) {
|
||||
return <RadioGroupPrimitive data-slot="radio-group" className={cn("grid gap-3", className)} {...props} />;
|
||||
}
|
||||
|
||||
function RadioGroupItem({ className, ...props }: React.ComponentProps<typeof RadioGroupPrimitive.Item>) {
|
||||
function RadioGroupItem({ className, ...props }: Radio.Root.Props) {
|
||||
return (
|
||||
<RadioGroupPrimitive.Item
|
||||
<Radio.Root
|
||||
data-slot="radio-group-item"
|
||||
className={cn(
|
||||
"border-border text-primary aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] disabled:cursor-not-allowed disabled:opacity-50",
|
||||
"border-border text-primary aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] data-disabled:cursor-not-allowed data-disabled:opacity-50",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<RadioGroupPrimitive.Indicator data-slot="radio-group-indicator" className="relative flex items-center justify-center">
|
||||
<Radio.Indicator data-slot="radio-group-indicator" className="relative flex items-center justify-center">
|
||||
<CircleIcon className="fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2" />
|
||||
</RadioGroupPrimitive.Indicator>
|
||||
</RadioGroupPrimitive.Item>
|
||||
</Radio.Indicator>
|
||||
</Radio.Root>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,28 @@
|
|||
import * as SelectPrimitive from "@radix-ui/react-select";
|
||||
import { Select as SelectPrimitive } from "@base-ui/react/select";
|
||||
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react";
|
||||
import * as React from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
function Select({ ...props }: React.ComponentProps<typeof SelectPrimitive.Root>) {
|
||||
return <SelectPrimitive.Root data-slot="select" {...props} />;
|
||||
type SelectProps = Omit<SelectPrimitive.Root.Props<string>, "onValueChange"> & {
|
||||
onValueChange?: (value: string) => void;
|
||||
};
|
||||
|
||||
// Base UI types the callback value as `string | null`, but none of the app's selects are
|
||||
// clearable, so the null case is filtered here once instead of at every call site.
|
||||
function Select({ onValueChange, ...props }: SelectProps) {
|
||||
return (
|
||||
<SelectPrimitive.Root
|
||||
data-slot="select"
|
||||
onValueChange={onValueChange && ((value: string | null) => value !== null && onValueChange(value))}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function SelectGroup({ ...props }: React.ComponentProps<typeof SelectPrimitive.Group>) {
|
||||
function SelectGroup({ ...props }: SelectPrimitive.Group.Props) {
|
||||
return <SelectPrimitive.Group data-slot="select-group" {...props} />;
|
||||
}
|
||||
|
||||
function SelectValue({ ...props }: React.ComponentProps<typeof SelectPrimitive.Value>) {
|
||||
function SelectValue({ ...props }: SelectPrimitive.Value.Props) {
|
||||
return <SelectPrimitive.Value data-slot="select-value" {...props} />;
|
||||
}
|
||||
|
||||
|
|
@ -20,7 +31,7 @@ function SelectTrigger({
|
|||
size = "default",
|
||||
children,
|
||||
...props
|
||||
}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
|
||||
}: SelectPrimitive.Trigger.Props & {
|
||||
size?: "xs" | "sm" | "default";
|
||||
}) {
|
||||
return (
|
||||
|
|
@ -34,45 +45,54 @@ function SelectTrigger({
|
|||
{...props}
|
||||
>
|
||||
{children}
|
||||
<SelectPrimitive.Icon asChild>
|
||||
<ChevronDownIcon className="size-4 opacity-50" />
|
||||
</SelectPrimitive.Icon>
|
||||
<SelectPrimitive.Icon render={<ChevronDownIcon className="size-4 opacity-50" />} />
|
||||
</SelectPrimitive.Trigger>
|
||||
);
|
||||
}
|
||||
|
||||
function SelectContent({ className, children, position = "popper", ...props }: React.ComponentProps<typeof SelectPrimitive.Content>) {
|
||||
type SelectContentProps = SelectPrimitive.Popup.Props &
|
||||
Pick<SelectPrimitive.Positioner.Props, "align" | "alignItemWithTrigger" | "alignOffset" | "side" | "sideOffset">;
|
||||
|
||||
function SelectContent({
|
||||
className,
|
||||
children,
|
||||
align = "start",
|
||||
alignItemWithTrigger = false,
|
||||
alignOffset,
|
||||
side,
|
||||
sideOffset = 4,
|
||||
...props
|
||||
}: SelectContentProps) {
|
||||
return (
|
||||
<SelectPrimitive.Portal>
|
||||
<SelectPrimitive.Content
|
||||
data-slot="select-content"
|
||||
className={cn(
|
||||
"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 relative z-dropdown max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
|
||||
position === "popper" &&
|
||||
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
||||
className,
|
||||
)}
|
||||
position={position}
|
||||
{...props}
|
||||
<SelectPrimitive.Positioner
|
||||
align={align}
|
||||
alignItemWithTrigger={alignItemWithTrigger}
|
||||
alignOffset={alignOffset}
|
||||
side={side}
|
||||
sideOffset={sideOffset}
|
||||
>
|
||||
<SelectScrollUpButton />
|
||||
<SelectPrimitive.Viewport
|
||||
<SelectPrimitive.Popup
|
||||
data-slot="select-content"
|
||||
className={cn(
|
||||
"p-1",
|
||||
position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1",
|
||||
"bg-popover text-popover-foreground relative z-dropdown max-h-(--available-height) min-w-[8rem] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md transition-[opacity,scale,translate] duration-150 data-starting-style:scale-95 data-starting-style:opacity-0 data-ending-style:scale-95 data-ending-style:opacity-0 data-[side=bottom]:translate-y-1 data-[side=bottom]:data-starting-style:-translate-y-1 data-[side=bottom]:data-ending-style:-translate-y-1 data-[side=left]:-translate-x-1 data-[side=left]:data-starting-style:translate-x-1 data-[side=left]:data-ending-style:translate-x-1 data-[side=right]:translate-x-1 data-[side=right]:data-starting-style:-translate-x-1 data-[side=right]:data-ending-style:-translate-x-1 data-[side=top]:-translate-y-1 data-[side=top]:data-starting-style:translate-y-1 data-[side=top]:data-ending-style:translate-y-1",
|
||||
!alignItemWithTrigger && "w-full min-w-(--anchor-width) scroll-my-1",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</SelectPrimitive.Viewport>
|
||||
<SelectScrollDownButton />
|
||||
</SelectPrimitive.Content>
|
||||
<SelectScrollUpButton />
|
||||
<SelectPrimitive.List className="p-1">{children}</SelectPrimitive.List>
|
||||
<SelectScrollDownButton />
|
||||
</SelectPrimitive.Popup>
|
||||
</SelectPrimitive.Positioner>
|
||||
</SelectPrimitive.Portal>
|
||||
);
|
||||
}
|
||||
|
||||
function SelectLabel({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.Label>) {
|
||||
function SelectLabel({ className, ...props }: SelectPrimitive.GroupLabel.Props) {
|
||||
return (
|
||||
<SelectPrimitive.Label
|
||||
<SelectPrimitive.GroupLabel
|
||||
data-slot="select-label"
|
||||
className={cn("text-muted-foreground px-2 py-1 text-xs select-none", className)}
|
||||
{...props}
|
||||
|
|
@ -80,27 +100,25 @@ function SelectLabel({ className, ...props }: React.ComponentProps<typeof Select
|
|||
);
|
||||
}
|
||||
|
||||
function SelectItem({ className, children, ...props }: React.ComponentProps<typeof SelectPrimitive.Item>) {
|
||||
function SelectItem({ className, children, ...props }: SelectPrimitive.Item.Props) {
|
||||
return (
|
||||
<SelectPrimitive.Item
|
||||
data-slot="select-item"
|
||||
className={cn(
|
||||
"focus:bg-accent focus: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",
|
||||
"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",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<span 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.ItemText className="shrink-0 whitespace-nowrap">{children}</SelectPrimitive.ItemText>
|
||||
<SelectPrimitive.ItemIndicator render={<span className="absolute right-2 flex size-3.5 items-center justify-center" />}>
|
||||
<CheckIcon className="size-4" />
|
||||
</SelectPrimitive.ItemIndicator>
|
||||
</SelectPrimitive.Item>
|
||||
);
|
||||
}
|
||||
|
||||
function SelectSeparator({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.Separator>) {
|
||||
function SelectSeparator({ className, ...props }: SelectPrimitive.Separator.Props) {
|
||||
return (
|
||||
<SelectPrimitive.Separator
|
||||
data-slot="select-separator"
|
||||
|
|
@ -110,27 +128,27 @@ function SelectSeparator({ className, ...props }: React.ComponentProps<typeof Se
|
|||
);
|
||||
}
|
||||
|
||||
function SelectScrollUpButton({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {
|
||||
function SelectScrollUpButton({ className, ...props }: SelectPrimitive.ScrollUpArrow.Props) {
|
||||
return (
|
||||
<SelectPrimitive.ScrollUpButton
|
||||
<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.ScrollUpButton>
|
||||
</SelectPrimitive.ScrollUpArrow>
|
||||
);
|
||||
}
|
||||
|
||||
function SelectScrollDownButton({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {
|
||||
function SelectScrollDownButton({ className, ...props }: SelectPrimitive.ScrollDownArrow.Props) {
|
||||
return (
|
||||
<SelectPrimitive.ScrollDownButton
|
||||
<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.ScrollDownButton>
|
||||
</SelectPrimitive.ScrollDownArrow>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,10 @@
|
|||
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
||||
import * as React from "react";
|
||||
import { Separator as SeparatorPrimitive } from "@base-ui/react/separator";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
function Separator({
|
||||
className,
|
||||
orientation = "horizontal",
|
||||
decorative = true,
|
||||
...props
|
||||
}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
|
||||
function Separator({ className, orientation = "horizontal", ...props }: SeparatorPrimitive.Props) {
|
||||
return (
|
||||
<SeparatorPrimitive.Root
|
||||
<SeparatorPrimitive
|
||||
data-slot="separator"
|
||||
decorative={decorative}
|
||||
orientation={orientation}
|
||||
className={cn(
|
||||
"bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",
|
||||
|
|
|
|||
|
|
@ -1,42 +1,33 @@
|
|||
import * as SheetPrimitive from "@radix-ui/react-dialog";
|
||||
import { Dialog as SheetPrimitive } from "@base-ui/react/dialog";
|
||||
import { XIcon } from "lucide-react";
|
||||
import * as React from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const Sheet = ({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>) => {
|
||||
const Sheet = ({ ...props }: SheetPrimitive.Root.Props) => {
|
||||
return <SheetPrimitive.Root data-slot="sheet" {...props} />;
|
||||
};
|
||||
|
||||
const SheetTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof SheetPrimitive.Trigger>,
|
||||
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Trigger>
|
||||
>(({ ...props }, ref) => {
|
||||
const SheetTrigger = React.forwardRef<HTMLButtonElement, SheetPrimitive.Trigger.Props>(({ ...props }, ref) => {
|
||||
return <SheetPrimitive.Trigger ref={ref} data-slot="sheet-trigger" {...props} />;
|
||||
});
|
||||
SheetTrigger.displayName = "SheetTrigger";
|
||||
|
||||
const SheetClose = React.forwardRef<
|
||||
React.ElementRef<typeof SheetPrimitive.Close>,
|
||||
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Close>
|
||||
>(({ ...props }, ref) => {
|
||||
const SheetClose = React.forwardRef<HTMLButtonElement, SheetPrimitive.Close.Props>(({ ...props }, ref) => {
|
||||
return <SheetPrimitive.Close ref={ref} data-slot="sheet-close" {...props} />;
|
||||
});
|
||||
SheetClose.displayName = "SheetClose";
|
||||
|
||||
const SheetPortal = ({ ...props }: React.ComponentProps<typeof SheetPrimitive.Portal>) => {
|
||||
return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />;
|
||||
const SheetPortal = ({ ...props }: SheetPrimitive.Portal.Props) => {
|
||||
return <SheetPrimitive.Portal {...props} />;
|
||||
};
|
||||
|
||||
const SheetOverlay = React.forwardRef<
|
||||
React.ElementRef<typeof SheetPrimitive.Overlay>,
|
||||
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>
|
||||
>(({ className, ...props }, ref) => {
|
||||
const SheetOverlay = React.forwardRef<HTMLDivElement, SheetPrimitive.Backdrop.Props>(({ className, ...props }, ref) => {
|
||||
return (
|
||||
<SheetPrimitive.Overlay
|
||||
<SheetPrimitive.Backdrop
|
||||
ref={ref}
|
||||
data-slot="sheet-overlay"
|
||||
className={cn(
|
||||
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-overlay bg-foreground/50",
|
||||
"fixed inset-0 z-overlay bg-foreground/50 transition-opacity duration-300 data-starting-style:opacity-0 data-ending-style:opacity-0",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
|
@ -46,43 +37,37 @@ const SheetOverlay = React.forwardRef<
|
|||
SheetOverlay.displayName = "SheetOverlay";
|
||||
|
||||
const SheetContent = React.forwardRef<
|
||||
React.ElementRef<typeof SheetPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content> & {
|
||||
HTMLDivElement,
|
||||
SheetPrimitive.Popup.Props & {
|
||||
side?: "top" | "right" | "bottom" | "left";
|
||||
}
|
||||
>(({ className, children, side = "right", ...props }, ref) => {
|
||||
return (
|
||||
<SheetPortal>
|
||||
<SheetOverlay />
|
||||
<SheetPrimitive.Content
|
||||
<SheetPrimitive.Popup
|
||||
ref={ref}
|
||||
data-slot="sheet-content"
|
||||
className={cn(
|
||||
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-overlay flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
|
||||
"bg-background fixed z-overlay flex flex-col gap-4 shadow-lg transition-transform duration-500 ease-in-out data-ending-style:duration-300",
|
||||
side === "right" &&
|
||||
"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",
|
||||
"inset-y-0 right-0 h-full w-3/4 border-l data-starting-style:translate-x-full data-ending-style:translate-x-full sm:max-w-sm",
|
||||
side === "left" &&
|
||||
"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",
|
||||
side === "top" && "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",
|
||||
side === "bottom" &&
|
||||
"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",
|
||||
"inset-y-0 left-0 h-full w-3/4 border-r data-starting-style:-translate-x-full data-ending-style:-translate-x-full sm:max-w-sm",
|
||||
side === "top" && "inset-x-0 top-0 h-auto border-b data-starting-style:-translate-y-full data-ending-style:-translate-y-full",
|
||||
side === "bottom" && "inset-x-0 bottom-0 h-auto border-t data-starting-style:translate-y-full data-ending-style:translate-y-full",
|
||||
className,
|
||||
)}
|
||||
onOpenAutoFocus={(e) => {
|
||||
e.preventDefault();
|
||||
}}
|
||||
onCloseAutoFocus={(e) => {
|
||||
e.preventDefault();
|
||||
document.body.style.pointerEvents = "auto";
|
||||
}}
|
||||
initialFocus={false}
|
||||
finalFocus={false}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<SheetPrimitive.Close className="ring-offset-background data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-60 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">
|
||||
<SheetPrimitive.Close className="ring-offset-background absolute top-4 right-4 rounded-xs opacity-60 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">
|
||||
<XIcon className="size-5" />
|
||||
<span className="sr-only">Close</span>
|
||||
</SheetPrimitive.Close>
|
||||
</SheetPrimitive.Content>
|
||||
</SheetPrimitive.Popup>
|
||||
</SheetPortal>
|
||||
);
|
||||
});
|
||||
|
|
@ -98,18 +83,12 @@ const SheetFooter = React.forwardRef<React.ElementRef<"div">, React.ComponentPro
|
|||
});
|
||||
SheetFooter.displayName = "SheetFooter";
|
||||
|
||||
const SheetTitle = React.forwardRef<
|
||||
React.ElementRef<typeof SheetPrimitive.Title>,
|
||||
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title>
|
||||
>(({ className, ...props }, ref) => {
|
||||
const SheetTitle = React.forwardRef<HTMLHeadingElement, SheetPrimitive.Title.Props>(({ className, ...props }, ref) => {
|
||||
return <SheetPrimitive.Title ref={ref} data-slot="sheet-title" className={cn("text-foreground font-semibold", className)} {...props} />;
|
||||
});
|
||||
SheetTitle.displayName = "SheetTitle";
|
||||
|
||||
const SheetDescription = React.forwardRef<
|
||||
React.ElementRef<typeof SheetPrimitive.Description>,
|
||||
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description>
|
||||
>(({ className, ...props }, ref) => {
|
||||
const SheetDescription = React.forwardRef<HTMLParagraphElement, SheetPrimitive.Description.Props>(({ className, ...props }, ref) => {
|
||||
return (
|
||||
<SheetPrimitive.Description
|
||||
ref={ref}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
import * as SwitchPrimitive from "@radix-ui/react-switch";
|
||||
import * as React from "react";
|
||||
import { Switch as SwitchPrimitive } from "@base-ui/react/switch";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
function Switch({ className, ...props }: React.ComponentProps<typeof SwitchPrimitive.Root>) {
|
||||
function Switch({ className, ...props }: SwitchPrimitive.Root.Props) {
|
||||
return (
|
||||
<SwitchPrimitive.Root
|
||||
data-slot="switch"
|
||||
className={cn(
|
||||
"peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",
|
||||
"peer data-checked:bg-primary data-unchecked:bg-input inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all data-disabled:cursor-not-allowed data-disabled:opacity-50",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
|
@ -15,7 +14,7 @@ function Switch({ className, ...props }: React.ComponentProps<typeof SwitchPrimi
|
|||
<SwitchPrimitive.Thumb
|
||||
data-slot="switch-thumb"
|
||||
className={cn(
|
||||
"bg-background pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0",
|
||||
"bg-background pointer-events-none block size-4 rounded-full ring-0 transition-transform data-checked:translate-x-[calc(100%-2px)] data-unchecked:translate-x-0",
|
||||
)}
|
||||
/>
|
||||
</SwitchPrimitive.Root>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
||||
import { Tooltip as TooltipPrimitive } from "@base-ui/react/tooltip";
|
||||
import * as React from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { popupMotionClasses } from "./popup";
|
||||
|
||||
const TooltipProvider = ({ delayDuration = 0, ...props }: React.ComponentProps<typeof TooltipPrimitive.Provider>) => {
|
||||
return <TooltipPrimitive.Provider data-slot="tooltip-provider" delayDuration={delayDuration} {...props} />;
|
||||
const TooltipProvider = ({ delay = 0, ...props }: TooltipPrimitive.Provider.Props) => {
|
||||
return <TooltipPrimitive.Provider delay={delay} {...props} />;
|
||||
};
|
||||
|
||||
const Tooltip = ({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Root>) => {
|
||||
const Tooltip = ({ ...props }: TooltipPrimitive.Root.Props) => {
|
||||
return (
|
||||
<TooltipProvider>
|
||||
<TooltipPrimitive.Root data-slot="tooltip" {...props} />
|
||||
|
|
@ -14,33 +15,38 @@ const Tooltip = ({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Root
|
|||
);
|
||||
};
|
||||
|
||||
const TooltipTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof TooltipPrimitive.Trigger>,
|
||||
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Trigger>
|
||||
>(({ ...props }, ref) => {
|
||||
const TooltipTrigger = React.forwardRef<HTMLButtonElement, TooltipPrimitive.Trigger.Props>(({ ...props }, ref) => {
|
||||
return <TooltipPrimitive.Trigger ref={ref} data-slot="tooltip-trigger" {...props} />;
|
||||
});
|
||||
TooltipTrigger.displayName = "TooltipTrigger";
|
||||
|
||||
const TooltipContent = React.forwardRef<
|
||||
React.ElementRef<typeof TooltipPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
|
||||
>(({ className, sideOffset = 0, children, ...props }, ref) => {
|
||||
HTMLDivElement,
|
||||
TooltipPrimitive.Popup.Props & Pick<TooltipPrimitive.Positioner.Props, "align" | "alignOffset" | "side" | "sideOffset">
|
||||
>(({ className, align, alignOffset, side, sideOffset = 0, children, ...props }, ref) => {
|
||||
return (
|
||||
<TooltipPrimitive.Portal>
|
||||
<TooltipPrimitive.Content
|
||||
ref={ref}
|
||||
data-slot="tooltip-content"
|
||||
<TooltipPrimitive.Positioner
|
||||
align={align}
|
||||
alignOffset={alignOffset}
|
||||
side={side}
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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-tooltip w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
className="isolate z-tooltip"
|
||||
>
|
||||
{children}
|
||||
<TooltipPrimitive.Arrow className="bg-primary fill-primary z-tooltip size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" />
|
||||
</TooltipPrimitive.Content>
|
||||
<TooltipPrimitive.Popup
|
||||
ref={ref}
|
||||
data-slot="tooltip-content"
|
||||
className={cn(
|
||||
"bg-primary text-primary-foreground z-tooltip w-fit origin-(--transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
|
||||
popupMotionClasses,
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<TooltipPrimitive.Arrow className="bg-primary z-tooltip size-2.5 rotate-45 rounded-[2px]" />
|
||||
</TooltipPrimitive.Popup>
|
||||
</TooltipPrimitive.Positioner>
|
||||
</TooltipPrimitive.Portal>
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -46,11 +46,9 @@ const About = () => {
|
|||
</div>
|
||||
<div className="flex shrink-0 flex-wrap gap-2">
|
||||
{PRODUCT_LINKS.map((link) => (
|
||||
<Button key={link.href} asChild variant="outline" size="lg">
|
||||
<a href={link.href} target="_blank" rel="noreferrer">
|
||||
{link.label}
|
||||
<ExternalLinkIcon className="size-3.5" />
|
||||
</a>
|
||||
<Button key={link.href} render={<a href={link.href} target="_blank" rel="noreferrer" />} variant="outline" size="lg">
|
||||
{link.label}
|
||||
<ExternalLinkIcon className="size-3.5" />
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -41,6 +41,11 @@ const Setting = () => {
|
|||
|
||||
const visibleSectionKeys = useMemo(() => new Set(sectionGroups.all.map((section) => section.key)), [sectionGroups.all]);
|
||||
|
||||
const sectionOptions = useMemo(
|
||||
() => sectionGroups.all.map((section) => ({ value: section.key, label: t(section.labelKey) })),
|
||||
[sectionGroups.all, t],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const hash = location.hash.slice(1);
|
||||
const nextSection = isSettingSectionKey(hash) && visibleSectionKeys.has(hash) ? hash : DEFAULT_SETTING_SECTION;
|
||||
|
|
@ -113,14 +118,18 @@ const Setting = () => {
|
|||
<div className="w-full grow sm:pl-4 overflow-x-auto">
|
||||
{!sm && (
|
||||
<div className="w-auto inline-block my-2">
|
||||
<Select value={selectedSection} onValueChange={(value) => handleSectionSelectorItemClick(value as SettingSectionKey)}>
|
||||
<Select
|
||||
value={selectedSection}
|
||||
items={sectionOptions}
|
||||
onValueChange={(value) => handleSectionSelectorItemClick(value as SettingSectionKey)}
|
||||
>
|
||||
<SelectTrigger className="w-[180px]">
|
||||
<SelectValue placeholder={t("setting.select-section")} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{sectionGroups.all.map((section) => (
|
||||
<SelectItem key={section.key} value={section.key}>
|
||||
{t(section.labelKey)}
|
||||
{sectionOptions.map((option) => (
|
||||
<SelectItem key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
|
|
|
|||
|
|
@ -536,10 +536,8 @@ const Shortcuts = () => {
|
|||
{shortcut.filter}
|
||||
</pre>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="ghost" size="icon" className="justify-self-end">
|
||||
<MoreVerticalIcon className="h-4 w-4" />
|
||||
</Button>
|
||||
<DropdownMenuTrigger render={<Button variant="ghost" size="icon" className="justify-self-end" />}>
|
||||
<MoreVerticalIcon className="h-4 w-4" />
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem onClick={() => handleEditShortcut(shortcut)}>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import type { EditorController } from "@/components/MemoEditor/types/editorContr
|
|||
// so accessible names below are the keys themselves.
|
||||
vi.mock("@/utils/i18n", () => ({ useTranslate: () => (key: string) => key }));
|
||||
|
||||
// Radix DropdownMenu reaches for layout/pointer APIs jsdom doesn't implement.
|
||||
// Base UI menus reach for layout/pointer APIs jsdom doesn't implement.
|
||||
beforeAll(() => {
|
||||
Element.prototype.scrollIntoView = vi.fn();
|
||||
Element.prototype.hasPointerCapture = vi.fn(() => false);
|
||||
|
|
@ -57,8 +57,7 @@ describe("FormattingToolbar", () => {
|
|||
it("runs the heading command when a heading level is chosen", () => {
|
||||
const { controller, run } = makeController();
|
||||
renderToolbar(controller);
|
||||
// Keyboard open is the most reliable path for Radix menus in jsdom.
|
||||
fireEvent.keyDown(screen.getByRole("button", { name: "editor.format.heading" }), { key: "Enter" });
|
||||
fireEvent.click(screen.getByRole("button", { name: "editor.format.heading" }));
|
||||
fireEvent.click(screen.getByRole("menuitem", { name: "editor.format.heading-2" }));
|
||||
expect(run).toHaveBeenCalledWith("heading2");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ vi.mock("@/hooks/useMediaQuery", () => ({
|
|||
}));
|
||||
|
||||
describe("<PreviewImageDialog>", () => {
|
||||
it("provides a dialog description without Radix accessibility warnings", async () => {
|
||||
it("provides a dialog description without accessibility warnings", async () => {
|
||||
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
|
||||
render(
|
||||
|
|
|
|||
Loading…
Reference in a new issue