{"version":3,"file":"DataList.cjs","names":[],"sources":["../../../src/components/DataList/DataList.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode } from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./DataList.module.css\";\n\nexport interface DataListProps<T> extends HTMLAttributes<HTMLUListElement> {\n    /** The collection to render, one `<li>` per item. */\n    items: readonly T[];\n    /** Renders the contents of each list item. */\n    renderItem: (item: T, index: number) => ReactNode;\n    /** Derives a stable React key for each item (defaults to the index). */\n    keyExtractor?: (item: T, index: number) => string | number;\n    /** Node rendered in place of the list when `items` is empty. */\n    empty?: ReactNode;\n}\n\n/**\n * Generic, typed list that renders a `<ul>` with one `<li>` per item.\n *\n * The component is generic over the item type so `renderItem` and\n * `keyExtractor` infer their argument types from `items`. When `items` is\n * empty it renders `empty` (or nothing) instead of an empty list.\n *\n * @param items - The collection to render.\n * @param renderItem - Renders the contents of each list item.\n * @param keyExtractor - Optional stable key derivation (defaults to index).\n * @param empty - Optional node shown when there are no items.\n * @returns The rendered list, or the `empty` node when there are no items.\n */\nexport function DataList<T>({\n    items,\n    renderItem,\n    keyExtractor,\n    empty,\n    className,\n    ...props\n}: DataListProps<T>) {\n    if (items.length === 0) {\n        return <>{empty ?? null}</>;\n    }\n\n    return (\n        <ul className={cn(styles.list, className)} {...props}>\n            {items.map((item, index) => (\n                <li key={keyExtractor ? keyExtractor(item, index) : index} className={styles.item}>\n                    {renderItem(item, index)}\n                </li>\n            ))}\n        </ul>\n    );\n}\n"],"mappings":"4GA4BA,SAAgB,EAAY,CACxB,QACA,aACA,eACA,QACA,YACA,GAAG,GACc,CAKjB,OAJI,EAAM,SAAW,GACV,EAAA,EAAA,IAAA,CAAA,EAAA,SAAA,CAAA,SAAG,GAAS,IAAO,CAAA,GAI1B,EAAA,EAAA,IAAA,CAAC,KAAD,CAAI,UAAW,EAAA,GAAG,EAAA,QAAO,KAAM,CAAS,EAAG,GAAI,EAC1C,SAAA,EAAM,KAAK,EAAM,KACd,EAAA,EAAA,IAAA,CAAC,KAAD,CAA2D,UAAW,EAAA,QAAO,KACxE,SAAA,EAAW,EAAM,CAAK,CACvB,EAFK,EAAe,EAAa,EAAM,CAAK,EAAI,CAEhD,CACP,CACD,CAAA,CAEZ"}