Skip to content

Commit a7882a4

Browse files
Copilothuangyiirene
andcommitted
Add comprehensive Form component with react-hook-form integration
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
1 parent a99e550 commit a7882a4

3 files changed

Lines changed: 463 additions & 1 deletion

File tree

apps/playground/src/data/examples.ts

Lines changed: 137 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,142 @@ export const examples = {
608608
]
609609
}`,
610610

611+
'airtable-form': `{
612+
"type": "div",
613+
"className": "max-w-4xl space-y-6",
614+
"body": [
615+
{
616+
"type": "div",
617+
"className": "space-y-2",
618+
"body": [
619+
{
620+
"type": "text",
621+
"content": "Airtable-Style Feature-Complete Form",
622+
"className": "text-3xl font-bold"
623+
},
624+
{
625+
"type": "text",
626+
"content": "A comprehensive form component with validation, multi-column layout, and conditional fields",
627+
"className": "text-muted-foreground"
628+
}
629+
]
630+
},
631+
{
632+
"type": "card",
633+
"className": "shadow-sm",
634+
"body": {
635+
"type": "form",
636+
"className": "p-6",
637+
"submitLabel": "Create Project",
638+
"cancelLabel": "Reset",
639+
"showCancel": true,
640+
"columns": 2,
641+
"validationMode": "onBlur",
642+
"resetOnSubmit": false,
643+
"defaultValues": {
644+
"projectType": "personal",
645+
"priority": "medium",
646+
"notifications": true
647+
},
648+
"fields": [
649+
{
650+
"name": "projectName",
651+
"label": "Project Name",
652+
"type": "input",
653+
"required": true,
654+
"placeholder": "Enter project name",
655+
"validation": {
656+
"minLength": {
657+
"value": 3,
658+
"message": "Project name must be at least 3 characters"
659+
}
660+
}
661+
},
662+
{
663+
"name": "projectType",
664+
"label": "Project Type",
665+
"type": "select",
666+
"required": true,
667+
"options": [
668+
{ "label": "Personal", "value": "personal" },
669+
{ "label": "Team", "value": "team" },
670+
{ "label": "Enterprise", "value": "enterprise" }
671+
]
672+
},
673+
{
674+
"name": "teamSize",
675+
"label": "Team Size",
676+
"type": "input",
677+
"inputType": "number",
678+
"placeholder": "Number of team members",
679+
"condition": {
680+
"field": "projectType",
681+
"in": ["team", "enterprise"]
682+
},
683+
"validation": {
684+
"min": {
685+
"value": 2,
686+
"message": "Team must have at least 2 members"
687+
}
688+
}
689+
},
690+
{
691+
"name": "budget",
692+
"label": "Budget",
693+
"type": "input",
694+
"inputType": "number",
695+
"placeholder": "Project budget",
696+
"condition": {
697+
"field": "projectType",
698+
"equals": "enterprise"
699+
}
700+
},
701+
{
702+
"name": "priority",
703+
"label": "Priority Level",
704+
"type": "select",
705+
"required": true,
706+
"options": [
707+
{ "label": "Low", "value": "low" },
708+
{ "label": "Medium", "value": "medium" },
709+
{ "label": "High", "value": "high" },
710+
{ "label": "Critical", "value": "critical" }
711+
]
712+
},
713+
{
714+
"name": "deadline",
715+
"label": "Deadline",
716+
"type": "input",
717+
"inputType": "date",
718+
"condition": {
719+
"field": "priority",
720+
"in": ["high", "critical"]
721+
}
722+
},
723+
{
724+
"name": "description",
725+
"label": "Project Description",
726+
"type": "textarea",
727+
"placeholder": "Describe your project goals and objectives",
728+
"validation": {
729+
"maxLength": {
730+
"value": 500,
731+
"message": "Description must not exceed 500 characters"
732+
}
733+
}
734+
},
735+
{
736+
"name": "notifications",
737+
"label": "Enable Notifications",
738+
"type": "checkbox",
739+
"description": "Receive updates about project progress"
740+
}
741+
]
742+
}
743+
}
744+
]
745+
}`,
746+
611747
'simple-page': `{
612748
"type": "div",
613749
"className": "space-y-4",
@@ -733,6 +869,6 @@ export type ExampleKey = keyof typeof examples;
733869
export const exampleCategories = {
734870
'Primitives': ['simple-page', 'input-states', 'button-variants'],
735871
'Layouts': ['grid-layout', 'dashboard', 'tabs-demo'],
736-
'Forms': ['form-demo'],
872+
'Forms': ['form-demo', 'airtable-form'],
737873
'Data Display': ['calendar-view']
738874
};

0 commit comments

Comments
 (0)