@annotorious/react 3.0.21 → 3.0.22

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