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