braid-design-system 33.12.2 → 33.12.4
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/CHANGELOG.md +28 -6
- package/dist/index.d.mts +22 -6
- package/dist/index.d.ts +22 -6
- package/dist/lib/components/TooltipRenderer/TooltipRenderer.cjs +64 -73
- package/dist/lib/components/TooltipRenderer/TooltipRenderer.css.cjs +9 -7
- package/dist/lib/components/TooltipRenderer/TooltipRenderer.css.mjs +9 -7
- package/dist/lib/components/TooltipRenderer/TooltipRenderer.mjs +65 -74
- package/dist/lib/components/private/Popover/Popover.cjs +90 -125
- package/dist/lib/components/private/Popover/Popover.css.cjs +0 -21
- package/dist/lib/components/private/Popover/Popover.css.mjs +2 -23
- package/dist/lib/components/private/Popover/Popover.mjs +92 -127
- package/dist/lib/playroom/components.cjs +6 -0
- package/dist/lib/playroom/components.mjs +8 -1
- package/dist/playroom/components.cjs +4 -5
- package/dist/playroom/components.d.mts +1 -1
- package/dist/playroom/components.d.ts +1 -1
- package/dist/playroom/components.mjs +1 -2
- package/package.json +4 -3
|
@@ -6,14 +6,13 @@ import { useFallbackId } from "../../hooks/useFallbackId.mjs";
|
|
|
6
6
|
import { useIsomorphicLayoutEffect } from "../../hooks/useIsomorphicLayoutEffect.mjs";
|
|
7
7
|
import { Box } from "../Box/Box.mjs";
|
|
8
8
|
import { Popover } from "../private/Popover/Popover.mjs";
|
|
9
|
-
import { animationTimeout } from "../private/animationTimeout.mjs";
|
|
10
9
|
import { DefaultTextPropsProvider } from "../private/defaultTextProps.mjs";
|
|
11
10
|
import { useSpace } from "../useSpace/useSpace.mjs";
|
|
12
11
|
import { useThemeName } from "../useThemeName/useThemeName.mjs";
|
|
13
|
-
import { maxWidth, translateZ0, overflowWrap, arrow,
|
|
14
|
-
const edgeOffset = "xxsmall";
|
|
12
|
+
import { maxWidth, translateZ0, overflowWrap, arrow, arrowY, arrowX, constants } from "./TooltipRenderer.css.mjs";
|
|
15
13
|
const offsetSpace = "small";
|
|
16
14
|
const StaticTooltipContext = createContext(false);
|
|
15
|
+
const clamp = (min, value, max) => Math.max(min, Math.min(value, max));
|
|
17
16
|
const TooltipTextDefaultsProvider = ({
|
|
18
17
|
children
|
|
19
18
|
}) => {
|
|
@@ -28,35 +27,59 @@ const TooltipTextDefaultsProvider = ({
|
|
|
28
27
|
);
|
|
29
28
|
};
|
|
30
29
|
const TooltipContent = ({
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
placement,
|
|
31
|
+
arrowPosition,
|
|
32
|
+
arrowRef,
|
|
33
33
|
children
|
|
34
|
-
}) =>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
34
|
+
}) => {
|
|
35
|
+
const arrowX$1 = arrowPosition?.x;
|
|
36
|
+
const arrowY$1 = arrowPosition?.y;
|
|
37
|
+
const { space, grid } = useSpace();
|
|
38
|
+
const edgeOffsetInPx = grid * space.xsmall;
|
|
39
|
+
const arrowWidthOffset = parseFloat(constants.arrowSize) * 2;
|
|
40
|
+
const [tooltipWidth, setTooltipWidth] = useState(0);
|
|
41
|
+
const tooltipContainerRef = useRef(null);
|
|
42
|
+
useIsomorphicLayoutEffect(() => {
|
|
43
|
+
if (!tooltipContainerRef.current) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const { width } = tooltipContainerRef.current.getBoundingClientRect();
|
|
47
|
+
setTooltipWidth(width);
|
|
48
|
+
}, [children]);
|
|
49
|
+
const clampedArrowX = arrowX$1 !== void 0 && tooltipWidth > 0 ? clamp(
|
|
50
|
+
edgeOffsetInPx,
|
|
51
|
+
arrowX$1,
|
|
52
|
+
tooltipWidth - edgeOffsetInPx - arrowWidthOffset
|
|
53
|
+
) : arrowX$1;
|
|
54
|
+
return /* @__PURE__ */ jsx(
|
|
55
|
+
Box,
|
|
56
|
+
{
|
|
57
|
+
ref: tooltipContainerRef,
|
|
58
|
+
textAlign: "left",
|
|
59
|
+
boxShadow: "large",
|
|
60
|
+
background: "neutral",
|
|
61
|
+
borderRadius: "large",
|
|
62
|
+
padding: "small",
|
|
63
|
+
className: [maxWidth, translateZ0],
|
|
64
|
+
children: /* @__PURE__ */ jsxs(TooltipTextDefaultsProvider, { children: [
|
|
65
|
+
/* @__PURE__ */ jsx(Box, { className: overflowWrap, zIndex: 1, position: "relative", children }),
|
|
66
|
+
/* @__PURE__ */ jsx(
|
|
67
|
+
Box,
|
|
68
|
+
{
|
|
69
|
+
ref: arrowRef,
|
|
70
|
+
position: "fixed",
|
|
71
|
+
background: "neutral",
|
|
72
|
+
className: arrow[placement ?? "top"],
|
|
73
|
+
style: assignInlineVars({
|
|
74
|
+
[arrowX]: clampedArrowX !== void 0 ? `${clampedArrowX}px` : void 0,
|
|
75
|
+
[arrowY]: arrowY$1 !== void 0 ? `${arrowY$1}px` : void 0
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
] })
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
};
|
|
60
83
|
const TooltipRenderer = ({
|
|
61
84
|
id,
|
|
62
85
|
tooltip,
|
|
@@ -64,16 +87,11 @@ const TooltipRenderer = ({
|
|
|
64
87
|
children
|
|
65
88
|
}) => {
|
|
66
89
|
const resolvedId = useFallbackId(id);
|
|
67
|
-
const tooltipRef = useRef(null);
|
|
68
90
|
const triggerRef = useRef(null);
|
|
91
|
+
const arrowRef = useRef(null);
|
|
69
92
|
const [open, setOpen] = useState(false);
|
|
70
|
-
const [
|
|
71
|
-
|
|
72
|
-
);
|
|
73
|
-
const [tooltipPosition, setTooltipPosition] = useState(
|
|
74
|
-
void 0
|
|
75
|
-
);
|
|
76
|
-
const { grid, space } = useSpace();
|
|
93
|
+
const [resolvedPlacement, setResolvedPlacement] = useState(placement);
|
|
94
|
+
const [arrowPosition, setArrowPosition] = useState();
|
|
77
95
|
const isStatic = useContext(StaticTooltipContext);
|
|
78
96
|
const isMobileDevice = useRef(isMobile()).current;
|
|
79
97
|
const onScreen = useRef(null);
|
|
@@ -133,38 +151,6 @@ const TooltipRenderer = ({
|
|
|
133
151
|
}
|
|
134
152
|
};
|
|
135
153
|
}, [open, isMobileDevice]);
|
|
136
|
-
const handleTooltipPosition = () => {
|
|
137
|
-
const setPositions = () => {
|
|
138
|
-
if (tooltipRef.current) {
|
|
139
|
-
setTooltipPosition(tooltipRef.current.getBoundingClientRect());
|
|
140
|
-
}
|
|
141
|
-
if (triggerRef.current) {
|
|
142
|
-
setTriggerPosition(triggerRef.current.getBoundingClientRect());
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
setTimeout(() => {
|
|
146
|
-
const frameId = requestAnimationFrame(setPositions);
|
|
147
|
-
return () => cancelAnimationFrame(frameId);
|
|
148
|
-
}, animationTimeout / 2);
|
|
149
|
-
};
|
|
150
|
-
useIsomorphicLayoutEffect(() => {
|
|
151
|
-
if (!showTooltip) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
handleTooltipPosition();
|
|
155
|
-
window.addEventListener("resize", handleTooltipPosition);
|
|
156
|
-
return () => {
|
|
157
|
-
window.removeEventListener("resize", handleTooltipPosition);
|
|
158
|
-
};
|
|
159
|
-
}, [showTooltip]);
|
|
160
|
-
let inferredPlacement = placement;
|
|
161
|
-
let arrowLeftOffset = 0;
|
|
162
|
-
if (tooltipPosition && triggerPosition) {
|
|
163
|
-
inferredPlacement = tooltipPosition.top > triggerPosition.top ? "bottom" : "top";
|
|
164
|
-
const edgeOffsetInPx = space[edgeOffset] * grid;
|
|
165
|
-
const tooltipLeftToTriggerLeft = triggerPosition.left - tooltipPosition.left - edgeOffsetInPx;
|
|
166
|
-
arrowLeftOffset = tooltipLeftToTriggerLeft + triggerPosition.width / 2;
|
|
167
|
-
}
|
|
168
154
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
169
155
|
children({
|
|
170
156
|
triggerProps: {
|
|
@@ -180,7 +166,6 @@ const TooltipRenderer = ({
|
|
|
180
166
|
{
|
|
181
167
|
id: resolvedId,
|
|
182
168
|
role: "tooltip",
|
|
183
|
-
ref: tooltipRef,
|
|
184
169
|
offsetSpace,
|
|
185
170
|
align: "center",
|
|
186
171
|
placement,
|
|
@@ -189,12 +174,18 @@ const TooltipRenderer = ({
|
|
|
189
174
|
modal: false,
|
|
190
175
|
open: showTooltip,
|
|
191
176
|
onClose: !isStatic ? () => setOpen(false) : void 0,
|
|
177
|
+
onPlacementChange: ({ placement: newPlacement, arrow: arrow2 }) => {
|
|
178
|
+
setResolvedPlacement(newPlacement);
|
|
179
|
+
setArrowPosition(arrow2);
|
|
180
|
+
},
|
|
192
181
|
triggerRef,
|
|
182
|
+
arrowRef,
|
|
193
183
|
children: /* @__PURE__ */ jsx(
|
|
194
184
|
TooltipContent,
|
|
195
185
|
{
|
|
196
|
-
|
|
197
|
-
|
|
186
|
+
placement: resolvedPlacement,
|
|
187
|
+
arrowPosition,
|
|
188
|
+
arrowRef,
|
|
198
189
|
children: tooltip
|
|
199
190
|
}
|
|
200
191
|
)
|
|
@@ -1,37 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
-
const
|
|
3
|
+
const reactDom = require("@floating-ui/react-dom");
|
|
4
4
|
const dedent = require("dedent");
|
|
5
5
|
const react = require("react");
|
|
6
|
-
const lib_hooks_useIsomorphicLayoutEffect_cjs = require("../../../hooks/useIsomorphicLayoutEffect.cjs");
|
|
7
6
|
const lib_components_Box_Box_cjs = require("../../Box/Box.cjs");
|
|
8
7
|
const lib_components_BraidPortal_BraidPortal_cjs = require("../../BraidPortal/BraidPortal.cjs");
|
|
8
|
+
const lib_components_useResponsiveValue_useResponsiveValue_cjs = require("../../useResponsiveValue/useResponsiveValue.cjs");
|
|
9
9
|
const lib_components_useSpace_useSpace_cjs = require("../../useSpace/useSpace.cjs");
|
|
10
10
|
const lib_components_private_animationTimeout_cjs = require("../animationTimeout.cjs");
|
|
11
11
|
const lib_components_private_Popover_Popover_css_cjs = require("./Popover.css.cjs");
|
|
12
|
+
const lib_css_atoms_sprinkles_css_cjs = require("../../../css/atoms/sprinkles.css.cjs");
|
|
12
13
|
const _interopDefaultCompat = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
13
14
|
const dedent__default = /* @__PURE__ */ _interopDefaultCompat(dedent);
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const positionMap = {
|
|
16
|
+
top: {
|
|
17
|
+
left: "top-start",
|
|
18
|
+
center: "top",
|
|
19
|
+
right: "top-end"
|
|
20
|
+
},
|
|
21
|
+
bottom: {
|
|
22
|
+
left: "bottom-start",
|
|
23
|
+
center: "bottom",
|
|
24
|
+
right: "bottom-end"
|
|
18
25
|
}
|
|
19
|
-
const rect = element.getBoundingClientRect();
|
|
20
|
-
const { top, bottom, left, right, width } = rect;
|
|
21
|
-
const { scrollX: scrollX2, scrollY, innerWidth } = window;
|
|
22
|
-
return {
|
|
23
|
-
// For `top`, we subtract this from the dynamic viewport height in `Popover.css.ts`
|
|
24
|
-
// which can't be accessed from Javascript.
|
|
25
|
-
top: top + scrollY,
|
|
26
|
-
bottom: bottom + scrollY,
|
|
27
|
-
left: left + scrollX2,
|
|
28
|
-
right: innerWidth - right - scrollX2,
|
|
29
|
-
width
|
|
30
|
-
};
|
|
31
26
|
};
|
|
32
|
-
function
|
|
33
|
-
return
|
|
27
|
+
function getFloatingUiPosition(placement, align) {
|
|
28
|
+
return positionMap[placement][align];
|
|
34
29
|
}
|
|
30
|
+
const zIndex = "notification";
|
|
31
|
+
const PopoverContext = react.createContext(null);
|
|
35
32
|
const PopoverContent = react.forwardRef(
|
|
36
33
|
({
|
|
37
34
|
id,
|
|
@@ -45,18 +42,59 @@ const PopoverContent = react.forwardRef(
|
|
|
45
42
|
modal = true,
|
|
46
43
|
open,
|
|
47
44
|
onClose,
|
|
45
|
+
onPlacementChange,
|
|
48
46
|
triggerRef,
|
|
49
47
|
enterFocusRef,
|
|
48
|
+
arrowRef,
|
|
50
49
|
children
|
|
51
50
|
}, forwardedRef) => {
|
|
52
|
-
const [triggerPosition, setTriggerPosition] = react.useState(void 0);
|
|
53
51
|
const ref = react.useRef(null);
|
|
54
52
|
react.useImperativeHandle(forwardedRef, () => ref.current);
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const
|
|
53
|
+
const normalized = lib_css_atoms_sprinkles_css_cjs.normalizeResponsiveValue(offsetSpace);
|
|
54
|
+
const mobile = normalized.mobile ?? "none";
|
|
55
|
+
const tablet = normalized.tablet ?? mobile;
|
|
56
|
+
const desktop = normalized.desktop ?? tablet;
|
|
57
|
+
const wide = normalized.wide ?? desktop;
|
|
58
|
+
const resolvedOffsetSpace = lib_components_useResponsiveValue_useResponsiveValue_cjs.useResponsiveValue()({ mobile, tablet, desktop, wide }) ?? mobile;
|
|
59
|
+
const spaceScale = lib_components_useSpace_useSpace_cjs.useSpace();
|
|
60
|
+
let offsetSpacePx = 0;
|
|
61
|
+
if (resolvedOffsetSpace !== "none") {
|
|
62
|
+
offsetSpacePx = spaceScale.space[resolvedOffsetSpace] * spaceScale.grid;
|
|
63
|
+
}
|
|
64
|
+
const floatingUiRequestedPosition = getFloatingUiPosition(placement, align);
|
|
65
|
+
const middleware = [
|
|
66
|
+
reactDom.offset(offsetSpacePx),
|
|
67
|
+
!lockPlacement && reactDom.flip(),
|
|
68
|
+
width === "full" ? reactDom.size({
|
|
69
|
+
apply({ rects, elements }) {
|
|
70
|
+
Object.assign(elements.floating.style, {
|
|
71
|
+
width: `${rects.reference.width}px`
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}) : reactDom.shift({
|
|
75
|
+
crossAxis: align === "center"
|
|
76
|
+
}),
|
|
77
|
+
arrowRef && reactDom.arrow({ element: arrowRef })
|
|
78
|
+
].filter(Boolean);
|
|
79
|
+
const {
|
|
80
|
+
refs,
|
|
81
|
+
floatingStyles,
|
|
82
|
+
middlewareData,
|
|
83
|
+
placement: floatingUiEvaluatedPosition,
|
|
84
|
+
isPositioned
|
|
85
|
+
} = reactDom.useFloating({
|
|
86
|
+
placement: floatingUiRequestedPosition,
|
|
87
|
+
middleware,
|
|
88
|
+
whileElementsMounted: reactDom.autoUpdate
|
|
89
|
+
});
|
|
90
|
+
react.useEffect(() => {
|
|
91
|
+
refs.setReference(triggerRef.current);
|
|
92
|
+
}, [triggerRef, refs]);
|
|
93
|
+
react.useEffect(() => {
|
|
94
|
+
if (ref.current) {
|
|
95
|
+
refs.setFloating(ref.current);
|
|
96
|
+
}
|
|
97
|
+
}, [refs]);
|
|
60
98
|
react.useEffect(() => {
|
|
61
99
|
const handleKeydown = (event) => {
|
|
62
100
|
if (event.key === "Escape" || event.key === "Tab") {
|
|
@@ -81,9 +119,6 @@ const PopoverContent = react.forwardRef(
|
|
|
81
119
|
window.removeEventListener("keydown", handleKeydown);
|
|
82
120
|
};
|
|
83
121
|
}, [onClose, triggerRef]);
|
|
84
|
-
react.useEffect(() => {
|
|
85
|
-
setTriggerPosition(getPosition(triggerRef.current));
|
|
86
|
-
}, [triggerRef]);
|
|
87
122
|
react.useEffect(() => {
|
|
88
123
|
setTimeout(() => {
|
|
89
124
|
if (!enterFocusRef) {
|
|
@@ -101,95 +136,24 @@ const PopoverContent = react.forwardRef(
|
|
|
101
136
|
}
|
|
102
137
|
}
|
|
103
138
|
}, lib_components_private_animationTimeout_cjs.animationTimeout);
|
|
104
|
-
}, [open, enterFocusRef
|
|
139
|
+
}, [open, enterFocusRef]);
|
|
140
|
+
const resolvedPlacement = floatingUiEvaluatedPosition?.startsWith("top") ? "top" : "bottom";
|
|
105
141
|
react.useEffect(() => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
resizeObserver.observe(document.body);
|
|
112
|
-
return () => {
|
|
113
|
-
window.removeEventListener("resize", handleResize);
|
|
114
|
-
resizeObserver.disconnect();
|
|
115
|
-
};
|
|
116
|
-
}, [triggerRef]);
|
|
117
|
-
const handlePlacement = () => {
|
|
118
|
-
const popoverBoundingRect = ref?.current?.getBoundingClientRect();
|
|
119
|
-
if (!popoverBoundingRect) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
const triggerBoundingRect = triggerRef.current?.getBoundingClientRect();
|
|
123
|
-
if (!triggerBoundingRect) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
const { height: popoverHeight } = popoverBoundingRect;
|
|
127
|
-
const heightRequired = popoverHeight + transitionThresholdInPx;
|
|
128
|
-
const fitsAbove = triggerBoundingRect.top >= heightRequired;
|
|
129
|
-
const fitsBelow = window.innerHeight - triggerBoundingRect.bottom >= heightRequired;
|
|
130
|
-
if (!fitsAbove && fitsBelow) {
|
|
131
|
-
setActualPlacement("bottom");
|
|
132
|
-
} else if (!fitsBelow && fitsAbove) {
|
|
133
|
-
setActualPlacement("top");
|
|
134
|
-
} else {
|
|
135
|
-
setActualPlacement(placement);
|
|
142
|
+
if (onPlacementChange) {
|
|
143
|
+
onPlacementChange({
|
|
144
|
+
placement: resolvedPlacement,
|
|
145
|
+
arrow: middlewareData.arrow
|
|
146
|
+
});
|
|
136
147
|
}
|
|
148
|
+
}, [resolvedPlacement, middlewareData.arrow, onPlacementChange]);
|
|
149
|
+
const combinedStyles = {
|
|
150
|
+
...floatingStyles,
|
|
151
|
+
...!isPositioned ? { opacity: 0, pointerEvents: "none" } : {}
|
|
137
152
|
};
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
const popoverBoundingRect = ref?.current?.getBoundingClientRect();
|
|
143
|
-
if (!popoverBoundingRect) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
const { width: popoverWidth } = popoverBoundingRect;
|
|
147
|
-
const triggerCenter = triggerPosition.width && triggerPosition.left + triggerPosition.width / 2;
|
|
148
|
-
const popoverLeft = align === "center" && triggerCenter ? triggerCenter - popoverWidth / 2 : triggerPosition.left;
|
|
149
|
-
const clampedPopoverLeft = clamp(
|
|
150
|
-
scrollX,
|
|
151
|
-
popoverLeft,
|
|
152
|
-
window.innerWidth + scrollX - popoverWidth
|
|
153
|
-
);
|
|
154
|
-
const triggerRightFromLeft = window.innerWidth - triggerPosition.right;
|
|
155
|
-
const clampedTriggerRightFromLeft = clamp(
|
|
156
|
-
scrollX + popoverWidth,
|
|
157
|
-
triggerRightFromLeft,
|
|
158
|
-
scrollX + window.innerWidth
|
|
159
|
-
);
|
|
160
|
-
if (alignmentAnchor === "right" && clampedTriggerRightFromLeft !== triggerPosition.right + horizontalOffset) {
|
|
161
|
-
setHorizontalOffset(
|
|
162
|
-
window.innerWidth - clampedTriggerRightFromLeft - triggerPosition.right
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
if (alignmentAnchor === "left" && clampedPopoverLeft !== triggerPosition.left + horizontalOffset) {
|
|
166
|
-
setHorizontalOffset(clampedPopoverLeft - triggerPosition.left);
|
|
167
|
-
}
|
|
168
|
-
return;
|
|
169
|
-
};
|
|
170
|
-
lib_hooks_useIsomorphicLayoutEffect_cjs.useIsomorphicLayoutEffect(() => {
|
|
171
|
-
if (!showPopover) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
if (width !== "full") {
|
|
175
|
-
handleHorizontalShift();
|
|
176
|
-
}
|
|
177
|
-
if (!lockPlacement) {
|
|
178
|
-
handlePlacement();
|
|
179
|
-
}
|
|
180
|
-
}, [showPopover]);
|
|
181
|
-
const triggerPositionVars = triggerPosition && {
|
|
182
|
-
// Vertical positioning
|
|
183
|
-
[lib_components_private_Popover_Popover_css_cjs.triggerVars[actualPlacement]]: `${triggerPosition[actualPlacement]}`,
|
|
184
|
-
// Horizontal positioning
|
|
185
|
-
[lib_components_private_Popover_Popover_css_cjs.triggerVars.left]: width === "full" || alignmentAnchor === "left" ? `${triggerPosition?.left}` : void 0,
|
|
186
|
-
[lib_components_private_Popover_Popover_css_cjs.triggerVars.right]: width === "full" || alignmentAnchor === "right" ? `${triggerPosition?.right}` : void 0,
|
|
187
|
-
// Horizontal scroll offset
|
|
188
|
-
[lib_components_private_Popover_Popover_css_cjs.horizontalOffset]: width !== "full" ? `${horizontalOffset}` : "0"
|
|
153
|
+
const popoverContextValue = {
|
|
154
|
+
arrow: middlewareData.arrow,
|
|
155
|
+
resolvedPlacement
|
|
189
156
|
};
|
|
190
|
-
if (!showPopover) {
|
|
191
|
-
return null;
|
|
192
|
-
}
|
|
193
157
|
return /* @__PURE__ */ jsxRuntime.jsxs(lib_components_BraidPortal_BraidPortal_cjs.BraidPortal, { children: [
|
|
194
158
|
modal && /* @__PURE__ */ jsxRuntime.jsx(
|
|
195
159
|
lib_components_Box_Box_cjs.Box,
|
|
@@ -217,17 +181,18 @@ const PopoverContent = react.forwardRef(
|
|
|
217
181
|
role: role || void 0,
|
|
218
182
|
tabIndex: -1,
|
|
219
183
|
zIndex,
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
184
|
+
style: combinedStyles,
|
|
185
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
186
|
+
lib_components_Box_Box_cjs.Box,
|
|
187
|
+
{
|
|
188
|
+
className: {
|
|
189
|
+
[lib_components_private_Popover_Popover_css_cjs.animation]: true,
|
|
190
|
+
[lib_components_private_Popover_Popover_css_cjs.invertPlacement]: resolvedPlacement === "bottom",
|
|
191
|
+
[lib_components_private_Popover_Popover_css_cjs.delayVisibility]: delayVisibility
|
|
192
|
+
},
|
|
193
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(PopoverContext.Provider, { value: popoverContextValue, children })
|
|
194
|
+
}
|
|
195
|
+
)
|
|
231
196
|
}
|
|
232
197
|
)
|
|
233
198
|
] });
|
|
@@ -9,23 +9,6 @@ const backdrop = css.style({
|
|
|
9
9
|
width: "100vw",
|
|
10
10
|
height: "100vh"
|
|
11
11
|
}, "backdrop");
|
|
12
|
-
const triggerVars = {
|
|
13
|
-
top: css.createVar("triggerVars_top"),
|
|
14
|
-
left: css.createVar("triggerVars_left"),
|
|
15
|
-
bottom: css.createVar("triggerVars_bottom"),
|
|
16
|
-
right: css.createVar("triggerVars_right")
|
|
17
|
-
};
|
|
18
|
-
const horizontalOffset = css.createVar("horizontalOffset");
|
|
19
|
-
const dynamicHeight = css.createVar("dynamicHeight");
|
|
20
|
-
const popoverPosition = css.style({
|
|
21
|
-
vars: {
|
|
22
|
-
[dynamicHeight]: "100svh"
|
|
23
|
-
},
|
|
24
|
-
top: cssUtils.calc(triggerVars.bottom).multiply("1px").toString(),
|
|
25
|
-
bottom: cssUtils.calc(css.fallbackVar(dynamicHeight, "100vh")).subtract(cssUtils.calc(triggerVars.top).multiply("1px")).toString(),
|
|
26
|
-
left: cssUtils.calc(triggerVars.left).add(horizontalOffset).multiply("1px").toString(),
|
|
27
|
-
right: cssUtils.calc(triggerVars.right).add(horizontalOffset).multiply("1px").toString()
|
|
28
|
-
}, "popoverPosition");
|
|
29
12
|
const placementModifier = css.createVar("placementModifier");
|
|
30
13
|
const invertPlacement = css.style({
|
|
31
14
|
vars: {
|
|
@@ -53,8 +36,4 @@ fileScope.endFileScope();
|
|
|
53
36
|
exports.animation = animation;
|
|
54
37
|
exports.backdrop = backdrop;
|
|
55
38
|
exports.delayVisibility = delayVisibility;
|
|
56
|
-
exports.horizontalOffset = horizontalOffset;
|
|
57
39
|
exports.invertPlacement = invertPlacement;
|
|
58
|
-
exports.popoverPosition = popoverPosition;
|
|
59
|
-
exports.transitionThreshold = transitionThreshold;
|
|
60
|
-
exports.triggerVars = triggerVars;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { setFileScope, endFileScope } from "@vanilla-extract/css/fileScope";
|
|
2
|
-
import {
|
|
2
|
+
import { style, keyframes, createVar, fallbackVar } from "@vanilla-extract/css";
|
|
3
3
|
import { calc } from "@vanilla-extract/css-utils";
|
|
4
4
|
import { animationTimeout } from "../animationTimeout.mjs";
|
|
5
5
|
import { vars } from "../../../themes/vars.css.mjs";
|
|
@@ -8,23 +8,6 @@ const backdrop = style({
|
|
|
8
8
|
width: "100vw",
|
|
9
9
|
height: "100vh"
|
|
10
10
|
}, "backdrop");
|
|
11
|
-
const triggerVars = {
|
|
12
|
-
top: createVar("triggerVars_top"),
|
|
13
|
-
left: createVar("triggerVars_left"),
|
|
14
|
-
bottom: createVar("triggerVars_bottom"),
|
|
15
|
-
right: createVar("triggerVars_right")
|
|
16
|
-
};
|
|
17
|
-
const horizontalOffset = createVar("horizontalOffset");
|
|
18
|
-
const dynamicHeight = createVar("dynamicHeight");
|
|
19
|
-
const popoverPosition = style({
|
|
20
|
-
vars: {
|
|
21
|
-
[dynamicHeight]: "100svh"
|
|
22
|
-
},
|
|
23
|
-
top: calc(triggerVars.bottom).multiply("1px").toString(),
|
|
24
|
-
bottom: calc(fallbackVar(dynamicHeight, "100vh")).subtract(calc(triggerVars.top).multiply("1px")).toString(),
|
|
25
|
-
left: calc(triggerVars.left).add(horizontalOffset).multiply("1px").toString(),
|
|
26
|
-
right: calc(triggerVars.right).add(horizontalOffset).multiply("1px").toString()
|
|
27
|
-
}, "popoverPosition");
|
|
28
11
|
const placementModifier = createVar("placementModifier");
|
|
29
12
|
const invertPlacement = style({
|
|
30
13
|
vars: {
|
|
@@ -53,9 +36,5 @@ export {
|
|
|
53
36
|
animation,
|
|
54
37
|
backdrop,
|
|
55
38
|
delayVisibility,
|
|
56
|
-
|
|
57
|
-
invertPlacement,
|
|
58
|
-
popoverPosition,
|
|
59
|
-
transitionThreshold,
|
|
60
|
-
triggerVars
|
|
39
|
+
invertPlacement
|
|
61
40
|
};
|