@react-aria/test-utils 1.0.0-alpha.7 → 1.0.0-alpha.8

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 (61) hide show
  1. package/dist/combobox.main.js +5 -4
  2. package/dist/combobox.main.js.map +1 -1
  3. package/dist/combobox.mjs +5 -4
  4. package/dist/combobox.module.js +5 -4
  5. package/dist/combobox.module.js.map +1 -1
  6. package/dist/events.main.js +31 -1
  7. package/dist/events.main.js.map +1 -1
  8. package/dist/events.mjs +30 -2
  9. package/dist/events.module.js +30 -2
  10. package/dist/events.module.js.map +1 -1
  11. package/dist/gridlist.main.js +23 -9
  12. package/dist/gridlist.main.js.map +1 -1
  13. package/dist/gridlist.mjs +24 -10
  14. package/dist/gridlist.module.js +24 -10
  15. package/dist/gridlist.module.js.map +1 -1
  16. package/dist/listbox.main.js +22 -13
  17. package/dist/listbox.main.js.map +1 -1
  18. package/dist/listbox.mjs +23 -14
  19. package/dist/listbox.module.js +23 -14
  20. package/dist/listbox.module.js.map +1 -1
  21. package/dist/menu.main.js +1 -1
  22. package/dist/menu.main.js.map +1 -1
  23. package/dist/menu.mjs +1 -1
  24. package/dist/menu.module.js +1 -1
  25. package/dist/menu.module.js.map +1 -1
  26. package/dist/select.main.js +7 -4
  27. package/dist/select.main.js.map +1 -1
  28. package/dist/select.mjs +7 -4
  29. package/dist/select.module.js +7 -4
  30. package/dist/select.module.js.map +1 -1
  31. package/dist/table.main.js +42 -9
  32. package/dist/table.main.js.map +1 -1
  33. package/dist/table.mjs +44 -11
  34. package/dist/table.module.js +44 -11
  35. package/dist/table.module.js.map +1 -1
  36. package/dist/tabs.main.js +1 -1
  37. package/dist/tabs.main.js.map +1 -1
  38. package/dist/tabs.mjs +1 -1
  39. package/dist/tabs.module.js +1 -1
  40. package/dist/tabs.module.js.map +1 -1
  41. package/dist/tree.main.js +27 -8
  42. package/dist/tree.main.js.map +1 -1
  43. package/dist/tree.mjs +28 -9
  44. package/dist/tree.module.js +28 -9
  45. package/dist/tree.module.js.map +1 -1
  46. package/dist/types.d.ts +21 -1
  47. package/dist/types.d.ts.map +1 -1
  48. package/dist/userEventMaps.main.js.map +1 -1
  49. package/dist/userEventMaps.module.js.map +1 -1
  50. package/package.json +7 -3
  51. package/src/combobox.ts +10 -7
  52. package/src/events.ts +34 -2
  53. package/src/gridlist.ts +35 -12
  54. package/src/listbox.ts +47 -19
  55. package/src/menu.ts +1 -1
  56. package/src/select.ts +10 -4
  57. package/src/table.ts +71 -10
  58. package/src/tabs.ts +1 -1
  59. package/src/tree.ts +40 -10
  60. package/src/types.ts +11 -1
  61. package/src/userEventMaps.ts +1 -1
package/dist/tree.main.js CHANGED
@@ -36,23 +36,29 @@ class $9c221bde173322ba$export$4445864b14128396 {
36
36
  }
37
37
  // TODO: RTL
38
38
  async keyboardNavigateToRow(opts) {
39
- let { row: row } = opts;
39
+ let { row: row, selectionOnNav: selectionOnNav = 'default' } = opts;
40
+ let altKey = (0, $5a8bfe1663b8366d$exports.getAltKey)();
40
41
  let rows = this.rows;
41
42
  let targetIndex = rows.indexOf(row);
42
43
  if (targetIndex === -1) throw new Error('Option provided is not in the tree');
43
- if (document.activeElement !== this._tree || !this._tree.contains(document.activeElement)) (0, $cVFA5$testinglibraryreact.act)(()=>this._tree.focus());
44
- if (document.activeElement === this.tree) await this.user.keyboard('[ArrowDown]');
44
+ if (document.activeElement !== this._tree && !this._tree.contains(document.activeElement)) (0, $cVFA5$testinglibraryreact.act)(()=>this._tree.focus());
45
+ if (document.activeElement === this.tree) await this.user.keyboard(`${selectionOnNav === 'none' ? `[${altKey}>]` : ''}[ArrowDown]${selectionOnNav === 'none' ? `[/${altKey}]` : ''}`);
45
46
  else if (this._tree.contains(document.activeElement) && document.activeElement.getAttribute('role') !== 'row') do await this.user.keyboard('[ArrowLeft]');
46
47
  while (document.activeElement.getAttribute('role') !== 'row');
47
48
  let currIndex = rows.indexOf(document.activeElement);
48
49
  if (currIndex === -1) throw new Error('ActiveElement is not in the tree');
49
50
  let direction = targetIndex > currIndex ? 'down' : 'up';
51
+ if (selectionOnNav === 'none') await this.user.keyboard(`[${altKey}>]`);
50
52
  for(let i = 0; i < Math.abs(targetIndex - currIndex); i++)await this.user.keyboard(`[${direction === 'down' ? 'ArrowDown' : 'ArrowUp'}]`);
53
+ if (selectionOnNav === 'none') await this.user.keyboard(`[/${altKey}]`);
51
54
  }
52
55
  /**
53
56
  * Toggles the selection for the specified tree row. Defaults to using the interaction type set on the tree tester.
57
+ * Note that this will endevor to always add/remove JUST the provided row to the set of selected rows.
54
58
  */ async toggleRowSelection(opts) {
55
- let { row: row, needsLongPress: needsLongPress, checkboxSelection: checkboxSelection = true, interactionType: interactionType = this._interactionType } = opts;
59
+ let { row: row, needsLongPress: needsLongPress, checkboxSelection: checkboxSelection = true, interactionType: interactionType = this._interactionType, selectionBehavior: selectionBehavior = 'toggle' } = opts;
60
+ let altKey = (0, $5a8bfe1663b8366d$exports.getAltKey)();
61
+ let metaKey = (0, $5a8bfe1663b8366d$exports.getMetaKey)();
56
62
  if (typeof row === 'string' || typeof row === 'number') row = this.findRow({
57
63
  rowIndexOrText: row
58
64
  });
@@ -63,11 +69,14 @@ class $9c221bde173322ba$export$4445864b14128396 {
63
69
  if (interactionType === 'keyboard' && ((rowCheckbox === null || rowCheckbox === void 0 ? void 0 : rowCheckbox.getAttribute('disabled')) === '' || (row === null || row === void 0 ? void 0 : row.getAttribute('aria-disabled')) === 'true')) return;
64
70
  // this would be better than the check to do nothing in events.ts
65
71
  // also, it'd be good to be able to trigger selection on the row instead of having to go to the checkbox directly
66
- if (interactionType === 'keyboard' && !checkboxSelection) {
72
+ if (interactionType === 'keyboard' && (!checkboxSelection || !rowCheckbox)) {
67
73
  await this.keyboardNavigateToRow({
68
- row: row
74
+ row: row,
75
+ selectionOnNav: selectionBehavior === 'replace' ? 'none' : 'default'
69
76
  });
70
- await this.user.keyboard('{Space}');
77
+ if (selectionBehavior === 'replace') await this.user.keyboard(`[${altKey}>]`);
78
+ await this.user.keyboard('[Space]');
79
+ if (selectionBehavior === 'replace') await this.user.keyboard(`[/${altKey}]`);
71
80
  return;
72
81
  }
73
82
  if (rowCheckbox && checkboxSelection) await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, rowCheckbox, interactionType);
@@ -83,7 +92,12 @@ class $9c221bde173322ba$export$4445864b14128396 {
83
92
  pointerType: 'touch'
84
93
  }
85
94
  });
86
- } else await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, cell, interactionType);
95
+ } else {
96
+ // TODO add modifiers here? Maybe move into pressElement if we get more cases for different types of modifier keys
97
+ if (selectionBehavior === 'replace' && interactionType !== 'touch') await this.user.keyboard(`[${metaKey}>]`);
98
+ await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, row, interactionType);
99
+ if (selectionBehavior === 'replace' && interactionType !== 'touch') await this.user.keyboard(`[/${metaKey}]`);
100
+ }
87
101
  }
88
102
  }
89
103
  /**
@@ -103,6 +117,9 @@ class $9c221bde173322ba$export$4445864b14128396 {
103
117
  await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, rowExpander, interactionType);
104
118
  } else if (interactionType === 'keyboard') {
105
119
  if ((row === null || row === void 0 ? void 0 : row.getAttribute('aria-disabled')) === 'true') return;
120
+ // TODO: We always Use Option/Ctrl when keyboard navigating so selection isn't changed
121
+ // in selectionmode="replace"/highlight selection when navigating to the row that the user wants
122
+ // to expand. Discuss if this is useful or not
106
123
  await this.keyboardNavigateToRow({
107
124
  row: row
108
125
  });
@@ -121,6 +138,8 @@ class $9c221bde173322ba$export$4445864b14128396 {
121
138
  if (needsDoubleClick) await this.user.dblClick(row);
122
139
  else if (interactionType === 'keyboard') {
123
140
  if ((row === null || row === void 0 ? void 0 : row.getAttribute('aria-disabled')) === 'true') return;
141
+ // TODO: same as above, uses the modifier key to make sure we don't modify selection state on row focus
142
+ // as we keyboard navigate to the row we want activate
124
143
  await this.keyboardNavigateToRow({
125
144
  row: row
126
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AAa,GAAG;QACrB,IAAI,CAAC,KAAK,GAAG;QACb,oCAAoC;QACpC,IAAI,OAAO,CAAA,GAAA,iCAAK,EAAE,MAAM,WAAW,CAAC;QACpC,IAAI,KAAK,YAAY,CAAC,YAAY,cAAc,MAC9C,IAAI,CAAC,KAAK,GAAG;IAEjB;AAkNF","sources":["packages/@react-aria/test-utils/src/tree.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {act, within} from '@testing-library/react';\nimport {BaseGridRowInteractionOpts, GridRowActionOpts, ToggleGridRowOpts, TreeTesterOpts, UserOpts} from './types';\nimport {pressElement, triggerLongPress} from './events';\n\ninterface TreeToggleExpansionOpts extends BaseGridRowInteractionOpts {}\ninterface TreeToggleRowOpts extends ToggleGridRowOpts {}\ninterface TreeRowActionOpts extends GridRowActionOpts {}\n\n// TODO: this ended up being pretty much the same as gridlist, refactor so it extends from gridlist\nexport class TreeTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _advanceTimer: UserOpts['advanceTimer'];\n private _tree: HTMLElement;\n\n constructor(opts: TreeTesterOpts) {\n let {root, user, interactionType, advanceTimer} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n this._advanceTimer = advanceTimer;\n this._tree = root;\n // TODO: should all helpers do this?\n let tree = within(root).queryByRole('treegrid');\n if (root.getAttribute('role') !== 'treegrid' && tree) {\n this._tree = tree;\n }\n }\n\n /**\n * Set the interaction type used by the tree tester.\n */\n setInteractionType(type: UserOpts['interactionType']): void {\n this._interactionType = type;\n };\n\n /**\n * Returns a row matching the specified index or text content.\n */\n findRow(opts: {rowIndexOrText: number | string}): HTMLElement {\n let {\n rowIndexOrText\n } = opts;\n\n let row;\n if (typeof rowIndexOrText === 'number') {\n row = this.rows[rowIndexOrText];\n } else if (typeof rowIndexOrText === 'string') {\n row = (within(this.tree!).getByText(rowIndexOrText).closest('[role=row]'))! as HTMLElement;\n }\n\n return row;\n }\n\n // TODO: RTL\n private async keyboardNavigateToRow(opts: {row: HTMLElement}) {\n let {row} = opts;\n let rows = this.rows;\n let targetIndex = rows.indexOf(row);\n if (targetIndex === -1) {\n throw new Error('Option provided is not in the tree');\n }\n\n if (document.activeElement !== this._tree || !this._tree.contains(document.activeElement)) {\n act(() => this._tree.focus());\n }\n\n if (document.activeElement === this.tree) {\n await this.user.keyboard('[ArrowDown]');\n } else if (this._tree.contains(document.activeElement) && document.activeElement!.getAttribute('role') !== 'row') {\n do {\n await this.user.keyboard('[ArrowLeft]');\n } while (document.activeElement!.getAttribute('role') !== 'row');\n }\n let currIndex = rows.indexOf(document.activeElement as HTMLElement);\n if (currIndex === -1) {\n throw new Error('ActiveElement is not in the tree');\n }\n let direction = targetIndex > currIndex ? 'down' : 'up';\n\n for (let i = 0; i < Math.abs(targetIndex - currIndex); i++) {\n await this.user.keyboard(`[${direction === 'down' ? 'ArrowDown' : 'ArrowUp'}]`);\n }\n };\n\n /**\n * Toggles the selection for the specified tree row. Defaults to using the interaction type set on the tree tester.\n */\n async toggleRowSelection(opts: TreeToggleRowOpts): Promise<void> {\n let {\n row,\n needsLongPress,\n checkboxSelection = true,\n interactionType = this._interactionType\n } = opts;\n\n if (typeof row === 'string' || typeof row === 'number') {\n row = this.findRow({rowIndexOrText: row});\n }\n\n if (!row) {\n throw new Error('Target row not found in the tree.');\n }\n\n let rowCheckbox = within(row).queryByRole('checkbox');\n\n // TODO: we early return here because the checkbox can't be keyboard navigated to if the row is disabled usually\n // but we may to check for disabledBehavior (aka if the disable row gets skipped when keyboard navigating or not)\n if (interactionType === 'keyboard' && (rowCheckbox?.getAttribute('disabled') === '' || row?.getAttribute('aria-disabled') === 'true')) {\n return;\n }\n\n // this would be better than the check to do nothing in events.ts\n // also, it'd be good to be able to trigger selection on the row instead of having to go to the checkbox directly\n if (interactionType === 'keyboard' && !checkboxSelection) {\n await this.keyboardNavigateToRow({row});\n await this.user.keyboard('{Space}');\n return;\n }\n if (rowCheckbox && checkboxSelection) {\n await pressElement(this.user, rowCheckbox, interactionType);\n } else {\n let cell = within(row).getAllByRole('gridcell')[0];\n if (needsLongPress && interactionType === 'touch') {\n if (this._advanceTimer == null) {\n throw new Error('No advanceTimers provided for long press.');\n }\n\n // Note that long press interactions with rows is strictly touch only for grid rows\n await triggerLongPress({element: cell, advanceTimer: this._advanceTimer, pointerOpts: {pointerType: 'touch'}});\n } else {\n await pressElement(this.user, cell, interactionType);\n }\n }\n };\n\n /**\n * Toggles the expansion for the specified tree row. Defaults to using the interaction type set on the tree tester.\n */\n async toggleRowExpansion(opts: TreeToggleExpansionOpts): Promise<void> {\n let {\n row,\n interactionType = this._interactionType\n } = opts;\n if (!this.tree.contains(document.activeElement)) {\n await act(async () => {\n this.tree.focus();\n });\n }\n\n if (typeof row === 'string' || typeof row === 'number') {\n row = this.findRow({rowIndexOrText: row});\n }\n\n if (!row) {\n throw new Error('Target row not found in the tree.');\n } else if (row.getAttribute('aria-expanded') == null) {\n throw new Error('Target row is not expandable.');\n }\n\n if (interactionType === 'mouse' || interactionType === 'touch') {\n let rowExpander = within(row).getAllByRole('button')[0]; // what happens if the button is not first? how can we differentiate?\n await pressElement(this.user, rowExpander, interactionType);\n } else if (interactionType === 'keyboard') {\n if (row?.getAttribute('aria-disabled') === 'true') {\n return;\n }\n\n await this.keyboardNavigateToRow({row});\n if (row.getAttribute('aria-expanded') === 'true') {\n await this.user.keyboard('[ArrowLeft]');\n } else {\n await this.user.keyboard('[ArrowRight]');\n }\n }\n };\n\n /**\n * Triggers the action for the specified tree row. Defaults to using the interaction type set on the tree tester.\n */\n async triggerRowAction(opts: TreeRowActionOpts): Promise<void> {\n let {\n row,\n needsDoubleClick,\n interactionType = this._interactionType\n } = opts;\n\n if (typeof row === 'string' || typeof row === 'number') {\n row = this.findRow({rowIndexOrText: row});\n }\n\n if (!row) {\n throw new Error('Target row not found in the tree.');\n }\n\n if (needsDoubleClick) {\n await this.user.dblClick(row);\n } else if (interactionType === 'keyboard') {\n if (row?.getAttribute('aria-disabled') === 'true') {\n return;\n }\n\n await this.keyboardNavigateToRow({row});\n await this.user.keyboard('[Enter]');\n } else {\n await pressElement(this.user, row, interactionType);\n }\n };\n\n /**\n * Returns the tree.\n */\n get tree(): HTMLElement {\n return this._tree;\n }\n\n /**\n * Returns the tree's rows if any.\n */\n get rows(): HTMLElement[] {\n return within(this?.tree).queryAllByRole('row');\n }\n\n /**\n * Returns the tree's selected rows if any.\n */\n get selectedRows(): HTMLElement[] {\n return this.rows.filter(row => row.getAttribute('aria-selected') === 'true');\n }\n\n /**\n * Returns the tree's cells if any. Can be filtered against a specific row if provided via `element`.\n */\n cells(opts: {element?: HTMLElement} = {}): HTMLElement[] {\n let {element = this.tree} = opts;\n return within(element).queryAllByRole('gridcell');\n }\n}\n"],"names":[],"version":3,"file":"tree.main.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAWM,MAAM;IAmBX;;GAEC,GACD,mBAAmB,IAAiC,EAAQ;QAC1D,IAAI,CAAC,gBAAgB,GAAG;IAC1B;IAEA;;GAEC,GACD,QAAQ,IAAuC,EAAe;QAC5D,IAAI,kBACF,cAAc,EACf,GAAG;QAEJ,IAAI;QACJ,IAAI,OAAO,mBAAmB,UAC5B,MAAM,IAAI,CAAC,IAAI,CAAC,eAAe;aAC1B,IAAI,OAAO,mBAAmB,UACnC,MAAO,CAAA,GAAA,iCAAK,EAAE,IAAI,CAAC,IAAI,EAAG,SAAS,CAAC,gBAAgB,OAAO,CAAC;QAG9D,OAAO;IACT;IAEA,YAAY;IACZ,MAAc,sBAAsB,IAA6D,EAAE;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IACnB;IAEA;;GAEC,GACD,IAAI,OAAsB;YACV;QAAd,OAAO,CAAA,GAAA,iCAAK,GAAE,QAAA,IAAI,cAAJ,4BAAA,MAAM,IAAI,EAAE,cAAc,CAAC;IAC3C;IAEA;;GAEC,GACD,IAAI,eAA8B;QAChC,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA,MAAO,IAAI,YAAY,CAAC,qBAAqB;IACvE;IAEA;;GAEC,GACD,MAAM,OAAgC,CAAC,CAAC,EAAiB;QACvD,IAAI,WAAC,UAAU,IAAI,CAAC,IAAI,EAAC,GAAG;QAC5B,OAAO,CAAA,GAAA,iCAAK,EAAE,SAAS,cAAc,CAAC;IACxC;IA1PA,YAAY,IAAoB,CAAE;QAChC,IAAI,QAAC,IAAI,QAAE,IAAI,mBAAE,eAAe,gBAAE,YAAY,EAAC,GAAG;QAClD,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,gBAAgB,GAAG,mBAAmB;QAC3C,IAAI,CAAC,aAAa,GAAG;QACrB,IAAI,CAAC,KAAK,GAAG;QACb,oCAAoC;QACpC,IAAI,OAAO,CAAA,GAAA,iCAAK,EAAE,MAAM,WAAW,CAAC;QACpC,IAAI,KAAK,YAAY,CAAC,YAAY,cAAc,MAC9C,IAAI,CAAC,KAAK,GAAG;IAEjB;AAgPF","sources":["packages/@react-aria/test-utils/src/tree.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {act, within} from '@testing-library/react';\nimport {BaseGridRowInteractionOpts, GridRowActionOpts, ToggleGridRowOpts, TreeTesterOpts, UserOpts} from './types';\nimport {getAltKey, getMetaKey, pressElement, triggerLongPress} from './events';\n\ninterface TreeToggleExpansionOpts extends BaseGridRowInteractionOpts {}\ninterface TreeToggleRowOpts extends ToggleGridRowOpts {}\ninterface TreeRowActionOpts extends GridRowActionOpts {}\n\n// TODO: this ended up being pretty much the same as gridlist, refactor so it extends from gridlist\nexport class TreeTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _advanceTimer: UserOpts['advanceTimer'];\n private _tree: HTMLElement;\n\n constructor(opts: TreeTesterOpts) {\n let {root, user, interactionType, advanceTimer} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n this._advanceTimer = advanceTimer;\n this._tree = root;\n // TODO: should all helpers do this?\n let tree = within(root).queryByRole('treegrid');\n if (root.getAttribute('role') !== 'treegrid' && tree) {\n this._tree = tree;\n }\n }\n\n /**\n * Set the interaction type used by the tree tester.\n */\n setInteractionType(type: UserOpts['interactionType']): void {\n this._interactionType = type;\n };\n\n /**\n * Returns a row matching the specified index or text content.\n */\n findRow(opts: {rowIndexOrText: number | string}): HTMLElement {\n let {\n rowIndexOrText\n } = opts;\n\n let row;\n if (typeof rowIndexOrText === 'number') {\n row = this.rows[rowIndexOrText];\n } else if (typeof rowIndexOrText === 'string') {\n row = (within(this.tree!).getByText(rowIndexOrText).closest('[role=row]'))! as HTMLElement;\n }\n\n return row;\n }\n\n // TODO: RTL\n private async keyboardNavigateToRow(opts: {row: HTMLElement, selectionOnNav?: 'default' | 'none'}) {\n let {row, selectionOnNav = 'default'} = opts;\n let altKey = getAltKey();\n let rows = this.rows;\n let targetIndex = rows.indexOf(row);\n if (targetIndex === -1) {\n throw new Error('Option provided is not in the tree');\n }\n\n if (document.activeElement !== this._tree && !this._tree.contains(document.activeElement)) {\n act(() => this._tree.focus());\n }\n\n if (document.activeElement === this.tree) {\n await this.user.keyboard(`${selectionOnNav === 'none' ? `[${altKey}>]` : ''}[ArrowDown]${selectionOnNav === 'none' ? `[/${altKey}]` : ''}`);\n } else if (this._tree.contains(document.activeElement) && document.activeElement!.getAttribute('role') !== 'row') {\n do {\n await this.user.keyboard('[ArrowLeft]');\n } while (document.activeElement!.getAttribute('role') !== 'row');\n }\n let currIndex = rows.indexOf(document.activeElement as HTMLElement);\n if (currIndex === -1) {\n throw new Error('ActiveElement is not in the tree');\n }\n let direction = targetIndex > currIndex ? 'down' : 'up';\n\n if (selectionOnNav === 'none') {\n await this.user.keyboard(`[${altKey}>]`);\n }\n for (let i = 0; i < Math.abs(targetIndex - currIndex); i++) {\n await this.user.keyboard(`[${direction === 'down' ? 'ArrowDown' : 'ArrowUp'}]`);\n }\n if (selectionOnNav === 'none') {\n await this.user.keyboard(`[/${altKey}]`);\n }\n };\n\n /**\n * Toggles the selection for the specified tree row. Defaults to using the interaction type set on the tree tester.\n * Note that this will endevor to always add/remove JUST the provided row to the set of selected rows.\n */\n async toggleRowSelection(opts: TreeToggleRowOpts): Promise<void> {\n let {\n row,\n needsLongPress,\n checkboxSelection = true,\n interactionType = this._interactionType,\n selectionBehavior = 'toggle'\n } = opts;\n\n let altKey = getAltKey();\n let metaKey = getMetaKey();\n\n if (typeof row === 'string' || typeof row === 'number') {\n row = this.findRow({rowIndexOrText: row});\n }\n\n if (!row) {\n throw new Error('Target row not found in the tree.');\n }\n\n let rowCheckbox = within(row).queryByRole('checkbox');\n\n // TODO: we early return here because the checkbox can't be keyboard navigated to if the row is disabled usually\n // but we may to check for disabledBehavior (aka if the disable row gets skipped when keyboard navigating or not)\n if (interactionType === 'keyboard' && (rowCheckbox?.getAttribute('disabled') === '' || row?.getAttribute('aria-disabled') === 'true')) {\n return;\n }\n\n // this would be better than the check to do nothing in events.ts\n // also, it'd be good to be able to trigger selection on the row instead of having to go to the checkbox directly\n if (interactionType === 'keyboard' && (!checkboxSelection || !rowCheckbox)) {\n await this.keyboardNavigateToRow({row, selectionOnNav: selectionBehavior === 'replace' ? 'none' : 'default'});\n if (selectionBehavior === 'replace') {\n await this.user.keyboard(`[${altKey}>]`);\n }\n await this.user.keyboard('[Space]');\n if (selectionBehavior === 'replace') {\n await this.user.keyboard(`[/${altKey}]`);\n }\n return;\n }\n if (rowCheckbox && checkboxSelection) {\n await pressElement(this.user, rowCheckbox, interactionType);\n } else {\n let cell = within(row).getAllByRole('gridcell')[0];\n if (needsLongPress && interactionType === 'touch') {\n if (this._advanceTimer == null) {\n throw new Error('No advanceTimers provided for long press.');\n }\n\n // Note that long press interactions with rows is strictly touch only for grid rows\n await triggerLongPress({element: cell, advanceTimer: this._advanceTimer, pointerOpts: {pointerType: 'touch'}});\n } else {\n // TODO add modifiers here? Maybe move into pressElement if we get more cases for different types of modifier keys\n if (selectionBehavior === 'replace' && interactionType !== 'touch') {\n await this.user.keyboard(`[${metaKey}>]`);\n }\n await pressElement(this.user, row, interactionType);\n if (selectionBehavior === 'replace' && interactionType !== 'touch') {\n await this.user.keyboard(`[/${metaKey}]`);\n }\n }\n }\n };\n\n /**\n * Toggles the expansion for the specified tree row. Defaults to using the interaction type set on the tree tester.\n */\n async toggleRowExpansion(opts: TreeToggleExpansionOpts): Promise<void> {\n let {\n row,\n interactionType = this._interactionType\n } = opts;\n if (!this.tree.contains(document.activeElement)) {\n await act(async () => {\n this.tree.focus();\n });\n }\n\n if (typeof row === 'string' || typeof row === 'number') {\n row = this.findRow({rowIndexOrText: row});\n }\n\n if (!row) {\n throw new Error('Target row not found in the tree.');\n } else if (row.getAttribute('aria-expanded') == null) {\n throw new Error('Target row is not expandable.');\n }\n\n if (interactionType === 'mouse' || interactionType === 'touch') {\n let rowExpander = within(row).getAllByRole('button')[0]; // what happens if the button is not first? how can we differentiate?\n await pressElement(this.user, rowExpander, interactionType);\n } else if (interactionType === 'keyboard') {\n if (row?.getAttribute('aria-disabled') === 'true') {\n return;\n }\n\n // TODO: We always Use Option/Ctrl when keyboard navigating so selection isn't changed\n // in selectionmode=\"replace\"/highlight selection when navigating to the row that the user wants\n // to expand. Discuss if this is useful or not\n await this.keyboardNavigateToRow({row});\n if (row.getAttribute('aria-expanded') === 'true') {\n await this.user.keyboard('[ArrowLeft]');\n } else {\n await this.user.keyboard('[ArrowRight]');\n }\n }\n };\n\n /**\n * Triggers the action for the specified tree row. Defaults to using the interaction type set on the tree tester.\n */\n async triggerRowAction(opts: TreeRowActionOpts): Promise<void> {\n let {\n row,\n needsDoubleClick,\n interactionType = this._interactionType\n } = opts;\n\n if (typeof row === 'string' || typeof row === 'number') {\n row = this.findRow({rowIndexOrText: row});\n }\n\n if (!row) {\n throw new Error('Target row not found in the tree.');\n }\n\n if (needsDoubleClick) {\n await this.user.dblClick(row);\n } else if (interactionType === 'keyboard') {\n if (row?.getAttribute('aria-disabled') === 'true') {\n return;\n }\n\n // TODO: same as above, uses the modifier key to make sure we don't modify selection state on row focus\n // as we keyboard navigate to the row we want activate\n await this.keyboardNavigateToRow({row});\n await this.user.keyboard('[Enter]');\n } else {\n await pressElement(this.user, row, interactionType);\n }\n };\n\n /**\n * Returns the tree.\n */\n get tree(): HTMLElement {\n return this._tree;\n }\n\n /**\n * Returns the tree's rows if any.\n */\n get rows(): HTMLElement[] {\n return within(this?.tree).queryAllByRole('row');\n }\n\n /**\n * Returns the tree's selected rows if any.\n */\n get selectedRows(): HTMLElement[] {\n return this.rows.filter(row => row.getAttribute('aria-selected') === 'true');\n }\n\n /**\n * Returns the tree's cells if any. Can be filtered against a specific row if provided via `element`.\n */\n cells(opts: {element?: HTMLElement} = {}): HTMLElement[] {\n let {element = this.tree} = opts;\n return within(element).queryAllByRole('gridcell');\n }\n}\n"],"names":[],"version":3,"file":"tree.main.js.map"}
package/dist/tree.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import {pressElement as $5d1eca18f92ad0e6$export$6ffa3eb717517feb, triggerLongPress as $5d1eca18f92ad0e6$export$3a22a5a9bc0fd3b} from "./events.mjs";
1
+ import {getAltKey as $5d1eca18f92ad0e6$export$6fc0ccaebd758b9d, getMetaKey as $5d1eca18f92ad0e6$export$7943c508934e27ce, pressElement as $5d1eca18f92ad0e6$export$6ffa3eb717517feb, triggerLongPress as $5d1eca18f92ad0e6$export$3a22a5a9bc0fd3b} from "./events.mjs";
2
2
  import {within as $3mnbZ$within, act as $3mnbZ$act} from "@testing-library/react";
3
3
 
4
4
  /*
@@ -30,23 +30,29 @@ class $962758aa2f16f1a4$export$4445864b14128396 {
30
30
  }
31
31
  // TODO: RTL
32
32
  async keyboardNavigateToRow(opts) {
33
- let { row: row } = opts;
33
+ let { row: row, selectionOnNav: selectionOnNav = 'default' } = opts;
34
+ let altKey = (0, $5d1eca18f92ad0e6$export$6fc0ccaebd758b9d)();
34
35
  let rows = this.rows;
35
36
  let targetIndex = rows.indexOf(row);
36
37
  if (targetIndex === -1) throw new Error('Option provided is not in the tree');
37
- if (document.activeElement !== this._tree || !this._tree.contains(document.activeElement)) (0, $3mnbZ$act)(()=>this._tree.focus());
38
- if (document.activeElement === this.tree) await this.user.keyboard('[ArrowDown]');
38
+ if (document.activeElement !== this._tree && !this._tree.contains(document.activeElement)) (0, $3mnbZ$act)(()=>this._tree.focus());
39
+ if (document.activeElement === this.tree) await this.user.keyboard(`${selectionOnNav === 'none' ? `[${altKey}>]` : ''}[ArrowDown]${selectionOnNav === 'none' ? `[/${altKey}]` : ''}`);
39
40
  else if (this._tree.contains(document.activeElement) && document.activeElement.getAttribute('role') !== 'row') do await this.user.keyboard('[ArrowLeft]');
40
41
  while (document.activeElement.getAttribute('role') !== 'row');
41
42
  let currIndex = rows.indexOf(document.activeElement);
42
43
  if (currIndex === -1) throw new Error('ActiveElement is not in the tree');
43
44
  let direction = targetIndex > currIndex ? 'down' : 'up';
45
+ if (selectionOnNav === 'none') await this.user.keyboard(`[${altKey}>]`);
44
46
  for(let i = 0; i < Math.abs(targetIndex - currIndex); i++)await this.user.keyboard(`[${direction === 'down' ? 'ArrowDown' : 'ArrowUp'}]`);
47
+ if (selectionOnNav === 'none') await this.user.keyboard(`[/${altKey}]`);
45
48
  }
46
49
  /**
47
50
  * Toggles the selection for the specified tree row. Defaults to using the interaction type set on the tree tester.
51
+ * Note that this will endevor to always add/remove JUST the provided row to the set of selected rows.
48
52
  */ async toggleRowSelection(opts) {
49
- let { row: row, needsLongPress: needsLongPress, checkboxSelection: checkboxSelection = true, interactionType: interactionType = this._interactionType } = opts;
53
+ let { row: row, needsLongPress: needsLongPress, checkboxSelection: checkboxSelection = true, interactionType: interactionType = this._interactionType, selectionBehavior: selectionBehavior = 'toggle' } = opts;
54
+ let altKey = (0, $5d1eca18f92ad0e6$export$6fc0ccaebd758b9d)();
55
+ let metaKey = (0, $5d1eca18f92ad0e6$export$7943c508934e27ce)();
50
56
  if (typeof row === 'string' || typeof row === 'number') row = this.findRow({
51
57
  rowIndexOrText: row
52
58
  });
@@ -57,11 +63,14 @@ class $962758aa2f16f1a4$export$4445864b14128396 {
57
63
  if (interactionType === 'keyboard' && ((rowCheckbox === null || rowCheckbox === void 0 ? void 0 : rowCheckbox.getAttribute('disabled')) === '' || (row === null || row === void 0 ? void 0 : row.getAttribute('aria-disabled')) === 'true')) return;
58
64
  // this would be better than the check to do nothing in events.ts
59
65
  // also, it'd be good to be able to trigger selection on the row instead of having to go to the checkbox directly
60
- if (interactionType === 'keyboard' && !checkboxSelection) {
66
+ if (interactionType === 'keyboard' && (!checkboxSelection || !rowCheckbox)) {
61
67
  await this.keyboardNavigateToRow({
62
- row: row
68
+ row: row,
69
+ selectionOnNav: selectionBehavior === 'replace' ? 'none' : 'default'
63
70
  });
64
- await this.user.keyboard('{Space}');
71
+ if (selectionBehavior === 'replace') await this.user.keyboard(`[${altKey}>]`);
72
+ await this.user.keyboard('[Space]');
73
+ if (selectionBehavior === 'replace') await this.user.keyboard(`[/${altKey}]`);
65
74
  return;
66
75
  }
67
76
  if (rowCheckbox && checkboxSelection) await (0, $5d1eca18f92ad0e6$export$6ffa3eb717517feb)(this.user, rowCheckbox, interactionType);
@@ -77,7 +86,12 @@ class $962758aa2f16f1a4$export$4445864b14128396 {
77
86
  pointerType: 'touch'
78
87
  }
79
88
  });
80
- } else await (0, $5d1eca18f92ad0e6$export$6ffa3eb717517feb)(this.user, cell, interactionType);
89
+ } else {
90
+ // TODO add modifiers here? Maybe move into pressElement if we get more cases for different types of modifier keys
91
+ if (selectionBehavior === 'replace' && interactionType !== 'touch') await this.user.keyboard(`[${metaKey}>]`);
92
+ await (0, $5d1eca18f92ad0e6$export$6ffa3eb717517feb)(this.user, row, interactionType);
93
+ if (selectionBehavior === 'replace' && interactionType !== 'touch') await this.user.keyboard(`[/${metaKey}]`);
94
+ }
81
95
  }
82
96
  }
83
97
  /**
@@ -97,6 +111,9 @@ class $962758aa2f16f1a4$export$4445864b14128396 {
97
111
  await (0, $5d1eca18f92ad0e6$export$6ffa3eb717517feb)(this.user, rowExpander, interactionType);
98
112
  } else if (interactionType === 'keyboard') {
99
113
  if ((row === null || row === void 0 ? void 0 : row.getAttribute('aria-disabled')) === 'true') return;
114
+ // TODO: We always Use Option/Ctrl when keyboard navigating so selection isn't changed
115
+ // in selectionmode="replace"/highlight selection when navigating to the row that the user wants
116
+ // to expand. Discuss if this is useful or not
100
117
  await this.keyboardNavigateToRow({
101
118
  row: row
102
119
  });
@@ -115,6 +132,8 @@ class $962758aa2f16f1a4$export$4445864b14128396 {
115
132
  if (needsDoubleClick) await this.user.dblClick(row);
116
133
  else if (interactionType === 'keyboard') {
117
134
  if ((row === null || row === void 0 ? void 0 : row.getAttribute('aria-disabled')) === 'true') return;
135
+ // TODO: same as above, uses the modifier key to make sure we don't modify selection state on row focus
136
+ // as we keyboard navigate to the row we want activate
118
137
  await this.keyboardNavigateToRow({
119
138
  row: row
120
139
  });
@@ -1,4 +1,4 @@
1
- import {pressElement as $5d1eca18f92ad0e6$export$6ffa3eb717517feb, triggerLongPress as $5d1eca18f92ad0e6$export$3a22a5a9bc0fd3b} from "./events.module.js";
1
+ import {getAltKey as $5d1eca18f92ad0e6$export$6fc0ccaebd758b9d, getMetaKey as $5d1eca18f92ad0e6$export$7943c508934e27ce, pressElement as $5d1eca18f92ad0e6$export$6ffa3eb717517feb, triggerLongPress as $5d1eca18f92ad0e6$export$3a22a5a9bc0fd3b} from "./events.module.js";
2
2
  import {within as $3mnbZ$within, act as $3mnbZ$act} from "@testing-library/react";
3
3
 
4
4
  /*
@@ -30,23 +30,29 @@ class $962758aa2f16f1a4$export$4445864b14128396 {
30
30
  }
31
31
  // TODO: RTL
32
32
  async keyboardNavigateToRow(opts) {
33
- let { row: row } = opts;
33
+ let { row: row, selectionOnNav: selectionOnNav = 'default' } = opts;
34
+ let altKey = (0, $5d1eca18f92ad0e6$export$6fc0ccaebd758b9d)();
34
35
  let rows = this.rows;
35
36
  let targetIndex = rows.indexOf(row);
36
37
  if (targetIndex === -1) throw new Error('Option provided is not in the tree');
37
- if (document.activeElement !== this._tree || !this._tree.contains(document.activeElement)) (0, $3mnbZ$act)(()=>this._tree.focus());
38
- if (document.activeElement === this.tree) await this.user.keyboard('[ArrowDown]');
38
+ if (document.activeElement !== this._tree && !this._tree.contains(document.activeElement)) (0, $3mnbZ$act)(()=>this._tree.focus());
39
+ if (document.activeElement === this.tree) await this.user.keyboard(`${selectionOnNav === 'none' ? `[${altKey}>]` : ''}[ArrowDown]${selectionOnNav === 'none' ? `[/${altKey}]` : ''}`);
39
40
  else if (this._tree.contains(document.activeElement) && document.activeElement.getAttribute('role') !== 'row') do await this.user.keyboard('[ArrowLeft]');
40
41
  while (document.activeElement.getAttribute('role') !== 'row');
41
42
  let currIndex = rows.indexOf(document.activeElement);
42
43
  if (currIndex === -1) throw new Error('ActiveElement is not in the tree');
43
44
  let direction = targetIndex > currIndex ? 'down' : 'up';
45
+ if (selectionOnNav === 'none') await this.user.keyboard(`[${altKey}>]`);
44
46
  for(let i = 0; i < Math.abs(targetIndex - currIndex); i++)await this.user.keyboard(`[${direction === 'down' ? 'ArrowDown' : 'ArrowUp'}]`);
47
+ if (selectionOnNav === 'none') await this.user.keyboard(`[/${altKey}]`);
45
48
  }
46
49
  /**
47
50
  * Toggles the selection for the specified tree row. Defaults to using the interaction type set on the tree tester.
51
+ * Note that this will endevor to always add/remove JUST the provided row to the set of selected rows.
48
52
  */ async toggleRowSelection(opts) {
49
- let { row: row, needsLongPress: needsLongPress, checkboxSelection: checkboxSelection = true, interactionType: interactionType = this._interactionType } = opts;
53
+ let { row: row, needsLongPress: needsLongPress, checkboxSelection: checkboxSelection = true, interactionType: interactionType = this._interactionType, selectionBehavior: selectionBehavior = 'toggle' } = opts;
54
+ let altKey = (0, $5d1eca18f92ad0e6$export$6fc0ccaebd758b9d)();
55
+ let metaKey = (0, $5d1eca18f92ad0e6$export$7943c508934e27ce)();
50
56
  if (typeof row === 'string' || typeof row === 'number') row = this.findRow({
51
57
  rowIndexOrText: row
52
58
  });
@@ -57,11 +63,14 @@ class $962758aa2f16f1a4$export$4445864b14128396 {
57
63
  if (interactionType === 'keyboard' && ((rowCheckbox === null || rowCheckbox === void 0 ? void 0 : rowCheckbox.getAttribute('disabled')) === '' || (row === null || row === void 0 ? void 0 : row.getAttribute('aria-disabled')) === 'true')) return;
58
64
  // this would be better than the check to do nothing in events.ts
59
65
  // also, it'd be good to be able to trigger selection on the row instead of having to go to the checkbox directly
60
- if (interactionType === 'keyboard' && !checkboxSelection) {
66
+ if (interactionType === 'keyboard' && (!checkboxSelection || !rowCheckbox)) {
61
67
  await this.keyboardNavigateToRow({
62
- row: row
68
+ row: row,
69
+ selectionOnNav: selectionBehavior === 'replace' ? 'none' : 'default'
63
70
  });
64
- await this.user.keyboard('{Space}');
71
+ if (selectionBehavior === 'replace') await this.user.keyboard(`[${altKey}>]`);
72
+ await this.user.keyboard('[Space]');
73
+ if (selectionBehavior === 'replace') await this.user.keyboard(`[/${altKey}]`);
65
74
  return;
66
75
  }
67
76
  if (rowCheckbox && checkboxSelection) await (0, $5d1eca18f92ad0e6$export$6ffa3eb717517feb)(this.user, rowCheckbox, interactionType);
@@ -77,7 +86,12 @@ class $962758aa2f16f1a4$export$4445864b14128396 {
77
86
  pointerType: 'touch'
78
87
  }
79
88
  });
80
- } else await (0, $5d1eca18f92ad0e6$export$6ffa3eb717517feb)(this.user, cell, interactionType);
89
+ } else {
90
+ // TODO add modifiers here? Maybe move into pressElement if we get more cases for different types of modifier keys
91
+ if (selectionBehavior === 'replace' && interactionType !== 'touch') await this.user.keyboard(`[${metaKey}>]`);
92
+ await (0, $5d1eca18f92ad0e6$export$6ffa3eb717517feb)(this.user, row, interactionType);
93
+ if (selectionBehavior === 'replace' && interactionType !== 'touch') await this.user.keyboard(`[/${metaKey}]`);
94
+ }
81
95
  }
82
96
  }
83
97
  /**
@@ -97,6 +111,9 @@ class $962758aa2f16f1a4$export$4445864b14128396 {
97
111
  await (0, $5d1eca18f92ad0e6$export$6ffa3eb717517feb)(this.user, rowExpander, interactionType);
98
112
  } else if (interactionType === 'keyboard') {
99
113
  if ((row === null || row === void 0 ? void 0 : row.getAttribute('aria-disabled')) === 'true') return;
114
+ // TODO: We always Use Option/Ctrl when keyboard navigating so selection isn't changed
115
+ // in selectionmode="replace"/highlight selection when navigating to the row that the user wants
116
+ // to expand. Discuss if this is useful or not
100
117
  await this.keyboardNavigateToRow({
101
118
  row: row
102
119
  });
@@ -115,6 +132,8 @@ class $962758aa2f16f1a4$export$4445864b14128396 {
115
132
  if (needsDoubleClick) await this.user.dblClick(row);
116
133
  else if (interactionType === 'keyboard') {
117
134
  if ((row === null || row === void 0 ? void 0 : row.getAttribute('aria-disabled')) === 'true') return;
135
+ // TODO: same as above, uses the modifier key to make sure we don't modify selection state on row focus
136
+ // as we keyboard navigate to the row we want activate
118
137
  await this.keyboardNavigateToRow({
119
138
  row: row
120
139
  });
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAWM,MAAM;IAmBX;;GAEC,GACD,mBAAmB,IAAiC,EAAQ;QAC1D,IAAI,CAAC,gBAAgB,GAAG;IAC1B;IAEA;;GAEC,GACD,QAAQ,IAAuC,EAAe;QAC5D,IAAI,kBACF,cAAc,EACf,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esContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {act, within} from '@testing-library/react';\nimport {BaseGridRowInteractionOpts, GridRowActionOpts, ToggleGridRowOpts, TreeTesterOpts, UserOpts} from './types';\nimport {pressElement, triggerLongPress} from './events';\n\ninterface TreeToggleExpansionOpts extends BaseGridRowInteractionOpts {}\ninterface TreeToggleRowOpts extends ToggleGridRowOpts {}\ninterface TreeRowActionOpts extends GridRowActionOpts {}\n\n// TODO: this ended up being pretty much the same as gridlist, refactor so it extends from gridlist\nexport class TreeTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _advanceTimer: UserOpts['advanceTimer'];\n private _tree: HTMLElement;\n\n constructor(opts: TreeTesterOpts) {\n let {root, user, interactionType, advanceTimer} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n this._advanceTimer = advanceTimer;\n this._tree = root;\n // TODO: should all helpers do this?\n let tree = within(root).queryByRole('treegrid');\n if (root.getAttribute('role') !== 'treegrid' && tree) {\n this._tree = tree;\n }\n }\n\n /**\n * Set the interaction type used by the tree tester.\n */\n setInteractionType(type: UserOpts['interactionType']): void {\n this._interactionType = type;\n };\n\n /**\n * Returns a row matching the specified index or text content.\n */\n findRow(opts: {rowIndexOrText: number | string}): HTMLElement {\n let {\n rowIndexOrText\n } = opts;\n\n let row;\n if (typeof rowIndexOrText === 'number') {\n row = this.rows[rowIndexOrText];\n } else if (typeof rowIndexOrText === 'string') {\n row = (within(this.tree!).getByText(rowIndexOrText).closest('[role=row]'))! as HTMLElement;\n }\n\n return row;\n }\n\n // TODO: RTL\n private async keyboardNavigateToRow(opts: {row: HTMLElement}) {\n let {row} = opts;\n let rows = this.rows;\n let targetIndex = rows.indexOf(row);\n if (targetIndex === -1) {\n throw new Error('Option provided is not in the tree');\n }\n\n if (document.activeElement !== this._tree || !this._tree.contains(document.activeElement)) {\n act(() => this._tree.focus());\n }\n\n if (document.activeElement === this.tree) {\n await this.user.keyboard('[ArrowDown]');\n } else if (this._tree.contains(document.activeElement) && document.activeElement!.getAttribute('role') !== 'row') {\n do {\n await this.user.keyboard('[ArrowLeft]');\n } while (document.activeElement!.getAttribute('role') !== 'row');\n }\n let currIndex = rows.indexOf(document.activeElement as HTMLElement);\n if (currIndex === -1) {\n throw new Error('ActiveElement is not in the tree');\n }\n let direction = targetIndex > currIndex ? 'down' : 'up';\n\n for (let i = 0; i < Math.abs(targetIndex - currIndex); i++) {\n await this.user.keyboard(`[${direction === 'down' ? 'ArrowDown' : 'ArrowUp'}]`);\n }\n };\n\n /**\n * Toggles the selection for the specified tree row. Defaults to using the interaction type set on the tree tester.\n */\n async toggleRowSelection(opts: TreeToggleRowOpts): Promise<void> {\n let {\n row,\n needsLongPress,\n checkboxSelection = true,\n interactionType = this._interactionType\n } = opts;\n\n if (typeof row === 'string' || typeof row === 'number') {\n row = this.findRow({rowIndexOrText: row});\n }\n\n if (!row) {\n throw new Error('Target row not found in the tree.');\n }\n\n let rowCheckbox = within(row).queryByRole('checkbox');\n\n // TODO: we early return here because the checkbox can't be keyboard navigated to if the row is disabled usually\n // but we may to check for disabledBehavior (aka if the disable row gets skipped when keyboard navigating or not)\n if (interactionType === 'keyboard' && (rowCheckbox?.getAttribute('disabled') === '' || row?.getAttribute('aria-disabled') === 'true')) {\n return;\n }\n\n // this would be better than the check to do nothing in events.ts\n // also, it'd be good to be able to trigger selection on the row instead of having to go to the checkbox directly\n if (interactionType === 'keyboard' && !checkboxSelection) {\n await this.keyboardNavigateToRow({row});\n await this.user.keyboard('{Space}');\n return;\n }\n if (rowCheckbox && checkboxSelection) {\n await pressElement(this.user, rowCheckbox, interactionType);\n } else {\n let cell = within(row).getAllByRole('gridcell')[0];\n if (needsLongPress && interactionType === 'touch') {\n if (this._advanceTimer == null) {\n throw new Error('No advanceTimers provided for long press.');\n }\n\n // Note that long press interactions with rows is strictly touch only for grid rows\n await triggerLongPress({element: cell, advanceTimer: this._advanceTimer, pointerOpts: {pointerType: 'touch'}});\n } else {\n await pressElement(this.user, cell, interactionType);\n }\n }\n };\n\n /**\n * Toggles the expansion for the specified tree row. Defaults to using the interaction type set on the tree tester.\n */\n async toggleRowExpansion(opts: TreeToggleExpansionOpts): Promise<void> {\n let {\n row,\n interactionType = this._interactionType\n } = opts;\n if (!this.tree.contains(document.activeElement)) {\n await act(async () => {\n this.tree.focus();\n });\n }\n\n if (typeof row === 'string' || typeof row === 'number') {\n row = this.findRow({rowIndexOrText: row});\n }\n\n if (!row) {\n throw new Error('Target row not found in the tree.');\n } else if (row.getAttribute('aria-expanded') == null) {\n throw new Error('Target row is not expandable.');\n }\n\n if (interactionType === 'mouse' || interactionType === 'touch') {\n let rowExpander = within(row).getAllByRole('button')[0]; // what happens if the button is not first? how can we differentiate?\n await pressElement(this.user, rowExpander, interactionType);\n } else if (interactionType === 'keyboard') {\n if (row?.getAttribute('aria-disabled') === 'true') {\n return;\n }\n\n await this.keyboardNavigateToRow({row});\n if (row.getAttribute('aria-expanded') === 'true') {\n await this.user.keyboard('[ArrowLeft]');\n } else {\n await this.user.keyboard('[ArrowRight]');\n }\n }\n };\n\n /**\n * Triggers the action for the specified tree row. Defaults to using the interaction type set on the tree tester.\n */\n async triggerRowAction(opts: TreeRowActionOpts): Promise<void> {\n let {\n row,\n needsDoubleClick,\n interactionType = this._interactionType\n } = opts;\n\n if (typeof row === 'string' || typeof row === 'number') {\n row = this.findRow({rowIndexOrText: row});\n }\n\n if (!row) {\n throw new Error('Target row not found in the tree.');\n }\n\n if (needsDoubleClick) {\n await this.user.dblClick(row);\n } else if (interactionType === 'keyboard') {\n if (row?.getAttribute('aria-disabled') === 'true') {\n return;\n }\n\n await this.keyboardNavigateToRow({row});\n await this.user.keyboard('[Enter]');\n } else {\n await pressElement(this.user, row, interactionType);\n }\n };\n\n /**\n * Returns the tree.\n */\n get tree(): HTMLElement {\n return this._tree;\n }\n\n /**\n * Returns the tree's rows if any.\n */\n get rows(): HTMLElement[] {\n return within(this?.tree).queryAllByRole('row');\n }\n\n /**\n * Returns the tree's selected rows if any.\n */\n get selectedRows(): HTMLElement[] {\n return this.rows.filter(row => row.getAttribute('aria-selected') === 'true');\n }\n\n /**\n * Returns the tree's cells if any. Can be filtered against a specific row if provided via `element`.\n */\n cells(opts: {element?: HTMLElement} = {}): HTMLElement[] {\n let {element = this.tree} = opts;\n return within(element).queryAllByRole('gridcell');\n }\n}\n"],"names":[],"version":3,"file":"tree.module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAWM,MAAM;IAmBX;;GAEC,GACD,mBAAmB,IAAiC,EAAQ;QAC1D,IAAI,CAAC,gBAAgB,GAAG;IAC1B;IAEA;;GAEC,GACD,QAAQ,IAAuC,EAAe;QAC5D,IAAI,kBACF,cAAc,EACf,GAAG;QAEJ,IAAI;QACJ,IAAI,OAAO,mBAAmB,UAC5B,MAAM,IAAI,CAAC,IAAI,CAAC,eAAe;aAC1B,IAAI,OAAO,mBAAmB,UACnC,MAAO,CAAA,GAAA,aAAK,EAAE,IAAI,CAAC,IAAI,EAAG,SAAS,CAAC,gBAAgB,OAAO,CAAC;QAG9D,OAAO;IACT;IAEA,YAAY;IACZ,MAAc,sBAAsB,IAA6D,EAAE;QACjG,IAAI,OAAC,GAAG,kBAAE,iBAAiB,WAAU,GAAG;QACxC,IAAI,SAAS,CAAA,GAAA,yCAAQ;QACrB,IAAI,OAAO,IAAI,CAAC,IAAI;QACpB,IAAI,cAAc,KAAK,OAAO,CAAC;QAC/B,IAAI,gBAAgB,IAClB,MAAM,IAAI,MAAM;QAGlB,IAAI,SAAS,aAAa,KAAK,IAAI,CAA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AqB;IACvE;IAEA;;GAEC,GACD,MAAM,OAAgC,CAAC,CAAC,EAAiB;QACvD,IAAI,WAAC,UAAU,IAAI,CAAC,IAAI,EAAC,GAAG;QAC5B,OAAO,CAAA,GAAA,aAAK,EAAE,SAAS,cAAc,CAAC;IACxC;IA1PA,YAAY,IAAoB,CAAE;QAChC,IAAI,QAAC,IAAI,QAAE,IAAI,mBAAE,eAAe,gBAAE,YAAY,EAAC,GAAG;QAClD,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,gBAAgB,GAAG,mBAAmB;QAC3C,IAAI,CAAC,aAAa,GAAG;QACrB,IAAI,CAAC,KAAK,GAAG;QACb,oCAAoC;QACpC,IAAI,OAAO,CAAA,GAAA,aAAK,EAAE,MAAM,WAAW,CAAC;QACpC,IAAI,KAAK,YAAY,CAAC,YAAY,cAAc,MAC9C,IAAI,CAAC,KAAK,GAAG;IAEjB;AAgPF","sources":["packages/@react-aria/test-utils/src/tree.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {act, within} from '@testing-library/react';\nimport {BaseGridRowInteractionOpts, GridRowActionOpts, ToggleGridRowOpts, TreeTesterOpts, UserOpts} from './types';\nimport {getAltKey, getMetaKey, pressElement, triggerLongPress} from './events';\n\ninterface TreeToggleExpansionOpts extends BaseGridRowInteractionOpts {}\ninterface TreeToggleRowOpts extends ToggleGridRowOpts {}\ninterface TreeRowActionOpts extends GridRowActionOpts {}\n\n// TODO: this ended up being pretty much the same as gridlist, refactor so it extends from gridlist\nexport class TreeTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _advanceTimer: UserOpts['advanceTimer'];\n private _tree: HTMLElement;\n\n constructor(opts: TreeTesterOpts) {\n let {root, user, interactionType, advanceTimer} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n this._advanceTimer = advanceTimer;\n this._tree = root;\n // TODO: should all helpers do this?\n let tree = within(root).queryByRole('treegrid');\n if (root.getAttribute('role') !== 'treegrid' && tree) {\n this._tree = tree;\n }\n }\n\n /**\n * Set the interaction type used by the tree tester.\n */\n setInteractionType(type: UserOpts['interactionType']): void {\n this._interactionType = type;\n };\n\n /**\n * Returns a row matching the specified index or text content.\n */\n findRow(opts: {rowIndexOrText: number | string}): HTMLElement {\n let {\n rowIndexOrText\n } = opts;\n\n let row;\n if (typeof rowIndexOrText === 'number') {\n row = this.rows[rowIndexOrText];\n } else if (typeof rowIndexOrText === 'string') {\n row = (within(this.tree!).getByText(rowIndexOrText).closest('[role=row]'))! as HTMLElement;\n }\n\n return row;\n }\n\n // TODO: RTL\n private async keyboardNavigateToRow(opts: {row: HTMLElement, selectionOnNav?: 'default' | 'none'}) {\n let {row, selectionOnNav = 'default'} = opts;\n let altKey = getAltKey();\n let rows = this.rows;\n let targetIndex = rows.indexOf(row);\n if (targetIndex === -1) {\n throw new Error('Option provided is not in the tree');\n }\n\n if (document.activeElement !== this._tree && !this._tree.contains(document.activeElement)) {\n act(() => this._tree.focus());\n }\n\n if (document.activeElement === this.tree) {\n await this.user.keyboard(`${selectionOnNav === 'none' ? `[${altKey}>]` : ''}[ArrowDown]${selectionOnNav === 'none' ? `[/${altKey}]` : ''}`);\n } else if (this._tree.contains(document.activeElement) && document.activeElement!.getAttribute('role') !== 'row') {\n do {\n await this.user.keyboard('[ArrowLeft]');\n } while (document.activeElement!.getAttribute('role') !== 'row');\n }\n let currIndex = rows.indexOf(document.activeElement as HTMLElement);\n if (currIndex === -1) {\n throw new Error('ActiveElement is not in the tree');\n }\n let direction = targetIndex > currIndex ? 'down' : 'up';\n\n if (selectionOnNav === 'none') {\n await this.user.keyboard(`[${altKey}>]`);\n }\n for (let i = 0; i < Math.abs(targetIndex - currIndex); i++) {\n await this.user.keyboard(`[${direction === 'down' ? 'ArrowDown' : 'ArrowUp'}]`);\n }\n if (selectionOnNav === 'none') {\n await this.user.keyboard(`[/${altKey}]`);\n }\n };\n\n /**\n * Toggles the selection for the specified tree row. Defaults to using the interaction type set on the tree tester.\n * Note that this will endevor to always add/remove JUST the provided row to the set of selected rows.\n */\n async toggleRowSelection(opts: TreeToggleRowOpts): Promise<void> {\n let {\n row,\n needsLongPress,\n checkboxSelection = true,\n interactionType = this._interactionType,\n selectionBehavior = 'toggle'\n } = opts;\n\n let altKey = getAltKey();\n let metaKey = getMetaKey();\n\n if (typeof row === 'string' || typeof row === 'number') {\n row = this.findRow({rowIndexOrText: row});\n }\n\n if (!row) {\n throw new Error('Target row not found in the tree.');\n }\n\n let rowCheckbox = within(row).queryByRole('checkbox');\n\n // TODO: we early return here because the checkbox can't be keyboard navigated to if the row is disabled usually\n // but we may to check for disabledBehavior (aka if the disable row gets skipped when keyboard navigating or not)\n if (interactionType === 'keyboard' && (rowCheckbox?.getAttribute('disabled') === '' || row?.getAttribute('aria-disabled') === 'true')) {\n return;\n }\n\n // this would be better than the check to do nothing in events.ts\n // also, it'd be good to be able to trigger selection on the row instead of having to go to the checkbox directly\n if (interactionType === 'keyboard' && (!checkboxSelection || !rowCheckbox)) {\n await this.keyboardNavigateToRow({row, selectionOnNav: selectionBehavior === 'replace' ? 'none' : 'default'});\n if (selectionBehavior === 'replace') {\n await this.user.keyboard(`[${altKey}>]`);\n }\n await this.user.keyboard('[Space]');\n if (selectionBehavior === 'replace') {\n await this.user.keyboard(`[/${altKey}]`);\n }\n return;\n }\n if (rowCheckbox && checkboxSelection) {\n await pressElement(this.user, rowCheckbox, interactionType);\n } else {\n let cell = within(row).getAllByRole('gridcell')[0];\n if (needsLongPress && interactionType === 'touch') {\n if (this._advanceTimer == null) {\n throw new Error('No advanceTimers provided for long press.');\n }\n\n // Note that long press interactions with rows is strictly touch only for grid rows\n await triggerLongPress({element: cell, advanceTimer: this._advanceTimer, pointerOpts: {pointerType: 'touch'}});\n } else {\n // TODO add modifiers here? Maybe move into pressElement if we get more cases for different types of modifier keys\n if (selectionBehavior === 'replace' && interactionType !== 'touch') {\n await this.user.keyboard(`[${metaKey}>]`);\n }\n await pressElement(this.user, row, interactionType);\n if (selectionBehavior === 'replace' && interactionType !== 'touch') {\n await this.user.keyboard(`[/${metaKey}]`);\n }\n }\n }\n };\n\n /**\n * Toggles the expansion for the specified tree row. Defaults to using the interaction type set on the tree tester.\n */\n async toggleRowExpansion(opts: TreeToggleExpansionOpts): Promise<void> {\n let {\n row,\n interactionType = this._interactionType\n } = opts;\n if (!this.tree.contains(document.activeElement)) {\n await act(async () => {\n this.tree.focus();\n });\n }\n\n if (typeof row === 'string' || typeof row === 'number') {\n row = this.findRow({rowIndexOrText: row});\n }\n\n if (!row) {\n throw new Error('Target row not found in the tree.');\n } else if (row.getAttribute('aria-expanded') == null) {\n throw new Error('Target row is not expandable.');\n }\n\n if (interactionType === 'mouse' || interactionType === 'touch') {\n let rowExpander = within(row).getAllByRole('button')[0]; // what happens if the button is not first? how can we differentiate?\n await pressElement(this.user, rowExpander, interactionType);\n } else if (interactionType === 'keyboard') {\n if (row?.getAttribute('aria-disabled') === 'true') {\n return;\n }\n\n // TODO: We always Use Option/Ctrl when keyboard navigating so selection isn't changed\n // in selectionmode=\"replace\"/highlight selection when navigating to the row that the user wants\n // to expand. Discuss if this is useful or not\n await this.keyboardNavigateToRow({row});\n if (row.getAttribute('aria-expanded') === 'true') {\n await this.user.keyboard('[ArrowLeft]');\n } else {\n await this.user.keyboard('[ArrowRight]');\n }\n }\n };\n\n /**\n * Triggers the action for the specified tree row. Defaults to using the interaction type set on the tree tester.\n */\n async triggerRowAction(opts: TreeRowActionOpts): Promise<void> {\n let {\n row,\n needsDoubleClick,\n interactionType = this._interactionType\n } = opts;\n\n if (typeof row === 'string' || typeof row === 'number') {\n row = this.findRow({rowIndexOrText: row});\n }\n\n if (!row) {\n throw new Error('Target row not found in the tree.');\n }\n\n if (needsDoubleClick) {\n await this.user.dblClick(row);\n } else if (interactionType === 'keyboard') {\n if (row?.getAttribute('aria-disabled') === 'true') {\n return;\n }\n\n // TODO: same as above, uses the modifier key to make sure we don't modify selection state on row focus\n // as we keyboard navigate to the row we want activate\n await this.keyboardNavigateToRow({row});\n await this.user.keyboard('[Enter]');\n } else {\n await pressElement(this.user, row, interactionType);\n }\n };\n\n /**\n * Returns the tree.\n */\n get tree(): HTMLElement {\n return this._tree;\n }\n\n /**\n * Returns the tree's rows if any.\n */\n get rows(): HTMLElement[] {\n return within(this?.tree).queryAllByRole('row');\n }\n\n /**\n * Returns the tree's selected rows if any.\n */\n get selectedRows(): HTMLElement[] {\n return this.rows.filter(row => row.getAttribute('aria-selected') === 'true');\n }\n\n /**\n * Returns the tree's cells if any. Can be filtered against a specific row if provided via `element`.\n */\n cells(opts: {element?: HTMLElement} = {}): HTMLElement[] {\n let {element = this.tree} = opts;\n return within(element).queryAllByRole('gridcell');\n }\n}\n"],"names":[],"version":3,"file":"tree.module.js.map"}
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { pointerKey } from "@testing-library/user-event/system/pointer/shared";
1
+ import { pointerKey } from "@testing-library/user-event";
2
2
  type Direction = 'ltr' | 'rtl';
3
3
  export interface UserOpts {
4
4
  /**
@@ -99,6 +99,15 @@ interface ToggleGridRowOpts extends BaseGridRowInteractionOpts {
99
99
  * @default 'true'
100
100
  */
101
101
  checkboxSelection?: boolean;
102
+ /**
103
+ * Whether the grid has a selectionBehavior of "toggle" or "replace" (aka highlight selection). This affects the user operations
104
+ * required to toggle row selection by adding modifier keys during user actions, useful when performing multi-row selection in a "selectionBehavior: 'replace'" grid.
105
+ * If you would like to still simulate user actions (aka press) without these modifiers keys for a "selectionBehavior: replace" grid, simply omit this option.
106
+ * See the "Selection Behavior" section of the appropriate React Aria Component docs for more information (e.g. https://react-spectrum.adobe.com/react-aria/Tree.html#selection-behavior).
107
+ *
108
+ * @default 'toggle'
109
+ */
110
+ selectionBehavior?: 'toggle' | 'replace';
102
111
  }
103
112
  interface GridRowActionOpts extends BaseGridRowInteractionOpts {
104
113
  /**
@@ -211,6 +220,7 @@ declare class GridListTester {
211
220
  }): HTMLElement;
212
221
  /**
213
222
  * Toggles the selection for the specified gridlist row. Defaults to using the interaction type set on the gridlist tester.
223
+ * Note that this will endevor to always add/remove JUST the provided row to the set of selected rows.
214
224
  */
215
225
  toggleRowSelection(opts: GridListToggleRowOpts): Promise<void>;
216
226
  /**
@@ -254,6 +264,15 @@ interface ListBoxToggleOptionOpts {
254
264
  * Whether the option needs to be long pressed to be selected. Depends on the listbox's implementation.
255
265
  */
256
266
  needsLongPress?: boolean;
267
+ /**
268
+ * Whether the listbox has a selectionBehavior of "toggle" or "replace" (aka highlight selection). This affects the user operations
269
+ * required to toggle option selection by adding modifier keys during user actions, useful when performing multi-option selection in a "selectionBehavior: 'replace'" listbox.
270
+ * If you would like to still simulate user actions (aka press) without these modifiers keys for a "selectionBehavior: replace" listbox, simply omit this option.
271
+ * See the [RAC Listbox docs](https://react-spectrum.adobe.com/react-aria/ListBox.html#selection-behavior) for more info on this behavior.
272
+ *
273
+ * @default 'toggle'
274
+ */
275
+ selectionBehavior?: 'toggle' | 'replace';
257
276
  }
258
277
  interface ListBoxOptionActionOpts extends Omit<ListBoxToggleOptionOpts, 'keyboardActivation' | 'needsLongPress'> {
259
278
  /**
@@ -611,6 +630,7 @@ declare class TreeTester {
611
630
  }): HTMLElement;
612
631
  /**
613
632
  * Toggles the selection for the specified tree row. Defaults to using the interaction type set on the tree tester.
633
+ * Note that this will endevor to always add/remove JUST the provided row to the set of selected rows.
614
634
  */
615
635
  toggleRowSelection(opts: TreeToggleRowOpts): Promise<void>;
616
636
  /**
@@ -1 +1 @@
1
- {"mappings":";AAaA,iBAAwB,KAAK,GAAG,KAAK,CA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,cAAc,CAAC,CAAC;gBAE3B,IAAI,GAAE,QAAa;IAO/B;;OAEG;IACH,YAAY,CAAC,CAAC,SAAS,YAAY,EAAE,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC;CAGrF","sources":["packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/types.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/events.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/testSetup.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/userEventMaps.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/combobox.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/gridlist.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/listbox.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/menu.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/select.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/table.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/tabs.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/tree.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/user.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/index.ts","packages/@react-aria/test-utils/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,"/*\n * Copyright 2023 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {triggerLongPress} from './events';\nexport {installMouseEvent, installPointerEvent} from './testSetup';\nexport {pointerMap} from './userEventMaps';\nexport {User} from './user';\n\nexport type {UserOpts} from './types';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";AAaA,iBAAwB,KAAK,GAAG,KAAK,CAAC;AAItC;IACE;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,UAAU,CAAC;IAIjD;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CAC5D;AAED,wBAAgC,SAAQ,QAAQ;IAC9C,eAAe;IACf,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,wFAAwF;IACxF,IAAI,EAAE,WAAW,CAAA;CAClB;AAED,4BAAoC,SAAQ,cAAc;IACxD;;;OAGG;IACH,IAAI,EAAE,WAAW,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,CAAA;CACtB;AAED,4BAAoC,SAAQ,cAAc;CAAG;AAE7D,2BAAmC,SAAQ,cAAc;IACvD;;OAEG;IACH,YAAY,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAA;CACxC;AAED,wBAAgC,SAAQ,cAAc;IACpD;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,WAAW,CAAA;CACvB;AAED,0BAAkC,SAAQ,cAAc;IACtD;;;OAGG;IACH,IAAI,EAAE,WAAW,CAAA;CAClB;AAED,yBAAiC,SAAQ,cAAc;IACrD;;OAEG;IACH,YAAY,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAA;CACxC;AAED,wBAAgC,SAAQ,cAAc;IACpD;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB;AAED,wBAAgC,SAAQ,cAAc;IACpD;;OAEG;IACH,YAAY,CAAC,E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S,MAAM,GAAG,cAAc,GACjC,CAAC,SAAS,QAAQ,GAAG,gBAAgB,GACrC,CAAC,SAAS,OAAO,GAAG,eAAe,GACnC,CAAC,SAAS,MAAM,GAAG,cAAc,GACjC,CAAC,SAAS,MAAM,GAAG,cAAc,GACjC,KAAK,CAAC;AAIR;IAEE;;;;OAIG;IACH,eAAe,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAC7C;;OAEG;IACH,YAAY,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC;gBAE3B,IAAI,GAAE,QAAa;IAO/B;;OAEG;IACH,YAAY,CAAC,CAAC,SAAS,YAAY,EAAE,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC;CAGrF","sources":["packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/types.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/events.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/testSetup.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/userEventMaps.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/combobox.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/gridlist.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/listbox.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/menu.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/select.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/table.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/tabs.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/tree.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/user.ts","packages/@react-aria/test-utils/src/packages/@react-aria/test-utils/src/index.ts","packages/@react-aria/test-utils/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,"/*\n * Copyright 2023 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {triggerLongPress} from './events';\nexport {installMouseEvent, installPointerEvent} from './testSetup';\nexport {pointerMap} from './userEventMaps';\nexport {User} from './user';\n\nexport type {UserOpts} from './types';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;AAEO,IAAI,4CAA2B;IACpC;QAAC,MAAM;QAAa,aAAa;QAAS,QAAQ;QAAW,QAAQ;QAAG,OAAO;QAAG,UAAU;IAAG;IAC/F;QAAC,MAAM;QAAc,aAAa;QAAS,QAAQ;IAAW;IAC9D;QAAC,MAAM;QAAe,aAAa;QAAS,QAAQ;IAAW;IAC/D;QAAC,MAAM;QAAU,aAAa;QAAS,QAAQ;QAAG,OAAO;IAAC;IAC1D;QAAC,MAAM;QAAU,aAAa;IAAO;IACrC;QAAC,MAAM;QAAU,aAAa;IAAO;CACtC","sources":["packages/@react-aria/test-utils/src/userEventMaps.ts"],"sourcesContent":["import {pointerKey} from '@testing-library/user-event/system/pointer/shared';\n\nexport let pointerMap: pointerKey[] = [\n {name: 'MouseLeft', pointerType: 'mouse', button: 'primary', height: 1, width: 1, pressure: 0.5},\n {name: 'MouseRight', pointerType: 'mouse', button: 'secondary'},\n {name: 'MouseMiddle', pointerType: 'mouse', button: 'auxiliary'},\n {name: 'TouchA', pointerType: 'touch', height: 1, width: 1},\n {name: 'TouchB', pointerType: 'touch'},\n {name: 'TouchC', pointerType: 'touch'}\n] as unknown as pointerKey[];\n"],"names":[],"version":3,"file":"userEventMaps.main.js.map"}
1
+ {"mappings":";;;;;;AAEO,IAAI,4CAA2B;IACpC;QAAC,MAAM;QAAa,aAAa;QAAS,QAAQ;QAAW,QAAQ;QAAG,OAAO;QAAG,UAAU;IAAG;IAC/F;QAAC,MAAM;QAAc,aAAa;QAAS,QAAQ;IAAW;IAC9D;QAAC,MAAM;QAAe,aAAa;QAAS,QAAQ;IAAW;IAC/D;QAAC,MAAM;QAAU,aAAa;QAAS,QAAQ;QAAG,OAAO;IAAC;IAC1D;QAAC,MAAM;QAAU,aAAa;IAAO;IACrC;QAAC,MAAM;QAAU,aAAa;IAAO;CACtC","sources":["packages/@react-aria/test-utils/src/userEventMaps.ts"],"sourcesContent":["import {pointerKey} from '@testing-library/user-event';\n\nexport let pointerMap: pointerKey[] = [\n {name: 'MouseLeft', pointerType: 'mouse', button: 'primary', height: 1, width: 1, pressure: 0.5},\n {name: 'MouseRight', pointerType: 'mouse', button: 'secondary'},\n {name: 'MouseMiddle', pointerType: 'mouse', button: 'auxiliary'},\n {name: 'TouchA', pointerType: 'touch', height: 1, width: 1},\n {name: 'TouchB', pointerType: 'touch'},\n {name: 'TouchC', pointerType: 'touch'}\n] as unknown as pointerKey[];\n"],"names":[],"version":3,"file":"userEventMaps.main.js.map"}
@@ -1 +1 @@
1
- {"mappings":"AAEO,IAAI,4CAA2B;IACpC;QAAC,MAAM;QAAa,aAAa;QAAS,QAAQ;QAAW,QAAQ;QAAG,OAAO;QAAG,UAAU;IAAG;IAC/F;QAAC,MAAM;QAAc,aAAa;QAAS,QAAQ;IAAW;IAC9D;QAAC,MAAM;QAAe,aAAa;QAAS,QAAQ;IAAW;IAC/D;QAAC,MAAM;QAAU,aAAa;QAAS,QAAQ;QAAG,OAAO;IAAC;IAC1D;QAAC,MAAM;QAAU,aAAa;IAAO;IACrC;QAAC,MAAM;QAAU,aAAa;IAAO;CACtC","sources":["packages/@react-aria/test-utils/src/userEventMaps.ts"],"sourcesContent":["import {pointerKey} from '@testing-library/user-event/system/pointer/shared';\n\nexport let pointerMap: pointerKey[] = [\n {name: 'MouseLeft', pointerType: 'mouse', button: 'primary', height: 1, width: 1, pressure: 0.5},\n {name: 'MouseRight', pointerType: 'mouse', button: 'secondary'},\n {name: 'MouseMiddle', pointerType: 'mouse', button: 'auxiliary'},\n {name: 'TouchA', pointerType: 'touch', height: 1, width: 1},\n {name: 'TouchB', pointerType: 'touch'},\n {name: 'TouchC', pointerType: 'touch'}\n] as unknown as pointerKey[];\n"],"names":[],"version":3,"file":"userEventMaps.module.js.map"}
1
+ {"mappings":"AAEO,IAAI,4CAA2B;IACpC;QAAC,MAAM;QAAa,aAAa;QAAS,QAAQ;QAAW,QAAQ;QAAG,OAAO;QAAG,UAAU;IAAG;IAC/F;QAAC,MAAM;QAAc,aAAa;QAAS,QAAQ;IAAW;IAC9D;QAAC,MAAM;QAAe,aAAa;QAAS,QAAQ;IAAW;IAC/D;QAAC,MAAM;QAAU,aAAa;QAAS,QAAQ;QAAG,OAAO;IAAC;IAC1D;QAAC,MAAM;QAAU,aAAa;IAAO;IACrC;QAAC,MAAM;QAAU,aAAa;IAAO;CACtC","sources":["packages/@react-aria/test-utils/src/userEventMaps.ts"],"sourcesContent":["import {pointerKey} from '@testing-library/user-event';\n\nexport let pointerMap: pointerKey[] = [\n {name: 'MouseLeft', pointerType: 'mouse', button: 'primary', height: 1, width: 1, pressure: 0.5},\n {name: 'MouseRight', pointerType: 'mouse', button: 'secondary'},\n {name: 'MouseMiddle', pointerType: 'mouse', button: 'auxiliary'},\n {name: 'TouchA', pointerType: 'touch', height: 1, width: 1},\n {name: 'TouchB', pointerType: 'touch'},\n {name: 'TouchC', pointerType: 'touch'}\n] as unknown as pointerKey[];\n"],"names":[],"version":3,"file":"userEventMaps.module.js.map"}
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@react-aria/test-utils",
3
- "version": "1.0.0-alpha.7",
3
+ "version": "1.0.0-alpha.8",
4
4
  "description": "Testing utils for react-aria patterns",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
8
  "exports": {
9
- "types": "./dist/types.d.ts",
9
+ "source": "./src/index.ts",
10
+ "types": [
11
+ "./dist/types.d.ts",
12
+ "./src/index.ts"
13
+ ],
10
14
  "import": "./dist/import.mjs",
11
15
  "require": "./dist/main.js"
12
16
  },
@@ -33,5 +37,5 @@
33
37
  "publishConfig": {
34
38
  "access": "public"
35
39
  },
36
- "gitHead": "9c77d4e8267ed39469c65f65da94ece7be509874"
40
+ "gitHead": "265b4d7f107905ee1c6e87a8af1613ab440a6849"
37
41
  }
package/src/combobox.ts CHANGED
@@ -55,14 +55,17 @@ export class ComboBoxTester {
55
55
  if (trigger) {
56
56
  this._trigger = trigger;
57
57
  } else {
58
- let trigger = within(root).queryByRole('button', {hidden: true});
59
- if (trigger) {
60
- this._trigger = trigger;
61
- } else {
62
- // For cases like https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/ where the combobox
63
- // is also the trigger button
64
- this._trigger = this._combobox;
58
+ let buttons = within(root).queryAllByRole('button', {hidden: true});
59
+
60
+ if (buttons.length === 1) {
61
+ trigger = buttons[0];
62
+ } else if (buttons.length > 1) {
63
+ trigger = buttons.find(button => button.hasAttribute('aria-haspopup'));
65
64
  }
65
+
66
+ // For cases like https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/ where the combobox
67
+ // is also the trigger button
68
+ this._trigger = trigger || this._combobox;
66
69
  }
67
70
  }
68
71