@xmachines/json-render-react 0.21.0-xm.5 → 0.21.0-xm.7
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 +51 -14
- package/dist/{chunk-SDI5YI5X.mjs → chunk-YOMYRECB.mjs} +3 -20
- package/dist/chunk-YOMYRECB.mjs.map +1 -0
- package/dist/index.d.mts +9 -14
- package/dist/index.d.ts +9 -14
- package/dist/index.js +409 -299
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +385 -255
- package/dist/index.mjs.map +1 -1
- package/dist/schema.js +1 -18
- package/dist/schema.js.map +1 -1
- package/dist/schema.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-SDI5YI5X.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -264,7 +264,7 @@ const { errors, validate } = useFieldValidation("/form/email", {
|
|
|
264
264
|
| `useStateBinding(path)` | Two-way data binding (returns `[value, setValue]`) |
|
|
265
265
|
| `useIsVisible(condition)` | Check if a visibility condition is met |
|
|
266
266
|
| `useActions()` | Access action context |
|
|
267
|
-
| `useAction(
|
|
267
|
+
| `useAction(binding)` | Run one action binding (returns `{ execute, isLoading }`) |
|
|
268
268
|
| `useFieldValidation(path, config)` | Field validation state |
|
|
269
269
|
| `useOptionalValidation()` | Non-throwing validation context (returns `null` if no provider) |
|
|
270
270
|
| `useUIStream(options)` | Stream specs from an API endpoint |
|
|
@@ -385,7 +385,7 @@ Elements can declare a `watch` field to trigger actions when state values change
|
|
|
385
385
|
|
|
386
386
|
## Built-in Actions
|
|
387
387
|
|
|
388
|
-
The `setState`, `pushState`, `removeState`, and `validateForm` actions are built into the React schema and handled automatically by `ActionProvider`. They are injected into AI prompts without needing to be declared in your catalog's `actions
|
|
388
|
+
The `setState`, `pushState`, `removeState`, `push`, `pop`, and `validateForm` actions are built into the React schema and handled automatically by `ActionProvider`. They are injected into AI prompts without needing to be declared in your catalog's `actions`. `push` puts `/currentScreen` on the `/navStack` array and sets `/currentScreen` to its `screen` param. `pop` takes the last entry off `/navStack` and makes it `/currentScreen` again:
|
|
389
389
|
|
|
390
390
|
```json
|
|
391
391
|
{
|
|
@@ -535,22 +535,59 @@ function App() {
|
|
|
535
535
|
}
|
|
536
536
|
```
|
|
537
537
|
|
|
538
|
+
## Render Errors
|
|
539
|
+
|
|
540
|
+
`Renderer` and the component of `createRenderer` take an `onRenderError` prop of the type `OnRenderError`. `defineRegistry(catalog, { onRenderError })` puts the handler on the registry, and the prop takes the place of that handler.
|
|
541
|
+
|
|
542
|
+
The renderer calls `onRenderError(error, name, info)` one time for each failure in code that it runs. `info.kind` gives the place of the failure:
|
|
543
|
+
|
|
544
|
+
| `info.kind` | Failure | `name` | Result |
|
|
545
|
+
| ------------------- | ------------------------------------------------------------------------------------------ | ---------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
|
546
|
+
| `element` | A component throws in its render, in an effect or in a lifecycle method. | the element type | The element shows nothing until a new version of it comes. |
|
|
547
|
+
| `props` / `visible` | A prop expression (`$computed`, a directive) or the `visible` condition of a child throws. | the type of the parent | The parent shows nothing. `info.key` and `info.type` name the child. |
|
|
548
|
+
| `root` | The root component, a prop expression of the root, or its `visible` condition throws. | the root type | The renderer shows nothing until a new version of the root comes. The error never goes to the error boundary of the host. |
|
|
549
|
+
| `action` / `watch` | A binding of an `on` chain or of a `watch` chain throws or rejects. | the action name | The chain stops. The element stays. |
|
|
550
|
+
|
|
551
|
+
`info.key` is the key of the element, `info.type` is its type, and `info.action` is the action name of a chain. Without a handler, the renderer writes one `console.error` line, for example `[json-render] props error in <Text> "title":`, and then the error.
|
|
552
|
+
|
|
553
|
+
```tsx
|
|
554
|
+
<Renderer
|
|
555
|
+
spec={spec}
|
|
556
|
+
registry={registry}
|
|
557
|
+
onRenderError={(error, name, info) => report(error, info.kind, info.key)}
|
|
558
|
+
/>
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
A handler with two parameters, `(error, name)`, is still a valid handler. If the handler throws, the renderer gives that error to `reportError` one time, and no other element fails.
|
|
562
|
+
|
|
563
|
+
The renderer does not report an error of code that it does not run. That code is a listener of a component, a timer, or a promise that the component drops. Such an error goes to the window, as in any React application. The promise of `useActions().execute` and of `useAction().execute` goes to the caller.
|
|
564
|
+
|
|
565
|
+
An element type with no component and no `fallback` gives one `[json-render]` warning when the element mounts. A `spec.root` that names no element gives one warning after the spec loads.
|
|
566
|
+
|
|
567
|
+
React 19 also writes each error that an error boundary catches to `console.error`, through the `onCaughtError` option of the root. So with the default option, the console shows a reported error a second time. The renderer cannot turn this off. Only the host can, with its own `onCaughtError`. The option applies to each error boundary of the root:
|
|
568
|
+
|
|
569
|
+
```tsx
|
|
570
|
+
createRoot(container, {
|
|
571
|
+
onCaughtError: (error, errorInfo) => tracker.capture(error, errorInfo),
|
|
572
|
+
});
|
|
573
|
+
```
|
|
574
|
+
|
|
538
575
|
## Key Exports
|
|
539
576
|
|
|
540
577
|
Nested lists can set `repeat.statePath` to `{ "$item": "field" }` to iterate an array on the enclosing repeat item.
|
|
541
578
|
|
|
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`
|
|
579
|
+
| Export | Purpose |
|
|
580
|
+
| ------------------ | ---------------------------------------------------------------------------------------------------------------------- |
|
|
581
|
+
| `defineRegistry` | Create a type-safe component registry from a catalog |
|
|
582
|
+
| `Renderer` | Render a spec using a registry |
|
|
583
|
+
| `schema` | Element tree schema (includes built-in actions: `setState`, `pushState`, `removeState`, `push`, `pop`, `validateForm`) |
|
|
584
|
+
| `useStateStore` | Access state context |
|
|
585
|
+
| `useStateValue` | Get single value from state |
|
|
586
|
+
| `useBoundProp` | Two-way binding for `$bindState`/`$bindItem` expressions |
|
|
587
|
+
| `useActions` | Access actions context |
|
|
588
|
+
| `useAction` | Get a single action dispatch function |
|
|
589
|
+
| `useUIStream` | Stream specs from an API endpoint |
|
|
590
|
+
| `createStateStore` | Create a framework-agnostic in-memory `StateStore` |
|
|
554
591
|
|
|
555
592
|
### Types
|
|
556
593
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/schema.ts
|
|
2
|
-
import { defineSchema } from "@xmachines/json-render-core";
|
|
2
|
+
import { builtInActionDefinitions, defineSchema } from "@xmachines/json-render-core";
|
|
3
3
|
var schema = defineSchema(
|
|
4
4
|
(s) => ({
|
|
5
5
|
// What the AI-generated SPEC looks like
|
|
@@ -46,24 +46,7 @@ var schema = defineSchema(
|
|
|
46
46
|
})
|
|
47
47
|
}),
|
|
48
48
|
{
|
|
49
|
-
builtInActions: [
|
|
50
|
-
{
|
|
51
|
-
name: "setState",
|
|
52
|
-
description: "Update a value in the state model at the given statePath. Params: { statePath: string, value: any }"
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
name: "pushState",
|
|
56
|
-
description: '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.'
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
name: "removeState",
|
|
60
|
-
description: "Remove an item from an array in state by index. Params: { statePath: string, index: number }"
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
name: "validateForm",
|
|
64
|
-
description: "Validate all registered form fields and write the result to state. Params: { statePath?: string }. Defaults to /formValidation. Result: { valid: boolean, errors: Record<string, string[]> }."
|
|
65
|
-
}
|
|
66
|
-
],
|
|
49
|
+
builtInActions: [...builtInActionDefinitions],
|
|
67
50
|
defaultRules: [
|
|
68
51
|
// Element integrity
|
|
69
52
|
"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.",
|
|
@@ -90,4 +73,4 @@ export {
|
|
|
90
73
|
schema,
|
|
91
74
|
elementTreeSchema
|
|
92
75
|
};
|
|
93
|
-
//# sourceMappingURL=chunk-
|
|
76
|
+
//# sourceMappingURL=chunk-YOMYRECB.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schema.ts"],"sourcesContent":["import { builtInActionDefinitions, 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: [...builtInActionDefinitions],\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,0BAA0B,oBAAoB;AAShD,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,CAAC,GAAG,wBAAwB;AAAA,IAC5C,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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode, ComponentType } from 'react';
|
|
3
|
-
import { StateStore, StateModel, VisibilityCondition, VisibilityContext, ActionHandler, ResolvedAction, ActionBinding, ActionConfirm, ValidationFunction, ValidationResult, ValidationConfig, Catalog, InferCatalogComponents, InferComponentProps, InferCatalogActions, InferActionParams,
|
|
4
|
-
export { RenderErrorHandler, Spec, StateModel, StateStore, createStateStore } from '@xmachines/json-render-core';
|
|
3
|
+
import { StateStore, StateModel, VisibilityCondition, VisibilityContext, ActionHandler, ResolvedAction, ActionBinding, ActionConfirm, ValidationFunction, ValidationResult, ValidationConfig, Catalog, InferCatalogComponents, InferComponentProps, InferCatalogActions, InferActionParams, OnRenderError, UIElement, SchemaDefinition, Spec, ComputedFunction, DirectiveDefinition, FlatElement } from '@xmachines/json-render-core';
|
|
4
|
+
export { OnRenderError, RenderErrorHandler, RenderErrorInfo, RenderErrorKind, Spec, StateModel, StateStore, createStateStore } from '@xmachines/json-render-core';
|
|
5
5
|
export { ElementTreeSchema, ElementTreeSpec, ReactSchema, ReactSpec, elementTreeSchema, schema } from './schema.mjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -202,14 +202,9 @@ interface ValidationContextValue {
|
|
|
202
202
|
clear: (path: string) => void;
|
|
203
203
|
/** Validate all fields */
|
|
204
204
|
validateAll: () => boolean;
|
|
205
|
-
/** Register field config
|
|
205
|
+
/** Register field config */
|
|
206
206
|
registerField: (path: string, config: ValidationConfig) => void;
|
|
207
|
-
/**
|
|
208
|
-
* Release one registration for the path; the config (and its stale field
|
|
209
|
-
* state) is dropped when the last registration is released. Without this,
|
|
210
|
-
* fields registered on one screen would keep failing validateAll() on every
|
|
211
|
-
* later screen (their bound state no longer exists there).
|
|
212
|
-
*/
|
|
207
|
+
/** Release one registration of the path; the last one drops its config */
|
|
213
208
|
unregisterField: (path: string) => void;
|
|
214
209
|
}
|
|
215
210
|
/**
|
|
@@ -415,8 +410,8 @@ interface RendererProps {
|
|
|
415
410
|
loading?: boolean;
|
|
416
411
|
/** Fallback component for unknown types */
|
|
417
412
|
fallback?: ComponentRenderer;
|
|
418
|
-
/** Callback for
|
|
419
|
-
onRenderError?:
|
|
413
|
+
/** Callback for each failure that the renderer reports (see the README) */
|
|
414
|
+
onRenderError?: OnRenderError;
|
|
420
415
|
}
|
|
421
416
|
/**
|
|
422
417
|
* Main renderer component
|
|
@@ -482,7 +477,7 @@ interface DefineRegistryResult {
|
|
|
482
477
|
*/
|
|
483
478
|
type DefineRegistryOptions<C extends Catalog> = {
|
|
484
479
|
components?: Components<C>;
|
|
485
|
-
onRenderError?:
|
|
480
|
+
onRenderError?: OnRenderError;
|
|
486
481
|
} & (CatalogHasActions<C> extends true ? {
|
|
487
482
|
actions: Actions<C>;
|
|
488
483
|
} : {
|
|
@@ -540,8 +535,8 @@ interface CreateRendererProps {
|
|
|
540
535
|
loading?: boolean;
|
|
541
536
|
/** Fallback component for unknown types */
|
|
542
537
|
fallback?: ComponentRenderer;
|
|
543
|
-
/** Callback for
|
|
544
|
-
onRenderError?:
|
|
538
|
+
/** Callback for each failure that the renderer reports (see the README) */
|
|
539
|
+
onRenderError?: OnRenderError;
|
|
545
540
|
}
|
|
546
541
|
/**
|
|
547
542
|
* Component map type - maps component names to React components
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode, ComponentType } from 'react';
|
|
3
|
-
import { StateStore, StateModel, VisibilityCondition, VisibilityContext, ActionHandler, ResolvedAction, ActionBinding, ActionConfirm, ValidationFunction, ValidationResult, ValidationConfig, Catalog, InferCatalogComponents, InferComponentProps, InferCatalogActions, InferActionParams,
|
|
4
|
-
export { RenderErrorHandler, Spec, StateModel, StateStore, createStateStore } from '@xmachines/json-render-core';
|
|
3
|
+
import { StateStore, StateModel, VisibilityCondition, VisibilityContext, ActionHandler, ResolvedAction, ActionBinding, ActionConfirm, ValidationFunction, ValidationResult, ValidationConfig, Catalog, InferCatalogComponents, InferComponentProps, InferCatalogActions, InferActionParams, OnRenderError, UIElement, SchemaDefinition, Spec, ComputedFunction, DirectiveDefinition, FlatElement } from '@xmachines/json-render-core';
|
|
4
|
+
export { OnRenderError, RenderErrorHandler, RenderErrorInfo, RenderErrorKind, Spec, StateModel, StateStore, createStateStore } from '@xmachines/json-render-core';
|
|
5
5
|
export { ElementTreeSchema, ElementTreeSpec, ReactSchema, ReactSpec, elementTreeSchema, schema } from './schema.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -202,14 +202,9 @@ interface ValidationContextValue {
|
|
|
202
202
|
clear: (path: string) => void;
|
|
203
203
|
/** Validate all fields */
|
|
204
204
|
validateAll: () => boolean;
|
|
205
|
-
/** Register field config
|
|
205
|
+
/** Register field config */
|
|
206
206
|
registerField: (path: string, config: ValidationConfig) => void;
|
|
207
|
-
/**
|
|
208
|
-
* Release one registration for the path; the config (and its stale field
|
|
209
|
-
* state) is dropped when the last registration is released. Without this,
|
|
210
|
-
* fields registered on one screen would keep failing validateAll() on every
|
|
211
|
-
* later screen (their bound state no longer exists there).
|
|
212
|
-
*/
|
|
207
|
+
/** Release one registration of the path; the last one drops its config */
|
|
213
208
|
unregisterField: (path: string) => void;
|
|
214
209
|
}
|
|
215
210
|
/**
|
|
@@ -415,8 +410,8 @@ interface RendererProps {
|
|
|
415
410
|
loading?: boolean;
|
|
416
411
|
/** Fallback component for unknown types */
|
|
417
412
|
fallback?: ComponentRenderer;
|
|
418
|
-
/** Callback for
|
|
419
|
-
onRenderError?:
|
|
413
|
+
/** Callback for each failure that the renderer reports (see the README) */
|
|
414
|
+
onRenderError?: OnRenderError;
|
|
420
415
|
}
|
|
421
416
|
/**
|
|
422
417
|
* Main renderer component
|
|
@@ -482,7 +477,7 @@ interface DefineRegistryResult {
|
|
|
482
477
|
*/
|
|
483
478
|
type DefineRegistryOptions<C extends Catalog> = {
|
|
484
479
|
components?: Components<C>;
|
|
485
|
-
onRenderError?:
|
|
480
|
+
onRenderError?: OnRenderError;
|
|
486
481
|
} & (CatalogHasActions<C> extends true ? {
|
|
487
482
|
actions: Actions<C>;
|
|
488
483
|
} : {
|
|
@@ -540,8 +535,8 @@ interface CreateRendererProps {
|
|
|
540
535
|
loading?: boolean;
|
|
541
536
|
/** Fallback component for unknown types */
|
|
542
537
|
fallback?: ComponentRenderer;
|
|
543
|
-
/** Callback for
|
|
544
|
-
onRenderError?:
|
|
538
|
+
/** Callback for each failure that the renderer reports (see the README) */
|
|
539
|
+
onRenderError?: OnRenderError;
|
|
545
540
|
}
|
|
546
541
|
/**
|
|
547
542
|
* Component map type - maps component names to React components
|