@testing-library/user-event 14.4.2 → 14.5.0
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/_interop/dtl.js +30 -0
- package/dist/cjs/_interop/dtlEventMap.js +30 -0
- package/dist/cjs/_interop/dtlHelpers.js +30 -0
- package/dist/cjs/clipboard/copy.js +6 -16
- package/dist/cjs/clipboard/cut.js +6 -16
- package/dist/cjs/clipboard/paste.js +6 -16
- package/dist/cjs/convenience/click.js +1 -4
- package/dist/cjs/convenience/hover.js +2 -12
- package/dist/cjs/convenience/tab.js +1 -1
- 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 +89 -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 -47
- package/dist/cjs/event/behavior/keypress.js +12 -12
- package/dist/cjs/event/behavior/keyup.js +6 -8
- package/dist/cjs/event/behavior/paste.js +7 -13
- package/dist/cjs/event/createEvent.js +43 -50
- package/dist/cjs/event/dispatchEvent.js +21 -3
- package/dist/cjs/event/eventMap.js +2 -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 +52 -50
- 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 +41 -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 +50 -0
- package/dist/cjs/event/selection/moveSelection.js +48 -0
- package/dist/cjs/{utils/focus → event/selection}/resolveCaretPosition.js +10 -18
- package/dist/cjs/event/selection/selectAll.js +48 -0
- package/dist/cjs/event/selection/setSelection.js +30 -0
- package/dist/cjs/event/selection/setSelectionPerMouse.js +91 -0
- package/dist/cjs/event/selection/setSelectionRange.js +40 -0
- package/dist/cjs/event/selection/updateSelectionOnFocus.js +46 -0
- package/dist/cjs/event/wrapEvent.js +3 -2
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/keyboard/index.js +13 -23
- package/dist/cjs/keyboard/parseKeyDef.js +9 -17
- package/dist/cjs/options.js +0 -28
- package/dist/cjs/pointer/index.js +28 -38
- package/dist/cjs/pointer/keyMap.js +1 -1
- package/dist/cjs/pointer/parseKeyDef.js +2 -10
- package/dist/cjs/setup/api.js +19 -17
- package/dist/cjs/setup/directApi.js +6 -6
- package/dist/cjs/setup/index.js +0 -2
- package/dist/cjs/setup/setup.js +70 -42
- package/dist/cjs/setup/wrapAsync.js +3 -2
- package/dist/cjs/system/index.js +15 -2
- package/dist/cjs/system/keyboard.js +34 -21
- package/dist/cjs/system/pointer/buttons.js +14 -1
- package/dist/cjs/system/pointer/device.js +14 -1
- package/dist/cjs/system/pointer/index.js +60 -45
- package/dist/cjs/system/pointer/mouse.js +77 -56
- package/dist/cjs/system/pointer/pointer.js +56 -42
- package/dist/cjs/system/pointer/shared.js +10 -0
- package/dist/cjs/utility/clear.js +10 -11
- package/dist/cjs/utility/selectOptions.js +28 -29
- package/dist/cjs/utility/type.js +6 -15
- package/dist/cjs/utility/upload.js +9 -18
- package/dist/cjs/utils/dataTransfer/Clipboard.js +26 -24
- package/dist/cjs/utils/dataTransfer/DataTransfer.js +25 -9
- package/dist/cjs/utils/edit/isEditable.js +6 -10
- package/dist/cjs/utils/edit/maxLength.js +6 -17
- package/dist/cjs/utils/edit/setFiles.js +4 -4
- package/dist/cjs/utils/edit/{buildTimeValue.js → timeValue.js} +6 -0
- package/dist/cjs/utils/focus/cursor.js +2 -18
- package/dist/cjs/utils/focus/getActiveElement.js +4 -3
- package/dist/cjs/utils/focus/selection.js +1 -271
- package/dist/cjs/utils/focus/selector.js +1 -1
- package/dist/cjs/utils/index.js +7 -32
- package/dist/cjs/utils/keyDef/readNextDescriptor.js +5 -5
- package/dist/cjs/utils/misc/getTreeDiff.js +3 -3
- package/dist/cjs/utils/misc/getWindow.js +3 -2
- package/dist/cjs/utils/misc/isDisabled.js +3 -3
- package/dist/cjs/utils/misc/isVisible.js +3 -2
- package/dist/cjs/utils/misc/level.js +4 -9
- package/dist/cjs/utils/misc/wait.js +1 -1
- package/dist/cjs/utils/pointer/cssPointerEvents.js +31 -40
- package/dist/esm/_interop/dtl.js +6 -0
- package/dist/esm/_interop/dtlEventMap.js +6 -0
- package/dist/esm/_interop/dtlHelpers.js +6 -0
- package/dist/esm/clipboard/copy.js +6 -16
- package/dist/esm/clipboard/cut.js +6 -16
- package/dist/esm/clipboard/paste.js +6 -16
- package/dist/esm/convenience/click.js +1 -4
- package/dist/esm/convenience/hover.js +2 -12
- package/dist/esm/convenience/tab.js +1 -1
- 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 +87 -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 -40
- package/dist/esm/event/behavior/keypress.js +12 -12
- package/dist/esm/event/behavior/keyup.js +6 -8
- package/dist/esm/event/behavior/paste.js +7 -13
- package/dist/esm/event/createEvent.js +43 -50
- package/dist/esm/event/dispatchEvent.js +20 -4
- package/dist/esm/event/eventMap.js +2 -2
- package/dist/esm/event/focus.js +39 -0
- package/dist/esm/event/index.js +14 -19
- package/dist/esm/{utils/edit → event}/input.js +39 -37
- 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 +37 -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 +46 -0
- package/dist/esm/event/selection/moveSelection.js +44 -0
- package/dist/esm/{utils/focus → event/selection}/resolveCaretPosition.js +9 -17
- package/dist/esm/event/selection/selectAll.js +43 -0
- package/dist/esm/event/selection/setSelection.js +26 -0
- package/dist/esm/event/selection/setSelectionPerMouse.js +87 -0
- package/dist/esm/event/selection/setSelectionRange.js +36 -0
- package/dist/esm/event/selection/updateSelectionOnFocus.js +42 -0
- package/dist/esm/event/wrapEvent.js +2 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/keyboard/index.js +13 -23
- package/dist/esm/keyboard/parseKeyDef.js +9 -17
- package/dist/esm/options.js +1 -26
- package/dist/esm/pointer/index.js +28 -38
- package/dist/esm/pointer/keyMap.js +1 -1
- package/dist/esm/pointer/parseKeyDef.js +2 -10
- package/dist/esm/setup/api.js +33 -12
- package/dist/esm/setup/directApi.js +6 -6
- package/dist/esm/setup/index.js +0 -1
- package/dist/esm/setup/setup.js +66 -39
- package/dist/esm/setup/wrapAsync.js +2 -1
- package/dist/esm/system/index.js +15 -2
- package/dist/esm/system/keyboard.js +34 -21
- package/dist/esm/system/pointer/buttons.js +14 -1
- package/dist/esm/system/pointer/device.js +14 -1
- package/dist/esm/system/pointer/index.js +61 -45
- package/dist/esm/system/pointer/mouse.js +74 -53
- package/dist/esm/system/pointer/pointer.js +55 -41
- package/dist/esm/system/pointer/shared.js +6 -0
- package/dist/esm/utility/clear.js +10 -11
- package/dist/esm/utility/selectOptions.js +24 -25
- package/dist/esm/utility/type.js +5 -14
- package/dist/esm/utility/upload.js +9 -18
- package/dist/esm/utils/dataTransfer/Clipboard.js +26 -24
- package/dist/esm/utils/dataTransfer/DataTransfer.js +25 -9
- package/dist/esm/utils/edit/isEditable.js +4 -8
- package/dist/esm/utils/edit/maxLength.js +5 -17
- package/dist/esm/utils/edit/setFiles.js +4 -4
- package/dist/esm/utils/edit/{buildTimeValue.js → timeValue.js} +6 -1
- package/dist/esm/utils/focus/cursor.js +2 -18
- package/dist/esm/utils/focus/getActiveElement.js +4 -3
- package/dist/esm/utils/focus/selection.js +3 -265
- package/dist/esm/utils/focus/selector.js +1 -1
- package/dist/esm/utils/index.js +4 -11
- package/dist/esm/utils/keyDef/readNextDescriptor.js +5 -5
- package/dist/esm/utils/misc/getTreeDiff.js +3 -3
- package/dist/esm/utils/misc/getWindow.js +2 -1
- package/dist/esm/utils/misc/isDisabled.js +3 -3
- package/dist/esm/utils/misc/isVisible.js +3 -2
- package/dist/esm/utils/misc/level.js +4 -9
- package/dist/esm/utils/misc/wait.js +1 -1
- package/dist/esm/utils/pointer/cssPointerEvents.js +31 -40
- package/dist/types/_interop/dtl.d.ts +3 -0
- package/dist/types/_interop/dtlEventMap.d.ts +3 -0
- package/dist/types/_interop/dtlHelpers.d.ts +3 -0
- 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/convenience/tab.d.ts +1 -1
- package/dist/types/document/UI.d.ts +42 -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 +6 -3
- 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/createEvent.d.ts +1 -1
- package/dist/types/event/dispatchEvent.d.ts +5 -2
- package/dist/types/event/eventMap.d.ts +8 -0
- 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/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/event/types.d.ts +3 -3
- package/dist/types/index.d.ts +3 -1
- package/dist/types/keyboard/index.d.ts +2 -2
- package/dist/types/options.d.ts +2 -10
- package/dist/types/pointer/index.d.ts +7 -7
- package/dist/types/setup/api.d.ts +23 -5
- package/dist/types/setup/directApi.d.ts +5 -5
- 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 +4 -4
- package/dist/types/system/pointer/buttons.d.ts +2 -2
- package/dist/types/system/pointer/device.d.ts +1 -1
- package/dist/types/system/pointer/index.d.ts +7 -25
- package/dist/types/system/pointer/mouse.d.ts +6 -6
- package/dist/types/system/pointer/pointer.d.ts +8 -8
- 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 +4 -4
- package/dist/types/utility/upload.d.ts +1 -1
- package/dist/types/utils/click/isClickableInput.d.ts +2 -2
- package/dist/types/utils/dataTransfer/Clipboard.d.ts +1 -1
- package/dist/types/utils/edit/isEditable.d.ts +6 -7
- 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/keyDef/readNextDescriptor.d.ts +1 -1
- package/dist/types/utils/misc/isElementType.d.ts +1 -1
- 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 +24 -12
- package/dist/cjs/document/selection.js +0 -108
- package/dist/cjs/document/setRangeText.js +0 -21
- package/dist/cjs/document/value.js +0 -127
- 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 -29
- package/dist/cjs/utils/focus/selectAll.js +0 -56
- package/dist/cjs/utils/misc/eventWrapper.js +0 -15
- package/dist/esm/document/selection.js +0 -100
- package/dist/esm/document/setRangeText.js +0 -17
- package/dist/esm/document/value.js +0 -117
- 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 -25
- package/dist/esm/utils/focus/selectAll.js +0 -51
- 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
- /package/dist/cjs/{event → _interop}/dom-events.d.js +0 -0
- /package/dist/cjs/{utils/misc → _interop}/dom-helpers.d.js +0 -0
- /package/dist/esm/{event → _interop}/dom-events.d.js +0 -0
- /package/dist/esm/{utils/misc → _interop}/dom-helpers.d.js +0 -0
- /package/dist/types/{utils/focus → document}/copySelection.d.ts +0 -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
|
@@ -1,16 +1,26 @@
|
|
|
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 { getActiveElementOrBody } from '../utils/focus/getActiveElement.js';
|
|
8
6
|
import '@testing-library/dom/dist/helpers.js';
|
|
9
7
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
10
8
|
import '../utils/misc/level.js';
|
|
11
9
|
import '../options.js';
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
function _define_property(obj, key, value) {
|
|
12
|
+
if (key in obj) {
|
|
13
|
+
Object.defineProperty(obj, key, {
|
|
14
|
+
value: value,
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true
|
|
18
|
+
});
|
|
19
|
+
} else {
|
|
20
|
+
obj[key] = value;
|
|
21
|
+
}
|
|
22
|
+
return obj;
|
|
23
|
+
}
|
|
14
24
|
var DOM_KEY_LOCATION;
|
|
15
25
|
(function(DOM_KEY_LOCATION) {
|
|
16
26
|
DOM_KEY_LOCATION[DOM_KEY_LOCATION["STANDARD"] = 0] = "STANDARD";
|
|
@@ -25,7 +35,7 @@ const modifierKeys = [
|
|
|
25
35
|
'Fn',
|
|
26
36
|
'Meta',
|
|
27
37
|
'Shift',
|
|
28
|
-
'Symbol'
|
|
38
|
+
'Symbol'
|
|
29
39
|
];
|
|
30
40
|
function isModifierKey(key) {
|
|
31
41
|
return modifierKeys.includes(key);
|
|
@@ -35,7 +45,7 @@ const modifierLocks = [
|
|
|
35
45
|
'FnLock',
|
|
36
46
|
'NumLock',
|
|
37
47
|
'ScrollLock',
|
|
38
|
-
'SymbolLock'
|
|
48
|
+
'SymbolLock'
|
|
39
49
|
];
|
|
40
50
|
function isModifierLock(key) {
|
|
41
51
|
return modifierLocks.includes(key);
|
|
@@ -47,20 +57,22 @@ class KeyboardHost {
|
|
|
47
57
|
getPressedKeys() {
|
|
48
58
|
return Object.values(this.pressed).map((p)=>p.keyDef);
|
|
49
59
|
}
|
|
50
|
-
/** Press a key */ async keydown(
|
|
60
|
+
/** Press a key */ async keydown(instance, keyDef) {
|
|
61
|
+
var // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
62
|
+
_this_pressed, _code, _this_pressed_code;
|
|
51
63
|
const key = String(keyDef.key);
|
|
52
64
|
const code = String(keyDef.code);
|
|
53
|
-
const target = getActiveElementOrBody(config.document);
|
|
65
|
+
const target = getActiveElementOrBody(instance.config.document);
|
|
54
66
|
this.setKeydownTarget(target);
|
|
55
|
-
var
|
|
56
|
-
(
|
|
67
|
+
var _;
|
|
68
|
+
(_ = (_this_pressed = this.pressed)[_code = code]) !== null && _ !== void 0 ? _ : _this_pressed[_code] = {
|
|
57
69
|
keyDef,
|
|
58
70
|
unpreventedDefault: false
|
|
59
71
|
};
|
|
60
72
|
if (isModifierKey(key)) {
|
|
61
73
|
this.modifiers[key] = true;
|
|
62
74
|
}
|
|
63
|
-
const unprevented = dispatchUIEvent(
|
|
75
|
+
const unprevented = instance.dispatchUIEvent(target, 'keydown', {
|
|
64
76
|
key,
|
|
65
77
|
code
|
|
66
78
|
});
|
|
@@ -68,16 +80,16 @@ class KeyboardHost {
|
|
|
68
80
|
this.modifiers[key] = true;
|
|
69
81
|
this.modifierLockStart[key] = true;
|
|
70
82
|
}
|
|
71
|
-
(
|
|
83
|
+
(_this_pressed_code = this.pressed[code]).unpreventedDefault || (_this_pressed_code.unpreventedDefault = unprevented);
|
|
72
84
|
if (unprevented && this.hasKeyPress(key)) {
|
|
73
|
-
dispatchUIEvent(
|
|
85
|
+
instance.dispatchUIEvent(getActiveElementOrBody(instance.config.document), 'keypress', {
|
|
74
86
|
key,
|
|
75
87
|
code,
|
|
76
88
|
charCode: keyDef.key === 'Enter' ? 13 : String(keyDef.key).charCodeAt(0)
|
|
77
89
|
});
|
|
78
90
|
}
|
|
79
91
|
}
|
|
80
|
-
/** Release a key */ async keyup(
|
|
92
|
+
/** Release a key */ async keyup(instance, keyDef) {
|
|
81
93
|
const key = String(keyDef.key);
|
|
82
94
|
const code = String(keyDef.code);
|
|
83
95
|
const unprevented = this.pressed[code].unpreventedDefault;
|
|
@@ -86,7 +98,7 @@ class KeyboardHost {
|
|
|
86
98
|
if (isModifierKey(key) && !Object.values(this.pressed).find((p)=>p.keyDef.key === key)) {
|
|
87
99
|
this.modifiers[key] = false;
|
|
88
100
|
}
|
|
89
|
-
dispatchUIEvent(
|
|
101
|
+
instance.dispatchUIEvent(getActiveElementOrBody(instance.config.document), 'keyup', {
|
|
90
102
|
key,
|
|
91
103
|
code
|
|
92
104
|
}, !unprevented);
|
|
@@ -108,7 +120,8 @@ class KeyboardHost {
|
|
|
108
120
|
return (key.length === 1 || key === 'Enter') && !this.modifiers.Control && !this.modifiers.Alt;
|
|
109
121
|
}
|
|
110
122
|
constructor(system){
|
|
111
|
-
this
|
|
123
|
+
_define_property(this, "system", void 0);
|
|
124
|
+
_define_property(this, "modifiers", {
|
|
112
125
|
Alt: false,
|
|
113
126
|
AltGraph: false,
|
|
114
127
|
CapsLock: false,
|
|
@@ -121,11 +134,11 @@ class KeyboardHost {
|
|
|
121
134
|
Shift: false,
|
|
122
135
|
Symbol: false,
|
|
123
136
|
SymbolLock: false
|
|
124
|
-
};
|
|
125
|
-
this
|
|
126
|
-
this
|
|
127
|
-
this
|
|
128
|
-
this
|
|
137
|
+
});
|
|
138
|
+
_define_property(this, "pressed", {});
|
|
139
|
+
_define_property(this, "carryChar", '');
|
|
140
|
+
_define_property(this, "lastKeydownTarget", undefined);
|
|
141
|
+
_define_property(this, "modifierLockStart", {});
|
|
129
142
|
this.system = system;
|
|
130
143
|
}
|
|
131
144
|
}
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
1
14
|
class Buttons {
|
|
2
15
|
getButtons() {
|
|
3
16
|
let v = 0;
|
|
@@ -31,7 +44,7 @@ class Buttons {
|
|
|
31
44
|
return undefined;
|
|
32
45
|
}
|
|
33
46
|
constructor(){
|
|
34
|
-
this
|
|
47
|
+
_define_property(this, "pressed", {});
|
|
35
48
|
}
|
|
36
49
|
}
|
|
37
50
|
const MouseButton = {
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
1
14
|
class Device {
|
|
2
15
|
get countPressed() {
|
|
3
16
|
return this.pressedKeys.size;
|
|
@@ -12,7 +25,7 @@ class Device {
|
|
|
12
25
|
return this.pressedKeys.delete(keyDef.name);
|
|
13
26
|
}
|
|
14
27
|
constructor(){
|
|
15
|
-
this
|
|
28
|
+
_define_property(this, "pressedKeys", new Set());
|
|
16
29
|
}
|
|
17
30
|
}
|
|
18
31
|
|
|
@@ -3,14 +3,26 @@ import { Device } from './device.js';
|
|
|
3
3
|
import { Mouse } from './mouse.js';
|
|
4
4
|
import { Pointer } from './pointer.js';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
function _define_property(obj, key, value) {
|
|
7
|
+
if (key in obj) {
|
|
8
|
+
Object.defineProperty(obj, key, {
|
|
9
|
+
value: value,
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
writable: true
|
|
13
|
+
});
|
|
14
|
+
} else {
|
|
15
|
+
obj[key] = value;
|
|
16
|
+
}
|
|
17
|
+
return obj;
|
|
18
|
+
}
|
|
7
19
|
class PointerHost {
|
|
8
20
|
isKeyPressed(keyDef) {
|
|
9
21
|
return this.devices.get(keyDef.pointerType).isPressed(keyDef);
|
|
10
22
|
}
|
|
11
|
-
async press(
|
|
23
|
+
async press(instance, keyDef, position) {
|
|
12
24
|
const pointerName = this.getPointerName(keyDef);
|
|
13
|
-
const pointer = keyDef.pointerType === 'touch' ? this.pointers.new(pointerName, keyDef).init(
|
|
25
|
+
const pointer = keyDef.pointerType === 'touch' ? this.pointers.new(pointerName, keyDef).init(instance, position) : this.pointers.get(pointerName);
|
|
14
26
|
// TODO: deprecate the following implicit setting of position
|
|
15
27
|
pointer.position = position;
|
|
16
28
|
if (pointer.pointerType !== 'touch') {
|
|
@@ -18,27 +30,28 @@ class PointerHost {
|
|
|
18
30
|
}
|
|
19
31
|
this.devices.get(keyDef.pointerType).addPressed(keyDef);
|
|
20
32
|
this.buttons.down(keyDef);
|
|
21
|
-
pointer.down(
|
|
33
|
+
pointer.down(instance, keyDef);
|
|
22
34
|
if (pointer.pointerType !== 'touch' && !pointer.isPrevented) {
|
|
23
|
-
this.mouse.down(
|
|
35
|
+
this.mouse.down(instance, keyDef, pointer);
|
|
24
36
|
}
|
|
25
37
|
}
|
|
26
|
-
async move(
|
|
38
|
+
async move(instance, pointerName, position) {
|
|
39
|
+
var _pointermove, _mousemove, _pointermove1, _mousemove1, _pointermove2, _mousemove2;
|
|
27
40
|
const pointer = this.pointers.get(pointerName);
|
|
28
41
|
// In (some?) browsers this order of events can be observed.
|
|
29
42
|
// This interweaving of events is probably unnecessary.
|
|
30
43
|
// While the order of mouse (or pointer) events is defined per spec,
|
|
31
44
|
// the order in which they interweave/follow on a user interaction depends on the implementation.
|
|
32
|
-
const pointermove = pointer.move(
|
|
33
|
-
const mousemove = pointer.pointerType === 'touch' || pointer.isPrevented && pointer.isDown ? undefined : this.mouse.move(
|
|
34
|
-
pointermove === null ||
|
|
35
|
-
mousemove === null ||
|
|
36
|
-
pointermove === null ||
|
|
37
|
-
mousemove === null ||
|
|
38
|
-
pointermove === null ||
|
|
39
|
-
mousemove === null ||
|
|
45
|
+
const pointermove = pointer.move(instance, position);
|
|
46
|
+
const mousemove = pointer.pointerType === 'touch' || pointer.isPrevented && pointer.isDown ? undefined : this.mouse.move(instance, position);
|
|
47
|
+
(_pointermove = pointermove) === null || _pointermove === void 0 ? void 0 : _pointermove.leave();
|
|
48
|
+
(_mousemove = mousemove) === null || _mousemove === void 0 ? void 0 : _mousemove.leave();
|
|
49
|
+
(_pointermove1 = pointermove) === null || _pointermove1 === void 0 ? void 0 : _pointermove1.enter();
|
|
50
|
+
(_mousemove1 = mousemove) === null || _mousemove1 === void 0 ? void 0 : _mousemove1.enter();
|
|
51
|
+
(_pointermove2 = pointermove) === null || _pointermove2 === void 0 ? void 0 : _pointermove2.move();
|
|
52
|
+
(_mousemove2 = mousemove) === null || _mousemove2 === void 0 ? void 0 : _mousemove2.move();
|
|
40
53
|
}
|
|
41
|
-
async release(
|
|
54
|
+
async release(instance, keyDef, position) {
|
|
42
55
|
const device = this.devices.get(keyDef.pointerType);
|
|
43
56
|
device.removePressed(keyDef);
|
|
44
57
|
this.buttons.up(keyDef);
|
|
@@ -49,25 +62,27 @@ class PointerHost {
|
|
|
49
62
|
this.mouse.position = position;
|
|
50
63
|
}
|
|
51
64
|
if (device.countPressed === 0) {
|
|
52
|
-
pointer.up(
|
|
65
|
+
pointer.up(instance, keyDef);
|
|
53
66
|
}
|
|
54
67
|
if (pointer.pointerType === 'touch') {
|
|
55
|
-
pointer.release(
|
|
68
|
+
pointer.release(instance);
|
|
56
69
|
}
|
|
57
70
|
if (!pointer.isPrevented) {
|
|
58
71
|
if (pointer.pointerType === 'touch' && !pointer.isMultitouch) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
mousemove === null ||
|
|
62
|
-
mousemove === null ||
|
|
63
|
-
|
|
72
|
+
var _mousemove, _mousemove1, _mousemove2;
|
|
73
|
+
const mousemove = this.mouse.move(instance, pointer.position);
|
|
74
|
+
(_mousemove = mousemove) === null || _mousemove === void 0 ? void 0 : _mousemove.leave();
|
|
75
|
+
(_mousemove1 = mousemove) === null || _mousemove1 === void 0 ? void 0 : _mousemove1.enter();
|
|
76
|
+
(_mousemove2 = mousemove) === null || _mousemove2 === void 0 ? void 0 : _mousemove2.move();
|
|
77
|
+
this.mouse.down(instance, keyDef, pointer);
|
|
64
78
|
}
|
|
65
79
|
if (!pointer.isMultitouch) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
80
|
+
var _mousemove3, _mousemove4, _mousemove5;
|
|
81
|
+
const mousemove = this.mouse.move(instance, pointer.position);
|
|
82
|
+
(_mousemove3 = mousemove) === null || _mousemove3 === void 0 ? void 0 : _mousemove3.leave();
|
|
83
|
+
(_mousemove4 = mousemove) === null || _mousemove4 === void 0 ? void 0 : _mousemove4.enter();
|
|
84
|
+
(_mousemove5 = mousemove) === null || _mousemove5 === void 0 ? void 0 : _mousemove5.move();
|
|
85
|
+
this.mouse.up(instance, keyDef, pointer);
|
|
71
86
|
}
|
|
72
87
|
}
|
|
73
88
|
}
|
|
@@ -80,26 +95,31 @@ class PointerHost {
|
|
|
80
95
|
resetClickCount() {
|
|
81
96
|
this.mouse.resetClickCount();
|
|
82
97
|
}
|
|
83
|
-
getMouseTarget(
|
|
84
|
-
var
|
|
85
|
-
return (
|
|
98
|
+
getMouseTarget(instance) {
|
|
99
|
+
var _this_mouse_position_target;
|
|
100
|
+
return (_this_mouse_position_target = this.mouse.position.target) !== null && _this_mouse_position_target !== void 0 ? _this_mouse_position_target : instance.config.document.body;
|
|
86
101
|
}
|
|
87
102
|
setMousePosition(position) {
|
|
88
103
|
this.mouse.position = position;
|
|
89
104
|
this.pointers.get('mouse').position = position;
|
|
90
105
|
}
|
|
91
106
|
constructor(system){
|
|
92
|
-
this
|
|
107
|
+
_define_property(this, "system", void 0);
|
|
108
|
+
_define_property(this, "mouse", void 0);
|
|
109
|
+
_define_property(this, "buttons", void 0);
|
|
110
|
+
_define_property(this, "devices", new class {
|
|
93
111
|
get(k) {
|
|
94
|
-
var
|
|
95
|
-
|
|
112
|
+
var // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
113
|
+
_this_registry, _k;
|
|
114
|
+
var _;
|
|
115
|
+
(_ = (_this_registry = this.registry)[_k = k]) !== null && _ !== void 0 ? _ : _this_registry[_k] = new Device();
|
|
96
116
|
return this.registry[k];
|
|
97
117
|
}
|
|
98
118
|
constructor(){
|
|
99
|
-
this
|
|
119
|
+
_define_property(this, "registry", {});
|
|
100
120
|
}
|
|
101
|
-
}();
|
|
102
|
-
this
|
|
121
|
+
}());
|
|
122
|
+
_define_property(this, "pointers", new class {
|
|
103
123
|
new(pointerName, keyDef) {
|
|
104
124
|
const isPrimary = keyDef.pointerType !== 'touch' || !Object.values(this.registry).some((p)=>p.pointerType === 'touch' && !p.isCancelled);
|
|
105
125
|
if (!isPrimary) {
|
|
@@ -126,24 +146,20 @@ class PointerHost {
|
|
|
126
146
|
return pointerName in this.registry;
|
|
127
147
|
}
|
|
128
148
|
constructor(){
|
|
129
|
-
this
|
|
149
|
+
_define_property(this, "registry", {
|
|
130
150
|
mouse: new Pointer({
|
|
131
151
|
pointerId: 1,
|
|
132
152
|
pointerType: 'mouse',
|
|
133
153
|
isPrimary: true
|
|
134
154
|
})
|
|
135
|
-
};
|
|
136
|
-
this
|
|
155
|
+
});
|
|
156
|
+
_define_property(this, "nextId", 2);
|
|
137
157
|
}
|
|
138
|
-
}();
|
|
158
|
+
}());
|
|
139
159
|
this.system = system;
|
|
140
160
|
this.buttons = new Buttons();
|
|
141
161
|
this.mouse = new Mouse();
|
|
142
162
|
}
|
|
143
163
|
}
|
|
144
|
-
function isDifferentPointerPosition(positionA, positionB) {
|
|
145
|
-
var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
|
|
146
|
-
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);
|
|
147
|
-
}
|
|
148
164
|
|
|
149
|
-
export { PointerHost
|
|
165
|
+
export { PointerHost };
|
|
@@ -1,85 +1,105 @@
|
|
|
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 {
|
|
19
|
+
import { focusElement } from '../../event/focus.js';
|
|
20
|
+
import { setSelectionPerMouseDown } from '../../event/selection/setSelectionPerMouse.js';
|
|
21
|
+
import { modifySelectionPerMouseMove } from '../../event/selection/modifySelectionPerMouse.js';
|
|
16
22
|
import { getMouseEventButton, Buttons } from './buttons.js';
|
|
23
|
+
import { isDifferentPointerPosition } from './shared.js';
|
|
17
24
|
|
|
25
|
+
function _define_property(obj, key, value) {
|
|
26
|
+
if (key in obj) {
|
|
27
|
+
Object.defineProperty(obj, key, {
|
|
28
|
+
value: value,
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true
|
|
32
|
+
});
|
|
33
|
+
} else {
|
|
34
|
+
obj[key] = value;
|
|
35
|
+
}
|
|
36
|
+
return obj;
|
|
37
|
+
}
|
|
18
38
|
/**
|
|
19
39
|
* This object is the single "virtual" mouse that might be controlled by multiple different pointer devices.
|
|
20
40
|
*/ class Mouse {
|
|
21
|
-
move(
|
|
41
|
+
move(instance, position) {
|
|
22
42
|
const prevPosition = this.position;
|
|
23
|
-
const prevTarget = this.getTarget(
|
|
43
|
+
const prevTarget = this.getTarget(instance);
|
|
24
44
|
this.position = position;
|
|
25
45
|
if (!isDifferentPointerPosition(prevPosition, position)) {
|
|
26
46
|
return;
|
|
27
47
|
}
|
|
28
|
-
const nextTarget = this.getTarget(
|
|
48
|
+
const nextTarget = this.getTarget(instance);
|
|
29
49
|
const init = this.getEventInit('mousemove');
|
|
30
50
|
const [leave, enter] = getTreeDiff(prevTarget, nextTarget);
|
|
31
51
|
return {
|
|
32
52
|
leave: ()=>{
|
|
33
53
|
if (prevTarget !== nextTarget) {
|
|
34
|
-
dispatchUIEvent(
|
|
35
|
-
leave.forEach((el)=>dispatchUIEvent(
|
|
54
|
+
instance.dispatchUIEvent(prevTarget, 'mouseout', init);
|
|
55
|
+
leave.forEach((el)=>instance.dispatchUIEvent(el, 'mouseleave', init));
|
|
36
56
|
}
|
|
37
57
|
},
|
|
38
58
|
enter: ()=>{
|
|
39
59
|
if (prevTarget !== nextTarget) {
|
|
40
|
-
dispatchUIEvent(
|
|
41
|
-
enter.forEach((el)=>dispatchUIEvent(
|
|
60
|
+
instance.dispatchUIEvent(nextTarget, 'mouseover', init);
|
|
61
|
+
enter.forEach((el)=>instance.dispatchUIEvent(el, 'mouseenter', init));
|
|
42
62
|
}
|
|
43
63
|
},
|
|
44
64
|
move: ()=>{
|
|
45
|
-
dispatchUIEvent(
|
|
46
|
-
this.modifySelecting(
|
|
65
|
+
instance.dispatchUIEvent(nextTarget, 'mousemove', init);
|
|
66
|
+
this.modifySelecting(instance);
|
|
47
67
|
}
|
|
48
68
|
};
|
|
49
69
|
}
|
|
50
|
-
down(
|
|
70
|
+
down(instance, keyDef, pointer) {
|
|
51
71
|
const button = this.buttons.down(keyDef);
|
|
52
72
|
if (button === undefined) {
|
|
53
73
|
return;
|
|
54
74
|
}
|
|
55
|
-
const target = this.getTarget(
|
|
75
|
+
const target = this.getTarget(instance);
|
|
56
76
|
this.buttonDownTarget[button] = target;
|
|
57
77
|
const disabled = isDisabled(target);
|
|
58
78
|
const init = this.getEventInit('mousedown', keyDef.button);
|
|
59
|
-
if (disabled || dispatchUIEvent(
|
|
60
|
-
this.startSelecting(
|
|
61
|
-
|
|
79
|
+
if (disabled || instance.dispatchUIEvent(target, 'mousedown', init)) {
|
|
80
|
+
this.startSelecting(instance, init.detail);
|
|
81
|
+
focusElement(target);
|
|
62
82
|
}
|
|
63
83
|
if (!disabled && getMouseEventButton(keyDef.button) === 2) {
|
|
64
|
-
dispatchUIEvent(
|
|
84
|
+
instance.dispatchUIEvent(target, 'contextmenu', this.getEventInit('contextmenu', keyDef.button, pointer));
|
|
65
85
|
}
|
|
66
86
|
}
|
|
67
|
-
up(
|
|
87
|
+
up(instance, keyDef, pointer) {
|
|
68
88
|
const button = this.buttons.up(keyDef);
|
|
69
89
|
if (button === undefined) {
|
|
70
90
|
return;
|
|
71
91
|
}
|
|
72
|
-
const target = this.getTarget(
|
|
92
|
+
const target = this.getTarget(instance);
|
|
73
93
|
if (!isDisabled(target)) {
|
|
74
|
-
dispatchUIEvent(
|
|
94
|
+
instance.dispatchUIEvent(target, 'mouseup', this.getEventInit('mouseup', keyDef.button));
|
|
75
95
|
this.endSelecting();
|
|
76
96
|
const clickTarget = getTreeDiff(this.buttonDownTarget[button], target)[2][0];
|
|
77
97
|
if (clickTarget) {
|
|
78
98
|
const init = this.getEventInit('click', keyDef.button, pointer);
|
|
79
99
|
if (init.detail) {
|
|
80
|
-
dispatchUIEvent(
|
|
100
|
+
instance.dispatchUIEvent(clickTarget, init.button === 0 ? 'click' : 'auxclick', init);
|
|
81
101
|
if (init.button === 0 && init.detail === 2) {
|
|
82
|
-
dispatchUIEvent(
|
|
102
|
+
instance.dispatchUIEvent(clickTarget, 'dblclick', {
|
|
83
103
|
...this.getEventInit('dblclick', keyDef.button),
|
|
84
104
|
detail: init.detail
|
|
85
105
|
});
|
|
@@ -111,40 +131,41 @@ import { getMouseEventButton, Buttons } from './buttons.js';
|
|
|
111
131
|
}
|
|
112
132
|
return init;
|
|
113
133
|
}
|
|
114
|
-
getTarget(
|
|
115
|
-
var
|
|
116
|
-
return (
|
|
134
|
+
getTarget(instance) {
|
|
135
|
+
var _this_position_target;
|
|
136
|
+
return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body;
|
|
117
137
|
}
|
|
118
|
-
startSelecting(
|
|
119
|
-
var
|
|
138
|
+
startSelecting(instance, clickCount) {
|
|
139
|
+
var _this_position_caret, _this_position_caret1;
|
|
120
140
|
// TODO: support extending range (shift)
|
|
121
141
|
this.selecting = setSelectionPerMouseDown({
|
|
122
|
-
document: config.document,
|
|
123
|
-
target: this.getTarget(
|
|
124
|
-
node: (
|
|
125
|
-
offset: (
|
|
142
|
+
document: instance.config.document,
|
|
143
|
+
target: this.getTarget(instance),
|
|
144
|
+
node: (_this_position_caret = this.position.caret) === null || _this_position_caret === void 0 ? void 0 : _this_position_caret.node,
|
|
145
|
+
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === void 0 ? void 0 : _this_position_caret1.offset,
|
|
126
146
|
clickCount
|
|
127
147
|
});
|
|
128
148
|
}
|
|
129
|
-
modifySelecting(
|
|
130
|
-
var
|
|
149
|
+
modifySelecting(instance) {
|
|
150
|
+
var _this_position_caret, _this_position_caret1;
|
|
131
151
|
if (!this.selecting) {
|
|
132
152
|
return;
|
|
133
153
|
}
|
|
134
154
|
modifySelectionPerMouseMove(this.selecting, {
|
|
135
|
-
document: config.document,
|
|
136
|
-
target: this.getTarget(
|
|
137
|
-
node: (
|
|
138
|
-
offset: (
|
|
155
|
+
document: instance.config.document,
|
|
156
|
+
target: this.getTarget(instance),
|
|
157
|
+
node: (_this_position_caret = this.position.caret) === null || _this_position_caret === void 0 ? void 0 : _this_position_caret.node,
|
|
158
|
+
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === void 0 ? void 0 : _this_position_caret1.offset
|
|
139
159
|
});
|
|
140
160
|
}
|
|
141
161
|
endSelecting() {
|
|
142
162
|
this.selecting = undefined;
|
|
143
163
|
}
|
|
144
164
|
constructor(){
|
|
145
|
-
this
|
|
146
|
-
this
|
|
147
|
-
this
|
|
165
|
+
_define_property(this, "position", {});
|
|
166
|
+
_define_property(this, "buttons", new Buttons());
|
|
167
|
+
_define_property(this, "selecting", void 0);
|
|
168
|
+
_define_property(this, "buttonDownTarget", {});
|
|
148
169
|
// According to spec the `detail` on click events should be the number
|
|
149
170
|
// of *consecutive* clicks with a specific button.
|
|
150
171
|
// On `mousedown` and `mouseup` it should be this number increased by one.
|
|
@@ -155,7 +176,7 @@ import { getMouseEventButton, Buttons } from './buttons.js';
|
|
|
155
176
|
// If there is a delay while a button is pressed,
|
|
156
177
|
// the `mouseup` and `click` are normal, but a following `mousedown` starts a new click count.
|
|
157
178
|
// We'll follow the minimal implementation of Webkit.
|
|
158
|
-
this
|
|
179
|
+
_define_property(this, "clickCount", new class {
|
|
159
180
|
incOnClick(button) {
|
|
160
181
|
const current = this.down[button] === undefined ? undefined : Number(this.down[button]) + 1;
|
|
161
182
|
this.count = this.count[button] === undefined ? {} : {
|
|
@@ -164,13 +185,13 @@ import { getMouseEventButton, Buttons } from './buttons.js';
|
|
|
164
185
|
return current;
|
|
165
186
|
}
|
|
166
187
|
getOnDown(button) {
|
|
167
|
-
var
|
|
188
|
+
var _this_count_button;
|
|
168
189
|
this.down = {
|
|
169
|
-
[button]: (
|
|
190
|
+
[button]: (_this_count_button = this.count[button]) !== null && _this_count_button !== void 0 ? _this_count_button : 0
|
|
170
191
|
};
|
|
171
|
-
var
|
|
192
|
+
var _this_count_button1;
|
|
172
193
|
this.count = {
|
|
173
|
-
[button]: (
|
|
194
|
+
[button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !== void 0 ? _this_count_button1 : 0
|
|
174
195
|
};
|
|
175
196
|
return Number(this.count[button]) + 1;
|
|
176
197
|
}
|
|
@@ -181,10 +202,10 @@ import { getMouseEventButton, Buttons } from './buttons.js';
|
|
|
181
202
|
this.count = {};
|
|
182
203
|
}
|
|
183
204
|
constructor(){
|
|
184
|
-
this
|
|
185
|
-
this
|
|
205
|
+
_define_property(this, "down", {});
|
|
206
|
+
_define_property(this, "count", {});
|
|
186
207
|
}
|
|
187
|
-
}();
|
|
208
|
+
}());
|
|
188
209
|
}
|
|
189
210
|
}
|
|
190
211
|
|