@ariakit/test 0.4.6 → 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 +8 -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 +2 -2
- 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
package/esm/__chunks/4SG6SLGL.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
dispatch
|
|
4
|
-
} from "./LK25WCYN.js";
|
|
5
|
-
import {
|
|
6
|
-
flushMicrotasks,
|
|
7
|
-
wrapAsync
|
|
8
|
-
} from "./HFG3HB6M.js";
|
|
9
|
-
|
|
10
|
-
// src/focus.ts
|
|
11
|
-
import { getActiveElement } from "@ariakit/core/utils/dom";
|
|
12
|
-
import { isFocusable } from "@ariakit/core/utils/focus";
|
|
13
|
-
import { invariant } from "@ariakit/core/utils/misc";
|
|
14
|
-
function focus(element) {
|
|
15
|
-
return wrapAsync(async () => {
|
|
16
|
-
invariant(element, "Unable to focus on null element");
|
|
17
|
-
if (getActiveElement(element) === element) return;
|
|
18
|
-
if (!isFocusable(element)) return;
|
|
19
|
-
const htmlElement = element;
|
|
20
|
-
const activeElement = getActiveElement(
|
|
21
|
-
htmlElement
|
|
22
|
-
);
|
|
23
|
-
if (activeElement == null ? void 0 : activeElement.dirty) {
|
|
24
|
-
await dispatch.change(activeElement);
|
|
25
|
-
activeElement.dirty = false;
|
|
26
|
-
}
|
|
27
|
-
htmlElement.focus();
|
|
28
|
-
await flushMicrotasks();
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export {
|
|
33
|
-
focus
|
|
34
|
-
};
|
package/esm/__chunks/BQA4OBCC.js
DELETED
package/esm/__chunks/CNNB7B4V.js
DELETED
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
type
|
|
4
|
-
} from "./YVVGFTRB.js";
|
|
5
|
-
import {
|
|
6
|
-
blur
|
|
7
|
-
} from "./SOWA2DKF.js";
|
|
8
|
-
import {
|
|
9
|
-
focus
|
|
10
|
-
} from "./4SG6SLGL.js";
|
|
11
|
-
import {
|
|
12
|
-
dispatch
|
|
13
|
-
} from "./LK25WCYN.js";
|
|
14
|
-
import {
|
|
15
|
-
sleep
|
|
16
|
-
} from "./DZ24E43J.js";
|
|
17
|
-
import {
|
|
18
|
-
wrapAsync
|
|
19
|
-
} from "./HFG3HB6M.js";
|
|
20
|
-
import {
|
|
21
|
-
__spreadValues
|
|
22
|
-
} from "./SM5ASDQ3.js";
|
|
23
|
-
|
|
24
|
-
// src/press.ts
|
|
25
|
-
import { isTextField, setSelectionRange } from "@ariakit/core/utils/dom";
|
|
26
|
-
import {
|
|
27
|
-
getNextTabbable,
|
|
28
|
-
getPreviousTabbable,
|
|
29
|
-
isFocusable
|
|
30
|
-
} from "@ariakit/core/utils/focus";
|
|
31
|
-
var clickableInputTypes = [
|
|
32
|
-
"button",
|
|
33
|
-
"color",
|
|
34
|
-
"file",
|
|
35
|
-
"image",
|
|
36
|
-
"reset",
|
|
37
|
-
"submit"
|
|
38
|
-
];
|
|
39
|
-
async function submitFormByPressingEnterOn(element, options) {
|
|
40
|
-
const { form } = element;
|
|
41
|
-
if (!form) return;
|
|
42
|
-
const elements = Array.from(form.elements);
|
|
43
|
-
const validInputs = elements.filter(
|
|
44
|
-
(el) => el instanceof HTMLInputElement && isTextField(el)
|
|
45
|
-
);
|
|
46
|
-
const submitButton = elements.find(
|
|
47
|
-
(el) => (el instanceof HTMLInputElement || el instanceof HTMLButtonElement) && el.type === "submit"
|
|
48
|
-
);
|
|
49
|
-
if (validInputs.length === 1 || submitButton) {
|
|
50
|
-
await dispatch.submit(form, options);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function isNumberInput(element) {
|
|
54
|
-
return element instanceof HTMLInputElement && element.type === "number";
|
|
55
|
-
}
|
|
56
|
-
async function incrementNumberInput(element, by = 1) {
|
|
57
|
-
const value = +element.value + by;
|
|
58
|
-
const max = element.max ? +element.max : Number.MAX_SAFE_INTEGER;
|
|
59
|
-
const min = element.min ? +element.min : Number.MIN_SAFE_INTEGER;
|
|
60
|
-
if (value > max || value < min) return;
|
|
61
|
-
element.value = value.toString();
|
|
62
|
-
await dispatch.input(element);
|
|
63
|
-
await dispatch.change(element);
|
|
64
|
-
}
|
|
65
|
-
var keyDownMap = {
|
|
66
|
-
async Tab(_, { shiftKey }) {
|
|
67
|
-
const nextElement = shiftKey ? getPreviousTabbable() : getNextTabbable();
|
|
68
|
-
if (nextElement) {
|
|
69
|
-
await focus(nextElement);
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
async Enter(element, options) {
|
|
73
|
-
const nonSubmittableTypes = [...clickableInputTypes, "hidden"];
|
|
74
|
-
const isClickable = element.tagName === "BUTTON" || element instanceof HTMLInputElement && clickableInputTypes.includes(element.type);
|
|
75
|
-
const isSubmittable = element instanceof HTMLInputElement && !nonSubmittableTypes.includes(element.type);
|
|
76
|
-
if (isClickable) {
|
|
77
|
-
await dispatch.click(element, options);
|
|
78
|
-
} else if (isSubmittable) {
|
|
79
|
-
await submitFormByPressingEnterOn(element, options);
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
async Home(element, { shiftKey }) {
|
|
83
|
-
if (isTextField(element)) {
|
|
84
|
-
const { value, selectionEnd } = element;
|
|
85
|
-
const end = Math.min(value.length, shiftKey ? selectionEnd != null ? selectionEnd : 0 : 0);
|
|
86
|
-
setSelectionRange(element, 0, end, "backward");
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
async End(element, { shiftKey }) {
|
|
90
|
-
if (isTextField(element)) {
|
|
91
|
-
const { value, selectionStart } = element;
|
|
92
|
-
const start = shiftKey ? selectionStart != null ? selectionStart : 0 : value.length;
|
|
93
|
-
setSelectionRange(element, start, value.length, "forward");
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
async ArrowLeft(element, { shiftKey }) {
|
|
97
|
-
if (isTextField(element)) {
|
|
98
|
-
const { value, selectionStart, selectionEnd, selectionDirection } = element;
|
|
99
|
-
const [start, end] = [selectionStart != null ? selectionStart : 0, selectionEnd != null ? selectionEnd : 0];
|
|
100
|
-
const collapsing = !shiftKey && start !== end;
|
|
101
|
-
const nextStart = Math.max(0, collapsing ? start : start - 1);
|
|
102
|
-
const nextEnd = Math.min(value.length, shiftKey ? end : nextStart);
|
|
103
|
-
setSelectionRange(
|
|
104
|
-
element,
|
|
105
|
-
nextStart,
|
|
106
|
-
nextEnd,
|
|
107
|
-
selectionDirection || "backward"
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
async ArrowRight(element, { shiftKey }) {
|
|
112
|
-
if (isTextField(element)) {
|
|
113
|
-
const { value, selectionStart, selectionEnd, selectionDirection } = element;
|
|
114
|
-
const [start, end] = [selectionStart != null ? selectionStart : 0, selectionEnd != null ? selectionEnd : 0];
|
|
115
|
-
const collapsing = !shiftKey && start !== end;
|
|
116
|
-
const nextEnd = Math.min(value.length, collapsing ? end : end + 1);
|
|
117
|
-
const nextStart = Math.max(0, shiftKey ? start : nextEnd);
|
|
118
|
-
setSelectionRange(
|
|
119
|
-
element,
|
|
120
|
-
nextStart,
|
|
121
|
-
nextEnd,
|
|
122
|
-
selectionDirection || "forward"
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
async ArrowUp(element, { shiftKey }) {
|
|
127
|
-
if (isTextField(element)) {
|
|
128
|
-
if (!shiftKey) {
|
|
129
|
-
return setSelectionRange(element, 0, 0);
|
|
130
|
-
}
|
|
131
|
-
const { selectionStart, selectionEnd, selectionDirection } = element;
|
|
132
|
-
const [start, end] = [selectionStart != null ? selectionStart : 0, selectionEnd != null ? selectionEnd : 0];
|
|
133
|
-
if (selectionDirection === "forward") {
|
|
134
|
-
setSelectionRange(element, start, start);
|
|
135
|
-
} else {
|
|
136
|
-
setSelectionRange(element, 0, end, "backward");
|
|
137
|
-
}
|
|
138
|
-
} else if (isNumberInput(element)) {
|
|
139
|
-
await incrementNumberInput(element);
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
async ArrowDown(element, { shiftKey }) {
|
|
143
|
-
if (isTextField(element)) {
|
|
144
|
-
const length = element.value.length;
|
|
145
|
-
if (!shiftKey) {
|
|
146
|
-
setSelectionRange(element, length, length);
|
|
147
|
-
} else {
|
|
148
|
-
const { selectionStart, selectionEnd, selectionDirection } = element;
|
|
149
|
-
const [start, end] = [selectionStart != null ? selectionStart : 0, selectionEnd != null ? selectionEnd : 0];
|
|
150
|
-
if (selectionDirection === "backward") {
|
|
151
|
-
setSelectionRange(element, end, end);
|
|
152
|
-
} else {
|
|
153
|
-
setSelectionRange(element, start, length, "forward");
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
} else if (isNumberInput(element)) {
|
|
157
|
-
await incrementNumberInput(element, -1);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
var keyUpMap = {
|
|
162
|
-
// Space
|
|
163
|
-
" ": async (element, options) => {
|
|
164
|
-
const spaceableTypes = [...clickableInputTypes, "checkbox", "radio"];
|
|
165
|
-
const isSpaceable = element.tagName === "BUTTON" || element instanceof HTMLInputElement && spaceableTypes.includes(element.type);
|
|
166
|
-
if (isSpaceable) {
|
|
167
|
-
await dispatch.click(element, options);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
function press(key, element, options = {}) {
|
|
172
|
-
return wrapAsync(async () => {
|
|
173
|
-
var _a, _b, _c, _d;
|
|
174
|
-
if (element == null) {
|
|
175
|
-
element = document.activeElement || document.body;
|
|
176
|
-
}
|
|
177
|
-
if (!element) return;
|
|
178
|
-
if (!isFocusable(element) && element.tagName !== "BODY") return;
|
|
179
|
-
if (isTextField(element)) {
|
|
180
|
-
if (key.length === 1) {
|
|
181
|
-
return type(key, element, options);
|
|
182
|
-
} else if (key === "Delete") {
|
|
183
|
-
return type("\x7F", element, options);
|
|
184
|
-
} else if (key === "Backspace") {
|
|
185
|
-
return type("\b", element, options);
|
|
186
|
-
} else if (key === "Enter" && element.tagName === "TEXTAREA") {
|
|
187
|
-
return type("\n", element, options);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (((_a = element.ownerDocument) == null ? void 0 : _a.activeElement) !== element) {
|
|
191
|
-
if (element.tagName === "BODY") {
|
|
192
|
-
await blur();
|
|
193
|
-
} else {
|
|
194
|
-
await focus(element);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
await sleep();
|
|
198
|
-
let defaultAllowed = await dispatch.keyDown(element, __spreadValues({ key }, options));
|
|
199
|
-
if (defaultAllowed && key in keyDownMap && !options.metaKey) {
|
|
200
|
-
await ((_b = keyDownMap[key]) == null ? void 0 : _b.call(keyDownMap, element, options));
|
|
201
|
-
}
|
|
202
|
-
await sleep();
|
|
203
|
-
if (((_c = element.ownerDocument) == null ? void 0 : _c.activeElement) !== element) {
|
|
204
|
-
element = element.ownerDocument.activeElement;
|
|
205
|
-
}
|
|
206
|
-
if (!await dispatch.keyUp(element, __spreadValues({ key }, options))) {
|
|
207
|
-
defaultAllowed = false;
|
|
208
|
-
}
|
|
209
|
-
if (defaultAllowed && key in keyUpMap && !options.metaKey) {
|
|
210
|
-
await ((_d = keyUpMap[key]) == null ? void 0 : _d.call(keyUpMap, element, options));
|
|
211
|
-
}
|
|
212
|
-
await sleep();
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
function createPress(key, defaultOptions = {}) {
|
|
216
|
-
return (element, options = {}) => press(key, element, __spreadValues(__spreadValues({}, defaultOptions), options));
|
|
217
|
-
}
|
|
218
|
-
press.Escape = createPress("Escape");
|
|
219
|
-
press.Backspace = createPress("Backspace");
|
|
220
|
-
press.Delete = createPress("Delete");
|
|
221
|
-
press.Tab = createPress("Tab");
|
|
222
|
-
press.ShiftTab = createPress("Tab", { shiftKey: true });
|
|
223
|
-
press.Enter = createPress("Enter");
|
|
224
|
-
press.Space = createPress(" ");
|
|
225
|
-
press.ArrowUp = createPress("ArrowUp");
|
|
226
|
-
press.ArrowRight = createPress("ArrowRight");
|
|
227
|
-
press.ArrowDown = createPress("ArrowDown");
|
|
228
|
-
press.ArrowLeft = createPress("ArrowLeft");
|
|
229
|
-
press.End = createPress("End");
|
|
230
|
-
press.Home = createPress("Home");
|
|
231
|
-
press.PageUp = createPress("PageUp");
|
|
232
|
-
press.PageDown = createPress("PageDown");
|
|
233
|
-
|
|
234
|
-
export {
|
|
235
|
-
press
|
|
236
|
-
};
|
package/esm/__chunks/CWTUOQ5Z.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
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
|
-
};
|
package/esm/__chunks/DZ24E43J.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
};
|
package/esm/__chunks/G32GEXRJ.js
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
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 = document.body) {
|
|
14
|
-
return Object.entries(baseQueries).reduce((queries, [key, query2]) => {
|
|
15
|
-
queries[key] = (...args) => query2(container, ...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
|
-
};
|
package/esm/__chunks/HFG3HB6M.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
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
|
-
};
|