@sanity/ui 2.6.2 → 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.d.mts +1 -3
- package/dist/index.d.ts +1 -3
- 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 +33 -41
- 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.d.mts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
|
|
3
1
|
import {BaseTheme as BaseTheme_2} from '@sanity/ui/theme'
|
|
4
2
|
import {Component} from 'react'
|
|
5
3
|
import {Context} from 'react'
|
|
@@ -89,7 +87,7 @@ export declare const Arrow: ForwardRefExoticComponent<
|
|
|
89
87
|
{
|
|
90
88
|
width: number
|
|
91
89
|
height: number
|
|
92
|
-
radius?: number
|
|
90
|
+
radius?: number
|
|
93
91
|
} & Omit<HTMLProps<HTMLDivElement>, 'height' | 'width'>,
|
|
94
92
|
'ref'
|
|
95
93
|
> &
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
|
|
3
1
|
import {BaseTheme as BaseTheme_2} from '@sanity/ui/theme'
|
|
4
2
|
import {Component} from 'react'
|
|
5
3
|
import {Context} from 'react'
|
|
@@ -89,7 +87,7 @@ export declare const Arrow: ForwardRefExoticComponent<
|
|
|
89
87
|
{
|
|
90
88
|
width: number
|
|
91
89
|
height: number
|
|
92
|
-
radius?: number
|
|
90
|
+
radius?: number
|
|
93
91
|
} & Omit<HTMLProps<HTMLDivElement>, 'height' | 'width'>,
|
|
94
92
|
'ref'
|
|
95
93
|
> &
|
package/dist/index.esm.js
CHANGED
|
@@ -5,7 +5,7 @@ import ReactIs, { isValidElementType } from "react-is";
|
|
|
5
5
|
import { ThemeProvider as ThemeProvider$1, useTheme as useTheme$1, css, styled, keyframes } from "styled-components";
|
|
6
6
|
import { SpinnerIcon, CheckmarkIcon, RemoveIcon, ChevronDownIcon, CloseIcon, ChevronRightIcon, ToggleArrowRightIcon } from "@sanity/icons";
|
|
7
7
|
import Refractor from "react-refractor";
|
|
8
|
-
import { detectOverflow, flip, offset, shift, arrow, hide, useFloating, autoUpdate } from "@floating-ui/react-dom";
|
|
8
|
+
import { detectOverflow, flip, offset, shift, arrow, hide, useFloating, autoUpdate, size as size$2 } from "@floating-ui/react-dom";
|
|
9
9
|
import { motion, AnimatePresence } from "framer-motion";
|
|
10
10
|
import { createPortal } from "react-dom";
|
|
11
11
|
import { getTheme_v2 as getTheme_v2$1 } from "./_legacy/getTheme_v2.esm.js";
|
|
@@ -3071,7 +3071,7 @@ function _isEqual(objA, objB) {
|
|
|
3071
3071
|
}
|
|
3072
3072
|
function PortalProvider(props) {
|
|
3073
3073
|
const { boundaryElement, children, element, __unstable_elements: elementsProp } = props, elements = useUnique(elementsProp), fallbackElement = useSyncExternalStore(
|
|
3074
|
-
emptySubscribe
|
|
3074
|
+
emptySubscribe,
|
|
3075
3075
|
() => document.body,
|
|
3076
3076
|
() => null
|
|
3077
3077
|
), value = useMemo(() => ({
|
|
@@ -3082,7 +3082,7 @@ function PortalProvider(props) {
|
|
|
3082
3082
|
}), [boundaryElement, element, elements, fallbackElement]);
|
|
3083
3083
|
return /* @__PURE__ */ jsx(PortalContext.Provider, { value, children });
|
|
3084
3084
|
}
|
|
3085
|
-
const emptySubscribe
|
|
3085
|
+
const emptySubscribe = () => () => {
|
|
3086
3086
|
}, Root$i = styled.div`
|
|
3087
3087
|
display: block;
|
|
3088
3088
|
width: 0;
|
|
@@ -4338,7 +4338,6 @@ function TooltipDelayGroupProvider(props) {
|
|
|
4338
4338
|
}
|
|
4339
4339
|
const Root$a = styled(Layer)`
|
|
4340
4340
|
pointer-events: none;
|
|
4341
|
-
max-width: ${({ $maxWidth }) => $maxWidth}px;
|
|
4342
4341
|
`, Tooltip = forwardRef(function(props, forwardedRef) {
|
|
4343
4342
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
4344
4343
|
const boundaryElementContext = useBoundaryElement(), { layer } = useTheme_v2(), {
|
|
@@ -4360,20 +4359,21 @@ const Root$a = styled(Layer)`
|
|
|
4360
4359
|
...restProps
|
|
4361
4360
|
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, fallbackPlacements = useArrayProp(fallbackPlacementsProp), ref = useRef(null), [referenceElement, setReferenceElement] = useState(null), arrowRef = useRef(null), rootBoundary = "viewport";
|
|
4362
4361
|
useImperativeHandle(forwardedRef, () => ref.current);
|
|
4363
|
-
const portal = usePortal(), portalElement = typeof portalProp == "string" ? ((_c = portal.elements) == null ? void 0 : _c[portalProp]) || null : portal.element,
|
|
4364
|
-
emptySubscribe,
|
|
4365
|
-
() => document.body.offsetWidth,
|
|
4366
|
-
// We don't actually know what the width of the body is during SSR, so we'll just assume it's 800px or larger
|
|
4367
|
-
() => 800
|
|
4368
|
-
), tooltipWidth = useMemo(() => {
|
|
4369
|
-
const availableWidths = [
|
|
4370
|
-
...boundaryElement ? [boundaryElement.offsetWidth] : [],
|
|
4371
|
-
(portalElement == null ? void 0 : portalElement.offsetWidth) || documentBodyOffsetWidth
|
|
4372
|
-
];
|
|
4373
|
-
return Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2;
|
|
4374
|
-
}, [boundaryElement, documentBodyOffsetWidth, portalElement == null ? void 0 : portalElement.offsetWidth]), middleware = useMemo(() => {
|
|
4362
|
+
const portal = usePortal(), portalElement = typeof portalProp == "string" ? ((_c = portal.elements) == null ? void 0 : _c[portalProp]) || null : portal.element, middleware = useMemo(() => {
|
|
4375
4363
|
const ret = [];
|
|
4376
4364
|
return ret.push(
|
|
4365
|
+
size$2({
|
|
4366
|
+
apply({ elements }) {
|
|
4367
|
+
const availableWidths = [
|
|
4368
|
+
...boundaryElement ? [boundaryElement.offsetWidth] : [],
|
|
4369
|
+
(portalElement == null ? void 0 : portalElement.offsetWidth) || document.body.offsetWidth
|
|
4370
|
+
], tooltipWidth = Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2;
|
|
4371
|
+
Object.assign(elements.floating.style, {
|
|
4372
|
+
maxWidth: tooltipWidth > 0 ? `${tooltipWidth}px` : void 0
|
|
4373
|
+
});
|
|
4374
|
+
}
|
|
4375
|
+
})
|
|
4376
|
+
), ret.push(
|
|
4377
4377
|
flip({
|
|
4378
4378
|
boundary: boundaryElement || void 0,
|
|
4379
4379
|
fallbackPlacements,
|
|
@@ -4387,7 +4387,7 @@ const Root$a = styled(Layer)`
|
|
|
4387
4387
|
padding: DEFAULT_TOOLTIP_PADDING
|
|
4388
4388
|
})
|
|
4389
4389
|
), arrowProp && ret.push(arrow({ element: arrowRef, padding: DEFAULT_TOOLTIP_PADDING })), animate && ret.push(origin), ret;
|
|
4390
|
-
}, [animate, arrowProp, boundaryElement, fallbackPlacements]), { floatingStyles, placement, middlewareData, refs, update } = useFloating({
|
|
4390
|
+
}, [animate, arrowProp, boundaryElement, fallbackPlacements, portalElement]), { floatingStyles, placement, middlewareData, refs, update } = useFloating({
|
|
4391
4391
|
middleware,
|
|
4392
4392
|
placement: placementProp,
|
|
4393
4393
|
whileElementsMounted: autoUpdate
|
|
@@ -4505,7 +4505,6 @@ const Root$a = styled(Layer)`
|
|
|
4505
4505
|
ref: setFloating,
|
|
4506
4506
|
style: floatingStyles,
|
|
4507
4507
|
zOffset,
|
|
4508
|
-
$maxWidth: tooltipWidth,
|
|
4509
4508
|
children: /* @__PURE__ */ jsx(
|
|
4510
4509
|
TooltipCard,
|
|
4511
4510
|
{
|
|
@@ -4546,8 +4545,7 @@ const Root$a = styled(Layer)`
|
|
|
4546
4545
|
),
|
|
4547
4546
|
child
|
|
4548
4547
|
] });
|
|
4549
|
-
}),
|
|
4550
|
-
}, Root$9 = styled.div`
|
|
4548
|
+
}), Root$9 = styled.div`
|
|
4551
4549
|
line-height: 0;
|
|
4552
4550
|
`, ListBox = styled(Box)`
|
|
4553
4551
|
& > ul {
|
|
@@ -6156,7 +6154,7 @@ const CustomInline = styled(Inline)`
|
|
|
6156
6154
|
}
|
|
6157
6155
|
100% {
|
|
6158
6156
|
width: 100%;
|
|
6159
|
-
}
|
|
6157
|
+
}
|
|
6160
6158
|
`, LOADING_BAR_HEIGHT = 2;
|
|
6161
6159
|
function rootStyles(props) {
|
|
6162
6160
|
const { color } = getTheme_v2$1(props.theme), loadingBarColor = color.button.default[props.tone].enabled.bg;
|