@soomo/react-text-annotator 3.0.0-staging.16 → 3.0.0-staging.17
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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/react-text-annotator.es.js +2 -0
- package/dist/react-text-annotator.es.js.map +1 -1
- package/dist/react-text-annotator.es10.js +210 -562
- package/dist/react-text-annotator.es10.js.map +1 -1
- package/dist/react-text-annotator.es11.js +535 -444
- package/dist/react-text-annotator.es11.js.map +1 -1
- package/dist/react-text-annotator.es12.js +488 -2
- package/dist/react-text-annotator.es12.js.map +1 -1
- package/dist/react-text-annotator.es13.js +2 -35
- package/dist/react-text-annotator.es13.js.map +1 -1
- package/dist/react-text-annotator.es14.js +24 -888
- package/dist/react-text-annotator.es14.js.map +1 -1
- package/dist/react-text-annotator.es15.js +891 -220
- package/dist/react-text-annotator.es15.js.map +1 -1
- package/dist/react-text-annotator.es16.js +218 -126
- package/dist/react-text-annotator.es16.js.map +1 -1
- package/dist/react-text-annotator.es17.js +136 -2
- package/dist/react-text-annotator.es17.js.map +1 -1
- package/dist/react-text-annotator.es18.js +2 -2
- package/dist/react-text-annotator.es19.js +2 -114
- package/dist/react-text-annotator.es19.js.map +1 -1
- package/dist/react-text-annotator.es2.js +2 -2
- package/dist/react-text-annotator.es20.js +107 -302
- package/dist/react-text-annotator.es20.js.map +1 -1
- package/dist/react-text-annotator.es21.js +290 -39
- package/dist/react-text-annotator.es21.js.map +1 -1
- package/dist/react-text-annotator.es22.js +55 -17
- package/dist/react-text-annotator.es22.js.map +1 -1
- package/dist/react-text-annotator.es23.js +17 -118
- package/dist/react-text-annotator.es23.js.map +1 -1
- package/dist/react-text-annotator.es24.js +107 -538
- package/dist/react-text-annotator.es24.js.map +1 -1
- package/dist/react-text-annotator.es25.js +555 -0
- package/dist/react-text-annotator.es25.js.map +1 -0
- package/dist/react-text-annotator.es3.js +2 -2
- package/dist/react-text-annotator.es4.js +2 -2
- package/dist/react-text-annotator.es5.js +4 -4
- package/dist/react-text-annotator.es6.js +178 -9
- package/dist/react-text-annotator.es6.js.map +1 -1
- package/dist/react-text-annotator.es7.js +12 -1
- package/dist/react-text-annotator.es7.js.map +1 -1
- package/dist/react-text-annotator.es9.js +20 -223
- package/dist/react-text-annotator.es9.js.map +1 -1
- package/package.json +13 -7
- package/dist/react-text-annotator.es8.js +0 -27
- package/dist/react-text-annotator.es8.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-text-annotator.es23.js","sources":["../../../node_modules
|
|
1
|
+
{"version":3,"file":"react-text-annotator.es23.js","sources":["../../../node_modules/CETEIcean/src/dom.js"],"sourcesContent":["export function learnElementNames(XML_dom, namespaces) {\n const root = XML_dom.documentElement;\n let i = 1;\n let qname = function(e) { \n if (!namespaces.has(e.namespaceURI ? e.namespaceURI : \"\")) {\n namespaces.set(e.namespaceURI, \"ns\" + i++);\n } \n return namespaces.get(e.namespaceURI ? e.namespaceURI : \"\") + \":\" + e.localName;\n };\n const els = new Set(\n Array.from(root.querySelectorAll(\"*\"), qname));\n \n // Add the root element to the array\n els.add(qname(root));\n return els\n}\n\nexport function learnCustomElementNames(HTML_dom) {\n return new Set(Array.from(HTML_dom.querySelectorAll(\"*[data-origname]\"), e => e.localName.replace(/(\\w+)-.+/,\"$1:\") + e.getAttribute(\"data-origname\")));\n}"],"names":[],"mappings":"AAAO,SAAS,kBAAkB,SAAS,YAAY;AACrD,QAAM,OAAO,QAAQ;AACrB,MAAI,IAAI;AACR,MAAI,QAAQ,SAAS,GAAG;AACtB,QAAI,CAAC,WAAW,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,GAAG;AACzD,iBAAW,IAAI,EAAE,cAAc,OAAO,GAAG;AAAA,IAC1C;AACD,WAAO,WAAW,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,IAAI,MAAM,EAAE;AAAA,EAC1E;AACE,QAAM,MAAM,IAAI;AAAA,IACd,MAAM,KAAK,KAAK,iBAAiB,GAAG,GAAG,KAAK;AAAA,EAAC;AAG/C,MAAI,IAAI,MAAM,IAAI,CAAC;AACnB,SAAO;AACT;AAEO,SAAS,wBAAwB,UAAU;AAChD,SAAO,IAAI,IAAI,MAAM,KAAK,SAAS,iBAAiB,kBAAkB,GAAG,OAAK,EAAE,UAAU,QAAQ,YAAW,KAAK,IAAI,EAAE,aAAa,eAAe,CAAC,CAAC;AACxJ;","x_google_ignoreList":[0]}
|
|
@@ -1,555 +1,124 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
case "top":
|
|
18
|
-
coords = {
|
|
19
|
-
x: commonX,
|
|
20
|
-
y: reference.y - floating.height
|
|
21
|
-
};
|
|
22
|
-
break;
|
|
23
|
-
case "bottom":
|
|
24
|
-
coords = {
|
|
25
|
-
x: commonX,
|
|
26
|
-
y: reference.y + reference.height
|
|
27
|
-
};
|
|
28
|
-
break;
|
|
29
|
-
case "right":
|
|
30
|
-
coords = {
|
|
31
|
-
x: reference.x + reference.width,
|
|
32
|
-
y: commonY
|
|
33
|
-
};
|
|
34
|
-
break;
|
|
35
|
-
case "left":
|
|
36
|
-
coords = {
|
|
37
|
-
x: reference.x - floating.width,
|
|
38
|
-
y: commonY
|
|
39
|
-
};
|
|
40
|
-
break;
|
|
41
|
-
default:
|
|
42
|
-
coords = {
|
|
43
|
-
x: reference.x,
|
|
44
|
-
y: reference.y
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
switch (getAlignment(placement)) {
|
|
48
|
-
case "start":
|
|
49
|
-
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
50
|
-
break;
|
|
51
|
-
case "end":
|
|
52
|
-
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
return coords;
|
|
56
|
-
}
|
|
57
|
-
const computePosition = async (reference, floating, config) => {
|
|
58
|
-
const {
|
|
59
|
-
placement = "bottom",
|
|
60
|
-
strategy = "absolute",
|
|
61
|
-
middleware = [],
|
|
62
|
-
platform
|
|
63
|
-
} = config;
|
|
64
|
-
const validMiddleware = middleware.filter(Boolean);
|
|
65
|
-
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
66
|
-
let rects = await platform.getElementRects({
|
|
67
|
-
reference,
|
|
68
|
-
floating,
|
|
69
|
-
strategy
|
|
70
|
-
});
|
|
71
|
-
let {
|
|
72
|
-
x,
|
|
73
|
-
y
|
|
74
|
-
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
75
|
-
let statefulPlacement = placement;
|
|
76
|
-
let middlewareData = {};
|
|
77
|
-
let resetCount = 0;
|
|
78
|
-
for (let i = 0; i < validMiddleware.length; i++) {
|
|
79
|
-
const {
|
|
80
|
-
name,
|
|
81
|
-
fn
|
|
82
|
-
} = validMiddleware[i];
|
|
83
|
-
const {
|
|
84
|
-
x: nextX,
|
|
85
|
-
y: nextY,
|
|
86
|
-
data,
|
|
87
|
-
reset
|
|
88
|
-
} = await fn({
|
|
89
|
-
x,
|
|
90
|
-
y,
|
|
91
|
-
initialPlacement: placement,
|
|
92
|
-
placement: statefulPlacement,
|
|
93
|
-
strategy,
|
|
94
|
-
middlewareData,
|
|
95
|
-
rects,
|
|
96
|
-
platform,
|
|
97
|
-
elements: {
|
|
98
|
-
reference,
|
|
99
|
-
floating
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
x = nextX != null ? nextX : x;
|
|
103
|
-
y = nextY != null ? nextY : y;
|
|
104
|
-
middlewareData = {
|
|
105
|
-
...middlewareData,
|
|
106
|
-
[name]: {
|
|
107
|
-
...middlewareData[name],
|
|
108
|
-
...data
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
if (reset && resetCount <= 50) {
|
|
112
|
-
resetCount++;
|
|
113
|
-
if (typeof reset === "object") {
|
|
114
|
-
if (reset.placement) {
|
|
115
|
-
statefulPlacement = reset.placement;
|
|
116
|
-
}
|
|
117
|
-
if (reset.rects) {
|
|
118
|
-
rects = reset.rects === true ? await platform.getElementRects({
|
|
119
|
-
reference,
|
|
120
|
-
floating,
|
|
121
|
-
strategy
|
|
122
|
-
}) : reset.rects;
|
|
123
|
-
}
|
|
124
|
-
({
|
|
125
|
-
x,
|
|
126
|
-
y
|
|
127
|
-
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
128
|
-
}
|
|
129
|
-
i = -1;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return {
|
|
133
|
-
x,
|
|
134
|
-
y,
|
|
135
|
-
placement: statefulPlacement,
|
|
136
|
-
strategy,
|
|
137
|
-
middlewareData
|
|
138
|
-
};
|
|
1
|
+
const sides = ["top", "right", "bottom", "left"];
|
|
2
|
+
const alignments = ["start", "end"];
|
|
3
|
+
const placements = /* @__PURE__ */ sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
|
|
4
|
+
const min = Math.min;
|
|
5
|
+
const max = Math.max;
|
|
6
|
+
const round = Math.round;
|
|
7
|
+
const floor = Math.floor;
|
|
8
|
+
const createCoords = (v) => ({
|
|
9
|
+
x: v,
|
|
10
|
+
y: v
|
|
11
|
+
});
|
|
12
|
+
const oppositeSideMap = {
|
|
13
|
+
left: "right",
|
|
14
|
+
right: "left",
|
|
15
|
+
bottom: "top",
|
|
16
|
+
top: "bottom"
|
|
139
17
|
};
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
x,
|
|
147
|
-
y,
|
|
148
|
-
platform,
|
|
149
|
-
rects,
|
|
150
|
-
elements,
|
|
151
|
-
strategy
|
|
152
|
-
} = state;
|
|
153
|
-
const {
|
|
154
|
-
boundary = "clippingAncestors",
|
|
155
|
-
rootBoundary = "viewport",
|
|
156
|
-
elementContext = "floating",
|
|
157
|
-
altBoundary = false,
|
|
158
|
-
padding = 0
|
|
159
|
-
} = evaluate(options, state);
|
|
160
|
-
const paddingObject = getPaddingObject(padding);
|
|
161
|
-
const altContext = elementContext === "floating" ? "reference" : "floating";
|
|
162
|
-
const element = elements[altBoundary ? altContext : elementContext];
|
|
163
|
-
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
164
|
-
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating)),
|
|
165
|
-
boundary,
|
|
166
|
-
rootBoundary,
|
|
167
|
-
strategy
|
|
168
|
-
}));
|
|
169
|
-
const rect = elementContext === "floating" ? {
|
|
170
|
-
x,
|
|
171
|
-
y,
|
|
172
|
-
width: rects.floating.width,
|
|
173
|
-
height: rects.floating.height
|
|
174
|
-
} : rects.reference;
|
|
175
|
-
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
176
|
-
const offsetScale = await (platform.isElement == null ? void 0 : platform.isElement(offsetParent)) ? await (platform.getScale == null ? void 0 : platform.getScale(offsetParent)) || {
|
|
177
|
-
x: 1,
|
|
178
|
-
y: 1
|
|
179
|
-
} : {
|
|
180
|
-
x: 1,
|
|
181
|
-
y: 1
|
|
182
|
-
};
|
|
183
|
-
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
184
|
-
elements,
|
|
185
|
-
rect,
|
|
186
|
-
offsetParent,
|
|
187
|
-
strategy
|
|
188
|
-
}) : rect);
|
|
189
|
-
return {
|
|
190
|
-
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
191
|
-
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
192
|
-
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
193
|
-
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
194
|
-
};
|
|
18
|
+
const oppositeAlignmentMap = {
|
|
19
|
+
start: "end",
|
|
20
|
+
end: "start"
|
|
21
|
+
};
|
|
22
|
+
function clamp(start, value, end) {
|
|
23
|
+
return max(start, min(value, end));
|
|
195
24
|
}
|
|
196
|
-
function
|
|
197
|
-
|
|
198
|
-
return allowedPlacementsSortedByAlignment.filter((placement) => {
|
|
199
|
-
if (alignment) {
|
|
200
|
-
return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
|
|
201
|
-
}
|
|
202
|
-
return true;
|
|
203
|
-
});
|
|
25
|
+
function evaluate(value, param) {
|
|
26
|
+
return typeof value === "function" ? value(param) : value;
|
|
204
27
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
options = {};
|
|
208
|
-
}
|
|
209
|
-
return {
|
|
210
|
-
name: "autoPlacement",
|
|
211
|
-
options,
|
|
212
|
-
async fn(state) {
|
|
213
|
-
var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
|
|
214
|
-
const {
|
|
215
|
-
rects,
|
|
216
|
-
middlewareData,
|
|
217
|
-
placement,
|
|
218
|
-
platform,
|
|
219
|
-
elements
|
|
220
|
-
} = state;
|
|
221
|
-
const {
|
|
222
|
-
crossAxis = false,
|
|
223
|
-
alignment,
|
|
224
|
-
allowedPlacements = placements,
|
|
225
|
-
autoAlignment = true,
|
|
226
|
-
...detectOverflowOptions
|
|
227
|
-
} = evaluate(options, state);
|
|
228
|
-
const placements$1 = alignment !== void 0 || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
|
|
229
|
-
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
230
|
-
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
|
|
231
|
-
const currentPlacement = placements$1[currentIndex];
|
|
232
|
-
if (currentPlacement == null) {
|
|
233
|
-
return {};
|
|
234
|
-
}
|
|
235
|
-
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
|
|
236
|
-
if (placement !== currentPlacement) {
|
|
237
|
-
return {
|
|
238
|
-
reset: {
|
|
239
|
-
placement: placements$1[0]
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
|
|
244
|
-
const allOverflows = [...((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || [], {
|
|
245
|
-
placement: currentPlacement,
|
|
246
|
-
overflows: currentOverflows
|
|
247
|
-
}];
|
|
248
|
-
const nextPlacement = placements$1[currentIndex + 1];
|
|
249
|
-
if (nextPlacement) {
|
|
250
|
-
return {
|
|
251
|
-
data: {
|
|
252
|
-
index: currentIndex + 1,
|
|
253
|
-
overflows: allOverflows
|
|
254
|
-
},
|
|
255
|
-
reset: {
|
|
256
|
-
placement: nextPlacement
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
const placementsSortedByMostSpace = allOverflows.map((d) => {
|
|
261
|
-
const alignment2 = getAlignment(d.placement);
|
|
262
|
-
return [d.placement, alignment2 && crossAxis ? (
|
|
263
|
-
// Check along the mainAxis and main crossAxis side.
|
|
264
|
-
d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0)
|
|
265
|
-
) : (
|
|
266
|
-
// Check only the mainAxis.
|
|
267
|
-
d.overflows[0]
|
|
268
|
-
), d.overflows];
|
|
269
|
-
}).sort((a, b) => a[1] - b[1]);
|
|
270
|
-
const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter((d) => d[2].slice(
|
|
271
|
-
0,
|
|
272
|
-
// Aligned placements should not check their opposite crossAxis
|
|
273
|
-
// side.
|
|
274
|
-
getAlignment(d[0]) ? 2 : 3
|
|
275
|
-
).every((v) => v <= 0));
|
|
276
|
-
const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
|
|
277
|
-
if (resetPlacement !== placement) {
|
|
278
|
-
return {
|
|
279
|
-
data: {
|
|
280
|
-
index: currentIndex + 1,
|
|
281
|
-
overflows: allOverflows
|
|
282
|
-
},
|
|
283
|
-
reset: {
|
|
284
|
-
placement: resetPlacement
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
return {};
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
};
|
|
292
|
-
function getBoundingRect(rects) {
|
|
293
|
-
const minX = min(...rects.map((rect) => rect.left));
|
|
294
|
-
const minY = min(...rects.map((rect) => rect.top));
|
|
295
|
-
const maxX = max(...rects.map((rect) => rect.right));
|
|
296
|
-
const maxY = max(...rects.map((rect) => rect.bottom));
|
|
297
|
-
return {
|
|
298
|
-
x: minX,
|
|
299
|
-
y: minY,
|
|
300
|
-
width: maxX - minX,
|
|
301
|
-
height: maxY - minY
|
|
302
|
-
};
|
|
28
|
+
function getSide(placement) {
|
|
29
|
+
return placement.split("-")[0];
|
|
303
30
|
}
|
|
304
|
-
function
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
} else {
|
|
313
|
-
groups[groups.length - 1].push(rect);
|
|
314
|
-
}
|
|
315
|
-
prevRect = rect;
|
|
316
|
-
}
|
|
317
|
-
return groups.map((rect) => rectToClientRect(getBoundingRect(rect)));
|
|
31
|
+
function getAlignment(placement) {
|
|
32
|
+
return placement.split("-")[1];
|
|
33
|
+
}
|
|
34
|
+
function getOppositeAxis(axis) {
|
|
35
|
+
return axis === "x" ? "y" : "x";
|
|
36
|
+
}
|
|
37
|
+
function getAxisLength(axis) {
|
|
38
|
+
return axis === "y" ? "height" : "width";
|
|
318
39
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
40
|
+
function getSideAxis(placement) {
|
|
41
|
+
return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
|
|
42
|
+
}
|
|
43
|
+
function getAlignmentAxis(placement) {
|
|
44
|
+
return getOppositeAxis(getSideAxis(placement));
|
|
45
|
+
}
|
|
46
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
47
|
+
if (rtl === void 0) {
|
|
48
|
+
rtl = false;
|
|
322
49
|
}
|
|
323
|
-
return {
|
|
324
|
-
name: "inline",
|
|
325
|
-
options,
|
|
326
|
-
async fn(state) {
|
|
327
|
-
const {
|
|
328
|
-
placement,
|
|
329
|
-
elements,
|
|
330
|
-
rects,
|
|
331
|
-
platform,
|
|
332
|
-
strategy
|
|
333
|
-
} = state;
|
|
334
|
-
const {
|
|
335
|
-
padding = 2,
|
|
336
|
-
x,
|
|
337
|
-
y
|
|
338
|
-
} = evaluate(options, state);
|
|
339
|
-
const nativeClientRects = Array.from(await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference)) || []);
|
|
340
|
-
const clientRects = getRectsByLine(nativeClientRects);
|
|
341
|
-
const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
|
|
342
|
-
const paddingObject = getPaddingObject(padding);
|
|
343
|
-
function getBoundingClientRect() {
|
|
344
|
-
if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
|
|
345
|
-
return clientRects.find((rect) => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
|
|
346
|
-
}
|
|
347
|
-
if (clientRects.length >= 2) {
|
|
348
|
-
if (getSideAxis(placement) === "y") {
|
|
349
|
-
const firstRect = clientRects[0];
|
|
350
|
-
const lastRect = clientRects[clientRects.length - 1];
|
|
351
|
-
const isTop = getSide(placement) === "top";
|
|
352
|
-
const top2 = firstRect.top;
|
|
353
|
-
const bottom2 = lastRect.bottom;
|
|
354
|
-
const left2 = isTop ? firstRect.left : lastRect.left;
|
|
355
|
-
const right2 = isTop ? firstRect.right : lastRect.right;
|
|
356
|
-
const width2 = right2 - left2;
|
|
357
|
-
const height2 = bottom2 - top2;
|
|
358
|
-
return {
|
|
359
|
-
top: top2,
|
|
360
|
-
bottom: bottom2,
|
|
361
|
-
left: left2,
|
|
362
|
-
right: right2,
|
|
363
|
-
width: width2,
|
|
364
|
-
height: height2,
|
|
365
|
-
x: left2,
|
|
366
|
-
y: top2
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
const isLeftSide = getSide(placement) === "left";
|
|
370
|
-
const maxRight = max(...clientRects.map((rect) => rect.right));
|
|
371
|
-
const minLeft = min(...clientRects.map((rect) => rect.left));
|
|
372
|
-
const measureRects = clientRects.filter((rect) => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
|
|
373
|
-
const top = measureRects[0].top;
|
|
374
|
-
const bottom = measureRects[measureRects.length - 1].bottom;
|
|
375
|
-
const left = minLeft;
|
|
376
|
-
const right = maxRight;
|
|
377
|
-
const width = right - left;
|
|
378
|
-
const height = bottom - top;
|
|
379
|
-
return {
|
|
380
|
-
top,
|
|
381
|
-
bottom,
|
|
382
|
-
left,
|
|
383
|
-
right,
|
|
384
|
-
width,
|
|
385
|
-
height,
|
|
386
|
-
x: left,
|
|
387
|
-
y: top
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
return fallback;
|
|
391
|
-
}
|
|
392
|
-
const resetRects = await platform.getElementRects({
|
|
393
|
-
reference: {
|
|
394
|
-
getBoundingClientRect
|
|
395
|
-
},
|
|
396
|
-
floating: elements.floating,
|
|
397
|
-
strategy
|
|
398
|
-
});
|
|
399
|
-
if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
|
|
400
|
-
return {
|
|
401
|
-
reset: {
|
|
402
|
-
rects: resetRects
|
|
403
|
-
}
|
|
404
|
-
};
|
|
405
|
-
}
|
|
406
|
-
return {};
|
|
407
|
-
}
|
|
408
|
-
};
|
|
409
|
-
};
|
|
410
|
-
async function convertValueToCoords(state, options) {
|
|
411
|
-
const {
|
|
412
|
-
placement,
|
|
413
|
-
platform,
|
|
414
|
-
elements
|
|
415
|
-
} = state;
|
|
416
|
-
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
417
|
-
const side = getSide(placement);
|
|
418
50
|
const alignment = getAlignment(placement);
|
|
419
|
-
const
|
|
420
|
-
const
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
mainAxis,
|
|
425
|
-
crossAxis,
|
|
426
|
-
alignmentAxis
|
|
427
|
-
} = typeof rawValue === "number" ? {
|
|
428
|
-
mainAxis: rawValue,
|
|
429
|
-
crossAxis: 0,
|
|
430
|
-
alignmentAxis: null
|
|
431
|
-
} : {
|
|
432
|
-
mainAxis: 0,
|
|
433
|
-
crossAxis: 0,
|
|
434
|
-
alignmentAxis: null,
|
|
435
|
-
...rawValue
|
|
436
|
-
};
|
|
437
|
-
if (alignment && typeof alignmentAxis === "number") {
|
|
438
|
-
crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
|
|
51
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
52
|
+
const length = getAxisLength(alignmentAxis);
|
|
53
|
+
let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
|
|
54
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
55
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
439
56
|
}
|
|
440
|
-
return
|
|
441
|
-
x: crossAxis * crossAxisMulti,
|
|
442
|
-
y: mainAxis * mainAxisMulti
|
|
443
|
-
} : {
|
|
444
|
-
x: mainAxis * mainAxisMulti,
|
|
445
|
-
y: crossAxis * crossAxisMulti
|
|
446
|
-
};
|
|
57
|
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
447
58
|
}
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
59
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
60
|
+
return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
|
|
61
|
+
}
|
|
62
|
+
function getOppositePlacement(placement) {
|
|
63
|
+
return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
|
|
64
|
+
}
|
|
65
|
+
function expandPaddingObject(padding) {
|
|
452
66
|
return {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
x,
|
|
459
|
-
y,
|
|
460
|
-
placement,
|
|
461
|
-
middlewareData
|
|
462
|
-
} = state;
|
|
463
|
-
const diffCoords = await convertValueToCoords(state, options);
|
|
464
|
-
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
465
|
-
return {};
|
|
466
|
-
}
|
|
467
|
-
return {
|
|
468
|
-
x: x + diffCoords.x,
|
|
469
|
-
y: y + diffCoords.y,
|
|
470
|
-
data: {
|
|
471
|
-
...diffCoords,
|
|
472
|
-
placement
|
|
473
|
-
}
|
|
474
|
-
};
|
|
475
|
-
}
|
|
67
|
+
top: 0,
|
|
68
|
+
right: 0,
|
|
69
|
+
bottom: 0,
|
|
70
|
+
left: 0,
|
|
71
|
+
...padding
|
|
476
72
|
};
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
73
|
+
}
|
|
74
|
+
function getPaddingObject(padding) {
|
|
75
|
+
return typeof padding !== "number" ? expandPaddingObject(padding) : {
|
|
76
|
+
top: padding,
|
|
77
|
+
right: padding,
|
|
78
|
+
bottom: padding,
|
|
79
|
+
left: padding
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function rectToClientRect(rect) {
|
|
83
|
+
const {
|
|
84
|
+
x,
|
|
85
|
+
y,
|
|
86
|
+
width,
|
|
87
|
+
height
|
|
88
|
+
} = rect;
|
|
482
89
|
return {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
const {
|
|
492
|
-
mainAxis: checkMainAxis = true,
|
|
493
|
-
crossAxis: checkCrossAxis = false,
|
|
494
|
-
limiter = {
|
|
495
|
-
fn: (_ref) => {
|
|
496
|
-
let {
|
|
497
|
-
x: x2,
|
|
498
|
-
y: y2
|
|
499
|
-
} = _ref;
|
|
500
|
-
return {
|
|
501
|
-
x: x2,
|
|
502
|
-
y: y2
|
|
503
|
-
};
|
|
504
|
-
}
|
|
505
|
-
},
|
|
506
|
-
...detectOverflowOptions
|
|
507
|
-
} = evaluate(options, state);
|
|
508
|
-
const coords = {
|
|
509
|
-
x,
|
|
510
|
-
y
|
|
511
|
-
};
|
|
512
|
-
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
513
|
-
const crossAxis = getSideAxis(getSide(placement));
|
|
514
|
-
const mainAxis = getOppositeAxis(crossAxis);
|
|
515
|
-
let mainAxisCoord = coords[mainAxis];
|
|
516
|
-
let crossAxisCoord = coords[crossAxis];
|
|
517
|
-
if (checkMainAxis) {
|
|
518
|
-
const minSide = mainAxis === "y" ? "top" : "left";
|
|
519
|
-
const maxSide = mainAxis === "y" ? "bottom" : "right";
|
|
520
|
-
const min2 = mainAxisCoord + overflow[minSide];
|
|
521
|
-
const max2 = mainAxisCoord - overflow[maxSide];
|
|
522
|
-
mainAxisCoord = clamp(min2, mainAxisCoord, max2);
|
|
523
|
-
}
|
|
524
|
-
if (checkCrossAxis) {
|
|
525
|
-
const minSide = crossAxis === "y" ? "top" : "left";
|
|
526
|
-
const maxSide = crossAxis === "y" ? "bottom" : "right";
|
|
527
|
-
const min2 = crossAxisCoord + overflow[minSide];
|
|
528
|
-
const max2 = crossAxisCoord - overflow[maxSide];
|
|
529
|
-
crossAxisCoord = clamp(min2, crossAxisCoord, max2);
|
|
530
|
-
}
|
|
531
|
-
const limitedCoords = limiter.fn({
|
|
532
|
-
...state,
|
|
533
|
-
[mainAxis]: mainAxisCoord,
|
|
534
|
-
[crossAxis]: crossAxisCoord
|
|
535
|
-
});
|
|
536
|
-
return {
|
|
537
|
-
...limitedCoords,
|
|
538
|
-
data: {
|
|
539
|
-
x: limitedCoords.x - x,
|
|
540
|
-
y: limitedCoords.y - y
|
|
541
|
-
}
|
|
542
|
-
};
|
|
543
|
-
}
|
|
90
|
+
width,
|
|
91
|
+
height,
|
|
92
|
+
top: y,
|
|
93
|
+
left: x,
|
|
94
|
+
right: x + width,
|
|
95
|
+
bottom: y + height,
|
|
96
|
+
x,
|
|
97
|
+
y
|
|
544
98
|
};
|
|
545
|
-
}
|
|
99
|
+
}
|
|
546
100
|
export {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
101
|
+
alignments,
|
|
102
|
+
clamp,
|
|
103
|
+
createCoords,
|
|
104
|
+
evaluate,
|
|
105
|
+
expandPaddingObject,
|
|
106
|
+
floor,
|
|
107
|
+
getAlignment,
|
|
108
|
+
getAlignmentAxis,
|
|
109
|
+
getAlignmentSides,
|
|
110
|
+
getAxisLength,
|
|
111
|
+
getOppositeAlignmentPlacement,
|
|
112
|
+
getOppositeAxis,
|
|
113
|
+
getOppositePlacement,
|
|
114
|
+
getPaddingObject,
|
|
115
|
+
getSide,
|
|
116
|
+
getSideAxis,
|
|
117
|
+
max,
|
|
118
|
+
min,
|
|
119
|
+
placements,
|
|
552
120
|
rectToClientRect,
|
|
553
|
-
|
|
121
|
+
round,
|
|
122
|
+
sides
|
|
554
123
|
};
|
|
555
124
|
//# sourceMappingURL=react-text-annotator.es24.js.map
|