@object-ui/types
v3.0.3
Published
Pure TypeScript type definitions for Object UI - The Protocol Layer
Maintainers
Readme
@object-ui/types
Pure TypeScript type definitions for Object UI - The Protocol Layer.
Features
- 🎯 Complete Type Coverage - Every component has full TypeScript definitions
- 🏛️ Built on @objectstack/spec - Extends the universal UI component specification
- 📦 Minimal Dependencies - Only depends on @objectstack/spec (pure types)
- 🔌 Framework Agnostic - Use with React, Vue, or any framework
- 🌍 Backend Agnostic - Works with REST, GraphQL, ObjectQL, or local data
- 🎨 Tailwind Native - Designed for Tailwind CSS styling
- 📚 Comprehensive JSDoc - Every type is fully documented
Installation
npm install @object-ui/types
# or
yarn add @object-ui/types
# or
pnpm add @object-ui/typesImportant: This package depends on @objectstack/spec which provides the foundational protocol.
Architecture: The Inheritance Chain
Object UI follows a strict "Protocol First" approach with a clear inheritance hierarchy:
@objectstack/spec (v2.0.1) ← The "Highest Law" - Universal protocol
↓
UIComponent ← Base interface for all UI components
↓
BaseSchema (@object-ui/types) ← ObjectUI extensions (visibleOn, hiddenOn, etc.)
↓
Specific Schemas ← Component implementations (ChartSchema, etc.)
↓
@object-ui/core (Engine) ← Schema validation and expression evaluation
↓
@object-ui/react (Framework) ← React renderer
↓
@object-ui/components (UI) ← Shadcn/Tailwind implementationThis separation allows:
- ✅ Multiple UI implementations (Shadcn, Material, Ant Design)
- ✅ Multiple framework bindings (React, Vue, Svelte)
- ✅ Multiple backend adapters (REST, GraphQL, ObjectQL)
- ✅ Static analysis and validation without runtime dependencies
- ✅ Compliance with the ObjectStack ecosystem standards
Usage
Basic Example
import type { FormSchema, InputSchema, ButtonSchema } from '@object-ui/types';
const loginForm: FormSchema = {
type: 'form',
fields: [
{
name: 'email',
type: 'input',
inputType: 'email',
label: 'Email',
required: true,
},
{
name: 'password',
type: 'input',
inputType: 'password',
label: 'Password',
required: true,
}
],
submitLabel: 'Sign In'
};Advanced Example
import type { DataTableSchema, FlexSchema, CardSchema } from '@object-ui/types';
const dashboard: CardSchema = {
type: 'card',
title: 'User Management',
content: {
type: 'data-table',
columns: [
{ header: 'Name', accessorKey: 'name' },
{ header: 'Email', accessorKey: 'email' },
{ header: 'Role', accessorKey: 'role' }
],
data: [], // Connected to data source
pagination: true,
searchable: true,
selectable: true
}
};Type Narrowing
import type { AnySchema, SchemaByType } from '@object-ui/types';
function renderComponent(schema: AnySchema) {
if (schema.type === 'input') {
// TypeScript automatically narrows to InputSchema
console.log(schema.placeholder);
}
}
// Or use the utility type
type ButtonSchema = SchemaByType<'button'>;Type Categories
Base Types
Foundation types that all components build upon:
BaseSchema- The base interface for all componentsSchemaNode- Union type for schema nodes (objects, strings, numbers, etc.)ComponentMeta- Metadata for component registrationComponentInput- Input field definitions for designers/editors
Layout Components
Structure and organization:
ContainerSchema- Max-width containerFlexSchema- Flexbox layoutGridSchema- CSS Grid layoutCardSchema- Card containerTabsSchema- Tabbed interface
Form Components
User input and interaction:
FormSchema- Complete form with validationInputSchema- Text input fieldSelectSchema- Dropdown selectCheckboxSchema- Checkbox inputRadioGroupSchema- Radio button groupDatePickerSchema- Date selection- And 10+ more form components
Data Display Components
Information presentation:
DataTableSchema- Enterprise data table with sorting, filtering, paginationTableSchema- Simple tableListSchema- List with itemsChartSchema- Charts and graphsTreeViewSchema- Hierarchical treeTimelineSchema- Timeline visualization
Feedback Components
Status and progress:
LoadingSchema- Loading spinnerProgressSchema- Progress barSkeletonSchema- Loading placeholderToastSchema- Toast notifications
Overlay Components
Modals and popovers:
DialogSchema- Modal dialogSheetSchema- Side panel/drawerPopoverSchema- PopoverTooltipSchema- TooltipDropdownMenuSchema- Dropdown menu
Navigation Components
Menus and navigation:
HeaderBarSchema- Top navigation barSidebarSchema- Side navigationBreadcrumbSchema- Breadcrumb navigationPaginationSchema- Pagination controls
Complex Components
Advanced composite components:
KanbanSchema- Kanban boardCalendarViewSchema- Calendar with eventsFilterBuilderSchema- Advanced filter builderCarouselSchema- Image/content carouselChatbotSchema- Chat interface
Data Management
Backend integration:
DataSource- Universal data adapter interfaceQueryParams- Query parameters (OData-style)QueryResult- Paginated query resultsDataBinding- Data binding configuration
Design Principles
1. Protocol Agnostic
Types don't assume any specific backend:
interface DataSource<T = any> {
find(resource: string, params?: QueryParams): Promise<QueryResult<T>>;
create(resource: string, data: Partial<T>): Promise<T>;
// Works with REST, GraphQL, ObjectQL, or anything
}2. Tailwind Native
All components support className for Tailwind styling:
const button: ButtonSchema = {
type: 'button',
label: 'Click Me',
className: 'bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded'
};3. Type Safe
Full TypeScript support with discriminated unions:
type AnySchema =
| InputSchema
| ButtonSchema
| FormSchema
| /* 50+ more */;
function render(schema: AnySchema) {
switch (schema.type) {
case 'input': /* schema is InputSchema */ break;
case 'button': /* schema is ButtonSchema */ break;
}
}4. Composable
Components can nest indefinitely:
const page: FlexSchema = {
type: 'flex',
direction: 'col',
children: [
{ type: 'header-bar', title: 'My App' },
{
type: 'flex',
direction: 'row',
children: [
{ type: 'sidebar', nav: [...] },
{ type: 'container', children: [...] }
]
}
]
};Comparison
vs Amis Types
- ✅ Lighter - No runtime dependencies
- ✅ Tailwind Native - Built for Tailwind CSS
- ✅ Better TypeScript - Full type inference
- ✅ Framework Agnostic - Not tied to React
vs Formily Types
- ✅ Full Pages - Not just forms, entire UIs
- ✅ Simpler - More straightforward API
- ✅ Better Docs - Comprehensive JSDoc
Contributing
We follow these constraints for this package:
- ZERO runtime dependencies - Only TypeScript types
- No React imports - Framework agnostic
- Comprehensive JSDoc - Every property documented
- Protocol first - Types define the contract
License
MIT
