Merge branch 'feat/component-conditional'

This commit is contained in:
2026-05-21 21:04:20 +00:00
3 changed files with 114 additions and 1 deletions

View File

@@ -1 +1,26 @@
export {};
import type { UElement, UNode, UniversalProps } from "@alkdev/ujsx";
import type { CallResult } from "../schema/edge.js";
export interface ConditionalProps {
test: ((results: Record<string, CallResult>) => boolean) | string;
else?: UNode;
}
function Conditional(
props: ConditionalProps & { children?: UNode[] },
): UElement {
const { test, else: elseProp, children } = props;
const elementProps: UniversalProps = { test: test as UniversalProps["test"] };
if (elseProp !== undefined) {
elementProps.else = elseProp;
}
return {
type: "conditional",
props: elementProps,
children: children ?? [],
};
}
Conditional.displayName = "Conditional";
export { Conditional };

View File

@@ -1,3 +1,5 @@
export { Conditional } from "./conditional.js";
export type { ConditionalProps } from "./conditional.js";
export { Operation } from "./operation.js";
export type { OperationProps } from "./operation.js";
export { Parallel } from "./parallel.js";