UNPKG

@tamagui/react-native-web-lite

Version:
92 lines (91 loc) 2.54 kB
import { VirtualizedSectionList } from "../VirtualizedSectionList/index.mjs"; import * as React from "react"; import { jsx } from "react/jsx-runtime"; class SectionList extends React.PureComponent { scrollToLocation(params) { if (this._wrapperListRef != null) { this._wrapperListRef.scrollToLocation(params); } } recordInteraction() { const listRef = this._wrapperListRef && this._wrapperListRef.getListRef(); listRef && listRef.recordInteraction(); } flashScrollIndicators() { const listRef = this._wrapperListRef && this._wrapperListRef.getListRef(); listRef && listRef.flashScrollIndicators(); } getScrollResponder() { const listRef = this._wrapperListRef && this._wrapperListRef.getListRef(); if (listRef) { return listRef.getScrollResponder(); } } getScrollableNode() { const listRef = this._wrapperListRef && this._wrapperListRef.getListRef(); if (listRef) { return listRef.getScrollableNode(); } } setNativeProps(props) { const listRef = this._wrapperListRef && this._wrapperListRef.getListRef(); if (listRef) { listRef.setNativeProps(props); } } render() { const { sections, ...passThroughProps } = this.props; return /* @__PURE__ */jsx(VirtualizedSectionList, { ...passThroughProps, sections, ref: this._captureRef, getItem: this._getItem, getItemCount: this._getItemCount, keyExtractor: this._keyExtractor, renderItem: this._renderItem }); } _captureRef = ref => { this._wrapperListRef = ref; }; _getItem = (sections, index) => { if (!sections) { return null; } const section = sections[index]; return section && section.data ? section.data[0] : null; }; _getItemCount = sections => { return sections ? sections.length : 0; }; _keyExtractor = (item, index) => { const keyExtractor = this.props.keyExtractor || this._defaultKeyExtractor; return keyExtractor(item, index); }; _defaultKeyExtractor = (item, index) => { return item.key != null ? item.key : String(index); }; _renderItem = ({ item, index, section }) => { const renderItem = this.props.renderItem || this._defaultRenderItem; return renderItem({ item, index, section }); }; _defaultRenderItem = ({ item }) => { return null; }; } var SectionList_default = SectionList; export { SectionList, SectionList_default as default }; //# sourceMappingURL=index.mjs.map