@sanity/ui 2.0.0-alpha.17 → 2.0.0-alpha.18
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.ts +4 -0
- package/dist/index.esm.js +31 -18
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +31 -18
- package/dist/index.js.map +1 -1
- package/package.json +4 -6
- package/src/primitives/avatar/avatar.tsx +14 -9
- package/src/primitives/avatar/avatarCounter.tsx +3 -3
- package/src/primitives/avatar/styles.ts +1 -1
- package/src/primitives/button/__workshop__/sanityUploadButton.tsx +2 -1
- package/src/primitives/tooltip/tooltip.test.tsx +67 -0
- package/src/primitives/tooltip/tooltip.tsx +25 -5
- package/src/theme/lib/theme/avatar.ts +2 -0
- package/src/theme/studioTheme/theme.ts +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -263,6 +263,8 @@ export declare interface AvatarProps {
|
|
|
263
263
|
arrowPosition?: AvatarPosition
|
|
264
264
|
as?: React.ElementType | keyof JSX.IntrinsicElements
|
|
265
265
|
color?: ThemeColorSpotKey
|
|
266
|
+
/** @beta */
|
|
267
|
+
hideInnerStroke?: boolean
|
|
266
268
|
initials?: string
|
|
267
269
|
onImageLoadError?: (event: Error) => void
|
|
268
270
|
size?: AvatarSize | AvatarSize[]
|
|
@@ -2744,7 +2746,9 @@ export declare interface Theme {
|
|
|
2744
2746
|
*/
|
|
2745
2747
|
export declare interface ThemeAvatar {
|
|
2746
2748
|
sizes: {
|
|
2749
|
+
/** Distance between avatars in an <AvatarStack> component (px) */
|
|
2747
2750
|
distance: number
|
|
2751
|
+
/** Diameter (px) */
|
|
2748
2752
|
size: number
|
|
2749
2753
|
}[]
|
|
2750
2754
|
focusRing: FocusRing
|
package/dist/index.esm.js
CHANGED
|
@@ -3823,16 +3823,16 @@ const studioTheme = {
|
|
|
3823
3823
|
avatar: {
|
|
3824
3824
|
sizes: [{
|
|
3825
3825
|
distance: -3,
|
|
3826
|
-
size:
|
|
3826
|
+
size: 23
|
|
3827
3827
|
}, {
|
|
3828
3828
|
distance: -6,
|
|
3829
|
-
size:
|
|
3829
|
+
size: 33
|
|
3830
3830
|
}, {
|
|
3831
3831
|
distance: -9,
|
|
3832
|
-
size:
|
|
3832
|
+
size: 53
|
|
3833
3833
|
}],
|
|
3834
3834
|
focusRing: {
|
|
3835
|
-
offset:
|
|
3835
|
+
offset: 0,
|
|
3836
3836
|
width: 1
|
|
3837
3837
|
}
|
|
3838
3838
|
},
|
|
@@ -5004,7 +5004,7 @@ function avatarBgStrokeStyle() {
|
|
|
5004
5004
|
}
|
|
5005
5005
|
function avatarStrokeStyle() {
|
|
5006
5006
|
return {
|
|
5007
|
-
strokeWidth: "
|
|
5007
|
+
strokeWidth: "2px",
|
|
5008
5008
|
'[data-status="editing"] &': {
|
|
5009
5009
|
strokeDasharray: "2 4",
|
|
5010
5010
|
strokeLinecap: "round"
|
|
@@ -5026,6 +5026,7 @@ const Avatar = forwardRef(function Avatar2(props, ref) {
|
|
|
5026
5026
|
onImageLoadError,
|
|
5027
5027
|
arrowPosition: arrowPositionProp,
|
|
5028
5028
|
animateArrowFrom,
|
|
5029
|
+
hideInnerStroke,
|
|
5029
5030
|
status = "online",
|
|
5030
5031
|
size: sizeProp = 0,
|
|
5031
5032
|
...restProps
|
|
@@ -5100,7 +5101,7 @@ const Avatar = forwardRef(function Avatar2(props, ref) {
|
|
|
5100
5101
|
cy: _radius,
|
|
5101
5102
|
r: _radius,
|
|
5102
5103
|
fill: "url(#".concat(imageId, ")")
|
|
5103
|
-
}), /* @__PURE__ */jsx(BgStroke, {
|
|
5104
|
+
}), !hideInnerStroke && /* @__PURE__ */jsx(BgStroke, {
|
|
5104
5105
|
cx: _radius,
|
|
5105
5106
|
cy: _radius,
|
|
5106
5107
|
rx: _radius,
|
|
@@ -5119,9 +5120,8 @@ const Avatar = forwardRef(function Avatar2(props, ref) {
|
|
|
5119
5120
|
children: /* @__PURE__ */jsx(Text, {
|
|
5120
5121
|
as: "span",
|
|
5121
5122
|
size: initialsSize,
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
})
|
|
5123
|
+
weight: "medium",
|
|
5124
|
+
children: initials
|
|
5125
5125
|
})
|
|
5126
5126
|
})
|
|
5127
5127
|
})]
|
|
@@ -5155,7 +5155,7 @@ function _avatarCounterBaseStyle(props) {
|
|
|
5155
5155
|
const {
|
|
5156
5156
|
theme
|
|
5157
5157
|
} = props;
|
|
5158
|
-
return css(_a$A || (_a$A = __template$A(["\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n user-select: none;\n color: inherit;\n color: var(--card-fg-color);\n background: var(--card-bg-color);\n box-shadow:\n 0 0 0 1px var(--card-bg-color),\n inset 0 0 0
|
|
5158
|
+
return css(_a$A || (_a$A = __template$A(["\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n user-select: none;\n color: inherit;\n color: var(--card-fg-color);\n background: var(--card-bg-color);\n box-shadow:\n 0 0 0 1px var(--card-bg-color),\n inset 0 0 0 1px var(--card-hairline-hard-color);\n padding: 0 ", ";\n\n &:not([hidden]) {\n display: flex;\n }\n "])), rem(theme.sanity.space[2]));
|
|
5159
5159
|
}
|
|
5160
5160
|
const Root$C = styled.div(_responsiveAvatarCounterSizeStyle, _avatarCounterBaseStyle);
|
|
5161
5161
|
const AvatarCounter = forwardRef(function AvatarCounter2(props, ref) {
|
|
@@ -5172,9 +5172,8 @@ const AvatarCounter = forwardRef(function AvatarCounter2(props, ref) {
|
|
|
5172
5172
|
children: /* @__PURE__ */jsx(Text, {
|
|
5173
5173
|
as: "span",
|
|
5174
5174
|
size: counterSize,
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
})
|
|
5175
|
+
weight: "medium",
|
|
5176
|
+
children: count
|
|
5178
5177
|
})
|
|
5179
5178
|
});
|
|
5180
5179
|
});
|
|
@@ -7981,19 +7980,21 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
|
7981
7980
|
const closeDelayProp = typeof delay === "number" ? delay : (delay == null ? void 0 : delay.close) || 0;
|
|
7982
7981
|
const openDelay = isInsideGroup ? delayGroupContext.openDelay : openDelayProp;
|
|
7983
7982
|
const closeDelay = isInsideGroup ? delayGroupContext.closeDelay : closeDelayProp;
|
|
7984
|
-
const handleIsOpenChange = useCallback(open => {
|
|
7983
|
+
const handleIsOpenChange = useCallback((open, immediate) => {
|
|
7985
7984
|
if (isInsideGroup) {
|
|
7986
7985
|
if (open) {
|
|
7987
|
-
|
|
7988
|
-
delayGroupContext.
|
|
7986
|
+
const groupedOpenDelay = immediate ? 0 : openDelay;
|
|
7987
|
+
delayGroupContext.setIsGroupActive(open, groupedOpenDelay);
|
|
7988
|
+
delayGroupContext.setOpenTooltipId(tooltipId, groupedOpenDelay);
|
|
7989
7989
|
} else {
|
|
7990
7990
|
const minimumGroupDeactivateDelay = 200;
|
|
7991
7991
|
const groupDeactivateDelay = closeDelay > minimumGroupDeactivateDelay ? closeDelay : minimumGroupDeactivateDelay;
|
|
7992
7992
|
delayGroupContext.setIsGroupActive(open, groupDeactivateDelay);
|
|
7993
|
-
delayGroupContext.setOpenTooltipId(null, closeDelay);
|
|
7993
|
+
delayGroupContext.setOpenTooltipId(null, immediate ? 0 : closeDelay);
|
|
7994
7994
|
}
|
|
7995
7995
|
} else {
|
|
7996
|
-
|
|
7996
|
+
const standaloneDelay = immediate ? 0 : open ? openDelay : closeDelay;
|
|
7997
|
+
setIsOpen(open, standaloneDelay);
|
|
7997
7998
|
}
|
|
7998
7999
|
}, [isInsideGroup, delayGroupContext, openDelay, tooltipId, closeDelay, setIsOpen]);
|
|
7999
8000
|
const handleBlur = useCallback(() => handleIsOpenChange(false), [handleIsOpenChange]);
|
|
@@ -8022,6 +8023,18 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
|
8022
8023
|
if (!content) handleIsOpenChange(false);
|
|
8023
8024
|
}, [content, handleIsOpenChange]);
|
|
8024
8025
|
useEffect(() => refs.setReference(referenceElement), [referenceElement, refs]);
|
|
8026
|
+
useEffect(() => {
|
|
8027
|
+
if (!showTooltip) return;
|
|
8028
|
+
function handleWindowKeyDown(event) {
|
|
8029
|
+
if (event.key === "Escape") {
|
|
8030
|
+
handleIsOpenChange(false, true);
|
|
8031
|
+
}
|
|
8032
|
+
}
|
|
8033
|
+
window.addEventListener("keydown", handleWindowKeyDown);
|
|
8034
|
+
return () => {
|
|
8035
|
+
window.removeEventListener("keydown", handleWindowKeyDown);
|
|
8036
|
+
};
|
|
8037
|
+
}, [handleIsOpenChange, showTooltip]);
|
|
8025
8038
|
const setArrow = useCallback(arrowEl => {
|
|
8026
8039
|
arrowRef.current = arrowEl;
|
|
8027
8040
|
update();
|