@legendapp/list 1.0.12 → 1.0.14
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/CHANGELOG.md +4 -0
- package/index.js +116 -97
- package/index.mjs +68 -49
- package/keyboard-controller.d.mts +133 -133
- package/keyboard-controller.d.ts +133 -133
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React2 = require('react');
|
|
4
4
|
var reactNative = require('react-native');
|
|
5
5
|
var shim = require('use-sync-external-store/shim');
|
|
6
6
|
|
|
@@ -22,12 +22,12 @@ function _interopNamespace(e) {
|
|
|
22
22
|
return Object.freeze(n);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
var
|
|
25
|
+
var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
|
|
26
26
|
|
|
27
27
|
// src/LegendList.tsx
|
|
28
|
-
var ContextState =
|
|
28
|
+
var ContextState = React2__namespace.createContext(null);
|
|
29
29
|
function StateProvider({ children }) {
|
|
30
|
-
const [value] =
|
|
30
|
+
const [value] = React2__namespace.useState(() => ({
|
|
31
31
|
listeners: /* @__PURE__ */ new Map(),
|
|
32
32
|
values: /* @__PURE__ */ new Map([
|
|
33
33
|
["paddingTop", 0],
|
|
@@ -42,10 +42,10 @@ function StateProvider({ children }) {
|
|
|
42
42
|
columnWrapperStyle: void 0,
|
|
43
43
|
viewRefs: /* @__PURE__ */ new Map()
|
|
44
44
|
}));
|
|
45
|
-
return /* @__PURE__ */
|
|
45
|
+
return /* @__PURE__ */ React2__namespace.createElement(ContextState.Provider, { value }, children);
|
|
46
46
|
}
|
|
47
47
|
function useStateContext() {
|
|
48
|
-
return
|
|
48
|
+
return React2__namespace.useContext(ContextState);
|
|
49
49
|
}
|
|
50
50
|
function createSelectorFunctionsArr(ctx, signalNames) {
|
|
51
51
|
let lastValues = [];
|
|
@@ -115,17 +115,17 @@ function getContentSize(ctx) {
|
|
|
115
115
|
return headerSize + footerSize + totalSize + stylePaddingTop;
|
|
116
116
|
}
|
|
117
117
|
function useArr$(signalNames) {
|
|
118
|
-
const ctx =
|
|
119
|
-
const { subscribe, get } =
|
|
118
|
+
const ctx = React2__namespace.useContext(ContextState);
|
|
119
|
+
const { subscribe, get } = React2__namespace.useMemo(() => createSelectorFunctionsArr(ctx, signalNames), [ctx, signalNames]);
|
|
120
120
|
const value = shim.useSyncExternalStore(subscribe, get);
|
|
121
121
|
return value;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
// src/DebugView.tsx
|
|
125
125
|
var DebugRow = ({ children }) => {
|
|
126
|
-
return /* @__PURE__ */
|
|
126
|
+
return /* @__PURE__ */ React2__namespace.createElement(reactNative.View, { style: { flexDirection: "row", alignItems: "center", justifyContent: "space-between" } }, children);
|
|
127
127
|
};
|
|
128
|
-
var DebugView =
|
|
128
|
+
var DebugView = React2__namespace.memo(function DebugView2({ state }) {
|
|
129
129
|
const ctx = useStateContext();
|
|
130
130
|
const [
|
|
131
131
|
totalSize = 0,
|
|
@@ -145,11 +145,11 @@ var DebugView = React3__namespace.memo(function DebugView2({ state }) {
|
|
|
145
145
|
"numContainersPooled"
|
|
146
146
|
]);
|
|
147
147
|
const contentSize = getContentSize(ctx);
|
|
148
|
-
const [, forceUpdate] =
|
|
148
|
+
const [, forceUpdate] = React2.useReducer((x) => x + 1, 0);
|
|
149
149
|
useInterval(() => {
|
|
150
150
|
forceUpdate();
|
|
151
151
|
}, 100);
|
|
152
|
-
return /* @__PURE__ */
|
|
152
|
+
return /* @__PURE__ */ React2__namespace.createElement(
|
|
153
153
|
reactNative.View,
|
|
154
154
|
{
|
|
155
155
|
style: {
|
|
@@ -165,19 +165,19 @@ var DebugView = React3__namespace.memo(function DebugView2({ state }) {
|
|
|
165
165
|
},
|
|
166
166
|
pointerEvents: "none"
|
|
167
167
|
},
|
|
168
|
-
/* @__PURE__ */
|
|
169
|
-
/* @__PURE__ */
|
|
170
|
-
/* @__PURE__ */
|
|
171
|
-
/* @__PURE__ */
|
|
172
|
-
/* @__PURE__ */
|
|
173
|
-
/* @__PURE__ */
|
|
174
|
-
/* @__PURE__ */
|
|
175
|
-
/* @__PURE__ */
|
|
176
|
-
/* @__PURE__ */
|
|
168
|
+
/* @__PURE__ */ React2__namespace.createElement(DebugRow, null, /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, "TotalSize:"), /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, totalSize.toFixed(2))),
|
|
169
|
+
/* @__PURE__ */ React2__namespace.createElement(DebugRow, null, /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, "ContentSize:"), /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, contentSize.toFixed(2))),
|
|
170
|
+
/* @__PURE__ */ React2__namespace.createElement(DebugRow, null, /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, "At end:"), /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, String(state.isAtBottom))),
|
|
171
|
+
/* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null),
|
|
172
|
+
/* @__PURE__ */ React2__namespace.createElement(DebugRow, null, /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, "ScrollAdjust:"), /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, scrollAdjust.toFixed(2))),
|
|
173
|
+
/* @__PURE__ */ React2__namespace.createElement(DebugRow, null, /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, "TotalSizeReal: "), /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, totalSizeWithScrollAdjust.toFixed(2))),
|
|
174
|
+
/* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null),
|
|
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)))
|
|
177
177
|
);
|
|
178
178
|
});
|
|
179
179
|
function useInterval(callback, delay) {
|
|
180
|
-
|
|
180
|
+
React2.useEffect(() => {
|
|
181
181
|
const interval = setInterval(callback, delay);
|
|
182
182
|
return () => clearInterval(interval);
|
|
183
183
|
}, [delay]);
|
|
@@ -206,9 +206,16 @@ function comparatorByDistance(a, b) {
|
|
|
206
206
|
function comparatorDefault(a, b) {
|
|
207
207
|
return a - b;
|
|
208
208
|
}
|
|
209
|
+
function getPadding(s) {
|
|
210
|
+
var _a, _b, _c;
|
|
211
|
+
return (_c = (_b = (_a = s.paddingTop) != null ? _a : s.paddingVertical) != null ? _b : s.padding) != null ? _c : 0;
|
|
212
|
+
}
|
|
213
|
+
function extractPaddingTop(style, contentContainerStyle) {
|
|
214
|
+
return getPadding(style) + getPadding(contentContainerStyle);
|
|
215
|
+
}
|
|
209
216
|
var symbolFirst = Symbol();
|
|
210
217
|
function useInit(cb) {
|
|
211
|
-
const refValue =
|
|
218
|
+
const refValue = React2.useRef(symbolFirst);
|
|
212
219
|
if (refValue.current === symbolFirst) {
|
|
213
220
|
refValue.current = cb();
|
|
214
221
|
}
|
|
@@ -216,10 +223,10 @@ function useInit(cb) {
|
|
|
216
223
|
}
|
|
217
224
|
|
|
218
225
|
// src/ContextContainer.ts
|
|
219
|
-
var ContextContainer =
|
|
226
|
+
var ContextContainer = React2.createContext(null);
|
|
220
227
|
function useViewability(callback, configId) {
|
|
221
228
|
const ctx = useStateContext();
|
|
222
|
-
const { containerId } =
|
|
229
|
+
const { containerId } = React2.useContext(ContextContainer);
|
|
223
230
|
const key = containerId + (configId != null ? configId : "");
|
|
224
231
|
useInit(() => {
|
|
225
232
|
const value = ctx.mapViewabilityValues.get(key);
|
|
@@ -228,7 +235,7 @@ function useViewability(callback, configId) {
|
|
|
228
235
|
}
|
|
229
236
|
});
|
|
230
237
|
ctx.mapViewabilityCallbacks.set(key, callback);
|
|
231
|
-
|
|
238
|
+
React2.useEffect(
|
|
232
239
|
() => () => {
|
|
233
240
|
ctx.mapViewabilityCallbacks.delete(key);
|
|
234
241
|
},
|
|
@@ -237,7 +244,7 @@ function useViewability(callback, configId) {
|
|
|
237
244
|
}
|
|
238
245
|
function useViewabilityAmount(callback) {
|
|
239
246
|
const ctx = useStateContext();
|
|
240
|
-
const { containerId } =
|
|
247
|
+
const { containerId } = React2.useContext(ContextContainer);
|
|
241
248
|
useInit(() => {
|
|
242
249
|
const value = ctx.mapViewabilityAmountValues.get(containerId);
|
|
243
250
|
if (value) {
|
|
@@ -245,7 +252,7 @@ function useViewabilityAmount(callback) {
|
|
|
245
252
|
}
|
|
246
253
|
});
|
|
247
254
|
ctx.mapViewabilityAmountCallbacks.set(containerId, callback);
|
|
248
|
-
|
|
255
|
+
React2.useEffect(
|
|
249
256
|
() => () => {
|
|
250
257
|
ctx.mapViewabilityAmountCallbacks.delete(containerId);
|
|
251
258
|
},
|
|
@@ -253,12 +260,12 @@ function useViewabilityAmount(callback) {
|
|
|
253
260
|
);
|
|
254
261
|
}
|
|
255
262
|
function useRecyclingEffect(effect) {
|
|
256
|
-
const { index, value } =
|
|
257
|
-
const prevValues =
|
|
263
|
+
const { index, value } = React2.useContext(ContextContainer);
|
|
264
|
+
const prevValues = React2.useRef({
|
|
258
265
|
prevIndex: void 0,
|
|
259
266
|
prevItem: void 0
|
|
260
267
|
});
|
|
261
|
-
|
|
268
|
+
React2.useEffect(() => {
|
|
262
269
|
let ret = void 0;
|
|
263
270
|
if (prevValues.current.prevIndex !== void 0 && prevValues.current.prevItem !== void 0) {
|
|
264
271
|
ret = effect({
|
|
@@ -276,12 +283,12 @@ function useRecyclingEffect(effect) {
|
|
|
276
283
|
}, [index, value]);
|
|
277
284
|
}
|
|
278
285
|
function useRecyclingState(valueOrFun) {
|
|
279
|
-
const { index, value, itemKey, triggerLayout } =
|
|
280
|
-
const refState =
|
|
286
|
+
const { index, value, itemKey, triggerLayout } = React2.useContext(ContextContainer);
|
|
287
|
+
const refState = React2.useRef({
|
|
281
288
|
itemKey: null,
|
|
282
289
|
value: null
|
|
283
290
|
});
|
|
284
|
-
const [_, setRenderNum] =
|
|
291
|
+
const [_, setRenderNum] = React2.useState(0);
|
|
285
292
|
if (refState.current.itemKey !== itemKey) {
|
|
286
293
|
refState.current.itemKey = itemKey;
|
|
287
294
|
refState.current.value = isFunction(valueOrFun) ? valueOrFun({
|
|
@@ -291,7 +298,7 @@ function useRecyclingState(valueOrFun) {
|
|
|
291
298
|
prevItem: void 0
|
|
292
299
|
}) : valueOrFun;
|
|
293
300
|
}
|
|
294
|
-
const setState =
|
|
301
|
+
const setState = React2.useCallback(
|
|
295
302
|
(newState) => {
|
|
296
303
|
refState.current.value = isFunction(newState) ? newState(refState.current.value) : newState;
|
|
297
304
|
setRenderNum((v) => v + 1);
|
|
@@ -301,8 +308,8 @@ function useRecyclingState(valueOrFun) {
|
|
|
301
308
|
);
|
|
302
309
|
return [refState.current.value, setState];
|
|
303
310
|
}
|
|
304
|
-
var LeanViewComponent =
|
|
305
|
-
return
|
|
311
|
+
var LeanViewComponent = React2__namespace.forwardRef((props, ref) => {
|
|
312
|
+
return React2__namespace.createElement("RCTView", { ...props, ref });
|
|
306
313
|
});
|
|
307
314
|
LeanViewComponent.displayName = "RCTView";
|
|
308
315
|
var LeanView = reactNative.Platform.OS === "android" || reactNative.Platform.OS === "ios" ? LeanViewComponent : reactNative.View;
|
|
@@ -348,9 +355,9 @@ var Container = ({
|
|
|
348
355
|
`containerItemData${id}`,
|
|
349
356
|
"extraData"
|
|
350
357
|
]);
|
|
351
|
-
const refLastSize =
|
|
352
|
-
const ref =
|
|
353
|
-
const [layoutRenderCount, forceLayoutRender] =
|
|
358
|
+
const refLastSize = React2.useRef();
|
|
359
|
+
const ref = React2.useRef(null);
|
|
360
|
+
const [layoutRenderCount, forceLayoutRender] = React2.useState(0);
|
|
354
361
|
const otherAxisPos = numColumns > 1 ? `${(column - 1) / numColumns * 100}%` : 0;
|
|
355
362
|
const otherAxisSize = numColumns > 1 ? `${1 / numColumns * 100}%` : void 0;
|
|
356
363
|
let paddingStyles;
|
|
@@ -384,12 +391,12 @@ var Container = ({
|
|
|
384
391
|
top: position.relativeCoordinate,
|
|
385
392
|
...paddingStyles || {}
|
|
386
393
|
};
|
|
387
|
-
const renderedItemInfo =
|
|
394
|
+
const renderedItemInfo = React2.useMemo(
|
|
388
395
|
() => itemKey !== void 0 ? getRenderedItem(itemKey) : null,
|
|
389
396
|
[itemKey, data, extraData]
|
|
390
397
|
);
|
|
391
398
|
const { index, renderedItem } = renderedItemInfo || {};
|
|
392
|
-
const triggerLayout =
|
|
399
|
+
const triggerLayout = React2.useCallback(() => {
|
|
393
400
|
forceLayoutRender((v) => v + 1);
|
|
394
401
|
}, []);
|
|
395
402
|
const onLayout = (event) => {
|
|
@@ -412,7 +419,7 @@ var Container = ({
|
|
|
412
419
|
}
|
|
413
420
|
};
|
|
414
421
|
if (IsNewArchitecture) {
|
|
415
|
-
|
|
422
|
+
React2.useLayoutEffect(() => {
|
|
416
423
|
var _a, _b;
|
|
417
424
|
if (!isNullOrUndefined(itemKey)) {
|
|
418
425
|
const measured = (_b = (_a = ref.current) == null ? void 0 : _a.unstable_getBoundingClientRect) == null ? void 0 : _b.call(_a);
|
|
@@ -425,7 +432,7 @@ var Container = ({
|
|
|
425
432
|
}
|
|
426
433
|
}, [itemKey, layoutRenderCount]);
|
|
427
434
|
} else {
|
|
428
|
-
|
|
435
|
+
React2.useEffect(() => {
|
|
429
436
|
if (!isNullOrUndefined(itemKey)) {
|
|
430
437
|
const timeout = setTimeout(() => {
|
|
431
438
|
if (refLastSize.current) {
|
|
@@ -438,25 +445,25 @@ var Container = ({
|
|
|
438
445
|
}
|
|
439
446
|
}, [itemKey]);
|
|
440
447
|
}
|
|
441
|
-
const contextValue =
|
|
448
|
+
const contextValue = React2.useMemo(() => {
|
|
442
449
|
ctx.viewRefs.set(id, ref);
|
|
443
450
|
return { containerId: id, itemKey, index, value: data, triggerLayout };
|
|
444
451
|
}, [id, itemKey, index, data]);
|
|
445
|
-
const contentFragment = /* @__PURE__ */
|
|
452
|
+
const contentFragment = /* @__PURE__ */ React2__namespace.default.createElement(React2__namespace.default.Fragment, { key: recycleItems ? void 0 : itemKey }, /* @__PURE__ */ React2__namespace.default.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItemInfo && ItemSeparatorComponent && !lastItemKeys.includes(itemKey) && /* @__PURE__ */ React2__namespace.default.createElement(ItemSeparatorComponent, { leadingItem: renderedItemInfo.item })));
|
|
446
453
|
if (maintainVisibleContentPosition) {
|
|
447
454
|
const anchorStyle = position.type === "top" ? { position: "absolute", top: 0, left: 0, right: 0 } : { position: "absolute", bottom: 0, left: 0, right: 0 };
|
|
448
455
|
if (__DEV__ && ENABLE_DEVMODE) {
|
|
449
456
|
anchorStyle.borderColor = position.type === "top" ? "red" : "blue";
|
|
450
457
|
anchorStyle.borderWidth = 1;
|
|
451
458
|
}
|
|
452
|
-
return /* @__PURE__ */
|
|
459
|
+
return /* @__PURE__ */ React2__namespace.default.createElement(LeanView, { style }, /* @__PURE__ */ React2__namespace.default.createElement(LeanView, { style: [anchorStyle, paddingStyles], onLayout, ref }, contentFragment, __DEV__ && ENABLE_DEVMODE && /* @__PURE__ */ React2__namespace.default.createElement(reactNative.Text, { style: { position: "absolute", top: 0, left: 0, zIndex: 1e3 } }, position.top)));
|
|
453
460
|
}
|
|
454
|
-
return /* @__PURE__ */
|
|
461
|
+
return /* @__PURE__ */ React2__namespace.default.createElement(LeanView, { style, onLayout, ref }, contentFragment);
|
|
455
462
|
};
|
|
456
|
-
var typedForwardRef =
|
|
457
|
-
var typedMemo =
|
|
463
|
+
var typedForwardRef = React2.forwardRef;
|
|
464
|
+
var typedMemo = React2.memo;
|
|
458
465
|
var useAnimatedValue = (initialValue) => {
|
|
459
|
-
return
|
|
466
|
+
return React2.useRef(new reactNative.Animated.Value(initialValue)).current;
|
|
460
467
|
};
|
|
461
468
|
|
|
462
469
|
// src/useValue$.ts
|
|
@@ -464,7 +471,7 @@ function useValue$(key, getValue, useMicrotask) {
|
|
|
464
471
|
var _a;
|
|
465
472
|
const ctx = useStateContext();
|
|
466
473
|
const animValue = useAnimatedValue((_a = getValue ? getValue(peek$(ctx, key)) : peek$(ctx, key)) != null ? _a : 0);
|
|
467
|
-
|
|
474
|
+
React2.useMemo(() => {
|
|
468
475
|
let newValue = void 0;
|
|
469
476
|
listen$(ctx, key, (v) => {
|
|
470
477
|
if (useMicrotask && newValue === void 0) {
|
|
@@ -504,7 +511,7 @@ var Containers = typedMemo(function Containers2({
|
|
|
504
511
|
const containers = [];
|
|
505
512
|
for (let i = 0; i < numContainers; i++) {
|
|
506
513
|
containers.push(
|
|
507
|
-
/* @__PURE__ */
|
|
514
|
+
/* @__PURE__ */ React2__namespace.createElement(
|
|
508
515
|
Container,
|
|
509
516
|
{
|
|
510
517
|
id: i,
|
|
@@ -533,7 +540,7 @@ var Containers = typedMemo(function Containers2({
|
|
|
533
540
|
}
|
|
534
541
|
}
|
|
535
542
|
}
|
|
536
|
-
return /* @__PURE__ */
|
|
543
|
+
return /* @__PURE__ */ React2__namespace.createElement(reactNative.Animated.View, { style }, containers);
|
|
537
544
|
});
|
|
538
545
|
function ListHeaderComponentContainer({
|
|
539
546
|
children,
|
|
@@ -548,7 +555,7 @@ function ListHeaderComponentContainer({
|
|
|
548
555
|
transform: [{ translateY: reactNative.Animated.multiply(scrollAdjust, -1) }],
|
|
549
556
|
opacity: animOpacity
|
|
550
557
|
};
|
|
551
|
-
return /* @__PURE__ */
|
|
558
|
+
return /* @__PURE__ */ React2__namespace.createElement(
|
|
552
559
|
reactNative.Animated.View,
|
|
553
560
|
{
|
|
554
561
|
style: [style, additionalSize],
|
|
@@ -563,11 +570,11 @@ function ListHeaderComponentContainer({
|
|
|
563
570
|
|
|
564
571
|
// src/ListComponent.tsx
|
|
565
572
|
var getComponent = (Component) => {
|
|
566
|
-
if (
|
|
573
|
+
if (React2__namespace.isValidElement(Component)) {
|
|
567
574
|
return Component;
|
|
568
575
|
}
|
|
569
576
|
if (Component) {
|
|
570
|
-
return /* @__PURE__ */
|
|
577
|
+
return /* @__PURE__ */ React2__namespace.createElement(Component, null);
|
|
571
578
|
}
|
|
572
579
|
return null;
|
|
573
580
|
};
|
|
@@ -575,12 +582,12 @@ var PaddingAndAdjust = () => {
|
|
|
575
582
|
const animPaddingTop = useValue$("paddingTop", (v) => v, true);
|
|
576
583
|
const animScrollAdjust = useValue$("scrollAdjust", (v) => v, true);
|
|
577
584
|
const additionalSize = { marginTop: animScrollAdjust, paddingTop: animPaddingTop };
|
|
578
|
-
return /* @__PURE__ */
|
|
585
|
+
return /* @__PURE__ */ React2__namespace.createElement(reactNative.Animated.View, { style: additionalSize });
|
|
579
586
|
};
|
|
580
587
|
var PaddingAndAdjustDevMode = () => {
|
|
581
588
|
const animPaddingTop = useValue$("paddingTop", (v) => v, true);
|
|
582
589
|
const animScrollAdjust = useValue$("scrollAdjust", (v) => v, true);
|
|
583
|
-
return /* @__PURE__ */
|
|
590
|
+
return /* @__PURE__ */ React2__namespace.createElement(React2__namespace.Fragment, null, /* @__PURE__ */ React2__namespace.createElement(reactNative.Animated.View, { style: { marginTop: animScrollAdjust } }), /* @__PURE__ */ React2__namespace.createElement(reactNative.Animated.View, { style: { paddingTop: animPaddingTop } }), /* @__PURE__ */ React2__namespace.createElement(
|
|
584
591
|
reactNative.Animated.View,
|
|
585
592
|
{
|
|
586
593
|
style: {
|
|
@@ -592,7 +599,7 @@ var PaddingAndAdjustDevMode = () => {
|
|
|
592
599
|
backgroundColor: "green"
|
|
593
600
|
}
|
|
594
601
|
}
|
|
595
|
-
), /* @__PURE__ */
|
|
602
|
+
), /* @__PURE__ */ React2__namespace.createElement(
|
|
596
603
|
reactNative.Animated.View,
|
|
597
604
|
{
|
|
598
605
|
style: {
|
|
@@ -604,7 +611,7 @@ var PaddingAndAdjustDevMode = () => {
|
|
|
604
611
|
backgroundColor: "lightblue"
|
|
605
612
|
}
|
|
606
613
|
}
|
|
607
|
-
), /* @__PURE__ */
|
|
614
|
+
), /* @__PURE__ */ React2__namespace.createElement(
|
|
608
615
|
reactNative.Animated.View,
|
|
609
616
|
{
|
|
610
617
|
style: {
|
|
@@ -649,11 +656,11 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
649
656
|
...rest
|
|
650
657
|
}) {
|
|
651
658
|
const ctx = useStateContext();
|
|
652
|
-
const ScrollComponent = renderScrollComponent ?
|
|
653
|
-
() =>
|
|
659
|
+
const ScrollComponent = renderScrollComponent ? React2.useMemo(
|
|
660
|
+
() => React2__namespace.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
|
|
654
661
|
[renderScrollComponent]
|
|
655
662
|
) : reactNative.ScrollView;
|
|
656
|
-
return /* @__PURE__ */
|
|
663
|
+
return /* @__PURE__ */ React2__namespace.createElement(
|
|
657
664
|
ScrollComponent,
|
|
658
665
|
{
|
|
659
666
|
...rest,
|
|
@@ -671,8 +678,8 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
671
678
|
contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
|
|
672
679
|
ref: refScrollView
|
|
673
680
|
},
|
|
674
|
-
!ListEmptyComponent && (ENABLE_DEVMODE ? /* @__PURE__ */
|
|
675
|
-
ListHeaderComponent && /* @__PURE__ */
|
|
681
|
+
!ListEmptyComponent && (ENABLE_DEVMODE ? /* @__PURE__ */ React2__namespace.createElement(PaddingAndAdjustDevMode, null) : /* @__PURE__ */ React2__namespace.createElement(PaddingAndAdjust, null)),
|
|
682
|
+
ListHeaderComponent && /* @__PURE__ */ React2__namespace.createElement(
|
|
676
683
|
ListHeaderComponentContainer,
|
|
677
684
|
{
|
|
678
685
|
style: ListHeaderComponentStyle,
|
|
@@ -683,7 +690,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
683
690
|
getComponent(ListHeaderComponent)
|
|
684
691
|
),
|
|
685
692
|
ListEmptyComponent && getComponent(ListEmptyComponent),
|
|
686
|
-
/* @__PURE__ */
|
|
693
|
+
/* @__PURE__ */ React2__namespace.createElement(
|
|
687
694
|
Containers,
|
|
688
695
|
{
|
|
689
696
|
horizontal,
|
|
@@ -694,7 +701,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
694
701
|
updateItemSize
|
|
695
702
|
}
|
|
696
703
|
),
|
|
697
|
-
ListFooterComponent && /* @__PURE__ */
|
|
704
|
+
ListFooterComponent && /* @__PURE__ */ React2__namespace.createElement(
|
|
698
705
|
reactNative.View,
|
|
699
706
|
{
|
|
700
707
|
style: ListFooterComponentStyle,
|
|
@@ -757,7 +764,7 @@ var ScrollAdjustHandler = class {
|
|
|
757
764
|
}
|
|
758
765
|
};
|
|
759
766
|
var useCombinedRef = (...refs) => {
|
|
760
|
-
const callback =
|
|
767
|
+
const callback = React2.useCallback((element) => {
|
|
761
768
|
for (const ref of refs) {
|
|
762
769
|
if (!ref) {
|
|
763
770
|
continue;
|
|
@@ -976,7 +983,7 @@ function createColumnWrapperStyle(contentContainerStyle) {
|
|
|
976
983
|
}
|
|
977
984
|
}
|
|
978
985
|
var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
|
|
979
|
-
return /* @__PURE__ */
|
|
986
|
+
return /* @__PURE__ */ React2__namespace.createElement(StateProvider, null, /* @__PURE__ */ React2__namespace.createElement(LegendListInner, { ...props, ref: forwardedRef }));
|
|
980
987
|
});
|
|
981
988
|
var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
|
|
982
989
|
const {
|
|
@@ -1019,7 +1026,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1019
1026
|
onViewableItemsChanged,
|
|
1020
1027
|
...rest
|
|
1021
1028
|
} = props;
|
|
1022
|
-
const callbacks =
|
|
1029
|
+
const callbacks = React2.useRef({
|
|
1023
1030
|
onStartReached: rest.onStartReached,
|
|
1024
1031
|
onEndReached: rest.onEndReached
|
|
1025
1032
|
});
|
|
@@ -1027,7 +1034,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1027
1034
|
callbacks.current.onEndReached = rest.onEndReached;
|
|
1028
1035
|
const contentContainerStyle = { ...reactNative.StyleSheet.flatten(contentContainerStyleProp) };
|
|
1029
1036
|
const style = { ...reactNative.StyleSheet.flatten(styleProp) };
|
|
1030
|
-
const stylePaddingTopState = (
|
|
1037
|
+
const stylePaddingTopState = extractPaddingTop(style, contentContainerStyle);
|
|
1031
1038
|
if (style == null ? void 0 : style.paddingTop) {
|
|
1032
1039
|
style.paddingTop = void 0;
|
|
1033
1040
|
}
|
|
@@ -1036,12 +1043,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1036
1043
|
}
|
|
1037
1044
|
const ctx = useStateContext();
|
|
1038
1045
|
ctx.columnWrapperStyle = columnWrapperStyle || (contentContainerStyle ? createColumnWrapperStyle(contentContainerStyle) : void 0);
|
|
1039
|
-
const refScroller =
|
|
1046
|
+
const refScroller = React2.useRef(null);
|
|
1040
1047
|
const combinedRef = useCombinedRef(refScroller, refScrollView);
|
|
1041
1048
|
const estimatedItemSize = estimatedItemSizeProp != null ? estimatedItemSizeProp : DEFAULT_ITEM_SIZE;
|
|
1042
1049
|
const scrollBuffer = (drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE) || 1;
|
|
1043
1050
|
const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (item, index) => index.toString();
|
|
1044
|
-
const refState =
|
|
1051
|
+
const refState = React2.useRef();
|
|
1045
1052
|
const getId = (index) => {
|
|
1046
1053
|
var _a;
|
|
1047
1054
|
const data = (_a = refState.current) == null ? void 0 : _a.data;
|
|
@@ -1076,8 +1083,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1076
1083
|
state.sizes.set(key, size);
|
|
1077
1084
|
return size;
|
|
1078
1085
|
};
|
|
1079
|
-
const calculateOffsetForIndex = (
|
|
1086
|
+
const calculateOffsetForIndex = (indexParam) => {
|
|
1080
1087
|
var _a;
|
|
1088
|
+
const isFromInit = indexParam === void 0;
|
|
1089
|
+
const index = isFromInit ? initialScrollIndex : indexParam;
|
|
1081
1090
|
const data = dataProp;
|
|
1082
1091
|
if (index !== void 0) {
|
|
1083
1092
|
let offset = 0;
|
|
@@ -1096,12 +1105,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1096
1105
|
offset = index * estimatedItemSize;
|
|
1097
1106
|
}
|
|
1098
1107
|
const adjust = peek$(ctx, "containersDidLayout") ? ((_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.getAppliedAdjust()) || 0 : 0;
|
|
1099
|
-
const
|
|
1108
|
+
const stylePaddingTop = isFromInit ? stylePaddingTopState : peek$(ctx, "stylePaddingTop");
|
|
1109
|
+
const topPad = (stylePaddingTop != null ? stylePaddingTop : 0) + peek$(ctx, "headerSize");
|
|
1100
1110
|
return offset / numColumnsProp - adjust + topPad;
|
|
1101
1111
|
}
|
|
1102
1112
|
return 0;
|
|
1103
1113
|
};
|
|
1104
|
-
const initialContentOffset = initialScrollOffset != null ? initialScrollOffset :
|
|
1114
|
+
const initialContentOffset = initialScrollOffset != null ? initialScrollOffset : React2.useMemo(() => calculateOffsetForIndex(void 0), []);
|
|
1105
1115
|
if (!refState.current) {
|
|
1106
1116
|
const initialScrollLength = reactNative.Dimensions.get("window")[horizontal ? "width" : "height"];
|
|
1107
1117
|
refState.current = {
|
|
@@ -1236,7 +1246,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1236
1246
|
});
|
|
1237
1247
|
}
|
|
1238
1248
|
};
|
|
1239
|
-
const addTotalSize =
|
|
1249
|
+
const addTotalSize = React2.useCallback((key, add, totalSizeBelowAnchor) => {
|
|
1240
1250
|
const state = refState.current;
|
|
1241
1251
|
const { indexByKey, anchorElement } = state;
|
|
1242
1252
|
const index = key === null ? 0 : indexByKey.get(key);
|
|
@@ -1343,7 +1353,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1343
1353
|
}
|
|
1344
1354
|
return res;
|
|
1345
1355
|
};
|
|
1346
|
-
const fixGaps =
|
|
1356
|
+
const fixGaps = React2.useCallback(() => {
|
|
1347
1357
|
var _a;
|
|
1348
1358
|
const state = refState.current;
|
|
1349
1359
|
const { data, scrollLength, positions, startBuffered, endBuffered } = state;
|
|
@@ -1408,7 +1418,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1408
1418
|
}
|
|
1409
1419
|
}
|
|
1410
1420
|
}, []);
|
|
1411
|
-
const checkAllSizesKnown =
|
|
1421
|
+
const checkAllSizesKnown = React2.useCallback(() => {
|
|
1412
1422
|
const { startBuffered, endBuffered, sizesKnown } = refState.current;
|
|
1413
1423
|
if (endBuffered !== null) {
|
|
1414
1424
|
let areAllKnown = true;
|
|
@@ -1420,7 +1430,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1420
1430
|
}
|
|
1421
1431
|
return false;
|
|
1422
1432
|
}, []);
|
|
1423
|
-
const calculateItemsInView =
|
|
1433
|
+
const calculateItemsInView = React2.useCallback((isReset) => {
|
|
1424
1434
|
var _a;
|
|
1425
1435
|
const state = refState.current;
|
|
1426
1436
|
const {
|
|
@@ -2024,7 +2034,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2024
2034
|
return result.sort(comparatorDefault);
|
|
2025
2035
|
};
|
|
2026
2036
|
const isFirst = !refState.current.renderItem;
|
|
2027
|
-
const memoizedLastItemKeys =
|
|
2037
|
+
const memoizedLastItemKeys = React2.useMemo(() => {
|
|
2028
2038
|
if (!dataProp.length) return [];
|
|
2029
2039
|
return Array.from(
|
|
2030
2040
|
{ length: Math.min(numColumnsProp, dataProp.length) },
|
|
@@ -2059,7 +2069,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2059
2069
|
refState.current.previousTotalSize = peek$(ctx, "totalSize");
|
|
2060
2070
|
calcTotalSizesAndPositions({ forgetPositions: false });
|
|
2061
2071
|
}
|
|
2062
|
-
|
|
2072
|
+
React2.useEffect(() => {
|
|
2063
2073
|
const didAllocateContainers = doInitialAllocateContainers();
|
|
2064
2074
|
if (!didAllocateContainers) {
|
|
2065
2075
|
checkResetContainers(
|
|
@@ -2068,12 +2078,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2068
2078
|
);
|
|
2069
2079
|
}
|
|
2070
2080
|
}, [dataProp, numColumnsProp]);
|
|
2071
|
-
|
|
2081
|
+
React2.useEffect(() => {
|
|
2072
2082
|
set$(ctx, "extraData", extraData);
|
|
2073
2083
|
}, [extraData]);
|
|
2074
2084
|
refState.current.renderItem = renderItem;
|
|
2075
|
-
|
|
2076
|
-
const getRenderedItem =
|
|
2085
|
+
React2.useEffect(initalizeStateVars, [memoizedLastItemKeys.join(","), numColumnsProp, stylePaddingTopState]);
|
|
2086
|
+
const getRenderedItem = React2.useCallback((key) => {
|
|
2077
2087
|
var _a, _b;
|
|
2078
2088
|
const state = refState.current;
|
|
2079
2089
|
if (!state) {
|
|
@@ -2119,7 +2129,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2119
2129
|
return true;
|
|
2120
2130
|
}
|
|
2121
2131
|
};
|
|
2122
|
-
|
|
2132
|
+
React2.useEffect(() => {
|
|
2123
2133
|
const state = refState.current;
|
|
2124
2134
|
const viewability = setupViewability({
|
|
2125
2135
|
viewabilityConfig,
|
|
@@ -2132,7 +2142,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2132
2142
|
useInit(() => {
|
|
2133
2143
|
doInitialAllocateContainers();
|
|
2134
2144
|
});
|
|
2135
|
-
const updateItemSize =
|
|
2145
|
+
const updateItemSize = React2.useCallback((itemKey, size, fromFixGaps) => {
|
|
2136
2146
|
const state = refState.current;
|
|
2137
2147
|
const {
|
|
2138
2148
|
sizes,
|
|
@@ -2212,7 +2222,16 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2212
2222
|
if (!queuedInitialLayout && checkAllSizesKnown()) {
|
|
2213
2223
|
needsUpdateContainersDidLayout = true;
|
|
2214
2224
|
}
|
|
2215
|
-
|
|
2225
|
+
let isInView = index >= startBuffered && index <= endBuffered;
|
|
2226
|
+
if (!isInView) {
|
|
2227
|
+
const numContainers = ctx.values.get("numContainers");
|
|
2228
|
+
for (let i = 0; i < numContainers; i++) {
|
|
2229
|
+
if (peek$(ctx, `containerItemKey${i}`) === itemKey) {
|
|
2230
|
+
isInView = true;
|
|
2231
|
+
break;
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2216
2235
|
if (needsUpdateContainersDidLayout || !fromFixGaps && needsCalculate && (isInView || !queuedInitialLayout)) {
|
|
2217
2236
|
const scrollVelocity = state.scrollVelocity;
|
|
2218
2237
|
let didCalculate = false;
|
|
@@ -2234,7 +2253,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2234
2253
|
}
|
|
2235
2254
|
}
|
|
2236
2255
|
}, []);
|
|
2237
|
-
const onLayout =
|
|
2256
|
+
const onLayout = React2.useCallback((event) => {
|
|
2238
2257
|
const state = refState.current;
|
|
2239
2258
|
const scrollLength = event.nativeEvent.layout[horizontal ? "width" : "height"];
|
|
2240
2259
|
const didChange = scrollLength !== state.scrollLength;
|
|
@@ -2263,7 +2282,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2263
2282
|
onLayoutProp(event);
|
|
2264
2283
|
}
|
|
2265
2284
|
}, []);
|
|
2266
|
-
const handleScroll =
|
|
2285
|
+
const handleScroll = React2.useCallback(
|
|
2267
2286
|
(event) => {
|
|
2268
2287
|
var _a, _b, _c, _d;
|
|
2269
2288
|
if (((_b = (_a = event.nativeEvent) == null ? void 0 : _a.contentSize) == null ? void 0 : _b.height) === 0 && ((_c = event.nativeEvent.contentSize) == null ? void 0 : _c.width) === 0) {
|
|
@@ -2280,7 +2299,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2280
2299
|
},
|
|
2281
2300
|
[]
|
|
2282
2301
|
);
|
|
2283
|
-
const updateScroll =
|
|
2302
|
+
const updateScroll = React2.useCallback((newScroll) => {
|
|
2284
2303
|
const state = refState.current;
|
|
2285
2304
|
const scrollingToOffset = state.scrollingToOffset;
|
|
2286
2305
|
if (scrollingToOffset !== void 0 && Math.abs(newScroll - scrollingToOffset) < 10) {
|
|
@@ -2334,7 +2353,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2334
2353
|
checkAtBottom();
|
|
2335
2354
|
checkAtTop();
|
|
2336
2355
|
}, []);
|
|
2337
|
-
|
|
2356
|
+
React2.useImperativeHandle(
|
|
2338
2357
|
forwardedRef,
|
|
2339
2358
|
() => {
|
|
2340
2359
|
const scrollIndexIntoView = (options) => {
|
|
@@ -2395,7 +2414,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2395
2414
|
[]
|
|
2396
2415
|
);
|
|
2397
2416
|
if (reactNative.Platform.OS === "web") {
|
|
2398
|
-
|
|
2417
|
+
React2.useEffect(() => {
|
|
2399
2418
|
var _a;
|
|
2400
2419
|
if (initialContentOffset) {
|
|
2401
2420
|
(_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.setDisableAdjust(true);
|
|
@@ -2407,7 +2426,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2407
2426
|
}
|
|
2408
2427
|
}, []);
|
|
2409
2428
|
}
|
|
2410
|
-
return /* @__PURE__ */
|
|
2429
|
+
return /* @__PURE__ */ React2__namespace.createElement(React2__namespace.Fragment, null, /* @__PURE__ */ React2__namespace.createElement(
|
|
2411
2430
|
ListComponent,
|
|
2412
2431
|
{
|
|
2413
2432
|
...rest,
|
|
@@ -2446,7 +2465,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2446
2465
|
maintainVisibleContentPosition,
|
|
2447
2466
|
scrollEventThrottle: reactNative.Platform.OS === "web" ? 16 : void 0,
|
|
2448
2467
|
waitForInitialLayout,
|
|
2449
|
-
refreshControl: refreshControl != null ? refreshControl : onRefresh && /* @__PURE__ */
|
|
2468
|
+
refreshControl: refreshControl != null ? refreshControl : onRefresh && /* @__PURE__ */ React2__namespace.createElement(
|
|
2450
2469
|
reactNative.RefreshControl,
|
|
2451
2470
|
{
|
|
2452
2471
|
refreshing: !!refreshing,
|
|
@@ -2457,7 +2476,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2457
2476
|
style,
|
|
2458
2477
|
contentContainerStyle
|
|
2459
2478
|
}
|
|
2460
|
-
), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */
|
|
2479
|
+
), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */ React2__namespace.createElement(DebugView, { state: refState.current }));
|
|
2461
2480
|
});
|
|
2462
2481
|
|
|
2463
2482
|
exports.LegendList = LegendList;
|