@testing-library/user-event 14.0.0-beta.3 → 14.0.0-beta.7
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 +2941 -0
- package/dist/index.mjs +3012 -0
- package/dist/types/clipboard/copy.d.ts +2 -0
- package/dist/types/clipboard/cut.d.ts +2 -0
- package/dist/{clipboard → types/clipboard}/index.d.ts +0 -0
- package/dist/types/clipboard/paste.d.ts +2 -0
- package/dist/types/convenience/click.d.ts +4 -0
- package/dist/types/convenience/hover.d.ts +3 -0
- package/dist/{convenience → types/convenience}/index.d.ts +0 -0
- package/dist/types/convenience/tab.d.ts +4 -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} +1 -0
- package/dist/{keyboard → types/keyboard}/index.d.ts +2 -2
- 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} +23 -8
- package/dist/{pointer → types/pointer}/index.d.ts +2 -2
- 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/types/pointer/pointerMove.d.ts +6 -0
- package/dist/{pointer → types/pointer}/pointerPress.d.ts +2 -2
- 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 +1 -2
- package/dist/{setup → types/setup}/index.d.ts +6 -2
- package/dist/types/setup/setup.d.ts +19 -0
- package/dist/{setup → types/setup}/wrapAsync.d.ts +0 -0
- package/dist/types/utility/clear.d.ts +2 -0
- package/dist/{utility → types/utility}/index.d.ts +0 -0
- package/dist/types/utility/selectOptions.d.ts +3 -0
- package/dist/types/utility/type.d.ts +9 -0
- package/dist/types/utility/upload.d.ts +5 -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 +5 -1
- 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/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/types/utils/misc/level.d.ts +17 -0
- package/dist/{utils → types/utils}/misc/wait.d.ts +0 -0
- package/dist/types/utils/pointer/cssPointerEvents.d.ts +15 -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.d.ts +0 -2
- package/dist/clipboard/copy.js +0 -36
- package/dist/clipboard/cut.d.ts +0 -2
- package/dist/clipboard/cut.js +0 -42
- package/dist/clipboard/index.js +0 -44
- package/dist/clipboard/paste.d.ts +0 -2
- package/dist/clipboard/paste.js +0 -47
- package/dist/convenience/click.d.ts +0 -4
- package/dist/convenience/click.js +0 -52
- package/dist/convenience/hover.d.ts +0 -3
- package/dist/convenience/hover.js +0 -31
- package/dist/convenience/index.js +0 -44
- package/dist/convenience/tab.d.ts +0 -4
- 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.d.ts +0 -6
- package/dist/pointer/pointerMove.js +0 -136
- package/dist/pointer/pointerPress.js +0 -327
- 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.d.ts +0 -74
- package/dist/setup/setup.js +0 -98
- package/dist/setup/wrapAsync.js +0 -15
- package/dist/utility/clear.d.ts +0 -2
- package/dist/utility/clear.js +0 -30
- package/dist/utility/index.js +0 -57
- package/dist/utility/selectOptions.d.ts +0 -3
- package/dist/utility/selectOptions.js +0 -132
- package/dist/utility/type.d.ts +0 -9
- package/dist/utility/type.js +0 -37
- package/dist/utility/upload.d.ts +0 -5
- 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 -84
- 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.d.ts +0 -15
- 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 -110
- package/dist/utils/pointer/mouseButtons.js +0 -45
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.preKeyupBehavior = exports.preKeydownBehavior = exports.postKeyupBehavior = exports.keyupBehavior = exports.keypressBehavior = exports.keydownBehavior = void 0;
|
|
7
|
-
|
|
8
|
-
var _dom = require("@testing-library/dom");
|
|
9
|
-
|
|
10
|
-
var _document = require("../../document");
|
|
11
|
-
|
|
12
|
-
var _utils = require("../../utils");
|
|
13
|
-
|
|
14
|
-
var _getEventProps = require("../getEventProps");
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* This file should contain behavior for functional keys as described here:
|
|
18
|
-
* https://w3c.github.io/uievents-code/#key-alphanumeric-functional
|
|
19
|
-
*/
|
|
20
|
-
const modifierKeys = {
|
|
21
|
-
Alt: 'alt',
|
|
22
|
-
Control: 'ctrl',
|
|
23
|
-
Shift: 'shift',
|
|
24
|
-
Meta: 'meta'
|
|
25
|
-
};
|
|
26
|
-
const preKeydownBehavior = [// modifierKeys switch on the modifier BEFORE the keydown event
|
|
27
|
-
...Object.entries(modifierKeys).map(([key, modKey]) => ({
|
|
28
|
-
matches: keyDef => keyDef.key === key,
|
|
29
|
-
handle: (keyDef, element, {
|
|
30
|
-
keyboardState
|
|
31
|
-
}) => {
|
|
32
|
-
keyboardState.modifiers[modKey] = true;
|
|
33
|
-
}
|
|
34
|
-
})), // AltGraph produces an extra keydown for Control
|
|
35
|
-
// The modifier does not change
|
|
36
|
-
{
|
|
37
|
-
matches: keyDef => keyDef.key === 'AltGraph',
|
|
38
|
-
handle: (keyDef, element, {
|
|
39
|
-
keyboardMap,
|
|
40
|
-
keyboardState
|
|
41
|
-
}) => {
|
|
42
|
-
var _keyboardMap$find;
|
|
43
|
-
|
|
44
|
-
const ctrlKeyDef = (_keyboardMap$find = keyboardMap.find(k => k.key === 'Control')) != null ? _keyboardMap$find :
|
|
45
|
-
/* istanbul ignore next */
|
|
46
|
-
{
|
|
47
|
-
key: 'Control',
|
|
48
|
-
code: 'Control'
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
_dom.fireEvent.keyDown(element, (0, _getEventProps.getKeyEventProps)(ctrlKeyDef, keyboardState));
|
|
52
|
-
}
|
|
53
|
-
}];
|
|
54
|
-
exports.preKeydownBehavior = preKeydownBehavior;
|
|
55
|
-
const keydownBehavior = [{
|
|
56
|
-
matches: keyDef => keyDef.key === 'CapsLock',
|
|
57
|
-
handle: (keyDef, element, {
|
|
58
|
-
keyboardState
|
|
59
|
-
}) => {
|
|
60
|
-
keyboardState.modifiers.caps = !keyboardState.modifiers.caps;
|
|
61
|
-
}
|
|
62
|
-
}, {
|
|
63
|
-
matches: (keyDef, element) => keyDef.key === 'Backspace' && (0, _utils.isEditable)(element),
|
|
64
|
-
handle: (keyDef, element) => {
|
|
65
|
-
var _prepareInput;
|
|
66
|
-
|
|
67
|
-
(_prepareInput = (0, _utils.prepareInput)('', element, 'deleteContentBackward')) == null ? void 0 : _prepareInput.commit();
|
|
68
|
-
}
|
|
69
|
-
}, {
|
|
70
|
-
matches: keyDef => keyDef.key === 'Tab',
|
|
71
|
-
handle: (keyDef, element, {
|
|
72
|
-
keyboardState
|
|
73
|
-
}) => {
|
|
74
|
-
const dest = (0, _utils.getTabDestination)(element, keyboardState.modifiers.shift);
|
|
75
|
-
|
|
76
|
-
if (dest === element.ownerDocument.body) {
|
|
77
|
-
(0, _utils.blur)(element);
|
|
78
|
-
} else {
|
|
79
|
-
(0, _utils.focus)(dest);
|
|
80
|
-
|
|
81
|
-
if ((0, _utils.isElementType)(dest, ['input', 'textarea'])) {
|
|
82
|
-
(0, _document.setUISelection)(dest, {
|
|
83
|
-
anchorOffset: 0,
|
|
84
|
-
focusOffset: dest.value.length
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}];
|
|
90
|
-
exports.keydownBehavior = keydownBehavior;
|
|
91
|
-
const keypressBehavior = [{
|
|
92
|
-
matches: (keyDef, element) => keyDef.key === 'Enter' && (0, _utils.isElementType)(element, 'input') && ['checkbox', 'radio'].includes(element.type),
|
|
93
|
-
handle: (keyDef, element) => {
|
|
94
|
-
const form = element.form;
|
|
95
|
-
|
|
96
|
-
if ((0, _utils.hasFormSubmit)(form)) {
|
|
97
|
-
_dom.fireEvent.submit(form);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}, {
|
|
101
|
-
matches: (keyDef, element) => keyDef.key === 'Enter' && ((0, _utils.isClickableInput)(element) || // Links with href defined should handle Enter the same as a click
|
|
102
|
-
(0, _utils.isElementType)(element, 'a') && Boolean(element.href)),
|
|
103
|
-
handle: (keyDef, element, {
|
|
104
|
-
keyboardState
|
|
105
|
-
}) => {
|
|
106
|
-
_dom.fireEvent.click(element, (0, _getEventProps.getMouseEventProps)(keyboardState));
|
|
107
|
-
}
|
|
108
|
-
}, {
|
|
109
|
-
matches: (keyDef, element) => keyDef.key === 'Enter' && (0, _utils.isElementType)(element, 'input'),
|
|
110
|
-
handle: (keyDef, element) => {
|
|
111
|
-
const form = element.form;
|
|
112
|
-
|
|
113
|
-
if (form && (form.querySelectorAll('input').length === 1 || (0, _utils.hasFormSubmit)(form))) {
|
|
114
|
-
_dom.fireEvent.submit(form);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}];
|
|
118
|
-
exports.keypressBehavior = keypressBehavior;
|
|
119
|
-
const preKeyupBehavior = [// modifierKeys switch off the modifier BEFORE the keyup event
|
|
120
|
-
...Object.entries(modifierKeys).map(([key, modKey]) => ({
|
|
121
|
-
matches: keyDef => keyDef.key === key,
|
|
122
|
-
handle: (keyDef, element, {
|
|
123
|
-
keyboardState
|
|
124
|
-
}) => {
|
|
125
|
-
keyboardState.modifiers[modKey] = false;
|
|
126
|
-
}
|
|
127
|
-
}))];
|
|
128
|
-
exports.preKeyupBehavior = preKeyupBehavior;
|
|
129
|
-
const keyupBehavior = [{
|
|
130
|
-
matches: (keyDef, element) => keyDef.key === ' ' && (0, _utils.isClickableInput)(element),
|
|
131
|
-
handle: (keyDef, element, {
|
|
132
|
-
keyboardState
|
|
133
|
-
}) => {
|
|
134
|
-
_dom.fireEvent.click(element, (0, _getEventProps.getMouseEventProps)(keyboardState));
|
|
135
|
-
}
|
|
136
|
-
}];
|
|
137
|
-
exports.keyupBehavior = keyupBehavior;
|
|
138
|
-
const postKeyupBehavior = [// AltGraph produces an extra keyup for Control
|
|
139
|
-
// The modifier does not change
|
|
140
|
-
{
|
|
141
|
-
matches: keyDef => keyDef.key === 'AltGraph',
|
|
142
|
-
handle: (keyDef, element, {
|
|
143
|
-
keyboardMap,
|
|
144
|
-
keyboardState
|
|
145
|
-
}) => {
|
|
146
|
-
var _keyboardMap$find2;
|
|
147
|
-
|
|
148
|
-
const ctrlKeyDef = (_keyboardMap$find2 = keyboardMap.find(k => k.key === 'Control')) != null ? _keyboardMap$find2 :
|
|
149
|
-
/* istanbul ignore next */
|
|
150
|
-
{
|
|
151
|
-
key: 'Control',
|
|
152
|
-
code: 'Control'
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
_dom.fireEvent.keyUp(element, (0, _getEventProps.getKeyEventProps)(ctrlKeyDef, keyboardState));
|
|
156
|
-
}
|
|
157
|
-
}];
|
|
158
|
-
exports.postKeyupBehavior = postKeyupBehavior;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.preKeyupBehavior = exports.preKeydownBehavior = exports.postKeyupBehavior = exports.keyupBehavior = exports.keypressBehavior = exports.keydownBehavior = void 0;
|
|
7
|
-
|
|
8
|
-
var arrowKeys = _interopRequireWildcard(require("./arrow"));
|
|
9
|
-
|
|
10
|
-
var controlKeys = _interopRequireWildcard(require("./control"));
|
|
11
|
-
|
|
12
|
-
var characterKeys = _interopRequireWildcard(require("./character"));
|
|
13
|
-
|
|
14
|
-
var functionalKeys = _interopRequireWildcard(require("./functional"));
|
|
15
|
-
|
|
16
|
-
var combination = _interopRequireWildcard(require("./combination"));
|
|
17
|
-
|
|
18
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
-
|
|
20
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
-
|
|
22
|
-
const preKeydownBehavior = [...functionalKeys.preKeydownBehavior];
|
|
23
|
-
exports.preKeydownBehavior = preKeydownBehavior;
|
|
24
|
-
const keydownBehavior = [...arrowKeys.keydownBehavior, ...controlKeys.keydownBehavior, ...functionalKeys.keydownBehavior, ...combination.keydownBehavior];
|
|
25
|
-
exports.keydownBehavior = keydownBehavior;
|
|
26
|
-
const keypressBehavior = [...functionalKeys.keypressBehavior, ...characterKeys.keypressBehavior];
|
|
27
|
-
exports.keypressBehavior = keypressBehavior;
|
|
28
|
-
const preKeyupBehavior = [...functionalKeys.preKeyupBehavior];
|
|
29
|
-
exports.preKeyupBehavior = preKeyupBehavior;
|
|
30
|
-
const keyupBehavior = [...functionalKeys.keyupBehavior];
|
|
31
|
-
exports.keyupBehavior = keyupBehavior;
|
|
32
|
-
const postKeyupBehavior = [...functionalKeys.postKeyupBehavior];
|
|
33
|
-
exports.postKeyupBehavior = postKeyupBehavior;
|
|
@@ -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,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
|
-
}
|