@scrolia/react-native
Version:
A headless scrollbar component
1 lines • 2.44 kB
Source Map (JSON)
{"version":3,"file":"x.mjs","names":[],"sources":["../../../src/components/content/x.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ScrollViewProps } from \"react-native\";\n\nimport * as React from \"react\";\nimport { ScrollView } from \"react-native\";\n\nimport { useScrollCore } from \"#/contexts/scrollcore\";\nimport { getComponentProps } from \"#/functions/props\";\nimport { useContentXHandler } from \"#/hooks/content\";\n\n/** Props for the `ContentX` component. */\ntype ContentXProps = ScrollViewProps & {\n ref?: React.Ref<ScrollView>;\n};\n\n/**\n * Horizontal Content component.\n *\n * Use `ListX` for a list of items.\n */\nconst ContentX = (props: ContentXProps): React.JSX.Element => {\n const {\n options: { disabled, plugins },\n x: { contentRef, contentType },\n } = useScrollCore();\n\n const p: ContentXProps = getComponentProps({\n name: \"contentX\",\n props,\n plugins,\n });\n\n React.useImperativeHandle(p.ref, (): ScrollView => {\n return contentRef.current as ScrollView;\n }, [\n contentRef,\n ]);\n\n React.useEffect((): void => {\n contentType.current = \"scrollview\";\n }, [\n contentType,\n ]);\n\n const { onLayout, onContentSizeChange, onScroll } = useContentXHandler({\n props: p,\n });\n\n return (\n <ScrollView\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 </ScrollView>\n );\n};\n\nexport type { ContentXProps };\nexport { ContentX };\n"],"mappings":";;;;;;;;;;;;;;AAqBA,MAAM,YAAY,UAA4C;CAC1D,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,WAAuB;AAC/C,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,YAAD;EACI,GAAI;EACJ,KAAK;EACL,gCACI,EAAE,kCAAkC;EAExC,8BAA8B;EACpB;EACW;EACX;EACV,YAAY;EACZ,qBAAqB,EAAE,uBAAuB;YAE7C,EAAE;EACM"}