formik-form-components 0.3.1 → 1.0.1
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 +91 -402
- package/dist/App.d.ts +3 -0
- package/dist/Form/AppAutoCompleter.d.ts +10 -0
- package/dist/Form/AppCheckBox.d.ts +15 -0
- package/dist/Form/AppDateAndTimePicker.d.ts +14 -0
- package/dist/Form/AppDatePicker.d.ts +11 -0
- package/dist/Form/AppFormErrorMessage.d.ts +9 -0
- package/dist/Form/AppInputField.d.ts +9 -0
- package/dist/Form/AppMultiSelector.d.ts +20 -0
- package/dist/Form/AppPhoneNoInput.d.ts +16 -0
- package/dist/Form/AppRadioGroup.d.ts +17 -0
- package/dist/Form/AppRating.d.ts +12 -0
- package/dist/Form/AppSelectInput.d.ts +15 -0
- package/dist/Form/AppSimpleUploadFile.d.ts +14 -0
- package/dist/Form/AppSwitch.d.ts +10 -0
- package/dist/Form/AppTagsCreator.d.ts +11 -0
- package/dist/Form/AppTextArea.d.ts +10 -0
- package/dist/Form/AppUploadFile.d.ts +20 -0
- package/dist/Form/SubmitButton.d.ts +10 -0
- package/dist/Form/index.d.ts +10 -0
- package/dist/Form/types.d.ts +32 -0
- package/dist/assets/illustrations/BackgroundIllustration.d.ts +7 -0
- package/dist/assets/illustrations/UploadIllustration.d.ts +4 -0
- package/dist/assets/illustrations/index.d.ts +2 -0
- package/dist/esm/App.d.ts +3 -0
- package/dist/esm/Form/AppAutoCompleter.d.ts +10 -0
- package/dist/esm/Form/AppCheckBox.d.ts +15 -0
- package/dist/esm/Form/AppDateAndTimePicker.d.ts +14 -0
- package/dist/esm/Form/AppDatePicker.d.ts +11 -0
- package/dist/esm/Form/AppFormErrorMessage.d.ts +9 -0
- package/dist/esm/Form/AppInputField.d.ts +9 -0
- package/dist/esm/Form/AppMultiSelector.d.ts +20 -0
- package/dist/esm/Form/AppPhoneNoInput.d.ts +16 -0
- package/dist/esm/Form/AppRadioGroup.d.ts +17 -0
- package/dist/esm/Form/AppRating.d.ts +12 -0
- package/dist/esm/Form/AppSelectInput.d.ts +15 -0
- package/dist/esm/Form/AppSimpleUploadFile.d.ts +14 -0
- package/dist/esm/Form/AppSwitch.d.ts +10 -0
- package/dist/esm/Form/AppTagsCreator.d.ts +11 -0
- package/dist/esm/Form/AppTextArea.d.ts +10 -0
- package/dist/esm/Form/AppUploadFile.d.ts +20 -0
- package/dist/esm/Form/SubmitButton.d.ts +10 -0
- package/dist/esm/Form/index.d.ts +10 -0
- package/dist/esm/Form/types.d.ts +32 -0
- package/dist/esm/assets/illustrations/BackgroundIllustration.d.ts +7 -0
- package/dist/esm/assets/illustrations/UploadIllustration.d.ts +4 -0
- package/dist/esm/assets/illustrations/index.d.ts +2 -0
- package/dist/esm/file-thumbnail/types.d.ts +6 -0
- package/dist/esm/file-thumbnail/utils.d.ts +26 -0
- package/dist/esm/index.d.ts +22 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/reportWebVitals.d.ts +4 -0
- package/dist/esm/setupTests.d.ts +2 -0
- package/dist/esm/upload/Upload.d.ts +5 -0
- package/dist/esm/upload/errors/RejectionFiles.d.ts +7 -0
- package/dist/esm/upload/index.d.ts +6 -0
- package/dist/esm/upload/preview/MultiFilePreview.d.ts +10 -0
- package/dist/esm/upload/preview/SingleFilePreview.d.ts +8 -0
- package/dist/esm/upload/types.d.ts +39 -0
- package/dist/file-thumbnail/types.d.ts +6 -0
- package/dist/file-thumbnail/utils.d.ts +26 -0
- package/dist/index.d.ts +22 -402
- package/dist/index.js +1 -11578
- package/dist/reportWebVitals.d.ts +4 -0
- package/dist/setupTests.d.ts +2 -0
- package/dist/types/App.d.ts +3 -0
- package/dist/types/Form/AppAutoCompleter.d.ts +10 -0
- package/dist/types/Form/AppCheckBox.d.ts +15 -0
- package/dist/types/Form/AppDateAndTimePicker.d.ts +14 -0
- package/dist/types/Form/AppDatePicker.d.ts +11 -0
- package/dist/types/Form/AppFormErrorMessage.d.ts +9 -0
- package/dist/types/Form/AppInputField.d.ts +9 -0
- package/dist/types/Form/AppMultiSelector.d.ts +20 -0
- package/dist/types/Form/AppPhoneNoInput.d.ts +16 -0
- package/dist/types/Form/AppRadioGroup.d.ts +17 -0
- package/dist/types/Form/AppRating.d.ts +12 -0
- package/dist/types/Form/AppSelectInput.d.ts +15 -0
- package/dist/types/Form/AppSimpleUploadFile.d.ts +14 -0
- package/dist/types/Form/AppSwitch.d.ts +10 -0
- package/dist/types/Form/AppTagsCreator.d.ts +11 -0
- package/dist/types/Form/AppTextArea.d.ts +10 -0
- package/dist/types/Form/AppUploadFile.d.ts +20 -0
- package/dist/types/Form/SubmitButton.d.ts +10 -0
- package/dist/types/Form/index.d.ts +10 -0
- package/dist/types/Form/types.d.ts +32 -0
- package/dist/types/assets/illustrations/BackgroundIllustration.d.ts +7 -0
- package/dist/types/assets/illustrations/UploadIllustration.d.ts +4 -0
- package/dist/types/assets/illustrations/index.d.ts +2 -0
- package/dist/types/file-thumbnail/types.d.ts +6 -0
- package/dist/types/file-thumbnail/utils.d.ts +26 -0
- package/dist/types/index.d.ts +22 -0
- package/dist/types/reportWebVitals.d.ts +4 -0
- package/dist/types/setupTests.d.ts +2 -0
- package/dist/types/upload/Upload.d.ts +5 -0
- package/dist/types/upload/errors/RejectionFiles.d.ts +7 -0
- package/dist/types/upload/index.d.ts +6 -0
- package/dist/types/upload/preview/MultiFilePreview.d.ts +10 -0
- package/dist/types/upload/preview/SingleFilePreview.d.ts +8 -0
- package/dist/types/upload/types.d.ts +39 -0
- package/dist/upload/Upload.d.ts +5 -0
- package/dist/upload/errors/RejectionFiles.d.ts +7 -0
- package/dist/upload/index.d.ts +6 -0
- package/dist/upload/preview/MultiFilePreview.d.ts +10 -0
- package/dist/upload/preview/SingleFilePreview.d.ts +8 -0
- package/dist/upload/types.d.ts +39 -0
- package/package.json +98 -69
- package/LICENSE +0 -21
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -11545
- package/dist/index.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,446 +1,135 @@
|
|
|
1
1
|
# Formik Form Components
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A collection of reusable form components built with Formik, React, and Tailwind CSS.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-

|
|
7
|
-

|
|
5
|
+
## Features
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
- 🏗️ Pre-built form components for common use cases
|
|
8
|
+
- 🎨 Styled with Tailwind CSS for easy customization
|
|
9
|
+
- 🚀 Built with TypeScript for type safety
|
|
10
|
+
- 🔄 Seamless integration with Formik
|
|
11
|
+
- 📱 Responsive design
|
|
10
12
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
- 🚀 **20+** production-ready form components
|
|
14
|
-
- 🎨 Styled with **Tailwind CSS** for maximum flexibility
|
|
15
|
-
- 🔍 Built-in validation support (Formik + Yup)
|
|
16
|
-
- 📱 Fully responsive and mobile-friendly
|
|
17
|
-
- 🎯 Full **TypeScript** support
|
|
18
|
-
- ♿ Accessibility-first with proper ARIA attributes
|
|
19
|
-
- 📅 Native HTML5 date & time pickers
|
|
20
|
-
- ✨ Rich text editor powered by **Tiptap**
|
|
21
|
-
- 📂 File & image uploads with drag-and-drop
|
|
22
|
-
- 🌍 Internationalization (i18n) ready
|
|
23
|
-
- 🎭 No dependencies on UI frameworks (MUI, etc.)
|
|
24
|
-
- 🔧 Fully customizable with Tailwind classes
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
## 📦 Installation
|
|
13
|
+
## Installation
|
|
29
14
|
|
|
30
15
|
```bash
|
|
31
|
-
# npm
|
|
32
16
|
npm install formik-form-components
|
|
33
|
-
|
|
34
|
-
# yarn
|
|
17
|
+
# or
|
|
35
18
|
yarn add formik-form-components
|
|
36
|
-
|
|
37
|
-
# pnpm
|
|
38
|
-
pnpm add formik-form-components
|
|
39
19
|
```
|
|
40
20
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Make sure you have the required peer dependencies installed:
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
npm install react react-dom formik tailwindcss
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
## 🚀 Getting Started
|
|
21
|
+
## Peer Dependencies
|
|
52
22
|
|
|
53
|
-
|
|
23
|
+
This package requires the following peer dependencies:
|
|
54
24
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
```js
|
|
64
|
-
/** @type {import('tailwindcss').Config} */
|
|
65
|
-
module.exports = {
|
|
66
|
-
content: [
|
|
67
|
-
"./src/**/*.{js,jsx,ts,tsx}",
|
|
68
|
-
"./node_modules/formik-form-components/dist/**/*.{js,mjs}",
|
|
69
|
-
],
|
|
70
|
-
theme: {
|
|
71
|
-
extend: {
|
|
72
|
-
colors: {
|
|
73
|
-
primary: {
|
|
74
|
-
50: '#e3f2fd',
|
|
75
|
-
100: '#bbdefb',
|
|
76
|
-
200: '#90caf9',
|
|
77
|
-
300: '#64b5f6',
|
|
78
|
-
400: '#42a5f5',
|
|
79
|
-
500: '#2196f3',
|
|
80
|
-
600: '#1e88e5',
|
|
81
|
-
700: '#1976d2',
|
|
82
|
-
800: '#1565c0',
|
|
83
|
-
900: '#0d47a1',
|
|
84
|
-
},
|
|
85
|
-
error: {
|
|
86
|
-
50: '#ffebee',
|
|
87
|
-
100: '#ffcdd2',
|
|
88
|
-
200: '#ef9a9a',
|
|
89
|
-
300: '#e57373',
|
|
90
|
-
400: '#ef5350',
|
|
91
|
-
500: '#f44336',
|
|
92
|
-
600: '#e53935',
|
|
93
|
-
700: '#d32f2f',
|
|
94
|
-
800: '#c62828',
|
|
95
|
-
900: '#b71c1c',
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
plugins: [],
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
28
|
+
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
29
|
+
"formik": "^2.0.0",
|
|
30
|
+
"@headlessui/react": "^1.0.0 || ^2.0.0",
|
|
31
|
+
"@heroicons/react": "^1.0.0 || ^2.0.0"
|
|
101
32
|
}
|
|
102
33
|
```
|
|
103
34
|
|
|
104
|
-
|
|
35
|
+
## Usage
|
|
105
36
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
```css
|
|
109
|
-
@tailwind base;
|
|
110
|
-
@tailwind components;
|
|
111
|
-
@tailwind utilities;
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### 3. Basic Form Example
|
|
37
|
+
### Basic Form Setup
|
|
115
38
|
|
|
116
39
|
```tsx
|
|
117
|
-
import {
|
|
118
|
-
import * as Yup from 'yup';
|
|
119
|
-
import {
|
|
120
|
-
AppInputField,
|
|
121
|
-
AppCheckBox,
|
|
122
|
-
AppDatePicker,
|
|
123
|
-
AppTextArea,
|
|
124
|
-
AppSelectInput,
|
|
125
|
-
SubmitButton,
|
|
126
|
-
} from 'formik-form-components';
|
|
40
|
+
import { Form, AppInputField, SubmitButton } from 'formik-form-components';
|
|
127
41
|
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
bio: Yup.string().required('Bio is required'),
|
|
134
|
-
terms: Yup.boolean().oneOf([true], 'You must accept the terms'),
|
|
135
|
-
});
|
|
42
|
+
const MyForm = () => {
|
|
43
|
+
const initialValues = {
|
|
44
|
+
email: '',
|
|
45
|
+
password: '',
|
|
46
|
+
};
|
|
136
47
|
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
{ label: 'United Kingdom', value: 'uk' },
|
|
141
|
-
{ label: 'Australia', value: 'au' },
|
|
142
|
-
];
|
|
48
|
+
const handleSubmit = (values) => {
|
|
49
|
+
console.log(values);
|
|
50
|
+
};
|
|
143
51
|
|
|
144
|
-
export default function ExampleForm() {
|
|
145
52
|
return (
|
|
146
|
-
<
|
|
147
|
-
initialValues={
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
birthDate: null,
|
|
151
|
-
country: '',
|
|
152
|
-
bio: '',
|
|
153
|
-
terms: false,
|
|
154
|
-
}}
|
|
155
|
-
validationSchema={validationSchema}
|
|
156
|
-
onSubmit={(values) => console.log(values)}
|
|
53
|
+
<Form
|
|
54
|
+
initialValues={initialValues}
|
|
55
|
+
onSubmit={handleSubmit}
|
|
56
|
+
className="max-w-md mx-auto p-6 bg-white rounded-lg shadow-md"
|
|
157
57
|
>
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
name="birthDate"
|
|
177
|
-
label="Date of Birth"
|
|
178
|
-
required
|
|
179
|
-
/>
|
|
180
|
-
|
|
181
|
-
<AppSelectInput
|
|
182
|
-
name="country"
|
|
183
|
-
label="Country"
|
|
184
|
-
options={countryOptions}
|
|
185
|
-
placeholder="Select a country"
|
|
186
|
-
required
|
|
187
|
-
/>
|
|
188
|
-
|
|
189
|
-
<AppTextArea
|
|
190
|
-
name="bio"
|
|
191
|
-
label="Bio"
|
|
192
|
-
rows={4}
|
|
193
|
-
maxLength={500}
|
|
194
|
-
showCount
|
|
195
|
-
required
|
|
196
|
-
/>
|
|
197
|
-
|
|
198
|
-
<AppCheckBox
|
|
199
|
-
name="terms"
|
|
200
|
-
option={[{
|
|
201
|
-
name: 'terms',
|
|
202
|
-
label: 'I agree to the terms and conditions',
|
|
203
|
-
value: true
|
|
204
|
-
}]}
|
|
205
|
-
/>
|
|
206
|
-
|
|
207
|
-
<SubmitButton
|
|
208
|
-
loading={isSubmitting}
|
|
209
|
-
fullWidth
|
|
210
|
-
>
|
|
211
|
-
Submit
|
|
212
|
-
</SubmitButton>
|
|
213
|
-
</Form>
|
|
214
|
-
)}
|
|
215
|
-
</Formik>
|
|
58
|
+
<AppInputField
|
|
59
|
+
name="email"
|
|
60
|
+
label="Email"
|
|
61
|
+
type="email"
|
|
62
|
+
placeholder="Enter your email"
|
|
63
|
+
required
|
|
64
|
+
/>
|
|
65
|
+
<AppInputField
|
|
66
|
+
name="password"
|
|
67
|
+
label="Password"
|
|
68
|
+
type="password"
|
|
69
|
+
placeholder="Enter your password"
|
|
70
|
+
required
|
|
71
|
+
/>
|
|
72
|
+
<SubmitButton className="w-full bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded">
|
|
73
|
+
Submit
|
|
74
|
+
</SubmitButton>
|
|
75
|
+
</Form>
|
|
216
76
|
);
|
|
217
|
-
}
|
|
77
|
+
};
|
|
218
78
|
```
|
|
219
79
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
## 📚 Available Components
|
|
223
|
-
|
|
224
|
-
### Form Inputs
|
|
80
|
+
## Available Components
|
|
225
81
|
|
|
226
|
-
-
|
|
227
|
-
-
|
|
228
|
-
-
|
|
229
|
-
-
|
|
230
|
-
-
|
|
231
|
-
-
|
|
232
|
-
-
|
|
82
|
+
- **Form** - Wrapper component that sets up Formik context
|
|
83
|
+
- **AppInputField** - Text input field with label and error handling
|
|
84
|
+
- **AppTextArea** - Textarea input field
|
|
85
|
+
- **AppSelectInput** - Dropdown select input
|
|
86
|
+
- **AppCheckBox** - Checkbox input
|
|
87
|
+
- **AppRadioGroup** - Radio button group
|
|
88
|
+
- **AppSwitch** - Toggle switch
|
|
89
|
+
- **AppDatePicker** - Date picker input
|
|
90
|
+
- **AppDateAndTimePicker** - Combined date and time picker
|
|
91
|
+
- **AppPhoneNoInput** - Phone number input with country code selection
|
|
92
|
+
- **AppRating** - Star rating input
|
|
93
|
+
- **AppTagsCreator** - Tag input with creation
|
|
94
|
+
- **AppMultiSelector** - Multi-select dropdown
|
|
95
|
+
- **AppAutoCompleter** - Autocomplete input with suggestions
|
|
96
|
+
- **AppUploadFile** - File upload component
|
|
97
|
+
- **AppSimpleUploadFile** - Simplified file upload
|
|
98
|
+
- **SubmitButton** - Form submit button with loading state
|
|
233
99
|
|
|
234
|
-
|
|
100
|
+
## Styling
|
|
235
101
|
|
|
236
|
-
|
|
237
|
-
- **`AppAutoComplete`** - Autocomplete with tags
|
|
238
|
-
- **`AppAutoCompleter`** - Advanced autocomplete with search
|
|
239
|
-
- **`AppMultiSelector`** - Multi-select with checkboxes
|
|
240
|
-
- **`AppTagsCreator`** - Tag input with suggestions
|
|
102
|
+
Components are styled using Tailwind CSS. You can customize the appearance by:
|
|
241
103
|
|
|
242
|
-
|
|
104
|
+
1. Overriding the default classes using the `className` prop
|
|
105
|
+
2. Using Tailwind's JIT compiler to customize the theme
|
|
106
|
+
3. Using CSS modules or styled-components for more complex styling needs
|
|
243
107
|
|
|
244
|
-
|
|
245
|
-
- **`AppDateAndTimePicker`** - Native HTML5 datetime-local picker
|
|
108
|
+
## Development
|
|
246
109
|
|
|
247
|
-
###
|
|
110
|
+
### Installation
|
|
248
111
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
- **`AppRichTextEditor`** - Rich text editor powered by Tiptap
|
|
255
|
-
|
|
256
|
-
### Other
|
|
257
|
-
|
|
258
|
-
- **`SubmitButton`** - Submit button with loading state
|
|
259
|
-
- **`Iconify`** - Icon component (optional, uses @iconify/react)
|
|
260
|
-
|
|
261
|
-
---
|
|
262
|
-
|
|
263
|
-
## 🎨 Customization
|
|
264
|
-
|
|
265
|
-
All components accept standard Tailwind CSS classes for customization:
|
|
266
|
-
|
|
267
|
-
```tsx
|
|
268
|
-
<AppInputField
|
|
269
|
-
name="email"
|
|
270
|
-
label="Email"
|
|
271
|
-
className="border-2 border-blue-500"
|
|
272
|
-
labelClassName="text-lg font-bold"
|
|
273
|
-
containerClassName="mb-6"
|
|
274
|
-
/>
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
### Custom Theme Colors
|
|
278
|
-
|
|
279
|
-
You can customize the primary and error colors in your `tailwind.config.js` to match your brand:
|
|
280
|
-
|
|
281
|
-
```js
|
|
282
|
-
theme: {
|
|
283
|
-
extend: {
|
|
284
|
-
colors: {
|
|
285
|
-
primary: {
|
|
286
|
-
500: '#your-brand-color',
|
|
287
|
-
600: '#your-brand-color-dark',
|
|
288
|
-
// ... other shades
|
|
289
|
-
},
|
|
290
|
-
},
|
|
291
|
-
},
|
|
292
|
-
},
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
---
|
|
296
|
-
|
|
297
|
-
## 🔧 Component Props
|
|
298
|
-
|
|
299
|
-
### Common Props (Available on Most Components)
|
|
300
|
-
|
|
301
|
-
```tsx
|
|
302
|
-
interface CommonProps {
|
|
303
|
-
name: string; // Required: Field name for Formik
|
|
304
|
-
label?: string; // Label text
|
|
305
|
-
required?: boolean; // Show required indicator
|
|
306
|
-
disabled?: boolean; // Disable the field
|
|
307
|
-
helperText?: string; // Helper text below input
|
|
308
|
-
className?: string; // Custom classes for input
|
|
309
|
-
labelClassName?: string; // Custom classes for label
|
|
310
|
-
errorClassName?: string; // Custom classes for error text
|
|
311
|
-
containerClassName?: string; // Custom classes for container
|
|
312
|
-
}
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
### AppInputField Specific Props
|
|
316
|
-
|
|
317
|
-
```tsx
|
|
318
|
-
interface AppInputFieldProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
319
|
-
name: string;
|
|
320
|
-
label?: ReactNode;
|
|
321
|
-
required?: boolean;
|
|
322
|
-
helperText?: string;
|
|
323
|
-
// ... plus all HTML input attributes
|
|
324
|
-
}
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
---
|
|
328
|
-
|
|
329
|
-
## 📖 Advanced Examples
|
|
330
|
-
|
|
331
|
-
### Custom Validation Messages
|
|
332
|
-
|
|
333
|
-
```tsx
|
|
334
|
-
const schema = Yup.object({
|
|
335
|
-
password: Yup.string()
|
|
336
|
-
.min(8, 'Password must be at least 8 characters')
|
|
337
|
-
.matches(/[A-Z]/, 'Must contain at least one uppercase letter')
|
|
338
|
-
.required('Password is required'),
|
|
339
|
-
});
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
### Multi-Step Form
|
|
343
|
-
|
|
344
|
-
```tsx
|
|
345
|
-
const [step, setStep] = useState(1);
|
|
346
|
-
|
|
347
|
-
return (
|
|
348
|
-
<Formik
|
|
349
|
-
initialValues={initialValues}
|
|
350
|
-
validationSchema={getValidationSchema(step)}
|
|
351
|
-
onSubmit={(values) => {
|
|
352
|
-
if (step < 3) {
|
|
353
|
-
setStep(step + 1);
|
|
354
|
-
} else {
|
|
355
|
-
// Submit final form
|
|
356
|
-
}
|
|
357
|
-
}}
|
|
358
|
-
>
|
|
359
|
-
{/* Render different fields based on step */}
|
|
360
|
-
</Formik>
|
|
361
|
-
);
|
|
112
|
+
```bash
|
|
113
|
+
git clone https://github.com/yourusername/formik-form-components.git
|
|
114
|
+
cd formik-form-components
|
|
115
|
+
npm install
|
|
362
116
|
```
|
|
363
117
|
|
|
364
|
-
###
|
|
118
|
+
### Building
|
|
365
119
|
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
name="avatar"
|
|
369
|
-
label="Upload Profile Picture"
|
|
370
|
-
accept={{ 'image/*': ['.png', '.jpg', '.jpeg'] }}
|
|
371
|
-
maxSize={2 * 1024 * 1024} // 2MB
|
|
372
|
-
maxFiles={1}
|
|
373
|
-
/>
|
|
120
|
+
```bash
|
|
121
|
+
npm run build
|
|
374
122
|
```
|
|
375
123
|
|
|
376
|
-
|
|
124
|
+
### Testing
|
|
377
125
|
|
|
378
|
-
|
|
126
|
+
```bash
|
|
127
|
+
npm test
|
|
128
|
+
## License
|
|
379
129
|
|
|
380
|
-
|
|
130
|
+
MIT
|
|
381
131
|
|
|
382
|
-
|
|
383
|
-
import { useTranslation } from 'react-i18next';
|
|
132
|
+
## Learn More
|
|
384
133
|
|
|
385
|
-
|
|
386
|
-
const { t } = useTranslation();
|
|
387
|
-
|
|
388
|
-
return (
|
|
389
|
-
<AppInputField
|
|
390
|
-
name="name"
|
|
391
|
-
label={t('form.name')}
|
|
392
|
-
placeholder={t('form.namePlaceholder')}
|
|
393
|
-
/>
|
|
394
|
-
);
|
|
395
|
-
}
|
|
134
|
+
You can learn more in the [React documentation](https://reactjs.org/).
|
|
396
135
|
```
|
|
397
|
-
|
|
398
|
-
---
|
|
399
|
-
|
|
400
|
-
## ♿ Accessibility
|
|
401
|
-
|
|
402
|
-
All components are built with accessibility in mind:
|
|
403
|
-
|
|
404
|
-
- Proper ARIA labels and descriptions
|
|
405
|
-
- Keyboard navigation support
|
|
406
|
-
- Screen reader friendly
|
|
407
|
-
- Focus management
|
|
408
|
-
- Error announcements
|
|
409
|
-
|
|
410
|
-
---
|
|
411
|
-
|
|
412
|
-
## 🤝 Contributing
|
|
413
|
-
|
|
414
|
-
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
415
|
-
|
|
416
|
-
1. Fork the repository
|
|
417
|
-
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
418
|
-
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
419
|
-
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
420
|
-
5. Open a Pull Request
|
|
421
|
-
|
|
422
|
-
---
|
|
423
|
-
|
|
424
|
-
## 📄 License
|
|
425
|
-
|
|
426
|
-
MIT © [tkturners](https://github.com/tkturners)
|
|
427
|
-
|
|
428
|
-
---
|
|
429
|
-
|
|
430
|
-
## 🆘 Support
|
|
431
|
-
|
|
432
|
-
If you find a bug or have a feature request, please open an issue on GitHub:
|
|
433
|
-
[https://github.com/tkturners/formik-form-components/issues](https://github.com/tkturners/formik-form-components/issues)
|
|
434
|
-
|
|
435
|
-
---
|
|
436
|
-
|
|
437
|
-
## 🙏 Acknowledgments
|
|
438
|
-
|
|
439
|
-
- Built with [Formik](https://formik.org/)
|
|
440
|
-
- Styled with [Tailwind CSS](https://tailwindcss.com/)
|
|
441
|
-
- Rich text editing powered by [Tiptap](https://tiptap.dev/)
|
|
442
|
-
- Icons from [@iconify/react](https://iconify.design/)
|
|
443
|
-
|
|
444
|
-
---
|
|
445
|
-
|
|
446
|
-
**Happy Coding! 🎉**
|
package/dist/App.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface AppAutoCompleterProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "name" | "value" | "onChange"> {
|
|
2
|
+
name: string;
|
|
3
|
+
label: string;
|
|
4
|
+
options: string[];
|
|
5
|
+
multiple?: boolean;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
export default function AppAutoCompleter({ name, label, options, multiple, className, ...inputProps }: AppAutoCompleterProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=AppAutoCompleter.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface CheckboxOption {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string | number | boolean;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface AppCheckBoxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "name" | "type"> {
|
|
8
|
+
name: string;
|
|
9
|
+
options: CheckboxOption[];
|
|
10
|
+
label?: string;
|
|
11
|
+
row?: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare const AppCheckBox: React.FC<AppCheckBoxProps>;
|
|
14
|
+
export default AppCheckBox;
|
|
15
|
+
//# sourceMappingURL=AppCheckBox.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface AppDateTimeInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "name" | "value" | "onChange" | "min" | "max"> {
|
|
3
|
+
name: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
/** Disable selecting past date & time */
|
|
6
|
+
disablePast?: boolean;
|
|
7
|
+
/** Disable selecting future date & time */
|
|
8
|
+
disableFuture?: boolean;
|
|
9
|
+
min?: string;
|
|
10
|
+
max?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const AppDateTimeInput: React.FC<AppDateTimeInputProps>;
|
|
13
|
+
export default AppDateTimeInput;
|
|
14
|
+
//# sourceMappingURL=AppDateAndTimePicker.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface AppDatePickerProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "onChange" | "min" | "max"> {
|
|
3
|
+
name: string;
|
|
4
|
+
label: string;
|
|
5
|
+
disablePast?: boolean;
|
|
6
|
+
disableFuture?: boolean;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const AppDatePicker: React.FC<AppDatePickerProps>;
|
|
10
|
+
export default AppDatePicker;
|
|
11
|
+
//# sourceMappingURL=AppDatePicker.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface AppFormErrorMessageProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
name: string;
|
|
4
|
+
alwaysShow?: boolean;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
declare const AppFormErrorMessage: React.FC<AppFormErrorMessageProps>;
|
|
8
|
+
export default AppFormErrorMessage;
|
|
9
|
+
//# sourceMappingURL=AppFormErrorMessage.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface AppInputFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "name"> {
|
|
3
|
+
name: string;
|
|
4
|
+
label: React.ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
declare const AppInputField: React.FC<AppInputFieldProps>;
|
|
8
|
+
export default AppInputField;
|
|
9
|
+
//# sourceMappingURL=AppInputField.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface AppSelectOption {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string | number;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
icon?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
interface AppMultiSelectProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange"> {
|
|
9
|
+
name: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
options: AppSelectOption[];
|
|
12
|
+
maxSelections?: number;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
showSelectedCount?: boolean;
|
|
15
|
+
className?: string;
|
|
16
|
+
onChange?: (value: Array<string | number>) => void;
|
|
17
|
+
}
|
|
18
|
+
declare const AppMultiSelect: React.FC<AppMultiSelectProps>;
|
|
19
|
+
export default AppMultiSelect;
|
|
20
|
+
//# sourceMappingURL=AppMultiSelector.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "react-phone-number-input/style.css";
|
|
3
|
+
import "../styles/PhoneInputCustom.css";
|
|
4
|
+
interface AppPhoneNoInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "value"> {
|
|
5
|
+
name: string;
|
|
6
|
+
label: string;
|
|
7
|
+
international?: boolean;
|
|
8
|
+
withCountryCallingCode?: boolean;
|
|
9
|
+
className?: string;
|
|
10
|
+
onChange?: (value: string | undefined) => void;
|
|
11
|
+
value?: string;
|
|
12
|
+
error?: string;
|
|
13
|
+
}
|
|
14
|
+
declare const AppPhoneNoInput: React.FC<AppPhoneNoInputProps>;
|
|
15
|
+
export default AppPhoneNoInput;
|
|
16
|
+
//# sourceMappingURL=AppPhoneNoInput.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface RadioOption {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string | number;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface AppRadioGroupProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "value" | "name"> {
|
|
8
|
+
name: string;
|
|
9
|
+
options: RadioOption[];
|
|
10
|
+
label?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
row?: boolean;
|
|
13
|
+
onChange?: (value: string | number) => void;
|
|
14
|
+
}
|
|
15
|
+
declare const AppRadioGroup: React.FC<AppRadioGroupProps>;
|
|
16
|
+
export default AppRadioGroup;
|
|
17
|
+
//# sourceMappingURL=AppRadioGroup.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface AppRatingProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "value"> {
|
|
3
|
+
name: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
max?: number;
|
|
6
|
+
helperText?: string;
|
|
7
|
+
onChange?: (value: number | null) => void;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
declare const AppRating: React.ForwardRefExoticComponent<AppRatingProps & React.RefAttributes<HTMLDivElement>>;
|
|
11
|
+
export default AppRating;
|
|
12
|
+
//# sourceMappingURL=AppRating.d.ts.map
|