Skip to content

Commit 55d8df0

Browse files
Copilothuangyiirene
andcommitted
Add README files for core packages
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
1 parent 8105b62 commit 55d8df0

3 files changed

Lines changed: 375 additions & 0 deletions

File tree

packages/components/README.md

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# @object-ui/components
2+
3+
Standard UI component library for Object UI, built with Shadcn UI + Tailwind CSS.
4+
5+
## Features
6+
7+
- 🎨 **Tailwind Native** - Built entirely with Tailwind CSS utility classes
8+
- 🧩 **Shadcn UI** - Based on Radix UI primitives for accessibility
9+
- 📦 **50+ Components** - Complete set of UI components
10+
-**Accessible** - WCAG compliant components
11+
- 🎯 **Type-Safe** - Full TypeScript support
12+
- 🔌 **Extensible** - Easy to customize and extend
13+
14+
## Installation
15+
16+
```bash
17+
npm install @object-ui/components @object-ui/react @object-ui/core
18+
```
19+
20+
**Peer Dependencies:**
21+
- `react` ^18.0.0 || ^19.0.0
22+
- `react-dom` ^18.0.0 || ^19.0.0
23+
- `tailwindcss` ^3.0.0
24+
25+
## Setup
26+
27+
### 1. Configure Tailwind
28+
29+
Add to your `tailwind.config.js`:
30+
31+
```js
32+
module.exports = {
33+
content: [
34+
'./src/**/*.{js,jsx,ts,tsx}',
35+
'./node_modules/@object-ui/components/**/*.{js,ts,jsx,tsx}'
36+
],
37+
// ... your config
38+
}
39+
```
40+
41+
### 2. Import Styles
42+
43+
Add to your main CSS file:
44+
45+
```css
46+
@import '@object-ui/components/dist/style.css';
47+
```
48+
49+
### 3. Register Components
50+
51+
```tsx
52+
import { registerDefaultRenderers } from '@object-ui/components'
53+
54+
registerDefaultRenderers()
55+
```
56+
57+
## Usage
58+
59+
### With SchemaRenderer
60+
61+
```tsx
62+
import { SchemaRenderer } from '@object-ui/react'
63+
import { registerDefaultRenderers } from '@object-ui/components'
64+
65+
registerDefaultRenderers()
66+
67+
const schema = {
68+
type: 'card',
69+
title: 'Welcome',
70+
body: {
71+
type: 'text',
72+
value: 'Hello from Object UI!'
73+
}
74+
}
75+
76+
function App() {
77+
return <SchemaRenderer schema={schema} />
78+
}
79+
```
80+
81+
### Direct Import
82+
83+
You can also import UI components directly:
84+
85+
```tsx
86+
import { Button, Input, Card } from '@object-ui/components'
87+
88+
function MyComponent() {
89+
return (
90+
<Card>
91+
<Input placeholder="Enter text" />
92+
<Button>Submit</Button>
93+
</Card>
94+
)
95+
}
96+
```
97+
98+
## Available Components
99+
100+
### Form Components
101+
- `input` - Text input
102+
- `textarea` - Multi-line text
103+
- `select` - Dropdown select
104+
- `checkbox` - Checkbox
105+
- `radio` - Radio button
106+
- `date-picker` - Date selection
107+
- `switch` - Toggle switch
108+
109+
### Layout Components
110+
- `container` - Container wrapper
111+
- `grid` - Grid layout
112+
- `flex` - Flexbox layout
113+
- `card` - Card container
114+
- `tabs` - Tab navigation
115+
- `accordion` - Collapsible sections
116+
117+
### Data Display
118+
- `table` - Data table
119+
- `list` - List view
120+
- `badge` - Badge label
121+
- `avatar` - User avatar
122+
- `progress` - Progress bar
123+
124+
### Feedback
125+
- `alert` - Alert messages
126+
- `toast` - Toast notifications
127+
- `dialog` - Modal dialog
128+
- `popover` - Popover overlay
129+
130+
### Navigation
131+
- `button` - Button component
132+
- `link` - Link component
133+
- `breadcrumb` - Breadcrumb navigation
134+
135+
## Customization
136+
137+
### Override Styles
138+
139+
All components accept `className` for Tailwind classes:
140+
141+
```json
142+
{
143+
"type": "button",
144+
"label": "Click Me",
145+
"className": "bg-blue-500 hover:bg-blue-700 text-white"
146+
}
147+
```
148+
149+
### Custom Components
150+
151+
Register your own components:
152+
153+
```tsx
154+
import { registerRenderer } from '@object-ui/react'
155+
import { Button } from '@object-ui/components'
156+
157+
function CustomButton(props) {
158+
return <Button {...props} className="my-custom-style" />
159+
}
160+
161+
registerRenderer('custom-button', CustomButton)
162+
```
163+
164+
## API Reference
165+
166+
See [full documentation](https://objectui.org/api/components) for detailed API reference.
167+
168+
## License
169+
170+
MIT

packages/core/README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# @object-ui/core
2+
3+
Core logic, types, and validation for Object UI. Zero React dependencies.
4+
5+
## Features
6+
7+
- 🎯 **Type Definitions** - Complete TypeScript schemas for all components
8+
- 🔍 **Component Registry** - Framework-agnostic component registration system
9+
- 📊 **Data Scope** - Data scope management and expression evaluation
10+
-**Validation** - Zod-based schema validation
11+
- 🚀 **Zero React** - Can run in Node.js or any JavaScript environment
12+
13+
## Installation
14+
15+
```bash
16+
npm install @object-ui/core
17+
```
18+
19+
## Usage
20+
21+
### Type Definitions
22+
23+
```typescript
24+
import type {
25+
PageSchema,
26+
FormSchema,
27+
InputSchema,
28+
BaseSchema
29+
} from '@object-ui/core'
30+
31+
const mySchema: PageSchema = {
32+
type: 'page',
33+
title: 'My Page',
34+
body: []
35+
}
36+
```
37+
38+
### Component Registry
39+
40+
```typescript
41+
import { ComponentRegistry } from '@object-ui/core'
42+
43+
const registry = new ComponentRegistry()
44+
registry.register('button', buttonMetadata)
45+
const metadata = registry.get('button')
46+
```
47+
48+
### Data Scope
49+
50+
```typescript
51+
import { DataScope } from '@object-ui/core'
52+
53+
const scope = new DataScope({
54+
user: { name: 'John', role: 'admin' }
55+
})
56+
57+
const userName = scope.get('user.name') // 'John'
58+
const isAdmin = scope.evaluate('${user.role === "admin"}') // true
59+
```
60+
61+
## Philosophy
62+
63+
This package is designed to be **framework-agnostic**. It contains:
64+
65+
- ✅ Pure TypeScript types and interfaces
66+
- ✅ Core logic and utilities
67+
- ✅ Validation schemas
68+
- ❌ NO React components
69+
- ❌ NO UI rendering logic
70+
- ❌ NO framework dependencies
71+
72+
This allows the core types and logic to be used in:
73+
- Build tools and CLI utilities
74+
- Backend validation
75+
- Code generators
76+
- Alternative framework adapters (Vue, Svelte, etc.)
77+
78+
## API Reference
79+
80+
See [full documentation](https://objectui.org/api/core) for detailed API reference.
81+
82+
## License
83+
84+
MIT

packages/react/README.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# @object-ui/react
2+
3+
React bindings and SchemaRenderer component for Object UI.
4+
5+
## Features
6+
7+
- ⚛️ **SchemaRenderer** - Main component for rendering Object UI schemas
8+
- 🪝 **React Hooks** - Hooks for accessing renderer context
9+
- 🔄 **Context Providers** - React Context for state management
10+
- 📦 **Tree-Shakable** - Import only what you need
11+
12+
## Installation
13+
14+
```bash
15+
npm install @object-ui/react @object-ui/core
16+
```
17+
18+
**Peer Dependencies:**
19+
- `react` ^18.0.0 || ^19.0.0
20+
- `react-dom` ^18.0.0 || ^19.0.0
21+
22+
## Usage
23+
24+
### Basic Example
25+
26+
```tsx
27+
import { SchemaRenderer } from '@object-ui/react'
28+
29+
const schema = {
30+
type: 'text',
31+
value: 'Hello, Object UI!'
32+
}
33+
34+
function App() {
35+
return <SchemaRenderer schema={schema} />
36+
}
37+
```
38+
39+
### With Data
40+
41+
```tsx
42+
import { SchemaRenderer } from '@object-ui/react'
43+
44+
const schema = {
45+
type: 'form',
46+
body: [
47+
{
48+
type: 'input',
49+
name: 'name',
50+
label: 'Name',
51+
value: '${user.name}'
52+
}
53+
]
54+
}
55+
56+
const data = {
57+
user: { name: 'John Doe' }
58+
}
59+
60+
function App() {
61+
return <SchemaRenderer schema={schema} data={data} />
62+
}
63+
```
64+
65+
### Handling Actions
66+
67+
```tsx
68+
import { SchemaRenderer } from '@object-ui/react'
69+
70+
function App() {
71+
const handleSubmit = (data) => {
72+
console.log('Form submitted:', data)
73+
}
74+
75+
return (
76+
<SchemaRenderer
77+
schema={formSchema}
78+
onSubmit={handleSubmit}
79+
/>
80+
)
81+
}
82+
```
83+
84+
## Hooks
85+
86+
### useSchemaContext
87+
88+
Access the current schema context:
89+
90+
```tsx
91+
import { useSchemaContext } from '@object-ui/react'
92+
93+
function MyComponent() {
94+
const { data, updateData } = useSchemaContext()
95+
96+
return <div>{data.value}</div>
97+
}
98+
```
99+
100+
### useRegistry
101+
102+
Access the component registry:
103+
104+
```tsx
105+
import { useRegistry } from '@object-ui/react'
106+
107+
function MyComponent() {
108+
const registry = useRegistry()
109+
const Component = registry.get('button')
110+
111+
return <Component {...props} />
112+
}
113+
```
114+
115+
## API Reference
116+
117+
See [full documentation](https://objectui.org/api/react) for detailed API reference.
118+
119+
## License
120+
121+
MIT

0 commit comments

Comments
 (0)