@spear-ai/spectral 1.4.4 → 1.4.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.
- package/dist/Alert/AlertBase.d.ts +5 -3
- package/dist/Alert/AlertBase.js +31 -31
- package/dist/Alert.js +11 -11
- package/dist/Avatar.js +14 -14
- package/dist/Button.js +1 -7
- package/dist/ButtonGroup/ButtonGroupButton.js +1 -1
- package/dist/Dialog.js +11 -11
- package/dist/Drawer.d.ts +6 -3
- package/dist/Drawer.js +10 -10
- package/dist/InputOTP.js +1 -0
- package/dist/MultiSelect/MultiSelectBase.js +1 -7
- package/dist/RadioGroup.js +1 -1
- package/dist/Select.d.ts +1 -1
- package/dist/Select.js +54 -54
- package/dist/Slider.js +26 -17
- package/dist/Switch.js +8 -8
- package/dist/Tabs/TabsBase.js +18 -18
- package/dist/Tabs/tabsUtils.js +31 -30
- package/dist/Textarea.js +2 -2
- package/dist/Toggle/ToggleBase.d.ts +1 -1
- package/dist/Toggle/ToggleBase.js +36 -18
- package/dist/Toggle.js +10 -10
- package/dist/Tooltip.d.ts +7 -2
- package/dist/Tooltip.js +156 -143
- package/dist/{createLucideIcon-B_8CJpcQ.js → createLucideIcon-D4r5Phnh.js} +0 -24
- package/dist/main.js +0 -36
- package/dist/styles/base-colors.css +13 -13
- package/dist/styles/main.css +1 -1
- package/package.json +20 -20
- package/dist/Slider/SliderBase.d.ts +0 -54
- package/dist/Slider/SliderBase.js +0 -256
- package/dist/Tooltip/TooltipBase.d.ts +0 -51
- package/dist/Tooltip/TooltipBase.js +0 -186
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import "../styles/main.css";
|
|
3
|
-
import { jsx as k, jsxs as Q } from "react/jsx-runtime";
|
|
4
|
-
import { Slot as P } from "../primitives/slot.js";
|
|
5
|
-
import { createContext as W, forwardRef as E, useEffect as Z, useRef as G, useState as B, useCallback as A, useContext as F, createRef as _ } from "react";
|
|
6
|
-
function x(...r) {
|
|
7
|
-
return r.filter(Boolean).join(" ");
|
|
8
|
-
}
|
|
9
|
-
function I(r, i, e) {
|
|
10
|
-
return Math.min(e, Math.max(i, r));
|
|
11
|
-
}
|
|
12
|
-
function U(r, i, e) {
|
|
13
|
-
const a = Math.round((r - e) / i), l = e + a * i;
|
|
14
|
-
return Number(l.toFixed(10));
|
|
15
|
-
}
|
|
16
|
-
function L(r, i, e) {
|
|
17
|
-
return (r - i) * 100 / (e - i);
|
|
18
|
-
}
|
|
19
|
-
function tt(r, i, e) {
|
|
20
|
-
return i + r / 100 * (e - i);
|
|
21
|
-
}
|
|
22
|
-
function et(r, i) {
|
|
23
|
-
let e = 0, a = 1 / 0;
|
|
24
|
-
for (let l = 0; l < r.length; l += 1) {
|
|
25
|
-
const n = Math.abs(r[l] - i);
|
|
26
|
-
n < a && (a = n, e = l);
|
|
27
|
-
}
|
|
28
|
-
return e;
|
|
29
|
-
}
|
|
30
|
-
function nt(r) {
|
|
31
|
-
const { value: i, defaultValue: e, onChange: a } = r, [l, n] = B(e), s = Array.isArray(i), t = s ? i : l, o = A(
|
|
32
|
-
(u) => {
|
|
33
|
-
const d = typeof u == "function" ? u(t) : u;
|
|
34
|
-
s || n(d), a?.(d);
|
|
35
|
-
},
|
|
36
|
-
[s, a, t]
|
|
37
|
-
);
|
|
38
|
-
return [t, o];
|
|
39
|
-
}
|
|
40
|
-
const z = W(null), rt = E(
|
|
41
|
-
({ asChild: r, className: i, value: e, defaultValue: a, onValueChange: l, onValueCommit: n, min: s = 0, max: t = 100, step: o = 1, minStepsBetweenThumbs: u = 0, orientation: d = "horizontal", dir: S = "ltr", disabled: b = !1, name: h, form: N, required: T, children: V, ...$ }, c) => {
|
|
42
|
-
const [m, p] = nt({
|
|
43
|
-
value: e,
|
|
44
|
-
defaultValue: a && a.length > 0 ? a : [s],
|
|
45
|
-
onChange: l
|
|
46
|
-
});
|
|
47
|
-
Z(() => {
|
|
48
|
-
p((g) => X(g, { min: s, max: t, step: o, minStepsBetweenThumbs: u }));
|
|
49
|
-
}, [s, t, o, u]);
|
|
50
|
-
const v = G(null), f = G([]), [y, C] = B(null), w = A(
|
|
51
|
-
(g, R) => {
|
|
52
|
-
const D = X(g, { min: s, max: t, step: o, minStepsBetweenThumbs: u });
|
|
53
|
-
p(D), R?.commit && n?.(D);
|
|
54
|
-
},
|
|
55
|
-
[t, s, u, n, p, o]
|
|
56
|
-
), K = A(
|
|
57
|
-
(g, R, D) => {
|
|
58
|
-
const j = [...m];
|
|
59
|
-
j[g] = R, w(j, D);
|
|
60
|
-
},
|
|
61
|
-
[w, m]
|
|
62
|
-
), M = {
|
|
63
|
-
values: m,
|
|
64
|
-
setValues: w,
|
|
65
|
-
min: s,
|
|
66
|
-
max: t,
|
|
67
|
-
step: o,
|
|
68
|
-
minStepsBetweenThumbs: u,
|
|
69
|
-
orientation: d,
|
|
70
|
-
dir: S,
|
|
71
|
-
disabled: b,
|
|
72
|
-
trackRef: v,
|
|
73
|
-
thumbsRef: f,
|
|
74
|
-
activeIndex: y,
|
|
75
|
-
setActiveIndex: C,
|
|
76
|
-
updateAtIndex: K
|
|
77
|
-
}, J = r ? P : "div", O = c;
|
|
78
|
-
return /* @__PURE__ */ k(z.Provider, { value: M, children: /* @__PURE__ */ Q(J, { ref: O, role: "presentation", "data-orientation": d, "data-disabled": b ? "" : void 0, className: x("relative touch-none select-none", d === "horizontal" ? "h-6 w-full" : "h-full w-6", i), ...$, children: [
|
|
79
|
-
h && M.values.map((g, R) => /* @__PURE__ */ k(
|
|
80
|
-
"input",
|
|
81
|
-
{
|
|
82
|
-
type: "hidden",
|
|
83
|
-
name: M.values.length > 1 ? `${h}[]` : h,
|
|
84
|
-
value: String(g),
|
|
85
|
-
form: N,
|
|
86
|
-
required: T && R === 0,
|
|
87
|
-
"aria-hidden": "true"
|
|
88
|
-
},
|
|
89
|
-
R
|
|
90
|
-
)),
|
|
91
|
-
V
|
|
92
|
-
] }) });
|
|
93
|
-
}
|
|
94
|
-
);
|
|
95
|
-
rt.displayName = "SliderBase";
|
|
96
|
-
function X(r, i) {
|
|
97
|
-
const { min: e, max: a, step: l, minStepsBetweenThumbs: n } = i, s = r.map((o) => I(U(o, l, e), e, a));
|
|
98
|
-
if (s.sort((o, u) => o - u), s.length <= 1 || n <= 0) return s;
|
|
99
|
-
const t = l * n;
|
|
100
|
-
for (let o = 1; o < s.length; o += 1)
|
|
101
|
-
s[o] - s[o - 1] < t && (s[o] = I(s[o - 1] + t, e, a));
|
|
102
|
-
return s;
|
|
103
|
-
}
|
|
104
|
-
const ot = E(({ asChild: r, className: i, onPointerDown: e, ...a }, l) => {
|
|
105
|
-
const n = F(z);
|
|
106
|
-
if (!n) throw new Error("SliderTrack must be used within Slider");
|
|
107
|
-
const s = r ? P : "div", t = (u) => {
|
|
108
|
-
n.trackRef.current = u, typeof l == "function" ? l(u) : l && "current" in l && (l.current = u);
|
|
109
|
-
}, o = A(
|
|
110
|
-
(u) => {
|
|
111
|
-
if (e?.(u), u.defaultPrevented || n.disabled) return;
|
|
112
|
-
const d = n.trackRef.current;
|
|
113
|
-
if (!d) return;
|
|
114
|
-
d.setPointerCapture?.(u.pointerId), u.preventDefault();
|
|
115
|
-
const S = d.getBoundingClientRect(), b = Y(u.clientX, u.clientY, S, n), h = et(n.values, b);
|
|
116
|
-
n.setActiveIndex(h), n.updateAtIndex(h, b), H(h, n);
|
|
117
|
-
},
|
|
118
|
-
[n, e]
|
|
119
|
-
);
|
|
120
|
-
return /* @__PURE__ */ k(
|
|
121
|
-
s,
|
|
122
|
-
{
|
|
123
|
-
ref: t,
|
|
124
|
-
"data-orientation": n.orientation,
|
|
125
|
-
className: x("bg-secondary relative grow rounded-full", n.orientation === "horizontal" ? "h-2" : "w-2", i),
|
|
126
|
-
style: { touchAction: "none" },
|
|
127
|
-
onPointerDown: o,
|
|
128
|
-
...a
|
|
129
|
-
}
|
|
130
|
-
);
|
|
131
|
-
});
|
|
132
|
-
ot.displayName = "SliderTrack";
|
|
133
|
-
const it = E(({ asChild: r, className: i, style: e, ...a }, l) => {
|
|
134
|
-
const n = F(z);
|
|
135
|
-
if (!n) throw new Error("SliderRange must be used within Slider");
|
|
136
|
-
const s = r ? P : "div", t = L(n.values[0], n.min, n.max), o = L(n.values[n.values.length - 1], n.min, n.max), u = n.orientation === "horizontal" ? { left: `${t}%`, width: `${o - t}%` } : { bottom: `${t}%`, height: `${o - t}%` };
|
|
137
|
-
return /* @__PURE__ */ k(s, { ref: l, "data-orientation": n.orientation, className: x("bg-primary absolute rounded-full", n.orientation === "horizontal" ? "h-2" : "w-2", i), style: { ...u, ...e }, ...a });
|
|
138
|
-
});
|
|
139
|
-
it.displayName = "SliderRange";
|
|
140
|
-
const at = E(({ asChild: r, className: i, index: e, onKeyDown: a, onPointerDown: l, ...n }, s) => {
|
|
141
|
-
const t = F(z);
|
|
142
|
-
if (!t) throw new Error("SliderThumb must be used within Slider");
|
|
143
|
-
const [o] = B(() => {
|
|
144
|
-
const c = typeof e == "number" ? e : t.thumbsRef.current.length;
|
|
145
|
-
return t.thumbsRef.current[c] || (t.thumbsRef.current[c] = _()), c;
|
|
146
|
-
}), u = t.values[o] ?? t.values[t.values.length - 1], d = L(u, t.min, t.max), S = r ? P : "button", b = (c) => {
|
|
147
|
-
t.thumbsRef.current[o].current = c, typeof s == "function" ? s(c) : s && "current" in s && (s.current = c);
|
|
148
|
-
}, N = (t.activeIndex === null || t.activeIndex === o) && !t.disabled ? 0 : -1, T = A(
|
|
149
|
-
(c) => {
|
|
150
|
-
if (a?.(c), c.defaultPrevented || t.disabled) return;
|
|
151
|
-
const m = Math.max(t.step * 10, t.step), p = (w) => w === "inc" ? 1 : -1, v = (w) => st(o, w, t), f = c.key;
|
|
152
|
-
if (f === "Home") {
|
|
153
|
-
c.preventDefault(), t.updateAtIndex(o, t.min, { commit: !0 });
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
if (f === "End") {
|
|
157
|
-
c.preventDefault(), t.updateAtIndex(o, t.max, { commit: !0 });
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
const y = t.orientation === "horizontal", C = t.dir === "rtl";
|
|
161
|
-
if (f === "ArrowRight" && y) {
|
|
162
|
-
c.preventDefault(), v(t.step * (C ? -1 : 1));
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
if (f === "ArrowLeft" && y) {
|
|
166
|
-
c.preventDefault(), v(t.step * (C ? 1 : -1));
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
if (f === "ArrowUp" && !y) {
|
|
170
|
-
c.preventDefault(), v(t.step);
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
if (f === "ArrowDown" && !y) {
|
|
174
|
-
c.preventDefault(), v(-t.step);
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
if (f === "PageUp") {
|
|
178
|
-
c.preventDefault(), v(p("inc") * m);
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
if (f === "PageDown") {
|
|
182
|
-
c.preventDefault(), v(p("dec") * m);
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
[t, o, a]
|
|
187
|
-
), V = A(
|
|
188
|
-
(c) => {
|
|
189
|
-
if (l?.(c), c.defaultPrevented || t.disabled) return;
|
|
190
|
-
const m = t.trackRef.current, p = t.thumbsRef.current[o].current;
|
|
191
|
-
!m || !p || (p.setPointerCapture?.(c.pointerId), c.preventDefault(), t.setActiveIndex(o), H(o, t));
|
|
192
|
-
},
|
|
193
|
-
[t, o, l]
|
|
194
|
-
), $ = t.orientation === "horizontal" ? { left: `${d}%`, transform: "translate(-50%, -50%)" } : { bottom: `${d}%`, transform: "translate(-50%, 50%)" };
|
|
195
|
-
return /* @__PURE__ */ k(
|
|
196
|
-
S,
|
|
197
|
-
{
|
|
198
|
-
ref: b,
|
|
199
|
-
role: "slider",
|
|
200
|
-
tabIndex: N,
|
|
201
|
-
"aria-valuemin": t.min,
|
|
202
|
-
"aria-valuemax": t.max,
|
|
203
|
-
"aria-valuenow": u,
|
|
204
|
-
"aria-orientation": t.orientation,
|
|
205
|
-
"aria-disabled": t.disabled || void 0,
|
|
206
|
-
"data-orientation": t.orientation,
|
|
207
|
-
"data-disabled": t.disabled ? "" : void 0,
|
|
208
|
-
className: x("absolute grid place-items-center rounded-full shadow", "border-input border outline-none", "focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2", "h-5 w-5", i),
|
|
209
|
-
style: {
|
|
210
|
-
...$,
|
|
211
|
-
...t.orientation === "horizontal" ? { top: "50%" } : { left: "50%" },
|
|
212
|
-
touchAction: "none"
|
|
213
|
-
},
|
|
214
|
-
onKeyDown: T,
|
|
215
|
-
onPointerDown: V,
|
|
216
|
-
...n
|
|
217
|
-
}
|
|
218
|
-
);
|
|
219
|
-
});
|
|
220
|
-
at.displayName = "SliderThumb";
|
|
221
|
-
function Y(r, i, e, a) {
|
|
222
|
-
let l;
|
|
223
|
-
if (a.orientation === "horizontal") {
|
|
224
|
-
const o = I(r - e.left, 0, e.width) / e.width * 100;
|
|
225
|
-
l = a.dir === "rtl" ? 100 - o : o;
|
|
226
|
-
} else
|
|
227
|
-
l = 100 - I(i - e.top, 0, e.height) / e.height * 100;
|
|
228
|
-
const n = tt(l, a.min, a.max), s = U(n, a.step, a.min);
|
|
229
|
-
return I(s, a.min, a.max);
|
|
230
|
-
}
|
|
231
|
-
function q(r, i, e) {
|
|
232
|
-
const a = e.step * e.minStepsBetweenThumbs, l = r > 0 ? e.values[r - 1] : e.min, n = r < e.values.length - 1 ? e.values[r + 1] : e.max, s = l + (r > 0 ? a : 0), t = n - (r < e.values.length - 1 ? a : 0);
|
|
233
|
-
return I(i, s, t);
|
|
234
|
-
}
|
|
235
|
-
function st(r, i, e) {
|
|
236
|
-
const a = e.values[r], l = q(r, U(a + i, e.step, e.min), e);
|
|
237
|
-
e.updateAtIndex(r, l, { commit: !0 });
|
|
238
|
-
}
|
|
239
|
-
function H(r, i) {
|
|
240
|
-
const e = i.trackRef.current;
|
|
241
|
-
if (!e) return;
|
|
242
|
-
const a = () => e.getBoundingClientRect(), l = (s) => {
|
|
243
|
-
if (i.disabled) return;
|
|
244
|
-
const t = Y(s.clientX, s.clientY, a(), i), o = q(r, t, i);
|
|
245
|
-
i.updateAtIndex(r, o);
|
|
246
|
-
}, n = () => {
|
|
247
|
-
i.setActiveIndex(null), window.removeEventListener("pointermove", l, !0), window.removeEventListener("pointerup", n, !0);
|
|
248
|
-
};
|
|
249
|
-
window.addEventListener("pointermove", l, !0), window.addEventListener("pointerup", n, !0);
|
|
250
|
-
}
|
|
251
|
-
export {
|
|
252
|
-
rt as SliderBase,
|
|
253
|
-
it as SliderRange,
|
|
254
|
-
at as SliderThumb,
|
|
255
|
-
ot as SliderTrack
|
|
256
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
-
type Side = 'top' | 'right' | 'bottom' | 'left';
|
|
3
|
-
type Align = 'start' | 'center' | 'end';
|
|
4
|
-
export type TooltipProviderProps = {
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
delayDuration?: number;
|
|
7
|
-
disableHoverableContent?: boolean;
|
|
8
|
-
skipDelayDuration?: number;
|
|
9
|
-
};
|
|
10
|
-
export declare const TooltipProviderBase: import('react').ForwardRefExoticComponent<TooltipProviderProps & import('react').RefAttributes<HTMLElement>>;
|
|
11
|
-
export type TooltipRootProps = {
|
|
12
|
-
align?: Align;
|
|
13
|
-
alignOffset?: number;
|
|
14
|
-
avoidCollisions?: boolean;
|
|
15
|
-
children: ReactNode;
|
|
16
|
-
defaultOpen?: boolean;
|
|
17
|
-
delayDuration?: number;
|
|
18
|
-
open?: boolean;
|
|
19
|
-
onOpenChange?: (open: boolean) => void;
|
|
20
|
-
side?: Side;
|
|
21
|
-
sideOffset?: number;
|
|
22
|
-
};
|
|
23
|
-
export declare const TooltipRootBase: ({ align, alignOffset, avoidCollisions, children, defaultOpen, delayDuration, onOpenChange, open: openProp, side, sideOffset }: TooltipRootProps) => import("react/jsx-runtime").JSX.Element;
|
|
24
|
-
export type TooltipTriggerProps = ComponentPropsWithoutRef<'button'> & {
|
|
25
|
-
asChild?: boolean;
|
|
26
|
-
};
|
|
27
|
-
export declare const TooltipTriggerBase: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
28
|
-
asChild?: boolean;
|
|
29
|
-
} & import('react').RefAttributes<HTMLElement>>;
|
|
30
|
-
export type TooltipContentProps = ComponentPropsWithoutRef<'div'> & {
|
|
31
|
-
arrowPadding?: number;
|
|
32
|
-
container?: Element | DocumentFragment | null | undefined;
|
|
33
|
-
forceMount?: boolean;
|
|
34
|
-
variant?: 'default' | 'outline';
|
|
35
|
-
};
|
|
36
|
-
export declare const TooltipContentBase: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
37
|
-
arrowPadding?: number;
|
|
38
|
-
container?: Element | DocumentFragment | null | undefined;
|
|
39
|
-
forceMount?: boolean;
|
|
40
|
-
variant?: "default" | "outline";
|
|
41
|
-
} & import('react').RefAttributes<HTMLDivElement>>;
|
|
42
|
-
export type TooltipArrowProps = ComponentPropsWithoutRef<'div'> & {
|
|
43
|
-
height?: number;
|
|
44
|
-
width?: number;
|
|
45
|
-
};
|
|
46
|
-
export declare const TooltipArrowBase: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
47
|
-
height?: number;
|
|
48
|
-
width?: number;
|
|
49
|
-
} & import('react').RefAttributes<HTMLDivElement>>;
|
|
50
|
-
export {};
|
|
51
|
-
//# sourceMappingURL=TooltipBase.d.ts.map
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import "../styles/main.css";
|
|
3
|
-
import { jsx as D } from "react/jsx-runtime";
|
|
4
|
-
import { createForwardedRef as N } from "../utils/createForwardRef.js";
|
|
5
|
-
import { cn as z } from "../utils/twUtils.js";
|
|
6
|
-
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";
|
|
7
|
-
import { createPortal as S } from "react-dom";
|
|
8
|
-
const F = X(null), V = L(function({ children: a, delayDuration: d = 700, disableHoverableContent: l = !1, skipDelayDuration: p = 300 }) {
|
|
9
|
-
const c = Y(() => ({ delayDuration: d, skipDelayDuration: p, disableHoverableContent: l }), [d, p, l]);
|
|
10
|
-
return /* @__PURE__ */ D(F.Provider, { value: c, children: a });
|
|
11
|
-
}), K = X(null), Z = ({ align: u = "center", alignOffset: a = 0, avoidCollisions: d = !0, children: l, defaultOpen: p, delayDuration: c, onOpenChange: f, open: v, side: h = "top", sideOffset: t = 0 }) => {
|
|
12
|
-
const r = M(F) ?? {
|
|
13
|
-
delayDuration: 700,
|
|
14
|
-
skipDelayDuration: 300,
|
|
15
|
-
disableHoverableContent: !1
|
|
16
|
-
}, w = {
|
|
17
|
-
...r,
|
|
18
|
-
delayDuration: c ?? r.delayDuration
|
|
19
|
-
}, [e, o] = I(!!p), i = typeof v == "boolean", m = i ? v : e, y = g(
|
|
20
|
-
(x) => {
|
|
21
|
-
i || o(x), f?.(x);
|
|
22
|
-
},
|
|
23
|
-
[i, f]
|
|
24
|
-
), T = E(null), b = A(), C = Y(
|
|
25
|
-
() => ({
|
|
26
|
-
arrowPadding: 4,
|
|
27
|
-
contentId: b,
|
|
28
|
-
open: m,
|
|
29
|
-
options: { side: h, align: u, sideOffset: t, alignOffset: a, avoidCollisions: d },
|
|
30
|
-
provider: w,
|
|
31
|
-
setOpen: y,
|
|
32
|
-
triggerRef: T
|
|
33
|
-
}),
|
|
34
|
-
[m, y, h, u, t, a, d, w]
|
|
35
|
-
);
|
|
36
|
-
return /* @__PURE__ */ D(K.Provider, { value: C, children: l });
|
|
37
|
-
}, _ = L(function({ asChild: a, onPointerEnter: d, onPointerLeave: l, onFocus: p, onBlur: c, onKeyDown: f, ...v }, h) {
|
|
38
|
-
const t = H(), { provider: r } = t, w = N(t.triggerRef, h), e = E(null), o = E(null), i = E(0), m = () => {
|
|
39
|
-
e.current && window.clearTimeout(e.current), o.current && window.clearTimeout(o.current), e.current = null, o.current = null;
|
|
40
|
-
};
|
|
41
|
-
k(() => () => m(), []);
|
|
42
|
-
const y = g(() => {
|
|
43
|
-
const O = Date.now() - i.current < r.skipDelayDuration ? 0 : r.delayDuration;
|
|
44
|
-
e.current = window.setTimeout(() => t.setOpen(!0), O);
|
|
45
|
-
}, [r.skipDelayDuration, r.delayDuration, t.setOpen]), T = g(() => {
|
|
46
|
-
m(), t.setOpen(!1), i.current = Date.now();
|
|
47
|
-
}, [t.setOpen]), b = g(
|
|
48
|
-
(s) => {
|
|
49
|
-
d?.(s), (s.pointerType === "mouse" || s.pointerType === "pen") && y();
|
|
50
|
-
},
|
|
51
|
-
[d, y]
|
|
52
|
-
), C = g(
|
|
53
|
-
(s) => {
|
|
54
|
-
l?.(s), (s.pointerType === "mouse" || s.pointerType === "pen") && (o.current = window.setTimeout(() => t.setOpen(!1), 0));
|
|
55
|
-
},
|
|
56
|
-
[l, t.setOpen]
|
|
57
|
-
), x = g(
|
|
58
|
-
(s) => {
|
|
59
|
-
p?.(s), y();
|
|
60
|
-
},
|
|
61
|
-
[p, y]
|
|
62
|
-
), B = g(
|
|
63
|
-
(s) => {
|
|
64
|
-
c?.(s), T();
|
|
65
|
-
},
|
|
66
|
-
[c, T]
|
|
67
|
-
), P = g(
|
|
68
|
-
(s) => {
|
|
69
|
-
f?.(s), s.key === "Escape" && T();
|
|
70
|
-
},
|
|
71
|
-
[f, T]
|
|
72
|
-
);
|
|
73
|
-
return /* @__PURE__ */ D(a ? "span" : "button", { "aria-describedby": t.open ? t.contentId : void 0, onBlur: B, onFocus: x, onKeyDown: P, onPointerEnter: b, onPointerLeave: C, ref: w, ...v });
|
|
74
|
-
}), tt = L(function({ arrowPadding: a = 4, children: d, className: l, container: p, forceMount: c, onPointerEnter: f, onPointerLeave: v, style: h, variant: t = "default", ...r }, w) {
|
|
75
|
-
const e = H(), [o, i] = I(null), [m, y] = I(null), T = g(
|
|
76
|
-
(n) => {
|
|
77
|
-
i(n), typeof w == "function" ? w(n) : w && "current" in w && (w.current = n);
|
|
78
|
-
},
|
|
79
|
-
[w]
|
|
80
|
-
), b = g(() => {
|
|
81
|
-
if (!e.triggerRef.current || !o) return;
|
|
82
|
-
const n = j(e.triggerRef.current, o, { ...e.options, arrowPadding: a });
|
|
83
|
-
y(n);
|
|
84
|
-
}, [o, e.triggerRef, e.options, a]);
|
|
85
|
-
k(() => {
|
|
86
|
-
if (!e.open) return;
|
|
87
|
-
b();
|
|
88
|
-
const n = () => b();
|
|
89
|
-
return window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
|
|
90
|
-
window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
|
|
91
|
-
};
|
|
92
|
-
}, [e.open, b]), k(() => {
|
|
93
|
-
if (!e.open) return;
|
|
94
|
-
const n = (s) => {
|
|
95
|
-
s instanceof KeyboardEvent && s.key === "Escape" && e.setOpen(!1);
|
|
96
|
-
};
|
|
97
|
-
return window.addEventListener("keydown", n), () => window.removeEventListener("keydown", n);
|
|
98
|
-
}, [e.open, e.setOpen]);
|
|
99
|
-
const C = g(
|
|
100
|
-
(n) => {
|
|
101
|
-
f?.(n), e.provider.disableHoverableContent || e.setOpen(!0);
|
|
102
|
-
},
|
|
103
|
-
[f, e.provider.disableHoverableContent, e.setOpen]
|
|
104
|
-
), x = g(
|
|
105
|
-
(n) => {
|
|
106
|
-
v?.(n), e.provider.disableHoverableContent || e.setOpen(!1);
|
|
107
|
-
},
|
|
108
|
-
[v, e.provider.disableHoverableContent, e.setOpen]
|
|
109
|
-
), B = e.open || c ? /* @__PURE__ */ D(
|
|
110
|
-
"div",
|
|
111
|
-
{
|
|
112
|
-
className: l,
|
|
113
|
-
"data-state": e.open ? "open" : "closed",
|
|
114
|
-
"data-testid": "spectral-tooltip-content",
|
|
115
|
-
"data-variant": t,
|
|
116
|
-
id: e.contentId,
|
|
117
|
-
onPointerEnter: C,
|
|
118
|
-
onPointerLeave: x,
|
|
119
|
-
ref: T,
|
|
120
|
-
role: "tooltip",
|
|
121
|
-
style: {
|
|
122
|
-
position: "fixed",
|
|
123
|
-
left: m?.x ?? -9999,
|
|
124
|
-
top: m?.y ?? -9999,
|
|
125
|
-
transformOrigin: m ? $(m.placing) : void 0,
|
|
126
|
-
...h
|
|
127
|
-
},
|
|
128
|
-
...r,
|
|
129
|
-
children: d
|
|
130
|
-
}
|
|
131
|
-
) : null, P = typeof document < "u" ? p ?? document.body : null;
|
|
132
|
-
return P ? S(B, P) : null;
|
|
133
|
-
}), et = L(function({ width: a = 16, height: d = 16, className: l, style: p, ...c }, f) {
|
|
134
|
-
const v = H();
|
|
135
|
-
return /* @__PURE__ */ D(
|
|
136
|
-
"div",
|
|
137
|
-
{
|
|
138
|
-
"aria-hidden": !0,
|
|
139
|
-
className: z("pointer-events-none", l),
|
|
140
|
-
"data-arrow": !0,
|
|
141
|
-
"data-testid": "spectral-tooltip-arrow",
|
|
142
|
-
"data-side": v.options.side,
|
|
143
|
-
ref: f,
|
|
144
|
-
style: {
|
|
145
|
-
width: a,
|
|
146
|
-
height: d,
|
|
147
|
-
...p
|
|
148
|
-
},
|
|
149
|
-
...c
|
|
150
|
-
}
|
|
151
|
-
);
|
|
152
|
-
});
|
|
153
|
-
function H() {
|
|
154
|
-
const u = M(K);
|
|
155
|
-
if (!u) throw new Error("Tooltip components must be used within <Tooltip>");
|
|
156
|
-
return u;
|
|
157
|
-
}
|
|
158
|
-
const U = {
|
|
159
|
-
bottom: "top center",
|
|
160
|
-
left: "center right",
|
|
161
|
-
right: "center left",
|
|
162
|
-
top: "bottom center"
|
|
163
|
-
};
|
|
164
|
-
function $(u) {
|
|
165
|
-
return U[u];
|
|
166
|
-
}
|
|
167
|
-
function R(u, a, d) {
|
|
168
|
-
return Math.max(a, Math.min(d, u));
|
|
169
|
-
}
|
|
170
|
-
function j(u, a, d) {
|
|
171
|
-
const { side: l, align: p, sideOffset: c, alignOffset: f, avoidCollisions: v, arrowPadding: h } = d, t = u.getBoundingClientRect(), r = a.getBoundingClientRect(), w = window.innerWidth, e = window.innerHeight;
|
|
172
|
-
let o = 0, i = 0;
|
|
173
|
-
const m = t.left + t.width / 2 - r.width / 2, y = 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 = p === "start" ? y : p === "end" ? T : m, P = p === "start" ? C : p === "end" ? x : b;
|
|
174
|
-
l === "top" ? (o = B + f, i = t.top - r.height - c) : l === "bottom" ? (o = B + f, i = t.bottom + c) : l === "left" ? (o = t.left - r.width - c, i = P + f) : (o = t.right + c, i = P + f);
|
|
175
|
-
let n = l;
|
|
176
|
-
v && (l === "top" && i < 0 ? (n = "bottom", i = t.bottom + c) : l === "bottom" && i + r.height > e ? (n = "top", i = t.top - r.height - c) : l === "left" && o < 0 ? (n = "right", o = t.right + c) : l === "right" && o + r.width > w && (n = "left", o = t.left - r.width - c));
|
|
177
|
-
let s = t.left + t.width / 2, O = t.top + t.height / 2;
|
|
178
|
-
return n === "top" && (O = i + r.height, s = R(t.left + t.width / 2, o + h, o + r.width - h)), n === "bottom" && (O = i, s = R(t.left + t.width / 2, o + h, o + r.width - h)), n === "left" && (s = o + r.width, O = R(t.top + t.height / 2, i + h, i + r.height - h)), n === "right" && (s = o, O = R(t.top + t.height / 2, i + h, i + r.height - h)), 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 };
|
|
179
|
-
}
|
|
180
|
-
export {
|
|
181
|
-
et as TooltipArrowBase,
|
|
182
|
-
tt as TooltipContentBase,
|
|
183
|
-
V as TooltipProviderBase,
|
|
184
|
-
Z as TooltipRootBase,
|
|
185
|
-
_ as TooltipTriggerBase
|
|
186
|
-
};
|