react-smart-fields 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 +105 -7
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ๐งน DynamicFields React Component
|
|
2
2
|
|
|
3
3
|
A flexible, fully-styled dynamic form generator built with **React** and **Tailwind CSS**, supporting custom input types, validation, and class overrides. Ideal for building forms quickly with full control over design and behavior.
|
|
4
4
|
|
|
@@ -6,12 +6,12 @@ A flexible, fully-styled dynamic form generator built with **React** and **Tailw
|
|
|
6
6
|
|
|
7
7
|
## โจ Features
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
* ๐ฆ Supports `text`, `number`, `checkbox`, `radio`, and `select` fields
|
|
10
|
+
* ๐
Fully customizable via Tailwind-compatible className props
|
|
11
|
+
* ๐ง Built-in required field validation
|
|
12
|
+
* ๐งฑ Extensible for advanced usage
|
|
13
|
+
* ๐ Full **dark mode** support
|
|
14
|
+
* ๐ Real-time `onChange` callback with live `formData` and `errors`
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
@@ -84,3 +84,101 @@ function App() {
|
|
|
84
84
|
/>
|
|
85
85
|
);
|
|
86
86
|
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## โ๏ธ Props
|
|
92
|
+
|
|
93
|
+
| Prop | Type | Required | Description |
|
|
94
|
+
| -------------------- | ------------------------------------- | -------- | --------------------------------- |
|
|
95
|
+
| `fields` | `FieldConfig[]` | โ
Yes | List of field definitions |
|
|
96
|
+
| `onChange` | `(data: Record<string, any>) => void` | โ
Yes | Callback on value change |
|
|
97
|
+
| `title` | `string` | โ No | Optional form title |
|
|
98
|
+
| `description` | `string` | โ No | Optional description |
|
|
99
|
+
| `className` | `string` | โ No | Wrapper div styling |
|
|
100
|
+
| `mainFieldClassName` | `string` | โ No | Class for the fields wrapper |
|
|
101
|
+
| `inputClassName` | `string` | โ No | Applies to `text`/`number` inputs |
|
|
102
|
+
| `labelClassName` | `string` | โ No | Applies to all labels |
|
|
103
|
+
| `fieldClassName` | `string` | โ No | Applied to each field wrapper div |
|
|
104
|
+
| `errorClassName` | `string` | โ No | Error message styling |
|
|
105
|
+
| `selectClassName` | `string` | โ No | `select` field styling |
|
|
106
|
+
| `checkboxClassName` | `string` | โ No | Checkbox input styling |
|
|
107
|
+
| `radioClassName` | `string` | โ No | Radio input styling |
|
|
108
|
+
| `optionClassName` | `string` | โ No | Dropdown option styling |
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## ๐ง `FieldConfig` (field definition)
|
|
113
|
+
|
|
114
|
+
Each field object can contain:
|
|
115
|
+
|
|
116
|
+
| Property | Type | Required | Notes |
|
|
117
|
+
| ------------- | --------------------------------------------------------- | --------------------------------- | -------------------------------------- |
|
|
118
|
+
| `name` | `string` | โ
Yes | Unique key |
|
|
119
|
+
| `label` | `string` | โ No | Display label |
|
|
120
|
+
| `type` | `"text"`, `"number"`, `"select"`, `"radio"`, `"checkbox"` | โ
Yes | Field type |
|
|
121
|
+
| `required` | `boolean` | โ No | Show red asterisk and basic validation |
|
|
122
|
+
| `placeholder` | `string` | โ No | Placeholder (for inputs/selects) |
|
|
123
|
+
| `description` | `string` | โ No | Optional helper text |
|
|
124
|
+
| `options` | `{ label: string; value: any; }[]` | Required for `select` and `radio` | Dropdown/Radio values |
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## ๐จ Class Mapping
|
|
129
|
+
|
|
130
|
+
Here's how classes are applied to each section:
|
|
131
|
+
|
|
132
|
+
| Section | Class Prop | Default Tailwind Example |
|
|
133
|
+
| ------------------- | ------------------- | ---------------------------------- |
|
|
134
|
+
| Wrapper div | `className` | `bg-white dark:bg-gray-900` |
|
|
135
|
+
| Label text | `labelClassName` | `text-gray-800 dark:text-gray-200` |
|
|
136
|
+
| Input fields | `inputClassName` | `bg-white dark:bg-gray-800` |
|
|
137
|
+
| Select dropdown | `selectClassName` | `rounded-lg` |
|
|
138
|
+
| Radio buttons | `radioClassName` | `rounded-full` |
|
|
139
|
+
| Checkbox | `checkboxClassName` | `rounded` |
|
|
140
|
+
| Field container div | `fieldClassName` | `w-full` |
|
|
141
|
+
| Dropdown options | `optionClassName` | `hover:bg-gray-100` |
|
|
142
|
+
| Error messages | `errorClassName` | `text-red-500` |
|
|
143
|
+
|
|
144
|
+
You can override all styles with your own Tailwind classes!
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## ๐งช Advanced Usage: Custom Styling Per Field
|
|
149
|
+
|
|
150
|
+
You can add `inputClassName`, `labelClassName`, or `className` inside each field:
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
{
|
|
154
|
+
name: "email",
|
|
155
|
+
label: "Email",
|
|
156
|
+
type: "text",
|
|
157
|
+
inputClassName: "border-purple-500",
|
|
158
|
+
labelClassName: "text-purple-700 font-semibold",
|
|
159
|
+
className: "mb-6",
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## ๐งโ๐ป Author
|
|
166
|
+
|
|
167
|
+
**Name:** Pratik Panchal
|
|
168
|
+
**GitHub:** [@Pratikpanchal25](https://github.com/Pratikpanchal25)
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## ๐ License
|
|
173
|
+
|
|
174
|
+
MIT โ Free to use, modify and distribute.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## ๐ Contributing
|
|
179
|
+
|
|
180
|
+
Pull requests are welcome! If you find bugs, feel free to [open an issue](https://github.com/ShubhamNakum/DynamicFields/issues).
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Keywords: DynamicFields, className merge, field styling, custom CSS, override default styles
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-smart-fields",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "> A flexible, customizable, and developer-friendly component to generate dynamic form fields in React. Supports all HTML inputs, validation, and styling out of the box.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Pratik Panchal",
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "tsc"
|
|
12
12
|
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/Pratikpanchal25/react-smart-fields"
|
|
16
|
+
},
|
|
13
17
|
"dependencies": {
|
|
14
18
|
"csstype": "^3.1.3",
|
|
15
19
|
"js-tokens": "^4.0.0",
|