import * as __ctHelpers from "commontools"; import { pattern, UI } from "commontools"; type ItemTuple = [ item: string, count: number ]; interface State { items: ItemTuple[]; } export default pattern(({ items }) => { return { [UI]: (
{/* Array destructured parameter - without fix, 'item' would be incorrectly captured in params due to shorthand usage in JSX */} {items.mapWithPattern(__ctHelpers.pattern(({ element: [item], params: {} }) => (
{item}
), { type: "object", properties: { element: { $ref: "#/$defs/ItemTuple" }, params: { type: "object", properties: {} } }, required: ["element", "params"], $defs: { ItemTuple: { type: "array", items: { type: ["number", "string"] } } } } as const satisfies __ctHelpers.JSONSchema, { anyOf: [{ $ref: "https://commonfabric.org/schemas/vnode.json" }, { type: "object", properties: {} }, { $ref: "#/$defs/UIRenderable", asOpaque: true }], $defs: { UIRenderable: { type: "object", properties: { $UI: { $ref: "https://commonfabric.org/schemas/vnode.json" } }, required: ["$UI"] } } } as const satisfies __ctHelpers.JSONSchema), {})} {/* Multiple array destructured params */} {items.mapWithPattern(__ctHelpers.pattern(({ element: [item, count], index, params: {} }) => (
{item}: {count}
), { type: "object", properties: { element: { $ref: "#/$defs/ItemTuple" }, index: { type: "number" }, params: { type: "object", properties: {} } }, required: ["element", "params"], $defs: { ItemTuple: { type: "array", items: { type: ["number", "string"] } } } } as const satisfies __ctHelpers.JSONSchema, { anyOf: [{ $ref: "https://commonfabric.org/schemas/vnode.json" }, { type: "object", properties: {} }, { $ref: "#/$defs/UIRenderable", asOpaque: true }], $defs: { UIRenderable: { type: "object", properties: { $UI: { $ref: "https://commonfabric.org/schemas/vnode.json" } }, required: ["$UI"] } } } as const satisfies __ctHelpers.JSONSchema), {})}
), }; }, { type: "object", properties: { items: { type: "array", items: { $ref: "#/$defs/ItemTuple" } } }, required: ["items"], $defs: { ItemTuple: { type: "array", items: { type: ["number", "string"] } } } } as const satisfies __ctHelpers.JSONSchema, { type: "object", properties: { $UI: { $ref: "#/$defs/JSXElement" } }, required: ["$UI"], $defs: { JSXElement: { anyOf: [{ $ref: "https://commonfabric.org/schemas/vnode.json" }, { type: "object", properties: {} }, { $ref: "#/$defs/UIRenderable", asOpaque: true }] }, UIRenderable: { type: "object", properties: { $UI: { $ref: "https://commonfabric.org/schemas/vnode.json" } }, required: ["$UI"] } } } as const satisfies __ctHelpers.JSONSchema); // @ts-ignore: Internals function h(...args: any[]) { return __ctHelpers.h.apply(null, args); } // @ts-ignore: Internals h.fragment = __ctHelpers.h.fragment;