import { ModalSize, ModalStatusType } from '@mezzanine-ui/core/modal'; import { ModalContainerProps } from './useModalContainer'; import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types'; import { ModalHeaderProps } from './ModalHeader'; import { ModalFooterProps } from './ModalFooter'; export type ModalHeaderLayoutProps = Pick; interface CommonModalProps extends Omit, Pick, 'children'>, Partial> { /** * The custom class name applied to the modal container. */ backdropClassName?: string; /** * Whether to force full screen on any breakpoint. * @default false */ fullScreen?: boolean; /** * Whether the modal is loading. * Controls the loading prop of confirm button in modal actions. */ loading?: boolean; /** * Controls whether or not to display status icon before title. * Notice that giving a status will only display the regular title. * @default 'info' */ modalStatusType?: ModalStatusType; /** * Controls whether or not to show dismiss button at top-end. * @default true */ showDismissButton?: boolean; /** * Whether to show status type icon. * @default false */ showStatusTypeIcon?: boolean; /** * Supporting text displayed below the title. */ supportingText?: string; } interface ExtendedSplitModalProps extends CommonModalProps { /** * Content for the left side in extendedSplit layout. * Required when modalType is 'extendedSplit'. */ extendedSplitLeftSideContent: React.ReactNode; /** * Content for the right side in extendedSplit layout. * Required when modalType is 'extendedSplit'. */ extendedSplitRightSideContent: React.ReactNode; /** * Controls which side the sidebar panel (narrow column with footer) appears on. * - `'left'`: sidebar on the left, wide content on the right * - `'right'`: wide content on the left, sidebar on the right * @default 'right' */ extendedSplitSidebarPosition?: 'left' | 'right'; /** * Controls the type/layout of the modal. * - 'extendedSplit': Modal with split layout (footer inside left content) */ modalType: 'extendedSplit'; /** * Controls the size of the modal. * For extendedSplit type, only 'wide' is allowed. * @default 'wide' */ size?: 'wide'; } interface OtherModalProps extends CommonModalProps { /** * Content for the left side in extendedSplit layout. * Cannot be provided when modalType is not 'extendedSplit'. */ extendedSplitLeftSideContent?: never; /** * Content for the right side in extendedSplit layout. * Cannot be provided when modalType is not 'extendedSplit'. */ extendedSplitRightSideContent?: never; /** * 此模式下不適用。 */ extendedSplitSidebarPosition?: never; /** * Controls the type/layout of the modal. * - 'standard': Default modal with body container * - 'extended': Modal with left and right content areas * - 'mediaPreview': Modal for media preview * - 'verification': Modal for verification flows * @default 'standard' */ modalType: 'extended' | 'standard' | 'mediaPreview' | 'verification'; /** * Controls the size of the modal. * @default 'regular' */ size?: ModalSize; } type BaseModalProps = ExtendedSplitModalProps | OtherModalProps; type ModalHeaderPropsWithHeader = { /** * Whether to show modal header. */ showModalHeader: true; /** * The title of the modal header (required when showModalHeader is true). */ title: string; }; type ModalHeaderPropsWithoutHeader = { /** * Whether to show modal header. * @default false */ showModalHeader?: false; /** * The title of the modal header. * Cannot be provided when showModalHeader is false. */ title?: never; }; export type ModalFooterCancelProps = Pick; type ModalFooterPropsWithFooter = { /** * Whether to show modal footer. */ showModalFooter: true; /** * The confirm button text of the modal footer (required when showModalFooter is true). */ confirmText: string; } & ModalFooterCancelProps; type ModalFooterPropsWithoutFooter = { /** * Whether to show modal footer. * @default false */ showModalFooter?: false; /** * The confirm button text of the modal footer. * Cannot be provided when showModalFooter is false. */ confirmText?: never; /** * 此模式下不適用。 */ cancelText?: never; /** * 此模式下不適用。 */ showCancelButton?: never; }; export type ModalProps = BaseModalProps & ModalHeaderLayoutProps & ((ModalHeaderPropsWithHeader & ModalFooterPropsWithFooter) | (ModalHeaderPropsWithHeader & ModalFooterPropsWithoutFooter) | (ModalHeaderPropsWithoutHeader & ModalFooterPropsWithFooter) | (ModalHeaderPropsWithoutHeader & ModalFooterPropsWithoutFooter)); /** * 對話框元件,以 Backdrop 遮罩呈現需要使用者互動或確認的浮動視窗。 * * 透過 `showModalHeader` 與 `showModalFooter` 分別啟用標題列與操作列, * `modalStatusType` 可在標題旁顯示狀態圖示(`info`、`success`、`warning`、`error`)。 * `modalType` 支援 `standard`、`extended`、`mediaPreview`、`verification` 及 `extendedSplit` 佈局, * 其中 `extendedSplit` 需同時傳入 `extendedSplitLeftSideContent` 與 `extendedSplitRightSideContent`。 * `size` 可選 `regular`、`large`、`wide` 等尺寸,`fullScreen` 則強制全螢幕顯示。 * * @example * ```tsx * import Modal from '@mezzanine-ui/react/Modal'; * * // 基本對話框(含標題與操作列) * setIsOpen(false)} * showModalHeader * title="確認刪除" * showModalFooter * confirmText="確認" * cancelText="取消" * onConfirm={handleConfirm} * onCancel={() => setIsOpen(false)} * > *

此操作無法復原,確定要刪除嗎?

*
* * // 帶狀態圖示的對話框 * setIsOpen(false)} * showModalHeader * title="操作成功" * showStatusTypeIcon * modalStatusType="success" * showModalFooter * confirmText="關閉" * onConfirm={() => setIsOpen(false)} * /> * ``` * * @see {@link Drawer} 從側邊滑入的抽屜式對話框元件 * @see {@link useModalContainer} 用於自訂 Modal 掛載容器的 Hook */ declare const Modal: import("react").ForwardRefExoticComponent>; export default Modal;