@legendapp/list 2.0.0 → 2.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.mts +7 -3
- package/index.d.ts +7 -3
- package/index.js +767 -550
- package/index.mjs +721 -504
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var reactNative = require('react-native');
|
|
3
|
+
var React4 = require('react');
|
|
5
4
|
var shim = require('use-sync-external-store/shim');
|
|
5
|
+
var reactDom = require('react-dom');
|
|
6
6
|
|
|
7
7
|
function _interopNamespace(e) {
|
|
8
8
|
if (e && e.__esModule) return e;
|
|
@@ -22,14 +22,27 @@ function _interopNamespace(e) {
|
|
|
22
22
|
return Object.freeze(n);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
var
|
|
25
|
+
var React4__namespace = /*#__PURE__*/_interopNamespace(React4);
|
|
26
26
|
|
|
27
27
|
// src/components/LegendList.tsx
|
|
28
|
-
var
|
|
28
|
+
var AnimatedView = React4.forwardRef(function AnimatedView2(props, ref) {
|
|
29
|
+
return /* @__PURE__ */ React4__namespace.createElement("div", { ref, ...props });
|
|
30
|
+
});
|
|
31
|
+
var View = React4.forwardRef(function View2(props, ref) {
|
|
32
|
+
return /* @__PURE__ */ React4__namespace.createElement("div", { ref, ...props });
|
|
33
|
+
});
|
|
34
|
+
var Text = View;
|
|
35
|
+
|
|
36
|
+
// src/platform/Animated.tsx
|
|
37
|
+
var createAnimatedValue = (value) => value;
|
|
38
|
+
|
|
39
|
+
// src/state/state.tsx
|
|
40
|
+
var ContextState = React4__namespace.createContext(null);
|
|
29
41
|
function StateProvider({ children }) {
|
|
30
|
-
const [value] =
|
|
31
|
-
animatedScrollY:
|
|
42
|
+
const [value] = React4__namespace.useState(() => ({
|
|
43
|
+
animatedScrollY: createAnimatedValue(0),
|
|
32
44
|
columnWrapperStyle: void 0,
|
|
45
|
+
internalState: void 0,
|
|
33
46
|
listeners: /* @__PURE__ */ new Map(),
|
|
34
47
|
mapViewabilityAmountCallbacks: /* @__PURE__ */ new Map(),
|
|
35
48
|
mapViewabilityAmountValues: /* @__PURE__ */ new Map(),
|
|
@@ -45,10 +58,10 @@ function StateProvider({ children }) {
|
|
|
45
58
|
]),
|
|
46
59
|
viewRefs: /* @__PURE__ */ new Map()
|
|
47
60
|
}));
|
|
48
|
-
return /* @__PURE__ */
|
|
61
|
+
return /* @__PURE__ */ React4__namespace.createElement(ContextState.Provider, { value }, children);
|
|
49
62
|
}
|
|
50
63
|
function useStateContext() {
|
|
51
|
-
return
|
|
64
|
+
return React4__namespace.useContext(ContextState);
|
|
52
65
|
}
|
|
53
66
|
function createSelectorFunctionsArr(ctx, signalNames) {
|
|
54
67
|
let lastValues = [];
|
|
@@ -118,23 +131,23 @@ function getContentSize(ctx) {
|
|
|
118
131
|
return headerSize + footerSize + totalSize + stylePaddingTop;
|
|
119
132
|
}
|
|
120
133
|
function useArr$(signalNames) {
|
|
121
|
-
const ctx =
|
|
122
|
-
const { subscribe, get } =
|
|
134
|
+
const ctx = React4__namespace.useContext(ContextState);
|
|
135
|
+
const { subscribe, get } = React4__namespace.useMemo(() => createSelectorFunctionsArr(ctx, signalNames), [ctx, signalNames]);
|
|
123
136
|
const value = shim.useSyncExternalStore(subscribe, get);
|
|
124
137
|
return value;
|
|
125
138
|
}
|
|
126
139
|
function useSelector$(signalName, selector) {
|
|
127
|
-
const ctx =
|
|
128
|
-
const { subscribe, get } =
|
|
140
|
+
const ctx = React4__namespace.useContext(ContextState);
|
|
141
|
+
const { subscribe, get } = React4__namespace.useMemo(() => createSelectorFunctionsArr(ctx, [signalName]), [ctx, signalName]);
|
|
129
142
|
const value = shim.useSyncExternalStore(subscribe, () => selector(get()[0]));
|
|
130
143
|
return value;
|
|
131
144
|
}
|
|
132
145
|
|
|
133
146
|
// src/components/DebugView.tsx
|
|
134
147
|
var DebugRow = ({ children }) => {
|
|
135
|
-
return /* @__PURE__ */
|
|
148
|
+
return /* @__PURE__ */ React4__namespace.createElement(View, { style: { alignItems: "center", flexDirection: "row", justifyContent: "space-between" } }, children);
|
|
136
149
|
};
|
|
137
|
-
var DebugView =
|
|
150
|
+
var DebugView = React4__namespace.memo(function DebugView2({ state }) {
|
|
138
151
|
const ctx = useStateContext();
|
|
139
152
|
const [totalSize = 0, scrollAdjust = 0, rawScroll = 0, scroll = 0, _numContainers = 0, _numContainersPooled = 0] = useArr$([
|
|
140
153
|
"totalSize",
|
|
@@ -145,12 +158,12 @@ var DebugView = React3__namespace.memo(function DebugView2({ state }) {
|
|
|
145
158
|
"numContainersPooled"
|
|
146
159
|
]);
|
|
147
160
|
const contentSize = getContentSize(ctx);
|
|
148
|
-
const [, forceUpdate] =
|
|
161
|
+
const [, forceUpdate] = React4.useReducer((x) => x + 1, 0);
|
|
149
162
|
useInterval(() => {
|
|
150
163
|
forceUpdate();
|
|
151
164
|
}, 100);
|
|
152
|
-
return /* @__PURE__ */
|
|
153
|
-
|
|
165
|
+
return /* @__PURE__ */ React4__namespace.createElement(
|
|
166
|
+
View,
|
|
154
167
|
{
|
|
155
168
|
pointerEvents: "none",
|
|
156
169
|
style: {
|
|
@@ -165,75 +178,106 @@ var DebugView = React3__namespace.memo(function DebugView2({ state }) {
|
|
|
165
178
|
top: 0
|
|
166
179
|
}
|
|
167
180
|
},
|
|
168
|
-
/* @__PURE__ */
|
|
169
|
-
/* @__PURE__ */
|
|
170
|
-
/* @__PURE__ */
|
|
171
|
-
/* @__PURE__ */
|
|
172
|
-
/* @__PURE__ */
|
|
173
|
-
/* @__PURE__ */
|
|
174
|
-
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, "RawScroll: "), /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, rawScroll.toFixed(2))),
|
|
175
|
-
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, "ComputedScroll: "), /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, scroll.toFixed(2)))
|
|
181
|
+
/* @__PURE__ */ React4__namespace.createElement(DebugRow, null, /* @__PURE__ */ React4__namespace.createElement(Text, null, "TotalSize:"), /* @__PURE__ */ React4__namespace.createElement(Text, null, totalSize.toFixed(2))),
|
|
182
|
+
/* @__PURE__ */ React4__namespace.createElement(DebugRow, null, /* @__PURE__ */ React4__namespace.createElement(Text, null, "ContentSize:"), /* @__PURE__ */ React4__namespace.createElement(Text, null, contentSize.toFixed(2))),
|
|
183
|
+
/* @__PURE__ */ React4__namespace.createElement(DebugRow, null, /* @__PURE__ */ React4__namespace.createElement(Text, null, "At end:"), /* @__PURE__ */ React4__namespace.createElement(Text, null, String(state.isAtEnd))),
|
|
184
|
+
/* @__PURE__ */ React4__namespace.createElement(DebugRow, null, /* @__PURE__ */ React4__namespace.createElement(Text, null, "ScrollAdjust:"), /* @__PURE__ */ React4__namespace.createElement(Text, null, scrollAdjust.toFixed(2))),
|
|
185
|
+
/* @__PURE__ */ React4__namespace.createElement(DebugRow, null, /* @__PURE__ */ React4__namespace.createElement(Text, null, "RawScroll: "), /* @__PURE__ */ React4__namespace.createElement(Text, null, rawScroll.toFixed(2))),
|
|
186
|
+
/* @__PURE__ */ React4__namespace.createElement(DebugRow, null, /* @__PURE__ */ React4__namespace.createElement(Text, null, "ComputedScroll: "), /* @__PURE__ */ React4__namespace.createElement(Text, null, scroll.toFixed(2)))
|
|
176
187
|
);
|
|
177
188
|
});
|
|
178
189
|
function useInterval(callback, delay) {
|
|
179
|
-
|
|
190
|
+
React4.useEffect(() => {
|
|
180
191
|
const interval = setInterval(callback, delay);
|
|
181
192
|
return () => clearInterval(interval);
|
|
182
193
|
}, [delay]);
|
|
183
194
|
}
|
|
184
|
-
var
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
var ENABLE_DEBUG_VIEW = __DEV__ && false;
|
|
194
|
-
var IsNewArchitecture = global.nativeFabricUIManager != null;
|
|
195
|
-
var useAnimatedValue = (initialValue) => {
|
|
196
|
-
return React3.useRef(new reactNative.Animated.Value(initialValue)).current;
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
// src/hooks/useValue$.ts
|
|
200
|
-
function useValue$(key, params) {
|
|
201
|
-
var _a;
|
|
202
|
-
const { getValue, delay } = params || {};
|
|
203
|
-
const ctx = useStateContext();
|
|
204
|
-
const animValue = useAnimatedValue((_a = getValue ? getValue(peek$(ctx, key)) : peek$(ctx, key)) != null ? _a : 0);
|
|
205
|
-
React3.useMemo(() => {
|
|
206
|
-
let newValue;
|
|
207
|
-
let prevValue;
|
|
208
|
-
let didQueueTask = false;
|
|
209
|
-
listen$(ctx, key, (v) => {
|
|
210
|
-
newValue = getValue ? getValue(v) : v;
|
|
211
|
-
if (delay !== void 0) {
|
|
212
|
-
const fn = () => {
|
|
213
|
-
didQueueTask = false;
|
|
214
|
-
if (newValue !== void 0) {
|
|
215
|
-
animValue.setValue(newValue);
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
const delayValue = typeof delay === "function" ? delay(newValue, prevValue) : delay;
|
|
219
|
-
prevValue = newValue;
|
|
220
|
-
if (!didQueueTask) {
|
|
221
|
-
didQueueTask = true;
|
|
222
|
-
if (delayValue === 0) {
|
|
223
|
-
queueMicrotask(fn);
|
|
224
|
-
} else {
|
|
225
|
-
setTimeout(fn, delayValue);
|
|
195
|
+
var globalResizeObserver = null;
|
|
196
|
+
function getGlobalResizeObserver() {
|
|
197
|
+
if (!globalResizeObserver) {
|
|
198
|
+
globalResizeObserver = new ResizeObserver((entries) => {
|
|
199
|
+
for (const entry of entries) {
|
|
200
|
+
const callbacks = callbackMap.get(entry.target);
|
|
201
|
+
if (callbacks) {
|
|
202
|
+
for (const callback of callbacks) {
|
|
203
|
+
callback(entry);
|
|
226
204
|
}
|
|
227
205
|
}
|
|
228
|
-
} else {
|
|
229
|
-
animValue.setValue(newValue);
|
|
230
206
|
}
|
|
231
207
|
});
|
|
208
|
+
}
|
|
209
|
+
return globalResizeObserver;
|
|
210
|
+
}
|
|
211
|
+
var callbackMap = /* @__PURE__ */ new WeakMap();
|
|
212
|
+
function useResizeObserver(element, callback) {
|
|
213
|
+
React4.useEffect(() => {
|
|
214
|
+
if (!element) return;
|
|
215
|
+
const observer = getGlobalResizeObserver();
|
|
216
|
+
let callbacks = callbackMap.get(element);
|
|
217
|
+
if (!callbacks) {
|
|
218
|
+
callbacks = /* @__PURE__ */ new Set();
|
|
219
|
+
callbackMap.set(element, callbacks);
|
|
220
|
+
observer.observe(element);
|
|
221
|
+
}
|
|
222
|
+
callbacks.add(callback);
|
|
223
|
+
return () => {
|
|
224
|
+
const callbacks2 = callbackMap.get(element);
|
|
225
|
+
if (callbacks2) {
|
|
226
|
+
callbacks2.delete(callback);
|
|
227
|
+
if (callbacks2.size === 0) {
|
|
228
|
+
callbackMap.delete(element);
|
|
229
|
+
observer.unobserve(element);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
}, [element, callback]);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// src/hooks/useSyncLayout.tsx
|
|
237
|
+
function useSyncLayout({
|
|
238
|
+
ref,
|
|
239
|
+
onLayoutChange
|
|
240
|
+
}) {
|
|
241
|
+
var _a, _b;
|
|
242
|
+
useResizeObserver(
|
|
243
|
+
((_b = (_a = ref.current) == null ? void 0 : _a.getScrollableNode) == null ? void 0 : _b.call(_a)) || ref.current,
|
|
244
|
+
React4.useCallback(
|
|
245
|
+
(entry) => {
|
|
246
|
+
onLayoutChange(entry.contentRect, false);
|
|
247
|
+
},
|
|
248
|
+
[onLayoutChange]
|
|
249
|
+
)
|
|
250
|
+
);
|
|
251
|
+
React4.useLayoutEffect(() => {
|
|
252
|
+
if (ref.current) {
|
|
253
|
+
const rect = ref.current.getBoundingClientRect();
|
|
254
|
+
onLayoutChange(
|
|
255
|
+
{
|
|
256
|
+
height: rect.height,
|
|
257
|
+
width: rect.width,
|
|
258
|
+
x: rect.left,
|
|
259
|
+
y: rect.top
|
|
260
|
+
},
|
|
261
|
+
true
|
|
262
|
+
);
|
|
263
|
+
}
|
|
232
264
|
}, []);
|
|
233
|
-
return
|
|
265
|
+
return {};
|
|
234
266
|
}
|
|
235
|
-
|
|
236
|
-
|
|
267
|
+
|
|
268
|
+
// src/components/LayoutView.tsx
|
|
269
|
+
var LayoutView = ({ onLayoutChange, refView, children, ...rest }) => {
|
|
270
|
+
const ref = refView != null ? refView : React4.useRef();
|
|
271
|
+
useSyncLayout({ onLayoutChange, ref });
|
|
272
|
+
return /* @__PURE__ */ React4__namespace.createElement("div", { ...rest, ref }, children);
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
// src/constants.ts
|
|
276
|
+
var POSITION_OUT_OF_VIEW = -1e7;
|
|
277
|
+
var ENABLE_DEVMODE = __DEV__ && false;
|
|
278
|
+
var ENABLE_DEBUG_VIEW = __DEV__ && false;
|
|
279
|
+
var typedForwardRef = React4.forwardRef;
|
|
280
|
+
var typedMemo = React4.memo;
|
|
237
281
|
|
|
238
282
|
// src/components/PositionView.tsx
|
|
239
283
|
var PositionViewState = typedMemo(function PositionView({
|
|
@@ -244,73 +288,48 @@ var PositionViewState = typedMemo(function PositionView({
|
|
|
244
288
|
...rest
|
|
245
289
|
}) {
|
|
246
290
|
const [position = POSITION_OUT_OF_VIEW] = useArr$([`containerPosition${id}`]);
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
ref: refView,
|
|
251
|
-
style: [
|
|
252
|
-
style,
|
|
253
|
-
horizontal ? { transform: [{ translateX: position }] } : { transform: [{ translateY: position }] }
|
|
254
|
-
],
|
|
255
|
-
...rest
|
|
256
|
-
}
|
|
257
|
-
);
|
|
258
|
-
});
|
|
259
|
-
var PositionViewAnimated = typedMemo(function PositionView2({
|
|
260
|
-
id,
|
|
261
|
-
horizontal,
|
|
262
|
-
style,
|
|
263
|
-
refView,
|
|
264
|
-
...rest
|
|
265
|
-
}) {
|
|
266
|
-
const position$ = useValue$(`containerPosition${id}`, {
|
|
267
|
-
getValue: (v) => v != null ? v : POSITION_OUT_OF_VIEW
|
|
268
|
-
});
|
|
269
|
-
return /* @__PURE__ */ React3__namespace.createElement(
|
|
270
|
-
reactNative.Animated.View,
|
|
271
|
-
{
|
|
272
|
-
ref: refView,
|
|
273
|
-
style: [
|
|
274
|
-
style,
|
|
275
|
-
horizontal ? { transform: [{ translateX: position$ }] } : { transform: [{ translateY: position$ }] }
|
|
276
|
-
],
|
|
277
|
-
...rest
|
|
278
|
-
}
|
|
279
|
-
);
|
|
291
|
+
const base = Array.isArray(style) ? Object.assign({}, ...style) : style;
|
|
292
|
+
const combinedStyle = horizontal ? { ...base, left: position } : { ...base, top: position };
|
|
293
|
+
return /* @__PURE__ */ React4__namespace.createElement(LayoutView, { refView, style: combinedStyle, ...rest });
|
|
280
294
|
});
|
|
281
295
|
var PositionViewSticky = typedMemo(function PositionViewSticky2({
|
|
282
296
|
id,
|
|
283
297
|
horizontal,
|
|
284
298
|
style,
|
|
285
299
|
refView,
|
|
286
|
-
animatedScrollY,
|
|
287
|
-
stickyOffset,
|
|
288
300
|
index,
|
|
289
301
|
...rest
|
|
290
302
|
}) {
|
|
291
|
-
const [position = POSITION_OUT_OF_VIEW
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
const viewStyle = React3__namespace.useMemo(() => [style, { zIndex: index + 1e3 }, { transform }], [style, transform]);
|
|
303
|
-
return /* @__PURE__ */ React3__namespace.createElement(reactNative.Animated.View, { ref: refView, style: viewStyle, ...rest });
|
|
303
|
+
const [position = POSITION_OUT_OF_VIEW] = useArr$([`containerPosition${id}`]);
|
|
304
|
+
const viewStyle = React4__namespace.useMemo(() => {
|
|
305
|
+
const base = Array.isArray(style) ? Object.assign({}, ...style) : style;
|
|
306
|
+
const axisStyle = horizontal ? { transform: `translateX(${position}px)` } : { top: position };
|
|
307
|
+
return {
|
|
308
|
+
...base,
|
|
309
|
+
zIndex: index + 1e3,
|
|
310
|
+
...axisStyle
|
|
311
|
+
};
|
|
312
|
+
}, [style, position, horizontal, index]);
|
|
313
|
+
return /* @__PURE__ */ React4__namespace.createElement(LayoutView, { refView, style: viewStyle, ...rest });
|
|
304
314
|
});
|
|
305
|
-
var
|
|
315
|
+
var PositionView2 = PositionViewState;
|
|
306
316
|
function Separator({ ItemSeparatorComponent, itemKey, leadingItem }) {
|
|
307
317
|
const [lastItemKeys] = useArr$(["lastItemKeys"]);
|
|
308
318
|
const isALastItem = lastItemKeys.includes(itemKey);
|
|
309
|
-
return isALastItem ? null : /* @__PURE__ */
|
|
319
|
+
return isALastItem ? null : /* @__PURE__ */ React4__namespace.createElement(ItemSeparatorComponent, { leadingItem });
|
|
310
320
|
}
|
|
321
|
+
|
|
322
|
+
// src/constants-platform.ts
|
|
323
|
+
var IsNewArchitecture = true;
|
|
324
|
+
|
|
325
|
+
// src/platform/Platform.ts
|
|
326
|
+
var Platform = {
|
|
327
|
+
// Widen the type to avoid unreachable-branch lints in cross-platform code that compares against other OSes
|
|
328
|
+
OS: "web"
|
|
329
|
+
};
|
|
311
330
|
var symbolFirst = Symbol();
|
|
312
331
|
function useInit(cb) {
|
|
313
|
-
const refValue =
|
|
332
|
+
const refValue = React4.useRef(symbolFirst);
|
|
314
333
|
if (refValue.current === symbolFirst) {
|
|
315
334
|
refValue.current = cb();
|
|
316
335
|
}
|
|
@@ -349,10 +368,10 @@ function extractPadding(style, contentContainerStyle, type) {
|
|
|
349
368
|
}
|
|
350
369
|
|
|
351
370
|
// src/state/ContextContainer.ts
|
|
352
|
-
var ContextContainer =
|
|
371
|
+
var ContextContainer = React4.createContext(null);
|
|
353
372
|
function useViewability(callback, configId) {
|
|
354
373
|
const ctx = useStateContext();
|
|
355
|
-
const { containerId } =
|
|
374
|
+
const { containerId } = React4.useContext(ContextContainer);
|
|
356
375
|
const key = containerId + (configId != null ? configId : "");
|
|
357
376
|
useInit(() => {
|
|
358
377
|
const value = ctx.mapViewabilityValues.get(key);
|
|
@@ -361,7 +380,7 @@ function useViewability(callback, configId) {
|
|
|
361
380
|
}
|
|
362
381
|
});
|
|
363
382
|
ctx.mapViewabilityCallbacks.set(key, callback);
|
|
364
|
-
|
|
383
|
+
React4.useEffect(
|
|
365
384
|
() => () => {
|
|
366
385
|
ctx.mapViewabilityCallbacks.delete(key);
|
|
367
386
|
},
|
|
@@ -370,7 +389,7 @@ function useViewability(callback, configId) {
|
|
|
370
389
|
}
|
|
371
390
|
function useViewabilityAmount(callback) {
|
|
372
391
|
const ctx = useStateContext();
|
|
373
|
-
const { containerId } =
|
|
392
|
+
const { containerId } = React4.useContext(ContextContainer);
|
|
374
393
|
useInit(() => {
|
|
375
394
|
const value = ctx.mapViewabilityAmountValues.get(containerId);
|
|
376
395
|
if (value) {
|
|
@@ -378,7 +397,7 @@ function useViewabilityAmount(callback) {
|
|
|
378
397
|
}
|
|
379
398
|
});
|
|
380
399
|
ctx.mapViewabilityAmountCallbacks.set(containerId, callback);
|
|
381
|
-
|
|
400
|
+
React4.useEffect(
|
|
382
401
|
() => () => {
|
|
383
402
|
ctx.mapViewabilityAmountCallbacks.delete(containerId);
|
|
384
403
|
},
|
|
@@ -386,12 +405,12 @@ function useViewabilityAmount(callback) {
|
|
|
386
405
|
);
|
|
387
406
|
}
|
|
388
407
|
function useRecyclingEffect(effect) {
|
|
389
|
-
const { index, value } =
|
|
390
|
-
const prevValues =
|
|
408
|
+
const { index, value } = React4.useContext(ContextContainer);
|
|
409
|
+
const prevValues = React4.useRef({
|
|
391
410
|
prevIndex: void 0,
|
|
392
411
|
prevItem: void 0
|
|
393
412
|
});
|
|
394
|
-
|
|
413
|
+
React4.useEffect(() => {
|
|
395
414
|
let ret;
|
|
396
415
|
if (prevValues.current.prevIndex !== void 0 && prevValues.current.prevItem !== void 0) {
|
|
397
416
|
ret = effect({
|
|
@@ -409,12 +428,12 @@ function useRecyclingEffect(effect) {
|
|
|
409
428
|
}, [index, value, effect]);
|
|
410
429
|
}
|
|
411
430
|
function useRecyclingState(valueOrFun) {
|
|
412
|
-
const { index, value, itemKey, triggerLayout } =
|
|
413
|
-
const refState =
|
|
431
|
+
const { index, value, itemKey, triggerLayout } = React4.useContext(ContextContainer);
|
|
432
|
+
const refState = React4.useRef({
|
|
414
433
|
itemKey: null,
|
|
415
434
|
value: null
|
|
416
435
|
});
|
|
417
|
-
const [_, setRenderNum] =
|
|
436
|
+
const [_, setRenderNum] = React4.useState(0);
|
|
418
437
|
const state = refState.current;
|
|
419
438
|
if (state.itemKey !== itemKey) {
|
|
420
439
|
state.itemKey = itemKey;
|
|
@@ -425,7 +444,7 @@ function useRecyclingState(valueOrFun) {
|
|
|
425
444
|
prevItem: void 0
|
|
426
445
|
}) : valueOrFun;
|
|
427
446
|
}
|
|
428
|
-
const setState =
|
|
447
|
+
const setState = React4.useCallback(
|
|
429
448
|
(newState) => {
|
|
430
449
|
state.value = isFunction(newState) ? newState(state.value) : newState;
|
|
431
450
|
setRenderNum((v) => v + 1);
|
|
@@ -436,7 +455,7 @@ function useRecyclingState(valueOrFun) {
|
|
|
436
455
|
return [state.value, setState];
|
|
437
456
|
}
|
|
438
457
|
function useIsLastItem() {
|
|
439
|
-
const { itemKey } =
|
|
458
|
+
const { itemKey } = React4.useContext(ContextContainer);
|
|
440
459
|
const isLast = useSelector$("lastItemKeys", (lastItemKeys) => (lastItemKeys == null ? void 0 : lastItemKeys.includes(itemKey)) || false);
|
|
441
460
|
return isLast;
|
|
442
461
|
}
|
|
@@ -444,14 +463,10 @@ function useListScrollSize() {
|
|
|
444
463
|
const [scrollSize] = useArr$(["scrollSize"]);
|
|
445
464
|
return scrollSize;
|
|
446
465
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
if (IsNewArchitecture) {
|
|
451
|
-
const { triggerLayout: syncLayout } = React3.useContext(ContextContainer);
|
|
466
|
+
function useSyncLayout2() {
|
|
467
|
+
{
|
|
468
|
+
const { triggerLayout: syncLayout } = React4.useContext(ContextContainer);
|
|
452
469
|
return syncLayout;
|
|
453
|
-
} else {
|
|
454
|
-
return noop;
|
|
455
470
|
}
|
|
456
471
|
}
|
|
457
472
|
|
|
@@ -465,35 +480,37 @@ var Container = typedMemo(function Container2({
|
|
|
465
480
|
ItemSeparatorComponent
|
|
466
481
|
}) {
|
|
467
482
|
const ctx = useStateContext();
|
|
468
|
-
const { columnWrapperStyle
|
|
469
|
-
const [column = 0, data, itemKey, numColumns, extraData, isSticky
|
|
483
|
+
const { columnWrapperStyle } = ctx;
|
|
484
|
+
const [column = 0, data, itemKey, numColumns, extraData, isSticky] = useArr$([
|
|
470
485
|
`containerColumn${id}`,
|
|
471
486
|
`containerItemData${id}`,
|
|
472
487
|
`containerItemKey${id}`,
|
|
473
488
|
"numColumns",
|
|
474
489
|
"extraData",
|
|
475
|
-
`containerSticky${id}
|
|
476
|
-
`containerStickyOffset${id}`
|
|
490
|
+
`containerSticky${id}`
|
|
477
491
|
]);
|
|
478
|
-
const refLastSize =
|
|
479
|
-
const ref =
|
|
480
|
-
const [
|
|
492
|
+
const refLastSize = React4.useRef();
|
|
493
|
+
const ref = React4.useRef(null);
|
|
494
|
+
const [_, forceLayoutRender] = React4.useState(0);
|
|
481
495
|
const otherAxisPos = numColumns > 1 ? `${(column - 1) / numColumns * 100}%` : 0;
|
|
482
496
|
const otherAxisSize = numColumns > 1 ? `${1 / numColumns * 100}%` : void 0;
|
|
483
|
-
|
|
484
|
-
const style = React3.useMemo(() => {
|
|
497
|
+
const style = React4.useMemo(() => {
|
|
485
498
|
let paddingStyles;
|
|
486
499
|
if (columnWrapperStyle) {
|
|
487
500
|
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
488
501
|
if (horizontal) {
|
|
502
|
+
const py = numColumns > 1 ? (rowGap || gap || 0) / 2 : void 0;
|
|
489
503
|
paddingStyles = {
|
|
504
|
+
paddingBottom: py,
|
|
490
505
|
paddingRight: columnGap || gap || void 0,
|
|
491
|
-
|
|
506
|
+
paddingTop: py
|
|
492
507
|
};
|
|
493
508
|
} else {
|
|
509
|
+
const px = numColumns > 1 ? (columnGap || gap || 0) / 2 : void 0;
|
|
494
510
|
paddingStyles = {
|
|
495
511
|
paddingBottom: rowGap || gap || void 0,
|
|
496
|
-
|
|
512
|
+
paddingLeft: px,
|
|
513
|
+
paddingRight: px
|
|
497
514
|
};
|
|
498
515
|
}
|
|
499
516
|
}
|
|
@@ -507,18 +524,18 @@ var Container = typedMemo(function Container2({
|
|
|
507
524
|
} : {
|
|
508
525
|
left: otherAxisPos,
|
|
509
526
|
position: "absolute",
|
|
510
|
-
right: numColumns > 1 ?
|
|
527
|
+
right: numColumns > 1 ? void 0 : 0,
|
|
511
528
|
top: 0,
|
|
512
529
|
width: otherAxisSize,
|
|
513
530
|
...paddingStyles || {}
|
|
514
531
|
};
|
|
515
532
|
}, [horizontal, otherAxisPos, otherAxisSize, columnWrapperStyle, numColumns]);
|
|
516
|
-
const renderedItemInfo =
|
|
533
|
+
const renderedItemInfo = React4.useMemo(
|
|
517
534
|
() => itemKey !== void 0 ? getRenderedItem2(itemKey) : null,
|
|
518
535
|
[itemKey, data, extraData]
|
|
519
536
|
);
|
|
520
537
|
const { index, renderedItem } = renderedItemInfo || {};
|
|
521
|
-
const contextValue =
|
|
538
|
+
const contextValue = React4.useMemo(() => {
|
|
522
539
|
ctx.viewRefs.set(id, ref);
|
|
523
540
|
return {
|
|
524
541
|
containerId: id,
|
|
@@ -530,79 +547,183 @@ var Container = typedMemo(function Container2({
|
|
|
530
547
|
value: data
|
|
531
548
|
};
|
|
532
549
|
}, [id, itemKey, index, data]);
|
|
533
|
-
const
|
|
534
|
-
var _a, _b;
|
|
550
|
+
const onLayoutChange = (rectangle) => {
|
|
535
551
|
if (!isNullOrUndefined(itemKey)) {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
const size = layout[horizontal ? "width" : "height"];
|
|
552
|
+
let layout = rectangle;
|
|
553
|
+
layout[horizontal ? "width" : "height"];
|
|
539
554
|
const doUpdate = () => {
|
|
540
555
|
refLastSize.current = { height: layout.height, width: layout.width };
|
|
541
556
|
updateItemSize2(itemKey, layout);
|
|
542
557
|
};
|
|
543
|
-
|
|
558
|
+
{
|
|
544
559
|
doUpdate();
|
|
545
|
-
} else {
|
|
546
|
-
(_b = (_a = ref.current) == null ? void 0 : _a.measure) == null ? void 0 : _b.call(_a, (_x, _y, width, height) => {
|
|
547
|
-
layout = { height, width };
|
|
548
|
-
doUpdate();
|
|
549
|
-
});
|
|
550
560
|
}
|
|
551
561
|
}
|
|
552
562
|
};
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
var _a, _b;
|
|
556
|
-
if (!isNullOrUndefined(itemKey)) {
|
|
557
|
-
const measured = (_b = (_a = ref.current) == null ? void 0 : _a.unstable_getBoundingClientRect) == null ? void 0 : _b.call(_a);
|
|
558
|
-
if (measured) {
|
|
559
|
-
const size = Math.floor(measured[horizontal ? "width" : "height"] * 8) / 8;
|
|
560
|
-
if (size) {
|
|
561
|
-
updateItemSize2(itemKey, measured);
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
}, [itemKey, layoutRenderCount]);
|
|
566
|
-
} else {
|
|
567
|
-
React3.useEffect(() => {
|
|
568
|
-
if (!isNullOrUndefined(itemKey)) {
|
|
569
|
-
const timeout = setTimeout(() => {
|
|
570
|
-
if (!didLayout && refLastSize.current) {
|
|
571
|
-
updateItemSize2(itemKey, refLastSize.current);
|
|
572
|
-
}
|
|
573
|
-
}, 16);
|
|
574
|
-
return () => {
|
|
575
|
-
clearTimeout(timeout);
|
|
576
|
-
};
|
|
577
|
-
}
|
|
578
|
-
}, [itemKey]);
|
|
579
|
-
}
|
|
580
|
-
const PositionComponent = isSticky ? PositionViewSticky : PositionView3;
|
|
581
|
-
return /* @__PURE__ */ React3__namespace.createElement(
|
|
563
|
+
const PositionComponent = isSticky ? PositionViewSticky : PositionView2;
|
|
564
|
+
return /* @__PURE__ */ React4__namespace.createElement(ContextContainer.Provider, { value: contextValue }, /* @__PURE__ */ React4__namespace.createElement(
|
|
582
565
|
PositionComponent,
|
|
583
566
|
{
|
|
584
|
-
animatedScrollY: isSticky ? animatedScrollY : void 0,
|
|
585
567
|
horizontal,
|
|
586
568
|
id,
|
|
587
569
|
index,
|
|
588
570
|
key: recycleItems ? void 0 : itemKey,
|
|
589
|
-
|
|
571
|
+
onLayoutChange,
|
|
590
572
|
refView: ref,
|
|
591
|
-
stickyOffset: isSticky ? stickyOffset : void 0,
|
|
592
573
|
style
|
|
593
574
|
},
|
|
594
|
-
|
|
575
|
+
renderedItem,
|
|
576
|
+
renderedItemInfo && ItemSeparatorComponent && /* @__PURE__ */ React4__namespace.createElement(
|
|
595
577
|
Separator,
|
|
596
578
|
{
|
|
597
579
|
ItemSeparatorComponent,
|
|
598
580
|
itemKey,
|
|
599
581
|
leadingItem: renderedItemInfo.item
|
|
600
582
|
}
|
|
601
|
-
)
|
|
602
|
-
);
|
|
583
|
+
)
|
|
584
|
+
));
|
|
603
585
|
});
|
|
604
586
|
|
|
587
|
+
// src/utils/reordering.ts
|
|
588
|
+
var mapFn = (element) => {
|
|
589
|
+
const indexStr = element.getAttribute("index");
|
|
590
|
+
return [element, indexStr === null ? null : parseInt(indexStr)];
|
|
591
|
+
};
|
|
592
|
+
function sortDOMElementsPatience(container) {
|
|
593
|
+
const elements = Array.from(container.children);
|
|
594
|
+
if (elements.length <= 1) return elements;
|
|
595
|
+
const items = elements.map(mapFn);
|
|
596
|
+
items.sort((a, b) => {
|
|
597
|
+
const aKey = a[1];
|
|
598
|
+
const bKey = b[1];
|
|
599
|
+
if (aKey === null) {
|
|
600
|
+
return 1;
|
|
601
|
+
}
|
|
602
|
+
if (bKey === null) {
|
|
603
|
+
return -1;
|
|
604
|
+
}
|
|
605
|
+
return aKey - bKey;
|
|
606
|
+
});
|
|
607
|
+
const targetPositions = /* @__PURE__ */ new Map();
|
|
608
|
+
items.forEach((item, index) => {
|
|
609
|
+
targetPositions.set(item[0], index);
|
|
610
|
+
});
|
|
611
|
+
const currentPositions = elements.map((el) => targetPositions.get(el));
|
|
612
|
+
const lis = findLIS(currentPositions);
|
|
613
|
+
const stableIndices = new Set(lis);
|
|
614
|
+
for (let targetPos = 0; targetPos < items.length; targetPos++) {
|
|
615
|
+
const element = items[targetPos][0];
|
|
616
|
+
const currentPos = elements.indexOf(element);
|
|
617
|
+
if (!stableIndices.has(currentPos)) {
|
|
618
|
+
let nextStableElement = null;
|
|
619
|
+
for (let i = targetPos + 1; i < items.length; i++) {
|
|
620
|
+
const nextEl = items[i][0];
|
|
621
|
+
const nextCurrentPos = elements.indexOf(nextEl);
|
|
622
|
+
if (stableIndices.has(nextCurrentPos)) {
|
|
623
|
+
nextStableElement = nextEl;
|
|
624
|
+
break;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
if (nextStableElement) {
|
|
628
|
+
container.insertBefore(element, nextStableElement);
|
|
629
|
+
} else {
|
|
630
|
+
container.appendChild(element);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
function findLIS(arr) {
|
|
636
|
+
const n = arr.length;
|
|
637
|
+
const tails = [];
|
|
638
|
+
const predecessors = new Array(n).fill(-1);
|
|
639
|
+
const indices = [];
|
|
640
|
+
for (let i = 0; i < n; i++) {
|
|
641
|
+
const num = arr[i];
|
|
642
|
+
let left = 0, right = tails.length;
|
|
643
|
+
while (left < right) {
|
|
644
|
+
const mid = Math.floor((left + right) / 2);
|
|
645
|
+
if (arr[indices[mid]] < num) {
|
|
646
|
+
left = mid + 1;
|
|
647
|
+
} else {
|
|
648
|
+
right = mid;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
if (left === tails.length) {
|
|
652
|
+
tails.push(num);
|
|
653
|
+
indices.push(i);
|
|
654
|
+
} else {
|
|
655
|
+
tails[left] = num;
|
|
656
|
+
indices[left] = i;
|
|
657
|
+
}
|
|
658
|
+
if (left > 0) {
|
|
659
|
+
predecessors[i] = indices[left - 1];
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
const result = [];
|
|
663
|
+
let k = indices[indices.length - 1];
|
|
664
|
+
while (k !== -1) {
|
|
665
|
+
result.unshift(k);
|
|
666
|
+
k = predecessors[k];
|
|
667
|
+
}
|
|
668
|
+
return result;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
// src/hooks/useDOMOrder.ts
|
|
672
|
+
function useDOMOrder(ref) {
|
|
673
|
+
const ctx = useStateContext();
|
|
674
|
+
const debounceRef = React4.useRef(void 0);
|
|
675
|
+
React4.useEffect(() => {
|
|
676
|
+
const unsubscribe = listen$(ctx, "lastPositionUpdate", () => {
|
|
677
|
+
if (debounceRef.current !== void 0) {
|
|
678
|
+
clearTimeout(debounceRef.current);
|
|
679
|
+
}
|
|
680
|
+
debounceRef.current = setTimeout(() => {
|
|
681
|
+
const parent = ref.current;
|
|
682
|
+
if (parent) {
|
|
683
|
+
sortDOMElementsPatience(parent);
|
|
684
|
+
}
|
|
685
|
+
debounceRef.current = void 0;
|
|
686
|
+
}, 500);
|
|
687
|
+
});
|
|
688
|
+
return () => {
|
|
689
|
+
unsubscribe();
|
|
690
|
+
if (debounceRef.current !== void 0) {
|
|
691
|
+
clearTimeout(debounceRef.current);
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
}, [ctx]);
|
|
695
|
+
}
|
|
696
|
+
|
|
605
697
|
// src/components/Containers.tsx
|
|
698
|
+
var ContainersInner = typedMemo(function ContainersInner2({ horizontal, numColumns, children }) {
|
|
699
|
+
const ref = React4.useRef(null);
|
|
700
|
+
const ctx = useStateContext();
|
|
701
|
+
const columnWrapperStyle = ctx.columnWrapperStyle;
|
|
702
|
+
const [totalSize, otherAxisSize] = useArr$(["totalSize", "otherAxisSize"]);
|
|
703
|
+
useDOMOrder(ref);
|
|
704
|
+
const style = horizontal ? { minHeight: otherAxisSize, width: totalSize } : { height: totalSize, minWidth: otherAxisSize };
|
|
705
|
+
if (columnWrapperStyle && numColumns > 1) {
|
|
706
|
+
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
707
|
+
const gapX = columnGap || gap || 0;
|
|
708
|
+
const gapY = rowGap || gap || 0;
|
|
709
|
+
if (horizontal) {
|
|
710
|
+
if (gapY) {
|
|
711
|
+
style.marginTop = style.marginBottom = -gapY / 2;
|
|
712
|
+
}
|
|
713
|
+
if (gapX) {
|
|
714
|
+
style.marginRight = -gapX;
|
|
715
|
+
}
|
|
716
|
+
} else {
|
|
717
|
+
if (gapX) {
|
|
718
|
+
style.marginLeft = style.marginRight = -gapX;
|
|
719
|
+
}
|
|
720
|
+
if (gapY) {
|
|
721
|
+
style.marginBottom = -gapY;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
return /* @__PURE__ */ React4__namespace.createElement("div", { ref, style }, children);
|
|
726
|
+
});
|
|
606
727
|
var Containers = typedMemo(function Containers2({
|
|
607
728
|
horizontal,
|
|
608
729
|
recycleItems,
|
|
@@ -611,19 +732,11 @@ var Containers = typedMemo(function Containers2({
|
|
|
611
732
|
updateItemSize: updateItemSize2,
|
|
612
733
|
getRenderedItem: getRenderedItem2
|
|
613
734
|
}) {
|
|
614
|
-
const ctx = useStateContext();
|
|
615
|
-
const columnWrapperStyle = ctx.columnWrapperStyle;
|
|
616
735
|
const [numContainers, numColumns] = useArr$(["numContainersPooled", "numColumns"]);
|
|
617
|
-
const animSize = useValue$("totalSize", {
|
|
618
|
-
// Use a microtask if increasing the size significantly, otherwise use a timeout
|
|
619
|
-
delay: (value, prevValue) => !prevValue || value - prevValue > 20 ? 0 : 200
|
|
620
|
-
});
|
|
621
|
-
const animOpacity = waitForInitialLayout && !IsNewArchitecture ? useValue$("containersDidLayout", { getValue: (value) => value ? 1 : 0 }) : void 0;
|
|
622
|
-
const otherAxisSize = useValue$("otherAxisSize", { delay: 0 });
|
|
623
736
|
const containers = [];
|
|
624
737
|
for (let i = 0; i < numContainers; i++) {
|
|
625
738
|
containers.push(
|
|
626
|
-
/* @__PURE__ */
|
|
739
|
+
/* @__PURE__ */ React4__namespace.createElement(
|
|
627
740
|
Container,
|
|
628
741
|
{
|
|
629
742
|
getRenderedItem: getRenderedItem2,
|
|
@@ -637,45 +750,209 @@ var Containers = typedMemo(function Containers2({
|
|
|
637
750
|
)
|
|
638
751
|
);
|
|
639
752
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
753
|
+
return /* @__PURE__ */ React4__namespace.createElement(ContainersInner, { horizontal, numColumns, waitForInitialLayout }, containers);
|
|
754
|
+
});
|
|
755
|
+
var DevNumbers = __DEV__ && React4__namespace.memo(function DevNumbers2() {
|
|
756
|
+
return Array.from({ length: 100 }).map((_, index) => /* @__PURE__ */ React4__namespace.createElement(
|
|
757
|
+
View,
|
|
758
|
+
{
|
|
759
|
+
key: index,
|
|
760
|
+
style: {
|
|
761
|
+
height: 100,
|
|
762
|
+
pointerEvents: "none",
|
|
763
|
+
position: "absolute",
|
|
764
|
+
top: index * 100,
|
|
765
|
+
width: "100%"
|
|
648
766
|
}
|
|
649
|
-
|
|
650
|
-
|
|
767
|
+
},
|
|
768
|
+
/* @__PURE__ */ React4__namespace.createElement(Text, { style: { color: "red" } }, index * 100)
|
|
769
|
+
));
|
|
770
|
+
});
|
|
771
|
+
var ListComponentScrollView = React4.forwardRef(function ListComponentScrollView2({
|
|
772
|
+
children,
|
|
773
|
+
style,
|
|
774
|
+
contentContainerStyle,
|
|
775
|
+
horizontal = false,
|
|
776
|
+
contentOffset,
|
|
777
|
+
maintainVisibleContentPosition,
|
|
778
|
+
onScroll: onScroll2,
|
|
779
|
+
onMomentumScrollEnd,
|
|
780
|
+
showsHorizontalScrollIndicator = true,
|
|
781
|
+
showsVerticalScrollIndicator = true,
|
|
782
|
+
refreshControl,
|
|
783
|
+
onLayout,
|
|
784
|
+
ScrollComponent,
|
|
785
|
+
...props
|
|
786
|
+
}, ref) {
|
|
787
|
+
const scrollRef = React4.useRef(null);
|
|
788
|
+
const contentRef = React4.useRef(null);
|
|
789
|
+
const momentumTimeout = React4.useRef(null);
|
|
790
|
+
React4.useImperativeHandle(ref, () => {
|
|
791
|
+
const api = {
|
|
792
|
+
getBoundingClientRect: () => {
|
|
793
|
+
var _a;
|
|
794
|
+
return (_a = scrollRef.current) == null ? void 0 : _a.getBoundingClientRect();
|
|
795
|
+
},
|
|
796
|
+
getScrollableNode: () => scrollRef.current,
|
|
797
|
+
getScrollResponder: () => scrollRef.current,
|
|
798
|
+
scrollBy: (options) => {
|
|
799
|
+
const el = scrollRef.current;
|
|
800
|
+
if (!el) return;
|
|
801
|
+
const { x = 0, y = 0, animated = true } = options;
|
|
802
|
+
el.scrollBy({ behavior: animated ? "smooth" : "auto", left: x, top: y });
|
|
803
|
+
},
|
|
804
|
+
scrollTo: (options) => {
|
|
805
|
+
const el = scrollRef.current;
|
|
806
|
+
if (!el) return;
|
|
807
|
+
const { x = 0, y = 0, animated = true } = options;
|
|
808
|
+
el.scrollTo({ behavior: animated ? "smooth" : "auto", left: x, top: y });
|
|
809
|
+
},
|
|
810
|
+
scrollToEnd: (options = {}) => {
|
|
811
|
+
const el = scrollRef.current;
|
|
812
|
+
if (!el) return;
|
|
813
|
+
const { animated = true } = options;
|
|
814
|
+
if (horizontal) {
|
|
815
|
+
el.scrollTo({ behavior: animated ? "smooth" : "auto", left: el.scrollWidth });
|
|
816
|
+
} else {
|
|
817
|
+
el.scrollTo({ behavior: animated ? "smooth" : "auto", top: el.scrollHeight });
|
|
818
|
+
}
|
|
819
|
+
},
|
|
820
|
+
scrollToOffset: (params) => {
|
|
821
|
+
const el = scrollRef.current;
|
|
822
|
+
if (!el) return;
|
|
823
|
+
const { offset, animated = true } = params;
|
|
824
|
+
if (horizontal) {
|
|
825
|
+
el.scrollTo({ behavior: animated ? "smooth" : "auto", left: offset });
|
|
826
|
+
} else {
|
|
827
|
+
el.scrollTo({ behavior: animated ? "smooth" : "auto", top: offset });
|
|
828
|
+
}
|
|
651
829
|
}
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
|
|
830
|
+
};
|
|
831
|
+
return api;
|
|
832
|
+
}, [horizontal]);
|
|
833
|
+
const handleScroll = React4.useCallback(
|
|
834
|
+
(event) => {
|
|
835
|
+
if (!onScroll2 || !(event == null ? void 0 : event.target)) {
|
|
836
|
+
return;
|
|
655
837
|
}
|
|
656
|
-
|
|
657
|
-
|
|
838
|
+
const target = event.target;
|
|
839
|
+
const scrollEvent = {
|
|
840
|
+
nativeEvent: {
|
|
841
|
+
contentOffset: {
|
|
842
|
+
x: target.scrollLeft,
|
|
843
|
+
y: target.scrollTop
|
|
844
|
+
},
|
|
845
|
+
contentSize: {
|
|
846
|
+
height: target.scrollHeight,
|
|
847
|
+
width: target.scrollWidth
|
|
848
|
+
},
|
|
849
|
+
layoutMeasurement: {
|
|
850
|
+
height: target.clientHeight,
|
|
851
|
+
width: target.clientWidth
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
};
|
|
855
|
+
onScroll2(scrollEvent);
|
|
856
|
+
if (onMomentumScrollEnd) {
|
|
857
|
+
if (momentumTimeout.current != null) clearTimeout(momentumTimeout.current);
|
|
858
|
+
momentumTimeout.current = setTimeout(() => {
|
|
859
|
+
onMomentumScrollEnd({
|
|
860
|
+
nativeEvent: {
|
|
861
|
+
contentOffset: scrollEvent.nativeEvent.contentOffset
|
|
862
|
+
}
|
|
863
|
+
});
|
|
864
|
+
}, 100);
|
|
658
865
|
}
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
|
|
866
|
+
},
|
|
867
|
+
[onScroll2, onMomentumScrollEnd]
|
|
868
|
+
);
|
|
869
|
+
React4.useLayoutEffect(() => {
|
|
870
|
+
const element = scrollRef.current;
|
|
871
|
+
if (!element) return;
|
|
872
|
+
element.addEventListener("scroll", handleScroll, { passive: true });
|
|
873
|
+
return () => {
|
|
874
|
+
element.removeEventListener("scroll", handleScroll);
|
|
875
|
+
};
|
|
876
|
+
}, [handleScroll]);
|
|
877
|
+
React4.useLayoutEffect(() => {
|
|
878
|
+
if (contentOffset && scrollRef.current) {
|
|
879
|
+
scrollRef.current.scrollLeft = contentOffset.x || 0;
|
|
880
|
+
scrollRef.current.scrollTop = contentOffset.y || 0;
|
|
881
|
+
}
|
|
882
|
+
}, [contentOffset]);
|
|
883
|
+
React4.useLayoutEffect(() => {
|
|
884
|
+
if (!onLayout || !scrollRef.current) return;
|
|
885
|
+
const element = scrollRef.current;
|
|
886
|
+
const fireLayout = () => {
|
|
887
|
+
const rect = element.getBoundingClientRect();
|
|
888
|
+
onLayout({
|
|
889
|
+
nativeEvent: {
|
|
890
|
+
layout: {
|
|
891
|
+
height: rect.height,
|
|
892
|
+
width: rect.width,
|
|
893
|
+
x: rect.left,
|
|
894
|
+
y: rect.top
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
});
|
|
898
|
+
};
|
|
899
|
+
fireLayout();
|
|
900
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
901
|
+
fireLayout();
|
|
902
|
+
});
|
|
903
|
+
resizeObserver.observe(element);
|
|
904
|
+
return () => resizeObserver.disconnect();
|
|
905
|
+
}, [onLayout]);
|
|
906
|
+
const scrollViewStyle = {
|
|
907
|
+
overflow: "auto",
|
|
908
|
+
overflowX: horizontal ? "auto" : showsHorizontalScrollIndicator ? "auto" : "hidden",
|
|
909
|
+
overflowY: horizontal ? showsVerticalScrollIndicator ? "auto" : "hidden" : "auto",
|
|
910
|
+
position: "relative",
|
|
911
|
+
// Ensure proper positioning context
|
|
912
|
+
WebkitOverflowScrolling: "touch",
|
|
913
|
+
// iOS momentum scrolling
|
|
914
|
+
...style
|
|
915
|
+
};
|
|
916
|
+
const contentStyle = {
|
|
917
|
+
display: horizontal ? "flex" : "block",
|
|
918
|
+
flexDirection: horizontal ? "row" : void 0,
|
|
919
|
+
minHeight: horizontal ? void 0 : "100%",
|
|
920
|
+
minWidth: horizontal ? "100%" : void 0,
|
|
921
|
+
...contentContainerStyle
|
|
922
|
+
};
|
|
923
|
+
return /* @__PURE__ */ React4__namespace.createElement("div", { ref: scrollRef, style: scrollViewStyle, ...props }, refreshControl, /* @__PURE__ */ React4__namespace.createElement("div", { ref: contentRef, style: contentStyle }, children));
|
|
662
924
|
});
|
|
925
|
+
function useValueListener$(key, callback) {
|
|
926
|
+
const ctx = useStateContext();
|
|
927
|
+
React4.useLayoutEffect(() => {
|
|
928
|
+
listen$(ctx, key, (value) => {
|
|
929
|
+
callback(value);
|
|
930
|
+
});
|
|
931
|
+
}, []);
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
// src/components/ScrollAdjust.tsx
|
|
663
935
|
function ScrollAdjust() {
|
|
664
|
-
const
|
|
665
|
-
const
|
|
666
|
-
const
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
936
|
+
const ctx = useStateContext();
|
|
937
|
+
const lastScrollOffsetRef = React4__namespace.useRef(0);
|
|
938
|
+
const callback = React4__namespace.useCallback(() => {
|
|
939
|
+
var _a;
|
|
940
|
+
const scrollAdjust = peek$(ctx, "scrollAdjust");
|
|
941
|
+
const scrollAdjustUserOffset = peek$(ctx, "scrollAdjustUserOffset");
|
|
942
|
+
const scrollOffset = (scrollAdjust || 0) + (scrollAdjustUserOffset || 0);
|
|
943
|
+
const scrollView = (_a = ctx.internalState) == null ? void 0 : _a.refScroller.current;
|
|
944
|
+
if (scrollView && scrollOffset !== lastScrollOffsetRef.current) {
|
|
945
|
+
const scrollDelta = scrollOffset - lastScrollOffsetRef.current;
|
|
946
|
+
if (scrollDelta !== 0) {
|
|
947
|
+
scrollView.scrollBy(0, scrollDelta);
|
|
948
|
+
console.log("ScrollAdjust (web scrollBy)", scrollDelta, "total offset:", scrollOffset);
|
|
949
|
+
}
|
|
950
|
+
lastScrollOffsetRef.current = scrollOffset;
|
|
677
951
|
}
|
|
678
|
-
);
|
|
952
|
+
}, []);
|
|
953
|
+
useValueListener$("scrollAdjust", callback);
|
|
954
|
+
useValueListener$("scrollAdjustUserOffset", callback);
|
|
955
|
+
return null;
|
|
679
956
|
}
|
|
680
957
|
|
|
681
958
|
// src/components/SnapWrapper.tsx
|
|
@@ -683,87 +960,31 @@ function SnapWrapper({ ScrollComponent, ...props }) {
|
|
|
683
960
|
const [snapToOffsets] = useArr$(["snapToOffsets"]);
|
|
684
961
|
return /* @__PURE__ */ React.createElement(ScrollComponent, { ...props, snapToOffsets });
|
|
685
962
|
}
|
|
686
|
-
function useThrottleDebounce(mode) {
|
|
687
|
-
const timeoutRef = React3.useRef(null);
|
|
688
|
-
const lastCallTimeRef = React3.useRef(0);
|
|
689
|
-
const lastArgsRef = React3.useRef(null);
|
|
690
|
-
const clearTimeoutRef = () => {
|
|
691
|
-
if (timeoutRef.current) {
|
|
692
|
-
clearTimeout(timeoutRef.current);
|
|
693
|
-
timeoutRef.current = null;
|
|
694
|
-
}
|
|
695
|
-
};
|
|
696
|
-
const execute = React3.useCallback(
|
|
697
|
-
(callback, delay, ...args) => {
|
|
698
|
-
{
|
|
699
|
-
const now = Date.now();
|
|
700
|
-
lastArgsRef.current = args;
|
|
701
|
-
if (now - lastCallTimeRef.current >= delay) {
|
|
702
|
-
lastCallTimeRef.current = now;
|
|
703
|
-
callback(...args);
|
|
704
|
-
clearTimeoutRef();
|
|
705
|
-
} else {
|
|
706
|
-
clearTimeoutRef();
|
|
707
|
-
timeoutRef.current = setTimeout(
|
|
708
|
-
() => {
|
|
709
|
-
if (lastArgsRef.current) {
|
|
710
|
-
lastCallTimeRef.current = Date.now();
|
|
711
|
-
callback(...lastArgsRef.current);
|
|
712
|
-
timeoutRef.current = null;
|
|
713
|
-
lastArgsRef.current = null;
|
|
714
|
-
}
|
|
715
|
-
},
|
|
716
|
-
delay - (now - lastCallTimeRef.current)
|
|
717
|
-
);
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
},
|
|
721
|
-
[mode]
|
|
722
|
-
);
|
|
723
|
-
return execute;
|
|
724
|
-
}
|
|
725
963
|
|
|
726
|
-
// src/hooks/
|
|
727
|
-
function
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
const ref = React3.useRef(null);
|
|
731
|
-
const onLayout = React3.useCallback(
|
|
732
|
-
(event) => {
|
|
733
|
-
onChange(event.nativeEvent.layout, false);
|
|
734
|
-
},
|
|
735
|
-
[onChange]
|
|
736
|
-
);
|
|
737
|
-
if (IsNewArchitecture) {
|
|
738
|
-
React3.useLayoutEffect(() => {
|
|
739
|
-
if (ref.current) {
|
|
740
|
-
ref.current.measure((x, y, width, height) => {
|
|
741
|
-
onChange({ height, width, x, y }, true);
|
|
742
|
-
});
|
|
743
|
-
}
|
|
744
|
-
}, []);
|
|
745
|
-
}
|
|
746
|
-
return { onLayout, ref };
|
|
964
|
+
// src/hooks/useValue$.ts
|
|
965
|
+
function useValue$(key, params) {
|
|
966
|
+
const [value] = useArr$([key]);
|
|
967
|
+
return value;
|
|
747
968
|
}
|
|
748
969
|
|
|
749
970
|
// src/components/ListComponent.tsx
|
|
750
971
|
var getComponent = (Component) => {
|
|
751
|
-
if (
|
|
972
|
+
if (React4__namespace.isValidElement(Component)) {
|
|
752
973
|
return Component;
|
|
753
974
|
}
|
|
754
975
|
if (Component) {
|
|
755
|
-
return /* @__PURE__ */
|
|
976
|
+
return /* @__PURE__ */ React4__namespace.createElement(Component, null);
|
|
756
977
|
}
|
|
757
978
|
return null;
|
|
758
979
|
};
|
|
759
980
|
var Padding = () => {
|
|
760
|
-
const animPaddingTop = useValue$("alignItemsPaddingTop"
|
|
761
|
-
return /* @__PURE__ */
|
|
981
|
+
const animPaddingTop = useValue$("alignItemsPaddingTop");
|
|
982
|
+
return /* @__PURE__ */ React4__namespace.createElement(AnimatedView, { style: { paddingTop: animPaddingTop } });
|
|
762
983
|
};
|
|
763
984
|
var PaddingDevMode = () => {
|
|
764
|
-
const animPaddingTop = useValue$("alignItemsPaddingTop"
|
|
765
|
-
return /* @__PURE__ */
|
|
766
|
-
|
|
985
|
+
const animPaddingTop = useValue$("alignItemsPaddingTop");
|
|
986
|
+
return /* @__PURE__ */ React4__namespace.createElement(React4__namespace.Fragment, null, /* @__PURE__ */ React4__namespace.createElement(AnimatedView, { style: { paddingTop: animPaddingTop } }), /* @__PURE__ */ React4__namespace.createElement(
|
|
987
|
+
AnimatedView,
|
|
767
988
|
{
|
|
768
989
|
style: {
|
|
769
990
|
backgroundColor: "green",
|
|
@@ -805,14 +1026,12 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
805
1026
|
...rest
|
|
806
1027
|
}) {
|
|
807
1028
|
const ctx = useStateContext();
|
|
808
|
-
const
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
const ScrollComponent = renderScrollComponent ? React3.useMemo(
|
|
812
|
-
() => React3__namespace.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
|
|
1029
|
+
const refHeader = React4__namespace.useRef(null);
|
|
1030
|
+
const ScrollComponent = renderScrollComponent ? React4.useMemo(
|
|
1031
|
+
() => React4__namespace.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
|
|
813
1032
|
[renderScrollComponent]
|
|
814
|
-
) :
|
|
815
|
-
|
|
1033
|
+
) : ListComponentScrollView;
|
|
1034
|
+
React4__namespace.useEffect(() => {
|
|
816
1035
|
if (canRender) {
|
|
817
1036
|
setTimeout(() => {
|
|
818
1037
|
scrollAdjustHandler.setMounted();
|
|
@@ -820,16 +1039,17 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
820
1039
|
}
|
|
821
1040
|
}, [canRender]);
|
|
822
1041
|
const SnapOrScroll = snapToIndices ? SnapWrapper : ScrollComponent;
|
|
823
|
-
|
|
1042
|
+
const contentContainerStyleWeb = React4.useMemo(() => {
|
|
1043
|
+
const base = contentContainerStyle || void 0;
|
|
1044
|
+
if (!horizontal) return base;
|
|
1045
|
+
if (base && base.height === "100%") return base;
|
|
1046
|
+
return { ...base || {}, height: "100%" };
|
|
1047
|
+
}, [horizontal, (contentContainerStyle == null ? void 0 : contentContainerStyle.height) === "100%" ? 1 : 0]);
|
|
1048
|
+
return /* @__PURE__ */ React4__namespace.createElement(
|
|
824
1049
|
SnapOrScroll,
|
|
825
1050
|
{
|
|
826
1051
|
...rest,
|
|
827
|
-
contentContainerStyle:
|
|
828
|
-
contentContainerStyle,
|
|
829
|
-
horizontal ? {
|
|
830
|
-
height: "100%"
|
|
831
|
-
} : {}
|
|
832
|
-
],
|
|
1052
|
+
contentContainerStyle: contentContainerStyleWeb,
|
|
833
1053
|
contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
|
|
834
1054
|
horizontal,
|
|
835
1055
|
maintainVisibleContentPosition: maintainVisibleContentPosition && !ListEmptyComponent ? { minIndexForVisible: 0 } : void 0,
|
|
@@ -839,11 +1059,19 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
839
1059
|
ScrollComponent: snapToIndices ? ScrollComponent : void 0,
|
|
840
1060
|
style
|
|
841
1061
|
},
|
|
842
|
-
maintainVisibleContentPosition && /* @__PURE__ */
|
|
843
|
-
ENABLE_DEVMODE ? /* @__PURE__ */
|
|
844
|
-
ListHeaderComponent && /* @__PURE__ */
|
|
1062
|
+
maintainVisibleContentPosition && /* @__PURE__ */ React4__namespace.createElement(ScrollAdjust, null),
|
|
1063
|
+
ENABLE_DEVMODE ? /* @__PURE__ */ React4__namespace.createElement(PaddingDevMode, null) : /* @__PURE__ */ React4__namespace.createElement(Padding, null),
|
|
1064
|
+
ListHeaderComponent && /* @__PURE__ */ React4__namespace.createElement(
|
|
1065
|
+
LayoutView,
|
|
1066
|
+
{
|
|
1067
|
+
onLayoutChange: onLayoutHeader,
|
|
1068
|
+
refView: refHeader,
|
|
1069
|
+
style: ListHeaderComponentStyle
|
|
1070
|
+
},
|
|
1071
|
+
getComponent(ListHeaderComponent)
|
|
1072
|
+
),
|
|
845
1073
|
ListEmptyComponent && getComponent(ListEmptyComponent),
|
|
846
|
-
canRender && /* @__PURE__ */
|
|
1074
|
+
canRender && /* @__PURE__ */ React4__namespace.createElement(
|
|
847
1075
|
Containers,
|
|
848
1076
|
{
|
|
849
1077
|
getRenderedItem: getRenderedItem2,
|
|
@@ -854,36 +1082,20 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
854
1082
|
waitForInitialLayout
|
|
855
1083
|
}
|
|
856
1084
|
),
|
|
857
|
-
ListFooterComponent && /* @__PURE__ */
|
|
858
|
-
|
|
1085
|
+
ListFooterComponent && /* @__PURE__ */ React4__namespace.createElement(
|
|
1086
|
+
LayoutView,
|
|
859
1087
|
{
|
|
860
|
-
|
|
861
|
-
const size =
|
|
1088
|
+
onLayoutChange: (layout) => {
|
|
1089
|
+
const size = layout[horizontal ? "width" : "height"];
|
|
862
1090
|
set$(ctx, "footerSize", size);
|
|
863
1091
|
},
|
|
864
1092
|
style: ListFooterComponentStyle
|
|
865
1093
|
},
|
|
866
1094
|
getComponent(ListFooterComponent)
|
|
867
1095
|
),
|
|
868
|
-
__DEV__ && ENABLE_DEVMODE && /* @__PURE__ */
|
|
1096
|
+
__DEV__ && ENABLE_DEVMODE && /* @__PURE__ */ React4__namespace.createElement(DevNumbers, null)
|
|
869
1097
|
);
|
|
870
1098
|
});
|
|
871
|
-
var DevNumbers = __DEV__ && React3__namespace.memo(function DevNumbers2() {
|
|
872
|
-
return Array.from({ length: 100 }).map((_, index) => /* @__PURE__ */ React3__namespace.createElement(
|
|
873
|
-
reactNative.View,
|
|
874
|
-
{
|
|
875
|
-
key: index,
|
|
876
|
-
style: {
|
|
877
|
-
height: 100,
|
|
878
|
-
pointerEvents: "none",
|
|
879
|
-
position: "absolute",
|
|
880
|
-
top: index * 100,
|
|
881
|
-
width: "100%"
|
|
882
|
-
}
|
|
883
|
-
},
|
|
884
|
-
/* @__PURE__ */ React3__namespace.createElement(reactNative.Text, { style: { color: "red" } }, index * 100)
|
|
885
|
-
));
|
|
886
|
-
});
|
|
887
1099
|
|
|
888
1100
|
// src/utils/getId.ts
|
|
889
1101
|
function getId(state, index) {
|
|
@@ -1004,14 +1216,8 @@ function scrollTo(state, params = {}) {
|
|
|
1004
1216
|
// src/utils/requestAdjust.ts
|
|
1005
1217
|
function requestAdjust(ctx, state, positionDiff, dataChanged) {
|
|
1006
1218
|
if (Math.abs(positionDiff) > 0.1) {
|
|
1007
|
-
const needsScrollWorkaround = reactNative.Platform.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff;
|
|
1008
1219
|
const doit = () => {
|
|
1009
|
-
|
|
1010
|
-
scrollTo(state, {
|
|
1011
|
-
noScrollingTo: true,
|
|
1012
|
-
offset: state.scroll
|
|
1013
|
-
});
|
|
1014
|
-
} else {
|
|
1220
|
+
{
|
|
1015
1221
|
state.scrollAdjustHandler.requestAdjust(positionDiff);
|
|
1016
1222
|
}
|
|
1017
1223
|
};
|
|
@@ -1036,7 +1242,7 @@ function requestAdjust(ctx, state, positionDiff, dataChanged) {
|
|
|
1036
1242
|
() => {
|
|
1037
1243
|
state.ignoreScrollFromMVCP = void 0;
|
|
1038
1244
|
},
|
|
1039
|
-
|
|
1245
|
+
100
|
|
1040
1246
|
);
|
|
1041
1247
|
} else {
|
|
1042
1248
|
requestAnimationFrame(doit);
|
|
@@ -1096,7 +1302,7 @@ function prepareMVCP(ctx, state, dataChanged) {
|
|
|
1096
1302
|
}
|
|
1097
1303
|
}
|
|
1098
1304
|
if (positionDiff !== void 0 && Math.abs(positionDiff) > 0.1) {
|
|
1099
|
-
requestAdjust(ctx, state, positionDiff
|
|
1305
|
+
requestAdjust(ctx, state, positionDiff);
|
|
1100
1306
|
}
|
|
1101
1307
|
};
|
|
1102
1308
|
}
|
|
@@ -1272,21 +1478,6 @@ function ensureViewabilityState(ctx, configId) {
|
|
|
1272
1478
|
}
|
|
1273
1479
|
return state;
|
|
1274
1480
|
}
|
|
1275
|
-
function setupViewability(props) {
|
|
1276
|
-
let { viewabilityConfig, viewabilityConfigCallbackPairs, onViewableItemsChanged } = props;
|
|
1277
|
-
if (viewabilityConfig || onViewableItemsChanged) {
|
|
1278
|
-
viewabilityConfigCallbackPairs = [
|
|
1279
|
-
...viewabilityConfigCallbackPairs || [],
|
|
1280
|
-
{
|
|
1281
|
-
onViewableItemsChanged,
|
|
1282
|
-
viewabilityConfig: viewabilityConfig || {
|
|
1283
|
-
viewAreaCoveragePercentThreshold: 0
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
];
|
|
1287
|
-
}
|
|
1288
|
-
return viewabilityConfigCallbackPairs;
|
|
1289
|
-
}
|
|
1290
1481
|
function updateViewableItems(state, ctx, viewabilityConfigCallbackPairs, scrollSize, start, end) {
|
|
1291
1482
|
const {
|
|
1292
1483
|
timeouts,
|
|
@@ -1456,12 +1647,11 @@ function maybeUpdateViewabilityCallback(ctx, configId, containerId, viewToken) {
|
|
|
1456
1647
|
const cb = ctx.mapViewabilityCallbacks.get(key);
|
|
1457
1648
|
cb == null ? void 0 : cb(viewToken);
|
|
1458
1649
|
}
|
|
1459
|
-
var batchedUpdates = reactNative.unstable_batchedUpdates || ((callback) => callback());
|
|
1460
1650
|
|
|
1461
1651
|
// src/utils/checkAllSizesKnown.ts
|
|
1462
1652
|
function checkAllSizesKnown(state) {
|
|
1463
1653
|
const { startBuffered, endBuffered, sizesKnown } = state;
|
|
1464
|
-
if (endBuffered !== null) {
|
|
1654
|
+
if (endBuffered !== null && startBuffered >= 0 && endBuffered >= 0) {
|
|
1465
1655
|
let areAllKnown = true;
|
|
1466
1656
|
for (let i = startBuffered; areAllKnown && i <= endBuffered; i++) {
|
|
1467
1657
|
const key = getId(state, i);
|
|
@@ -1719,19 +1909,7 @@ function setDidLayout(ctx, state) {
|
|
|
1719
1909
|
onLoad({ elapsedTimeInMs: Date.now() - loadStartTime });
|
|
1720
1910
|
}
|
|
1721
1911
|
};
|
|
1722
|
-
|
|
1723
|
-
if (initialScroll) {
|
|
1724
|
-
queueMicrotask(() => {
|
|
1725
|
-
scrollToIndex(ctx, state, { ...initialScroll, animated: false });
|
|
1726
|
-
requestAnimationFrame(() => {
|
|
1727
|
-
scrollToIndex(ctx, state, { ...initialScroll, animated: false });
|
|
1728
|
-
setIt();
|
|
1729
|
-
});
|
|
1730
|
-
});
|
|
1731
|
-
} else {
|
|
1732
|
-
queueMicrotask(setIt);
|
|
1733
|
-
}
|
|
1734
|
-
} else {
|
|
1912
|
+
{
|
|
1735
1913
|
setIt();
|
|
1736
1914
|
}
|
|
1737
1915
|
}
|
|
@@ -1800,7 +1978,7 @@ function handleStickyRecycling(ctx, state, stickyArray, scroll, scrollBuffer, pe
|
|
|
1800
1978
|
}
|
|
1801
1979
|
}
|
|
1802
1980
|
function calculateItemsInView(ctx, state, params = {}) {
|
|
1803
|
-
|
|
1981
|
+
reactDom.unstable_batchedUpdates(() => {
|
|
1804
1982
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1805
1983
|
const {
|
|
1806
1984
|
columns,
|
|
@@ -2028,10 +2206,9 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
2028
2206
|
if (stickyIndicesSet.has(i)) {
|
|
2029
2207
|
set$(ctx, `containerSticky${containerIndex}`, true);
|
|
2030
2208
|
const topPadding = (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "headerSize") || 0);
|
|
2031
|
-
set$(ctx, `containerStickyOffset${containerIndex}`,
|
|
2209
|
+
set$(ctx, `containerStickyOffset${containerIndex}`, createAnimatedValue(topPadding));
|
|
2032
2210
|
state.stickyContainerPool.add(containerIndex);
|
|
2033
2211
|
} else {
|
|
2034
|
-
set$(ctx, `containerSticky${containerIndex}`, false);
|
|
2035
2212
|
state.stickyContainerPool.delete(containerIndex);
|
|
2036
2213
|
}
|
|
2037
2214
|
if (containerIndex >= numContainers2) {
|
|
@@ -2049,6 +2226,7 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
2049
2226
|
if (stickyIndicesArr.length > 0) {
|
|
2050
2227
|
handleStickyRecycling(ctx, state, stickyIndicesArr, scroll, scrollBuffer, pendingRemoval);
|
|
2051
2228
|
}
|
|
2229
|
+
let didChangePositions = false;
|
|
2052
2230
|
for (let i = 0; i < numContainers; i++) {
|
|
2053
2231
|
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
2054
2232
|
if (pendingRemoval.includes(i)) {
|
|
@@ -2080,6 +2258,7 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
2080
2258
|
const prevData = peek$(ctx, `containerItemData${i}`);
|
|
2081
2259
|
if (position > POSITION_OUT_OF_VIEW && position !== prevPos) {
|
|
2082
2260
|
set$(ctx, `containerPosition${i}`, position);
|
|
2261
|
+
didChangePositions = true;
|
|
2083
2262
|
}
|
|
2084
2263
|
if (column >= 0 && column !== prevColumn) {
|
|
2085
2264
|
set$(ctx, `containerColumn${i}`, column);
|
|
@@ -2091,6 +2270,9 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
2091
2270
|
}
|
|
2092
2271
|
}
|
|
2093
2272
|
}
|
|
2273
|
+
if (didChangePositions) {
|
|
2274
|
+
set$(ctx, "lastPositionUpdate", Date.now());
|
|
2275
|
+
}
|
|
2094
2276
|
if (!queuedInitialLayout && endBuffered !== null) {
|
|
2095
2277
|
if (checkAllSizesKnown(state)) {
|
|
2096
2278
|
setDidLayout(ctx, state);
|
|
@@ -2138,7 +2320,7 @@ function doInitialAllocateContainers(ctx, state) {
|
|
|
2138
2320
|
}
|
|
2139
2321
|
set$(ctx, "numContainers", numContainers);
|
|
2140
2322
|
set$(ctx, "numContainersPooled", numContainers * state.props.initialContainerPoolRatio);
|
|
2141
|
-
if (
|
|
2323
|
+
if (state.lastLayout) {
|
|
2142
2324
|
if (state.props.initialScroll) {
|
|
2143
2325
|
requestAnimationFrame(() => {
|
|
2144
2326
|
calculateItemsInView(ctx, state, { dataChanged: true });
|
|
@@ -2212,7 +2394,9 @@ function checkAtTop(state) {
|
|
|
2212
2394
|
// src/core/handleLayout.ts
|
|
2213
2395
|
function handleLayout(ctx, state, layout, setCanRender) {
|
|
2214
2396
|
const { maintainScrollAtEnd } = state.props;
|
|
2215
|
-
const
|
|
2397
|
+
const measuredLength = layout[state.props.horizontal ? "width" : "height"];
|
|
2398
|
+
const previousLength = state.scrollLength;
|
|
2399
|
+
const scrollLength = measuredLength > 0 ? measuredLength : previousLength;
|
|
2216
2400
|
const otherAxisSize = layout[state.props.horizontal ? "height" : "width"];
|
|
2217
2401
|
const needsCalculate = !state.lastLayout || scrollLength > state.scrollLength || state.lastLayout.x !== layout.x || state.lastLayout.y !== layout.y;
|
|
2218
2402
|
state.lastLayout = layout;
|
|
@@ -2223,7 +2407,9 @@ function handleLayout(ctx, state, layout, setCanRender) {
|
|
|
2223
2407
|
state.otherAxisSize = otherAxisSize;
|
|
2224
2408
|
state.lastBatchingAction = Date.now();
|
|
2225
2409
|
state.scrollForNextCalculateItemsInView = void 0;
|
|
2226
|
-
|
|
2410
|
+
if (scrollLength > 0) {
|
|
2411
|
+
doInitialAllocateContainers(ctx, state);
|
|
2412
|
+
}
|
|
2227
2413
|
if (needsCalculate) {
|
|
2228
2414
|
calculateItemsInView(ctx, state, { doMVCP: true });
|
|
2229
2415
|
}
|
|
@@ -2239,7 +2425,7 @@ function handleLayout(ctx, state, layout, setCanRender) {
|
|
|
2239
2425
|
if (state) {
|
|
2240
2426
|
state.needsOtherAxisSize = otherAxisSize - (state.props.stylePaddingTop || 0) < 10;
|
|
2241
2427
|
}
|
|
2242
|
-
if (__DEV__ &&
|
|
2428
|
+
if (__DEV__ && measuredLength === 0) {
|
|
2243
2429
|
warnDevOnce(
|
|
2244
2430
|
"height0",
|
|
2245
2431
|
`List ${state.props.horizontal ? "width" : "height"} is 0. You may need to set a style or \`flex: \` for the list, because children are absolutely positioned.`
|
|
@@ -2271,7 +2457,15 @@ function onScroll(ctx, state, event) {
|
|
|
2271
2457
|
}
|
|
2272
2458
|
}
|
|
2273
2459
|
state.scrollPending = newScroll;
|
|
2274
|
-
|
|
2460
|
+
{
|
|
2461
|
+
if (!state.onScrollRafScheduled) {
|
|
2462
|
+
state.onScrollRafScheduled = true;
|
|
2463
|
+
requestAnimationFrame(() => {
|
|
2464
|
+
state.onScrollRafScheduled = false;
|
|
2465
|
+
updateScroll(ctx, state, newScroll);
|
|
2466
|
+
});
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
2275
2469
|
onScrollProp == null ? void 0 : onScrollProp(event);
|
|
2276
2470
|
}
|
|
2277
2471
|
function updateScroll(ctx, state, newScroll) {
|
|
@@ -2437,7 +2631,8 @@ function updateOneItemSize(state, itemKey, sizeObj) {
|
|
|
2437
2631
|
if (!data) return 0;
|
|
2438
2632
|
const index = indexByKey.get(itemKey);
|
|
2439
2633
|
const prevSize = getItemSize(state, itemKey, index, data);
|
|
2440
|
-
const
|
|
2634
|
+
const rawSize = horizontal ? sizeObj.width : sizeObj.height;
|
|
2635
|
+
const size = Math.round(rawSize) ;
|
|
2441
2636
|
sizesKnown.set(itemKey, size);
|
|
2442
2637
|
if (!getEstimatedItemSize && !getFixedItemSize && size > 0) {
|
|
2443
2638
|
const itemType = getItemType ? (_a = getItemType(data[index], index)) != null ? _a : "" : "";
|
|
@@ -2455,7 +2650,7 @@ function updateOneItemSize(state, itemKey, sizeObj) {
|
|
|
2455
2650
|
return 0;
|
|
2456
2651
|
}
|
|
2457
2652
|
var useCombinedRef = (...refs) => {
|
|
2458
|
-
const callback =
|
|
2653
|
+
const callback = React4.useCallback((element) => {
|
|
2459
2654
|
for (const ref of refs) {
|
|
2460
2655
|
if (!ref) {
|
|
2461
2656
|
continue;
|
|
@@ -2470,6 +2665,28 @@ var useCombinedRef = (...refs) => {
|
|
|
2470
2665
|
return callback;
|
|
2471
2666
|
};
|
|
2472
2667
|
|
|
2668
|
+
// src/platform/RefreshControl.tsx
|
|
2669
|
+
function RefreshControl(props) {
|
|
2670
|
+
return null;
|
|
2671
|
+
}
|
|
2672
|
+
|
|
2673
|
+
// src/platform/StyleSheet.tsx
|
|
2674
|
+
function flattenStyles(styles) {
|
|
2675
|
+
if (Array.isArray(styles)) {
|
|
2676
|
+
return Object.assign({}, ...styles.filter(Boolean));
|
|
2677
|
+
}
|
|
2678
|
+
return styles;
|
|
2679
|
+
}
|
|
2680
|
+
var StyleSheet = {
|
|
2681
|
+
create: (styles) => styles,
|
|
2682
|
+
flatten: (style) => flattenStyles(style)
|
|
2683
|
+
};
|
|
2684
|
+
|
|
2685
|
+
// src/platform/useStickyScrollHandler.ts
|
|
2686
|
+
function useStickyScrollHandler(stickyIndices, horizontal, ctx, onScroll2) {
|
|
2687
|
+
return onScroll2;
|
|
2688
|
+
}
|
|
2689
|
+
|
|
2473
2690
|
// src/utils/createColumnWrapperStyle.ts
|
|
2474
2691
|
function createColumnWrapperStyle(contentContainerStyle) {
|
|
2475
2692
|
const { gap, columnGap, rowGap } = contentContainerStyle;
|
|
@@ -2506,10 +2723,49 @@ function getRenderedItem(ctx, state, key) {
|
|
|
2506
2723
|
item: data[index],
|
|
2507
2724
|
type: getItemType ? (_a = getItemType(data[index], index)) != null ? _a : "" : ""
|
|
2508
2725
|
};
|
|
2509
|
-
renderedItem = isFunction(renderItem) ? renderItem(itemProps) :
|
|
2726
|
+
renderedItem = isFunction(renderItem) ? renderItem(itemProps) : React4__namespace.default.createElement(renderItem, itemProps);
|
|
2510
2727
|
}
|
|
2511
2728
|
return { index, item: data[index], renderedItem };
|
|
2512
2729
|
}
|
|
2730
|
+
function useThrottleDebounce(mode) {
|
|
2731
|
+
const timeoutRef = React4.useRef(null);
|
|
2732
|
+
const lastCallTimeRef = React4.useRef(0);
|
|
2733
|
+
const lastArgsRef = React4.useRef(null);
|
|
2734
|
+
const clearTimeoutRef = () => {
|
|
2735
|
+
if (timeoutRef.current) {
|
|
2736
|
+
clearTimeout(timeoutRef.current);
|
|
2737
|
+
timeoutRef.current = null;
|
|
2738
|
+
}
|
|
2739
|
+
};
|
|
2740
|
+
const execute = React4.useCallback(
|
|
2741
|
+
(callback, delay, ...args) => {
|
|
2742
|
+
{
|
|
2743
|
+
const now = Date.now();
|
|
2744
|
+
lastArgsRef.current = args;
|
|
2745
|
+
if (now - lastCallTimeRef.current >= delay) {
|
|
2746
|
+
lastCallTimeRef.current = now;
|
|
2747
|
+
callback(...args);
|
|
2748
|
+
clearTimeoutRef();
|
|
2749
|
+
} else {
|
|
2750
|
+
clearTimeoutRef();
|
|
2751
|
+
timeoutRef.current = setTimeout(
|
|
2752
|
+
() => {
|
|
2753
|
+
if (lastArgsRef.current) {
|
|
2754
|
+
lastCallTimeRef.current = Date.now();
|
|
2755
|
+
callback(...lastArgsRef.current);
|
|
2756
|
+
timeoutRef.current = null;
|
|
2757
|
+
lastArgsRef.current = null;
|
|
2758
|
+
}
|
|
2759
|
+
},
|
|
2760
|
+
delay - (now - lastCallTimeRef.current)
|
|
2761
|
+
);
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
},
|
|
2765
|
+
[mode]
|
|
2766
|
+
);
|
|
2767
|
+
return execute;
|
|
2768
|
+
}
|
|
2513
2769
|
|
|
2514
2770
|
// src/utils/throttledOnScroll.ts
|
|
2515
2771
|
function useThrottledOnScroll(originalHandler, scrollEventThrottle) {
|
|
@@ -2578,18 +2834,17 @@ var LegendList = typedMemo(
|
|
|
2578
2834
|
const isChildrenMode = children !== void 0 && dataProp === void 0;
|
|
2579
2835
|
const processedProps = isChildrenMode ? {
|
|
2580
2836
|
...restProps,
|
|
2581
|
-
data: (isArray(children) ? children :
|
|
2837
|
+
data: (isArray(children) ? children : React4__namespace.Children.toArray(children)).flat(1),
|
|
2582
2838
|
renderItem: ({ item }) => item
|
|
2583
2839
|
} : {
|
|
2584
2840
|
...restProps,
|
|
2585
2841
|
data: dataProp || [],
|
|
2586
2842
|
renderItem: renderItemProp
|
|
2587
2843
|
};
|
|
2588
|
-
return /* @__PURE__ */
|
|
2844
|
+
return /* @__PURE__ */ React4__namespace.createElement(StateProvider, null, /* @__PURE__ */ React4__namespace.createElement(LegendListInner, { ...processedProps, ref: forwardedRef }));
|
|
2589
2845
|
})
|
|
2590
2846
|
);
|
|
2591
2847
|
var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
|
|
2592
|
-
var _a;
|
|
2593
2848
|
const {
|
|
2594
2849
|
alignItemsAtEnd = false,
|
|
2595
2850
|
columnWrapperStyle,
|
|
@@ -2625,7 +2880,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2625
2880
|
onScroll: onScrollProp,
|
|
2626
2881
|
onStartReached,
|
|
2627
2882
|
onStartReachedThreshold = 0.5,
|
|
2628
|
-
onViewableItemsChanged,
|
|
2629
2883
|
progressViewOffset,
|
|
2630
2884
|
recycleItems = false,
|
|
2631
2885
|
refreshControl,
|
|
@@ -2637,85 +2891,89 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2637
2891
|
stickyIndices,
|
|
2638
2892
|
style: styleProp,
|
|
2639
2893
|
suggestEstimatedItemSize,
|
|
2640
|
-
viewabilityConfig,
|
|
2641
|
-
viewabilityConfigCallbackPairs,
|
|
2642
2894
|
waitForInitialLayout = true,
|
|
2643
2895
|
...rest
|
|
2644
2896
|
} = props;
|
|
2645
|
-
const [renderNum, setRenderNum] =
|
|
2897
|
+
const [renderNum, setRenderNum] = React4.useState(0);
|
|
2646
2898
|
const initialScroll = initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
|
|
2647
|
-
const [canRender, setCanRender] =
|
|
2648
|
-
const contentContainerStyle = { ...
|
|
2649
|
-
const style = { ...
|
|
2899
|
+
const [canRender, setCanRender] = React4__namespace.useState(!IsNewArchitecture);
|
|
2900
|
+
const contentContainerStyle = { ...StyleSheet.flatten(contentContainerStyleProp) };
|
|
2901
|
+
const style = { ...StyleSheet.flatten(styleProp) };
|
|
2650
2902
|
const stylePaddingTopState = extractPadding(style, contentContainerStyle, "Top");
|
|
2651
2903
|
const stylePaddingBottomState = extractPadding(style, contentContainerStyle, "Bottom");
|
|
2652
2904
|
const ctx = useStateContext();
|
|
2653
2905
|
ctx.columnWrapperStyle = columnWrapperStyle || (contentContainerStyle ? createColumnWrapperStyle(contentContainerStyle) : void 0);
|
|
2654
|
-
const refScroller =
|
|
2906
|
+
const refScroller = React4.useRef(null);
|
|
2655
2907
|
const combinedRef = useCombinedRef(refScroller, refScrollView);
|
|
2656
2908
|
const estimatedItemSize = estimatedItemSizeProp != null ? estimatedItemSizeProp : DEFAULT_ITEM_SIZE;
|
|
2657
2909
|
const scrollBuffer = (drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE) || 1;
|
|
2658
2910
|
const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (_item, index) => index.toString();
|
|
2659
|
-
const refState =
|
|
2911
|
+
const refState = React4.useRef();
|
|
2660
2912
|
if (!refState.current) {
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2913
|
+
if (!ctx.internalState) {
|
|
2914
|
+
const initialScrollLength = (estimatedListSize != null ? estimatedListSize : { height: 0, width: 0 } )[horizontal ? "width" : "height"];
|
|
2915
|
+
ctx.internalState = {
|
|
2916
|
+
activeStickyIndex: void 0,
|
|
2917
|
+
averageSizes: {},
|
|
2918
|
+
columns: /* @__PURE__ */ new Map(),
|
|
2919
|
+
containerItemKeys: /* @__PURE__ */ new Set(),
|
|
2920
|
+
containerItemTypes: /* @__PURE__ */ new Map(),
|
|
2921
|
+
enableScrollForNextCalculateItemsInView: true,
|
|
2922
|
+
endBuffered: -1,
|
|
2923
|
+
endNoBuffer: -1,
|
|
2924
|
+
endReachedBlockedByTimer: false,
|
|
2925
|
+
firstFullyOnScreenIndex: -1,
|
|
2926
|
+
idCache: /* @__PURE__ */ new Map(),
|
|
2927
|
+
idsInView: [],
|
|
2928
|
+
indexByKey: /* @__PURE__ */ new Map(),
|
|
2929
|
+
initialScroll,
|
|
2930
|
+
isAtEnd: false,
|
|
2931
|
+
isAtStart: false,
|
|
2932
|
+
isEndReached: false,
|
|
2933
|
+
isStartReached: false,
|
|
2934
|
+
lastBatchingAction: Date.now(),
|
|
2935
|
+
lastLayout: void 0,
|
|
2936
|
+
loadStartTime: Date.now(),
|
|
2937
|
+
minIndexSizeChanged: 0,
|
|
2938
|
+
nativeMarginTop: 0,
|
|
2939
|
+
positions: /* @__PURE__ */ new Map(),
|
|
2940
|
+
props: {},
|
|
2941
|
+
queuedCalculateItemsInView: 0,
|
|
2942
|
+
refScroller: void 0,
|
|
2943
|
+
scroll: 0,
|
|
2944
|
+
scrollAdjustHandler: new ScrollAdjustHandler(ctx),
|
|
2945
|
+
scrollForNextCalculateItemsInView: void 0,
|
|
2946
|
+
scrollHistory: [],
|
|
2947
|
+
scrollLength: initialScrollLength,
|
|
2948
|
+
scrollPending: 0,
|
|
2949
|
+
scrollPrev: 0,
|
|
2950
|
+
scrollPrevTime: 0,
|
|
2951
|
+
scrollProcessingEnabled: true,
|
|
2952
|
+
scrollTime: 0,
|
|
2953
|
+
sizes: /* @__PURE__ */ new Map(),
|
|
2954
|
+
sizesKnown: /* @__PURE__ */ new Map(),
|
|
2955
|
+
startBuffered: -1,
|
|
2956
|
+
startNoBuffer: -1,
|
|
2957
|
+
startReachedBlockedByTimer: false,
|
|
2958
|
+
stickyContainerPool: /* @__PURE__ */ new Set(),
|
|
2959
|
+
stickyContainers: /* @__PURE__ */ new Map(),
|
|
2960
|
+
timeoutSizeMessage: 0,
|
|
2961
|
+
timeouts: /* @__PURE__ */ new Set(),
|
|
2962
|
+
totalSize: 0,
|
|
2963
|
+
viewabilityConfigCallbackPairs: void 0
|
|
2964
|
+
};
|
|
2965
|
+
set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPosition);
|
|
2966
|
+
set$(ctx, "extraData", extraData);
|
|
2967
|
+
}
|
|
2968
|
+
refState.current = ctx.internalState;
|
|
2714
2969
|
}
|
|
2715
2970
|
const state = refState.current;
|
|
2716
2971
|
const isFirst = !state.props.renderItem;
|
|
2717
2972
|
const didDataChange = state.props.data !== dataProp;
|
|
2718
|
-
const throttleScrollFn =
|
|
2973
|
+
const throttleScrollFn = (
|
|
2974
|
+
// @ts-expect-error TODO Fix this
|
|
2975
|
+
scrollEventThrottle && onScrollProp ? useThrottledOnScroll(onScrollProp, scrollEventThrottle) : onScrollProp
|
|
2976
|
+
);
|
|
2719
2977
|
state.props = {
|
|
2720
2978
|
alignItemsAtEnd,
|
|
2721
2979
|
data: dataProp,
|
|
@@ -2745,7 +3003,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2745
3003
|
scrollBuffer,
|
|
2746
3004
|
snapToIndices,
|
|
2747
3005
|
stickyIndicesArr: stickyIndices != null ? stickyIndices : [],
|
|
2748
|
-
stickyIndicesSet:
|
|
3006
|
+
stickyIndicesSet: React4.useMemo(() => new Set(stickyIndices != null ? stickyIndices : []), [stickyIndices == null ? void 0 : stickyIndices.join(",")]),
|
|
2749
3007
|
stylePaddingBottom: stylePaddingBottomState,
|
|
2750
3008
|
stylePaddingTop: stylePaddingTopState,
|
|
2751
3009
|
suggestEstimatedItemSize: !!suggestEstimatedItemSize
|
|
@@ -2772,7 +3030,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2772
3030
|
}
|
|
2773
3031
|
}
|
|
2774
3032
|
};
|
|
2775
|
-
const memoizedLastItemKeys =
|
|
3033
|
+
const memoizedLastItemKeys = React4.useMemo(() => {
|
|
2776
3034
|
if (!dataProp.length) return [];
|
|
2777
3035
|
return Array.from(
|
|
2778
3036
|
{ length: Math.min(numColumnsProp, dataProp.length) },
|
|
@@ -2786,7 +3044,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2786
3044
|
setPaddingTop(ctx, state, { stylePaddingTop: stylePaddingTopState });
|
|
2787
3045
|
refState.current.props.stylePaddingBottom = stylePaddingBottomState;
|
|
2788
3046
|
let paddingDiff = stylePaddingTopState - prevPaddingTop;
|
|
2789
|
-
if (maintainVisibleContentPosition && paddingDiff && prevPaddingTop !== void 0 &&
|
|
3047
|
+
if (maintainVisibleContentPosition && paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
|
|
2790
3048
|
if (state.scroll < 0) {
|
|
2791
3049
|
paddingDiff += state.scroll;
|
|
2792
3050
|
}
|
|
@@ -2797,7 +3055,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2797
3055
|
initializeStateVars();
|
|
2798
3056
|
updateAllPositions(ctx, state);
|
|
2799
3057
|
}
|
|
2800
|
-
const initialContentOffset =
|
|
3058
|
+
const initialContentOffset = React4.useMemo(() => {
|
|
2801
3059
|
if (initialScroll) {
|
|
2802
3060
|
const { index, viewOffset } = initialScroll;
|
|
2803
3061
|
let initialContentOffset2 = viewOffset || 0;
|
|
@@ -2813,37 +3071,33 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2813
3071
|
return 0;
|
|
2814
3072
|
}, [renderNum]);
|
|
2815
3073
|
if (isFirst || didDataChange || numColumnsProp !== peek$(ctx, "numColumns")) {
|
|
2816
|
-
|
|
3074
|
+
state.lastBatchingAction = Date.now();
|
|
2817
3075
|
if (!keyExtractorProp && !isFirst && didDataChange) {
|
|
2818
3076
|
__DEV__ && warnDevOnce(
|
|
2819
3077
|
"keyExtractor",
|
|
2820
3078
|
"Changing data without a keyExtractor can cause slow performance and resetting scroll. If your list data can change you should use a keyExtractor with a unique id for best performance and behavior."
|
|
2821
3079
|
);
|
|
2822
|
-
|
|
2823
|
-
|
|
3080
|
+
state.sizes.clear();
|
|
3081
|
+
state.positions.clear();
|
|
2824
3082
|
}
|
|
2825
3083
|
}
|
|
2826
|
-
const onLayoutHeader =
|
|
3084
|
+
const onLayoutHeader = React4.useCallback((rect, fromLayoutEffect) => {
|
|
2827
3085
|
const size = rect[horizontal ? "width" : "height"];
|
|
2828
3086
|
set$(ctx, "headerSize", size);
|
|
2829
3087
|
if ((initialScroll == null ? void 0 : initialScroll.index) !== void 0) {
|
|
2830
|
-
|
|
3088
|
+
{
|
|
2831
3089
|
if (fromLayoutEffect) {
|
|
2832
3090
|
setRenderNum((v) => v + 1);
|
|
2833
3091
|
}
|
|
2834
|
-
} else {
|
|
2835
|
-
setTimeout(() => {
|
|
2836
|
-
scrollToIndex(ctx, state, { ...initialScroll, animated: false });
|
|
2837
|
-
}, 17);
|
|
2838
3092
|
}
|
|
2839
3093
|
}
|
|
2840
3094
|
}, []);
|
|
2841
|
-
|
|
3095
|
+
React4.useLayoutEffect(() => {
|
|
2842
3096
|
if (snapToIndices) {
|
|
2843
3097
|
updateSnapToOffsets(ctx, state);
|
|
2844
3098
|
}
|
|
2845
3099
|
}, [snapToIndices]);
|
|
2846
|
-
|
|
3100
|
+
React4.useLayoutEffect(() => {
|
|
2847
3101
|
const didAllocateContainers = dataProp.length > 0 && doInitialAllocateContainersCallback();
|
|
2848
3102
|
if (!didAllocateContainers) {
|
|
2849
3103
|
checkResetContainers(
|
|
@@ -2852,24 +3106,20 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2852
3106
|
);
|
|
2853
3107
|
}
|
|
2854
3108
|
}, [dataProp, numColumnsProp]);
|
|
2855
|
-
|
|
3109
|
+
React4.useLayoutEffect(() => {
|
|
2856
3110
|
set$(ctx, "extraData", extraData);
|
|
2857
3111
|
}, [extraData]);
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
}
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
}
|
|
2870
|
-
}
|
|
2871
|
-
}, []);
|
|
2872
|
-
React3.useLayoutEffect(initializeStateVars, [
|
|
3112
|
+
const { onLayout } = useSyncLayout({
|
|
3113
|
+
onLayout: onLayoutProp,
|
|
3114
|
+
onLayoutChange: React4.useCallback(
|
|
3115
|
+
(rectangle) => {
|
|
3116
|
+
handleLayout(ctx, state, rectangle, setCanRender);
|
|
3117
|
+
},
|
|
3118
|
+
[ctx, state, setCanRender]
|
|
3119
|
+
),
|
|
3120
|
+
ref: refScroller
|
|
3121
|
+
});
|
|
3122
|
+
React4.useLayoutEffect(initializeStateVars, [
|
|
2873
3123
|
memoizedLastItemKeys.join(","),
|
|
2874
3124
|
numColumnsProp,
|
|
2875
3125
|
stylePaddingTopState,
|
|
@@ -2878,28 +3128,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2878
3128
|
const doInitialAllocateContainersCallback = () => {
|
|
2879
3129
|
return doInitialAllocateContainers(ctx, state);
|
|
2880
3130
|
};
|
|
2881
|
-
|
|
2882
|
-
const viewability = setupViewability({
|
|
2883
|
-
onViewableItemsChanged,
|
|
2884
|
-
viewabilityConfig,
|
|
2885
|
-
viewabilityConfigCallbackPairs
|
|
2886
|
-
});
|
|
2887
|
-
state.viewabilityConfigCallbackPairs = viewability;
|
|
2888
|
-
state.enableScrollForNextCalculateItemsInView = !viewability;
|
|
2889
|
-
}, [viewabilityConfig, viewabilityConfigCallbackPairs, onViewableItemsChanged]);
|
|
2890
|
-
if (!IsNewArchitecture) {
|
|
2891
|
-
useInit(() => {
|
|
2892
|
-
doInitialAllocateContainersCallback();
|
|
2893
|
-
});
|
|
2894
|
-
}
|
|
2895
|
-
const onLayout = React3.useCallback((event) => {
|
|
2896
|
-
const layout = event.nativeEvent.layout;
|
|
2897
|
-
handleLayout(ctx, state, layout, setCanRender);
|
|
2898
|
-
if (onLayoutProp) {
|
|
2899
|
-
onLayoutProp(event);
|
|
2900
|
-
}
|
|
2901
|
-
}, []);
|
|
2902
|
-
React3.useImperativeHandle(forwardedRef, () => {
|
|
3131
|
+
React4.useImperativeHandle(forwardedRef, () => {
|
|
2903
3132
|
const scrollIndexIntoView = (options) => {
|
|
2904
3133
|
const state2 = refState.current;
|
|
2905
3134
|
if (state2) {
|
|
@@ -2916,10 +3145,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2916
3145
|
}
|
|
2917
3146
|
};
|
|
2918
3147
|
return {
|
|
2919
|
-
flashScrollIndicators: () =>
|
|
3148
|
+
flashScrollIndicators: () => {
|
|
3149
|
+
var _a, _b;
|
|
3150
|
+
return (_b = (_a = refScroller.current) == null ? void 0 : _a.flashScrollIndicators) == null ? void 0 : _b.call(_a);
|
|
3151
|
+
},
|
|
2920
3152
|
getNativeScrollRef: () => refScroller.current,
|
|
2921
|
-
getScrollableNode: () => refScroller.current
|
|
2922
|
-
getScrollResponder: () => refScroller.current
|
|
3153
|
+
getScrollableNode: () => refScroller.current,
|
|
3154
|
+
getScrollResponder: () => refScroller.current,
|
|
2923
3155
|
getState: () => {
|
|
2924
3156
|
const state2 = refState.current;
|
|
2925
3157
|
return state2 ? {
|
|
@@ -2980,14 +3212,14 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2980
3212
|
}
|
|
2981
3213
|
};
|
|
2982
3214
|
}, []);
|
|
2983
|
-
|
|
2984
|
-
|
|
3215
|
+
{
|
|
3216
|
+
React4.useEffect(() => {
|
|
2985
3217
|
if (initialContentOffset) {
|
|
2986
3218
|
scrollTo(state, { animated: false, offset: initialContentOffset });
|
|
2987
3219
|
}
|
|
2988
3220
|
}, []);
|
|
2989
3221
|
}
|
|
2990
|
-
const fns =
|
|
3222
|
+
const fns = React4.useMemo(
|
|
2991
3223
|
() => ({
|
|
2992
3224
|
getRenderedItem: (key) => getRenderedItem(ctx, state, key),
|
|
2993
3225
|
onScroll: (event) => onScroll(ctx, state, event),
|
|
@@ -2995,18 +3227,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2995
3227
|
}),
|
|
2996
3228
|
[]
|
|
2997
3229
|
);
|
|
2998
|
-
const onScrollHandler =
|
|
2999
|
-
|
|
3000
|
-
if (stickyIndices == null ? void 0 : stickyIndices.length) {
|
|
3001
|
-
const { animatedScrollY } = ctx;
|
|
3002
|
-
return reactNative.Animated.event([{ nativeEvent: { contentOffset: { [horizontal ? "x" : "y"]: animatedScrollY } } }], {
|
|
3003
|
-
listener: onScrollFn,
|
|
3004
|
-
useNativeDriver: true
|
|
3005
|
-
});
|
|
3006
|
-
}
|
|
3007
|
-
return onScrollFn;
|
|
3008
|
-
}, [stickyIndices == null ? void 0 : stickyIndices.length, horizontal, scrollEventThrottle]);
|
|
3009
|
-
return /* @__PURE__ */ React3__namespace.createElement(React3__namespace.Fragment, null, /* @__PURE__ */ React3__namespace.createElement(
|
|
3230
|
+
const onScrollHandler = useStickyScrollHandler(stickyIndices, horizontal, ctx, fns.onScroll);
|
|
3231
|
+
return /* @__PURE__ */ React4__namespace.createElement(React4__namespace.Fragment, null, /* @__PURE__ */ React4__namespace.createElement(
|
|
3010
3232
|
ListComponent,
|
|
3011
3233
|
{
|
|
3012
3234
|
...rest,
|
|
@@ -3022,14 +3244,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3022
3244
|
onLayout,
|
|
3023
3245
|
onLayoutHeader,
|
|
3024
3246
|
onMomentumScrollEnd: (event) => {
|
|
3025
|
-
|
|
3247
|
+
{
|
|
3026
3248
|
requestAnimationFrame(() => {
|
|
3027
3249
|
finishScrollTo(refState.current);
|
|
3028
3250
|
});
|
|
3029
|
-
} else {
|
|
3030
|
-
setTimeout(() => {
|
|
3031
|
-
finishScrollTo(refState.current);
|
|
3032
|
-
}, 1e3);
|
|
3033
3251
|
}
|
|
3034
3252
|
if (onMomentumScrollEnd) {
|
|
3035
3253
|
onMomentumScrollEnd(event);
|
|
@@ -3037,10 +3255,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3037
3255
|
},
|
|
3038
3256
|
onScroll: onScrollHandler,
|
|
3039
3257
|
recycleItems,
|
|
3040
|
-
refreshControl: refreshControl ? stylePaddingTopState > 0 ?
|
|
3258
|
+
refreshControl: refreshControl ? stylePaddingTopState > 0 ? React4__namespace.cloneElement(refreshControl, {
|
|
3041
3259
|
progressViewOffset: (refreshControl.props.progressViewOffset || 0) + stylePaddingTopState
|
|
3042
|
-
}) : refreshControl : onRefresh && /* @__PURE__ */
|
|
3043
|
-
|
|
3260
|
+
}) : refreshControl : onRefresh && /* @__PURE__ */ React4__namespace.createElement(
|
|
3261
|
+
RefreshControl,
|
|
3044
3262
|
{
|
|
3045
3263
|
onRefresh,
|
|
3046
3264
|
progressViewOffset: (progressViewOffset || 0) + stylePaddingTopState,
|
|
@@ -3048,15 +3266,14 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3048
3266
|
}
|
|
3049
3267
|
),
|
|
3050
3268
|
refScrollView: combinedRef,
|
|
3051
|
-
scrollAdjustHandler:
|
|
3052
|
-
scrollEventThrottle: reactNative.Platform.OS === "web" ? 16 : void 0,
|
|
3269
|
+
scrollAdjustHandler: state.scrollAdjustHandler,
|
|
3053
3270
|
snapToIndices,
|
|
3054
3271
|
stickyIndices,
|
|
3055
3272
|
style,
|
|
3056
3273
|
updateItemSize: fns.updateItemSize,
|
|
3057
3274
|
waitForInitialLayout
|
|
3058
3275
|
}
|
|
3059
|
-
), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */
|
|
3276
|
+
), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */ React4__namespace.createElement(DebugView, { state: refState.current }));
|
|
3060
3277
|
});
|
|
3061
3278
|
|
|
3062
3279
|
exports.LegendList = LegendList;
|
|
@@ -3064,6 +3281,6 @@ exports.useIsLastItem = useIsLastItem;
|
|
|
3064
3281
|
exports.useListScrollSize = useListScrollSize;
|
|
3065
3282
|
exports.useRecyclingEffect = useRecyclingEffect;
|
|
3066
3283
|
exports.useRecyclingState = useRecyclingState;
|
|
3067
|
-
exports.useSyncLayout =
|
|
3284
|
+
exports.useSyncLayout = useSyncLayout2;
|
|
3068
3285
|
exports.useViewability = useViewability;
|
|
3069
3286
|
exports.useViewabilityAmount = useViewabilityAmount;
|