#356

catalog.jsonSchema() does not describe the element-level `on` field

OpenhamzaPixlopened 1mo ago

Version: @json-render/core 0.21.0, @json-render/react 0.21.0

catalog.jsonSchema() describes type, props, children, visible, repeat… but not on, the top-level field that binds a component event to an action:

import { schema } from "@json-render/react/schema";
import { defineCatalog } from "@json-render/core";
import { z } from "zod";

const c = defineCatalog(schema, {
  components: { Button: { props: z.object({ label: z.string() }), description: "b", events: ["press"] } },
  actions: { go: { description: "g" } },
});
JSON.stringify(c.jsonSchema()).includes('"on"'); // false

Meanwhile validation rejects on placed inside props ("It should be a top-level field on the element"). A model given only the JSON Schema has no way to learn where on goes, so it either omits events or puts them in props and fails validation.

Suggestion: add on to the element schema, keyed by the component's declared events, with values referencing the catalog's actions.

Activity

0

No activity yet.