@wordpress/dom 4.32.0 → 4.32.1-next.ff1cebbba.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/build/data-transfer.js +30 -18
- package/build/data-transfer.js.map +7 -1
- package/build/dom/caret-range-from-point.js +22 -25
- package/build/dom/caret-range-from-point.js.map +7 -1
- package/build/dom/clean-node-list.js +122 -129
- package/build/dom/clean-node-list.js.map +7 -1
- package/build/dom/compute-caret-rect.js +36 -21
- package/build/dom/compute-caret-rect.js.map +7 -1
- package/build/dom/document-has-selection.js +36 -22
- package/build/dom/document-has-selection.js.map +7 -1
- package/build/dom/document-has-text-selection.js +25 -23
- package/build/dom/document-has-text-selection.js.map +7 -1
- package/build/dom/document-has-uncollapsed-selection.js +35 -22
- package/build/dom/document-has-uncollapsed-selection.js.map +7 -1
- package/build/dom/get-computed-style.js +27 -17
- package/build/dom/get-computed-style.js.map +7 -1
- package/build/dom/get-offset-parent.js +43 -32
- package/build/dom/get-offset-parent.js.map +7 -1
- package/build/dom/get-range-height.js +24 -18
- package/build/dom/get-range-height.js.map +7 -1
- package/build/dom/get-rectangle-from-range.js +47 -68
- package/build/dom/get-rectangle-from-range.js.map +7 -1
- package/build/dom/get-scroll-container.js +44 -37
- package/build/dom/get-scroll-container.js.map +7 -1
- package/build/dom/hidden-caret-range-from-point.js +39 -33
- package/build/dom/hidden-caret-range-from-point.js.map +7 -1
- package/build/dom/index.js +116 -195
- package/build/dom/index.js.map +7 -1
- package/build/dom/input-field-has-uncollapsed-selection.js +40 -42
- package/build/dom/input-field-has-uncollapsed-selection.js.map +7 -1
- package/build/dom/insert-after.js +24 -19
- package/build/dom/insert-after.js.map +7 -1
- package/build/dom/is-edge.js +57 -67
- package/build/dom/is-edge.js.map +7 -1
- package/build/dom/is-element.js +22 -11
- package/build/dom/is-element.js.map +7 -1
- package/build/dom/is-empty.js +27 -17
- package/build/dom/is-empty.js.map +7 -1
- package/build/dom/is-entirely-selected.js +46 -50
- package/build/dom/is-entirely-selected.js.map +7 -1
- package/build/dom/is-form-element.js +36 -24
- package/build/dom/is-form-element.js.map +7 -1
- package/build/dom/is-horizontal-edge.js +34 -20
- package/build/dom/is-horizontal-edge.js.map +7 -1
- package/build/dom/is-html-input-element.js +23 -12
- package/build/dom/is-html-input-element.js.map +7 -1
- package/build/dom/is-input-or-text-area.js +23 -12
- package/build/dom/is-input-or-text-area.js.map +7 -1
- package/build/dom/is-number-input.js +38 -29
- package/build/dom/is-number-input.js.map +7 -1
- package/build/dom/is-rtl.js +34 -19
- package/build/dom/is-rtl.js.map +7 -1
- package/build/dom/is-selection-forward.js +26 -40
- package/build/dom/is-selection-forward.js.map +7 -1
- package/build/dom/is-text-field.js +49 -24
- package/build/dom/is-text-field.js.map +7 -1
- package/build/dom/is-vertical-edge.js +34 -20
- package/build/dom/is-vertical-edge.js.map +7 -1
- package/build/dom/place-caret-at-edge.js +52 -55
- package/build/dom/place-caret-at-edge.js.map +7 -1
- package/build/dom/place-caret-at-horizontal-edge.js +34 -18
- package/build/dom/place-caret-at-horizontal-edge.js.map +7 -1
- package/build/dom/place-caret-at-vertical-edge.js +34 -19
- package/build/dom/place-caret-at-vertical-edge.js.map +7 -1
- package/build/dom/remove-invalid-html.js +35 -22
- package/build/dom/remove-invalid-html.js.map +7 -1
- package/build/dom/remove.js +24 -17
- package/build/dom/remove.js.map +7 -1
- package/build/dom/replace-tag.js +24 -19
- package/build/dom/replace-tag.js.map +7 -1
- package/build/dom/replace.js +38 -23
- package/build/dom/replace.js.map +7 -1
- package/build/dom/safe-html.js +39 -28
- package/build/dom/safe-html.js.map +7 -1
- package/build/dom/scroll-if-no-range.js +26 -18
- package/build/dom/scroll-if-no-range.js.map +7 -1
- package/build/dom/strip-html.js +36 -23
- package/build/dom/strip-html.js.map +7 -1
- package/build/dom/unwrap.js +24 -18
- package/build/dom/unwrap.js.map +7 -1
- package/build/dom/wrap.js +24 -17
- package/build/dom/wrap.js.map +7 -1
- package/build/focusable.js +52 -85
- package/build/focusable.js.map +7 -1
- package/build/index.js +44 -58
- package/build/index.js.map +7 -1
- package/build/phrasing-content.js +88 -128
- package/build/phrasing-content.js.map +7 -1
- package/build/tabbable.js +52 -137
- package/build/tabbable.js.map +7 -1
- package/build/utils/assert-is-defined.js +30 -7
- package/build/utils/assert-is-defined.js.map +7 -1
- package/build-module/data-transfer.js +9 -15
- package/build-module/data-transfer.js.map +7 -1
- package/build-module/dom/caret-range-from-point.js +5 -22
- package/build-module/dom/caret-range-from-point.js.map +7 -1
- package/build-module/dom/clean-node-list.js +94 -123
- package/build-module/dom/clean-node-list.js.map +7 -1
- package/build-module/dom/compute-caret-rect.js +8 -16
- package/build-module/dom/compute-caret-rect.js.map +7 -1
- package/build-module/dom/document-has-selection.js +8 -17
- package/build-module/dom/document-has-selection.js.map +7 -1
- package/build-module/dom/document-has-text-selection.js +8 -20
- package/build-module/dom/document-has-text-selection.js.map +7 -1
- package/build-module/dom/document-has-uncollapsed-selection.js +7 -17
- package/build-module/dom/document-has-uncollapsed-selection.js.map +7 -1
- package/build-module/dom/get-computed-style.js +10 -14
- package/build-module/dom/get-computed-style.js.map +7 -1
- package/build-module/dom/get-offset-parent.js +16 -28
- package/build-module/dom/get-offset-parent.js.map +7 -1
- package/build-module/dom/get-range-height.js +7 -15
- package/build-module/dom/get-range-height.js.map +7 -1
- package/build-module/dom/get-rectangle-from-range.js +30 -65
- package/build-module/dom/get-rectangle-from-range.js.map +7 -1
- package/build-module/dom/get-scroll-container.js +16 -32
- package/build-module/dom/get-scroll-container.js.map +7 -1
- package/build-module/dom/hidden-caret-range-from-point.js +11 -28
- package/build-module/dom/hidden-caret-range-from-point.js.map +7 -1
- package/build-module/dom/index.js +57 -28
- package/build-module/dom/index.js.map +7 -1
- package/build-module/dom/input-field-has-uncollapsed-selection.js +12 -37
- package/build-module/dom/input-field-has-uncollapsed-selection.js.map +7 -1
- package/build-module/dom/insert-after.js +7 -16
- package/build-module/dom/insert-after.js.map +7 -1
- package/build-module/dom/is-edge.js +24 -57
- package/build-module/dom/is-edge.js.map +7 -1
- package/build-module/dom/is-element.js +5 -8
- package/build-module/dom/is-element.js.map +7 -1
- package/build-module/dom/is-empty.js +10 -14
- package/build-module/dom/is-empty.js.map +7 -1
- package/build-module/dom/is-entirely-selected.js +18 -45
- package/build-module/dom/is-entirely-selected.js.map +7 -1
- package/build-module/dom/is-form-element.js +8 -19
- package/build-module/dom/is-form-element.js.map +7 -1
- package/build-module/dom/is-horizontal-edge.js +6 -15
- package/build-module/dom/is-horizontal-edge.js.map +7 -1
- package/build-module/dom/is-html-input-element.js +6 -9
- package/build-module/dom/is-html-input-element.js.map +7 -1
- package/build-module/dom/is-input-or-text-area.js +6 -9
- package/build-module/dom/is-input-or-text-area.js.map +7 -1
- package/build-module/dom/is-number-input.js +11 -25
- package/build-module/dom/is-number-input.js.map +7 -1
- package/build-module/dom/is-rtl.js +7 -15
- package/build-module/dom/is-rtl.js.map +7 -1
- package/build-module/dom/is-selection-forward.js +9 -37
- package/build-module/dom/is-selection-forward.js.map +7 -1
- package/build-module/dom/is-text-field.js +22 -20
- package/build-module/dom/is-text-field.js.map +7 -1
- package/build-module/dom/is-vertical-edge.js +6 -15
- package/build-module/dom/is-vertical-edge.js.map +7 -1
- package/build-module/dom/place-caret-at-edge.js +22 -48
- package/build-module/dom/place-caret-at-edge.js.map +7 -1
- package/build-module/dom/place-caret-at-horizontal-edge.js +7 -14
- package/build-module/dom/place-caret-at-horizontal-edge.js.map +7 -1
- package/build-module/dom/place-caret-at-vertical-edge.js +6 -14
- package/build-module/dom/place-caret-at-vertical-edge.js.map +7 -1
- package/build-module/dom/remove-invalid-html.js +7 -17
- package/build-module/dom/remove-invalid-html.js.map +7 -1
- package/build-module/dom/remove.js +7 -14
- package/build-module/dom/remove.js.map +7 -1
- package/build-module/dom/replace-tag.js +7 -16
- package/build-module/dom/replace-tag.js.map +7 -1
- package/build-module/dom/replace.js +9 -17
- package/build-module/dom/replace.js.map +7 -1
- package/build-module/dom/safe-html.js +11 -23
- package/build-module/dom/safe-html.js.map +7 -1
- package/build-module/dom/scroll-if-no-range.js +5 -15
- package/build-module/dom/scroll-if-no-range.js.map +7 -1
- package/build-module/dom/strip-html.js +8 -18
- package/build-module/dom/strip-html.js.map +7 -1
- package/build-module/dom/unwrap.js +7 -15
- package/build-module/dom/unwrap.js.map +7 -1
- package/build-module/dom/wrap.js +7 -14
- package/build-module/dom/wrap.js.map +7 -1
- package/build-module/focusable.js +30 -81
- package/build-module/focusable.js.map +7 -1
- package/build-module/index.js +9 -17
- package/build-module/index.js.map +7 -1
- package/build-module/phrasing-content.js +67 -125
- package/build-module/phrasing-content.js.map +7 -1
- package/build-module/tabbable.js +30 -133
- package/build-module/tabbable.js.map +7 -1
- package/build-module/utils/assert-is-defined.js +9 -4
- package/build-module/utils/assert-is-defined.js.map +7 -1
- package/package.json +11 -4
package/build/tabbable.js
CHANGED
|
@@ -1,130 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var tabbable_exports = {};
|
|
20
|
+
__export(tabbable_exports, {
|
|
21
|
+
find: () => find,
|
|
22
|
+
findNext: () => findNext,
|
|
23
|
+
findPrevious: () => findPrevious,
|
|
24
|
+
isTabbableIndex: () => isTabbableIndex
|
|
5
25
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
exports.findPrevious = findPrevious;
|
|
9
|
-
exports.isTabbableIndex = isTabbableIndex;
|
|
10
|
-
var _focusable = require("./focusable");
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Returns the tab index of the given element. In contrast with the tabIndex
|
|
17
|
-
* property, this normalizes the default (0) to avoid browser inconsistencies,
|
|
18
|
-
* operating under the assumption that this function is only ever called with a
|
|
19
|
-
* focusable node.
|
|
20
|
-
*
|
|
21
|
-
* @see https://bugzilla.mozilla.org/show_bug.cgi?id=1190261
|
|
22
|
-
*
|
|
23
|
-
* @param {Element} element Element from which to retrieve.
|
|
24
|
-
*
|
|
25
|
-
* @return {number} Tab index of element (default 0).
|
|
26
|
-
*/
|
|
26
|
+
module.exports = __toCommonJS(tabbable_exports);
|
|
27
|
+
var import_focusable = require("./focusable");
|
|
27
28
|
function getTabIndex(element) {
|
|
28
|
-
const tabIndex = element.getAttribute(
|
|
29
|
+
const tabIndex = element.getAttribute("tabindex");
|
|
29
30
|
return tabIndex === null ? 0 : parseInt(tabIndex, 10);
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Returns true if the specified element is tabbable, or false otherwise.
|
|
34
|
-
*
|
|
35
|
-
* @param {Element} element Element to test.
|
|
36
|
-
*
|
|
37
|
-
* @return {boolean} Whether element is tabbable.
|
|
38
|
-
*/
|
|
39
32
|
function isTabbableIndex(element) {
|
|
40
33
|
return getTabIndex(element) !== -1;
|
|
41
34
|
}
|
|
42
|
-
|
|
43
|
-
/** @typedef {HTMLElement & { type?: string, checked?: boolean, name?: string }} MaybeHTMLInputElement */
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Returns a stateful reducer function which constructs a filtered array of
|
|
47
|
-
* tabbable elements, where at most one radio input is selected for a given
|
|
48
|
-
* name, giving priority to checked input, falling back to the first
|
|
49
|
-
* encountered.
|
|
50
|
-
*
|
|
51
|
-
* @return {(acc: MaybeHTMLInputElement[], el: MaybeHTMLInputElement) => MaybeHTMLInputElement[]} Radio group collapse reducer.
|
|
52
|
-
*/
|
|
53
35
|
function createStatefulCollapseRadioGroup() {
|
|
54
|
-
/** @type {Record<string, MaybeHTMLInputElement>} */
|
|
55
36
|
const CHOSEN_RADIO_BY_NAME = {};
|
|
56
|
-
return function collapseRadioGroup(
|
|
57
|
-
const {
|
|
58
|
-
|
|
59
|
-
type,
|
|
60
|
-
checked,
|
|
61
|
-
name
|
|
62
|
-
} = element;
|
|
63
|
-
|
|
64
|
-
// For all non-radio tabbables, construct to array by concatenating.
|
|
65
|
-
if (nodeName !== 'INPUT' || type !== 'radio' || !name) {
|
|
37
|
+
return function collapseRadioGroup(result, element) {
|
|
38
|
+
const { nodeName, type, checked, name } = element;
|
|
39
|
+
if (nodeName !== "INPUT" || type !== "radio" || !name) {
|
|
66
40
|
return result.concat(element);
|
|
67
41
|
}
|
|
68
42
|
const hasChosen = CHOSEN_RADIO_BY_NAME.hasOwnProperty(name);
|
|
69
|
-
|
|
70
|
-
// Omit by skipping concatenation if the radio element is not chosen.
|
|
71
43
|
const isChosen = checked || !hasChosen;
|
|
72
44
|
if (!isChosen) {
|
|
73
45
|
return result;
|
|
74
46
|
}
|
|
75
|
-
|
|
76
|
-
// At this point, if there had been a chosen element, the current
|
|
77
|
-
// element is checked and should take priority. Retroactively remove
|
|
78
|
-
// the element which had previously been considered the chosen one.
|
|
79
47
|
if (hasChosen) {
|
|
80
48
|
const hadChosenElement = CHOSEN_RADIO_BY_NAME[name];
|
|
81
|
-
result = result.filter(e => e !== hadChosenElement);
|
|
49
|
+
result = result.filter((e) => e !== hadChosenElement);
|
|
82
50
|
}
|
|
83
51
|
CHOSEN_RADIO_BY_NAME[name] = element;
|
|
84
52
|
return result.concat(element);
|
|
85
53
|
};
|
|
86
54
|
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* An array map callback, returning an object with the element value and its
|
|
90
|
-
* array index location as properties. This is used to emulate a proper stable
|
|
91
|
-
* sort where equal tabIndex should be left in order of their occurrence in the
|
|
92
|
-
* document.
|
|
93
|
-
*
|
|
94
|
-
* @param {HTMLElement} element Element.
|
|
95
|
-
* @param {number} index Array index of element.
|
|
96
|
-
*
|
|
97
|
-
* @return {{ element: HTMLElement, index: number }} Mapped object with element, index.
|
|
98
|
-
*/
|
|
99
55
|
function mapElementToObjectTabbable(element, index) {
|
|
100
|
-
return {
|
|
101
|
-
element,
|
|
102
|
-
index
|
|
103
|
-
};
|
|
56
|
+
return { element, index };
|
|
104
57
|
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* An array map callback, returning an element of the given mapped object's
|
|
108
|
-
* element value.
|
|
109
|
-
*
|
|
110
|
-
* @param {{ element: HTMLElement }} object Mapped object with element.
|
|
111
|
-
*
|
|
112
|
-
* @return {HTMLElement} Mapped object element.
|
|
113
|
-
*/
|
|
114
58
|
function mapObjectTabbableToElement(object) {
|
|
115
59
|
return object.element;
|
|
116
60
|
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* A sort comparator function used in comparing two objects of mapped elements.
|
|
120
|
-
*
|
|
121
|
-
* @see mapElementToObjectTabbable
|
|
122
|
-
*
|
|
123
|
-
* @param {{ element: HTMLElement, index: number }} a First object to compare.
|
|
124
|
-
* @param {{ element: HTMLElement, index: number }} b Second object to compare.
|
|
125
|
-
*
|
|
126
|
-
* @return {number} Comparator result.
|
|
127
|
-
*/
|
|
128
61
|
function compareObjectTabbables(a, b) {
|
|
129
62
|
const aTabIndex = getTabIndex(a.element);
|
|
130
63
|
const bTabIndex = getTabIndex(b.element);
|
|
@@ -133,51 +66,33 @@ function compareObjectTabbables(a, b) {
|
|
|
133
66
|
}
|
|
134
67
|
return aTabIndex - bTabIndex;
|
|
135
68
|
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Givin focusable elements, filters out tabbable element.
|
|
139
|
-
*
|
|
140
|
-
* @param {HTMLElement[]} focusables Focusable elements to filter.
|
|
141
|
-
*
|
|
142
|
-
* @return {HTMLElement[]} Tabbable elements.
|
|
143
|
-
*/
|
|
144
69
|
function filterTabbable(focusables) {
|
|
145
70
|
return focusables.filter(isTabbableIndex).map(mapElementToObjectTabbable).sort(compareObjectTabbables).map(mapObjectTabbableToElement).reduce(createStatefulCollapseRadioGroup(), []);
|
|
146
71
|
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* @param {Element} context
|
|
150
|
-
* @return {HTMLElement[]} Tabbable elements within the context.
|
|
151
|
-
*/
|
|
152
72
|
function find(context) {
|
|
153
|
-
return filterTabbable((0,
|
|
73
|
+
return filterTabbable((0, import_focusable.find)(context));
|
|
154
74
|
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Given a focusable element, find the preceding tabbable element.
|
|
158
|
-
*
|
|
159
|
-
* @param {Element} element The focusable element before which to look. Defaults
|
|
160
|
-
* to the active element.
|
|
161
|
-
*
|
|
162
|
-
* @return {HTMLElement|undefined} Preceding tabbable element.
|
|
163
|
-
*/
|
|
164
75
|
function findPrevious(element) {
|
|
165
|
-
return filterTabbable((0,
|
|
166
|
-
|
|
167
|
-
|
|
76
|
+
return filterTabbable((0, import_focusable.find)(element.ownerDocument.body)).reverse().find(
|
|
77
|
+
(focusable) => (
|
|
78
|
+
// eslint-disable-next-line no-bitwise
|
|
79
|
+
element.compareDocumentPosition(focusable) & element.DOCUMENT_POSITION_PRECEDING
|
|
80
|
+
)
|
|
81
|
+
);
|
|
168
82
|
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Given a focusable element, find the next tabbable element.
|
|
172
|
-
*
|
|
173
|
-
* @param {Element} element The focusable element after which to look. Defaults
|
|
174
|
-
* to the active element.
|
|
175
|
-
*
|
|
176
|
-
* @return {HTMLElement|undefined} Next tabbable element.
|
|
177
|
-
*/
|
|
178
83
|
function findNext(element) {
|
|
179
|
-
return filterTabbable((0,
|
|
180
|
-
|
|
181
|
-
|
|
84
|
+
return filterTabbable((0, import_focusable.find)(element.ownerDocument.body)).find(
|
|
85
|
+
(focusable) => (
|
|
86
|
+
// eslint-disable-next-line no-bitwise
|
|
87
|
+
element.compareDocumentPosition(focusable) & element.DOCUMENT_POSITION_FOLLOWING
|
|
88
|
+
)
|
|
89
|
+
);
|
|
182
90
|
}
|
|
183
|
-
|
|
91
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
+
0 && (module.exports = {
|
|
93
|
+
find,
|
|
94
|
+
findNext,
|
|
95
|
+
findPrevious,
|
|
96
|
+
isTabbableIndex
|
|
97
|
+
});
|
|
98
|
+
//# sourceMappingURL=tabbable.js.map
|
package/build/tabbable.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/tabbable.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { find as findFocusable } from './focusable';\n\n/**\n * Returns the tab index of the given element. In contrast with the tabIndex\n * property, this normalizes the default (0) to avoid browser inconsistencies,\n * operating under the assumption that this function is only ever called with a\n * focusable node.\n *\n * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1190261\n *\n * @param {Element} element Element from which to retrieve.\n *\n * @return {number} Tab index of element (default 0).\n */\nfunction getTabIndex( element ) {\n\tconst tabIndex = element.getAttribute( 'tabindex' );\n\treturn tabIndex === null ? 0 : parseInt( tabIndex, 10 );\n}\n\n/**\n * Returns true if the specified element is tabbable, or false otherwise.\n *\n * @param {Element} element Element to test.\n *\n * @return {boolean} Whether element is tabbable.\n */\nexport function isTabbableIndex( element ) {\n\treturn getTabIndex( element ) !== -1;\n}\n\n/** @typedef {HTMLElement & { type?: string, checked?: boolean, name?: string }} MaybeHTMLInputElement */\n\n/**\n * Returns a stateful reducer function which constructs a filtered array of\n * tabbable elements, where at most one radio input is selected for a given\n * name, giving priority to checked input, falling back to the first\n * encountered.\n *\n * @return {(acc: MaybeHTMLInputElement[], el: MaybeHTMLInputElement) => MaybeHTMLInputElement[]} Radio group collapse reducer.\n */\nfunction createStatefulCollapseRadioGroup() {\n\t/** @type {Record<string, MaybeHTMLInputElement>} */\n\tconst CHOSEN_RADIO_BY_NAME = {};\n\n\treturn function collapseRadioGroup(\n\t\t/** @type {MaybeHTMLInputElement[]} */ result,\n\t\t/** @type {MaybeHTMLInputElement} */ element\n\t) {\n\t\tconst { nodeName, type, checked, name } = element;\n\n\t\t// For all non-radio tabbables, construct to array by concatenating.\n\t\tif ( nodeName !== 'INPUT' || type !== 'radio' || ! name ) {\n\t\t\treturn result.concat( element );\n\t\t}\n\n\t\tconst hasChosen = CHOSEN_RADIO_BY_NAME.hasOwnProperty( name );\n\n\t\t// Omit by skipping concatenation if the radio element is not chosen.\n\t\tconst isChosen = checked || ! hasChosen;\n\t\tif ( ! isChosen ) {\n\t\t\treturn result;\n\t\t}\n\n\t\t// At this point, if there had been a chosen element, the current\n\t\t// element is checked and should take priority. Retroactively remove\n\t\t// the element which had previously been considered the chosen one.\n\t\tif ( hasChosen ) {\n\t\t\tconst hadChosenElement = CHOSEN_RADIO_BY_NAME[ name ];\n\t\t\tresult = result.filter( ( e ) => e !== hadChosenElement );\n\t\t}\n\n\t\tCHOSEN_RADIO_BY_NAME[ name ] = element;\n\n\t\treturn result.concat( element );\n\t};\n}\n\n/**\n * An array map callback, returning an object with the element value and its\n * array index location as properties. This is used to emulate a proper stable\n * sort where equal tabIndex should be left in order of their occurrence in the\n * document.\n *\n * @param {HTMLElement} element Element.\n * @param {number} index Array index of element.\n *\n * @return {{ element: HTMLElement, index: number }} Mapped object with element, index.\n */\nfunction mapElementToObjectTabbable( element, index ) {\n\treturn { element, index };\n}\n\n/**\n * An array map callback, returning an element of the given mapped object's\n * element value.\n *\n * @param {{ element: HTMLElement }} object Mapped object with element.\n *\n * @return {HTMLElement} Mapped object element.\n */\nfunction mapObjectTabbableToElement( object ) {\n\treturn object.element;\n}\n\n/**\n * A sort comparator function used in comparing two objects of mapped elements.\n *\n * @see mapElementToObjectTabbable\n *\n * @param {{ element: HTMLElement, index: number }} a First object to compare.\n * @param {{ element: HTMLElement, index: number }} b Second object to compare.\n *\n * @return {number} Comparator result.\n */\nfunction compareObjectTabbables( a, b ) {\n\tconst aTabIndex = getTabIndex( a.element );\n\tconst bTabIndex = getTabIndex( b.element );\n\n\tif ( aTabIndex === bTabIndex ) {\n\t\treturn a.index - b.index;\n\t}\n\n\treturn aTabIndex - bTabIndex;\n}\n\n/**\n * Givin focusable elements, filters out tabbable element.\n *\n * @param {HTMLElement[]} focusables Focusable elements to filter.\n *\n * @return {HTMLElement[]} Tabbable elements.\n */\nfunction filterTabbable( focusables ) {\n\treturn focusables\n\t\t.filter( isTabbableIndex )\n\t\t.map( mapElementToObjectTabbable )\n\t\t.sort( compareObjectTabbables )\n\t\t.map( mapObjectTabbableToElement )\n\t\t.reduce( createStatefulCollapseRadioGroup(), [] );\n}\n\n/**\n * @param {Element} context\n * @return {HTMLElement[]} Tabbable elements within the context.\n */\nexport function find( context ) {\n\treturn filterTabbable( findFocusable( context ) );\n}\n\n/**\n * Given a focusable element, find the preceding tabbable element.\n *\n * @param {Element} element The focusable element before which to look. Defaults\n * to the active element.\n *\n * @return {HTMLElement|undefined} Preceding tabbable element.\n */\nexport function findPrevious( element ) {\n\treturn filterTabbable( findFocusable( element.ownerDocument.body ) )\n\t\t.reverse()\n\t\t.find(\n\t\t\t( focusable ) =>\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\telement.compareDocumentPosition( focusable ) &\n\t\t\t\telement.DOCUMENT_POSITION_PRECEDING\n\t\t);\n}\n\n/**\n * Given a focusable element, find the next tabbable element.\n *\n * @param {Element} element The focusable element after which to look. Defaults\n * to the active element.\n *\n * @return {HTMLElement|undefined} Next tabbable element.\n */\nexport function findNext( element ) {\n\treturn filterTabbable( findFocusable( element.ownerDocument.body ) ).find(\n\t\t( focusable ) =>\n\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\telement.compareDocumentPosition( focusable ) &\n\t\t\telement.DOCUMENT_POSITION_FOLLOWING\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAsC;AActC,SAAS,YAAa,SAAU;AAC/B,QAAM,WAAW,QAAQ,aAAc,UAAW;AAClD,SAAO,aAAa,OAAO,IAAI,SAAU,UAAU,EAAG;AACvD;AASO,SAAS,gBAAiB,SAAU;AAC1C,SAAO,YAAa,OAAQ,MAAM;AACnC;AAYA,SAAS,mCAAmC;AAE3C,QAAM,uBAAuB,CAAC;AAE9B,SAAO,SAAS,mBACwB,QACF,SACpC;AACD,UAAM,EAAE,UAAU,MAAM,SAAS,KAAK,IAAI;AAG1C,QAAK,aAAa,WAAW,SAAS,WAAW,CAAE,MAAO;AACzD,aAAO,OAAO,OAAQ,OAAQ;AAAA,IAC/B;AAEA,UAAM,YAAY,qBAAqB,eAAgB,IAAK;AAG5D,UAAM,WAAW,WAAW,CAAE;AAC9B,QAAK,CAAE,UAAW;AACjB,aAAO;AAAA,IACR;AAKA,QAAK,WAAY;AAChB,YAAM,mBAAmB,qBAAsB,IAAK;AACpD,eAAS,OAAO,OAAQ,CAAE,MAAO,MAAM,gBAAiB;AAAA,IACzD;AAEA,yBAAsB,IAAK,IAAI;AAE/B,WAAO,OAAO,OAAQ,OAAQ;AAAA,EAC/B;AACD;AAaA,SAAS,2BAA4B,SAAS,OAAQ;AACrD,SAAO,EAAE,SAAS,MAAM;AACzB;AAUA,SAAS,2BAA4B,QAAS;AAC7C,SAAO,OAAO;AACf;AAYA,SAAS,uBAAwB,GAAG,GAAI;AACvC,QAAM,YAAY,YAAa,EAAE,OAAQ;AACzC,QAAM,YAAY,YAAa,EAAE,OAAQ;AAEzC,MAAK,cAAc,WAAY;AAC9B,WAAO,EAAE,QAAQ,EAAE;AAAA,EACpB;AAEA,SAAO,YAAY;AACpB;AASA,SAAS,eAAgB,YAAa;AACrC,SAAO,WACL,OAAQ,eAAgB,EACxB,IAAK,0BAA2B,EAChC,KAAM,sBAAuB,EAC7B,IAAK,0BAA2B,EAChC,OAAQ,iCAAiC,GAAG,CAAC,CAAE;AAClD;AAMO,SAAS,KAAM,SAAU;AAC/B,SAAO,mBAAgB,iBAAAA,MAAe,OAAQ,CAAE;AACjD;AAUO,SAAS,aAAc,SAAU;AACvC,SAAO,mBAAgB,iBAAAA,MAAe,QAAQ,cAAc,IAAK,CAAE,EACjE,QAAQ,EACR;AAAA,IACA,CAAE;AAAA;AAAA,MAED,QAAQ,wBAAyB,SAAU,IAC3C,QAAQ;AAAA;AAAA,EACV;AACF;AAUO,SAAS,SAAU,SAAU;AACnC,SAAO,mBAAgB,iBAAAA,MAAe,QAAQ,cAAc,IAAK,CAAE,EAAE;AAAA,IACpE,CAAE;AAAA;AAAA,MAED,QAAQ,wBAAyB,SAAU,IAC3C,QAAQ;AAAA;AAAA,EACV;AACD;",
|
|
6
|
+
"names": ["findFocusable"]
|
|
7
|
+
}
|
|
@@ -1,12 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var assert_is_defined_exports = {};
|
|
20
|
+
__export(assert_is_defined_exports, {
|
|
21
|
+
assertIsDefined: () => assertIsDefined
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
23
|
+
module.exports = __toCommonJS(assert_is_defined_exports);
|
|
7
24
|
function assertIsDefined(val, name) {
|
|
8
|
-
if (process.env.NODE_ENV !==
|
|
9
|
-
throw new Error(
|
|
25
|
+
if (process.env.NODE_ENV !== "production" && (val === void 0 || val === null)) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`Expected '${name}' to be defined, but received ${val}`
|
|
28
|
+
);
|
|
10
29
|
}
|
|
11
30
|
}
|
|
12
|
-
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
assertIsDefined
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=assert-is-defined.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/assert-is-defined.ts"],
|
|
4
|
+
"sourcesContent": ["export function assertIsDefined< T >(\n\tval: T,\n\tname: string\n): asserts val is NonNullable< T > {\n\tif (\n\t\tprocess.env.NODE_ENV !== 'production' &&\n\t\t( val === undefined || val === null )\n\t) {\n\t\tthrow new Error(\n\t\t\t`Expected '${ name }' to be defined, but received ${ val }`\n\t\t);\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,gBACf,KACA,MACkC;AAClC,MACC,QAAQ,IAAI,aAAa,iBACvB,QAAQ,UAAa,QAAQ,OAC9B;AACD,UAAM,IAAI;AAAA,MACT,aAAc,IAAK,iCAAkC,GAAI;AAAA,IAC1D;AAAA,EACD;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
* Gets all files from a DataTransfer object.
|
|
3
|
-
*
|
|
4
|
-
* @param {DataTransfer} dataTransfer DataTransfer object to inspect.
|
|
5
|
-
*
|
|
6
|
-
* @return {File[]} An array containing all files.
|
|
7
|
-
*/
|
|
8
|
-
export function getFilesFromDataTransfer(dataTransfer) {
|
|
1
|
+
function getFilesFromDataTransfer(dataTransfer) {
|
|
9
2
|
const files = Array.from(dataTransfer.files);
|
|
10
|
-
Array.from(dataTransfer.items).forEach(item => {
|
|
3
|
+
Array.from(dataTransfer.items).forEach((item) => {
|
|
11
4
|
const file = item.getAsFile();
|
|
12
|
-
if (file && !files.find(
|
|
13
|
-
name,
|
|
14
|
-
|
|
15
|
-
size
|
|
16
|
-
}) => name === file.name && type === file.type && size === file.size)) {
|
|
5
|
+
if (file && !files.find(
|
|
6
|
+
({ name, type, size }) => name === file.name && type === file.type && size === file.size
|
|
7
|
+
)) {
|
|
17
8
|
files.push(file);
|
|
18
9
|
}
|
|
19
10
|
});
|
|
20
11
|
return files;
|
|
21
12
|
}
|
|
22
|
-
|
|
13
|
+
export {
|
|
14
|
+
getFilesFromDataTransfer
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=data-transfer.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/data-transfer.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Gets all files from a DataTransfer object.\n *\n * @param {DataTransfer} dataTransfer DataTransfer object to inspect.\n *\n * @return {File[]} An array containing all files.\n */\nexport function getFilesFromDataTransfer( dataTransfer ) {\n\tconst files = Array.from( dataTransfer.files );\n\n\tArray.from( dataTransfer.items ).forEach( ( item ) => {\n\t\tconst file = item.getAsFile();\n\n\t\tif (\n\t\t\tfile &&\n\t\t\t! files.find(\n\t\t\t\t( { name, type, size } ) =>\n\t\t\t\t\tname === file.name &&\n\t\t\t\t\ttype === file.type &&\n\t\t\t\t\tsize === file.size\n\t\t\t)\n\t\t) {\n\t\t\tfiles.push( file );\n\t\t}\n\t} );\n\n\treturn files;\n}\n"],
|
|
5
|
+
"mappings": "AAOO,SAAS,yBAA0B,cAAe;AACxD,QAAM,QAAQ,MAAM,KAAM,aAAa,KAAM;AAE7C,QAAM,KAAM,aAAa,KAAM,EAAE,QAAS,CAAE,SAAU;AACrD,UAAM,OAAO,KAAK,UAAU;AAE5B,QACC,QACA,CAAE,MAAM;AAAA,MACP,CAAE,EAAE,MAAM,MAAM,KAAK,MACpB,SAAS,KAAK,QACd,SAAS,KAAK,QACd,SAAS,KAAK;AAAA,IAChB,GACC;AACD,YAAM,KAAM,IAAK;AAAA,IAClB;AAAA,EACD,CAAE;AAEF,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Polyfill.
|
|
3
|
-
* Get a collapsed range for a given point.
|
|
4
|
-
*
|
|
5
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint
|
|
6
|
-
*
|
|
7
|
-
* @param {DocumentMaybeWithCaretPositionFromPoint} doc The document of the range.
|
|
8
|
-
* @param {number} x Horizontal position within the current viewport.
|
|
9
|
-
* @param {number} y Vertical position within the current viewport.
|
|
10
|
-
*
|
|
11
|
-
* @return {Range | null} The best range for the given point.
|
|
12
|
-
*/
|
|
13
|
-
export default function caretRangeFromPoint(doc, x, y) {
|
|
1
|
+
function caretRangeFromPoint(doc, x, y) {
|
|
14
2
|
if (doc.caretRangeFromPoint) {
|
|
15
3
|
return doc.caretRangeFromPoint(x, y);
|
|
16
4
|
}
|
|
@@ -18,9 +6,6 @@ export default function caretRangeFromPoint(doc, x, y) {
|
|
|
18
6
|
return null;
|
|
19
7
|
}
|
|
20
8
|
const point = doc.caretPositionFromPoint(x, y);
|
|
21
|
-
|
|
22
|
-
// If x or y are negative, outside viewport, or there is no text entry node.
|
|
23
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint
|
|
24
9
|
if (!point) {
|
|
25
10
|
return null;
|
|
26
11
|
}
|
|
@@ -29,9 +14,7 @@ export default function caretRangeFromPoint(doc, x, y) {
|
|
|
29
14
|
range.collapse(true);
|
|
30
15
|
return range;
|
|
31
16
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*/
|
|
37
|
-
//# sourceMappingURL=caret-range-from-point.js.map
|
|
17
|
+
export {
|
|
18
|
+
caretRangeFromPoint as default
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=caret-range-from-point.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dom/caret-range-from-point.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Polyfill.\n * Get a collapsed range for a given point.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint\n *\n * @param {DocumentMaybeWithCaretPositionFromPoint} doc The document of the range.\n * @param {number} x Horizontal position within the current viewport.\n * @param {number} y Vertical position within the current viewport.\n *\n * @return {Range | null} The best range for the given point.\n */\nexport default function caretRangeFromPoint( doc, x, y ) {\n\tif ( doc.caretRangeFromPoint ) {\n\t\treturn doc.caretRangeFromPoint( x, y );\n\t}\n\n\tif ( ! doc.caretPositionFromPoint ) {\n\t\treturn null;\n\t}\n\n\tconst point = doc.caretPositionFromPoint( x, y );\n\n\t// If x or y are negative, outside viewport, or there is no text entry node.\n\t// https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint\n\tif ( ! point ) {\n\t\treturn null;\n\t}\n\n\tconst range = doc.createRange();\n\n\trange.setStart( point.offsetNode, point.offset );\n\trange.collapse( true );\n\n\treturn range;\n}\n\n/**\n * @typedef {{caretPositionFromPoint?: (x: number, y: number)=> CaretPosition | null} & Document } DocumentMaybeWithCaretPositionFromPoint\n * @typedef {{ readonly offset: number; readonly offsetNode: Node; getClientRect(): DOMRect | null; }} CaretPosition\n */\n"],
|
|
5
|
+
"mappings": "AAYe,SAAR,oBAAsC,KAAK,GAAG,GAAI;AACxD,MAAK,IAAI,qBAAsB;AAC9B,WAAO,IAAI,oBAAqB,GAAG,CAAE;AAAA,EACtC;AAEA,MAAK,CAAE,IAAI,wBAAyB;AACnC,WAAO;AAAA,EACR;AAEA,QAAM,QAAQ,IAAI,uBAAwB,GAAG,CAAE;AAI/C,MAAK,CAAE,OAAQ;AACd,WAAO;AAAA,EACR;AAEA,QAAM,QAAQ,IAAI,YAAY;AAE9B,QAAM,SAAU,MAAM,YAAY,MAAM,MAAO;AAC/C,QAAM,SAAU,IAAK;AAErB,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|