@legendapp/list 0.1.0 → 0.1.1

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.
Files changed (3) hide show
  1. package/index.js +15 -6
  2. package/index.mjs +15 -6
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -81,7 +81,7 @@ function LegendList(props) {
81
81
  contentContainerStyle,
82
82
  initialContainers,
83
83
  drawDistance,
84
- recycleItems = true,
84
+ recycleItems = false,
85
85
  onEndReachedThreshold,
86
86
  autoScrollToBottom = false,
87
87
  autoScrollToBottomThreshold = 0.1,
@@ -90,8 +90,10 @@ function LegendList(props) {
90
90
  estimatedItemLength,
91
91
  onEndReached,
92
92
  onViewableRangeChanged,
93
+ children,
93
94
  ...rest
94
95
  } = props;
96
+ const childrenArray = children && !data ? React2__namespace.Children.toArray(children) : void 0;
95
97
  const refScroller = React2.useRef(null);
96
98
  const containers$ = react.useObservable(() => []);
97
99
  const visibleRange$ = react.useObservable(() => ({
@@ -109,7 +111,7 @@ function LegendList(props) {
109
111
  if (!data2) {
110
112
  return "";
111
113
  }
112
- const ret = index < data2.length ? keyExtractor ? keyExtractor(data2[index], index) : index : null;
114
+ const ret = index < (data2 || childrenArray).length ? data2 ? keyExtractor ? keyExtractor(data2[index], index) : index : index : null;
113
115
  return ret + "";
114
116
  };
115
117
  if (!refPositions.current) {
@@ -123,11 +125,13 @@ function LegendList(props) {
123
125
  isAtBottom: false,
124
126
  data,
125
127
  idsInFirstRender: void 0,
126
- hasScrolled: false
128
+ hasScrolled: false,
129
+ childrenArray
127
130
  };
128
- refPositions.current.idsInFirstRender = new Set(data.map((_, i) => getId(i)));
131
+ refPositions.current.idsInFirstRender = new Set((data || childrenArray).map((_, i) => getId(i)));
129
132
  }
130
133
  refPositions.current.data = data;
134
+ refPositions.current.childrenArray = childrenArray;
131
135
  const SCREEN_LENGTH = reactNative.Dimensions.get("window")[horizontal ? "width" : "height"];
132
136
  const initialContentOffset = initialScrollOffset != null ? initialScrollOffset : initialScrollIndex ? initialScrollIndex * estimatedItemLength(initialScrollIndex) : void 0;
133
137
  const allocateContainers = React2.useCallback(() => {
@@ -144,10 +148,15 @@ function LegendList(props) {
144
148
  }, []);
145
149
  const getRenderedItem = React2.useCallback(
146
150
  (index) => {
147
- var _a;
151
+ var _a, _b;
148
152
  const data2 = (_a = refPositions.current) == null ? void 0 : _a.data;
149
153
  if (!data2) {
150
- return null;
154
+ const childrenArray2 = (_b = refPositions.current) == null ? void 0 : _b.childrenArray;
155
+ if (childrenArray2) {
156
+ return childrenArray2[index];
157
+ } else {
158
+ return null;
159
+ }
151
160
  }
152
161
  const renderedItem = renderItem == null ? void 0 : renderItem({
153
162
  item: data2[index],
package/index.mjs CHANGED
@@ -60,7 +60,7 @@ function LegendList(props) {
60
60
  contentContainerStyle,
61
61
  initialContainers,
62
62
  drawDistance,
63
- recycleItems = true,
63
+ recycleItems = false,
64
64
  onEndReachedThreshold,
65
65
  autoScrollToBottom = false,
66
66
  autoScrollToBottomThreshold = 0.1,
@@ -69,8 +69,10 @@ function LegendList(props) {
69
69
  estimatedItemLength,
70
70
  onEndReached,
71
71
  onViewableRangeChanged,
72
+ children,
72
73
  ...rest
73
74
  } = props;
75
+ const childrenArray = children && !data ? React2.Children.toArray(children) : void 0;
74
76
  const refScroller = useRef(null);
75
77
  const containers$ = useObservable(() => []);
76
78
  const visibleRange$ = useObservable(() => ({
@@ -88,7 +90,7 @@ function LegendList(props) {
88
90
  if (!data2) {
89
91
  return "";
90
92
  }
91
- const ret = index < data2.length ? keyExtractor ? keyExtractor(data2[index], index) : index : null;
93
+ const ret = index < (data2 || childrenArray).length ? data2 ? keyExtractor ? keyExtractor(data2[index], index) : index : index : null;
92
94
  return ret + "";
93
95
  };
94
96
  if (!refPositions.current) {
@@ -102,11 +104,13 @@ function LegendList(props) {
102
104
  isAtBottom: false,
103
105
  data,
104
106
  idsInFirstRender: void 0,
105
- hasScrolled: false
107
+ hasScrolled: false,
108
+ childrenArray
106
109
  };
107
- refPositions.current.idsInFirstRender = new Set(data.map((_, i) => getId(i)));
110
+ refPositions.current.idsInFirstRender = new Set((data || childrenArray).map((_, i) => getId(i)));
108
111
  }
109
112
  refPositions.current.data = data;
113
+ refPositions.current.childrenArray = childrenArray;
110
114
  const SCREEN_LENGTH = Dimensions.get("window")[horizontal ? "width" : "height"];
111
115
  const initialContentOffset = initialScrollOffset != null ? initialScrollOffset : initialScrollIndex ? initialScrollIndex * estimatedItemLength(initialScrollIndex) : void 0;
112
116
  const allocateContainers = useCallback(() => {
@@ -123,10 +127,15 @@ function LegendList(props) {
123
127
  }, []);
124
128
  const getRenderedItem = useCallback(
125
129
  (index) => {
126
- var _a;
130
+ var _a, _b;
127
131
  const data2 = (_a = refPositions.current) == null ? void 0 : _a.data;
128
132
  if (!data2) {
129
- return null;
133
+ const childrenArray2 = (_b = refPositions.current) == null ? void 0 : _b.childrenArray;
134
+ if (childrenArray2) {
135
+ return childrenArray2[index];
136
+ } else {
137
+ return null;
138
+ }
130
139
  }
131
140
  const renderedItem = renderItem == null ? void 0 : renderItem({
132
141
  item: data2[index],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "legend-list",
5
5
  "sideEffects": false,
6
6
  "private": false,