@testing-library/user-event 14.0.0-beta.2 → 14.0.0-beta.6

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 (179) hide show
  1. package/dist/index.cjs +2896 -0
  2. package/dist/index.mjs +2967 -0
  3. package/dist/{clipboard → types/clipboard}/copy.d.ts +0 -0
  4. package/dist/{clipboard → types/clipboard}/cut.d.ts +0 -0
  5. package/dist/{clipboard → types/clipboard}/index.d.ts +0 -0
  6. package/dist/{clipboard → types/clipboard}/paste.d.ts +0 -0
  7. package/dist/{convenience → types/convenience}/click.d.ts +0 -0
  8. package/dist/{convenience → types/convenience}/hover.d.ts +0 -0
  9. package/dist/{convenience → types/convenience}/index.d.ts +0 -0
  10. package/dist/{convenience → types/convenience}/tab.d.ts +0 -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} +0 -0
  16. package/dist/{keyboard → types/keyboard}/index.d.ts +0 -0
  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} +0 -0
  31. package/dist/{pointer → types/pointer}/index.d.ts +0 -0
  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/{pointer → types/pointer}/pointerMove.d.ts +0 -0
  36. package/dist/{pointer → types/pointer}/pointerPress.d.ts +0 -0
  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 +0 -0
  42. package/dist/{setup → types/setup}/index.d.ts +0 -0
  43. package/dist/{setup → types/setup}/setup.d.ts +0 -0
  44. package/dist/{setup → types/setup}/wrapAsync.d.ts +0 -0
  45. package/dist/{utility → types/utility}/clear.d.ts +0 -0
  46. package/dist/{utility → types/utility}/index.d.ts +0 -0
  47. package/dist/{utility → types/utility}/selectOptions.d.ts +0 -0
  48. package/dist/{utility → types/utility}/type.d.ts +0 -0
  49. package/dist/{utility → types/utility}/upload.d.ts +0 -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 +3 -0
  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/hasPointerEvents.d.ts +0 -0
  85. package/dist/{utils → types/utils}/misc/isDescendantOrSelf.d.ts +0 -0
  86. package/dist/{utils → types/utils}/misc/isDisabled.d.ts +0 -0
  87. package/dist/{utils → types/utils}/misc/isElementType.d.ts +0 -0
  88. package/dist/{utils → types/utils}/misc/isVisible.d.ts +0 -0
  89. package/dist/{utils → types/utils}/misc/wait.d.ts +0 -0
  90. package/dist/{utils → types/utils}/pointer/firePointerEvents.d.ts +0 -0
  91. package/dist/{utils → types/utils}/pointer/mouseButtons.d.ts +0 -0
  92. package/package.json +13 -30
  93. package/dist/clipboard/copy.js +0 -36
  94. package/dist/clipboard/cut.js +0 -42
  95. package/dist/clipboard/index.js +0 -44
  96. package/dist/clipboard/paste.js +0 -47
  97. package/dist/convenience/click.js +0 -52
  98. package/dist/convenience/hover.js +0 -31
  99. package/dist/convenience/index.js +0 -44
  100. package/dist/convenience/tab.js +0 -12
  101. package/dist/document/index.js +0 -100
  102. package/dist/document/interceptor.js +0 -37
  103. package/dist/document/selection.js +0 -90
  104. package/dist/document/value.js +0 -77
  105. package/dist/index.js +0 -13
  106. package/dist/keyboard/getEventProps.d.ts +0 -15
  107. package/dist/keyboard/getEventProps.js +0 -27
  108. package/dist/keyboard/index.js +0 -42
  109. package/dist/keyboard/keyMap.js +0 -119
  110. package/dist/keyboard/keyboardAction.js +0 -156
  111. package/dist/keyboard/parseKeyDef.js +0 -61
  112. package/dist/keyboard/plugins/arrow.js +0 -28
  113. package/dist/keyboard/plugins/character.js +0 -173
  114. package/dist/keyboard/plugins/combination.js +0 -19
  115. package/dist/keyboard/plugins/control.js +0 -52
  116. package/dist/keyboard/plugins/functional.js +0 -158
  117. package/dist/keyboard/plugins/index.js +0 -33
  118. package/dist/keyboard/shared/fireChangeForInputTimeIfValid.js +0 -20
  119. package/dist/keyboard/shared/index.js +0 -18
  120. package/dist/keyboard/types.js +0 -19
  121. package/dist/options.js +0 -36
  122. package/dist/pointer/index.js +0 -56
  123. package/dist/pointer/keyMap.js +0 -29
  124. package/dist/pointer/parseKeyDef.js +0 -34
  125. package/dist/pointer/pointerAction.js +0 -46
  126. package/dist/pointer/pointerMove.js +0 -136
  127. package/dist/pointer/pointerPress.js +0 -330
  128. package/dist/pointer/resolveSelectionTarget.js +0 -75
  129. package/dist/pointer/types.js +0 -1
  130. package/dist/setup/api.js +0 -111
  131. package/dist/setup/config.js +0 -8
  132. package/dist/setup/directApi.js +0 -95
  133. package/dist/setup/index.js +0 -27
  134. package/dist/setup/setup.js +0 -98
  135. package/dist/setup/wrapAsync.js +0 -15
  136. package/dist/utility/clear.js +0 -30
  137. package/dist/utility/index.js +0 -57
  138. package/dist/utility/selectOptions.js +0 -132
  139. package/dist/utility/type.js +0 -37
  140. package/dist/utility/upload.js +0 -64
  141. package/dist/utils/click/isClickableInput.js +0 -14
  142. package/dist/utils/dataTransfer/Blob.js +0 -21
  143. package/dist/utils/dataTransfer/Clipboard.js +0 -188
  144. package/dist/utils/dataTransfer/DataTransfer.js +0 -158
  145. package/dist/utils/dataTransfer/FileList.js +0 -23
  146. package/dist/utils/edit/buildTimeValue.js +0 -44
  147. package/dist/utils/edit/calculateNewValue.js +0 -46
  148. package/dist/utils/edit/editInputElement.js +0 -53
  149. package/dist/utils/edit/getValue.js +0 -23
  150. package/dist/utils/edit/isContentEditable.js +0 -25
  151. package/dist/utils/edit/isEditable.js +0 -42
  152. package/dist/utils/edit/isValidDateValue.js +0 -12
  153. package/dist/utils/edit/isValidInputTimeValue.js +0 -12
  154. package/dist/utils/edit/maxLength.js +0 -50
  155. package/dist/utils/edit/prepareInput.js +0 -77
  156. package/dist/utils/edit/setFiles.js +0 -72
  157. package/dist/utils/focus/blur.js +0 -19
  158. package/dist/utils/focus/copySelection.js +0 -36
  159. package/dist/utils/focus/focus.js +0 -22
  160. package/dist/utils/focus/getActiveElement.js +0 -26
  161. package/dist/utils/focus/getTabDestination.js +0 -71
  162. package/dist/utils/focus/isFocusable.js +0 -12
  163. package/dist/utils/focus/selectAll.js +0 -51
  164. package/dist/utils/focus/selection.js +0 -190
  165. package/dist/utils/focus/selector.js +0 -8
  166. package/dist/utils/index.js +0 -499
  167. package/dist/utils/keyDef/readNextDescriptor.js +0 -102
  168. package/dist/utils/misc/eventWrapper.js +0 -16
  169. package/dist/utils/misc/findClosest.js +0 -20
  170. package/dist/utils/misc/getDocumentFromNode.js +0 -14
  171. package/dist/utils/misc/hasFormSubmit.js +0 -10
  172. package/dist/utils/misc/hasPointerEvents.js +0 -24
  173. package/dist/utils/misc/isDescendantOrSelf.js +0 -20
  174. package/dist/utils/misc/isDisabled.js +0 -12
  175. package/dist/utils/misc/isElementType.js +0 -24
  176. package/dist/utils/misc/isVisible.js +0 -31
  177. package/dist/utils/misc/wait.js +0 -10
  178. package/dist/utils/pointer/firePointerEvents.js +0 -112
  179. package/dist/utils/pointer/mouseButtons.js +0 -45
@@ -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,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
- };
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getKeyEventProps = getKeyEventProps;
7
- exports.getMouseEventProps = getMouseEventProps;
8
-
9
- function getKeyEventProps(keyDef, state) {
10
- return {
11
- key: keyDef.key,
12
- code: keyDef.code,
13
- altKey: state.modifiers.alt,
14
- ctrlKey: state.modifiers.ctrl,
15
- metaKey: state.modifiers.meta,
16
- shiftKey: state.modifiers.shift
17
- };
18
- }
19
-
20
- function getMouseEventProps(state) {
21
- return {
22
- altKey: state.modifiers.alt,
23
- ctrlKey: state.modifiers.ctrl,
24
- metaKey: state.modifiers.meta,
25
- shiftKey: state.modifiers.shift
26
- };
27
- }
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createKeyboardState = createKeyboardState;
7
- exports.keyboard = keyboard;
8
- Object.defineProperty(exports, "releaseAllKeys", {
9
- enumerable: true,
10
- get: function () {
11
- return _keyboardAction.releaseAllKeys;
12
- }
13
- });
14
-
15
- var _setup = require("../setup");
16
-
17
- var _keyboardAction = require("./keyboardAction");
18
-
19
- var _parseKeyDef = require("./parseKeyDef");
20
-
21
- async function keyboard(text) {
22
- const {
23
- keyboardMap
24
- } = this[_setup.Config];
25
- const actions = (0, _parseKeyDef.parseKeyDef)(keyboardMap, text);
26
- return (0, _keyboardAction.keyboardAction)(this[_setup.Config], actions);
27
- }
28
-
29
- function createKeyboardState() {
30
- return {
31
- activeElement: null,
32
- pressed: [],
33
- carryChar: '',
34
- modifiers: {
35
- alt: false,
36
- caps: false,
37
- ctrl: false,
38
- meta: false,
39
- shift: false
40
- }
41
- };
42
- }
@@ -1,119 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.defaultKeyMap = void 0;
7
-
8
- var _types = require("./types");
9
-
10
- /**
11
- * Mapping for a default US-104-QWERTY keyboard
12
- */
13
- const defaultKeyMap = [// alphanumeric keys
14
- ...'0123456789'.split('').map(c => ({
15
- code: `Digit${c}`,
16
- key: c
17
- })), ...')!@#$%^&*('.split('').map((c, i) => ({
18
- code: `Digit${i}`,
19
- key: c,
20
- shiftKey: true
21
- })), ...'abcdefghijklmnopqrstuvwxyz'.split('').map(c => ({
22
- code: `Key${c.toUpperCase()}`,
23
- key: c
24
- })), ...'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('').map(c => ({
25
- code: `Key${c}`,
26
- key: c,
27
- shiftKey: true
28
- })), // alphanumeric block - functional
29
- {
30
- code: 'Space',
31
- key: ' '
32
- }, {
33
- code: 'AltLeft',
34
- key: 'Alt',
35
- location: _types.DOM_KEY_LOCATION.LEFT
36
- }, {
37
- code: 'AltRight',
38
- key: 'Alt',
39
- location: _types.DOM_KEY_LOCATION.RIGHT
40
- }, {
41
- code: 'ShiftLeft',
42
- key: 'Shift',
43
- location: _types.DOM_KEY_LOCATION.LEFT
44
- }, {
45
- code: 'ShiftRight',
46
- key: 'Shift',
47
- location: _types.DOM_KEY_LOCATION.RIGHT
48
- }, {
49
- code: 'ControlLeft',
50
- key: 'Control',
51
- location: _types.DOM_KEY_LOCATION.LEFT
52
- }, {
53
- code: 'ControlRight',
54
- key: 'Control',
55
- location: _types.DOM_KEY_LOCATION.RIGHT
56
- }, {
57
- code: 'MetaLeft',
58
- key: 'Meta',
59
- location: _types.DOM_KEY_LOCATION.LEFT
60
- }, {
61
- code: 'MetaRight',
62
- key: 'Meta',
63
- location: _types.DOM_KEY_LOCATION.RIGHT
64
- }, {
65
- code: 'OSLeft',
66
- key: 'OS',
67
- location: _types.DOM_KEY_LOCATION.LEFT
68
- }, {
69
- code: 'OSRight',
70
- key: 'OS',
71
- location: _types.DOM_KEY_LOCATION.RIGHT
72
- }, {
73
- code: 'Tab',
74
- key: 'Tab'
75
- }, {
76
- code: 'CapsLock',
77
- key: 'CapsLock'
78
- }, {
79
- code: 'Backspace',
80
- key: 'Backspace'
81
- }, {
82
- code: 'Enter',
83
- key: 'Enter'
84
- }, // function
85
- {
86
- code: 'Escape',
87
- key: 'Escape'
88
- }, // arrows
89
- {
90
- code: 'ArrowUp',
91
- key: 'ArrowUp'
92
- }, {
93
- code: 'ArrowDown',
94
- key: 'ArrowDown'
95
- }, {
96
- code: 'ArrowLeft',
97
- key: 'ArrowLeft'
98
- }, {
99
- code: 'ArrowRight',
100
- key: 'ArrowRight'
101
- }, // control pad
102
- {
103
- code: 'Home',
104
- key: 'Home'
105
- }, {
106
- code: 'End',
107
- key: 'End'
108
- }, {
109
- code: 'Delete',
110
- key: 'Delete'
111
- }, {
112
- code: 'PageUp',
113
- key: 'PageUp'
114
- }, {
115
- code: 'PageDown',
116
- key: 'PageDown'
117
- } // TODO: add mappings
118
- ];
119
- exports.defaultKeyMap = defaultKeyMap;