react-motion-modal 1.2.1 → 1.2.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/CHANGELOG.md CHANGED
@@ -15,6 +15,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
15
15
 
16
16
  ### Removed
17
17
 
18
+ ### Fixed
19
+
20
+ ## [1.2.2] - 2025-11-21
21
+
22
+ ### Added
23
+ - Enhanced TypeScript documentation with comprehensive JSDoc comments
24
+ - More detailed examples for modal animations and positioning
25
+ - Better documentation for blur effect parameter
26
+ - Comprehensive examples for ModalComponent and ModalConfig types
27
+
28
+ ### Changed
29
+ - Improved type documentation with real-world usage examples
30
+ - Enhanced Framer Motion animation configuration documentation
31
+ - Better documentation for modal positioning options
32
+
18
33
  ### Fixed
19
34
  - Type definitions now properly import required dependencies
20
35
  - Documentation examples updated to reflect current API
package/dist/index.d.ts CHANGED
@@ -79,27 +79,109 @@ declare type BaseModalParams = {
79
79
  /**
80
80
  * Framer Motion animation settings for modal entrance and exit animations.
81
81
  * These settings define how the modal appears and disappears.
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * // Simple fade animation
86
+ * animate: {
87
+ * animate: { opacity: 1 },
88
+ * exit: { opacity: 0 }
89
+ * }
90
+ *
91
+ * // Scale and fade animation
92
+ * animate: {
93
+ * animate: {
94
+ * opacity: 1,
95
+ * scale: 1,
96
+ * transition: { duration: 0.3, ease: "easeOut" }
97
+ * },
98
+ * exit: {
99
+ * opacity: 0,
100
+ * scale: 0.9,
101
+ * transition: { duration: 0.2, ease: "easeIn" }
102
+ * }
103
+ * }
104
+ *
105
+ * // Slide up animation
106
+ * animate: {
107
+ * animate: {
108
+ * opacity: 1,
109
+ * y: 0,
110
+ * transition: { type: "spring", stiffness: 300, damping: 30 }
111
+ * },
112
+ * exit: {
113
+ * opacity: 0,
114
+ * y: 50,
115
+ * transition: { duration: 0.25 }
116
+ * }
117
+ * }
118
+ * ```
82
119
  */
83
120
  animate?: {
84
121
  /**
85
122
  * Animation properties for the exit transition (when modal is closing).
86
123
  * Accepts any valid Framer Motion TargetAndTransition properties.
87
- * Example: { opacity: 0, scale: 0.8, transition: { duration: 0.2 } }
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * // Simple fade out
128
+ * exit: { opacity: 0 }
129
+ *
130
+ * // Scale down and fade out
131
+ * exit: {
132
+ * opacity: 0,
133
+ * scale: 0.8,
134
+ * transition: { duration: 0.2 }
135
+ * }
136
+ * ```
88
137
  */
89
138
  exit?: TargetAndTransition;
90
139
  /**
91
140
  * Animation properties for the animate state (when modal is visible).
92
141
  * Accepts any valid Framer Motion TargetAndTransition properties.
93
- * Example: { opacity: 1, scale: 1, transition: { duration: 0.3 } }
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * // Simple fade in
146
+ * animate: { opacity: 1 }
147
+ *
148
+ * // Scale up and fade in with spring
149
+ * animate: {
150
+ * opacity: 1,
151
+ * scale: 1,
152
+ * transition: { type: "spring", stiffness: 400 }
153
+ * }
154
+ * ```
94
155
  */
95
156
  animate?: TargetAndTransition;
96
157
  };
97
158
  /**
98
159
  * Optional positioning string for modal placement.
99
160
  * This can be used to override default modal positioning behavior.
161
+ *
162
+ * @example
163
+ * ```typescript
100
164
  * import { MODAL_POSITIONS } from 'react-motion-modal';
165
+ *
166
+ * // Available positions
167
+ * MODAL_POSITIONS.TOP_LEFT // 'top-left'
168
+ * MODAL_POSITIONS.TOP_CENTER // 'top-center'
169
+ * MODAL_POSITIONS.TOP_RIGHT // 'top-right'
170
+ * MODAL_POSITIONS.CENTER_LEFT // 'center-left'
171
+ * MODAL_POSITIONS.CENTER // 'center' (default)
172
+ * MODAL_POSITIONS.CENTER_RIGHT // 'center-right'
173
+ * MODAL_POSITIONS.BOTTOM_LEFT // 'bottom-left'
174
+ * MODAL_POSITIONS.BOTTOM_CENTER// 'bottom-center'
175
+ * MODAL_POSITIONS.BOTTOM_RIGHT // 'bottom-right'
176
+ * ```
101
177
  */
102
178
  position?: string;
179
+ /**
180
+ * Enables backdrop blur effect when modal is open.
181
+ * When set to true, the background content will be blurred.
182
+ * @default false
183
+ */
184
+ blur?: boolean;
103
185
  };
104
186
 
105
187
  export declare const MODAL_POSITIONS: {
@@ -162,8 +244,44 @@ declare type ModalAction = {
162
244
  *
163
245
  * @example
164
246
  * ```typescript
247
+ * // Basic modal component
165
248
  * const AlertModal: ModalComponent<{ message: string; closeModal: () => void }> =
166
- * ({ message, closeModal }) => <div>{message}<button onClick={closeModal}>Close</button></div>;
249
+ * ({ message, closeModal }) => (
250
+ * <div className="bg-white p-6 rounded-lg shadow-lg">
251
+ * <p>{message}</p>
252
+ * <button onClick={closeModal}>Close</button>
253
+ * </div>
254
+ * );
255
+ *
256
+ * // Modal component with advanced features
257
+ * const ConfirmModal: ModalComponent<{
258
+ * message: string;
259
+ * onConfirm: () => void;
260
+ * closeModal: () => void;
261
+ * closeOnClickOutside?: boolean;
262
+ * }> = ({ message, onConfirm, closeModal, closeOnClickOutside = true }) => (
263
+ * <div className="bg-white p-6 rounded-lg shadow-lg max-w-sm mx-auto">
264
+ * <h3 className="text-lg font-semibold mb-4">Confirm Action</h3>
265
+ * <p className="mb-6">{message}</p>
266
+ * <div className="flex justify-end gap-3">
267
+ * <button
268
+ * onClick={closeModal}
269
+ * className="px-4 py-2 text-gray-600 hover:text-gray-800"
270
+ * >
271
+ * Cancel
272
+ * </button>
273
+ * <button
274
+ * onClick={() => {
275
+ * onConfirm();
276
+ * closeModal();
277
+ * }}
278
+ * className="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600"
279
+ * >
280
+ * Confirm
281
+ * </button>
282
+ * </div>
283
+ * </div>
284
+ * );
167
285
  * ```
168
286
  */
169
287
  declare type ModalComponent<T = any> = (props: T) => ReactElement;
@@ -174,11 +292,44 @@ declare type ModalComponent<T = any> = (props: T) => ReactElement;
174
292
  *
175
293
  * @example
176
294
  * ```typescript
295
+ * // First, define your modal parameters
296
+ * type ModalDefinition = {
297
+ * alert: { message: string; type?: 'info' | 'warning' | 'error' };
298
+ * confirm: { message: string; onConfirm: () => void; onCancel?: () => void };
299
+ * form: { title: string; fields: FormField[]; onSubmit: (data: any) => void };
300
+ * };
301
+ *
302
+ * // Then create your modal components
303
+ * const AlertModal: ModalComponent<Params<'alert'>> = ({ message, type, closeModal }) => (
304
+ * <div className={`alert alert-${type}`}>
305
+ * {message}
306
+ * <button onClick={closeModal}>Dismiss</button>
307
+ * </div>
308
+ * );
309
+ *
310
+ * const ConfirmModal: ModalComponent<Params<'confirm'>> = ({
311
+ * message, onConfirm, onCancel, closeModal
312
+ * }) => (
313
+ * <div className="confirm-dialog">
314
+ * <p>{message}</p>
315
+ * <div className="actions">
316
+ * <button onClick={() => { onCancel?.(); closeModal(); }}>No</button>
317
+ * <button onClick={() => { onConfirm(); closeModal(); }}>Yes</button>
318
+ * </div>
319
+ * </div>
320
+ * );
321
+ *
322
+ * // Finally, create the configuration
177
323
  * const modalConfig: ModalConfig = {
178
324
  * alert: AlertModal,
179
325
  * confirm: ConfirmModal,
180
- * // ... other modals
326
+ * form: FormModal,
181
327
  * };
328
+ *
329
+ * // Use with ModalProvider
330
+ * <ModalProvider config={modalConfig}>
331
+ * <App />
332
+ * </ModalProvider>
182
333
  * ```
183
334
  */
184
335
  declare type ModalConfig = {