@sanity/ui 2.0.0-alpha.23 → 2.0.0-alpha.25
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/dist/index.esm.js +18 -22
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +18 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/primitives/tooltip/constants.ts +12 -12
- package/src/primitives/tooltip/tooltip.test.tsx +0 -20
- package/src/primitives/tooltip/tooltip.tsx +6 -6
- package/src/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupProvider.tsx +1 -9
package/dist/index.esm.js
CHANGED
|
@@ -7814,18 +7814,18 @@ function useDelayedState(initialState) {
|
|
|
7814
7814
|
const DEFAULT_TOOLTIP_DISTANCE = 4;
|
|
7815
7815
|
const DEFAULT_TOOLTIP_PADDING = 4;
|
|
7816
7816
|
const DEFAULT_FALLBACK_PLACEMENTS = {
|
|
7817
|
-
top: ["bottom", "left", "right"],
|
|
7818
|
-
"top-start": ["bottom-start", "left-start", "right-start"],
|
|
7819
|
-
"top-end": ["bottom-end", "left-end", "right-end"],
|
|
7820
|
-
bottom: ["top", "left", "right"],
|
|
7821
|
-
"bottom-start": ["top-start", "left-start", "right-start"],
|
|
7822
|
-
"bottom-end": ["top-end", "left-end", "right-end"],
|
|
7823
|
-
left: ["right", "top", "bottom"],
|
|
7824
|
-
"left-start": ["right-start", "top-start", "bottom-start"],
|
|
7825
|
-
"left-end": ["right-end", "top-end", "bottom-end"],
|
|
7826
|
-
right: ["left", "top", "bottom"],
|
|
7827
|
-
"right-start": ["left-start", "top-start", "bottom-start"],
|
|
7828
|
-
"right-end": ["left-end", "top-end", "bottom-end"]
|
|
7817
|
+
top: ["top-end", "top-start", "bottom", "left", "right"],
|
|
7818
|
+
"top-start": ["top", "top-end", "bottom-start", "left-start", "right-start"],
|
|
7819
|
+
"top-end": ["top", "top-start", "bottom-end", "left-end", "right-end"],
|
|
7820
|
+
bottom: ["bottom-end", "bottom-start", "top", "left", "right"],
|
|
7821
|
+
"bottom-start": ["bottom", "bottom-end", "top-start", "left-start", "right-start"],
|
|
7822
|
+
"bottom-end": ["bottom", "bottom-start", "top-end", "left-end", "right-end"],
|
|
7823
|
+
left: ["left-end", "left-start", "right", "top", "bottom"],
|
|
7824
|
+
"left-start": ["left", "left-end", "right-start", "top-start", "bottom-start"],
|
|
7825
|
+
"left-end": ["left", "left-start", "right-end", "top-end", "bottom-end"],
|
|
7826
|
+
right: ["right-end", "right-start", "left", "top", "bottom"],
|
|
7827
|
+
"right-start": ["right", "right-end", "left-start", "top-start", "bottom-start"],
|
|
7828
|
+
"right-end": ["right", "right-start", "left-end", "top-end", "bottom-end"]
|
|
7829
7829
|
};
|
|
7830
7830
|
var __freeze$f = Object.freeze;
|
|
7831
7831
|
var __defProp$f = Object.defineProperty;
|
|
@@ -7870,10 +7870,6 @@ function TooltipDelayGroupProvider(props) {
|
|
|
7870
7870
|
} = props;
|
|
7871
7871
|
const [isGroupActive, setIsGroupActive] = useDelayedState(false);
|
|
7872
7872
|
const [openTooltipId, setOpenTooltipId] = useDelayedState(null);
|
|
7873
|
-
const isInsideContext = useTooltipDelayGroup();
|
|
7874
|
-
if (isInsideContext) {
|
|
7875
|
-
throw new Error("TooltipDelayGroupProvider cannot be nested inside another TooltipDelayGroupProvider");
|
|
7876
|
-
}
|
|
7877
7873
|
const openDelay = typeof delay === "number" ? delay : (delay == null ? void 0 : delay.open) || 0;
|
|
7878
7874
|
const closeDelay = typeof delay === "number" ? delay : (delay == null ? void 0 : delay.close) || 0;
|
|
7879
7875
|
const value = useMemo(() => ({
|
|
@@ -8038,7 +8034,7 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
|
8038
8034
|
(_b2 = (_a3 = childProp == null ? void 0 : childProp.props) == null ? void 0 : _a3.onMouseLeave) == null ? void 0 : _b2.call(_a3, e);
|
|
8039
8035
|
}, [childProp == null ? void 0 : childProp.props, handleIsOpenChange]);
|
|
8040
8036
|
useEffect(() => {
|
|
8041
|
-
if (!
|
|
8037
|
+
if (!showTooltip) return;
|
|
8042
8038
|
function handleWindowMouseMove(event) {
|
|
8043
8039
|
if (!referenceElement) return;
|
|
8044
8040
|
const isHoveringReference = referenceElement === event.target || event.target instanceof Node && referenceElement.contains(event.target);
|
|
@@ -8051,13 +8047,13 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
|
8051
8047
|
return () => {
|
|
8052
8048
|
window.removeEventListener("mousemove", handleWindowMouseMove);
|
|
8053
8049
|
};
|
|
8054
|
-
}, [
|
|
8050
|
+
}, [showTooltip, referenceElement, handleIsOpenChange]);
|
|
8055
8051
|
useEffect(() => {
|
|
8056
|
-
if (disabled) handleIsOpenChange(false);
|
|
8057
|
-
}, [disabled, handleIsOpenChange]);
|
|
8052
|
+
if (disabled && showTooltip) handleIsOpenChange(false);
|
|
8053
|
+
}, [disabled, handleIsOpenChange, showTooltip]);
|
|
8058
8054
|
useEffect(() => {
|
|
8059
|
-
if (!content) handleIsOpenChange(false);
|
|
8060
|
-
}, [content, handleIsOpenChange]);
|
|
8055
|
+
if (!content && showTooltip) handleIsOpenChange(false);
|
|
8056
|
+
}, [content, handleIsOpenChange, showTooltip]);
|
|
8061
8057
|
useEffect(() => refs.setReference(referenceElement), [referenceElement, refs]);
|
|
8062
8058
|
useEffect(() => {
|
|
8063
8059
|
if (!showTooltip) return;
|