react-motion-modal 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,84 @@
1
+ import { ReactElement } from 'react';
2
+ import { ReactPortal } from 'react';
3
+ import { StoreApi } from 'zustand/vanilla';
4
+ import { TargetAndTransition } from 'motion/react';
5
+ import { UseBoundStore } from 'zustand/react';
6
+
7
+ declare type Action = {
8
+ closeModal: (name?: ModalName) => void;
9
+ openModal: <T extends ModalName>(name: T, params?: Omit<ModalParams<T>, 'closeModal'>) => void;
10
+ };
11
+
12
+ declare type ActiveModal = {
13
+ id: string;
14
+ name: ModalName;
15
+ params?: ModalParams<ModalName>;
16
+ };
17
+
18
+ export declare type BaseModalParams = {
19
+ /**
20
+ * Function to close the modal. Automatically injected.
21
+ */
22
+ closeModal: () => void;
23
+ /**
24
+ * Callback triggered when the modal is closed.
25
+ */
26
+ onClose?: () => void;
27
+ /**
28
+ * Whether to close the modal when clicking outside of it.
29
+ */
30
+ closeOnClickOutside?: boolean;
31
+ /**
32
+ * Whether to close the modal when pressing the Escape key.
33
+ */
34
+ closeOnPressEsc?: boolean;
35
+ /**
36
+ * Styling options for the outer container of the modal.
37
+ */
38
+ container?: {
39
+ className?: string;
40
+ override?: boolean;
41
+ };
42
+ /**
43
+ * Styling options for the modal content/body.
44
+ */
45
+ body?: {
46
+ className?: string;
47
+ override?: boolean;
48
+ };
49
+ /**
50
+ * Framer Motion animation settings for entrance and exit.
51
+ */
52
+ animate?: {
53
+ exit?: TargetAndTransition;
54
+ animate?: TargetAndTransition;
55
+ };
56
+ };
57
+
58
+ declare type ModalComponent<T = any> = (props: T) => ReactElement;
59
+
60
+ export declare type ModalConfig = {
61
+ [K in ModalName]: ModalComponent<ModalParams<K>>;
62
+ };
63
+
64
+ export declare type ModalName = keyof ModalStackParams;
65
+
66
+ export declare type ModalParams<T extends ModalName> = ModalStackParams[T] & BaseModalParams;
67
+
68
+ export declare const ModalProvider: ({ modals, initialParams }: Props) => ReactPortal | null;
69
+
70
+ export declare interface ModalStackParams {
71
+ }
72
+
73
+ declare type Props = {
74
+ modals: ModalConfig;
75
+ initialParams?: Partial<BaseModalParams>;
76
+ };
77
+
78
+ declare type State = {
79
+ activeModals: ActiveModal[];
80
+ };
81
+
82
+ export declare const useModal: UseBoundStore<StoreApi<State & Action>>;
83
+
84
+ export { }