@testing-library/user-event 14.0.0-beta.3 → 14.0.0-beta.4

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 (174) hide show
  1. package/dist/index.d.ts +1110 -3
  2. package/dist/index.js +2826 -8
  3. package/dist/package.json +1 -0
  4. package/package.json +6 -30
  5. package/dist/clipboard/copy.d.ts +0 -2
  6. package/dist/clipboard/copy.js +0 -36
  7. package/dist/clipboard/cut.d.ts +0 -2
  8. package/dist/clipboard/cut.js +0 -42
  9. package/dist/clipboard/index.d.ts +0 -3
  10. package/dist/clipboard/index.js +0 -44
  11. package/dist/clipboard/paste.d.ts +0 -2
  12. package/dist/clipboard/paste.js +0 -47
  13. package/dist/convenience/click.d.ts +0 -4
  14. package/dist/convenience/click.js +0 -52
  15. package/dist/convenience/hover.d.ts +0 -3
  16. package/dist/convenience/hover.js +0 -31
  17. package/dist/convenience/index.d.ts +0 -3
  18. package/dist/convenience/index.js +0 -44
  19. package/dist/convenience/tab.d.ts +0 -4
  20. package/dist/convenience/tab.js +0 -12
  21. package/dist/document/index.d.ts +0 -10
  22. package/dist/document/index.js +0 -100
  23. package/dist/document/interceptor.d.ts +0 -15
  24. package/dist/document/interceptor.js +0 -37
  25. package/dist/document/selection.d.ts +0 -27
  26. package/dist/document/selection.js +0 -90
  27. package/dist/document/value.d.ts +0 -18
  28. package/dist/document/value.js +0 -77
  29. package/dist/keyboard/getEventProps.d.ts +0 -15
  30. package/dist/keyboard/getEventProps.js +0 -27
  31. package/dist/keyboard/index.d.ts +0 -7
  32. package/dist/keyboard/index.js +0 -42
  33. package/dist/keyboard/keyMap.d.ts +0 -5
  34. package/dist/keyboard/keyMap.js +0 -119
  35. package/dist/keyboard/keyboardAction.d.ts +0 -10
  36. package/dist/keyboard/keyboardAction.js +0 -156
  37. package/dist/keyboard/parseKeyDef.d.ts +0 -17
  38. package/dist/keyboard/parseKeyDef.js +0 -61
  39. package/dist/keyboard/plugins/arrow.d.ts +0 -6
  40. package/dist/keyboard/plugins/arrow.js +0 -28
  41. package/dist/keyboard/plugins/character.d.ts +0 -5
  42. package/dist/keyboard/plugins/character.js +0 -173
  43. package/dist/keyboard/plugins/combination.d.ts +0 -5
  44. package/dist/keyboard/plugins/combination.js +0 -19
  45. package/dist/keyboard/plugins/control.d.ts +0 -6
  46. package/dist/keyboard/plugins/control.js +0 -52
  47. package/dist/keyboard/plugins/functional.d.ts +0 -11
  48. package/dist/keyboard/plugins/functional.js +0 -158
  49. package/dist/keyboard/plugins/index.d.ts +0 -7
  50. package/dist/keyboard/plugins/index.js +0 -33
  51. package/dist/keyboard/shared/fireChangeForInputTimeIfValid.d.ts +0 -3
  52. package/dist/keyboard/shared/fireChangeForInputTimeIfValid.js +0 -20
  53. package/dist/keyboard/shared/index.d.ts +0 -1
  54. package/dist/keyboard/shared/index.js +0 -18
  55. package/dist/keyboard/types.d.ts +0 -64
  56. package/dist/keyboard/types.js +0 -19
  57. package/dist/options.d.ts +0 -102
  58. package/dist/options.js +0 -36
  59. package/dist/pointer/index.d.ts +0 -10
  60. package/dist/pointer/index.js +0 -56
  61. package/dist/pointer/keyMap.d.ts +0 -2
  62. package/dist/pointer/keyMap.js +0 -29
  63. package/dist/pointer/parseKeyDef.d.ts +0 -6
  64. package/dist/pointer/parseKeyDef.js +0 -34
  65. package/dist/pointer/pointerAction.d.ts +0 -7
  66. package/dist/pointer/pointerAction.js +0 -46
  67. package/dist/pointer/pointerMove.d.ts +0 -6
  68. package/dist/pointer/pointerMove.js +0 -136
  69. package/dist/pointer/pointerPress.d.ts +0 -8
  70. package/dist/pointer/pointerPress.js +0 -327
  71. package/dist/pointer/resolveSelectionTarget.d.ts +0 -5
  72. package/dist/pointer/resolveSelectionTarget.js +0 -75
  73. package/dist/pointer/types.d.ts +0 -61
  74. package/dist/pointer/types.js +0 -1
  75. package/dist/setup/api.d.ts +0 -5
  76. package/dist/setup/api.js +0 -111
  77. package/dist/setup/config.d.ts +0 -10
  78. package/dist/setup/config.js +0 -8
  79. package/dist/setup/directApi.d.ts +0 -20
  80. package/dist/setup/directApi.js +0 -95
  81. package/dist/setup/index.d.ts +0 -30
  82. package/dist/setup/index.js +0 -27
  83. package/dist/setup/setup.d.ts +0 -74
  84. package/dist/setup/setup.js +0 -98
  85. package/dist/setup/wrapAsync.d.ts +0 -4
  86. package/dist/setup/wrapAsync.js +0 -15
  87. package/dist/utility/clear.d.ts +0 -2
  88. package/dist/utility/clear.js +0 -30
  89. package/dist/utility/index.d.ts +0 -4
  90. package/dist/utility/index.js +0 -57
  91. package/dist/utility/selectOptions.d.ts +0 -3
  92. package/dist/utility/selectOptions.js +0 -132
  93. package/dist/utility/type.d.ts +0 -9
  94. package/dist/utility/type.js +0 -37
  95. package/dist/utility/upload.d.ts +0 -5
  96. package/dist/utility/upload.js +0 -64
  97. package/dist/utils/click/isClickableInput.d.ts +0 -1
  98. package/dist/utils/click/isClickableInput.js +0 -14
  99. package/dist/utils/dataTransfer/Blob.d.ts +0 -1
  100. package/dist/utils/dataTransfer/Blob.js +0 -21
  101. package/dist/utils/dataTransfer/Clipboard.d.ts +0 -9
  102. package/dist/utils/dataTransfer/Clipboard.js +0 -188
  103. package/dist/utils/dataTransfer/DataTransfer.d.ts +0 -2
  104. package/dist/utils/dataTransfer/DataTransfer.js +0 -158
  105. package/dist/utils/dataTransfer/FileList.d.ts +0 -1
  106. package/dist/utils/dataTransfer/FileList.js +0 -23
  107. package/dist/utils/edit/buildTimeValue.d.ts +0 -1
  108. package/dist/utils/edit/buildTimeValue.js +0 -44
  109. package/dist/utils/edit/calculateNewValue.d.ts +0 -14
  110. package/dist/utils/edit/calculateNewValue.js +0 -46
  111. package/dist/utils/edit/editInputElement.d.ts +0 -16
  112. package/dist/utils/edit/editInputElement.js +0 -53
  113. package/dist/utils/edit/getValue.d.ts +0 -1
  114. package/dist/utils/edit/getValue.js +0 -23
  115. package/dist/utils/edit/isContentEditable.d.ts +0 -7
  116. package/dist/utils/edit/isContentEditable.js +0 -25
  117. package/dist/utils/edit/isEditable.d.ts +0 -25
  118. package/dist/utils/edit/isEditable.js +0 -42
  119. package/dist/utils/edit/isValidDateValue.d.ts +0 -3
  120. package/dist/utils/edit/isValidDateValue.js +0 -12
  121. package/dist/utils/edit/isValidInputTimeValue.d.ts +0 -3
  122. package/dist/utils/edit/isValidInputTimeValue.js +0 -12
  123. package/dist/utils/edit/maxLength.d.ts +0 -1
  124. package/dist/utils/edit/maxLength.js +0 -50
  125. package/dist/utils/edit/prepareInput.d.ts +0 -7
  126. package/dist/utils/edit/prepareInput.js +0 -77
  127. package/dist/utils/edit/setFiles.d.ts +0 -12
  128. package/dist/utils/edit/setFiles.js +0 -72
  129. package/dist/utils/focus/blur.d.ts +0 -2
  130. package/dist/utils/focus/blur.js +0 -19
  131. package/dist/utils/focus/copySelection.d.ts +0 -1
  132. package/dist/utils/focus/copySelection.js +0 -36
  133. package/dist/utils/focus/focus.d.ts +0 -2
  134. package/dist/utils/focus/focus.js +0 -22
  135. package/dist/utils/focus/getActiveElement.d.ts +0 -1
  136. package/dist/utils/focus/getActiveElement.js +0 -26
  137. package/dist/utils/focus/getTabDestination.d.ts +0 -1
  138. package/dist/utils/focus/getTabDestination.js +0 -84
  139. package/dist/utils/focus/isFocusable.d.ts +0 -1
  140. package/dist/utils/focus/isFocusable.js +0 -12
  141. package/dist/utils/focus/selectAll.d.ts +0 -5
  142. package/dist/utils/focus/selectAll.js +0 -51
  143. package/dist/utils/focus/selection.d.ts +0 -42
  144. package/dist/utils/focus/selection.js +0 -190
  145. package/dist/utils/focus/selector.d.ts +0 -1
  146. package/dist/utils/focus/selector.js +0 -8
  147. package/dist/utils/index.d.ts +0 -38
  148. package/dist/utils/index.js +0 -499
  149. package/dist/utils/keyDef/readNextDescriptor.d.ts +0 -19
  150. package/dist/utils/keyDef/readNextDescriptor.js +0 -102
  151. package/dist/utils/misc/eventWrapper.d.ts +0 -1
  152. package/dist/utils/misc/eventWrapper.js +0 -16
  153. package/dist/utils/misc/findClosest.d.ts +0 -1
  154. package/dist/utils/misc/findClosest.js +0 -20
  155. package/dist/utils/misc/getDocumentFromNode.d.ts +0 -1
  156. package/dist/utils/misc/getDocumentFromNode.js +0 -14
  157. package/dist/utils/misc/hasFormSubmit.d.ts +0 -1
  158. package/dist/utils/misc/hasFormSubmit.js +0 -10
  159. package/dist/utils/misc/hasPointerEvents.d.ts +0 -15
  160. package/dist/utils/misc/hasPointerEvents.js +0 -24
  161. package/dist/utils/misc/isDescendantOrSelf.d.ts +0 -1
  162. package/dist/utils/misc/isDescendantOrSelf.js +0 -20
  163. package/dist/utils/misc/isDisabled.d.ts +0 -1
  164. package/dist/utils/misc/isDisabled.js +0 -12
  165. package/dist/utils/misc/isElementType.d.ts +0 -5
  166. package/dist/utils/misc/isElementType.js +0 -24
  167. package/dist/utils/misc/isVisible.d.ts +0 -1
  168. package/dist/utils/misc/isVisible.js +0 -31
  169. package/dist/utils/misc/wait.d.ts +0 -1
  170. package/dist/utils/misc/wait.js +0 -10
  171. package/dist/utils/pointer/firePointerEvents.d.ts +0 -25
  172. package/dist/utils/pointer/firePointerEvents.js +0 -110
  173. package/dist/utils/pointer/mouseButtons.d.ts +0 -12
  174. package/dist/utils/pointer/mouseButtons.js +0 -45
package/dist/options.d.ts DELETED
@@ -1,102 +0,0 @@
1
- import type { keyboardKey } from './keyboard/types';
2
- import type { pointerKey } from './pointer/types';
3
- export interface Options {
4
- /**
5
- * When using `userEvent.upload`, automatically discard files
6
- * that don't match an `accept` property if it exists.
7
- *
8
- * @default true
9
- */
10
- applyAccept?: boolean;
11
- /**
12
- * We intend to automatically apply modifier keys for printable characters in the future.
13
- * I.e. `A` implying `{Shift>}a{/Shift}` if caps lock is not active.
14
- *
15
- * This options allows you to opt out of this change in foresight.
16
- * The feature therefore will not constitute a breaking change.
17
- *
18
- * @default true
19
- */
20
- autoModify?: boolean;
21
- /**
22
- * Between some subsequent inputs like typing a series of characters
23
- * the code execution is delayed per `setTimeout` for (at least) `delay` seconds.
24
- * This moves the next changes at least to next macro task
25
- * and allows other (asynchronous) code to run between events.
26
- *
27
- * `null` prevents `setTimeout` from being called.
28
- *
29
- * @default 0
30
- */
31
- delay?: number | null;
32
- /**
33
- * The document.
34
- *
35
- * This defaults to the owner document of an element if an API is called directly with an element and without setup.
36
- * Otherwise it falls back to the global document.
37
- *
38
- * @default element.ownerDocument??global.document
39
- */
40
- document?: Document;
41
- /**
42
- * An array of keyboard keys the keyboard device consists of.
43
- *
44
- * This allows to plug in different layouts / localizations.
45
- *
46
- * Defaults to a "standard" US-104-QWERTY keyboard.
47
- */
48
- keyboardMap?: keyboardKey[];
49
- /**
50
- * An array of available pointer keys.
51
- *
52
- * This allows to plug in different pointer devices.
53
- */
54
- pointerMap?: pointerKey[];
55
- /**
56
- * `userEvent.type` automatically releases any keys still pressed at the end of the call.
57
- * This option allows to opt out of this feature.
58
- *
59
- * @default false
60
- */
61
- skipAutoClose?: boolean;
62
- /**
63
- * `userEvent.type` implys a click at the end of the element content/value.
64
- * This option allows to opt out of this feature.
65
- *
66
- * @default false
67
- */
68
- skipClick?: boolean;
69
- /**
70
- * `userEvent.click` implys moving the cursor to the target element first.
71
- * This options allows to opt out of this feature.
72
- *
73
- * @default false
74
- */
75
- skipHover?: boolean;
76
- /**
77
- * Calling pointer related APIs on an element triggers a check if that element can receive pointer events.
78
- * This check is known to be expensive.
79
- * This option allows to skip the check.
80
- *
81
- * @default false
82
- */
83
- skipPointerEventsCheck?: boolean;
84
- /**
85
- * Write selected data to Clipboard API when a `cut` or `copy` is triggered.
86
- *
87
- * The Clipboard API is usually not available to test code.
88
- * Our `setup` replaces the `navigator.clipboard` property with a stub.
89
- *
90
- * Defaults to `false` when calling the APIs directly.
91
- * Defaults to `true` when calling the APIs per `setup`.
92
- */
93
- writeToClipboard?: boolean;
94
- }
95
- /**
96
- * Default options applied when API is called per `userEvent.anyApi()`
97
- */
98
- export declare const defaultOptionsDirect: Required<Options>;
99
- /**
100
- * Default options applied when API is called per `userEvent().anyApi()`
101
- */
102
- export declare const defaultOptionsSetup: Required<Options>;
package/dist/options.js DELETED
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.defaultOptionsSetup = exports.defaultOptionsDirect = void 0;
7
-
8
- var _keyMap = require("./keyboard/keyMap");
9
-
10
- var _keyMap2 = require("./pointer/keyMap");
11
-
12
- /**
13
- * Default options applied when API is called per `userEvent.anyApi()`
14
- */
15
- const defaultOptionsDirect = {
16
- applyAccept: true,
17
- autoModify: true,
18
- delay: 0,
19
- document: global.document,
20
- keyboardMap: _keyMap.defaultKeyMap,
21
- pointerMap: _keyMap2.defaultKeyMap,
22
- skipAutoClose: false,
23
- skipClick: false,
24
- skipHover: false,
25
- skipPointerEventsCheck: false,
26
- writeToClipboard: false
27
- };
28
- /**
29
- * Default options applied when API is called per `userEvent().anyApi()`
30
- */
31
-
32
- exports.defaultOptionsDirect = defaultOptionsDirect;
33
- const defaultOptionsSetup = { ...defaultOptionsDirect,
34
- writeToClipboard: true
35
- };
36
- exports.defaultOptionsSetup = defaultOptionsSetup;
@@ -1,10 +0,0 @@
1
- import { UserEvent } from '../setup';
2
- import { PointerAction, PointerActionTarget } from './pointerAction';
3
- import type { pointerState, pointerKey } from './types';
4
- export type { pointerState, pointerKey };
5
- declare type PointerActionInput = string | ({
6
- keys: string;
7
- } & PointerActionTarget) | PointerAction;
8
- export declare type PointerInput = PointerActionInput | Array<PointerActionInput>;
9
- export declare function pointer(this: UserEvent, input: PointerInput): Promise<void>;
10
- export declare function createPointerState(document: Document): pointerState;
@@ -1,56 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createPointerState = createPointerState;
7
- exports.pointer = pointer;
8
-
9
- var _setup = require("../setup");
10
-
11
- var _parseKeyDef = require("./parseKeyDef");
12
-
13
- var _pointerAction = require("./pointerAction");
14
-
15
- async function pointer(input) {
16
- const {
17
- pointerMap
18
- } = this[_setup.Config];
19
- const actions = [];
20
- (Array.isArray(input) ? input : [input]).forEach(actionInput => {
21
- if (typeof actionInput === 'string') {
22
- actions.push(...(0, _parseKeyDef.parseKeyDef)(pointerMap, actionInput));
23
- } else if ('keys' in actionInput) {
24
- actions.push(...(0, _parseKeyDef.parseKeyDef)(pointerMap, actionInput.keys).map(i => ({ ...actionInput,
25
- ...i
26
- })));
27
- } else {
28
- actions.push(actionInput);
29
- }
30
- });
31
- return (0, _pointerAction.pointerAction)(this[_setup.Config], actions).then(() => undefined);
32
- }
33
-
34
- function createPointerState(document) {
35
- return {
36
- pointerId: 1,
37
- position: {
38
- mouse: {
39
- pointerType: 'mouse',
40
- pointerId: 1,
41
- target: document.body,
42
- coords: {
43
- clientX: 0,
44
- clientY: 0,
45
- offsetX: 0,
46
- offsetY: 0,
47
- pageX: 0,
48
- pageY: 0,
49
- x: 0,
50
- y: 0
51
- }
52
- }
53
- },
54
- pressed: []
55
- };
56
- }
@@ -1,2 +0,0 @@
1
- import { pointerKey } from './types';
2
- export declare const defaultKeyMap: pointerKey[];
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.defaultKeyMap = void 0;
7
- const defaultKeyMap = [{
8
- name: 'MouseLeft',
9
- pointerType: 'mouse',
10
- button: 'primary'
11
- }, {
12
- name: 'MouseRight',
13
- pointerType: 'mouse',
14
- button: 'secondary'
15
- }, {
16
- name: 'MouseMiddle',
17
- pointerType: 'mouse',
18
- button: 'auxiliary'
19
- }, {
20
- name: 'TouchA',
21
- pointerType: 'touch'
22
- }, {
23
- name: 'TouchB',
24
- pointerType: 'touch'
25
- }, {
26
- name: 'TouchC',
27
- pointerType: 'touch'
28
- }];
29
- exports.defaultKeyMap = defaultKeyMap;
@@ -1,6 +0,0 @@
1
- import { pointerKey } from './types';
2
- export declare function parseKeyDef(pointerMap: pointerKey[], keys: string): {
3
- keyDef: pointerKey;
4
- releasePrevious: boolean;
5
- releaseSelf: boolean;
6
- }[];
@@ -1,34 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.parseKeyDef = parseKeyDef;
7
-
8
- var _utils = require("../utils");
9
-
10
- function parseKeyDef(pointerMap, keys) {
11
- const defs = [];
12
-
13
- do {
14
- const {
15
- descriptor,
16
- consumedLength,
17
- releasePrevious,
18
- releaseSelf = true
19
- } = (0, _utils.readNextDescriptor)(keys);
20
- const keyDef = pointerMap.find(p => p.name === descriptor);
21
-
22
- if (keyDef) {
23
- defs.push({
24
- keyDef,
25
- releasePrevious,
26
- releaseSelf
27
- });
28
- }
29
-
30
- keys = keys.slice(consumedLength);
31
- } while (keys);
32
-
33
- return defs;
34
- }
@@ -1,7 +0,0 @@
1
- import { Config } from '../setup';
2
- import { PointerMoveAction } from './pointerMove';
3
- import { PointerPressAction } from './pointerPress';
4
- import { PointerTarget, SelectionTarget } from './types';
5
- export declare type PointerActionTarget = Partial<PointerTarget> & Partial<SelectionTarget>;
6
- export declare type PointerAction = PointerActionTarget & (Omit<PointerPressAction, 'target' | 'coords'> | Omit<PointerMoveAction, 'target' | 'coords'>);
7
- export declare function pointerAction(config: Config, actions: PointerAction[]): Promise<void>;
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.pointerAction = pointerAction;
7
-
8
- var _utils = require("../utils");
9
-
10
- var _pointerMove = require("./pointerMove");
11
-
12
- var _pointerPress = require("./pointerPress");
13
-
14
- async function pointerAction(config, actions) {
15
- for (let i = 0; i < actions.length; i++) {
16
- var _action$target, _action$coords;
17
-
18
- const action = actions[i];
19
- const pointerName = 'pointerName' in action && action.pointerName ? action.pointerName : 'keyDef' in action ? action.keyDef.pointerType === 'touch' ? action.keyDef.name : action.keyDef.pointerType : 'mouse';
20
- const target = (_action$target = action.target) != null ? _action$target : getPrevTarget(pointerName, config.pointerState);
21
- const coords = (_action$coords = action.coords) != null ? _action$coords : pointerName in config.pointerState.position ? config.pointerState.position[pointerName].coords : undefined;
22
- await ('keyDef' in action ? (0, _pointerPress.pointerPress)({ ...action,
23
- target,
24
- coords
25
- }, config) : (0, _pointerMove.pointerMove)({ ...action,
26
- target,
27
- coords
28
- }, config));
29
-
30
- if (typeof config.delay === 'number') {
31
- if (i < actions.length - 1) {
32
- await (0, _utils.wait)(config.delay);
33
- }
34
- }
35
- }
36
-
37
- delete config.pointerState.activeClickCount;
38
- }
39
-
40
- function getPrevTarget(pointerName, state) {
41
- if (!(pointerName in state.position) || !state.position[pointerName].target) {
42
- throw new Error('This pointer has no previous position. Provide a target property!');
43
- }
44
-
45
- return state.position[pointerName].target;
46
- }
@@ -1,6 +0,0 @@
1
- import { inputDeviceState } from '../setup';
2
- import { PointerTarget, SelectionTarget } from './types';
3
- export interface PointerMoveAction extends PointerTarget, SelectionTarget {
4
- pointerName?: string;
5
- }
6
- export declare function pointerMove({ pointerName, target, coords, node, offset }: PointerMoveAction, { pointerState, keyboardState }: inputDeviceState): Promise<void>;
@@ -1,136 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.pointerMove = pointerMove;
7
-
8
- var _document = require("../document");
9
-
10
- var _utils = require("../utils");
11
-
12
- var _resolveSelectionTarget = require("./resolveSelectionTarget");
13
-
14
- async function pointerMove({
15
- pointerName = 'mouse',
16
- target,
17
- coords,
18
- node,
19
- offset
20
- }, {
21
- pointerState,
22
- keyboardState
23
- }) {
24
- if (!(pointerName in pointerState.position)) {
25
- throw new Error(`Trying to move pointer "${pointerName}" which does not exist.`);
26
- }
27
-
28
- const {
29
- pointerId,
30
- pointerType,
31
- target: prevTarget,
32
- coords: prevCoords,
33
- selectionRange
34
- } = pointerState.position[pointerName];
35
-
36
- if (prevTarget && prevTarget !== target) {
37
- // Here we could probably calculate a few coords to a fake boundary(?)
38
- fireMove(prevTarget, prevCoords);
39
-
40
- if (!(0, _utils.isDescendantOrSelf)(target, prevTarget)) {
41
- fireLeave(prevTarget, prevCoords);
42
- }
43
- }
44
-
45
- pointerState.position[pointerName] = { ...pointerState.position[pointerName],
46
- target,
47
- coords
48
- };
49
-
50
- if (prevTarget !== target) {
51
- if (!prevTarget || !(0, _utils.isDescendantOrSelf)(prevTarget, target)) {
52
- fireEnter(target, coords);
53
- }
54
- } // TODO: drag if the target didn't change?
55
- // Here we could probably calculate a few coords leading up to the final position
56
-
57
-
58
- fireMove(target, coords);
59
-
60
- if (selectionRange) {
61
- // TODO: support extending range (shift)
62
- const selectionFocus = (0, _resolveSelectionTarget.resolveSelectionTarget)({
63
- target,
64
- node,
65
- offset
66
- });
67
-
68
- if ('node' in selectionRange) {
69
- // When the mouse is dragged outside of an input/textarea,
70
- // the selection is extended to the beginning or end of the input
71
- // depending on pointer position.
72
- // TODO: extend selection according to pointer position
73
-
74
- /* istanbul ignore else */
75
- if (selectionFocus.node === selectionRange.node) {
76
- const anchorOffset = selectionFocus.offset < selectionRange.start ? selectionRange.end : selectionRange.start;
77
- const focusOffset = selectionFocus.offset > selectionRange.end || selectionFocus.offset < selectionRange.start ? selectionFocus.offset : selectionRange.end;
78
- (0, _document.setUISelection)(selectionRange.node, {
79
- anchorOffset,
80
- focusOffset
81
- });
82
- }
83
- } else {
84
- const range = selectionRange.cloneRange();
85
- const cmp = range.comparePoint(selectionFocus.node, selectionFocus.offset);
86
-
87
- if (cmp < 0) {
88
- range.setStart(selectionFocus.node, selectionFocus.offset);
89
- } else if (cmp > 0) {
90
- range.setEnd(selectionFocus.node, selectionFocus.offset);
91
- }
92
-
93
- const selection = target.ownerDocument.getSelection();
94
- selection.removeAllRanges();
95
- selection.addRange(range.cloneRange());
96
- }
97
- }
98
-
99
- function fireMove(eventTarget, eventCoords) {
100
- fire(eventTarget, 'pointermove', eventCoords);
101
-
102
- if (pointerType === 'mouse' && !(0, _utils.isDisabled)(eventTarget)) {
103
- fire(eventTarget, 'mousemove', eventCoords);
104
- }
105
- }
106
-
107
- function fireLeave(eventTarget, eventCoords) {
108
- fire(eventTarget, 'pointerout', eventCoords);
109
- fire(eventTarget, 'pointerleave', eventCoords);
110
-
111
- if (pointerType === 'mouse' && !(0, _utils.isDisabled)(eventTarget)) {
112
- fire(eventTarget, 'mouseout', eventCoords);
113
- fire(eventTarget, 'mouseleave', eventCoords);
114
- }
115
- }
116
-
117
- function fireEnter(eventTarget, eventCoords) {
118
- fire(eventTarget, 'pointerover', eventCoords);
119
- fire(eventTarget, 'pointerenter', eventCoords);
120
-
121
- if (pointerType === 'mouse' && !(0, _utils.isDisabled)(eventTarget)) {
122
- fire(eventTarget, 'mouseover', eventCoords);
123
- fire(eventTarget, 'mouseenter', eventCoords);
124
- }
125
- }
126
-
127
- function fire(eventTarget, type, eventCoords) {
128
- return (0, _utils.firePointerEvent)(eventTarget, type, {
129
- pointerState,
130
- keyboardState,
131
- coords: eventCoords,
132
- pointerId,
133
- pointerType
134
- });
135
- }
136
- }
@@ -1,8 +0,0 @@
1
- import { inputDeviceState } from '../setup';
2
- import type { pointerKey, PointerTarget, SelectionTarget } from './types';
3
- export interface PointerPressAction extends PointerTarget, SelectionTarget {
4
- keyDef: pointerKey;
5
- releasePrevious: boolean;
6
- releaseSelf: boolean;
7
- }
8
- export declare function pointerPress(action: PointerPressAction, state: inputDeviceState): Promise<void>;