Version 1.0.2 mit node_modules Verzeichnis

This commit is contained in:
ISA
2024-10-02 07:58:24 +02:00
parent f353a06b1b
commit 62b6e55a0a
68228 changed files with 4548477 additions and 651 deletions

View File

@@ -0,0 +1,37 @@
'use strict';
require('../event/behavior/click.js');
require('../event/behavior/cut.js');
require('../event/behavior/keydown.js');
require('../event/behavior/keypress.js');
require('../event/behavior/keyup.js');
require('../event/behavior/paste.js');
require('@testing-library/dom');
require('../utils/click/isClickableInput.js');
require('../utils/dataTransfer/Clipboard.js');
var isEditable = require('../utils/edit/isEditable.js');
require('../utils/edit/maxLength.js');
var isDisabled = require('../utils/misc/isDisabled.js');
require('../utils/keyDef/readNextDescriptor.js');
require('../utils/misc/level.js');
require('../options.js');
var focus = require('../event/focus.js');
var input = require('../event/input.js');
var selectAll = require('../event/selection/selectAll.js');
async function clear(element) {
if (!isEditable.isEditable(element) || isDisabled.isDisabled(element)) {
throw new Error('clear()` is only supported on editable elements.');
}
focus.focusElement(element);
if (element.ownerDocument.activeElement !== element) {
throw new Error('The element to be cleared could not be focused.');
}
selectAll.selectAll(element);
if (!selectAll.isAllSelected(element)) {
throw new Error('The element content to be cleared could not be selected.');
}
input.input(this, element, '', 'deleteContentBackward');
}
exports.clear = clear;

View File

@@ -0,0 +1,14 @@
'use strict';
var clear = require('./clear.js');
var selectOptions = require('./selectOptions.js');
var type = require('./type.js');
var upload = require('./upload.js');
exports.clear = clear.clear;
exports.deselectOptions = selectOptions.deselectOptions;
exports.selectOptions = selectOptions.selectOptions;
exports.type = type.type;
exports.upload = upload.upload;

View File

@@ -0,0 +1,119 @@
'use strict';
var dom = require('@testing-library/dom');
require('../utils/click/isClickableInput.js');
require('../utils/dataTransfer/Clipboard.js');
require('../utils/edit/isEditable.js');
require('../utils/edit/maxLength.js');
var isElementType = require('../utils/misc/isElementType.js');
var isDisabled = require('../utils/misc/isDisabled.js');
require('../utils/keyDef/readNextDescriptor.js');
require('../utils/misc/level.js');
var wait = require('../utils/misc/wait.js');
var cssPointerEvents = require('../utils/pointer/cssPointerEvents.js');
require('../event/behavior/click.js');
require('../event/behavior/cut.js');
require('../event/behavior/keydown.js');
require('../event/behavior/keypress.js');
require('../event/behavior/keyup.js');
require('../event/behavior/paste.js');
var focus = require('../event/focus.js');
async function selectOptions(select, values) {
return selectOptionsBase.call(this, true, select, values);
}
async function deselectOptions(select, values) {
return selectOptionsBase.call(this, false, select, values);
}
async function selectOptionsBase(newValue, select, values) {
if (!newValue && !select.multiple) {
throw dom.getConfig().getElementError(`Unable to deselect an option in a non-multiple select. Use selectOptions to change the selection instead.`, select);
}
const valArray = Array.isArray(values) ? values : [
values
];
const allOptions = Array.from(select.querySelectorAll('option, [role="option"]'));
const selectedOptions = valArray.map((val)=>{
if (typeof val !== 'string' && allOptions.includes(val)) {
return val;
} else {
const matchingOption = allOptions.find((o)=>o.value === val || o.innerHTML === val);
if (matchingOption) {
return matchingOption;
} else {
throw dom.getConfig().getElementError(`Value "${String(val)}" not found in options`, select);
}
}
}).filter((option)=>!isDisabled.isDisabled(option));
if (isDisabled.isDisabled(select) || !selectedOptions.length) return;
const selectOption = (option)=>{
option.selected = newValue;
this.dispatchUIEvent(select, 'input', {
bubbles: true,
cancelable: false,
composed: true
});
this.dispatchUIEvent(select, 'change');
};
if (isElementType.isElementType(select, 'select')) {
if (select.multiple) {
for (const option of selectedOptions){
const withPointerEvents = this.config.pointerEventsCheck === 0 ? true : cssPointerEvents.hasPointerEvents(this, option);
// events fired for multiple select are weird. Can't use hover...
if (withPointerEvents) {
this.dispatchUIEvent(option, 'pointerover');
this.dispatchUIEvent(select, 'pointerenter');
this.dispatchUIEvent(option, 'mouseover');
this.dispatchUIEvent(select, 'mouseenter');
this.dispatchUIEvent(option, 'pointermove');
this.dispatchUIEvent(option, 'mousemove');
this.dispatchUIEvent(option, 'pointerdown');
this.dispatchUIEvent(option, 'mousedown');
}
focus.focusElement(select);
if (withPointerEvents) {
this.dispatchUIEvent(option, 'pointerup');
this.dispatchUIEvent(option, 'mouseup');
}
selectOption(option);
if (withPointerEvents) {
this.dispatchUIEvent(option, 'click');
}
await wait.wait(this.config);
}
} else if (selectedOptions.length === 1) {
const withPointerEvents = this.config.pointerEventsCheck === 0 ? true : cssPointerEvents.hasPointerEvents(this, select);
// the click to open the select options
if (withPointerEvents) {
await this.click(select);
} else {
focus.focusElement(select);
}
selectOption(selectedOptions[0]);
if (withPointerEvents) {
// the browser triggers another click event on the select for the click on the option
// this second click has no 'down' phase
this.dispatchUIEvent(select, 'pointerover');
this.dispatchUIEvent(select, 'pointerenter');
this.dispatchUIEvent(select, 'mouseover');
this.dispatchUIEvent(select, 'mouseenter');
this.dispatchUIEvent(select, 'pointerup');
this.dispatchUIEvent(select, 'mouseup');
this.dispatchUIEvent(select, 'click');
}
await wait.wait(this.config);
} else {
throw dom.getConfig().getElementError(`Cannot select multiple options on a non-multiple select`, select);
}
} else if (select.getAttribute('role') === 'listbox') {
for (const option of selectedOptions){
await this.click(option);
await this.unhover(option);
}
} else {
throw dom.getConfig().getElementError(`Cannot select options on elements that are neither select nor listbox elements`, select);
}
}
exports.deselectOptions = deselectOptions;
exports.selectOptions = selectOptions;

View File

@@ -0,0 +1,29 @@
'use strict';
var index = require('../keyboard/index.js');
require('../utils/click/isClickableInput.js');
require('../utils/dataTransfer/Clipboard.js');
require('../utils/edit/isEditable.js');
require('../utils/edit/maxLength.js');
require('../utils/keyDef/readNextDescriptor.js');
require('../utils/misc/level.js');
require('../options.js');
var setSelectionRange = require('../event/selection/setSelectionRange.js');
async function type(element, text, { skipClick = this.config.skipClick, skipAutoClose = this.config.skipAutoClose, initialSelectionStart, initialSelectionEnd } = {}) {
// TODO: properly type guard
// we use this workaround for now to prevent changing behavior
if (element.disabled) return;
if (!skipClick) {
await this.click(element);
}
if (initialSelectionStart !== undefined) {
setSelectionRange.setSelectionRange(element, initialSelectionStart, initialSelectionEnd !== null && initialSelectionEnd !== void 0 ? initialSelectionEnd : initialSelectionStart);
}
await this.keyboard(text);
if (!skipAutoClose) {
await index.releaseAllKeys(this);
}
}
exports.type = type;

View File

@@ -0,0 +1,64 @@
'use strict';
require('../utils/click/isClickableInput.js');
var FileList = require('../utils/dataTransfer/FileList.js');
require('../utils/dataTransfer/Clipboard.js');
require('../utils/edit/isEditable.js');
require('../utils/edit/maxLength.js');
var setFiles = require('../utils/edit/setFiles.js');
var isElementType = require('../utils/misc/isElementType.js');
var isDisabled = require('../utils/misc/isDisabled.js');
var getWindow = require('../utils/misc/getWindow.js');
require('../utils/keyDef/readNextDescriptor.js');
require('../utils/misc/level.js');
require('../options.js');
async function upload(element, fileOrFiles) {
const input = isElementType.isElementType(element, 'label') ? element.control : element;
if (!input || !isElementType.isElementType(input, 'input', {
type: 'file'
})) {
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input === void 0 ? void 0 : input.tagName} element does not accept file uploads`);
}
if (isDisabled.isDisabled(element)) return;
const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [
fileOrFiles
]).filter((file)=>!this.config.applyAccept || isAcceptableFile(file, input.accept)).slice(0, input.multiple ? undefined : 1);
const fileDialog = ()=>{
var _input_files;
// do not fire an input event if the file selection does not change
if (files.length === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.length) && files.every((f, i)=>{
var _input_files;
return f === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.item(i));
})) {
return;
}
setFiles.setFiles(input, FileList.createFileList(getWindow.getWindow(element), files));
this.dispatchUIEvent(input, 'input');
this.dispatchUIEvent(input, 'change');
};
input.addEventListener('fileDialog', fileDialog);
await this.click(element);
input.removeEventListener('fileDialog', fileDialog);
}
function isAcceptableFile(file, accept) {
if (!accept) {
return true;
}
const wildcards = [
'audio/*',
'image/*',
'video/*'
];
return accept.split(',').some((acceptToken)=>{
if (acceptToken.startsWith('.')) {
// tokens starting with a dot represent a file extension
return file.name.endsWith(acceptToken);
} else if (wildcards.includes(acceptToken)) {
return file.type.startsWith(acceptToken.substr(0, acceptToken.length - 1));
}
return file.type === acceptToken;
});
}
exports.upload = upload;