react-motion-modal 1.1.0 → 1.1.2
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.
- package/README.md +24 -2
- package/dist/index.d.ts +10 -8
- package/dist/index.js +3427 -3809
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -44,7 +44,29 @@ declare module 'react-motion-modal' {
|
|
|
44
44
|
}
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
### 2.
|
|
47
|
+
### 2. Import <ModalProvider />
|
|
48
|
+
|
|
49
|
+
Import <ModalProvider /> to define your modals
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { ModalProvider } from 'react-motion-modal';
|
|
53
|
+
|
|
54
|
+
export const App = () => {
|
|
55
|
+
|
|
56
|
+
return <div>
|
|
57
|
+
{...rest-of-your-app}
|
|
58
|
+
|
|
59
|
+
<ModalProvider
|
|
60
|
+
modals={{
|
|
61
|
+
AlertModal,
|
|
62
|
+
ConfirmModal,
|
|
63
|
+
}}
|
|
64
|
+
/>
|
|
65
|
+
<div/>
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 3. Open modal anywhere
|
|
48
70
|
|
|
49
71
|
```tsx
|
|
50
72
|
import { useModal } from 'react-motion-modal';
|
|
@@ -56,7 +78,7 @@ openModal('ConfirmModal', {1
|
|
|
56
78
|
});
|
|
57
79
|
```
|
|
58
80
|
|
|
59
|
-
###
|
|
81
|
+
### 4. Use `closeModal` inside your modal component
|
|
60
82
|
|
|
61
83
|
```tsx
|
|
62
84
|
const ConfirmModal = ({ title, closeModal }: ModalDefinition<'ConfirmModal'>) => (
|
package/dist/index.d.ts
CHANGED
|
@@ -4,13 +4,13 @@ import { StoreApi } from 'zustand/vanilla';
|
|
|
4
4
|
import { TargetAndTransition } from 'motion';
|
|
5
5
|
import { UseBoundStore } from 'zustand/react';
|
|
6
6
|
|
|
7
|
-
declare type ActiveModal = {
|
|
7
|
+
export declare type ActiveModal = {
|
|
8
8
|
id: string;
|
|
9
9
|
name: ModalName;
|
|
10
10
|
params?: Params<ModalName>;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
declare type BaseModalParams = {
|
|
13
|
+
export declare type BaseModalParams = {
|
|
14
14
|
/**
|
|
15
15
|
* Function to close the modal
|
|
16
16
|
*/
|
|
@@ -50,30 +50,32 @@ declare type BaseModalParams = {
|
|
|
50
50
|
};
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
declare type ModalAction = {
|
|
53
|
+
export declare type ModalAction = {
|
|
54
54
|
closeModal: (name?: ModalName) => void;
|
|
55
55
|
closeAllModal: () => void;
|
|
56
56
|
openModal: <T extends ModalName>(name: T, params?: Omit<Params<T>, 'closeModal'>) => void;
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
declare type ModalComponent<T = any> = (props: T) => ReactElement;
|
|
59
|
+
export declare type ModalComponent<T = any> = (props: T) => ReactElement;
|
|
60
60
|
|
|
61
|
-
declare type ModalConfig = {
|
|
61
|
+
export declare type ModalConfig = {
|
|
62
62
|
[K in ModalName]: ModalComponent<Params<K>>;
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
export declare interface ModalDefinition {
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
declare type ModalName = keyof ModalDefinition;
|
|
68
|
+
export declare type ModalName = keyof ModalDefinition;
|
|
69
|
+
|
|
70
|
+
export declare type ModalParams<T extends ModalName> = Omit<Params<T>, 'animate' | 'body' | 'container' | 'onClose'>;
|
|
69
71
|
|
|
70
72
|
export declare const ModalProvider: ({ modals, initialParams }: Props) => ReactPortal | null;
|
|
71
73
|
|
|
72
|
-
declare type ModalState = {
|
|
74
|
+
export declare type ModalState = {
|
|
73
75
|
activeModals: ActiveModal[];
|
|
74
76
|
};
|
|
75
77
|
|
|
76
|
-
declare type Params<T extends ModalName> = ModalDefinition[T] & BaseModalParams;
|
|
78
|
+
export declare type Params<T extends ModalName> = ModalDefinition[T] & BaseModalParams;
|
|
77
79
|
|
|
78
80
|
declare type Props = {
|
|
79
81
|
modals: ModalConfig;
|