@testing-library/user-event 14.0.0-beta.3 → 14.0.0-beta.7

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 (193) hide show
  1. package/dist/index.cjs +2941 -0
  2. package/dist/index.mjs +3012 -0
  3. package/dist/types/clipboard/copy.d.ts +2 -0
  4. package/dist/types/clipboard/cut.d.ts +2 -0
  5. package/dist/{clipboard → types/clipboard}/index.d.ts +0 -0
  6. package/dist/types/clipboard/paste.d.ts +2 -0
  7. package/dist/types/convenience/click.d.ts +4 -0
  8. package/dist/types/convenience/hover.d.ts +3 -0
  9. package/dist/{convenience → types/convenience}/index.d.ts +0 -0
  10. package/dist/types/convenience/tab.d.ts +4 -0
  11. package/dist/{document → types/document}/index.d.ts +0 -0
  12. package/dist/{document → types/document}/interceptor.d.ts +0 -0
  13. package/dist/{document → types/document}/selection.d.ts +0 -0
  14. package/dist/{document → types/document}/value.d.ts +0 -0
  15. package/dist/{index.d.ts → types/index.d.ts} +1 -0
  16. package/dist/{keyboard → types/keyboard}/index.d.ts +2 -2
  17. package/dist/{keyboard → types/keyboard}/keyMap.d.ts +0 -0
  18. package/dist/{keyboard → types/keyboard}/keyboardAction.d.ts +0 -0
  19. package/dist/{keyboard → types/keyboard}/parseKeyDef.d.ts +0 -0
  20. package/dist/{keyboard → types/keyboard}/plugins/arrow.d.ts +0 -0
  21. package/dist/{keyboard → types/keyboard}/plugins/character.d.ts +0 -0
  22. package/dist/{keyboard → types/keyboard}/plugins/combination.d.ts +0 -0
  23. package/dist/{keyboard → types/keyboard}/plugins/control.d.ts +0 -0
  24. package/dist/{keyboard → types/keyboard}/plugins/functional.d.ts +0 -3
  25. package/dist/{keyboard → types/keyboard}/plugins/index.d.ts +0 -0
  26. package/dist/types/keyboard/plugins/modifiers.d.ts +8 -0
  27. package/dist/{keyboard → types/keyboard}/shared/fireChangeForInputTimeIfValid.d.ts +0 -0
  28. package/dist/{keyboard → types/keyboard}/shared/index.d.ts +0 -0
  29. package/dist/{keyboard → types/keyboard}/types.d.ts +19 -5
  30. package/dist/{options.d.ts → types/options.d.ts} +23 -8
  31. package/dist/{pointer → types/pointer}/index.d.ts +2 -2
  32. package/dist/{pointer → types/pointer}/keyMap.d.ts +0 -0
  33. package/dist/{pointer → types/pointer}/parseKeyDef.d.ts +0 -0
  34. package/dist/{pointer → types/pointer}/pointerAction.d.ts +0 -0
  35. package/dist/types/pointer/pointerMove.d.ts +6 -0
  36. package/dist/{pointer → types/pointer}/pointerPress.d.ts +2 -2
  37. package/dist/{pointer → types/pointer}/resolveSelectionTarget.d.ts +0 -0
  38. package/dist/{pointer → types/pointer}/types.d.ts +0 -0
  39. package/dist/{setup → types/setup}/api.d.ts +0 -0
  40. package/dist/{setup → types/setup}/config.d.ts +0 -0
  41. package/dist/{setup → types/setup}/directApi.d.ts +1 -2
  42. package/dist/{setup → types/setup}/index.d.ts +6 -2
  43. package/dist/types/setup/setup.d.ts +19 -0
  44. package/dist/{setup → types/setup}/wrapAsync.d.ts +0 -0
  45. package/dist/types/utility/clear.d.ts +2 -0
  46. package/dist/{utility → types/utility}/index.d.ts +0 -0
  47. package/dist/types/utility/selectOptions.d.ts +3 -0
  48. package/dist/types/utility/type.d.ts +9 -0
  49. package/dist/types/utility/upload.d.ts +5 -0
  50. package/dist/{utils → types/utils}/click/isClickableInput.d.ts +0 -0
  51. package/dist/{utils → types/utils}/dataTransfer/Blob.d.ts +0 -0
  52. package/dist/{utils → types/utils}/dataTransfer/Clipboard.d.ts +0 -0
  53. package/dist/{utils → types/utils}/dataTransfer/DataTransfer.d.ts +0 -0
  54. package/dist/{utils → types/utils}/dataTransfer/FileList.d.ts +0 -0
  55. package/dist/{utils → types/utils}/edit/buildTimeValue.d.ts +0 -0
  56. package/dist/{utils → types/utils}/edit/calculateNewValue.d.ts +0 -0
  57. package/dist/{utils → types/utils}/edit/editInputElement.d.ts +0 -0
  58. package/dist/{utils → types/utils}/edit/getValue.d.ts +0 -0
  59. package/dist/{utils → types/utils}/edit/isContentEditable.d.ts +0 -0
  60. package/dist/{utils → types/utils}/edit/isEditable.d.ts +0 -0
  61. package/dist/{utils → types/utils}/edit/isValidDateValue.d.ts +0 -0
  62. package/dist/{utils → types/utils}/edit/isValidInputTimeValue.d.ts +0 -0
  63. package/dist/{utils → types/utils}/edit/maxLength.d.ts +0 -0
  64. package/dist/{utils → types/utils}/edit/prepareInput.d.ts +0 -0
  65. package/dist/{utils → types/utils}/edit/setFiles.d.ts +0 -0
  66. package/dist/{utils → types/utils}/focus/blur.d.ts +0 -0
  67. package/dist/{utils → types/utils}/focus/copySelection.d.ts +0 -0
  68. package/dist/types/utils/focus/cursor.d.ts +9 -0
  69. package/dist/{utils → types/utils}/focus/focus.d.ts +0 -0
  70. package/dist/{utils → types/utils}/focus/getActiveElement.d.ts +0 -0
  71. package/dist/{utils → types/utils}/focus/getTabDestination.d.ts +0 -0
  72. package/dist/{utils → types/utils}/focus/isFocusable.d.ts +0 -0
  73. package/dist/{utils → types/utils}/focus/selectAll.d.ts +0 -0
  74. package/dist/{utils → types/utils}/focus/selection.d.ts +0 -0
  75. package/dist/{utils → types/utils}/focus/selector.d.ts +0 -0
  76. package/dist/{utils → types/utils}/index.d.ts +5 -1
  77. package/dist/{utils → types/utils}/keyDef/readNextDescriptor.d.ts +0 -0
  78. package/dist/types/utils/keyboard/getKeyEventProps.d.ts +17 -0
  79. package/dist/types/utils/keyboard/getUIEventModifiers.d.ts +15 -0
  80. package/dist/{utils → types/utils}/misc/eventWrapper.d.ts +0 -0
  81. package/dist/{utils → types/utils}/misc/findClosest.d.ts +0 -0
  82. package/dist/{utils → types/utils}/misc/getDocumentFromNode.d.ts +0 -0
  83. package/dist/{utils → types/utils}/misc/hasFormSubmit.d.ts +0 -0
  84. package/dist/{utils → types/utils}/misc/isDescendantOrSelf.d.ts +0 -0
  85. package/dist/{utils → types/utils}/misc/isDisabled.d.ts +0 -0
  86. package/dist/{utils → types/utils}/misc/isElementType.d.ts +0 -0
  87. package/dist/{utils → types/utils}/misc/isVisible.d.ts +0 -0
  88. package/dist/types/utils/misc/level.d.ts +17 -0
  89. package/dist/{utils → types/utils}/misc/wait.d.ts +0 -0
  90. package/dist/types/utils/pointer/cssPointerEvents.d.ts +15 -0
  91. package/dist/{utils → types/utils}/pointer/firePointerEvents.d.ts +0 -0
  92. package/dist/{utils → types/utils}/pointer/mouseButtons.d.ts +0 -0
  93. package/package.json +13 -30
  94. package/dist/clipboard/copy.d.ts +0 -2
  95. package/dist/clipboard/copy.js +0 -36
  96. package/dist/clipboard/cut.d.ts +0 -2
  97. package/dist/clipboard/cut.js +0 -42
  98. package/dist/clipboard/index.js +0 -44
  99. package/dist/clipboard/paste.d.ts +0 -2
  100. package/dist/clipboard/paste.js +0 -47
  101. package/dist/convenience/click.d.ts +0 -4
  102. package/dist/convenience/click.js +0 -52
  103. package/dist/convenience/hover.d.ts +0 -3
  104. package/dist/convenience/hover.js +0 -31
  105. package/dist/convenience/index.js +0 -44
  106. package/dist/convenience/tab.d.ts +0 -4
  107. package/dist/convenience/tab.js +0 -12
  108. package/dist/document/index.js +0 -100
  109. package/dist/document/interceptor.js +0 -37
  110. package/dist/document/selection.js +0 -90
  111. package/dist/document/value.js +0 -77
  112. package/dist/index.js +0 -13
  113. package/dist/keyboard/getEventProps.d.ts +0 -15
  114. package/dist/keyboard/getEventProps.js +0 -27
  115. package/dist/keyboard/index.js +0 -42
  116. package/dist/keyboard/keyMap.js +0 -119
  117. package/dist/keyboard/keyboardAction.js +0 -156
  118. package/dist/keyboard/parseKeyDef.js +0 -61
  119. package/dist/keyboard/plugins/arrow.js +0 -28
  120. package/dist/keyboard/plugins/character.js +0 -173
  121. package/dist/keyboard/plugins/combination.js +0 -19
  122. package/dist/keyboard/plugins/control.js +0 -52
  123. package/dist/keyboard/plugins/functional.js +0 -158
  124. package/dist/keyboard/plugins/index.js +0 -33
  125. package/dist/keyboard/shared/fireChangeForInputTimeIfValid.js +0 -20
  126. package/dist/keyboard/shared/index.js +0 -18
  127. package/dist/keyboard/types.js +0 -19
  128. package/dist/options.js +0 -36
  129. package/dist/pointer/index.js +0 -56
  130. package/dist/pointer/keyMap.js +0 -29
  131. package/dist/pointer/parseKeyDef.js +0 -34
  132. package/dist/pointer/pointerAction.js +0 -46
  133. package/dist/pointer/pointerMove.d.ts +0 -6
  134. package/dist/pointer/pointerMove.js +0 -136
  135. package/dist/pointer/pointerPress.js +0 -327
  136. package/dist/pointer/resolveSelectionTarget.js +0 -75
  137. package/dist/pointer/types.js +0 -1
  138. package/dist/setup/api.js +0 -111
  139. package/dist/setup/config.js +0 -8
  140. package/dist/setup/directApi.js +0 -95
  141. package/dist/setup/index.js +0 -27
  142. package/dist/setup/setup.d.ts +0 -74
  143. package/dist/setup/setup.js +0 -98
  144. package/dist/setup/wrapAsync.js +0 -15
  145. package/dist/utility/clear.d.ts +0 -2
  146. package/dist/utility/clear.js +0 -30
  147. package/dist/utility/index.js +0 -57
  148. package/dist/utility/selectOptions.d.ts +0 -3
  149. package/dist/utility/selectOptions.js +0 -132
  150. package/dist/utility/type.d.ts +0 -9
  151. package/dist/utility/type.js +0 -37
  152. package/dist/utility/upload.d.ts +0 -5
  153. package/dist/utility/upload.js +0 -64
  154. package/dist/utils/click/isClickableInput.js +0 -14
  155. package/dist/utils/dataTransfer/Blob.js +0 -21
  156. package/dist/utils/dataTransfer/Clipboard.js +0 -188
  157. package/dist/utils/dataTransfer/DataTransfer.js +0 -158
  158. package/dist/utils/dataTransfer/FileList.js +0 -23
  159. package/dist/utils/edit/buildTimeValue.js +0 -44
  160. package/dist/utils/edit/calculateNewValue.js +0 -46
  161. package/dist/utils/edit/editInputElement.js +0 -53
  162. package/dist/utils/edit/getValue.js +0 -23
  163. package/dist/utils/edit/isContentEditable.js +0 -25
  164. package/dist/utils/edit/isEditable.js +0 -42
  165. package/dist/utils/edit/isValidDateValue.js +0 -12
  166. package/dist/utils/edit/isValidInputTimeValue.js +0 -12
  167. package/dist/utils/edit/maxLength.js +0 -50
  168. package/dist/utils/edit/prepareInput.js +0 -77
  169. package/dist/utils/edit/setFiles.js +0 -72
  170. package/dist/utils/focus/blur.js +0 -19
  171. package/dist/utils/focus/copySelection.js +0 -36
  172. package/dist/utils/focus/focus.js +0 -22
  173. package/dist/utils/focus/getActiveElement.js +0 -26
  174. package/dist/utils/focus/getTabDestination.js +0 -84
  175. package/dist/utils/focus/isFocusable.js +0 -12
  176. package/dist/utils/focus/selectAll.js +0 -51
  177. package/dist/utils/focus/selection.js +0 -190
  178. package/dist/utils/focus/selector.js +0 -8
  179. package/dist/utils/index.js +0 -499
  180. package/dist/utils/keyDef/readNextDescriptor.js +0 -102
  181. package/dist/utils/misc/eventWrapper.js +0 -16
  182. package/dist/utils/misc/findClosest.js +0 -20
  183. package/dist/utils/misc/getDocumentFromNode.js +0 -14
  184. package/dist/utils/misc/hasFormSubmit.js +0 -10
  185. package/dist/utils/misc/hasPointerEvents.d.ts +0 -15
  186. package/dist/utils/misc/hasPointerEvents.js +0 -24
  187. package/dist/utils/misc/isDescendantOrSelf.js +0 -20
  188. package/dist/utils/misc/isDisabled.js +0 -12
  189. package/dist/utils/misc/isElementType.js +0 -24
  190. package/dist/utils/misc/isVisible.js +0 -31
  191. package/dist/utils/misc/wait.js +0 -10
  192. package/dist/utils/pointer/firePointerEvents.js +0 -110
  193. package/dist/utils/pointer/mouseButtons.js +0 -45
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.copy = copy;
7
-
8
- var _dom = require("@testing-library/dom");
9
-
10
- var _setup = require("../setup");
11
-
12
- var _utils = require("../utils");
13
-
14
- async function copy() {
15
- var _doc$activeElement;
16
-
17
- const doc = this[_setup.Config].document;
18
- const target = (_doc$activeElement = doc.activeElement) != null ? _doc$activeElement :
19
- /* istanbul ignore next */
20
- doc.body;
21
- const clipboardData = (0, _utils.copySelection)(target);
22
-
23
- if (clipboardData.items.length === 0) {
24
- return;
25
- }
26
-
27
- _dom.fireEvent.copy(target, {
28
- clipboardData
29
- });
30
-
31
- if (this[_setup.Config].writeToClipboard) {
32
- await (0, _utils.writeDataTransferToClipboard)(doc, clipboardData);
33
- }
34
-
35
- return clipboardData;
36
- }
@@ -1,2 +0,0 @@
1
- import { UserEvent } from '../setup';
2
- export declare function cut(this: UserEvent): Promise<DataTransfer | undefined>;
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.cut = cut;
7
-
8
- var _dom = require("@testing-library/dom");
9
-
10
- var _setup = require("../setup");
11
-
12
- var _utils = require("../utils");
13
-
14
- async function cut() {
15
- var _doc$activeElement;
16
-
17
- const doc = this[_setup.Config].document;
18
- const target = (_doc$activeElement = doc.activeElement) != null ? _doc$activeElement :
19
- /* istanbul ignore next */
20
- doc.body;
21
- const clipboardData = (0, _utils.copySelection)(target);
22
-
23
- if (clipboardData.items.length === 0) {
24
- return;
25
- }
26
-
27
- _dom.fireEvent.cut(target, {
28
- clipboardData
29
- });
30
-
31
- if ((0, _utils.isEditable)(target)) {
32
- var _prepareInput;
33
-
34
- (_prepareInput = (0, _utils.prepareInput)('', target, 'deleteByCut')) == null ? void 0 : _prepareInput.commit();
35
- }
36
-
37
- if (this[_setup.Config].writeToClipboard) {
38
- await (0, _utils.writeDataTransferToClipboard)(doc, clipboardData);
39
- }
40
-
41
- return clipboardData;
42
- }
@@ -1,44 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _copy = require("./copy");
8
-
9
- Object.keys(_copy).forEach(function (key) {
10
- if (key === "default" || key === "__esModule") return;
11
- if (key in exports && exports[key] === _copy[key]) return;
12
- Object.defineProperty(exports, key, {
13
- enumerable: true,
14
- get: function () {
15
- return _copy[key];
16
- }
17
- });
18
- });
19
-
20
- var _cut = require("./cut");
21
-
22
- Object.keys(_cut).forEach(function (key) {
23
- if (key === "default" || key === "__esModule") return;
24
- if (key in exports && exports[key] === _cut[key]) return;
25
- Object.defineProperty(exports, key, {
26
- enumerable: true,
27
- get: function () {
28
- return _cut[key];
29
- }
30
- });
31
- });
32
-
33
- var _paste = require("./paste");
34
-
35
- Object.keys(_paste).forEach(function (key) {
36
- if (key === "default" || key === "__esModule") return;
37
- if (key in exports && exports[key] === _paste[key]) return;
38
- Object.defineProperty(exports, key, {
39
- enumerable: true,
40
- get: function () {
41
- return _paste[key];
42
- }
43
- });
44
- });
@@ -1,2 +0,0 @@
1
- import { UserEvent } from '../setup';
2
- export declare function paste(this: UserEvent, clipboardData?: DataTransfer | string): Promise<void>;
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.paste = paste;
7
-
8
- var _dom = require("@testing-library/dom");
9
-
10
- var _setup = require("../setup");
11
-
12
- var _utils = require("../utils");
13
-
14
- async function paste(clipboardData) {
15
- var _doc$activeElement, _ref;
16
-
17
- const doc = this[_setup.Config].document;
18
- const target = (_doc$activeElement = doc.activeElement) != null ? _doc$activeElement :
19
- /* istanbul ignore next */
20
- doc.body;
21
- const data = (_ref = typeof clipboardData === 'string' ? getClipboardDataFromString(clipboardData) : clipboardData) != null ? _ref : await (0, _utils.readDataTransferFromClipboard)(doc).catch(() => {
22
- throw new Error('`userEvent.paste()` without `clipboardData` requires the `ClipboardAPI` to be available.');
23
- });
24
- return pasteImpl(target, data);
25
- }
26
-
27
- function pasteImpl(target, clipboardData) {
28
- _dom.fireEvent.paste(target, {
29
- clipboardData
30
- });
31
-
32
- if ((0, _utils.isEditable)(target)) {
33
- const data = clipboardData.getData('text').substr(0, (0, _utils.getSpaceUntilMaxLength)(target));
34
-
35
- if (data) {
36
- var _prepareInput;
37
-
38
- (_prepareInput = (0, _utils.prepareInput)(data, target, 'insertFromPaste')) == null ? void 0 : _prepareInput.commit();
39
- }
40
- }
41
- }
42
-
43
- function getClipboardDataFromString(text) {
44
- const dt = (0, _utils.createDataTransfer)();
45
- dt.setData('text', text);
46
- return dt;
47
- }
@@ -1,4 +0,0 @@
1
- import { UserEvent } from '../setup';
2
- export declare function click(this: UserEvent, element: Element): Promise<void>;
3
- export declare function dblClick(this: UserEvent, element: Element): Promise<void>;
4
- export declare function tripleClick(this: UserEvent, element: Element): Promise<void>;
@@ -1,52 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.click = click;
7
- exports.dblClick = dblClick;
8
- exports.tripleClick = tripleClick;
9
-
10
- var _utils = require("../utils");
11
-
12
- var _setup = require("../setup");
13
-
14
- async function click(element) {
15
- if (!this[_setup.Config].skipPointerEventsCheck && !(0, _utils.hasPointerEvents)(element)) {
16
- throw new Error('unable to click element as it has or inherits pointer-events set to "none".');
17
- }
18
-
19
- const pointerIn = [];
20
-
21
- if (!this[_setup.Config].skipHover) {
22
- pointerIn.push({
23
- target: element
24
- });
25
- }
26
-
27
- pointerIn.push({
28
- keys: '[MouseLeft]',
29
- target: element
30
- });
31
- return this.pointer(pointerIn);
32
- }
33
-
34
- async function dblClick(element) {
35
- if (!this[_setup.Config].skipPointerEventsCheck && !(0, _utils.hasPointerEvents)(element)) {
36
- throw new Error('unable to double-click element as it has or inherits pointer-events set to "none".');
37
- }
38
-
39
- return this.pointer([{
40
- target: element
41
- }, '[MouseLeft][MouseLeft]']);
42
- }
43
-
44
- async function tripleClick(element) {
45
- if (!this[_setup.Config].skipPointerEventsCheck && !(0, _utils.hasPointerEvents)(element)) {
46
- throw new Error('unable to triple-click element as it has or inherits pointer-events set to "none".');
47
- }
48
-
49
- return this.pointer([{
50
- target: element
51
- }, '[MouseLeft][MouseLeft][MouseLeft]']);
52
- }
@@ -1,3 +0,0 @@
1
- import { UserEvent } from '../setup';
2
- export declare function hover(this: UserEvent, element: Element): Promise<void>;
3
- export declare function unhover(this: UserEvent, element: Element): Promise<void>;
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.hover = hover;
7
- exports.unhover = unhover;
8
-
9
- var _setup = require("../setup");
10
-
11
- var _utils = require("../utils");
12
-
13
- async function hover(element) {
14
- if (!this[_setup.Config].skipPointerEventsCheck && !(0, _utils.hasPointerEvents)(element)) {
15
- throw new Error('unable to hover element as it has or inherits pointer-events set to "none".');
16
- }
17
-
18
- return this.pointer({
19
- target: element
20
- });
21
- }
22
-
23
- async function unhover(element) {
24
- if (!this[_setup.Config].skipPointerEventsCheck && !(0, _utils.hasPointerEvents)(element)) {
25
- throw new Error('unable to unhover element as it has or inherits pointer-events set to "none".');
26
- }
27
-
28
- return this.pointer({
29
- target: element.ownerDocument.body
30
- });
31
- }
@@ -1,44 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _click = require("./click");
8
-
9
- Object.keys(_click).forEach(function (key) {
10
- if (key === "default" || key === "__esModule") return;
11
- if (key in exports && exports[key] === _click[key]) return;
12
- Object.defineProperty(exports, key, {
13
- enumerable: true,
14
- get: function () {
15
- return _click[key];
16
- }
17
- });
18
- });
19
-
20
- var _hover = require("./hover");
21
-
22
- Object.keys(_hover).forEach(function (key) {
23
- if (key === "default" || key === "__esModule") return;
24
- if (key in exports && exports[key] === _hover[key]) return;
25
- Object.defineProperty(exports, key, {
26
- enumerable: true,
27
- get: function () {
28
- return _hover[key];
29
- }
30
- });
31
- });
32
-
33
- var _tab = require("./tab");
34
-
35
- Object.keys(_tab).forEach(function (key) {
36
- if (key === "default" || key === "__esModule") return;
37
- if (key in exports && exports[key] === _tab[key]) return;
38
- Object.defineProperty(exports, key, {
39
- enumerable: true,
40
- get: function () {
41
- return _tab[key];
42
- }
43
- });
44
- });
@@ -1,4 +0,0 @@
1
- import type { UserEvent } from '../setup';
2
- export declare function tab(this: UserEvent, { shift, }?: {
3
- shift?: boolean;
4
- }): Promise<void>;
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.tab = tab;
7
-
8
- async function tab({
9
- shift
10
- } = {}) {
11
- return this.keyboard(shift === true ? '{Shift>}{Tab}{/Shift}' : shift === false ? '[/ShiftLeft][/ShiftRight]{Tab}' : '{Tab}');
12
- }
@@ -1,100 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "endTrackValue", {
7
- enumerable: true,
8
- get: function () {
9
- return _value.endTrackValue;
10
- }
11
- });
12
- Object.defineProperty(exports, "getUISelection", {
13
- enumerable: true,
14
- get: function () {
15
- return _selection.getUISelection;
16
- }
17
- });
18
- Object.defineProperty(exports, "getUIValue", {
19
- enumerable: true,
20
- get: function () {
21
- return _value.getUIValue;
22
- }
23
- });
24
- exports.prepareDocument = prepareDocument;
25
- Object.defineProperty(exports, "setUISelection", {
26
- enumerable: true,
27
- get: function () {
28
- return _selection.setUISelection;
29
- }
30
- });
31
- Object.defineProperty(exports, "setUIValue", {
32
- enumerable: true,
33
- get: function () {
34
- return _value.setUIValue;
35
- }
36
- });
37
- Object.defineProperty(exports, "startTrackValue", {
38
- enumerable: true,
39
- get: function () {
40
- return _value.startTrackValue;
41
- }
42
- });
43
-
44
- var _dom = require("@testing-library/dom");
45
-
46
- var _selection = require("./selection");
47
-
48
- var _value = require("./value");
49
-
50
- const isPrepared = Symbol('Node prepared with document state workarounds');
51
-
52
- function prepareDocument(document) {
53
- if (document[isPrepared]) {
54
- return;
55
- }
56
-
57
- document.addEventListener('focus', e => {
58
- const el = e.target;
59
- prepareElement(el);
60
- }, {
61
- capture: true,
62
- passive: true
63
- }); // Our test environment defaults to `document.body` as `activeElement`.
64
- // In other environments this might be `null` when preparing.
65
- // istanbul ignore else
66
-
67
- if (document.activeElement) {
68
- prepareElement(document.activeElement);
69
- }
70
-
71
- document.addEventListener('blur', e => {
72
- const el = e.target;
73
- const initialValue = (0, _value.getInitialValue)(el);
74
-
75
- if (typeof initialValue === 'string' && el.value !== initialValue) {
76
- _dom.fireEvent.change(el);
77
- }
78
- }, {
79
- capture: true,
80
- passive: true
81
- });
82
- document[isPrepared] = isPrepared;
83
- }
84
-
85
- function prepareElement(el) {
86
- if ('value' in el) {
87
- (0, _value.setInitialValue)(el);
88
- }
89
-
90
- if (el[isPrepared]) {
91
- return;
92
- }
93
-
94
- if ('value' in el) {
95
- (0, _value.prepareValueInterceptor)(el);
96
- (0, _selection.prepareSelectionInterceptor)(el);
97
- }
98
-
99
- el[isPrepared] = isPrepared;
100
- }
@@ -1,37 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.prepareInterceptor = prepareInterceptor;
7
- const Interceptor = Symbol('Interceptor for programmatical calls');
8
-
9
- function prepareInterceptor(element, propName, interceptorImpl) {
10
- const prototypeDescriptor = Object.getOwnPropertyDescriptor(element.constructor.prototype, propName);
11
- const objectDescriptor = Object.getOwnPropertyDescriptor(element, propName);
12
- const target = prototypeDescriptor != null && prototypeDescriptor.set ? 'set' : 'value';
13
-
14
- if (typeof (prototypeDescriptor == null ? void 0 : prototypeDescriptor[target]) !== 'function' || prototypeDescriptor[target][Interceptor]) {
15
- return;
16
- }
17
-
18
- function intercept(...args) {
19
- const {
20
- applyNative = true,
21
- realArgs
22
- } = interceptorImpl.call(this, ...args);
23
- const realFunc = (!applyNative && objectDescriptor || prototypeDescriptor)[target];
24
-
25
- if (target === 'set') {
26
- realFunc.call(this, realArgs);
27
- } else {
28
- realFunc.call(this, ...realArgs);
29
- }
30
- }
31
-
32
- ;
33
- intercept[Interceptor] = Interceptor;
34
- Object.defineProperty(element, propName, { ...(objectDescriptor != null ? objectDescriptor : prototypeDescriptor),
35
- [target]: intercept
36
- });
37
- }
@@ -1,90 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.clearUISelection = clearUISelection;
7
- exports.getUISelection = getUISelection;
8
- exports.prepareSelectionInterceptor = prepareSelectionInterceptor;
9
- exports.setUISelection = setUISelection;
10
-
11
- var _ = require(".");
12
-
13
- var _interceptor = require("./interceptor");
14
-
15
- const UISelection = Symbol('Displayed selection in UI');
16
-
17
- function prepareSelectionInterceptor(element) {
18
- (0, _interceptor.prepareInterceptor)(element, 'setSelectionRange', function interceptorImpl(start, end, direction = 'none') {
19
- const isUI = start && typeof start === 'object' && start[UISelection];
20
-
21
- if (!isUI) {
22
- this[UISelection] = undefined;
23
- }
24
-
25
- return {
26
- realArgs: [Number(start), end, direction]
27
- };
28
- });
29
- (0, _interceptor.prepareInterceptor)(element, 'selectionStart', function interceptorImpl(v) {
30
- this[UISelection] = undefined;
31
- return {
32
- realArgs: v
33
- };
34
- });
35
- (0, _interceptor.prepareInterceptor)(element, 'selectionEnd', function interceptorImpl(v) {
36
- this[UISelection] = undefined;
37
- return {
38
- realArgs: v
39
- };
40
- });
41
- }
42
-
43
- function setUISelection(element, {
44
- focusOffset: focusOffsetParam,
45
- anchorOffset: anchorOffsetParam = focusOffsetParam
46
- }, mode = 'replace') {
47
- const valueLength = (0, _.getUIValue)(element).length;
48
-
49
- const sanitizeOffset = o => Math.max(0, Math.min(valueLength, o));
50
-
51
- const anchorOffset = mode === 'replace' || element[UISelection] === undefined ? sanitizeOffset(anchorOffsetParam) : element[UISelection].anchorOffset;
52
- const focusOffset = sanitizeOffset(focusOffsetParam);
53
- const startOffset = Math.min(anchorOffset, focusOffset);
54
- const endOffset = Math.max(anchorOffset, focusOffset);
55
- element[UISelection] = {
56
- anchorOffset,
57
- focusOffset
58
- };
59
-
60
- if (element.selectionStart === startOffset && element.selectionEnd === endOffset) {
61
- return;
62
- } // eslint-disable-next-line no-new-wrappers
63
-
64
-
65
- const startObj = new Number(startOffset);
66
- startObj[UISelection] = UISelection;
67
-
68
- try {
69
- element.setSelectionRange(startObj, endOffset);
70
- } catch {// DOMException for invalid state is expected when calling this
71
- // on an element without support for setSelectionRange
72
- }
73
- }
74
-
75
- function getUISelection(element) {
76
- var _element$UISelection, _element$selectionSta, _element$selectionEnd;
77
-
78
- const sel = (_element$UISelection = element[UISelection]) != null ? _element$UISelection : {
79
- anchorOffset: (_element$selectionSta = element.selectionStart) != null ? _element$selectionSta : 0,
80
- focusOffset: (_element$selectionEnd = element.selectionEnd) != null ? _element$selectionEnd : 0
81
- };
82
- return { ...sel,
83
- startOffset: Math.min(sel.anchorOffset, sel.focusOffset),
84
- endOffset: Math.max(sel.anchorOffset, sel.focusOffset)
85
- };
86
- }
87
-
88
- function clearUISelection(element) {
89
- element[UISelection] = undefined;
90
- }
@@ -1,77 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.endTrackValue = endTrackValue;
7
- exports.getInitialValue = getInitialValue;
8
- exports.getUIValue = getUIValue;
9
- exports.prepareValueInterceptor = prepareValueInterceptor;
10
- exports.setInitialValue = setInitialValue;
11
- exports.setUIValue = setUIValue;
12
- exports.startTrackValue = startTrackValue;
13
-
14
- var _interceptor = require("./interceptor");
15
-
16
- var _selection = require("./selection");
17
-
18
- const UIValue = Symbol('Displayed value in UI');
19
- const InitialValue = Symbol('Initial value to compare on blur');
20
- const TrackChanges = Symbol('Track programmatic changes for React workaround');
21
-
22
- function valueInterceptor(v) {
23
- const isUI = typeof v === 'object' && v[UIValue];
24
- this[UIValue] = isUI ? String(v) : undefined;
25
-
26
- if (!isUI) {
27
- trackValue(this, String(v));
28
- this[InitialValue] = String(v); // Programmatically setting the value property
29
- // moves the cursor to the end of the input.
30
-
31
- (0, _selection.clearUISelection)(this);
32
- }
33
-
34
- return {
35
- applyNative: !!isUI,
36
- realArgs: String(v)
37
- };
38
- }
39
-
40
- function prepareValueInterceptor(element) {
41
- (0, _interceptor.prepareInterceptor)(element, 'value', valueInterceptor);
42
- }
43
-
44
- function setUIValue(element, value) {
45
- element.value = {
46
- [UIValue]: UIValue,
47
- toString: () => value
48
- };
49
- }
50
-
51
- function getUIValue(element) {
52
- return element[UIValue] === undefined ? element.value : String(element[UIValue]);
53
- }
54
-
55
- function setInitialValue(element) {
56
- element[InitialValue] = element.value;
57
- }
58
-
59
- function getInitialValue(element) {
60
- return element[InitialValue];
61
- }
62
-
63
- function startTrackValue(element) {
64
- element[TrackChanges] = [];
65
- }
66
-
67
- function trackValue(element, v) {
68
- var _element$TrackChanges;
69
-
70
- (_element$TrackChanges = element[TrackChanges]) == null ? void 0 : _element$TrackChanges.push(v);
71
- }
72
-
73
- function endTrackValue(element) {
74
- const tracked = element[TrackChanges];
75
- element[TrackChanges] = undefined;
76
- return tracked;
77
- }
package/dist/index.js DELETED
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "default", {
7
- enumerable: true,
8
- get: function () {
9
- return _setup.userEvent;
10
- }
11
- });
12
-
13
- var _setup = require("./setup");
@@ -1,15 +0,0 @@
1
- import { keyboardKey, keyboardState } from './types';
2
- export declare function getKeyEventProps(keyDef: keyboardKey, state: keyboardState): {
3
- key: string | undefined;
4
- code: string | undefined;
5
- altKey: boolean;
6
- ctrlKey: boolean;
7
- metaKey: boolean;
8
- shiftKey: boolean;
9
- };
10
- export declare function getMouseEventProps(state: keyboardState): {
11
- altKey: boolean;
12
- ctrlKey: boolean;
13
- metaKey: boolean;
14
- shiftKey: boolean;
15
- };