@stackone/malachite 2.64.0 → 2.65.0
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/COMPONENTS.md +3 -3
- package/dist/components/Avatar.js +10 -10
- package/dist/components/Avatar.js.map +1 -1
- package/dist/components/Button.js +103 -89
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Popover.js +157 -149
- package/dist/components/Popover.js.map +1 -1
- package/dist/components/Typography/PathText.js +158 -0
- package/dist/components/Typography/PathText.js.map +1 -0
- package/dist/components/Typography/index.js +15 -13
- package/dist/components/Typography/index.js.map +1 -1
- package/dist/components/Typography/pathTextFit.js +42 -0
- package/dist/components/Typography/pathTextFit.js.map +1 -0
- package/dist/components/Typography/pathTextMeasure.js +67 -0
- package/dist/components/Typography/pathTextMeasure.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import { ShadowRootWrapper as
|
|
5
|
-
import { PopoverEmpty as
|
|
6
|
-
import { getDeepActiveElement as
|
|
7
|
-
import { elementRef as Ae, composeRefs as
|
|
1
|
+
import { jsxs as he, Fragment as be, jsx as C } from "react/jsx-runtime";
|
|
2
|
+
import Pe, { useContext as Ee, useState as W, useSyncExternalStore as xe, useRef as h, useCallback as ge, useEffect as j, useMemo as we } from "react";
|
|
3
|
+
import { createPortal as Te } from "react-dom";
|
|
4
|
+
import { ShadowRootWrapper as ye } from "../ShadowRootWrapper.js";
|
|
5
|
+
import { PopoverEmpty as Le, PopoverSection as Me, PopoverList as Se, PopoverAction as De, PopoverHeader as _e } from "./PopoverParts.js";
|
|
6
|
+
import { getDeepActiveElement as G } from "./activeElement.js";
|
|
7
|
+
import { elementRef as Ae, composeRefs as Ce, chainHandler as p } from "./composeRefs.js";
|
|
8
8
|
import { pushEscapeLayer as Ie } from "./escapeLayers.js";
|
|
9
|
-
import { MENU_VIEWPORT_PADDING_PX as
|
|
10
|
-
import { firstTabStopIn as
|
|
11
|
-
import { usePopupLayer as
|
|
12
|
-
import { PopoverTreeContext as
|
|
13
|
-
import { useHoverClose as
|
|
9
|
+
import { MENU_VIEWPORT_PADDING_PX as Ne } from "./floatingMenuGeometry.js";
|
|
10
|
+
import { firstTabStopIn as Oe } from "./overlayBehaviour.js";
|
|
11
|
+
import { usePopupLayer as ke } from "./overlayLayers.js";
|
|
12
|
+
import { PopoverTreeContext as V } from "./popoverTree.js";
|
|
13
|
+
import { useHoverClose as Ke } from "./useHoverClose.js";
|
|
14
14
|
import { useLatestRef as I } from "./useLatestRef.js";
|
|
15
|
-
import { usePopoverPosition as
|
|
16
|
-
import { usePopoverTree as
|
|
17
|
-
const
|
|
15
|
+
import { usePopoverPosition as Re } from "./usePopoverPosition.js";
|
|
16
|
+
import { usePopoverTree as Be } from "./usePopoverTree.js";
|
|
17
|
+
const He = "font-sans box-border overflow-auto outline-none rounded-[var(--malachite-radius-xl,12px)] border border-solid border-[var(--malachite-card-border,rgb(232,232,232))] bg-[var(--malachite-card-background,rgb(255,255,255))] text-[var(--malachite-text-primary,rgb(10,10,10))]", $e = {
|
|
18
18
|
default: "[box-shadow:0px_4px_10px_0px_var(--malachite-card-shadow,rgba(0,0,0,0.1))]",
|
|
19
19
|
raised: "[box-shadow:0px_8px_24px_0px_var(--malachite-card-shadow,rgba(0,0,0,0.1))]"
|
|
20
|
-
},
|
|
20
|
+
}, Ue = {
|
|
21
21
|
none: "p-0",
|
|
22
22
|
small: "p-1",
|
|
23
23
|
medium: "p-2"
|
|
24
|
-
}, We = (
|
|
24
|
+
}, We = (r, c) => {
|
|
25
25
|
for (const b of c)
|
|
26
|
-
if (b &&
|
|
26
|
+
if (b && r.includes(b))
|
|
27
27
|
return !0;
|
|
28
28
|
return !1;
|
|
29
29
|
}, je = {
|
|
@@ -31,216 +31,224 @@ const Be = "font-sans box-border overflow-auto outline-none rounded-[var(--malac
|
|
|
31
31
|
top: "ArrowUp",
|
|
32
32
|
right: "ArrowRight",
|
|
33
33
|
left: "ArrowLeft"
|
|
34
|
-
}, Y = (
|
|
35
|
-
if (!(
|
|
34
|
+
}, Ge = (r) => r instanceof HTMLElement && (r.isContentEditable || ["INPUT", "TEXTAREA", "SELECT"].includes(r.tagName)), Y = (r) => {
|
|
35
|
+
if (!(r instanceof Node))
|
|
36
36
|
return [];
|
|
37
|
-
const c =
|
|
38
|
-
return [
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
trigger:
|
|
37
|
+
const c = r.getRootNode();
|
|
38
|
+
return [r, ...c instanceof ShadowRoot ? Y(c.host) : []];
|
|
39
|
+
}, Ve = () => () => {
|
|
40
|
+
}, Xe = () => !0, Ye = () => !1, X = (r, c) => c ?? Oe(r) ?? r, qe = ({
|
|
41
|
+
trigger: r,
|
|
42
42
|
children: c,
|
|
43
43
|
open: b,
|
|
44
44
|
defaultOpen: q = !1,
|
|
45
|
-
onOpenChange:
|
|
46
|
-
placement:
|
|
47
|
-
openOn:
|
|
48
|
-
width:
|
|
49
|
-
padding:
|
|
50
|
-
anchorRef:
|
|
51
|
-
offset:
|
|
52
|
-
elevation:
|
|
53
|
-
initialFocusRef:
|
|
54
|
-
|
|
55
|
-
"
|
|
56
|
-
"aria-
|
|
57
|
-
|
|
45
|
+
onOpenChange: z,
|
|
46
|
+
placement: N = "bottom-start",
|
|
47
|
+
openOn: f = "click",
|
|
48
|
+
width: J = "content",
|
|
49
|
+
padding: Q = "small",
|
|
50
|
+
anchorRef: Z,
|
|
51
|
+
offset: F = "small",
|
|
52
|
+
elevation: ee = "default",
|
|
53
|
+
initialFocusRef: d,
|
|
54
|
+
openOnArrowKey: re = !1,
|
|
55
|
+
role: O = "dialog",
|
|
56
|
+
"aria-label": oe,
|
|
57
|
+
"aria-labelledby": te,
|
|
58
|
+
className: ne = ""
|
|
58
59
|
}) => {
|
|
59
|
-
const
|
|
60
|
+
const se = Ee(V), [ce, ue] = W(q), t = b ?? ce, ae = xe(Ve, Xe, Ye), P = h(null), E = h(null), le = ke("popover", t, E), [u, ie] = W(null), k = h(0), D = h(!1), w = h(!1), T = h(!1), y = I(t), K = I(b), L = I(z), n = ge(
|
|
60
61
|
(e) => {
|
|
61
|
-
var
|
|
62
|
-
e !==
|
|
62
|
+
var v;
|
|
63
|
+
e !== y.current && (K.current === void 0 && ue(e), (v = L.current) == null || v.call(L, e));
|
|
63
64
|
},
|
|
64
|
-
[
|
|
65
|
-
), { pointerInside: x, focusInside:
|
|
66
|
-
isOpenRef:
|
|
67
|
-
heldByChildren:
|
|
65
|
+
[y, K, L]
|
|
66
|
+
), { pointerInside: x, focusInside: g, triggerFocused: R, cancelClose: m, scheduleClose: M } = Ke({
|
|
67
|
+
isOpenRef: y,
|
|
68
|
+
heldByChildren: k,
|
|
68
69
|
setOpen: n
|
|
69
|
-
}), { tree:
|
|
70
|
-
parent:
|
|
70
|
+
}), { tree: pe, ownedSources: _ } = Be({
|
|
71
|
+
parent: se,
|
|
71
72
|
isOpen: t,
|
|
72
|
-
openOn:
|
|
73
|
-
isOpenRef:
|
|
74
|
-
heldByChildren:
|
|
75
|
-
cancelClose:
|
|
76
|
-
scheduleClose:
|
|
77
|
-
}),
|
|
73
|
+
openOn: f,
|
|
74
|
+
isOpenRef: y,
|
|
75
|
+
heldByChildren: k,
|
|
76
|
+
cancelClose: m,
|
|
77
|
+
scheduleClose: M
|
|
78
|
+
}), o = Re({
|
|
78
79
|
isOpen: t,
|
|
79
80
|
panel: u,
|
|
80
|
-
hostRef:
|
|
81
|
+
hostRef: E,
|
|
81
82
|
triggerRef: P,
|
|
82
|
-
anchorRef:
|
|
83
|
-
placement:
|
|
84
|
-
width:
|
|
85
|
-
offset:
|
|
83
|
+
anchorRef: Z,
|
|
84
|
+
placement: N,
|
|
85
|
+
width: J,
|
|
86
|
+
offset: F
|
|
86
87
|
});
|
|
87
88
|
j(() => {
|
|
88
89
|
if (!t)
|
|
89
90
|
return;
|
|
90
|
-
const e = (
|
|
91
|
-
const
|
|
92
|
-
We(
|
|
91
|
+
const e = (l) => {
|
|
92
|
+
const i = l.composedPath();
|
|
93
|
+
We(i, [
|
|
93
94
|
P.current,
|
|
94
|
-
|
|
95
|
-
...[...
|
|
95
|
+
E.current,
|
|
96
|
+
...[..._.current].map((ve) => ve())
|
|
96
97
|
]) || n(!1);
|
|
97
98
|
};
|
|
98
99
|
document.addEventListener("mousedown", e, !0);
|
|
99
|
-
const
|
|
100
|
+
const v = Ie(() => n(!1));
|
|
100
101
|
return () => {
|
|
101
|
-
var
|
|
102
|
-
document.removeEventListener("mousedown", e, !0),
|
|
103
|
-
const
|
|
104
|
-
|
|
102
|
+
var i;
|
|
103
|
+
document.removeEventListener("mousedown", e, !0), v(), x.current = !1;
|
|
104
|
+
const l = G();
|
|
105
|
+
g.current && (!l || l === document.body) && (w.current = !0, (i = P.current) == null || i.focus({ preventScroll: !0 }), w.current = !1), g.current = !1;
|
|
105
106
|
};
|
|
106
|
-
}, [t, n,
|
|
107
|
-
const
|
|
107
|
+
}, [t, n, _, x, g]);
|
|
108
|
+
const B = t && u !== null && o !== null;
|
|
108
109
|
j(() => {
|
|
109
|
-
const e =
|
|
110
|
-
!
|
|
111
|
-
}, [
|
|
112
|
-
const
|
|
113
|
-
if (
|
|
114
|
-
|
|
110
|
+
const e = f === "click" || D.current;
|
|
111
|
+
!B || !u || !e || (D.current = !1, X(u, d == null ? void 0 : d.current).focus({ preventScroll: !0 }));
|
|
112
|
+
}, [B, u, f, d]);
|
|
113
|
+
const A = () => {
|
|
114
|
+
if (m(), t && u) {
|
|
115
|
+
X(u, d == null ? void 0 : d.current).focus({ preventScroll: !0 });
|
|
115
116
|
return;
|
|
116
117
|
}
|
|
117
|
-
|
|
118
|
+
D.current = !0, n(!0);
|
|
118
119
|
}, S = (e) => {
|
|
119
|
-
const
|
|
120
|
+
const v = [
|
|
120
121
|
P.current,
|
|
121
|
-
|
|
122
|
+
E.current,
|
|
122
123
|
u,
|
|
123
|
-
...[...
|
|
124
|
+
...[..._.current].map((l) => l())
|
|
124
125
|
];
|
|
125
126
|
return Y(e).some(
|
|
126
|
-
(
|
|
127
|
+
(l) => v.some((i) => i == null ? void 0 : i.contains(l))
|
|
127
128
|
);
|
|
128
|
-
},
|
|
129
|
+
}, H = (e) => {
|
|
129
130
|
e && queueMicrotask(() => {
|
|
130
|
-
!S(e) && !S(
|
|
131
|
+
!S(e) && !S(G()) && n(!1);
|
|
131
132
|
});
|
|
132
|
-
}, s =
|
|
133
|
+
}, s = f === "hover" ? {
|
|
133
134
|
onMouseEnter: () => {
|
|
134
|
-
x.current = !0,
|
|
135
|
+
x.current = !0, m(), n(!0);
|
|
135
136
|
},
|
|
136
137
|
onMouseLeave: () => {
|
|
137
|
-
x.current = !1,
|
|
138
|
+
x.current = !1, M();
|
|
138
139
|
},
|
|
139
140
|
onPanelMouseOver: () => {
|
|
140
|
-
x.current = !0,
|
|
141
|
+
x.current = !0, m();
|
|
141
142
|
}
|
|
142
|
-
} : null,
|
|
143
|
-
() =>
|
|
144
|
-
[
|
|
145
|
-
),
|
|
146
|
-
ref:
|
|
147
|
-
"aria-haspopup":
|
|
143
|
+
} : null, a = r.props, $ = Ae(r), fe = we(
|
|
144
|
+
() => Ce($, P),
|
|
145
|
+
[$]
|
|
146
|
+
), U = je[N.split("-")[0]], de = Pe.cloneElement(r, {
|
|
147
|
+
ref: fe,
|
|
148
|
+
"aria-haspopup": O,
|
|
148
149
|
"aria-expanded": t,
|
|
149
|
-
onClick:
|
|
150
|
-
|
|
150
|
+
onClick: p(
|
|
151
|
+
a.onClick,
|
|
151
152
|
(e) => {
|
|
152
|
-
if (
|
|
153
|
+
if (f !== "hover") {
|
|
153
154
|
n(!t);
|
|
154
155
|
return;
|
|
155
156
|
}
|
|
156
157
|
if (e.detail === 0) {
|
|
157
|
-
|
|
158
|
+
A();
|
|
158
159
|
return;
|
|
159
160
|
}
|
|
160
|
-
|
|
161
|
+
m(), n(!0);
|
|
161
162
|
}
|
|
162
163
|
),
|
|
163
164
|
...s ? {
|
|
164
|
-
onMouseEnter:
|
|
165
|
-
|
|
165
|
+
onMouseEnter: p(
|
|
166
|
+
a.onMouseEnter,
|
|
166
167
|
s.onMouseEnter
|
|
167
168
|
),
|
|
168
|
-
onMouseLeave:
|
|
169
|
-
|
|
169
|
+
onMouseLeave: p(
|
|
170
|
+
a.onMouseLeave,
|
|
170
171
|
s.onMouseLeave
|
|
171
172
|
),
|
|
172
|
-
onMouseDown:
|
|
173
|
-
|
|
173
|
+
onMouseDown: p(
|
|
174
|
+
a.onMouseDown,
|
|
174
175
|
() => {
|
|
175
|
-
|
|
176
|
-
|
|
176
|
+
T.current = !0, setTimeout(() => {
|
|
177
|
+
T.current = !1;
|
|
177
178
|
});
|
|
178
179
|
}
|
|
179
180
|
),
|
|
180
|
-
onFocus:
|
|
181
|
-
const e =
|
|
182
|
-
|
|
181
|
+
onFocus: p(a.onFocus, () => {
|
|
182
|
+
const e = T.current;
|
|
183
|
+
T.current = !1, R.current = !e && !w.current, !w.current && (m(), n(!0));
|
|
183
184
|
}),
|
|
184
|
-
onKeyDown:
|
|
185
|
-
|
|
185
|
+
onKeyDown: p(
|
|
186
|
+
a.onKeyDown,
|
|
186
187
|
(e) => {
|
|
187
|
-
e.key ===
|
|
188
|
+
e.key === U && (e.preventDefault(), A());
|
|
189
|
+
}
|
|
190
|
+
)
|
|
191
|
+
} : re ? {
|
|
192
|
+
onKeyDown: p(
|
|
193
|
+
a.onKeyDown,
|
|
194
|
+
(e) => {
|
|
195
|
+
e.key !== U || Ge(e.target) || (e.preventDefault(), A());
|
|
188
196
|
}
|
|
189
197
|
)
|
|
190
198
|
} : {},
|
|
191
|
-
onBlur:
|
|
192
|
-
|
|
199
|
+
onBlur: p(
|
|
200
|
+
a.onBlur,
|
|
193
201
|
(e) => {
|
|
194
|
-
if (
|
|
195
|
-
if (
|
|
196
|
-
|
|
202
|
+
if (R.current = !1, !(!t || S(e.relatedTarget))) {
|
|
203
|
+
if (f === "hover") {
|
|
204
|
+
M();
|
|
197
205
|
return;
|
|
198
206
|
}
|
|
199
|
-
|
|
207
|
+
H(e.relatedTarget);
|
|
200
208
|
}
|
|
201
209
|
}
|
|
202
210
|
)
|
|
203
|
-
}),
|
|
204
|
-
maxHeight:
|
|
205
|
-
maxWidth: `calc(100vw - ${
|
|
206
|
-
visibility:
|
|
211
|
+
}), me = {
|
|
212
|
+
maxHeight: o == null ? void 0 : o.maxHeight,
|
|
213
|
+
maxWidth: `calc(100vw - ${Ne * 2}px)`,
|
|
214
|
+
visibility: o ? "visible" : "hidden"
|
|
207
215
|
};
|
|
208
|
-
return /* @__PURE__ */
|
|
216
|
+
return /* @__PURE__ */ he(be, { children: [
|
|
209
217
|
de,
|
|
210
|
-
t &&
|
|
211
|
-
/* @__PURE__ */
|
|
212
|
-
|
|
218
|
+
t && ae && Te(
|
|
219
|
+
/* @__PURE__ */ C(V.Provider, { value: pe, children: /* @__PURE__ */ C(
|
|
220
|
+
ye,
|
|
213
221
|
{
|
|
214
|
-
hostRef:
|
|
215
|
-
hostProps:
|
|
222
|
+
hostRef: E,
|
|
223
|
+
hostProps: le,
|
|
216
224
|
hostStyle: {
|
|
217
225
|
position: "fixed",
|
|
218
|
-
top: (
|
|
219
|
-
left: (
|
|
226
|
+
top: (o == null ? void 0 : o.top) ?? 0,
|
|
227
|
+
left: (o == null ? void 0 : o.left) ?? 0
|
|
220
228
|
},
|
|
221
|
-
children: /* @__PURE__ */
|
|
229
|
+
children: /* @__PURE__ */ C(
|
|
222
230
|
"div",
|
|
223
231
|
{
|
|
224
|
-
ref:
|
|
225
|
-
role:
|
|
226
|
-
"aria-label":
|
|
227
|
-
"aria-labelledby":
|
|
228
|
-
"data-side":
|
|
232
|
+
ref: ie,
|
|
233
|
+
role: O,
|
|
234
|
+
"aria-label": oe,
|
|
235
|
+
"aria-labelledby": te,
|
|
236
|
+
"data-side": o == null ? void 0 : o.side,
|
|
229
237
|
tabIndex: -1,
|
|
230
|
-
className: `${
|
|
231
|
-
style:
|
|
238
|
+
className: `${He} ${$e[ee]} ${Ue[Q]} ${ne}`.trim(),
|
|
239
|
+
style: me,
|
|
232
240
|
onMouseOver: s == null ? void 0 : s.onPanelMouseOver,
|
|
233
241
|
onMouseLeave: s == null ? void 0 : s.onMouseLeave,
|
|
234
242
|
onFocus: () => {
|
|
235
|
-
|
|
243
|
+
g.current = !0, m();
|
|
236
244
|
},
|
|
237
245
|
onBlur: (e) => {
|
|
238
246
|
if (!S(e.relatedTarget)) {
|
|
239
|
-
if (
|
|
240
|
-
|
|
247
|
+
if (g.current = !1, f === "hover") {
|
|
248
|
+
M();
|
|
241
249
|
return;
|
|
242
250
|
}
|
|
243
|
-
|
|
251
|
+
H(e.relatedTarget);
|
|
244
252
|
}
|
|
245
253
|
},
|
|
246
254
|
children: c
|
|
@@ -251,15 +259,15 @@ const Be = "font-sans box-border overflow-auto outline-none rounded-[var(--malac
|
|
|
251
259
|
document.body
|
|
252
260
|
)
|
|
253
261
|
] });
|
|
254
|
-
},
|
|
262
|
+
}, fr = Object.assign(qe, {
|
|
255
263
|
Header: _e,
|
|
256
|
-
Action:
|
|
257
|
-
List:
|
|
258
|
-
Section:
|
|
259
|
-
Empty:
|
|
264
|
+
Action: De,
|
|
265
|
+
List: Se,
|
|
266
|
+
Section: Me,
|
|
267
|
+
Empty: Le
|
|
260
268
|
});
|
|
261
269
|
export {
|
|
262
|
-
|
|
263
|
-
|
|
270
|
+
fr as Popover,
|
|
271
|
+
fr as default
|
|
264
272
|
};
|
|
265
273
|
//# sourceMappingURL=Popover.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.js","sources":["../../src/components/Popover.tsx"],"sourcesContent":["import React, {\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { ShadowRootWrapper } from '../ShadowRootWrapper';\nimport {\n PopoverAction,\n PopoverEmpty,\n PopoverHeader,\n PopoverList,\n PopoverSection,\n} from './PopoverParts';\nimport { getDeepActiveElement } from './activeElement';\nimport { chainHandler, composeRefs, elementRef } from './composeRefs';\nimport { pushEscapeLayer } from './escapeLayers';\nimport {\n type FloatingOffset,\n type FloatingPlacement,\n MENU_VIEWPORT_PADDING_PX,\n} from './floatingMenuGeometry';\nimport { firstTabStopIn } from './overlayBehaviour';\nimport { usePopupLayer } from './overlayLayers';\nimport { PopoverTreeContext } from './popoverTree';\nimport { useHoverClose } from './useHoverClose';\nimport { useLatestRef } from './useLatestRef';\nimport { usePopoverPosition } from './usePopoverPosition';\nimport { usePopoverTree } from './usePopoverTree';\n\nexport type PopoverPlacement = FloatingPlacement;\n\ninterface PopoverBaseProps {\n trigger: React.ReactElement;\n children?: React.ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n placement?: PopoverPlacement;\n openOn?: 'click' | 'hover';\n width?: 'content' | 'trigger';\n padding?: 'none' | 'small' | 'medium';\n anchorRef?: React.RefObject<HTMLElement | null>;\n offset?: FloatingOffset;\n elevation?: 'default' | 'raised';\n initialFocusRef?: React.RefObject<HTMLElement | null>;\n role?: 'dialog' | 'menu' | 'listbox';\n className?: string;\n}\n\ntype PopoverName =\n | { 'aria-label': string; 'aria-labelledby'?: string }\n | { 'aria-label'?: string; 'aria-labelledby': string };\n\nexport type PopoverProps = PopoverBaseProps & PopoverName;\n\nconst PANEL =\n 'font-sans box-border overflow-auto outline-none rounded-[var(--malachite-radius-xl,12px)] border border-solid border-[var(--malachite-card-border,rgb(232,232,232))] bg-[var(--malachite-card-background,rgb(255,255,255))] text-[var(--malachite-text-primary,rgb(10,10,10))]';\n\nconst ELEVATION: Record<NonNullable<PopoverBaseProps['elevation']>, string> = {\n default: '[box-shadow:0px_4px_10px_0px_var(--malachite-card-shadow,rgba(0,0,0,0.1))]',\n raised: '[box-shadow:0px_8px_24px_0px_var(--malachite-card-shadow,rgba(0,0,0,0.1))]',\n};\n\nconst PADDING: Record<NonNullable<PopoverBaseProps['padding']>, string> = {\n none: 'p-0',\n small: 'p-1',\n medium: 'p-2',\n};\n\nconst pathHits = (path: EventTarget[], nodes: Iterable<Element | null | undefined>): boolean => {\n for (const node of nodes) {\n if (node && path.includes(node)) {\n return true;\n }\n }\n return false;\n};\n\nconst KEYBOARD_OPEN_KEY: Record<string, string> = {\n bottom: 'ArrowDown',\n top: 'ArrowUp',\n right: 'ArrowRight',\n left: 'ArrowLeft',\n};\n\nconst composedPathOf = (node: EventTarget | null): Node[] => {\n if (!(node instanceof Node)) {\n return [];\n }\n const root = node.getRootNode();\n return [node, ...(root instanceof ShadowRoot ? composedPathOf(root.host) : [])];\n};\n\nconst subscribeToNothing = () => () => undefined;\nconst onClient = () => true;\nconst onServer = () => false;\n\nconst focusTarget = (panel: HTMLElement, initial: HTMLElement | null | undefined): HTMLElement =>\n initial ?? firstTabStopIn(panel) ?? panel;\n\n/** An anchored, non-modal panel; nested Popovers count as inside their parent. */\nconst PopoverRoot: React.FC<PopoverProps> = ({\n trigger,\n children,\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n placement = 'bottom-start',\n openOn = 'click',\n width = 'content',\n padding = 'small',\n anchorRef,\n offset = 'small',\n elevation = 'default',\n initialFocusRef,\n role = 'dialog',\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n className = '',\n}) => {\n const parent = useContext(PopoverTreeContext);\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const isOpen = controlledOpen ?? uncontrolledOpen;\n const isClient = useSyncExternalStore(subscribeToNothing, onClient, onServer);\n\n const triggerRef = useRef<HTMLElement | null>(null);\n const hostRef = useRef<HTMLDivElement | null>(null);\n const popupIdentity = usePopupLayer('popover', isOpen, hostRef);\n const [panel, setPanel] = useState<HTMLDivElement | null>(null);\n const heldByChildren = useRef(0);\n const focusOnOpen = useRef(false);\n const returningFocus = useRef(false);\n const pointerPressedTrigger = useRef(false);\n\n const isOpenRef = useLatestRef(isOpen);\n const controlledRef = useLatestRef(controlledOpen);\n const onOpenChangeRef = useLatestRef(onOpenChange);\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (next === isOpenRef.current) {\n return;\n }\n if (controlledRef.current === undefined) {\n setUncontrolledOpen(next);\n }\n onOpenChangeRef.current?.(next);\n },\n [isOpenRef, controlledRef, onOpenChangeRef],\n );\n\n const { pointerInside, focusInside, triggerFocused, cancelClose, scheduleClose } =\n useHoverClose({\n isOpenRef,\n heldByChildren,\n setOpen,\n });\n\n const { tree, ownedSources } = usePopoverTree({\n parent,\n isOpen,\n openOn,\n isOpenRef,\n heldByChildren,\n cancelClose,\n scheduleClose,\n });\n\n const geometry = usePopoverPosition({\n isOpen,\n panel,\n hostRef,\n triggerRef,\n anchorRef,\n placement,\n width,\n offset,\n });\n\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n const closeOnOutsidePress = (event: MouseEvent) => {\n const path = event.composedPath();\n const inside = pathHits(path, [\n triggerRef.current,\n hostRef.current,\n ...[...ownedSources.current].map((source) => source()),\n ]);\n if (!inside) {\n setOpen(false);\n }\n };\n document.addEventListener('mousedown', closeOnOutsidePress, true);\n const popEscapeLayer = pushEscapeLayer(() => setOpen(false));\n return () => {\n document.removeEventListener('mousedown', closeOnOutsidePress, true);\n popEscapeLayer();\n pointerInside.current = false;\n const active = getDeepActiveElement();\n if (focusInside.current && (!active || active === document.body)) {\n returningFocus.current = true;\n triggerRef.current?.focus({ preventScroll: true });\n returningFocus.current = false;\n }\n focusInside.current = false;\n };\n }, [isOpen, setOpen, ownedSources, pointerInside, focusInside]);\n\n const shown = isOpen && panel !== null && geometry !== null;\n\n useEffect(() => {\n const shouldFocus = openOn === 'click' || focusOnOpen.current;\n if (!shown || !panel || !shouldFocus) {\n return;\n }\n focusOnOpen.current = false;\n focusTarget(panel, initialFocusRef?.current).focus({ preventScroll: true });\n }, [shown, panel, openOn, initialFocusRef]);\n\n const openWithFocus = () => {\n cancelClose();\n if (isOpen && panel) {\n focusTarget(panel, initialFocusRef?.current).focus({ preventScroll: true });\n return;\n }\n focusOnOpen.current = true;\n setOpen(true);\n };\n\n const isInside = (node: EventTarget | null): boolean => {\n const containers = [\n triggerRef.current,\n hostRef.current,\n panel,\n ...[...ownedSources.current].map((source) => source()),\n ];\n return composedPathOf(node).some((step) =>\n containers.some((container) => container?.contains(step)),\n );\n };\n\n const closeIfFocusLeft = (next: EventTarget | null) => {\n if (!next) {\n return;\n }\n queueMicrotask(() => {\n if (!isInside(next) && !isInside(getDeepActiveElement())) {\n setOpen(false);\n }\n });\n };\n\n const hoverHandlers =\n openOn === 'hover'\n ? {\n onMouseEnter: () => {\n pointerInside.current = true;\n cancelClose();\n setOpen(true);\n },\n onMouseLeave: () => {\n pointerInside.current = false;\n scheduleClose();\n },\n onPanelMouseOver: () => {\n pointerInside.current = true;\n cancelClose();\n },\n }\n : null;\n\n const triggerProps = trigger.props as Record<string, unknown>;\n type Handler<E extends React.SyntheticEvent> = ((event: E) => void) | undefined;\n\n const ownTriggerRef = elementRef<HTMLElement>(trigger);\n const composedTriggerRef = useMemo(\n () => composeRefs(ownTriggerRef, triggerRef),\n [ownTriggerRef],\n );\n const openKey = KEYBOARD_OPEN_KEY[placement.split('-')[0]];\n\n const clonedTrigger = React.cloneElement(trigger, {\n ref: composedTriggerRef,\n 'aria-haspopup': role,\n 'aria-expanded': isOpen,\n onClick: chainHandler(\n triggerProps.onClick as Handler<React.MouseEvent>,\n (event: React.MouseEvent) => {\n if (openOn !== 'hover') {\n setOpen(!isOpen);\n return;\n }\n const fromKeyboard = event.detail === 0;\n if (fromKeyboard) {\n openWithFocus();\n return;\n }\n cancelClose();\n setOpen(true);\n },\n ),\n ...(hoverHandlers\n ? {\n onMouseEnter: chainHandler(\n triggerProps.onMouseEnter as Handler<React.MouseEvent>,\n hoverHandlers.onMouseEnter,\n ),\n onMouseLeave: chainHandler(\n triggerProps.onMouseLeave as Handler<React.MouseEvent>,\n hoverHandlers.onMouseLeave,\n ),\n onMouseDown: chainHandler(\n triggerProps.onMouseDown as Handler<React.MouseEvent>,\n () => {\n pointerPressedTrigger.current = true;\n setTimeout(() => {\n pointerPressedTrigger.current = false;\n });\n },\n ),\n onFocus: chainHandler(triggerProps.onFocus as Handler<React.FocusEvent>, () => {\n const fromPointer = pointerPressedTrigger.current;\n pointerPressedTrigger.current = false;\n triggerFocused.current = !fromPointer && !returningFocus.current;\n if (returningFocus.current) {\n return;\n }\n cancelClose();\n setOpen(true);\n }),\n onKeyDown: chainHandler(\n triggerProps.onKeyDown as Handler<React.KeyboardEvent>,\n (event: React.KeyboardEvent) => {\n if (event.key !== openKey) {\n return;\n }\n event.preventDefault();\n openWithFocus();\n },\n ),\n }\n : {}),\n onBlur: chainHandler(\n triggerProps.onBlur as Handler<React.FocusEvent>,\n (event: React.FocusEvent) => {\n triggerFocused.current = false;\n if (!isOpen || isInside(event.relatedTarget)) {\n return;\n }\n if (openOn === 'hover') {\n scheduleClose();\n return;\n }\n closeIfFocusLeft(event.relatedTarget);\n },\n ),\n } as Record<string, unknown>);\n\n const panelStyle: React.CSSProperties = {\n maxHeight: geometry?.maxHeight,\n maxWidth: `calc(100vw - ${MENU_VIEWPORT_PADDING_PX * 2}px)`,\n visibility: geometry ? 'visible' : 'hidden',\n };\n\n return (\n <>\n {clonedTrigger}\n {isOpen &&\n isClient &&\n createPortal(\n <PopoverTreeContext.Provider value={tree}>\n <ShadowRootWrapper\n hostRef={hostRef}\n hostProps={popupIdentity}\n hostStyle={{\n position: 'fixed',\n top: geometry?.top ?? 0,\n left: geometry?.left ?? 0,\n }}\n >\n <div\n ref={setPanel}\n role={role}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n data-side={geometry?.side}\n tabIndex={-1}\n className={`${PANEL} ${ELEVATION[elevation]} ${PADDING[padding]} ${className}`.trim()}\n style={panelStyle}\n // React's mouseenter stops at the shadow host, so the panel listens for mouseover.\n onMouseOver={hoverHandlers?.onPanelMouseOver}\n onMouseLeave={hoverHandlers?.onMouseLeave}\n onFocus={() => {\n focusInside.current = true;\n cancelClose();\n }}\n onBlur={(event) => {\n if (isInside(event.relatedTarget)) {\n return;\n }\n focusInside.current = false;\n if (openOn === 'hover') {\n scheduleClose();\n return;\n }\n closeIfFocusLeft(event.relatedTarget);\n }}\n >\n {children}\n </div>\n </ShadowRootWrapper>\n </PopoverTreeContext.Provider>,\n document.body,\n )}\n </>\n );\n};\n\nexport const Popover = Object.assign(PopoverRoot, {\n Header: PopoverHeader,\n Action: PopoverAction,\n List: PopoverList,\n Section: PopoverSection,\n Empty: PopoverEmpty,\n});\n\nexport default Popover;\n"],"names":["PANEL","ELEVATION","PADDING","pathHits","path","nodes","node","KEYBOARD_OPEN_KEY","composedPathOf","root","subscribeToNothing","onClient","onServer","focusTarget","panel","initial","firstTabStopIn","PopoverRoot","trigger","children","controlledOpen","defaultOpen","onOpenChange","placement","openOn","width","padding","anchorRef","offset","elevation","initialFocusRef","role","ariaLabel","ariaLabelledBy","className","parent","useContext","PopoverTreeContext","uncontrolledOpen","setUncontrolledOpen","useState","isOpen","isClient","useSyncExternalStore","triggerRef","useRef","hostRef","popupIdentity","usePopupLayer","setPanel","heldByChildren","focusOnOpen","returningFocus","pointerPressedTrigger","isOpenRef","useLatestRef","controlledRef","onOpenChangeRef","setOpen","useCallback","next","_a","pointerInside","focusInside","triggerFocused","cancelClose","scheduleClose","useHoverClose","tree","ownedSources","usePopoverTree","geometry","usePopoverPosition","useEffect","closeOnOutsidePress","event","source","popEscapeLayer","pushEscapeLayer","active","getDeepActiveElement","shown","shouldFocus","openWithFocus","isInside","containers","step","container","closeIfFocusLeft","hoverHandlers","triggerProps","ownTriggerRef","elementRef","composedTriggerRef","useMemo","composeRefs","openKey","clonedTrigger","React","chainHandler","fromPointer","panelStyle","MENU_VIEWPORT_PADDING_PX","jsxs","Fragment","createPortal","jsx","ShadowRootWrapper","Popover","Pop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B,EAAiBb,EAAM,aAAa;AAAA;AAAA,cACxC;AAAA,cAEC,UAAAxD;AAAA,YAAA;AAAA,UAAA;AAAA,QACL;AAAA,MAAA,GAER;AAAA,MACA,SAAS;AAAA,IAAA;AAAA,EACb,GACR;AAER,GAEayF,KAAU,OAAO,OAAO3F,IAAa;AAAA,EAC9C,QAAQ4F;AAAA,EACR,QAAQC;AAAA,EACR,MAAMC;AAAA,EACN,SAASC;AAAA,EACT,OAAOC;AACX,CAAC;"}
|
|
1
|
+
{"version":3,"file":"Popover.js","sources":["../../src/components/Popover.tsx"],"sourcesContent":["import React, {\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { ShadowRootWrapper } from '../ShadowRootWrapper';\nimport {\n PopoverAction,\n PopoverEmpty,\n PopoverHeader,\n PopoverList,\n PopoverSection,\n} from './PopoverParts';\nimport { getDeepActiveElement } from './activeElement';\nimport { chainHandler, composeRefs, elementRef } from './composeRefs';\nimport { pushEscapeLayer } from './escapeLayers';\nimport {\n type FloatingOffset,\n type FloatingPlacement,\n MENU_VIEWPORT_PADDING_PX,\n} from './floatingMenuGeometry';\nimport { firstTabStopIn } from './overlayBehaviour';\nimport { usePopupLayer } from './overlayLayers';\nimport { PopoverTreeContext } from './popoverTree';\nimport { useHoverClose } from './useHoverClose';\nimport { useLatestRef } from './useLatestRef';\nimport { usePopoverPosition } from './usePopoverPosition';\nimport { usePopoverTree } from './usePopoverTree';\n\nexport type PopoverPlacement = FloatingPlacement;\n\ninterface PopoverBaseProps {\n trigger: React.ReactElement;\n children?: React.ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n placement?: PopoverPlacement;\n openOn?: 'click' | 'hover';\n width?: 'content' | 'trigger';\n padding?: 'none' | 'small' | 'medium';\n anchorRef?: React.RefObject<HTMLElement | null>;\n offset?: FloatingOffset;\n elevation?: 'default' | 'raised';\n initialFocusRef?: React.RefObject<HTMLElement | null>;\n /** A click panel also opens, focus inside, on the arrow key its placement points at. */\n openOnArrowKey?: boolean;\n role?: 'dialog' | 'menu' | 'listbox';\n className?: string;\n}\n\ntype PopoverName =\n | { 'aria-label': string; 'aria-labelledby'?: string }\n | { 'aria-label'?: string; 'aria-labelledby': string };\n\nexport type PopoverProps = PopoverBaseProps & PopoverName;\n\nconst PANEL =\n 'font-sans box-border overflow-auto outline-none rounded-[var(--malachite-radius-xl,12px)] border border-solid border-[var(--malachite-card-border,rgb(232,232,232))] bg-[var(--malachite-card-background,rgb(255,255,255))] text-[var(--malachite-text-primary,rgb(10,10,10))]';\n\nconst ELEVATION: Record<NonNullable<PopoverBaseProps['elevation']>, string> = {\n default: '[box-shadow:0px_4px_10px_0px_var(--malachite-card-shadow,rgba(0,0,0,0.1))]',\n raised: '[box-shadow:0px_8px_24px_0px_var(--malachite-card-shadow,rgba(0,0,0,0.1))]',\n};\n\nconst PADDING: Record<NonNullable<PopoverBaseProps['padding']>, string> = {\n none: 'p-0',\n small: 'p-1',\n medium: 'p-2',\n};\n\nconst pathHits = (path: EventTarget[], nodes: Iterable<Element | null | undefined>): boolean => {\n for (const node of nodes) {\n if (node && path.includes(node)) {\n return true;\n }\n }\n return false;\n};\n\nconst KEYBOARD_OPEN_KEY: Record<string, string> = {\n bottom: 'ArrowDown',\n top: 'ArrowUp',\n right: 'ArrowRight',\n left: 'ArrowLeft',\n};\n\nconst isTextEntry = (target: EventTarget): boolean =>\n target instanceof HTMLElement &&\n (target.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(target.tagName));\n\nconst composedPathOf = (node: EventTarget | null): Node[] => {\n if (!(node instanceof Node)) {\n return [];\n }\n const root = node.getRootNode();\n return [node, ...(root instanceof ShadowRoot ? composedPathOf(root.host) : [])];\n};\n\nconst subscribeToNothing = () => () => undefined;\nconst onClient = () => true;\nconst onServer = () => false;\n\nconst focusTarget = (panel: HTMLElement, initial: HTMLElement | null | undefined): HTMLElement =>\n initial ?? firstTabStopIn(panel) ?? panel;\n\n/** An anchored, non-modal panel; nested Popovers count as inside their parent. */\nconst PopoverRoot: React.FC<PopoverProps> = ({\n trigger,\n children,\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n placement = 'bottom-start',\n openOn = 'click',\n width = 'content',\n padding = 'small',\n anchorRef,\n offset = 'small',\n elevation = 'default',\n initialFocusRef,\n openOnArrowKey = false,\n role = 'dialog',\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n className = '',\n}) => {\n const parent = useContext(PopoverTreeContext);\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const isOpen = controlledOpen ?? uncontrolledOpen;\n const isClient = useSyncExternalStore(subscribeToNothing, onClient, onServer);\n\n const triggerRef = useRef<HTMLElement | null>(null);\n const hostRef = useRef<HTMLDivElement | null>(null);\n const popupIdentity = usePopupLayer('popover', isOpen, hostRef);\n const [panel, setPanel] = useState<HTMLDivElement | null>(null);\n const heldByChildren = useRef(0);\n const focusOnOpen = useRef(false);\n const returningFocus = useRef(false);\n const pointerPressedTrigger = useRef(false);\n\n const isOpenRef = useLatestRef(isOpen);\n const controlledRef = useLatestRef(controlledOpen);\n const onOpenChangeRef = useLatestRef(onOpenChange);\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (next === isOpenRef.current) {\n return;\n }\n if (controlledRef.current === undefined) {\n setUncontrolledOpen(next);\n }\n onOpenChangeRef.current?.(next);\n },\n [isOpenRef, controlledRef, onOpenChangeRef],\n );\n\n const { pointerInside, focusInside, triggerFocused, cancelClose, scheduleClose } =\n useHoverClose({\n isOpenRef,\n heldByChildren,\n setOpen,\n });\n\n const { tree, ownedSources } = usePopoverTree({\n parent,\n isOpen,\n openOn,\n isOpenRef,\n heldByChildren,\n cancelClose,\n scheduleClose,\n });\n\n const geometry = usePopoverPosition({\n isOpen,\n panel,\n hostRef,\n triggerRef,\n anchorRef,\n placement,\n width,\n offset,\n });\n\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n const closeOnOutsidePress = (event: MouseEvent) => {\n const path = event.composedPath();\n const inside = pathHits(path, [\n triggerRef.current,\n hostRef.current,\n ...[...ownedSources.current].map((source) => source()),\n ]);\n if (!inside) {\n setOpen(false);\n }\n };\n document.addEventListener('mousedown', closeOnOutsidePress, true);\n const popEscapeLayer = pushEscapeLayer(() => setOpen(false));\n return () => {\n document.removeEventListener('mousedown', closeOnOutsidePress, true);\n popEscapeLayer();\n pointerInside.current = false;\n const active = getDeepActiveElement();\n if (focusInside.current && (!active || active === document.body)) {\n returningFocus.current = true;\n triggerRef.current?.focus({ preventScroll: true });\n returningFocus.current = false;\n }\n focusInside.current = false;\n };\n }, [isOpen, setOpen, ownedSources, pointerInside, focusInside]);\n\n const shown = isOpen && panel !== null && geometry !== null;\n\n useEffect(() => {\n const shouldFocus = openOn === 'click' || focusOnOpen.current;\n if (!shown || !panel || !shouldFocus) {\n return;\n }\n focusOnOpen.current = false;\n focusTarget(panel, initialFocusRef?.current).focus({ preventScroll: true });\n }, [shown, panel, openOn, initialFocusRef]);\n\n const openWithFocus = () => {\n cancelClose();\n if (isOpen && panel) {\n focusTarget(panel, initialFocusRef?.current).focus({ preventScroll: true });\n return;\n }\n focusOnOpen.current = true;\n setOpen(true);\n };\n\n const isInside = (node: EventTarget | null): boolean => {\n const containers = [\n triggerRef.current,\n hostRef.current,\n panel,\n ...[...ownedSources.current].map((source) => source()),\n ];\n return composedPathOf(node).some((step) =>\n containers.some((container) => container?.contains(step)),\n );\n };\n\n const closeIfFocusLeft = (next: EventTarget | null) => {\n if (!next) {\n return;\n }\n queueMicrotask(() => {\n if (!isInside(next) && !isInside(getDeepActiveElement())) {\n setOpen(false);\n }\n });\n };\n\n const hoverHandlers =\n openOn === 'hover'\n ? {\n onMouseEnter: () => {\n pointerInside.current = true;\n cancelClose();\n setOpen(true);\n },\n onMouseLeave: () => {\n pointerInside.current = false;\n scheduleClose();\n },\n onPanelMouseOver: () => {\n pointerInside.current = true;\n cancelClose();\n },\n }\n : null;\n\n const triggerProps = trigger.props as Record<string, unknown>;\n type Handler<E extends React.SyntheticEvent> = ((event: E) => void) | undefined;\n\n const ownTriggerRef = elementRef<HTMLElement>(trigger);\n const composedTriggerRef = useMemo(\n () => composeRefs(ownTriggerRef, triggerRef),\n [ownTriggerRef],\n );\n const openKey = KEYBOARD_OPEN_KEY[placement.split('-')[0]];\n\n const clonedTrigger = React.cloneElement(trigger, {\n ref: composedTriggerRef,\n 'aria-haspopup': role,\n 'aria-expanded': isOpen,\n onClick: chainHandler(\n triggerProps.onClick as Handler<React.MouseEvent>,\n (event: React.MouseEvent) => {\n if (openOn !== 'hover') {\n setOpen(!isOpen);\n return;\n }\n const fromKeyboard = event.detail === 0;\n if (fromKeyboard) {\n openWithFocus();\n return;\n }\n cancelClose();\n setOpen(true);\n },\n ),\n ...(hoverHandlers\n ? {\n onMouseEnter: chainHandler(\n triggerProps.onMouseEnter as Handler<React.MouseEvent>,\n hoverHandlers.onMouseEnter,\n ),\n onMouseLeave: chainHandler(\n triggerProps.onMouseLeave as Handler<React.MouseEvent>,\n hoverHandlers.onMouseLeave,\n ),\n onMouseDown: chainHandler(\n triggerProps.onMouseDown as Handler<React.MouseEvent>,\n () => {\n pointerPressedTrigger.current = true;\n setTimeout(() => {\n pointerPressedTrigger.current = false;\n });\n },\n ),\n onFocus: chainHandler(triggerProps.onFocus as Handler<React.FocusEvent>, () => {\n const fromPointer = pointerPressedTrigger.current;\n pointerPressedTrigger.current = false;\n triggerFocused.current = !fromPointer && !returningFocus.current;\n if (returningFocus.current) {\n return;\n }\n cancelClose();\n setOpen(true);\n }),\n onKeyDown: chainHandler(\n triggerProps.onKeyDown as Handler<React.KeyboardEvent>,\n (event: React.KeyboardEvent) => {\n if (event.key !== openKey) {\n return;\n }\n event.preventDefault();\n openWithFocus();\n },\n ),\n }\n : openOnArrowKey\n ? {\n onKeyDown: chainHandler(\n triggerProps.onKeyDown as Handler<React.KeyboardEvent>,\n (event: React.KeyboardEvent) => {\n if (event.key !== openKey || isTextEntry(event.target)) {\n return;\n }\n event.preventDefault();\n openWithFocus();\n },\n ),\n }\n : {}),\n onBlur: chainHandler(\n triggerProps.onBlur as Handler<React.FocusEvent>,\n (event: React.FocusEvent) => {\n triggerFocused.current = false;\n if (!isOpen || isInside(event.relatedTarget)) {\n return;\n }\n if (openOn === 'hover') {\n scheduleClose();\n return;\n }\n closeIfFocusLeft(event.relatedTarget);\n },\n ),\n } as Record<string, unknown>);\n\n const panelStyle: React.CSSProperties = {\n maxHeight: geometry?.maxHeight,\n maxWidth: `calc(100vw - ${MENU_VIEWPORT_PADDING_PX * 2}px)`,\n visibility: geometry ? 'visible' : 'hidden',\n };\n\n return (\n <>\n {clonedTrigger}\n {isOpen &&\n isClient &&\n createPortal(\n <PopoverTreeContext.Provider value={tree}>\n <ShadowRootWrapper\n hostRef={hostRef}\n hostProps={popupIdentity}\n hostStyle={{\n position: 'fixed',\n top: geometry?.top ?? 0,\n left: geometry?.left ?? 0,\n }}\n >\n <div\n ref={setPanel}\n role={role}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n data-side={geometry?.side}\n tabIndex={-1}\n className={`${PANEL} ${ELEVATION[elevation]} ${PADDING[padding]} ${className}`.trim()}\n style={panelStyle}\n // React's mouseenter stops at the shadow host, so the panel listens for mouseover.\n onMouseOver={hoverHandlers?.onPanelMouseOver}\n onMouseLeave={hoverHandlers?.onMouseLeave}\n onFocus={() => {\n focusInside.current = true;\n cancelClose();\n }}\n onBlur={(event) => {\n if (isInside(event.relatedTarget)) {\n return;\n }\n focusInside.current = false;\n if (openOn === 'hover') {\n scheduleClose();\n return;\n }\n closeIfFocusLeft(event.relatedTarget);\n }}\n >\n {children}\n </div>\n </ShadowRootWrapper>\n </PopoverTreeContext.Provider>,\n document.body,\n )}\n </>\n );\n};\n\nexport const Popover = Object.assign(PopoverRoot, {\n Header: PopoverHeader,\n Action: PopoverAction,\n List: PopoverList,\n Section: PopoverSection,\n Empty: PopoverEmpty,\n});\n\nexport default Popover;\n"],"names":["PANEL","ELEVATION","PADDING","pathHits","path","nodes","node","KEYBOARD_OPEN_KEY","isTextEntry","target","composedPathOf","root","subscribeToNothing","onClient","onServer","focusTarget","panel","initial","firstTabStopIn","PopoverRoot","trigger","children","controlledOpen","defaultOpen","onOpenChange","placement","openOn","width","padding","anchorRef","offset","elevation","initialFocusRef","openOnArrowKey","role","ariaLabel","ariaLabelledBy","className","parent","useContext","PopoverTreeContext","uncontrolledOpen","setUncontrolledOpen","useState","isOpen","isClient","useSyncExternalStore","triggerRef","useRef","hostRef","popupIdentity","usePopupLayer","setPanel","heldByChildren","focusOnOpen","returningFocus","pointerPressedTrigger","isOpenRef","useLatestRef","controlledRef","onOpenChangeRef","setOpen","useCallback","next","_a","pointerInside","focusInside","triggerFocused","cancelClose","scheduleClose","useHoverClose","tree","ownedSources","usePopoverTree","geometry","usePopoverPosition","useEffect","closeOnOutsidePress","event","source","popEscapeLayer","pushEscapeLayer","active","getDeepActiveElement","shown","shouldFocus","openWithFocus","isInside","containers","step","container","closeIfFocusLeft","hoverHandlers","triggerProps","ownTriggerRef","elementRef","composedTriggerRef","useMemo","composeRefs","openKey","clonedTrigger","React","chainHandler","fromPointer","panelStyle","MENU_VIEWPORT_PADDING_PX","jsxs","Fragment","createPortal","jsx","ShadowRootWrapper","Popover","PopoverHeader","PopoverAction","PopoverList","PopoverSection","PopoverEmpty"],"mappings":";;;;;;;;;;;;;;;;AA8DA,MAAMA,KACF,kRAEEC,KAAwE;AAAA,EAC1E,SAAS;AAAA,EACT,QAAQ;AACZ,GAEMC,KAAoE;AAAA,EACtE,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AACZ,GAEMC,KAAW,CAACC,GAAqBC,MAAyD;AAC5F,aAAWC,KAAQD;AACf,QAAIC,KAAQF,EAAK,SAASE,CAAI;AAC1B,aAAO;AAGf,SAAO;AACX,GAEMC,KAA4C;AAAA,EAC9C,Q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