{"version":3,"file":"For.cjs","names":[],"sources":["../../../src/components/For/For.tsx"],"sourcesContent":["import { Fragment, type ReactNode } from \"react\";\n\nexport interface ForProps<T> {\n    /** The collection to iterate over. */\n    each: readonly T[];\n    /** Render function called for each item with its index. */\n    children: (item: T, index: number) => ReactNode;\n    /** Rendered when `each` is empty. Defaults to `null`. */\n    fallback?: ReactNode;\n}\n\n/**\n * Typed, JSX-friendly list renderer.\n *\n * Maps over `each`, calling `children(item, index)` for every entry. When\n * `each` is empty, it renders `fallback` (or nothing). The generic parameter is\n * inferred from `each`, so the render callback's `item` is fully typed:\n * `<For each={users}>{(user) => <li>{user.name}</li>}</For>`.\n *\n * @typeParam T - The element type of the `each` collection.\n * @param props - The list-rendering props.\n * @returns The mapped children, or the fallback when `each` is empty.\n */\nexport function For<T>({ each, children, fallback = null }: ForProps<T>): ReactNode {\n    if (each.length === 0) {\n        return <>{fallback}</>;\n    }\n    return (\n        <>\n            {each.map((item, index) => (\n                <Fragment key={index}>{children(item, index)}</Fragment>\n            ))}\n        </>\n    );\n}\n"],"mappings":"sDAuBA,SAAgB,EAAO,CAAE,OAAM,WAAU,WAAW,MAAgC,CAIhF,OAHI,EAAK,SAAW,GACT,EAAA,EAAA,IAAA,CAAA,EAAA,SAAA,CAAA,SAAG,CAAW,CAAA,GAGrB,EAAA,EAAA,IAAA,CAAA,EAAA,SAAA,CAAA,SACK,EAAK,KAAK,EAAM,KACb,EAAA,EAAA,IAAA,CAAC,EAAA,SAAD,CAAA,SAAuB,EAAS,EAAM,CAAK,CAAY,EAAxC,CAAwC,CAC1D,CACH,CAAA,CAEV"}