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

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?: 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?: 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?: 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?: StyleProp<ViewStyle> | undefined;
480
480
  maintainScrollAtEnd?: boolean;
481
481
  maintainScrollAtEndThreshold?: number;
482
482
  maintainVisibleContentPosition?: boolean;
package/index.js CHANGED
@@ -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,16 @@ 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 } = reactNative.StyleSheet.flatten(contentContainerStyle);
785
+ if (gap || columnGap || rowGap) {
786
+ return {
787
+ gap,
788
+ columnGap,
789
+ rowGap
790
+ };
791
+ }
792
+ }
783
793
  var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
784
794
  return /* @__PURE__ */ React6__namespace.createElement(StateProvider, null, /* @__PURE__ */ React6__namespace.createElement(LegendListInner, { ...props, ref: forwardedRef }));
785
795
  });
@@ -831,7 +841,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
831
841
  callbacks.current.onStartReached = rest.onStartReached;
832
842
  callbacks.current.onEndReached = rest.onEndReached;
833
843
  const ctx = useStateContext();
834
- ctx.columnWrapperStyle = columnWrapperStyle;
844
+ ctx.columnWrapperStyle = columnWrapperStyle || (contentContainerStyle ? createColumnWrapperStyle(contentContainerStyle) : void 0);
835
845
  const refScroller = React6.useRef(null);
836
846
  const combinedRef = useCombinedRef(refScroller, refScrollView);
837
847
  const scrollBuffer = (drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE) || 1;
@@ -926,13 +936,14 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
926
936
  lastBatchingAction: Date.now(),
927
937
  onScroll: onScrollProp
928
938
  };
929
- if (maintainVisibleContentPosition) {
930
- if (initialScrollIndex) {
939
+ const dataLength = dataProp.length;
940
+ if (maintainVisibleContentPosition && dataLength > 0) {
941
+ if (initialScrollIndex && initialScrollIndex < dataLength) {
931
942
  refState.current.anchorElement = {
932
943
  coordinate: initialContentOffset,
933
944
  id: getId(initialScrollIndex)
934
945
  };
935
- } else if (dataProp.length) {
946
+ } else if (dataLength > 0) {
936
947
  refState.current.anchorElement = {
937
948
  coordinate: initialContentOffset,
938
949
  id: getId(0)
package/index.mjs CHANGED
@@ -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,16 @@ 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 } = StyleSheet.flatten(contentContainerStyle);
764
+ if (gap || columnGap || rowGap) {
765
+ return {
766
+ gap,
767
+ columnGap,
768
+ rowGap
769
+ };
770
+ }
771
+ }
762
772
  var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
763
773
  return /* @__PURE__ */ React6.createElement(StateProvider, null, /* @__PURE__ */ React6.createElement(LegendListInner, { ...props, ref: forwardedRef }));
764
774
  });
@@ -810,7 +820,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
810
820
  callbacks.current.onStartReached = rest.onStartReached;
811
821
  callbacks.current.onEndReached = rest.onEndReached;
812
822
  const ctx = useStateContext();
813
- ctx.columnWrapperStyle = columnWrapperStyle;
823
+ ctx.columnWrapperStyle = columnWrapperStyle || (contentContainerStyle ? createColumnWrapperStyle(contentContainerStyle) : void 0);
814
824
  const refScroller = useRef(null);
815
825
  const combinedRef = useCombinedRef(refScroller, refScrollView);
816
826
  const scrollBuffer = (drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE) || 1;
@@ -905,13 +915,14 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
905
915
  lastBatchingAction: Date.now(),
906
916
  onScroll: onScrollProp
907
917
  };
908
- if (maintainVisibleContentPosition) {
909
- if (initialScrollIndex) {
918
+ const dataLength = dataProp.length;
919
+ if (maintainVisibleContentPosition && dataLength > 0) {
920
+ if (initialScrollIndex && initialScrollIndex < dataLength) {
910
921
  refState.current.anchorElement = {
911
922
  coordinate: initialContentOffset,
912
923
  id: getId(initialScrollIndex)
913
924
  };
914
- } else if (dataProp.length) {
925
+ } else if (dataLength > 0) {
915
926
  refState.current.anchorElement = {
916
927
  coordinate: initialContentOffset,
917
928
  id: getId(0)
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.33",
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,