@scrolia/react-native
Version:
A headless scrollbar component
1 lines • 2.52 kB
Source Map (JSON)
{"version":3,"file":"y.mjs","names":["props: ContentYProps","p: ContentYProps"],"sources":["../../../src/components/content/y.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 { useContentYHandler } from \"#/hooks/content\";\n\n/** Props for the `ContentY` component. */\ntype ContentYProps = ScrollViewProps & {\n ref?: React.Ref<ScrollView>;\n};\n\n/**\n * Vertical Content component.\n *\n * Use `ListY` for a list of items.\n */\nconst ContentY = (props: ContentYProps): React.JSX.Element => {\n const {\n options: { disabled, plugins },\n y: { contentRef, contentType },\n } = useScrollCore();\n\n const p: ContentYProps = getComponentProps({\n name: \"contentY\",\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 } = useContentYHandler({\n props: p,\n });\n\n return (\n <ScrollView\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 </ScrollView>\n );\n};\n\nexport type { ContentYProps };\nexport { ContentY };\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAM,WAAW,CAACA,UAA4C;CAC1D,MAAM,EACF,SAAS,EAAE,UAAU,SAAS,EAC9B,GAAG,EAAE,YAAY,aAAa,EACjC,GAAG,eAAe;CAEnB,MAAMC,IAAmB,kBAAkB;EACvC,MAAM;EACN;EACA;CACH,EAAC;CAEF,MAAM,oBAAoB,EAAE,KAAK,MAAkB;AAC/C,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,OAAO,EACV,EAAC;AAEF,4BACK;EACG,GAAI;EACJ,KAAK;EACL,gCAAgC;EAChC,8BACI,EAAE,kCAAkC;EAE9B;EACW;EACX;EACV,YAAY;EACZ,qBAAqB,EAAE,uBAAuB;YAE7C,EAAE;GACM;AAEpB"}