formik-form-components 0.2.19 → 0.2.21
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 +130 -551
- package/dist/index.d.ts +2 -0
- package/dist/index.js +36 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,666 +1,245 @@
|
|
|
1
1
|
# Formik Form Components
|
|
2
2
|
|
|
3
|
-
A comprehensive collection of reusable, accessible, and customizable form components built with React
|
|
3
|
+
A comprehensive collection of reusable, accessible, and customizable form components built with **React**, **Material UI**, **Formik**, and **Tiptap**. This library helps you build production-ready forms faster while maintaining consistency with Material Design.
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
7
|
+
---
|
|
8
|
+
|
|
7
9
|
## Features
|
|
8
10
|
|
|
9
11
|
- 🚀 **30+** production-ready form components
|
|
10
12
|
- 🎨 Consistent Material Design styling
|
|
11
|
-
- 🔍 Built-in
|
|
12
|
-
- 📱 Fully responsive
|
|
13
|
-
- 🎯 TypeScript support
|
|
14
|
-
- 🛠️
|
|
15
|
-
- 📅 Date
|
|
16
|
-
- ✨ Rich text
|
|
17
|
-
-
|
|
13
|
+
- 🔍 Built-in validation support (Formik + Yup)
|
|
14
|
+
- 📱 Fully responsive and mobile-friendly
|
|
15
|
+
- 🎯 Full TypeScript support
|
|
16
|
+
- 🛠️ Easy theming with MUI
|
|
17
|
+
- 📅 Date & time pickers with calendar icons
|
|
18
|
+
- ✨ Rich text editor powered by Tiptap
|
|
19
|
+
- 📂 File & image uploads with preview
|
|
18
20
|
- 🌍 Internationalization (i18n) ready
|
|
19
21
|
|
|
22
|
+
---
|
|
23
|
+
|
|
20
24
|
## Table of Contents
|
|
21
25
|
|
|
22
26
|
- [Installation](#installation)
|
|
23
27
|
- [Peer Dependencies](#peer-dependencies)
|
|
24
28
|
- [Getting Started](#getting-started)
|
|
25
29
|
- [Available Components](#available-components)
|
|
26
|
-
- [Component
|
|
30
|
+
- [Component Examples](#component-examples)
|
|
27
31
|
- [Theming](#theming)
|
|
28
32
|
- [TypeScript Support](#typescript-support)
|
|
29
33
|
- [Contributing](#contributing)
|
|
30
34
|
- [License](#license)
|
|
31
35
|
|
|
36
|
+
---
|
|
37
|
+
|
|
32
38
|
## Installation
|
|
33
39
|
|
|
34
40
|
```bash
|
|
35
|
-
#
|
|
36
|
-
npm install formik-form-components
|
|
41
|
+
# npm
|
|
42
|
+
npm install formik-form-components
|
|
37
43
|
|
|
38
|
-
#
|
|
44
|
+
# yarn
|
|
39
45
|
yarn add formik-form-components
|
|
40
46
|
```
|
|
41
47
|
|
|
42
|
-
|
|
48
|
+
---
|
|
43
49
|
|
|
44
|
-
|
|
50
|
+
## Getting Started
|
|
45
51
|
|
|
46
|
-
|
|
47
|
-
- Node.js 16.0.0 or higher
|
|
48
|
-
- React 18.0.0 or higher
|
|
52
|
+
### 1. Wrap your app with `ThemeProvider` (recommended)
|
|
49
53
|
|
|
50
|
-
|
|
54
|
+
```tsx
|
|
55
|
+
import { ThemeProvider, createTheme } from '@mui/material/styles';
|
|
51
56
|
|
|
52
|
-
|
|
53
|
-
# Using npm
|
|
54
|
-
npx create-react-app my-app --template typescript
|
|
55
|
-
cd my-app
|
|
56
|
-
npm install formik-form-components
|
|
57
|
+
const theme = createTheme({});
|
|
57
58
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
export default function App() {
|
|
60
|
+
return (
|
|
61
|
+
<ThemeProvider theme={theme}>
|
|
62
|
+
<YourApp />
|
|
63
|
+
</ThemeProvider>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
62
66
|
```
|
|
63
67
|
|
|
64
|
-
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
### 2. Basic Form Example
|
|
65
71
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
function App() {
|
|
82
|
-
return (
|
|
83
|
-
<ThemeProvider theme={theme}>
|
|
84
|
-
<YourApp />
|
|
85
|
-
</ThemeProvider>
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
3. **Basic Form Example**:
|
|
91
|
-
|
|
92
|
-
```tsx
|
|
93
|
-
import { Formik, Form } from "formik";
|
|
94
|
-
import * as Yup from "yup";
|
|
95
|
-
import {
|
|
96
|
-
AppInputField,
|
|
97
|
-
AppCheckBox,
|
|
98
|
-
AppDatePicker,
|
|
99
|
-
AppRichTextEditor,
|
|
100
|
-
AppRating,
|
|
101
|
-
AppRadioGroup,
|
|
102
|
-
AppMultiSelector,
|
|
103
|
-
} from "formik-form-components";
|
|
104
|
-
import { FormikHelpers } from "formik";
|
|
105
|
-
import { Button, Box } from "@mui/material";
|
|
106
|
-
```
|
|
72
|
+
```tsx
|
|
73
|
+
import { Formik, Form } from 'formik';
|
|
74
|
+
import * as Yup from 'yup';
|
|
75
|
+
import { Button, Box } from '@mui/material';
|
|
76
|
+
import {
|
|
77
|
+
AppInputField,
|
|
78
|
+
AppCheckBox,
|
|
79
|
+
AppDatePicker,
|
|
80
|
+
AppRichTextEditor,
|
|
81
|
+
AppRating,
|
|
82
|
+
AppRadioGroup,
|
|
83
|
+
AppMultiSelector,
|
|
84
|
+
} from 'formik-form-components';
|
|
107
85
|
|
|
108
86
|
const validationSchema = Yup.object({
|
|
109
|
-
name: Yup.string().required(
|
|
110
|
-
email: Yup.string().email(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
terms: Yup.boolean().oneOf([true], "You must accept the terms"),
|
|
87
|
+
name: Yup.string().required('Name is required'),
|
|
88
|
+
email: Yup.string().email('Invalid email').required('Email is required'),
|
|
89
|
+
dob: Yup.date().required('Date of birth is required'),
|
|
90
|
+
bio: Yup.string().required('Bio is required'),
|
|
91
|
+
rating: Yup.number().required('Rating is required'),
|
|
92
|
+
gender: Yup.string().required('Gender is required'),
|
|
93
|
+
interests: Yup.array().min(1, 'Select at least one interest'),
|
|
94
|
+
terms: Yup.boolean().oneOf([true], 'You must accept the terms'),
|
|
118
95
|
});
|
|
119
96
|
|
|
120
97
|
const interests = [
|
|
121
|
-
{ value:
|
|
122
|
-
{ value:
|
|
123
|
-
{ value:
|
|
124
|
-
{ value:
|
|
98
|
+
{ value: 'sports', label: 'Sports' },
|
|
99
|
+
{ value: 'music', label: 'Music' },
|
|
100
|
+
{ value: 'reading', label: 'Reading' },
|
|
101
|
+
{ value: 'travel', label: 'Travel' },
|
|
125
102
|
];
|
|
126
103
|
|
|
127
104
|
const genderOptions = [
|
|
128
|
-
{ value:
|
|
129
|
-
{ value:
|
|
130
|
-
{ value:
|
|
105
|
+
{ value: 'male', label: 'Male' },
|
|
106
|
+
{ value: 'female', label: 'Female' },
|
|
107
|
+
{ value: 'other', label: 'Other' },
|
|
131
108
|
];
|
|
132
109
|
|
|
133
|
-
function
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const handleSubmit = (
|
|
147
|
-
values: {
|
|
148
|
-
[K in keyof typeof initialValues]: (typeof initialValues)[K];
|
|
149
|
-
},
|
|
150
|
-
{ setSubmitting }: FormikHelpers<typeof initialValues>
|
|
151
|
-
) => {
|
|
152
|
-
console.log("Form submitted:", values);
|
|
153
|
-
setSubmitting(false);
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
return (
|
|
157
|
-
<Formik
|
|
158
|
-
initialValues={initialValues}
|
|
110
|
+
export default function ExampleForm() {
|
|
111
|
+
return (
|
|
112
|
+
<Formik
|
|
113
|
+
initialValues={{
|
|
114
|
+
name: '',
|
|
115
|
+
email: '',
|
|
116
|
+
dob: null,
|
|
117
|
+
bio: '',
|
|
118
|
+
rating: 0,
|
|
119
|
+
gender: '',
|
|
120
|
+
interests: [],
|
|
121
|
+
terms: false,
|
|
122
|
+
}}
|
|
159
123
|
validationSchema={validationSchema}
|
|
160
|
-
onSubmit={
|
|
124
|
+
onSubmit={(values) => console.log(values)}
|
|
161
125
|
>
|
|
162
|
-
{({ isSubmitting
|
|
163
|
-
|
|
164
|
-
<
|
|
165
|
-
<
|
|
166
|
-
<AppInputField
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
/>
|
|
173
|
-
|
|
174
|
-
<AppInputField
|
|
175
|
-
name="email"
|
|
176
|
-
label="Email Address"
|
|
177
|
-
type="email"
|
|
178
|
-
placeholder="your.email@example.com"
|
|
179
|
-
fullWidth
|
|
180
|
-
margin="normal"
|
|
181
|
-
/>
|
|
182
|
-
|
|
183
|
-
<AppDatePicker name="birthDate" label="Birth Date" sx={{ mb: 2 }} />
|
|
184
|
-
|
|
185
|
-
<AppRichTextEditor
|
|
186
|
-
name="content"
|
|
187
|
-
label="Content"
|
|
188
|
-
variant="outlined"
|
|
189
|
-
sx={{ mb: 2 }}
|
|
190
|
-
/>
|
|
191
|
-
|
|
192
|
-
<AppRating
|
|
193
|
-
name="rating"
|
|
194
|
-
label="How would you rate your experience?"
|
|
195
|
-
precision={0.5}
|
|
196
|
-
size="large"
|
|
197
|
-
/>
|
|
198
|
-
|
|
199
|
-
<AppRadioGroup
|
|
200
|
-
name="gender"
|
|
201
|
-
label="Gender"
|
|
202
|
-
options={genderOptions}
|
|
203
|
-
row
|
|
204
|
-
/>
|
|
205
|
-
|
|
206
|
-
<AppMultiSelector
|
|
207
|
-
name="interests"
|
|
208
|
-
label="Interests"
|
|
209
|
-
options={interests}
|
|
210
|
-
fullWidth
|
|
211
|
-
/>
|
|
212
|
-
|
|
126
|
+
{({ isSubmitting }) => (
|
|
127
|
+
<Form>
|
|
128
|
+
<Box sx={{ maxWidth: 600, mx: 'auto', p: 3 }}>
|
|
129
|
+
<AppInputField name="name" label="Full Name" />
|
|
130
|
+
<AppInputField name="email" label="Email" type="email" />
|
|
131
|
+
<AppDatePicker name="dob" label="Date of Birth" />
|
|
132
|
+
<AppRichTextEditor name="bio" label="Bio" />
|
|
133
|
+
<AppRating name="rating" label="Rating" />
|
|
134
|
+
<AppRadioGroup name="gender" label="Gender" options={genderOptions} row />
|
|
135
|
+
<AppMultiSelector name="interests" label="Interests" options={interests} />
|
|
213
136
|
<AppCheckBox
|
|
214
137
|
name="terms"
|
|
215
|
-
option={[
|
|
216
|
-
{
|
|
217
|
-
label: "I agree to terms and conditions",
|
|
218
|
-
name: "terms",
|
|
219
|
-
value: "agreed",
|
|
220
|
-
},
|
|
221
|
-
]}
|
|
222
|
-
sx={{ mb: 2 }}
|
|
138
|
+
option={[{ name: 'terms', label: 'I agree to the terms', value: 'yes' }]}
|
|
223
139
|
/>
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
type="submit"
|
|
228
|
-
variant="contained"
|
|
229
|
-
color="primary"
|
|
230
|
-
disabled={isSubmitting}
|
|
231
|
-
>
|
|
232
|
-
{isSubmitting ? "Submitting..." : "Submit"}
|
|
233
|
-
</Button>
|
|
234
|
-
</Box>
|
|
140
|
+
<Button type="submit" variant="contained" disabled={isSubmitting}>
|
|
141
|
+
Submit
|
|
142
|
+
</Button>
|
|
235
143
|
</Box>
|
|
236
144
|
</Form>
|
|
237
145
|
)}
|
|
238
146
|
</Formik>
|
|
239
|
-
|
|
240
|
-
);
|
|
147
|
+
);
|
|
241
148
|
}
|
|
149
|
+
```
|
|
242
150
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
````
|
|
151
|
+
---
|
|
246
152
|
|
|
247
153
|
## Available Components
|
|
248
154
|
|
|
249
155
|
### Form Inputs
|
|
250
156
|
|
|
251
|
-
- `AppInputField`
|
|
252
|
-
- `AppTextArea`
|
|
253
|
-
- `AppCheckBox`
|
|
254
|
-
- `AppSwitch`
|
|
255
|
-
- `AppRadioGroup`
|
|
256
|
-
- `AppRating`
|
|
157
|
+
- `AppInputField`
|
|
158
|
+
- `AppTextArea`
|
|
159
|
+
- `AppCheckBox`
|
|
160
|
+
- `AppSwitch`
|
|
161
|
+
- `AppRadioGroup`
|
|
162
|
+
- `AppRating`
|
|
257
163
|
|
|
258
164
|
### Selection Components
|
|
259
165
|
|
|
260
|
-
- `AppSelect`
|
|
261
|
-
- `AppSearchableSelect`
|
|
262
|
-
- `AppMultiSelector`
|
|
263
|
-
- `AppSearchableMultiSelector`
|
|
264
|
-
- `AppAutocomplete`
|
|
265
|
-
- `AppTagsCreator`
|
|
166
|
+
- `AppSelect`
|
|
167
|
+
- `AppSearchableSelect`
|
|
168
|
+
- `AppMultiSelector`
|
|
169
|
+
- `AppSearchableMultiSelector`
|
|
170
|
+
- `AppAutocomplete`
|
|
171
|
+
- `AppTagsCreator`
|
|
266
172
|
|
|
267
173
|
### Date & Time Pickers
|
|
268
174
|
|
|
269
|
-
- `AppDatePicker`
|
|
270
|
-
- `AppTimePicker`
|
|
271
|
-
- `AppDateAndTimePicker`
|
|
272
|
-
- `AppDateTimePicker`
|
|
175
|
+
- `AppDatePicker`
|
|
176
|
+
- `AppTimePicker`
|
|
177
|
+
- `AppDateAndTimePicker`
|
|
178
|
+
- `AppDateTimePicker`
|
|
273
179
|
|
|
274
180
|
### File Handling
|
|
275
181
|
|
|
276
|
-
- `AppUploadFile`
|
|
277
|
-
- `AppSimpleUploadFile`
|
|
278
|
-
- `
|
|
279
|
-
|
|
280
|
-
### Rich Content
|
|
281
|
-
|
|
282
|
-
- `AppRichTextEditor` - Feature-rich WYSIWYG editor with Tiptap
|
|
283
|
-
- `RichTextEditor` - Core rich text editor component
|
|
284
|
-
|
|
285
|
-
### Advanced
|
|
286
|
-
|
|
287
|
-
- `AppPhoneNoInput` - International phone number input
|
|
288
|
-
- `AppFormErrorMessage` - Consistent error message display
|
|
289
|
-
- `SubmitButton` - Form submission button with loading state
|
|
290
|
-
|
|
291
|
-
## Component Documentation
|
|
292
|
-
|
|
293
|
-
## Component Examples
|
|
294
|
-
|
|
295
|
-
### AppInputField
|
|
296
|
-
|
|
297
|
-
A versatile text input field with built-in validation and Material-UI styling.
|
|
298
|
-
|
|
299
|
-
```tsx
|
|
300
|
-
import { AppInputField } from 'formik-form-components';
|
|
301
|
-
import { InputAdornment } from '@mui/material';
|
|
302
|
-
import { Email as EmailIcon } from '@mui/icons-material';
|
|
303
|
-
|
|
304
|
-
// Basic usage
|
|
305
|
-
<AppInputField
|
|
306
|
-
name="email"
|
|
307
|
-
label="Email Address"
|
|
308
|
-
placeholder="Enter your email"
|
|
309
|
-
fullWidth
|
|
310
|
-
required
|
|
311
|
-
helperText="We'll never share your email"
|
|
312
|
-
InputProps={{
|
|
313
|
-
startAdornment: (
|
|
314
|
-
<InputAdornment position="start">
|
|
315
|
-
<EmailIcon color="action" />
|
|
316
|
-
</InputAdornment>
|
|
317
|
-
),
|
|
318
|
-
}}
|
|
319
|
-
/>
|
|
320
|
-
````
|
|
321
|
-
|
|
322
|
-
### AppDatePicker
|
|
323
|
-
|
|
324
|
-
Date picker with calendar icon and validation.
|
|
325
|
-
|
|
326
|
-
```tsx
|
|
327
|
-
import { AppDatePicker } from 'formik-form-components';
|
|
328
|
-
|
|
329
|
-
<AppDatePicker
|
|
330
|
-
name="birthDate"
|
|
331
|
-
label="Date of Birth"
|
|
332
|
-
required
|
|
333
|
-
sx={{ mb: 2 }}
|
|
334
|
-
textFieldSx={{
|
|
335
|
-
'& .MuiOutlinedInput-root': {
|
|
336
|
-
'&:hover fieldset': {
|
|
337
|
-
borderColor: 'primary.main',
|
|
338
|
-
},
|
|
339
|
-
},
|
|
340
|
-
}}
|
|
341
|
-
/>
|
|
342
|
-
```
|
|
182
|
+
- `AppUploadFile`
|
|
183
|
+
- `AppSimpleUploadFile`
|
|
184
|
+
- `AppUploadFile`
|
|
185
|
+
- `AppSimpleUploadFile`
|
|
343
186
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
Interactive star rating component with customizable colors.
|
|
347
|
-
|
|
348
|
-
```tsx
|
|
349
|
-
import { AppRating } from 'formik-form-components';
|
|
350
|
-
|
|
351
|
-
<AppRating
|
|
352
|
-
name="rating"
|
|
353
|
-
label="Rating"
|
|
354
|
-
required
|
|
355
|
-
ratingSx={{
|
|
356
|
-
'& .MuiRating-iconFilled': {
|
|
357
|
-
color: '#ff6d75',
|
|
358
|
-
},
|
|
359
|
-
'& .MuiRating-iconHover': {
|
|
360
|
-
color: '#ff3d47',
|
|
361
|
-
},
|
|
362
|
-
}}
|
|
363
|
-
/>
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
### AppUploadFile
|
|
367
|
-
|
|
368
|
-
File upload component with drag & drop support.
|
|
369
|
-
|
|
370
|
-
```tsx
|
|
371
|
-
import { AppUploadFile } from 'formik-form-components';
|
|
372
|
-
|
|
373
|
-
<AppUploadFile
|
|
374
|
-
name="document"
|
|
375
|
-
label="Upload Document"
|
|
376
|
-
accept="application/pdf"
|
|
377
|
-
maxSize={5 * 1024 * 1024} // 5MB
|
|
378
|
-
onDelete={() => setFieldValue("document", null)}
|
|
379
|
-
helperText="PDF files up to 5MB"
|
|
380
|
-
/>
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
### AppRichTextEditor
|
|
384
|
-
|
|
385
|
-
Feature-rich WYSIWYG editor based on Tiptap.
|
|
386
|
-
|
|
387
|
-
```tsx
|
|
388
|
-
import { AppRichTextEditor } from 'formik-form-components';
|
|
389
|
-
|
|
390
|
-
<AppRichTextEditor
|
|
391
|
-
name="content"
|
|
392
|
-
label="Article Content"
|
|
393
|
-
placeholder="Start writing your article here..."
|
|
394
|
-
toolbarItems={[
|
|
395
|
-
'heading',
|
|
396
|
-
'bold', 'italic', 'underline', 'strike',
|
|
397
|
-
'|',
|
|
398
|
-
'bulletList', 'orderedList', 'blockquote',
|
|
399
|
-
'|',
|
|
400
|
-
'link', 'image', 'video',
|
|
401
|
-
'|',
|
|
402
|
-
'alignLeft', 'alignCenter', 'alignRight',
|
|
403
|
-
'|',
|
|
404
|
-
'undo', 'redo'
|
|
405
|
-
]}
|
|
406
|
-
sx={{ minHeight: 300 }}
|
|
407
|
-
/>
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
## Component Props
|
|
411
|
-
|
|
412
|
-
### Common Props
|
|
413
|
-
|
|
414
|
-
Most form components accept these common props:
|
|
415
|
-
|
|
416
|
-
| Prop | Type | Default | Description |
|
|
417
|
-
| ---------- | ------- | -------- | --------------------------------------------------- |
|
|
418
|
-
| name | string | required | Field name for Formik |
|
|
419
|
-
| label | string | '' | Field label |
|
|
420
|
-
| required | boolean | false | Show required indicator |
|
|
421
|
-
| disabled | boolean | false | Disable the input |
|
|
422
|
-
| helperText | string | '' | Helper text below the field |
|
|
423
|
-
| fullWidth | boolean | false | Take full width of container |
|
|
424
|
-
| sx | SxProps | {} | Custom styles |
|
|
425
|
-
| ...other | any | - | Additional props passed to the underlying component |
|
|
426
|
-
|
|
427
|
-
### AppRichTextEditor
|
|
428
|
-
|
|
429
|
-
A powerful rich text editor built with TipTap.
|
|
430
|
-
|
|
431
|
-
```tsx
|
|
432
|
-
import { AppRichTextEditor } from '@tkturners/form-components';
|
|
433
|
-
|
|
434
|
-
<AppRichTextEditor
|
|
435
|
-
name="content"
|
|
436
|
-
label="Content"
|
|
437
|
-
placeholder="Start writing here..."
|
|
438
|
-
fullWidth
|
|
439
|
-
margin="normal"
|
|
440
|
-
toolbarItems={['bold', 'italic', 'underline', 'link', 'bulletList', 'orderedList']}
|
|
441
|
-
/>
|
|
442
|
-
```
|
|
443
|
-
|
|
444
|
-
#### Props
|
|
445
|
-
|
|
446
|
-
| Prop | Type | Default | Description |
|
|
447
|
-
| ------------ | -------- | ------------------- | -------------------------------------------------------------- |
|
|
448
|
-
| name | string | required | Field name for Formik |
|
|
449
|
-
| label | string | '' | Field label |
|
|
450
|
-
| placeholder | string | '' | Placeholder text |
|
|
451
|
-
| toolbarItems | string[] | All available items | Array of toolbar items to display |
|
|
452
|
-
| ...other | any | - | Any other props will be passed to the underlying MUI TextField |
|
|
187
|
+
---
|
|
453
188
|
|
|
454
189
|
## Theming
|
|
455
190
|
|
|
456
|
-
All components
|
|
457
|
-
|
|
458
|
-
### Basic Theme Customization
|
|
191
|
+
All components fully support **Material UI theming**.
|
|
459
192
|
|
|
460
193
|
```tsx
|
|
461
194
|
import { createTheme } from '@mui/material/styles';
|
|
462
195
|
|
|
463
196
|
export const theme = createTheme({
|
|
464
197
|
palette: {
|
|
465
|
-
primary: {
|
|
466
|
-
|
|
467
|
-
light: '#6573c3',
|
|
468
|
-
dark: '#2c387e',
|
|
469
|
-
contrastText: '#fff',
|
|
470
|
-
},
|
|
471
|
-
secondary: {
|
|
472
|
-
main: '#f50057',
|
|
473
|
-
light: '#f73378',
|
|
474
|
-
dark: '#ab003c',
|
|
475
|
-
contrastText: '#fff',
|
|
476
|
-
},
|
|
477
|
-
},
|
|
478
|
-
typography: {
|
|
479
|
-
fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
|
|
480
|
-
h1: { fontSize: '2.5rem', fontWeight: 500 },
|
|
481
|
-
h2: { fontSize: '2rem', fontWeight: 500 },
|
|
482
|
-
// ... other typography settings
|
|
483
|
-
},
|
|
484
|
-
components: {
|
|
485
|
-
MuiButton: {
|
|
486
|
-
styleOverrides: {
|
|
487
|
-
root: {
|
|
488
|
-
textTransform: 'none',
|
|
489
|
-
borderRadius: 8,
|
|
490
|
-
},
|
|
491
|
-
},
|
|
492
|
-
},
|
|
493
|
-
MuiTextField: {
|
|
494
|
-
defaultProps: {
|
|
495
|
-
variant: 'outlined',
|
|
496
|
-
fullWidth: true,
|
|
497
|
-
size: 'small',
|
|
498
|
-
},
|
|
499
|
-
},
|
|
500
|
-
MuiFormControl: {
|
|
501
|
-
styleOverrides: {
|
|
502
|
-
root: {
|
|
503
|
-
marginBottom: '1rem',
|
|
504
|
-
},
|
|
505
|
-
},
|
|
506
|
-
},
|
|
507
|
-
// Add more component overrides as needed
|
|
508
|
-
},
|
|
509
|
-
});
|
|
510
|
-
```
|
|
511
|
-
|
|
512
|
-
### Customizing Specific Components
|
|
513
|
-
|
|
514
|
-
You can customize specific components by targeting their class names:
|
|
515
|
-
|
|
516
|
-
```tsx
|
|
517
|
-
const theme = createTheme({
|
|
518
|
-
components: {
|
|
519
|
-
// Customize DatePicker
|
|
520
|
-
MuiPickersDay: {
|
|
521
|
-
styleOverrides: {
|
|
522
|
-
root: {
|
|
523
|
-
'&.Mui-selected': {
|
|
524
|
-
backgroundColor: theme.palette.primary.main,
|
|
525
|
-
'&:hover': {
|
|
526
|
-
backgroundColor: theme.palette.primary.dark,
|
|
527
|
-
},
|
|
528
|
-
},
|
|
529
|
-
},
|
|
530
|
-
},
|
|
531
|
-
},
|
|
532
|
-
|
|
533
|
-
// Customize Rating
|
|
534
|
-
MuiRating: {
|
|
535
|
-
styleOverrides: {
|
|
536
|
-
iconFilled: {
|
|
537
|
-
color: '#ff6d75',
|
|
538
|
-
},
|
|
539
|
-
iconHover: {
|
|
540
|
-
color: '#ff3d47',
|
|
541
|
-
},
|
|
542
|
-
},
|
|
543
|
-
},
|
|
544
|
-
|
|
545
|
-
// Customize Select
|
|
546
|
-
MuiOutlinedInput: {
|
|
547
|
-
styleOverrides: {
|
|
548
|
-
root: {
|
|
549
|
-
'&:hover .MuiOutlinedInput-notchedOutline': {
|
|
550
|
-
borderColor: 'rgba(0, 0, 0, 0.23)',
|
|
551
|
-
},
|
|
552
|
-
'&.Mui-focused .MuiOutlinedInput-notchedOutline': {
|
|
553
|
-
borderWidth: '1px',
|
|
554
|
-
},
|
|
555
|
-
},
|
|
556
|
-
},
|
|
557
|
-
},
|
|
198
|
+
primary: { main: '#1976d2' },
|
|
199
|
+
secondary: { main: '#dc004e' },
|
|
558
200
|
},
|
|
559
201
|
});
|
|
560
202
|
```
|
|
561
203
|
|
|
562
204
|
### Dark Mode
|
|
563
205
|
|
|
564
|
-
Easily implement dark mode with Material-UI's theme system:
|
|
565
|
-
|
|
566
206
|
```tsx
|
|
567
|
-
import { createTheme, ThemeProvider } from '@mui/material/styles';
|
|
568
|
-
import CssBaseline from '@mui/material/CssBaseline';
|
|
569
|
-
|
|
570
207
|
const darkTheme = createTheme({
|
|
571
|
-
palette: {
|
|
572
|
-
mode: 'dark',
|
|
573
|
-
primary: {
|
|
574
|
-
main: '#90caf9',
|
|
575
|
-
},
|
|
576
|
-
secondary: {
|
|
577
|
-
main: '#f48fb1',
|
|
578
|
-
},
|
|
579
|
-
background: {
|
|
580
|
-
default: '#121212',
|
|
581
|
-
paper: '#1e1e1e',
|
|
582
|
-
},
|
|
583
|
-
},
|
|
208
|
+
palette: { mode: 'dark' },
|
|
584
209
|
});
|
|
585
|
-
|
|
586
|
-
function App() {
|
|
587
|
-
return (
|
|
588
|
-
<ThemeProvider theme={darkTheme}>
|
|
589
|
-
<CssBaseline />
|
|
590
|
-
{/* Your app components */}
|
|
591
|
-
</ThemeProvider>
|
|
592
|
-
);
|
|
593
|
-
}
|
|
594
210
|
```
|
|
595
211
|
|
|
596
|
-
|
|
597
|
-
marginBottom: '1rem',
|
|
598
|
-
},
|
|
599
|
-
},
|
|
600
|
-
},
|
|
601
|
-
|
|
602
|
-
},
|
|
603
|
-
// Custom palette
|
|
604
|
-
palette: {
|
|
605
|
-
primary: {
|
|
606
|
-
main: '#1976d2',
|
|
607
|
-
},
|
|
608
|
-
secondary: {
|
|
609
|
-
main: '#dc004e',
|
|
610
|
-
},
|
|
611
|
-
},
|
|
612
|
-
});
|
|
613
|
-
|
|
614
|
-
````
|
|
212
|
+
---
|
|
615
213
|
|
|
616
214
|
## TypeScript Support
|
|
617
215
|
|
|
618
|
-
All components are written in TypeScript and
|
|
216
|
+
All components are written in **TypeScript** and fully typed.
|
|
619
217
|
|
|
620
218
|
```tsx
|
|
621
219
|
type FormValues = {
|
|
622
220
|
name: string;
|
|
623
221
|
email: string;
|
|
624
|
-
// ... other fields
|
|
625
222
|
};
|
|
223
|
+
```
|
|
626
224
|
|
|
627
|
-
|
|
628
|
-
name: Yup.string().required('Required'),
|
|
629
|
-
email: Yup.string().email('Invalid email').required('Required'),
|
|
630
|
-
// ... other validations
|
|
631
|
-
});
|
|
632
|
-
|
|
633
|
-
// In your component
|
|
634
|
-
<Formik<FormValues>
|
|
635
|
-
initialValues={{
|
|
636
|
-
name: '',
|
|
637
|
-
email: '',
|
|
638
|
-
// ... other initial values
|
|
639
|
-
}}
|
|
640
|
-
validationSchema={validationSchema}
|
|
641
|
-
onSubmit={(values) => {
|
|
642
|
-
// values is properly typed as FormValues
|
|
643
|
-
console.log(values);
|
|
644
|
-
}}
|
|
645
|
-
>
|
|
646
|
-
{/* ... */}
|
|
647
|
-
</Formik>
|
|
648
|
-
````
|
|
225
|
+
---
|
|
649
226
|
|
|
650
227
|
## Contributing
|
|
651
228
|
|
|
652
|
-
Contributions are welcome! Please follow these steps:
|
|
653
|
-
|
|
654
229
|
1. Fork the repository
|
|
655
230
|
2. Create a feature branch
|
|
656
231
|
3. Commit your changes
|
|
657
|
-
4.
|
|
658
|
-
|
|
232
|
+
4. Open a Pull Request
|
|
233
|
+
|
|
234
|
+
---
|
|
659
235
|
|
|
660
236
|
## License
|
|
661
237
|
|
|
662
|
-
|
|
238
|
+
MIT © tkturners
|
|
239
|
+
|
|
240
|
+
---
|
|
663
241
|
|
|
664
242
|
## Support
|
|
665
243
|
|
|
666
|
-
If you
|
|
244
|
+
If you find a bug or have a feature request, please open an issue on GitHub:
|
|
245
|
+
https://github.com/tkturners/formik-form-components/issues
|