@soomo/react-text-annotator 3.0.0-staging.2 → 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/TextAnnotator.d.ts +3 -3
- package/dist/TextAnnotator.d.ts.map +1 -1
- package/dist/TextAnnotatorPlugin.d.ts +1 -2
- package/dist/TextAnnotatorPlugin.d.ts.map +1 -1
- package/dist/TextAnnotatorPopup.d.ts +6 -5
- package/dist/TextAnnotatorPopup.d.ts.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/react-text-annotator.es.js +8 -2
- package/dist/react-text-annotator.es.js.map +1 -1
- package/dist/react-text-annotator.es10.js +230 -33
- package/dist/react-text-annotator.es10.js.map +1 -1
- package/dist/react-text-annotator.es11.js +236 -881
- package/dist/react-text-annotator.es11.js.map +1 -1
- package/dist/react-text-annotator.es12.js +579 -2
- 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 -114
- package/dist/react-text-annotator.es14.js.map +1 -1
- package/dist/react-text-annotator.es15.js +34 -308
- package/dist/react-text-annotator.es15.js.map +1 -1
- package/dist/react-text-annotator.es16.js +895 -54
- package/dist/react-text-annotator.es16.js.map +1 -1
- package/dist/react-text-annotator.es17.js +131 -15
- package/dist/react-text-annotator.es17.js.map +1 -1
- package/dist/react-text-annotator.es18.js +5 -0
- package/dist/react-text-annotator.es18.js.map +1 -0
- package/dist/react-text-annotator.es19.js +5 -0
- package/dist/react-text-annotator.es19.js.map +1 -0
- package/dist/react-text-annotator.es2.js +2 -2
- package/dist/react-text-annotator.es20.js +117 -0
- package/dist/react-text-annotator.es20.js.map +1 -0
- package/dist/react-text-annotator.es21.js +312 -0
- package/dist/react-text-annotator.es21.js.map +1 -0
- package/dist/react-text-annotator.es22.js +61 -0
- package/dist/react-text-annotator.es22.js.map +1 -0
- package/dist/react-text-annotator.es23.js +23 -0
- package/dist/react-text-annotator.es23.js.map +1 -0
- package/dist/react-text-annotator.es24.js +124 -0
- package/dist/react-text-annotator.es24.js.map +1 -0
- 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 +6 -12
- package/dist/react-text-annotator.es4.js.map +1 -1
- package/dist/react-text-annotator.es5.js +62 -37
- package/dist/react-text-annotator.es5.js.map +1 -1
- 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 +24 -2
- package/dist/react-text-annotator.es9.js.map +1 -1
- package/dist/tei/TEIAnnotator.d.ts +2 -2
- package/dist/utils.d.ts +14 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +20 -14
- package/dist/react-text-annotator.es8.js +0 -491
- package/dist/react-text-annotator.es8.js.map +0 -1
package/dist/TextAnnotator.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HighlightStyleExpression, TextAnnotation, TextAnnotatorOptions } from '@soomo/text-annotator';
|
|
2
|
-
import { FormatAdapter } from '@annotorious/core';
|
|
3
|
-
import { Filter } from '@annotorious/react';
|
|
4
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { Filter } from '@annotorious/react';
|
|
3
|
+
import { FormatAdapter } from '@annotorious/core';
|
|
4
|
+
import { HighlightStyleExpression, TextAnnotation, TextAnnotatorOptions } from '@soomo/text-annotator';
|
|
5
5
|
|
|
6
6
|
export interface TextAnnotatorProps<E extends unknown> extends Omit<TextAnnotatorOptions<E>, 'adapter'> {
|
|
7
7
|
children?: ReactNode | JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextAnnotator.d.ts","sourceRoot":"","sources":["../src/TextAnnotator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiC,MAAM,OAAO,CAAC;AACjE,OAAO,EAAsB,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,wBAAwB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAG5G,OAAO,+CAA+C,CAAC;AAGvD,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,OAAO,CAAE,SAAQ,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC;IAErG,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC;IAEnC,OAAO,CAAC,EAAE,aAAa,CAAC,cAAc,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,WAAW,KAAK,aAAa,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAEnH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,KAAK,CAAC,EAAE,wBAAwB,CAAC;IAEjC,SAAS,CAAC,EAAE,MAAM,CAAC;CAEpB;AAED,eAAO,MAAM,aAAa,6BAA8B,mBAAmB,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"TextAnnotator.d.ts","sourceRoot":"","sources":["../src/TextAnnotator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiC,MAAM,OAAO,CAAC;AACjE,OAAO,EAAsB,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,wBAAwB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAG5G,OAAO,+CAA+C,CAAC;AAGvD,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,OAAO,CAAE,SAAQ,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC;IAErG,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC;IAEnC,OAAO,CAAC,EAAE,aAAa,CAAC,cAAc,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,WAAW,KAAK,aAAa,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAEnH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,KAAK,CAAC,EAAE,wBAAwB,CAAC;IAEjC,SAAS,CAAC,EAAE,MAAM,CAAC;CAEpB;AAED,eAAO,MAAM,aAAa,6BAA8B,mBAAmB,CAAC,CAAC,4CAgC5E,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
+
import { AnnotatorPlugin } from '@annotorious/react';
|
|
1
2
|
import { TextAnnotator } from '@soomo/text-annotator';
|
|
2
|
-
import { AnnotatorPlugin, AnnotoriousPlugin } from '@annotorious/react';
|
|
3
3
|
|
|
4
4
|
export type TextAnnotatorPlugin<T extends unknown = TextAnnotator> = AnnotatorPlugin<T>;
|
|
5
|
-
export { AnnotoriousPlugin as TextAnnotatorPlugin };
|
|
6
5
|
//# sourceMappingURL=TextAnnotatorPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextAnnotatorPlugin.d.ts","sourceRoot":"","sources":["../src/TextAnnotatorPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"TextAnnotatorPlugin.d.ts","sourceRoot":"","sources":["../src/TextAnnotatorPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,OAAO,GAAG,aAAa,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { TextAnnotation } from '@soomo/text-annotator';
|
|
2
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { TextAnnotation } from '@soomo/text-annotator';
|
|
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
|
|
11
|
-
|
|
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":"
|
|
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
|
@@ -2,6 +2,9 @@ export * from './tei';
|
|
|
2
2
|
export * from './TextAnnotator';
|
|
3
3
|
export * from './TextAnnotatorPopup';
|
|
4
4
|
export * from './TextAnnotatorPlugin';
|
|
5
|
-
export type {
|
|
6
|
-
export
|
|
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
|
+
export { createBody, Origin, PointerSelectAction } from '@annotorious/core';
|
|
7
|
+
export { AnnotoriousPlugin } from '@annotorious/react';
|
|
8
|
+
export type { HighlightStyle, HighlightStyleExpression, TextAnnotation, TextAnnotationTarget, TextSelector, W3CTextAnnotation, W3CTextAnnotationTarget, W3CTextSelector, W3CAnnotationStylesheet, TextAnnotator as RecogitoTextAnnotator, TextAnnotationStore } from '@soomo/text-annotator';
|
|
9
|
+
export { W3CTextFormat } from '@recogito/text-annotator';
|
|
7
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,iBAAiB,
|
|
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;AAE/B,OAAO,EACL,aAAa,EACd,MAAM,0BAA0B,CAAC"}
|
|
@@ -2,12 +2,18 @@ import { CETEIcean } from "./react-text-annotator.es2.js";
|
|
|
2
2
|
import { TEIAnnotator } from "./react-text-annotator.es3.js";
|
|
3
3
|
import { TextAnnotator } from "./react-text-annotator.es4.js";
|
|
4
4
|
import { TextAnnotatorPopup } from "./react-text-annotator.es5.js";
|
|
5
|
+
import { Origin, PointerSelectAction, createBody } from "@annotorious/core";
|
|
5
6
|
import { AnnotoriousPlugin } from "@annotorious/react";
|
|
7
|
+
import { W3CTextFormat } from "./react-text-annotator.es6.js";
|
|
6
8
|
export {
|
|
9
|
+
AnnotoriousPlugin,
|
|
7
10
|
CETEIcean,
|
|
11
|
+
Origin,
|
|
12
|
+
PointerSelectAction,
|
|
8
13
|
TEIAnnotator,
|
|
9
14
|
TextAnnotator,
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
TextAnnotatorPopup,
|
|
16
|
+
W3CTextFormat,
|
|
17
|
+
createBody
|
|
12
18
|
};
|
|
13
19
|
//# sourceMappingURL=react-text-annotator.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-text-annotator.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"react-text-annotator.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
@@ -1,38 +1,235 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
for (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useLayoutEffect, useEffect } from "react";
|
|
3
|
+
import { useFloating as useFloating$1 } from "./react-text-annotator.es11.js";
|
|
4
|
+
import { autoPlacement, inline, offset, shift } from "./react-text-annotator.es11.js";
|
|
5
|
+
import { isElement } from "./react-text-annotator.es17.js";
|
|
6
|
+
import { getOverflowAncestors } from "./react-text-annotator.es17.js";
|
|
7
|
+
import "react-dom";
|
|
8
|
+
const SafeReact = {
|
|
9
|
+
...React
|
|
10
|
+
};
|
|
11
|
+
const useInsertionEffect = SafeReact.useInsertionEffect;
|
|
12
|
+
const useSafeInsertionEffect = useInsertionEffect || ((fn) => fn());
|
|
13
|
+
function useEffectEvent(callback) {
|
|
14
|
+
const ref = React.useRef(() => {
|
|
15
|
+
if (process.env.NODE_ENV !== "production") {
|
|
16
|
+
throw new Error("Cannot call an event handler while rendering.");
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
useSafeInsertionEffect(() => {
|
|
20
|
+
ref.current = callback;
|
|
21
|
+
});
|
|
22
|
+
return React.useCallback(function() {
|
|
23
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
24
|
+
args[_key] = arguments[_key];
|
|
25
|
+
}
|
|
26
|
+
return ref.current == null ? void 0 : ref.current(...args);
|
|
27
|
+
}, []);
|
|
28
|
+
}
|
|
29
|
+
var index = typeof document !== "undefined" ? useLayoutEffect : useEffect;
|
|
30
|
+
let serverHandoffComplete = false;
|
|
31
|
+
let count = 0;
|
|
32
|
+
const genId = () => (
|
|
33
|
+
// Ensure the id is unique with multiple independent versions of Floating UI
|
|
34
|
+
// on <React 18
|
|
35
|
+
"floating-ui-" + Math.random().toString(36).slice(2, 6) + count++
|
|
36
|
+
);
|
|
37
|
+
function useFloatingId() {
|
|
38
|
+
const [id, setId] = React.useState(() => serverHandoffComplete ? genId() : void 0);
|
|
39
|
+
index(() => {
|
|
40
|
+
if (id == null) {
|
|
41
|
+
setId(genId());
|
|
42
|
+
}
|
|
43
|
+
}, []);
|
|
44
|
+
React.useEffect(() => {
|
|
45
|
+
serverHandoffComplete = true;
|
|
46
|
+
}, []);
|
|
47
|
+
return id;
|
|
48
|
+
}
|
|
49
|
+
const useReactId = SafeReact.useId;
|
|
50
|
+
const useId = useReactId || useFloatingId;
|
|
51
|
+
let devMessageSet;
|
|
52
|
+
if (process.env.NODE_ENV !== "production") {
|
|
53
|
+
devMessageSet = /* @__PURE__ */ new Set();
|
|
54
|
+
}
|
|
55
|
+
function error() {
|
|
56
|
+
var _devMessageSet3;
|
|
57
|
+
for (var _len2 = arguments.length, messages = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
58
|
+
messages[_key2] = arguments[_key2];
|
|
59
|
+
}
|
|
60
|
+
const message = "Floating UI: " + messages.join(" ");
|
|
61
|
+
if (!((_devMessageSet3 = devMessageSet) != null && _devMessageSet3.has(message))) {
|
|
62
|
+
var _devMessageSet4;
|
|
63
|
+
(_devMessageSet4 = devMessageSet) == null || _devMessageSet4.add(message);
|
|
64
|
+
console.error(message);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function createPubSub() {
|
|
68
|
+
const map = /* @__PURE__ */ new Map();
|
|
69
|
+
return {
|
|
70
|
+
emit(event, data) {
|
|
71
|
+
var _map$get;
|
|
72
|
+
(_map$get = map.get(event)) == null || _map$get.forEach((handler) => handler(data));
|
|
73
|
+
},
|
|
74
|
+
on(event, listener) {
|
|
75
|
+
map.set(event, [...map.get(event) || [], listener]);
|
|
76
|
+
},
|
|
77
|
+
off(event, listener) {
|
|
78
|
+
var _map$get2;
|
|
79
|
+
map.set(event, ((_map$get2 = map.get(event)) == null ? void 0 : _map$get2.filter((l) => l !== listener)) || []);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const FloatingNodeContext = /* @__PURE__ */ React.createContext(null);
|
|
84
|
+
const FloatingTreeContext = /* @__PURE__ */ React.createContext(null);
|
|
85
|
+
const useFloatingParentNodeId = () => {
|
|
86
|
+
var _React$useContext;
|
|
87
|
+
return ((_React$useContext = React.useContext(FloatingNodeContext)) == null ? void 0 : _React$useContext.id) || null;
|
|
88
|
+
};
|
|
89
|
+
const useFloatingTree = () => React.useContext(FloatingTreeContext);
|
|
90
|
+
function useFloatingRootContext(options) {
|
|
91
|
+
const {
|
|
92
|
+
open = false,
|
|
93
|
+
onOpenChange: onOpenChangeProp,
|
|
94
|
+
elements: elementsProp
|
|
95
|
+
} = options;
|
|
96
|
+
const floatingId = useId();
|
|
97
|
+
const dataRef = React.useRef({});
|
|
98
|
+
const [events] = React.useState(() => createPubSub());
|
|
99
|
+
const nested = useFloatingParentNodeId() != null;
|
|
100
|
+
if (process.env.NODE_ENV !== "production") {
|
|
101
|
+
const optionDomReference = elementsProp.reference;
|
|
102
|
+
if (optionDomReference && !isElement(optionDomReference)) {
|
|
103
|
+
error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const [positionReference, setPositionReference] = React.useState(elementsProp.reference);
|
|
107
|
+
const onOpenChange = useEffectEvent((open2, event, reason) => {
|
|
108
|
+
dataRef.current.openEvent = open2 ? event : void 0;
|
|
109
|
+
events.emit("openchange", {
|
|
110
|
+
open: open2,
|
|
111
|
+
event,
|
|
112
|
+
reason,
|
|
113
|
+
nested
|
|
114
|
+
});
|
|
115
|
+
onOpenChangeProp == null || onOpenChangeProp(open2, event, reason);
|
|
116
|
+
});
|
|
117
|
+
const refs = React.useMemo(() => ({
|
|
118
|
+
setPositionReference
|
|
119
|
+
}), []);
|
|
120
|
+
const elements = React.useMemo(() => ({
|
|
121
|
+
reference: positionReference || elementsProp.reference || null,
|
|
122
|
+
floating: elementsProp.floating || null,
|
|
123
|
+
domReference: elementsProp.reference
|
|
124
|
+
}), [positionReference, elementsProp.reference, elementsProp.floating]);
|
|
125
|
+
return React.useMemo(() => ({
|
|
126
|
+
dataRef,
|
|
127
|
+
open,
|
|
128
|
+
onOpenChange,
|
|
129
|
+
elements,
|
|
130
|
+
events,
|
|
131
|
+
floatingId,
|
|
132
|
+
refs
|
|
133
|
+
}), [open, onOpenChange, elements, events, floatingId, refs]);
|
|
134
|
+
}
|
|
135
|
+
function useFloating(options) {
|
|
136
|
+
if (options === void 0) {
|
|
137
|
+
options = {};
|
|
29
138
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
139
|
+
const {
|
|
140
|
+
nodeId
|
|
141
|
+
} = options;
|
|
142
|
+
const internalRootContext = useFloatingRootContext({
|
|
143
|
+
...options,
|
|
144
|
+
elements: {
|
|
145
|
+
reference: null,
|
|
146
|
+
floating: null,
|
|
147
|
+
...options.elements
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
const rootContext = options.rootContext || internalRootContext;
|
|
151
|
+
const computedElements = rootContext.elements;
|
|
152
|
+
const [_domReference, setDomReference] = React.useState(null);
|
|
153
|
+
const [positionReference, _setPositionReference] = React.useState(null);
|
|
154
|
+
const optionDomReference = computedElements == null ? void 0 : computedElements.reference;
|
|
155
|
+
const domReference = optionDomReference || _domReference;
|
|
156
|
+
const domReferenceRef = React.useRef(null);
|
|
157
|
+
const tree = useFloatingTree();
|
|
158
|
+
index(() => {
|
|
159
|
+
if (domReference) {
|
|
160
|
+
domReferenceRef.current = domReference;
|
|
161
|
+
}
|
|
162
|
+
}, [domReference]);
|
|
163
|
+
const position = useFloating$1({
|
|
164
|
+
...options,
|
|
165
|
+
elements: {
|
|
166
|
+
...computedElements,
|
|
167
|
+
...positionReference && {
|
|
168
|
+
reference: positionReference
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
const setPositionReference = React.useCallback((node) => {
|
|
173
|
+
const computedPositionReference = isElement(node) ? {
|
|
174
|
+
getBoundingClientRect: () => node.getBoundingClientRect(),
|
|
175
|
+
contextElement: node
|
|
176
|
+
} : node;
|
|
177
|
+
_setPositionReference(computedPositionReference);
|
|
178
|
+
position.refs.setReference(computedPositionReference);
|
|
179
|
+
}, [position.refs]);
|
|
180
|
+
const setReference = React.useCallback((node) => {
|
|
181
|
+
if (isElement(node) || node === null) {
|
|
182
|
+
domReferenceRef.current = node;
|
|
183
|
+
setDomReference(node);
|
|
184
|
+
}
|
|
185
|
+
if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
|
|
186
|
+
// `null` to support `positionReference` + an unstable `reference`
|
|
187
|
+
// callback ref.
|
|
188
|
+
node !== null && !isElement(node)) {
|
|
189
|
+
position.refs.setReference(node);
|
|
190
|
+
}
|
|
191
|
+
}, [position.refs]);
|
|
192
|
+
const refs = React.useMemo(() => ({
|
|
193
|
+
...position.refs,
|
|
194
|
+
setReference,
|
|
195
|
+
setPositionReference,
|
|
196
|
+
domReference: domReferenceRef
|
|
197
|
+
}), [position.refs, setReference, setPositionReference]);
|
|
198
|
+
const elements = React.useMemo(() => ({
|
|
199
|
+
...position.elements,
|
|
200
|
+
domReference
|
|
201
|
+
}), [position.elements, domReference]);
|
|
202
|
+
const context = React.useMemo(() => ({
|
|
203
|
+
...position,
|
|
204
|
+
...rootContext,
|
|
205
|
+
refs,
|
|
206
|
+
elements,
|
|
207
|
+
nodeId
|
|
208
|
+
}), [position, refs, elements, nodeId, rootContext]);
|
|
209
|
+
index(() => {
|
|
210
|
+
rootContext.dataRef.current.floatingContext = context;
|
|
211
|
+
const node = tree == null ? void 0 : tree.nodesRef.current.find((node2) => node2.id === nodeId);
|
|
212
|
+
if (node) {
|
|
213
|
+
node.context = context;
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
return React.useMemo(() => ({
|
|
217
|
+
...position,
|
|
218
|
+
context,
|
|
219
|
+
refs,
|
|
220
|
+
elements
|
|
221
|
+
}), [position, refs, elements, context]);
|
|
34
222
|
}
|
|
35
223
|
export {
|
|
36
|
-
|
|
224
|
+
autoPlacement,
|
|
225
|
+
getOverflowAncestors,
|
|
226
|
+
inline,
|
|
227
|
+
offset,
|
|
228
|
+
shift,
|
|
229
|
+
useFloating,
|
|
230
|
+
useFloatingParentNodeId,
|
|
231
|
+
useFloatingRootContext,
|
|
232
|
+
useFloatingTree,
|
|
233
|
+
useId
|
|
37
234
|
};
|
|
38
235
|
//# sourceMappingURL=react-text-annotator.es10.js.map
|