@soomo/react-text-annotator 3.1.0-staging.9 → 3.2.0-staging.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.
Files changed (89) hide show
  1. package/dist/TextAnnotationPopup/TextAnnotationPopup.d.ts +32 -0
  2. package/dist/TextAnnotationPopup/TextAnnotationPopup.d.ts.map +1 -0
  3. package/dist/TextAnnotationPopup/index.d.ts +2 -0
  4. package/dist/TextAnnotationPopup/index.d.ts.map +1 -0
  5. package/dist/TextAnnotationPopup/isMobile.d.ts.map +1 -0
  6. package/dist/TextAnnotator.d.ts +5 -5
  7. package/dist/TextAnnotator.d.ts.map +1 -1
  8. package/dist/hooks/index.d.ts +2 -1
  9. package/dist/hooks/index.d.ts.map +1 -1
  10. package/dist/hooks/useAnnotationQuoteIdling.d.ts +4 -0
  11. package/dist/hooks/useAnnotationQuoteIdling.d.ts.map +1 -0
  12. package/dist/hooks/useAnnouncePopupNavigation.d.ts.map +1 -1
  13. package/dist/index.d.ts +4 -3
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/react-text-annotator.es.js +10 -4
  16. package/dist/react-text-annotator.es.js.map +1 -1
  17. package/dist/react-text-annotator.es10.js +24 -10
  18. package/dist/react-text-annotator.es10.js.map +1 -1
  19. package/dist/react-text-annotator.es11.js +82 -9
  20. package/dist/react-text-annotator.es11.js.map +1 -1
  21. package/dist/react-text-annotator.es12.js +33 -1436
  22. package/dist/react-text-annotator.es12.js.map +1 -1
  23. package/dist/react-text-annotator.es13.js +28 -0
  24. package/dist/react-text-annotator.es13.js.map +1 -0
  25. package/dist/react-text-annotator.es14.js +1590 -193
  26. package/dist/react-text-annotator.es14.js.map +1 -1
  27. package/dist/react-text-annotator.es15.js +9 -584
  28. package/dist/react-text-annotator.es15.js.map +1 -1
  29. package/dist/react-text-annotator.es17.js +592 -33
  30. package/dist/react-text-annotator.es17.js.map +1 -1
  31. package/dist/react-text-annotator.es18.js +282 -2
  32. package/dist/react-text-annotator.es18.js.map +1 -1
  33. package/dist/react-text-annotator.es19.js +13 -29
  34. package/dist/react-text-annotator.es19.js.map +1 -1
  35. package/dist/react-text-annotator.es2.js +5 -2
  36. package/dist/react-text-annotator.es2.js.map +1 -1
  37. package/dist/react-text-annotator.es20.js +2 -898
  38. package/dist/react-text-annotator.es20.js.map +1 -1
  39. package/dist/react-text-annotator.es21.js +31 -2
  40. package/dist/react-text-annotator.es21.js.map +1 -1
  41. package/dist/react-text-annotator.es22.js +888 -2
  42. package/dist/react-text-annotator.es22.js.map +1 -1
  43. package/dist/react-text-annotator.es23.js +111 -124
  44. package/dist/react-text-annotator.es23.js.map +1 -1
  45. package/dist/react-text-annotator.es24.js +285 -140
  46. package/dist/react-text-annotator.es24.js.map +1 -1
  47. package/dist/react-text-annotator.es25.js +43 -296
  48. package/dist/react-text-annotator.es25.js.map +1 -1
  49. package/dist/react-text-annotator.es26.js +19 -113
  50. package/dist/react-text-annotator.es26.js.map +1 -1
  51. package/dist/react-text-annotator.es27.js +2 -309
  52. package/dist/react-text-annotator.es27.js.map +1 -1
  53. package/dist/react-text-annotator.es28.js +2 -58
  54. package/dist/react-text-annotator.es28.js.map +1 -1
  55. package/dist/react-text-annotator.es29.js +124 -17
  56. package/dist/react-text-annotator.es29.js.map +1 -1
  57. package/dist/react-text-annotator.es3.js +3 -3
  58. package/dist/react-text-annotator.es3.js.map +1 -1
  59. package/dist/react-text-annotator.es30.js +146 -131
  60. package/dist/react-text-annotator.es30.js.map +1 -1
  61. package/dist/react-text-annotator.es31.js +281 -533
  62. package/dist/react-text-annotator.es31.js.map +1 -1
  63. package/dist/react-text-annotator.es32.js +152 -0
  64. package/dist/react-text-annotator.es32.js.map +1 -0
  65. package/dist/react-text-annotator.es33.js +629 -0
  66. package/dist/react-text-annotator.es33.js.map +1 -0
  67. package/dist/react-text-annotator.es4.js +2 -2
  68. package/dist/react-text-annotator.es4.js.map +1 -1
  69. package/dist/react-text-annotator.es5.js +43 -24
  70. package/dist/react-text-annotator.es5.js.map +1 -1
  71. package/dist/react-text-annotator.es6.js +23 -122
  72. package/dist/react-text-annotator.es6.js.map +1 -1
  73. package/dist/react-text-annotator.es7.js +133 -537
  74. package/dist/react-text-annotator.es7.js.map +1 -1
  75. package/dist/react-text-annotator.es8.js +2 -9
  76. package/dist/react-text-annotator.es8.js.map +1 -1
  77. package/dist/tei/CETEIcean.d.ts +1 -0
  78. package/dist/tei/CETEIcean.d.ts.map +1 -1
  79. package/dist/tei/TEIAnnotator.d.ts +1 -1
  80. package/dist/tei/TEIAnnotator.d.ts.map +1 -1
  81. package/package.json +16 -14
  82. package/dist/TextAnnotatorPopup/TextAnnotatorPopup.d.ts +0 -25
  83. package/dist/TextAnnotatorPopup/TextAnnotatorPopup.d.ts.map +0 -1
  84. package/dist/TextAnnotatorPopup/index.d.ts +0 -2
  85. package/dist/TextAnnotatorPopup/index.d.ts.map +0 -1
  86. package/dist/TextAnnotatorPopup/isMobile.d.ts.map +0 -1
  87. package/dist/react-text-annotator.es16.js +0 -85
  88. package/dist/react-text-annotator.es16.js.map +0 -1
  89. /package/dist/{TextAnnotatorPopup → TextAnnotationPopup}/isMobile.d.ts +0 -0
@@ -1,566 +1,314 @@
1
- import { evaluate, getSide, getSideAxis, getOppositePlacement, getExpandedPlacements, getOppositeAxisPlacements, getAlignmentSides, rectToClientRect, getPaddingObject, clamp, getAlignmentAxis, getAlignment, min, max, getOppositeAxis, getAxisLength } from "./react-text-annotator.es30.js";
2
- function computeCoordsFromPlacement(_ref, placement, rtl) {
3
- let {
4
- reference,
5
- floating
6
- } = _ref;
7
- const sideAxis = getSideAxis(placement);
8
- const alignmentAxis = getAlignmentAxis(placement);
9
- const alignLength = getAxisLength(alignmentAxis);
10
- const side = getSide(placement);
11
- const isVertical = sideAxis === "y";
12
- const commonX = reference.x + reference.width / 2 - floating.width / 2;
13
- const commonY = reference.y + reference.height / 2 - floating.height / 2;
14
- const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
15
- let coords;
16
- switch (side) {
17
- case "top":
18
- coords = {
19
- x: commonX,
20
- y: reference.y - floating.height
21
- };
22
- break;
23
- case "bottom":
24
- coords = {
25
- x: commonX,
26
- y: reference.y + reference.height
27
- };
28
- break;
29
- case "right":
30
- coords = {
31
- x: reference.x + reference.width,
32
- y: commonY
33
- };
34
- break;
35
- case "left":
36
- coords = {
37
- x: reference.x - floating.width,
38
- y: commonY
39
- };
40
- break;
41
- default:
42
- coords = {
43
- x: reference.x,
44
- y: reference.y
45
- };
1
+ /*!
2
+ * tabbable 6.2.0
3
+ * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
4
+ */
5
+ var candidateSelectors = ["input:not([inert])", "select:not([inert])", "textarea:not([inert])", "a[href]:not([inert])", "button:not([inert])", "[tabindex]:not(slot):not([inert])", "audio[controls]:not([inert])", "video[controls]:not([inert])", '[contenteditable]:not([contenteditable="false"]):not([inert])', "details>summary:first-of-type:not([inert])", "details:not([inert])"];
6
+ var candidateSelector = /* @__PURE__ */ candidateSelectors.join(",");
7
+ var NoElement = typeof Element === "undefined";
8
+ var matches = NoElement ? function() {
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;
46
20
  }
47
- switch (getAlignment(placement)) {
48
- case "start":
49
- coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
50
- break;
51
- case "end":
52
- coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
53
- break;
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 [];
54
34
  }
55
- return coords;
56
- }
57
- const computePosition = async (reference, floating, config) => {
58
- const {
59
- placement = "bottom",
60
- strategy = "absolute",
61
- middleware = [],
62
- platform
63
- } = config;
64
- const validMiddleware = middleware.filter(Boolean);
65
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
66
- let rects = await platform.getElementRects({
67
- reference,
68
- floating,
69
- strategy
70
- });
71
- let {
72
- x,
73
- y
74
- } = computeCoordsFromPlacement(rects, placement, rtl);
75
- let statefulPlacement = placement;
76
- let middlewareData = {};
77
- let resetCount = 0;
78
- for (let i = 0; i < validMiddleware.length; i++) {
79
- const {
80
- name,
81
- fn
82
- } = validMiddleware[i];
83
- const {
84
- x: nextX,
85
- y: nextY,
86
- data,
87
- reset
88
- } = await fn({
89
- x,
90
- y,
91
- initialPlacement: placement,
92
- placement: statefulPlacement,
93
- strategy,
94
- middlewareData,
95
- rects,
96
- platform,
97
- elements: {
98
- reference,
99
- floating
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
+ });
100
61
  }
101
- });
102
- x = nextX != null ? nextX : x;
103
- y = nextY != null ? nextY : y;
104
- middlewareData = {
105
- ...middlewareData,
106
- [name]: {
107
- ...middlewareData[name],
108
- ...data
62
+ } else {
63
+ var validCandidate = matches.call(element, candidateSelector);
64
+ if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
65
+ candidates.push(element);
109
66
  }
110
- };
111
- if (reset && resetCount <= 50) {
112
- resetCount++;
113
- if (typeof reset === "object") {
114
- if (reset.placement) {
115
- statefulPlacement = reset.placement;
116
- }
117
- if (reset.rects) {
118
- rects = reset.rects === true ? await platform.getElementRects({
119
- reference,
120
- floating,
121
- strategy
122
- }) : reset.rects;
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
+ });
123
79
  }
124
- ({
125
- x,
126
- y
127
- } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
80
+ } else {
81
+ elementsToCheck.unshift.apply(elementsToCheck, element.children);
128
82
  }
129
- i = -1;
130
83
  }
131
84
  }
132
- return {
133
- x,
134
- y,
135
- placement: statefulPlacement,
136
- strategy,
137
- middlewareData
138
- };
85
+ return candidates;
86
+ };
87
+ var hasTabIndex = function hasTabIndex2(node) {
88
+ return !isNaN(parseInt(node.getAttribute("tabindex"), 10));
139
89
  };
140
- async function detectOverflow(state, options) {
141
- var _await$platform$isEle;
142
- if (options === void 0) {
143
- options = {};
90
+ var getTabIndex = function getTabIndex2(node) {
91
+ if (!node) {
92
+ throw new Error("No node provided");
144
93
  }
145
- const {
146
- x,
147
- y,
148
- platform,
149
- rects,
150
- elements,
151
- strategy
152
- } = state;
153
- const {
154
- boundary = "clippingAncestors",
155
- rootBoundary = "viewport",
156
- elementContext = "floating",
157
- altBoundary = false,
158
- padding = 0
159
- } = evaluate(options, state);
160
- const paddingObject = getPaddingObject(padding);
161
- const altContext = elementContext === "floating" ? "reference" : "floating";
162
- const element = elements[altBoundary ? altContext : elementContext];
163
- const clippingClientRect = rectToClientRect(await platform.getClippingRect({
164
- element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating)),
165
- boundary,
166
- rootBoundary,
167
- strategy
168
- }));
169
- const rect = elementContext === "floating" ? {
170
- x,
171
- y,
172
- width: rects.floating.width,
173
- height: rects.floating.height
174
- } : rects.reference;
175
- const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
176
- const offsetScale = await (platform.isElement == null ? void 0 : platform.isElement(offsetParent)) ? await (platform.getScale == null ? void 0 : platform.getScale(offsetParent)) || {
177
- x: 1,
178
- y: 1
179
- } : {
180
- x: 1,
181
- y: 1
182
- };
183
- const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
184
- elements,
185
- rect,
186
- offsetParent,
187
- strategy
188
- }) : rect);
189
- return {
190
- top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
191
- bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
192
- left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
193
- right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
194
- };
195
- }
196
- const flip = function(options) {
197
- if (options === void 0) {
198
- options = {};
94
+ if (node.tabIndex < 0) {
95
+ if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
96
+ return 0;
97
+ }
199
98
  }
200
- return {
201
- name: "flip",
202
- options,
203
- async fn(state) {
204
- var _middlewareData$arrow, _middlewareData$flip;
205
- const {
206
- placement,
207
- middlewareData,
208
- rects,
209
- initialPlacement,
210
- platform,
211
- elements
212
- } = state;
213
- const {
214
- mainAxis: checkMainAxis = true,
215
- crossAxis: checkCrossAxis = true,
216
- fallbackPlacements: specifiedFallbackPlacements,
217
- fallbackStrategy = "bestFit",
218
- fallbackAxisSideDirection = "none",
219
- flipAlignment = true,
220
- ...detectOverflowOptions
221
- } = evaluate(options, state);
222
- if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
223
- return {};
224
- }
225
- const side = getSide(placement);
226
- const initialSideAxis = getSideAxis(initialPlacement);
227
- const isBasePlacement = getSide(initialPlacement) === initialPlacement;
228
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
229
- const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
230
- const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
231
- if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
232
- fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
233
- }
234
- const placements = [initialPlacement, ...fallbackPlacements];
235
- const overflow = await detectOverflow(state, detectOverflowOptions);
236
- const overflows = [];
237
- let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
238
- if (checkMainAxis) {
239
- overflows.push(overflow[side]);
240
- }
241
- if (checkCrossAxis) {
242
- const sides = getAlignmentSides(placement, rects, rtl);
243
- overflows.push(overflow[sides[0]], overflow[sides[1]]);
244
- }
245
- overflowsData = [...overflowsData, {
246
- placement,
247
- overflows
248
- }];
249
- if (!overflows.every((side2) => side2 <= 0)) {
250
- var _middlewareData$flip2, _overflowsData$filter;
251
- const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
252
- const nextPlacement = placements[nextIndex];
253
- if (nextPlacement) {
254
- return {
255
- data: {
256
- index: nextIndex,
257
- overflows: overflowsData
258
- },
259
- reset: {
260
- placement: nextPlacement
261
- }
262
- };
263
- }
264
- let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
265
- if (!resetPlacement) {
266
- switch (fallbackStrategy) {
267
- case "bestFit": {
268
- var _overflowsData$filter2;
269
- const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
270
- if (hasFallbackAxisSideDirection) {
271
- const currentSideAxis = getSideAxis(d.placement);
272
- return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
273
- // reading directions favoring greater width.
274
- currentSideAxis === "y";
275
- }
276
- return true;
277
- }).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
278
- if (placement2) {
279
- resetPlacement = placement2;
280
- }
281
- break;
282
- }
283
- case "initialPlacement":
284
- resetPlacement = initialPlacement;
285
- break;
286
- }
287
- }
288
- if (placement !== resetPlacement) {
289
- return {
290
- reset: {
291
- placement: resetPlacement
292
- }
293
- };
294
- }
295
- }
296
- return {};
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];
297
127
  }
298
- };
128
+ }
299
129
  };
300
- function getBoundingRect(rects) {
301
- const minX = min(...rects.map((rect) => rect.left));
302
- const minY = min(...rects.map((rect) => rect.top));
303
- const maxX = max(...rects.map((rect) => rect.right));
304
- const maxY = max(...rects.map((rect) => rect.bottom));
305
- return {
306
- x: minX,
307
- y: minY,
308
- width: maxX - minX,
309
- height: maxY - minY
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 + '"]');
310
137
  };
311
- }
312
- function getRectsByLine(rects) {
313
- const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
314
- const groups = [];
315
- let prevRect = null;
316
- for (let i = 0; i < sortedRects.length; i++) {
317
- const rect = sortedRects[i];
318
- if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
319
- groups.push([rect]);
320
- } else {
321
- groups[groups.length - 1].push(rect);
138
+ var radioSet;
139
+ if (typeof window !== "undefined" && typeof window.CSS !== "undefined" && typeof window.CSS.escape === "function") {
140
+ radioSet = queryRadios(window.CSS.escape(node.name));
141
+ } else {
142
+ try {
143
+ radioSet = queryRadios(node.name);
144
+ } catch (err) {
145
+ console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", err.message);
146
+ return false;
322
147
  }
323
- prevRect = rect;
324
148
  }
325
- return groups.map((rect) => rectToClientRect(getBoundingRect(rect)));
326
- }
327
- const inline = function(options) {
328
- if (options === void 0) {
329
- options = {};
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
+ }
330
172
  }
331
- return {
332
- name: "inline",
333
- options,
334
- async fn(state) {
335
- const {
336
- placement,
337
- elements,
338
- rects,
339
- platform,
340
- strategy
341
- } = state;
342
- const {
343
- padding = 2,
344
- x,
345
- y
346
- } = evaluate(options, state);
347
- const nativeClientRects = Array.from(await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference)) || []);
348
- const clientRects = getRectsByLine(nativeClientRects);
349
- const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
350
- const paddingObject = getPaddingObject(padding);
351
- function getBoundingClientRect() {
352
- if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
353
- return clientRects.find((rect) => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
354
- }
355
- if (clientRects.length >= 2) {
356
- if (getSideAxis(placement) === "y") {
357
- const firstRect = clientRects[0];
358
- const lastRect = clientRects[clientRects.length - 1];
359
- const isTop = getSide(placement) === "top";
360
- const top2 = firstRect.top;
361
- const bottom2 = lastRect.bottom;
362
- const left2 = isTop ? firstRect.left : lastRect.left;
363
- const right2 = isTop ? firstRect.right : lastRect.right;
364
- const width2 = right2 - left2;
365
- const height2 = bottom2 - top2;
366
- return {
367
- top: top2,
368
- bottom: bottom2,
369
- left: left2,
370
- right: right2,
371
- width: width2,
372
- height: height2,
373
- x: left2,
374
- y: top2
375
- };
376
- }
377
- const isLeftSide = getSide(placement) === "left";
378
- const maxRight = max(...clientRects.map((rect) => rect.right));
379
- const minLeft = min(...clientRects.map((rect) => rect.left));
380
- const measureRects = clientRects.filter((rect) => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
381
- const top = measureRects[0].top;
382
- const bottom = measureRects[measureRects.length - 1].bottom;
383
- const left = minLeft;
384
- const right = maxRight;
385
- const width = right - left;
386
- const height = bottom - top;
387
- return {
388
- top,
389
- bottom,
390
- left,
391
- right,
392
- width,
393
- height,
394
- x: left,
395
- y: top
396
- };
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;
397
203
  }
398
- return fallback;
399
204
  }
400
- const resetRects = await platform.getElementRects({
401
- reference: {
402
- getBoundingClientRect
403
- },
404
- floating: elements.floating,
405
- strategy
406
- });
407
- if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
408
- return {
409
- reset: {
410
- rects: resetRects
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);
411
227
  }
412
- };
228
+ }
229
+ return true;
413
230
  }
414
- return {};
231
+ parentNode = parentNode.parentElement;
415
232
  }
416
- };
233
+ }
234
+ return false;
417
235
  };
418
- async function convertValueToCoords(state, options) {
419
- const {
420
- placement,
421
- platform,
422
- elements
423
- } = state;
424
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
425
- const side = getSide(placement);
426
- const alignment = getAlignment(placement);
427
- const isVertical = getSideAxis(placement) === "y";
428
- const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
429
- const crossAxisMulti = rtl && isVertical ? -1 : 1;
430
- const rawValue = evaluate(options, state);
431
- let {
432
- mainAxis,
433
- crossAxis,
434
- alignmentAxis
435
- } = typeof rawValue === "number" ? {
436
- mainAxis: rawValue,
437
- crossAxis: 0,
438
- alignmentAxis: null
439
- } : {
440
- mainAxis: rawValue.mainAxis || 0,
441
- crossAxis: rawValue.crossAxis || 0,
442
- alignmentAxis: rawValue.alignmentAxis
443
- };
444
- if (alignment && typeof alignmentAxis === "number") {
445
- crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
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;
446
243
  }
447
- return isVertical ? {
448
- x: crossAxis * crossAxisMulti,
449
- y: mainAxis * mainAxisMulti
450
- } : {
451
- x: mainAxis * mainAxisMulti,
452
- y: crossAxis * crossAxisMulti
453
- };
454
- }
455
- const offset = function(options) {
456
- if (options === void 0) {
457
- options = 0;
244
+ return true;
245
+ };
246
+ var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable2(options, node) {
247
+ if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
248
+ return false;
458
249
  }
459
- return {
460
- name: "offset",
461
- options,
462
- async fn(state) {
463
- var _middlewareData$offse, _middlewareData$arrow;
464
- const {
465
- x,
466
- y,
467
- placement,
468
- middlewareData
469
- } = state;
470
- const diffCoords = await convertValueToCoords(state, options);
471
- if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
472
- return {};
473
- }
474
- return {
475
- x: x + diffCoords.x,
476
- y: y + diffCoords.y,
477
- data: {
478
- ...diffCoords,
479
- placement
480
- }
481
- };
482
- }
483
- };
250
+ return true;
484
251
  };
485
- const shift = function(options) {
486
- if (options === void 0) {
487
- options = {};
252
+ var isValidShadowRootTabbable = function isValidShadowRootTabbable2(shadowHostNode) {
253
+ var tabIndex = parseInt(shadowHostNode.getAttribute("tabindex"), 10);
254
+ if (isNaN(tabIndex) || tabIndex >= 0) {
255
+ return true;
488
256
  }
489
- return {
490
- name: "shift",
491
- options,
492
- async fn(state) {
493
- const {
494
- x,
495
- y,
496
- placement
497
- } = state;
498
- const {
499
- mainAxis: checkMainAxis = true,
500
- crossAxis: checkCrossAxis = false,
501
- limiter = {
502
- fn: (_ref) => {
503
- let {
504
- x: x2,
505
- y: y2
506
- } = _ref;
507
- return {
508
- x: x2,
509
- y: y2
510
- };
511
- }
512
- },
513
- ...detectOverflowOptions
514
- } = evaluate(options, state);
515
- const coords = {
516
- x,
517
- y
518
- };
519
- const overflow = await detectOverflow(state, detectOverflowOptions);
520
- const crossAxis = getSideAxis(getSide(placement));
521
- const mainAxis = getOppositeAxis(crossAxis);
522
- let mainAxisCoord = coords[mainAxis];
523
- let crossAxisCoord = coords[crossAxis];
524
- if (checkMainAxis) {
525
- const minSide = mainAxis === "y" ? "top" : "left";
526
- const maxSide = mainAxis === "y" ? "bottom" : "right";
527
- const min2 = mainAxisCoord + overflow[minSide];
528
- const max2 = mainAxisCoord - overflow[maxSide];
529
- mainAxisCoord = clamp(min2, mainAxisCoord, max2);
530
- }
531
- if (checkCrossAxis) {
532
- const minSide = crossAxis === "y" ? "top" : "left";
533
- const maxSide = crossAxis === "y" ? "bottom" : "right";
534
- const min2 = crossAxisCoord + overflow[minSide];
535
- const max2 = crossAxisCoord - overflow[maxSide];
536
- crossAxisCoord = clamp(min2, crossAxisCoord, max2);
537
- }
538
- const limitedCoords = limiter.fn({
539
- ...state,
540
- [mainAxis]: mainAxisCoord,
541
- [crossAxis]: crossAxisCoord
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
542
276
  });
543
- return {
544
- ...limitedCoords,
545
- data: {
546
- x: limitedCoords.x - x,
547
- y: limitedCoords.y - y,
548
- enabled: {
549
- [mainAxis]: checkMainAxis,
550
- [crossAxis]: checkCrossAxis
551
- }
552
- }
553
- };
554
277
  }
555
- };
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);
556
308
  };
557
309
  export {
558
- computePosition,
559
- detectOverflow,
560
- flip,
561
- inline,
562
- offset,
563
- rectToClientRect,
564
- shift
310
+ getTabIndex,
311
+ isTabbable,
312
+ tabbable
565
313
  };
566
314
  //# sourceMappingURL=react-text-annotator.es31.js.map