Re-export JSON UI hooks

This commit is contained in:
2026-01-18 01:41:27 +00:00
parent e033b032a1
commit 671a99d30b
5 changed files with 18 additions and 3 deletions

View File

@@ -46,7 +46,7 @@ Replaced all imports of `@github/spark/hooks` with the local `@/hooks/use-kv` im
### Config Files
- `src/config/orchestration/data-source-manager.ts`
- `src/lib/json-ui/hooks.ts`
- `src/lib/json-ui/hooks.ts` (re-exported via `@/lib/json-ui`)
## Change Pattern
All instances of:

View File

@@ -27,7 +27,7 @@ Successfully implemented a comprehensive JSON-driven UI system that allows build
- Array looping for lists
- Form rendering with validation
- **hooks.ts**: React hooks for data management
- **hooks.ts**: React hooks for data management (import from `@/lib/json-ui`)
- `useJSONDataSource`: Single data source management (KV, API, static, computed)
- `useJSONDataSources`: Multiple data sources orchestration
- `useJSONActions`: Action registration and execution

View File

@@ -275,6 +275,12 @@ registerComponent('MyCustom', MyCustomComponent)
### Add Custom Data Source Types
Use the public entrypoint when consuming JSON UI hooks:
```typescript
import { useJSONDataSource, useJSONDataSources, useJSONActions } from '@/lib/json-ui'
```
Edit `/src/lib/json-ui/hooks.ts` to add new data source handlers.
### Add Custom Actions
@@ -296,7 +302,7 @@ const handleAction = (handler: EventHandler, event?: any) => {
- **Schema Definitions**: `/src/lib/json-ui/schema.ts`
- **Component Registry**: `/src/lib/json-ui/component-registry.ts`
- **Renderer**: `/src/lib/json-ui/renderer.tsx`
- **Hooks**: `/src/lib/json-ui/hooks.ts`
- **Hooks**: Import from `@/lib/json-ui` (source: `/src/lib/json-ui/hooks.ts`)
- **Utils**: `/src/lib/json-ui/utils.ts`
- **Examples**: `/src/config/ui-examples/`
- **Demo Page**: `/src/components/JSONUIShowcase.tsx`

View File

@@ -226,6 +226,14 @@ const component: UIComponent = {
}
```
### Hooks
Consume JSON UI data hooks from the public entrypoint:
```typescript
import { useJSONDataSource, useJSONDataSources, useJSONActions } from '@/lib/json-ui'
```
## 📦 Exports
```typescript

View File

@@ -1,5 +1,6 @@
export { JSONUIRenderer, JSONFormRenderer } from './renderer'
export { getUIComponent, uiComponentRegistry, registerComponent } from './component-registry'
export * from './hooks'
export * from './schema'
export * from './utils'
export * from './validator'