This commit is contained in:
Iliyan Angelov
2025-09-14 23:24:25 +03:00
commit c67067a2a4
71311 changed files with 6800714 additions and 0 deletions

View File

@@ -0,0 +1 @@
export declare function eventWrapper<T>(cb: () => T): T | undefined;

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.eventWrapper = eventWrapper;
var _dom = require("@testing-library/dom");
function eventWrapper(cb) {
let result;
(0, _dom.getConfig)().eventWrapper(() => {
result = cb();
});
return result;
}

View File

@@ -0,0 +1 @@
export declare const hasFormSubmit: (form: HTMLFormElement | null) => form is HTMLFormElement;

View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.hasFormSubmit = void 0;
const hasFormSubmit = form => !!(form && (form.querySelector('input[type="submit"]') || form.querySelector('button[type="submit"]')));
exports.hasFormSubmit = hasFormSubmit;

View File

@@ -0,0 +1,15 @@
/**
* Options that can be passed to any event that relies
* on pointer-events property
*/
export declare interface PointerOptions {
/**
* When set to `true` the event skips checking if any element
* in the DOM-tree has `'pointer-events: none'` set. This check is
* costly in general and very costly when rendering large DOM-trees.
* Can be used to speed up tests.
* Default: `false`
* */
skipPointerEventsCheck?: boolean;
}
export declare function hasPointerEvents(element: Element): boolean;

View File

@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.hasPointerEvents = hasPointerEvents;
var _helpers = require("@testing-library/dom/dist/helpers");
function hasPointerEvents(element) {
const window = (0, _helpers.getWindowFromNode)(element);
for (let el = element; (_el = el) != null && _el.ownerDocument; el = el.parentElement) {
var _el;
const pointerEvents = window.getComputedStyle(el).pointerEvents;
if (pointerEvents && !['inherit', 'unset'].includes(pointerEvents)) {
return pointerEvents !== 'none';
}
}
return true;
}

View File

@@ -0,0 +1 @@
export declare function isDisabled(element: Element | null): boolean;

View File

@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isDisabled = isDisabled;
// This should probably be extended with checking the element type
// https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled
function isDisabled(element) {
return Boolean(element && element.disabled);
}

View File

@@ -0,0 +1 @@
export declare function isDocument(el: Document | Element): el is Document;

View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isDocument = isDocument;
function isDocument(el) {
return el.nodeType === el.DOCUMENT_NODE;
}

View File

@@ -0,0 +1,5 @@
declare type tag = keyof HTMLElementTagNameMap;
export declare function isElementType<T extends tag, P extends {
[k: string]: unknown;
} | undefined = undefined>(element: Element, tag: T | T[], props?: P): element is P extends undefined ? HTMLElementTagNameMap[T] : HTMLElementTagNameMap[T] & P;
export {};

View File

@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isElementType = isElementType;
function isElementType(element, tag, props) {
if (element.namespaceURI && element.namespaceURI !== 'http://www.w3.org/1999/xhtml') {
return false;
}
tag = Array.isArray(tag) ? tag : [tag]; // tagName is uppercase in HTMLDocument and lowercase in XMLDocument
if (!tag.includes(element.tagName.toLowerCase())) {
return false;
}
if (props) {
return Object.entries(props).every(([k, v]) => element[k] === v);
}
return true;
}

View File

@@ -0,0 +1 @@
export declare function isLabelWithInternallyDisabledControl(element: Element): boolean;

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isLabelWithInternallyDisabledControl = isLabelWithInternallyDisabledControl;
var _isDisabled = require("./isDisabled");
var _isElementType = require("./isElementType");
// Absolutely NO events fire on label elements that contain their control
// if that control is disabled. NUTS!
// no joke. There are NO events for: <label><input disabled /><label>
function isLabelWithInternallyDisabledControl(element) {
if (!(0, _isElementType.isElementType)(element, 'label')) {
return false;
}
const control = element.control;
return Boolean(control && element.contains(control) && (0, _isDisabled.isDisabled)(control));
}

View File

@@ -0,0 +1 @@
export declare function isVisible(element: Element): boolean;

View File

@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isVisible = isVisible;
var _helpers = require("@testing-library/dom/dist/helpers");
function isVisible(element) {
const window = (0, _helpers.getWindowFromNode)(element);
for (let el = element; (_el = el) != null && _el.ownerDocument; el = el.parentElement) {
var _el;
const display = window.getComputedStyle(el).display;
if (display === 'none') {
return false;
}
}
return true;
}

View File

@@ -0,0 +1 @@
export declare function wait(time?: number): Promise<void>;

View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.wait = wait;
function wait(time) {
return new Promise(resolve => setTimeout(() => resolve(), time));
}