import * as __ctHelpers from "commontools";
import { derive } from "commontools";
// Test case: User-written derive calls should not be double-wrapped
// This tests that derive(index, (i) => i + 1) doesn't become derive(index, index => derive(index, (i) => i + 1))
export default function TestComponent({ items, cellRef }: {
items: {
id: number;
title: string;
}[];
cellRef: {
name?: string;
value: string;
};
}) {
return (
{/* User-written derive with simple parameter transformation - should NOT be double-wrapped */}
Count: {derive({
type: "number"
} as const satisfies __ctHelpers.JSONSchema, {
type: "number"
} as const satisfies __ctHelpers.JSONSchema, items.length, (n) => n + 1)}
{/* User-written derive accessing opaque ref property - should NOT be double-wrapped */}
Name: {derive({
type: "object",
properties: {
name: {
type: "string"
},
value: {
type: "string"
}
},
required: ["value"]
} as const satisfies __ctHelpers.JSONSchema, {
type: "string"
} as const satisfies __ctHelpers.JSONSchema, cellRef, (ref) => ref.name || "Unknown")}
{/* Nested in map with user-written derive - derives should NOT be double-wrapped */}
{items.map((item, index) => (
{/* These user-written derives should remain as-is, not wrapped in another derive */}
Item {derive({
type: "number"
} as const satisfies __ctHelpers.JSONSchema, {
type: "number"
} as const satisfies __ctHelpers.JSONSchema, index, (i) => i + 1)}: {derive({
type: "object",
properties: {
id: {
type: "number"
},
title: {
type: "string"
}
},
required: ["id", "title"]
} as const satisfies __ctHelpers.JSONSchema, {
type: "string"
} as const satisfies __ctHelpers.JSONSchema, item, (it) => it.title)}
))}
{/* Simple property access - should NOT be transformed */}
Direct access: {cellRef.value}
);
}
// @ts-ignore: Internals
function h(...args: any[]) { return __ctHelpers.h.apply(null, args); }
// @ts-ignore: Internals
h.fragment = __ctHelpers.h.fragment;