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