@annotorious/react 3.3.3 → 3.3.4

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.
@@ -1,43 +1,49 @@
1
- import { Annotorious as r, AnnotoriousContext as a, useAnnotation as p, useAnnotationSelectAction as i, useAnnotationStore as u, useAnnotations as s, useAnnotator as m, useAnnotatorUser as A, useHover as S, useSelection as x, useViewportState as c } from "./annotorious-react.es2.js";
2
- import { AnnotoriousPlugin as g } from "./annotorious-react.es3.js";
1
+ import { Annotorious as r, AnnotoriousContext as a, useAnnotation as i, useAnnotationSelectAction as p, useAnnotationStore as s, useAnnotations as m, useAnnotator as u, useAnnotatorUser as A, useHover as S, useSelection as l, useViewportState as c } from "./annotorious-react.es2.js";
2
+ import { AnnotoriousPlugin as x } from "./annotorious-react.es3.js";
3
3
  import { ImageAnnotationPopup as d } from "./annotorious-react.es4.js";
4
- import { ImageAnnotator as O } from "./annotorious-react.es5.js";
4
+ import { ImageAnnotator as I } from "./annotorious-react.es5.js";
5
5
  /* empty css */
6
6
  /* empty css */
7
- import { Origin as I, UserSelectAction as P, createAnonymousGuest as w, createBody as V, defaultColorProvider as h } from "@annotorious/core";
8
- import { ShapeType as U, W3CImageFormat as B, chainStyles as F, computeStyle as G, createImageAnnotator as H } from "@annotorious/annotorious";
9
- import { OpenSeadragonAnnotator as W, OpenSeadragonAnnotatorContext as b, useViewer as j } from "./annotorious-react.es8.js";
10
- import { OpenSeadragonAnnotationPopup as q } from "./annotorious-react.es9.js";
11
- import { OpenSeadragonViewer as D } from "./annotorious-react.es10.js";
7
+ import { Origin as O, UserSelectAction as V, createAnonymousGuest as P, createBody as w, defaultColorProvider as z } from "@annotorious/core";
8
+ import { ShapeType as G, W3CImageFormat as W, chainStyles as h, computeStyle as v, createImageAnnotator as U, parseFragmentSelector as B, parseSVGSelector as H, parseW3CImageAnnotation as T, serializeFragmentSelector as b, serializeSVGSelector as j, serializeW3CImageAnnotation as k } from "@annotorious/annotorious";
9
+ import { OpenSeadragonAnnotator as D, OpenSeadragonAnnotatorContext as E, useViewer as J } from "./annotorious-react.es8.js";
10
+ import { OpenSeadragonAnnotationPopup as L } from "./annotorious-react.es9.js";
11
+ import { OpenSeadragonViewer as N } from "./annotorious-react.es10.js";
12
12
  export {
13
13
  r as Annotorious,
14
14
  a as AnnotoriousContext,
15
- g as AnnotoriousPlugin,
15
+ x as AnnotoriousPlugin,
16
16
  d as ImageAnnotationPopup,
17
- O as ImageAnnotator,
18
- q as OpenSeadragonAnnotationPopup,
19
- W as OpenSeadragonAnnotator,
20
- b as OpenSeadragonAnnotatorContext,
21
- D as OpenSeadragonViewer,
22
- I as Origin,
23
- U as ShapeType,
24
- P as UserSelectAction,
25
- B as W3CImageFormat,
26
- F as chainStyles,
27
- G as computeStyle,
28
- w as createAnonymousGuest,
29
- V as createBody,
30
- H as createImageAnnotator,
31
- h as defaultColorProvider,
32
- p as useAnnotation,
33
- i as useAnnotationSelectAction,
34
- u as useAnnotationStore,
35
- s as useAnnotations,
36
- m as useAnnotator,
17
+ I as ImageAnnotator,
18
+ L as OpenSeadragonAnnotationPopup,
19
+ D as OpenSeadragonAnnotator,
20
+ E as OpenSeadragonAnnotatorContext,
21
+ N as OpenSeadragonViewer,
22
+ O as Origin,
23
+ G as ShapeType,
24
+ V as UserSelectAction,
25
+ W as W3CImageFormat,
26
+ h as chainStyles,
27
+ v as computeStyle,
28
+ P as createAnonymousGuest,
29
+ w as createBody,
30
+ U as createImageAnnotator,
31
+ z as defaultColorProvider,
32
+ B as parseFragmentSelector,
33
+ H as parseSVGSelector,
34
+ T as parseW3CImageAnnotation,
35
+ b as serializeFragmentSelector,
36
+ j as serializeSVGSelector,
37
+ k as serializeW3CImageAnnotation,
38
+ i as useAnnotation,
39
+ p as useAnnotationSelectAction,
40
+ s as useAnnotationStore,
41
+ m as useAnnotations,
42
+ u as useAnnotator,
37
43
  A as useAnnotatorUser,
38
44
  S as useHover,
39
- x as useSelection,
40
- j as useViewer,
45
+ l as useSelection,
46
+ J as useViewer,
41
47
  c as useViewportState
42
48
  };
43
49
  //# sourceMappingURL=annotorious-react.es.js.map
@@ -1,6 +1,6 @@
1
1
  import * as s from "react";
2
2
  import { useLayoutEffect as k, useEffect as q } from "react";
3
- import { jsxs as Q, jsx as O } from "react/jsx-runtime";
3
+ import { jsxs as Q, jsx as P } from "react/jsx-runtime";
4
4
  import { isElement as F, getComputedStyle as Z } from "./annotorious-react.es17.js";
5
5
  import { getOverflowAncestors as xe } from "./annotorious-react.es17.js";
6
6
  import "react-dom";
@@ -38,24 +38,24 @@ function ee() {
38
38
  }, []), t;
39
39
  }
40
40
  const te = $.useId, B = te || ee;
41
- let P;
42
- process.env.NODE_ENV !== "production" && (P = /* @__PURE__ */ new Set());
41
+ let O;
42
+ process.env.NODE_ENV !== "production" && (O = /* @__PURE__ */ new Set());
43
43
  function ne() {
44
44
  for (var t, n = arguments.length, c = new Array(n), e = 0; e < n; e++)
45
45
  c[e] = arguments[e];
46
46
  const o = "Floating UI: " + c.join(" ");
47
- if (!((t = P) != null && t.has(o))) {
48
- var i;
49
- (i = P) == null || i.add(o), console.warn(o);
47
+ if (!((t = O) != null && t.has(o))) {
48
+ var l;
49
+ (l = O) == null || l.add(o), console.warn(o);
50
50
  }
51
51
  }
52
52
  function oe() {
53
53
  for (var t, n = arguments.length, c = new Array(n), e = 0; e < n; e++)
54
54
  c[e] = arguments[e];
55
55
  const o = "Floating UI: " + c.join(" ");
56
- if (!((t = P) != null && t.has(o))) {
57
- var i;
58
- (i = P) == null || i.add(o), console.error(o);
56
+ if (!((t = O) != null && t.has(o))) {
57
+ var l;
58
+ (l = O) == null || l.add(o), console.error(o);
59
59
  }
60
60
  }
61
61
  const pe = /* @__PURE__ */ s.forwardRef(function(n, c) {
@@ -66,11 +66,11 @@ const pe = /* @__PURE__ */ s.forwardRef(function(n, c) {
66
66
  floating: o
67
67
  },
68
68
  middlewareData: {
69
- arrow: i,
69
+ arrow: l,
70
70
  shift: u
71
71
  }
72
72
  },
73
- width: l = 14,
73
+ width: f = 14,
74
74
  height: a = 7,
75
75
  tipRadius: I = 0,
76
76
  strokeWidth: d = 0,
@@ -84,19 +84,19 @@ const pe = /* @__PURE__ */ s.forwardRef(function(n, c) {
84
84
  ...v
85
85
  } = n;
86
86
  process.env.NODE_ENV !== "production" && (c || ne("The `ref` prop is required for `FloatingArrow`."));
87
- const x = B(), [E, f] = s.useState(!1);
87
+ const x = B(), [E, i] = s.useState(!1);
88
88
  if (M(() => {
89
89
  if (!o) return;
90
- Z(o).direction === "rtl" && f(!0);
90
+ Z(o).direction === "rtl" && i(!0);
91
91
  }, [o]), !o)
92
92
  return null;
93
- const [m, b] = e.split("-"), D = m === "top" || m === "bottom";
93
+ const [m, D] = e.split("-"), N = m === "top" || m === "bottom";
94
94
  let S = g;
95
- (D && u != null && u.x || !D && u != null && u.y) && (S = null);
96
- const C = d * 2, N = C / 2, A = l / 2 * (I / -8 + 1), T = a / 2 * I / 4, w = !!r, U = S && b === "end" ? "bottom" : "top";
97
- let L = S && b === "end" ? "right" : "left";
98
- S && E && (L = b === "end" ? "left" : "right");
99
- const H = (i == null ? void 0 : i.x) != null ? S || i.x : "", X = (i == null ? void 0 : i.y) != null ? S || i.y : "", V = r || "M0,0" + (" H" + l) + (" L" + (l - A) + "," + (a - T)) + (" Q" + l / 2 + "," + a + " " + A + "," + (a - T)) + " Z", Y = {
95
+ (N && u != null && u.x || !N && u != null && u.y) && (S = null);
96
+ const C = d * 2, b = C / 2, A = f / 2 * (I / -8 + 1), T = a / 2 * I / 4, w = !!r, U = S && D === "end" ? "bottom" : "top";
97
+ let L = S && D === "end" ? "right" : "left";
98
+ S && E && (L = D === "end" ? "left" : "right");
99
+ const H = (l == null ? void 0 : l.x) != null ? S || l.x : "", X = (l == null ? void 0 : l.y) != null ? S || l.y : "", V = r || "M0,0" + (" H" + f) + (" L" + (f - A) + "," + (a - T)) + (" Q" + f / 2 + "," + a + " " + A + "," + (a - T)) + " Z", Y = {
100
100
  top: w ? "rotate(180deg)" : "",
101
101
  left: w ? "rotate(90deg)" : "rotate(-90deg)",
102
102
  bottom: w ? "" : "rotate(180deg)",
@@ -106,34 +106,34 @@ const pe = /* @__PURE__ */ s.forwardRef(function(n, c) {
106
106
  ...v,
107
107
  "aria-hidden": !0,
108
108
  ref: c,
109
- width: w ? l : l + C,
110
- height: l,
111
- viewBox: "0 0 " + l + " " + (a > l ? a : l),
109
+ width: w ? f : f + C,
110
+ height: f,
111
+ viewBox: "0 0 " + f + " " + (a > f ? a : f),
112
112
  style: {
113
113
  position: "absolute",
114
114
  pointerEvents: "none",
115
115
  [L]: H,
116
116
  [U]: X,
117
- [m]: D || w ? "100%" : "calc(100% - " + C / 2 + "px)",
117
+ [m]: N || w ? "100%" : "calc(100% - " + C / 2 + "px)",
118
118
  transform: [Y, p].filter((j) => !!j).join(" "),
119
119
  ...R
120
120
  },
121
- children: [C > 0 && /* @__PURE__ */ O("path", {
121
+ children: [C > 0 && /* @__PURE__ */ P("path", {
122
122
  clipPath: "url(#" + x + ")",
123
123
  fill: "none",
124
124
  stroke: h,
125
125
  strokeWidth: C + (r ? 0 : 1),
126
126
  d: V
127
- }), /* @__PURE__ */ O("path", {
127
+ }), /* @__PURE__ */ P("path", {
128
128
  stroke: C && !r ? v.fill : "none",
129
129
  d: V
130
- }), /* @__PURE__ */ O("clipPath", {
130
+ }), /* @__PURE__ */ P("clipPath", {
131
131
  id: x,
132
- children: /* @__PURE__ */ O("rect", {
133
- x: -N,
134
- y: N * (w ? -1 : 1),
135
- width: l + C,
136
- height: l
132
+ children: /* @__PURE__ */ P("rect", {
133
+ x: -b,
134
+ y: b * (w ? -1 : 1),
135
+ width: f + C,
136
+ height: f
137
137
  })
138
138
  })]
139
139
  });
@@ -146,11 +146,11 @@ function re() {
146
146
  (e = t.get(n)) == null || e.forEach((o) => o(c));
147
147
  },
148
148
  on(n, c) {
149
- t.set(n, [...t.get(n) || [], c]);
149
+ t.has(n) || t.set(n, /* @__PURE__ */ new Set()), t.get(n).add(c);
150
150
  },
151
151
  off(n, c) {
152
152
  var e;
153
- t.set(n, ((e = t.get(n)) == null ? void 0 : e.filter((o) => o !== c)) || []);
153
+ (e = t.get(n)) == null || e.delete(c);
154
154
  }
155
155
  };
156
156
  }
@@ -163,17 +163,17 @@ function fe(t) {
163
163
  open: n = !1,
164
164
  onOpenChange: c,
165
165
  elements: e
166
- } = t, o = B(), i = s.useRef({}), [u] = s.useState(() => re()), l = ie() != null;
166
+ } = t, o = B(), l = s.useRef({}), [u] = s.useState(() => re()), f = ie() != null;
167
167
  if (process.env.NODE_ENV !== "production") {
168
168
  const r = e.reference;
169
169
  r && !F(r) && oe("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
170
170
  }
171
171
  const [a, I] = s.useState(e.reference), d = K((r, p, R) => {
172
- i.current.openEvent = r ? p : void 0, u.emit("openchange", {
172
+ l.current.openEvent = r ? p : void 0, u.emit("openchange", {
173
173
  open: r,
174
174
  event: p,
175
175
  reason: R,
176
- nested: l
176
+ nested: f
177
177
  }), c == null || c(r, p, R);
178
178
  }), g = s.useMemo(() => ({
179
179
  setPositionReference: I
@@ -183,7 +183,7 @@ function fe(t) {
183
183
  domReference: e.reference
184
184
  }), [a, e.reference, e.floating]);
185
185
  return s.useMemo(() => ({
186
- dataRef: i,
186
+ dataRef: l,
187
187
  open: n,
188
188
  onOpenChange: d,
189
189
  elements: h,
@@ -203,7 +203,7 @@ function he(t) {
203
203
  floating: null,
204
204
  ...t.elements
205
205
  }
206
- }), e = t.rootContext || c, o = e.elements, [i, u] = s.useState(null), [l, a] = s.useState(null), d = (o == null ? void 0 : o.domReference) || i, g = s.useRef(null), h = le();
206
+ }), e = t.rootContext || c, o = e.elements, [l, u] = s.useState(null), [f, a] = s.useState(null), d = (o == null ? void 0 : o.domReference) || l, g = s.useRef(null), h = le();
207
207
  M(() => {
208
208
  d && (g.current = d);
209
209
  }, [d]);
@@ -211,21 +211,22 @@ function he(t) {
211
211
  ...t,
212
212
  elements: {
213
213
  ...o,
214
- ...l && {
215
- reference: l
214
+ ...f && {
215
+ reference: f
216
216
  }
217
217
  }
218
- }), p = s.useCallback((f) => {
219
- const m = F(f) ? {
220
- getBoundingClientRect: () => f.getBoundingClientRect(),
221
- contextElement: f
222
- } : f;
218
+ }), p = s.useCallback((i) => {
219
+ const m = F(i) ? {
220
+ getBoundingClientRect: () => i.getBoundingClientRect(),
221
+ getClientRects: () => i.getClientRects(),
222
+ contextElement: i
223
+ } : i;
223
224
  a(m), r.refs.setReference(m);
224
- }, [r.refs]), R = s.useCallback((f) => {
225
- (F(f) || f === null) && (g.current = f, u(f)), (F(r.refs.reference.current) || r.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
225
+ }, [r.refs]), R = s.useCallback((i) => {
226
+ (F(i) || i === null) && (g.current = i, u(i)), (F(r.refs.reference.current) || r.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
226
227
  // `null` to support `positionReference` + an unstable `reference`
227
228
  // callback ref.
228
- f !== null && !F(f)) && r.refs.setReference(f);
229
+ i !== null && !F(i)) && r.refs.setReference(i);
229
230
  }, [r.refs]), v = s.useMemo(() => ({
230
231
  ...r.refs,
231
232
  setReference: R,
@@ -243,8 +244,8 @@ function he(t) {
243
244
  }), [r, v, x, n, e]);
244
245
  return M(() => {
245
246
  e.dataRef.current.floatingContext = E;
246
- const f = h == null ? void 0 : h.nodesRef.current.find((m) => m.id === n);
247
- f && (f.context = E);
247
+ const i = h == null ? void 0 : h.nodesRef.current.find((m) => m.id === n);
248
+ i && (i.context = E);
248
249
  }), s.useMemo(() => ({
249
250
  ...r,
250
251
  context: E,