Merge branch 'feat/component-map'

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

View File

@@ -4,5 +4,7 @@ export { Operation } from "./operation.js";
export type { OperationProps } from "./operation.js";
export { Parallel } from "./parallel.js";
export type { ParallelProps } from "./parallel.js";
export { Map } from "./map.js";
export type { MapOver, MapProps } from "./map.js";
export { Sequential } from "./sequential.js";
export type { SequentialProps } from "./sequential.js";

View File

@@ -1 +1,24 @@
export {};
import type { UComponent, UElement, UNode, PropValue, UniversalProps } from "@alkdev/ujsx";
import type { Signal } from "@preact/signals-core";
import type { CallResult } from "../schema/edge.js";
export type MapOver = Signal<unknown[]> | unknown[] | ((results: Record<string, CallResult>) => unknown[]);
export interface MapProps {
over: MapOver;
as: string;
}
export const Map: UComponent<MapProps & UniversalProps> = (
props: (MapProps & UniversalProps) & { children?: UNode[] },
): UElement => {
const { over, as, children, ...rest } = props;
const elementProps: UniversalProps = { ...rest, over: over as PropValue, as };
return {
type: "map",
props: elementProps,
children: children ?? [],
};
};
Map.displayName = "Map";