@sanity/ui 2.6.3 → 2.6.4-canary.1
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 +37 -37
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +37 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -37
- 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 +52 -59
- 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 +51 -36
- package/src/core/styles/font/responsiveFont.ts +8 -8
- package/src/core/theme/__workshop__/debug/story.tsx +11 -11
- package/src/core/utils/portal/portalProvider.tsx +5 -10
- 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.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import Refractor from "react-refractor";
|
|
|
8
8
|
import { detectOverflow, flip, offset, shift, arrow, hide, useFloating, autoUpdate } from "@floating-ui/react-dom";
|
|
9
9
|
import { motion, AnimatePresence } from "framer-motion";
|
|
10
10
|
import { createPortal } from "react-dom";
|
|
11
|
+
import { useEffectEvent } from "use-effect-event";
|
|
11
12
|
import { getTheme_v2 as getTheme_v2$1 } from "./_chunks-es/getTheme_v2.mjs";
|
|
12
13
|
const createColorTheme = createColorTheme$1, hexToRgb = hexToRgb$1, hslToRgb = hslToRgb$1, multiply = multiply$1, parseColor = parseColor$1, rgbToHex = rgbToHex$1, rgbToHsl = rgbToHsl$1, rgba = rgba$1, screen = screen$1, studioTheme = buildTheme(), EMPTY_ARRAY = [], EMPTY_RECORD = {}, POPOVER_MOTION_CONTENT_OPACITY_PROPERTY = "--motion-content-opacity", POPOVER_MOTION_PROPS = {
|
|
13
14
|
initial: {
|
|
@@ -3069,21 +3070,25 @@ function _isEqual(objA, objB) {
|
|
|
3069
3070
|
const keysA = Object.keys(objA), keysB = Object.keys(objB);
|
|
3070
3071
|
return keysA.length !== keysB.length ? !1 : keysA.every((key2) => objA[key2] === objB[key2]);
|
|
3071
3072
|
}
|
|
3073
|
+
function useMounted() {
|
|
3074
|
+
return useSyncExternalStore(
|
|
3075
|
+
subscribe,
|
|
3076
|
+
() => !0,
|
|
3077
|
+
() => !1
|
|
3078
|
+
);
|
|
3079
|
+
}
|
|
3080
|
+
const subscribe = () => () => {
|
|
3081
|
+
};
|
|
3072
3082
|
function PortalProvider(props) {
|
|
3073
|
-
const { boundaryElement, children, element, __unstable_elements: elementsProp } = props, elements = useUnique(elementsProp),
|
|
3074
|
-
emptySubscribe$1,
|
|
3075
|
-
() => document.body,
|
|
3076
|
-
() => null
|
|
3077
|
-
), value = useMemo(() => ({
|
|
3083
|
+
const { boundaryElement, children, element, __unstable_elements: elementsProp } = props, elements = useUnique(elementsProp), mounted = useMounted(), value = useMemo(() => ({
|
|
3078
3084
|
version: 0,
|
|
3079
3085
|
boundaryElement: boundaryElement || null,
|
|
3080
|
-
element: element ||
|
|
3086
|
+
element: element || mounted ? document.body : null,
|
|
3081
3087
|
elements
|
|
3082
|
-
}), [boundaryElement, element, elements,
|
|
3088
|
+
}), [boundaryElement, element, elements, mounted]);
|
|
3083
3089
|
return /* @__PURE__ */ jsx(PortalContext.Provider, { value, children });
|
|
3084
3090
|
}
|
|
3085
|
-
const
|
|
3086
|
-
}, Root$i = styled.div`
|
|
3091
|
+
const Root$i = styled.div`
|
|
3087
3092
|
display: block;
|
|
3088
3093
|
width: 0;
|
|
3089
3094
|
height: 0;
|
|
@@ -4360,18 +4365,16 @@ const Root$a = styled(Layer)`
|
|
|
4360
4365
|
...restProps
|
|
4361
4366
|
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, fallbackPlacements = useArrayProp(fallbackPlacementsProp), ref = useRef(null), [referenceElement, setReferenceElement] = useState(null), arrowRef = useRef(null), rootBoundary = "viewport";
|
|
4362
4367
|
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(() => {
|
|
4368
|
+
const portal = usePortal(), portalElement = typeof portalProp == "string" ? ((_c = portal.elements) == null ? void 0 : _c[portalProp]) || null : portal.element, mounted = useMounted(), tooltipWidth = useMemo(() => {
|
|
4369
4369
|
const availableWidths = [
|
|
4370
4370
|
...boundaryElement ? [boundaryElement.offsetWidth] : [],
|
|
4371
|
-
|
|
4371
|
+
portalElement != null && portalElement.offsetWidth || mounted ? document.body.offsetWidth : (
|
|
4372
|
+
// We don't actually know what the width of the body is during SSR, so we'll just assume it's 800px or larger
|
|
4373
|
+
800
|
|
4374
|
+
)
|
|
4372
4375
|
];
|
|
4373
4376
|
return Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2;
|
|
4374
|
-
}, [boundaryElement,
|
|
4377
|
+
}, [boundaryElement, mounted, portalElement]), middleware = useMemo(() => {
|
|
4375
4378
|
const ret = [];
|
|
4376
4379
|
return ret.push(
|
|
4377
4380
|
flip({
|
|
@@ -4443,14 +4446,6 @@ const Root$a = styled(Layer)`
|
|
|
4443
4446
|
[childProp == null ? void 0 : childProp.props, handleIsOpenChange]
|
|
4444
4447
|
);
|
|
4445
4448
|
useEffect(() => {
|
|
4446
|
-
if (!showTooltip) return;
|
|
4447
|
-
function handleWindowMouseMove(event) {
|
|
4448
|
-
referenceElement && (referenceElement === event.target || event.target instanceof Node && referenceElement.contains(event.target) || (handleIsOpenChange(!1), window.removeEventListener("mousemove", handleWindowMouseMove)));
|
|
4449
|
-
}
|
|
4450
|
-
return window.addEventListener("mousemove", handleWindowMouseMove), () => {
|
|
4451
|
-
window.removeEventListener("mousemove", handleWindowMouseMove);
|
|
4452
|
-
};
|
|
4453
|
-
}, [showTooltip, referenceElement, handleIsOpenChange]), useEffect(() => {
|
|
4454
4449
|
disabled && showTooltip && handleIsOpenChange(!1);
|
|
4455
4450
|
}, [disabled, handleIsOpenChange, showTooltip]), useEffect(() => {
|
|
4456
4451
|
!content && showTooltip && handleIsOpenChange(!1);
|
|
@@ -4462,7 +4457,7 @@ const Root$a = styled(Layer)`
|
|
|
4462
4457
|
return window.addEventListener("keydown", handleWindowKeyDown), () => {
|
|
4463
4458
|
window.removeEventListener("keydown", handleWindowKeyDown);
|
|
4464
4459
|
};
|
|
4465
|
-
}, [handleIsOpenChange, showTooltip]);
|
|
4460
|
+
}, [handleIsOpenChange, showTooltip]), useCloseOnMouseLeave({ handleIsOpenChange, referenceElement, showTooltip });
|
|
4466
4461
|
const setArrow = useCallback(
|
|
4467
4462
|
(arrowEl) => {
|
|
4468
4463
|
arrowRef.current = arrowEl, update();
|
|
@@ -4546,8 +4541,21 @@ const Root$a = styled(Layer)`
|
|
|
4546
4541
|
),
|
|
4547
4542
|
child
|
|
4548
4543
|
] });
|
|
4549
|
-
})
|
|
4550
|
-
|
|
4544
|
+
});
|
|
4545
|
+
function useCloseOnMouseLeave({
|
|
4546
|
+
handleIsOpenChange,
|
|
4547
|
+
referenceElement,
|
|
4548
|
+
showTooltip
|
|
4549
|
+
}) {
|
|
4550
|
+
const handleWindowMouseMove = useEffectEvent((event) => {
|
|
4551
|
+
referenceElement && (referenceElement === event.target || event.target instanceof Node && referenceElement.contains(event.target) || handleIsOpenChange(!1));
|
|
4552
|
+
});
|
|
4553
|
+
useEffect(() => {
|
|
4554
|
+
if (showTooltip)
|
|
4555
|
+
return window.addEventListener("mousemove", handleWindowMouseMove), () => window.removeEventListener("mousemove", handleWindowMouseMove);
|
|
4556
|
+
}, [handleWindowMouseMove, showTooltip]);
|
|
4557
|
+
}
|
|
4558
|
+
const Root$9 = styled.div`
|
|
4551
4559
|
line-height: 0;
|
|
4552
4560
|
`, ListBox = styled(Box)`
|
|
4553
4561
|
& > ul {
|
|
@@ -6242,15 +6250,7 @@ function Toast(props) {
|
|
|
6242
6250
|
}
|
|
6243
6251
|
);
|
|
6244
6252
|
}
|
|
6245
|
-
|
|
6246
|
-
return useSyncExternalStore(
|
|
6247
|
-
subscribe,
|
|
6248
|
-
() => !0,
|
|
6249
|
-
() => !1
|
|
6250
|
-
);
|
|
6251
|
-
}
|
|
6252
|
-
const subscribe = () => () => {
|
|
6253
|
-
}, key$1 = Symbol.for("@sanity/ui/context/toast"), ToastContext = createGlobalScopedContext(key$1, null), Root$1 = styled(Layer)`
|
|
6253
|
+
const key$1 = Symbol.for("@sanity/ui/context/toast"), ToastContext = createGlobalScopedContext(key$1, null), Root$1 = styled(Layer)`
|
|
6254
6254
|
position: fixed;
|
|
6255
6255
|
top: 0;
|
|
6256
6256
|
left: 0;
|