shadcn-zod-formkit 1.0.0
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 +99 -0
- package/dist/index.cjs +3769 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +377 -0
- package/dist/index.d.ts +377 -0
- package/dist/index.mjs +3637 -0
- package/dist/index.mjs.map +1 -0
- package/license.md +9 -0
- package/package.json +94 -0
package/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
⚡️ # React Dynamic Form Maker
|
|
2
|
+
|
|
3
|
+
⚡️ **Next.js & Client Components**
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
📦 A React library for creating **dynamic forms** with **Zod validations**, supporting multiple input types: text, number, email, switch, color, date, select, file, and OTP.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 📌 Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Using npm
|
|
15
|
+
npm install @nativolink/react-form-maker-lib
|
|
16
|
+
|
|
17
|
+
# Using yarn
|
|
18
|
+
yarn add @nativolink/react-form-maker-lib
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Add Shadcn
|
|
22
|
+
```bash
|
|
23
|
+
# Add Shadcn
|
|
24
|
+
npx shadcn@latest init
|
|
25
|
+
```
|
|
26
|
+
You need installa shadcn basic components
|
|
27
|
+
```bash
|
|
28
|
+
# Add Shadcn Basics
|
|
29
|
+
npx shadcn@latest add accordion alert badge button calendar card checkbox dialog popover form input label select sonner tooltip switch textarea input-otp collapsible
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## 🛠️ Basic Usage
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
'use client'
|
|
38
|
+
|
|
39
|
+
import {
|
|
40
|
+
DynamicForm,
|
|
41
|
+
FieldProps,
|
|
42
|
+
InputTypes,
|
|
43
|
+
TextInputType
|
|
44
|
+
} from "@nativolink/react-form-maker-lib";
|
|
45
|
+
|
|
46
|
+
export default function Home() {
|
|
47
|
+
const record= {
|
|
48
|
+
username: "John Doe ",
|
|
49
|
+
email: "johndoe@example.com",
|
|
50
|
+
isActive: true,
|
|
51
|
+
favoriteColor: undefined,
|
|
52
|
+
age: 25,
|
|
53
|
+
role: "editor",
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<DynamicForm
|
|
58
|
+
fields={mockFields}
|
|
59
|
+
record={record}
|
|
60
|
+
onSubmit={(data) => console.log("📤 Resultado final:", data)}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const mockFields: Array<FieldProps |FieldProps[]> = [
|
|
66
|
+
// 🧍♂️ Campo requerido simple
|
|
67
|
+
{
|
|
68
|
+
name: "username",
|
|
69
|
+
label: "Nombre de usuario",
|
|
70
|
+
inputType: InputTypes.TEXT,
|
|
71
|
+
required: true,
|
|
72
|
+
// ZodTypeAny: z
|
|
73
|
+
// .string()
|
|
74
|
+
// .min(3)
|
|
75
|
+
// .max(20),
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
// // 📧 Campo de correo con validación personalizada (ZodTypeAny)
|
|
79
|
+
{
|
|
80
|
+
name: "email",
|
|
81
|
+
label: "Correo electrónico",
|
|
82
|
+
inputType: InputTypes.TEXT,
|
|
83
|
+
required: false,
|
|
84
|
+
},
|
|
85
|
+
]
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
## ✅ Features
|
|
90
|
+
- Fully dynamic fields array support.
|
|
91
|
+
- Multiple input types (text, email, number, color, date, select, switch, file, OTP).
|
|
92
|
+
- Zod validation integration for robust form validation.
|
|
93
|
+
- Supports default values via record prop.
|
|
94
|
+
- Works seamlessly with React 18+ and TypeScript.
|
|
95
|
+
|
|
96
|
+
## 💡 Tips
|
|
97
|
+
- Use peerDependencies for React to avoid version conflicts.
|
|
98
|
+
- Wrap your forms inside a "use client" component if using Next.js App Router.
|
|
99
|
+
- Combine multiple FieldProps in arrays for grouped fields (like age + color).
|