@annotorious/react 3.0.0-rc.9 → 3.0.1

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 (83) hide show
  1. package/dist/Annotorious.d.ts +14 -43
  2. package/dist/Annotorious.d.ts.map +1 -1
  3. package/dist/AnnotoriousPlugin.d.ts +12 -6
  4. package/dist/AnnotoriousPlugin.d.ts.map +1 -1
  5. package/dist/AnnotoriousPopupProps.d.ts +10 -0
  6. package/dist/AnnotoriousPopupProps.d.ts.map +1 -0
  7. package/dist/ImageAnnotationPopup.d.ts +9 -0
  8. package/dist/ImageAnnotationPopup.d.ts.map +1 -0
  9. package/dist/ImageAnnotator.d.ts +2 -3
  10. package/dist/ImageAnnotator.d.ts.map +1 -1
  11. package/dist/annotorious-react.css +1 -1
  12. package/dist/annotorious-react.es.js +37 -34
  13. package/dist/annotorious-react.es.js.map +1 -1
  14. package/dist/annotorious-react.es10.js +15 -35
  15. package/dist/annotorious-react.es10.js.map +1 -1
  16. package/dist/annotorious-react.es11.js +6 -16
  17. package/dist/annotorious-react.es11.js.map +1 -1
  18. package/dist/annotorious-react.es12.js +8 -4
  19. package/dist/annotorious-react.es12.js.map +1 -1
  20. package/dist/annotorious-react.es13.js +272 -8
  21. package/dist/annotorious-react.es13.js.map +1 -1
  22. package/dist/annotorious-react.es14.js +9 -153
  23. package/dist/annotorious-react.es14.js.map +1 -1
  24. package/dist/annotorious-react.es15.js +193 -6
  25. package/dist/annotorious-react.es15.js.map +1 -1
  26. package/dist/annotorious-react.es16.js +327 -22113
  27. package/dist/annotorious-react.es16.js.map +1 -1
  28. package/dist/annotorious-react.es17.js +11 -32
  29. package/dist/annotorious-react.es17.js.map +1 -1
  30. package/dist/annotorious-react.es19.js +6 -10
  31. package/dist/annotorious-react.es19.js.map +1 -1
  32. package/dist/annotorious-react.es2.js +87 -68
  33. package/dist/annotorious-react.es2.js.map +1 -1
  34. package/dist/annotorious-react.es20.js +214 -207
  35. package/dist/annotorious-react.es20.js.map +1 -1
  36. package/dist/annotorious-react.es21.js +126 -2
  37. package/dist/annotorious-react.es21.js.map +1 -1
  38. package/dist/annotorious-react.es22.js +2 -2
  39. package/dist/annotorious-react.es23.js +5 -0
  40. package/dist/annotorious-react.es23.js.map +1 -0
  41. package/dist/annotorious-react.es24.js +10 -0
  42. package/dist/annotorious-react.es24.js.map +1 -0
  43. package/dist/annotorious-react.es25.js +8 -0
  44. package/dist/annotorious-react.es25.js.map +1 -0
  45. package/dist/annotorious-react.es26.js +10 -0
  46. package/dist/annotorious-react.es26.js.map +1 -0
  47. package/dist/annotorious-react.es27.js +129 -0
  48. package/dist/annotorious-react.es27.js.map +1 -0
  49. package/dist/annotorious-react.es28.js +466 -0
  50. package/dist/annotorious-react.es28.js.map +1 -0
  51. package/dist/annotorious-react.es3.js +10 -11
  52. package/dist/annotorious-react.es3.js.map +1 -1
  53. package/dist/annotorious-react.es4.js +90 -12
  54. package/dist/annotorious-react.es4.js.map +1 -1
  55. package/dist/annotorious-react.es5.js +21 -20
  56. package/dist/annotorious-react.es5.js.map +1 -1
  57. package/dist/annotorious-react.es8.js +27 -80
  58. package/dist/annotorious-react.es8.js.map +1 -1
  59. package/dist/annotorious-react.es9.js +103 -26
  60. package/dist/annotorious-react.es9.js.map +1 -1
  61. package/dist/index.d.ts +10 -10
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/openseadragon/OpenSeadragonAnnotationPopup.d.ts +9 -0
  64. package/dist/openseadragon/OpenSeadragonAnnotationPopup.d.ts.map +1 -0
  65. package/dist/openseadragon/OpenSeadragonAnnotator.d.ts +7 -8
  66. package/dist/openseadragon/OpenSeadragonAnnotator.d.ts.map +1 -1
  67. package/dist/openseadragon/OpenSeadragonViewer.d.ts +2 -3
  68. package/dist/openseadragon/OpenSeadragonViewer.d.ts.map +1 -1
  69. package/dist/openseadragon/index.d.ts +1 -1
  70. package/dist/openseadragon/index.d.ts.map +1 -1
  71. package/dist/openseadragon/setPosition.d.ts +1 -1
  72. package/dist/openseadragon/setPosition.d.ts.map +1 -1
  73. package/dist/utils/toClientRects.d.ts +6 -0
  74. package/dist/utils/toClientRects.d.ts.map +1 -0
  75. package/package.json +15 -13
  76. package/dist/AnnotoriousPopup.d.ts +0 -16
  77. package/dist/AnnotoriousPopup.d.ts.map +0 -1
  78. package/dist/annotorious-react.es6.js +0 -5
  79. package/dist/annotorious-react.es6.js.map +0 -1
  80. package/dist/annotorious-react.es7.js +0 -5
  81. package/dist/annotorious-react.es7.js.map +0 -1
  82. package/dist/openseadragon/OpenSeadragonPopup.d.ts +0 -11
  83. package/dist/openseadragon/OpenSeadragonPopup.d.ts.map +0 -1
@@ -1,11 +1,275 @@
1
- import { useState as c, useRef as n, useEffect as s } from "react";
2
- const m = (e, t) => {
3
- const [u, o] = c(e), r = n();
4
- return s(() => (r.current = setTimeout(() => o(e), t), () => {
5
- clearTimeout(r.current);
6
- }), [e, t]), u;
7
- };
1
+ import * as o from "react";
2
+ import { useLayoutEffect as Y, useEffect as q } from "react";
3
+ import { getComputedStyle as Q, isElement as I } from "./annotorious-react.es21.js";
4
+ import { getOverflowAncestors as Re } from "./annotorious-react.es21.js";
5
+ import "react-dom";
6
+ import { useFloating as Z } from "./annotorious-react.es15.js";
7
+ import { arrow as xe, flip as Ee, inline as we, offset as Ce, shift as Se } from "./annotorious-react.es15.js";
8
+ const W = {
9
+ ...o
10
+ }, z = W.useInsertionEffect, G = z || ((t) => t());
11
+ function J(t) {
12
+ const n = o.useRef(() => {
13
+ if (process.env.NODE_ENV !== "production")
14
+ throw new Error("Cannot call an event handler while rendering.");
15
+ });
16
+ return G(() => {
17
+ n.current = t;
18
+ }), o.useCallback(function() {
19
+ for (var s = arguments.length, e = new Array(s), r = 0; r < s; r++)
20
+ e[r] = arguments[r];
21
+ return n.current == null ? void 0 : n.current(...e);
22
+ }, []);
23
+ }
24
+ var b = typeof document < "u" ? Y : q;
25
+ function D() {
26
+ return D = Object.assign ? Object.assign.bind() : function(t) {
27
+ for (var n = 1; n < arguments.length; n++) {
28
+ var s = arguments[n];
29
+ for (var e in s)
30
+ Object.prototype.hasOwnProperty.call(s, e) && (t[e] = s[e]);
31
+ }
32
+ return t;
33
+ }, D.apply(this, arguments);
34
+ }
35
+ let V = !1, K = 0;
36
+ const j = () => (
37
+ // Ensure the id is unique with multiple independent versions of Floating UI
38
+ // on <React 18
39
+ "floating-ui-" + Math.random().toString(36).slice(2, 6) + K++
40
+ );
41
+ function k() {
42
+ const [t, n] = o.useState(() => V ? j() : void 0);
43
+ return b(() => {
44
+ t == null && n(j());
45
+ }, []), o.useEffect(() => {
46
+ V = !0;
47
+ }, []), t;
48
+ }
49
+ const _ = W.useId, $ = _ || k;
50
+ let P;
51
+ process.env.NODE_ENV !== "production" && (P = /* @__PURE__ */ new Set());
52
+ function ee() {
53
+ for (var t, n = arguments.length, s = new Array(n), e = 0; e < n; e++)
54
+ s[e] = arguments[e];
55
+ const r = "Floating UI: " + s.join(" ");
56
+ if (!((t = P) != null && t.has(r))) {
57
+ var l;
58
+ (l = P) == null || l.add(r), console.warn(r);
59
+ }
60
+ }
61
+ function te() {
62
+ for (var t, n = arguments.length, s = new Array(n), e = 0; e < n; e++)
63
+ s[e] = arguments[e];
64
+ const r = "Floating UI: " + s.join(" ");
65
+ if (!((t = P) != null && t.has(r))) {
66
+ var l;
67
+ (l = P) == null || l.add(r), console.error(r);
68
+ }
69
+ }
70
+ const me = /* @__PURE__ */ o.forwardRef(function(n, s) {
71
+ const {
72
+ context: {
73
+ placement: e,
74
+ elements: {
75
+ floating: r
76
+ },
77
+ middlewareData: {
78
+ arrow: l,
79
+ shift: u
80
+ }
81
+ },
82
+ width: i = 14,
83
+ height: a = 7,
84
+ tipRadius: O = 0,
85
+ strokeWidth: d = 0,
86
+ staticOffset: p,
87
+ stroke: h,
88
+ d: c,
89
+ style: {
90
+ transform: m,
91
+ ...R
92
+ } = {},
93
+ ...v
94
+ } = n;
95
+ process.env.NODE_ENV !== "production" && (s || ee("The `ref` prop is required for `FloatingArrow`."));
96
+ const x = $(), [C, f] = o.useState(!1);
97
+ if (b(() => {
98
+ if (!r) return;
99
+ Q(r).direction === "rtl" && f(!0);
100
+ }, [r]), !r)
101
+ return null;
102
+ const [g, F] = e.split("-"), M = g === "top" || g === "bottom";
103
+ let S = p;
104
+ (M && u != null && u.x || !M && u != null && u.y) && (S = null);
105
+ const E = d * 2, N = E / 2, A = i / 2 * (O / -8 + 1), T = a / 2 * O / 4, w = !!c, B = S && F === "end" ? "bottom" : "top";
106
+ let y = S && F === "end" ? "right" : "left";
107
+ S && C && (y = F === "end" ? "left" : "right");
108
+ const U = (l == null ? void 0 : l.x) != null ? S || l.x : "", H = (l == null ? void 0 : l.y) != null ? S || l.y : "", L = c || "M0,0" + (" H" + i) + (" L" + (i - A) + "," + (a - T)) + (" Q" + i / 2 + "," + a + " " + A + "," + (a - T)) + " Z", X = {
109
+ top: w ? "rotate(180deg)" : "",
110
+ left: w ? "rotate(90deg)" : "rotate(-90deg)",
111
+ bottom: w ? "" : "rotate(180deg)",
112
+ right: w ? "rotate(-90deg)" : "rotate(90deg)"
113
+ }[g];
114
+ return /* @__PURE__ */ o.createElement("svg", D({}, v, {
115
+ "aria-hidden": !0,
116
+ ref: s,
117
+ width: w ? i : i + E,
118
+ height: i,
119
+ viewBox: "0 0 " + i + " " + (a > i ? a : i),
120
+ style: {
121
+ position: "absolute",
122
+ pointerEvents: "none",
123
+ [y]: U,
124
+ [B]: H,
125
+ [g]: M || w ? "100%" : "calc(100% - " + E / 2 + "px)",
126
+ transform: "" + X + (m ?? ""),
127
+ ...R
128
+ }
129
+ }), E > 0 && /* @__PURE__ */ o.createElement("path", {
130
+ clipPath: "url(#" + x + ")",
131
+ fill: "none",
132
+ stroke: h,
133
+ strokeWidth: E + (c ? 0 : 1),
134
+ d: L
135
+ }), /* @__PURE__ */ o.createElement("path", {
136
+ stroke: E && !c ? v.fill : "none",
137
+ d: L
138
+ }), /* @__PURE__ */ o.createElement("clipPath", {
139
+ id: x
140
+ }, /* @__PURE__ */ o.createElement("rect", {
141
+ x: -N,
142
+ y: N * (w ? -1 : 1),
143
+ width: i + E,
144
+ height: i
145
+ })));
146
+ });
147
+ function ne() {
148
+ const t = /* @__PURE__ */ new Map();
149
+ return {
150
+ emit(n, s) {
151
+ var e;
152
+ (e = t.get(n)) == null || e.forEach((r) => r(s));
153
+ },
154
+ on(n, s) {
155
+ t.set(n, [...t.get(n) || [], s]);
156
+ },
157
+ off(n, s) {
158
+ var e;
159
+ t.set(n, ((e = t.get(n)) == null ? void 0 : e.filter((r) => r !== s)) || []);
160
+ }
161
+ };
162
+ }
163
+ const oe = /* @__PURE__ */ o.createContext(null), re = /* @__PURE__ */ o.createContext(null), se = () => {
164
+ var t;
165
+ return ((t = o.useContext(oe)) == null ? void 0 : t.id) || null;
166
+ }, ce = () => o.useContext(re);
167
+ function le(t) {
168
+ const {
169
+ open: n = !1,
170
+ onOpenChange: s,
171
+ elements: e
172
+ } = t, r = $(), l = o.useRef({}), [u] = o.useState(() => ne()), i = se() != null;
173
+ if (process.env.NODE_ENV !== "production") {
174
+ const c = e.reference;
175
+ c && !I(c) && te("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
176
+ }
177
+ const [a, O] = o.useState(e.reference), d = J((c, m, R) => {
178
+ l.current.openEvent = c ? m : void 0, u.emit("openchange", {
179
+ open: c,
180
+ event: m,
181
+ reason: R,
182
+ nested: i
183
+ }), s == null || s(c, m, R);
184
+ }), p = o.useMemo(() => ({
185
+ setPositionReference: O
186
+ }), []), h = o.useMemo(() => ({
187
+ reference: a || e.reference || null,
188
+ floating: e.floating || null,
189
+ domReference: e.reference
190
+ }), [a, e.reference, e.floating]);
191
+ return o.useMemo(() => ({
192
+ dataRef: l,
193
+ open: n,
194
+ onOpenChange: d,
195
+ elements: h,
196
+ events: u,
197
+ floatingId: r,
198
+ refs: p
199
+ }), [n, d, h, u, r, p]);
200
+ }
201
+ function ge(t) {
202
+ t === void 0 && (t = {});
203
+ const {
204
+ nodeId: n
205
+ } = t, s = le({
206
+ ...t,
207
+ elements: {
208
+ reference: null,
209
+ floating: null,
210
+ ...t.elements
211
+ }
212
+ }), e = t.rootContext || s, r = e.elements, [l, u] = o.useState(null), [i, a] = o.useState(null), d = (r == null ? void 0 : r.reference) || l, p = o.useRef(null), h = ce();
213
+ b(() => {
214
+ d && (p.current = d);
215
+ }, [d]);
216
+ const c = Z({
217
+ ...t,
218
+ elements: {
219
+ ...r,
220
+ ...i && {
221
+ reference: i
222
+ }
223
+ }
224
+ }), m = o.useCallback((f) => {
225
+ const g = I(f) ? {
226
+ getBoundingClientRect: () => f.getBoundingClientRect(),
227
+ contextElement: f
228
+ } : f;
229
+ a(g), c.refs.setReference(g);
230
+ }, [c.refs]), R = o.useCallback((f) => {
231
+ (I(f) || f === null) && (p.current = f, u(f)), (I(c.refs.reference.current) || c.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
232
+ // `null` to support `positionReference` + an unstable `reference`
233
+ // callback ref.
234
+ f !== null && !I(f)) && c.refs.setReference(f);
235
+ }, [c.refs]), v = o.useMemo(() => ({
236
+ ...c.refs,
237
+ setReference: R,
238
+ setPositionReference: m,
239
+ domReference: p
240
+ }), [c.refs, R, m]), x = o.useMemo(() => ({
241
+ ...c.elements,
242
+ domReference: d
243
+ }), [c.elements, d]), C = o.useMemo(() => ({
244
+ ...c,
245
+ ...e,
246
+ refs: v,
247
+ elements: x,
248
+ nodeId: n
249
+ }), [c, v, x, n, e]);
250
+ return b(() => {
251
+ e.dataRef.current.floatingContext = C;
252
+ const f = h == null ? void 0 : h.nodesRef.current.find((g) => g.id === n);
253
+ f && (f.context = C);
254
+ }), o.useMemo(() => ({
255
+ ...c,
256
+ context: C,
257
+ refs: v,
258
+ elements: x
259
+ }), [c, v, x, C]);
260
+ }
8
261
  export {
9
- m as useDebounce
262
+ me as FloatingArrow,
263
+ xe as arrow,
264
+ Ee as flip,
265
+ Re as getOverflowAncestors,
266
+ we as inline,
267
+ Ce as offset,
268
+ Se as shift,
269
+ ge as useFloating,
270
+ se as useFloatingParentNodeId,
271
+ le as useFloatingRootContext,
272
+ ce as useFloatingTree,
273
+ $ as useId
10
274
  };
11
275
  //# sourceMappingURL=annotorious-react.es13.js.map