@threadlabs/looma 0.23.2 → 0.23.4

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.
@@ -6,7 +6,8 @@
6
6
  <prop name="label" type="string" default="Tree">The tree's accessible name, announced when focus enters it. Name what the tree holds.</prop>
7
7
  <prop name="selection" type="keyword" values="none, single, multiple" default="none"
8
8
  >How selection works. None keeps rows for navigation and expansion; single requests one selected item; multiple shows checkboxes and requests an item with
9
- its descendants. The application owns each Tree Item's selected state and responds to select.</prop>
9
+ its descendants. The application owns each Tree Item's selected state and responds to select. Single-selection rows also request activate on a row click
10
+ or Enter, including an already selected row. Space requests selection only; controls and disabled rows do not activate.</prop>
10
11
  <prop name="hoverExpandDelay" type="number" default="700"
11
12
  >How long, in milliseconds, a dragged item must hover over the middle of a collapsed branch before the branch opens to receive it. 0 opens it at
12
13
  once.</prop>
@@ -41,6 +42,10 @@
41
42
  <prop name="resultingDepth" required type="integer"></prop>
42
43
  <prop name="trigger" required type="keyword" values="keyboard, pointer, programmatic"></prop>
43
44
  </event>
45
+ <event name="activate" type="object">
46
+ <prop name="id" required type="string"></prop>
47
+ <prop name="trigger" required type="keyword" values="keyboard, pointer"></prop>
48
+ </event>
44
49
  <event name="select" type="object">
45
50
  <prop name="ids" required type="list">
46
51
  <prop type="string"></prop>
@@ -202,6 +202,7 @@ export default function controller(host) {
202
202
  event.stopPropagation();
203
203
  selectItem(item, "pointer");
204
204
  focusItem(item);
205
+ if (selectionMode() === "single" && !checkbox) host.dispatch("activate", { id: itemId(item), trigger: "pointer" });
205
206
  if (checkbox) requestAnimationFrame(syncSelection);
206
207
  return;
207
208
  }
@@ -382,6 +383,13 @@ export default function controller(host) {
382
383
  if (interactive(event)) return;
383
384
  const current = itemFromEvent(event);
384
385
  if (!current) return;
386
+ if (event.key === "Enter" && selectionMode() === "single" && !event.altKey && !event.ctrlKey && !event.metaKey) {
387
+ if (current.getAttribute("aria-disabled") === "true") return;
388
+ event.preventDefault();
389
+ selectItem(current, "keyboard");
390
+ host.dispatch("activate", { id: itemId(current), trigger: "keyboard" });
391
+ return;
392
+ }
385
393
  if (event.key === " " && selectionMode() !== "none") {
386
394
  event.preventDefault();
387
395
  selectItem(current, "keyboard");