124 lines
4.0 KiB
React
124 lines
4.0 KiB
React
// Metro module 438 (f439).
|
|
import _slicedToArray from "./_slicedToArray";
|
|
import { useState, forwardRef, useCallback, useMemo } from "react";
|
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
import defaultHiddenStyle, { VirtualViewMode } from "./defaultHiddenStyle";
|
|
import Module439 from "./Module439";
|
|
function $mk101267($env) {
|
|
return function SpacerView_withRef(a0, a1) {
|
|
let env28653 = {
|
|
$parent: $env
|
|
};
|
|
const { itemCount, ...rest } = a0;
|
|
env28653[0] = itemCount;
|
|
const r1 = $env.$parent;
|
|
return r1[8]((0, r1[6])(() => {
|
|
const r1 = env28653.$parent.$parent;
|
|
return (0, r1[0])(r1[2][3]).createHiddenVirtualView((0, env28653.$parent[0])(env28653[0]));
|
|
}, [itemCount]), {
|
|
ref: a1,
|
|
...rest
|
|
});
|
|
};
|
|
}
|
|
let env453 = {};
|
|
const defaultItemToKey = function defaultItemToKey({ key }) {
|
|
if (typeof key !== "string") {
|
|
throw new TypeError("Expected 'id' of item to be a string, got: " + typeof key);
|
|
}
|
|
return key;
|
|
};
|
|
export function createVirtualCollectionView(Component, { initial, next }) {
|
|
let c12328_3;
|
|
let env12329;
|
|
c12328_3 = void 0;
|
|
const VirtualCollectionSpacer2 = function VirtualCollectionSpacer({ nativeID, virtualItemCount, onRenderMoreItems: onRenderMoreItems2 }) {
|
|
const r13 = _slicedToArray((0, useState)(c12328_3), 2);
|
|
const SpacerView = r13[0].SpacerView;
|
|
let c23781_2 = r13[1];
|
|
return (0, jsx)(SpacerView, {
|
|
itemCount: virtualItemCount,
|
|
nativeID,
|
|
onModeChange: (a0) => {
|
|
if (a0.mode !== VirtualViewMode.Hidden) {
|
|
let env28654;
|
|
const r16 = next(a0);
|
|
const { itemCount, spacerStyle } = r16;
|
|
const r18 = env28654 = {
|
|
$parent: env453
|
|
};
|
|
env28654[0] = spacerStyle;
|
|
c23781_2({
|
|
SpacerView: forwardRef($mk101267(r18))
|
|
});
|
|
onRenderMoreItems2(Math.min(Math.ceil(itemCount), virtualItemCount));
|
|
}
|
|
}
|
|
});
|
|
};
|
|
const spacerStyle = initial.spacerStyle;
|
|
const r9 = env12329 = {
|
|
$parent: env453
|
|
};
|
|
env12329[0] = spacerStyle;
|
|
c12328_3 = {
|
|
SpacerView: forwardRef($mk101267(r9))
|
|
};
|
|
return function VirtualCollectionView(props) {
|
|
let c23782_6, virtualItemCount2;
|
|
const { children, items, itemToKey = defaultItemToKey, removeClippedSubviews: _removeClippedSubviews, testID, ...props2 } = props;
|
|
let c23782_2 = itemToKey;
|
|
let removeClippedSubviews2 = props.removeClippedSubviews;
|
|
if (removeClippedSubviews2 === void 0) {
|
|
removeClippedSubviews2 = false;
|
|
}
|
|
let c23783_0;
|
|
const removeClippedSubviews = removeClippedSubviews2;
|
|
c23782_6 = void 0;
|
|
virtualItemCount2 = void 0;
|
|
let [r27, c23782_5] = (0, useState)(Math.ceil(initial.itemCount));
|
|
const r32 = (0, useCallback)((a0) => {
|
|
const nativeID = c23782_2(a0);
|
|
return jsxs(defaultHiddenStyle, {
|
|
nativeID,
|
|
removeClippedSubviews,
|
|
children: [Module439 != null ? (0, jsx)(Module439, {
|
|
nativeID
|
|
}) : null, children(a0, nativeID)]
|
|
}, nativeID);
|
|
}, [children, itemToKey, removeClippedSubviews]);
|
|
c23783_0 = r32;
|
|
c23782_6 = useMemo(() => {
|
|
let c31153_0 = c23783_0;
|
|
let c31153_1 = new WeakMap();
|
|
return (a0) => {
|
|
let r6 = c31153_1.get(a0);
|
|
if (r6 == null) {
|
|
const r9 = c31153_0(a0);
|
|
c31153_1.set(a0, r9);
|
|
r6 = r9;
|
|
}
|
|
return r6;
|
|
};
|
|
}, [r32]);
|
|
const length = Math.min(r27, items.size);
|
|
const r46 = Array.from({
|
|
length
|
|
}, (a0, a1) => c23782_6(items.at(a1)));
|
|
virtualItemCount2 = items.size - length;
|
|
return <Component {...props2} spacer={useMemo(() => {
|
|
let r2 = null;
|
|
if (virtualItemCount2 !== 0) {
|
|
let r11 = testID;
|
|
if (testID == null) {
|
|
r11 = "";
|
|
}
|
|
r2 = <VirtualCollectionSpacer2 nativeID={`${r11}:Spacer`} virtualItemCount={virtualItemCount2} onRenderMoreItems={(c31154_0) => {
|
|
c23782_5((a0) => a0 + c31154_0);
|
|
}} />;
|
|
}
|
|
return r2;
|
|
}, [virtualItemCount2, testID])}>{r46}</Component>;
|
|
};
|
|
}
|