@legendapp/list 2.0.13 → 2.1.0-beta.1
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 +14 -6
- package/index.d.ts +14 -6
- package/index.js +753 -455
- package/index.mjs +700 -402
- package/package.json +6 -3
package/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var reactNative = require('react-native');
|
|
3
|
+
var React3 = 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,13 +22,25 @@ function _interopNamespace(e) {
|
|
|
22
22
|
return Object.freeze(n);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
var
|
|
25
|
+
var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
|
|
26
26
|
|
|
27
27
|
// src/components/LegendList.tsx
|
|
28
|
-
|
|
28
|
+
React3.forwardRef(function AnimatedView2(props, ref) {
|
|
29
|
+
return /* @__PURE__ */ React3__namespace.createElement("div", { ref, ...props });
|
|
30
|
+
});
|
|
31
|
+
var View = React3.forwardRef(function View2(props, ref) {
|
|
32
|
+
return /* @__PURE__ */ React3__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 = React3__namespace.createContext(null);
|
|
29
41
|
function StateProvider({ children }) {
|
|
30
|
-
const [value] =
|
|
31
|
-
animatedScrollY:
|
|
42
|
+
const [value] = React3__namespace.useState(() => ({
|
|
43
|
+
animatedScrollY: createAnimatedValue(0),
|
|
32
44
|
columnWrapperStyle: void 0,
|
|
33
45
|
internalState: void 0,
|
|
34
46
|
listeners: /* @__PURE__ */ new Map(),
|
|
@@ -46,10 +58,10 @@ function StateProvider({ children }) {
|
|
|
46
58
|
]),
|
|
47
59
|
viewRefs: /* @__PURE__ */ new Map()
|
|
48
60
|
}));
|
|
49
|
-
return /* @__PURE__ */
|
|
61
|
+
return /* @__PURE__ */ React3__namespace.createElement(ContextState.Provider, { value }, children);
|
|
50
62
|
}
|
|
51
63
|
function useStateContext() {
|
|
52
|
-
return
|
|
64
|
+
return React3__namespace.useContext(ContextState);
|
|
53
65
|
}
|
|
54
66
|
function createSelectorFunctionsArr(ctx, signalNames) {
|
|
55
67
|
let lastValues = [];
|
|
@@ -119,23 +131,23 @@ function getContentSize(ctx) {
|
|
|
119
131
|
return headerSize + footerSize + totalSize + stylePaddingTop;
|
|
120
132
|
}
|
|
121
133
|
function useArr$(signalNames) {
|
|
122
|
-
const ctx =
|
|
123
|
-
const { subscribe, get } =
|
|
134
|
+
const ctx = React3__namespace.useContext(ContextState);
|
|
135
|
+
const { subscribe, get } = React3__namespace.useMemo(() => createSelectorFunctionsArr(ctx, signalNames), [ctx, signalNames]);
|
|
124
136
|
const value = shim.useSyncExternalStore(subscribe, get);
|
|
125
137
|
return value;
|
|
126
138
|
}
|
|
127
139
|
function useSelector$(signalName, selector) {
|
|
128
|
-
const ctx =
|
|
129
|
-
const { subscribe, get } =
|
|
140
|
+
const ctx = React3__namespace.useContext(ContextState);
|
|
141
|
+
const { subscribe, get } = React3__namespace.useMemo(() => createSelectorFunctionsArr(ctx, [signalName]), [ctx, signalName]);
|
|
130
142
|
const value = shim.useSyncExternalStore(subscribe, () => selector(get()[0]));
|
|
131
143
|
return value;
|
|
132
144
|
}
|
|
133
145
|
|
|
134
146
|
// src/components/DebugView.tsx
|
|
135
147
|
var DebugRow = ({ children }) => {
|
|
136
|
-
return /* @__PURE__ */
|
|
148
|
+
return /* @__PURE__ */ React3__namespace.createElement(View, { style: { alignItems: "center", flexDirection: "row", justifyContent: "space-between" } }, children);
|
|
137
149
|
};
|
|
138
|
-
var DebugView =
|
|
150
|
+
var DebugView = React3__namespace.memo(function DebugView2({ state }) {
|
|
139
151
|
const ctx = useStateContext();
|
|
140
152
|
const [totalSize = 0, scrollAdjust = 0, rawScroll = 0, scroll = 0, _numContainers = 0, _numContainersPooled = 0] = useArr$([
|
|
141
153
|
"totalSize",
|
|
@@ -146,12 +158,12 @@ var DebugView = React2__namespace.memo(function DebugView2({ state }) {
|
|
|
146
158
|
"numContainersPooled"
|
|
147
159
|
]);
|
|
148
160
|
const contentSize = getContentSize(ctx);
|
|
149
|
-
const [, forceUpdate] =
|
|
161
|
+
const [, forceUpdate] = React3.useReducer((x) => x + 1, 0);
|
|
150
162
|
useInterval(() => {
|
|
151
163
|
forceUpdate();
|
|
152
164
|
}, 100);
|
|
153
|
-
return /* @__PURE__ */
|
|
154
|
-
|
|
165
|
+
return /* @__PURE__ */ React3__namespace.createElement(
|
|
166
|
+
View,
|
|
155
167
|
{
|
|
156
168
|
pointerEvents: "none",
|
|
157
169
|
style: {
|
|
@@ -166,72 +178,35 @@ var DebugView = React2__namespace.memo(function DebugView2({ state }) {
|
|
|
166
178
|
top: 0
|
|
167
179
|
}
|
|
168
180
|
},
|
|
169
|
-
/* @__PURE__ */
|
|
170
|
-
/* @__PURE__ */
|
|
171
|
-
/* @__PURE__ */
|
|
172
|
-
/* @__PURE__ */
|
|
173
|
-
/* @__PURE__ */
|
|
174
|
-
/* @__PURE__ */
|
|
175
|
-
/* @__PURE__ */ React2__namespace.createElement(DebugRow, null, /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, "RawScroll: "), /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, rawScroll.toFixed(2))),
|
|
176
|
-
/* @__PURE__ */ React2__namespace.createElement(DebugRow, null, /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, "ComputedScroll: "), /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, scroll.toFixed(2)))
|
|
181
|
+
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(Text, null, "TotalSize:"), /* @__PURE__ */ React3__namespace.createElement(Text, null, totalSize.toFixed(2))),
|
|
182
|
+
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(Text, null, "ContentSize:"), /* @__PURE__ */ React3__namespace.createElement(Text, null, contentSize.toFixed(2))),
|
|
183
|
+
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(Text, null, "At end:"), /* @__PURE__ */ React3__namespace.createElement(Text, null, String(state.isAtEnd))),
|
|
184
|
+
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(Text, null, "ScrollAdjust:"), /* @__PURE__ */ React3__namespace.createElement(Text, null, scrollAdjust.toFixed(2))),
|
|
185
|
+
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(Text, null, "RawScroll: "), /* @__PURE__ */ React3__namespace.createElement(Text, null, rawScroll.toFixed(2))),
|
|
186
|
+
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(Text, null, "ComputedScroll: "), /* @__PURE__ */ React3__namespace.createElement(Text, null, scroll.toFixed(2)))
|
|
177
187
|
);
|
|
178
188
|
});
|
|
179
189
|
function useInterval(callback, delay) {
|
|
180
|
-
|
|
190
|
+
React3.useEffect(() => {
|
|
181
191
|
const interval = setInterval(callback, delay);
|
|
182
192
|
return () => clearInterval(interval);
|
|
183
193
|
}, [delay]);
|
|
184
194
|
}
|
|
185
195
|
|
|
196
|
+
// src/utils/devEnvironment.ts
|
|
197
|
+
var metroDev = typeof __DEV__ !== "undefined" ? __DEV__ : void 0;
|
|
198
|
+
var _a;
|
|
199
|
+
var envMode = typeof process !== "undefined" && typeof process.env === "object" && process.env ? (_a = process.env.NODE_ENV) != null ? _a : process.env.MODE : void 0;
|
|
200
|
+
var processDev = typeof envMode === "string" ? envMode.toLowerCase() !== "production" : void 0;
|
|
201
|
+
var _a2;
|
|
202
|
+
var IS_DEV = (_a2 = metroDev != null ? metroDev : processDev) != null ? _a2 : false;
|
|
203
|
+
|
|
186
204
|
// src/constants.ts
|
|
187
205
|
var POSITION_OUT_OF_VIEW = -1e7;
|
|
188
|
-
var ENABLE_DEVMODE =
|
|
189
|
-
var ENABLE_DEBUG_VIEW =
|
|
190
|
-
var
|
|
191
|
-
var
|
|
192
|
-
return React2.useRef(new reactNative.Animated.Value(initialValue)).current;
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
// src/hooks/useValue$.ts
|
|
196
|
-
function useValue$(key, params) {
|
|
197
|
-
var _a;
|
|
198
|
-
const { getValue, delay } = params || {};
|
|
199
|
-
const ctx = useStateContext();
|
|
200
|
-
const animValue = useAnimatedValue((_a = getValue ? getValue(peek$(ctx, key)) : peek$(ctx, key)) != null ? _a : 0);
|
|
201
|
-
React2.useMemo(() => {
|
|
202
|
-
let newValue;
|
|
203
|
-
let prevValue;
|
|
204
|
-
let didQueueTask = false;
|
|
205
|
-
listen$(ctx, key, (v) => {
|
|
206
|
-
newValue = getValue ? getValue(v) : v;
|
|
207
|
-
if (delay !== void 0) {
|
|
208
|
-
const fn = () => {
|
|
209
|
-
didQueueTask = false;
|
|
210
|
-
if (newValue !== void 0) {
|
|
211
|
-
animValue.setValue(newValue);
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
const delayValue = typeof delay === "function" ? delay(newValue, prevValue) : delay;
|
|
215
|
-
prevValue = newValue;
|
|
216
|
-
if (!didQueueTask) {
|
|
217
|
-
didQueueTask = true;
|
|
218
|
-
if (delayValue === void 0) {
|
|
219
|
-
fn();
|
|
220
|
-
} else if (delayValue === 0) {
|
|
221
|
-
queueMicrotask(fn);
|
|
222
|
-
} else {
|
|
223
|
-
setTimeout(fn, delayValue);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
} else {
|
|
227
|
-
animValue.setValue(newValue);
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
}, []);
|
|
231
|
-
return animValue;
|
|
232
|
-
}
|
|
233
|
-
var typedForwardRef = React2.forwardRef;
|
|
234
|
-
var typedMemo = React2.memo;
|
|
206
|
+
var ENABLE_DEVMODE = IS_DEV && false;
|
|
207
|
+
var ENABLE_DEBUG_VIEW = IS_DEV && false;
|
|
208
|
+
var typedForwardRef = React3.forwardRef;
|
|
209
|
+
var typedMemo = React3.memo;
|
|
235
210
|
|
|
236
211
|
// src/components/PositionView.tsx
|
|
237
212
|
var PositionViewState = typedMemo(function PositionView({
|
|
@@ -242,64 +217,37 @@ var PositionViewState = typedMemo(function PositionView({
|
|
|
242
217
|
...rest
|
|
243
218
|
}) {
|
|
244
219
|
const [position = POSITION_OUT_OF_VIEW] = useArr$([`containerPosition${id}`]);
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
ref: refView,
|
|
249
|
-
style: [
|
|
250
|
-
style,
|
|
251
|
-
horizontal ? { transform: [{ translateX: position }] } : { transform: [{ translateY: position }] }
|
|
252
|
-
],
|
|
253
|
-
...rest
|
|
254
|
-
}
|
|
255
|
-
);
|
|
256
|
-
});
|
|
257
|
-
var PositionViewAnimated = typedMemo(function PositionView2({
|
|
258
|
-
id,
|
|
259
|
-
horizontal,
|
|
260
|
-
style,
|
|
261
|
-
refView,
|
|
262
|
-
...rest
|
|
263
|
-
}) {
|
|
264
|
-
const position$ = useValue$(`containerPosition${id}`, {
|
|
265
|
-
getValue: (v) => v != null ? v : POSITION_OUT_OF_VIEW
|
|
266
|
-
});
|
|
267
|
-
let position;
|
|
268
|
-
if (reactNative.Platform.OS === "ios" || reactNative.Platform.OS === "android") {
|
|
269
|
-
position = horizontal ? { transform: [{ translateX: position$ }] } : { transform: [{ translateY: position$ }] };
|
|
270
|
-
} else {
|
|
271
|
-
position = horizontal ? { left: position$ } : { top: position$ };
|
|
272
|
-
}
|
|
273
|
-
return /* @__PURE__ */ React2__namespace.createElement(reactNative.Animated.View, { ref: refView, style: [style, position], ...rest });
|
|
220
|
+
const base = Array.isArray(style) ? Object.assign({}, ...style) : style;
|
|
221
|
+
const combinedStyle = horizontal ? { ...base, left: position } : { ...base, top: position };
|
|
222
|
+
return /* @__PURE__ */ React3__namespace.createElement("div", { ref: refView, style: combinedStyle, ...rest });
|
|
274
223
|
});
|
|
275
224
|
var PositionViewSticky = typedMemo(function PositionViewSticky2({
|
|
276
225
|
id,
|
|
277
226
|
horizontal,
|
|
278
227
|
style,
|
|
279
228
|
refView,
|
|
280
|
-
animatedScrollY,
|
|
281
|
-
stickyOffset,
|
|
282
229
|
index,
|
|
283
230
|
...rest
|
|
284
231
|
}) {
|
|
285
|
-
const [position = POSITION_OUT_OF_VIEW,
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
const viewStyle = React2__namespace.useMemo(() => [style, { zIndex: index + 1e3 }, { transform }], [style, transform]);
|
|
297
|
-
return /* @__PURE__ */ React2__namespace.createElement(reactNative.Animated.View, { ref: refView, style: viewStyle, ...rest });
|
|
232
|
+
const [position = POSITION_OUT_OF_VIEW, _headerSize] = useArr$([`containerPosition${id}`, "headerSize"]);
|
|
233
|
+
const viewStyle = React3__namespace.useMemo(() => {
|
|
234
|
+
const base = Array.isArray(style) ? Object.assign({}, ...style) : style;
|
|
235
|
+
const axisStyle = horizontal ? { transform: `translateX(${position}px)` } : { top: position };
|
|
236
|
+
return {
|
|
237
|
+
...base,
|
|
238
|
+
zIndex: index + 1e3,
|
|
239
|
+
...axisStyle
|
|
240
|
+
};
|
|
241
|
+
}, [style, position, horizontal, index]);
|
|
242
|
+
return /* @__PURE__ */ React3__namespace.createElement("div", { ref: refView, style: viewStyle, ...rest });
|
|
298
243
|
});
|
|
299
|
-
var
|
|
244
|
+
var PositionView2 = PositionViewState;
|
|
245
|
+
|
|
246
|
+
// src/constants-platform.ts
|
|
247
|
+
var IsNewArchitecture = true;
|
|
300
248
|
var symbolFirst = Symbol();
|
|
301
249
|
function useInit(cb) {
|
|
302
|
-
const refValue =
|
|
250
|
+
const refValue = React3.useRef(symbolFirst);
|
|
303
251
|
if (refValue.current === symbolFirst) {
|
|
304
252
|
refValue.current = cb();
|
|
305
253
|
}
|
|
@@ -315,7 +263,7 @@ function isArray(obj) {
|
|
|
315
263
|
}
|
|
316
264
|
var warned = /* @__PURE__ */ new Set();
|
|
317
265
|
function warnDevOnce(id, text) {
|
|
318
|
-
if (
|
|
266
|
+
if (IS_DEV && !warned.has(id)) {
|
|
319
267
|
warned.add(id);
|
|
320
268
|
console.warn(`[legend-list] ${text}`);
|
|
321
269
|
}
|
|
@@ -330,18 +278,18 @@ function comparatorDefault(a, b) {
|
|
|
330
278
|
return a - b;
|
|
331
279
|
}
|
|
332
280
|
function getPadding(s, type) {
|
|
333
|
-
var
|
|
334
|
-
return (_c = (_b = (
|
|
281
|
+
var _a3, _b, _c;
|
|
282
|
+
return (_c = (_b = (_a3 = s[`padding${type}`]) != null ? _a3 : s.paddingVertical) != null ? _b : s.padding) != null ? _c : 0;
|
|
335
283
|
}
|
|
336
284
|
function extractPadding(style, contentContainerStyle, type) {
|
|
337
285
|
return getPadding(style, type) + getPadding(contentContainerStyle, type);
|
|
338
286
|
}
|
|
339
287
|
|
|
340
288
|
// src/state/ContextContainer.ts
|
|
341
|
-
var ContextContainer =
|
|
289
|
+
var ContextContainer = React3.createContext(null);
|
|
342
290
|
function useViewability(callback, configId) {
|
|
343
291
|
const ctx = useStateContext();
|
|
344
|
-
const { containerId } =
|
|
292
|
+
const { containerId } = React3.useContext(ContextContainer);
|
|
345
293
|
const key = containerId + (configId != null ? configId : "");
|
|
346
294
|
useInit(() => {
|
|
347
295
|
const value = ctx.mapViewabilityValues.get(key);
|
|
@@ -350,7 +298,7 @@ function useViewability(callback, configId) {
|
|
|
350
298
|
}
|
|
351
299
|
});
|
|
352
300
|
ctx.mapViewabilityCallbacks.set(key, callback);
|
|
353
|
-
|
|
301
|
+
React3.useEffect(
|
|
354
302
|
() => () => {
|
|
355
303
|
ctx.mapViewabilityCallbacks.delete(key);
|
|
356
304
|
},
|
|
@@ -359,7 +307,7 @@ function useViewability(callback, configId) {
|
|
|
359
307
|
}
|
|
360
308
|
function useViewabilityAmount(callback) {
|
|
361
309
|
const ctx = useStateContext();
|
|
362
|
-
const { containerId } =
|
|
310
|
+
const { containerId } = React3.useContext(ContextContainer);
|
|
363
311
|
useInit(() => {
|
|
364
312
|
const value = ctx.mapViewabilityAmountValues.get(containerId);
|
|
365
313
|
if (value) {
|
|
@@ -367,7 +315,7 @@ function useViewabilityAmount(callback) {
|
|
|
367
315
|
}
|
|
368
316
|
});
|
|
369
317
|
ctx.mapViewabilityAmountCallbacks.set(containerId, callback);
|
|
370
|
-
|
|
318
|
+
React3.useEffect(
|
|
371
319
|
() => () => {
|
|
372
320
|
ctx.mapViewabilityAmountCallbacks.delete(containerId);
|
|
373
321
|
},
|
|
@@ -375,12 +323,12 @@ function useViewabilityAmount(callback) {
|
|
|
375
323
|
);
|
|
376
324
|
}
|
|
377
325
|
function useRecyclingEffect(effect) {
|
|
378
|
-
const { index, value } =
|
|
379
|
-
const prevValues =
|
|
326
|
+
const { index, value } = React3.useContext(ContextContainer);
|
|
327
|
+
const prevValues = React3.useRef({
|
|
380
328
|
prevIndex: void 0,
|
|
381
329
|
prevItem: void 0
|
|
382
330
|
});
|
|
383
|
-
|
|
331
|
+
React3.useEffect(() => {
|
|
384
332
|
let ret;
|
|
385
333
|
if (prevValues.current.prevIndex !== void 0 && prevValues.current.prevItem !== void 0) {
|
|
386
334
|
ret = effect({
|
|
@@ -398,12 +346,12 @@ function useRecyclingEffect(effect) {
|
|
|
398
346
|
}, [index, value, effect]);
|
|
399
347
|
}
|
|
400
348
|
function useRecyclingState(valueOrFun) {
|
|
401
|
-
const { index, value, itemKey, triggerLayout } =
|
|
402
|
-
const refState =
|
|
349
|
+
const { index, value, itemKey, triggerLayout } = React3.useContext(ContextContainer);
|
|
350
|
+
const refState = React3.useRef({
|
|
403
351
|
itemKey: null,
|
|
404
352
|
value: null
|
|
405
353
|
});
|
|
406
|
-
const [_, setRenderNum] =
|
|
354
|
+
const [_, setRenderNum] = React3.useState(0);
|
|
407
355
|
const state = refState.current;
|
|
408
356
|
if (state.itemKey !== itemKey) {
|
|
409
357
|
state.itemKey = itemKey;
|
|
@@ -414,7 +362,7 @@ function useRecyclingState(valueOrFun) {
|
|
|
414
362
|
prevItem: void 0
|
|
415
363
|
}) : valueOrFun;
|
|
416
364
|
}
|
|
417
|
-
const setState =
|
|
365
|
+
const setState = React3.useCallback(
|
|
418
366
|
(newState) => {
|
|
419
367
|
state.value = isFunction(newState) ? newState(state.value) : newState;
|
|
420
368
|
setRenderNum((v) => v + 1);
|
|
@@ -425,7 +373,7 @@ function useRecyclingState(valueOrFun) {
|
|
|
425
373
|
return [state.value, setState];
|
|
426
374
|
}
|
|
427
375
|
function useIsLastItem() {
|
|
428
|
-
const { itemKey } =
|
|
376
|
+
const { itemKey } = React3.useContext(ContextContainer);
|
|
429
377
|
const isLast = useSelector$("lastItemKeys", (lastItemKeys) => (lastItemKeys == null ? void 0 : lastItemKeys.includes(itemKey)) || false);
|
|
430
378
|
return isLast;
|
|
431
379
|
}
|
|
@@ -433,44 +381,101 @@ function useListScrollSize() {
|
|
|
433
381
|
const [scrollSize] = useArr$(["scrollSize"]);
|
|
434
382
|
return scrollSize;
|
|
435
383
|
}
|
|
436
|
-
var noop = () => {
|
|
437
|
-
};
|
|
438
384
|
function useSyncLayout() {
|
|
439
|
-
|
|
440
|
-
const { triggerLayout: syncLayout } =
|
|
385
|
+
{
|
|
386
|
+
const { triggerLayout: syncLayout } = React3.useContext(ContextContainer);
|
|
441
387
|
return syncLayout;
|
|
442
|
-
} else {
|
|
443
|
-
return noop;
|
|
444
388
|
}
|
|
445
389
|
}
|
|
446
390
|
|
|
447
391
|
// src/components/Separator.tsx
|
|
448
392
|
function Separator({ ItemSeparatorComponent, leadingItem }) {
|
|
449
393
|
const isLastItem = useIsLastItem();
|
|
450
|
-
return isLastItem ? null : /* @__PURE__ */
|
|
394
|
+
return isLastItem ? null : /* @__PURE__ */ React3__namespace.createElement(ItemSeparatorComponent, { leadingItem });
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// src/hooks/createResizeObserver.ts
|
|
398
|
+
var globalResizeObserver = null;
|
|
399
|
+
function getGlobalResizeObserver() {
|
|
400
|
+
if (!globalResizeObserver) {
|
|
401
|
+
globalResizeObserver = new ResizeObserver((entries) => {
|
|
402
|
+
for (const entry of entries) {
|
|
403
|
+
const callbacks = callbackMap.get(entry.target);
|
|
404
|
+
if (callbacks) {
|
|
405
|
+
for (const callback of callbacks) {
|
|
406
|
+
callback(entry);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
return globalResizeObserver;
|
|
413
|
+
}
|
|
414
|
+
var callbackMap = /* @__PURE__ */ new WeakMap();
|
|
415
|
+
function createResizeObserver(element, callback) {
|
|
416
|
+
if (!element) {
|
|
417
|
+
return () => {
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
const observer = getGlobalResizeObserver();
|
|
421
|
+
let callbacks = callbackMap.get(element);
|
|
422
|
+
if (!callbacks) {
|
|
423
|
+
callbacks = /* @__PURE__ */ new Set();
|
|
424
|
+
callbackMap.set(element, callbacks);
|
|
425
|
+
observer.observe(element);
|
|
426
|
+
}
|
|
427
|
+
callbacks.add(callback);
|
|
428
|
+
return () => {
|
|
429
|
+
const callbacks2 = callbackMap.get(element);
|
|
430
|
+
if (callbacks2) {
|
|
431
|
+
callbacks2.delete(callback);
|
|
432
|
+
if (callbacks2.size === 0) {
|
|
433
|
+
callbackMap.delete(element);
|
|
434
|
+
observer.unobserve(element);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
};
|
|
451
438
|
}
|
|
439
|
+
|
|
440
|
+
// src/hooks/useOnLayoutSync.tsx
|
|
452
441
|
function useOnLayoutSync({
|
|
453
442
|
ref,
|
|
454
443
|
onLayoutProp,
|
|
455
444
|
onLayoutChange
|
|
456
|
-
}, deps
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
if (
|
|
467
|
-
|
|
468
|
-
onLayoutChange({ height, width, x, y }, true);
|
|
469
|
-
});
|
|
445
|
+
}, deps) {
|
|
446
|
+
React3.useLayoutEffect(() => {
|
|
447
|
+
var _a3, _b;
|
|
448
|
+
const current = ref.current;
|
|
449
|
+
const scrollableNode = (_b = (_a3 = current == null ? void 0 : current.getScrollableNode) == null ? void 0 : _a3.call(current)) != null ? _b : null;
|
|
450
|
+
const element = scrollableNode || current;
|
|
451
|
+
if (!element || !(element instanceof HTMLElement)) {
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
const emit = (layout, fromLayoutEffect) => {
|
|
455
|
+
if (layout.height === 0 && layout.width === 0) {
|
|
456
|
+
return;
|
|
470
457
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
458
|
+
onLayoutChange(layout, fromLayoutEffect);
|
|
459
|
+
onLayoutProp == null ? void 0 : onLayoutProp({ nativeEvent: { layout } });
|
|
460
|
+
};
|
|
461
|
+
const rect = element.getBoundingClientRect();
|
|
462
|
+
emit(toLayout(rect), true);
|
|
463
|
+
return createResizeObserver(element, (entry) => {
|
|
464
|
+
var _a4;
|
|
465
|
+
const target = entry.target instanceof HTMLElement ? entry.target : void 0;
|
|
466
|
+
const rect2 = (_a4 = entry.contentRect) != null ? _a4 : target == null ? void 0 : target.getBoundingClientRect();
|
|
467
|
+
emit(toLayout(rect2), false);
|
|
468
|
+
});
|
|
469
|
+
}, deps);
|
|
470
|
+
return {};
|
|
471
|
+
}
|
|
472
|
+
function toLayout(rect) {
|
|
473
|
+
return {
|
|
474
|
+
height: rect.height,
|
|
475
|
+
width: rect.width,
|
|
476
|
+
x: rect.left,
|
|
477
|
+
y: rect.top
|
|
478
|
+
};
|
|
474
479
|
}
|
|
475
480
|
|
|
476
481
|
// src/components/Container.tsx
|
|
@@ -493,13 +498,20 @@ var Container = typedMemo(function Container2({
|
|
|
493
498
|
`containerSticky${id}`,
|
|
494
499
|
`containerStickyOffset${id}`
|
|
495
500
|
]);
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
|
|
501
|
+
const itemLayoutRef = React3.useRef({
|
|
502
|
+
horizontal,
|
|
503
|
+
itemKey,
|
|
504
|
+
updateItemSize: updateItemSize2
|
|
505
|
+
});
|
|
506
|
+
itemLayoutRef.current.horizontal = horizontal;
|
|
507
|
+
itemLayoutRef.current.itemKey = itemKey;
|
|
508
|
+
itemLayoutRef.current.updateItemSize = updateItemSize2;
|
|
509
|
+
const ref = React3.useRef(null);
|
|
510
|
+
const [layoutRenderCount, forceLayoutRender] = React3.useState(0);
|
|
499
511
|
const otherAxisPos = numColumns > 1 ? `${(column - 1) / numColumns * 100}%` : 0;
|
|
500
512
|
const otherAxisSize = numColumns > 1 ? `${1 / numColumns * 100}%` : void 0;
|
|
501
|
-
const didLayoutRef =
|
|
502
|
-
const style =
|
|
513
|
+
const didLayoutRef = React3.useRef(false);
|
|
514
|
+
const style = React3.useMemo(() => {
|
|
503
515
|
let paddingStyles;
|
|
504
516
|
if (columnWrapperStyle) {
|
|
505
517
|
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
@@ -531,12 +543,12 @@ var Container = typedMemo(function Container2({
|
|
|
531
543
|
...paddingStyles || {}
|
|
532
544
|
};
|
|
533
545
|
}, [horizontal, otherAxisPos, otherAxisSize, columnWrapperStyle, numColumns]);
|
|
534
|
-
const renderedItemInfo =
|
|
546
|
+
const renderedItemInfo = React3.useMemo(
|
|
535
547
|
() => itemKey !== void 0 ? getRenderedItem2(itemKey) : null,
|
|
536
548
|
[itemKey, data, extraData]
|
|
537
549
|
);
|
|
538
550
|
const { index, renderedItem } = renderedItemInfo || {};
|
|
539
|
-
const contextValue =
|
|
551
|
+
const contextValue = React3.useMemo(() => {
|
|
540
552
|
ctx.viewRefs.set(id, ref);
|
|
541
553
|
return {
|
|
542
554
|
containerId: id,
|
|
@@ -548,27 +560,27 @@ var Container = typedMemo(function Container2({
|
|
|
548
560
|
value: data
|
|
549
561
|
};
|
|
550
562
|
}, [id, itemKey, index, data]);
|
|
551
|
-
const onLayoutChange = (rectangle) => {
|
|
552
|
-
|
|
553
|
-
|
|
563
|
+
const onLayoutChange = React3.useCallback((rectangle) => {
|
|
564
|
+
const {
|
|
565
|
+
horizontal: currentHorizontal,
|
|
566
|
+
itemKey: currentItemKey,
|
|
567
|
+
updateItemSize: updateItemSizeFn
|
|
568
|
+
} = itemLayoutRef.current;
|
|
569
|
+
if (isNullOrUndefined(currentItemKey)) {
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
didLayoutRef.current = true;
|
|
573
|
+
let layout = rectangle;
|
|
574
|
+
Math.floor(rectangle[currentHorizontal ? "width" : "height"] * 8) / 8;
|
|
575
|
+
const doUpdate = () => {
|
|
576
|
+
itemLayoutRef.current.lastSize = { height: layout.height, width: layout.width };
|
|
577
|
+
updateItemSizeFn(currentItemKey, layout);
|
|
554
578
|
didLayoutRef.current = true;
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
refLastSize.current = { height: layout.height, width: layout.width };
|
|
559
|
-
updateItemSize2(itemKey, layout);
|
|
560
|
-
didLayoutRef.current = true;
|
|
561
|
-
};
|
|
562
|
-
if (IsNewArchitecture || size > 0) {
|
|
563
|
-
doUpdate();
|
|
564
|
-
} else {
|
|
565
|
-
(_b = (_a = ref.current) == null ? void 0 : _a.measure) == null ? void 0 : _b.call(_a, (_x, _y, width, height) => {
|
|
566
|
-
layout = { height, width };
|
|
567
|
-
doUpdate();
|
|
568
|
-
});
|
|
569
|
-
}
|
|
579
|
+
};
|
|
580
|
+
{
|
|
581
|
+
doUpdate();
|
|
570
582
|
}
|
|
571
|
-
};
|
|
583
|
+
}, []);
|
|
572
584
|
const { onLayout } = useOnLayoutSync(
|
|
573
585
|
{
|
|
574
586
|
onLayoutChange,
|
|
@@ -576,23 +588,8 @@ var Container = typedMemo(function Container2({
|
|
|
576
588
|
},
|
|
577
589
|
[itemKey, layoutRenderCount]
|
|
578
590
|
);
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
if (!isNullOrUndefined(itemKey)) {
|
|
582
|
-
const timeout = setTimeout(() => {
|
|
583
|
-
if (!didLayoutRef.current && refLastSize.current) {
|
|
584
|
-
updateItemSize2(itemKey, refLastSize.current);
|
|
585
|
-
didLayoutRef.current = true;
|
|
586
|
-
}
|
|
587
|
-
}, 16);
|
|
588
|
-
return () => {
|
|
589
|
-
clearTimeout(timeout);
|
|
590
|
-
};
|
|
591
|
-
}
|
|
592
|
-
}, [itemKey]);
|
|
593
|
-
}
|
|
594
|
-
const PositionComponent = isSticky ? PositionViewSticky : PositionView3;
|
|
595
|
-
return /* @__PURE__ */ React2__namespace.createElement(
|
|
591
|
+
const PositionComponent = isSticky ? PositionViewSticky : PositionView2;
|
|
592
|
+
return /* @__PURE__ */ React3__namespace.createElement(
|
|
596
593
|
PositionComponent,
|
|
597
594
|
{
|
|
598
595
|
animatedScrollY: isSticky ? animatedScrollY : void 0,
|
|
@@ -605,11 +602,156 @@ var Container = typedMemo(function Container2({
|
|
|
605
602
|
stickyOffset: isSticky ? stickyOffset : void 0,
|
|
606
603
|
style
|
|
607
604
|
},
|
|
608
|
-
/* @__PURE__ */
|
|
605
|
+
/* @__PURE__ */ React3__namespace.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItemInfo && ItemSeparatorComponent && /* @__PURE__ */ React3__namespace.createElement(Separator, { ItemSeparatorComponent, leadingItem: renderedItemInfo.item }))
|
|
609
606
|
);
|
|
610
607
|
});
|
|
611
608
|
|
|
609
|
+
// src/platform/Platform.ts
|
|
610
|
+
var Platform = {
|
|
611
|
+
// Widen the type to avoid unreachable-branch lints in cross-platform code that compares against other OSes
|
|
612
|
+
OS: "web"
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
// src/utils/reordering.ts
|
|
616
|
+
var mapFn = (element) => {
|
|
617
|
+
const indexStr = element.getAttribute("index");
|
|
618
|
+
return [element, indexStr === null ? null : parseInt(indexStr)];
|
|
619
|
+
};
|
|
620
|
+
function sortDOMElements(container) {
|
|
621
|
+
const elements = Array.from(container.children);
|
|
622
|
+
if (elements.length <= 1) return elements;
|
|
623
|
+
const items = elements.map(mapFn);
|
|
624
|
+
items.sort((a, b) => {
|
|
625
|
+
const aKey = a[1];
|
|
626
|
+
const bKey = b[1];
|
|
627
|
+
if (aKey === null) {
|
|
628
|
+
return 1;
|
|
629
|
+
}
|
|
630
|
+
if (bKey === null) {
|
|
631
|
+
return -1;
|
|
632
|
+
}
|
|
633
|
+
return aKey - bKey;
|
|
634
|
+
});
|
|
635
|
+
const targetPositions = /* @__PURE__ */ new Map();
|
|
636
|
+
items.forEach((item, index) => {
|
|
637
|
+
targetPositions.set(item[0], index);
|
|
638
|
+
});
|
|
639
|
+
const currentPositions = elements.map((el) => targetPositions.get(el));
|
|
640
|
+
const lis = findLIS(currentPositions);
|
|
641
|
+
const stableIndices = new Set(lis);
|
|
642
|
+
for (let targetPos = 0; targetPos < items.length; targetPos++) {
|
|
643
|
+
const element = items[targetPos][0];
|
|
644
|
+
const currentPos = elements.indexOf(element);
|
|
645
|
+
if (!stableIndices.has(currentPos)) {
|
|
646
|
+
let nextStableElement = null;
|
|
647
|
+
for (let i = targetPos + 1; i < items.length; i++) {
|
|
648
|
+
const nextEl = items[i][0];
|
|
649
|
+
const nextCurrentPos = elements.indexOf(nextEl);
|
|
650
|
+
if (stableIndices.has(nextCurrentPos)) {
|
|
651
|
+
nextStableElement = nextEl;
|
|
652
|
+
break;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
if (nextStableElement) {
|
|
656
|
+
container.insertBefore(element, nextStableElement);
|
|
657
|
+
} else {
|
|
658
|
+
container.appendChild(element);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
function findLIS(arr) {
|
|
664
|
+
const n = arr.length;
|
|
665
|
+
const tails = [];
|
|
666
|
+
const predecessors = new Array(n).fill(-1);
|
|
667
|
+
const indices = [];
|
|
668
|
+
for (let i = 0; i < n; i++) {
|
|
669
|
+
const num = arr[i];
|
|
670
|
+
let left = 0, right = tails.length;
|
|
671
|
+
while (left < right) {
|
|
672
|
+
const mid = Math.floor((left + right) / 2);
|
|
673
|
+
if (arr[indices[mid]] < num) {
|
|
674
|
+
left = mid + 1;
|
|
675
|
+
} else {
|
|
676
|
+
right = mid;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
if (left === tails.length) {
|
|
680
|
+
tails.push(num);
|
|
681
|
+
indices.push(i);
|
|
682
|
+
} else {
|
|
683
|
+
tails[left] = num;
|
|
684
|
+
indices[left] = i;
|
|
685
|
+
}
|
|
686
|
+
if (left > 0) {
|
|
687
|
+
predecessors[i] = indices[left - 1];
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
const result = [];
|
|
691
|
+
let k = indices[indices.length - 1];
|
|
692
|
+
while (k !== -1) {
|
|
693
|
+
result.unshift(k);
|
|
694
|
+
k = predecessors[k];
|
|
695
|
+
}
|
|
696
|
+
return result;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
// src/hooks/useDOMOrder.ts
|
|
700
|
+
function useDOMOrder(ref) {
|
|
701
|
+
const ctx = useStateContext();
|
|
702
|
+
const debounceRef = React3.useRef(void 0);
|
|
703
|
+
React3.useEffect(() => {
|
|
704
|
+
const unsubscribe = listen$(ctx, "lastPositionUpdate", () => {
|
|
705
|
+
if (debounceRef.current !== void 0) {
|
|
706
|
+
clearTimeout(debounceRef.current);
|
|
707
|
+
}
|
|
708
|
+
debounceRef.current = setTimeout(() => {
|
|
709
|
+
const parent = ref.current;
|
|
710
|
+
if (parent) {
|
|
711
|
+
sortDOMElements(parent);
|
|
712
|
+
}
|
|
713
|
+
debounceRef.current = void 0;
|
|
714
|
+
}, 500);
|
|
715
|
+
});
|
|
716
|
+
return () => {
|
|
717
|
+
unsubscribe();
|
|
718
|
+
if (debounceRef.current !== void 0) {
|
|
719
|
+
clearTimeout(debounceRef.current);
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
}, [ctx]);
|
|
723
|
+
}
|
|
724
|
+
|
|
612
725
|
// src/components/Containers.tsx
|
|
726
|
+
var ContainersInner = typedMemo(function ContainersInner2({ horizontal, numColumns, children }) {
|
|
727
|
+
const ref = React3.useRef(null);
|
|
728
|
+
const ctx = useStateContext();
|
|
729
|
+
const columnWrapperStyle = ctx.columnWrapperStyle;
|
|
730
|
+
const [totalSize, otherAxisSize] = useArr$(["totalSize", "otherAxisSize"]);
|
|
731
|
+
useDOMOrder(ref);
|
|
732
|
+
const style = horizontal ? { minHeight: otherAxisSize, width: totalSize } : { height: totalSize, minWidth: otherAxisSize };
|
|
733
|
+
if (columnWrapperStyle && numColumns > 1) {
|
|
734
|
+
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
735
|
+
const gapX = columnGap || gap || 0;
|
|
736
|
+
const gapY = rowGap || gap || 0;
|
|
737
|
+
if (horizontal) {
|
|
738
|
+
if (gapY) {
|
|
739
|
+
style.marginTop = style.marginBottom = -gapY / 2;
|
|
740
|
+
}
|
|
741
|
+
if (gapX) {
|
|
742
|
+
style.marginRight = -gapX;
|
|
743
|
+
}
|
|
744
|
+
} else {
|
|
745
|
+
if (gapX) {
|
|
746
|
+
style.marginLeft = style.marginRight = -gapX;
|
|
747
|
+
}
|
|
748
|
+
if (gapY) {
|
|
749
|
+
style.marginBottom = -gapY;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
return /* @__PURE__ */ React3__namespace.createElement("div", { ref, style }, children);
|
|
754
|
+
});
|
|
613
755
|
var Containers = typedMemo(function Containers2({
|
|
614
756
|
horizontal,
|
|
615
757
|
recycleItems,
|
|
@@ -618,23 +760,11 @@ var Containers = typedMemo(function Containers2({
|
|
|
618
760
|
updateItemSize: updateItemSize2,
|
|
619
761
|
getRenderedItem: getRenderedItem2
|
|
620
762
|
}) {
|
|
621
|
-
const ctx = useStateContext();
|
|
622
|
-
const columnWrapperStyle = ctx.columnWrapperStyle;
|
|
623
763
|
const [numContainers, numColumns] = useArr$(["numContainersPooled", "numColumns"]);
|
|
624
|
-
const animSize = useValue$("totalSize", {
|
|
625
|
-
// Use a microtask if increasing the size significantly, otherwise use a timeout
|
|
626
|
-
// If this is the initial scroll, we don't want to delay because we want to update the size immediately
|
|
627
|
-
delay: (value, prevValue) => {
|
|
628
|
-
var _a;
|
|
629
|
-
return !((_a = ctx.internalState) == null ? void 0 : _a.initialScroll) ? !prevValue || value - prevValue > 20 ? 0 : 200 : void 0;
|
|
630
|
-
}
|
|
631
|
-
});
|
|
632
|
-
const animOpacity = waitForInitialLayout && !IsNewArchitecture ? useValue$("containersDidLayout", { getValue: (value) => value ? 1 : 0 }) : void 0;
|
|
633
|
-
const otherAxisSize = useValue$("otherAxisSize", { delay: 0 });
|
|
634
764
|
const containers = [];
|
|
635
765
|
for (let i = 0; i < numContainers; i++) {
|
|
636
766
|
containers.push(
|
|
637
|
-
/* @__PURE__ */
|
|
767
|
+
/* @__PURE__ */ React3__namespace.createElement(
|
|
638
768
|
Container,
|
|
639
769
|
{
|
|
640
770
|
getRenderedItem: getRenderedItem2,
|
|
@@ -648,86 +778,268 @@ var Containers = typedMemo(function Containers2({
|
|
|
648
778
|
)
|
|
649
779
|
);
|
|
650
780
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
781
|
+
return /* @__PURE__ */ React3__namespace.createElement(ContainersInner, { horizontal, numColumns, waitForInitialLayout }, containers);
|
|
782
|
+
});
|
|
783
|
+
function DevNumbers() {
|
|
784
|
+
return IS_DEV && React3__namespace.memo(function DevNumbers2() {
|
|
785
|
+
return Array.from({ length: 100 }).map((_, index) => /* @__PURE__ */ React3__namespace.createElement(
|
|
786
|
+
"div",
|
|
787
|
+
{
|
|
788
|
+
key: index,
|
|
789
|
+
style: {
|
|
790
|
+
height: 100,
|
|
791
|
+
pointerEvents: "none",
|
|
792
|
+
position: "absolute",
|
|
793
|
+
top: index * 100,
|
|
794
|
+
width: "100%"
|
|
795
|
+
}
|
|
796
|
+
},
|
|
797
|
+
/* @__PURE__ */ React3__namespace.createElement("div", { style: { color: "red" } }, index * 100)
|
|
798
|
+
));
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
// src/platform/StyleSheet.tsx
|
|
803
|
+
function flattenStyles(styles) {
|
|
804
|
+
if (Array.isArray(styles)) {
|
|
805
|
+
return Object.assign({}, ...styles.filter(Boolean));
|
|
806
|
+
}
|
|
807
|
+
return styles;
|
|
808
|
+
}
|
|
809
|
+
var StyleSheet = {
|
|
810
|
+
create: (styles) => styles,
|
|
811
|
+
flatten: (style) => flattenStyles(style)
|
|
812
|
+
};
|
|
813
|
+
|
|
814
|
+
// src/components/ListComponentScrollView.tsx
|
|
815
|
+
var ListComponentScrollView = React3.forwardRef(function ListComponentScrollView2({
|
|
816
|
+
children,
|
|
817
|
+
style,
|
|
818
|
+
contentContainerStyle,
|
|
819
|
+
horizontal = false,
|
|
820
|
+
contentOffset,
|
|
821
|
+
maintainVisibleContentPosition,
|
|
822
|
+
onScroll: onScroll2,
|
|
823
|
+
onMomentumScrollEnd,
|
|
824
|
+
showsHorizontalScrollIndicator = true,
|
|
825
|
+
showsVerticalScrollIndicator = true,
|
|
826
|
+
refreshControl,
|
|
827
|
+
onLayout,
|
|
828
|
+
...props
|
|
829
|
+
}, ref) {
|
|
830
|
+
const scrollRef = React3.useRef(null);
|
|
831
|
+
const contentRef = React3.useRef(null);
|
|
832
|
+
const momentumTimeout = React3.useRef(null);
|
|
833
|
+
React3.useImperativeHandle(ref, () => {
|
|
834
|
+
const api = {
|
|
835
|
+
getBoundingClientRect: () => {
|
|
836
|
+
var _a3;
|
|
837
|
+
return (_a3 = scrollRef.current) == null ? void 0 : _a3.getBoundingClientRect();
|
|
838
|
+
},
|
|
839
|
+
getScrollableNode: () => scrollRef.current,
|
|
840
|
+
getScrollResponder: () => scrollRef.current,
|
|
841
|
+
scrollBy: (x, y) => {
|
|
842
|
+
const el = scrollRef.current;
|
|
843
|
+
if (!el) return;
|
|
844
|
+
el.scrollBy(x, y);
|
|
845
|
+
},
|
|
846
|
+
scrollTo: (options) => {
|
|
847
|
+
const el = scrollRef.current;
|
|
848
|
+
if (!el) return;
|
|
849
|
+
const { x = 0, y = 0, animated = true } = options;
|
|
850
|
+
el.scrollTo({ behavior: animated ? "smooth" : "auto", left: x, top: y });
|
|
851
|
+
},
|
|
852
|
+
scrollToEnd: (options = {}) => {
|
|
853
|
+
const el = scrollRef.current;
|
|
854
|
+
if (!el) return;
|
|
855
|
+
const { animated = true } = options;
|
|
856
|
+
if (horizontal) {
|
|
857
|
+
el.scrollTo({ behavior: animated ? "smooth" : "auto", left: el.scrollWidth });
|
|
858
|
+
} else {
|
|
859
|
+
el.scrollTo({ behavior: animated ? "smooth" : "auto", top: el.scrollHeight });
|
|
860
|
+
}
|
|
861
|
+
},
|
|
862
|
+
scrollToOffset: (params) => {
|
|
863
|
+
const el = scrollRef.current;
|
|
864
|
+
if (!el) return;
|
|
865
|
+
const { offset, animated = true } = params;
|
|
866
|
+
if (horizontal) {
|
|
867
|
+
el.scrollTo({ behavior: animated ? "smooth" : "auto", left: offset });
|
|
868
|
+
} else {
|
|
869
|
+
el.scrollTo({ behavior: animated ? "smooth" : "auto", top: offset });
|
|
870
|
+
}
|
|
659
871
|
}
|
|
660
|
-
|
|
661
|
-
|
|
872
|
+
};
|
|
873
|
+
return api;
|
|
874
|
+
}, [horizontal]);
|
|
875
|
+
const handleScroll = React3.useCallback(
|
|
876
|
+
(event) => {
|
|
877
|
+
if (!onScroll2 || !(event == null ? void 0 : event.target)) {
|
|
878
|
+
return;
|
|
662
879
|
}
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
880
|
+
const target = event.target;
|
|
881
|
+
const scrollEvent = {
|
|
882
|
+
nativeEvent: {
|
|
883
|
+
contentOffset: {
|
|
884
|
+
x: target.scrollLeft,
|
|
885
|
+
y: target.scrollTop
|
|
886
|
+
},
|
|
887
|
+
contentSize: {
|
|
888
|
+
height: target.scrollHeight,
|
|
889
|
+
width: target.scrollWidth
|
|
890
|
+
},
|
|
891
|
+
layoutMeasurement: {
|
|
892
|
+
height: target.clientHeight,
|
|
893
|
+
width: target.clientWidth
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
};
|
|
897
|
+
onScroll2(scrollEvent);
|
|
898
|
+
if (onMomentumScrollEnd) {
|
|
899
|
+
if (momentumTimeout.current != null) clearTimeout(momentumTimeout.current);
|
|
900
|
+
momentumTimeout.current = setTimeout(() => {
|
|
901
|
+
onMomentumScrollEnd({
|
|
902
|
+
nativeEvent: {
|
|
903
|
+
contentOffset: scrollEvent.nativeEvent.contentOffset
|
|
904
|
+
}
|
|
905
|
+
});
|
|
906
|
+
}, 100);
|
|
666
907
|
}
|
|
667
|
-
|
|
668
|
-
|
|
908
|
+
},
|
|
909
|
+
[onScroll2, onMomentumScrollEnd]
|
|
910
|
+
);
|
|
911
|
+
React3.useLayoutEffect(() => {
|
|
912
|
+
const element = scrollRef.current;
|
|
913
|
+
if (!element) return;
|
|
914
|
+
element.addEventListener("scroll", handleScroll);
|
|
915
|
+
return () => {
|
|
916
|
+
element.removeEventListener("scroll", handleScroll);
|
|
917
|
+
};
|
|
918
|
+
}, [handleScroll]);
|
|
919
|
+
React3.useEffect(() => {
|
|
920
|
+
const doScroll = () => {
|
|
921
|
+
if (contentOffset && scrollRef.current) {
|
|
922
|
+
scrollRef.current.scrollLeft = contentOffset.x || 0;
|
|
923
|
+
scrollRef.current.scrollTop = contentOffset.y || 0;
|
|
669
924
|
}
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
|
|
925
|
+
};
|
|
926
|
+
doScroll();
|
|
927
|
+
requestAnimationFrame(doScroll);
|
|
928
|
+
}, [contentOffset == null ? void 0 : contentOffset.x, contentOffset == null ? void 0 : contentOffset.y]);
|
|
929
|
+
React3.useLayoutEffect(() => {
|
|
930
|
+
if (!onLayout || !scrollRef.current) return;
|
|
931
|
+
const element = scrollRef.current;
|
|
932
|
+
const fireLayout = () => {
|
|
933
|
+
const rect = element.getBoundingClientRect();
|
|
934
|
+
onLayout({
|
|
935
|
+
nativeEvent: {
|
|
936
|
+
layout: {
|
|
937
|
+
height: rect.height,
|
|
938
|
+
width: rect.width,
|
|
939
|
+
x: rect.left,
|
|
940
|
+
y: rect.top
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
});
|
|
944
|
+
};
|
|
945
|
+
fireLayout();
|
|
946
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
947
|
+
fireLayout();
|
|
948
|
+
});
|
|
949
|
+
resizeObserver.observe(element);
|
|
950
|
+
return () => resizeObserver.disconnect();
|
|
951
|
+
}, [onLayout]);
|
|
952
|
+
const scrollViewStyle = {
|
|
953
|
+
overflow: "auto",
|
|
954
|
+
overflowX: horizontal ? "auto" : showsHorizontalScrollIndicator ? "auto" : "hidden",
|
|
955
|
+
overflowY: horizontal ? showsVerticalScrollIndicator ? "auto" : "hidden" : "auto",
|
|
956
|
+
position: "relative",
|
|
957
|
+
// Ensure proper positioning context
|
|
958
|
+
WebkitOverflowScrolling: "touch",
|
|
959
|
+
// iOS momentum scrolling
|
|
960
|
+
...StyleSheet.flatten(style)
|
|
961
|
+
};
|
|
962
|
+
const contentStyle = {
|
|
963
|
+
display: horizontal ? "flex" : "block",
|
|
964
|
+
flexDirection: horizontal ? "row" : void 0,
|
|
965
|
+
minHeight: horizontal ? void 0 : "100%",
|
|
966
|
+
minWidth: horizontal ? "100%" : void 0,
|
|
967
|
+
...StyleSheet.flatten(contentContainerStyle)
|
|
968
|
+
};
|
|
969
|
+
return /* @__PURE__ */ React3__namespace.createElement("div", { ref: scrollRef, style: scrollViewStyle, ...props }, refreshControl, /* @__PURE__ */ React3__namespace.createElement("div", { ref: contentRef, style: contentStyle }, children));
|
|
673
970
|
});
|
|
674
|
-
|
|
675
|
-
const
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
const scrollOffset = (scrollAdjust || 0) + (scrollAdjustUserOffset || 0) + bias;
|
|
683
|
-
return /* @__PURE__ */ React2__namespace.createElement(
|
|
684
|
-
reactNative.View,
|
|
971
|
+
function Padding() {
|
|
972
|
+
const [paddingTop] = useArr$(["alignItemsPaddingTop"]);
|
|
973
|
+
return /* @__PURE__ */ React3__namespace.createElement("div", { style: { paddingTop } });
|
|
974
|
+
}
|
|
975
|
+
function PaddingDevMode() {
|
|
976
|
+
const [paddingTop] = useArr$(["alignItemsPaddingTop"]);
|
|
977
|
+
return /* @__PURE__ */ React3__namespace.createElement(React3__namespace.Fragment, null, /* @__PURE__ */ React3__namespace.createElement("div", { style: { paddingTop } }), /* @__PURE__ */ React3__namespace.createElement(
|
|
978
|
+
"div",
|
|
685
979
|
{
|
|
686
980
|
style: {
|
|
687
|
-
|
|
981
|
+
backgroundColor: "green",
|
|
982
|
+
height: paddingTop,
|
|
688
983
|
left: 0,
|
|
689
984
|
position: "absolute",
|
|
690
|
-
|
|
691
|
-
|
|
985
|
+
right: 0,
|
|
986
|
+
top: 0
|
|
692
987
|
}
|
|
693
988
|
}
|
|
694
|
-
);
|
|
989
|
+
));
|
|
990
|
+
}
|
|
991
|
+
function useValueListener$(key, callback) {
|
|
992
|
+
const ctx = useStateContext();
|
|
993
|
+
React3.useLayoutEffect(() => {
|
|
994
|
+
listen$(ctx, key, (value) => {
|
|
995
|
+
callback(value);
|
|
996
|
+
});
|
|
997
|
+
}, []);
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
// src/components/ScrollAdjust.tsx
|
|
1001
|
+
function ScrollAdjust() {
|
|
1002
|
+
const ctx = useStateContext();
|
|
1003
|
+
const lastScrollOffsetRef = React3__namespace.useRef(0);
|
|
1004
|
+
const callback = React3__namespace.useCallback(() => {
|
|
1005
|
+
var _a3;
|
|
1006
|
+
const scrollAdjust = peek$(ctx, "scrollAdjust");
|
|
1007
|
+
const scrollAdjustUserOffset = peek$(ctx, "scrollAdjustUserOffset");
|
|
1008
|
+
const scrollOffset = (scrollAdjust || 0) + (scrollAdjustUserOffset || 0);
|
|
1009
|
+
const scrollView = (_a3 = ctx.internalState) == null ? void 0 : _a3.refScroller.current;
|
|
1010
|
+
if (scrollView && scrollOffset !== lastScrollOffsetRef.current) {
|
|
1011
|
+
const scrollDelta = scrollOffset - lastScrollOffsetRef.current;
|
|
1012
|
+
if (scrollDelta !== 0) {
|
|
1013
|
+
scrollView.scrollBy(0, scrollDelta);
|
|
1014
|
+
console.log("ScrollAdjust (web scrollBy)", scrollDelta, "total offset:", scrollOffset);
|
|
1015
|
+
}
|
|
1016
|
+
lastScrollOffsetRef.current = scrollOffset;
|
|
1017
|
+
}
|
|
1018
|
+
}, []);
|
|
1019
|
+
useValueListener$("scrollAdjust", callback);
|
|
1020
|
+
useValueListener$("scrollAdjustUserOffset", callback);
|
|
1021
|
+
return null;
|
|
695
1022
|
}
|
|
696
1023
|
function SnapWrapper({ ScrollComponent, ...props }) {
|
|
697
1024
|
const [snapToOffsets] = useArr$(["snapToOffsets"]);
|
|
698
|
-
return /* @__PURE__ */
|
|
1025
|
+
return /* @__PURE__ */ React3__namespace.createElement(ScrollComponent, { ...props, snapToOffsets });
|
|
699
1026
|
}
|
|
1027
|
+
var LayoutView = ({ onLayoutChange, refView, children, ...rest }) => {
|
|
1028
|
+
const ref = refView != null ? refView : React3.useRef();
|
|
1029
|
+
useOnLayoutSync({ onLayoutChange, ref });
|
|
1030
|
+
return /* @__PURE__ */ React3__namespace.createElement("div", { ...rest, ref }, children);
|
|
1031
|
+
};
|
|
700
1032
|
|
|
701
1033
|
// src/components/ListComponent.tsx
|
|
702
1034
|
var getComponent = (Component) => {
|
|
703
|
-
if (
|
|
1035
|
+
if (React3__namespace.isValidElement(Component)) {
|
|
704
1036
|
return Component;
|
|
705
1037
|
}
|
|
706
1038
|
if (Component) {
|
|
707
|
-
return /* @__PURE__ */
|
|
1039
|
+
return /* @__PURE__ */ React3__namespace.createElement(Component, null);
|
|
708
1040
|
}
|
|
709
1041
|
return null;
|
|
710
1042
|
};
|
|
711
|
-
var Padding = () => {
|
|
712
|
-
const animPaddingTop = useValue$("alignItemsPaddingTop", { delay: 0 });
|
|
713
|
-
return /* @__PURE__ */ React2__namespace.createElement(reactNative.Animated.View, { style: { paddingTop: animPaddingTop } });
|
|
714
|
-
};
|
|
715
|
-
var PaddingDevMode = () => {
|
|
716
|
-
const animPaddingTop = useValue$("alignItemsPaddingTop", { delay: 0 });
|
|
717
|
-
return /* @__PURE__ */ React2__namespace.createElement(React2__namespace.Fragment, null, /* @__PURE__ */ React2__namespace.createElement(reactNative.Animated.View, { style: { paddingTop: animPaddingTop } }), /* @__PURE__ */ React2__namespace.createElement(
|
|
718
|
-
reactNative.Animated.View,
|
|
719
|
-
{
|
|
720
|
-
style: {
|
|
721
|
-
backgroundColor: "green",
|
|
722
|
-
height: animPaddingTop,
|
|
723
|
-
left: 0,
|
|
724
|
-
position: "absolute",
|
|
725
|
-
right: 0,
|
|
726
|
-
top: 0
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
));
|
|
730
|
-
};
|
|
731
1043
|
var ListComponent = typedMemo(function ListComponent2({
|
|
732
1044
|
canRender,
|
|
733
1045
|
style,
|
|
@@ -757,11 +1069,11 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
757
1069
|
...rest
|
|
758
1070
|
}) {
|
|
759
1071
|
const ctx = useStateContext();
|
|
760
|
-
const ScrollComponent = renderScrollComponent ?
|
|
761
|
-
() =>
|
|
1072
|
+
const ScrollComponent = renderScrollComponent ? React3.useMemo(
|
|
1073
|
+
() => React3__namespace.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
|
|
762
1074
|
[renderScrollComponent]
|
|
763
|
-
) :
|
|
764
|
-
|
|
1075
|
+
) : ListComponentScrollView;
|
|
1076
|
+
React3__namespace.useEffect(() => {
|
|
765
1077
|
if (canRender) {
|
|
766
1078
|
setTimeout(() => {
|
|
767
1079
|
scrollAdjustHandler.setMounted();
|
|
@@ -769,7 +1081,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
769
1081
|
}
|
|
770
1082
|
}, [canRender]);
|
|
771
1083
|
const SnapOrScroll = snapToIndices ? SnapWrapper : ScrollComponent;
|
|
772
|
-
return /* @__PURE__ */
|
|
1084
|
+
return /* @__PURE__ */ React3__namespace.createElement(
|
|
773
1085
|
SnapOrScroll,
|
|
774
1086
|
{
|
|
775
1087
|
...rest,
|
|
@@ -788,11 +1100,11 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
788
1100
|
ScrollComponent: snapToIndices ? ScrollComponent : void 0,
|
|
789
1101
|
style
|
|
790
1102
|
},
|
|
791
|
-
maintainVisibleContentPosition && /* @__PURE__ */
|
|
792
|
-
ENABLE_DEVMODE ? /* @__PURE__ */
|
|
793
|
-
ListHeaderComponent && /* @__PURE__ */
|
|
1103
|
+
maintainVisibleContentPosition && /* @__PURE__ */ React3__namespace.createElement(ScrollAdjust, null),
|
|
1104
|
+
ENABLE_DEVMODE ? /* @__PURE__ */ React3__namespace.createElement(PaddingDevMode, null) : /* @__PURE__ */ React3__namespace.createElement(Padding, null),
|
|
1105
|
+
ListHeaderComponent && /* @__PURE__ */ React3__namespace.createElement(LayoutView, { onLayoutChange: onLayoutHeader, style: ListHeaderComponentStyle }, getComponent(ListHeaderComponent)),
|
|
794
1106
|
ListEmptyComponent && getComponent(ListEmptyComponent),
|
|
795
|
-
canRender && !ListEmptyComponent && /* @__PURE__ */
|
|
1107
|
+
canRender && !ListEmptyComponent && /* @__PURE__ */ React3__namespace.createElement(
|
|
796
1108
|
Containers,
|
|
797
1109
|
{
|
|
798
1110
|
getRenderedItem: getRenderedItem2,
|
|
@@ -803,7 +1115,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
803
1115
|
waitForInitialLayout
|
|
804
1116
|
}
|
|
805
1117
|
),
|
|
806
|
-
ListFooterComponent && /* @__PURE__ */
|
|
1118
|
+
ListFooterComponent && /* @__PURE__ */ React3__namespace.createElement(
|
|
807
1119
|
LayoutView,
|
|
808
1120
|
{
|
|
809
1121
|
onLayoutChange: (layout) => {
|
|
@@ -814,25 +1126,9 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
814
1126
|
},
|
|
815
1127
|
getComponent(ListFooterComponent)
|
|
816
1128
|
),
|
|
817
|
-
|
|
1129
|
+
IS_DEV && ENABLE_DEVMODE && /* @__PURE__ */ React3__namespace.createElement(DevNumbers, null)
|
|
818
1130
|
);
|
|
819
1131
|
});
|
|
820
|
-
var DevNumbers = __DEV__ && React2__namespace.memo(function DevNumbers2() {
|
|
821
|
-
return Array.from({ length: 100 }).map((_, index) => /* @__PURE__ */ React2__namespace.createElement(
|
|
822
|
-
reactNative.View,
|
|
823
|
-
{
|
|
824
|
-
key: index,
|
|
825
|
-
style: {
|
|
826
|
-
height: 100,
|
|
827
|
-
pointerEvents: "none",
|
|
828
|
-
position: "absolute",
|
|
829
|
-
top: index * 100,
|
|
830
|
-
width: "100%"
|
|
831
|
-
}
|
|
832
|
-
},
|
|
833
|
-
/* @__PURE__ */ React2__namespace.createElement(reactNative.Text, { style: { color: "red" } }, index * 100)
|
|
834
|
-
));
|
|
835
|
-
});
|
|
836
1132
|
|
|
837
1133
|
// src/utils/getId.ts
|
|
838
1134
|
function getId(state, index) {
|
|
@@ -865,7 +1161,7 @@ function calculateOffsetForIndex(ctx, state, index) {
|
|
|
865
1161
|
|
|
866
1162
|
// src/utils/getItemSize.ts
|
|
867
1163
|
function getItemSize(state, key, index, data, useAverageSize) {
|
|
868
|
-
var
|
|
1164
|
+
var _a3, _b;
|
|
869
1165
|
const {
|
|
870
1166
|
sizesKnown,
|
|
871
1167
|
sizes,
|
|
@@ -878,7 +1174,7 @@ function getItemSize(state, key, index, data, useAverageSize) {
|
|
|
878
1174
|
return sizeKnown;
|
|
879
1175
|
}
|
|
880
1176
|
let size;
|
|
881
|
-
const itemType = getItemType ? (
|
|
1177
|
+
const itemType = getItemType ? (_a3 = getItemType(data, index)) != null ? _a3 : "" : "";
|
|
882
1178
|
if (getFixedItemSize) {
|
|
883
1179
|
size = getFixedItemSize(index, data, itemType);
|
|
884
1180
|
if (size !== void 0) {
|
|
@@ -927,7 +1223,7 @@ var finishScrollTo = (state) => {
|
|
|
927
1223
|
|
|
928
1224
|
// src/core/scrollTo.ts
|
|
929
1225
|
function scrollTo(state, params = {}) {
|
|
930
|
-
var
|
|
1226
|
+
var _a3;
|
|
931
1227
|
const { animated, noScrollingTo, isInitialScroll } = params;
|
|
932
1228
|
const {
|
|
933
1229
|
refScroller,
|
|
@@ -939,8 +1235,8 @@ function scrollTo(state, params = {}) {
|
|
|
939
1235
|
state.scrollingTo = params;
|
|
940
1236
|
}
|
|
941
1237
|
state.scrollPending = offset;
|
|
942
|
-
if (!params.isInitialScroll ||
|
|
943
|
-
(
|
|
1238
|
+
if (!params.isInitialScroll || Platform.OS === "android") {
|
|
1239
|
+
(_a3 = refScroller.current) == null ? void 0 : _a3.scrollTo({
|
|
944
1240
|
animated: !!animated,
|
|
945
1241
|
x: horizontal ? offset : 0,
|
|
946
1242
|
y: horizontal ? 0 : offset
|
|
@@ -960,14 +1256,8 @@ function scrollTo(state, params = {}) {
|
|
|
960
1256
|
// src/utils/requestAdjust.ts
|
|
961
1257
|
function requestAdjust(ctx, state, positionDiff, dataChanged) {
|
|
962
1258
|
if (Math.abs(positionDiff) > 0.1) {
|
|
963
|
-
const needsScrollWorkaround = reactNative.Platform.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff;
|
|
964
1259
|
const doit = () => {
|
|
965
|
-
|
|
966
|
-
scrollTo(state, {
|
|
967
|
-
noScrollingTo: true,
|
|
968
|
-
offset: state.scroll
|
|
969
|
-
});
|
|
970
|
-
} else {
|
|
1260
|
+
{
|
|
971
1261
|
state.scrollAdjustHandler.requestAdjust(positionDiff);
|
|
972
1262
|
}
|
|
973
1263
|
};
|
|
@@ -992,7 +1282,7 @@ function requestAdjust(ctx, state, positionDiff, dataChanged) {
|
|
|
992
1282
|
() => {
|
|
993
1283
|
state.ignoreScrollFromMVCP = void 0;
|
|
994
1284
|
},
|
|
995
|
-
|
|
1285
|
+
100
|
|
996
1286
|
);
|
|
997
1287
|
} else {
|
|
998
1288
|
requestAnimationFrame(doit);
|
|
@@ -1061,14 +1351,14 @@ function prepareMVCP(ctx, state, dataChanged) {
|
|
|
1061
1351
|
}
|
|
1062
1352
|
}
|
|
1063
1353
|
if (positionDiff !== void 0 && Math.abs(positionDiff) > 0.1) {
|
|
1064
|
-
requestAdjust(ctx, state, positionDiff
|
|
1354
|
+
requestAdjust(ctx, state, positionDiff);
|
|
1065
1355
|
}
|
|
1066
1356
|
};
|
|
1067
1357
|
}
|
|
1068
1358
|
|
|
1069
1359
|
// src/core/prepareColumnStartState.ts
|
|
1070
1360
|
function prepareColumnStartState(ctx, state, startIndex, useAverageSize) {
|
|
1071
|
-
var
|
|
1361
|
+
var _a3;
|
|
1072
1362
|
const numColumns = peek$(ctx, "numColumns");
|
|
1073
1363
|
let rowStartIndex = startIndex;
|
|
1074
1364
|
const columnAtStart = state.columns.get(state.idCache[startIndex]);
|
|
@@ -1081,7 +1371,7 @@ function prepareColumnStartState(ctx, state, startIndex, useAverageSize) {
|
|
|
1081
1371
|
if (rowStartIndex > 0) {
|
|
1082
1372
|
const prevIndex = rowStartIndex - 1;
|
|
1083
1373
|
const prevId = state.idCache[prevIndex];
|
|
1084
|
-
const prevPosition = (
|
|
1374
|
+
const prevPosition = (_a3 = state.positions.get(prevId)) != null ? _a3 : 0;
|
|
1085
1375
|
const prevRowStart = findRowStartIndex(state, numColumns, prevIndex);
|
|
1086
1376
|
const prevRowHeight = calculateRowMaxSize(state, prevRowStart, prevIndex, useAverageSize);
|
|
1087
1377
|
currentRowTop = prevPosition + prevRowHeight;
|
|
@@ -1222,7 +1512,7 @@ function updateSnapToOffsets(ctx, state) {
|
|
|
1222
1512
|
|
|
1223
1513
|
// src/core/updateItemPositions.ts
|
|
1224
1514
|
function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottomBuffered } = { scrollBottomBuffered: -1, startIndex: 0 }) {
|
|
1225
|
-
var
|
|
1515
|
+
var _a3, _b, _c, _d;
|
|
1226
1516
|
const {
|
|
1227
1517
|
columns,
|
|
1228
1518
|
indexByKey,
|
|
@@ -1235,7 +1525,7 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
|
|
|
1235
1525
|
const dataLength = data.length;
|
|
1236
1526
|
const numColumns = peek$(ctx, "numColumns");
|
|
1237
1527
|
const hasColumns = numColumns > 1;
|
|
1238
|
-
const indexByKeyForChecking =
|
|
1528
|
+
const indexByKeyForChecking = IS_DEV ? /* @__PURE__ */ new Map() : void 0;
|
|
1239
1529
|
const maxVisibleArea = scrollBottomBuffered + 1e3;
|
|
1240
1530
|
const useAverageSize = enableAverages && !getEstimatedItemSize;
|
|
1241
1531
|
let currentRowTop = 0;
|
|
@@ -1254,7 +1544,7 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
|
|
|
1254
1544
|
} else if (startIndex < dataLength) {
|
|
1255
1545
|
const prevIndex = startIndex - 1;
|
|
1256
1546
|
const prevId = getId(state, prevIndex);
|
|
1257
|
-
const prevPosition = (
|
|
1547
|
+
const prevPosition = (_a3 = positions.get(prevId)) != null ? _a3 : 0;
|
|
1258
1548
|
const prevSize = (_b = sizesKnown.get(prevId)) != null ? _b : getItemSize(state, prevId, prevIndex, data[prevIndex], useAverageSize);
|
|
1259
1549
|
currentRowTop = prevPosition + prevSize;
|
|
1260
1550
|
}
|
|
@@ -1273,7 +1563,7 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
|
|
|
1273
1563
|
}
|
|
1274
1564
|
const id = (_c = idCache[i]) != null ? _c : getId(state, i);
|
|
1275
1565
|
const size = (_d = sizesKnown.get(id)) != null ? _d : getItemSize(state, id, i, data[i], useAverageSize);
|
|
1276
|
-
if (
|
|
1566
|
+
if (IS_DEV && needsIndexByKey) {
|
|
1277
1567
|
if (indexByKeyForChecking.has(id)) {
|
|
1278
1568
|
console.error(
|
|
1279
1569
|
`[legend-list] Error: Detected overlapping key (${id}) which causes missing items and gaps and other terrrible things. Check that keyExtractor returns unique values.`
|
|
@@ -1506,7 +1796,6 @@ function maybeUpdateViewabilityCallback(ctx, configId, containerId, viewToken) {
|
|
|
1506
1796
|
const cb = ctx.mapViewabilityCallbacks.get(key);
|
|
1507
1797
|
cb == null ? void 0 : cb(viewToken);
|
|
1508
1798
|
}
|
|
1509
|
-
var batchedUpdates = reactNative.unstable_batchedUpdates || ((callback) => callback());
|
|
1510
1799
|
|
|
1511
1800
|
// src/utils/checkAllSizesKnown.ts
|
|
1512
1801
|
function isNullOrUndefined2(value) {
|
|
@@ -1619,7 +1908,7 @@ function findAvailableContainers(ctx, state, numNeeded, startBuffered, endBuffer
|
|
|
1619
1908
|
for (let i = 0; i < stillNeeded; i++) {
|
|
1620
1909
|
result.push(numContainers + i);
|
|
1621
1910
|
}
|
|
1622
|
-
if (
|
|
1911
|
+
if (IS_DEV && numContainers + stillNeeded > peek$(ctx, "numContainersPooled")) {
|
|
1623
1912
|
console.warn(
|
|
1624
1913
|
"[legend-list] No unused container available, so creating one on demand. This can be a minor performance issue and is likely caused by the estimatedItemSize being too large. Consider decreasing estimatedItemSize or increasing initialContainerPoolRatio.",
|
|
1625
1914
|
{
|
|
@@ -1707,28 +1996,44 @@ function scrollToIndex(ctx, state, { index, viewOffset = 0, animated = true, vie
|
|
|
1707
1996
|
}
|
|
1708
1997
|
|
|
1709
1998
|
// src/utils/checkThreshold.ts
|
|
1710
|
-
var
|
|
1711
|
-
|
|
1712
|
-
const
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
if (
|
|
1999
|
+
var HYSTERESIS_MULTIPLIER = 1.3;
|
|
2000
|
+
var checkThreshold = (distance, atThreshold, threshold, wasReached, snapshot, context, onReached, setSnapshot) => {
|
|
2001
|
+
const absDistance = Math.abs(distance);
|
|
2002
|
+
const within = atThreshold || threshold > 0 && absDistance <= threshold;
|
|
2003
|
+
const updateSnapshot = () => {
|
|
2004
|
+
setSnapshot == null ? void 0 : setSnapshot({
|
|
2005
|
+
atThreshold,
|
|
2006
|
+
contentSize: context.contentSize,
|
|
2007
|
+
dataLength: context.dataLength,
|
|
2008
|
+
scrollPosition: context.scrollPosition
|
|
2009
|
+
});
|
|
2010
|
+
};
|
|
2011
|
+
if (!wasReached) {
|
|
2012
|
+
if (!within) {
|
|
1724
2013
|
return false;
|
|
1725
2014
|
}
|
|
2015
|
+
onReached == null ? void 0 : onReached(distance);
|
|
2016
|
+
updateSnapshot();
|
|
2017
|
+
return true;
|
|
2018
|
+
}
|
|
2019
|
+
const reset = !atThreshold && threshold > 0 && absDistance >= threshold * HYSTERESIS_MULTIPLIER || !atThreshold && threshold <= 0 && absDistance > 0;
|
|
2020
|
+
if (reset) {
|
|
2021
|
+
setSnapshot == null ? void 0 : setSnapshot(void 0);
|
|
2022
|
+
return false;
|
|
2023
|
+
}
|
|
2024
|
+
if (within) {
|
|
2025
|
+
const changed = !snapshot || snapshot.atThreshold !== atThreshold || snapshot.contentSize !== context.contentSize || snapshot.dataLength !== context.dataLength;
|
|
2026
|
+
if (changed) {
|
|
2027
|
+
onReached == null ? void 0 : onReached(distance);
|
|
2028
|
+
updateSnapshot();
|
|
2029
|
+
}
|
|
1726
2030
|
}
|
|
1727
|
-
return
|
|
2031
|
+
return true;
|
|
1728
2032
|
};
|
|
1729
2033
|
|
|
1730
2034
|
// src/utils/checkAtBottom.ts
|
|
1731
2035
|
function checkAtBottom(ctx, state) {
|
|
2036
|
+
var _a3;
|
|
1732
2037
|
if (!state) {
|
|
1733
2038
|
return;
|
|
1734
2039
|
}
|
|
@@ -1749,13 +2054,18 @@ function checkAtBottom(ctx, state) {
|
|
|
1749
2054
|
isContentLess,
|
|
1750
2055
|
onEndReachedThreshold * scrollLength,
|
|
1751
2056
|
state.isEndReached,
|
|
1752
|
-
state.
|
|
2057
|
+
state.endReachedSnapshot,
|
|
2058
|
+
{
|
|
2059
|
+
scrollPosition: scroll,
|
|
2060
|
+
contentSize,
|
|
2061
|
+
dataLength: (_a3 = state.props.data) == null ? void 0 : _a3.length
|
|
2062
|
+
},
|
|
1753
2063
|
(distance) => {
|
|
1754
|
-
var
|
|
1755
|
-
return (_b = (
|
|
2064
|
+
var _a4, _b;
|
|
2065
|
+
return (_b = (_a4 = state.props).onEndReached) == null ? void 0 : _b.call(_a4, { distanceFromEnd: distance });
|
|
1756
2066
|
},
|
|
1757
|
-
(
|
|
1758
|
-
state.
|
|
2067
|
+
(snapshot) => {
|
|
2068
|
+
state.endReachedSnapshot = snapshot;
|
|
1759
2069
|
}
|
|
1760
2070
|
);
|
|
1761
2071
|
}
|
|
@@ -1776,30 +2086,19 @@ function setDidLayout(ctx, state) {
|
|
|
1776
2086
|
onLoad({ elapsedTimeInMs: Date.now() - loadStartTime });
|
|
1777
2087
|
}
|
|
1778
2088
|
};
|
|
1779
|
-
|
|
1780
|
-
if (IsNewArchitecture) {
|
|
1781
|
-
scrollToIndex(ctx, state, { ...initialScroll, animated: false });
|
|
1782
|
-
requestAnimationFrame(() => {
|
|
1783
|
-
scrollToIndex(ctx, state, { ...initialScroll, animated: false });
|
|
1784
|
-
setIt();
|
|
1785
|
-
});
|
|
1786
|
-
} else {
|
|
1787
|
-
scrollToIndex(ctx, state, { ...initialScroll, animated: false });
|
|
1788
|
-
setIt();
|
|
1789
|
-
}
|
|
1790
|
-
} else {
|
|
2089
|
+
{
|
|
1791
2090
|
setIt();
|
|
1792
2091
|
}
|
|
1793
2092
|
}
|
|
1794
2093
|
|
|
1795
2094
|
// src/core/calculateItemsInView.ts
|
|
1796
2095
|
function findCurrentStickyIndex(stickyArray, scroll, state) {
|
|
1797
|
-
var
|
|
2096
|
+
var _a3;
|
|
1798
2097
|
const idCache = state.idCache;
|
|
1799
2098
|
const positions = state.positions;
|
|
1800
2099
|
for (let i = stickyArray.length - 1; i >= 0; i--) {
|
|
1801
2100
|
const stickyIndex = stickyArray[i];
|
|
1802
|
-
const stickyId = (
|
|
2101
|
+
const stickyId = (_a3 = idCache[stickyIndex]) != null ? _a3 : getId(state, stickyIndex);
|
|
1803
2102
|
const stickyPos = stickyId ? positions.get(stickyId) : void 0;
|
|
1804
2103
|
if (stickyPos !== void 0 && scroll >= stickyPos) {
|
|
1805
2104
|
return i;
|
|
@@ -1813,21 +2112,21 @@ function getActiveStickyIndices(ctx, state, stickyIndices) {
|
|
|
1813
2112
|
);
|
|
1814
2113
|
}
|
|
1815
2114
|
function handleStickyActivation(ctx, state, stickyIndices, stickyArray, currentStickyIdx, needNewContainers, startBuffered, endBuffered) {
|
|
1816
|
-
var
|
|
2115
|
+
var _a3;
|
|
1817
2116
|
const activeIndices = getActiveStickyIndices(ctx, state, stickyIndices);
|
|
1818
2117
|
state.activeStickyIndex = currentStickyIdx >= 0 ? stickyArray[currentStickyIdx] : void 0;
|
|
1819
2118
|
for (let offset = 0; offset <= 1; offset++) {
|
|
1820
2119
|
const idx = currentStickyIdx - offset;
|
|
1821
2120
|
if (idx < 0 || activeIndices.has(stickyArray[idx])) continue;
|
|
1822
2121
|
const stickyIndex = stickyArray[idx];
|
|
1823
|
-
const stickyId = (
|
|
2122
|
+
const stickyId = (_a3 = state.idCache[stickyIndex]) != null ? _a3 : getId(state, stickyIndex);
|
|
1824
2123
|
if (stickyId && !state.containerItemKeys.has(stickyId) && (stickyIndex < startBuffered || stickyIndex > endBuffered)) {
|
|
1825
2124
|
needNewContainers.push(stickyIndex);
|
|
1826
2125
|
}
|
|
1827
2126
|
}
|
|
1828
2127
|
}
|
|
1829
2128
|
function handleStickyRecycling(ctx, state, stickyArray, scroll, scrollBuffer, currentStickyIdx, pendingRemoval) {
|
|
1830
|
-
var
|
|
2129
|
+
var _a3, _b, _c;
|
|
1831
2130
|
for (const containerIndex of state.stickyContainerPool) {
|
|
1832
2131
|
const itemKey = peek$(ctx, `containerItemKey${containerIndex}`);
|
|
1833
2132
|
const itemIndex = itemKey ? state.indexByKey.get(itemKey) : void 0;
|
|
@@ -1844,7 +2143,7 @@ function handleStickyRecycling(ctx, state, stickyArray, scroll, scrollBuffer, cu
|
|
|
1844
2143
|
const nextIndex = stickyArray[arrayIdx + 1];
|
|
1845
2144
|
let shouldRecycle = false;
|
|
1846
2145
|
if (nextIndex) {
|
|
1847
|
-
const nextId = (
|
|
2146
|
+
const nextId = (_a3 = state.idCache[nextIndex]) != null ? _a3 : getId(state, nextIndex);
|
|
1848
2147
|
const nextPos = nextId ? state.positions.get(nextId) : void 0;
|
|
1849
2148
|
shouldRecycle = nextPos !== void 0 && scroll > nextPos + scrollBuffer * 2;
|
|
1850
2149
|
} else {
|
|
@@ -1861,8 +2160,8 @@ function handleStickyRecycling(ctx, state, stickyArray, scroll, scrollBuffer, cu
|
|
|
1861
2160
|
}
|
|
1862
2161
|
}
|
|
1863
2162
|
function calculateItemsInView(ctx, state, params = {}) {
|
|
1864
|
-
|
|
1865
|
-
var
|
|
2163
|
+
reactDom.unstable_batchedUpdates(() => {
|
|
2164
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1866
2165
|
const {
|
|
1867
2166
|
columns,
|
|
1868
2167
|
containerItemKeys,
|
|
@@ -1938,7 +2237,7 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
1938
2237
|
idCache.length = 0;
|
|
1939
2238
|
positions.clear();
|
|
1940
2239
|
}
|
|
1941
|
-
const startIndex = dataChanged ? 0 : (
|
|
2240
|
+
const startIndex = dataChanged ? 0 : (_a3 = minIndexSizeChanged != null ? minIndexSizeChanged : state.startBuffered) != null ? _a3 : 0;
|
|
1942
2241
|
updateItemPositions(ctx, state, dataChanged, { scrollBottomBuffered, startIndex });
|
|
1943
2242
|
if (minIndexSizeChanged !== void 0) {
|
|
1944
2243
|
state.minIndexSizeChanged = void 0;
|
|
@@ -2113,6 +2412,7 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
2113
2412
|
if (stickyIndicesArr.length > 0) {
|
|
2114
2413
|
handleStickyRecycling(ctx, state, stickyIndicesArr, scroll, scrollBuffer, currentStickyIdx, pendingRemoval);
|
|
2115
2414
|
}
|
|
2415
|
+
let didChangePositions = false;
|
|
2116
2416
|
for (let i = 0; i < numContainers; i++) {
|
|
2117
2417
|
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
2118
2418
|
if (pendingRemoval.includes(i)) {
|
|
@@ -2144,6 +2444,7 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
2144
2444
|
const prevData = peek$(ctx, `containerItemData${i}`);
|
|
2145
2445
|
if (position > POSITION_OUT_OF_VIEW && position !== prevPos) {
|
|
2146
2446
|
set$(ctx, `containerPosition${i}`, position);
|
|
2447
|
+
didChangePositions = true;
|
|
2147
2448
|
}
|
|
2148
2449
|
if (column >= 0 && column !== prevColumn) {
|
|
2149
2450
|
set$(ctx, `containerColumn${i}`, column);
|
|
@@ -2155,6 +2456,9 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
2155
2456
|
}
|
|
2156
2457
|
}
|
|
2157
2458
|
}
|
|
2459
|
+
if (didChangePositions) {
|
|
2460
|
+
set$(ctx, "lastPositionUpdate", Date.now());
|
|
2461
|
+
}
|
|
2158
2462
|
if (!queuedInitialLayout && endBuffered !== null) {
|
|
2159
2463
|
if (checkAllSizesKnown(state)) {
|
|
2160
2464
|
setDidLayout(ctx, state);
|
|
@@ -2184,10 +2488,10 @@ function doMaintainScrollAtEnd(ctx, state, animated) {
|
|
|
2184
2488
|
state.scroll = 0;
|
|
2185
2489
|
}
|
|
2186
2490
|
requestAnimationFrame(() => {
|
|
2187
|
-
var
|
|
2491
|
+
var _a3;
|
|
2188
2492
|
if (state == null ? void 0 : state.isAtEnd) {
|
|
2189
2493
|
state.maintainingScrollAtEnd = true;
|
|
2190
|
-
(
|
|
2494
|
+
(_a3 = refScroller.current) == null ? void 0 : _a3.scrollToEnd({
|
|
2191
2495
|
animated
|
|
2192
2496
|
});
|
|
2193
2497
|
setTimeout(
|
|
@@ -2204,6 +2508,7 @@ function doMaintainScrollAtEnd(ctx, state, animated) {
|
|
|
2204
2508
|
|
|
2205
2509
|
// src/utils/checkAtTop.ts
|
|
2206
2510
|
function checkAtTop(state) {
|
|
2511
|
+
var _a3;
|
|
2207
2512
|
if (!state) {
|
|
2208
2513
|
return;
|
|
2209
2514
|
}
|
|
@@ -2219,20 +2524,25 @@ function checkAtTop(state) {
|
|
|
2219
2524
|
false,
|
|
2220
2525
|
onStartReachedThreshold * scrollLength,
|
|
2221
2526
|
state.isStartReached,
|
|
2222
|
-
state.
|
|
2527
|
+
state.startReachedSnapshot,
|
|
2528
|
+
{
|
|
2529
|
+
scrollPosition: scroll,
|
|
2530
|
+
contentSize: state.totalSize,
|
|
2531
|
+
dataLength: (_a3 = state.props.data) == null ? void 0 : _a3.length
|
|
2532
|
+
},
|
|
2223
2533
|
(distance) => {
|
|
2224
|
-
var
|
|
2225
|
-
return (_b = (
|
|
2534
|
+
var _a4, _b;
|
|
2535
|
+
return (_b = (_a4 = state.props).onStartReached) == null ? void 0 : _b.call(_a4, { distanceFromStart: distance });
|
|
2226
2536
|
},
|
|
2227
|
-
(
|
|
2228
|
-
state.
|
|
2537
|
+
(snapshot) => {
|
|
2538
|
+
state.startReachedSnapshot = snapshot;
|
|
2229
2539
|
}
|
|
2230
2540
|
);
|
|
2231
2541
|
}
|
|
2232
2542
|
|
|
2233
2543
|
// src/utils/updateAveragesOnDataChange.ts
|
|
2234
2544
|
function updateAveragesOnDataChange(state, oldData, newData) {
|
|
2235
|
-
var
|
|
2545
|
+
var _a3;
|
|
2236
2546
|
const {
|
|
2237
2547
|
averageSizes,
|
|
2238
2548
|
sizesKnown,
|
|
@@ -2258,7 +2568,7 @@ function updateAveragesOnDataChange(state, oldData, newData) {
|
|
|
2258
2568
|
const oldItem = oldData[oldIndex];
|
|
2259
2569
|
const areEqual = itemsAreEqual(oldItem, newItem, newIndex, newData);
|
|
2260
2570
|
if (areEqual) {
|
|
2261
|
-
const itemType = getItemType ? (
|
|
2571
|
+
const itemType = getItemType ? (_a3 = getItemType(newItem, newIndex)) != null ? _a3 : "" : "";
|
|
2262
2572
|
let typeData = itemTypesToPreserve[itemType];
|
|
2263
2573
|
if (!typeData) {
|
|
2264
2574
|
typeData = itemTypesToPreserve[itemType] = { count: 0, totalSize: 0 };
|
|
@@ -2306,7 +2616,7 @@ function checkResetContainers(ctx, state, isFirst, dataProp) {
|
|
|
2306
2616
|
|
|
2307
2617
|
// src/core/doInitialAllocateContainers.ts
|
|
2308
2618
|
function doInitialAllocateContainers(ctx, state) {
|
|
2309
|
-
var
|
|
2619
|
+
var _a3, _b, _c;
|
|
2310
2620
|
const {
|
|
2311
2621
|
scrollLength,
|
|
2312
2622
|
props: {
|
|
@@ -2327,7 +2637,7 @@ function doInitialAllocateContainers(ctx, state) {
|
|
|
2327
2637
|
const num = Math.min(20, data.length);
|
|
2328
2638
|
for (let i = 0; i < num; i++) {
|
|
2329
2639
|
const item = data[i];
|
|
2330
|
-
const itemType = getItemType ? (
|
|
2640
|
+
const itemType = getItemType ? (_a3 = getItemType(item, i)) != null ? _a3 : "" : "";
|
|
2331
2641
|
totalSize += (_c = (_b = getFixedItemSize == null ? void 0 : getFixedItemSize(i, item, itemType)) != null ? _b : getEstimatedItemSize == null ? void 0 : getEstimatedItemSize(i, item, itemType)) != null ? _c : estimatedItemSize;
|
|
2332
2642
|
}
|
|
2333
2643
|
averageItemSize = totalSize / num;
|
|
@@ -2341,7 +2651,7 @@ function doInitialAllocateContainers(ctx, state) {
|
|
|
2341
2651
|
}
|
|
2342
2652
|
set$(ctx, "numContainers", numContainers);
|
|
2343
2653
|
set$(ctx, "numContainersPooled", numContainers * state.props.initialContainerPoolRatio);
|
|
2344
|
-
if (
|
|
2654
|
+
if (state.lastLayout) {
|
|
2345
2655
|
if (state.props.initialScroll) {
|
|
2346
2656
|
requestAnimationFrame(() => {
|
|
2347
2657
|
calculateItemsInView(ctx, state, { dataChanged: true, doMVCP: true });
|
|
@@ -2388,7 +2698,7 @@ function handleLayout(ctx, state, layout, setCanRender) {
|
|
|
2388
2698
|
if (state) {
|
|
2389
2699
|
state.needsOtherAxisSize = otherAxisSize - (state.props.stylePaddingTop || 0) < 10;
|
|
2390
2700
|
}
|
|
2391
|
-
if (
|
|
2701
|
+
if (IS_DEV && measuredLength === 0) {
|
|
2392
2702
|
warnDevOnce(
|
|
2393
2703
|
"height0",
|
|
2394
2704
|
`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.`
|
|
@@ -2400,7 +2710,7 @@ function handleLayout(ctx, state, layout, setCanRender) {
|
|
|
2400
2710
|
|
|
2401
2711
|
// src/core/onScroll.ts
|
|
2402
2712
|
function onScroll(ctx, state, event) {
|
|
2403
|
-
var
|
|
2713
|
+
var _a3, _b, _c;
|
|
2404
2714
|
const {
|
|
2405
2715
|
scrollProcessingEnabled,
|
|
2406
2716
|
props: { onScroll: onScrollProp }
|
|
@@ -2408,7 +2718,7 @@ function onScroll(ctx, state, event) {
|
|
|
2408
2718
|
if (scrollProcessingEnabled === false) {
|
|
2409
2719
|
return;
|
|
2410
2720
|
}
|
|
2411
|
-
if (((_b = (
|
|
2721
|
+
if (((_b = (_a3 = event.nativeEvent) == null ? void 0 : _a3.contentSize) == null ? void 0 : _b.height) === 0 && ((_c = event.nativeEvent.contentSize) == null ? void 0 : _c.width) === 0) {
|
|
2412
2722
|
return;
|
|
2413
2723
|
}
|
|
2414
2724
|
const newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
|
|
@@ -2482,7 +2792,7 @@ var ScrollAdjustHandler = class {
|
|
|
2482
2792
|
|
|
2483
2793
|
// src/core/updateItemSize.ts
|
|
2484
2794
|
function updateItemSize(ctx, state, itemKey, sizeObj) {
|
|
2485
|
-
var
|
|
2795
|
+
var _a3;
|
|
2486
2796
|
const {
|
|
2487
2797
|
sizesKnown,
|
|
2488
2798
|
props: {
|
|
@@ -2505,7 +2815,7 @@ function updateItemSize(ctx, state, itemKey, sizeObj) {
|
|
|
2505
2815
|
if (itemData === void 0) {
|
|
2506
2816
|
return;
|
|
2507
2817
|
}
|
|
2508
|
-
const type = getItemType ? (
|
|
2818
|
+
const type = getItemType ? (_a3 = getItemType(itemData, index)) != null ? _a3 : "" : "";
|
|
2509
2819
|
const size2 = getFixedItemSize(index, itemData, type);
|
|
2510
2820
|
if (size2 !== void 0 && size2 === sizesKnown.get(itemKey)) {
|
|
2511
2821
|
return;
|
|
@@ -2551,13 +2861,13 @@ function updateItemSize(ctx, state, itemKey, sizeObj) {
|
|
|
2551
2861
|
if (minIndexSizeChanged !== void 0) {
|
|
2552
2862
|
state.minIndexSizeChanged = state.minIndexSizeChanged !== void 0 ? Math.min(state.minIndexSizeChanged, minIndexSizeChanged) : minIndexSizeChanged;
|
|
2553
2863
|
}
|
|
2554
|
-
if (
|
|
2864
|
+
if (IS_DEV && suggestEstimatedItemSize && minIndexSizeChanged !== void 0) {
|
|
2555
2865
|
if (state.timeoutSizeMessage) clearTimeout(state.timeoutSizeMessage);
|
|
2556
2866
|
state.timeoutSizeMessage = setTimeout(() => {
|
|
2557
|
-
var
|
|
2867
|
+
var _a4;
|
|
2558
2868
|
state.timeoutSizeMessage = void 0;
|
|
2559
2869
|
const num = state.sizesKnown.size;
|
|
2560
|
-
const avg = (
|
|
2870
|
+
const avg = (_a4 = state.averageSizes[""]) == null ? void 0 : _a4.avg;
|
|
2561
2871
|
console.warn(
|
|
2562
2872
|
`[legend-list] Based on the ${num} items rendered so far, the optimal estimated size is ${avg}.`
|
|
2563
2873
|
);
|
|
@@ -2580,7 +2890,7 @@ function updateItemSize(ctx, state, itemKey, sizeObj) {
|
|
|
2580
2890
|
}
|
|
2581
2891
|
}
|
|
2582
2892
|
function updateOneItemSize(state, itemKey, sizeObj) {
|
|
2583
|
-
var
|
|
2893
|
+
var _a3;
|
|
2584
2894
|
const {
|
|
2585
2895
|
sizes,
|
|
2586
2896
|
indexByKey,
|
|
@@ -2591,10 +2901,11 @@ function updateOneItemSize(state, itemKey, sizeObj) {
|
|
|
2591
2901
|
if (!data) return 0;
|
|
2592
2902
|
const index = indexByKey.get(itemKey);
|
|
2593
2903
|
const prevSize = getItemSize(state, itemKey, index, data[index]);
|
|
2594
|
-
const
|
|
2904
|
+
const rawSize = horizontal ? sizeObj.width : sizeObj.height;
|
|
2905
|
+
const size = Math.round(rawSize) ;
|
|
2595
2906
|
sizesKnown.set(itemKey, size);
|
|
2596
2907
|
if (!getEstimatedItemSize && !getFixedItemSize && size > 0) {
|
|
2597
|
-
const itemType = getItemType ? (
|
|
2908
|
+
const itemType = getItemType ? (_a3 = getItemType(data[index], index)) != null ? _a3 : "" : "";
|
|
2598
2909
|
let averages = averageSizes[itemType];
|
|
2599
2910
|
if (!averages) {
|
|
2600
2911
|
averages = averageSizes[itemType] = { avg: 0, num: 0 };
|
|
@@ -2609,7 +2920,7 @@ function updateOneItemSize(state, itemKey, sizeObj) {
|
|
|
2609
2920
|
return 0;
|
|
2610
2921
|
}
|
|
2611
2922
|
var useCombinedRef = (...refs) => {
|
|
2612
|
-
const callback =
|
|
2923
|
+
const callback = React3.useCallback((element) => {
|
|
2613
2924
|
for (const ref of refs) {
|
|
2614
2925
|
if (!ref) {
|
|
2615
2926
|
continue;
|
|
@@ -2624,6 +2935,16 @@ var useCombinedRef = (...refs) => {
|
|
|
2624
2935
|
return callback;
|
|
2625
2936
|
};
|
|
2626
2937
|
|
|
2938
|
+
// src/platform/RefreshControl.tsx
|
|
2939
|
+
function RefreshControl(_props) {
|
|
2940
|
+
return null;
|
|
2941
|
+
}
|
|
2942
|
+
|
|
2943
|
+
// src/platform/useStickyScrollHandler.ts
|
|
2944
|
+
function useStickyScrollHandler(_stickyIndices, _horizontal, _ctx, onScroll2) {
|
|
2945
|
+
return onScroll2;
|
|
2946
|
+
}
|
|
2947
|
+
|
|
2627
2948
|
// src/utils/createColumnWrapperStyle.ts
|
|
2628
2949
|
function createColumnWrapperStyle(contentContainerStyle) {
|
|
2629
2950
|
const { gap, columnGap, rowGap } = contentContainerStyle;
|
|
@@ -2639,7 +2960,7 @@ function createColumnWrapperStyle(contentContainerStyle) {
|
|
|
2639
2960
|
}
|
|
2640
2961
|
}
|
|
2641
2962
|
function getRenderedItem(ctx, state, key) {
|
|
2642
|
-
var
|
|
2963
|
+
var _a3;
|
|
2643
2964
|
if (!state) {
|
|
2644
2965
|
return null;
|
|
2645
2966
|
}
|
|
@@ -2660,23 +2981,23 @@ function getRenderedItem(ctx, state, key) {
|
|
|
2660
2981
|
extraData,
|
|
2661
2982
|
index,
|
|
2662
2983
|
item,
|
|
2663
|
-
type: getItemType ? (
|
|
2984
|
+
type: getItemType ? (_a3 = getItemType(item, index)) != null ? _a3 : "" : ""
|
|
2664
2985
|
};
|
|
2665
|
-
renderedItem = isFunction(renderItem) ? renderItem(itemProps) :
|
|
2986
|
+
renderedItem = isFunction(renderItem) ? renderItem(itemProps) : React3__namespace.default.createElement(renderItem, itemProps);
|
|
2666
2987
|
}
|
|
2667
2988
|
return { index, item: data[index], renderedItem };
|
|
2668
2989
|
}
|
|
2669
2990
|
function useThrottleDebounce(mode) {
|
|
2670
|
-
const timeoutRef =
|
|
2671
|
-
const lastCallTimeRef =
|
|
2672
|
-
const lastArgsRef =
|
|
2991
|
+
const timeoutRef = React3.useRef(null);
|
|
2992
|
+
const lastCallTimeRef = React3.useRef(0);
|
|
2993
|
+
const lastArgsRef = React3.useRef(null);
|
|
2673
2994
|
const clearTimeoutRef = () => {
|
|
2674
2995
|
if (timeoutRef.current) {
|
|
2675
2996
|
clearTimeout(timeoutRef.current);
|
|
2676
2997
|
timeoutRef.current = null;
|
|
2677
2998
|
}
|
|
2678
2999
|
};
|
|
2679
|
-
const execute =
|
|
3000
|
+
const execute = React3.useCallback(
|
|
2680
3001
|
(callback, delay, ...args) => {
|
|
2681
3002
|
{
|
|
2682
3003
|
const now = Date.now();
|
|
@@ -2721,18 +3042,18 @@ var LegendList = typedMemo(
|
|
|
2721
3042
|
const isChildrenMode = children !== void 0 && dataProp === void 0;
|
|
2722
3043
|
const processedProps = isChildrenMode ? {
|
|
2723
3044
|
...restProps,
|
|
2724
|
-
data: (isArray(children) ? children :
|
|
3045
|
+
data: (isArray(children) ? children : React3__namespace.Children.toArray(children)).flat(1),
|
|
2725
3046
|
renderItem: ({ item }) => item
|
|
2726
3047
|
} : {
|
|
2727
3048
|
...restProps,
|
|
2728
3049
|
data: dataProp || [],
|
|
2729
3050
|
renderItem: renderItemProp
|
|
2730
3051
|
};
|
|
2731
|
-
return /* @__PURE__ */
|
|
3052
|
+
return /* @__PURE__ */ React3__namespace.createElement(StateProvider, null, /* @__PURE__ */ React3__namespace.createElement(LegendListInner, { ...processedProps, ref: forwardedRef }));
|
|
2732
3053
|
})
|
|
2733
3054
|
);
|
|
2734
3055
|
var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
|
|
2735
|
-
var
|
|
3056
|
+
var _a3;
|
|
2736
3057
|
const {
|
|
2737
3058
|
alignItemsAtEnd = false,
|
|
2738
3059
|
columnWrapperStyle,
|
|
@@ -2786,24 +3107,24 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2786
3107
|
waitForInitialLayout = true,
|
|
2787
3108
|
...rest
|
|
2788
3109
|
} = props;
|
|
2789
|
-
const [renderNum, setRenderNum] =
|
|
3110
|
+
const [renderNum, setRenderNum] = React3.useState(0);
|
|
2790
3111
|
const initialScroll = initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
|
|
2791
|
-
const [canRender, setCanRender] =
|
|
2792
|
-
const contentContainerStyle = { ...
|
|
2793
|
-
const style = { ...
|
|
3112
|
+
const [canRender, setCanRender] = React3__namespace.useState(!IsNewArchitecture);
|
|
3113
|
+
const contentContainerStyle = { ...StyleSheet.flatten(contentContainerStyleProp) };
|
|
3114
|
+
const style = { ...StyleSheet.flatten(styleProp) };
|
|
2794
3115
|
const stylePaddingTopState = extractPadding(style, contentContainerStyle, "Top");
|
|
2795
3116
|
const stylePaddingBottomState = extractPadding(style, contentContainerStyle, "Bottom");
|
|
2796
3117
|
const ctx = useStateContext();
|
|
2797
3118
|
ctx.columnWrapperStyle = columnWrapperStyle || (contentContainerStyle ? createColumnWrapperStyle(contentContainerStyle) : void 0);
|
|
2798
|
-
const refScroller =
|
|
3119
|
+
const refScroller = React3.useRef(null);
|
|
2799
3120
|
const combinedRef = useCombinedRef(refScroller, refScrollView);
|
|
2800
3121
|
const estimatedItemSize = estimatedItemSizeProp != null ? estimatedItemSizeProp : DEFAULT_ITEM_SIZE;
|
|
2801
3122
|
const scrollBuffer = (drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE) || 1;
|
|
2802
3123
|
const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (_item, index) => index.toString();
|
|
2803
|
-
const refState =
|
|
3124
|
+
const refState = React3.useRef();
|
|
2804
3125
|
if (!refState.current) {
|
|
2805
3126
|
if (!ctx.internalState) {
|
|
2806
|
-
const initialScrollLength = (estimatedListSize != null ? estimatedListSize :
|
|
3127
|
+
const initialScrollLength = (estimatedListSize != null ? estimatedListSize : { height: 0, width: 0 } )[horizontal ? "width" : "height"];
|
|
2807
3128
|
ctx.internalState = {
|
|
2808
3129
|
activeStickyIndex: void 0,
|
|
2809
3130
|
averageSizes: {},
|
|
@@ -2814,7 +3135,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2814
3135
|
enableScrollForNextCalculateItemsInView: true,
|
|
2815
3136
|
endBuffered: -1,
|
|
2816
3137
|
endNoBuffer: -1,
|
|
2817
|
-
|
|
3138
|
+
endReachedSnapshot: void 0,
|
|
2818
3139
|
firstFullyOnScreenIndex: -1,
|
|
2819
3140
|
idCache: [],
|
|
2820
3141
|
idsInView: [],
|
|
@@ -2847,7 +3168,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2847
3168
|
sizesKnown: /* @__PURE__ */ new Map(),
|
|
2848
3169
|
startBuffered: -1,
|
|
2849
3170
|
startNoBuffer: -1,
|
|
2850
|
-
|
|
3171
|
+
startReachedSnapshot: void 0,
|
|
2851
3172
|
stickyContainerPool: /* @__PURE__ */ new Set(),
|
|
2852
3173
|
stickyContainers: /* @__PURE__ */ new Map(),
|
|
2853
3174
|
timeoutSizeMessage: 0,
|
|
@@ -2897,13 +3218,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2897
3218
|
scrollBuffer,
|
|
2898
3219
|
snapToIndices,
|
|
2899
3220
|
stickyIndicesArr: stickyIndices != null ? stickyIndices : [],
|
|
2900
|
-
stickyIndicesSet:
|
|
3221
|
+
stickyIndicesSet: React3.useMemo(() => new Set(stickyIndices != null ? stickyIndices : []), [stickyIndices == null ? void 0 : stickyIndices.join(",")]),
|
|
2901
3222
|
stylePaddingBottom: stylePaddingBottomState,
|
|
2902
3223
|
stylePaddingTop: stylePaddingTopState,
|
|
2903
3224
|
suggestEstimatedItemSize: !!suggestEstimatedItemSize
|
|
2904
3225
|
};
|
|
2905
3226
|
state.refScroller = refScroller;
|
|
2906
|
-
const memoizedLastItemKeys =
|
|
3227
|
+
const memoizedLastItemKeys = React3.useMemo(() => {
|
|
2907
3228
|
if (!dataProp.length) return [];
|
|
2908
3229
|
return Array.from(
|
|
2909
3230
|
{ length: Math.min(numColumnsProp, dataProp.length) },
|
|
@@ -2917,7 +3238,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2917
3238
|
setPaddingTop(ctx, state, { stylePaddingTop: stylePaddingTopState });
|
|
2918
3239
|
refState.current.props.stylePaddingBottom = stylePaddingBottomState;
|
|
2919
3240
|
let paddingDiff = stylePaddingTopState - prevPaddingTop;
|
|
2920
|
-
if (maintainVisibleContentPosition && paddingDiff && prevPaddingTop !== void 0 &&
|
|
3241
|
+
if (maintainVisibleContentPosition && paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
|
|
2921
3242
|
if (state.scroll < 0) {
|
|
2922
3243
|
paddingDiff += state.scroll;
|
|
2923
3244
|
}
|
|
@@ -2933,7 +3254,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2933
3254
|
true
|
|
2934
3255
|
);
|
|
2935
3256
|
}
|
|
2936
|
-
const initialContentOffset =
|
|
3257
|
+
const initialContentOffset = React3.useMemo(() => {
|
|
2937
3258
|
if (initialScroll) {
|
|
2938
3259
|
const { index, viewOffset } = initialScroll;
|
|
2939
3260
|
let initialContentOffset2 = viewOffset || 0;
|
|
@@ -2957,7 +3278,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2957
3278
|
if (isFirst || didDataChange || numColumnsProp !== peek$(ctx, "numColumns")) {
|
|
2958
3279
|
refState.current.lastBatchingAction = Date.now();
|
|
2959
3280
|
if (!keyExtractorProp && !isFirst && didDataChange) {
|
|
2960
|
-
|
|
3281
|
+
IS_DEV && warnDevOnce(
|
|
2961
3282
|
"keyExtractor",
|
|
2962
3283
|
"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."
|
|
2963
3284
|
);
|
|
@@ -2965,27 +3286,23 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2965
3286
|
refState.current.positions.clear();
|
|
2966
3287
|
}
|
|
2967
3288
|
}
|
|
2968
|
-
const onLayoutHeader =
|
|
3289
|
+
const onLayoutHeader = React3.useCallback((rect, fromLayoutEffect) => {
|
|
2969
3290
|
const size = rect[horizontal ? "width" : "height"];
|
|
2970
3291
|
set$(ctx, "headerSize", size);
|
|
2971
3292
|
if ((initialScroll == null ? void 0 : initialScroll.index) !== void 0) {
|
|
2972
|
-
|
|
3293
|
+
{
|
|
2973
3294
|
if (fromLayoutEffect) {
|
|
2974
3295
|
setRenderNum((v) => v + 1);
|
|
2975
3296
|
}
|
|
2976
|
-
} else {
|
|
2977
|
-
setTimeout(() => {
|
|
2978
|
-
scrollToIndex(ctx, state, { ...initialScroll, animated: false });
|
|
2979
|
-
}, 17);
|
|
2980
3297
|
}
|
|
2981
3298
|
}
|
|
2982
3299
|
}, []);
|
|
2983
|
-
|
|
3300
|
+
React3.useLayoutEffect(() => {
|
|
2984
3301
|
if (snapToIndices) {
|
|
2985
3302
|
updateSnapToOffsets(ctx, state);
|
|
2986
3303
|
}
|
|
2987
3304
|
}, [snapToIndices]);
|
|
2988
|
-
|
|
3305
|
+
React3.useLayoutEffect(() => {
|
|
2989
3306
|
const didAllocateContainers = dataProp.length > 0 && doInitialAllocateContainers(ctx, state);
|
|
2990
3307
|
if (!didAllocateContainers) {
|
|
2991
3308
|
checkResetContainers(
|
|
@@ -2997,16 +3314,16 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2997
3314
|
);
|
|
2998
3315
|
}
|
|
2999
3316
|
}, [dataProp, numColumnsProp]);
|
|
3000
|
-
|
|
3317
|
+
React3.useLayoutEffect(() => {
|
|
3001
3318
|
set$(ctx, "extraData", extraData);
|
|
3002
3319
|
}, [extraData]);
|
|
3003
|
-
|
|
3320
|
+
React3.useLayoutEffect(initializeStateVars, [
|
|
3004
3321
|
memoizedLastItemKeys.join(","),
|
|
3005
3322
|
numColumnsProp,
|
|
3006
3323
|
stylePaddingTopState,
|
|
3007
3324
|
stylePaddingBottomState
|
|
3008
3325
|
]);
|
|
3009
|
-
|
|
3326
|
+
React3.useEffect(() => {
|
|
3010
3327
|
const viewability = setupViewability({
|
|
3011
3328
|
onViewableItemsChanged,
|
|
3012
3329
|
viewabilityConfig,
|
|
@@ -3015,12 +3332,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3015
3332
|
state.viewabilityConfigCallbackPairs = viewability;
|
|
3016
3333
|
state.enableScrollForNextCalculateItemsInView = !viewability;
|
|
3017
3334
|
}, [viewabilityConfig, viewabilityConfigCallbackPairs, onViewableItemsChanged]);
|
|
3018
|
-
|
|
3019
|
-
useInit(() => {
|
|
3020
|
-
doInitialAllocateContainers(ctx, state);
|
|
3021
|
-
});
|
|
3022
|
-
}
|
|
3023
|
-
const onLayoutChange = React2.useCallback((layout) => {
|
|
3335
|
+
const onLayoutChange = React3.useCallback((layout) => {
|
|
3024
3336
|
handleLayout(ctx, state, layout, setCanRender);
|
|
3025
3337
|
}, []);
|
|
3026
3338
|
const { onLayout } = useOnLayoutSync({
|
|
@@ -3029,7 +3341,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3029
3341
|
ref: refScroller
|
|
3030
3342
|
// the type of ScrollView doesn't include measure?
|
|
3031
3343
|
});
|
|
3032
|
-
|
|
3344
|
+
React3.useImperativeHandle(forwardedRef, () => {
|
|
3033
3345
|
const scrollIndexIntoView = (options) => {
|
|
3034
3346
|
const state2 = refState.current;
|
|
3035
3347
|
if (state2) {
|
|
@@ -3111,14 +3423,14 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3111
3423
|
}
|
|
3112
3424
|
};
|
|
3113
3425
|
}, []);
|
|
3114
|
-
|
|
3115
|
-
|
|
3426
|
+
{
|
|
3427
|
+
React3.useEffect(() => {
|
|
3116
3428
|
if (initialContentOffset) {
|
|
3117
|
-
scrollTo(state, { animated: false, offset: initialContentOffset });
|
|
3429
|
+
scrollTo(state, { animated: false, offset: initialContentOffset, ...initialScroll || {} });
|
|
3118
3430
|
}
|
|
3119
3431
|
}, []);
|
|
3120
3432
|
}
|
|
3121
|
-
const fns =
|
|
3433
|
+
const fns = React3.useMemo(
|
|
3122
3434
|
() => ({
|
|
3123
3435
|
getRenderedItem: (key) => getRenderedItem(ctx, state, key),
|
|
3124
3436
|
onScroll: (event) => onScroll(ctx, state, event),
|
|
@@ -3126,18 +3438,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3126
3438
|
}),
|
|
3127
3439
|
[]
|
|
3128
3440
|
);
|
|
3129
|
-
const onScrollHandler =
|
|
3130
|
-
|
|
3131
|
-
if (stickyIndices == null ? void 0 : stickyIndices.length) {
|
|
3132
|
-
const { animatedScrollY } = ctx;
|
|
3133
|
-
return reactNative.Animated.event([{ nativeEvent: { contentOffset: { [horizontal ? "x" : "y"]: animatedScrollY } } }], {
|
|
3134
|
-
listener: onScrollFn,
|
|
3135
|
-
useNativeDriver: true
|
|
3136
|
-
});
|
|
3137
|
-
}
|
|
3138
|
-
return onScrollFn;
|
|
3139
|
-
}, [stickyIndices == null ? void 0 : stickyIndices.length, horizontal, scrollEventThrottle]);
|
|
3140
|
-
return /* @__PURE__ */ React2__namespace.createElement(React2__namespace.Fragment, null, /* @__PURE__ */ React2__namespace.createElement(
|
|
3441
|
+
const onScrollHandler = useStickyScrollHandler(stickyIndices, horizontal, ctx, fns.onScroll);
|
|
3442
|
+
return /* @__PURE__ */ React3__namespace.createElement(React3__namespace.Fragment, null, /* @__PURE__ */ React3__namespace.createElement(
|
|
3141
3443
|
ListComponent,
|
|
3142
3444
|
{
|
|
3143
3445
|
...rest,
|
|
@@ -3153,14 +3455,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3153
3455
|
onLayout,
|
|
3154
3456
|
onLayoutHeader,
|
|
3155
3457
|
onMomentumScrollEnd: (event) => {
|
|
3156
|
-
|
|
3458
|
+
{
|
|
3157
3459
|
requestAnimationFrame(() => {
|
|
3158
3460
|
finishScrollTo(refState.current);
|
|
3159
3461
|
});
|
|
3160
|
-
} else {
|
|
3161
|
-
setTimeout(() => {
|
|
3162
|
-
finishScrollTo(refState.current);
|
|
3163
|
-
}, 1e3);
|
|
3164
3462
|
}
|
|
3165
3463
|
if (onMomentumScrollEnd) {
|
|
3166
3464
|
onMomentumScrollEnd(event);
|
|
@@ -3168,10 +3466,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3168
3466
|
},
|
|
3169
3467
|
onScroll: onScrollHandler,
|
|
3170
3468
|
recycleItems,
|
|
3171
|
-
refreshControl: refreshControl ? stylePaddingTopState > 0 ?
|
|
3469
|
+
refreshControl: refreshControl ? stylePaddingTopState > 0 ? React3__namespace.cloneElement(refreshControl, {
|
|
3172
3470
|
progressViewOffset: (refreshControl.props.progressViewOffset || 0) + stylePaddingTopState
|
|
3173
|
-
}) : refreshControl : onRefresh && /* @__PURE__ */
|
|
3174
|
-
|
|
3471
|
+
}) : refreshControl : onRefresh && /* @__PURE__ */ React3__namespace.createElement(
|
|
3472
|
+
RefreshControl,
|
|
3175
3473
|
{
|
|
3176
3474
|
onRefresh,
|
|
3177
3475
|
progressViewOffset: (progressViewOffset || 0) + stylePaddingTopState,
|
|
@@ -3179,15 +3477,15 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3179
3477
|
}
|
|
3180
3478
|
),
|
|
3181
3479
|
refScrollView: combinedRef,
|
|
3182
|
-
scrollAdjustHandler: (
|
|
3183
|
-
scrollEventThrottle:
|
|
3480
|
+
scrollAdjustHandler: (_a3 = refState.current) == null ? void 0 : _a3.scrollAdjustHandler,
|
|
3481
|
+
scrollEventThrottle: 16 ,
|
|
3184
3482
|
snapToIndices,
|
|
3185
3483
|
stickyIndices,
|
|
3186
3484
|
style,
|
|
3187
3485
|
updateItemSize: fns.updateItemSize,
|
|
3188
3486
|
waitForInitialLayout
|
|
3189
3487
|
}
|
|
3190
|
-
),
|
|
3488
|
+
), IS_DEV && ENABLE_DEBUG_VIEW && /* @__PURE__ */ React3__namespace.createElement(DebugView, { state: refState.current }));
|
|
3191
3489
|
});
|
|
3192
3490
|
|
|
3193
3491
|
exports.LegendList = LegendList;
|