|
| 1 | +# AI Generation Guide: Object UI |
| 2 | + |
| 3 | +**This document is optimized for LLMs.** Use this context to generate high-quality, bug-free Object UI JSON schemas. |
| 4 | + |
| 5 | +## 1. Core Mental Model |
| 6 | + |
| 7 | +* **You are a Schema Engine**: You do not write React code. You write **JSON** that describes a UI. |
| 8 | +* **Recursive Structure**: Every component is a node. `children` prop can contain arrays of other nodes. |
| 9 | +* **Tailwind Native**: Styling is done via `className`. Use standardized margins/padding (e.g., `p-4`, `gap-4`). |
| 10 | + |
| 11 | +## 2. The Enterprise Component Palette |
| 12 | + |
| 13 | +Use these strictly typed components. Do not hallucinate `type` names. |
| 14 | + |
| 15 | +### Layout (The Skeleton) |
| 16 | +* **`page`**: Top-level container. Properties: `title`, `body[]`. |
| 17 | +* **`grid`**: CSS Grid. Properties: `columns` (number), `gap` (number), `children[]`. |
| 18 | +* **`flex`**: Flexbox. Properties: `direction` ('row'|'col'), `gap`, `justify`, `align`, `children[]`. |
| 19 | +* **`card`**: Content container. Properties: `title`, `description`, `header` (node), `children` (body), `footer` (node). |
| 20 | +* **`tabs`**: Tabbed interface. Properties: `items: [{ label, value, content }]`. |
| 21 | +* **`resizable`**: Split pane. Properties: `direction`, `panels: [{ defaultSize, content }]`. |
| 22 | + |
| 23 | +### Form (The Input) |
| 24 | +* **`form`**: Data context wrapper. Properties: `mode` ('edit'|'read'), `layout`, `actions` (toolbar), `body[]`. **Crucial**: Inputs must be inside a form to bind data. |
| 25 | +* **`input`**: Text/Number. Properties: `name` (key), `label`, `inputType`, `required`, `colSpan` (grid width). |
| 26 | +* **`select`**: Dropdown. Properties: `name`, `label`, `options: [{ label, value }]`, `colSpan`. |
| 27 | +* **`date-picker`**: Date/Time. Properties: `name`, `label`, `mode`, `colSpan`. |
| 28 | +* **`checkbox` / `switch`**: Boolean. |
| 29 | +* **`upload`**: File handling. |
| 30 | + |
| 31 | +### Data (The Output) |
| 32 | +* **`data-table`**: Enterprise Grid. Properties: `data` (array), `toolbar`, `columns: [{ header, accessorKey, fixed, align, width, type }]`. |
| 33 | +* **`statistic`**: KPI Metrics. Properties: `label`, `value`, `trend`. |
| 34 | +* **`tag`** / **`badge`**: Status indicators. |
| 35 | + |
| 36 | +## 3. Golden Rules for Generation |
| 37 | + |
| 38 | +1. **Always use `name` in Inputs**: Without `name`, the form cannot save data. |
| 39 | +2. **Combine Layouts**: Don't just dump fields. Wrap them in `grid` -> `card` for structure. |
| 40 | +3. **Strict Types**: |
| 41 | + * `className` is always a STRING. |
| 42 | + * `children` is an ARRAY of objects. |
| 43 | +4. **Data Binding**: |
| 44 | + * In `table`, `field` matches the data key. |
| 45 | + * In `form`, `name` matches the submission key. |
| 46 | + |
| 47 | +## 4. One-Shot Examples |
| 48 | + |
| 49 | +### Scenario: CRM Customer Detail Page |
| 50 | +*Pattern: Header + Sidebar Layout + Tabbed Content* |
| 51 | + |
| 52 | +```json |
| 53 | +{ |
| 54 | + "type": "page", |
| 55 | + "title": "Customer: Acme Corp", |
| 56 | + "body": [ |
| 57 | + { |
| 58 | + "type": "grid", |
| 59 | + "columns": 12, |
| 60 | + "gap": 6, |
| 61 | + "children": [ |
| 62 | + { |
| 63 | + "type": "div", |
| 64 | + "className": "col-span-12 md:col-span-4", |
| 65 | + "children": [ |
| 66 | + { |
| 67 | + "type": "card", |
| 68 | + "title": "Contact Info", |
| 69 | + "children": [ |
| 70 | + { "type": "text", "value": "[email protected]", "className": "text-sm" }, |
| 71 | + { "type": "text", "value": "+1 555 0199", "className": "text-sm" } |
| 72 | + ] |
| 73 | + } |
| 74 | + ] |
| 75 | + }, |
| 76 | + { |
| 77 | + "type": "div", |
| 78 | + "className": "col-span-12 md:col-span-8", |
| 79 | + "children": [ |
| 80 | + { |
| 81 | + "type": "tabs", |
| 82 | + "defaultValue": "activity", |
| 83 | + "items": [ |
| 84 | + { |
| 85 | + "label": "Activity", |
| 86 | + "value": "activity", |
| 87 | + "content": { "type": "timeline", "items": [] } |
| 88 | + }, |
| 89 | + { |
| 90 | + "label": "Opportunities", |
| 91 | + "value": "opportunities", |
| 92 | + "content": { |
| 93 | + "type": "table", |
| 94 | + "columns": [ |
| 95 | + { "title": "Deal Name", "field": "name" }, |
| 96 | + { "title": "Amount", "field": "amount" } |
| 97 | + ] |
| 98 | + } |
| 99 | + } |
| 100 | + ] |
| 101 | + } |
| 102 | + ] |
| 103 | + } |
| 104 | + ] |
| 105 | + } |
| 106 | + ] |
| 107 | +} |
| 108 | +``` |
| 109 | + |
| 110 | +### Scenario: Enterprise Settings Form |
| 111 | +*Pattern: Card-based Sections + Form Context* |
| 112 | + |
| 113 | +```json |
| 114 | +{ |
| 115 | + "type": "form", |
| 116 | + "submitLabel": "Save Changes", |
| 117 | + "layout": "vertical", |
| 118 | + "body": [ |
| 119 | + { |
| 120 | + "type": "card", |
| 121 | + "title": "General Settings", |
| 122 | + "description": "Basic account configuration", |
| 123 | + "children": [ |
| 124 | + { |
| 125 | + "type": "grid", |
| 126 | + "columns": 2, |
| 127 | + "gap": 4, |
| 128 | + "children": [ |
| 129 | + { "type": "input", "name": "companyName", "label": "Company Name", "required": true }, |
| 130 | + { "type": "select", "name": "industry", "label": "Industry", "options": [{"label": "Tech", "value": "tech"}] } |
| 131 | + ] |
| 132 | + } |
| 133 | + ] |
| 134 | + }, |
| 135 | + { |
| 136 | + "type": "card", |
| 137 | + "title": "Notifications", |
| 138 | + "className": "mt-4", |
| 139 | + "children": [ |
| 140 | + { "type": "switch", "name": "emailAlerts", "label": "Email Alerts" }, |
| 141 | + { "type": "switch", "name": "smsAlerts", "label": "SMS Alerts" } |
| 142 | + ] |
| 143 | + } |
| 144 | + ] |
| 145 | +} |
| 146 | +``` |
0 commit comments