@sanity/ui 2.6.6 → 2.6.7
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 +47 -48
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +47 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -48
- 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 +24 -25
- 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 +49 -68
- 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 +10 -5
- 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"),
|
|
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");
|
|
4
4
|
function _interopDefaultCompat(e) {
|
|
5
5
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
6
6
|
}
|
|
@@ -3065,25 +3065,21 @@ 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
|
-
};
|
|
3077
3068
|
function PortalProvider(props) {
|
|
3078
|
-
const { boundaryElement, children, element, __unstable_elements: elementsProp } = props, elements = useUnique(elementsProp),
|
|
3069
|
+
const { boundaryElement, children, element, __unstable_elements: elementsProp } = props, elements = useUnique(elementsProp), fallbackElement = react.useSyncExternalStore(
|
|
3070
|
+
emptySubscribe$1,
|
|
3071
|
+
() => document.body,
|
|
3072
|
+
() => null
|
|
3073
|
+
), value = react.useMemo(() => ({
|
|
3079
3074
|
version: 0,
|
|
3080
3075
|
boundaryElement: boundaryElement || null,
|
|
3081
|
-
element: element ||
|
|
3076
|
+
element: element || fallbackElement,
|
|
3082
3077
|
elements
|
|
3083
|
-
}), [boundaryElement, element, elements,
|
|
3078
|
+
}), [boundaryElement, element, elements, fallbackElement]);
|
|
3084
3079
|
return /* @__PURE__ */ jsxRuntime.jsx(PortalContext.Provider, { value, children });
|
|
3085
3080
|
}
|
|
3086
|
-
const
|
|
3081
|
+
const emptySubscribe$1 = () => () => {
|
|
3082
|
+
}, Root$i = styledComponents.styled.div`
|
|
3087
3083
|
display: block;
|
|
3088
3084
|
width: 0;
|
|
3089
3085
|
height: 0;
|
|
@@ -4338,6 +4334,7 @@ function TooltipDelayGroupProvider(props) {
|
|
|
4338
4334
|
}
|
|
4339
4335
|
const Root$a = styledComponents.styled(Layer)`
|
|
4340
4336
|
pointer-events: none;
|
|
4337
|
+
max-width: ${({ $maxWidth }) => $maxWidth}px;
|
|
4341
4338
|
`, Tooltip = react.forwardRef(function(props, forwardedRef) {
|
|
4342
4339
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
4343
4340
|
const boundaryElementContext = useBoundaryElement(), { layer } = useTheme_v2(), {
|
|
@@ -4357,9 +4354,20 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4357
4354
|
zOffset = layer.tooltip.zOffset,
|
|
4358
4355
|
delay,
|
|
4359
4356
|
...restProps
|
|
4360
|
-
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, fallbackPlacements = useArrayProp(fallbackPlacementsProp), ref = react.useRef(null), [referenceElement, setReferenceElement] = react.useState(null), arrowRef = react.useRef(null), rootBoundary = "viewport"
|
|
4357
|
+
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, fallbackPlacements = useArrayProp(fallbackPlacementsProp), ref = react.useRef(null), [referenceElement, setReferenceElement] = react.useState(null), arrowRef = react.useRef(null), rootBoundary = "viewport";
|
|
4361
4358
|
react.useImperativeHandle(forwardedRef, () => ref.current);
|
|
4362
|
-
const portal = usePortal(), portalElement = typeof portalProp == "string" ? ((_c = portal.elements) == null ? void 0 : _c[portalProp]) || null : portal.element,
|
|
4359
|
+
const portal = usePortal(), portalElement = typeof portalProp == "string" ? ((_c = portal.elements) == null ? void 0 : _c[portalProp]) || null : portal.element, documentBodyOffsetWidth = react.useSyncExternalStore(
|
|
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(() => {
|
|
4363
4371
|
const ret = [];
|
|
4364
4372
|
return ret.push(
|
|
4365
4373
|
reactDom$1.flip({
|
|
@@ -4430,7 +4438,15 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4430
4438
|
},
|
|
4431
4439
|
[childProp == null ? void 0 : childProp.props, handleIsOpenChange]
|
|
4432
4440
|
);
|
|
4433
|
-
|
|
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(() => {
|
|
4434
4450
|
disabled && showTooltip && handleIsOpenChange(!1);
|
|
4435
4451
|
}, [disabled, handleIsOpenChange, showTooltip]), react.useEffect(() => {
|
|
4436
4452
|
!content && showTooltip && handleIsOpenChange(!1);
|
|
@@ -4442,13 +4458,7 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4442
4458
|
return window.addEventListener("keydown", handleWindowKeyDown), () => {
|
|
4443
4459
|
window.removeEventListener("keydown", handleWindowKeyDown);
|
|
4444
4460
|
};
|
|
4445
|
-
}, [handleIsOpenChange, showTooltip])
|
|
4446
|
-
const availableWidths = [
|
|
4447
|
-
...boundaryElement ? [boundaryElement.offsetWidth] : [],
|
|
4448
|
-
(portalElement == null ? void 0 : portalElement.offsetWidth) || document.body.offsetWidth
|
|
4449
|
-
];
|
|
4450
|
-
setTooltipMaxWidth(Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2);
|
|
4451
|
-
}, [boundaryElement, portalElement]);
|
|
4461
|
+
}, [handleIsOpenChange, showTooltip]);
|
|
4452
4462
|
const setArrow = react.useCallback(
|
|
4453
4463
|
(arrowEl) => {
|
|
4454
4464
|
arrowRef.current = arrowEl, update();
|
|
@@ -4489,11 +4499,9 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4489
4499
|
"data-ui": "Tooltip",
|
|
4490
4500
|
...restProps,
|
|
4491
4501
|
ref: setFloating,
|
|
4492
|
-
style:
|
|
4493
|
-
...floatingStyles,
|
|
4494
|
-
maxWidth: tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : void 0
|
|
4495
|
-
},
|
|
4502
|
+
style: floatingStyles,
|
|
4496
4503
|
zOffset,
|
|
4504
|
+
$maxWidth: tooltipWidth,
|
|
4497
4505
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4498
4506
|
TooltipCard,
|
|
4499
4507
|
{
|
|
@@ -4534,24 +4542,8 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4534
4542
|
),
|
|
4535
4543
|
child
|
|
4536
4544
|
] });
|
|
4537
|
-
})
|
|
4538
|
-
|
|
4539
|
-
handleIsOpenChange,
|
|
4540
|
-
referenceElement,
|
|
4541
|
-
showTooltip
|
|
4542
|
-
}) {
|
|
4543
|
-
const onMouseMove = useEffectEvent.useEffectEvent((target, teardown) => {
|
|
4544
|
-
referenceElement && (referenceElement === target || target instanceof Node && referenceElement.contains(target) || (handleIsOpenChange(!1), teardown()));
|
|
4545
|
-
});
|
|
4546
|
-
react.useEffect(() => {
|
|
4547
|
-
if (!showTooltip) return;
|
|
4548
|
-
const handleMouseMove = (event) => {
|
|
4549
|
-
onMouseMove(event.target, () => window.removeEventListener("mousemove", handleMouseMove));
|
|
4550
|
-
};
|
|
4551
|
-
return window.addEventListener("mousemove", handleMouseMove), () => window.removeEventListener("mousemove", handleMouseMove);
|
|
4552
|
-
}, [onMouseMove, showTooltip]);
|
|
4553
|
-
}
|
|
4554
|
-
const Root$9 = styledComponents.styled.div`
|
|
4545
|
+
}), emptySubscribe = () => () => {
|
|
4546
|
+
}, Root$9 = styledComponents.styled.div`
|
|
4555
4547
|
line-height: 0;
|
|
4556
4548
|
`, ListBox = styledComponents.styled(Box)`
|
|
4557
4549
|
& > ul {
|
|
@@ -6246,7 +6238,15 @@ function Toast(props) {
|
|
|
6246
6238
|
}
|
|
6247
6239
|
);
|
|
6248
6240
|
}
|
|
6249
|
-
|
|
6241
|
+
function useMounted() {
|
|
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)`
|
|
6250
6250
|
position: fixed;
|
|
6251
6251
|
top: 0;
|
|
6252
6252
|
left: 0;
|