import { MessageSeverity } from '@mezzanine-ui/core/message'; import { IconDefinition } from '@mezzanine-ui/icons'; import type { FC, Key } from 'react'; import { NotifierData, NotifierConfig } from '../Notifier'; import { TranslateProps } from '../Transition'; export interface MessageConfigProps extends Pick, Pick { } export interface MessageData extends Omit, MessageConfigProps { /** * If given, the message will be closed after the amount of time. * You can use `Message.config` to overwrite. * @default 3000 */ duration?: NotifierData['duration']; /** * message icon prefix */ icon?: IconDefinition; /** * The key of message. */ reference?: Key; /** * The severity of the message. */ severity?: MessageSeverity; } /** * Props accepted by Message severity shorthand methods such as `Message.success`. * Includes an optional `key` to identify the message for later updates or dismissal. */ export type MessageShorthandProps = Omit & { key?: Key; }; /** * Signature shared by all Message severity shorthand methods. * @param message - The notification content. * @param props - Optional configuration; mirrors {@link MessageData} minus `children`, `severity`, and `icon`. */ export type MessageShorthandMethod = (message: MessageData['children'], props?: MessageShorthandProps) => Key; /** Static severity shorthand methods attached to the {@link Message} component. */ export interface MessageSeverityMethods { /** Display an error message. */ error: MessageShorthandMethod; /** Display an informational message. */ info: MessageShorthandMethod; /** Display a loading message that will **not** auto-close. */ loading: MessageShorthandMethod; /** Display a success message. */ success: MessageShorthandMethod; /** Display a warning message. */ warning: MessageShorthandMethod; } /** * The react component for `mezzanine` message. * * Trigger messages imperatively via severity shorthand methods: * * @example * ```tsx * import Message from '@mezzanine-ui/react/message'; * * Message.success('Saved!'); * Message.error('Something went wrong.'); * * // With custom key for later update/dismissal * const key = Message.loading('Uploading…'); * Message.success('Done!', { key }); * ``` * * @see {@link MessageData} for the full set of options accepted by `Message.add`. */ declare const Message: FC & { add: (notifier: MessageData & { key?: Key; }) => Key; config: (configs: MessageConfigProps) => void; destroy: VoidFunction; remove: (key: Key) => void; error: (message: MessageData["children"], props?: MessageShorthandProps) => Key; info: (message: MessageData["children"], props?: MessageShorthandProps) => Key; loading: (message: MessageData["children"], props?: MessageShorthandProps) => Key; success: (message: MessageData["children"], props?: MessageShorthandProps) => Key; warning: (message: MessageData["children"], props?: MessageShorthandProps) => Key; }; /** Full type of the {@link Message} component including all static notification API methods. */ export type MessageType = typeof Message; export default Message;