@testing-library/user-event 14.4.2 → 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 +4 -14
- package/dist/cjs/clipboard/cut.js +4 -14
- package/dist/cjs/clipboard/paste.js +2 -12
- package/dist/cjs/convenience/click.js +1 -4
- package/dist/cjs/convenience/hover.js +2 -12
- package/dist/cjs/document/{selection.js → UI.js} +43 -57
- 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 +83 -0
- 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 +39 -43
- package/dist/cjs/event/behavior/keypress.js +8 -9
- package/dist/cjs/event/behavior/keyup.js +5 -7
- package/dist/cjs/event/behavior/paste.js +5 -11
- package/dist/cjs/event/createEvent.js +2 -9
- package/dist/cjs/event/dispatchEvent.js +20 -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 +48 -46
- 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 +9 -17
- 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 +1 -9
- package/dist/cjs/options.js +0 -28
- package/dist/cjs/pointer/index.js +20 -30
- 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 +65 -37
- package/dist/cjs/system/keyboard.js +7 -9
- package/dist/cjs/system/pointer/index.js +16 -21
- package/dist/cjs/system/pointer/mouse.js +45 -38
- package/dist/cjs/system/pointer/pointer.js +33 -35
- 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 +3 -13
- package/dist/cjs/utils/dataTransfer/Clipboard.js +1 -15
- package/dist/cjs/utils/edit/isEditable.js +6 -10
- package/dist/cjs/utils/edit/maxLength.js +4 -15
- package/dist/cjs/utils/edit/{buildTimeValue.js → timeValue.js} +6 -0
- package/dist/cjs/utils/focus/cursor.js +0 -16
- package/dist/cjs/utils/focus/selection.js +1 -271
- package/dist/cjs/utils/index.js +7 -32
- package/dist/cjs/utils/misc/level.js +4 -9
- package/dist/cjs/utils/pointer/cssPointerEvents.js +9 -22
- package/dist/esm/clipboard/copy.js +4 -14
- package/dist/esm/clipboard/cut.js +4 -14
- package/dist/esm/clipboard/paste.js +2 -12
- package/dist/esm/convenience/click.js +1 -4
- package/dist/esm/convenience/hover.js +2 -12
- package/dist/esm/document/{selection.js → UI.js} +35 -56
- 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 +81 -1
- package/dist/esm/document/prepareDocument.js +63 -0
- package/dist/esm/document/{value.js → trackValue.js} +3 -61
- 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 +32 -36
- package/dist/esm/event/behavior/keypress.js +8 -9
- package/dist/esm/event/behavior/keyup.js +5 -7
- package/dist/esm/event/behavior/paste.js +5 -11
- package/dist/esm/event/createEvent.js +2 -9
- package/dist/esm/event/dispatchEvent.js +19 -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 +35 -33
- 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 +8 -16
- package/dist/esm/{utils/focus → event/selection}/selectAll.js +12 -21
- 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 +1 -9
- package/dist/esm/options.js +1 -26
- package/dist/esm/pointer/index.js +20 -30
- 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 +59 -32
- package/dist/esm/system/keyboard.js +7 -9
- package/dist/esm/system/pointer/index.js +17 -21
- package/dist/esm/system/pointer/mouse.js +42 -35
- package/dist/esm/system/pointer/pointer.js +32 -34
- 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 +5 -14
- package/dist/esm/utility/upload.js +3 -13
- package/dist/esm/utils/dataTransfer/Clipboard.js +1 -15
- package/dist/esm/utils/edit/isEditable.js +4 -8
- package/dist/esm/utils/edit/maxLength.js +3 -15
- package/dist/esm/utils/edit/{buildTimeValue.js → timeValue.js} +6 -1
- package/dist/esm/utils/focus/cursor.js +0 -16
- package/dist/esm/utils/focus/selection.js +3 -265
- package/dist/esm/utils/index.js +4 -11
- package/dist/esm/utils/misc/level.js +4 -9
- package/dist/esm/utils/pointer/cssPointerEvents.js +9 -22
- 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 +3 -2
- 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/setRangeText.js +0 -17
- 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/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,76 +1,72 @@
|
|
|
1
|
+
import { getUIValue, setUISelection } from '../../document/UI.js';
|
|
2
|
+
import { getValueOrTextContent } from '../../document/getValueOrTextContent.js';
|
|
1
3
|
import '../../utils/click/isClickableInput.js';
|
|
2
4
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
3
|
-
import { getValue } from '../../utils/edit/getValue.js';
|
|
4
|
-
import { input } from '../../utils/edit/input.js';
|
|
5
5
|
import { isContentEditable } from '../../utils/edit/isContentEditable.js';
|
|
6
6
|
import { isEditable } from '../../utils/edit/isEditable.js';
|
|
7
|
-
import
|
|
8
|
-
import '@testing-library/dom';
|
|
7
|
+
import '../../utils/edit/maxLength.js';
|
|
9
8
|
import { isElementType } from '../../utils/misc/isElementType.js';
|
|
10
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
11
|
-
import { moveSelection, setSelectionRange, hasOwnSelection } from '../../utils/focus/selection.js';
|
|
12
|
-
import { focus } from '../../utils/focus/focus.js';
|
|
13
9
|
import { getTabDestination } from '../../utils/focus/getTabDestination.js';
|
|
14
|
-
import {
|
|
10
|
+
import { hasOwnSelection } from '../../utils/focus/selection.js';
|
|
15
11
|
import '../../utils/keyDef/readNextDescriptor.js';
|
|
12
|
+
import '@testing-library/dom/dist/helpers.js';
|
|
16
13
|
import '../../utils/misc/level.js';
|
|
17
14
|
import '../../options.js';
|
|
18
|
-
import '../
|
|
19
|
-
import '
|
|
20
|
-
import '
|
|
21
|
-
import '
|
|
22
|
-
import '
|
|
23
|
-
import '
|
|
15
|
+
import { focusElement } from '../focus.js';
|
|
16
|
+
import { input } from '../input.js';
|
|
17
|
+
import { moveSelection } from '../selection/moveSelection.js';
|
|
18
|
+
import { selectAll } from '../selection/selectAll.js';
|
|
19
|
+
import { setSelectionRange } from '../selection/setSelectionRange.js';
|
|
20
|
+
import { walkRadio } from '../radio.js';
|
|
24
21
|
import { behavior } from './registry.js';
|
|
25
|
-
import { setUISelection } from '../../document/selection.js';
|
|
26
22
|
|
|
27
|
-
behavior.keydown = (event, target,
|
|
23
|
+
behavior.keydown = (event, target, instance)=>{
|
|
28
24
|
var ref;
|
|
29
25
|
var ref1;
|
|
30
|
-
return (ref1 = (ref = keydownBehavior[event.key]) === null || ref === void 0 ? void 0 : ref.call(keydownBehavior, event, target,
|
|
26
|
+
return (ref1 = (ref = keydownBehavior[event.key]) === null || ref === void 0 ? void 0 : ref.call(keydownBehavior, event, target, instance)) !== null && ref1 !== void 0 ? ref1 : combinationBehavior(event, target, instance);
|
|
31
27
|
};
|
|
32
28
|
const keydownBehavior = {
|
|
33
|
-
ArrowDown: (event, target,
|
|
29
|
+
ArrowDown: (event, target, instance)=>{
|
|
34
30
|
/* istanbul ignore else */ if (isElementType(target, 'input', {
|
|
35
31
|
type: 'radio'
|
|
36
32
|
})) {
|
|
37
|
-
return ()=>walkRadio(
|
|
33
|
+
return ()=>walkRadio(instance, target, -1);
|
|
38
34
|
}
|
|
39
35
|
},
|
|
40
|
-
ArrowLeft: (event, target,
|
|
36
|
+
ArrowLeft: (event, target, instance)=>{
|
|
41
37
|
if (isElementType(target, 'input', {
|
|
42
38
|
type: 'radio'
|
|
43
39
|
})) {
|
|
44
|
-
return ()=>walkRadio(
|
|
40
|
+
return ()=>walkRadio(instance, target, -1);
|
|
45
41
|
}
|
|
46
42
|
return ()=>moveSelection(target, -1);
|
|
47
43
|
},
|
|
48
|
-
ArrowRight: (event, target,
|
|
44
|
+
ArrowRight: (event, target, instance)=>{
|
|
49
45
|
if (isElementType(target, 'input', {
|
|
50
46
|
type: 'radio'
|
|
51
47
|
})) {
|
|
52
|
-
return ()=>walkRadio(
|
|
48
|
+
return ()=>walkRadio(instance, target, 1);
|
|
53
49
|
}
|
|
54
50
|
return ()=>moveSelection(target, 1);
|
|
55
51
|
},
|
|
56
|
-
ArrowUp: (event, target,
|
|
52
|
+
ArrowUp: (event, target, instance)=>{
|
|
57
53
|
/* istanbul ignore else */ if (isElementType(target, 'input', {
|
|
58
54
|
type: 'radio'
|
|
59
55
|
})) {
|
|
60
|
-
return ()=>walkRadio(
|
|
56
|
+
return ()=>walkRadio(instance, target, 1);
|
|
61
57
|
}
|
|
62
58
|
},
|
|
63
|
-
Backspace: (event, target,
|
|
59
|
+
Backspace: (event, target, instance)=>{
|
|
64
60
|
if (isEditable(target)) {
|
|
65
61
|
return ()=>{
|
|
66
|
-
input(
|
|
62
|
+
input(instance, target, '', 'deleteContentBackward');
|
|
67
63
|
};
|
|
68
64
|
}
|
|
69
65
|
},
|
|
70
|
-
Delete: (event, target,
|
|
66
|
+
Delete: (event, target, instance)=>{
|
|
71
67
|
if (isEditable(target)) {
|
|
72
68
|
return ()=>{
|
|
73
|
-
input(
|
|
69
|
+
input(instance, target, '', 'deleteContentForward');
|
|
74
70
|
};
|
|
75
71
|
}
|
|
76
72
|
},
|
|
@@ -82,7 +78,7 @@ const keydownBehavior = {
|
|
|
82
78
|
return ()=>{
|
|
83
79
|
var ref;
|
|
84
80
|
var ref1;
|
|
85
|
-
const newPos = (ref1 = (ref =
|
|
81
|
+
const newPos = (ref1 = (ref = getValueOrTextContent(target)) === null || ref === void 0 ? void 0 : ref.length) !== null && ref1 !== void 0 ? ref1 : /* istanbul ignore next */ 0;
|
|
86
82
|
setSelectionRange(target, newPos, newPos);
|
|
87
83
|
};
|
|
88
84
|
}
|
|
@@ -102,7 +98,7 @@ const keydownBehavior = {
|
|
|
102
98
|
'input'
|
|
103
99
|
])) {
|
|
104
100
|
return ()=>{
|
|
105
|
-
const newPos =
|
|
101
|
+
const newPos = getUIValue(target).length;
|
|
106
102
|
setSelectionRange(target, newPos, newPos);
|
|
107
103
|
};
|
|
108
104
|
}
|
|
@@ -116,10 +112,10 @@ const keydownBehavior = {
|
|
|
116
112
|
};
|
|
117
113
|
}
|
|
118
114
|
},
|
|
119
|
-
Tab: (event, target,
|
|
115
|
+
Tab: (event, target, instance)=>{
|
|
120
116
|
return ()=>{
|
|
121
|
-
const dest = getTabDestination(target,
|
|
122
|
-
|
|
117
|
+
const dest = getTabDestination(target, instance.system.keyboard.modifiers.Shift);
|
|
118
|
+
focusElement(dest);
|
|
123
119
|
if (hasOwnSelection(dest)) {
|
|
124
120
|
setUISelection(dest, {
|
|
125
121
|
anchorOffset: 0,
|
|
@@ -129,8 +125,8 @@ const keydownBehavior = {
|
|
|
129
125
|
};
|
|
130
126
|
}
|
|
131
127
|
};
|
|
132
|
-
const combinationBehavior = (event, target,
|
|
133
|
-
if (event.code === 'KeyA' &&
|
|
128
|
+
const combinationBehavior = (event, target, instance)=>{
|
|
129
|
+
if (event.code === 'KeyA' && instance.system.keyboard.modifiers.Control) {
|
|
134
130
|
return ()=>selectAll(target);
|
|
135
131
|
}
|
|
136
132
|
};
|
|
@@ -1,39 +1,38 @@
|
|
|
1
|
-
import { dispatchUIEvent } from '../index.js';
|
|
2
1
|
import '../../utils/click/isClickableInput.js';
|
|
3
2
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
4
3
|
import { isContentEditable } from '../../utils/edit/isContentEditable.js';
|
|
5
|
-
import { input } from '../../utils/edit/input.js';
|
|
6
4
|
import { isEditable } from '../../utils/edit/isEditable.js';
|
|
7
|
-
import '
|
|
5
|
+
import '../../utils/edit/maxLength.js';
|
|
8
6
|
import { isElementType } from '../../utils/misc/isElementType.js';
|
|
9
7
|
import '@testing-library/dom/dist/helpers.js';
|
|
10
8
|
import '../../utils/keyDef/readNextDescriptor.js';
|
|
11
9
|
import '../../utils/misc/level.js';
|
|
12
10
|
import '../../options.js';
|
|
11
|
+
import { input } from '../input.js';
|
|
13
12
|
import { behavior } from './registry.js';
|
|
14
13
|
|
|
15
|
-
behavior.keypress = (event, target,
|
|
14
|
+
behavior.keypress = (event, target, instance)=>{
|
|
16
15
|
if (event.key === 'Enter') {
|
|
17
16
|
if (isElementType(target, 'button') || isElementType(target, 'input') && ClickInputOnEnter.includes(target.type) || isElementType(target, 'a') && Boolean(target.href)) {
|
|
18
17
|
return ()=>{
|
|
19
|
-
dispatchUIEvent(
|
|
18
|
+
instance.dispatchUIEvent(target, 'click');
|
|
20
19
|
};
|
|
21
20
|
} else if (isElementType(target, 'input')) {
|
|
22
21
|
const form = target.form;
|
|
23
22
|
const submit = form === null || form === void 0 ? void 0 : form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]');
|
|
24
23
|
if (submit) {
|
|
25
|
-
return ()=>dispatchUIEvent(
|
|
24
|
+
return ()=>instance.dispatchUIEvent(submit, 'click');
|
|
26
25
|
} else if (form && SubmitSingleInputOnEnter.includes(target.type) && form.querySelectorAll('input').length === 1) {
|
|
27
|
-
return ()=>dispatchUIEvent(
|
|
26
|
+
return ()=>instance.dispatchUIEvent(form, 'submit');
|
|
28
27
|
} else {
|
|
29
28
|
return;
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
if (isEditable(target)) {
|
|
34
|
-
const inputType = event.key === 'Enter' ? isContentEditable(target) && !
|
|
33
|
+
const inputType = event.key === 'Enter' ? isContentEditable(target) && !instance.system.keyboard.modifiers.Shift ? 'insertParagraph' : 'insertLineBreak' : 'insertText';
|
|
35
34
|
const inputData = event.key === 'Enter' ? '\n' : event.key;
|
|
36
|
-
return ()=>input(
|
|
35
|
+
return ()=>input(instance, target, inputData, inputType);
|
|
37
36
|
}
|
|
38
37
|
};
|
|
39
38
|
const ClickInputOnEnter = [
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import { isClickableInput } from '../../utils/click/isClickableInput.js';
|
|
2
2
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
3
|
-
import { dispatchUIEvent } from '../index.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 '../../utils/misc/level.js';
|
|
10
8
|
import '../../options.js';
|
|
11
9
|
import { behavior } from './registry.js';
|
|
12
10
|
|
|
13
|
-
behavior.keyup = (event, target,
|
|
11
|
+
behavior.keyup = (event, target, instance)=>{
|
|
14
12
|
var ref;
|
|
15
|
-
return (ref = keyupBehavior[event.key]) === null || ref === void 0 ? void 0 : ref.call(keyupBehavior, event, target,
|
|
13
|
+
return (ref = keyupBehavior[event.key]) === null || ref === void 0 ? void 0 : ref.call(keyupBehavior, event, target, instance);
|
|
16
14
|
};
|
|
17
15
|
const keyupBehavior = {
|
|
18
|
-
' ': (event, target,
|
|
16
|
+
' ': (event, target, instance)=>{
|
|
19
17
|
if (isClickableInput(target)) {
|
|
20
|
-
return ()=>dispatchUIEvent(
|
|
18
|
+
return ()=>instance.dispatchUIEvent(target, 'click');
|
|
21
19
|
}
|
|
22
20
|
}
|
|
23
21
|
};
|
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
import '../../utils/click/isClickableInput.js';
|
|
2
2
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
3
|
-
import '../eventMap.js';
|
|
4
|
-
import './click.js';
|
|
5
|
-
import './cut.js';
|
|
6
|
-
import './keydown.js';
|
|
7
|
-
import './keypress.js';
|
|
8
|
-
import './keyup.js';
|
|
9
|
-
import { behavior } from './registry.js';
|
|
10
|
-
import '@testing-library/dom';
|
|
11
|
-
import { input } from '../../utils/edit/input.js';
|
|
12
3
|
import { isEditable } from '../../utils/edit/isEditable.js';
|
|
4
|
+
import '../../utils/edit/maxLength.js';
|
|
13
5
|
import '@testing-library/dom/dist/helpers.js';
|
|
14
6
|
import '../../utils/keyDef/readNextDescriptor.js';
|
|
15
7
|
import '../../utils/misc/level.js';
|
|
16
8
|
import '../../options.js';
|
|
9
|
+
import { input } from '../input.js';
|
|
10
|
+
import { behavior } from './registry.js';
|
|
17
11
|
|
|
18
|
-
behavior.paste = (event, target,
|
|
12
|
+
behavior.paste = (event, target, instance)=>{
|
|
19
13
|
if (isEditable(target)) {
|
|
20
14
|
return ()=>{
|
|
21
15
|
var ref;
|
|
22
16
|
const insertData = (ref = event.clipboardData) === null || ref === void 0 ? void 0 : ref.getData('text');
|
|
23
17
|
if (insertData) {
|
|
24
|
-
input(
|
|
18
|
+
input(instance, target, insertData, 'insertFromPaste');
|
|
25
19
|
}
|
|
26
20
|
};
|
|
27
21
|
}
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import '../utils/click/isClickableInput.js';
|
|
2
2
|
import '../utils/dataTransfer/Clipboard.js';
|
|
3
|
-
import './behavior/click.js';
|
|
4
|
-
import './behavior/cut.js';
|
|
5
|
-
import './behavior/keydown.js';
|
|
6
|
-
import './behavior/keypress.js';
|
|
7
|
-
import './behavior/keyup.js';
|
|
8
|
-
import './behavior/paste.js';
|
|
9
|
-
import '@testing-library/dom';
|
|
10
|
-
import { eventMap, eventMapKeys } from './eventMap.js';
|
|
11
|
-
import '../utils/edit/maxLength.js';
|
|
12
3
|
import '../utils/edit/isEditable.js';
|
|
4
|
+
import '../utils/edit/maxLength.js';
|
|
13
5
|
import { getWindow } from '../utils/misc/getWindow.js';
|
|
14
6
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
15
7
|
import '../utils/misc/level.js';
|
|
16
8
|
import '../options.js';
|
|
9
|
+
import { eventMap, eventMapKeys } from './eventMap.js';
|
|
17
10
|
|
|
18
11
|
const eventInitializer = {
|
|
19
12
|
ClipboardEvent: [
|
|
@@ -6,11 +6,23 @@ import './behavior/keyup.js';
|
|
|
6
6
|
import './behavior/paste.js';
|
|
7
7
|
import { behavior } from './behavior/registry.js';
|
|
8
8
|
import { wrapEvent } from './wrapEvent.js';
|
|
9
|
+
import { isMouseEvent, isKeyboardEvent } from './eventMap.js';
|
|
10
|
+
import { createEvent } from './createEvent.js';
|
|
9
11
|
|
|
10
|
-
function
|
|
12
|
+
function dispatchUIEvent(target, type, init, preventDefault = false) {
|
|
13
|
+
if (isMouseEvent(type) || isKeyboardEvent(type)) {
|
|
14
|
+
init = {
|
|
15
|
+
...init,
|
|
16
|
+
...this.system.getUIEventModifiers()
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const event = createEvent(type, target, init);
|
|
20
|
+
return dispatchEvent.call(this, target, event, preventDefault);
|
|
21
|
+
}
|
|
22
|
+
function dispatchEvent(target, event, preventDefault = false) {
|
|
11
23
|
var ref;
|
|
12
24
|
const type = event.type;
|
|
13
|
-
const behaviorImplementation = preventDefault ? ()=>{} : (ref = behavior[type]) === null || ref === void 0 ? void 0 : ref(event, target,
|
|
25
|
+
const behaviorImplementation = preventDefault ? ()=>{} : (ref = behavior[type]) === null || ref === void 0 ? void 0 : ref(event, target, this);
|
|
14
26
|
if (behaviorImplementation) {
|
|
15
27
|
event.preventDefault();
|
|
16
28
|
let defaultPrevented = false;
|
|
@@ -30,5 +42,9 @@ function dispatchEvent(config, target, event, preventDefault = false) {
|
|
|
30
42
|
}
|
|
31
43
|
return wrapEvent(()=>target.dispatchEvent(event));
|
|
32
44
|
}
|
|
45
|
+
function dispatchDOMEvent(target, type, init) {
|
|
46
|
+
const event = createEvent(type, target, init);
|
|
47
|
+
wrapEvent(()=>target.dispatchEvent(event));
|
|
48
|
+
}
|
|
33
49
|
|
|
34
|
-
export { dispatchEvent };
|
|
50
|
+
export { dispatchDOMEvent, dispatchEvent, dispatchUIEvent };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import '../utils/click/isClickableInput.js';
|
|
2
|
+
import '../utils/dataTransfer/Clipboard.js';
|
|
3
|
+
import '../utils/edit/isEditable.js';
|
|
4
|
+
import '../utils/edit/maxLength.js';
|
|
5
|
+
import { getActiveElement } from '../utils/focus/getActiveElement.js';
|
|
6
|
+
import '@testing-library/dom/dist/helpers.js';
|
|
7
|
+
import { isFocusable } from '../utils/focus/isFocusable.js';
|
|
8
|
+
import '../utils/keyDef/readNextDescriptor.js';
|
|
9
|
+
import { findClosest } from '../utils/misc/findClosest.js';
|
|
10
|
+
import '../utils/misc/level.js';
|
|
11
|
+
import '../options.js';
|
|
12
|
+
import { updateSelectionOnFocus } from './selection/updateSelectionOnFocus.js';
|
|
13
|
+
import { wrapEvent } from './wrapEvent.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Focus closest focusable element.
|
|
17
|
+
*/ function focusElement(element) {
|
|
18
|
+
const target = findClosest(element, isFocusable);
|
|
19
|
+
const activeElement = getActiveElement(element.ownerDocument);
|
|
20
|
+
if ((target !== null && target !== void 0 ? target : element.ownerDocument.body) === activeElement) {
|
|
21
|
+
return;
|
|
22
|
+
} else if (target) {
|
|
23
|
+
wrapEvent(()=>target.focus());
|
|
24
|
+
} else {
|
|
25
|
+
wrapEvent(()=>{
|
|
26
|
+
var ref;
|
|
27
|
+
return (ref = activeElement) === null || ref === void 0 ? void 0 : ref.blur();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
updateSelectionOnFocus(target !== null && target !== void 0 ? target : element.ownerDocument.body);
|
|
31
|
+
}
|
|
32
|
+
function blurElement(element) {
|
|
33
|
+
if (!isFocusable(element)) return;
|
|
34
|
+
const wasActive = getActiveElement(element.ownerDocument) === element;
|
|
35
|
+
if (!wasActive) return;
|
|
36
|
+
wrapEvent(()=>element.blur());
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { blurElement, focusElement };
|
package/dist/esm/event/index.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
function bindDispatchUIEvent(config) {
|
|
16
|
-
return dispatchUIEvent.bind(undefined, config);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export { bindDispatchUIEvent, dispatchUIEvent };
|
|
1
|
+
export { dispatchDOMEvent, dispatchEvent, dispatchUIEvent } from './dispatchEvent.js';
|
|
2
|
+
export { blurElement, focusElement } from './focus.js';
|
|
3
|
+
export { input } from './input.js';
|
|
4
|
+
import '../utils/click/isClickableInput.js';
|
|
5
|
+
import '../utils/dataTransfer/Clipboard.js';
|
|
6
|
+
import '../utils/edit/isEditable.js';
|
|
7
|
+
import '../utils/edit/maxLength.js';
|
|
8
|
+
import '@testing-library/dom/dist/helpers.js';
|
|
9
|
+
import '../utils/keyDef/readNextDescriptor.js';
|
|
10
|
+
import '../utils/misc/level.js';
|
|
11
|
+
import '../options.js';
|
|
12
|
+
export { setSelectionPerMouseDown } from './selection/setSelectionPerMouse.js';
|
|
13
|
+
export { modifySelectionPerMouseMove } from './selection/modifySelectionPerMouse.js';
|
|
14
|
+
export { isAllSelected, selectAll } from './selection/selectAll.js';
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import '../click/isClickableInput.js';
|
|
3
|
-
import '../dataTransfer/Clipboard.js';
|
|
4
|
-
import '
|
|
5
|
-
import '
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { setUIValue, clearInitialValue, getUIValue } from '../document/UI.js';
|
|
2
|
+
import '../utils/click/isClickableInput.js';
|
|
3
|
+
import '../utils/dataTransfer/Clipboard.js';
|
|
4
|
+
import { isValidDateOrTimeValue, buildTimeValue } from '../utils/edit/timeValue.js';
|
|
5
|
+
import '../utils/edit/isEditable.js';
|
|
6
|
+
import { supportsMaxLength, getMaxLength } from '../utils/edit/maxLength.js';
|
|
7
|
+
import { getNextCursorPosition } from '../utils/focus/cursor.js';
|
|
8
|
+
import { isElementType } from '../utils/misc/isElementType.js';
|
|
8
9
|
import '@testing-library/dom/dist/helpers.js';
|
|
9
|
-
import
|
|
10
|
-
import '../
|
|
11
|
-
import '../
|
|
12
|
-
import '
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { isValidDateOrTimeValue } from './isValidDateOrTimeValue.js';
|
|
16
|
-
import { getSpaceUntilMaxLength } from './maxLength.js';
|
|
10
|
+
import '../utils/keyDef/readNextDescriptor.js';
|
|
11
|
+
import '../utils/misc/level.js';
|
|
12
|
+
import '../options.js';
|
|
13
|
+
import { commitValueAfterInput } from '../document/trackValue.js';
|
|
14
|
+
import { getInputRange } from './selection/getInputRange.js';
|
|
15
|
+
import { setSelection } from './selection/setSelection.js';
|
|
17
16
|
|
|
18
17
|
function isDateOrTime(element) {
|
|
19
18
|
return isElementType(element, 'input') && [
|
|
@@ -21,14 +20,14 @@ function isDateOrTime(element) {
|
|
|
21
20
|
'time'
|
|
22
21
|
].includes(element.type);
|
|
23
22
|
}
|
|
24
|
-
function input(
|
|
23
|
+
function input(instance, element, data, inputType = 'insertText') {
|
|
25
24
|
const inputRange = getInputRange(element);
|
|
26
25
|
/* istanbul ignore if */ if (!inputRange) {
|
|
27
26
|
return;
|
|
28
27
|
}
|
|
29
28
|
// There is no `beforeinput` event on `date` and `time` input
|
|
30
29
|
if (!isDateOrTime(element)) {
|
|
31
|
-
const unprevented = dispatchUIEvent(
|
|
30
|
+
const unprevented = instance.dispatchUIEvent(element, 'beforeinput', {
|
|
32
31
|
inputType,
|
|
33
32
|
data
|
|
34
33
|
});
|
|
@@ -37,12 +36,12 @@ function input(config, element, data, inputType = 'insertText') {
|
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
if ('startContainer' in inputRange) {
|
|
40
|
-
editContenteditable(
|
|
39
|
+
editContenteditable(instance, element, inputRange, data, inputType);
|
|
41
40
|
} else {
|
|
42
|
-
editInputElement(
|
|
41
|
+
editInputElement(instance, element, inputRange, data, inputType);
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
|
-
function editContenteditable(
|
|
44
|
+
function editContenteditable(instance, element, inputRange, data, inputType) {
|
|
46
45
|
let del = false;
|
|
47
46
|
if (!inputRange.collapsed) {
|
|
48
47
|
del = true;
|
|
@@ -77,19 +76,22 @@ function editContenteditable(config, element, inputRange, data, inputType) {
|
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
78
|
if (del || data) {
|
|
80
|
-
dispatchUIEvent(
|
|
79
|
+
instance.dispatchUIEvent(element, 'input', {
|
|
81
80
|
inputType
|
|
82
81
|
});
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
|
-
function editInputElement(
|
|
84
|
+
function editInputElement(instance, element, inputRange, data, inputType) {
|
|
86
85
|
let dataToInsert = data;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
if (supportsMaxLength(element)) {
|
|
87
|
+
const maxLength = getMaxLength(element);
|
|
88
|
+
if (maxLength !== undefined && data.length > 0) {
|
|
89
|
+
const spaceUntilMaxLength = maxLength - element.value.length;
|
|
90
|
+
if (spaceUntilMaxLength > 0) {
|
|
91
|
+
dataToInsert = data.substring(0, spaceUntilMaxLength);
|
|
92
|
+
} else {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
97
|
const { newValue , newOffset , oldValue } = calculateNewValue(dataToInsert, element, inputRange, inputType);
|
|
@@ -109,12 +111,12 @@ function editInputElement(config, element, inputRange, data, inputType) {
|
|
|
109
111
|
});
|
|
110
112
|
if (isDateOrTime(element)) {
|
|
111
113
|
if (isValidDateOrTimeValue(element, newValue)) {
|
|
112
|
-
commitInput(
|
|
113
|
-
dispatchUIEvent(
|
|
114
|
+
commitInput(instance, element, newOffset, {});
|
|
115
|
+
instance.dispatchUIEvent(element, 'change');
|
|
114
116
|
clearInitialValue(element);
|
|
115
117
|
}
|
|
116
118
|
} else {
|
|
117
|
-
commitInput(
|
|
119
|
+
commitInput(instance, element, newOffset, {
|
|
118
120
|
data,
|
|
119
121
|
inputType
|
|
120
122
|
});
|
|
@@ -143,8 +145,8 @@ function calculateNewValue(inputData, node, { startOffset , endOffset }, inputT
|
|
|
143
145
|
newOffset
|
|
144
146
|
};
|
|
145
147
|
}
|
|
146
|
-
function commitInput(
|
|
147
|
-
dispatchUIEvent(
|
|
148
|
+
function commitInput(instance, element, newOffset, inputInit) {
|
|
149
|
+
instance.dispatchUIEvent(element, 'input', inputInit);
|
|
148
150
|
commitValueAfterInput(element, newOffset);
|
|
149
151
|
}
|
|
150
152
|
function isValidNumberInput(value) {
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import '../utils/click/isClickableInput.js';
|
|
2
|
+
import '../utils/dataTransfer/Clipboard.js';
|
|
3
|
+
import '../utils/edit/isEditable.js';
|
|
4
|
+
import '../utils/edit/maxLength.js';
|
|
5
|
+
import { isDisabled } from '../utils/misc/isDisabled.js';
|
|
6
|
+
import { getWindow } from '../utils/misc/getWindow.js';
|
|
7
|
+
import '../utils/keyDef/readNextDescriptor.js';
|
|
8
|
+
import '../utils/misc/level.js';
|
|
9
|
+
import '../options.js';
|
|
10
|
+
import { focusElement } from './focus.js';
|
|
5
11
|
|
|
6
|
-
function walkRadio(
|
|
12
|
+
function walkRadio(instance, el, direction) {
|
|
7
13
|
const window = getWindow(el);
|
|
8
14
|
const group = Array.from(el.ownerDocument.querySelectorAll(el.name ? `input[type="radio"][name="${window.CSS.escape(el.name)}"]` : `input[type="radio"][name=""], input[type="radio"]:not([name])`));
|
|
9
15
|
for(let i = group.findIndex((e)=>e === el) + direction;; i += direction){
|
|
@@ -16,8 +22,8 @@ function walkRadio(config, el, direction) {
|
|
|
16
22
|
if (isDisabled(group[i])) {
|
|
17
23
|
continue;
|
|
18
24
|
}
|
|
19
|
-
|
|
20
|
-
dispatchUIEvent(
|
|
25
|
+
focusElement(group[i]);
|
|
26
|
+
instance.dispatchUIEvent(group[i], 'click');
|
|
21
27
|
}
|
|
22
28
|
}
|
|
23
29
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getTargetTypeAndSelection } from './getTargetTypeAndSelection.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get the range that would be overwritten by input.
|
|
5
|
+
*/ function getInputRange(focusNode) {
|
|
6
|
+
const typeAndSelection = getTargetTypeAndSelection(focusNode);
|
|
7
|
+
if (typeAndSelection.type === 'input') {
|
|
8
|
+
return typeAndSelection.selection;
|
|
9
|
+
} else if (typeAndSelection.type === 'contenteditable') {
|
|
10
|
+
var ref;
|
|
11
|
+
// Multi-range on contenteditable edits the first selection instead of the last
|
|
12
|
+
return (ref = typeAndSelection.selection) === null || ref === void 0 ? void 0 : ref.getRangeAt(0);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { getInputRange };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { getUISelection } from '../../document/UI.js';
|
|
2
|
+
import '../../utils/click/isClickableInput.js';
|
|
3
|
+
import '../../utils/dataTransfer/Clipboard.js';
|
|
4
|
+
import { getContentEditable } from '../../utils/edit/isContentEditable.js';
|
|
5
|
+
import '../../utils/edit/isEditable.js';
|
|
6
|
+
import '../../utils/edit/maxLength.js';
|
|
7
|
+
import '@testing-library/dom/dist/helpers.js';
|
|
8
|
+
import { hasOwnSelection } from '../../utils/focus/selection.js';
|
|
9
|
+
import '../../utils/keyDef/readNextDescriptor.js';
|
|
10
|
+
import '../../utils/misc/level.js';
|
|
11
|
+
import '../../options.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Determine which selection logic and selection ranges to consider.
|
|
15
|
+
*/ function getTargetTypeAndSelection(node) {
|
|
16
|
+
const element = getElement(node);
|
|
17
|
+
if (element && hasOwnSelection(element)) {
|
|
18
|
+
return {
|
|
19
|
+
type: 'input',
|
|
20
|
+
selection: getUISelection(element)
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const selection = element === null || element === void 0 ? void 0 : element.ownerDocument.getSelection();
|
|
24
|
+
// It is possible to extend a single-range selection into a contenteditable.
|
|
25
|
+
// This results in the range acting like a range outside of contenteditable.
|
|
26
|
+
const isCE = getContentEditable(node) && (selection === null || selection === void 0 ? void 0 : selection.anchorNode) && getContentEditable(selection.anchorNode);
|
|
27
|
+
return {
|
|
28
|
+
type: isCE ? 'contenteditable' : 'default',
|
|
29
|
+
selection
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function getElement(node) {
|
|
33
|
+
return node.nodeType === 1 ? node : node.parentElement;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { getTargetTypeAndSelection };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { getInputRange } from './getInputRange.js';
|
|
2
|
+
export { modifySelection } from './modifySelection.js';
|
|
3
|
+
export { moveSelection } from './moveSelection.js';
|
|
4
|
+
export { setSelectionPerMouseDown } from './setSelectionPerMouse.js';
|
|
5
|
+
export { modifySelectionPerMouseMove } from './modifySelectionPerMouse.js';
|
|
6
|
+
export { isAllSelected, selectAll } from './selectAll.js';
|
|
7
|
+
export { setSelectionRange } from './setSelectionRange.js';
|
|
8
|
+
export { setSelection } from './setSelection.js';
|
|
9
|
+
export { updateSelectionOnFocus } from './updateSelectionOnFocus.js';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { setUISelection } from '../../document/UI.js';
|
|
2
|
+
import '../../utils/click/isClickableInput.js';
|
|
3
|
+
import '../../utils/dataTransfer/Clipboard.js';
|
|
4
|
+
import '../../utils/edit/isEditable.js';
|
|
5
|
+
import '../../utils/edit/maxLength.js';
|
|
6
|
+
import '@testing-library/dom/dist/helpers.js';
|
|
7
|
+
import '../../utils/keyDef/readNextDescriptor.js';
|
|
8
|
+
import '../../utils/misc/level.js';
|
|
9
|
+
import '../../options.js';
|
|
10
|
+
import { getTargetTypeAndSelection } from './getTargetTypeAndSelection.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Extend/shrink the selection like with Shift+Arrows or Shift+Mouse
|
|
14
|
+
*/ function modifySelection({ focusNode , focusOffset }) {
|
|
15
|
+
var ref, ref1;
|
|
16
|
+
const typeAndSelection = getTargetTypeAndSelection(focusNode);
|
|
17
|
+
if (typeAndSelection.type === 'input') {
|
|
18
|
+
return setUISelection(focusNode, {
|
|
19
|
+
anchorOffset: typeAndSelection.selection.anchorOffset,
|
|
20
|
+
focusOffset
|
|
21
|
+
}, 'modify');
|
|
22
|
+
}
|
|
23
|
+
(ref1 = (ref = focusNode.ownerDocument) === null || ref === void 0 ? void 0 : ref.getSelection()) === null || ref1 === void 0 ? void 0 : ref1.extend(focusNode, focusOffset);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { modifySelection };
|