tgui-core 2.0.0 → 2.0.2
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.
|
@@ -26,12 +26,14 @@ type Props = {
|
|
|
26
26
|
displayText: ReactNode;
|
|
27
27
|
/** Icon to display in dropdown button */
|
|
28
28
|
icon: string;
|
|
29
|
+
/** Whether the icon should be displayed alone */
|
|
30
|
+
iconOnly: boolean;
|
|
29
31
|
/** Angle of the icon */
|
|
30
32
|
iconRotation: number;
|
|
31
33
|
/** Whether or not the icon should spin */
|
|
32
34
|
iconSpin: boolean;
|
|
33
|
-
/** Width of the dropdown menu. Default:
|
|
34
|
-
menuWidth: number;
|
|
35
|
+
/** Width of the dropdown menu in box units. Default: 15 */
|
|
36
|
+
menuWidth: string | number;
|
|
35
37
|
/** Whether or not the arrow on the right hand side of the dropdown button is visible */
|
|
36
38
|
noChevron: boolean;
|
|
37
39
|
/** Dropdown renders over instead of below */
|
|
@@ -1,67 +1,69 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { KEY as
|
|
4
|
-
import { classes as
|
|
5
|
-
import { unit as
|
|
6
|
-
import { Button as
|
|
7
|
-
import { Floating as
|
|
8
|
-
import { Icon as
|
|
9
|
-
const
|
|
10
|
-
function
|
|
1
|
+
import { jsxs as u, jsx as r, Fragment as I } from "react/jsx-runtime";
|
|
2
|
+
import { useState as S, useRef as V } from "react";
|
|
3
|
+
import { KEY as O } from "../common/keys.js";
|
|
4
|
+
import { classes as D } from "../common/react.js";
|
|
5
|
+
import { unit as C } from "../common/ui.js";
|
|
6
|
+
import { Button as E } from "./Button.js";
|
|
7
|
+
import { Floating as Y } from "./Floating.js";
|
|
8
|
+
import { Icon as T } from "./Icon.js";
|
|
9
|
+
const q = -1;
|
|
10
|
+
function f(d) {
|
|
11
11
|
return typeof d == "string" ? d : d.value;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function X(d) {
|
|
14
14
|
const {
|
|
15
|
-
autoScroll:
|
|
16
|
-
buttons:
|
|
17
|
-
className:
|
|
18
|
-
color:
|
|
19
|
-
disabled:
|
|
20
|
-
displayText:
|
|
21
|
-
icon:
|
|
22
|
-
iconRotation:
|
|
23
|
-
iconSpin:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
autoScroll: v = !0,
|
|
16
|
+
buttons: k,
|
|
17
|
+
className: B,
|
|
18
|
+
color: K = "default",
|
|
19
|
+
disabled: i,
|
|
20
|
+
displayText: R,
|
|
21
|
+
icon: x,
|
|
22
|
+
iconRotation: j,
|
|
23
|
+
iconSpin: A,
|
|
24
|
+
iconOnly: h,
|
|
25
|
+
menuWidth: _,
|
|
26
|
+
noChevron: F,
|
|
27
|
+
onClick: a,
|
|
27
28
|
onSelected: t,
|
|
28
|
-
options:
|
|
29
|
-
over:
|
|
29
|
+
options: l = [],
|
|
30
|
+
over: y,
|
|
30
31
|
placeholder: W = "Select...",
|
|
31
32
|
selected: m,
|
|
32
|
-
width:
|
|
33
|
-
} = d, [
|
|
34
|
-
function
|
|
33
|
+
width: $ = 15
|
|
34
|
+
} = d, [p, P] = S(!1), N = V(null), s = l.findIndex((e) => f(e) === m) || 0;
|
|
35
|
+
function g(e) {
|
|
35
36
|
let n = e;
|
|
36
|
-
e <
|
|
37
|
-
const o =
|
|
37
|
+
e < s ? n = e < 2 ? 0 : e - 2 : n = e > l.length - 3 ? l.length - 1 : e - 2;
|
|
38
|
+
const o = N.current, c = o == null ? void 0 : o.children[n];
|
|
38
39
|
o && c && (o.scrollTop = c.offsetTop);
|
|
39
40
|
}
|
|
40
|
-
function
|
|
41
|
-
if (
|
|
41
|
+
function b(e) {
|
|
42
|
+
if (l.length < 1 || i)
|
|
42
43
|
return;
|
|
43
|
-
const n = 0, o =
|
|
44
|
+
const n = 0, o = l.length - 1;
|
|
44
45
|
let c;
|
|
45
|
-
|
|
46
|
+
s < 0 ? c = e === "next" ? o : n : e === "next" ? c = s === o ? n : s + 1 : c = s === n ? o : s - 1, p && v && g(c), t == null || t(f(l[c]));
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
+
let w = y ? "top" : "bottom";
|
|
49
|
+
return h && (w = `${w}-start`), /* @__PURE__ */ u("div", { className: "Dropdown", children: [
|
|
48
50
|
/* @__PURE__ */ r(
|
|
49
|
-
|
|
51
|
+
Y,
|
|
50
52
|
{
|
|
51
|
-
contentAutoWidth: !0,
|
|
52
|
-
closeAfterInteract: !0,
|
|
53
|
-
placement: D ? "top" : "bottom",
|
|
54
53
|
allowedOutsideClasses: ".Dropdown__button",
|
|
54
|
+
closeAfterInteract: !0,
|
|
55
|
+
contentAutoWidth: !_,
|
|
55
56
|
contentClasses: "Dropdown__menu--wrapper",
|
|
56
|
-
contentStyles: {
|
|
57
|
-
disabled:
|
|
58
|
-
onOpenChange:
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
contentStyles: { width: _ ? C(_) : void 0 },
|
|
58
|
+
disabled: i,
|
|
59
|
+
onOpenChange: P,
|
|
60
|
+
placement: w,
|
|
61
|
+
content: /* @__PURE__ */ r("div", { ref: N, className: "Dropdown__menu", children: l.length === 0 ? /* @__PURE__ */ r("div", { className: "Dropdown__menu--entry", children: "No options" }) : l.map((e) => {
|
|
62
|
+
const n = f(e);
|
|
61
63
|
return /* @__PURE__ */ r(
|
|
62
64
|
"div",
|
|
63
65
|
{
|
|
64
|
-
className:
|
|
66
|
+
className: D([
|
|
65
67
|
"Dropdown__menu--entry",
|
|
66
68
|
m === n && "selected"
|
|
67
69
|
]),
|
|
@@ -69,7 +71,7 @@ function Q(d) {
|
|
|
69
71
|
t == null || t(n);
|
|
70
72
|
},
|
|
71
73
|
onKeyDown: (o) => {
|
|
72
|
-
o.key ===
|
|
74
|
+
o.key === O.Enter && (t == null || t(n));
|
|
73
75
|
},
|
|
74
76
|
children: typeof e == "string" ? e : e.displayText
|
|
75
77
|
},
|
|
@@ -77,61 +79,64 @@ function Q(d) {
|
|
|
77
79
|
);
|
|
78
80
|
}) }),
|
|
79
81
|
onMounted: () => {
|
|
80
|
-
|
|
82
|
+
p && v && s !== q && g(s);
|
|
81
83
|
},
|
|
82
|
-
children: /* @__PURE__ */
|
|
84
|
+
children: /* @__PURE__ */ u(
|
|
83
85
|
"div",
|
|
84
86
|
{
|
|
85
|
-
className:
|
|
87
|
+
className: D([
|
|
86
88
|
"Dropdown__control",
|
|
87
|
-
`Button--color--${
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
`Button--color--${K}`,
|
|
90
|
+
i && "Button--disabled",
|
|
91
|
+
h && "Dropdown__control--icon-only",
|
|
92
|
+
B
|
|
90
93
|
]),
|
|
91
|
-
style: { width:
|
|
94
|
+
style: { width: C($) },
|
|
92
95
|
onClick: (e) => {
|
|
93
|
-
|
|
96
|
+
i && !p || a == null || a(e);
|
|
94
97
|
},
|
|
95
98
|
onKeyDown: (e) => {
|
|
96
|
-
e.key ===
|
|
99
|
+
e.key === O.Enter && !i && (a == null || a(e));
|
|
97
100
|
},
|
|
98
101
|
children: [
|
|
99
|
-
|
|
100
|
-
|
|
102
|
+
x && /* @__PURE__ */ r(
|
|
103
|
+
T,
|
|
101
104
|
{
|
|
102
105
|
className: "Dropdown__icon",
|
|
103
|
-
name:
|
|
104
|
-
rotation:
|
|
105
|
-
spin:
|
|
106
|
+
name: x,
|
|
107
|
+
rotation: j,
|
|
108
|
+
spin: A
|
|
106
109
|
}
|
|
107
110
|
),
|
|
108
|
-
/* @__PURE__ */
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
111
|
+
!h && /* @__PURE__ */ u(I, { children: [
|
|
112
|
+
/* @__PURE__ */ r("span", { className: "Dropdown__selected-text", children: R || m && f(m) || W }),
|
|
113
|
+
!F && /* @__PURE__ */ r(
|
|
114
|
+
T,
|
|
115
|
+
{
|
|
116
|
+
className: D([
|
|
117
|
+
"Dropdown__icon",
|
|
118
|
+
"Dropdown__icon--arrow",
|
|
119
|
+
y && "over",
|
|
120
|
+
p && "open"
|
|
121
|
+
]),
|
|
122
|
+
name: "chevron-down"
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
] })
|
|
121
126
|
]
|
|
122
127
|
}
|
|
123
128
|
)
|
|
124
129
|
}
|
|
125
130
|
),
|
|
126
|
-
|
|
131
|
+
k && /* @__PURE__ */ u(I, { children: [
|
|
127
132
|
/* @__PURE__ */ r(
|
|
128
|
-
|
|
133
|
+
E,
|
|
129
134
|
{
|
|
130
135
|
className: "Dropdown__button",
|
|
131
|
-
disabled:
|
|
136
|
+
disabled: i,
|
|
132
137
|
icon: "chevron-left",
|
|
133
138
|
onClick: () => {
|
|
134
|
-
|
|
139
|
+
b(
|
|
135
140
|
"previous"
|
|
136
141
|
/* Previous */
|
|
137
142
|
);
|
|
@@ -139,13 +144,13 @@ function Q(d) {
|
|
|
139
144
|
}
|
|
140
145
|
),
|
|
141
146
|
/* @__PURE__ */ r(
|
|
142
|
-
|
|
147
|
+
E,
|
|
143
148
|
{
|
|
144
149
|
className: "Dropdown__button",
|
|
145
|
-
disabled:
|
|
150
|
+
disabled: i,
|
|
146
151
|
icon: "chevron-right",
|
|
147
152
|
onClick: () => {
|
|
148
|
-
|
|
153
|
+
b(
|
|
149
154
|
"next"
|
|
150
155
|
/* Next */
|
|
151
156
|
);
|
|
@@ -156,5 +161,5 @@ function Q(d) {
|
|
|
156
161
|
] });
|
|
157
162
|
}
|
|
158
163
|
export {
|
|
159
|
-
|
|
164
|
+
X as Dropdown
|
|
160
165
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as mt, jsx as ne, Fragment as zt } from "react/jsx-runtime";
|
|
2
|
-
import * as
|
|
2
|
+
import * as m from "react";
|
|
3
3
|
import { useLayoutEffect as gt, useEffect as pt, useRef as Xt, useState as Gt, isValidElement as Zt, cloneElement as Jt } from "react";
|
|
4
4
|
import * as ht from "react-dom";
|
|
5
5
|
import { classes as Qt } from "../common/react.js";
|
|
@@ -308,10 +308,10 @@ var bn = ["input:not([inert])", "select:not([inert])", "textarea:not([inert])",
|
|
|
308
308
|
var g = i.shadowRoot || // check for an undisclosed shadow
|
|
309
309
|
typeof r.getShadowRoot == "function" && r.getShadowRoot(i), h = !Ce(g, !1) && (!r.shadowRootFilter || r.shadowRootFilter(i));
|
|
310
310
|
if (g && h) {
|
|
311
|
-
var
|
|
312
|
-
r.flatten ? o.push.apply(o,
|
|
311
|
+
var d = e(g === !0 ? i.children : g.children, !0, r);
|
|
312
|
+
r.flatten ? o.push.apply(o, d) : o.push({
|
|
313
313
|
scopeParent: i,
|
|
314
|
-
candidates:
|
|
314
|
+
candidates: d
|
|
315
315
|
});
|
|
316
316
|
} else
|
|
317
317
|
s.unshift.apply(s, i.children);
|
|
@@ -454,47 +454,47 @@ function Je(e, t, n) {
|
|
|
454
454
|
floating: o
|
|
455
455
|
} = e;
|
|
456
456
|
const s = se(t), i = wt(t), c = yt(i), l = re(t), a = s === "y", u = r.x + r.width / 2 - o.width / 2, g = r.y + r.height / 2 - o.height / 2, h = r[c] / 2 - o[c] / 2;
|
|
457
|
-
let
|
|
457
|
+
let d;
|
|
458
458
|
switch (l) {
|
|
459
459
|
case "top":
|
|
460
|
-
|
|
460
|
+
d = {
|
|
461
461
|
x: u,
|
|
462
462
|
y: r.y - o.height
|
|
463
463
|
};
|
|
464
464
|
break;
|
|
465
465
|
case "bottom":
|
|
466
|
-
|
|
466
|
+
d = {
|
|
467
467
|
x: u,
|
|
468
468
|
y: r.y + r.height
|
|
469
469
|
};
|
|
470
470
|
break;
|
|
471
471
|
case "right":
|
|
472
|
-
|
|
472
|
+
d = {
|
|
473
473
|
x: r.x + r.width,
|
|
474
474
|
y: g
|
|
475
475
|
};
|
|
476
476
|
break;
|
|
477
477
|
case "left":
|
|
478
|
-
|
|
478
|
+
d = {
|
|
479
479
|
x: r.x - o.width,
|
|
480
480
|
y: g
|
|
481
481
|
};
|
|
482
482
|
break;
|
|
483
483
|
default:
|
|
484
|
-
|
|
484
|
+
d = {
|
|
485
485
|
x: r.x,
|
|
486
486
|
y: r.y
|
|
487
487
|
};
|
|
488
488
|
}
|
|
489
489
|
switch (pe(t)) {
|
|
490
490
|
case "start":
|
|
491
|
-
|
|
491
|
+
d[i] -= h * (n && a ? -1 : 1);
|
|
492
492
|
break;
|
|
493
493
|
case "end":
|
|
494
|
-
|
|
494
|
+
d[i] += h * (n && a ? -1 : 1);
|
|
495
495
|
break;
|
|
496
496
|
}
|
|
497
|
-
return
|
|
497
|
+
return d;
|
|
498
498
|
}
|
|
499
499
|
const Nn = async (e, t, n) => {
|
|
500
500
|
const {
|
|
@@ -510,7 +510,7 @@ const Nn = async (e, t, n) => {
|
|
|
510
510
|
}), {
|
|
511
511
|
x: u,
|
|
512
512
|
y: g
|
|
513
|
-
} = Je(a, r, l), h = r,
|
|
513
|
+
} = Je(a, r, l), h = r, d = {}, x = 0;
|
|
514
514
|
for (let f = 0; f < c.length; f++) {
|
|
515
515
|
const {
|
|
516
516
|
name: y,
|
|
@@ -526,7 +526,7 @@ const Nn = async (e, t, n) => {
|
|
|
526
526
|
initialPlacement: r,
|
|
527
527
|
placement: h,
|
|
528
528
|
strategy: o,
|
|
529
|
-
middlewareData:
|
|
529
|
+
middlewareData: d,
|
|
530
530
|
rects: a,
|
|
531
531
|
platform: i,
|
|
532
532
|
elements: {
|
|
@@ -534,10 +534,10 @@ const Nn = async (e, t, n) => {
|
|
|
534
534
|
floating: t
|
|
535
535
|
}
|
|
536
536
|
});
|
|
537
|
-
u = E ?? u, g = w ?? g,
|
|
538
|
-
...
|
|
537
|
+
u = E ?? u, g = w ?? g, d = {
|
|
538
|
+
...d,
|
|
539
539
|
[y]: {
|
|
540
|
-
...
|
|
540
|
+
...d[y],
|
|
541
541
|
...T
|
|
542
542
|
}
|
|
543
543
|
}, C && x <= 50 && (x++, typeof C == "object" && (C.placement && (h = C.placement), C.rects && (a = C.rects === !0 ? await i.getElementRects({
|
|
@@ -554,7 +554,7 @@ const Nn = async (e, t, n) => {
|
|
|
554
554
|
y: g,
|
|
555
555
|
placement: h,
|
|
556
556
|
strategy: o,
|
|
557
|
-
middlewareData:
|
|
557
|
+
middlewareData: d
|
|
558
558
|
};
|
|
559
559
|
};
|
|
560
560
|
async function Tt(e, t) {
|
|
@@ -572,8 +572,8 @@ async function Tt(e, t) {
|
|
|
572
572
|
rootBoundary: u = "viewport",
|
|
573
573
|
elementContext: g = "floating",
|
|
574
574
|
altBoundary: h = !1,
|
|
575
|
-
padding:
|
|
576
|
-
} = Me(t, e), x = vn(
|
|
575
|
+
padding: d = 0
|
|
576
|
+
} = Me(t, e), x = vn(d), y = c[h ? g === "floating" ? "reference" : "floating" : g], R = Re(await s.getClippingRect({
|
|
577
577
|
element: (n = await (s.isElement == null ? void 0 : s.isElement(y))) == null || n ? y : y.contextElement || await (s.getDocumentElement == null ? void 0 : s.getDocumentElement(c.floating)),
|
|
578
578
|
boundary: a,
|
|
579
579
|
rootBoundary: u,
|
|
@@ -619,7 +619,7 @@ const Bn = function(e) {
|
|
|
619
619
|
mainAxis: u = !0,
|
|
620
620
|
crossAxis: g = !0,
|
|
621
621
|
fallbackPlacements: h,
|
|
622
|
-
fallbackStrategy:
|
|
622
|
+
fallbackStrategy: d = "bestFit",
|
|
623
623
|
fallbackAxisSideDirection: x = "none",
|
|
624
624
|
flipAlignment: f = !0,
|
|
625
625
|
...y
|
|
@@ -652,7 +652,7 @@ const Bn = function(e) {
|
|
|
652
652
|
};
|
|
653
653
|
let A = ($ = N.filter((b) => b.overflows[0] <= 0).sort((b, p) => b.overflows[1] - p.overflows[1])[0]) == null ? void 0 : $.placement;
|
|
654
654
|
if (!A)
|
|
655
|
-
switch (
|
|
655
|
+
switch (d) {
|
|
656
656
|
case "bestFit": {
|
|
657
657
|
var F;
|
|
658
658
|
const b = (F = N.filter((p) => {
|
|
@@ -690,7 +690,7 @@ async function Wn(e, t) {
|
|
|
690
690
|
} = e, s = await (r.isRTL == null ? void 0 : r.isRTL(o.floating)), i = re(n), c = pe(n), l = se(n) === "y", a = ["left", "top"].includes(i) ? -1 : 1, u = s && l ? -1 : 1, g = Me(t, e);
|
|
691
691
|
let {
|
|
692
692
|
mainAxis: h,
|
|
693
|
-
crossAxis:
|
|
693
|
+
crossAxis: d,
|
|
694
694
|
alignmentAxis: x
|
|
695
695
|
} = typeof g == "number" ? {
|
|
696
696
|
mainAxis: g,
|
|
@@ -701,12 +701,12 @@ async function Wn(e, t) {
|
|
|
701
701
|
crossAxis: g.crossAxis || 0,
|
|
702
702
|
alignmentAxis: g.alignmentAxis
|
|
703
703
|
};
|
|
704
|
-
return c && typeof x == "number" && (
|
|
705
|
-
x:
|
|
704
|
+
return c && typeof x == "number" && (d = c === "end" ? x * -1 : x), l ? {
|
|
705
|
+
x: d * u,
|
|
706
706
|
y: h * a
|
|
707
707
|
} : {
|
|
708
708
|
x: h * a,
|
|
709
|
-
y:
|
|
709
|
+
y: d * u
|
|
710
710
|
};
|
|
711
711
|
}
|
|
712
712
|
const $n = function(e) {
|
|
@@ -746,7 +746,7 @@ const $n = function(e) {
|
|
|
746
746
|
apply: l = () => {
|
|
747
747
|
},
|
|
748
748
|
...a
|
|
749
|
-
} = Me(e, t), u = await Tt(t, a), g = re(o), h = pe(o),
|
|
749
|
+
} = Me(e, t), u = await Tt(t, a), g = re(o), h = pe(o), d = se(o) === "y", {
|
|
750
750
|
width: x,
|
|
751
751
|
height: f
|
|
752
752
|
} = s.floating;
|
|
@@ -756,7 +756,7 @@ const $n = function(e) {
|
|
|
756
756
|
let M = T, W = C;
|
|
757
757
|
if ((n = t.middlewareData.shift) != null && n.enabled.x && (W = w), (r = t.middlewareData.shift) != null && r.enabled.y && (M = E), D && !h) {
|
|
758
758
|
const N = Y(u.left, 0), B = Y(u.right, 0), $ = Y(u.top, 0), F = Y(u.bottom, 0);
|
|
759
|
-
|
|
759
|
+
d ? W = x - 2 * (N !== 0 || B !== 0 ? N + B : Y(u.left, u.right)) : M = f - 2 * ($ !== 0 || F !== 0 ? $ + F : Y(u.top, u.bottom));
|
|
760
760
|
}
|
|
761
761
|
await l({
|
|
762
762
|
...t,
|
|
@@ -819,9 +819,9 @@ function oe(e, t, n, r) {
|
|
|
819
819
|
const c = Hn(s, n, r) ? Pt(s) : z(0);
|
|
820
820
|
let l = (o.left + c.x) / i.x, a = (o.top + c.y) / i.y, u = o.width / i.x, g = o.height / i.y;
|
|
821
821
|
if (s) {
|
|
822
|
-
const h = K(s),
|
|
822
|
+
const h = K(s), d = r && k(r) ? K(r) : r;
|
|
823
823
|
let x = h, f = _e(x);
|
|
824
|
-
for (; f && r &&
|
|
824
|
+
for (; f && r && d !== x; ) {
|
|
825
825
|
const y = ie(f), R = f.getBoundingClientRect(), E = U(f), w = R.left + (f.clientLeft + parseFloat(E.paddingLeft)) * y.x, T = R.top + (f.clientTop + parseFloat(E.paddingTop)) * y.y;
|
|
826
826
|
l *= y.x, a *= y.y, u *= y.x, g *= y.y, l += w, a += T, x = K(f), f = _e(x);
|
|
827
827
|
}
|
|
@@ -864,8 +864,8 @@ function Kn(e) {
|
|
|
864
864
|
}, a = z(1);
|
|
865
865
|
const u = z(0), g = _(r);
|
|
866
866
|
if ((g || !g && !s) && ((ce(r) !== "body" || ge(i)) && (l = Ae(r)), _(r))) {
|
|
867
|
-
const
|
|
868
|
-
a = ie(r), u.x =
|
|
867
|
+
const d = oe(r);
|
|
868
|
+
a = ie(r), u.x = d.x + r.clientLeft, u.y = d.y + r.clientTop;
|
|
869
869
|
}
|
|
870
870
|
const h = i && !g && !s ? At(i, l, !0) : z(0);
|
|
871
871
|
return {
|
|
@@ -1069,11 +1069,11 @@ function tr(e, t) {
|
|
|
1069
1069
|
left: u,
|
|
1070
1070
|
top: g,
|
|
1071
1071
|
width: h,
|
|
1072
|
-
height:
|
|
1072
|
+
height: d
|
|
1073
1073
|
} = a;
|
|
1074
|
-
if (c || t(), !h || !
|
|
1074
|
+
if (c || t(), !h || !d)
|
|
1075
1075
|
return;
|
|
1076
|
-
const x = ve(g), f = ve(o.clientWidth - (u + h)), y = ve(o.clientHeight - (g +
|
|
1076
|
+
const x = ve(g), f = ve(o.clientWidth - (u + h)), y = ve(o.clientHeight - (g + d)), R = ve(u), w = {
|
|
1077
1077
|
rootMargin: -x + "px " + -f + "px " + -y + "px " + -R + "px",
|
|
1078
1078
|
threshold: Y(0, de(1, l)) || 1
|
|
1079
1079
|
};
|
|
@@ -1117,14 +1117,14 @@ function nr(e, t, n, r) {
|
|
|
1117
1117
|
}), s && R.addEventListener("resize", n);
|
|
1118
1118
|
});
|
|
1119
1119
|
const g = a && c ? tr(a, n) : null;
|
|
1120
|
-
let h = -1,
|
|
1121
|
-
i && (
|
|
1120
|
+
let h = -1, d = null;
|
|
1121
|
+
i && (d = new ResizeObserver((R) => {
|
|
1122
1122
|
let [E] = R;
|
|
1123
|
-
E && E.target === a &&
|
|
1123
|
+
E && E.target === a && d && (d.unobserve(t), cancelAnimationFrame(h), h = requestAnimationFrame(() => {
|
|
1124
1124
|
var w;
|
|
1125
|
-
(w =
|
|
1125
|
+
(w = d) == null || w.observe(t);
|
|
1126
1126
|
})), n();
|
|
1127
|
-
}), a && !l &&
|
|
1127
|
+
}), a && !l && d.observe(a), d.observe(t));
|
|
1128
1128
|
let x, f = l ? oe(e) : null;
|
|
1129
1129
|
l && y();
|
|
1130
1130
|
function y() {
|
|
@@ -1135,7 +1135,7 @@ function nr(e, t, n, r) {
|
|
|
1135
1135
|
var R;
|
|
1136
1136
|
u.forEach((E) => {
|
|
1137
1137
|
o && E.removeEventListener("scroll", n), s && E.removeEventListener("resize", n);
|
|
1138
|
-
}), g == null || g(), (R =
|
|
1138
|
+
}), g == null || g(), (R = d) == null || R.disconnect(), d = null, l && cancelAnimationFrame(x);
|
|
1139
1139
|
};
|
|
1140
1140
|
}
|
|
1141
1141
|
const rr = $n, or = Bn, ir = Vn, sr = (e, t, n) => {
|
|
@@ -1190,7 +1190,7 @@ function tt(e, t) {
|
|
|
1190
1190
|
return Math.round(t * n) / n;
|
|
1191
1191
|
}
|
|
1192
1192
|
function ke(e) {
|
|
1193
|
-
const t =
|
|
1193
|
+
const t = m.useRef(e);
|
|
1194
1194
|
return be(() => {
|
|
1195
1195
|
t.current = e;
|
|
1196
1196
|
}), t;
|
|
@@ -1209,20 +1209,20 @@ function cr(e) {
|
|
|
1209
1209
|
transform: c = !0,
|
|
1210
1210
|
whileElementsMounted: l,
|
|
1211
1211
|
open: a
|
|
1212
|
-
} = e, [u, g] =
|
|
1212
|
+
} = e, [u, g] = m.useState({
|
|
1213
1213
|
x: 0,
|
|
1214
1214
|
y: 0,
|
|
1215
1215
|
strategy: n,
|
|
1216
1216
|
placement: t,
|
|
1217
1217
|
middlewareData: {},
|
|
1218
1218
|
isPositioned: !1
|
|
1219
|
-
}), [h,
|
|
1220
|
-
Se(h, r) ||
|
|
1221
|
-
const [x, f] =
|
|
1219
|
+
}), [h, d] = m.useState(r);
|
|
1220
|
+
Se(h, r) || d(r);
|
|
1221
|
+
const [x, f] = m.useState(null), [y, R] = m.useState(null), E = m.useCallback((p) => {
|
|
1222
1222
|
p !== D.current && (D.current = p, f(p));
|
|
1223
|
-
}, []), w =
|
|
1223
|
+
}, []), w = m.useCallback((p) => {
|
|
1224
1224
|
p !== M.current && (M.current = p, R(p));
|
|
1225
|
-
}, []), T = s || x, C = i || y, D =
|
|
1225
|
+
}, []), T = s || x, C = i || y, D = m.useRef(null), M = m.useRef(null), W = m.useRef(u), L = l != null, N = ke(l), B = ke(o), $ = ke(a), F = m.useCallback(() => {
|
|
1226
1226
|
if (!D.current || !M.current)
|
|
1227
1227
|
return;
|
|
1228
1228
|
const p = {
|
|
@@ -1250,7 +1250,7 @@ function cr(e) {
|
|
|
1250
1250
|
isPositioned: !1
|
|
1251
1251
|
})));
|
|
1252
1252
|
}, [a]);
|
|
1253
|
-
const I =
|
|
1253
|
+
const I = m.useRef(!1);
|
|
1254
1254
|
be(() => (I.current = !0, () => {
|
|
1255
1255
|
I.current = !1;
|
|
1256
1256
|
}), []), be(() => {
|
|
@@ -1260,15 +1260,15 @@ function cr(e) {
|
|
|
1260
1260
|
F();
|
|
1261
1261
|
}
|
|
1262
1262
|
}, [T, C, F, N, L]);
|
|
1263
|
-
const S =
|
|
1263
|
+
const S = m.useMemo(() => ({
|
|
1264
1264
|
reference: D,
|
|
1265
1265
|
floating: M,
|
|
1266
1266
|
setReference: E,
|
|
1267
1267
|
setFloating: w
|
|
1268
|
-
}), [E, w]), A =
|
|
1268
|
+
}), [E, w]), A = m.useMemo(() => ({
|
|
1269
1269
|
reference: T,
|
|
1270
1270
|
floating: C
|
|
1271
|
-
}), [T, C]), b =
|
|
1271
|
+
}), [T, C]), b = m.useMemo(() => {
|
|
1272
1272
|
const p = {
|
|
1273
1273
|
position: n,
|
|
1274
1274
|
left: 0,
|
|
@@ -1289,7 +1289,7 @@ function cr(e) {
|
|
|
1289
1289
|
top: P
|
|
1290
1290
|
};
|
|
1291
1291
|
}, [n, c, A.floating, u.x, u.y]);
|
|
1292
|
-
return
|
|
1292
|
+
return m.useMemo(() => ({
|
|
1293
1293
|
...u,
|
|
1294
1294
|
update: F,
|
|
1295
1295
|
refs: S,
|
|
@@ -1307,16 +1307,16 @@ const lr = (e, t) => ({
|
|
|
1307
1307
|
...ir(e),
|
|
1308
1308
|
options: [e, t]
|
|
1309
1309
|
}), kt = {
|
|
1310
|
-
...
|
|
1310
|
+
...m
|
|
1311
1311
|
}, fr = kt.useInsertionEffect, dr = fr || ((e) => e());
|
|
1312
1312
|
function Z(e) {
|
|
1313
|
-
const t =
|
|
1313
|
+
const t = m.useRef(() => {
|
|
1314
1314
|
if (process.env.NODE_ENV !== "production")
|
|
1315
1315
|
throw new Error("Cannot call an event handler while rendering.");
|
|
1316
1316
|
});
|
|
1317
1317
|
return dr(() => {
|
|
1318
1318
|
t.current = e;
|
|
1319
|
-
}),
|
|
1319
|
+
}), m.useCallback(function() {
|
|
1320
1320
|
for (var n = arguments.length, r = new Array(n), o = 0; o < n; o++)
|
|
1321
1321
|
r[o] = arguments[o];
|
|
1322
1322
|
return t.current == null ? void 0 : t.current(...r);
|
|
@@ -1330,10 +1330,10 @@ const rt = () => (
|
|
|
1330
1330
|
"floating-ui-" + Math.random().toString(36).slice(2, 6) + mr++
|
|
1331
1331
|
);
|
|
1332
1332
|
function gr() {
|
|
1333
|
-
const [e, t] =
|
|
1333
|
+
const [e, t] = m.useState(() => nt ? rt() : void 0);
|
|
1334
1334
|
return q(() => {
|
|
1335
1335
|
e == null && t(rt());
|
|
1336
|
-
}, []),
|
|
1336
|
+
}, []), m.useEffect(() => {
|
|
1337
1337
|
nt = !0;
|
|
1338
1338
|
}, []), e;
|
|
1339
1339
|
}
|
|
@@ -1365,10 +1365,10 @@ function vr() {
|
|
|
1365
1365
|
}
|
|
1366
1366
|
};
|
|
1367
1367
|
}
|
|
1368
|
-
const br = /* @__PURE__ */
|
|
1368
|
+
const br = /* @__PURE__ */ m.createContext(null), yr = /* @__PURE__ */ m.createContext(null), Nt = () => {
|
|
1369
1369
|
var e;
|
|
1370
|
-
return ((e =
|
|
1371
|
-
}, ze = () =>
|
|
1370
|
+
return ((e = m.useContext(br)) == null ? void 0 : e.id) || null;
|
|
1371
|
+
}, ze = () => m.useContext(yr);
|
|
1372
1372
|
function De(e) {
|
|
1373
1373
|
return "data-floating-ui-" + e;
|
|
1374
1374
|
}
|
|
@@ -1400,13 +1400,13 @@ function wr(e, t) {
|
|
|
1400
1400
|
mouseOnly: u = !1,
|
|
1401
1401
|
restMs: g = 0,
|
|
1402
1402
|
move: h = !0
|
|
1403
|
-
} = t,
|
|
1404
|
-
}), L =
|
|
1403
|
+
} = t, d = ze(), x = Nt(), f = Fe(a), y = Fe(l), R = Fe(n), E = m.useRef(), w = m.useRef(-1), T = m.useRef(), C = m.useRef(-1), D = m.useRef(!0), M = m.useRef(!1), W = m.useRef(() => {
|
|
1404
|
+
}), L = m.useRef(!1), N = m.useCallback(() => {
|
|
1405
1405
|
var b;
|
|
1406
1406
|
const p = (b = o.current.openEvent) == null ? void 0 : b.type;
|
|
1407
1407
|
return (p == null ? void 0 : p.includes("mouse")) && p !== "mousedown";
|
|
1408
1408
|
}, [o]);
|
|
1409
|
-
|
|
1409
|
+
m.useEffect(() => {
|
|
1410
1410
|
if (!c) return;
|
|
1411
1411
|
function b(p) {
|
|
1412
1412
|
let {
|
|
@@ -1417,7 +1417,7 @@ function wr(e, t) {
|
|
|
1417
1417
|
return s.on("openchange", b), () => {
|
|
1418
1418
|
s.off("openchange", b);
|
|
1419
1419
|
};
|
|
1420
|
-
}, [c, s]),
|
|
1420
|
+
}, [c, s]), m.useEffect(() => {
|
|
1421
1421
|
if (!c || !f.current || !n) return;
|
|
1422
1422
|
function b(v) {
|
|
1423
1423
|
N() && r(!1, v, "hover");
|
|
@@ -1427,7 +1427,7 @@ function wr(e, t) {
|
|
|
1427
1427
|
p.removeEventListener("mouseleave", b);
|
|
1428
1428
|
};
|
|
1429
1429
|
}, [i.floating, n, r, c, f, N]);
|
|
1430
|
-
const B =
|
|
1430
|
+
const B = m.useCallback(function(b, p, v) {
|
|
1431
1431
|
p === void 0 && (p = !0), v === void 0 && (v = "hover");
|
|
1432
1432
|
const P = Ne(y.current, "close", E.current);
|
|
1433
1433
|
P && !T.current ? (j(w), w.current = window.setTimeout(() => r(!1, b, v), P)) : p && (j(w), r(!1, b, v));
|
|
@@ -1439,7 +1439,7 @@ function wr(e, t) {
|
|
|
1439
1439
|
b.style.pointerEvents = "", b.removeAttribute(ot), M.current = !1;
|
|
1440
1440
|
}
|
|
1441
1441
|
}), I = Z(() => o.current.openEvent ? ["click", "mousedown"].includes(o.current.openEvent.type) : !1);
|
|
1442
|
-
|
|
1442
|
+
m.useEffect(() => {
|
|
1443
1443
|
if (!c) return;
|
|
1444
1444
|
function b(O) {
|
|
1445
1445
|
if (j(w), D.current = !1, u && !fe(E.current) || g > 0 && !Ne(y.current, "open"))
|
|
@@ -1456,7 +1456,7 @@ function wr(e, t) {
|
|
|
1456
1456
|
if (j(C), L.current = !1, f.current && o.current.floatingContext) {
|
|
1457
1457
|
n || j(w), T.current = f.current({
|
|
1458
1458
|
...o.current.floatingContext,
|
|
1459
|
-
tree:
|
|
1459
|
+
tree: d,
|
|
1460
1460
|
x: O.clientX,
|
|
1461
1461
|
y: O.clientY,
|
|
1462
1462
|
onClose() {
|
|
@@ -1474,7 +1474,7 @@ function wr(e, t) {
|
|
|
1474
1474
|
function v(O) {
|
|
1475
1475
|
I() || o.current.floatingContext && (f.current == null || f.current({
|
|
1476
1476
|
...o.current.floatingContext,
|
|
1477
|
-
tree:
|
|
1477
|
+
tree: d,
|
|
1478
1478
|
x: O.clientX,
|
|
1479
1479
|
y: O.clientY,
|
|
1480
1480
|
onClose() {
|
|
@@ -1492,7 +1492,7 @@ function wr(e, t) {
|
|
|
1492
1492
|
n && O.removeEventListener("mouseleave", v), (V = i.floating) == null || V.removeEventListener("mouseleave", v), h && O.removeEventListener("mousemove", b), O.removeEventListener("mouseenter", b), O.removeEventListener("mouseleave", p);
|
|
1493
1493
|
};
|
|
1494
1494
|
}
|
|
1495
|
-
}, [i, c, e, u, g, h, B, $, F, r, n, R,
|
|
1495
|
+
}, [i, c, e, u, g, h, B, $, F, r, n, R, d, y, f, o, I]), q(() => {
|
|
1496
1496
|
var b;
|
|
1497
1497
|
if (c && n && (b = f.current) != null && b.__options.blockPointerEvents && N()) {
|
|
1498
1498
|
M.current = !0;
|
|
@@ -1501,18 +1501,18 @@ function wr(e, t) {
|
|
|
1501
1501
|
var p;
|
|
1502
1502
|
const P = J(i.floating).body;
|
|
1503
1503
|
P.setAttribute(ot, "");
|
|
1504
|
-
const O = i.domReference, V =
|
|
1504
|
+
const O = i.domReference, V = d == null || (p = d.nodesRef.current.find((le) => le.id === x)) == null || (p = p.context) == null ? void 0 : p.elements.floating;
|
|
1505
1505
|
return V && (V.style.pointerEvents = ""), P.style.pointerEvents = "none", O.style.pointerEvents = "auto", v.style.pointerEvents = "auto", () => {
|
|
1506
1506
|
P.style.pointerEvents = "", O.style.pointerEvents = "", v.style.pointerEvents = "";
|
|
1507
1507
|
};
|
|
1508
1508
|
}
|
|
1509
1509
|
}
|
|
1510
|
-
}, [c, n, x, i,
|
|
1510
|
+
}, [c, n, x, i, d, f, N]), q(() => {
|
|
1511
1511
|
n || (E.current = void 0, L.current = !1, $(), F());
|
|
1512
|
-
}, [n, $, F]),
|
|
1512
|
+
}, [n, $, F]), m.useEffect(() => () => {
|
|
1513
1513
|
$(), j(w), j(C), F();
|
|
1514
1514
|
}, [c, i.domReference, $, F]);
|
|
1515
|
-
const S =
|
|
1515
|
+
const S = m.useMemo(() => {
|
|
1516
1516
|
function b(p) {
|
|
1517
1517
|
E.current = p.pointerType;
|
|
1518
1518
|
}
|
|
@@ -1529,7 +1529,7 @@ function wr(e, t) {
|
|
|
1529
1529
|
u && !fe(E.current) || n || g === 0 || L.current && p.movementX ** 2 + p.movementY ** 2 < 2 || (j(C), E.current === "touch" ? P() : (L.current = !0, C.current = window.setTimeout(P, g)));
|
|
1530
1530
|
}
|
|
1531
1531
|
};
|
|
1532
|
-
}, [u, r, n, R, g]), A =
|
|
1532
|
+
}, [u, r, n, R, g]), A = m.useMemo(() => ({
|
|
1533
1533
|
onMouseEnter() {
|
|
1534
1534
|
j(w);
|
|
1535
1535
|
},
|
|
@@ -1537,7 +1537,7 @@ function wr(e, t) {
|
|
|
1537
1537
|
I() || B(b.nativeEvent, !1);
|
|
1538
1538
|
}
|
|
1539
1539
|
}), [B, I]);
|
|
1540
|
-
return
|
|
1540
|
+
return m.useMemo(() => c ? {
|
|
1541
1541
|
reference: S,
|
|
1542
1542
|
floating: A
|
|
1543
1543
|
} : {}, [c, S, A]);
|
|
@@ -1605,8 +1605,8 @@ const $t = {
|
|
|
1605
1605
|
width: "1px",
|
|
1606
1606
|
top: 0,
|
|
1607
1607
|
left: 0
|
|
1608
|
-
}, st = /* @__PURE__ */
|
|
1609
|
-
const [r, o] =
|
|
1608
|
+
}, st = /* @__PURE__ */ m.forwardRef(function(t, n) {
|
|
1609
|
+
const [r, o] = m.useState();
|
|
1610
1610
|
q(() => {
|
|
1611
1611
|
rn() && o("button");
|
|
1612
1612
|
}, []);
|
|
@@ -1623,13 +1623,13 @@ const $t = {
|
|
|
1623
1623
|
...t,
|
|
1624
1624
|
...s
|
|
1625
1625
|
});
|
|
1626
|
-
}), Vt = /* @__PURE__ */
|
|
1626
|
+
}), Vt = /* @__PURE__ */ m.createContext(null), ct = /* @__PURE__ */ De("portal");
|
|
1627
1627
|
function Cr(e) {
|
|
1628
1628
|
e === void 0 && (e = {});
|
|
1629
1629
|
const {
|
|
1630
1630
|
id: t,
|
|
1631
1631
|
root: n
|
|
1632
|
-
} = e, r = Ft(), o = Tr(), [s, i] =
|
|
1632
|
+
} = e, r = Ft(), o = Tr(), [s, i] = m.useState(null), c = m.useRef(null);
|
|
1633
1633
|
return q(() => () => {
|
|
1634
1634
|
s == null || s.remove(), queueMicrotask(() => {
|
|
1635
1635
|
c.current = null;
|
|
@@ -1659,14 +1659,14 @@ function Sr(e) {
|
|
|
1659
1659
|
} = e, s = Cr({
|
|
1660
1660
|
id: n,
|
|
1661
1661
|
root: r
|
|
1662
|
-
}), [i, c] =
|
|
1662
|
+
}), [i, c] = m.useState(null), l = m.useRef(null), a = m.useRef(null), u = m.useRef(null), g = m.useRef(null), h = i == null ? void 0 : i.modal, d = i == null ? void 0 : i.open, x = (
|
|
1663
1663
|
// The FocusManager and therefore floating element are currently open/
|
|
1664
1664
|
// rendered.
|
|
1665
1665
|
!!i && // Guards are only for non-modal focus management.
|
|
1666
1666
|
!i.modal && // Don't render if unmount is transitioning.
|
|
1667
1667
|
i.open && o && !!(r || s)
|
|
1668
1668
|
);
|
|
1669
|
-
return
|
|
1669
|
+
return m.useEffect(() => {
|
|
1670
1670
|
if (!s || !o || h)
|
|
1671
1671
|
return;
|
|
1672
1672
|
function f(y) {
|
|
@@ -1675,10 +1675,10 @@ function Sr(e) {
|
|
|
1675
1675
|
return s.addEventListener("focusin", f, !0), s.addEventListener("focusout", f, !0), () => {
|
|
1676
1676
|
s.removeEventListener("focusin", f, !0), s.removeEventListener("focusout", f, !0);
|
|
1677
1677
|
};
|
|
1678
|
-
}, [s, o, h]),
|
|
1679
|
-
s && (
|
|
1680
|
-
}, [
|
|
1681
|
-
value:
|
|
1678
|
+
}, [s, o, h]), m.useEffect(() => {
|
|
1679
|
+
s && (d || it(s));
|
|
1680
|
+
}, [d, s]), /* @__PURE__ */ mt(Vt.Provider, {
|
|
1681
|
+
value: m.useMemo(() => ({
|
|
1682
1682
|
preserveTabOrder: o,
|
|
1683
1683
|
beforeOutsideRef: l,
|
|
1684
1684
|
afterOutsideRef: a,
|
|
@@ -1717,7 +1717,7 @@ function Sr(e) {
|
|
|
1717
1717
|
})]
|
|
1718
1718
|
});
|
|
1719
1719
|
}
|
|
1720
|
-
const Tr = () =>
|
|
1720
|
+
const Tr = () => m.useContext(Vt), Or = "data-floating-ui-focusable";
|
|
1721
1721
|
function lt(e) {
|
|
1722
1722
|
return _(e.target) && e.target.tagName === "BUTTON";
|
|
1723
1723
|
}
|
|
@@ -1743,7 +1743,7 @@ function Ar(e, t) {
|
|
|
1743
1743
|
ignoreMouse: a = !1,
|
|
1744
1744
|
keyboardHandlers: u = !0,
|
|
1745
1745
|
stickIfOpen: g = !0
|
|
1746
|
-
} = t, h =
|
|
1746
|
+
} = t, h = m.useRef(), d = m.useRef(!1), x = m.useMemo(() => ({
|
|
1747
1747
|
onPointerDown(f) {
|
|
1748
1748
|
h.current = f.pointerType;
|
|
1749
1749
|
},
|
|
@@ -1760,13 +1760,13 @@ function Ar(e, t) {
|
|
|
1760
1760
|
fe(y, !0) && a || (n && l && (!(o.current.openEvent && g) || o.current.openEvent.type === "click") ? r(!1, f.nativeEvent, "click") : r(!0, f.nativeEvent, "click"));
|
|
1761
1761
|
},
|
|
1762
1762
|
onKeyDown(f) {
|
|
1763
|
-
h.current = void 0, !(f.defaultPrevented || !u || lt(f)) && (f.key === " " && !at(s) && (f.preventDefault(),
|
|
1763
|
+
h.current = void 0, !(f.defaultPrevented || !u || lt(f)) && (f.key === " " && !at(s) && (f.preventDefault(), d.current = !0), !Pr(f) && f.key === "Enter" && r(!(n && l), f.nativeEvent, "click"));
|
|
1764
1764
|
},
|
|
1765
1765
|
onKeyUp(f) {
|
|
1766
|
-
f.defaultPrevented || !u || lt(f) || at(s) || f.key === " " &&
|
|
1766
|
+
f.defaultPrevented || !u || lt(f) || at(s) || f.key === " " && d.current && (d.current = !1, r(!(n && l), f.nativeEvent, "click"));
|
|
1767
1767
|
}
|
|
1768
1768
|
}), [o, s, c, a, u, r, n, g, l]);
|
|
1769
|
-
return
|
|
1769
|
+
return m.useMemo(() => i ? {
|
|
1770
1770
|
reference: x
|
|
1771
1771
|
} : {}, [i, x]);
|
|
1772
1772
|
}
|
|
@@ -1800,15 +1800,15 @@ function Lr(e, t) {
|
|
|
1800
1800
|
referencePress: u = !1,
|
|
1801
1801
|
referencePressEvent: g = "pointerdown",
|
|
1802
1802
|
ancestorScroll: h = !1,
|
|
1803
|
-
bubbles:
|
|
1803
|
+
bubbles: d,
|
|
1804
1804
|
capture: x
|
|
1805
|
-
} = t, f = ze(), y = Z(typeof l == "function" ? l : () => !1), R = typeof l == "function" ? y : l, E =
|
|
1805
|
+
} = t, f = ze(), y = Z(typeof l == "function" ? l : () => !1), R = typeof l == "function" ? y : l, E = m.useRef(!1), w = m.useRef(!1), {
|
|
1806
1806
|
escapeKey: T,
|
|
1807
1807
|
outsidePress: C
|
|
1808
|
-
} = ut(
|
|
1808
|
+
} = ut(d), {
|
|
1809
1809
|
escapeKey: D,
|
|
1810
1810
|
outsidePress: M
|
|
1811
|
-
} = ut(x), W =
|
|
1811
|
+
} = ut(x), W = m.useRef(!1), L = Z((S) => {
|
|
1812
1812
|
var A;
|
|
1813
1813
|
if (!n || !i || !c || S.key !== "Escape" || W.current)
|
|
1814
1814
|
return;
|
|
@@ -1884,7 +1884,7 @@ function Lr(e, t) {
|
|
|
1884
1884
|
};
|
|
1885
1885
|
(A = ue(S)) == null || A.addEventListener(a, b);
|
|
1886
1886
|
});
|
|
1887
|
-
|
|
1887
|
+
m.useEffect(() => {
|
|
1888
1888
|
if (!n || !i)
|
|
1889
1889
|
return;
|
|
1890
1890
|
s.current.__escapeKeyBubbles = T, s.current.__outsidePressBubbles = C;
|
|
@@ -1920,10 +1920,10 @@ function Lr(e, t) {
|
|
|
1920
1920
|
O.removeEventListener("scroll", A);
|
|
1921
1921
|
}), window.clearTimeout(S);
|
|
1922
1922
|
};
|
|
1923
|
-
}, [s, o, c, R, a, n, r, h, i, T, C, L, D, N, B, M, $]),
|
|
1923
|
+
}, [s, o, c, R, a, n, r, h, i, T, C, L, D, N, B, M, $]), m.useEffect(() => {
|
|
1924
1924
|
E.current = !1;
|
|
1925
1925
|
}, [R, a]);
|
|
1926
|
-
const F =
|
|
1926
|
+
const F = m.useMemo(() => ({
|
|
1927
1927
|
onKeyDown: L,
|
|
1928
1928
|
...u && {
|
|
1929
1929
|
[Mr[g]]: (S) => {
|
|
@@ -1935,7 +1935,7 @@ function Lr(e, t) {
|
|
|
1935
1935
|
}
|
|
1936
1936
|
}
|
|
1937
1937
|
}
|
|
1938
|
-
}), [L, r, u, g]), I =
|
|
1938
|
+
}), [L, r, u, g]), I = m.useMemo(() => ({
|
|
1939
1939
|
onKeyDown: L,
|
|
1940
1940
|
onMouseDown() {
|
|
1941
1941
|
w.current = !0;
|
|
@@ -1947,7 +1947,7 @@ function Lr(e, t) {
|
|
|
1947
1947
|
E.current = !0;
|
|
1948
1948
|
}
|
|
1949
1949
|
}), [L, a]);
|
|
1950
|
-
return
|
|
1950
|
+
return m.useMemo(() => i ? {
|
|
1951
1951
|
reference: F,
|
|
1952
1952
|
floating: I
|
|
1953
1953
|
} : {}, [i, F, I]);
|
|
@@ -1957,26 +1957,26 @@ function Ir(e) {
|
|
|
1957
1957
|
open: t = !1,
|
|
1958
1958
|
onOpenChange: n,
|
|
1959
1959
|
elements: r
|
|
1960
|
-
} = e, o = Ft(), s =
|
|
1960
|
+
} = e, o = Ft(), s = m.useRef({}), [i] = m.useState(() => vr()), c = Nt() != null;
|
|
1961
1961
|
if (process.env.NODE_ENV !== "production") {
|
|
1962
|
-
const
|
|
1963
|
-
|
|
1962
|
+
const d = r.reference;
|
|
1963
|
+
d && !k(d) && hr("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
|
|
1964
1964
|
}
|
|
1965
|
-
const [l, a] =
|
|
1966
|
-
s.current.openEvent =
|
|
1967
|
-
open:
|
|
1965
|
+
const [l, a] = m.useState(r.reference), u = Z((d, x, f) => {
|
|
1966
|
+
s.current.openEvent = d ? x : void 0, i.emit("openchange", {
|
|
1967
|
+
open: d,
|
|
1968
1968
|
event: x,
|
|
1969
1969
|
reason: f,
|
|
1970
1970
|
nested: c
|
|
1971
|
-
}), n == null || n(
|
|
1972
|
-
}), g =
|
|
1971
|
+
}), n == null || n(d, x, f);
|
|
1972
|
+
}), g = m.useMemo(() => ({
|
|
1973
1973
|
setPositionReference: a
|
|
1974
|
-
}), []), h =
|
|
1974
|
+
}), []), h = m.useMemo(() => ({
|
|
1975
1975
|
reference: l || r.reference || null,
|
|
1976
1976
|
floating: r.floating || null,
|
|
1977
1977
|
domReference: r.reference
|
|
1978
1978
|
}), [l, r.reference, r.floating]);
|
|
1979
|
-
return
|
|
1979
|
+
return m.useMemo(() => ({
|
|
1980
1980
|
dataRef: s,
|
|
1981
1981
|
open: t,
|
|
1982
1982
|
onOpenChange: u,
|
|
@@ -1997,11 +1997,11 @@ function kr(e) {
|
|
|
1997
1997
|
floating: null,
|
|
1998
1998
|
...e.elements
|
|
1999
1999
|
}
|
|
2000
|
-
}), r = e.rootContext || n, o = r.elements, [s, i] =
|
|
2000
|
+
}), r = e.rootContext || n, o = r.elements, [s, i] = m.useState(null), [c, l] = m.useState(null), u = (o == null ? void 0 : o.domReference) || s, g = m.useRef(null), h = ze();
|
|
2001
2001
|
q(() => {
|
|
2002
2002
|
u && (g.current = u);
|
|
2003
2003
|
}, [u]);
|
|
2004
|
-
const
|
|
2004
|
+
const d = cr({
|
|
2005
2005
|
...e,
|
|
2006
2006
|
elements: {
|
|
2007
2007
|
...o,
|
|
@@ -2009,43 +2009,43 @@ function kr(e) {
|
|
|
2009
2009
|
reference: c
|
|
2010
2010
|
}
|
|
2011
2011
|
}
|
|
2012
|
-
}), x =
|
|
2012
|
+
}), x = m.useCallback((w) => {
|
|
2013
2013
|
const T = k(w) ? {
|
|
2014
2014
|
getBoundingClientRect: () => w.getBoundingClientRect(),
|
|
2015
2015
|
getClientRects: () => w.getClientRects(),
|
|
2016
2016
|
contextElement: w
|
|
2017
2017
|
} : w;
|
|
2018
|
-
l(T),
|
|
2019
|
-
}, [
|
|
2020
|
-
(k(w) || w === null) && (g.current = w, i(w)), (k(
|
|
2018
|
+
l(T), d.refs.setReference(T);
|
|
2019
|
+
}, [d.refs]), f = m.useCallback((w) => {
|
|
2020
|
+
(k(w) || w === null) && (g.current = w, i(w)), (k(d.refs.reference.current) || d.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
|
|
2021
2021
|
// `null` to support `positionReference` + an unstable `reference`
|
|
2022
2022
|
// callback ref.
|
|
2023
|
-
w !== null && !k(w)) &&
|
|
2024
|
-
}, [
|
|
2025
|
-
...
|
|
2023
|
+
w !== null && !k(w)) && d.refs.setReference(w);
|
|
2024
|
+
}, [d.refs]), y = m.useMemo(() => ({
|
|
2025
|
+
...d.refs,
|
|
2026
2026
|
setReference: f,
|
|
2027
2027
|
setPositionReference: x,
|
|
2028
2028
|
domReference: g
|
|
2029
|
-
}), [
|
|
2030
|
-
...
|
|
2029
|
+
}), [d.refs, f, x]), R = m.useMemo(() => ({
|
|
2030
|
+
...d.elements,
|
|
2031
2031
|
domReference: u
|
|
2032
|
-
}), [
|
|
2033
|
-
...
|
|
2032
|
+
}), [d.elements, u]), E = m.useMemo(() => ({
|
|
2033
|
+
...d,
|
|
2034
2034
|
...r,
|
|
2035
2035
|
refs: y,
|
|
2036
2036
|
elements: R,
|
|
2037
2037
|
nodeId: t
|
|
2038
|
-
}), [
|
|
2038
|
+
}), [d, y, R, t, r]);
|
|
2039
2039
|
return q(() => {
|
|
2040
2040
|
r.dataRef.current.floatingContext = E;
|
|
2041
2041
|
const w = h == null ? void 0 : h.nodesRef.current.find((T) => T.id === t);
|
|
2042
2042
|
w && (w.context = E);
|
|
2043
|
-
}),
|
|
2044
|
-
...
|
|
2043
|
+
}), m.useMemo(() => ({
|
|
2044
|
+
...d,
|
|
2045
2045
|
context: E,
|
|
2046
2046
|
refs: y,
|
|
2047
2047
|
elements: R
|
|
2048
|
-
}), [
|
|
2048
|
+
}), [d, y, R, E]);
|
|
2049
2049
|
}
|
|
2050
2050
|
const ft = "active", dt = "selected";
|
|
2051
2051
|
function $e(e, t, n) {
|
|
@@ -2075,7 +2075,7 @@ function $e(e, t, n) {
|
|
|
2075
2075
|
if (r.has(a) || r.set(a, []), typeof u == "function") {
|
|
2076
2076
|
var g;
|
|
2077
2077
|
(g = r.get(a)) == null || g.push(u), i[a] = function() {
|
|
2078
|
-
for (var h,
|
|
2078
|
+
for (var h, d = arguments.length, x = new Array(d), f = 0; f < d; f++)
|
|
2079
2079
|
x[f] = arguments[f];
|
|
2080
2080
|
return (h = r.get(a)) == null ? void 0 : h.map((y) => y(...x)).find((y) => y !== void 0);
|
|
2081
2081
|
};
|
|
@@ -2087,28 +2087,28 @@ function $e(e, t, n) {
|
|
|
2087
2087
|
}
|
|
2088
2088
|
function Fr(e) {
|
|
2089
2089
|
e === void 0 && (e = []);
|
|
2090
|
-
const t = e.map((c) => c == null ? void 0 : c.reference), n = e.map((c) => c == null ? void 0 : c.floating), r = e.map((c) => c == null ? void 0 : c.item), o =
|
|
2090
|
+
const t = e.map((c) => c == null ? void 0 : c.reference), n = e.map((c) => c == null ? void 0 : c.floating), r = e.map((c) => c == null ? void 0 : c.item), o = m.useCallback(
|
|
2091
2091
|
(c) => $e(c, e, "reference"),
|
|
2092
2092
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2093
2093
|
t
|
|
2094
|
-
), s =
|
|
2094
|
+
), s = m.useCallback(
|
|
2095
2095
|
(c) => $e(c, e, "floating"),
|
|
2096
2096
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2097
2097
|
n
|
|
2098
|
-
), i =
|
|
2098
|
+
), i = m.useCallback(
|
|
2099
2099
|
(c) => $e(c, e, "item"),
|
|
2100
2100
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2101
2101
|
r
|
|
2102
2102
|
);
|
|
2103
|
-
return
|
|
2103
|
+
return m.useMemo(() => ({
|
|
2104
2104
|
getReferenceProps: o,
|
|
2105
2105
|
getFloatingProps: s,
|
|
2106
2106
|
getItemProps: i
|
|
2107
2107
|
}), [o, s, i]);
|
|
2108
2108
|
}
|
|
2109
2109
|
function Nr(e, t) {
|
|
2110
|
-
const [n, r] =
|
|
2111
|
-
return e && !n && r(!0),
|
|
2110
|
+
const [n, r] = m.useState(e);
|
|
2111
|
+
return e && !n && r(!0), m.useEffect(() => {
|
|
2112
2112
|
if (!e && n) {
|
|
2113
2113
|
const o = setTimeout(() => r(!1), t);
|
|
2114
2114
|
return () => clearTimeout(o);
|
|
@@ -2124,7 +2124,7 @@ function Br(e, t) {
|
|
|
2124
2124
|
}
|
|
2125
2125
|
} = e, {
|
|
2126
2126
|
duration: o = 250
|
|
2127
|
-
} = t, i = (typeof o == "number" ? o : o.close) || 0, [c, l] =
|
|
2127
|
+
} = t, i = (typeof o == "number" ? o : o.close) || 0, [c, l] = m.useState("unmounted"), a = Nr(n, i);
|
|
2128
2128
|
return !a && c === "close" && l("unmounted"), q(() => {
|
|
2129
2129
|
if (r) {
|
|
2130
2130
|
if (n) {
|
|
@@ -2145,33 +2145,33 @@ function Br(e, t) {
|
|
|
2145
2145
|
}
|
|
2146
2146
|
function _r(e) {
|
|
2147
2147
|
const {
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2148
|
+
allowedOutsideClasses: t,
|
|
2149
|
+
animationDuration: n,
|
|
2150
|
+
children: r,
|
|
2151
|
+
closeAfterInteract: o,
|
|
2152
|
+
content: s,
|
|
2153
2153
|
contentAutoWidth: i,
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2154
|
+
contentClasses: c,
|
|
2155
|
+
contentOffset: l = 6,
|
|
2156
|
+
contentStyles: a,
|
|
2157
|
+
disabled: u,
|
|
2158
2158
|
hoverDelay: g,
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2159
|
+
hoverOpen: h,
|
|
2160
|
+
onMounted: d,
|
|
2161
|
+
placement: x,
|
|
2162
|
+
stopChildPropagation: f,
|
|
2163
2163
|
onOpenChange: y
|
|
2164
2164
|
} = e, [R, E] = Gt(!1), { refs: w, floatingStyles: T, context: C } = kr({
|
|
2165
2165
|
open: R,
|
|
2166
2166
|
onOpenChange(b) {
|
|
2167
2167
|
E(b), y == null || y(b);
|
|
2168
2168
|
},
|
|
2169
|
-
whileElementsMounted: (b, p, v) => (
|
|
2170
|
-
placement:
|
|
2169
|
+
whileElementsMounted: (b, p, v) => (d !== void 0 && d(), nr(b, p, v)),
|
|
2170
|
+
placement: x || "bottom",
|
|
2171
2171
|
transform: !1,
|
|
2172
2172
|
// More expensive but allows to use transform for animations
|
|
2173
2173
|
middleware: [
|
|
2174
|
-
lr(
|
|
2174
|
+
lr(l),
|
|
2175
2175
|
ar({
|
|
2176
2176
|
padding: 6,
|
|
2177
2177
|
fallbackPlacements: [
|
|
@@ -2189,43 +2189,43 @@ function _r(e) {
|
|
|
2189
2189
|
})
|
|
2190
2190
|
]
|
|
2191
2191
|
}), { isMounted: D, status: M } = Br(C, {
|
|
2192
|
-
duration:
|
|
2192
|
+
duration: n || 200
|
|
2193
2193
|
}), W = Lr(C, {
|
|
2194
2194
|
ancestorScroll: !0,
|
|
2195
|
-
outsidePress: (b) =>
|
|
2196
|
-
}), L = Ar(C, { enabled: !
|
|
2197
|
-
enabled: !
|
|
2195
|
+
outsidePress: (b) => t && b.target instanceof Element && !b.target.closest(t) || !1
|
|
2196
|
+
}), L = Ar(C, { enabled: !u }), N = wr(C, {
|
|
2197
|
+
enabled: !u,
|
|
2198
2198
|
restMs: g || 200
|
|
2199
|
-
}), B =
|
|
2199
|
+
}), B = h ? N : L, { getReferenceProps: $, getFloatingProps: F } = Fr([
|
|
2200
2200
|
W,
|
|
2201
2201
|
B
|
|
2202
2202
|
]), I = $({
|
|
2203
2203
|
ref: w.setReference,
|
|
2204
|
-
...
|
|
2204
|
+
...f && {
|
|
2205
2205
|
onClick: (b) => b.stopPropagation()
|
|
2206
2206
|
}
|
|
2207
2207
|
}), S = F({
|
|
2208
2208
|
onClick: () => {
|
|
2209
|
-
|
|
2209
|
+
o && C.onOpenChange(!1);
|
|
2210
2210
|
}
|
|
2211
2211
|
});
|
|
2212
2212
|
let A;
|
|
2213
|
-
return Zt(
|
|
2213
|
+
return Zt(r) ? A = Jt(r, I) : A = /* @__PURE__ */ ne("div", { ...I, children: r }), /* @__PURE__ */ mt(zt, { children: [
|
|
2214
2214
|
A,
|
|
2215
|
-
D && /* @__PURE__ */ ne(Sr, { children: /* @__PURE__ */ ne(
|
|
2215
|
+
D && !!s && /* @__PURE__ */ ne(Sr, { children: /* @__PURE__ */ ne(
|
|
2216
2216
|
"div",
|
|
2217
2217
|
{
|
|
2218
2218
|
ref: w.setFloating,
|
|
2219
2219
|
className: Qt([
|
|
2220
2220
|
"Floating",
|
|
2221
|
-
!
|
|
2222
|
-
|
|
2221
|
+
!n && "Floating--animated",
|
|
2222
|
+
c
|
|
2223
2223
|
]),
|
|
2224
2224
|
"data-position": C.placement,
|
|
2225
2225
|
"data-transition": M,
|
|
2226
|
-
style: { ...T, ...
|
|
2226
|
+
style: { ...T, ...a },
|
|
2227
2227
|
...S,
|
|
2228
|
-
children:
|
|
2228
|
+
children: s
|
|
2229
2229
|
}
|
|
2230
2230
|
) })
|
|
2231
2231
|
] });
|
package/package.json
CHANGED