@swan-io/lake 8.18.5 → 8.18.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-io/lake",
3
- "version": "8.18.5",
3
+ "version": "8.18.7",
4
4
  "engines": {
5
5
  "node": ">=20.9.0",
6
6
  "yarn": "^1.22.0"
@@ -38,14 +38,14 @@ export type VirtualizedListProps<T, ExtraInfo> = {
38
38
  onEndReached?: () => void;
39
39
  onEndReachedThreshold?: number;
40
40
  getRowLink?: (config: LinkConfig<T, ExtraInfo>) => ReactElement | undefined;
41
- renderEmptyList?: () => ReactNode;
41
+ renderEmptyList: () => ReactNode;
42
42
  marginHorizontal?: string;
43
43
  loading?: {
44
44
  isLoading: boolean;
45
45
  count: number;
46
46
  };
47
47
  };
48
- export declare const VirtualizedList: <T, ExtraInfo>({ variant, data, stickedToStartColumns, columns, stickedToEndColumns, headerHeight, rowHeight, renderThreshold, onEndReached, onEndReachedThreshold, loading, extraInfo, keyExtractor, marginHorizontal, }: VirtualizedListProps<T, ExtraInfo>) => import("react/jsx-runtime").JSX.Element;
48
+ export declare const VirtualizedList: <T, ExtraInfo>({ variant, data, stickedToStartColumns, columns, stickedToEndColumns, headerHeight, rowHeight, renderThreshold, onEndReached, onEndReachedThreshold, loading, extraInfo, keyExtractor, marginHorizontal, renderEmptyList, getRowLink, }: VirtualizedListProps<T, ExtraInfo>) => import("react/jsx-runtime").JSX.Element;
49
49
  type VirtualizedListPlaceholderProps = {
50
50
  count: number;
51
51
  rowHeight: number;
@@ -14,6 +14,13 @@ const styles = StyleSheet.create({
14
14
  height: 1,
15
15
  alignSelf: "stretch",
16
16
  },
17
+ emptyListContentContainer: {
18
+ flexDirection: "column",
19
+ alignItems: "center",
20
+ justifyContent: "center",
21
+ padding: spacings[48],
22
+ minHeight: "100%",
23
+ },
17
24
  headerRow: {
18
25
  position: "sticky",
19
26
  top: 0,
@@ -152,7 +159,7 @@ const styles = StyleSheet.create({
152
159
  width: "10%",
153
160
  },
154
161
  });
155
- export const VirtualizedList = ({ variant, data, stickedToStartColumns, columns, stickedToEndColumns, headerHeight, rowHeight, renderThreshold = 1000, onEndReached, onEndReachedThreshold = 200, loading, extraInfo, keyExtractor, marginHorizontal, }) => {
162
+ export const VirtualizedList = ({ variant, data, stickedToStartColumns, columns, stickedToEndColumns, headerHeight, rowHeight, renderThreshold = 1000, onEndReached, onEndReachedThreshold = 200, loading, extraInfo, keyExtractor, marginHorizontal, renderEmptyList, getRowLink, }) => {
156
163
  // Used for unique IDs generation (usefull for header IDs and cells aria-describedBy pointing to them)
157
164
  const viewId = useId();
158
165
  const scrollViewRef = useRef(null);
@@ -354,11 +361,17 @@ export const VirtualizedList = ({ variant, data, stickedToStartColumns, columns,
354
361
  },
355
362
  ] }));
356
363
  }, [stickedToEndColumnsWidth, horizontalScrollPosition]);
364
+ if (data.length === 0 &&
365
+ !Option.fromNullable(loading)
366
+ .map(({ isLoading }) => isLoading)
367
+ .getOr(false)) {
368
+ return (_jsx(ScrollView, { style: styles.container, contentContainerStyle: styles.emptyListContentContainer, children: renderEmptyList() }));
369
+ }
357
370
  return (_jsxs(ScrollView, { ref: scrollViewRef, both: true, style: [styles.container, { marginHorizontal }], onScroll: onScroll, scrollEventThrottle: 32, contentContainerStyle: {
358
371
  height: containerContainerHeight,
359
372
  width: contentContainerWidth,
360
373
  }, children: [header, rowsToRender
361
- .map(({ startIndex, endIndex, data }) => (_jsxs(View, { style: styles.rowsContainer, ref: rowsContainerRef, children: [data.map((item, index) => (_jsx(VirtualizedRow, { viewId: viewId, item: item, rowHeight: rowHeight, absoluteIndex: startIndex + index, variant: variant, stickedToStartColumnsWidth: stickedToStartColumnsWidth, centerColumnsWidth: centerColumnsWidth, stickedToEndColumnsWidth: stickedToEndColumnsWidth, stickedToStartColumns: stickedToStartColumns, columns: columns, stickedToEndColumns: stickedToEndColumns, extraInfo: extraInfo, horizontalScrollPosition: horizontalScrollPosition !== null && horizontalScrollPosition !== void 0 ? horizontalScrollPosition : "NoScroll", stickedToStartFirstCellLeftPadding: stickedToStartFirstCellLeftPadding, centerFirstCellLeftPadding: centerFirstCellLeftPadding, centerLastCellLeftPadding: centerLastCellLeftPadding, stickedToEndLastCellRightPadding: stickedToEndLastCellRightPadding }, keyExtractor(item, startIndex + index)))), Option.fromNullable(loading)
374
+ .map(({ startIndex, endIndex, data }) => (_jsxs(View, { style: styles.rowsContainer, ref: rowsContainerRef, children: [data.map((item, index) => (_jsx(VirtualizedRow, { viewId: viewId, item: item, rowHeight: rowHeight, absoluteIndex: startIndex + index, variant: variant, stickedToStartColumnsWidth: stickedToStartColumnsWidth, centerColumnsWidth: centerColumnsWidth, stickedToEndColumnsWidth: stickedToEndColumnsWidth, stickedToStartColumns: stickedToStartColumns, columns: columns, stickedToEndColumns: stickedToEndColumns, extraInfo: extraInfo, getRowLink: getRowLink, horizontalScrollPosition: horizontalScrollPosition !== null && horizontalScrollPosition !== void 0 ? horizontalScrollPosition : "NoScroll", stickedToStartFirstCellLeftPadding: stickedToStartFirstCellLeftPadding, centerFirstCellLeftPadding: centerFirstCellLeftPadding, centerLastCellLeftPadding: centerLastCellLeftPadding, stickedToEndLastCellRightPadding: stickedToEndLastCellRightPadding }, keyExtractor(item, startIndex + index)))), Option.fromNullable(loading)
362
375
  .flatMap(({ isLoading, count }) => (isLoading ? Option.Some(count) : Option.None()))
363
376
  .map(count => (_jsx(View, { "aria-busy": true, style: [
364
377
  styles.loadingPlaceholder,