@sanity/ui 2.6.7 → 2.6.8-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 +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.esm.js +36 -31
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +35 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -31
- 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 +46 -53
- 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 +68 -49
- package/src/core/styles/font/responsiveFont.ts +8 -8
- package/src/core/theme/__workshop__/debug/story.tsx +11 -11
- 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.d.mts
CHANGED
|
@@ -2069,7 +2069,7 @@ export declare interface TabPanelProps extends BoxProps {
|
|
|
2069
2069
|
* The `id` of the correlating `Tab` component.
|
|
2070
2070
|
*/
|
|
2071
2071
|
'aria-labelledby': string
|
|
2072
|
-
id: string
|
|
2072
|
+
'id': string
|
|
2073
2073
|
}
|
|
2074
2074
|
|
|
2075
2075
|
/**
|
|
@@ -2080,14 +2080,14 @@ export declare interface TabProps {
|
|
|
2080
2080
|
* The `id` of the correlating `TabPanel` component.
|
|
2081
2081
|
*/
|
|
2082
2082
|
'aria-controls': string
|
|
2083
|
-
id: string
|
|
2084
|
-
icon?: React.ElementType | React.ReactNode
|
|
2085
|
-
focused?: boolean
|
|
2086
|
-
fontSize?: number | number[]
|
|
2087
|
-
label?: React.ReactNode
|
|
2088
|
-
padding?: number | number[]
|
|
2089
|
-
selected?: boolean
|
|
2090
|
-
tone?: ButtonTone
|
|
2083
|
+
'id': string
|
|
2084
|
+
'icon'?: React.ElementType | React.ReactNode
|
|
2085
|
+
'focused'?: boolean
|
|
2086
|
+
'fontSize'?: number | number[]
|
|
2087
|
+
'label'?: React.ReactNode
|
|
2088
|
+
'padding'?: number | number[]
|
|
2089
|
+
'selected'?: boolean
|
|
2090
|
+
'tone'?: ButtonTone
|
|
2091
2091
|
}
|
|
2092
2092
|
|
|
2093
2093
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -2069,7 +2069,7 @@ export declare interface TabPanelProps extends BoxProps {
|
|
|
2069
2069
|
* The `id` of the correlating `Tab` component.
|
|
2070
2070
|
*/
|
|
2071
2071
|
'aria-labelledby': string
|
|
2072
|
-
id: string
|
|
2072
|
+
'id': string
|
|
2073
2073
|
}
|
|
2074
2074
|
|
|
2075
2075
|
/**
|
|
@@ -2080,14 +2080,14 @@ export declare interface TabProps {
|
|
|
2080
2080
|
* The `id` of the correlating `TabPanel` component.
|
|
2081
2081
|
*/
|
|
2082
2082
|
'aria-controls': string
|
|
2083
|
-
id: string
|
|
2084
|
-
icon?: React.ElementType | React.ReactNode
|
|
2085
|
-
focused?: boolean
|
|
2086
|
-
fontSize?: number | number[]
|
|
2087
|
-
label?: React.ReactNode
|
|
2088
|
-
padding?: number | number[]
|
|
2089
|
-
selected?: boolean
|
|
2090
|
-
tone?: ButtonTone
|
|
2083
|
+
'id': string
|
|
2084
|
+
'icon'?: React.ElementType | React.ReactNode
|
|
2085
|
+
'focused'?: boolean
|
|
2086
|
+
'fontSize'?: number | number[]
|
|
2087
|
+
'label'?: React.ReactNode
|
|
2088
|
+
'padding'?: number | number[]
|
|
2089
|
+
'selected'?: boolean
|
|
2090
|
+
'tone'?: ButtonTone
|
|
2091
2091
|
}
|
|
2092
2092
|
|
|
2093
2093
|
/**
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { buildTheme, createColorTheme as createColorTheme$1, hexToRgb as hexToRgb$1, hslToRgb as hslToRgb$1, multiply as multiply$1, parseColor as parseColor$1, rgbToHex as rgbToHex$1, rgbToHsl as rgbToHsl$1, rgba as rgba$1, screen as screen$1, getTheme_v2, getScopedTheme } from "@sanity/ui/theme";
|
|
2
2
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { useMemo, useState, useRef, useEffect, createContext, useContext, useSyncExternalStore, useImperativeHandle, forwardRef, useId, useCallback, Children, isValidElement, cloneElement, Component, memo, useReducer, Fragment as Fragment$1, startTransition } from "react";
|
|
3
|
+
import { useMemo, useState, useRef, useEffect, createContext, useContext, useSyncExternalStore, useImperativeHandle, forwardRef, useId, useCallback, Children, isValidElement, cloneElement, Component, memo, useLayoutEffect, useReducer, Fragment as Fragment$1, startTransition } from "react";
|
|
4
4
|
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";
|
|
@@ -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 "./_legacy/getTheme_v2.esm.js";
|
|
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: {
|
|
@@ -3071,7 +3072,7 @@ function _isEqual(objA, objB) {
|
|
|
3071
3072
|
}
|
|
3072
3073
|
function PortalProvider(props) {
|
|
3073
3074
|
const { boundaryElement, children, element, __unstable_elements: elementsProp } = props, elements = useUnique(elementsProp), fallbackElement = useSyncExternalStore(
|
|
3074
|
-
emptySubscribe
|
|
3075
|
+
emptySubscribe,
|
|
3075
3076
|
() => document.body,
|
|
3076
3077
|
() => null
|
|
3077
3078
|
), value = useMemo(() => ({
|
|
@@ -3082,7 +3083,7 @@ function PortalProvider(props) {
|
|
|
3082
3083
|
}), [boundaryElement, element, elements, fallbackElement]);
|
|
3083
3084
|
return /* @__PURE__ */ jsx(PortalContext.Provider, { value, children });
|
|
3084
3085
|
}
|
|
3085
|
-
const emptySubscribe
|
|
3086
|
+
const emptySubscribe = () => () => {
|
|
3086
3087
|
}, Root$i = styled.div`
|
|
3087
3088
|
display: block;
|
|
3088
3089
|
width: 0;
|
|
@@ -4338,7 +4339,6 @@ function TooltipDelayGroupProvider(props) {
|
|
|
4338
4339
|
}
|
|
4339
4340
|
const Root$a = styled(Layer)`
|
|
4340
4341
|
pointer-events: none;
|
|
4341
|
-
max-width: ${({ $maxWidth }) => $maxWidth}px;
|
|
4342
4342
|
`, Tooltip = forwardRef(function(props, forwardedRef) {
|
|
4343
4343
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
4344
4344
|
const boundaryElementContext = useBoundaryElement(), { layer } = useTheme_v2(), {
|
|
@@ -4358,20 +4358,9 @@ const Root$a = styled(Layer)`
|
|
|
4358
4358
|
zOffset = layer.tooltip.zOffset,
|
|
4359
4359
|
delay,
|
|
4360
4360
|
...restProps
|
|
4361
|
-
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, fallbackPlacements = useArrayProp(fallbackPlacementsProp), ref = useRef(null), [referenceElement, setReferenceElement] = useState(null), arrowRef = useRef(null), rootBoundary = "viewport";
|
|
4361
|
+
} = props, animate = usePrefersReducedMotion() ? !1 : _animate, fallbackPlacements = useArrayProp(fallbackPlacementsProp), ref = useRef(null), [referenceElement, setReferenceElement] = useState(null), arrowRef = useRef(null), rootBoundary = "viewport", [tooltipMaxWidth, setTooltipMaxWidth] = useState(0);
|
|
4362
4362
|
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(() => {
|
|
4363
|
+
const portal = usePortal(), portalElement = typeof portalProp == "string" ? ((_c = portal.elements) == null ? void 0 : _c[portalProp]) || null : portal.element, middleware = useMemo(() => {
|
|
4375
4364
|
const ret = [];
|
|
4376
4365
|
return ret.push(
|
|
4377
4366
|
flip({
|
|
@@ -4442,15 +4431,7 @@ const Root$a = styled(Layer)`
|
|
|
4442
4431
|
},
|
|
4443
4432
|
[childProp == null ? void 0 : childProp.props, handleIsOpenChange]
|
|
4444
4433
|
);
|
|
4445
|
-
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(() => {
|
|
4434
|
+
useCloseOnMouseLeave({ handleIsOpenChange, referenceElement, showTooltip }), useEffect(() => {
|
|
4454
4435
|
disabled && showTooltip && handleIsOpenChange(!1);
|
|
4455
4436
|
}, [disabled, handleIsOpenChange, showTooltip]), useEffect(() => {
|
|
4456
4437
|
!content && showTooltip && handleIsOpenChange(!1);
|
|
@@ -4462,7 +4443,13 @@ const Root$a = styled(Layer)`
|
|
|
4462
4443
|
return window.addEventListener("keydown", handleWindowKeyDown), () => {
|
|
4463
4444
|
window.removeEventListener("keydown", handleWindowKeyDown);
|
|
4464
4445
|
};
|
|
4465
|
-
}, [handleIsOpenChange, showTooltip])
|
|
4446
|
+
}, [handleIsOpenChange, showTooltip]), useLayoutEffect(() => {
|
|
4447
|
+
const availableWidths = [
|
|
4448
|
+
...boundaryElement ? [boundaryElement.offsetWidth] : [],
|
|
4449
|
+
(portalElement == null ? void 0 : portalElement.offsetWidth) || document.body.offsetWidth
|
|
4450
|
+
];
|
|
4451
|
+
setTooltipMaxWidth(Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2);
|
|
4452
|
+
}, [boundaryElement, portalElement]);
|
|
4466
4453
|
const setArrow = useCallback(
|
|
4467
4454
|
(arrowEl) => {
|
|
4468
4455
|
arrowRef.current = arrowEl, update();
|
|
@@ -4503,9 +4490,11 @@ const Root$a = styled(Layer)`
|
|
|
4503
4490
|
"data-ui": "Tooltip",
|
|
4504
4491
|
...restProps,
|
|
4505
4492
|
ref: setFloating,
|
|
4506
|
-
style:
|
|
4493
|
+
style: {
|
|
4494
|
+
...floatingStyles,
|
|
4495
|
+
maxWidth: tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : void 0
|
|
4496
|
+
},
|
|
4507
4497
|
zOffset,
|
|
4508
|
-
$maxWidth: tooltipWidth,
|
|
4509
4498
|
children: /* @__PURE__ */ jsx(
|
|
4510
4499
|
TooltipCard,
|
|
4511
4500
|
{
|
|
@@ -4546,8 +4535,24 @@ const Root$a = styled(Layer)`
|
|
|
4546
4535
|
),
|
|
4547
4536
|
child
|
|
4548
4537
|
] });
|
|
4549
|
-
})
|
|
4550
|
-
|
|
4538
|
+
});
|
|
4539
|
+
function useCloseOnMouseLeave({
|
|
4540
|
+
handleIsOpenChange,
|
|
4541
|
+
referenceElement,
|
|
4542
|
+
showTooltip
|
|
4543
|
+
}) {
|
|
4544
|
+
const onMouseMove = useEffectEvent((target, teardown) => {
|
|
4545
|
+
referenceElement && (referenceElement === target || target instanceof Node && referenceElement.contains(target) || (handleIsOpenChange(!1), teardown()));
|
|
4546
|
+
});
|
|
4547
|
+
useEffect(() => {
|
|
4548
|
+
if (!showTooltip) return;
|
|
4549
|
+
const handleMouseMove = (event) => {
|
|
4550
|
+
onMouseMove(event.target, () => window.removeEventListener("mousemove", handleMouseMove));
|
|
4551
|
+
};
|
|
4552
|
+
return window.addEventListener("mousemove", handleMouseMove), () => window.removeEventListener("mousemove", handleMouseMove);
|
|
4553
|
+
}, [onMouseMove, showTooltip]);
|
|
4554
|
+
}
|
|
4555
|
+
const Root$9 = styled.div`
|
|
4551
4556
|
line-height: 0;
|
|
4552
4557
|
`, ListBox = styled(Box)`
|
|
4553
4558
|
& > ul {
|