@soomo/react-text-annotator 3.1.0-staging.22 → 3.1.0-staging.23
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/TextAnnotationPopup/TextAnnotationPopup.d.ts.map +1 -1
- package/dist/hooks/useAnnotationQuoteIdling.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/react-text-annotator.es.js +1 -1
- package/dist/react-text-annotator.es10.js +490 -0
- package/dist/react-text-annotator.es10.js.map +1 -0
- package/dist/react-text-annotator.es11.js +78 -483
- package/dist/react-text-annotator.es11.js.map +1 -1
- package/dist/react-text-annotator.es12.js +40 -77
- package/dist/react-text-annotator.es12.js.map +1 -1
- package/dist/react-text-annotator.es13.js +21 -41
- package/dist/react-text-annotator.es13.js.map +1 -1
- package/dist/react-text-annotator.es14.js +1629 -19
- package/dist/react-text-annotator.es14.js.map +1 -1
- package/dist/react-text-annotator.es15.js +8 -1596
- package/dist/react-text-annotator.es15.js.map +1 -1
- package/dist/react-text-annotator.es17.js +285 -0
- package/dist/react-text-annotator.es17.js.map +1 -0
- package/dist/react-text-annotator.es18.js +559 -244
- package/dist/react-text-annotator.es18.js.map +1 -1
- package/dist/react-text-annotator.es19.js +12 -584
- package/dist/react-text-annotator.es19.js.map +1 -1
- package/dist/react-text-annotator.es2.js +7 -4
- package/dist/react-text-annotator.es2.js.map +1 -1
- package/dist/react-text-annotator.es22.js.map +1 -1
- package/dist/react-text-annotator.es3.js +5 -5
- package/dist/react-text-annotator.es3.js.map +1 -1
- package/dist/react-text-annotator.es4.js +2 -2
- package/dist/react-text-annotator.es4.js.map +1 -1
- package/dist/react-text-annotator.es5.js +1 -1
- package/dist/react-text-annotator.es5.js.map +1 -1
- package/dist/react-text-annotator.es6.js +2 -2
- package/dist/react-text-annotator.es7.js +14 -11
- package/dist/react-text-annotator.es7.js.map +1 -1
- package/dist/react-text-annotator.es8.js +3 -559
- package/dist/react-text-annotator.es8.js.map +1 -1
- package/dist/tei/CETEIcean.d.ts +1 -0
- package/dist/tei/CETEIcean.d.ts.map +1 -1
- package/dist/tei/TEIAnnotator.d.ts.map +1 -1
- package/package.json +11 -11
- package/dist/react-text-annotator.es16.js +0 -12
- package/dist/react-text-annotator.es16.js.map +0 -1
- package/dist/react-text-annotator.es9.js +0 -13
- package/dist/react-text-annotator.es9.js.map +0 -1
|
@@ -1,285 +1,600 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { offset as offset$1, shift as shift$1, flip as flip$1, inline as inline$1, computePosition as computePosition$1, arrow as arrow$1 } from "./react-text-annotator.es33.js";
|
|
2
|
+
import { createCoords, rectToClientRect, round, floor, max, min } from "./react-text-annotator.es32.js";
|
|
3
|
+
import { getOverflowAncestors, isElement, getWindow, getFrameElement, getComputedStyle, getDocumentElement, isHTMLElement, isWebKit, isTopLayer, getNodeName, isOverflowElement, getNodeScroll, getParentNode, isLastTraversableNode, isTableElement, isContainingBlock, getContainingBlock } from "./react-text-annotator.es30.js";
|
|
4
|
+
function getCssDimensions(element) {
|
|
5
|
+
const css = getComputedStyle(element);
|
|
6
|
+
let width = parseFloat(css.width) || 0;
|
|
7
|
+
let height = parseFloat(css.height) || 0;
|
|
8
|
+
const hasOffset = isHTMLElement(element);
|
|
9
|
+
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
10
|
+
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
11
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
12
|
+
if (shouldFallback) {
|
|
13
|
+
width = offsetWidth;
|
|
14
|
+
height = offsetHeight;
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
width,
|
|
18
|
+
height,
|
|
19
|
+
$: shouldFallback
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function unwrapElement(element) {
|
|
23
|
+
return !isElement(element) ? element.contextElement : element;
|
|
24
|
+
}
|
|
25
|
+
function getScale(element) {
|
|
26
|
+
const domElement = unwrapElement(element);
|
|
27
|
+
if (!isHTMLElement(domElement)) {
|
|
28
|
+
return createCoords(1);
|
|
29
|
+
}
|
|
30
|
+
const rect = domElement.getBoundingClientRect();
|
|
31
|
+
const {
|
|
32
|
+
width,
|
|
33
|
+
height,
|
|
34
|
+
$
|
|
35
|
+
} = getCssDimensions(domElement);
|
|
36
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
37
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
38
|
+
if (!x || !Number.isFinite(x)) {
|
|
39
|
+
x = 1;
|
|
40
|
+
}
|
|
41
|
+
if (!y || !Number.isFinite(y)) {
|
|
42
|
+
y = 1;
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
x,
|
|
46
|
+
y
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const noOffsets = /* @__PURE__ */ createCoords(0);
|
|
50
|
+
function getVisualOffsets(element) {
|
|
51
|
+
const win = getWindow(element);
|
|
52
|
+
if (!isWebKit() || !win.visualViewport) {
|
|
53
|
+
return noOffsets;
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
x: win.visualViewport.offsetLeft,
|
|
57
|
+
y: win.visualViewport.offsetTop
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
61
|
+
if (isFixed === void 0) {
|
|
62
|
+
isFixed = false;
|
|
63
|
+
}
|
|
64
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
12
65
|
return false;
|
|
13
66
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
67
|
+
return isFixed;
|
|
68
|
+
}
|
|
69
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
70
|
+
if (includeScale === void 0) {
|
|
71
|
+
includeScale = false;
|
|
72
|
+
}
|
|
73
|
+
if (isFixedStrategy === void 0) {
|
|
74
|
+
isFixedStrategy = false;
|
|
75
|
+
}
|
|
76
|
+
const clientRect = element.getBoundingClientRect();
|
|
77
|
+
const domElement = unwrapElement(element);
|
|
78
|
+
let scale = createCoords(1);
|
|
79
|
+
if (includeScale) {
|
|
80
|
+
if (offsetParent) {
|
|
81
|
+
if (isElement(offsetParent)) {
|
|
82
|
+
scale = getScale(offsetParent);
|
|
28
83
|
}
|
|
29
|
-
|
|
84
|
+
} else {
|
|
85
|
+
scale = getScale(element);
|
|
30
86
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
87
|
+
}
|
|
88
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
89
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
90
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
91
|
+
let width = clientRect.width / scale.x;
|
|
92
|
+
let height = clientRect.height / scale.y;
|
|
93
|
+
if (domElement) {
|
|
94
|
+
const win = getWindow(domElement);
|
|
95
|
+
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
96
|
+
let currentWin = win;
|
|
97
|
+
let currentIFrame = getFrameElement(currentWin);
|
|
98
|
+
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
99
|
+
const iframeScale = getScale(currentIFrame);
|
|
100
|
+
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
101
|
+
const css = getComputedStyle(currentIFrame);
|
|
102
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
103
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
104
|
+
x *= iframeScale.x;
|
|
105
|
+
y *= iframeScale.y;
|
|
106
|
+
width *= iframeScale.x;
|
|
107
|
+
height *= iframeScale.y;
|
|
108
|
+
x += left;
|
|
109
|
+
y += top;
|
|
110
|
+
currentWin = getWindow(currentIFrame);
|
|
111
|
+
currentIFrame = getFrameElement(currentWin);
|
|
35
112
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
113
|
+
}
|
|
114
|
+
return rectToClientRect({
|
|
115
|
+
width,
|
|
116
|
+
height,
|
|
117
|
+
x,
|
|
118
|
+
y
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function getWindowScrollBarX(element, rect) {
|
|
122
|
+
const leftScroll = getNodeScroll(element).scrollLeft;
|
|
123
|
+
if (!rect) {
|
|
124
|
+
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
|
125
|
+
}
|
|
126
|
+
return rect.left + leftScroll;
|
|
127
|
+
}
|
|
128
|
+
function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
|
|
129
|
+
if (ignoreScrollbarX === void 0) {
|
|
130
|
+
ignoreScrollbarX = false;
|
|
131
|
+
}
|
|
132
|
+
const htmlRect = documentElement.getBoundingClientRect();
|
|
133
|
+
const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 : (
|
|
134
|
+
// RTL <body> scrollbar.
|
|
135
|
+
getWindowScrollBarX(documentElement, htmlRect)
|
|
136
|
+
));
|
|
137
|
+
const y = htmlRect.top + scroll.scrollTop;
|
|
138
|
+
return {
|
|
139
|
+
x,
|
|
140
|
+
y
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
144
|
+
let {
|
|
145
|
+
elements,
|
|
146
|
+
rect,
|
|
147
|
+
offsetParent,
|
|
148
|
+
strategy
|
|
149
|
+
} = _ref;
|
|
150
|
+
const isFixed = strategy === "fixed";
|
|
151
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
152
|
+
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
153
|
+
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
154
|
+
return rect;
|
|
155
|
+
}
|
|
156
|
+
let scroll = {
|
|
157
|
+
scrollLeft: 0,
|
|
158
|
+
scrollTop: 0
|
|
159
|
+
};
|
|
160
|
+
let scale = createCoords(1);
|
|
161
|
+
const offsets = createCoords(0);
|
|
162
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
163
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
164
|
+
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
165
|
+
scroll = getNodeScroll(offsetParent);
|
|
40
166
|
}
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (!deepEqual(a[key], b[key])) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
167
|
+
if (isHTMLElement(offsetParent)) {
|
|
168
|
+
const offsetRect = getBoundingClientRect(offsetParent);
|
|
169
|
+
scale = getScale(offsetParent);
|
|
170
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
171
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
49
172
|
}
|
|
50
|
-
return true;
|
|
51
173
|
}
|
|
52
|
-
|
|
174
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
|
|
175
|
+
return {
|
|
176
|
+
width: rect.width * scale.x,
|
|
177
|
+
height: rect.height * scale.y,
|
|
178
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
|
179
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
|
180
|
+
};
|
|
53
181
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
56
|
-
|
|
182
|
+
function getClientRects(element) {
|
|
183
|
+
return Array.from(element.getClientRects());
|
|
184
|
+
}
|
|
185
|
+
function getDocumentRect(element) {
|
|
186
|
+
const html = getDocumentElement(element);
|
|
187
|
+
const scroll = getNodeScroll(element);
|
|
188
|
+
const body = element.ownerDocument.body;
|
|
189
|
+
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
190
|
+
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
191
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
192
|
+
const y = -scroll.scrollTop;
|
|
193
|
+
if (getComputedStyle(body).direction === "rtl") {
|
|
194
|
+
x += max(html.clientWidth, body.clientWidth) - width;
|
|
57
195
|
}
|
|
58
|
-
|
|
59
|
-
|
|
196
|
+
return {
|
|
197
|
+
width,
|
|
198
|
+
height,
|
|
199
|
+
x,
|
|
200
|
+
y
|
|
201
|
+
};
|
|
60
202
|
}
|
|
61
|
-
function
|
|
62
|
-
const
|
|
63
|
-
|
|
203
|
+
function getViewportRect(element, strategy) {
|
|
204
|
+
const win = getWindow(element);
|
|
205
|
+
const html = getDocumentElement(element);
|
|
206
|
+
const visualViewport = win.visualViewport;
|
|
207
|
+
let width = html.clientWidth;
|
|
208
|
+
let height = html.clientHeight;
|
|
209
|
+
let x = 0;
|
|
210
|
+
let y = 0;
|
|
211
|
+
if (visualViewport) {
|
|
212
|
+
width = visualViewport.width;
|
|
213
|
+
height = visualViewport.height;
|
|
214
|
+
const visualViewportBased = isWebKit();
|
|
215
|
+
if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
|
|
216
|
+
x = visualViewport.offsetLeft;
|
|
217
|
+
y = visualViewport.offsetTop;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
width,
|
|
222
|
+
height,
|
|
223
|
+
x,
|
|
224
|
+
y
|
|
225
|
+
};
|
|
64
226
|
}
|
|
65
|
-
function
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
227
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
228
|
+
const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
|
|
229
|
+
const top = clientRect.top + element.clientTop;
|
|
230
|
+
const left = clientRect.left + element.clientLeft;
|
|
231
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
232
|
+
const width = element.clientWidth * scale.x;
|
|
233
|
+
const height = element.clientHeight * scale.y;
|
|
234
|
+
const x = left * scale.x;
|
|
235
|
+
const y = top * scale.y;
|
|
236
|
+
return {
|
|
237
|
+
width,
|
|
238
|
+
height,
|
|
239
|
+
x,
|
|
240
|
+
y
|
|
241
|
+
};
|
|
71
242
|
}
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
|
|
243
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
244
|
+
let rect;
|
|
245
|
+
if (clippingAncestor === "viewport") {
|
|
246
|
+
rect = getViewportRect(element, strategy);
|
|
247
|
+
} else if (clippingAncestor === "document") {
|
|
248
|
+
rect = getDocumentRect(getDocumentElement(element));
|
|
249
|
+
} else if (isElement(clippingAncestor)) {
|
|
250
|
+
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
251
|
+
} else {
|
|
252
|
+
const visualOffsets = getVisualOffsets(element);
|
|
253
|
+
rect = {
|
|
254
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
255
|
+
y: clippingAncestor.y - visualOffsets.y,
|
|
256
|
+
width: clippingAncestor.width,
|
|
257
|
+
height: clippingAncestor.height
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
return rectToClientRect(rect);
|
|
261
|
+
}
|
|
262
|
+
function hasFixedPositionAncestor(element, stopNode) {
|
|
263
|
+
const parentNode = getParentNode(element);
|
|
264
|
+
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
return getComputedStyle(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
|
|
268
|
+
}
|
|
269
|
+
function getClippingElementAncestors(element, cache) {
|
|
270
|
+
const cachedResult = cache.get(element);
|
|
271
|
+
if (cachedResult) {
|
|
272
|
+
return cachedResult;
|
|
75
273
|
}
|
|
274
|
+
let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
|
|
275
|
+
let currentContainingBlockComputedStyle = null;
|
|
276
|
+
const elementIsFixed = getComputedStyle(element).position === "fixed";
|
|
277
|
+
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
278
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
279
|
+
const computedStyle = getComputedStyle(currentNode);
|
|
280
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
281
|
+
if (!currentNodeIsContaining && computedStyle.position === "fixed") {
|
|
282
|
+
currentContainingBlockComputedStyle = null;
|
|
283
|
+
}
|
|
284
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
285
|
+
if (shouldDropCurrentNode) {
|
|
286
|
+
result = result.filter((ancestor) => ancestor !== currentNode);
|
|
287
|
+
} else {
|
|
288
|
+
currentContainingBlockComputedStyle = computedStyle;
|
|
289
|
+
}
|
|
290
|
+
currentNode = getParentNode(currentNode);
|
|
291
|
+
}
|
|
292
|
+
cache.set(element, result);
|
|
293
|
+
return result;
|
|
294
|
+
}
|
|
295
|
+
function getClippingRect(_ref) {
|
|
296
|
+
let {
|
|
297
|
+
element,
|
|
298
|
+
boundary,
|
|
299
|
+
rootBoundary,
|
|
300
|
+
strategy
|
|
301
|
+
} = _ref;
|
|
302
|
+
const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
303
|
+
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
304
|
+
const firstClippingAncestor = clippingAncestors[0];
|
|
305
|
+
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
306
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
307
|
+
accRect.top = max(rect.top, accRect.top);
|
|
308
|
+
accRect.right = min(rect.right, accRect.right);
|
|
309
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
310
|
+
accRect.left = max(rect.left, accRect.left);
|
|
311
|
+
return accRect;
|
|
312
|
+
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
313
|
+
return {
|
|
314
|
+
width: clippingRect.right - clippingRect.left,
|
|
315
|
+
height: clippingRect.bottom - clippingRect.top,
|
|
316
|
+
x: clippingRect.left,
|
|
317
|
+
y: clippingRect.top
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
function getDimensions(element) {
|
|
76
321
|
const {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (!deepEqual(latestMiddleware, middleware)) {
|
|
99
|
-
setLatestMiddleware(middleware);
|
|
100
|
-
}
|
|
101
|
-
const [_reference, _setReference] = React.useState(null);
|
|
102
|
-
const [_floating, _setFloating] = React.useState(null);
|
|
103
|
-
const setReference = React.useCallback((node) => {
|
|
104
|
-
if (node !== referenceRef.current) {
|
|
105
|
-
referenceRef.current = node;
|
|
106
|
-
_setReference(node);
|
|
322
|
+
width,
|
|
323
|
+
height
|
|
324
|
+
} = getCssDimensions(element);
|
|
325
|
+
return {
|
|
326
|
+
width,
|
|
327
|
+
height
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
331
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
332
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
333
|
+
const isFixed = strategy === "fixed";
|
|
334
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
335
|
+
let scroll = {
|
|
336
|
+
scrollLeft: 0,
|
|
337
|
+
scrollTop: 0
|
|
338
|
+
};
|
|
339
|
+
const offsets = createCoords(0);
|
|
340
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
341
|
+
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
342
|
+
scroll = getNodeScroll(offsetParent);
|
|
107
343
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
344
|
+
if (isOffsetParentAnElement) {
|
|
345
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
346
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
347
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
348
|
+
} else if (documentElement) {
|
|
349
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
353
|
+
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
|
354
|
+
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
|
355
|
+
return {
|
|
356
|
+
x,
|
|
357
|
+
y,
|
|
358
|
+
width: rect.width,
|
|
359
|
+
height: rect.height
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
function isStaticPositioned(element) {
|
|
363
|
+
return getComputedStyle(element).position === "static";
|
|
364
|
+
}
|
|
365
|
+
function getTrueOffsetParent(element, polyfill) {
|
|
366
|
+
if (!isHTMLElement(element) || getComputedStyle(element).position === "fixed") {
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
369
|
+
if (polyfill) {
|
|
370
|
+
return polyfill(element);
|
|
371
|
+
}
|
|
372
|
+
let rawOffsetParent = element.offsetParent;
|
|
373
|
+
if (getDocumentElement(element) === rawOffsetParent) {
|
|
374
|
+
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
375
|
+
}
|
|
376
|
+
return rawOffsetParent;
|
|
377
|
+
}
|
|
378
|
+
function getOffsetParent(element, polyfill) {
|
|
379
|
+
const win = getWindow(element);
|
|
380
|
+
if (isTopLayer(element)) {
|
|
381
|
+
return win;
|
|
382
|
+
}
|
|
383
|
+
if (!isHTMLElement(element)) {
|
|
384
|
+
let svgOffsetParent = getParentNode(element);
|
|
385
|
+
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
386
|
+
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
|
387
|
+
return svgOffsetParent;
|
|
388
|
+
}
|
|
389
|
+
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
113
390
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
391
|
+
return win;
|
|
392
|
+
}
|
|
393
|
+
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
394
|
+
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
|
395
|
+
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
396
|
+
}
|
|
397
|
+
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
|
398
|
+
return win;
|
|
399
|
+
}
|
|
400
|
+
return offsetParent || getContainingBlock(element) || win;
|
|
401
|
+
}
|
|
402
|
+
const getElementRects = async function(data) {
|
|
403
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
404
|
+
const getDimensionsFn = this.getDimensions;
|
|
405
|
+
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
406
|
+
return {
|
|
407
|
+
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
408
|
+
floating: {
|
|
409
|
+
x: 0,
|
|
410
|
+
y: 0,
|
|
411
|
+
width: floatingDimensions.width,
|
|
412
|
+
height: floatingDimensions.height
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
};
|
|
416
|
+
function isRTL(element) {
|
|
417
|
+
return getComputedStyle(element).direction === "rtl";
|
|
418
|
+
}
|
|
419
|
+
const platform = {
|
|
420
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
421
|
+
getDocumentElement,
|
|
422
|
+
getClippingRect,
|
|
423
|
+
getOffsetParent,
|
|
424
|
+
getElementRects,
|
|
425
|
+
getClientRects,
|
|
426
|
+
getDimensions,
|
|
427
|
+
getScale,
|
|
428
|
+
isElement,
|
|
429
|
+
isRTL
|
|
430
|
+
};
|
|
431
|
+
function observeMove(element, onMove) {
|
|
432
|
+
let io = null;
|
|
433
|
+
let timeoutId;
|
|
434
|
+
const root = getDocumentElement(element);
|
|
435
|
+
function cleanup() {
|
|
436
|
+
var _io;
|
|
437
|
+
clearTimeout(timeoutId);
|
|
438
|
+
(_io = io) == null || _io.disconnect();
|
|
439
|
+
io = null;
|
|
440
|
+
}
|
|
441
|
+
function refresh(skip, threshold) {
|
|
442
|
+
if (skip === void 0) {
|
|
443
|
+
skip = false;
|
|
444
|
+
}
|
|
445
|
+
if (threshold === void 0) {
|
|
446
|
+
threshold = 1;
|
|
447
|
+
}
|
|
448
|
+
cleanup();
|
|
449
|
+
const {
|
|
450
|
+
left,
|
|
451
|
+
top,
|
|
452
|
+
width,
|
|
453
|
+
height
|
|
454
|
+
} = element.getBoundingClientRect();
|
|
455
|
+
if (!skip) {
|
|
456
|
+
onMove();
|
|
457
|
+
}
|
|
458
|
+
if (!width || !height) {
|
|
126
459
|
return;
|
|
127
460
|
}
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
461
|
+
const insetTop = floor(top);
|
|
462
|
+
const insetRight = floor(root.clientWidth - (left + width));
|
|
463
|
+
const insetBottom = floor(root.clientHeight - (top + height));
|
|
464
|
+
const insetLeft = floor(left);
|
|
465
|
+
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
|
466
|
+
const options = {
|
|
467
|
+
rootMargin,
|
|
468
|
+
threshold: max(0, min(1, threshold)) || 1
|
|
132
469
|
};
|
|
133
|
-
|
|
134
|
-
|
|
470
|
+
let isFirstUpdate = true;
|
|
471
|
+
function handleObserve(entries) {
|
|
472
|
+
const ratio = entries[0].intersectionRatio;
|
|
473
|
+
if (ratio !== threshold) {
|
|
474
|
+
if (!isFirstUpdate) {
|
|
475
|
+
return refresh();
|
|
476
|
+
}
|
|
477
|
+
if (!ratio) {
|
|
478
|
+
timeoutId = setTimeout(() => {
|
|
479
|
+
refresh(false, 1e-7);
|
|
480
|
+
}, 1e3);
|
|
481
|
+
} else {
|
|
482
|
+
refresh(false, ratio);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
isFirstUpdate = false;
|
|
486
|
+
}
|
|
487
|
+
try {
|
|
488
|
+
io = new IntersectionObserver(handleObserve, {
|
|
489
|
+
...options,
|
|
490
|
+
// Handle <iframe>s
|
|
491
|
+
root: root.ownerDocument
|
|
492
|
+
});
|
|
493
|
+
} catch (e) {
|
|
494
|
+
io = new IntersectionObserver(handleObserve, options);
|
|
135
495
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
496
|
+
io.observe(element);
|
|
497
|
+
}
|
|
498
|
+
refresh(true);
|
|
499
|
+
return cleanup;
|
|
500
|
+
}
|
|
501
|
+
function autoUpdate(reference, floating, update, options) {
|
|
502
|
+
if (options === void 0) {
|
|
503
|
+
options = {};
|
|
504
|
+
}
|
|
505
|
+
const {
|
|
506
|
+
ancestorScroll = true,
|
|
507
|
+
ancestorResize = true,
|
|
508
|
+
elementResize = typeof ResizeObserver === "function",
|
|
509
|
+
layoutShift = typeof IntersectionObserver === "function",
|
|
510
|
+
animationFrame = false
|
|
511
|
+
} = options;
|
|
512
|
+
const referenceEl = unwrapElement(reference);
|
|
513
|
+
const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
|
|
514
|
+
ancestors.forEach((ancestor) => {
|
|
515
|
+
ancestorScroll && ancestor.addEventListener("scroll", update, {
|
|
516
|
+
passive: true
|
|
517
|
+
});
|
|
518
|
+
ancestorResize && ancestor.addEventListener("resize", update);
|
|
519
|
+
});
|
|
520
|
+
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
|
521
|
+
let reobserveFrame = -1;
|
|
522
|
+
let resizeObserver = null;
|
|
523
|
+
if (elementResize) {
|
|
524
|
+
resizeObserver = new ResizeObserver((_ref) => {
|
|
525
|
+
let [firstEntry] = _ref;
|
|
526
|
+
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
|
527
|
+
resizeObserver.unobserve(floating);
|
|
528
|
+
cancelAnimationFrame(reobserveFrame);
|
|
529
|
+
reobserveFrame = requestAnimationFrame(() => {
|
|
530
|
+
var _resizeObserver;
|
|
531
|
+
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
|
|
149
532
|
});
|
|
150
533
|
}
|
|
534
|
+
update();
|
|
151
535
|
});
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (open === false && dataRef.current.isPositioned) {
|
|
155
|
-
dataRef.current.isPositioned = false;
|
|
156
|
-
setData((data2) => ({
|
|
157
|
-
...data2,
|
|
158
|
-
isPositioned: false
|
|
159
|
-
}));
|
|
536
|
+
if (referenceEl && !animationFrame) {
|
|
537
|
+
resizeObserver.observe(referenceEl);
|
|
160
538
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if (
|
|
171
|
-
if (floatingEl) floatingRef.current = floatingEl;
|
|
172
|
-
if (referenceEl && floatingEl) {
|
|
173
|
-
if (whileElementsMountedRef.current) {
|
|
174
|
-
return whileElementsMountedRef.current(referenceEl, floatingEl, update);
|
|
175
|
-
}
|
|
539
|
+
resizeObserver.observe(floating);
|
|
540
|
+
}
|
|
541
|
+
let frameId;
|
|
542
|
+
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
543
|
+
if (animationFrame) {
|
|
544
|
+
frameLoop();
|
|
545
|
+
}
|
|
546
|
+
function frameLoop() {
|
|
547
|
+
const nextRefRect = getBoundingClientRect(reference);
|
|
548
|
+
if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
|
|
176
549
|
update();
|
|
177
550
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
reference: referenceRef,
|
|
181
|
-
floating: floatingRef,
|
|
182
|
-
setReference,
|
|
183
|
-
setFloating
|
|
184
|
-
}), [setReference, setFloating]);
|
|
185
|
-
const elements = React.useMemo(() => ({
|
|
186
|
-
reference: referenceEl,
|
|
187
|
-
floating: floatingEl
|
|
188
|
-
}), [referenceEl, floatingEl]);
|
|
189
|
-
const floatingStyles = React.useMemo(() => {
|
|
190
|
-
const initialStyles = {
|
|
191
|
-
position: strategy,
|
|
192
|
-
left: 0,
|
|
193
|
-
top: 0
|
|
194
|
-
};
|
|
195
|
-
if (!elements.floating) {
|
|
196
|
-
return initialStyles;
|
|
197
|
-
}
|
|
198
|
-
const x = roundByDPR(elements.floating, data.x);
|
|
199
|
-
const y = roundByDPR(elements.floating, data.y);
|
|
200
|
-
if (transform) {
|
|
201
|
-
return {
|
|
202
|
-
...initialStyles,
|
|
203
|
-
transform: "translate(" + x + "px, " + y + "px)",
|
|
204
|
-
...getDPR(elements.floating) >= 1.5 && {
|
|
205
|
-
willChange: "transform"
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
return {
|
|
210
|
-
position: strategy,
|
|
211
|
-
left: x,
|
|
212
|
-
top: y
|
|
213
|
-
};
|
|
214
|
-
}, [strategy, transform, elements.floating, data.x, data.y]);
|
|
215
|
-
return React.useMemo(() => ({
|
|
216
|
-
...data,
|
|
217
|
-
update,
|
|
218
|
-
refs,
|
|
219
|
-
elements,
|
|
220
|
-
floatingStyles
|
|
221
|
-
}), [data, update, refs, elements, floatingStyles]);
|
|
222
|
-
}
|
|
223
|
-
const arrow$1 = (options) => {
|
|
224
|
-
function isRef(value) {
|
|
225
|
-
return {}.hasOwnProperty.call(value, "current");
|
|
551
|
+
prevRefRect = nextRefRect;
|
|
552
|
+
frameId = requestAnimationFrame(frameLoop);
|
|
226
553
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
padding
|
|
240
|
-
}).fn(state);
|
|
241
|
-
}
|
|
242
|
-
return {};
|
|
243
|
-
}
|
|
244
|
-
if (element) {
|
|
245
|
-
return arrow$2({
|
|
246
|
-
element,
|
|
247
|
-
padding
|
|
248
|
-
}).fn(state);
|
|
249
|
-
}
|
|
250
|
-
return {};
|
|
554
|
+
update();
|
|
555
|
+
return () => {
|
|
556
|
+
var _resizeObserver2;
|
|
557
|
+
ancestors.forEach((ancestor) => {
|
|
558
|
+
ancestorScroll && ancestor.removeEventListener("scroll", update);
|
|
559
|
+
ancestorResize && ancestor.removeEventListener("resize", update);
|
|
560
|
+
});
|
|
561
|
+
cleanupIo == null || cleanupIo();
|
|
562
|
+
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
|
|
563
|
+
resizeObserver = null;
|
|
564
|
+
if (animationFrame) {
|
|
565
|
+
cancelAnimationFrame(frameId);
|
|
251
566
|
}
|
|
252
567
|
};
|
|
568
|
+
}
|
|
569
|
+
const offset = offset$1;
|
|
570
|
+
const shift = shift$1;
|
|
571
|
+
const flip = flip$1;
|
|
572
|
+
const arrow = arrow$1;
|
|
573
|
+
const inline = inline$1;
|
|
574
|
+
const computePosition = (reference, floating, options) => {
|
|
575
|
+
const cache = /* @__PURE__ */ new Map();
|
|
576
|
+
const mergedOptions = {
|
|
577
|
+
platform,
|
|
578
|
+
...options
|
|
579
|
+
};
|
|
580
|
+
const platformWithCache = {
|
|
581
|
+
...mergedOptions.platform,
|
|
582
|
+
_c: cache
|
|
583
|
+
};
|
|
584
|
+
return computePosition$1(reference, floating, {
|
|
585
|
+
...mergedOptions,
|
|
586
|
+
platform: platformWithCache
|
|
587
|
+
});
|
|
253
588
|
};
|
|
254
|
-
const offset = (options, deps) => ({
|
|
255
|
-
...offset$1(options),
|
|
256
|
-
options: [options, deps]
|
|
257
|
-
});
|
|
258
|
-
const shift = (options, deps) => ({
|
|
259
|
-
...shift$1(options),
|
|
260
|
-
options: [options, deps]
|
|
261
|
-
});
|
|
262
|
-
const flip = (options, deps) => ({
|
|
263
|
-
...flip$1(options),
|
|
264
|
-
options: [options, deps]
|
|
265
|
-
});
|
|
266
|
-
const inline = (options, deps) => ({
|
|
267
|
-
...inline$1(options),
|
|
268
|
-
options: [options, deps]
|
|
269
|
-
});
|
|
270
|
-
const arrow = (options, deps) => ({
|
|
271
|
-
...arrow$1(options),
|
|
272
|
-
options: [options, deps]
|
|
273
|
-
});
|
|
274
589
|
export {
|
|
275
590
|
arrow,
|
|
276
591
|
autoUpdate,
|
|
277
592
|
computePosition,
|
|
278
593
|
flip,
|
|
594
|
+
getOverflowAncestors,
|
|
279
595
|
inline,
|
|
280
596
|
offset,
|
|
281
597
|
platform,
|
|
282
|
-
shift
|
|
283
|
-
useFloating
|
|
598
|
+
shift
|
|
284
599
|
};
|
|
285
600
|
//# sourceMappingURL=react-text-annotator.es18.js.map
|