@annotorious/react 3.0.5 → 3.0.6

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,65 +1,65 @@
1
- import { offset as et, shift as it, flip as nt, inline as ot, arrow as st, computePosition as rt } from "./annotorious-react.es28.js";
2
- import { createCoords as b, rectToClientRect as X, round as D, floor as A, max as T, min as z } from "./annotorious-react.es27.js";
3
- import { getOverflowAncestors as $, isElement as x, getWindow as E, getFrameElement as U, getComputedStyle as y, getDocumentElement as C, isHTMLElement as R, isWebKit as j, isTopLayer as S, getNodeName as M, isOverflowElement as _, getNodeScroll as H, getParentNode as W, isLastTraversableNode as N, isTableElement as ct, isContainingBlock as G, getContainingBlock as lt } from "./annotorious-react.es21.js";
1
+ import { offset as et, shift as nt, flip as it, inline as ot, arrow as st, computePosition as rt } from "./annotorious-react.es28.js";
2
+ import { createCoords as R, rectToClientRect as Y, round as A, floor as D, max as E, min as z } from "./annotorious-react.es27.js";
3
+ import { getOverflowAncestors as $, isElement as y, getWindow as L, getFrameElement as U, getComputedStyle as x, getDocumentElement as b, isHTMLElement as C, isWebKit as j, isTopLayer as M, getNodeName as _, isOverflowElement as k, getNodeScroll as H, getParentNode as W, isLastTraversableNode as N, isTableElement as ct, isContainingBlock as G, getContainingBlock as lt } from "./annotorious-react.es21.js";
4
4
  function J(t) {
5
- const e = y(t);
5
+ const e = x(t);
6
6
  let n = parseFloat(e.width) || 0, i = parseFloat(e.height) || 0;
7
- const o = R(t), c = o ? t.offsetWidth : n, s = o ? t.offsetHeight : i, r = D(n) !== c || D(i) !== s;
7
+ const o = C(t), c = o ? t.offsetWidth : n, s = o ? t.offsetHeight : i, r = A(n) !== c || A(i) !== s;
8
8
  return r && (n = c, i = s), {
9
9
  width: n,
10
10
  height: i,
11
11
  $: r
12
12
  };
13
13
  }
14
- function k(t) {
15
- return x(t) ? t : t.contextElement;
14
+ function q(t) {
15
+ return y(t) ? t : t.contextElement;
16
16
  }
17
17
  function F(t) {
18
- const e = k(t);
19
- if (!R(e))
20
- return b(1);
18
+ const e = q(t);
19
+ if (!C(e))
20
+ return R(1);
21
21
  const n = e.getBoundingClientRect(), {
22
22
  width: i,
23
23
  height: o,
24
24
  $: c
25
25
  } = J(e);
26
- let s = (c ? D(n.width) : n.width) / i, r = (c ? D(n.height) : n.height) / o;
26
+ let s = (c ? A(n.width) : n.width) / i, r = (c ? A(n.height) : n.height) / o;
27
27
  return (!s || !Number.isFinite(s)) && (s = 1), (!r || !Number.isFinite(r)) && (r = 1), {
28
28
  x: s,
29
29
  y: r
30
30
  };
31
31
  }
32
- const ft = /* @__PURE__ */ b(0);
32
+ const ft = /* @__PURE__ */ R(0);
33
33
  function Q(t) {
34
- const e = E(t);
34
+ const e = L(t);
35
35
  return !j() || !e.visualViewport ? ft : {
36
36
  x: e.visualViewport.offsetLeft,
37
37
  y: e.visualViewport.offsetTop
38
38
  };
39
39
  }
40
40
  function ut(t, e, n) {
41
- return e === void 0 && (e = !1), !n || e && n !== E(t) ? !1 : e;
41
+ return e === void 0 && (e = !1), !n || e && n !== L(t) ? !1 : e;
42
42
  }
43
- function L(t, e, n, i) {
43
+ function T(t, e, n, i) {
44
44
  e === void 0 && (e = !1), n === void 0 && (n = !1);
45
- const o = t.getBoundingClientRect(), c = k(t);
46
- let s = b(1);
47
- e && (i ? x(i) && (s = F(i)) : s = F(t));
48
- const r = ut(c, n, i) ? Q(c) : b(0);
49
- let l = (o.left + r.x) / s.x, f = (o.top + r.y) / s.y, u = o.width / s.x, h = o.height / s.y;
45
+ const o = t.getBoundingClientRect(), c = q(t);
46
+ let s = R(1);
47
+ e && (i ? y(i) && (s = F(i)) : s = F(t));
48
+ const r = ut(c, n, i) ? Q(c) : R(0);
49
+ let f = (o.left + r.x) / s.x, l = (o.top + r.y) / s.y, u = o.width / s.x, a = o.height / s.y;
50
50
  if (c) {
51
- const m = E(c), g = i && x(i) ? E(i) : i;
52
- let v = m, a = U(v);
53
- for (; a && i && g !== v; ) {
54
- const p = F(a), d = a.getBoundingClientRect(), w = y(a), O = d.left + (a.clientLeft + parseFloat(w.paddingLeft)) * p.x, B = d.top + (a.clientTop + parseFloat(w.paddingTop)) * p.y;
55
- l *= p.x, f *= p.y, u *= p.x, h *= p.y, l += O, f += B, v = E(a), a = U(v);
51
+ const p = L(c), h = i && y(i) ? L(i) : i;
52
+ let v = p, d = U(v);
53
+ for (; d && i && h !== v; ) {
54
+ const w = F(d), g = d.getBoundingClientRect(), m = x(d), O = g.left + (d.clientLeft + parseFloat(m.paddingLeft)) * w.x, B = g.top + (d.clientTop + parseFloat(m.paddingTop)) * w.y;
55
+ f *= w.x, l *= w.y, u *= w.x, a *= w.y, f += O, l += B, v = L(d), d = U(v);
56
56
  }
57
57
  }
58
- return X({
58
+ return Y({
59
59
  width: u,
60
- height: h,
61
- x: l,
62
- y: f
60
+ height: a,
61
+ x: f,
62
+ y: l
63
63
  });
64
64
  }
65
65
  function ht(t) {
@@ -69,36 +69,37 @@ function ht(t) {
69
69
  offsetParent: i,
70
70
  strategy: o
71
71
  } = t;
72
- const c = o === "fixed", s = C(i), r = e ? S(e.floating) : !1;
72
+ const c = o === "fixed", s = b(i), r = e ? M(e.floating) : !1;
73
73
  if (i === s || r && c)
74
74
  return n;
75
- let l = {
75
+ let f = {
76
76
  scrollLeft: 0,
77
77
  scrollTop: 0
78
- }, f = b(1);
79
- const u = b(0), h = R(i);
80
- if ((h || !h && !c) && ((M(i) !== "body" || _(s)) && (l = H(i)), R(i))) {
81
- const m = L(i);
82
- f = F(i), u.x = m.x + i.clientLeft, u.y = m.y + i.clientTop;
78
+ }, l = R(1);
79
+ const u = R(0), a = C(i);
80
+ if ((a || !a && !c) && ((_(i) !== "body" || k(s)) && (f = H(i)), C(i))) {
81
+ const p = T(i);
82
+ l = F(i), u.x = p.x + i.clientLeft, u.y = p.y + i.clientTop;
83
83
  }
84
84
  return {
85
- width: n.width * f.x,
86
- height: n.height * f.y,
87
- x: n.x * f.x - l.scrollLeft * f.x + u.x,
88
- y: n.y * f.y - l.scrollTop * f.y + u.y
85
+ width: n.width * l.x,
86
+ height: n.height * l.y,
87
+ x: n.x * l.x - f.scrollLeft * l.x + u.x,
88
+ y: n.y * l.y - f.scrollTop * l.y + u.y
89
89
  };
90
90
  }
91
91
  function at(t) {
92
92
  return Array.from(t.getClientRects());
93
93
  }
94
- function Y(t) {
95
- return L(C(t)).left + H(t).scrollLeft;
94
+ function S(t, e) {
95
+ const n = H(t).scrollLeft;
96
+ return e ? e.left + n : T(b(t)).left + n;
96
97
  }
97
98
  function dt(t) {
98
- const e = C(t), n = H(t), i = t.ownerDocument.body, o = T(e.scrollWidth, e.clientWidth, i.scrollWidth, i.clientWidth), c = T(e.scrollHeight, e.clientHeight, i.scrollHeight, i.clientHeight);
99
- let s = -n.scrollLeft + Y(t);
99
+ const e = b(t), n = H(t), i = t.ownerDocument.body, o = E(e.scrollWidth, e.clientWidth, i.scrollWidth, i.clientWidth), c = E(e.scrollHeight, e.clientHeight, i.scrollHeight, i.clientHeight);
100
+ let s = -n.scrollLeft + S(t);
100
101
  const r = -n.scrollTop;
101
- return y(i).direction === "rtl" && (s += T(e.clientWidth, i.clientWidth) - o), {
102
+ return x(i).direction === "rtl" && (s += E(e.clientWidth, i.clientWidth) - o), {
102
103
  width: o,
103
104
  height: c,
104
105
  x: s,
@@ -106,36 +107,36 @@ function dt(t) {
106
107
  };
107
108
  }
108
109
  function gt(t, e) {
109
- const n = E(t), i = C(t), o = n.visualViewport;
110
- let c = i.clientWidth, s = i.clientHeight, r = 0, l = 0;
110
+ const n = L(t), i = b(t), o = n.visualViewport;
111
+ let c = i.clientWidth, s = i.clientHeight, r = 0, f = 0;
111
112
  if (o) {
112
113
  c = o.width, s = o.height;
113
- const f = j();
114
- (!f || f && e === "fixed") && (r = o.offsetLeft, l = o.offsetTop);
114
+ const l = j();
115
+ (!l || l && e === "fixed") && (r = o.offsetLeft, f = o.offsetTop);
115
116
  }
116
117
  return {
117
118
  width: c,
118
119
  height: s,
119
120
  x: r,
120
- y: l
121
+ y: f
121
122
  };
122
123
  }
123
124
  function pt(t, e) {
124
- const n = L(t, !0, e === "fixed"), i = n.top + t.clientTop, o = n.left + t.clientLeft, c = R(t) ? F(t) : b(1), s = t.clientWidth * c.x, r = t.clientHeight * c.y, l = o * c.x, f = i * c.y;
125
+ const n = T(t, !0, e === "fixed"), i = n.top + t.clientTop, o = n.left + t.clientLeft, c = C(t) ? F(t) : R(1), s = t.clientWidth * c.x, r = t.clientHeight * c.y, f = o * c.x, l = i * c.y;
125
126
  return {
126
127
  width: s,
127
128
  height: r,
128
- x: l,
129
- y: f
129
+ x: f,
130
+ y: l
130
131
  };
131
132
  }
132
- function K(t, e, n) {
133
+ function X(t, e, n) {
133
134
  let i;
134
135
  if (e === "viewport")
135
136
  i = gt(t, n);
136
137
  else if (e === "document")
137
- i = dt(C(t));
138
- else if (x(e))
138
+ i = dt(b(t));
139
+ else if (y(e))
139
140
  i = pt(e, n);
140
141
  else {
141
142
  const o = Q(t);
@@ -145,22 +146,22 @@ function K(t, e, n) {
145
146
  y: e.y - o.y
146
147
  };
147
148
  }
148
- return X(i);
149
+ return Y(i);
149
150
  }
150
151
  function Z(t, e) {
151
152
  const n = W(t);
152
- return n === e || !x(n) || N(n) ? !1 : y(n).position === "fixed" || Z(n, e);
153
+ return n === e || !y(n) || N(n) ? !1 : x(n).position === "fixed" || Z(n, e);
153
154
  }
154
155
  function wt(t, e) {
155
156
  const n = e.get(t);
156
157
  if (n)
157
158
  return n;
158
- let i = $(t, [], !1).filter((r) => x(r) && M(r) !== "body"), o = null;
159
- const c = y(t).position === "fixed";
159
+ let i = $(t, [], !1).filter((r) => y(r) && _(r) !== "body"), o = null;
160
+ const c = x(t).position === "fixed";
160
161
  let s = c ? W(t) : t;
161
- for (; x(s) && !N(s); ) {
162
- const r = y(s), l = G(s);
163
- !l && r.position === "fixed" && (o = null), (c ? !l && !o : !l && r.position === "static" && !!o && ["absolute", "fixed"].includes(o.position) || _(s) && !l && Z(t, s)) ? i = i.filter((u) => u !== s) : o = r, s = W(s);
162
+ for (; y(s) && !N(s); ) {
163
+ const r = x(s), f = G(s);
164
+ !f && r.position === "fixed" && (o = null), (c ? !f && !o : !f && r.position === "static" && !!o && ["absolute", "fixed"].includes(o.position) || k(s) && !f && Z(t, s)) ? i = i.filter((u) => u !== s) : o = r, s = W(s);
164
165
  }
165
166
  return e.set(t, i), i;
166
167
  }
@@ -171,15 +172,15 @@ function mt(t) {
171
172
  rootBoundary: i,
172
173
  strategy: o
173
174
  } = t;
174
- const s = [...n === "clippingAncestors" ? S(e) ? [] : wt(e, this._c) : [].concat(n), i], r = s[0], l = s.reduce((f, u) => {
175
- const h = K(e, u, o);
176
- return f.top = T(h.top, f.top), f.right = z(h.right, f.right), f.bottom = z(h.bottom, f.bottom), f.left = T(h.left, f.left), f;
177
- }, K(e, r, o));
175
+ const s = [...n === "clippingAncestors" ? M(e) ? [] : wt(e, this._c) : [].concat(n), i], r = s[0], f = s.reduce((l, u) => {
176
+ const a = X(e, u, o);
177
+ return l.top = E(a.top, l.top), l.right = z(a.right, l.right), l.bottom = z(a.bottom, l.bottom), l.left = E(a.left, l.left), l;
178
+ }, X(e, r, o));
178
179
  return {
179
- width: l.right - l.left,
180
- height: l.bottom - l.top,
181
- x: l.left,
182
- y: l.top
180
+ width: f.right - f.left,
181
+ height: f.bottom - f.top,
182
+ x: f.left,
183
+ y: f.top
183
184
  };
184
185
  }
185
186
  function vt(t) {
@@ -192,54 +193,65 @@ function vt(t) {
192
193
  height: n
193
194
  };
194
195
  }
195
- function xt(t, e, n) {
196
- const i = R(e), o = C(e), c = n === "fixed", s = L(t, !0, c, e);
196
+ function yt(t, e, n) {
197
+ const i = C(e), o = b(e), c = n === "fixed", s = T(t, !0, c, e);
197
198
  let r = {
198
199
  scrollLeft: 0,
199
200
  scrollTop: 0
200
201
  };
201
- const l = b(0);
202
+ const f = R(0);
202
203
  if (i || !i && !c)
203
- if ((M(e) !== "body" || _(o)) && (r = H(e)), i) {
204
- const h = L(e, !0, c, e);
205
- l.x = h.x + e.clientLeft, l.y = h.y + e.clientTop;
206
- } else o && (l.x = Y(o));
207
- const f = s.left + r.scrollLeft - l.x, u = s.top + r.scrollTop - l.y;
204
+ if ((_(e) !== "body" || k(o)) && (r = H(e)), i) {
205
+ const h = T(e, !0, c, e);
206
+ f.x = h.x + e.clientLeft, f.y = h.y + e.clientTop;
207
+ } else o && (f.x = S(o));
208
+ let l = 0, u = 0;
209
+ if (o && !i && !c) {
210
+ const h = o.getBoundingClientRect();
211
+ u = h.top + r.scrollTop, l = h.left + r.scrollLeft - // RTL <body> scrollbar.
212
+ S(o, h);
213
+ }
214
+ const a = s.left + r.scrollLeft - f.x - l, p = s.top + r.scrollTop - f.y - u;
208
215
  return {
209
- x: f,
210
- y: u,
216
+ x: a,
217
+ y: p,
211
218
  width: s.width,
212
219
  height: s.height
213
220
  };
214
221
  }
215
222
  function V(t) {
216
- return y(t).position === "static";
223
+ return x(t).position === "static";
217
224
  }
218
- function P(t, e) {
219
- return !R(t) || y(t).position === "fixed" ? null : e ? e(t) : t.offsetParent;
225
+ function K(t, e) {
226
+ if (!C(t) || x(t).position === "fixed")
227
+ return null;
228
+ if (e)
229
+ return e(t);
230
+ let n = t.offsetParent;
231
+ return b(t) === n && (n = n.ownerDocument.body), n;
220
232
  }
221
233
  function tt(t, e) {
222
- const n = E(t);
223
- if (S(t))
234
+ const n = L(t);
235
+ if (M(t))
224
236
  return n;
225
- if (!R(t)) {
237
+ if (!C(t)) {
226
238
  let o = W(t);
227
239
  for (; o && !N(o); ) {
228
- if (x(o) && !V(o))
240
+ if (y(o) && !V(o))
229
241
  return o;
230
242
  o = W(o);
231
243
  }
232
244
  return n;
233
245
  }
234
- let i = P(t, e);
246
+ let i = K(t, e);
235
247
  for (; i && ct(i) && V(i); )
236
- i = P(i, e);
248
+ i = K(i, e);
237
249
  return i && N(i) && V(i) && !G(i) ? n : i || lt(t) || n;
238
250
  }
239
- const yt = async function(t) {
251
+ const xt = async function(t) {
240
252
  const e = this.getOffsetParent || tt, n = this.getDimensions, i = await n(t.floating);
241
253
  return {
242
- reference: xt(t.reference, await e(t.floating), t.strategy),
254
+ reference: yt(t.reference, await e(t.floating), t.strategy),
243
255
  floating: {
244
256
  x: 0,
245
257
  y: 0,
@@ -249,45 +261,45 @@ const yt = async function(t) {
249
261
  };
250
262
  };
251
263
  function bt(t) {
252
- return y(t).direction === "rtl";
264
+ return x(t).direction === "rtl";
253
265
  }
254
266
  const Rt = {
255
267
  convertOffsetParentRelativeRectToViewportRelativeRect: ht,
256
- getDocumentElement: C,
268
+ getDocumentElement: b,
257
269
  getClippingRect: mt,
258
270
  getOffsetParent: tt,
259
- getElementRects: yt,
271
+ getElementRects: xt,
260
272
  getClientRects: at,
261
273
  getDimensions: vt,
262
274
  getScale: F,
263
- isElement: x,
275
+ isElement: y,
264
276
  isRTL: bt
265
277
  };
266
278
  function Ct(t, e) {
267
279
  let n = null, i;
268
- const o = C(t);
280
+ const o = b(t);
269
281
  function c() {
270
282
  var r;
271
283
  clearTimeout(i), (r = n) == null || r.disconnect(), n = null;
272
284
  }
273
- function s(r, l) {
274
- r === void 0 && (r = !1), l === void 0 && (l = 1), c();
285
+ function s(r, f) {
286
+ r === void 0 && (r = !1), f === void 0 && (f = 1), c();
275
287
  const {
276
- left: f,
288
+ left: l,
277
289
  top: u,
278
- width: h,
279
- height: m
290
+ width: a,
291
+ height: p
280
292
  } = t.getBoundingClientRect();
281
- if (r || e(), !h || !m)
293
+ if (r || e(), !a || !p)
282
294
  return;
283
- const g = A(u), v = A(o.clientWidth - (f + h)), a = A(o.clientHeight - (u + m)), p = A(f), w = {
284
- rootMargin: -g + "px " + -v + "px " + -a + "px " + -p + "px",
285
- threshold: T(0, z(1, l)) || 1
295
+ const h = D(u), v = D(o.clientWidth - (l + a)), d = D(o.clientHeight - (u + p)), w = D(l), m = {
296
+ rootMargin: -h + "px " + -v + "px " + -d + "px " + -w + "px",
297
+ threshold: E(0, z(1, f)) || 1
286
298
  };
287
299
  let O = !0;
288
- function B(q) {
289
- const I = q[0].intersectionRatio;
290
- if (I !== l) {
300
+ function B(P) {
301
+ const I = P[0].intersectionRatio;
302
+ if (I !== f) {
291
303
  if (!O)
292
304
  return s();
293
305
  I ? s(!1, I) : i = setTimeout(() => {
@@ -298,54 +310,54 @@ function Ct(t, e) {
298
310
  }
299
311
  try {
300
312
  n = new IntersectionObserver(B, {
301
- ...w,
313
+ ...m,
302
314
  // Handle <iframe>s
303
315
  root: o.ownerDocument
304
316
  });
305
317
  } catch {
306
- n = new IntersectionObserver(B, w);
318
+ n = new IntersectionObserver(B, m);
307
319
  }
308
320
  n.observe(t);
309
321
  }
310
322
  return s(!0), c;
311
323
  }
312
- function Tt(t, e, n, i) {
324
+ function Et(t, e, n, i) {
313
325
  i === void 0 && (i = {});
314
326
  const {
315
327
  ancestorScroll: o = !0,
316
328
  ancestorResize: c = !0,
317
329
  elementResize: s = typeof ResizeObserver == "function",
318
330
  layoutShift: r = typeof IntersectionObserver == "function",
319
- animationFrame: l = !1
320
- } = i, f = k(t), u = o || c ? [...f ? $(f) : [], ...$(e)] : [];
321
- u.forEach((d) => {
322
- o && d.addEventListener("scroll", n, {
331
+ animationFrame: f = !1
332
+ } = i, l = q(t), u = o || c ? [...l ? $(l) : [], ...$(e)] : [];
333
+ u.forEach((g) => {
334
+ o && g.addEventListener("scroll", n, {
323
335
  passive: !0
324
- }), c && d.addEventListener("resize", n);
336
+ }), c && g.addEventListener("resize", n);
325
337
  });
326
- const h = f && r ? Ct(f, n) : null;
327
- let m = -1, g = null;
328
- s && (g = new ResizeObserver((d) => {
329
- let [w] = d;
330
- w && w.target === f && g && (g.unobserve(e), cancelAnimationFrame(m), m = requestAnimationFrame(() => {
338
+ const a = l && r ? Ct(l, n) : null;
339
+ let p = -1, h = null;
340
+ s && (h = new ResizeObserver((g) => {
341
+ let [m] = g;
342
+ m && m.target === l && h && (h.unobserve(e), cancelAnimationFrame(p), p = requestAnimationFrame(() => {
331
343
  var O;
332
- (O = g) == null || O.observe(e);
344
+ (O = h) == null || O.observe(e);
333
345
  })), n();
334
- }), f && !l && g.observe(f), g.observe(e));
335
- let v, a = l ? L(t) : null;
336
- l && p();
337
- function p() {
338
- const d = L(t);
339
- a && (d.x !== a.x || d.y !== a.y || d.width !== a.width || d.height !== a.height) && n(), a = d, v = requestAnimationFrame(p);
346
+ }), l && !f && h.observe(l), h.observe(e));
347
+ let v, d = f ? T(t) : null;
348
+ f && w();
349
+ function w() {
350
+ const g = T(t);
351
+ d && (g.x !== d.x || g.y !== d.y || g.width !== d.width || g.height !== d.height) && n(), d = g, v = requestAnimationFrame(w);
340
352
  }
341
353
  return n(), () => {
342
- var d;
343
- u.forEach((w) => {
344
- o && w.removeEventListener("scroll", n), c && w.removeEventListener("resize", n);
345
- }), h == null || h(), (d = g) == null || d.disconnect(), g = null, l && cancelAnimationFrame(v);
354
+ var g;
355
+ u.forEach((m) => {
356
+ o && m.removeEventListener("scroll", n), c && m.removeEventListener("resize", n);
357
+ }), a == null || a(), (g = h) == null || g.disconnect(), h = null, f && cancelAnimationFrame(v);
346
358
  };
347
359
  }
348
- const Ft = et, Wt = it, Bt = nt, At = st, Dt = ot, Nt = (t, e, n) => {
360
+ const Ft = et, Wt = nt, Bt = it, Dt = st, At = ot, Nt = (t, e, n) => {
349
361
  const i = /* @__PURE__ */ new Map(), o = {
350
362
  platform: Rt,
351
363
  ...n
@@ -359,12 +371,12 @@ const Ft = et, Wt = it, Bt = nt, At = st, Dt = ot, Nt = (t, e, n) => {
359
371
  });
360
372
  };
361
373
  export {
362
- At as arrow,
363
- Tt as autoUpdate,
374
+ Dt as arrow,
375
+ Et as autoUpdate,
364
376
  Nt as computePosition,
365
377
  Bt as flip,
366
378
  $ as getOverflowAncestors,
367
- Dt as inline,
379
+ At as inline,
368
380
  Ft as offset,
369
381
  Rt as platform,
370
382
  Wt as shift