({
collection,
persistedKeys,
scrollRef,
renderDropIndicator
}: CollectionRootProps)
| 97 | } |
| 98 | |
| 99 | function CollectionRoot({ |
| 100 | collection, |
| 101 | persistedKeys, |
| 102 | scrollRef, |
| 103 | renderDropIndicator |
| 104 | }: CollectionRootProps) { |
| 105 | let {layout, layoutOptions, shouldObserveItemSize} = useContext(VirtualizerOptionsContext)!; |
| 106 | // oxlint-disable-next-line react/react-compiler |
| 107 | let layoutOptions2 = layout.useLayoutOptions?.(); |
| 108 | let state = useVirtualizerState({ |
| 109 | allowsWindowScrolling: true, |
| 110 | layout, |
| 111 | collection, |
| 112 | renderView: (type, item) => { |
| 113 | return item?.render?.(item); |
| 114 | }, |
| 115 | onVisibleRectChange(rect) { |
| 116 | let element = scrollRef?.current; |
| 117 | if (element) { |
| 118 | // oxlint-disable-next-line react/react-compiler |
| 119 | element.scrollLeft = rect.x; |
| 120 | element.scrollTop = rect.y; |
| 121 | } |
| 122 | }, |
| 123 | persistedKeys, |
| 124 | layoutOptions: useMemo( |
| 125 | () => |
| 126 | layoutOptions && layoutOptions2 |
| 127 | ? {...layoutOptions, ...layoutOptions2} |
| 128 | : layoutOptions || layoutOptions2, |
| 129 | [layoutOptions, layoutOptions2] |
| 130 | ) |
| 131 | }); |
| 132 | |
| 133 | let {contentProps} = useScrollView( |
| 134 | { |
| 135 | onVisibleRectChange: state.setVisibleRect, |
| 136 | onSizeChange: state.setSize, |
| 137 | contentSize: state.contentSize, |
| 138 | onScrollStart: state.startScrolling, |
| 139 | onScrollEnd: state.endScrolling, |
| 140 | allowsWindowScrolling: true |
| 141 | }, |
| 142 | scrollRef! |
| 143 | ); |
| 144 | |
| 145 | return ( |
| 146 | <div {...contentProps}> |
| 147 | <VirtualizerContext.Provider value={state}> |
| 148 | {renderChildren(null, state.visibleViews, renderDropIndicator, shouldObserveItemSize)} |
| 149 | </VirtualizerContext.Provider> |
| 150 | </div> |
| 151 | ); |
| 152 | } |
| 153 | |
| 154 | function CollectionBranch({parent, renderDropIndicator}: CollectionBranchProps) { |
| 155 | let virtualizer = useContext(VirtualizerContext); |
nothing calls this directly
no test coverage detected