@legendapp/list 3.0.0 → 3.0.2
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/CHANGELOG.md +10 -0
- package/package.json +1 -1
- package/react-native.js +1201 -1183
- package/react-native.mjs +1201 -1183
- package/react-native.web.js +1338 -1321
- package/react-native.web.mjs +1338 -1321
- package/react.js +1338 -1321
- package/react.mjs +1338 -1321
- package/section-list.d.ts +19 -2
- package/section-list.js +47 -26
- package/section-list.mjs +47 -26
package/section-list.d.ts
CHANGED
|
@@ -729,7 +729,22 @@ type SectionListOnViewableItemsChanged<ItemT, SectionT> = ((info: {
|
|
|
729
729
|
start: number;
|
|
730
730
|
startBuffered: number;
|
|
731
731
|
}) => void) | null;
|
|
732
|
-
type
|
|
732
|
+
type SectionListFlatItem<ItemT, SectionT extends SectionBase<ItemT>> = FlatSectionListItem<ItemT, SectionListData<ItemT, SectionT>>;
|
|
733
|
+
type SectionListGetFixedItemSizeInfo<ItemT, SectionT extends SectionBase<ItemT>> = (SectionListRenderItemInfo<ItemT, SectionT> & {
|
|
734
|
+
type: "item";
|
|
735
|
+
}) | {
|
|
736
|
+
section: SectionListData<ItemT, SectionT>;
|
|
737
|
+
type: "header";
|
|
738
|
+
} | {
|
|
739
|
+
section: SectionListData<ItemT, SectionT>;
|
|
740
|
+
type: "footer";
|
|
741
|
+
} | ({
|
|
742
|
+
type: "item-separator";
|
|
743
|
+
} & SectionListSeparatorProps<ItemT, SectionT>) | ({
|
|
744
|
+
type: "section-separator";
|
|
745
|
+
} & SectionListSeparatorProps<ItemT, SectionT>);
|
|
746
|
+
type SectionListGetFixedItemSize<ItemT, SectionT extends SectionBase<ItemT>> = (info: SectionListGetFixedItemSizeInfo<ItemT, SectionT>) => number | undefined;
|
|
747
|
+
type SectionListLegendProps<ItemT, SectionT extends SectionBase<ItemT>> = Omit<LegendListProps<SectionListFlatItem<ItemT, SectionT>>, "data" | "children" | "renderItem" | "keyExtractor" | "ItemSeparatorComponent" | "getItemType" | "getFixedItemSize" | "stickyHeaderIndices" | "numColumns" | "columnWrapperStyle" | "onViewableItemsChanged">;
|
|
733
748
|
type SectionListProps<ItemT, SectionT extends SectionBase<ItemT> = SectionBase<ItemT>> = SectionListLegendProps<ItemT, SectionT> & {
|
|
734
749
|
sections: ReadonlyArray<SectionListData<ItemT, SectionT>>;
|
|
735
750
|
extraData?: any;
|
|
@@ -742,6 +757,7 @@ type SectionListProps<ItemT, SectionT extends SectionBase<ItemT> = SectionBase<I
|
|
|
742
757
|
}) => React.ReactElement | null;
|
|
743
758
|
ItemSeparatorComponent?: React.ComponentType<SectionListSeparatorProps<ItemT, SectionT>> | null;
|
|
744
759
|
SectionSeparatorComponent?: React.ComponentType<SectionListSeparatorProps<ItemT, SectionT>> | React.ReactElement | null;
|
|
760
|
+
getFixedItemSize?: SectionListGetFixedItemSize<ItemT, SectionT>;
|
|
745
761
|
keyExtractor?: (item: ItemT, index: number) => string;
|
|
746
762
|
stickySectionHeadersEnabled?: boolean;
|
|
747
763
|
onViewableItemsChanged?: SectionListOnViewableItemsChanged<ItemT, SectionT>;
|
|
@@ -761,6 +777,7 @@ declare const SectionList: (<ItemT, SectionT extends SectionBase<ItemT, react_na
|
|
|
761
777
|
}) => React.ReactElement | null) | undefined;
|
|
762
778
|
ItemSeparatorComponent?: React.ComponentType<SectionListSeparatorProps<ItemT, SectionT>> | null | undefined;
|
|
763
779
|
SectionSeparatorComponent?: React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | React.ComponentType<SectionListSeparatorProps<ItemT, SectionT>> | null | undefined;
|
|
780
|
+
getFixedItemSize?: SectionListGetFixedItemSize<ItemT, SectionT> | undefined;
|
|
764
781
|
keyExtractor?: ((item: ItemT, index: number) => string) | undefined;
|
|
765
782
|
stickySectionHeadersEnabled?: boolean;
|
|
766
783
|
onViewableItemsChanged?: SectionListOnViewableItemsChanged<ItemT, SectionT> | undefined;
|
|
@@ -768,4 +785,4 @@ declare const SectionList: (<ItemT, SectionT extends SectionBase<ItemT, react_na
|
|
|
768
785
|
displayName?: string;
|
|
769
786
|
};
|
|
770
787
|
|
|
771
|
-
export { type BuildSectionListDataResult, type FlatSectionListItem, SectionList, type SectionListOnViewableItemsChanged, type SectionListProps, type SectionListRef, type SectionListSeparatorProps, type SectionListViewToken, type SectionMeta };
|
|
788
|
+
export { type BuildSectionListDataResult, type FlatSectionListItem, SectionList, type SectionListGetFixedItemSize, type SectionListGetFixedItemSizeInfo, type SectionListOnViewableItemsChanged, type SectionListProps, type SectionListRef, type SectionListSeparatorProps, type SectionListViewToken, type SectionMeta };
|
package/section-list.js
CHANGED
|
@@ -132,6 +132,38 @@ var defaultSeparators = {
|
|
|
132
132
|
updateProps: () => {
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
|
+
function getSectionListItemInfo(item) {
|
|
136
|
+
switch (item.kind) {
|
|
137
|
+
case "item":
|
|
138
|
+
return {
|
|
139
|
+
index: item.itemIndex,
|
|
140
|
+
item: item.item,
|
|
141
|
+
section: item.section,
|
|
142
|
+
separators: defaultSeparators,
|
|
143
|
+
type: item.kind
|
|
144
|
+
};
|
|
145
|
+
case "item-separator":
|
|
146
|
+
return {
|
|
147
|
+
leadingItem: item.leadingItem,
|
|
148
|
+
leadingSection: item.section,
|
|
149
|
+
section: item.section,
|
|
150
|
+
trailingItem: item.trailingItem,
|
|
151
|
+
trailingSection: item.section,
|
|
152
|
+
type: item.kind
|
|
153
|
+
};
|
|
154
|
+
case "section-separator":
|
|
155
|
+
return {
|
|
156
|
+
leadingItem: void 0,
|
|
157
|
+
leadingSection: item.leadingSection,
|
|
158
|
+
section: item.leadingSection,
|
|
159
|
+
trailingItem: void 0,
|
|
160
|
+
trailingSection: item.trailingSection,
|
|
161
|
+
type: item.kind
|
|
162
|
+
};
|
|
163
|
+
default:
|
|
164
|
+
return { section: item.section, type: item.kind };
|
|
165
|
+
}
|
|
166
|
+
}
|
|
135
167
|
function resolveSeparatorComponent(component, props) {
|
|
136
168
|
if (!component) return null;
|
|
137
169
|
if (React__namespace.isValidElement(component)) {
|
|
@@ -153,6 +185,7 @@ var SectionList = typedMemo(
|
|
|
153
185
|
keyExtractor,
|
|
154
186
|
extraData,
|
|
155
187
|
onViewableItemsChanged,
|
|
188
|
+
getFixedItemSize,
|
|
156
189
|
horizontal,
|
|
157
190
|
...restProps
|
|
158
191
|
} = props;
|
|
@@ -180,6 +213,10 @@ var SectionList = typedMemo(
|
|
|
180
213
|
]
|
|
181
214
|
);
|
|
182
215
|
const { data, sectionMeta, stickyHeaderIndices } = flattened;
|
|
216
|
+
const handleGetFixedItemSize = React__namespace.useCallback(
|
|
217
|
+
(item) => getFixedItemSize == null ? void 0 : getFixedItemSize(getSectionListItemInfo(item)),
|
|
218
|
+
[getFixedItemSize]
|
|
219
|
+
);
|
|
183
220
|
const handleViewableItemsChanged = React__namespace.useMemo(() => {
|
|
184
221
|
if (!onViewableItemsChanged) return void 0;
|
|
185
222
|
return ({
|
|
@@ -215,39 +252,22 @@ var SectionList = typedMemo(
|
|
|
215
252
|
const renderItem = React__namespace.useCallback(
|
|
216
253
|
({ item }) => {
|
|
217
254
|
var _a, _b;
|
|
218
|
-
|
|
255
|
+
const info = getSectionListItemInfo(item);
|
|
256
|
+
switch (info.type) {
|
|
219
257
|
case "header":
|
|
220
|
-
return renderSectionHeader ? renderSectionHeader(
|
|
258
|
+
return renderSectionHeader ? renderSectionHeader(info) : null;
|
|
221
259
|
case "footer":
|
|
222
|
-
return renderSectionFooter ? renderSectionFooter(
|
|
260
|
+
return renderSectionFooter ? renderSectionFooter(info) : null;
|
|
223
261
|
case "item": {
|
|
224
|
-
const render = (_a =
|
|
225
|
-
|
|
226
|
-
return render({
|
|
227
|
-
index: item.itemIndex,
|
|
228
|
-
item: item.item,
|
|
229
|
-
section: item.section,
|
|
230
|
-
separators: defaultSeparators
|
|
231
|
-
});
|
|
262
|
+
const render = (_a = info.section.renderItem) != null ? _a : renderItemProp;
|
|
263
|
+
return render ? render(info) : null;
|
|
232
264
|
}
|
|
233
265
|
case "item-separator": {
|
|
234
|
-
const SeparatorComponent = (_b =
|
|
235
|
-
return resolveSeparatorComponent(SeparatorComponent,
|
|
236
|
-
leadingItem: item.leadingItem,
|
|
237
|
-
leadingSection: item.section,
|
|
238
|
-
section: item.section,
|
|
239
|
-
trailingItem: item.trailingItem,
|
|
240
|
-
trailingSection: item.section
|
|
241
|
-
});
|
|
266
|
+
const SeparatorComponent = (_b = info.section.ItemSeparatorComponent) != null ? _b : ItemSeparatorComponent;
|
|
267
|
+
return resolveSeparatorComponent(SeparatorComponent, info);
|
|
242
268
|
}
|
|
243
269
|
case "section-separator":
|
|
244
|
-
return resolveSeparatorComponent(SectionSeparatorComponent,
|
|
245
|
-
leadingItem: void 0,
|
|
246
|
-
leadingSection: item.leadingSection,
|
|
247
|
-
section: item.leadingSection,
|
|
248
|
-
trailingItem: void 0,
|
|
249
|
-
trailingSection: item.trailingSection
|
|
250
|
-
});
|
|
270
|
+
return resolveSeparatorComponent(SectionSeparatorComponent, info);
|
|
251
271
|
default:
|
|
252
272
|
return null;
|
|
253
273
|
}
|
|
@@ -290,6 +310,7 @@ var SectionList = typedMemo(
|
|
|
290
310
|
...restProps,
|
|
291
311
|
columnWrapperStyle: void 0,
|
|
292
312
|
data,
|
|
313
|
+
getFixedItemSize: getFixedItemSize ? handleGetFixedItemSize : void 0,
|
|
293
314
|
getItemType: (item) => item.kind,
|
|
294
315
|
keyExtractor: (item) => item.key,
|
|
295
316
|
numColumns: 1,
|
package/section-list.mjs
CHANGED
|
@@ -110,6 +110,38 @@ var defaultSeparators = {
|
|
|
110
110
|
updateProps: () => {
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
|
+
function getSectionListItemInfo(item) {
|
|
114
|
+
switch (item.kind) {
|
|
115
|
+
case "item":
|
|
116
|
+
return {
|
|
117
|
+
index: item.itemIndex,
|
|
118
|
+
item: item.item,
|
|
119
|
+
section: item.section,
|
|
120
|
+
separators: defaultSeparators,
|
|
121
|
+
type: item.kind
|
|
122
|
+
};
|
|
123
|
+
case "item-separator":
|
|
124
|
+
return {
|
|
125
|
+
leadingItem: item.leadingItem,
|
|
126
|
+
leadingSection: item.section,
|
|
127
|
+
section: item.section,
|
|
128
|
+
trailingItem: item.trailingItem,
|
|
129
|
+
trailingSection: item.section,
|
|
130
|
+
type: item.kind
|
|
131
|
+
};
|
|
132
|
+
case "section-separator":
|
|
133
|
+
return {
|
|
134
|
+
leadingItem: void 0,
|
|
135
|
+
leadingSection: item.leadingSection,
|
|
136
|
+
section: item.leadingSection,
|
|
137
|
+
trailingItem: void 0,
|
|
138
|
+
trailingSection: item.trailingSection,
|
|
139
|
+
type: item.kind
|
|
140
|
+
};
|
|
141
|
+
default:
|
|
142
|
+
return { section: item.section, type: item.kind };
|
|
143
|
+
}
|
|
144
|
+
}
|
|
113
145
|
function resolveSeparatorComponent(component, props) {
|
|
114
146
|
if (!component) return null;
|
|
115
147
|
if (React.isValidElement(component)) {
|
|
@@ -131,6 +163,7 @@ var SectionList = typedMemo(
|
|
|
131
163
|
keyExtractor,
|
|
132
164
|
extraData,
|
|
133
165
|
onViewableItemsChanged,
|
|
166
|
+
getFixedItemSize,
|
|
134
167
|
horizontal,
|
|
135
168
|
...restProps
|
|
136
169
|
} = props;
|
|
@@ -158,6 +191,10 @@ var SectionList = typedMemo(
|
|
|
158
191
|
]
|
|
159
192
|
);
|
|
160
193
|
const { data, sectionMeta, stickyHeaderIndices } = flattened;
|
|
194
|
+
const handleGetFixedItemSize = React.useCallback(
|
|
195
|
+
(item) => getFixedItemSize == null ? void 0 : getFixedItemSize(getSectionListItemInfo(item)),
|
|
196
|
+
[getFixedItemSize]
|
|
197
|
+
);
|
|
161
198
|
const handleViewableItemsChanged = React.useMemo(() => {
|
|
162
199
|
if (!onViewableItemsChanged) return void 0;
|
|
163
200
|
return ({
|
|
@@ -193,39 +230,22 @@ var SectionList = typedMemo(
|
|
|
193
230
|
const renderItem = React.useCallback(
|
|
194
231
|
({ item }) => {
|
|
195
232
|
var _a, _b;
|
|
196
|
-
|
|
233
|
+
const info = getSectionListItemInfo(item);
|
|
234
|
+
switch (info.type) {
|
|
197
235
|
case "header":
|
|
198
|
-
return renderSectionHeader ? renderSectionHeader(
|
|
236
|
+
return renderSectionHeader ? renderSectionHeader(info) : null;
|
|
199
237
|
case "footer":
|
|
200
|
-
return renderSectionFooter ? renderSectionFooter(
|
|
238
|
+
return renderSectionFooter ? renderSectionFooter(info) : null;
|
|
201
239
|
case "item": {
|
|
202
|
-
const render = (_a =
|
|
203
|
-
|
|
204
|
-
return render({
|
|
205
|
-
index: item.itemIndex,
|
|
206
|
-
item: item.item,
|
|
207
|
-
section: item.section,
|
|
208
|
-
separators: defaultSeparators
|
|
209
|
-
});
|
|
240
|
+
const render = (_a = info.section.renderItem) != null ? _a : renderItemProp;
|
|
241
|
+
return render ? render(info) : null;
|
|
210
242
|
}
|
|
211
243
|
case "item-separator": {
|
|
212
|
-
const SeparatorComponent = (_b =
|
|
213
|
-
return resolveSeparatorComponent(SeparatorComponent,
|
|
214
|
-
leadingItem: item.leadingItem,
|
|
215
|
-
leadingSection: item.section,
|
|
216
|
-
section: item.section,
|
|
217
|
-
trailingItem: item.trailingItem,
|
|
218
|
-
trailingSection: item.section
|
|
219
|
-
});
|
|
244
|
+
const SeparatorComponent = (_b = info.section.ItemSeparatorComponent) != null ? _b : ItemSeparatorComponent;
|
|
245
|
+
return resolveSeparatorComponent(SeparatorComponent, info);
|
|
220
246
|
}
|
|
221
247
|
case "section-separator":
|
|
222
|
-
return resolveSeparatorComponent(SectionSeparatorComponent,
|
|
223
|
-
leadingItem: void 0,
|
|
224
|
-
leadingSection: item.leadingSection,
|
|
225
|
-
section: item.leadingSection,
|
|
226
|
-
trailingItem: void 0,
|
|
227
|
-
trailingSection: item.trailingSection
|
|
228
|
-
});
|
|
248
|
+
return resolveSeparatorComponent(SectionSeparatorComponent, info);
|
|
229
249
|
default:
|
|
230
250
|
return null;
|
|
231
251
|
}
|
|
@@ -268,6 +288,7 @@ var SectionList = typedMemo(
|
|
|
268
288
|
...restProps,
|
|
269
289
|
columnWrapperStyle: void 0,
|
|
270
290
|
data,
|
|
291
|
+
getFixedItemSize: getFixedItemSize ? handleGetFixedItemSize : void 0,
|
|
271
292
|
getItemType: (item) => item.kind,
|
|
272
293
|
keyExtractor: (item) => item.key,
|
|
273
294
|
numColumns: 1,
|