UNPKG

@scrolia/react-native

Version:
1 lines 2.41 kB
{"version":3,"file":"y.mjs","names":[],"sources":["../../../src/components/list/y.tsx"],"sourcesContent":["\"use client\";\n\nimport type { FlatListProps } from \"react-native\";\n\nimport * as React from \"react\";\nimport { FlatList } from \"react-native\";\n\nimport { useScrollCore } from \"#/contexts/scrollcore\";\nimport { getComponentProps } from \"#/functions/props\";\nimport { useContentYHandler } from \"#/hooks/content\";\n\n/** Props for the `ListY` component. */\ntype ListYProps<T> = FlatListProps<T> & {\n ref?: React.Ref<FlatList>;\n};\n\n/**\n * Vertical list component.\n *\n * Use `ContentY` for generic content.\n */\nconst ListY = <T,>(props: ListYProps<T>): React.JSX.Element => {\n const {\n options: { disabled, plugins },\n y: { contentRef, contentType },\n } = useScrollCore();\n\n const p: ListYProps<T> = getComponentProps({\n name: \"listY\",\n props,\n plugins,\n });\n\n React.useImperativeHandle(p.ref, (): FlatList => {\n return contentRef.current as FlatList;\n }, [\n contentRef,\n ]);\n\n React.useEffect((): void => {\n contentType.current = \"flatlist\";\n }, [\n contentType,\n ]);\n\n const { onLayout, onContentSizeChange, onScroll } = useContentYHandler({\n props: p,\n });\n\n return (\n <FlatList\n {...p}\n ref={contentRef}\n showsHorizontalScrollIndicator={false}\n showsVerticalScrollIndicator={\n p.showsHorizontalScrollIndicator ?? disabled\n }\n onLayout={onLayout}\n onContentSizeChange={onContentSizeChange}\n onScroll={onScroll}\n horizontal={false}\n scrollEventThrottle={p.scrollEventThrottle ?? 5}\n >\n {p.children}\n </FlatList>\n );\n};\n\nexport type { ListYProps };\nexport { ListY };\n"],"mappings":";;;;;;;;;;;;;;AAqBA,MAAM,SAAa,UAA4C;CAC3D,MAAM,EACF,SAAS,EAAE,UAAU,WACrB,GAAG,EAAE,YAAY,kBACjB,eAAe;CAEnB,MAAM,IAAmB,kBAAkB;EACvC,MAAM;EACN;EACA;EACH,CAAC;AAEF,OAAM,oBAAoB,EAAE,WAAqB;AAC7C,SAAO,WAAW;IACnB,CACC,WACH,CAAC;AAEF,OAAM,gBAAsB;AACxB,cAAY,UAAU;IACvB,CACC,YACH,CAAC;CAEF,MAAM,EAAE,UAAU,qBAAqB,aAAa,mBAAmB,EACnE,OAAO,GACV,CAAC;AAEF,QACI,oBAAC,UAAD;EACI,GAAI;EACJ,KAAK;EACL,gCAAgC;EAChC,8BACI,EAAE,kCAAkC;EAE9B;EACW;EACX;EACV,YAAY;EACZ,qBAAqB,EAAE,uBAAuB;YAE7C,EAAE;EACI"}