### Development Setup Commands
Source: https://github.com/chappy202/modal-manager/blob/master/CONTRIBUTING.md
Commands to set up the development environment for the Modal State Manager project, including installing dependencies and starting the development server.
```bash
pnpm install
pnpm dev
```
--------------------------------
### Installation
Source: https://github.com/chappy202/modal-manager/blob/master/README.md
Instructions for installing the modal-manager package using npm, yarn, or pnpm.
```bash
npm install modal-manager
# or
yarn add modal-manager
# or
pnpm add modal-manager
```
--------------------------------
### Conventional Commit Examples
Source: https://github.com/chappy202/modal-manager/blob/master/CONTRIBUTING.md
Examples of commit messages following the conventional commit format, used for automated versioning and changelog generation.
```bash
git commit -m "feat: add new transition animation"
git commit -m "fix: resolve issue with back navigation"
git commit -m "docs: update API documentation"
```
--------------------------------
### Material UI Modal Integration
Source: https://github.com/chappy202/modal-manager/blob/master/README.md
Shows how to integrate the modal-manager with Material UI components. This example demonstrates using Material UI's `Dialog`, `DialogTitle`, `DialogContent`, and `DialogActions` to build a modal with navigation controls like 'Back', 'Next', and 'Finish'.
```tsx
import { useModal } from 'modal-manager';
import { Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';
function MaterialUIModal() {
const { isOpen, open, close, currentStep, next, prev, isFirst, isLast } = useModal({
id: 'mui-modal',
steps: [{ id: 'step1' }, { id: 'step2' }]
});
return (
<>
>
);
}
```
--------------------------------
### Shadcn/UI Modal Integration
Source: https://github.com/chappy202/modal-manager/blob/master/README.md
Demonstrates how to integrate the modal-manager with Shadcn/UI components to create a multi-step modal experience. It shows how to open, close, and navigate between steps using the `useModal` hook.
```tsx
import { useModal } from 'modal-manager';
import {
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
DialogFooter,
Button
} from '@/components/ui';
function ShadcnModal() {
const { isOpen, open, close, currentStep, next, prev, isFirst, isLast } = useModal({
id: 'shadcn-modal',
steps: [{ id: 'step1' }, { id: 'step2' }]
});
return (
<>
>
);
}
```
--------------------------------
### Modal Manager API Reference
Source: https://github.com/chappy202/modal-manager/blob/master/README.md
Provides a detailed reference for the `useModal` hook, outlining its returned state variables and action functions, as well as the configuration options for initializing the hook.
```APIDOC
useModal:
// Initialization Options:
id: string - Unique identifier for the modal.
initialData?: object - Initial data for the modal (optional).
steps?: array - Array of step objects (optional).
// Returned State:
isOpen: boolean - Whether the modal is open.
currentStep: string | null - ID of the current step.
currentStepIndex: number - Index of the current step.
totalSteps: number - Total number of steps.
data: Record - Current modal data.
isFirst: boolean - Whether the current step is the first step.
isLast: boolean - Whether the current step is the last step.
// Returned Actions:
open: (data?: any) => void - Opens the modal with optional initial data.
close: () => void - Closes the modal.
next: (data?: any) => void - Goes to the next step with optional data.
prev: () => void - Goes to the previous step.
goTo: (stepId: string, data?: any) => void - Goes to a specific step with optional data.
setData: (data: any) => void - Updates the modal data.
addStep: (modalId: string, stepId: string, data?: any, previousStep?: string) => void - Adds or updates a step.
```
--------------------------------
### API Reference: useModal Hook
Source: https://github.com/chappy202/modal-manager/blob/master/README.md
Details the `useModal` hook, its configuration options, and the returned values for managing modal state and navigation. This includes parameters for modal initialization and the functions/booleans provided for controlling the modal flow.
```APIDOC
useModal(options)
- Initializes and manages the state of a multi-step modal.
- Parameters:
- options (object): Configuration for the modal.
- id (string): A unique identifier for the modal instance.
- steps (Array