import type { Meta, StoryObj } from "@storybook/react-vite"; import type { ReactNode } from "react"; import { type SafeAreaEdge, SafeAreaScope, } from "../../core/SafeAreaEdgesContext"; import { Box } from "../containers/Box"; import { Text } from "../primitives/Text"; import { View } from "../primitives/View"; import { Story } from "../story-components/Story"; import { ScreenFlatList } from "./ScreenFlatList"; export default { title: "alouette/Layout/ScreenFlatList", component: ScreenFlatList, parameters: { componentSubtitle: "A screen-filling FlatList: bg-screen frame, growing content, safe-area insets as content padding", docs: { description: { component: `### Features - \`bg-screen min-h-full\` frame and a \`grow\` content container, both extendable through \`className\` / \`contentContainerClassName\` (merged with tailwind-merge) - Safe-area insets applied to the **content**, so rows scroll under the system bars but the first and last one clear them - Edges default to everything an ancestor \`SafeAreaScope\` has not declared consumed; \`edges\` overrides them per screen - Insets are native-only: \`useSafeAreaInsets\` is stubbed to zeros on web ### Usage ~~~tsx data={contacts} contentContainerClassName="p-m gap-xxs" keyExtractor={(item) => item.name} renderItem={({ item }) => } /> ~~~`, }, }, }, } satisfies Meta; interface Contact { name: string; } function ContactRow({ name }: Contact): ReactNode { return ( {name} ); } interface ContactScreenListProps { edges?: readonly SafeAreaEdge[]; } function ContactScreenList({ edges }: ContactScreenListProps): ReactNode { return ( data={[ { name: "Aaron" }, { name: "Alice" }, { name: "Bianca" }, { name: "Bruno" }, { name: "Cara" }, { name: "Colette" }, { name: "Cyrus" }, { name: "Avery" }, ]} edges={edges} contentContainerClassName="p-m gap-xxs" keyExtractor={(item) => item.name} renderItem={({ item }) => } /> ); } export const PreviewStory: StoryObj = { name: "ScreenFlatList Preview", parameters: { chromatic: { disableSnapshot: true } }, render: () => , }; export const VariantsStory: StoryObj = { name: "ScreenFlatList", render: () => ( ), };