@domicile-desktop/component-library 0.0.0-alpha-c9c67f4f5860 → 0.0.0-alpha-e63627fa3d07
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/package.json +3 -3
- package/src/Popover/Popover.tsx +15 -3
package/package.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"dependencies": {
|
|
3
3
|
"@base-ui/react": "^1.8.0",
|
|
4
4
|
"@cprussin/option-result": "^2.0.1",
|
|
5
|
-
"@domicile-desktop/sdk": "0.0.0-alpha-
|
|
6
|
-
"@domicile-desktop/system-apps": "0.0.0-alpha-
|
|
5
|
+
"@domicile-desktop/sdk": "0.0.0-alpha-e63627fa3d07",
|
|
6
|
+
"@domicile-desktop/system-apps": "0.0.0-alpha-e63627fa3d07",
|
|
7
7
|
"@phosphor-icons/react": "^2.1.10"
|
|
8
8
|
},
|
|
9
9
|
"description": "React components and the Panda CSS design system that Domicile's shells are built from.",
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"test:unit": "bun test"
|
|
104
104
|
},
|
|
105
105
|
"type": "module",
|
|
106
|
-
"version": "0.0.0-alpha-
|
|
106
|
+
"version": "0.0.0-alpha-e63627fa3d07"
|
|
107
107
|
}
|
package/src/Popover/Popover.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Popover as BasePopover } from "@base-ui/react/popover";
|
|
2
|
-
import type { ReactElement, ReactNode, RefObject } from "react";
|
|
3
|
-
import { useEffect, useRef } from "react";
|
|
2
|
+
import type { ReactElement, ReactNode, RefCallback, RefObject } from "react";
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { css, cva } from "../../styled-system/css";
|
|
5
5
|
import { flex } from "../../styled-system/patterns";
|
|
6
6
|
import { useStableRef } from "../_control/useStableRef";
|
|
@@ -49,6 +49,9 @@ type Props = ExtendProps<
|
|
|
49
49
|
* A non-modal panel anchored to its trigger, for detail the trigger has no
|
|
50
50
|
* room for. Use `ModalDialog` when the user must respond first.
|
|
51
51
|
*
|
|
52
|
+
* Stays on its trigger's `<Screen>` region, so on a desktop of several
|
|
53
|
+
* monitors it never spans two.
|
|
54
|
+
*
|
|
52
55
|
* Closes on an outside press, Escape, or focus leaving it. The focus check
|
|
53
56
|
* catches presses inside out-of-process frames, which the document can't
|
|
54
57
|
* see. Portaled content such as a `Select` list counts as inside.
|
|
@@ -69,16 +72,25 @@ const PopoverComponent = ({
|
|
|
69
72
|
const actions = actionsRef ?? ownActions;
|
|
70
73
|
const [popupRef, setPopupRef] = useStableRef<HTMLDivElement>();
|
|
71
74
|
const [triggerRef, setTriggerRef] = useStableRef<HTMLElement>();
|
|
75
|
+
const [screen, setScreen] = useState<Element | undefined>(undefined);
|
|
76
|
+
const attachTrigger = useCallback<RefCallback<HTMLElement>>(
|
|
77
|
+
(element) => {
|
|
78
|
+
setScreen(element?.closest("[data-screen]") ?? undefined);
|
|
79
|
+
return setTriggerRef(element);
|
|
80
|
+
},
|
|
81
|
+
[setTriggerRef],
|
|
82
|
+
);
|
|
72
83
|
const within = useRef<FocusEvent | undefined>(undefined);
|
|
73
84
|
return (
|
|
74
85
|
<BasePopover.Root actionsRef={actions} {...rootProps}>
|
|
75
86
|
{trigger !== undefined && (
|
|
76
|
-
<BasePopover.Trigger ref={
|
|
87
|
+
<BasePopover.Trigger ref={attachTrigger} render={trigger} />
|
|
77
88
|
)}
|
|
78
89
|
<BasePopover.Portal>
|
|
79
90
|
<BasePopover.Positioner
|
|
80
91
|
align={align}
|
|
81
92
|
className={positionerStyles}
|
|
93
|
+
collisionBoundary={screen}
|
|
82
94
|
onFocus={(event) => {
|
|
83
95
|
within.current = event.nativeEvent;
|
|
84
96
|
}}
|