@x-plat/design-system 0.14.19 → 0.15.1

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.
@@ -35,13 +35,13 @@ __export(Dropdown_exports, {
35
35
  module.exports = __toCommonJS(Dropdown_exports);
36
36
 
37
37
  // src/components/Dropdown/Dropdown.tsx
38
- var import_react4 = __toESM(require("react"), 1);
38
+ var import_react5 = __toESM(require("react"), 1);
39
39
 
40
40
  // src/tokens/hooks/Portal.tsx
41
41
  var import_react_dom = __toESM(require("react-dom"), 1);
42
- var Portal = ({ children }) => {
42
+ var Portal = ({ children, container }) => {
43
43
  if (typeof document === "undefined") return null;
44
- return import_react_dom.default.createPortal(children, document.body);
44
+ return import_react_dom.default.createPortal(children, container ?? document.body);
45
45
  };
46
46
  Portal.displayName = "Portal";
47
47
  var Portal_default = Portal;
@@ -50,8 +50,10 @@ var Portal_default = Portal;
50
50
  var import_react = __toESM(require("react"), 1);
51
51
  var findScrollParent = (el) => {
52
52
  for (let p = el.parentElement; p; p = p.parentElement) {
53
- const { overflowY, overflowX } = getComputedStyle(p);
54
- if (/(auto|scroll)/.test(overflowY) || /(auto|scroll)/.test(overflowX)) return p;
53
+ if (p.dataset.xplatOverlayEscape !== void 0) continue;
54
+ const { overflowY } = getComputedStyle(p);
55
+ if (!/(auto|scroll)/.test(overflowY)) continue;
56
+ if (p.scrollHeight > p.clientHeight) return p;
55
57
  }
56
58
  return null;
57
59
  };
@@ -147,8 +149,9 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
147
149
  );
148
150
  if (frozenMaxRef.current === void 0) frozenMaxRef.current = suggested;
149
151
  const maxHeight = frozenMaxRef.current;
150
- pop.style.top = `${top + window.scrollY}px`;
151
- pop.style.left = `${left + window.scrollX}px`;
152
+ const hostRect = (pop.offsetParent ?? pop.parentElement)?.getBoundingClientRect();
153
+ pop.style.top = `${top - (hostRect?.top ?? 0)}px`;
154
+ pop.style.left = `${left - (hostRect?.left ?? 0)}px`;
152
155
  pop.style.maxHeight = maxHeight === null ? "" : `${maxHeight}px`;
153
156
  pop.style.clipPath = over.top || over.right || over.bottom || over.left ? `inset(${over.top}px ${over.right}px ${over.bottom}px ${over.left}px)` : "none";
154
157
  directionRef.current = next;
@@ -223,8 +226,34 @@ var useClickOutside = (refs, handler, enabled = true) => {
223
226
  };
224
227
  var useClickOutside_default = useClickOutside;
225
228
 
226
- // src/tokens/hooks/useOverlayKeyboard.ts
229
+ // src/tokens/hooks/useOverlayHost.ts
227
230
  var import_react3 = __toESM(require("react"), 1);
231
+ var useOverlayHost = (triggerRef, enabled) => {
232
+ const [host, setHost] = import_react3.default.useState(null);
233
+ import_react3.default.useLayoutEffect(() => {
234
+ if (!enabled || !triggerRef.current) {
235
+ setHost(null);
236
+ return;
237
+ }
238
+ const el = document.createElement("div");
239
+ el.dataset.xplatOverlayHost = "";
240
+ el.style.position = "relative";
241
+ el.style.width = "0";
242
+ el.style.height = "0";
243
+ const parent = findScrollParent(triggerRef.current) ?? document.body;
244
+ parent.appendChild(el);
245
+ setHost(el);
246
+ return () => {
247
+ el.remove();
248
+ setHost(null);
249
+ };
250
+ }, [enabled, triggerRef]);
251
+ return host;
252
+ };
253
+ var useOverlayHost_default = useOverlayHost;
254
+
255
+ // src/tokens/hooks/useOverlayKeyboard.ts
256
+ var import_react4 = __toESM(require("react"), 1);
228
257
  var FOCUSABLE = [
229
258
  "a[href]",
230
259
  "button:not([disabled])",
@@ -234,7 +263,7 @@ var FOCUSABLE = [
234
263
  "[tabindex]:not([tabindex='-1'])"
235
264
  ].join(",");
236
265
  var useEscapeKey = (enabled, onEscape) => {
237
- import_react3.default.useEffect(() => {
266
+ import_react4.default.useEffect(() => {
238
267
  if (!enabled) return;
239
268
  const onKey = (e) => {
240
269
  if (e.key !== "Escape") return;
@@ -247,9 +276,9 @@ var useEscapeKey = (enabled, onEscape) => {
247
276
  }, [enabled, onEscape]);
248
277
  };
249
278
  var useCloseWhenFocusHidden = (enabled, triggerRef, popRef, onClose) => {
250
- const onCloseRef = import_react3.default.useRef(onClose);
279
+ const onCloseRef = import_react4.default.useRef(onClose);
251
280
  onCloseRef.current = onClose;
252
- import_react3.default.useEffect(() => {
281
+ import_react4.default.useEffect(() => {
253
282
  const trigger = triggerRef.current;
254
283
  if (!enabled || !trigger) return;
255
284
  const observer = new IntersectionObserver(
@@ -287,11 +316,12 @@ var clsx_default = clsx;
287
316
  var import_jsx_runtime = require("react/jsx-runtime");
288
317
  var Dropdown = (props) => {
289
318
  const { items, children } = props;
290
- const [isOpen, setIsOpen] = import_react4.default.useState(false);
291
- const [mounted, setMounted] = import_react4.default.useState(false);
292
- const [visible, setVisible] = import_react4.default.useState(false);
293
- const triggerRef = import_react4.default.useRef(null);
294
- const menuRef = import_react4.default.useRef(null);
319
+ const [isOpen, setIsOpen] = import_react5.default.useState(false);
320
+ const [mounted, setMounted] = import_react5.default.useState(false);
321
+ const [visible, setVisible] = import_react5.default.useState(false);
322
+ const triggerRef = import_react5.default.useRef(null);
323
+ const menuRef = import_react5.default.useRef(null);
324
+ const host = useOverlayHost_default(triggerRef, mounted);
295
325
  useAutoPosition_default(triggerRef, menuRef, mounted);
296
326
  useClickOutside_default([triggerRef, menuRef], () => setIsOpen(false), isOpen);
297
327
  useCloseWhenFocusHidden(isOpen, triggerRef, menuRef, () => setIsOpen(false));
@@ -299,7 +329,7 @@ var Dropdown = (props) => {
299
329
  setIsOpen(false);
300
330
  triggerRef.current?.focus({ preventScroll: true });
301
331
  });
302
- import_react4.default.useEffect(() => {
332
+ import_react5.default.useEffect(() => {
303
333
  if (isOpen) {
304
334
  setMounted(true);
305
335
  const t2 = setTimeout(() => setVisible(true), 1);
@@ -324,7 +354,7 @@ var Dropdown = (props) => {
324
354
  children
325
355
  }
326
356
  ),
327
- mounted && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Portal_default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
357
+ mounted && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Portal_default, { container: host, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
328
358
  "div",
329
359
  {
330
360
  ref: menuRef,
@@ -1,11 +1,11 @@
1
1
  // src/components/Dropdown/Dropdown.tsx
2
- import React4 from "react";
2
+ import React5 from "react";
3
3
 
4
4
  // src/tokens/hooks/Portal.tsx
5
5
  import ReactDOM from "react-dom";
6
- var Portal = ({ children }) => {
6
+ var Portal = ({ children, container }) => {
7
7
  if (typeof document === "undefined") return null;
8
- return ReactDOM.createPortal(children, document.body);
8
+ return ReactDOM.createPortal(children, container ?? document.body);
9
9
  };
10
10
  Portal.displayName = "Portal";
11
11
  var Portal_default = Portal;
@@ -14,8 +14,10 @@ var Portal_default = Portal;
14
14
  import React from "react";
15
15
  var findScrollParent = (el) => {
16
16
  for (let p = el.parentElement; p; p = p.parentElement) {
17
- const { overflowY, overflowX } = getComputedStyle(p);
18
- if (/(auto|scroll)/.test(overflowY) || /(auto|scroll)/.test(overflowX)) return p;
17
+ if (p.dataset.xplatOverlayEscape !== void 0) continue;
18
+ const { overflowY } = getComputedStyle(p);
19
+ if (!/(auto|scroll)/.test(overflowY)) continue;
20
+ if (p.scrollHeight > p.clientHeight) return p;
19
21
  }
20
22
  return null;
21
23
  };
@@ -111,8 +113,9 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
111
113
  );
112
114
  if (frozenMaxRef.current === void 0) frozenMaxRef.current = suggested;
113
115
  const maxHeight = frozenMaxRef.current;
114
- pop.style.top = `${top + window.scrollY}px`;
115
- pop.style.left = `${left + window.scrollX}px`;
116
+ const hostRect = (pop.offsetParent ?? pop.parentElement)?.getBoundingClientRect();
117
+ pop.style.top = `${top - (hostRect?.top ?? 0)}px`;
118
+ pop.style.left = `${left - (hostRect?.left ?? 0)}px`;
116
119
  pop.style.maxHeight = maxHeight === null ? "" : `${maxHeight}px`;
117
120
  pop.style.clipPath = over.top || over.right || over.bottom || over.left ? `inset(${over.top}px ${over.right}px ${over.bottom}px ${over.left}px)` : "none";
118
121
  directionRef.current = next;
@@ -187,8 +190,34 @@ var useClickOutside = (refs, handler, enabled = true) => {
187
190
  };
188
191
  var useClickOutside_default = useClickOutside;
189
192
 
190
- // src/tokens/hooks/useOverlayKeyboard.ts
193
+ // src/tokens/hooks/useOverlayHost.ts
191
194
  import React3 from "react";
195
+ var useOverlayHost = (triggerRef, enabled) => {
196
+ const [host, setHost] = React3.useState(null);
197
+ React3.useLayoutEffect(() => {
198
+ if (!enabled || !triggerRef.current) {
199
+ setHost(null);
200
+ return;
201
+ }
202
+ const el = document.createElement("div");
203
+ el.dataset.xplatOverlayHost = "";
204
+ el.style.position = "relative";
205
+ el.style.width = "0";
206
+ el.style.height = "0";
207
+ const parent = findScrollParent(triggerRef.current) ?? document.body;
208
+ parent.appendChild(el);
209
+ setHost(el);
210
+ return () => {
211
+ el.remove();
212
+ setHost(null);
213
+ };
214
+ }, [enabled, triggerRef]);
215
+ return host;
216
+ };
217
+ var useOverlayHost_default = useOverlayHost;
218
+
219
+ // src/tokens/hooks/useOverlayKeyboard.ts
220
+ import React4 from "react";
192
221
  var FOCUSABLE = [
193
222
  "a[href]",
194
223
  "button:not([disabled])",
@@ -198,7 +227,7 @@ var FOCUSABLE = [
198
227
  "[tabindex]:not([tabindex='-1'])"
199
228
  ].join(",");
200
229
  var useEscapeKey = (enabled, onEscape) => {
201
- React3.useEffect(() => {
230
+ React4.useEffect(() => {
202
231
  if (!enabled) return;
203
232
  const onKey = (e) => {
204
233
  if (e.key !== "Escape") return;
@@ -211,9 +240,9 @@ var useEscapeKey = (enabled, onEscape) => {
211
240
  }, [enabled, onEscape]);
212
241
  };
213
242
  var useCloseWhenFocusHidden = (enabled, triggerRef, popRef, onClose) => {
214
- const onCloseRef = React3.useRef(onClose);
243
+ const onCloseRef = React4.useRef(onClose);
215
244
  onCloseRef.current = onClose;
216
- React3.useEffect(() => {
245
+ React4.useEffect(() => {
217
246
  const trigger = triggerRef.current;
218
247
  if (!enabled || !trigger) return;
219
248
  const observer = new IntersectionObserver(
@@ -251,11 +280,12 @@ var clsx_default = clsx;
251
280
  import { jsx, jsxs } from "react/jsx-runtime";
252
281
  var Dropdown = (props) => {
253
282
  const { items, children } = props;
254
- const [isOpen, setIsOpen] = React4.useState(false);
255
- const [mounted, setMounted] = React4.useState(false);
256
- const [visible, setVisible] = React4.useState(false);
257
- const triggerRef = React4.useRef(null);
258
- const menuRef = React4.useRef(null);
283
+ const [isOpen, setIsOpen] = React5.useState(false);
284
+ const [mounted, setMounted] = React5.useState(false);
285
+ const [visible, setVisible] = React5.useState(false);
286
+ const triggerRef = React5.useRef(null);
287
+ const menuRef = React5.useRef(null);
288
+ const host = useOverlayHost_default(triggerRef, mounted);
259
289
  useAutoPosition_default(triggerRef, menuRef, mounted);
260
290
  useClickOutside_default([triggerRef, menuRef], () => setIsOpen(false), isOpen);
261
291
  useCloseWhenFocusHidden(isOpen, triggerRef, menuRef, () => setIsOpen(false));
@@ -263,7 +293,7 @@ var Dropdown = (props) => {
263
293
  setIsOpen(false);
264
294
  triggerRef.current?.focus({ preventScroll: true });
265
295
  });
266
- React4.useEffect(() => {
296
+ React5.useEffect(() => {
267
297
  if (isOpen) {
268
298
  setMounted(true);
269
299
  const t2 = setTimeout(() => setVisible(true), 1);
@@ -288,7 +318,7 @@ var Dropdown = (props) => {
288
318
  children
289
319
  }
290
320
  ),
291
- mounted && /* @__PURE__ */ jsx(Portal_default, { children: /* @__PURE__ */ jsx(
321
+ mounted && /* @__PURE__ */ jsx(Portal_default, { container: host, children: /* @__PURE__ */ jsx(
292
322
  "div",
293
323
  {
294
324
  ref: menuRef,
@@ -35,13 +35,13 @@ __export(PopOver_exports, {
35
35
  module.exports = __toCommonJS(PopOver_exports);
36
36
 
37
37
  // src/components/PopOver/PopOver.tsx
38
- var import_react4 = __toESM(require("react"), 1);
38
+ var import_react5 = __toESM(require("react"), 1);
39
39
 
40
40
  // src/tokens/hooks/Portal.tsx
41
41
  var import_react_dom = __toESM(require("react-dom"), 1);
42
- var Portal = ({ children }) => {
42
+ var Portal = ({ children, container }) => {
43
43
  if (typeof document === "undefined") return null;
44
- return import_react_dom.default.createPortal(children, document.body);
44
+ return import_react_dom.default.createPortal(children, container ?? document.body);
45
45
  };
46
46
  Portal.displayName = "Portal";
47
47
  var Portal_default = Portal;
@@ -50,8 +50,10 @@ var Portal_default = Portal;
50
50
  var import_react = __toESM(require("react"), 1);
51
51
  var findScrollParent = (el) => {
52
52
  for (let p = el.parentElement; p; p = p.parentElement) {
53
- const { overflowY, overflowX } = getComputedStyle(p);
54
- if (/(auto|scroll)/.test(overflowY) || /(auto|scroll)/.test(overflowX)) return p;
53
+ if (p.dataset.xplatOverlayEscape !== void 0) continue;
54
+ const { overflowY } = getComputedStyle(p);
55
+ if (!/(auto|scroll)/.test(overflowY)) continue;
56
+ if (p.scrollHeight > p.clientHeight) return p;
55
57
  }
56
58
  return null;
57
59
  };
@@ -147,8 +149,9 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
147
149
  );
148
150
  if (frozenMaxRef.current === void 0) frozenMaxRef.current = suggested;
149
151
  const maxHeight = frozenMaxRef.current;
150
- pop.style.top = `${top + window.scrollY}px`;
151
- pop.style.left = `${left + window.scrollX}px`;
152
+ const hostRect = (pop.offsetParent ?? pop.parentElement)?.getBoundingClientRect();
153
+ pop.style.top = `${top - (hostRect?.top ?? 0)}px`;
154
+ pop.style.left = `${left - (hostRect?.left ?? 0)}px`;
152
155
  pop.style.maxHeight = maxHeight === null ? "" : `${maxHeight}px`;
153
156
  pop.style.clipPath = over.top || over.right || over.bottom || over.left ? `inset(${over.top}px ${over.right}px ${over.bottom}px ${over.left}px)` : "none";
154
157
  directionRef.current = next;
@@ -223,8 +226,34 @@ var useClickOutside = (refs, handler, enabled = true) => {
223
226
  };
224
227
  var useClickOutside_default = useClickOutside;
225
228
 
226
- // src/tokens/hooks/useOverlayKeyboard.ts
229
+ // src/tokens/hooks/useOverlayHost.ts
227
230
  var import_react3 = __toESM(require("react"), 1);
231
+ var useOverlayHost = (triggerRef, enabled) => {
232
+ const [host, setHost] = import_react3.default.useState(null);
233
+ import_react3.default.useLayoutEffect(() => {
234
+ if (!enabled || !triggerRef.current) {
235
+ setHost(null);
236
+ return;
237
+ }
238
+ const el = document.createElement("div");
239
+ el.dataset.xplatOverlayHost = "";
240
+ el.style.position = "relative";
241
+ el.style.width = "0";
242
+ el.style.height = "0";
243
+ const parent = findScrollParent(triggerRef.current) ?? document.body;
244
+ parent.appendChild(el);
245
+ setHost(el);
246
+ return () => {
247
+ el.remove();
248
+ setHost(null);
249
+ };
250
+ }, [enabled, triggerRef]);
251
+ return host;
252
+ };
253
+ var useOverlayHost_default = useOverlayHost;
254
+
255
+ // src/tokens/hooks/useOverlayKeyboard.ts
256
+ var import_react4 = __toESM(require("react"), 1);
228
257
  var FOCUSABLE = [
229
258
  "a[href]",
230
259
  "button:not([disabled])",
@@ -234,7 +263,7 @@ var FOCUSABLE = [
234
263
  "[tabindex]:not([tabindex='-1'])"
235
264
  ].join(",");
236
265
  var useEscapeKey = (enabled, onEscape) => {
237
- import_react3.default.useEffect(() => {
266
+ import_react4.default.useEffect(() => {
238
267
  if (!enabled) return;
239
268
  const onKey = (e) => {
240
269
  if (e.key !== "Escape") return;
@@ -247,9 +276,9 @@ var useEscapeKey = (enabled, onEscape) => {
247
276
  }, [enabled, onEscape]);
248
277
  };
249
278
  var useCloseWhenFocusHidden = (enabled, triggerRef, popRef, onClose) => {
250
- const onCloseRef = import_react3.default.useRef(onClose);
279
+ const onCloseRef = import_react4.default.useRef(onClose);
251
280
  onCloseRef.current = onClose;
252
- import_react3.default.useEffect(() => {
281
+ import_react4.default.useEffect(() => {
253
282
  const trigger = triggerRef.current;
254
283
  if (!enabled || !trigger) return;
255
284
  const observer = new IntersectionObserver(
@@ -287,18 +316,19 @@ var clsx_default = clsx;
287
316
  var import_jsx_runtime = require("react/jsx-runtime");
288
317
  var PopOver = (props) => {
289
318
  const { children, isOpen, onClose, PopOverEl } = props;
290
- const popRef = import_react4.default.useRef(null);
291
- const triggerRef = import_react4.default.useRef(null);
292
- const [localOpen, setLocalOpen] = import_react4.default.useState(false);
293
- const [eventTrigger, setEventTrigger] = import_react4.default.useState(false);
319
+ const popRef = import_react5.default.useRef(null);
320
+ const triggerRef = import_react5.default.useRef(null);
321
+ const [localOpen, setLocalOpen] = import_react5.default.useState(false);
322
+ const [eventTrigger, setEventTrigger] = import_react5.default.useState(false);
294
323
  useClickOutside_default([popRef, triggerRef], onClose, isOpen);
295
324
  useCloseWhenFocusHidden(isOpen, triggerRef, popRef, onClose);
296
325
  useEscapeKey(isOpen, () => {
297
326
  onClose();
298
327
  triggerRef.current?.focus({ preventScroll: true });
299
328
  });
329
+ const host = useOverlayHost_default(triggerRef, localOpen);
300
330
  useAutoPosition_default(triggerRef, popRef, localOpen);
301
- import_react4.default.useEffect(() => {
331
+ import_react5.default.useEffect(() => {
302
332
  if (isOpen) {
303
333
  setLocalOpen(isOpen);
304
334
  setTimeout(() => {
@@ -321,7 +351,7 @@ var PopOver = (props) => {
321
351
  },
322
352
  children: [
323
353
  children,
324
- localOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Portal_default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
354
+ localOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Portal_default, { container: host, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
325
355
  "div",
326
356
  {
327
357
  className: clsx_default(
@@ -1,11 +1,11 @@
1
1
  // src/components/PopOver/PopOver.tsx
2
- import React4 from "react";
2
+ import React5 from "react";
3
3
 
4
4
  // src/tokens/hooks/Portal.tsx
5
5
  import ReactDOM from "react-dom";
6
- var Portal = ({ children }) => {
6
+ var Portal = ({ children, container }) => {
7
7
  if (typeof document === "undefined") return null;
8
- return ReactDOM.createPortal(children, document.body);
8
+ return ReactDOM.createPortal(children, container ?? document.body);
9
9
  };
10
10
  Portal.displayName = "Portal";
11
11
  var Portal_default = Portal;
@@ -14,8 +14,10 @@ var Portal_default = Portal;
14
14
  import React from "react";
15
15
  var findScrollParent = (el) => {
16
16
  for (let p = el.parentElement; p; p = p.parentElement) {
17
- const { overflowY, overflowX } = getComputedStyle(p);
18
- if (/(auto|scroll)/.test(overflowY) || /(auto|scroll)/.test(overflowX)) return p;
17
+ if (p.dataset.xplatOverlayEscape !== void 0) continue;
18
+ const { overflowY } = getComputedStyle(p);
19
+ if (!/(auto|scroll)/.test(overflowY)) continue;
20
+ if (p.scrollHeight > p.clientHeight) return p;
19
21
  }
20
22
  return null;
21
23
  };
@@ -111,8 +113,9 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
111
113
  );
112
114
  if (frozenMaxRef.current === void 0) frozenMaxRef.current = suggested;
113
115
  const maxHeight = frozenMaxRef.current;
114
- pop.style.top = `${top + window.scrollY}px`;
115
- pop.style.left = `${left + window.scrollX}px`;
116
+ const hostRect = (pop.offsetParent ?? pop.parentElement)?.getBoundingClientRect();
117
+ pop.style.top = `${top - (hostRect?.top ?? 0)}px`;
118
+ pop.style.left = `${left - (hostRect?.left ?? 0)}px`;
116
119
  pop.style.maxHeight = maxHeight === null ? "" : `${maxHeight}px`;
117
120
  pop.style.clipPath = over.top || over.right || over.bottom || over.left ? `inset(${over.top}px ${over.right}px ${over.bottom}px ${over.left}px)` : "none";
118
121
  directionRef.current = next;
@@ -187,8 +190,34 @@ var useClickOutside = (refs, handler, enabled = true) => {
187
190
  };
188
191
  var useClickOutside_default = useClickOutside;
189
192
 
190
- // src/tokens/hooks/useOverlayKeyboard.ts
193
+ // src/tokens/hooks/useOverlayHost.ts
191
194
  import React3 from "react";
195
+ var useOverlayHost = (triggerRef, enabled) => {
196
+ const [host, setHost] = React3.useState(null);
197
+ React3.useLayoutEffect(() => {
198
+ if (!enabled || !triggerRef.current) {
199
+ setHost(null);
200
+ return;
201
+ }
202
+ const el = document.createElement("div");
203
+ el.dataset.xplatOverlayHost = "";
204
+ el.style.position = "relative";
205
+ el.style.width = "0";
206
+ el.style.height = "0";
207
+ const parent = findScrollParent(triggerRef.current) ?? document.body;
208
+ parent.appendChild(el);
209
+ setHost(el);
210
+ return () => {
211
+ el.remove();
212
+ setHost(null);
213
+ };
214
+ }, [enabled, triggerRef]);
215
+ return host;
216
+ };
217
+ var useOverlayHost_default = useOverlayHost;
218
+
219
+ // src/tokens/hooks/useOverlayKeyboard.ts
220
+ import React4 from "react";
192
221
  var FOCUSABLE = [
193
222
  "a[href]",
194
223
  "button:not([disabled])",
@@ -198,7 +227,7 @@ var FOCUSABLE = [
198
227
  "[tabindex]:not([tabindex='-1'])"
199
228
  ].join(",");
200
229
  var useEscapeKey = (enabled, onEscape) => {
201
- React3.useEffect(() => {
230
+ React4.useEffect(() => {
202
231
  if (!enabled) return;
203
232
  const onKey = (e) => {
204
233
  if (e.key !== "Escape") return;
@@ -211,9 +240,9 @@ var useEscapeKey = (enabled, onEscape) => {
211
240
  }, [enabled, onEscape]);
212
241
  };
213
242
  var useCloseWhenFocusHidden = (enabled, triggerRef, popRef, onClose) => {
214
- const onCloseRef = React3.useRef(onClose);
243
+ const onCloseRef = React4.useRef(onClose);
215
244
  onCloseRef.current = onClose;
216
- React3.useEffect(() => {
245
+ React4.useEffect(() => {
217
246
  const trigger = triggerRef.current;
218
247
  if (!enabled || !trigger) return;
219
248
  const observer = new IntersectionObserver(
@@ -251,18 +280,19 @@ var clsx_default = clsx;
251
280
  import { jsx, jsxs } from "react/jsx-runtime";
252
281
  var PopOver = (props) => {
253
282
  const { children, isOpen, onClose, PopOverEl } = props;
254
- const popRef = React4.useRef(null);
255
- const triggerRef = React4.useRef(null);
256
- const [localOpen, setLocalOpen] = React4.useState(false);
257
- const [eventTrigger, setEventTrigger] = React4.useState(false);
283
+ const popRef = React5.useRef(null);
284
+ const triggerRef = React5.useRef(null);
285
+ const [localOpen, setLocalOpen] = React5.useState(false);
286
+ const [eventTrigger, setEventTrigger] = React5.useState(false);
258
287
  useClickOutside_default([popRef, triggerRef], onClose, isOpen);
259
288
  useCloseWhenFocusHidden(isOpen, triggerRef, popRef, onClose);
260
289
  useEscapeKey(isOpen, () => {
261
290
  onClose();
262
291
  triggerRef.current?.focus({ preventScroll: true });
263
292
  });
293
+ const host = useOverlayHost_default(triggerRef, localOpen);
264
294
  useAutoPosition_default(triggerRef, popRef, localOpen);
265
- React4.useEffect(() => {
295
+ React5.useEffect(() => {
266
296
  if (isOpen) {
267
297
  setLocalOpen(isOpen);
268
298
  setTimeout(() => {
@@ -285,7 +315,7 @@ var PopOver = (props) => {
285
315
  },
286
316
  children: [
287
317
  children,
288
- localOpen && /* @__PURE__ */ jsx(Portal_default, { children: /* @__PURE__ */ jsx(
318
+ localOpen && /* @__PURE__ */ jsx(Portal_default, { container: host, children: /* @__PURE__ */ jsx(
289
319
  "div",
290
320
  {
291
321
  className: clsx_default(