import * as __ctHelpers from "commontools"; import { Cell, derive, handler, NAME, pattern, str, UI } from "commontools"; const adder = handler(false as const satisfies __ctHelpers.JSONSchema, { type: "object", properties: { values: { type: "array", items: { type: "string" }, asCell: true } }, required: ["values"] } as const satisfies __ctHelpers.JSONSchema, (_, state: { values: Cell; }) => { state.values.push(Math.random().toString(36).substring(2, 15)); }); export default pattern(({ values }) => { derive({ type: "array", items: { type: "string" } } as const satisfies __ctHelpers.JSONSchema, true as const satisfies __ctHelpers.JSONSchema, values, (values) => { console.log("values#", values?.length); }); return { [NAME]: str `Simple Value: ${values.length || 0}`, [UI]: (
{values.mapWithPattern(__ctHelpers.pattern(({ element: value, index, params: {} }) => (
{index}: {value}
), { type: "object", properties: { element: { type: "string" }, index: { type: "number" }, params: { type: "object", properties: {} } }, required: ["element", "params"] } 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), {})}
), values, }; }, { type: "object", properties: { values: { type: "array", items: { type: "string" } } }, required: ["values"] } as const satisfies __ctHelpers.JSONSchema, { type: "object", properties: { $NAME: { type: "string", asOpaque: true }, $UI: { $ref: "#/$defs/JSXElement" }, values: { type: "array", items: { type: "string" }, asOpaque: true } }, required: ["$NAME", "$UI", "values"], $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;