Set up comprehensive frontend testing infrastructure
- Install Jest for unit testing with React Testing Library - Install Playwright for end-to-end testing - Configure Jest with proper TypeScript support and module mapping - Create test setup files and utilities for both unit and e2e tests Components: * Jest configuration with coverage thresholds * Playwright configuration with browser automation * Unit tests for LoginForm, AuthContext, and useSocketIO hook * E2E tests for authentication, dashboard, and agents workflows * GitHub Actions workflow for automated testing * Mock data and API utilities for consistent testing * Test documentation with best practices Testing features: - Unit tests with 70% coverage threshold - E2E tests with API mocking and user journey testing - CI/CD integration for automated test runs - Cross-browser testing support with Playwright - Authentication system testing end-to-end 🚀 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
32
frontend/node_modules/@testing-library/user-event/dist/cjs/event/behavior/click.js
generated
vendored
Normal file
32
frontend/node_modules/@testing-library/user-event/dist/cjs/event/behavior/click.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
var isElementType = require('../../utils/misc/isElementType.js');
|
||||
require('../../utils/dataTransfer/Clipboard.js');
|
||||
var getWindow = require('../../utils/misc/getWindow.js');
|
||||
var isFocusable = require('../../utils/focus/isFocusable.js');
|
||||
var cloneEvent = require('../../utils/misc/cloneEvent.js');
|
||||
var focus = require('../focus.js');
|
||||
var registry = require('./registry.js');
|
||||
|
||||
registry.behavior.click = (event, target, instance)=>{
|
||||
const context = target.closest('button,input,label,select,textarea');
|
||||
const control = context && isElementType.isElementType(context, 'label') && context.control;
|
||||
if (control && control !== target) {
|
||||
return ()=>{
|
||||
if (isFocusable.isFocusable(control)) {
|
||||
focus.focusElement(control);
|
||||
instance.dispatchEvent(control, cloneEvent.cloneEvent(event));
|
||||
}
|
||||
};
|
||||
} else if (isElementType.isElementType(target, 'input', {
|
||||
type: 'file'
|
||||
})) {
|
||||
return ()=>{
|
||||
// blur fires when the file selector pops up
|
||||
focus.blurElement(target);
|
||||
target.dispatchEvent(new (getWindow.getWindow(target)).Event('fileDialog'));
|
||||
// focus fires after the file selector has been closed
|
||||
focus.focusElement(target);
|
||||
};
|
||||
}
|
||||
};
|
||||
14
frontend/node_modules/@testing-library/user-event/dist/cjs/event/behavior/cut.js
generated
vendored
Normal file
14
frontend/node_modules/@testing-library/user-event/dist/cjs/event/behavior/cut.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
require('../../utils/dataTransfer/Clipboard.js');
|
||||
var isEditable = require('../../utils/edit/isEditable.js');
|
||||
var input = require('../input.js');
|
||||
var registry = require('./registry.js');
|
||||
|
||||
registry.behavior.cut = (event, target, instance)=>{
|
||||
return ()=>{
|
||||
if (isEditable.isEditable(target)) {
|
||||
input.input(instance, target, '', 'deleteByCut');
|
||||
}
|
||||
};
|
||||
};
|
||||
13
frontend/node_modules/@testing-library/user-event/dist/cjs/event/behavior/index.js
generated
vendored
Normal file
13
frontend/node_modules/@testing-library/user-event/dist/cjs/event/behavior/index.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
require('./click.js');
|
||||
require('./cut.js');
|
||||
require('./keydown.js');
|
||||
require('./keypress.js');
|
||||
require('./keyup.js');
|
||||
require('./paste.js');
|
||||
var registry = require('./registry.js');
|
||||
|
||||
|
||||
|
||||
exports.behavior = registry.behavior;
|
||||
128
frontend/node_modules/@testing-library/user-event/dist/cjs/event/behavior/keydown.js
generated
vendored
Normal file
128
frontend/node_modules/@testing-library/user-event/dist/cjs/event/behavior/keydown.js
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
'use strict';
|
||||
|
||||
var UI = require('../../document/UI.js');
|
||||
var getValueOrTextContent = require('../../document/getValueOrTextContent.js');
|
||||
var isElementType = require('../../utils/misc/isElementType.js');
|
||||
require('../../utils/dataTransfer/Clipboard.js');
|
||||
var isContentEditable = require('../../utils/edit/isContentEditable.js');
|
||||
var isEditable = require('../../utils/edit/isEditable.js');
|
||||
var getTabDestination = require('../../utils/focus/getTabDestination.js');
|
||||
var selection = require('../../utils/focus/selection.js');
|
||||
var focus = require('../focus.js');
|
||||
var input = require('../input.js');
|
||||
var moveSelection = require('../selection/moveSelection.js');
|
||||
var selectAll = require('../selection/selectAll.js');
|
||||
var setSelectionRange = require('../selection/setSelectionRange.js');
|
||||
var radio = require('../radio.js');
|
||||
var registry = require('./registry.js');
|
||||
|
||||
registry.behavior.keydown = (event, target, instance)=>{
|
||||
var _keydownBehavior_event_key;
|
||||
var _keydownBehavior_event_key1;
|
||||
return (_keydownBehavior_event_key1 = (_keydownBehavior_event_key = keydownBehavior[event.key]) === null || _keydownBehavior_event_key === undefined ? undefined : _keydownBehavior_event_key.call(keydownBehavior, event, target, instance)) !== null && _keydownBehavior_event_key1 !== undefined ? _keydownBehavior_event_key1 : combinationBehavior(event, target, instance);
|
||||
};
|
||||
const keydownBehavior = {
|
||||
ArrowDown: (event, target, instance)=>{
|
||||
/* istanbul ignore else */ if (isElementType.isElementType(target, 'input', {
|
||||
type: 'radio'
|
||||
})) {
|
||||
return ()=>radio.walkRadio(instance, target, 1);
|
||||
}
|
||||
},
|
||||
ArrowLeft: (event, target, instance)=>{
|
||||
if (isElementType.isElementType(target, 'input', {
|
||||
type: 'radio'
|
||||
})) {
|
||||
return ()=>radio.walkRadio(instance, target, -1);
|
||||
}
|
||||
return ()=>moveSelection.moveSelection(target, -1);
|
||||
},
|
||||
ArrowRight: (event, target, instance)=>{
|
||||
if (isElementType.isElementType(target, 'input', {
|
||||
type: 'radio'
|
||||
})) {
|
||||
return ()=>radio.walkRadio(instance, target, 1);
|
||||
}
|
||||
return ()=>moveSelection.moveSelection(target, 1);
|
||||
},
|
||||
ArrowUp: (event, target, instance)=>{
|
||||
/* istanbul ignore else */ if (isElementType.isElementType(target, 'input', {
|
||||
type: 'radio'
|
||||
})) {
|
||||
return ()=>radio.walkRadio(instance, target, -1);
|
||||
}
|
||||
},
|
||||
Backspace: (event, target, instance)=>{
|
||||
if (isEditable.isEditable(target)) {
|
||||
return ()=>{
|
||||
input.input(instance, target, '', 'deleteContentBackward');
|
||||
};
|
||||
}
|
||||
},
|
||||
Delete: (event, target, instance)=>{
|
||||
if (isEditable.isEditable(target)) {
|
||||
return ()=>{
|
||||
input.input(instance, target, '', 'deleteContentForward');
|
||||
};
|
||||
}
|
||||
},
|
||||
End: (event, target)=>{
|
||||
if (isElementType.isElementType(target, [
|
||||
'input',
|
||||
'textarea'
|
||||
]) || isContentEditable.isContentEditable(target)) {
|
||||
return ()=>{
|
||||
var _getValueOrTextContent;
|
||||
var _getValueOrTextContent_length;
|
||||
const newPos = (_getValueOrTextContent_length = (_getValueOrTextContent = getValueOrTextContent.getValueOrTextContent(target)) === null || _getValueOrTextContent === undefined ? undefined : _getValueOrTextContent.length) !== null && _getValueOrTextContent_length !== undefined ? _getValueOrTextContent_length : /* istanbul ignore next */ 0;
|
||||
setSelectionRange.setSelectionRange(target, newPos, newPos);
|
||||
};
|
||||
}
|
||||
},
|
||||
Home: (event, target)=>{
|
||||
if (isElementType.isElementType(target, [
|
||||
'input',
|
||||
'textarea'
|
||||
]) || isContentEditable.isContentEditable(target)) {
|
||||
return ()=>{
|
||||
setSelectionRange.setSelectionRange(target, 0, 0);
|
||||
};
|
||||
}
|
||||
},
|
||||
PageDown: (event, target)=>{
|
||||
if (isElementType.isElementType(target, [
|
||||
'input'
|
||||
])) {
|
||||
return ()=>{
|
||||
const newPos = UI.getUIValue(target).length;
|
||||
setSelectionRange.setSelectionRange(target, newPos, newPos);
|
||||
};
|
||||
}
|
||||
},
|
||||
PageUp: (event, target)=>{
|
||||
if (isElementType.isElementType(target, [
|
||||
'input'
|
||||
])) {
|
||||
return ()=>{
|
||||
setSelectionRange.setSelectionRange(target, 0, 0);
|
||||
};
|
||||
}
|
||||
},
|
||||
Tab: (event, target, instance)=>{
|
||||
return ()=>{
|
||||
const dest = getTabDestination.getTabDestination(target, instance.system.keyboard.modifiers.Shift);
|
||||
focus.focusElement(dest);
|
||||
if (selection.hasOwnSelection(dest)) {
|
||||
UI.setUISelection(dest, {
|
||||
anchorOffset: 0,
|
||||
focusOffset: dest.value.length
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
const combinationBehavior = (event, target, instance)=>{
|
||||
if (event.code === 'KeyA' && instance.system.keyboard.modifiers.Control) {
|
||||
return ()=>selectAll.selectAll(target);
|
||||
}
|
||||
};
|
||||
51
frontend/node_modules/@testing-library/user-event/dist/cjs/event/behavior/keypress.js
generated
vendored
Normal file
51
frontend/node_modules/@testing-library/user-event/dist/cjs/event/behavior/keypress.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
'use strict';
|
||||
|
||||
var isElementType = require('../../utils/misc/isElementType.js');
|
||||
require('../../utils/dataTransfer/Clipboard.js');
|
||||
var isContentEditable = require('../../utils/edit/isContentEditable.js');
|
||||
var isEditable = require('../../utils/edit/isEditable.js');
|
||||
var input = require('../input.js');
|
||||
var registry = require('./registry.js');
|
||||
|
||||
registry.behavior.keypress = (event, target, instance)=>{
|
||||
if (event.key === 'Enter') {
|
||||
if (isElementType.isElementType(target, 'button') || isElementType.isElementType(target, 'input') && ClickInputOnEnter.includes(target.type) || isElementType.isElementType(target, 'a') && Boolean(target.href)) {
|
||||
return ()=>{
|
||||
instance.dispatchUIEvent(target, 'click');
|
||||
};
|
||||
} else if (isElementType.isElementType(target, 'input')) {
|
||||
const form = target.form;
|
||||
const submit = form === null || form === undefined ? undefined : form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]');
|
||||
if (submit) {
|
||||
return ()=>instance.dispatchUIEvent(submit, 'click');
|
||||
} else if (form && SubmitSingleInputOnEnter.includes(target.type) && form.querySelectorAll('input').length === 1) {
|
||||
return ()=>instance.dispatchUIEvent(form, 'submit');
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isEditable.isEditable(target)) {
|
||||
const inputType = event.key === 'Enter' ? isContentEditable.isContentEditable(target) && !instance.system.keyboard.modifiers.Shift ? 'insertParagraph' : 'insertLineBreak' : 'insertText';
|
||||
const inputData = event.key === 'Enter' ? '\n' : event.key;
|
||||
return ()=>input.input(instance, target, inputData, inputType);
|
||||
}
|
||||
};
|
||||
const ClickInputOnEnter = [
|
||||
'button',
|
||||
'color',
|
||||
'file',
|
||||
'image',
|
||||
'reset',
|
||||
'submit'
|
||||
];
|
||||
const SubmitSingleInputOnEnter = [
|
||||
'email',
|
||||
'month',
|
||||
'password',
|
||||
'search',
|
||||
'tel',
|
||||
'text',
|
||||
'url',
|
||||
'week'
|
||||
];
|
||||
17
frontend/node_modules/@testing-library/user-event/dist/cjs/event/behavior/keyup.js
generated
vendored
Normal file
17
frontend/node_modules/@testing-library/user-event/dist/cjs/event/behavior/keyup.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
var isClickableInput = require('../../utils/click/isClickableInput.js');
|
||||
require('../../utils/dataTransfer/Clipboard.js');
|
||||
var registry = require('./registry.js');
|
||||
|
||||
registry.behavior.keyup = (event, target, instance)=>{
|
||||
var _keyupBehavior_event_key;
|
||||
return (_keyupBehavior_event_key = keyupBehavior[event.key]) === null || _keyupBehavior_event_key === undefined ? undefined : _keyupBehavior_event_key.call(keyupBehavior, event, target, instance);
|
||||
};
|
||||
const keyupBehavior = {
|
||||
' ': (event, target, instance)=>{
|
||||
if (isClickableInput.isClickableInput(target)) {
|
||||
return ()=>instance.dispatchUIEvent(target, 'click');
|
||||
}
|
||||
}
|
||||
};
|
||||
18
frontend/node_modules/@testing-library/user-event/dist/cjs/event/behavior/paste.js
generated
vendored
Normal file
18
frontend/node_modules/@testing-library/user-event/dist/cjs/event/behavior/paste.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
require('../../utils/dataTransfer/Clipboard.js');
|
||||
var isEditable = require('../../utils/edit/isEditable.js');
|
||||
var input = require('../input.js');
|
||||
var registry = require('./registry.js');
|
||||
|
||||
registry.behavior.paste = (event, target, instance)=>{
|
||||
if (isEditable.isEditable(target)) {
|
||||
return ()=>{
|
||||
var _event_clipboardData;
|
||||
const insertData = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === undefined ? undefined : _event_clipboardData.getData('text');
|
||||
if (insertData) {
|
||||
input.input(instance, target, insertData, 'insertFromPaste');
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
5
frontend/node_modules/@testing-library/user-event/dist/cjs/event/behavior/registry.js
generated
vendored
Normal file
5
frontend/node_modules/@testing-library/user-event/dist/cjs/event/behavior/registry.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
const behavior = {};
|
||||
|
||||
exports.behavior = behavior;
|
||||
207
frontend/node_modules/@testing-library/user-event/dist/cjs/event/createEvent.js
generated
vendored
Normal file
207
frontend/node_modules/@testing-library/user-event/dist/cjs/event/createEvent.js
generated
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
'use strict';
|
||||
|
||||
require('../utils/dataTransfer/Clipboard.js');
|
||||
var getWindow = require('../utils/misc/getWindow.js');
|
||||
var eventMap = require('./eventMap.js');
|
||||
|
||||
const eventInitializer = {
|
||||
ClipboardEvent: [
|
||||
initClipboardEvent
|
||||
],
|
||||
Event: [],
|
||||
FocusEvent: [
|
||||
initUIEvent,
|
||||
initFocusEvent
|
||||
],
|
||||
InputEvent: [
|
||||
initUIEvent,
|
||||
initInputEvent
|
||||
],
|
||||
MouseEvent: [
|
||||
initUIEvent,
|
||||
initUIEventModifiers,
|
||||
initMouseEvent
|
||||
],
|
||||
PointerEvent: [
|
||||
initUIEvent,
|
||||
initUIEventModifiers,
|
||||
initMouseEvent,
|
||||
initPointerEvent
|
||||
],
|
||||
KeyboardEvent: [
|
||||
initUIEvent,
|
||||
initUIEventModifiers,
|
||||
initKeyboardEvent
|
||||
]
|
||||
};
|
||||
function createEvent(type, target, init) {
|
||||
const window = getWindow.getWindow(target);
|
||||
const { EventType, defaultInit } = eventMap.eventMap[type];
|
||||
const event = new (getEventConstructors(window))[EventType](type, defaultInit);
|
||||
eventInitializer[EventType].forEach((f)=>f(event, init !== null && init !== undefined ? init : {}));
|
||||
return event;
|
||||
}
|
||||
/* istanbul ignore next */ function getEventConstructors(window) {
|
||||
var _window_Event;
|
||||
/* eslint-disable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ const Event = (_window_Event = window.Event) !== null && _window_Event !== undefined ? _window_Event : class Event {
|
||||
};
|
||||
var _window_AnimationEvent;
|
||||
const AnimationEvent = (_window_AnimationEvent = window.AnimationEvent) !== null && _window_AnimationEvent !== undefined ? _window_AnimationEvent : class AnimationEvent extends Event {
|
||||
};
|
||||
var _window_ClipboardEvent;
|
||||
const ClipboardEvent = (_window_ClipboardEvent = window.ClipboardEvent) !== null && _window_ClipboardEvent !== undefined ? _window_ClipboardEvent : class ClipboardEvent extends Event {
|
||||
};
|
||||
var _window_PopStateEvent;
|
||||
const PopStateEvent = (_window_PopStateEvent = window.PopStateEvent) !== null && _window_PopStateEvent !== undefined ? _window_PopStateEvent : class PopStateEvent extends Event {
|
||||
};
|
||||
var _window_ProgressEvent;
|
||||
const ProgressEvent = (_window_ProgressEvent = window.ProgressEvent) !== null && _window_ProgressEvent !== undefined ? _window_ProgressEvent : class ProgressEvent extends Event {
|
||||
};
|
||||
var _window_TransitionEvent;
|
||||
const TransitionEvent = (_window_TransitionEvent = window.TransitionEvent) !== null && _window_TransitionEvent !== undefined ? _window_TransitionEvent : class TransitionEvent extends Event {
|
||||
};
|
||||
var _window_UIEvent;
|
||||
const UIEvent = (_window_UIEvent = window.UIEvent) !== null && _window_UIEvent !== undefined ? _window_UIEvent : class UIEvent extends Event {
|
||||
};
|
||||
var _window_CompositionEvent;
|
||||
const CompositionEvent = (_window_CompositionEvent = window.CompositionEvent) !== null && _window_CompositionEvent !== undefined ? _window_CompositionEvent : class CompositionEvent extends UIEvent {
|
||||
};
|
||||
var _window_FocusEvent;
|
||||
const FocusEvent = (_window_FocusEvent = window.FocusEvent) !== null && _window_FocusEvent !== undefined ? _window_FocusEvent : class FocusEvent extends UIEvent {
|
||||
};
|
||||
var _window_InputEvent;
|
||||
const InputEvent = (_window_InputEvent = window.InputEvent) !== null && _window_InputEvent !== undefined ? _window_InputEvent : class InputEvent extends UIEvent {
|
||||
};
|
||||
var _window_KeyboardEvent;
|
||||
const KeyboardEvent = (_window_KeyboardEvent = window.KeyboardEvent) !== null && _window_KeyboardEvent !== undefined ? _window_KeyboardEvent : class KeyboardEvent extends UIEvent {
|
||||
};
|
||||
var _window_MouseEvent;
|
||||
const MouseEvent = (_window_MouseEvent = window.MouseEvent) !== null && _window_MouseEvent !== undefined ? _window_MouseEvent : class MouseEvent extends UIEvent {
|
||||
};
|
||||
var _window_DragEvent;
|
||||
const DragEvent = (_window_DragEvent = window.DragEvent) !== null && _window_DragEvent !== undefined ? _window_DragEvent : class DragEvent extends MouseEvent {
|
||||
};
|
||||
var _window_PointerEvent;
|
||||
const PointerEvent = (_window_PointerEvent = window.PointerEvent) !== null && _window_PointerEvent !== undefined ? _window_PointerEvent : class PointerEvent extends MouseEvent {
|
||||
};
|
||||
var _window_TouchEvent;
|
||||
const TouchEvent = (_window_TouchEvent = window.TouchEvent) !== null && _window_TouchEvent !== undefined ? _window_TouchEvent : class TouchEvent extends UIEvent {
|
||||
};
|
||||
/* eslint-enable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ return {
|
||||
Event,
|
||||
AnimationEvent,
|
||||
ClipboardEvent,
|
||||
PopStateEvent,
|
||||
ProgressEvent,
|
||||
TransitionEvent,
|
||||
UIEvent,
|
||||
CompositionEvent,
|
||||
FocusEvent,
|
||||
InputEvent,
|
||||
KeyboardEvent,
|
||||
MouseEvent,
|
||||
DragEvent,
|
||||
PointerEvent,
|
||||
TouchEvent
|
||||
};
|
||||
}
|
||||
function assignProps(obj, props) {
|
||||
for (const [key, value] of Object.entries(props)){
|
||||
Object.defineProperty(obj, key, {
|
||||
get: ()=>value !== null && value !== undefined ? value : null
|
||||
});
|
||||
}
|
||||
}
|
||||
function sanitizeNumber(n) {
|
||||
return Number(n !== null && n !== undefined ? n : 0);
|
||||
}
|
||||
function initClipboardEvent(event, { clipboardData }) {
|
||||
assignProps(event, {
|
||||
clipboardData
|
||||
});
|
||||
}
|
||||
function initFocusEvent(event, { relatedTarget }) {
|
||||
assignProps(event, {
|
||||
relatedTarget
|
||||
});
|
||||
}
|
||||
function initInputEvent(event, { data, inputType, isComposing }) {
|
||||
assignProps(event, {
|
||||
data,
|
||||
isComposing: Boolean(isComposing),
|
||||
inputType: String(inputType)
|
||||
});
|
||||
}
|
||||
function initUIEvent(event, { view, detail }) {
|
||||
assignProps(event, {
|
||||
view,
|
||||
detail: sanitizeNumber(detail !== null && detail !== undefined ? detail : 0)
|
||||
});
|
||||
}
|
||||
function initUIEventModifiers(event, { altKey, ctrlKey, metaKey, shiftKey, modifierAltGraph, modifierCapsLock, modifierFn, modifierFnLock, modifierNumLock, modifierScrollLock, modifierSymbol, modifierSymbolLock }) {
|
||||
assignProps(event, {
|
||||
altKey: Boolean(altKey),
|
||||
ctrlKey: Boolean(ctrlKey),
|
||||
metaKey: Boolean(metaKey),
|
||||
shiftKey: Boolean(shiftKey),
|
||||
getModifierState (k) {
|
||||
return Boolean({
|
||||
Alt: altKey,
|
||||
AltGraph: modifierAltGraph,
|
||||
CapsLock: modifierCapsLock,
|
||||
Control: ctrlKey,
|
||||
Fn: modifierFn,
|
||||
FnLock: modifierFnLock,
|
||||
Meta: metaKey,
|
||||
NumLock: modifierNumLock,
|
||||
ScrollLock: modifierScrollLock,
|
||||
Shift: shiftKey,
|
||||
Symbol: modifierSymbol,
|
||||
SymbolLock: modifierSymbolLock
|
||||
}[k]);
|
||||
}
|
||||
});
|
||||
}
|
||||
function initKeyboardEvent(event, { key, code, location, repeat, isComposing, charCode }) {
|
||||
assignProps(event, {
|
||||
key: String(key),
|
||||
code: String(code),
|
||||
location: sanitizeNumber(location),
|
||||
repeat: Boolean(repeat),
|
||||
isComposing: Boolean(isComposing),
|
||||
charCode
|
||||
});
|
||||
}
|
||||
function initMouseEvent(event, { x, y, screenX, screenY, clientX = x, clientY = y, button, buttons, relatedTarget, offsetX, offsetY, pageX, pageY }) {
|
||||
assignProps(event, {
|
||||
screenX: sanitizeNumber(screenX),
|
||||
screenY: sanitizeNumber(screenY),
|
||||
clientX: sanitizeNumber(clientX),
|
||||
x: sanitizeNumber(clientX),
|
||||
clientY: sanitizeNumber(clientY),
|
||||
y: sanitizeNumber(clientY),
|
||||
button: sanitizeNumber(button),
|
||||
buttons: sanitizeNumber(buttons),
|
||||
relatedTarget,
|
||||
offsetX: sanitizeNumber(offsetX),
|
||||
offsetY: sanitizeNumber(offsetY),
|
||||
pageX: sanitizeNumber(pageX),
|
||||
pageY: sanitizeNumber(pageY)
|
||||
});
|
||||
}
|
||||
function initPointerEvent(event, { pointerId, width, height, pressure, tangentialPressure, tiltX, tiltY, twist, pointerType, isPrimary }) {
|
||||
assignProps(event, {
|
||||
pointerId: sanitizeNumber(pointerId),
|
||||
width: sanitizeNumber(width !== null && width !== undefined ? width : 1),
|
||||
height: sanitizeNumber(height !== null && height !== undefined ? height : 1),
|
||||
pressure: sanitizeNumber(pressure),
|
||||
tangentialPressure: sanitizeNumber(tangentialPressure),
|
||||
tiltX: sanitizeNumber(tiltX),
|
||||
tiltY: sanitizeNumber(tiltY),
|
||||
twist: sanitizeNumber(twist),
|
||||
pointerType: String(pointerType),
|
||||
isPrimary: Boolean(isPrimary)
|
||||
});
|
||||
}
|
||||
|
||||
exports.createEvent = createEvent;
|
||||
54
frontend/node_modules/@testing-library/user-event/dist/cjs/event/dispatchEvent.js
generated
vendored
Normal file
54
frontend/node_modules/@testing-library/user-event/dist/cjs/event/dispatchEvent.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
'use strict';
|
||||
|
||||
require('./behavior/click.js');
|
||||
require('./behavior/cut.js');
|
||||
require('./behavior/keydown.js');
|
||||
require('./behavior/keypress.js');
|
||||
require('./behavior/keyup.js');
|
||||
require('./behavior/paste.js');
|
||||
var registry = require('./behavior/registry.js');
|
||||
var wrapEvent = require('./wrapEvent.js');
|
||||
var eventMap = require('./eventMap.js');
|
||||
var createEvent = require('./createEvent.js');
|
||||
|
||||
function dispatchUIEvent(target, type, init, preventDefault = false) {
|
||||
if (eventMap.isMouseEvent(type) || eventMap.isKeyboardEvent(type)) {
|
||||
init = {
|
||||
...init,
|
||||
...this.system.getUIEventModifiers()
|
||||
};
|
||||
}
|
||||
const event = createEvent.createEvent(type, target, init);
|
||||
return dispatchEvent.call(this, target, event, preventDefault);
|
||||
}
|
||||
function dispatchEvent(target, event, preventDefault = false) {
|
||||
var _behavior_type;
|
||||
const type = event.type;
|
||||
const behaviorImplementation = preventDefault ? ()=>{} : (_behavior_type = registry.behavior[type]) === null || _behavior_type === undefined ? undefined : _behavior_type.call(registry.behavior, event, target, this);
|
||||
if (behaviorImplementation) {
|
||||
event.preventDefault();
|
||||
let defaultPrevented = false;
|
||||
Object.defineProperty(event, 'defaultPrevented', {
|
||||
get: ()=>defaultPrevented
|
||||
});
|
||||
Object.defineProperty(event, 'preventDefault', {
|
||||
value: ()=>{
|
||||
defaultPrevented = event.cancelable;
|
||||
}
|
||||
});
|
||||
wrapEvent.wrapEvent(()=>target.dispatchEvent(event));
|
||||
if (!defaultPrevented) {
|
||||
behaviorImplementation();
|
||||
}
|
||||
return !defaultPrevented;
|
||||
}
|
||||
return wrapEvent.wrapEvent(()=>target.dispatchEvent(event));
|
||||
}
|
||||
function dispatchDOMEvent(target, type, init) {
|
||||
const event = createEvent.createEvent(type, target, init);
|
||||
wrapEvent.wrapEvent(()=>target.dispatchEvent(event));
|
||||
}
|
||||
|
||||
exports.dispatchDOMEvent = dispatchDOMEvent;
|
||||
exports.dispatchEvent = dispatchEvent;
|
||||
exports.dispatchUIEvent = dispatchUIEvent;
|
||||
281
frontend/node_modules/@testing-library/user-event/dist/cjs/event/eventMap.js
generated
vendored
Normal file
281
frontend/node_modules/@testing-library/user-event/dist/cjs/event/eventMap.js
generated
vendored
Normal file
@@ -0,0 +1,281 @@
|
||||
'use strict';
|
||||
|
||||
const eventMap = {
|
||||
auxclick: {
|
||||
EventType: 'PointerEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
beforeinput: {
|
||||
EventType: 'InputEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
blur: {
|
||||
EventType: 'FocusEvent',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
click: {
|
||||
EventType: 'PointerEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
contextmenu: {
|
||||
EventType: 'PointerEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
copy: {
|
||||
EventType: 'ClipboardEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
change: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
cut: {
|
||||
EventType: 'ClipboardEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
dblclick: {
|
||||
EventType: 'MouseEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
focus: {
|
||||
EventType: 'FocusEvent',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
focusin: {
|
||||
EventType: 'FocusEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
focusout: {
|
||||
EventType: 'FocusEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
keydown: {
|
||||
EventType: 'KeyboardEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
keypress: {
|
||||
EventType: 'KeyboardEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
keyup: {
|
||||
EventType: 'KeyboardEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
paste: {
|
||||
EventType: 'ClipboardEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
input: {
|
||||
EventType: 'InputEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
mousedown: {
|
||||
EventType: 'MouseEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
mouseenter: {
|
||||
EventType: 'MouseEvent',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
mouseleave: {
|
||||
EventType: 'MouseEvent',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
mousemove: {
|
||||
EventType: 'MouseEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
mouseout: {
|
||||
EventType: 'MouseEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
mouseover: {
|
||||
EventType: 'MouseEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
mouseup: {
|
||||
EventType: 'MouseEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
pointerover: {
|
||||
EventType: 'PointerEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
pointerenter: {
|
||||
EventType: 'PointerEvent',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
pointerdown: {
|
||||
EventType: 'PointerEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
pointermove: {
|
||||
EventType: 'PointerEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
pointerup: {
|
||||
EventType: 'PointerEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
pointercancel: {
|
||||
EventType: 'PointerEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
pointerout: {
|
||||
EventType: 'PointerEvent',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true
|
||||
}
|
||||
},
|
||||
pointerleave: {
|
||||
EventType: 'PointerEvent',
|
||||
defaultInit: {
|
||||
bubbles: false,
|
||||
cancelable: false
|
||||
}
|
||||
},
|
||||
submit: {
|
||||
EventType: 'Event',
|
||||
defaultInit: {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
}
|
||||
}
|
||||
};
|
||||
function getEventClass(type) {
|
||||
return eventMap[type].EventType;
|
||||
}
|
||||
const mouseEvents = [
|
||||
'MouseEvent',
|
||||
'PointerEvent'
|
||||
];
|
||||
function isMouseEvent(type) {
|
||||
return mouseEvents.includes(getEventClass(type));
|
||||
}
|
||||
function isKeyboardEvent(type) {
|
||||
return getEventClass(type) === 'KeyboardEvent';
|
||||
}
|
||||
|
||||
exports.eventMap = eventMap;
|
||||
exports.isKeyboardEvent = isKeyboardEvent;
|
||||
exports.isMouseEvent = isMouseEvent;
|
||||
34
frontend/node_modules/@testing-library/user-event/dist/cjs/event/focus.js
generated
vendored
Normal file
34
frontend/node_modules/@testing-library/user-event/dist/cjs/event/focus.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
|
||||
require('../utils/dataTransfer/Clipboard.js');
|
||||
var getActiveElement = require('../utils/focus/getActiveElement.js');
|
||||
var isFocusable = require('../utils/focus/isFocusable.js');
|
||||
var findClosest = require('../utils/misc/findClosest.js');
|
||||
var updateSelectionOnFocus = require('./selection/updateSelectionOnFocus.js');
|
||||
var wrapEvent = require('./wrapEvent.js');
|
||||
|
||||
// Browsers do not dispatch FocusEvent if the document does not have focus.
|
||||
// TODO: simulate FocusEvent in browsers
|
||||
/**
|
||||
* Focus closest focusable element.
|
||||
*/ function focusElement(element) {
|
||||
const target = findClosest.findClosest(element, isFocusable.isFocusable);
|
||||
const activeElement = getActiveElement.getActiveElement(element.ownerDocument);
|
||||
if ((target !== null && target !== undefined ? target : element.ownerDocument.body) === activeElement) {
|
||||
return;
|
||||
} else if (target) {
|
||||
wrapEvent.wrapEvent(()=>target.focus());
|
||||
} else {
|
||||
wrapEvent.wrapEvent(()=>activeElement === null || activeElement === undefined ? undefined : activeElement.blur());
|
||||
}
|
||||
updateSelectionOnFocus.updateSelectionOnFocus(target !== null && target !== undefined ? target : element.ownerDocument.body);
|
||||
}
|
||||
function blurElement(element) {
|
||||
if (!isFocusable.isFocusable(element)) return;
|
||||
const wasActive = getActiveElement.getActiveElement(element.ownerDocument) === element;
|
||||
if (!wasActive) return;
|
||||
wrapEvent.wrapEvent(()=>element.blur());
|
||||
}
|
||||
|
||||
exports.blurElement = blurElement;
|
||||
exports.focusElement = focusElement;
|
||||
22
frontend/node_modules/@testing-library/user-event/dist/cjs/event/index.js
generated
vendored
Normal file
22
frontend/node_modules/@testing-library/user-event/dist/cjs/event/index.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
var dispatchEvent = require('./dispatchEvent.js');
|
||||
var focus = require('./focus.js');
|
||||
var input = require('./input.js');
|
||||
require('../utils/dataTransfer/Clipboard.js');
|
||||
var setSelectionPerMouse = require('./selection/setSelectionPerMouse.js');
|
||||
var modifySelectionPerMouse = require('./selection/modifySelectionPerMouse.js');
|
||||
var selectAll = require('./selection/selectAll.js');
|
||||
|
||||
|
||||
|
||||
exports.dispatchDOMEvent = dispatchEvent.dispatchDOMEvent;
|
||||
exports.dispatchEvent = dispatchEvent.dispatchEvent;
|
||||
exports.dispatchUIEvent = dispatchEvent.dispatchUIEvent;
|
||||
exports.blurElement = focus.blurElement;
|
||||
exports.focusElement = focus.focusElement;
|
||||
exports.input = input.input;
|
||||
exports.setSelectionPerMouseDown = setSelectionPerMouse.setSelectionPerMouseDown;
|
||||
exports.modifySelectionPerMouseMove = modifySelectionPerMouse.modifySelectionPerMouseMove;
|
||||
exports.isAllSelected = selectAll.isAllSelected;
|
||||
exports.selectAll = selectAll.selectAll;
|
||||
157
frontend/node_modules/@testing-library/user-event/dist/cjs/event/input.js
generated
vendored
Normal file
157
frontend/node_modules/@testing-library/user-event/dist/cjs/event/input.js
generated
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
'use strict';
|
||||
|
||||
var UI = require('../document/UI.js');
|
||||
var isElementType = require('../utils/misc/isElementType.js');
|
||||
require('../utils/dataTransfer/Clipboard.js');
|
||||
var timeValue = require('../utils/edit/timeValue.js');
|
||||
var maxLength = require('../utils/edit/maxLength.js');
|
||||
var cursor = require('../utils/focus/cursor.js');
|
||||
var trackValue = require('../document/trackValue.js');
|
||||
var getInputRange = require('./selection/getInputRange.js');
|
||||
var setSelection = require('./selection/setSelection.js');
|
||||
|
||||
function isDateOrTime(element) {
|
||||
return isElementType.isElementType(element, 'input') && [
|
||||
'date',
|
||||
'time'
|
||||
].includes(element.type);
|
||||
}
|
||||
function input(instance, element, data, inputType = 'insertText') {
|
||||
const inputRange = getInputRange.getInputRange(element);
|
||||
/* istanbul ignore if */ if (!inputRange) {
|
||||
return;
|
||||
}
|
||||
// There is no `beforeinput` event on `date` and `time` input
|
||||
if (!isDateOrTime(element)) {
|
||||
const unprevented = instance.dispatchUIEvent(element, 'beforeinput', {
|
||||
inputType,
|
||||
data
|
||||
});
|
||||
if (!unprevented) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ('startContainer' in inputRange) {
|
||||
editContenteditable(instance, element, inputRange, data, inputType);
|
||||
} else {
|
||||
editInputElement(instance, element, inputRange, data, inputType);
|
||||
}
|
||||
}
|
||||
function editContenteditable(instance, element, inputRange, data, inputType) {
|
||||
let del = false;
|
||||
if (!inputRange.collapsed) {
|
||||
del = true;
|
||||
inputRange.deleteContents();
|
||||
} else if ([
|
||||
'deleteContentBackward',
|
||||
'deleteContentForward'
|
||||
].includes(inputType)) {
|
||||
const nextPosition = cursor.getNextCursorPosition(inputRange.startContainer, inputRange.startOffset, inputType === 'deleteContentBackward' ? -1 : 1, inputType);
|
||||
if (nextPosition) {
|
||||
del = true;
|
||||
const delRange = inputRange.cloneRange();
|
||||
if (delRange.comparePoint(nextPosition.node, nextPosition.offset) < 0) {
|
||||
delRange.setStart(nextPosition.node, nextPosition.offset);
|
||||
} else {
|
||||
delRange.setEnd(nextPosition.node, nextPosition.offset);
|
||||
}
|
||||
delRange.deleteContents();
|
||||
}
|
||||
}
|
||||
if (data) {
|
||||
if (inputRange.endContainer.nodeType === 3) {
|
||||
const offset = inputRange.endOffset;
|
||||
inputRange.endContainer.insertData(offset, data);
|
||||
inputRange.setStart(inputRange.endContainer, offset + data.length);
|
||||
inputRange.setEnd(inputRange.endContainer, offset + data.length);
|
||||
} else {
|
||||
const text = element.ownerDocument.createTextNode(data);
|
||||
inputRange.insertNode(text);
|
||||
inputRange.setStart(text, data.length);
|
||||
inputRange.setEnd(text, data.length);
|
||||
}
|
||||
}
|
||||
if (del || data) {
|
||||
instance.dispatchUIEvent(element, 'input', {
|
||||
inputType
|
||||
});
|
||||
}
|
||||
}
|
||||
function editInputElement(instance, element, inputRange, data, inputType) {
|
||||
let dataToInsert = data;
|
||||
if (maxLength.supportsMaxLength(element)) {
|
||||
const maxLength$1 = maxLength.getMaxLength(element);
|
||||
if (maxLength$1 !== undefined && data.length > 0) {
|
||||
const spaceUntilMaxLength = maxLength$1 - element.value.length;
|
||||
if (spaceUntilMaxLength > 0) {
|
||||
dataToInsert = data.substring(0, spaceUntilMaxLength);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
const { newValue, newOffset, oldValue } = calculateNewValue(dataToInsert, element, inputRange, inputType);
|
||||
if (newValue === oldValue && newOffset === inputRange.startOffset && newOffset === inputRange.endOffset) {
|
||||
return;
|
||||
}
|
||||
if (isElementType.isElementType(element, 'input', {
|
||||
type: 'number'
|
||||
}) && !isValidNumberInput(newValue)) {
|
||||
return;
|
||||
}
|
||||
UI.setUIValue(element, newValue);
|
||||
setSelection.setSelection({
|
||||
focusNode: element,
|
||||
anchorOffset: newOffset,
|
||||
focusOffset: newOffset
|
||||
});
|
||||
if (isDateOrTime(element)) {
|
||||
if (timeValue.isValidDateOrTimeValue(element, newValue)) {
|
||||
commitInput(instance, element, newOffset, {});
|
||||
instance.dispatchUIEvent(element, 'change');
|
||||
UI.clearInitialValue(element);
|
||||
}
|
||||
} else {
|
||||
commitInput(instance, element, newOffset, {
|
||||
data,
|
||||
inputType
|
||||
});
|
||||
}
|
||||
}
|
||||
function calculateNewValue(inputData, node, { startOffset, endOffset }, inputType) {
|
||||
const value = UI.getUIValue(node);
|
||||
const prologEnd = Math.max(0, startOffset === endOffset && inputType === 'deleteContentBackward' ? startOffset - 1 : startOffset);
|
||||
const prolog = value.substring(0, prologEnd);
|
||||
const epilogStart = Math.min(value.length, startOffset === endOffset && inputType === 'deleteContentForward' ? startOffset + 1 : endOffset);
|
||||
const epilog = value.substring(epilogStart, value.length);
|
||||
let newValue = `${prolog}${inputData}${epilog}`;
|
||||
let newOffset = prologEnd + inputData.length;
|
||||
if (isElementType.isElementType(node, 'input', {
|
||||
type: 'time'
|
||||
})) {
|
||||
const builtValue = timeValue.buildTimeValue(newValue);
|
||||
if (builtValue !== '' && timeValue.isValidDateOrTimeValue(node, builtValue)) {
|
||||
newValue = builtValue;
|
||||
newOffset = builtValue.length;
|
||||
}
|
||||
}
|
||||
return {
|
||||
oldValue: value,
|
||||
newValue,
|
||||
newOffset
|
||||
};
|
||||
}
|
||||
function commitInput(instance, element, newOffset, inputInit) {
|
||||
instance.dispatchUIEvent(element, 'input', inputInit);
|
||||
trackValue.commitValueAfterInput(element, newOffset);
|
||||
}
|
||||
function isValidNumberInput(value) {
|
||||
var _value_match, _value_match1;
|
||||
// the browser allows some invalid input but not others
|
||||
// it allows up to two '-' at any place before any 'e' or one directly following 'e'
|
||||
// it allows one '.' at any place before e
|
||||
const valueParts = value.split('e', 2);
|
||||
return !(/[^\d.\-e]/.test(value) || Number((_value_match = value.match(/-/g)) === null || _value_match === undefined ? undefined : _value_match.length) > 2 || Number((_value_match1 = value.match(/\./g)) === null || _value_match1 === undefined ? undefined : _value_match1.length) > 1 || valueParts[1] && !/^-?\d*$/.test(valueParts[1]));
|
||||
}
|
||||
|
||||
exports.input = input;
|
||||
27
frontend/node_modules/@testing-library/user-event/dist/cjs/event/radio.js
generated
vendored
Normal file
27
frontend/node_modules/@testing-library/user-event/dist/cjs/event/radio.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
require('../utils/dataTransfer/Clipboard.js');
|
||||
var isDisabled = require('../utils/misc/isDisabled.js');
|
||||
var getWindow = require('../utils/misc/getWindow.js');
|
||||
var focus = require('./focus.js');
|
||||
|
||||
function walkRadio(instance, el, direction) {
|
||||
const window = getWindow.getWindow(el);
|
||||
const group = Array.from(el.ownerDocument.querySelectorAll(el.name ? `input[type="radio"][name="${window.CSS.escape(el.name)}"]` : `input[type="radio"][name=""], input[type="radio"]:not([name])`));
|
||||
for(let i = group.findIndex((e)=>e === el) + direction;; i += direction){
|
||||
if (!group[i]) {
|
||||
i = direction > 0 ? 0 : group.length - 1;
|
||||
}
|
||||
if (group[i] === el) {
|
||||
return;
|
||||
}
|
||||
if (isDisabled.isDisabled(group[i])) {
|
||||
continue;
|
||||
}
|
||||
focus.focusElement(group[i]);
|
||||
instance.dispatchUIEvent(group[i], 'click');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
exports.walkRadio = walkRadio;
|
||||
18
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/getInputRange.js
generated
vendored
Normal file
18
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/getInputRange.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
var getTargetTypeAndSelection = require('./getTargetTypeAndSelection.js');
|
||||
|
||||
/**
|
||||
* Get the range that would be overwritten by input.
|
||||
*/ function getInputRange(focusNode) {
|
||||
const typeAndSelection = getTargetTypeAndSelection.getTargetTypeAndSelection(focusNode);
|
||||
if (typeAndSelection.type === 'input') {
|
||||
return typeAndSelection.selection;
|
||||
} else if (typeAndSelection.type === 'contenteditable') {
|
||||
var _typeAndSelection_selection;
|
||||
// Multi-range on contenteditable edits the first selection instead of the last
|
||||
return (_typeAndSelection_selection = typeAndSelection.selection) === null || _typeAndSelection_selection === undefined ? undefined : _typeAndSelection_selection.getRangeAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
exports.getInputRange = getInputRange;
|
||||
31
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/getTargetTypeAndSelection.js
generated
vendored
Normal file
31
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/getTargetTypeAndSelection.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
var UI = require('../../document/UI.js');
|
||||
require('../../utils/dataTransfer/Clipboard.js');
|
||||
var isContentEditable = require('../../utils/edit/isContentEditable.js');
|
||||
var selection = require('../../utils/focus/selection.js');
|
||||
|
||||
/**
|
||||
* Determine which selection logic and selection ranges to consider.
|
||||
*/ function getTargetTypeAndSelection(node) {
|
||||
const element = getElement(node);
|
||||
if (element && selection.hasOwnSelection(element)) {
|
||||
return {
|
||||
type: 'input',
|
||||
selection: UI.getUISelection(element)
|
||||
};
|
||||
}
|
||||
const selection$1 = element === null || element === undefined ? undefined : element.ownerDocument.getSelection();
|
||||
// It is possible to extend a single-range selection into a contenteditable.
|
||||
// This results in the range acting like a range outside of contenteditable.
|
||||
const isCE = isContentEditable.getContentEditable(node) && (selection$1 === null || selection$1 === undefined ? undefined : selection$1.anchorNode) && isContentEditable.getContentEditable(selection$1.anchorNode);
|
||||
return {
|
||||
type: isCE ? 'contenteditable' : 'default',
|
||||
selection: selection$1
|
||||
};
|
||||
}
|
||||
function getElement(node) {
|
||||
return node.nodeType === 1 ? node : node.parentElement;
|
||||
}
|
||||
|
||||
exports.getTargetTypeAndSelection = getTargetTypeAndSelection;
|
||||
24
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/index.js
generated
vendored
Normal file
24
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/index.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
var getInputRange = require('./getInputRange.js');
|
||||
var modifySelection = require('./modifySelection.js');
|
||||
var moveSelection = require('./moveSelection.js');
|
||||
var setSelectionPerMouse = require('./setSelectionPerMouse.js');
|
||||
var modifySelectionPerMouse = require('./modifySelectionPerMouse.js');
|
||||
var selectAll = require('./selectAll.js');
|
||||
var setSelectionRange = require('./setSelectionRange.js');
|
||||
var setSelection = require('./setSelection.js');
|
||||
var updateSelectionOnFocus = require('./updateSelectionOnFocus.js');
|
||||
|
||||
|
||||
|
||||
exports.getInputRange = getInputRange.getInputRange;
|
||||
exports.modifySelection = modifySelection.modifySelection;
|
||||
exports.moveSelection = moveSelection.moveSelection;
|
||||
exports.setSelectionPerMouseDown = setSelectionPerMouse.setSelectionPerMouseDown;
|
||||
exports.modifySelectionPerMouseMove = modifySelectionPerMouse.modifySelectionPerMouseMove;
|
||||
exports.isAllSelected = selectAll.isAllSelected;
|
||||
exports.selectAll = selectAll.selectAll;
|
||||
exports.setSelectionRange = setSelectionRange.setSelectionRange;
|
||||
exports.setSelection = setSelection.setSelection;
|
||||
exports.updateSelectionOnFocus = updateSelectionOnFocus.updateSelectionOnFocus;
|
||||
21
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/modifySelection.js
generated
vendored
Normal file
21
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/modifySelection.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
var UI = require('../../document/UI.js');
|
||||
require('../../utils/dataTransfer/Clipboard.js');
|
||||
var getTargetTypeAndSelection = require('./getTargetTypeAndSelection.js');
|
||||
|
||||
/**
|
||||
* Extend/shrink the selection like with Shift+Arrows or Shift+Mouse
|
||||
*/ function modifySelection({ focusNode, focusOffset }) {
|
||||
var _focusNode_ownerDocument_getSelection, _focusNode_ownerDocument;
|
||||
const typeAndSelection = getTargetTypeAndSelection.getTargetTypeAndSelection(focusNode);
|
||||
if (typeAndSelection.type === 'input') {
|
||||
return UI.setUISelection(focusNode, {
|
||||
anchorOffset: typeAndSelection.selection.anchorOffset,
|
||||
focusOffset
|
||||
}, 'modify');
|
||||
}
|
||||
(_focusNode_ownerDocument = focusNode.ownerDocument) === null || _focusNode_ownerDocument === undefined ? undefined : (_focusNode_ownerDocument_getSelection = _focusNode_ownerDocument.getSelection()) === null || _focusNode_ownerDocument_getSelection === undefined ? undefined : _focusNode_ownerDocument_getSelection.extend(focusNode, focusOffset);
|
||||
}
|
||||
|
||||
exports.modifySelection = modifySelection;
|
||||
40
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/modifySelectionPerMouse.js
generated
vendored
Normal file
40
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/modifySelectionPerMouse.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
|
||||
var UI = require('../../document/UI.js');
|
||||
require('../../utils/dataTransfer/Clipboard.js');
|
||||
var resolveCaretPosition = require('./resolveCaretPosition.js');
|
||||
|
||||
function modifySelectionPerMouseMove(selectionRange, { document, target, node, offset }) {
|
||||
const selectionFocus = resolveCaretPosition.resolveCaretPosition({
|
||||
target,
|
||||
node,
|
||||
offset
|
||||
});
|
||||
if ('node' in selectionRange) {
|
||||
// When the mouse is dragged outside of an input/textarea,
|
||||
// the selection is extended to the beginning or end of the input
|
||||
// depending on pointer position.
|
||||
// TODO: extend selection according to pointer position
|
||||
/* istanbul ignore else */ if (selectionFocus.node === selectionRange.node) {
|
||||
const anchorOffset = selectionFocus.offset < selectionRange.start ? selectionRange.end : selectionRange.start;
|
||||
const focusOffset = selectionFocus.offset > selectionRange.end || selectionFocus.offset < selectionRange.start ? selectionFocus.offset : selectionRange.end;
|
||||
UI.setUISelection(selectionRange.node, {
|
||||
anchorOffset,
|
||||
focusOffset
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const range = selectionRange.cloneRange();
|
||||
const cmp = range.comparePoint(selectionFocus.node, selectionFocus.offset);
|
||||
if (cmp < 0) {
|
||||
range.setStart(selectionFocus.node, selectionFocus.offset);
|
||||
} else if (cmp > 0) {
|
||||
range.setEnd(selectionFocus.node, selectionFocus.offset);
|
||||
}
|
||||
const selection = document.getSelection();
|
||||
selection === null || selection === undefined ? undefined : selection.removeAllRanges();
|
||||
selection === null || selection === undefined ? undefined : selection.addRange(range.cloneRange());
|
||||
}
|
||||
}
|
||||
|
||||
exports.modifySelectionPerMouseMove = modifySelectionPerMouseMove;
|
||||
38
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/moveSelection.js
generated
vendored
Normal file
38
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/moveSelection.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
|
||||
var UI = require('../../document/UI.js');
|
||||
require('../../utils/dataTransfer/Clipboard.js');
|
||||
var cursor = require('../../utils/focus/cursor.js');
|
||||
var selection = require('../../utils/focus/selection.js');
|
||||
var setSelection = require('./setSelection.js');
|
||||
|
||||
/**
|
||||
* Move the selection
|
||||
*/ function moveSelection(node, direction) {
|
||||
// TODO: implement shift
|
||||
if (selection.hasOwnSelection(node)) {
|
||||
const selection = UI.getUISelection(node);
|
||||
setSelection.setSelection({
|
||||
focusNode: node,
|
||||
focusOffset: selection.startOffset === selection.endOffset ? selection.focusOffset + direction : direction < 0 ? selection.startOffset : selection.endOffset
|
||||
});
|
||||
} else {
|
||||
const selection = node.ownerDocument.getSelection();
|
||||
if (!(selection === null || selection === undefined ? undefined : selection.focusNode)) {
|
||||
return;
|
||||
}
|
||||
if (selection.isCollapsed) {
|
||||
const nextPosition = cursor.getNextCursorPosition(selection.focusNode, selection.focusOffset, direction);
|
||||
if (nextPosition) {
|
||||
setSelection.setSelection({
|
||||
focusNode: nextPosition.node,
|
||||
focusOffset: nextPosition.offset
|
||||
});
|
||||
}
|
||||
} else {
|
||||
selection[direction < 0 ? 'collapseToStart' : 'collapseToEnd']();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.moveSelection = moveSelection;
|
||||
61
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/resolveCaretPosition.js
generated
vendored
Normal file
61
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/resolveCaretPosition.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
'use strict';
|
||||
|
||||
var UI = require('../../document/UI.js');
|
||||
require('../../utils/dataTransfer/Clipboard.js');
|
||||
var selection = require('../../utils/focus/selection.js');
|
||||
|
||||
function resolveCaretPosition({ target, node, offset }) {
|
||||
if (selection.hasOwnSelection(target)) {
|
||||
return {
|
||||
node: target,
|
||||
offset: offset !== null && offset !== undefined ? offset : UI.getUIValue(target).length
|
||||
};
|
||||
} else if (node) {
|
||||
return {
|
||||
node,
|
||||
offset: offset !== null && offset !== undefined ? offset : node.nodeType === 3 ? node.nodeValue.length : node.childNodes.length
|
||||
};
|
||||
}
|
||||
return findNodeAtTextOffset(target, offset);
|
||||
}
|
||||
function findNodeAtTextOffset(node, offset, isRoot = true) {
|
||||
// When clicking after the content the browser behavior can be complicated:
|
||||
// 1. If there is textContent after the last element child,
|
||||
// the cursor is moved there.
|
||||
// 2. If there is textContent in the last element child,
|
||||
// the browser moves the cursor to the last non-empty text node inside this element.
|
||||
// 3. Otherwise the cursor is moved to the end of the target.
|
||||
let i = offset === undefined ? node.childNodes.length - 1 : 0;
|
||||
const step = offset === undefined ? -1 : 1;
|
||||
while(offset === undefined ? i >= (isRoot ? Math.max(node.childNodes.length - 1, 0) : 0) : i <= node.childNodes.length){
|
||||
if (offset && i === node.childNodes.length) {
|
||||
throw new Error('The given offset is out of bounds.');
|
||||
}
|
||||
const c = node.childNodes.item(i);
|
||||
const text = String(c.textContent);
|
||||
if (text.length) {
|
||||
if (offset !== undefined && text.length < offset) {
|
||||
offset -= text.length;
|
||||
} else if (c.nodeType === 1) {
|
||||
return findNodeAtTextOffset(c, offset, false);
|
||||
} else {
|
||||
// The pre-commit hooks keeps changing this
|
||||
// See https://github.com/kentcdodds/kcd-scripts/issues/218
|
||||
/* istanbul ignore else */ // eslint-disable-next-line no-lonely-if
|
||||
if (c.nodeType === 3) {
|
||||
return {
|
||||
node: c,
|
||||
offset: offset !== null && offset !== undefined ? offset : c.nodeValue.length
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
i += step;
|
||||
}
|
||||
return {
|
||||
node,
|
||||
offset: node.childNodes.length
|
||||
};
|
||||
}
|
||||
|
||||
exports.resolveCaretPosition = resolveCaretPosition;
|
||||
38
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/selectAll.js
generated
vendored
Normal file
38
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/selectAll.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
|
||||
var UI = require('../../document/UI.js');
|
||||
require('../../utils/dataTransfer/Clipboard.js');
|
||||
var isContentEditable = require('../../utils/edit/isContentEditable.js');
|
||||
var selection = require('../../utils/focus/selection.js');
|
||||
var setSelection = require('./setSelection.js');
|
||||
|
||||
/**
|
||||
* Expand a selection like the browser does when pressing Ctrl+A.
|
||||
*/ function selectAll(target) {
|
||||
if (selection.hasOwnSelection(target)) {
|
||||
return setSelection.setSelection({
|
||||
focusNode: target,
|
||||
anchorOffset: 0,
|
||||
focusOffset: UI.getUIValue(target).length
|
||||
});
|
||||
}
|
||||
var _getContentEditable;
|
||||
const focusNode = (_getContentEditable = isContentEditable.getContentEditable(target)) !== null && _getContentEditable !== undefined ? _getContentEditable : target.ownerDocument.body;
|
||||
setSelection.setSelection({
|
||||
focusNode,
|
||||
anchorOffset: 0,
|
||||
focusOffset: focusNode.childNodes.length
|
||||
});
|
||||
}
|
||||
function isAllSelected(target) {
|
||||
if (selection.hasOwnSelection(target)) {
|
||||
return UI.getUISelection(target).startOffset === 0 && UI.getUISelection(target).endOffset === UI.getUIValue(target).length;
|
||||
}
|
||||
var _getContentEditable;
|
||||
const focusNode = (_getContentEditable = isContentEditable.getContentEditable(target)) !== null && _getContentEditable !== undefined ? _getContentEditable : target.ownerDocument.body;
|
||||
const selection$1 = target.ownerDocument.getSelection();
|
||||
return (selection$1 === null || selection$1 === undefined ? undefined : selection$1.anchorNode) === focusNode && selection$1.focusNode === focusNode && selection$1.anchorOffset === 0 && selection$1.focusOffset === focusNode.childNodes.length;
|
||||
}
|
||||
|
||||
exports.isAllSelected = isAllSelected;
|
||||
exports.selectAll = selectAll;
|
||||
21
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/setSelection.js
generated
vendored
Normal file
21
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/setSelection.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
var UI = require('../../document/UI.js');
|
||||
require('../../utils/dataTransfer/Clipboard.js');
|
||||
var getTargetTypeAndSelection = require('./getTargetTypeAndSelection.js');
|
||||
|
||||
/**
|
||||
* Set the selection
|
||||
*/ function setSelection({ focusNode, focusOffset, anchorNode = focusNode, anchorOffset = focusOffset }) {
|
||||
var _anchorNode_ownerDocument_getSelection, _anchorNode_ownerDocument;
|
||||
const typeAndSelection = getTargetTypeAndSelection.getTargetTypeAndSelection(focusNode);
|
||||
if (typeAndSelection.type === 'input') {
|
||||
return UI.setUISelection(focusNode, {
|
||||
anchorOffset,
|
||||
focusOffset
|
||||
});
|
||||
}
|
||||
(_anchorNode_ownerDocument = anchorNode.ownerDocument) === null || _anchorNode_ownerDocument === undefined ? undefined : (_anchorNode_ownerDocument_getSelection = _anchorNode_ownerDocument.getSelection()) === null || _anchorNode_ownerDocument_getSelection === undefined ? undefined : _anchorNode_ownerDocument_getSelection.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
|
||||
}
|
||||
|
||||
exports.setSelection = setSelection;
|
||||
81
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/setSelectionPerMouse.js
generated
vendored
Normal file
81
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/setSelectionPerMouse.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
'use strict';
|
||||
|
||||
var UI = require('../../document/UI.js');
|
||||
require('../../utils/dataTransfer/Clipboard.js');
|
||||
var selection = require('../../utils/focus/selection.js');
|
||||
var resolveCaretPosition = require('./resolveCaretPosition.js');
|
||||
|
||||
function setSelectionPerMouseDown({ document, target, clickCount, node, offset }) {
|
||||
if (selection.hasNoSelection(target)) {
|
||||
return;
|
||||
}
|
||||
const targetHasOwnSelection = selection.hasOwnSelection(target);
|
||||
// On non-input elements the text selection per multiple click
|
||||
// can extend beyond the target boundaries.
|
||||
// The exact mechanism what is considered in the same line is unclear.
|
||||
// Looks it might be every inline element.
|
||||
// TODO: Check what might be considered part of the same line of text.
|
||||
const text = String(targetHasOwnSelection ? UI.getUIValue(target) : target.textContent);
|
||||
const [start, end] = node ? // which elements might be considered in the same line of text.
|
||||
// TODO: support expanding initial range on multiple clicks if node is given
|
||||
[
|
||||
offset,
|
||||
offset
|
||||
] : getTextRange(text, offset, clickCount);
|
||||
// TODO: implement modifying selection per shift/ctrl+mouse
|
||||
if (targetHasOwnSelection) {
|
||||
UI.setUISelection(target, {
|
||||
anchorOffset: start !== null && start !== undefined ? start : text.length,
|
||||
focusOffset: end !== null && end !== undefined ? end : text.length
|
||||
});
|
||||
return {
|
||||
node: target,
|
||||
start: start !== null && start !== undefined ? start : 0,
|
||||
end: end !== null && end !== undefined ? end : text.length
|
||||
};
|
||||
} else {
|
||||
const { node: startNode, offset: startOffset } = resolveCaretPosition.resolveCaretPosition({
|
||||
target,
|
||||
node,
|
||||
offset: start
|
||||
});
|
||||
const { node: endNode, offset: endOffset } = resolveCaretPosition.resolveCaretPosition({
|
||||
target,
|
||||
node,
|
||||
offset: end
|
||||
});
|
||||
const range = target.ownerDocument.createRange();
|
||||
try {
|
||||
range.setStart(startNode, startOffset);
|
||||
range.setEnd(endNode, endOffset);
|
||||
} catch (e) {
|
||||
throw new Error('The given offset is out of bounds.');
|
||||
}
|
||||
const selection = document.getSelection();
|
||||
selection === null || selection === undefined ? undefined : selection.removeAllRanges();
|
||||
selection === null || selection === undefined ? undefined : selection.addRange(range.cloneRange());
|
||||
return range;
|
||||
}
|
||||
}
|
||||
function getTextRange(text, pos, clickCount) {
|
||||
if (clickCount % 3 === 1 || text.length === 0) {
|
||||
return [
|
||||
pos,
|
||||
pos
|
||||
];
|
||||
}
|
||||
const textPos = pos !== null && pos !== undefined ? pos : text.length;
|
||||
if (clickCount % 3 === 2) {
|
||||
return [
|
||||
textPos - text.substr(0, pos).match(/(\w+|\s+|\W)?$/)[0].length,
|
||||
pos === undefined ? pos : pos + text.substr(pos).match(/^(\w+|\s+|\W)?/)[0].length
|
||||
];
|
||||
}
|
||||
// triple click
|
||||
return [
|
||||
textPos - text.substr(0, pos).match(/[^\r\n]*$/)[0].length,
|
||||
pos === undefined ? pos : pos + text.substr(pos).match(/^[^\r\n]*/)[0].length
|
||||
];
|
||||
}
|
||||
|
||||
exports.setSelectionPerMouseDown = setSelectionPerMouseDown;
|
||||
31
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/setSelectionRange.js
generated
vendored
Normal file
31
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/setSelectionRange.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
require('../../utils/dataTransfer/Clipboard.js');
|
||||
var isContentEditable = require('../../utils/edit/isContentEditable.js');
|
||||
var selection = require('../../utils/focus/selection.js');
|
||||
var setSelection = require('./setSelection.js');
|
||||
|
||||
/**
|
||||
* Backward-compatible selection.
|
||||
*
|
||||
* Handles input elements and contenteditable if it only contains a single text node.
|
||||
*/ function setSelectionRange(element, anchorOffset, focusOffset) {
|
||||
var _element_firstChild;
|
||||
if (selection.hasOwnSelection(element)) {
|
||||
return setSelection.setSelection({
|
||||
focusNode: element,
|
||||
anchorOffset,
|
||||
focusOffset
|
||||
});
|
||||
}
|
||||
/* istanbul ignore else */ if (isContentEditable.isContentEditable(element) && ((_element_firstChild = element.firstChild) === null || _element_firstChild === undefined ? undefined : _element_firstChild.nodeType) === 3) {
|
||||
return setSelection.setSelection({
|
||||
focusNode: element.firstChild,
|
||||
anchorOffset,
|
||||
focusOffset
|
||||
});
|
||||
}
|
||||
/* istanbul ignore next */ throw new Error('Not implemented. The result of this interaction is unreliable.');
|
||||
}
|
||||
|
||||
exports.setSelectionRange = setSelectionRange;
|
||||
40
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/updateSelectionOnFocus.js
generated
vendored
Normal file
40
frontend/node_modules/@testing-library/user-event/dist/cjs/event/selection/updateSelectionOnFocus.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
|
||||
require('../../utils/dataTransfer/Clipboard.js');
|
||||
var isContentEditable = require('../../utils/edit/isContentEditable.js');
|
||||
var selection = require('../../utils/focus/selection.js');
|
||||
|
||||
// The browser implementation seems to have changed.
|
||||
// When focus is inside <input type="text"/>,
|
||||
// Chrome updates Selection to be collapsed at the position of the input element.
|
||||
// TODO: update implementation to match that of current browsers
|
||||
/**
|
||||
* Reset the Document Selection when moving focus into an element
|
||||
* with own selection implementation.
|
||||
*/ function updateSelectionOnFocus(element) {
|
||||
const selection$1 = element.ownerDocument.getSelection();
|
||||
/* istanbul ignore if */ if (!(selection$1 === null || selection$1 === undefined ? undefined : selection$1.focusNode)) {
|
||||
return;
|
||||
}
|
||||
// If the focus moves inside an element with own selection implementation,
|
||||
// the document selection will be this element.
|
||||
// But if the focused element is inside a contenteditable,
|
||||
// 1) a collapsed selection will be retained.
|
||||
// 2) other selections will be replaced by a cursor
|
||||
// 2.a) at the start of the first child if it is a text node
|
||||
// 2.b) at the start of the contenteditable.
|
||||
if (selection.hasOwnSelection(element)) {
|
||||
const contenteditable = isContentEditable.getContentEditable(selection$1.focusNode);
|
||||
if (contenteditable) {
|
||||
if (!selection$1.isCollapsed) {
|
||||
var _contenteditable_firstChild;
|
||||
const focusNode = ((_contenteditable_firstChild = contenteditable.firstChild) === null || _contenteditable_firstChild === undefined ? undefined : _contenteditable_firstChild.nodeType) === 3 ? contenteditable.firstChild : contenteditable;
|
||||
selection$1.setBaseAndExtent(focusNode, 0, focusNode, 0);
|
||||
}
|
||||
} else {
|
||||
selection$1.setBaseAndExtent(element, 0, element, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.updateSelectionOnFocus = updateSelectionOnFocus;
|
||||
2
frontend/node_modules/@testing-library/user-event/dist/cjs/event/types.js
generated
vendored
Normal file
2
frontend/node_modules/@testing-library/user-event/dist/cjs/event/types.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
'use strict';
|
||||
|
||||
9
frontend/node_modules/@testing-library/user-event/dist/cjs/event/wrapEvent.js
generated
vendored
Normal file
9
frontend/node_modules/@testing-library/user-event/dist/cjs/event/wrapEvent.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
var dom = require('@testing-library/dom');
|
||||
|
||||
function wrapEvent(cb, _element) {
|
||||
return dom.getConfig().eventWrapper(cb);
|
||||
}
|
||||
|
||||
exports.wrapEvent = wrapEvent;
|
||||
Reference in New Issue
Block a user