Server IP : 192.158.238.246 / Your IP : 18.223.188.252 Web Server : LiteSpeed System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64 User : jenniferflocom ( 1321) PHP Version : 8.1.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/jenniferflocom/www/wp-content/plugins/code-snippets/js/components/common/ |
Upload File : |
import React from 'react' import { __ } from '@wordpress/i18n' import { Button, Flex, Modal } from '@wordpress/components' import type { ReactNode } from 'react' export interface ConfirmDialogProps { open?: boolean title: string onConfirm?: VoidFunction onCancel: VoidFunction confirmLabel?: string cancelLabel?: string children?: ReactNode, confirmButtonClassName?: string } export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({ open, title, onConfirm, onCancel, children, confirmLabel = __('OK', 'code-snippets'), cancelLabel = __('Cancel', 'code-snippets'), confirmButtonClassName }) => open ? <Modal title={title} onRequestClose={onCancel} closeButtonLabel={cancelLabel} isDismissible={true} onKeyDown={event => { if ('Enter' === event.key) { onConfirm?.() } }} > {children} <Flex direction="row" justify="flex-end"> <Button variant="tertiary" onClick={onCancel}> {cancelLabel} </Button> <Button variant="primary" onClick={onConfirm} className={confirmButtonClassName}> {confirmLabel} </Button> </Flex> </Modal> : null