@scrolia/react-native-flash-list
Version:
A set of list components for Scrolia React Native
1 lines • 2.69 kB
Source Map (JSON)
{"version":3,"file":"y.mjs","names":["props: FlashListYProps<T>","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,aAAa,CAAKA,UAAiD;CACrE,MAAM,EACF,SAAS,EAAE,UAAU,SAAS,EAC9B,GAAG,EAAE,aAAa,YAAY,EACjC,GAAG,eAAe;CAEnB,MAAMC,IAAwB,kBAAkB;EAC5C,MAAM;EACN;EACA;CACH,EAAC;CAEF,MAAM,oBAAoB,EAAE,KAAK,MAAuB;AACpD,SAAO,WAAW;CACrB,GAAE,CACC,UACH,EAAC;CAEF,MAAM,UAAU,MAAY;EACxB,YAAY,UAAU;CACzB,GAAE,CACC,WACH,EAAC;CAEF,MAAM,EAAE,UAAU,qBAAqB,UAAU,GAAG,mBAAmB,EACnE,MACH,EAAC;AAEF,4BACK;EACG,GAAI;EACJ,KAAK;EACL,gCAAgC;EAChC,8BACI,EAAE,kCAAkC;EAE9B;EACW;EACX;EACV,YAAY;EACZ,qBAAqB,EAAE,uBAAuB;YAE7C,EAAE;GACK;AAEnB"}