@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
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import '../../utils/click/isClickableInput.js';
|
|
2
|
+
import '../../utils/dataTransfer/Clipboard.js';
|
|
3
|
+
import { getContentEditable } from '../../utils/edit/isContentEditable.js';
|
|
4
|
+
import '../../utils/edit/isEditable.js';
|
|
5
|
+
import '../../utils/edit/maxLength.js';
|
|
6
|
+
import '@testing-library/dom/dist/helpers.js';
|
|
7
|
+
import { hasOwnSelection } from '../../utils/focus/selection.js';
|
|
8
|
+
import '../../utils/keyDef/readNextDescriptor.js';
|
|
9
|
+
import '../../utils/misc/level.js';
|
|
10
|
+
import '../../options.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Reset the Document Selection when moving focus into an element
|
|
14
|
+
* with own selection implementation.
|
|
15
|
+
*/ function updateSelectionOnFocus(element) {
|
|
16
|
+
var _selection;
|
|
17
|
+
const selection = element.ownerDocument.getSelection();
|
|
18
|
+
/* istanbul ignore if */ if (!((_selection = selection) === null || _selection === void 0 ? void 0 : _selection.focusNode)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
// If the focus moves inside an element with own selection implementation,
|
|
22
|
+
// the document selection will be this element.
|
|
23
|
+
// But if the focused element is inside a contenteditable,
|
|
24
|
+
// 1) a collapsed selection will be retained.
|
|
25
|
+
// 2) other selections will be replaced by a cursor
|
|
26
|
+
// 2.a) at the start of the first child if it is a text node
|
|
27
|
+
// 2.b) at the start of the contenteditable.
|
|
28
|
+
if (hasOwnSelection(element)) {
|
|
29
|
+
const contenteditable = getContentEditable(selection.focusNode);
|
|
30
|
+
if (contenteditable) {
|
|
31
|
+
if (!selection.isCollapsed) {
|
|
32
|
+
var _contenteditable_firstChild;
|
|
33
|
+
const focusNode = ((_contenteditable_firstChild = contenteditable.firstChild) === null || _contenteditable_firstChild === void 0 ? void 0 : _contenteditable_firstChild.nodeType) === 3 ? contenteditable.firstChild : contenteditable;
|
|
34
|
+
selection.setBaseAndExtent(focusNode, 0, focusNode, 0);
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
selection.setBaseAndExtent(element, 0, element, 0);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { updateSelectionOnFocus };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { userEvent as default } from './setup/index.js';
|
|
1
|
+
export { userEvent as default, userEvent } from './setup/index.js';
|
|
2
2
|
export { PointerEventsCheckLevel } from './options.js';
|
|
@@ -1,53 +1,43 @@
|
|
|
1
|
-
import '../setup/index.js';
|
|
2
1
|
import '../utils/click/isClickableInput.js';
|
|
3
2
|
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
3
|
import '../utils/edit/isEditable.js';
|
|
4
|
+
import '../utils/edit/maxLength.js';
|
|
14
5
|
import '@testing-library/dom/dist/helpers.js';
|
|
15
6
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
16
7
|
import '../utils/misc/level.js';
|
|
17
8
|
import { wait } from '../utils/misc/wait.js';
|
|
18
9
|
import '../options.js';
|
|
19
10
|
import { parseKeyDef } from './parseKeyDef.js';
|
|
20
|
-
import { Config } from '../setup/config.js';
|
|
21
11
|
|
|
22
12
|
async function keyboard(text) {
|
|
23
|
-
const actions = parseKeyDef(this
|
|
13
|
+
const actions = parseKeyDef(this.config.keyboardMap, text);
|
|
24
14
|
for(let i = 0; i < actions.length; i++){
|
|
25
|
-
await wait(this
|
|
26
|
-
await keyboardAction(this
|
|
15
|
+
await wait(this.config);
|
|
16
|
+
await keyboardAction(this, actions[i]);
|
|
27
17
|
}
|
|
28
18
|
}
|
|
29
|
-
async function keyboardAction(
|
|
30
|
-
const { system
|
|
19
|
+
async function keyboardAction(instance, { keyDef, releasePrevious, releaseSelf, repeat }) {
|
|
20
|
+
const { system } = instance;
|
|
31
21
|
// Release the key automatically if it was pressed before.
|
|
32
22
|
if (system.keyboard.isKeyPressed(keyDef)) {
|
|
33
|
-
await system.keyboard.keyup(
|
|
23
|
+
await system.keyboard.keyup(instance, keyDef);
|
|
34
24
|
}
|
|
35
25
|
if (!releasePrevious) {
|
|
36
26
|
for(let i = 1; i <= repeat; i++){
|
|
37
|
-
await system.keyboard.keydown(
|
|
27
|
+
await system.keyboard.keydown(instance, keyDef);
|
|
38
28
|
if (i < repeat) {
|
|
39
|
-
await wait(config);
|
|
29
|
+
await wait(instance.config);
|
|
40
30
|
}
|
|
41
31
|
}
|
|
42
32
|
// Release the key only on the last iteration on `state.repeatKey`.
|
|
43
33
|
if (releaseSelf) {
|
|
44
|
-
await system.keyboard.keyup(
|
|
34
|
+
await system.keyboard.keyup(instance, keyDef);
|
|
45
35
|
}
|
|
46
36
|
}
|
|
47
37
|
}
|
|
48
|
-
async function releaseAllKeys(
|
|
49
|
-
for (const k of
|
|
50
|
-
await
|
|
38
|
+
async function releaseAllKeys(instance) {
|
|
39
|
+
for (const k of instance.system.keyboard.getPressedKeys()){
|
|
40
|
+
await instance.system.keyboard.keyup(instance, k);
|
|
51
41
|
}
|
|
52
42
|
}
|
|
53
43
|
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import '../utils/click/isClickableInput.js';
|
|
2
2
|
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
3
|
import '../utils/edit/isEditable.js';
|
|
4
|
+
import '../utils/edit/maxLength.js';
|
|
13
5
|
import '@testing-library/dom/dist/helpers.js';
|
|
14
6
|
import { readNextDescriptor } from '../utils/keyDef/readNextDescriptor.js';
|
|
15
7
|
import '../utils/misc/level.js';
|
|
@@ -27,18 +19,18 @@ import '../options.js';
|
|
|
27
19
|
*/ function parseKeyDef(keyboardMap, text) {
|
|
28
20
|
const defs = [];
|
|
29
21
|
do {
|
|
30
|
-
const { type
|
|
31
|
-
var
|
|
32
|
-
const keyDef = (
|
|
22
|
+
const { type, descriptor, consumedLength, releasePrevious, releaseSelf = true, repeat } = readNextDescriptor(text, 'keyboard');
|
|
23
|
+
var _keyboardMap_find;
|
|
24
|
+
const keyDef = (_keyboardMap_find = keyboardMap.find((def)=>{
|
|
33
25
|
if (type === '[') {
|
|
34
|
-
var
|
|
35
|
-
return ((
|
|
26
|
+
var _def_code;
|
|
27
|
+
return ((_def_code = def.code) === null || _def_code === void 0 ? void 0 : _def_code.toLowerCase()) === descriptor.toLowerCase();
|
|
36
28
|
} else if (type === '{') {
|
|
37
|
-
var
|
|
38
|
-
return ((
|
|
29
|
+
var _def_key;
|
|
30
|
+
return ((_def_key = def.key) === null || _def_key === void 0 ? void 0 : _def_key.toLowerCase()) === descriptor.toLowerCase();
|
|
39
31
|
}
|
|
40
32
|
return def.key === descriptor;
|
|
41
|
-
})) !== null &&
|
|
33
|
+
})) !== null && _keyboardMap_find !== void 0 ? _keyboardMap_find : {
|
|
42
34
|
key: 'Unknown',
|
|
43
35
|
code: 'Unknown',
|
|
44
36
|
[type === '[' ? 'code' : 'key']: descriptor
|
package/dist/esm/options.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { defaultKeyMap } from './keyboard/keyMap.js';
|
|
2
|
-
import { defaultKeyMap as defaultKeyMap$1 } from './pointer/keyMap.js';
|
|
3
|
-
|
|
4
1
|
var PointerEventsCheckLevel;
|
|
5
2
|
(function(PointerEventsCheckLevel) {
|
|
6
3
|
PointerEventsCheckLevel[PointerEventsCheckLevel[/**
|
|
@@ -11,27 +8,5 @@ var PointerEventsCheckLevel;
|
|
|
11
8
|
PointerEventsCheckLevel[PointerEventsCheckLevel[/** Check each event target once */ "EachTarget"] = 1] = "EachTarget";
|
|
12
9
|
PointerEventsCheckLevel[PointerEventsCheckLevel[/** No pointer events check */ "Never"] = 0] = "Never";
|
|
13
10
|
})(PointerEventsCheckLevel || (PointerEventsCheckLevel = {}));
|
|
14
|
-
/**
|
|
15
|
-
* Default options applied when API is called per `userEvent.anyApi()`
|
|
16
|
-
*/ const defaultOptionsDirect = {
|
|
17
|
-
applyAccept: true,
|
|
18
|
-
autoModify: true,
|
|
19
|
-
delay: 0,
|
|
20
|
-
document: globalThis.document,
|
|
21
|
-
keyboardMap: defaultKeyMap,
|
|
22
|
-
pointerMap: defaultKeyMap$1,
|
|
23
|
-
pointerEventsCheck: PointerEventsCheckLevel.EachApiCall,
|
|
24
|
-
skipAutoClose: false,
|
|
25
|
-
skipClick: false,
|
|
26
|
-
skipHover: false,
|
|
27
|
-
writeToClipboard: false,
|
|
28
|
-
advanceTimers: ()=>Promise.resolve()
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Default options applied when API is called per `userEvent().anyApi()`
|
|
32
|
-
*/ const defaultOptionsSetup = {
|
|
33
|
-
...defaultOptionsDirect,
|
|
34
|
-
writeToClipboard: true
|
|
35
|
-
};
|
|
36
11
|
|
|
37
|
-
export { PointerEventsCheckLevel
|
|
12
|
+
export { PointerEventsCheckLevel };
|
|
@@ -1,26 +1,16 @@
|
|
|
1
|
-
import '../setup/index.js';
|
|
2
1
|
import '../utils/click/isClickableInput.js';
|
|
3
2
|
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
3
|
import '../utils/edit/isEditable.js';
|
|
4
|
+
import '../utils/edit/maxLength.js';
|
|
14
5
|
import '@testing-library/dom/dist/helpers.js';
|
|
15
6
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
16
7
|
import { setLevelRef, ApiLevel } from '../utils/misc/level.js';
|
|
17
8
|
import { wait } from '../utils/misc/wait.js';
|
|
18
9
|
import '../options.js';
|
|
19
10
|
import { parseKeyDef } from './parseKeyDef.js';
|
|
20
|
-
import { Config } from '../setup/config.js';
|
|
21
11
|
|
|
22
12
|
async function pointer(input) {
|
|
23
|
-
const { pointerMap
|
|
13
|
+
const { pointerMap } = this.config;
|
|
24
14
|
const actions = [];
|
|
25
15
|
(Array.isArray(input) ? input : [
|
|
26
16
|
input
|
|
@@ -37,52 +27,52 @@ async function pointer(input) {
|
|
|
37
27
|
}
|
|
38
28
|
});
|
|
39
29
|
for(let i = 0; i < actions.length; i++){
|
|
40
|
-
await wait(this
|
|
41
|
-
await pointerAction(this
|
|
30
|
+
await wait(this.config);
|
|
31
|
+
await pointerAction(this, actions[i]);
|
|
42
32
|
}
|
|
43
|
-
this
|
|
33
|
+
this.system.pointer.resetClickCount();
|
|
44
34
|
}
|
|
45
|
-
async function pointerAction(
|
|
46
|
-
var
|
|
47
|
-
const pointerName = 'pointerName' in action && action.pointerName ? action.pointerName : 'keyDef' in action ?
|
|
48
|
-
const previousPosition =
|
|
49
|
-
var
|
|
35
|
+
async function pointerAction(instance, action) {
|
|
36
|
+
var _previousPosition, _previousPosition_caret, _previousPosition1, _previousPosition_caret1, _previousPosition2;
|
|
37
|
+
const pointerName = 'pointerName' in action && action.pointerName ? action.pointerName : 'keyDef' in action ? instance.system.pointer.getPointerName(action.keyDef) : 'mouse';
|
|
38
|
+
const previousPosition = instance.system.pointer.getPreviousPosition(pointerName);
|
|
39
|
+
var _action_target, _action_coords, _action_node, _action_offset;
|
|
50
40
|
const position = {
|
|
51
|
-
target: (
|
|
52
|
-
coords: (
|
|
41
|
+
target: (_action_target = action.target) !== null && _action_target !== void 0 ? _action_target : getPrevTarget(instance, previousPosition),
|
|
42
|
+
coords: (_action_coords = action.coords) !== null && _action_coords !== void 0 ? _action_coords : (_previousPosition = previousPosition) === null || _previousPosition === void 0 ? void 0 : _previousPosition.coords,
|
|
53
43
|
caret: {
|
|
54
|
-
node: (
|
|
55
|
-
offset: (
|
|
44
|
+
node: (_action_node = action.node) !== null && _action_node !== void 0 ? _action_node : hasCaretPosition(action) ? undefined : (_previousPosition1 = previousPosition) === null || _previousPosition1 === void 0 ? void 0 : (_previousPosition_caret = _previousPosition1.caret) === null || _previousPosition_caret === void 0 ? void 0 : _previousPosition_caret.node,
|
|
45
|
+
offset: (_action_offset = action.offset) !== null && _action_offset !== void 0 ? _action_offset : hasCaretPosition(action) ? undefined : (_previousPosition2 = previousPosition) === null || _previousPosition2 === void 0 ? void 0 : (_previousPosition_caret1 = _previousPosition2.caret) === null || _previousPosition_caret1 === void 0 ? void 0 : _previousPosition_caret1.offset
|
|
56
46
|
}
|
|
57
47
|
};
|
|
58
48
|
if ('keyDef' in action) {
|
|
59
|
-
if (
|
|
60
|
-
setLevelRef(
|
|
61
|
-
await
|
|
49
|
+
if (instance.system.pointer.isKeyPressed(action.keyDef)) {
|
|
50
|
+
setLevelRef(instance, ApiLevel.Trigger);
|
|
51
|
+
await instance.system.pointer.release(instance, action.keyDef, position);
|
|
62
52
|
}
|
|
63
53
|
if (!action.releasePrevious) {
|
|
64
|
-
setLevelRef(
|
|
65
|
-
await
|
|
54
|
+
setLevelRef(instance, ApiLevel.Trigger);
|
|
55
|
+
await instance.system.pointer.press(instance, action.keyDef, position);
|
|
66
56
|
if (action.releaseSelf) {
|
|
67
|
-
setLevelRef(
|
|
68
|
-
await
|
|
57
|
+
setLevelRef(instance, ApiLevel.Trigger);
|
|
58
|
+
await instance.system.pointer.release(instance, action.keyDef, position);
|
|
69
59
|
}
|
|
70
60
|
}
|
|
71
61
|
} else {
|
|
72
|
-
setLevelRef(
|
|
73
|
-
await
|
|
62
|
+
setLevelRef(instance, ApiLevel.Trigger);
|
|
63
|
+
await instance.system.pointer.move(instance, pointerName, position);
|
|
74
64
|
}
|
|
75
65
|
}
|
|
76
66
|
function hasCaretPosition(action) {
|
|
77
|
-
var
|
|
78
|
-
return !!((
|
|
67
|
+
var _action_target, _ref;
|
|
68
|
+
return !!((_ref = (_action_target = action.target) !== null && _action_target !== void 0 ? _action_target : action.node) !== null && _ref !== void 0 ? _ref : action.offset !== undefined);
|
|
79
69
|
}
|
|
80
|
-
function getPrevTarget(
|
|
70
|
+
function getPrevTarget(instance, position) {
|
|
81
71
|
if (!position) {
|
|
82
72
|
throw new Error('This pointer has no previous position. Provide a target property!');
|
|
83
73
|
}
|
|
84
|
-
var
|
|
85
|
-
return (
|
|
74
|
+
var _position_target;
|
|
75
|
+
return (_position_target = position.target) !== null && _position_target !== void 0 ? _position_target : instance.config.document.body;
|
|
86
76
|
}
|
|
87
77
|
|
|
88
78
|
export { pointer };
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import '../utils/click/isClickableInput.js';
|
|
2
2
|
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
3
|
import '../utils/edit/isEditable.js';
|
|
4
|
+
import '../utils/edit/maxLength.js';
|
|
13
5
|
import '@testing-library/dom/dist/helpers.js';
|
|
14
6
|
import { readNextDescriptor } from '../utils/keyDef/readNextDescriptor.js';
|
|
15
7
|
import '../utils/misc/level.js';
|
|
@@ -18,7 +10,7 @@ import '../options.js';
|
|
|
18
10
|
function parseKeyDef(pointerMap, keys) {
|
|
19
11
|
const defs = [];
|
|
20
12
|
do {
|
|
21
|
-
const { descriptor
|
|
13
|
+
const { descriptor, consumedLength, releasePrevious, releaseSelf = true } = readNextDescriptor(keys, 'pointer');
|
|
22
14
|
const keyDef = pointerMap.find((p)=>p.name === descriptor);
|
|
23
15
|
if (keyDef) {
|
|
24
16
|
defs.push({
|
package/dist/esm/setup/api.js
CHANGED
|
@@ -1,12 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { click, dblClick, tripleClick } from '../convenience/click.js';
|
|
2
|
+
import { hover, unhover } from '../convenience/hover.js';
|
|
3
|
+
import { tab } from '../convenience/tab.js';
|
|
4
|
+
import { keyboard } from '../keyboard/index.js';
|
|
5
|
+
import { copy } from '../clipboard/copy.js';
|
|
6
|
+
import { cut } from '../clipboard/cut.js';
|
|
7
|
+
import { paste } from '../clipboard/paste.js';
|
|
8
|
+
import { pointer } from '../pointer/index.js';
|
|
9
|
+
import { clear } from '../utility/clear.js';
|
|
10
|
+
import { deselectOptions, selectOptions } from '../utility/selectOptions.js';
|
|
11
|
+
import { type } from '../utility/type.js';
|
|
12
|
+
import { upload } from '../utility/upload.js';
|
|
13
|
+
|
|
14
|
+
const userEventApi = {
|
|
15
|
+
click,
|
|
16
|
+
dblClick,
|
|
17
|
+
tripleClick,
|
|
18
|
+
hover,
|
|
19
|
+
unhover,
|
|
20
|
+
tab,
|
|
21
|
+
keyboard,
|
|
22
|
+
copy,
|
|
23
|
+
cut,
|
|
24
|
+
paste,
|
|
25
|
+
pointer,
|
|
26
|
+
clear,
|
|
27
|
+
deselectOptions,
|
|
28
|
+
selectOptions,
|
|
29
|
+
type,
|
|
30
|
+
upload
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { userEventApi };
|
|
@@ -22,12 +22,12 @@ function hover(element, options = {}) {
|
|
|
22
22
|
return setupDirect(options).api.hover(element);
|
|
23
23
|
}
|
|
24
24
|
async function keyboard(text, options = {}) {
|
|
25
|
-
const {
|
|
26
|
-
return api.keyboard(text).then(()=>
|
|
25
|
+
const { api, system } = setupDirect(options);
|
|
26
|
+
return api.keyboard(text).then(()=>system);
|
|
27
27
|
}
|
|
28
28
|
async function pointer(input, options = {}) {
|
|
29
|
-
const {
|
|
30
|
-
return api.pointer(input).then(()=>
|
|
29
|
+
const { api, system } = setupDirect(options);
|
|
30
|
+
return api.pointer(input).then(()=>system);
|
|
31
31
|
}
|
|
32
32
|
function paste(clipboardData, options) {
|
|
33
33
|
return setupDirect(options).api.paste(clipboardData);
|
|
@@ -42,8 +42,8 @@ function type(element, text, options = {}) {
|
|
|
42
42
|
return setupDirect(options, element).api.type(element, text, options);
|
|
43
43
|
}
|
|
44
44
|
function unhover(element, options = {}) {
|
|
45
|
-
const {
|
|
46
|
-
|
|
45
|
+
const { api, system } = setupDirect(options);
|
|
46
|
+
system.pointer.setMousePosition({
|
|
47
47
|
target: element
|
|
48
48
|
});
|
|
49
49
|
return api.unhover(element);
|
package/dist/esm/setup/index.js
CHANGED
package/dist/esm/setup/setup.js
CHANGED
|
@@ -1,29 +1,50 @@
|
|
|
1
|
-
import { prepareDocument } from '../document/
|
|
2
|
-
import {
|
|
3
|
-
import { defaultOptionsSetup, defaultOptionsDirect } from '../options.js';
|
|
1
|
+
import { prepareDocument } from '../document/prepareDocument.js';
|
|
2
|
+
import { dispatchEvent, dispatchUIEvent } from '../event/dispatchEvent.js';
|
|
4
3
|
import '../utils/click/isClickableInput.js';
|
|
5
4
|
import { attachClipboardStubToView } from '../utils/dataTransfer/Clipboard.js';
|
|
6
|
-
import '../utils/edit/maxLength.js';
|
|
7
5
|
import '../utils/edit/isEditable.js';
|
|
8
|
-
import '
|
|
6
|
+
import '../utils/edit/maxLength.js';
|
|
9
7
|
import '@testing-library/dom/dist/helpers.js';
|
|
10
8
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
11
9
|
import { getDocumentFromNode } from '../utils/misc/getDocumentFromNode.js';
|
|
12
10
|
import { setLevelRef, ApiLevel } from '../utils/misc/level.js';
|
|
13
11
|
import { wait } from '../utils/misc/wait.js';
|
|
12
|
+
import { PointerEventsCheckLevel } from '../options.js';
|
|
13
|
+
import '@testing-library/dom';
|
|
14
|
+
import { defaultKeyMap } from '../keyboard/keyMap.js';
|
|
15
|
+
import { defaultKeyMap as defaultKeyMap$1 } from '../pointer/keyMap.js';
|
|
14
16
|
import { System } from '../system/index.js';
|
|
15
|
-
import {
|
|
16
|
-
import * as api from './api.js';
|
|
17
|
+
import { userEventApi } from './api.js';
|
|
17
18
|
import { wrapAsync } from './wrapAsync.js';
|
|
18
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Default options applied when API is called per `userEvent.anyApi()`
|
|
22
|
+
*/ const defaultOptionsDirect = {
|
|
23
|
+
applyAccept: true,
|
|
24
|
+
autoModify: true,
|
|
25
|
+
delay: 0,
|
|
26
|
+
document: globalThis.document,
|
|
27
|
+
keyboardMap: defaultKeyMap,
|
|
28
|
+
pointerMap: defaultKeyMap$1,
|
|
29
|
+
pointerEventsCheck: PointerEventsCheckLevel.EachApiCall,
|
|
30
|
+
skipAutoClose: false,
|
|
31
|
+
skipClick: false,
|
|
32
|
+
skipHover: false,
|
|
33
|
+
writeToClipboard: false,
|
|
34
|
+
advanceTimers: ()=>Promise.resolve()
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Default options applied when API is called per `userEvent().anyApi()`
|
|
38
|
+
*/ const defaultOptionsSetup = {
|
|
39
|
+
...defaultOptionsDirect,
|
|
40
|
+
writeToClipboard: true
|
|
41
|
+
};
|
|
19
42
|
function createConfig(options = {}, defaults = defaultOptionsSetup, node) {
|
|
20
43
|
const document = getDocument(options, node, defaults);
|
|
21
|
-
var _system;
|
|
22
44
|
return {
|
|
23
45
|
...defaults,
|
|
24
46
|
...options,
|
|
25
|
-
document
|
|
26
|
-
system: (_system = options.system) !== null && _system !== void 0 ? _system : new System()
|
|
47
|
+
document
|
|
27
48
|
};
|
|
28
49
|
}
|
|
29
50
|
/**
|
|
@@ -32,37 +53,36 @@ function createConfig(options = {}, defaults = defaultOptionsSetup, node) {
|
|
|
32
53
|
*/ function setupMain(options = {}) {
|
|
33
54
|
const config = createConfig(options);
|
|
34
55
|
prepareDocument(config.document);
|
|
35
|
-
var
|
|
36
|
-
const view = (
|
|
56
|
+
var _config_document_defaultView;
|
|
57
|
+
const view = (_config_document_defaultView = config.document.defaultView) !== null && _config_document_defaultView !== void 0 ? _config_document_defaultView : /* istanbul ignore next */ globalThis.window;
|
|
37
58
|
attachClipboardStubToView(view);
|
|
38
|
-
return
|
|
59
|
+
return createInstance(config).api;
|
|
39
60
|
}
|
|
40
61
|
/**
|
|
41
62
|
* Setup in direct call per `userEvent.anyApi()`
|
|
42
|
-
*/ function setupDirect({ keyboardState
|
|
43
|
-
const config = createConfig(
|
|
44
|
-
...options,
|
|
45
|
-
system: pointerState !== null && pointerState !== void 0 ? pointerState : keyboardState
|
|
46
|
-
}, defaultOptionsDirect, node);
|
|
63
|
+
*/ function setupDirect({ keyboardState, pointerState, ...options } = {}, node) {
|
|
64
|
+
const config = createConfig(options, defaultOptionsDirect, node);
|
|
47
65
|
prepareDocument(config.document);
|
|
66
|
+
var _ref;
|
|
67
|
+
const system = (_ref = pointerState !== null && pointerState !== void 0 ? pointerState : keyboardState) !== null && _ref !== void 0 ? _ref : new System();
|
|
48
68
|
return {
|
|
49
|
-
config,
|
|
50
|
-
|
|
69
|
+
api: createInstance(config, system).api,
|
|
70
|
+
system
|
|
51
71
|
};
|
|
52
72
|
}
|
|
53
73
|
/**
|
|
54
74
|
* Create a set of callbacks with different default settings but the same state.
|
|
55
75
|
*/ function setupSub(options) {
|
|
56
|
-
return
|
|
57
|
-
...this
|
|
76
|
+
return createInstance({
|
|
77
|
+
...this.config,
|
|
58
78
|
...options
|
|
59
|
-
});
|
|
79
|
+
}, this.system).api;
|
|
60
80
|
}
|
|
61
81
|
function wrapAndBindImpl(instance, impl) {
|
|
62
82
|
function method(...args) {
|
|
63
|
-
setLevelRef(instance
|
|
83
|
+
setLevelRef(instance, ApiLevel.Call);
|
|
64
84
|
return wrapAsync(()=>impl.apply(instance, args).then(async (ret)=>{
|
|
65
|
-
await wait(instance
|
|
85
|
+
await wait(instance.config);
|
|
66
86
|
return ret;
|
|
67
87
|
}));
|
|
68
88
|
}
|
|
@@ -71,23 +91,30 @@ function wrapAndBindImpl(instance, impl) {
|
|
|
71
91
|
});
|
|
72
92
|
return method;
|
|
73
93
|
}
|
|
74
|
-
function
|
|
75
|
-
const instance = {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
94
|
+
function createInstance(config, system = new System()) {
|
|
95
|
+
const instance = {};
|
|
96
|
+
Object.assign(instance, {
|
|
97
|
+
config,
|
|
98
|
+
dispatchEvent: dispatchEvent.bind(instance),
|
|
99
|
+
dispatchUIEvent: dispatchUIEvent.bind(instance),
|
|
100
|
+
system,
|
|
101
|
+
levelRefs: {},
|
|
102
|
+
...userEventApi
|
|
103
|
+
});
|
|
80
104
|
return {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
105
|
+
instance,
|
|
106
|
+
api: {
|
|
107
|
+
...Object.fromEntries(Object.entries(userEventApi).map(([name, api])=>[
|
|
108
|
+
name,
|
|
109
|
+
wrapAndBindImpl(instance, api)
|
|
110
|
+
])),
|
|
111
|
+
setup: setupSub.bind(instance)
|
|
112
|
+
}
|
|
86
113
|
};
|
|
87
114
|
}
|
|
88
115
|
function getDocument(options, node, defaults) {
|
|
89
|
-
var
|
|
90
|
-
return (
|
|
116
|
+
var _options_document, _ref;
|
|
117
|
+
return (_ref = (_options_document = options.document) !== null && _options_document !== void 0 ? _options_document : node && getDocumentFromNode(node)) !== null && _ref !== void 0 ? _ref : defaults.document;
|
|
91
118
|
}
|
|
92
119
|
|
|
93
|
-
export { createConfig, setupDirect, setupMain, setupSub };
|
|
120
|
+
export { createConfig, createInstance, setupDirect, setupMain, setupSub };
|
package/dist/esm/system/index.js
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { KeyboardHost } from './keyboard.js';
|
|
2
2
|
import { PointerHost } from './pointer/index.js';
|
|
3
3
|
|
|
4
|
+
function _define_property(obj, key, value) {
|
|
5
|
+
if (key in obj) {
|
|
6
|
+
Object.defineProperty(obj, key, {
|
|
7
|
+
value: value,
|
|
8
|
+
enumerable: true,
|
|
9
|
+
configurable: true,
|
|
10
|
+
writable: true
|
|
11
|
+
});
|
|
12
|
+
} else {
|
|
13
|
+
obj[key] = value;
|
|
14
|
+
}
|
|
15
|
+
return obj;
|
|
16
|
+
}
|
|
4
17
|
/**
|
|
5
18
|
* @internal Do not create/alter this by yourself as this type might be subject to changes.
|
|
6
19
|
*/ class System {
|
|
@@ -21,8 +34,8 @@ import { PointerHost } from './pointer/index.js';
|
|
|
21
34
|
};
|
|
22
35
|
}
|
|
23
36
|
constructor(){
|
|
24
|
-
this
|
|
25
|
-
this
|
|
37
|
+
_define_property(this, "keyboard", new KeyboardHost(this));
|
|
38
|
+
_define_property(this, "pointer", new PointerHost(this));
|
|
26
39
|
}
|
|
27
40
|
}
|
|
28
41
|
|