@stackone/malachite 2.120.1 → 2.122.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.
@@ -1,184 +1,188 @@
1
- import { jsxs as ye, Fragment as Se, jsx as O } from "react/jsx-runtime";
2
- import Me, { useContext as Ce, useState as Q, useSyncExternalStore as De, useRef as d, useCallback as Z, useEffect as $, useMemo as _e } from "react";
3
- import { createPortal as Ae } from "react-dom";
4
- import { ShadowRootWrapper as Ne } from "../ShadowRootWrapper.js";
5
- import { PopoverNote as Ie, PopoverStatus as Oe, PopoverSearch as Ke, PopoverEmpty as ke, PopoverSection as Re, PopoverList as He, PopoverAction as Be, PopoverHeader as $e } from "./PopoverParts.js";
6
- import { getDeepActiveElement as U } from "./activeElement.js";
7
- import { elementRef as Ue, composeRefs as We, chainHandler as p } from "./composeRefs.js";
8
- import { pushEscapeLayer as je } from "./escapeLayers.js";
9
- import { MENU_VIEWPORT_PADDING_PX as Fe } from "./floatingMenuGeometry.js";
10
- import { firstTabStopIn as re } from "./overlayBehaviour.js";
11
- import { usePopupLayer as Ge } from "./overlayLayers.js";
12
- import { PopoverTreeContext as ee, PopoverShownContext as Ve } from "./popoverTree.js";
13
- import { useHoverClose as Xe } from "./useHoverClose.js";
14
- import { useLatestRef as K } from "./useLatestRef.js";
15
- import { usePopoverPosition as Ye } from "./usePopoverPosition.js";
16
- import { usePopoverTree as qe } from "./usePopoverTree.js";
17
- const ze = "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))]", Je = {
1
+ import { jsxs as Ce, Fragment as Me, jsx as k } from "react/jsx-runtime";
2
+ import De, { useContext as _e, useState as re, useSyncExternalStore as Ae, useRef as f, useCallback as W, useEffect as K, useMemo as Ne } from "react";
3
+ import { createPortal as Ie } from "react-dom";
4
+ import { ShadowRootWrapper as Oe } from "../ShadowRootWrapper.js";
5
+ import { PopoverNote as ke, PopoverStatus as Ke, PopoverSearch as Re, PopoverEmpty as He, PopoverSection as Be, PopoverList as $e, PopoverAction as Fe, PopoverHeader as Ue } from "./PopoverParts.js";
6
+ import { getDeepActiveElement as j } from "./activeElement.js";
7
+ import { elementRef as We, composeRefs as je, chainHandler as p } from "./composeRefs.js";
8
+ import { pushEscapeLayer as Ge } from "./escapeLayers.js";
9
+ import { MENU_VIEWPORT_PADDING_PX as Ve } from "./floatingMenuGeometry.js";
10
+ import { firstTabStopIn as oe } from "./overlayBehaviour.js";
11
+ import { usePopupLayer as Xe } from "./overlayLayers.js";
12
+ import { PopoverTreeContext as te, PopoverShownContext as Ye } from "./popoverTree.js";
13
+ import { useHoverClose as qe } from "./useHoverClose.js";
14
+ import { useLatestRef as R } from "./useLatestRef.js";
15
+ import { usePopoverPosition as ze } from "./usePopoverPosition.js";
16
+ import { usePopoverTree as Je } from "./usePopoverTree.js";
17
+ const Qe = "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))]", Ze = {
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
- }, Qe = {
20
+ }, er = {
21
21
  none: "p-0",
22
22
  small: "p-1",
23
23
  medium: "p-2"
24
- }, Ze = (r, a) => {
24
+ }, rr = (r, a) => {
25
25
  for (const g of a)
26
26
  if (g && r.includes(g))
27
27
  return !0;
28
28
  return !1;
29
- }, er = {
29
+ }, tr = {
30
30
  bottom: "ArrowDown",
31
31
  top: "ArrowUp",
32
32
  right: "ArrowRight",
33
33
  left: "ArrowLeft"
34
- }, rr = (r) => r instanceof HTMLElement && (r.isContentEditable || ["INPUT", "TEXTAREA", "SELECT"].includes(r.tagName)), te = (r) => {
34
+ }, or = (r) => r instanceof HTMLElement && (r.isContentEditable || ["INPUT", "TEXTAREA", "SELECT"].includes(r.tagName)), ne = (r) => {
35
35
  if (!(r instanceof Node))
36
36
  return [];
37
37
  const a = r.getRootNode();
38
- return [r, ...a instanceof ShadowRoot ? te(a.host) : []];
39
- }, tr = () => () => {
40
- }, or = () => !0, nr = () => !1, W = (r, a) => a ?? re(r) ?? r, k = (r) => typeof r == "function" ? r() : r == null ? void 0 : r.current, sr = (r, a) => !r || r === document.body || !r.isConnected || r === a, cr = ({
38
+ return [r, ...a instanceof ShadowRoot ? ne(a.host) : []];
39
+ }, nr = () => () => {
40
+ }, sr = () => !0, cr = () => !1, G = (r, a) => a ?? oe(r) ?? r, H = (r) => typeof r == "function" ? r() : r == null ? void 0 : r.current, ur = (r, a) => !r || r === document.body || !r.isConnected || r === a, ar = ({
41
41
  trigger: r,
42
42
  children: a,
43
43
  open: g,
44
- defaultOpen: oe = !1,
45
- onOpenChange: ne,
46
- placement: j = "bottom-start",
44
+ defaultOpen: se = !1,
45
+ onOpenChange: ce,
46
+ placement: V = "bottom-start",
47
47
  openOn: m = "click",
48
- width: se = "content",
49
- padding: ce = "small",
50
- anchorRef: ue,
51
- offset: ae = "small",
52
- elevation: le = "default",
53
- initialFocus: F,
48
+ width: ue = "content",
49
+ padding: ae = "small",
50
+ anchorRef: le,
51
+ offset: ie = "small",
52
+ elevation: fe = "default",
53
+ initialFocus: X,
54
54
  initialFocusRef: v,
55
- openOnArrowKey: ie = !1,
56
- role: G = "dialog",
57
- "aria-label": fe,
58
- "aria-labelledby": de,
59
- className: pe = ""
55
+ openOnArrowKey: de = !1,
56
+ role: Y = "dialog",
57
+ "aria-label": pe,
58
+ "aria-labelledby": me,
59
+ className: ve = ""
60
60
  }) => {
61
- const me = Ce(ee), [ve, he] = Q(oe), c = g ?? ve, be = De(tr, or, nr), w = d(null), b = d(null), Pe = Ge("popover", c, b), [t, Ee] = Q(null), V = d(0), R = d(!1), C = d(!1), D = d(!1), x = d(null), T = d(null), _ = K(c), X = K(g), A = K(ne), P = K(F), L = F !== void 0, l = Z(
61
+ const he = _e(te), [be, Pe] = re(se), c = g ?? be, Ee = Ae(nr, sr, cr), w = f(null), b = f(null), ge = Xe("popover", c, b), [t, we] = re(null), q = f(0), B = f(!1), D = f(!1), _ = f(!1), x = f(null), T = f(null), L = f(null), A = R(c), z = R(g), N = R(ce), P = R(X), y = X !== void 0, l = W(
62
62
  (e) => {
63
63
  var u;
64
- e !== _.current && (X.current === void 0 && he(e), (u = A.current) == null || u.call(A, e));
64
+ e !== A.current && (z.current === void 0 && Pe(e), (u = N.current) == null || u.call(N, e));
65
65
  },
66
- [_, X, A]
67
- ), { pointerInside: y, focusInside: S, triggerFocused: Y, cancelClose: h, scheduleClose: N } = Xe({
68
- isOpenRef: _,
69
- heldByChildren: V,
66
+ [A, z, N]
67
+ ), { pointerInside: S, focusInside: C, triggerFocused: J, cancelClose: h, scheduleClose: I } = qe({
68
+ isOpenRef: A,
69
+ heldByChildren: q,
70
70
  setOpen: l
71
- }), { tree: ge, ownedSources: H } = qe({
72
- parent: me,
71
+ }), { tree: xe, ownedSources: $ } = Je({
72
+ parent: he,
73
73
  isOpen: c,
74
74
  openOn: m,
75
- isOpenRef: _,
76
- heldByChildren: V,
75
+ isOpenRef: A,
76
+ heldByChildren: q,
77
77
  cancelClose: h,
78
- scheduleClose: N
79
- }), o = Ye({
78
+ scheduleClose: I
79
+ }), o = ze({
80
80
  isOpen: c,
81
81
  panel: t,
82
82
  hostRef: b,
83
83
  triggerRef: w,
84
- anchorRef: ue,
85
- placement: j,
86
- width: se,
87
- offset: ae
84
+ anchorRef: le,
85
+ placement: V,
86
+ width: ue,
87
+ offset: ie
88
88
  });
89
- $(() => {
89
+ K(() => {
90
90
  if (!c)
91
91
  return;
92
92
  const e = (n) => {
93
93
  const s = n.composedPath();
94
- Ze(s, [
94
+ rr(s, [
95
95
  w.current,
96
96
  b.current,
97
- ...[...H.current].map((Le) => Le())
97
+ ...[...$.current].map((Se) => Se())
98
98
  ]) || l(!1);
99
99
  };
100
100
  document.addEventListener("mousedown", e, !0);
101
- const u = je(() => l(!1));
101
+ const u = Ge(() => l(!1));
102
102
  return () => {
103
103
  var s;
104
- document.removeEventListener("mousedown", e, !0), u(), y.current = !1;
105
- const n = U();
106
- S.current && (!n || n === document.body) && (C.current = !0, (s = w.current) == null || s.focus({ preventScroll: !0 }), C.current = !1), S.current = !1, x.current = null, T.current = null;
104
+ document.removeEventListener("mousedown", e, !0), u(), S.current = !1;
105
+ const n = j();
106
+ C.current && (!n || n === document.body) && (D.current = !0, (s = w.current) == null || s.focus({ preventScroll: !0 }), D.current = !1), C.current = !1, x.current = null, T.current = null;
107
107
  };
108
- }, [c, l, H, y, S]);
109
- const M = c && t !== null && o !== null, E = Z((e) => {
108
+ }, [c, l, $, S, C]);
109
+ const M = c && t !== null && o !== null, E = W((e) => {
110
110
  x.current = e, e.focus({ preventScroll: !0 });
111
111
  }, []);
112
- $(() => {
113
- const e = m === "click" || R.current;
112
+ K(() => {
113
+ const e = m === "click" || B.current;
114
114
  if (!M || !t || !e)
115
115
  return;
116
- R.current = !1;
117
- const u = L ? k(P.current) : v == null ? void 0 : v.current;
118
- E(W(t, u));
119
- }, [M, t, m, L, v, P, E]), $(() => {
120
- if (!M || !t || !L)
116
+ B.current = !1;
117
+ const u = y ? H(P.current) : v == null ? void 0 : v.current;
118
+ E(G(t, u));
119
+ }, [M, t, m, y, v, P, E]), K(() => {
120
+ if (!M || !t || !y)
121
121
  return;
122
122
  const e = () => {
123
- const n = U();
124
- if (sr(n, b.current)) {
125
- T.current && !T.current.isConnected && E(W(t, k(P.current)));
123
+ const n = j();
124
+ if (ur(n, b.current)) {
125
+ T.current && !T.current.isConnected && E(G(t, H(P.current)));
126
126
  return;
127
127
  }
128
128
  if (n !== x.current)
129
129
  return;
130
- const s = k(P.current) ?? (n === t ? re(t) : null);
130
+ const s = H(P.current) ?? (n === t ? oe(t) : null);
131
131
  s && s !== n && s.isConnected && E(s);
132
132
  }, u = new MutationObserver(e);
133
133
  return u.observe(t, { childList: !0, subtree: !0 }), () => u.disconnect();
134
- }, [M, t, L, P, E]);
135
- const B = () => {
134
+ }, [M, t, y, P, E]);
135
+ const F = () => {
136
136
  if (h(), c && t) {
137
- const e = L ? k(P.current) : v == null ? void 0 : v.current;
138
- E(W(t, e));
137
+ const e = y ? H(P.current) : v == null ? void 0 : v.current;
138
+ E(G(t, e));
139
139
  return;
140
140
  }
141
- R.current = !0, l(!0);
142
- }, I = (e) => {
141
+ B.current = !0, l(!0);
142
+ }, O = (e) => {
143
143
  const u = [
144
144
  w.current,
145
145
  b.current,
146
146
  t,
147
- ...[...H.current].map((n) => n())
147
+ ...[...$.current].map((n) => n())
148
148
  ];
149
- return te(e).some(
149
+ return ne(e).some(
150
150
  (n) => u.some((s) => s == null ? void 0 : s.contains(n))
151
151
  );
152
- }, q = (e) => {
153
- e && setTimeout(() => {
154
- !I(e) && !I(U()) && l(!1);
155
- });
152
+ }, U = W(() => {
153
+ L.current && (clearTimeout(L.current), L.current = null);
154
+ }, []);
155
+ K(() => U, [U]);
156
+ const Q = (e) => {
157
+ e && (U(), L.current = setTimeout(() => {
158
+ L.current = null, !O(e) && !O(j()) && l(!1);
159
+ }));
156
160
  }, i = m === "hover" ? {
157
161
  onMouseEnter: () => {
158
- y.current = !0, h(), l(!0);
162
+ S.current = !0, h(), l(!0);
159
163
  },
160
164
  onMouseLeave: () => {
161
- y.current = !1, N();
165
+ S.current = !1, I();
162
166
  },
163
167
  onPanelMouseOver: () => {
164
- y.current = !0, h();
168
+ S.current = !0, h();
165
169
  }
166
- } : null, f = r.props, z = Ue(r), we = _e(
167
- () => We(z, w),
168
- [z]
169
- ), J = er[j.split("-")[0]], xe = Me.cloneElement(r, {
170
- ref: we,
171
- "aria-haspopup": G,
170
+ } : null, d = r.props, Z = We(r), Te = Ne(
171
+ () => je(Z, w),
172
+ [Z]
173
+ ), ee = tr[V.split("-")[0]], Le = De.cloneElement(r, {
174
+ ref: Te,
175
+ "aria-haspopup": Y,
172
176
  "aria-expanded": c,
173
177
  onClick: p(
174
- f.onClick,
178
+ d.onClick,
175
179
  (e) => {
176
180
  if (m !== "hover") {
177
181
  l(!c);
178
182
  return;
179
183
  }
180
184
  if (e.detail === 0) {
181
- B();
185
+ F();
182
186
  return;
183
187
  }
184
188
  h(), l(!0);
@@ -186,95 +190,95 @@ const ze = "font-sans box-border overflow-auto outline-none rounded-[var(--malac
186
190
  ),
187
191
  ...i ? {
188
192
  onMouseEnter: p(
189
- f.onMouseEnter,
193
+ d.onMouseEnter,
190
194
  i.onMouseEnter
191
195
  ),
192
196
  onMouseLeave: p(
193
- f.onMouseLeave,
197
+ d.onMouseLeave,
194
198
  i.onMouseLeave
195
199
  ),
196
200
  onMouseDown: p(
197
- f.onMouseDown,
201
+ d.onMouseDown,
198
202
  () => {
199
- D.current = !0, setTimeout(() => {
200
- D.current = !1;
203
+ _.current = !0, setTimeout(() => {
204
+ _.current = !1;
201
205
  });
202
206
  }
203
207
  ),
204
- onFocus: p(f.onFocus, () => {
205
- const e = D.current;
206
- D.current = !1, Y.current = !e && !C.current, !C.current && (h(), l(!0));
208
+ onFocus: p(d.onFocus, () => {
209
+ const e = _.current;
210
+ _.current = !1, J.current = !e && !D.current, !D.current && (h(), l(!0));
207
211
  }),
208
212
  onKeyDown: p(
209
- f.onKeyDown,
213
+ d.onKeyDown,
210
214
  (e) => {
211
- e.key === J && (e.preventDefault(), B());
215
+ e.key === ee && (e.preventDefault(), F());
212
216
  }
213
217
  )
214
- } : ie ? {
218
+ } : de ? {
215
219
  onKeyDown: p(
216
- f.onKeyDown,
220
+ d.onKeyDown,
217
221
  (e) => {
218
- e.key !== J || rr(e.target) || (e.preventDefault(), B());
222
+ e.key !== ee || or(e.target) || (e.preventDefault(), F());
219
223
  }
220
224
  )
221
225
  } : {},
222
226
  onBlur: p(
223
- f.onBlur,
227
+ d.onBlur,
224
228
  (e) => {
225
- if (Y.current = !1, !(!c || I(e.relatedTarget))) {
229
+ if (J.current = !1, !(!c || O(e.relatedTarget))) {
226
230
  if (m === "hover") {
227
- N();
231
+ I();
228
232
  return;
229
233
  }
230
- q(e.relatedTarget);
234
+ Q(e.relatedTarget);
231
235
  }
232
236
  }
233
237
  )
234
- }), Te = {
238
+ }), ye = {
235
239
  maxHeight: o == null ? void 0 : o.maxHeight,
236
- maxWidth: `calc(100vw - ${Fe * 2}px)`,
240
+ maxWidth: `calc(100vw - ${Ve * 2}px)`,
237
241
  visibility: o ? "visible" : "hidden"
238
242
  };
239
- return /* @__PURE__ */ ye(Se, { children: [
240
- xe,
241
- c && be && Ae(
242
- /* @__PURE__ */ O(ee.Provider, { value: ge, children: /* @__PURE__ */ O(
243
- Ne,
243
+ return /* @__PURE__ */ Ce(Me, { children: [
244
+ Le,
245
+ c && Ee && Ie(
246
+ /* @__PURE__ */ k(te.Provider, { value: xe, children: /* @__PURE__ */ k(
247
+ Oe,
244
248
  {
245
249
  hostRef: b,
246
- hostProps: Pe,
250
+ hostProps: ge,
247
251
  hostStyle: {
248
252
  position: "fixed",
249
253
  top: (o == null ? void 0 : o.top) ?? 0,
250
254
  left: (o == null ? void 0 : o.left) ?? 0
251
255
  },
252
- children: /* @__PURE__ */ O(
256
+ children: /* @__PURE__ */ k(
253
257
  "div",
254
258
  {
255
- ref: Ee,
256
- role: G,
257
- "aria-label": fe,
258
- "aria-labelledby": de,
259
+ ref: we,
260
+ role: Y,
261
+ "aria-label": pe,
262
+ "aria-labelledby": me,
259
263
  "data-side": o == null ? void 0 : o.side,
260
264
  tabIndex: -1,
261
- className: `${ze} ${Je[le]} ${Qe[ce]} ${pe}`.trim(),
262
- style: Te,
265
+ className: `${Qe} ${Ze[fe]} ${er[ae]} ${ve}`.trim(),
266
+ style: ye,
263
267
  onMouseOver: i == null ? void 0 : i.onPanelMouseOver,
264
268
  onMouseLeave: i == null ? void 0 : i.onMouseLeave,
265
269
  onFocus: (e) => {
266
- S.current = !0, e.target !== x.current && (x.current = null), e.target instanceof HTMLElement && (t != null && t.contains(e.target)) && (T.current = e.target), h();
270
+ C.current = !0, e.target !== x.current && (x.current = null), e.target instanceof HTMLElement && (t != null && t.contains(e.target)) && (T.current = e.target), h();
267
271
  },
268
272
  onBlur: (e) => {
269
- if (!I(e.relatedTarget)) {
270
- if (e.relatedTarget && (T.current = null), S.current = !1, m === "hover") {
271
- N();
273
+ if (!O(e.relatedTarget)) {
274
+ if (e.relatedTarget && (T.current = null), C.current = !1, m === "hover") {
275
+ I();
272
276
  return;
273
277
  }
274
- q(e.relatedTarget);
278
+ Q(e.relatedTarget);
275
279
  }
276
280
  },
277
- children: /* @__PURE__ */ O(Ve.Provider, { value: M, children: a })
281
+ children: /* @__PURE__ */ k(Ye.Provider, { value: M, children: a })
278
282
  }
279
283
  )
280
284
  }
@@ -282,18 +286,18 @@ const ze = "font-sans box-border overflow-auto outline-none rounded-[var(--malac
282
286
  document.body
283
287
  )
284
288
  ] });
285
- }, Lr = Object.assign(cr, {
286
- Header: $e,
287
- Action: Be,
288
- List: He,
289
- Section: Re,
290
- Empty: ke,
291
- Search: Ke,
292
- Status: Oe,
293
- Note: Ie
289
+ }, Sr = Object.assign(ar, {
290
+ Header: Ue,
291
+ Action: Fe,
292
+ List: $e,
293
+ Section: Be,
294
+ Empty: He,
295
+ Search: Re,
296
+ Status: Ke,
297
+ Note: ke
294
298
  });
295
299
  export {
296
- Lr as Popover,
297
- Lr as default
300
+ Sr as Popover,
301
+ Sr as default
298
302
  };
299
303
  //# 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 PopoverNote,\n PopoverSearch,\n PopoverSection,\n PopoverStatus,\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 { PopoverShownContext, 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\nexport type PopoverInitialFocus =\n | React.RefObject<HTMLElement | null>\n | (() => HTMLElement | null | undefined);\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 /** 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\ntype PopoverFocusSource =\n | {\n /**\n * What takes focus when the panel is shown, in place of its first tab stop. Re-read as the\n * content changes, so focus follows late content but never leaves where the user moved it.\n */\n initialFocus?: PopoverInitialFocus;\n initialFocusRef?: never;\n }\n | {\n initialFocus?: never;\n /** @deprecated Use `initialFocus`, which takes the same ref and also follows late content. */\n initialFocusRef?: React.RefObject<HTMLElement | null>;\n };\n\nexport type PopoverProps = PopoverBaseProps & PopoverName & PopoverFocusSource;\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\nconst resolveFocus = (source: PopoverInitialFocus | undefined): HTMLElement | null | undefined =>\n typeof source === 'function' ? source() : source?.current;\n\n// Some engines keep a removed element as `activeElement`, and a shadow host with nothing\n// focused inside it holds focus for no one.\nconst focusIsLost = (active: HTMLElement | null, host: HTMLElement | null): boolean =>\n !active || active === document.body || !active.isConnected || active === host;\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 initialFocus,\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 const placedFocus = useRef<HTMLElement | null>(null);\n const heldFocus = useRef<HTMLElement | null>(null);\n\n const isOpenRef = useLatestRef(isOpen);\n const controlledRef = useLatestRef(controlledOpen);\n const onOpenChangeRef = useLatestRef(onOpenChange);\n const initialFocusSource = useLatestRef(initialFocus);\n const followsContent = initialFocus !== undefined;\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 placedFocus.current = null;\n heldFocus.current = null;\n };\n }, [isOpen, setOpen, ownedSources, pointerInside, focusInside]);\n\n const shown = isOpen && panel !== null && geometry !== null;\n\n const placeFocus = useCallback((target: HTMLElement) => {\n placedFocus.current = target;\n target.focus({ preventScroll: true });\n }, []);\n\n useEffect(() => {\n const shouldFocus = openOn === 'click' || focusOnOpen.current;\n if (!shown || !panel || !shouldFocus) {\n return;\n }\n focusOnOpen.current = false;\n const initial = followsContent\n ? resolveFocus(initialFocusSource.current)\n : initialFocusRef?.current;\n placeFocus(focusTarget(panel, initial));\n }, [shown, panel, openOn, followsContent, initialFocusRef, initialFocusSource, placeFocus]);\n\n useEffect(() => {\n if (!shown || !panel || !followsContent) {\n return;\n }\n const followContent = () => {\n const active = getDeepActiveElement();\n if (focusIsLost(active, hostRef.current)) {\n if (heldFocus.current && !heldFocus.current.isConnected) {\n placeFocus(focusTarget(panel, resolveFocus(initialFocusSource.current)));\n }\n return;\n }\n if (active !== placedFocus.current) {\n return;\n }\n const next =\n resolveFocus(initialFocusSource.current) ??\n (active === panel ? firstTabStopIn(panel) : null);\n if (next && next !== active && next.isConnected) {\n placeFocus(next);\n }\n };\n const observer = new MutationObserver(followContent);\n observer.observe(panel, { childList: true, subtree: true });\n return () => observer.disconnect();\n }, [shown, panel, followsContent, initialFocusSource, placeFocus]);\n\n const openWithFocus = () => {\n cancelClose();\n if (isOpen && panel) {\n const initial = followsContent\n ? resolveFocus(initialFocusSource.current)\n : initialFocusRef?.current;\n placeFocus(focusTarget(panel, initial));\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 // A press blurs before it focuses, and `next` is retargeted to the trigger's shadow host,\n // so judge by where focus lands once the press has moved it, not between the two steps.\n setTimeout(() => {\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={(event) => {\n focusInside.current = true;\n if (event.target !== placedFocus.current) {\n placedFocus.current = null;\n }\n if (\n event.target instanceof HTMLElement &&\n panel?.contains(event.target)\n ) {\n heldFocus.current = event.target;\n }\n cancelClose();\n }}\n onBlur={(event) => {\n if (isInside(event.relatedTarget)) {\n return;\n }\n if (event.relatedTarget) {\n heldFocus.current = null;\n }\n focusInside.current = false;\n if (openOn === 'hover') {\n scheduleClose();\n return;\n }\n closeIfFocusLeft(event.relatedTarget);\n }}\n >\n <PopoverShownContext.Provider value={shown}>\n {children}\n </PopoverShownContext.Provider>\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 Search: PopoverSearch,\n Status: PopoverStatus,\n Note: PopoverNote,\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","resolveFocus","source","focusIsLost","active","host","PopoverRoot","trigger","children","controlledOpen","defaultOpen","onOpenChange","placement","openOn","width","padding","anchorRef","offset","elevation","initialFocus","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","placedFocus","heldFocus","isOpenRef","useLatestRef","controlledRef","onOpenChangeRef","initialFocusSource","followsContent","setOpen","useCallback","next","_a","pointerInside","focusInside","triggerFocused","cancelClose","scheduleClose","useHoverClose","tree","ownedSources","usePopoverTree","geometry","usePopoverPosition","useEffect","closeOnOutsidePress","event","popEscapeLayer","pushEscapeLayer","getDeepActiveElement","shown","placeFocus","shouldFocus","followContent","observer","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","PopoverShownContext","Popover","PopoverHeader","PopoverAction","PopoverList","PopoverSection","PopoverEmpty","PopoverSearch","PopoverStatus","PopoverNote"],"mappings":";;;;;;;;;;;;;;;;AAmFA,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,QAAQ;AAAA,EACR,KAAK;AAAA,E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cACJ;AAAA,cACA,QAAQ,CAACU,MAAU;AACf,oBAAI,CAAAU,EAASV,EAAM,aAAa,GAOhC;AAAA,sBAJIA,EAAM,kBACNxB,EAAU,UAAU,OAExBY,EAAY,UAAU,IAClB7C,MAAW,SAAS;AACpB,oBAAAgD,EAAA;AACA;AAAA,kBACJ;AACA,kBAAAuB,EAAiBd,EAAM,aAAa;AAAA;AAAA,cACxC;AAAA,cAEA,4BAACkC,GAAoB,UAApB,EAA6B,OAAO9B,GAChC,UAAAlE,EAAA,CACL;AAAA,YAAA;AAAA,UAAA;AAAA,QACJ;AAAA,MAAA,GAER;AAAA,MACA,SAAS;AAAA,IAAA;AAAA,EACb,GACR;AAER,GAEaiG,KAAU,OAAO,OAAOnG,IAAa;AAAA,EAC9C,QAAQoG;AAAA,EACR,QAAQC;AAAA,EACR,MAAMC;AAAA,EACN,SAASC;AAAA,EACT,OAAOC;AAAA,EACP,QAAQC;AAAA,EACR,QAAQC;AAAA,EACR,MAAMC;AACV,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 PopoverNote,\n PopoverSearch,\n PopoverSection,\n PopoverStatus,\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 { PopoverShownContext, 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\nexport type PopoverInitialFocus =\n | React.RefObject<HTMLElement | null>\n | (() => HTMLElement | null | undefined);\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 /** 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\ntype PopoverFocusSource =\n | {\n /**\n * What takes focus when the panel is shown, in place of its first tab stop. Re-read as the\n * content changes, so focus follows late content but never leaves where the user moved it.\n */\n initialFocus?: PopoverInitialFocus;\n initialFocusRef?: never;\n }\n | {\n initialFocus?: never;\n /** @deprecated Use `initialFocus`, which takes the same ref and also follows late content. */\n initialFocusRef?: React.RefObject<HTMLElement | null>;\n };\n\nexport type PopoverProps = PopoverBaseProps & PopoverName & PopoverFocusSource;\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\nconst resolveFocus = (source: PopoverInitialFocus | undefined): HTMLElement | null | undefined =>\n typeof source === 'function' ? source() : source?.current;\n\n// Some engines keep a removed element as `activeElement`, and a shadow host with nothing\n// focused inside it holds focus for no one.\nconst focusIsLost = (active: HTMLElement | null, host: HTMLElement | null): boolean =>\n !active || active === document.body || !active.isConnected || active === host;\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 initialFocus,\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 const placedFocus = useRef<HTMLElement | null>(null);\n const heldFocus = useRef<HTMLElement | null>(null);\n const focusLeaveCheck = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const isOpenRef = useLatestRef(isOpen);\n const controlledRef = useLatestRef(controlledOpen);\n const onOpenChangeRef = useLatestRef(onOpenChange);\n const initialFocusSource = useLatestRef(initialFocus);\n const followsContent = initialFocus !== undefined;\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 placedFocus.current = null;\n heldFocus.current = null;\n };\n }, [isOpen, setOpen, ownedSources, pointerInside, focusInside]);\n\n const shown = isOpen && panel !== null && geometry !== null;\n\n const placeFocus = useCallback((target: HTMLElement) => {\n placedFocus.current = target;\n target.focus({ preventScroll: true });\n }, []);\n\n useEffect(() => {\n const shouldFocus = openOn === 'click' || focusOnOpen.current;\n if (!shown || !panel || !shouldFocus) {\n return;\n }\n focusOnOpen.current = false;\n const initial = followsContent\n ? resolveFocus(initialFocusSource.current)\n : initialFocusRef?.current;\n placeFocus(focusTarget(panel, initial));\n }, [shown, panel, openOn, followsContent, initialFocusRef, initialFocusSource, placeFocus]);\n\n useEffect(() => {\n if (!shown || !panel || !followsContent) {\n return;\n }\n const followContent = () => {\n const active = getDeepActiveElement();\n if (focusIsLost(active, hostRef.current)) {\n if (heldFocus.current && !heldFocus.current.isConnected) {\n placeFocus(focusTarget(panel, resolveFocus(initialFocusSource.current)));\n }\n return;\n }\n if (active !== placedFocus.current) {\n return;\n }\n const next =\n resolveFocus(initialFocusSource.current) ??\n (active === panel ? firstTabStopIn(panel) : null);\n if (next && next !== active && next.isConnected) {\n placeFocus(next);\n }\n };\n const observer = new MutationObserver(followContent);\n observer.observe(panel, { childList: true, subtree: true });\n return () => observer.disconnect();\n }, [shown, panel, followsContent, initialFocusSource, placeFocus]);\n\n const openWithFocus = () => {\n cancelClose();\n if (isOpen && panel) {\n const initial = followsContent\n ? resolveFocus(initialFocusSource.current)\n : initialFocusRef?.current;\n placeFocus(focusTarget(panel, initial));\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 clearFocusLeaveCheck = useCallback(() => {\n if (focusLeaveCheck.current) {\n clearTimeout(focusLeaveCheck.current);\n focusLeaveCheck.current = null;\n }\n }, []);\n\n useEffect(() => clearFocusLeaveCheck, [clearFocusLeaveCheck]);\n\n const closeIfFocusLeft = (next: EventTarget | null) => {\n if (!next) {\n return;\n }\n // A press blurs before it focuses, and `next` is retargeted to the trigger's shadow host,\n // so judge by where focus lands once the press has moved it, not between the two steps.\n clearFocusLeaveCheck();\n focusLeaveCheck.current = setTimeout(() => {\n focusLeaveCheck.current = null;\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={(event) => {\n focusInside.current = true;\n if (event.target !== placedFocus.current) {\n placedFocus.current = null;\n }\n if (\n event.target instanceof HTMLElement &&\n panel?.contains(event.target)\n ) {\n heldFocus.current = event.target;\n }\n cancelClose();\n }}\n onBlur={(event) => {\n if (isInside(event.relatedTarget)) {\n return;\n }\n if (event.relatedTarget) {\n heldFocus.current = null;\n }\n focusInside.current = false;\n if (openOn === 'hover') {\n scheduleClose();\n return;\n }\n closeIfFocusLeft(event.relatedTarget);\n }}\n >\n <PopoverShownContext.Provider value={shown}>\n {children}\n </PopoverShownContext.Provider>\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 Search: PopoverSearch,\n Status: PopoverStatus,\n Note: PopoverNote,\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","resolveFocus","source","focusIsLost","active","host","PopoverRoot","trigger","children","controlledOpen","defaultOpen","onOpenChange","placement","openOn","width","padding","anchorRef","offset","elevation","initialFocus","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","placedFocus","heldFocus","focusLeaveCheck","isOpenRef","useLatestRef","controlledRef","onOpenChangeRef","initialFocusSource","followsContent","setOpen","useCallback","next","_a","pointerInside","focusInside","triggerFocused","cancelClose","scheduleClose","useHoverClose","tree","ownedSources","usePopoverTree","geometry","usePopoverPosition","useEffect","closeOnOutsidePress","event","popEscapeLayer","pushEscapeLayer","getDeepActiveElement","shown","placeFocus","shouldFocus","followContent","observer","openWithFocus","isInside","containers","step","container","clearFocusLeaveCheck","closeIfFocusLeft","hoverHandlers","triggerProps","ownTriggerRef","elementRef","composedTriggerRef","useMemo","composeRefs","openKey","clonedTrigger","React","chainHandler","fromPointer","panelStyle","MENU_VIEWPORT_PADDING_PX","jsxs","Fragment","createPortal","jsx","ShadowRootWrapper","PopoverShownContext","Popover","PopoverHeader","PopoverAction","PopoverList","PopoverSection","PopoverEmpty","PopoverSearch","PopoverStatus","PopoverNote"],"mappings":";;;;;;;;;;;;;;;;AAmFA,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,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AACV,GAEMC,KAAc,CAACC,MACjBA,aAAkB,gBACjBA,EAAO,qBAAqB,CAAC,SAAS,YAAY,QAAQ,EAAE,SAASA,EAAO,OAA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