@ariakit/test 0.4.7 → 0.4.8
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/CHANGELOG.md +4 -0
- package/cjs/query.d.cts +2 -2
- package/cjs/query.d.ts +2 -2
- package/esm/query.d.ts +2 -2
- package/package.json +1 -1
- package/cjs/__chunks/3L4XZQN6.cjs +0 -118
- package/cjs/__chunks/5USXAKSO.cjs +0 -32
- package/cjs/__chunks/72WSX5BL.cjs +0 -201
- package/cjs/__chunks/7LFSIKVW.cjs +0 -134
- package/cjs/__chunks/AA4DRZPS.cjs +0 -19
- package/cjs/__chunks/ANKVPRYL.cjs +0 -27
- package/cjs/__chunks/C6KLLVD3.cjs +0 -90
- package/cjs/__chunks/CAAOBH77.cjs +0 -89
- package/cjs/__chunks/E4OOGVMW.cjs +0 -24
- package/cjs/__chunks/IDMD7IDF.cjs +0 -1
- package/cjs/__chunks/IWR6DHL3.cjs +0 -13
- package/cjs/__chunks/ML4UXKC3.cjs +0 -56
- package/cjs/__chunks/OYUSBKO4.cjs +0 -235
- package/cjs/__chunks/Q3ZREZK3.cjs +0 -67
- package/cjs/__chunks/RHX5DDWS.cjs +0 -83
- package/cjs/__chunks/SMHVZDHR.cjs +0 -33
- package/cjs/__chunks/W5TVXVBK.cjs +0 -133
- package/cjs/__chunks/Y4FGMHAT.cjs +0 -12
- package/cjs/blur.cjs +0 -9
- package/cjs/click.cjs +0 -15
- package/cjs/dispatch.cjs +0 -8
- package/cjs/focus.cjs +0 -9
- package/cjs/hover.cjs +0 -10
- package/cjs/index.cjs +0 -64
- package/cjs/mouse-down.cjs +0 -11
- package/cjs/mouse-up.cjs +0 -9
- package/cjs/playwright.cjs +0 -19
- package/cjs/press.cjs +0 -13
- package/cjs/query.cjs +0 -10
- package/cjs/react.cjs +0 -103
- package/cjs/select.cjs +0 -15
- package/cjs/sleep.cjs +0 -8
- package/cjs/tap.cjs +0 -16
- package/cjs/type.cjs +0 -11
- package/cjs/wait-for.cjs +0 -8
- package/esm/__chunks/3TAKJKL3.js +0 -135
- package/esm/__chunks/4SG6SLGL.js +0 -34
- package/esm/__chunks/BQA4OBCC.js +0 -13
- package/esm/__chunks/CNNB7B4V.js +0 -236
- package/esm/__chunks/CWTUOQ5Z.js +0 -91
- package/esm/__chunks/DZ24E43J.js +0 -20
- package/esm/__chunks/G32GEXRJ.js +0 -134
- package/esm/__chunks/HFG3HB6M.js +0 -85
- package/esm/__chunks/LK25WCYN.js +0 -202
- package/esm/__chunks/NR24PD4G.js +0 -28
- package/esm/__chunks/PVRUCEXU.js +0 -68
- package/esm/__chunks/RHBNMDK4.js +0 -1
- package/esm/__chunks/SB7WYA2U.js +0 -14
- package/esm/__chunks/SM5ASDQ3.js +0 -25
- package/esm/__chunks/SOWA2DKF.js +0 -33
- package/esm/__chunks/UG25M3QN.js +0 -91
- package/esm/__chunks/YVVGFTRB.js +0 -119
- package/esm/__chunks/Z7WVAAXJ.js +0 -57
- package/esm/blur.js +0 -10
- package/esm/click.js +0 -16
- package/esm/dispatch.js +0 -9
- package/esm/focus.js +0 -10
- package/esm/hover.js +0 -11
- package/esm/index.js +0 -65
- package/esm/mouse-down.js +0 -12
- package/esm/mouse-up.js +0 -10
- package/esm/playwright.js +0 -20
- package/esm/press.js +0 -14
- package/esm/query.js +0 -11
- package/esm/react.js +0 -104
- package/esm/select.js +0 -16
- package/esm/sleep.js +0 -9
- package/esm/tap.js +0 -17
- package/esm/type.js +0 -12
- package/esm/wait-for.js +0 -9
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _ANKVPRYLcjs = require('./ANKVPRYL.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _ML4UXKC3cjs = require('./ML4UXKC3.cjs');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _Q3ZREZK3cjs = require('./Q3ZREZK3.cjs');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _72WSX5BLcjs = require('./72WSX5BL.cjs');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _AA4DRZPScjs = require('./AA4DRZPS.cjs');
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var _RHX5DDWScjs = require('./RHX5DDWS.cjs');
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var _E4OOGVMWcjs = require('./E4OOGVMW.cjs');
|
|
22
|
-
|
|
23
|
-
// src/select.ts
|
|
24
|
-
var _dom = require('@ariakit/core/utils/dom');
|
|
25
|
-
var _misc = require('@ariakit/core/utils/misc');
|
|
26
|
-
function select(text, element = document.body, options) {
|
|
27
|
-
return _RHX5DDWScjs.wrapAsync.call(void 0, async () => {
|
|
28
|
-
var _a, _b;
|
|
29
|
-
_misc.invariant.call(void 0, element, "Unable to select text on null element");
|
|
30
|
-
if (!_dom.isVisible.call(void 0, element)) return;
|
|
31
|
-
const document2 = element.ownerDocument;
|
|
32
|
-
await _Q3ZREZK3cjs.hover.call(void 0, element, options);
|
|
33
|
-
await _ML4UXKC3cjs.mouseDown.call(void 0, element, options);
|
|
34
|
-
await _72WSX5BLcjs.dispatch.call(void 0,
|
|
35
|
-
element,
|
|
36
|
-
new Event("selectstart", {
|
|
37
|
-
bubbles: true,
|
|
38
|
-
cancelable: true,
|
|
39
|
-
composed: false
|
|
40
|
-
})
|
|
41
|
-
);
|
|
42
|
-
const startIndex = (_b = (_a = element.textContent) == null ? void 0 : _a.indexOf(text)) != null ? _b : -1;
|
|
43
|
-
const selection = document2.getSelection();
|
|
44
|
-
const range = document2.createRange();
|
|
45
|
-
for (let i = 1; i <= text.length; i++) {
|
|
46
|
-
const iterator = document2.createNodeIterator(
|
|
47
|
-
element,
|
|
48
|
-
NodeFilter.SHOW_TEXT
|
|
49
|
-
);
|
|
50
|
-
const textSlice = text.slice(0, i);
|
|
51
|
-
const endIndex = startIndex + textSlice.length;
|
|
52
|
-
let index = startIndex;
|
|
53
|
-
let node = null;
|
|
54
|
-
let charCount = 0;
|
|
55
|
-
let startContainer = null;
|
|
56
|
-
let startOffset = -1;
|
|
57
|
-
let endContainer = null;
|
|
58
|
-
let endOffset = -1;
|
|
59
|
-
while (index >= 0 && index < endIndex && charCount < endIndex && (node = iterator.nextNode())) {
|
|
60
|
-
const textContent = node.textContent;
|
|
61
|
-
if (!textContent) continue;
|
|
62
|
-
charCount += textContent.length;
|
|
63
|
-
if (index > charCount) continue;
|
|
64
|
-
if (!startContainer) {
|
|
65
|
-
startContainer = node;
|
|
66
|
-
startOffset = index - charCount + textContent.length;
|
|
67
|
-
}
|
|
68
|
-
endContainer = node;
|
|
69
|
-
endOffset = endIndex - charCount + textContent.length;
|
|
70
|
-
index++;
|
|
71
|
-
}
|
|
72
|
-
if (!startContainer || !endContainer) continue;
|
|
73
|
-
await _Q3ZREZK3cjs.hover.call(void 0, element, options);
|
|
74
|
-
range.setStart(startContainer, startOffset);
|
|
75
|
-
range.setEnd(endContainer, endOffset);
|
|
76
|
-
selection == null ? void 0 : selection.removeAllRanges();
|
|
77
|
-
selection == null ? void 0 : selection.addRange(range);
|
|
78
|
-
}
|
|
79
|
-
await _AA4DRZPScjs.sleep.call(void 0, );
|
|
80
|
-
await _ANKVPRYLcjs.mouseUp.call(void 0, element, options);
|
|
81
|
-
await _72WSX5BLcjs.dispatch.click(element, _E4OOGVMWcjs.__spreadValues.call(void 0, { detail: 1 }, options));
|
|
82
|
-
selection == null ? void 0 : selection.removeAllRanges();
|
|
83
|
-
selection == null ? void 0 : selection.addRange(range);
|
|
84
|
-
await _AA4DRZPScjs.sleep.call(void 0, );
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
exports.select = select;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/__aria-role.ts
|
|
2
|
-
var roles = [
|
|
3
|
-
"alert",
|
|
4
|
-
"alertdialog",
|
|
5
|
-
"application",
|
|
6
|
-
"article",
|
|
7
|
-
"banner",
|
|
8
|
-
"blockquote",
|
|
9
|
-
"button",
|
|
10
|
-
"caption",
|
|
11
|
-
"cell",
|
|
12
|
-
"checkbox",
|
|
13
|
-
"code",
|
|
14
|
-
"columnheader",
|
|
15
|
-
"combobox",
|
|
16
|
-
"complementary",
|
|
17
|
-
"contentinfo",
|
|
18
|
-
"definition",
|
|
19
|
-
"deletion",
|
|
20
|
-
"dialog",
|
|
21
|
-
"directory",
|
|
22
|
-
"document",
|
|
23
|
-
"emphasis",
|
|
24
|
-
"feed",
|
|
25
|
-
"figure",
|
|
26
|
-
"form",
|
|
27
|
-
"generic",
|
|
28
|
-
"grid",
|
|
29
|
-
"gridcell",
|
|
30
|
-
"group",
|
|
31
|
-
"heading",
|
|
32
|
-
"img",
|
|
33
|
-
"insertion",
|
|
34
|
-
"link",
|
|
35
|
-
"list",
|
|
36
|
-
"listbox",
|
|
37
|
-
"listitem",
|
|
38
|
-
"log",
|
|
39
|
-
"main",
|
|
40
|
-
"marquee",
|
|
41
|
-
"math",
|
|
42
|
-
"menu",
|
|
43
|
-
"menubar",
|
|
44
|
-
"menuitem",
|
|
45
|
-
"menuitemcheckbox",
|
|
46
|
-
"menuitemradio",
|
|
47
|
-
"meter",
|
|
48
|
-
"navigation",
|
|
49
|
-
"none",
|
|
50
|
-
"note",
|
|
51
|
-
"option",
|
|
52
|
-
"paragraph",
|
|
53
|
-
"presentation",
|
|
54
|
-
"progressbar",
|
|
55
|
-
"radio",
|
|
56
|
-
"radiogroup",
|
|
57
|
-
"region",
|
|
58
|
-
"row",
|
|
59
|
-
"rowgroup",
|
|
60
|
-
"rowheader",
|
|
61
|
-
"scrollbar",
|
|
62
|
-
"search",
|
|
63
|
-
"searchbox",
|
|
64
|
-
"separator",
|
|
65
|
-
"slider",
|
|
66
|
-
"spinbutton",
|
|
67
|
-
"status",
|
|
68
|
-
"strong",
|
|
69
|
-
"subscript",
|
|
70
|
-
"superscript",
|
|
71
|
-
"switch",
|
|
72
|
-
"tab",
|
|
73
|
-
"table",
|
|
74
|
-
"tablist",
|
|
75
|
-
"tabpanel",
|
|
76
|
-
"term",
|
|
77
|
-
"textbox",
|
|
78
|
-
"time",
|
|
79
|
-
"timer",
|
|
80
|
-
"toolbar",
|
|
81
|
-
"tooltip",
|
|
82
|
-
"tree",
|
|
83
|
-
"treegrid",
|
|
84
|
-
"treeitem"
|
|
85
|
-
];
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
exports.roles = roles;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
exports.__spreadValues = __spreadValues; exports.__spreadProps = __spreadProps;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }
|
|
2
|
-
|
|
3
|
-
var _RHX5DDWScjs = require('./RHX5DDWS.cjs');
|
|
4
|
-
|
|
5
|
-
// src/wait-for.ts
|
|
6
|
-
var _dom = require('@testing-library/dom'); var DOMTestingLibrary = _interopRequireWildcard(_dom);
|
|
7
|
-
function waitFor2(callback, options) {
|
|
8
|
-
return _RHX5DDWScjs.wrapAsync.call(void 0, () => DOMTestingLibrary.waitFor(callback, options));
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
exports.waitFor = waitFor2;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _5USXAKSOcjs = require('./5USXAKSO.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _SMHVZDHRcjs = require('./SMHVZDHR.cjs');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _72WSX5BLcjs = require('./72WSX5BL.cjs');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _RHX5DDWScjs = require('./RHX5DDWS.cjs');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _E4OOGVMWcjs = require('./E4OOGVMW.cjs');
|
|
16
|
-
|
|
17
|
-
// src/mouse-down.ts
|
|
18
|
-
var _dom = require('@ariakit/core/utils/dom');
|
|
19
|
-
var _focus = require('@ariakit/core/utils/focus');
|
|
20
|
-
var _misc = require('@ariakit/core/utils/misc');
|
|
21
|
-
function mouseDown(element, options) {
|
|
22
|
-
return _RHX5DDWScjs.wrapAsync.call(void 0, async () => {
|
|
23
|
-
_misc.invariant.call(void 0, element, "Unable to mouseDown on null element");
|
|
24
|
-
if (!_dom.isVisible.call(void 0, element)) return;
|
|
25
|
-
const { disabled } = element;
|
|
26
|
-
let defaultAllowed = await _72WSX5BLcjs.dispatch.pointerDown(element, options);
|
|
27
|
-
if (!disabled) {
|
|
28
|
-
if (!await _72WSX5BLcjs.dispatch.mouseDown(element, _E4OOGVMWcjs.__spreadValues.call(void 0, { detail: 1 }, options))) {
|
|
29
|
-
defaultAllowed = false;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (defaultAllowed) {
|
|
33
|
-
const selection = _dom.getDocument.call(void 0, element).getSelection();
|
|
34
|
-
if (selection == null ? void 0 : selection.rangeCount) {
|
|
35
|
-
const range = selection.getRangeAt(0);
|
|
36
|
-
if (!range.collapsed) {
|
|
37
|
-
selection.removeAllRanges();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (_focus.isFocusable.call(void 0, element) && getComputedStyle(element).pointerEvents !== "none") {
|
|
41
|
-
await _SMHVZDHRcjs.focus.call(void 0, element);
|
|
42
|
-
} else if (element.parentElement) {
|
|
43
|
-
const closestFocusable = _focus.getClosestFocusable.call(void 0, element.parentElement);
|
|
44
|
-
if (closestFocusable) {
|
|
45
|
-
await _SMHVZDHRcjs.focus.call(void 0, closestFocusable);
|
|
46
|
-
} else {
|
|
47
|
-
await _5USXAKSOcjs.blur.call(void 0, );
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
exports.mouseDown = mouseDown;
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _3L4XZQN6cjs = require('./3L4XZQN6.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _5USXAKSOcjs = require('./5USXAKSO.cjs');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _SMHVZDHRcjs = require('./SMHVZDHR.cjs');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _72WSX5BLcjs = require('./72WSX5BL.cjs');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _AA4DRZPScjs = require('./AA4DRZPS.cjs');
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var _RHX5DDWScjs = require('./RHX5DDWS.cjs');
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var _E4OOGVMWcjs = require('./E4OOGVMW.cjs');
|
|
22
|
-
|
|
23
|
-
// src/press.ts
|
|
24
|
-
var _dom = require('@ariakit/core/utils/dom');
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var _focus = require('@ariakit/core/utils/focus');
|
|
30
|
-
var clickableInputTypes = [
|
|
31
|
-
"button",
|
|
32
|
-
"color",
|
|
33
|
-
"file",
|
|
34
|
-
"image",
|
|
35
|
-
"reset",
|
|
36
|
-
"submit"
|
|
37
|
-
];
|
|
38
|
-
async function submitFormByPressingEnterOn(element, options) {
|
|
39
|
-
const { form } = element;
|
|
40
|
-
if (!form) return;
|
|
41
|
-
const elements = Array.from(form.elements);
|
|
42
|
-
const validInputs = elements.filter(
|
|
43
|
-
(el) => el instanceof HTMLInputElement && _dom.isTextField.call(void 0, el)
|
|
44
|
-
);
|
|
45
|
-
const submitButton = elements.find(
|
|
46
|
-
(el) => (el instanceof HTMLInputElement || el instanceof HTMLButtonElement) && el.type === "submit"
|
|
47
|
-
);
|
|
48
|
-
if (validInputs.length === 1 || submitButton) {
|
|
49
|
-
await _72WSX5BLcjs.dispatch.submit(form, options);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function isNumberInput(element) {
|
|
53
|
-
return element instanceof HTMLInputElement && element.type === "number";
|
|
54
|
-
}
|
|
55
|
-
async function incrementNumberInput(element, by = 1) {
|
|
56
|
-
const value = +element.value + by;
|
|
57
|
-
const max = element.max ? +element.max : Number.MAX_SAFE_INTEGER;
|
|
58
|
-
const min = element.min ? +element.min : Number.MIN_SAFE_INTEGER;
|
|
59
|
-
if (value > max || value < min) return;
|
|
60
|
-
element.value = value.toString();
|
|
61
|
-
await _72WSX5BLcjs.dispatch.input(element);
|
|
62
|
-
await _72WSX5BLcjs.dispatch.change(element);
|
|
63
|
-
}
|
|
64
|
-
var keyDownMap = {
|
|
65
|
-
async Tab(_, { shiftKey }) {
|
|
66
|
-
const nextElement = shiftKey ? _focus.getPreviousTabbable.call(void 0, ) : _focus.getNextTabbable.call(void 0, );
|
|
67
|
-
if (nextElement) {
|
|
68
|
-
await _SMHVZDHRcjs.focus.call(void 0, nextElement);
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
async Enter(element, options) {
|
|
72
|
-
const nonSubmittableTypes = [...clickableInputTypes, "hidden"];
|
|
73
|
-
const isClickable = element.tagName === "BUTTON" || element instanceof HTMLInputElement && clickableInputTypes.includes(element.type);
|
|
74
|
-
const isSubmittable = element instanceof HTMLInputElement && !nonSubmittableTypes.includes(element.type);
|
|
75
|
-
if (isClickable) {
|
|
76
|
-
await _72WSX5BLcjs.dispatch.click(element, options);
|
|
77
|
-
} else if (isSubmittable) {
|
|
78
|
-
await submitFormByPressingEnterOn(element, options);
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
async Home(element, { shiftKey }) {
|
|
82
|
-
if (_dom.isTextField.call(void 0, element)) {
|
|
83
|
-
const { value, selectionEnd } = element;
|
|
84
|
-
const end = Math.min(value.length, shiftKey ? selectionEnd != null ? selectionEnd : 0 : 0);
|
|
85
|
-
_dom.setSelectionRange.call(void 0, element, 0, end, "backward");
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
async End(element, { shiftKey }) {
|
|
89
|
-
if (_dom.isTextField.call(void 0, element)) {
|
|
90
|
-
const { value, selectionStart } = element;
|
|
91
|
-
const start = shiftKey ? selectionStart != null ? selectionStart : 0 : value.length;
|
|
92
|
-
_dom.setSelectionRange.call(void 0, element, start, value.length, "forward");
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
async ArrowLeft(element, { shiftKey }) {
|
|
96
|
-
if (_dom.isTextField.call(void 0, element)) {
|
|
97
|
-
const { value, selectionStart, selectionEnd, selectionDirection } = element;
|
|
98
|
-
const [start, end] = [selectionStart != null ? selectionStart : 0, selectionEnd != null ? selectionEnd : 0];
|
|
99
|
-
const collapsing = !shiftKey && start !== end;
|
|
100
|
-
const nextStart = Math.max(0, collapsing ? start : start - 1);
|
|
101
|
-
const nextEnd = Math.min(value.length, shiftKey ? end : nextStart);
|
|
102
|
-
_dom.setSelectionRange.call(void 0,
|
|
103
|
-
element,
|
|
104
|
-
nextStart,
|
|
105
|
-
nextEnd,
|
|
106
|
-
selectionDirection || "backward"
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
async ArrowRight(element, { shiftKey }) {
|
|
111
|
-
if (_dom.isTextField.call(void 0, element)) {
|
|
112
|
-
const { value, selectionStart, selectionEnd, selectionDirection } = element;
|
|
113
|
-
const [start, end] = [selectionStart != null ? selectionStart : 0, selectionEnd != null ? selectionEnd : 0];
|
|
114
|
-
const collapsing = !shiftKey && start !== end;
|
|
115
|
-
const nextEnd = Math.min(value.length, collapsing ? end : end + 1);
|
|
116
|
-
const nextStart = Math.max(0, shiftKey ? start : nextEnd);
|
|
117
|
-
_dom.setSelectionRange.call(void 0,
|
|
118
|
-
element,
|
|
119
|
-
nextStart,
|
|
120
|
-
nextEnd,
|
|
121
|
-
selectionDirection || "forward"
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
async ArrowUp(element, { shiftKey }) {
|
|
126
|
-
if (_dom.isTextField.call(void 0, element)) {
|
|
127
|
-
if (!shiftKey) {
|
|
128
|
-
return _dom.setSelectionRange.call(void 0, element, 0, 0);
|
|
129
|
-
}
|
|
130
|
-
const { selectionStart, selectionEnd, selectionDirection } = element;
|
|
131
|
-
const [start, end] = [selectionStart != null ? selectionStart : 0, selectionEnd != null ? selectionEnd : 0];
|
|
132
|
-
if (selectionDirection === "forward") {
|
|
133
|
-
_dom.setSelectionRange.call(void 0, element, start, start);
|
|
134
|
-
} else {
|
|
135
|
-
_dom.setSelectionRange.call(void 0, element, 0, end, "backward");
|
|
136
|
-
}
|
|
137
|
-
} else if (isNumberInput(element)) {
|
|
138
|
-
await incrementNumberInput(element);
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
async ArrowDown(element, { shiftKey }) {
|
|
142
|
-
if (_dom.isTextField.call(void 0, element)) {
|
|
143
|
-
const length = element.value.length;
|
|
144
|
-
if (!shiftKey) {
|
|
145
|
-
_dom.setSelectionRange.call(void 0, element, length, length);
|
|
146
|
-
} else {
|
|
147
|
-
const { selectionStart, selectionEnd, selectionDirection } = element;
|
|
148
|
-
const [start, end] = [selectionStart != null ? selectionStart : 0, selectionEnd != null ? selectionEnd : 0];
|
|
149
|
-
if (selectionDirection === "backward") {
|
|
150
|
-
_dom.setSelectionRange.call(void 0, element, end, end);
|
|
151
|
-
} else {
|
|
152
|
-
_dom.setSelectionRange.call(void 0, element, start, length, "forward");
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
} else if (isNumberInput(element)) {
|
|
156
|
-
await incrementNumberInput(element, -1);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
var keyUpMap = {
|
|
161
|
-
// Space
|
|
162
|
-
" ": async (element, options) => {
|
|
163
|
-
const spaceableTypes = [...clickableInputTypes, "checkbox", "radio"];
|
|
164
|
-
const isSpaceable = element.tagName === "BUTTON" || element instanceof HTMLInputElement && spaceableTypes.includes(element.type);
|
|
165
|
-
if (isSpaceable) {
|
|
166
|
-
await _72WSX5BLcjs.dispatch.click(element, options);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
function press(key, element, options = {}) {
|
|
171
|
-
return _RHX5DDWScjs.wrapAsync.call(void 0, async () => {
|
|
172
|
-
var _a, _b, _c, _d;
|
|
173
|
-
if (element == null) {
|
|
174
|
-
element = document.activeElement || document.body;
|
|
175
|
-
}
|
|
176
|
-
if (!element) return;
|
|
177
|
-
if (!_focus.isFocusable.call(void 0, element) && element.tagName !== "BODY") return;
|
|
178
|
-
if (_dom.isTextField.call(void 0, element)) {
|
|
179
|
-
if (key.length === 1) {
|
|
180
|
-
return _3L4XZQN6cjs.type.call(void 0, key, element, options);
|
|
181
|
-
} else if (key === "Delete") {
|
|
182
|
-
return _3L4XZQN6cjs.type.call(void 0, "\x7F", element, options);
|
|
183
|
-
} else if (key === "Backspace") {
|
|
184
|
-
return _3L4XZQN6cjs.type.call(void 0, "\b", element, options);
|
|
185
|
-
} else if (key === "Enter" && element.tagName === "TEXTAREA") {
|
|
186
|
-
return _3L4XZQN6cjs.type.call(void 0, "\n", element, options);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
if (((_a = element.ownerDocument) == null ? void 0 : _a.activeElement) !== element) {
|
|
190
|
-
if (element.tagName === "BODY") {
|
|
191
|
-
await _5USXAKSOcjs.blur.call(void 0, );
|
|
192
|
-
} else {
|
|
193
|
-
await _SMHVZDHRcjs.focus.call(void 0, element);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
await _AA4DRZPScjs.sleep.call(void 0, );
|
|
197
|
-
let defaultAllowed = await _72WSX5BLcjs.dispatch.keyDown(element, _E4OOGVMWcjs.__spreadValues.call(void 0, { key }, options));
|
|
198
|
-
if (defaultAllowed && key in keyDownMap && !options.metaKey) {
|
|
199
|
-
await ((_b = keyDownMap[key]) == null ? void 0 : _b.call(keyDownMap, element, options));
|
|
200
|
-
}
|
|
201
|
-
await _AA4DRZPScjs.sleep.call(void 0, );
|
|
202
|
-
if (((_c = element.ownerDocument) == null ? void 0 : _c.activeElement) !== element) {
|
|
203
|
-
element = element.ownerDocument.activeElement;
|
|
204
|
-
}
|
|
205
|
-
if (!await _72WSX5BLcjs.dispatch.keyUp(element, _E4OOGVMWcjs.__spreadValues.call(void 0, { key }, options))) {
|
|
206
|
-
defaultAllowed = false;
|
|
207
|
-
}
|
|
208
|
-
if (defaultAllowed && key in keyUpMap && !options.metaKey) {
|
|
209
|
-
await ((_d = keyUpMap[key]) == null ? void 0 : _d.call(keyUpMap, element, options));
|
|
210
|
-
}
|
|
211
|
-
await _AA4DRZPScjs.sleep.call(void 0, );
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
function createPress(key, defaultOptions = {}) {
|
|
215
|
-
return (element, options = {}) => press(key, element, _E4OOGVMWcjs.__spreadValues.call(void 0, _E4OOGVMWcjs.__spreadValues.call(void 0, {}, defaultOptions), options));
|
|
216
|
-
}
|
|
217
|
-
press.Escape = createPress("Escape");
|
|
218
|
-
press.Backspace = createPress("Backspace");
|
|
219
|
-
press.Delete = createPress("Delete");
|
|
220
|
-
press.Tab = createPress("Tab");
|
|
221
|
-
press.ShiftTab = createPress("Tab", { shiftKey: true });
|
|
222
|
-
press.Enter = createPress("Enter");
|
|
223
|
-
press.Space = createPress(" ");
|
|
224
|
-
press.ArrowUp = createPress("ArrowUp");
|
|
225
|
-
press.ArrowRight = createPress("ArrowRight");
|
|
226
|
-
press.ArrowDown = createPress("ArrowDown");
|
|
227
|
-
press.ArrowLeft = createPress("ArrowLeft");
|
|
228
|
-
press.End = createPress("End");
|
|
229
|
-
press.Home = createPress("Home");
|
|
230
|
-
press.PageUp = createPress("PageUp");
|
|
231
|
-
press.PageDown = createPress("PageDown");
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
exports.press = press;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _72WSX5BLcjs = require('./72WSX5BL.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _AA4DRZPScjs = require('./AA4DRZPS.cjs');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _RHX5DDWScjs = require('./RHX5DDWS.cjs');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var _E4OOGVMWcjs = require('./E4OOGVMW.cjs');
|
|
14
|
-
|
|
15
|
-
// src/hover.ts
|
|
16
|
-
var _dom = require('@ariakit/core/utils/dom');
|
|
17
|
-
var _misc = require('@ariakit/core/utils/misc');
|
|
18
|
-
function isPointerEventsEnabled(element) {
|
|
19
|
-
return getComputedStyle(element).pointerEvents !== "none";
|
|
20
|
-
}
|
|
21
|
-
function hover(element, options) {
|
|
22
|
-
return _RHX5DDWScjs.wrapAsync.call(void 0, async () => {
|
|
23
|
-
_misc.invariant.call(void 0, element, "Unable to hover on null element");
|
|
24
|
-
if (!_dom.isVisible.call(void 0, element)) return;
|
|
25
|
-
const document = element.ownerDocument;
|
|
26
|
-
const { lastHovered } = document;
|
|
27
|
-
const { disabled } = element;
|
|
28
|
-
const pointerEventsEnabled = isPointerEventsEnabled(element);
|
|
29
|
-
if (lastHovered && lastHovered !== element && _dom.isVisible.call(void 0, lastHovered)) {
|
|
30
|
-
await _72WSX5BLcjs.dispatch.pointerMove(lastHovered, options);
|
|
31
|
-
await _72WSX5BLcjs.dispatch.mouseMove(lastHovered, options);
|
|
32
|
-
if (isPointerEventsEnabled(lastHovered)) {
|
|
33
|
-
const isElementWithinLastHovered = lastHovered.contains(element);
|
|
34
|
-
const relatedTarget = pointerEventsEnabled ? element : null;
|
|
35
|
-
const leaveOptions = _E4OOGVMWcjs.__spreadProps.call(void 0, _E4OOGVMWcjs.__spreadValues.call(void 0, {}, options), { relatedTarget });
|
|
36
|
-
await _72WSX5BLcjs.dispatch.pointerOut(lastHovered, leaveOptions);
|
|
37
|
-
if (!isElementWithinLastHovered) {
|
|
38
|
-
await _72WSX5BLcjs.dispatch.pointerLeave(lastHovered, leaveOptions);
|
|
39
|
-
}
|
|
40
|
-
await _72WSX5BLcjs.dispatch.mouseOut(lastHovered, leaveOptions);
|
|
41
|
-
if (!isElementWithinLastHovered) {
|
|
42
|
-
await _72WSX5BLcjs.dispatch.mouseLeave(lastHovered, leaveOptions);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
await _AA4DRZPScjs.sleep.call(void 0, );
|
|
47
|
-
if (pointerEventsEnabled) {
|
|
48
|
-
const enterOptions = lastHovered ? _E4OOGVMWcjs.__spreadValues.call(void 0, { relatedTarget: lastHovered }, options) : options;
|
|
49
|
-
await _72WSX5BLcjs.dispatch.pointerOver(element, enterOptions);
|
|
50
|
-
await _72WSX5BLcjs.dispatch.pointerEnter(element, enterOptions);
|
|
51
|
-
if (!disabled) {
|
|
52
|
-
await _72WSX5BLcjs.dispatch.mouseOver(element, enterOptions);
|
|
53
|
-
await _72WSX5BLcjs.dispatch.mouseEnter(element, enterOptions);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
await _72WSX5BLcjs.dispatch.pointerMove(element, options);
|
|
57
|
-
if (!disabled) {
|
|
58
|
-
await _72WSX5BLcjs.dispatch.mouseMove(element, options);
|
|
59
|
-
}
|
|
60
|
-
document.lastHovered = element;
|
|
61
|
-
await _AA4DRZPScjs.sleep.call(void 0, );
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
exports.hover = hover;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/__utils.ts
|
|
2
|
-
var _focus = require('@ariakit/core/utils/focus');
|
|
3
|
-
var _misc = require('@ariakit/core/utils/misc');
|
|
4
|
-
var isBrowser = typeof navigator !== "undefined" && !navigator.userAgent.includes("jsdom") && typeof window !== "undefined" && !("happyDOM" in window);
|
|
5
|
-
async function flushMicrotasks() {
|
|
6
|
-
await Promise.resolve();
|
|
7
|
-
await Promise.resolve();
|
|
8
|
-
await Promise.resolve();
|
|
9
|
-
}
|
|
10
|
-
function nextFrame() {
|
|
11
|
-
return new Promise(requestAnimationFrame);
|
|
12
|
-
}
|
|
13
|
-
function setActEnvironment(value) {
|
|
14
|
-
const scope = globalThis;
|
|
15
|
-
const previousValue = scope.IS_REACT_ACT_ENVIRONMENT;
|
|
16
|
-
scope.IS_REACT_ACT_ENVIRONMENT = value;
|
|
17
|
-
const restoreActEnvironment = () => {
|
|
18
|
-
scope.IS_REACT_ACT_ENVIRONMENT = previousValue;
|
|
19
|
-
};
|
|
20
|
-
return restoreActEnvironment;
|
|
21
|
-
}
|
|
22
|
-
function applyBrowserPolyfills() {
|
|
23
|
-
if (isBrowser) return _misc.noop;
|
|
24
|
-
const originalFocus = HTMLElement.prototype.focus;
|
|
25
|
-
HTMLElement.prototype.focus = function focus(options) {
|
|
26
|
-
if (!_focus.isFocusable.call(void 0, this)) return;
|
|
27
|
-
return originalFocus.call(this, options);
|
|
28
|
-
};
|
|
29
|
-
const originalGetClientRects = Element.prototype.getClientRects;
|
|
30
|
-
Element.prototype.getClientRects = function getClientRects() {
|
|
31
|
-
const isHidden = (element) => {
|
|
32
|
-
if (!element.isConnected) return true;
|
|
33
|
-
if (element.parentElement && isHidden(element.parentElement)) return true;
|
|
34
|
-
if (!(element instanceof HTMLElement)) return false;
|
|
35
|
-
if (element.hidden) return true;
|
|
36
|
-
const style = getComputedStyle(element);
|
|
37
|
-
return style.display === "none" || style.visibility === "hidden";
|
|
38
|
-
};
|
|
39
|
-
if (isHidden(this)) return [];
|
|
40
|
-
return [{ width: 1, height: 1 }];
|
|
41
|
-
};
|
|
42
|
-
if (!Element.prototype.scrollIntoView) {
|
|
43
|
-
Element.prototype.scrollIntoView = _misc.noop;
|
|
44
|
-
}
|
|
45
|
-
if (!Element.prototype.hasPointerCapture) {
|
|
46
|
-
Element.prototype.hasPointerCapture = _misc.noop;
|
|
47
|
-
}
|
|
48
|
-
if (!Element.prototype.setPointerCapture) {
|
|
49
|
-
Element.prototype.setPointerCapture = _misc.noop;
|
|
50
|
-
}
|
|
51
|
-
if (!Element.prototype.releasePointerCapture) {
|
|
52
|
-
Element.prototype.releasePointerCapture = _misc.noop;
|
|
53
|
-
}
|
|
54
|
-
if (typeof window.ClipboardEvent === "undefined") {
|
|
55
|
-
window.ClipboardEvent = class ClipboardEvent extends Event {
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
if (typeof window.PointerEvent === "undefined") {
|
|
59
|
-
window.PointerEvent = class PointerEvent extends MouseEvent {
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
return () => {
|
|
63
|
-
HTMLElement.prototype.focus = originalFocus;
|
|
64
|
-
Element.prototype.getClientRects = originalGetClientRects;
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
async function wrapAsync(fn) {
|
|
68
|
-
const restoreActEnvironment = setActEnvironment(false);
|
|
69
|
-
const removeBrowserPolyfills = applyBrowserPolyfills();
|
|
70
|
-
try {
|
|
71
|
-
return await fn();
|
|
72
|
-
} finally {
|
|
73
|
-
restoreActEnvironment();
|
|
74
|
-
removeBrowserPolyfills();
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
exports.isBrowser = isBrowser; exports.flushMicrotasks = flushMicrotasks; exports.nextFrame = nextFrame; exports.wrapAsync = wrapAsync;
|