@legendapp/list 1.0.0-beta.52 → 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/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var React6 = require('react');
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 React6__namespace = /*#__PURE__*/_interopNamespace(React6);
24
+ var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
25
25
 
26
26
  // src/LegendList.tsx
27
- var ContextState = React6__namespace.createContext(null);
27
+ var ContextState = React2__namespace.createContext(null);
28
28
  function StateProvider({ children }) {
29
- const [value] = React6__namespace.useState(() => ({
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__ */ React6__namespace.createElement(ContextState.Provider, { value }, children);
44
+ return /* @__PURE__ */ React2__namespace.createElement(ContextState.Provider, { value }, children);
45
45
  }
46
46
  function useStateContext() {
47
- return React6__namespace.useContext(ContextState);
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 = React6__namespace.useContext(ContextState);
57
- const { subscribe, get } = React6__namespace.useMemo(() => createSelectorFunctions(ctx, signalName), []);
58
- const value = React6.useSyncExternalStore(subscribe, get);
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__ */ React.createElement(reactNative.View, { style: { flexDirection: "row", alignItems: "center", justifyContent: "space-between" } }, children);
98
+ return /* @__PURE__ */ React2__namespace.createElement(reactNative.View, { style: { flexDirection: "row", alignItems: "center", justifyContent: "space-between" } }, children);
99
99
  };
100
- var DebugView = React6.memo(function DebugView2({ state }) {
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] = React6.useReducer((x) => x + 1, 0);
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__ */ React.createElement(
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__ */ React.createElement(DebugRow, null, /* @__PURE__ */ React.createElement(reactNative.Text, null, "TotalSize:"), /* @__PURE__ */ React.createElement(reactNative.Text, null, totalSize.toFixed(2))),
131
- /* @__PURE__ */ React.createElement(DebugRow, null, /* @__PURE__ */ React.createElement(reactNative.Text, null, "ContentSize:"), /* @__PURE__ */ React.createElement(reactNative.Text, null, contentSize.toFixed(2))),
132
- /* @__PURE__ */ React.createElement(DebugRow, null, /* @__PURE__ */ React.createElement(reactNative.Text, null, "At end:"), /* @__PURE__ */ React.createElement(reactNative.Text, null, String(state.isAtBottom))),
133
- /* @__PURE__ */ React.createElement(reactNative.Text, null),
134
- /* @__PURE__ */ React.createElement(DebugRow, null, /* @__PURE__ */ React.createElement(reactNative.Text, null, "ScrollAdjust:"), /* @__PURE__ */ React.createElement(reactNative.Text, null, scrollAdjust.toFixed(2))),
135
- /* @__PURE__ */ React.createElement(DebugRow, null, /* @__PURE__ */ React.createElement(reactNative.Text, null, "TotalSizeReal: "), /* @__PURE__ */ React.createElement(reactNative.Text, null, totalSizeWithScrollAdjust.toFixed(2))),
136
- /* @__PURE__ */ React.createElement(reactNative.Text, null),
137
- /* @__PURE__ */ React.createElement(DebugRow, null, /* @__PURE__ */ React.createElement(reactNative.Text, null, "RawScroll: "), /* @__PURE__ */ React.createElement(reactNative.Text, null, rawScroll.toFixed(2))),
138
- /* @__PURE__ */ React.createElement(DebugRow, null, /* @__PURE__ */ React.createElement(reactNative.Text, null, "ComputedScroll: "), /* @__PURE__ */ React.createElement(reactNative.Text, null, scroll.toFixed(2)))
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
- React6.useEffect(() => {
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 = React6.useRef(symbolFirst);
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 = React6.createContext(null);
172
+ var ContextContainer = React2.createContext(null);
173
173
  function useViewability(callback, configId) {
174
174
  const ctx = useStateContext();
175
- const { containerId } = React6.useContext(ContextContainer);
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
- React6.useEffect(
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 } = React6.useContext(ContextContainer);
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
- React6.useEffect(
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 } = React6.useContext(ContextContainer);
210
- const prevValues = React6.useRef({
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
- React6.useEffect(() => {
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 } = React6.useContext(ContextContainer);
233
- const refState = React6.useRef({
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] = React6.useState(0);
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 = React6.useCallback(
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 = React6__namespace.forwardRef((props, ref) => {
258
- return React6__namespace.createElement("RCTView", { ...props, ref });
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 = React6.useRef();
294
- const ref = React6.useRef(null);
295
- const [layoutRenderCount, forceLayoutRender] = React6.useState(0);
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 = React6.useMemo(
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 = React6.useCallback(() => {
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
- React6.useLayoutEffect(() => {
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
- React6.useEffect(() => {
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 = React6.useMemo(() => {
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__ */ React6__namespace.default.createElement(React6__namespace.default.Fragment, { key: recycleItems ? void 0 : itemKey }, /* @__PURE__ */ React6__namespace.default.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItemInfo && ItemSeparatorComponent && !lastItemKeys.includes(itemKey) && /* @__PURE__ */ React6__namespace.default.createElement(ItemSeparatorComponent, { leadingItem: renderedItemInfo.item })));
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__ */ React6__namespace.default.createElement(LeanView, { style }, /* @__PURE__ */ React6__namespace.default.createElement(LeanView, { style: anchorStyle, onLayout, ref }, contentFragment, ENABLE_DEVMODE && /* @__PURE__ */ React6__namespace.default.createElement(reactNative.Text, { style: { position: "absolute", top: 0, left: 0, zIndex: 1e3 } }, position.top)));
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__ */ React6__namespace.default.createElement(LeanView, { style, onLayout, ref }, contentFragment);
385
+ return /* @__PURE__ */ React2__namespace.default.createElement(LeanView, { style, onLayout, ref }, contentFragment);
386
386
  };
387
- var typedForwardRef = React6.forwardRef;
388
- var typedMemo = React6.memo;
387
+ var typedForwardRef = React2.forwardRef;
388
+ var typedMemo = React2.memo;
389
389
  var useAnimatedValue = (initialValue) => {
390
- return React6.useRef(new reactNative.Animated.Value(initialValue)).current;
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
- React6.useMemo(() => {
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__ */ React6__namespace.createElement(
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__ */ React6__namespace.createElement(reactNative.Animated.View, { style }, containers);
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 (React6__namespace.isValidElement(Component)) {
472
+ if (React2__namespace.isValidElement(Component)) {
473
473
  return Component;
474
474
  }
475
475
  if (Component) {
476
- return /* @__PURE__ */ React6__namespace.createElement(Component, null);
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__ */ React6__namespace.createElement(reactNative.Animated.View, { style: additionalSize });
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__ */ React6__namespace.createElement(React6__namespace.Fragment, null, /* @__PURE__ */ React6__namespace.createElement(reactNative.Animated.View, { style: { marginTop: animScrollAdjust } }), /* @__PURE__ */ React6__namespace.createElement(reactNative.Animated.View, { style: { paddingTop: animPaddingTop } }), /* @__PURE__ */ React6__namespace.createElement(
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__ */ React6__namespace.createElement(
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__ */ React6__namespace.createElement(
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 ? React6.useMemo(
559
- () => React6__namespace.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
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__ */ React6__namespace.createElement(
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__ */ React6__namespace.createElement(PaddingAndAdjustDevMode, null) : /* @__PURE__ */ React6__namespace.createElement(PaddingAndAdjust, null)),
581
- ListHeaderComponent && /* @__PURE__ */ React6__namespace.createElement(
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__ */ React6__namespace.createElement(
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__ */ React6__namespace.createElement(
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 = React6.useCallback((element) => {
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__ */ React6__namespace.createElement(StateProvider, null, /* @__PURE__ */ React6__namespace.createElement(LegendListInner, { ...props, ref: forwardedRef }));
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 = React6.useRef({
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 = React6.useRef(null);
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 = React6.useRef();
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;
@@ -974,10 +974,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
974
974
  size = roundSize(average.avg);
975
975
  }
976
976
  }
977
- const sizePrevious = state.sizesKnown.get(key);
978
- if (sizePrevious !== void 0) {
979
- return sizePrevious;
980
- }
981
977
  if (size === void 0) {
982
978
  size = estimatedItemSize != null ? estimatedItemSize : DEFAULT_ITEM_SIZE;
983
979
  }
@@ -1007,7 +1003,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1007
1003
  }
1008
1004
  return 0;
1009
1005
  };
1010
- const initialContentOffset = initialScrollOffset != null ? initialScrollOffset : React6.useMemo(calculateOffsetForIndex, []);
1006
+ const initialContentOffset = initialScrollOffset != null ? initialScrollOffset : React2.useMemo(calculateOffsetForIndex, []);
1011
1007
  if (!refState.current) {
1012
1008
  const initialScrollLength = reactNative.Dimensions.get("window")[horizontal ? "width" : "height"];
1013
1009
  refState.current = {
@@ -1118,6 +1114,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1118
1114
  state.scrollAdjustHandler.setDisableAdjust(true);
1119
1115
  state.scrollingToOffset = firstIndexScrollPostion;
1120
1116
  scrollTo(firstIndexScrollPostion, animated);
1117
+ if (!animated) {
1118
+ requestAnimationFrame(() => {
1119
+ state.scrollingToOffset = void 0;
1120
+ state.scrollAdjustHandler.setDisableAdjust(false);
1121
+ });
1122
+ }
1121
1123
  };
1122
1124
  const setDidLayout = () => {
1123
1125
  refState.current.queuedInitialLayout = true;
@@ -1135,7 +1137,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1135
1137
  });
1136
1138
  }
1137
1139
  };
1138
- const addTotalSize = React6.useCallback((key, add, totalSizeBelowAnchor) => {
1140
+ const addTotalSize = React2.useCallback((key, add, totalSizeBelowAnchor) => {
1139
1141
  const state = refState.current;
1140
1142
  const { indexByKey, anchorElement } = state;
1141
1143
  const index = key === null ? 0 : indexByKey.get(key);
@@ -1229,7 +1231,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1229
1231
  }
1230
1232
  return res;
1231
1233
  };
1232
- const fixGaps = React6.useCallback(() => {
1234
+ const fixGaps = React2.useCallback(() => {
1233
1235
  var _a;
1234
1236
  const state = refState.current;
1235
1237
  const { data, scrollLength, positions, startBuffered, endBuffered } = state;
@@ -1294,7 +1296,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1294
1296
  }
1295
1297
  }
1296
1298
  }, []);
1297
- const calculateItemsInView = React6.useCallback(() => {
1299
+ const calculateItemsInView = React2.useCallback(() => {
1298
1300
  var _a;
1299
1301
  const state = refState.current;
1300
1302
  const {
@@ -1529,7 +1531,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1529
1531
  if (item !== void 0) {
1530
1532
  const id = getId(itemIndex);
1531
1533
  if (itemKey !== id || itemIndex < startBuffered || itemIndex > endBuffered) {
1532
- const prevPos = peek$(ctx, `containerPosition${i}`).top;
1534
+ const prevPos = peek$(ctx, `containerPosition${i}`);
1533
1535
  const pos = positions.get(id) || 0;
1534
1536
  const size = getItemSize(id, itemIndex, data[i]);
1535
1537
  if (pos + size >= scroll && pos <= scrollBottom || prevPos + size >= scroll && prevPos <= scrollBottom) {
@@ -1596,6 +1598,14 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1596
1598
  alignItemsPaddingTop
1597
1599
  }) => {
1598
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
+ }
1599
1609
  set$(ctx, "stylePaddingTop", stylePaddingTop);
1600
1610
  }
1601
1611
  if (alignItemsPaddingTop !== void 0) {
@@ -1725,8 +1735,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1725
1735
  for (let i = 0; i < numContainers; i++) {
1726
1736
  const itemKey = peek$(ctx, `containerItemKey${i}`);
1727
1737
  if (!keyExtractorProp || itemKey && state.indexByKey.get(itemKey) === void 0) {
1728
- set$(ctx, `containerItemKey${i}`, void 0);
1729
- set$(ctx, `containerItemData${i}`, void 0);
1738
+ set$(ctx, `containerItemKey${i}`, null);
1739
+ set$(ctx, `containerItemData${i}`, null);
1730
1740
  set$(ctx, `containerPosition${i}`, ANCHORED_POSITION_OUT_OF_VIEW);
1731
1741
  set$(ctx, `containerColumn${i}`, -1);
1732
1742
  }
@@ -1832,7 +1842,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1832
1842
  addTotalSize(null, totalSize, totalSizeBelowIndex);
1833
1843
  };
1834
1844
  const isFirst = !refState.current.renderItem;
1835
- const memoizedLastItemKeys = React6.useMemo(() => {
1845
+ const memoizedLastItemKeys = React2.useMemo(() => {
1836
1846
  if (!dataProp.length) return [];
1837
1847
  return Array.from(
1838
1848
  { length: Math.min(numColumnsProp, dataProp.length) },
@@ -1866,7 +1876,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1866
1876
  }
1867
1877
  calcTotalSizesAndPositions({ forgetPositions: false });
1868
1878
  }
1869
- React6.useEffect(() => {
1879
+ React2.useEffect(() => {
1870
1880
  const didAllocateContainers = doInitialAllocateContainers();
1871
1881
  if (!didAllocateContainers) {
1872
1882
  checkResetContainers(
@@ -1875,12 +1885,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1875
1885
  );
1876
1886
  }
1877
1887
  }, [isFirst, dataProp, numColumnsProp]);
1878
- React6.useEffect(() => {
1888
+ React2.useEffect(() => {
1879
1889
  set$(ctx, "extraData", extraData);
1880
1890
  }, [extraData]);
1881
1891
  refState.current.renderItem = renderItem;
1882
- React6.useEffect(initalizeStateVars, [memoizedLastItemKeys.join(","), numColumnsProp, stylePaddingTopState]);
1883
- const getRenderedItem = React6.useCallback((key) => {
1892
+ React2.useEffect(initalizeStateVars, [memoizedLastItemKeys.join(","), numColumnsProp, stylePaddingTopState]);
1893
+ const getRenderedItem = React2.useCallback((key) => {
1884
1894
  var _a, _b;
1885
1895
  const state = refState.current;
1886
1896
  if (!state) {
@@ -1950,7 +1960,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1950
1960
  return true;
1951
1961
  }
1952
1962
  };
1953
- React6.useEffect(() => {
1963
+ React2.useEffect(() => {
1954
1964
  const state = refState.current;
1955
1965
  const viewability = setupViewability({
1956
1966
  viewabilityConfig,
@@ -1963,7 +1973,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1963
1973
  useInit(() => {
1964
1974
  doInitialAllocateContainers();
1965
1975
  });
1966
- const updateItemSize = React6.useCallback((itemKey, size, fromFixGaps) => {
1976
+ const updateItemSize = React2.useCallback((itemKey, size, fromFixGaps) => {
1967
1977
  const state = refState.current;
1968
1978
  const { sizes, indexByKey, sizesKnown, data, rowHeights, startBuffered, endBuffered, averageSizes } = state;
1969
1979
  if (!data) {
@@ -2056,7 +2066,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2056
2066
  }
2057
2067
  }
2058
2068
  }, []);
2059
- const onLayout = React6.useCallback((event) => {
2069
+ const onLayout = React2.useCallback((event) => {
2060
2070
  const state = refState.current;
2061
2071
  const scrollLength = event.nativeEvent.layout[horizontal ? "width" : "height"];
2062
2072
  const didChange = scrollLength !== state.scrollLength;
@@ -2085,7 +2095,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2085
2095
  onLayoutProp(event);
2086
2096
  }
2087
2097
  }, []);
2088
- const handleScroll = React6.useCallback(
2098
+ const handleScroll = React2.useCallback(
2089
2099
  (event, fromSelf) => {
2090
2100
  var _a, _b, _c, _d;
2091
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) {
@@ -2133,7 +2143,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2133
2143
  },
2134
2144
  []
2135
2145
  );
2136
- React6.useImperativeHandle(
2146
+ React2.useImperativeHandle(
2137
2147
  forwardedRef,
2138
2148
  () => {
2139
2149
  const scrollIndexIntoView = (options) => {
@@ -2194,7 +2204,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2194
2204
  []
2195
2205
  );
2196
2206
  if (reactNative.Platform.OS === "web") {
2197
- React6.useEffect(() => {
2207
+ React2.useEffect(() => {
2198
2208
  var _a;
2199
2209
  if (initialContentOffset) {
2200
2210
  (_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.setDisableAdjust(true);
@@ -2206,7 +2216,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2206
2216
  }
2207
2217
  }, []);
2208
2218
  }
2209
- return /* @__PURE__ */ React6__namespace.createElement(React6__namespace.Fragment, null, /* @__PURE__ */ React6__namespace.createElement(
2219
+ return /* @__PURE__ */ React2__namespace.createElement(React2__namespace.Fragment, null, /* @__PURE__ */ React2__namespace.createElement(
2210
2220
  ListComponent,
2211
2221
  {
2212
2222
  ...rest,
@@ -2245,7 +2255,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2245
2255
  maintainVisibleContentPosition,
2246
2256
  scrollEventThrottle: reactNative.Platform.OS === "web" ? 16 : void 0,
2247
2257
  waitForInitialLayout,
2248
- refreshControl: refreshControl != null ? refreshControl : onRefresh && /* @__PURE__ */ React6__namespace.createElement(
2258
+ refreshControl: refreshControl != null ? refreshControl : onRefresh && /* @__PURE__ */ React2__namespace.createElement(
2249
2259
  reactNative.RefreshControl,
2250
2260
  {
2251
2261
  refreshing: !!refreshing,
@@ -2256,7 +2266,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2256
2266
  style,
2257
2267
  contentContainerStyle
2258
2268
  }
2259
- ), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */ React6__namespace.createElement(DebugView, { state: refState.current }));
2269
+ ), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */ React2__namespace.createElement(DebugView, { state: refState.current }));
2260
2270
  });
2261
2271
 
2262
2272
  exports.LegendList = LegendList;
package/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
- import * as React6 from 'react';
2
- import React6__default, { memo, useReducer, useEffect, createContext, useMemo, useRef, useCallback, useImperativeHandle, useSyncExternalStore, useContext, useState, forwardRef, useLayoutEffect } from 'react';
1
+ import * as React2 from 'react';
2
+ import React2__default, { useReducer, useEffect, createContext, useMemo, useRef, useCallback, useImperativeHandle, useSyncExternalStore, useContext, useState, forwardRef, memo, useLayoutEffect } from 'react';
3
3
  import { View, Text, Platform, Animated, ScrollView, StyleSheet, Dimensions, RefreshControl } from 'react-native';
4
4
 
5
5
  // src/LegendList.tsx
6
- var ContextState = React6.createContext(null);
6
+ var ContextState = React2.createContext(null);
7
7
  function StateProvider({ children }) {
8
- const [value] = React6.useState(() => ({
8
+ const [value] = React2.useState(() => ({
9
9
  listeners: /* @__PURE__ */ new Map(),
10
10
  values: /* @__PURE__ */ new Map([
11
11
  ["paddingTop", 0],
@@ -20,10 +20,10 @@ function StateProvider({ children }) {
20
20
  columnWrapperStyle: void 0,
21
21
  viewRefs: /* @__PURE__ */ new Map()
22
22
  }));
23
- return /* @__PURE__ */ React6.createElement(ContextState.Provider, { value }, children);
23
+ return /* @__PURE__ */ React2.createElement(ContextState.Provider, { value }, children);
24
24
  }
25
25
  function useStateContext() {
26
- return React6.useContext(ContextState);
26
+ return React2.useContext(ContextState);
27
27
  }
28
28
  function createSelectorFunctions(ctx, signalName) {
29
29
  return {
@@ -32,8 +32,8 @@ function createSelectorFunctions(ctx, signalName) {
32
32
  };
33
33
  }
34
34
  function use$(signalName) {
35
- const ctx = React6.useContext(ContextState);
36
- const { subscribe, get } = React6.useMemo(() => createSelectorFunctions(ctx, signalName), []);
35
+ const ctx = React2.useContext(ContextState);
36
+ const { subscribe, get } = React2.useMemo(() => createSelectorFunctions(ctx, signalName), []);
37
37
  const value = useSyncExternalStore(subscribe, get);
38
38
  return value;
39
39
  }
@@ -74,9 +74,9 @@ function getContentSize(ctx) {
74
74
 
75
75
  // src/DebugView.tsx
76
76
  var DebugRow = ({ children }) => {
77
- return /* @__PURE__ */ React.createElement(View, { style: { flexDirection: "row", alignItems: "center", justifyContent: "space-between" } }, children);
77
+ return /* @__PURE__ */ React2.createElement(View, { style: { flexDirection: "row", alignItems: "center", justifyContent: "space-between" } }, children);
78
78
  };
79
- var DebugView = memo(function DebugView2({ state }) {
79
+ var DebugView = React2.memo(function DebugView2({ state }) {
80
80
  const ctx = useStateContext();
81
81
  const totalSize = use$("totalSize") || 0;
82
82
  const totalSizeWithScrollAdjust = use$("totalSizeWithScrollAdjust") || 0;
@@ -90,7 +90,7 @@ var DebugView = memo(function DebugView2({ state }) {
90
90
  useInterval(() => {
91
91
  forceUpdate();
92
92
  }, 100);
93
- return /* @__PURE__ */ React.createElement(
93
+ return /* @__PURE__ */ React2.createElement(
94
94
  View,
95
95
  {
96
96
  style: {
@@ -106,15 +106,15 @@ var DebugView = memo(function DebugView2({ state }) {
106
106
  },
107
107
  pointerEvents: "none"
108
108
  },
109
- /* @__PURE__ */ React.createElement(DebugRow, null, /* @__PURE__ */ React.createElement(Text, null, "TotalSize:"), /* @__PURE__ */ React.createElement(Text, null, totalSize.toFixed(2))),
110
- /* @__PURE__ */ React.createElement(DebugRow, null, /* @__PURE__ */ React.createElement(Text, null, "ContentSize:"), /* @__PURE__ */ React.createElement(Text, null, contentSize.toFixed(2))),
111
- /* @__PURE__ */ React.createElement(DebugRow, null, /* @__PURE__ */ React.createElement(Text, null, "At end:"), /* @__PURE__ */ React.createElement(Text, null, String(state.isAtBottom))),
112
- /* @__PURE__ */ React.createElement(Text, null),
113
- /* @__PURE__ */ React.createElement(DebugRow, null, /* @__PURE__ */ React.createElement(Text, null, "ScrollAdjust:"), /* @__PURE__ */ React.createElement(Text, null, scrollAdjust.toFixed(2))),
114
- /* @__PURE__ */ React.createElement(DebugRow, null, /* @__PURE__ */ React.createElement(Text, null, "TotalSizeReal: "), /* @__PURE__ */ React.createElement(Text, null, totalSizeWithScrollAdjust.toFixed(2))),
115
- /* @__PURE__ */ React.createElement(Text, null),
116
- /* @__PURE__ */ React.createElement(DebugRow, null, /* @__PURE__ */ React.createElement(Text, null, "RawScroll: "), /* @__PURE__ */ React.createElement(Text, null, rawScroll.toFixed(2))),
117
- /* @__PURE__ */ React.createElement(DebugRow, null, /* @__PURE__ */ React.createElement(Text, null, "ComputedScroll: "), /* @__PURE__ */ React.createElement(Text, null, scroll.toFixed(2)))
109
+ /* @__PURE__ */ React2.createElement(DebugRow, null, /* @__PURE__ */ React2.createElement(Text, null, "TotalSize:"), /* @__PURE__ */ React2.createElement(Text, null, totalSize.toFixed(2))),
110
+ /* @__PURE__ */ React2.createElement(DebugRow, null, /* @__PURE__ */ React2.createElement(Text, null, "ContentSize:"), /* @__PURE__ */ React2.createElement(Text, null, contentSize.toFixed(2))),
111
+ /* @__PURE__ */ React2.createElement(DebugRow, null, /* @__PURE__ */ React2.createElement(Text, null, "At end:"), /* @__PURE__ */ React2.createElement(Text, null, String(state.isAtBottom))),
112
+ /* @__PURE__ */ React2.createElement(Text, null),
113
+ /* @__PURE__ */ React2.createElement(DebugRow, null, /* @__PURE__ */ React2.createElement(Text, null, "ScrollAdjust:"), /* @__PURE__ */ React2.createElement(Text, null, scrollAdjust.toFixed(2))),
114
+ /* @__PURE__ */ React2.createElement(DebugRow, null, /* @__PURE__ */ React2.createElement(Text, null, "TotalSizeReal: "), /* @__PURE__ */ React2.createElement(Text, null, totalSizeWithScrollAdjust.toFixed(2))),
115
+ /* @__PURE__ */ React2.createElement(Text, null),
116
+ /* @__PURE__ */ React2.createElement(DebugRow, null, /* @__PURE__ */ React2.createElement(Text, null, "RawScroll: "), /* @__PURE__ */ React2.createElement(Text, null, rawScroll.toFixed(2))),
117
+ /* @__PURE__ */ React2.createElement(DebugRow, null, /* @__PURE__ */ React2.createElement(Text, null, "ComputedScroll: "), /* @__PURE__ */ React2.createElement(Text, null, scroll.toFixed(2)))
118
118
  );
119
119
  });
120
120
  function useInterval(callback, delay) {
@@ -233,8 +233,8 @@ function useRecyclingState(valueOrFun) {
233
233
  );
234
234
  return [refState.current.value, setState];
235
235
  }
236
- var LeanViewComponent = React6.forwardRef((props, ref) => {
237
- return React6.createElement("RCTView", { ...props, ref });
236
+ var LeanViewComponent = React2.forwardRef((props, ref) => {
237
+ return React2.createElement("RCTView", { ...props, ref });
238
238
  });
239
239
  LeanViewComponent.displayName = "RCTView";
240
240
  var LeanView = Platform.OS === "android" || Platform.OS === "ios" ? LeanViewComponent : View;
@@ -352,16 +352,16 @@ var Container = ({
352
352
  ctx.viewRefs.set(id, ref);
353
353
  return { containerId: id, itemKey, index, value: data, triggerLayout };
354
354
  }, [id, itemKey, index, data]);
355
- const contentFragment = /* @__PURE__ */ React6__default.createElement(React6__default.Fragment, { key: recycleItems ? void 0 : itemKey }, /* @__PURE__ */ React6__default.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItemInfo && ItemSeparatorComponent && !lastItemKeys.includes(itemKey) && /* @__PURE__ */ React6__default.createElement(ItemSeparatorComponent, { leadingItem: renderedItemInfo.item })));
355
+ const contentFragment = /* @__PURE__ */ React2__default.createElement(React2__default.Fragment, { key: recycleItems ? void 0 : itemKey }, /* @__PURE__ */ React2__default.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItemInfo && ItemSeparatorComponent && !lastItemKeys.includes(itemKey) && /* @__PURE__ */ React2__default.createElement(ItemSeparatorComponent, { leadingItem: renderedItemInfo.item })));
356
356
  if (maintainVisibleContentPosition) {
357
357
  const anchorStyle = position.type === "top" ? { position: "absolute", top: 0, left: 0, right: 0 } : { position: "absolute", bottom: 0, left: 0, right: 0 };
358
358
  if (ENABLE_DEVMODE) {
359
359
  anchorStyle.borderColor = position.type === "top" ? "red" : "blue";
360
360
  anchorStyle.borderWidth = 1;
361
361
  }
362
- return /* @__PURE__ */ React6__default.createElement(LeanView, { style }, /* @__PURE__ */ React6__default.createElement(LeanView, { style: anchorStyle, onLayout, ref }, contentFragment, ENABLE_DEVMODE && /* @__PURE__ */ React6__default.createElement(Text, { style: { position: "absolute", top: 0, left: 0, zIndex: 1e3 } }, position.top)));
362
+ return /* @__PURE__ */ React2__default.createElement(LeanView, { style }, /* @__PURE__ */ React2__default.createElement(LeanView, { style: anchorStyle, onLayout, ref }, contentFragment, ENABLE_DEVMODE && /* @__PURE__ */ React2__default.createElement(Text, { style: { position: "absolute", top: 0, left: 0, zIndex: 1e3 } }, position.top)));
363
363
  }
364
- return /* @__PURE__ */ React6__default.createElement(LeanView, { style, onLayout, ref }, contentFragment);
364
+ return /* @__PURE__ */ React2__default.createElement(LeanView, { style, onLayout, ref }, contentFragment);
365
365
  };
366
366
  var typedForwardRef = forwardRef;
367
367
  var typedMemo = memo;
@@ -414,7 +414,7 @@ var Containers = typedMemo(function Containers2({
414
414
  const containers = [];
415
415
  for (let i = 0; i < numContainers; i++) {
416
416
  containers.push(
417
- /* @__PURE__ */ React6.createElement(
417
+ /* @__PURE__ */ React2.createElement(
418
418
  Container,
419
419
  {
420
420
  id: i,
@@ -443,16 +443,16 @@ var Containers = typedMemo(function Containers2({
443
443
  }
444
444
  }
445
445
  }
446
- return /* @__PURE__ */ React6.createElement(Animated.View, { style }, containers);
446
+ return /* @__PURE__ */ React2.createElement(Animated.View, { style }, containers);
447
447
  });
448
448
 
449
449
  // src/ListComponent.tsx
450
450
  var getComponent = (Component) => {
451
- if (React6.isValidElement(Component)) {
451
+ if (React2.isValidElement(Component)) {
452
452
  return Component;
453
453
  }
454
454
  if (Component) {
455
- return /* @__PURE__ */ React6.createElement(Component, null);
455
+ return /* @__PURE__ */ React2.createElement(Component, null);
456
456
  }
457
457
  return null;
458
458
  };
@@ -460,12 +460,12 @@ var PaddingAndAdjust = () => {
460
460
  const animPaddingTop = useValue$("paddingTop", (v) => v, true);
461
461
  const animScrollAdjust = useValue$("scrollAdjust", (v) => v, true);
462
462
  const additionalSize = { marginTop: animScrollAdjust, paddingTop: animPaddingTop };
463
- return /* @__PURE__ */ React6.createElement(Animated.View, { style: additionalSize });
463
+ return /* @__PURE__ */ React2.createElement(Animated.View, { style: additionalSize });
464
464
  };
465
465
  var PaddingAndAdjustDevMode = () => {
466
466
  const animPaddingTop = useValue$("paddingTop", (v) => v, true);
467
467
  const animScrollAdjust = useValue$("scrollAdjust", (v) => v, true);
468
- return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(Animated.View, { style: { marginTop: animScrollAdjust } }), /* @__PURE__ */ React6.createElement(Animated.View, { style: { paddingTop: animPaddingTop } }), /* @__PURE__ */ React6.createElement(
468
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Animated.View, { style: { marginTop: animScrollAdjust } }), /* @__PURE__ */ React2.createElement(Animated.View, { style: { paddingTop: animPaddingTop } }), /* @__PURE__ */ React2.createElement(
469
469
  Animated.View,
470
470
  {
471
471
  style: {
@@ -477,7 +477,7 @@ var PaddingAndAdjustDevMode = () => {
477
477
  backgroundColor: "green"
478
478
  }
479
479
  }
480
- ), /* @__PURE__ */ React6.createElement(
480
+ ), /* @__PURE__ */ React2.createElement(
481
481
  Animated.View,
482
482
  {
483
483
  style: {
@@ -489,7 +489,7 @@ var PaddingAndAdjustDevMode = () => {
489
489
  backgroundColor: "lightblue"
490
490
  }
491
491
  }
492
- ), /* @__PURE__ */ React6.createElement(
492
+ ), /* @__PURE__ */ React2.createElement(
493
493
  Animated.View,
494
494
  {
495
495
  style: {
@@ -535,10 +535,10 @@ var ListComponent = typedMemo(function ListComponent2({
535
535
  }) {
536
536
  const ctx = useStateContext();
537
537
  const ScrollComponent = renderScrollComponent ? useMemo(
538
- () => React6.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
538
+ () => React2.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
539
539
  [renderScrollComponent]
540
540
  ) : ScrollView;
541
- return /* @__PURE__ */ React6.createElement(
541
+ return /* @__PURE__ */ React2.createElement(
542
542
  ScrollComponent,
543
543
  {
544
544
  ...rest,
@@ -556,8 +556,8 @@ var ListComponent = typedMemo(function ListComponent2({
556
556
  contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
557
557
  ref: refScrollView
558
558
  },
559
- !ListEmptyComponent && (ENABLE_DEVMODE ? /* @__PURE__ */ React6.createElement(PaddingAndAdjustDevMode, null) : /* @__PURE__ */ React6.createElement(PaddingAndAdjust, null)),
560
- ListHeaderComponent && /* @__PURE__ */ React6.createElement(
559
+ !ListEmptyComponent && (ENABLE_DEVMODE ? /* @__PURE__ */ React2.createElement(PaddingAndAdjustDevMode, null) : /* @__PURE__ */ React2.createElement(PaddingAndAdjust, null)),
560
+ ListHeaderComponent && /* @__PURE__ */ React2.createElement(
561
561
  View,
562
562
  {
563
563
  style: ListHeaderComponentStyle,
@@ -569,7 +569,7 @@ var ListComponent = typedMemo(function ListComponent2({
569
569
  getComponent(ListHeaderComponent)
570
570
  ),
571
571
  ListEmptyComponent && getComponent(ListEmptyComponent),
572
- /* @__PURE__ */ React6.createElement(
572
+ /* @__PURE__ */ React2.createElement(
573
573
  Containers,
574
574
  {
575
575
  horizontal,
@@ -580,7 +580,7 @@ var ListComponent = typedMemo(function ListComponent2({
580
580
  updateItemSize
581
581
  }
582
582
  ),
583
- ListFooterComponent && /* @__PURE__ */ React6.createElement(
583
+ ListFooterComponent && /* @__PURE__ */ React2.createElement(
584
584
  View,
585
585
  {
586
586
  style: ListFooterComponentStyle,
@@ -862,7 +862,7 @@ function createColumnWrapperStyle(contentContainerStyle) {
862
862
  }
863
863
  }
864
864
  var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
865
- return /* @__PURE__ */ React6.createElement(StateProvider, null, /* @__PURE__ */ React6.createElement(LegendListInner, { ...props, ref: forwardedRef }));
865
+ return /* @__PURE__ */ React2.createElement(StateProvider, null, /* @__PURE__ */ React2.createElement(LegendListInner, { ...props, ref: forwardedRef }));
866
866
  });
867
867
  var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
868
868
  const {
@@ -953,10 +953,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
953
953
  size = roundSize(average.avg);
954
954
  }
955
955
  }
956
- const sizePrevious = state.sizesKnown.get(key);
957
- if (sizePrevious !== void 0) {
958
- return sizePrevious;
959
- }
960
956
  if (size === void 0) {
961
957
  size = estimatedItemSize != null ? estimatedItemSize : DEFAULT_ITEM_SIZE;
962
958
  }
@@ -1097,6 +1093,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1097
1093
  state.scrollAdjustHandler.setDisableAdjust(true);
1098
1094
  state.scrollingToOffset = firstIndexScrollPostion;
1099
1095
  scrollTo(firstIndexScrollPostion, animated);
1096
+ if (!animated) {
1097
+ requestAnimationFrame(() => {
1098
+ state.scrollingToOffset = void 0;
1099
+ state.scrollAdjustHandler.setDisableAdjust(false);
1100
+ });
1101
+ }
1100
1102
  };
1101
1103
  const setDidLayout = () => {
1102
1104
  refState.current.queuedInitialLayout = true;
@@ -1508,7 +1510,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1508
1510
  if (item !== void 0) {
1509
1511
  const id = getId(itemIndex);
1510
1512
  if (itemKey !== id || itemIndex < startBuffered || itemIndex > endBuffered) {
1511
- const prevPos = peek$(ctx, `containerPosition${i}`).top;
1513
+ const prevPos = peek$(ctx, `containerPosition${i}`);
1512
1514
  const pos = positions.get(id) || 0;
1513
1515
  const size = getItemSize(id, itemIndex, data[i]);
1514
1516
  if (pos + size >= scroll && pos <= scrollBottom || prevPos + size >= scroll && prevPos <= scrollBottom) {
@@ -1575,6 +1577,14 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1575
1577
  alignItemsPaddingTop
1576
1578
  }) => {
1577
1579
  if (stylePaddingTop !== void 0) {
1580
+ const prevStylePaddingTop = peek$(ctx, "stylePaddingTop") || 0;
1581
+ if (stylePaddingTop < prevStylePaddingTop) {
1582
+ const prevTotalSize = peek$(ctx, "totalSizeWithScrollAdjust") || 0;
1583
+ set$(ctx, "totalSizeWithScrollAdjust", prevTotalSize + prevStylePaddingTop);
1584
+ setTimeout(() => {
1585
+ set$(ctx, "totalSizeWithScrollAdjust", prevTotalSize);
1586
+ }, 16);
1587
+ }
1578
1588
  set$(ctx, "stylePaddingTop", stylePaddingTop);
1579
1589
  }
1580
1590
  if (alignItemsPaddingTop !== void 0) {
@@ -1704,8 +1714,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1704
1714
  for (let i = 0; i < numContainers; i++) {
1705
1715
  const itemKey = peek$(ctx, `containerItemKey${i}`);
1706
1716
  if (!keyExtractorProp || itemKey && state.indexByKey.get(itemKey) === void 0) {
1707
- set$(ctx, `containerItemKey${i}`, void 0);
1708
- set$(ctx, `containerItemData${i}`, void 0);
1717
+ set$(ctx, `containerItemKey${i}`, null);
1718
+ set$(ctx, `containerItemData${i}`, null);
1709
1719
  set$(ctx, `containerPosition${i}`, ANCHORED_POSITION_OUT_OF_VIEW);
1710
1720
  set$(ctx, `containerColumn${i}`, -1);
1711
1721
  }
@@ -2185,7 +2195,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2185
2195
  }
2186
2196
  }, []);
2187
2197
  }
2188
- return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(
2198
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
2189
2199
  ListComponent,
2190
2200
  {
2191
2201
  ...rest,
@@ -2224,7 +2234,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2224
2234
  maintainVisibleContentPosition,
2225
2235
  scrollEventThrottle: Platform.OS === "web" ? 16 : void 0,
2226
2236
  waitForInitialLayout,
2227
- refreshControl: refreshControl != null ? refreshControl : onRefresh && /* @__PURE__ */ React6.createElement(
2237
+ refreshControl: refreshControl != null ? refreshControl : onRefresh && /* @__PURE__ */ React2.createElement(
2228
2238
  RefreshControl,
2229
2239
  {
2230
2240
  refreshing: !!refreshing,
@@ -2235,7 +2245,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2235
2245
  style,
2236
2246
  contentContainerStyle
2237
2247
  }
2238
- ), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */ React6.createElement(DebugView, { state: refState.current }));
2248
+ ), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */ React2.createElement(DebugView, { state: refState.current }));
2239
2249
  });
2240
2250
 
2241
2251
  export { LegendList, useRecyclingEffect, useRecyclingState, useViewability, useViewabilityAmount };
@@ -31,7 +31,7 @@ var typedForwardRef = React.forwardRef;
31
31
  var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
32
32
  const {
33
33
  LegendList: LegendListProp,
34
- style: styleProp,
34
+ contentContainerStyle: contentContainerStyleProp,
35
35
  scrollIndicatorInsets: scrollIndicatorInsetsProp,
36
36
  ...rest
37
37
  } = props;
@@ -46,15 +46,23 @@ var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
46
46
  }
47
47
  });
48
48
  const LegendListComponent = LegendListProp != null ? LegendListProp : list.LegendList;
49
- const styleFlattened = reactNative.StyleSheet.flatten(styleProp) || {};
50
- const style = { ...styleFlattened, paddingTop: padding + (styleFlattened.paddingTop || 0) };
49
+ const contentContainerStyleFlattened = reactNative.StyleSheet.flatten(contentContainerStyleProp) || {};
50
+ const contentContainerStyle = { ...contentContainerStyleFlattened, paddingTop: padding };
51
51
  const scrollIndicatorInsets = scrollIndicatorInsetsProp ? { ...scrollIndicatorInsetsProp } : {};
52
52
  if (!props.horizontal) {
53
- scrollIndicatorInsets.top = (scrollIndicatorInsets.top || 0) + padding;
53
+ scrollIndicatorInsets.top = ((scrollIndicatorInsets == null ? void 0 : scrollIndicatorInsets.top) || 0) + padding;
54
54
  }
55
55
  return (
56
56
  // @ts-expect-error TODO: Fix this type
57
- /* @__PURE__ */ React__namespace.createElement(LegendListComponent, { ...rest, style, scrollIndicatorInsets, ref: forwardedRef })
57
+ /* @__PURE__ */ React__namespace.createElement(
58
+ LegendListComponent,
59
+ {
60
+ ...rest,
61
+ contentContainerStyle,
62
+ scrollIndicatorInsets,
63
+ ref: forwardedRef
64
+ }
65
+ )
58
66
  );
59
67
  });
60
68
 
@@ -10,7 +10,7 @@ var typedForwardRef = forwardRef;
10
10
  var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
11
11
  const {
12
12
  LegendList: LegendListProp,
13
- style: styleProp,
13
+ contentContainerStyle: contentContainerStyleProp,
14
14
  scrollIndicatorInsets: scrollIndicatorInsetsProp,
15
15
  ...rest
16
16
  } = props;
@@ -25,15 +25,23 @@ var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
25
25
  }
26
26
  });
27
27
  const LegendListComponent = LegendListProp != null ? LegendListProp : LegendList$1;
28
- const styleFlattened = StyleSheet.flatten(styleProp) || {};
29
- const style = { ...styleFlattened, paddingTop: padding + (styleFlattened.paddingTop || 0) };
28
+ const contentContainerStyleFlattened = StyleSheet.flatten(contentContainerStyleProp) || {};
29
+ const contentContainerStyle = { ...contentContainerStyleFlattened, paddingTop: padding };
30
30
  const scrollIndicatorInsets = scrollIndicatorInsetsProp ? { ...scrollIndicatorInsetsProp } : {};
31
31
  if (!props.horizontal) {
32
- scrollIndicatorInsets.top = (scrollIndicatorInsets.top || 0) + padding;
32
+ scrollIndicatorInsets.top = ((scrollIndicatorInsets == null ? void 0 : scrollIndicatorInsets.top) || 0) + padding;
33
33
  }
34
34
  return (
35
35
  // @ts-expect-error TODO: Fix this type
36
- /* @__PURE__ */ React.createElement(LegendListComponent, { ...rest, style, scrollIndicatorInsets, ref: forwardedRef })
36
+ /* @__PURE__ */ React.createElement(
37
+ LegendListComponent,
38
+ {
39
+ ...rest,
40
+ contentContainerStyle,
41
+ scrollIndicatorInsets,
42
+ ref: forwardedRef
43
+ }
44
+ )
37
45
  );
38
46
  });
39
47
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "1.0.0-beta.52",
3
+ "version": "1.0.0-beta.53",
4
4
  "description": "Legend List aims to be a drop-in replacement for FlatList with much better performance and supporting dynamically sized items.",
5
5
  "sideEffects": false,
6
6
  "private": false,