@sanity/ui 2.6.7 → 2.6.8
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.d.mts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.esm.js +36 -31
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +35 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -31
- package/dist/index.mjs.map +1 -1
- package/dist/theme.d.mts +14 -14
- package/dist/theme.d.ts +14 -14
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs.map +1 -1
- package/package.json +25 -24
- package/src/core/__workshop__/constants.ts +36 -36
- package/src/core/components/autocomplete/autocomplete.tsx +1 -1
- package/src/core/components/dialog/styles.ts +8 -8
- package/src/core/components/menu/menuButton.tsx +10 -10
- package/src/core/components/tab/tab.tsx +8 -8
- package/src/core/components/tab/tabPanel.tsx +1 -1
- package/src/core/primitives/avatar/styles.ts +42 -42
- package/src/core/primitives/badge/styles.ts +2 -2
- package/src/core/primitives/button/styles.ts +4 -4
- package/src/core/primitives/inline/styles.ts +2 -2
- package/src/core/primitives/popover/constants.ts +4 -4
- package/src/core/primitives/stack/styles.ts +2 -2
- package/src/core/primitives/tooltip/__workshop__/customPortal.tsx +1 -1
- package/src/core/primitives/tooltip/constants.ts +4 -4
- package/src/core/primitives/tooltip/tooltip.tsx +68 -49
- package/src/core/styles/font/responsiveFont.ts +8 -8
- package/src/core/theme/__workshop__/debug/story.tsx +11 -11
- package/src/theme/build/buildColorTheme.test.ts +13 -13
- package/src/theme/config/tokens/color/types.ts +14 -14
- package/src/theme/defaults/colorTokens.ts +36 -36
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
-
var theme = require("@sanity/ui/theme"), jsxRuntime = require("react/jsx-runtime"), react = require("react"), ReactIs = require("react-is"), styledComponents = require("styled-components"), icons = require("@sanity/icons"), Refractor = require("react-refractor"), reactDom$1 = require("@floating-ui/react-dom"), framerMotion = require("framer-motion"), reactDom = require("react-dom"), getTheme_v2 = require("./_chunks-cjs/getTheme_v2.js");
|
|
3
|
+
var theme = require("@sanity/ui/theme"), jsxRuntime = require("react/jsx-runtime"), react = require("react"), ReactIs = require("react-is"), styledComponents = require("styled-components"), icons = require("@sanity/icons"), Refractor = require("react-refractor"), reactDom$1 = require("@floating-ui/react-dom"), framerMotion = require("framer-motion"), reactDom = require("react-dom"), useEffectEvent = require("use-effect-event"), getTheme_v2 = require("./_chunks-cjs/getTheme_v2.js");
|
|
4
4
|
function _interopDefaultCompat(e) {
|
|
5
5
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
6
6
|
}
|
|
@@ -3067,7 +3067,7 @@ function _isEqual(objA, objB) {
|
|
|
3067
3067
|
}
|
|
3068
3068
|
function PortalProvider(props) {
|
|
3069
3069
|
const { boundaryElement, children, element, __unstable_elements: elementsProp } = props, elements = useUnique(elementsProp), fallbackElement = react.useSyncExternalStore(
|
|
3070
|
-
emptySubscribe
|
|
3070
|
+
emptySubscribe,
|
|
3071
3071
|
() => document.body,
|
|
3072
3072
|
() => null
|
|
3073
3073
|
), value = react.useMemo(() => ({
|
|
@@ -3078,7 +3078,7 @@ function PortalProvider(props) {
|
|
|
3078
3078
|
}), [boundaryElement, element, elements, fallbackElement]);
|
|
3079
3079
|
return /* @__PURE__ */ jsxRuntime.jsx(PortalContext.Provider, { value, children });
|
|
3080
3080
|
}
|
|
3081
|
-
const emptySubscribe
|
|
3081
|
+
const emptySubscribe = () => () => {
|
|
3082
3082
|
}, Root$i = styledComponents.styled.div`
|
|
3083
3083
|
display: block;
|
|
3084
3084
|
width: 0;
|
|
@@ -4334,7 +4334,6 @@ function TooltipDelayGroupProvider(props) {
|
|
|
4334
4334
|
}
|
|
4335
4335
|
const Root$a = styledComponents.styled(Layer)`
|
|
4336
4336
|
pointer-events: none;
|
|
4337
|
-
max-width: ${({ $maxWidth }) => $maxWidth}px;
|
|
4338
4337
|
`, Tooltip = react.forwardRef(function(props, forwardedRef) {
|
|
4339
4338
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
4340
4339
|
const boundaryElementContext = useBoundaryElement(), { layer } = useTheme_v2(), {
|
|
@@ -4354,20 +4353,9 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4354
4353
|
zOffset = layer.tooltip.zOffset,
|
|
4355
4354
|
delay,
|
|
4356
4355
|
...restProps
|
|
4357
|
-
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, fallbackPlacements = useArrayProp(fallbackPlacementsProp), ref = react.useRef(null), [referenceElement, setReferenceElement] = react.useState(null), arrowRef = react.useRef(null), rootBoundary = "viewport";
|
|
4356
|
+
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, fallbackPlacements = useArrayProp(fallbackPlacementsProp), ref = react.useRef(null), [referenceElement, setReferenceElement] = react.useState(null), arrowRef = react.useRef(null), rootBoundary = "viewport", [tooltipMaxWidth, setTooltipMaxWidth] = react.useState(0);
|
|
4358
4357
|
react.useImperativeHandle(forwardedRef, () => ref.current);
|
|
4359
|
-
const portal = usePortal(), portalElement = typeof portalProp == "string" ? ((_c = portal.elements) == null ? void 0 : _c[portalProp]) || null : portal.element,
|
|
4360
|
-
emptySubscribe,
|
|
4361
|
-
() => document.body.offsetWidth,
|
|
4362
|
-
// We don't actually know what the width of the body is during SSR, so we'll just assume it's 800px or larger
|
|
4363
|
-
() => 800
|
|
4364
|
-
), tooltipWidth = react.useMemo(() => {
|
|
4365
|
-
const availableWidths = [
|
|
4366
|
-
...boundaryElement ? [boundaryElement.offsetWidth] : [],
|
|
4367
|
-
(portalElement == null ? void 0 : portalElement.offsetWidth) || documentBodyOffsetWidth
|
|
4368
|
-
];
|
|
4369
|
-
return Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2;
|
|
4370
|
-
}, [boundaryElement, documentBodyOffsetWidth, portalElement == null ? void 0 : portalElement.offsetWidth]), middleware = react.useMemo(() => {
|
|
4358
|
+
const portal = usePortal(), portalElement = typeof portalProp == "string" ? ((_c = portal.elements) == null ? void 0 : _c[portalProp]) || null : portal.element, middleware = react.useMemo(() => {
|
|
4371
4359
|
const ret = [];
|
|
4372
4360
|
return ret.push(
|
|
4373
4361
|
reactDom$1.flip({
|
|
@@ -4438,15 +4426,7 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4438
4426
|
},
|
|
4439
4427
|
[childProp == null ? void 0 : childProp.props, handleIsOpenChange]
|
|
4440
4428
|
);
|
|
4441
|
-
react.useEffect(() => {
|
|
4442
|
-
if (!showTooltip) return;
|
|
4443
|
-
function handleWindowMouseMove(event) {
|
|
4444
|
-
referenceElement && (referenceElement === event.target || event.target instanceof Node && referenceElement.contains(event.target) || (handleIsOpenChange(!1), window.removeEventListener("mousemove", handleWindowMouseMove)));
|
|
4445
|
-
}
|
|
4446
|
-
return window.addEventListener("mousemove", handleWindowMouseMove), () => {
|
|
4447
|
-
window.removeEventListener("mousemove", handleWindowMouseMove);
|
|
4448
|
-
};
|
|
4449
|
-
}, [showTooltip, referenceElement, handleIsOpenChange]), react.useEffect(() => {
|
|
4429
|
+
useCloseOnMouseLeave({ handleIsOpenChange, referenceElement, showTooltip }), react.useEffect(() => {
|
|
4450
4430
|
disabled && showTooltip && handleIsOpenChange(!1);
|
|
4451
4431
|
}, [disabled, handleIsOpenChange, showTooltip]), react.useEffect(() => {
|
|
4452
4432
|
!content && showTooltip && handleIsOpenChange(!1);
|
|
@@ -4458,7 +4438,13 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4458
4438
|
return window.addEventListener("keydown", handleWindowKeyDown), () => {
|
|
4459
4439
|
window.removeEventListener("keydown", handleWindowKeyDown);
|
|
4460
4440
|
};
|
|
4461
|
-
}, [handleIsOpenChange, showTooltip])
|
|
4441
|
+
}, [handleIsOpenChange, showTooltip]), react.useLayoutEffect(() => {
|
|
4442
|
+
const availableWidths = [
|
|
4443
|
+
...boundaryElement ? [boundaryElement.offsetWidth] : [],
|
|
4444
|
+
(portalElement == null ? void 0 : portalElement.offsetWidth) || document.body.offsetWidth
|
|
4445
|
+
];
|
|
4446
|
+
setTooltipMaxWidth(Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2);
|
|
4447
|
+
}, [boundaryElement, portalElement]);
|
|
4462
4448
|
const setArrow = react.useCallback(
|
|
4463
4449
|
(arrowEl) => {
|
|
4464
4450
|
arrowRef.current = arrowEl, update();
|
|
@@ -4499,9 +4485,11 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4499
4485
|
"data-ui": "Tooltip",
|
|
4500
4486
|
...restProps,
|
|
4501
4487
|
ref: setFloating,
|
|
4502
|
-
style:
|
|
4488
|
+
style: {
|
|
4489
|
+
...floatingStyles,
|
|
4490
|
+
maxWidth: tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : void 0
|
|
4491
|
+
},
|
|
4503
4492
|
zOffset,
|
|
4504
|
-
$maxWidth: tooltipWidth,
|
|
4505
4493
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4506
4494
|
TooltipCard,
|
|
4507
4495
|
{
|
|
@@ -4542,8 +4530,24 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4542
4530
|
),
|
|
4543
4531
|
child
|
|
4544
4532
|
] });
|
|
4545
|
-
})
|
|
4546
|
-
|
|
4533
|
+
});
|
|
4534
|
+
function useCloseOnMouseLeave({
|
|
4535
|
+
handleIsOpenChange,
|
|
4536
|
+
referenceElement,
|
|
4537
|
+
showTooltip
|
|
4538
|
+
}) {
|
|
4539
|
+
const onMouseMove = useEffectEvent.useEffectEvent((target, teardown) => {
|
|
4540
|
+
referenceElement && (referenceElement === target || target instanceof Node && referenceElement.contains(target) || (handleIsOpenChange(!1), teardown()));
|
|
4541
|
+
});
|
|
4542
|
+
react.useEffect(() => {
|
|
4543
|
+
if (!showTooltip) return;
|
|
4544
|
+
const handleMouseMove = (event) => {
|
|
4545
|
+
onMouseMove(event.target, () => window.removeEventListener("mousemove", handleMouseMove));
|
|
4546
|
+
};
|
|
4547
|
+
return window.addEventListener("mousemove", handleMouseMove), () => window.removeEventListener("mousemove", handleMouseMove);
|
|
4548
|
+
}, [onMouseMove, showTooltip]);
|
|
4549
|
+
}
|
|
4550
|
+
const Root$9 = styledComponents.styled.div`
|
|
4547
4551
|
line-height: 0;
|
|
4548
4552
|
`, ListBox = styledComponents.styled(Box)`
|
|
4549
4553
|
& > ul {
|