import * as React from "react"; import { ScrollView } from "react-native"; import type { NativeScrollerProps } from "./NativeScroller"; type NativeScrollerWebProps = NativeScrollerProps & { dataSet?: Record; }; export const NativeScroller = React.forwardRef< React.ElementRef, NativeScrollerProps >(function NativeScroller(inputProps, ref) { const { dataSet, pagerScrollKey, topOverlay: _topOverlay, topScrollEdgeEffect: _topScrollEdgeEffect, ...props } = inputProps as NativeScrollerWebProps; const scrollRef = React.useRef>(null); const setRef = React.useCallback( (node: React.ElementRef | null) => { scrollRef.current = node; if (typeof ref === "function") ref(node); else if (ref) ref.current = node; }, [ref] ); React.useLayoutEffect(() => { const element = scrollRef.current?.getScrollableNode() as unknown as | HTMLElement | undefined; const EventConstructor = element?.ownerDocument?.defaultView?.Event; if (EventConstructor) element.dispatchEvent( new EventConstructor("ok-collapsible-pager-scroll-key-changed", { bubbles: true, }) ); }, [pagerScrollKey]); const webDataProps = { dataSet: { ...dataSet, collapsiblePagerScroll: "true", collapsiblePagerScrollKey: pagerScrollKey ?? "", }, }; return ; }); NativeScroller.displayName = "NativeScroller"; export type { NativeScrollerProps } from "./NativeScroller";