@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,5 +1,5 @@
1
- import {pressElement as $5d1eca18f92ad0e6$export$6ffa3eb717517feb} from "./events.mjs";
2
- import {within as $im2y9$within, act as $im2y9$act} from "@testing-library/react";
1
+ import {pressElement as $22d7d9b763402afa$export$6ffa3eb717517feb} from "./events.js";
2
+ import {within as $7d80g$within, act as $7d80g$act} from "@testing-library/react";
3
3
 
4
4
  /*
5
5
  * Copyright 2024 Adobe. All rights reserved.
@@ -13,7 +13,16 @@ import {within as $im2y9$within, act as $im2y9$act} from "@testing-library/react
13
13
  * governing permissions and limitations under the License.
14
14
  */
15
15
 
16
- class $e615c34a00448a49$export$f1539bff3fc7d485 {
16
+ class $e1a5bc7455cf5719$export$f1539bff3fc7d485 {
17
+ constructor(opts){
18
+ let { root: root, user: user, interactionType: interactionType, direction: direction } = opts;
19
+ this.user = user;
20
+ this._interactionType = interactionType || 'mouse';
21
+ this._direction = direction || 'ltr';
22
+ this._tablist = root;
23
+ let tablist = (0, $7d80g$within)(root).queryAllByRole('tablist');
24
+ if (tablist.length > 0) this._tablist = tablist[0];
25
+ }
17
26
  /**
18
27
  * Set the interaction type used by the tabs tester.
19
28
  */ setInteractionType(type) {
@@ -27,24 +36,23 @@ class $e615c34a00448a49$export$f1539bff3fc7d485 {
27
36
  let tab;
28
37
  let tabs = this.tabs;
29
38
  if (typeof tabIndexOrText === 'number') tab = tabs[tabIndexOrText];
30
- else if (typeof tabIndexOrText === 'string') tab = (0, $im2y9$within)(this._tablist).getByText(tabIndexOrText).closest('[role=tab]');
39
+ else if (typeof tabIndexOrText === 'string') tab = (0, $7d80g$within)(this._tablist).getByText(tabIndexOrText).closest('[role=tab]');
31
40
  return tab;
32
41
  }
33
42
  // TODO: also quite similar across more utils albeit with orientation, refactor to make generic
34
43
  async keyboardNavigateToTab(opts) {
35
44
  let { tab: tab, orientation: orientation = 'vertical' } = opts;
36
45
  let tabs = this.tabs;
46
+ tabs = tabs.filter((tab)=>!(tab.hasAttribute('disabled') || tab.getAttribute('aria-disabled') === 'true'));
47
+ if (tabs.length === 0) throw new Error('Tablist doesnt have any non-disabled tabs. Please double check your tabs implementation.');
37
48
  let targetIndex = tabs.indexOf(tab);
38
49
  if (targetIndex === -1) throw new Error('Tab provided is not in the tablist');
39
50
  if (!this._tablist.contains(document.activeElement)) {
40
51
  let selectedTab = this.selectedTab;
41
- if (selectedTab != null) (0, $im2y9$act)(()=>selectedTab.focus());
42
- else (0, $im2y9$act)(()=>{
43
- var _tabs_find;
44
- return (_tabs_find = tabs.find((tab)=>!(tab.hasAttribute('disabled') || tab.getAttribute('aria-disabled') === 'true'))) === null || _tabs_find === void 0 ? void 0 : _tabs_find.focus();
45
- });
52
+ if (selectedTab != null) (0, $7d80g$act)(()=>selectedTab.focus());
53
+ else (0, $7d80g$act)(()=>tabs[0]?.focus());
46
54
  }
47
- let currIndex = this.tabs.indexOf(document.activeElement);
55
+ let currIndex = tabs.indexOf(document.activeElement);
48
56
  if (currIndex === -1) throw new Error('ActiveElement is not in the tablist');
49
57
  let arrowUp = 'ArrowUp';
50
58
  let arrowDown = 'ArrowDown';
@@ -70,14 +78,14 @@ class $e615c34a00448a49$export$f1539bff3fc7d485 {
70
78
  if (!tab) throw new Error('Target tab not found in the tablist.');
71
79
  else if (tab.hasAttribute('disabled')) throw new Error('Target tab is disabled.');
72
80
  if (interactionType === 'keyboard') {
73
- if (document.activeElement !== this._tablist && !this._tablist.contains(document.activeElement)) (0, $im2y9$act)(()=>this._tablist.focus());
81
+ if (document.activeElement !== this._tablist && !this._tablist.contains(document.activeElement)) (0, $7d80g$act)(()=>this._tablist.focus());
74
82
  let tabsOrientation = this._tablist.getAttribute('aria-orientation') || 'horizontal';
75
83
  await this.keyboardNavigateToTab({
76
84
  tab: tab,
77
85
  orientation: tabsOrientation
78
86
  });
79
87
  if (manualActivation) await this.user.keyboard('[Enter]');
80
- } else await (0, $5d1eca18f92ad0e6$export$6ffa3eb717517feb)(this.user, tab, interactionType);
88
+ } else await (0, $22d7d9b763402afa$export$6ffa3eb717517feb)(this.user, tab, interactionType);
81
89
  }
82
90
  /**
83
91
  * Returns the tablist.
@@ -98,7 +106,7 @@ class $e615c34a00448a49$export$f1539bff3fc7d485 {
98
106
  /**
99
107
  * Returns the tabs in the tablist.
100
108
  */ get tabs() {
101
- return (0, $im2y9$within)(this.tablist).queryAllByRole('tab');
109
+ return (0, $7d80g$within)(this.tablist).queryAllByRole('tab');
102
110
  }
103
111
  /**
104
112
  * Returns the currently selected tab in the tablist if any.
@@ -108,21 +116,11 @@ class $e615c34a00448a49$export$f1539bff3fc7d485 {
108
116
  /**
109
117
  * Returns the currently active tabpanel if any.
110
118
  */ get activeTabpanel() {
111
- var _this_selectedTab;
112
- let activeTabpanelId = (_this_selectedTab = this.selectedTab) === null || _this_selectedTab === void 0 ? void 0 : _this_selectedTab.getAttribute('aria-controls');
119
+ let activeTabpanelId = this.selectedTab?.getAttribute('aria-controls');
113
120
  return activeTabpanelId ? document.getElementById(activeTabpanelId) : null;
114
121
  }
115
- constructor(opts){
116
- let { root: root, user: user, interactionType: interactionType, direction: direction } = opts;
117
- this.user = user;
118
- this._interactionType = interactionType || 'mouse';
119
- this._direction = direction || 'ltr';
120
- this._tablist = root;
121
- let tablist = (0, $im2y9$within)(root).queryAllByRole('tablist');
122
- if (tablist.length > 0) this._tablist = tablist[0];
123
- }
124
122
  }
125
123
 
126
124
 
127
- export {$e615c34a00448a49$export$f1539bff3fc7d485 as TabsTester};
128
- //# sourceMappingURL=tabs.module.js.map
125
+ export {$e1a5bc7455cf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CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,aAAa,GAC5F,CAAA,GAAA,UAAE,EAAE,IAAM,IAAI,CAAC,QAAQ,CAAC,KAAK;YAG/B,IAAI,kBAAkB,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,uBAAuB;YACxE,MAAM,IAAI,CAAC,qBAAqB,CAAC;qBAAC;gBAAK,aAAa;YAA8B;YAClF,IAAI,kBACF,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;QAE7B,OACE,MAAM,CAAA,GAAA,yCAAW,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK;IAEvC;IAEA;;GAEC,GACD,IAAI,UAAuB;QACzB,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEA;;GAEC,GACD,IAAI,YAA2B;QAC7B,IAAI,YAAY,EAAE;QAClB,KAAK,IAAI,OAAO,IAAI,CAAC,IAAI,CAAE;YACzB,IAAI,YAAY,IAAI,YAAY,CAAC;YACjC,IAAI,QAAQ,aAAa,OAAO,SAAS,cAAc,CAAC,aAAa;YACrE,IAAI,SAAS,MACX,UAAU,IAAI,CAAC;QAEnB;QAEA,OAAO;IACT;IAEA;;GAEC,GACD,IAAI,OAAsB;QACxB,OAAO,CAAA,GAAA,aAAK,EAAE,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC;IAC7C;IAEA;;GAEC,GACD,IAAI,cAAkC;QACpC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,MAAO,IAAI,YAAY,CAAC,qBAAqB,WAAW;IAChF;IAEA;;GAEC,GACD,IAAI,iBAAqC;QACvC,IAAI,mBAAmB,IAAI,CAAC,WAAW,EAAE,aAAa;QACtD,OAAO,mBAAmB,SAAS,cAAc,CAAC,oBAAoB;IACxE;AACF","sources":["packages/@react-aria/test-utils/src/tabs.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {act, within} from '@testing-library/react';\nimport {Direction, Orientation, TabsTesterOpts, UserOpts} from './types';\nimport {pressElement} from './events';\n\ninterface TriggerTabOptions {\n /**\n * What interaction type to use when triggering a tab. Defaults to the interaction type set on the tester.\n */\n interactionType?: UserOpts['interactionType'],\n /**\n * The index, text, or node of the tab to toggle selection for.\n */\n tab: number | string | HTMLElement,\n /**\n * Whether the tab needs to be activated manually rather than on focus.\n */\n manualActivation?: boolean\n}\n\nexport class TabsTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _tablist: HTMLElement;\n private _direction: Direction;\n\n constructor(opts: TabsTesterOpts) {\n let {root, user, interactionType, direction} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n this._direction = direction || 'ltr';\n\n this._tablist = root;\n let tablist = within(root).queryAllByRole('tablist');\n if (tablist.length > 0) {\n this._tablist = tablist[0];\n }\n }\n\n /**\n * Set the interaction type used by the tabs tester.\n */\n setInteractionType(type: UserOpts['interactionType']): void {\n this._interactionType = type;\n }\n\n // TODO: This is pretty similar across most the utils, refactor to make it generic?\n /**\n * Returns a tab matching the specified index or text content.\n */\n findTab(opts: {tabIndexOrText: number | string}): HTMLElement {\n let {\n tabIndexOrText\n } = opts;\n\n let tab;\n let tabs = this.tabs;\n if (typeof tabIndexOrText === 'number') {\n tab = tabs[tabIndexOrText];\n } else if (typeof tabIndexOrText === 'string') {\n tab = (within(this._tablist).getByText(tabIndexOrText).closest('[role=tab]'))! as HTMLElement;\n }\n\n return tab;\n }\n\n // TODO: also quite similar across more utils albeit with orientation, refactor to make generic\n private async keyboardNavigateToTab(opts: {tab: HTMLElement, orientation?: Orientation}) {\n let {tab, orientation = 'vertical'} = opts;\n let tabs = this.tabs;\n tabs = tabs.filter(tab => !(tab.hasAttribute('disabled') || tab.getAttribute('aria-disabled') === 'true'));\n if (tabs.length === 0) {\n throw new Error('Tablist doesnt have any non-disabled tabs. Please double check your tabs implementation.');\n }\n\n let targetIndex = tabs.indexOf(tab);\n if (targetIndex === -1) {\n throw new Error('Tab provided is not in the tablist');\n }\n\n if (!this._tablist.contains(document.activeElement)) {\n let selectedTab = this.selectedTab;\n if (selectedTab != null) {\n act(() => selectedTab.focus());\n } else {\n act(() => tabs[0]?.focus());\n }\n }\n\n let currIndex = tabs.indexOf(document.activeElement as HTMLElement);\n if (currIndex === -1) {\n throw new Error('ActiveElement is not in the tablist');\n }\n\n let arrowUp = 'ArrowUp';\n let arrowDown = 'ArrowDown';\n if (orientation === 'horizontal') {\n if (this._direction === 'ltr') {\n arrowUp = 'ArrowLeft';\n arrowDown = 'ArrowRight';\n } else {\n arrowUp = 'ArrowRight';\n arrowDown = 'ArrowLeft';\n }\n }\n\n let movementDirection = targetIndex > currIndex ? 'down' : 'up';\n for (let i = 0; i < Math.abs(targetIndex - currIndex); i++) {\n await this.user.keyboard(`[${movementDirection === 'down' ? arrowDown : arrowUp}]`);\n }\n };\n\n /**\n * Triggers the specified tab. Defaults to using the interaction type set on the tabs tester.\n */\n async triggerTab(opts: TriggerTabOptions): Promise<void> {\n let {\n tab,\n interactionType = this._interactionType,\n manualActivation\n } = opts;\n\n if (typeof tab === 'string' || typeof tab === 'number') {\n tab = this.findTab({tabIndexOrText: tab});\n }\n\n if (!tab) {\n throw new Error('Target tab not found in the tablist.');\n } else if (tab.hasAttribute('disabled')) {\n throw new Error('Target tab is disabled.');\n }\n\n if (interactionType === 'keyboard') {\n if (document.activeElement !== this._tablist && !this._tablist.contains(document.activeElement)) {\n act(() => this._tablist.focus());\n }\n\n let tabsOrientation = this._tablist.getAttribute('aria-orientation') || 'horizontal';\n await this.keyboardNavigateToTab({tab, orientation: tabsOrientation as Orientation});\n if (manualActivation) {\n await this.user.keyboard('[Enter]');\n }\n } else {\n await pressElement(this.user, tab, interactionType);\n }\n }\n\n /**\n * Returns the tablist.\n */\n get tablist(): HTMLElement {\n return this._tablist;\n }\n\n /**\n * Returns the tabpanels.\n */\n get tabpanels(): HTMLElement[] {\n let tabpanels = [] as HTMLElement[];\n for (let tab of this.tabs) {\n let controlId = tab.getAttribute('aria-controls');\n let panel = controlId != null ? document.getElementById(controlId) : null;\n if (panel != null) {\n tabpanels.push(panel);\n }\n }\n\n return tabpanels;\n }\n\n /**\n * Returns the tabs in the tablist.\n */\n get tabs(): HTMLElement[] {\n return within(this.tablist).queryAllByRole('tab');\n }\n\n /**\n * Returns the currently selected tab in the tablist if any.\n */\n get selectedTab(): HTMLElement | null {\n return this.tabs.find(tab => tab.getAttribute('aria-selected') === 'true') || null;\n }\n\n /**\n * Returns the currently active tabpanel if any.\n */\n get activeTabpanel(): HTMLElement | null {\n let activeTabpanelId = this.selectedTab?.getAttribute('aria-controls');\n return activeTabpanelId ? document.getElementById(activeTabpanelId) : null;\n }\n}\n"],"names":[],"version":3,"file":"tabs.js.map"}
@@ -0,0 +1,87 @@
1
+
2
+ var $parcel$global =
3
+ typeof globalThis !== 'undefined'
4
+ ? globalThis
5
+ : typeof self !== 'undefined'
6
+ ? self
7
+ : typeof window !== 'undefined'
8
+ ? window
9
+ : typeof global !== 'undefined'
10
+ ? global
11
+ : {};
12
+
13
+ function $parcel$export(e, n, v, s) {
14
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
15
+ }
16
+
17
+ $parcel$export(module.exports, "installMouseEvent", function () { return $5e3c75beb0dad42b$export$de31e3987c917741; });
18
+ $parcel$export(module.exports, "installPointerEvent", function () { return $5e3c75beb0dad42b$export$82f0b04c1d69a901; });
19
+ /*
20
+ * Copyright 2023 Adobe. All rights reserved.
21
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
22
+ * you may not use this file except in compliance with the License. You may obtain a copy
23
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
24
+ *
25
+ * Unless required by applicable law or agreed to in writing, software distributed under
26
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
27
+ * OF ANY KIND, either express or implied. See the License for the specific language
28
+ * governing permissions and limitations under the License.
29
+ */ /**
30
+ * Enables reading pageX/pageY from fireEvent.mouse*(..., {pageX: ..., pageY: ...}).
31
+ */ function $5e3c75beb0dad42b$export$de31e3987c917741() {
32
+ let oldMouseEvent = MouseEvent;
33
+ beforeAll(()=>{
34
+ $parcel$global.MouseEvent = class FakeMouseEvent extends MouseEvent {
35
+ constructor(name, init){
36
+ super(name, init);
37
+ this._init = init;
38
+ }
39
+ get pageX() {
40
+ return this._init.pageX;
41
+ }
42
+ get pageY() {
43
+ return this._init.pageY;
44
+ }
45
+ };
46
+ });
47
+ afterAll(()=>{
48
+ $parcel$global.MouseEvent = oldMouseEvent;
49
+ });
50
+ }
51
+ function $5e3c75beb0dad42b$export$93965c727ae9548a() {
52
+ // @ts-ignore
53
+ $parcel$global.PointerEvent = class FakePointerEvent extends MouseEvent {
54
+ constructor(name, init){
55
+ super(name, init);
56
+ this._init = init;
57
+ }
58
+ get pointerType() {
59
+ return this._init.pointerType ?? 'mouse';
60
+ }
61
+ get pointerId() {
62
+ return this._init.pointerId;
63
+ }
64
+ get pageX() {
65
+ return this._init.pageX;
66
+ }
67
+ get pageY() {
68
+ return this._init.pageY;
69
+ }
70
+ get width() {
71
+ return this._init.width;
72
+ }
73
+ get height() {
74
+ return this._init.height;
75
+ }
76
+ };
77
+ }
78
+ function $5e3c75beb0dad42b$export$82f0b04c1d69a901() {
79
+ beforeAll($5e3c75beb0dad42b$export$93965c727ae9548a);
80
+ afterAll(()=>{
81
+ // @ts-ignore
82
+ delete $parcel$global.PointerEvent;
83
+ });
84
+ }
85
+
86
+
87
+ //# sourceMappingURL=testSetup.cjs.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED;;CAEC,GACM,SAAS;IACd,IAAI,gBAAgB;IACpB,UAAU;QACR,eAAO,UAAU,GAAG,MAAM,uBAAuB;YAE/C,YAAY,IAAI,EAAE,IAAI,CAAE;gBACtB,KAAK,CAAC,MAAM;gBACZ,IAAI,CAAC,KAAK,GAAG;YACf;YACA,IAAI,QAAQ;gBACV,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK;YACzB;YACA,IAAI,QAAQ;gBACV,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK;YACzB;QACF;IACF;IACA,SAAS;QACP,eAAO,UAAU,GAAG;IACtB;AACF;AAEO,SAAS;IACd,aAAa;IACb,eAAO,YAAY,GAAG,MAAM,yBAAyB;QAEnD,YAAY,IAAI,EAAE,IAAI,CAAE;YACtB,KAAK,CAAC,MAAM;YACZ,IAAI,CAAC,KAAK,GAAG;QACf;QACA,IAAI,cAAc;YAChB,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI;QACnC;QACA,IAAI,YAAY;YACd,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS;QAC7B;QACA,IAAI,QAAQ;YACV,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK;QACzB;QACA,IAAI,QAAQ;YACV,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK;QACzB;QACA,IAAI,QAAQ;YACV,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK;QACzB;QACA,IAAI,SAAS;YACX,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM;QAC1B;IACF;AACF;AAEO,SAAS;IACd,UAAU;IACV,SAAS;QACP,aAAa;QACb,OAAO,eAAO,YAAY;IAC5B;AACF","sources":["packages/@react-aria/test-utils/src/testSetup.ts"],"sourcesContent":["/*\n * Copyright 2023 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/**\n * Enables reading pageX/pageY from fireEvent.mouse*(..., {pageX: ..., pageY: ...}).\n */\nexport function installMouseEvent(): void {\n let oldMouseEvent = MouseEvent;\n beforeAll(() => {\n global.MouseEvent = class FakeMouseEvent extends MouseEvent {\n _init: {pageX: number, pageY: number};\n constructor(name, init) {\n super(name, init);\n this._init = init;\n }\n get pageX() {\n return this._init.pageX;\n }\n get pageY() {\n return this._init.pageY;\n }\n };\n });\n afterAll(() => {\n global.MouseEvent = oldMouseEvent;\n });\n}\n\nexport function definePointerEvent(): void {\n // @ts-ignore\n global.PointerEvent = class FakePointerEvent extends MouseEvent {\n _init: {pageX: number, pageY: number, pointerType: string, pointerId: number, width: number, height: number};\n constructor(name, init) {\n super(name, init);\n this._init = init;\n }\n get pointerType() {\n return this._init.pointerType ?? 'mouse';\n }\n get pointerId() {\n return this._init.pointerId;\n }\n get pageX() {\n return this._init.pageX;\n }\n get pageY() {\n return this._init.pageY;\n }\n get width() {\n return this._init.width;\n }\n get height() {\n return this._init.height;\n }\n };\n}\n\nexport function installPointerEvent(): void {\n beforeAll(definePointerEvent);\n afterAll(() => {\n // @ts-ignore\n delete global.PointerEvent;\n });\n}\n"],"names":[],"version":3,"file":"testSetup.cjs.map"}
@@ -0,0 +1,81 @@
1
+
2
+ var $parcel$global =
3
+ typeof globalThis !== 'undefined'
4
+ ? globalThis
5
+ : typeof self !== 'undefined'
6
+ ? self
7
+ : typeof window !== 'undefined'
8
+ ? window
9
+ : typeof global !== 'undefined'
10
+ ? global
11
+ : {};
12
+ /*
13
+ * Copyright 2023 Adobe. All rights reserved.
14
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
15
+ * you may not use this file except in compliance with the License. You may obtain a copy
16
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software distributed under
19
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
20
+ * OF ANY KIND, either express or implied. See the License for the specific language
21
+ * governing permissions and limitations under the License.
22
+ */ /**
23
+ * Enables reading pageX/pageY from fireEvent.mouse*(..., {pageX: ..., pageY: ...}).
24
+ */ function $448e93e3748c7958$export$de31e3987c917741() {
25
+ let oldMouseEvent = MouseEvent;
26
+ beforeAll(()=>{
27
+ $parcel$global.MouseEvent = class FakeMouseEvent extends MouseEvent {
28
+ constructor(name, init){
29
+ super(name, init);
30
+ this._init = init;
31
+ }
32
+ get pageX() {
33
+ return this._init.pageX;
34
+ }
35
+ get pageY() {
36
+ return this._init.pageY;
37
+ }
38
+ };
39
+ });
40
+ afterAll(()=>{
41
+ $parcel$global.MouseEvent = oldMouseEvent;
42
+ });
43
+ }
44
+ function $448e93e3748c7958$export$93965c727ae9548a() {
45
+ // @ts-ignore
46
+ $parcel$global.PointerEvent = class FakePointerEvent extends MouseEvent {
47
+ constructor(name, init){
48
+ super(name, init);
49
+ this._init = init;
50
+ }
51
+ get pointerType() {
52
+ return this._init.pointerType ?? 'mouse';
53
+ }
54
+ get pointerId() {
55
+ return this._init.pointerId;
56
+ }
57
+ get pageX() {
58
+ return this._init.pageX;
59
+ }
60
+ get pageY() {
61
+ return this._init.pageY;
62
+ }
63
+ get width() {
64
+ return this._init.width;
65
+ }
66
+ get height() {
67
+ return this._init.height;
68
+ }
69
+ };
70
+ }
71
+ function $448e93e3748c7958$export$82f0b04c1d69a901() {
72
+ beforeAll($448e93e3748c7958$export$93965c727ae9548a);
73
+ afterAll(()=>{
74
+ // @ts-ignore
75
+ delete $parcel$global.PointerEvent;
76
+ });
77
+ }
78
+
79
+
80
+ export {$448e93e3748c7958$export$de31e3987c917741 as installMouseEvent, $448e93e3748c7958$export$93965c727ae9548a as definePointerEvent, $448e93e3748c7958$export$82f0b04c1d69a901 as installPointerEvent};
81
+ //# sourceMappingURL=testSetup.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED;;CAEC,GACM,SAAS;IACd,IAAI,gBAAgB;IACpB,UAAU;QACR,eAAO,UAAU,GAAG,MAAM,uBAAuB;YAE/C,YAAY,IAAI,EAAE,IAAI,CAAE;gBACtB,KAAK,CAAC,MAAM;gBACZ,IAAI,CAAC,KAAK,GAAG;YACf;YACA,IAAI,QAAQ;gBACV,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK;YACzB;YACA,IAAI,QAAQ;gBACV,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK;YACzB;QACF;IACF;IACA,SAAS;QACP,eAAO,UAAU,GAAG;IACtB;AACF;AAEO,SAAS;IACd,aAAa;IACb,eAAO,YAAY,GAAG,MAAM,yBAAyB;QAEnD,YAAY,IAAI,EAAE,IAAI,CAAE;YACtB,KAAK,CAAC,MAAM;YACZ,IAAI,CAAC,KAAK,GAAG;QACf;QACA,IAAI,cAAc;YAChB,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI;QACnC;QACA,IAAI,YAAY;YACd,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS;QAC7B;QACA,IAAI,QAAQ;YACV,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK;QACzB;QACA,IAAI,QAAQ;YACV,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK;QACzB;QACA,IAAI,QAAQ;YACV,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK;QACzB;QACA,IAAI,SAAS;YACX,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM;QAC1B;IACF;AACF;AAEO,SAAS;IACd,UAAU;IACV,SAAS;QACP,aAAa;QACb,OAAO,eAAO,YAAY;IAC5B;AACF","sources":["packages/@react-aria/test-utils/src/testSetup.ts"],"sourcesContent":["/*\n * Copyright 2023 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/**\n * Enables reading pageX/pageY from fireEvent.mouse*(..., {pageX: ..., pageY: ...}).\n */\nexport function installMouseEvent(): void {\n let oldMouseEvent = MouseEvent;\n beforeAll(() => {\n global.MouseEvent = class FakeMouseEvent extends MouseEvent {\n _init: {pageX: number, pageY: number};\n constructor(name, init) {\n super(name, init);\n this._init = init;\n }\n get pageX() {\n return this._init.pageX;\n }\n get pageY() {\n return this._init.pageY;\n }\n };\n });\n afterAll(() => {\n global.MouseEvent = oldMouseEvent;\n });\n}\n\nexport function definePointerEvent(): void {\n // @ts-ignore\n global.PointerEvent = class FakePointerEvent extends MouseEvent {\n _init: {pageX: number, pageY: number, pointerType: string, pointerId: number, width: number, height: number};\n constructor(name, init) {\n super(name, init);\n this._init = init;\n }\n get pointerType() {\n return this._init.pointerType ?? 'mouse';\n }\n get pointerId() {\n return this._init.pointerId;\n }\n get pageX() {\n return this._init.pageX;\n }\n get pageY() {\n return this._init.pageY;\n }\n get width() {\n return this._init.width;\n }\n get height() {\n return this._init.height;\n }\n };\n}\n\nexport function installPointerEvent(): void {\n beforeAll(definePointerEvent);\n afterAll(() => {\n // @ts-ignore\n delete global.PointerEvent;\n });\n}\n"],"names":[],"version":3,"file":"testSetup.js.map"}
@@ -1,12 +1,12 @@
1
- var $5a8bfe1663b8366d$exports = require("./events.main.js");
2
- var $cVFA5$testinglibraryreact = require("@testing-library/react");
1
+ var $01a4eeee86094c77$exports = require("./events.cjs");
2
+ var $6QyUo$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, "TreeTester", () => $9c221bde173322ba$export$4445864b14128396);
9
+ $parcel$export(module.exports, "TreeTester", function () { return $c7f71a5a893f714a$export$4445864b14128396; });
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,17 @@ $parcel$export(module.exports, "TreeTester", () => $9c221bde173322ba$export$4445
19
19
  * governing permissions and limitations under the License.
20
20
  */
21
21
 
22
- class $9c221bde173322ba$export$4445864b14128396 {
22
+ class $c7f71a5a893f714a$export$4445864b14128396 {
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._tree = root;
29
+ // TODO: should all helpers do this?
30
+ let tree = (0, $6QyUo$testinglibraryreact.within)(root).queryByRole('treegrid');
31
+ if (root.getAttribute('role') !== 'treegrid' && tree) this._tree = tree;
32
+ }
23
33
  /**
24
34
  * Set the interaction type used by the tree tester.
25
35
  */ setInteractionType(type) {
@@ -31,17 +41,17 @@ class $9c221bde173322ba$export$4445864b14128396 {
31
41
  let { rowIndexOrText: rowIndexOrText } = opts;
32
42
  let row;
33
43
  if (typeof rowIndexOrText === 'number') row = this.rows[rowIndexOrText];
34
- else if (typeof rowIndexOrText === 'string') row = (0, $cVFA5$testinglibraryreact.within)(this.tree).getByText(rowIndexOrText).closest('[role=row]');
44
+ else if (typeof rowIndexOrText === 'string') row = (0, $6QyUo$testinglibraryreact.within)(this.tree).getByText(rowIndexOrText).closest('[role=row]');
35
45
  return row;
36
46
  }
37
47
  // TODO: RTL
38
48
  async keyboardNavigateToRow(opts) {
39
49
  let { row: row, selectionOnNav: selectionOnNav = 'default' } = opts;
40
- let altKey = (0, $5a8bfe1663b8366d$exports.getAltKey)();
50
+ let altKey = (0, $01a4eeee86094c77$exports.getAltKey)();
41
51
  let rows = this.rows;
42
52
  let targetIndex = rows.indexOf(row);
43
53
  if (targetIndex === -1) throw new Error('Option provided is not in the tree');
44
- if (document.activeElement !== this._tree && !this._tree.contains(document.activeElement)) (0, $cVFA5$testinglibraryreact.act)(()=>this._tree.focus());
54
+ if (document.activeElement !== this._tree && !this._tree.contains(document.activeElement)) (0, $6QyUo$testinglibraryreact.act)(()=>this._tree.focus());
45
55
  if (document.activeElement === this.tree) await this.user.keyboard(`${selectionOnNav === 'none' ? `[${altKey}>]` : ''}[ArrowDown]${selectionOnNav === 'none' ? `[/${altKey}]` : ''}`);
46
56
  else if (this._tree.contains(document.activeElement) && document.activeElement.getAttribute('role') !== 'row') do await this.user.keyboard('[ArrowLeft]');
47
57
  while (document.activeElement.getAttribute('role') !== 'row');
@@ -57,16 +67,16 @@ class $9c221bde173322ba$export$4445864b14128396 {
57
67
  * Note that this will endevor to always add/remove JUST the provided row to the set of selected rows.
58
68
  */ async toggleRowSelection(opts) {
59
69
  let { row: row, needsLongPress: needsLongPress, checkboxSelection: checkboxSelection = true, interactionType: interactionType = this._interactionType, selectionBehavior: selectionBehavior = 'toggle' } = opts;
60
- let altKey = (0, $5a8bfe1663b8366d$exports.getAltKey)();
61
- let metaKey = (0, $5a8bfe1663b8366d$exports.getMetaKey)();
70
+ let altKey = (0, $01a4eeee86094c77$exports.getAltKey)();
71
+ let metaKey = (0, $01a4eeee86094c77$exports.getMetaKey)();
62
72
  if (typeof row === 'string' || typeof row === 'number') row = this.findRow({
63
73
  rowIndexOrText: row
64
74
  });
65
75
  if (!row) throw new Error('Target row not found in the tree.');
66
- let rowCheckbox = (0, $cVFA5$testinglibraryreact.within)(row).queryByRole('checkbox');
76
+ let rowCheckbox = (0, $6QyUo$testinglibraryreact.within)(row).queryByRole('checkbox');
67
77
  // TODO: we early return here because the checkbox can't be keyboard navigated to if the row is disabled usually
68
78
  // but we may to check for disabledBehavior (aka if the disable row gets skipped when keyboard navigating or not)
69
- if (interactionType === 'keyboard' && ((rowCheckbox === null || rowCheckbox === void 0 ? void 0 : rowCheckbox.getAttribute('disabled')) === '' || (row === null || row === void 0 ? void 0 : row.getAttribute('aria-disabled')) === 'true')) return;
79
+ if (interactionType === 'keyboard' && (rowCheckbox?.getAttribute('disabled') === '' || row?.getAttribute('aria-disabled') === 'true')) return;
70
80
  // this would be better than the check to do nothing in events.ts
71
81
  // also, it'd be good to be able to trigger selection on the row instead of having to go to the checkbox directly
72
82
  if (interactionType === 'keyboard' && (!checkboxSelection || !rowCheckbox)) {
@@ -79,13 +89,13 @@ class $9c221bde173322ba$export$4445864b14128396 {
79
89
  if (selectionBehavior === 'replace') await this.user.keyboard(`[/${altKey}]`);
80
90
  return;
81
91
  }
82
- if (rowCheckbox && checkboxSelection) await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, rowCheckbox, interactionType);
92
+ if (rowCheckbox && checkboxSelection) await (0, $01a4eeee86094c77$exports.pressElement)(this.user, rowCheckbox, interactionType);
83
93
  else {
84
- let cell = (0, $cVFA5$testinglibraryreact.within)(row).getAllByRole('gridcell')[0];
94
+ let cell = (0, $6QyUo$testinglibraryreact.within)(row).getAllByRole('gridcell')[0];
85
95
  if (needsLongPress && interactionType === 'touch') {
86
96
  if (this._advanceTimer == null) throw new Error('No advanceTimers provided for long press.');
87
97
  // Note that long press interactions with rows is strictly touch only for grid rows
88
- await (0, $5a8bfe1663b8366d$exports.triggerLongPress)({
98
+ await (0, $01a4eeee86094c77$exports.triggerLongPress)({
89
99
  element: cell,
90
100
  advanceTimer: this._advanceTimer,
91
101
  pointerOpts: {
@@ -95,7 +105,7 @@ class $9c221bde173322ba$export$4445864b14128396 {
95
105
  } else {
96
106
  // TODO add modifiers here? Maybe move into pressElement if we get more cases for different types of modifier keys
97
107
  if (selectionBehavior === 'replace' && interactionType !== 'touch') await this.user.keyboard(`[${metaKey}>]`);
98
- await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, row, interactionType);
108
+ await (0, $01a4eeee86094c77$exports.pressElement)(this.user, row, interactionType);
99
109
  if (selectionBehavior === 'replace' && interactionType !== 'touch') await this.user.keyboard(`[/${metaKey}]`);
100
110
  }
101
111
  }
@@ -104,7 +114,7 @@ class $9c221bde173322ba$export$4445864b14128396 {
104
114
  * Toggles the expansion for the specified tree row. Defaults to using the interaction type set on the tree tester.
105
115
  */ async toggleRowExpansion(opts) {
106
116
  let { row: row, interactionType: interactionType = this._interactionType } = opts;
107
- if (!this.tree.contains(document.activeElement)) await (0, $cVFA5$testinglibraryreact.act)(async ()=>{
117
+ if (!this.tree.contains(document.activeElement)) await (0, $6QyUo$testinglibraryreact.act)(async ()=>{
108
118
  this.tree.focus();
109
119
  });
110
120
  if (typeof row === 'string' || typeof row === 'number') row = this.findRow({
@@ -113,10 +123,10 @@ class $9c221bde173322ba$export$4445864b14128396 {
113
123
  if (!row) throw new Error('Target row not found in the tree.');
114
124
  else if (row.getAttribute('aria-expanded') == null) throw new Error('Target row is not expandable.');
115
125
  if (interactionType === 'mouse' || interactionType === 'touch') {
116
- let rowExpander = (0, $cVFA5$testinglibraryreact.within)(row).getAllByRole('button')[0]; // what happens if the button is not first? how can we differentiate?
117
- await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, rowExpander, interactionType);
126
+ let rowExpander = (0, $6QyUo$testinglibraryreact.within)(row).getAllByRole('button')[0]; // what happens if the button is not first? how can we differentiate?
127
+ await (0, $01a4eeee86094c77$exports.pressElement)(this.user, rowExpander, interactionType);
118
128
  } else if (interactionType === 'keyboard') {
119
- if ((row === null || row === void 0 ? void 0 : row.getAttribute('aria-disabled')) === 'true') return;
129
+ if (row?.getAttribute('aria-disabled') === 'true') return;
120
130
  // TODO: We always Use Option/Ctrl when keyboard navigating so selection isn't changed
121
131
  // in selectionmode="replace"/highlight selection when navigating to the row that the user wants
122
132
  // to expand. Discuss if this is useful or not
@@ -137,14 +147,14 @@ class $9c221bde173322ba$export$4445864b14128396 {
137
147
  if (!row) throw new Error('Target row not found in the tree.');
138
148
  if (needsDoubleClick) await this.user.dblClick(row);
139
149
  else if (interactionType === 'keyboard') {
140
- if ((row === null || row === void 0 ? void 0 : row.getAttribute('aria-disabled')) === 'true') return;
150
+ if (row?.getAttribute('aria-disabled') === 'true') return;
141
151
  // TODO: same as above, uses the modifier key to make sure we don't modify selection state on row focus
142
152
  // as we keyboard navigate to the row we want activate
143
153
  await this.keyboardNavigateToRow({
144
154
  row: row
145
155
  });
146
156
  await this.user.keyboard('[Enter]');
147
- } else await (0, $5a8bfe1663b8366d$exports.pressElement)(this.user, row, interactionType);
157
+ } else await (0, $01a4eeee86094c77$exports.pressElement)(this.user, row, interactionType);
148
158
  }
149
159
  /**
150
160
  * Returns the tree.
@@ -154,8 +164,7 @@ class $9c221bde173322ba$export$4445864b14128396 {
154
164
  /**
155
165
  * Returns the tree's rows if any.
156
166
  */ get rows() {
157
- var _this;
158
- return (0, $cVFA5$testinglibraryreact.within)((_this = this) === null || _this === void 0 ? void 0 : _this.tree).queryAllByRole('row');
167
+ return (0, $6QyUo$testinglibraryreact.within)(this?.tree).queryAllByRole('row');
159
168
  }
160
169
  /**
161
170
  * Returns the tree's selected rows if any.
@@ -166,19 +175,9 @@ class $9c221bde173322ba$export$4445864b14128396 {
166
175
  * Returns the tree's cells if any. Can be filtered against a specific row if provided via `element`.
167
176
  */ cells(opts = {}) {
168
177
  let { element: element = this.tree } = opts;
169
- return (0, $cVFA5$testinglibraryreact.within)(element).queryAllByRole('gridcell');
170
- }
171
- constructor(opts){
172
- let { root: root, user: user, interactionType: interactionType, advanceTimer: advanceTimer } = opts;
173
- this.user = user;
174
- this._interactionType = interactionType || 'mouse';
175
- this._advanceTimer = advanceTimer;
176
- this._tree = root;
177
- // TODO: should all helpers do this?
178
- let tree = (0, $cVFA5$testinglibraryreact.within)(root).queryByRole('treegrid');
179
- if (root.getAttribute('role') !== 'treegrid' && tree) this._tree = tree;
178
+ return (0, $6QyUo$testinglibraryreact.within)(element).queryAllByRole('gridcell');
180
179
  }
181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,EAAE,SAAS,cAAc,CAAC;IACxC;AACF","sources":["packages/@react-aria/test-utils/src/tree.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {act, within} from '@testing-library/react';\nimport {BaseGridRowInteractionOpts, GridRowActionOpts, ToggleGridRowOpts, TreeTesterOpts, UserOpts} from './types';\nimport {getAltKey, getMetaKey, pressElement, triggerLongPress} from './events';\n\ninterface TreeToggleExpansionOpts extends BaseGridRowInteractionOpts {}\ninterface TreeToggleRowOpts extends ToggleGridRowOpts {}\ninterface TreeRowActionOpts extends GridRowActionOpts {}\n\n// TODO: this ended up being pretty much the same as gridlist, refactor so it extends from gridlist\nexport class TreeTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _advanceTimer: UserOpts['advanceTimer'];\n private _tree: HTMLElement;\n\n constructor(opts: TreeTesterOpts) {\n let {root, user, interactionType, advanceTimer} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n this._advanceTimer = advanceTimer;\n this._tree = root;\n // TODO: should all helpers do this?\n let tree = within(root).queryByRole('treegrid');\n if (root.getAttribute('role') !== 'treegrid' && tree) {\n this._tree = tree;\n }\n }\n\n /**\n * Set the interaction type used by the tree tester.\n */\n setInteractionType(type: UserOpts['interactionType']): void {\n this._interactionType = type;\n };\n\n /**\n * Returns a row matching the specified index or text content.\n */\n findRow(opts: {rowIndexOrText: number | string}): HTMLElement {\n let {\n rowIndexOrText\n } = opts;\n\n let row;\n if (typeof rowIndexOrText === 'number') {\n row = this.rows[rowIndexOrText];\n } else if (typeof rowIndexOrText === 'string') {\n row = (within(this.tree!).getByText(rowIndexOrText).closest('[role=row]'))! as HTMLElement;\n }\n\n return row;\n }\n\n // TODO: RTL\n private async keyboardNavigateToRow(opts: {row: HTMLElement, selectionOnNav?: 'default' | 'none'}) {\n let {row, selectionOnNav = 'default'} = opts;\n let altKey = getAltKey();\n let rows = this.rows;\n let targetIndex = rows.indexOf(row);\n if (targetIndex === -1) {\n throw new Error('Option provided is not in the tree');\n }\n\n if (document.activeElement !== this._tree && !this._tree.contains(document.activeElement)) {\n act(() => this._tree.focus());\n }\n\n if (document.activeElement === this.tree) {\n await this.user.keyboard(`${selectionOnNav === 'none' ? `[${altKey}>]` : ''}[ArrowDown]${selectionOnNav === 'none' ? `[/${altKey}]` : ''}`);\n } else if (this._tree.contains(document.activeElement) && document.activeElement!.getAttribute('role') !== 'row') {\n do {\n await this.user.keyboard('[ArrowLeft]');\n } while (document.activeElement!.getAttribute('role') !== 'row');\n }\n let currIndex = rows.indexOf(document.activeElement as HTMLElement);\n if (currIndex === -1) {\n throw new Error('ActiveElement is not in the tree');\n }\n let direction = targetIndex > currIndex ? 'down' : 'up';\n\n if (selectionOnNav === 'none') {\n await this.user.keyboard(`[${altKey}>]`);\n }\n for (let i = 0; i < Math.abs(targetIndex - currIndex); i++) {\n await this.user.keyboard(`[${direction === 'down' ? 'ArrowDown' : 'ArrowUp'}]`);\n }\n if (selectionOnNav === 'none') {\n await this.user.keyboard(`[/${altKey}]`);\n }\n };\n\n /**\n * Toggles the selection for the specified tree row. Defaults to using the interaction type set on the tree tester.\n * Note that this will endevor to always add/remove JUST the provided row to the set of selected rows.\n */\n async toggleRowSelection(opts: TreeToggleRowOpts): Promise<void> {\n let {\n row,\n needsLongPress,\n checkboxSelection = true,\n interactionType = this._interactionType,\n selectionBehavior = 'toggle'\n } = opts;\n\n let altKey = getAltKey();\n let metaKey = getMetaKey();\n\n if (typeof row === 'string' || typeof row === 'number') {\n row = this.findRow({rowIndexOrText: row});\n }\n\n if (!row) {\n throw new Error('Target row not found in the tree.');\n }\n\n let rowCheckbox = within(row).queryByRole('checkbox');\n\n // TODO: we early return here because the checkbox can't be keyboard navigated to if the row is disabled usually\n // but we may to check for disabledBehavior (aka if the disable row gets skipped when keyboard navigating or not)\n if (interactionType === 'keyboard' && (rowCheckbox?.getAttribute('disabled') === '' || row?.getAttribute('aria-disabled') === 'true')) {\n return;\n }\n\n // this would be better than the check to do nothing in events.ts\n // also, it'd be good to be able to trigger selection on the row instead of having to go to the checkbox directly\n if (interactionType === 'keyboard' && (!checkboxSelection || !rowCheckbox)) {\n await this.keyboardNavigateToRow({row, selectionOnNav: selectionBehavior === 'replace' ? 'none' : 'default'});\n if (selectionBehavior === 'replace') {\n await this.user.keyboard(`[${altKey}>]`);\n }\n await this.user.keyboard('[Space]');\n if (selectionBehavior === 'replace') {\n await this.user.keyboard(`[/${altKey}]`);\n }\n return;\n }\n if (rowCheckbox && checkboxSelection) {\n await pressElement(this.user, rowCheckbox, interactionType);\n } else {\n let cell = within(row).getAllByRole('gridcell')[0];\n if (needsLongPress && interactionType === 'touch') {\n if (this._advanceTimer == null) {\n throw new Error('No advanceTimers provided for long press.');\n }\n\n // Note that long press interactions with rows is strictly touch only for grid rows\n await triggerLongPress({element: cell, advanceTimer: this._advanceTimer, pointerOpts: {pointerType: 'touch'}});\n } else {\n // TODO add modifiers here? Maybe move into pressElement if we get more cases for different types of modifier keys\n if (selectionBehavior === 'replace' && interactionType !== 'touch') {\n await this.user.keyboard(`[${metaKey}>]`);\n }\n await pressElement(this.user, row, interactionType);\n if (selectionBehavior === 'replace' && interactionType !== 'touch') {\n await this.user.keyboard(`[/${metaKey}]`);\n }\n }\n }\n };\n\n /**\n * Toggles the expansion for the specified tree row. Defaults to using the interaction type set on the tree tester.\n */\n async toggleRowExpansion(opts: TreeToggleExpansionOpts): Promise<void> {\n let {\n row,\n interactionType = this._interactionType\n } = opts;\n if (!this.tree.contains(document.activeElement)) {\n await act(async () => {\n this.tree.focus();\n });\n }\n\n if (typeof row === 'string' || typeof row === 'number') {\n row = this.findRow({rowIndexOrText: row});\n }\n\n if (!row) {\n throw new Error('Target row not found in the tree.');\n } else if (row.getAttribute('aria-expanded') == null) {\n throw new Error('Target row is not expandable.');\n }\n\n if (interactionType === 'mouse' || interactionType === 'touch') {\n let rowExpander = within(row).getAllByRole('button')[0]; // what happens if the button is not first? how can we differentiate?\n await pressElement(this.user, rowExpander, interactionType);\n } else if (interactionType === 'keyboard') {\n if (row?.getAttribute('aria-disabled') === 'true') {\n return;\n }\n\n // TODO: We always Use Option/Ctrl when keyboard navigating so selection isn't changed\n // in selectionmode=\"replace\"/highlight selection when navigating to the row that the user wants\n // to expand. Discuss if this is useful or not\n await this.keyboardNavigateToRow({row});\n if (row.getAttribute('aria-expanded') === 'true') {\n await this.user.keyboard('[ArrowLeft]');\n } else {\n await this.user.keyboard('[ArrowRight]');\n }\n }\n };\n\n /**\n * Triggers the action for the specified tree row. Defaults to using the interaction type set on the tree tester.\n */\n async triggerRowAction(opts: TreeRowActionOpts): Promise<void> {\n let {\n row,\n needsDoubleClick,\n interactionType = this._interactionType\n } = opts;\n\n if (typeof row === 'string' || typeof row === 'number') {\n row = this.findRow({rowIndexOrText: row});\n }\n\n if (!row) {\n throw new Error('Target row not found in the tree.');\n }\n\n if (needsDoubleClick) {\n await this.user.dblClick(row);\n } else if (interactionType === 'keyboard') {\n if (row?.getAttribute('aria-disabled') === 'true') {\n return;\n }\n\n // TODO: same as above, uses the modifier key to make sure we don't modify selection state on row focus\n // as we keyboard navigate to the row we want activate\n await this.keyboardNavigateToRow({row});\n await this.user.keyboard('[Enter]');\n } else {\n await pressElement(this.user, row, interactionType);\n }\n };\n\n /**\n * Returns the tree.\n */\n get tree(): HTMLElement {\n return this._tree;\n }\n\n /**\n * Returns the tree's rows if any.\n */\n get rows(): HTMLElement[] {\n return within(this?.tree).queryAllByRole('row');\n }\n\n /**\n * Returns the tree's selected rows if any.\n */\n get selectedRows(): HTMLElement[] {\n return this.rows.filter(row => row.getAttribute('aria-selected') === 'true');\n }\n\n /**\n * Returns the tree's cells if any. Can be filtered against a specific row if provided via `element`.\n */\n cells(opts: {element?: HTMLElement} = {}): HTMLElement[] {\n let {element = this.tree} = opts;\n return within(element).queryAllByRole('gridcell');\n }\n}\n"],"names":[],"version":3,"file":"tree.cjs.map"}