@testing-library/user-event 14.0.0-alpha.1 → 14.0.0-alpha.10

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.
Files changed (161) hide show
  1. package/dist/{src/clear.d.ts → clear.d.ts} +0 -0
  2. package/dist/clear.js +14 -27
  3. package/dist/{src/click.d.ts → click.d.ts} +1 -0
  4. package/dist/click.js +17 -0
  5. package/dist/document/index.d.ts +10 -0
  6. package/dist/document/index.js +8 -10
  7. package/dist/document/interceptor.d.ts +15 -0
  8. package/dist/document/interceptor.js +7 -4
  9. package/dist/document/selection.d.ts +27 -0
  10. package/dist/document/selection.js +51 -28
  11. package/dist/{src/document → document}/value.d.ts +5 -1
  12. package/dist/document/value.js +27 -6
  13. package/dist/{src/hover.d.ts → hover.d.ts} +0 -0
  14. package/dist/{src/index.d.ts → index.d.ts} +0 -0
  15. package/dist/{src/keyboard → keyboard}/getEventProps.d.ts +0 -0
  16. package/dist/{src/keyboard → keyboard}/getNextKeyDef.d.ts +0 -0
  17. package/dist/{src/keyboard → keyboard}/index.d.ts +0 -0
  18. package/dist/{src/keyboard → keyboard}/keyMap.d.ts +0 -0
  19. package/dist/keyboard/keyMap.js +4 -0
  20. package/dist/{src/keyboard → keyboard}/keyboardImplementation.d.ts +0 -0
  21. package/dist/keyboard/keyboardImplementation.js +3 -1
  22. package/dist/{src/keyboard → keyboard}/plugins/arrow.d.ts +0 -0
  23. package/dist/keyboard/plugins/arrow.js +7 -12
  24. package/dist/{src/keyboard → keyboard}/plugins/character.d.ts +0 -0
  25. package/dist/keyboard/plugins/character.js +27 -45
  26. package/dist/keyboard/plugins/combination.d.ts +5 -0
  27. package/dist/keyboard/plugins/combination.js +17 -0
  28. package/dist/{src/keyboard → keyboard}/plugins/control.d.ts +0 -0
  29. package/dist/keyboard/plugins/control.js +4 -12
  30. package/dist/{src/keyboard → keyboard}/plugins/functional.d.ts +0 -0
  31. package/dist/keyboard/plugins/functional.js +23 -11
  32. package/dist/{src/keyboard → keyboard}/plugins/index.d.ts +0 -0
  33. package/dist/keyboard/plugins/index.js +3 -1
  34. package/dist/{src/keyboard → keyboard}/shared/fireChangeForInputTimeIfValid.d.ts +0 -0
  35. package/dist/{src/keyboard → keyboard}/shared/index.d.ts +0 -0
  36. package/dist/{src/keyboard → keyboard}/specialCharMap.d.ts +0 -0
  37. package/dist/{src/keyboard → keyboard}/types.d.ts +0 -0
  38. package/dist/{src/paste.d.ts → paste.d.ts} +0 -0
  39. package/dist/paste.js +8 -15
  40. package/dist/{src/pointer → pointer}/index.d.ts +0 -0
  41. package/dist/{src/pointer → pointer}/keyMap.d.ts +0 -0
  42. package/dist/{src/pointer → pointer}/parseKeyDef.d.ts +0 -0
  43. package/dist/{src/pointer → pointer}/pointerAction.d.ts +2 -6
  44. package/dist/pointer/pointerAction.js +2 -26
  45. package/dist/pointer/pointerMove.d.ts +5 -0
  46. package/dist/pointer/pointerMove.js +49 -5
  47. package/dist/pointer/pointerPress.d.ts +7 -0
  48. package/dist/pointer/pointerPress.js +135 -29
  49. package/dist/pointer/resolveSelectionTarget.d.ts +5 -0
  50. package/dist/pointer/resolveSelectionTarget.js +75 -0
  51. package/dist/{src/pointer → pointer}/types.d.ts +18 -4
  52. package/dist/{src/selectOptions.d.ts → selectOptions.d.ts} +0 -0
  53. package/dist/{src/setup.d.ts → setup.d.ts} +5 -2
  54. package/dist/setup.js +4 -7
  55. package/dist/tab.d.ts +5 -0
  56. package/dist/tab.js +3 -132
  57. package/dist/{src/type.d.ts → type.d.ts} +0 -0
  58. package/dist/type.js +3 -19
  59. package/dist/{src/upload.d.ts → upload.d.ts} +0 -0
  60. package/dist/{src/utils → utils}/click/isClickableInput.d.ts +0 -0
  61. package/dist/{src/utils → utils}/edit/buildTimeValue.d.ts +0 -0
  62. package/dist/utils/edit/calculateNewValue.d.ts +14 -0
  63. package/dist/utils/edit/calculateNewValue.js +19 -21
  64. package/dist/utils/edit/editInputElement.d.ts +16 -0
  65. package/dist/utils/edit/editInputElement.js +53 -0
  66. package/dist/{src/utils → utils}/edit/getValue.d.ts +0 -0
  67. package/dist/utils/edit/getValue.js +1 -3
  68. package/dist/utils/edit/isContentEditable.d.ts +7 -0
  69. package/dist/utils/edit/isContentEditable.js +14 -0
  70. package/dist/{src/utils → utils}/edit/isEditable.d.ts +1 -0
  71. package/dist/{src/utils → utils}/edit/isValidDateValue.d.ts +0 -0
  72. package/dist/{src/utils → utils}/edit/isValidInputTimeValue.d.ts +0 -0
  73. package/dist/{src/utils → utils}/edit/maxLength.d.ts +0 -0
  74. package/dist/utils/edit/prepareInput.d.ts +7 -0
  75. package/dist/utils/edit/prepareInput.js +77 -0
  76. package/dist/{src/utils → utils}/focus/blur.d.ts +0 -0
  77. package/dist/{src/utils → utils}/focus/focus.d.ts +0 -0
  78. package/dist/utils/focus/focus.js +3 -0
  79. package/dist/{src/utils → utils}/focus/getActiveElement.d.ts +0 -0
  80. package/dist/utils/focus/getTabDestination.d.ts +1 -0
  81. package/dist/utils/focus/getTabDestination.js +71 -0
  82. package/dist/{src/utils → utils}/focus/isFocusable.d.ts +0 -0
  83. package/dist/utils/focus/selectAll.d.ts +5 -0
  84. package/dist/utils/focus/selectAll.js +51 -0
  85. package/dist/utils/focus/selection.d.ts +42 -0
  86. package/dist/utils/focus/selection.js +190 -0
  87. package/dist/{src/utils → utils}/focus/selector.d.ts +0 -0
  88. package/dist/{src/utils → utils}/index.d.ts +5 -5
  89. package/dist/utils/index.js +47 -47
  90. package/dist/{src/utils → utils}/keyDef/readNextDescriptor.d.ts +0 -0
  91. package/dist/{src/utils → utils}/misc/eventWrapper.d.ts +0 -0
  92. package/dist/{src/utils → utils}/misc/findClosest.d.ts +0 -0
  93. package/dist/{src/utils → utils}/misc/hasFormSubmit.d.ts +0 -0
  94. package/dist/{src/utils → utils}/misc/hasPointerEvents.d.ts +0 -0
  95. package/dist/{src/utils → utils}/misc/isDescendantOrSelf.d.ts +0 -0
  96. package/dist/{src/utils → utils}/misc/isDisabled.d.ts +0 -0
  97. package/dist/{src/utils → utils}/misc/isElementType.d.ts +0 -0
  98. package/dist/{src/utils → utils}/misc/isVisible.d.ts +0 -0
  99. package/dist/{src/utils → utils}/misc/wait.d.ts +0 -0
  100. package/dist/{src/utils → utils}/pointer/firePointerEvents.d.ts +13 -11
  101. package/dist/utils/pointer/firePointerEvents.js +62 -5
  102. package/dist/{src/utils → utils}/pointer/mouseButtons.d.ts +0 -0
  103. package/package.json +2 -2
  104. package/dist/document/applyNative.js +0 -28
  105. package/dist/src/document/applyNative.d.ts +0 -8
  106. package/dist/src/document/index.d.ts +0 -10
  107. package/dist/src/document/interceptor.d.ts +0 -5
  108. package/dist/src/document/selection.d.ts +0 -18
  109. package/dist/src/pointer/pointerMove.d.ts +0 -5
  110. package/dist/src/pointer/pointerPress.d.ts +0 -7
  111. package/dist/src/tab.d.ts +0 -6
  112. package/dist/src/utils/edit/calculateNewValue.d.ts +0 -7
  113. package/dist/src/utils/edit/cursorPosition.d.ts +0 -2
  114. package/dist/src/utils/edit/fireInputEvent.d.ts +0 -8
  115. package/dist/src/utils/edit/isContentEditable.d.ts +0 -3
  116. package/dist/src/utils/edit/selectionRange.d.ts +0 -5
  117. package/dist/src/utils/misc/isDocument.d.ts +0 -1
  118. package/dist/src/utils/pointer/fakeEvent.d.ts +0 -16
  119. package/dist/tests/_helpers/custom-element.d.ts +0 -8
  120. package/dist/tests/_helpers/utils.d.ts +0 -73
  121. package/dist/tests/_setup-env.d.ts +0 -1
  122. package/dist/tests/clear.d.ts +0 -1
  123. package/dist/tests/click/click.d.ts +0 -1
  124. package/dist/tests/click/dblclick.d.ts +0 -1
  125. package/dist/tests/document/index.d.ts +0 -1
  126. package/dist/tests/document/selectionRange.d.ts +0 -1
  127. package/dist/tests/hover/hover.d.ts +0 -1
  128. package/dist/tests/hover/unhover.d.ts +0 -1
  129. package/dist/tests/keyboard/getNextKeyDef.d.ts +0 -1
  130. package/dist/tests/keyboard/index.d.ts +0 -1
  131. package/dist/tests/keyboard/keyboardImplementation.d.ts +0 -1
  132. package/dist/tests/keyboard/plugin/arrow.d.ts +0 -1
  133. package/dist/tests/keyboard/plugin/character.d.ts +0 -1
  134. package/dist/tests/keyboard/plugin/control.d.ts +0 -1
  135. package/dist/tests/keyboard/plugin/functional.d.ts +0 -1
  136. package/dist/tests/keyboard/shared/fireInputEvent.d.ts +0 -1
  137. package/dist/tests/paste.d.ts +0 -1
  138. package/dist/tests/pointer/index.d.ts +0 -1
  139. package/dist/tests/react/keyboard.d.ts +0 -1
  140. package/dist/tests/react/type.d.ts +0 -1
  141. package/dist/tests/selectOptions/deselect.d.ts +0 -1
  142. package/dist/tests/selectOptions/select.d.ts +0 -1
  143. package/dist/tests/setup.d.ts +0 -10
  144. package/dist/tests/tab.d.ts +0 -1
  145. package/dist/tests/type/index.d.ts +0 -1
  146. package/dist/tests/type/modifiers.d.ts +0 -1
  147. package/dist/tests/upload.d.ts +0 -1
  148. package/dist/tests/utils/edit/calculateNewValue.d.ts +0 -1
  149. package/dist/tests/utils/edit/isContentEditable.d.ts +0 -1
  150. package/dist/tests/utils/focus/blur.d.ts +0 -1
  151. package/dist/tests/utils/focus/focus.d.ts +0 -1
  152. package/dist/tests/utils/misc/hasPointerEvents.d.ts +0 -1
  153. package/dist/tests/utils/misc/isDescendantOrSelf.d.ts +0 -1
  154. package/dist/tests/utils/misc/isElementType.d.ts +0 -1
  155. package/dist/tests/utils/misc/isVisible.d.ts +0 -1
  156. package/dist/utils/edit/cursorPosition.js +0 -35
  157. package/dist/utils/edit/fireInputEvent.js +0 -55
  158. package/dist/utils/edit/selectionRange.js +0 -64
  159. package/dist/utils/misc/dom-helpers.d.ts +0 -3
  160. package/dist/utils/misc/isDocument.js +0 -10
  161. package/dist/utils/pointer/fakeEvent.js +0 -82
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getTabDestination = getTabDestination;
7
+
8
+ var _isDisabled = require("../misc/isDisabled");
9
+
10
+ var _isElementType = require("../misc/isElementType");
11
+
12
+ var _isVisible = require("../misc/isVisible");
13
+
14
+ var _selector = require("./selector");
15
+
16
+ function getTabDestination(activeElement, shift) {
17
+ const document = activeElement.ownerDocument;
18
+ const focusableElements = document.querySelectorAll(_selector.FOCUSABLE_SELECTOR);
19
+ const enabledElements = Array.from(focusableElements).filter(el => el === activeElement || el.getAttribute('tabindex') !== '-1' && !(0, _isDisabled.isDisabled)(el) && // Hidden elements are not tabable
20
+ (0, _isVisible.isVisible)(el));
21
+
22
+ if (activeElement.getAttribute('tabindex') !== '-1') {
23
+ // tabindex has no effect if the active element has tabindex="-1"
24
+ enabledElements.sort((a, b) => Number(a.getAttribute('tabindex')) - Number(b.getAttribute('tabindex')));
25
+ }
26
+
27
+ const checkedRadio = {};
28
+ let prunedElements = [document.body];
29
+ const activeRadioGroup = (0, _isElementType.isElementType)(activeElement, 'input', {
30
+ type: 'radio'
31
+ }) ? activeElement.name : undefined;
32
+ enabledElements.forEach(currentElement => {
33
+ const el = currentElement; // For radio groups keep only the active radio
34
+ // If there is no active radio, keep only the checked radio
35
+ // If there is no checked radio, treat like everything else
36
+
37
+ if ((0, _isElementType.isElementType)(el, 'input', {
38
+ type: 'radio'
39
+ }) && el.name) {
40
+ // If the active element is part of the group, add only that
41
+ if (el === activeElement) {
42
+ prunedElements.push(el);
43
+ return;
44
+ } else if (el.name === activeRadioGroup) {
45
+ return;
46
+ } // If we stumble upon a checked radio, remove the others
47
+
48
+
49
+ if (el.checked) {
50
+ prunedElements = prunedElements.filter(e => !(0, _isElementType.isElementType)(e, 'input', {
51
+ type: 'radio',
52
+ name: el.name
53
+ }));
54
+ prunedElements.push(el);
55
+ checkedRadio[el.name] = el;
56
+ return;
57
+ } // If we already found the checked one, skip
58
+
59
+
60
+ if (typeof checkedRadio[el.name] !== 'undefined') {
61
+ return;
62
+ }
63
+ }
64
+
65
+ prunedElements.push(el);
66
+ });
67
+ const currentIndex = prunedElements.findIndex(el => el === activeElement);
68
+ const nextIndex = shift ? currentIndex - 1 : currentIndex + 1;
69
+ const defaultIndex = shift ? prunedElements.length - 1 : 0;
70
+ return prunedElements[nextIndex] || prunedElements[defaultIndex];
71
+ }
File without changes
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Expand a selection like the browser does when pressing Ctrl+A.
3
+ */
4
+ export declare function selectAll(target: Element): void;
5
+ export declare function isAllSelected(target: Element): boolean;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isAllSelected = isAllSelected;
7
+ exports.selectAll = selectAll;
8
+
9
+ var _document = require("../../document");
10
+
11
+ var _isContentEditable = require("../edit/isContentEditable");
12
+
13
+ var _isEditable = require("../edit/isEditable");
14
+
15
+ var _isElementType = require("../misc/isElementType");
16
+
17
+ var _selection = require("./selection");
18
+
19
+ /**
20
+ * Expand a selection like the browser does when pressing Ctrl+A.
21
+ */
22
+ function selectAll(target) {
23
+ var _getContentEditable;
24
+
25
+ if ((0, _isElementType.isElementType)(target, 'textarea') || (0, _isElementType.isElementType)(target, 'input') && target.type in _isEditable.editableInputTypes) {
26
+ return (0, _selection.setSelection)({
27
+ focusNode: target,
28
+ anchorOffset: 0,
29
+ focusOffset: (0, _document.getUIValue)(target).length
30
+ });
31
+ }
32
+
33
+ const focusNode = (_getContentEditable = (0, _isContentEditable.getContentEditable)(target)) != null ? _getContentEditable : target.ownerDocument.body;
34
+ (0, _selection.setSelection)({
35
+ focusNode,
36
+ anchorOffset: 0,
37
+ focusOffset: focusNode.childNodes.length
38
+ });
39
+ }
40
+
41
+ function isAllSelected(target) {
42
+ var _getContentEditable2;
43
+
44
+ if ((0, _isElementType.isElementType)(target, 'textarea') || (0, _isElementType.isElementType)(target, 'input') && target.type in _isEditable.editableInputTypes) {
45
+ return (0, _document.getUISelection)(target).startOffset === 0 && (0, _document.getUISelection)(target).endOffset === (0, _document.getUIValue)(target).length;
46
+ }
47
+
48
+ const focusNode = (_getContentEditable2 = (0, _isContentEditable.getContentEditable)(target)) != null ? _getContentEditable2 : target.ownerDocument.body;
49
+ const selection = target.ownerDocument.getSelection();
50
+ return (selection == null ? void 0 : selection.anchorNode) === focusNode && selection.focusNode === focusNode && selection.anchorOffset === 0 && selection.focusOffset === focusNode.childNodes.length;
51
+ }
@@ -0,0 +1,42 @@
1
+ import { UISelectionRange } from '../../document';
2
+ import { editableInputTypes } from '../edit/isEditable';
3
+ /**
4
+ * Backward-compatible selection.
5
+ *
6
+ * Handles input elements and contenteditable if it only contains a single text node.
7
+ */
8
+ export declare function setSelectionRange(element: Element, anchorOffset: number, focusOffset: number): void;
9
+ /**
10
+ * Determine if the element has its own selection implementation
11
+ * and does not interact with the Document Selection API.
12
+ */
13
+ export declare function hasOwnSelection(node: Node): node is HTMLTextAreaElement | (HTMLInputElement & {
14
+ type: editableInputTypes;
15
+ });
16
+ /**
17
+ * Reset the Document Selection when moving focus into an element
18
+ * with own selection implementation.
19
+ */
20
+ export declare function updateSelectionOnFocus(element: Element): void;
21
+ /**
22
+ * Get the range that would be overwritten by input.
23
+ */
24
+ export declare function getInputRange(focusNode: Node): UISelectionRange | Range | undefined;
25
+ /**
26
+ * Extend/shrink the selection like with Shift+Arrows or Shift+Mouse
27
+ */
28
+ export declare function modifySelection({ focusNode, focusOffset, }: {
29
+ focusNode: Node;
30
+ /** DOM Offset */
31
+ focusOffset: number;
32
+ }): void;
33
+ /**
34
+ * Set the selection
35
+ */
36
+ export declare function setSelection({ focusNode, focusOffset, anchorNode, anchorOffset, }: {
37
+ anchorNode?: Node;
38
+ /** DOM offset */
39
+ anchorOffset?: number;
40
+ focusNode: Node;
41
+ focusOffset: number;
42
+ }): void;
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getInputRange = getInputRange;
7
+ exports.hasOwnSelection = hasOwnSelection;
8
+ exports.modifySelection = modifySelection;
9
+ exports.setSelection = setSelection;
10
+ exports.setSelectionRange = setSelectionRange;
11
+ exports.updateSelectionOnFocus = updateSelectionOnFocus;
12
+
13
+ var _isElementType = require("../misc/isElementType");
14
+
15
+ var _document = require("../../document");
16
+
17
+ var _isEditable = require("../edit/isEditable");
18
+
19
+ var _isContentEditable = require("../edit/isContentEditable");
20
+
21
+ /**
22
+ * Backward-compatible selection.
23
+ *
24
+ * Handles input elements and contenteditable if it only contains a single text node.
25
+ */
26
+ function setSelectionRange(element, anchorOffset, focusOffset) {
27
+ var _element$firstChild;
28
+
29
+ if (hasOwnSelection(element)) {
30
+ return setSelection({
31
+ focusNode: element,
32
+ anchorOffset,
33
+ focusOffset
34
+ });
35
+ }
36
+ /* istanbul ignore else */
37
+
38
+
39
+ if ((0, _isContentEditable.isContentEditable)(element) && ((_element$firstChild = element.firstChild) == null ? void 0 : _element$firstChild.nodeType) === 3) {
40
+ return setSelection({
41
+ focusNode: element.firstChild,
42
+ anchorOffset,
43
+ focusOffset
44
+ });
45
+ }
46
+ /* istanbul ignore next */
47
+
48
+
49
+ throw new Error('Not implemented. The result of this interaction is unreliable.');
50
+ }
51
+ /**
52
+ * Determine if the element has its own selection implementation
53
+ * and does not interact with the Document Selection API.
54
+ */
55
+
56
+
57
+ function hasOwnSelection(node) {
58
+ return isElement(node) && ((0, _isElementType.isElementType)(node, 'textarea') || (0, _isElementType.isElementType)(node, 'input') && node.type in _isEditable.editableInputTypes);
59
+ }
60
+
61
+ function isElement(node) {
62
+ return node.nodeType === 1;
63
+ }
64
+ /**
65
+ * Determine which selection logic and selection ranges to consider.
66
+ */
67
+
68
+
69
+ function getTargetTypeAndSelection(node) {
70
+ const element = getElement(node);
71
+
72
+ if (element && hasOwnSelection(element)) {
73
+ return {
74
+ type: 'input',
75
+ selection: (0, _document.getUISelection)(element)
76
+ };
77
+ }
78
+
79
+ const selection = element == null ? void 0 : element.ownerDocument.getSelection(); // It is possible to extend a single-range selection into a contenteditable.
80
+ // This results in the range acting like a range outside of contenteditable.
81
+
82
+ const isCE = (0, _isContentEditable.getContentEditable)(node) && (selection == null ? void 0 : selection.anchorNode) && (0, _isContentEditable.getContentEditable)(selection.anchorNode);
83
+ return {
84
+ type: isCE ? 'contenteditable' : 'default',
85
+ selection
86
+ };
87
+ }
88
+
89
+ function getElement(node) {
90
+ return node.nodeType === 1 ? node : node.parentElement;
91
+ }
92
+ /**
93
+ * Reset the Document Selection when moving focus into an element
94
+ * with own selection implementation.
95
+ */
96
+
97
+
98
+ function updateSelectionOnFocus(element) {
99
+ const selection = element.ownerDocument.getSelection();
100
+ /* istanbul ignore if */
101
+
102
+ if (!(selection != null && selection.focusNode)) {
103
+ return;
104
+ } // If the focus moves inside an element with own selection implementation,
105
+ // the document selection will be this element.
106
+ // But if the focused element is inside a contenteditable,
107
+ // 1) a collapsed selection will be retained.
108
+ // 2) other selections will be replaced by a cursor
109
+ // 2.a) at the start of the first child if it is a text node
110
+ // 2.b) at the start of the contenteditable.
111
+
112
+
113
+ if (hasOwnSelection(element)) {
114
+ const contenteditable = (0, _isContentEditable.getContentEditable)(selection.focusNode);
115
+
116
+ if (contenteditable) {
117
+ if (!selection.isCollapsed) {
118
+ var _contenteditable$firs;
119
+
120
+ const focusNode = ((_contenteditable$firs = contenteditable.firstChild) == null ? void 0 : _contenteditable$firs.nodeType) === 3 ? contenteditable.firstChild : contenteditable;
121
+ selection.setBaseAndExtent(focusNode, 0, focusNode, 0);
122
+ }
123
+ } else {
124
+ selection.setBaseAndExtent(element, 0, element, 0);
125
+ }
126
+ }
127
+ }
128
+ /**
129
+ * Get the range that would be overwritten by input.
130
+ */
131
+
132
+
133
+ function getInputRange(focusNode) {
134
+ const typeAndSelection = getTargetTypeAndSelection(focusNode);
135
+
136
+ if (typeAndSelection.type === 'input') {
137
+ return typeAndSelection.selection;
138
+ } else if (typeAndSelection.type === 'contenteditable') {
139
+ var _typeAndSelection$sel;
140
+
141
+ // Multi-range on contenteditable edits the first selection instead of the last
142
+ return (_typeAndSelection$sel = typeAndSelection.selection) == null ? void 0 : _typeAndSelection$sel.getRangeAt(0);
143
+ }
144
+ }
145
+ /**
146
+ * Extend/shrink the selection like with Shift+Arrows or Shift+Mouse
147
+ */
148
+
149
+
150
+ function modifySelection({
151
+ focusNode,
152
+ focusOffset
153
+ }) {
154
+ var _focusNode$ownerDocum, _focusNode$ownerDocum2;
155
+
156
+ const typeAndSelection = getTargetTypeAndSelection(focusNode);
157
+
158
+ if (typeAndSelection.type === 'input') {
159
+ return (0, _document.setUISelection)(focusNode, {
160
+ anchorOffset: typeAndSelection.selection.anchorOffset,
161
+ focusOffset
162
+ }, 'modify');
163
+ }
164
+
165
+ (_focusNode$ownerDocum = focusNode.ownerDocument) == null ? void 0 : (_focusNode$ownerDocum2 = _focusNode$ownerDocum.getSelection()) == null ? void 0 : _focusNode$ownerDocum2.extend(focusNode, focusOffset);
166
+ }
167
+ /**
168
+ * Set the selection
169
+ */
170
+
171
+
172
+ function setSelection({
173
+ focusNode,
174
+ focusOffset,
175
+ anchorNode = focusNode,
176
+ anchorOffset = focusOffset
177
+ }) {
178
+ var _anchorNode$ownerDocu, _anchorNode$ownerDocu2;
179
+
180
+ const typeAndSelection = getTargetTypeAndSelection(focusNode);
181
+
182
+ if (typeAndSelection.type === 'input') {
183
+ return (0, _document.setUISelection)(focusNode, {
184
+ anchorOffset,
185
+ focusOffset
186
+ });
187
+ }
188
+
189
+ (_anchorNode$ownerDocu = anchorNode.ownerDocument) == null ? void 0 : (_anchorNode$ownerDocu2 = _anchorNode$ownerDocu.getSelection()) == null ? void 0 : _anchorNode$ownerDocu2.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
190
+ }
File without changes
@@ -1,19 +1,21 @@
1
1
  export * from './click/isClickableInput';
2
2
  export * from './edit/buildTimeValue';
3
3
  export * from './edit/calculateNewValue';
4
- export * from './edit/cursorPosition';
5
- export * from './edit/fireInputEvent';
4
+ export * from './edit/editInputElement';
6
5
  export * from './edit/getValue';
7
6
  export * from './edit/isContentEditable';
8
7
  export * from './edit/isEditable';
9
8
  export * from './edit/isValidDateValue';
10
9
  export * from './edit/isValidInputTimeValue';
11
10
  export * from './edit/maxLength';
12
- export * from './edit/selectionRange';
11
+ export * from './edit/prepareInput';
13
12
  export * from './focus/blur';
14
13
  export * from './focus/focus';
15
14
  export * from './focus/getActiveElement';
15
+ export * from './focus/getTabDestination';
16
16
  export * from './focus/isFocusable';
17
+ export * from './focus/selectAll';
18
+ export * from './focus/selection';
17
19
  export * from './focus/selector';
18
20
  export * from './keyDef/readNextDescriptor';
19
21
  export * from './misc/eventWrapper';
@@ -22,10 +24,8 @@ export * from './misc/isDescendantOrSelf';
22
24
  export * from './misc/isElementType';
23
25
  export * from './misc/isVisible';
24
26
  export * from './misc/isDisabled';
25
- export * from './misc/isDocument';
26
27
  export * from './misc/wait';
27
28
  export * from './misc/hasPointerEvents';
28
29
  export * from './misc/hasFormSubmit';
29
- export * from './pointer/fakeEvent';
30
30
  export * from './pointer/firePointerEvents';
31
31
  export * from './pointer/mouseButtons';
@@ -43,28 +43,15 @@ Object.keys(_calculateNewValue).forEach(function (key) {
43
43
  });
44
44
  });
45
45
 
46
- var _cursorPosition = require("./edit/cursorPosition");
46
+ var _editInputElement = require("./edit/editInputElement");
47
47
 
48
- Object.keys(_cursorPosition).forEach(function (key) {
48
+ Object.keys(_editInputElement).forEach(function (key) {
49
49
  if (key === "default" || key === "__esModule") return;
50
- if (key in exports && exports[key] === _cursorPosition[key]) return;
50
+ if (key in exports && exports[key] === _editInputElement[key]) return;
51
51
  Object.defineProperty(exports, key, {
52
52
  enumerable: true,
53
53
  get: function () {
54
- return _cursorPosition[key];
55
- }
56
- });
57
- });
58
-
59
- var _fireInputEvent = require("./edit/fireInputEvent");
60
-
61
- Object.keys(_fireInputEvent).forEach(function (key) {
62
- if (key === "default" || key === "__esModule") return;
63
- if (key in exports && exports[key] === _fireInputEvent[key]) return;
64
- Object.defineProperty(exports, key, {
65
- enumerable: true,
66
- get: function () {
67
- return _fireInputEvent[key];
54
+ return _editInputElement[key];
68
55
  }
69
56
  });
70
57
  });
@@ -147,15 +134,15 @@ Object.keys(_maxLength).forEach(function (key) {
147
134
  });
148
135
  });
149
136
 
150
- var _selectionRange = require("./edit/selectionRange");
137
+ var _prepareInput = require("./edit/prepareInput");
151
138
 
152
- Object.keys(_selectionRange).forEach(function (key) {
139
+ Object.keys(_prepareInput).forEach(function (key) {
153
140
  if (key === "default" || key === "__esModule") return;
154
- if (key in exports && exports[key] === _selectionRange[key]) return;
141
+ if (key in exports && exports[key] === _prepareInput[key]) return;
155
142
  Object.defineProperty(exports, key, {
156
143
  enumerable: true,
157
144
  get: function () {
158
- return _selectionRange[key];
145
+ return _prepareInput[key];
159
146
  }
160
147
  });
161
148
  });
@@ -199,6 +186,19 @@ Object.keys(_getActiveElement).forEach(function (key) {
199
186
  });
200
187
  });
201
188
 
189
+ var _getTabDestination = require("./focus/getTabDestination");
190
+
191
+ Object.keys(_getTabDestination).forEach(function (key) {
192
+ if (key === "default" || key === "__esModule") return;
193
+ if (key in exports && exports[key] === _getTabDestination[key]) return;
194
+ Object.defineProperty(exports, key, {
195
+ enumerable: true,
196
+ get: function () {
197
+ return _getTabDestination[key];
198
+ }
199
+ });
200
+ });
201
+
202
202
  var _isFocusable = require("./focus/isFocusable");
203
203
 
204
204
  Object.keys(_isFocusable).forEach(function (key) {
@@ -212,6 +212,32 @@ Object.keys(_isFocusable).forEach(function (key) {
212
212
  });
213
213
  });
214
214
 
215
+ var _selectAll = require("./focus/selectAll");
216
+
217
+ Object.keys(_selectAll).forEach(function (key) {
218
+ if (key === "default" || key === "__esModule") return;
219
+ if (key in exports && exports[key] === _selectAll[key]) return;
220
+ Object.defineProperty(exports, key, {
221
+ enumerable: true,
222
+ get: function () {
223
+ return _selectAll[key];
224
+ }
225
+ });
226
+ });
227
+
228
+ var _selection = require("./focus/selection");
229
+
230
+ Object.keys(_selection).forEach(function (key) {
231
+ if (key === "default" || key === "__esModule") return;
232
+ if (key in exports && exports[key] === _selection[key]) return;
233
+ Object.defineProperty(exports, key, {
234
+ enumerable: true,
235
+ get: function () {
236
+ return _selection[key];
237
+ }
238
+ });
239
+ });
240
+
215
241
  var _selector = require("./focus/selector");
216
242
 
217
243
  Object.keys(_selector).forEach(function (key) {
@@ -316,19 +342,6 @@ Object.keys(_isDisabled).forEach(function (key) {
316
342
  });
317
343
  });
318
344
 
319
- var _isDocument = require("./misc/isDocument");
320
-
321
- Object.keys(_isDocument).forEach(function (key) {
322
- if (key === "default" || key === "__esModule") return;
323
- if (key in exports && exports[key] === _isDocument[key]) return;
324
- Object.defineProperty(exports, key, {
325
- enumerable: true,
326
- get: function () {
327
- return _isDocument[key];
328
- }
329
- });
330
- });
331
-
332
345
  var _wait = require("./misc/wait");
333
346
 
334
347
  Object.keys(_wait).forEach(function (key) {
@@ -368,19 +381,6 @@ Object.keys(_hasFormSubmit).forEach(function (key) {
368
381
  });
369
382
  });
370
383
 
371
- var _fakeEvent = require("./pointer/fakeEvent");
372
-
373
- Object.keys(_fakeEvent).forEach(function (key) {
374
- if (key === "default" || key === "__esModule") return;
375
- if (key in exports && exports[key] === _fakeEvent[key]) return;
376
- Object.defineProperty(exports, key, {
377
- enumerable: true,
378
- get: function () {
379
- return _fakeEvent[key];
380
- }
381
- });
382
- });
383
-
384
384
  var _firePointerEvents = require("./pointer/firePointerEvents");
385
385
 
386
386
  Object.keys(_firePointerEvents).forEach(function (key) {
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,23 +1,25 @@
1
1
  import type { pointerState } from '../../pointer/types';
2
2
  import type { keyboardState } from '../../keyboard/types';
3
3
  import { MouseButton } from './mouseButtons';
4
- export interface Coords {
5
- x: number;
6
- y: number;
7
- clientX: number;
8
- clientY: number;
9
- offsetX: number;
10
- offsetY: number;
11
- pageX: number;
12
- pageY: number;
13
- }
14
4
  export declare function firePointerEvent(target: Element, type: string, { pointerState, keyboardState, pointerType, button, coords, pointerId, isPrimary, clickCount, }: {
15
5
  pointerState: pointerState;
16
6
  keyboardState: keyboardState;
17
7
  pointerType?: 'mouse' | 'pen' | 'touch';
18
8
  button?: MouseButton;
19
- coords: Coords;
9
+ coords?: PointerCoords;
20
10
  pointerId?: number;
21
11
  isPrimary?: boolean;
22
12
  clickCount?: number;
23
13
  }): boolean;
14
+ export interface PointerCoords {
15
+ x?: number;
16
+ y?: number;
17
+ clientX?: number;
18
+ clientY?: number;
19
+ offsetX?: number;
20
+ offsetY?: number;
21
+ pageX?: number;
22
+ pageY?: number;
23
+ screenX?: number;
24
+ screenY?: number;
25
+ }