@legendapp/list 1.0.0-beta.32 → 1.0.0-beta.34

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
@@ -474,9 +474,9 @@ declare const LegendList: <T>(props: Omit<react_native.ScrollViewProps, "content
474
474
  keyExtractor?: ((item: T, index: number) => string) | undefined;
475
475
  ListEmptyComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
476
476
  ListFooterComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
477
- ListFooterComponentStyle?: react_native.StyleProp<react_native.ViewStyle> | undefined;
477
+ ListFooterComponentStyle?: react_native.StyleProp<ViewStyle> | undefined;
478
478
  ListHeaderComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
479
- ListHeaderComponentStyle?: react_native.StyleProp<react_native.ViewStyle> | undefined;
479
+ ListHeaderComponentStyle?: react_native.StyleProp<ViewStyle> | undefined;
480
480
  maintainScrollAtEnd?: boolean;
481
481
  maintainScrollAtEndThreshold?: number;
482
482
  maintainVisibleContentPosition?: boolean;
package/index.d.ts CHANGED
@@ -474,9 +474,9 @@ declare const LegendList: <T>(props: Omit<react_native.ScrollViewProps, "content
474
474
  keyExtractor?: ((item: T, index: number) => string) | undefined;
475
475
  ListEmptyComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
476
476
  ListFooterComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
477
- ListFooterComponentStyle?: react_native.StyleProp<react_native.ViewStyle> | undefined;
477
+ ListFooterComponentStyle?: react_native.StyleProp<ViewStyle> | undefined;
478
478
  ListHeaderComponent?: React$1.ComponentType<any> | React$1.ReactElement | null | undefined;
479
- ListHeaderComponentStyle?: react_native.StyleProp<react_native.ViewStyle> | undefined;
479
+ ListHeaderComponentStyle?: react_native.StyleProp<ViewStyle> | undefined;
480
480
  maintainScrollAtEnd?: boolean;
481
481
  maintainScrollAtEndThreshold?: number;
482
482
  maintainVisibleContentPosition?: boolean;
package/index.js CHANGED
@@ -261,7 +261,7 @@ var Container = ({
261
261
  const otherAxisPos = numColumns > 1 ? `${(column - 1) / numColumns * 100}%` : 0;
262
262
  const otherAxisSize = numColumns > 1 ? `${1 / numColumns * 100}%` : void 0;
263
263
  let verticalPaddingStyles;
264
- if (columnWrapperStyle && !horizontal && numColumns > 1) {
264
+ if (columnWrapperStyle) {
265
265
  const { columnGap, rowGap, gap } = columnWrapperStyle;
266
266
  verticalPaddingStyles = {
267
267
  paddingBottom: !lastItemKeys.includes(itemKey) ? rowGap || gap || void 0 : void 0,
@@ -526,7 +526,7 @@ var ListComponent = typedMemo(function ListComponent2({
526
526
  contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
527
527
  ref: refScrollView
528
528
  },
529
- ENABLE_DEVMODE ? /* @__PURE__ */ React6__namespace.createElement(PaddingAndAdjustDevMode, null) : /* @__PURE__ */ React6__namespace.createElement(PaddingAndAdjust, null),
529
+ !ListEmptyComponent && (ENABLE_DEVMODE ? /* @__PURE__ */ React6__namespace.createElement(PaddingAndAdjustDevMode, null) : /* @__PURE__ */ React6__namespace.createElement(PaddingAndAdjust, null)),
530
530
  ListHeaderComponent && /* @__PURE__ */ React6__namespace.createElement(
531
531
  reactNative.View,
532
532
  {
@@ -780,6 +780,19 @@ function maybeUpdateViewabilityCallback(ctx, configId, viewToken) {
780
780
  // src/LegendList.tsx
781
781
  var DEFAULT_DRAW_DISTANCE = 250;
782
782
  var DEFAULT_ITEM_SIZE = 100;
783
+ function createColumnWrapperStyle(contentContainerStyle) {
784
+ const { gap, columnGap, rowGap } = contentContainerStyle;
785
+ if (gap || columnGap || rowGap) {
786
+ contentContainerStyle.gap = void 0;
787
+ contentContainerStyle.columnGap = void 0;
788
+ contentContainerStyle.rowGap = void 0;
789
+ return {
790
+ gap,
791
+ columnGap,
792
+ rowGap
793
+ };
794
+ }
795
+ }
783
796
  var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
784
797
  return /* @__PURE__ */ React6__namespace.createElement(StateProvider, null, /* @__PURE__ */ React6__namespace.createElement(LegendListInner, { ...props, ref: forwardedRef }));
785
798
  });
@@ -812,6 +825,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
812
825
  refScrollView,
813
826
  waitForInitialLayout = true,
814
827
  extraData,
828
+ contentContainerStyle: contentContainerStyleProp,
815
829
  onLayout: onLayoutProp,
816
830
  onRefresh,
817
831
  refreshing,
@@ -823,15 +837,16 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
823
837
  onViewableItemsChanged,
824
838
  ...rest
825
839
  } = props;
826
- const { style, contentContainerStyle } = props;
840
+ const { style } = props;
827
841
  const callbacks = React6.useRef({
828
842
  onStartReached: rest.onStartReached,
829
843
  onEndReached: rest.onEndReached
830
844
  });
831
845
  callbacks.current.onStartReached = rest.onStartReached;
832
846
  callbacks.current.onEndReached = rest.onEndReached;
847
+ const contentContainerStyle = reactNative.StyleSheet.flatten(contentContainerStyleProp);
833
848
  const ctx = useStateContext();
834
- ctx.columnWrapperStyle = columnWrapperStyle;
849
+ ctx.columnWrapperStyle = columnWrapperStyle || (contentContainerStyle ? createColumnWrapperStyle(contentContainerStyle) : void 0);
835
850
  const refScroller = React6.useRef(null);
836
851
  const combinedRef = useCombinedRef(refScroller, refScrollView);
837
852
  const scrollBuffer = (drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE) || 1;
@@ -926,13 +941,14 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
926
941
  lastBatchingAction: Date.now(),
927
942
  onScroll: onScrollProp
928
943
  };
929
- if (maintainVisibleContentPosition) {
930
- if (initialScrollIndex) {
944
+ const dataLength = dataProp.length;
945
+ if (maintainVisibleContentPosition && dataLength > 0) {
946
+ if (initialScrollIndex && initialScrollIndex < dataLength) {
931
947
  refState.current.anchorElement = {
932
948
  coordinate: initialContentOffset,
933
949
  id: getId(initialScrollIndex)
934
950
  };
935
- } else if (dataProp.length) {
951
+ } else if (dataLength > 0) {
936
952
  refState.current.anchorElement = {
937
953
  coordinate: initialContentOffset,
938
954
  id: getId(0)
@@ -1982,7 +1998,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1982
1998
  progressViewOffset
1983
1999
  }
1984
2000
  ),
1985
- style
2001
+ style,
2002
+ contentContainerStyle
1986
2003
  }
1987
2004
  ), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */ React6__namespace.createElement(DebugView, { state: refState.current }));
1988
2005
  });
package/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React6 from 'react';
2
2
  import React6__default, { createContext, memo, useReducer, useEffect, useMemo, useRef, useCallback, useImperativeHandle, useSyncExternalStore, useContext, useState, forwardRef, useLayoutEffect } from 'react';
3
- import { View, Text, Platform, Animated, ScrollView, Dimensions, StyleSheet, RefreshControl } from 'react-native';
3
+ import { View, Text, Platform, Animated, ScrollView, StyleSheet, Dimensions, RefreshControl } from 'react-native';
4
4
 
5
5
  // src/LegendList.tsx
6
6
  var ContextState = React6.createContext(null);
@@ -240,7 +240,7 @@ var Container = ({
240
240
  const otherAxisPos = numColumns > 1 ? `${(column - 1) / numColumns * 100}%` : 0;
241
241
  const otherAxisSize = numColumns > 1 ? `${1 / numColumns * 100}%` : void 0;
242
242
  let verticalPaddingStyles;
243
- if (columnWrapperStyle && !horizontal && numColumns > 1) {
243
+ if (columnWrapperStyle) {
244
244
  const { columnGap, rowGap, gap } = columnWrapperStyle;
245
245
  verticalPaddingStyles = {
246
246
  paddingBottom: !lastItemKeys.includes(itemKey) ? rowGap || gap || void 0 : void 0,
@@ -505,7 +505,7 @@ var ListComponent = typedMemo(function ListComponent2({
505
505
  contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
506
506
  ref: refScrollView
507
507
  },
508
- ENABLE_DEVMODE ? /* @__PURE__ */ React6.createElement(PaddingAndAdjustDevMode, null) : /* @__PURE__ */ React6.createElement(PaddingAndAdjust, null),
508
+ !ListEmptyComponent && (ENABLE_DEVMODE ? /* @__PURE__ */ React6.createElement(PaddingAndAdjustDevMode, null) : /* @__PURE__ */ React6.createElement(PaddingAndAdjust, null)),
509
509
  ListHeaderComponent && /* @__PURE__ */ React6.createElement(
510
510
  View,
511
511
  {
@@ -759,6 +759,19 @@ function maybeUpdateViewabilityCallback(ctx, configId, viewToken) {
759
759
  // src/LegendList.tsx
760
760
  var DEFAULT_DRAW_DISTANCE = 250;
761
761
  var DEFAULT_ITEM_SIZE = 100;
762
+ function createColumnWrapperStyle(contentContainerStyle) {
763
+ const { gap, columnGap, rowGap } = contentContainerStyle;
764
+ if (gap || columnGap || rowGap) {
765
+ contentContainerStyle.gap = void 0;
766
+ contentContainerStyle.columnGap = void 0;
767
+ contentContainerStyle.rowGap = void 0;
768
+ return {
769
+ gap,
770
+ columnGap,
771
+ rowGap
772
+ };
773
+ }
774
+ }
762
775
  var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
763
776
  return /* @__PURE__ */ React6.createElement(StateProvider, null, /* @__PURE__ */ React6.createElement(LegendListInner, { ...props, ref: forwardedRef }));
764
777
  });
@@ -791,6 +804,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
791
804
  refScrollView,
792
805
  waitForInitialLayout = true,
793
806
  extraData,
807
+ contentContainerStyle: contentContainerStyleProp,
794
808
  onLayout: onLayoutProp,
795
809
  onRefresh,
796
810
  refreshing,
@@ -802,15 +816,16 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
802
816
  onViewableItemsChanged,
803
817
  ...rest
804
818
  } = props;
805
- const { style, contentContainerStyle } = props;
819
+ const { style } = props;
806
820
  const callbacks = useRef({
807
821
  onStartReached: rest.onStartReached,
808
822
  onEndReached: rest.onEndReached
809
823
  });
810
824
  callbacks.current.onStartReached = rest.onStartReached;
811
825
  callbacks.current.onEndReached = rest.onEndReached;
826
+ const contentContainerStyle = StyleSheet.flatten(contentContainerStyleProp);
812
827
  const ctx = useStateContext();
813
- ctx.columnWrapperStyle = columnWrapperStyle;
828
+ ctx.columnWrapperStyle = columnWrapperStyle || (contentContainerStyle ? createColumnWrapperStyle(contentContainerStyle) : void 0);
814
829
  const refScroller = useRef(null);
815
830
  const combinedRef = useCombinedRef(refScroller, refScrollView);
816
831
  const scrollBuffer = (drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE) || 1;
@@ -905,13 +920,14 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
905
920
  lastBatchingAction: Date.now(),
906
921
  onScroll: onScrollProp
907
922
  };
908
- if (maintainVisibleContentPosition) {
909
- if (initialScrollIndex) {
923
+ const dataLength = dataProp.length;
924
+ if (maintainVisibleContentPosition && dataLength > 0) {
925
+ if (initialScrollIndex && initialScrollIndex < dataLength) {
910
926
  refState.current.anchorElement = {
911
927
  coordinate: initialContentOffset,
912
928
  id: getId(initialScrollIndex)
913
929
  };
914
- } else if (dataProp.length) {
930
+ } else if (dataLength > 0) {
915
931
  refState.current.anchorElement = {
916
932
  coordinate: initialContentOffset,
917
933
  id: getId(0)
@@ -1961,7 +1977,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1961
1977
  progressViewOffset
1962
1978
  }
1963
1979
  ),
1964
- style
1980
+ style,
1981
+ contentContainerStyle
1965
1982
  }
1966
1983
  ), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */ React6.createElement(DebugView, { state: refState.current }));
1967
1984
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "1.0.0-beta.32",
3
+ "version": "1.0.0-beta.34",
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,