@ariakit/test 0.4.8 → 0.4.9
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/__chunks/4P2TRHCD.cjs +67 -0
- package/cjs/__chunks/5USXAKSO.cjs +32 -0
- package/cjs/__chunks/72WSX5BL.cjs +201 -0
- package/cjs/__chunks/AA4DRZPS.cjs +19 -0
- package/cjs/__chunks/ANKVPRYL.cjs +27 -0
- package/cjs/__chunks/AYPQCP2P.cjs +90 -0
- package/cjs/__chunks/CAAOBH77.cjs +89 -0
- package/cjs/__chunks/E4OOGVMW.cjs +24 -0
- package/cjs/__chunks/EA2M4PHP.cjs +235 -0
- package/cjs/__chunks/EG24EIKR.cjs +134 -0
- package/cjs/__chunks/IDMD7IDF.cjs +1 -0
- package/cjs/__chunks/IWR6DHL3.cjs +13 -0
- package/cjs/__chunks/KKOPNQIH.cjs +133 -0
- package/cjs/__chunks/ML4UXKC3.cjs +56 -0
- package/cjs/__chunks/RHX5DDWS.cjs +83 -0
- package/cjs/__chunks/SMHVZDHR.cjs +33 -0
- package/cjs/__chunks/UYJAT53J.cjs +118 -0
- package/cjs/__chunks/XODU6QCY.cjs +12 -0
- package/cjs/blur.cjs +9 -0
- package/cjs/click.cjs +15 -0
- package/cjs/dispatch.cjs +8 -0
- package/cjs/focus.cjs +9 -0
- package/cjs/hover.cjs +10 -0
- package/cjs/index.cjs +64 -0
- package/cjs/mouse-down.cjs +11 -0
- package/cjs/mouse-up.cjs +9 -0
- package/cjs/playwright.cjs +19 -0
- package/cjs/press.cjs +13 -0
- package/cjs/query.cjs +10 -0
- package/cjs/react.cjs +103 -0
- package/cjs/select.cjs +15 -0
- package/cjs/sleep.cjs +8 -0
- package/cjs/tap.cjs +16 -0
- package/cjs/type.cjs +11 -0
- package/cjs/wait-for.cjs +8 -0
- package/esm/__chunks/433S5VGJ.js +91 -0
- package/esm/__chunks/4SG6SLGL.js +34 -0
- package/esm/__chunks/4VR4URFV.js +119 -0
- package/esm/__chunks/BG5U5JFH.js +68 -0
- package/esm/__chunks/CSF4U66P.js +13 -0
- package/esm/__chunks/CWTUOQ5Z.js +91 -0
- package/esm/__chunks/DFUW3DFA.js +134 -0
- package/esm/__chunks/DZ24E43J.js +20 -0
- package/esm/__chunks/HFG3HB6M.js +85 -0
- package/esm/__chunks/LK25WCYN.js +202 -0
- package/esm/__chunks/NR24PD4G.js +28 -0
- package/esm/__chunks/OLDQVNUU.js +236 -0
- package/esm/__chunks/RHBNMDK4.js +1 -0
- package/esm/__chunks/RTBDUQHD.js +135 -0
- package/esm/__chunks/SB7WYA2U.js +14 -0
- package/esm/__chunks/SM5ASDQ3.js +25 -0
- package/esm/__chunks/SOWA2DKF.js +33 -0
- package/esm/__chunks/Z7WVAAXJ.js +57 -0
- package/esm/blur.js +10 -0
- package/esm/click.js +16 -0
- package/esm/dispatch.js +9 -0
- package/esm/focus.js +10 -0
- package/esm/hover.js +11 -0
- package/esm/index.js +65 -0
- package/esm/mouse-down.js +12 -0
- package/esm/mouse-up.js +10 -0
- package/esm/playwright.js +20 -0
- package/esm/press.js +14 -0
- package/esm/query.js +11 -0
- package/esm/react.js +104 -0
- package/esm/select.js +16 -0
- package/esm/sleep.js +9 -0
- package/esm/tap.js +17 -0
- package/esm/type.js +12 -0
- package/esm/wait-for.js +9 -0
- package/package.json +64 -64
- package/readme.md +3 -2
- /package/cjs/__tests__/{blur-test.d.cts → blur-test.react.d.cts} +0 -0
- /package/cjs/__tests__/{blur-test.d.ts → blur-test.react.d.ts} +0 -0
- /package/esm/__tests__/{blur-test.d.ts → blur-test.react.d.ts} +0 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
sleep
|
|
4
|
+
} from "./DZ24E43J.js";
|
|
5
|
+
import {
|
|
6
|
+
focus
|
|
7
|
+
} from "./4SG6SLGL.js";
|
|
8
|
+
import {
|
|
9
|
+
dispatch
|
|
10
|
+
} from "./LK25WCYN.js";
|
|
11
|
+
import {
|
|
12
|
+
wrapAsync
|
|
13
|
+
} from "./HFG3HB6M.js";
|
|
14
|
+
import {
|
|
15
|
+
__spreadValues
|
|
16
|
+
} from "./SM5ASDQ3.js";
|
|
17
|
+
|
|
18
|
+
// src/type.ts
|
|
19
|
+
import { getActiveElement, isTextField } from "@ariakit/core/utils/dom";
|
|
20
|
+
import { isFocusable } from "@ariakit/core/utils/focus";
|
|
21
|
+
function getKeyFromChar(key) {
|
|
22
|
+
if (key === "\x7F") return "Delete";
|
|
23
|
+
if (key === "\b") return "Backspace";
|
|
24
|
+
if (key === "\n") return "Enter";
|
|
25
|
+
if (key === " ") return "Tab";
|
|
26
|
+
return key;
|
|
27
|
+
}
|
|
28
|
+
function workAroundEmailInput(element) {
|
|
29
|
+
const input = element;
|
|
30
|
+
if (input.tagName !== "INPUT" || input.type !== "email") return () => {
|
|
31
|
+
};
|
|
32
|
+
input.type = "text";
|
|
33
|
+
return () => {
|
|
34
|
+
input.type = "email";
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function type(text, element, options = {}) {
|
|
38
|
+
return wrapAsync(async () => {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
if (element == null) {
|
|
41
|
+
element = document.activeElement;
|
|
42
|
+
}
|
|
43
|
+
if (!element) return;
|
|
44
|
+
if (!isFocusable(element)) return;
|
|
45
|
+
await focus(element);
|
|
46
|
+
element.dirty = true;
|
|
47
|
+
const restoreEmailInput = workAroundEmailInput(element);
|
|
48
|
+
for (const char of text) {
|
|
49
|
+
const key = getKeyFromChar(char);
|
|
50
|
+
let value = "";
|
|
51
|
+
let inputType = options.isComposing ? "insertCompositionText" : "insertText";
|
|
52
|
+
let defaultAllowed = await dispatch.keyDown(element, __spreadValues({ key }, options));
|
|
53
|
+
element = getActiveElement(element) || element;
|
|
54
|
+
if (isTextField(element)) {
|
|
55
|
+
const input = element;
|
|
56
|
+
const [start, end] = [
|
|
57
|
+
(_a = input.selectionStart) != null ? _a : 0,
|
|
58
|
+
(_b = input.selectionEnd) != null ? _b : 0
|
|
59
|
+
];
|
|
60
|
+
const collapsed = start === end;
|
|
61
|
+
let nextCaretPosition = start;
|
|
62
|
+
if (char === "\x7F") {
|
|
63
|
+
const firstPart = input.value.slice(0, start);
|
|
64
|
+
const secondPart = input.value.slice(collapsed ? end + 1 : end);
|
|
65
|
+
value = `${firstPart}${secondPart}`;
|
|
66
|
+
inputType = "deleteContentForward";
|
|
67
|
+
} else if (char === "\b") {
|
|
68
|
+
nextCaretPosition = collapsed ? Math.max(start - 1, 0) : start;
|
|
69
|
+
const firstPart = input.value.slice(0, nextCaretPosition);
|
|
70
|
+
const lastPart = input.value.slice(end, input.value.length);
|
|
71
|
+
value = `${firstPart}${lastPart}`;
|
|
72
|
+
inputType = "deleteContentBackward";
|
|
73
|
+
} else {
|
|
74
|
+
const firstPartEnd = options.isComposing ? start - 1 : start;
|
|
75
|
+
const firstPart = input.value.slice(0, firstPartEnd);
|
|
76
|
+
const lastPart = input.value.slice(end, input.value.length);
|
|
77
|
+
nextCaretPosition = start + 1;
|
|
78
|
+
value = `${firstPart}${char}${lastPart}`;
|
|
79
|
+
}
|
|
80
|
+
if (defaultAllowed && !input.readOnly) {
|
|
81
|
+
if (inputType === "insertText") {
|
|
82
|
+
defaultAllowed = await dispatch.keyPress(input, __spreadValues({
|
|
83
|
+
key,
|
|
84
|
+
charCode: key.charCodeAt(0)
|
|
85
|
+
}, options));
|
|
86
|
+
}
|
|
87
|
+
if (inputType === "insertCompositionText") {
|
|
88
|
+
defaultAllowed = await dispatch.compositionUpdate(input, __spreadValues({
|
|
89
|
+
data: char,
|
|
90
|
+
target: { value }
|
|
91
|
+
}, options));
|
|
92
|
+
}
|
|
93
|
+
if (defaultAllowed) {
|
|
94
|
+
await dispatch.input(input, __spreadValues({
|
|
95
|
+
data: char,
|
|
96
|
+
target: {
|
|
97
|
+
value,
|
|
98
|
+
selectionStart: nextCaretPosition,
|
|
99
|
+
selectionEnd: nextCaretPosition
|
|
100
|
+
},
|
|
101
|
+
inputType
|
|
102
|
+
}, options));
|
|
103
|
+
if (input.selectionStart !== nextCaretPosition) {
|
|
104
|
+
input.setSelectionRange(nextCaretPosition, nextCaretPosition);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
await sleep();
|
|
110
|
+
await dispatch.keyUp(element, __spreadValues({ key }, options));
|
|
111
|
+
await sleep();
|
|
112
|
+
}
|
|
113
|
+
restoreEmailInput();
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export {
|
|
118
|
+
type
|
|
119
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
sleep
|
|
4
|
+
} from "./DZ24E43J.js";
|
|
5
|
+
import {
|
|
6
|
+
dispatch
|
|
7
|
+
} from "./LK25WCYN.js";
|
|
8
|
+
import {
|
|
9
|
+
wrapAsync
|
|
10
|
+
} from "./HFG3HB6M.js";
|
|
11
|
+
import {
|
|
12
|
+
__spreadProps,
|
|
13
|
+
__spreadValues
|
|
14
|
+
} from "./SM5ASDQ3.js";
|
|
15
|
+
|
|
16
|
+
// src/hover.ts
|
|
17
|
+
import { isVisible } from "@ariakit/core/utils/dom";
|
|
18
|
+
import { invariant } from "@ariakit/core/utils/misc";
|
|
19
|
+
function isPointerEventsEnabled(element) {
|
|
20
|
+
return getComputedStyle(element).pointerEvents !== "none";
|
|
21
|
+
}
|
|
22
|
+
function hover(element, options) {
|
|
23
|
+
return wrapAsync(async () => {
|
|
24
|
+
invariant(element, "Unable to hover on null element");
|
|
25
|
+
if (!isVisible(element)) return;
|
|
26
|
+
const document = element.ownerDocument;
|
|
27
|
+
const { lastHovered } = document;
|
|
28
|
+
const { disabled } = element;
|
|
29
|
+
const pointerEventsEnabled = isPointerEventsEnabled(element);
|
|
30
|
+
if (lastHovered && lastHovered !== element && isVisible(lastHovered)) {
|
|
31
|
+
await dispatch.pointerMove(lastHovered, options);
|
|
32
|
+
await dispatch.mouseMove(lastHovered, options);
|
|
33
|
+
if (isPointerEventsEnabled(lastHovered)) {
|
|
34
|
+
const isElementWithinLastHovered = lastHovered.contains(element);
|
|
35
|
+
const relatedTarget = pointerEventsEnabled ? element : null;
|
|
36
|
+
const leaveOptions = __spreadProps(__spreadValues({}, options), { relatedTarget });
|
|
37
|
+
await dispatch.pointerOut(lastHovered, leaveOptions);
|
|
38
|
+
if (!isElementWithinLastHovered) {
|
|
39
|
+
await dispatch.pointerLeave(lastHovered, leaveOptions);
|
|
40
|
+
}
|
|
41
|
+
await dispatch.mouseOut(lastHovered, leaveOptions);
|
|
42
|
+
if (!isElementWithinLastHovered) {
|
|
43
|
+
await dispatch.mouseLeave(lastHovered, leaveOptions);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
await sleep();
|
|
48
|
+
if (pointerEventsEnabled) {
|
|
49
|
+
const enterOptions = lastHovered ? __spreadValues({ relatedTarget: lastHovered }, options) : options;
|
|
50
|
+
await dispatch.pointerOver(element, enterOptions);
|
|
51
|
+
await dispatch.pointerEnter(element, enterOptions);
|
|
52
|
+
if (!disabled) {
|
|
53
|
+
await dispatch.mouseOver(element, enterOptions);
|
|
54
|
+
await dispatch.mouseEnter(element, enterOptions);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
await dispatch.pointerMove(element, options);
|
|
58
|
+
if (!disabled) {
|
|
59
|
+
await dispatch.mouseMove(element, options);
|
|
60
|
+
}
|
|
61
|
+
document.lastHovered = element;
|
|
62
|
+
await sleep();
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export {
|
|
67
|
+
hover
|
|
68
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/__aria-role.ts
|
|
4
|
+
var roles = [
|
|
5
|
+
"alert",
|
|
6
|
+
"alertdialog",
|
|
7
|
+
"application",
|
|
8
|
+
"article",
|
|
9
|
+
"banner",
|
|
10
|
+
"blockquote",
|
|
11
|
+
"button",
|
|
12
|
+
"caption",
|
|
13
|
+
"cell",
|
|
14
|
+
"checkbox",
|
|
15
|
+
"code",
|
|
16
|
+
"columnheader",
|
|
17
|
+
"combobox",
|
|
18
|
+
"complementary",
|
|
19
|
+
"contentinfo",
|
|
20
|
+
"definition",
|
|
21
|
+
"deletion",
|
|
22
|
+
"dialog",
|
|
23
|
+
"directory",
|
|
24
|
+
"document",
|
|
25
|
+
"emphasis",
|
|
26
|
+
"feed",
|
|
27
|
+
"figure",
|
|
28
|
+
"form",
|
|
29
|
+
"generic",
|
|
30
|
+
"grid",
|
|
31
|
+
"gridcell",
|
|
32
|
+
"group",
|
|
33
|
+
"heading",
|
|
34
|
+
"img",
|
|
35
|
+
"insertion",
|
|
36
|
+
"link",
|
|
37
|
+
"list",
|
|
38
|
+
"listbox",
|
|
39
|
+
"listitem",
|
|
40
|
+
"log",
|
|
41
|
+
"main",
|
|
42
|
+
"marquee",
|
|
43
|
+
"math",
|
|
44
|
+
"menu",
|
|
45
|
+
"menubar",
|
|
46
|
+
"menuitem",
|
|
47
|
+
"menuitemcheckbox",
|
|
48
|
+
"menuitemradio",
|
|
49
|
+
"meter",
|
|
50
|
+
"navigation",
|
|
51
|
+
"none",
|
|
52
|
+
"note",
|
|
53
|
+
"option",
|
|
54
|
+
"paragraph",
|
|
55
|
+
"presentation",
|
|
56
|
+
"progressbar",
|
|
57
|
+
"radio",
|
|
58
|
+
"radiogroup",
|
|
59
|
+
"region",
|
|
60
|
+
"row",
|
|
61
|
+
"rowgroup",
|
|
62
|
+
"rowheader",
|
|
63
|
+
"scrollbar",
|
|
64
|
+
"search",
|
|
65
|
+
"searchbox",
|
|
66
|
+
"separator",
|
|
67
|
+
"slider",
|
|
68
|
+
"spinbutton",
|
|
69
|
+
"status",
|
|
70
|
+
"strong",
|
|
71
|
+
"subscript",
|
|
72
|
+
"superscript",
|
|
73
|
+
"switch",
|
|
74
|
+
"tab",
|
|
75
|
+
"table",
|
|
76
|
+
"tablist",
|
|
77
|
+
"tabpanel",
|
|
78
|
+
"term",
|
|
79
|
+
"textbox",
|
|
80
|
+
"time",
|
|
81
|
+
"timer",
|
|
82
|
+
"toolbar",
|
|
83
|
+
"tooltip",
|
|
84
|
+
"tree",
|
|
85
|
+
"treegrid",
|
|
86
|
+
"treeitem"
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
export {
|
|
90
|
+
roles
|
|
91
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
roles
|
|
4
|
+
} from "./CWTUOQ5Z.js";
|
|
5
|
+
import {
|
|
6
|
+
__spreadProps,
|
|
7
|
+
__spreadValues
|
|
8
|
+
} from "./SM5ASDQ3.js";
|
|
9
|
+
|
|
10
|
+
// src/query.ts
|
|
11
|
+
import { invariant } from "@ariakit/core/utils/misc";
|
|
12
|
+
import { queries as baseQueries } from "@testing-library/dom";
|
|
13
|
+
function createQueries(container) {
|
|
14
|
+
return Object.entries(baseQueries).reduce((queries, [key, query2]) => {
|
|
15
|
+
queries[key] = (...args) => query2(container || document.body, ...args);
|
|
16
|
+
return queries;
|
|
17
|
+
}, {});
|
|
18
|
+
}
|
|
19
|
+
var documentQueries = createQueries();
|
|
20
|
+
function matchName(name, accessibleName) {
|
|
21
|
+
if (accessibleName == null) return false;
|
|
22
|
+
if (typeof name === "string") {
|
|
23
|
+
return accessibleName === name;
|
|
24
|
+
}
|
|
25
|
+
return name.test(accessibleName);
|
|
26
|
+
}
|
|
27
|
+
function getNameOption(name, includesHidden) {
|
|
28
|
+
return (accessibleName, element) => {
|
|
29
|
+
if (!includesHidden && element.closest("[inert]")) return false;
|
|
30
|
+
if (!name) return true;
|
|
31
|
+
if (matchName(name, accessibleName)) return true;
|
|
32
|
+
if (element.getAttribute("aria-label")) return false;
|
|
33
|
+
const labeledBy = element.getAttribute("aria-labelledby");
|
|
34
|
+
if (!labeledBy) {
|
|
35
|
+
const content = "placeholder" in element && element.placeholder != null ? element.placeholder : element.textContent;
|
|
36
|
+
return matchName(name, content);
|
|
37
|
+
}
|
|
38
|
+
const label = document.getElementById(labeledBy);
|
|
39
|
+
if (!(label == null ? void 0 : label.textContent)) return false;
|
|
40
|
+
return matchName(name, label.textContent);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function createRoleQuery(role, queries = documentQueries) {
|
|
44
|
+
const createQuery = (query3) => {
|
|
45
|
+
return (name, options) => {
|
|
46
|
+
return query3(role, __spreadValues({
|
|
47
|
+
name: getNameOption(name, options == null ? void 0 : options.hidden)
|
|
48
|
+
}, options));
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
const createIncludesHidden = (query3) => (name, options) => query3(name, __spreadValues({ hidden: true }, options));
|
|
52
|
+
const query2 = createQuery(queries.queryByRole);
|
|
53
|
+
const allQuery = createQuery(queries.queryAllByRole);
|
|
54
|
+
const waitQuery = createQuery(queries.findByRole);
|
|
55
|
+
const waitAllQuery = createQuery(queries.findAllByRole);
|
|
56
|
+
const ensureQuery = createQuery(queries.getByRole);
|
|
57
|
+
const ensureAllQuery = createQuery(queries.getAllByRole);
|
|
58
|
+
const all = Object.assign(allQuery, {
|
|
59
|
+
includesHidden: createIncludesHidden(allQuery),
|
|
60
|
+
wait: Object.assign(waitAllQuery, {
|
|
61
|
+
includesHidden: createIncludesHidden(waitAllQuery)
|
|
62
|
+
}),
|
|
63
|
+
ensure: Object.assign(ensureAllQuery, {
|
|
64
|
+
includesHidden: createIncludesHidden(ensureAllQuery)
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
const wait = Object.assign(waitQuery, {
|
|
68
|
+
includesHidden: createIncludesHidden(waitQuery),
|
|
69
|
+
all: Object.assign(waitAllQuery, {
|
|
70
|
+
includesHidden: createIncludesHidden(waitAllQuery)
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
const ensure = Object.assign(ensureQuery, {
|
|
74
|
+
includesHidden: createIncludesHidden(ensureQuery),
|
|
75
|
+
all: Object.assign(ensureAllQuery, {
|
|
76
|
+
includesHidden: createIncludesHidden(ensureAllQuery)
|
|
77
|
+
})
|
|
78
|
+
});
|
|
79
|
+
return Object.assign(query2, {
|
|
80
|
+
includesHidden: createIncludesHidden(query2),
|
|
81
|
+
all,
|
|
82
|
+
wait,
|
|
83
|
+
ensure
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function createRoleQueries(queries = documentQueries) {
|
|
87
|
+
return roles.reduce((acc, role) => {
|
|
88
|
+
acc[role] = createRoleQuery(role, queries);
|
|
89
|
+
return acc;
|
|
90
|
+
}, {});
|
|
91
|
+
}
|
|
92
|
+
function createTextQuery(queries = documentQueries) {
|
|
93
|
+
const all = Object.assign(queries.queryAllByText, {
|
|
94
|
+
wait: queries.findAllByText,
|
|
95
|
+
ensure: queries.getAllByText
|
|
96
|
+
});
|
|
97
|
+
const wait = Object.assign(queries.findByText, {
|
|
98
|
+
all: queries.findAllByText
|
|
99
|
+
});
|
|
100
|
+
const ensure = Object.assign(queries.getByText, {
|
|
101
|
+
all: queries.getAllByText
|
|
102
|
+
});
|
|
103
|
+
return Object.assign(queries.queryByText, { all, wait, ensure });
|
|
104
|
+
}
|
|
105
|
+
function createLabeledQuery(queries = documentQueries) {
|
|
106
|
+
const all = Object.assign(queries.queryAllByLabelText, {
|
|
107
|
+
wait: queries.findAllByLabelText,
|
|
108
|
+
ensure: queries.getAllByLabelText
|
|
109
|
+
});
|
|
110
|
+
const wait = Object.assign(queries.findByLabelText, {
|
|
111
|
+
all: queries.findAllByLabelText
|
|
112
|
+
});
|
|
113
|
+
const ensure = Object.assign(queries.getByLabelText, {
|
|
114
|
+
all: queries.getAllByLabelText
|
|
115
|
+
});
|
|
116
|
+
return Object.assign(queries.queryByLabelText, { all, wait, ensure });
|
|
117
|
+
}
|
|
118
|
+
function createQueryObject(queries = documentQueries) {
|
|
119
|
+
return __spreadProps(__spreadValues({}, createRoleQueries(queries)), {
|
|
120
|
+
text: createTextQuery(queries),
|
|
121
|
+
labeled: createLabeledQuery(queries),
|
|
122
|
+
within: (element) => {
|
|
123
|
+
invariant(element, "Unable to create queries for null element");
|
|
124
|
+
return createQueryObject(createQueries(element));
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
var query = createQueryObject();
|
|
129
|
+
var q = query;
|
|
130
|
+
|
|
131
|
+
export {
|
|
132
|
+
query,
|
|
133
|
+
q
|
|
134
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
isBrowser,
|
|
4
|
+
nextFrame,
|
|
5
|
+
wrapAsync
|
|
6
|
+
} from "./HFG3HB6M.js";
|
|
7
|
+
|
|
8
|
+
// src/sleep.ts
|
|
9
|
+
var defaultMs = isBrowser ? 150 : 10;
|
|
10
|
+
function sleep(ms = defaultMs) {
|
|
11
|
+
return wrapAsync(async () => {
|
|
12
|
+
await nextFrame();
|
|
13
|
+
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
14
|
+
await nextFrame();
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
sleep
|
|
20
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/__utils.ts
|
|
4
|
+
import { isFocusable } from "@ariakit/core/utils/focus";
|
|
5
|
+
import { noop } from "@ariakit/core/utils/misc";
|
|
6
|
+
var isBrowser = typeof navigator !== "undefined" && !navigator.userAgent.includes("jsdom") && typeof window !== "undefined" && !("happyDOM" in window);
|
|
7
|
+
async function flushMicrotasks() {
|
|
8
|
+
await Promise.resolve();
|
|
9
|
+
await Promise.resolve();
|
|
10
|
+
await Promise.resolve();
|
|
11
|
+
}
|
|
12
|
+
function nextFrame() {
|
|
13
|
+
return new Promise(requestAnimationFrame);
|
|
14
|
+
}
|
|
15
|
+
function setActEnvironment(value) {
|
|
16
|
+
const scope = globalThis;
|
|
17
|
+
const previousValue = scope.IS_REACT_ACT_ENVIRONMENT;
|
|
18
|
+
scope.IS_REACT_ACT_ENVIRONMENT = value;
|
|
19
|
+
const restoreActEnvironment = () => {
|
|
20
|
+
scope.IS_REACT_ACT_ENVIRONMENT = previousValue;
|
|
21
|
+
};
|
|
22
|
+
return restoreActEnvironment;
|
|
23
|
+
}
|
|
24
|
+
function applyBrowserPolyfills() {
|
|
25
|
+
if (isBrowser) return noop;
|
|
26
|
+
const originalFocus = HTMLElement.prototype.focus;
|
|
27
|
+
HTMLElement.prototype.focus = function focus(options) {
|
|
28
|
+
if (!isFocusable(this)) return;
|
|
29
|
+
return originalFocus.call(this, options);
|
|
30
|
+
};
|
|
31
|
+
const originalGetClientRects = Element.prototype.getClientRects;
|
|
32
|
+
Element.prototype.getClientRects = function getClientRects() {
|
|
33
|
+
const isHidden = (element) => {
|
|
34
|
+
if (!element.isConnected) return true;
|
|
35
|
+
if (element.parentElement && isHidden(element.parentElement)) return true;
|
|
36
|
+
if (!(element instanceof HTMLElement)) return false;
|
|
37
|
+
if (element.hidden) return true;
|
|
38
|
+
const style = getComputedStyle(element);
|
|
39
|
+
return style.display === "none" || style.visibility === "hidden";
|
|
40
|
+
};
|
|
41
|
+
if (isHidden(this)) return [];
|
|
42
|
+
return [{ width: 1, height: 1 }];
|
|
43
|
+
};
|
|
44
|
+
if (!Element.prototype.scrollIntoView) {
|
|
45
|
+
Element.prototype.scrollIntoView = noop;
|
|
46
|
+
}
|
|
47
|
+
if (!Element.prototype.hasPointerCapture) {
|
|
48
|
+
Element.prototype.hasPointerCapture = noop;
|
|
49
|
+
}
|
|
50
|
+
if (!Element.prototype.setPointerCapture) {
|
|
51
|
+
Element.prototype.setPointerCapture = noop;
|
|
52
|
+
}
|
|
53
|
+
if (!Element.prototype.releasePointerCapture) {
|
|
54
|
+
Element.prototype.releasePointerCapture = noop;
|
|
55
|
+
}
|
|
56
|
+
if (typeof window.ClipboardEvent === "undefined") {
|
|
57
|
+
window.ClipboardEvent = class ClipboardEvent extends Event {
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (typeof window.PointerEvent === "undefined") {
|
|
61
|
+
window.PointerEvent = class PointerEvent extends MouseEvent {
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return () => {
|
|
65
|
+
HTMLElement.prototype.focus = originalFocus;
|
|
66
|
+
Element.prototype.getClientRects = originalGetClientRects;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
async function wrapAsync(fn) {
|
|
70
|
+
const restoreActEnvironment = setActEnvironment(false);
|
|
71
|
+
const removeBrowserPolyfills = applyBrowserPolyfills();
|
|
72
|
+
try {
|
|
73
|
+
return await fn();
|
|
74
|
+
} finally {
|
|
75
|
+
restoreActEnvironment();
|
|
76
|
+
removeBrowserPolyfills();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export {
|
|
81
|
+
isBrowser,
|
|
82
|
+
flushMicrotasks,
|
|
83
|
+
nextFrame,
|
|
84
|
+
wrapAsync
|
|
85
|
+
};
|