@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
|
|
2
|
-
import { useLayoutEffect as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
|
|
8
|
-
import { arrow as
|
|
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
|
-
...
|
|
11
|
-
},
|
|
12
|
-
function
|
|
13
|
-
const n =
|
|
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
|
|
16
|
+
return J(() => {
|
|
18
17
|
n.current = t;
|
|
19
|
-
}),
|
|
20
|
-
for (var
|
|
21
|
-
e[
|
|
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
|
|
26
|
-
|
|
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) +
|
|
39
|
+
"floating-ui-" + Math.random().toString(36).slice(2, 6) + k++
|
|
31
40
|
);
|
|
32
41
|
function _() {
|
|
33
|
-
const [t, n] =
|
|
34
|
-
return
|
|
42
|
+
const [t, n] = o.useState(() => V ? W() : void 0);
|
|
43
|
+
return b(() => {
|
|
35
44
|
t == null && n(W());
|
|
36
|
-
}, []),
|
|
37
|
-
|
|
45
|
+
}, []), o.useEffect(() => {
|
|
46
|
+
V = !0;
|
|
38
47
|
}, []), t;
|
|
39
48
|
}
|
|
40
49
|
const ee = $.useId, B = ee || _;
|
|
41
|
-
let
|
|
42
|
-
process.env.NODE_ENV !== "production" && (
|
|
50
|
+
let P;
|
|
51
|
+
process.env.NODE_ENV !== "production" && (P = /* @__PURE__ */ new Set());
|
|
43
52
|
function te() {
|
|
44
|
-
for (var t, n = arguments.length,
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
if (!((t =
|
|
48
|
-
var
|
|
49
|
-
(
|
|
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,
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
if (!((t =
|
|
57
|
-
var
|
|
58
|
-
(
|
|
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
|
|
70
|
+
const me = /* @__PURE__ */ o.forwardRef(function(n, s) {
|
|
62
71
|
const {
|
|
63
72
|
context: {
|
|
64
73
|
placement: e,
|
|
65
74
|
elements: {
|
|
66
|
-
floating:
|
|
75
|
+
floating: r
|
|
67
76
|
},
|
|
68
77
|
middlewareData: {
|
|
69
|
-
arrow:
|
|
70
|
-
shift:
|
|
78
|
+
arrow: l,
|
|
79
|
+
shift: u
|
|
71
80
|
}
|
|
72
81
|
},
|
|
73
|
-
width:
|
|
74
|
-
height:
|
|
75
|
-
tipRadius:
|
|
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:
|
|
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" && (
|
|
87
|
-
const
|
|
88
|
-
if (
|
|
89
|
-
if (!
|
|
90
|
-
|
|
91
|
-
}, [
|
|
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,
|
|
102
|
+
const [m, F] = e.split("-"), M = m === "top" || m === "bottom";
|
|
94
103
|
let S = g;
|
|
95
|
-
(
|
|
96
|
-
const v = d * 2,
|
|
97
|
-
let
|
|
98
|
-
S &&
|
|
99
|
-
const H = (
|
|
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__ */
|
|
106
|
-
...x,
|
|
114
|
+
return /* @__PURE__ */ o.createElement("svg", D({}, x, {
|
|
107
115
|
"aria-hidden": !0,
|
|
108
|
-
ref:
|
|
109
|
-
width: w ?
|
|
110
|
-
height:
|
|
111
|
-
viewBox: "0 0 " +
|
|
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
|
-
[
|
|
123
|
+
[j]: H,
|
|
116
124
|
[U]: X,
|
|
117
|
-
[m]:
|
|
118
|
-
transform: [Y, p].filter((
|
|
125
|
+
[m]: M || w ? "100%" : "calc(100% - " + v / 2 + "px)",
|
|
126
|
+
transform: [Y, p].filter((L) => !!L).join(" "),
|
|
119
127
|
...R
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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,
|
|
150
|
+
emit(n, s) {
|
|
145
151
|
var e;
|
|
146
|
-
(e = t.get(n)) == null || e.forEach((
|
|
152
|
+
(e = t.get(n)) == null || e.forEach((r) => r(s));
|
|
147
153
|
},
|
|
148
|
-
on(n,
|
|
149
|
-
t.set(n, [...t.get(n) || [],
|
|
154
|
+
on(n, s) {
|
|
155
|
+
t.set(n, [...t.get(n) || [], s]);
|
|
150
156
|
},
|
|
151
|
-
off(n,
|
|
157
|
+
off(n, s) {
|
|
152
158
|
var e;
|
|
153
|
-
t.set(n, ((e = t.get(n)) == null ? void 0 : e.filter((
|
|
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__ */
|
|
163
|
+
const re = /* @__PURE__ */ o.createContext(null), se = /* @__PURE__ */ o.createContext(null), ce = () => {
|
|
158
164
|
var t;
|
|
159
|
-
return ((t =
|
|
160
|
-
},
|
|
161
|
-
function
|
|
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:
|
|
170
|
+
onOpenChange: s,
|
|
165
171
|
elements: e
|
|
166
|
-
} = t,
|
|
172
|
+
} = t, r = B(), l = o.useRef({}), [u] = o.useState(() => oe()), i = ce() != null;
|
|
167
173
|
if (process.env.NODE_ENV !== "production") {
|
|
168
|
-
const
|
|
169
|
-
|
|
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 [
|
|
172
|
-
|
|
173
|
-
open:
|
|
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:
|
|
177
|
-
}),
|
|
178
|
-
}), g =
|
|
179
|
-
setPositionReference:
|
|
180
|
-
}), []), h =
|
|
181
|
-
reference:
|
|
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
|
-
}), [
|
|
185
|
-
return
|
|
186
|
-
dataRef:
|
|
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:
|
|
191
|
-
floatingId:
|
|
196
|
+
events: u,
|
|
197
|
+
floatingId: r,
|
|
192
198
|
refs: g
|
|
193
|
-
}), [n, d, h,
|
|
199
|
+
}), [n, d, h, u, r, g]);
|
|
194
200
|
}
|
|
195
|
-
function
|
|
201
|
+
function ge(t) {
|
|
196
202
|
t === void 0 && (t = {});
|
|
197
203
|
const {
|
|
198
204
|
nodeId: n
|
|
199
|
-
} = t,
|
|
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 ||
|
|
207
|
-
|
|
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
|
|
216
|
+
const c = z({
|
|
211
217
|
...t,
|
|
212
218
|
elements: {
|
|
213
|
-
...
|
|
214
|
-
...
|
|
215
|
-
reference:
|
|
219
|
+
...r,
|
|
220
|
+
...i && {
|
|
221
|
+
reference: i
|
|
216
222
|
}
|
|
217
223
|
}
|
|
218
|
-
}), p =
|
|
219
|
-
const m =
|
|
224
|
+
}), p = o.useCallback((f) => {
|
|
225
|
+
const m = I(f) ? {
|
|
220
226
|
getBoundingClientRect: () => f.getBoundingClientRect(),
|
|
221
227
|
contextElement: f
|
|
222
228
|
} : f;
|
|
223
|
-
|
|
224
|
-
}, [
|
|
225
|
-
(
|
|
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 && !
|
|
229
|
-
}, [
|
|
230
|
-
...
|
|
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
|
-
}), [
|
|
235
|
-
...
|
|
240
|
+
}), [c.refs, R, p]), E = o.useMemo(() => ({
|
|
241
|
+
...c.elements,
|
|
236
242
|
domReference: d
|
|
237
|
-
}), [
|
|
238
|
-
...
|
|
243
|
+
}), [c.elements, d]), C = o.useMemo(() => ({
|
|
244
|
+
...c,
|
|
239
245
|
...e,
|
|
240
246
|
refs: x,
|
|
241
|
-
elements:
|
|
247
|
+
elements: E,
|
|
242
248
|
nodeId: n
|
|
243
|
-
}), [
|
|
244
|
-
return
|
|
245
|
-
e.dataRef.current.floatingContext =
|
|
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 =
|
|
248
|
-
}),
|
|
249
|
-
...
|
|
250
|
-
context:
|
|
253
|
+
f && (f.context = C);
|
|
254
|
+
}), o.useMemo(() => ({
|
|
255
|
+
...c,
|
|
256
|
+
context: C,
|
|
251
257
|
refs: x,
|
|
252
|
-
elements:
|
|
253
|
-
}), [
|
|
258
|
+
elements: E
|
|
259
|
+
}), [c, x, E, C]);
|
|
254
260
|
}
|
|
255
261
|
export {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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
|
-
|
|
266
|
-
|
|
271
|
+
ie as useFloatingRootContext,
|
|
272
|
+
le as useFloatingTree,
|
|
267
273
|
B as useId
|
|
268
274
|
};
|
|
269
275
|
//# sourceMappingURL=annotorious-react.es13.js.map
|