@legendapp/list 1.0.0-beta.51 → 1.0.0-beta.53
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/README.md +11 -12
- package/index.d.mts +2 -4
- package/index.d.ts +2 -4
- package/index.js +112 -99
- package/index.mjs +64 -51
- package/keyboard-controller.d.mts +132 -132
- package/keyboard-controller.d.ts +132 -132
- package/keyboard-controller.js +13 -5
- package/keyboard-controller.mjs +13 -5
- 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
|
|
|
6
6
|
function _interopNamespace(e) {
|
|
@@ -21,12 +21,12 @@ function _interopNamespace(e) {
|
|
|
21
21
|
return Object.freeze(n);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
|
|
25
25
|
|
|
26
26
|
// src/LegendList.tsx
|
|
27
|
-
var ContextState =
|
|
27
|
+
var ContextState = React2__namespace.createContext(null);
|
|
28
28
|
function StateProvider({ children }) {
|
|
29
|
-
const [value] =
|
|
29
|
+
const [value] = React2__namespace.useState(() => ({
|
|
30
30
|
listeners: /* @__PURE__ */ new Map(),
|
|
31
31
|
values: /* @__PURE__ */ new Map([
|
|
32
32
|
["paddingTop", 0],
|
|
@@ -41,10 +41,10 @@ function StateProvider({ children }) {
|
|
|
41
41
|
columnWrapperStyle: void 0,
|
|
42
42
|
viewRefs: /* @__PURE__ */ new Map()
|
|
43
43
|
}));
|
|
44
|
-
return /* @__PURE__ */
|
|
44
|
+
return /* @__PURE__ */ React2__namespace.createElement(ContextState.Provider, { value }, children);
|
|
45
45
|
}
|
|
46
46
|
function useStateContext() {
|
|
47
|
-
return
|
|
47
|
+
return React2__namespace.useContext(ContextState);
|
|
48
48
|
}
|
|
49
49
|
function createSelectorFunctions(ctx, signalName) {
|
|
50
50
|
return {
|
|
@@ -53,9 +53,9 @@ function createSelectorFunctions(ctx, signalName) {
|
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
function use$(signalName) {
|
|
56
|
-
const ctx =
|
|
57
|
-
const { subscribe, get } =
|
|
58
|
-
const value =
|
|
56
|
+
const ctx = React2__namespace.useContext(ContextState);
|
|
57
|
+
const { subscribe, get } = React2__namespace.useMemo(() => createSelectorFunctions(ctx, signalName), []);
|
|
58
|
+
const value = React2.useSyncExternalStore(subscribe, get);
|
|
59
59
|
return value;
|
|
60
60
|
}
|
|
61
61
|
function listen$(ctx, signalName, cb) {
|
|
@@ -95,9 +95,9 @@ function getContentSize(ctx) {
|
|
|
95
95
|
|
|
96
96
|
// src/DebugView.tsx
|
|
97
97
|
var DebugRow = ({ children }) => {
|
|
98
|
-
return /* @__PURE__ */
|
|
98
|
+
return /* @__PURE__ */ React2__namespace.createElement(reactNative.View, { style: { flexDirection: "row", alignItems: "center", justifyContent: "space-between" } }, children);
|
|
99
99
|
};
|
|
100
|
-
var DebugView =
|
|
100
|
+
var DebugView = React2__namespace.memo(function DebugView2({ state }) {
|
|
101
101
|
const ctx = useStateContext();
|
|
102
102
|
const totalSize = use$("totalSize") || 0;
|
|
103
103
|
const totalSizeWithScrollAdjust = use$("totalSizeWithScrollAdjust") || 0;
|
|
@@ -105,13 +105,13 @@ var DebugView = React6.memo(function DebugView2({ state }) {
|
|
|
105
105
|
const rawScroll = use$("debugRawScroll") || 0;
|
|
106
106
|
const scroll = use$("debugComputedScroll") || 0;
|
|
107
107
|
const contentSize = getContentSize(ctx);
|
|
108
|
-
const [, forceUpdate] =
|
|
108
|
+
const [, forceUpdate] = React2.useReducer((x) => x + 1, 0);
|
|
109
109
|
use$("numContainers");
|
|
110
110
|
use$("numContainersPooled");
|
|
111
111
|
useInterval(() => {
|
|
112
112
|
forceUpdate();
|
|
113
113
|
}, 100);
|
|
114
|
-
return /* @__PURE__ */
|
|
114
|
+
return /* @__PURE__ */ React2__namespace.createElement(
|
|
115
115
|
reactNative.View,
|
|
116
116
|
{
|
|
117
117
|
style: {
|
|
@@ -127,19 +127,19 @@ var DebugView = React6.memo(function DebugView2({ state }) {
|
|
|
127
127
|
},
|
|
128
128
|
pointerEvents: "none"
|
|
129
129
|
},
|
|
130
|
-
/* @__PURE__ */
|
|
131
|
-
/* @__PURE__ */
|
|
132
|
-
/* @__PURE__ */
|
|
133
|
-
/* @__PURE__ */
|
|
134
|
-
/* @__PURE__ */
|
|
135
|
-
/* @__PURE__ */
|
|
136
|
-
/* @__PURE__ */
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
-
/* @__PURE__ */
|
|
130
|
+
/* @__PURE__ */ React2__namespace.createElement(DebugRow, null, /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, "TotalSize:"), /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, totalSize.toFixed(2))),
|
|
131
|
+
/* @__PURE__ */ React2__namespace.createElement(DebugRow, null, /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, "ContentSize:"), /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, contentSize.toFixed(2))),
|
|
132
|
+
/* @__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))),
|
|
133
|
+
/* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null),
|
|
134
|
+
/* @__PURE__ */ React2__namespace.createElement(DebugRow, null, /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, "ScrollAdjust:"), /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, scrollAdjust.toFixed(2))),
|
|
135
|
+
/* @__PURE__ */ React2__namespace.createElement(DebugRow, null, /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, "TotalSizeReal: "), /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, totalSizeWithScrollAdjust.toFixed(2))),
|
|
136
|
+
/* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null),
|
|
137
|
+
/* @__PURE__ */ React2__namespace.createElement(DebugRow, null, /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, "RawScroll: "), /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, rawScroll.toFixed(2))),
|
|
138
|
+
/* @__PURE__ */ React2__namespace.createElement(DebugRow, null, /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, "ComputedScroll: "), /* @__PURE__ */ React2__namespace.createElement(reactNative.Text, null, scroll.toFixed(2)))
|
|
139
139
|
);
|
|
140
140
|
});
|
|
141
141
|
function useInterval(callback, delay) {
|
|
142
|
-
|
|
142
|
+
React2.useEffect(() => {
|
|
143
143
|
const interval = setInterval(callback, delay);
|
|
144
144
|
return () => clearInterval(interval);
|
|
145
145
|
}, [delay]);
|
|
@@ -161,7 +161,7 @@ function roundSize(size) {
|
|
|
161
161
|
}
|
|
162
162
|
var symbolFirst = Symbol();
|
|
163
163
|
function useInit(cb) {
|
|
164
|
-
const refValue =
|
|
164
|
+
const refValue = React2.useRef(symbolFirst);
|
|
165
165
|
if (refValue.current === symbolFirst) {
|
|
166
166
|
refValue.current = cb();
|
|
167
167
|
}
|
|
@@ -169,10 +169,10 @@ function useInit(cb) {
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
// src/ContextContainer.ts
|
|
172
|
-
var ContextContainer =
|
|
172
|
+
var ContextContainer = React2.createContext(null);
|
|
173
173
|
function useViewability(callback, configId) {
|
|
174
174
|
const ctx = useStateContext();
|
|
175
|
-
const { containerId } =
|
|
175
|
+
const { containerId } = React2.useContext(ContextContainer);
|
|
176
176
|
const key = containerId + (configId != null ? configId : "");
|
|
177
177
|
useInit(() => {
|
|
178
178
|
const value = ctx.mapViewabilityValues.get(key);
|
|
@@ -181,7 +181,7 @@ function useViewability(callback, configId) {
|
|
|
181
181
|
}
|
|
182
182
|
});
|
|
183
183
|
ctx.mapViewabilityCallbacks.set(key, callback);
|
|
184
|
-
|
|
184
|
+
React2.useEffect(
|
|
185
185
|
() => () => {
|
|
186
186
|
ctx.mapViewabilityCallbacks.delete(key);
|
|
187
187
|
},
|
|
@@ -190,7 +190,7 @@ function useViewability(callback, configId) {
|
|
|
190
190
|
}
|
|
191
191
|
function useViewabilityAmount(callback) {
|
|
192
192
|
const ctx = useStateContext();
|
|
193
|
-
const { containerId } =
|
|
193
|
+
const { containerId } = React2.useContext(ContextContainer);
|
|
194
194
|
useInit(() => {
|
|
195
195
|
const value = ctx.mapViewabilityAmountValues.get(containerId);
|
|
196
196
|
if (value) {
|
|
@@ -198,7 +198,7 @@ function useViewabilityAmount(callback) {
|
|
|
198
198
|
}
|
|
199
199
|
});
|
|
200
200
|
ctx.mapViewabilityAmountCallbacks.set(containerId, callback);
|
|
201
|
-
|
|
201
|
+
React2.useEffect(
|
|
202
202
|
() => () => {
|
|
203
203
|
ctx.mapViewabilityAmountCallbacks.delete(containerId);
|
|
204
204
|
},
|
|
@@ -206,12 +206,12 @@ function useViewabilityAmount(callback) {
|
|
|
206
206
|
);
|
|
207
207
|
}
|
|
208
208
|
function useRecyclingEffect(effect) {
|
|
209
|
-
const { index, value } =
|
|
210
|
-
const prevValues =
|
|
209
|
+
const { index, value } = React2.useContext(ContextContainer);
|
|
210
|
+
const prevValues = React2.useRef({
|
|
211
211
|
prevIndex: void 0,
|
|
212
212
|
prevItem: void 0
|
|
213
213
|
});
|
|
214
|
-
|
|
214
|
+
React2.useEffect(() => {
|
|
215
215
|
let ret = void 0;
|
|
216
216
|
if (prevValues.current.prevIndex !== void 0 && prevValues.current.prevItem !== void 0) {
|
|
217
217
|
ret = effect({
|
|
@@ -229,12 +229,12 @@ function useRecyclingEffect(effect) {
|
|
|
229
229
|
}, [index, value]);
|
|
230
230
|
}
|
|
231
231
|
function useRecyclingState(valueOrFun) {
|
|
232
|
-
const { index, value, itemKey, triggerLayout } =
|
|
233
|
-
const refState =
|
|
232
|
+
const { index, value, itemKey, triggerLayout } = React2.useContext(ContextContainer);
|
|
233
|
+
const refState = React2.useRef({
|
|
234
234
|
itemKey: null,
|
|
235
235
|
value: null
|
|
236
236
|
});
|
|
237
|
-
const [_, setRenderNum] =
|
|
237
|
+
const [_, setRenderNum] = React2.useState(0);
|
|
238
238
|
if (refState.current.itemKey !== itemKey) {
|
|
239
239
|
refState.current.itemKey = itemKey;
|
|
240
240
|
refState.current.value = isFunction(valueOrFun) ? valueOrFun({
|
|
@@ -244,7 +244,7 @@ function useRecyclingState(valueOrFun) {
|
|
|
244
244
|
prevItem: void 0
|
|
245
245
|
}) : valueOrFun;
|
|
246
246
|
}
|
|
247
|
-
const setState =
|
|
247
|
+
const setState = React2.useCallback(
|
|
248
248
|
(newState) => {
|
|
249
249
|
refState.current.value = isFunction(newState) ? newState(refState.current.value) : newState;
|
|
250
250
|
setRenderNum((v) => v + 1);
|
|
@@ -254,8 +254,8 @@ function useRecyclingState(valueOrFun) {
|
|
|
254
254
|
);
|
|
255
255
|
return [refState.current.value, setState];
|
|
256
256
|
}
|
|
257
|
-
var LeanViewComponent =
|
|
258
|
-
return
|
|
257
|
+
var LeanViewComponent = React2__namespace.forwardRef((props, ref) => {
|
|
258
|
+
return React2__namespace.createElement("RCTView", { ...props, ref });
|
|
259
259
|
});
|
|
260
260
|
LeanViewComponent.displayName = "RCTView";
|
|
261
261
|
var LeanView = reactNative.Platform.OS === "android" || reactNative.Platform.OS === "ios" ? LeanViewComponent : reactNative.View;
|
|
@@ -290,9 +290,9 @@ var Container = ({
|
|
|
290
290
|
const itemKey = use$(`containerItemKey${id}`);
|
|
291
291
|
const data = use$(`containerItemData${id}`);
|
|
292
292
|
const extraData = use$("extraData");
|
|
293
|
-
const refLastSize =
|
|
294
|
-
const ref =
|
|
295
|
-
const [layoutRenderCount, forceLayoutRender] =
|
|
293
|
+
const refLastSize = React2.useRef();
|
|
294
|
+
const ref = React2.useRef(null);
|
|
295
|
+
const [layoutRenderCount, forceLayoutRender] = React2.useState(0);
|
|
296
296
|
const otherAxisPos = numColumns > 1 ? `${(column - 1) / numColumns * 100}%` : 0;
|
|
297
297
|
const otherAxisSize = numColumns > 1 ? `${1 / numColumns * 100}%` : void 0;
|
|
298
298
|
let paddingStyles;
|
|
@@ -326,12 +326,12 @@ var Container = ({
|
|
|
326
326
|
top: position.relativeCoordinate,
|
|
327
327
|
...paddingStyles || {}
|
|
328
328
|
};
|
|
329
|
-
const renderedItemInfo =
|
|
329
|
+
const renderedItemInfo = React2.useMemo(
|
|
330
330
|
() => itemKey !== void 0 ? getRenderedItem(itemKey) : null,
|
|
331
331
|
[itemKey, data, extraData]
|
|
332
332
|
);
|
|
333
333
|
const { index, renderedItem } = renderedItemInfo || {};
|
|
334
|
-
const triggerLayout =
|
|
334
|
+
const triggerLayout = React2.useCallback(() => {
|
|
335
335
|
forceLayoutRender((v) => v + 1);
|
|
336
336
|
}, []);
|
|
337
337
|
const onLayout = (event) => {
|
|
@@ -343,7 +343,7 @@ var Container = ({
|
|
|
343
343
|
}
|
|
344
344
|
};
|
|
345
345
|
if (IsNewArchitecture) {
|
|
346
|
-
|
|
346
|
+
React2.useLayoutEffect(() => {
|
|
347
347
|
var _a, _b;
|
|
348
348
|
if (itemKey !== void 0) {
|
|
349
349
|
const measured = (_b = (_a = ref.current) == null ? void 0 : _a.unstable_getBoundingClientRect) == null ? void 0 : _b.call(_a);
|
|
@@ -356,7 +356,7 @@ var Container = ({
|
|
|
356
356
|
}
|
|
357
357
|
}, [itemKey, layoutRenderCount]);
|
|
358
358
|
} else {
|
|
359
|
-
|
|
359
|
+
React2.useEffect(() => {
|
|
360
360
|
if (itemKey) {
|
|
361
361
|
const timeout = setTimeout(() => {
|
|
362
362
|
if (refLastSize.current) {
|
|
@@ -369,25 +369,25 @@ var Container = ({
|
|
|
369
369
|
}
|
|
370
370
|
}, [itemKey]);
|
|
371
371
|
}
|
|
372
|
-
const contextValue =
|
|
372
|
+
const contextValue = React2.useMemo(() => {
|
|
373
373
|
ctx.viewRefs.set(id, ref);
|
|
374
374
|
return { containerId: id, itemKey, index, value: data, triggerLayout };
|
|
375
375
|
}, [id, itemKey, index, data]);
|
|
376
|
-
const contentFragment = /* @__PURE__ */
|
|
376
|
+
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 })));
|
|
377
377
|
if (maintainVisibleContentPosition) {
|
|
378
378
|
const anchorStyle = position.type === "top" ? { position: "absolute", top: 0, left: 0, right: 0 } : { position: "absolute", bottom: 0, left: 0, right: 0 };
|
|
379
379
|
if (ENABLE_DEVMODE) {
|
|
380
380
|
anchorStyle.borderColor = position.type === "top" ? "red" : "blue";
|
|
381
381
|
anchorStyle.borderWidth = 1;
|
|
382
382
|
}
|
|
383
|
-
return /* @__PURE__ */
|
|
383
|
+
return /* @__PURE__ */ React2__namespace.default.createElement(LeanView, { style }, /* @__PURE__ */ React2__namespace.default.createElement(LeanView, { style: anchorStyle, onLayout, ref }, contentFragment, ENABLE_DEVMODE && /* @__PURE__ */ React2__namespace.default.createElement(reactNative.Text, { style: { position: "absolute", top: 0, left: 0, zIndex: 1e3 } }, position.top)));
|
|
384
384
|
}
|
|
385
|
-
return /* @__PURE__ */
|
|
385
|
+
return /* @__PURE__ */ React2__namespace.default.createElement(LeanView, { style, onLayout, ref }, contentFragment);
|
|
386
386
|
};
|
|
387
|
-
var typedForwardRef =
|
|
388
|
-
var typedMemo =
|
|
387
|
+
var typedForwardRef = React2.forwardRef;
|
|
388
|
+
var typedMemo = React2.memo;
|
|
389
389
|
var useAnimatedValue = (initialValue) => {
|
|
390
|
-
return
|
|
390
|
+
return React2.useRef(new reactNative.Animated.Value(initialValue)).current;
|
|
391
391
|
};
|
|
392
392
|
|
|
393
393
|
// src/useValue$.ts
|
|
@@ -395,7 +395,7 @@ function useValue$(key, getValue, useMicrotask) {
|
|
|
395
395
|
var _a;
|
|
396
396
|
const ctx = useStateContext();
|
|
397
397
|
const animValue = useAnimatedValue((_a = getValue ? getValue(peek$(ctx, key)) : peek$(ctx, key)) != null ? _a : 0);
|
|
398
|
-
|
|
398
|
+
React2.useMemo(() => {
|
|
399
399
|
let newValue = void 0;
|
|
400
400
|
listen$(ctx, key, (v) => {
|
|
401
401
|
if (useMicrotask && newValue === void 0) {
|
|
@@ -435,7 +435,7 @@ var Containers = typedMemo(function Containers2({
|
|
|
435
435
|
const containers = [];
|
|
436
436
|
for (let i = 0; i < numContainers; i++) {
|
|
437
437
|
containers.push(
|
|
438
|
-
/* @__PURE__ */
|
|
438
|
+
/* @__PURE__ */ React2__namespace.createElement(
|
|
439
439
|
Container,
|
|
440
440
|
{
|
|
441
441
|
id: i,
|
|
@@ -464,16 +464,16 @@ var Containers = typedMemo(function Containers2({
|
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
|
-
return /* @__PURE__ */
|
|
467
|
+
return /* @__PURE__ */ React2__namespace.createElement(reactNative.Animated.View, { style }, containers);
|
|
468
468
|
});
|
|
469
469
|
|
|
470
470
|
// src/ListComponent.tsx
|
|
471
471
|
var getComponent = (Component) => {
|
|
472
|
-
if (
|
|
472
|
+
if (React2__namespace.isValidElement(Component)) {
|
|
473
473
|
return Component;
|
|
474
474
|
}
|
|
475
475
|
if (Component) {
|
|
476
|
-
return /* @__PURE__ */
|
|
476
|
+
return /* @__PURE__ */ React2__namespace.createElement(Component, null);
|
|
477
477
|
}
|
|
478
478
|
return null;
|
|
479
479
|
};
|
|
@@ -481,12 +481,12 @@ var PaddingAndAdjust = () => {
|
|
|
481
481
|
const animPaddingTop = useValue$("paddingTop", (v) => v, true);
|
|
482
482
|
const animScrollAdjust = useValue$("scrollAdjust", (v) => v, true);
|
|
483
483
|
const additionalSize = { marginTop: animScrollAdjust, paddingTop: animPaddingTop };
|
|
484
|
-
return /* @__PURE__ */
|
|
484
|
+
return /* @__PURE__ */ React2__namespace.createElement(reactNative.Animated.View, { style: additionalSize });
|
|
485
485
|
};
|
|
486
486
|
var PaddingAndAdjustDevMode = () => {
|
|
487
487
|
const animPaddingTop = useValue$("paddingTop", (v) => v, true);
|
|
488
488
|
const animScrollAdjust = useValue$("scrollAdjust", (v) => v, true);
|
|
489
|
-
return /* @__PURE__ */
|
|
489
|
+
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(
|
|
490
490
|
reactNative.Animated.View,
|
|
491
491
|
{
|
|
492
492
|
style: {
|
|
@@ -498,7 +498,7 @@ var PaddingAndAdjustDevMode = () => {
|
|
|
498
498
|
backgroundColor: "green"
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
|
-
), /* @__PURE__ */
|
|
501
|
+
), /* @__PURE__ */ React2__namespace.createElement(
|
|
502
502
|
reactNative.Animated.View,
|
|
503
503
|
{
|
|
504
504
|
style: {
|
|
@@ -510,7 +510,7 @@ var PaddingAndAdjustDevMode = () => {
|
|
|
510
510
|
backgroundColor: "lightblue"
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
|
-
), /* @__PURE__ */
|
|
513
|
+
), /* @__PURE__ */ React2__namespace.createElement(
|
|
514
514
|
reactNative.Animated.View,
|
|
515
515
|
{
|
|
516
516
|
style: {
|
|
@@ -555,11 +555,11 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
555
555
|
...rest
|
|
556
556
|
}) {
|
|
557
557
|
const ctx = useStateContext();
|
|
558
|
-
const ScrollComponent = renderScrollComponent ?
|
|
559
|
-
() =>
|
|
558
|
+
const ScrollComponent = renderScrollComponent ? React2.useMemo(
|
|
559
|
+
() => React2__namespace.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
|
|
560
560
|
[renderScrollComponent]
|
|
561
561
|
) : reactNative.ScrollView;
|
|
562
|
-
return /* @__PURE__ */
|
|
562
|
+
return /* @__PURE__ */ React2__namespace.createElement(
|
|
563
563
|
ScrollComponent,
|
|
564
564
|
{
|
|
565
565
|
...rest,
|
|
@@ -577,8 +577,8 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
577
577
|
contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
|
|
578
578
|
ref: refScrollView
|
|
579
579
|
},
|
|
580
|
-
!ListEmptyComponent && (ENABLE_DEVMODE ? /* @__PURE__ */
|
|
581
|
-
ListHeaderComponent && /* @__PURE__ */
|
|
580
|
+
!ListEmptyComponent && (ENABLE_DEVMODE ? /* @__PURE__ */ React2__namespace.createElement(PaddingAndAdjustDevMode, null) : /* @__PURE__ */ React2__namespace.createElement(PaddingAndAdjust, null)),
|
|
581
|
+
ListHeaderComponent && /* @__PURE__ */ React2__namespace.createElement(
|
|
582
582
|
reactNative.View,
|
|
583
583
|
{
|
|
584
584
|
style: ListHeaderComponentStyle,
|
|
@@ -590,7 +590,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
590
590
|
getComponent(ListHeaderComponent)
|
|
591
591
|
),
|
|
592
592
|
ListEmptyComponent && getComponent(ListEmptyComponent),
|
|
593
|
-
/* @__PURE__ */
|
|
593
|
+
/* @__PURE__ */ React2__namespace.createElement(
|
|
594
594
|
Containers,
|
|
595
595
|
{
|
|
596
596
|
horizontal,
|
|
@@ -601,7 +601,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
601
601
|
updateItemSize
|
|
602
602
|
}
|
|
603
603
|
),
|
|
604
|
-
ListFooterComponent && /* @__PURE__ */
|
|
604
|
+
ListFooterComponent && /* @__PURE__ */ React2__namespace.createElement(
|
|
605
605
|
reactNative.View,
|
|
606
606
|
{
|
|
607
607
|
style: ListFooterComponentStyle,
|
|
@@ -664,7 +664,7 @@ var ScrollAdjustHandler = class {
|
|
|
664
664
|
}
|
|
665
665
|
};
|
|
666
666
|
var useCombinedRef = (...refs) => {
|
|
667
|
-
const callback =
|
|
667
|
+
const callback = React2.useCallback((element) => {
|
|
668
668
|
for (const ref of refs) {
|
|
669
669
|
if (!ref) {
|
|
670
670
|
continue;
|
|
@@ -883,7 +883,7 @@ function createColumnWrapperStyle(contentContainerStyle) {
|
|
|
883
883
|
}
|
|
884
884
|
}
|
|
885
885
|
var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
|
|
886
|
-
return /* @__PURE__ */
|
|
886
|
+
return /* @__PURE__ */ React2__namespace.createElement(StateProvider, null, /* @__PURE__ */ React2__namespace.createElement(LegendListInner, { ...props, ref: forwardedRef }));
|
|
887
887
|
});
|
|
888
888
|
var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
|
|
889
889
|
const {
|
|
@@ -926,7 +926,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
926
926
|
onViewableItemsChanged,
|
|
927
927
|
...rest
|
|
928
928
|
} = props;
|
|
929
|
-
const callbacks =
|
|
929
|
+
const callbacks = React2.useRef({
|
|
930
930
|
onStartReached: rest.onStartReached,
|
|
931
931
|
onEndReached: rest.onEndReached
|
|
932
932
|
});
|
|
@@ -943,11 +943,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
943
943
|
}
|
|
944
944
|
const ctx = useStateContext();
|
|
945
945
|
ctx.columnWrapperStyle = columnWrapperStyle || (contentContainerStyle ? createColumnWrapperStyle(contentContainerStyle) : void 0);
|
|
946
|
-
const refScroller =
|
|
946
|
+
const refScroller = React2.useRef(null);
|
|
947
947
|
const combinedRef = useCombinedRef(refScroller, refScrollView);
|
|
948
948
|
const scrollBuffer = (drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE) || 1;
|
|
949
949
|
const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (item, index) => index.toString();
|
|
950
|
-
const refState =
|
|
950
|
+
const refState = React2.useRef();
|
|
951
951
|
const getId = (index) => {
|
|
952
952
|
var _a;
|
|
953
953
|
const data = (_a = refState.current) == null ? void 0 : _a.data;
|
|
@@ -964,6 +964,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
964
964
|
return sizeKnown;
|
|
965
965
|
}
|
|
966
966
|
let size;
|
|
967
|
+
if (getEstimatedItemSize) {
|
|
968
|
+
size = getEstimatedItemSize(index, data);
|
|
969
|
+
}
|
|
967
970
|
if (size === void 0 && useAverageSize) {
|
|
968
971
|
const itemType = "";
|
|
969
972
|
const average = state.averageSizes[itemType];
|
|
@@ -971,12 +974,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
971
974
|
size = roundSize(average.avg);
|
|
972
975
|
}
|
|
973
976
|
}
|
|
974
|
-
const sizePrevious = state.sizesKnown.get(key);
|
|
975
|
-
if (sizePrevious !== void 0) {
|
|
976
|
-
return sizePrevious;
|
|
977
|
-
}
|
|
978
977
|
if (size === void 0) {
|
|
979
|
-
size =
|
|
978
|
+
size = estimatedItemSize != null ? estimatedItemSize : DEFAULT_ITEM_SIZE;
|
|
980
979
|
}
|
|
981
980
|
state.sizes.set(key, size);
|
|
982
981
|
return size;
|
|
@@ -1004,7 +1003,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1004
1003
|
}
|
|
1005
1004
|
return 0;
|
|
1006
1005
|
};
|
|
1007
|
-
const initialContentOffset = initialScrollOffset != null ? initialScrollOffset :
|
|
1006
|
+
const initialContentOffset = initialScrollOffset != null ? initialScrollOffset : React2.useMemo(calculateOffsetForIndex, []);
|
|
1008
1007
|
if (!refState.current) {
|
|
1009
1008
|
const initialScrollLength = reactNative.Dimensions.get("window")[horizontal ? "width" : "height"];
|
|
1010
1009
|
refState.current = {
|
|
@@ -1115,6 +1114,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1115
1114
|
state.scrollAdjustHandler.setDisableAdjust(true);
|
|
1116
1115
|
state.scrollingToOffset = firstIndexScrollPostion;
|
|
1117
1116
|
scrollTo(firstIndexScrollPostion, animated);
|
|
1117
|
+
if (!animated) {
|
|
1118
|
+
requestAnimationFrame(() => {
|
|
1119
|
+
state.scrollingToOffset = void 0;
|
|
1120
|
+
state.scrollAdjustHandler.setDisableAdjust(false);
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1118
1123
|
};
|
|
1119
1124
|
const setDidLayout = () => {
|
|
1120
1125
|
refState.current.queuedInitialLayout = true;
|
|
@@ -1132,7 +1137,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1132
1137
|
});
|
|
1133
1138
|
}
|
|
1134
1139
|
};
|
|
1135
|
-
const addTotalSize =
|
|
1140
|
+
const addTotalSize = React2.useCallback((key, add, totalSizeBelowAnchor) => {
|
|
1136
1141
|
const state = refState.current;
|
|
1137
1142
|
const { indexByKey, anchorElement } = state;
|
|
1138
1143
|
const index = key === null ? 0 : indexByKey.get(key);
|
|
@@ -1226,7 +1231,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1226
1231
|
}
|
|
1227
1232
|
return res;
|
|
1228
1233
|
};
|
|
1229
|
-
const fixGaps =
|
|
1234
|
+
const fixGaps = React2.useCallback(() => {
|
|
1230
1235
|
var _a;
|
|
1231
1236
|
const state = refState.current;
|
|
1232
1237
|
const { data, scrollLength, positions, startBuffered, endBuffered } = state;
|
|
@@ -1291,7 +1296,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1291
1296
|
}
|
|
1292
1297
|
}
|
|
1293
1298
|
}, []);
|
|
1294
|
-
const calculateItemsInView =
|
|
1299
|
+
const calculateItemsInView = React2.useCallback(() => {
|
|
1295
1300
|
var _a;
|
|
1296
1301
|
const state = refState.current;
|
|
1297
1302
|
const {
|
|
@@ -1526,7 +1531,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1526
1531
|
if (item !== void 0) {
|
|
1527
1532
|
const id = getId(itemIndex);
|
|
1528
1533
|
if (itemKey !== id || itemIndex < startBuffered || itemIndex > endBuffered) {
|
|
1529
|
-
const prevPos = peek$(ctx, `containerPosition${i}`)
|
|
1534
|
+
const prevPos = peek$(ctx, `containerPosition${i}`);
|
|
1530
1535
|
const pos = positions.get(id) || 0;
|
|
1531
1536
|
const size = getItemSize(id, itemIndex, data[i]);
|
|
1532
1537
|
if (pos + size >= scroll && pos <= scrollBottom || prevPos + size >= scroll && prevPos <= scrollBottom) {
|
|
@@ -1593,6 +1598,14 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1593
1598
|
alignItemsPaddingTop
|
|
1594
1599
|
}) => {
|
|
1595
1600
|
if (stylePaddingTop !== void 0) {
|
|
1601
|
+
const prevStylePaddingTop = peek$(ctx, "stylePaddingTop") || 0;
|
|
1602
|
+
if (stylePaddingTop < prevStylePaddingTop) {
|
|
1603
|
+
const prevTotalSize = peek$(ctx, "totalSizeWithScrollAdjust") || 0;
|
|
1604
|
+
set$(ctx, "totalSizeWithScrollAdjust", prevTotalSize + prevStylePaddingTop);
|
|
1605
|
+
setTimeout(() => {
|
|
1606
|
+
set$(ctx, "totalSizeWithScrollAdjust", prevTotalSize);
|
|
1607
|
+
}, 16);
|
|
1608
|
+
}
|
|
1596
1609
|
set$(ctx, "stylePaddingTop", stylePaddingTop);
|
|
1597
1610
|
}
|
|
1598
1611
|
if (alignItemsPaddingTop !== void 0) {
|
|
@@ -1722,8 +1735,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1722
1735
|
for (let i = 0; i < numContainers; i++) {
|
|
1723
1736
|
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
1724
1737
|
if (!keyExtractorProp || itemKey && state.indexByKey.get(itemKey) === void 0) {
|
|
1725
|
-
set$(ctx, `containerItemKey${i}`,
|
|
1726
|
-
set$(ctx, `containerItemData${i}`,
|
|
1738
|
+
set$(ctx, `containerItemKey${i}`, null);
|
|
1739
|
+
set$(ctx, `containerItemData${i}`, null);
|
|
1727
1740
|
set$(ctx, `containerPosition${i}`, ANCHORED_POSITION_OUT_OF_VIEW);
|
|
1728
1741
|
set$(ctx, `containerColumn${i}`, -1);
|
|
1729
1742
|
}
|
|
@@ -1829,7 +1842,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1829
1842
|
addTotalSize(null, totalSize, totalSizeBelowIndex);
|
|
1830
1843
|
};
|
|
1831
1844
|
const isFirst = !refState.current.renderItem;
|
|
1832
|
-
const memoizedLastItemKeys =
|
|
1845
|
+
const memoizedLastItemKeys = React2.useMemo(() => {
|
|
1833
1846
|
if (!dataProp.length) return [];
|
|
1834
1847
|
return Array.from(
|
|
1835
1848
|
{ length: Math.min(numColumnsProp, dataProp.length) },
|
|
@@ -1863,7 +1876,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1863
1876
|
}
|
|
1864
1877
|
calcTotalSizesAndPositions({ forgetPositions: false });
|
|
1865
1878
|
}
|
|
1866
|
-
|
|
1879
|
+
React2.useEffect(() => {
|
|
1867
1880
|
const didAllocateContainers = doInitialAllocateContainers();
|
|
1868
1881
|
if (!didAllocateContainers) {
|
|
1869
1882
|
checkResetContainers(
|
|
@@ -1872,12 +1885,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1872
1885
|
);
|
|
1873
1886
|
}
|
|
1874
1887
|
}, [isFirst, dataProp, numColumnsProp]);
|
|
1875
|
-
|
|
1888
|
+
React2.useEffect(() => {
|
|
1876
1889
|
set$(ctx, "extraData", extraData);
|
|
1877
1890
|
}, [extraData]);
|
|
1878
1891
|
refState.current.renderItem = renderItem;
|
|
1879
|
-
|
|
1880
|
-
const getRenderedItem =
|
|
1892
|
+
React2.useEffect(initalizeStateVars, [memoizedLastItemKeys.join(","), numColumnsProp, stylePaddingTopState]);
|
|
1893
|
+
const getRenderedItem = React2.useCallback((key) => {
|
|
1881
1894
|
var _a, _b;
|
|
1882
1895
|
const state = refState.current;
|
|
1883
1896
|
if (!state) {
|
|
@@ -1947,7 +1960,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1947
1960
|
return true;
|
|
1948
1961
|
}
|
|
1949
1962
|
};
|
|
1950
|
-
|
|
1963
|
+
React2.useEffect(() => {
|
|
1951
1964
|
const state = refState.current;
|
|
1952
1965
|
const viewability = setupViewability({
|
|
1953
1966
|
viewabilityConfig,
|
|
@@ -1960,7 +1973,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1960
1973
|
useInit(() => {
|
|
1961
1974
|
doInitialAllocateContainers();
|
|
1962
1975
|
});
|
|
1963
|
-
const updateItemSize =
|
|
1976
|
+
const updateItemSize = React2.useCallback((itemKey, size, fromFixGaps) => {
|
|
1964
1977
|
const state = refState.current;
|
|
1965
1978
|
const { sizes, indexByKey, sizesKnown, data, rowHeights, startBuffered, endBuffered, averageSizes } = state;
|
|
1966
1979
|
if (!data) {
|
|
@@ -2053,7 +2066,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2053
2066
|
}
|
|
2054
2067
|
}
|
|
2055
2068
|
}, []);
|
|
2056
|
-
const onLayout =
|
|
2069
|
+
const onLayout = React2.useCallback((event) => {
|
|
2057
2070
|
const state = refState.current;
|
|
2058
2071
|
const scrollLength = event.nativeEvent.layout[horizontal ? "width" : "height"];
|
|
2059
2072
|
const didChange = scrollLength !== state.scrollLength;
|
|
@@ -2082,7 +2095,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2082
2095
|
onLayoutProp(event);
|
|
2083
2096
|
}
|
|
2084
2097
|
}, []);
|
|
2085
|
-
const handleScroll =
|
|
2098
|
+
const handleScroll = React2.useCallback(
|
|
2086
2099
|
(event, fromSelf) => {
|
|
2087
2100
|
var _a, _b, _c, _d;
|
|
2088
2101
|
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) {
|
|
@@ -2130,7 +2143,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2130
2143
|
},
|
|
2131
2144
|
[]
|
|
2132
2145
|
);
|
|
2133
|
-
|
|
2146
|
+
React2.useImperativeHandle(
|
|
2134
2147
|
forwardedRef,
|
|
2135
2148
|
() => {
|
|
2136
2149
|
const scrollIndexIntoView = (options) => {
|
|
@@ -2191,7 +2204,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2191
2204
|
[]
|
|
2192
2205
|
);
|
|
2193
2206
|
if (reactNative.Platform.OS === "web") {
|
|
2194
|
-
|
|
2207
|
+
React2.useEffect(() => {
|
|
2195
2208
|
var _a;
|
|
2196
2209
|
if (initialContentOffset) {
|
|
2197
2210
|
(_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.setDisableAdjust(true);
|
|
@@ -2203,7 +2216,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2203
2216
|
}
|
|
2204
2217
|
}, []);
|
|
2205
2218
|
}
|
|
2206
|
-
return /* @__PURE__ */
|
|
2219
|
+
return /* @__PURE__ */ React2__namespace.createElement(React2__namespace.Fragment, null, /* @__PURE__ */ React2__namespace.createElement(
|
|
2207
2220
|
ListComponent,
|
|
2208
2221
|
{
|
|
2209
2222
|
...rest,
|
|
@@ -2242,7 +2255,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2242
2255
|
maintainVisibleContentPosition,
|
|
2243
2256
|
scrollEventThrottle: reactNative.Platform.OS === "web" ? 16 : void 0,
|
|
2244
2257
|
waitForInitialLayout,
|
|
2245
|
-
refreshControl: refreshControl != null ? refreshControl : onRefresh && /* @__PURE__ */
|
|
2258
|
+
refreshControl: refreshControl != null ? refreshControl : onRefresh && /* @__PURE__ */ React2__namespace.createElement(
|
|
2246
2259
|
reactNative.RefreshControl,
|
|
2247
2260
|
{
|
|
2248
2261
|
refreshing: !!refreshing,
|
|
@@ -2253,7 +2266,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2253
2266
|
style,
|
|
2254
2267
|
contentContainerStyle
|
|
2255
2268
|
}
|
|
2256
|
-
), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */
|
|
2269
|
+
), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */ React2__namespace.createElement(DebugView, { state: refState.current }));
|
|
2257
2270
|
});
|
|
2258
2271
|
|
|
2259
2272
|
exports.LegendList = LegendList;
|