import { FC, Key, PropsWithChildren } from 'react'; import { DropdownOption } from '@mezzanine-ui/core/dropdown/dropdown'; import { NotificationSeverity, NotificationType } from '@mezzanine-ui/core/notification-center'; import { ButtonProps } from '../Button'; import { NotifierConfig, NotifierData } from '../Notifier'; import { type SlideProps } from '../Transition'; export interface NotificationConfigProps extends Pick, Pick { /** * Callback function when "View All" button is clicked. * This will be called after closing all notifications. */ onViewAll?: VoidFunction; /** * The text of the "View All" button. * @default '查看更多' */ viewAllButtonText?: string; } export interface NotificationData extends NotifierData, NotificationConfigProps { /** * The tips to be appended to the notification. * Only displayed when the type is 'drawer'. */ appendTips?: string; /** * Other props of cancel button. */ cancelButtonProps?: ButtonProps; /** * Cancel button text. */ cancelButtonText?: string; /** * Other props of confirm button. */ confirmButtonProps?: ButtonProps; /** * Confirm button text. */ confirmButtonText?: string; /** * The description of notification. */ description?: string; /** * The maximum number of notifications to be displayed. * Only displayed when the type is 'notification'. * @default 3 */ maxVisibleNotifications?: number; /** * The callback function when the badge is clicked. * Only displayed when the type is 'drawer'. */ onBadgeClick?: VoidFunction; /** * The callback function when the badge is selected. * Only displayed when the type is 'drawer'. */ onBadgeSelect?: (option: DropdownOption) => void; /** * Cancel button click event handler.
* If not provided, the event handler will fallback to a close function using `NotificationCenter.remove`. */ onCancel?: VoidFunction; /** * Confirm button click event handler.
* If given, will render action button group. */ onConfirm?: VoidFunction; /** * The options of the badge. * Only displayed when the type is 'drawer'. */ options?: DropdownOption[]; /** * The tips to be prepended to the notification. * Only displayed when the type is 'drawer'. */ prependTips?: string; /** * The identifier of the notification. */ reference?: Key; /** * The severity of the message. * @default info */ severity?: NotificationSeverity; /** * The props of the badge. * Only displayed when the type is 'drawer'. */ showBadge?: boolean; /** * The time stamp of notification on the drawer list. * @default new Date().toLocaleTimeString() */ timeStamp?: string | number; /** * The locale of the time stamp. * @default 'zh-TW' */ timeStampLocale?: string; /** * The title of notification. */ title?: string; /** * The type of notification. * @default 'notification' */ type?: NotificationType; } /** Props accepted by NotificationCenter severity shorthand methods such as `NotificationCenter.success`. */ export type NotificationCenterShorthandProps = Omit; /** Static severity shorthand methods attached to the {@link NotificationCenter} component. */ export interface NotificationCenterSeverityMethods { /** Display an error notification. */ error: (props?: NotificationCenterShorthandProps) => Key; /** Display an informational notification. */ info: (props?: NotificationCenterShorthandProps) => Key; /** Display a success notification. */ success: (props?: NotificationCenterShorthandProps) => Key; /** Display a warning notification. */ warning: (props?: NotificationCenterShorthandProps) => Key; } /** * 通知中心元件,支援即時提示(`notification`)與抽屜清單(`drawer`)兩種呈現模式。 * * 以 `` 宣告式渲染單筆浮動通知; * 或使用靜態方法 `NotificationCenter.add()`、`.success()`、`.error()` 等命令式 API * 觸發通知,並可透過回傳的 key 呼叫 `remove()` 收回。 * `type: 'drawer'` 模式下,請搭配 `NotificationCenterDrawer` 以清單方式顯示。 * * @example * ```tsx * import NotificationCenter from '@mezzanine-ui/react/NotificationCenter'; * * // 宣告式:嵌入畫面中的通知 * * * // 命令式:觸發浮動通知 * NotificationCenter.success({ title: '儲存成功', description: '資料已更新。' }); * NotificationCenter.error({ title: '操作失敗', description: '請稍後再試。' }); * * // 手動控制生命週期 * const key = NotificationCenter.add({ severity: 'info', title: '處理中…', type: 'notification' }); * NotificationCenter.remove(key); * ``` * * @see {@link NotificationData} 所有可用的通知設定項 * @see {@link NotificationCenterDrawer} 抽屜清單模式的容器元件 */ declare const NotificationCenter: FC> & { add: (notif: NotificationData & { key?: Key; }) => Key; config: (configs: NotificationConfigProps) => void; destroy: VoidFunction; remove: (key: Key) => void; error: (props?: NotificationCenterShorthandProps) => Key; info: (props?: NotificationCenterShorthandProps) => Key; success: (props?: NotificationCenterShorthandProps) => Key; warning: (props?: NotificationCenterShorthandProps) => Key; }; /** Full type of the {@link NotificationCenter} component including all static notification API methods. */ export type NotificationCenterType = typeof NotificationCenter; export default NotificationCenter;