@homebound/beam 2.109.0 → 2.110.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.
|
@@ -42,6 +42,7 @@ const useSortState_1 = require("./useSortState");
|
|
|
42
42
|
const visitor_1 = require("./visitor");
|
|
43
43
|
const Css_1 = require("../../Css");
|
|
44
44
|
const hooks_1 = require("../../hooks");
|
|
45
|
+
const useRenderCount_1 = require("../../hooks/useRenderCount");
|
|
45
46
|
const tinycolor2_1 = __importDefault(require("tinycolor2"));
|
|
46
47
|
const _1 = require(".");
|
|
47
48
|
exports.ASC = "ASC";
|
|
@@ -109,6 +110,11 @@ function GridTable(props) {
|
|
|
109
110
|
},
|
|
110
111
|
};
|
|
111
112
|
}
|
|
113
|
+
// We track render count at the table level, which seems odd (we should be able to track this
|
|
114
|
+
// internally within each GridRow using a useRef), but we have suspicions that react-virtuoso
|
|
115
|
+
// (or us) is resetting component state more than necessary, so we track render counts from
|
|
116
|
+
// here instead.
|
|
117
|
+
const { getCount } = (0, useRenderCount_1.useRenderCount)();
|
|
112
118
|
const [sortState, setSortKey] = (0, useSortState_1.useSortState)(columns, sorting);
|
|
113
119
|
const maybeSorted = (0, react_1.useMemo)(() => {
|
|
114
120
|
if ((sorting === null || sorting === void 0 ? void 0 : sorting.on) === "client" && sortState) {
|
|
@@ -140,6 +146,7 @@ function GridTable(props) {
|
|
|
140
146
|
openCards: nestedCards ? nestedCards.currentOpenCards() : undefined,
|
|
141
147
|
columnSizes,
|
|
142
148
|
level,
|
|
149
|
+
getCount,
|
|
143
150
|
...sortProps,
|
|
144
151
|
}), `${row.kind}-${row.id}`));
|
|
145
152
|
}
|
|
@@ -445,7 +452,7 @@ function getFirstOrLastCellCss(style, columnIndex, columns) {
|
|
|
445
452
|
}
|
|
446
453
|
// We extract GridRow to its own mini-component primarily so we can React.memo'ize it.
|
|
447
454
|
function GridRow(props) {
|
|
448
|
-
const { as, columns, row, style, rowStyles, stickyHeader, stickyOffset, sorting, sortState, setSortKey, openCards, columnSizes, level, ...others } = props;
|
|
455
|
+
const { as, columns, row, style, rowStyles, stickyHeader, stickyOffset, sorting, sortState, setSortKey, openCards, columnSizes, level, getCount, ...others } = props;
|
|
449
456
|
// We treat the "header" kind as special for "good defaults" styling
|
|
450
457
|
const isHeader = row.kind === "header";
|
|
451
458
|
const rowStyle = rowStyles === null || rowStyles === void 0 ? void 0 : rowStyles[row.kind];
|
|
@@ -471,7 +478,7 @@ function GridRow(props) {
|
|
|
471
478
|
...(0, nestedCards_1.getNestedCardStyles)(row, openCardStyles, style),
|
|
472
479
|
};
|
|
473
480
|
let currentColspan = 1;
|
|
474
|
-
const rowNode = ((0, jsx_runtime_1.jsx)(Row, Object.assign({ css: rowCss }, others, { "data-gridrow": true }, { children: columns.map((column, columnIndex) => {
|
|
481
|
+
const rowNode = ((0, jsx_runtime_1.jsx)(Row, Object.assign({ css: rowCss }, others, { "data-gridrow": true }, getCount(row.id), { children: columns.map((column, columnIndex) => {
|
|
475
482
|
var _a, _b;
|
|
476
483
|
if (column.mw) {
|
|
477
484
|
// Validate the column's minWidth definition if set.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A hook to add `data-render=${count}` to an element.
|
|
3
|
+
*
|
|
4
|
+
* This will output even in production mode, which in theory is not necessary
|
|
5
|
+
* and we could/should avoid, but it should also be np.
|
|
6
|
+
*
|
|
7
|
+
* The intent is to leave it "always on" for dev & tests, so that engineers
|
|
8
|
+
* and test suites can very easily grab "what was the render count of that?"
|
|
9
|
+
* w/o bringing in one-off modes/tools.
|
|
10
|
+
*
|
|
11
|
+
* (One-off modes/tools are more appropriate for truly adhoc performance
|
|
12
|
+
* but the intent is to use this in GridTable where "what's the render count?"
|
|
13
|
+
* will be a common question.)
|
|
14
|
+
*/
|
|
15
|
+
export declare function useRenderCount(): {
|
|
16
|
+
getCount: (id: string) => object;
|
|
17
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useRenderCount = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* A hook to add `data-render=${count}` to an element.
|
|
7
|
+
*
|
|
8
|
+
* This will output even in production mode, which in theory is not necessary
|
|
9
|
+
* and we could/should avoid, but it should also be np.
|
|
10
|
+
*
|
|
11
|
+
* The intent is to leave it "always on" for dev & tests, so that engineers
|
|
12
|
+
* and test suites can very easily grab "what was the render count of that?"
|
|
13
|
+
* w/o bringing in one-off modes/tools.
|
|
14
|
+
*
|
|
15
|
+
* (One-off modes/tools are more appropriate for truly adhoc performance
|
|
16
|
+
* but the intent is to use this in GridTable where "what's the render count?"
|
|
17
|
+
* will be a common question.)
|
|
18
|
+
*/
|
|
19
|
+
function useRenderCount() {
|
|
20
|
+
const ref = (0, react_1.useRef)(new Map());
|
|
21
|
+
const getCount = (0, react_1.useCallback)((id) => {
|
|
22
|
+
const count = ref.current.get(id) || 1;
|
|
23
|
+
ref.current.set(id, count + 1);
|
|
24
|
+
return { "data-render": count };
|
|
25
|
+
}, []);
|
|
26
|
+
return { getCount };
|
|
27
|
+
}
|
|
28
|
+
exports.useRenderCount = useRenderCount;
|