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