@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.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
|
-
|
|
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
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
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,
|
|
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";
|
|
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,7 +8,6 @@ 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";
|
|
12
11
|
import { getTheme_v2 as getTheme_v2$1 } from "./_legacy/getTheme_v2.esm.js";
|
|
13
12
|
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 = {
|
|
14
13
|
initial: {
|
|
@@ -3070,25 +3069,21 @@ function _isEqual(objA, objB) {
|
|
|
3070
3069
|
const keysA = Object.keys(objA), keysB = Object.keys(objB);
|
|
3071
3070
|
return keysA.length !== keysB.length ? !1 : keysA.every((key2) => objA[key2] === objB[key2]);
|
|
3072
3071
|
}
|
|
3073
|
-
function useMounted() {
|
|
3074
|
-
return useSyncExternalStore(
|
|
3075
|
-
subscribe,
|
|
3076
|
-
() => !0,
|
|
3077
|
-
() => !1
|
|
3078
|
-
);
|
|
3079
|
-
}
|
|
3080
|
-
const subscribe = () => () => {
|
|
3081
|
-
};
|
|
3082
3072
|
function PortalProvider(props) {
|
|
3083
|
-
const { boundaryElement, children, element, __unstable_elements: elementsProp } = props, elements = useUnique(elementsProp),
|
|
3073
|
+
const { boundaryElement, children, element, __unstable_elements: elementsProp } = props, elements = useUnique(elementsProp), fallbackElement = useSyncExternalStore(
|
|
3074
|
+
emptySubscribe$1,
|
|
3075
|
+
() => document.body,
|
|
3076
|
+
() => null
|
|
3077
|
+
), value = useMemo(() => ({
|
|
3084
3078
|
version: 0,
|
|
3085
3079
|
boundaryElement: boundaryElement || null,
|
|
3086
|
-
element: element ||
|
|
3080
|
+
element: element || fallbackElement,
|
|
3087
3081
|
elements
|
|
3088
|
-
}), [boundaryElement, element, elements,
|
|
3082
|
+
}), [boundaryElement, element, elements, fallbackElement]);
|
|
3089
3083
|
return /* @__PURE__ */ jsx(PortalContext.Provider, { value, children });
|
|
3090
3084
|
}
|
|
3091
|
-
const
|
|
3085
|
+
const emptySubscribe$1 = () => () => {
|
|
3086
|
+
}, Root$i = styled.div`
|
|
3092
3087
|
display: block;
|
|
3093
3088
|
width: 0;
|
|
3094
3089
|
height: 0;
|
|
@@ -4343,6 +4338,7 @@ function TooltipDelayGroupProvider(props) {
|
|
|
4343
4338
|
}
|
|
4344
4339
|
const Root$a = styled(Layer)`
|
|
4345
4340
|
pointer-events: none;
|
|
4341
|
+
max-width: ${({ $maxWidth }) => $maxWidth}px;
|
|
4346
4342
|
`, Tooltip = forwardRef(function(props, forwardedRef) {
|
|
4347
4343
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
4348
4344
|
const boundaryElementContext = useBoundaryElement(), { layer } = useTheme_v2(), {
|
|
@@ -4362,9 +4358,20 @@ const Root$a = styled(Layer)`
|
|
|
4362
4358
|
zOffset = layer.tooltip.zOffset,
|
|
4363
4359
|
delay,
|
|
4364
4360
|
...restProps
|
|
4365
|
-
} = 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";
|
|
4366
4362
|
useImperativeHandle(forwardedRef, () => ref.current);
|
|
4367
|
-
const portal = usePortal(), portalElement = typeof portalProp == "string" ? ((_c = portal.elements) == null ? void 0 : _c[portalProp]) || null : portal.element,
|
|
4363
|
+
const portal = usePortal(), portalElement = typeof portalProp == "string" ? ((_c = portal.elements) == null ? void 0 : _c[portalProp]) || null : portal.element, documentBodyOffsetWidth = useSyncExternalStore(
|
|
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(() => {
|
|
4368
4375
|
const ret = [];
|
|
4369
4376
|
return ret.push(
|
|
4370
4377
|
flip({
|
|
@@ -4435,7 +4442,15 @@ const Root$a = styled(Layer)`
|
|
|
4435
4442
|
},
|
|
4436
4443
|
[childProp == null ? void 0 : childProp.props, handleIsOpenChange]
|
|
4437
4444
|
);
|
|
4438
|
-
|
|
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(() => {
|
|
4439
4454
|
disabled && showTooltip && handleIsOpenChange(!1);
|
|
4440
4455
|
}, [disabled, handleIsOpenChange, showTooltip]), useEffect(() => {
|
|
4441
4456
|
!content && showTooltip && handleIsOpenChange(!1);
|
|
@@ -4447,13 +4462,7 @@ const Root$a = styled(Layer)`
|
|
|
4447
4462
|
return window.addEventListener("keydown", handleWindowKeyDown), () => {
|
|
4448
4463
|
window.removeEventListener("keydown", handleWindowKeyDown);
|
|
4449
4464
|
};
|
|
4450
|
-
}, [handleIsOpenChange, showTooltip])
|
|
4451
|
-
const availableWidths = [
|
|
4452
|
-
...boundaryElement ? [boundaryElement.offsetWidth] : [],
|
|
4453
|
-
(portalElement == null ? void 0 : portalElement.offsetWidth) || document.body.offsetWidth
|
|
4454
|
-
];
|
|
4455
|
-
setTooltipMaxWidth(Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2);
|
|
4456
|
-
}, [boundaryElement, portalElement]);
|
|
4465
|
+
}, [handleIsOpenChange, showTooltip]);
|
|
4457
4466
|
const setArrow = useCallback(
|
|
4458
4467
|
(arrowEl) => {
|
|
4459
4468
|
arrowRef.current = arrowEl, update();
|
|
@@ -4494,11 +4503,9 @@ const Root$a = styled(Layer)`
|
|
|
4494
4503
|
"data-ui": "Tooltip",
|
|
4495
4504
|
...restProps,
|
|
4496
4505
|
ref: setFloating,
|
|
4497
|
-
style:
|
|
4498
|
-
...floatingStyles,
|
|
4499
|
-
maxWidth: tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : void 0
|
|
4500
|
-
},
|
|
4506
|
+
style: floatingStyles,
|
|
4501
4507
|
zOffset,
|
|
4508
|
+
$maxWidth: tooltipWidth,
|
|
4502
4509
|
children: /* @__PURE__ */ jsx(
|
|
4503
4510
|
TooltipCard,
|
|
4504
4511
|
{
|
|
@@ -4539,24 +4546,8 @@ const Root$a = styled(Layer)`
|
|
|
4539
4546
|
),
|
|
4540
4547
|
child
|
|
4541
4548
|
] });
|
|
4542
|
-
})
|
|
4543
|
-
|
|
4544
|
-
handleIsOpenChange,
|
|
4545
|
-
referenceElement,
|
|
4546
|
-
showTooltip
|
|
4547
|
-
}) {
|
|
4548
|
-
const onMouseMove = useEffectEvent((target, teardown) => {
|
|
4549
|
-
referenceElement && (referenceElement === target || target instanceof Node && referenceElement.contains(target) || (handleIsOpenChange(!1), teardown()));
|
|
4550
|
-
});
|
|
4551
|
-
useEffect(() => {
|
|
4552
|
-
if (!showTooltip) return;
|
|
4553
|
-
const handleMouseMove = (event) => {
|
|
4554
|
-
onMouseMove(event.target, () => window.removeEventListener("mousemove", handleMouseMove));
|
|
4555
|
-
};
|
|
4556
|
-
return window.addEventListener("mousemove", handleMouseMove), () => window.removeEventListener("mousemove", handleMouseMove);
|
|
4557
|
-
}, [onMouseMove, showTooltip]);
|
|
4558
|
-
}
|
|
4559
|
-
const Root$9 = styled.div`
|
|
4549
|
+
}), emptySubscribe = () => () => {
|
|
4550
|
+
}, Root$9 = styled.div`
|
|
4560
4551
|
line-height: 0;
|
|
4561
4552
|
`, ListBox = styled(Box)`
|
|
4562
4553
|
& > ul {
|
|
@@ -6251,7 +6242,15 @@ function Toast(props) {
|
|
|
6251
6242
|
}
|
|
6252
6243
|
);
|
|
6253
6244
|
}
|
|
6254
|
-
|
|
6245
|
+
function useMounted() {
|
|
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)`
|
|
6255
6254
|
position: fixed;
|
|
6256
6255
|
top: 0;
|
|
6257
6256
|
left: 0;
|