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,31 @@
export declare function getMouseEventOptions(event: string, init?: MouseEventInit, clickCount?: number): {
detail: number;
buttons: number;
button: number;
clientX?: number | undefined;
clientY?: number | undefined;
movementX?: number | undefined;
movementY?: number | undefined;
relatedTarget?: EventTarget | null | undefined;
screenX?: number | undefined;
screenY?: number | undefined;
altKey?: boolean | undefined;
ctrlKey?: boolean | undefined;
metaKey?: boolean | undefined;
modifierAltGraph?: boolean | undefined;
modifierCapsLock?: boolean | undefined;
modifierFn?: boolean | undefined;
modifierFnLock?: boolean | undefined;
modifierHyper?: boolean | undefined;
modifierNumLock?: boolean | undefined;
modifierScrollLock?: boolean | undefined;
modifierSuper?: boolean | undefined;
modifierSymbol?: boolean | undefined;
modifierSymbolLock?: boolean | undefined;
shiftKey?: boolean | undefined;
view?: Window | null | undefined;
which?: number | undefined;
bubbles?: boolean | undefined;
cancelable?: boolean | undefined;
composed?: boolean | undefined;
};

View File

@@ -0,0 +1,61 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getMouseEventOptions = getMouseEventOptions;
function isMousePressEvent(event) {
return event === 'mousedown' || event === 'mouseup' || event === 'click' || event === 'dblclick';
} // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
const BUTTONS_NAMES = {
none: 0,
primary: 1,
secondary: 2,
auxiliary: 4
}; // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
const BUTTON_NAMES = {
primary: 0,
auxiliary: 1,
secondary: 2
};
function translateButtonNumber(value, from) {
var _Object$entries$find;
const [mapIn, mapOut] = from === 'button' ? [BUTTON_NAMES, BUTTONS_NAMES] : [BUTTONS_NAMES, BUTTON_NAMES];
const name = (_Object$entries$find = Object.entries(mapIn).find(([, i]) => i === value)) == null ? void 0 : _Object$entries$find[0]; // istanbul ignore next
return name && Object.prototype.hasOwnProperty.call(mapOut, name) ? mapOut[name] : 0;
}
function convertMouseButtons(event, init, property) {
if (!isMousePressEvent(event)) {
return 0;
}
if (typeof init[property] === 'number') {
return init[property];
} else if (property === 'button' && typeof init.buttons === 'number') {
return translateButtonNumber(init.buttons, 'buttons');
} else if (property === 'buttons' && typeof init.button === 'number') {
return translateButtonNumber(init.button, 'button');
}
return property != 'button' && isMousePressEvent(event) ? 1 : 0;
}
function getMouseEventOptions(event, init, clickCount = 0) {
var _init;
init = (_init = init) != null ? _init : {};
return { ...init,
// https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail
detail: event === 'mousedown' || event === 'mouseup' || event === 'click' ? 1 + clickCount : clickCount,
buttons: convertMouseButtons(event, init, 'buttons'),
button: convertMouseButtons(event, init, 'button')
};
}

View File

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

View File

@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isClickableInput = isClickableInput;
var _isElementType = require("../misc/isElementType");
const CLICKABLE_INPUT_TYPES = ['button', 'color', 'file', 'image', 'reset', 'submit', 'checkbox', 'radio'];
function isClickableInput(element) {
return (0, _isElementType.isElementType)(element, 'button') || (0, _isElementType.isElementType)(element, 'input') && CLICKABLE_INPUT_TYPES.includes(element.type);
}

View File

@@ -0,0 +1 @@
export declare function buildTimeValue(value: string): string;

View File

@@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.buildTimeValue = buildTimeValue;
function buildTimeValue(value) {
const onlyDigitsValue = value.replace(/\D/g, '');
if (onlyDigitsValue.length < 2) {
return value;
}
const firstDigit = parseInt(onlyDigitsValue[0], 10);
const secondDigit = parseInt(onlyDigitsValue[1], 10);
if (firstDigit >= 3 || firstDigit === 2 && secondDigit >= 4) {
let index;
if (firstDigit >= 3) {
index = 1;
} else {
index = 2;
}
return build(onlyDigitsValue, index);
}
if (value.length === 2) {
return value;
}
return build(onlyDigitsValue, 2);
}
function build(onlyDigitsValue, index) {
const hours = onlyDigitsValue.slice(0, index);
const validHours = Math.min(parseInt(hours, 10), 23);
const minuteCharacters = onlyDigitsValue.slice(index);
const parsedMinutes = parseInt(minuteCharacters, 10);
const validMinutes = Math.min(parsedMinutes, 59);
return `${validHours.toString().padStart(2, '0')}:${validMinutes.toString().padStart(2, '0')}`;
}

View File

@@ -0,0 +1,7 @@
export declare function calculateNewValue(newEntry: string, element: HTMLElement, value?: string, selectionRange?: {
selectionStart: number | null;
selectionEnd: number | null;
}, deleteContent?: 'backward' | 'forward'): {
newValue: string;
newSelectionStart: number;
};

View File

@@ -0,0 +1,48 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.calculateNewValue = calculateNewValue;
var _selectionRange = require("./selectionRange");
var _getValue2 = require("./getValue");
var _isValidDateValue = require("./isValidDateValue");
var _isValidInputTimeValue = require("./isValidInputTimeValue");
function calculateNewValue(newEntry, element, value = (() => {
var _getValue;
return (_getValue = (0, _getValue2.getValue)(element)) != null ? _getValue :
/* istanbul ignore next */
'';
})(), selectionRange = (0, _selectionRange.getSelectionRange)(element), deleteContent) {
const selectionStart = selectionRange.selectionStart === null ? value.length : selectionRange.selectionStart;
const selectionEnd = selectionRange.selectionEnd === null ? value.length : selectionRange.selectionEnd;
const prologEnd = Math.max(0, selectionStart === selectionEnd && deleteContent === 'backward' ? selectionStart - 1 : selectionStart);
const prolog = value.substring(0, prologEnd);
const epilogStart = Math.min(value.length, selectionStart === selectionEnd && deleteContent === 'forward' ? selectionEnd + 1 : selectionEnd);
const epilog = value.substring(epilogStart, value.length);
let newValue = `${prolog}${newEntry}${epilog}`;
const newSelectionStart = prologEnd + newEntry.length;
if (element.type === 'date' && !(0, _isValidDateValue.isValidDateValue)(element, newValue)) {
newValue = value;
}
if (element.type === 'time' && !(0, _isValidInputTimeValue.isValidInputTimeValue)(element, newValue)) {
if ((0, _isValidInputTimeValue.isValidInputTimeValue)(element, newEntry)) {
newValue = newEntry;
} else {
newValue = value;
}
}
return {
newValue,
newSelectionStart
};
}

View File

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

View File

@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isCursorAtEnd = isCursorAtEnd;
exports.isCursorAtStart = isCursorAtStart;
var _selectionRange = require("./selectionRange");
var _getValue2 = require("./getValue");
function isCursorAtEnd(element) {
var _getValue;
const {
selectionStart,
selectionEnd
} = (0, _selectionRange.getSelectionRange)(element);
return selectionStart === selectionEnd && (selectionStart != null ? selectionStart :
/* istanbul ignore next */
0) === ((_getValue = (0, _getValue2.getValue)(element)) != null ? _getValue :
/* istanbul ignore next */
'').length;
}
function isCursorAtStart(element) {
const {
selectionStart,
selectionEnd
} = (0, _selectionRange.getSelectionRange)(element);
return selectionStart === selectionEnd && (selectionStart != null ? selectionStart :
/* istanbul ignore next */
0) === 0;
}

View File

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

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getValue = getValue;
var _isContentEditable = require("./isContentEditable");
function getValue(element) {
// istanbul ignore if
if (!element) {
return null;
}
if ((0, _isContentEditable.isContentEditable)(element)) {
return element.textContent;
}
return element.value;
}

View File

@@ -0,0 +1,10 @@
declare enum unreliableValueInputTypes {
'number' = "number"
}
/**
* Check if an empty IDL value on the element could mean a derivation of displayed value and IDL value
*/
export declare function hasUnreliableEmptyValue(element: Element): element is HTMLInputElement & {
type: unreliableValueInputTypes;
};
export {};

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.hasUnreliableEmptyValue = hasUnreliableEmptyValue;
var _isElementType = require("../misc/isElementType");
var unreliableValueInputTypes;
/**
* Check if an empty IDL value on the element could mean a derivation of displayed value and IDL value
*/
(function (unreliableValueInputTypes) {
unreliableValueInputTypes["number"] = "number";
})(unreliableValueInputTypes || (unreliableValueInputTypes = {}));
function hasUnreliableEmptyValue(element) {
return (0, _isElementType.isElementType)(element, 'input') && Boolean(unreliableValueInputTypes[element.type]);
}

View File

@@ -0,0 +1,3 @@
export declare function isContentEditable(element: Element): element is HTMLElement & {
contenteditable: 'true';
};

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isContentEditable = isContentEditable;
//jsdom is not supporting isContentEditable
function isContentEditable(element) {
return element.hasAttribute('contenteditable') && (element.getAttribute('contenteditable') == 'true' || element.getAttribute('contenteditable') == '');
}

View File

@@ -0,0 +1,24 @@
import { isContentEditable } from './isContentEditable';
declare type GuardedType<T> = T extends (x: any) => x is infer R ? R : never;
export declare function isEditable(element: Element): element is GuardedType<typeof isContentEditable> | GuardedType<typeof isEditableInput> | (HTMLTextAreaElement & {
readOnly: false;
});
export declare enum editableInputTypes {
'text' = "text",
'date' = "date",
'datetime-local' = "datetime-local",
'email' = "email",
'month' = "month",
'number' = "number",
'password' = "password",
'search' = "search",
'tel' = "tel",
'time' = "time",
'url' = "url",
'week' = "week"
}
export declare function isEditableInput(element: Element): element is HTMLInputElement & {
readOnly: false;
type: editableInputTypes;
};
export {};

View File

@@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.editableInputTypes = void 0;
exports.isEditable = isEditable;
exports.isEditableInput = isEditableInput;
var _isElementType = require("../misc/isElementType");
var _isContentEditable = require("./isContentEditable");
function isEditable(element) {
return isEditableInput(element) || (0, _isElementType.isElementType)(element, 'textarea', {
readOnly: false
}) || (0, _isContentEditable.isContentEditable)(element);
}
let editableInputTypes;
exports.editableInputTypes = editableInputTypes;
(function (editableInputTypes) {
editableInputTypes["text"] = "text";
editableInputTypes["date"] = "date";
editableInputTypes["datetime-local"] = "datetime-local";
editableInputTypes["email"] = "email";
editableInputTypes["month"] = "month";
editableInputTypes["number"] = "number";
editableInputTypes["password"] = "password";
editableInputTypes["search"] = "search";
editableInputTypes["tel"] = "tel";
editableInputTypes["time"] = "time";
editableInputTypes["url"] = "url";
editableInputTypes["week"] = "week";
})(editableInputTypes || (exports.editableInputTypes = editableInputTypes = {}));
function isEditableInput(element) {
return (0, _isElementType.isElementType)(element, 'input', {
readOnly: false
}) && Boolean(editableInputTypes[element.type]);
}

View File

@@ -0,0 +1,3 @@
export declare function isValidDateValue(element: HTMLInputElement & {
type: 'date';
}, value: string): boolean;

View File

@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isValidDateValue = isValidDateValue;
function isValidDateValue(element, value) {
const clone = element.cloneNode();
clone.value = value;
return clone.value === value;
}

View File

@@ -0,0 +1,3 @@
export declare function isValidInputTimeValue(element: HTMLInputElement & {
type: 'time';
}, timeValue: string): boolean;

View File

@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isValidInputTimeValue = isValidInputTimeValue;
function isValidInputTimeValue(element, timeValue) {
const clone = element.cloneNode();
clone.value = timeValue;
return clone.value === timeValue;
}

View File

@@ -0,0 +1 @@
export declare function getSpaceUntilMaxLength(element: Element): number | undefined;

View File

@@ -0,0 +1,50 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getSpaceUntilMaxLength = getSpaceUntilMaxLength;
var _isElementType = require("../misc/isElementType");
var _getValue = require("./getValue");
var maxLengthSupportedTypes;
(function (maxLengthSupportedTypes) {
maxLengthSupportedTypes["email"] = "email";
maxLengthSupportedTypes["password"] = "password";
maxLengthSupportedTypes["search"] = "search";
maxLengthSupportedTypes["telephone"] = "telephone";
maxLengthSupportedTypes["text"] = "text";
maxLengthSupportedTypes["url"] = "url";
})(maxLengthSupportedTypes || (maxLengthSupportedTypes = {}));
function getSpaceUntilMaxLength(element) {
const value = (0, _getValue.getValue)(element);
/* istanbul ignore if */
if (value === null) {
return undefined;
}
const maxLength = getSanitizedMaxLength(element);
return maxLength ? maxLength - value.length : undefined;
} // can't use .maxLength property because of a jsdom bug:
// https://github.com/jsdom/jsdom/issues/2927
function getSanitizedMaxLength(element) {
var _element$getAttribute;
if (!supportsMaxLength(element)) {
return undefined;
}
const attr = (_element$getAttribute = element.getAttribute('maxlength')) != null ? _element$getAttribute : '';
return /^\d+$/.test(attr) && Number(attr) >= 0 ? Number(attr) : undefined;
}
function supportsMaxLength(element) {
return (0, _isElementType.isElementType)(element, 'textarea') || (0, _isElementType.isElementType)(element, 'input') && Boolean(maxLengthSupportedTypes[element.type]);
}

View File

@@ -0,0 +1,16 @@
declare enum selectionSupportType {
'text' = "text",
'search' = "search",
'url' = "url",
'tel' = "tel",
'password' = "password"
}
export declare function hasSelectionSupport(element: Element): element is HTMLTextAreaElement | (HTMLInputElement & {
type: selectionSupportType;
});
export declare function getSelectionRange(element: Element): {
selectionStart: number | null;
selectionEnd: number | null;
};
export declare function setSelectionRange(element: Element, newSelectionStart: number, newSelectionEnd: number): void;
export {};

View File

@@ -0,0 +1,104 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getSelectionRange = getSelectionRange;
exports.hasSelectionSupport = hasSelectionSupport;
exports.setSelectionRange = setSelectionRange;
var _isElementType = require("../misc/isElementType");
// https://github.com/jsdom/jsdom/blob/c2fb8ff94917a4d45e2398543f5dd2a8fed0bdab/lib/jsdom/living/nodes/HTMLInputElement-impl.js#L45
var selectionSupportType;
(function (selectionSupportType) {
selectionSupportType["text"] = "text";
selectionSupportType["search"] = "search";
selectionSupportType["url"] = "url";
selectionSupportType["tel"] = "tel";
selectionSupportType["password"] = "password";
})(selectionSupportType || (selectionSupportType = {}));
const InputSelection = Symbol('inputSelection');
function hasSelectionSupport(element) {
return (0, _isElementType.isElementType)(element, 'textarea') || (0, _isElementType.isElementType)(element, 'input') && Boolean(selectionSupportType[element.type]);
}
function getSelectionRange(element) {
if (hasSelectionSupport(element)) {
return {
selectionStart: element.selectionStart,
selectionEnd: element.selectionEnd
};
}
if ((0, _isElementType.isElementType)(element, 'input')) {
var _InputSelection;
return (_InputSelection = element[InputSelection]) != null ? _InputSelection : {
selectionStart: null,
selectionEnd: null
};
}
const selection = element.ownerDocument.getSelection(); // there should be no editing if the focusNode is outside of element
// TODO: properly handle selection ranges
if (selection != null && selection.rangeCount && element.contains(selection.focusNode)) {
const range = selection.getRangeAt(0);
return {
selectionStart: range.startOffset,
selectionEnd: range.endOffset
};
} else {
return {
selectionStart: null,
selectionEnd: null
};
}
}
function setSelectionRange(element, newSelectionStart, newSelectionEnd) {
const {
selectionStart,
selectionEnd
} = getSelectionRange(element);
if (selectionStart === newSelectionStart && selectionEnd === newSelectionEnd) {
return;
}
if (hasSelectionSupport(element)) {
element.setSelectionRange(newSelectionStart, newSelectionEnd);
}
if ((0, _isElementType.isElementType)(element, 'input')) {
;
element[InputSelection] = {
selectionStart: newSelectionStart,
selectionEnd: newSelectionEnd
};
} // Moving the selection inside <input> or <textarea> does not alter the document Selection.
if ((0, _isElementType.isElementType)(element, 'input') || (0, _isElementType.isElementType)(element, 'textarea')) {
return;
}
const range = element.ownerDocument.createRange();
range.selectNodeContents(element); // istanbul ignore else
if (element.firstChild) {
range.setStart(element.firstChild, newSelectionStart);
range.setEnd(element.firstChild, newSelectionEnd);
}
const selection = element.ownerDocument.getSelection(); // istanbul ignore else
if (selection) {
selection.removeAllRanges();
selection.addRange(range);
}
}

View File

@@ -0,0 +1 @@
export declare function getActiveElement(document: Document | ShadowRoot): Element | null;

View File

@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getActiveElement = getActiveElement;
var _isDisabled = require("../misc/isDisabled");
function getActiveElement(document) {
const activeElement = document.activeElement;
if (activeElement != null && activeElement.shadowRoot) {
return getActiveElement(activeElement.shadowRoot);
} else {
// Browser does not yield disabled elements as document.activeElement - jsdom does
if ((0, _isDisabled.isDisabled)(activeElement)) {
return document.ownerDocument ? // TODO: verify behavior in ShadowRoot
/* istanbul ignore next */
document.ownerDocument.body : document.body;
}
return activeElement;
}
}

View File

@@ -0,0 +1 @@
export declare function isFocusable(element: Element): element is HTMLElement;

View File

@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isFocusable = isFocusable;
var _isLabelWithInternallyDisabledControl = require("../misc/isLabelWithInternallyDisabledControl");
var _selector = require("./selector");
function isFocusable(element) {
return !(0, _isLabelWithInternallyDisabledControl.isLabelWithInternallyDisabledControl)(element) && element.matches(_selector.FOCUSABLE_SELECTOR);
}

View File

@@ -0,0 +1 @@
export declare const FOCUSABLE_SELECTOR: string;

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.FOCUSABLE_SELECTOR = void 0;
const FOCUSABLE_SELECTOR = ['input:not([type=hidden]):not([disabled])', 'button:not([disabled])', 'select:not([disabled])', 'textarea:not([disabled])', '[contenteditable=""]', '[contenteditable="true"]', 'a[href]', '[tabindex]:not([disabled])'].join(', ');
exports.FOCUSABLE_SELECTOR = FOCUSABLE_SELECTOR;

View File

@@ -0,0 +1,25 @@
export * from './click/getMouseEventOptions';
export * from './click/isClickableInput';
export * from './edit/buildTimeValue';
export * from './edit/calculateNewValue';
export * from './edit/cursorPosition';
export * from './edit/getValue';
export * from './edit/hasUnreliableEmptyValue';
export * from './edit/isContentEditable';
export * from './edit/isEditable';
export * from './edit/isValidDateValue';
export * from './edit/isValidInputTimeValue';
export * from './edit/maxLength';
export * from './edit/selectionRange';
export * from './focus/getActiveElement';
export * from './focus/isFocusable';
export * from './focus/selector';
export * from './misc/eventWrapper';
export * from './misc/isElementType';
export * from './misc/isLabelWithInternallyDisabledControl';
export * from './misc/isVisible';
export * from './misc/isDisabled';
export * from './misc/isDocument';
export * from './misc/wait';
export * from './misc/hasPointerEvents';
export * from './misc/hasFormSubmit';

View File

@@ -0,0 +1,330 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _getMouseEventOptions = require("./click/getMouseEventOptions");
Object.keys(_getMouseEventOptions).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _getMouseEventOptions[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _getMouseEventOptions[key];
}
});
});
var _isClickableInput = require("./click/isClickableInput");
Object.keys(_isClickableInput).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _isClickableInput[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _isClickableInput[key];
}
});
});
var _buildTimeValue = require("./edit/buildTimeValue");
Object.keys(_buildTimeValue).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _buildTimeValue[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _buildTimeValue[key];
}
});
});
var _calculateNewValue = require("./edit/calculateNewValue");
Object.keys(_calculateNewValue).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _calculateNewValue[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _calculateNewValue[key];
}
});
});
var _cursorPosition = require("./edit/cursorPosition");
Object.keys(_cursorPosition).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _cursorPosition[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _cursorPosition[key];
}
});
});
var _getValue = require("./edit/getValue");
Object.keys(_getValue).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _getValue[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _getValue[key];
}
});
});
var _hasUnreliableEmptyValue = require("./edit/hasUnreliableEmptyValue");
Object.keys(_hasUnreliableEmptyValue).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _hasUnreliableEmptyValue[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _hasUnreliableEmptyValue[key];
}
});
});
var _isContentEditable = require("./edit/isContentEditable");
Object.keys(_isContentEditable).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _isContentEditable[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _isContentEditable[key];
}
});
});
var _isEditable = require("./edit/isEditable");
Object.keys(_isEditable).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _isEditable[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _isEditable[key];
}
});
});
var _isValidDateValue = require("./edit/isValidDateValue");
Object.keys(_isValidDateValue).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _isValidDateValue[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _isValidDateValue[key];
}
});
});
var _isValidInputTimeValue = require("./edit/isValidInputTimeValue");
Object.keys(_isValidInputTimeValue).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _isValidInputTimeValue[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _isValidInputTimeValue[key];
}
});
});
var _maxLength = require("./edit/maxLength");
Object.keys(_maxLength).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _maxLength[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _maxLength[key];
}
});
});
var _selectionRange = require("./edit/selectionRange");
Object.keys(_selectionRange).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _selectionRange[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _selectionRange[key];
}
});
});
var _getActiveElement = require("./focus/getActiveElement");
Object.keys(_getActiveElement).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _getActiveElement[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _getActiveElement[key];
}
});
});
var _isFocusable = require("./focus/isFocusable");
Object.keys(_isFocusable).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _isFocusable[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _isFocusable[key];
}
});
});
var _selector = require("./focus/selector");
Object.keys(_selector).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _selector[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _selector[key];
}
});
});
var _eventWrapper = require("./misc/eventWrapper");
Object.keys(_eventWrapper).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _eventWrapper[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _eventWrapper[key];
}
});
});
var _isElementType = require("./misc/isElementType");
Object.keys(_isElementType).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _isElementType[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _isElementType[key];
}
});
});
var _isLabelWithInternallyDisabledControl = require("./misc/isLabelWithInternallyDisabledControl");
Object.keys(_isLabelWithInternallyDisabledControl).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _isLabelWithInternallyDisabledControl[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _isLabelWithInternallyDisabledControl[key];
}
});
});
var _isVisible = require("./misc/isVisible");
Object.keys(_isVisible).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _isVisible[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _isVisible[key];
}
});
});
var _isDisabled = require("./misc/isDisabled");
Object.keys(_isDisabled).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _isDisabled[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _isDisabled[key];
}
});
});
var _isDocument = require("./misc/isDocument");
Object.keys(_isDocument).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _isDocument[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _isDocument[key];
}
});
});
var _wait = require("./misc/wait");
Object.keys(_wait).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _wait[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _wait[key];
}
});
});
var _hasPointerEvents = require("./misc/hasPointerEvents");
Object.keys(_hasPointerEvents).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _hasPointerEvents[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _hasPointerEvents[key];
}
});
});
var _hasFormSubmit = require("./misc/hasFormSubmit");
Object.keys(_hasFormSubmit).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _hasFormSubmit[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _hasFormSubmit[key];
}
});
});

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));
}