@homebound/beam 2.316.0 → 2.317.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.
@@ -41,7 +41,7 @@ function RightPaneProvider({ children }) {
41
41
  setRightPaneContent(opts === null || opts === void 0 ? void 0 : opts.content);
42
42
  setIsRightPaneOpen(true);
43
43
  }, [setRightPaneContent]);
44
- const closePane = (0, react_1.useCallback)(() => setIsRightPaneOpen(false), [setRightPaneContent]);
44
+ const closePane = (0, react_1.useCallback)(() => setIsRightPaneOpen(false), []);
45
45
  const clearPane = (0, react_1.useCallback)(() => setRightPaneContent(undefined), [setRightPaneContent]);
46
46
  const context = (0, react_1.useMemo)(() => ({ openInPane, closePane, clearPane, rightPaneContent, isRightPaneOpen }), [openInPane, closePane, rightPaneContent, clearPane, isRightPaneOpen]);
47
47
  return (0, jsx_runtime_1.jsx)(exports.RightPaneContext.Provider, { value: context, children: children });
@@ -1,6 +1,6 @@
1
1
  import { ReactElement } from "react";
2
2
  import { Palette } from "../../../Css";
3
- export declare function RightPaneLayout({ children, paneBgColor, paneWidth, defaultPaneContent, }: {
3
+ export declare function RightPaneLayout(props: {
4
4
  children: ReactElement;
5
5
  paneBgColor?: Palette;
6
6
  paneWidth?: number;
@@ -6,23 +6,19 @@ const framer_motion_1 = require("framer-motion");
6
6
  const react_1 = require("react");
7
7
  const Css_1 = require("../../../Css");
8
8
  const RightPaneContext_1 = require("./RightPaneContext");
9
- function RightPaneLayout({ children, paneBgColor = Css_1.Palette.White, paneWidth = 450, defaultPaneContent, }) {
9
+ function RightPaneLayout(props) {
10
+ const { children, paneBgColor = Css_1.Palette.White, paneWidth = 450, defaultPaneContent } = props;
10
11
  const { isRightPaneOpen, rightPaneContent, clearPane, closePane } = (0, RightPaneContext_1.useRightPaneContext)();
11
12
  // Close pane on page unmount because otherwise the next page that has a right pane will show our stale content
12
- (0, react_1.useEffect)(() => {
13
- return () => {
14
- closePane();
15
- };
16
- }, []);
13
+ (0, react_1.useEffect)(() => closePane, [closePane]);
17
14
  return ((0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.h100.df.overflowXHidden.$, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { css: {
18
15
  ...Css_1.Css.w(`calc(100% - ${paneWidth + 24}px)`).add("transition", "width .2s linear").h100.mr3.overflowXAuto.$,
19
16
  ...Css_1.Css.if(!isRightPaneOpen).w100.mr0.$,
20
17
  ...Css_1.Css.if(!!defaultPaneContent).w(`calc(100% - ${paneWidth + 24}px)`).mr3.$,
21
- }, children: children }), (0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.position("relative").if(!!defaultPaneContent).wPx(paneWidth).$, children: [defaultPaneContent && ((0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.h100
18
+ }, children: children }), (0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.relative.if(!!defaultPaneContent).wPx(paneWidth).$, children: [defaultPaneContent && ((0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.h100
22
19
  .wPx(paneWidth)
23
20
  .left(0)
24
- .position("absolute")
25
- .add("transition", "all .3s ease-in-out")
21
+ .absolute.add("transition", "all .3s ease-in-out")
26
22
  .if(isRightPaneOpen)
27
23
  .add("opacity", 0)
28
24
  .left(100).$, children: defaultPaneContent })), (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { children: isRightPaneOpen && ((0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { layout: "position", "data-testid": "rightPaneContent", css: Css_1.Css.bgColor(paneBgColor).h100.wPx(paneWidth).$,
@@ -150,10 +150,10 @@ class RowState {
150
150
  if (this.row.selectable !== false) {
151
151
  this.selected = selected;
152
152
  }
153
- // We don't check inferSelectedState here, b/c even if the parent is considered selectable
154
- // on its own, we still push down selected-ness to our visible children.
155
- for (const child of this.visibleChildren) {
156
- child.select(selected);
153
+ if (this.inferSelectedState) {
154
+ for (const child of this.visibleChildren) {
155
+ child.select(selected);
156
+ }
157
157
  }
158
158
  }
159
159
  /** Marks the row as removed from `props.rows`, to potentially become kept. */
@@ -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 an data-testid set by the encompassing page.
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 an data-testid set by the encompassing page.
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
- return (0, change_case_1.camelCase)(label);
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;
@@ -1,7 +1,7 @@
1
1
  import { newLocation as _newLocation, withRouter as _withRouter } from "@homebound/rtl-react-router-utils";
2
- import { blur as _blur, change as _change, click as _click, focus as _focus, getOptions as _getOptions, input as _input, RenderResult, select as _select, type as _type, typeAndWait as _typeAndWait, wait as _wait, Wrapper } from "@homebound/rtl-utils";
2
+ import { blur as _blur, change as _change, click as _click, clickAndWait as _clickAndWait, focus as _focus, getOptions as _getOptions, input as _input, RenderResult, select as _select, type as _type, typeAndWait as _typeAndWait, wait as _wait, Wrapper } from "@homebound/rtl-utils";
3
3
  import { ReactElement } from "react";
4
- export { _blur as blur, _change as change, _click as click, _focus as focus, _getOptions as rtlUtilGetOptions, _input as input, _select as rtlUtilSelect, _type as type, _typeAndWait as typeAndWait, _wait as wait, };
4
+ export { _blur as blur, _change as change, _click as click, _clickAndWait as clickAndWait, _focus as focus, _getOptions as rtlUtilGetOptions, _input as input, _select as rtlUtilSelect, _type as type, _typeAndWait as typeAndWait, _wait as wait, };
5
5
  export { _newLocation as newLocation, _withRouter as withRouter };
6
6
  interface RenderOpts {
7
7
  at?: {
@@ -10,8 +10,8 @@ interface RenderOpts {
10
10
  };
11
11
  omitBeamContext?: boolean;
12
12
  }
13
- export declare function render(component: ReactElement, withoutBeamProvider: RenderOpts, ...otherWrappers: Wrapper[]): Promise<RenderResult & Record<string, HTMLElement & Function>>;
14
- export declare function render(component: ReactElement, ...otherWrappers: Wrapper[]): Promise<RenderResult & Record<string, HTMLElement & Function>>;
13
+ export declare function render(component: ReactElement, withoutBeamProvider: RenderOpts, ...otherWrappers: Wrapper[]): Promise<RenderResult & Record<string, HTMLElement>>;
14
+ export declare function render(component: ReactElement, ...otherWrappers: Wrapper[]): Promise<RenderResult & Record<string, HTMLElement>>;
15
15
  export declare function cell(r: RenderResult, row: number, column: number): HTMLElement;
16
16
  export declare function cellOf(r: RenderResult, tableTestId: string, rowNum: number, column: number): HTMLElement;
17
17
  export declare function cellAnd(r: RenderResult, row: number, column: number, testId: string): HTMLElement;
@@ -39,7 +39,7 @@ export declare const withBeamRTL: Wrapper;
39
39
  *
40
40
  * @param value The value or label of the option.
41
41
  * */
42
- export declare function select(element: HTMLElement, value: string | string[]): void;
43
- export declare function selectAndWait(input: HTMLElement, value: string | string[]): Promise<void>;
44
- export declare function getSelected(element: HTMLElement): string[] | string | undefined;
45
- export declare function getOptions(element: HTMLElement): string[];
42
+ export declare function select(select: HTMLElement, value: string | string[]): void;
43
+ export declare function selectAndWait(select: HTMLElement, value: string | string[]): Promise<void>;
44
+ export declare function getSelected(select: HTMLElement): string[] | string | undefined;
45
+ export declare function getOptions(select: HTMLElement): string[];
package/dist/utils/rtl.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOptions = exports.getSelected = exports.selectAndWait = exports.select = exports.withBeamRTL = exports.tableSnapshot = exports.rowAnd = exports.row = exports.cellAnd = exports.cellOf = exports.cell = exports.render = exports.withRouter = exports.newLocation = exports.wait = exports.typeAndWait = exports.type = exports.rtlUtilSelect = exports.input = exports.rtlUtilGetOptions = exports.focus = exports.click = exports.change = exports.blur = void 0;
3
+ exports.getOptions = exports.getSelected = exports.selectAndWait = exports.select = exports.withBeamRTL = exports.tableSnapshot = exports.rowAnd = exports.row = exports.cellAnd = exports.cellOf = exports.cell = exports.render = exports.withRouter = exports.newLocation = exports.wait = exports.typeAndWait = exports.type = exports.rtlUtilSelect = exports.input = exports.rtlUtilGetOptions = exports.focus = exports.clickAndWait = exports.click = exports.change = exports.blur = void 0;
4
4
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
5
  const rtl_react_router_utils_1 = require("@homebound/rtl-react-router-utils");
6
6
  Object.defineProperty(exports, "newLocation", { enumerable: true, get: function () { return rtl_react_router_utils_1.newLocation; } });
@@ -9,6 +9,7 @@ const rtl_utils_1 = require("@homebound/rtl-utils");
9
9
  Object.defineProperty(exports, "blur", { enumerable: true, get: function () { return rtl_utils_1.blur; } });
10
10
  Object.defineProperty(exports, "change", { enumerable: true, get: function () { return rtl_utils_1.change; } });
11
11
  Object.defineProperty(exports, "click", { enumerable: true, get: function () { return rtl_utils_1.click; } });
12
+ Object.defineProperty(exports, "clickAndWait", { enumerable: true, get: function () { return rtl_utils_1.clickAndWait; } });
12
13
  Object.defineProperty(exports, "focus", { enumerable: true, get: function () { return rtl_utils_1.focus; } });
13
14
  Object.defineProperty(exports, "rtlUtilGetOptions", { enumerable: true, get: function () { return rtl_utils_1.getOptions; } });
14
15
  Object.defineProperty(exports, "input", { enumerable: true, get: function () { return rtl_utils_1.input; } });
@@ -143,16 +144,14 @@ exports.withBeamRTL = {
143
144
  *
144
145
  * @param value The value or label of the option.
145
146
  * */
146
- function select(element, value) {
147
- const select = resolveIfNeeded(element);
147
+ function select(select, value) {
148
148
  assertListBoxInput(select);
149
149
  ensureListBoxOpen(select);
150
150
  const optionValues = Array.isArray(value) ? value : [value];
151
151
  optionValues.forEach((optionValue) => selectOption(select, optionValue));
152
152
  }
153
153
  exports.select = select;
154
- async function selectAndWait(input, value) {
155
- const select = resolveIfNeeded(input);
154
+ async function selectAndWait(select, value) {
156
155
  // To work with React 18, we need to execute these as separate steps, otherwise
157
156
  // the `ensureListBoxOpen` async render won't flush, and the `selectOption` will fail.
158
157
  await (0, rtl_utils_1.allowAndWaitForAsyncBehavior)(() => ensureListBoxOpen(select));
@@ -178,9 +177,8 @@ function selectOption(select, optionValue) {
178
177
  }
179
178
  (0, rtl_utils_1.click)(optionToSelect);
180
179
  }
181
- function getSelected(element) {
180
+ function getSelected(select) {
182
181
  var _a;
183
- const select = resolveIfNeeded(element);
184
182
  if (isSelectElement(select)) {
185
183
  throw new Error("Beam getSelected helper does not support <select> elements");
186
184
  }
@@ -199,8 +197,7 @@ function getSelected(element) {
199
197
  return selections.length > 0 ? (selections.length > 1 ? selections : selections[0]) : undefined;
200
198
  }
201
199
  exports.getSelected = getSelected;
202
- function getOptions(element) {
203
- const select = resolveIfNeeded(element);
200
+ function getOptions(select) {
204
201
  assertListBoxInput(select);
205
202
  ensureListBoxOpen(select);
206
203
  const listbox = findListBox(select);
@@ -223,10 +220,6 @@ function assertListBoxInput(select) {
223
220
  }
224
221
  return true;
225
222
  }
226
- function resolveIfNeeded(element) {
227
- const maybeProxy = element;
228
- return maybeProxy instanceof Function ? maybeProxy() : element;
229
- }
230
223
  function isSelectElement(element) {
231
224
  return element.nodeName === "SELECT";
232
225
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.316.0",
3
+ "version": "2.317.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -77,7 +77,7 @@
77
77
  "@emotion/react": "^11.10.6",
78
78
  "@homebound/eslint-config": "1.6.1",
79
79
  "@homebound/rtl-react-router-utils": "1.0.3",
80
- "@homebound/rtl-utils": "^2.63.1",
80
+ "@homebound/rtl-utils": "^2.65.0",
81
81
  "@homebound/truss": "^1.131.0",
82
82
  "@homebound/tsconfig": "^1.0.3",
83
83
  "@semantic-release/exec": "^6.0.3",
@@ -93,7 +93,8 @@
93
93
  "@storybook/react": "^7.3.0",
94
94
  "@storybook/react-vite": "^7.3.0",
95
95
  "@storybook/testing-library": "^0.2.0",
96
- "@testing-library/jest-dom": "^5.16.5",
96
+ "@testing-library/jest-dom": "^6.1.2",
97
+ "@testing-library/react": "^14.0.0",
97
98
  "@tsconfig/recommended": "^1.0.2",
98
99
  "@types/dompurify": "^2.2.3",
99
100
  "@types/jest": "^29.4.0",