import type { FC } from 'react'; import React, { useContext } from 'react'; import ActionButton from '../../_util/ActionButton'; import type { ConfirmDialogProps } from '../ConfirmDialog'; import { ModalContext } from '../context'; export interface ConfirmCancelBtnProps extends Pick< ConfirmDialogProps, 'cancelButtonProps' | 'isSilent' | 'rootPrefixCls' | 'close' | 'onConfirm' | 'onCancel' > { autoFocusButton?: false | 'ok' | 'cancel' | null; cancelTextLocale?: | string | number | true | React.ReactElement> | Iterable; mergedOkCancel?: boolean; } const ConfirmCancelBtn: FC = () => { const { autoFocusButton, cancelButtonProps, cancelTextLocale, isSilent, mergedOkCancel, rootPrefixCls, close, onCancel, onConfirm, } = useContext(ModalContext); return mergedOkCancel ? ( { close?.(...args); onConfirm?.(false); }} autoFocus={autoFocusButton === 'cancel'} buttonProps={cancelButtonProps} prefixCls={`${rootPrefixCls}-btn`} > {cancelTextLocale} ) : null; }; export default ConfirmCancelBtn;