@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
@@ -15,8 +15,8 @@ var getTargetTypeAndSelection = require('./getTargetTypeAndSelection.js');
15
15
 
16
16
  /**
17
17
  * Set the selection
18
- */ function setSelection({ focusNode , focusOffset , anchorNode =focusNode , anchorOffset =focusOffset }) {
19
- var ref, ref1;
18
+ */ function setSelection({ focusNode, focusOffset, anchorNode = focusNode, anchorOffset = focusOffset }) {
19
+ var _anchorNode_ownerDocument_getSelection, _anchorNode_ownerDocument;
20
20
  const typeAndSelection = getTargetTypeAndSelection.getTargetTypeAndSelection(focusNode);
21
21
  if (typeAndSelection.type === 'input') {
22
22
  return UI.setUISelection(focusNode, {
@@ -24,7 +24,7 @@ var getTargetTypeAndSelection = require('./getTargetTypeAndSelection.js');
24
24
  focusOffset
25
25
  });
26
26
  }
27
- (ref1 = (ref = anchorNode.ownerDocument) === null || ref === void 0 ? void 0 : ref.getSelection()) === null || ref1 === void 0 ? void 0 : ref1.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
27
+ (_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);
28
28
  }
29
29
 
30
30
  exports.setSelection = setSelection;
@@ -14,7 +14,7 @@ require('../../utils/misc/level.js');
14
14
  require('../../options.js');
15
15
  var resolveCaretPosition = require('./resolveCaretPosition.js');
16
16
 
17
- function setSelectionPerMouseDown({ document , target , clickCount , node , offset }) {
17
+ function setSelectionPerMouseDown({ document, target, clickCount, node, offset }) {
18
18
  if (selection.hasNoSelection(target)) {
19
19
  return;
20
20
  }
@@ -43,12 +43,12 @@ function setSelectionPerMouseDown({ document , target , clickCount , node , offs
43
43
  end: end !== null && end !== void 0 ? end : text.length
44
44
  };
45
45
  } else {
46
- const { node: startNode , offset: startOffset } = resolveCaretPosition.resolveCaretPosition({
46
+ const { node: startNode, offset: startOffset } = resolveCaretPosition.resolveCaretPosition({
47
47
  target,
48
48
  node,
49
49
  offset: start
50
50
  });
51
- const { node: endNode , offset: endOffset } = resolveCaretPosition.resolveCaretPosition({
51
+ const { node: endNode, offset: endOffset } = resolveCaretPosition.resolveCaretPosition({
52
52
  target,
53
53
  node,
54
54
  offset: end
@@ -77,13 +77,13 @@ function getTextRange(text, pos, clickCount) {
77
77
  if (clickCount % 3 === 2) {
78
78
  return [
79
79
  textPos - text.substr(0, pos).match(/(\w+|\s+|\W)?$/)[0].length,
80
- pos === undefined ? pos : pos + text.substr(pos).match(/^(\w+|\s+|\W)?/)[0].length,
80
+ pos === undefined ? pos : pos + text.substr(pos).match(/^(\w+|\s+|\W)?/)[0].length
81
81
  ];
82
82
  }
83
83
  // triple click
84
84
  return [
85
85
  textPos - text.substr(0, pos).match(/[^\r\n]*$/)[0].length,
86
- pos === undefined ? pos : pos + text.substr(pos).match(/^[^\r\n]*/)[0].length,
86
+ pos === undefined ? pos : pos + text.substr(pos).match(/^[^\r\n]*/)[0].length
87
87
  ];
88
88
  }
89
89
 
@@ -19,7 +19,7 @@ var setSelection = require('./setSelection.js');
19
19
  *
20
20
  * Handles input elements and contenteditable if it only contains a single text node.
21
21
  */ function setSelectionRange(element, anchorOffset, focusOffset) {
22
- var ref;
22
+ var _element_firstChild;
23
23
  if (selection.hasOwnSelection(element)) {
24
24
  return setSelection.setSelection({
25
25
  focusNode: element,
@@ -27,7 +27,7 @@ var setSelection = require('./setSelection.js');
27
27
  focusOffset
28
28
  });
29
29
  }
30
- /* istanbul ignore else */ if (isContentEditable.isContentEditable(element) && ((ref = element.firstChild) === null || ref === void 0 ? void 0 : ref.nodeType) === 3) {
30
+ /* istanbul ignore else */ if (isContentEditable.isContentEditable(element) && ((_element_firstChild = element.firstChild) === null || _element_firstChild === void 0 ? void 0 : _element_firstChild.nodeType) === 3) {
31
31
  return setSelection.setSelection({
32
32
  focusNode: element.firstChild,
33
33
  anchorOffset,
@@ -32,8 +32,8 @@ require('../../options.js');
32
32
  const contenteditable = isContentEditable.getContentEditable(selection$1.focusNode);
33
33
  if (contenteditable) {
34
34
  if (!selection$1.isCollapsed) {
35
- var ref;
36
- const focusNode = ((ref = contenteditable.firstChild) === null || ref === void 0 ? void 0 : ref.nodeType) === 3 ? contenteditable.firstChild : contenteditable;
35
+ var _contenteditable_firstChild;
36
+ const focusNode = ((_contenteditable_firstChild = contenteditable.firstChild) === null || _contenteditable_firstChild === void 0 ? void 0 : _contenteditable_firstChild.nodeType) === 3 ? contenteditable.firstChild : contenteditable;
37
37
  selection$1.setBaseAndExtent(focusNode, 0, focusNode, 0);
38
38
  }
39
39
  } else {
@@ -2,10 +2,31 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dom = require('@testing-library/dom');
5
+ var named = require('@testing-library/dom');
6
6
 
7
+ function _interopNamespace(e) {
8
+ if (e && e.__esModule) return e;
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () { return e[k]; }
17
+ });
18
+ }
19
+ });
20
+ }
21
+ n["default"] = e;
22
+ return Object.freeze(n);
23
+ }
24
+
25
+ var named__namespace = /*#__PURE__*/_interopNamespace(named);
26
+
27
+ const { getConfig } = named__namespace;
7
28
  function wrapEvent(cb, _element) {
8
- return dom.getConfig().eventWrapper(cb);
29
+ return getConfig().eventWrapper(cb);
9
30
  }
10
31
 
11
32
  exports.wrapEvent = wrapEvent;
package/dist/cjs/index.js CHANGED
@@ -8,6 +8,7 @@ var options = require('./options.js');
8
8
 
9
9
 
10
10
  exports["default"] = index.userEvent;
11
+ exports.userEvent = index.userEvent;
11
12
  Object.defineProperty(exports, 'PointerEventsCheckLevel', {
12
13
  enumerable: true,
13
14
  get: function () { return options.PointerEventsCheckLevel; }
@@ -20,8 +20,8 @@ async function keyboard(text) {
20
20
  await keyboardAction(this, actions[i]);
21
21
  }
22
22
  }
23
- async function keyboardAction(instance, { keyDef , releasePrevious , releaseSelf , repeat }) {
24
- const { system } = instance;
23
+ async function keyboardAction(instance, { keyDef, releasePrevious, releaseSelf, repeat }) {
24
+ const { system } = instance;
25
25
  // Release the key automatically if it was pressed before.
26
26
  if (system.keyboard.isKeyPressed(keyDef)) {
27
27
  await system.keyboard.keyup(instance, keyDef);
@@ -23,18 +23,18 @@ require('../options.js');
23
23
  */ function parseKeyDef(keyboardMap, text) {
24
24
  const defs = [];
25
25
  do {
26
- const { type , descriptor , consumedLength , releasePrevious , releaseSelf =true , repeat , } = readNextDescriptor.readNextDescriptor(text, 'keyboard');
27
- var ref;
28
- const keyDef = (ref = keyboardMap.find((def)=>{
26
+ const { type, descriptor, consumedLength, releasePrevious, releaseSelf = true, repeat } = readNextDescriptor.readNextDescriptor(text, 'keyboard');
27
+ var _keyboardMap_find;
28
+ const keyDef = (_keyboardMap_find = keyboardMap.find((def)=>{
29
29
  if (type === '[') {
30
- var ref;
31
- return ((ref = def.code) === null || ref === void 0 ? void 0 : ref.toLowerCase()) === descriptor.toLowerCase();
30
+ var _def_code;
31
+ return ((_def_code = def.code) === null || _def_code === void 0 ? void 0 : _def_code.toLowerCase()) === descriptor.toLowerCase();
32
32
  } else if (type === '{') {
33
- var ref1;
34
- return ((ref1 = def.key) === null || ref1 === void 0 ? void 0 : ref1.toLowerCase()) === descriptor.toLowerCase();
33
+ var _def_key;
34
+ return ((_def_key = def.key) === null || _def_key === void 0 ? void 0 : _def_key.toLowerCase()) === descriptor.toLowerCase();
35
35
  }
36
36
  return def.key === descriptor;
37
- })) !== null && ref !== void 0 ? ref : {
37
+ })) !== null && _keyboardMap_find !== void 0 ? _keyboardMap_find : {
38
38
  key: 'Unknown',
39
39
  code: 'Unknown',
40
40
  [type === '[' ? 'code' : 'key']: descriptor
@@ -14,7 +14,7 @@ require('../options.js');
14
14
  var parseKeyDef = require('./parseKeyDef.js');
15
15
 
16
16
  async function pointer(input) {
17
- const { pointerMap } = this.config;
17
+ const { pointerMap } = this.config;
18
18
  const actions = [];
19
19
  (Array.isArray(input) ? input : [
20
20
  input
@@ -37,16 +37,16 @@ async function pointer(input) {
37
37
  this.system.pointer.resetClickCount();
38
38
  }
39
39
  async function pointerAction(instance, action) {
40
- var ref, ref1;
40
+ var _previousPosition_caret, _previousPosition_caret1;
41
41
  const pointerName = 'pointerName' in action && action.pointerName ? action.pointerName : 'keyDef' in action ? instance.system.pointer.getPointerName(action.keyDef) : 'mouse';
42
42
  const previousPosition = instance.system.pointer.getPreviousPosition(pointerName);
43
- var _target, _coords, _node, _offset;
43
+ var _action_target, _action_coords, _action_node, _action_offset;
44
44
  const position = {
45
- target: (_target = action.target) !== null && _target !== void 0 ? _target : getPrevTarget(instance, previousPosition),
46
- coords: (_coords = action.coords) !== null && _coords !== void 0 ? _coords : previousPosition === null || previousPosition === void 0 ? void 0 : previousPosition.coords,
45
+ target: (_action_target = action.target) !== null && _action_target !== void 0 ? _action_target : getPrevTarget(instance, previousPosition),
46
+ coords: (_action_coords = action.coords) !== null && _action_coords !== void 0 ? _action_coords : previousPosition === null || previousPosition === void 0 ? void 0 : previousPosition.coords,
47
47
  caret: {
48
- 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,
49
- 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
48
+ 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,
49
+ 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
50
50
  }
51
51
  };
52
52
  if ('keyDef' in action) {
@@ -68,15 +68,15 @@ async function pointerAction(instance, action) {
68
68
  }
69
69
  }
70
70
  function hasCaretPosition(action) {
71
- var _target, ref;
72
- return !!((ref = (_target = action.target) !== null && _target !== void 0 ? _target : action.node) !== null && ref !== void 0 ? ref : action.offset !== undefined);
71
+ var _action_target, _ref;
72
+ return !!((_ref = (_action_target = action.target) !== null && _action_target !== void 0 ? _action_target : action.node) !== null && _ref !== void 0 ? _ref : action.offset !== undefined);
73
73
  }
74
74
  function getPrevTarget(instance, position) {
75
75
  if (!position) {
76
76
  throw new Error('This pointer has no previous position. Provide a target property!');
77
77
  }
78
- var _target;
79
- return (_target = position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
78
+ var _position_target;
79
+ return (_position_target = position.target) !== null && _position_target !== void 0 ? _position_target : instance.config.document.body;
80
80
  }
81
81
 
82
82
  exports.pointer = pointer;
@@ -29,7 +29,7 @@ const defaultKeyMap = [
29
29
  {
30
30
  name: 'TouchC',
31
31
  pointerType: 'touch'
32
- },
32
+ }
33
33
  ];
34
34
 
35
35
  exports.defaultKeyMap = defaultKeyMap;
@@ -14,7 +14,7 @@ require('../options.js');
14
14
  function parseKeyDef(pointerMap, keys) {
15
15
  const defs = [];
16
16
  do {
17
- const { descriptor , consumedLength , releasePrevious , releaseSelf =true , } = readNextDescriptor.readNextDescriptor(keys, 'pointer');
17
+ const { descriptor, consumedLength, releasePrevious, releaseSelf = true } = readNextDescriptor.readNextDescriptor(keys, 'pointer');
18
18
  const keyDef = pointerMap.find((p)=>p.name === descriptor);
19
19
  if (keyDef) {
20
20
  defs.push({
@@ -15,21 +15,23 @@ var selectOptions = require('../utility/selectOptions.js');
15
15
  var type = require('../utility/type.js');
16
16
  var upload = require('../utility/upload.js');
17
17
 
18
+ const userEventApi = {
19
+ click: click.click,
20
+ dblClick: click.dblClick,
21
+ tripleClick: click.tripleClick,
22
+ hover: hover.hover,
23
+ unhover: hover.unhover,
24
+ tab: tab.tab,
25
+ keyboard: index.keyboard,
26
+ copy: copy.copy,
27
+ cut: cut.cut,
28
+ paste: paste.paste,
29
+ pointer: index$1.pointer,
30
+ clear: clear.clear,
31
+ deselectOptions: selectOptions.deselectOptions,
32
+ selectOptions: selectOptions.selectOptions,
33
+ type: type.type,
34
+ upload: upload.upload
35
+ };
18
36
 
19
-
20
- exports.click = click.click;
21
- exports.dblClick = click.dblClick;
22
- exports.tripleClick = click.tripleClick;
23
- exports.hover = hover.hover;
24
- exports.unhover = hover.unhover;
25
- exports.tab = tab.tab;
26
- exports.keyboard = index.keyboard;
27
- exports.copy = copy.copy;
28
- exports.cut = cut.cut;
29
- exports.paste = paste.paste;
30
- exports.pointer = index$1.pointer;
31
- exports.clear = clear.clear;
32
- exports.deselectOptions = selectOptions.deselectOptions;
33
- exports.selectOptions = selectOptions.selectOptions;
34
- exports.type = type.type;
35
- exports.upload = upload.upload;
37
+ exports.userEventApi = userEventApi;
@@ -26,11 +26,11 @@ function hover(element, options = {}) {
26
26
  return setup.setupDirect(options).api.hover(element);
27
27
  }
28
28
  async function keyboard(text, options = {}) {
29
- const { api , system } = setup.setupDirect(options);
29
+ const { api, system } = setup.setupDirect(options);
30
30
  return api.keyboard(text).then(()=>system);
31
31
  }
32
32
  async function pointer(input, options = {}) {
33
- const { api , system } = setup.setupDirect(options);
33
+ const { api, system } = setup.setupDirect(options);
34
34
  return api.pointer(input).then(()=>system);
35
35
  }
36
36
  function paste(clipboardData, options) {
@@ -46,7 +46,7 @@ function type(element, text, options = {}) {
46
46
  return setup.setupDirect(options, element).api.type(element, text, options);
47
47
  }
48
48
  function unhover(element, options = {}) {
49
- const { api , system } = setup.setupDirect(options);
49
+ const { api, system } = setup.setupDirect(options);
50
50
  system.pointer.setMousePosition({
51
51
  target: element
52
52
  });
@@ -57,18 +57,18 @@ function createConfig(options = {}, defaults = defaultOptionsSetup, node) {
57
57
  */ function setupMain(options = {}) {
58
58
  const config = createConfig(options);
59
59
  prepareDocument.prepareDocument(config.document);
60
- var _defaultView;
61
- const view = (_defaultView = config.document.defaultView) !== null && _defaultView !== void 0 ? _defaultView : /* istanbul ignore next */ globalThis.window;
60
+ var _config_document_defaultView;
61
+ const view = (_config_document_defaultView = config.document.defaultView) !== null && _config_document_defaultView !== void 0 ? _config_document_defaultView : /* istanbul ignore next */ globalThis.window;
62
62
  Clipboard.attachClipboardStubToView(view);
63
63
  return createInstance(config).api;
64
64
  }
65
65
  /**
66
66
  * Setup in direct call per `userEvent.anyApi()`
67
- */ function setupDirect({ keyboardState , pointerState , ...options } = {}, node) {
67
+ */ function setupDirect({ keyboardState, pointerState, ...options } = {}, node) {
68
68
  const config = createConfig(options, defaultOptionsDirect, node);
69
69
  prepareDocument.prepareDocument(config.document);
70
- var ref;
71
- const system = (ref = pointerState !== null && pointerState !== void 0 ? pointerState : keyboardState) !== null && ref !== void 0 ? ref : new index.System();
70
+ var _ref;
71
+ const system = (_ref = pointerState !== null && pointerState !== void 0 ? pointerState : keyboardState) !== null && _ref !== void 0 ? _ref : new index.System();
72
72
  return {
73
73
  api: createInstance(config, system).api,
74
74
  system
@@ -103,22 +103,22 @@ function createInstance(config, system = new index.System()) {
103
103
  dispatchUIEvent: dispatchEvent.dispatchUIEvent.bind(instance),
104
104
  system,
105
105
  levelRefs: {},
106
- ...api
106
+ ...api.userEventApi
107
107
  });
108
108
  return {
109
109
  instance,
110
110
  api: {
111
- ...Object.fromEntries(Object.entries(api).map(([name, api])=>[
111
+ ...Object.fromEntries(Object.entries(api.userEventApi).map(([name, api])=>[
112
112
  name,
113
- wrapAndBindImpl(instance, api),
113
+ wrapAndBindImpl(instance, api)
114
114
  ])),
115
115
  setup: setupSub.bind(instance)
116
116
  }
117
117
  };
118
118
  }
119
119
  function getDocument(options, node, defaults) {
120
- var _document, ref;
121
- return (ref = (_document = options.document) !== null && _document !== void 0 ? _document : node && getDocumentFromNode.getDocumentFromNode(node)) !== null && ref !== void 0 ? ref : defaults.document;
120
+ var _options_document, _ref;
121
+ return (_ref = (_options_document = options.document) !== null && _options_document !== void 0 ? _options_document : node && getDocumentFromNode.getDocumentFromNode(node)) !== null && _ref !== void 0 ? _ref : defaults.document;
122
122
  }
123
123
 
124
124
  exports.createConfig = createConfig;
@@ -2,12 +2,33 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dom = require('@testing-library/dom');
5
+ var named = require('@testing-library/dom');
6
6
 
7
+ function _interopNamespace(e) {
8
+ if (e && e.__esModule) return e;
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () { return e[k]; }
17
+ });
18
+ }
19
+ });
20
+ }
21
+ n["default"] = e;
22
+ return Object.freeze(n);
23
+ }
24
+
25
+ var named__namespace = /*#__PURE__*/_interopNamespace(named);
26
+
27
+ const { getConfig } = named__namespace;
7
28
  /**
8
29
  * Wrap an internal Promise
9
30
  */ function wrapAsync(implementation) {
10
- return dom.getConfig().asyncWrapper(implementation);
31
+ return getConfig().asyncWrapper(implementation);
11
32
  }
12
33
 
13
34
  exports.wrapAsync = wrapAsync;
@@ -5,6 +5,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var keyboard = require('./keyboard.js');
6
6
  var index = require('./pointer/index.js');
7
7
 
8
+ function _define_property(obj, key, value) {
9
+ if (key in obj) {
10
+ Object.defineProperty(obj, key, {
11
+ value: value,
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true
15
+ });
16
+ } else {
17
+ obj[key] = value;
18
+ }
19
+ return obj;
20
+ }
8
21
  /**
9
22
  * @internal Do not create/alter this by yourself as this type might be subject to changes.
10
23
  */ class System {
@@ -25,8 +38,8 @@ var index = require('./pointer/index.js');
25
38
  };
26
39
  }
27
40
  constructor(){
28
- this.keyboard = new keyboard.KeyboardHost(this);
29
- this.pointer = new index.PointerHost(this);
41
+ _define_property(this, "keyboard", new keyboard.KeyboardHost(this));
42
+ _define_property(this, "pointer", new index.PointerHost(this));
30
43
  }
31
44
  }
32
45
 
@@ -12,7 +12,19 @@ require('../utils/keyDef/readNextDescriptor.js');
12
12
  require('../utils/misc/level.js');
13
13
  require('../options.js');
14
14
 
15
- var _pressed, _code, _code1;
15
+ function _define_property(obj, key, value) {
16
+ if (key in obj) {
17
+ Object.defineProperty(obj, key, {
18
+ value: value,
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true
22
+ });
23
+ } else {
24
+ obj[key] = value;
25
+ }
26
+ return obj;
27
+ }
16
28
  exports.DOM_KEY_LOCATION = void 0;
17
29
  (function(DOM_KEY_LOCATION) {
18
30
  DOM_KEY_LOCATION[DOM_KEY_LOCATION["STANDARD"] = 0] = "STANDARD";
@@ -27,7 +39,7 @@ const modifierKeys = [
27
39
  'Fn',
28
40
  'Meta',
29
41
  'Shift',
30
- 'Symbol',
42
+ 'Symbol'
31
43
  ];
32
44
  function isModifierKey(key) {
33
45
  return modifierKeys.includes(key);
@@ -37,7 +49,7 @@ const modifierLocks = [
37
49
  'FnLock',
38
50
  'NumLock',
39
51
  'ScrollLock',
40
- 'SymbolLock',
52
+ 'SymbolLock'
41
53
  ];
42
54
  function isModifierLock(key) {
43
55
  return modifierLocks.includes(key);
@@ -50,12 +62,14 @@ class KeyboardHost {
50
62
  return Object.values(this.pressed).map((p)=>p.keyDef);
51
63
  }
52
64
  /** Press a key */ async keydown(instance, keyDef) {
65
+ var // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
66
+ _this_pressed, _code, _this_pressed_code;
53
67
  const key = String(keyDef.key);
54
68
  const code = String(keyDef.code);
55
69
  const target = getActiveElement.getActiveElementOrBody(instance.config.document);
56
70
  this.setKeydownTarget(target);
57
- var ref;
58
- (ref = (_pressed = this.pressed)[_code = code]) !== null && ref !== void 0 ? ref : _pressed[_code] = {
71
+ var _;
72
+ (_ = (_this_pressed = this.pressed)[_code = code]) !== null && _ !== void 0 ? _ : _this_pressed[_code] = {
59
73
  keyDef,
60
74
  unpreventedDefault: false
61
75
  };
@@ -70,7 +84,7 @@ class KeyboardHost {
70
84
  this.modifiers[key] = true;
71
85
  this.modifierLockStart[key] = true;
72
86
  }
73
- (_code1 = this.pressed[code]).unpreventedDefault || (_code1.unpreventedDefault = unprevented);
87
+ (_this_pressed_code = this.pressed[code]).unpreventedDefault || (_this_pressed_code.unpreventedDefault = unprevented);
74
88
  if (unprevented && this.hasKeyPress(key)) {
75
89
  instance.dispatchUIEvent(getActiveElement.getActiveElementOrBody(instance.config.document), 'keypress', {
76
90
  key,
@@ -110,7 +124,8 @@ class KeyboardHost {
110
124
  return (key.length === 1 || key === 'Enter') && !this.modifiers.Control && !this.modifiers.Alt;
111
125
  }
112
126
  constructor(system){
113
- this.modifiers = {
127
+ _define_property(this, "system", void 0);
128
+ _define_property(this, "modifiers", {
114
129
  Alt: false,
115
130
  AltGraph: false,
116
131
  CapsLock: false,
@@ -123,11 +138,11 @@ class KeyboardHost {
123
138
  Shift: false,
124
139
  Symbol: false,
125
140
  SymbolLock: false
126
- };
127
- this.pressed = {};
128
- this.carryChar = '';
129
- this.lastKeydownTarget = undefined;
130
- this.modifierLockStart = {};
141
+ });
142
+ _define_property(this, "pressed", {});
143
+ _define_property(this, "carryChar", '');
144
+ _define_property(this, "lastKeydownTarget", undefined);
145
+ _define_property(this, "modifierLockStart", {});
131
146
  this.system = system;
132
147
  }
133
148
  }
@@ -2,6 +2,19 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ function _define_property(obj, key, value) {
6
+ if (key in obj) {
7
+ Object.defineProperty(obj, key, {
8
+ value: value,
9
+ enumerable: true,
10
+ configurable: true,
11
+ writable: true
12
+ });
13
+ } else {
14
+ obj[key] = value;
15
+ }
16
+ return obj;
17
+ }
5
18
  class Buttons {
6
19
  getButtons() {
7
20
  let v = 0;
@@ -35,7 +48,7 @@ class Buttons {
35
48
  return undefined;
36
49
  }
37
50
  constructor(){
38
- this.pressed = {};
51
+ _define_property(this, "pressed", {});
39
52
  }
40
53
  }
41
54
  const MouseButton = {
@@ -2,6 +2,19 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ function _define_property(obj, key, value) {
6
+ if (key in obj) {
7
+ Object.defineProperty(obj, key, {
8
+ value: value,
9
+ enumerable: true,
10
+ configurable: true,
11
+ writable: true
12
+ });
13
+ } else {
14
+ obj[key] = value;
15
+ }
16
+ return obj;
17
+ }
5
18
  class Device {
6
19
  get countPressed() {
7
20
  return this.pressedKeys.size;
@@ -16,7 +29,7 @@ class Device {
16
29
  return this.pressedKeys.delete(keyDef.name);
17
30
  }
18
31
  constructor(){
19
- this.pressedKeys = new Set();
32
+ _define_property(this, "pressedKeys", new Set());
20
33
  }
21
34
  }
22
35