@soomo/react-text-annotator 3.2.0-staging.3 → 3.2.0-staging.4
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/dist/react-text-annotator.css +1 -1
- package/dist/react-text-annotator.es10.js +78 -497
- package/dist/react-text-annotator.es10.js.map +1 -1
- package/dist/react-text-annotator.es11.js +40 -77
- package/dist/react-text-annotator.es11.js.map +1 -1
- package/dist/react-text-annotator.es12.js +21 -41
- package/dist/react-text-annotator.es12.js.map +1 -1
- package/dist/react-text-annotator.es13.js +1637 -19
- package/dist/react-text-annotator.es13.js.map +1 -1
- package/dist/react-text-annotator.es14.js +9 -1642
- package/dist/react-text-annotator.es14.js.map +1 -1
- package/dist/react-text-annotator.es16.js +607 -0
- package/dist/react-text-annotator.es16.js.map +1 -0
- package/dist/react-text-annotator.es17.js +244 -566
- package/dist/react-text-annotator.es17.js.map +1 -1
- package/dist/react-text-annotator.es18.js +471 -252
- package/dist/react-text-annotator.es18.js.map +1 -1
- package/dist/react-text-annotator.es2.js +1 -1
- package/dist/react-text-annotator.es25.js +124 -111
- package/dist/react-text-annotator.es25.js.map +1 -1
- package/dist/react-text-annotator.es26.js +140 -285
- package/dist/react-text-annotator.es26.js.map +1 -1
- package/dist/react-text-annotator.es27.js +296 -43
- package/dist/react-text-annotator.es27.js.map +1 -1
- package/dist/react-text-annotator.es28.js +113 -19
- package/dist/react-text-annotator.es28.js.map +1 -1
- package/dist/react-text-annotator.es29.js +287 -105
- package/dist/react-text-annotator.es29.js.map +1 -1
- package/dist/react-text-annotator.es30.js +48 -154
- package/dist/react-text-annotator.es30.js.map +1 -1
- package/dist/react-text-annotator.es31.js +19 -310
- package/dist/react-text-annotator.es31.js.map +1 -1
- package/dist/react-text-annotator.es4.js +2 -2
- package/dist/react-text-annotator.es5.js +1 -1
- package/dist/react-text-annotator.es7.js +4 -4
- package/package.json +2 -2
- package/dist/react-text-annotator.es15.js +0 -13
- package/dist/react-text-annotator.es15.js.map +0 -1
|
@@ -1,167 +1,61 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
function addBehaviors(bhvs) {
|
|
2
|
+
if (bhvs.namespaces) {
|
|
3
|
+
for (let prefix of Object.keys(bhvs.namespaces)) {
|
|
4
|
+
if (!this.namespaces.has(bhvs.namespaces[prefix]) && !Array.from(this.namespaces.values()).includes(prefix)) {
|
|
5
|
+
this.namespaces.set(bhvs.namespaces[prefix], prefix);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
function getDocumentElement(node) {
|
|
15
|
-
var _ref;
|
|
16
|
-
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
17
|
-
}
|
|
18
|
-
function isNode(value) {
|
|
19
|
-
if (!hasWindow()) {
|
|
20
|
-
return false;
|
|
9
|
+
for (let prefix of this.namespaces.values()) {
|
|
10
|
+
if (bhvs[prefix]) {
|
|
11
|
+
for (let b of Object.keys(bhvs[prefix])) {
|
|
12
|
+
this.behaviors[`${prefix}:${b}`] = bhvs[prefix][b];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
21
15
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return false;
|
|
16
|
+
if (bhvs["functions"]) {
|
|
17
|
+
for (let fn of Object.keys(bhvs["functions"])) {
|
|
18
|
+
this.utilities[fn] = bhvs["functions"][fn].bind(this.utilities);
|
|
19
|
+
}
|
|
27
20
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
function isHTMLElement(value) {
|
|
31
|
-
if (!hasWindow()) {
|
|
32
|
-
return false;
|
|
21
|
+
if (bhvs["handlers"]) {
|
|
22
|
+
console.log("Behavior handlers are no longer used.");
|
|
33
23
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function isShadowRoot(value) {
|
|
37
|
-
if (!hasWindow() || typeof ShadowRoot === "undefined") {
|
|
38
|
-
return false;
|
|
24
|
+
if (bhvs["fallbacks"]) {
|
|
25
|
+
console.log("Fallback behaviors are no longer used.");
|
|
39
26
|
}
|
|
40
|
-
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
41
|
-
}
|
|
42
|
-
function isOverflowElement(element) {
|
|
43
|
-
const {
|
|
44
|
-
overflow,
|
|
45
|
-
overflowX,
|
|
46
|
-
overflowY,
|
|
47
|
-
display
|
|
48
|
-
} = getComputedStyle(element);
|
|
49
|
-
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
|
|
50
|
-
}
|
|
51
|
-
function isTableElement(element) {
|
|
52
|
-
return ["table", "td", "th"].includes(getNodeName(element));
|
|
53
27
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
28
|
+
function addBehavior(ns, element, b) {
|
|
29
|
+
let p;
|
|
30
|
+
if (ns === Object(ns)) {
|
|
31
|
+
for (let prefix of Object.keys(ns)) {
|
|
32
|
+
if (!this.namespaces.has(ns[prefix])) {
|
|
33
|
+
this.namespaces.set(ns[prefix], prefix);
|
|
34
|
+
p = prefix;
|
|
35
|
+
}
|
|
60
36
|
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return null;
|
|
37
|
+
} else {
|
|
38
|
+
p = ns;
|
|
39
|
+
}
|
|
40
|
+
this.behaviors[`${p}:${element}`] = b;
|
|
41
|
+
}
|
|
42
|
+
function removeBehavior(ns, element) {
|
|
43
|
+
let p;
|
|
44
|
+
if (ns === Object(ns)) {
|
|
45
|
+
for (let prefix of Object.keys(ns)) {
|
|
46
|
+
if (!this.namespaces.has(ns[prefix])) {
|
|
47
|
+
this.namespaces.set(ns[prefix], prefix);
|
|
48
|
+
p = prefix;
|
|
49
|
+
}
|
|
75
50
|
}
|
|
76
|
-
|
|
51
|
+
} else {
|
|
52
|
+
p = ns;
|
|
77
53
|
}
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
function isWebKit() {
|
|
81
|
-
if (typeof CSS === "undefined" || !CSS.supports) return false;
|
|
82
|
-
return CSS.supports("-webkit-backdrop-filter", "none");
|
|
83
|
-
}
|
|
84
|
-
function isLastTraversableNode(node) {
|
|
85
|
-
return ["html", "body", "#document"].includes(getNodeName(node));
|
|
86
|
-
}
|
|
87
|
-
function getComputedStyle(element) {
|
|
88
|
-
return getWindow(element).getComputedStyle(element);
|
|
89
|
-
}
|
|
90
|
-
function getNodeScroll(element) {
|
|
91
|
-
if (isElement(element)) {
|
|
92
|
-
return {
|
|
93
|
-
scrollLeft: element.scrollLeft,
|
|
94
|
-
scrollTop: element.scrollTop
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
return {
|
|
98
|
-
scrollLeft: element.scrollX,
|
|
99
|
-
scrollTop: element.scrollY
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
function getParentNode(node) {
|
|
103
|
-
if (getNodeName(node) === "html") {
|
|
104
|
-
return node;
|
|
105
|
-
}
|
|
106
|
-
const result = (
|
|
107
|
-
// Step into the shadow DOM of the parent of a slotted node.
|
|
108
|
-
node.assignedSlot || // DOM Element detected.
|
|
109
|
-
node.parentNode || // ShadowRoot detected.
|
|
110
|
-
isShadowRoot(node) && node.host || // Fallback.
|
|
111
|
-
getDocumentElement(node)
|
|
112
|
-
);
|
|
113
|
-
return isShadowRoot(result) ? result.host : result;
|
|
114
|
-
}
|
|
115
|
-
function getNearestOverflowAncestor(node) {
|
|
116
|
-
const parentNode = getParentNode(node);
|
|
117
|
-
if (isLastTraversableNode(parentNode)) {
|
|
118
|
-
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
119
|
-
}
|
|
120
|
-
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
121
|
-
return parentNode;
|
|
122
|
-
}
|
|
123
|
-
return getNearestOverflowAncestor(parentNode);
|
|
124
|
-
}
|
|
125
|
-
function getOverflowAncestors(node, list, traverseIframes) {
|
|
126
|
-
var _node$ownerDocument2;
|
|
127
|
-
if (list === void 0) {
|
|
128
|
-
list = [];
|
|
129
|
-
}
|
|
130
|
-
if (traverseIframes === void 0) {
|
|
131
|
-
traverseIframes = true;
|
|
132
|
-
}
|
|
133
|
-
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
134
|
-
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
135
|
-
const win = getWindow(scrollableAncestor);
|
|
136
|
-
if (isBody) {
|
|
137
|
-
const frameElement = getFrameElement(win);
|
|
138
|
-
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
139
|
-
}
|
|
140
|
-
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
141
|
-
}
|
|
142
|
-
function getFrameElement(win) {
|
|
143
|
-
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
54
|
+
delete this.behaviors[`${p}:${element}`];
|
|
144
55
|
}
|
|
145
56
|
export {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
getFrameElement,
|
|
150
|
-
getNearestOverflowAncestor,
|
|
151
|
-
getNodeName,
|
|
152
|
-
getNodeScroll,
|
|
153
|
-
getOverflowAncestors,
|
|
154
|
-
getParentNode,
|
|
155
|
-
getWindow,
|
|
156
|
-
isContainingBlock,
|
|
157
|
-
isElement,
|
|
158
|
-
isHTMLElement,
|
|
159
|
-
isLastTraversableNode,
|
|
160
|
-
isNode,
|
|
161
|
-
isOverflowElement,
|
|
162
|
-
isShadowRoot,
|
|
163
|
-
isTableElement,
|
|
164
|
-
isTopLayer,
|
|
165
|
-
isWebKit
|
|
57
|
+
addBehavior,
|
|
58
|
+
addBehaviors,
|
|
59
|
+
removeBehavior
|
|
166
60
|
};
|
|
167
61
|
//# sourceMappingURL=react-text-annotator.es30.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-text-annotator.es30.js","sources":["../../../node_modules
|
|
1
|
+
{"version":3,"file":"react-text-annotator.es30.js","sources":["../../../node_modules/CETEIcean/src/behaviors.js"],"sourcesContent":["\n/* \n Add a user-defined set of behaviors to CETEIcean's processing\n workflow. Added behaviors will override predefined behaviors with the\n same name.\n*/\nexport function addBehaviors(bhvs) {\n if (bhvs.namespaces) {\n for (let prefix of Object.keys(bhvs.namespaces)) {\n if (!this.namespaces.has(bhvs.namespaces[prefix]) && !Array.from(this.namespaces.values()).includes(prefix)) {\n this.namespaces.set(bhvs.namespaces[prefix], prefix);\n }\n }\n }\n for (let prefix of this.namespaces.values()) {\n if (bhvs[prefix]) {\n for (let b of Object.keys(bhvs[prefix])) {\n this.behaviors[`${prefix}:${b}`] = bhvs[prefix][b];\n }\n }\n }\n if (bhvs[\"functions\"]) {\n for (let fn of Object.keys(bhvs[\"functions\"])) {\n this.utilities[fn] = bhvs[\"functions\"][fn].bind(this.utilities);\n }\n }\n if (bhvs[\"handlers\"]) {\n console.log(\"Behavior handlers are no longer used.\")\n }\n if (bhvs[\"fallbacks\"]) {\n console.log(\"Fallback behaviors are no longer used.\")\n }\n}\n\n/* \n Adds or replaces an individual behavior. Takes a namespace prefix or namespace definition,\n the element name, and the behavior. E.g.\n addBehavior(\"tei\", \"add\", [\"`\",\"`\"]) for an already-declared namespace or\n addBehavior({\"doc\": \"http://docbook.org/ns/docbook\"}, \"note\", [\"[\",\"]\"]) for a new one\n*/\nexport function addBehavior(ns, element, b) {\n let p;\n if (ns === Object(ns)) {\n for (let prefix of Object.keys(ns)) {\n if (!this.namespaces.has(ns[prefix])) {\n this.namespaces.set(ns[prefix], prefix);\n p = prefix;\n }\n }\n } else {\n p = ns;\n }\n this.behaviors[`${p}:${element}`] = b;\n}\n\n/*\n Removes a previously-defined or default behavior. Takes a namespace prefix or namespace definition\n and the element name.\n*/\nexport function removeBehavior(ns, element) {\n let p;\n if (ns === Object(ns)) {\n for (let prefix of Object.keys(ns)) {\n if (!this.namespaces.has(ns[prefix])) {\n this.namespaces.set(ns[prefix], prefix);\n p = prefix;\n }\n }\n } else {\n p = ns;\n }\n delete this.behaviors[`${p}:${element}`];\n}\n"],"names":[],"mappings":"AAMO,SAAS,aAAa,MAAM;AACjC,MAAI,KAAK,YAAY;AACnB,aAAS,UAAU,OAAO,KAAK,KAAK,UAAU,GAAG;AAC/C,UAAI,CAAC,KAAK,WAAW,IAAI,KAAK,WAAW,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,KAAK,WAAW,OAAM,CAAE,EAAE,SAAS,MAAM,GAAG;AAC3G,aAAK,WAAW,IAAI,KAAK,WAAW,MAAM,GAAG,MAAM;AAAA,MAC3D;AAAA,IACA;AAAA,EACA;AACE,WAAS,UAAU,KAAK,WAAW,OAAM,GAAI;AAC3C,QAAI,KAAK,MAAM,GAAG;AAChB,eAAS,KAAK,OAAO,KAAK,KAAK,MAAM,CAAC,GAAG;AACvC,aAAK,UAAU,GAAG,MAAM,IAAI,CAAC,EAAE,IAAI,KAAK,MAAM,EAAE,CAAC;AAAA,MACzD;AAAA,IACA;AAAA,EACA;AACE,MAAI,KAAK,WAAW,GAAG;AACrB,aAAS,MAAM,OAAO,KAAK,KAAK,WAAW,CAAC,GAAG;AAC7C,WAAK,UAAU,EAAE,IAAI,KAAK,WAAW,EAAE,EAAE,EAAE,KAAK,KAAK,SAAS;AAAA,IACpE;AAAA,EACA;AACE,MAAI,KAAK,UAAU,GAAG;AACpB,YAAQ,IAAI,uCAAuC;AAAA,EACvD;AACE,MAAI,KAAK,WAAW,GAAG;AACrB,YAAQ,IAAI,wCAAwC;AAAA,EACxD;AACA;AAQO,SAAS,YAAY,IAAI,SAAS,GAAG;AAC1C,MAAI;AACJ,MAAI,OAAO,OAAO,EAAE,GAAG;AACrB,aAAS,UAAU,OAAO,KAAK,EAAE,GAAG;AAClC,UAAI,CAAC,KAAK,WAAW,IAAI,GAAG,MAAM,CAAC,GAAG;AACpC,aAAK,WAAW,IAAI,GAAG,MAAM,GAAG,MAAM;AACtC,YAAI;AAAA,MACZ;AAAA,IACA;AAAA,EACA,OAAS;AACL,QAAI;AAAA,EACR;AACE,OAAK,UAAU,GAAG,CAAC,IAAI,OAAO,EAAE,IAAI;AACtC;AAMO,SAAS,eAAe,IAAI,SAAS;AAC1C,MAAI;AACJ,MAAI,OAAO,OAAO,EAAE,GAAG;AACrB,aAAS,UAAU,OAAO,KAAK,EAAE,GAAG;AAClC,UAAI,CAAC,KAAK,WAAW,IAAI,GAAG,MAAM,CAAC,GAAG;AACpC,aAAK,WAAW,IAAI,GAAG,MAAM,GAAG,MAAM;AACtC,YAAI;AAAA,MACZ;AAAA,IACA;AAAA,EACA,OAAS;AACL,QAAI;AAAA,EACR;AACE,SAAO,KAAK,UAAU,GAAG,CAAC,IAAI,OAAO,EAAE;AACzC;","x_google_ignoreList":[0]}
|
|
@@ -1,314 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
|
|
10
|
-
var getRootNode = !NoElement && Element.prototype.getRootNode ? function(element) {
|
|
11
|
-
var _element$getRootNode;
|
|
12
|
-
return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
|
|
13
|
-
} : function(element) {
|
|
14
|
-
return element === null || element === void 0 ? void 0 : element.ownerDocument;
|
|
15
|
-
};
|
|
16
|
-
var isInert = function isInert2(node, lookUp) {
|
|
17
|
-
var _node$getAttribute;
|
|
18
|
-
if (lookUp === void 0) {
|
|
19
|
-
lookUp = true;
|
|
20
|
-
}
|
|
21
|
-
var inertAtt = node === null || node === void 0 ? void 0 : (_node$getAttribute = node.getAttribute) === null || _node$getAttribute === void 0 ? void 0 : _node$getAttribute.call(node, "inert");
|
|
22
|
-
var inert = inertAtt === "" || inertAtt === "true";
|
|
23
|
-
var result = inert || lookUp && node && isInert2(node.parentNode);
|
|
24
|
-
return result;
|
|
25
|
-
};
|
|
26
|
-
var isContentEditable = function isContentEditable2(node) {
|
|
27
|
-
var _node$getAttribute2;
|
|
28
|
-
var attValue = node === null || node === void 0 ? void 0 : (_node$getAttribute2 = node.getAttribute) === null || _node$getAttribute2 === void 0 ? void 0 : _node$getAttribute2.call(node, "contenteditable");
|
|
29
|
-
return attValue === "" || attValue === "true";
|
|
30
|
-
};
|
|
31
|
-
var getCandidates = function getCandidates2(el, includeContainer, filter) {
|
|
32
|
-
if (isInert(el)) {
|
|
33
|
-
return [];
|
|
34
|
-
}
|
|
35
|
-
var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
|
|
36
|
-
if (includeContainer && matches.call(el, candidateSelector)) {
|
|
37
|
-
candidates.unshift(el);
|
|
38
|
-
}
|
|
39
|
-
candidates = candidates.filter(filter);
|
|
40
|
-
return candidates;
|
|
41
|
-
};
|
|
42
|
-
var getCandidatesIteratively = function getCandidatesIteratively2(elements, includeContainer, options) {
|
|
43
|
-
var candidates = [];
|
|
44
|
-
var elementsToCheck = Array.from(elements);
|
|
45
|
-
while (elementsToCheck.length) {
|
|
46
|
-
var element = elementsToCheck.shift();
|
|
47
|
-
if (isInert(element, false)) {
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
if (element.tagName === "SLOT") {
|
|
51
|
-
var assigned = element.assignedElements();
|
|
52
|
-
var content = assigned.length ? assigned : element.children;
|
|
53
|
-
var nestedCandidates = getCandidatesIteratively2(content, true, options);
|
|
54
|
-
if (options.flatten) {
|
|
55
|
-
candidates.push.apply(candidates, nestedCandidates);
|
|
56
|
-
} else {
|
|
57
|
-
candidates.push({
|
|
58
|
-
scopeParent: element,
|
|
59
|
-
candidates: nestedCandidates
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
} else {
|
|
63
|
-
var validCandidate = matches.call(element, candidateSelector);
|
|
64
|
-
if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
|
|
65
|
-
candidates.push(element);
|
|
66
|
-
}
|
|
67
|
-
var shadowRoot = element.shadowRoot || // check for an undisclosed shadow
|
|
68
|
-
typeof options.getShadowRoot === "function" && options.getShadowRoot(element);
|
|
69
|
-
var validShadowRoot = !isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
|
|
70
|
-
if (shadowRoot && validShadowRoot) {
|
|
71
|
-
var _nestedCandidates = getCandidatesIteratively2(shadowRoot === true ? element.children : shadowRoot.children, true, options);
|
|
72
|
-
if (options.flatten) {
|
|
73
|
-
candidates.push.apply(candidates, _nestedCandidates);
|
|
74
|
-
} else {
|
|
75
|
-
candidates.push({
|
|
76
|
-
scopeParent: element,
|
|
77
|
-
candidates: _nestedCandidates
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
} else {
|
|
81
|
-
elementsToCheck.unshift.apply(elementsToCheck, element.children);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return candidates;
|
|
86
|
-
};
|
|
87
|
-
var hasTabIndex = function hasTabIndex2(node) {
|
|
88
|
-
return !isNaN(parseInt(node.getAttribute("tabindex"), 10));
|
|
89
|
-
};
|
|
90
|
-
var getTabIndex = function getTabIndex2(node) {
|
|
91
|
-
if (!node) {
|
|
92
|
-
throw new Error("No node provided");
|
|
93
|
-
}
|
|
94
|
-
if (node.tabIndex < 0) {
|
|
95
|
-
if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
|
|
96
|
-
return 0;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return node.tabIndex;
|
|
100
|
-
};
|
|
101
|
-
var getSortOrderTabIndex = function getSortOrderTabIndex2(node, isScope) {
|
|
102
|
-
var tabIndex = getTabIndex(node);
|
|
103
|
-
if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
|
|
104
|
-
return 0;
|
|
105
|
-
}
|
|
106
|
-
return tabIndex;
|
|
107
|
-
};
|
|
108
|
-
var sortOrderedTabbables = function sortOrderedTabbables2(a, b) {
|
|
109
|
-
return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
|
|
110
|
-
};
|
|
111
|
-
var isInput = function isInput2(node) {
|
|
112
|
-
return node.tagName === "INPUT";
|
|
113
|
-
};
|
|
114
|
-
var isHiddenInput = function isHiddenInput2(node) {
|
|
115
|
-
return isInput(node) && node.type === "hidden";
|
|
116
|
-
};
|
|
117
|
-
var isDetailsWithSummary = function isDetailsWithSummary2(node) {
|
|
118
|
-
var r = node.tagName === "DETAILS" && Array.prototype.slice.apply(node.children).some(function(child) {
|
|
119
|
-
return child.tagName === "SUMMARY";
|
|
120
|
-
});
|
|
121
|
-
return r;
|
|
122
|
-
};
|
|
123
|
-
var getCheckedRadio = function getCheckedRadio2(nodes, form) {
|
|
124
|
-
for (var i = 0; i < nodes.length; i++) {
|
|
125
|
-
if (nodes[i].checked && nodes[i].form === form) {
|
|
126
|
-
return nodes[i];
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
var isTabbableRadio = function isTabbableRadio2(node) {
|
|
131
|
-
if (!node.name) {
|
|
132
|
-
return true;
|
|
133
|
-
}
|
|
134
|
-
var radioScope = node.form || getRootNode(node);
|
|
135
|
-
var queryRadios = function queryRadios2(name) {
|
|
136
|
-
return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
|
|
1
|
+
function learnElementNames(XML_dom, namespaces) {
|
|
2
|
+
const root = XML_dom.documentElement;
|
|
3
|
+
let i = 1;
|
|
4
|
+
let qname = function(e) {
|
|
5
|
+
if (!namespaces.has(e.namespaceURI ? e.namespaceURI : "")) {
|
|
6
|
+
namespaces.set(e.namespaceURI, "ns" + i++);
|
|
7
|
+
}
|
|
8
|
+
return namespaces.get(e.namespaceURI ? e.namespaceURI : "") + ":" + e.localName;
|
|
137
9
|
};
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
var checked = getCheckedRadio(radioSet, node.form);
|
|
150
|
-
return !checked || checked === node;
|
|
151
|
-
};
|
|
152
|
-
var isRadio = function isRadio2(node) {
|
|
153
|
-
return isInput(node) && node.type === "radio";
|
|
154
|
-
};
|
|
155
|
-
var isNonTabbableRadio = function isNonTabbableRadio2(node) {
|
|
156
|
-
return isRadio(node) && !isTabbableRadio(node);
|
|
157
|
-
};
|
|
158
|
-
var isNodeAttached = function isNodeAttached2(node) {
|
|
159
|
-
var _nodeRoot;
|
|
160
|
-
var nodeRoot = node && getRootNode(node);
|
|
161
|
-
var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
|
|
162
|
-
var attached = false;
|
|
163
|
-
if (nodeRoot && nodeRoot !== node) {
|
|
164
|
-
var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
|
|
165
|
-
attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && (_nodeRootHost$ownerDo = _nodeRootHost.ownerDocument) !== null && _nodeRootHost$ownerDo !== void 0 && _nodeRootHost$ownerDo.contains(nodeRootHost) || node !== null && node !== void 0 && (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 && _node$ownerDocument.contains(node));
|
|
166
|
-
while (!attached && nodeRootHost) {
|
|
167
|
-
var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
|
|
168
|
-
nodeRoot = getRootNode(nodeRootHost);
|
|
169
|
-
nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
|
|
170
|
-
attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return attached;
|
|
174
|
-
};
|
|
175
|
-
var isZeroArea = function isZeroArea2(node) {
|
|
176
|
-
var _node$getBoundingClie = node.getBoundingClientRect(), width = _node$getBoundingClie.width, height = _node$getBoundingClie.height;
|
|
177
|
-
return width === 0 && height === 0;
|
|
178
|
-
};
|
|
179
|
-
var isHidden = function isHidden2(node, _ref) {
|
|
180
|
-
var displayCheck = _ref.displayCheck, getShadowRoot = _ref.getShadowRoot;
|
|
181
|
-
if (getComputedStyle(node).visibility === "hidden") {
|
|
182
|
-
return true;
|
|
183
|
-
}
|
|
184
|
-
var isDirectSummary = matches.call(node, "details>summary:first-of-type");
|
|
185
|
-
var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
|
|
186
|
-
if (matches.call(nodeUnderDetails, "details:not([open]) *")) {
|
|
187
|
-
return true;
|
|
188
|
-
}
|
|
189
|
-
if (!displayCheck || displayCheck === "full" || displayCheck === "legacy-full") {
|
|
190
|
-
if (typeof getShadowRoot === "function") {
|
|
191
|
-
var originalNode = node;
|
|
192
|
-
while (node) {
|
|
193
|
-
var parentElement = node.parentElement;
|
|
194
|
-
var rootNode = getRootNode(node);
|
|
195
|
-
if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true) {
|
|
196
|
-
return isZeroArea(node);
|
|
197
|
-
} else if (node.assignedSlot) {
|
|
198
|
-
node = node.assignedSlot;
|
|
199
|
-
} else if (!parentElement && rootNode !== node.ownerDocument) {
|
|
200
|
-
node = rootNode.host;
|
|
201
|
-
} else {
|
|
202
|
-
node = parentElement;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
node = originalNode;
|
|
206
|
-
}
|
|
207
|
-
if (isNodeAttached(node)) {
|
|
208
|
-
return !node.getClientRects().length;
|
|
209
|
-
}
|
|
210
|
-
if (displayCheck !== "legacy-full") {
|
|
211
|
-
return true;
|
|
212
|
-
}
|
|
213
|
-
} else if (displayCheck === "non-zero-area") {
|
|
214
|
-
return isZeroArea(node);
|
|
215
|
-
}
|
|
216
|
-
return false;
|
|
217
|
-
};
|
|
218
|
-
var isDisabledFromFieldset = function isDisabledFromFieldset2(node) {
|
|
219
|
-
if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
|
|
220
|
-
var parentNode = node.parentElement;
|
|
221
|
-
while (parentNode) {
|
|
222
|
-
if (parentNode.tagName === "FIELDSET" && parentNode.disabled) {
|
|
223
|
-
for (var i = 0; i < parentNode.children.length; i++) {
|
|
224
|
-
var child = parentNode.children.item(i);
|
|
225
|
-
if (child.tagName === "LEGEND") {
|
|
226
|
-
return matches.call(parentNode, "fieldset[disabled] *") ? true : !child.contains(node);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
return true;
|
|
230
|
-
}
|
|
231
|
-
parentNode = parentNode.parentElement;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return false;
|
|
235
|
-
};
|
|
236
|
-
var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable2(options, node) {
|
|
237
|
-
if (node.disabled || // we must do an inert look up to filter out any elements inside an inert ancestor
|
|
238
|
-
// because we're limited in the type of selectors we can use in JSDom (see related
|
|
239
|
-
// note related to `candidateSelectors`)
|
|
240
|
-
isInert(node) || isHiddenInput(node) || isHidden(node, options) || // For a details element with a summary, the summary element gets the focus
|
|
241
|
-
isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
|
|
242
|
-
return false;
|
|
243
|
-
}
|
|
244
|
-
return true;
|
|
245
|
-
};
|
|
246
|
-
var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable2(options, node) {
|
|
247
|
-
if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
|
|
248
|
-
return false;
|
|
249
|
-
}
|
|
250
|
-
return true;
|
|
251
|
-
};
|
|
252
|
-
var isValidShadowRootTabbable = function isValidShadowRootTabbable2(shadowHostNode) {
|
|
253
|
-
var tabIndex = parseInt(shadowHostNode.getAttribute("tabindex"), 10);
|
|
254
|
-
if (isNaN(tabIndex) || tabIndex >= 0) {
|
|
255
|
-
return true;
|
|
256
|
-
}
|
|
257
|
-
return false;
|
|
258
|
-
};
|
|
259
|
-
var sortByOrder = function sortByOrder2(candidates) {
|
|
260
|
-
var regularTabbables = [];
|
|
261
|
-
var orderedTabbables = [];
|
|
262
|
-
candidates.forEach(function(item, i) {
|
|
263
|
-
var isScope = !!item.scopeParent;
|
|
264
|
-
var element = isScope ? item.scopeParent : item;
|
|
265
|
-
var candidateTabindex = getSortOrderTabIndex(element, isScope);
|
|
266
|
-
var elements = isScope ? sortByOrder2(item.candidates) : element;
|
|
267
|
-
if (candidateTabindex === 0) {
|
|
268
|
-
isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
|
|
269
|
-
} else {
|
|
270
|
-
orderedTabbables.push({
|
|
271
|
-
documentOrder: i,
|
|
272
|
-
tabIndex: candidateTabindex,
|
|
273
|
-
item,
|
|
274
|
-
isScope,
|
|
275
|
-
content: elements
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
return orderedTabbables.sort(sortOrderedTabbables).reduce(function(acc, sortable) {
|
|
280
|
-
sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
|
|
281
|
-
return acc;
|
|
282
|
-
}, []).concat(regularTabbables);
|
|
283
|
-
};
|
|
284
|
-
var tabbable = function tabbable2(container, options) {
|
|
285
|
-
options = options || {};
|
|
286
|
-
var candidates;
|
|
287
|
-
if (options.getShadowRoot) {
|
|
288
|
-
candidates = getCandidatesIteratively([container], options.includeContainer, {
|
|
289
|
-
filter: isNodeMatchingSelectorTabbable.bind(null, options),
|
|
290
|
-
flatten: false,
|
|
291
|
-
getShadowRoot: options.getShadowRoot,
|
|
292
|
-
shadowRootFilter: isValidShadowRootTabbable
|
|
293
|
-
});
|
|
294
|
-
} else {
|
|
295
|
-
candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
|
|
296
|
-
}
|
|
297
|
-
return sortByOrder(candidates);
|
|
298
|
-
};
|
|
299
|
-
var isTabbable = function isTabbable2(node, options) {
|
|
300
|
-
options = options || {};
|
|
301
|
-
if (!node) {
|
|
302
|
-
throw new Error("No node provided");
|
|
303
|
-
}
|
|
304
|
-
if (matches.call(node, candidateSelector) === false) {
|
|
305
|
-
return false;
|
|
306
|
-
}
|
|
307
|
-
return isNodeMatchingSelectorTabbable(options, node);
|
|
308
|
-
};
|
|
10
|
+
const els = new Set(
|
|
11
|
+
Array.from(root.querySelectorAll("*"), qname)
|
|
12
|
+
);
|
|
13
|
+
els.add(qname(root));
|
|
14
|
+
return els;
|
|
15
|
+
}
|
|
16
|
+
function learnCustomElementNames(HTML_dom) {
|
|
17
|
+
return new Set(Array.from(HTML_dom.querySelectorAll("*[data-origname]"), (e) => e.localName.replace(/(\w+)-.+/, "$1:") + e.getAttribute("data-origname")));
|
|
18
|
+
}
|
|
309
19
|
export {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
tabbable
|
|
20
|
+
learnCustomElementNames,
|
|
21
|
+
learnElementNames
|
|
313
22
|
};
|
|
314
23
|
//# sourceMappingURL=react-text-annotator.es31.js.map
|