UNPKG

@react-crates/modal

Version:

리액트 모달을 쉽게 등록하고 사용가능한 라이브러리입니다.

77 lines (76 loc) 4.09 kB
import { ReactElement } from "react"; import { Modal } from "./modal"; import { ModalListener, ModalComponentSeed, ModalSeed, ModalRemovedName, ModalDispatchOptions, CloseModalProps, ModalPositionMap, ModalPositionTable, ModalTransition, ModalManagerOptionsProps, ModalTransitionProps, ModalPositionStyle, ModalTransitionOptions, ModalTransactionState, ModalManagerState, ModalLifecycleState, ModalComponent, ModalCallback, ModalEditOptions, ModalManagerInterface, ModalConfirmType, PositionStyle } from "../types"; export declare class ModalManager<T extends ModalPositionTable = ModalPositionTable> implements ModalManagerInterface { private currentId; private transactionCount; private transactionState; private modalStack; private listeners; private modalComponentSeedMap; private modalPositionMap; private modalTransition; private modalDuration; private stateResponsiveComponent; private breakPoint; private originZindex; private zIndex; private modalManagerState; constructor(baseModalComponentSeed?: ModalComponentSeed[], options?: ModalManagerOptionsProps<T>); private bind; initModalOptions(optionsProps: ModalManagerOptionsProps<T>): void; private setModalManagerState; private setModalComponentSeedMap; setZIndex(zIndex?: number): void; resetZIndex(): void; setModalComponent(componentSeed: ModalComponentSeed | ModalComponentSeed[]): this; removeModalComponent(name: string | string[]): this; getModalComponentSeed(name: string): ModalComponentSeed<any, string> | undefined; private createModalCloser; setModalTransition(transitionProps?: ModalTransitionProps): this; setModalDuration(duration?: number): this; setModalPosition(modalPositionTable: ModalPositionTable): this; setModalOptions<P extends ModalPositionTable = ModalPositionTable>(optionsProps: ModalManagerOptionsProps<T & P>): void; getModalTransition(duration?: number, options?: ModalTransitionOptions): ModalTransition; getModalPosition(key?: string): ModalPositionStyle; getModalPositionMap(): ModalPositionMap; getCurrentModalPosition(positionState: ModalLifecycleState, position?: string): [PositionStyle, string]; setTransactionState(transactionState: ModalTransactionState): number; startTransaction(): number; endTransaction(): number; getTransactionState(): ModalTransactionState; executeAsync<F = any, P = any>(asyncCallback: (props: P) => Promise<F>, asyncCallbackProps: P): Promise<F>; executeWithTransaction<T = any>(callback: (props: T) => Promise<boolean>, callbackProps: T): Promise<boolean>; subscribe(listener: ModalListener): this; unsubscribe(listener: ModalListener): void; notify(): void; getState(): ModalManagerState; getModalStack(): Modal[]; private createModal; filterModalByName(name: string | string[]): this; pushModal(modalSeed: ModalSeed<ModalDispatchOptions> | ModalSeed<ModalDispatchOptions>[]): void; popModal(removedName?: ModalRemovedName): this; clearModalStack(): this; getCurrentModalId(): number; /** * action이 실행되지 않으면 false * 성공적으로 실행되면 true; * @param targetModalId * @param confirm * @returns */ action(targetModalId?: number, confirm?: ModalConfirmType): Promise<boolean>; /** * @param name * @param options * @returns 현재 등록된 모달의 id를 반환합니다. 만약 등록되지 않은 모달이라면 0을 반환합니다. */ open<P = any>(name: string | ModalComponent | ReactElement, action?: Omit<ModalDispatchOptions<P, Extract<keyof T, string>>, "required"> | ModalCallback | string): number; /** * @param closeTarget * @returns 마지막으로 등록된 모달의 id를 반환합니다. 만약 등록된 모달이 없다면 0을 반환합니다. */ remove(closeTarget?: CloseModalProps): number; edit(id: number, options: ModalEditOptions<Extract<keyof T, string>>): boolean; setBreakPoint(breakPoint: number): void; }