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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/import.mjs +5 -5
  2. package/dist/main.js +9 -9
  3. package/dist/module.js +5 -5
  4. package/dist/{checkboxgroup.main.js → private/checkboxgroup.cjs} +19 -19
  5. package/dist/private/checkboxgroup.cjs.map +1 -0
  6. package/dist/{checkboxgroup.mjs → private/checkboxgroup.js} +19 -19
  7. package/dist/private/checkboxgroup.js.map +1 -0
  8. package/dist/{combobox.main.js → private/combobox.cjs} +35 -35
  9. package/dist/private/combobox.cjs.map +1 -0
  10. package/dist/{combobox.mjs → private/combobox.js} +35 -35
  11. package/dist/private/combobox.js.map +1 -0
  12. package/dist/{dialog.main.js → private/dialog.cjs} +19 -19
  13. package/dist/private/dialog.cjs.map +1 -0
  14. package/dist/{dialog.mjs → private/dialog.js} +19 -19
  15. package/dist/private/dialog.js.map +1 -0
  16. package/dist/{events.main.js → private/events.cjs} +32 -34
  17. package/dist/private/events.cjs.map +1 -0
  18. package/dist/{events.mjs → private/events.js} +29 -31
  19. package/dist/private/events.js.map +1 -0
  20. package/dist/{gridlist.main.js → private/gridlist.cjs} +27 -28
  21. package/dist/private/gridlist.cjs.map +1 -0
  22. package/dist/{gridlist.mjs → private/gridlist.js} +27 -28
  23. package/dist/private/gridlist.js.map +1 -0
  24. package/dist/{listbox.main.js → private/listbox.cjs} +24 -24
  25. package/dist/private/listbox.cjs.map +1 -0
  26. package/dist/{listbox.mjs → private/listbox.js} +24 -24
  27. package/dist/private/listbox.js.map +1 -0
  28. package/dist/{menu.main.js → private/menu.cjs} +46 -48
  29. package/dist/private/menu.cjs.map +1 -0
  30. package/dist/{menu.mjs → private/menu.js} +46 -48
  31. package/dist/private/menu.js.map +1 -0
  32. package/dist/{radiogroup.main.js → private/radiogroup.cjs} +21 -24
  33. package/dist/private/radiogroup.cjs.map +1 -0
  34. package/dist/{radiogroup.mjs → private/radiogroup.js} +21 -24
  35. package/dist/private/radiogroup.js.map +1 -0
  36. package/dist/{select.main.js → private/select.cjs} +31 -29
  37. package/dist/private/select.cjs.map +1 -0
  38. package/dist/{select.module.js → private/select.js} +31 -29
  39. package/dist/private/select.js.map +1 -0
  40. package/dist/{table.main.js → private/table.cjs} +82 -57
  41. package/dist/private/table.cjs.map +1 -0
  42. package/dist/{table.module.js → private/table.js} +82 -57
  43. package/dist/private/table.js.map +1 -0
  44. package/dist/{tabs.main.js → private/tabs.cjs} +21 -25
  45. package/dist/private/tabs.cjs.map +1 -0
  46. package/dist/{tabs.mjs → private/tabs.js} +21 -25
  47. package/dist/private/tabs.js.map +1 -0
  48. package/dist/{testSetup.main.js → private/testSetup.cjs} +27 -19
  49. package/dist/private/testSetup.cjs.map +1 -0
  50. package/dist/{testSetup.module.js → private/testSetup.js} +26 -18
  51. package/dist/private/testSetup.js.map +1 -0
  52. package/dist/{tree.main.js → private/tree.cjs} +34 -35
  53. package/dist/private/tree.cjs.map +1 -0
  54. package/dist/{tree.mjs → private/tree.js} +34 -35
  55. package/dist/private/tree.js.map +1 -0
  56. package/dist/private/user.cjs +85 -0
  57. package/dist/private/user.cjs.map +1 -0
  58. package/dist/private/user.js +76 -0
  59. package/dist/private/user.js.map +1 -0
  60. package/dist/{userEventMaps.main.js → private/userEventMaps.cjs} +3 -3
  61. package/dist/{userEventMaps.main.js.map → private/userEventMaps.cjs.map} +1 -1
  62. package/dist/{userEventMaps.mjs → private/userEventMaps.js} +3 -3
  63. package/dist/{userEventMaps.module.js.map → private/userEventMaps.js.map} +1 -1
  64. package/dist/types/src/checkboxgroup.d.ts +45 -0
  65. package/dist/types/src/combobox.d.ts +75 -0
  66. package/dist/types/src/dialog.d.ts +36 -0
  67. package/dist/types/src/events.d.ts +25 -0
  68. package/dist/types/src/gridlist.d.ts +51 -0
  69. package/dist/types/src/index.d.ts +16 -0
  70. package/dist/types/src/listbox.d.ts +80 -0
  71. package/dist/types/src/menu.d.ts +102 -0
  72. package/dist/types/src/radiogroup.d.ts +46 -0
  73. package/dist/types/src/select.d.ts +67 -0
  74. package/dist/types/src/table.d.ts +104 -0
  75. package/dist/types/src/tabs.d.ts +58 -0
  76. package/dist/types/src/testSetup.d.ts +6 -0
  77. package/dist/types/src/tree.d.ts +57 -0
  78. package/dist/types/src/types.d.ts +136 -0
  79. package/dist/types/src/user.d.ts +47 -0
  80. package/dist/types/src/userEventMaps.d.ts +2 -0
  81. package/package.json +7 -7
  82. package/src/select.ts +10 -2
  83. package/src/table.ts +46 -1
  84. package/dist/checkboxgroup.main.js.map +0 -1
  85. package/dist/checkboxgroup.module.js +0 -99
  86. package/dist/checkboxgroup.module.js.map +0 -1
  87. package/dist/combobox.main.js.map +0 -1
  88. package/dist/combobox.module.js +0 -167
  89. package/dist/combobox.module.js.map +0 -1
  90. package/dist/dialog.main.js.map +0 -1
  91. package/dist/dialog.module.js +0 -100
  92. package/dist/dialog.module.js.map +0 -1
  93. package/dist/events.main.js.map +0 -1
  94. package/dist/events.module.js +0 -112
  95. package/dist/events.module.js.map +0 -1
  96. package/dist/gridlist.main.js.map +0 -1
  97. package/dist/gridlist.module.js +0 -149
  98. package/dist/gridlist.module.js.map +0 -1
  99. package/dist/listbox.main.js.map +0 -1
  100. package/dist/listbox.module.js +0 -138
  101. package/dist/listbox.module.js.map +0 -1
  102. package/dist/menu.main.js.map +0 -1
  103. package/dist/menu.module.js +0 -269
  104. package/dist/menu.module.js.map +0 -1
  105. package/dist/radiogroup.main.js.map +0 -1
  106. package/dist/radiogroup.module.js +0 -118
  107. package/dist/radiogroup.module.js.map +0 -1
  108. package/dist/select.main.js.map +0 -1
  109. package/dist/select.mjs +0 -158
  110. package/dist/select.module.js.map +0 -1
  111. package/dist/table.main.js.map +0 -1
  112. package/dist/table.mjs +0 -290
  113. package/dist/table.module.js.map +0 -1
  114. package/dist/tabs.main.js.map +0 -1
  115. package/dist/tabs.module.js +0 -130
  116. package/dist/tabs.module.js.map +0 -1
  117. package/dist/testSetup.main.js.map +0 -1
  118. package/dist/testSetup.mjs +0 -73
  119. package/dist/testSetup.module.js.map +0 -1
  120. package/dist/tree.main.js.map +0 -1
  121. package/dist/tree.module.js +0 -179
  122. package/dist/tree.module.js.map +0 -1
  123. package/dist/types.d.ts +0 -823
  124. package/dist/types.d.ts.map +0 -1
  125. package/dist/user.main.js +0 -85
  126. package/dist/user.main.js.map +0 -1
  127. package/dist/user.mjs +0 -76
  128. package/dist/user.module.js +0 -76
  129. package/dist/user.module.js.map +0 -1
  130. package/dist/userEventMaps.module.js +0 -38
@@ -0,0 +1 @@
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AAwBM,MAAM;IAMX,YAAY,IAAwB,CAAE;QACpC,IAAI,QAAC,IAAI,WAAE,OAAO,QAAE,IAAI,mBAAE,eAAe,EAAC,GAAG;QAC7C,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,gBAAgB,GAAG,mBAAmB;QAE3C,8IAA8I;QAC9I,2FAA2F;QAC3F,IAAI,CAAC,SAAS,GAAG;QACjB,IAAI,WAAW,CAAA,GAAA,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,cAAc,CAAC,UAAU;gBAAC,QAAQ;YAAI;YAEjE,IAAI,QAAQ,MAAM,KAAK,GACrB,UAAU,OAAO,CAAC,EAAE;iBACf,IAAI,QAAQ,MAAM,GAAG,GAC1B,UAAU,QAAQ,IAAI,CAAC,CAAA,SAAU,OAAO,YAAY,CAAC;YAGvD,qHAAqH;YACrH,6BAA6B;YAC7B,IAAI,CAAC,QAAQ,GAAG,WAAW,IAAI,CAAC,SAAS;QAC3C;IACF;IAEA;;GAEC,GACD,mBAAmB,IAAiC,EAAQ;Q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3B,IAAI,UAAU,IAAI,CAAC,OAAO;QAC1B,IAAI,SAAS;YACX,CAAA,GAAA,UAAE,EAAE,IAAM,IAAI,CAAC,QAAQ,CAAC,KAAK;YAC7B,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;YAEzB,MAAM,CAAA,GAAA,cAAM,EAAE;gBACZ,IAAI,SAAS,QAAQ,CAAC,UACpB,MAAM,IAAI,MAAM;qBAEhB,OAAO;YAEX;QACF;IACF;IAEA;;GAEC,GACD,IAAI,WAAwB;QAC1B,OAAO,IAAI,CAAC,SAAS;IACvB;IAEA;;GAEC,GACD,IAAI,UAAuB;QACzB,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEA;;GAEC,GACD,IAAI,UAA8B;QAChC,IAAI,YAAY,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;QAC3C,OAAO,YAAY,SAAS,cAAc,CAAC,cAAc,OAAO;IAClE;IAEA;;GAEC,GACD,IAAI,WAA0B;QAC5B,IAAI,UAAU,IAAI,CAAC,OAAO;QAC1B,OAAO,UAAU,CAAA,GAAA,aAAK,EAAE,SAAS,cAAc,CAAC,WAAW,EAAE;IAC/D;IAEA;;GAEC,GACD,QAAQ,OAAgC,CAAC,CAAC,EAAiB;QACzD,IAAI,WAAC,UAAU,IAAI,CAAC,OAAO,EAAC,GAAG;QAC/B,IAAI,UAAU,EAAE;QAChB,IAAI,SACF,UAAU,CAAA,GAAA,aAAK,EAAE,SAAS,cAAc,CAAC;QAG3C,OAAO;IACT;IAEA;;GAEC,GACD,IAAI,gBAAoC;QACtC,IAAI,kBAAkB,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;QACjD,OAAO,kBAAkB,SAAS,cAAc,CAAC,mBAAmB;IACtE;AACF","sources":["packages/@react-aria/test-utils/src/combobox.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {act, waitFor, within} from '@testing-library/react';\nimport {ComboBoxTesterOpts, UserOpts} from './types';\n\ninterface ComboBoxOpenOpts {\n /**\n * Whether the combobox opens on focus or needs to be manually opened via user action.\n * @default 'manual'\n */\n triggerBehavior?: 'focus' | 'manual',\n /**\n * What interaction type to use when opening the combobox. Defaults to the interaction type set on the tester.\n */\n interactionType?: UserOpts['interactionType']\n}\n\ninterface ComboBoxSelectOpts extends ComboBoxOpenOpts {\n /**\n * The index, text, or node of the option to select. Option nodes can be sourced via `options()`.\n */\n option: number | string | HTMLElement\n}\n\nexport class ComboBoxTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _combobox: HTMLElement;\n private _trigger: HTMLElement;\n\n constructor(opts: ComboBoxTesterOpts) {\n let {root, trigger, user, interactionType} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n\n // Handle case where element provided is a wrapper around the combobox. The expectation is that the user at least uses a ref/data attribute to\n // query their combobox/combobox wrapper (in the case of RSP) which they then pass to thhis\n this._combobox = root;\n let combobox = within(root).queryByRole('combobox');\n if (combobox) {\n this._combobox = combobox;\n }\n\n // This is for if user need to directly set the trigger button element (aka the element provided in setElement was the combobox input or the trigger is somewhere unexpected)\n if (trigger) {\n this._trigger = trigger;\n } else {\n let buttons = within(root).queryAllByRole('button', {hidden: true});\n\n if (buttons.length === 1) {\n trigger = buttons[0];\n } else if (buttons.length > 1) {\n trigger = buttons.find(button => button.hasAttribute('aria-haspopup'));\n }\n\n // For cases like https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/ where the combobox\n // is also the trigger button\n this._trigger = trigger || this._combobox;\n }\n }\n\n /**\n * Set the interaction type used by the combobox tester.\n */\n setInteractionType(type: UserOpts['interactionType']): void {\n this._interactionType = type;\n }\n\n /**\n * Opens the combobox dropdown. Defaults to using the interaction type set on the combobox tester.\n */\n async open(opts: ComboBoxOpenOpts = {}): Promise<void> {\n let {triggerBehavior = 'manual', interactionType = this._interactionType} = opts;\n let trigger = this.trigger;\n let combobox = this.combobox;\n let isDisabled = trigger!.hasAttribute('disabled');\n\n if (interactionType === 'mouse') {\n if (triggerBehavior === 'focus') {\n await this.user.click(combobox);\n } else {\n await this.user.click(trigger);\n }\n } else if (interactionType === 'keyboard' && this._trigger != null) {\n act(() => this._trigger!.focus());\n if (triggerBehavior !== 'focus') {\n await this.user.keyboard('{ArrowDown}');\n }\n } else if (interactionType === 'touch') {\n if (triggerBehavior === 'focus') {\n await this.user.pointer({target: combobox, keys: '[TouchA]'});\n } else {\n await this.user.pointer({target: trigger, keys: '[TouchA]'});\n }\n }\n\n await waitFor(() => {\n if (!isDisabled && combobox.getAttribute('aria-controls') == null) {\n throw new Error('No aria-controls found on combobox trigger element.');\n } else {\n return true;\n }\n });\n let listBoxId = combobox.getAttribute('aria-controls');\n await waitFor(() => {\n if (!isDisabled && (!listBoxId || document.getElementById(listBoxId) == null)) {\n throw new Error(`Listbox with id of ${listBoxId} not found in document.`);\n } else {\n return true;\n }\n });\n }\n\n /**\n * Returns an option matching the specified index or text content.\n */\n findOption(opts: {optionIndexOrText: number | string}): HTMLElement {\n let {\n optionIndexOrText\n } = opts;\n\n let option;\n let options = this.options();\n let listbox = this.listbox;\n\n if (typeof optionIndexOrText === 'number') {\n option = options[optionIndexOrText];\n } else if (typeof optionIndexOrText === 'string' && listbox != null) {\n option = (within(listbox!).getByText(optionIndexOrText).closest('[role=option]'))! as HTMLElement;\n }\n\n return option;\n }\n\n /**\n * Selects the desired combobox option. Defaults to using the interaction type set on the combobox tester. If necessary, will open the combobox dropdown beforehand.\n * The desired option can be targeted via the option's node, the option's text, or the option's index.\n */\n async selectOption(opts: ComboBoxSelectOpts): Promise<void> {\n let {option, triggerBehavior, interactionType = this._interactionType} = opts;\n if (!this.combobox.getAttribute('aria-controls')) {\n await this.open({triggerBehavior});\n }\n\n let listbox = this.listbox;\n if (!listbox) {\n throw new Error('Combobox\\'s listbox not found.');\n }\n\n if (listbox) {\n if (typeof option === 'string' || typeof option === 'number') {\n option = this.findOption({optionIndexOrText: option});\n }\n\n if (!option) {\n throw new Error('Target option not found in the listbox.');\n }\n\n // TODO: keyboard method of selecting the the option is a bit tricky unless I simply simulate the user pressing the down arrow\n // the required amount of times to reach the option. For now just click the option even in keyboard mode\n if (interactionType === 'mouse' || interactionType === 'keyboard') {\n await this.user.click(option);\n } else {\n await this.user.pointer({target: option, keys: '[TouchA]'});\n }\n\n if (option.getAttribute('href') == null) {\n await waitFor(() => {\n if (document.contains(listbox)) {\n throw new Error('Expected listbox element to not be in the document after selecting an option');\n } else {\n return true;\n }\n });\n }\n } else {\n throw new Error(\"Attempted to select a option in the combobox, but the listbox wasn't found.\");\n }\n }\n\n /**\n * Closes the combobox dropdown.\n */\n async close(): Promise<void> {\n let listbox = this.listbox;\n if (listbox) {\n act(() => this.combobox.focus());\n await this.user.keyboard('[Escape]');\n\n await waitFor(() => {\n if (document.contains(listbox)) {\n throw new Error('Expected listbox element to not be in the document after selecting an option');\n } else {\n return true;\n }\n });\n }\n }\n\n /**\n * Returns the combobox.\n */\n get combobox(): HTMLElement {\n return this._combobox;\n }\n\n /**\n * Returns the combobox trigger button.\n */\n get trigger(): HTMLElement {\n return this._trigger;\n }\n\n /**\n * Returns the combobox's listbox if present.\n */\n get listbox(): HTMLElement | null {\n let listBoxId = this.combobox.getAttribute('aria-controls');\n return listBoxId ? document.getElementById(listBoxId) || null : null;\n }\n\n /**\n * Returns the combobox's sections if present.\n */\n get sections(): HTMLElement[] {\n let listbox = this.listbox;\n return listbox ? within(listbox).queryAllByRole('group') : [];\n }\n\n /**\n * Returns the combobox's options if present. Can be filtered to a subsection of the listbox if provided via `element`.\n */\n options(opts: {element?: HTMLElement} = {}): HTMLElement[] {\n let {element = this.listbox} = opts;\n let options = [];\n if (element) {\n options = within(element).queryAllByRole('option');\n }\n\n return options;\n }\n\n /**\n * Returns the currently focused option in the combobox's dropdown if any.\n */\n get focusedOption(): HTMLElement | null {\n let focusedOptionId = this.combobox.getAttribute('aria-activedescendant');\n return focusedOptionId ? document.getElementById(focusedOptionId) : null;\n }\n}\n"],"names":[],"version":3,"file":"combobox.js.map"}
@@ -1,11 +1,11 @@
1
- var $7D3o2$testinglibraryreact = require("@testing-library/react");
1
+ var $4WTiJ$testinglibraryreact = require("@testing-library/react");
2
2
 
3
3
 
4
4
  function $parcel$export(e, n, v, s) {
5
5
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
6
  }
7
7
 
8
- $parcel$export(module.exports, "DialogTester", () => $fe51f406377a5335$export$e79328f5295cc2a1);
8
+ $parcel$export(module.exports, "DialogTester", function () { return $cde1dbf8bdfa11d9$export$e79328f5295cc2a1; });
9
9
  /*
10
10
  * Copyright 2025 Adobe. All rights reserved.
11
11
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -17,7 +17,17 @@ $parcel$export(module.exports, "DialogTester", () => $fe51f406377a5335$export$e7
17
17
  * OF ANY KIND, either express or implied. See the License for the specific language
18
18
  * governing permissions and limitations under the License.
19
19
  */
20
- class $fe51f406377a5335$export$e79328f5295cc2a1 {
20
+ class $cde1dbf8bdfa11d9$export$e79328f5295cc2a1 {
21
+ constructor(opts){
22
+ let { root: root, user: user, interactionType: interactionType, overlayType: overlayType } = opts;
23
+ this.user = user;
24
+ this._interactionType = interactionType || 'mouse';
25
+ this._overlayType = overlayType || 'modal';
26
+ // Handle case where element provided is a wrapper of the trigger button
27
+ let trigger = (0, $4WTiJ$testinglibraryreact.within)(root).queryByRole('button');
28
+ if (trigger) this._trigger = trigger;
29
+ else this._trigger = root;
30
+ }
21
31
  /**
22
32
  * Set the interaction type used by the dialog tester.
23
33
  */ setInteractionType(type) {
@@ -35,16 +45,16 @@ class $fe51f406377a5335$export$e79328f5295cc2a1 {
35
45
  keys: '[TouchA]'
36
46
  });
37
47
  else if (interactionType === 'keyboard') {
38
- (0, $7D3o2$testinglibraryreact.act)(()=>trigger.focus());
48
+ (0, $4WTiJ$testinglibraryreact.act)(()=>trigger.focus());
39
49
  await this.user.keyboard('[Enter]');
40
50
  }
41
51
  if (this._overlayType === 'popover') {
42
- await (0, $7D3o2$testinglibraryreact.waitFor)(()=>{
52
+ await (0, $4WTiJ$testinglibraryreact.waitFor)(()=>{
43
53
  if (trigger.getAttribute('aria-controls') == null) throw new Error('No aria-controls found on dialog trigger element.');
44
54
  else return true;
45
55
  });
46
56
  let dialogId = trigger.getAttribute('aria-controls');
47
- await (0, $7D3o2$testinglibraryreact.waitFor)(()=>{
57
+ await (0, $4WTiJ$testinglibraryreact.waitFor)(()=>{
48
58
  if (!dialogId || document.getElementById(dialogId) == null) throw new Error(`Dialog with id of ${dialogId} not found in document.`);
49
59
  else {
50
60
  this._dialog = document.getElementById(dialogId);
@@ -53,7 +63,7 @@ class $fe51f406377a5335$export$e79328f5295cc2a1 {
53
63
  });
54
64
  } else {
55
65
  let dialog;
56
- await (0, $7D3o2$testinglibraryreact.waitFor)(()=>{
66
+ await (0, $4WTiJ$testinglibraryreact.waitFor)(()=>{
57
67
  dialog = document.querySelector('[role=dialog], [role=alertdialog]');
58
68
  if (dialog == null) throw new Error('No dialog of type role="dialog" or role="alertdialog" found after pressing the trigger.');
59
69
  else return true;
@@ -69,7 +79,7 @@ class $fe51f406377a5335$export$e79328f5295cc2a1 {
69
79
  let dialog = this._dialog;
70
80
  if (dialog) {
71
81
  await this.user.keyboard('[Escape]');
72
- await (0, $7D3o2$testinglibraryreact.waitFor)(()=>{
82
+ await (0, $4WTiJ$testinglibraryreact.waitFor)(()=>{
73
83
  if (document.contains(dialog)) throw new Error('Expected the dialog to not be in the document after closing it.');
74
84
  else {
75
85
  this._dialog = undefined;
@@ -89,17 +99,7 @@ class $fe51f406377a5335$export$e79328f5295cc2a1 {
89
99
  */ get dialog() {
90
100
  return this._dialog && document.contains(this._dialog) ? this._dialog : null;
91
101
  }
92
- constructor(opts){
93
- let { root: root, user: user, interactionType: interactionType, overlayType: overlayType } = opts;
94
- this.user = user;
95
- this._interactionType = interactionType || 'mouse';
96
- this._overlayType = overlayType || 'modal';
97
- // Handle case where element provided is a wrapper of the trigger button
98
- let trigger = (0, $7D3o2$testinglibraryreact.within)(root).queryByRole('button');
99
- if (trigger) this._trigger = trigger;
100
- else this._trigger = root;
101
- }
102
102
  }
103
103
 
104
104
 
105
- //# sourceMappingURL=dialog.main.js.map
105
+ //# sourceMappingURL=dialog.cjs.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAYM,MAAM;IAOX,YAAY,IAAsB,CAAE;QAClC,IAAI,QAAC,IAAI,QAAE,IAAI,mBAAE,eAAe,eAAE,WAAW,EAAC,GAAG;QACjD,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,gBAAgB,GAAG,mBAAmB;QAC3C,IAAI,CAAC,YAAY,GAAG,eAAe;QAEnC,wEAAwE;QACxE,IAAI,UAAU,CAAA,GAAA,iCAAK,EAAE,MAAM,WAAW,CAAC;QACvC,IAAI,SACF,IAAI,CAAC,QAAQ,GAAG;aAEhB,IAAI,CAAC,QAAQ,GAAG;IAEpB;IAEA;;GAEC,GACD,mBAAmB,IAAiC,EAAQ;QAC1D,IAAI,CAAC,gBAAgB,GAAG;IAC1B;IAEA;;GAEC,GACD,MAAM,KAAK,OAAuB,CAAC,CAAC,EAAiB;QACnD,IAAI,mBACF,kBAAkB,IAAI,CAAC,gBAAgB,EACxC,GAAG;QACJ,IAAI,UAAU,IAAI,CAAC,OAAO;QAC1B,IAAI,CAAC,QAAQ,YAAY,CAAC,aAAa;YACrC,IAAI,oBAAoB,SACtB,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;iBACjB,IAAI,oBAAoB,SA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AAC,OAAO,GAAG;oBACf,OAAO;gBACT;YACF;QACF;IACF;IAEA;;GAEC,GACD,IAAI,UAAuB;QACzB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAChB,MAAM,IAAI,MAAM;QAGlB,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEA;;GAEC,GACD,IAAI,SAA6B;QAC/B,OAAO,IAAI,CAAC,OAAO,IAAI,SAAS,QAAQ,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,GAAG;IAC1E;AACF","sources":["packages/@react-aria/test-utils/src/dialog.ts"],"sourcesContent":["/*\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {act, waitFor, within} from '@testing-library/react';\nimport {DialogTesterOpts, UserOpts} from './types';\n\ninterface DialogOpenOpts {\n /**\n * What interaction type to use when opening the dialog. Defaults to the interaction type set on the tester.\n */\n interactionType?: UserOpts['interactionType']\n}\n\nexport class DialogTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _trigger: HTMLElement | undefined;\n private _dialog: HTMLElement | undefined;\n private _overlayType: DialogTesterOpts['overlayType'];\n\n constructor(opts: DialogTesterOpts) {\n let {root, user, interactionType, overlayType} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n this._overlayType = overlayType || 'modal';\n\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 * Set the interaction type used by the dialog tester.\n */\n setInteractionType(type: UserOpts['interactionType']): void {\n this._interactionType = type;\n }\n\n /**\n * Opens the dialog. Defaults to using the interaction type set on the dialog tester.\n */\n async open(opts: DialogOpenOpts = {}): Promise<void> {\n let {\n interactionType = this._interactionType\n } = opts;\n let trigger = this.trigger;\n if (!trigger.hasAttribute('disabled')) {\n if (interactionType === 'mouse') {\n await this.user.click(trigger);\n } else if (interactionType === 'touch') {\n await this.user.pointer({target: trigger, keys: '[TouchA]'});\n } else if (interactionType === 'keyboard') {\n act(() => trigger.focus());\n await this.user.keyboard('[Enter]');\n }\n\n if (this._overlayType === 'popover') {\n await waitFor(() => {\n if (trigger.getAttribute('aria-controls') == null) {\n throw new Error('No aria-controls found on dialog trigger element.');\n } else {\n return true;\n }\n });\n\n let dialogId = trigger.getAttribute('aria-controls');\n await waitFor(() => {\n if (!dialogId || document.getElementById(dialogId) == null) {\n throw new Error(`Dialog with id of ${dialogId} not found in document.`);\n } else {\n this._dialog = document.getElementById(dialogId)!;\n return true;\n }\n });\n } else {\n let dialog;\n await waitFor(() => {\n dialog = document.querySelector('[role=dialog], [role=alertdialog]');\n if (dialog == null) {\n throw new Error('No dialog of type role=\"dialog\" or role=\"alertdialog\" found after pressing the trigger.');\n } else {\n return true;\n }\n });\n\n if (dialog && document.activeElement !== this._trigger && dialog.contains(document.activeElement)) {\n this._dialog = dialog;\n } else {\n throw new Error('New modal dialog doesnt contain the active element OR the active element is still the trigger. Uncertain if the proper modal dialog was found');\n }\n }\n }\n }\n\n /**\n * Closes the dialog via the Escape key.\n */\n async close(): Promise<void> {\n let dialog = this._dialog;\n if (dialog) {\n await this.user.keyboard('[Escape]');\n await waitFor(() => {\n if (document.contains(dialog)) {\n throw new Error('Expected the dialog to not be in the document after closing it.');\n } else {\n this._dialog = undefined;\n return true;\n }\n });\n }\n }\n\n /**\n * Returns the dialog's trigger.\n */\n get trigger(): HTMLElement {\n if (!this._trigger) {\n throw new Error('No trigger element found for dialog.');\n }\n\n return this._trigger;\n }\n\n /**\n * Returns the dialog if present.\n */\n get dialog(): HTMLElement | null {\n return this._dialog && document.contains(this._dialog) ? this._dialog : null;\n }\n}\n"],"names":[],"version":3,"file":"dialog.cjs.map"}
@@ -1,4 +1,4 @@
1
- import {act as $ikD9Y$act, waitFor as $ikD9Y$waitFor, within as $ikD9Y$within} from "@testing-library/react";
1
+ import {within as $Hdzb6$within, act as $Hdzb6$act, waitFor as $Hdzb6$waitFor} from "@testing-library/react";
2
2
 
3
3
  /*
4
4
  * Copyright 2025 Adobe. All rights reserved.
@@ -11,7 +11,17 @@ import {act as $ikD9Y$act, waitFor as $ikD9Y$waitFor, within as $ikD9Y$within} f
11
11
  * OF ANY KIND, either express or implied. See the License for the specific language
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
- class $5bce5d4037467b58$export$e79328f5295cc2a1 {
14
+ class $1bad24930969e309$export$e79328f5295cc2a1 {
15
+ constructor(opts){
16
+ let { root: root, user: user, interactionType: interactionType, overlayType: overlayType } = opts;
17
+ this.user = user;
18
+ this._interactionType = interactionType || 'mouse';
19
+ this._overlayType = overlayType || 'modal';
20
+ // Handle case where element provided is a wrapper of the trigger button
21
+ let trigger = (0, $Hdzb6$within)(root).queryByRole('button');
22
+ if (trigger) this._trigger = trigger;
23
+ else this._trigger = root;
24
+ }
15
25
  /**
16
26
  * Set the interaction type used by the dialog tester.
17
27
  */ setInteractionType(type) {
@@ -29,16 +39,16 @@ class $5bce5d4037467b58$export$e79328f5295cc2a1 {
29
39
  keys: '[TouchA]'
30
40
  });
31
41
  else if (interactionType === 'keyboard') {
32
- (0, $ikD9Y$act)(()=>trigger.focus());
42
+ (0, $Hdzb6$act)(()=>trigger.focus());
33
43
  await this.user.keyboard('[Enter]');
34
44
  }
35
45
  if (this._overlayType === 'popover') {
36
- await (0, $ikD9Y$waitFor)(()=>{
46
+ await (0, $Hdzb6$waitFor)(()=>{
37
47
  if (trigger.getAttribute('aria-controls') == null) throw new Error('No aria-controls found on dialog trigger element.');
38
48
  else return true;
39
49
  });
40
50
  let dialogId = trigger.getAttribute('aria-controls');
41
- await (0, $ikD9Y$waitFor)(()=>{
51
+ await (0, $Hdzb6$waitFor)(()=>{
42
52
  if (!dialogId || document.getElementById(dialogId) == null) throw new Error(`Dialog with id of ${dialogId} not found in document.`);
43
53
  else {
44
54
  this._dialog = document.getElementById(dialogId);
@@ -47,7 +57,7 @@ class $5bce5d4037467b58$export$e79328f5295cc2a1 {
47
57
  });
48
58
  } else {
49
59
  let dialog;
50
- await (0, $ikD9Y$waitFor)(()=>{
60
+ await (0, $Hdzb6$waitFor)(()=>{
51
61
  dialog = document.querySelector('[role=dialog], [role=alertdialog]');
52
62
  if (dialog == null) throw new Error('No dialog of type role="dialog" or role="alertdialog" found after pressing the trigger.');
53
63
  else return true;
@@ -63,7 +73,7 @@ class $5bce5d4037467b58$export$e79328f5295cc2a1 {
63
73
  let dialog = this._dialog;
64
74
  if (dialog) {
65
75
  await this.user.keyboard('[Escape]');
66
- await (0, $ikD9Y$waitFor)(()=>{
76
+ await (0, $Hdzb6$waitFor)(()=>{
67
77
  if (document.contains(dialog)) throw new Error('Expected the dialog to not be in the document after closing it.');
68
78
  else {
69
79
  this._dialog = undefined;
@@ -83,18 +93,8 @@ class $5bce5d4037467b58$export$e79328f5295cc2a1 {
83
93
  */ get dialog() {
84
94
  return this._dialog && document.contains(this._dialog) ? this._dialog : null;
85
95
  }
86
- constructor(opts){
87
- let { root: root, user: user, interactionType: interactionType, overlayType: overlayType } = opts;
88
- this.user = user;
89
- this._interactionType = interactionType || 'mouse';
90
- this._overlayType = overlayType || 'modal';
91
- // Handle case where element provided is a wrapper of the trigger button
92
- let trigger = (0, $ikD9Y$within)(root).queryByRole('button');
93
- if (trigger) this._trigger = trigger;
94
- else this._trigger = root;
95
- }
96
96
  }
97
97
 
98
98
 
99
- export {$5bce5d4037467b58$export$e79328f5295cc2a1 as DialogTester};
100
- //# sourceMappingURL=dialog.module.js.map
99
+ export {$1bad24930969e309$export$e79328f5295cc2a1 as DialogTester};
100
+ //# sourceMappingURL=dialog.js.map
@@ -0,0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A,GAAA,cAAM,EAAE;oBACZ,IAAI,CAAC,YAAY,SAAS,cAAc,CAAC,aAAa,MACpD,MAAM,IAAI,MAAM,CAAC,kBAAkB,EAAE,SAAS,uBAAuB,CAAC;yBACjE;wBACL,IAAI,CAAC,OAAO,GAAG,SAAS,cAAc,CAAC;wBACvC,OAAO;oBACT;gBACF;YACF,OAAO;gBACL,IAAI;gBACJ,MAAM,CAAA,GAAA,cAAM,EAAE;oBACZ,SAAS,SAAS,aAAa,CAAC;oBAChC,IAAI,UAAU,MACZ,MAAM,IAAI,MAAM;yBAEhB,OAAO;gBAEX;gBAEA,IAAI,UAAU,SAAS,aAAa,KAAK,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,CAAC,SAAS,aAAa,GAC9F,IAAI,CAAC,OAAO,GAAG;qBAEf,MAAM,IAAI,MAAM;YAEpB;QACF;IACF;IAEA;;GAEC,GACD,MAAM,QAAuB;QAC3B,IAAI,SAAS,IAAI,CAAC,OAAO;QACzB,IAAI,QAAQ;YACV,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;YACzB,MAAM,CAAA,GAAA,cAAM,EAAE;gBACZ,IAAI,SAAS,QAAQ,CAAC,SACpB,MAAM,IAAI,MAAM;qBACX;oBACL,IAAI,CAAC,OAAO,GAAG;oBACf,OAAO;gBACT;YACF;QACF;IACF;IAEA;;GAEC,GACD,IAAI,UAAuB;QACzB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAChB,MAAM,IAAI,MAAM;QAGlB,OAAO,IAAI,CAAC,QAAQ;IACtB;IAEA;;GAEC,GACD,IAAI,SAA6B;QAC/B,OAAO,IAAI,CAAC,OAAO,IAAI,SAAS,QAAQ,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,GAAG;IAC1E;AACF","sources":["packages/@react-aria/test-utils/src/dialog.ts"],"sourcesContent":["/*\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {act, waitFor, within} from '@testing-library/react';\nimport {DialogTesterOpts, UserOpts} from './types';\n\ninterface DialogOpenOpts {\n /**\n * What interaction type to use when opening the dialog. Defaults to the interaction type set on the tester.\n */\n interactionType?: UserOpts['interactionType']\n}\n\nexport class DialogTester {\n private user;\n private _interactionType: UserOpts['interactionType'];\n private _trigger: HTMLElement | undefined;\n private _dialog: HTMLElement | undefined;\n private _overlayType: DialogTesterOpts['overlayType'];\n\n constructor(opts: DialogTesterOpts) {\n let {root, user, interactionType, overlayType} = opts;\n this.user = user;\n this._interactionType = interactionType || 'mouse';\n this._overlayType = overlayType || 'modal';\n\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 * Set the interaction type used by the dialog tester.\n */\n setInteractionType(type: UserOpts['interactionType']): void {\n this._interactionType = type;\n }\n\n /**\n * Opens the dialog. Defaults to using the interaction type set on the dialog tester.\n */\n async open(opts: DialogOpenOpts = {}): Promise<void> {\n let {\n interactionType = this._interactionType\n } = opts;\n let trigger = this.trigger;\n if (!trigger.hasAttribute('disabled')) {\n if (interactionType === 'mouse') {\n await this.user.click(trigger);\n } else if (interactionType === 'touch') {\n await this.user.pointer({target: trigger, keys: '[TouchA]'});\n } else if (interactionType === 'keyboard') {\n act(() => trigger.focus());\n await this.user.keyboard('[Enter]');\n }\n\n if (this._overlayType === 'popover') {\n await waitFor(() => {\n if (trigger.getAttribute('aria-controls') == null) {\n throw new Error('No aria-controls found on dialog trigger element.');\n } else {\n return true;\n }\n });\n\n let dialogId = trigger.getAttribute('aria-controls');\n await waitFor(() => {\n if (!dialogId || document.getElementById(dialogId) == null) {\n throw new Error(`Dialog with id of ${dialogId} not found in document.`);\n } else {\n this._dialog = document.getElementById(dialogId)!;\n return true;\n }\n });\n } else {\n let dialog;\n await waitFor(() => {\n dialog = document.querySelector('[role=dialog], [role=alertdialog]');\n if (dialog == null) {\n throw new Error('No dialog of type role=\"dialog\" or role=\"alertdialog\" found after pressing the trigger.');\n } else {\n return true;\n }\n });\n\n if (dialog && document.activeElement !== this._trigger && dialog.contains(document.activeElement)) {\n this._dialog = dialog;\n } else {\n throw new Error('New modal dialog doesnt contain the active element OR the active element is still the trigger. Uncertain if the proper modal dialog was found');\n }\n }\n }\n }\n\n /**\n * Closes the dialog via the Escape key.\n */\n async close(): Promise<void> {\n let dialog = this._dialog;\n if (dialog) {\n await this.user.keyboard('[Escape]');\n await waitFor(() => {\n if (document.contains(dialog)) {\n throw new Error('Expected the dialog to not be in the document after closing it.');\n } else {\n this._dialog = undefined;\n return true;\n }\n });\n }\n }\n\n /**\n * Returns the dialog's trigger.\n */\n get trigger(): HTMLElement {\n if (!this._trigger) {\n throw new Error('No trigger element found for dialog.');\n }\n\n return this._trigger;\n }\n\n /**\n * Returns the dialog if present.\n */\n get dialog(): HTMLElement | null {\n return this._dialog && document.contains(this._dialog) ? this._dialog : null;\n }\n}\n"],"names":[],"version":3,"file":"dialog.js.map"}
@@ -1,14 +1,14 @@
1
- var $jxdbS$testinglibraryreact = require("@testing-library/react");
1
+ var $dJoEb$testinglibraryreact = require("@testing-library/react");
2
2
 
3
3
 
4
4
  function $parcel$export(e, n, v, s) {
5
5
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
6
  }
7
7
 
8
- $parcel$export(module.exports, "getAltKey", () => $5a8bfe1663b8366d$export$6fc0ccaebd758b9d);
9
- $parcel$export(module.exports, "getMetaKey", () => $5a8bfe1663b8366d$export$7943c508934e27ce);
10
- $parcel$export(module.exports, "triggerLongPress", () => $5a8bfe1663b8366d$export$3a22a5a9bc0fd3b);
11
- $parcel$export(module.exports, "pressElement", () => $5a8bfe1663b8366d$export$6ffa3eb717517feb);
8
+ $parcel$export(module.exports, "getAltKey", function () { return $01a4eeee86094c77$export$6fc0ccaebd758b9d; });
9
+ $parcel$export(module.exports, "getMetaKey", function () { return $01a4eeee86094c77$export$7943c508934e27ce; });
10
+ $parcel$export(module.exports, "triggerLongPress", function () { return $01a4eeee86094c77$export$3a22a5a9bc0fd3b; });
11
+ $parcel$export(module.exports, "pressElement", function () { return $01a4eeee86094c77$export$6ffa3eb717517feb; });
12
12
  /*
13
13
  * Copyright 2023 Adobe. All rights reserved.
14
14
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -20,12 +20,11 @@ $parcel$export(module.exports, "pressElement", () => $5a8bfe1663b8366d$export$6f
20
20
  * OF ANY KIND, either express or implied. See the License for the specific language
21
21
  * governing permissions and limitations under the License.
22
22
  */
23
- const $5a8bfe1663b8366d$export$4bd1d2d5ba6f5eaf = 500;
24
- function $5a8bfe1663b8366d$var$testPlatform(re) {
25
- var _window_navigator_userAgentData;
26
- return typeof window !== 'undefined' && window.navigator != null ? re.test(((_window_navigator_userAgentData = window.navigator['userAgentData']) === null || _window_navigator_userAgentData === void 0 ? void 0 : _window_navigator_userAgentData.platform) || window.navigator.platform) : false;
23
+ const $01a4eeee86094c77$export$4bd1d2d5ba6f5eaf = 500;
24
+ function $01a4eeee86094c77$var$testPlatform(re) {
25
+ return typeof window !== 'undefined' && window.navigator != null ? re.test(window.navigator['userAgentData']?.platform || window.navigator.platform) : false;
27
26
  }
28
- function $5a8bfe1663b8366d$var$cached(fn) {
27
+ function $01a4eeee86094c77$var$cached(fn) {
29
28
  if (process.env.NODE_ENV === 'test') return fn;
30
29
  let res = null;
31
30
  return ()=>{
@@ -33,29 +32,28 @@ function $5a8bfe1663b8366d$var$cached(fn) {
33
32
  return res;
34
33
  };
35
34
  }
36
- const $5a8bfe1663b8366d$var$isMac = $5a8bfe1663b8366d$var$cached(function() {
37
- return $5a8bfe1663b8366d$var$testPlatform(/^Mac/i);
35
+ const $01a4eeee86094c77$var$isMac = $01a4eeee86094c77$var$cached(function() {
36
+ return $01a4eeee86094c77$var$testPlatform(/^Mac/i);
38
37
  });
39
- function $5a8bfe1663b8366d$export$6fc0ccaebd758b9d() {
40
- return $5a8bfe1663b8366d$var$isMac() ? 'Alt' : 'ControlLeft';
38
+ function $01a4eeee86094c77$export$6fc0ccaebd758b9d() {
39
+ return $01a4eeee86094c77$var$isMac() ? 'Alt' : 'ControlLeft';
41
40
  }
42
- function $5a8bfe1663b8366d$export$7943c508934e27ce() {
43
- return $5a8bfe1663b8366d$var$isMac() ? 'MetaLeft' : 'ControlLeft';
41
+ function $01a4eeee86094c77$export$7943c508934e27ce() {
42
+ return $01a4eeee86094c77$var$isMac() ? 'MetaLeft' : 'ControlLeft';
44
43
  }
45
- async function $5a8bfe1663b8366d$export$3a22a5a9bc0fd3b(opts) {
44
+ async function $01a4eeee86094c77$export$3a22a5a9bc0fd3b(opts) {
46
45
  // TODO: note that this only works if the code from installPointerEvent is called somewhere in the test BEFORE the
47
46
  // render. Perhaps we should rely on the user setting that up since I'm not sure there is a great way to set that up here in the
48
47
  // util before first render. Will need to document it well
49
48
  let { element: element, advanceTimer: advanceTimer, pointerOpts: pointerOpts = {} } = opts;
50
- var _pointerOpts_pointerType;
51
- let pointerType = (_pointerOpts_pointerType = pointerOpts.pointerType) !== null && _pointerOpts_pointerType !== void 0 ? _pointerOpts_pointerType : 'mouse';
52
- let shouldFireCompatibilityEvents = (0, $jxdbS$testinglibraryreact.fireEvent).pointerDown(element, {
49
+ let pointerType = pointerOpts.pointerType ?? 'mouse';
50
+ let shouldFireCompatibilityEvents = (0, $dJoEb$testinglibraryreact.fireEvent).pointerDown(element, {
53
51
  pointerType: pointerType,
54
52
  ...pointerOpts
55
53
  });
56
54
  let shouldFocus = true;
57
55
  if (shouldFireCompatibilityEvents) {
58
- if (pointerType === 'touch') shouldFocus = shouldFireCompatibilityEvents = (0, $jxdbS$testinglibraryreact.fireEvent).touchStart(element, {
56
+ if (pointerType === 'touch') shouldFocus = shouldFireCompatibilityEvents = (0, $dJoEb$testinglibraryreact.fireEvent).touchStart(element, {
59
57
  targetTouches: [
60
58
  {
61
59
  identifier: pointerOpts.pointerId,
@@ -65,18 +63,18 @@ async function $5a8bfe1663b8366d$export$3a22a5a9bc0fd3b(opts) {
65
63
  ]
66
64
  });
67
65
  else if (pointerType === 'mouse') {
68
- shouldFocus = (0, $jxdbS$testinglibraryreact.fireEvent).mouseDown(element, pointerOpts);
69
- if (shouldFocus) (0, $jxdbS$testinglibraryreact.act)(()=>element.focus());
66
+ shouldFocus = (0, $dJoEb$testinglibraryreact.fireEvent).mouseDown(element, pointerOpts);
67
+ if (shouldFocus) (0, $dJoEb$testinglibraryreact.act)(()=>element.focus());
70
68
  }
71
69
  }
72
- await (0, $jxdbS$testinglibraryreact.act)(async ()=>await advanceTimer($5a8bfe1663b8366d$export$4bd1d2d5ba6f5eaf));
73
- (0, $jxdbS$testinglibraryreact.fireEvent).pointerUp(element, {
70
+ await (0, $dJoEb$testinglibraryreact.act)(async ()=>await advanceTimer($01a4eeee86094c77$export$4bd1d2d5ba6f5eaf));
71
+ (0, $dJoEb$testinglibraryreact.fireEvent).pointerUp(element, {
74
72
  pointerType: pointerType,
75
73
  ...pointerOpts
76
74
  });
77
75
  if (shouldFireCompatibilityEvents) {
78
76
  if (pointerType === 'touch') {
79
- shouldFocus = (0, $jxdbS$testinglibraryreact.fireEvent).touchEnd(element, {
77
+ shouldFocus = (0, $dJoEb$testinglibraryreact.fireEvent).touchEnd(element, {
80
78
  targetTouches: [
81
79
  {
82
80
  identifier: pointerOpts.pointerId,
@@ -85,17 +83,17 @@ async function $5a8bfe1663b8366d$export$3a22a5a9bc0fd3b(opts) {
85
83
  }
86
84
  ]
87
85
  });
88
- shouldFocus = (0, $jxdbS$testinglibraryreact.fireEvent).mouseDown(element, pointerOpts);
89
- if (shouldFocus) (0, $jxdbS$testinglibraryreact.act)(()=>element.focus());
90
- (0, $jxdbS$testinglibraryreact.fireEvent).mouseUp(element, pointerOpts);
91
- } else if (pointerType === 'mouse') (0, $jxdbS$testinglibraryreact.fireEvent).mouseUp(element, pointerOpts);
86
+ shouldFocus = (0, $dJoEb$testinglibraryreact.fireEvent).mouseDown(element, pointerOpts);
87
+ if (shouldFocus) (0, $dJoEb$testinglibraryreact.act)(()=>element.focus());
88
+ (0, $dJoEb$testinglibraryreact.fireEvent).mouseUp(element, pointerOpts);
89
+ } else if (pointerType === 'mouse') (0, $dJoEb$testinglibraryreact.fireEvent).mouseUp(element, pointerOpts);
92
90
  }
93
- (0, $jxdbS$testinglibraryreact.fireEvent).click(element, {
91
+ (0, $dJoEb$testinglibraryreact.fireEvent).click(element, {
94
92
  detail: 1,
95
93
  ...pointerOpts
96
94
  });
97
95
  }
98
- async function $5a8bfe1663b8366d$export$6ffa3eb717517feb(user, element, interactionType) {
96
+ async function $01a4eeee86094c77$export$6ffa3eb717517feb(user, element, interactionType) {
99
97
  if (interactionType === 'mouse') // Add coords with pressure so this isn't detected as a virtual click
100
98
  await user.pointer({
101
99
  target: element,
@@ -108,7 +106,7 @@ async function $5a8bfe1663b8366d$export$6ffa3eb717517feb(user, element, interact
108
106
  // TODO: For the keyboard flow, I wonder if it would be reasonable to just do fireEvent directly on the obtained row node or if we should
109
107
  // stick to simulting an actual user's keyboard operations as closely as possible
110
108
  // There are problems when using this approach though, actions like trying to trigger the select all checkbox and stuff behave oddly.
111
- (0, $jxdbS$testinglibraryreact.act)(()=>element.focus());
109
+ (0, $dJoEb$testinglibraryreact.act)(()=>element.focus());
112
110
  await user.keyboard('[Space]');
113
111
  } else if (interactionType === 'touch') await user.pointer({
114
112
  target: element,
@@ -117,4 +115,4 @@ async function $5a8bfe1663b8366d$export$6ffa3eb717517feb(user, element, interact
117
115
  }
118
116
 
119
117
 
120
- //# sourceMappingURL=events.main.js.map
118
+ //# sourceMappingURL=events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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, fireEvent} from '@testing-library/react';\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\n/**\n * Simulates a \"long press\" event on a element.\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 specific amount of time(ms).\n * @param opts.pointeropts - Options to pass to the simulated event. Defaults to mouse. See https://testing-library.com/docs/dom-testing-library/api-events/#fireevent for more info.\n */\nexport async function triggerLongPress(opts: {element: HTMLElement, advanceTimer: (time: number) => unknown | Promise<unknown>, pointerOpts?: Record<string, any>}): Promise<void> {\n // TODO: note that this only works if the code from installPointerEvent is called somewhere in the test BEFORE the\n // render. Perhaps we should rely on the user setting that up since I'm not sure there is a great way to set that up here in the\n // util before first render. Will need to document it well\n let {element, advanceTimer, pointerOpts = {}} = opts;\n let pointerType = pointerOpts.pointerType ?? 'mouse';\n let shouldFireCompatibilityEvents = fireEvent.pointerDown(element, {pointerType, ...pointerOpts});\n let shouldFocus = true;\n if (shouldFireCompatibilityEvents) {\n if (pointerType === 'touch') {\n shouldFocus = shouldFireCompatibilityEvents = fireEvent.touchStart(element, {targetTouches: [{identifier: pointerOpts.pointerId, clientX: pointerOpts.clientX, clientY: pointerOpts.clientY}]});\n } else if (pointerType === 'mouse') {\n shouldFocus = fireEvent.mouseDown(element, pointerOpts);\n if (shouldFocus) {\n act(() => element.focus());\n }\n }\n }\n await act(async () => await advanceTimer(DEFAULT_LONG_PRESS_TIME));\n fireEvent.pointerUp(element, {pointerType, ...pointerOpts});\n if (shouldFireCompatibilityEvents) {\n if (pointerType === 'touch') {\n shouldFocus = fireEvent.touchEnd(element, {targetTouches: [{identifier: pointerOpts.pointerId, clientX: pointerOpts.clientX, clientY: pointerOpts.clientY}]});\n shouldFocus = fireEvent.mouseDown(element, pointerOpts);\n if (shouldFocus) {\n act(() => element.focus());\n }\n fireEvent.mouseUp(element, pointerOpts);\n } else if (pointerType === 'mouse') {\n fireEvent.mouseUp(element, pointerOpts);\n }\n }\n fireEvent.click(element, {detail: 1, ...pointerOpts});\n}\n\n// Docs cannot handle the types that userEvent actually declares, so hopefully this sub set is okay\nexport async function pressElement(user: {click: (element: Element) => Promise<void>, keyboard: (keys: string) => Promise<void>, pointer: (opts: {target: Element, keys: string, coords?: any}) => Promise<void>}, element: HTMLElement, interactionType: UserOpts['interactionType']): 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: .5}});\n } else if (interactionType === 'keyboard') {\n // TODO: For the keyboard flow, I wonder if it would be reasonable to just do fireEvent directly on the obtained row node or if we should\n // stick to simulting an actual user's keyboard operations as closely as possible\n // There are problems when using this approach though, actions like trying to trigger the select all checkbox and stuff behave oddly.\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":"events.cjs.map"}
@@ -1,4 +1,4 @@
1
- import {fireEvent as $hhVmT$fireEvent, act as $hhVmT$act} from "@testing-library/react";
1
+ import {fireEvent as $bWe3B$fireEvent, act as $bWe3B$act} from "@testing-library/react";
2
2
 
3
3
  /*
4
4
  * Copyright 2023 Adobe. All rights reserved.
@@ -11,12 +11,11 @@ import {fireEvent as $hhVmT$fireEvent, act as $hhVmT$act} from "@testing-library
11
11
  * OF ANY KIND, either express or implied. See the License for the specific language
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
- const $5d1eca18f92ad0e6$export$4bd1d2d5ba6f5eaf = 500;
15
- function $5d1eca18f92ad0e6$var$testPlatform(re) {
16
- var _window_navigator_userAgentData;
17
- return typeof window !== 'undefined' && window.navigator != null ? re.test(((_window_navigator_userAgentData = window.navigator['userAgentData']) === null || _window_navigator_userAgentData === void 0 ? void 0 : _window_navigator_userAgentData.platform) || window.navigator.platform) : false;
14
+ const $22d7d9b763402afa$export$4bd1d2d5ba6f5eaf = 500;
15
+ function $22d7d9b763402afa$var$testPlatform(re) {
16
+ return typeof window !== 'undefined' && window.navigator != null ? re.test(window.navigator['userAgentData']?.platform || window.navigator.platform) : false;
18
17
  }
19
- function $5d1eca18f92ad0e6$var$cached(fn) {
18
+ function $22d7d9b763402afa$var$cached(fn) {
20
19
  if (process.env.NODE_ENV === 'test') return fn;
21
20
  let res = null;
22
21
  return ()=>{
@@ -24,29 +23,28 @@ function $5d1eca18f92ad0e6$var$cached(fn) {
24
23
  return res;
25
24
  };
26
25
  }
27
- const $5d1eca18f92ad0e6$var$isMac = $5d1eca18f92ad0e6$var$cached(function() {
28
- return $5d1eca18f92ad0e6$var$testPlatform(/^Mac/i);
26
+ const $22d7d9b763402afa$var$isMac = $22d7d9b763402afa$var$cached(function() {
27
+ return $22d7d9b763402afa$var$testPlatform(/^Mac/i);
29
28
  });
30
- function $5d1eca18f92ad0e6$export$6fc0ccaebd758b9d() {
31
- return $5d1eca18f92ad0e6$var$isMac() ? 'Alt' : 'ControlLeft';
29
+ function $22d7d9b763402afa$export$6fc0ccaebd758b9d() {
30
+ return $22d7d9b763402afa$var$isMac() ? 'Alt' : 'ControlLeft';
32
31
  }
33
- function $5d1eca18f92ad0e6$export$7943c508934e27ce() {
34
- return $5d1eca18f92ad0e6$var$isMac() ? 'MetaLeft' : 'ControlLeft';
32
+ function $22d7d9b763402afa$export$7943c508934e27ce() {
33
+ return $22d7d9b763402afa$var$isMac() ? 'MetaLeft' : 'ControlLeft';
35
34
  }
36
- async function $5d1eca18f92ad0e6$export$3a22a5a9bc0fd3b(opts) {
35
+ async function $22d7d9b763402afa$export$3a22a5a9bc0fd3b(opts) {
37
36
  // TODO: note that this only works if the code from installPointerEvent is called somewhere in the test BEFORE the
38
37
  // render. Perhaps we should rely on the user setting that up since I'm not sure there is a great way to set that up here in the
39
38
  // util before first render. Will need to document it well
40
39
  let { element: element, advanceTimer: advanceTimer, pointerOpts: pointerOpts = {} } = opts;
41
- var _pointerOpts_pointerType;
42
- let pointerType = (_pointerOpts_pointerType = pointerOpts.pointerType) !== null && _pointerOpts_pointerType !== void 0 ? _pointerOpts_pointerType : 'mouse';
43
- let shouldFireCompatibilityEvents = (0, $hhVmT$fireEvent).pointerDown(element, {
40
+ let pointerType = pointerOpts.pointerType ?? 'mouse';
41
+ let shouldFireCompatibilityEvents = (0, $bWe3B$fireEvent).pointerDown(element, {
44
42
  pointerType: pointerType,
45
43
  ...pointerOpts
46
44
  });
47
45
  let shouldFocus = true;
48
46
  if (shouldFireCompatibilityEvents) {
49
- if (pointerType === 'touch') shouldFocus = shouldFireCompatibilityEvents = (0, $hhVmT$fireEvent).touchStart(element, {
47
+ if (pointerType === 'touch') shouldFocus = shouldFireCompatibilityEvents = (0, $bWe3B$fireEvent).touchStart(element, {
50
48
  targetTouches: [
51
49
  {
52
50
  identifier: pointerOpts.pointerId,
@@ -56,18 +54,18 @@ async function $5d1eca18f92ad0e6$export$3a22a5a9bc0fd3b(opts) {
56
54
  ]
57
55
  });
58
56
  else if (pointerType === 'mouse') {
59
- shouldFocus = (0, $hhVmT$fireEvent).mouseDown(element, pointerOpts);
60
- if (shouldFocus) (0, $hhVmT$act)(()=>element.focus());
57
+ shouldFocus = (0, $bWe3B$fireEvent).mouseDown(element, pointerOpts);
58
+ if (shouldFocus) (0, $bWe3B$act)(()=>element.focus());
61
59
  }
62
60
  }
63
- await (0, $hhVmT$act)(async ()=>await advanceTimer($5d1eca18f92ad0e6$export$4bd1d2d5ba6f5eaf));
64
- (0, $hhVmT$fireEvent).pointerUp(element, {
61
+ await (0, $bWe3B$act)(async ()=>await advanceTimer($22d7d9b763402afa$export$4bd1d2d5ba6f5eaf));
62
+ (0, $bWe3B$fireEvent).pointerUp(element, {
65
63
  pointerType: pointerType,
66
64
  ...pointerOpts
67
65
  });
68
66
  if (shouldFireCompatibilityEvents) {
69
67
  if (pointerType === 'touch') {
70
- shouldFocus = (0, $hhVmT$fireEvent).touchEnd(element, {
68
+ shouldFocus = (0, $bWe3B$fireEvent).touchEnd(element, {
71
69
  targetTouches: [
72
70
  {
73
71
  identifier: pointerOpts.pointerId,
@@ -76,17 +74,17 @@ async function $5d1eca18f92ad0e6$export$3a22a5a9bc0fd3b(opts) {
76
74
  }
77
75
  ]
78
76
  });
79
- shouldFocus = (0, $hhVmT$fireEvent).mouseDown(element, pointerOpts);
80
- if (shouldFocus) (0, $hhVmT$act)(()=>element.focus());
81
- (0, $hhVmT$fireEvent).mouseUp(element, pointerOpts);
82
- } else if (pointerType === 'mouse') (0, $hhVmT$fireEvent).mouseUp(element, pointerOpts);
77
+ shouldFocus = (0, $bWe3B$fireEvent).mouseDown(element, pointerOpts);
78
+ if (shouldFocus) (0, $bWe3B$act)(()=>element.focus());
79
+ (0, $bWe3B$fireEvent).mouseUp(element, pointerOpts);
80
+ } else if (pointerType === 'mouse') (0, $bWe3B$fireEvent).mouseUp(element, pointerOpts);
83
81
  }
84
- (0, $hhVmT$fireEvent).click(element, {
82
+ (0, $bWe3B$fireEvent).click(element, {
85
83
  detail: 1,
86
84
  ...pointerOpts
87
85
  });
88
86
  }
89
- async function $5d1eca18f92ad0e6$export$6ffa3eb717517feb(user, element, interactionType) {
87
+ async function $22d7d9b763402afa$export$6ffa3eb717517feb(user, element, interactionType) {
90
88
  if (interactionType === 'mouse') // Add coords with pressure so this isn't detected as a virtual click
91
89
  await user.pointer({
92
90
  target: element,
@@ -99,7 +97,7 @@ async function $5d1eca18f92ad0e6$export$6ffa3eb717517feb(user, element, interact
99
97
  // TODO: For the keyboard flow, I wonder if it would be reasonable to just do fireEvent directly on the obtained row node or if we should
100
98
  // stick to simulting an actual user's keyboard operations as closely as possible
101
99
  // There are problems when using this approach though, actions like trying to trigger the select all checkbox and stuff behave oddly.
102
- (0, $hhVmT$act)(()=>element.focus());
100
+ (0, $bWe3B$act)(()=>element.focus());
103
101
  await user.keyboard('[Space]');
104
102
  } else if (interactionType === 'touch') await user.pointer({
105
103
  target: element,
@@ -108,5 +106,5 @@ async function $5d1eca18f92ad0e6$export$6ffa3eb717517feb(user, element, interact
108
106
  }
109
107
 
110
108
 
111
- export {$5d1eca18f92ad0e6$export$4bd1d2d5ba6f5eaf as DEFAULT_LONG_PRESS_TIME, $5d1eca18f92ad0e6$export$6fc0ccaebd758b9d as getAltKey, $5d1eca18f92ad0e6$export$7943c508934e27ce as getMetaKey, $5d1eca18f92ad0e6$export$3a22a5a9bc0fd3b as triggerLongPress, $5d1eca18f92ad0e6$export$6ffa3eb717517feb as pressElement};
112
- //# sourceMappingURL=events.module.js.map
109
+ export {$22d7d9b763402afa$export$4bd1d2d5ba6f5eaf as DEFAULT_LONG_PRESS_TIME, $22d7d9b763402afa$export$6fc0ccaebd758b9d as getAltKey, $22d7d9b763402afa$export$7943c508934e27ce as getMetaKey, $22d7d9b763402afa$export$3a22a5a9bc0fd3b as triggerLongPress, $22d7d9b763402afa$export$6ffa3eb717517feb as pressElement};
110
+ //# sourceMappingURL=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,MAAM,CAAA,GAAA,UAAE,EAAE,UAAY,MAAM,aAAa;IACzC,CAAA,GAAA,gBAAQ,EAAE,SAAS,CAAC,SAAS;qBAAC;QAAa,GAAG,WAAW;IAAA;IACzD,IAAI,+BAA+B;QACjC,IAAI,gBAAgB,SAAS;YAC3B,cAAc,CAAA,GAAA,gBAAQ,EAAE,QAAQ,CAAC,SAAS;gBAAC,eAAe;oBAAC;wBAAC,YAAY,YAAY,SAAS;wBAAE,SAAS,YAAY,OAAO;wBAAE,SAAS,YAAY,OAAO;oBAAA;iBAAE;YAAA;YAC3J,cAAc,CAAA,GAAA,gBAAQ,EAAE,SAAS,CAAC,SAAS;YAC3C,IAAI,aACF,CAAA,GAAA,UAAE,EAAE,IAAM,QAAQ,KAAK;YAEzB,CAAA,GAAA,gBAAQ,EAAE,OAAO,CAAC,SAAS;QAC7B,OAAO,IAAI,gBAAgB,SACzB,CAAA,GAAA,gBAAQ,EAAE,OAAO,CAAC,SAAS;IAE/B;IACA,CAAA,GAAA,gBAAQ,EAAE,KAAK,CAAC,SAAS;QAAC,QAAQ;QAAG,GAAG,WAAW;IAAA;AACrD;AAGO,eAAe,0CAAa,IAA8K,EAAE,OAAoB,EAAE,eAA4C;IACnR,IAAI,oBAAoB,SACtB,qEAAqE;IACrE,MAAM,KAAK,OAAO,CAAC;QAAC,QAAQ;QAAS,MAAM;QAAe,QAAQ;YAAC,UAAU;QAAE;IAAC;SAC3E,IAAI,oBAAoB,YAAY;QACzC,yIAAyI;QACzI,iFAAiF;QACjF,qIAAqI;QACrI,CAAA,GAAA,UAAE,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/events.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, fireEvent} from '@testing-library/react';\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\n/**\n * Simulates a \"long press\" event on a element.\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 specific amount of time(ms).\n * @param opts.pointeropts - Options to pass to the simulated event. Defaults to mouse. See https://testing-library.com/docs/dom-testing-library/api-events/#fireevent for more info.\n */\nexport async function triggerLongPress(opts: {element: HTMLElement, advanceTimer: (time: number) => unknown | Promise<unknown>, pointerOpts?: Record<string, any>}): Promise<void> {\n // TODO: note that this only works if the code from installPointerEvent is called somewhere in the test BEFORE the\n // render. Perhaps we should rely on the user setting that up since I'm not sure there is a great way to set that up here in the\n // util before first render. Will need to document it well\n let {element, advanceTimer, pointerOpts = {}} = opts;\n let pointerType = pointerOpts.pointerType ?? 'mouse';\n let shouldFireCompatibilityEvents = fireEvent.pointerDown(element, {pointerType, ...pointerOpts});\n let shouldFocus = true;\n if (shouldFireCompatibilityEvents) {\n if (pointerType === 'touch') {\n shouldFocus = shouldFireCompatibilityEvents = fireEvent.touchStart(element, {targetTouches: [{identifier: pointerOpts.pointerId, clientX: pointerOpts.clientX, clientY: pointerOpts.clientY}]});\n } else if (pointerType === 'mouse') {\n shouldFocus = fireEvent.mouseDown(element, pointerOpts);\n if (shouldFocus) {\n act(() => element.focus());\n }\n }\n }\n await act(async () => await advanceTimer(DEFAULT_LONG_PRESS_TIME));\n fireEvent.pointerUp(element, {pointerType, ...pointerOpts});\n if (shouldFireCompatibilityEvents) {\n if (pointerType === 'touch') {\n shouldFocus = fireEvent.touchEnd(element, {targetTouches: [{identifier: pointerOpts.pointerId, clientX: pointerOpts.clientX, clientY: pointerOpts.clientY}]});\n shouldFocus = fireEvent.mouseDown(element, pointerOpts);\n if (shouldFocus) {\n act(() => element.focus());\n }\n fireEvent.mouseUp(element, pointerOpts);\n } else if (pointerType === 'mouse') {\n fireEvent.mouseUp(element, pointerOpts);\n }\n }\n fireEvent.click(element, {detail: 1, ...pointerOpts});\n}\n\n// Docs cannot handle the types that userEvent actually declares, so hopefully this sub set is okay\nexport async function pressElement(user: {click: (element: Element) => Promise<void>, keyboard: (keys: string) => Promise<void>, pointer: (opts: {target: Element, keys: string, coords?: any}) => Promise<void>}, element: HTMLElement, interactionType: UserOpts['interactionType']): 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: .5}});\n } else if (interactionType === 'keyboard') {\n // TODO: For the keyboard flow, I wonder if it would be reasonable to just do fireEvent directly on the obtained row node or if we should\n // stick to simulting an actual user's keyboard operations as closely as possible\n // There are problems when using this approach though, actions like trying to trigger the select all checkbox and stuff behave oddly.\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":"events.js.map"}