@homebound/beam 2.123.2 → 2.123.3
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/dist/components/Layout/ScrollableContent.d.ts +2 -2
- package/dist/components/Layout/ScrollableContent.js +3 -2
- package/dist/components/Table/GridTable.js +18 -2
- package/dist/utils/rtl.js +8 -4
- package/dist/utils/shallowEqual.d.ts +4 -0
- package/dist/utils/shallowEqual.js +28 -0
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode, ReactPortal } from "react";
|
|
2
|
-
/** Helper component for placing scrollable content within a `
|
|
3
|
-
export declare function ScrollableContent(
|
|
2
|
+
/** Helper component for placing scrollable content within a `ScrollableParent`. */
|
|
3
|
+
export declare function ScrollableContent(props: {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
virtualized?: boolean;
|
|
6
6
|
}): ReactPortal | JSX.Element;
|
|
@@ -7,8 +7,9 @@ const react_dom_1 = require("react-dom");
|
|
|
7
7
|
const FullBleed_1 = require("./FullBleed");
|
|
8
8
|
const ScrollableParent_1 = require("./ScrollableParent");
|
|
9
9
|
const Css_1 = require("../../Css");
|
|
10
|
-
/** Helper component for placing scrollable content within a `
|
|
11
|
-
function ScrollableContent(
|
|
10
|
+
/** Helper component for placing scrollable content within a `ScrollableParent`. */
|
|
11
|
+
function ScrollableContent(props) {
|
|
12
|
+
const { children, virtualized = false } = props;
|
|
12
13
|
const { scrollableEl, setPortalTick, pl } = (0, ScrollableParent_1.useScrollableParent)();
|
|
13
14
|
(0, react_1.useEffect)(() => {
|
|
14
15
|
// The below `tick` logic is a way to detect whether the ScrollableContent is being used.
|
|
@@ -43,6 +43,7 @@ const useSortState_1 = require("./useSortState");
|
|
|
43
43
|
const Css_1 = require("../../Css");
|
|
44
44
|
const hooks_1 = require("../../hooks");
|
|
45
45
|
const useRenderCount_1 = require("../../hooks/useRenderCount");
|
|
46
|
+
const shallowEqual_1 = require("../../utils/shallowEqual");
|
|
46
47
|
const _1 = require(".");
|
|
47
48
|
exports.ASC = "ASC";
|
|
48
49
|
exports.DESC = "DESC";
|
|
@@ -592,8 +593,23 @@ function GridRow(props) {
|
|
|
592
593
|
}) }), void 0));
|
|
593
594
|
return openCardStyles && openCardStyles.length > 0 ? (0, nestedCards_1.wrapCard)(openCardStyles, rowNode) : rowNode;
|
|
594
595
|
}
|
|
595
|
-
|
|
596
|
-
|
|
596
|
+
/**
|
|
597
|
+
* Memoizes GridRows so that re-rendering the table doesn't re-render every single row.
|
|
598
|
+
*
|
|
599
|
+
* We use a custom `propsAreEqual` for the `GridRowProps.row` property, which we memoize
|
|
600
|
+
* based on the `GridDataRow.data` prop, such that if a table re-renders (i.e. for a cache
|
|
601
|
+
* updated) and technically creates new row instances, but a row's `row.data` points to the
|
|
602
|
+
* same/unchanged Apollo cache fragment, then we won't re-render that row.
|
|
603
|
+
*
|
|
604
|
+
* Note that if you're using virtualization, it can be surprising how unnoticeable broken row
|
|
605
|
+
* memoization is.
|
|
606
|
+
*/
|
|
607
|
+
// Declared as a const + `as typeof GridRow` to work with generics, see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/37087#issuecomment-656596623
|
|
608
|
+
const MemoizedGridRow = react_1.default.memo(GridRow, (one, two) => {
|
|
609
|
+
const { row: row1, ...others1 } = one;
|
|
610
|
+
const { row: row2, ...others2 } = two;
|
|
611
|
+
return (0, shallowEqual_1.shallowEqual)(row1, row2) && (0, shallowEqual_1.shallowEqual)(others1, others2);
|
|
612
|
+
});
|
|
597
613
|
/** Wraps a mobx Observer around the row's rendering/evaluation, so that it will be reactive. */
|
|
598
614
|
const ObservedGridRow = react_1.default.memo((props) => ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => {
|
|
599
615
|
// Invoke this just as a regular function so that Observer sees the proxy access's
|
package/dist/utils/rtl.js
CHANGED
|
@@ -17,20 +17,24 @@ Object.defineProperty(exports, "wait", { enumerable: true, get: function () { re
|
|
|
17
17
|
const react_1 = require("@testing-library/react");
|
|
18
18
|
const components_1 = require("../components");
|
|
19
19
|
function render(component, wrapperOrOpts, ...otherWrappers) {
|
|
20
|
+
let wrappers;
|
|
20
21
|
if (wrapperOrOpts && "wrap" in wrapperOrOpts) {
|
|
21
22
|
// They passed at least single wrapper + maybe more.
|
|
22
23
|
// We put `withBeamRTL` first so that any `withApollo`s wrap outside of beam, so in-drawer/in-modal content has apollo
|
|
23
|
-
|
|
24
|
+
wrappers = [exports.withBeamRTL, wrapperOrOpts, ...otherWrappers];
|
|
24
25
|
}
|
|
25
26
|
else if (wrapperOrOpts) {
|
|
26
27
|
const { omitBeamContext, at } = wrapperOrOpts;
|
|
27
|
-
|
|
28
|
+
wrappers = [
|
|
28
29
|
...otherWrappers,
|
|
29
30
|
...(!omitBeamContext ? [exports.withBeamRTL] : []),
|
|
30
31
|
...(at ? [(0, rtl_react_router_utils_1.withRouter)(at.url, at.route)] : [(0, rtl_react_router_utils_1.withRouter)()]),
|
|
31
|
-
]
|
|
32
|
+
];
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
+
else {
|
|
35
|
+
wrappers = [exports.withBeamRTL];
|
|
36
|
+
}
|
|
37
|
+
return (0, rtl_utils_1.render)(component, { wrappers, wait: true });
|
|
34
38
|
}
|
|
35
39
|
exports.render = render;
|
|
36
40
|
function cell(r, row, column) {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shallowEqual = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* An inlined version of shallowEach, see https://github.com/facebook/react/issues/16919
|
|
6
|
+
*/
|
|
7
|
+
function shallowEqual(objA, objB) {
|
|
8
|
+
if (Object.is(objA, objB)) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const keysA = Object.keys(objA);
|
|
15
|
+
const keysB = Object.keys(objB);
|
|
16
|
+
if (keysA.length !== keysB.length) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
// Test for A's keys different from B.
|
|
20
|
+
for (let i = 0; i < keysA.length; i++) {
|
|
21
|
+
const currentKey = keysA[i];
|
|
22
|
+
if (!objB.hasOwnProperty(currentKey) || !Object.is(objA[currentKey], objB[currentKey])) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
exports.shallowEqual = shallowEqual;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@homebound/beam",
|
|
3
|
-
"version": "2.123.
|
|
3
|
+
"version": "2.123.3",
|
|
4
4
|
"author": "Homebound",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@emotion/jest": "^11.3.0",
|
|
78
78
|
"@emotion/react": "^11.1.5",
|
|
79
79
|
"@homebound/rtl-react-router-utils": "^1.0.3",
|
|
80
|
-
"@homebound/rtl-utils": "^2.
|
|
80
|
+
"@homebound/rtl-utils": "^2.59.3",
|
|
81
81
|
"@homebound/truss": "^1.111.3",
|
|
82
82
|
"@homebound/tsconfig": "^1.0.3",
|
|
83
83
|
"@semantic-release/exec": "^6.0.3",
|