@soomo/react-text-annotator 3.0.0-staging.1 → 3.0.0-staging.11

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 (55) hide show
  1. package/dist/TextAnnotator.d.ts +4 -3
  2. package/dist/TextAnnotator.d.ts.map +1 -1
  3. package/dist/TextAnnotatorPlugin.d.ts +3 -3
  4. package/dist/TextAnnotatorPlugin.d.ts.map +1 -1
  5. package/dist/TextAnnotatorPopup.d.ts +6 -4
  6. package/dist/TextAnnotatorPopup.d.ts.map +1 -1
  7. package/dist/index.d.ts +4 -2
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/react-text-annotator.css +1 -1
  10. package/dist/react-text-annotator.es.js +6 -2
  11. package/dist/react-text-annotator.es.js.map +1 -1
  12. package/dist/react-text-annotator.es10.js +578 -34
  13. package/dist/react-text-annotator.es10.js.map +1 -1
  14. package/dist/react-text-annotator.es11.js +460 -861
  15. package/dist/react-text-annotator.es11.js.map +1 -1
  16. package/dist/react-text-annotator.es12.js +2 -114
  17. package/dist/react-text-annotator.es12.js.map +1 -1
  18. package/dist/react-text-annotator.es13.js +34 -308
  19. package/dist/react-text-annotator.es13.js.map +1 -1
  20. package/dist/react-text-annotator.es14.js +895 -54
  21. package/dist/react-text-annotator.es14.js.map +1 -1
  22. package/dist/react-text-annotator.es15.js +226 -18
  23. package/dist/react-text-annotator.es15.js.map +1 -1
  24. package/dist/react-text-annotator.es16.js +136 -2
  25. package/dist/react-text-annotator.es16.js.map +1 -1
  26. package/dist/react-text-annotator.es17.js +2 -2
  27. package/dist/react-text-annotator.es18.js +5 -0
  28. package/dist/react-text-annotator.es18.js.map +1 -0
  29. package/dist/react-text-annotator.es19.js +117 -0
  30. package/dist/react-text-annotator.es19.js.map +1 -0
  31. package/dist/react-text-annotator.es2.js +1 -1
  32. package/dist/react-text-annotator.es20.js +312 -0
  33. package/dist/react-text-annotator.es20.js.map +1 -0
  34. package/dist/react-text-annotator.es21.js +61 -0
  35. package/dist/react-text-annotator.es21.js.map +1 -0
  36. package/dist/react-text-annotator.es22.js +23 -0
  37. package/dist/react-text-annotator.es22.js.map +1 -0
  38. package/dist/react-text-annotator.es23.js +124 -0
  39. package/dist/react-text-annotator.es23.js.map +1 -0
  40. package/dist/react-text-annotator.es24.js +555 -0
  41. package/dist/react-text-annotator.es24.js.map +1 -0
  42. package/dist/react-text-annotator.es3.js.map +1 -1
  43. package/dist/react-text-annotator.es4.js.map +1 -1
  44. package/dist/react-text-annotator.es5.js +60 -36
  45. package/dist/react-text-annotator.es5.js.map +1 -1
  46. package/dist/react-text-annotator.es6.js +3 -3
  47. package/dist/react-text-annotator.es8.js +24 -488
  48. package/dist/react-text-annotator.es8.js.map +1 -1
  49. package/dist/react-text-annotator.es9.js +227 -2
  50. package/dist/react-text-annotator.es9.js.map +1 -1
  51. package/dist/tei/TEIAnnotator.d.ts +3 -2
  52. package/dist/tei/TEIAnnotator.d.ts.map +1 -1
  53. package/dist/utils.d.ts +14 -0
  54. package/dist/utils.d.ts.map +1 -0
  55. package/package.json +14 -13
@@ -1,5 +1,230 @@
1
- var jsxRuntime = { exports: {} };
1
+ import * as React from "react";
2
+ import { useLayoutEffect, useEffect } from "react";
3
+ import { useFloating as useFloating$1 } from "./react-text-annotator.es15.js";
4
+ import { isElement } from "./react-text-annotator.es16.js";
5
+ import { getOverflowAncestors } from "./react-text-annotator.es16.js";
6
+ import "react-dom";
7
+ const SafeReact = {
8
+ ...React
9
+ };
10
+ const useInsertionEffect = SafeReact.useInsertionEffect;
11
+ const useSafeInsertionEffect = useInsertionEffect || ((fn) => fn());
12
+ function useEffectEvent(callback) {
13
+ const ref = React.useRef(() => {
14
+ if (process.env.NODE_ENV !== "production") {
15
+ throw new Error("Cannot call an event handler while rendering.");
16
+ }
17
+ });
18
+ useSafeInsertionEffect(() => {
19
+ ref.current = callback;
20
+ });
21
+ return React.useCallback(function() {
22
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
23
+ args[_key] = arguments[_key];
24
+ }
25
+ return ref.current == null ? void 0 : ref.current(...args);
26
+ }, []);
27
+ }
28
+ var index = typeof document !== "undefined" ? useLayoutEffect : useEffect;
29
+ let serverHandoffComplete = false;
30
+ let count = 0;
31
+ const genId = () => (
32
+ // Ensure the id is unique with multiple independent versions of Floating UI
33
+ // on <React 18
34
+ "floating-ui-" + Math.random().toString(36).slice(2, 6) + count++
35
+ );
36
+ function useFloatingId() {
37
+ const [id, setId] = React.useState(() => serverHandoffComplete ? genId() : void 0);
38
+ index(() => {
39
+ if (id == null) {
40
+ setId(genId());
41
+ }
42
+ }, []);
43
+ React.useEffect(() => {
44
+ serverHandoffComplete = true;
45
+ }, []);
46
+ return id;
47
+ }
48
+ const useReactId = SafeReact.useId;
49
+ const useId = useReactId || useFloatingId;
50
+ let devMessageSet;
51
+ if (process.env.NODE_ENV !== "production") {
52
+ devMessageSet = /* @__PURE__ */ new Set();
53
+ }
54
+ function error() {
55
+ var _devMessageSet3;
56
+ for (var _len2 = arguments.length, messages = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
57
+ messages[_key2] = arguments[_key2];
58
+ }
59
+ const message = "Floating UI: " + messages.join(" ");
60
+ if (!((_devMessageSet3 = devMessageSet) != null && _devMessageSet3.has(message))) {
61
+ var _devMessageSet4;
62
+ (_devMessageSet4 = devMessageSet) == null || _devMessageSet4.add(message);
63
+ console.error(message);
64
+ }
65
+ }
66
+ function createPubSub() {
67
+ const map = /* @__PURE__ */ new Map();
68
+ return {
69
+ emit(event, data) {
70
+ var _map$get;
71
+ (_map$get = map.get(event)) == null || _map$get.forEach((handler) => handler(data));
72
+ },
73
+ on(event, listener) {
74
+ map.set(event, [...map.get(event) || [], listener]);
75
+ },
76
+ off(event, listener) {
77
+ var _map$get2;
78
+ map.set(event, ((_map$get2 = map.get(event)) == null ? void 0 : _map$get2.filter((l) => l !== listener)) || []);
79
+ }
80
+ };
81
+ }
82
+ const FloatingNodeContext = /* @__PURE__ */ React.createContext(null);
83
+ const FloatingTreeContext = /* @__PURE__ */ React.createContext(null);
84
+ const useFloatingParentNodeId = () => {
85
+ var _React$useContext;
86
+ return ((_React$useContext = React.useContext(FloatingNodeContext)) == null ? void 0 : _React$useContext.id) || null;
87
+ };
88
+ const useFloatingTree = () => React.useContext(FloatingTreeContext);
89
+ function useFloatingRootContext(options) {
90
+ const {
91
+ open = false,
92
+ onOpenChange: onOpenChangeProp,
93
+ elements: elementsProp
94
+ } = options;
95
+ const floatingId = useId();
96
+ const dataRef = React.useRef({});
97
+ const [events] = React.useState(() => createPubSub());
98
+ const nested = useFloatingParentNodeId() != null;
99
+ if (process.env.NODE_ENV !== "production") {
100
+ const optionDomReference = elementsProp.reference;
101
+ if (optionDomReference && !isElement(optionDomReference)) {
102
+ error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
103
+ }
104
+ }
105
+ const [positionReference, setPositionReference] = React.useState(elementsProp.reference);
106
+ const onOpenChange = useEffectEvent((open2, event, reason) => {
107
+ dataRef.current.openEvent = open2 ? event : void 0;
108
+ events.emit("openchange", {
109
+ open: open2,
110
+ event,
111
+ reason,
112
+ nested
113
+ });
114
+ onOpenChangeProp == null || onOpenChangeProp(open2, event, reason);
115
+ });
116
+ const refs = React.useMemo(() => ({
117
+ setPositionReference
118
+ }), []);
119
+ const elements = React.useMemo(() => ({
120
+ reference: positionReference || elementsProp.reference || null,
121
+ floating: elementsProp.floating || null,
122
+ domReference: elementsProp.reference
123
+ }), [positionReference, elementsProp.reference, elementsProp.floating]);
124
+ return React.useMemo(() => ({
125
+ dataRef,
126
+ open,
127
+ onOpenChange,
128
+ elements,
129
+ events,
130
+ floatingId,
131
+ refs
132
+ }), [open, onOpenChange, elements, events, floatingId, refs]);
133
+ }
134
+ function useFloating(options) {
135
+ if (options === void 0) {
136
+ options = {};
137
+ }
138
+ const {
139
+ nodeId
140
+ } = options;
141
+ const internalRootContext = useFloatingRootContext({
142
+ ...options,
143
+ elements: {
144
+ reference: null,
145
+ floating: null,
146
+ ...options.elements
147
+ }
148
+ });
149
+ const rootContext = options.rootContext || internalRootContext;
150
+ const computedElements = rootContext.elements;
151
+ const [_domReference, setDomReference] = React.useState(null);
152
+ const [positionReference, _setPositionReference] = React.useState(null);
153
+ const optionDomReference = computedElements == null ? void 0 : computedElements.reference;
154
+ const domReference = optionDomReference || _domReference;
155
+ const domReferenceRef = React.useRef(null);
156
+ const tree = useFloatingTree();
157
+ index(() => {
158
+ if (domReference) {
159
+ domReferenceRef.current = domReference;
160
+ }
161
+ }, [domReference]);
162
+ const position = useFloating$1({
163
+ ...options,
164
+ elements: {
165
+ ...computedElements,
166
+ ...positionReference && {
167
+ reference: positionReference
168
+ }
169
+ }
170
+ });
171
+ const setPositionReference = React.useCallback((node) => {
172
+ const computedPositionReference = isElement(node) ? {
173
+ getBoundingClientRect: () => node.getBoundingClientRect(),
174
+ contextElement: node
175
+ } : node;
176
+ _setPositionReference(computedPositionReference);
177
+ position.refs.setReference(computedPositionReference);
178
+ }, [position.refs]);
179
+ const setReference = React.useCallback((node) => {
180
+ if (isElement(node) || node === null) {
181
+ domReferenceRef.current = node;
182
+ setDomReference(node);
183
+ }
184
+ if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
185
+ // `null` to support `positionReference` + an unstable `reference`
186
+ // callback ref.
187
+ node !== null && !isElement(node)) {
188
+ position.refs.setReference(node);
189
+ }
190
+ }, [position.refs]);
191
+ const refs = React.useMemo(() => ({
192
+ ...position.refs,
193
+ setReference,
194
+ setPositionReference,
195
+ domReference: domReferenceRef
196
+ }), [position.refs, setReference, setPositionReference]);
197
+ const elements = React.useMemo(() => ({
198
+ ...position.elements,
199
+ domReference
200
+ }), [position.elements, domReference]);
201
+ const context = React.useMemo(() => ({
202
+ ...position,
203
+ ...rootContext,
204
+ refs,
205
+ elements,
206
+ nodeId
207
+ }), [position, refs, elements, nodeId, rootContext]);
208
+ index(() => {
209
+ rootContext.dataRef.current.floatingContext = context;
210
+ const node = tree == null ? void 0 : tree.nodesRef.current.find((node2) => node2.id === nodeId);
211
+ if (node) {
212
+ node.context = context;
213
+ }
214
+ });
215
+ return React.useMemo(() => ({
216
+ ...position,
217
+ context,
218
+ refs,
219
+ elements
220
+ }), [position, refs, elements, context]);
221
+ }
2
222
  export {
3
- jsxRuntime as __module
223
+ getOverflowAncestors,
224
+ useFloating,
225
+ useFloatingParentNodeId,
226
+ useFloatingRootContext,
227
+ useFloatingTree,
228
+ useId
4
229
  };
5
230
  //# sourceMappingURL=react-text-annotator.es9.js.map