@homebound/beam 2.123.2 → 2.124.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.
@@ -1,6 +1,6 @@
1
1
  import { ReactNode, ReactPortal } from "react";
2
- /** Helper component for placing scrollable content within a `NestedScrollProvider`. */
3
- export declare function ScrollableContent({ children, virtualized, }: {
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 `NestedScrollProvider`. */
11
- function ScrollableContent({ children, virtualized = false, }) {
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
- // Fix to work with generics, see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/37087#issuecomment-656596623
596
- const MemoizedGridRow = react_1.default.memo(GridRow);
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
@@ -65,7 +65,7 @@ exports.beamTotalsFixedStyle = {
65
65
  };
66
66
  exports.beamFlexibleStyle = {
67
67
  ...exports.beamFixedStyle,
68
- cellCss: Css_1.Css.xs.bgWhite.aic.p2.boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray100}`).$,
68
+ cellCss: Css_1.Css.xs.bgWhite.aic.py2.pxPx(12).boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray100}`).$,
69
69
  presentationSettings: { borderless: true, typeScale: "xs", wrap: true },
70
70
  };
71
71
  exports.beamNestedFlexibleStyle = {
@@ -4,5 +4,6 @@ export interface DatePickerProps {
4
4
  value?: Date;
5
5
  onSelect: (value: Date) => void;
6
6
  disabledDays?: Modifier | Modifier[];
7
+ dottedDays?: Modifier[];
7
8
  }
8
9
  export declare function DatePicker(props: DatePickerProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -11,7 +11,7 @@ const Css_1 = require("../../Css");
11
11
  const utils_1 = require("../../utils");
12
12
  require("./DatePicker.css");
13
13
  function DatePicker(props) {
14
- const { value, onSelect, disabledDays } = props;
14
+ const { value, onSelect, disabledDays, dottedDays } = props;
15
15
  const tid = (0, utils_1.useTestIds)(props, "datePicker");
16
16
  return ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: {
17
17
  ...Css_1.Css.dib.bgWhite.xs.$,
@@ -20,7 +20,7 @@ function DatePicker(props) {
20
20
  // Un-collapse the borders so we can hover each cell
21
21
  "& .DayPicker-Month": Css_1.Css.add({ borderCollapse: "separate" }).$,
22
22
  // // Make the boxes smaller, this ends up being 32x32 which matches figma
23
- "& .DayPicker-Day": Css_1.Css.pPx(8).xs.ba.bWhite.br4.$,
23
+ "& .DayPicker-Day": Css_1.Css.px1.ptPx(6).pbPx(10).xs.ba.bWhite.br4.relative.$,
24
24
  // For today, use a background
25
25
  "& .DayPicker-Day--today": Css_1.Css.bgGray100.$,
26
26
  // For selected, use a background - `--outside` modifier is set on placeholder days not within the viewed month
@@ -33,12 +33,16 @@ function DatePicker(props) {
33
33
  "& .DayPicker-Day--disabled": Css_1.Css.cursorNotAllowed.$,
34
34
  // Override `.DayPicker-Day:active` background when the day is disabled
35
35
  "& .DayPicker-Day--disabled:active": Css_1.Css.bgWhite.$,
36
+ // Display dottedDays using positioned pseudo elements.
37
+ "& .DayPicker-Day--indicatorDot": Css_1.Css.addIn("&:after", Css_1.Css.wPx(4).hPx(4).br4.absolute.bottomPx(5).left("calc(50% - 2px)").bgLightBlue700.add("content", "''").$).$,
38
+ // Update dottedDays color if day is "selected"
39
+ "& .DayPicker-Day--selected.DayPicker-Day--indicatorDot": Css_1.Css.addIn("&:after", Css_1.Css.bgWhite.$).$,
36
40
  } }, tid, { children: (0, jsx_runtime_1.jsx)(react_day_picker_1.default, { navbarElement: NavbarElement, weekdayElement: Weekday, selectedDays: [value], initialMonth: value !== null && value !== void 0 ? value : new Date(), onDayClick: (day, modifiers) => {
37
41
  if (modifiers.disabled)
38
42
  return;
39
43
  // Set the day value
40
44
  onSelect(day);
41
- }, disabledDays: disabledDays }, void 0) }), void 0));
45
+ }, disabledDays: disabledDays, modifiers: { indicatorDot: dottedDays } }, void 0) }), void 0));
42
46
  }
43
47
  exports.DatePicker = DatePicker;
44
48
  /** Customize the prev/next button to be our SVG icons. */
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
- return (0, rtl_utils_1.render)(component, ...[exports.withBeamRTL, wrapperOrOpts, ...otherWrappers]);
24
+ wrappers = [exports.withBeamRTL, wrapperOrOpts, ...otherWrappers];
24
25
  }
25
26
  else if (wrapperOrOpts) {
26
27
  const { omitBeamContext, at } = wrapperOrOpts;
27
- return (0, rtl_utils_1.render)(component, ...[
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
- return (0, rtl_utils_1.render)(component, exports.withBeamRTL);
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,4 @@
1
+ /**
2
+ * An inlined version of shallowEach, see https://github.com/facebook/react/issues/16919
3
+ */
4
+ export declare function shallowEqual(objA: any, objB: any): boolean;
@@ -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.2",
3
+ "version": "2.124.0",
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.51.0",
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",