import type { ComponentType } from 'react'; import type { Animated, StyleProp, ViewStyle } from 'react-native'; export declare type ModalfyParams = { [key: string]: any; }; export declare type ModalTransitionValue = Animated.AnimatedInterpolation | string | number | undefined | null; export declare type ModalTransitionOptions = (animatedValue: Animated.Value) => { [key: string]: { [key: string]: ModalTransitionValue; }[] | ModalTransitionValue; }; export declare type ModalListener = (eventName: ModalEventName, callback: ModalEventCallback) => ModalEventListener; export declare type ModalEventListeners = Set<{ event: string; handler: ModalEventCallback; }>; export declare type ModalEventName = 'onAnimate' | 'onClose'; export declare type ModalOnAnimateEventCallback = (value?: number) => void; export declare type ModalOnCloseEventCallback = (closingAction: { type: ModalClosingActionName; origin: ModalClosingActionOrigin; }) => void; export declare type ModalClosingActionName = 'closeModal' | 'closeModals' | 'closeAllModals'; export declare type ModalClosingActionOrigin = 'default' | 'fling' | 'backdrop'; export declare type ModalEventCallback = ModalOnAnimateEventCallback | ModalOnCloseEventCallback; export declare type ModalEventListener = { remove: () => boolean; }; export declare type ModalEventAction = 'add'; export declare type ModalEventPayload = { eventName: ModalEventName; handler: ModalEventCallback; }; export declare type ModalStatePendingClosingAction = { modalName?: string; action: 'closeModal'; callback?: () => void; } | { modalName: string; action: 'closeModals'; callback?: () => void; } | { modalName?: never; action: 'closeAllModals'; callback?: () => void; }; export declare type ModalPendingClosingAction = { hash: string; currentModalHash?: string; modalName?: string; action: 'closeModal'; callback?: () => void; } | { hash: string; currentModalHash?: string; modalName: string; action: 'closeModals'; callback?: () => void; } | { hash: string; modalName?: never; currentModalHash?: string; action: 'closeAllModals'; callback?: () => void; }; export interface ModalStackItem
{
name: Exclude {
names: Array [];
defaultOptions: ModalOptions;
openedItems: Set = Exclude , callback?: () => void) => void;
closeModals: (modalName: M, callback?: () => void) => boolean;
getParam: ['hash'], paramName: N, defaultValue?: D) => D extends P[M][N] ? P[M][N] : undefined;
openModal: ;
}
export declare type ModalInternalState = {
currentModal: ModalContextProvider ['currentModal'] | string | null;
stack: ModalContextProvider ['stack'];
};
export interface ModalStateSubscriber {
state: ModalInternalState ;
equalityFn: ModalStateEqualityChecker ;
error: boolean;
stateListener: ModalStateListener ;
unsubscribe: () => boolean;
}
export interface ModalStateSubscription {
unsubscribe: ModalStateSubscriber ['unsubscribe'];
}
export declare type ModalStateListener = (state: ModalInternalState | null, error?: Error) => void;
export declare type ModalStateEqualityChecker = (currentState: ModalInternalState , newState: ModalInternalState ) => boolean;
export declare type ModalState = Omit extends ModalContextProvider {
clearListeners: (hash: string) => void;
eventListeners: ModalEventListeners;
registerListener: (hash: ModalStackItem ['hash'], eventName: ModalEventName, handler: ModalEventCallback) => ModalEventListener;
removeClosingAction: ModalState ['removeClosingAction'];
rootStyle?: StyleProp = Pick extends Omit = Props & {
/**
* Interface of the `modal` prop exposed by the library to regular components.
*
* Note: Modal components used in `createModalStack()`'s config should employ `ModalComponentProp` instead.
*
* @see https://colorfy-software.gitbook.io/react-native-modalfy/guides/typing#modalprop
*/
modal: UsableModalProp ;
};
/**
* Interface of the `modal` prop exposed by the library specifically to modal components.
*
* @argument { unknown } ModalStackParamsList? - Interface of the whole modal stack params.
* @argument { unknown } Props? - Component's props interface.
* @argument { string } ModalName? - Name of the current modal
*
* Note: Components that are not used from `createModalStack()`'s config should employ `ModalProp` instead.
*
* @see https://colorfy-software.gitbook.io/react-native-modalfy/guides/typing#modalcomponentprop
*/
export declare type ModalComponentProp = Props & {
/**
* Interface of the `modal` prop exposed by the library specifically to modal components.
*
* Note: Components that are not used from `createModalStack()`'s config should employ `ModalProp` instead.
*
* @see https://colorfy-software.gitbook.io/react-native-modalfy/guides/typing#modalcomponentprop
*/
modal: UsableModalComponentProp ;
};
/**
* Interface for a React component containing its props and the `modalOptions` static property.
*
* Note: Only use with Hooks modal components (those present in your `createModalStack()`'s config).
* If you're working with a Class modal component, you can directly use `static modalOptions: ModalOptions`.
*
* @argument { unknown } Props? - Component's props interface.
*
* @see https://colorfy-software.gitbook.io/react-native-modalfy/guides/typing#modalcomponentwithoptions
*/
export declare type ModalComponentWithOptions = ComponentType & {
modalOptions?: ModalOptions;
};