@react-aria/test-utils 1.0.0-nightly.5042 → 1.0.0-rc.0

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 (124) hide show
  1. package/README.md +70 -0
  2. package/dist/import.mjs +6 -4
  3. package/dist/main.js +15 -23
  4. package/dist/main.js.map +1 -1
  5. package/dist/module.js +6 -4
  6. package/dist/module.js.map +1 -1
  7. package/dist/private/act.cjs +33 -0
  8. package/dist/private/act.cjs.map +1 -0
  9. package/dist/private/act.js +28 -0
  10. package/dist/private/act.js.map +1 -0
  11. package/dist/private/checkboxgroup.cjs +107 -0
  12. package/dist/private/checkboxgroup.cjs.map +1 -0
  13. package/dist/private/checkboxgroup.js +102 -0
  14. package/dist/private/checkboxgroup.js.map +1 -0
  15. package/dist/private/combobox.cjs +199 -0
  16. package/dist/private/combobox.cjs.map +1 -0
  17. package/dist/private/combobox.js +194 -0
  18. package/dist/private/combobox.js.map +1 -0
  19. package/dist/private/dialog.cjs +110 -0
  20. package/dist/private/dialog.cjs.map +1 -0
  21. package/dist/private/dialog.js +105 -0
  22. package/dist/private/dialog.js.map +1 -0
  23. package/dist/private/gridlist.cjs +173 -0
  24. package/dist/private/gridlist.cjs.map +1 -0
  25. package/dist/private/gridlist.js +168 -0
  26. package/dist/private/gridlist.js.map +1 -0
  27. package/dist/private/listbox.cjs +163 -0
  28. package/dist/private/listbox.cjs.map +1 -0
  29. package/dist/private/listbox.js +158 -0
  30. package/dist/private/listbox.js.map +1 -0
  31. package/dist/private/menu.cjs +265 -0
  32. package/dist/private/menu.cjs.map +1 -0
  33. package/dist/private/menu.js +260 -0
  34. package/dist/private/menu.js.map +1 -0
  35. package/dist/private/radiogroup.cjs +122 -0
  36. package/dist/private/radiogroup.cjs.map +1 -0
  37. package/dist/private/radiogroup.js +117 -0
  38. package/dist/private/radiogroup.js.map +1 -0
  39. package/dist/private/select.cjs +169 -0
  40. package/dist/private/select.cjs.map +1 -0
  41. package/dist/private/select.js +164 -0
  42. package/dist/private/select.js.map +1 -0
  43. package/dist/private/table.cjs +346 -0
  44. package/dist/private/table.cjs.map +1 -0
  45. package/dist/private/table.js +341 -0
  46. package/dist/private/table.js.map +1 -0
  47. package/dist/private/tabs.cjs +131 -0
  48. package/dist/private/tabs.cjs.map +1 -0
  49. package/dist/private/tabs.js +126 -0
  50. package/dist/private/tabs.js.map +1 -0
  51. package/dist/private/testSetup.cjs +87 -0
  52. package/dist/private/testSetup.cjs.map +1 -0
  53. package/dist/private/testSetup.js +81 -0
  54. package/dist/private/testSetup.js.map +1 -0
  55. package/dist/private/tree.cjs +181 -0
  56. package/dist/private/tree.cjs.map +1 -0
  57. package/dist/private/tree.js +176 -0
  58. package/dist/private/tree.js.map +1 -0
  59. package/dist/private/user.cjs +85 -0
  60. package/dist/private/user.cjs.map +1 -0
  61. package/dist/private/user.js +76 -0
  62. package/dist/private/user.js.map +1 -0
  63. package/dist/{userEventMaps.main.js → private/userEventMaps.cjs} +3 -3
  64. package/dist/private/userEventMaps.cjs.map +1 -0
  65. package/dist/{userEventMaps.mjs → private/userEventMaps.js} +3 -3
  66. package/dist/private/userEventMaps.js.map +1 -0
  67. package/dist/private/utils.cjs +136 -0
  68. package/dist/private/utils.cjs.map +1 -0
  69. package/dist/private/utils.js +127 -0
  70. package/dist/private/utils.js.map +1 -0
  71. package/dist/types/src/act.d.ts +4 -0
  72. package/dist/types/src/checkboxgroup.d.ts +47 -0
  73. package/dist/types/src/combobox.d.ts +87 -0
  74. package/dist/types/src/dialog.d.ts +37 -0
  75. package/dist/types/src/events.d.ts +25 -0
  76. package/dist/types/src/gridlist.d.ts +56 -0
  77. package/dist/types/src/index.d.ts +16 -0
  78. package/dist/types/src/listbox.d.ts +91 -0
  79. package/dist/types/src/menu.d.ts +112 -0
  80. package/dist/types/src/radiogroup.d.ts +47 -0
  81. package/dist/types/src/select.d.ts +74 -0
  82. package/dist/types/src/table.d.ts +120 -0
  83. package/dist/types/src/tabs.d.ts +59 -0
  84. package/dist/types/src/testSetup.d.ts +6 -0
  85. package/dist/types/src/tree.d.ts +62 -0
  86. package/dist/types/src/types.d.ts +143 -0
  87. package/dist/types/src/user.d.ts +49 -0
  88. package/dist/types/src/userEventMaps.d.ts +2 -0
  89. package/dist/types/src/utils.d.ts +29 -0
  90. package/package.json +26 -18
  91. package/src/act.ts +35 -0
  92. package/src/checkboxgroup.ts +165 -0
  93. package/src/combobox.ts +307 -0
  94. package/src/dialog.ts +155 -0
  95. package/src/gridlist.ts +278 -0
  96. package/src/index.ts +17 -3
  97. package/src/listbox.ts +300 -0
  98. package/src/menu.ts +479 -0
  99. package/src/radiogroup.ts +179 -0
  100. package/src/select.ts +273 -0
  101. package/src/table.ts +589 -0
  102. package/src/tabs.ts +204 -0
  103. package/src/testSetup.ts +41 -36
  104. package/src/tree.ts +290 -0
  105. package/src/types.ts +171 -0
  106. package/src/user.ts +153 -0
  107. package/src/userEventMaps.ts +1 -1
  108. package/src/utils.ts +155 -0
  109. package/dist/events.main.js +0 -37
  110. package/dist/events.main.js.map +0 -1
  111. package/dist/events.mjs +0 -31
  112. package/dist/events.module.js +0 -31
  113. package/dist/events.module.js.map +0 -1
  114. package/dist/testSetup.main.js +0 -82
  115. package/dist/testSetup.main.js.map +0 -1
  116. package/dist/testSetup.mjs +0 -76
  117. package/dist/testSetup.module.js +0 -76
  118. package/dist/testSetup.module.js.map +0 -1
  119. package/dist/types.d.ts +0 -16
  120. package/dist/types.d.ts.map +0 -1
  121. package/dist/userEventMaps.main.js.map +0 -1
  122. package/dist/userEventMaps.module.js +0 -38
  123. package/dist/userEventMaps.module.js.map +0 -1
  124. package/src/events.ts +0 -28
@@ -0,0 +1,176 @@
1
+ import {act as $1350703ef3ac1acc$export$3ba232387fd5d6dd} from "./act.js";
2
+ import {formatTargetNode as $b4e037a2907521c6$export$bc3bc4a9206bf789, getAltKey as $b4e037a2907521c6$export$6fc0ccaebd758b9d, getMetaKey as $b4e037a2907521c6$export$7943c508934e27ce, pressElement as $b4e037a2907521c6$export$6ffa3eb717517feb, triggerLongPress as $b4e037a2907521c6$export$3a22a5a9bc0fd3b} from "./utils.js";
3
+ import {within as $5Fhol$within} from "@testing-library/dom";
4
+
5
+ /*
6
+ * Copyright 2024 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */
16
+
17
+
18
+ class $d721d67b8ba87a3b$export$4445864b14128396 {
19
+ constructor(opts){
20
+ let { root: root, user: user, interactionType: interactionType, advanceTimer: advanceTimer, direction: direction } = opts;
21
+ this.user = user;
22
+ this._interactionType = interactionType || 'mouse';
23
+ this._advanceTimer = advanceTimer;
24
+ this._direction = direction || 'ltr';
25
+ this._tree = root;
26
+ if (root.getAttribute('role') !== 'treegrid') {
27
+ let tree = (0, $5Fhol$within)(root).queryByRole('treegrid');
28
+ if (tree) this._tree = tree;
29
+ }
30
+ }
31
+ /**
32
+ * Set the interaction type used by the tree tester.
33
+ */ setInteractionType(type) {
34
+ this._interactionType = type;
35
+ }
36
+ /**
37
+ * Returns a row matching the specified index or text content.
38
+ */ findRow(opts) {
39
+ let { indexOrText: indexOrText } = opts;
40
+ let row;
41
+ if (typeof indexOrText === 'number') row = this.getRows()[indexOrText];
42
+ else if (typeof indexOrText === 'string') row = (0, $5Fhol$within)(this.getTree()).getByText(indexOrText).closest('[role=row]');
43
+ return row;
44
+ }
45
+ async keyboardNavigateToRow(opts) {
46
+ let { row: row, selectionOnNav: selectionOnNav = 'default' } = opts;
47
+ let altKey = (0, $b4e037a2907521c6$export$6fc0ccaebd758b9d)();
48
+ let rows = this.getRows();
49
+ let targetIndex = rows.indexOf(row);
50
+ if (targetIndex === -1) throw new Error('Row provided is not in the tree');
51
+ if (document.activeElement !== this._tree && !this._tree.contains(document.activeElement)) (0, $1350703ef3ac1acc$export$3ba232387fd5d6dd)(()=>this._tree.focus());
52
+ let focusPrevKey = this._direction === 'rtl' ? 'ArrowRight' : 'ArrowLeft';
53
+ if (document.activeElement === this.getTree()) await this.user.keyboard(`${selectionOnNav === 'none' ? `[${altKey}>]` : ''}[ArrowDown]${selectionOnNav === 'none' ? `[/${altKey}]` : ''}`);
54
+ else if (this._tree.contains(document.activeElement) && document.activeElement.getAttribute('role') !== 'row') do await this.user.keyboard(`[${focusPrevKey}]`);
55
+ while (document.activeElement.getAttribute('role') !== 'row');
56
+ let currIndex = rows.indexOf(document.activeElement);
57
+ if (currIndex === -1) throw new Error('ActiveElement is not in the tree');
58
+ let direction = targetIndex > currIndex ? 'down' : 'up';
59
+ if (selectionOnNav === 'none') await this.user.keyboard(`[${altKey}>]`);
60
+ for(let i = 0; i < Math.abs(targetIndex - currIndex); i++)await this.user.keyboard(`[${direction === 'down' ? 'ArrowDown' : 'ArrowUp'}]`);
61
+ if (selectionOnNav === 'none') await this.user.keyboard(`[/${altKey}]`);
62
+ }
63
+ /**
64
+ * Toggles the selection for the specified tree row. Defaults to using the interaction type set on
65
+ * the tree tester. Note that this will endevor to always add/remove JUST the provided row to the
66
+ * set of selected rows.
67
+ */ async toggleRowSelection(opts) {
68
+ let { row: row, needsLongPress: needsLongPress, checkboxSelection: checkboxSelection = true, interactionType: interactionType = this._interactionType, selectionBehavior: selectionBehavior = 'toggle' } = opts;
69
+ let altKey = (0, $b4e037a2907521c6$export$6fc0ccaebd758b9d)();
70
+ let metaKey = (0, $b4e037a2907521c6$export$7943c508934e27ce)();
71
+ if (typeof row === 'string' || typeof row === 'number') row = this.findRow({
72
+ indexOrText: row
73
+ });
74
+ if (!row) throw new Error(`Target row "${(0, $b4e037a2907521c6$export$bc3bc4a9206bf789)(opts.row)}" not found in the tree.`);
75
+ let rowCheckbox = (0, $5Fhol$within)(row).queryByRole('checkbox');
76
+ if (rowCheckbox?.getAttribute('disabled') === '' || row?.getAttribute('aria-disabled') === 'true') throw new Error(`Cannot toggle selection on disabled row "${(0, $b4e037a2907521c6$export$bc3bc4a9206bf789)(opts.row)}".`);
77
+ // this would be better than the check to do nothing in events.ts
78
+ // also, it'd be good to be able to trigger selection on the row instead of having to go to the checkbox directly
79
+ if (interactionType === 'keyboard' && (!checkboxSelection || !rowCheckbox)) {
80
+ await this.keyboardNavigateToRow({
81
+ row: row,
82
+ selectionOnNav: selectionBehavior === 'replace' ? 'none' : 'default'
83
+ });
84
+ if (selectionBehavior === 'replace') await this.user.keyboard(`[${altKey}>]`);
85
+ await this.user.keyboard('[Space]');
86
+ if (selectionBehavior === 'replace') await this.user.keyboard(`[/${altKey}]`);
87
+ return;
88
+ }
89
+ if (rowCheckbox && checkboxSelection) await (0, $b4e037a2907521c6$export$6ffa3eb717517feb)(this.user, rowCheckbox, interactionType);
90
+ else {
91
+ let cell = (0, $5Fhol$within)(row).getAllByRole('gridcell')[0];
92
+ if (needsLongPress && interactionType === 'touch') // Note that long press interactions with rows is strictly touch only for grid rows
93
+ await (0, $b4e037a2907521c6$export$3a22a5a9bc0fd3b)({
94
+ element: cell,
95
+ advanceTimer: this._advanceTimer,
96
+ pointerOpts: {
97
+ pointerType: 'touch'
98
+ }
99
+ });
100
+ else {
101
+ if (selectionBehavior === 'replace' && interactionType !== 'touch') await this.user.keyboard(`[${metaKey}>]`);
102
+ await (0, $b4e037a2907521c6$export$6ffa3eb717517feb)(this.user, row, interactionType);
103
+ if (selectionBehavior === 'replace' && interactionType !== 'touch') await this.user.keyboard(`[/${metaKey}]`);
104
+ }
105
+ }
106
+ }
107
+ /**
108
+ * Toggles the expansion for the specified tree row. Defaults to using the interaction type set on
109
+ * the tree tester.
110
+ */ async toggleRowExpansion(opts) {
111
+ let { row: row, interactionType: interactionType = this._interactionType } = opts;
112
+ if (!this.getTree().contains(document.activeElement)) (0, $1350703ef3ac1acc$export$3ba232387fd5d6dd)(()=>this.getTree().focus());
113
+ if (typeof row === 'string' || typeof row === 'number') row = this.findRow({
114
+ indexOrText: row
115
+ });
116
+ if (!row) throw new Error(`Target row "${(0, $b4e037a2907521c6$export$bc3bc4a9206bf789)(opts.row)}" not found in the tree.`);
117
+ else if (row.getAttribute('aria-expanded') == null) throw new Error(`Target row "${(0, $b4e037a2907521c6$export$bc3bc4a9206bf789)(opts.row)}" is not expandable.`);
118
+ if (row.getAttribute('aria-disabled') === 'true') throw new Error(`Cannot toggle expansion on disabled row "${(0, $b4e037a2907521c6$export$bc3bc4a9206bf789)(opts.row)}".`);
119
+ if (interactionType === 'mouse' || interactionType === 'touch') {
120
+ let rowExpander = (0, $5Fhol$within)(row).getAllByRole('button')[0]; // what happens if the button is not first? how can we differentiate?
121
+ await (0, $b4e037a2907521c6$export$6ffa3eb717517feb)(this.user, rowExpander, interactionType);
122
+ } else if (interactionType === 'keyboard') {
123
+ await this.keyboardNavigateToRow({
124
+ row: row
125
+ });
126
+ let collapseKey = this._direction === 'rtl' ? 'ArrowRight' : 'ArrowLeft';
127
+ let expandKey = this._direction === 'rtl' ? 'ArrowLeft' : 'ArrowRight';
128
+ if (row.getAttribute('aria-expanded') === 'true') await this.user.keyboard(`[${collapseKey}]`);
129
+ else await this.user.keyboard(`[${expandKey}]`);
130
+ }
131
+ }
132
+ /**
133
+ * Triggers the action for the specified tree row. Defaults to using the interaction type set on
134
+ * the tree tester.
135
+ */ async triggerRowAction(opts) {
136
+ let { row: row, needsDoubleClick: needsDoubleClick, interactionType: interactionType = this._interactionType } = opts;
137
+ if (typeof row === 'string' || typeof row === 'number') row = this.findRow({
138
+ indexOrText: row
139
+ });
140
+ if (!row) throw new Error(`Target row "${(0, $b4e037a2907521c6$export$bc3bc4a9206bf789)(opts.row)}" not found in the tree.`);
141
+ if (row.getAttribute('aria-disabled') === 'true') throw new Error(`Cannot trigger row action on disabled row "${(0, $b4e037a2907521c6$export$bc3bc4a9206bf789)(opts.row)}".`);
142
+ if (needsDoubleClick) await this.user.dblClick(row);
143
+ else if (interactionType === 'keyboard') {
144
+ await this.keyboardNavigateToRow({
145
+ row: row
146
+ });
147
+ await this.user.keyboard('[Enter]');
148
+ } else await (0, $b4e037a2907521c6$export$6ffa3eb717517feb)(this.user, row, interactionType);
149
+ }
150
+ /**
151
+ * Returns the tree.
152
+ */ getTree() {
153
+ return this._tree;
154
+ }
155
+ /**
156
+ * Returns the tree's rows if any.
157
+ */ getRows() {
158
+ return (0, $5Fhol$within)(this.getTree()).queryAllByRole('row');
159
+ }
160
+ /**
161
+ * Returns the tree's selected rows if any.
162
+ */ getSelectedRows() {
163
+ return this.getRows().filter((row)=>row.getAttribute('aria-selected') === 'true');
164
+ }
165
+ /**
166
+ * Returns the tree's cells if any. Can be filtered against a specific row if provided via
167
+ * `element`.
168
+ */ getCells(opts = {}) {
169
+ let { element: element = this.getTree() } = opts;
170
+ return (0, $5Fhol$within)(element).queryAllByRole('gridcell');
171
+ }
172
+ }
173
+
174
+
175
+ export {$d721d67b8ba87a3b$export$4445864b14128396 as TreeTester};
176
+ //# sourceMappingURL=tree.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAkBM,MAAM;IAOX,YAAY,IAAoB,CAAE;QAChC,IAAI,QAAC,IAAI,QAAE,IAAI,mBAAE,eAAe,gBAAE,YAAY,aAAE,SAAS,EAAC,GAAG;QAC7D,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,gBAAgB,GAAG,mBAAmB;QAC3C,IAAI,CAAC,aAAa,GAAG;QACrB,IAAI,CAAC,UAAU,GAAG,aAAa;QAC/B,IAAI,CAAC,KAAK,GAAG;QACb,IAAI,KAAK,YAAY,CAAC,YAAY,YAAY;YAC5C,IAAI,OAAO,CAAA,GAAA,aAAK,EAAE,MAAM,WAAW,CAAC;YACpC,IAAI,MACF,IAAI,CAAC,KAAK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AC,CAAC,EAAiB;QAC1D,IAAI,WAAC,UAAU,IAAI,CAAC,OAAO,IAAG,GAAG;QACjC,OAAO,CAAA,GAAA,aAAK,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} from './act';\nimport {\n BaseGridRowInteractionOpts,\n Direction,\n GridRowActionOpts,\n ToggleGridRowOpts,\n TreeTesterOpts,\n UserOpts\n} from './types';\nimport {formatTargetNode, getAltKey, getMetaKey, pressElement, triggerLongPress} from './utils';\nimport {within} from '@testing-library/dom';\n\ninterface TreeToggleExpansionOpts extends BaseGridRowInteractionOpts {}\ninterface TreeToggleRowOpts extends ToggleGridRowOpts {}\ninterface TreeRowActionOpts extends GridRowActionOpts {}\n\nexport class TreeTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _advanceTimer: UserOpts['advanceTimer'];\n private _direction: Direction;\n private _tree: HTMLElement;\n\n constructor(opts: TreeTesterOpts) {\n let {root, user, interactionType, advanceTimer, direction} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n this._advanceTimer = advanceTimer;\n this._direction = direction || 'ltr';\n this._tree = root;\n if (root.getAttribute('role') !== 'treegrid') {\n let tree = within(root).queryByRole('treegrid');\n if (tree) {\n this._tree = tree;\n }\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: {indexOrText: number | string}): HTMLElement {\n let {indexOrText} = opts;\n\n let row;\n if (typeof indexOrText === 'number') {\n row = this.getRows()[indexOrText];\n } else if (typeof indexOrText === 'string') {\n row = within(this.getTree()!).getByText(indexOrText).closest('[role=row]')! as HTMLElement;\n }\n\n return row;\n }\n\n private async keyboardNavigateToRow(opts: {\n row: HTMLElement;\n selectionOnNav?: 'default' | 'none';\n }) {\n let {row, selectionOnNav = 'default'} = opts;\n let altKey = getAltKey();\n let rows = this.getRows();\n let targetIndex = rows.indexOf(row);\n if (targetIndex === -1) {\n throw new Error('Row 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 let focusPrevKey = this._direction === 'rtl' ? 'ArrowRight' : 'ArrowLeft';\n if (document.activeElement === this.getTree()) {\n await this.user.keyboard(\n `${selectionOnNav === 'none' ? `[${altKey}>]` : ''}[ArrowDown]${selectionOnNav === 'none' ? `[/${altKey}]` : ''}`\n );\n } else if (\n this._tree.contains(document.activeElement) &&\n document.activeElement!.getAttribute('role') !== 'row'\n ) {\n do {\n await this.user.keyboard(`[${focusPrevKey}]`);\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\n * the tree tester. Note that this will endevor to always add/remove JUST the provided row to the\n * 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({indexOrText: row});\n }\n\n if (!row) {\n throw new Error(`Target row \"${formatTargetNode(opts.row)}\" not found in the tree.`);\n }\n\n let rowCheckbox = within(row).queryByRole('checkbox');\n\n if (\n rowCheckbox?.getAttribute('disabled') === '' ||\n row?.getAttribute('aria-disabled') === 'true'\n ) {\n throw new Error(`Cannot toggle selection on disabled row \"${formatTargetNode(opts.row)}\".`);\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({\n row,\n selectionOnNav: selectionBehavior === 'replace' ? 'none' : 'default'\n });\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 // Note that long press interactions with rows is strictly touch only for grid rows\n await triggerLongPress({\n element: cell,\n advanceTimer: this._advanceTimer!,\n pointerOpts: {pointerType: 'touch'}\n });\n } else {\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\n * the tree tester.\n */\n async toggleRowExpansion(opts: TreeToggleExpansionOpts): Promise<void> {\n let {row, interactionType = this._interactionType} = opts;\n if (!this.getTree().contains(document.activeElement)) {\n act(() => this.getTree().focus());\n }\n\n if (typeof row === 'string' || typeof row === 'number') {\n row = this.findRow({indexOrText: row});\n }\n\n if (!row) {\n throw new Error(`Target row \"${formatTargetNode(opts.row)}\" not found in the tree.`);\n } else if (row.getAttribute('aria-expanded') == null) {\n throw new Error(`Target row \"${formatTargetNode(opts.row)}\" is not expandable.`);\n }\n\n if (row.getAttribute('aria-disabled') === 'true') {\n throw new Error(`Cannot toggle expansion on disabled row \"${formatTargetNode(opts.row)}\".`);\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 await this.keyboardNavigateToRow({row});\n let collapseKey = this._direction === 'rtl' ? 'ArrowRight' : 'ArrowLeft';\n let expandKey = this._direction === 'rtl' ? 'ArrowLeft' : 'ArrowRight';\n if (row.getAttribute('aria-expanded') === 'true') {\n await this.user.keyboard(`[${collapseKey}]`);\n } else {\n await this.user.keyboard(`[${expandKey}]`);\n }\n }\n }\n\n /**\n * Triggers the action for the specified tree row. Defaults to using the interaction type set on\n * the tree tester.\n */\n async triggerRowAction(opts: TreeRowActionOpts): Promise<void> {\n let {row, needsDoubleClick, interactionType = this._interactionType} = opts;\n\n if (typeof row === 'string' || typeof row === 'number') {\n row = this.findRow({indexOrText: row});\n }\n\n if (!row) {\n throw new Error(`Target row \"${formatTargetNode(opts.row)}\" not found in the tree.`);\n }\n\n if (row.getAttribute('aria-disabled') === 'true') {\n throw new Error(`Cannot trigger row action on disabled row \"${formatTargetNode(opts.row)}\".`);\n }\n\n if (needsDoubleClick) {\n await this.user.dblClick(row);\n } else if (interactionType === 'keyboard') {\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 getTree(): HTMLElement {\n return this._tree;\n }\n\n /**\n * Returns the tree's rows if any.\n */\n getRows(): HTMLElement[] {\n return within(this.getTree()).queryAllByRole('row');\n }\n\n /**\n * Returns the tree's selected rows if any.\n */\n getSelectedRows(): HTMLElement[] {\n return this.getRows().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\n * `element`.\n */\n getCells(opts: {element?: HTMLElement} = {}): HTMLElement[] {\n let {element = this.getTree()} = opts;\n return within(element).queryAllByRole('gridcell');\n }\n}\n"],"names":[],"version":3,"file":"tree.js.map"}
@@ -0,0 +1,85 @@
1
+ var $2c71bb2c1e5033f0$exports = require("./checkboxgroup.cjs");
2
+ var $2cdddd94ee78eafe$exports = require("./combobox.cjs");
3
+ var $cde1dbf8bdfa11d9$exports = require("./dialog.cjs");
4
+ var $31bb3cd1e8c56ca2$exports = require("./gridlist.cjs");
5
+ var $c0f7ae61eac30828$exports = require("./listbox.cjs");
6
+ var $72b6079685b45ac0$exports = require("./menu.cjs");
7
+ var $b3fc8c302673b35d$exports = require("./userEventMaps.cjs");
8
+ var $4308942495e5af40$exports = require("./radiogroup.cjs");
9
+ var $842eb702165f4e83$exports = require("./select.cjs");
10
+ var $b9d4e4f005cd9015$exports = require("./table.cjs");
11
+ var $d225318b7bd4eacf$exports = require("./tabs.cjs");
12
+ var $c7f71a5a893f714a$exports = require("./tree.cjs");
13
+ var $2DbTQ$testinglibraryuserevent = require("@testing-library/user-event");
14
+
15
+
16
+ function $parcel$interopDefault(a) {
17
+ return a && a.__esModule ? a.default : a;
18
+ }
19
+
20
+ function $parcel$export(e, n, v, s) {
21
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
22
+ }
23
+
24
+ $parcel$export(module.exports, "User", function () { return $3117e6a7fac3686b$export$1f44aaf2ec115b54; });
25
+ /*
26
+ * Copyright 2024 Adobe. All rights reserved.
27
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
28
+ * you may not use this file except in compliance with the License. You may obtain a copy
29
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
30
+ *
31
+ * Unless required by applicable law or agreed to in writing, software distributed under
32
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
33
+ * OF ANY KIND, either express or implied. See the License for the specific language
34
+ * governing permissions and limitations under the License.
35
+ */
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+ let $3117e6a7fac3686b$var$keyToUtil = {
49
+ CheckboxGroup: (0, $2c71bb2c1e5033f0$exports.CheckboxGroupTester),
50
+ ComboBox: (0, $2cdddd94ee78eafe$exports.ComboBoxTester),
51
+ Dialog: (0, $cde1dbf8bdfa11d9$exports.DialogTester),
52
+ GridList: (0, $31bb3cd1e8c56ca2$exports.GridListTester),
53
+ ListBox: (0, $c0f7ae61eac30828$exports.ListBoxTester),
54
+ Menu: (0, $72b6079685b45ac0$exports.MenuTester),
55
+ RadioGroup: (0, $4308942495e5af40$exports.RadioGroupTester),
56
+ Select: (0, $842eb702165f4e83$exports.SelectTester),
57
+ Table: (0, $b9d4e4f005cd9015$exports.TableTester),
58
+ Tabs: (0, $d225318b7bd4eacf$exports.TabsTester),
59
+ Tree: (0, $c7f71a5a893f714a$exports.TreeTester)
60
+ };
61
+ let $3117e6a7fac3686b$var$defaultAdvanceTimer = (waitTime)=>new Promise((resolve)=>setTimeout(resolve, waitTime));
62
+ class $3117e6a7fac3686b$export$1f44aaf2ec115b54 {
63
+ constructor(opts = {}){
64
+ let { interactionType: interactionType, advanceTimer: advanceTimer } = opts;
65
+ this.user = (0, ($parcel$interopDefault($2DbTQ$testinglibraryuserevent))).setup({
66
+ delay: null,
67
+ pointerMap: $b3fc8c302673b35d$exports.pointerMap
68
+ });
69
+ this.interactionType = interactionType;
70
+ this.advanceTimer = advanceTimer || $3117e6a7fac3686b$var$defaultAdvanceTimer;
71
+ }
72
+ /**
73
+ * Creates an aria pattern tester, inheriting the options provided to the original user.
74
+ */ createTester(patternName, opts) {
75
+ return new $3117e6a7fac3686b$var$keyToUtil[patternName]({
76
+ interactionType: this.interactionType,
77
+ advanceTimer: this.advanceTimer,
78
+ ...opts,
79
+ user: this.user
80
+ });
81
+ }
82
+ }
83
+
84
+
85
+ //# sourceMappingURL=user.cjs.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;AA8BD,IAAI,kCAYA;IACF,eAAe,CAAA,GAAA,6CAAkB;IACjC,UAAU,CAAA,GAAA,wCAAa;IACvB,QAAQ,CAAA,GAAA,sCAAW;IACnB,UAAU,CAAA,GAAA,wCAAa;IACvB,SAAS,CAAA,GAAA,uCAAY;IACrB,MAAM,CAAA,GAAA,oCAAS;IACf,YAAY,CAAA,GAAA,0CAAe;IAC3B,QAAQ,CAAA,GAAA,sCAAW;IACnB,OAAO,CAAA,GAAA,qCAAU;IACjB,MAAM,CAAA,GAAA,oCAAS;IACf,MAAM,CAAA,GAAA,oCAAS;AACjB;AAoDA,IAAI,4CAAsB,CAAC,WACzB,IAAI,QAAQ,CAAA,UAAW,WAAW,SAAS;AAEtC,MAAM;IAeX,YAAY,OAAiB,CAAC,CAAC,CAAE;QAC/B,IAAI,mBAAC,eAAe,gBAAE,YAAY,EAAC,GAAG;QACtC,IAAI,CAAC,IAAI,GAAG,CAAA,GAAA,wDAAQ,EAAE,KAAK,CAAC;YAAC,OAAO;wBAAM;QAAU;QACpD,IAAI,CAAC,eAAe,GAAG;QACvB,IAAI,CAAC,YAAY,GAAG,gBAAgB;IACtC;IAEA;;GAEC,GACD,aAAqC,WAAc,EAAE,IAAmB,EAAa;QACnF,OAAO,IAAI,+BAAS,CAAC,YAAY,CAAC;YAChC,iBAAiB,IAAI,CAAC,eAAe;YACrC,cAAc,IAAI,CAAC,YAAY;YAC/B,GAAG,IAAI;YACP,MAAM,IAAI,CAAC,IAAI;QACjB;IACF;AACF","sources":["packages/@react-aria/test-utils/src/user.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 {CheckboxGroupTester} from './checkboxgroup';\nimport {\n CheckboxGroupTesterOpts,\n ComboBoxTesterOpts,\n DialogTesterOpts,\n GridListTesterOpts,\n ListBoxTesterOpts,\n MenuTesterOpts,\n RadioGroupTesterOpts,\n SelectTesterOpts,\n TableTesterOpts,\n TabsTesterOpts,\n TreeTesterOpts,\n UserOpts\n} from './types';\nimport {ComboBoxTester} from './combobox';\nimport {DialogTester} from './dialog';\nimport {GridListTester} from './gridlist';\nimport {ListBoxTester} from './listbox';\nimport {MenuTester} from './menu';\nimport {pointerMap} from './';\nimport {RadioGroupTester} from './radiogroup';\nimport {SelectTester} from './select';\nimport {TableTester} from './table';\nimport {TabsTester} from './tabs';\nimport {TreeTester} from './tree';\nimport userEvent from '@testing-library/user-event';\n\nlet keyToUtil: {\n CheckboxGroup: typeof CheckboxGroupTester;\n ComboBox: typeof ComboBoxTester;\n Dialog: typeof DialogTester;\n GridList: typeof GridListTester;\n ListBox: typeof ListBoxTester;\n Menu: typeof MenuTester;\n RadioGroup: typeof RadioGroupTester;\n Select: typeof SelectTester;\n Table: typeof TableTester;\n Tabs: typeof TabsTester;\n Tree: typeof TreeTester;\n} = {\n CheckboxGroup: CheckboxGroupTester,\n ComboBox: ComboBoxTester,\n Dialog: DialogTester,\n GridList: GridListTester,\n ListBox: ListBoxTester,\n Menu: MenuTester,\n RadioGroup: RadioGroupTester,\n Select: SelectTester,\n Table: TableTester,\n Tabs: TabsTester,\n Tree: TreeTester\n} as const;\nexport type PatternNames = keyof typeof keyToUtil;\n\n// Conditional type: https://www.typescriptlang.org/docs/handbook/2/conditional-types.html\ntype Tester<T> = T extends 'CheckboxGroup'\n ? CheckboxGroupTester\n : T extends 'ComboBox'\n ? ComboBoxTester\n : T extends 'Dialog'\n ? DialogTester\n : T extends 'GridList'\n ? GridListTester\n : T extends 'ListBox'\n ? ListBoxTester\n : T extends 'Menu'\n ? MenuTester\n : T extends 'RadioGroup'\n ? RadioGroupTester\n : T extends 'Select'\n ? SelectTester\n : T extends 'Table'\n ? TableTester\n : T extends 'Tabs'\n ? TabsTester\n : T extends 'Tree'\n ? TreeTester\n : never;\n\ntype TesterOpts<T> = T extends 'CheckboxGroup'\n ? CheckboxGroupTesterOpts\n : T extends 'ComboBox'\n ? ComboBoxTesterOpts\n : T extends 'Dialog'\n ? DialogTesterOpts\n : T extends 'GridList'\n ? GridListTesterOpts\n : T extends 'ListBox'\n ? ListBoxTesterOpts\n : T extends 'Menu'\n ? MenuTesterOpts\n : T extends 'RadioGroup'\n ? RadioGroupTesterOpts\n : T extends 'Select'\n ? SelectTesterOpts\n : T extends 'Table'\n ? TableTesterOpts\n : T extends 'Tabs'\n ? TabsTesterOpts\n : T extends 'Tree'\n ? TreeTesterOpts\n : never;\n\nlet defaultAdvanceTimer = (waitTime: number | undefined) =>\n new Promise(resolve => setTimeout(resolve, waitTime));\n\nexport class User {\n private user;\n /**\n * The interaction type (mouse, touch, keyboard) that the test util user will use when interacting\n * with a component. This can be overridden at the aria pattern util level if needed.\n *\n * @default mouse\n */\n interactionType: UserOpts['interactionType'];\n /**\n * A function used by the test utils to advance timers during interactions. Required for certain\n * aria patterns (e.g. table).\n */\n advanceTimer: UserOpts['advanceTimer'];\n\n constructor(opts: UserOpts = {}) {\n let {interactionType, advanceTimer} = opts;\n this.user = userEvent.setup({delay: null, pointerMap});\n this.interactionType = interactionType;\n this.advanceTimer = advanceTimer || defaultAdvanceTimer;\n }\n\n /**\n * Creates an aria pattern tester, inheriting the options provided to the original user.\n */\n createTester<T extends PatternNames>(patternName: T, opts: TesterOpts<T>): Tester<T> {\n return new keyToUtil[patternName]({\n interactionType: this.interactionType,\n advanceTimer: this.advanceTimer,\n ...opts,\n user: this.user\n }) as Tester<T>;\n }\n}\n"],"names":[],"version":3,"file":"user.cjs.map"}
@@ -0,0 +1,76 @@
1
+ import {CheckboxGroupTester as $e7160b4be83b4967$export$f54f4bde770cc5a6} from "./checkboxgroup.js";
2
+ import {ComboBoxTester as $a2202d8b369e6a8a$export$f97e14e96d71ab3b} from "./combobox.js";
3
+ import {DialogTester as $1bad24930969e309$export$e79328f5295cc2a1} from "./dialog.js";
4
+ import {GridListTester as $ed42840525c46506$export$93a85aaed9fabd83} from "./gridlist.js";
5
+ import {ListBoxTester as $8d2aea0e455eb460$export$54c24f7ee8577f4f} from "./listbox.js";
6
+ import {MenuTester as $460bfe9f038d2630$export$f73bbc9212ed861e} from "./menu.js";
7
+ import {pointerMap as $759f061d800cf446$export$7dbde2c4caaa8d35} from "./userEventMaps.js";
8
+ import {RadioGroupTester as $14dc6ef63d191867$export$d66326e63d27e116} from "./radiogroup.js";
9
+ import {SelectTester as $6acb352063615cf0$export$d1859707465446a9} from "./select.js";
10
+ import {TableTester as $196900c7f8f394b6$export$4c6a9d6ae3b0086} from "./table.js";
11
+ import {TabsTester as $e1a5bc7455cf5719$export$f1539bff3fc7d485} from "./tabs.js";
12
+ import {TreeTester as $d721d67b8ba87a3b$export$4445864b14128396} from "./tree.js";
13
+ import $9gPuy$testinglibraryuserevent from "@testing-library/user-event";
14
+
15
+ /*
16
+ * Copyright 2024 Adobe. All rights reserved.
17
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
+ * you may not use this file except in compliance with the License. You may obtain a copy
19
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
20
+ *
21
+ * Unless required by applicable law or agreed to in writing, software distributed under
22
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
23
+ * OF ANY KIND, either express or implied. See the License for the specific language
24
+ * governing permissions and limitations under the License.
25
+ */
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+ let $4ab48216ddc89c32$var$keyToUtil = {
39
+ CheckboxGroup: (0, $e7160b4be83b4967$export$f54f4bde770cc5a6),
40
+ ComboBox: (0, $a2202d8b369e6a8a$export$f97e14e96d71ab3b),
41
+ Dialog: (0, $1bad24930969e309$export$e79328f5295cc2a1),
42
+ GridList: (0, $ed42840525c46506$export$93a85aaed9fabd83),
43
+ ListBox: (0, $8d2aea0e455eb460$export$54c24f7ee8577f4f),
44
+ Menu: (0, $460bfe9f038d2630$export$f73bbc9212ed861e),
45
+ RadioGroup: (0, $14dc6ef63d191867$export$d66326e63d27e116),
46
+ Select: (0, $6acb352063615cf0$export$d1859707465446a9),
47
+ Table: (0, $196900c7f8f394b6$export$4c6a9d6ae3b0086),
48
+ Tabs: (0, $e1a5bc7455cf5719$export$f1539bff3fc7d485),
49
+ Tree: (0, $d721d67b8ba87a3b$export$4445864b14128396)
50
+ };
51
+ let $4ab48216ddc89c32$var$defaultAdvanceTimer = (waitTime)=>new Promise((resolve)=>setTimeout(resolve, waitTime));
52
+ class $4ab48216ddc89c32$export$1f44aaf2ec115b54 {
53
+ constructor(opts = {}){
54
+ let { interactionType: interactionType, advanceTimer: advanceTimer } = opts;
55
+ this.user = (0, $9gPuy$testinglibraryuserevent).setup({
56
+ delay: null,
57
+ pointerMap: $759f061d800cf446$export$7dbde2c4caaa8d35
58
+ });
59
+ this.interactionType = interactionType;
60
+ this.advanceTimer = advanceTimer || $4ab48216ddc89c32$var$defaultAdvanceTimer;
61
+ }
62
+ /**
63
+ * Creates an aria pattern tester, inheriting the options provided to the original user.
64
+ */ createTester(patternName, opts) {
65
+ return new $4ab48216ddc89c32$var$keyToUtil[patternName]({
66
+ interactionType: this.interactionType,
67
+ advanceTimer: this.advanceTimer,
68
+ ...opts,
69
+ user: this.user
70
+ });
71
+ }
72
+ }
73
+
74
+
75
+ export {$4ab48216ddc89c32$export$1f44aaf2ec115b54 as User};
76
+ //# sourceMappingURL=user.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;AA8BD,IAAI,kCAYA;IACF,eAAe,CAAA,GAAA,yCAAkB;IACjC,UAAU,CAAA,GAAA,yCAAa;IACvB,QAAQ,CAAA,GAAA,yCAAW;IACnB,UAAU,CAAA,GAAA,yCAAa;IACvB,SAAS,CAAA,GAAA,yCAAY;IACrB,MAAM,CAAA,GAAA,yCAAS;IACf,YAAY,CAAA,GAAA,yCAAe;IAC3B,QAAQ,CAAA,GAAA,yCAAW;IACnB,OAAO,CAAA,GAAA,wCAAU;IACjB,MAAM,CAAA,GAAA,yCAAS;IACf,MAAM,CAAA,GAAA,yCAAS;AACjB;AAoDA,IAAI,4CAAsB,CAAC,WACzB,IAAI,QAAQ,CAAA,UAAW,WAAW,SAAS;AAEtC,MAAM;IAeX,YAAY,OAAiB,CAAC,CAAC,CAAE;QAC/B,IAAI,mBAAC,eAAe,gBAAE,YAAY,EAAC,GAAG;QACtC,IAAI,CAAC,IAAI,GAAG,CAAA,GAAA,8BAAQ,EAAE,KAAK,CAAC;YAAC,OAAO;wBAAM;QAAU;QACpD,IAAI,CAAC,eAAe,GAAG;QACvB,IAAI,CAAC,YAAY,GAAG,gBAAgB;IACtC;IAEA;;GAEC,GACD,aAAqC,WAAc,EAAE,IAAmB,EAAa;QACnF,OAAO,IAAI,+BAAS,CAAC,YAAY,CAAC;YAChC,iBAAiB,IAAI,CAAC,eAAe;YACrC,cAAc,IAAI,CAAC,YAAY;YAC/B,GAAG,IAAI;YACP,MAAM,IAAI,CAAC,IAAI;QACjB;IACF;AACF","sources":["packages/@react-aria/test-utils/src/user.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 {CheckboxGroupTester} from './checkboxgroup';\nimport {\n CheckboxGroupTesterOpts,\n ComboBoxTesterOpts,\n DialogTesterOpts,\n GridListTesterOpts,\n ListBoxTesterOpts,\n MenuTesterOpts,\n RadioGroupTesterOpts,\n SelectTesterOpts,\n TableTesterOpts,\n TabsTesterOpts,\n TreeTesterOpts,\n UserOpts\n} from './types';\nimport {ComboBoxTester} from './combobox';\nimport {DialogTester} from './dialog';\nimport {GridListTester} from './gridlist';\nimport {ListBoxTester} from './listbox';\nimport {MenuTester} from './menu';\nimport {pointerMap} from './';\nimport {RadioGroupTester} from './radiogroup';\nimport {SelectTester} from './select';\nimport {TableTester} from './table';\nimport {TabsTester} from './tabs';\nimport {TreeTester} from './tree';\nimport userEvent from '@testing-library/user-event';\n\nlet keyToUtil: {\n CheckboxGroup: typeof CheckboxGroupTester;\n ComboBox: typeof ComboBoxTester;\n Dialog: typeof DialogTester;\n GridList: typeof GridListTester;\n ListBox: typeof ListBoxTester;\n Menu: typeof MenuTester;\n RadioGroup: typeof RadioGroupTester;\n Select: typeof SelectTester;\n Table: typeof TableTester;\n Tabs: typeof TabsTester;\n Tree: typeof TreeTester;\n} = {\n CheckboxGroup: CheckboxGroupTester,\n ComboBox: ComboBoxTester,\n Dialog: DialogTester,\n GridList: GridListTester,\n ListBox: ListBoxTester,\n Menu: MenuTester,\n RadioGroup: RadioGroupTester,\n Select: SelectTester,\n Table: TableTester,\n Tabs: TabsTester,\n Tree: TreeTester\n} as const;\nexport type PatternNames = keyof typeof keyToUtil;\n\n// Conditional type: https://www.typescriptlang.org/docs/handbook/2/conditional-types.html\ntype Tester<T> = T extends 'CheckboxGroup'\n ? CheckboxGroupTester\n : T extends 'ComboBox'\n ? ComboBoxTester\n : T extends 'Dialog'\n ? DialogTester\n : T extends 'GridList'\n ? GridListTester\n : T extends 'ListBox'\n ? ListBoxTester\n : T extends 'Menu'\n ? MenuTester\n : T extends 'RadioGroup'\n ? RadioGroupTester\n : T extends 'Select'\n ? SelectTester\n : T extends 'Table'\n ? TableTester\n : T extends 'Tabs'\n ? TabsTester\n : T extends 'Tree'\n ? TreeTester\n : never;\n\ntype TesterOpts<T> = T extends 'CheckboxGroup'\n ? CheckboxGroupTesterOpts\n : T extends 'ComboBox'\n ? ComboBoxTesterOpts\n : T extends 'Dialog'\n ? DialogTesterOpts\n : T extends 'GridList'\n ? GridListTesterOpts\n : T extends 'ListBox'\n ? ListBoxTesterOpts\n : T extends 'Menu'\n ? MenuTesterOpts\n : T extends 'RadioGroup'\n ? RadioGroupTesterOpts\n : T extends 'Select'\n ? SelectTesterOpts\n : T extends 'Table'\n ? TableTesterOpts\n : T extends 'Tabs'\n ? TabsTesterOpts\n : T extends 'Tree'\n ? TreeTesterOpts\n : never;\n\nlet defaultAdvanceTimer = (waitTime: number | undefined) =>\n new Promise(resolve => setTimeout(resolve, waitTime));\n\nexport class User {\n private user;\n /**\n * The interaction type (mouse, touch, keyboard) that the test util user will use when interacting\n * with a component. This can be overridden at the aria pattern util level if needed.\n *\n * @default mouse\n */\n interactionType: UserOpts['interactionType'];\n /**\n * A function used by the test utils to advance timers during interactions. Required for certain\n * aria patterns (e.g. table).\n */\n advanceTimer: UserOpts['advanceTimer'];\n\n constructor(opts: UserOpts = {}) {\n let {interactionType, advanceTimer} = opts;\n this.user = userEvent.setup({delay: null, pointerMap});\n this.interactionType = interactionType;\n this.advanceTimer = advanceTimer || defaultAdvanceTimer;\n }\n\n /**\n * Creates an aria pattern tester, inheriting the options provided to the original user.\n */\n createTester<T extends PatternNames>(patternName: T, opts: TesterOpts<T>): Tester<T> {\n return new keyToUtil[patternName]({\n interactionType: this.interactionType,\n advanceTimer: this.advanceTimer,\n ...opts,\n user: this.user\n }) as Tester<T>;\n }\n}\n"],"names":[],"version":3,"file":"user.js.map"}
@@ -3,8 +3,8 @@ function $parcel$export(e, n, v, s) {
3
3
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
4
  }
5
5
 
6
- $parcel$export(module.exports, "pointerMap", () => $0e568517a25183a7$export$7dbde2c4caaa8d35);
7
- let $0e568517a25183a7$export$7dbde2c4caaa8d35 = [
6
+ $parcel$export(module.exports, "pointerMap", function () { return $b3fc8c302673b35d$export$7dbde2c4caaa8d35; });
7
+ let $b3fc8c302673b35d$export$7dbde2c4caaa8d35 = [
8
8
  {
9
9
  name: 'MouseLeft',
10
10
  pointerType: 'mouse',
@@ -40,4 +40,4 @@ let $0e568517a25183a7$export$7dbde2c4caaa8d35 = [
40
40
  ];
41
41
 
42
42
 
43
- //# sourceMappingURL=userEventMaps.main.js.map
43
+ //# sourceMappingURL=userEventMaps.cjs.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;AAEO,IAAI,4CAA2B;IACpC;QAAC,MAAM;QAAa,aAAa;QAAS,QAAQ;QAAW,QAAQ;QAAG,OAAO;QAAG,UAAU;IAAG;IAC/F;QAAC,MAAM;QAAc,aAAa;QAAS,QAAQ;IAAW;IAC9D;QAAC,MAAM;QAAe,aAAa;QAAS,QAAQ;IAAW;IAC/D;QAAC,MAAM;QAAU,aAAa;QAAS,QAAQ;QAAG,OAAO;IAAC;IAC1D;QAAC,MAAM;QAAU,aAAa;IAAO;IACrC;QAAC,MAAM;QAAU,aAAa;IAAO;CACtC","sources":["packages/@react-aria/test-utils/src/userEventMaps.ts"],"sourcesContent":["import {pointerKey} from '@testing-library/user-event';\n\nexport let pointerMap: pointerKey[] = [\n {name: 'MouseLeft', pointerType: 'mouse', button: 'primary', height: 1, width: 1, pressure: 0.5},\n {name: 'MouseRight', pointerType: 'mouse', button: 'secondary'},\n {name: 'MouseMiddle', pointerType: 'mouse', button: 'auxiliary'},\n {name: 'TouchA', pointerType: 'touch', height: 1, width: 1},\n {name: 'TouchB', pointerType: 'touch'},\n {name: 'TouchC', pointerType: 'touch'}\n] as unknown as pointerKey[];\n"],"names":[],"version":3,"file":"userEventMaps.cjs.map"}
@@ -1,4 +1,4 @@
1
- let $50ecfb18069ec897$export$7dbde2c4caaa8d35 = [
1
+ let $759f061d800cf446$export$7dbde2c4caaa8d35 = [
2
2
  {
3
3
  name: 'MouseLeft',
4
4
  pointerType: 'mouse',
@@ -34,5 +34,5 @@ let $50ecfb18069ec897$export$7dbde2c4caaa8d35 = [
34
34
  ];
35
35
 
36
36
 
37
- export {$50ecfb18069ec897$export$7dbde2c4caaa8d35 as pointerMap};
38
- //# sourceMappingURL=userEventMaps.module.js.map
37
+ export {$759f061d800cf446$export$7dbde2c4caaa8d35 as pointerMap};
38
+ //# sourceMappingURL=userEventMaps.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAEO,IAAI,4CAA2B;IACpC;QAAC,MAAM;QAAa,aAAa;QAAS,QAAQ;QAAW,QAAQ;QAAG,OAAO;QAAG,UAAU;IAAG;IAC/F;QAAC,MAAM;QAAc,aAAa;QAAS,QAAQ;IAAW;IAC9D;QAAC,MAAM;QAAe,aAAa;QAAS,QAAQ;IAAW;IAC/D;QAAC,MAAM;QAAU,aAAa;QAAS,QAAQ;QAAG,OAAO;IAAC;IAC1D;QAAC,MAAM;QAAU,aAAa;IAAO;IACrC;QAAC,MAAM;QAAU,aAAa;IAAO;CACtC","sources":["packages/@react-aria/test-utils/src/userEventMaps.ts"],"sourcesContent":["import {pointerKey} from '@testing-library/user-event';\n\nexport let pointerMap: pointerKey[] = [\n {name: 'MouseLeft', pointerType: 'mouse', button: 'primary', height: 1, width: 1, pressure: 0.5},\n {name: 'MouseRight', pointerType: 'mouse', button: 'secondary'},\n {name: 'MouseMiddle', pointerType: 'mouse', button: 'auxiliary'},\n {name: 'TouchA', pointerType: 'touch', height: 1, width: 1},\n {name: 'TouchB', pointerType: 'touch'},\n {name: 'TouchC', pointerType: 'touch'}\n] as unknown as pointerKey[];\n"],"names":[],"version":3,"file":"userEventMaps.js.map"}
@@ -0,0 +1,136 @@
1
+ var $a84d573878cc1e5e$exports = require("./act.cjs");
2
+ var $jfoSl$testinglibrarydom = require("@testing-library/dom");
3
+
4
+
5
+ function $parcel$export(e, n, v, s) {
6
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
+ }
8
+
9
+ $parcel$export(module.exports, "getAltKey", function () { return $022fcf8e360befed$export$6fc0ccaebd758b9d; });
10
+ $parcel$export(module.exports, "getMetaKey", function () { return $022fcf8e360befed$export$7943c508934e27ce; });
11
+ $parcel$export(module.exports, "formatTargetNode", function () { return $022fcf8e360befed$export$bc3bc4a9206bf789; });
12
+ $parcel$export(module.exports, "triggerLongPress", function () { return $022fcf8e360befed$export$3a22a5a9bc0fd3b; });
13
+ $parcel$export(module.exports, "pressElement", function () { return $022fcf8e360befed$export$6ffa3eb717517feb; });
14
+ /*
15
+ * Copyright 2023 Adobe. All rights reserved.
16
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
17
+ * you may not use this file except in compliance with the License. You may obtain a copy
18
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software distributed under
21
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
22
+ * OF ANY KIND, either express or implied. See the License for the specific language
23
+ * governing permissions and limitations under the License.
24
+ */
25
+
26
+ const $022fcf8e360befed$export$4bd1d2d5ba6f5eaf = 500;
27
+ function $022fcf8e360befed$var$testPlatform(re) {
28
+ return typeof window !== 'undefined' && window.navigator != null ? re.test(window.navigator['userAgentData']?.platform || window.navigator.platform) : false;
29
+ }
30
+ function $022fcf8e360befed$var$cached(fn) {
31
+ if (process.env.NODE_ENV === 'test') return fn;
32
+ let res = null;
33
+ return ()=>{
34
+ if (res == null) res = fn();
35
+ return res;
36
+ };
37
+ }
38
+ const $022fcf8e360befed$var$isMac = $022fcf8e360befed$var$cached(function() {
39
+ return $022fcf8e360befed$var$testPlatform(/^Mac/i);
40
+ });
41
+ function $022fcf8e360befed$export$6fc0ccaebd758b9d() {
42
+ return $022fcf8e360befed$var$isMac() ? 'Alt' : 'ControlLeft';
43
+ }
44
+ function $022fcf8e360befed$export$7943c508934e27ce() {
45
+ return $022fcf8e360befed$var$isMac() ? 'MetaLeft' : 'ControlLeft';
46
+ }
47
+ function $022fcf8e360befed$export$bc3bc4a9206bf789(value) {
48
+ if (typeof HTMLElement !== 'undefined' && value instanceof HTMLElement) return value.cloneNode(false).outerHTML;
49
+ return String(value);
50
+ }
51
+ async function $022fcf8e360befed$export$3a22a5a9bc0fd3b(opts) {
52
+ let { element: element, advanceTimer: advanceTimer, pointerOpts: pointerOpts = {} } = opts;
53
+ let pointerType = pointerOpts.pointerType ?? 'mouse';
54
+ let shouldFireCompatibilityEvents = false;
55
+ (0, $a84d573878cc1e5e$exports.act)(()=>{
56
+ shouldFireCompatibilityEvents = (0, $jfoSl$testinglibrarydom.fireEvent).pointerDown(element, {
57
+ pointerType: pointerType,
58
+ ...pointerOpts
59
+ });
60
+ });
61
+ let shouldFocus = true;
62
+ if (shouldFireCompatibilityEvents) {
63
+ if (pointerType === 'touch') (0, $a84d573878cc1e5e$exports.act)(()=>{
64
+ shouldFocus = shouldFireCompatibilityEvents = (0, $jfoSl$testinglibrarydom.fireEvent).touchStart(element, {
65
+ targetTouches: [
66
+ {
67
+ identifier: pointerOpts.pointerId,
68
+ clientX: pointerOpts.clientX,
69
+ clientY: pointerOpts.clientY
70
+ }
71
+ ]
72
+ });
73
+ });
74
+ else if (pointerType === 'mouse') {
75
+ (0, $a84d573878cc1e5e$exports.act)(()=>{
76
+ shouldFocus = (0, $jfoSl$testinglibrarydom.fireEvent).mouseDown(element, pointerOpts);
77
+ });
78
+ if (shouldFocus) (0, $a84d573878cc1e5e$exports.act)(()=>element.focus());
79
+ }
80
+ }
81
+ await (0, $a84d573878cc1e5e$exports.act)(async ()=>await advanceTimer($022fcf8e360befed$export$4bd1d2d5ba6f5eaf));
82
+ (0, $a84d573878cc1e5e$exports.act)(()=>{
83
+ (0, $jfoSl$testinglibrarydom.fireEvent).pointerUp(element, {
84
+ pointerType: pointerType,
85
+ ...pointerOpts
86
+ });
87
+ });
88
+ if (shouldFireCompatibilityEvents) {
89
+ if (pointerType === 'touch') {
90
+ (0, $a84d573878cc1e5e$exports.act)(()=>{
91
+ shouldFocus = (0, $jfoSl$testinglibrarydom.fireEvent).touchEnd(element, {
92
+ targetTouches: [
93
+ {
94
+ identifier: pointerOpts.pointerId,
95
+ clientX: pointerOpts.clientX,
96
+ clientY: pointerOpts.clientY
97
+ }
98
+ ]
99
+ });
100
+ shouldFocus = (0, $jfoSl$testinglibrarydom.fireEvent).mouseDown(element, pointerOpts);
101
+ });
102
+ if (shouldFocus) (0, $a84d573878cc1e5e$exports.act)(()=>element.focus());
103
+ (0, $a84d573878cc1e5e$exports.act)(()=>{
104
+ (0, $jfoSl$testinglibrarydom.fireEvent).mouseUp(element, pointerOpts);
105
+ });
106
+ } else if (pointerType === 'mouse') (0, $a84d573878cc1e5e$exports.act)(()=>{
107
+ (0, $jfoSl$testinglibrarydom.fireEvent).mouseUp(element, pointerOpts);
108
+ });
109
+ }
110
+ (0, $a84d573878cc1e5e$exports.act)(()=>{
111
+ (0, $jfoSl$testinglibrarydom.fireEvent).click(element, {
112
+ detail: 1,
113
+ ...pointerOpts
114
+ });
115
+ });
116
+ }
117
+ async function $022fcf8e360befed$export$6ffa3eb717517feb(user, element, interactionType) {
118
+ if (interactionType === 'mouse') // Add coords with pressure so this isn't detected as a virtual click
119
+ await user.pointer({
120
+ target: element,
121
+ keys: '[MouseLeft]',
122
+ coords: {
123
+ pressure: 0.5
124
+ }
125
+ });
126
+ else if (interactionType === 'keyboard') {
127
+ (0, $a84d573878cc1e5e$exports.act)(()=>element.focus());
128
+ await user.keyboard('[Space]');
129
+ } else if (interactionType === 'touch') await user.pointer({
130
+ target: element,
131
+ keys: '[TouchA]'
132
+ });
133
+ }
134
+
135
+
136
+ //# sourceMappingURL=utils.cjs.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAMM,MAAM,4CAA0B;AACvC,SAAS,mCAAa,EAAU;IAC9B,OAAO,OAAO,WAAW,eAAe,OAAO,SAAS,IAAI,OACxD,GAAG,IAAI,CAAC,OAAO,SAAS,CAAC,gBAAgB,EAAE,YAAY,OAAO,SAAS,CAAC,QAAQ,IAChF;AACN;AAEA,SAAS,6BAAO,EAAiB;IAC/B,IAAI,QAAQ,GAAG,CAAC,QAAQ,KAAK,QAC3B,OAAO;IAGT,IAAI,MAAsB;IAC1B,OAAO;QACL,IAAI,OAAO,MACT,MAAM;QAER,OAAO;IACT;AACF;AAEA,MAAM,8BAAQ,6BAAO;IACnB,OAAO,mCAAa;AACtB;AAEO,SAAS;IACd,OAAO,gCAAU,QAAQ;AAC3B;AAEO,SAAS;IACd,OAAO,gCAAU,aAAa;AAChC;AAEO,SAAS,0CAAiB,KAAoC;IACnE,IAAI,OAAO,gBAAgB,eAAe,iBAAiB,aACzD,OAAO,AAAC,MAAM,SAAS,CAAC,OAAuB,SAAS;IAE1D,OAAO,OAAO;AAChB;AAYO,eAAe,yCAAiB,IAItC;IACC,IAAI,WAAC,OAAO,gBAAE,YAAY,eAAE,cAAc,CAAC,GAAE,GAAG;IAChD,IAAI,cAAc,YAAY,WAAW,IAAI;IAC7C,IAAI,gCAAgC;IACpC,CAAA,GAAA,6BAAE,EAAE;QACF,gCAAgC,CAAA,GAAA,kCAAQ,EAAE,WAAW,CAAC,SAAS;yBAAC;YAAa,GAAG,WAAW;QAAA;IAC7F;IACA,IAAI,cAAc;IAClB,IAAI,+BAA+B;QACjC,IAAI,gBAAgB,SAClB,CAAA,GAAA,6BAAE,EAAE;YACF,cAAc,gCAAgC,CAAA,GAAA,kCAAQ,EAAE,U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pB,IAIC,EACD,OAAoB,EACpB,eAA4C;IAE5C,IAAI,oBAAoB,SACtB,qEAAqE;IACrE,MAAM,KAAK,OAAO,CAAC;QAAC,QAAQ;QAAS,MAAM;QAAe,QAAQ;YAAC,UAAU;QAAG;IAAC;SAC5E,IAAI,oBAAoB,YAAY;QACzC,CAAA,GAAA,6BAAE,EAAE,IAAM,QAAQ,KAAK;QACvB,MAAM,KAAK,QAAQ,CAAC;IACtB,OAAO,IAAI,oBAAoB,SAC7B,MAAM,KAAK,OAAO,CAAC;QAAC,QAAQ;QAAS,MAAM;IAAU;AAEzD","sources":["packages/@react-aria/test-utils/src/utils.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\nimport {act} from './act';\nimport {fireEvent} from '@testing-library/dom';\nimport {UserOpts} from './types';\n\nexport const DEFAULT_LONG_PRESS_TIME = 500;\nfunction testPlatform(re: RegExp) {\n return typeof window !== 'undefined' && window.navigator != null\n ? re.test(window.navigator['userAgentData']?.platform || window.navigator.platform)\n : false;\n}\n\nfunction cached(fn: () => boolean) {\n if (process.env.NODE_ENV === 'test') {\n return fn;\n }\n\n let res: boolean | null = null;\n return () => {\n if (res == null) {\n res = fn();\n }\n return res;\n };\n}\n\nconst isMac = cached(function () {\n return testPlatform(/^Mac/i);\n});\n\nexport function getAltKey(): 'Alt' | 'ControlLeft' {\n return isMac() ? 'Alt' : 'ControlLeft';\n}\n\nexport function getMetaKey(): 'MetaLeft' | 'ControlLeft' {\n return isMac() ? 'MetaLeft' : 'ControlLeft';\n}\n\nexport function formatTargetNode(value: number | string | HTMLElement): string {\n if (typeof HTMLElement !== 'undefined' && value instanceof HTMLElement) {\n return (value.cloneNode(false) as HTMLElement).outerHTML;\n }\n return String(value);\n}\n\n/**\n * Simulates a \"long press\" event on a element.\n *\n * @param opts - Options for the long press.\n * @param opts.element - Element to long press.\n * @param opts.advanceTimer - Function that when called advances the timers in your test suite by a\n * specific amount of time(ms).\n * @param opts.pointeropts - Options to pass to the simulated event. Defaults to mouse. See\n * https://testing-library.com/docs/dom-testing-library/api-events/#fireevent for more info.\n */\nexport async function triggerLongPress(opts: {\n element: HTMLElement;\n advanceTimer: (time: number) => unknown | Promise<unknown>;\n pointerOpts?: Record<string, any>;\n}): Promise<void> {\n let {element, advanceTimer, pointerOpts = {}} = opts;\n let pointerType = pointerOpts.pointerType ?? 'mouse';\n let shouldFireCompatibilityEvents = false;\n act(() => {\n shouldFireCompatibilityEvents = fireEvent.pointerDown(element, {pointerType, ...pointerOpts});\n });\n let shouldFocus = true;\n if (shouldFireCompatibilityEvents) {\n if (pointerType === 'touch') {\n act(() => {\n shouldFocus = shouldFireCompatibilityEvents = fireEvent.touchStart(element, {\n targetTouches: [\n {\n identifier: pointerOpts.pointerId,\n clientX: pointerOpts.clientX,\n clientY: pointerOpts.clientY\n }\n ]\n });\n });\n } else if (pointerType === 'mouse') {\n act(() => {\n shouldFocus = fireEvent.mouseDown(element, pointerOpts);\n });\n if (shouldFocus) {\n act(() => element.focus());\n }\n }\n }\n await act(async () => await advanceTimer(DEFAULT_LONG_PRESS_TIME));\n act(() => {\n fireEvent.pointerUp(element, {pointerType, ...pointerOpts});\n });\n if (shouldFireCompatibilityEvents) {\n if (pointerType === 'touch') {\n act(() => {\n shouldFocus = fireEvent.touchEnd(element, {\n targetTouches: [\n {\n identifier: pointerOpts.pointerId,\n clientX: pointerOpts.clientX,\n clientY: pointerOpts.clientY\n }\n ]\n });\n shouldFocus = fireEvent.mouseDown(element, pointerOpts);\n });\n if (shouldFocus) {\n act(() => element.focus());\n }\n act(() => {\n fireEvent.mouseUp(element, pointerOpts);\n });\n } else if (pointerType === 'mouse') {\n act(() => {\n fireEvent.mouseUp(element, pointerOpts);\n });\n }\n }\n act(() => {\n fireEvent.click(element, {detail: 1, ...pointerOpts});\n });\n}\n\n// Docs cannot handle the types that userEvent actually declares, so hopefully this sub set is okay\nexport async function pressElement(\n user: {\n click: (element: Element) => Promise<void>;\n keyboard: (keys: string) => Promise<void>;\n pointer: (opts: {target: Element; keys: string; coords?: any}) => Promise<void>;\n },\n element: HTMLElement,\n interactionType: UserOpts['interactionType']\n): Promise<void> {\n if (interactionType === 'mouse') {\n // Add coords with pressure so this isn't detected as a virtual click\n await user.pointer({target: element, keys: '[MouseLeft]', coords: {pressure: 0.5}});\n } else if (interactionType === 'keyboard') {\n act(() => element.focus());\n await user.keyboard('[Space]');\n } else if (interactionType === 'touch') {\n await user.pointer({target: element, keys: '[TouchA]'});\n }\n}\n"],"names":[],"version":3,"file":"utils.cjs.map"}