@testing-library/user-event 14.4.3 → 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 (183) 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 +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 +6 -4
  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 +4 -3
  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 +2 -2
  18. package/dist/cjs/event/focus.js +2 -2
  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/getTargetTypeAndSelection.js +3 -2
  22. package/dist/cjs/event/selection/modifySelection.js +3 -3
  23. package/dist/cjs/event/selection/modifySelectionPerMouse.js +4 -3
  24. package/dist/cjs/event/selection/moveSelection.js +6 -5
  25. package/dist/cjs/event/selection/resolveCaretPosition.js +1 -1
  26. package/dist/cjs/event/selection/selectAll.js +6 -5
  27. package/dist/cjs/event/selection/setSelection.js +3 -3
  28. package/dist/cjs/event/selection/setSelectionPerMouse.js +8 -7
  29. package/dist/cjs/event/selection/setSelectionRange.js +2 -2
  30. package/dist/cjs/event/selection/updateSelectionOnFocus.js +4 -3
  31. package/dist/cjs/event/wrapEvent.js +3 -2
  32. package/dist/cjs/index.js +1 -0
  33. package/dist/cjs/keyboard/index.js +2 -2
  34. package/dist/cjs/keyboard/parseKeyDef.js +8 -8
  35. package/dist/cjs/pointer/index.js +11 -11
  36. package/dist/cjs/pointer/keyMap.js +1 -1
  37. package/dist/cjs/pointer/parseKeyDef.js +1 -1
  38. package/dist/cjs/setup/api.js +19 -17
  39. package/dist/cjs/setup/directApi.js +3 -3
  40. package/dist/cjs/setup/setup.js +10 -10
  41. package/dist/cjs/setup/wrapAsync.js +3 -2
  42. package/dist/cjs/system/index.js +15 -2
  43. package/dist/cjs/system/keyboard.js +27 -12
  44. package/dist/cjs/system/pointer/buttons.js +14 -1
  45. package/dist/cjs/system/pointer/device.js +14 -1
  46. package/dist/cjs/system/pointer/index.js +46 -26
  47. package/dist/cjs/system/pointer/mouse.js +33 -19
  48. package/dist/cjs/system/pointer/pointer.js +24 -8
  49. package/dist/cjs/system/pointer/shared.js +2 -2
  50. package/dist/cjs/utility/selectOptions.js +12 -11
  51. package/dist/cjs/utility/type.js +1 -1
  52. package/dist/cjs/utility/upload.js +6 -5
  53. package/dist/cjs/utils/dataTransfer/Clipboard.js +25 -9
  54. package/dist/cjs/utils/dataTransfer/DataTransfer.js +25 -9
  55. package/dist/cjs/utils/edit/maxLength.js +2 -2
  56. package/dist/cjs/utils/edit/setFiles.js +4 -4
  57. package/dist/cjs/utils/focus/cursor.js +2 -2
  58. package/dist/cjs/utils/focus/getActiveElement.js +4 -3
  59. package/dist/cjs/utils/focus/selector.js +1 -1
  60. package/dist/cjs/utils/keyDef/readNextDescriptor.js +5 -5
  61. package/dist/cjs/utils/misc/getTreeDiff.js +3 -3
  62. package/dist/cjs/utils/misc/getWindow.js +3 -2
  63. package/dist/cjs/utils/misc/isDisabled.js +3 -3
  64. package/dist/cjs/utils/misc/isVisible.js +3 -2
  65. package/dist/cjs/utils/misc/wait.js +1 -1
  66. package/dist/cjs/utils/pointer/cssPointerEvents.js +23 -19
  67. package/dist/esm/_interop/dtl.js +6 -0
  68. package/dist/esm/_interop/dtlEventMap.js +6 -0
  69. package/dist/esm/_interop/dtlHelpers.js +6 -0
  70. package/dist/esm/clipboard/copy.js +2 -2
  71. package/dist/esm/clipboard/cut.js +2 -2
  72. package/dist/esm/clipboard/paste.js +4 -4
  73. package/dist/esm/convenience/tab.js +1 -1
  74. package/dist/esm/document/UI.js +5 -5
  75. package/dist/esm/document/interceptor.js +6 -4
  76. package/dist/esm/document/trackValue.js +4 -4
  77. package/dist/esm/event/behavior/keydown.js +6 -6
  78. package/dist/esm/event/behavior/keypress.js +4 -3
  79. package/dist/esm/event/behavior/keyup.js +2 -2
  80. package/dist/esm/event/behavior/paste.js +2 -2
  81. package/dist/esm/event/createEvent.js +41 -41
  82. package/dist/esm/event/dispatchEvent.js +2 -2
  83. package/dist/esm/event/eventMap.js +2 -2
  84. package/dist/esm/event/focus.js +2 -2
  85. package/dist/esm/event/input.js +4 -4
  86. package/dist/esm/event/selection/getInputRange.js +2 -2
  87. package/dist/esm/event/selection/getTargetTypeAndSelection.js +3 -2
  88. package/dist/esm/event/selection/modifySelection.js +3 -3
  89. package/dist/esm/event/selection/modifySelectionPerMouse.js +4 -3
  90. package/dist/esm/event/selection/moveSelection.js +6 -5
  91. package/dist/esm/event/selection/resolveCaretPosition.js +1 -1
  92. package/dist/esm/event/selection/selectAll.js +6 -5
  93. package/dist/esm/event/selection/setSelection.js +3 -3
  94. package/dist/esm/event/selection/setSelectionPerMouse.js +8 -7
  95. package/dist/esm/event/selection/setSelectionRange.js +2 -2
  96. package/dist/esm/event/selection/updateSelectionOnFocus.js +4 -3
  97. package/dist/esm/event/wrapEvent.js +2 -1
  98. package/dist/esm/index.js +1 -1
  99. package/dist/esm/keyboard/index.js +2 -2
  100. package/dist/esm/keyboard/parseKeyDef.js +8 -8
  101. package/dist/esm/pointer/index.js +11 -11
  102. package/dist/esm/pointer/keyMap.js +1 -1
  103. package/dist/esm/pointer/parseKeyDef.js +1 -1
  104. package/dist/esm/setup/api.js +33 -12
  105. package/dist/esm/setup/directApi.js +3 -3
  106. package/dist/esm/setup/setup.js +11 -11
  107. package/dist/esm/setup/wrapAsync.js +2 -1
  108. package/dist/esm/system/index.js +15 -2
  109. package/dist/esm/system/keyboard.js +27 -12
  110. package/dist/esm/system/pointer/buttons.js +14 -1
  111. package/dist/esm/system/pointer/device.js +14 -1
  112. package/dist/esm/system/pointer/index.js +46 -26
  113. package/dist/esm/system/pointer/mouse.js +33 -19
  114. package/dist/esm/system/pointer/pointer.js +24 -8
  115. package/dist/esm/system/pointer/shared.js +2 -2
  116. package/dist/esm/utility/selectOptions.js +8 -7
  117. package/dist/esm/utility/type.js +1 -1
  118. package/dist/esm/utility/upload.js +6 -5
  119. package/dist/esm/utils/dataTransfer/Clipboard.js +25 -9
  120. package/dist/esm/utils/dataTransfer/DataTransfer.js +25 -9
  121. package/dist/esm/utils/edit/maxLength.js +2 -2
  122. package/dist/esm/utils/edit/setFiles.js +4 -4
  123. package/dist/esm/utils/focus/cursor.js +2 -2
  124. package/dist/esm/utils/focus/getActiveElement.js +4 -3
  125. package/dist/esm/utils/focus/selector.js +1 -1
  126. package/dist/esm/utils/keyDef/readNextDescriptor.js +5 -5
  127. package/dist/esm/utils/misc/getTreeDiff.js +3 -3
  128. package/dist/esm/utils/misc/getWindow.js +2 -1
  129. package/dist/esm/utils/misc/isDisabled.js +3 -3
  130. package/dist/esm/utils/misc/isVisible.js +3 -2
  131. package/dist/esm/utils/misc/wait.js +1 -1
  132. package/dist/esm/utils/pointer/cssPointerEvents.js +23 -19
  133. package/dist/types/_interop/dtl.d.ts +3 -0
  134. package/dist/types/_interop/dtlEventMap.d.ts +3 -0
  135. package/dist/types/_interop/dtlHelpers.d.ts +3 -0
  136. package/dist/types/clipboard/copy.d.ts +1 -1
  137. package/dist/types/clipboard/cut.d.ts +1 -1
  138. package/dist/types/clipboard/paste.d.ts +1 -1
  139. package/dist/types/convenience/click.d.ts +1 -1
  140. package/dist/types/convenience/hover.d.ts +1 -1
  141. package/dist/types/convenience/tab.d.ts +1 -1
  142. package/dist/types/document/UI.d.ts +3 -3
  143. package/dist/types/document/interceptor.d.ts +3 -3
  144. package/dist/types/event/behavior/registry.d.ts +1 -1
  145. package/dist/types/event/createEvent.d.ts +1 -1
  146. package/dist/types/event/dispatchEvent.d.ts +1 -1
  147. package/dist/types/event/eventMap.d.ts +8 -0
  148. package/dist/types/event/input.d.ts +1 -1
  149. package/dist/types/event/radio.d.ts +1 -1
  150. package/dist/types/event/selection/index.d.ts +2 -2
  151. package/dist/types/event/selection/modifySelectionPerMouse.d.ts +1 -1
  152. package/dist/types/event/selection/setSelectionPerMouse.d.ts +1 -1
  153. package/dist/types/event/types.d.ts +3 -3
  154. package/dist/types/index.d.ts +3 -1
  155. package/dist/types/keyboard/index.d.ts +1 -1
  156. package/dist/types/options.d.ts +2 -2
  157. package/dist/types/pointer/index.d.ts +7 -7
  158. package/dist/types/setup/api.d.ts +23 -5
  159. package/dist/types/setup/directApi.d.ts +5 -5
  160. package/dist/types/setup/setup.d.ts +5 -5
  161. package/dist/types/system/keyboard.d.ts +2 -2
  162. package/dist/types/system/pointer/buttons.d.ts +2 -2
  163. package/dist/types/system/pointer/device.d.ts +1 -1
  164. package/dist/types/system/pointer/mouse.d.ts +2 -2
  165. package/dist/types/system/pointer/pointer.d.ts +2 -2
  166. package/dist/types/utility/clear.d.ts +1 -1
  167. package/dist/types/utility/selectOptions.d.ts +1 -1
  168. package/dist/types/utility/type.d.ts +2 -2
  169. package/dist/types/utility/upload.d.ts +1 -1
  170. package/dist/types/utils/click/isClickableInput.d.ts +1 -1
  171. package/dist/types/utils/dataTransfer/Clipboard.d.ts +1 -1
  172. package/dist/types/utils/edit/isEditable.d.ts +2 -2
  173. package/dist/types/utils/edit/maxLength.d.ts +1 -1
  174. package/dist/types/utils/keyDef/readNextDescriptor.d.ts +1 -1
  175. package/dist/types/utils/misc/isElementType.d.ts +1 -1
  176. package/dist/types/utils/misc/level.d.ts +2 -2
  177. package/dist/types/utils/misc/wait.d.ts +1 -1
  178. package/dist/types/utils/pointer/cssPointerEvents.d.ts +1 -1
  179. package/package.json +22 -11
  180. /package/dist/cjs/{event → _interop}/dom-events.d.js +0 -0
  181. /package/dist/cjs/{utils/misc → _interop}/dom-helpers.d.js +0 -0
  182. /package/dist/esm/{event → _interop}/dom-events.d.js +0 -0
  183. /package/dist/esm/{utils/misc → _interop}/dom-helpers.d.js +0 -0
@@ -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
 
@@ -3,7 +3,19 @@ import { Device } from './device.js';
3
3
  import { Mouse } from './mouse.js';
4
4
  import { Pointer } from './pointer.js';
5
5
 
6
- var _registry, _k;
6
+ function _define_property(obj, key, value) {
7
+ if (key in obj) {
8
+ Object.defineProperty(obj, key, {
9
+ value: value,
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true
13
+ });
14
+ } else {
15
+ obj[key] = value;
16
+ }
17
+ return obj;
18
+ }
7
19
  class PointerHost {
8
20
  isKeyPressed(keyDef) {
9
21
  return this.devices.get(keyDef.pointerType).isPressed(keyDef);
@@ -24,6 +36,7 @@ class PointerHost {
24
36
  }
25
37
  }
26
38
  async move(instance, pointerName, position) {
39
+ var _pointermove, _mousemove, _pointermove1, _mousemove1, _pointermove2, _mousemove2;
27
40
  const pointer = this.pointers.get(pointerName);
28
41
  // In (some?) browsers this order of events can be observed.
29
42
  // This interweaving of events is probably unnecessary.
@@ -31,12 +44,12 @@ class PointerHost {
31
44
  // the order in which they interweave/follow on a user interaction depends on the implementation.
32
45
  const pointermove = pointer.move(instance, position);
33
46
  const mousemove = pointer.pointerType === 'touch' || pointer.isPrevented && pointer.isDown ? undefined : this.mouse.move(instance, position);
34
- pointermove === null || pointermove === void 0 ? void 0 : pointermove.leave();
35
- mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
36
- pointermove === null || pointermove === void 0 ? void 0 : pointermove.enter();
37
- mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
38
- pointermove === null || pointermove === void 0 ? void 0 : pointermove.move();
39
- mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
47
+ (_pointermove = pointermove) === null || _pointermove === void 0 ? void 0 : _pointermove.leave();
48
+ (_mousemove = mousemove) === null || _mousemove === void 0 ? void 0 : _mousemove.leave();
49
+ (_pointermove1 = pointermove) === null || _pointermove1 === void 0 ? void 0 : _pointermove1.enter();
50
+ (_mousemove1 = mousemove) === null || _mousemove1 === void 0 ? void 0 : _mousemove1.enter();
51
+ (_pointermove2 = pointermove) === null || _pointermove2 === void 0 ? void 0 : _pointermove2.move();
52
+ (_mousemove2 = mousemove) === null || _mousemove2 === void 0 ? void 0 : _mousemove2.move();
40
53
  }
41
54
  async release(instance, keyDef, position) {
42
55
  const device = this.devices.get(keyDef.pointerType);
@@ -56,17 +69,19 @@ class PointerHost {
56
69
  }
57
70
  if (!pointer.isPrevented) {
58
71
  if (pointer.pointerType === 'touch' && !pointer.isMultitouch) {
72
+ var _mousemove, _mousemove1, _mousemove2;
59
73
  const mousemove = this.mouse.move(instance, pointer.position);
60
- mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
61
- mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
62
- mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
74
+ (_mousemove = mousemove) === null || _mousemove === void 0 ? void 0 : _mousemove.leave();
75
+ (_mousemove1 = mousemove) === null || _mousemove1 === void 0 ? void 0 : _mousemove1.enter();
76
+ (_mousemove2 = mousemove) === null || _mousemove2 === void 0 ? void 0 : _mousemove2.move();
63
77
  this.mouse.down(instance, keyDef, pointer);
64
78
  }
65
79
  if (!pointer.isMultitouch) {
66
- const mousemove1 = this.mouse.move(instance, pointer.position);
67
- mousemove1 === null || mousemove1 === void 0 ? void 0 : mousemove1.leave();
68
- mousemove1 === null || mousemove1 === void 0 ? void 0 : mousemove1.enter();
69
- mousemove1 === null || mousemove1 === void 0 ? void 0 : mousemove1.move();
80
+ var _mousemove3, _mousemove4, _mousemove5;
81
+ const mousemove = this.mouse.move(instance, pointer.position);
82
+ (_mousemove3 = mousemove) === null || _mousemove3 === void 0 ? void 0 : _mousemove3.leave();
83
+ (_mousemove4 = mousemove) === null || _mousemove4 === void 0 ? void 0 : _mousemove4.enter();
84
+ (_mousemove5 = mousemove) === null || _mousemove5 === void 0 ? void 0 : _mousemove5.move();
70
85
  this.mouse.up(instance, keyDef, pointer);
71
86
  }
72
87
  }
@@ -81,25 +96,30 @@ class PointerHost {
81
96
  this.mouse.resetClickCount();
82
97
  }
83
98
  getMouseTarget(instance) {
84
- var _target;
85
- return (_target = this.mouse.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
99
+ var _this_mouse_position_target;
100
+ return (_this_mouse_position_target = this.mouse.position.target) !== null && _this_mouse_position_target !== void 0 ? _this_mouse_position_target : instance.config.document.body;
86
101
  }
87
102
  setMousePosition(position) {
88
103
  this.mouse.position = position;
89
104
  this.pointers.get('mouse').position = position;
90
105
  }
91
106
  constructor(system){
92
- this.devices = new class {
107
+ _define_property(this, "system", void 0);
108
+ _define_property(this, "mouse", void 0);
109
+ _define_property(this, "buttons", void 0);
110
+ _define_property(this, "devices", new class {
93
111
  get(k) {
94
- var ref;
95
- (ref = (_registry = this.registry)[_k = k]) !== null && ref !== void 0 ? ref : _registry[_k] = new Device();
112
+ var // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
113
+ _this_registry, _k;
114
+ var _;
115
+ (_ = (_this_registry = this.registry)[_k = k]) !== null && _ !== void 0 ? _ : _this_registry[_k] = new Device();
96
116
  return this.registry[k];
97
117
  }
98
118
  constructor(){
99
- this.registry = {};
119
+ _define_property(this, "registry", {});
100
120
  }
101
- }();
102
- this.pointers = new class {
121
+ }());
122
+ _define_property(this, "pointers", new class {
103
123
  new(pointerName, keyDef) {
104
124
  const isPrimary = keyDef.pointerType !== 'touch' || !Object.values(this.registry).some((p)=>p.pointerType === 'touch' && !p.isCancelled);
105
125
  if (!isPrimary) {
@@ -126,16 +146,16 @@ class PointerHost {
126
146
  return pointerName in this.registry;
127
147
  }
128
148
  constructor(){
129
- this.registry = {
149
+ _define_property(this, "registry", {
130
150
  mouse: new Pointer({
131
151
  pointerId: 1,
132
152
  pointerType: 'mouse',
133
153
  isPrimary: true
134
154
  })
135
- };
136
- this.nextId = 2;
155
+ });
156
+ _define_property(this, "nextId", 2);
137
157
  }
138
- }();
158
+ }());
139
159
  this.system = system;
140
160
  this.buttons = new Buttons();
141
161
  this.mouse = new Mouse();
@@ -22,6 +22,19 @@ import { modifySelectionPerMouseMove } from '../../event/selection/modifySelecti
22
22
  import { getMouseEventButton, Buttons } from './buttons.js';
23
23
  import { isDifferentPointerPosition } from './shared.js';
24
24
 
25
+ function _define_property(obj, key, value) {
26
+ if (key in obj) {
27
+ Object.defineProperty(obj, key, {
28
+ value: value,
29
+ enumerable: true,
30
+ configurable: true,
31
+ writable: true
32
+ });
33
+ } else {
34
+ obj[key] = value;
35
+ }
36
+ return obj;
37
+ }
25
38
  /**
26
39
  * This object is the single "virtual" mouse that might be controlled by multiple different pointer devices.
27
40
  */ class Mouse {
@@ -119,39 +132,40 @@ import { isDifferentPointerPosition } from './shared.js';
119
132
  return init;
120
133
  }
121
134
  getTarget(instance) {
122
- var _target;
123
- return (_target = this.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
135
+ var _this_position_target;
136
+ return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body;
124
137
  }
125
138
  startSelecting(instance, clickCount) {
126
- var ref, ref1;
139
+ var _this_position_caret, _this_position_caret1;
127
140
  // TODO: support extending range (shift)
128
141
  this.selecting = setSelectionPerMouseDown({
129
142
  document: instance.config.document,
130
143
  target: this.getTarget(instance),
131
- node: (ref = this.position.caret) === null || ref === void 0 ? void 0 : ref.node,
132
- offset: (ref1 = this.position.caret) === null || ref1 === void 0 ? void 0 : ref1.offset,
144
+ node: (_this_position_caret = this.position.caret) === null || _this_position_caret === void 0 ? void 0 : _this_position_caret.node,
145
+ offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === void 0 ? void 0 : _this_position_caret1.offset,
133
146
  clickCount
134
147
  });
135
148
  }
136
149
  modifySelecting(instance) {
137
- var ref, ref1;
150
+ var _this_position_caret, _this_position_caret1;
138
151
  if (!this.selecting) {
139
152
  return;
140
153
  }
141
154
  modifySelectionPerMouseMove(this.selecting, {
142
155
  document: instance.config.document,
143
156
  target: this.getTarget(instance),
144
- node: (ref = this.position.caret) === null || ref === void 0 ? void 0 : ref.node,
145
- offset: (ref1 = this.position.caret) === null || ref1 === void 0 ? void 0 : ref1.offset
157
+ node: (_this_position_caret = this.position.caret) === null || _this_position_caret === void 0 ? void 0 : _this_position_caret.node,
158
+ offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === void 0 ? void 0 : _this_position_caret1.offset
146
159
  });
147
160
  }
148
161
  endSelecting() {
149
162
  this.selecting = undefined;
150
163
  }
151
164
  constructor(){
152
- this.position = {};
153
- this.buttons = new Buttons();
154
- this.buttonDownTarget = {};
165
+ _define_property(this, "position", {});
166
+ _define_property(this, "buttons", new Buttons());
167
+ _define_property(this, "selecting", void 0);
168
+ _define_property(this, "buttonDownTarget", {});
155
169
  // According to spec the `detail` on click events should be the number
156
170
  // of *consecutive* clicks with a specific button.
157
171
  // On `mousedown` and `mouseup` it should be this number increased by one.
@@ -162,7 +176,7 @@ import { isDifferentPointerPosition } from './shared.js';
162
176
  // If there is a delay while a button is pressed,
163
177
  // the `mouseup` and `click` are normal, but a following `mousedown` starts a new click count.
164
178
  // We'll follow the minimal implementation of Webkit.
165
- this.clickCount = new class {
179
+ _define_property(this, "clickCount", new class {
166
180
  incOnClick(button) {
167
181
  const current = this.down[button] === undefined ? undefined : Number(this.down[button]) + 1;
168
182
  this.count = this.count[button] === undefined ? {} : {
@@ -171,13 +185,13 @@ import { isDifferentPointerPosition } from './shared.js';
171
185
  return current;
172
186
  }
173
187
  getOnDown(button) {
174
- var _button;
188
+ var _this_count_button;
175
189
  this.down = {
176
- [button]: (_button = this.count[button]) !== null && _button !== void 0 ? _button : 0
190
+ [button]: (_this_count_button = this.count[button]) !== null && _this_count_button !== void 0 ? _this_count_button : 0
177
191
  };
178
- var _button1;
192
+ var _this_count_button1;
179
193
  this.count = {
180
- [button]: (_button1 = this.count[button]) !== null && _button1 !== void 0 ? _button1 : 0
194
+ [button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !== void 0 ? _this_count_button1 : 0
181
195
  };
182
196
  return Number(this.count[button]) + 1;
183
197
  }
@@ -188,10 +202,10 @@ import { isDifferentPointerPosition } from './shared.js';
188
202
  this.count = {};
189
203
  }
190
204
  constructor(){
191
- this.down = {};
192
- this.count = {};
205
+ _define_property(this, "down", {});
206
+ _define_property(this, "count", {});
193
207
  }
194
- }();
208
+ }());
195
209
  }
196
210
  }
197
211
 
@@ -9,6 +9,19 @@ import '../../utils/misc/level.js';
9
9
  import { assertPointerEvents, hasPointerEvents } from '../../utils/pointer/cssPointerEvents.js';
10
10
  import { isDifferentPointerPosition } from './shared.js';
11
11
 
12
+ function _define_property(obj, key, value) {
13
+ if (key in obj) {
14
+ Object.defineProperty(obj, key, {
15
+ value: value,
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true
19
+ });
20
+ } else {
21
+ obj[key] = value;
22
+ }
23
+ return obj;
24
+ }
12
25
  class Pointer {
13
26
  init(instance, position) {
14
27
  this.position = position;
@@ -82,8 +95,8 @@ class Pointer {
82
95
  this.isCancelled = true;
83
96
  }
84
97
  getTarget(instance) {
85
- var _target;
86
- return (_target = this.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
98
+ var _this_position_target;
99
+ return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body;
87
100
  }
88
101
  getEventInit() {
89
102
  return {
@@ -93,12 +106,15 @@ class Pointer {
93
106
  isPrimary: this.isPrimary
94
107
  };
95
108
  }
96
- constructor({ pointerId , pointerType , isPrimary }){
97
- this.isMultitouch = false;
98
- this.isCancelled = false;
99
- this.isDown = false;
100
- this.isPrevented = false;
101
- this.position = {};
109
+ constructor({ pointerId, pointerType, isPrimary }){
110
+ _define_property(this, "pointerId", void 0);
111
+ _define_property(this, "pointerType", void 0);
112
+ _define_property(this, "isPrimary", void 0);
113
+ _define_property(this, "isMultitouch", false);
114
+ _define_property(this, "isCancelled", false);
115
+ _define_property(this, "isDown", false);
116
+ _define_property(this, "isPrevented", false);
117
+ _define_property(this, "position", {});
102
118
  this.pointerId = pointerId;
103
119
  this.pointerType = pointerType;
104
120
  this.isPrimary = isPrimary;
@@ -1,6 +1,6 @@
1
1
  function isDifferentPointerPosition(positionA, positionB) {
2
- var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
3
- return positionA.target !== positionB.target || ((ref = positionA.coords) === null || ref === void 0 ? void 0 : ref.x) !== ((ref1 = positionB.coords) === null || ref1 === void 0 ? void 0 : ref1.y) || ((ref2 = positionA.coords) === null || ref2 === void 0 ? void 0 : ref2.y) !== ((ref3 = positionB.coords) === null || ref3 === void 0 ? void 0 : ref3.y) || ((ref4 = positionA.caret) === null || ref4 === void 0 ? void 0 : ref4.node) !== ((ref5 = positionB.caret) === null || ref5 === void 0 ? void 0 : ref5.node) || ((ref6 = positionA.caret) === null || ref6 === void 0 ? void 0 : ref6.offset) !== ((ref7 = positionB.caret) === null || ref7 === void 0 ? void 0 : ref7.offset);
2
+ var _positionA_coords, _positionB_coords, _positionA_coords1, _positionB_coords1, _positionA_caret, _positionB_caret, _positionA_caret1, _positionB_caret1;
3
+ return positionA.target !== positionB.target || ((_positionA_coords = positionA.coords) === null || _positionA_coords === void 0 ? void 0 : _positionA_coords.x) !== ((_positionB_coords = positionB.coords) === null || _positionB_coords === void 0 ? void 0 : _positionB_coords.y) || ((_positionA_coords1 = positionA.coords) === null || _positionA_coords1 === void 0 ? void 0 : _positionA_coords1.y) !== ((_positionB_coords1 = positionB.coords) === null || _positionB_coords1 === void 0 ? void 0 : _positionB_coords1.y) || ((_positionA_caret = positionA.caret) === null || _positionA_caret === void 0 ? void 0 : _positionA_caret.node) !== ((_positionB_caret = positionB.caret) === null || _positionB_caret === void 0 ? void 0 : _positionB_caret.node) || ((_positionA_caret1 = positionA.caret) === null || _positionA_caret1 === void 0 ? void 0 : _positionA_caret1.offset) !== ((_positionB_caret1 = positionB.caret) === null || _positionB_caret1 === void 0 ? void 0 : _positionB_caret1.offset);
4
4
  }
5
5
 
6
6
  export { isDifferentPointerPosition };
@@ -1,4 +1,4 @@
1
- import { getConfig } from '@testing-library/dom';
1
+ import dtl from '../_interop/dtl.js';
2
2
  import '../utils/click/isClickableInput.js';
3
3
  import '../utils/dataTransfer/Clipboard.js';
4
4
  import '../utils/edit/isEditable.js';
@@ -19,6 +19,7 @@ import '../event/behavior/paste.js';
19
19
  import '../event/eventMap.js';
20
20
  import { focusElement } from '../event/focus.js';
21
21
 
22
+ const { getConfig } = dtl;
22
23
  async function selectOptions(select, values) {
23
24
  return selectOptionsBase.call(this, true, select, values);
24
25
  }
@@ -82,15 +83,15 @@ async function selectOptionsBase(newValue, select, values) {
82
83
  await wait(this.config);
83
84
  }
84
85
  } else if (selectedOptions.length === 1) {
85
- const withPointerEvents1 = this.config.pointerEventsCheck === 0 ? true : hasPointerEvents(this, select);
86
+ const withPointerEvents = this.config.pointerEventsCheck === 0 ? true : hasPointerEvents(this, select);
86
87
  // the click to open the select options
87
- if (withPointerEvents1) {
88
+ if (withPointerEvents) {
88
89
  await this.click(select);
89
90
  } else {
90
91
  focusElement(select);
91
92
  }
92
93
  selectOption(selectedOptions[0]);
93
- if (withPointerEvents1) {
94
+ if (withPointerEvents) {
94
95
  // the browser triggers another click event on the select for the click on the option
95
96
  // this second click has no 'down' phase
96
97
  this.dispatchUIEvent(select, 'pointerover');
@@ -106,9 +107,9 @@ async function selectOptionsBase(newValue, select, values) {
106
107
  throw getConfig().getElementError(`Cannot select multiple options on a non-multiple select`, select);
107
108
  }
108
109
  } else if (select.getAttribute('role') === 'listbox') {
109
- for (const option1 of selectedOptions){
110
- await this.click(option1);
111
- await this.unhover(option1);
110
+ for (const option of selectedOptions){
111
+ await this.click(option);
112
+ await this.unhover(option);
112
113
  }
113
114
  } else {
114
115
  throw getConfig().getElementError(`Cannot select options on elements that are neither select nor listbox elements`, select);
@@ -9,7 +9,7 @@ import '../utils/misc/level.js';
9
9
  import '../options.js';
10
10
  import { setSelectionRange } from '../event/selection/setSelectionRange.js';
11
11
 
12
- async function type(element, text, { skipClick =this.config.skipClick , skipAutoClose =this.config.skipAutoClose , initialSelectionStart , initialSelectionEnd } = {}) {
12
+ async function type(element, text, { skipClick = this.config.skipClick, skipAutoClose = this.config.skipAutoClose, initialSelectionStart, initialSelectionEnd } = {}) {
13
13
  // TODO: properly type guard
14
14
  // we use this workaround for now to prevent changing behavior
15
15
  if (element.disabled) return;
@@ -16,18 +16,19 @@ async function upload(element, fileOrFiles) {
16
16
  if (!input || !isElementType(input, 'input', {
17
17
  type: 'file'
18
18
  })) {
19
- throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input === void 0 ? void 0 : input.tagName} element does not accept file uploads`);
19
+ var _input;
20
+ throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${(_input = input) === null || _input === void 0 ? void 0 : _input.tagName} element does not accept file uploads`);
20
21
  }
21
22
  if (isDisabled(element)) return;
22
23
  const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [
23
24
  fileOrFiles
24
25
  ]).filter((file)=>!this.config.applyAccept || isAcceptableFile(file, input.accept)).slice(0, input.multiple ? undefined : 1);
25
26
  const fileDialog = ()=>{
26
- var ref;
27
+ var _input_files;
27
28
  // do not fire an input event if the file selection does not change
28
- if (files.length === ((ref = input.files) === null || ref === void 0 ? void 0 : ref.length) && files.every((f, i)=>{
29
- var ref;
30
- return f === ((ref = input.files) === null || ref === void 0 ? void 0 : ref.item(i));
29
+ if (files.length === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.length) && files.every((f, i)=>{
30
+ var _input_files;
31
+ return f === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.item(i));
31
32
  })) {
32
33
  return;
33
34
  }
@@ -3,13 +3,26 @@ import { readBlobText } from './Blob.js';
3
3
  import { createDataTransfer, getBlobFromDataTransferItem } from './DataTransfer.js';
4
4
 
5
5
  // Clipboard is not available in jsdom
6
+ function _define_property(obj, key, value) {
7
+ if (key in obj) {
8
+ Object.defineProperty(obj, key, {
9
+ value: value,
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true
13
+ });
14
+ } else {
15
+ obj[key] = value;
16
+ }
17
+ return obj;
18
+ }
6
19
  // MDN lists string|Blob|Promise<Blob|string> as possible types in ClipboardItemData
7
20
  // lib.dom.d.ts lists only Promise<Blob|string>
8
21
  // https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem/ClipboardItem#syntax
9
22
  function createClipboardItem(window, ...blobs) {
10
23
  const dataMap = Object.fromEntries(blobs.map((b)=>[
11
24
  typeof b === 'string' ? 'text/plain' : b.type,
12
- Promise.resolve(b),
25
+ Promise.resolve(b)
13
26
  ]));
14
27
  // use real ClipboardItem if available
15
28
  /* istanbul ignore if */ if (typeof window.ClipboardItem !== 'undefined') {
@@ -31,6 +44,7 @@ function createClipboardItem(window, ...blobs) {
31
44
  });
32
45
  }
33
46
  constructor(d){
47
+ _define_property(this, "data", void 0);
34
48
  this.data = d;
35
49
  }
36
50
  }(dataMap);
@@ -61,15 +75,15 @@ function createClipboardStub(window, control) {
61
75
  }
62
76
  constructor(...args){
63
77
  super(...args);
64
- this.items = [];
78
+ _define_property(this, "items", []);
65
79
  }
66
80
  }(), {
67
81
  [ClipboardStubControl]: control
68
82
  });
69
83
  }
70
84
  function isClipboardStub(clipboard) {
71
- var ref;
72
- return !!((ref = clipboard) === null || ref === void 0 ? void 0 : ref[ClipboardStubControl]);
85
+ var _clipboard;
86
+ return !!((_clipboard = clipboard) === null || _clipboard === void 0 ? void 0 : _clipboard[ClipboardStubControl]);
73
87
  }
74
88
  function attachClipboardStubToView(window) {
75
89
  if (isClipboardStub(window.navigator.clipboard)) {
@@ -110,8 +124,9 @@ function detachClipboardStubFromView(window) {
110
124
  }
111
125
  }
112
126
  async function readDataTransferFromClipboard(document) {
127
+ var _window;
113
128
  const window = document.defaultView;
114
- const clipboard = window === null || window === void 0 ? void 0 : window.navigator.clipboard;
129
+ const clipboard = (_window = window) === null || _window === void 0 ? void 0 : _window.navigator.clipboard;
115
130
  const items = clipboard && await clipboard.read();
116
131
  if (!items) {
117
132
  throw new Error('The Clipboard API is unavailable.');
@@ -139,11 +154,12 @@ async function writeDataTransferToClipboard(document, clipboardData) {
139
154
  throw new Error('The Clipboard API is unavailable.');
140
155
  }
141
156
  }
142
- /* istanbul ignore else */ if (typeof globalThis.afterEach === 'function') {
143
- globalThis.afterEach(()=>resetClipboardStubOnView(globalThis.window));
157
+ const g = globalThis;
158
+ /* istanbul ignore else */ if (typeof g.afterEach === 'function') {
159
+ g.afterEach(()=>resetClipboardStubOnView(globalThis.window));
144
160
  }
145
- /* istanbul ignore else */ if (typeof globalThis.afterAll === 'function') {
146
- globalThis.afterAll(()=>detachClipboardStubFromView(globalThis.window));
161
+ /* istanbul ignore else */ if (typeof g.afterAll === 'function') {
162
+ g.afterAll(()=>detachClipboardStubFromView(globalThis.window));
147
163
  }
148
164
 
149
165
  export { attachClipboardStubToView, createClipboardItem, detachClipboardStubFromView, readDataTransferFromClipboard, resetClipboardStubOnView, writeDataTransferToClipboard };