@testing-library/user-event 14.4.3 → 14.5.1

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 (181) hide show
  1. package/dist/cjs/_interop/dtl.js +27 -0
  2. package/dist/cjs/_interop/dtlEventMap.js +27 -0
  3. package/dist/cjs/_interop/dtlHelpers.js +27 -0
  4. package/dist/cjs/clipboard/copy.js +2 -2
  5. package/dist/cjs/clipboard/cut.js +2 -2
  6. package/dist/cjs/clipboard/paste.js +4 -4
  7. package/dist/cjs/convenience/tab.js +1 -1
  8. package/dist/cjs/document/UI.js +5 -5
  9. package/dist/cjs/document/interceptor.js +1 -1
  10. package/dist/cjs/document/trackValue.js +4 -4
  11. package/dist/cjs/event/behavior/keydown.js +6 -6
  12. package/dist/cjs/event/behavior/keypress.js +2 -2
  13. package/dist/cjs/event/behavior/keyup.js +2 -2
  14. package/dist/cjs/event/behavior/paste.js +2 -2
  15. package/dist/cjs/event/createEvent.js +41 -41
  16. package/dist/cjs/event/dispatchEvent.js +2 -2
  17. package/dist/cjs/event/eventMap.js +22 -2
  18. package/dist/cjs/event/focus.js +1 -4
  19. package/dist/cjs/event/input.js +4 -4
  20. package/dist/cjs/event/selection/getInputRange.js +2 -2
  21. package/dist/cjs/event/selection/modifySelection.js +3 -3
  22. package/dist/cjs/event/selection/modifySelectionPerMouse.js +1 -1
  23. package/dist/cjs/event/selection/moveSelection.js +5 -5
  24. package/dist/cjs/event/selection/resolveCaretPosition.js +1 -1
  25. package/dist/cjs/event/selection/selectAll.js +4 -4
  26. package/dist/cjs/event/selection/setSelection.js +3 -3
  27. package/dist/cjs/event/selection/setSelectionPerMouse.js +5 -5
  28. package/dist/cjs/event/selection/setSelectionRange.js +2 -2
  29. package/dist/cjs/event/selection/updateSelectionOnFocus.js +2 -2
  30. package/dist/cjs/event/wrapEvent.js +23 -2
  31. package/dist/cjs/index.js +1 -0
  32. package/dist/cjs/keyboard/index.js +2 -2
  33. package/dist/cjs/keyboard/parseKeyDef.js +8 -8
  34. package/dist/cjs/pointer/index.js +11 -11
  35. package/dist/cjs/pointer/keyMap.js +1 -1
  36. package/dist/cjs/pointer/parseKeyDef.js +1 -1
  37. package/dist/cjs/setup/api.js +19 -17
  38. package/dist/cjs/setup/directApi.js +3 -3
  39. package/dist/cjs/setup/setup.js +10 -10
  40. package/dist/cjs/setup/wrapAsync.js +23 -2
  41. package/dist/cjs/system/index.js +15 -2
  42. package/dist/cjs/system/keyboard.js +27 -12
  43. package/dist/cjs/system/pointer/buttons.js +14 -1
  44. package/dist/cjs/system/pointer/device.js +14 -1
  45. package/dist/cjs/system/pointer/index.js +34 -17
  46. package/dist/cjs/system/pointer/mouse.js +33 -19
  47. package/dist/cjs/system/pointer/pointer.js +24 -8
  48. package/dist/cjs/system/pointer/shared.js +2 -2
  49. package/dist/cjs/utility/selectOptions.js +32 -11
  50. package/dist/cjs/utility/type.js +1 -1
  51. package/dist/cjs/utility/upload.js +4 -4
  52. package/dist/cjs/utils/dataTransfer/Clipboard.js +22 -8
  53. package/dist/cjs/utils/dataTransfer/DataTransfer.js +23 -8
  54. package/dist/cjs/utils/edit/maxLength.js +2 -2
  55. package/dist/cjs/utils/edit/setFiles.js +4 -4
  56. package/dist/cjs/utils/focus/cursor.js +2 -2
  57. package/dist/cjs/utils/focus/getActiveElement.js +2 -2
  58. package/dist/cjs/utils/focus/selector.js +1 -1
  59. package/dist/cjs/utils/keyDef/readNextDescriptor.js +5 -5
  60. package/dist/cjs/utils/misc/getTreeDiff.js +3 -3
  61. package/dist/cjs/utils/misc/getWindow.js +23 -2
  62. package/dist/cjs/utils/misc/isDisabled.js +3 -3
  63. package/dist/cjs/utils/misc/isVisible.js +1 -1
  64. package/dist/cjs/utils/misc/wait.js +1 -1
  65. package/dist/cjs/utils/pointer/cssPointerEvents.js +13 -13
  66. package/dist/esm/_interop/dtl.js +2 -0
  67. package/dist/esm/_interop/dtlEventMap.js +2 -0
  68. package/dist/esm/_interop/dtlHelpers.js +2 -0
  69. package/dist/esm/clipboard/copy.js +2 -2
  70. package/dist/esm/clipboard/cut.js +2 -2
  71. package/dist/esm/clipboard/paste.js +4 -4
  72. package/dist/esm/convenience/tab.js +1 -1
  73. package/dist/esm/document/UI.js +5 -5
  74. package/dist/esm/document/interceptor.js +1 -1
  75. package/dist/esm/document/trackValue.js +4 -4
  76. package/dist/esm/event/behavior/keydown.js +6 -6
  77. package/dist/esm/event/behavior/keypress.js +2 -2
  78. package/dist/esm/event/behavior/keyup.js +2 -2
  79. package/dist/esm/event/behavior/paste.js +2 -2
  80. package/dist/esm/event/createEvent.js +41 -41
  81. package/dist/esm/event/dispatchEvent.js +2 -2
  82. package/dist/esm/event/eventMap.js +2 -2
  83. package/dist/esm/event/focus.js +1 -4
  84. package/dist/esm/event/input.js +4 -4
  85. package/dist/esm/event/selection/getInputRange.js +2 -2
  86. package/dist/esm/event/selection/modifySelection.js +3 -3
  87. package/dist/esm/event/selection/modifySelectionPerMouse.js +1 -1
  88. package/dist/esm/event/selection/moveSelection.js +5 -5
  89. package/dist/esm/event/selection/resolveCaretPosition.js +1 -1
  90. package/dist/esm/event/selection/selectAll.js +4 -4
  91. package/dist/esm/event/selection/setSelection.js +3 -3
  92. package/dist/esm/event/selection/setSelectionPerMouse.js +5 -5
  93. package/dist/esm/event/selection/setSelectionRange.js +2 -2
  94. package/dist/esm/event/selection/updateSelectionOnFocus.js +2 -2
  95. package/dist/esm/event/wrapEvent.js +2 -1
  96. package/dist/esm/index.js +1 -1
  97. package/dist/esm/keyboard/index.js +2 -2
  98. package/dist/esm/keyboard/parseKeyDef.js +8 -8
  99. package/dist/esm/pointer/index.js +11 -11
  100. package/dist/esm/pointer/keyMap.js +1 -1
  101. package/dist/esm/pointer/parseKeyDef.js +1 -1
  102. package/dist/esm/setup/api.js +33 -12
  103. package/dist/esm/setup/directApi.js +3 -3
  104. package/dist/esm/setup/setup.js +11 -11
  105. package/dist/esm/setup/wrapAsync.js +2 -1
  106. package/dist/esm/system/index.js +15 -2
  107. package/dist/esm/system/keyboard.js +27 -12
  108. package/dist/esm/system/pointer/buttons.js +14 -1
  109. package/dist/esm/system/pointer/device.js +14 -1
  110. package/dist/esm/system/pointer/index.js +34 -17
  111. package/dist/esm/system/pointer/mouse.js +33 -19
  112. package/dist/esm/system/pointer/pointer.js +24 -8
  113. package/dist/esm/system/pointer/shared.js +2 -2
  114. package/dist/esm/utility/selectOptions.js +8 -7
  115. package/dist/esm/utility/type.js +1 -1
  116. package/dist/esm/utility/upload.js +4 -4
  117. package/dist/esm/utils/dataTransfer/Clipboard.js +22 -8
  118. package/dist/esm/utils/dataTransfer/DataTransfer.js +23 -8
  119. package/dist/esm/utils/edit/maxLength.js +2 -2
  120. package/dist/esm/utils/edit/setFiles.js +4 -4
  121. package/dist/esm/utils/focus/cursor.js +2 -2
  122. package/dist/esm/utils/focus/getActiveElement.js +2 -2
  123. package/dist/esm/utils/focus/selector.js +1 -1
  124. package/dist/esm/utils/keyDef/readNextDescriptor.js +5 -5
  125. package/dist/esm/utils/misc/getTreeDiff.js +3 -3
  126. package/dist/esm/utils/misc/getWindow.js +2 -1
  127. package/dist/esm/utils/misc/isDisabled.js +3 -3
  128. package/dist/esm/utils/misc/isVisible.js +1 -1
  129. package/dist/esm/utils/misc/wait.js +1 -1
  130. package/dist/esm/utils/pointer/cssPointerEvents.js +13 -13
  131. package/dist/types/_interop/dtl.d.ts +2 -0
  132. package/dist/types/_interop/dtlEventMap.d.ts +2 -0
  133. package/dist/types/_interop/dtlHelpers.d.ts +2 -0
  134. package/dist/types/clipboard/copy.d.ts +1 -1
  135. package/dist/types/clipboard/cut.d.ts +1 -1
  136. package/dist/types/clipboard/paste.d.ts +1 -1
  137. package/dist/types/convenience/click.d.ts +1 -1
  138. package/dist/types/convenience/hover.d.ts +1 -1
  139. package/dist/types/convenience/tab.d.ts +1 -1
  140. package/dist/types/document/UI.d.ts +3 -3
  141. package/dist/types/document/interceptor.d.ts +3 -3
  142. package/dist/types/event/behavior/registry.d.ts +1 -1
  143. package/dist/types/event/createEvent.d.ts +1 -1
  144. package/dist/types/event/dispatchEvent.d.ts +1 -1
  145. package/dist/types/event/eventMap.d.ts +8 -0
  146. package/dist/types/event/input.d.ts +1 -1
  147. package/dist/types/event/radio.d.ts +1 -1
  148. package/dist/types/event/selection/index.d.ts +2 -2
  149. package/dist/types/event/selection/modifySelectionPerMouse.d.ts +1 -1
  150. package/dist/types/event/selection/setSelectionPerMouse.d.ts +1 -1
  151. package/dist/types/event/types.d.ts +3 -3
  152. package/dist/types/index.d.ts +3 -1
  153. package/dist/types/keyboard/index.d.ts +1 -1
  154. package/dist/types/options.d.ts +2 -2
  155. package/dist/types/pointer/index.d.ts +7 -7
  156. package/dist/types/setup/api.d.ts +23 -5
  157. package/dist/types/setup/directApi.d.ts +5 -5
  158. package/dist/types/setup/setup.d.ts +5 -5
  159. package/dist/types/system/keyboard.d.ts +2 -2
  160. package/dist/types/system/pointer/buttons.d.ts +2 -2
  161. package/dist/types/system/pointer/device.d.ts +1 -1
  162. package/dist/types/system/pointer/mouse.d.ts +2 -2
  163. package/dist/types/system/pointer/pointer.d.ts +2 -2
  164. package/dist/types/utility/clear.d.ts +1 -1
  165. package/dist/types/utility/selectOptions.d.ts +1 -1
  166. package/dist/types/utility/type.d.ts +2 -2
  167. package/dist/types/utility/upload.d.ts +1 -1
  168. package/dist/types/utils/click/isClickableInput.d.ts +1 -1
  169. package/dist/types/utils/dataTransfer/Clipboard.d.ts +1 -1
  170. package/dist/types/utils/edit/isEditable.d.ts +2 -2
  171. package/dist/types/utils/edit/maxLength.d.ts +1 -1
  172. package/dist/types/utils/keyDef/readNextDescriptor.d.ts +1 -1
  173. package/dist/types/utils/misc/isElementType.d.ts +1 -1
  174. package/dist/types/utils/misc/level.d.ts +2 -2
  175. package/dist/types/utils/misc/wait.d.ts +1 -1
  176. package/dist/types/utils/pointer/cssPointerEvents.d.ts +1 -1
  177. package/package.json +22 -11
  178. /package/dist/cjs/{event → _interop}/dom-events.d.js +0 -0
  179. /package/dist/cjs/{utils/misc → _interop}/dom-helpers.d.js +0 -0
  180. /package/dist/esm/{event → _interop}/dom-events.d.js +0 -0
  181. /package/dist/esm/{utils/misc → _interop}/dom-helpers.d.js +0 -0
@@ -22,12 +22,12 @@ import { setSelection } from './setSelection.js';
22
22
  focusOffset: selection.startOffset === selection.endOffset ? selection.focusOffset + direction : direction < 0 ? selection.startOffset : selection.endOffset
23
23
  });
24
24
  } else {
25
- const selection1 = node.ownerDocument.getSelection();
26
- if (!(selection1 === null || selection1 === void 0 ? void 0 : selection1.focusNode)) {
25
+ const selection = node.ownerDocument.getSelection();
26
+ if (!(selection === null || selection === void 0 ? void 0 : selection.focusNode)) {
27
27
  return;
28
28
  }
29
- if (selection1.isCollapsed) {
30
- const nextPosition = getNextCursorPosition(selection1.focusNode, selection1.focusOffset, direction);
29
+ if (selection.isCollapsed) {
30
+ const nextPosition = getNextCursorPosition(selection.focusNode, selection.focusOffset, direction);
31
31
  if (nextPosition) {
32
32
  setSelection({
33
33
  focusNode: nextPosition.node,
@@ -35,7 +35,7 @@ import { setSelection } from './setSelection.js';
35
35
  });
36
36
  }
37
37
  } else {
38
- selection1[direction < 0 ? 'collapseToStart' : 'collapseToEnd']();
38
+ selection[direction < 0 ? 'collapseToStart' : 'collapseToEnd']();
39
39
  }
40
40
  }
41
41
  }
@@ -9,7 +9,7 @@ import '../../utils/keyDef/readNextDescriptor.js';
9
9
  import '../../utils/misc/level.js';
10
10
  import '../../options.js';
11
11
 
12
- function resolveCaretPosition({ target , node , offset }) {
12
+ function resolveCaretPosition({ target, node, offset }) {
13
13
  if (hasOwnSelection(target)) {
14
14
  return {
15
15
  node: target,
@@ -21,8 +21,8 @@ import { setSelection } from './setSelection.js';
21
21
  focusOffset: getUIValue(target).length
22
22
  });
23
23
  }
24
- var ref;
25
- const focusNode = (ref = getContentEditable(target)) !== null && ref !== void 0 ? ref : target.ownerDocument.body;
24
+ var _getContentEditable;
25
+ const focusNode = (_getContentEditable = getContentEditable(target)) !== null && _getContentEditable !== void 0 ? _getContentEditable : target.ownerDocument.body;
26
26
  setSelection({
27
27
  focusNode,
28
28
  anchorOffset: 0,
@@ -33,8 +33,8 @@ function isAllSelected(target) {
33
33
  if (hasOwnSelection(target)) {
34
34
  return getUISelection(target).startOffset === 0 && getUISelection(target).endOffset === getUIValue(target).length;
35
35
  }
36
- var ref;
37
- const focusNode = (ref = getContentEditable(target)) !== null && ref !== void 0 ? ref : target.ownerDocument.body;
36
+ var _getContentEditable;
37
+ const focusNode = (_getContentEditable = getContentEditable(target)) !== null && _getContentEditable !== void 0 ? _getContentEditable : target.ownerDocument.body;
38
38
  const selection = target.ownerDocument.getSelection();
39
39
  return (selection === null || selection === void 0 ? void 0 : selection.anchorNode) === focusNode && selection.focusNode === focusNode && selection.anchorOffset === 0 && selection.focusOffset === focusNode.childNodes.length;
40
40
  }
@@ -11,8 +11,8 @@ import { getTargetTypeAndSelection } from './getTargetTypeAndSelection.js';
11
11
 
12
12
  /**
13
13
  * Set the selection
14
- */ function setSelection({ focusNode , focusOffset , anchorNode =focusNode , anchorOffset =focusOffset }) {
15
- var ref, ref1;
14
+ */ function setSelection({ focusNode, focusOffset, anchorNode = focusNode, anchorOffset = focusOffset }) {
15
+ var _anchorNode_ownerDocument_getSelection, _anchorNode_ownerDocument;
16
16
  const typeAndSelection = getTargetTypeAndSelection(focusNode);
17
17
  if (typeAndSelection.type === 'input') {
18
18
  return setUISelection(focusNode, {
@@ -20,7 +20,7 @@ import { getTargetTypeAndSelection } from './getTargetTypeAndSelection.js';
20
20
  focusOffset
21
21
  });
22
22
  }
23
- (ref1 = (ref = anchorNode.ownerDocument) === null || ref === void 0 ? void 0 : ref.getSelection()) === null || ref1 === void 0 ? void 0 : ref1.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
23
+ (_anchorNode_ownerDocument = anchorNode.ownerDocument) === null || _anchorNode_ownerDocument === void 0 ? void 0 : (_anchorNode_ownerDocument_getSelection = _anchorNode_ownerDocument.getSelection()) === null || _anchorNode_ownerDocument_getSelection === void 0 ? void 0 : _anchorNode_ownerDocument_getSelection.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
24
24
  }
25
25
 
26
26
  export { setSelection };
@@ -10,7 +10,7 @@ import '../../utils/misc/level.js';
10
10
  import '../../options.js';
11
11
  import { resolveCaretPosition } from './resolveCaretPosition.js';
12
12
 
13
- function setSelectionPerMouseDown({ document , target , clickCount , node , offset }) {
13
+ function setSelectionPerMouseDown({ document, target, clickCount, node, offset }) {
14
14
  if (hasNoSelection(target)) {
15
15
  return;
16
16
  }
@@ -39,12 +39,12 @@ function setSelectionPerMouseDown({ document , target , clickCount , node , offs
39
39
  end: end !== null && end !== void 0 ? end : text.length
40
40
  };
41
41
  } else {
42
- const { node: startNode , offset: startOffset } = resolveCaretPosition({
42
+ const { node: startNode, offset: startOffset } = resolveCaretPosition({
43
43
  target,
44
44
  node,
45
45
  offset: start
46
46
  });
47
- const { node: endNode , offset: endOffset } = resolveCaretPosition({
47
+ const { node: endNode, offset: endOffset } = resolveCaretPosition({
48
48
  target,
49
49
  node,
50
50
  offset: end
@@ -73,13 +73,13 @@ function getTextRange(text, pos, clickCount) {
73
73
  if (clickCount % 3 === 2) {
74
74
  return [
75
75
  textPos - text.substr(0, pos).match(/(\w+|\s+|\W)?$/)[0].length,
76
- pos === undefined ? pos : pos + text.substr(pos).match(/^(\w+|\s+|\W)?/)[0].length,
76
+ pos === undefined ? pos : pos + text.substr(pos).match(/^(\w+|\s+|\W)?/)[0].length
77
77
  ];
78
78
  }
79
79
  // triple click
80
80
  return [
81
81
  textPos - text.substr(0, pos).match(/[^\r\n]*$/)[0].length,
82
- pos === undefined ? pos : pos + text.substr(pos).match(/^[^\r\n]*/)[0].length,
82
+ pos === undefined ? pos : pos + text.substr(pos).match(/^[^\r\n]*/)[0].length
83
83
  ];
84
84
  }
85
85
 
@@ -15,7 +15,7 @@ import { setSelection } from './setSelection.js';
15
15
  *
16
16
  * Handles input elements and contenteditable if it only contains a single text node.
17
17
  */ function setSelectionRange(element, anchorOffset, focusOffset) {
18
- var ref;
18
+ var _element_firstChild;
19
19
  if (hasOwnSelection(element)) {
20
20
  return setSelection({
21
21
  focusNode: element,
@@ -23,7 +23,7 @@ import { setSelection } from './setSelection.js';
23
23
  focusOffset
24
24
  });
25
25
  }
26
- /* istanbul ignore else */ if (isContentEditable(element) && ((ref = element.firstChild) === null || ref === void 0 ? void 0 : ref.nodeType) === 3) {
26
+ /* istanbul ignore else */ if (isContentEditable(element) && ((_element_firstChild = element.firstChild) === null || _element_firstChild === void 0 ? void 0 : _element_firstChild.nodeType) === 3) {
27
27
  return setSelection({
28
28
  focusNode: element.firstChild,
29
29
  anchorOffset,
@@ -28,8 +28,8 @@ import '../../options.js';
28
28
  const contenteditable = getContentEditable(selection.focusNode);
29
29
  if (contenteditable) {
30
30
  if (!selection.isCollapsed) {
31
- var ref;
32
- const focusNode = ((ref = contenteditable.firstChild) === null || ref === void 0 ? void 0 : ref.nodeType) === 3 ? contenteditable.firstChild : contenteditable;
31
+ var _contenteditable_firstChild;
32
+ const focusNode = ((_contenteditable_firstChild = contenteditable.firstChild) === null || _contenteditable_firstChild === void 0 ? void 0 : _contenteditable_firstChild.nodeType) === 3 ? contenteditable.firstChild : contenteditable;
33
33
  selection.setBaseAndExtent(focusNode, 0, focusNode, 0);
34
34
  }
35
35
  } else {
@@ -1,5 +1,6 @@
1
- import { getConfig } from '@testing-library/dom';
1
+ import * as named from '@testing-library/dom';
2
2
 
3
+ const { getConfig } = named;
3
4
  function wrapEvent(cb, _element) {
4
5
  return getConfig().eventWrapper(cb);
5
6
  }
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { userEvent as default } from './setup/index.js';
1
+ export { userEvent as default, userEvent } from './setup/index.js';
2
2
  export { PointerEventsCheckLevel } from './options.js';
@@ -16,8 +16,8 @@ async function keyboard(text) {
16
16
  await keyboardAction(this, actions[i]);
17
17
  }
18
18
  }
19
- async function keyboardAction(instance, { keyDef , releasePrevious , releaseSelf , repeat }) {
20
- const { system } = instance;
19
+ async function keyboardAction(instance, { keyDef, releasePrevious, releaseSelf, repeat }) {
20
+ const { system } = instance;
21
21
  // Release the key automatically if it was pressed before.
22
22
  if (system.keyboard.isKeyPressed(keyDef)) {
23
23
  await system.keyboard.keyup(instance, keyDef);
@@ -19,18 +19,18 @@ import '../options.js';
19
19
  */ function parseKeyDef(keyboardMap, text) {
20
20
  const defs = [];
21
21
  do {
22
- const { type , descriptor , consumedLength , releasePrevious , releaseSelf =true , repeat , } = readNextDescriptor(text, 'keyboard');
23
- var ref;
24
- const keyDef = (ref = keyboardMap.find((def)=>{
22
+ const { type, descriptor, consumedLength, releasePrevious, releaseSelf = true, repeat } = readNextDescriptor(text, 'keyboard');
23
+ var _keyboardMap_find;
24
+ const keyDef = (_keyboardMap_find = keyboardMap.find((def)=>{
25
25
  if (type === '[') {
26
- var ref;
27
- return ((ref = def.code) === null || ref === void 0 ? void 0 : ref.toLowerCase()) === descriptor.toLowerCase();
26
+ var _def_code;
27
+ return ((_def_code = def.code) === null || _def_code === void 0 ? void 0 : _def_code.toLowerCase()) === descriptor.toLowerCase();
28
28
  } else if (type === '{') {
29
- var ref1;
30
- return ((ref1 = def.key) === null || ref1 === void 0 ? void 0 : ref1.toLowerCase()) === descriptor.toLowerCase();
29
+ var _def_key;
30
+ return ((_def_key = def.key) === null || _def_key === void 0 ? void 0 : _def_key.toLowerCase()) === descriptor.toLowerCase();
31
31
  }
32
32
  return def.key === descriptor;
33
- })) !== null && ref !== void 0 ? ref : {
33
+ })) !== null && _keyboardMap_find !== void 0 ? _keyboardMap_find : {
34
34
  key: 'Unknown',
35
35
  code: 'Unknown',
36
36
  [type === '[' ? 'code' : 'key']: descriptor
@@ -10,7 +10,7 @@ import '../options.js';
10
10
  import { parseKeyDef } from './parseKeyDef.js';
11
11
 
12
12
  async function pointer(input) {
13
- const { pointerMap } = this.config;
13
+ const { pointerMap } = this.config;
14
14
  const actions = [];
15
15
  (Array.isArray(input) ? input : [
16
16
  input
@@ -33,16 +33,16 @@ async function pointer(input) {
33
33
  this.system.pointer.resetClickCount();
34
34
  }
35
35
  async function pointerAction(instance, action) {
36
- var ref, ref1;
36
+ var _previousPosition_caret, _previousPosition_caret1;
37
37
  const pointerName = 'pointerName' in action && action.pointerName ? action.pointerName : 'keyDef' in action ? instance.system.pointer.getPointerName(action.keyDef) : 'mouse';
38
38
  const previousPosition = instance.system.pointer.getPreviousPosition(pointerName);
39
- var _target, _coords, _node, _offset;
39
+ var _action_target, _action_coords, _action_node, _action_offset;
40
40
  const position = {
41
- target: (_target = action.target) !== null && _target !== void 0 ? _target : getPrevTarget(instance, previousPosition),
42
- coords: (_coords = action.coords) !== null && _coords !== void 0 ? _coords : previousPosition === null || previousPosition === void 0 ? void 0 : previousPosition.coords,
41
+ target: (_action_target = action.target) !== null && _action_target !== void 0 ? _action_target : getPrevTarget(instance, previousPosition),
42
+ coords: (_action_coords = action.coords) !== null && _action_coords !== void 0 ? _action_coords : previousPosition === null || previousPosition === void 0 ? void 0 : previousPosition.coords,
43
43
  caret: {
44
- node: (_node = action.node) !== null && _node !== void 0 ? _node : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === void 0 ? void 0 : (ref = previousPosition.caret) === null || ref === void 0 ? void 0 : ref.node,
45
- offset: (_offset = action.offset) !== null && _offset !== void 0 ? _offset : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === void 0 ? void 0 : (ref1 = previousPosition.caret) === null || ref1 === void 0 ? void 0 : ref1.offset
44
+ node: (_action_node = action.node) !== null && _action_node !== void 0 ? _action_node : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === void 0 ? void 0 : (_previousPosition_caret = previousPosition.caret) === null || _previousPosition_caret === void 0 ? void 0 : _previousPosition_caret.node,
45
+ offset: (_action_offset = action.offset) !== null && _action_offset !== void 0 ? _action_offset : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === void 0 ? void 0 : (_previousPosition_caret1 = previousPosition.caret) === null || _previousPosition_caret1 === void 0 ? void 0 : _previousPosition_caret1.offset
46
46
  }
47
47
  };
48
48
  if ('keyDef' in action) {
@@ -64,15 +64,15 @@ async function pointerAction(instance, action) {
64
64
  }
65
65
  }
66
66
  function hasCaretPosition(action) {
67
- var _target, ref;
68
- return !!((ref = (_target = action.target) !== null && _target !== void 0 ? _target : action.node) !== null && ref !== void 0 ? ref : action.offset !== undefined);
67
+ var _action_target, _ref;
68
+ return !!((_ref = (_action_target = action.target) !== null && _action_target !== void 0 ? _action_target : action.node) !== null && _ref !== void 0 ? _ref : action.offset !== undefined);
69
69
  }
70
70
  function getPrevTarget(instance, position) {
71
71
  if (!position) {
72
72
  throw new Error('This pointer has no previous position. Provide a target property!');
73
73
  }
74
- var _target;
75
- return (_target = position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
74
+ var _position_target;
75
+ return (_position_target = position.target) !== null && _position_target !== void 0 ? _position_target : instance.config.document.body;
76
76
  }
77
77
 
78
78
  export { pointer };
@@ -25,7 +25,7 @@ const defaultKeyMap = [
25
25
  {
26
26
  name: 'TouchC',
27
27
  pointerType: 'touch'
28
- },
28
+ }
29
29
  ];
30
30
 
31
31
  export { defaultKeyMap };
@@ -10,7 +10,7 @@ import '../options.js';
10
10
  function parseKeyDef(pointerMap, keys) {
11
11
  const defs = [];
12
12
  do {
13
- const { descriptor , consumedLength , releasePrevious , releaseSelf =true , } = readNextDescriptor(keys, 'pointer');
13
+ const { descriptor, consumedLength, releasePrevious, releaseSelf = true } = readNextDescriptor(keys, 'pointer');
14
14
  const keyDef = pointerMap.find((p)=>p.name === descriptor);
15
15
  if (keyDef) {
16
16
  defs.push({
@@ -1,12 +1,33 @@
1
- export { click, dblClick, tripleClick } from '../convenience/click.js';
2
- export { hover, unhover } from '../convenience/hover.js';
3
- export { tab } from '../convenience/tab.js';
4
- export { keyboard } from '../keyboard/index.js';
5
- export { copy } from '../clipboard/copy.js';
6
- export { cut } from '../clipboard/cut.js';
7
- export { paste } from '../clipboard/paste.js';
8
- export { pointer } from '../pointer/index.js';
9
- export { clear } from '../utility/clear.js';
10
- export { deselectOptions, selectOptions } from '../utility/selectOptions.js';
11
- export { type } from '../utility/type.js';
12
- export { upload } from '../utility/upload.js';
1
+ import { click, dblClick, tripleClick } from '../convenience/click.js';
2
+ import { hover, unhover } from '../convenience/hover.js';
3
+ import { tab } from '../convenience/tab.js';
4
+ import { keyboard } from '../keyboard/index.js';
5
+ import { copy } from '../clipboard/copy.js';
6
+ import { cut } from '../clipboard/cut.js';
7
+ import { paste } from '../clipboard/paste.js';
8
+ import { pointer } from '../pointer/index.js';
9
+ import { clear } from '../utility/clear.js';
10
+ import { deselectOptions, selectOptions } from '../utility/selectOptions.js';
11
+ import { type } from '../utility/type.js';
12
+ import { upload } from '../utility/upload.js';
13
+
14
+ const userEventApi = {
15
+ click,
16
+ dblClick,
17
+ tripleClick,
18
+ hover,
19
+ unhover,
20
+ tab,
21
+ keyboard,
22
+ copy,
23
+ cut,
24
+ paste,
25
+ pointer,
26
+ clear,
27
+ deselectOptions,
28
+ selectOptions,
29
+ type,
30
+ upload
31
+ };
32
+
33
+ export { userEventApi };
@@ -22,11 +22,11 @@ function hover(element, options = {}) {
22
22
  return setupDirect(options).api.hover(element);
23
23
  }
24
24
  async function keyboard(text, options = {}) {
25
- const { api , system } = setupDirect(options);
25
+ const { api, system } = setupDirect(options);
26
26
  return api.keyboard(text).then(()=>system);
27
27
  }
28
28
  async function pointer(input, options = {}) {
29
- const { api , system } = setupDirect(options);
29
+ const { api, system } = setupDirect(options);
30
30
  return api.pointer(input).then(()=>system);
31
31
  }
32
32
  function paste(clipboardData, options) {
@@ -42,7 +42,7 @@ function type(element, text, options = {}) {
42
42
  return setupDirect(options, element).api.type(element, text, options);
43
43
  }
44
44
  function unhover(element, options = {}) {
45
- const { api , system } = setupDirect(options);
45
+ const { api, system } = setupDirect(options);
46
46
  system.pointer.setMousePosition({
47
47
  target: element
48
48
  });
@@ -14,7 +14,7 @@ import '@testing-library/dom';
14
14
  import { defaultKeyMap } from '../keyboard/keyMap.js';
15
15
  import { defaultKeyMap as defaultKeyMap$1 } from '../pointer/keyMap.js';
16
16
  import { System } from '../system/index.js';
17
- import * as api from './api.js';
17
+ import { userEventApi } from './api.js';
18
18
  import { wrapAsync } from './wrapAsync.js';
19
19
 
20
20
  /**
@@ -53,18 +53,18 @@ function createConfig(options = {}, defaults = defaultOptionsSetup, node) {
53
53
  */ function setupMain(options = {}) {
54
54
  const config = createConfig(options);
55
55
  prepareDocument(config.document);
56
- var _defaultView;
57
- const view = (_defaultView = config.document.defaultView) !== null && _defaultView !== void 0 ? _defaultView : /* istanbul ignore next */ globalThis.window;
56
+ var _config_document_defaultView;
57
+ const view = (_config_document_defaultView = config.document.defaultView) !== null && _config_document_defaultView !== void 0 ? _config_document_defaultView : /* istanbul ignore next */ globalThis.window;
58
58
  attachClipboardStubToView(view);
59
59
  return createInstance(config).api;
60
60
  }
61
61
  /**
62
62
  * Setup in direct call per `userEvent.anyApi()`
63
- */ function setupDirect({ keyboardState , pointerState , ...options } = {}, node) {
63
+ */ function setupDirect({ keyboardState, pointerState, ...options } = {}, node) {
64
64
  const config = createConfig(options, defaultOptionsDirect, node);
65
65
  prepareDocument(config.document);
66
- var ref;
67
- const system = (ref = pointerState !== null && pointerState !== void 0 ? pointerState : keyboardState) !== null && ref !== void 0 ? ref : new System();
66
+ var _ref;
67
+ const system = (_ref = pointerState !== null && pointerState !== void 0 ? pointerState : keyboardState) !== null && _ref !== void 0 ? _ref : new System();
68
68
  return {
69
69
  api: createInstance(config, system).api,
70
70
  system
@@ -99,22 +99,22 @@ function createInstance(config, system = new System()) {
99
99
  dispatchUIEvent: dispatchUIEvent.bind(instance),
100
100
  system,
101
101
  levelRefs: {},
102
- ...api
102
+ ...userEventApi
103
103
  });
104
104
  return {
105
105
  instance,
106
106
  api: {
107
- ...Object.fromEntries(Object.entries(api).map(([name, api])=>[
107
+ ...Object.fromEntries(Object.entries(userEventApi).map(([name, api])=>[
108
108
  name,
109
- wrapAndBindImpl(instance, api),
109
+ wrapAndBindImpl(instance, api)
110
110
  ])),
111
111
  setup: setupSub.bind(instance)
112
112
  }
113
113
  };
114
114
  }
115
115
  function getDocument(options, node, defaults) {
116
- var _document, ref;
117
- return (ref = (_document = options.document) !== null && _document !== void 0 ? _document : node && getDocumentFromNode(node)) !== null && ref !== void 0 ? ref : defaults.document;
116
+ var _options_document, _ref;
117
+ return (_ref = (_options_document = options.document) !== null && _options_document !== void 0 ? _options_document : node && getDocumentFromNode(node)) !== null && _ref !== void 0 ? _ref : defaults.document;
118
118
  }
119
119
 
120
120
  export { createConfig, createInstance, setupDirect, setupMain, setupSub };
@@ -1,5 +1,6 @@
1
- import { getConfig } from '@testing-library/dom';
1
+ import * as named from '@testing-library/dom';
2
2
 
3
+ const { getConfig } = named;
3
4
  /**
4
5
  * Wrap an internal Promise
5
6
  */ function wrapAsync(implementation) {
@@ -1,6 +1,19 @@
1
1
  import { KeyboardHost } from './keyboard.js';
2
2
  import { PointerHost } from './pointer/index.js';
3
3
 
4
+ function _define_property(obj, key, value) {
5
+ if (key in obj) {
6
+ Object.defineProperty(obj, key, {
7
+ value: value,
8
+ enumerable: true,
9
+ configurable: true,
10
+ writable: true
11
+ });
12
+ } else {
13
+ obj[key] = value;
14
+ }
15
+ return obj;
16
+ }
4
17
  /**
5
18
  * @internal Do not create/alter this by yourself as this type might be subject to changes.
6
19
  */ class System {
@@ -21,8 +34,8 @@ import { PointerHost } from './pointer/index.js';
21
34
  };
22
35
  }
23
36
  constructor(){
24
- this.keyboard = new KeyboardHost(this);
25
- this.pointer = new PointerHost(this);
37
+ _define_property(this, "keyboard", new KeyboardHost(this));
38
+ _define_property(this, "pointer", new PointerHost(this));
26
39
  }
27
40
  }
28
41
 
@@ -8,7 +8,19 @@ import '../utils/keyDef/readNextDescriptor.js';
8
8
  import '../utils/misc/level.js';
9
9
  import '../options.js';
10
10
 
11
- var _pressed, _code, _code1;
11
+ function _define_property(obj, key, value) {
12
+ if (key in obj) {
13
+ Object.defineProperty(obj, key, {
14
+ value: value,
15
+ enumerable: true,
16
+ configurable: true,
17
+ writable: true
18
+ });
19
+ } else {
20
+ obj[key] = value;
21
+ }
22
+ return obj;
23
+ }
12
24
  var DOM_KEY_LOCATION;
13
25
  (function(DOM_KEY_LOCATION) {
14
26
  DOM_KEY_LOCATION[DOM_KEY_LOCATION["STANDARD"] = 0] = "STANDARD";
@@ -23,7 +35,7 @@ const modifierKeys = [
23
35
  'Fn',
24
36
  'Meta',
25
37
  'Shift',
26
- 'Symbol',
38
+ 'Symbol'
27
39
  ];
28
40
  function isModifierKey(key) {
29
41
  return modifierKeys.includes(key);
@@ -33,7 +45,7 @@ const modifierLocks = [
33
45
  'FnLock',
34
46
  'NumLock',
35
47
  'ScrollLock',
36
- 'SymbolLock',
48
+ 'SymbolLock'
37
49
  ];
38
50
  function isModifierLock(key) {
39
51
  return modifierLocks.includes(key);
@@ -46,12 +58,14 @@ class KeyboardHost {
46
58
  return Object.values(this.pressed).map((p)=>p.keyDef);
47
59
  }
48
60
  /** Press a key */ async keydown(instance, keyDef) {
61
+ var // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
62
+ _this_pressed, _code, _this_pressed_code;
49
63
  const key = String(keyDef.key);
50
64
  const code = String(keyDef.code);
51
65
  const target = getActiveElementOrBody(instance.config.document);
52
66
  this.setKeydownTarget(target);
53
- var ref;
54
- (ref = (_pressed = this.pressed)[_code = code]) !== null && ref !== void 0 ? ref : _pressed[_code] = {
67
+ var _;
68
+ (_ = (_this_pressed = this.pressed)[_code = code]) !== null && _ !== void 0 ? _ : _this_pressed[_code] = {
55
69
  keyDef,
56
70
  unpreventedDefault: false
57
71
  };
@@ -66,7 +80,7 @@ class KeyboardHost {
66
80
  this.modifiers[key] = true;
67
81
  this.modifierLockStart[key] = true;
68
82
  }
69
- (_code1 = this.pressed[code]).unpreventedDefault || (_code1.unpreventedDefault = unprevented);
83
+ (_this_pressed_code = this.pressed[code]).unpreventedDefault || (_this_pressed_code.unpreventedDefault = unprevented);
70
84
  if (unprevented && this.hasKeyPress(key)) {
71
85
  instance.dispatchUIEvent(getActiveElementOrBody(instance.config.document), 'keypress', {
72
86
  key,
@@ -106,7 +120,8 @@ class KeyboardHost {
106
120
  return (key.length === 1 || key === 'Enter') && !this.modifiers.Control && !this.modifiers.Alt;
107
121
  }
108
122
  constructor(system){
109
- this.modifiers = {
123
+ _define_property(this, "system", void 0);
124
+ _define_property(this, "modifiers", {
110
125
  Alt: false,
111
126
  AltGraph: false,
112
127
  CapsLock: false,
@@ -119,11 +134,11 @@ class KeyboardHost {
119
134
  Shift: false,
120
135
  Symbol: false,
121
136
  SymbolLock: false
122
- };
123
- this.pressed = {};
124
- this.carryChar = '';
125
- this.lastKeydownTarget = undefined;
126
- this.modifierLockStart = {};
137
+ });
138
+ _define_property(this, "pressed", {});
139
+ _define_property(this, "carryChar", '');
140
+ _define_property(this, "lastKeydownTarget", undefined);
141
+ _define_property(this, "modifierLockStart", {});
127
142
  this.system = system;
128
143
  }
129
144
  }
@@ -1,3 +1,16 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
1
14
  class Buttons {
2
15
  getButtons() {
3
16
  let v = 0;
@@ -31,7 +44,7 @@ class Buttons {
31
44
  return undefined;
32
45
  }
33
46
  constructor(){
34
- this.pressed = {};
47
+ _define_property(this, "pressed", {});
35
48
  }
36
49
  }
37
50
  const MouseButton = {
@@ -1,3 +1,16 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
1
14
  class Device {
2
15
  get countPressed() {
3
16
  return this.pressedKeys.size;
@@ -12,7 +25,7 @@ class Device {
12
25
  return this.pressedKeys.delete(keyDef.name);
13
26
  }
14
27
  constructor(){
15
- this.pressedKeys = new Set();
28
+ _define_property(this, "pressedKeys", new Set());
16
29
  }
17
30
  }
18
31