@react-aria/test-utils 1.0.0-alpha.2 → 1.0.0-alpha.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.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2019 Adobe
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAUM,MAAM;IAkIX,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,SAAS;IACvB;IAEA,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEA,IAAI,UAAU;QACZ,IAAI,YAAY,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;QAC3C,OAAO,YAAY,SAAS,cAAc,CAAC,cAAc,YAAY;IACvE;IAaA,IAAI,WAAW;QACb,IAAI,UAAU,IAAI,CAAC,OAAO;QAC1B,IAAI,SACF,OAAO,CAAA,GAAA,iCAAK,EAAE,SAAS,cAAc,CAAC;aAEtC,OAAO,EAAE;IAEb;IAEA,IAAI,gBAAgB;QAClB,IAAI,kBAAkB,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;QACjD,OAAO,kBAAkB,SAAS,cAAc,CAAC,mBAAmB;IACtE;IAhKA,YAAY,IAAqB,CAAE;aA4BnC,qBAAqB,CAAC;YACpB,IAAI,CAAC,gBAAgB,GAAG;QAC1B;aAEA,OAAO,OAAO,OAA8F,CAAC,CAAC;YAC5G,IAAI,mBAAC,kBAAkB,2BAAU,kBAAkB,IAAI,CAAC,gBAAgB,EAAC,GAAG;YAC5E,IAAI,UAAU,IAAI,CAAC,OAAO;YAC1B,IAAI,WAAW,IAAI,CAAC,QAAQ;YAC5B,IAAI,aAAa,QAAS,YAAY,CAAC;YAEvC,IAAI,oBAAoB;gBACtB,IAAI,oBAAoB,SACtB,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;qBAEtB,MAAM,IAAI,CAAC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7K,IAAI,SACF,IAAI,CAAC,QAAQ,GAAG;aACX;YACL,IAAI,UAAU,CAAA,GAAA,iCAAK,EAAE,MAAM,WAAW,CAAC,UAAU;gBAAC,QAAQ;YAAI;YAC9D,IAAI,SACF,IAAI,CAAC,QAAQ,GAAG;iBAEhB,qHAAqH;YACrH,6BAA6B;YAC7B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS;QAElC;IACF;AAuIF","sources":["packages/@react-aria/test-utils/src/combobox.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {act, waitFor, within} from '@testing-library/react';\nimport {BaseTesterOpts, UserOpts} from './user';\n\nexport interface ComboBoxOptions extends UserOpts, BaseTesterOpts {\n user: any,\n trigger?: HTMLElement\n}\n\nexport class ComboBoxTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _combobox: HTMLElement;\n private _trigger: HTMLElement | undefined;\n\n constructor(opts: ComboBoxOptions) {\n let {root, trigger, user, interactionType} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n\n // Handle case where element provided is a wrapper around the combobox. The expectation is that the user at least uses a ref/data attribute to\n // query their combobox/combobox wrapper (in the case of RSP) which they then pass to thhis\n this._combobox = root;\n let combobox = within(root).queryByRole('combobox');\n if (combobox) {\n this._combobox = combobox;\n }\n\n // This is for if user need to directly set the trigger button element (aka the element provided in setElement was the combobox input or the trigger is somewhere unexpected)\n if (trigger) {\n this._trigger = trigger;\n } else {\n let trigger = within(root).queryByRole('button', {hidden: true});\n if (trigger) {\n this._trigger = trigger;\n } else {\n // For cases like https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/ where the combobox\n // is also the trigger button\n this._trigger = this._combobox;\n }\n }\n }\n\n setInteractionType = (type: UserOpts['interactionType']) => {\n this._interactionType = type;\n };\n\n open = async (opts: {triggerBehavior?: 'focus' | 'manual', interactionType?: UserOpts['interactionType']} = {}) => {\n let {triggerBehavior = 'manual', interactionType = this._interactionType} = opts;\n let trigger = this.trigger;\n let combobox = this.combobox;\n let isDisabled = trigger!.hasAttribute('disabled');\n\n if (interactionType === 'mouse') {\n if (triggerBehavior === 'focus') {\n await this.user.click(combobox);\n } else {\n await this.user.click(trigger);\n }\n } else if (interactionType === 'keyboard' && this._trigger != null) {\n act(() => this._trigger!.focus());\n if (triggerBehavior !== 'focus') {\n await this.user.keyboard('{ArrowDown}');\n }\n } else if (interactionType === 'touch') {\n if (triggerBehavior === 'focus') {\n await this.user.pointer({target: combobox, keys: '[TouchA]'});\n } else {\n await this.user.pointer({target: trigger, keys: '[TouchA]'});\n }\n }\n\n await waitFor(() => {\n if (!isDisabled && combobox.getAttribute('aria-controls') == null) {\n throw new Error('No aria-controls found on combobox trigger element.');\n } else {\n return true;\n }\n });\n let listBoxId = combobox.getAttribute('aria-controls');\n await waitFor(() => {\n if (!isDisabled && (!listBoxId || document.getElementById(listBoxId) == null)) {\n throw new Error(`Listbox with id of ${listBoxId} not found in document.`);\n } else {\n return true;\n }\n });\n };\n\n selectOption = async (opts: {option?: HTMLElement, optionText?: string, triggerBehavior?: 'focus' | 'manual', interactionType?: UserOpts['interactionType']} = {}) => {\n let {optionText, option, triggerBehavior, interactionType = this._interactionType} = opts;\n if (!this.combobox.getAttribute('aria-controls')) {\n await this.open({triggerBehavior});\n }\n\n let listbox = this.listbox;\n if (listbox) {\n if (!option && optionText) {\n option = within(listbox).getByText(optionText);\n }\n\n // TODO: keyboard method of selecting the the option is a bit tricky unless I simply simulate the user pressing the down arrow\n // the required amount of times to reach the option. For now just click the option even in keyboard mode\n if (interactionType === 'mouse' || interactionType === 'keyboard') {\n await this.user.click(option);\n } else {\n await this.user.pointer({target: option, keys: '[TouchA]'});\n }\n\n if (option && option.getAttribute('href') == null) {\n await waitFor(() => {\n if (document.contains(listbox)) {\n throw new Error('Expected listbox element to not be in the document after selecting an option');\n } else {\n return true;\n }\n });\n }\n } else {\n throw new Error(\"Attempted to select a option in the combobox, but the listbox wasn't found.\");\n }\n };\n\n close = async () => {\n let listbox = this.listbox;\n if (listbox) {\n act(() => this.combobox.focus());\n await this.user.keyboard('[Escape]');\n\n await waitFor(() => {\n if (document.contains(listbox)) {\n throw new Error('Expected listbox element to not be in the document after selecting an option');\n } else {\n return true;\n }\n });\n }\n };\n\n get combobox() {\n return this._combobox;\n }\n\n get trigger() {\n return this._trigger;\n }\n\n get listbox() {\n let listBoxId = this.combobox.getAttribute('aria-controls');\n return listBoxId ? document.getElementById(listBoxId) || undefined : undefined;\n }\n\n options = (opts: {element?: HTMLElement} = {}): HTMLElement[] | never[] => {\n let {element} = opts;\n element = element || this.listbox;\n let options = [];\n if (element) {\n options = within(element).queryAllByRole('option');\n }\n\n return options;\n };\n\n get sections() {\n let listbox = this.listbox;\n if (listbox) {\n return within(listbox).queryAllByRole('group');\n } else {\n return [];\n }\n }\n\n get focusedOption() {\n let focusedOptionId = this.combobox.getAttribute('aria-activedescendant');\n return focusedOptionId ? document.getElementById(focusedOptionId) : undefined;\n }\n}\n"],"names":[],"version":3,"file":"combobox.main.js.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAUM,MAAM;IAkIX,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,SAAS;IACvB;IAEA,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEA,IAAI,UAAU;QACZ,IAAI,YAAY,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;QAC3C,OAAO,YAAY,SAAS,cAAc,CAAC,cAAc,YAAY;IACvE;IAaA,IAAI,WAAW;QACb,IAAI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AAC;gBAEzB,MAAM,CAAA,GAAA,kCAAM,EAAE;oBACZ,IAAI,SAAS,QAAQ,CAAC,UACpB,MAAM,IAAI,MAAM;yBAEhB,OAAO;gBAEX;YACF;QACF;aAeA,UAAU,CAAC,OAAgC,CAAC,CAAC;YAC3C,IAAI,WAAC,OAAO,EAAC,GAAG;YAChB,UAAU,WAAW,IAAI,CAAC,OAAO;YACjC,IAAI,UAAU,EAAE;YAChB,IAAI,SACF,UAAU,CAAA,GAAA,iCAAK,EAAE,SAAS,cAAc,CAAC;YAG3C,OAAO;QACT;QAjJE,IAAI,QAAC,IAAI,WAAE,OAAO,QAAE,IAAI,mBAAE,eAAe,EAAC,GAAG;QAC7C,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,gBAAgB,GAAG,mBAAmB;QAE3C,8IAA8I;QAC9I,2FAA2F;QAC3F,IAAI,CAAC,SAAS,GAAG;QACjB,IAAI,WAAW,CAAA,GAAA,iCAAK,EAAE,MAAM,WAAW,CAAC;QACxC,IAAI,UACF,IAAI,CAAC,SAAS,GAAG;QAGnB,6KAA6K;QAC7K,IAAI,SACF,IAAI,CAAC,QAAQ,GAAG;aACX;YACL,IAAI,UAAU,CAAA,GAAA,iCAAK,EAAE,MAAM,WAAW,CAAC,UAAU;gBAAC,QAAQ;YAAI;YAC9D,IAAI,SACF,IAAI,CAAC,QAAQ,GAAG;iBAEhB,qHAAqH;YACrH,6BAA6B;YAC7B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS;QAElC;IACF;AAuIF","sources":["packages/@react-aria/test-utils/src/combobox.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {act, waitFor, within} from '@testing-library/react';\nimport {BaseTesterOpts, UserOpts} from './user';\n\nexport interface ComboBoxOptions extends UserOpts, BaseTesterOpts {\n user?: any,\n trigger?: HTMLElement\n}\n\nexport class ComboBoxTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _combobox: HTMLElement;\n private _trigger: HTMLElement | undefined;\n\n constructor(opts: ComboBoxOptions) {\n let {root, trigger, user, interactionType} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n\n // Handle case where element provided is a wrapper around the combobox. The expectation is that the user at least uses a ref/data attribute to\n // query their combobox/combobox wrapper (in the case of RSP) which they then pass to thhis\n this._combobox = root;\n let combobox = within(root).queryByRole('combobox');\n if (combobox) {\n this._combobox = combobox;\n }\n\n // This is for if user need to directly set the trigger button element (aka the element provided in setElement was the combobox input or the trigger is somewhere unexpected)\n if (trigger) {\n this._trigger = trigger;\n } else {\n let trigger = within(root).queryByRole('button', {hidden: true});\n if (trigger) {\n this._trigger = trigger;\n } else {\n // For cases like https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/ where the combobox\n // is also the trigger button\n this._trigger = this._combobox;\n }\n }\n }\n\n setInteractionType = (type: UserOpts['interactionType']) => {\n this._interactionType = type;\n };\n\n open = async (opts: {triggerBehavior?: 'focus' | 'manual', interactionType?: UserOpts['interactionType']} = {}) => {\n let {triggerBehavior = 'manual', interactionType = this._interactionType} = opts;\n let trigger = this.trigger;\n let combobox = this.combobox;\n let isDisabled = trigger!.hasAttribute('disabled');\n\n if (interactionType === 'mouse') {\n if (triggerBehavior === 'focus') {\n await this.user.click(combobox);\n } else {\n await this.user.click(trigger);\n }\n } else if (interactionType === 'keyboard' && this._trigger != null) {\n act(() => this._trigger!.focus());\n if (triggerBehavior !== 'focus') {\n await this.user.keyboard('{ArrowDown}');\n }\n } else if (interactionType === 'touch') {\n if (triggerBehavior === 'focus') {\n await this.user.pointer({target: combobox, keys: '[TouchA]'});\n } else {\n await this.user.pointer({target: trigger, keys: '[TouchA]'});\n }\n }\n\n await waitFor(() => {\n if (!isDisabled && combobox.getAttribute('aria-controls') == null) {\n throw new Error('No aria-controls found on combobox trigger element.');\n } else {\n return true;\n }\n });\n let listBoxId = combobox.getAttribute('aria-controls');\n await waitFor(() => {\n if (!isDisabled && (!listBoxId || document.getElementById(listBoxId) == null)) {\n throw new Error(`Listbox with id of ${listBoxId} not found in document.`);\n } else {\n return true;\n }\n });\n };\n\n selectOption = async (opts: {option?: HTMLElement, optionText?: string, triggerBehavior?: 'focus' | 'manual', interactionType?: UserOpts['interactionType']} = {}) => {\n let {optionText, option, triggerBehavior, interactionType = this._interactionType} = opts;\n if (!this.combobox.getAttribute('aria-controls')) {\n await this.open({triggerBehavior});\n }\n\n let listbox = this.listbox;\n if (listbox) {\n if (!option && optionText) {\n option = within(listbox).getByText(optionText);\n }\n\n // TODO: keyboard method of selecting the the option is a bit tricky unless I simply simulate the user pressing the down arrow\n // the required amount of times to reach the option. For now just click the option even in keyboard mode\n if (interactionType === 'mouse' || interactionType === 'keyboard') {\n await this.user.click(option);\n } else {\n await this.user.pointer({target: option, keys: '[TouchA]'});\n }\n\n if (option && option.getAttribute('href') == null) {\n await waitFor(() => {\n if (document.contains(listbox)) {\n throw new Error('Expected listbox element to not be in the document after selecting an option');\n } else {\n return true;\n }\n });\n }\n } else {\n throw new Error(\"Attempted to select a option in the combobox, but the listbox wasn't found.\");\n }\n };\n\n close = async () => {\n let listbox = this.listbox;\n if (listbox) {\n act(() => this.combobox.focus());\n await this.user.keyboard('[Escape]');\n\n await waitFor(() => {\n if (document.contains(listbox)) {\n throw new Error('Expected listbox element to not be in the document after selecting an option');\n } else {\n return true;\n }\n });\n }\n };\n\n get combobox() {\n return this._combobox;\n }\n\n get trigger() {\n return this._trigger;\n }\n\n get listbox() {\n let listBoxId = this.combobox.getAttribute('aria-controls');\n return listBoxId ? document.getElementById(listBoxId) || undefined : undefined;\n }\n\n options = (opts: {element?: HTMLElement} = {}): HTMLElement[] | never[] => {\n let {element} = opts;\n element = element || this.listbox;\n let options = [];\n if (element) {\n options = within(element).queryAllByRole('option');\n }\n\n return options;\n };\n\n get sections() {\n let listbox = this.listbox;\n if (listbox) {\n return within(listbox).queryAllByRole('group');\n } else {\n return [];\n }\n }\n\n get focusedOption() {\n let focusedOptionId = this.combobox.getAttribute('aria-activedescendant');\n return focusedOptionId ? document.getElementById(focusedOptionId) : undefined;\n }\n}\n"],"names":[],"version":3,"file":"combobox.main.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC;AAUM,MAAM;IAkIX,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,SAAS;IACvB;IAEA,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEA,IAAI,UAAU;QACZ,IAAI,YAAY,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;QAC3C,OAAO,YAAY,SAAS,cAAc,CAAC,cAAc,YAAY;IACvE;IAaA,IAAI,WAAW;QACb,IAAI,UAAU,IAAI,CAAC,OAAO;QAC1B,IAAI,SACF,OAAO,CAAA,GAAA,aAAK,EAAE,SAAS,cAAc,CAAC;aAEtC,OAAO,EAAE;IAEb;IAEA,IAAI,gBAAgB;QAClB,IAAI,kBAAkB,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;QACjD,OAAO,kBAAkB,SAAS,cAAc,CAAC,mBAAmB;IACtE;IAhKA,YAAY,IAAqB,CAAE;aA4BnC,qBAAqB,CAAC;YACpB,IAAI,CAAC,gBAAgB,GAAG;QAC1B;aAEA,OAAO,OAAO,OAA8F,CAAC,CAAC;YAC5G,IAAI,mBAAC,kBAAkB,2BAAU,kBAAkB,IAAI,CAAC,gBAAgB,EAAC,GAAG;YAC5E,IAAI,UAAU,IAAI,CAAC,OAAO;YAC1B,IAAI,WAAW,IAAI,CAAC,QAAQ;YAC5B,IAAI,aA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,GAAG;QACjB,IAAI,WAAW,CAAA,GAAA,aAAK,EAAE,MAAM,WAAW,CAAC;QACxC,IAAI,UACF,IAAI,CAAC,SAAS,GAAG;QAGnB,6KAA6K;QAC7K,IAAI,SACF,IAAI,CAAC,QAAQ,GAAG;aACX;YACL,IAAI,UAAU,CAAA,GAAA,aAAK,EAAE,MAAM,WAAW,CAAC,UAAU;gBAAC,QAAQ;YAAI;YAC9D,IAAI,SACF,IAAI,CAAC,QAAQ,GAAG;iBAEhB,qHAAqH;YACrH,6BAA6B;YAC7B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS;QAElC;IACF;AAuIF","sources":["packages/@react-aria/test-utils/src/combobox.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {act, waitFor, within} from '@testing-library/react';\nimport {BaseTesterOpts, UserOpts} from './user';\n\nexport interface ComboBoxOptions extends UserOpts, BaseTesterOpts {\n user: any,\n trigger?: HTMLElement\n}\n\nexport class ComboBoxTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _combobox: HTMLElement;\n private _trigger: HTMLElement | undefined;\n\n constructor(opts: ComboBoxOptions) {\n let {root, trigger, user, interactionType} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n\n // Handle case where element provided is a wrapper around the combobox. The expectation is that the user at least uses a ref/data attribute to\n // query their combobox/combobox wrapper (in the case of RSP) which they then pass to thhis\n this._combobox = root;\n let combobox = within(root).queryByRole('combobox');\n if (combobox) {\n this._combobox = combobox;\n }\n\n // This is for if user need to directly set the trigger button element (aka the element provided in setElement was the combobox input or the trigger is somewhere unexpected)\n if (trigger) {\n this._trigger = trigger;\n } else {\n let trigger = within(root).queryByRole('button', {hidden: true});\n if (trigger) {\n this._trigger = trigger;\n } else {\n // For cases like https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/ where the combobox\n // is also the trigger button\n this._trigger = this._combobox;\n }\n }\n }\n\n setInteractionType = (type: UserOpts['interactionType']) => {\n this._interactionType = type;\n };\n\n open = async (opts: {triggerBehavior?: 'focus' | 'manual', interactionType?: UserOpts['interactionType']} = {}) => {\n let {triggerBehavior = 'manual', interactionType = this._interactionType} = opts;\n let trigger = this.trigger;\n let combobox = this.combobox;\n let isDisabled = trigger!.hasAttribute('disabled');\n\n if (interactionType === 'mouse') {\n if (triggerBehavior === 'focus') {\n await this.user.click(combobox);\n } else {\n await this.user.click(trigger);\n }\n } else if (interactionType === 'keyboard' && this._trigger != null) {\n act(() => this._trigger!.focus());\n if (triggerBehavior !== 'focus') {\n await this.user.keyboard('{ArrowDown}');\n }\n } else if (interactionType === 'touch') {\n if (triggerBehavior === 'focus') {\n await this.user.pointer({target: combobox, keys: '[TouchA]'});\n } else {\n await this.user.pointer({target: trigger, keys: '[TouchA]'});\n }\n }\n\n await waitFor(() => {\n if (!isDisabled && combobox.getAttribute('aria-controls') == null) {\n throw new Error('No aria-controls found on combobox trigger element.');\n } else {\n return true;\n }\n });\n let listBoxId = combobox.getAttribute('aria-controls');\n await waitFor(() => {\n if (!isDisabled && (!listBoxId || document.getElementById(listBoxId) == null)) {\n throw new Error(`Listbox with id of ${listBoxId} not found in document.`);\n } else {\n return true;\n }\n });\n };\n\n selectOption = async (opts: {option?: HTMLElement, optionText?: string, triggerBehavior?: 'focus' | 'manual', interactionType?: UserOpts['interactionType']} = {}) => {\n let {optionText, option, triggerBehavior, interactionType = this._interactionType} = opts;\n if (!this.combobox.getAttribute('aria-controls')) {\n await this.open({triggerBehavior});\n }\n\n let listbox = this.listbox;\n if (listbox) {\n if (!option && optionText) {\n option = within(listbox).getByText(optionText);\n }\n\n // TODO: keyboard method of selecting the the option is a bit tricky unless I simply simulate the user pressing the down arrow\n // the required amount of times to reach the option. For now just click the option even in keyboard mode\n if (interactionType === 'mouse' || interactionType === 'keyboard') {\n await this.user.click(option);\n } else {\n await this.user.pointer({target: option, keys: '[TouchA]'});\n }\n\n if (option && option.getAttribute('href') == null) {\n await waitFor(() => {\n if (document.contains(listbox)) {\n throw new Error('Expected listbox element to not be in the document after selecting an option');\n } else {\n return true;\n }\n });\n }\n } else {\n throw new Error(\"Attempted to select a option in the combobox, but the listbox wasn't found.\");\n }\n };\n\n close = async () => {\n let listbox = this.listbox;\n if (listbox) {\n act(() => this.combobox.focus());\n await this.user.keyboard('[Escape]');\n\n await waitFor(() => {\n if (document.contains(listbox)) {\n throw new Error('Expected listbox element to not be in the document after selecting an option');\n } else {\n return true;\n }\n });\n }\n };\n\n get combobox() {\n return this._combobox;\n }\n\n get trigger() {\n return this._trigger;\n }\n\n get listbox() {\n let listBoxId = this.combobox.getAttribute('aria-controls');\n return listBoxId ? document.getElementById(listBoxId) || undefined : undefined;\n }\n\n options = (opts: {element?: HTMLElement} = {}): HTMLElement[] | never[] => {\n let {element} = opts;\n element = element || this.listbox;\n let options = [];\n if (element) {\n options = within(element).queryAllByRole('option');\n }\n\n return options;\n };\n\n get sections() {\n let listbox = this.listbox;\n if (listbox) {\n return within(listbox).queryAllByRole('group');\n } else {\n return [];\n }\n }\n\n get focusedOption() {\n let focusedOptionId = this.combobox.getAttribute('aria-activedescendant');\n return focusedOptionId ? document.getElementById(focusedOptionId) : undefined;\n }\n}\n"],"names":[],"version":3,"file":"combobox.module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AAUM,MAAM;IAkIX,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,SAAS;IACvB;IAEA,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEA,IAAI,UAAU;QACZ,IAAI,YAAY,I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X,CAAA,GAAA,UAAE,EAAE,IAAM,IAAI,CAAC,QAAQ,CAAC,KAAK;gBAC7B,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAEzB,MAAM,CAAA,GAAA,cAAM,EAAE;oBACZ,IAAI,SAAS,QAAQ,CAAC,UACpB,MAAM,IAAI,MAAM;yBAEhB,OAAO;gBAEX;YACF;QACF;aAeA,UAAU,CAAC,OAAgC,CAAC,CAAC;YAC3C,IAAI,WAAC,OAAO,EAAC,GAAG;YAChB,UAAU,WAAW,IAAI,CAAC,OAAO;YACjC,IAAI,UAAU,EAAE;YAChB,IAAI,SACF,UAAU,CAAA,GAAA,aAAK,EAAE,SAAS,cAAc,CAAC;YAG3C,OAAO;QACT;QAjJE,IAAI,QAAC,IAAI,WAAE,OAAO,QAAE,IAAI,mBAAE,eAAe,EAAC,GAAG;QAC7C,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,gBAAgB,GAAG,mBAAmB;QAE3C,8IAA8I;QAC9I,2FAA2F;QAC3F,IAAI,CAAC,SAAS,GAAG;QACjB,IAAI,WAAW,CAAA,GAAA,aAAK,EAAE,MAAM,WAAW,CAAC;QACxC,IAAI,UACF,IAAI,CAAC,SAAS,GAAG;QAGnB,6KAA6K;QAC7K,IAAI,SACF,IAAI,CAAC,QAAQ,GAAG;aACX;YACL,IAAI,UAAU,CAAA,GAAA,aAAK,EAAE,MAAM,WAAW,CAAC,UAAU;gBAAC,QAAQ;YAAI;YAC9D,IAAI,SACF,IAAI,CAAC,QAAQ,GAAG;iBAEhB,qHAAqH;YACrH,6BAA6B;YAC7B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS;QAElC;IACF;AAuIF","sources":["packages/@react-aria/test-utils/src/combobox.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {act, waitFor, within} from '@testing-library/react';\nimport {BaseTesterOpts, UserOpts} from './user';\n\nexport interface ComboBoxOptions extends UserOpts, BaseTesterOpts {\n user?: any,\n trigger?: HTMLElement\n}\n\nexport class ComboBoxTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _combobox: HTMLElement;\n private _trigger: HTMLElement | undefined;\n\n constructor(opts: ComboBoxOptions) {\n let {root, trigger, user, interactionType} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n\n // Handle case where element provided is a wrapper around the combobox. The expectation is that the user at least uses a ref/data attribute to\n // query their combobox/combobox wrapper (in the case of RSP) which they then pass to thhis\n this._combobox = root;\n let combobox = within(root).queryByRole('combobox');\n if (combobox) {\n this._combobox = combobox;\n }\n\n // This is for if user need to directly set the trigger button element (aka the element provided in setElement was the combobox input or the trigger is somewhere unexpected)\n if (trigger) {\n this._trigger = trigger;\n } else {\n let trigger = within(root).queryByRole('button', {hidden: true});\n if (trigger) {\n this._trigger = trigger;\n } else {\n // For cases like https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/ where the combobox\n // is also the trigger button\n this._trigger = this._combobox;\n }\n }\n }\n\n setInteractionType = (type: UserOpts['interactionType']) => {\n this._interactionType = type;\n };\n\n open = async (opts: {triggerBehavior?: 'focus' | 'manual', interactionType?: UserOpts['interactionType']} = {}) => {\n let {triggerBehavior = 'manual', interactionType = this._interactionType} = opts;\n let trigger = this.trigger;\n let combobox = this.combobox;\n let isDisabled = trigger!.hasAttribute('disabled');\n\n if (interactionType === 'mouse') {\n if (triggerBehavior === 'focus') {\n await this.user.click(combobox);\n } else {\n await this.user.click(trigger);\n }\n } else if (interactionType === 'keyboard' && this._trigger != null) {\n act(() => this._trigger!.focus());\n if (triggerBehavior !== 'focus') {\n await this.user.keyboard('{ArrowDown}');\n }\n } else if (interactionType === 'touch') {\n if (triggerBehavior === 'focus') {\n await this.user.pointer({target: combobox, keys: '[TouchA]'});\n } else {\n await this.user.pointer({target: trigger, keys: '[TouchA]'});\n }\n }\n\n await waitFor(() => {\n if (!isDisabled && combobox.getAttribute('aria-controls') == null) {\n throw new Error('No aria-controls found on combobox trigger element.');\n } else {\n return true;\n }\n });\n let listBoxId = combobox.getAttribute('aria-controls');\n await waitFor(() => {\n if (!isDisabled && (!listBoxId || document.getElementById(listBoxId) == null)) {\n throw new Error(`Listbox with id of ${listBoxId} not found in document.`);\n } else {\n return true;\n }\n });\n };\n\n selectOption = async (opts: {option?: HTMLElement, optionText?: string, triggerBehavior?: 'focus' | 'manual', interactionType?: UserOpts['interactionType']} = {}) => {\n let {optionText, option, triggerBehavior, interactionType = this._interactionType} = opts;\n if (!this.combobox.getAttribute('aria-controls')) {\n await this.open({triggerBehavior});\n }\n\n let listbox = this.listbox;\n if (listbox) {\n if (!option && optionText) {\n option = within(listbox).getByText(optionText);\n }\n\n // TODO: keyboard method of selecting the the option is a bit tricky unless I simply simulate the user pressing the down arrow\n // the required amount of times to reach the option. For now just click the option even in keyboard mode\n if (interactionType === 'mouse' || interactionType === 'keyboard') {\n await this.user.click(option);\n } else {\n await this.user.pointer({target: option, keys: '[TouchA]'});\n }\n\n if (option && option.getAttribute('href') == null) {\n await waitFor(() => {\n if (document.contains(listbox)) {\n throw new Error('Expected listbox element to not be in the document after selecting an option');\n } else {\n return true;\n }\n });\n }\n } else {\n throw new Error(\"Attempted to select a option in the combobox, but the listbox wasn't found.\");\n }\n };\n\n close = async () => {\n let listbox = this.listbox;\n if (listbox) {\n act(() => this.combobox.focus());\n await this.user.keyboard('[Escape]');\n\n await waitFor(() => {\n if (document.contains(listbox)) {\n throw new Error('Expected listbox element to not be in the document after selecting an option');\n } else {\n return true;\n }\n });\n }\n };\n\n get combobox() {\n return this._combobox;\n }\n\n get trigger() {\n return this._trigger;\n }\n\n get listbox() {\n let listBoxId = this.combobox.getAttribute('aria-controls');\n return listBoxId ? document.getElementById(listBoxId) || undefined : undefined;\n }\n\n options = (opts: {element?: HTMLElement} = {}): HTMLElement[] | never[] => {\n let {element} = opts;\n element = element || this.listbox;\n let options = [];\n if (element) {\n options = within(element).queryAllByRole('option');\n }\n\n return options;\n };\n\n get sections() {\n let listbox = this.listbox;\n if (listbox) {\n return within(listbox).queryAllByRole('group');\n } else {\n return [];\n }\n }\n\n get focusedOption() {\n let focusedOptionId = this.combobox.getAttribute('aria-activedescendant');\n return focusedOptionId ? document.getElementById(focusedOptionId) : undefined;\n }\n}\n"],"names":[],"version":3,"file":"combobox.module.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AASM,MAAM;IA+EX,wGAAwG;IACxG,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,SAAS;IACvB;IAEA,IAAI,OAAO;YACK;QAAd,OAAO,CAAA,GAAA,iCAAK,GAAE,QAAA,IAAI,cAAJ,4BAAA,MAAM,QAAQ,EAAE,cAAc,CAAC;IAC/C;IAEA,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA,MAAO,IAAI,YAAY,CAAC,qBAAqB;IACvE;IApFA,YAAY,IAAqB,CAAE;aAOnC,qBAAqB,CAAC;YACpB,IAAI,CAAC,gBAAgB,GAAG;QAC1B;QAEA,+GAA+G;QAC/G,6IAA6I;QAC7I,kHAAkH;QAClH,0HAA0H;QAC1H,oDAAoD;aACpD,qBAAqB,OAAO,OAAuF,CAAC,CAAC;YACnH,IAAI,SAAC,KAAK,QAAE,IAAI,mBAAE,kBAAkB,IAAI,CAAC,gBAAgB,EAAC,GAAG;YAE7D,IAAI,MAAM,IAAI,CAAC,OAAO,CAAC;uBAAC;sBAAO;YAAI;YACnC,IAAI,cAAc,CAAA,GAAA,iCAAK,EA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ChB,OAAO,CAAA,GAAA,iCAAK,EAAE,WAAW,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC;QACzD;QAxFE,IAAI,QAAC,IAAI,QAAE,IAAI,mBAAE,eAAe,EAAC,GAAG;QACpC,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,gBAAgB,GAAG,mBAAmB;QAC3C,IAAI,CAAC,SAAS,GAAG;IACnB;AAqFF","sources":["packages/@react-aria/test-utils/src/gridlist.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 {BaseTesterOpts, UserOpts} from './user';\nimport {pressElement} from './events';\n\nexport interface GridListOptions extends UserOpts, BaseTesterOpts {\n user: any\n}\nexport class GridListTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _gridlist: HTMLElement;\n\n\n constructor(opts: GridListOptions) {\n let {root, user, interactionType} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n this._gridlist = root;\n }\n\n setInteractionType = (type: UserOpts['interactionType']) => {\n this._interactionType = type;\n };\n\n // TODO: support long press? This is also pretty much the same as table's toggleRowSelection so maybe can share\n // For now, don't include long press, see if people need it or if we should just expose long press as a separate util if it isn't very common\n // If the current way of passing in the user specified advance timers is ok, then I'd be find including long press\n // Maybe also support an option to force the click to happen on a specific part of the element (checkbox or row). That way\n // the user can test a specific type of interaction?\n toggleRowSelection = async (opts: {index?: number, text?: string, interactionType?: UserOpts['interactionType']} = {}) => {\n let {index, text, interactionType = this._interactionType} = opts;\n\n let row = this.findRow({index, text});\n let rowCheckbox = within(row).queryByRole('checkbox');\n if (rowCheckbox) {\n await pressElement(this.user, rowCheckbox, interactionType);\n } else {\n let cell = within(row).getAllByRole('gridcell')[0];\n await pressElement(this.user, cell, interactionType);\n }\n };\n\n // TODO: pretty much the same as table except it uses this.gridlist. Make common between the two by accepting an option for\n // an element?\n findRow = (opts: {index?: number, text?: string}) => {\n let {\n index,\n text\n } = opts;\n\n let row;\n if (index != null) {\n row = this.rows[index];\n } else if (text != null) {\n row = within(this?.gridlist).getByText(text);\n while (row && row.getAttribute('role') !== 'row') {\n row = row.parentElement;\n }\n }\n\n return row;\n };\n\n // TODO: There is a more difficult use case where the row has/behaves as link, don't think we have a good way to determine that unless the\n // user specificlly tells us\n triggerRowAction = async (opts: {index?: number, text?: string, needsDoubleClick?: boolean, interactionType?: UserOpts['interactionType']}) => {\n let {\n index,\n text,\n needsDoubleClick,\n interactionType = this._interactionType\n } = opts;\n\n let row = this.findRow({index, text});\n if (row) {\n if (needsDoubleClick) {\n await this.user.dblClick(row);\n } else if (interactionType === 'keyboard') {\n act(() => row.focus());\n await this.user.keyboard('[Enter]');\n } else {\n await pressElement(this.user, row, interactionType);\n }\n }\n };\n\n // TODO: do we really need this getter? Theoretically the user already has the reference to the gridlist\n get gridlist() {\n return this._gridlist;\n }\n\n get rows() {\n return within(this?.gridlist).queryAllByRole('row');\n }\n\n get selectedRows() {\n return this.rows.filter(row => row.getAttribute('aria-selected') === 'true');\n }\n\n cells = (opts: {element?: HTMLElement} = {}) => {\n let {element} = opts;\n return within(element || this.gridlist).queryAllByRole('gridcell');\n };\n}\n"],"names":[],"version":3,"file":"gridlist.main.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AASM,MAAM;IA+EX,wGAAwG;IACxG,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,SAAS;IACvB;IAEA,IAAI,OAAO;YACK;QAAd,OAAO,CAAA,GAAA,iCAAK,GAAE,QAAA,IAAI,cAAJ,4BAAA,MA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AO;YACxB,IAAI,SACF,KAAK,QACL,IAAI,oBACJ,gBAAgB,mBAChB,kBAAkB,IAAI,CAAC,gBAAgB,EACxC,GAAG;YAEJ,IAAI,MAAM,IAAI,CAAC,OAAO,CAAC;uBAAC;sBAAO;YAAI;YACnC,IAAI,KAAK;gBACP,IAAI,kBACF,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;qBACpB,IAAI,oBAAoB,YAAY;oBACzC,CAAA,GAAA,8BAAE,EAAE,IAAM,IAAI,KAAK;oBACnB,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAC3B,OACE,MAAM,CAAA,GAAA,sCAAW,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK;YAEvC;QACF;aAeA,QAAQ,CAAC,OAAgC,CAAC,CAAC;YACzC,IAAI,WAAC,OAAO,EAAC,GAAG;YAChB,OAAO,CAAA,GAAA,iCAAK,EAAE,WAAW,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC;QACzD;QAxFE,IAAI,QAAC,IAAI,QAAE,IAAI,mBAAE,eAAe,EAAC,GAAG;QACpC,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,gBAAgB,GAAG,mBAAmB;QAC3C,IAAI,CAAC,SAAS,GAAG;IACnB;AAqFF","sources":["packages/@react-aria/test-utils/src/gridlist.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 {BaseTesterOpts, UserOpts} from './user';\nimport {pressElement} from './events';\n\nexport interface GridListOptions extends UserOpts, BaseTesterOpts {\n user?: any\n}\nexport class GridListTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _gridlist: HTMLElement;\n\n\n constructor(opts: GridListOptions) {\n let {root, user, interactionType} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n this._gridlist = root;\n }\n\n setInteractionType = (type: UserOpts['interactionType']) => {\n this._interactionType = type;\n };\n\n // TODO: support long press? This is also pretty much the same as table's toggleRowSelection so maybe can share\n // For now, don't include long press, see if people need it or if we should just expose long press as a separate util if it isn't very common\n // If the current way of passing in the user specified advance timers is ok, then I'd be find including long press\n // Maybe also support an option to force the click to happen on a specific part of the element (checkbox or row). That way\n // the user can test a specific type of interaction?\n toggleRowSelection = async (opts: {index?: number, text?: string, interactionType?: UserOpts['interactionType']} = {}) => {\n let {index, text, interactionType = this._interactionType} = opts;\n\n let row = this.findRow({index, text});\n let rowCheckbox = within(row).queryByRole('checkbox');\n if (rowCheckbox) {\n await pressElement(this.user, rowCheckbox, interactionType);\n } else {\n let cell = within(row).getAllByRole('gridcell')[0];\n await pressElement(this.user, cell, interactionType);\n }\n };\n\n // TODO: pretty much the same as table except it uses this.gridlist. Make common between the two by accepting an option for\n // an element?\n findRow = (opts: {index?: number, text?: string}) => {\n let {\n index,\n text\n } = opts;\n\n let row;\n if (index != null) {\n row = this.rows[index];\n } else if (text != null) {\n row = within(this?.gridlist).getByText(text);\n while (row && row.getAttribute('role') !== 'row') {\n row = row.parentElement;\n }\n }\n\n return row;\n };\n\n // TODO: There is a more difficult use case where the row has/behaves as link, don't think we have a good way to determine that unless the\n // user specificlly tells us\n triggerRowAction = async (opts: {index?: number, text?: string, needsDoubleClick?: boolean, interactionType?: UserOpts['interactionType']}) => {\n let {\n index,\n text,\n needsDoubleClick,\n interactionType = this._interactionType\n } = opts;\n\n let row = this.findRow({index, text});\n if (row) {\n if (needsDoubleClick) {\n await this.user.dblClick(row);\n } else if (interactionType === 'keyboard') {\n act(() => row.focus());\n await this.user.keyboard('[Enter]');\n } else {\n await pressElement(this.user, row, interactionType);\n }\n }\n };\n\n // TODO: do we really need this getter? Theoretically the user already has the reference to the gridlist\n get gridlist() {\n return this._gridlist;\n }\n\n get rows() {\n return within(this?.gridlist).queryAllByRole('row');\n }\n\n get selectedRows() {\n return this.rows.filter(row => row.getAttribute('aria-selected') === 'true');\n }\n\n cells = (opts: {element?: HTMLElement} = {}) => {\n let {element} = opts;\n return within(element || this.gridlist).queryAllByRole('gridcell');\n };\n}\n"],"names":[],"version":3,"file":"gridlist.main.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AASM,MAAM;IA+EX,wGAAwG;IACxG,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,SAAS;IACvB;IAEA,IAAI,OAAO;YACK;QAAd,OAAO,CAAA,GAAA,aAAK,GAAE,QAAA,IAAI,cAAJ,4BAAA,MAAM,QAAQ,EAAE,cAAc,CAAC;IAC/C;IAEA,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA,MAAO,IAAI,YAAY,CAAC,qBAAqB;IACvE;IApFA,YAAY,IAAqB,CAAE;aAOnC,qBAAqB,CAAC;YACpB,IAAI,CAAC,gBAAgB,GAAG;QAC1B;QAEA,+GAA+G;QAC/G,6IAA6I;QAC7I,kHAAkH;QAClH,0HAA0H;QAC1H,oDAAoD;aACpD,qBAAqB,OAAO,OAAuF,CAAC,CAAC;YACnH,IAAI,SAAC,KAAK,QAAE,IAAI,mBAAE,kBAAkB,IAAI,CAAC,gBAAgB,EAAC,GAAG;YAE7D,IAAI,MAAM,IAAI,CAAC,OAAO,CAAC;uBAAC;sBAAO;YAAI;YACnC,IAAI,cAAc,CAAA,GAAA,aAAK,EAAE,KAAK,WAAW,CAAC;YAC1C,IAAI,aACF,MAAM,CAAA,GAAA,yCAAW,EAAE,IAAI,CAAC,IAAI,EAAE,aAAa;iBACtC;gBACL,IAAI,OAAO,CAAA,GAAA,aAAK,EAAE,KAA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CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,gBAAgB,GAAG,mBAAmB;QAC3C,IAAI,CAAC,SAAS,GAAG;IACnB;AAqFF","sources":["packages/@react-aria/test-utils/src/gridlist.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 {BaseTesterOpts, UserOpts} from './user';\nimport {pressElement} from './events';\n\nexport interface GridListOptions extends UserOpts, BaseTesterOpts {\n user: any\n}\nexport class GridListTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _gridlist: HTMLElement;\n\n\n constructor(opts: GridListOptions) {\n let {root, user, interactionType} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n this._gridlist = root;\n }\n\n setInteractionType = (type: UserOpts['interactionType']) => {\n this._interactionType = type;\n };\n\n // TODO: support long press? This is also pretty much the same as table's toggleRowSelection so maybe can share\n // For now, don't include long press, see if people need it or if we should just expose long press as a separate util if it isn't very common\n // If the current way of passing in the user specified advance timers is ok, then I'd be find including long press\n // Maybe also support an option to force the click to happen on a specific part of the element (checkbox or row). That way\n // the user can test a specific type of interaction?\n toggleRowSelection = async (opts: {index?: number, text?: string, interactionType?: UserOpts['interactionType']} = {}) => {\n let {index, text, interactionType = this._interactionType} = opts;\n\n let row = this.findRow({index, text});\n let rowCheckbox = within(row).queryByRole('checkbox');\n if (rowCheckbox) {\n await pressElement(this.user, rowCheckbox, interactionType);\n } else {\n let cell = within(row).getAllByRole('gridcell')[0];\n await pressElement(this.user, cell, interactionType);\n }\n };\n\n // TODO: pretty much the same as table except it uses this.gridlist. Make common between the two by accepting an option for\n // an element?\n findRow = (opts: {index?: number, text?: string}) => {\n let {\n index,\n text\n } = opts;\n\n let row;\n if (index != null) {\n row = this.rows[index];\n } else if (text != null) {\n row = within(this?.gridlist).getByText(text);\n while (row && row.getAttribute('role') !== 'row') {\n row = row.parentElement;\n }\n }\n\n return row;\n };\n\n // TODO: There is a more difficult use case where the row has/behaves as link, don't think we have a good way to determine that unless the\n // user specificlly tells us\n triggerRowAction = async (opts: {index?: number, text?: string, needsDoubleClick?: boolean, interactionType?: UserOpts['interactionType']}) => {\n let {\n index,\n text,\n needsDoubleClick,\n interactionType = this._interactionType\n } = opts;\n\n let row = this.findRow({index, text});\n if (row) {\n if (needsDoubleClick) {\n await this.user.dblClick(row);\n } else if (interactionType === 'keyboard') {\n act(() => row.focus());\n await this.user.keyboard('[Enter]');\n } else {\n await pressElement(this.user, row, interactionType);\n }\n }\n };\n\n // TODO: do we really need this getter? Theoretically the user already has the reference to the gridlist\n get gridlist() {\n return this._gridlist;\n }\n\n get rows() {\n return within(this?.gridlist).queryAllByRole('row');\n }\n\n get selectedRows() {\n return this.rows.filter(row => row.getAttribute('aria-selected') === 'true');\n }\n\n cells = (opts: {element?: HTMLElement} = {}) => {\n let {element} = opts;\n return within(element || this.gridlist).queryAllByRole('gridcell');\n };\n}\n"],"names":[],"version":3,"file":"gridlist.module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AASM,MAAM;IA+EX,wGAAwG;IACxG,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,SAAS;IACvB;IAEA,IAAI,OAAO;YACK;QAAd,OAAO,CAAA,GAAA,aAAK,GAAE,QAAA,IAAI,cAAJ,4BAAA,MAAM,QAAQ,EAAE,cAAc,CAAC;IAC/C;IAEA,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA,MAAO,IAAI,YAAY,CAAC,qBAAqB;IACvE;IApFA,YAAY,IAAqB,C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IAAI,KAAK;gBACP,IAAI,kBACF,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;qBACpB,IAAI,oBAAoB,YAAY;oBACzC,CAAA,GAAA,UAAE,EAAE,IAAM,IAAI,KAAK;oBACnB,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAC3B,OACE,MAAM,CAAA,GAAA,yCAAW,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK;YAEvC;QACF;aAeA,QAAQ,CAAC,OAAgC,CAAC,CAAC;YACzC,IAAI,WAAC,OAAO,EAAC,GAAG;YAChB,OAAO,CAAA,GAAA,aAAK,EAAE,WAAW,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC;QACzD;QAxFE,IAAI,QAAC,IAAI,QAAE,IAAI,mBAAE,eAAe,EAAC,GAAG;QACpC,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,gBAAgB,GAAG,mBAAmB;QAC3C,IAAI,CAAC,SAAS,GAAG;IACnB;AAqFF","sources":["packages/@react-aria/test-utils/src/gridlist.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 {BaseTesterOpts, UserOpts} from './user';\nimport {pressElement} from './events';\n\nexport interface GridListOptions extends UserOpts, BaseTesterOpts {\n user?: any\n}\nexport class GridListTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _gridlist: HTMLElement;\n\n\n constructor(opts: GridListOptions) {\n let {root, user, interactionType} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n this._gridlist = root;\n }\n\n setInteractionType = (type: UserOpts['interactionType']) => {\n this._interactionType = type;\n };\n\n // TODO: support long press? This is also pretty much the same as table's toggleRowSelection so maybe can share\n // For now, don't include long press, see if people need it or if we should just expose long press as a separate util if it isn't very common\n // If the current way of passing in the user specified advance timers is ok, then I'd be find including long press\n // Maybe also support an option to force the click to happen on a specific part of the element (checkbox or row). That way\n // the user can test a specific type of interaction?\n toggleRowSelection = async (opts: {index?: number, text?: string, interactionType?: UserOpts['interactionType']} = {}) => {\n let {index, text, interactionType = this._interactionType} = opts;\n\n let row = this.findRow({index, text});\n let rowCheckbox = within(row).queryByRole('checkbox');\n if (rowCheckbox) {\n await pressElement(this.user, rowCheckbox, interactionType);\n } else {\n let cell = within(row).getAllByRole('gridcell')[0];\n await pressElement(this.user, cell, interactionType);\n }\n };\n\n // TODO: pretty much the same as table except it uses this.gridlist. Make common between the two by accepting an option for\n // an element?\n findRow = (opts: {index?: number, text?: string}) => {\n let {\n index,\n text\n } = opts;\n\n let row;\n if (index != null) {\n row = this.rows[index];\n } else if (text != null) {\n row = within(this?.gridlist).getByText(text);\n while (row && row.getAttribute('role') !== 'row') {\n row = row.parentElement;\n }\n }\n\n return row;\n };\n\n // TODO: There is a more difficult use case where the row has/behaves as link, don't think we have a good way to determine that unless the\n // user specificlly tells us\n triggerRowAction = async (opts: {index?: number, text?: string, needsDoubleClick?: boolean, interactionType?: UserOpts['interactionType']}) => {\n let {\n index,\n text,\n needsDoubleClick,\n interactionType = this._interactionType\n } = opts;\n\n let row = this.findRow({index, text});\n if (row) {\n if (needsDoubleClick) {\n await this.user.dblClick(row);\n } else if (interactionType === 'keyboard') {\n act(() => row.focus());\n await this.user.keyboard('[Enter]');\n } else {\n await pressElement(this.user, row, interactionType);\n }\n }\n };\n\n // TODO: do we really need this getter? Theoretically the user already has the reference to the gridlist\n get gridlist() {\n return this._gridlist;\n }\n\n get rows() {\n return within(this?.gridlist).queryAllByRole('row');\n }\n\n get selectedRows() {\n return this.rows.filter(row => row.getAttribute('aria-selected') === 'true');\n }\n\n cells = (opts: {element?: HTMLElement} = {}) => {\n let {element} = opts;\n return within(element || this.gridlist).queryAllByRole('gridcell');\n };\n}\n"],"names":[],"version":3,"file":"gridlist.module.js.map"}
package/dist/menu.main.js CHANGED
@@ -21,6 +21,7 @@ $parcel$export(module.exports, "MenuTester", () => $31965f39292c8e99$export$f73b
21
21
 
22
22
  class $31965f39292c8e99$export$f73bbc9212ed861e {
23
23
  get trigger() {
24
+ if (!this._trigger) throw new Error('No trigger element found for menu.');
24
25
  return this._trigger;
25
26
  }
26
27
  get menu() {
@@ -50,13 +51,14 @@ class $31965f39292c8e99$export$f73bbc9212ed861e {
50
51
  return [];
51
52
  }
52
53
  constructor(opts){
54
+ this._isSubmenu = false;
53
55
  this.setInteractionType = (type)=>{
54
56
  this._interactionType = type;
55
57
  };
56
58
  // TODO: this has been common to select as well, maybe make select use it? Or make a generic method. Will need to make error messages generic
57
59
  // One difference will be that it supports long press as well
58
60
  this.open = async (opts = {})=>{
59
- let { needsLongPress: needsLongPress, interactionType: interactionType = this._interactionType } = opts;
61
+ let { needsLongPress: needsLongPress, interactionType: interactionType = this._interactionType, direction: direction } = opts;
60
62
  let trigger = this.trigger;
61
63
  let isDisabled = trigger.hasAttribute('disabled');
62
64
  if (interactionType === 'mouse' || interactionType === 'touch') {
@@ -76,8 +78,16 @@ class $31965f39292c8e99$export$f73bbc9212ed861e {
76
78
  keys: '[TouchA]'
77
79
  });
78
80
  } else if (interactionType === 'keyboard' && !isDisabled) {
79
- (0, $l5sJH$testinglibraryreact.act)(()=>trigger.focus());
80
- await this.user.keyboard('[Enter]');
81
+ if (direction === 'up') {
82
+ (0, $l5sJH$testinglibraryreact.act)(()=>trigger.focus());
83
+ await this.user.keyboard('[ArrowUp]');
84
+ } else if (direction === 'down') {
85
+ (0, $l5sJH$testinglibraryreact.act)(()=>trigger.focus());
86
+ await this.user.keyboard('[ArrowDown]');
87
+ } else {
88
+ (0, $l5sJH$testinglibraryreact.act)(()=>trigger.focus());
89
+ await this.user.keyboard('[Enter]');
90
+ }
81
91
  }
82
92
  await (0, $l5sJH$testinglibraryreact.waitFor)(()=>{
83
93
  if (trigger.getAttribute('aria-controls') == null && !isDisabled) throw new Error('No aria-controls found on menu trigger element.');
@@ -94,24 +104,30 @@ class $31965f39292c8e99$export$f73bbc9212ed861e {
94
104
  // TODO: also very similar to select, barring potential long press support
95
105
  // Close on select is also kinda specific?
96
106
  this.selectOption = async (opts)=>{
97
- let { optionText: optionText, menuSelectionMode: menuSelectionMode = 'single', needsLongPress: needsLongPress, closesOnSelect: closesOnSelect = true, option: option, interactionType: interactionType = this._interactionType } = opts;
107
+ let { optionText: optionText, menuSelectionMode: menuSelectionMode = 'single', needsLongPress: needsLongPress, closesOnSelect: closesOnSelect = true, option: option, interactionType: interactionType = this._interactionType, keyboardActivation: keyboardActivation = 'Enter' } = opts;
98
108
  let trigger = this.trigger;
99
- if (!trigger.getAttribute('aria-controls')) await this.open({
109
+ if (!trigger.getAttribute('aria-controls') && !trigger.hasAttribute('aria-expanded')) await this.open({
100
110
  needsLongPress: needsLongPress
101
111
  });
102
112
  let menu = this.menu;
103
113
  if (menu) {
104
- if (!option && optionText) option = (0, $l5sJH$testinglibraryreact.within)(menu).getByText(optionText);
114
+ if (!option && optionText) option = (0, $l5sJH$testinglibraryreact.within)(menu).getByText(optionText).closest('[role=menuitem], [role=menuitemradio], [role=menuitemcheckbox]');
115
+ if (!option) throw new Error('No option found in the menu.');
105
116
  if (interactionType === 'keyboard') {
106
117
  if (document.activeElement !== menu || !menu.contains(document.activeElement)) (0, $l5sJH$testinglibraryreact.act)(()=>menu.focus());
107
- await this.user.keyboard(optionText);
108
- await this.user.keyboard('[Enter]');
118
+ await this.keyboardNavigateToOption({
119
+ option: option
120
+ });
121
+ await this.user.keyboard(`[${keyboardActivation}]`);
109
122
  } else if (interactionType === 'mouse') await this.user.click(option);
110
123
  else await this.user.pointer({
111
124
  target: option,
112
125
  keys: '[TouchA]'
113
126
  });
114
- if (option && option.getAttribute('href') == null && option.getAttribute('aria-haspopup') == null && menuSelectionMode === 'single' && closesOnSelect) {
127
+ (0, $l5sJH$testinglibraryreact.act)(()=>{
128
+ jest.runAllTimers();
129
+ });
130
+ if (option && option.getAttribute('href') == null && option.getAttribute('aria-haspopup') == null && menuSelectionMode === 'single' && closesOnSelect && keyboardActivation !== 'Space' && !this._isSubmenu) {
115
131
  await (0, $l5sJH$testinglibraryreact.waitFor)(()=>{
116
132
  if (document.activeElement !== trigger) throw new Error(`Expected the document.activeElement after selecting an option to be the menu trigger but got ${document.activeElement}`);
117
133
  else return true;
@@ -136,15 +152,42 @@ class $31965f39292c8e99$export$f73bbc9212ed861e {
136
152
  else if (submenuTriggerText) submenu = (0, $l5sJH$testinglibraryreact.within)(menu).getByText(submenuTriggerText);
137
153
  let submenuTriggerTester = new $31965f39292c8e99$export$f73bbc9212ed861e({
138
154
  user: this.user,
139
- interactionType: interactionType,
140
- root: submenu
155
+ interactionType: this._interactionType,
156
+ root: submenu,
157
+ isSubmenu: true
141
158
  });
142
- await submenuTriggerTester.open();
159
+ if (interactionType === 'mouse') {
160
+ await this.user.pointer({
161
+ target: submenu
162
+ });
163
+ (0, $l5sJH$testinglibraryreact.act)(()=>{
164
+ jest.runAllTimers();
165
+ });
166
+ } else if (interactionType === 'keyboard') {
167
+ await this.keyboardNavigateToOption({
168
+ option: submenu
169
+ });
170
+ await this.user.keyboard('[ArrowRight]');
171
+ (0, $l5sJH$testinglibraryreact.act)(()=>{
172
+ jest.runAllTimers();
173
+ });
174
+ } else await submenuTriggerTester.open();
143
175
  return submenuTriggerTester;
144
176
  }
145
177
  }
146
178
  return null;
147
179
  };
180
+ this.keyboardNavigateToOption = async (opts)=>{
181
+ let { option: option } = opts;
182
+ let options = this.options;
183
+ let targetIndex = options.indexOf(option);
184
+ if (targetIndex === -1) throw new Error('Option provided is not in the menu');
185
+ if (document.activeElement === this.menu) await this.user.keyboard('[ArrowDown]');
186
+ let currIndex = options.indexOf(document.activeElement);
187
+ if (targetIndex === -1) throw new Error('ActiveElement is not in the menu');
188
+ let direction = targetIndex > currIndex ? 'down' : 'up';
189
+ for(let i = 0; i < Math.abs(targetIndex - currIndex); i++)await this.user.keyboard(`[${direction === 'down' ? 'ArrowDown' : 'ArrowUp'}]`);
190
+ };
148
191
  this.close = async ()=>{
149
192
  let menu = this.menu;
150
193
  if (menu) {
@@ -157,7 +200,7 @@ class $31965f39292c8e99$export$f73bbc9212ed861e {
157
200
  if (document.contains(menu)) throw new Error('Expected the menu to not be in the document after closing it.');
158
201
  }
159
202
  };
160
- let { root: root, user: user, interactionType: interactionType, advanceTimer: advanceTimer } = opts;
203
+ let { root: root, user: user, interactionType: interactionType, advanceTimer: advanceTimer, isSubmenu: isSubmenu } = opts;
161
204
  this.user = user;
162
205
  this._interactionType = interactionType || 'mouse';
163
206
  this._advanceTimer = advanceTimer;
@@ -169,6 +212,7 @@ class $31965f39292c8e99$export$f73bbc9212ed861e {
169
212
  if (trigger) this._trigger = trigger;
170
213
  else this._trigger = root;
171
214
  }
215
+ this._isSubmenu = isSubmenu || false;
172
216
  }
173
217
  }
174
218
 
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AASM,MAAM;IAwLX,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEA,IAAI,OAAO;QACT,IAAI,SAAS,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;QACvC,OAAO,SAAS,SAAS,cAAc,CAAC,UAAU;IACpD;IAEA,IAAI,UAAmC;QACrC,IAAI,OAAO,IAAI,CAAC,IAAI;QACpB,IAAI,UAAU,EAAE;QAChB,IAAI,MAAM;YACR,UAAU,CAAA,GAAA,iCAAK,EAAE,MAAM,cAAc,CAAC;YACtC,IAAI,QAAQ,MAAM,KAAK,GAAG;gBACxB,UAAU,CAAA,GAAA,iCAAK,EAAE,MAAM,cAAc,CAAC;gBACtC,IAAI,QAAQ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,GAAA,8BAAE,EAAE,IAAM,KAAK,KAAK;gBACpB,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAEzB,MAAM,CAAA,GAAA,kCAAM,EAAE;oBACZ,IAAI,SAAS,aAAa,KAAK,IAAI,CAAC,OAAO,EACzC,MAAM,IAAI,MAAM,CAAC,0FAA0F,EAAE,SAAS,aAAa,CAAC,CAAC;yBAErI,OAAO;gBAEX;gBAEA,IAAI,SAAS,QAAQ,CAAC,OACpB,MAAM,IAAI,MAAM;YAEpB;QACF;QA/KE,IAAI,QAAC,IAAI,QAAE,IAAI,mBAAE,eAAe,gBAAE,YAAY,EAAC,GAAG;QAClD,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,gBAAgB,GAAG,mBAAmB;QAC3C,IAAI,CAAC,aAAa,GAAG;QAErB,gEAAgE;QAChE,IAAI,KAAK,YAAY,CAAC,YAAY,YAChC,IAAI,CAAC,QAAQ,GAAG;aACX;YACL,wEAAwE;YACxE,IAAI,UAAU,CAAA,GAAA,iCAAK,EAAE,MAAM,WAAW,CAAC;YACvC,IAAI,SACF,IAAI,CAAC,QAAQ,GAAG;iBAEhB,IAAI,CAAC,QAAQ,GAAG;QAEpB;IACF;AA0MF","sources":["packages/@react-aria/test-utils/src/menu.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {act, waitFor, within} from '@testing-library/react';\nimport {BaseTesterOpts, UserOpts} from './user';\nimport {triggerLongPress} from './events';\n\nexport interface MenuOptions extends UserOpts, BaseTesterOpts {\n user: any\n}\nexport class MenuTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _advanceTimer: UserOpts['advanceTimer'];\n private _trigger: HTMLElement;\n\n constructor(opts: MenuOptions) {\n let {root, user, interactionType, advanceTimer} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n this._advanceTimer = advanceTimer;\n\n // Handle case where a submenu trigger is provided to the tester\n if (root.getAttribute('role') === 'menuitem') {\n this._trigger = root;\n } else {\n // Handle case where element provided is a wrapper of the trigger button\n let trigger = within(root).queryByRole('button');\n if (trigger) {\n this._trigger = trigger;\n } else {\n this._trigger = root;\n }\n }\n }\n\n setInteractionType = (type: UserOpts['interactionType']) => {\n this._interactionType = type;\n };\n\n // TODO: this has been common to select as well, maybe make select use it? Or make a generic method. Will need to make error messages generic\n // One difference will be that it supports long press as well\n open = async (opts: {needsLongPress?: boolean, interactionType?: UserOpts['interactionType']} = {}) => {\n let {\n needsLongPress,\n interactionType = this._interactionType\n } = opts;\n\n let trigger = this.trigger;\n let isDisabled = trigger.hasAttribute('disabled');\n if (interactionType === 'mouse' || interactionType === 'touch') {\n if (needsLongPress) {\n if (this._advanceTimer == null) {\n throw new Error('No advanceTimers provided for long press.');\n }\n let pointerType = interactionType === 'mouse' ? 'mouse' : 'touch';\n await triggerLongPress({element: trigger, advanceTimer: this._advanceTimer, pointerOpts: {pointerType}});\n } else if (interactionType === 'mouse') {\n await this.user.click(trigger);\n } else {\n await this.user.pointer({target: trigger, keys: '[TouchA]'});\n }\n } else if (interactionType === 'keyboard' && !isDisabled) {\n act(() => trigger.focus());\n await this.user.keyboard('[Enter]');\n }\n\n await waitFor(() => {\n if (trigger.getAttribute('aria-controls') == null && !isDisabled) {\n throw new Error('No aria-controls found on menu trigger element.');\n } else {\n return true;\n }\n });\n if (!isDisabled) {\n let menuId = trigger.getAttribute('aria-controls');\n await waitFor(() => {\n if (!menuId || document.getElementById(menuId) == null) {\n throw new Error(`Menu with id of ${menuId} not found in document.`);\n } else {\n return true;\n }\n });\n }\n };\n\n // TODO: also very similar to select, barring potential long press support\n // Close on select is also kinda specific?\n selectOption = async (opts: {option?: HTMLElement, optionText?: string, menuSelectionMode?: 'single' | 'multiple', needsLongPress?: boolean, closesOnSelect?: boolean, interactionType?: UserOpts['interactionType']}) => {\n let {\n optionText,\n menuSelectionMode = 'single',\n needsLongPress,\n closesOnSelect = true,\n option,\n interactionType = this._interactionType\n } = opts;\n let trigger = this.trigger;\n if (!trigger.getAttribute('aria-controls')) {\n await this.open({needsLongPress});\n }\n\n let menu = this.menu;\n if (menu) {\n if (!option && optionText) {\n option = within(menu).getByText(optionText);\n }\n\n if (interactionType === 'keyboard') {\n if (document.activeElement !== menu || !menu.contains(document.activeElement)) {\n act(() => menu.focus());\n }\n\n await this.user.keyboard(optionText);\n await this.user.keyboard('[Enter]');\n } else {\n if (interactionType === 'mouse') {\n await this.user.click(option);\n } else {\n await this.user.pointer({target: option, keys: '[TouchA]'});\n }\n }\n\n if (option && option.getAttribute('href') == null && option.getAttribute('aria-haspopup') == null && menuSelectionMode === 'single' && closesOnSelect) {\n await waitFor(() => {\n if (document.activeElement !== trigger) {\n throw new Error(`Expected the document.activeElement after selecting an option to be the menu trigger but got ${document.activeElement}`);\n } else {\n return true;\n }\n });\n\n if (document.contains(menu)) {\n throw new Error('Expected menu element to not be in the document after selecting an option');\n }\n }\n } else {\n throw new Error(\"Attempted to select a option in the menu, but menu wasn't found.\");\n }\n };\n\n // TODO: update this to remove needsLongPress if we wanna make the user call open first always\n openSubmenu = async (opts: {submenuTrigger?: HTMLElement, submenuTriggerText?: string, needsLongPress?: boolean, interactionType?: UserOpts['interactionType']}): Promise<MenuTester | null> => {\n let {\n submenuTrigger,\n submenuTriggerText,\n needsLongPress,\n interactionType = this._interactionType\n } = opts;\n let trigger = this.trigger;\n let isDisabled = trigger.hasAttribute('disabled');\n if (!trigger.getAttribute('aria-controls') && !isDisabled) {\n await this.open({needsLongPress});\n }\n if (!isDisabled) {\n let menu = this.menu;\n if (menu) {\n let submenu;\n if (submenuTrigger) {\n submenu = submenuTrigger;\n } else if (submenuTriggerText) {\n submenu = within(menu).getByText(submenuTriggerText);\n }\n\n let submenuTriggerTester = new MenuTester({user: this.user, interactionType: interactionType, root: submenu});\n await submenuTriggerTester.open();\n\n return submenuTriggerTester;\n }\n }\n\n return null;\n };\n\n close = async () => {\n let menu = this.menu;\n if (menu) {\n act(() => menu.focus());\n await this.user.keyboard('[Escape]');\n\n await waitFor(() => {\n if (document.activeElement !== this.trigger) {\n throw new Error(`Expected the document.activeElement after closing the menu to be the menu trigger but got ${document.activeElement}`);\n } else {\n return true;\n }\n });\n\n if (document.contains(menu)) {\n throw new Error('Expected the menu to not be in the document after closing it.');\n }\n }\n };\n\n get trigger() {\n return this._trigger;\n }\n\n get menu() {\n let menuId = this.trigger.getAttribute('aria-controls');\n return menuId ? document.getElementById(menuId) : undefined;\n }\n\n get options(): HTMLElement[] | never[] {\n let menu = this.menu;\n let options = [];\n if (menu) {\n options = within(menu).queryAllByRole('menuitem');\n if (options.length === 0) {\n options = within(menu).queryAllByRole('menuitemradio');\n if (options.length === 0) {\n options = within(menu).queryAllByRole('menuitemcheckbox');\n }\n }\n }\n\n return options;\n }\n\n get sections() {\n let menu = this.menu;\n if (menu) {\n return within(menu).queryAllByRole('group');\n } else {\n return [];\n }\n }\n\n get submenuTriggers() {\n let options = this.options;\n if (options.length > 0) {\n return this.options.filter(item => item.getAttribute('aria-haspopup') != null);\n }\n\n return [];\n }\n}\n"],"names":[],"version":3,"file":"menu.main.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAUM,MAAM;IAkPX,IAAI,UAAU;QACZ,IAAI,CAAC,IAAI,CAAC,QAAQ,EAChB,MAAM,IAAI,MAAM;QAElB,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEA,IAAI,OAAO;QACT,IAAI,SAAS,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;QACvC,OAAO,SAAS,SAAS,cAAc,CAAC,UAAU;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,iCAAK,EAAE,MAAM,WAAW,CAAC;YACvC,IAAI,SACF,IAAI,CAAC,QAAQ,GAAG;iBAEhB,IAAI,CAAC,QAAQ,GAAG;QAEpB;QAEA,IAAI,CAAC,UAAU,GAAG,aAAa;IACjC;AAoQF","sources":["packages/@react-aria/test-utils/src/menu.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {act, waitFor, within} from '@testing-library/react';\nimport {BaseTesterOpts, UserOpts} from './user';\nimport {triggerLongPress} from './events';\n\nexport interface MenuOptions extends UserOpts, BaseTesterOpts {\n user?: any,\n isSubmenu?: boolean\n}\nexport class MenuTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _advanceTimer: UserOpts['advanceTimer'];\n private _trigger: HTMLElement | undefined;\n private _isSubmenu: boolean = false;\n\n constructor(opts: MenuOptions) {\n let {root, user, interactionType, advanceTimer, isSubmenu} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n this._advanceTimer = advanceTimer;\n\n // Handle case where a submenu trigger is provided to the tester\n if (root.getAttribute('role') === 'menuitem') {\n this._trigger = root;\n } else {\n // Handle case where element provided is a wrapper of the trigger button\n let trigger = within(root).queryByRole('button');\n if (trigger) {\n this._trigger = trigger;\n } else {\n this._trigger = root;\n }\n }\n\n this._isSubmenu = isSubmenu || false;\n }\n\n setInteractionType = (type: UserOpts['interactionType']) => {\n this._interactionType = type;\n };\n\n // TODO: this has been common to select as well, maybe make select use it? Or make a generic method. Will need to make error messages generic\n // One difference will be that it supports long press as well\n open = async (opts: {needsLongPress?: boolean, interactionType?: UserOpts['interactionType'], direction?: 'up' | 'down'} = {}) => {\n let {\n needsLongPress,\n interactionType = this._interactionType,\n direction\n } = opts;\n let trigger = this.trigger;\n let isDisabled = trigger.hasAttribute('disabled');\n if (interactionType === 'mouse' || interactionType === 'touch') {\n if (needsLongPress) {\n if (this._advanceTimer == null) {\n throw new Error('No advanceTimers provided for long press.');\n }\n let pointerType = interactionType === 'mouse' ? 'mouse' : 'touch';\n await triggerLongPress({element: trigger, advanceTimer: this._advanceTimer, pointerOpts: {pointerType}});\n } else if (interactionType === 'mouse') {\n await this.user.click(trigger);\n } else {\n await this.user.pointer({target: trigger, keys: '[TouchA]'});\n }\n } else if (interactionType === 'keyboard' && !isDisabled) {\n if (direction === 'up') {\n act(() => trigger.focus());\n await this.user.keyboard('[ArrowUp]');\n } else if (direction === 'down') {\n act(() => trigger.focus());\n await this.user.keyboard('[ArrowDown]');\n } else {\n act(() => trigger.focus());\n await this.user.keyboard('[Enter]');\n }\n }\n\n await waitFor(() => {\n if (trigger.getAttribute('aria-controls') == null && !isDisabled) {\n throw new Error('No aria-controls found on menu trigger element.');\n } else {\n return true;\n }\n });\n if (!isDisabled) {\n let menuId = trigger.getAttribute('aria-controls');\n await waitFor(() => {\n if (!menuId || document.getElementById(menuId) == null) {\n throw new Error(`Menu with id of ${menuId} not found in document.`);\n } else {\n return true;\n }\n });\n }\n };\n\n // TODO: also very similar to select, barring potential long press support\n // Close on select is also kinda specific?\n selectOption = async (opts: {\n option?: HTMLElement,\n optionText?: string,\n menuSelectionMode?: 'single' | 'multiple',\n needsLongPress?: boolean,\n closesOnSelect?: boolean,\n interactionType?: UserOpts['interactionType'],\n keyboardActivation?: 'Space' | 'Enter'\n }) => {\n let {\n optionText,\n menuSelectionMode = 'single',\n needsLongPress,\n closesOnSelect = true,\n option,\n interactionType = this._interactionType,\n keyboardActivation = 'Enter'\n } = opts;\n let trigger = this.trigger;\n\n if (!trigger.getAttribute('aria-controls') && !trigger.hasAttribute('aria-expanded')) {\n await this.open({needsLongPress});\n }\n\n let menu = this.menu;\n if (menu) {\n if (!option && optionText) {\n option = (within(menu!).getByText(optionText).closest('[role=menuitem], [role=menuitemradio], [role=menuitemcheckbox]'))! as HTMLElement;\n }\n if (!option) {\n throw new Error('No option found in the menu.');\n }\n\n if (interactionType === 'keyboard') {\n if (document.activeElement !== menu || !menu.contains(document.activeElement)) {\n act(() => menu.focus());\n }\n\n await this.keyboardNavigateToOption({option});\n await this.user.keyboard(`[${keyboardActivation}]`);\n } else {\n if (interactionType === 'mouse') {\n await this.user.click(option);\n } else {\n await this.user.pointer({target: option, keys: '[TouchA]'});\n }\n }\n act(() => {jest.runAllTimers();});\n\n if (option && option.getAttribute('href') == null && option.getAttribute('aria-haspopup') == null && menuSelectionMode === 'single' && closesOnSelect && keyboardActivation !== 'Space' && !this._isSubmenu) {\n await waitFor(() => {\n if (document.activeElement !== trigger) {\n throw new Error(`Expected the document.activeElement after selecting an option to be the menu trigger but got ${document.activeElement}`);\n } else {\n return true;\n }\n });\n\n if (document.contains(menu)) {\n throw new Error('Expected menu element to not be in the document after selecting an option');\n }\n }\n } else {\n throw new Error(\"Attempted to select a option in the menu, but menu wasn't found.\");\n }\n };\n\n // TODO: update this to remove needsLongPress if we wanna make the user call open first always\n openSubmenu = async (opts: {submenuTrigger?: HTMLElement, submenuTriggerText?: string, needsLongPress?: boolean, interactionType?: UserOpts['interactionType']}): Promise<MenuTester | null> => {\n let {\n submenuTrigger,\n submenuTriggerText,\n needsLongPress,\n interactionType = this._interactionType\n } = opts;\n\n let trigger = this.trigger;\n let isDisabled = trigger.hasAttribute('disabled');\n if (!trigger.getAttribute('aria-controls') && !isDisabled) {\n await this.open({needsLongPress});\n }\n if (!isDisabled) {\n let menu = this.menu;\n if (menu) {\n let submenu;\n if (submenuTrigger) {\n submenu = submenuTrigger;\n } else if (submenuTriggerText) {\n submenu = within(menu).getByText(submenuTriggerText);\n }\n\n let submenuTriggerTester = new MenuTester({user: this.user, interactionType: this._interactionType, root: submenu, isSubmenu: true});\n if (interactionType === 'mouse') {\n await this.user.pointer({target: submenu});\n act(() => {jest.runAllTimers();});\n } else if (interactionType === 'keyboard') {\n await this.keyboardNavigateToOption({option: submenu});\n await this.user.keyboard('[ArrowRight]');\n act(() => {jest.runAllTimers();});\n } else {\n await submenuTriggerTester.open();\n }\n\n\n return submenuTriggerTester;\n }\n }\n\n return null;\n };\n\n keyboardNavigateToOption = async (opts: {option: HTMLElement}) => {\n let {option} = opts;\n let options = this.options;\n let targetIndex = options.indexOf(option);\n if (targetIndex === -1) {\n throw new Error('Option provided is not in the menu');\n }\n if (document.activeElement === this.menu) {\n await this.user.keyboard('[ArrowDown]');\n }\n let currIndex = options.indexOf(document.activeElement as HTMLElement);\n if (targetIndex === -1) {\n throw new Error('ActiveElement is not in the menu');\n }\n let direction = targetIndex > currIndex ? 'down' : 'up';\n\n for (let i = 0; i < Math.abs(targetIndex - currIndex); i++) {\n await this.user.keyboard(`[${direction === 'down' ? 'ArrowDown' : 'ArrowUp'}]`);\n }\n };\n\n\n close = async () => {\n let menu = this.menu;\n if (menu) {\n act(() => menu.focus());\n await this.user.keyboard('[Escape]');\n\n await waitFor(() => {\n if (document.activeElement !== this.trigger) {\n throw new Error(`Expected the document.activeElement after closing the menu to be the menu trigger but got ${document.activeElement}`);\n } else {\n return true;\n }\n });\n\n if (document.contains(menu)) {\n throw new Error('Expected the menu to not be in the document after closing it.');\n }\n }\n };\n\n get trigger() {\n if (!this._trigger) {\n throw new Error('No trigger element found for menu.');\n }\n return this._trigger;\n }\n\n get menu() {\n let menuId = this.trigger.getAttribute('aria-controls');\n return menuId ? document.getElementById(menuId) : undefined;\n }\n\n get options(): HTMLElement[] {\n let menu = this.menu;\n let options: HTMLElement[] = [];\n if (menu) {\n options = within(menu).queryAllByRole('menuitem');\n if (options.length === 0) {\n options = within(menu).queryAllByRole('menuitemradio');\n if (options.length === 0) {\n options = within(menu).queryAllByRole('menuitemcheckbox');\n }\n }\n }\n\n return options;\n }\n\n get sections() {\n let menu = this.menu;\n if (menu) {\n return within(menu).queryAllByRole('group');\n } else {\n return [];\n }\n }\n\n get submenuTriggers() {\n let options = this.options;\n if (options.length > 0) {\n return this.options.filter(item => item.getAttribute('aria-haspopup') != null);\n }\n\n return [];\n }\n}\n"],"names":[],"version":3,"file":"menu.main.js.map"}