perf: confirm ux (#4843)

* perf: delete tip ux

* perf: confirm ux
This commit is contained in:
Archer
2025-05-20 13:41:56 +08:00
committed by GitHub
parent 1dac2b70ec
commit d44c338059
18 changed files with 309 additions and 391 deletions

View File

@@ -11,15 +11,16 @@ import {
HStack,
Box,
Button,
PopoverArrow
PopoverArrow,
Portal
} from '@chakra-ui/react';
const PopoverConfirm = ({
content,
showCancel,
showCancel = true,
type,
Trigger,
placement = 'bottom-start',
placement = 'auto',
offset,
onConfirm,
confirmText,
@@ -50,7 +51,7 @@ const PopoverConfirm = ({
};
if (type && map[type]) return map[type];
return map.info;
}, [type, t]);
}, [type]);
const firstFieldRef = React.useRef(null);
const { onOpen, onClose, isOpen } = useDisclosure();
@@ -67,7 +68,7 @@ const PopoverConfirm = ({
onClose={onClose}
placement={placement}
offset={offset}
closeOnBlur={false}
closeOnBlur={true}
trigger={'click'}
openDelay={100}
closeDelay={100}
@@ -75,6 +76,7 @@ const PopoverConfirm = ({
lazyBehavior="keepMounted"
arrowSize={10}
strategy={'fixed'}
computePositionOnMount={true}
>
<PopoverTrigger>{Trigger}</PopoverTrigger>
<PopoverContent p={4}>
@@ -82,15 +84,25 @@ const PopoverConfirm = ({
<HStack alignItems={'flex-start'} color={'myGray.700'}>
<MyIcon name={map.icon as any} w={'1.5rem'} />
<Box fontSize={'sm'}>{content}</Box>
<Box fontSize={'sm'} whiteSpace={'pre-wrap'}>
{content}
</Box>
</HStack>
<HStack mt={1} justifyContent={'flex-end'}>
<HStack mt={2} justifyContent={'flex-end'}>
{showCancel && (
<Button variant={'whiteBase'} size="sm" onClick={onClose}>
{cancelText || t('common:Cancel')}
</Button>
)}
<Button isLoading={loading} variant={map.variant} size="sm" onClick={onclickConfirm}>
<Button
isLoading={loading}
variant={map.variant}
size="sm"
onClick={async (e) => {
e.stopPropagation();
await onclickConfirm();
}}
>
{confirmText || t('common:Confirm')}
</Button>
</HStack>