@testing-library/user-event 14.0.0-beta.2 → 14.0.0-beta.6
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.
- package/dist/index.cjs +2896 -0
- package/dist/index.mjs +2967 -0
- package/dist/{clipboard → types/clipboard}/copy.d.ts +0 -0
- package/dist/{clipboard → types/clipboard}/cut.d.ts +0 -0
- package/dist/{clipboard → types/clipboard}/index.d.ts +0 -0
- package/dist/{clipboard → types/clipboard}/paste.d.ts +0 -0
- package/dist/{convenience → types/convenience}/click.d.ts +0 -0
- package/dist/{convenience → types/convenience}/hover.d.ts +0 -0
- package/dist/{convenience → types/convenience}/index.d.ts +0 -0
- package/dist/{convenience → types/convenience}/tab.d.ts +0 -0
- package/dist/{document → types/document}/index.d.ts +0 -0
- package/dist/{document → types/document}/interceptor.d.ts +0 -0
- package/dist/{document → types/document}/selection.d.ts +0 -0
- package/dist/{document → types/document}/value.d.ts +0 -0
- package/dist/{index.d.ts → types/index.d.ts} +0 -0
- package/dist/{keyboard → types/keyboard}/index.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/keyMap.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/keyboardAction.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/parseKeyDef.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/plugins/arrow.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/plugins/character.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/plugins/combination.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/plugins/control.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/plugins/functional.d.ts +0 -3
- package/dist/{keyboard → types/keyboard}/plugins/index.d.ts +0 -0
- package/dist/types/keyboard/plugins/modifiers.d.ts +8 -0
- package/dist/{keyboard → types/keyboard}/shared/fireChangeForInputTimeIfValid.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/shared/index.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/types.d.ts +19 -5
- package/dist/{options.d.ts → types/options.d.ts} +0 -0
- package/dist/{pointer → types/pointer}/index.d.ts +0 -0
- package/dist/{pointer → types/pointer}/keyMap.d.ts +0 -0
- package/dist/{pointer → types/pointer}/parseKeyDef.d.ts +0 -0
- package/dist/{pointer → types/pointer}/pointerAction.d.ts +0 -0
- package/dist/{pointer → types/pointer}/pointerMove.d.ts +0 -0
- package/dist/{pointer → types/pointer}/pointerPress.d.ts +0 -0
- package/dist/{pointer → types/pointer}/resolveSelectionTarget.d.ts +0 -0
- package/dist/{pointer → types/pointer}/types.d.ts +0 -0
- package/dist/{setup → types/setup}/api.d.ts +0 -0
- package/dist/{setup → types/setup}/config.d.ts +0 -0
- package/dist/{setup → types/setup}/directApi.d.ts +0 -0
- package/dist/{setup → types/setup}/index.d.ts +0 -0
- package/dist/{setup → types/setup}/setup.d.ts +0 -0
- package/dist/{setup → types/setup}/wrapAsync.d.ts +0 -0
- package/dist/{utility → types/utility}/clear.d.ts +0 -0
- package/dist/{utility → types/utility}/index.d.ts +0 -0
- package/dist/{utility → types/utility}/selectOptions.d.ts +0 -0
- package/dist/{utility → types/utility}/type.d.ts +0 -0
- package/dist/{utility → types/utility}/upload.d.ts +0 -0
- package/dist/{utils → types/utils}/click/isClickableInput.d.ts +0 -0
- package/dist/{utils → types/utils}/dataTransfer/Blob.d.ts +0 -0
- package/dist/{utils → types/utils}/dataTransfer/Clipboard.d.ts +0 -0
- package/dist/{utils → types/utils}/dataTransfer/DataTransfer.d.ts +0 -0
- package/dist/{utils → types/utils}/dataTransfer/FileList.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/buildTimeValue.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/calculateNewValue.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/editInputElement.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/getValue.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/isContentEditable.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/isEditable.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/isValidDateValue.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/isValidInputTimeValue.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/maxLength.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/prepareInput.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/setFiles.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/blur.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/copySelection.d.ts +0 -0
- package/dist/types/utils/focus/cursor.d.ts +9 -0
- package/dist/{utils → types/utils}/focus/focus.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/getActiveElement.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/getTabDestination.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/isFocusable.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/selectAll.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/selection.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/selector.d.ts +0 -0
- package/dist/{utils → types/utils}/index.d.ts +3 -0
- package/dist/{utils → types/utils}/keyDef/readNextDescriptor.d.ts +0 -0
- package/dist/types/utils/keyboard/getKeyEventProps.d.ts +17 -0
- package/dist/types/utils/keyboard/getUIEventModifiers.d.ts +15 -0
- package/dist/{utils → types/utils}/misc/eventWrapper.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/findClosest.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/getDocumentFromNode.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/hasFormSubmit.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/hasPointerEvents.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/isDescendantOrSelf.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/isDisabled.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/isElementType.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/isVisible.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/wait.d.ts +0 -0
- package/dist/{utils → types/utils}/pointer/firePointerEvents.d.ts +0 -0
- package/dist/{utils → types/utils}/pointer/mouseButtons.d.ts +0 -0
- package/package.json +13 -30
- package/dist/clipboard/copy.js +0 -36
- package/dist/clipboard/cut.js +0 -42
- package/dist/clipboard/index.js +0 -44
- package/dist/clipboard/paste.js +0 -47
- package/dist/convenience/click.js +0 -52
- package/dist/convenience/hover.js +0 -31
- package/dist/convenience/index.js +0 -44
- package/dist/convenience/tab.js +0 -12
- package/dist/document/index.js +0 -100
- package/dist/document/interceptor.js +0 -37
- package/dist/document/selection.js +0 -90
- package/dist/document/value.js +0 -77
- package/dist/index.js +0 -13
- package/dist/keyboard/getEventProps.d.ts +0 -15
- package/dist/keyboard/getEventProps.js +0 -27
- package/dist/keyboard/index.js +0 -42
- package/dist/keyboard/keyMap.js +0 -119
- package/dist/keyboard/keyboardAction.js +0 -156
- package/dist/keyboard/parseKeyDef.js +0 -61
- package/dist/keyboard/plugins/arrow.js +0 -28
- package/dist/keyboard/plugins/character.js +0 -173
- package/dist/keyboard/plugins/combination.js +0 -19
- package/dist/keyboard/plugins/control.js +0 -52
- package/dist/keyboard/plugins/functional.js +0 -158
- package/dist/keyboard/plugins/index.js +0 -33
- package/dist/keyboard/shared/fireChangeForInputTimeIfValid.js +0 -20
- package/dist/keyboard/shared/index.js +0 -18
- package/dist/keyboard/types.js +0 -19
- package/dist/options.js +0 -36
- package/dist/pointer/index.js +0 -56
- package/dist/pointer/keyMap.js +0 -29
- package/dist/pointer/parseKeyDef.js +0 -34
- package/dist/pointer/pointerAction.js +0 -46
- package/dist/pointer/pointerMove.js +0 -136
- package/dist/pointer/pointerPress.js +0 -330
- package/dist/pointer/resolveSelectionTarget.js +0 -75
- package/dist/pointer/types.js +0 -1
- package/dist/setup/api.js +0 -111
- package/dist/setup/config.js +0 -8
- package/dist/setup/directApi.js +0 -95
- package/dist/setup/index.js +0 -27
- package/dist/setup/setup.js +0 -98
- package/dist/setup/wrapAsync.js +0 -15
- package/dist/utility/clear.js +0 -30
- package/dist/utility/index.js +0 -57
- package/dist/utility/selectOptions.js +0 -132
- package/dist/utility/type.js +0 -37
- package/dist/utility/upload.js +0 -64
- package/dist/utils/click/isClickableInput.js +0 -14
- package/dist/utils/dataTransfer/Blob.js +0 -21
- package/dist/utils/dataTransfer/Clipboard.js +0 -188
- package/dist/utils/dataTransfer/DataTransfer.js +0 -158
- package/dist/utils/dataTransfer/FileList.js +0 -23
- package/dist/utils/edit/buildTimeValue.js +0 -44
- package/dist/utils/edit/calculateNewValue.js +0 -46
- package/dist/utils/edit/editInputElement.js +0 -53
- package/dist/utils/edit/getValue.js +0 -23
- package/dist/utils/edit/isContentEditable.js +0 -25
- package/dist/utils/edit/isEditable.js +0 -42
- package/dist/utils/edit/isValidDateValue.js +0 -12
- package/dist/utils/edit/isValidInputTimeValue.js +0 -12
- package/dist/utils/edit/maxLength.js +0 -50
- package/dist/utils/edit/prepareInput.js +0 -77
- package/dist/utils/edit/setFiles.js +0 -72
- package/dist/utils/focus/blur.js +0 -19
- package/dist/utils/focus/copySelection.js +0 -36
- package/dist/utils/focus/focus.js +0 -22
- package/dist/utils/focus/getActiveElement.js +0 -26
- package/dist/utils/focus/getTabDestination.js +0 -71
- package/dist/utils/focus/isFocusable.js +0 -12
- package/dist/utils/focus/selectAll.js +0 -51
- package/dist/utils/focus/selection.js +0 -190
- package/dist/utils/focus/selector.js +0 -8
- package/dist/utils/index.js +0 -499
- package/dist/utils/keyDef/readNextDescriptor.js +0 -102
- package/dist/utils/misc/eventWrapper.js +0 -16
- package/dist/utils/misc/findClosest.js +0 -20
- package/dist/utils/misc/getDocumentFromNode.js +0 -14
- package/dist/utils/misc/hasFormSubmit.js +0 -10
- package/dist/utils/misc/hasPointerEvents.js +0 -24
- package/dist/utils/misc/isDescendantOrSelf.js +0 -20
- package/dist/utils/misc/isDisabled.js +0 -12
- package/dist/utils/misc/isElementType.js +0 -24
- package/dist/utils/misc/isVisible.js +0 -31
- package/dist/utils/misc/wait.js +0 -10
- package/dist/utils/pointer/firePointerEvents.js +0 -112
- package/dist/utils/pointer/mouseButtons.js +0 -45
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.fireChangeForInputTimeIfValid = fireChangeForInputTimeIfValid;
|
|
7
|
-
|
|
8
|
-
var _dom = require("@testing-library/dom");
|
|
9
|
-
|
|
10
|
-
var _utils = require("../../utils");
|
|
11
|
-
|
|
12
|
-
function fireChangeForInputTimeIfValid(el, prevValue, timeNewEntry) {
|
|
13
|
-
if ((0, _utils.isValidInputTimeValue)(el, timeNewEntry) && prevValue !== timeNewEntry) {
|
|
14
|
-
_dom.fireEvent.change(el, {
|
|
15
|
-
target: {
|
|
16
|
-
value: timeNewEntry
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _fireChangeForInputTimeIfValid = require("./fireChangeForInputTimeIfValid");
|
|
8
|
-
|
|
9
|
-
Object.keys(_fireChangeForInputTimeIfValid).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _fireChangeForInputTimeIfValid[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _fireChangeForInputTimeIfValid[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
package/dist/keyboard/types.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.DOM_KEY_LOCATION = void 0;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @internal Do not create/alter this by yourself as this type might be subject to changes.
|
|
10
|
-
*/
|
|
11
|
-
let DOM_KEY_LOCATION;
|
|
12
|
-
exports.DOM_KEY_LOCATION = DOM_KEY_LOCATION;
|
|
13
|
-
|
|
14
|
-
(function (DOM_KEY_LOCATION) {
|
|
15
|
-
DOM_KEY_LOCATION[DOM_KEY_LOCATION["STANDARD"] = 0] = "STANDARD";
|
|
16
|
-
DOM_KEY_LOCATION[DOM_KEY_LOCATION["LEFT"] = 1] = "LEFT";
|
|
17
|
-
DOM_KEY_LOCATION[DOM_KEY_LOCATION["RIGHT"] = 2] = "RIGHT";
|
|
18
|
-
DOM_KEY_LOCATION[DOM_KEY_LOCATION["NUMPAD"] = 3] = "NUMPAD";
|
|
19
|
-
})(DOM_KEY_LOCATION || (exports.DOM_KEY_LOCATION = DOM_KEY_LOCATION = {}));
|
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;
|
package/dist/pointer/index.js
DELETED
|
@@ -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
|
-
}
|
package/dist/pointer/keyMap.js
DELETED
|
@@ -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,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,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,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
|
-
}
|