@wordpress/dom 3.38.0 → 3.40.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/CHANGELOG.md +4 -0
- package/README.md +2 -2
- package/build/data-transfer.js +0 -2
- package/build/data-transfer.js.map +1 -1
- package/build/dom/caret-range-from-point.js +3 -5
- package/build/dom/caret-range-from-point.js.map +1 -1
- package/build/dom/clean-node-list.js +25 -42
- package/build/dom/clean-node-list.js.map +1 -1
- package/build/dom/compute-caret-rect.js +0 -6
- package/build/dom/compute-caret-rect.js.map +1 -1
- package/build/dom/document-has-selection.js +0 -5
- package/build/dom/document-has-selection.js.map +1 -1
- package/build/dom/document-has-text-selection.js +0 -2
- package/build/dom/document-has-text-selection.js.map +1 -1
- package/build/dom/document-has-uncollapsed-selection.js +0 -4
- package/build/dom/document-has-uncollapsed-selection.js.map +1 -1
- package/build/dom/get-computed-style.js +0 -3
- package/build/dom/get-computed-style.js.map +1 -1
- package/build/dom/get-offset-parent.js +8 -19
- package/build/dom/get-offset-parent.js.map +1 -1
- package/build/dom/get-range-height.js +0 -3
- package/build/dom/get-range-height.js.map +1 -1
- package/build/dom/get-rectangle-from-range.js +15 -22
- package/build/dom/get-rectangle-from-range.js.map +1 -1
- package/build/dom/get-scroll-container.js +3 -13
- package/build/dom/get-scroll-container.js.map +1 -1
- package/build/dom/hidden-caret-range-from-point.js +2 -6
- package/build/dom/hidden-caret-range-from-point.js.map +1 -1
- package/build/dom/index.js +0 -27
- package/build/dom/index.js.map +1 -1
- package/build/dom/input-field-has-uncollapsed-selection.js +8 -12
- package/build/dom/input-field-has-uncollapsed-selection.js.map +1 -1
- package/build/dom/insert-after.js +0 -2
- package/build/dom/insert-after.js.map +1 -1
- package/build/dom/is-edge.js +18 -40
- package/build/dom/is-edge.js.map +1 -1
- package/build/dom/is-element.js +0 -2
- package/build/dom/is-element.js.map +1 -1
- package/build/dom/is-empty.js +1 -7
- package/build/dom/is-empty.js.map +1 -1
- package/build/dom/is-entirely-selected.js +2 -18
- package/build/dom/is-entirely-selected.js.map +1 -1
- package/build/dom/is-form-element.js +0 -4
- package/build/dom/is-form-element.js.map +1 -1
- package/build/dom/is-horizontal-edge.js +2 -5
- package/build/dom/is-horizontal-edge.js.map +1 -1
- package/build/dom/is-html-input-element.js +0 -2
- package/build/dom/is-html-input-element.js.map +1 -1
- package/build/dom/is-input-or-text-area.js +0 -2
- package/build/dom/is-input-or-text-area.js.map +1 -1
- package/build/dom/is-number-input.js +0 -6
- package/build/dom/is-number-input.js.map +1 -1
- package/build/dom/is-rtl.js +0 -3
- package/build/dom/is-rtl.js.map +1 -1
- package/build/dom/is-selection-forward.js +6 -10
- package/build/dom/is-selection-forward.js.map +1 -1
- package/build/dom/is-text-field.js +1 -7
- package/build/dom/is-text-field.js.map +1 -1
- package/build/dom/is-vertical-edge.js +2 -5
- package/build/dom/is-vertical-edge.js.map +1 -1
- package/build/dom/place-caret-at-edge.js +8 -31
- package/build/dom/place-caret-at-edge.js.map +1 -1
- package/build/dom/place-caret-at-horizontal-edge.js +0 -3
- package/build/dom/place-caret-at-horizontal-edge.js.map +1 -1
- package/build/dom/place-caret-at-vertical-edge.js +0 -3
- package/build/dom/place-caret-at-vertical-edge.js.map +1 -1
- package/build/dom/remove-invalid-html.js +0 -3
- package/build/dom/remove-invalid-html.js.map +1 -1
- package/build/dom/remove.js +0 -2
- package/build/dom/remove.js.map +1 -1
- package/build/dom/replace-tag.js +0 -4
- package/build/dom/replace-tag.js.map +1 -1
- package/build/dom/replace.js +0 -5
- package/build/dom/replace.js.map +1 -1
- package/build/dom/safe-html.js +0 -8
- package/build/dom/safe-html.js.map +1 -1
- package/build/dom/scroll-if-no-range.js +31 -0
- package/build/dom/scroll-if-no-range.js.map +1 -0
- package/build/dom/strip-html.js +0 -3
- package/build/dom/strip-html.js.map +1 -1
- package/build/dom/unwrap.js +0 -4
- package/build/dom/unwrap.js.map +1 -1
- package/build/dom/wrap.js +0 -2
- package/build/dom/wrap.js.map +1 -1
- package/build/focusable.js +5 -18
- package/build/focusable.js.map +1 -1
- package/build/index.js +0 -11
- package/build/index.js.map +1 -1
- package/build/phrasing-content.js +13 -14
- package/build/phrasing-content.js.map +1 -1
- package/build/tabbable.js +21 -37
- package/build/tabbable.js.map +1 -1
- package/build/utils/assert-is-defined.js +0 -1
- package/build/utils/assert-is-defined.js.map +1 -1
- package/build-module/data-transfer.js +0 -1
- package/build-module/data-transfer.js.map +1 -1
- package/build-module/dom/caret-range-from-point.js +3 -4
- package/build-module/dom/caret-range-from-point.js.map +1 -1
- package/build-module/dom/clean-node-list.js +24 -35
- package/build-module/dom/clean-node-list.js.map +1 -1
- package/build-module/dom/compute-caret-rect.js +1 -3
- package/build-module/dom/compute-caret-rect.js.map +1 -1
- package/build-module/dom/document-has-selection.js +1 -1
- package/build-module/dom/document-has-selection.js.map +1 -1
- package/build-module/dom/document-has-text-selection.js +1 -1
- package/build-module/dom/document-has-text-selection.js.map +1 -1
- package/build-module/dom/document-has-uncollapsed-selection.js +1 -1
- package/build-module/dom/document-has-uncollapsed-selection.js.map +1 -1
- package/build-module/dom/get-computed-style.js +1 -2
- package/build-module/dom/get-computed-style.js.map +1 -1
- package/build-module/dom/get-offset-parent.js +9 -17
- package/build-module/dom/get-offset-parent.js.map +1 -1
- package/build-module/dom/get-range-height.js +0 -2
- package/build-module/dom/get-range-height.js.map +1 -1
- package/build-module/dom/get-rectangle-from-range.js +16 -21
- package/build-module/dom/get-rectangle-from-range.js.map +1 -1
- package/build-module/dom/get-scroll-container.js +4 -11
- package/build-module/dom/get-scroll-container.js.map +1 -1
- package/build-module/dom/hidden-caret-range-from-point.js +3 -3
- package/build-module/dom/hidden-caret-range-from-point.js.map +1 -1
- package/build-module/dom/index.js.map +1 -1
- package/build-module/dom/input-field-has-uncollapsed-selection.js +9 -9
- package/build-module/dom/input-field-has-uncollapsed-selection.js.map +1 -1
- package/build-module/dom/insert-after.js +1 -1
- package/build-module/dom/insert-after.js.map +1 -1
- package/build-module/dom/is-edge.js +19 -32
- package/build-module/dom/is-edge.js.map +1 -1
- package/build-module/dom/is-element.js +0 -1
- package/build-module/dom/is-element.js.map +1 -1
- package/build-module/dom/is-empty.js +1 -6
- package/build-module/dom/is-empty.js.map +1 -1
- package/build-module/dom/is-entirely-selected.js +3 -14
- package/build-module/dom/is-entirely-selected.js.map +1 -1
- package/build-module/dom/is-form-element.js +1 -2
- package/build-module/dom/is-form-element.js.map +1 -1
- package/build-module/dom/is-horizontal-edge.js +3 -3
- package/build-module/dom/is-horizontal-edge.js.map +1 -1
- package/build-module/dom/is-html-input-element.js +0 -1
- package/build-module/dom/is-html-input-element.js.map +1 -1
- package/build-module/dom/is-input-or-text-area.js +0 -1
- package/build-module/dom/is-input-or-text-area.js.map +1 -1
- package/build-module/dom/is-number-input.js +2 -4
- package/build-module/dom/is-number-input.js.map +1 -1
- package/build-module/dom/is-rtl.js +1 -1
- package/build-module/dom/is-rtl.js.map +1 -1
- package/build-module/dom/is-selection-forward.js +7 -9
- package/build-module/dom/is-selection-forward.js.map +1 -1
- package/build-module/dom/is-text-field.js +2 -5
- package/build-module/dom/is-text-field.js.map +1 -1
- package/build-module/dom/is-vertical-edge.js +3 -3
- package/build-module/dom/is-vertical-edge.js.map +1 -1
- package/build-module/dom/place-caret-at-edge.js +9 -26
- package/build-module/dom/place-caret-at-edge.js.map +1 -1
- package/build-module/dom/place-caret-at-horizontal-edge.js +1 -1
- package/build-module/dom/place-caret-at-horizontal-edge.js.map +1 -1
- package/build-module/dom/place-caret-at-vertical-edge.js +1 -1
- package/build-module/dom/place-caret-at-vertical-edge.js.map +1 -1
- package/build-module/dom/remove-invalid-html.js +1 -1
- package/build-module/dom/remove-invalid-html.js.map +1 -1
- package/build-module/dom/remove.js +1 -1
- package/build-module/dom/remove.js.map +1 -1
- package/build-module/dom/replace-tag.js +1 -3
- package/build-module/dom/replace-tag.js.map +1 -1
- package/build-module/dom/replace.js +1 -1
- package/build-module/dom/replace.js.map +1 -1
- package/build-module/dom/safe-html.js +1 -6
- package/build-module/dom/safe-html.js.map +1 -1
- package/build-module/dom/scroll-if-no-range.js +25 -0
- package/build-module/dom/scroll-if-no-range.js.map +1 -0
- package/build-module/dom/strip-html.js +1 -1
- package/build-module/dom/strip-html.js.map +1 -1
- package/build-module/dom/unwrap.js +1 -3
- package/build-module/dom/unwrap.js.map +1 -1
- package/build-module/dom/wrap.js +1 -1
- package/build-module/dom/wrap.js.map +1 -1
- package/build-module/focusable.js +5 -17
- package/build-module/focusable.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/phrasing-content.js +13 -11
- package/build-module/phrasing-content.js.map +1 -1
- package/build-module/tabbable.js +22 -33
- package/build-module/tabbable.js.map +1 -1
- package/build-module/utils/assert-is-defined.js.map +1 -1
- package/build-types/dom/is-edge.d.ts +4 -4
- package/build-types/dom/is-edge.d.ts.map +1 -1
- package/build-types/dom/is-horizontal-edge.d.ts +3 -3
- package/build-types/dom/is-horizontal-edge.d.ts.map +1 -1
- package/build-types/dom/is-vertical-edge.d.ts +3 -3
- package/build-types/dom/is-vertical-edge.d.ts.map +1 -1
- package/build-types/dom/place-caret-at-edge.d.ts.map +1 -1
- package/build-types/dom/scroll-if-no-range.d.ts +12 -0
- package/build-types/dom/scroll-if-no-range.d.ts.map +1 -0
- package/build-types/index.d.ts +2 -2
- package/build-types/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/dom/is-edge.js +6 -8
- package/src/dom/is-horizontal-edge.js +2 -2
- package/src/dom/is-vertical-edge.js +2 -2
- package/src/dom/place-caret-at-edge.js +5 -19
- package/src/dom/scroll-if-no-range.js +34 -0
- package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["isElement","node","nodeType","ELEMENT_NODE"],"sources":["@wordpress/dom/src/dom/is-element.js"],"sourcesContent":["/* eslint-disable jsdoc/valid-types */\n/**\n * @param {Node | null | undefined} node\n * @return {node is Element} True if node is an Element node\n */\nexport default function isElement( node ) {\n\t/* eslint-enable jsdoc/valid-types */\n\treturn !! node && node.nodeType === node.ELEMENT_NODE;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACe,SAASA,SAASA,CAAEC,IAAI,EAAG;EACzC;EACA,OAAO,CAAC,CAAEA,IAAI,IAAIA,IAAI,CAACC,QAAQ,KAAKD,IAAI,CAACE,YAAY;AACtD"}
|
package/build/dom/is-empty.js
CHANGED
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = isEmpty;
|
7
|
-
|
8
7
|
/**
|
9
8
|
* Recursively checks if an element is empty. An element is not empty if it
|
10
9
|
* contains text or contains elements with attributes such as images.
|
@@ -19,19 +18,14 @@ function isEmpty(element) {
|
|
19
18
|
// We cannot use \s since it includes special spaces which we want
|
20
19
|
// to preserve.
|
21
20
|
return /^[ \f\n\r\t\v\u00a0]*$/.test(element.nodeValue || '');
|
22
|
-
|
23
21
|
case element.ELEMENT_NODE:
|
24
22
|
if (element.hasAttributes()) {
|
25
23
|
return false;
|
26
24
|
} else if (!element.hasChildNodes()) {
|
27
25
|
return true;
|
28
26
|
}
|
29
|
-
|
30
|
-
return (
|
31
|
-
/** @type {Element[]} */
|
32
|
-
Array.from(element.childNodes).every(isEmpty)
|
27
|
+
return (/** @type {Element[]} */Array.from(element.childNodes).every(isEmpty)
|
33
28
|
);
|
34
|
-
|
35
29
|
default:
|
36
30
|
return true;
|
37
31
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["isEmpty","element","nodeType","TEXT_NODE","test","nodeValue","ELEMENT_NODE","hasAttributes","hasChildNodes","Array","from","childNodes","every"],"sources":["@wordpress/dom/src/dom/is-empty.js"],"sourcesContent":["/**\n * Recursively checks if an element is empty. An element is not empty if it\n * contains text or contains elements with attributes such as images.\n *\n * @param {Element} element The element to check.\n *\n * @return {boolean} Whether or not the element is empty.\n */\nexport default function isEmpty( element ) {\n\tswitch ( element.nodeType ) {\n\t\tcase element.TEXT_NODE:\n\t\t\t// We cannot use \\s since it includes special spaces which we want\n\t\t\t// to preserve.\n\t\t\treturn /^[ \\f\\n\\r\\t\\v\\u00a0]*$/.test( element.nodeValue || '' );\n\t\tcase element.ELEMENT_NODE:\n\t\t\tif ( element.hasAttributes() ) {\n\t\t\t\treturn false;\n\t\t\t} else if ( ! element.hasChildNodes() ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn /** @type {Element[]} */ (\n\t\t\t\tArray.from( element.childNodes )\n\t\t\t).every( isEmpty );\n\t\tdefault:\n\t\t\treturn true;\n\t}\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,OAAOA,CAAEC,OAAO,EAAG;EAC1C,QAASA,OAAO,CAACC,QAAQ;IACxB,KAAKD,OAAO,CAACE,SAAS;MACrB;MACA;MACA,OAAO,wBAAwB,CAACC,IAAI,CAAEH,OAAO,CAACI,SAAS,IAAI,EAAG,CAAC;IAChE,KAAKJ,OAAO,CAACK,YAAY;MACxB,IAAKL,OAAO,CAACM,aAAa,CAAC,CAAC,EAAG;QAC9B,OAAO,KAAK;MACb,CAAC,MAAM,IAAK,CAAEN,OAAO,CAACO,aAAa,CAAC,CAAC,EAAG;QACvC,OAAO,IAAI;MACZ;MAEA,OAAO,yBACNC,KAAK,CAACC,IAAI,CAAET,OAAO,CAACU,UAAW,CAAC,CAC/BC,KAAK,CAAEZ,OAAQ;MAAC;IACnB;MACC,OAAO,IAAI;EACb;AACD"}
|
@@ -1,16 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.default = isEntirelySelected;
|
9
|
-
|
10
8
|
var _assertIsDefined = require("../utils/assert-is-defined");
|
11
|
-
|
12
9
|
var _isInputOrTextArea = _interopRequireDefault(require("./is-input-or-text-area"));
|
13
|
-
|
14
10
|
/**
|
15
11
|
* Internal dependencies
|
16
12
|
*/
|
@@ -27,11 +23,9 @@ function isEntirelySelected(element) {
|
|
27
23
|
if ((0, _isInputOrTextArea.default)(element)) {
|
28
24
|
return element.selectionStart === 0 && element.value.length === element.selectionEnd;
|
29
25
|
}
|
30
|
-
|
31
26
|
if (!element.isContentEditable) {
|
32
27
|
return true;
|
33
28
|
}
|
34
|
-
|
35
29
|
const {
|
36
30
|
ownerDocument
|
37
31
|
} = element;
|
@@ -42,29 +36,24 @@ function isEntirelySelected(element) {
|
|
42
36
|
const selection = defaultView.getSelection();
|
43
37
|
(0, _assertIsDefined.assertIsDefined)(selection, 'selection');
|
44
38
|
const range = selection.rangeCount ? selection.getRangeAt(0) : null;
|
45
|
-
|
46
39
|
if (!range) {
|
47
40
|
return true;
|
48
41
|
}
|
49
|
-
|
50
42
|
const {
|
51
43
|
startContainer,
|
52
44
|
endContainer,
|
53
45
|
startOffset,
|
54
46
|
endOffset
|
55
47
|
} = range;
|
56
|
-
|
57
48
|
if (startContainer === element && endContainer === element && startOffset === 0 && endOffset === element.childNodes.length) {
|
58
49
|
return true;
|
59
50
|
}
|
60
|
-
|
61
51
|
const lastChild = element.lastChild;
|
62
52
|
(0, _assertIsDefined.assertIsDefined)(lastChild, 'lastChild');
|
63
|
-
const endContainerContentLength = endContainer.nodeType === endContainer.TEXT_NODE ?
|
64
|
-
/** @type {Text} */
|
65
|
-
endContainer.data.length : endContainer.childNodes.length;
|
53
|
+
const endContainerContentLength = endContainer.nodeType === endContainer.TEXT_NODE ? /** @type {Text} */endContainer.data.length : endContainer.childNodes.length;
|
66
54
|
return isDeepChild(startContainer, element, 'firstChild') && isDeepChild(endContainer, element, 'lastChild') && startOffset === 0 && endOffset === endContainerContentLength;
|
67
55
|
}
|
56
|
+
|
68
57
|
/**
|
69
58
|
* Check whether the contents of the element have been entirely selected.
|
70
59
|
* Returns true if there is no possibility of selection.
|
@@ -75,20 +64,15 @@ function isEntirelySelected(element) {
|
|
75
64
|
*
|
76
65
|
* @return {boolean} True if query is a deep first/last child of container, false otherwise.
|
77
66
|
*/
|
78
|
-
|
79
|
-
|
80
67
|
function isDeepChild(query, container, propName) {
|
81
68
|
/** @type {HTMLElement | ChildNode | null} */
|
82
69
|
let candidate = container;
|
83
|
-
|
84
70
|
do {
|
85
71
|
if (query === candidate) {
|
86
72
|
return true;
|
87
73
|
}
|
88
|
-
|
89
74
|
candidate = candidate[propName];
|
90
75
|
} while (candidate);
|
91
|
-
|
92
76
|
return false;
|
93
77
|
}
|
94
78
|
//# sourceMappingURL=is-entirely-selected.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["_assertIsDefined","require","_isInputOrTextArea","_interopRequireDefault","isEntirelySelected","element","isInputOrTextArea","selectionStart","value","length","selectionEnd","isContentEditable","ownerDocument","defaultView","assertIsDefined","selection","getSelection","range","rangeCount","getRangeAt","startContainer","endContainer","startOffset","endOffset","childNodes","lastChild","endContainerContentLength","nodeType","TEXT_NODE","data","isDeepChild","query","container","propName","candidate"],"sources":["@wordpress/dom/src/dom/is-entirely-selected.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\nimport isInputOrTextArea from './is-input-or-text-area';\n\n/**\n * Check whether the contents of the element have been entirely selected.\n * Returns true if there is no possibility of selection.\n *\n * @param {HTMLElement} element The element to check.\n *\n * @return {boolean} True if entirely selected, false if not.\n */\nexport default function isEntirelySelected( element ) {\n\tif ( isInputOrTextArea( element ) ) {\n\t\treturn (\n\t\t\telement.selectionStart === 0 &&\n\t\t\telement.value.length === element.selectionEnd\n\t\t);\n\t}\n\n\tif ( ! element.isContentEditable ) {\n\t\treturn true;\n\t}\n\n\tconst { ownerDocument } = element;\n\tconst { defaultView } = ownerDocument;\n\tassertIsDefined( defaultView, 'defaultView' );\n\tconst selection = defaultView.getSelection();\n\tassertIsDefined( selection, 'selection' );\n\tconst range = selection.rangeCount ? selection.getRangeAt( 0 ) : null;\n\n\tif ( ! range ) {\n\t\treturn true;\n\t}\n\n\tconst { startContainer, endContainer, startOffset, endOffset } = range;\n\n\tif (\n\t\tstartContainer === element &&\n\t\tendContainer === element &&\n\t\tstartOffset === 0 &&\n\t\tendOffset === element.childNodes.length\n\t) {\n\t\treturn true;\n\t}\n\n\tconst lastChild = element.lastChild;\n\tassertIsDefined( lastChild, 'lastChild' );\n\tconst endContainerContentLength =\n\t\tendContainer.nodeType === endContainer.TEXT_NODE\n\t\t\t? /** @type {Text} */ ( endContainer ).data.length\n\t\t\t: endContainer.childNodes.length;\n\n\treturn (\n\t\tisDeepChild( startContainer, element, 'firstChild' ) &&\n\t\tisDeepChild( endContainer, element, 'lastChild' ) &&\n\t\tstartOffset === 0 &&\n\t\tendOffset === endContainerContentLength\n\t);\n}\n\n/**\n * Check whether the contents of the element have been entirely selected.\n * Returns true if there is no possibility of selection.\n *\n * @param {HTMLElement|Node} query The element to check.\n * @param {HTMLElement} container The container that we suspect \"query\" may be a first or last child of.\n * @param {\"firstChild\"|\"lastChild\"} propName \"firstChild\" or \"lastChild\"\n *\n * @return {boolean} True if query is a deep first/last child of container, false otherwise.\n */\nfunction isDeepChild( query, container, propName ) {\n\t/** @type {HTMLElement | ChildNode | null} */\n\tlet candidate = container;\n\tdo {\n\t\tif ( query === candidate ) {\n\t\t\treturn true;\n\t\t}\n\t\tcandidate = candidate[ propName ];\n\t} while ( candidate );\n\treturn false;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASG,kBAAkBA,CAAEC,OAAO,EAAG;EACrD,IAAK,IAAAC,0BAAiB,EAAED,OAAQ,CAAC,EAAG;IACnC,OACCA,OAAO,CAACE,cAAc,KAAK,CAAC,IAC5BF,OAAO,CAACG,KAAK,CAACC,MAAM,KAAKJ,OAAO,CAACK,YAAY;EAE/C;EAEA,IAAK,CAAEL,OAAO,CAACM,iBAAiB,EAAG;IAClC,OAAO,IAAI;EACZ;EAEA,MAAM;IAAEC;EAAc,CAAC,GAAGP,OAAO;EACjC,MAAM;IAAEQ;EAAY,CAAC,GAAGD,aAAa;EACrC,IAAAE,gCAAe,EAAED,WAAW,EAAE,aAAc,CAAC;EAC7C,MAAME,SAAS,GAAGF,WAAW,CAACG,YAAY,CAAC,CAAC;EAC5C,IAAAF,gCAAe,EAAEC,SAAS,EAAE,WAAY,CAAC;EACzC,MAAME,KAAK,GAAGF,SAAS,CAACG,UAAU,GAAGH,SAAS,CAACI,UAAU,CAAE,CAAE,CAAC,GAAG,IAAI;EAErE,IAAK,CAAEF,KAAK,EAAG;IACd,OAAO,IAAI;EACZ;EAEA,MAAM;IAAEG,cAAc;IAAEC,YAAY;IAAEC,WAAW;IAAEC;EAAU,CAAC,GAAGN,KAAK;EAEtE,IACCG,cAAc,KAAKf,OAAO,IAC1BgB,YAAY,KAAKhB,OAAO,IACxBiB,WAAW,KAAK,CAAC,IACjBC,SAAS,KAAKlB,OAAO,CAACmB,UAAU,CAACf,MAAM,EACtC;IACD,OAAO,IAAI;EACZ;EAEA,MAAMgB,SAAS,GAAGpB,OAAO,CAACoB,SAAS;EACnC,IAAAX,gCAAe,EAAEW,SAAS,EAAE,WAAY,CAAC;EACzC,MAAMC,yBAAyB,GAC9BL,YAAY,CAACM,QAAQ,KAAKN,YAAY,CAACO,SAAS,GAC7C,mBAAsBP,YAAY,CAAGQ,IAAI,CAACpB,MAAM,GAChDY,YAAY,CAACG,UAAU,CAACf,MAAM;EAElC,OACCqB,WAAW,CAAEV,cAAc,EAAEf,OAAO,EAAE,YAAa,CAAC,IACpDyB,WAAW,CAAET,YAAY,EAAEhB,OAAO,EAAE,WAAY,CAAC,IACjDiB,WAAW,KAAK,CAAC,IACjBC,SAAS,KAAKG,yBAAyB;AAEzC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASI,WAAWA,CAAEC,KAAK,EAAEC,SAAS,EAAEC,QAAQ,EAAG;EAClD;EACA,IAAIC,SAAS,GAAGF,SAAS;EACzB,GAAG;IACF,IAAKD,KAAK,KAAKG,SAAS,EAAG;MAC1B,OAAO,IAAI;IACZ;IACAA,SAAS,GAAGA,SAAS,CAAED,QAAQ,CAAE;EAClC,CAAC,QAASC,SAAS;EACnB,OAAO,KAAK;AACb"}
|
@@ -1,14 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.default = isFormElement;
|
9
|
-
|
10
8
|
var _isInputOrTextArea = _interopRequireDefault(require("./is-input-or-text-area"));
|
11
|
-
|
12
9
|
/**
|
13
10
|
* Internal dependencies
|
14
11
|
*/
|
@@ -25,7 +22,6 @@ function isFormElement(element) {
|
|
25
22
|
if (!element) {
|
26
23
|
return false;
|
27
24
|
}
|
28
|
-
|
29
25
|
const {
|
30
26
|
tagName
|
31
27
|
} = element;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["_isInputOrTextArea","_interopRequireDefault","require","isFormElement","element","tagName","checkForInputTextarea","isInputOrTextArea"],"sources":["@wordpress/dom/src/dom/is-form-element.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport isInputOrTextArea from './is-input-or-text-area';\n\n/**\n *\n * Detects if element is a form element.\n *\n * @param {Element} element The element to check.\n *\n * @return {boolean} True if form element and false otherwise.\n */\nexport default function isFormElement( element ) {\n\tif ( ! element ) {\n\t\treturn false;\n\t}\n\n\tconst { tagName } = element;\n\tconst checkForInputTextarea = isInputOrTextArea( element );\n\treturn (\n\t\tcheckForInputTextarea || tagName === 'BUTTON' || tagName === 'SELECT'\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,kBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,aAAaA,CAAEC,OAAO,EAAG;EAChD,IAAK,CAAEA,OAAO,EAAG;IAChB,OAAO,KAAK;EACb;EAEA,MAAM;IAAEC;EAAQ,CAAC,GAAGD,OAAO;EAC3B,MAAME,qBAAqB,GAAG,IAAAC,0BAAiB,EAAEH,OAAQ,CAAC;EAC1D,OACCE,qBAAqB,IAAID,OAAO,KAAK,QAAQ,IAAIA,OAAO,KAAK,QAAQ;AAEvE"}
|
@@ -1,14 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.default = isHorizontalEdge;
|
9
|
-
|
10
8
|
var _isEdge = _interopRequireDefault(require("./is-edge"));
|
11
|
-
|
12
9
|
/**
|
13
10
|
* Internal dependencies
|
14
11
|
*/
|
@@ -16,8 +13,8 @@ var _isEdge = _interopRequireDefault(require("./is-edge"));
|
|
16
13
|
/**
|
17
14
|
* Check whether the selection is horizontally at the edge of the container.
|
18
15
|
*
|
19
|
-
* @param {
|
20
|
-
* @param {boolean}
|
16
|
+
* @param {HTMLElement} container Focusable element.
|
17
|
+
* @param {boolean} isReverse Set to true to check left, false for right.
|
21
18
|
*
|
22
19
|
* @return {boolean} True if at the horizontal edge, false if not.
|
23
20
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["_isEdge","_interopRequireDefault","require","isHorizontalEdge","container","isReverse","isEdge"],"sources":["@wordpress/dom/src/dom/is-horizontal-edge.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport isEdge from './is-edge';\n\n/**\n * Check whether the selection is horizontally at the edge of the container.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse Set to true to check left, false for right.\n *\n * @return {boolean} True if at the horizontal edge, false if not.\n */\nexport default function isHorizontalEdge( container, isReverse ) {\n\treturn isEdge( container, isReverse );\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,gBAAgBA,CAAEC,SAAS,EAAEC,SAAS,EAAG;EAChE,OAAO,IAAAC,eAAM,EAAEF,SAAS,EAAEC,SAAU,CAAC;AACtC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["@wordpress/dom/src/dom/is-html-input-element.js"],"
|
1
|
+
{"version":3,"names":["isHTMLInputElement","node","nodeName"],"sources":["@wordpress/dom/src/dom/is-html-input-element.js"],"sourcesContent":["/* eslint-disable jsdoc/valid-types */\n/**\n * @param {Node} node\n * @return {node is HTMLInputElement} Whether the node is an HTMLInputElement.\n */\nexport default function isHTMLInputElement( node ) {\n\t/* eslint-enable jsdoc/valid-types */\n\treturn node?.nodeName === 'INPUT';\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACe,SAASA,kBAAkBA,CAAEC,IAAI,EAAG;EAClD;EACA,OAAOA,IAAI,EAAEC,QAAQ,KAAK,OAAO;AAClC"}
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = isInputOrTextArea;
|
7
|
-
|
8
7
|
/* eslint-disable jsdoc/valid-types */
|
9
|
-
|
10
8
|
/**
|
11
9
|
* @param {Element} element
|
12
10
|
* @return {element is HTMLInputElement | HTMLTextAreaElement} Whether the element is an input or textarea
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["@wordpress/dom/src/dom/is-input-or-text-area.js"],"
|
1
|
+
{"version":3,"names":["isInputOrTextArea","element","tagName"],"sources":["@wordpress/dom/src/dom/is-input-or-text-area.js"],"sourcesContent":["/* eslint-disable jsdoc/valid-types */\n/**\n * @param {Element} element\n * @return {element is HTMLInputElement | HTMLTextAreaElement} Whether the element is an input or textarea\n */\nexport default function isInputOrTextArea( element ) {\n\t/* eslint-enable jsdoc/valid-types */\n\treturn element.tagName === 'INPUT' || element.tagName === 'TEXTAREA';\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACe,SAASA,iBAAiBA,CAAEC,OAAO,EAAG;EACpD;EACA,OAAOA,OAAO,CAACC,OAAO,KAAK,OAAO,IAAID,OAAO,CAACC,OAAO,KAAK,UAAU;AACrE"}
|
@@ -1,16 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.default = isNumberInput;
|
9
|
-
|
10
8
|
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
|
11
|
-
|
12
9
|
var _isHtmlInputElement = _interopRequireDefault(require("./is-html-input-element"));
|
13
|
-
|
14
10
|
/**
|
15
11
|
* WordPress dependencies
|
16
12
|
*/
|
@@ -20,7 +16,6 @@ var _isHtmlInputElement = _interopRequireDefault(require("./is-html-input-elemen
|
|
20
16
|
*/
|
21
17
|
|
22
18
|
/* eslint-disable jsdoc/valid-types */
|
23
|
-
|
24
19
|
/**
|
25
20
|
* Check whether the given element is an input field of type number.
|
26
21
|
*
|
@@ -34,7 +29,6 @@ function isNumberInput(node) {
|
|
34
29
|
version: '6.5'
|
35
30
|
});
|
36
31
|
/* eslint-enable jsdoc/valid-types */
|
37
|
-
|
38
32
|
return (0, _isHtmlInputElement.default)(node) && node.type === 'number' && !isNaN(node.valueAsNumber);
|
39
33
|
}
|
40
34
|
//# sourceMappingURL=is-number-input.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["_deprecated","_interopRequireDefault","require","_isHtmlInputElement","isNumberInput","node","deprecated","since","version","isHTMLInputElement","type","isNaN","valueAsNumber"],"sources":["@wordpress/dom/src/dom/is-number-input.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport isHTMLInputElement from './is-html-input-element';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Check whether the given element is an input field of type number.\n *\n * @param {Node} node The HTML node.\n *\n * @return {node is HTMLInputElement} True if the node is number input.\n */\nexport default function isNumberInput( node ) {\n\tdeprecated( 'wp.dom.isNumberInput', {\n\t\tsince: '6.1',\n\t\tversion: '6.5',\n\t} );\n\t/* eslint-enable jsdoc/valid-types */\n\treturn (\n\t\tisHTMLInputElement( node ) &&\n\t\tnode.type === 'number' &&\n\t\t! isNaN( node.valueAsNumber )\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,mBAAA,GAAAF,sBAAA,CAAAC,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASE,aAAaA,CAAEC,IAAI,EAAG;EAC7C,IAAAC,mBAAU,EAAE,sBAAsB,EAAE;IACnCC,KAAK,EAAE,KAAK;IACZC,OAAO,EAAE;EACV,CAAE,CAAC;EACH;EACA,OACC,IAAAC,2BAAkB,EAAEJ,IAAK,CAAC,IAC1BA,IAAI,CAACK,IAAI,KAAK,QAAQ,IACtB,CAAEC,KAAK,CAAEN,IAAI,CAACO,aAAc,CAAC;AAE/B"}
|
package/build/dom/is-rtl.js
CHANGED
@@ -1,14 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.default = isRTL;
|
9
|
-
|
10
8
|
var _getComputedStyle = _interopRequireDefault(require("./get-computed-style"));
|
11
|
-
|
12
9
|
/**
|
13
10
|
* Internal dependencies
|
14
11
|
*/
|
package/build/dom/is-rtl.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["_getComputedStyle","_interopRequireDefault","require","isRTL","element","getComputedStyle","direction"],"sources":["@wordpress/dom/src/dom/is-rtl.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport getComputedStyle from './get-computed-style';\n\n/**\n * Whether the element's text direction is right-to-left.\n *\n * @param {Element} element The element to check.\n *\n * @return {boolean} True if rtl, false if ltr.\n */\nexport default function isRTL( element ) {\n\treturn getComputedStyle( element ).direction === 'rtl';\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,KAAKA,CAAEC,OAAO,EAAG;EACxC,OAAO,IAAAC,yBAAgB,EAAED,OAAQ,CAAC,CAACE,SAAS,KAAK,KAAK;AACvD"}
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = isSelectionForward;
|
7
|
-
|
8
7
|
var _assertIsDefined = require("../utils/assert-is-defined");
|
9
|
-
|
10
8
|
/**
|
11
9
|
* Internal dependencies
|
12
10
|
*/
|
@@ -30,30 +28,28 @@ function isSelectionForward(selection) {
|
|
30
28
|
} = selection;
|
31
29
|
(0, _assertIsDefined.assertIsDefined)(anchorNode, 'anchorNode');
|
32
30
|
(0, _assertIsDefined.assertIsDefined)(focusNode, 'focusNode');
|
33
|
-
const position = anchorNode.compareDocumentPosition(focusNode);
|
34
|
-
// so bitwise operators are intended.
|
31
|
+
const position = anchorNode.compareDocumentPosition(focusNode);
|
35
32
|
|
33
|
+
// Disable reason: `Node#compareDocumentPosition` returns a bitmask value,
|
34
|
+
// so bitwise operators are intended.
|
36
35
|
/* eslint-disable no-bitwise */
|
37
36
|
// Compare whether anchor node precedes focus node. If focus node (where
|
38
37
|
// end of selection occurs) is after the anchor node, it is forward.
|
39
|
-
|
40
38
|
if (position & anchorNode.DOCUMENT_POSITION_PRECEDING) {
|
41
39
|
return false;
|
42
40
|
}
|
43
|
-
|
44
41
|
if (position & anchorNode.DOCUMENT_POSITION_FOLLOWING) {
|
45
42
|
return true;
|
46
43
|
}
|
47
44
|
/* eslint-enable no-bitwise */
|
45
|
+
|
48
46
|
// `compareDocumentPosition` returns 0 when passed the same node, in which
|
49
47
|
// case compare offsets.
|
50
|
-
|
51
|
-
|
52
48
|
if (position === 0) {
|
53
49
|
return anchorOffset <= focusOffset;
|
54
|
-
}
|
55
|
-
|
50
|
+
}
|
56
51
|
|
52
|
+
// This should never be reached, but return true as default case.
|
57
53
|
return true;
|
58
54
|
}
|
59
55
|
//# sourceMappingURL=is-selection-forward.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["_assertIsDefined","require","isSelectionForward","selection","anchorNode","focusNode","anchorOffset","focusOffset","assertIsDefined","position","compareDocumentPosition","DOCUMENT_POSITION_PRECEDING","DOCUMENT_POSITION_FOLLOWING"],"sources":["@wordpress/dom/src/dom/is-selection-forward.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Returns true if the given selection object is in the forward direction, or\n * false otherwise.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition\n *\n * @param {Selection} selection Selection object to check.\n *\n * @return {boolean} Whether the selection is forward.\n */\nexport default function isSelectionForward( selection ) {\n\tconst { anchorNode, focusNode, anchorOffset, focusOffset } = selection;\n\n\tassertIsDefined( anchorNode, 'anchorNode' );\n\tassertIsDefined( focusNode, 'focusNode' );\n\tconst position = anchorNode.compareDocumentPosition( focusNode );\n\n\t// Disable reason: `Node#compareDocumentPosition` returns a bitmask value,\n\t// so bitwise operators are intended.\n\t/* eslint-disable no-bitwise */\n\t// Compare whether anchor node precedes focus node. If focus node (where\n\t// end of selection occurs) is after the anchor node, it is forward.\n\tif ( position & anchorNode.DOCUMENT_POSITION_PRECEDING ) {\n\t\treturn false;\n\t}\n\n\tif ( position & anchorNode.DOCUMENT_POSITION_FOLLOWING ) {\n\t\treturn true;\n\t}\n\t/* eslint-enable no-bitwise */\n\n\t// `compareDocumentPosition` returns 0 when passed the same node, in which\n\t// case compare offsets.\n\tif ( position === 0 ) {\n\t\treturn anchorOffset <= focusOffset;\n\t}\n\n\t// This should never be reached, but return true as default case.\n\treturn true;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,gBAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,kBAAkBA,CAAEC,SAAS,EAAG;EACvD,MAAM;IAAEC,UAAU;IAAEC,SAAS;IAAEC,YAAY;IAAEC;EAAY,CAAC,GAAGJ,SAAS;EAEtE,IAAAK,gCAAe,EAAEJ,UAAU,EAAE,YAAa,CAAC;EAC3C,IAAAI,gCAAe,EAAEH,SAAS,EAAE,WAAY,CAAC;EACzC,MAAMI,QAAQ,GAAGL,UAAU,CAACM,uBAAuB,CAAEL,SAAU,CAAC;;EAEhE;EACA;EACA;EACA;EACA;EACA,IAAKI,QAAQ,GAAGL,UAAU,CAACO,2BAA2B,EAAG;IACxD,OAAO,KAAK;EACb;EAEA,IAAKF,QAAQ,GAAGL,UAAU,CAACQ,2BAA2B,EAAG;IACxD,OAAO,IAAI;EACZ;EACA;;EAEA;EACA;EACA,IAAKH,QAAQ,KAAK,CAAC,EAAG;IACrB,OAAOH,YAAY,IAAIC,WAAW;EACnC;;EAEA;EACA,OAAO,IAAI;AACZ"}
|
@@ -1,20 +1,16 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.default = isTextField;
|
9
|
-
|
10
8
|
var _isHtmlInputElement = _interopRequireDefault(require("./is-html-input-element"));
|
11
|
-
|
12
9
|
/**
|
13
10
|
* Internal dependencies
|
14
11
|
*/
|
15
12
|
|
16
13
|
/* eslint-disable jsdoc/valid-types */
|
17
|
-
|
18
14
|
/**
|
19
15
|
* Check whether the given element is a text field, where text field is defined
|
20
16
|
* by the ability to select within the input, or that it is contenteditable.
|
@@ -27,8 +23,6 @@ var _isHtmlInputElement = _interopRequireDefault(require("./is-html-input-elemen
|
|
27
23
|
function isTextField(node) {
|
28
24
|
/* eslint-enable jsdoc/valid-types */
|
29
25
|
const nonTextInputs = ['button', 'checkbox', 'hidden', 'file', 'radio', 'image', 'range', 'reset', 'submit', 'number', 'email', 'time'];
|
30
|
-
return (0, _isHtmlInputElement.default)(node) && node.type && !nonTextInputs.includes(node.type) || node.nodeName === 'TEXTAREA' ||
|
31
|
-
/** @type {HTMLElement} */
|
32
|
-
node.contentEditable === 'true';
|
26
|
+
return (0, _isHtmlInputElement.default)(node) && node.type && !nonTextInputs.includes(node.type) || node.nodeName === 'TEXTAREA' || /** @type {HTMLElement} */node.contentEditable === 'true';
|
33
27
|
}
|
34
28
|
//# sourceMappingURL=is-text-field.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["_isHtmlInputElement","_interopRequireDefault","require","isTextField","node","nonTextInputs","isHTMLInputElement","type","includes","nodeName","contentEditable"],"sources":["@wordpress/dom/src/dom/is-text-field.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport isHTMLInputElement from './is-html-input-element';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Check whether the given element is a text field, where text field is defined\n * by the ability to select within the input, or that it is contenteditable.\n *\n * See: https://html.spec.whatwg.org/#textFieldSelection\n *\n * @param {Node} node The HTML element.\n * @return {node is HTMLElement} True if the element is an text field, false if not.\n */\nexport default function isTextField( node ) {\n\t/* eslint-enable jsdoc/valid-types */\n\tconst nonTextInputs = [\n\t\t'button',\n\t\t'checkbox',\n\t\t'hidden',\n\t\t'file',\n\t\t'radio',\n\t\t'image',\n\t\t'range',\n\t\t'reset',\n\t\t'submit',\n\t\t'number',\n\t\t'email',\n\t\t'time',\n\t];\n\treturn (\n\t\t( isHTMLInputElement( node ) &&\n\t\t\tnode.type &&\n\t\t\t! nonTextInputs.includes( node.type ) ) ||\n\t\tnode.nodeName === 'TEXTAREA' ||\n\t\t/** @type {HTMLElement} */ ( node ).contentEditable === 'true'\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,WAAWA,CAAEC,IAAI,EAAG;EAC3C;EACA,MAAMC,aAAa,GAAG,CACrB,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,MAAM,EACN,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,MAAM,CACN;EACD,OACG,IAAAC,2BAAkB,EAAEF,IAAK,CAAC,IAC3BA,IAAI,CAACG,IAAI,IACT,CAAEF,aAAa,CAACG,QAAQ,CAAEJ,IAAI,CAACG,IAAK,CAAC,IACtCH,IAAI,CAACK,QAAQ,KAAK,UAAU,IAC5B,0BAA6BL,IAAI,CAAGM,eAAe,KAAK,MAAM;AAEhE"}
|
@@ -1,14 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.default = isVerticalEdge;
|
9
|
-
|
10
8
|
var _isEdge = _interopRequireDefault(require("./is-edge"));
|
11
|
-
|
12
9
|
/**
|
13
10
|
* Internal dependencies
|
14
11
|
*/
|
@@ -16,8 +13,8 @@ var _isEdge = _interopRequireDefault(require("./is-edge"));
|
|
16
13
|
/**
|
17
14
|
* Check whether the selection is vertically at the edge of the container.
|
18
15
|
*
|
19
|
-
* @param {
|
20
|
-
* @param {boolean}
|
16
|
+
* @param {HTMLElement} container Focusable element.
|
17
|
+
* @param {boolean} isReverse Set to true to check top, false for bottom.
|
21
18
|
*
|
22
19
|
* @return {boolean} True if at the vertical edge, false if not.
|
23
20
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["_isEdge","_interopRequireDefault","require","isVerticalEdge","container","isReverse","isEdge"],"sources":["@wordpress/dom/src/dom/is-vertical-edge.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport isEdge from './is-edge';\n\n/**\n * Check whether the selection is vertically at the edge of the container.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse Set to true to check top, false for bottom.\n *\n * @return {boolean} True if at the vertical edge, false if not.\n */\nexport default function isVerticalEdge( container, isReverse ) {\n\treturn isEdge( container, isReverse, true );\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,cAAcA,CAAEC,SAAS,EAAEC,SAAS,EAAG;EAC9D,OAAO,IAAAC,eAAM,EAAEF,SAAS,EAAEC,SAAS,EAAE,IAAK,CAAC;AAC5C"}
|
@@ -1,20 +1,15 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.default = placeCaretAtEdge;
|
9
|
-
|
10
8
|
var _hiddenCaretRangeFromPoint = _interopRequireDefault(require("./hidden-caret-range-from-point"));
|
11
|
-
|
12
9
|
var _assertIsDefined = require("../utils/assert-is-defined");
|
13
|
-
|
14
10
|
var _isInputOrTextArea = _interopRequireDefault(require("./is-input-or-text-area"));
|
15
|
-
|
16
11
|
var _isRtl = _interopRequireDefault(require("./is-rtl"));
|
17
|
-
|
12
|
+
var _scrollIfNoRange = require("./scroll-if-no-range");
|
18
13
|
/**
|
19
14
|
* Internal dependencies
|
20
15
|
*/
|
@@ -31,14 +26,14 @@ var _isRtl = _interopRequireDefault(require("./is-rtl"));
|
|
31
26
|
function getRange(container, isReverse, x) {
|
32
27
|
const {
|
33
28
|
ownerDocument
|
34
|
-
} = container;
|
35
|
-
|
29
|
+
} = container;
|
30
|
+
// In the case of RTL scripts, the horizontal edge is at the opposite side.
|
36
31
|
const isReverseDir = (0, _isRtl.default)(container) ? !isReverse : isReverse;
|
37
|
-
const containerRect = container.getBoundingClientRect();
|
32
|
+
const containerRect = container.getBoundingClientRect();
|
33
|
+
// When placing at the end (isReverse), find the closest range to the bottom
|
38
34
|
// right corner. When placing at the start, to the top left corner.
|
39
35
|
// Ensure x is defined and within the container's boundaries. When it's
|
40
36
|
// exactly at the boundary, it's not considered within the boundaries.
|
41
|
-
|
42
37
|
if (x === undefined) {
|
43
38
|
x = isReverse ? containerRect.right - 1 : containerRect.left + 1;
|
44
39
|
} else if (x <= containerRect.left) {
|
@@ -46,10 +41,10 @@ function getRange(container, isReverse, x) {
|
|
46
41
|
} else if (x >= containerRect.right) {
|
47
42
|
x = containerRect.right - 1;
|
48
43
|
}
|
49
|
-
|
50
44
|
const y = isReverseDir ? containerRect.bottom - 1 : containerRect.top + 1;
|
51
45
|
return (0, _hiddenCaretRangeFromPoint.default)(ownerDocument, x, y, container);
|
52
46
|
}
|
47
|
+
|
53
48
|
/**
|
54
49
|
* Places the caret at start or end of a given element.
|
55
50
|
*
|
@@ -57,21 +52,16 @@ function getRange(container, isReverse, x) {
|
|
57
52
|
* @param {boolean} isReverse True for end, false for start.
|
58
53
|
* @param {number|undefined} x X coordinate to vertically position.
|
59
54
|
*/
|
60
|
-
|
61
|
-
|
62
55
|
function placeCaretAtEdge(container, isReverse, x) {
|
63
56
|
if (!container) {
|
64
57
|
return;
|
65
58
|
}
|
66
|
-
|
67
59
|
container.focus();
|
68
|
-
|
69
60
|
if ((0, _isInputOrTextArea.default)(container)) {
|
70
61
|
// The element may not support selection setting.
|
71
62
|
if (typeof container.selectionStart !== 'number') {
|
72
63
|
return;
|
73
64
|
}
|
74
|
-
|
75
65
|
if (isReverse) {
|
76
66
|
container.selectionStart = container.value.length;
|
77
67
|
container.selectionEnd = container.value.length;
|
@@ -79,26 +69,13 @@ function placeCaretAtEdge(container, isReverse, x) {
|
|
79
69
|
container.selectionStart = 0;
|
80
70
|
container.selectionEnd = 0;
|
81
71
|
}
|
82
|
-
|
83
72
|
return;
|
84
73
|
}
|
85
|
-
|
86
74
|
if (!container.isContentEditable) {
|
87
75
|
return;
|
88
76
|
}
|
89
|
-
|
90
|
-
|
91
|
-
// element may be out of view.
|
92
|
-
|
93
|
-
if (!range || !range.startContainer || !container.contains(range.startContainer)) {
|
94
|
-
container.scrollIntoView(isReverse);
|
95
|
-
range = range = getRange(container, isReverse, x);
|
96
|
-
|
97
|
-
if (!range || !range.startContainer || !container.contains(range.startContainer)) {
|
98
|
-
return;
|
99
|
-
}
|
100
|
-
}
|
101
|
-
|
77
|
+
const range = (0, _scrollIfNoRange.scrollIfNoRange)(container, isReverse, () => getRange(container, isReverse, x));
|
78
|
+
if (!range) return;
|
102
79
|
const {
|
103
80
|
ownerDocument
|
104
81
|
} = container;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["_hiddenCaretRangeFromPoint","_interopRequireDefault","require","_assertIsDefined","_isInputOrTextArea","_isRtl","_scrollIfNoRange","getRange","container","isReverse","x","ownerDocument","isReverseDir","isRTL","containerRect","getBoundingClientRect","undefined","right","left","y","bottom","top","hiddenCaretRangeFromPoint","placeCaretAtEdge","focus","isInputOrTextArea","selectionStart","value","length","selectionEnd","isContentEditable","range","scrollIfNoRange","defaultView","assertIsDefined","selection","getSelection","removeAllRanges","addRange"],"sources":["@wordpress/dom/src/dom/place-caret-at-edge.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport hiddenCaretRangeFromPoint from './hidden-caret-range-from-point';\nimport { assertIsDefined } from '../utils/assert-is-defined';\nimport isInputOrTextArea from './is-input-or-text-area';\nimport isRTL from './is-rtl';\nimport { scrollIfNoRange } from './scroll-if-no-range';\n\n/**\n * Gets the range to place.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse True for end, false for start.\n * @param {number|undefined} x X coordinate to vertically position.\n *\n * @return {Range|null} The range to place.\n */\nfunction getRange( container, isReverse, x ) {\n\tconst { ownerDocument } = container;\n\t// In the case of RTL scripts, the horizontal edge is at the opposite side.\n\tconst isReverseDir = isRTL( container ) ? ! isReverse : isReverse;\n\tconst containerRect = container.getBoundingClientRect();\n\t// When placing at the end (isReverse), find the closest range to the bottom\n\t// right corner. When placing at the start, to the top left corner.\n\t// Ensure x is defined and within the container's boundaries. When it's\n\t// exactly at the boundary, it's not considered within the boundaries.\n\tif ( x === undefined ) {\n\t\tx = isReverse ? containerRect.right - 1 : containerRect.left + 1;\n\t} else if ( x <= containerRect.left ) {\n\t\tx = containerRect.left + 1;\n\t} else if ( x >= containerRect.right ) {\n\t\tx = containerRect.right - 1;\n\t}\n\tconst y = isReverseDir ? containerRect.bottom - 1 : containerRect.top + 1;\n\treturn hiddenCaretRangeFromPoint( ownerDocument, x, y, container );\n}\n\n/**\n * Places the caret at start or end of a given element.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse True for end, false for start.\n * @param {number|undefined} x X coordinate to vertically position.\n */\nexport default function placeCaretAtEdge( container, isReverse, x ) {\n\tif ( ! container ) {\n\t\treturn;\n\t}\n\n\tcontainer.focus();\n\n\tif ( isInputOrTextArea( container ) ) {\n\t\t// The element may not support selection setting.\n\t\tif ( typeof container.selectionStart !== 'number' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isReverse ) {\n\t\t\tcontainer.selectionStart = container.value.length;\n\t\t\tcontainer.selectionEnd = container.value.length;\n\t\t} else {\n\t\t\tcontainer.selectionStart = 0;\n\t\t\tcontainer.selectionEnd = 0;\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif ( ! container.isContentEditable ) {\n\t\treturn;\n\t}\n\n\tconst range = scrollIfNoRange( container, isReverse, () =>\n\t\tgetRange( container, isReverse, x )\n\t);\n\n\tif ( ! range ) return;\n\n\tconst { ownerDocument } = container;\n\tconst { defaultView } = ownerDocument;\n\tassertIsDefined( defaultView, 'defaultView' );\n\tconst selection = defaultView.getSelection();\n\tassertIsDefined( selection, 'selection' );\n\tselection.removeAllRanges();\n\tselection.addRange( range );\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,0BAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,MAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AAPA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASK,QAAQA,CAAEC,SAAS,EAAEC,SAAS,EAAEC,CAAC,EAAG;EAC5C,MAAM;IAAEC;EAAc,CAAC,GAAGH,SAAS;EACnC;EACA,MAAMI,YAAY,GAAG,IAAAC,cAAK,EAAEL,SAAU,CAAC,GAAG,CAAEC,SAAS,GAAGA,SAAS;EACjE,MAAMK,aAAa,GAAGN,SAAS,CAACO,qBAAqB,CAAC,CAAC;EACvD;EACA;EACA;EACA;EACA,IAAKL,CAAC,KAAKM,SAAS,EAAG;IACtBN,CAAC,GAAGD,SAAS,GAAGK,aAAa,CAACG,KAAK,GAAG,CAAC,GAAGH,aAAa,CAACI,IAAI,GAAG,CAAC;EACjE,CAAC,MAAM,IAAKR,CAAC,IAAII,aAAa,CAACI,IAAI,EAAG;IACrCR,CAAC,GAAGI,aAAa,CAACI,IAAI,GAAG,CAAC;EAC3B,CAAC,MAAM,IAAKR,CAAC,IAAII,aAAa,CAACG,KAAK,EAAG;IACtCP,CAAC,GAAGI,aAAa,CAACG,KAAK,GAAG,CAAC;EAC5B;EACA,MAAME,CAAC,GAAGP,YAAY,GAAGE,aAAa,CAACM,MAAM,GAAG,CAAC,GAAGN,aAAa,CAACO,GAAG,GAAG,CAAC;EACzE,OAAO,IAAAC,kCAAyB,EAAEX,aAAa,EAAED,CAAC,EAAES,CAAC,EAAEX,SAAU,CAAC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASe,gBAAgBA,CAAEf,SAAS,EAAEC,SAAS,EAAEC,CAAC,EAAG;EACnE,IAAK,CAAEF,SAAS,EAAG;IAClB;EACD;EAEAA,SAAS,CAACgB,KAAK,CAAC,CAAC;EAEjB,IAAK,IAAAC,0BAAiB,EAAEjB,SAAU,CAAC,EAAG;IACrC;IACA,IAAK,OAAOA,SAAS,CAACkB,cAAc,KAAK,QAAQ,EAAG;MACnD;IACD;IAEA,IAAKjB,SAAS,EAAG;MAChBD,SAAS,CAACkB,cAAc,GAAGlB,SAAS,CAACmB,KAAK,CAACC,MAAM;MACjDpB,SAAS,CAACqB,YAAY,GAAGrB,SAAS,CAACmB,KAAK,CAACC,MAAM;IAChD,CAAC,MAAM;MACNpB,SAAS,CAACkB,cAAc,GAAG,CAAC;MAC5BlB,SAAS,CAACqB,YAAY,GAAG,CAAC;IAC3B;IAEA;EACD;EAEA,IAAK,CAAErB,SAAS,CAACsB,iBAAiB,EAAG;IACpC;EACD;EAEA,MAAMC,KAAK,GAAG,IAAAC,gCAAe,EAAExB,SAAS,EAAEC,SAAS,EAAE,MACpDF,QAAQ,CAAEC,SAAS,EAAEC,SAAS,EAAEC,CAAE,CACnC,CAAC;EAED,IAAK,CAAEqB,KAAK,EAAG;EAEf,MAAM;IAAEpB;EAAc,CAAC,GAAGH,SAAS;EACnC,MAAM;IAAEyB;EAAY,CAAC,GAAGtB,aAAa;EACrC,IAAAuB,gCAAe,EAAED,WAAW,EAAE,aAAc,CAAC;EAC7C,MAAME,SAAS,GAAGF,WAAW,CAACG,YAAY,CAAC,CAAC;EAC5C,IAAAF,gCAAe,EAAEC,SAAS,EAAE,WAAY,CAAC;EACzCA,SAAS,CAACE,eAAe,CAAC,CAAC;EAC3BF,SAAS,CAACG,QAAQ,CAAEP,KAAM,CAAC;AAC5B"}
|
@@ -1,14 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.default = placeCaretAtHorizontalEdge;
|
9
|
-
|
10
8
|
var _placeCaretAtEdge = _interopRequireDefault(require("./place-caret-at-edge"));
|
11
|
-
|
12
9
|
/**
|
13
10
|
* Internal dependencies
|
14
11
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["_placeCaretAtEdge","_interopRequireDefault","require","placeCaretAtHorizontalEdge","container","isReverse","placeCaretAtEdge","undefined"],"sources":["@wordpress/dom/src/dom/place-caret-at-horizontal-edge.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport placeCaretAtEdge from './place-caret-at-edge';\n\n/**\n * Places the caret at start or end of a given element.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse True for end, false for start.\n */\nexport default function placeCaretAtHorizontalEdge( container, isReverse ) {\n\treturn placeCaretAtEdge( container, isReverse, undefined );\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,0BAA0BA,CAAEC,SAAS,EAAEC,SAAS,EAAG;EAC1E,OAAO,IAAAC,yBAAgB,EAAEF,SAAS,EAAEC,SAAS,EAAEE,SAAU,CAAC;AAC3D"}
|