import type { Meta, StoryObj } from "@storybook/react-vite"; import type { ReactNode } from "react"; import { Box } from "../containers/Box"; import { Story } from "../story-components/Story"; import { SectionList } from "./SectionList"; import { Text } from "./Text"; import { View } from "./View"; export default { title: "alouette/Primitives/SectionList", component: SectionList, parameters: { componentSubtitle: "A performant, sectioned list (RN SectionList) with className support for the list and its content container", docs: { description: { component: `### Features - Grouped data via \`sections\`, each with a \`renderSectionHeader\` - Virtualized rendering for long lists - NativeWind \`className\` (maps to \`style\`) and \`contentContainerClassName\` (maps to \`contentContainerStyle\`) ### Usage ~~~tsx item + index} renderSectionHeader={({ section }) => {section.title}} renderItem={({ item }) => {item}} /> ~~~`, }, }, }, } satisfies Meta; interface Contact { name: string; } interface ContactSection { title: string; data: Contact[]; } function ContactRow({ name }: Contact): ReactNode { return ( {name} ); } function SectionHeader({ title }: { title: string }): ReactNode { return ( {title} ); } interface ContactSectionListProps { stickySectionHeadersEnabled?: boolean; contentContainerClassName?: string; } function ContactSectionList({ stickySectionHeadersEnabled, contentContainerClassName, }: ContactSectionListProps): ReactNode { return ( sections={[ { title: "A", data: [{ name: "Aaron" }, { name: "Alice" }, { name: "Avery" }], }, { title: "B", data: [{ name: "Bianca" }, { name: "Bruno" }] }, { title: "C", data: [{ name: "Cara" }, { name: "Cyrus" }, { name: "Colette" }], }, ]} stickySectionHeadersEnabled={stickySectionHeadersEnabled} contentContainerClassName={contentContainerClassName} keyExtractor={(item, index) => `${item.name}${index}`} renderSectionHeader={({ section }) => ( )} renderItem={({ item }) => } /> ); } export const PreviewStory: StoryObj = { name: "SectionList Preview", parameters: { layout: "padded", chromatic: { disableSnapshot: true }, }, render: () => , }; export const VariantsStory: StoryObj = { name: "SectionList", render: () => ( ), };