@trellixio/roaster-coffee
Version:
Beans' product component library
57 lines • 2.38 kB
TypeScript
/// <reference types="react" />
import { ButtonProps } from '@/components';
export interface ModalProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'title'> {
/** Mounts modal if true */
opened: boolean;
/** Called when close button clicked */
onClose(): void;
/** Modal title, displayed in header */
title?: React.ReactNode;
/** Modal width */
size?: 'small' | 'large';
/** Modal footer use it for actions */
footer?: React.ReactNode;
}
export declare type ConfirmLabels = Record<'confirm' | 'cancel', React.ReactNode>;
export interface ModalProviderFooterProps {
/** The HTML ID attribute to be applied to the footer element (optional). */
id?: string;
/** A function to be called when the cancel button is clicked (optional). */
onCancel?(): void;
/** A function to be called when the confirm button is clicked (optional). */
onConfirm?(): void;
/** Whether the modal should close when the confirm button is clicked (optional). */
closeOnConfirm?: boolean;
/** Whether the modal should close when the cancel button is clicked (optional). */
closeOnCancel?: boolean;
/** Additional props to be passed to the cancel button (optional). */
cancelProps?: ButtonProps & React.ComponentPropsWithoutRef<'button'>;
/** Additional props to be passed to the confirm button (optional). */
confirmProps?: ButtonProps & React.ComponentPropsWithoutRef<'button'>;
/** Labels to be used for the confirm and cancel buttons (optional). */
labels?: ConfirmLabels;
}
export declare type ModalSettings = Partial<Omit<ModalProps, 'opened'>> & ModalProviderFooterProps;
export declare type ModalEvents = {
openModal(payload: ModalSettings): void;
closeModal(): void;
};
export declare type ModalState = {
props: ModalSettings;
type?: 'content';
};
export interface ModalContextProps {
/** The current state of the modal. */
modal: ModalState;
/** A function that opens a new modal with the specified settings. */
openModal: (props: ModalSettings) => void;
/** A function that closes the current modal. */
closeModal: () => void;
}
export interface ModalProviderProps {
/** Your app */
children: React.ReactNode;
/** Shared Modal component props, applied for every modal */
modalProps?: ModalSettings;
}
//# sourceMappingURL=index.d.ts.map