@homebound/beam 2.315.1 → 2.315.2

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.
Files changed (2) hide show
  1. package/dist/utils/rtl.js +10 -11
  2. package/package.json +1 -1
package/dist/utils/rtl.js CHANGED
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "type", { enumerable: true, get: function () { re
17
17
  Object.defineProperty(exports, "typeAndWait", { enumerable: true, get: function () { return rtl_utils_1.typeAndWait; } });
18
18
  Object.defineProperty(exports, "wait", { enumerable: true, get: function () { return rtl_utils_1.wait; } });
19
19
  const react_1 = require("@testing-library/react");
20
+ const mobx_utils_1 = require("mobx-utils");
20
21
  const components_1 = require("../components");
21
22
  function render(component, wrapperOrOpts, ...otherWrappers) {
22
23
  let wrappers;
@@ -49,7 +50,7 @@ function cellOf(r, tableTestId, rowNum, column) {
49
50
  exports.cellOf = cellOf;
50
51
  function cellAnd(r, row, column, testId) {
51
52
  return (cell(r, row, column).querySelector(`[data-testid="${testId}"]`) ||
52
- fail(`Element not found ${(0, react_1.prettyDOM)(cell(r, row, column))}`));
53
+ (0, mobx_utils_1.fail)(`Element not found ${(0, react_1.prettyDOM)(cell(r, row, column))}`));
53
54
  }
54
55
  exports.cellAnd = cellAnd;
55
56
  function row(r, row, tableTestId = "gridTable") {
@@ -59,7 +60,7 @@ function row(r, row, tableTestId = "gridTable") {
59
60
  exports.row = row;
60
61
  function rowAnd(r, rowNum, testId) {
61
62
  const e = row(r, rowNum);
62
- return e.querySelector(`[data-testid="${testId}"]`) || fail(`Element not found ${(0, react_1.prettyDOM)(e)}`);
63
+ return e.querySelector(`[data-testid="${testId}"]`) || (0, mobx_utils_1.fail)(`Element not found ${(0, react_1.prettyDOM)(e)}`);
63
64
  }
64
65
  exports.rowAnd = rowAnd;
65
66
  /** Intended to be used to generate a human-readable text
@@ -168,9 +169,7 @@ function ensureListBoxOpen(select) {
168
169
  }
169
170
  }
170
171
  function selectOption(select, optionValue) {
171
- const body = select.closest("body");
172
- const listboxId = select.getAttribute("aria-controls");
173
- const listbox = body.querySelector(`#${listboxId}`);
172
+ const listbox = findListBox(select);
174
173
  const options = listbox.querySelectorAll("[role=option]");
175
174
  // Allow searching for options by their data-key (value) or textContent (label)
176
175
  const optionToSelect = Array.from(options).find((o) => o.dataset.key === optionValue || o.dataset.label === optionValue);
@@ -190,9 +189,7 @@ function getSelected(element) {
190
189
  return (_a = select.textContent) !== null && _a !== void 0 ? _a : undefined;
191
190
  }
192
191
  ensureListBoxOpen(select);
193
- const body = select.closest("body");
194
- const listboxId = select.getAttribute("aria-controls");
195
- const listbox = body.querySelector(`#${listboxId}`);
192
+ const listbox = findListBox(select);
196
193
  const options = listbox.querySelectorAll("[role=option]");
197
194
  const selections = Array.from(options)
198
195
  .filter((o) => o.getAttribute("aria-selected") === "true")
@@ -206,15 +203,17 @@ function getOptions(element) {
206
203
  const select = resolveIfNeeded(element);
207
204
  assertListBoxInput(select);
208
205
  ensureListBoxOpen(select);
209
- const body = select.closest("body");
210
- const listboxId = select.getAttribute("aria-controls");
211
- const listbox = body.querySelector(`#${listboxId}`);
206
+ const listbox = findListBox(select);
212
207
  const options = listbox.querySelectorAll("[role=option]");
213
208
  return Array.from(options)
214
209
  .map((o) => { var _a, _b; return (_b = (_a = o.dataset.label) !== null && _a !== void 0 ? _a : o.dataset.key) !== null && _b !== void 0 ? _b : ""; })
215
210
  .filter((o) => !!o);
216
211
  }
217
212
  exports.getOptions = getOptions;
213
+ function findListBox(select) {
214
+ const listboxId = select.getAttribute("aria-controls") || (0, mobx_utils_1.fail)("aria-controls attribute not found");
215
+ return document.getElementById(listboxId) || (0, mobx_utils_1.fail)("listbox not found");
216
+ }
218
217
  function assertListBoxInput(select) {
219
218
  if (isSelectElement(select)) {
220
219
  throw new Error("Beam getOptions helper does not support <select> elements");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.315.1",
3
+ "version": "2.315.2",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",