@homebound/beam 2.315.2 → 2.316.0
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.
|
@@ -32,6 +32,7 @@ const memoize_one_1 = __importDefault(require("memoize-one"));
|
|
|
32
32
|
const mobx_1 = require("mobx");
|
|
33
33
|
const react_1 = __importStar(require("react"));
|
|
34
34
|
const react_virtuoso_1 = require("react-virtuoso");
|
|
35
|
+
const components_1 = require("..");
|
|
35
36
|
const PresentationContext_1 = require("../PresentationContext");
|
|
36
37
|
const GridTableApi_1 = require("./GridTableApi");
|
|
37
38
|
const useSetupColumnSizes_1 = require("./hooks/useSetupColumnSizes");
|
|
@@ -42,6 +43,7 @@ const utils_1 = require("./utils/utils");
|
|
|
42
43
|
const Css_1 = require("../../Css");
|
|
43
44
|
const hooks_1 = require("../../hooks");
|
|
44
45
|
const useRenderCount_1 = require("../../hooks/useRenderCount");
|
|
46
|
+
const utils_2 = require("../../utils");
|
|
45
47
|
const Row_1 = require("./components/Row");
|
|
46
48
|
let runningInJest = false;
|
|
47
49
|
/** Tells GridTable we're running in Jest, which forces as=virtual to be as=div, to work in jsdom. */
|
|
@@ -276,11 +278,15 @@ function renderVirtual(style, id, columns, visibleDataRows, keptSelectedRows, fi
|
|
|
276
278
|
const { paddingBottom, ...otherRootStyles } = (_a = style.rootCss) !== null && _a !== void 0 ? _a : {};
|
|
277
279
|
return { footerStyle: { paddingBottom }, listStyle: { ...style, rootCss: otherRootStyles } };
|
|
278
280
|
}, [style]);
|
|
281
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
282
|
+
const [fetchMoreInProgress, setFetchMoreInProgress] = (0, react_1.useState)(false);
|
|
279
283
|
return ((0, jsx_runtime_1.jsx)(react_virtuoso_1.Virtuoso, { overscan: 5, ref: virtuosoRef, components: {
|
|
280
284
|
// Applying a zIndex: 2 to ensure it stays on top of sticky columns
|
|
281
285
|
TopItemList: react_1.default.forwardRef((props, ref) => ((0, jsx_runtime_1.jsx)("div", { ...props, ref: ref, style: { ...props.style, ...{ zIndex: utils_1.zIndices.stickyHeader } } }))),
|
|
282
286
|
List: VirtualRoot(listStyle, columns, id, xss),
|
|
283
|
-
Footer: () =>
|
|
287
|
+
Footer: () => {
|
|
288
|
+
return ((0, jsx_runtime_1.jsx)("div", { css: footerStyle, children: fetchMoreInProgress && ((0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.h5.df.aic.jcc.$, children: (0, jsx_runtime_1.jsx)(components_1.Loader, { size: "xs" }) })) }));
|
|
289
|
+
},
|
|
284
290
|
},
|
|
285
291
|
// Pin/sticky both the header row(s) + firstRowMessage to the top
|
|
286
292
|
topItemCount: stickyHeader ? tableHeadRows.length : 0, itemContent: (index) => {
|
|
@@ -316,7 +322,15 @@ function renderVirtual(style, id, columns, visibleDataRows, keptSelectedRows, fi
|
|
|
316
322
|
// Add a `index > 0` check b/c Virtuoso is calling this in storybook
|
|
317
323
|
// with `endReached(0)` at odd times, like on page unload/story load,
|
|
318
324
|
// which then causes our test data to have duplicate ids in it.
|
|
319
|
-
endReached: (index) =>
|
|
325
|
+
endReached: (index) => {
|
|
326
|
+
if (index === 0)
|
|
327
|
+
return;
|
|
328
|
+
const result = infiniteScroll.onEndReached(index);
|
|
329
|
+
if ((0, utils_2.isPromise)(result)) {
|
|
330
|
+
setFetchMoreInProgress(true);
|
|
331
|
+
result.finally(() => setFetchMoreInProgress(false));
|
|
332
|
+
}
|
|
333
|
+
},
|
|
320
334
|
}
|
|
321
335
|
: {}) }));
|
|
322
336
|
}
|
|
@@ -104,8 +104,8 @@ export type Pin = {
|
|
|
104
104
|
};
|
|
105
105
|
export type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N;
|
|
106
106
|
export type InfiniteScroll = {
|
|
107
|
-
/** will be called when the user scrolls to the end of the list with the last item index as an argument. */
|
|
108
|
-
onEndReached: (index: number) => void
|
|
107
|
+
/** will be called when the user scrolls to the end of the list with the last item index as an argument. Return a promise to automatically show a loading spinner. */
|
|
108
|
+
onEndReached: (index: number) => void | Promise<void>;
|
|
109
109
|
/** The number of pixels from the bottom of the list to eagerly trigger `onEndReached`. The default is 500px. */
|
|
110
110
|
endOffsetPx?: number;
|
|
111
111
|
};
|