24 lines
755 B
TypeScript
24 lines
755 B
TypeScript
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"; |