@react-aria/test-utils 1.0.0-beta.1 → 1.0.0-beta.3

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 (133) hide show
  1. package/dist/import.mjs +5 -5
  2. package/dist/main.js +9 -9
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +5 -5
  5. package/dist/module.js.map +1 -1
  6. package/dist/private/checkboxgroup.cjs +104 -0
  7. package/dist/private/checkboxgroup.cjs.map +1 -0
  8. package/dist/private/checkboxgroup.js +99 -0
  9. package/dist/private/checkboxgroup.js.map +1 -0
  10. package/dist/{combobox.main.js → private/combobox.cjs} +35 -35
  11. package/dist/private/combobox.cjs.map +1 -0
  12. package/dist/{combobox.mjs → private/combobox.js} +35 -35
  13. package/dist/private/combobox.js.map +1 -0
  14. package/dist/private/dialog.cjs +105 -0
  15. package/dist/private/dialog.cjs.map +1 -0
  16. package/dist/private/dialog.js +100 -0
  17. package/dist/private/dialog.js.map +1 -0
  18. package/dist/{events.main.js → private/events.cjs} +32 -34
  19. package/dist/private/events.cjs.map +1 -0
  20. package/dist/{events.mjs → private/events.js} +29 -31
  21. package/dist/private/events.js.map +1 -0
  22. package/dist/{gridlist.main.js → private/gridlist.cjs} +27 -28
  23. package/dist/private/gridlist.cjs.map +1 -0
  24. package/dist/{gridlist.mjs → private/gridlist.js} +27 -28
  25. package/dist/private/gridlist.js.map +1 -0
  26. package/dist/{listbox.main.js → private/listbox.cjs} +24 -24
  27. package/dist/private/listbox.cjs.map +1 -0
  28. package/dist/{listbox.mjs → private/listbox.js} +24 -24
  29. package/dist/private/listbox.js.map +1 -0
  30. package/dist/{menu.main.js → private/menu.cjs} +46 -48
  31. package/dist/private/menu.cjs.map +1 -0
  32. package/dist/{menu.mjs → private/menu.js} +46 -48
  33. package/dist/private/menu.js.map +1 -0
  34. package/dist/private/radiogroup.cjs +120 -0
  35. package/dist/private/radiogroup.cjs.map +1 -0
  36. package/dist/private/radiogroup.js +115 -0
  37. package/dist/private/radiogroup.js.map +1 -0
  38. package/dist/{select.main.js → private/select.cjs} +31 -29
  39. package/dist/private/select.cjs.map +1 -0
  40. package/dist/{select.mjs → private/select.js} +31 -29
  41. package/dist/private/select.js.map +1 -0
  42. package/dist/{table.main.js → private/table.cjs} +82 -57
  43. package/dist/private/table.cjs.map +1 -0
  44. package/dist/{table.module.js → private/table.js} +82 -57
  45. package/dist/private/table.js.map +1 -0
  46. package/dist/{tabs.main.js → private/tabs.cjs} +24 -26
  47. package/dist/private/tabs.cjs.map +1 -0
  48. package/dist/{tabs.mjs → private/tabs.js} +24 -26
  49. package/dist/private/tabs.js.map +1 -0
  50. package/dist/private/testSetup.cjs +87 -0
  51. package/dist/private/testSetup.cjs.map +1 -0
  52. package/dist/private/testSetup.js +81 -0
  53. package/dist/private/testSetup.js.map +1 -0
  54. package/dist/{tree.main.js → private/tree.cjs} +34 -35
  55. package/dist/private/tree.cjs.map +1 -0
  56. package/dist/{tree.mjs → private/tree.js} +34 -35
  57. package/dist/private/tree.js.map +1 -0
  58. package/dist/private/user.cjs +85 -0
  59. package/dist/private/user.cjs.map +1 -0
  60. package/dist/private/user.js +76 -0
  61. package/dist/private/user.js.map +1 -0
  62. package/dist/{userEventMaps.main.js → private/userEventMaps.cjs} +3 -3
  63. package/dist/{userEventMaps.main.js.map → private/userEventMaps.cjs.map} +1 -1
  64. package/dist/{userEventMaps.mjs → private/userEventMaps.js} +3 -3
  65. package/dist/{userEventMaps.module.js.map → private/userEventMaps.js.map} +1 -1
  66. package/dist/types/src/checkboxgroup.d.ts +45 -0
  67. package/dist/types/src/combobox.d.ts +75 -0
  68. package/dist/types/src/dialog.d.ts +36 -0
  69. package/dist/types/src/events.d.ts +25 -0
  70. package/dist/types/src/gridlist.d.ts +51 -0
  71. package/dist/types/src/index.d.ts +16 -0
  72. package/dist/types/src/listbox.d.ts +80 -0
  73. package/dist/types/src/menu.d.ts +102 -0
  74. package/dist/types/src/radiogroup.d.ts +46 -0
  75. package/dist/types/src/select.d.ts +67 -0
  76. package/dist/types/src/table.d.ts +104 -0
  77. package/dist/types/src/tabs.d.ts +58 -0
  78. package/dist/types/src/testSetup.d.ts +6 -0
  79. package/dist/types/src/tree.d.ts +57 -0
  80. package/dist/types/src/types.d.ts +136 -0
  81. package/dist/types/src/user.d.ts +47 -0
  82. package/dist/types/src/userEventMaps.d.ts +2 -0
  83. package/package.json +7 -7
  84. package/src/checkboxgroup.ts +158 -0
  85. package/src/dialog.ts +143 -0
  86. package/src/index.ts +11 -0
  87. package/src/radiogroup.ts +176 -0
  88. package/src/select.ts +10 -2
  89. package/src/table.ts +46 -1
  90. package/src/tabs.ts +7 -2
  91. package/src/testSetup.ts +30 -28
  92. package/src/types.ts +21 -0
  93. package/src/user.ts +25 -7
  94. package/dist/combobox.main.js.map +0 -1
  95. package/dist/combobox.module.js +0 -167
  96. package/dist/combobox.module.js.map +0 -1
  97. package/dist/events.main.js.map +0 -1
  98. package/dist/events.module.js +0 -112
  99. package/dist/events.module.js.map +0 -1
  100. package/dist/gridlist.main.js.map +0 -1
  101. package/dist/gridlist.module.js +0 -149
  102. package/dist/gridlist.module.js.map +0 -1
  103. package/dist/listbox.main.js.map +0 -1
  104. package/dist/listbox.module.js +0 -138
  105. package/dist/listbox.module.js.map +0 -1
  106. package/dist/menu.main.js.map +0 -1
  107. package/dist/menu.module.js +0 -269
  108. package/dist/menu.module.js.map +0 -1
  109. package/dist/select.main.js.map +0 -1
  110. package/dist/select.module.js +0 -158
  111. package/dist/select.module.js.map +0 -1
  112. package/dist/table.main.js.map +0 -1
  113. package/dist/table.mjs +0 -290
  114. package/dist/table.module.js.map +0 -1
  115. package/dist/tabs.main.js.map +0 -1
  116. package/dist/tabs.module.js +0 -128
  117. package/dist/tabs.module.js.map +0 -1
  118. package/dist/testSetup.main.js +0 -78
  119. package/dist/testSetup.main.js.map +0 -1
  120. package/dist/testSetup.mjs +0 -72
  121. package/dist/testSetup.module.js +0 -72
  122. package/dist/testSetup.module.js.map +0 -1
  123. package/dist/tree.main.js.map +0 -1
  124. package/dist/tree.module.js +0 -179
  125. package/dist/tree.module.js.map +0 -1
  126. package/dist/types.d.ts +0 -694
  127. package/dist/types.d.ts.map +0 -1
  128. package/dist/user.main.js +0 -76
  129. package/dist/user.main.js.map +0 -1
  130. package/dist/user.mjs +0 -67
  131. package/dist/user.module.js +0 -67
  132. package/dist/user.module.js.map +0 -1
  133. package/dist/userEventMaps.module.js +0 -38
@@ -1,12 +1,12 @@
1
- var $5a8bfe1663b8366d$exports = require("./events.main.js");
2
- var $2auAU$testinglibraryreact = require("@testing-library/react");
1
+ var $01a4eeee86094c77$exports = require("./events.cjs");
2
+ var $kIP0K$testinglibraryreact = require("@testing-library/react");
3
3
 
4
4
 
5
5
  function $parcel$export(e, n, v, s) {
6
6
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
7
  }
8
8
 
9
- $parcel$export(module.exports, "TableTester", () => $80a9def682ac1297$export$4c6a9d6ae3b0086);
9
+ $parcel$export(module.exports, "TableTester", function () { return $b9d4e4f005cd9015$export$4c6a9d6ae3b0086; });
10
10
  /*
11
11
  * Copyright 2024 Adobe. All rights reserved.
12
12
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -19,7 +19,14 @@ $parcel$export(module.exports, "TableTester", () => $80a9def682ac1297$export$4c6
19
19
  * governing permissions and limitations under the License.
20
20
  */
21
21
 
22
- class $80a9def682ac1297$export$4c6a9d6ae3b0086 {
22
+ class $b9d4e4f005cd9015$export$4c6a9d6ae3b0086 {
23
+ constructor(opts){
24
+ let { root: root, user: user, interactionType: interactionType, advanceTimer: advanceTimer } = opts;
25
+ this.user = user;
26
+ this._interactionType = interactionType || 'mouse';
27
+ this._advanceTimer = advanceTimer;
28
+ this._table = root;
29
+ }
23
30
  /**
24
31
  * Set the interaction type used by the table tester.
25
32
  */ setInteractionType(type) {
@@ -28,12 +35,12 @@ class $80a9def682ac1297$export$4c6a9d6ae3b0086 {
28
35
  // TODO: RTL
29
36
  async keyboardNavigateToRow(opts) {
30
37
  let { row: row, selectionOnNav: selectionOnNav = 'default' } = opts;
31
- let altKey = (0, $5a8bfe1663b8366d$exports.getAltKey)();
38
+ let altKey = (0, $01a4eeee86094c77$exports.getAltKey)();
32
39
  let rows = this.rows;
33
40
  let targetIndex = rows.indexOf(row);
34
41
  if (targetIndex === -1) throw new Error('Row provided is not in the table');
35
42
  // Move focus into the table
36
- if (document.activeElement !== this._table && !this._table.contains(document.activeElement)) (0, $2auAU$testinglibraryreact.act)(()=>this._table.focus());
43
+ if (document.activeElement !== this._table && !this._table.contains(document.activeElement)) (0, $kIP0K$testinglibraryreact.act)(()=>this._table.focus());
37
44
  if (document.activeElement === this._table) await this.user.keyboard('[ArrowDown]');
38
45
  // If focus is currently somewhere in the first row group (aka on a column), we want to keyboard navigate downwards till we reach the rows
39
46
  if (this.rowGroups[0].contains(document.activeElement)) do await this.user.keyboard('[ArrowDown]');
@@ -52,13 +59,13 @@ class $80a9def682ac1297$export$4c6a9d6ae3b0086 {
52
59
  * Toggles the selection for the specified table row. Defaults to using the interaction type set on the table tester.
53
60
  */ async toggleRowSelection(opts) {
54
61
  let { row: row, needsLongPress: needsLongPress, checkboxSelection: checkboxSelection = true, interactionType: interactionType = this._interactionType, selectionBehavior: selectionBehavior = 'toggle' } = opts;
55
- let altKey = (0, $5a8bfe1663b8366d$exports.getMetaKey)();
56
- let metaKey = (0, $5a8bfe1663b8366d$exports.getMetaKey)();
62
+ let altKey = (0, $01a4eeee86094c77$exports.getMetaKey)();
63
+ let metaKey = (0, $01a4eeee86094c77$exports.getMetaKey)();
57
64
  if (typeof row === 'string' || typeof row === 'number') row = this.findRow({
58
65
  rowIndexOrText: row
59
66
  });
60
67
  if (!row) throw new Error('Target row not found in the table.');
61
- let rowCheckbox = (0, $2auAU$testinglibraryreact.within)(row).queryByRole('checkbox');
68
+ let rowCheckbox = (0, $kIP0K$testinglibraryreact.within)(row).queryByRole('checkbox');
62
69
  if (interactionType === 'keyboard' && (!checkboxSelection || !rowCheckbox)) {
63
70
  await this.keyboardNavigateToRow({
64
71
  row: row,
@@ -69,13 +76,13 @@ class $80a9def682ac1297$export$4c6a9d6ae3b0086 {
69
76
  if (selectionBehavior === 'replace') await this.user.keyboard(`[/${altKey}]`);
70
77
  return;
71
78
  }
72
- if (rowCheckbox && checkboxSelection) await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, rowCheckbox, interactionType);
79
+ if (rowCheckbox && checkboxSelection) await (0, $01a4eeee86094c77$exports.pressElement)(this.user, rowCheckbox, interactionType);
73
80
  else {
74
- let cell = (0, $2auAU$testinglibraryreact.within)(row).getAllByRole('gridcell')[0];
81
+ let cell = (0, $kIP0K$testinglibraryreact.within)(row).getAllByRole('gridcell')[0];
75
82
  if (needsLongPress && interactionType === 'touch') {
76
83
  if (this._advanceTimer == null) throw new Error('No advanceTimers provided for long press.');
77
84
  // Note that long press interactions with rows is strictly touch only for grid rows
78
- await (0, $5a8bfe1663b8366d$exports.triggerLongPress)({
85
+ await (0, $01a4eeee86094c77$exports.triggerLongPress)({
79
86
  element: cell,
80
87
  advanceTimer: this._advanceTimer,
81
88
  pointerOpts: {
@@ -84,44 +91,71 @@ class $80a9def682ac1297$export$4c6a9d6ae3b0086 {
84
91
  });
85
92
  } else {
86
93
  if (selectionBehavior === 'replace' && interactionType !== 'touch') await this.user.keyboard(`[${metaKey}>]`);
87
- await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, cell, interactionType);
94
+ await (0, $01a4eeee86094c77$exports.pressElement)(this.user, cell, interactionType);
88
95
  if (selectionBehavior === 'replace' && interactionType !== 'touch') await this.user.keyboard(`[/${metaKey}]`);
89
96
  }
90
97
  }
91
98
  }
92
99
  /**
100
+ * Toggles the expansion for the specified tree row. Defaults to using the interaction type set on the tree tester.
101
+ */ async toggleRowExpansion(opts) {
102
+ let { row: row, interactionType: interactionType = this._interactionType } = opts;
103
+ if (!this.table.contains(document.activeElement)) await (0, $kIP0K$testinglibraryreact.act)(async ()=>{
104
+ this.table.focus();
105
+ });
106
+ if (typeof row === 'string' || typeof row === 'number') row = this.findRow({
107
+ rowIndexOrText: row
108
+ });
109
+ if (!row) throw new Error('Target row not found in the table.');
110
+ else if (row.getAttribute('aria-expanded') == null) throw new Error('Target row is not expandable.');
111
+ if (interactionType === 'mouse' || interactionType === 'touch') {
112
+ let rowExpander = (0, $kIP0K$testinglibraryreact.within)(row).getAllByRole('button')[0]; // what happens if the button is not first? how can we differentiate?
113
+ await (0, $01a4eeee86094c77$exports.pressElement)(this.user, rowExpander, interactionType);
114
+ } else if (interactionType === 'keyboard') {
115
+ if (row?.getAttribute('aria-disabled') === 'true') return;
116
+ // TODO: We always Use Option/Ctrl when keyboard navigating so selection isn't changed
117
+ // in selectionmode="replace"/highlight selection when navigating to the row that the user wants
118
+ // to expand. Discuss if this is useful or not
119
+ await this.keyboardNavigateToRow({
120
+ row: row
121
+ });
122
+ if (row.getAttribute('aria-expanded') === 'true') await this.user.keyboard('[ArrowLeft]');
123
+ else await this.user.keyboard('[ArrowRight]');
124
+ }
125
+ }
126
+ /**
93
127
  * Toggles the sort order for the specified table column. Defaults to using the interaction type set on the table tester.
94
128
  */ async toggleSort(opts) {
95
129
  let { column: column, interactionType: interactionType = this._interactionType } = opts;
96
130
  let columnheader;
97
131
  if (typeof column === 'number') columnheader = this.columns[column];
98
132
  else if (typeof column === 'string') {
99
- columnheader = (0, $2auAU$testinglibraryreact.within)(this.rowGroups[0]).getByText(column);
133
+ columnheader = (0, $kIP0K$testinglibraryreact.within)(this.rowGroups[0]).getByText(column);
100
134
  while(columnheader && !/columnheader/.test(columnheader.getAttribute('role')))columnheader = columnheader.parentElement;
101
135
  } else columnheader = column;
102
- let menuButton = (0, $2auAU$testinglibraryreact.within)(columnheader).queryByRole('button');
136
+ let menuButton = (0, $kIP0K$testinglibraryreact.within)(columnheader).queryByRole('button');
103
137
  if (menuButton) {
104
138
  let currentSort = columnheader.getAttribute('aria-sort');
105
139
  // TODO: Focus management is all kinda of messed up if I just use .focus and Space to open the sort menu. Seems like
106
140
  // the focused key doesn't get properly set to the desired column header. Have to do this strange flow where I focus the
107
141
  // column header except if the active element is already the menu button within the column header
108
- if (interactionType === 'keyboard' && document.activeElement !== menuButton) await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, columnheader, interactionType);
109
- else await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, menuButton, interactionType);
110
- await (0, $2auAU$testinglibraryreact.waitFor)(()=>{
142
+ if (interactionType === 'keyboard' && document.activeElement !== menuButton) await (0, $01a4eeee86094c77$exports.pressElement)(this.user, columnheader, interactionType);
143
+ else await (0, $01a4eeee86094c77$exports.pressElement)(this.user, menuButton, interactionType);
144
+ await (0, $kIP0K$testinglibraryreact.waitFor)(()=>{
111
145
  if (menuButton.getAttribute('aria-controls') == null) throw new Error('No aria-controls found on table column dropdown menu trigger element.');
112
146
  else return true;
113
147
  });
114
148
  let menuId = menuButton.getAttribute('aria-controls');
115
- await (0, $2auAU$testinglibraryreact.waitFor)(()=>{
149
+ await (0, $kIP0K$testinglibraryreact.waitFor)(()=>{
116
150
  if (!menuId || document.getElementById(menuId) == null) throw new Error(`Table column header menu with id of ${menuId} not found in document.`);
117
151
  else return true;
118
152
  });
119
153
  if (menuId) {
120
154
  let menu = document.getElementById(menuId);
121
155
  if (menu) {
122
- if (currentSort === 'ascending') await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, (0, $2auAU$testinglibraryreact.within)(menu).getAllByRole('menuitem')[1], interactionType);
123
- else await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, (0, $2auAU$testinglibraryreact.within)(menu).getAllByRole('menuitem')[0], interactionType);
124
- await (0, $2auAU$testinglibraryreact.waitFor)(()=>{
156
+ if (currentSort === 'ascending') await (0, $01a4eeee86094c77$exports.pressElement)(this.user, (0, $kIP0K$testinglibraryreact.within)(menu).getAllByRole('menuitem')[1], interactionType);
157
+ else await (0, $01a4eeee86094c77$exports.pressElement)(this.user, (0, $kIP0K$testinglibraryreact.within)(menu).getAllByRole('menuitem')[0], interactionType);
158
+ await (0, $kIP0K$testinglibraryreact.waitFor)(()=>{
125
159
  if (document.contains(menu)) throw new Error('Expected table column menu listbox to not be in the document after selecting an option');
126
160
  else return true;
127
161
  });
@@ -129,15 +163,14 @@ class $80a9def682ac1297$export$4c6a9d6ae3b0086 {
129
163
  }
130
164
  // Handle cases where the table may transition in response to the row selection/deselection
131
165
  if (!this._advanceTimer) throw new Error('No advanceTimers provided for table transition.');
132
- await (0, $2auAU$testinglibraryreact.act)(async ()=>{
133
- var _this__advanceTimer, _this;
134
- await ((_this__advanceTimer = (_this = this)._advanceTimer) === null || _this__advanceTimer === void 0 ? void 0 : _this__advanceTimer.call(_this, 200));
166
+ await (0, $kIP0K$testinglibraryreact.act)(async ()=>{
167
+ await this._advanceTimer?.(200);
135
168
  });
136
- await (0, $2auAU$testinglibraryreact.waitFor)(()=>{
169
+ await (0, $kIP0K$testinglibraryreact.waitFor)(()=>{
137
170
  if (document.activeElement !== menuButton) throw new Error(`Expected the document.activeElement to be the table column menu button but got ${document.activeElement}`);
138
171
  else return true;
139
172
  });
140
- } else await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, columnheader, interactionType);
173
+ } else await (0, $01a4eeee86094c77$exports.pressElement)(this.user, columnheader, interactionType);
141
174
  }
142
175
  /**
143
176
  * Triggers an action for the specified table column menu. Defaults to using the interaction type set on the table tester.
@@ -146,30 +179,30 @@ class $80a9def682ac1297$export$4c6a9d6ae3b0086 {
146
179
  let columnheader;
147
180
  if (typeof column === 'number') columnheader = this.columns[column];
148
181
  else if (typeof column === 'string') {
149
- columnheader = (0, $2auAU$testinglibraryreact.within)(this.rowGroups[0]).getByText(column);
182
+ columnheader = (0, $kIP0K$testinglibraryreact.within)(this.rowGroups[0]).getByText(column);
150
183
  while(columnheader && !/columnheader/.test(columnheader.getAttribute('role')))columnheader = columnheader.parentElement;
151
184
  } else columnheader = column;
152
- let menuButton = (0, $2auAU$testinglibraryreact.within)(columnheader).queryByRole('button');
185
+ let menuButton = (0, $kIP0K$testinglibraryreact.within)(columnheader).queryByRole('button');
153
186
  if (menuButton) {
154
187
  // TODO: Focus management is all kinda of messed up if I just use .focus and Space to open the sort menu. Seems like
155
188
  // the focused key doesn't get properly set to the desired column header. Have to do this strange flow where I focus the
156
189
  // column header except if the active element is already the menu button within the column header
157
- if (interactionType === 'keyboard' && document.activeElement !== menuButton) await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, columnheader, interactionType);
158
- else await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, menuButton, interactionType);
159
- await (0, $2auAU$testinglibraryreact.waitFor)(()=>{
190
+ if (interactionType === 'keyboard' && document.activeElement !== menuButton) await (0, $01a4eeee86094c77$exports.pressElement)(this.user, columnheader, interactionType);
191
+ else await (0, $01a4eeee86094c77$exports.pressElement)(this.user, menuButton, interactionType);
192
+ await (0, $kIP0K$testinglibraryreact.waitFor)(()=>{
160
193
  if (menuButton.getAttribute('aria-controls') == null) throw new Error('No aria-controls found on table column dropdown menu trigger element.');
161
194
  else return true;
162
195
  });
163
196
  let menuId = menuButton.getAttribute('aria-controls');
164
- await (0, $2auAU$testinglibraryreact.waitFor)(()=>{
197
+ await (0, $kIP0K$testinglibraryreact.waitFor)(()=>{
165
198
  if (!menuId || document.getElementById(menuId) == null) throw new Error(`Table column header menu with id of ${menuId} not found in document.`);
166
199
  else return true;
167
200
  });
168
201
  if (menuId) {
169
202
  let menu = document.getElementById(menuId);
170
203
  if (menu) {
171
- await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, (0, $2auAU$testinglibraryreact.within)(menu).getAllByRole('menuitem')[action], interactionType);
172
- await (0, $2auAU$testinglibraryreact.waitFor)(()=>{
204
+ await (0, $01a4eeee86094c77$exports.pressElement)(this.user, (0, $kIP0K$testinglibraryreact.within)(menu).getAllByRole('menuitem')[action], interactionType);
205
+ await (0, $kIP0K$testinglibraryreact.waitFor)(()=>{
173
206
  if (document.contains(menu)) throw new Error('Expected table column menu listbox to not be in the document after selecting an option');
174
207
  else return true;
175
208
  });
@@ -177,11 +210,10 @@ class $80a9def682ac1297$export$4c6a9d6ae3b0086 {
177
210
  }
178
211
  // Handle cases where the table may transition in response to the row selection/deselection
179
212
  if (!this._advanceTimer) throw new Error('No advanceTimers provided for table transition.');
180
- await (0, $2auAU$testinglibraryreact.act)(async ()=>{
181
- var _this__advanceTimer, _this;
182
- await ((_this__advanceTimer = (_this = this)._advanceTimer) === null || _this__advanceTimer === void 0 ? void 0 : _this__advanceTimer.call(_this, 200));
213
+ await (0, $kIP0K$testinglibraryreact.act)(async ()=>{
214
+ await this._advanceTimer?.(200);
183
215
  });
184
- await (0, $2auAU$testinglibraryreact.waitFor)(()=>{
216
+ await (0, $kIP0K$testinglibraryreact.waitFor)(()=>{
185
217
  if (document.activeElement !== menuButton) throw new Error(`Expected the document.activeElement to be the table column menu button but got ${document.activeElement}`);
186
218
  else return true;
187
219
  });
@@ -202,7 +234,7 @@ class $80a9def682ac1297$export$4c6a9d6ae3b0086 {
202
234
  selectionOnNav: 'none'
203
235
  });
204
236
  await this.user.keyboard('[Enter]');
205
- } else await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, row, interactionType);
237
+ } else await (0, $01a4eeee86094c77$exports.pressElement)(this.user, row, interactionType);
206
238
  }
207
239
  // TODO: should there be utils for drag and drop and column resizing? For column resizing, I'm not entirely convinced that users will be doing that in their tests.
208
240
  // For DnD, it might be tricky to do for keyboard DnD since we wouldn't know what valid drop zones there are... Similarly, for simulating mouse drag and drop the coordinates depend
@@ -213,10 +245,10 @@ class $80a9def682ac1297$export$4c6a9d6ae3b0086 {
213
245
  * Toggle selection for all rows in the table. Defaults to using the interaction type set on the table tester.
214
246
  */ async toggleSelectAll(opts = {}) {
215
247
  let { interactionType: interactionType = this._interactionType } = opts;
216
- let checkbox = (0, $2auAU$testinglibraryreact.within)(this.table).getByLabelText('Select All');
248
+ let checkbox = (0, $kIP0K$testinglibraryreact.within)(this.table).getByLabelText('Select All');
217
249
  if (interactionType === 'keyboard') // TODO: using the .focus -> trigger keyboard Enter approach doesn't work for some reason, for now just trigger select all with click.
218
250
  await this.user.click(checkbox);
219
- else await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, checkbox, interactionType);
251
+ else await (0, $01a4eeee86094c77$exports.pressElement)(this.user, checkbox, interactionType);
220
252
  }
221
253
  /**
222
254
  * Returns a row matching the specified index or text content.
@@ -227,7 +259,7 @@ class $80a9def682ac1297$export$4c6a9d6ae3b0086 {
227
259
  let bodyRowGroup = this.rowGroups[1];
228
260
  if (typeof rowIndexOrText === 'number') row = rows[rowIndexOrText];
229
261
  else if (typeof rowIndexOrText === 'string') {
230
- row = (0, $2auAU$testinglibraryreact.within)(bodyRowGroup).getByText(rowIndexOrText);
262
+ row = (0, $kIP0K$testinglibraryreact.within)(bodyRowGroup).getByText(rowIndexOrText);
231
263
  while(row && row.getAttribute('role') !== 'row')row = row.parentElement;
232
264
  }
233
265
  return row;
@@ -236,7 +268,7 @@ class $80a9def682ac1297$export$4c6a9d6ae3b0086 {
236
268
  * Returns a cell matching the specified text content.
237
269
  */ findCell(opts) {
238
270
  let { text: text } = opts;
239
- let cell = (0, $2auAU$testinglibraryreact.within)(this.table).getByText(text);
271
+ let cell = (0, $kIP0K$testinglibraryreact.within)(this.table).getByText(text);
240
272
  if (cell) while(cell && !/gridcell|rowheader|columnheader/.test(cell.getAttribute('role') || '')){
241
273
  if (cell.parentElement) cell = cell.parentElement;
242
274
  else break;
@@ -252,19 +284,19 @@ class $80a9def682ac1297$export$4c6a9d6ae3b0086 {
252
284
  * Returns the row groups within the table.
253
285
  */ get rowGroups() {
254
286
  let table = this._table;
255
- return table ? (0, $2auAU$testinglibraryreact.within)(table).queryAllByRole('rowgroup') : [];
287
+ return table ? (0, $kIP0K$testinglibraryreact.within)(table).queryAllByRole('rowgroup') : [];
256
288
  }
257
289
  /**
258
290
  * Returns the columns within the table.
259
291
  */ get columns() {
260
292
  let headerRowGroup = this.rowGroups[0];
261
- return headerRowGroup ? (0, $2auAU$testinglibraryreact.within)(headerRowGroup).queryAllByRole('columnheader') : [];
293
+ return headerRowGroup ? (0, $kIP0K$testinglibraryreact.within)(headerRowGroup).queryAllByRole('columnheader') : [];
262
294
  }
263
295
  /**
264
296
  * Returns the rows within the table if any.
265
297
  */ get rows() {
266
298
  let bodyRowGroup = this.rowGroups[1];
267
- return bodyRowGroup ? (0, $2auAU$testinglibraryreact.within)(bodyRowGroup).queryAllByRole('row') : [];
299
+ return bodyRowGroup ? (0, $kIP0K$testinglibraryreact.within)(bodyRowGroup).queryAllByRole('row') : [];
268
300
  }
269
301
  /**
270
302
  * Returns the currently selected rows within the table if any.
@@ -274,22 +306,15 @@ class $80a9def682ac1297$export$4c6a9d6ae3b0086 {
274
306
  /**
275
307
  * Returns the row headers within the table if any.
276
308
  */ get rowHeaders() {
277
- return (0, $2auAU$testinglibraryreact.within)(this.table).queryAllByRole('rowheader');
309
+ return (0, $kIP0K$testinglibraryreact.within)(this.table).queryAllByRole('rowheader');
278
310
  }
279
311
  /**
280
312
  * Returns the cells within the table if any. Can be filtered against a specific row if provided via `element`.
281
313
  */ cells(opts = {}) {
282
314
  let { element: element = this.table } = opts;
283
- return (0, $2auAU$testinglibraryreact.within)(element).queryAllByRole('gridcell');
284
- }
285
- constructor(opts){
286
- let { root: root, user: user, interactionType: interactionType, advanceTimer: advanceTimer } = opts;
287
- this.user = user;
288
- this._interactionType = interactionType || 'mouse';
289
- this._advanceTimer = advanceTimer;
290
- this._table = root;
315
+ return (0, $kIP0K$testinglibraryreact.within)(element).queryAllByRole('gridcell');
291
316
  }
292
317
  }
293
318
 
294
319
 
295
- //# sourceMappingURL=table.main.js.map
320
+ //# sourceMappingURL=table.cjs.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AA0BM,MAAM;IAMX,YAAY,IAAqB,CAAE;QACjC,IA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O;IACT;IAEA;;GAEC,GACD,IAAI,QAAqB;QACvB,OAAO,IAAI,CAAC,MAAM;IACpB;IAEA;;GAEC,GACD,IAAI,YAA2B;QAC7B,IAAI,QAAQ,IAAI,CAAC,MAAM;QACvB,OAAO,QAAQ,CAAA,GAAA,iCAAK,EAAE,OAAO,cAAc,CAAC,cAAc,EAAE;IAC9D;IAEA;;GAEC,GACD,IAAI,UAAyB;QAC3B,IAAI,iBAAiB,IAAI,CAAC,SAAS,CAAC,EAAE;QACtC,OAAO,iBAAiB,CAAA,GAAA,iCAAK,EAAE,gBAAgB,cAAc,CAAC,kBAAkB,EAAE;IACpF;IAEA;;GAEC,GACD,IAAI,OAAsB;QACxB,IAAI,eAAe,IAAI,CAAC,SAAS,CAAC,EAAE;QACpC,OAAO,eAAe,CAAA,GAAA,iCAAK,EAAE,cAAc,cAAc,CAAC,SAAS,EAAE;IACvE;IAEA;;GAEC,GACD,IAAI,eAA8B;QAChC,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA,MAAO,IAAI,YAAY,CAAC,qBAAqB;IACvE;IAEA;;GAEC,GACD,IAAI,aAA4B;QAC9B,OAAO,CAAA,GAAA,iCAAK,EAAE,IAAI,CAAC,KAAK,EAAE,cAAc,CAAC;IAC3C;IAEA;;GAEC,GACD,MAAM,OAAgC,CAAC,CAAC,EAAiB;QACvD,IAAI,WAAC,UAAU,IAAI,CAAC,KAAK,EAAC,GAAG;QAC7B,OAAO,CAAA,GAAA,iCAAK,EAAE,SAAS,cAAc,CAAC;IACxC;AACF","sources":["packages/@react-aria/test-utils/src/table.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, waitFor, within} from '@testing-library/react';\nimport {BaseGridRowInteractionOpts, GridRowActionOpts, TableTesterOpts, ToggleGridRowOpts, UserOpts} from './types';\nimport {getAltKey, getMetaKey, pressElement, triggerLongPress} from './events';\n\ninterface TableToggleRowOpts extends ToggleGridRowOpts {}\ninterface TableToggleExpansionOpts extends BaseGridRowInteractionOpts {}\ninterface TableToggleSortOpts {\n /**\n * The index, text, or node of the column to toggle selection for.\n */\n column: number | string | HTMLElement,\n /**\n * What interaction type to use when sorting the column. Defaults to the interaction type set on the tester.\n */\n interactionType?: UserOpts['interactionType']\n}\ninterface TableColumnHeaderActionOpts extends TableToggleSortOpts {\n /**\n * The index of the column header action to trigger.\n */\n action: number\n}\ninterface TableRowActionOpts extends GridRowActionOpts {}\n\nexport class TableTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _advanceTimer: UserOpts['advanceTimer'];\n private _table: HTMLElement;\n\n constructor(opts: TableTesterOpts) {\n let {root, user, interactionType, advanceTimer} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n this._advanceTimer = advanceTimer;\n this._table = root;\n }\n\n /**\n * Set the interaction type used by the table tester.\n */\n setInteractionType(type: UserOpts['interactionType']): void {\n this._interactionType = type;\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('Row provided is not in the table');\n }\n\n // Move focus into the table\n if (document.activeElement !== this._table && !this._table.contains(document.activeElement)) {\n act(() => this._table.focus());\n }\n\n if (document.activeElement === this._table) {\n await this.user.keyboard('[ArrowDown]');\n }\n\n // If focus is currently somewhere in the first row group (aka on a column), we want to keyboard navigate downwards till we reach the rows\n if (this.rowGroups[0].contains(document.activeElement)) {\n do {\n await this.user.keyboard('[ArrowDown]');\n } while (!this.rowGroups[1].contains(document.activeElement));\n }\n\n // Move focus onto the row itself\n if (this.rowGroups[1].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('Current active element is not on any of the table rows');\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 table row. Defaults to using the interaction type set on the table tester.\n */\n async toggleRowSelection(opts: TableToggleRowOpts): Promise<void> {\n let {\n row,\n needsLongPress,\n checkboxSelection = true,\n interactionType = this._interactionType,\n selectionBehavior = 'toggle'\n } = opts;\n\n let altKey = getMetaKey();\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 table.');\n }\n\n let rowCheckbox = within(row).queryByRole('checkbox');\n\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 if (selectionBehavior === 'replace' && interactionType !== 'touch') {\n await this.user.keyboard(`[${metaKey}>]`);\n }\n await pressElement(this.user, cell, 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: TableToggleExpansionOpts): Promise<void> {\n let {\n row,\n interactionType = this._interactionType\n } = opts;\n if (!this.table.contains(document.activeElement)) {\n await act(async () => {\n this.table.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 table.');\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 * Toggles the sort order for the specified table column. Defaults to using the interaction type set on the table tester.\n */\n async toggleSort(opts: TableToggleSortOpts): Promise<void> {\n let {\n column,\n interactionType = this._interactionType\n } = opts;\n\n let columnheader;\n if (typeof column === 'number') {\n columnheader = this.columns[column];\n } else if (typeof column === 'string') {\n columnheader = within(this.rowGroups[0]).getByText(column);\n while (columnheader && !/columnheader/.test(columnheader.getAttribute('role'))) {\n columnheader = columnheader.parentElement;\n }\n } else {\n columnheader = column;\n }\n\n let menuButton = within(columnheader).queryByRole('button');\n if (menuButton) {\n let currentSort = columnheader.getAttribute('aria-sort');\n // TODO: Focus management is all kinda of messed up if I just use .focus and Space to open the sort menu. Seems like\n // the focused key doesn't get properly set to the desired column header. Have to do this strange flow where I focus the\n // column header except if the active element is already the menu button within the column header\n if (interactionType === 'keyboard' && document.activeElement !== menuButton) {\n await pressElement(this.user, columnheader, interactionType);\n } else {\n await pressElement(this.user, menuButton, interactionType);\n }\n\n await waitFor(() => {\n if (menuButton.getAttribute('aria-controls') == null) {\n throw new Error('No aria-controls found on table column dropdown menu trigger element.');\n } else {\n return true;\n }\n });\n\n let menuId = menuButton.getAttribute('aria-controls');\n await waitFor(() => {\n if (!menuId || document.getElementById(menuId) == null) {\n throw new Error(`Table column header menu with id of ${menuId} not found in document.`);\n } else {\n return true;\n }\n });\n\n if (menuId) {\n let menu = document.getElementById(menuId);\n if (menu) {\n if (currentSort === 'ascending') {\n await pressElement(this.user, within(menu).getAllByRole('menuitem')[1], interactionType);\n } else {\n await pressElement(this.user, within(menu).getAllByRole('menuitem')[0], interactionType);\n }\n\n await waitFor(() => {\n if (document.contains(menu)) {\n throw new Error('Expected table column menu listbox to not be in the document after selecting an option');\n } else {\n return true;\n }\n });\n }\n }\n\n // Handle cases where the table may transition in response to the row selection/deselection\n if (!this._advanceTimer) {\n throw new Error('No advanceTimers provided for table transition.');\n }\n\n await act(async () => {\n await this._advanceTimer?.(200);\n });\n\n await waitFor(() => {\n if (document.activeElement !== menuButton) {\n throw new Error(`Expected the document.activeElement to be the table column menu button but got ${document.activeElement}`);\n } else {\n return true;\n }\n });\n } else {\n await pressElement(this.user, columnheader, interactionType);\n }\n }\n\n /**\n * Triggers an action for the specified table column menu. Defaults to using the interaction type set on the table tester.\n */\n async triggerColumnHeaderAction(opts: TableColumnHeaderActionOpts): Promise<void> {\n let {\n column,\n interactionType = this._interactionType,\n action\n } = opts;\n\n let columnheader;\n if (typeof column === 'number') {\n columnheader = this.columns[column];\n } else if (typeof column === 'string') {\n columnheader = within(this.rowGroups[0]).getByText(column);\n while (columnheader && !/columnheader/.test(columnheader.getAttribute('role'))) {\n columnheader = columnheader.parentElement;\n }\n } else {\n columnheader = column;\n }\n\n let menuButton = within(columnheader).queryByRole('button');\n if (menuButton) {\n // TODO: Focus management is all kinda of messed up if I just use .focus and Space to open the sort menu. Seems like\n // the focused key doesn't get properly set to the desired column header. Have to do this strange flow where I focus the\n // column header except if the active element is already the menu button within the column header\n if (interactionType === 'keyboard' && document.activeElement !== menuButton) {\n await pressElement(this.user, columnheader, interactionType);\n } else {\n await pressElement(this.user, menuButton, interactionType);\n }\n\n await waitFor(() => {\n if (menuButton.getAttribute('aria-controls') == null) {\n throw new Error('No aria-controls found on table column dropdown menu trigger element.');\n } else {\n return true;\n }\n });\n\n let menuId = menuButton.getAttribute('aria-controls');\n await waitFor(() => {\n if (!menuId || document.getElementById(menuId) == null) {\n throw new Error(`Table column header menu with id of ${menuId} not found in document.`);\n } else {\n return true;\n }\n });\n\n if (menuId) {\n let menu = document.getElementById(menuId);\n if (menu) {\n await pressElement(this.user, within(menu).getAllByRole('menuitem')[action], interactionType);\n\n await waitFor(() => {\n if (document.contains(menu)) {\n throw new Error('Expected table column menu listbox to not be in the document after selecting an option');\n } else {\n return true;\n }\n });\n }\n }\n\n // Handle cases where the table may transition in response to the row selection/deselection\n if (!this._advanceTimer) {\n throw new Error('No advanceTimers provided for table transition.');\n }\n\n await act(async () => {\n await this._advanceTimer?.(200);\n });\n\n await waitFor(() => {\n if (document.activeElement !== menuButton) {\n throw new Error(`Expected the document.activeElement to be the table column menu button but got ${document.activeElement}`);\n } else {\n return true;\n }\n });\n } else {\n throw new Error('No menu button found on table column header.');\n }\n }\n\n /**\n * Triggers the action for the specified table row. Defaults to using the interaction type set on the table tester.\n */\n async triggerRowAction(opts: TableRowActionOpts): 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 table.');\n }\n\n if (needsDoubleClick) {\n await this.user.dblClick(row);\n } else if (interactionType === 'keyboard') {\n await this.keyboardNavigateToRow({row, selectionOnNav: 'none'});\n await this.user.keyboard('[Enter]');\n } else {\n await pressElement(this.user, row, interactionType);\n }\n }\n\n // TODO: should there be utils for drag and drop and column resizing? For column resizing, I'm not entirely convinced that users will be doing that in their tests.\n // For DnD, it might be tricky to do for keyboard DnD since we wouldn't know what valid drop zones there are... Similarly, for simulating mouse drag and drop the coordinates depend\n // on the mocks the user sets up for their row height/etc.\n // Additionally, should we also support keyboard navigation/typeahead? Those felt like they could be very easily replicated by the user via user.keyboard already and don't really\n // add much value if we provide that to them\n /**\n * Toggle selection for all rows in the table. Defaults to using the interaction type set on the table tester.\n */\n async toggleSelectAll(opts: {interactionType?: UserOpts['interactionType']} = {}): Promise<void> {\n let {\n interactionType = this._interactionType\n } = opts;\n let checkbox = within(this.table).getByLabelText('Select All');\n if (interactionType === 'keyboard') {\n // TODO: using the .focus -> trigger keyboard Enter approach doesn't work for some reason, for now just trigger select all with click.\n await this.user.click(checkbox);\n } else {\n await pressElement(this.user, checkbox, interactionType);\n }\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 let rows = this.rows;\n let bodyRowGroup = this.rowGroups[1];\n if (typeof rowIndexOrText === 'number') {\n row = rows[rowIndexOrText];\n } else if (typeof rowIndexOrText === 'string') {\n row = within(bodyRowGroup).getByText(rowIndexOrText);\n while (row && row.getAttribute('role') !== 'row') {\n row = row.parentElement;\n }\n }\n\n return row;\n }\n\n /**\n * Returns a cell matching the specified text content.\n */\n findCell(opts: {text: string}): HTMLElement {\n let {\n text\n } = opts;\n\n let cell = within(this.table).getByText(text);\n if (cell) {\n while (cell && !/gridcell|rowheader|columnheader/.test(cell.getAttribute('role') || '')) {\n if (cell.parentElement) {\n cell = cell.parentElement;\n } else {\n break;\n }\n }\n }\n\n return cell;\n }\n\n /**\n * Returns the table.\n */\n get table(): HTMLElement {\n return this._table;\n }\n\n /**\n * Returns the row groups within the table.\n */\n get rowGroups(): HTMLElement[] {\n let table = this._table;\n return table ? within(table).queryAllByRole('rowgroup') : [];\n }\n\n /**\n * Returns the columns within the table.\n */\n get columns(): HTMLElement[] {\n let headerRowGroup = this.rowGroups[0];\n return headerRowGroup ? within(headerRowGroup).queryAllByRole('columnheader') : [];\n }\n\n /**\n * Returns the rows within the table if any.\n */\n get rows(): HTMLElement[] {\n let bodyRowGroup = this.rowGroups[1];\n return bodyRowGroup ? within(bodyRowGroup).queryAllByRole('row') : [];\n }\n\n /**\n * Returns the currently selected rows within the table if any.\n */\n get selectedRows(): HTMLElement[] {\n return this.rows.filter(row => row.getAttribute('aria-selected') === 'true');\n }\n\n /**\n * Returns the row headers within the table if any.\n */\n get rowHeaders(): HTMLElement[] {\n return within(this.table).queryAllByRole('rowheader');\n }\n\n /**\n * Returns the cells within the table if any. Can be filtered against a specific row if provided via `element`.\n */\n cells(opts: {element?: HTMLElement} = {}): HTMLElement[] {\n let {element = this.table} = opts;\n return within(element).queryAllByRole('gridcell');\n }\n}\n"],"names":[],"version":3,"file":"table.cjs.map"}