@jengaui/alert-dialog
Version:
Jenga UI Alert Dialog component in React
43 lines (40 loc) • 1.72 kB
TypeScript
import { AriaDialogProps } from '@react-types/dialog';
import { ReactNode } from 'react';
import { BaseProps, BaseStyleProps, BlockStyleProps, DimensionStyleProps } from 'tastycss';
import { JengaDialogContainerProps } from '@jengaui/dialog';
import { JengaAlertDialogProps } from './AlertDialog.js';
import '@jengaui/button';
interface Dialog {
props: DialogProps;
meta: AlertDialogMeta;
}
interface DialogProps extends Omit<JengaDialogContainerProps, 'onDismiss' | 'children'>, Omit<JengaAlertDialogProps, 'type' | 'id' | 'content'> {
content: ReactNode | (({ resolve, reject }: {
resolve: any;
reject: any;
}) => ReactNode);
}
declare type AlertDialogResolveStatus = 'confirm' | 'cancel' | 'secondary';
interface AlertDialogMeta {
id: number;
isClosed: boolean;
promise: Promise<AlertDialogResolveStatus>;
placement: 'top' | 'bottom';
resolve: (status: AlertDialogResolveStatus) => void;
reject: (reason: any) => void;
isVisible?: boolean;
dialogType?: 'info' | 'confirm' | 'form';
}
interface JengaDialogProps extends Omit<BaseProps, 'role'>, AriaDialogProps, BaseStyleProps, BlockStyleProps, DimensionStyleProps {
/** The type of the dialog. It affects its size and position. */
type?: 'modal' | 'popover' | 'fullscreen' | 'fullscreenTakeover' | 'panel' | 'tray';
/** The size of the dialog */
size?: 'S' | 'M' | 'L';
/** Whether the dialog is dismissable */
isDismissable?: boolean;
/** Trigger when the dialog is dismissed */
onDismiss?: (arg?: any) => void;
/** That you can replace the close icon with */
closeIcon?: ReactNode;
}
export { AlertDialogResolveStatus, Dialog, DialogProps, JengaDialogProps };