@testing-library/user-event 14.4.2 → 14.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) hide show
  1. package/dist/cjs/_interop/dtl.js +30 -0
  2. package/dist/cjs/_interop/dtlEventMap.js +30 -0
  3. package/dist/cjs/_interop/dtlHelpers.js +30 -0
  4. package/dist/cjs/clipboard/copy.js +6 -16
  5. package/dist/cjs/clipboard/cut.js +6 -16
  6. package/dist/cjs/clipboard/paste.js +6 -16
  7. package/dist/cjs/convenience/click.js +1 -4
  8. package/dist/cjs/convenience/hover.js +2 -12
  9. package/dist/cjs/convenience/tab.js +1 -1
  10. package/dist/cjs/document/UI.js +94 -0
  11. package/dist/cjs/document/copySelection.js +37 -0
  12. package/dist/cjs/document/getValueOrTextContent.js +27 -0
  13. package/dist/cjs/document/index.js +13 -68
  14. package/dist/cjs/document/interceptor.js +89 -4
  15. package/dist/cjs/document/prepareDocument.js +67 -0
  16. package/dist/cjs/document/trackValue.js +65 -0
  17. package/dist/cjs/event/behavior/click.js +8 -12
  18. package/dist/cjs/event/behavior/cut.js +5 -11
  19. package/dist/cjs/event/behavior/keydown.js +43 -47
  20. package/dist/cjs/event/behavior/keypress.js +12 -12
  21. package/dist/cjs/event/behavior/keyup.js +6 -8
  22. package/dist/cjs/event/behavior/paste.js +7 -13
  23. package/dist/cjs/event/createEvent.js +43 -50
  24. package/dist/cjs/event/dispatchEvent.js +21 -3
  25. package/dist/cjs/event/eventMap.js +2 -2
  26. package/dist/cjs/event/focus.js +44 -0
  27. package/dist/cjs/event/index.js +24 -17
  28. package/dist/cjs/{utils/edit → event}/input.js +52 -50
  29. package/dist/cjs/{utils/edit/walkRadio.js → event/radio.js} +13 -7
  30. package/dist/cjs/event/selection/getInputRange.js +20 -0
  31. package/dist/cjs/event/selection/getTargetTypeAndSelection.js +41 -0
  32. package/dist/cjs/event/selection/index.js +26 -0
  33. package/dist/cjs/event/selection/modifySelection.js +30 -0
  34. package/dist/cjs/event/selection/modifySelectionPerMouse.js +50 -0
  35. package/dist/cjs/event/selection/moveSelection.js +48 -0
  36. package/dist/cjs/{utils/focus → event/selection}/resolveCaretPosition.js +10 -18
  37. package/dist/cjs/event/selection/selectAll.js +48 -0
  38. package/dist/cjs/event/selection/setSelection.js +30 -0
  39. package/dist/cjs/event/selection/setSelectionPerMouse.js +91 -0
  40. package/dist/cjs/event/selection/setSelectionRange.js +40 -0
  41. package/dist/cjs/event/selection/updateSelectionOnFocus.js +46 -0
  42. package/dist/cjs/event/wrapEvent.js +3 -2
  43. package/dist/cjs/index.js +1 -0
  44. package/dist/cjs/keyboard/index.js +13 -23
  45. package/dist/cjs/keyboard/parseKeyDef.js +9 -17
  46. package/dist/cjs/options.js +0 -28
  47. package/dist/cjs/pointer/index.js +28 -38
  48. package/dist/cjs/pointer/keyMap.js +1 -1
  49. package/dist/cjs/pointer/parseKeyDef.js +2 -10
  50. package/dist/cjs/setup/api.js +19 -17
  51. package/dist/cjs/setup/directApi.js +6 -6
  52. package/dist/cjs/setup/index.js +0 -2
  53. package/dist/cjs/setup/setup.js +70 -42
  54. package/dist/cjs/setup/wrapAsync.js +3 -2
  55. package/dist/cjs/system/index.js +15 -2
  56. package/dist/cjs/system/keyboard.js +34 -21
  57. package/dist/cjs/system/pointer/buttons.js +14 -1
  58. package/dist/cjs/system/pointer/device.js +14 -1
  59. package/dist/cjs/system/pointer/index.js +60 -45
  60. package/dist/cjs/system/pointer/mouse.js +77 -56
  61. package/dist/cjs/system/pointer/pointer.js +56 -42
  62. package/dist/cjs/system/pointer/shared.js +10 -0
  63. package/dist/cjs/utility/clear.js +10 -11
  64. package/dist/cjs/utility/selectOptions.js +28 -29
  65. package/dist/cjs/utility/type.js +6 -15
  66. package/dist/cjs/utility/upload.js +9 -18
  67. package/dist/cjs/utils/dataTransfer/Clipboard.js +26 -24
  68. package/dist/cjs/utils/dataTransfer/DataTransfer.js +25 -9
  69. package/dist/cjs/utils/edit/isEditable.js +6 -10
  70. package/dist/cjs/utils/edit/maxLength.js +6 -17
  71. package/dist/cjs/utils/edit/setFiles.js +4 -4
  72. package/dist/cjs/utils/edit/{buildTimeValue.js → timeValue.js} +6 -0
  73. package/dist/cjs/utils/focus/cursor.js +2 -18
  74. package/dist/cjs/utils/focus/getActiveElement.js +4 -3
  75. package/dist/cjs/utils/focus/selection.js +1 -271
  76. package/dist/cjs/utils/focus/selector.js +1 -1
  77. package/dist/cjs/utils/index.js +7 -32
  78. package/dist/cjs/utils/keyDef/readNextDescriptor.js +5 -5
  79. package/dist/cjs/utils/misc/getTreeDiff.js +3 -3
  80. package/dist/cjs/utils/misc/getWindow.js +3 -2
  81. package/dist/cjs/utils/misc/isDisabled.js +3 -3
  82. package/dist/cjs/utils/misc/isVisible.js +3 -2
  83. package/dist/cjs/utils/misc/level.js +4 -9
  84. package/dist/cjs/utils/misc/wait.js +1 -1
  85. package/dist/cjs/utils/pointer/cssPointerEvents.js +31 -40
  86. package/dist/esm/_interop/dtl.js +6 -0
  87. package/dist/esm/_interop/dtlEventMap.js +6 -0
  88. package/dist/esm/_interop/dtlHelpers.js +6 -0
  89. package/dist/esm/clipboard/copy.js +6 -16
  90. package/dist/esm/clipboard/cut.js +6 -16
  91. package/dist/esm/clipboard/paste.js +6 -16
  92. package/dist/esm/convenience/click.js +1 -4
  93. package/dist/esm/convenience/hover.js +2 -12
  94. package/dist/esm/convenience/tab.js +1 -1
  95. package/dist/esm/document/UI.js +79 -0
  96. package/dist/esm/document/copySelection.js +33 -0
  97. package/dist/esm/document/getValueOrTextContent.js +23 -0
  98. package/dist/esm/document/index.js +4 -66
  99. package/dist/esm/document/interceptor.js +87 -5
  100. package/dist/esm/document/prepareDocument.js +63 -0
  101. package/dist/esm/document/trackValue.js +59 -0
  102. package/dist/esm/event/behavior/click.js +8 -12
  103. package/dist/esm/event/behavior/cut.js +5 -11
  104. package/dist/esm/event/behavior/keydown.js +36 -40
  105. package/dist/esm/event/behavior/keypress.js +12 -12
  106. package/dist/esm/event/behavior/keyup.js +6 -8
  107. package/dist/esm/event/behavior/paste.js +7 -13
  108. package/dist/esm/event/createEvent.js +43 -50
  109. package/dist/esm/event/dispatchEvent.js +20 -4
  110. package/dist/esm/event/eventMap.js +2 -2
  111. package/dist/esm/event/focus.js +39 -0
  112. package/dist/esm/event/index.js +14 -19
  113. package/dist/esm/{utils/edit → event}/input.js +39 -37
  114. package/dist/esm/{utils/edit/walkRadio.js → event/radio.js} +13 -7
  115. package/dist/esm/event/selection/getInputRange.js +16 -0
  116. package/dist/esm/event/selection/getTargetTypeAndSelection.js +37 -0
  117. package/dist/esm/event/selection/index.js +9 -0
  118. package/dist/esm/event/selection/modifySelection.js +26 -0
  119. package/dist/esm/event/selection/modifySelectionPerMouse.js +46 -0
  120. package/dist/esm/event/selection/moveSelection.js +44 -0
  121. package/dist/esm/{utils/focus → event/selection}/resolveCaretPosition.js +9 -17
  122. package/dist/esm/event/selection/selectAll.js +43 -0
  123. package/dist/esm/event/selection/setSelection.js +26 -0
  124. package/dist/esm/event/selection/setSelectionPerMouse.js +87 -0
  125. package/dist/esm/event/selection/setSelectionRange.js +36 -0
  126. package/dist/esm/event/selection/updateSelectionOnFocus.js +42 -0
  127. package/dist/esm/event/wrapEvent.js +2 -1
  128. package/dist/esm/index.js +1 -1
  129. package/dist/esm/keyboard/index.js +13 -23
  130. package/dist/esm/keyboard/parseKeyDef.js +9 -17
  131. package/dist/esm/options.js +1 -26
  132. package/dist/esm/pointer/index.js +28 -38
  133. package/dist/esm/pointer/keyMap.js +1 -1
  134. package/dist/esm/pointer/parseKeyDef.js +2 -10
  135. package/dist/esm/setup/api.js +33 -12
  136. package/dist/esm/setup/directApi.js +6 -6
  137. package/dist/esm/setup/index.js +0 -1
  138. package/dist/esm/setup/setup.js +66 -39
  139. package/dist/esm/setup/wrapAsync.js +2 -1
  140. package/dist/esm/system/index.js +15 -2
  141. package/dist/esm/system/keyboard.js +34 -21
  142. package/dist/esm/system/pointer/buttons.js +14 -1
  143. package/dist/esm/system/pointer/device.js +14 -1
  144. package/dist/esm/system/pointer/index.js +61 -45
  145. package/dist/esm/system/pointer/mouse.js +74 -53
  146. package/dist/esm/system/pointer/pointer.js +55 -41
  147. package/dist/esm/system/pointer/shared.js +6 -0
  148. package/dist/esm/utility/clear.js +10 -11
  149. package/dist/esm/utility/selectOptions.js +24 -25
  150. package/dist/esm/utility/type.js +5 -14
  151. package/dist/esm/utility/upload.js +9 -18
  152. package/dist/esm/utils/dataTransfer/Clipboard.js +26 -24
  153. package/dist/esm/utils/dataTransfer/DataTransfer.js +25 -9
  154. package/dist/esm/utils/edit/isEditable.js +4 -8
  155. package/dist/esm/utils/edit/maxLength.js +5 -17
  156. package/dist/esm/utils/edit/setFiles.js +4 -4
  157. package/dist/esm/utils/edit/{buildTimeValue.js → timeValue.js} +6 -1
  158. package/dist/esm/utils/focus/cursor.js +2 -18
  159. package/dist/esm/utils/focus/getActiveElement.js +4 -3
  160. package/dist/esm/utils/focus/selection.js +3 -265
  161. package/dist/esm/utils/focus/selector.js +1 -1
  162. package/dist/esm/utils/index.js +4 -11
  163. package/dist/esm/utils/keyDef/readNextDescriptor.js +5 -5
  164. package/dist/esm/utils/misc/getTreeDiff.js +3 -3
  165. package/dist/esm/utils/misc/getWindow.js +2 -1
  166. package/dist/esm/utils/misc/isDisabled.js +3 -3
  167. package/dist/esm/utils/misc/isVisible.js +3 -2
  168. package/dist/esm/utils/misc/level.js +4 -9
  169. package/dist/esm/utils/misc/wait.js +1 -1
  170. package/dist/esm/utils/pointer/cssPointerEvents.js +31 -40
  171. package/dist/types/_interop/dtl.d.ts +3 -0
  172. package/dist/types/_interop/dtlEventMap.d.ts +3 -0
  173. package/dist/types/_interop/dtlHelpers.d.ts +3 -0
  174. package/dist/types/clipboard/copy.d.ts +1 -1
  175. package/dist/types/clipboard/cut.d.ts +1 -1
  176. package/dist/types/clipboard/paste.d.ts +1 -1
  177. package/dist/types/convenience/click.d.ts +1 -1
  178. package/dist/types/convenience/hover.d.ts +1 -1
  179. package/dist/types/convenience/tab.d.ts +1 -1
  180. package/dist/types/document/UI.d.ts +42 -0
  181. package/dist/types/document/getValueOrTextContent.d.ts +1 -0
  182. package/dist/types/document/index.d.ts +5 -10
  183. package/dist/types/document/interceptor.d.ts +6 -3
  184. package/dist/types/document/prepareDocument.d.ts +8 -0
  185. package/dist/types/document/trackValue.d.ts +17 -0
  186. package/dist/types/event/behavior/registry.d.ts +2 -2
  187. package/dist/types/event/createEvent.d.ts +1 -1
  188. package/dist/types/event/dispatchEvent.d.ts +5 -2
  189. package/dist/types/event/eventMap.d.ts +8 -0
  190. package/dist/types/event/focus.d.ts +5 -0
  191. package/dist/types/event/index.d.ts +6 -4
  192. package/dist/types/event/input.d.ts +2 -0
  193. package/dist/types/event/radio.d.ts +4 -0
  194. package/dist/types/event/selection/getInputRange.d.ts +5 -0
  195. package/dist/types/event/selection/getTargetTypeAndSelection.d.ts +10 -0
  196. package/dist/types/event/selection/index.d.ts +15 -0
  197. package/dist/types/event/selection/modifySelection.d.ts +8 -0
  198. package/dist/types/event/selection/modifySelectionPerMouse.d.ts +7 -0
  199. package/dist/types/event/selection/moveSelection.d.ts +4 -0
  200. package/dist/types/event/selection/setSelection.d.ts +10 -0
  201. package/dist/types/event/selection/setSelectionPerMouse.d.ts +8 -0
  202. package/dist/types/event/selection/setSelectionRange.d.ts +6 -0
  203. package/dist/types/event/selection/updateSelectionOnFocus.d.ts +5 -0
  204. package/dist/types/event/types.d.ts +3 -3
  205. package/dist/types/index.d.ts +3 -1
  206. package/dist/types/keyboard/index.d.ts +2 -2
  207. package/dist/types/options.d.ts +2 -10
  208. package/dist/types/pointer/index.d.ts +7 -7
  209. package/dist/types/setup/api.d.ts +23 -5
  210. package/dist/types/setup/directApi.d.ts +5 -5
  211. package/dist/types/setup/index.d.ts +2 -15
  212. package/dist/types/setup/setup.d.ts +25 -7
  213. package/dist/types/system/keyboard.d.ts +4 -4
  214. package/dist/types/system/pointer/buttons.d.ts +2 -2
  215. package/dist/types/system/pointer/device.d.ts +1 -1
  216. package/dist/types/system/pointer/index.d.ts +7 -25
  217. package/dist/types/system/pointer/mouse.d.ts +6 -6
  218. package/dist/types/system/pointer/pointer.d.ts +8 -8
  219. package/dist/types/system/pointer/shared.d.ts +20 -0
  220. package/dist/types/utility/clear.d.ts +1 -1
  221. package/dist/types/utility/selectOptions.d.ts +1 -1
  222. package/dist/types/utility/type.d.ts +4 -4
  223. package/dist/types/utility/upload.d.ts +1 -1
  224. package/dist/types/utils/click/isClickableInput.d.ts +2 -2
  225. package/dist/types/utils/dataTransfer/Clipboard.d.ts +1 -1
  226. package/dist/types/utils/edit/isEditable.d.ts +6 -7
  227. package/dist/types/utils/edit/maxLength.d.ts +14 -1
  228. package/dist/types/utils/edit/{isValidDateOrTimeValue.d.ts → timeValue.d.ts} +1 -0
  229. package/dist/types/utils/focus/selection.d.ts +4 -69
  230. package/dist/types/utils/index.d.ts +2 -9
  231. package/dist/types/utils/keyDef/readNextDescriptor.d.ts +1 -1
  232. package/dist/types/utils/misc/isElementType.d.ts +1 -1
  233. package/dist/types/utils/misc/level.d.ts +4 -13
  234. package/dist/types/utils/misc/wait.d.ts +2 -2
  235. package/dist/types/utils/pointer/cssPointerEvents.d.ts +4 -4
  236. package/package.json +24 -12
  237. package/dist/cjs/document/selection.js +0 -108
  238. package/dist/cjs/document/setRangeText.js +0 -21
  239. package/dist/cjs/document/value.js +0 -127
  240. package/dist/cjs/setup/config.js +0 -7
  241. package/dist/cjs/utils/edit/getValue.js +0 -35
  242. package/dist/cjs/utils/edit/isValidDateOrTimeValue.js +0 -11
  243. package/dist/cjs/utils/focus/blur.js +0 -16
  244. package/dist/cjs/utils/focus/copySelection.js +0 -46
  245. package/dist/cjs/utils/focus/focus.js +0 -29
  246. package/dist/cjs/utils/focus/selectAll.js +0 -56
  247. package/dist/cjs/utils/misc/eventWrapper.js +0 -15
  248. package/dist/esm/document/selection.js +0 -100
  249. package/dist/esm/document/setRangeText.js +0 -17
  250. package/dist/esm/document/value.js +0 -117
  251. package/dist/esm/setup/config.js +0 -3
  252. package/dist/esm/utils/edit/getValue.js +0 -31
  253. package/dist/esm/utils/edit/isValidDateOrTimeValue.js +0 -7
  254. package/dist/esm/utils/focus/blur.js +0 -12
  255. package/dist/esm/utils/focus/copySelection.js +0 -42
  256. package/dist/esm/utils/focus/focus.js +0 -25
  257. package/dist/esm/utils/focus/selectAll.js +0 -51
  258. package/dist/esm/utils/misc/eventWrapper.js +0 -11
  259. package/dist/types/document/selection.d.ts +0 -29
  260. package/dist/types/document/setRangeText.d.ts +0 -1
  261. package/dist/types/document/value.d.ts +0 -26
  262. package/dist/types/setup/config.d.ts +0 -6
  263. package/dist/types/utils/edit/buildTimeValue.d.ts +0 -1
  264. package/dist/types/utils/edit/getValue.d.ts +0 -1
  265. package/dist/types/utils/edit/input.d.ts +0 -2
  266. package/dist/types/utils/edit/walkRadio.d.ts +0 -4
  267. package/dist/types/utils/focus/blur.d.ts +0 -2
  268. package/dist/types/utils/focus/focus.d.ts +0 -5
  269. package/dist/types/utils/misc/eventWrapper.d.ts +0 -1
  270. /package/dist/cjs/{event → _interop}/dom-events.d.js +0 -0
  271. /package/dist/cjs/{utils/misc → _interop}/dom-helpers.d.js +0 -0
  272. /package/dist/esm/{event → _interop}/dom-events.d.js +0 -0
  273. /package/dist/esm/{utils/misc → _interop}/dom-helpers.d.js +0 -0
  274. /package/dist/types/{utils/focus → document}/copySelection.d.ts +0 -0
  275. /package/dist/types/{utils/focus → event/selection}/resolveCaretPosition.d.ts +0 -0
  276. /package/dist/types/{utils/focus → event/selection}/selectAll.d.ts +0 -0
@@ -1,40 +1,36 @@
1
1
  import '../../utils/click/isClickableInput.js';
2
2
  import '../../utils/dataTransfer/Clipboard.js';
3
- import '../eventMap.js';
4
- import { dispatchEvent } from '../dispatchEvent.js';
5
- import '../../utils/edit/maxLength.js';
6
3
  import '../../utils/edit/isEditable.js';
7
- import { focus } from '../../utils/focus/focus.js';
8
- import { getWindow } from '../../utils/misc/getWindow.js';
4
+ import '../../utils/edit/maxLength.js';
9
5
  import { isElementType } from '../../utils/misc/isElementType.js';
10
- import { blur } from '../../utils/focus/blur.js';
6
+ import { getWindow } from '../../utils/misc/getWindow.js';
11
7
  import { isFocusable } from '../../utils/focus/isFocusable.js';
12
8
  import '../../utils/keyDef/readNextDescriptor.js';
13
9
  import { cloneEvent } from '../../utils/misc/cloneEvent.js';
14
- import '@testing-library/dom';
15
10
  import '../../utils/misc/level.js';
16
11
  import '../../options.js';
12
+ import { focusElement, blurElement } from '../focus.js';
17
13
  import { behavior } from './registry.js';
18
14
 
19
- behavior.click = (event, target, config)=>{
15
+ behavior.click = (event, target, instance)=>{
20
16
  const context = target.closest('button,input,label,select,textarea');
21
17
  const control = context && isElementType(context, 'label') && context.control;
22
18
  if (control) {
23
19
  return ()=>{
24
20
  if (isFocusable(control)) {
25
- focus(control);
21
+ focusElement(control);
26
22
  }
27
- dispatchEvent(config, control, cloneEvent(event));
23
+ instance.dispatchEvent(control, cloneEvent(event));
28
24
  };
29
25
  } else if (isElementType(target, 'input', {
30
26
  type: 'file'
31
27
  })) {
32
28
  return ()=>{
33
29
  // blur fires when the file selector pops up
34
- blur(target);
30
+ blurElement(target);
35
31
  target.dispatchEvent(new (getWindow(target)).Event('fileDialog'));
36
32
  // focus fires after the file selector has been closed
37
- focus(target);
33
+ focusElement(target);
38
34
  };
39
35
  }
40
36
  };
@@ -1,24 +1,18 @@
1
1
  import '../../utils/click/isClickableInput.js';
2
2
  import '../../utils/dataTransfer/Clipboard.js';
3
- import '../eventMap.js';
4
- import './click.js';
5
- import './keydown.js';
6
- import './keypress.js';
7
- import './keyup.js';
8
- import './paste.js';
9
- import { behavior } from './registry.js';
10
- import '@testing-library/dom';
11
- import { input } from '../../utils/edit/input.js';
12
3
  import { isEditable } from '../../utils/edit/isEditable.js';
4
+ import '../../utils/edit/maxLength.js';
13
5
  import '@testing-library/dom/dist/helpers.js';
14
6
  import '../../utils/keyDef/readNextDescriptor.js';
15
7
  import '../../utils/misc/level.js';
16
8
  import '../../options.js';
9
+ import { input } from '../input.js';
10
+ import { behavior } from './registry.js';
17
11
 
18
- behavior.cut = (event, target, config)=>{
12
+ behavior.cut = (event, target, instance)=>{
19
13
  return ()=>{
20
14
  if (isEditable(target)) {
21
- input(config, target, '', 'deleteByCut');
15
+ input(instance, target, '', 'deleteByCut');
22
16
  }
23
17
  };
24
18
  };
@@ -1,76 +1,72 @@
1
+ import { getUIValue, setUISelection } from '../../document/UI.js';
2
+ import { getValueOrTextContent } from '../../document/getValueOrTextContent.js';
1
3
  import '../../utils/click/isClickableInput.js';
2
4
  import '../../utils/dataTransfer/Clipboard.js';
3
- import { getValue } from '../../utils/edit/getValue.js';
4
- import { input } from '../../utils/edit/input.js';
5
5
  import { isContentEditable } from '../../utils/edit/isContentEditable.js';
6
6
  import { isEditable } from '../../utils/edit/isEditable.js';
7
- import { walkRadio } from '../../utils/edit/walkRadio.js';
8
- import '@testing-library/dom';
7
+ import '../../utils/edit/maxLength.js';
9
8
  import { isElementType } from '../../utils/misc/isElementType.js';
10
- import '@testing-library/dom/dist/helpers.js';
11
- import { moveSelection, setSelectionRange, hasOwnSelection } from '../../utils/focus/selection.js';
12
- import { focus } from '../../utils/focus/focus.js';
13
9
  import { getTabDestination } from '../../utils/focus/getTabDestination.js';
14
- import { selectAll } from '../../utils/focus/selectAll.js';
10
+ import { hasOwnSelection } from '../../utils/focus/selection.js';
15
11
  import '../../utils/keyDef/readNextDescriptor.js';
12
+ import '@testing-library/dom/dist/helpers.js';
16
13
  import '../../utils/misc/level.js';
17
14
  import '../../options.js';
18
- import '../eventMap.js';
19
- import './click.js';
20
- import './cut.js';
21
- import './keypress.js';
22
- import './keyup.js';
23
- import './paste.js';
15
+ import { focusElement } from '../focus.js';
16
+ import { input } from '../input.js';
17
+ import { moveSelection } from '../selection/moveSelection.js';
18
+ import { selectAll } from '../selection/selectAll.js';
19
+ import { setSelectionRange } from '../selection/setSelectionRange.js';
20
+ import { walkRadio } from '../radio.js';
24
21
  import { behavior } from './registry.js';
25
- import { setUISelection } from '../../document/selection.js';
26
22
 
27
- behavior.keydown = (event, target, config)=>{
28
- var ref;
29
- var ref1;
30
- return (ref1 = (ref = keydownBehavior[event.key]) === null || ref === void 0 ? void 0 : ref.call(keydownBehavior, event, target, config)) !== null && ref1 !== void 0 ? ref1 : combinationBehavior(event, target, config);
23
+ behavior.keydown = (event, target, instance)=>{
24
+ var _keydownBehavior_event_key, _keydownBehavior;
25
+ var _keydownBehavior_event_key1;
26
+ return (_keydownBehavior_event_key1 = (_keydownBehavior_event_key = (_keydownBehavior = keydownBehavior)[event.key]) === null || _keydownBehavior_event_key === void 0 ? void 0 : _keydownBehavior_event_key.call(_keydownBehavior, event, target, instance)) !== null && _keydownBehavior_event_key1 !== void 0 ? _keydownBehavior_event_key1 : combinationBehavior(event, target, instance);
31
27
  };
32
28
  const keydownBehavior = {
33
- ArrowDown: (event, target, config)=>{
29
+ ArrowDown: (event, target, instance)=>{
34
30
  /* istanbul ignore else */ if (isElementType(target, 'input', {
35
31
  type: 'radio'
36
32
  })) {
37
- return ()=>walkRadio(config, target, -1);
33
+ return ()=>walkRadio(instance, target, -1);
38
34
  }
39
35
  },
40
- ArrowLeft: (event, target, config)=>{
36
+ ArrowLeft: (event, target, instance)=>{
41
37
  if (isElementType(target, 'input', {
42
38
  type: 'radio'
43
39
  })) {
44
- return ()=>walkRadio(config, target, -1);
40
+ return ()=>walkRadio(instance, target, -1);
45
41
  }
46
42
  return ()=>moveSelection(target, -1);
47
43
  },
48
- ArrowRight: (event, target, config)=>{
44
+ ArrowRight: (event, target, instance)=>{
49
45
  if (isElementType(target, 'input', {
50
46
  type: 'radio'
51
47
  })) {
52
- return ()=>walkRadio(config, target, 1);
48
+ return ()=>walkRadio(instance, target, 1);
53
49
  }
54
50
  return ()=>moveSelection(target, 1);
55
51
  },
56
- ArrowUp: (event, target, config)=>{
52
+ ArrowUp: (event, target, instance)=>{
57
53
  /* istanbul ignore else */ if (isElementType(target, 'input', {
58
54
  type: 'radio'
59
55
  })) {
60
- return ()=>walkRadio(config, target, 1);
56
+ return ()=>walkRadio(instance, target, 1);
61
57
  }
62
58
  },
63
- Backspace: (event, target, config)=>{
59
+ Backspace: (event, target, instance)=>{
64
60
  if (isEditable(target)) {
65
61
  return ()=>{
66
- input(config, target, '', 'deleteContentBackward');
62
+ input(instance, target, '', 'deleteContentBackward');
67
63
  };
68
64
  }
69
65
  },
70
- Delete: (event, target, config)=>{
66
+ Delete: (event, target, instance)=>{
71
67
  if (isEditable(target)) {
72
68
  return ()=>{
73
- input(config, target, '', 'deleteContentForward');
69
+ input(instance, target, '', 'deleteContentForward');
74
70
  };
75
71
  }
76
72
  },
@@ -80,9 +76,9 @@ const keydownBehavior = {
80
76
  'textarea'
81
77
  ]) || isContentEditable(target)) {
82
78
  return ()=>{
83
- var ref;
84
- var ref1;
85
- const newPos = (ref1 = (ref = getValue(target)) === null || ref === void 0 ? void 0 : ref.length) !== null && ref1 !== void 0 ? ref1 : /* istanbul ignore next */ 0;
79
+ var _getValueOrTextContent;
80
+ var _getValueOrTextContent_length;
81
+ const newPos = (_getValueOrTextContent_length = (_getValueOrTextContent = getValueOrTextContent(target)) === null || _getValueOrTextContent === void 0 ? void 0 : _getValueOrTextContent.length) !== null && _getValueOrTextContent_length !== void 0 ? _getValueOrTextContent_length : /* istanbul ignore next */ 0;
86
82
  setSelectionRange(target, newPos, newPos);
87
83
  };
88
84
  }
@@ -102,7 +98,7 @@ const keydownBehavior = {
102
98
  'input'
103
99
  ])) {
104
100
  return ()=>{
105
- const newPos = getValue(target).length;
101
+ const newPos = getUIValue(target).length;
106
102
  setSelectionRange(target, newPos, newPos);
107
103
  };
108
104
  }
@@ -116,10 +112,10 @@ const keydownBehavior = {
116
112
  };
117
113
  }
118
114
  },
119
- Tab: (event, target, config)=>{
115
+ Tab: (event, target, instance)=>{
120
116
  return ()=>{
121
- const dest = getTabDestination(target, config.system.keyboard.modifiers.Shift);
122
- focus(dest);
117
+ const dest = getTabDestination(target, instance.system.keyboard.modifiers.Shift);
118
+ focusElement(dest);
123
119
  if (hasOwnSelection(dest)) {
124
120
  setUISelection(dest, {
125
121
  anchorOffset: 0,
@@ -129,8 +125,8 @@ const keydownBehavior = {
129
125
  };
130
126
  }
131
127
  };
132
- const combinationBehavior = (event, target, config)=>{
133
- if (event.code === 'KeyA' && config.system.keyboard.modifiers.Control) {
128
+ const combinationBehavior = (event, target, instance)=>{
129
+ if (event.code === 'KeyA' && instance.system.keyboard.modifiers.Control) {
134
130
  return ()=>selectAll(target);
135
131
  }
136
132
  };
@@ -1,39 +1,39 @@
1
- import { dispatchUIEvent } from '../index.js';
2
1
  import '../../utils/click/isClickableInput.js';
3
2
  import '../../utils/dataTransfer/Clipboard.js';
4
3
  import { isContentEditable } from '../../utils/edit/isContentEditable.js';
5
- import { input } from '../../utils/edit/input.js';
6
4
  import { isEditable } from '../../utils/edit/isEditable.js';
7
- import '@testing-library/dom';
5
+ import '../../utils/edit/maxLength.js';
8
6
  import { isElementType } from '../../utils/misc/isElementType.js';
9
7
  import '@testing-library/dom/dist/helpers.js';
10
8
  import '../../utils/keyDef/readNextDescriptor.js';
11
9
  import '../../utils/misc/level.js';
12
10
  import '../../options.js';
11
+ import { input } from '../input.js';
13
12
  import { behavior } from './registry.js';
14
13
 
15
- behavior.keypress = (event, target, config)=>{
14
+ behavior.keypress = (event, target, instance)=>{
16
15
  if (event.key === 'Enter') {
17
16
  if (isElementType(target, 'button') || isElementType(target, 'input') && ClickInputOnEnter.includes(target.type) || isElementType(target, 'a') && Boolean(target.href)) {
18
17
  return ()=>{
19
- dispatchUIEvent(config, target, 'click');
18
+ instance.dispatchUIEvent(target, 'click');
20
19
  };
21
20
  } else if (isElementType(target, 'input')) {
21
+ var _form;
22
22
  const form = target.form;
23
- const submit = form === null || form === void 0 ? void 0 : form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]');
23
+ const submit = (_form = form) === null || _form === void 0 ? void 0 : _form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]');
24
24
  if (submit) {
25
- return ()=>dispatchUIEvent(config, submit, 'click');
25
+ return ()=>instance.dispatchUIEvent(submit, 'click');
26
26
  } else if (form && SubmitSingleInputOnEnter.includes(target.type) && form.querySelectorAll('input').length === 1) {
27
- return ()=>dispatchUIEvent(config, form, 'submit');
27
+ return ()=>instance.dispatchUIEvent(form, 'submit');
28
28
  } else {
29
29
  return;
30
30
  }
31
31
  }
32
32
  }
33
33
  if (isEditable(target)) {
34
- const inputType = event.key === 'Enter' ? isContentEditable(target) && !config.system.keyboard.modifiers.Shift ? 'insertParagraph' : 'insertLineBreak' : 'insertText';
34
+ const inputType = event.key === 'Enter' ? isContentEditable(target) && !instance.system.keyboard.modifiers.Shift ? 'insertParagraph' : 'insertLineBreak' : 'insertText';
35
35
  const inputData = event.key === 'Enter' ? '\n' : event.key;
36
- return ()=>input(config, target, inputData, inputType);
36
+ return ()=>input(instance, target, inputData, inputType);
37
37
  }
38
38
  };
39
39
  const ClickInputOnEnter = [
@@ -42,7 +42,7 @@ const ClickInputOnEnter = [
42
42
  'file',
43
43
  'image',
44
44
  'reset',
45
- 'submit',
45
+ 'submit'
46
46
  ];
47
47
  const SubmitSingleInputOnEnter = [
48
48
  'email',
@@ -52,5 +52,5 @@ const SubmitSingleInputOnEnter = [
52
52
  'tel',
53
53
  'text',
54
54
  'url',
55
- 'week',
55
+ 'week'
56
56
  ];
@@ -1,23 +1,21 @@
1
1
  import { isClickableInput } from '../../utils/click/isClickableInput.js';
2
2
  import '../../utils/dataTransfer/Clipboard.js';
3
- import { dispatchUIEvent } from '../index.js';
4
- import '../../utils/edit/maxLength.js';
5
3
  import '../../utils/edit/isEditable.js';
6
- import '@testing-library/dom';
4
+ import '../../utils/edit/maxLength.js';
7
5
  import '@testing-library/dom/dist/helpers.js';
8
6
  import '../../utils/keyDef/readNextDescriptor.js';
9
7
  import '../../utils/misc/level.js';
10
8
  import '../../options.js';
11
9
  import { behavior } from './registry.js';
12
10
 
13
- behavior.keyup = (event, target, config)=>{
14
- var ref;
15
- return (ref = keyupBehavior[event.key]) === null || ref === void 0 ? void 0 : ref.call(keyupBehavior, event, target, config);
11
+ behavior.keyup = (event, target, instance)=>{
12
+ var _keyupBehavior_event_key, _keyupBehavior;
13
+ return (_keyupBehavior_event_key = (_keyupBehavior = keyupBehavior)[event.key]) === null || _keyupBehavior_event_key === void 0 ? void 0 : _keyupBehavior_event_key.call(_keyupBehavior, event, target, instance);
16
14
  };
17
15
  const keyupBehavior = {
18
- ' ': (event, target, config)=>{
16
+ ' ': (event, target, instance)=>{
19
17
  if (isClickableInput(target)) {
20
- return ()=>dispatchUIEvent(config, target, 'click');
18
+ return ()=>instance.dispatchUIEvent(target, 'click');
21
19
  }
22
20
  }
23
21
  };
@@ -1,27 +1,21 @@
1
1
  import '../../utils/click/isClickableInput.js';
2
2
  import '../../utils/dataTransfer/Clipboard.js';
3
- import '../eventMap.js';
4
- import './click.js';
5
- import './cut.js';
6
- import './keydown.js';
7
- import './keypress.js';
8
- import './keyup.js';
9
- import { behavior } from './registry.js';
10
- import '@testing-library/dom';
11
- import { input } from '../../utils/edit/input.js';
12
3
  import { isEditable } from '../../utils/edit/isEditable.js';
4
+ import '../../utils/edit/maxLength.js';
13
5
  import '@testing-library/dom/dist/helpers.js';
14
6
  import '../../utils/keyDef/readNextDescriptor.js';
15
7
  import '../../utils/misc/level.js';
16
8
  import '../../options.js';
9
+ import { input } from '../input.js';
10
+ import { behavior } from './registry.js';
17
11
 
18
- behavior.paste = (event, target, config)=>{
12
+ behavior.paste = (event, target, instance)=>{
19
13
  if (isEditable(target)) {
20
14
  return ()=>{
21
- var ref;
22
- const insertData = (ref = event.clipboardData) === null || ref === void 0 ? void 0 : ref.getData('text');
15
+ var _event_clipboardData;
16
+ const insertData = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.getData('text');
23
17
  if (insertData) {
24
- input(config, target, insertData, 'insertFromPaste');
18
+ input(instance, target, insertData, 'insertFromPaste');
25
19
  }
26
20
  };
27
21
  }
@@ -1,19 +1,12 @@
1
1
  import '../utils/click/isClickableInput.js';
2
2
  import '../utils/dataTransfer/Clipboard.js';
3
- import './behavior/click.js';
4
- import './behavior/cut.js';
5
- import './behavior/keydown.js';
6
- import './behavior/keypress.js';
7
- import './behavior/keyup.js';
8
- import './behavior/paste.js';
9
- import '@testing-library/dom';
10
- import { eventMap, eventMapKeys } from './eventMap.js';
11
- import '../utils/edit/maxLength.js';
12
3
  import '../utils/edit/isEditable.js';
4
+ import '../utils/edit/maxLength.js';
13
5
  import { getWindow } from '../utils/misc/getWindow.js';
14
6
  import '../utils/keyDef/readNextDescriptor.js';
15
7
  import '../utils/misc/level.js';
16
8
  import '../options.js';
9
+ import { eventMap, eventMapKeys } from './eventMap.js';
17
10
 
18
11
  const eventInitializer = {
19
12
  ClipboardEvent: [
@@ -32,7 +25,7 @@ const eventInitializer = {
32
25
  initUIEvent,
33
26
  initUIEventModififiers,
34
27
  initMouseEvent,
35
- initPointerEvent,
28
+ initPointerEvent
36
29
  ],
37
30
  KeyboardEvent: [
38
31
  initUIEvent,
@@ -41,58 +34,58 @@ const eventInitializer = {
41
34
  ]
42
35
  };
43
36
  function createEvent(type, target, init) {
44
- var ref;
37
+ var _eventInitializer_EventType;
45
38
  const window = getWindow(target);
46
- const { EventType , defaultInit } = eventMap[eventMapKeys[type]];
39
+ const { EventType, defaultInit } = eventMap[eventMapKeys[type]];
47
40
  const event = new (getEventConstructors(window))[EventType](type, defaultInit);
48
- (ref = eventInitializer[EventType]) === null || ref === void 0 ? void 0 : ref.forEach((f)=>f(event, init !== null && init !== void 0 ? init : {}));
41
+ (_eventInitializer_EventType = eventInitializer[EventType]) === null || _eventInitializer_EventType === void 0 ? void 0 : _eventInitializer_EventType.forEach((f)=>f(event, init !== null && init !== void 0 ? init : {}));
49
42
  return event;
50
43
  }
51
44
  /* istanbul ignore next */ function getEventConstructors(window) {
52
- var _Event;
53
- /* eslint-disable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ const Event = (_Event = window.Event) !== null && _Event !== void 0 ? _Event : class Event {
45
+ var _window_Event;
46
+ /* eslint-disable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ const Event = (_window_Event = window.Event) !== null && _window_Event !== void 0 ? _window_Event : class Event {
54
47
  };
55
- var _AnimationEvent;
56
- const AnimationEvent = (_AnimationEvent = window.AnimationEvent) !== null && _AnimationEvent !== void 0 ? _AnimationEvent : class AnimationEvent extends Event {
48
+ var _window_AnimationEvent;
49
+ const AnimationEvent = (_window_AnimationEvent = window.AnimationEvent) !== null && _window_AnimationEvent !== void 0 ? _window_AnimationEvent : class AnimationEvent extends Event {
57
50
  };
58
- var _ClipboardEvent;
59
- const ClipboardEvent = (_ClipboardEvent = window.ClipboardEvent) !== null && _ClipboardEvent !== void 0 ? _ClipboardEvent : class ClipboardEvent extends Event {
51
+ var _window_ClipboardEvent;
52
+ const ClipboardEvent = (_window_ClipboardEvent = window.ClipboardEvent) !== null && _window_ClipboardEvent !== void 0 ? _window_ClipboardEvent : class ClipboardEvent extends Event {
60
53
  };
61
- var _PopStateEvent;
62
- const PopStateEvent = (_PopStateEvent = window.PopStateEvent) !== null && _PopStateEvent !== void 0 ? _PopStateEvent : class PopStateEvent extends Event {
54
+ var _window_PopStateEvent;
55
+ const PopStateEvent = (_window_PopStateEvent = window.PopStateEvent) !== null && _window_PopStateEvent !== void 0 ? _window_PopStateEvent : class PopStateEvent extends Event {
63
56
  };
64
- var _ProgressEvent;
65
- const ProgressEvent = (_ProgressEvent = window.ProgressEvent) !== null && _ProgressEvent !== void 0 ? _ProgressEvent : class ProgressEvent extends Event {
57
+ var _window_ProgressEvent;
58
+ const ProgressEvent = (_window_ProgressEvent = window.ProgressEvent) !== null && _window_ProgressEvent !== void 0 ? _window_ProgressEvent : class ProgressEvent extends Event {
66
59
  };
67
- var _TransitionEvent;
68
- const TransitionEvent = (_TransitionEvent = window.TransitionEvent) !== null && _TransitionEvent !== void 0 ? _TransitionEvent : class TransitionEvent extends Event {
60
+ var _window_TransitionEvent;
61
+ const TransitionEvent = (_window_TransitionEvent = window.TransitionEvent) !== null && _window_TransitionEvent !== void 0 ? _window_TransitionEvent : class TransitionEvent extends Event {
69
62
  };
70
- var _UIEvent;
71
- const UIEvent = (_UIEvent = window.UIEvent) !== null && _UIEvent !== void 0 ? _UIEvent : class UIEvent extends Event {
63
+ var _window_UIEvent;
64
+ const UIEvent = (_window_UIEvent = window.UIEvent) !== null && _window_UIEvent !== void 0 ? _window_UIEvent : class UIEvent extends Event {
72
65
  };
73
- var _CompositionEvent;
74
- const CompositionEvent = (_CompositionEvent = window.CompositionEvent) !== null && _CompositionEvent !== void 0 ? _CompositionEvent : class CompositionEvent extends UIEvent {
66
+ var _window_CompositionEvent;
67
+ const CompositionEvent = (_window_CompositionEvent = window.CompositionEvent) !== null && _window_CompositionEvent !== void 0 ? _window_CompositionEvent : class CompositionEvent extends UIEvent {
75
68
  };
76
- var _FocusEvent;
77
- const FocusEvent = (_FocusEvent = window.FocusEvent) !== null && _FocusEvent !== void 0 ? _FocusEvent : class FocusEvent extends UIEvent {
69
+ var _window_FocusEvent;
70
+ const FocusEvent = (_window_FocusEvent = window.FocusEvent) !== null && _window_FocusEvent !== void 0 ? _window_FocusEvent : class FocusEvent extends UIEvent {
78
71
  };
79
- var _InputEvent;
80
- const InputEvent = (_InputEvent = window.InputEvent) !== null && _InputEvent !== void 0 ? _InputEvent : class InputEvent extends UIEvent {
72
+ var _window_InputEvent;
73
+ const InputEvent = (_window_InputEvent = window.InputEvent) !== null && _window_InputEvent !== void 0 ? _window_InputEvent : class InputEvent extends UIEvent {
81
74
  };
82
- var _KeyboardEvent;
83
- const KeyboardEvent = (_KeyboardEvent = window.KeyboardEvent) !== null && _KeyboardEvent !== void 0 ? _KeyboardEvent : class KeyboardEvent extends UIEvent {
75
+ var _window_KeyboardEvent;
76
+ const KeyboardEvent = (_window_KeyboardEvent = window.KeyboardEvent) !== null && _window_KeyboardEvent !== void 0 ? _window_KeyboardEvent : class KeyboardEvent extends UIEvent {
84
77
  };
85
- var _MouseEvent;
86
- const MouseEvent = (_MouseEvent = window.MouseEvent) !== null && _MouseEvent !== void 0 ? _MouseEvent : class MouseEvent extends UIEvent {
78
+ var _window_MouseEvent;
79
+ const MouseEvent = (_window_MouseEvent = window.MouseEvent) !== null && _window_MouseEvent !== void 0 ? _window_MouseEvent : class MouseEvent extends UIEvent {
87
80
  };
88
- var _DragEvent;
89
- const DragEvent = (_DragEvent = window.DragEvent) !== null && _DragEvent !== void 0 ? _DragEvent : class DragEvent extends MouseEvent {
81
+ var _window_DragEvent;
82
+ const DragEvent = (_window_DragEvent = window.DragEvent) !== null && _window_DragEvent !== void 0 ? _window_DragEvent : class DragEvent extends MouseEvent {
90
83
  };
91
- var _PointerEvent;
92
- const PointerEvent = (_PointerEvent = window.PointerEvent) !== null && _PointerEvent !== void 0 ? _PointerEvent : class PointerEvent extends MouseEvent {
84
+ var _window_PointerEvent;
85
+ const PointerEvent = (_window_PointerEvent = window.PointerEvent) !== null && _window_PointerEvent !== void 0 ? _window_PointerEvent : class PointerEvent extends MouseEvent {
93
86
  };
94
- var _TouchEvent;
95
- const TouchEvent = (_TouchEvent = window.TouchEvent) !== null && _TouchEvent !== void 0 ? _TouchEvent : class TouchEvent extends UIEvent {
87
+ var _window_TouchEvent;
88
+ const TouchEvent = (_window_TouchEvent = window.TouchEvent) !== null && _window_TouchEvent !== void 0 ? _window_TouchEvent : class TouchEvent extends UIEvent {
96
89
  };
97
90
  /* eslint-enable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ return {
98
91
  Event,
@@ -122,25 +115,25 @@ function assignProps(obj, props) {
122
115
  function sanitizeNumber(n) {
123
116
  return Number(n !== null && n !== void 0 ? n : 0);
124
117
  }
125
- function initClipboardEvent(event, { clipboardData }) {
118
+ function initClipboardEvent(event, { clipboardData }) {
126
119
  assignProps(event, {
127
120
  clipboardData
128
121
  });
129
122
  }
130
- function initInputEvent(event, { data , inputType , isComposing }) {
123
+ function initInputEvent(event, { data, inputType, isComposing }) {
131
124
  assignProps(event, {
132
125
  data,
133
126
  isComposing: Boolean(isComposing),
134
127
  inputType: String(inputType)
135
128
  });
136
129
  }
137
- function initUIEvent(event, { view , detail }) {
130
+ function initUIEvent(event, { view, detail }) {
138
131
  assignProps(event, {
139
132
  view,
140
133
  detail: sanitizeNumber(detail !== null && detail !== void 0 ? detail : 0)
141
134
  });
142
135
  }
143
- function initUIEventModififiers(event, { altKey , ctrlKey , metaKey , shiftKey , modifierAltGraph , modifierCapsLock , modifierFn , modifierFnLock , modifierNumLock , modifierScrollLock , modifierSymbol , modifierSymbolLock }) {
136
+ function initUIEventModififiers(event, { altKey, ctrlKey, metaKey, shiftKey, modifierAltGraph, modifierCapsLock, modifierFn, modifierFnLock, modifierNumLock, modifierScrollLock, modifierSymbol, modifierSymbolLock }) {
144
137
  assignProps(event, {
145
138
  altKey: Boolean(altKey),
146
139
  ctrlKey: Boolean(ctrlKey),
@@ -164,7 +157,7 @@ function initUIEventModififiers(event, { altKey , ctrlKey , metaKey , shiftKey ,
164
157
  }
165
158
  });
166
159
  }
167
- function initKeyboardEvent(event, { key , code , location , repeat , isComposing , charCode }) {
160
+ function initKeyboardEvent(event, { key, code, location, repeat, isComposing, charCode }) {
168
161
  assignProps(event, {
169
162
  key: String(key),
170
163
  code: String(code),
@@ -174,7 +167,7 @@ function initKeyboardEvent(event, { key , code , location , repeat , isComposing
174
167
  charCode
175
168
  });
176
169
  }
177
- function initMouseEvent(event, { x , y , screenX , screenY , clientX =x , clientY =y , button , buttons , relatedTarget }) {
170
+ function initMouseEvent(event, { x, y, screenX, screenY, clientX = x, clientY = y, button, buttons, relatedTarget }) {
178
171
  assignProps(event, {
179
172
  screenX: sanitizeNumber(screenX),
180
173
  screenY: sanitizeNumber(screenY),
@@ -187,7 +180,7 @@ function initMouseEvent(event, { x , y , screenX , screenY , clientX =x , client
187
180
  relatedTarget
188
181
  });
189
182
  }
190
- function initPointerEvent(event, { pointerId , width , height , pressure , tangentialPressure , tiltX , tiltY , twist , pointerType , isPrimary }) {
183
+ function initPointerEvent(event, { pointerId, width, height, pressure, tangentialPressure, tiltX, tiltY, twist, pointerType, isPrimary }) {
191
184
  assignProps(event, {
192
185
  pointerId: sanitizeNumber(pointerId),
193
186
  width: sanitizeNumber(width),
@@ -6,11 +6,23 @@ import './behavior/keyup.js';
6
6
  import './behavior/paste.js';
7
7
  import { behavior } from './behavior/registry.js';
8
8
  import { wrapEvent } from './wrapEvent.js';
9
+ import { isMouseEvent, isKeyboardEvent } from './eventMap.js';
10
+ import { createEvent } from './createEvent.js';
9
11
 
10
- function dispatchEvent(config, target, event, preventDefault = false) {
11
- var ref;
12
+ function dispatchUIEvent(target, type, init, preventDefault = false) {
13
+ if (isMouseEvent(type) || isKeyboardEvent(type)) {
14
+ init = {
15
+ ...init,
16
+ ...this.system.getUIEventModifiers()
17
+ };
18
+ }
19
+ const event = createEvent(type, target, init);
20
+ return dispatchEvent.call(this, target, event, preventDefault);
21
+ }
22
+ function dispatchEvent(target, event, preventDefault = false) {
23
+ var _behavior_type, _behavior;
12
24
  const type = event.type;
13
- const behaviorImplementation = preventDefault ? ()=>{} : (ref = behavior[type]) === null || ref === void 0 ? void 0 : ref(event, target, config);
25
+ const behaviorImplementation = preventDefault ? ()=>{} : (_behavior_type = (_behavior = behavior)[type]) === null || _behavior_type === void 0 ? void 0 : _behavior_type.call(_behavior, event, target, this);
14
26
  if (behaviorImplementation) {
15
27
  event.preventDefault();
16
28
  let defaultPrevented = false;
@@ -30,5 +42,9 @@ function dispatchEvent(config, target, event, preventDefault = false) {
30
42
  }
31
43
  return wrapEvent(()=>target.dispatchEvent(event));
32
44
  }
45
+ function dispatchDOMEvent(target, type, init) {
46
+ const event = createEvent(type, target, init);
47
+ wrapEvent(()=>target.dispatchEvent(event));
48
+ }
33
49
 
34
- export { dispatchEvent };
50
+ export { dispatchDOMEvent, dispatchEvent, dispatchUIEvent };
@@ -1,7 +1,7 @@
1
- import { eventMap as eventMap$1 } from '@testing-library/dom/dist/event-map.js';
1
+ import dtlEvents from '../_interop/dtlEventMap.js';
2
2
 
3
3
  const eventMap = {
4
- ...eventMap$1,
4
+ ...dtlEvents.eventMap,
5
5
  click: {
6
6
  EventType: 'PointerEvent',
7
7
  defaultInit: {
@@ -0,0 +1,39 @@
1
+ import '../utils/click/isClickableInput.js';
2
+ import '../utils/dataTransfer/Clipboard.js';
3
+ import '../utils/edit/isEditable.js';
4
+ import '../utils/edit/maxLength.js';
5
+ import { getActiveElement } from '../utils/focus/getActiveElement.js';
6
+ import '@testing-library/dom/dist/helpers.js';
7
+ import { isFocusable } from '../utils/focus/isFocusable.js';
8
+ import '../utils/keyDef/readNextDescriptor.js';
9
+ import { findClosest } from '../utils/misc/findClosest.js';
10
+ import '../utils/misc/level.js';
11
+ import '../options.js';
12
+ import { updateSelectionOnFocus } from './selection/updateSelectionOnFocus.js';
13
+ import { wrapEvent } from './wrapEvent.js';
14
+
15
+ /**
16
+ * Focus closest focusable element.
17
+ */ function focusElement(element) {
18
+ const target = findClosest(element, isFocusable);
19
+ const activeElement = getActiveElement(element.ownerDocument);
20
+ if ((target !== null && target !== void 0 ? target : element.ownerDocument.body) === activeElement) {
21
+ return;
22
+ } else if (target) {
23
+ wrapEvent(()=>target.focus());
24
+ } else {
25
+ wrapEvent(()=>{
26
+ var _activeElement;
27
+ return (_activeElement = activeElement) === null || _activeElement === void 0 ? void 0 : _activeElement.blur();
28
+ });
29
+ }
30
+ updateSelectionOnFocus(target !== null && target !== void 0 ? target : element.ownerDocument.body);
31
+ }
32
+ function blurElement(element) {
33
+ if (!isFocusable(element)) return;
34
+ const wasActive = getActiveElement(element.ownerDocument) === element;
35
+ if (!wasActive) return;
36
+ wrapEvent(()=>element.blur());
37
+ }
38
+
39
+ export { blurElement, focusElement };