@homebound/beam 2.123.0 → 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/components/Tooltip.js +6 -1
- package/dist/inputs/ChipSelectField.js +1 -1
- package/dist/inputs/TextFieldBase.js +2 -0
- 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 +5 -5
|
@@ -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
|
|
@@ -35,7 +35,12 @@ function Tooltip(props) {
|
|
|
35
35
|
const { triggerProps, tooltipProps: _tooltipProps } = (0, react_aria_1.useTooltipTrigger)({ isDisabled: disabled }, state, triggerRef);
|
|
36
36
|
const { tooltipProps } = (0, react_aria_1.useTooltip)(_tooltipProps, state);
|
|
37
37
|
const tid = (0, utils_1.useTestIds)(props, "tooltip");
|
|
38
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ ref: triggerRef }, triggerProps, (!state.isOpen && typeof title === "string" ? { title } : {}), tid, {
|
|
38
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ ref: triggerRef }, triggerProps, (!state.isOpen && typeof title === "string" ? { title } : {}), tid, {
|
|
39
|
+
// Adding `draggable` as a hack to allow focus to continue through this element and into its children.
|
|
40
|
+
// This is due to some code in React-Aria that prevents default due ot mobile browser inconsistencies,
|
|
41
|
+
// and the only way they don't prevent default is if the element is draggable.
|
|
42
|
+
// See https://github.com/adobe/react-spectrum/discussions/3058 for discussion related to this issue.
|
|
43
|
+
draggable: true, onDragStart: (e) => e.preventDefault() }, { children: children }), void 0), state.isOpen && ((0, jsx_runtime_1.jsx)(Popper, Object.assign({}, (0, react_aria_1.mergeProps)(_tooltipProps, tooltipProps), { triggerRef: triggerRef, content: title, placement: placement }), void 0))] }, void 0));
|
|
39
44
|
}
|
|
40
45
|
exports.Tooltip = Tooltip;
|
|
41
46
|
function Popper({ triggerRef, content, placement = "auto" }) {
|
|
@@ -100,11 +100,11 @@ function ChipSelectField(props) {
|
|
|
100
100
|
items: listData.items,
|
|
101
101
|
children: selectChildren,
|
|
102
102
|
autoFocus: true,
|
|
103
|
+
disallowEmptySelection: false,
|
|
103
104
|
};
|
|
104
105
|
const state = (0, react_stately_1.useSelectState)({
|
|
105
106
|
...selectHookProps,
|
|
106
107
|
selectedKey: (0, Value_1.valueToKey)(value),
|
|
107
|
-
disallowEmptySelection: false,
|
|
108
108
|
onSelectionChange: (key) => {
|
|
109
109
|
if (key === createNewOpt.id) {
|
|
110
110
|
setShowInput(true);
|
|
@@ -50,6 +50,8 @@ function TextFieldBase(props) {
|
|
|
50
50
|
.if(compact)
|
|
51
51
|
.mhPx(compactFieldHeight - maybeSmaller).$,
|
|
52
52
|
...Css_1.Css.gray900.if(contrast).white.$,
|
|
53
|
+
// Make read-only fields vertically line up with editable fields in tables
|
|
54
|
+
...(borderless ? Css_1.Css.px1.$ : {}),
|
|
53
55
|
},
|
|
54
56
|
input: {
|
|
55
57
|
...Css_1.Css.w100.mw0.outline0.fg1.if(multiline).br4.$,
|
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",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@homebound/form-state": "2.13.0",
|
|
36
36
|
"@internationalized/number": "^3.0.3",
|
|
37
|
-
"@react-aria/utils": "^3.
|
|
37
|
+
"@react-aria/utils": "^3.11.3",
|
|
38
38
|
"@react-hook/resize-observer": "^1.2.2",
|
|
39
39
|
"change-case": "^4.1.2",
|
|
40
40
|
"date-fns": "^2.21.3",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"fast-deep-equal": "^3.1.3",
|
|
43
43
|
"framer-motion": "^4.1.11",
|
|
44
44
|
"memoize-one": "^5.2.1",
|
|
45
|
-
"react-aria": "^3.
|
|
45
|
+
"react-aria": "^3.14.1",
|
|
46
46
|
"react-day-picker": "^7.4.10",
|
|
47
47
|
"react-popper": "^2.2.5",
|
|
48
48
|
"react-router": "^5.2.0",
|
|
49
49
|
"react-router-dom": "^5.2.0",
|
|
50
|
-
"react-stately": "^3.
|
|
50
|
+
"react-stately": "^3.12.2",
|
|
51
51
|
"react-virtuoso": "^2.4.0",
|
|
52
52
|
"tributejs": "^5.1.3",
|
|
53
53
|
"trix": "^1.3.1",
|
|
@@ -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",
|