@react-aria/test-utils 1.0.0-beta.2 → 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 (130) hide show
  1. package/dist/import.mjs +5 -5
  2. package/dist/main.js +9 -9
  3. package/dist/module.js +5 -5
  4. package/dist/{checkboxgroup.main.js → private/checkboxgroup.cjs} +19 -19
  5. package/dist/private/checkboxgroup.cjs.map +1 -0
  6. package/dist/{checkboxgroup.mjs → private/checkboxgroup.js} +19 -19
  7. package/dist/private/checkboxgroup.js.map +1 -0
  8. package/dist/{combobox.main.js → private/combobox.cjs} +35 -35
  9. package/dist/private/combobox.cjs.map +1 -0
  10. package/dist/{combobox.mjs → private/combobox.js} +35 -35
  11. package/dist/private/combobox.js.map +1 -0
  12. package/dist/{dialog.main.js → private/dialog.cjs} +19 -19
  13. package/dist/private/dialog.cjs.map +1 -0
  14. package/dist/{dialog.mjs → private/dialog.js} +19 -19
  15. package/dist/private/dialog.js.map +1 -0
  16. package/dist/{events.main.js → private/events.cjs} +32 -34
  17. package/dist/private/events.cjs.map +1 -0
  18. package/dist/{events.mjs → private/events.js} +29 -31
  19. package/dist/private/events.js.map +1 -0
  20. package/dist/{gridlist.main.js → private/gridlist.cjs} +27 -28
  21. package/dist/private/gridlist.cjs.map +1 -0
  22. package/dist/{gridlist.mjs → private/gridlist.js} +27 -28
  23. package/dist/private/gridlist.js.map +1 -0
  24. package/dist/{listbox.main.js → private/listbox.cjs} +24 -24
  25. package/dist/private/listbox.cjs.map +1 -0
  26. package/dist/{listbox.mjs → private/listbox.js} +24 -24
  27. package/dist/private/listbox.js.map +1 -0
  28. package/dist/{menu.main.js → private/menu.cjs} +46 -48
  29. package/dist/private/menu.cjs.map +1 -0
  30. package/dist/{menu.mjs → private/menu.js} +46 -48
  31. package/dist/private/menu.js.map +1 -0
  32. package/dist/{radiogroup.main.js → private/radiogroup.cjs} +21 -24
  33. package/dist/private/radiogroup.cjs.map +1 -0
  34. package/dist/{radiogroup.mjs → private/radiogroup.js} +21 -24
  35. package/dist/private/radiogroup.js.map +1 -0
  36. package/dist/{select.main.js → private/select.cjs} +31 -29
  37. package/dist/private/select.cjs.map +1 -0
  38. package/dist/{select.module.js → private/select.js} +31 -29
  39. package/dist/private/select.js.map +1 -0
  40. package/dist/{table.main.js → private/table.cjs} +82 -57
  41. package/dist/private/table.cjs.map +1 -0
  42. package/dist/{table.module.js → private/table.js} +82 -57
  43. package/dist/private/table.js.map +1 -0
  44. package/dist/{tabs.main.js → private/tabs.cjs} +21 -25
  45. package/dist/private/tabs.cjs.map +1 -0
  46. package/dist/{tabs.mjs → private/tabs.js} +21 -25
  47. package/dist/private/tabs.js.map +1 -0
  48. package/dist/{testSetup.main.js → private/testSetup.cjs} +27 -19
  49. package/dist/private/testSetup.cjs.map +1 -0
  50. package/dist/{testSetup.module.js → private/testSetup.js} +26 -18
  51. package/dist/private/testSetup.js.map +1 -0
  52. package/dist/{tree.main.js → private/tree.cjs} +34 -35
  53. package/dist/private/tree.cjs.map +1 -0
  54. package/dist/{tree.mjs → private/tree.js} +34 -35
  55. package/dist/private/tree.js.map +1 -0
  56. package/dist/private/user.cjs +85 -0
  57. package/dist/private/user.cjs.map +1 -0
  58. package/dist/private/user.js +76 -0
  59. package/dist/private/user.js.map +1 -0
  60. package/dist/{userEventMaps.main.js → private/userEventMaps.cjs} +3 -3
  61. package/dist/{userEventMaps.main.js.map → private/userEventMaps.cjs.map} +1 -1
  62. package/dist/{userEventMaps.mjs → private/userEventMaps.js} +3 -3
  63. package/dist/{userEventMaps.module.js.map → private/userEventMaps.js.map} +1 -1
  64. package/dist/types/src/checkboxgroup.d.ts +45 -0
  65. package/dist/types/src/combobox.d.ts +75 -0
  66. package/dist/types/src/dialog.d.ts +36 -0
  67. package/dist/types/src/events.d.ts +25 -0
  68. package/dist/types/src/gridlist.d.ts +51 -0
  69. package/dist/types/src/index.d.ts +16 -0
  70. package/dist/types/src/listbox.d.ts +80 -0
  71. package/dist/types/src/menu.d.ts +102 -0
  72. package/dist/types/src/radiogroup.d.ts +46 -0
  73. package/dist/types/src/select.d.ts +67 -0
  74. package/dist/types/src/table.d.ts +104 -0
  75. package/dist/types/src/tabs.d.ts +58 -0
  76. package/dist/types/src/testSetup.d.ts +6 -0
  77. package/dist/types/src/tree.d.ts +57 -0
  78. package/dist/types/src/types.d.ts +136 -0
  79. package/dist/types/src/user.d.ts +47 -0
  80. package/dist/types/src/userEventMaps.d.ts +2 -0
  81. package/package.json +7 -7
  82. package/src/select.ts +10 -2
  83. package/src/table.ts +46 -1
  84. package/dist/checkboxgroup.main.js.map +0 -1
  85. package/dist/checkboxgroup.module.js +0 -99
  86. package/dist/checkboxgroup.module.js.map +0 -1
  87. package/dist/combobox.main.js.map +0 -1
  88. package/dist/combobox.module.js +0 -167
  89. package/dist/combobox.module.js.map +0 -1
  90. package/dist/dialog.main.js.map +0 -1
  91. package/dist/dialog.module.js +0 -100
  92. package/dist/dialog.module.js.map +0 -1
  93. package/dist/events.main.js.map +0 -1
  94. package/dist/events.module.js +0 -112
  95. package/dist/events.module.js.map +0 -1
  96. package/dist/gridlist.main.js.map +0 -1
  97. package/dist/gridlist.module.js +0 -149
  98. package/dist/gridlist.module.js.map +0 -1
  99. package/dist/listbox.main.js.map +0 -1
  100. package/dist/listbox.module.js +0 -138
  101. package/dist/listbox.module.js.map +0 -1
  102. package/dist/menu.main.js.map +0 -1
  103. package/dist/menu.module.js +0 -269
  104. package/dist/menu.module.js.map +0 -1
  105. package/dist/radiogroup.main.js.map +0 -1
  106. package/dist/radiogroup.module.js +0 -118
  107. package/dist/radiogroup.module.js.map +0 -1
  108. package/dist/select.main.js.map +0 -1
  109. package/dist/select.mjs +0 -158
  110. package/dist/select.module.js.map +0 -1
  111. package/dist/table.main.js.map +0 -1
  112. package/dist/table.mjs +0 -290
  113. package/dist/table.module.js.map +0 -1
  114. package/dist/tabs.main.js.map +0 -1
  115. package/dist/tabs.module.js +0 -130
  116. package/dist/tabs.module.js.map +0 -1
  117. package/dist/testSetup.main.js.map +0 -1
  118. package/dist/testSetup.mjs +0 -73
  119. package/dist/testSetup.module.js.map +0 -1
  120. package/dist/tree.main.js.map +0 -1
  121. package/dist/tree.module.js +0 -179
  122. package/dist/tree.module.js.map +0 -1
  123. package/dist/types.d.ts +0 -823
  124. package/dist/types.d.ts.map +0 -1
  125. package/dist/user.main.js +0 -85
  126. package/dist/user.main.js.map +0 -1
  127. package/dist/user.mjs +0 -76
  128. package/dist/user.module.js +0 -76
  129. package/dist/user.module.js.map +0 -1
  130. package/dist/userEventMaps.module.js +0 -38
package/dist/import.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import {triggerLongPress as $5d1eca18f92ad0e6$export$3a22a5a9bc0fd3b} from "./events.mjs";
2
- import {installMouseEvent as $68df97871cfb5e33$export$de31e3987c917741, installPointerEvent as $68df97871cfb5e33$export$82f0b04c1d69a901} from "./testSetup.mjs";
3
- import {pointerMap as $50ecfb18069ec897$export$7dbde2c4caaa8d35} from "./userEventMaps.mjs";
4
- import {User as $0d71b4e9cc4df40a$export$1f44aaf2ec115b54} from "./user.mjs";
1
+ import {triggerLongPress as $22d7d9b763402afa$export$3a22a5a9bc0fd3b} from "./private/events.js";
2
+ import {installMouseEvent as $448e93e3748c7958$export$de31e3987c917741, installPointerEvent as $448e93e3748c7958$export$82f0b04c1d69a901} from "./private/testSetup.js";
3
+ import {pointerMap as $759f061d800cf446$export$7dbde2c4caaa8d35} from "./private/userEventMaps.js";
4
+ import {User as $4ab48216ddc89c32$export$1f44aaf2ec115b54} from "./private/user.js";
5
5
 
6
6
  /*
7
7
  * Copyright 2023 Adobe. All rights reserved.
@@ -19,5 +19,5 @@ import {User as $0d71b4e9cc4df40a$export$1f44aaf2ec115b54} from "./user.mjs";
19
19
 
20
20
 
21
21
 
22
- export {$5d1eca18f92ad0e6$export$3a22a5a9bc0fd3b as triggerLongPress, $68df97871cfb5e33$export$de31e3987c917741 as installMouseEvent, $68df97871cfb5e33$export$82f0b04c1d69a901 as installPointerEvent, $50ecfb18069ec897$export$7dbde2c4caaa8d35 as pointerMap, $0d71b4e9cc4df40a$export$1f44aaf2ec115b54 as User};
22
+ export {$22d7d9b763402afa$export$3a22a5a9bc0fd3b as triggerLongPress, $448e93e3748c7958$export$de31e3987c917741 as installMouseEvent, $448e93e3748c7958$export$82f0b04c1d69a901 as installPointerEvent, $759f061d800cf446$export$7dbde2c4caaa8d35 as pointerMap, $4ab48216ddc89c32$export$1f44aaf2ec115b54 as User};
23
23
  //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,18 +1,18 @@
1
- var $5a8bfe1663b8366d$exports = require("./events.main.js");
2
- var $b53408e40e8d56d0$exports = require("./testSetup.main.js");
3
- var $0e568517a25183a7$exports = require("./userEventMaps.main.js");
4
- var $4168d511756883ff$exports = require("./user.main.js");
1
+ var $01a4eeee86094c77$exports = require("./private/events.cjs");
2
+ var $5e3c75beb0dad42b$exports = require("./private/testSetup.cjs");
3
+ var $b3fc8c302673b35d$exports = require("./private/userEventMaps.cjs");
4
+ var $3117e6a7fac3686b$exports = require("./private/user.cjs");
5
5
 
6
6
 
7
7
  function $parcel$export(e, n, v, s) {
8
8
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
9
9
  }
10
10
 
11
- $parcel$export(module.exports, "triggerLongPress", () => $5a8bfe1663b8366d$exports.triggerLongPress);
12
- $parcel$export(module.exports, "installMouseEvent", () => $b53408e40e8d56d0$exports.installMouseEvent);
13
- $parcel$export(module.exports, "installPointerEvent", () => $b53408e40e8d56d0$exports.installPointerEvent);
14
- $parcel$export(module.exports, "pointerMap", () => $0e568517a25183a7$exports.pointerMap);
15
- $parcel$export(module.exports, "User", () => $4168d511756883ff$exports.User);
11
+ $parcel$export(module.exports, "triggerLongPress", function () { return $01a4eeee86094c77$exports.triggerLongPress; });
12
+ $parcel$export(module.exports, "installMouseEvent", function () { return $5e3c75beb0dad42b$exports.installMouseEvent; });
13
+ $parcel$export(module.exports, "installPointerEvent", function () { return $5e3c75beb0dad42b$exports.installPointerEvent; });
14
+ $parcel$export(module.exports, "pointerMap", function () { return $b3fc8c302673b35d$exports.pointerMap; });
15
+ $parcel$export(module.exports, "User", function () { return $3117e6a7fac3686b$exports.User; });
16
16
  /*
17
17
  * Copyright 2023 Adobe. All rights reserved.
18
18
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
package/dist/module.js CHANGED
@@ -1,7 +1,7 @@
1
- import {triggerLongPress as $5d1eca18f92ad0e6$export$3a22a5a9bc0fd3b} from "./events.module.js";
2
- import {installMouseEvent as $68df97871cfb5e33$export$de31e3987c917741, installPointerEvent as $68df97871cfb5e33$export$82f0b04c1d69a901} from "./testSetup.module.js";
3
- import {pointerMap as $50ecfb18069ec897$export$7dbde2c4caaa8d35} from "./userEventMaps.module.js";
4
- import {User as $0d71b4e9cc4df40a$export$1f44aaf2ec115b54} from "./user.module.js";
1
+ import {triggerLongPress as $22d7d9b763402afa$export$3a22a5a9bc0fd3b} from "./private/events.js";
2
+ import {installMouseEvent as $448e93e3748c7958$export$de31e3987c917741, installPointerEvent as $448e93e3748c7958$export$82f0b04c1d69a901} from "./private/testSetup.js";
3
+ import {pointerMap as $759f061d800cf446$export$7dbde2c4caaa8d35} from "./private/userEventMaps.js";
4
+ import {User as $4ab48216ddc89c32$export$1f44aaf2ec115b54} from "./private/user.js";
5
5
 
6
6
  /*
7
7
  * Copyright 2023 Adobe. All rights reserved.
@@ -19,5 +19,5 @@ import {User as $0d71b4e9cc4df40a$export$1f44aaf2ec115b54} from "./user.module.j
19
19
 
20
20
 
21
21
 
22
- export {$5d1eca18f92ad0e6$export$3a22a5a9bc0fd3b as triggerLongPress, $68df97871cfb5e33$export$de31e3987c917741 as installMouseEvent, $68df97871cfb5e33$export$82f0b04c1d69a901 as installPointerEvent, $50ecfb18069ec897$export$7dbde2c4caaa8d35 as pointerMap, $0d71b4e9cc4df40a$export$1f44aaf2ec115b54 as User};
22
+ export {$22d7d9b763402afa$export$3a22a5a9bc0fd3b as triggerLongPress, $448e93e3748c7958$export$de31e3987c917741 as installMouseEvent, $448e93e3748c7958$export$82f0b04c1d69a901 as installPointerEvent, $759f061d800cf446$export$7dbde2c4caaa8d35 as pointerMap, $4ab48216ddc89c32$export$1f44aaf2ec115b54 as User};
23
23
  //# sourceMappingURL=module.js.map
@@ -1,12 +1,12 @@
1
- var $5a8bfe1663b8366d$exports = require("./events.main.js");
2
- var $7ADgU$testinglibraryreact = require("@testing-library/react");
1
+ var $01a4eeee86094c77$exports = require("./events.cjs");
2
+ var $aZ766$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, "CheckboxGroupTester", () => $18c3478e4f4e94c5$export$f54f4bde770cc5a6);
9
+ $parcel$export(module.exports, "CheckboxGroupTester", function () { return $2c71bb2c1e5033f0$export$f54f4bde770cc5a6; });
10
10
  /*
11
11
  * Copyright 2025 Adobe. All rights reserved.
12
12
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -19,7 +19,15 @@ $parcel$export(module.exports, "CheckboxGroupTester", () => $18c3478e4f4e94c5$ex
19
19
  * governing permissions and limitations under the License.
20
20
  */
21
21
 
22
- class $18c3478e4f4e94c5$export$f54f4bde770cc5a6 {
22
+ class $2c71bb2c1e5033f0$export$f54f4bde770cc5a6 {
23
+ constructor(opts){
24
+ let { root: root, user: user, interactionType: interactionType } = opts;
25
+ this.user = user;
26
+ this._interactionType = interactionType || 'mouse';
27
+ this._checkboxgroup = root;
28
+ let checkboxgroup = (0, $aZ766$testinglibraryreact.within)(root).queryAllByRole('group');
29
+ if (checkboxgroup.length > 0) this._checkboxgroup = checkboxgroup[0];
30
+ }
23
31
  /**
24
32
  * Set the interaction type used by the checkbox group tester.
25
33
  */ setInteractionType(type) {
@@ -32,13 +40,13 @@ class $18c3478e4f4e94c5$export$f54f4bde770cc5a6 {
32
40
  let checkbox;
33
41
  if (typeof checkboxIndexOrText === 'number') checkbox = this.checkboxes[checkboxIndexOrText];
34
42
  else if (typeof checkboxIndexOrText === 'string') {
35
- let label = (0, $7ADgU$testinglibraryreact.within)(this.checkboxgroup).getByText(checkboxIndexOrText);
43
+ let label = (0, $aZ766$testinglibraryreact.within)(this.checkboxgroup).getByText(checkboxIndexOrText);
36
44
  // Label may wrap the checkbox, or the actual label may be a sibling span, or the checkbox div could have the label within it
37
45
  if (label) {
38
- checkbox = (0, $7ADgU$testinglibraryreact.within)(label).queryByRole('checkbox');
46
+ checkbox = (0, $aZ766$testinglibraryreact.within)(label).queryByRole('checkbox');
39
47
  if (!checkbox) {
40
48
  let labelWrapper = label.closest('label');
41
- if (labelWrapper) checkbox = (0, $7ADgU$testinglibraryreact.within)(labelWrapper).queryByRole('checkbox');
49
+ if (labelWrapper) checkbox = (0, $aZ766$testinglibraryreact.within)(labelWrapper).queryByRole('checkbox');
42
50
  else checkbox = label.closest('[role=checkbox]');
43
51
  }
44
52
  }
@@ -52,7 +60,7 @@ class $18c3478e4f4e94c5$export$f54f4bde770cc5a6 {
52
60
  if (checkboxes.length === 0) throw new Error('Checkbox group doesnt have any non-disabled checkboxes. Please double check your checkbox group.');
53
61
  let targetIndex = checkboxes.indexOf(checkbox);
54
62
  if (targetIndex === -1) throw new Error('Checkbox provided is not in the checkbox group.');
55
- if (!this.checkboxgroup.contains(document.activeElement)) (0, $7ADgU$testinglibraryreact.act)(()=>checkboxes[0].focus());
63
+ if (!this.checkboxgroup.contains(document.activeElement)) (0, $aZ766$testinglibraryreact.act)(()=>checkboxes[0].focus());
56
64
  let currIndex = checkboxes.indexOf(document.activeElement);
57
65
  if (currIndex === -1) throw new Error('Active element is not in the checkbox group.');
58
66
  for(let i = 0; i < Math.abs(targetIndex - currIndex); i++)await this.user.tab({
@@ -73,7 +81,7 @@ class $18c3478e4f4e94c5$export$f54f4bde770cc5a6 {
73
81
  checkbox: checkbox
74
82
  });
75
83
  await this.user.keyboard('[Space]');
76
- } else await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, checkbox, interactionType);
84
+ } else await (0, $01a4eeee86094c77$exports.pressElement)(this.user, checkbox, interactionType);
77
85
  }
78
86
  /**
79
87
  * Returns the checkboxgroup.
@@ -83,22 +91,14 @@ class $18c3478e4f4e94c5$export$f54f4bde770cc5a6 {
83
91
  /**
84
92
  * Returns the checkboxes.
85
93
  */ get checkboxes() {
86
- return (0, $7ADgU$testinglibraryreact.within)(this.checkboxgroup).queryAllByRole('checkbox');
94
+ return (0, $aZ766$testinglibraryreact.within)(this.checkboxgroup).queryAllByRole('checkbox');
87
95
  }
88
96
  /**
89
97
  * Returns the currently selected checkboxes in the checkboxgroup if any.
90
98
  */ get selectedCheckboxes() {
91
99
  return this.checkboxes.filter((checkbox)=>checkbox.checked || checkbox.getAttribute('aria-checked') === 'true');
92
100
  }
93
- constructor(opts){
94
- let { root: root, user: user, interactionType: interactionType } = opts;
95
- this.user = user;
96
- this._interactionType = interactionType || 'mouse';
97
- this._checkboxgroup = root;
98
- let checkboxgroup = (0, $7ADgU$testinglibraryreact.within)(root).queryAllByRole('group');
99
- if (checkboxgroup.length > 0) this._checkboxgroup = checkboxgroup[0];
100
- }
101
101
  }
102
102
 
103
103
 
104
- //# sourceMappingURL=checkboxgroup.main.js.map
104
+ //# sourceMappingURL=checkboxgroup.cjs.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAiBM,MAAM;IAMX,YAAY,IAA6B,CAAE;QACzC,IAAI,QAAC,IAAI,QAAE,IAAI,mBAAE,eAAe,EAAC,GAAG;QACpC,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,gBAAgB,GAAG,mBAAmB;QAE3C,IAAI,CAAC,cAAc,GAAG;QACtB,IAAI,gBAAgB,CAAA,GAAA,iCAAK,EAAE,MAAM,cAAc,CAAC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YAAY,WAAW,OAAO,CAAC,SAAS,aAAa;QACzD,IAAI,cAAc,IAChB,MAAM,IAAI,MAAM;QAGlB,IAAK,IAAI,IAAI,GAAG,IAAI,KAAK,GAAG,CAAC,cAAc,YAAY,IACrD,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;YAAC,OAAO,cAAc;QAAS;IAEvD;IAEA;;GAEC,GACD,MAAM,eAAe,IAA4B,EAAiB;QAChE,IAAI,YACF,QAAQ,mBACR,kBAAkB,IAAI,CAAC,gBAAgB,EACxC,GAAG;QAEJ,IAAI,OAAO,aAAa,YAAY,OAAO,aAAa,UACtD,WAAW,IAAI,CAAC,YAAY,CAAC;YAAC,qBAAqB;QAAQ;QAG7D,IAAI,CAAC,UACH,MAAM,IAAI,MAAM;aACX,IAAI,SAAS,YAAY,CAAC,aAC/B,MAAM,IAAI,MAAM;QAGlB,IAAI,oBAAoB,YAAY;YAClC,MAAM,IAAI,CAAC,0BAA0B,CAAC;0BAAC;YAAQ;YAC/C,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC3B,OACE,MAAM,CAAA,GAAA,sCAAW,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU;IAE5C;IAEA;;GAEC,GACD,IAAI,gBAA6B;QAC/B,OAAO,IAAI,CAAC,cAAc;IAC5B;IAEA;;GAEC,GACD,IAAI,aAA4B;QAC9B,OAAO,CAAA,GAAA,iCAAK,EAAE,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC;IACnD;IAEA;;GAEC,GACD,IAAI,qBAAoC;QACtC,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA,WAAY,AAAC,SAA8B,OAAO,IAAI,SAAS,YAAY,CAAC,oBAAoB;IAChI;AACF","sources":["packages/@react-aria/test-utils/src/checkboxgroup.ts"],"sourcesContent":["/*\n * Copyright 2025 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 {CheckboxGroupTesterOpts, UserOpts} from './types';\nimport {pressElement} from './events';\n\ninterface TriggerCheckboxOptions {\n /**\n * What interaction type to use when triggering a checkbox. Defaults to the interaction type set on the tester.\n */\n interactionType?: UserOpts['interactionType'],\n /**\n * The index, text, or node of the checkbox to toggle selection for.\n */\n checkbox: number | string | HTMLElement\n}\n\nexport class CheckboxGroupTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _checkboxgroup: HTMLElement;\n\n\n constructor(opts: CheckboxGroupTesterOpts) {\n let {root, user, interactionType} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n\n this._checkboxgroup = root;\n let checkboxgroup = within(root).queryAllByRole('group');\n if (checkboxgroup.length > 0) {\n this._checkboxgroup = checkboxgroup[0];\n }\n }\n\n /**\n * Set the interaction type used by the checkbox group tester.\n */\n setInteractionType(type: UserOpts['interactionType']): void {\n this._interactionType = type;\n }\n\n /**\n * Returns a checkbox matching the specified index or text content.\n */\n findCheckbox(opts: {checkboxIndexOrText: number | string}): HTMLElement {\n let {\n checkboxIndexOrText\n } = opts;\n\n let checkbox;\n if (typeof checkboxIndexOrText === 'number') {\n checkbox = this.checkboxes[checkboxIndexOrText];\n } else if (typeof checkboxIndexOrText === 'string') {\n let label = within(this.checkboxgroup).getByText(checkboxIndexOrText);\n\n // Label may wrap the checkbox, or the actual label may be a sibling span, or the checkbox div could have the label within it\n if (label) {\n checkbox = within(label).queryByRole('checkbox');\n if (!checkbox) {\n let labelWrapper = label.closest('label');\n if (labelWrapper) {\n checkbox = within(labelWrapper).queryByRole('checkbox');\n } else {\n checkbox = label.closest('[role=checkbox]');\n }\n }\n }\n }\n\n return checkbox;\n }\n\n private async keyboardNavigateToCheckbox(opts: {checkbox: HTMLElement}) {\n let {checkbox} = opts;\n let checkboxes = this.checkboxes;\n checkboxes = checkboxes.filter(checkbox => !(checkbox.hasAttribute('disabled') || checkbox.getAttribute('aria-disabled') === 'true'));\n if (checkboxes.length === 0) {\n throw new Error('Checkbox group doesnt have any non-disabled checkboxes. Please double check your checkbox group.');\n }\n\n let targetIndex = checkboxes.indexOf(checkbox);\n if (targetIndex === -1) {\n throw new Error('Checkbox provided is not in the checkbox group.');\n }\n\n if (!this.checkboxgroup.contains(document.activeElement)) {\n act(() => checkboxes[0].focus());\n }\n\n let currIndex = checkboxes.indexOf(document.activeElement as HTMLElement);\n if (currIndex === -1) {\n throw new Error('Active element is not in the checkbox group.');\n }\n\n for (let i = 0; i < Math.abs(targetIndex - currIndex); i++) {\n await this.user.tab({shift: targetIndex < currIndex});\n }\n };\n\n /**\n * Toggles the specified checkbox. Defaults to using the interaction type set on the checkbox tester.\n */\n async toggleCheckbox(opts: TriggerCheckboxOptions): Promise<void> {\n let {\n checkbox,\n interactionType = this._interactionType\n } = opts;\n\n if (typeof checkbox === 'string' || typeof checkbox === 'number') {\n checkbox = this.findCheckbox({checkboxIndexOrText: checkbox});\n }\n\n if (!checkbox) {\n throw new Error('Target checkbox not found in the checkboxgroup.');\n } else if (checkbox.hasAttribute('disabled')) {\n throw new Error('Target checkbox is disabled.');\n }\n\n if (interactionType === 'keyboard') {\n await this.keyboardNavigateToCheckbox({checkbox});\n await this.user.keyboard('[Space]');\n } else {\n await pressElement(this.user, checkbox, interactionType);\n }\n }\n\n /**\n * Returns the checkboxgroup.\n */\n get checkboxgroup(): HTMLElement {\n return this._checkboxgroup;\n }\n\n /**\n * Returns the checkboxes.\n */\n get checkboxes(): HTMLElement[] {\n return within(this.checkboxgroup).queryAllByRole('checkbox');\n }\n\n /**\n * Returns the currently selected checkboxes in the checkboxgroup if any.\n */\n get selectedCheckboxes(): HTMLElement[] {\n return this.checkboxes.filter(checkbox => (checkbox as HTMLInputElement).checked || checkbox.getAttribute('aria-checked') === 'true');\n }\n}\n"],"names":[],"version":3,"file":"checkboxgroup.cjs.map"}
@@ -1,5 +1,5 @@
1
- import {pressElement as $5d1eca18f92ad0e6$export$6ffa3eb717517feb} from "./events.mjs";
2
- import {within as $jmBF6$within, act as $jmBF6$act} from "@testing-library/react";
1
+ import {pressElement as $22d7d9b763402afa$export$6ffa3eb717517feb} from "./events.js";
2
+ import {within as $g4drr$within, act as $g4drr$act} from "@testing-library/react";
3
3
 
4
4
  /*
5
5
  * Copyright 2025 Adobe. All rights reserved.
@@ -13,7 +13,15 @@ import {within as $jmBF6$within, act as $jmBF6$act} from "@testing-library/react
13
13
  * governing permissions and limitations under the License.
14
14
  */
15
15
 
16
- class $8473f5d1df4c8eb7$export$f54f4bde770cc5a6 {
16
+ class $e7160b4be83b4967$export$f54f4bde770cc5a6 {
17
+ constructor(opts){
18
+ let { root: root, user: user, interactionType: interactionType } = opts;
19
+ this.user = user;
20
+ this._interactionType = interactionType || 'mouse';
21
+ this._checkboxgroup = root;
22
+ let checkboxgroup = (0, $g4drr$within)(root).queryAllByRole('group');
23
+ if (checkboxgroup.length > 0) this._checkboxgroup = checkboxgroup[0];
24
+ }
17
25
  /**
18
26
  * Set the interaction type used by the checkbox group tester.
19
27
  */ setInteractionType(type) {
@@ -26,13 +34,13 @@ class $8473f5d1df4c8eb7$export$f54f4bde770cc5a6 {
26
34
  let checkbox;
27
35
  if (typeof checkboxIndexOrText === 'number') checkbox = this.checkboxes[checkboxIndexOrText];
28
36
  else if (typeof checkboxIndexOrText === 'string') {
29
- let label = (0, $jmBF6$within)(this.checkboxgroup).getByText(checkboxIndexOrText);
37
+ let label = (0, $g4drr$within)(this.checkboxgroup).getByText(checkboxIndexOrText);
30
38
  // Label may wrap the checkbox, or the actual label may be a sibling span, or the checkbox div could have the label within it
31
39
  if (label) {
32
- checkbox = (0, $jmBF6$within)(label).queryByRole('checkbox');
40
+ checkbox = (0, $g4drr$within)(label).queryByRole('checkbox');
33
41
  if (!checkbox) {
34
42
  let labelWrapper = label.closest('label');
35
- if (labelWrapper) checkbox = (0, $jmBF6$within)(labelWrapper).queryByRole('checkbox');
43
+ if (labelWrapper) checkbox = (0, $g4drr$within)(labelWrapper).queryByRole('checkbox');
36
44
  else checkbox = label.closest('[role=checkbox]');
37
45
  }
38
46
  }
@@ -46,7 +54,7 @@ class $8473f5d1df4c8eb7$export$f54f4bde770cc5a6 {
46
54
  if (checkboxes.length === 0) throw new Error('Checkbox group doesnt have any non-disabled checkboxes. Please double check your checkbox group.');
47
55
  let targetIndex = checkboxes.indexOf(checkbox);
48
56
  if (targetIndex === -1) throw new Error('Checkbox provided is not in the checkbox group.');
49
- if (!this.checkboxgroup.contains(document.activeElement)) (0, $jmBF6$act)(()=>checkboxes[0].focus());
57
+ if (!this.checkboxgroup.contains(document.activeElement)) (0, $g4drr$act)(()=>checkboxes[0].focus());
50
58
  let currIndex = checkboxes.indexOf(document.activeElement);
51
59
  if (currIndex === -1) throw new Error('Active element is not in the checkbox group.');
52
60
  for(let i = 0; i < Math.abs(targetIndex - currIndex); i++)await this.user.tab({
@@ -67,7 +75,7 @@ class $8473f5d1df4c8eb7$export$f54f4bde770cc5a6 {
67
75
  checkbox: checkbox
68
76
  });
69
77
  await this.user.keyboard('[Space]');
70
- } else await (0, $5d1eca18f92ad0e6$export$6ffa3eb717517feb)(this.user, checkbox, interactionType);
78
+ } else await (0, $22d7d9b763402afa$export$6ffa3eb717517feb)(this.user, checkbox, interactionType);
71
79
  }
72
80
  /**
73
81
  * Returns the checkboxgroup.
@@ -77,23 +85,15 @@ class $8473f5d1df4c8eb7$export$f54f4bde770cc5a6 {
77
85
  /**
78
86
  * Returns the checkboxes.
79
87
  */ get checkboxes() {
80
- return (0, $jmBF6$within)(this.checkboxgroup).queryAllByRole('checkbox');
88
+ return (0, $g4drr$within)(this.checkboxgroup).queryAllByRole('checkbox');
81
89
  }
82
90
  /**
83
91
  * Returns the currently selected checkboxes in the checkboxgroup if any.
84
92
  */ get selectedCheckboxes() {
85
93
  return this.checkboxes.filter((checkbox)=>checkbox.checked || checkbox.getAttribute('aria-checked') === 'true');
86
94
  }
87
- constructor(opts){
88
- let { root: root, user: user, interactionType: interactionType } = opts;
89
- this.user = user;
90
- this._interactionType = interactionType || 'mouse';
91
- this._checkboxgroup = root;
92
- let checkboxgroup = (0, $jmBF6$within)(root).queryAllByRole('group');
93
- if (checkboxgroup.length > 0) this._checkboxgroup = checkboxgroup[0];
94
- }
95
95
  }
96
96
 
97
97
 
98
- export {$8473f5d1df4c8eb7$export$f54f4bde770cc5a6 as CheckboxGroupTester};
99
- //# sourceMappingURL=checkboxgroup.module.js.map
98
+ export {$e7160b4be83b4967$export$f54f4bde770cc5a6 as CheckboxGroupTester};
99
+ //# sourceMappingURL=checkboxgroup.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAiBM,MAAM;IAMX,YAAY,IAA6B,CAAE;QACzC,IAAI,QAAC,IAAI,QAAE,IAAI,mBAAE,eAAe,EAAC,GAAG;QACpC,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,gBAAgB,GAAG,mBAAmB;QAE3C,IAAI,CAAC,cAAc,GAAG;QACtB,IAAI,gBAAgB,CAAA,GAAA,aAAK,EAAE,MAAM,cAAc,CAAC;QAChD,IAAI,cAAc,MAAM,GAAG,GACzB,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC,EAAE;IAE1C;IAEA;;GAEC,GACD,mBAAmB,IAAiC,EAAQ;QAC1D,IAAI,CAAC,gBAAgB,GAAG;IAC1B;IAEA;;GAEC,GACD,aAAa,IAA4C,EAAe;QACtE,IAAI,uBACF,mBAAmB,EACpB,GAAG;QAEJ,IAAI;QACJ,IAAI,OAAO,wBAAwB,UACjC,WAAW,IAAI,CAAC,UAAU,CAAC,oBAAoB;aAC1C,IAAI,OAAO,wBAAwB,UAAU;YAClD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OAAO,aAAa,UACtD,WAAW,IAAI,CAAC,YAAY,CAAC;YAAC,qBAAqB;QAAQ;QAG7D,IAAI,CAAC,UACH,MAAM,IAAI,MAAM;aACX,IAAI,SAAS,YAAY,CAAC,aAC/B,MAAM,IAAI,MAAM;QAGlB,IAAI,oBAAoB,YAAY;YAClC,MAAM,IAAI,CAAC,0BAA0B,CAAC;0BAAC;YAAQ;YAC/C,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC3B,OACE,MAAM,CAAA,GAAA,yCAAW,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU;IAE5C;IAEA;;GAEC,GACD,IAAI,gBAA6B;QAC/B,OAAO,IAAI,CAAC,cAAc;IAC5B;IAEA;;GAEC,GACD,IAAI,aAA4B;QAC9B,OAAO,CAAA,GAAA,aAAK,EAAE,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC;IACnD;IAEA;;GAEC,GACD,IAAI,qBAAoC;QACtC,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA,WAAY,AAAC,SAA8B,OAAO,IAAI,SAAS,YAAY,CAAC,oBAAoB;IAChI;AACF","sources":["packages/@react-aria/test-utils/src/checkboxgroup.ts"],"sourcesContent":["/*\n * Copyright 2025 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 {CheckboxGroupTesterOpts, UserOpts} from './types';\nimport {pressElement} from './events';\n\ninterface TriggerCheckboxOptions {\n /**\n * What interaction type to use when triggering a checkbox. Defaults to the interaction type set on the tester.\n */\n interactionType?: UserOpts['interactionType'],\n /**\n * The index, text, or node of the checkbox to toggle selection for.\n */\n checkbox: number | string | HTMLElement\n}\n\nexport class CheckboxGroupTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _checkboxgroup: HTMLElement;\n\n\n constructor(opts: CheckboxGroupTesterOpts) {\n let {root, user, interactionType} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n\n this._checkboxgroup = root;\n let checkboxgroup = within(root).queryAllByRole('group');\n if (checkboxgroup.length > 0) {\n this._checkboxgroup = checkboxgroup[0];\n }\n }\n\n /**\n * Set the interaction type used by the checkbox group tester.\n */\n setInteractionType(type: UserOpts['interactionType']): void {\n this._interactionType = type;\n }\n\n /**\n * Returns a checkbox matching the specified index or text content.\n */\n findCheckbox(opts: {checkboxIndexOrText: number | string}): HTMLElement {\n let {\n checkboxIndexOrText\n } = opts;\n\n let checkbox;\n if (typeof checkboxIndexOrText === 'number') {\n checkbox = this.checkboxes[checkboxIndexOrText];\n } else if (typeof checkboxIndexOrText === 'string') {\n let label = within(this.checkboxgroup).getByText(checkboxIndexOrText);\n\n // Label may wrap the checkbox, or the actual label may be a sibling span, or the checkbox div could have the label within it\n if (label) {\n checkbox = within(label).queryByRole('checkbox');\n if (!checkbox) {\n let labelWrapper = label.closest('label');\n if (labelWrapper) {\n checkbox = within(labelWrapper).queryByRole('checkbox');\n } else {\n checkbox = label.closest('[role=checkbox]');\n }\n }\n }\n }\n\n return checkbox;\n }\n\n private async keyboardNavigateToCheckbox(opts: {checkbox: HTMLElement}) {\n let {checkbox} = opts;\n let checkboxes = this.checkboxes;\n checkboxes = checkboxes.filter(checkbox => !(checkbox.hasAttribute('disabled') || checkbox.getAttribute('aria-disabled') === 'true'));\n if (checkboxes.length === 0) {\n throw new Error('Checkbox group doesnt have any non-disabled checkboxes. Please double check your checkbox group.');\n }\n\n let targetIndex = checkboxes.indexOf(checkbox);\n if (targetIndex === -1) {\n throw new Error('Checkbox provided is not in the checkbox group.');\n }\n\n if (!this.checkboxgroup.contains(document.activeElement)) {\n act(() => checkboxes[0].focus());\n }\n\n let currIndex = checkboxes.indexOf(document.activeElement as HTMLElement);\n if (currIndex === -1) {\n throw new Error('Active element is not in the checkbox group.');\n }\n\n for (let i = 0; i < Math.abs(targetIndex - currIndex); i++) {\n await this.user.tab({shift: targetIndex < currIndex});\n }\n };\n\n /**\n * Toggles the specified checkbox. Defaults to using the interaction type set on the checkbox tester.\n */\n async toggleCheckbox(opts: TriggerCheckboxOptions): Promise<void> {\n let {\n checkbox,\n interactionType = this._interactionType\n } = opts;\n\n if (typeof checkbox === 'string' || typeof checkbox === 'number') {\n checkbox = this.findCheckbox({checkboxIndexOrText: checkbox});\n }\n\n if (!checkbox) {\n throw new Error('Target checkbox not found in the checkboxgroup.');\n } else if (checkbox.hasAttribute('disabled')) {\n throw new Error('Target checkbox is disabled.');\n }\n\n if (interactionType === 'keyboard') {\n await this.keyboardNavigateToCheckbox({checkbox});\n await this.user.keyboard('[Space]');\n } else {\n await pressElement(this.user, checkbox, interactionType);\n }\n }\n\n /**\n * Returns the checkboxgroup.\n */\n get checkboxgroup(): HTMLElement {\n return this._checkboxgroup;\n }\n\n /**\n * Returns the checkboxes.\n */\n get checkboxes(): HTMLElement[] {\n return within(this.checkboxgroup).queryAllByRole('checkbox');\n }\n\n /**\n * Returns the currently selected checkboxes in the checkboxgroup if any.\n */\n get selectedCheckboxes(): HTMLElement[] {\n return this.checkboxes.filter(checkbox => (checkbox as HTMLInputElement).checked || checkbox.getAttribute('aria-checked') === 'true');\n }\n}\n"],"names":[],"version":3,"file":"checkboxgroup.js.map"}
@@ -1,11 +1,11 @@
1
- var $f8PS3$testinglibraryreact = require("@testing-library/react");
1
+ var $btaxF$testinglibraryreact = require("@testing-library/react");
2
2
 
3
3
 
4
4
  function $parcel$export(e, n, v, s) {
5
5
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
6
  }
7
7
 
8
- $parcel$export(module.exports, "ComboBoxTester", () => $15e4b71f2b6c4964$export$f97e14e96d71ab3b);
8
+ $parcel$export(module.exports, "ComboBoxTester", function () { return $2cdddd94ee78eafe$export$f97e14e96d71ab3b; });
9
9
  /*
10
10
  * Copyright 2024 Adobe. All rights reserved.
11
11
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -17,7 +17,29 @@ $parcel$export(module.exports, "ComboBoxTester", () => $15e4b71f2b6c4964$export$
17
17
  * OF ANY KIND, either express or implied. See the License for the specific language
18
18
  * governing permissions and limitations under the License.
19
19
  */
20
- class $15e4b71f2b6c4964$export$f97e14e96d71ab3b {
20
+ class $2cdddd94ee78eafe$export$f97e14e96d71ab3b {
21
+ constructor(opts){
22
+ let { root: root, trigger: trigger, user: user, interactionType: interactionType } = opts;
23
+ this.user = user;
24
+ this._interactionType = interactionType || 'mouse';
25
+ // Handle case where element provided is a wrapper around the combobox. The expectation is that the user at least uses a ref/data attribute to
26
+ // query their combobox/combobox wrapper (in the case of RSP) which they then pass to thhis
27
+ this._combobox = root;
28
+ let combobox = (0, $btaxF$testinglibraryreact.within)(root).queryByRole('combobox');
29
+ if (combobox) this._combobox = combobox;
30
+ // This is for if user need to directly set the trigger button element (aka the element provided in setElement was the combobox input or the trigger is somewhere unexpected)
31
+ if (trigger) this._trigger = trigger;
32
+ else {
33
+ let buttons = (0, $btaxF$testinglibraryreact.within)(root).queryAllByRole('button', {
34
+ hidden: true
35
+ });
36
+ if (buttons.length === 1) trigger = buttons[0];
37
+ else if (buttons.length > 1) trigger = buttons.find((button)=>button.hasAttribute('aria-haspopup'));
38
+ // For cases like https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/ where the combobox
39
+ // is also the trigger button
40
+ this._trigger = trigger || this._combobox;
41
+ }
42
+ }
21
43
  /**
22
44
  * Set the interaction type used by the combobox tester.
23
45
  */ setInteractionType(type) {
@@ -34,7 +56,7 @@ class $15e4b71f2b6c4964$export$f97e14e96d71ab3b {
34
56
  if (triggerBehavior === 'focus') await this.user.click(combobox);
35
57
  else await this.user.click(trigger);
36
58
  } else if (interactionType === 'keyboard' && this._trigger != null) {
37
- (0, $f8PS3$testinglibraryreact.act)(()=>this._trigger.focus());
59
+ (0, $btaxF$testinglibraryreact.act)(()=>this._trigger.focus());
38
60
  if (triggerBehavior !== 'focus') await this.user.keyboard('{ArrowDown}');
39
61
  } else if (interactionType === 'touch') {
40
62
  if (triggerBehavior === 'focus') await this.user.pointer({
@@ -46,12 +68,12 @@ class $15e4b71f2b6c4964$export$f97e14e96d71ab3b {
46
68
  keys: '[TouchA]'
47
69
  });
48
70
  }
49
- await (0, $f8PS3$testinglibraryreact.waitFor)(()=>{
71
+ await (0, $btaxF$testinglibraryreact.waitFor)(()=>{
50
72
  if (!isDisabled && combobox.getAttribute('aria-controls') == null) throw new Error('No aria-controls found on combobox trigger element.');
51
73
  else return true;
52
74
  });
53
75
  let listBoxId = combobox.getAttribute('aria-controls');
54
- await (0, $f8PS3$testinglibraryreact.waitFor)(()=>{
76
+ await (0, $btaxF$testinglibraryreact.waitFor)(()=>{
55
77
  if (!isDisabled && (!listBoxId || document.getElementById(listBoxId) == null)) throw new Error(`Listbox with id of ${listBoxId} not found in document.`);
56
78
  else return true;
57
79
  });
@@ -64,7 +86,7 @@ class $15e4b71f2b6c4964$export$f97e14e96d71ab3b {
64
86
  let options = this.options();
65
87
  let listbox = this.listbox;
66
88
  if (typeof optionIndexOrText === 'number') option = options[optionIndexOrText];
67
- else if (typeof optionIndexOrText === 'string' && listbox != null) option = (0, $f8PS3$testinglibraryreact.within)(listbox).getByText(optionIndexOrText).closest('[role=option]');
89
+ else if (typeof optionIndexOrText === 'string' && listbox != null) option = (0, $btaxF$testinglibraryreact.within)(listbox).getByText(optionIndexOrText).closest('[role=option]');
68
90
  return option;
69
91
  }
70
92
  /**
@@ -89,7 +111,7 @@ class $15e4b71f2b6c4964$export$f97e14e96d71ab3b {
89
111
  target: option,
90
112
  keys: '[TouchA]'
91
113
  });
92
- if (option.getAttribute('href') == null) await (0, $f8PS3$testinglibraryreact.waitFor)(()=>{
114
+ if (option.getAttribute('href') == null) await (0, $btaxF$testinglibraryreact.waitFor)(()=>{
93
115
  if (document.contains(listbox)) throw new Error('Expected listbox element to not be in the document after selecting an option');
94
116
  else return true;
95
117
  });
@@ -100,9 +122,9 @@ class $15e4b71f2b6c4964$export$f97e14e96d71ab3b {
100
122
  */ async close() {
101
123
  let listbox = this.listbox;
102
124
  if (listbox) {
103
- (0, $f8PS3$testinglibraryreact.act)(()=>this.combobox.focus());
125
+ (0, $btaxF$testinglibraryreact.act)(()=>this.combobox.focus());
104
126
  await this.user.keyboard('[Escape]');
105
- await (0, $f8PS3$testinglibraryreact.waitFor)(()=>{
127
+ await (0, $btaxF$testinglibraryreact.waitFor)(()=>{
106
128
  if (document.contains(listbox)) throw new Error('Expected listbox element to not be in the document after selecting an option');
107
129
  else return true;
108
130
  });
@@ -128,14 +150,14 @@ class $15e4b71f2b6c4964$export$f97e14e96d71ab3b {
128
150
  * Returns the combobox's sections if present.
129
151
  */ get sections() {
130
152
  let listbox = this.listbox;
131
- return listbox ? (0, $f8PS3$testinglibraryreact.within)(listbox).queryAllByRole('group') : [];
153
+ return listbox ? (0, $btaxF$testinglibraryreact.within)(listbox).queryAllByRole('group') : [];
132
154
  }
133
155
  /**
134
156
  * Returns the combobox's options if present. Can be filtered to a subsection of the listbox if provided via `element`.
135
157
  */ options(opts = {}) {
136
158
  let { element: element = this.listbox } = opts;
137
159
  let options = [];
138
- if (element) options = (0, $f8PS3$testinglibraryreact.within)(element).queryAllByRole('option');
160
+ if (element) options = (0, $btaxF$testinglibraryreact.within)(element).queryAllByRole('option');
139
161
  return options;
140
162
  }
141
163
  /**
@@ -144,29 +166,7 @@ class $15e4b71f2b6c4964$export$f97e14e96d71ab3b {
144
166
  let focusedOptionId = this.combobox.getAttribute('aria-activedescendant');
145
167
  return focusedOptionId ? document.getElementById(focusedOptionId) : null;
146
168
  }
147
- constructor(opts){
148
- let { root: root, trigger: trigger, user: user, interactionType: interactionType } = opts;
149
- this.user = user;
150
- this._interactionType = interactionType || 'mouse';
151
- // Handle case where element provided is a wrapper around the combobox. The expectation is that the user at least uses a ref/data attribute to
152
- // query their combobox/combobox wrapper (in the case of RSP) which they then pass to thhis
153
- this._combobox = root;
154
- let combobox = (0, $f8PS3$testinglibraryreact.within)(root).queryByRole('combobox');
155
- if (combobox) this._combobox = combobox;
156
- // This is for if user need to directly set the trigger button element (aka the element provided in setElement was the combobox input or the trigger is somewhere unexpected)
157
- if (trigger) this._trigger = trigger;
158
- else {
159
- let buttons = (0, $f8PS3$testinglibraryreact.within)(root).queryAllByRole('button', {
160
- hidden: true
161
- });
162
- if (buttons.length === 1) trigger = buttons[0];
163
- else if (buttons.length > 1) trigger = buttons.find((button)=>button.hasAttribute('aria-haspopup'));
164
- // For cases like https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/ where the combobox
165
- // is also the trigger button
166
- this._trigger = trigger || this._combobox;
167
- }
168
- }
169
169
  }
170
170
 
171
171
 
172
- //# sourceMappingURL=combobox.main.js.map
172
+ //# sourceMappingURL=combobox.cjs.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAwBM,MAAM;IAMX,YAAY,IAAwB,CAAE;QACpC,IAAI,QAAC,IAAI,WAAE,OAAO,QAAE,IAAI,mBAAE,eAAe,EAAC,GAAG;QAC7C,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,gBAAgB,GAAG,mBAAmB;QAE3C,8IAA8I;QAC9I,2FAA2F;QAC3F,IAAI,CAAC,SAAS,GAAG;QACjB,IAAI,WAAW,CAAA,GAAA,iCAAK,EAAE,MAAM,WAAW,CAAC;QACxC,IAAI,UACF,IAAI,CAAC,SAAS,GAAG;QAGnB,6KAA6K;QAC7K,IAAI,SACF,IAAI,CAAC,QAAQ,GAAG;aACX;YACL,IAAI,UAAU,CAAA,GAAA,iCAAK,EAAE,MAAM,cAAc,CAAC,UAAU;gBAAC,QAA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AC;QAG3C,OAAO;IACT;IAEA;;GAEC,GACD,IAAI,gBAAoC;QACtC,IAAI,kBAAkB,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;QACjD,OAAO,kBAAkB,SAAS,cAAc,CAAC,mBAAmB;IACtE;AACF","sources":["packages/@react-aria/test-utils/src/combobox.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 {ComboBoxTesterOpts, UserOpts} from './types';\n\ninterface ComboBoxOpenOpts {\n /**\n * Whether the combobox opens on focus or needs to be manually opened via user action.\n * @default 'manual'\n */\n triggerBehavior?: 'focus' | 'manual',\n /**\n * What interaction type to use when opening the combobox. Defaults to the interaction type set on the tester.\n */\n interactionType?: UserOpts['interactionType']\n}\n\ninterface ComboBoxSelectOpts extends ComboBoxOpenOpts {\n /**\n * The index, text, or node of the option to select. Option nodes can be sourced via `options()`.\n */\n option: number | string | HTMLElement\n}\n\nexport class ComboBoxTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _combobox: HTMLElement;\n private _trigger: HTMLElement;\n\n constructor(opts: ComboBoxTesterOpts) {\n let {root, trigger, user, interactionType} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n\n // Handle case where element provided is a wrapper around the combobox. The expectation is that the user at least uses a ref/data attribute to\n // query their combobox/combobox wrapper (in the case of RSP) which they then pass to thhis\n this._combobox = root;\n let combobox = within(root).queryByRole('combobox');\n if (combobox) {\n this._combobox = combobox;\n }\n\n // This is for if user need to directly set the trigger button element (aka the element provided in setElement was the combobox input or the trigger is somewhere unexpected)\n if (trigger) {\n this._trigger = trigger;\n } else {\n let buttons = within(root).queryAllByRole('button', {hidden: true});\n\n if (buttons.length === 1) {\n trigger = buttons[0];\n } else if (buttons.length > 1) {\n trigger = buttons.find(button => button.hasAttribute('aria-haspopup'));\n }\n\n // For cases like https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/ where the combobox\n // is also the trigger button\n this._trigger = trigger || this._combobox;\n }\n }\n\n /**\n * Set the interaction type used by the combobox tester.\n */\n setInteractionType(type: UserOpts['interactionType']): void {\n this._interactionType = type;\n }\n\n /**\n * Opens the combobox dropdown. Defaults to using the interaction type set on the combobox tester.\n */\n async open(opts: ComboBoxOpenOpts = {}): Promise<void> {\n let {triggerBehavior = 'manual', interactionType = this._interactionType} = opts;\n let trigger = this.trigger;\n let combobox = this.combobox;\n let isDisabled = trigger!.hasAttribute('disabled');\n\n if (interactionType === 'mouse') {\n if (triggerBehavior === 'focus') {\n await this.user.click(combobox);\n } else {\n await this.user.click(trigger);\n }\n } else if (interactionType === 'keyboard' && this._trigger != null) {\n act(() => this._trigger!.focus());\n if (triggerBehavior !== 'focus') {\n await this.user.keyboard('{ArrowDown}');\n }\n } else if (interactionType === 'touch') {\n if (triggerBehavior === 'focus') {\n await this.user.pointer({target: combobox, keys: '[TouchA]'});\n } else {\n await this.user.pointer({target: trigger, keys: '[TouchA]'});\n }\n }\n\n await waitFor(() => {\n if (!isDisabled && combobox.getAttribute('aria-controls') == null) {\n throw new Error('No aria-controls found on combobox trigger element.');\n } else {\n return true;\n }\n });\n let listBoxId = combobox.getAttribute('aria-controls');\n await waitFor(() => {\n if (!isDisabled && (!listBoxId || document.getElementById(listBoxId) == null)) {\n throw new Error(`Listbox with id of ${listBoxId} not found in document.`);\n } else {\n return true;\n }\n });\n }\n\n /**\n * Returns an option matching the specified index or text content.\n */\n findOption(opts: {optionIndexOrText: number | string}): HTMLElement {\n let {\n optionIndexOrText\n } = opts;\n\n let option;\n let options = this.options();\n let listbox = this.listbox;\n\n if (typeof optionIndexOrText === 'number') {\n option = options[optionIndexOrText];\n } else if (typeof optionIndexOrText === 'string' && listbox != null) {\n option = (within(listbox!).getByText(optionIndexOrText).closest('[role=option]'))! as HTMLElement;\n }\n\n return option;\n }\n\n /**\n * Selects the desired combobox option. Defaults to using the interaction type set on the combobox tester. If necessary, will open the combobox dropdown beforehand.\n * The desired option can be targeted via the option's node, the option's text, or the option's index.\n */\n async selectOption(opts: ComboBoxSelectOpts): Promise<void> {\n let {option, triggerBehavior, interactionType = this._interactionType} = opts;\n if (!this.combobox.getAttribute('aria-controls')) {\n await this.open({triggerBehavior});\n }\n\n let listbox = this.listbox;\n if (!listbox) {\n throw new Error('Combobox\\'s listbox not found.');\n }\n\n if (listbox) {\n if (typeof option === 'string' || typeof option === 'number') {\n option = this.findOption({optionIndexOrText: option});\n }\n\n if (!option) {\n throw new Error('Target option not found in the listbox.');\n }\n\n // TODO: keyboard method of selecting the the option is a bit tricky unless I simply simulate the user pressing the down arrow\n // the required amount of times to reach the option. For now just click the option even in keyboard mode\n if (interactionType === 'mouse' || interactionType === 'keyboard') {\n await this.user.click(option);\n } else {\n await this.user.pointer({target: option, keys: '[TouchA]'});\n }\n\n if (option.getAttribute('href') == null) {\n await waitFor(() => {\n if (document.contains(listbox)) {\n throw new Error('Expected listbox element to not be in the document after selecting an option');\n } else {\n return true;\n }\n });\n }\n } else {\n throw new Error(\"Attempted to select a option in the combobox, but the listbox wasn't found.\");\n }\n }\n\n /**\n * Closes the combobox dropdown.\n */\n async close(): Promise<void> {\n let listbox = this.listbox;\n if (listbox) {\n act(() => this.combobox.focus());\n await this.user.keyboard('[Escape]');\n\n await waitFor(() => {\n if (document.contains(listbox)) {\n throw new Error('Expected listbox element to not be in the document after selecting an option');\n } else {\n return true;\n }\n });\n }\n }\n\n /**\n * Returns the combobox.\n */\n get combobox(): HTMLElement {\n return this._combobox;\n }\n\n /**\n * Returns the combobox trigger button.\n */\n get trigger(): HTMLElement {\n return this._trigger;\n }\n\n /**\n * Returns the combobox's listbox if present.\n */\n get listbox(): HTMLElement | null {\n let listBoxId = this.combobox.getAttribute('aria-controls');\n return listBoxId ? document.getElementById(listBoxId) || null : null;\n }\n\n /**\n * Returns the combobox's sections if present.\n */\n get sections(): HTMLElement[] {\n let listbox = this.listbox;\n return listbox ? within(listbox).queryAllByRole('group') : [];\n }\n\n /**\n * Returns the combobox's options if present. Can be filtered to a subsection of the listbox if provided via `element`.\n */\n options(opts: {element?: HTMLElement} = {}): HTMLElement[] {\n let {element = this.listbox} = opts;\n let options = [];\n if (element) {\n options = within(element).queryAllByRole('option');\n }\n\n return options;\n }\n\n /**\n * Returns the currently focused option in the combobox's dropdown if any.\n */\n get focusedOption(): HTMLElement | null {\n let focusedOptionId = this.combobox.getAttribute('aria-activedescendant');\n return focusedOptionId ? document.getElementById(focusedOptionId) : null;\n }\n}\n"],"names":[],"version":3,"file":"combobox.cjs.map"}
@@ -1,4 +1,4 @@
1
- import {act as $1n52X$act, waitFor as $1n52X$waitFor, within as $1n52X$within} from "@testing-library/react";
1
+ import {within as $d5vWN$within, act as $d5vWN$act, waitFor as $d5vWN$waitFor} from "@testing-library/react";
2
2
 
3
3
  /*
4
4
  * Copyright 2024 Adobe. All rights reserved.
@@ -11,7 +11,29 @@ import {act as $1n52X$act, waitFor as $1n52X$waitFor, within as $1n52X$within} f
11
11
  * OF ANY KIND, either express or implied. See the License for the specific language
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
- class $dab75f394483aa9c$export$f97e14e96d71ab3b {
14
+ class $a2202d8b369e6a8a$export$f97e14e96d71ab3b {
15
+ constructor(opts){
16
+ let { root: root, trigger: trigger, user: user, interactionType: interactionType } = opts;
17
+ this.user = user;
18
+ this._interactionType = interactionType || 'mouse';
19
+ // Handle case where element provided is a wrapper around the combobox. The expectation is that the user at least uses a ref/data attribute to
20
+ // query their combobox/combobox wrapper (in the case of RSP) which they then pass to thhis
21
+ this._combobox = root;
22
+ let combobox = (0, $d5vWN$within)(root).queryByRole('combobox');
23
+ if (combobox) this._combobox = combobox;
24
+ // This is for if user need to directly set the trigger button element (aka the element provided in setElement was the combobox input or the trigger is somewhere unexpected)
25
+ if (trigger) this._trigger = trigger;
26
+ else {
27
+ let buttons = (0, $d5vWN$within)(root).queryAllByRole('button', {
28
+ hidden: true
29
+ });
30
+ if (buttons.length === 1) trigger = buttons[0];
31
+ else if (buttons.length > 1) trigger = buttons.find((button)=>button.hasAttribute('aria-haspopup'));
32
+ // For cases like https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/ where the combobox
33
+ // is also the trigger button
34
+ this._trigger = trigger || this._combobox;
35
+ }
36
+ }
15
37
  /**
16
38
  * Set the interaction type used by the combobox tester.
17
39
  */ setInteractionType(type) {
@@ -28,7 +50,7 @@ class $dab75f394483aa9c$export$f97e14e96d71ab3b {
28
50
  if (triggerBehavior === 'focus') await this.user.click(combobox);
29
51
  else await this.user.click(trigger);
30
52
  } else if (interactionType === 'keyboard' && this._trigger != null) {
31
- (0, $1n52X$act)(()=>this._trigger.focus());
53
+ (0, $d5vWN$act)(()=>this._trigger.focus());
32
54
  if (triggerBehavior !== 'focus') await this.user.keyboard('{ArrowDown}');
33
55
  } else if (interactionType === 'touch') {
34
56
  if (triggerBehavior === 'focus') await this.user.pointer({
@@ -40,12 +62,12 @@ class $dab75f394483aa9c$export$f97e14e96d71ab3b {
40
62
  keys: '[TouchA]'
41
63
  });
42
64
  }
43
- await (0, $1n52X$waitFor)(()=>{
65
+ await (0, $d5vWN$waitFor)(()=>{
44
66
  if (!isDisabled && combobox.getAttribute('aria-controls') == null) throw new Error('No aria-controls found on combobox trigger element.');
45
67
  else return true;
46
68
  });
47
69
  let listBoxId = combobox.getAttribute('aria-controls');
48
- await (0, $1n52X$waitFor)(()=>{
70
+ await (0, $d5vWN$waitFor)(()=>{
49
71
  if (!isDisabled && (!listBoxId || document.getElementById(listBoxId) == null)) throw new Error(`Listbox with id of ${listBoxId} not found in document.`);
50
72
  else return true;
51
73
  });
@@ -58,7 +80,7 @@ class $dab75f394483aa9c$export$f97e14e96d71ab3b {
58
80
  let options = this.options();
59
81
  let listbox = this.listbox;
60
82
  if (typeof optionIndexOrText === 'number') option = options[optionIndexOrText];
61
- else if (typeof optionIndexOrText === 'string' && listbox != null) option = (0, $1n52X$within)(listbox).getByText(optionIndexOrText).closest('[role=option]');
83
+ else if (typeof optionIndexOrText === 'string' && listbox != null) option = (0, $d5vWN$within)(listbox).getByText(optionIndexOrText).closest('[role=option]');
62
84
  return option;
63
85
  }
64
86
  /**
@@ -83,7 +105,7 @@ class $dab75f394483aa9c$export$f97e14e96d71ab3b {
83
105
  target: option,
84
106
  keys: '[TouchA]'
85
107
  });
86
- if (option.getAttribute('href') == null) await (0, $1n52X$waitFor)(()=>{
108
+ if (option.getAttribute('href') == null) await (0, $d5vWN$waitFor)(()=>{
87
109
  if (document.contains(listbox)) throw new Error('Expected listbox element to not be in the document after selecting an option');
88
110
  else return true;
89
111
  });
@@ -94,9 +116,9 @@ class $dab75f394483aa9c$export$f97e14e96d71ab3b {
94
116
  */ async close() {
95
117
  let listbox = this.listbox;
96
118
  if (listbox) {
97
- (0, $1n52X$act)(()=>this.combobox.focus());
119
+ (0, $d5vWN$act)(()=>this.combobox.focus());
98
120
  await this.user.keyboard('[Escape]');
99
- await (0, $1n52X$waitFor)(()=>{
121
+ await (0, $d5vWN$waitFor)(()=>{
100
122
  if (document.contains(listbox)) throw new Error('Expected listbox element to not be in the document after selecting an option');
101
123
  else return true;
102
124
  });
@@ -122,14 +144,14 @@ class $dab75f394483aa9c$export$f97e14e96d71ab3b {
122
144
  * Returns the combobox's sections if present.
123
145
  */ get sections() {
124
146
  let listbox = this.listbox;
125
- return listbox ? (0, $1n52X$within)(listbox).queryAllByRole('group') : [];
147
+ return listbox ? (0, $d5vWN$within)(listbox).queryAllByRole('group') : [];
126
148
  }
127
149
  /**
128
150
  * Returns the combobox's options if present. Can be filtered to a subsection of the listbox if provided via `element`.
129
151
  */ options(opts = {}) {
130
152
  let { element: element = this.listbox } = opts;
131
153
  let options = [];
132
- if (element) options = (0, $1n52X$within)(element).queryAllByRole('option');
154
+ if (element) options = (0, $d5vWN$within)(element).queryAllByRole('option');
133
155
  return options;
134
156
  }
135
157
  /**
@@ -138,30 +160,8 @@ class $dab75f394483aa9c$export$f97e14e96d71ab3b {
138
160
  let focusedOptionId = this.combobox.getAttribute('aria-activedescendant');
139
161
  return focusedOptionId ? document.getElementById(focusedOptionId) : null;
140
162
  }
141
- constructor(opts){
142
- let { root: root, trigger: trigger, user: user, interactionType: interactionType } = opts;
143
- this.user = user;
144
- this._interactionType = interactionType || 'mouse';
145
- // Handle case where element provided is a wrapper around the combobox. The expectation is that the user at least uses a ref/data attribute to
146
- // query their combobox/combobox wrapper (in the case of RSP) which they then pass to thhis
147
- this._combobox = root;
148
- let combobox = (0, $1n52X$within)(root).queryByRole('combobox');
149
- if (combobox) this._combobox = combobox;
150
- // This is for if user need to directly set the trigger button element (aka the element provided in setElement was the combobox input or the trigger is somewhere unexpected)
151
- if (trigger) this._trigger = trigger;
152
- else {
153
- let buttons = (0, $1n52X$within)(root).queryAllByRole('button', {
154
- hidden: true
155
- });
156
- if (buttons.length === 1) trigger = buttons[0];
157
- else if (buttons.length > 1) trigger = buttons.find((button)=>button.hasAttribute('aria-haspopup'));
158
- // For cases like https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/ where the combobox
159
- // is also the trigger button
160
- this._trigger = trigger || this._combobox;
161
- }
162
- }
163
163
  }
164
164
 
165
165
 
166
- export {$dab75f394483aa9c$export$f97e14e96d71ab3b as ComboBoxTester};
167
- //# sourceMappingURL=combobox.module.js.map
166
+ export {$a2202d8b369e6a8a$export$f97e14e96d71ab3b as ComboBoxTester};
167
+ //# sourceMappingURL=combobox.js.map