@testing-library/user-event 14.4.0 → 14.4.3
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/cjs/clipboard/copy.js +6 -15
- package/dist/cjs/clipboard/cut.js +6 -15
- package/dist/cjs/clipboard/paste.js +6 -14
- package/dist/cjs/convenience/click.js +1 -4
- package/dist/cjs/convenience/hover.js +2 -12
- package/dist/cjs/document/UI.js +94 -0
- package/dist/cjs/document/copySelection.js +37 -0
- package/dist/cjs/document/getValueOrTextContent.js +27 -0
- package/dist/cjs/document/index.js +13 -68
- package/dist/cjs/document/interceptor.js +87 -4
- package/dist/cjs/document/prepareDocument.js +67 -0
- package/dist/cjs/document/trackValue.js +65 -0
- package/dist/cjs/event/behavior/click.js +8 -12
- package/dist/cjs/event/behavior/cut.js +5 -11
- package/dist/cjs/event/behavior/keydown.js +43 -43
- package/dist/cjs/event/behavior/keypress.js +9 -10
- package/dist/cjs/event/behavior/keyup.js +6 -7
- package/dist/cjs/event/behavior/paste.js +7 -12
- package/dist/cjs/event/createEvent.js +37 -28
- package/dist/cjs/event/dispatchEvent.js +21 -2
- package/dist/cjs/event/focus.js +44 -0
- package/dist/cjs/event/index.js +24 -17
- package/dist/cjs/{utils/edit → event}/input.js +50 -47
- package/dist/cjs/{utils/edit/walkRadio.js → event/radio.js} +13 -7
- package/dist/cjs/event/selection/getInputRange.js +20 -0
- package/dist/cjs/event/selection/getTargetTypeAndSelection.js +40 -0
- package/dist/cjs/event/selection/index.js +26 -0
- package/dist/cjs/event/selection/modifySelection.js +30 -0
- package/dist/cjs/event/selection/modifySelectionPerMouse.js +49 -0
- package/dist/cjs/event/selection/moveSelection.js +47 -0
- package/dist/cjs/{utils/focus → event/selection}/resolveCaretPosition.js +11 -19
- package/dist/cjs/event/selection/selectAll.js +47 -0
- package/dist/cjs/event/selection/setSelection.js +30 -0
- package/dist/cjs/event/selection/setSelectionPerMouse.js +90 -0
- package/dist/cjs/event/selection/setSelectionRange.js +40 -0
- package/dist/cjs/event/selection/updateSelectionOnFocus.js +45 -0
- package/dist/cjs/keyboard/index.js +13 -23
- package/dist/cjs/keyboard/parseKeyDef.js +8 -13
- package/dist/cjs/options.js +0 -28
- package/dist/cjs/pointer/index.js +28 -34
- package/dist/cjs/pointer/parseKeyDef.js +1 -9
- package/dist/cjs/setup/directApi.js +6 -6
- package/dist/cjs/setup/index.js +0 -2
- package/dist/cjs/setup/setup.js +69 -38
- package/dist/cjs/system/index.js +4 -2
- package/dist/cjs/system/keyboard.js +32 -32
- package/dist/cjs/system/pointer/buttons.js +3 -1
- package/dist/cjs/system/pointer/device.js +3 -1
- package/dist/cjs/system/pointer/index.js +82 -79
- package/dist/cjs/system/pointer/mouse.js +97 -81
- package/dist/cjs/system/pointer/pointer.js +45 -46
- package/dist/cjs/system/pointer/shared.js +10 -0
- package/dist/cjs/utility/clear.js +10 -11
- package/dist/cjs/utility/selectOptions.js +17 -19
- package/dist/cjs/utility/type.js +6 -15
- package/dist/cjs/utility/upload.js +9 -15
- package/dist/cjs/utils/dataTransfer/Clipboard.js +11 -21
- package/dist/cjs/utils/dataTransfer/DataTransfer.js +22 -19
- package/dist/cjs/utils/edit/isEditable.js +6 -10
- package/dist/cjs/utils/edit/maxLength.js +6 -16
- package/dist/cjs/utils/edit/setFiles.js +4 -2
- package/dist/cjs/utils/edit/{buildTimeValue.js → timeValue.js} +6 -0
- package/dist/cjs/utils/focus/cursor.js +2 -17
- package/dist/cjs/utils/focus/getActiveElement.js +3 -2
- package/dist/cjs/utils/focus/selection.js +1 -266
- package/dist/cjs/utils/index.js +7 -32
- package/dist/cjs/utils/keyDef/readNextDescriptor.js +5 -3
- package/dist/cjs/utils/misc/isDisabled.js +2 -1
- package/dist/cjs/utils/misc/isVisible.js +1 -1
- package/dist/cjs/utils/misc/level.js +4 -6
- package/dist/cjs/utils/pointer/cssPointerEvents.js +26 -32
- package/dist/esm/clipboard/copy.js +6 -15
- package/dist/esm/clipboard/cut.js +6 -15
- package/dist/esm/clipboard/paste.js +6 -14
- package/dist/esm/convenience/click.js +1 -4
- package/dist/esm/convenience/hover.js +2 -12
- package/dist/esm/document/UI.js +79 -0
- package/dist/esm/document/copySelection.js +33 -0
- package/dist/esm/document/getValueOrTextContent.js +23 -0
- package/dist/esm/document/index.js +4 -66
- package/dist/esm/document/interceptor.js +85 -5
- package/dist/esm/document/prepareDocument.js +63 -0
- package/dist/esm/document/trackValue.js +59 -0
- package/dist/esm/event/behavior/click.js +8 -12
- package/dist/esm/event/behavior/cut.js +5 -11
- package/dist/esm/event/behavior/keydown.js +36 -36
- package/dist/esm/event/behavior/keypress.js +9 -10
- package/dist/esm/event/behavior/keyup.js +6 -7
- package/dist/esm/event/behavior/paste.js +7 -12
- package/dist/esm/event/createEvent.js +37 -28
- package/dist/esm/event/dispatchEvent.js +20 -3
- package/dist/esm/event/focus.js +39 -0
- package/dist/esm/event/index.js +14 -19
- package/dist/esm/{utils/edit → event}/input.js +37 -34
- package/dist/esm/{utils/edit/walkRadio.js → event/radio.js} +13 -7
- package/dist/esm/event/selection/getInputRange.js +16 -0
- package/dist/esm/event/selection/getTargetTypeAndSelection.js +36 -0
- package/dist/esm/event/selection/index.js +9 -0
- package/dist/esm/event/selection/modifySelection.js +26 -0
- package/dist/esm/event/selection/modifySelectionPerMouse.js +45 -0
- package/dist/esm/event/selection/moveSelection.js +43 -0
- package/dist/esm/{utils/focus → event/selection}/resolveCaretPosition.js +11 -19
- package/dist/esm/event/selection/selectAll.js +42 -0
- package/dist/esm/event/selection/setSelection.js +26 -0
- package/dist/esm/event/selection/setSelectionPerMouse.js +86 -0
- package/dist/esm/event/selection/setSelectionRange.js +36 -0
- package/dist/esm/event/selection/updateSelectionOnFocus.js +41 -0
- package/dist/esm/keyboard/index.js +13 -23
- package/dist/esm/keyboard/parseKeyDef.js +8 -13
- package/dist/esm/options.js +1 -26
- package/dist/esm/pointer/index.js +28 -34
- package/dist/esm/pointer/parseKeyDef.js +1 -9
- package/dist/esm/setup/directApi.js +6 -6
- package/dist/esm/setup/index.js +0 -1
- package/dist/esm/setup/setup.js +63 -33
- package/dist/esm/system/index.js +4 -2
- package/dist/esm/system/keyboard.js +32 -32
- package/dist/esm/system/pointer/buttons.js +3 -1
- package/dist/esm/system/pointer/device.js +3 -1
- package/dist/esm/system/pointer/index.js +83 -79
- package/dist/esm/system/pointer/mouse.js +95 -79
- package/dist/esm/system/pointer/pointer.js +44 -45
- package/dist/esm/system/pointer/shared.js +6 -0
- package/dist/esm/utility/clear.js +10 -11
- package/dist/esm/utility/selectOptions.js +17 -19
- package/dist/esm/utility/type.js +6 -15
- package/dist/esm/utility/upload.js +9 -15
- package/dist/esm/utils/dataTransfer/Clipboard.js +11 -21
- package/dist/esm/utils/dataTransfer/DataTransfer.js +22 -19
- package/dist/esm/utils/edit/isEditable.js +4 -8
- package/dist/esm/utils/edit/maxLength.js +5 -16
- package/dist/esm/utils/edit/setFiles.js +4 -2
- package/dist/esm/utils/edit/{buildTimeValue.js → timeValue.js} +6 -1
- package/dist/esm/utils/focus/cursor.js +2 -17
- package/dist/esm/utils/focus/getActiveElement.js +3 -2
- package/dist/esm/utils/focus/selection.js +3 -260
- package/dist/esm/utils/index.js +4 -11
- package/dist/esm/utils/keyDef/readNextDescriptor.js +5 -3
- package/dist/esm/utils/misc/isDisabled.js +2 -1
- package/dist/esm/utils/misc/isVisible.js +1 -1
- package/dist/esm/utils/misc/level.js +4 -6
- package/dist/esm/utils/pointer/cssPointerEvents.js +26 -32
- package/dist/types/clipboard/copy.d.ts +1 -1
- package/dist/types/clipboard/cut.d.ts +1 -1
- package/dist/types/clipboard/paste.d.ts +1 -1
- package/dist/types/convenience/click.d.ts +1 -1
- package/dist/types/convenience/hover.d.ts +1 -1
- package/dist/types/document/UI.d.ts +42 -0
- package/dist/types/{utils/focus → document}/copySelection.d.ts +0 -0
- package/dist/types/document/getValueOrTextContent.d.ts +1 -0
- package/dist/types/document/index.d.ts +5 -10
- package/dist/types/document/interceptor.d.ts +3 -0
- package/dist/types/document/prepareDocument.d.ts +8 -0
- package/dist/types/document/trackValue.d.ts +17 -0
- package/dist/types/event/behavior/registry.d.ts +2 -2
- package/dist/types/event/dispatchEvent.d.ts +5 -2
- package/dist/types/event/focus.d.ts +5 -0
- package/dist/types/event/index.d.ts +6 -4
- package/dist/types/event/input.d.ts +2 -0
- package/dist/types/event/radio.d.ts +4 -0
- package/dist/types/event/selection/getInputRange.d.ts +5 -0
- package/dist/types/event/selection/getTargetTypeAndSelection.d.ts +10 -0
- package/dist/types/event/selection/index.d.ts +15 -0
- package/dist/types/event/selection/modifySelection.d.ts +8 -0
- package/dist/types/event/selection/modifySelectionPerMouse.d.ts +7 -0
- package/dist/types/event/selection/moveSelection.d.ts +4 -0
- package/dist/types/{utils/focus → event/selection}/resolveCaretPosition.d.ts +0 -0
- package/dist/types/{utils/focus → event/selection}/selectAll.d.ts +0 -0
- package/dist/types/event/selection/setSelection.d.ts +10 -0
- package/dist/types/event/selection/setSelectionPerMouse.d.ts +8 -0
- package/dist/types/event/selection/setSelectionRange.d.ts +6 -0
- package/dist/types/event/selection/updateSelectionOnFocus.d.ts +5 -0
- package/dist/types/keyboard/index.d.ts +2 -2
- package/dist/types/options.d.ts +0 -8
- package/dist/types/pointer/index.d.ts +3 -3
- package/dist/types/setup/directApi.d.ts +1 -1
- package/dist/types/setup/index.d.ts +2 -15
- package/dist/types/setup/setup.d.ts +25 -7
- package/dist/types/system/keyboard.d.ts +3 -3
- package/dist/types/system/pointer/buttons.d.ts +1 -1
- package/dist/types/system/pointer/index.d.ts +7 -25
- package/dist/types/system/pointer/mouse.d.ts +5 -5
- package/dist/types/system/pointer/pointer.d.ts +7 -7
- package/dist/types/system/pointer/shared.d.ts +20 -0
- package/dist/types/utility/clear.d.ts +1 -1
- package/dist/types/utility/selectOptions.d.ts +1 -1
- package/dist/types/utility/type.d.ts +3 -3
- package/dist/types/utility/upload.d.ts +1 -1
- package/dist/types/utils/click/isClickableInput.d.ts +2 -2
- package/dist/types/utils/edit/isEditable.d.ts +5 -6
- package/dist/types/utils/edit/maxLength.d.ts +14 -1
- package/dist/types/utils/edit/{isValidDateOrTimeValue.d.ts → timeValue.d.ts} +1 -0
- package/dist/types/utils/focus/selection.d.ts +4 -69
- package/dist/types/utils/index.d.ts +2 -9
- package/dist/types/utils/misc/level.d.ts +4 -13
- package/dist/types/utils/misc/wait.d.ts +2 -2
- package/dist/types/utils/pointer/cssPointerEvents.d.ts +4 -4
- package/package.json +29 -4
- package/dist/cjs/document/selection.js +0 -107
- package/dist/cjs/document/setRangeText.js +0 -21
- package/dist/cjs/document/value.js +0 -125
- package/dist/cjs/setup/config.js +0 -7
- package/dist/cjs/utils/edit/getValue.js +0 -35
- package/dist/cjs/utils/edit/isValidDateOrTimeValue.js +0 -11
- package/dist/cjs/utils/focus/blur.js +0 -16
- package/dist/cjs/utils/focus/copySelection.js +0 -46
- package/dist/cjs/utils/focus/focus.js +0 -26
- package/dist/cjs/utils/focus/selectAll.js +0 -54
- package/dist/cjs/utils/misc/eventWrapper.js +0 -15
- package/dist/esm/document/selection.js +0 -99
- package/dist/esm/document/setRangeText.js +0 -17
- package/dist/esm/document/value.js +0 -115
- package/dist/esm/setup/config.js +0 -3
- package/dist/esm/utils/edit/getValue.js +0 -31
- package/dist/esm/utils/edit/isValidDateOrTimeValue.js +0 -7
- package/dist/esm/utils/focus/blur.js +0 -12
- package/dist/esm/utils/focus/copySelection.js +0 -42
- package/dist/esm/utils/focus/focus.js +0 -22
- package/dist/esm/utils/focus/selectAll.js +0 -49
- package/dist/esm/utils/misc/eventWrapper.js +0 -11
- package/dist/types/document/selection.d.ts +0 -29
- package/dist/types/document/setRangeText.d.ts +0 -1
- package/dist/types/document/value.d.ts +0 -26
- package/dist/types/setup/config.d.ts +0 -6
- package/dist/types/utils/edit/buildTimeValue.d.ts +0 -1
- package/dist/types/utils/edit/getValue.d.ts +0 -1
- package/dist/types/utils/edit/input.d.ts +0 -2
- package/dist/types/utils/edit/walkRadio.d.ts +0 -4
- package/dist/types/utils/focus/blur.d.ts +0 -2
- package/dist/types/utils/focus/focus.d.ts +0 -5
- package/dist/types/utils/misc/eventWrapper.d.ts +0 -1
|
@@ -1,124 +1,92 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../../event/behavior/click.js';
|
|
2
|
+
import '../../event/behavior/cut.js';
|
|
3
|
+
import '../../event/behavior/keydown.js';
|
|
4
|
+
import '../../event/behavior/keypress.js';
|
|
5
|
+
import '../../event/behavior/keyup.js';
|
|
6
|
+
import '../../event/behavior/paste.js';
|
|
7
|
+
import '@testing-library/dom';
|
|
8
|
+
import '../../event/eventMap.js';
|
|
2
9
|
import '../../utils/click/isClickableInput.js';
|
|
3
10
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../../utils/edit/maxLength.js';
|
|
5
11
|
import '../../utils/edit/isEditable.js';
|
|
6
|
-
import
|
|
7
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
12
|
+
import '../../utils/edit/maxLength.js';
|
|
8
13
|
import { isDisabled } from '../../utils/misc/isDisabled.js';
|
|
9
|
-
import '@testing-library/dom';
|
|
10
|
-
import { setSelectionPerMouseDown, modifySelectionPerMouseMove } from '../../utils/focus/selection.js';
|
|
14
|
+
import '@testing-library/dom/dist/helpers.js';
|
|
11
15
|
import '../../utils/keyDef/readNextDescriptor.js';
|
|
12
16
|
import { getTreeDiff } from '../../utils/misc/getTreeDiff.js';
|
|
13
17
|
import '../../utils/misc/level.js';
|
|
14
18
|
import '../../options.js';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
19
|
+
import { focusElement } from '../../event/focus.js';
|
|
20
|
+
import { setSelectionPerMouseDown } from '../../event/selection/setSelectionPerMouse.js';
|
|
21
|
+
import { modifySelectionPerMouseMove } from '../../event/selection/modifySelectionPerMouse.js';
|
|
22
|
+
import { getMouseEventButton, Buttons } from './buttons.js';
|
|
23
|
+
import { isDifferentPointerPosition } from './shared.js';
|
|
17
24
|
|
|
18
25
|
/**
|
|
19
26
|
* This object is the single "virtual" mouse that might be controlled by multiple different pointer devices.
|
|
20
27
|
*/ class Mouse {
|
|
21
|
-
position
|
|
22
|
-
buttons = new Buttons();
|
|
23
|
-
buttonDownTarget = {};
|
|
24
|
-
// According to spec the `detail` on click events should be the number
|
|
25
|
-
// of *consecutive* clicks with a specific button.
|
|
26
|
-
// On `mousedown` and `mouseup` it should be this number increased by one.
|
|
27
|
-
// But the browsers don't implement it this way.
|
|
28
|
-
// If another button is pressed,
|
|
29
|
-
// in Webkit: the `mouseup` on the previously pressed button has `detail: 0` and no `click`/`auxclick`.
|
|
30
|
-
// in Gecko: the `mouseup` and click events have the same detail as the `mousedown`.
|
|
31
|
-
// If there is a delay while a button is pressed,
|
|
32
|
-
// the `mouseup` and `click` are normal, but a following `mousedown` starts a new click count.
|
|
33
|
-
// We'll follow the minimal implementation of Webkit.
|
|
34
|
-
clickCount = new class {
|
|
35
|
-
down = {};
|
|
36
|
-
count = {};
|
|
37
|
-
incOnClick(button) {
|
|
38
|
-
const current = this.down[button] === undefined ? undefined : Number(this.down[button]) + 1;
|
|
39
|
-
this.count = this.count[button] === undefined ? {} : {
|
|
40
|
-
[button]: Number(this.count[button]) + 1
|
|
41
|
-
};
|
|
42
|
-
return current;
|
|
43
|
-
}
|
|
44
|
-
getOnDown(button) {
|
|
45
|
-
this.down = {
|
|
46
|
-
[button]: this.count[button] ?? 0
|
|
47
|
-
};
|
|
48
|
-
this.count = {
|
|
49
|
-
[button]: this.count[button] ?? 0
|
|
50
|
-
};
|
|
51
|
-
return Number(this.count[button]) + 1;
|
|
52
|
-
}
|
|
53
|
-
getOnUp(button) {
|
|
54
|
-
return this.down[button] === undefined ? undefined : Number(this.down[button]) + 1;
|
|
55
|
-
}
|
|
56
|
-
reset() {
|
|
57
|
-
this.count = {};
|
|
58
|
-
}
|
|
59
|
-
}();
|
|
60
|
-
move(config, position) {
|
|
28
|
+
move(instance, position) {
|
|
61
29
|
const prevPosition = this.position;
|
|
62
|
-
const prevTarget = this.getTarget(
|
|
30
|
+
const prevTarget = this.getTarget(instance);
|
|
63
31
|
this.position = position;
|
|
64
32
|
if (!isDifferentPointerPosition(prevPosition, position)) {
|
|
65
33
|
return;
|
|
66
34
|
}
|
|
67
|
-
const nextTarget = this.getTarget(
|
|
35
|
+
const nextTarget = this.getTarget(instance);
|
|
68
36
|
const init = this.getEventInit('mousemove');
|
|
69
37
|
const [leave, enter] = getTreeDiff(prevTarget, nextTarget);
|
|
70
38
|
return {
|
|
71
39
|
leave: ()=>{
|
|
72
40
|
if (prevTarget !== nextTarget) {
|
|
73
|
-
dispatchUIEvent(
|
|
74
|
-
leave.forEach((el)=>dispatchUIEvent(
|
|
41
|
+
instance.dispatchUIEvent(prevTarget, 'mouseout', init);
|
|
42
|
+
leave.forEach((el)=>instance.dispatchUIEvent(el, 'mouseleave', init));
|
|
75
43
|
}
|
|
76
44
|
},
|
|
77
45
|
enter: ()=>{
|
|
78
46
|
if (prevTarget !== nextTarget) {
|
|
79
|
-
dispatchUIEvent(
|
|
80
|
-
enter.forEach((el)=>dispatchUIEvent(
|
|
47
|
+
instance.dispatchUIEvent(nextTarget, 'mouseover', init);
|
|
48
|
+
enter.forEach((el)=>instance.dispatchUIEvent(el, 'mouseenter', init));
|
|
81
49
|
}
|
|
82
50
|
},
|
|
83
51
|
move: ()=>{
|
|
84
|
-
dispatchUIEvent(
|
|
85
|
-
this.modifySelecting(
|
|
52
|
+
instance.dispatchUIEvent(nextTarget, 'mousemove', init);
|
|
53
|
+
this.modifySelecting(instance);
|
|
86
54
|
}
|
|
87
55
|
};
|
|
88
56
|
}
|
|
89
|
-
down(
|
|
57
|
+
down(instance, keyDef, pointer) {
|
|
90
58
|
const button = this.buttons.down(keyDef);
|
|
91
59
|
if (button === undefined) {
|
|
92
60
|
return;
|
|
93
61
|
}
|
|
94
|
-
const target = this.getTarget(
|
|
62
|
+
const target = this.getTarget(instance);
|
|
95
63
|
this.buttonDownTarget[button] = target;
|
|
96
64
|
const disabled = isDisabled(target);
|
|
97
65
|
const init = this.getEventInit('mousedown', keyDef.button);
|
|
98
|
-
if (disabled || dispatchUIEvent(
|
|
99
|
-
this.startSelecting(
|
|
100
|
-
|
|
66
|
+
if (disabled || instance.dispatchUIEvent(target, 'mousedown', init)) {
|
|
67
|
+
this.startSelecting(instance, init.detail);
|
|
68
|
+
focusElement(target);
|
|
101
69
|
}
|
|
102
70
|
if (!disabled && getMouseEventButton(keyDef.button) === 2) {
|
|
103
|
-
dispatchUIEvent(
|
|
71
|
+
instance.dispatchUIEvent(target, 'contextmenu', this.getEventInit('contextmenu', keyDef.button, pointer));
|
|
104
72
|
}
|
|
105
73
|
}
|
|
106
|
-
up(
|
|
74
|
+
up(instance, keyDef, pointer) {
|
|
107
75
|
const button = this.buttons.up(keyDef);
|
|
108
76
|
if (button === undefined) {
|
|
109
77
|
return;
|
|
110
78
|
}
|
|
111
|
-
const target = this.getTarget(
|
|
79
|
+
const target = this.getTarget(instance);
|
|
112
80
|
if (!isDisabled(target)) {
|
|
113
|
-
dispatchUIEvent(
|
|
81
|
+
instance.dispatchUIEvent(target, 'mouseup', this.getEventInit('mouseup', keyDef.button));
|
|
114
82
|
this.endSelecting();
|
|
115
83
|
const clickTarget = getTreeDiff(this.buttonDownTarget[button], target)[2][0];
|
|
116
84
|
if (clickTarget) {
|
|
117
85
|
const init = this.getEventInit('click', keyDef.button, pointer);
|
|
118
86
|
if (init.detail) {
|
|
119
|
-
dispatchUIEvent(
|
|
87
|
+
instance.dispatchUIEvent(clickTarget, init.button === 0 ? 'click' : 'auxclick', init);
|
|
120
88
|
if (init.button === 0 && init.detail === 2) {
|
|
121
|
-
dispatchUIEvent(
|
|
89
|
+
instance.dispatchUIEvent(clickTarget, 'dblclick', {
|
|
122
90
|
...this.getEventInit('dblclick', keyDef.button),
|
|
123
91
|
detail: init.detail
|
|
124
92
|
});
|
|
@@ -150,33 +118,81 @@ import { Buttons, getMouseEventButton } from './buttons.js';
|
|
|
150
118
|
}
|
|
151
119
|
return init;
|
|
152
120
|
}
|
|
153
|
-
getTarget(
|
|
154
|
-
|
|
121
|
+
getTarget(instance) {
|
|
122
|
+
var _target;
|
|
123
|
+
return (_target = this.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
|
|
155
124
|
}
|
|
156
|
-
startSelecting(
|
|
125
|
+
startSelecting(instance, clickCount) {
|
|
126
|
+
var ref, ref1;
|
|
157
127
|
// TODO: support extending range (shift)
|
|
158
128
|
this.selecting = setSelectionPerMouseDown({
|
|
159
|
-
document: config.document,
|
|
160
|
-
target: this.getTarget(
|
|
161
|
-
node: this.position.caret
|
|
162
|
-
offset: this.position.caret
|
|
129
|
+
document: instance.config.document,
|
|
130
|
+
target: this.getTarget(instance),
|
|
131
|
+
node: (ref = this.position.caret) === null || ref === void 0 ? void 0 : ref.node,
|
|
132
|
+
offset: (ref1 = this.position.caret) === null || ref1 === void 0 ? void 0 : ref1.offset,
|
|
163
133
|
clickCount
|
|
164
134
|
});
|
|
165
135
|
}
|
|
166
|
-
modifySelecting(
|
|
136
|
+
modifySelecting(instance) {
|
|
137
|
+
var ref, ref1;
|
|
167
138
|
if (!this.selecting) {
|
|
168
139
|
return;
|
|
169
140
|
}
|
|
170
141
|
modifySelectionPerMouseMove(this.selecting, {
|
|
171
|
-
document: config.document,
|
|
172
|
-
target: this.getTarget(
|
|
173
|
-
node: this.position.caret
|
|
174
|
-
offset: this.position.caret
|
|
142
|
+
document: instance.config.document,
|
|
143
|
+
target: this.getTarget(instance),
|
|
144
|
+
node: (ref = this.position.caret) === null || ref === void 0 ? void 0 : ref.node,
|
|
145
|
+
offset: (ref1 = this.position.caret) === null || ref1 === void 0 ? void 0 : ref1.offset
|
|
175
146
|
});
|
|
176
147
|
}
|
|
177
148
|
endSelecting() {
|
|
178
149
|
this.selecting = undefined;
|
|
179
150
|
}
|
|
151
|
+
constructor(){
|
|
152
|
+
this.position = {};
|
|
153
|
+
this.buttons = new Buttons();
|
|
154
|
+
this.buttonDownTarget = {};
|
|
155
|
+
// According to spec the `detail` on click events should be the number
|
|
156
|
+
// of *consecutive* clicks with a specific button.
|
|
157
|
+
// On `mousedown` and `mouseup` it should be this number increased by one.
|
|
158
|
+
// But the browsers don't implement it this way.
|
|
159
|
+
// If another button is pressed,
|
|
160
|
+
// in Webkit: the `mouseup` on the previously pressed button has `detail: 0` and no `click`/`auxclick`.
|
|
161
|
+
// in Gecko: the `mouseup` and click events have the same detail as the `mousedown`.
|
|
162
|
+
// If there is a delay while a button is pressed,
|
|
163
|
+
// the `mouseup` and `click` are normal, but a following `mousedown` starts a new click count.
|
|
164
|
+
// We'll follow the minimal implementation of Webkit.
|
|
165
|
+
this.clickCount = new class {
|
|
166
|
+
incOnClick(button) {
|
|
167
|
+
const current = this.down[button] === undefined ? undefined : Number(this.down[button]) + 1;
|
|
168
|
+
this.count = this.count[button] === undefined ? {} : {
|
|
169
|
+
[button]: Number(this.count[button]) + 1
|
|
170
|
+
};
|
|
171
|
+
return current;
|
|
172
|
+
}
|
|
173
|
+
getOnDown(button) {
|
|
174
|
+
var _button;
|
|
175
|
+
this.down = {
|
|
176
|
+
[button]: (_button = this.count[button]) !== null && _button !== void 0 ? _button : 0
|
|
177
|
+
};
|
|
178
|
+
var _button1;
|
|
179
|
+
this.count = {
|
|
180
|
+
[button]: (_button1 = this.count[button]) !== null && _button1 !== void 0 ? _button1 : 0
|
|
181
|
+
};
|
|
182
|
+
return Number(this.count[button]) + 1;
|
|
183
|
+
}
|
|
184
|
+
getOnUp(button) {
|
|
185
|
+
return this.down[button] === undefined ? undefined : Number(this.down[button]) + 1;
|
|
186
|
+
}
|
|
187
|
+
reset() {
|
|
188
|
+
this.count = {};
|
|
189
|
+
}
|
|
190
|
+
constructor(){
|
|
191
|
+
this.down = {};
|
|
192
|
+
this.count = {};
|
|
193
|
+
}
|
|
194
|
+
}();
|
|
195
|
+
}
|
|
180
196
|
}
|
|
181
197
|
|
|
182
198
|
export { Mouse };
|
|
@@ -1,101 +1,89 @@
|
|
|
1
|
-
import { dispatchUIEvent } from '../../event/index.js';
|
|
2
1
|
import '../../utils/click/isClickableInput.js';
|
|
3
2
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../../utils/edit/maxLength.js';
|
|
5
3
|
import '../../utils/edit/isEditable.js';
|
|
6
|
-
import '
|
|
4
|
+
import '../../utils/edit/maxLength.js';
|
|
7
5
|
import '@testing-library/dom/dist/helpers.js';
|
|
8
6
|
import '../../utils/keyDef/readNextDescriptor.js';
|
|
9
7
|
import { getTreeDiff } from '../../utils/misc/getTreeDiff.js';
|
|
10
8
|
import '../../utils/misc/level.js';
|
|
11
9
|
import { assertPointerEvents, hasPointerEvents } from '../../utils/pointer/cssPointerEvents.js';
|
|
12
|
-
import { isDifferentPointerPosition } from './
|
|
10
|
+
import { isDifferentPointerPosition } from './shared.js';
|
|
13
11
|
|
|
14
12
|
class Pointer {
|
|
15
|
-
|
|
16
|
-
this.pointerId = pointerId;
|
|
17
|
-
this.pointerType = pointerType;
|
|
18
|
-
this.isPrimary = isPrimary;
|
|
19
|
-
this.isMultitouch = !isPrimary;
|
|
20
|
-
}
|
|
21
|
-
isMultitouch = false;
|
|
22
|
-
isCancelled = false;
|
|
23
|
-
isDown = false;
|
|
24
|
-
isPrevented = false;
|
|
25
|
-
position = {};
|
|
26
|
-
init(config, position) {
|
|
13
|
+
init(instance, position) {
|
|
27
14
|
this.position = position;
|
|
28
|
-
const target = this.getTarget(
|
|
15
|
+
const target = this.getTarget(instance);
|
|
29
16
|
const [, enter] = getTreeDiff(null, target);
|
|
30
17
|
const init = this.getEventInit();
|
|
31
|
-
assertPointerEvents(
|
|
32
|
-
dispatchUIEvent(
|
|
33
|
-
enter.forEach((el)=>dispatchUIEvent(
|
|
18
|
+
assertPointerEvents(instance, target);
|
|
19
|
+
instance.dispatchUIEvent(target, 'pointerover', init);
|
|
20
|
+
enter.forEach((el)=>instance.dispatchUIEvent(el, 'pointerenter', init));
|
|
34
21
|
return this;
|
|
35
22
|
}
|
|
36
|
-
move(
|
|
23
|
+
move(instance, position) {
|
|
37
24
|
const prevPosition = this.position;
|
|
38
|
-
const prevTarget = this.getTarget(
|
|
25
|
+
const prevTarget = this.getTarget(instance);
|
|
39
26
|
this.position = position;
|
|
40
27
|
if (!isDifferentPointerPosition(prevPosition, position)) {
|
|
41
28
|
return;
|
|
42
29
|
}
|
|
43
|
-
const nextTarget = this.getTarget(
|
|
30
|
+
const nextTarget = this.getTarget(instance);
|
|
44
31
|
const init = this.getEventInit();
|
|
45
32
|
const [leave, enter] = getTreeDiff(prevTarget, nextTarget);
|
|
46
33
|
return {
|
|
47
34
|
leave: ()=>{
|
|
48
|
-
if (hasPointerEvents(
|
|
35
|
+
if (hasPointerEvents(instance, prevTarget)) {
|
|
49
36
|
if (prevTarget !== nextTarget) {
|
|
50
|
-
dispatchUIEvent(
|
|
51
|
-
leave.forEach((el)=>dispatchUIEvent(
|
|
37
|
+
instance.dispatchUIEvent(prevTarget, 'pointerout', init);
|
|
38
|
+
leave.forEach((el)=>instance.dispatchUIEvent(el, 'pointerleave', init));
|
|
52
39
|
}
|
|
53
40
|
}
|
|
54
41
|
},
|
|
55
42
|
enter: ()=>{
|
|
56
|
-
assertPointerEvents(
|
|
43
|
+
assertPointerEvents(instance, nextTarget);
|
|
57
44
|
if (prevTarget !== nextTarget) {
|
|
58
|
-
dispatchUIEvent(
|
|
59
|
-
enter.forEach((el)=>dispatchUIEvent(
|
|
45
|
+
instance.dispatchUIEvent(nextTarget, 'pointerover', init);
|
|
46
|
+
enter.forEach((el)=>instance.dispatchUIEvent(el, 'pointerenter', init));
|
|
60
47
|
}
|
|
61
48
|
},
|
|
62
49
|
move: ()=>{
|
|
63
|
-
dispatchUIEvent(
|
|
50
|
+
instance.dispatchUIEvent(nextTarget, 'pointermove', init);
|
|
64
51
|
}
|
|
65
52
|
};
|
|
66
53
|
}
|
|
67
|
-
down(
|
|
54
|
+
down(instance, _keyDef) {
|
|
68
55
|
if (this.isDown) {
|
|
69
56
|
return;
|
|
70
57
|
}
|
|
71
|
-
const target = this.getTarget(
|
|
72
|
-
assertPointerEvents(
|
|
58
|
+
const target = this.getTarget(instance);
|
|
59
|
+
assertPointerEvents(instance, target);
|
|
73
60
|
this.isDown = true;
|
|
74
|
-
this.isPrevented = !dispatchUIEvent(
|
|
61
|
+
this.isPrevented = !instance.dispatchUIEvent(target, 'pointerdown', this.getEventInit());
|
|
75
62
|
}
|
|
76
|
-
up(
|
|
63
|
+
up(instance, _keyDef) {
|
|
77
64
|
if (!this.isDown) {
|
|
78
65
|
return;
|
|
79
66
|
}
|
|
80
|
-
const target = this.getTarget(
|
|
81
|
-
assertPointerEvents(
|
|
67
|
+
const target = this.getTarget(instance);
|
|
68
|
+
assertPointerEvents(instance, target);
|
|
82
69
|
this.isDown = false;
|
|
83
|
-
dispatchUIEvent(
|
|
70
|
+
instance.dispatchUIEvent(target, 'pointerup', this.getEventInit());
|
|
84
71
|
}
|
|
85
|
-
release(
|
|
86
|
-
const target = this.getTarget(
|
|
72
|
+
release(instance) {
|
|
73
|
+
const target = this.getTarget(instance);
|
|
87
74
|
const [leave] = getTreeDiff(target, null);
|
|
88
75
|
const init = this.getEventInit();
|
|
89
76
|
// Currently there is no PointerEventsCheckLevel that would
|
|
90
77
|
// make this check not use the *asserted* cached value from `up`.
|
|
91
|
-
/* istanbul ignore else */ if (hasPointerEvents(
|
|
92
|
-
dispatchUIEvent(
|
|
93
|
-
leave.forEach((el)=>dispatchUIEvent(
|
|
78
|
+
/* istanbul ignore else */ if (hasPointerEvents(instance, target)) {
|
|
79
|
+
instance.dispatchUIEvent(target, 'pointerout', init);
|
|
80
|
+
leave.forEach((el)=>instance.dispatchUIEvent(el, 'pointerleave', init));
|
|
94
81
|
}
|
|
95
82
|
this.isCancelled = true;
|
|
96
83
|
}
|
|
97
|
-
getTarget(
|
|
98
|
-
|
|
84
|
+
getTarget(instance) {
|
|
85
|
+
var _target;
|
|
86
|
+
return (_target = this.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
|
|
99
87
|
}
|
|
100
88
|
getEventInit() {
|
|
101
89
|
return {
|
|
@@ -105,6 +93,17 @@ class Pointer {
|
|
|
105
93
|
isPrimary: this.isPrimary
|
|
106
94
|
};
|
|
107
95
|
}
|
|
96
|
+
constructor({ pointerId , pointerType , isPrimary }){
|
|
97
|
+
this.isMultitouch = false;
|
|
98
|
+
this.isCancelled = false;
|
|
99
|
+
this.isDown = false;
|
|
100
|
+
this.isPrevented = false;
|
|
101
|
+
this.position = {};
|
|
102
|
+
this.pointerId = pointerId;
|
|
103
|
+
this.pointerType = pointerType;
|
|
104
|
+
this.isPrimary = isPrimary;
|
|
105
|
+
this.isMultitouch = !isPrimary;
|
|
106
|
+
}
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
export { Pointer };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
function isDifferentPointerPosition(positionA, positionB) {
|
|
2
|
+
var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
|
|
3
|
+
return positionA.target !== positionB.target || ((ref = positionA.coords) === null || ref === void 0 ? void 0 : ref.x) !== ((ref1 = positionB.coords) === null || ref1 === void 0 ? void 0 : ref1.y) || ((ref2 = positionA.coords) === null || ref2 === void 0 ? void 0 : ref2.y) !== ((ref3 = positionB.coords) === null || ref3 === void 0 ? void 0 : ref3.y) || ((ref4 = positionA.caret) === null || ref4 === void 0 ? void 0 : ref4.node) !== ((ref5 = positionB.caret) === null || ref5 === void 0 ? void 0 : ref5.node) || ((ref6 = positionA.caret) === null || ref6 === void 0 ? void 0 : ref6.offset) !== ((ref7 = positionB.caret) === null || ref7 === void 0 ? void 0 : ref7.offset);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export { isDifferentPointerPosition };
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import '../setup/index.js';
|
|
2
|
-
import '../utils/click/isClickableInput.js';
|
|
3
|
-
import '../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../event/eventMap.js';
|
|
5
1
|
import '../event/behavior/click.js';
|
|
6
2
|
import '../event/behavior/cut.js';
|
|
7
3
|
import '../event/behavior/keydown.js';
|
|
@@ -9,22 +5,25 @@ import '../event/behavior/keypress.js';
|
|
|
9
5
|
import '../event/behavior/keyup.js';
|
|
10
6
|
import '../event/behavior/paste.js';
|
|
11
7
|
import '@testing-library/dom';
|
|
12
|
-
import
|
|
8
|
+
import '../event/eventMap.js';
|
|
9
|
+
import '../utils/click/isClickableInput.js';
|
|
10
|
+
import '../utils/dataTransfer/Clipboard.js';
|
|
13
11
|
import { isEditable } from '../utils/edit/isEditable.js';
|
|
14
|
-
import
|
|
15
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
12
|
+
import '../utils/edit/maxLength.js';
|
|
16
13
|
import { isDisabled } from '../utils/misc/isDisabled.js';
|
|
17
|
-
import
|
|
14
|
+
import '@testing-library/dom/dist/helpers.js';
|
|
18
15
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
19
16
|
import '../utils/misc/level.js';
|
|
20
17
|
import '../options.js';
|
|
21
|
-
import {
|
|
18
|
+
import { focusElement } from '../event/focus.js';
|
|
19
|
+
import { input } from '../event/input.js';
|
|
20
|
+
import { selectAll, isAllSelected } from '../event/selection/selectAll.js';
|
|
22
21
|
|
|
23
22
|
async function clear(element) {
|
|
24
23
|
if (!isEditable(element) || isDisabled(element)) {
|
|
25
24
|
throw new Error('clear()` is only supported on editable elements.');
|
|
26
25
|
}
|
|
27
|
-
|
|
26
|
+
focusElement(element);
|
|
28
27
|
if (element.ownerDocument.activeElement !== element) {
|
|
29
28
|
throw new Error('The element to be cleared could not be focused.');
|
|
30
29
|
}
|
|
@@ -32,7 +31,7 @@ async function clear(element) {
|
|
|
32
31
|
if (!isAllSelected(element)) {
|
|
33
32
|
throw new Error('The element content to be cleared could not be selected.');
|
|
34
33
|
}
|
|
35
|
-
input(this
|
|
34
|
+
input(this, element, '', 'deleteContentBackward');
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
export { clear };
|
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
import { getConfig } from '@testing-library/dom';
|
|
2
2
|
import '../utils/click/isClickableInput.js';
|
|
3
3
|
import '../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../event/eventMap.js';
|
|
5
|
-
import '../event/behavior/click.js';
|
|
6
|
-
import '../event/behavior/cut.js';
|
|
7
|
-
import '../event/behavior/keydown.js';
|
|
8
|
-
import '../event/behavior/keypress.js';
|
|
9
|
-
import '../event/behavior/keyup.js';
|
|
10
|
-
import '../event/behavior/paste.js';
|
|
11
|
-
import '../utils/edit/maxLength.js';
|
|
12
4
|
import '../utils/edit/isEditable.js';
|
|
13
|
-
import
|
|
14
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
15
|
-
import { isDisabled } from '../utils/misc/isDisabled.js';
|
|
5
|
+
import '../utils/edit/maxLength.js';
|
|
16
6
|
import { isElementType } from '../utils/misc/isElementType.js';
|
|
7
|
+
import { isDisabled } from '../utils/misc/isDisabled.js';
|
|
8
|
+
import '@testing-library/dom/dist/helpers.js';
|
|
17
9
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
18
10
|
import '../utils/misc/level.js';
|
|
19
11
|
import { wait } from '../utils/misc/wait.js';
|
|
20
12
|
import { hasPointerEvents } from '../utils/pointer/cssPointerEvents.js';
|
|
21
|
-
import '../
|
|
22
|
-
import
|
|
13
|
+
import '../event/behavior/click.js';
|
|
14
|
+
import '../event/behavior/cut.js';
|
|
15
|
+
import '../event/behavior/keydown.js';
|
|
16
|
+
import '../event/behavior/keypress.js';
|
|
17
|
+
import '../event/behavior/keyup.js';
|
|
18
|
+
import '../event/behavior/paste.js';
|
|
19
|
+
import '../event/eventMap.js';
|
|
20
|
+
import { focusElement } from '../event/focus.js';
|
|
23
21
|
|
|
24
22
|
async function selectOptions(select, values) {
|
|
25
23
|
return selectOptionsBase.call(this, true, select, values);
|
|
@@ -60,7 +58,7 @@ async function selectOptionsBase(newValue, select, values) {
|
|
|
60
58
|
if (isElementType(select, 'select')) {
|
|
61
59
|
if (select.multiple) {
|
|
62
60
|
for (const option of selectedOptions){
|
|
63
|
-
const withPointerEvents = this
|
|
61
|
+
const withPointerEvents = this.config.pointerEventsCheck === 0 ? true : hasPointerEvents(this, option);
|
|
64
62
|
// events fired for multiple select are weird. Can't use hover...
|
|
65
63
|
if (withPointerEvents) {
|
|
66
64
|
this.dispatchUIEvent(option, 'pointerover');
|
|
@@ -72,7 +70,7 @@ async function selectOptionsBase(newValue, select, values) {
|
|
|
72
70
|
this.dispatchUIEvent(option, 'pointerdown');
|
|
73
71
|
this.dispatchUIEvent(option, 'mousedown');
|
|
74
72
|
}
|
|
75
|
-
|
|
73
|
+
focusElement(select);
|
|
76
74
|
if (withPointerEvents) {
|
|
77
75
|
this.dispatchUIEvent(option, 'pointerup');
|
|
78
76
|
this.dispatchUIEvent(option, 'mouseup');
|
|
@@ -81,15 +79,15 @@ async function selectOptionsBase(newValue, select, values) {
|
|
|
81
79
|
if (withPointerEvents) {
|
|
82
80
|
this.dispatchUIEvent(option, 'click');
|
|
83
81
|
}
|
|
84
|
-
await wait(this
|
|
82
|
+
await wait(this.config);
|
|
85
83
|
}
|
|
86
84
|
} else if (selectedOptions.length === 1) {
|
|
87
|
-
const withPointerEvents1 = this
|
|
85
|
+
const withPointerEvents1 = this.config.pointerEventsCheck === 0 ? true : hasPointerEvents(this, select);
|
|
88
86
|
// the click to open the select options
|
|
89
87
|
if (withPointerEvents1) {
|
|
90
88
|
await this.click(select);
|
|
91
89
|
} else {
|
|
92
|
-
|
|
90
|
+
focusElement(select);
|
|
93
91
|
}
|
|
94
92
|
selectOption(selectedOptions[0]);
|
|
95
93
|
if (withPointerEvents1) {
|
|
@@ -103,7 +101,7 @@ async function selectOptionsBase(newValue, select, values) {
|
|
|
103
101
|
this.dispatchUIEvent(select, 'mouseup');
|
|
104
102
|
this.dispatchUIEvent(select, 'click');
|
|
105
103
|
}
|
|
106
|
-
await wait(this
|
|
104
|
+
await wait(this.config);
|
|
107
105
|
} else {
|
|
108
106
|
throw getConfig().getElementError(`Cannot select multiple options on a non-multiple select`, select);
|
|
109
107
|
}
|
package/dist/esm/utility/type.js
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
|
+
import { releaseAllKeys } from '../keyboard/index.js';
|
|
1
2
|
import '../utils/click/isClickableInput.js';
|
|
2
3
|
import '../utils/dataTransfer/Clipboard.js';
|
|
3
|
-
import '../event/eventMap.js';
|
|
4
|
-
import '../event/behavior/click.js';
|
|
5
|
-
import '../event/behavior/cut.js';
|
|
6
|
-
import '../event/behavior/keydown.js';
|
|
7
|
-
import '../event/behavior/keypress.js';
|
|
8
|
-
import '../event/behavior/keyup.js';
|
|
9
|
-
import '../event/behavior/paste.js';
|
|
10
|
-
import '@testing-library/dom';
|
|
11
|
-
import '../utils/edit/maxLength.js';
|
|
12
4
|
import '../utils/edit/isEditable.js';
|
|
13
|
-
import
|
|
5
|
+
import '../utils/edit/maxLength.js';
|
|
14
6
|
import '@testing-library/dom/dist/helpers.js';
|
|
15
7
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
16
8
|
import '../utils/misc/level.js';
|
|
17
9
|
import '../options.js';
|
|
18
|
-
import {
|
|
19
|
-
import { Config } from '../setup/config.js';
|
|
10
|
+
import { setSelectionRange } from '../event/selection/setSelectionRange.js';
|
|
20
11
|
|
|
21
|
-
async function type(element, text, { skipClick =this
|
|
12
|
+
async function type(element, text, { skipClick =this.config.skipClick , skipAutoClose =this.config.skipAutoClose , initialSelectionStart , initialSelectionEnd } = {}) {
|
|
22
13
|
// TODO: properly type guard
|
|
23
14
|
// we use this workaround for now to prevent changing behavior
|
|
24
15
|
if (element.disabled) return;
|
|
@@ -26,11 +17,11 @@ async function type(element, text, { skipClick =this[Config].skipClick , skipAut
|
|
|
26
17
|
await this.click(element);
|
|
27
18
|
}
|
|
28
19
|
if (initialSelectionStart !== undefined) {
|
|
29
|
-
setSelectionRange(element, initialSelectionStart, initialSelectionEnd
|
|
20
|
+
setSelectionRange(element, initialSelectionStart, initialSelectionEnd !== null && initialSelectionEnd !== void 0 ? initialSelectionEnd : initialSelectionStart);
|
|
30
21
|
}
|
|
31
22
|
await this.keyboard(text);
|
|
32
23
|
if (!skipAutoClose) {
|
|
33
|
-
await releaseAllKeys(this
|
|
24
|
+
await releaseAllKeys(this);
|
|
34
25
|
}
|
|
35
26
|
}
|
|
36
27
|
|
|
@@ -1,40 +1,34 @@
|
|
|
1
1
|
import '../utils/click/isClickableInput.js';
|
|
2
2
|
import { createFileList } from '../utils/dataTransfer/FileList.js';
|
|
3
3
|
import '../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../event/eventMap.js';
|
|
5
|
-
import '../event/behavior/click.js';
|
|
6
|
-
import '../event/behavior/cut.js';
|
|
7
|
-
import '../event/behavior/keydown.js';
|
|
8
|
-
import '../event/behavior/keypress.js';
|
|
9
|
-
import '../event/behavior/keyup.js';
|
|
10
|
-
import '../event/behavior/paste.js';
|
|
11
|
-
import '@testing-library/dom';
|
|
12
|
-
import '../utils/edit/maxLength.js';
|
|
13
4
|
import '../utils/edit/isEditable.js';
|
|
5
|
+
import '../utils/edit/maxLength.js';
|
|
14
6
|
import { setFiles } from '../utils/edit/setFiles.js';
|
|
15
|
-
import { isDisabled } from '../utils/misc/isDisabled.js';
|
|
16
7
|
import { isElementType } from '../utils/misc/isElementType.js';
|
|
8
|
+
import { isDisabled } from '../utils/misc/isDisabled.js';
|
|
17
9
|
import { getWindow } from '../utils/misc/getWindow.js';
|
|
18
10
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
19
11
|
import '../utils/misc/level.js';
|
|
20
12
|
import '../options.js';
|
|
21
|
-
import '../setup/index.js';
|
|
22
|
-
import { Config } from '../setup/config.js';
|
|
23
13
|
|
|
24
14
|
async function upload(element, fileOrFiles) {
|
|
25
15
|
const input = isElementType(element, 'label') ? element.control : element;
|
|
26
16
|
if (!input || !isElementType(input, 'input', {
|
|
27
17
|
type: 'file'
|
|
28
18
|
})) {
|
|
29
|
-
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input
|
|
19
|
+
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input === void 0 ? void 0 : input.tagName} element does not accept file uploads`);
|
|
30
20
|
}
|
|
31
21
|
if (isDisabled(element)) return;
|
|
32
22
|
const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [
|
|
33
23
|
fileOrFiles
|
|
34
|
-
]).filter((file)=>!this
|
|
24
|
+
]).filter((file)=>!this.config.applyAccept || isAcceptableFile(file, input.accept)).slice(0, input.multiple ? undefined : 1);
|
|
35
25
|
const fileDialog = ()=>{
|
|
26
|
+
var ref;
|
|
36
27
|
// do not fire an input event if the file selection does not change
|
|
37
|
-
if (files.length === input.files
|
|
28
|
+
if (files.length === ((ref = input.files) === null || ref === void 0 ? void 0 : ref.length) && files.every((f, i)=>{
|
|
29
|
+
var ref;
|
|
30
|
+
return f === ((ref = input.files) === null || ref === void 0 ? void 0 : ref.item(i));
|
|
31
|
+
})) {
|
|
38
32
|
return;
|
|
39
33
|
}
|
|
40
34
|
setFiles(input, createFileList(getWindow(element), files));
|