@thorprovider/storefront 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/README.md +333 -0
- package/assets/templates/app/app/[[...slug]]/page.tsx +17 -0
- package/assets/templates/app/app/[[...slug]]/renderer.tsx +10 -0
- package/assets/templates/app/app/globals.css +101 -0
- package/assets/templates/app/app/layout.tsx +35 -0
- package/assets/templates/app/lib/__STOREFRONT__/catalog.ts +88 -0
- package/assets/templates/app/lib/__STOREFRONT__/handlers.ts +42 -0
- package/assets/templates/app/lib/__STOREFRONT__/mappers.ts +47 -0
- package/assets/templates/app/lib/__STOREFRONT__/registry.tsx +98 -0
- package/assets/templates/app/lib/__STOREFRONT__/runtime.ts +17 -0
- package/assets/templates/app/lib/__STOREFRONT__/spec/index.ts +48 -0
- package/assets/templates/app/lib/__STOREFRONT__/spec/page-root.ts +26 -0
- package/assets/templates/app/lib/__STOREFRONT__/spec/types.ts +14 -0
- package/assets/templates/app/lib/__STOREFRONT__/state.ts +35 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/index.ts +7 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/faq.tsx +29 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/logoCloud.tsx +29 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/pricing.tsx +33 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/statistics.tsx +29 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/testimonials.tsx +28 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/types.ts +46 -0
- package/assets/templates/views/home/index.tsx +142 -0
- package/assets/templates/views/home/registry.tsx +65 -0
- package/bin/storefront.js +531 -0
- package/commands/sf-add-view.md +26 -0
- package/commands/sf-theme.md +20 -0
- package/commands/sf-view.md +25 -0
- package/package.json +48 -0
- package/recipes/archetype.schema.json +39 -0
- package/recipes/archetypes.json +148 -0
- package/recipes/recipe.schema.json +59 -0
- package/recipes/recipes.json +90 -0
- package/recipes/sections.json +46 -0
- package/recipes/validate.mjs +190 -0
- package/scripts/render-templates.mjs +255 -0
- package/scripts/sync-assets.mjs +87 -0
- package/skills/building-storefronts/SKILL.md +178 -0
- package/skills/building-storefronts/references/frontend-integration.md +229 -0
- package/skills/json-render-core/SKILL.md +291 -0
- package/skills/json-render-next/SKILL.md +194 -0
- package/skills/json-render-react/SKILL.md +298 -0
- package/skills/json-render-remotion/SKILL.md +111 -0
- package/skills/json-render-shadcn/SKILL.md +159 -0
- package/skills/json-render-solid/SKILL.md +204 -0
- package/skills/nextjs-shadcn/SKILL.md +367 -0
- package/skills/nextjs-shadcn/references/architecture.md +499 -0
- package/skills/nextjs-shadcn/references/project-setup.md +162 -0
- package/skills/nextjs-shadcn/references/shadcn-platform.md +261 -0
- package/skills/nextjs-shadcn/references/sidebar.md +274 -0
- package/skills/nextjs-shadcn/references/styling.md +555 -0
- package/skills/sf-theme-gen/SKILL.md +61 -0
- package/skills/sf-view-gen/SKILL.md +116 -0
- package/skills/sf-view-gen/assets/recipes/archetypes.json +148 -0
- package/skills/sf-view-gen/assets/recipes/recipes.json +90 -0
- package/skills/sf-view-gen/assets/recipes/sections.json +46 -0
- package/skills/sf-view-gen/assets/templates/views/category/index.tsx +86 -0
- package/skills/sf-view-gen/assets/templates/views/category/registry.tsx +48 -0
- package/skills/sf-view-gen/assets/templates/views/checkout/index.tsx +192 -0
- package/skills/sf-view-gen/assets/templates/views/checkout/registry.tsx +45 -0
- package/skills/sf-view-gen/assets/templates/views/product/index.tsx +122 -0
- package/skills/sf-view-gen/assets/templates/views/product/registry.tsx +49 -0
- package/skills/sf-view-gen/assets/templates/views/sections/faq.client.tsx +20 -0
- package/skills/sf-view-gen/assets/templates/views/sections/faq.tsx +21 -0
- package/skills/sf-view-gen/assets/templates/views/sections/logoCloud.client.tsx +18 -0
- package/skills/sf-view-gen/assets/templates/views/sections/logoCloud.tsx +21 -0
- package/skills/sf-view-gen/assets/templates/views/sections/pricing.client.tsx +20 -0
- package/skills/sf-view-gen/assets/templates/views/sections/pricing.tsx +23 -0
- package/skills/sf-view-gen/assets/templates/views/sections/statistics.client.tsx +18 -0
- package/skills/sf-view-gen/assets/templates/views/sections/statistics.tsx +21 -0
- package/skills/sf-view-gen/assets/templates/views/sections/testimonials.client.tsx +19 -0
- package/skills/sf-view-gen/assets/templates/views/sections/testimonials.tsx +19 -0
- package/skills/sf-view-gen/assets/templates/views/user-panel/index.tsx +168 -0
- package/skills/sf-view-gen/assets/templates/views/user-panel/registry.tsx +49 -0
- package/skills/sf-view-gen/references/views.md +69 -0
- package/skills/sf-view-gen/scripts/validate.mjs +190 -0
- package/skills/shadcn-component-discovery/SKILL.md +273 -0
- package/skills/shadcn-component-discovery/references/registries.md +226 -0
- package/skills/shadcn-theming/SKILL.md +104 -0
- package/skills/shadcn-theming/references/templates/theme-setup.md +109 -0
- package/skills/shadcn-theming/references/theming-guide.md +90 -0
- package/skills/storefront-best-practices/SKILL.md +421 -0
- package/skills/storefront-best-practices/reference/components/breadcrumbs.md +123 -0
- package/skills/storefront-best-practices/reference/components/cart-popup.md +189 -0
- package/skills/storefront-best-practices/reference/components/country-selector.md +298 -0
- package/skills/storefront-best-practices/reference/components/footer.md +112 -0
- package/skills/storefront-best-practices/reference/components/hero.md +241 -0
- package/skills/storefront-best-practices/reference/components/megamenu.md +239 -0
- package/skills/storefront-best-practices/reference/components/navbar.md +397 -0
- package/skills/storefront-best-practices/reference/components/popups.md +221 -0
- package/skills/storefront-best-practices/reference/components/product-card.md +125 -0
- package/skills/storefront-best-practices/reference/components/product-reviews.md +217 -0
- package/skills/storefront-best-practices/reference/components/product-slider.md +174 -0
- package/skills/storefront-best-practices/reference/components/search.md +101 -0
- package/skills/storefront-best-practices/reference/connecting-to-backend.md +391 -0
- package/skills/storefront-best-practices/reference/design.md +388 -0
- package/skills/storefront-best-practices/reference/features/promotions.md +307 -0
- package/skills/storefront-best-practices/reference/features/wishlist.md +230 -0
- package/skills/storefront-best-practices/reference/layouts/account.md +380 -0
- package/skills/storefront-best-practices/reference/layouts/cart.md +316 -0
- package/skills/storefront-best-practices/reference/layouts/checkout.md +486 -0
- package/skills/storefront-best-practices/reference/layouts/home-page.md +264 -0
- package/skills/storefront-best-practices/reference/layouts/order-confirmation.md +231 -0
- package/skills/storefront-best-practices/reference/layouts/product-details.md +527 -0
- package/skills/storefront-best-practices/reference/layouts/product-listing.md +520 -0
- package/skills/storefront-best-practices/reference/layouts/static-pages.md +356 -0
- package/skills/storefront-best-practices/reference/medusa.md +307 -0
- package/skills/storefront-best-practices/reference/mobile-responsiveness.md +183 -0
- package/skills/storefront-best-practices/reference/seo.md +195 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: shadcn
|
|
3
|
+
description: Pre-built shadcn/ui components for json-render. Use when working with @json-render/shadcn, adding standard UI components to a catalog, or building web UIs with Radix UI + Tailwind CSS components.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @json-render/shadcn
|
|
7
|
+
|
|
8
|
+
Pre-built shadcn/ui component definitions and implementations for json-render. Provides 36 components built on Radix UI + Tailwind CSS.
|
|
9
|
+
|
|
10
|
+
## Two Entry Points
|
|
11
|
+
|
|
12
|
+
| Entry Point | Exports | Use For |
|
|
13
|
+
|-------------|---------|---------|
|
|
14
|
+
| `@json-render/shadcn/catalog` | `shadcnComponentDefinitions` | Catalog schemas (no React dependency, safe for server) |
|
|
15
|
+
| `@json-render/shadcn` | `shadcnComponents` | React implementations |
|
|
16
|
+
|
|
17
|
+
## Usage Pattern
|
|
18
|
+
|
|
19
|
+
Pick the components you need from the standard definitions. Do not spread all definitions -- explicitly select what your app uses:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { defineCatalog } from "@json-render/core";
|
|
23
|
+
import { schema } from "@json-render/react/schema";
|
|
24
|
+
import { shadcnComponentDefinitions } from "@json-render/shadcn/catalog";
|
|
25
|
+
import { defineRegistry } from "@json-render/react";
|
|
26
|
+
import { shadcnComponents } from "@json-render/shadcn";
|
|
27
|
+
|
|
28
|
+
// Catalog: pick definitions
|
|
29
|
+
const catalog = defineCatalog(schema, {
|
|
30
|
+
components: {
|
|
31
|
+
Card: shadcnComponentDefinitions.Card,
|
|
32
|
+
Stack: shadcnComponentDefinitions.Stack,
|
|
33
|
+
Heading: shadcnComponentDefinitions.Heading,
|
|
34
|
+
Button: shadcnComponentDefinitions.Button,
|
|
35
|
+
Input: shadcnComponentDefinitions.Input,
|
|
36
|
+
},
|
|
37
|
+
actions: {},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Registry: pick matching implementations
|
|
41
|
+
const { registry } = defineRegistry(catalog, {
|
|
42
|
+
components: {
|
|
43
|
+
Card: shadcnComponents.Card,
|
|
44
|
+
Stack: shadcnComponents.Stack,
|
|
45
|
+
Heading: shadcnComponents.Heading,
|
|
46
|
+
Button: shadcnComponents.Button,
|
|
47
|
+
Input: shadcnComponents.Input,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
> State actions (`setState`, `pushState`, `removeState`) are built into the React schema and handled by `ActionProvider` automatically. No need to declare them.
|
|
53
|
+
|
|
54
|
+
## Extending with Custom Components
|
|
55
|
+
|
|
56
|
+
Add custom components alongside standard ones:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
const catalog = defineCatalog(schema, {
|
|
60
|
+
components: {
|
|
61
|
+
// Standard
|
|
62
|
+
Card: shadcnComponentDefinitions.Card,
|
|
63
|
+
Stack: shadcnComponentDefinitions.Stack,
|
|
64
|
+
|
|
65
|
+
// Custom
|
|
66
|
+
Metric: {
|
|
67
|
+
props: z.object({
|
|
68
|
+
label: z.string(),
|
|
69
|
+
value: z.string(),
|
|
70
|
+
trend: z.enum(["up", "down", "neutral"]).nullable(),
|
|
71
|
+
}),
|
|
72
|
+
description: "KPI metric display",
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
actions: {},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const { registry } = defineRegistry(catalog, {
|
|
79
|
+
components: {
|
|
80
|
+
Card: shadcnComponents.Card,
|
|
81
|
+
Stack: shadcnComponents.Stack,
|
|
82
|
+
Metric: ({ props }) => <div>{props.label}: {props.value}</div>,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Available Components
|
|
88
|
+
|
|
89
|
+
### Layout
|
|
90
|
+
- **Card** - Container with optional title, description, maxWidth, centered
|
|
91
|
+
- **Stack** - Flex container with direction, gap, align, justify
|
|
92
|
+
- **Grid** - Grid layout with columns (number) and gap
|
|
93
|
+
- **Separator** - Visual divider with orientation
|
|
94
|
+
|
|
95
|
+
### Navigation
|
|
96
|
+
- **Tabs** - Tabbed navigation with tabs array, defaultValue, value
|
|
97
|
+
- **Accordion** - Collapsible sections with items array and type (single/multiple)
|
|
98
|
+
- **Collapsible** - Single collapsible section with title
|
|
99
|
+
- **Pagination** - Page navigation with totalPages and page
|
|
100
|
+
|
|
101
|
+
### Overlay
|
|
102
|
+
- **Dialog** - Modal dialog with title, description, openPath
|
|
103
|
+
- **Drawer** - Bottom drawer with title, description, openPath
|
|
104
|
+
- **Tooltip** - Hover tooltip with content and text
|
|
105
|
+
- **Popover** - Click-triggered popover with trigger and content
|
|
106
|
+
- **DropdownMenu** - Dropdown with label and items array
|
|
107
|
+
|
|
108
|
+
### Content
|
|
109
|
+
- **Heading** - Heading text with level (h1-h4)
|
|
110
|
+
- **Text** - Paragraph with variant (body, caption, muted, lead, code)
|
|
111
|
+
- **Image** - Image with alt, width, height
|
|
112
|
+
- **Avatar** - User avatar with src, name, size
|
|
113
|
+
- **Badge** - Status badge with text and variant (default, secondary, destructive, outline)
|
|
114
|
+
- **Alert** - Alert banner with title, message, type (success, warning, info, error)
|
|
115
|
+
- **Carousel** - Scrollable carousel with items array
|
|
116
|
+
- **Table** - Data table with columns (string[]) and rows (string[][])
|
|
117
|
+
|
|
118
|
+
### Feedback
|
|
119
|
+
- **Progress** - Progress bar with value, max, label
|
|
120
|
+
- **Skeleton** - Loading placeholder with width, height, rounded
|
|
121
|
+
- **Spinner** - Loading spinner with size and label
|
|
122
|
+
|
|
123
|
+
### Input
|
|
124
|
+
- **Button** - Button with label, variant (primary, secondary, danger), disabled
|
|
125
|
+
- **Link** - Anchor link with label and href
|
|
126
|
+
- **Input** - Text input with label, name, type, placeholder, value, checks
|
|
127
|
+
- **Textarea** - Multi-line input with label, name, placeholder, rows, value, checks
|
|
128
|
+
- **Select** - Dropdown select with label, name, options (string[]), value, checks
|
|
129
|
+
- **Checkbox** - Checkbox with label, name, checked, checks, validateOn
|
|
130
|
+
- **Radio** - Radio group with label, name, options (string[]), value, checks, validateOn
|
|
131
|
+
- **Switch** - Toggle switch with label, name, checked, checks, validateOn
|
|
132
|
+
- **Slider** - Range slider with label, min, max, step, value
|
|
133
|
+
- **Toggle** - Toggle button with label, pressed, variant
|
|
134
|
+
- **ToggleGroup** - Group of toggles with items, type, value
|
|
135
|
+
- **ButtonGroup** - Button group with buttons array and selected
|
|
136
|
+
|
|
137
|
+
## Built-in Actions (from `@json-render/react`)
|
|
138
|
+
|
|
139
|
+
These are built into the React schema and handled by `ActionProvider` automatically. They appear in prompts without needing to be declared in the catalog.
|
|
140
|
+
|
|
141
|
+
- **setState** - Set a value at a state path (`{ statePath, value }`)
|
|
142
|
+
- **pushState** - Push a value onto an array (`{ statePath, value, clearStatePath? }`)
|
|
143
|
+
- **removeState** - Remove an array item by index (`{ statePath, index }`)
|
|
144
|
+
- **validateForm** - Validate all fields, write `{ valid, errors }` to state (`{ statePath? }`)
|
|
145
|
+
|
|
146
|
+
## Validation Timing (`validateOn`)
|
|
147
|
+
|
|
148
|
+
All form components support `validateOn` to control when validation runs:
|
|
149
|
+
- `"change"` — validate on every input change (default for Select, Checkbox, Radio, Switch)
|
|
150
|
+
- `"blur"` — validate when field loses focus (default for Input, Textarea)
|
|
151
|
+
- `"submit"` — validate only on form submission
|
|
152
|
+
|
|
153
|
+
## Important Notes
|
|
154
|
+
|
|
155
|
+
- The `/catalog` entry point has no React dependency -- use it for server-side prompt generation
|
|
156
|
+
- Components use Tailwind CSS classes -- your app must have Tailwind configured
|
|
157
|
+
- Component implementations use bundled shadcn/ui primitives (not your app's `components/ui/`)
|
|
158
|
+
- All form inputs support `checks` for validation (type + message pairs) and `validateOn` for timing
|
|
159
|
+
- Events: inputs emit `change`/`submit`/`focus`/`blur`; buttons emit `press`; selects emit `change`/`select`
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: solid
|
|
3
|
+
description: SolidJS renderer for json-render. Use when building @json-render/solid catalogs/registries, wiring Renderer providers, implementing bindings/actions, or troubleshooting Solid-specific reactivity patterns.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @json-render/solid
|
|
7
|
+
|
|
8
|
+
`@json-render/solid` renders json-render specs into Solid component trees with fine-grained reactivity.
|
|
9
|
+
|
|
10
|
+
## Quick Start
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import { Renderer, JSONUIProvider } from "@json-render/solid";
|
|
14
|
+
import type { Spec } from "@json-render/solid";
|
|
15
|
+
import { registry } from "./registry";
|
|
16
|
+
|
|
17
|
+
export function App(props: { spec: Spec | null }) {
|
|
18
|
+
return (
|
|
19
|
+
<JSONUIProvider registry={registry} initialState={{}}>
|
|
20
|
+
<Renderer spec={props.spec} registry={registry} />
|
|
21
|
+
</JSONUIProvider>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Create a Catalog
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { defineCatalog } from "@json-render/core";
|
|
30
|
+
import { schema } from "@json-render/solid/schema";
|
|
31
|
+
import { z } from "zod";
|
|
32
|
+
|
|
33
|
+
export const catalog = defineCatalog(schema, {
|
|
34
|
+
components: {
|
|
35
|
+
Button: {
|
|
36
|
+
props: z.object({
|
|
37
|
+
label: z.string(),
|
|
38
|
+
variant: z.enum(["primary", "secondary"]).nullable(),
|
|
39
|
+
}),
|
|
40
|
+
description: "Clickable button",
|
|
41
|
+
},
|
|
42
|
+
Card: {
|
|
43
|
+
props: z.object({ title: z.string() }),
|
|
44
|
+
description: "Card container",
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
actions: {
|
|
48
|
+
submit: { description: "Submit data" },
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Define Components
|
|
54
|
+
|
|
55
|
+
Components receive `ComponentRenderProps` from the renderer:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
interface ComponentRenderProps<P = Record<string, unknown>> {
|
|
59
|
+
element: UIElement<string, P>;
|
|
60
|
+
children?: JSX.Element;
|
|
61
|
+
emit: (event: string) => void;
|
|
62
|
+
on: (event: string) => EventHandle;
|
|
63
|
+
bindings?: Record<string, string>;
|
|
64
|
+
loading?: boolean;
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Example:
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
import type { BaseComponentProps } from "@json-render/solid";
|
|
72
|
+
|
|
73
|
+
export function Button(props: BaseComponentProps<{ label: string }>) {
|
|
74
|
+
return (
|
|
75
|
+
<button onClick={() => props.emit("press")}>{props.props.label}</button>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Create a Registry
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { defineRegistry } from "@json-render/solid";
|
|
84
|
+
import { catalog } from "./catalog";
|
|
85
|
+
import { Card } from "./Card";
|
|
86
|
+
import { Button } from "./Button";
|
|
87
|
+
|
|
88
|
+
const { registry, handlers, executeAction } = defineRegistry(catalog, {
|
|
89
|
+
components: {
|
|
90
|
+
Card,
|
|
91
|
+
Button,
|
|
92
|
+
},
|
|
93
|
+
actions: {
|
|
94
|
+
submit: async (params, setState, state) => {
|
|
95
|
+
// custom action logic
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Spec Structure
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"root": "card1",
|
|
106
|
+
"elements": {
|
|
107
|
+
"card1": {
|
|
108
|
+
"type": "Card",
|
|
109
|
+
"props": { "title": "Hello" },
|
|
110
|
+
"children": ["btn1"]
|
|
111
|
+
},
|
|
112
|
+
"btn1": {
|
|
113
|
+
"type": "Button",
|
|
114
|
+
"props": { "label": "Click me" },
|
|
115
|
+
"on": {
|
|
116
|
+
"press": { "action": "submit" }
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Providers
|
|
124
|
+
|
|
125
|
+
- `StateProvider`: state model read/write and controlled mode via `store`
|
|
126
|
+
- `VisibilityProvider`: evaluates `visible` conditions
|
|
127
|
+
- `ValidationProvider`: field validation + `validateForm` integration
|
|
128
|
+
- `ActionProvider`: runs built-in and custom actions
|
|
129
|
+
- `JSONUIProvider`: combined provider wrapper
|
|
130
|
+
|
|
131
|
+
## Hooks
|
|
132
|
+
|
|
133
|
+
- `useStateStore`, `useStateValue`, `useStateBinding`
|
|
134
|
+
- `useVisibility`, `useIsVisible`
|
|
135
|
+
- `useActions`, `useAction`
|
|
136
|
+
- `useValidation`, `useOptionalValidation`, `useFieldValidation`
|
|
137
|
+
- `useBoundProp`
|
|
138
|
+
- `useUIStream`, `useChatUI`
|
|
139
|
+
|
|
140
|
+
## Built-in Actions
|
|
141
|
+
|
|
142
|
+
Handled automatically by `ActionProvider`:
|
|
143
|
+
|
|
144
|
+
- `setState`
|
|
145
|
+
- `pushState`
|
|
146
|
+
- `removeState`
|
|
147
|
+
- `validateForm`
|
|
148
|
+
|
|
149
|
+
## Dynamic Props and Bindings
|
|
150
|
+
|
|
151
|
+
Nested lists can set `repeat.statePath` to `{ "$item": "field" }` inside an enclosing repeat.
|
|
152
|
+
|
|
153
|
+
Supported expression forms include:
|
|
154
|
+
|
|
155
|
+
- `{"$state": "/path"}`
|
|
156
|
+
- `{"$bindState": "/path"}`
|
|
157
|
+
- `{"$bindItem": "field"}`
|
|
158
|
+
- `{"$template": "Hi ${/user/name}"}`
|
|
159
|
+
- `{"$computed": "fn", "args": {...}}`
|
|
160
|
+
- `{"$cond": <condition>, "$then": <value>, "$else": <value>}`
|
|
161
|
+
|
|
162
|
+
Use `useBoundProp` in components for writable bound values:
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
import { useBoundProp } from "@json-render/solid";
|
|
166
|
+
|
|
167
|
+
function Input(props: BaseComponentProps<{ value?: string }>) {
|
|
168
|
+
const [value, setValue] = useBoundProp(
|
|
169
|
+
props.props.value,
|
|
170
|
+
props.bindings?.value,
|
|
171
|
+
);
|
|
172
|
+
return (
|
|
173
|
+
<input
|
|
174
|
+
value={String(value() ?? "")}
|
|
175
|
+
onInput={(e) => setValue(e.currentTarget.value)}
|
|
176
|
+
/>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
`useStateValue`, `useStateBinding`, and the `state` / `errors` / `isValid` fields from `useFieldValidation` are reactive accessors in Solid. Call them as functions inside JSX, `createMemo`, or `createEffect`.
|
|
182
|
+
|
|
183
|
+
## Solid Reactivity Rules
|
|
184
|
+
|
|
185
|
+
- Do not destructure component props in function signatures when values need to stay reactive.
|
|
186
|
+
- Keep changing reads inside JSX expressions, `createMemo`, or `createEffect`.
|
|
187
|
+
- Context values are exposed through getter-based objects so consumers always observe live signals.
|
|
188
|
+
|
|
189
|
+
## Streaming UI
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
import { useUIStream, Renderer } from "@json-render/solid";
|
|
193
|
+
|
|
194
|
+
const stream = useUIStream({ api: "/api/generate-ui" });
|
|
195
|
+
await stream.send("Create a support dashboard");
|
|
196
|
+
|
|
197
|
+
<Renderer
|
|
198
|
+
spec={stream.spec}
|
|
199
|
+
registry={registry}
|
|
200
|
+
loading={stream.isStreaming}
|
|
201
|
+
/>;
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Use `useChatUI` for chat + UI generation flows.
|