A powerful React library for rapidly generating Create, Read, Update, and Delete (CRUD) pages with minimal code. Built with TypeScript and featuring a comprehensive set of form components for modern web applications.
- 🚀 Rapid Development: Create full CRUD pages with just configuration objects
- 🎨 Rich Components: Input, Select (3 variants), TextArea, Toggle, FileUpload, and more
- 📱 Responsive Design: Mobile-first approach with beautiful UI out of the box
- 🔒 TypeScript Support: Full type safety and excellent developer experience
- 🎯 Form Validation: Built-in validation with regex support and custom error messages
- 📁 File Handling: Drag-and-drop file uploads with image preview
- 📝 Rich Text Editor: Integrated Quill editor for rich content
- 🏗️ Flexible Architecture: Support for nested fields, arrays, and complex data structures
- 🎭 Customizable: Extensive theming and styling options
# Using npm npm install mich-pages # Using yarn yarn add mich-pages # Using pnpm pnpm add mich-pagesimport React from 'react'; import { NewPage } from 'mich-pages'; import { User, Phone } from 'lucide-react'; const pageConfig = { type: "CREATE", name: "User Profile", icon: <User />, id: "user-form", categories: [ { key: "personal", name: "Personal Information" } ], headings: [ { key: "name", name: "Full Name", category: "personal", placeholder: "Enter your full name", formType: "text", prefixIcons: <User />, required: true }, { key: "phone", name: "Phone Number", category: "personal", placeholder: "Enter phone number", formType: "text", prefixIcons: <Phone /> } ], data: {}, showButton: { createButton: true }, create: { create: async (data) => { console.log("Form submitted:", data); return "isSuccess"; }, createStatus: "none" } }; export function UserForm() { return <NewPage data={pageConfig} />; }| Component | Description |
|---|---|
NewPage | General purpose page component for all CRUD operations |
NewCreatePage | Specialized component for creation forms |
NewViewPage | Read-only view component |
NewSubmitPage | Form submission component |
NewPageUi | Base UI component for custom implementations |
| Component | Description |
|---|---|
Input | Enhanced input with validation and error handling |
SelectInput | Standard dropdown select |
SelectInput2 | Card-style selection interface |
SelectInput3 | Advanced select with search functionality |
FileInput | Drag-and-drop file upload with preview |
PresetQuillEditor | Rich text editor |
StyledButton | Customizable button component |
| Type | Description | Use Case |
|---|---|---|
text | Standard text input | Names, titles, descriptions |
email | Email input with validation | Email addresses |
password | Password input with toggle | Secure text entry |
number | Numeric input | Ages, quantities, prices |
date | Date picker | Birthdays, deadlines |
select | Dropdown selection | Categories, statuses |
select2 | Card-based selection | Visual choices |
select3 | Searchable dropdown | Large option lists |
toggle | Switch/checkbox | Boolean values |
textarea1 | Single-line text area | Short descriptions |
textarea2 | Rich text editor | Long content |
file | File upload | Documents, images |
array | Repeating field groups | Multiple entries |
obj | Nested object fields | Complex data structures |
interface PageI { type: "CREATE" | "UPDATE" | "VIEW"; name: string; icon: ReactNode; id: string; style?: { primary?: string; secondary?: string; tertiary?: string; }; categories: PageCategoriesI[]; headings: PageHeadingI[]; data: Record<string, any>; showButton?: { createButton?: boolean; updateButton?: boolean; deleteButton?: boolean; }; create?: CreateConfig; update?: UpdateConfig; delete?: DeleteConfig; extraInfo?: string; showHeading?: boolean; }const advancedField = { key: "email", name: "Email Address", category: "contact", placeholder: "Enter your email", formType: "email", required: true, prefixIcons: <Mail />, suffixIcons: <Check />, helper: "We'll never share your email", useRegex: [ { regex: /^[^\s@]+@[^\s@]+\.[^\s@]+$/, message: "Please enter a valid email address" } ] };import { useState } from "react"; import { NewPage } from "mich-pages"; import { Lock, Eye, EyeOff } from "lucide-react"; export function SecureForm() { const [showPassword, setShowPassword] = useState(false); const passwordField = { key: "password", name: "Password", category: "security", placeholder: "Create a strong password", required: true, formType: showPassword ? "text" : "password", prefixIcons: <Lock />, suffixIcons: ( <button type="button" onClick={() => setShowPassword(!showPassword)} className="p-1 hover:bg-gray-100 rounded" > {showPassword ? <EyeOff size={16} /> : <Eye size={16} />} </button> ), useRegex: [ { regex: /^.{8,}$/, message: "Password must be at least 8 characters long" }, { regex: /[A-Z]/, message: "Password must contain at least one uppercase letter" }, { regex: /[a-z]/, message: "Password must contain at least one lowercase letter" }, { regex: /\d/, message: "Password must contain at least one number" }, { regex: /[!@#$%^&*(),.?":{}|<>]/, message: "Password must contain at least one special character" } ] }; // ... rest of configuration }const teamMembersField = { key: "teamMembers", name: "Team Members", category: "team", formType: "array", child: [ { key: "name", name: "Member Name", category: "team", formType: "text", required: true, placeholder: "Enter member name" }, { key: "role", name: "Role", category: "team", formType: "select", required: true, keyValue: { developer: { value: "developer", description: "Developer" }, designer: { value: "designer", description: "Designer" }, manager: { value: "manager", description: "Manager" } } }, { key: "email", name: "Email", category: "team", formType: "email", placeholder: "member@company.com" } ] };const profilePictureField = { key: "profilePicture", name: "Profile Picture", category: "personal", formType: "image", placeholder: "Upload your profile picture", accept: "image/*", maxSize: 5000000, // 5MB helper: "Supported formats: JPG, PNG, GIF (max 5MB)" };Customize the appearance of your forms:
const customTheme = { style: { primary: "#3b82f6", // Primary color for buttons and accents secondary: "#6b7280", // Secondary color for borders and labels tertiary: "#1e293b" // Tertiary color for backgrounds } };interface NewPageProps { data: PageI; }interface InputProps { label: string; inputType: InputTypeI; helper?: string; showHelper?: boolean; className?: string; }interface SelectInput3Props { label: string; kv: Record<string, { value: string; description: string }>; placeholder?: string; inputType: SelectInputTypeI; helper?: string; showHelper?: boolean; }Q: Can I use custom validation rules? A: Yes! Use the useRegex property with custom regex patterns and error messages.
Q: How do I handle file uploads? A: Use the FileInput component or set formType: "file" in your field configuration.
Q: Can I nest objects and arrays? A: Absolutely! Use formType: "obj" for nested objects and formType: "array" for arrays.
Q: Is server-side rendering supported? A: Yes, the library is compatible with Next.js and other SSR frameworks.
# Clone the repository git clone https://github.com/derekzyl/mich-pages.git # Install dependencies npm install # Run development server npm run dev # Build the library npm run build # Run tests npm test- Initial release with full CRUD functionality
- TypeScript support
- Comprehensive form validation
- File upload capabilities
- Rich text editor integration
- create desktop page
- update desktop page
- view desktop page
- create mobile page
- update mobile page
- view mobile page
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with React
- Icons by Lucide React
- Rich text editing powered by Quill
- 📧 Email: derekzyl@gmail.com
- 🐛 Issues: GitHub Issues
- 📖 Documentation: GitHub Repository
- 💬 Discussions: GitHub Discussions
Made with ❤️ by Derek Og