@soomo/react-text-annotator 3.0.0-staging.8 → 3.0.0-staging.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/TextAnnotatorPopup.d.ts +5 -4
  2. package/dist/TextAnnotatorPopup.d.ts.map +1 -1
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/react-text-annotator.es10.js +565 -34
  6. package/dist/react-text-annotator.es10.js.map +1 -1
  7. package/dist/react-text-annotator.es11.js +460 -856
  8. package/dist/react-text-annotator.es11.js.map +1 -1
  9. package/dist/react-text-annotator.es12.js +2 -2
  10. package/dist/react-text-annotator.es13.js +35 -2
  11. package/dist/react-text-annotator.es13.js.map +1 -1
  12. package/dist/react-text-annotator.es14.js +894 -109
  13. package/dist/react-text-annotator.es14.js.map +1 -1
  14. package/dist/react-text-annotator.es15.js +208 -289
  15. package/dist/react-text-annotator.es15.js.map +1 -1
  16. package/dist/react-text-annotator.es16.js +127 -49
  17. package/dist/react-text-annotator.es16.js.map +1 -1
  18. package/dist/react-text-annotator.es17.js +113 -19
  19. package/dist/react-text-annotator.es17.js.map +1 -1
  20. package/dist/react-text-annotator.es18.js +312 -0
  21. package/dist/react-text-annotator.es18.js.map +1 -0
  22. package/dist/react-text-annotator.es19.js +61 -0
  23. package/dist/react-text-annotator.es19.js.map +1 -0
  24. package/dist/react-text-annotator.es2.js +1 -1
  25. package/dist/react-text-annotator.es20.js +23 -0
  26. package/dist/react-text-annotator.es20.js.map +1 -0
  27. package/dist/react-text-annotator.es21.js +5 -0
  28. package/dist/react-text-annotator.es21.js.map +1 -0
  29. package/dist/react-text-annotator.es22.js +5 -0
  30. package/dist/react-text-annotator.es22.js.map +1 -0
  31. package/dist/react-text-annotator.es23.js +124 -0
  32. package/dist/react-text-annotator.es23.js.map +1 -0
  33. package/dist/react-text-annotator.es24.js +555 -0
  34. package/dist/react-text-annotator.es24.js.map +1 -0
  35. package/dist/react-text-annotator.es5.js +60 -36
  36. package/dist/react-text-annotator.es5.js.map +1 -1
  37. package/dist/react-text-annotator.es6.js +3 -3
  38. package/dist/react-text-annotator.es8.js +24 -488
  39. package/dist/react-text-annotator.es8.js.map +1 -1
  40. package/dist/react-text-annotator.es9.js +196 -2
  41. package/dist/react-text-annotator.es9.js.map +1 -1
  42. package/dist/utils.d.ts +14 -0
  43. package/dist/utils.d.ts.map +1 -0
  44. package/package.json +4 -3
@@ -1,14 +1,15 @@
1
1
  import { TextAnnotation } from '@soomo/text-annotator';
2
2
  import { ReactNode } from 'react';
3
3
 
4
+ interface TextAnnotationPopupProps {
5
+ popup(props: TextAnnotatorPopupProps): ReactNode;
6
+ }
4
7
  export interface TextAnnotatorPopupProps {
5
8
  selected: {
6
9
  annotation: TextAnnotation;
7
10
  editable?: boolean;
8
11
  }[];
9
12
  }
10
- export interface TextAnnotatorPopupContainerProps {
11
- popup(props: TextAnnotatorPopupProps): ReactNode | JSX.Element;
12
- }
13
- export declare const TextAnnotatorPopup: (props: TextAnnotatorPopupContainerProps) => import('react').ReactPortal;
13
+ export declare const TextAnnotatorPopup: (props: TextAnnotationPopupProps) => import("react/jsx-runtime").JSX.Element;
14
+ export {};
14
15
  //# sourceMappingURL=TextAnnotatorPopup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TextAnnotatorPopup.d.ts","sourceRoot":"","sources":["../src/TextAnnotatorPopup.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAA+B,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAiB,cAAc,EAAsB,MAAM,uBAAuB,CAAC;AAG1F,MAAM,WAAW,uBAAuB;IAEtC,QAAQ,EAAE;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;CAEhE;AAED,MAAM,WAAW,gCAAgC;IAE/C,KAAK,CAAC,KAAK,EAAE,uBAAuB,GAAG,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC;CAEhE;AAED,eAAO,MAAM,kBAAkB,UAAW,gCAAgC,gCA0DzE,CAAA"}
1
+ {"version":3,"file":"TextAnnotatorPopup.d.ts","sourceRoot":"","sources":["../src/TextAnnotatorPopup.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAW1E,UAAU,wBAAwB;IAEhC,KAAK,CAAC,KAAK,EAAE,uBAAuB,GAAG,SAAS,CAAC;CAElD;AAED,MAAM,WAAW,uBAAuB;IAEtC,QAAQ,EAAE;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;CAEhE;AAED,eAAO,MAAM,kBAAkB,UAAW,wBAAwB,4CAsFjE,CAAA"}
package/dist/index.d.ts CHANGED
@@ -5,5 +5,5 @@ export * from './TextAnnotatorPlugin';
5
5
  export type { Annotation, AnnotationBody, AnnotationTarget, Annotator, AnnotatorState, Color, Filter, FormatAdapter, HoverState, Selection, SelectionState, Store, StoreChangeEvent, StoreObserver, ParseResult, User, W3CAnnotation, W3CAnnotationBody, W3CAnnotationTarget } from '@annotorious/core';
6
6
  export { createBody, Origin, PointerSelectAction } from '@annotorious/core';
7
7
  export { AnnotoriousPlugin } from '@annotorious/react';
8
- export type { TextAnnotation, TextAnnotationTarget, TextSelector, W3CTextAnnotation, W3CTextAnnotationTarget, W3CTextSelector, W3CAnnotationStylesheet, HighlightStyle, TextAnnotator as RecogitoTextAnnotator, TextAnnotationStore } from '@soomo/text-annotator';
8
+ export type { HighlightStyle, HighlightStyleExpression, TextAnnotation, TextAnnotationTarget, TextSelector, W3CTextAnnotation, W3CTextAnnotationTarget, W3CTextSelector, W3CAnnotationStylesheet, TextAnnotator as RecogitoTextAnnotator, TextAnnotationStore } from '@soomo/text-annotator';
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AAGtC,YAAY,EACV,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,cAAc,EACd,KAAK,EACL,MAAM,EACN,aAAa,EACb,UAAU,EACV,SAAS,EACT,cAAc,EACd,KAAK,EACL,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,IAAI,EACJ,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,UAAU,EACV,MAAM,EACN,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACN,iBAAiB,EACjB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,EACvB,eAAe,EACf,uBAAuB,EACvB,cAAc,EACd,aAAa,IAAI,qBAAqB,EACtC,mBAAmB,EACpB,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AAGtC,YAAY,EACV,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,cAAc,EACd,KAAK,EACL,MAAM,EACN,aAAa,EACb,UAAU,EACV,SAAS,EACT,cAAc,EACd,KAAK,EACL,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,IAAI,EACJ,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,UAAU,EACV,MAAM,EACN,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACN,iBAAiB,EACjB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,cAAc,EACd,wBAAwB,EACxB,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,EACvB,eAAe,EACf,uBAAuB,EACvB,aAAa,IAAI,qBAAqB,EACtC,mBAAmB,EACpB,MAAM,uBAAuB,CAAC"}
@@ -1,38 +1,569 @@
1
- import { __exports as reactJsxRuntime_production_min } from "./react-text-annotator.es12.js";
2
- import require$$0 from "react";
3
- /**
4
- * @license React
5
- * react-jsx-runtime.production.min.js
6
- *
7
- * Copyright (c) Facebook, Inc. and its affiliates.
8
- *
9
- * This source code is licensed under the MIT license found in the
10
- * LICENSE file in the root directory of this source tree.
11
- */
12
- var hasRequiredReactJsxRuntime_production_min;
13
- function requireReactJsxRuntime_production_min() {
14
- if (hasRequiredReactJsxRuntime_production_min)
15
- return reactJsxRuntime_production_min;
16
- hasRequiredReactJsxRuntime_production_min = 1;
17
- var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
18
- function q(c, a, g) {
19
- var b, d = {}, e = null, h = null;
20
- void 0 !== g && (e = "" + g);
21
- void 0 !== a.key && (e = "" + a.key);
22
- void 0 !== a.ref && (h = a.ref);
23
- for (b in a)
24
- m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
25
- if (c && c.defaultProps)
26
- for (b in a = c.defaultProps, a)
27
- void 0 === d[b] && (d[b] = a[b]);
28
- return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
29
- }
30
- reactJsxRuntime_production_min.Fragment = l;
31
- reactJsxRuntime_production_min.jsx = q;
32
- reactJsxRuntime_production_min.jsxs = q;
33
- return reactJsxRuntime_production_min;
1
+ import { offset as offset$1, autoPlacement as autoPlacement$1, shift as shift$1, inline as inline$1, computePosition as computePosition$1 } from "./react-text-annotator.es24.js";
2
+ import { createCoords, rectToClientRect, round, floor, max, min } from "./react-text-annotator.es23.js";
3
+ import { getOverflowAncestors, isElement, getWindow, getComputedStyle, getDocumentElement, isHTMLElement, isWebKit, getNodeName, isOverflowElement, getNodeScroll, isTableElement, isContainingBlock, getContainingBlock, getParentNode, isLastTraversableNode } from "./react-text-annotator.es16.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)) {
65
+ return false;
66
+ }
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);
83
+ }
84
+ } else {
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;
112
+ }
113
+ }
114
+ return rectToClientRect({
115
+ width,
116
+ height,
117
+ x,
118
+ y
119
+ });
120
+ }
121
+ const topLayerSelectors = [":popover-open", ":modal"];
122
+ function isTopLayer(floating) {
123
+ return topLayerSelectors.some((selector) => {
124
+ try {
125
+ return floating.matches(selector);
126
+ } catch (e) {
127
+ return false;
128
+ }
129
+ });
130
+ }
131
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
132
+ let {
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);
34
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" ? 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);
339
+ }
340
+ }
341
+ const x = rect.left + scroll.scrollLeft - offsets.x;
342
+ const y = rect.top + scroll.scrollTop - offsets.y;
343
+ return {
344
+ x,
345
+ y,
346
+ width: rect.width,
347
+ height: rect.height
348
+ };
349
+ }
350
+ function getTrueOffsetParent(element, polyfill) {
351
+ if (!isHTMLElement(element) || getComputedStyle(element).position === "fixed") {
352
+ return null;
353
+ }
354
+ if (polyfill) {
355
+ return polyfill(element);
356
+ }
357
+ return element.offsetParent;
358
+ }
359
+ function getOffsetParent(element, polyfill) {
360
+ const window = getWindow(element);
361
+ if (!isHTMLElement(element) || isTopLayer(element)) {
362
+ return window;
363
+ }
364
+ let offsetParent = getTrueOffsetParent(element, polyfill);
365
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
366
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
367
+ }
368
+ if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static" && !isContainingBlock(offsetParent))) {
369
+ return window;
370
+ }
371
+ return offsetParent || getContainingBlock(element) || window;
372
+ }
373
+ const getElementRects = async function(data) {
374
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
375
+ const getDimensionsFn = this.getDimensions;
376
+ const floatingDimensions = await getDimensionsFn(data.floating);
377
+ return {
378
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
379
+ floating: {
380
+ x: 0,
381
+ y: 0,
382
+ width: floatingDimensions.width,
383
+ height: floatingDimensions.height
384
+ }
385
+ };
386
+ };
387
+ function isRTL(element) {
388
+ return getComputedStyle(element).direction === "rtl";
389
+ }
390
+ const platform = {
391
+ convertOffsetParentRelativeRectToViewportRelativeRect,
392
+ getDocumentElement,
393
+ getClippingRect,
394
+ getOffsetParent,
395
+ getElementRects,
396
+ getClientRects,
397
+ getDimensions,
398
+ getScale,
399
+ isElement,
400
+ isRTL
401
+ };
402
+ function observeMove(element, onMove) {
403
+ let io = null;
404
+ let timeoutId;
405
+ const root = getDocumentElement(element);
406
+ function cleanup() {
407
+ var _io;
408
+ clearTimeout(timeoutId);
409
+ (_io = io) == null || _io.disconnect();
410
+ io = null;
411
+ }
412
+ function refresh(skip, threshold) {
413
+ if (skip === void 0) {
414
+ skip = false;
415
+ }
416
+ if (threshold === void 0) {
417
+ threshold = 1;
418
+ }
419
+ cleanup();
420
+ const {
421
+ left,
422
+ top,
423
+ width,
424
+ height
425
+ } = element.getBoundingClientRect();
426
+ if (!skip) {
427
+ onMove();
428
+ }
429
+ if (!width || !height) {
430
+ return;
431
+ }
432
+ const insetTop = floor(top);
433
+ const insetRight = floor(root.clientWidth - (left + width));
434
+ const insetBottom = floor(root.clientHeight - (top + height));
435
+ const insetLeft = floor(left);
436
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
437
+ const options = {
438
+ rootMargin,
439
+ threshold: max(0, min(1, threshold)) || 1
440
+ };
441
+ let isFirstUpdate = true;
442
+ function handleObserve(entries) {
443
+ const ratio = entries[0].intersectionRatio;
444
+ if (ratio !== threshold) {
445
+ if (!isFirstUpdate) {
446
+ return refresh();
447
+ }
448
+ if (!ratio) {
449
+ timeoutId = setTimeout(() => {
450
+ refresh(false, 1e-7);
451
+ }, 1e3);
452
+ } else {
453
+ refresh(false, ratio);
454
+ }
455
+ }
456
+ isFirstUpdate = false;
457
+ }
458
+ try {
459
+ io = new IntersectionObserver(handleObserve, {
460
+ ...options,
461
+ // Handle <iframe>s
462
+ root: root.ownerDocument
463
+ });
464
+ } catch (e) {
465
+ io = new IntersectionObserver(handleObserve, options);
466
+ }
467
+ io.observe(element);
468
+ }
469
+ refresh(true);
470
+ return cleanup;
471
+ }
472
+ function autoUpdate(reference, floating, update, options) {
473
+ if (options === void 0) {
474
+ options = {};
475
+ }
476
+ const {
477
+ ancestorScroll = true,
478
+ ancestorResize = true,
479
+ elementResize = typeof ResizeObserver === "function",
480
+ layoutShift = typeof IntersectionObserver === "function",
481
+ animationFrame = false
482
+ } = options;
483
+ const referenceEl = unwrapElement(reference);
484
+ const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
485
+ ancestors.forEach((ancestor) => {
486
+ ancestorScroll && ancestor.addEventListener("scroll", update, {
487
+ passive: true
488
+ });
489
+ ancestorResize && ancestor.addEventListener("resize", update);
490
+ });
491
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
492
+ let reobserveFrame = -1;
493
+ let resizeObserver = null;
494
+ if (elementResize) {
495
+ resizeObserver = new ResizeObserver((_ref) => {
496
+ let [firstEntry] = _ref;
497
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
498
+ resizeObserver.unobserve(floating);
499
+ cancelAnimationFrame(reobserveFrame);
500
+ reobserveFrame = requestAnimationFrame(() => {
501
+ var _resizeObserver;
502
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
503
+ });
504
+ }
505
+ update();
506
+ });
507
+ if (referenceEl && !animationFrame) {
508
+ resizeObserver.observe(referenceEl);
509
+ }
510
+ resizeObserver.observe(floating);
511
+ }
512
+ let frameId;
513
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
514
+ if (animationFrame) {
515
+ frameLoop();
516
+ }
517
+ function frameLoop() {
518
+ const nextRefRect = getBoundingClientRect(reference);
519
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
520
+ update();
521
+ }
522
+ prevRefRect = nextRefRect;
523
+ frameId = requestAnimationFrame(frameLoop);
524
+ }
525
+ update();
526
+ return () => {
527
+ var _resizeObserver2;
528
+ ancestors.forEach((ancestor) => {
529
+ ancestorScroll && ancestor.removeEventListener("scroll", update);
530
+ ancestorResize && ancestor.removeEventListener("resize", update);
531
+ });
532
+ cleanupIo == null || cleanupIo();
533
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
534
+ resizeObserver = null;
535
+ if (animationFrame) {
536
+ cancelAnimationFrame(frameId);
537
+ }
538
+ };
539
+ }
540
+ const offset = offset$1;
541
+ const autoPlacement = autoPlacement$1;
542
+ const shift = shift$1;
543
+ const inline = inline$1;
544
+ const computePosition = (reference, floating, options) => {
545
+ const cache = /* @__PURE__ */ new Map();
546
+ const mergedOptions = {
547
+ platform,
548
+ ...options
549
+ };
550
+ const platformWithCache = {
551
+ ...mergedOptions.platform,
552
+ _c: cache
553
+ };
554
+ return computePosition$1(reference, floating, {
555
+ ...mergedOptions,
556
+ platform: platformWithCache
557
+ });
558
+ };
35
559
  export {
36
- requireReactJsxRuntime_production_min as __require
560
+ autoPlacement,
561
+ autoUpdate,
562
+ computePosition,
563
+ getOverflowAncestors,
564
+ inline,
565
+ offset,
566
+ platform,
567
+ shift
37
568
  };
38
569
  //# sourceMappingURL=react-text-annotator.es10.js.map