@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.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
|
}
|
|
@@ -3065,21 +3065,25 @@ function _isEqual(objA, objB) {
|
|
|
3065
3065
|
const keysA = Object.keys(objA), keysB = Object.keys(objB);
|
|
3066
3066
|
return keysA.length !== keysB.length ? !1 : keysA.every((key2) => objA[key2] === objB[key2]);
|
|
3067
3067
|
}
|
|
3068
|
+
function useMounted() {
|
|
3069
|
+
return react.useSyncExternalStore(
|
|
3070
|
+
subscribe,
|
|
3071
|
+
() => !0,
|
|
3072
|
+
() => !1
|
|
3073
|
+
);
|
|
3074
|
+
}
|
|
3075
|
+
const subscribe = () => () => {
|
|
3076
|
+
};
|
|
3068
3077
|
function PortalProvider(props) {
|
|
3069
|
-
const { boundaryElement, children, element, __unstable_elements: elementsProp } = props, elements = useUnique(elementsProp),
|
|
3070
|
-
emptySubscribe$1,
|
|
3071
|
-
() => document.body,
|
|
3072
|
-
() => null
|
|
3073
|
-
), value = react.useMemo(() => ({
|
|
3078
|
+
const { boundaryElement, children, element, __unstable_elements: elementsProp } = props, elements = useUnique(elementsProp), mounted = useMounted(), value = react.useMemo(() => ({
|
|
3074
3079
|
version: 0,
|
|
3075
3080
|
boundaryElement: boundaryElement || null,
|
|
3076
|
-
element: element ||
|
|
3081
|
+
element: element || mounted ? document.body : null,
|
|
3077
3082
|
elements
|
|
3078
|
-
}), [boundaryElement, element, elements,
|
|
3083
|
+
}), [boundaryElement, element, elements, mounted]);
|
|
3079
3084
|
return /* @__PURE__ */ jsxRuntime.jsx(PortalContext.Provider, { value, children });
|
|
3080
3085
|
}
|
|
3081
|
-
const
|
|
3082
|
-
}, Root$i = styledComponents.styled.div`
|
|
3086
|
+
const Root$i = styledComponents.styled.div`
|
|
3083
3087
|
display: block;
|
|
3084
3088
|
width: 0;
|
|
3085
3089
|
height: 0;
|
|
@@ -4356,18 +4360,16 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4356
4360
|
...restProps
|
|
4357
4361
|
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, fallbackPlacements = useArrayProp(fallbackPlacementsProp), ref = react.useRef(null), [referenceElement, setReferenceElement] = react.useState(null), arrowRef = react.useRef(null), rootBoundary = "viewport";
|
|
4358
4362
|
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(() => {
|
|
4363
|
+
const portal = usePortal(), portalElement = typeof portalProp == "string" ? ((_c = portal.elements) == null ? void 0 : _c[portalProp]) || null : portal.element, mounted = useMounted(), tooltipWidth = react.useMemo(() => {
|
|
4365
4364
|
const availableWidths = [
|
|
4366
4365
|
...boundaryElement ? [boundaryElement.offsetWidth] : [],
|
|
4367
|
-
|
|
4366
|
+
portalElement != null && portalElement.offsetWidth || mounted ? document.body.offsetWidth : (
|
|
4367
|
+
// We don't actually know what the width of the body is during SSR, so we'll just assume it's 800px or larger
|
|
4368
|
+
800
|
|
4369
|
+
)
|
|
4368
4370
|
];
|
|
4369
4371
|
return Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2;
|
|
4370
|
-
}, [boundaryElement,
|
|
4372
|
+
}, [boundaryElement, mounted, portalElement]), middleware = react.useMemo(() => {
|
|
4371
4373
|
const ret = [];
|
|
4372
4374
|
return ret.push(
|
|
4373
4375
|
reactDom$1.flip({
|
|
@@ -4439,14 +4441,6 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4439
4441
|
[childProp == null ? void 0 : childProp.props, handleIsOpenChange]
|
|
4440
4442
|
);
|
|
4441
4443
|
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(() => {
|
|
4450
4444
|
disabled && showTooltip && handleIsOpenChange(!1);
|
|
4451
4445
|
}, [disabled, handleIsOpenChange, showTooltip]), react.useEffect(() => {
|
|
4452
4446
|
!content && showTooltip && handleIsOpenChange(!1);
|
|
@@ -4458,7 +4452,7 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4458
4452
|
return window.addEventListener("keydown", handleWindowKeyDown), () => {
|
|
4459
4453
|
window.removeEventListener("keydown", handleWindowKeyDown);
|
|
4460
4454
|
};
|
|
4461
|
-
}, [handleIsOpenChange, showTooltip]);
|
|
4455
|
+
}, [handleIsOpenChange, showTooltip]), useCloseOnMouseLeave({ handleIsOpenChange, referenceElement, showTooltip });
|
|
4462
4456
|
const setArrow = react.useCallback(
|
|
4463
4457
|
(arrowEl) => {
|
|
4464
4458
|
arrowRef.current = arrowEl, update();
|
|
@@ -4542,8 +4536,21 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4542
4536
|
),
|
|
4543
4537
|
child
|
|
4544
4538
|
] });
|
|
4545
|
-
})
|
|
4546
|
-
|
|
4539
|
+
});
|
|
4540
|
+
function useCloseOnMouseLeave({
|
|
4541
|
+
handleIsOpenChange,
|
|
4542
|
+
referenceElement,
|
|
4543
|
+
showTooltip
|
|
4544
|
+
}) {
|
|
4545
|
+
const handleWindowMouseMove = useEffectEvent.useEffectEvent((event) => {
|
|
4546
|
+
referenceElement && (referenceElement === event.target || event.target instanceof Node && referenceElement.contains(event.target) || handleIsOpenChange(!1));
|
|
4547
|
+
});
|
|
4548
|
+
react.useEffect(() => {
|
|
4549
|
+
if (showTooltip)
|
|
4550
|
+
return window.addEventListener("mousemove", handleWindowMouseMove), () => window.removeEventListener("mousemove", handleWindowMouseMove);
|
|
4551
|
+
}, [handleWindowMouseMove, showTooltip]);
|
|
4552
|
+
}
|
|
4553
|
+
const Root$9 = styledComponents.styled.div`
|
|
4547
4554
|
line-height: 0;
|
|
4548
4555
|
`, ListBox = styledComponents.styled(Box)`
|
|
4549
4556
|
& > ul {
|
|
@@ -6238,15 +6245,7 @@ function Toast(props) {
|
|
|
6238
6245
|
}
|
|
6239
6246
|
);
|
|
6240
6247
|
}
|
|
6241
|
-
|
|
6242
|
-
return react.useSyncExternalStore(
|
|
6243
|
-
subscribe,
|
|
6244
|
-
() => !0,
|
|
6245
|
-
() => !1
|
|
6246
|
-
);
|
|
6247
|
-
}
|
|
6248
|
-
const subscribe = () => () => {
|
|
6249
|
-
}, key$1 = Symbol.for("@sanity/ui/context/toast"), ToastContext = createGlobalScopedContext(key$1, null), Root$1 = styledComponents.styled(Layer)`
|
|
6248
|
+
const key$1 = Symbol.for("@sanity/ui/context/toast"), ToastContext = createGlobalScopedContext(key$1, null), Root$1 = styledComponents.styled(Layer)`
|
|
6250
6249
|
position: fixed;
|
|
6251
6250
|
top: 0;
|
|
6252
6251
|
left: 0;
|