@legendapp/list 2.1.0-beta.8 → 2.1.0-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.mts CHANGED
@@ -455,6 +455,7 @@ type ScrollState = {
455
455
  activeStickyIndex: number | undefined;
456
456
  contentLength: number;
457
457
  data: readonly any[];
458
+ elementAtIndex: (index: number) => View | null | undefined;
458
459
  end: number;
459
460
  endBuffered: number;
460
461
  isAtEnd: boolean;
package/index.d.ts CHANGED
@@ -455,6 +455,7 @@ type ScrollState = {
455
455
  activeStickyIndex: number | undefined;
456
456
  contentLength: number;
457
457
  data: readonly any[];
458
+ elementAtIndex: (index: number) => View | null | undefined;
458
459
  end: number;
459
460
  endBuffered: number;
460
461
  isAtEnd: boolean;
package/index.js CHANGED
@@ -313,6 +313,16 @@ function getPadding(s, type) {
313
313
  function extractPadding(style, contentContainerStyle, type) {
314
314
  return getPadding(style, type) + getPadding(contentContainerStyle, type);
315
315
  }
316
+ function findContainerId(ctx, key) {
317
+ const numContainers = peek$(ctx, "numContainers");
318
+ for (let i = 0; i < numContainers; i++) {
319
+ const itemKey = peek$(ctx, `containerItemKey${i}`);
320
+ if (itemKey === key) {
321
+ return i;
322
+ }
323
+ }
324
+ return -1;
325
+ }
316
326
 
317
327
  // src/state/ContextContainer.ts
318
328
  var ContextContainer = React3.createContext(null);
@@ -2040,16 +2050,6 @@ function isViewable(state, ctx, viewabilityConfig, containerId, key, scrollSize,
2040
2050
  const value = ctx.mapViewabilityAmountValues.get(containerId) || computeViewability(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index);
2041
2051
  return value.isViewable;
2042
2052
  }
2043
- function findContainerId(ctx, key) {
2044
- const numContainers = peek$(ctx, "numContainers");
2045
- for (let i = 0; i < numContainers; i++) {
2046
- const itemKey = peek$(ctx, `containerItemKey${i}`);
2047
- if (itemKey === key) {
2048
- return i;
2049
- }
2050
- }
2051
- return -1;
2052
- }
2053
2053
  function maybeUpdateViewabilityCallback(ctx, configId, containerId, viewToken) {
2054
2054
  const key = containerId + configId;
2055
2055
  ctx.mapViewabilityValues.set(key, viewToken);
@@ -2571,7 +2571,7 @@ function calculateItemsInView(ctx, state, params = {}) {
2571
2571
  for (let i = 0; i < numContainers; i++) {
2572
2572
  const itemKey = peek$(ctx, `containerItemKey${i}`);
2573
2573
  if (pendingRemoval.includes(i)) {
2574
- if (itemKey) {
2574
+ if (itemKey !== void 0) {
2575
2575
  containerItemKeys.delete(itemKey);
2576
2576
  }
2577
2577
  state.containerItemTypes.delete(i);
@@ -3222,7 +3222,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3222
3222
  const stylePaddingTopState = extractPadding(style, contentContainerStyle, "Top");
3223
3223
  const stylePaddingBottomState = extractPadding(style, contentContainerStyle, "Bottom");
3224
3224
  const [renderNum, setRenderNum] = React3.useState(0);
3225
- const initialScrollProp = initialScrollAtEnd ? { index: dataProp.length - 1, viewOffset: -stylePaddingBottomState } : initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
3225
+ const initialScrollProp = initialScrollAtEnd ? { index: Math.max(0, dataProp.length - 1), viewOffset: -stylePaddingBottomState } : initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
3226
3226
  const [canRender, setCanRender] = React3__namespace.useState(!IsNewArchitecture);
3227
3227
  const ctx = useStateContext();
3228
3228
  ctx.columnWrapperStyle = columnWrapperStyle || (contentContainerStyle ? createColumnWrapperStyle(contentContainerStyle) : void 0);
@@ -3507,6 +3507,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3507
3507
  activeStickyIndex: state2.activeStickyIndex,
3508
3508
  contentLength: state2.totalSize,
3509
3509
  data: state2.props.data,
3510
+ elementAtIndex: (index) => {
3511
+ var _a4;
3512
+ return (_a4 = ctx.viewRefs.get(findContainerId(ctx, getId(state2, index)))) == null ? void 0 : _a4.current;
3513
+ },
3510
3514
  end: state2.endNoBuffer,
3511
3515
  endBuffered: state2.endBuffered,
3512
3516
  isAtEnd: state2.isAtEnd,
package/index.mjs CHANGED
@@ -292,6 +292,16 @@ function getPadding(s, type) {
292
292
  function extractPadding(style, contentContainerStyle, type) {
293
293
  return getPadding(style, type) + getPadding(contentContainerStyle, type);
294
294
  }
295
+ function findContainerId(ctx, key) {
296
+ const numContainers = peek$(ctx, "numContainers");
297
+ for (let i = 0; i < numContainers; i++) {
298
+ const itemKey = peek$(ctx, `containerItemKey${i}`);
299
+ if (itemKey === key) {
300
+ return i;
301
+ }
302
+ }
303
+ return -1;
304
+ }
295
305
 
296
306
  // src/state/ContextContainer.ts
297
307
  var ContextContainer = createContext(null);
@@ -2019,16 +2029,6 @@ function isViewable(state, ctx, viewabilityConfig, containerId, key, scrollSize,
2019
2029
  const value = ctx.mapViewabilityAmountValues.get(containerId) || computeViewability(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index);
2020
2030
  return value.isViewable;
2021
2031
  }
2022
- function findContainerId(ctx, key) {
2023
- const numContainers = peek$(ctx, "numContainers");
2024
- for (let i = 0; i < numContainers; i++) {
2025
- const itemKey = peek$(ctx, `containerItemKey${i}`);
2026
- if (itemKey === key) {
2027
- return i;
2028
- }
2029
- }
2030
- return -1;
2031
- }
2032
2032
  function maybeUpdateViewabilityCallback(ctx, configId, containerId, viewToken) {
2033
2033
  const key = containerId + configId;
2034
2034
  ctx.mapViewabilityValues.set(key, viewToken);
@@ -2550,7 +2550,7 @@ function calculateItemsInView(ctx, state, params = {}) {
2550
2550
  for (let i = 0; i < numContainers; i++) {
2551
2551
  const itemKey = peek$(ctx, `containerItemKey${i}`);
2552
2552
  if (pendingRemoval.includes(i)) {
2553
- if (itemKey) {
2553
+ if (itemKey !== void 0) {
2554
2554
  containerItemKeys.delete(itemKey);
2555
2555
  }
2556
2556
  state.containerItemTypes.delete(i);
@@ -3201,7 +3201,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3201
3201
  const stylePaddingTopState = extractPadding(style, contentContainerStyle, "Top");
3202
3202
  const stylePaddingBottomState = extractPadding(style, contentContainerStyle, "Bottom");
3203
3203
  const [renderNum, setRenderNum] = useState(0);
3204
- const initialScrollProp = initialScrollAtEnd ? { index: dataProp.length - 1, viewOffset: -stylePaddingBottomState } : initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
3204
+ const initialScrollProp = initialScrollAtEnd ? { index: Math.max(0, dataProp.length - 1), viewOffset: -stylePaddingBottomState } : initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
3205
3205
  const [canRender, setCanRender] = React3.useState(!IsNewArchitecture);
3206
3206
  const ctx = useStateContext();
3207
3207
  ctx.columnWrapperStyle = columnWrapperStyle || (contentContainerStyle ? createColumnWrapperStyle(contentContainerStyle) : void 0);
@@ -3486,6 +3486,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3486
3486
  activeStickyIndex: state2.activeStickyIndex,
3487
3487
  contentLength: state2.totalSize,
3488
3488
  data: state2.props.data,
3489
+ elementAtIndex: (index) => {
3490
+ var _a4;
3491
+ return (_a4 = ctx.viewRefs.get(findContainerId(ctx, getId(state2, index)))) == null ? void 0 : _a4.current;
3492
+ },
3489
3493
  end: state2.endNoBuffer,
3490
3494
  endBuffered: state2.endBuffered,
3491
3495
  isAtEnd: state2.isAtEnd,
@@ -455,6 +455,7 @@ type ScrollState = {
455
455
  activeStickyIndex: number | undefined;
456
456
  contentLength: number;
457
457
  data: readonly any[];
458
+ elementAtIndex: (index: number) => View | null | undefined;
458
459
  end: number;
459
460
  endBuffered: number;
460
461
  isAtEnd: boolean;
package/index.native.d.ts CHANGED
@@ -455,6 +455,7 @@ type ScrollState = {
455
455
  activeStickyIndex: number | undefined;
456
456
  contentLength: number;
457
457
  data: readonly any[];
458
+ elementAtIndex: (index: number) => View | null | undefined;
458
459
  end: number;
459
460
  endBuffered: number;
460
461
  isAtEnd: boolean;
package/index.native.js CHANGED
@@ -354,6 +354,16 @@ function getPadding(s, type) {
354
354
  function extractPadding(style, contentContainerStyle, type) {
355
355
  return getPadding(style, type) + getPadding(contentContainerStyle, type);
356
356
  }
357
+ function findContainerId(ctx, key) {
358
+ const numContainers = peek$(ctx, "numContainers");
359
+ for (let i = 0; i < numContainers; i++) {
360
+ const itemKey = peek$(ctx, `containerItemKey${i}`);
361
+ if (itemKey === key) {
362
+ return i;
363
+ }
364
+ }
365
+ return -1;
366
+ }
357
367
 
358
368
  // src/state/ContextContainer.ts
359
369
  var ContextContainer = React2.createContext(null);
@@ -1779,16 +1789,6 @@ function isViewable(state, ctx, viewabilityConfig, containerId, key, scrollSize,
1779
1789
  const value = ctx.mapViewabilityAmountValues.get(containerId) || computeViewability(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index);
1780
1790
  return value.isViewable;
1781
1791
  }
1782
- function findContainerId(ctx, key) {
1783
- const numContainers = peek$(ctx, "numContainers");
1784
- for (let i = 0; i < numContainers; i++) {
1785
- const itemKey = peek$(ctx, `containerItemKey${i}`);
1786
- if (itemKey === key) {
1787
- return i;
1788
- }
1789
- }
1790
- return -1;
1791
- }
1792
1792
  function maybeUpdateViewabilityCallback(ctx, configId, containerId, viewToken) {
1793
1793
  const key = containerId + configId;
1794
1794
  ctx.mapViewabilityValues.set(key, viewToken);
@@ -2321,7 +2321,7 @@ function calculateItemsInView(ctx, state, params = {}) {
2321
2321
  for (let i = 0; i < numContainers; i++) {
2322
2322
  const itemKey = peek$(ctx, `containerItemKey${i}`);
2323
2323
  if (pendingRemoval.includes(i)) {
2324
- if (itemKey) {
2324
+ if (itemKey !== void 0) {
2325
2325
  containerItemKeys.delete(itemKey);
2326
2326
  }
2327
2327
  state.containerItemTypes.delete(i);
@@ -2991,7 +2991,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2991
2991
  const stylePaddingTopState = extractPadding(style, contentContainerStyle, "Top");
2992
2992
  const stylePaddingBottomState = extractPadding(style, contentContainerStyle, "Bottom");
2993
2993
  const [renderNum, setRenderNum] = React2.useState(0);
2994
- const initialScrollProp = initialScrollAtEnd ? { index: dataProp.length - 1, viewOffset: -stylePaddingBottomState } : initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
2994
+ const initialScrollProp = initialScrollAtEnd ? { index: Math.max(0, dataProp.length - 1), viewOffset: -stylePaddingBottomState } : initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
2995
2995
  const [canRender, setCanRender] = React2__namespace.useState(!IsNewArchitecture);
2996
2996
  const ctx = useStateContext();
2997
2997
  ctx.columnWrapperStyle = columnWrapperStyle || (contentContainerStyle ? createColumnWrapperStyle(contentContainerStyle) : void 0);
@@ -3283,6 +3283,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3283
3283
  activeStickyIndex: state2.activeStickyIndex,
3284
3284
  contentLength: state2.totalSize,
3285
3285
  data: state2.props.data,
3286
+ elementAtIndex: (index) => {
3287
+ var _a4;
3288
+ return (_a4 = ctx.viewRefs.get(findContainerId(ctx, getId(state2, index)))) == null ? void 0 : _a4.current;
3289
+ },
3286
3290
  end: state2.endNoBuffer,
3287
3291
  endBuffered: state2.endBuffered,
3288
3292
  isAtEnd: state2.isAtEnd,
package/index.native.mjs CHANGED
@@ -333,6 +333,16 @@ function getPadding(s, type) {
333
333
  function extractPadding(style, contentContainerStyle, type) {
334
334
  return getPadding(style, type) + getPadding(contentContainerStyle, type);
335
335
  }
336
+ function findContainerId(ctx, key) {
337
+ const numContainers = peek$(ctx, "numContainers");
338
+ for (let i = 0; i < numContainers; i++) {
339
+ const itemKey = peek$(ctx, `containerItemKey${i}`);
340
+ if (itemKey === key) {
341
+ return i;
342
+ }
343
+ }
344
+ return -1;
345
+ }
336
346
 
337
347
  // src/state/ContextContainer.ts
338
348
  var ContextContainer = createContext(null);
@@ -1758,16 +1768,6 @@ function isViewable(state, ctx, viewabilityConfig, containerId, key, scrollSize,
1758
1768
  const value = ctx.mapViewabilityAmountValues.get(containerId) || computeViewability(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index);
1759
1769
  return value.isViewable;
1760
1770
  }
1761
- function findContainerId(ctx, key) {
1762
- const numContainers = peek$(ctx, "numContainers");
1763
- for (let i = 0; i < numContainers; i++) {
1764
- const itemKey = peek$(ctx, `containerItemKey${i}`);
1765
- if (itemKey === key) {
1766
- return i;
1767
- }
1768
- }
1769
- return -1;
1770
- }
1771
1771
  function maybeUpdateViewabilityCallback(ctx, configId, containerId, viewToken) {
1772
1772
  const key = containerId + configId;
1773
1773
  ctx.mapViewabilityValues.set(key, viewToken);
@@ -2300,7 +2300,7 @@ function calculateItemsInView(ctx, state, params = {}) {
2300
2300
  for (let i = 0; i < numContainers; i++) {
2301
2301
  const itemKey = peek$(ctx, `containerItemKey${i}`);
2302
2302
  if (pendingRemoval.includes(i)) {
2303
- if (itemKey) {
2303
+ if (itemKey !== void 0) {
2304
2304
  containerItemKeys.delete(itemKey);
2305
2305
  }
2306
2306
  state.containerItemTypes.delete(i);
@@ -2970,7 +2970,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
2970
2970
  const stylePaddingTopState = extractPadding(style, contentContainerStyle, "Top");
2971
2971
  const stylePaddingBottomState = extractPadding(style, contentContainerStyle, "Bottom");
2972
2972
  const [renderNum, setRenderNum] = useState(0);
2973
- const initialScrollProp = initialScrollAtEnd ? { index: dataProp.length - 1, viewOffset: -stylePaddingBottomState } : initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
2973
+ const initialScrollProp = initialScrollAtEnd ? { index: Math.max(0, dataProp.length - 1), viewOffset: -stylePaddingBottomState } : initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
2974
2974
  const [canRender, setCanRender] = React2.useState(!IsNewArchitecture);
2975
2975
  const ctx = useStateContext();
2976
2976
  ctx.columnWrapperStyle = columnWrapperStyle || (contentContainerStyle ? createColumnWrapperStyle(contentContainerStyle) : void 0);
@@ -3262,6 +3262,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
3262
3262
  activeStickyIndex: state2.activeStickyIndex,
3263
3263
  contentLength: state2.totalSize,
3264
3264
  data: state2.props.data,
3265
+ elementAtIndex: (index) => {
3266
+ var _a4;
3267
+ return (_a4 = ctx.viewRefs.get(findContainerId(ctx, getId(state2, index)))) == null ? void 0 : _a4.current;
3268
+ },
3265
3269
  end: state2.endNoBuffer,
3266
3270
  endBuffered: state2.endBuffered,
3267
3271
  isAtEnd: state2.isAtEnd,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "2.1.0-beta.8",
3
+ "version": "2.1.0-beta.9",
4
4
  "description": "Legend List is a drop-in replacement for FlatList with much better performance and supporting dynamically sized items.",
5
5
  "sideEffects": false,
6
6
  "private": false,