@spear-ai/spectral 1.3.9 → 1.3.11
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.
- package/dist/.js +91 -0
- package/dist/Accordion/AccordionBase.js +233 -0
- package/dist/App.js +8 -0
- package/dist/Badge/BadgeBase.js +35 -0
- package/dist/Badge.js +7 -0
- package/dist/Button.js +99 -0
- package/dist/Card.js +35 -0
- package/dist/Checkbox/CheckboxBase.js +141 -0
- package/dist/Drawer.js +1293 -0
- package/dist/Icons/AnnotationsIcon.js +28 -0
- package/dist/Icons/CalendarIcon.js +60 -0
- package/dist/Icons/ClockIcon.js +40 -0
- package/dist/Icons/DeleteIcon.js +32 -0
- package/dist/Icons/DurationIcon.js +80 -0
- package/dist/Icons/EraserIcon.js +37 -0
- package/dist/Icons/GoToFirstIcon.js +40 -0
- package/dist/Icons/GoToLastIcon.js +40 -0
- package/dist/Icons/IconBase.js +33 -0
- package/dist/Icons/LabelIcon.js +27 -0
- package/dist/Icons/LassoIcon.js +50 -0
- package/dist/Icons/LineToolIcon.js +96 -0
- package/dist/Icons/LiveViewIcon.js +70 -0
- package/dist/Icons/LocationIcon.js +40 -0
- package/dist/Icons/MetadataIcon.js +28 -0
- package/dist/Icons/OntologyIcon.js +31 -0
- package/dist/Icons/PlayIcon.js +28 -0
- package/dist/Icons/PlusIcon.js +27 -0
- package/dist/Icons/ResetIcon.js +25 -0
- package/dist/Icons/ScissorsIcon.js +36 -0
- package/dist/Icons/TrashIcon.js +25 -0
- package/dist/Icons/UndoIcon.js +28 -0
- package/dist/Icons/ZoomAllIcon.js +28 -0
- package/dist/Icons/ZoomXIcon.js +41 -0
- package/dist/Icons/ZoomYIcon.js +41 -0
- package/dist/Icons/iconTypes.js +2 -0
- package/dist/Icons.js +51 -0
- package/dist/Label.js +13 -0
- package/dist/Popover.js +250 -0
- package/dist/RadioGroup/RadioGroupBase.js +254 -0
- package/dist/Skeleton.js +10 -0
- package/dist/Slider/SliderBase.js +315 -0
- package/dist/Slider.js +74 -0
- package/dist/Switch/SwitchBase.js +131 -0
- package/dist/Switch.js +59 -0
- package/dist/Toggle/ToggleBase.js +51 -0
- package/dist/Toggle.js +51 -0
- package/dist/ToggleGroup/ToggleGroupBase.js +125 -0
- package/dist/ToggleGroup.js +53 -0
- package/dist/Toolbar.js +13 -0
- package/dist/Tooltip/TooltipBase.js +225 -0
- package/dist/Tooltip.js +371 -0
- package/dist/features/LabelingTools/LabelingTools.d.ts.map +1 -0
- package/dist/features/LabelingTools.js +107 -0
- package/dist/hooks/useAccordionAutoScroll.js +65 -0
- package/dist/hooks/useOutsideClick.js +16 -0
- package/dist/hooks/useTheme.js +19 -0
- package/dist/index-B7LSgz_k.js +446 -0
- package/dist/index-CRBC94ik.js +34 -0
- package/dist/index-gg2zpNk0.js +672 -0
- package/dist/index-sDEISz8i.js +1558 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/loader-circle-Btf6jOd5.js +101 -0
- package/dist/main.js +25212 -0
- package/dist/primitives/label.js +27 -0
- package/dist/primitives/slot.js +40 -0
- package/dist/twUtils-CRiPKpXj.js +2743 -0
- package/dist/utils/refs.js +10 -0
- package/dist/utils/shared.js +29 -0
- package/dist/utils/twUtils.js +5 -0
- package/package.json +19 -15
- package/dist/components/LabelingTools/LabelingTools.d.ts.map +0 -1
- package/dist/index.js +0 -8443
- package/dist/spectral.cjs.js +0 -83
- /package/dist/{components → features}/LabelingTools/LabelingTools.d.ts +0 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import './assets/main.css'
|
|
2
|
+
import { jsx as D } from "react/jsx-runtime";
|
|
3
|
+
import { createForwardedRef as N } from "../utils/refs.js";
|
|
4
|
+
import { c as z } from "../twUtils-CRiPKpXj.js";
|
|
5
|
+
import { createContext as X, forwardRef as L, useMemo as Y, useRef as E, useEffect as k, useCallback as g, useState as I, useContext as M, useId as A } from "react";
|
|
6
|
+
import { createPortal as S } from "react-dom";
|
|
7
|
+
const F = X(null), V = L(function({
|
|
8
|
+
children: a,
|
|
9
|
+
delayDuration: u = 700,
|
|
10
|
+
skipDelayDuration: c = 300,
|
|
11
|
+
disableHoverableContent: d = !1
|
|
12
|
+
}) {
|
|
13
|
+
const l = Y(
|
|
14
|
+
() => ({ delayDuration: u, skipDelayDuration: c, disableHoverableContent: d }),
|
|
15
|
+
[u, c, d]
|
|
16
|
+
);
|
|
17
|
+
return /* @__PURE__ */ D(F.Provider, { value: l, children: a });
|
|
18
|
+
}), K = X(null), Z = ({
|
|
19
|
+
children: h,
|
|
20
|
+
open: a,
|
|
21
|
+
defaultOpen: u,
|
|
22
|
+
onOpenChange: c,
|
|
23
|
+
side: d = "top",
|
|
24
|
+
align: l = "center",
|
|
25
|
+
sideOffset: f = 0,
|
|
26
|
+
alignOffset: y = 0,
|
|
27
|
+
avoidCollisions: p = !0,
|
|
28
|
+
delayDuration: t
|
|
29
|
+
}) => {
|
|
30
|
+
const r = M(F) ?? {
|
|
31
|
+
delayDuration: 700,
|
|
32
|
+
skipDelayDuration: 300,
|
|
33
|
+
disableHoverableContent: !1
|
|
34
|
+
}, m = {
|
|
35
|
+
...r,
|
|
36
|
+
delayDuration: t ?? r.delayDuration
|
|
37
|
+
}, [e, o] = I(!!u), i = typeof a == "boolean", w = i ? a : e, v = g(
|
|
38
|
+
(x) => {
|
|
39
|
+
i || o(x), c?.(x);
|
|
40
|
+
},
|
|
41
|
+
[i, c]
|
|
42
|
+
), T = E(null), b = A(), C = Y(
|
|
43
|
+
() => ({
|
|
44
|
+
open: w,
|
|
45
|
+
setOpen: v,
|
|
46
|
+
triggerRef: T,
|
|
47
|
+
contentId: b,
|
|
48
|
+
options: { side: d, align: l, sideOffset: f, alignOffset: y, avoidCollisions: p },
|
|
49
|
+
provider: m,
|
|
50
|
+
arrowPadding: 4
|
|
51
|
+
}),
|
|
52
|
+
[w, v, d, l, f, y, p, m]
|
|
53
|
+
);
|
|
54
|
+
return /* @__PURE__ */ D(K.Provider, { value: C, children: h });
|
|
55
|
+
}, _ = L(function({ asChild: a, onPointerEnter: u, onPointerLeave: c, onFocus: d, onBlur: l, onKeyDown: f, ...y }, p) {
|
|
56
|
+
const t = H(), { provider: r } = t, m = N(t.triggerRef, p), e = E(null), o = E(null), i = E(0), w = () => {
|
|
57
|
+
e.current && window.clearTimeout(e.current), o.current && window.clearTimeout(o.current), e.current = null, o.current = null;
|
|
58
|
+
};
|
|
59
|
+
k(() => () => w(), []);
|
|
60
|
+
const v = g(() => {
|
|
61
|
+
const O = Date.now() - i.current < r.skipDelayDuration ? 0 : r.delayDuration;
|
|
62
|
+
e.current = window.setTimeout(() => t.setOpen(!0), O);
|
|
63
|
+
}, [r.skipDelayDuration, r.delayDuration, t.setOpen]), T = g(() => {
|
|
64
|
+
w(), t.setOpen(!1), i.current = Date.now();
|
|
65
|
+
}, [t.setOpen]), b = g(
|
|
66
|
+
(s) => {
|
|
67
|
+
u?.(s), (s.pointerType === "mouse" || s.pointerType === "pen") && v();
|
|
68
|
+
},
|
|
69
|
+
[u, v]
|
|
70
|
+
), C = g(
|
|
71
|
+
(s) => {
|
|
72
|
+
c?.(s), (s.pointerType === "mouse" || s.pointerType === "pen") && (o.current = window.setTimeout(() => t.setOpen(!1), 0));
|
|
73
|
+
},
|
|
74
|
+
[c, t.setOpen]
|
|
75
|
+
), x = g(
|
|
76
|
+
(s) => {
|
|
77
|
+
d?.(s), v();
|
|
78
|
+
},
|
|
79
|
+
[d, v]
|
|
80
|
+
), B = g(
|
|
81
|
+
(s) => {
|
|
82
|
+
l?.(s), T();
|
|
83
|
+
},
|
|
84
|
+
[l, T]
|
|
85
|
+
), P = g(
|
|
86
|
+
(s) => {
|
|
87
|
+
f?.(s), s.key === "Escape" && T();
|
|
88
|
+
},
|
|
89
|
+
[f, T]
|
|
90
|
+
);
|
|
91
|
+
return /* @__PURE__ */ D(
|
|
92
|
+
a ? "span" : "button",
|
|
93
|
+
{
|
|
94
|
+
...y,
|
|
95
|
+
ref: m,
|
|
96
|
+
"aria-describedby": t.open ? t.contentId : void 0,
|
|
97
|
+
onPointerEnter: b,
|
|
98
|
+
onPointerLeave: C,
|
|
99
|
+
onFocus: x,
|
|
100
|
+
onBlur: B,
|
|
101
|
+
onKeyDown: P
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
}), tt = L(function({
|
|
105
|
+
className: a,
|
|
106
|
+
style: u,
|
|
107
|
+
forceMount: c,
|
|
108
|
+
container: d,
|
|
109
|
+
onPointerEnter: l,
|
|
110
|
+
onPointerLeave: f,
|
|
111
|
+
children: y,
|
|
112
|
+
arrowPadding: p = 4,
|
|
113
|
+
variant: t = "default",
|
|
114
|
+
...r
|
|
115
|
+
}, m) {
|
|
116
|
+
const e = H(), [o, i] = I(null), [w, v] = I(null), T = g(
|
|
117
|
+
(n) => {
|
|
118
|
+
i(n), typeof m == "function" ? m(n) : m && "current" in m && (m.current = n);
|
|
119
|
+
},
|
|
120
|
+
[m]
|
|
121
|
+
), b = g(() => {
|
|
122
|
+
if (!e.triggerRef.current || !o) return;
|
|
123
|
+
const n = j(e.triggerRef.current, o, { ...e.options, arrowPadding: p });
|
|
124
|
+
v(n);
|
|
125
|
+
}, [o, e.triggerRef, e.options, p]);
|
|
126
|
+
k(() => {
|
|
127
|
+
if (!e.open) return;
|
|
128
|
+
b();
|
|
129
|
+
const n = () => b();
|
|
130
|
+
return window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
|
|
131
|
+
window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
|
|
132
|
+
};
|
|
133
|
+
}, [e.open, b]), k(() => {
|
|
134
|
+
if (!e.open) return;
|
|
135
|
+
const n = (s) => {
|
|
136
|
+
s instanceof KeyboardEvent && s.key === "Escape" && e.setOpen(!1);
|
|
137
|
+
};
|
|
138
|
+
return window.addEventListener("keydown", n), () => window.removeEventListener("keydown", n);
|
|
139
|
+
}, [e.open, e.setOpen]);
|
|
140
|
+
const C = g(
|
|
141
|
+
(n) => {
|
|
142
|
+
l?.(n), e.provider.disableHoverableContent || e.setOpen(!0);
|
|
143
|
+
},
|
|
144
|
+
[l, e.provider.disableHoverableContent, e.setOpen]
|
|
145
|
+
), x = g(
|
|
146
|
+
(n) => {
|
|
147
|
+
f?.(n), e.provider.disableHoverableContent || e.setOpen(!1);
|
|
148
|
+
},
|
|
149
|
+
[f, e.provider.disableHoverableContent, e.setOpen]
|
|
150
|
+
), B = e.open || c ? /* @__PURE__ */ D(
|
|
151
|
+
"div",
|
|
152
|
+
{
|
|
153
|
+
...r,
|
|
154
|
+
ref: T,
|
|
155
|
+
id: e.contentId,
|
|
156
|
+
role: "tooltip",
|
|
157
|
+
"data-state": e.open ? "open" : "closed",
|
|
158
|
+
"data-variant": t,
|
|
159
|
+
className: a,
|
|
160
|
+
style: {
|
|
161
|
+
position: "fixed",
|
|
162
|
+
left: w?.x ?? -9999,
|
|
163
|
+
top: w?.y ?? -9999,
|
|
164
|
+
transformOrigin: w ? $(w.placing) : void 0,
|
|
165
|
+
...u
|
|
166
|
+
},
|
|
167
|
+
onPointerEnter: C,
|
|
168
|
+
onPointerLeave: x,
|
|
169
|
+
children: y
|
|
170
|
+
}
|
|
171
|
+
) : null, P = typeof document < "u" ? d ?? document.body : null;
|
|
172
|
+
return P ? S(B, P) : null;
|
|
173
|
+
}), et = L(function({ width: a = 16, height: u = 16, className: c, style: d, ...l }, f) {
|
|
174
|
+
const y = H();
|
|
175
|
+
return /* @__PURE__ */ D(
|
|
176
|
+
"div",
|
|
177
|
+
{
|
|
178
|
+
...l,
|
|
179
|
+
ref: f,
|
|
180
|
+
"aria-hidden": !0,
|
|
181
|
+
className: z("pointer-events-none", c),
|
|
182
|
+
style: {
|
|
183
|
+
width: a,
|
|
184
|
+
height: u,
|
|
185
|
+
...d
|
|
186
|
+
},
|
|
187
|
+
"data-arrow": !0,
|
|
188
|
+
"data-side": y.options.side
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
});
|
|
192
|
+
function H() {
|
|
193
|
+
const h = M(K);
|
|
194
|
+
if (!h) throw new Error("Tooltip components must be used within <Tooltip>");
|
|
195
|
+
return h;
|
|
196
|
+
}
|
|
197
|
+
const U = {
|
|
198
|
+
top: "bottom center",
|
|
199
|
+
bottom: "top center",
|
|
200
|
+
left: "center right",
|
|
201
|
+
right: "center left"
|
|
202
|
+
};
|
|
203
|
+
function $(h) {
|
|
204
|
+
return U[h];
|
|
205
|
+
}
|
|
206
|
+
function R(h, a, u) {
|
|
207
|
+
return Math.max(a, Math.min(u, h));
|
|
208
|
+
}
|
|
209
|
+
function j(h, a, u) {
|
|
210
|
+
const { side: c, align: d, sideOffset: l, alignOffset: f, avoidCollisions: y, arrowPadding: p } = u, t = h.getBoundingClientRect(), r = a.getBoundingClientRect(), m = window.innerWidth, e = window.innerHeight;
|
|
211
|
+
let o = 0, i = 0;
|
|
212
|
+
const w = t.left + t.width / 2 - r.width / 2, v = t.left, T = t.right - r.width, b = t.top + t.height / 2 - r.height / 2, C = t.top, x = t.bottom - r.height, B = d === "start" ? v : d === "end" ? T : w, P = d === "start" ? C : d === "end" ? x : b;
|
|
213
|
+
c === "top" ? (o = B + f, i = t.top - r.height - l) : c === "bottom" ? (o = B + f, i = t.bottom + l) : c === "left" ? (o = t.left - r.width - l, i = P + f) : (o = t.right + l, i = P + f);
|
|
214
|
+
let n = c;
|
|
215
|
+
y && (c === "top" && i < 0 ? (n = "bottom", i = t.bottom + l) : c === "bottom" && i + r.height > e ? (n = "top", i = t.top - r.height - l) : c === "left" && o < 0 ? (n = "right", o = t.right + l) : c === "right" && o + r.width > m && (n = "left", o = t.left - r.width - l));
|
|
216
|
+
let s = t.left + t.width / 2, O = t.top + t.height / 2;
|
|
217
|
+
return n === "top" && (O = i + r.height, s = R(t.left + t.width / 2, o + p, o + r.width - p)), n === "bottom" && (O = i, s = R(t.left + t.width / 2, o + p, o + r.width - p)), n === "left" && (s = o + r.width, O = R(t.top + t.height / 2, i + p, i + r.height - p)), n === "right" && (s = o, O = R(t.top + t.height / 2, i + p, i + r.height - p)), a.style.setProperty("--arrow-x", `${s - o}px`), a.style.setProperty("--arrow-y", `${O - i}px`), a.dataset.side = n, { x: o, y: i, placing: n, arrowX: s, arrowY: O };
|
|
218
|
+
}
|
|
219
|
+
export {
|
|
220
|
+
et as TooltipArrowBase,
|
|
221
|
+
tt as TooltipContentBase,
|
|
222
|
+
V as TooltipProviderBase,
|
|
223
|
+
Z as TooltipRootBase,
|
|
224
|
+
_ as TooltipTriggerBase
|
|
225
|
+
};
|
package/dist/Tooltip.js
ADDED
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import './assets/main.css'
|
|
2
|
+
import { jsx as u, jsxs as S } from "react/jsx-runtime";
|
|
3
|
+
import * as a from "react";
|
|
4
|
+
import { e as H, c as J, a as Q, u as Z, P as j, b as ee, d as G, f as C, D as te, h as oe } from "./index-B7LSgz_k.js";
|
|
5
|
+
import { c as z, R as re, a as ne, A as ae, C as se } from "./index-sDEISz8i.js";
|
|
6
|
+
import { c as ie } from "./twUtils-CRiPKpXj.js";
|
|
7
|
+
var le = Object.freeze({
|
|
8
|
+
// See: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_visually-hidden.scss
|
|
9
|
+
position: "absolute",
|
|
10
|
+
border: 0,
|
|
11
|
+
width: 1,
|
|
12
|
+
height: 1,
|
|
13
|
+
padding: 0,
|
|
14
|
+
margin: -1,
|
|
15
|
+
overflow: "hidden",
|
|
16
|
+
clip: "rect(0, 0, 0, 0)",
|
|
17
|
+
whiteSpace: "nowrap",
|
|
18
|
+
wordWrap: "normal"
|
|
19
|
+
}), ce = "VisuallyHidden", F = a.forwardRef(
|
|
20
|
+
(e, o) => /* @__PURE__ */ u(
|
|
21
|
+
H.span,
|
|
22
|
+
{
|
|
23
|
+
...e,
|
|
24
|
+
ref: o,
|
|
25
|
+
style: { ...le, ...e.style }
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
);
|
|
29
|
+
F.displayName = ce;
|
|
30
|
+
var ue = F, [D, He] = J("Tooltip", [
|
|
31
|
+
z
|
|
32
|
+
]), O = z(), V = "TooltipProvider", de = 700, A = "tooltip.open", [pe, k] = D(V), Y = (e) => {
|
|
33
|
+
const {
|
|
34
|
+
__scopeTooltip: o,
|
|
35
|
+
delayDuration: t = de,
|
|
36
|
+
skipDelayDuration: r = 300,
|
|
37
|
+
disableHoverableContent: n = !1,
|
|
38
|
+
children: l
|
|
39
|
+
} = e, i = a.useRef(!0), v = a.useRef(!1), s = a.useRef(0);
|
|
40
|
+
return a.useEffect(() => {
|
|
41
|
+
const p = s.current;
|
|
42
|
+
return () => window.clearTimeout(p);
|
|
43
|
+
}, []), /* @__PURE__ */ u(
|
|
44
|
+
pe,
|
|
45
|
+
{
|
|
46
|
+
scope: o,
|
|
47
|
+
isOpenDelayedRef: i,
|
|
48
|
+
delayDuration: t,
|
|
49
|
+
onOpen: a.useCallback(() => {
|
|
50
|
+
window.clearTimeout(s.current), i.current = !1;
|
|
51
|
+
}, []),
|
|
52
|
+
onClose: a.useCallback(() => {
|
|
53
|
+
window.clearTimeout(s.current), s.current = window.setTimeout(
|
|
54
|
+
() => i.current = !0,
|
|
55
|
+
r
|
|
56
|
+
);
|
|
57
|
+
}, [r]),
|
|
58
|
+
isPointerInTransitRef: v,
|
|
59
|
+
onPointerInTransitChange: a.useCallback((p) => {
|
|
60
|
+
v.current = p;
|
|
61
|
+
}, []),
|
|
62
|
+
disableHoverableContent: n,
|
|
63
|
+
children: l
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
Y.displayName = V;
|
|
68
|
+
var R = "Tooltip", [fe, _] = D(R), $ = (e) => {
|
|
69
|
+
const {
|
|
70
|
+
__scopeTooltip: o,
|
|
71
|
+
children: t,
|
|
72
|
+
open: r,
|
|
73
|
+
defaultOpen: n,
|
|
74
|
+
onOpenChange: l,
|
|
75
|
+
disableHoverableContent: i,
|
|
76
|
+
delayDuration: v
|
|
77
|
+
} = e, s = k(R, e.__scopeTooltip), p = O(o), [c, f] = a.useState(null), h = Q(), d = a.useRef(0), g = i ?? s.disableHoverableContent, T = v ?? s.delayDuration, m = a.useRef(!1), [x, y] = Z({
|
|
78
|
+
prop: r,
|
|
79
|
+
defaultProp: n ?? !1,
|
|
80
|
+
onChange: (M) => {
|
|
81
|
+
M ? (s.onOpen(), document.dispatchEvent(new CustomEvent(A))) : s.onClose(), l?.(M);
|
|
82
|
+
},
|
|
83
|
+
caller: R
|
|
84
|
+
}), w = a.useMemo(() => x ? m.current ? "delayed-open" : "instant-open" : "closed", [x]), P = a.useCallback(() => {
|
|
85
|
+
window.clearTimeout(d.current), d.current = 0, m.current = !1, y(!0);
|
|
86
|
+
}, [y]), E = a.useCallback(() => {
|
|
87
|
+
window.clearTimeout(d.current), d.current = 0, y(!1);
|
|
88
|
+
}, [y]), I = a.useCallback(() => {
|
|
89
|
+
window.clearTimeout(d.current), d.current = window.setTimeout(() => {
|
|
90
|
+
m.current = !0, y(!0), d.current = 0;
|
|
91
|
+
}, T);
|
|
92
|
+
}, [T, y]);
|
|
93
|
+
return a.useEffect(() => () => {
|
|
94
|
+
d.current && (window.clearTimeout(d.current), d.current = 0);
|
|
95
|
+
}, []), /* @__PURE__ */ u(re, { ...p, children: /* @__PURE__ */ u(
|
|
96
|
+
fe,
|
|
97
|
+
{
|
|
98
|
+
scope: o,
|
|
99
|
+
contentId: h,
|
|
100
|
+
open: x,
|
|
101
|
+
stateAttribute: w,
|
|
102
|
+
trigger: c,
|
|
103
|
+
onTriggerChange: f,
|
|
104
|
+
onTriggerEnter: a.useCallback(() => {
|
|
105
|
+
s.isOpenDelayedRef.current ? I() : P();
|
|
106
|
+
}, [s.isOpenDelayedRef, I, P]),
|
|
107
|
+
onTriggerLeave: a.useCallback(() => {
|
|
108
|
+
g ? E() : (window.clearTimeout(d.current), d.current = 0);
|
|
109
|
+
}, [E, g]),
|
|
110
|
+
onOpen: P,
|
|
111
|
+
onClose: E,
|
|
112
|
+
disableHoverableContent: g,
|
|
113
|
+
children: t
|
|
114
|
+
}
|
|
115
|
+
) });
|
|
116
|
+
};
|
|
117
|
+
$.displayName = R;
|
|
118
|
+
var L = "TooltipTrigger", B = a.forwardRef(
|
|
119
|
+
(e, o) => {
|
|
120
|
+
const { __scopeTooltip: t, ...r } = e, n = _(L, t), l = k(L, t), i = O(t), v = a.useRef(null), s = G(o, v, n.onTriggerChange), p = a.useRef(!1), c = a.useRef(!1), f = a.useCallback(() => p.current = !1, []);
|
|
121
|
+
return a.useEffect(() => () => document.removeEventListener("pointerup", f), [f]), /* @__PURE__ */ u(ae, { asChild: !0, ...i, children: /* @__PURE__ */ u(
|
|
122
|
+
H.button,
|
|
123
|
+
{
|
|
124
|
+
"aria-describedby": n.open ? n.contentId : void 0,
|
|
125
|
+
"data-state": n.stateAttribute,
|
|
126
|
+
...r,
|
|
127
|
+
ref: s,
|
|
128
|
+
onPointerMove: C(e.onPointerMove, (h) => {
|
|
129
|
+
h.pointerType !== "touch" && !c.current && !l.isPointerInTransitRef.current && (n.onTriggerEnter(), c.current = !0);
|
|
130
|
+
}),
|
|
131
|
+
onPointerLeave: C(e.onPointerLeave, () => {
|
|
132
|
+
n.onTriggerLeave(), c.current = !1;
|
|
133
|
+
}),
|
|
134
|
+
onPointerDown: C(e.onPointerDown, () => {
|
|
135
|
+
n.open && n.onClose(), p.current = !0, document.addEventListener("pointerup", f, { once: !0 });
|
|
136
|
+
}),
|
|
137
|
+
onFocus: C(e.onFocus, () => {
|
|
138
|
+
p.current || n.onOpen();
|
|
139
|
+
}),
|
|
140
|
+
onBlur: C(e.onBlur, n.onClose),
|
|
141
|
+
onClick: C(e.onClick, n.onClose)
|
|
142
|
+
}
|
|
143
|
+
) });
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
B.displayName = L;
|
|
147
|
+
var N = "TooltipPortal", [ve, he] = D(N, {
|
|
148
|
+
forceMount: void 0
|
|
149
|
+
}), U = (e) => {
|
|
150
|
+
const { __scopeTooltip: o, forceMount: t, children: r, container: n } = e, l = _(N, o);
|
|
151
|
+
return /* @__PURE__ */ u(ve, { scope: o, forceMount: t, children: /* @__PURE__ */ u(j, { present: t || l.open, children: /* @__PURE__ */ u(ee, { asChild: !0, container: n, children: r }) }) });
|
|
152
|
+
};
|
|
153
|
+
U.displayName = N;
|
|
154
|
+
var b = "TooltipContent", q = a.forwardRef(
|
|
155
|
+
(e, o) => {
|
|
156
|
+
const t = he(b, e.__scopeTooltip), { forceMount: r = t.forceMount, side: n = "top", ...l } = e, i = _(b, e.__scopeTooltip);
|
|
157
|
+
return /* @__PURE__ */ u(j, { present: r || i.open, children: i.disableHoverableContent ? /* @__PURE__ */ u(W, { side: n, ...l, ref: o }) : /* @__PURE__ */ u(ge, { side: n, ...l, ref: o }) });
|
|
158
|
+
}
|
|
159
|
+
), ge = a.forwardRef((e, o) => {
|
|
160
|
+
const t = _(b, e.__scopeTooltip), r = k(b, e.__scopeTooltip), n = a.useRef(null), l = G(o, n), [i, v] = a.useState(null), { trigger: s, onClose: p } = t, c = n.current, { onPointerInTransitChange: f } = r, h = a.useCallback(() => {
|
|
161
|
+
v(null), f(!1);
|
|
162
|
+
}, [f]), d = a.useCallback(
|
|
163
|
+
(g, T) => {
|
|
164
|
+
const m = g.currentTarget, x = { x: g.clientX, y: g.clientY }, y = xe(x, m.getBoundingClientRect()), w = Ce(x, y), P = be(T.getBoundingClientRect()), E = Pe([...w, ...P]);
|
|
165
|
+
v(E), f(!0);
|
|
166
|
+
},
|
|
167
|
+
[f]
|
|
168
|
+
);
|
|
169
|
+
return a.useEffect(() => () => h(), [h]), a.useEffect(() => {
|
|
170
|
+
if (s && c) {
|
|
171
|
+
const g = (m) => d(m, c), T = (m) => d(m, s);
|
|
172
|
+
return s.addEventListener("pointerleave", g), c.addEventListener("pointerleave", T), () => {
|
|
173
|
+
s.removeEventListener("pointerleave", g), c.removeEventListener("pointerleave", T);
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}, [s, c, d, h]), a.useEffect(() => {
|
|
177
|
+
if (i) {
|
|
178
|
+
const g = (T) => {
|
|
179
|
+
const m = T.target, x = { x: T.clientX, y: T.clientY }, y = s?.contains(m) || c?.contains(m), w = !we(x, i);
|
|
180
|
+
y ? h() : w && (h(), p());
|
|
181
|
+
};
|
|
182
|
+
return document.addEventListener("pointermove", g), () => document.removeEventListener("pointermove", g);
|
|
183
|
+
}
|
|
184
|
+
}, [s, c, i, p, h]), /* @__PURE__ */ u(W, { ...e, ref: l });
|
|
185
|
+
}), [me, Te] = D(R, { isInside: !1 }), ye = oe("TooltipContent"), W = a.forwardRef(
|
|
186
|
+
(e, o) => {
|
|
187
|
+
const {
|
|
188
|
+
__scopeTooltip: t,
|
|
189
|
+
children: r,
|
|
190
|
+
"aria-label": n,
|
|
191
|
+
onEscapeKeyDown: l,
|
|
192
|
+
onPointerDownOutside: i,
|
|
193
|
+
...v
|
|
194
|
+
} = e, s = _(b, t), p = O(t), { onClose: c } = s;
|
|
195
|
+
return a.useEffect(() => (document.addEventListener(A, c), () => document.removeEventListener(A, c)), [c]), a.useEffect(() => {
|
|
196
|
+
if (s.trigger) {
|
|
197
|
+
const f = (h) => {
|
|
198
|
+
h.target?.contains(s.trigger) && c();
|
|
199
|
+
};
|
|
200
|
+
return window.addEventListener("scroll", f, { capture: !0 }), () => window.removeEventListener("scroll", f, { capture: !0 });
|
|
201
|
+
}
|
|
202
|
+
}, [s.trigger, c]), /* @__PURE__ */ u(
|
|
203
|
+
te,
|
|
204
|
+
{
|
|
205
|
+
asChild: !0,
|
|
206
|
+
disableOutsidePointerEvents: !1,
|
|
207
|
+
onEscapeKeyDown: l,
|
|
208
|
+
onPointerDownOutside: i,
|
|
209
|
+
onFocusOutside: (f) => f.preventDefault(),
|
|
210
|
+
onDismiss: c,
|
|
211
|
+
children: /* @__PURE__ */ S(
|
|
212
|
+
se,
|
|
213
|
+
{
|
|
214
|
+
"data-state": s.stateAttribute,
|
|
215
|
+
...p,
|
|
216
|
+
...v,
|
|
217
|
+
ref: o,
|
|
218
|
+
style: {
|
|
219
|
+
...v.style,
|
|
220
|
+
"--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
221
|
+
"--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
|
|
222
|
+
"--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
|
|
223
|
+
"--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
|
|
224
|
+
"--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
|
|
225
|
+
},
|
|
226
|
+
children: [
|
|
227
|
+
/* @__PURE__ */ u(ye, { children: r }),
|
|
228
|
+
/* @__PURE__ */ u(me, { scope: t, isInside: !0, children: /* @__PURE__ */ u(ue, { id: s.contentId, role: "tooltip", children: n || r }) })
|
|
229
|
+
]
|
|
230
|
+
}
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
q.displayName = b;
|
|
237
|
+
var X = "TooltipArrow", K = a.forwardRef(
|
|
238
|
+
(e, o) => {
|
|
239
|
+
const { __scopeTooltip: t, ...r } = e, n = O(t);
|
|
240
|
+
return Te(
|
|
241
|
+
X,
|
|
242
|
+
t
|
|
243
|
+
).isInside ? null : /* @__PURE__ */ u(ne, { ...n, ...r, ref: o });
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
K.displayName = X;
|
|
247
|
+
function xe(e, o) {
|
|
248
|
+
const t = Math.abs(o.top - e.y), r = Math.abs(o.bottom - e.y), n = Math.abs(o.right - e.x), l = Math.abs(o.left - e.x);
|
|
249
|
+
switch (Math.min(t, r, n, l)) {
|
|
250
|
+
case l:
|
|
251
|
+
return "left";
|
|
252
|
+
case n:
|
|
253
|
+
return "right";
|
|
254
|
+
case t:
|
|
255
|
+
return "top";
|
|
256
|
+
case r:
|
|
257
|
+
return "bottom";
|
|
258
|
+
default:
|
|
259
|
+
throw new Error("unreachable");
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function Ce(e, o, t = 5) {
|
|
263
|
+
const r = [];
|
|
264
|
+
switch (o) {
|
|
265
|
+
case "top":
|
|
266
|
+
r.push(
|
|
267
|
+
{ x: e.x - t, y: e.y + t },
|
|
268
|
+
{ x: e.x + t, y: e.y + t }
|
|
269
|
+
);
|
|
270
|
+
break;
|
|
271
|
+
case "bottom":
|
|
272
|
+
r.push(
|
|
273
|
+
{ x: e.x - t, y: e.y - t },
|
|
274
|
+
{ x: e.x + t, y: e.y - t }
|
|
275
|
+
);
|
|
276
|
+
break;
|
|
277
|
+
case "left":
|
|
278
|
+
r.push(
|
|
279
|
+
{ x: e.x + t, y: e.y - t },
|
|
280
|
+
{ x: e.x + t, y: e.y + t }
|
|
281
|
+
);
|
|
282
|
+
break;
|
|
283
|
+
case "right":
|
|
284
|
+
r.push(
|
|
285
|
+
{ x: e.x - t, y: e.y - t },
|
|
286
|
+
{ x: e.x - t, y: e.y + t }
|
|
287
|
+
);
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
return r;
|
|
291
|
+
}
|
|
292
|
+
function be(e) {
|
|
293
|
+
const { top: o, right: t, bottom: r, left: n } = e;
|
|
294
|
+
return [
|
|
295
|
+
{ x: n, y: o },
|
|
296
|
+
{ x: t, y: o },
|
|
297
|
+
{ x: t, y: r },
|
|
298
|
+
{ x: n, y: r }
|
|
299
|
+
];
|
|
300
|
+
}
|
|
301
|
+
function we(e, o) {
|
|
302
|
+
const { x: t, y: r } = e;
|
|
303
|
+
let n = !1;
|
|
304
|
+
for (let l = 0, i = o.length - 1; l < o.length; i = l++) {
|
|
305
|
+
const v = o[l], s = o[i], p = v.x, c = v.y, f = s.x, h = s.y;
|
|
306
|
+
c > r != h > r && t < (f - p) * (r - c) / (h - c) + p && (n = !n);
|
|
307
|
+
}
|
|
308
|
+
return n;
|
|
309
|
+
}
|
|
310
|
+
function Pe(e) {
|
|
311
|
+
const o = e.slice();
|
|
312
|
+
return o.sort((t, r) => t.x < r.x ? -1 : t.x > r.x ? 1 : t.y < r.y ? -1 : t.y > r.y ? 1 : 0), Ee(o);
|
|
313
|
+
}
|
|
314
|
+
function Ee(e) {
|
|
315
|
+
if (e.length <= 1) return e.slice();
|
|
316
|
+
const o = [];
|
|
317
|
+
for (let r = 0; r < e.length; r++) {
|
|
318
|
+
const n = e[r];
|
|
319
|
+
for (; o.length >= 2; ) {
|
|
320
|
+
const l = o[o.length - 1], i = o[o.length - 2];
|
|
321
|
+
if ((l.x - i.x) * (n.y - i.y) >= (l.y - i.y) * (n.x - i.x)) o.pop();
|
|
322
|
+
else break;
|
|
323
|
+
}
|
|
324
|
+
o.push(n);
|
|
325
|
+
}
|
|
326
|
+
o.pop();
|
|
327
|
+
const t = [];
|
|
328
|
+
for (let r = e.length - 1; r >= 0; r--) {
|
|
329
|
+
const n = e[r];
|
|
330
|
+
for (; t.length >= 2; ) {
|
|
331
|
+
const l = t[t.length - 1], i = t[t.length - 2];
|
|
332
|
+
if ((l.x - i.x) * (n.y - i.y) >= (l.y - i.y) * (n.x - i.x)) t.pop();
|
|
333
|
+
else break;
|
|
334
|
+
}
|
|
335
|
+
t.push(n);
|
|
336
|
+
}
|
|
337
|
+
return t.pop(), o.length === 1 && t.length === 1 && o[0].x === t[0].x && o[0].y === t[0].y ? o : o.concat(t);
|
|
338
|
+
}
|
|
339
|
+
var Re = Y, _e = $, De = B, Oe = U, Ae = q, Le = K;
|
|
340
|
+
const ke = ({ delayDuration: e = 0, ...o }) => /* @__PURE__ */ u(Re, { "data-slot": "tooltip-provider", delayDuration: e, ...o }), je = ({ ...e }) => /* @__PURE__ */ u(ke, { children: /* @__PURE__ */ u(_e, { "data-slot": "tooltip", ...e }) }), Ge = ({ ...e }) => /* @__PURE__ */ u(De, { asChild: !0, "data-slot": "tooltip-trigger", ...e }), ze = ({
|
|
341
|
+
className: e,
|
|
342
|
+
children: o,
|
|
343
|
+
sideOffset: t = 0,
|
|
344
|
+
showArrow: r = !1,
|
|
345
|
+
...n
|
|
346
|
+
}) => /* @__PURE__ */ u(Oe, { children: /* @__PURE__ */ S(
|
|
347
|
+
Ae,
|
|
348
|
+
{
|
|
349
|
+
"data-slot": "tooltip-content",
|
|
350
|
+
sideOffset: t,
|
|
351
|
+
className: ie(
|
|
352
|
+
"bg-tooltip-bg text-text-primary pointer-events-auto z-50 w-fit rounded-md px-3 py-1.5 text-xs shadow-lg will-change-transform outline-none select-none",
|
|
353
|
+
"data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
|
|
354
|
+
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
|
|
355
|
+
"data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2",
|
|
356
|
+
"data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
357
|
+
e
|
|
358
|
+
),
|
|
359
|
+
...n,
|
|
360
|
+
children: [
|
|
361
|
+
o,
|
|
362
|
+
r && /* @__PURE__ */ u(Le, { className: "bg-tooltip-arrow fill-tooltip-arrow z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })
|
|
363
|
+
]
|
|
364
|
+
}
|
|
365
|
+
) });
|
|
366
|
+
export {
|
|
367
|
+
je as Tooltip,
|
|
368
|
+
ze as TooltipContent,
|
|
369
|
+
ke as TooltipProvider,
|
|
370
|
+
Ge as TooltipTrigger
|
|
371
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LabelingTools.d.ts","sourceRoot":"","sources":["../../../src/features/LabelingTools/LabelingTools.tsx"],"names":[],"mappings":"AAiBA,eAAO,MAAM,aAAa,+CA+HzB,CAAA"}
|