@annotorious/react 3.4.4 → 3.4.5

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,10 +1,10 @@
1
- import { evaluate as X, rectToClientRect as I, getPaddingObject as W, getSide as Y, getSideAxis as F, getOppositePlacement as U, getExpandedPlacements as Z, getOppositeAxisPlacements as tt, getAlignmentSides as et, clamp as z, min as $, max as H, getAlignment as _, getOppositeAxis as nt, getAlignmentAxis as G, getAxisLength as J } from "./annotorious-react.es23.js";
2
- function q(o, c, l) {
1
+ import { evaluate as Y, rectToClientRect as $, getPaddingObject as H, getSide as M, getSideAxis as j, getOppositePlacement as Q, getExpandedPlacements as U, getOppositeAxisPlacements as Z, getAlignmentSides as tt, clamp as _, min as X, max as z, getAlignment as I, getOppositeAxis as et, getAlignmentAxis as q, getAxisLength as G } from "./annotorious-react.es23.js";
2
+ function W(o, c, l) {
3
3
  let {
4
4
  reference: e,
5
5
  floating: s
6
6
  } = o;
7
- const t = F(c), a = G(c), r = J(a), d = Y(c), g = t === "y", u = e.x + e.width / 2 - s.width / 2, n = e.y + e.height / 2 - s.height / 2, m = e[r] / 2 - s[r] / 2;
7
+ const t = j(c), a = q(c), r = G(a), d = M(c), g = t === "y", u = e.x + e.width / 2 - s.width / 2, n = e.y + e.height / 2 - s.height / 2, m = e[r] / 2 - s[r] / 2;
8
8
  let i;
9
9
  switch (d) {
10
10
  case "top":
@@ -37,7 +37,7 @@ function q(o, c, l) {
37
37
  y: e.y
38
38
  };
39
39
  }
40
- switch (_(c)) {
40
+ switch (I(c)) {
41
41
  case "start":
42
42
  i[a] -= m * (l && g ? -1 : 1);
43
43
  break;
@@ -47,7 +47,7 @@ function q(o, c, l) {
47
47
  }
48
48
  return i;
49
49
  }
50
- const ct = async (o, c, l) => {
50
+ const st = async (o, c, l) => {
51
51
  const {
52
52
  placement: e = "bottom",
53
53
  strategy: s = "absolute",
@@ -61,17 +61,17 @@ const ct = async (o, c, l) => {
61
61
  }), {
62
62
  x: u,
63
63
  y: n
64
- } = q(g, e, d), m = e, i = {}, f = 0;
65
- for (let h = 0; h < r.length; h++) {
64
+ } = W(g, e, d), m = e, i = {}, f = 0;
65
+ for (let p = 0; p < r.length; p++) {
66
66
  const {
67
67
  name: x,
68
- fn: y
69
- } = r[h], {
70
- x: v,
68
+ fn: v
69
+ } = r[p], {
70
+ x: h,
71
71
  y: A,
72
- data: b,
73
- reset: p
74
- } = await y({
72
+ data: R,
73
+ reset: w
74
+ } = await v({
75
75
  x: u,
76
76
  y: n,
77
77
  initialPlacement: e,
@@ -85,20 +85,20 @@ const ct = async (o, c, l) => {
85
85
  floating: c
86
86
  }
87
87
  });
88
- u = v ?? u, n = A ?? n, i = {
88
+ u = h ?? u, n = A ?? n, i = {
89
89
  ...i,
90
90
  [x]: {
91
91
  ...i[x],
92
- ...b
92
+ ...R
93
93
  }
94
- }, p && f <= 50 && (f++, typeof p == "object" && (p.placement && (m = p.placement), p.rects && (g = p.rects === !0 ? await a.getElementRects({
94
+ }, w && f <= 50 && (f++, typeof w == "object" && (w.placement && (m = w.placement), w.rects && (g = w.rects === !0 ? await a.getElementRects({
95
95
  reference: o,
96
96
  floating: c,
97
97
  strategy: s
98
- }) : p.rects), {
98
+ }) : w.rects), {
99
99
  x: u,
100
100
  y: n
101
- } = q(g, m, d)), h = -1);
101
+ } = W(g, m, d)), p = -1);
102
102
  }
103
103
  return {
104
104
  x: u,
@@ -108,7 +108,7 @@ const ct = async (o, c, l) => {
108
108
  middlewareData: i
109
109
  };
110
110
  };
111
- async function K(o, c) {
111
+ async function J(o, c) {
112
112
  var l;
113
113
  c === void 0 && (c = {});
114
114
  const {
@@ -124,36 +124,36 @@ async function K(o, c) {
124
124
  elementContext: n = "floating",
125
125
  altBoundary: m = !1,
126
126
  padding: i = 0
127
- } = X(c, o), f = W(i), x = r[m ? n === "floating" ? "reference" : "floating" : n], y = I(await t.getClippingRect({
127
+ } = Y(c, o), f = H(i), x = r[m ? n === "floating" ? "reference" : "floating" : n], v = $(await t.getClippingRect({
128
128
  element: (l = await (t.isElement == null ? void 0 : t.isElement(x))) == null || l ? x : x.contextElement || await (t.getDocumentElement == null ? void 0 : t.getDocumentElement(r.floating)),
129
129
  boundary: g,
130
130
  rootBoundary: u,
131
131
  strategy: d
132
- })), v = n === "floating" ? {
132
+ })), h = n === "floating" ? {
133
133
  x: e,
134
134
  y: s,
135
135
  width: a.floating.width,
136
136
  height: a.floating.height
137
- } : a.reference, A = await (t.getOffsetParent == null ? void 0 : t.getOffsetParent(r.floating)), b = await (t.isElement == null ? void 0 : t.isElement(A)) ? await (t.getScale == null ? void 0 : t.getScale(A)) || {
137
+ } : a.reference, A = await (t.getOffsetParent == null ? void 0 : t.getOffsetParent(r.floating)), R = await (t.isElement == null ? void 0 : t.isElement(A)) ? await (t.getScale == null ? void 0 : t.getScale(A)) || {
138
138
  x: 1,
139
139
  y: 1
140
140
  } : {
141
141
  x: 1,
142
142
  y: 1
143
- }, p = I(t.convertOffsetParentRelativeRectToViewportRelativeRect ? await t.convertOffsetParentRelativeRectToViewportRelativeRect({
143
+ }, w = $(t.convertOffsetParentRelativeRectToViewportRelativeRect ? await t.convertOffsetParentRelativeRectToViewportRelativeRect({
144
144
  elements: r,
145
- rect: v,
145
+ rect: h,
146
146
  offsetParent: A,
147
147
  strategy: d
148
- }) : v);
148
+ }) : h);
149
149
  return {
150
- top: (y.top - p.top + f.top) / b.y,
151
- bottom: (p.bottom - y.bottom + f.bottom) / b.y,
152
- left: (y.left - p.left + f.left) / b.x,
153
- right: (p.right - y.right + f.right) / b.x
150
+ top: (v.top - w.top + f.top) / R.y,
151
+ bottom: (w.bottom - v.bottom + f.bottom) / R.y,
152
+ left: (v.left - w.left + f.left) / R.x,
153
+ right: (w.right - v.right + f.right) / R.x
154
154
  };
155
155
  }
156
- const lt = (o) => ({
156
+ const ct = (o) => ({
157
157
  name: "arrow",
158
158
  options: o,
159
159
  async fn(c) {
@@ -168,29 +168,29 @@ const lt = (o) => ({
168
168
  } = c, {
169
169
  element: g,
170
170
  padding: u = 0
171
- } = X(o, c) || {};
171
+ } = Y(o, c) || {};
172
172
  if (g == null)
173
173
  return {};
174
- const n = W(u), m = {
174
+ const n = H(u), m = {
175
175
  x: l,
176
176
  y: e
177
- }, i = G(s), f = J(i), h = await a.getDimensions(g), x = i === "y", y = x ? "top" : "left", v = x ? "bottom" : "right", A = x ? "clientHeight" : "clientWidth", b = t.reference[f] + t.reference[i] - m[i] - t.floating[f], p = m[i] - t.reference[i], C = await (a.getOffsetParent == null ? void 0 : a.getOffsetParent(g));
178
- let k = C ? C[A] : 0;
179
- (!k || !await (a.isElement == null ? void 0 : a.isElement(C))) && (k = r.floating[A] || t.floating[f]);
180
- const j = b / 2 - p / 2, L = k / 2 - h[f] / 2 - 1, w = $(n[y], L), B = $(n[v], L), S = w, M = k - h[f] - B, P = k / 2 - h[f] / 2 + j, R = z(S, P, M), E = !d.arrow && _(s) != null && P !== R && t.reference[f] / 2 - (P < S ? w : B) - h[f] / 2 < 0, O = E ? P < S ? P - S : P - M : 0;
177
+ }, i = q(s), f = G(i), p = await a.getDimensions(g), x = i === "y", v = x ? "top" : "left", h = x ? "bottom" : "right", A = x ? "clientHeight" : "clientWidth", R = t.reference[f] + t.reference[i] - m[i] - t.floating[f], w = m[i] - t.reference[i], S = await (a.getOffsetParent == null ? void 0 : a.getOffsetParent(g));
178
+ let D = S ? S[A] : 0;
179
+ (!D || !await (a.isElement == null ? void 0 : a.isElement(S))) && (D = r.floating[A] || t.floating[f]);
180
+ const F = R / 2 - w / 2, T = D / 2 - p[f] / 2 - 1, y = X(n[v], T), L = X(n[h], T), E = y, B = D - p[f] - L, b = D / 2 - p[f] / 2 + F, k = _(E, b, B), C = !d.arrow && I(s) != null && b !== k && t.reference[f] / 2 - (b < E ? y : L) - p[f] / 2 < 0, P = C ? b < E ? b - E : b - B : 0;
181
181
  return {
182
- [i]: m[i] + O,
182
+ [i]: m[i] + P,
183
183
  data: {
184
- [i]: R,
185
- centerOffset: P - R - O,
186
- ...E && {
187
- alignmentOffset: O
184
+ [i]: k,
185
+ centerOffset: b - k - P,
186
+ ...C && {
187
+ alignmentOffset: P
188
188
  }
189
189
  },
190
- reset: E
190
+ reset: C
191
191
  };
192
192
  }
193
- }), at = function(o) {
193
+ }), lt = function(o) {
194
194
  return o === void 0 && (o = {}), {
195
195
  name: "flip",
196
196
  options: o,
@@ -209,64 +209,62 @@ const lt = (o) => ({
209
209
  fallbackPlacements: m,
210
210
  fallbackStrategy: i = "bestFit",
211
211
  fallbackAxisSideDirection: f = "none",
212
- flipAlignment: h = !0,
212
+ flipAlignment: p = !0,
213
213
  ...x
214
- } = X(o, c);
214
+ } = Y(o, c);
215
215
  if ((l = t.arrow) != null && l.alignmentOffset)
216
216
  return {};
217
- const y = Y(s), v = F(r), A = Y(r) === r, b = await (d.isRTL == null ? void 0 : d.isRTL(g.floating)), p = m || (A || !h ? [U(r)] : Z(r)), C = f !== "none";
218
- !m && C && p.push(...tt(r, h, f, b));
219
- const k = [r, ...p], j = await K(c, x), L = [];
220
- let w = ((e = t.flip) == null ? void 0 : e.overflows) || [];
221
- if (u && L.push(j[y]), n) {
222
- const R = et(s, a, b);
223
- L.push(j[R[0]], j[R[1]]);
217
+ const v = M(s), h = j(r), A = M(r) === r, R = await (d.isRTL == null ? void 0 : d.isRTL(g.floating)), w = m || (A || !p ? [Q(r)] : U(r)), S = f !== "none";
218
+ !m && S && w.push(...Z(r, p, f, R));
219
+ const D = [r, ...w], F = await J(c, x), T = [];
220
+ let y = ((e = t.flip) == null ? void 0 : e.overflows) || [];
221
+ if (u && T.push(F[v]), n) {
222
+ const b = tt(s, a, R);
223
+ T.push(F[b[0]], F[b[1]]);
224
224
  }
225
- if (w = [...w, {
225
+ if (y = [...y, {
226
226
  placement: s,
227
- overflows: L
228
- }], !L.every((R) => R <= 0)) {
229
- var B, S;
230
- const R = (((B = t.flip) == null ? void 0 : B.index) || 0) + 1, E = k[R];
231
- if (E) {
232
- var M;
233
- const D = n === "alignment" ? v !== F(E) : !1, T = ((M = w[0]) == null ? void 0 : M.overflows[0]) > 0;
234
- if (!D || T)
235
- return {
236
- data: {
237
- index: R,
238
- overflows: w
239
- },
240
- reset: {
241
- placement: E
242
- }
243
- };
244
- }
245
- let O = (S = w.filter((D) => D.overflows[0] <= 0).sort((D, T) => D.overflows[1] - T.overflows[1])[0]) == null ? void 0 : S.placement;
246
- if (!O)
227
+ overflows: T
228
+ }], !T.every((b) => b <= 0)) {
229
+ var L, E;
230
+ const b = (((L = t.flip) == null ? void 0 : L.index) || 0) + 1, k = D[b];
231
+ if (k && (!(n === "alignment" ? h !== j(k) : !1) || // We leave the current main axis only if every placement on that axis
232
+ // overflows the main axis.
233
+ y.every((O) => O.overflows[0] > 0 && j(O.placement) === h)))
234
+ return {
235
+ data: {
236
+ index: b,
237
+ overflows: y
238
+ },
239
+ reset: {
240
+ placement: k
241
+ }
242
+ };
243
+ let C = (E = y.filter((P) => P.overflows[0] <= 0).sort((P, O) => P.overflows[1] - O.overflows[1])[0]) == null ? void 0 : E.placement;
244
+ if (!C)
247
245
  switch (i) {
248
246
  case "bestFit": {
249
- var P;
250
- const D = (P = w.filter((T) => {
251
- if (C) {
252
- const V = F(T.placement);
253
- return V === v || // Create a bias to the `y` side axis due to horizontal
247
+ var B;
248
+ const P = (B = y.filter((O) => {
249
+ if (S) {
250
+ const V = j(O.placement);
251
+ return V === h || // Create a bias to the `y` side axis due to horizontal
254
252
  // reading directions favoring greater width.
255
253
  V === "y";
256
254
  }
257
255
  return !0;
258
- }).map((T) => [T.placement, T.overflows.filter((V) => V > 0).reduce((V, Q) => V + Q, 0)]).sort((T, V) => T[1] - V[1])[0]) == null ? void 0 : P[0];
259
- D && (O = D);
256
+ }).map((O) => [O.placement, O.overflows.filter((V) => V > 0).reduce((V, N) => V + N, 0)]).sort((O, V) => O[1] - V[1])[0]) == null ? void 0 : B[0];
257
+ P && (C = P);
260
258
  break;
261
259
  }
262
260
  case "initialPlacement":
263
- O = r;
261
+ C = r;
264
262
  break;
265
263
  }
266
- if (s !== O)
264
+ if (s !== C)
267
265
  return {
268
266
  reset: {
269
- placement: O
267
+ placement: C
270
268
  }
271
269
  };
272
270
  }
@@ -274,8 +272,8 @@ const lt = (o) => ({
274
272
  }
275
273
  };
276
274
  };
277
- function N(o) {
278
- const c = $(...o.map((t) => t.left)), l = $(...o.map((t) => t.top)), e = H(...o.map((t) => t.right)), s = H(...o.map((t) => t.bottom));
275
+ function K(o) {
276
+ const c = X(...o.map((t) => t.left)), l = X(...o.map((t) => t.top)), e = z(...o.map((t) => t.right)), s = z(...o.map((t) => t.bottom));
279
277
  return {
280
278
  x: c,
281
279
  y: l,
@@ -283,16 +281,16 @@ function N(o) {
283
281
  height: s - l
284
282
  };
285
283
  }
286
- function it(o) {
284
+ function nt(o) {
287
285
  const c = o.slice().sort((s, t) => s.y - t.y), l = [];
288
286
  let e = null;
289
287
  for (let s = 0; s < c.length; s++) {
290
288
  const t = c[s];
291
289
  !e || t.y - e.y > e.height / 2 ? l.push([t]) : l[l.length - 1].push(t), e = t;
292
290
  }
293
- return l.map((s) => I(N(s)));
291
+ return l.map((s) => $(K(s)));
294
292
  }
295
- const rt = function(o) {
293
+ const at = function(o) {
296
294
  return o === void 0 && (o = {}), {
297
295
  name: "inline",
298
296
  options: o,
@@ -307,59 +305,59 @@ const rt = function(o) {
307
305
  padding: r = 2,
308
306
  x: d,
309
307
  y: g
310
- } = X(o, c), u = Array.from(await (t.getClientRects == null ? void 0 : t.getClientRects(e.reference)) || []), n = it(u), m = I(N(u)), i = W(r);
308
+ } = Y(o, c), u = Array.from(await (t.getClientRects == null ? void 0 : t.getClientRects(e.reference)) || []), n = nt(u), m = $(K(u)), i = H(r);
311
309
  function f() {
312
310
  if (n.length === 2 && n[0].left > n[1].right && d != null && g != null)
313
311
  return n.find((x) => d > x.left - i.left && d < x.right + i.right && g > x.top - i.top && g < x.bottom + i.bottom) || m;
314
312
  if (n.length >= 2) {
315
- if (F(l) === "y") {
316
- const w = n[0], B = n[n.length - 1], S = Y(l) === "top", M = w.top, P = B.bottom, R = S ? w.left : B.left, E = S ? w.right : B.right, O = E - R, D = P - M;
313
+ if (j(l) === "y") {
314
+ const y = n[0], L = n[n.length - 1], E = M(l) === "top", B = y.top, b = L.bottom, k = E ? y.left : L.left, C = E ? y.right : L.right, P = C - k, O = b - B;
317
315
  return {
318
- top: M,
319
- bottom: P,
320
- left: R,
321
- right: E,
322
- width: O,
323
- height: D,
324
- x: R,
325
- y: M
316
+ top: B,
317
+ bottom: b,
318
+ left: k,
319
+ right: C,
320
+ width: P,
321
+ height: O,
322
+ x: k,
323
+ y: B
326
324
  };
327
325
  }
328
- const x = Y(l) === "left", y = H(...n.map((w) => w.right)), v = $(...n.map((w) => w.left)), A = n.filter((w) => x ? w.left === v : w.right === y), b = A[0].top, p = A[A.length - 1].bottom, C = v, k = y, j = k - C, L = p - b;
326
+ const x = M(l) === "left", v = z(...n.map((y) => y.right)), h = X(...n.map((y) => y.left)), A = n.filter((y) => x ? y.left === h : y.right === v), R = A[0].top, w = A[A.length - 1].bottom, S = h, D = v, F = D - S, T = w - R;
329
327
  return {
330
- top: b,
331
- bottom: p,
332
- left: C,
333
- right: k,
334
- width: j,
335
- height: L,
336
- x: C,
337
- y: b
328
+ top: R,
329
+ bottom: w,
330
+ left: S,
331
+ right: D,
332
+ width: F,
333
+ height: T,
334
+ x: S,
335
+ y: R
338
336
  };
339
337
  }
340
338
  return m;
341
339
  }
342
- const h = await t.getElementRects({
340
+ const p = await t.getElementRects({
343
341
  reference: {
344
342
  getBoundingClientRect: f
345
343
  },
346
344
  floating: e.floating,
347
345
  strategy: a
348
346
  });
349
- return s.reference.x !== h.reference.x || s.reference.y !== h.reference.y || s.reference.width !== h.reference.width || s.reference.height !== h.reference.height ? {
347
+ return s.reference.x !== p.reference.x || s.reference.y !== p.reference.y || s.reference.width !== p.reference.width || s.reference.height !== p.reference.height ? {
350
348
  reset: {
351
- rects: h
349
+ rects: p
352
350
  }
353
351
  } : {};
354
352
  }
355
353
  };
356
354
  };
357
- async function ot(o, c) {
355
+ async function it(o, c) {
358
356
  const {
359
357
  placement: l,
360
358
  platform: e,
361
359
  elements: s
362
- } = o, t = await (e.isRTL == null ? void 0 : e.isRTL(s.floating)), a = Y(l), r = _(l), d = F(l) === "y", g = ["left", "top"].includes(a) ? -1 : 1, u = t && d ? -1 : 1, n = X(c, o);
360
+ } = o, t = await (e.isRTL == null ? void 0 : e.isRTL(s.floating)), a = M(l), r = I(l), d = j(l) === "y", g = ["left", "top"].includes(a) ? -1 : 1, u = t && d ? -1 : 1, n = Y(c, o);
363
361
  let {
364
362
  mainAxis: m,
365
363
  crossAxis: i,
@@ -381,7 +379,7 @@ async function ot(o, c) {
381
379
  y: i * u
382
380
  };
383
381
  }
384
- const ft = function(o) {
382
+ const rt = function(o) {
385
383
  return o === void 0 && (o = 0), {
386
384
  name: "offset",
387
385
  options: o,
@@ -392,7 +390,7 @@ const ft = function(o) {
392
390
  y: t,
393
391
  placement: a,
394
392
  middlewareData: r
395
- } = c, d = await ot(c, o);
393
+ } = c, d = await it(c, o);
396
394
  return a === ((l = r.offset) == null ? void 0 : l.placement) && (e = r.arrow) != null && e.alignmentOffset ? {} : {
397
395
  x: s + d.x,
398
396
  y: t + d.y,
@@ -403,7 +401,7 @@ const ft = function(o) {
403
401
  };
404
402
  }
405
403
  };
406
- }, mt = function(o) {
404
+ }, ft = function(o) {
407
405
  return o === void 0 && (o = {}), {
408
406
  name: "shift",
409
407
  options: o,
@@ -418,39 +416,39 @@ const ft = function(o) {
418
416
  limiter: r = {
419
417
  fn: (x) => {
420
418
  let {
421
- x: y,
422
- y: v
419
+ x: v,
420
+ y: h
423
421
  } = x;
424
422
  return {
425
- x: y,
426
- y: v
423
+ x: v,
424
+ y: h
427
425
  };
428
426
  }
429
427
  },
430
428
  ...d
431
- } = X(o, c), g = {
429
+ } = Y(o, c), g = {
432
430
  x: l,
433
431
  y: e
434
- }, u = await K(c, d), n = F(Y(s)), m = nt(n);
432
+ }, u = await J(c, d), n = j(M(s)), m = et(n);
435
433
  let i = g[m], f = g[n];
436
434
  if (t) {
437
- const x = m === "y" ? "top" : "left", y = m === "y" ? "bottom" : "right", v = i + u[x], A = i - u[y];
438
- i = z(v, i, A);
435
+ const x = m === "y" ? "top" : "left", v = m === "y" ? "bottom" : "right", h = i + u[x], A = i - u[v];
436
+ i = _(h, i, A);
439
437
  }
440
438
  if (a) {
441
- const x = n === "y" ? "top" : "left", y = n === "y" ? "bottom" : "right", v = f + u[x], A = f - u[y];
442
- f = z(v, f, A);
439
+ const x = n === "y" ? "top" : "left", v = n === "y" ? "bottom" : "right", h = f + u[x], A = f - u[v];
440
+ f = _(h, f, A);
443
441
  }
444
- const h = r.fn({
442
+ const p = r.fn({
445
443
  ...c,
446
444
  [m]: i,
447
445
  [n]: f
448
446
  });
449
447
  return {
450
- ...h,
448
+ ...p,
451
449
  data: {
452
- x: h.x - l,
453
- y: h.y - e,
450
+ x: p.x - l,
451
+ y: p.y - e,
454
452
  enabled: {
455
453
  [m]: t,
456
454
  [n]: a
@@ -461,13 +459,13 @@ const ft = function(o) {
461
459
  };
462
460
  };
463
461
  export {
464
- lt as arrow,
465
- ct as computePosition,
466
- K as detectOverflow,
467
- at as flip,
468
- rt as inline,
469
- ft as offset,
470
- I as rectToClientRect,
471
- mt as shift
462
+ ct as arrow,
463
+ st as computePosition,
464
+ J as detectOverflow,
465
+ lt as flip,
466
+ at as inline,
467
+ rt as offset,
468
+ $ as rectToClientRect,
469
+ ft as shift
472
470
  };
473
471
  //# sourceMappingURL=annotorious-react.es24.js.map