@homebound/beam 2.315.2 → 2.316.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.
|
@@ -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
|
};
|
|
@@ -41,8 +41,13 @@ function useComputed(fn, deps) {
|
|
|
41
41
|
// Only trigger a re-render if this is not the 1st autorun. Note
|
|
42
42
|
// that if deps has changed, we're inherently in a re-render so also
|
|
43
43
|
// don't need to trigger an additional re-render.
|
|
44
|
-
if (hasRan)
|
|
44
|
+
if (hasRan) {
|
|
45
|
+
// This can cause 'Cannot update a component while rendering a different component'
|
|
46
|
+
// if one component (the mutator) is updating observable from directly
|
|
47
|
+
// within it's render method. Usually this is rare and can be avoided by
|
|
48
|
+
// only updating observables from within useEffect.
|
|
45
49
|
setTick((tick) => tick + 1);
|
|
50
|
+
}
|
|
46
51
|
});
|
|
47
52
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
48
53
|
}, deps);
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* returns `homeownerContract`.
|
|
4
4
|
*
|
|
5
5
|
* This is useful for our (non-bound) form fields that will probably have a label,
|
|
6
|
-
* but may not have
|
|
6
|
+
* but may not have a `data-testid` set by the encompassing page.
|
|
7
|
+
*
|
|
8
|
+
* (Bound form fields typically set their test id from their form-state field's key.)
|
|
7
9
|
*/
|
|
8
10
|
export declare function defaultTestId(label: string): string;
|
|
@@ -7,9 +7,13 @@ const change_case_1 = require("change-case");
|
|
|
7
7
|
* returns `homeownerContract`.
|
|
8
8
|
*
|
|
9
9
|
* This is useful for our (non-bound) form fields that will probably have a label,
|
|
10
|
-
* but may not have
|
|
10
|
+
* but may not have a `data-testid` set by the encompassing page.
|
|
11
|
+
*
|
|
12
|
+
* (Bound form fields typically set their test id from their form-state field's key.)
|
|
11
13
|
*/
|
|
12
14
|
function defaultTestId(label) {
|
|
13
|
-
|
|
15
|
+
// Strip `m:4` to `m4` to prevent it from becoming `m_4` which our rtl-utils assumes
|
|
16
|
+
// means "the 4th element with a data-testid value of 'm'".
|
|
17
|
+
return (0, change_case_1.camelCase)(label.replace(":", ""));
|
|
14
18
|
}
|
|
15
19
|
exports.defaultTestId = defaultTestId;
|