@xmachines/json-render-react 0.19.0-xm.3 → 0.20.0-xm.2

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/README.md CHANGED
@@ -67,9 +67,7 @@ export const { registry } = defineRegistry(catalog, {
67
67
  </div>
68
68
  ),
69
69
  Button: ({ props, emit }) => (
70
- <button onClick={() => emit("press")}>
71
- {props.label}
72
- </button>
70
+ <button onClick={() => emit("press")}>{props.label}</button>
73
71
  ),
74
72
  Input: ({ props, bindings }) => {
75
73
  const [value, setValue] = useBoundProp(props.value, bindings?.value);
@@ -97,9 +95,11 @@ import { registry } from "./registry";
97
95
  function App({ spec }) {
98
96
  return (
99
97
  <StateProvider initialState={{ form: { name: "" } }}>
100
- <ActionProvider handlers={{
101
- submit: () => console.log("Submit"),
102
- }}>
98
+ <ActionProvider
99
+ handlers={{
100
+ submit: () => console.log("Submit"),
101
+ }}
102
+ >
103
103
  <Renderer spec={spec} registry={registry} />
104
104
  </ActionProvider>
105
105
  </StateProvider>
@@ -113,19 +113,22 @@ The React renderer uses a flat element map format:
113
113
 
114
114
  ```typescript
115
115
  interface Spec {
116
- root: string; // Key of the root element
117
- elements: Record<string, UIElement>; // Flat map of elements by key
118
- state?: Record<string, unknown>; // Optional initial state
116
+ root: string; // Key of the root element
117
+ elements: Record<string, UIElement>; // Flat map of elements by key
118
+ state?: Record<string, unknown>; // Optional initial state
119
119
  }
120
120
 
121
121
  interface UIElement {
122
- type: string; // Component name from catalog
123
- props: Record<string, unknown>; // Component props
124
- children?: string[]; // Keys of child elements
125
- visible?: VisibilityCondition; // Visibility condition
122
+ type: string; // Component name from catalog
123
+ props: Record<string, unknown>; // Component props
124
+ children?: string[]; // Keys of child elements
125
+ slots?: Record<string, string[]>; // Named slots mapped to child keys
126
+ visible?: VisibilityCondition; // Visibility condition
126
127
  }
127
128
  ```
128
129
 
130
+ The `slots` element field is a React renderer feature. Other renderer packages may only use catalog slot declarations for default children.
131
+
129
132
  Example spec:
130
133
 
131
134
  ```json
@@ -163,11 +166,11 @@ Share data across components with JSON Pointer paths:
163
166
  ```tsx
164
167
  <StateProvider initialState={{ user: { name: "John" } }}>
165
168
  {children}
166
- </StateProvider>
169
+ </StateProvider>;
167
170
 
168
171
  // In components:
169
172
  const { state, get, set } = useStateStore();
170
- const name = get("/user/name"); // "John"
173
+ const name = get("/user/name"); // "John"
171
174
  set("/user/age", 25);
172
175
  ```
173
176
 
@@ -181,9 +184,7 @@ import { createStateStore, type StateStore } from "@xmachines/json-render-react"
181
184
  // Option 1: Use the built-in store outside of React
182
185
  const store = createStateStore({ count: 0 });
183
186
 
184
- <StateProvider store={store}>
185
- {children}
186
- </StateProvider>
187
+ <StateProvider store={store}>{children}</StateProvider>;
187
188
 
188
189
  // Mutate from anywhere — React will re-render automatically:
189
190
  store.set("/count", 1);
@@ -191,8 +192,14 @@ store.set("/count", 1);
191
192
  // Option 2: Implement the StateStore interface with your own backend
192
193
  const zustandStore: StateStore = {
193
194
  get: (path) => getByPath(useStore.getState(), path),
194
- set: (path, value) => useStore.setState(prev => { /* ... */ }),
195
- update: (updates) => useStore.setState(prev => { /* ... */ }),
195
+ set: (path, value) =>
196
+ useStore.setState((prev) => {
197
+ /* ... */
198
+ }),
199
+ update: (updates) =>
200
+ useStore.setState((prev) => {
201
+ /* ... */
202
+ }),
196
203
  getSnapshot: () => useStore.getState(),
197
204
  subscribe: (listener) => useStore.subscribe(listener),
198
205
  };
@@ -237,9 +244,7 @@ Control element visibility based on data:
237
244
  Add field validation:
238
245
 
239
246
  ```tsx
240
- <ValidationProvider>
241
- {children}
242
- </ValidationProvider>
247
+ <ValidationProvider>{children}</ValidationProvider>;
243
248
 
244
249
  // Use validation hooks:
245
250
  const { errors, validate } = useFieldValidation("/form/email", {
@@ -252,17 +257,17 @@ const { errors, validate } = useFieldValidation("/form/email", {
252
257
 
253
258
  ## Hooks
254
259
 
255
- | Hook | Purpose |
256
- |------|---------|
257
- | `useStateStore()` | Access state context (`state`, `get`, `set`, `update`) |
258
- | `useStateValue(path)` | Get single value from state |
259
- | `useStateBinding(path)` | Two-way data binding (returns `[value, setValue]`) |
260
- | `useIsVisible(condition)` | Check if a visibility condition is met |
261
- | `useActions()` | Access action context |
262
- | `useAction(name)` | Get a single action dispatch function |
263
- | `useFieldValidation(path, config)` | Field validation state |
264
- | `useOptionalValidation()` | Non-throwing validation context (returns `null` if no provider) |
265
- | `useUIStream(options)` | Stream specs from an API endpoint |
260
+ | Hook | Purpose |
261
+ | ---------------------------------- | --------------------------------------------------------------- |
262
+ | `useStateStore()` | Access state context (`state`, `get`, `set`, `update`) |
263
+ | `useStateValue(path)` | Get single value from state |
264
+ | `useStateBinding(path)` | Two-way data binding (returns `[value, setValue]`) |
265
+ | `useIsVisible(condition)` | Check if a visibility condition is met |
266
+ | `useActions()` | Access action context |
267
+ | `useAction(name)` | Get a single action dispatch function |
268
+ | `useFieldValidation(path, config)` | Field validation state |
269
+ | `useOptionalValidation()` | Non-throwing validation context (returns `null` if no provider) |
270
+ | `useUIStream(options)` | Stream specs from an API endpoint |
266
271
 
267
272
  ## Visibility Conditions
268
273
 
@@ -296,13 +301,13 @@ TypeScript helpers from `@xmachines/json-render-core`:
296
301
  ```typescript
297
302
  import { visibility } from "@xmachines/json-render-core";
298
303
 
299
- visibility.when("/path") // { $state: "/path" }
300
- visibility.unless("/path") // { $state: "/path", not: true }
301
- visibility.eq("/path", val) // { $state: "/path", eq: val }
302
- visibility.neq("/path", val) // { $state: "/path", neq: val }
303
- visibility.and(cond1, cond2) // { $and: [cond1, cond2] }
304
- visibility.always // true
305
- visibility.never // false
304
+ visibility.when("/path"); // { $state: "/path" }
305
+ visibility.unless("/path"); // { $state: "/path", not: true }
306
+ visibility.eq("/path", val); // { $state: "/path", eq: val }
307
+ visibility.neq("/path", val); // { $state: "/path", neq: val }
308
+ visibility.and(cond1, cond2); // { $and: [cond1, cond2] }
309
+ visibility.always; // true
310
+ visibility.never; // false
306
311
  ```
307
312
 
308
313
  ## Dynamic Prop Expressions
@@ -323,7 +328,9 @@ Any prop value can use data-driven expressions that resolve at render time. The
323
328
  }
324
329
  ```
325
330
 
326
- For two-way binding, use `{ "$bindState": "/path" }` on the natural value prop (e.g. `value`, `checked`, `pressed`). Inside repeat scopes, use `{ "$bindItem": "field" }` instead. Components receive resolved `bindings` with the state path for each bound prop; use `useBoundProp(props.value, bindings?.value)` to get `[value, setValue]`.
331
+ For two-way binding, use `{ "$bindState": "/path" }` on the natural value prop (e.g. `value`, `checked`, `pressed`). Inside repeat scopes, use `{ "$bindItem": "field" }` instead.
332
+
333
+ To render a filtered list (kanban columns, status sections), put `repeat` and an `$item` visibility condition on the same container: `{ "repeat": { "statePath": "/tasks", "key": "id" }, "visible": { "$item": "status", "eq": "todo" }, "children": ["task-card"] }` renders one child per matching item. AND-composed `$state` conjuncts still gate the container itself. Components receive resolved `bindings` with the state path for each bound prop; use `useBoundProp(props.value, bindings?.value)` to get `[value, setValue]`.
327
334
 
328
335
  ### `$template` and `$computed`
329
336
 
@@ -420,21 +427,34 @@ When using `defineRegistry`, components receive these props:
420
427
 
421
428
  ```typescript
422
429
  interface ComponentContext<P> {
423
- props: P; // Typed props from the catalog (expressions resolved)
424
- children?: React.ReactNode; // Rendered children
425
- emit: (event: string) => void; // Emit a named event (always defined)
430
+ props: P; // Typed props from the catalog (expressions resolved)
431
+ children?: React.ReactNode; // Rendered children
432
+ slots?: Record<string, React.ReactNode>; // Rendered named slots
433
+ emit: (event: string) => void; // Emit a named event (always defined)
426
434
  on: (event: string) => EventHandle; // Get event handle with metadata
427
- loading?: boolean; // Whether the parent is loading
428
- bindings?: Record<string, string>; // State paths for $bindState/$bindItem expressions (e.g. bindings.value)
435
+ loading?: boolean; // Whether the parent is loading
436
+ bindings?: Record<string, string>; // State paths for $bindState/$bindItem expressions (e.g. bindings.value)
429
437
  }
430
438
 
431
439
  interface EventHandle {
432
- emit: () => void; // Fire the event
440
+ emit: () => void; // Fire the event
433
441
  shouldPreventDefault: boolean; // Whether any binding requested preventDefault
434
- bound: boolean; // Whether any handler is bound
442
+ bound: boolean; // Whether any handler is bound
435
443
  }
436
444
  ```
437
445
 
446
+ Use `children` for the catalog's `"default"` slot. Components with additional slots receive them by name:
447
+
448
+ ```tsx
449
+ Layout: ({ children, slots }) => (
450
+ <div>
451
+ <header>{slots?.header}</header>
452
+ <main>{children}</main>
453
+ <footer>{slots?.footer}</footer>
454
+ </div>
455
+ ),
456
+ ```
457
+
438
458
  Use `emit("press")` for simple event firing. Use `on("click")` when you need to check metadata like `shouldPreventDefault` or `bound`:
439
459
 
440
460
  ```tsx
@@ -517,27 +537,29 @@ function App() {
517
537
 
518
538
  ## Key Exports
519
539
 
520
- | Export | Purpose |
521
- |--------|---------|
522
- | `defineRegistry` | Create a type-safe component registry from a catalog |
523
- | `Renderer` | Render a spec using a registry |
524
- | `schema` | Element tree schema (includes built-in actions: `setState`, `pushState`, `removeState`, `validateForm`) |
525
- | `useStateStore` | Access state context |
526
- | `useStateValue` | Get single value from state |
527
- | `useBoundProp` | Two-way binding for `$bindState`/`$bindItem` expressions |
528
- | `useActions` | Access actions context |
529
- | `useAction` | Get a single action dispatch function |
530
- | `useUIStream` | Stream specs from an API endpoint |
531
- | `createStateStore` | Create a framework-agnostic in-memory `StateStore` |
540
+ Nested lists can set `repeat.statePath` to `{ "$item": "field" }` to iterate an array on the enclosing repeat item.
541
+
542
+ | Export | Purpose |
543
+ | ------------------ | ------------------------------------------------------------------------------------------------------- |
544
+ | `defineRegistry` | Create a type-safe component registry from a catalog |
545
+ | `Renderer` | Render a spec using a registry |
546
+ | `schema` | Element tree schema (includes built-in actions: `setState`, `pushState`, `removeState`, `validateForm`) |
547
+ | `useStateStore` | Access state context |
548
+ | `useStateValue` | Get single value from state |
549
+ | `useBoundProp` | Two-way binding for `$bindState`/`$bindItem` expressions |
550
+ | `useActions` | Access actions context |
551
+ | `useAction` | Get a single action dispatch function |
552
+ | `useUIStream` | Stream specs from an API endpoint |
553
+ | `createStateStore` | Create a framework-agnostic in-memory `StateStore` |
532
554
 
533
555
  ### Types
534
556
 
535
- | Export | Purpose |
536
- |--------|---------|
537
- | `ComponentContext` | Typed component render function context (catalog-aware) |
557
+ | Export | Purpose |
558
+ | -------------------- | ----------------------------------------------------------- |
559
+ | `ComponentContext` | Typed component render function context (catalog-aware) |
538
560
  | `BaseComponentProps` | Catalog-agnostic base type for reusable component libraries |
539
- | `EventHandle` | Event handle with `emit()`, `shouldPreventDefault`, `bound` |
540
- | `ComponentFn` | Component render function type |
541
- | `SetState` | State setter type |
542
- | `StateModel` | State model type |
543
- | `StateStore` | Interface for plugging in external state management |
561
+ | `EventHandle` | Event handle with `emit()`, `shouldPreventDefault`, `bound` |
562
+ | `ComponentFn` | Component render function type |
563
+ | `SetState` | State setter type |
564
+ | `StateModel` | State model type |
565
+ | `StateStore` | Interface for plugging in external state management |
@@ -15,8 +15,11 @@ var schema = defineSchema(
15
15
  props: s.propsOf("catalog.components"),
16
16
  /** Child element keys (flat reference) */
17
17
  children: s.array(s.string()),
18
+ slots: { ...s.record(s.array(s.string())), ...s.optional() },
18
19
  /** Visibility condition */
19
- visible: s.any()
20
+ visible: { ...s.any(), ...s.optional() },
21
+ /** Repeat children from a state array */
22
+ repeat: { ...s.any(), ...s.optional() }
20
23
  })
21
24
  )
22
25
  }),
@@ -65,12 +68,15 @@ var schema = defineSchema(
65
68
  // Element integrity
66
69
  "CRITICAL INTEGRITY CHECK: Before outputting ANY element that references children, you MUST have already output (or will output) each child as its own element. If an element has children: ['a', 'b'], then elements 'a' and 'b' MUST exist. A missing child element causes that entire branch of the UI to be invisible.",
67
70
  "SELF-CHECK: After generating all elements, mentally walk the tree from root. Every key in every children array must resolve to a defined element. If you find a gap, output the missing element immediately.",
71
+ 'REQUIRED FIELDS: Every element MUST include a "children" array. Leaf elements (text, badges, inputs, images) use an empty array: "children": []. Omitting "children" fails validation.',
72
+ 'NAMED SLOTS: Use "children" for the default slot. For other slots declared by the component, use a top-level "slots" object that maps each slot name to child element keys, for example {"slots":{"header":["heading"],"footer":["actions"]}}. Never use "slots.default". Every referenced key must exist.',
73
+ 'FILTERED LISTS: To render only the items matching a field value (kanban columns, tabbed lists, status sections), put "repeat" and a "visible" condition with $item on the same container element: {"repeat": {"statePath": "/tasks", "key": "id"}, "visible": {"$item": "status", "eq": "todo"}} renders one child per matching item. A visible condition object must use exactly one of $state, $item, or $index \u2014 never combine them in one object.',
68
74
  // Field placement
69
75
  'CRITICAL: The "visible" field goes on the ELEMENT object, NOT inside "props". Correct: {"type":"<ComponentName>","props":{},"visible":{"$state":"/tab","eq":"home"},"children":[...]}.',
70
76
  'CRITICAL: The "on" field goes on the ELEMENT object, NOT inside "props". Use on.press, on.change, on.submit etc. NEVER put action/actionParams inside props.',
71
77
  // State and data
72
78
  "When the user asks for a UI that displays data (e.g. blog posts, products, users), ALWAYS include a state field with realistic sample data. The state field is a top-level field on the spec (sibling of root/elements).",
73
- 'When building repeating content backed by a state array (e.g. posts, products, items), use the "repeat" field on a container element. Example: { "type": "<ContainerComponent>", "props": {}, "repeat": { "statePath": "/posts", "key": "id" }, "children": ["post-card"] }. Replace <ContainerComponent> with an appropriate component from the AVAILABLE COMPONENTS list. Inside repeated children, use { "$item": "field" } to read a field from the current item, and { "$index": true } for the current array index. For two-way binding to an item field use { "$bindItem": "completed" }. Do NOT hardcode individual elements for each array item.',
79
+ 'When building repeating content backed by a state array (e.g. posts, products, items), use the "repeat" field on a container element. Example: { "type": "<ContainerComponent>", "props": {}, "repeat": { "statePath": "/posts", "key": "id" }, "children": ["post-card"] }. For a nested list stored on the enclosing item, use "repeat": { "statePath": { "$item": "comments" }, "key": "id" }. The $item statePath form is valid only inside another repeat. Replace <ContainerComponent> with an appropriate component from the AVAILABLE COMPONENTS list. Inside repeated children, use { "$item": "field" } to read a field from the current item, and { "$index": true } for the current array index. For two-way binding to an item field use { "$bindItem": "completed" }. Do NOT hardcode individual elements for each array item.',
74
80
  // Design quality
75
81
  "Design with visual hierarchy: use container components to group content, heading components for section titles, proper spacing, and status indicators. ONLY use components from the AVAILABLE COMPONENTS list.",
76
82
  "For data-rich UIs, use multi-column layout components if available. For forms and single-column content, use vertical layout components. ONLY use components from the AVAILABLE COMPONENTS list.",
@@ -84,4 +90,4 @@ export {
84
90
  schema,
85
91
  elementTreeSchema
86
92
  };
87
- //# sourceMappingURL=chunk-WYDS23XB.mjs.map
93
+ //# sourceMappingURL=chunk-SDI5YI5X.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schema.ts"],"sourcesContent":["import { defineSchema } from \"@xmachines/json-render-core\";\n\n/**\n * The schema for @xmachines/json-render-react\n *\n * Defines:\n * - Spec: A flat tree of elements with keys, types, props, and children references\n * - Catalog: Components with props schemas, and optional actions\n */\nexport const schema = defineSchema(\n (s) => ({\n // What the AI-generated SPEC looks like\n spec: s.object({\n /** Root element key */\n root: s.string(),\n /** Flat map of elements by key */\n elements: s.record(\n s.object({\n /** Component type from catalog */\n type: s.ref(\"catalog.components\"),\n /** Component props */\n props: s.propsOf(\"catalog.components\"),\n /** Child element keys (flat reference) */\n children: s.array(s.string()),\n slots: { ...s.record(s.array(s.string())), ...s.optional() },\n /** Visibility condition */\n visible: { ...s.any(), ...s.optional() },\n /** Repeat children from a state array */\n repeat: { ...s.any(), ...s.optional() },\n }),\n ),\n }),\n\n // What the CATALOG must provide\n catalog: s.object({\n /** Component definitions */\n components: s.map({\n /** Zod schema for component props */\n props: s.zod(),\n /** Slots for this component. Use ['default'] for children, or named slots like ['header', 'footer'] */\n slots: s.array(s.string()),\n /** Description for AI generation hints */\n description: s.string(),\n /** Example prop values used in prompt examples (auto-generated from Zod schema if omitted) */\n example: s.any(),\n }),\n /** Action definitions (optional) */\n actions: s.map({\n /** Zod schema for action params */\n params: s.zod(),\n /** Description for AI generation hints */\n description: s.string(),\n }),\n }),\n }),\n {\n builtInActions: [\n {\n name: \"setState\",\n description:\n \"Update a value in the state model at the given statePath. Params: { statePath: string, value: any }\",\n },\n {\n name: \"pushState\",\n description:\n 'Append an item to an array in state. Params: { statePath: string, value: any, clearStatePath?: string }. Value can contain {\"$state\":\"/path\"} refs and \"$id\" for auto IDs.',\n },\n {\n name: \"removeState\",\n description:\n \"Remove an item from an array in state by index. Params: { statePath: string, index: number }\",\n },\n {\n name: \"validateForm\",\n description:\n \"Validate all registered form fields and write the result to state. Params: { statePath?: string }. Defaults to /formValidation. Result: { valid: boolean, errors: Record<string, string[]> }.\",\n },\n ],\n defaultRules: [\n // Element integrity\n \"CRITICAL INTEGRITY CHECK: Before outputting ANY element that references children, you MUST have already output (or will output) each child as its own element. If an element has children: ['a', 'b'], then elements 'a' and 'b' MUST exist. A missing child element causes that entire branch of the UI to be invisible.\",\n \"SELF-CHECK: After generating all elements, mentally walk the tree from root. Every key in every children array must resolve to a defined element. If you find a gap, output the missing element immediately.\",\n 'REQUIRED FIELDS: Every element MUST include a \"children\" array. Leaf elements (text, badges, inputs, images) use an empty array: \"children\": []. Omitting \"children\" fails validation.',\n 'NAMED SLOTS: Use \"children\" for the default slot. For other slots declared by the component, use a top-level \"slots\" object that maps each slot name to child element keys, for example {\"slots\":{\"header\":[\"heading\"],\"footer\":[\"actions\"]}}. Never use \"slots.default\". Every referenced key must exist.',\n 'FILTERED LISTS: To render only the items matching a field value (kanban columns, tabbed lists, status sections), put \"repeat\" and a \"visible\" condition with $item on the same container element: {\"repeat\": {\"statePath\": \"/tasks\", \"key\": \"id\"}, \"visible\": {\"$item\": \"status\", \"eq\": \"todo\"}} renders one child per matching item. A visible condition object must use exactly one of $state, $item, or $index — never combine them in one object.',\n\n // Field placement\n 'CRITICAL: The \"visible\" field goes on the ELEMENT object, NOT inside \"props\". Correct: {\"type\":\"<ComponentName>\",\"props\":{},\"visible\":{\"$state\":\"/tab\",\"eq\":\"home\"},\"children\":[...]}.',\n 'CRITICAL: The \"on\" field goes on the ELEMENT object, NOT inside \"props\". Use on.press, on.change, on.submit etc. NEVER put action/actionParams inside props.',\n\n // State and data\n \"When the user asks for a UI that displays data (e.g. blog posts, products, users), ALWAYS include a state field with realistic sample data. The state field is a top-level field on the spec (sibling of root/elements).\",\n 'When building repeating content backed by a state array (e.g. posts, products, items), use the \"repeat\" field on a container element. Example: { \"type\": \"<ContainerComponent>\", \"props\": {}, \"repeat\": { \"statePath\": \"/posts\", \"key\": \"id\" }, \"children\": [\"post-card\"] }. For a nested list stored on the enclosing item, use \"repeat\": { \"statePath\": { \"$item\": \"comments\" }, \"key\": \"id\" }. The $item statePath form is valid only inside another repeat. Replace <ContainerComponent> with an appropriate component from the AVAILABLE COMPONENTS list. Inside repeated children, use { \"$item\": \"field\" } to read a field from the current item, and { \"$index\": true } for the current array index. For two-way binding to an item field use { \"$bindItem\": \"completed\" }. Do NOT hardcode individual elements for each array item.',\n\n // Design quality\n \"Design with visual hierarchy: use container components to group content, heading components for section titles, proper spacing, and status indicators. ONLY use components from the AVAILABLE COMPONENTS list.\",\n \"For data-rich UIs, use multi-column layout components if available. For forms and single-column content, use vertical layout components. ONLY use components from the AVAILABLE COMPONENTS list.\",\n \"Always include realistic, professional-looking sample data. For blogs include 3-4 posts with varied titles, authors, dates, categories. For products include names, prices, images. Never leave data empty.\",\n ],\n },\n);\n\n/**\n * Type for the React schema\n */\nexport type ReactSchema = typeof schema;\n\n/**\n * Infer the spec type from a catalog\n */\nexport type ReactSpec<TCatalog> = typeof schema extends {\n createCatalog: (catalog: TCatalog) => { _specType: infer S };\n}\n ? S\n : never;\n\n// Backward compatibility aliases\n/** @deprecated Use `schema` instead */\nexport const elementTreeSchema = schema;\n/** @deprecated Use `ReactSchema` instead */\nexport type ElementTreeSchema = ReactSchema;\n/** @deprecated Use `ReactSpec` instead */\nexport type ElementTreeSpec<T> = ReactSpec<T>;\n"],"mappings":";AAAA,SAAS,oBAAoB;AAStB,IAAM,SAAS;AAAA,EACpB,CAAC,OAAO;AAAA;AAAA,IAEN,MAAM,EAAE,OAAO;AAAA;AAAA,MAEb,MAAM,EAAE,OAAO;AAAA;AAAA,MAEf,UAAU,EAAE;AAAA,QACV,EAAE,OAAO;AAAA;AAAA,UAEP,MAAM,EAAE,IAAI,oBAAoB;AAAA;AAAA,UAEhC,OAAO,EAAE,QAAQ,oBAAoB;AAAA;AAAA,UAErC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA,UAC5B,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,SAAS,EAAE;AAAA;AAAA,UAE3D,SAAS,EAAE,GAAG,EAAE,IAAI,GAAG,GAAG,EAAE,SAAS,EAAE;AAAA;AAAA,UAEvC,QAAQ,EAAE,GAAG,EAAE,IAAI,GAAG,GAAG,EAAE,SAAS,EAAE;AAAA,QACxC,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAAA;AAAA,IAGD,SAAS,EAAE,OAAO;AAAA;AAAA,MAEhB,YAAY,EAAE,IAAI;AAAA;AAAA,QAEhB,OAAO,EAAE,IAAI;AAAA;AAAA,QAEb,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA;AAAA,QAEzB,aAAa,EAAE,OAAO;AAAA;AAAA,QAEtB,SAAS,EAAE,IAAI;AAAA,MACjB,CAAC;AAAA;AAAA,MAED,SAAS,EAAE,IAAI;AAAA;AAAA,QAEb,QAAQ,EAAE,IAAI;AAAA;AAAA,QAEd,aAAa,EAAE,OAAO;AAAA,MACxB,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EACA;AAAA,IACE,gBAAgB;AAAA,MACd;AAAA,QACE,MAAM;AAAA,QACN,aACE;AAAA,MACJ;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,aACE;AAAA,MACJ;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,aACE;AAAA,MACJ;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,aACE;AAAA,MACJ;AAAA,IACF;AAAA,IACA,cAAc;AAAA;AAAA,MAEZ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MAGA;AAAA,MACA;AAAA;AAAA,MAGA;AAAA,MACA;AAAA;AAAA,MAGA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAkBO,IAAM,oBAAoB;","names":[]}
package/dist/index.d.mts CHANGED
@@ -196,8 +196,15 @@ interface ValidationContextValue {
196
196
  clear: (path: string) => void;
197
197
  /** Validate all fields */
198
198
  validateAll: () => boolean;
199
- /** Register field config */
199
+ /** Register field config (ref-counted per path) */
200
200
  registerField: (path: string, config: ValidationConfig) => void;
201
+ /**
202
+ * Release one registration for the path; the config (and its stale field
203
+ * state) is dropped when the last registration is released. Without this,
204
+ * fields registered on one screen would keep failing validateAll() on every
205
+ * later screen (their bound state no longer exists there).
206
+ */
207
+ unregisterField: (path: string) => void;
201
208
  }
202
209
  /**
203
210
  * Props for ValidationProvider
@@ -292,6 +299,7 @@ interface EventHandle {
292
299
  interface BaseComponentProps<P = Record<string, unknown>> {
293
300
  props: P;
294
301
  children?: ReactNode;
302
+ slots?: Record<string, ReactNode>;
295
303
  /** Simple event emitter (shorthand). Fires the event and returns void. */
296
304
  emit: (event: string) => void;
297
305
  /** Get an event handle with metadata. Use when you need shouldPreventDefault or bound checks. */
@@ -367,6 +375,7 @@ interface ComponentRenderProps<P = Record<string, unknown>> {
367
375
  element: UIElement<string, P>;
368
376
  /** Rendered children */
369
377
  children?: ReactNode;
378
+ slots?: Record<string, ReactNode>;
370
379
  /** Emit a named event. The renderer resolves the event to action binding(s) from the element's `on` field. Always provided by the renderer. */
371
380
  emit: (event: string) => void;
372
381
  /** Get an event handle with metadata (shouldPreventDefault, bound). Use when you need to inspect event bindings. */
@@ -496,7 +505,7 @@ type DefineRegistryOptions<C extends Catalog> = {
496
505
  * });
497
506
  * ```
498
507
  */
499
- declare function defineRegistry<C extends Catalog>(_catalog: C, options: DefineRegistryOptions<C>): DefineRegistryResult;
508
+ declare function defineRegistry<C extends Catalog>(catalog: C, options: DefineRegistryOptions<C>): DefineRegistryResult;
500
509
  /**
501
510
  * Props for renderers created with createRenderer
502
511
  */
package/dist/index.d.ts CHANGED
@@ -196,8 +196,15 @@ interface ValidationContextValue {
196
196
  clear: (path: string) => void;
197
197
  /** Validate all fields */
198
198
  validateAll: () => boolean;
199
- /** Register field config */
199
+ /** Register field config (ref-counted per path) */
200
200
  registerField: (path: string, config: ValidationConfig) => void;
201
+ /**
202
+ * Release one registration for the path; the config (and its stale field
203
+ * state) is dropped when the last registration is released. Without this,
204
+ * fields registered on one screen would keep failing validateAll() on every
205
+ * later screen (their bound state no longer exists there).
206
+ */
207
+ unregisterField: (path: string) => void;
201
208
  }
202
209
  /**
203
210
  * Props for ValidationProvider
@@ -292,6 +299,7 @@ interface EventHandle {
292
299
  interface BaseComponentProps<P = Record<string, unknown>> {
293
300
  props: P;
294
301
  children?: ReactNode;
302
+ slots?: Record<string, ReactNode>;
295
303
  /** Simple event emitter (shorthand). Fires the event and returns void. */
296
304
  emit: (event: string) => void;
297
305
  /** Get an event handle with metadata. Use when you need shouldPreventDefault or bound checks. */
@@ -367,6 +375,7 @@ interface ComponentRenderProps<P = Record<string, unknown>> {
367
375
  element: UIElement<string, P>;
368
376
  /** Rendered children */
369
377
  children?: ReactNode;
378
+ slots?: Record<string, ReactNode>;
370
379
  /** Emit a named event. The renderer resolves the event to action binding(s) from the element's `on` field. Always provided by the renderer. */
371
380
  emit: (event: string) => void;
372
381
  /** Get an event handle with metadata (shouldPreventDefault, bound). Use when you need to inspect event bindings. */
@@ -496,7 +505,7 @@ type DefineRegistryOptions<C extends Catalog> = {
496
505
  * });
497
506
  * ```
498
507
  */
499
- declare function defineRegistry<C extends Catalog>(_catalog: C, options: DefineRegistryOptions<C>): DefineRegistryResult;
508
+ declare function defineRegistry<C extends Catalog>(catalog: C, options: DefineRegistryOptions<C>): DefineRegistryResult;
500
509
  /**
501
510
  * Props for renderers created with createRenderer
502
511
  */