@delightui/components 0.1.105 → 0.1.107
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 +104 -1
- package/dist/cjs/components/molecules/Modal/DemoModal.d.ts +8 -0
- package/dist/cjs/components/molecules/Modal/ModalContext/ModalContext.d.ts +41 -0
- package/dist/cjs/components/molecules/Modal/ModalContext/ModalContext.types.d.ts +87 -0
- package/dist/cjs/components/molecules/Modal/ModalContext/index.d.ts +3 -0
- package/dist/cjs/components/molecules/Modal/ModalContext/useModal.d.ts +34 -0
- package/dist/cjs/components/molecules/Modal/index.d.ts +2 -0
- package/dist/cjs/components/molecules/index.d.ts +2 -0
- package/dist/cjs/library.css +19 -6
- package/dist/cjs/library.js +3 -3
- package/dist/cjs/library.js.map +1 -1
- package/dist/esm/components/molecules/Modal/DemoModal.d.ts +8 -0
- package/dist/esm/components/molecules/Modal/ModalContext/ModalContext.d.ts +41 -0
- package/dist/esm/components/molecules/Modal/ModalContext/ModalContext.types.d.ts +87 -0
- package/dist/esm/components/molecules/Modal/ModalContext/index.d.ts +3 -0
- package/dist/esm/components/molecules/Modal/ModalContext/useModal.d.ts +34 -0
- package/dist/esm/components/molecules/Modal/index.d.ts +2 -0
- package/dist/esm/components/molecules/index.d.ts +2 -0
- package/dist/esm/library.css +19 -6
- package/dist/esm/library.js +3 -3
- package/dist/esm/library.js.map +1 -1
- package/dist/index.d.ts +108 -2
- package/docs/README.md +264 -0
- package/docs/components/atoms/ActionImage.md +119 -0
- package/docs/components/atoms/Button.md +197 -0
- package/docs/components/atoms/Checkbox.md +299 -0
- package/docs/components/atoms/CheckboxItem.md +314 -0
- package/docs/components/atoms/Chip.md +380 -0
- package/docs/components/atoms/CustomToggle.md +270 -0
- package/docs/components/atoms/Icon.md +365 -0
- package/docs/components/atoms/IconButton.md +407 -0
- package/docs/components/atoms/Image.md +448 -0
- package/docs/components/atoms/Input.md +430 -0
- package/docs/components/atoms/ListItem.md +502 -0
- package/docs/components/atoms/Password.md +472 -0
- package/docs/components/atoms/RadioButton.md +614 -0
- package/docs/components/atoms/RadioButtonItem.md +588 -0
- package/docs/components/atoms/ResponsiveComponent.md +612 -0
- package/docs/components/atoms/SelectListItem.md +609 -0
- package/docs/components/atoms/Slider.md +605 -0
- package/docs/components/atoms/Spinner.md +605 -0
- package/docs/components/atoms/Text.md +463 -0
- package/docs/components/atoms/TextArea.md +670 -0
- package/docs/components/atoms/ToastNotification.md +668 -0
- package/docs/components/atoms/Toggle.md +737 -0
- package/docs/components/atoms/ToggleButton.md +751 -0
- package/docs/components/atoms/Tooltip.md +391 -0
- package/docs/components/molecules/Accordion.md +440 -0
- package/docs/components/molecules/AccordionGroup.md +547 -0
- package/docs/components/molecules/ActionCard.md +546 -0
- package/docs/components/molecules/Breadcrumb.md +403 -0
- package/docs/components/molecules/Breadcrumbs.md +485 -0
- package/docs/components/molecules/ButtonGroup.md +383 -0
- package/docs/components/molecules/Card.md +298 -0
- package/docs/components/molecules/ChipInput.md +646 -0
- package/docs/components/molecules/ContextMenu.md +768 -0
- package/docs/components/molecules/CustomTimeSelector.md +116 -0
- package/docs/components/molecules/DatePicker.md +516 -0
- package/docs/components/molecules/DateTimeSelector.md +166 -0
- package/docs/components/molecules/FormField.md +312 -0
- package/docs/components/molecules/Grid.md +577 -0
- package/docs/components/molecules/GridItem.md +834 -0
- package/docs/components/molecules/GridList.md +244 -0
- package/docs/components/molecules/List.md +485 -0
- package/docs/components/molecules/Modal.md +470 -0
- package/docs/components/molecules/ModalFooter.md +702 -0
- package/docs/components/molecules/ModalHeader.md +756 -0
- package/docs/components/molecules/ModalProvider.md +205 -0
- package/docs/components/molecules/Nav.md +530 -0
- package/docs/components/molecules/NavItem.md +572 -0
- package/docs/components/molecules/NavLink.md +499 -0
- package/docs/components/molecules/Option.md +521 -0
- package/docs/components/molecules/Pagination.md +592 -0
- package/docs/components/molecules/PaginationNumberField.md +722 -0
- package/docs/components/molecules/Popover.md +516 -0
- package/docs/components/molecules/ProgressBar.md +624 -0
- package/docs/components/molecules/RadioGroup.md +831 -0
- package/docs/components/molecules/RepeaterList.md +185 -0
- package/docs/components/molecules/Select.md +402 -0
- package/docs/components/molecules/SortableTrigger.md +82 -0
- package/docs/components/molecules/useModal.md +379 -0
- package/docs/components/organisms/Dropzone.md +346 -0
- package/docs/components/organisms/DropzoneClear.md +135 -0
- package/docs/components/organisms/DropzoneContent.md +216 -0
- package/docs/components/organisms/DropzoneFilename.md +191 -0
- package/docs/components/organisms/DropzoneSupportedFormats.md +184 -0
- package/docs/components/organisms/DropzoneTrigger.md +209 -0
- package/docs/components/organisms/Form.md +533 -0
- package/docs/components/organisms/SlideOutPanel.md +662 -0
- package/docs/components/organisms/TabContent.md +902 -0
- package/docs/components/organisms/TabItem.md +1091 -0
- package/docs/components/organisms/Table.md +611 -0
- package/docs/components/organisms/TableBody.md +679 -0
- package/docs/components/organisms/TableCell.md +482 -0
- package/docs/components/organisms/TableHeader.md +513 -0
- package/docs/components/organisms/TableHeaderCell.md +661 -0
- package/docs/components/organisms/TableRow.md +715 -0
- package/docs/components/organisms/Tabs.md +1330 -0
- package/docs/components/utils/ConditionalView.md +568 -0
- package/docs/components/utils/RenderStateView.md +726 -0
- package/docs/components/utils/WrapTextNodes.md +614 -0
- package/package.json +3 -2
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# DateTimeSelector
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
A Flatpickr plugin component that provides a combined date and time selection interface with a custom time input field and dropdown. It enhances the DatePicker component by adding a labeled time input section alongside the calendar, providing a comprehensive date-time selection experience.
|
|
6
|
+
|
|
7
|
+
## Aliases
|
|
8
|
+
|
|
9
|
+
- DateTimeSelector
|
|
10
|
+
- DateTimeDropdownPlugin
|
|
11
|
+
- DateTimePickerPlugin
|
|
12
|
+
- CombinedDateTimePicker
|
|
13
|
+
|
|
14
|
+
## Props Breakdown
|
|
15
|
+
|
|
16
|
+
**Type:** Flatpickr Plugin Function
|
|
17
|
+
|
|
18
|
+
| Prop | Type | Default | Required | Description |
|
|
19
|
+
|------|------|---------|----------|-------------|
|
|
20
|
+
| `config` | `CustomTimePickerConfig` | - | Yes | Configuration object for the date-time picker |
|
|
21
|
+
| `config.minuteStep` | `number` | `30` | No | Step interval for minute options in the time dropdown |
|
|
22
|
+
|
|
23
|
+
## Examples
|
|
24
|
+
|
|
25
|
+
### Basic Usage
|
|
26
|
+
```tsx
|
|
27
|
+
import { DatePicker } from '@delightui/components';
|
|
28
|
+
import dateTimeSelector from './Plugins/dateTimeSelector';
|
|
29
|
+
|
|
30
|
+
function DateTimePickerExample() {
|
|
31
|
+
return (
|
|
32
|
+
<DatePicker
|
|
33
|
+
plugins={[dateTimeSelector({ minuteStep: 15 })]}
|
|
34
|
+
enableTime={true}
|
|
35
|
+
dateFormat="m/d/Y h:i K"
|
|
36
|
+
placeholder="Select date and time"
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Different Time Intervals
|
|
43
|
+
```tsx
|
|
44
|
+
function TimeIntervalExample() {
|
|
45
|
+
return (
|
|
46
|
+
<div className="datetime-pickers">
|
|
47
|
+
{/* 5-minute intervals */}
|
|
48
|
+
<DatePicker
|
|
49
|
+
plugins={[dateTimeSelector({ minuteStep: 5 })]}
|
|
50
|
+
enableTime={true}
|
|
51
|
+
dateFormat="m/d/Y h:i K"
|
|
52
|
+
placeholder="Precise timing (5 min)"
|
|
53
|
+
/>
|
|
54
|
+
|
|
55
|
+
{/* 30-minute intervals */}
|
|
56
|
+
<DatePicker
|
|
57
|
+
plugins={[dateTimeSelector({ minuteStep: 30 })]}
|
|
58
|
+
enableTime={true}
|
|
59
|
+
dateFormat="m/d/Y h:i K"
|
|
60
|
+
placeholder="Standard timing (30 min)"
|
|
61
|
+
/>
|
|
62
|
+
|
|
63
|
+
{/* 60-minute intervals */}
|
|
64
|
+
<DatePicker
|
|
65
|
+
plugins={[dateTimeSelector({ minuteStep: 60 })]}
|
|
66
|
+
enableTime={true}
|
|
67
|
+
dateFormat="m/d/Y h:i K"
|
|
68
|
+
placeholder="Hourly timing"
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Event Scheduling
|
|
76
|
+
```tsx
|
|
77
|
+
import { Form, FormField, DatePicker } from '@delightui/components';
|
|
78
|
+
|
|
79
|
+
function EventSchedulingExample() {
|
|
80
|
+
const handleSubmit = (values) => {
|
|
81
|
+
console.log('Event details:', {
|
|
82
|
+
startTime: values.startDateTime,
|
|
83
|
+
endTime: values.endDateTime,
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<Form onSubmit={handleSubmit}>
|
|
89
|
+
<FormField
|
|
90
|
+
name="startDateTime"
|
|
91
|
+
label="Event Start"
|
|
92
|
+
required
|
|
93
|
+
>
|
|
94
|
+
<DatePicker
|
|
95
|
+
plugins={[dateTimeSelector({ minuteStep: 15 })]}
|
|
96
|
+
enableTime={true}
|
|
97
|
+
dateFormat="m/d/Y h:i K"
|
|
98
|
+
placeholder="Select start date and time"
|
|
99
|
+
/>
|
|
100
|
+
</FormField>
|
|
101
|
+
|
|
102
|
+
<FormField
|
|
103
|
+
name="endDateTime"
|
|
104
|
+
label="Event End"
|
|
105
|
+
required
|
|
106
|
+
>
|
|
107
|
+
<DatePicker
|
|
108
|
+
plugins={[dateTimeSelector({ minuteStep: 15 })]}
|
|
109
|
+
enableTime={true}
|
|
110
|
+
dateFormat="m/d/Y h:i K"
|
|
111
|
+
placeholder="Select end date and time"
|
|
112
|
+
/>
|
|
113
|
+
</FormField>
|
|
114
|
+
</Form>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Appointment Booking
|
|
120
|
+
```tsx
|
|
121
|
+
function AppointmentBookingExample() {
|
|
122
|
+
const [selectedDateTime, setSelectedDateTime] = useState('');
|
|
123
|
+
|
|
124
|
+
const handleDateTimeChange = (selectedDates) => {
|
|
125
|
+
if (selectedDates.length > 0) {
|
|
126
|
+
setSelectedDateTime(selectedDates[0].toLocaleString());
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<div className="appointment-booking">
|
|
132
|
+
<h3>Book Your Appointment</h3>
|
|
133
|
+
|
|
134
|
+
<DatePicker
|
|
135
|
+
plugins={[dateTimeSelector({ minuteStep: 30 })]}
|
|
136
|
+
enableTime={true}
|
|
137
|
+
dateFormat="m/d/Y h:i K"
|
|
138
|
+
placeholder="Select appointment date and time"
|
|
139
|
+
onChange={handleDateTimeChange}
|
|
140
|
+
minDate="today"
|
|
141
|
+
/>
|
|
142
|
+
|
|
143
|
+
{selectedDateTime && (
|
|
144
|
+
<div className="selected-time">
|
|
145
|
+
<p>Selected appointment: {selectedDateTime}</p>
|
|
146
|
+
</div>
|
|
147
|
+
)}
|
|
148
|
+
</div>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Range Date-Time Selection
|
|
154
|
+
```tsx
|
|
155
|
+
function RangeDateTimeExample() {
|
|
156
|
+
return (
|
|
157
|
+
<DatePicker
|
|
158
|
+
plugins={[dateTimeSelector({ minuteStep: 30 })]}
|
|
159
|
+
enableTime={true}
|
|
160
|
+
mode="range"
|
|
161
|
+
dateFormat="m/d/Y h:i K"
|
|
162
|
+
placeholder="Select date range with times"
|
|
163
|
+
/>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
```
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
# FormField
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
A form field wrapper component that provides consistent labeling, validation messaging, and styling for form inputs. Integrates seamlessly with the Form component to provide a complete form field experience with error handling, required field indicators, and accessibility features.
|
|
6
|
+
|
|
7
|
+
## Aliases
|
|
8
|
+
|
|
9
|
+
- FormField
|
|
10
|
+
- FieldWrapper
|
|
11
|
+
- InputWrapper
|
|
12
|
+
- FormGroup
|
|
13
|
+
- Field
|
|
14
|
+
|
|
15
|
+
## Props Breakdown
|
|
16
|
+
|
|
17
|
+
**Extends:** `HTMLAttributes<HTMLDivElement>`
|
|
18
|
+
|
|
19
|
+
| Prop | Type | Default | Required | Description |
|
|
20
|
+
|------|------|---------|----------|-------------|
|
|
21
|
+
| `name` | `string` | - | Yes | Name of the form field |
|
|
22
|
+
| `label` | `string` | - | No | Label for the form field |
|
|
23
|
+
| `children` | `ReactNode` | - | Yes | Form input component to wrap |
|
|
24
|
+
| `message` | `string` | - | No | Message for the form field |
|
|
25
|
+
| `hasMessage` | `boolean` | `false` | No | Whether there is a message/error for the field |
|
|
26
|
+
| `infoIcon` | `ReactNode` | - | No | Info icon for the form field |
|
|
27
|
+
| `required` | `boolean` | `false` | No | Whether the form field is required |
|
|
28
|
+
| `validate` | `FieldValidationFunction` | - | No | Validation function for the form field |
|
|
29
|
+
| `disabled` | `boolean` | `false` | No | Whether the form field is disabled |
|
|
30
|
+
| `invalid` | `boolean` | `false` | No | Whether the form field is invalid |
|
|
31
|
+
| `id` | `string` | - | No | ID for the form field |
|
|
32
|
+
|
|
33
|
+
Plus all standard HTML div attributes (className, style, onClick, etc.).
|
|
34
|
+
|
|
35
|
+
## Examples
|
|
36
|
+
|
|
37
|
+
### Basic Usage
|
|
38
|
+
```tsx
|
|
39
|
+
import { FormField, Input } from '@delightui/components';
|
|
40
|
+
|
|
41
|
+
function BasicExample() {
|
|
42
|
+
return (
|
|
43
|
+
<FormField name="email" label="Email Address">
|
|
44
|
+
<Input inputType="Email" placeholder="Enter your email" />
|
|
45
|
+
</FormField>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Required Field
|
|
51
|
+
```tsx
|
|
52
|
+
function RequiredFieldExample() {
|
|
53
|
+
return (
|
|
54
|
+
<FormField name="firstName" label="First Name" required>
|
|
55
|
+
<Input placeholder="Enter your first name" />
|
|
56
|
+
</FormField>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Field with Validation Message
|
|
62
|
+
```tsx
|
|
63
|
+
function ValidationMessageExample() {
|
|
64
|
+
const [email, setEmail] = useState('');
|
|
65
|
+
const [isValid, setIsValid] = useState(true);
|
|
66
|
+
|
|
67
|
+
const validateEmail = (value) => {
|
|
68
|
+
const valid = /\S+@\S+\.\S+/.test(value);
|
|
69
|
+
setIsValid(valid);
|
|
70
|
+
return valid;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<FormField
|
|
75
|
+
name="email"
|
|
76
|
+
label="Email Address"
|
|
77
|
+
required
|
|
78
|
+
invalid={!isValid}
|
|
79
|
+
message={!isValid ? "Please enter a valid email address" : ""}
|
|
80
|
+
>
|
|
81
|
+
<Input
|
|
82
|
+
inputType="Email"
|
|
83
|
+
value={email}
|
|
84
|
+
onValueChange={(value) => {
|
|
85
|
+
setEmail(value);
|
|
86
|
+
validateEmail(value);
|
|
87
|
+
}}
|
|
88
|
+
/>
|
|
89
|
+
</FormField>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Field with Info Icon
|
|
95
|
+
```tsx
|
|
96
|
+
function InfoIconExample() {
|
|
97
|
+
return (
|
|
98
|
+
<FormField
|
|
99
|
+
name="password"
|
|
100
|
+
label="Password"
|
|
101
|
+
required
|
|
102
|
+
infoIcon={
|
|
103
|
+
<Tooltip target={<Icon icon="Info" size="Small" />}>
|
|
104
|
+
Password must be at least 8 characters with uppercase, lowercase, and numbers
|
|
105
|
+
</Tooltip>
|
|
106
|
+
}
|
|
107
|
+
>
|
|
108
|
+
<Input inputType="Password" />
|
|
109
|
+
</FormField>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Disabled Field
|
|
115
|
+
```tsx
|
|
116
|
+
function DisabledFieldExample() {
|
|
117
|
+
return (
|
|
118
|
+
<FormField
|
|
119
|
+
name="username"
|
|
120
|
+
label="Username"
|
|
121
|
+
disabled
|
|
122
|
+
message="Username cannot be changed"
|
|
123
|
+
>
|
|
124
|
+
<Input value="john_doe" disabled />
|
|
125
|
+
</FormField>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Different Input Types
|
|
131
|
+
```tsx
|
|
132
|
+
function InputTypesExample() {
|
|
133
|
+
return (
|
|
134
|
+
<div className="form-fields">
|
|
135
|
+
<FormField name="name" label="Full Name" required>
|
|
136
|
+
<Input placeholder="Enter your name" />
|
|
137
|
+
</FormField>
|
|
138
|
+
|
|
139
|
+
<FormField name="bio" label="Biography">
|
|
140
|
+
<TextArea placeholder="Tell us about yourself" rows={4} />
|
|
141
|
+
</FormField>
|
|
142
|
+
|
|
143
|
+
<FormField name="country" label="Country" required>
|
|
144
|
+
<Select>
|
|
145
|
+
<Option value="us">United States</Option>
|
|
146
|
+
<Option value="uk">United Kingdom</Option>
|
|
147
|
+
<Option value="ca">Canada</Option>
|
|
148
|
+
</Select>
|
|
149
|
+
</FormField>
|
|
150
|
+
|
|
151
|
+
<FormField name="newsletter" label="Email Preferences">
|
|
152
|
+
<Checkbox>Subscribe to our newsletter</Checkbox>
|
|
153
|
+
</FormField>
|
|
154
|
+
|
|
155
|
+
<FormField name="plan" label="Subscription Plan" required>
|
|
156
|
+
<RadioGroup>
|
|
157
|
+
<RadioButton value="basic">Basic Plan</RadioButton>
|
|
158
|
+
<RadioButton value="premium">Premium Plan</RadioButton>
|
|
159
|
+
<RadioButton value="enterprise">Enterprise Plan</RadioButton>
|
|
160
|
+
</RadioGroup>
|
|
161
|
+
</FormField>
|
|
162
|
+
</div>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Custom Validation
|
|
168
|
+
```tsx
|
|
169
|
+
function CustomValidationExample() {
|
|
170
|
+
const validateAge = (setError, value) => {
|
|
171
|
+
if (!value) {
|
|
172
|
+
setError('Age is required');
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const age = parseInt(value);
|
|
177
|
+
if (isNaN(age) || age < 18 || age > 120) {
|
|
178
|
+
setError('Age must be between 18 and 120');
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return true;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<FormField
|
|
187
|
+
name="age"
|
|
188
|
+
label="Age"
|
|
189
|
+
required
|
|
190
|
+
validate={validateAge}
|
|
191
|
+
>
|
|
192
|
+
<Input inputType="Number" placeholder="Enter your age" />
|
|
193
|
+
</FormField>
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Form Integration
|
|
199
|
+
```tsx
|
|
200
|
+
function FormIntegrationExample() {
|
|
201
|
+
const handleSubmit = (values, setError) => {
|
|
202
|
+
console.log('Form values:', values);
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
<Form onSubmit={handleSubmit}>
|
|
207
|
+
<FormField name="firstName" label="First Name" required>
|
|
208
|
+
<Input />
|
|
209
|
+
</FormField>
|
|
210
|
+
|
|
211
|
+
<FormField name="lastName" label="Last Name" required>
|
|
212
|
+
<Input />
|
|
213
|
+
</FormField>
|
|
214
|
+
|
|
215
|
+
<FormField name="email" label="Email" required>
|
|
216
|
+
<Input inputType="Email" />
|
|
217
|
+
</FormField>
|
|
218
|
+
|
|
219
|
+
<FormField name="phone" label="Phone Number">
|
|
220
|
+
<Input inputType="Tel" />
|
|
221
|
+
</FormField>
|
|
222
|
+
|
|
223
|
+
<FormField name="message" label="Message">
|
|
224
|
+
<TextArea rows={4} />
|
|
225
|
+
</FormField>
|
|
226
|
+
|
|
227
|
+
<Button actionType="submit">Submit</Button>
|
|
228
|
+
</Form>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Conditional Fields
|
|
234
|
+
```tsx
|
|
235
|
+
function ConditionalFieldsExample() {
|
|
236
|
+
const [hasCompany, setHasCompany] = useState(false);
|
|
237
|
+
|
|
238
|
+
return (
|
|
239
|
+
<Form>
|
|
240
|
+
<FormField name="name" label="Full Name" required>
|
|
241
|
+
<Input />
|
|
242
|
+
</FormField>
|
|
243
|
+
|
|
244
|
+
<FormField name="hasCompany" label="Employment">
|
|
245
|
+
<Checkbox
|
|
246
|
+
checked={hasCompany}
|
|
247
|
+
onValueChange={setHasCompany}
|
|
248
|
+
>
|
|
249
|
+
I am employed by a company
|
|
250
|
+
</Checkbox>
|
|
251
|
+
</FormField>
|
|
252
|
+
|
|
253
|
+
{hasCompany && (
|
|
254
|
+
<>
|
|
255
|
+
<FormField name="companyName" label="Company Name" required>
|
|
256
|
+
<Input placeholder="Enter company name" />
|
|
257
|
+
</FormField>
|
|
258
|
+
|
|
259
|
+
<FormField name="jobTitle" label="Job Title" required>
|
|
260
|
+
<Input placeholder="Enter your job title" />
|
|
261
|
+
</FormField>
|
|
262
|
+
</>
|
|
263
|
+
)}
|
|
264
|
+
|
|
265
|
+
<Button actionType="submit">Submit</Button>
|
|
266
|
+
</Form>
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Field Groups
|
|
272
|
+
```tsx
|
|
273
|
+
function FieldGroupsExample() {
|
|
274
|
+
return (
|
|
275
|
+
<Form>
|
|
276
|
+
<div className="form-section">
|
|
277
|
+
<Text type="Heading5">Personal Information</Text>
|
|
278
|
+
|
|
279
|
+
<FormField name="firstName" label="First Name" required>
|
|
280
|
+
<Input />
|
|
281
|
+
</FormField>
|
|
282
|
+
|
|
283
|
+
<FormField name="lastName" label="Last Name" required>
|
|
284
|
+
<Input />
|
|
285
|
+
</FormField>
|
|
286
|
+
|
|
287
|
+
<FormField name="dateOfBirth" label="Date of Birth">
|
|
288
|
+
<DatePicker />
|
|
289
|
+
</FormField>
|
|
290
|
+
</div>
|
|
291
|
+
|
|
292
|
+
<div className="form-section">
|
|
293
|
+
<Text type="Heading5">Contact Information</Text>
|
|
294
|
+
|
|
295
|
+
<FormField name="email" label="Email" required>
|
|
296
|
+
<Input inputType="Email" />
|
|
297
|
+
</FormField>
|
|
298
|
+
|
|
299
|
+
<FormField name="phone" label="Phone">
|
|
300
|
+
<Input inputType="Tel" />
|
|
301
|
+
</FormField>
|
|
302
|
+
|
|
303
|
+
<FormField name="address" label="Address">
|
|
304
|
+
<TextArea rows={3} />
|
|
305
|
+
</FormField>
|
|
306
|
+
</div>
|
|
307
|
+
|
|
308
|
+
<Button actionType="submit">Save</Button>
|
|
309
|
+
</Form>
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
```
|