@scrolia/react-native-flash-list
Version:
A set of list components for Scrolia React Native
1 lines • 2.62 kB
Source Map (JSON)
{"version":3,"file":"x.mjs","names":["p: FlashListXProps<T>"],"sources":["../src/x.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 { useContentXHandler } from \"@scrolia/react-native/hooks/content\";\nimport { FlashList } from \"@shopify/flash-list\";\nimport * as React from \"react\";\n\n/** Props for the `FlashListX` component. */\ntype FlashListXProps<T> = FlashListProps<T> & {\n ref?: React.Ref<FlashListRef<T>>;\n};\n\n/**\n * Horizontal list component based on `@shopify/flash-list`.\n *\n * **This component requires `@shopify/flash-list` to be installed.**\n */\nconst FlashListX = <T,>(props: FlashListXProps<T>): React.JSX.Element => {\n const {\n options: { disabled, plugins },\n x: { contentType, contentRef },\n } = useScrollCore();\n\n const p: FlashListXProps<T> = getComponentProps({\n name: \"listX\",\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 } = useContentXHandler({\n props: p,\n });\n\n return (\n <FlashList\n {...p}\n ref={contentRef}\n showsHorizontalScrollIndicator={\n p.showsHorizontalScrollIndicator ?? disabled\n }\n showsVerticalScrollIndicator={false}\n onLayout={onLayout}\n onContentSizeChange={onContentSizeChange}\n onScroll={onScroll}\n horizontal={true}\n scrollEventThrottle={p.scrollEventThrottle ?? 5}\n >\n {p.children}\n </FlashList>\n );\n};\n\nexport type { FlashListXProps };\nexport { FlashListX };\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,OAAO,GACV,CAAC;AAEF,QACI,oBAAC;EACG,GAAI;EACJ,KAAK;EACL,gCACI,EAAE,kCAAkC;EAExC,8BAA8B;EACpB;EACW;EACX;EACV,YAAY;EACZ,qBAAqB,EAAE,uBAAuB;YAE7C,EAAE;GACK"}