@rind-ui/testing 0.3.0 → 0.4.0
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/dist/{adapter-B05M46SW.d.mts → adapter-C3LQTPFi.d.mts} +2 -0
- package/dist/{compose-BpR_PG11.mjs → compose-m76ER6GL.mjs} +1 -1
- package/dist/{dom-Ur_VPlTe.d.mts → dom-BH8CVBb2.d.mts} +1 -1
- package/dist/{dom-Bnnr_fg-.mjs → dom-DjurZVd0.mjs} +35 -4
- package/dist/dom.d.mts +1 -1
- package/dist/dom.mjs +1 -1
- package/dist/index.d.mts +3276 -852
- package/dist/index.mjs +217 -25
- package/dist/inpage.iife.js +7 -7
- package/dist/{playwright-C3Ue38p3.mjs → playwright-BbVj53fU.mjs} +10 -3
- package/dist/{playwright-By15MZsN.d.mts → playwright-D2coDhsT.d.mts} +1 -1
- package/dist/playwright.d.mts +1 -1
- package/dist/playwright.mjs +1 -1
- package/dist/setup.mjs +1 -1
- package/package.json +3 -3
|
@@ -17,6 +17,8 @@ interface ElementInfo {
|
|
|
17
17
|
readonly inAriaHidden: boolean;
|
|
18
18
|
readonly inInert: boolean;
|
|
19
19
|
readonly focusable: boolean;
|
|
20
|
+
/** A grid cell (the roving focus target itself) holding a focusable descendant. */
|
|
21
|
+
readonly focusableInside: boolean;
|
|
20
22
|
/** Finite animations running (or held) on the element: exit animations presence waits for. */
|
|
21
23
|
readonly animations: number;
|
|
22
24
|
/** Its computed style animates (a transition or animation duration above zero). */
|
|
@@ -67,7 +67,7 @@ var UntilTimeout = class extends Error {
|
|
|
67
67
|
};
|
|
68
68
|
/** Mirrors horizontal arrows for right-to-left runs; everything else is unchanged. */
|
|
69
69
|
const mirror = (key, direction) => direction === "ltr" ? key : key === "ArrowLeft" ? "ArrowRight" : key === "ArrowRight" ? "ArrowLeft" : key;
|
|
70
|
-
const describeBy = (by) => "role" in by ? `role "${by.role}"${by.name === void 0 ? "" : ` named ${JSON.stringify(String(by.name))}`}` : "label" in by ? `control labelled ${JSON.stringify(String(by.label))}` : "part" in by ? `part "${by.part}"` : `text ${JSON.stringify(String(by.text))}`;
|
|
70
|
+
const describeBy = (by) => "role" in by ? `role "${[by.role].flat().join(" | ")}"${by.name === void 0 ? "" : ` named ${JSON.stringify(String(by.name))}`}` : "label" in by ? `control labelled ${JSON.stringify(String(by.label))}` : "part" in by ? `part "${by.part}"` : `text ${JSON.stringify(String(by.text))}`;
|
|
71
71
|
//#endregion
|
|
72
72
|
//#region src/adapters/compose.ts
|
|
73
73
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as renamedSnapshot, r as describeBy, s as poll, t as composeInPage } from "./compose-
|
|
1
|
+
import { c as renamedSnapshot, r as describeBy, s as poll, t as composeInPage } from "./compose-m76ER6GL.mjs";
|
|
2
2
|
import { ANNOUNCEMENTS, KEY_DEBOUNCE_MS, PENDING_ANNOUNCEMENTS, isKeptVisible, tabbables } from "@rind-ui/core";
|
|
3
3
|
import { computeAccessibleDescription, computeAccessibleName } from "dom-accessibility-api";
|
|
4
4
|
//#region src/announcements.ts
|
|
@@ -166,7 +166,16 @@ function collectDom(arg) {
|
|
|
166
166
|
const groupOf = (el) => {
|
|
167
167
|
const parent = el.parentElement;
|
|
168
168
|
if (!parents.has(parent)) parents.set(parent, parents.size);
|
|
169
|
-
|
|
169
|
+
const level = el.getAttribute("aria-level");
|
|
170
|
+
let owner = "";
|
|
171
|
+
if (level !== null) for (let p = el.previousElementSibling; p; p = p.previousElementSibling) {
|
|
172
|
+
const l = p.getAttribute("aria-level");
|
|
173
|
+
if (l !== null && Number(l) < Number(level)) {
|
|
174
|
+
owner = p.id;
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return `${parents.get(parent)}|${level ?? ""}|${owner}`;
|
|
170
179
|
};
|
|
171
180
|
const own = (el) => el.getAttribute("data-instance") === arg.instance && el.getAttribute("data-scope") === arg.scope;
|
|
172
181
|
const info = (el) => ({
|
|
@@ -192,6 +201,7 @@ function collectDom(arg) {
|
|
|
192
201
|
inAriaHidden: el.closest("[aria-hidden=true]") !== null,
|
|
193
202
|
inInert: el.closest("[inert]") !== null,
|
|
194
203
|
focusable: focusable(el),
|
|
204
|
+
focusableInside: roleOf(el) === "gridcell" && [...el.querySelectorAll("*")].some(focusable),
|
|
195
205
|
animations: typeof el.getAnimations === "function" ? el.getAnimations().filter((a) => (a.playState === "running" || a.playState === "paused") && a.effect?.getComputedTiming().endTime !== Number.POSITIVE_INFINITY).length : 0,
|
|
196
206
|
motion: hasMotion(el),
|
|
197
207
|
group: groupOf(el),
|
|
@@ -247,6 +257,7 @@ function collectDom(arg) {
|
|
|
247
257
|
if (partEls.length === 0 && doc.body) for (const el of Array.from(doc.body.querySelectorAll("*"))) record(el);
|
|
248
258
|
const active = doc.activeElement;
|
|
249
259
|
const activePart = active?.closest(selector);
|
|
260
|
+
const inControlled = active != null && elements.some((el) => (el.getAttribute("aria-controls") ?? "").split(/\s+/).filter(Boolean).some((id) => doc.getElementById(id)?.contains(active) === true));
|
|
250
261
|
const fieldRoot = partEls[0]?.closest("[data-scope=\"field\"][data-part=\"root\"]") ?? null;
|
|
251
262
|
const fieldPart = (part) => fieldRoot ? Array.from(doc.querySelectorAll(`[data-scope="field"][data-part="${part}"][data-instance="${fieldRoot.getAttribute("data-instance")}"]`)) : [];
|
|
252
263
|
const fieldLabel = fieldPart("label")[0];
|
|
@@ -267,7 +278,7 @@ function collectDom(arg) {
|
|
|
267
278
|
focus: {
|
|
268
279
|
onBody: active === null || active === doc.body,
|
|
269
280
|
part: activePart?.getAttribute("data-part") ?? null,
|
|
270
|
-
inInstance: activePart != null,
|
|
281
|
+
inInstance: activePart != null || inControlled,
|
|
271
282
|
element: active && active !== doc.body ? info(active) : null
|
|
272
283
|
},
|
|
273
284
|
html: attrsOf(doc.documentElement),
|
|
@@ -596,7 +607,7 @@ function createDomEnv({ scope, anchor, modality, platform, partName, anatomyName
|
|
|
596
607
|
if ("role" in by) {
|
|
597
608
|
const { queryAllByRole } = await loadTL();
|
|
598
609
|
const name = by.name;
|
|
599
|
-
return queryAllByRole(within,
|
|
610
|
+
return [...new Set([by.role].flat().flatMap((role) => queryAllByRole(within, role, { ...name === void 0 ? {} : { name: typeof name === "string" ? (n) => normalize(n) === name : name } })))].sort((a, b) => a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1);
|
|
600
611
|
}
|
|
601
612
|
if ("label" in by) {
|
|
602
613
|
const { queryAllByLabelText } = await loadTL();
|
|
@@ -1047,6 +1058,26 @@ function createDomEnv({ scope, anchor, modality, platform, partName, anatomyName
|
|
|
1047
1058
|
input.dispatchEvent(new InputEvent("input", init));
|
|
1048
1059
|
});
|
|
1049
1060
|
},
|
|
1061
|
+
async setFiles(specs) {
|
|
1062
|
+
const el = await waitFor();
|
|
1063
|
+
await act(() => {
|
|
1064
|
+
const input = el;
|
|
1065
|
+
const files = specs.map((f) => new File([f.content], f.name, { type: f.type }));
|
|
1066
|
+
if (typeof DataTransfer === "function") {
|
|
1067
|
+
const dt = new DataTransfer();
|
|
1068
|
+
for (const f of files) dt.items.add(f);
|
|
1069
|
+
input.files = dt.files;
|
|
1070
|
+
} else {
|
|
1071
|
+
const list = Object.assign([...files], { item: (i) => files[i] ?? null });
|
|
1072
|
+
Object.defineProperty(input, "files", {
|
|
1073
|
+
configurable: true,
|
|
1074
|
+
value: list
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
1078
|
+
input.dispatchEvent(new Event("change", { bubbles: true }));
|
|
1079
|
+
});
|
|
1080
|
+
},
|
|
1050
1081
|
waitForDetach: async () => {
|
|
1051
1082
|
await until(async () => (await resolve()).length, (n) => n === 0);
|
|
1052
1083
|
},
|
package/dist/dom.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as UserLike, r as domEnv, t as DomAdapterOptions } from "./dom-
|
|
1
|
+
import { n as UserLike, r as domEnv, t as DomAdapterOptions } from "./dom-BH8CVBb2.mjs";
|
|
2
2
|
export { type DomAdapterOptions, type UserLike, domEnv };
|
package/dist/dom.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as domEnv } from "./dom-
|
|
1
|
+
export { t as domEnv } from "./dom-DjurZVd0.mjs";
|