@testing-library/user-event 14.0.0-alpha.8 → 14.0.0-beta.11
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/README.md +5 -192
- package/dist/index.cjs +2864 -0
- package/dist/index.mjs +2935 -0
- package/dist/types/clipboard/copy.d.ts +2 -0
- package/dist/types/clipboard/cut.d.ts +2 -0
- package/dist/types/clipboard/index.d.ts +3 -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/types/convenience/index.d.ts +3 -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/types/event/behavior/click.d.ts +1 -0
- package/dist/types/event/behavior/index.d.ts +6 -0
- package/dist/types/event/behavior/keydown.d.ts +1 -0
- package/dist/types/event/behavior/keypress.d.ts +1 -0
- package/dist/types/event/behavior/keyup.d.ts +1 -0
- package/dist/types/event/behavior/registry.d.ts +9 -0
- package/dist/types/event/createEvent.d.ts +8 -0
- package/dist/types/event/dispatchEvent.d.ts +2 -0
- package/dist/types/event/eventMap.d.ts +342 -0
- package/dist/types/event/eventTypes.d.ts +2 -0
- package/dist/types/event/index.d.ts +6 -0
- package/dist/types/event/types.d.ts +13 -0
- package/dist/types/event/wrapEvent.d.ts +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/keyboard/index.d.ts +7 -0
- package/dist/{keyboard → types/keyboard}/keyMap.d.ts +0 -0
- package/dist/types/keyboard/keyboardAction.d.ts +10 -0
- package/dist/types/keyboard/modifiers.d.ts +9 -0
- package/dist/{keyboard/getNextKeyDef.d.ts → types/keyboard/parseKeyDef.d.ts} +4 -6
- package/dist/{keyboard → types/keyboard}/types.d.ts +19 -26
- package/dist/types/options.d.ts +117 -0
- package/dist/types/pointer/firePointerEvents.d.ts +11 -0
- package/dist/types/pointer/index.d.ts +10 -0
- package/dist/{pointer → types/pointer}/keyMap.d.ts +0 -0
- package/dist/types/pointer/parseKeyDef.d.ts +6 -0
- package/dist/{pointer → types/pointer}/pointerAction.d.ts +3 -2
- package/dist/types/pointer/pointerMove.d.ts +6 -0
- package/dist/types/pointer/pointerPress.d.ts +8 -0
- package/dist/{pointer → types/pointer}/resolveSelectionTarget.d.ts +0 -0
- package/dist/{pointer → types/pointer}/types.d.ts +2 -12
- package/dist/types/setup/api.d.ts +5 -0
- package/dist/types/setup/config.d.ts +10 -0
- package/dist/types/setup/directApi.d.ts +19 -0
- package/dist/types/setup/index.d.ts +36 -0
- package/dist/types/setup/setup.d.ts +20 -0
- package/dist/types/setup/wrapAsync.d.ts +4 -0
- package/dist/types/utility/clear.d.ts +2 -0
- package/dist/types/utility/index.d.ts +4 -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/types/utils/dataTransfer/Blob.d.ts +1 -0
- package/dist/types/utils/dataTransfer/Clipboard.d.ts +9 -0
- package/dist/types/utils/dataTransfer/DataTransfer.d.ts +2 -0
- package/dist/types/utils/dataTransfer/FileList.d.ts +1 -0
- package/dist/{utils → types/utils}/edit/buildTimeValue.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/getValue.d.ts +0 -0
- package/dist/types/utils/edit/input.d.ts +2 -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/types/utils/edit/isValidDateOrTimeValue.d.ts +3 -0
- package/dist/{utils → types/utils}/edit/maxLength.d.ts +0 -0
- package/dist/types/utils/edit/setFiles.d.ts +12 -0
- package/dist/{utils → types/utils}/focus/blur.d.ts +0 -0
- package/dist/types/utils/focus/copySelection.d.ts +1 -0
- package/dist/types/utils/focus/cursor.d.ts +9 -0
- package/dist/{utils → types/utils}/focus/focus.d.ts +3 -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 +1 -0
- package/dist/{utils → types/utils}/focus/selection.d.ts +4 -0
- package/dist/{utils → types/utils}/focus/selector.d.ts +0 -0
- package/dist/{utils → types/utils}/index.d.ts +14 -11
- package/dist/{utils → types/utils}/keyDef/readNextDescriptor.d.ts +0 -0
- package/dist/types/utils/keyboard/getKeyEventProps.d.ts +5 -0
- package/dist/types/utils/keyboard/getUIEventModifiers.d.ts +15 -0
- package/dist/types/utils/misc/cloneEvent.d.ts +1 -0
- package/dist/{utils → types/utils}/misc/eventWrapper.d.ts +0 -0
- package/dist/types/utils/misc/findClosest.d.ts +1 -0
- package/dist/types/utils/misc/getDocumentFromNode.d.ts +1 -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/mouseButtons.d.ts +0 -0
- package/package.json +13 -30
- package/CHANGELOG.md +0 -5
- package/dist/clear.d.ts +0 -2
- package/dist/clear.js +0 -46
- package/dist/click.d.ts +0 -9
- package/dist/click.js +0 -62
- 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/hover.d.ts +0 -4
- package/dist/hover.js +0 -43
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -22
- package/dist/keyboard/getEventProps.d.ts +0 -17
- package/dist/keyboard/getEventProps.js +0 -33
- package/dist/keyboard/getNextKeyDef.js +0 -85
- package/dist/keyboard/index.d.ts +0 -19
- package/dist/keyboard/index.js +0 -78
- package/dist/keyboard/keyMap.js +0 -143
- package/dist/keyboard/keyboardImplementation.d.ts +0 -3
- package/dist/keyboard/keyboardImplementation.js +0 -169
- package/dist/keyboard/plugins/arrow.d.ts +0 -6
- package/dist/keyboard/plugins/arrow.js +0 -28
- package/dist/keyboard/plugins/character.d.ts +0 -5
- package/dist/keyboard/plugins/character.js +0 -166
- package/dist/keyboard/plugins/combination.d.ts +0 -5
- package/dist/keyboard/plugins/combination.js +0 -17
- package/dist/keyboard/plugins/control.d.ts +0 -6
- package/dist/keyboard/plugins/control.js +0 -52
- package/dist/keyboard/plugins/functional.d.ts +0 -11
- package/dist/keyboard/plugins/functional.js +0 -140
- package/dist/keyboard/plugins/index.d.ts +0 -8
- package/dist/keyboard/plugins/index.js +0 -42
- package/dist/keyboard/shared/fireChangeForInputTimeIfValid.d.ts +0 -3
- package/dist/keyboard/shared/fireChangeForInputTimeIfValid.js +0 -20
- package/dist/keyboard/shared/index.d.ts +0 -1
- package/dist/keyboard/shared/index.js +0 -18
- package/dist/keyboard/specialCharMap.d.ts +0 -22
- package/dist/keyboard/specialCharMap.js +0 -30
- package/dist/keyboard/types.js +0 -19
- package/dist/paste.d.ts +0 -7
- package/dist/paste.js +0 -60
- package/dist/pointer/index.d.ts +0 -18
- package/dist/pointer/index.js +0 -90
- package/dist/pointer/keyMap.js +0 -29
- package/dist/pointer/parseKeyDef.d.ts +0 -6
- package/dist/pointer/parseKeyDef.js +0 -36
- package/dist/pointer/pointerAction.js +0 -52
- package/dist/pointer/pointerMove.d.ts +0 -5
- package/dist/pointer/pointerMove.js +0 -136
- package/dist/pointer/pointerPress.d.ts +0 -7
- package/dist/pointer/pointerPress.js +0 -330
- package/dist/pointer/resolveSelectionTarget.js +0 -75
- package/dist/pointer/types.js +0 -1
- package/dist/selectOptions.d.ts +0 -4
- package/dist/selectOptions.js +0 -142
- package/dist/setup.d.ts +0 -92
- package/dist/setup.js +0 -203
- package/dist/tab.d.ts +0 -5
- package/dist/tab.js +0 -12
- package/dist/type.d.ts +0 -14
- package/dist/type.js +0 -74
- package/dist/upload.d.ts +0 -10
- package/dist/upload.js +0 -92
- package/dist/utils/click/isClickableInput.js +0 -14
- package/dist/utils/edit/buildTimeValue.js +0 -44
- package/dist/utils/edit/calculateNewValue.d.ts +0 -16
- package/dist/utils/edit/calculateNewValue.js +0 -50
- package/dist/utils/edit/fireInputEvent.d.ts +0 -11
- package/dist/utils/edit/fireInputEvent.js +0 -65
- 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.d.ts +0 -3
- package/dist/utils/edit/isValidDateValue.js +0 -12
- package/dist/utils/edit/isValidInputTimeValue.d.ts +0 -3
- package/dist/utils/edit/isValidInputTimeValue.js +0 -12
- package/dist/utils/edit/maxLength.js +0 -50
- package/dist/utils/edit/prepareInput.d.ts +0 -4
- package/dist/utils/edit/prepareInput.js +0 -60
- package/dist/utils/focus/blur.js +0 -19
- 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 -38
- package/dist/utils/focus/selection.js +0 -190
- package/dist/utils/focus/selector.js +0 -8
- package/dist/utils/index.js +0 -421
- package/dist/utils/keyDef/readNextDescriptor.js +0 -102
- package/dist/utils/misc/eventWrapper.js +0 -16
- package/dist/utils/misc/findClosest.d.ts +0 -1
- package/dist/utils/misc/findClosest.js +0 -20
- package/dist/utils/misc/hasFormSubmit.d.ts +0 -1
- 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 -24
- package/dist/utils/misc/wait.js +0 -10
- package/dist/utils/pointer/fakeEvent.d.ts +0 -20
- package/dist/utils/pointer/fakeEvent.js +0 -91
- package/dist/utils/pointer/firePointerEvents.d.ts +0 -14
- package/dist/utils/pointer/firePointerEvents.js +0 -55
- package/dist/utils/pointer/mouseButtons.js +0 -45
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.keypressBehavior = void 0;
|
|
7
|
-
|
|
8
|
-
var _dom = require("@testing-library/dom");
|
|
9
|
-
|
|
10
|
-
var _shared = require("../shared");
|
|
11
|
-
|
|
12
|
-
var _utils = require("../../utils");
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* This file should cover the behavior for keys that produce character input
|
|
16
|
-
*/
|
|
17
|
-
const keypressBehavior = [{
|
|
18
|
-
matches: (keyDef, element) => {
|
|
19
|
-
var _keyDef$key;
|
|
20
|
-
|
|
21
|
-
return ((_keyDef$key = keyDef.key) == null ? void 0 : _keyDef$key.length) === 1 && (0, _utils.isElementType)(element, 'input', {
|
|
22
|
-
type: 'time',
|
|
23
|
-
readOnly: false
|
|
24
|
-
});
|
|
25
|
-
},
|
|
26
|
-
handle: (keyDef, element, options, state) => {
|
|
27
|
-
var _state$carryValue;
|
|
28
|
-
|
|
29
|
-
let newEntry = keyDef.key;
|
|
30
|
-
const textToBeTyped = ((_state$carryValue = state.carryValue) != null ? _state$carryValue : '') + newEntry;
|
|
31
|
-
const timeNewEntry = (0, _utils.buildTimeValue)(textToBeTyped);
|
|
32
|
-
|
|
33
|
-
if ((0, _utils.isValidInputTimeValue)(element, timeNewEntry)) {
|
|
34
|
-
newEntry = timeNewEntry;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const {
|
|
38
|
-
newValue,
|
|
39
|
-
newOffset
|
|
40
|
-
} = (0, _utils.calculateNewValue)(newEntry, element, (0, _utils.getInputRange)(element));
|
|
41
|
-
const prevValue = (0, _utils.getValue)(element); // this check was provided by fireInputEventIfNeeded
|
|
42
|
-
// TODO: verify if it is even needed by this handler
|
|
43
|
-
|
|
44
|
-
if (prevValue !== newValue) {
|
|
45
|
-
(0, _utils.fireInputEvent)(element, {
|
|
46
|
-
newValue,
|
|
47
|
-
newSelection: {
|
|
48
|
-
node: element,
|
|
49
|
-
offset: newOffset
|
|
50
|
-
},
|
|
51
|
-
eventOverrides: {
|
|
52
|
-
data: keyDef.key,
|
|
53
|
-
inputType: 'insertText'
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
(0, _shared.fireChangeForInputTimeIfValid)(element, prevValue, timeNewEntry);
|
|
59
|
-
state.carryValue = textToBeTyped;
|
|
60
|
-
}
|
|
61
|
-
}, {
|
|
62
|
-
matches: (keyDef, element) => {
|
|
63
|
-
var _keyDef$key2;
|
|
64
|
-
|
|
65
|
-
return ((_keyDef$key2 = keyDef.key) == null ? void 0 : _keyDef$key2.length) === 1 && (0, _utils.isElementType)(element, 'input', {
|
|
66
|
-
type: 'date',
|
|
67
|
-
readOnly: false
|
|
68
|
-
});
|
|
69
|
-
},
|
|
70
|
-
handle: (keyDef, element, options, state) => {
|
|
71
|
-
var _state$carryValue2;
|
|
72
|
-
|
|
73
|
-
let newEntry = keyDef.key;
|
|
74
|
-
const textToBeTyped = ((_state$carryValue2 = state.carryValue) != null ? _state$carryValue2 : '') + newEntry;
|
|
75
|
-
const isValidToBeTyped = (0, _utils.isValidDateValue)(element, textToBeTyped);
|
|
76
|
-
|
|
77
|
-
if (isValidToBeTyped) {
|
|
78
|
-
newEntry = textToBeTyped;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const {
|
|
82
|
-
newValue,
|
|
83
|
-
newOffset
|
|
84
|
-
} = (0, _utils.calculateNewValue)(newEntry, element, (0, _utils.getInputRange)(element));
|
|
85
|
-
const prevValue = (0, _utils.getValue)(element); // this check was provided by fireInputEventIfNeeded
|
|
86
|
-
// TODO: verify if it is even needed by this handler
|
|
87
|
-
|
|
88
|
-
if (prevValue !== newValue) {
|
|
89
|
-
(0, _utils.fireInputEvent)(element, {
|
|
90
|
-
newValue,
|
|
91
|
-
newSelection: {
|
|
92
|
-
node: element,
|
|
93
|
-
offset: newOffset
|
|
94
|
-
},
|
|
95
|
-
eventOverrides: {
|
|
96
|
-
data: keyDef.key,
|
|
97
|
-
inputType: 'insertText'
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (isValidToBeTyped) {
|
|
103
|
-
_dom.fireEvent.change(element, {
|
|
104
|
-
target: {
|
|
105
|
-
value: textToBeTyped
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
state.carryValue = textToBeTyped;
|
|
111
|
-
}
|
|
112
|
-
}, {
|
|
113
|
-
matches: (keyDef, element) => {
|
|
114
|
-
var _keyDef$key3;
|
|
115
|
-
|
|
116
|
-
return ((_keyDef$key3 = keyDef.key) == null ? void 0 : _keyDef$key3.length) === 1 && (0, _utils.isElementType)(element, 'input', {
|
|
117
|
-
type: 'number',
|
|
118
|
-
readOnly: false
|
|
119
|
-
});
|
|
120
|
-
},
|
|
121
|
-
handle: (keyDef, element) => {
|
|
122
|
-
var _newValue$match, _newValue$match2;
|
|
123
|
-
|
|
124
|
-
if (!/[\d.\-e]/.test(keyDef.key)) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const {
|
|
129
|
-
newValue,
|
|
130
|
-
commit
|
|
131
|
-
} = (0, _utils.prepareInput)(keyDef.key, element); // the browser allows some invalid input but not others
|
|
132
|
-
// it allows up to two '-' at any place before any 'e' or one directly following 'e'
|
|
133
|
-
// it allows one '.' at any place before e
|
|
134
|
-
|
|
135
|
-
const valueParts = newValue.split('e', 2);
|
|
136
|
-
|
|
137
|
-
if (Number((_newValue$match = newValue.match(/-/g)) == null ? void 0 : _newValue$match.length) > 2 || Number((_newValue$match2 = newValue.match(/\./g)) == null ? void 0 : _newValue$match2.length) > 1 || valueParts[1] && !/^-?\d*$/.test(valueParts[1])) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
commit();
|
|
142
|
-
}
|
|
143
|
-
}, {
|
|
144
|
-
matches: (keyDef, element) => {
|
|
145
|
-
var _keyDef$key4;
|
|
146
|
-
|
|
147
|
-
return ((_keyDef$key4 = keyDef.key) == null ? void 0 : _keyDef$key4.length) === 1 && ((0, _utils.isEditableInput)(element) || (0, _utils.isElementType)(element, 'textarea', {
|
|
148
|
-
readOnly: false
|
|
149
|
-
}) || (0, _utils.isContentEditable)(element)) && (0, _utils.getSpaceUntilMaxLength)(element) !== 0;
|
|
150
|
-
},
|
|
151
|
-
handle: (keyDef, element) => {
|
|
152
|
-
var _prepareInput;
|
|
153
|
-
|
|
154
|
-
(_prepareInput = (0, _utils.prepareInput)(keyDef.key, element)) == null ? void 0 : _prepareInput.commit();
|
|
155
|
-
}
|
|
156
|
-
}, {
|
|
157
|
-
matches: (keyDef, element) => keyDef.key === 'Enter' && ((0, _utils.isElementType)(element, 'textarea', {
|
|
158
|
-
readOnly: false
|
|
159
|
-
}) || (0, _utils.isContentEditable)(element)) && (0, _utils.getSpaceUntilMaxLength)(element) !== 0,
|
|
160
|
-
handle: (keyDef, element, options, state) => {
|
|
161
|
-
var _prepareInput2;
|
|
162
|
-
|
|
163
|
-
(_prepareInput2 = (0, _utils.prepareInput)('\n', element, (0, _utils.isContentEditable)(element) && !state.modifiers.shift ? 'insertParagraph' : 'insertLineBreak')) == null ? void 0 : _prepareInput2.commit();
|
|
164
|
-
}
|
|
165
|
-
}];
|
|
166
|
-
exports.keypressBehavior = keypressBehavior;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.keydownBehavior = void 0;
|
|
7
|
-
|
|
8
|
-
var _utils = require("../../utils");
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Default behavior for key combinations
|
|
12
|
-
*/
|
|
13
|
-
const keydownBehavior = [{
|
|
14
|
-
matches: (keyDef, element, options, state) => keyDef.code === 'KeyA' && state.modifiers.ctrl,
|
|
15
|
-
handle: (keyDef, element) => (0, _utils.selectAll)(element)
|
|
16
|
-
}];
|
|
17
|
-
exports.keydownBehavior = keydownBehavior;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.keydownBehavior = void 0;
|
|
7
|
-
|
|
8
|
-
var _utils = require("../../utils");
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* This file should contain behavior for arrow keys as described here:
|
|
12
|
-
* https://w3c.github.io/uievents-code/#key-controlpad-section
|
|
13
|
-
*/
|
|
14
|
-
const keydownBehavior = [{
|
|
15
|
-
matches: (keyDef, element) => (keyDef.key === 'Home' || keyDef.key === 'End') && ((0, _utils.isElementType)(element, ['input', 'textarea']) || (0, _utils.isContentEditable)(element)),
|
|
16
|
-
handle: (keyDef, element) => {
|
|
17
|
-
// This could probably been improved by collapsing a selection range
|
|
18
|
-
if (keyDef.key === 'Home') {
|
|
19
|
-
(0, _utils.setSelectionRange)(element, 0, 0);
|
|
20
|
-
} else {
|
|
21
|
-
var _getValue$length, _getValue;
|
|
22
|
-
|
|
23
|
-
const newPos = (_getValue$length = (_getValue = (0, _utils.getValue)(element)) == null ? void 0 : _getValue.length) != null ? _getValue$length :
|
|
24
|
-
/* istanbul ignore next */
|
|
25
|
-
0;
|
|
26
|
-
(0, _utils.setSelectionRange)(element, newPos, newPos);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}, {
|
|
30
|
-
matches: (keyDef, element) => (keyDef.key === 'PageUp' || keyDef.key === 'PageDown') && (0, _utils.isElementType)(element, ['input']),
|
|
31
|
-
handle: (keyDef, element) => {
|
|
32
|
-
// This could probably been improved by collapsing a selection range
|
|
33
|
-
if (keyDef.key === 'PageUp') {
|
|
34
|
-
(0, _utils.setSelectionRange)(element, 0, 0);
|
|
35
|
-
} else {
|
|
36
|
-
var _getValue$length2, _getValue2;
|
|
37
|
-
|
|
38
|
-
const newPos = (_getValue$length2 = (_getValue2 = (0, _utils.getValue)(element)) == null ? void 0 : _getValue2.length) != null ? _getValue$length2 :
|
|
39
|
-
/* istanbul ignore next */
|
|
40
|
-
0;
|
|
41
|
-
(0, _utils.setSelectionRange)(element, newPos, newPos);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}, {
|
|
45
|
-
matches: (keyDef, element) => keyDef.key === 'Delete' && (0, _utils.isEditable)(element),
|
|
46
|
-
handle: (keDef, element) => {
|
|
47
|
-
var _prepareInput;
|
|
48
|
-
|
|
49
|
-
(_prepareInput = (0, _utils.prepareInput)('', element, 'deleteContentForward')) == null ? void 0 : _prepareInput.commit();
|
|
50
|
-
}
|
|
51
|
-
}];
|
|
52
|
-
exports.keydownBehavior = keydownBehavior;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file should contain behavior for functional keys as described here:
|
|
3
|
-
* https://w3c.github.io/uievents-code/#key-alphanumeric-functional
|
|
4
|
-
*/
|
|
5
|
-
import { behaviorPlugin } from '../types';
|
|
6
|
-
export declare const preKeydownBehavior: behaviorPlugin[];
|
|
7
|
-
export declare const keydownBehavior: behaviorPlugin[];
|
|
8
|
-
export declare const keypressBehavior: behaviorPlugin[];
|
|
9
|
-
export declare const preKeyupBehavior: behaviorPlugin[];
|
|
10
|
-
export declare const keyupBehavior: behaviorPlugin[];
|
|
11
|
-
export declare const postKeyupBehavior: behaviorPlugin[];
|
|
@@ -1,140 +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, options, state) => {
|
|
30
|
-
state.modifiers[modKey] = true;
|
|
31
|
-
}
|
|
32
|
-
})), // AltGraph produces an extra keydown for Control
|
|
33
|
-
// The modifier does not change
|
|
34
|
-
{
|
|
35
|
-
matches: keyDef => keyDef.key === 'AltGraph',
|
|
36
|
-
handle: (keyDef, element, options, state) => {
|
|
37
|
-
var _options$keyboardMap$;
|
|
38
|
-
|
|
39
|
-
const ctrlKeyDef = (_options$keyboardMap$ = options.keyboardMap.find(k => k.key === 'Control')) != null ? _options$keyboardMap$ :
|
|
40
|
-
/* istanbul ignore next */
|
|
41
|
-
{
|
|
42
|
-
key: 'Control',
|
|
43
|
-
code: 'Control'
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
_dom.fireEvent.keyDown(element, (0, _getEventProps.getKeyEventProps)(ctrlKeyDef, state));
|
|
47
|
-
}
|
|
48
|
-
}];
|
|
49
|
-
exports.preKeydownBehavior = preKeydownBehavior;
|
|
50
|
-
const keydownBehavior = [{
|
|
51
|
-
matches: keyDef => keyDef.key === 'CapsLock',
|
|
52
|
-
handle: (keyDef, element, options, state) => {
|
|
53
|
-
state.modifiers.caps = !state.modifiers.caps;
|
|
54
|
-
}
|
|
55
|
-
}, {
|
|
56
|
-
matches: (keyDef, element) => keyDef.key === 'Backspace' && (0, _utils.isEditable)(element),
|
|
57
|
-
handle: (keyDef, element) => {
|
|
58
|
-
var _prepareInput;
|
|
59
|
-
|
|
60
|
-
(_prepareInput = (0, _utils.prepareInput)('', element, 'deleteContentBackward')) == null ? void 0 : _prepareInput.commit();
|
|
61
|
-
}
|
|
62
|
-
}, {
|
|
63
|
-
matches: keyDef => keyDef.key === 'Tab',
|
|
64
|
-
handle: (keyDef, element, options, state) => {
|
|
65
|
-
const dest = (0, _utils.getTabDestination)(element, state.modifiers.shift);
|
|
66
|
-
|
|
67
|
-
if (dest === element.ownerDocument.body) {
|
|
68
|
-
(0, _utils.blur)(element);
|
|
69
|
-
} else {
|
|
70
|
-
(0, _utils.focus)(dest);
|
|
71
|
-
|
|
72
|
-
if ((0, _utils.isElementType)(dest, ['input', 'textarea'])) {
|
|
73
|
-
(0, _document.setUISelection)(dest, {
|
|
74
|
-
anchorOffset: 0,
|
|
75
|
-
focusOffset: dest.value.length
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}];
|
|
81
|
-
exports.keydownBehavior = keydownBehavior;
|
|
82
|
-
const keypressBehavior = [{
|
|
83
|
-
matches: (keyDef, element) => keyDef.key === 'Enter' && (0, _utils.isElementType)(element, 'input') && ['checkbox', 'radio'].includes(element.type),
|
|
84
|
-
handle: (keyDef, element) => {
|
|
85
|
-
const form = element.form;
|
|
86
|
-
|
|
87
|
-
if ((0, _utils.hasFormSubmit)(form)) {
|
|
88
|
-
_dom.fireEvent.submit(form);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}, {
|
|
92
|
-
matches: (keyDef, element) => keyDef.key === 'Enter' && ((0, _utils.isClickableInput)(element) || // Links with href defined should handle Enter the same as a click
|
|
93
|
-
(0, _utils.isElementType)(element, 'a') && Boolean(element.href)),
|
|
94
|
-
handle: (keyDef, element, options, state) => {
|
|
95
|
-
_dom.fireEvent.click(element, (0, _getEventProps.getMouseEventProps)(state));
|
|
96
|
-
}
|
|
97
|
-
}, {
|
|
98
|
-
matches: (keyDef, element) => keyDef.key === 'Enter' && (0, _utils.isElementType)(element, 'input'),
|
|
99
|
-
handle: (keyDef, element) => {
|
|
100
|
-
const form = element.form;
|
|
101
|
-
|
|
102
|
-
if (form && (form.querySelectorAll('input').length === 1 || (0, _utils.hasFormSubmit)(form))) {
|
|
103
|
-
_dom.fireEvent.submit(form);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}];
|
|
107
|
-
exports.keypressBehavior = keypressBehavior;
|
|
108
|
-
const preKeyupBehavior = [// modifierKeys switch off the modifier BEFORE the keyup event
|
|
109
|
-
...Object.entries(modifierKeys).map(([key, modKey]) => ({
|
|
110
|
-
matches: keyDef => keyDef.key === key,
|
|
111
|
-
handle: (keyDef, element, options, state) => {
|
|
112
|
-
state.modifiers[modKey] = false;
|
|
113
|
-
}
|
|
114
|
-
}))];
|
|
115
|
-
exports.preKeyupBehavior = preKeyupBehavior;
|
|
116
|
-
const keyupBehavior = [{
|
|
117
|
-
matches: (keyDef, element) => keyDef.key === ' ' && (0, _utils.isClickableInput)(element),
|
|
118
|
-
handle: (keyDef, element, options, state) => {
|
|
119
|
-
_dom.fireEvent.click(element, (0, _getEventProps.getMouseEventProps)(state));
|
|
120
|
-
}
|
|
121
|
-
}];
|
|
122
|
-
exports.keyupBehavior = keyupBehavior;
|
|
123
|
-
const postKeyupBehavior = [// AltGraph produces an extra keyup for Control
|
|
124
|
-
// The modifier does not change
|
|
125
|
-
{
|
|
126
|
-
matches: keyDef => keyDef.key === 'AltGraph',
|
|
127
|
-
handle: (keyDef, element, options, state) => {
|
|
128
|
-
var _options$keyboardMap$2;
|
|
129
|
-
|
|
130
|
-
const ctrlKeyDef = (_options$keyboardMap$2 = options.keyboardMap.find(k => k.key === 'Control')) != null ? _options$keyboardMap$2 :
|
|
131
|
-
/* istanbul ignore next */
|
|
132
|
-
{
|
|
133
|
-
key: 'Control',
|
|
134
|
-
code: 'Control'
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
_dom.fireEvent.keyUp(element, (0, _getEventProps.getKeyEventProps)(ctrlKeyDef, state));
|
|
138
|
-
}
|
|
139
|
-
}];
|
|
140
|
-
exports.postKeyupBehavior = postKeyupBehavior;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { behaviorPlugin } from '../types';
|
|
2
|
-
export declare const replaceBehavior: behaviorPlugin[];
|
|
3
|
-
export declare const preKeydownBehavior: behaviorPlugin[];
|
|
4
|
-
export declare const keydownBehavior: behaviorPlugin[];
|
|
5
|
-
export declare const keypressBehavior: behaviorPlugin[];
|
|
6
|
-
export declare const preKeyupBehavior: behaviorPlugin[];
|
|
7
|
-
export declare const keyupBehavior: behaviorPlugin[];
|
|
8
|
-
export declare const postKeyupBehavior: behaviorPlugin[];
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.replaceBehavior = exports.preKeyupBehavior = exports.preKeydownBehavior = exports.postKeyupBehavior = exports.keyupBehavior = exports.keypressBehavior = exports.keydownBehavior = void 0;
|
|
7
|
-
|
|
8
|
-
var _utils = require("../../utils");
|
|
9
|
-
|
|
10
|
-
var arrowKeys = _interopRequireWildcard(require("./arrow"));
|
|
11
|
-
|
|
12
|
-
var controlKeys = _interopRequireWildcard(require("./control"));
|
|
13
|
-
|
|
14
|
-
var characterKeys = _interopRequireWildcard(require("./character"));
|
|
15
|
-
|
|
16
|
-
var functionalKeys = _interopRequireWildcard(require("./functional"));
|
|
17
|
-
|
|
18
|
-
var combination = _interopRequireWildcard(require("./combination"));
|
|
19
|
-
|
|
20
|
-
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); }
|
|
21
|
-
|
|
22
|
-
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; }
|
|
23
|
-
|
|
24
|
-
const replaceBehavior = [{
|
|
25
|
-
matches: (keyDef, element) => keyDef.key === 'selectall' && (0, _utils.isElementType)(element, ['input', 'textarea']),
|
|
26
|
-
handle: (keyDef, element) => {
|
|
27
|
-
(0, _utils.setSelectionRange)(element, 0, (0, _utils.getValue)(element).length);
|
|
28
|
-
}
|
|
29
|
-
}];
|
|
30
|
-
exports.replaceBehavior = replaceBehavior;
|
|
31
|
-
const preKeydownBehavior = [...functionalKeys.preKeydownBehavior];
|
|
32
|
-
exports.preKeydownBehavior = preKeydownBehavior;
|
|
33
|
-
const keydownBehavior = [...arrowKeys.keydownBehavior, ...controlKeys.keydownBehavior, ...functionalKeys.keydownBehavior, ...combination.keydownBehavior];
|
|
34
|
-
exports.keydownBehavior = keydownBehavior;
|
|
35
|
-
const keypressBehavior = [...functionalKeys.keypressBehavior, ...characterKeys.keypressBehavior];
|
|
36
|
-
exports.keypressBehavior = keypressBehavior;
|
|
37
|
-
const preKeyupBehavior = [...functionalKeys.preKeyupBehavior];
|
|
38
|
-
exports.preKeyupBehavior = preKeyupBehavior;
|
|
39
|
-
const keyupBehavior = [...functionalKeys.keyupBehavior];
|
|
40
|
-
exports.keyupBehavior = keyupBehavior;
|
|
41
|
-
const postKeyupBehavior = [...functionalKeys.postKeyupBehavior];
|
|
42
|
-
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 +0,0 @@
|
|
|
1
|
-
export * from './fireChangeForInputTimeIfValid';
|
|
@@ -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
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated This list of strings with special meaning is no longer necessary
|
|
3
|
-
* as we've introduced a standardized way to describe any keystroke for `userEvent`.
|
|
4
|
-
* @see https://testing-library.com/docs/ecosystem-user-event#keyboardtext-options
|
|
5
|
-
*/
|
|
6
|
-
export declare const specialCharMap: {
|
|
7
|
-
readonly arrowLeft: "{arrowleft}";
|
|
8
|
-
readonly arrowRight: "{arrowright}";
|
|
9
|
-
readonly arrowDown: "{arrowdown}";
|
|
10
|
-
readonly arrowUp: "{arrowup}";
|
|
11
|
-
readonly enter: "{enter}";
|
|
12
|
-
readonly escape: "{esc}";
|
|
13
|
-
readonly delete: "{del}";
|
|
14
|
-
readonly backspace: "{backspace}";
|
|
15
|
-
readonly home: "{home}";
|
|
16
|
-
readonly end: "{end}";
|
|
17
|
-
readonly selectAll: "{selectall}";
|
|
18
|
-
readonly space: "{space}";
|
|
19
|
-
readonly whitespace: " ";
|
|
20
|
-
readonly pageUp: "{pageUp}";
|
|
21
|
-
readonly pageDown: "{pageDown}";
|
|
22
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.specialCharMap = void 0;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated This list of strings with special meaning is no longer necessary
|
|
10
|
-
* as we've introduced a standardized way to describe any keystroke for `userEvent`.
|
|
11
|
-
* @see https://testing-library.com/docs/ecosystem-user-event#keyboardtext-options
|
|
12
|
-
*/
|
|
13
|
-
const specialCharMap = {
|
|
14
|
-
arrowLeft: '{arrowleft}',
|
|
15
|
-
arrowRight: '{arrowright}',
|
|
16
|
-
arrowDown: '{arrowdown}',
|
|
17
|
-
arrowUp: '{arrowup}',
|
|
18
|
-
enter: '{enter}',
|
|
19
|
-
escape: '{esc}',
|
|
20
|
-
delete: '{del}',
|
|
21
|
-
backspace: '{backspace}',
|
|
22
|
-
home: '{home}',
|
|
23
|
-
end: '{end}',
|
|
24
|
-
selectAll: '{selectall}',
|
|
25
|
-
space: '{space}',
|
|
26
|
-
whitespace: ' ',
|
|
27
|
-
pageUp: '{pageUp}',
|
|
28
|
-
pageDown: '{pageDown}'
|
|
29
|
-
};
|
|
30
|
-
exports.specialCharMap = specialCharMap;
|
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/paste.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { UserEvent } from './setup';
|
|
2
|
-
interface pasteOptions {
|
|
3
|
-
initialSelectionStart?: number;
|
|
4
|
-
initialSelectionEnd?: number;
|
|
5
|
-
}
|
|
6
|
-
export declare function paste(this: UserEvent, element: HTMLElement, text: string, init?: ClipboardEventInit, { initialSelectionStart, initialSelectionEnd }?: pasteOptions): void;
|
|
7
|
-
export {};
|
package/dist/paste.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.paste = paste;
|
|
7
|
-
|
|
8
|
-
var _dom = require("@testing-library/dom");
|
|
9
|
-
|
|
10
|
-
var _utils = require("./utils");
|
|
11
|
-
|
|
12
|
-
function isSupportedElement(element) {
|
|
13
|
-
return (0, _utils.isElementType)(element, 'input') && Boolean(_utils.editableInputTypes[element.type]) || (0, _utils.isElementType)(element, 'textarea');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function paste(element, text, init, {
|
|
17
|
-
initialSelectionStart,
|
|
18
|
-
initialSelectionEnd
|
|
19
|
-
} = {}) {
|
|
20
|
-
var _prepareInput;
|
|
21
|
-
|
|
22
|
-
// TODO: implement for contenteditable
|
|
23
|
-
if (!isSupportedElement(element)) {
|
|
24
|
-
throw new TypeError(`The given ${element.tagName} element is currently unsupported.
|
|
25
|
-
A PR extending this implementation would be very much welcome at https://github.com/testing-library/user-event`);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if ((0, _utils.isDisabled)(element)) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
(0, _utils.eventWrapper)(() => element.focus()); // by default, a new element has it's selection start and end at 0
|
|
33
|
-
// but most of the time when people call "paste", they expect it to paste
|
|
34
|
-
// at the end of the current input value. So, if the selection start
|
|
35
|
-
// and end are both the default of 0, then we'll go ahead and change
|
|
36
|
-
// them to the length of the current value.
|
|
37
|
-
// the only time it would make sense to pass the initialSelectionStart or
|
|
38
|
-
// initialSelectionEnd is if you have an input with a value and want to
|
|
39
|
-
// explicitely start typing with the cursor at 0. Not super common.
|
|
40
|
-
|
|
41
|
-
if (element.selectionStart === 0 && element.selectionEnd === 0) {
|
|
42
|
-
(0, _utils.setSelectionRange)(element, initialSelectionStart != null ? initialSelectionStart : element.value.length, initialSelectionEnd != null ? initialSelectionEnd : element.value.length);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
_dom.fireEvent.paste(element, init);
|
|
46
|
-
|
|
47
|
-
if (element.readOnly) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
text = text.substr(0, (0, _utils.getSpaceUntilMaxLength)(element));
|
|
52
|
-
const inputRange = (0, _utils.getInputRange)(element);
|
|
53
|
-
/* istanbul ignore if */
|
|
54
|
-
|
|
55
|
-
if (!inputRange) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
(_prepareInput = (0, _utils.prepareInput)(text, element, 'insertFromPaste')) == null ? void 0 : _prepareInput.commit();
|
|
60
|
-
}
|
package/dist/pointer/index.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { PointerAction, PointerActionTarget } from './pointerAction';
|
|
2
|
-
import type { inputDeviceState, pointerOptions, pointerState } from './types';
|
|
3
|
-
export declare function pointer(input: PointerInput, options?: Partial<pointerOptions & {
|
|
4
|
-
delay: 0;
|
|
5
|
-
} & inputDeviceState>): pointerState;
|
|
6
|
-
export declare function pointer(input: PointerInput, options: Partial<pointerOptions & {
|
|
7
|
-
delay: number;
|
|
8
|
-
} & inputDeviceState>): Promise<pointerState>;
|
|
9
|
-
declare type PointerActionInput = string | ({
|
|
10
|
-
keys: string;
|
|
11
|
-
} & PointerActionTarget) | PointerAction;
|
|
12
|
-
declare type PointerInput = PointerActionInput | Array<PointerActionInput>;
|
|
13
|
-
export declare function pointerImplementationWrapper(input: PointerInput, config: Partial<pointerOptions & inputDeviceState>): {
|
|
14
|
-
promise: Promise<unknown[]>;
|
|
15
|
-
pointerState: pointerState;
|
|
16
|
-
};
|
|
17
|
-
export declare function createPointerState(): pointerState;
|
|
18
|
-
export {};
|