-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathobject-form.json
More file actions
214 lines (214 loc) · 8.47 KB
/
object-form.json
File metadata and controls
214 lines (214 loc) · 8.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
{
"type": "page",
"title": "Object Form - ObjectQL Components",
"body": [
{
"type": "div",
"className": "space-y-6 container mx-auto py-6 max-w-6xl",
"children": [
{
"type": "div",
"className": "space-y-2",
"children": [
{
"type": "text",
"value": "Object Form",
"className": "text-3xl font-bold tracking-tight"
},
{
"type": "text",
"value": "Auto-generates forms from ObjectQL object schemas. Supports create, edit, and view modes with automatic field generation and validation.",
"className": "text-lg text-muted-foreground"
}
]
},
{
"type": "separator",
"className": "my-6"
},
{
"type": "div",
"className": "space-y-6",
"children": [
{
"type": "card",
"title": "Create Mode",
"description": "ObjectForm in create mode - generates form fields from object schema for creating new records.",
"children": {
"type": "div",
"className": "space-y-4",
"children": [
{
"type": "alert",
"variant": "default",
"title": "Demo Mode",
"description": "This is a simulated example. In production, ObjectForm would connect to an ObjectQL backend, fetch object metadata, and submit data to the API.",
"className": "mb-4"
},
{
"type": "div",
"className": "p-4 bg-muted/50 rounded-lg font-mono text-sm",
"children": {
"type": "text",
"value": "const dataSource = new ObjectQLDataSource({\n baseUrl: 'https://api.example.com',\n token: 'your-auth-token'\n});\n\n<ObjectForm \n schema={{\n type: 'object-form',\n objectName: 'contacts',\n mode: 'create',\n onSuccess: (data) => console.log('Created:', data)\n }}\n dataSource={dataSource}\n/>",
"className": "whitespace-pre"
}
},
{
"type": "text",
"value": "Example Output:",
"className": "text-sm font-semibold mt-4"
},
{
"type": "form",
"layout": "vertical",
"submitLabel": "Create Contact",
"showCancel": true,
"fields": [
{
"name": "name",
"label": "Full Name",
"type": "input",
"required": true,
"placeholder": "John Doe"
},
{
"name": "email",
"label": "Email",
"type": "input",
"inputType": "email",
"required": true,
"placeholder": "john@example.com"
},
{
"name": "company",
"label": "Company",
"type": "input",
"placeholder": "Acme Corp"
},
{
"name": "status",
"label": "Status",
"type": "select",
"options": [
{ "label": "Active", "value": "active" },
{ "label": "Inactive", "value": "inactive" }
]
}
]
}
]
}
},
{
"type": "card",
"title": "Edit Mode",
"description": "ObjectForm in edit mode - fetches existing record data and allows updates.",
"children": {
"type": "div",
"className": "space-y-4",
"children": [
{
"type": "div",
"className": "p-4 bg-muted/50 rounded-lg font-mono text-sm",
"children": {
"type": "text",
"value": "<ObjectForm \n schema={{\n type: 'object-form',\n objectName: 'contacts',\n mode: 'edit',\n recordId: '12345',\n onSuccess: (data) => console.log('Updated:', data)\n }}\n dataSource={dataSource}\n/>",
"className": "whitespace-pre"
}
},
{
"type": "text",
"value": "Example Output:",
"className": "text-sm font-semibold mt-4"
},
{
"type": "form",
"layout": "vertical",
"submitLabel": "Update Contact",
"showCancel": true,
"defaultValues": {
"name": "Alice Johnson",
"email": "alice@example.com",
"company": "Tech Innovators",
"status": "active"
},
"fields": [
{
"name": "name",
"label": "Full Name",
"type": "input",
"required": true
},
{
"name": "email",
"label": "Email",
"type": "input",
"inputType": "email",
"required": true
},
{
"name": "company",
"label": "Company",
"type": "input"
},
{
"name": "status",
"label": "Status",
"type": "select",
"options": [
{ "label": "Active", "value": "active" },
{ "label": "Inactive", "value": "inactive" }
]
}
]
}
]
}
},
{
"type": "card",
"title": "Custom Field Configuration",
"description": "Specify which fields to include and override auto-generated configurations.",
"children": {
"type": "div",
"className": "space-y-4",
"children": [
{
"type": "div",
"className": "p-4 bg-muted/50 rounded-lg font-mono text-sm",
"children": {
"type": "text",
"value": "<ObjectForm \n schema={{\n type: 'object-form',\n objectName: 'users',\n mode: 'create',\n fields: ['username', 'email', 'role'],\n customFields: [\n {\n name: 'username',\n label: 'Username',\n placeholder: 'Choose a unique username'\n }\n ]\n }}\n dataSource={dataSource}\n/>",
"className": "whitespace-pre"
}
}
]
}
},
{
"type": "card",
"title": "Features",
"children": {
"type": "list",
"items": [
"Auto-fetches object metadata from ObjectQL using MetadataApiClient",
"Auto-generates form fields based on field definitions",
"Supports create, edit, and view modes",
"Fetches existing record data in edit/view modes",
"Handles form validation based on field schema",
"Submits data to ObjectQL backend automatically",
"Supports custom field configurations and overrides",
"Includes loading and error states",
"Full TypeScript support with ObjectFormSchema",
"Callback support for success and error handling"
]
}
}
]
}
]
}
],
"icon": "FileEdit"
}