@testing-library/user-event 14.0.0-beta.9 → 14.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.cjs +632 -739
- package/dist/index.mjs +624 -726
- package/dist/types/event/behavior/cut.d.ts +1 -0
- package/dist/types/event/behavior/index.d.ts +5 -0
- package/dist/types/event/behavior/keydown.d.ts +1 -0
- package/dist/types/event/behavior/keypress.d.ts +1 -0
- package/dist/types/event/behavior/keyup.d.ts +1 -0
- package/dist/types/event/behavior/paste.d.ts +1 -0
- package/dist/types/event/dispatchEvent.d.ts +1 -1
- package/dist/types/event/eventMap.d.ts +361 -0
- package/dist/types/event/index.d.ts +2 -2
- package/dist/types/keyboard/modifiers.d.ts +9 -0
- package/dist/types/keyboard/types.d.ts +0 -5
- package/dist/types/utils/edit/input.d.ts +2 -0
- package/dist/types/utils/edit/isValidDateOrTimeValue.d.ts +3 -0
- package/dist/types/utils/focus/selection.d.ts +4 -0
- package/dist/types/utils/index.d.ts +1 -8
- package/dist/types/utils/keyDef/readNextDescriptor.d.ts +3 -1
- package/package.json +10 -13
- package/dist/types/keyboard/plugins/arrow.d.ts +0 -6
- package/dist/types/keyboard/plugins/character.d.ts +0 -5
- package/dist/types/keyboard/plugins/combination.d.ts +0 -5
- package/dist/types/keyboard/plugins/control.d.ts +0 -6
- package/dist/types/keyboard/plugins/functional.d.ts +0 -8
- package/dist/types/keyboard/plugins/index.d.ts +0 -7
- package/dist/types/keyboard/plugins/modifiers.d.ts +0 -8
- package/dist/types/keyboard/shared/fireChangeForInputTimeIfValid.d.ts +0 -4
- package/dist/types/keyboard/shared/index.d.ts +0 -1
- package/dist/types/utils/edit/calculateNewValue.d.ts +0 -14
- package/dist/types/utils/edit/editInputElement.d.ts +0 -14
- package/dist/types/utils/edit/isValidDateValue.d.ts +0 -3
- package/dist/types/utils/edit/isValidInputTimeValue.d.ts +0 -3
- package/dist/types/utils/edit/prepareInput.d.ts +0 -8
- package/dist/types/utils/misc/hasFormSubmit.d.ts +0 -1
package/dist/index.mjs
CHANGED
|
@@ -352,6 +352,29 @@ if (typeof afterAll === "function") {
|
|
|
352
352
|
afterAll(() => detachClipboardStubFromView(window));
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
+
// src/utils/edit/isContentEditable.ts
|
|
356
|
+
function isContentEditable(element) {
|
|
357
|
+
return element.hasAttribute("contenteditable") && (element.getAttribute("contenteditable") == "true" || element.getAttribute("contenteditable") == "");
|
|
358
|
+
}
|
|
359
|
+
function getContentEditable(node) {
|
|
360
|
+
const element = getElement(node);
|
|
361
|
+
return element && (element.closest('[contenteditable=""]') || element.closest('[contenteditable="true"]'));
|
|
362
|
+
}
|
|
363
|
+
function getElement(node) {
|
|
364
|
+
return node.nodeType === 1 ? node : node.parentElement;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// src/utils/edit/getValue.ts
|
|
368
|
+
function getValue(element) {
|
|
369
|
+
if (!element) {
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
if (isContentEditable(element)) {
|
|
373
|
+
return element.textContent;
|
|
374
|
+
}
|
|
375
|
+
return getUIValue(element);
|
|
376
|
+
}
|
|
377
|
+
|
|
355
378
|
// src/utils/edit/buildTimeValue.ts
|
|
356
379
|
function buildTimeValue(value) {
|
|
357
380
|
const onlyDigitsValue = value.replace(/\D/g, "");
|
|
@@ -383,21 +406,137 @@ function build(onlyDigitsValue, index) {
|
|
|
383
406
|
return `${validHours.toString().padStart(2, "0")}:${validMinutes.toString().padStart(2, "0")}`;
|
|
384
407
|
}
|
|
385
408
|
|
|
386
|
-
// src/utils/edit/
|
|
387
|
-
function
|
|
409
|
+
// src/utils/edit/isValidDateOrTimeValue.ts
|
|
410
|
+
function isValidDateOrTimeValue(element, value) {
|
|
388
411
|
const clone = element.cloneNode();
|
|
389
412
|
clone.value = value;
|
|
390
413
|
return clone.value === value;
|
|
391
414
|
}
|
|
392
415
|
|
|
393
|
-
// src/utils/edit/
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
416
|
+
// src/utils/edit/maxLength.ts
|
|
417
|
+
var maxLengthSupportedTypes = /* @__PURE__ */ ((maxLengthSupportedTypes2) => {
|
|
418
|
+
maxLengthSupportedTypes2["email"] = "email";
|
|
419
|
+
maxLengthSupportedTypes2["password"] = "password";
|
|
420
|
+
maxLengthSupportedTypes2["search"] = "search";
|
|
421
|
+
maxLengthSupportedTypes2["telephone"] = "telephone";
|
|
422
|
+
maxLengthSupportedTypes2["text"] = "text";
|
|
423
|
+
maxLengthSupportedTypes2["url"] = "url";
|
|
424
|
+
return maxLengthSupportedTypes2;
|
|
425
|
+
})(maxLengthSupportedTypes || {});
|
|
426
|
+
function getSpaceUntilMaxLength(element) {
|
|
427
|
+
const value = getValue(element);
|
|
428
|
+
if (value === null) {
|
|
429
|
+
return void 0;
|
|
430
|
+
}
|
|
431
|
+
const maxLength = getSanitizedMaxLength(element);
|
|
432
|
+
return maxLength ? maxLength - value.length : void 0;
|
|
433
|
+
}
|
|
434
|
+
function getSanitizedMaxLength(element) {
|
|
435
|
+
var _a;
|
|
436
|
+
if (!supportsMaxLength(element)) {
|
|
437
|
+
return void 0;
|
|
438
|
+
}
|
|
439
|
+
const attr = (_a = element.getAttribute("maxlength")) != null ? _a : "";
|
|
440
|
+
return /^\d+$/.test(attr) && Number(attr) >= 0 ? Number(attr) : void 0;
|
|
441
|
+
}
|
|
442
|
+
function supportsMaxLength(element) {
|
|
443
|
+
return isElementType(element, "textarea") || isElementType(element, "input") && Boolean(maxLengthSupportedTypes[element.type]);
|
|
398
444
|
}
|
|
399
445
|
|
|
400
|
-
// src/utils/edit/
|
|
446
|
+
// src/utils/edit/input.ts
|
|
447
|
+
function isDateOrTime(element) {
|
|
448
|
+
return isElementType(element, "input") && ["date", "time"].includes(element.type);
|
|
449
|
+
}
|
|
450
|
+
function input(config, element, data, inputType = "insertText") {
|
|
451
|
+
const inputRange = getInputRange(element);
|
|
452
|
+
if (!inputRange) {
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
if (!isDateOrTime(element)) {
|
|
456
|
+
const unprevented = dispatchUIEvent(config, element, "beforeinput", {
|
|
457
|
+
inputType,
|
|
458
|
+
data
|
|
459
|
+
});
|
|
460
|
+
if (!unprevented) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
if ("startContainer" in inputRange) {
|
|
465
|
+
editContenteditable(config, element, inputRange, data, inputType);
|
|
466
|
+
} else {
|
|
467
|
+
editInputElement(config, element, inputRange, data, inputType);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
function editContenteditable(config, element, inputRange, data, inputType) {
|
|
471
|
+
let del = false;
|
|
472
|
+
if (!inputRange.collapsed) {
|
|
473
|
+
del = true;
|
|
474
|
+
inputRange.deleteContents();
|
|
475
|
+
} else if (["deleteContentBackward", "deleteContentForward"].includes(inputType)) {
|
|
476
|
+
const nextPosition = getNextCursorPosition(inputRange.startContainer, inputRange.startOffset, inputType === "deleteContentBackward" ? -1 : 1, inputType);
|
|
477
|
+
if (nextPosition) {
|
|
478
|
+
del = true;
|
|
479
|
+
const delRange = inputRange.cloneRange();
|
|
480
|
+
if (delRange.comparePoint(nextPosition.node, nextPosition.offset) < 0) {
|
|
481
|
+
delRange.setStart(nextPosition.node, nextPosition.offset);
|
|
482
|
+
} else {
|
|
483
|
+
delRange.setEnd(nextPosition.node, nextPosition.offset);
|
|
484
|
+
}
|
|
485
|
+
delRange.deleteContents();
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
if (data) {
|
|
489
|
+
if (inputRange.endContainer.nodeType === 3) {
|
|
490
|
+
const offset = inputRange.endOffset;
|
|
491
|
+
inputRange.endContainer.insertData(offset, data);
|
|
492
|
+
inputRange.setStart(inputRange.endContainer, offset + data.length);
|
|
493
|
+
inputRange.setEnd(inputRange.endContainer, offset + data.length);
|
|
494
|
+
} else {
|
|
495
|
+
const text = element.ownerDocument.createTextNode(data);
|
|
496
|
+
inputRange.insertNode(text);
|
|
497
|
+
inputRange.setStart(text, data.length);
|
|
498
|
+
inputRange.setEnd(text, data.length);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
if (del || data) {
|
|
502
|
+
dispatchUIEvent(config, element, "input", { inputType });
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
function editInputElement(config, element, inputRange, data, inputType) {
|
|
506
|
+
let dataToInsert = data;
|
|
507
|
+
const spaceUntilMaxLength = getSpaceUntilMaxLength(element);
|
|
508
|
+
if (spaceUntilMaxLength !== void 0) {
|
|
509
|
+
if (spaceUntilMaxLength > 0) {
|
|
510
|
+
dataToInsert = data.substring(0, spaceUntilMaxLength);
|
|
511
|
+
} else {
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
const { newValue, newOffset, oldValue } = calculateNewValue(dataToInsert, element, inputRange, inputType);
|
|
516
|
+
if (newValue === oldValue && newOffset === inputRange.startOffset && newOffset === inputRange.endOffset) {
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
if (isElementType(element, "input", { type: "number" }) && !isValidNumberInput(newValue)) {
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
setUIValue(element, newValue);
|
|
523
|
+
setSelection({
|
|
524
|
+
focusNode: element,
|
|
525
|
+
anchorOffset: newOffset,
|
|
526
|
+
focusOffset: newOffset
|
|
527
|
+
});
|
|
528
|
+
if (isDateOrTime(element)) {
|
|
529
|
+
if (isValidDateOrTimeValue(element, newValue)) {
|
|
530
|
+
commitInput(config, element, oldValue, newValue, newOffset, {});
|
|
531
|
+
dispatchUIEvent(config, element, "change");
|
|
532
|
+
}
|
|
533
|
+
} else {
|
|
534
|
+
commitInput(config, element, oldValue, newValue, newOffset, {
|
|
535
|
+
data,
|
|
536
|
+
inputType
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
}
|
|
401
540
|
function calculateNewValue(inputData, node, {
|
|
402
541
|
startOffset,
|
|
403
542
|
endOffset
|
|
@@ -408,15 +547,12 @@ function calculateNewValue(inputData, node, {
|
|
|
408
547
|
const epilogStart = Math.min(value.length, startOffset === endOffset && inputType === "deleteContentForward" ? startOffset + 1 : endOffset);
|
|
409
548
|
const epilog = value.substring(epilogStart, value.length);
|
|
410
549
|
let newValue = `${prolog}${inputData}${epilog}`;
|
|
411
|
-
|
|
412
|
-
if (node
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
newValue = inputData;
|
|
418
|
-
} else {
|
|
419
|
-
newValue = value;
|
|
550
|
+
let newOffset = prologEnd + inputData.length;
|
|
551
|
+
if (isElementType(node, "input", { type: "time" })) {
|
|
552
|
+
const builtValue = buildTimeValue(newValue);
|
|
553
|
+
if (builtValue !== "" && isValidDateOrTimeValue(node, builtValue)) {
|
|
554
|
+
newValue = builtValue;
|
|
555
|
+
newOffset = builtValue.length;
|
|
420
556
|
}
|
|
421
557
|
}
|
|
422
558
|
return {
|
|
@@ -425,17 +561,22 @@ function calculateNewValue(inputData, node, {
|
|
|
425
561
|
newOffset
|
|
426
562
|
};
|
|
427
563
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
564
|
+
function commitInput(config, element, oldValue, newValue, newOffset, inputInit) {
|
|
565
|
+
startTrackValue(element);
|
|
566
|
+
dispatchUIEvent(config, element, "input", inputInit);
|
|
567
|
+
const tracked = endTrackValue(element);
|
|
568
|
+
if ((tracked == null ? void 0 : tracked.length) === 2 && tracked[0] === oldValue && tracked[1] === newValue) {
|
|
569
|
+
setSelection({
|
|
570
|
+
focusNode: element,
|
|
571
|
+
anchorOffset: newOffset,
|
|
572
|
+
focusOffset: newOffset
|
|
573
|
+
});
|
|
574
|
+
}
|
|
436
575
|
}
|
|
437
|
-
function
|
|
438
|
-
|
|
576
|
+
function isValidNumberInput(value) {
|
|
577
|
+
var _a, _b;
|
|
578
|
+
const valueParts = value.split("e", 2);
|
|
579
|
+
return !(/[^\d.\-e]/.test(value) || Number((_a = value.match(/-/g)) == null ? void 0 : _a.length) > 2 || Number((_b = value.match(/\./g)) == null ? void 0 : _b.length) > 1 || valueParts[1] && !/^-?\d*$/.test(valueParts[1]));
|
|
439
580
|
}
|
|
440
581
|
|
|
441
582
|
// src/utils/edit/isEditable.ts
|
|
@@ -461,157 +602,123 @@ function isEditableInput(element) {
|
|
|
461
602
|
return isElementType(element, "input", { readOnly: false }) && Boolean(editableInputTypes[element.type]);
|
|
462
603
|
}
|
|
463
604
|
|
|
464
|
-
// src/utils/
|
|
465
|
-
|
|
605
|
+
// src/utils/edit/setFiles.ts
|
|
606
|
+
var fakeFiles = Symbol("files and value properties are mocked");
|
|
607
|
+
function setFiles(el, files) {
|
|
466
608
|
var _a;
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
return setSelection({
|
|
476
|
-
focusNode: element.firstChild,
|
|
477
|
-
anchorOffset,
|
|
478
|
-
focusOffset
|
|
609
|
+
(_a = el[fakeFiles]) == null ? void 0 : _a.restore();
|
|
610
|
+
const objectDescriptors = Object.getOwnPropertyDescriptors(el);
|
|
611
|
+
const prototypeDescriptors = Object.getOwnPropertyDescriptors(Object.getPrototypeOf(el));
|
|
612
|
+
function restore() {
|
|
613
|
+
Object.defineProperties(el, {
|
|
614
|
+
files: __spreadValues(__spreadValues({}, prototypeDescriptors.files), objectDescriptors.files),
|
|
615
|
+
value: __spreadValues(__spreadValues({}, prototypeDescriptors.value), objectDescriptors.value),
|
|
616
|
+
type: __spreadValues(__spreadValues({}, prototypeDescriptors.type), objectDescriptors.type)
|
|
479
617
|
});
|
|
480
618
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
619
|
+
el[fakeFiles] = { restore };
|
|
620
|
+
Object.defineProperties(el, {
|
|
621
|
+
files: __spreadProps(__spreadValues(__spreadValues({}, prototypeDescriptors.files), objectDescriptors.files), {
|
|
622
|
+
get: () => files
|
|
623
|
+
}),
|
|
624
|
+
value: __spreadProps(__spreadValues(__spreadValues({}, prototypeDescriptors.value), objectDescriptors.value), {
|
|
625
|
+
get: () => files.length ? `C:\\fakepath\\${files[0].name}` : "",
|
|
626
|
+
set(v) {
|
|
627
|
+
var _a2;
|
|
628
|
+
if (v === "") {
|
|
629
|
+
restore();
|
|
630
|
+
} else {
|
|
631
|
+
(_a2 = objectDescriptors.value.set) == null ? void 0 : _a2.call(el, v);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}),
|
|
635
|
+
type: __spreadProps(__spreadValues(__spreadValues({}, prototypeDescriptors.type), objectDescriptors.type), {
|
|
636
|
+
set(v) {
|
|
637
|
+
if (v !== "file") {
|
|
638
|
+
restore();
|
|
639
|
+
el.type = v;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
})
|
|
643
|
+
});
|
|
503
644
|
}
|
|
504
|
-
|
|
505
|
-
|
|
645
|
+
|
|
646
|
+
// src/utils/misc/eventWrapper.ts
|
|
647
|
+
import { getConfig } from "@testing-library/dom";
|
|
648
|
+
function eventWrapper(cb) {
|
|
649
|
+
let result;
|
|
650
|
+
getConfig().eventWrapper(() => {
|
|
651
|
+
result = cb();
|
|
652
|
+
});
|
|
653
|
+
return result;
|
|
506
654
|
}
|
|
507
|
-
|
|
655
|
+
|
|
656
|
+
// src/utils/misc/isDisabled.ts
|
|
657
|
+
function isDisabled(element) {
|
|
508
658
|
var _a;
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
659
|
+
for (let el = element; el; el = el.parentElement) {
|
|
660
|
+
if (isElementType(el, [
|
|
661
|
+
"button",
|
|
662
|
+
"input",
|
|
663
|
+
"select",
|
|
664
|
+
"textarea",
|
|
665
|
+
"optgroup",
|
|
666
|
+
"option"
|
|
667
|
+
])) {
|
|
668
|
+
if (el.hasAttribute("disabled")) {
|
|
669
|
+
return true;
|
|
670
|
+
}
|
|
671
|
+
} else if (isElementType(el, "fieldset")) {
|
|
672
|
+
if (el.hasAttribute("disabled") && !((_a = el.querySelector(":scope > legend")) == null ? void 0 : _a.contains(element))) {
|
|
673
|
+
return true;
|
|
674
|
+
}
|
|
675
|
+
} else if (el.tagName.includes("-")) {
|
|
676
|
+
if (el.constructor.formAssociated && el.hasAttribute("disabled")) {
|
|
677
|
+
return true;
|
|
519
678
|
}
|
|
520
|
-
} else {
|
|
521
|
-
selection.setBaseAndExtent(element, 0, element, 0);
|
|
522
679
|
}
|
|
523
680
|
}
|
|
524
|
-
|
|
525
|
-
function getInputRange(focusNode) {
|
|
526
|
-
var _a;
|
|
527
|
-
const typeAndSelection = getTargetTypeAndSelection(focusNode);
|
|
528
|
-
if (typeAndSelection.type === "input") {
|
|
529
|
-
return typeAndSelection.selection;
|
|
530
|
-
} else if (typeAndSelection.type === "contenteditable") {
|
|
531
|
-
return (_a = typeAndSelection.selection) == null ? void 0 : _a.getRangeAt(0);
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
function setSelection({
|
|
535
|
-
focusNode,
|
|
536
|
-
focusOffset,
|
|
537
|
-
anchorNode = focusNode,
|
|
538
|
-
anchorOffset = focusOffset
|
|
539
|
-
}) {
|
|
540
|
-
var _a, _b;
|
|
541
|
-
const typeAndSelection = getTargetTypeAndSelection(focusNode);
|
|
542
|
-
if (typeAndSelection.type === "input") {
|
|
543
|
-
return setUISelection(focusNode, {
|
|
544
|
-
anchorOffset,
|
|
545
|
-
focusOffset
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
|
-
(_b = (_a = anchorNode.ownerDocument) == null ? void 0 : _a.getSelection()) == null ? void 0 : _b.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
|
|
681
|
+
return false;
|
|
549
682
|
}
|
|
550
683
|
|
|
551
|
-
// src/utils/
|
|
552
|
-
function
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
anchorOffset: newSelection.offset,
|
|
562
|
-
focusOffset: newSelection.offset
|
|
563
|
-
});
|
|
564
|
-
startTrackValue(element);
|
|
565
|
-
dispatchUIEvent(config, element, "input", eventOverrides);
|
|
566
|
-
const tracked = endTrackValue(element);
|
|
567
|
-
if ((tracked == null ? void 0 : tracked.length) === 2 && tracked[0] === oldValue && tracked[1] === newValue) {
|
|
568
|
-
setSelection({
|
|
569
|
-
focusNode: newSelection.node,
|
|
570
|
-
anchorOffset: newSelection.offset,
|
|
571
|
-
focusOffset: newSelection.offset
|
|
572
|
-
});
|
|
684
|
+
// src/utils/focus/getActiveElement.ts
|
|
685
|
+
function getActiveElement(document2) {
|
|
686
|
+
const activeElement = document2.activeElement;
|
|
687
|
+
if (activeElement == null ? void 0 : activeElement.shadowRoot) {
|
|
688
|
+
return getActiveElement(activeElement.shadowRoot);
|
|
689
|
+
} else {
|
|
690
|
+
if (isDisabled(activeElement)) {
|
|
691
|
+
return document2.ownerDocument ? document2.ownerDocument.body : document2.body;
|
|
692
|
+
}
|
|
693
|
+
return activeElement;
|
|
573
694
|
}
|
|
574
695
|
}
|
|
575
696
|
|
|
576
|
-
// src/utils/
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
697
|
+
// src/utils/focus/selector.ts
|
|
698
|
+
var FOCUSABLE_SELECTOR = [
|
|
699
|
+
"input:not([type=hidden]):not([disabled])",
|
|
700
|
+
"button:not([disabled])",
|
|
701
|
+
"select:not([disabled])",
|
|
702
|
+
"textarea:not([disabled])",
|
|
703
|
+
'[contenteditable=""]',
|
|
704
|
+
'[contenteditable="true"]',
|
|
705
|
+
"a[href]",
|
|
706
|
+
"[tabindex]:not([disabled])"
|
|
707
|
+
].join(", ");
|
|
586
708
|
|
|
587
|
-
// src/utils/
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
maxLengthSupportedTypes2["password"] = "password";
|
|
591
|
-
maxLengthSupportedTypes2["search"] = "search";
|
|
592
|
-
maxLengthSupportedTypes2["telephone"] = "telephone";
|
|
593
|
-
maxLengthSupportedTypes2["text"] = "text";
|
|
594
|
-
maxLengthSupportedTypes2["url"] = "url";
|
|
595
|
-
return maxLengthSupportedTypes2;
|
|
596
|
-
})(maxLengthSupportedTypes || {});
|
|
597
|
-
function getSpaceUntilMaxLength(element) {
|
|
598
|
-
const value = getValue(element);
|
|
599
|
-
if (value === null) {
|
|
600
|
-
return void 0;
|
|
601
|
-
}
|
|
602
|
-
const maxLength = getSanitizedMaxLength(element);
|
|
603
|
-
return maxLength ? maxLength - value.length : void 0;
|
|
604
|
-
}
|
|
605
|
-
function getSanitizedMaxLength(element) {
|
|
606
|
-
var _a;
|
|
607
|
-
if (!supportsMaxLength(element)) {
|
|
608
|
-
return void 0;
|
|
609
|
-
}
|
|
610
|
-
const attr = (_a = element.getAttribute("maxlength")) != null ? _a : "";
|
|
611
|
-
return /^\d+$/.test(attr) && Number(attr) >= 0 ? Number(attr) : void 0;
|
|
709
|
+
// src/utils/focus/isFocusable.ts
|
|
710
|
+
function isFocusable(element) {
|
|
711
|
+
return element.matches(FOCUSABLE_SELECTOR);
|
|
612
712
|
}
|
|
613
|
-
|
|
614
|
-
|
|
713
|
+
|
|
714
|
+
// src/utils/focus/blur.ts
|
|
715
|
+
function blur(element) {
|
|
716
|
+
if (!isFocusable(element))
|
|
717
|
+
return;
|
|
718
|
+
const wasActive = getActiveElement(element.ownerDocument) === element;
|
|
719
|
+
if (!wasActive)
|
|
720
|
+
return;
|
|
721
|
+
eventWrapper(() => element.blur());
|
|
615
722
|
}
|
|
616
723
|
|
|
617
724
|
// src/utils/focus/cursor.ts
|
|
@@ -662,7 +769,7 @@ function getNextCursorPosition(node, offset, direction, inputType) {
|
|
|
662
769
|
}
|
|
663
770
|
function getNextCharacterContentNode(node, offset, direction) {
|
|
664
771
|
const nextOffset = Number(offset) + (direction < 0 ? -1 : 0);
|
|
665
|
-
if (offset !== void 0 &&
|
|
772
|
+
if (offset !== void 0 && isElement(node) && nextOffset >= 0 && nextOffset < node.children.length) {
|
|
666
773
|
node = node.children[nextOffset];
|
|
667
774
|
}
|
|
668
775
|
return walkNodes(node, direction === 1 ? "next" : "previous", isTreatedAsCharacterContent);
|
|
@@ -671,7 +778,7 @@ function isTreatedAsCharacterContent(node) {
|
|
|
671
778
|
if (isTextNode(node)) {
|
|
672
779
|
return true;
|
|
673
780
|
}
|
|
674
|
-
if (
|
|
781
|
+
if (isElement(node)) {
|
|
675
782
|
if (isElementType(node, ["input", "textarea"])) {
|
|
676
783
|
return node.type !== "hidden";
|
|
677
784
|
} else if (isElementType(node, "br")) {
|
|
@@ -688,7 +795,7 @@ function getOffset(node) {
|
|
|
688
795
|
}
|
|
689
796
|
return i;
|
|
690
797
|
}
|
|
691
|
-
function
|
|
798
|
+
function isElement(node) {
|
|
692
799
|
return node.nodeType === 1;
|
|
693
800
|
}
|
|
694
801
|
function isTextNode(node) {
|
|
@@ -703,7 +810,7 @@ function walkNodes(node, direction, callback) {
|
|
|
703
810
|
if (callback(node)) {
|
|
704
811
|
return node;
|
|
705
812
|
}
|
|
706
|
-
} else if (node.parentNode && (!
|
|
813
|
+
} else if (node.parentNode && (!isElement(node.parentNode) || !isContentEditable(node.parentNode) && node.parentNode !== ((_a = node.ownerDocument) == null ? void 0 : _a.body))) {
|
|
707
814
|
node = node.parentNode;
|
|
708
815
|
} else {
|
|
709
816
|
break;
|
|
@@ -717,167 +824,116 @@ function getDescendant(node, direction) {
|
|
|
717
824
|
return node;
|
|
718
825
|
}
|
|
719
826
|
|
|
720
|
-
// src/utils/
|
|
721
|
-
function
|
|
722
|
-
|
|
723
|
-
if (
|
|
724
|
-
return
|
|
827
|
+
// src/utils/focus/selection.ts
|
|
828
|
+
function setSelectionRange(element, anchorOffset, focusOffset) {
|
|
829
|
+
var _a;
|
|
830
|
+
if (hasOwnSelection(element)) {
|
|
831
|
+
return setSelection({
|
|
832
|
+
focusNode: element,
|
|
833
|
+
anchorOffset,
|
|
834
|
+
focusOffset
|
|
835
|
+
});
|
|
725
836
|
}
|
|
726
|
-
if (
|
|
727
|
-
return {
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
if (data) {
|
|
747
|
-
if (inputRange.endContainer.nodeType === 3) {
|
|
748
|
-
const offset = inputRange.endOffset;
|
|
749
|
-
inputRange.endContainer.insertData(offset, data);
|
|
750
|
-
inputRange.setStart(inputRange.endContainer, offset + data.length);
|
|
751
|
-
inputRange.setEnd(inputRange.endContainer, offset + data.length);
|
|
752
|
-
} else {
|
|
753
|
-
const text = element.ownerDocument.createTextNode(data);
|
|
754
|
-
inputRange.insertNode(text);
|
|
755
|
-
inputRange.setStart(text, data.length);
|
|
756
|
-
inputRange.setEnd(text, data.length);
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
if (del || data) {
|
|
760
|
-
dispatchUIEvent(config, element, "input", { inputType });
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
};
|
|
764
|
-
} else {
|
|
837
|
+
if (isContentEditable(element) && ((_a = element.firstChild) == null ? void 0 : _a.nodeType) === 3) {
|
|
838
|
+
return setSelection({
|
|
839
|
+
focusNode: element.firstChild,
|
|
840
|
+
anchorOffset,
|
|
841
|
+
focusOffset
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
throw new Error("Not implemented. The result of this interaction is unreliable.");
|
|
845
|
+
}
|
|
846
|
+
function hasOwnSelection(node) {
|
|
847
|
+
return isElement2(node) && (isElementType(node, "textarea") || isElementType(node, "input") && node.type in editableInputTypes);
|
|
848
|
+
}
|
|
849
|
+
function isElement2(node) {
|
|
850
|
+
return node.nodeType === 1;
|
|
851
|
+
}
|
|
852
|
+
function getTargetTypeAndSelection(node) {
|
|
853
|
+
const element = getElement2(node);
|
|
854
|
+
if (element && hasOwnSelection(element)) {
|
|
765
855
|
return {
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
const { newValue, newOffset, oldValue } = calculateNewValue(data, element, inputRange, inputType);
|
|
769
|
-
if (newValue === oldValue && newOffset === inputRange.startOffset && newOffset === inputRange.endOffset) {
|
|
770
|
-
return;
|
|
771
|
-
}
|
|
772
|
-
editInputElement(config, element, {
|
|
773
|
-
newValue,
|
|
774
|
-
newSelection: {
|
|
775
|
-
node: element,
|
|
776
|
-
offset: newOffset
|
|
777
|
-
},
|
|
778
|
-
eventOverrides: {
|
|
779
|
-
inputType
|
|
780
|
-
}
|
|
781
|
-
});
|
|
782
|
-
}
|
|
856
|
+
type: "input",
|
|
857
|
+
selection: getUISelection(element)
|
|
783
858
|
};
|
|
784
859
|
}
|
|
860
|
+
const selection = element == null ? void 0 : element.ownerDocument.getSelection();
|
|
861
|
+
const isCE = getContentEditable(node) && (selection == null ? void 0 : selection.anchorNode) && getContentEditable(selection.anchorNode);
|
|
862
|
+
return {
|
|
863
|
+
type: isCE ? "contenteditable" : "default",
|
|
864
|
+
selection
|
|
865
|
+
};
|
|
785
866
|
}
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
function
|
|
867
|
+
function getElement2(node) {
|
|
868
|
+
return node.nodeType === 1 ? node : node.parentElement;
|
|
869
|
+
}
|
|
870
|
+
function updateSelectionOnFocus(element) {
|
|
790
871
|
var _a;
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
function restore() {
|
|
795
|
-
Object.defineProperties(el, {
|
|
796
|
-
files: __spreadValues(__spreadValues({}, prototypeDescriptors.files), objectDescriptors.files),
|
|
797
|
-
value: __spreadValues(__spreadValues({}, prototypeDescriptors.value), objectDescriptors.value),
|
|
798
|
-
type: __spreadValues(__spreadValues({}, prototypeDescriptors.type), objectDescriptors.type)
|
|
799
|
-
});
|
|
872
|
+
const selection = element.ownerDocument.getSelection();
|
|
873
|
+
if (!(selection == null ? void 0 : selection.focusNode)) {
|
|
874
|
+
return;
|
|
800
875
|
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
get: () => files.length ? `C:\\fakepath\\${files[0].name}` : "",
|
|
808
|
-
set(v) {
|
|
809
|
-
var _a2;
|
|
810
|
-
if (v === "") {
|
|
811
|
-
restore();
|
|
812
|
-
} else {
|
|
813
|
-
(_a2 = objectDescriptors.value.set) == null ? void 0 : _a2.call(el, v);
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
}),
|
|
817
|
-
type: __spreadProps(__spreadValues(__spreadValues({}, prototypeDescriptors.type), objectDescriptors.type), {
|
|
818
|
-
set(v) {
|
|
819
|
-
if (v !== "file") {
|
|
820
|
-
restore();
|
|
821
|
-
el.type = v;
|
|
822
|
-
}
|
|
876
|
+
if (hasOwnSelection(element)) {
|
|
877
|
+
const contenteditable = getContentEditable(selection.focusNode);
|
|
878
|
+
if (contenteditable) {
|
|
879
|
+
if (!selection.isCollapsed) {
|
|
880
|
+
const focusNode = ((_a = contenteditable.firstChild) == null ? void 0 : _a.nodeType) === 3 ? contenteditable.firstChild : contenteditable;
|
|
881
|
+
selection.setBaseAndExtent(focusNode, 0, focusNode, 0);
|
|
823
882
|
}
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
// src/utils/misc/eventWrapper.ts
|
|
829
|
-
import { getConfig } from "@testing-library/dom";
|
|
830
|
-
function eventWrapper(cb) {
|
|
831
|
-
let result;
|
|
832
|
-
getConfig().eventWrapper(() => {
|
|
833
|
-
result = cb();
|
|
834
|
-
});
|
|
835
|
-
return result;
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
// src/utils/misc/isDisabled.ts
|
|
839
|
-
function isDisabled(element) {
|
|
840
|
-
return Boolean(element && element.disabled);
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
// src/utils/focus/getActiveElement.ts
|
|
844
|
-
function getActiveElement(document2) {
|
|
845
|
-
const activeElement = document2.activeElement;
|
|
846
|
-
if (activeElement == null ? void 0 : activeElement.shadowRoot) {
|
|
847
|
-
return getActiveElement(activeElement.shadowRoot);
|
|
848
|
-
} else {
|
|
849
|
-
if (isDisabled(activeElement)) {
|
|
850
|
-
return document2.ownerDocument ? document2.ownerDocument.body : document2.body;
|
|
883
|
+
} else {
|
|
884
|
+
selection.setBaseAndExtent(element, 0, element, 0);
|
|
851
885
|
}
|
|
852
|
-
return activeElement;
|
|
853
886
|
}
|
|
854
887
|
}
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
"input
|
|
859
|
-
|
|
860
|
-
"
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
'[contenteditable="true"]',
|
|
864
|
-
"a[href]",
|
|
865
|
-
"[tabindex]:not([disabled])"
|
|
866
|
-
].join(", ");
|
|
867
|
-
|
|
868
|
-
// src/utils/focus/isFocusable.ts
|
|
869
|
-
function isFocusable(element) {
|
|
870
|
-
return element.matches(FOCUSABLE_SELECTOR);
|
|
888
|
+
function getInputRange(focusNode) {
|
|
889
|
+
var _a;
|
|
890
|
+
const typeAndSelection = getTargetTypeAndSelection(focusNode);
|
|
891
|
+
if (typeAndSelection.type === "input") {
|
|
892
|
+
return typeAndSelection.selection;
|
|
893
|
+
} else if (typeAndSelection.type === "contenteditable") {
|
|
894
|
+
return (_a = typeAndSelection.selection) == null ? void 0 : _a.getRangeAt(0);
|
|
895
|
+
}
|
|
871
896
|
}
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
897
|
+
function setSelection({
|
|
898
|
+
focusNode,
|
|
899
|
+
focusOffset,
|
|
900
|
+
anchorNode = focusNode,
|
|
901
|
+
anchorOffset = focusOffset
|
|
902
|
+
}) {
|
|
903
|
+
var _a, _b;
|
|
904
|
+
const typeAndSelection = getTargetTypeAndSelection(focusNode);
|
|
905
|
+
if (typeAndSelection.type === "input") {
|
|
906
|
+
return setUISelection(focusNode, {
|
|
907
|
+
anchorOffset,
|
|
908
|
+
focusOffset
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
(_b = (_a = anchorNode.ownerDocument) == null ? void 0 : _a.getSelection()) == null ? void 0 : _b.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
|
|
912
|
+
}
|
|
913
|
+
function moveSelection(node, direction) {
|
|
914
|
+
if (hasOwnSelection(node)) {
|
|
915
|
+
const selection = getUISelection(node);
|
|
916
|
+
setSelection({
|
|
917
|
+
focusNode: node,
|
|
918
|
+
focusOffset: selection.startOffset === selection.endOffset ? selection.focusOffset + direction : direction < 0 ? selection.startOffset : selection.endOffset
|
|
919
|
+
});
|
|
920
|
+
} else {
|
|
921
|
+
const selection = node.ownerDocument.getSelection();
|
|
922
|
+
if (!selection) {
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
if (selection.isCollapsed) {
|
|
926
|
+
const nextPosition = getNextCursorPosition(selection.focusNode, selection.focusOffset, direction);
|
|
927
|
+
if (nextPosition) {
|
|
928
|
+
setSelection({
|
|
929
|
+
focusNode: nextPosition.node,
|
|
930
|
+
focusOffset: nextPosition.offset
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
} else {
|
|
934
|
+
selection[direction < 0 ? "collapseToStart" : "collapseToEnd"]();
|
|
935
|
+
}
|
|
936
|
+
}
|
|
881
937
|
}
|
|
882
938
|
|
|
883
939
|
// src/utils/focus/copySelection.ts
|
|
@@ -1049,7 +1105,7 @@ var bracketDict = /* @__PURE__ */ ((bracketDict2) => {
|
|
|
1049
1105
|
bracketDict2["["] = "]";
|
|
1050
1106
|
return bracketDict2;
|
|
1051
1107
|
})(bracketDict || {});
|
|
1052
|
-
function readNextDescriptor(text) {
|
|
1108
|
+
function readNextDescriptor(text, context) {
|
|
1053
1109
|
let pos = 0;
|
|
1054
1110
|
const startBracket = text[pos] in bracketDict ? text[pos] : "";
|
|
1055
1111
|
pos += startBracket.length;
|
|
@@ -1057,11 +1113,11 @@ function readNextDescriptor(text) {
|
|
|
1057
1113
|
const type3 = isEscapedChar ? "" : startBracket;
|
|
1058
1114
|
return __spreadValues({
|
|
1059
1115
|
type: type3
|
|
1060
|
-
}, type3 === "" ? readPrintableChar(text, pos) : readTag(text, pos, type3));
|
|
1116
|
+
}, type3 === "" ? readPrintableChar(text, pos, context) : readTag(text, pos, type3, context));
|
|
1061
1117
|
}
|
|
1062
|
-
function readPrintableChar(text, pos) {
|
|
1118
|
+
function readPrintableChar(text, pos, context) {
|
|
1063
1119
|
const descriptor = text[pos];
|
|
1064
|
-
assertDescriptor(descriptor, text, pos);
|
|
1120
|
+
assertDescriptor(descriptor, text, pos, context);
|
|
1065
1121
|
pos += descriptor.length;
|
|
1066
1122
|
return {
|
|
1067
1123
|
consumedLength: pos,
|
|
@@ -1071,14 +1127,14 @@ function readPrintableChar(text, pos) {
|
|
|
1071
1127
|
repeat: 1
|
|
1072
1128
|
};
|
|
1073
1129
|
}
|
|
1074
|
-
function readTag(text, pos, startBracket) {
|
|
1130
|
+
function readTag(text, pos, startBracket, context) {
|
|
1075
1131
|
var _a, _b, _c;
|
|
1076
1132
|
const releasePreviousModifier = text[pos] === "/" ? "/" : "";
|
|
1077
1133
|
pos += releasePreviousModifier.length;
|
|
1078
1134
|
const escapedDescriptor = startBracket === "{" && text[pos] === "\\";
|
|
1079
1135
|
pos += Number(escapedDescriptor);
|
|
1080
1136
|
const descriptor = escapedDescriptor ? text[pos] : (_a = text.slice(pos).match(startBracket === "{" ? /^\w+|^[^}>/]/ : /^\w+/)) == null ? void 0 : _a[0];
|
|
1081
|
-
assertDescriptor(descriptor, text, pos);
|
|
1137
|
+
assertDescriptor(descriptor, text, pos, context);
|
|
1082
1138
|
pos += descriptor.length;
|
|
1083
1139
|
const repeatModifier = (_c = (_b = text.slice(pos).match(/^>\d+/)) == null ? void 0 : _b[0]) != null ? _c : "";
|
|
1084
1140
|
pos += repeatModifier.length;
|
|
@@ -1091,7 +1147,7 @@ function readTag(text, pos, startBracket) {
|
|
|
1091
1147
|
!repeatModifier && "repeat modifier",
|
|
1092
1148
|
!releaseSelfModifier && "release modifier",
|
|
1093
1149
|
`"${expectedEndBracket}"`
|
|
1094
|
-
].filter(Boolean).join(" or "), text[pos], text));
|
|
1150
|
+
].filter(Boolean).join(" or "), text[pos], text, context));
|
|
1095
1151
|
}
|
|
1096
1152
|
pos += endBracket.length;
|
|
1097
1153
|
return {
|
|
@@ -1102,9 +1158,9 @@ function readTag(text, pos, startBracket) {
|
|
|
1102
1158
|
releaseSelf: hasReleaseSelf(releaseSelfModifier, repeatModifier)
|
|
1103
1159
|
};
|
|
1104
1160
|
}
|
|
1105
|
-
function assertDescriptor(descriptor, text, pos) {
|
|
1161
|
+
function assertDescriptor(descriptor, text, pos, context) {
|
|
1106
1162
|
if (!descriptor) {
|
|
1107
|
-
throw new Error(getErrorMessage("key descriptor", text[pos], text));
|
|
1163
|
+
throw new Error(getErrorMessage("key descriptor", text[pos], text, context));
|
|
1108
1164
|
}
|
|
1109
1165
|
}
|
|
1110
1166
|
function hasReleaseSelf(releaseSelfModifier, repeatModifier) {
|
|
@@ -1115,9 +1171,9 @@ function hasReleaseSelf(releaseSelfModifier, repeatModifier) {
|
|
|
1115
1171
|
return false;
|
|
1116
1172
|
}
|
|
1117
1173
|
}
|
|
1118
|
-
function getErrorMessage(expected, found, text) {
|
|
1174
|
+
function getErrorMessage(expected, found, text, context) {
|
|
1119
1175
|
return `Expected ${expected} but found "${found != null ? found : ""}" in "${text}"
|
|
1120
|
-
See https://
|
|
1176
|
+
See ${context === "pointer" ? `https://testing-library.com/docs/user-event/pointer#pressing-a-button-or-touching-the-screen` : `https://testing-library.com/docs/user-event/keyboard`}
|
|
1121
1177
|
for more information about how userEvent parses your input.`;
|
|
1122
1178
|
}
|
|
1123
1179
|
|
|
@@ -1163,9 +1219,6 @@ function wait(time) {
|
|
|
1163
1219
|
return new Promise((resolve) => setTimeout(() => resolve(), time));
|
|
1164
1220
|
}
|
|
1165
1221
|
|
|
1166
|
-
// src/utils/misc/hasFormSubmit.ts
|
|
1167
|
-
var hasFormSubmit = (form) => !!(form == null ? void 0 : form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]'));
|
|
1168
|
-
|
|
1169
1222
|
// src/utils/pointer/cssPointerEvents.ts
|
|
1170
1223
|
import { getWindowFromNode as getWindowFromNode2 } from "@testing-library/dom/dist/helpers.js";
|
|
1171
1224
|
|
|
@@ -1325,13 +1378,22 @@ function getMouseButtons(...buttons) {
|
|
|
1325
1378
|
|
|
1326
1379
|
// src/event/createEvent.ts
|
|
1327
1380
|
import { createEvent as createEventBase } from "@testing-library/dom";
|
|
1328
|
-
|
|
1381
|
+
|
|
1382
|
+
// src/event/eventMap.ts
|
|
1383
|
+
import { eventMap as baseEventMap } from "@testing-library/dom/dist/event-map.js";
|
|
1384
|
+
var eventMap = __spreadProps(__spreadValues({}, baseEventMap), {
|
|
1385
|
+
beforeInput: {
|
|
1386
|
+
EventType: "InputEvent",
|
|
1387
|
+
defaultInit: { bubbles: true, cancelable: true, composed: true }
|
|
1388
|
+
}
|
|
1389
|
+
});
|
|
1390
|
+
var eventMapKeys = Object.fromEntries(Object.keys(eventMap).map((k) => [k.toLowerCase(), k]));
|
|
1329
1391
|
|
|
1330
1392
|
// src/event/eventTypes.ts
|
|
1331
|
-
import { eventMap } from "@testing-library/dom/dist/event-map.js";
|
|
1332
|
-
var eventKeys = Object.fromEntries(Object.keys(
|
|
1393
|
+
import { eventMap as eventMap2 } from "@testing-library/dom/dist/event-map.js";
|
|
1394
|
+
var eventKeys = Object.fromEntries(Object.keys(eventMap2).map((k) => [k.toLowerCase(), k]));
|
|
1333
1395
|
function getEventClass(type3) {
|
|
1334
|
-
return
|
|
1396
|
+
return type3 in eventKeys ? eventMap2[eventKeys[type3]].EventType : "Event";
|
|
1335
1397
|
}
|
|
1336
1398
|
var mouseEvents = ["MouseEvent", "PointerEvent"];
|
|
1337
1399
|
function isMouseEvent(type3) {
|
|
@@ -1343,8 +1405,7 @@ function isKeyboardEvent(type3) {
|
|
|
1343
1405
|
|
|
1344
1406
|
// src/event/createEvent.ts
|
|
1345
1407
|
function createEvent(type3, target, init) {
|
|
1346
|
-
const
|
|
1347
|
-
const event = createEventBase[eventKey](target, init);
|
|
1408
|
+
const event = createEventBase(type3, target, init, eventMap[eventMapKeys[type3]]);
|
|
1348
1409
|
if (isMouseEvent(type3) && init) {
|
|
1349
1410
|
assignPositionInit(event, init);
|
|
1350
1411
|
assignPointerInit(event, init);
|
|
@@ -1395,8 +1456,8 @@ var behavior = {};
|
|
|
1395
1456
|
|
|
1396
1457
|
// src/event/behavior/click.ts
|
|
1397
1458
|
behavior.click = (event, target, config) => {
|
|
1398
|
-
|
|
1399
|
-
const control =
|
|
1459
|
+
const context = target.closest("button,input,label,textarea");
|
|
1460
|
+
const control = context && isElementType(context, "label") && context.control;
|
|
1400
1461
|
if (control) {
|
|
1401
1462
|
return () => {
|
|
1402
1463
|
if (isFocusable(control)) {
|
|
@@ -1413,11 +1474,169 @@ behavior.click = (event, target, config) => {
|
|
|
1413
1474
|
}
|
|
1414
1475
|
};
|
|
1415
1476
|
|
|
1477
|
+
// src/event/behavior/cut.ts
|
|
1478
|
+
behavior.cut = (event, target, config) => {
|
|
1479
|
+
return () => {
|
|
1480
|
+
if (isEditable(target)) {
|
|
1481
|
+
input(config, target, "", "deleteByCut");
|
|
1482
|
+
}
|
|
1483
|
+
};
|
|
1484
|
+
};
|
|
1485
|
+
|
|
1486
|
+
// src/event/behavior/keydown.ts
|
|
1487
|
+
behavior.keydown = (event, target, config) => {
|
|
1488
|
+
var _a, _b;
|
|
1489
|
+
return (_b = (_a = keydownBehavior[event.key]) == null ? void 0 : _a.call(keydownBehavior, event, target, config)) != null ? _b : combinationBehavior(event, target, config);
|
|
1490
|
+
};
|
|
1491
|
+
var keydownBehavior = {
|
|
1492
|
+
ArrowLeft: (event, target) => () => moveSelection(target, -1),
|
|
1493
|
+
ArrowRight: (event, target) => () => moveSelection(target, 1),
|
|
1494
|
+
Backspace: (event, target, config) => {
|
|
1495
|
+
if (isEditable(target)) {
|
|
1496
|
+
return () => {
|
|
1497
|
+
input(config, target, "", "deleteContentBackward");
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1500
|
+
},
|
|
1501
|
+
Delete: (event, target, config) => {
|
|
1502
|
+
if (isEditable(target)) {
|
|
1503
|
+
return () => {
|
|
1504
|
+
input(config, target, "", "deleteContentForward");
|
|
1505
|
+
};
|
|
1506
|
+
}
|
|
1507
|
+
},
|
|
1508
|
+
End: (event, target) => {
|
|
1509
|
+
if (isElementType(target, ["input", "textarea"]) || isContentEditable(target)) {
|
|
1510
|
+
return () => {
|
|
1511
|
+
var _a, _b;
|
|
1512
|
+
const newPos = (_b = (_a = getValue(target)) == null ? void 0 : _a.length) != null ? _b : 0;
|
|
1513
|
+
setSelectionRange(target, newPos, newPos);
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
},
|
|
1517
|
+
Home: (event, target) => {
|
|
1518
|
+
if (isElementType(target, ["input", "textarea"]) || isContentEditable(target)) {
|
|
1519
|
+
return () => {
|
|
1520
|
+
setSelectionRange(target, 0, 0);
|
|
1521
|
+
};
|
|
1522
|
+
}
|
|
1523
|
+
},
|
|
1524
|
+
PageDown: (event, target) => {
|
|
1525
|
+
if (isElementType(target, ["input"])) {
|
|
1526
|
+
return () => {
|
|
1527
|
+
const newPos = getValue(target).length;
|
|
1528
|
+
setSelectionRange(target, newPos, newPos);
|
|
1529
|
+
};
|
|
1530
|
+
}
|
|
1531
|
+
},
|
|
1532
|
+
PageUp: (event, target) => {
|
|
1533
|
+
if (isElementType(target, ["input"])) {
|
|
1534
|
+
return () => {
|
|
1535
|
+
setSelectionRange(target, 0, 0);
|
|
1536
|
+
};
|
|
1537
|
+
}
|
|
1538
|
+
},
|
|
1539
|
+
Tab: (event, target, { keyboardState }) => {
|
|
1540
|
+
return () => {
|
|
1541
|
+
const dest = getTabDestination(target, keyboardState.modifiers.Shift);
|
|
1542
|
+
focus(dest);
|
|
1543
|
+
if (hasOwnSelection(dest)) {
|
|
1544
|
+
setUISelection(dest, {
|
|
1545
|
+
anchorOffset: 0,
|
|
1546
|
+
focusOffset: dest.value.length
|
|
1547
|
+
});
|
|
1548
|
+
}
|
|
1549
|
+
};
|
|
1550
|
+
}
|
|
1551
|
+
};
|
|
1552
|
+
var combinationBehavior = (event, target, config) => {
|
|
1553
|
+
if (event.code === "KeyA" && config.keyboardState.modifiers.Control) {
|
|
1554
|
+
return () => selectAll(target);
|
|
1555
|
+
}
|
|
1556
|
+
};
|
|
1557
|
+
|
|
1558
|
+
// src/event/behavior/keypress.ts
|
|
1559
|
+
behavior.keypress = (event, target, config) => {
|
|
1560
|
+
if (event.key === "Enter") {
|
|
1561
|
+
if (isElementType(target, "button") || isElementType(target, "input") && ClickInputOnEnter.includes(target.type) || isElementType(target, "a") && Boolean(target.href)) {
|
|
1562
|
+
return () => {
|
|
1563
|
+
dispatchUIEvent(config, target, "click");
|
|
1564
|
+
};
|
|
1565
|
+
} else if (isElementType(target, "input")) {
|
|
1566
|
+
const form = target.form;
|
|
1567
|
+
const submit = form == null ? void 0 : form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]');
|
|
1568
|
+
if (submit) {
|
|
1569
|
+
return () => dispatchUIEvent(config, submit, "click");
|
|
1570
|
+
} else if (form && SubmitSingleInputOnEnter.includes(target.type) && form.querySelectorAll("input").length === 1) {
|
|
1571
|
+
return () => dispatchUIEvent(config, form, "submit");
|
|
1572
|
+
} else {
|
|
1573
|
+
return;
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
if (isEditable(target)) {
|
|
1578
|
+
const inputType = event.key === "Enter" ? isContentEditable(target) && !config.keyboardState.modifiers.Shift ? "insertParagraph" : "insertLineBreak" : "insertText";
|
|
1579
|
+
const inputData = event.key === "Enter" ? "\n" : event.key;
|
|
1580
|
+
return () => input(config, target, inputData, inputType);
|
|
1581
|
+
}
|
|
1582
|
+
};
|
|
1583
|
+
var ClickInputOnEnter = [
|
|
1584
|
+
"button",
|
|
1585
|
+
"color",
|
|
1586
|
+
"file",
|
|
1587
|
+
"image",
|
|
1588
|
+
"reset",
|
|
1589
|
+
"submit"
|
|
1590
|
+
];
|
|
1591
|
+
var SubmitSingleInputOnEnter = [
|
|
1592
|
+
"email",
|
|
1593
|
+
"month",
|
|
1594
|
+
"password",
|
|
1595
|
+
"search",
|
|
1596
|
+
"tel",
|
|
1597
|
+
"text",
|
|
1598
|
+
"url",
|
|
1599
|
+
"week"
|
|
1600
|
+
];
|
|
1601
|
+
|
|
1602
|
+
// src/event/behavior/keyup.ts
|
|
1603
|
+
behavior.keyup = (event, target, config) => {
|
|
1604
|
+
var _a;
|
|
1605
|
+
return (_a = keyupBehavior[event.key]) == null ? void 0 : _a.call(keyupBehavior, event, target, config);
|
|
1606
|
+
};
|
|
1607
|
+
var keyupBehavior = {
|
|
1608
|
+
" ": (event, target, config) => {
|
|
1609
|
+
if (isClickableInput(target)) {
|
|
1610
|
+
return () => dispatchUIEvent(config, target, "click");
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
};
|
|
1614
|
+
|
|
1615
|
+
// src/event/behavior/paste.ts
|
|
1616
|
+
behavior.paste = (event, target, config) => {
|
|
1617
|
+
if (isEditable(target)) {
|
|
1618
|
+
return () => {
|
|
1619
|
+
var _a;
|
|
1620
|
+
const insertData = (_a = event.clipboardData) == null ? void 0 : _a.getData("text");
|
|
1621
|
+
if (insertData) {
|
|
1622
|
+
input(config, target, insertData, "insertFromPaste");
|
|
1623
|
+
}
|
|
1624
|
+
};
|
|
1625
|
+
}
|
|
1626
|
+
};
|
|
1627
|
+
|
|
1628
|
+
// src/event/wrapEvent.ts
|
|
1629
|
+
import { getConfig as getConfig2 } from "@testing-library/dom";
|
|
1630
|
+
function wrapEvent(cb, _element) {
|
|
1631
|
+
return getConfig2().eventWrapper(cb);
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1416
1634
|
// src/event/dispatchEvent.ts
|
|
1417
|
-
function dispatchEvent(config, target, event) {
|
|
1635
|
+
function dispatchEvent(config, target, event, preventDefault = false) {
|
|
1418
1636
|
var _a, _b;
|
|
1419
1637
|
const type3 = event.type;
|
|
1420
|
-
const behaviorImplementation =
|
|
1638
|
+
const behaviorImplementation = preventDefault ? () => {
|
|
1639
|
+
} : (_b = (_a = behavior)[type3]) == null ? void 0 : _b.call(_a, event, target, config);
|
|
1421
1640
|
if (behaviorImplementation) {
|
|
1422
1641
|
event.preventDefault();
|
|
1423
1642
|
let defaultPrevented = false;
|
|
@@ -1429,28 +1648,22 @@ function dispatchEvent(config, target, event) {
|
|
|
1429
1648
|
defaultPrevented = event.cancelable;
|
|
1430
1649
|
}
|
|
1431
1650
|
});
|
|
1432
|
-
target.dispatchEvent(event);
|
|
1651
|
+
wrapEvent(() => target.dispatchEvent(event), target);
|
|
1433
1652
|
if (!defaultPrevented) {
|
|
1434
1653
|
behaviorImplementation();
|
|
1435
1654
|
}
|
|
1436
1655
|
return !defaultPrevented;
|
|
1437
1656
|
}
|
|
1438
|
-
return target.dispatchEvent(event);
|
|
1439
|
-
}
|
|
1440
|
-
|
|
1441
|
-
// src/event/wrapEvent.ts
|
|
1442
|
-
import { getConfig as getConfig2 } from "@testing-library/dom";
|
|
1443
|
-
function wrapEvent(cb, _element) {
|
|
1444
|
-
return getConfig2().eventWrapper(cb);
|
|
1657
|
+
return wrapEvent(() => target.dispatchEvent(event), target);
|
|
1445
1658
|
}
|
|
1446
1659
|
|
|
1447
1660
|
// src/event/index.ts
|
|
1448
|
-
function dispatchUIEvent(config, target, type3, init) {
|
|
1661
|
+
function dispatchUIEvent(config, target, type3, init, preventDefault = false) {
|
|
1449
1662
|
if (isMouseEvent(type3) || isKeyboardEvent(type3)) {
|
|
1450
1663
|
init = __spreadValues(__spreadValues({}, init), getUIEventModifiers(config.keyboardState));
|
|
1451
1664
|
}
|
|
1452
1665
|
const event = createEvent(type3, target, init);
|
|
1453
|
-
return
|
|
1666
|
+
return dispatchEvent(config, target, event, preventDefault);
|
|
1454
1667
|
}
|
|
1455
1668
|
function bindDispatchUIEvent(config) {
|
|
1456
1669
|
return dispatchUIEvent.bind(void 0, config);
|
|
@@ -1631,259 +1844,7 @@ function prepareElement(el) {
|
|
|
1631
1844
|
el[isPrepared] = isPrepared;
|
|
1632
1845
|
}
|
|
1633
1846
|
|
|
1634
|
-
// src/keyboard/
|
|
1635
|
-
var keydownBehavior = [
|
|
1636
|
-
{
|
|
1637
|
-
matches: (keyDef) => keyDef.key === "ArrowLeft" || keyDef.key === "ArrowRight",
|
|
1638
|
-
handle: (keyDef, element) => {
|
|
1639
|
-
if (hasOwnSelection(element)) {
|
|
1640
|
-
const selection = getUISelection(element);
|
|
1641
|
-
setSelection({
|
|
1642
|
-
focusNode: element,
|
|
1643
|
-
focusOffset: selection.startOffset === selection.endOffset ? selection.focusOffset + (keyDef.key === "ArrowLeft" ? -1 : 1) : keyDef.key === "ArrowLeft" ? selection.startOffset : selection.endOffset
|
|
1644
|
-
});
|
|
1645
|
-
} else {
|
|
1646
|
-
const selection = element.ownerDocument.getSelection();
|
|
1647
|
-
if (!selection) {
|
|
1648
|
-
return;
|
|
1649
|
-
}
|
|
1650
|
-
if (selection.isCollapsed) {
|
|
1651
|
-
const nextPosition = getNextCursorPosition(selection.focusNode, selection.focusOffset, keyDef.key === "ArrowLeft" ? -1 : 1);
|
|
1652
|
-
if (nextPosition) {
|
|
1653
|
-
setSelection({
|
|
1654
|
-
focusNode: nextPosition.node,
|
|
1655
|
-
focusOffset: nextPosition.offset
|
|
1656
|
-
});
|
|
1657
|
-
}
|
|
1658
|
-
} else {
|
|
1659
|
-
selection[keyDef.key === "ArrowLeft" ? "collapseToStart" : "collapseToEnd"]();
|
|
1660
|
-
}
|
|
1661
|
-
}
|
|
1662
|
-
}
|
|
1663
|
-
}
|
|
1664
|
-
];
|
|
1665
|
-
|
|
1666
|
-
// src/keyboard/plugins/control.ts
|
|
1667
|
-
var keydownBehavior2 = [
|
|
1668
|
-
{
|
|
1669
|
-
matches: (keyDef, element) => (keyDef.key === "Home" || keyDef.key === "End") && (isElementType(element, ["input", "textarea"]) || isContentEditable(element)),
|
|
1670
|
-
handle: (keyDef, element) => {
|
|
1671
|
-
var _a, _b;
|
|
1672
|
-
if (keyDef.key === "Home") {
|
|
1673
|
-
setSelectionRange(element, 0, 0);
|
|
1674
|
-
} else {
|
|
1675
|
-
const newPos = (_b = (_a = getValue(element)) == null ? void 0 : _a.length) != null ? _b : 0;
|
|
1676
|
-
setSelectionRange(element, newPos, newPos);
|
|
1677
|
-
}
|
|
1678
|
-
}
|
|
1679
|
-
},
|
|
1680
|
-
{
|
|
1681
|
-
matches: (keyDef, element) => (keyDef.key === "PageUp" || keyDef.key === "PageDown") && isElementType(element, ["input"]),
|
|
1682
|
-
handle: (keyDef, element) => {
|
|
1683
|
-
var _a, _b;
|
|
1684
|
-
if (keyDef.key === "PageUp") {
|
|
1685
|
-
setSelectionRange(element, 0, 0);
|
|
1686
|
-
} else {
|
|
1687
|
-
const newPos = (_b = (_a = getValue(element)) == null ? void 0 : _a.length) != null ? _b : 0;
|
|
1688
|
-
setSelectionRange(element, newPos, newPos);
|
|
1689
|
-
}
|
|
1690
|
-
}
|
|
1691
|
-
},
|
|
1692
|
-
{
|
|
1693
|
-
matches: (keyDef, element) => keyDef.key === "Delete" && isEditable(element),
|
|
1694
|
-
handle: (keDef, element, config) => {
|
|
1695
|
-
var _a;
|
|
1696
|
-
(_a = prepareInput(config, "", element, "deleteContentForward")) == null ? void 0 : _a.commit();
|
|
1697
|
-
}
|
|
1698
|
-
}
|
|
1699
|
-
];
|
|
1700
|
-
|
|
1701
|
-
// src/keyboard/shared/fireChangeForInputTimeIfValid.ts
|
|
1702
|
-
function fireChangeForInputTimeIfValid(config, el, prevValue, timeNewEntry) {
|
|
1703
|
-
if (isValidInputTimeValue(el, timeNewEntry) && prevValue !== timeNewEntry) {
|
|
1704
|
-
setUIValue(el, timeNewEntry);
|
|
1705
|
-
dispatchUIEvent(config, el, "change");
|
|
1706
|
-
}
|
|
1707
|
-
}
|
|
1708
|
-
|
|
1709
|
-
// src/keyboard/plugins/character.ts
|
|
1710
|
-
var keypressBehavior = [
|
|
1711
|
-
{
|
|
1712
|
-
matches: (keyDef, element) => {
|
|
1713
|
-
var _a;
|
|
1714
|
-
return ((_a = keyDef.key) == null ? void 0 : _a.length) === 1 && isElementType(element, "input", { type: "time", readOnly: false });
|
|
1715
|
-
},
|
|
1716
|
-
handle: (keyDef, element, config) => {
|
|
1717
|
-
var _a;
|
|
1718
|
-
let newEntry = keyDef.key;
|
|
1719
|
-
const textToBeTyped = ((_a = config.keyboardState.carryValue) != null ? _a : "") + newEntry;
|
|
1720
|
-
const timeNewEntry = buildTimeValue(textToBeTyped);
|
|
1721
|
-
if (isValidInputTimeValue(element, timeNewEntry)) {
|
|
1722
|
-
newEntry = timeNewEntry;
|
|
1723
|
-
}
|
|
1724
|
-
const { newValue, newOffset } = calculateNewValue(newEntry, element, getInputRange(element));
|
|
1725
|
-
const prevValue = getValue(element);
|
|
1726
|
-
if (prevValue !== newValue) {
|
|
1727
|
-
editInputElement(config, element, {
|
|
1728
|
-
newValue,
|
|
1729
|
-
newSelection: {
|
|
1730
|
-
node: element,
|
|
1731
|
-
offset: newOffset
|
|
1732
|
-
},
|
|
1733
|
-
eventOverrides: {
|
|
1734
|
-
data: keyDef.key,
|
|
1735
|
-
inputType: "insertText"
|
|
1736
|
-
}
|
|
1737
|
-
});
|
|
1738
|
-
}
|
|
1739
|
-
fireChangeForInputTimeIfValid(config, element, prevValue, timeNewEntry);
|
|
1740
|
-
config.keyboardState.carryValue = textToBeTyped;
|
|
1741
|
-
}
|
|
1742
|
-
},
|
|
1743
|
-
{
|
|
1744
|
-
matches: (keyDef, element) => {
|
|
1745
|
-
var _a;
|
|
1746
|
-
return ((_a = keyDef.key) == null ? void 0 : _a.length) === 1 && isElementType(element, "input", { type: "date", readOnly: false });
|
|
1747
|
-
},
|
|
1748
|
-
handle: (keyDef, element, config) => {
|
|
1749
|
-
var _a;
|
|
1750
|
-
let newEntry = keyDef.key;
|
|
1751
|
-
const textToBeTyped = ((_a = config.keyboardState.carryValue) != null ? _a : "") + newEntry;
|
|
1752
|
-
const isValidToBeTyped = isValidDateValue(element, textToBeTyped);
|
|
1753
|
-
if (isValidToBeTyped) {
|
|
1754
|
-
newEntry = textToBeTyped;
|
|
1755
|
-
}
|
|
1756
|
-
const { newValue, newOffset } = calculateNewValue(newEntry, element, getInputRange(element));
|
|
1757
|
-
const prevValue = getValue(element);
|
|
1758
|
-
if (prevValue !== newValue) {
|
|
1759
|
-
editInputElement(config, element, {
|
|
1760
|
-
newValue,
|
|
1761
|
-
newSelection: {
|
|
1762
|
-
node: element,
|
|
1763
|
-
offset: newOffset
|
|
1764
|
-
},
|
|
1765
|
-
eventOverrides: {
|
|
1766
|
-
data: keyDef.key,
|
|
1767
|
-
inputType: "insertText"
|
|
1768
|
-
}
|
|
1769
|
-
});
|
|
1770
|
-
}
|
|
1771
|
-
if (isValidToBeTyped) {
|
|
1772
|
-
setUIValue(element, textToBeTyped);
|
|
1773
|
-
dispatchUIEvent(config, element, "change");
|
|
1774
|
-
}
|
|
1775
|
-
config.keyboardState.carryValue = textToBeTyped;
|
|
1776
|
-
}
|
|
1777
|
-
},
|
|
1778
|
-
{
|
|
1779
|
-
matches: (keyDef, element) => {
|
|
1780
|
-
var _a;
|
|
1781
|
-
return ((_a = keyDef.key) == null ? void 0 : _a.length) === 1 && isElementType(element, "input", { type: "number", readOnly: false });
|
|
1782
|
-
},
|
|
1783
|
-
handle: (keyDef, element, config) => {
|
|
1784
|
-
var _a, _b;
|
|
1785
|
-
if (!/[\d.\-e]/.test(keyDef.key)) {
|
|
1786
|
-
return;
|
|
1787
|
-
}
|
|
1788
|
-
const { getNewValue, commit } = prepareInput(config, keyDef.key, element);
|
|
1789
|
-
const newValue = getNewValue();
|
|
1790
|
-
const valueParts = newValue.split("e", 2);
|
|
1791
|
-
if (Number((_a = newValue.match(/-/g)) == null ? void 0 : _a.length) > 2 || Number((_b = newValue.match(/\./g)) == null ? void 0 : _b.length) > 1 || valueParts[1] && !/^-?\d*$/.test(valueParts[1])) {
|
|
1792
|
-
return;
|
|
1793
|
-
}
|
|
1794
|
-
commit();
|
|
1795
|
-
}
|
|
1796
|
-
},
|
|
1797
|
-
{
|
|
1798
|
-
matches: (keyDef, element) => {
|
|
1799
|
-
var _a;
|
|
1800
|
-
return ((_a = keyDef.key) == null ? void 0 : _a.length) === 1 && (isEditableInput(element) || isElementType(element, "textarea", { readOnly: false }) || isContentEditable(element)) && getSpaceUntilMaxLength(element) !== 0;
|
|
1801
|
-
},
|
|
1802
|
-
handle: (keyDef, element, config) => {
|
|
1803
|
-
var _a;
|
|
1804
|
-
(_a = prepareInput(config, keyDef.key, element)) == null ? void 0 : _a.commit();
|
|
1805
|
-
}
|
|
1806
|
-
},
|
|
1807
|
-
{
|
|
1808
|
-
matches: (keyDef, element) => keyDef.key === "Enter" && (isElementType(element, "textarea", { readOnly: false }) || isContentEditable(element)) && getSpaceUntilMaxLength(element) !== 0,
|
|
1809
|
-
handle: (keyDef, element, config) => {
|
|
1810
|
-
var _a;
|
|
1811
|
-
(_a = prepareInput(config, "\n", element, isContentEditable(element) && !config.keyboardState.modifiers.Shift ? "insertParagraph" : "insertLineBreak")) == null ? void 0 : _a.commit();
|
|
1812
|
-
}
|
|
1813
|
-
}
|
|
1814
|
-
];
|
|
1815
|
-
|
|
1816
|
-
// src/keyboard/plugins/functional.ts
|
|
1817
|
-
var keydownBehavior3 = [
|
|
1818
|
-
{
|
|
1819
|
-
matches: (keyDef, element) => keyDef.key === "Backspace" && isEditable(element),
|
|
1820
|
-
handle: (keyDef, element, config) => {
|
|
1821
|
-
var _a;
|
|
1822
|
-
(_a = prepareInput(config, "", element, "deleteContentBackward")) == null ? void 0 : _a.commit();
|
|
1823
|
-
}
|
|
1824
|
-
},
|
|
1825
|
-
{
|
|
1826
|
-
matches: (keyDef) => keyDef.key === "Tab",
|
|
1827
|
-
handle: (keyDef, element, { keyboardState }) => {
|
|
1828
|
-
const dest = getTabDestination(element, keyboardState.modifiers.Shift);
|
|
1829
|
-
if (dest === element.ownerDocument.body) {
|
|
1830
|
-
blur(element);
|
|
1831
|
-
} else {
|
|
1832
|
-
focus(dest);
|
|
1833
|
-
if (isElementType(dest, ["input", "textarea"])) {
|
|
1834
|
-
setUISelection(dest, {
|
|
1835
|
-
anchorOffset: 0,
|
|
1836
|
-
focusOffset: dest.value.length
|
|
1837
|
-
});
|
|
1838
|
-
}
|
|
1839
|
-
}
|
|
1840
|
-
}
|
|
1841
|
-
}
|
|
1842
|
-
];
|
|
1843
|
-
var keypressBehavior2 = [
|
|
1844
|
-
{
|
|
1845
|
-
matches: (keyDef, element) => keyDef.key === "Enter" && isElementType(element, "input") && ["checkbox", "radio"].includes(element.type),
|
|
1846
|
-
handle: (keyDef, element, config) => {
|
|
1847
|
-
const form = element.form;
|
|
1848
|
-
if (hasFormSubmit(form)) {
|
|
1849
|
-
dispatchUIEvent(config, form, "submit");
|
|
1850
|
-
}
|
|
1851
|
-
}
|
|
1852
|
-
},
|
|
1853
|
-
{
|
|
1854
|
-
matches: (keyDef, element) => keyDef.key === "Enter" && (isClickableInput(element) || isElementType(element, "a") && Boolean(element.href)),
|
|
1855
|
-
handle: (keyDef, element, config) => {
|
|
1856
|
-
dispatchUIEvent(config, element, "click");
|
|
1857
|
-
}
|
|
1858
|
-
},
|
|
1859
|
-
{
|
|
1860
|
-
matches: (keyDef, element) => keyDef.key === "Enter" && isElementType(element, "input"),
|
|
1861
|
-
handle: (keyDef, element, config) => {
|
|
1862
|
-
const form = element.form;
|
|
1863
|
-
if (form && (form.querySelectorAll("input").length === 1 || hasFormSubmit(form))) {
|
|
1864
|
-
dispatchUIEvent(config, form, "submit");
|
|
1865
|
-
}
|
|
1866
|
-
}
|
|
1867
|
-
}
|
|
1868
|
-
];
|
|
1869
|
-
var keyupBehavior = [
|
|
1870
|
-
{
|
|
1871
|
-
matches: (keyDef, element) => keyDef.key === " " && isClickableInput(element),
|
|
1872
|
-
handle: (keyDef, element, config) => {
|
|
1873
|
-
dispatchUIEvent(config, element, "click");
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
];
|
|
1877
|
-
|
|
1878
|
-
// src/keyboard/plugins/combination.ts
|
|
1879
|
-
var keydownBehavior4 = [
|
|
1880
|
-
{
|
|
1881
|
-
matches: (keyDef, element, { keyboardState }) => keyDef.code === "KeyA" && keyboardState.modifiers.Control,
|
|
1882
|
-
handle: (keyDef, element) => selectAll(element)
|
|
1883
|
-
}
|
|
1884
|
-
];
|
|
1885
|
-
|
|
1886
|
-
// src/keyboard/plugins/modifiers.ts
|
|
1847
|
+
// src/keyboard/modifiers.ts
|
|
1887
1848
|
var modifierKeys = [
|
|
1888
1849
|
"Alt",
|
|
1889
1850
|
"AltGraph",
|
|
@@ -1893,6 +1854,9 @@ var modifierKeys = [
|
|
|
1893
1854
|
"Shift",
|
|
1894
1855
|
"Symbol"
|
|
1895
1856
|
];
|
|
1857
|
+
function isModifierKey(key) {
|
|
1858
|
+
return modifierKeys.includes(key);
|
|
1859
|
+
}
|
|
1896
1860
|
var modifierLocks = [
|
|
1897
1861
|
"CapsLock",
|
|
1898
1862
|
"FnLock",
|
|
@@ -1900,78 +1864,40 @@ var modifierLocks = [
|
|
|
1900
1864
|
"ScrollLock",
|
|
1901
1865
|
"SymbolLock"
|
|
1902
1866
|
];
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1867
|
+
function isModifierLock(key) {
|
|
1868
|
+
return modifierLocks.includes(key);
|
|
1869
|
+
}
|
|
1870
|
+
function preKeydownBehavior(config, { key }, element) {
|
|
1871
|
+
var _a;
|
|
1872
|
+
if (isModifierKey(key)) {
|
|
1873
|
+
config.keyboardState.modifiers[key] = true;
|
|
1874
|
+
if (key === "AltGraph") {
|
|
1875
|
+
const ctrlKeyDef = (_a = config.keyboardMap.find((k) => k.key === "Control")) != null ? _a : { key: "Control", code: "Control" };
|
|
1876
|
+
dispatchUIEvent(config, element, "keydown", getKeyEventProps(ctrlKeyDef));
|
|
1913
1877
|
}
|
|
1914
|
-
}
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
const key = keyDef.key;
|
|
1919
|
-
keyboardState.modifierPhase[key] = keyboardState.modifiers[key];
|
|
1920
|
-
if (!keyboardState.modifierPhase[key]) {
|
|
1921
|
-
keyboardState.modifiers[key] = true;
|
|
1922
|
-
}
|
|
1878
|
+
} else if (isModifierLock(key)) {
|
|
1879
|
+
config.keyboardState.modifierPhase[key] = config.keyboardState.modifiers[key];
|
|
1880
|
+
if (!config.keyboardState.modifierPhase[key]) {
|
|
1881
|
+
config.keyboardState.modifiers[key] = true;
|
|
1923
1882
|
}
|
|
1924
1883
|
}
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
{
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
},
|
|
1933
|
-
{
|
|
1934
|
-
matches: (keyDef) => modifierLocks.includes(keyDef.key),
|
|
1935
|
-
handle: (keyDef, element, { keyboardState }) => {
|
|
1936
|
-
const key = keyDef.key;
|
|
1937
|
-
if (keyboardState.modifierPhase[key]) {
|
|
1938
|
-
keyboardState.modifiers[key] = false;
|
|
1939
|
-
}
|
|
1884
|
+
}
|
|
1885
|
+
function preKeyupBehavior(config, { key }) {
|
|
1886
|
+
if (isModifierKey(key)) {
|
|
1887
|
+
config.keyboardState.modifiers[key] = false;
|
|
1888
|
+
} else if (isModifierLock(key)) {
|
|
1889
|
+
if (config.keyboardState.modifierPhase[key]) {
|
|
1890
|
+
config.keyboardState.modifiers[key] = false;
|
|
1940
1891
|
}
|
|
1941
1892
|
}
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
const ctrlKeyDef = (_a = config.keyboardMap.find((k) => k.key === "Control")) != null ? _a : { key: "Control", code: "Control" };
|
|
1949
|
-
dispatchUIEvent(config, element, "keyup", getKeyEventProps(ctrlKeyDef));
|
|
1950
|
-
}
|
|
1893
|
+
}
|
|
1894
|
+
function postKeyupBehavior(config, { key }, element) {
|
|
1895
|
+
var _a;
|
|
1896
|
+
if (key === "AltGraph") {
|
|
1897
|
+
const ctrlKeyDef = (_a = config.keyboardMap.find((k) => k.key === "Control")) != null ? _a : { key: "Control", code: "Control" };
|
|
1898
|
+
dispatchUIEvent(config, element, "keyup", getKeyEventProps(ctrlKeyDef));
|
|
1951
1899
|
}
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
// src/keyboard/plugins/index.ts
|
|
1955
|
-
var preKeydownBehavior2 = [
|
|
1956
|
-
...preKeydownBehavior
|
|
1957
|
-
];
|
|
1958
|
-
var keydownBehavior5 = [
|
|
1959
|
-
...keydownBehavior,
|
|
1960
|
-
...keydownBehavior2,
|
|
1961
|
-
...keydownBehavior3,
|
|
1962
|
-
...keydownBehavior4
|
|
1963
|
-
];
|
|
1964
|
-
var keypressBehavior3 = [
|
|
1965
|
-
...keypressBehavior2,
|
|
1966
|
-
...keypressBehavior
|
|
1967
|
-
];
|
|
1968
|
-
var preKeyupBehavior2 = [
|
|
1969
|
-
...preKeyupBehavior
|
|
1970
|
-
];
|
|
1971
|
-
var keyupBehavior2 = [...keyupBehavior];
|
|
1972
|
-
var postKeyupBehavior2 = [
|
|
1973
|
-
...postKeyupBehavior
|
|
1974
|
-
];
|
|
1900
|
+
}
|
|
1975
1901
|
|
|
1976
1902
|
// src/keyboard/keyboardAction.ts
|
|
1977
1903
|
function keyboardAction(config, actions) {
|
|
@@ -2029,45 +1955,29 @@ function keydown(keyDef, getCurrentElement, config) {
|
|
|
2029
1955
|
config.keyboardState.carryChar = "";
|
|
2030
1956
|
}
|
|
2031
1957
|
config.keyboardState.activeElement = element;
|
|
2032
|
-
|
|
1958
|
+
preKeydownBehavior(config, keyDef, element);
|
|
2033
1959
|
const unpreventedDefault = dispatchUIEvent(config, element, "keydown", getKeyEventProps(keyDef));
|
|
2034
1960
|
config.keyboardState.pressed.push({ keyDef, unpreventedDefault });
|
|
2035
|
-
if (unpreventedDefault) {
|
|
2036
|
-
applyPlugins(keydownBehavior5, keyDef, getCurrentElement(), config);
|
|
2037
|
-
}
|
|
2038
1961
|
return unpreventedDefault;
|
|
2039
1962
|
});
|
|
2040
1963
|
}
|
|
2041
1964
|
function keypress(keyDef, getCurrentElement, config) {
|
|
2042
1965
|
return __async(this, null, function* () {
|
|
2043
1966
|
const element = getCurrentElement();
|
|
2044
|
-
|
|
1967
|
+
dispatchUIEvent(config, element, "keypress", __spreadProps(__spreadValues({}, getKeyEventProps(keyDef)), {
|
|
2045
1968
|
charCode: keyDef.key === "Enter" ? 13 : String(keyDef.key).charCodeAt(0)
|
|
2046
1969
|
}));
|
|
2047
|
-
if (unpreventedDefault) {
|
|
2048
|
-
applyPlugins(keypressBehavior3, keyDef, getCurrentElement(), config);
|
|
2049
|
-
}
|
|
2050
1970
|
});
|
|
2051
1971
|
}
|
|
2052
1972
|
function keyup(keyDef, getCurrentElement, config, unprevented) {
|
|
2053
1973
|
return __async(this, null, function* () {
|
|
2054
1974
|
const element = getCurrentElement();
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
if (unprevented && unpreventedDefault) {
|
|
2058
|
-
applyPlugins(keyupBehavior2, keyDef, getCurrentElement(), config);
|
|
2059
|
-
}
|
|
1975
|
+
preKeyupBehavior(config, keyDef);
|
|
1976
|
+
dispatchUIEvent(config, element, "keyup", getKeyEventProps(keyDef), !unprevented);
|
|
2060
1977
|
config.keyboardState.pressed = config.keyboardState.pressed.filter((k) => k.keyDef !== keyDef);
|
|
2061
|
-
|
|
1978
|
+
postKeyupBehavior(config, keyDef, element);
|
|
2062
1979
|
});
|
|
2063
1980
|
}
|
|
2064
|
-
function applyPlugins(pluginCollection, keyDef, element, config) {
|
|
2065
|
-
const plugin = pluginCollection.find((p) => p.matches(keyDef, element, config));
|
|
2066
|
-
if (plugin) {
|
|
2067
|
-
plugin.handle(keyDef, element, config);
|
|
2068
|
-
}
|
|
2069
|
-
return !!plugin;
|
|
2070
|
-
}
|
|
2071
1981
|
function hasKeyPress(keyDef, config) {
|
|
2072
1982
|
var _a;
|
|
2073
1983
|
return (((_a = keyDef.key) == null ? void 0 : _a.length) === 1 || keyDef.key === "Enter") && !config.keyboardState.modifiers.Control && !config.keyboardState.modifiers.Alt;
|
|
@@ -2085,7 +1995,7 @@ function parseKeyDef(keyboardMap, text) {
|
|
|
2085
1995
|
releasePrevious,
|
|
2086
1996
|
releaseSelf = true,
|
|
2087
1997
|
repeat
|
|
2088
|
-
} = readNextDescriptor(text);
|
|
1998
|
+
} = readNextDescriptor(text, "keyboard");
|
|
2089
1999
|
const keyDef = (_a = keyboardMap.find((def) => {
|
|
2090
2000
|
var _a2, _b;
|
|
2091
2001
|
if (type3 === "[") {
|
|
@@ -2144,7 +2054,7 @@ function parseKeyDef2(pointerMap, keys) {
|
|
|
2144
2054
|
consumedLength,
|
|
2145
2055
|
releasePrevious,
|
|
2146
2056
|
releaseSelf = true
|
|
2147
|
-
} = readNextDescriptor(keys);
|
|
2057
|
+
} = readNextDescriptor(keys, "pointer");
|
|
2148
2058
|
const keyDef = pointerMap.find((p) => p.name === descriptor);
|
|
2149
2059
|
if (keyDef) {
|
|
2150
2060
|
defs.push({ keyDef, releasePrevious, releaseSelf });
|
|
@@ -2567,11 +2477,11 @@ function getPrevTarget(pointerName, state) {
|
|
|
2567
2477
|
}
|
|
2568
2478
|
|
|
2569
2479
|
// src/pointer/index.ts
|
|
2570
|
-
function pointer(
|
|
2480
|
+
function pointer(input2) {
|
|
2571
2481
|
return __async(this, null, function* () {
|
|
2572
2482
|
const { pointerMap } = this[Config];
|
|
2573
2483
|
const actions = [];
|
|
2574
|
-
(Array.isArray(
|
|
2484
|
+
(Array.isArray(input2) ? input2 : [input2]).forEach((actionInput) => {
|
|
2575
2485
|
if (typeof actionInput === "string") {
|
|
2576
2486
|
actions.push(...parseKeyDef2(pointerMap, actionInput));
|
|
2577
2487
|
} else if ("keys" in actionInput) {
|
|
@@ -2684,10 +2594,9 @@ function copy() {
|
|
|
2684
2594
|
if (clipboardData.items.length === 0) {
|
|
2685
2595
|
return;
|
|
2686
2596
|
}
|
|
2687
|
-
this.dispatchUIEvent(target, "copy", {
|
|
2597
|
+
if (this.dispatchUIEvent(target, "copy", {
|
|
2688
2598
|
clipboardData
|
|
2689
|
-
})
|
|
2690
|
-
if (this[Config].writeToClipboard) {
|
|
2599
|
+
}) && this[Config].writeToClipboard) {
|
|
2691
2600
|
yield writeDataTransferToClipboard(doc, clipboardData);
|
|
2692
2601
|
}
|
|
2693
2602
|
return clipboardData;
|
|
@@ -2697,21 +2606,17 @@ function copy() {
|
|
|
2697
2606
|
// src/clipboard/cut.ts
|
|
2698
2607
|
function cut() {
|
|
2699
2608
|
return __async(this, null, function* () {
|
|
2700
|
-
var _a
|
|
2609
|
+
var _a;
|
|
2701
2610
|
const doc = this[Config].document;
|
|
2702
2611
|
const target = (_a = doc.activeElement) != null ? _a : doc.body;
|
|
2703
2612
|
const clipboardData = copySelection(target);
|
|
2704
2613
|
if (clipboardData.items.length === 0) {
|
|
2705
2614
|
return;
|
|
2706
2615
|
}
|
|
2707
|
-
this.dispatchUIEvent(target, "cut", {
|
|
2616
|
+
if (this.dispatchUIEvent(target, "cut", {
|
|
2708
2617
|
clipboardData
|
|
2709
|
-
})
|
|
2710
|
-
|
|
2711
|
-
(_b = prepareInput(this[Config], "", target, "deleteByCut")) == null ? void 0 : _b.commit();
|
|
2712
|
-
}
|
|
2713
|
-
if (this[Config].writeToClipboard) {
|
|
2714
|
-
yield writeDataTransferToClipboard(doc, clipboardData);
|
|
2618
|
+
}) && this[Config].writeToClipboard) {
|
|
2619
|
+
yield writeDataTransferToClipboard(target.ownerDocument, clipboardData);
|
|
2715
2620
|
}
|
|
2716
2621
|
return clipboardData;
|
|
2717
2622
|
});
|
|
@@ -2720,7 +2625,7 @@ function cut() {
|
|
|
2720
2625
|
// src/clipboard/paste.ts
|
|
2721
2626
|
function paste(clipboardData) {
|
|
2722
2627
|
return __async(this, null, function* () {
|
|
2723
|
-
var _a, _b
|
|
2628
|
+
var _a, _b;
|
|
2724
2629
|
const doc = this[Config].document;
|
|
2725
2630
|
const target = (_a = doc.activeElement) != null ? _a : doc.body;
|
|
2726
2631
|
const dataTransfer = (_b = typeof clipboardData === "string" ? getClipboardDataFromString(clipboardData) : clipboardData) != null ? _b : yield readDataTransferFromClipboard(doc).catch(() => {
|
|
@@ -2729,12 +2634,6 @@ function paste(clipboardData) {
|
|
|
2729
2634
|
this.dispatchUIEvent(target, "paste", {
|
|
2730
2635
|
clipboardData: dataTransfer
|
|
2731
2636
|
});
|
|
2732
|
-
if (isEditable(target)) {
|
|
2733
|
-
const textData = dataTransfer.getData("text").substr(0, getSpaceUntilMaxLength(target));
|
|
2734
|
-
if (textData) {
|
|
2735
|
-
(_c = prepareInput(this[Config], textData, target, "insertFromPaste")) == null ? void 0 : _c.commit();
|
|
2736
|
-
}
|
|
2737
|
-
}
|
|
2738
2637
|
});
|
|
2739
2638
|
}
|
|
2740
2639
|
function getClipboardDataFromString(text) {
|
|
@@ -2746,7 +2645,6 @@ function getClipboardDataFromString(text) {
|
|
|
2746
2645
|
// src/utility/clear.ts
|
|
2747
2646
|
function clear(element) {
|
|
2748
2647
|
return __async(this, null, function* () {
|
|
2749
|
-
var _a;
|
|
2750
2648
|
if (!isEditable(element) || isDisabled(element)) {
|
|
2751
2649
|
throw new Error("clear()` is only supported on editable elements.");
|
|
2752
2650
|
}
|
|
@@ -2758,7 +2656,7 @@ function clear(element) {
|
|
|
2758
2656
|
if (!isAllSelected(element)) {
|
|
2759
2657
|
throw new Error("The element content to be cleared could not be selected.");
|
|
2760
2658
|
}
|
|
2761
|
-
(
|
|
2659
|
+
input(this[Config], element, "", "deleteContentBackward");
|
|
2762
2660
|
});
|
|
2763
2661
|
}
|
|
2764
2662
|
|
|
@@ -2885,28 +2783,28 @@ function type(_0, _1) {
|
|
|
2885
2783
|
// src/utility/upload.ts
|
|
2886
2784
|
function upload(element, fileOrFiles) {
|
|
2887
2785
|
return __async(this, null, function* () {
|
|
2888
|
-
const
|
|
2889
|
-
if (!
|
|
2890
|
-
throw new TypeError(`The ${
|
|
2786
|
+
const input2 = isElementType(element, "label") ? element.control : element;
|
|
2787
|
+
if (!input2 || !isElementType(input2, "input", { type: "file" })) {
|
|
2788
|
+
throw new TypeError(`The ${input2 === element ? "given" : "associated"} ${input2 == null ? void 0 : input2.tagName} element does not accept file uploads`);
|
|
2891
2789
|
}
|
|
2892
2790
|
if (isDisabled(element))
|
|
2893
2791
|
return;
|
|
2894
|
-
const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [fileOrFiles]).filter((file) => !this[Config].applyAccept || isAcceptableFile(file,
|
|
2792
|
+
const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [fileOrFiles]).filter((file) => !this[Config].applyAccept || isAcceptableFile(file, input2.accept)).slice(0, input2.multiple ? void 0 : 1);
|
|
2895
2793
|
const fileDialog = () => {
|
|
2896
2794
|
var _a;
|
|
2897
|
-
if (files.length === ((_a =
|
|
2795
|
+
if (files.length === ((_a = input2.files) == null ? void 0 : _a.length) && files.every((f, i) => {
|
|
2898
2796
|
var _a2;
|
|
2899
|
-
return f === ((_a2 =
|
|
2797
|
+
return f === ((_a2 = input2.files) == null ? void 0 : _a2.item(i));
|
|
2900
2798
|
})) {
|
|
2901
2799
|
return;
|
|
2902
2800
|
}
|
|
2903
|
-
setFiles(
|
|
2904
|
-
this.dispatchUIEvent(
|
|
2905
|
-
this.dispatchUIEvent(
|
|
2801
|
+
setFiles(input2, createFileList(files));
|
|
2802
|
+
this.dispatchUIEvent(input2, "input");
|
|
2803
|
+
this.dispatchUIEvent(input2, "change");
|
|
2906
2804
|
};
|
|
2907
|
-
|
|
2805
|
+
input2.addEventListener("fileDialog", fileDialog);
|
|
2908
2806
|
yield this.click(element);
|
|
2909
|
-
|
|
2807
|
+
input2.removeEventListener("fileDialog", fileDialog);
|
|
2910
2808
|
});
|
|
2911
2809
|
}
|
|
2912
2810
|
function isAcceptableFile(file, accept) {
|
|
@@ -3035,9 +2933,9 @@ function keyboard2(_0) {
|
|
|
3035
2933
|
});
|
|
3036
2934
|
}
|
|
3037
2935
|
function pointer2(_0) {
|
|
3038
|
-
return __async(this, arguments, function* (
|
|
2936
|
+
return __async(this, arguments, function* (input2, options = {}) {
|
|
3039
2937
|
const { config, api } = setupDirect(options);
|
|
3040
|
-
return api.pointer(
|
|
2938
|
+
return api.pointer(input2).then(() => config.pointerState);
|
|
3041
2939
|
});
|
|
3042
2940
|
}
|
|
3043
2941
|
function paste2(clipboardData, options) {
|