@scrolia/react-native-flash-list
Version:
A set of list components for Scrolia React Native
1 lines • 2.61 kB
Source Map (JSON)
{"version":3,"file":"y.mjs","names":["p: FlashListYProps<T>"],"sources":["../src/y.tsx"],"sourcesContent":["\"use client\";\n\nimport type { FlashListProps, FlashListRef } from \"@shopify/flash-list\";\n\nimport { useScrollCore } from \"@scrolia/react-native/contexts/scrollcore\";\nimport { getComponentProps } from \"@scrolia/react-native/functions/props\";\nimport { useContentYHandler } from \"@scrolia/react-native/hooks/content\";\nimport { FlashList } from \"@shopify/flash-list\";\nimport * as React from \"react\";\n\n/** Props for the `FlashListY` component. */\ntype FlashListYProps<T> = FlashListProps<T> & {\n ref?: React.Ref<FlashListRef<T>>;\n};\n\n/**\n * Vertical list component based on `@shopify/flash-list`.\n *\n * **This component requires `@shopify/flash-list` to be installed.**\n */\nconst FlashListY = <T,>(props: FlashListYProps<T>): React.JSX.Element => {\n const {\n options: { disabled, plugins },\n y: { contentType, contentRef },\n } = useScrollCore();\n\n const p: FlashListYProps<T> = getComponentProps({\n name: \"listY\",\n props,\n plugins,\n });\n\n React.useImperativeHandle(p.ref, (): FlashListRef<T> => {\n return contentRef.current as FlashListRef<T>;\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,\n });\n\n return (\n <FlashList\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 </FlashList>\n );\n};\n\nexport type { FlashListYProps };\nexport { FlashListY };\n"],"mappings":";;;;;;;;;;;;;;AAoBA,MAAM,cAAkB,UAAiD;CACrE,MAAM,EACF,SAAS,EAAE,UAAU,WACrB,GAAG,EAAE,aAAa,iBAClB,eAAe;CAEnB,MAAMA,IAAwB,kBAAkB;EAC5C,MAAM;EACN;EACA;EACH,CAAC;AAEF,OAAM,oBAAoB,EAAE,WAA4B;AACpD,SAAO,WAAW;IACnB,CACC,WACH,CAAC;AAEF,OAAM,gBAAsB;AACxB,cAAY,UAAU;IACvB,CACC,YACH,CAAC;CAEF,MAAM,EAAE,UAAU,qBAAqB,aAAa,mBAAmB,EACnE,OACH,CAAC;AAEF,QACI,oBAAC;EACG,GAAI;EACJ,KAAK;EACL,gCAAgC;EAChC,8BACI,EAAE,kCAAkC;EAE9B;EACW;EACX;EACV,YAAY;EACZ,qBAAqB,EAAE,uBAAuB;YAE7C,EAAE;GACK"}