@app-studio/web 0.9.17 → 0.9.19
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/dist/components/AuthGuard/index.d.ts +1 -1
- package/dist/utils/request.d.ts +2 -2
- package/dist/web.cjs.development.js +41 -46
- package/dist/web.cjs.development.js.map +1 -1
- package/dist/web.cjs.production.min.js +1 -1
- package/dist/web.cjs.production.min.js.map +1 -1
- package/dist/web.esm.js +43 -48
- package/dist/web.esm.js.map +1 -1
- package/dist/web.umd.development.js +45 -45
- package/dist/web.umd.development.js.map +1 -1
- package/dist/web.umd.production.min.js +1 -1
- package/dist/web.umd.production.min.js.map +1 -1
- package/docs/README.md +52 -0
- package/docs/adk-components.md +316 -0
- package/docs/adk-quick-start.md +294 -0
- package/docs/api-integration.md +801 -0
- package/docs/api-reference/README.md +103 -0
- package/docs/api-reference/data-display/flow.md +220 -0
- package/docs/api-reference/data-display/tree.md +210 -0
- package/docs/api-reference/form/chat-input.md +210 -0
- package/docs/api-reference/utility/button.md +145 -0
- package/docs/api-reference/utility/title.md +301 -0
- package/docs/app-studio.md +302 -0
- package/docs/component-development/guide.md +546 -0
- package/docs/contributing/documentation.md +153 -0
- package/docs/conventions.md +536 -0
- package/docs/design-system/theming.md +299 -0
- package/docs/documentation-system.md +143 -0
- package/docs/getting-started/component-usage.md +211 -0
- package/docs/getting-started/introduction.md +114 -0
- package/docs/guide.md +550 -0
- package/docs/integration-guide.md +449 -0
- package/docs/tutorials/README.md +51 -0
- package/docs/tutorials/basic/creating-a-simple-form.md +566 -0
- package/package.json +3 -2
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
# Creating a Simple Form
|
|
2
|
+
|
|
3
|
+
This tutorial will guide you through creating a simple form using the App Studio Web Component Library.
|
|
4
|
+
|
|
5
|
+
## Introduction
|
|
6
|
+
|
|
7
|
+
Forms are a fundamental part of web applications. In this tutorial, we'll create a simple contact form with validation using the App Studio Web Component Library components.
|
|
8
|
+
|
|
9
|
+
## Prerequisites
|
|
10
|
+
|
|
11
|
+
- Basic knowledge of React
|
|
12
|
+
- App Studio Web Component Library installed
|
|
13
|
+
- Formik and Yup for form handling and validation (optional)
|
|
14
|
+
|
|
15
|
+
## Step 1: Set Up the Basic Form Structure
|
|
16
|
+
|
|
17
|
+
First, let's create a basic form structure using the `View` and `Vertical` components:
|
|
18
|
+
|
|
19
|
+
```jsx
|
|
20
|
+
import React from 'react';
|
|
21
|
+
import { View, Vertical } from 'app-studio';
|
|
22
|
+
import { Text, Button } from '@app-studio/web';
|
|
23
|
+
|
|
24
|
+
function ContactForm() {
|
|
25
|
+
return (
|
|
26
|
+
<View padding={20} maxWidth={500} margin="0 auto">
|
|
27
|
+
<Vertical gap={20}>
|
|
28
|
+
<Text fontSize={24} fontWeight="bold">Contact Us</Text>
|
|
29
|
+
|
|
30
|
+
{/* Form fields will go here */}
|
|
31
|
+
|
|
32
|
+
<Button>Submit</Button>
|
|
33
|
+
</Vertical>
|
|
34
|
+
</View>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default ContactForm;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Step 2: Add Form Fields
|
|
42
|
+
|
|
43
|
+
Now, let's add form fields using the `TextField` and `TextArea` components:
|
|
44
|
+
|
|
45
|
+
```jsx
|
|
46
|
+
import React, { useState } from 'react';
|
|
47
|
+
import { View, Vertical } from 'app-studio';
|
|
48
|
+
import { Text, Button, TextField, TextArea } from '@app-studio/web';
|
|
49
|
+
|
|
50
|
+
function ContactForm() {
|
|
51
|
+
const [formData, setFormData] = useState({
|
|
52
|
+
name: '',
|
|
53
|
+
email: '',
|
|
54
|
+
message: ''
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const handleChange = (e) => {
|
|
58
|
+
const { name, value } = e.target;
|
|
59
|
+
setFormData({
|
|
60
|
+
...formData,
|
|
61
|
+
[name]: value
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<View padding={20} maxWidth={500} margin="0 auto">
|
|
67
|
+
<Vertical gap={20}>
|
|
68
|
+
<Text fontSize={24} fontWeight="bold">Contact Us</Text>
|
|
69
|
+
|
|
70
|
+
<TextField
|
|
71
|
+
label="Name"
|
|
72
|
+
name="name"
|
|
73
|
+
value={formData.name}
|
|
74
|
+
onChange={handleChange}
|
|
75
|
+
placeholder="Enter your name"
|
|
76
|
+
/>
|
|
77
|
+
|
|
78
|
+
<TextField
|
|
79
|
+
label="Email"
|
|
80
|
+
name="email"
|
|
81
|
+
type="email"
|
|
82
|
+
value={formData.email}
|
|
83
|
+
onChange={handleChange}
|
|
84
|
+
placeholder="Enter your email"
|
|
85
|
+
/>
|
|
86
|
+
|
|
87
|
+
<TextArea
|
|
88
|
+
label="Message"
|
|
89
|
+
name="message"
|
|
90
|
+
value={formData.message}
|
|
91
|
+
onChange={handleChange}
|
|
92
|
+
placeholder="Enter your message"
|
|
93
|
+
rows={5}
|
|
94
|
+
/>
|
|
95
|
+
|
|
96
|
+
<Button>Submit</Button>
|
|
97
|
+
</Vertical>
|
|
98
|
+
</View>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export default ContactForm;
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Step 3: Add Form Submission Logic
|
|
106
|
+
|
|
107
|
+
Let's add form submission logic:
|
|
108
|
+
|
|
109
|
+
```jsx
|
|
110
|
+
import React, { useState } from 'react';
|
|
111
|
+
import { View, Vertical } from 'app-studio';
|
|
112
|
+
import { Text, Button, TextField, TextArea, Alert } from '@app-studio/web';
|
|
113
|
+
|
|
114
|
+
function ContactForm() {
|
|
115
|
+
const [formData, setFormData] = useState({
|
|
116
|
+
name: '',
|
|
117
|
+
email: '',
|
|
118
|
+
message: ''
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
122
|
+
const [submitStatus, setSubmitStatus] = useState(null);
|
|
123
|
+
|
|
124
|
+
const handleChange = (e) => {
|
|
125
|
+
const { name, value } = e.target;
|
|
126
|
+
setFormData({
|
|
127
|
+
...formData,
|
|
128
|
+
[name]: value
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const handleSubmit = (e) => {
|
|
133
|
+
e.preventDefault();
|
|
134
|
+
setIsSubmitting(true);
|
|
135
|
+
|
|
136
|
+
// Simulate API call
|
|
137
|
+
setTimeout(() => {
|
|
138
|
+
setIsSubmitting(false);
|
|
139
|
+
setSubmitStatus('success');
|
|
140
|
+
|
|
141
|
+
// Reset form after successful submission
|
|
142
|
+
setFormData({
|
|
143
|
+
name: '',
|
|
144
|
+
email: '',
|
|
145
|
+
message: ''
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// Clear success message after 3 seconds
|
|
149
|
+
setTimeout(() => {
|
|
150
|
+
setSubmitStatus(null);
|
|
151
|
+
}, 3000);
|
|
152
|
+
}, 1000);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<View padding={20} maxWidth={500} margin="0 auto">
|
|
157
|
+
<Vertical gap={20}>
|
|
158
|
+
<Text fontSize={24} fontWeight="bold">Contact Us</Text>
|
|
159
|
+
|
|
160
|
+
{submitStatus === 'success' && (
|
|
161
|
+
<Alert
|
|
162
|
+
variant="success"
|
|
163
|
+
title="Success"
|
|
164
|
+
description="Your message has been sent successfully!"
|
|
165
|
+
/>
|
|
166
|
+
)}
|
|
167
|
+
|
|
168
|
+
<form onSubmit={handleSubmit}>
|
|
169
|
+
<Vertical gap={20}>
|
|
170
|
+
<TextField
|
|
171
|
+
label="Name"
|
|
172
|
+
name="name"
|
|
173
|
+
value={formData.name}
|
|
174
|
+
onChange={handleChange}
|
|
175
|
+
placeholder="Enter your name"
|
|
176
|
+
isRequired
|
|
177
|
+
/>
|
|
178
|
+
|
|
179
|
+
<TextField
|
|
180
|
+
label="Email"
|
|
181
|
+
name="email"
|
|
182
|
+
type="email"
|
|
183
|
+
value={formData.email}
|
|
184
|
+
onChange={handleChange}
|
|
185
|
+
placeholder="Enter your email"
|
|
186
|
+
isRequired
|
|
187
|
+
/>
|
|
188
|
+
|
|
189
|
+
<TextArea
|
|
190
|
+
label="Message"
|
|
191
|
+
name="message"
|
|
192
|
+
value={formData.message}
|
|
193
|
+
onChange={handleChange}
|
|
194
|
+
placeholder="Enter your message"
|
|
195
|
+
rows={5}
|
|
196
|
+
isRequired
|
|
197
|
+
/>
|
|
198
|
+
|
|
199
|
+
<Button type="submit" isLoading={isSubmitting}>
|
|
200
|
+
Submit
|
|
201
|
+
</Button>
|
|
202
|
+
</Vertical>
|
|
203
|
+
</form>
|
|
204
|
+
</Vertical>
|
|
205
|
+
</View>
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export default ContactForm;
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Step 4: Add Form Validation
|
|
213
|
+
|
|
214
|
+
Let's add basic form validation:
|
|
215
|
+
|
|
216
|
+
```jsx
|
|
217
|
+
import React, { useState } from 'react';
|
|
218
|
+
import { View, Vertical } from 'app-studio';
|
|
219
|
+
import { Text, Button, TextField, TextArea, Alert } from '@app-studio/web';
|
|
220
|
+
|
|
221
|
+
function ContactForm() {
|
|
222
|
+
const [formData, setFormData] = useState({
|
|
223
|
+
name: '',
|
|
224
|
+
email: '',
|
|
225
|
+
message: ''
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
const [errors, setErrors] = useState({});
|
|
229
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
230
|
+
const [submitStatus, setSubmitStatus] = useState(null);
|
|
231
|
+
|
|
232
|
+
const handleChange = (e) => {
|
|
233
|
+
const { name, value } = e.target;
|
|
234
|
+
setFormData({
|
|
235
|
+
...formData,
|
|
236
|
+
[name]: value
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
// Clear error when field is edited
|
|
240
|
+
if (errors[name]) {
|
|
241
|
+
setErrors({
|
|
242
|
+
...errors,
|
|
243
|
+
[name]: ''
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
const validateForm = () => {
|
|
249
|
+
const newErrors = {};
|
|
250
|
+
|
|
251
|
+
if (!formData.name.trim()) {
|
|
252
|
+
newErrors.name = 'Name is required';
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (!formData.email.trim()) {
|
|
256
|
+
newErrors.email = 'Email is required';
|
|
257
|
+
} else if (!/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i.test(formData.email)) {
|
|
258
|
+
newErrors.email = 'Invalid email address';
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (!formData.message.trim()) {
|
|
262
|
+
newErrors.message = 'Message is required';
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
setErrors(newErrors);
|
|
266
|
+
return Object.keys(newErrors).length === 0;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
const handleSubmit = (e) => {
|
|
270
|
+
e.preventDefault();
|
|
271
|
+
|
|
272
|
+
if (!validateForm()) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
setIsSubmitting(true);
|
|
277
|
+
|
|
278
|
+
// Simulate API call
|
|
279
|
+
setTimeout(() => {
|
|
280
|
+
setIsSubmitting(false);
|
|
281
|
+
setSubmitStatus('success');
|
|
282
|
+
|
|
283
|
+
// Reset form after successful submission
|
|
284
|
+
setFormData({
|
|
285
|
+
name: '',
|
|
286
|
+
email: '',
|
|
287
|
+
message: ''
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
// Clear success message after 3 seconds
|
|
291
|
+
setTimeout(() => {
|
|
292
|
+
setSubmitStatus(null);
|
|
293
|
+
}, 3000);
|
|
294
|
+
}, 1000);
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
return (
|
|
298
|
+
<View padding={20} maxWidth={500} margin="0 auto">
|
|
299
|
+
<Vertical gap={20}>
|
|
300
|
+
<Text fontSize={24} fontWeight="bold">Contact Us</Text>
|
|
301
|
+
|
|
302
|
+
{submitStatus === 'success' && (
|
|
303
|
+
<Alert
|
|
304
|
+
variant="success"
|
|
305
|
+
title="Success"
|
|
306
|
+
description="Your message has been sent successfully!"
|
|
307
|
+
/>
|
|
308
|
+
)}
|
|
309
|
+
|
|
310
|
+
<form onSubmit={handleSubmit}>
|
|
311
|
+
<Vertical gap={20}>
|
|
312
|
+
<TextField
|
|
313
|
+
label="Name"
|
|
314
|
+
name="name"
|
|
315
|
+
value={formData.name}
|
|
316
|
+
onChange={handleChange}
|
|
317
|
+
placeholder="Enter your name"
|
|
318
|
+
isRequired
|
|
319
|
+
error={errors.name}
|
|
320
|
+
/>
|
|
321
|
+
|
|
322
|
+
<TextField
|
|
323
|
+
label="Email"
|
|
324
|
+
name="email"
|
|
325
|
+
type="email"
|
|
326
|
+
value={formData.email}
|
|
327
|
+
onChange={handleChange}
|
|
328
|
+
placeholder="Enter your email"
|
|
329
|
+
isRequired
|
|
330
|
+
error={errors.email}
|
|
331
|
+
/>
|
|
332
|
+
|
|
333
|
+
<TextArea
|
|
334
|
+
label="Message"
|
|
335
|
+
name="message"
|
|
336
|
+
value={formData.message}
|
|
337
|
+
onChange={handleChange}
|
|
338
|
+
placeholder="Enter your message"
|
|
339
|
+
rows={5}
|
|
340
|
+
isRequired
|
|
341
|
+
error={errors.message}
|
|
342
|
+
/>
|
|
343
|
+
|
|
344
|
+
<Button type="submit" isLoading={isSubmitting}>
|
|
345
|
+
Submit
|
|
346
|
+
</Button>
|
|
347
|
+
</Vertical>
|
|
348
|
+
</form>
|
|
349
|
+
</Vertical>
|
|
350
|
+
</View>
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export default ContactForm;
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
## Step 5 (Optional): Using Formik and Yup
|
|
358
|
+
|
|
359
|
+
For more advanced form handling, you can use Formik and Yup with the App Studio Web Component Library's Formik components:
|
|
360
|
+
|
|
361
|
+
```jsx
|
|
362
|
+
import React from 'react';
|
|
363
|
+
import { Formik, Form } from 'formik';
|
|
364
|
+
import * as Yup from 'yup';
|
|
365
|
+
import { View, Vertical } from 'app-studio';
|
|
366
|
+
import {
|
|
367
|
+
Text,
|
|
368
|
+
Button,
|
|
369
|
+
Alert,
|
|
370
|
+
FormikTextField,
|
|
371
|
+
FormikTextArea
|
|
372
|
+
} from '@app-studio/web';
|
|
373
|
+
|
|
374
|
+
// Validation schema
|
|
375
|
+
const validationSchema = Yup.object({
|
|
376
|
+
name: Yup.string().required('Name is required'),
|
|
377
|
+
email: Yup.string()
|
|
378
|
+
.email('Invalid email address')
|
|
379
|
+
.required('Email is required'),
|
|
380
|
+
message: Yup.string().required('Message is required')
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
function ContactForm() {
|
|
384
|
+
const handleSubmit = (values, { setSubmitting, resetForm, setStatus }) => {
|
|
385
|
+
// Simulate API call
|
|
386
|
+
setTimeout(() => {
|
|
387
|
+
setSubmitting(false);
|
|
388
|
+
setStatus({ success: true });
|
|
389
|
+
resetForm();
|
|
390
|
+
|
|
391
|
+
// Clear success message after 3 seconds
|
|
392
|
+
setTimeout(() => {
|
|
393
|
+
setStatus(null);
|
|
394
|
+
}, 3000);
|
|
395
|
+
}, 1000);
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
return (
|
|
399
|
+
<View padding={20} maxWidth={500} margin="0 auto">
|
|
400
|
+
<Vertical gap={20}>
|
|
401
|
+
<Text fontSize={24} fontWeight="bold">Contact Us</Text>
|
|
402
|
+
|
|
403
|
+
<Formik
|
|
404
|
+
initialValues={{ name: '', email: '', message: '' }}
|
|
405
|
+
validationSchema={validationSchema}
|
|
406
|
+
onSubmit={handleSubmit}
|
|
407
|
+
>
|
|
408
|
+
{({ isSubmitting, status }) => (
|
|
409
|
+
<Form>
|
|
410
|
+
<Vertical gap={20}>
|
|
411
|
+
{status?.success && (
|
|
412
|
+
<Alert
|
|
413
|
+
variant="success"
|
|
414
|
+
title="Success"
|
|
415
|
+
description="Your message has been sent successfully!"
|
|
416
|
+
/>
|
|
417
|
+
)}
|
|
418
|
+
|
|
419
|
+
<FormikTextField
|
|
420
|
+
name="name"
|
|
421
|
+
label="Name"
|
|
422
|
+
placeholder="Enter your name"
|
|
423
|
+
isRequired
|
|
424
|
+
/>
|
|
425
|
+
|
|
426
|
+
<FormikTextField
|
|
427
|
+
name="email"
|
|
428
|
+
label="Email"
|
|
429
|
+
type="email"
|
|
430
|
+
placeholder="Enter your email"
|
|
431
|
+
isRequired
|
|
432
|
+
/>
|
|
433
|
+
|
|
434
|
+
<FormikTextArea
|
|
435
|
+
name="message"
|
|
436
|
+
label="Message"
|
|
437
|
+
placeholder="Enter your message"
|
|
438
|
+
rows={5}
|
|
439
|
+
isRequired
|
|
440
|
+
/>
|
|
441
|
+
|
|
442
|
+
<Button type="submit" isLoading={isSubmitting}>
|
|
443
|
+
Submit
|
|
444
|
+
</Button>
|
|
445
|
+
</Vertical>
|
|
446
|
+
</Form>
|
|
447
|
+
)}
|
|
448
|
+
</Formik>
|
|
449
|
+
</Vertical>
|
|
450
|
+
</View>
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export default ContactForm;
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
## Complete Example
|
|
458
|
+
|
|
459
|
+
Here's the complete example using Formik and Yup:
|
|
460
|
+
|
|
461
|
+
```jsx
|
|
462
|
+
import React from 'react';
|
|
463
|
+
import { Formik, Form } from 'formik';
|
|
464
|
+
import * as Yup from 'yup';
|
|
465
|
+
import { View, Vertical } from 'app-studio';
|
|
466
|
+
import {
|
|
467
|
+
Text,
|
|
468
|
+
Button,
|
|
469
|
+
Alert,
|
|
470
|
+
FormikTextField,
|
|
471
|
+
FormikTextArea
|
|
472
|
+
} from '@app-studio/web';
|
|
473
|
+
|
|
474
|
+
// Validation schema
|
|
475
|
+
const validationSchema = Yup.object({
|
|
476
|
+
name: Yup.string().required('Name is required'),
|
|
477
|
+
email: Yup.string()
|
|
478
|
+
.email('Invalid email address')
|
|
479
|
+
.required('Email is required'),
|
|
480
|
+
message: Yup.string().required('Message is required')
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
function ContactForm() {
|
|
484
|
+
const handleSubmit = (values, { setSubmitting, resetForm, setStatus }) => {
|
|
485
|
+
// Simulate API call
|
|
486
|
+
setTimeout(() => {
|
|
487
|
+
console.log('Form values:', values);
|
|
488
|
+
setSubmitting(false);
|
|
489
|
+
setStatus({ success: true });
|
|
490
|
+
resetForm();
|
|
491
|
+
|
|
492
|
+
// Clear success message after 3 seconds
|
|
493
|
+
setTimeout(() => {
|
|
494
|
+
setStatus(null);
|
|
495
|
+
}, 3000);
|
|
496
|
+
}, 1000);
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
return (
|
|
500
|
+
<View padding={20} maxWidth={500} margin="0 auto" backgroundColor="color.white" borderRadius={8} boxShadow="0 2px 8px rgba(0, 0, 0, 0.1)">
|
|
501
|
+
<Vertical gap={20}>
|
|
502
|
+
<Text fontSize={24} fontWeight="bold" color="theme.primary">Contact Us</Text>
|
|
503
|
+
|
|
504
|
+
<Formik
|
|
505
|
+
initialValues={{ name: '', email: '', message: '' }}
|
|
506
|
+
validationSchema={validationSchema}
|
|
507
|
+
onSubmit={handleSubmit}
|
|
508
|
+
>
|
|
509
|
+
{({ isSubmitting, status }) => (
|
|
510
|
+
<Form>
|
|
511
|
+
<Vertical gap={20}>
|
|
512
|
+
{status?.success && (
|
|
513
|
+
<Alert
|
|
514
|
+
variant="success"
|
|
515
|
+
title="Success"
|
|
516
|
+
description="Your message has been sent successfully!"
|
|
517
|
+
/>
|
|
518
|
+
)}
|
|
519
|
+
|
|
520
|
+
<FormikTextField
|
|
521
|
+
name="name"
|
|
522
|
+
label="Name"
|
|
523
|
+
placeholder="Enter your name"
|
|
524
|
+
isRequired
|
|
525
|
+
/>
|
|
526
|
+
|
|
527
|
+
<FormikTextField
|
|
528
|
+
name="email"
|
|
529
|
+
label="Email"
|
|
530
|
+
type="email"
|
|
531
|
+
placeholder="Enter your email"
|
|
532
|
+
isRequired
|
|
533
|
+
/>
|
|
534
|
+
|
|
535
|
+
<FormikTextArea
|
|
536
|
+
name="message"
|
|
537
|
+
label="Message"
|
|
538
|
+
placeholder="Enter your message"
|
|
539
|
+
rows={5}
|
|
540
|
+
isRequired
|
|
541
|
+
/>
|
|
542
|
+
|
|
543
|
+
<Button type="submit" isLoading={isSubmitting} isFilled>
|
|
544
|
+
Submit
|
|
545
|
+
</Button>
|
|
546
|
+
</Vertical>
|
|
547
|
+
</Form>
|
|
548
|
+
)}
|
|
549
|
+
</Formik>
|
|
550
|
+
</Vertical>
|
|
551
|
+
</View>
|
|
552
|
+
);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
export default ContactForm;
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
## Next Steps
|
|
559
|
+
|
|
560
|
+
Now that you've created a simple form, you can:
|
|
561
|
+
|
|
562
|
+
- Add more form fields like `Select`, `Checkbox`, or `Radio`
|
|
563
|
+
- Implement more complex validation rules
|
|
564
|
+
- Connect the form to a real API endpoint
|
|
565
|
+
- Add form field groups and sections for more complex forms
|
|
566
|
+
- Explore the [Form Validation with Formik](../intermediate/form-validation-with-formik.md) tutorial for more advanced form handling
|
package/package.json
CHANGED