@sanity/ui 2.6.3 → 2.6.4-canary.0
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 +19 -21
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +18 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +25 -33
- package/src/core/components/menu/useMenuController.ts +1 -0
- package/src/core/components/toast/styles.ts +2 -1
- package/src/core/helpers/focus.ts +1 -0
- package/src/core/helpers/scroll.ts +1 -0
- package/src/core/hooks/useClickOutside.ts +3 -0
- package/src/core/hooks/useElementSize.ts +1 -0
- package/src/core/hooks/useMediaIndex/useMediaIndex.ts +1 -0
- package/src/core/hooks/usePrefersDark.ts +3 -0
- package/src/core/hooks/usePrefersReducedMotion.ts +2 -0
- package/src/core/primitives/tooltip/tooltip.tsx +26 -25
- package/src/core/utils/portal/portalProvider.tsx +1 -0
package/dist/index.js
CHANGED
|
@@ -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(), {
|
|
@@ -4356,20 +4355,21 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4356
4355
|
...restProps
|
|
4357
4356
|
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, fallbackPlacements = useArrayProp(fallbackPlacementsProp), ref = react.useRef(null), [referenceElement, setReferenceElement] = react.useState(null), arrowRef = react.useRef(null), rootBoundary = "viewport";
|
|
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(
|
|
4361
|
+
reactDom$1.size({
|
|
4362
|
+
apply({ elements }) {
|
|
4363
|
+
const availableWidths = [
|
|
4364
|
+
...boundaryElement ? [boundaryElement.offsetWidth] : [],
|
|
4365
|
+
(portalElement == null ? void 0 : portalElement.offsetWidth) || document.body.offsetWidth
|
|
4366
|
+
], tooltipWidth = Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2;
|
|
4367
|
+
Object.assign(elements.floating.style, {
|
|
4368
|
+
maxWidth: tooltipWidth > 0 ? `${tooltipWidth}px` : void 0
|
|
4369
|
+
});
|
|
4370
|
+
}
|
|
4371
|
+
})
|
|
4372
|
+
), ret.push(
|
|
4373
4373
|
reactDom$1.flip({
|
|
4374
4374
|
boundary: boundaryElement || void 0,
|
|
4375
4375
|
fallbackPlacements,
|
|
@@ -4383,7 +4383,7 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4383
4383
|
padding: DEFAULT_TOOLTIP_PADDING
|
|
4384
4384
|
})
|
|
4385
4385
|
), arrowProp && ret.push(reactDom$1.arrow({ element: arrowRef, padding: DEFAULT_TOOLTIP_PADDING })), animate && ret.push(origin), ret;
|
|
4386
|
-
}, [animate, arrowProp, boundaryElement, fallbackPlacements]), { floatingStyles, placement, middlewareData, refs, update } = reactDom$1.useFloating({
|
|
4386
|
+
}, [animate, arrowProp, boundaryElement, fallbackPlacements, portalElement]), { floatingStyles, placement, middlewareData, refs, update } = reactDom$1.useFloating({
|
|
4387
4387
|
middleware,
|
|
4388
4388
|
placement: placementProp,
|
|
4389
4389
|
whileElementsMounted: reactDom$1.autoUpdate
|
|
@@ -4501,7 +4501,6 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4501
4501
|
ref: setFloating,
|
|
4502
4502
|
style: floatingStyles,
|
|
4503
4503
|
zOffset,
|
|
4504
|
-
$maxWidth: tooltipWidth,
|
|
4505
4504
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4506
4505
|
TooltipCard,
|
|
4507
4506
|
{
|
|
@@ -4542,8 +4541,7 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4542
4541
|
),
|
|
4543
4542
|
child
|
|
4544
4543
|
] });
|
|
4545
|
-
}),
|
|
4546
|
-
}, Root$9 = styledComponents.styled.div`
|
|
4544
|
+
}), Root$9 = styledComponents.styled.div`
|
|
4547
4545
|
line-height: 0;
|
|
4548
4546
|
`, ListBox = styledComponents.styled(Box)`
|
|
4549
4547
|
& > ul {
|
|
@@ -6152,7 +6150,7 @@ const CustomInline = styledComponents.styled(Inline)`
|
|
|
6152
6150
|
}
|
|
6153
6151
|
100% {
|
|
6154
6152
|
width: 100%;
|
|
6155
|
-
}
|
|
6153
|
+
}
|
|
6156
6154
|
`, LOADING_BAR_HEIGHT = 2;
|
|
6157
6155
|
function rootStyles(props) {
|
|
6158
6156
|
const { color } = getTheme_v2.getTheme_v2(props.theme), loadingBarColor = color.button.default[props.tone].enabled.bg;
|