import { Text } from "./Text.js"; import { FunctionalComponent } from "../component.js"; import { createTemplate, Template } from "../template.js"; import { useMemo, type MaybeSignal } from "../scope.js"; export type Children = | Template | MaybeSignal | Children[]; /** * Fragment is a component that can be used to wrap multiple children without * introducing an extra DOM element. * * @example * ```tsx * render() { * return ( * <> *

Hello World

*

This is a paragraph.

* * ); * } * ``` */ export const Fragment: FunctionalComponent<{ children?: Children; }> = ({ children }) => createTemplate(() => { return !Array.isArray(children) ? children == null ? [] : [ typeof children == "object" ? children.build() : Text({ text: children }).build(), ] : children.flatMap((children) => Fragment({ children }).build()); });