From 4c8877044c9a58fbe2878d0d70b566bb1e64a4a8 Mon Sep 17 00:00:00 2001 From: yyh Date: Tue, 3 Mar 2026 15:49:29 +0800 Subject: [PATCH] feat(ui): fill capability gaps in tooltip, dialog, and select primitives Tooltip: add enter/exit opacity animation with data-[instant] support Dialog: add overflow-y-auto for long content, optional closable button Select: add clearable/loading props to trigger, disable alignItemWithTrigger --- web/app/components/base/ui/dialog/index.tsx | 9 +++- web/app/components/base/ui/select/index.tsx | 45 ++++++++++++++++++-- web/app/components/base/ui/tooltip/index.tsx | 1 + 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/web/app/components/base/ui/dialog/index.tsx b/web/app/components/base/ui/dialog/index.tsx index b4b5f728b6..605fccee09 100644 --- a/web/app/components/base/ui/dialog/index.tsx +++ b/web/app/components/base/ui/dialog/index.tsx @@ -21,12 +21,14 @@ type DialogContentProps = { children: React.ReactNode className?: string overlayClassName?: string + closable?: boolean } export function DialogContent({ children, className, overlayClassName, + closable = false, }: DialogContentProps) { return ( @@ -39,11 +41,16 @@ export function DialogContent({ /> + {closable && ( + + + + )} {children} diff --git a/web/app/components/base/ui/select/index.tsx b/web/app/components/base/ui/select/index.tsx index adc4a70b58..d894cf0ded 100644 --- a/web/app/components/base/ui/select/index.tsx +++ b/web/app/components/base/ui/select/index.tsx @@ -12,11 +12,22 @@ export const SelectGroup = BaseSelect.Group export const SelectGroupLabel = BaseSelect.GroupLabel export const SelectSeparator = BaseSelect.Separator +type SelectTriggerProps = React.ComponentPropsWithoutRef & { + clearable?: boolean + onClear?: () => void + loading?: boolean +} + export function SelectTrigger({ className, children, + clearable = false, + onClear, + loading = false, ...props -}: React.ComponentPropsWithoutRef) { +}: SelectTriggerProps) { + const showClear = clearable && !loading + return ( {children} - - - + {loading + ? ( + + + + ) + : showClear + ? ( + { + e.stopPropagation() + onClear?.() + }} + onMouseDown={(e) => { + e.stopPropagation() + }} + > + + + ) + : ( + + + + )} ) } @@ -77,6 +113,7 @@ export function SelectContent({ align={align} sideOffset={sideOffset} alignOffset={alignOffset} + alignItemWithTrigger={false} className={cn('z-50 outline-none', className)} {...positionerProps} > diff --git a/web/app/components/base/ui/tooltip/index.tsx b/web/app/components/base/ui/tooltip/index.tsx index c4f18140e1..1a41cc0f56 100644 --- a/web/app/components/base/ui/tooltip/index.tsx +++ b/web/app/components/base/ui/tooltip/index.tsx @@ -42,6 +42,7 @@ export function TooltipContent({