@sanity/ui 2.0.0-alpha.17 → 2.0.0-alpha.19
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 +8 -0
- package/dist/index.esm.js +37 -21
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +37 -21
- 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/textInput/textInput.tsx +7 -0
- package/src/primitives/tooltip/tooltip.test.tsx +67 -0
- package/src/primitives/tooltip/tooltip.tsx +25 -5
- package/src/styles/input/textInputStyle.ts +11 -6
- 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[]
|
|
@@ -2672,6 +2674,10 @@ export declare interface TextInputProps {
|
|
|
2672
2674
|
suffix?: React.ReactNode
|
|
2673
2675
|
type?: TextInputType
|
|
2674
2676
|
weight?: ThemeFontWeightKey
|
|
2677
|
+
/**
|
|
2678
|
+
* @beta
|
|
2679
|
+
*/
|
|
2680
|
+
unstableDisableFocusRing?: boolean
|
|
2675
2681
|
}
|
|
2676
2682
|
|
|
2677
2683
|
/**
|
|
@@ -2744,7 +2750,9 @@ export declare interface Theme {
|
|
|
2744
2750
|
*/
|
|
2745
2751
|
export declare interface ThemeAvatar {
|
|
2746
2752
|
sizes: {
|
|
2753
|
+
/** Distance between avatars in an <AvatarStack> component (px) */
|
|
2747
2754
|
distance: number
|
|
2755
|
+
/** Diameter (px) */
|
|
2748
2756
|
size: number
|
|
2749
2757
|
}[]
|
|
2750
2758
|
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
|
},
|
|
@@ -4720,6 +4720,7 @@ function textInputRepresentationStyle(props) {
|
|
|
4720
4720
|
$hasSuffix,
|
|
4721
4721
|
$scheme,
|
|
4722
4722
|
$tone,
|
|
4723
|
+
$unstableDisableFocusRing,
|
|
4723
4724
|
theme
|
|
4724
4725
|
} = props;
|
|
4725
4726
|
const {
|
|
@@ -4735,13 +4736,13 @@ function textInputRepresentationStyle(props) {
|
|
|
4735
4736
|
}), color.invalid.enabled.bg, color.invalid.enabled.fg, focusRingBorderStyle({
|
|
4736
4737
|
color: color.invalid.enabled.border,
|
|
4737
4738
|
width: input.border.width
|
|
4738
|
-
}), focusRingStyle({
|
|
4739
|
+
}), $unstableDisableFocusRing ? void 0 : focusRingStyle({
|
|
4739
4740
|
border: {
|
|
4740
4741
|
color: color.default.enabled.border,
|
|
4741
4742
|
width: input.border.width
|
|
4742
4743
|
},
|
|
4743
4744
|
focusRing
|
|
4744
|
-
}), focusRingStyle({
|
|
4745
|
+
}), $unstableDisableFocusRing ? void 0 : focusRingStyle({
|
|
4745
4746
|
focusRing
|
|
4746
4747
|
}), color.default.disabled.bg, color.default.disabled.fg, focusRingBorderStyle({
|
|
4747
4748
|
color: color.default.disabled.border,
|
|
@@ -5004,7 +5005,7 @@ function avatarBgStrokeStyle() {
|
|
|
5004
5005
|
}
|
|
5005
5006
|
function avatarStrokeStyle() {
|
|
5006
5007
|
return {
|
|
5007
|
-
strokeWidth: "
|
|
5008
|
+
strokeWidth: "2px",
|
|
5008
5009
|
'[data-status="editing"] &': {
|
|
5009
5010
|
strokeDasharray: "2 4",
|
|
5010
5011
|
strokeLinecap: "round"
|
|
@@ -5026,6 +5027,7 @@ const Avatar = forwardRef(function Avatar2(props, ref) {
|
|
|
5026
5027
|
onImageLoadError,
|
|
5027
5028
|
arrowPosition: arrowPositionProp,
|
|
5028
5029
|
animateArrowFrom,
|
|
5030
|
+
hideInnerStroke,
|
|
5029
5031
|
status = "online",
|
|
5030
5032
|
size: sizeProp = 0,
|
|
5031
5033
|
...restProps
|
|
@@ -5100,7 +5102,7 @@ const Avatar = forwardRef(function Avatar2(props, ref) {
|
|
|
5100
5102
|
cy: _radius,
|
|
5101
5103
|
r: _radius,
|
|
5102
5104
|
fill: "url(#".concat(imageId, ")")
|
|
5103
|
-
}), /* @__PURE__ */jsx(BgStroke, {
|
|
5105
|
+
}), !hideInnerStroke && /* @__PURE__ */jsx(BgStroke, {
|
|
5104
5106
|
cx: _radius,
|
|
5105
5107
|
cy: _radius,
|
|
5106
5108
|
rx: _radius,
|
|
@@ -5119,9 +5121,8 @@ const Avatar = forwardRef(function Avatar2(props, ref) {
|
|
|
5119
5121
|
children: /* @__PURE__ */jsx(Text, {
|
|
5120
5122
|
as: "span",
|
|
5121
5123
|
size: initialsSize,
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
})
|
|
5124
|
+
weight: "medium",
|
|
5125
|
+
children: initials
|
|
5125
5126
|
})
|
|
5126
5127
|
})
|
|
5127
5128
|
})]
|
|
@@ -5155,7 +5156,7 @@ function _avatarCounterBaseStyle(props) {
|
|
|
5155
5156
|
const {
|
|
5156
5157
|
theme
|
|
5157
5158
|
} = 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
|
|
5159
|
+
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
5160
|
}
|
|
5160
5161
|
const Root$C = styled.div(_responsiveAvatarCounterSizeStyle, _avatarCounterBaseStyle);
|
|
5161
5162
|
const AvatarCounter = forwardRef(function AvatarCounter2(props, ref) {
|
|
@@ -5172,9 +5173,8 @@ const AvatarCounter = forwardRef(function AvatarCounter2(props, ref) {
|
|
|
5172
5173
|
children: /* @__PURE__ */jsx(Text, {
|
|
5173
5174
|
as: "span",
|
|
5174
5175
|
size: counterSize,
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
})
|
|
5176
|
+
weight: "medium",
|
|
5177
|
+
children: count
|
|
5178
5178
|
})
|
|
5179
5179
|
});
|
|
5180
5180
|
});
|
|
@@ -7659,6 +7659,7 @@ const TextInput = forwardRef(function TextInput2(props, forwardedRef) {
|
|
|
7659
7659
|
customValidity,
|
|
7660
7660
|
type = "text",
|
|
7661
7661
|
weight,
|
|
7662
|
+
unstableDisableFocusRing,
|
|
7662
7663
|
...restProps
|
|
7663
7664
|
} = props;
|
|
7664
7665
|
const ref = useForwardedRef(forwardedRef);
|
|
@@ -7697,6 +7698,7 @@ const TextInput = forwardRef(function TextInput2(props, forwardedRef) {
|
|
|
7697
7698
|
}), [prefix, radius]);
|
|
7698
7699
|
const presentationNode = useMemo(() => /* @__PURE__ */jsxs(Presentation, {
|
|
7699
7700
|
$hasPrefix,
|
|
7701
|
+
$unstableDisableFocusRing: unstableDisableFocusRing,
|
|
7700
7702
|
$hasSuffix,
|
|
7701
7703
|
$radius: radius,
|
|
7702
7704
|
$scheme: rootTheme.scheme,
|
|
@@ -7717,7 +7719,7 @@ const TextInput = forwardRef(function TextInput2(props, forwardedRef) {
|
|
|
7717
7719
|
children: [isValidElement(iconRight) && iconRight, isValidElementType(iconRight) && createElement(iconRight)]
|
|
7718
7720
|
})
|
|
7719
7721
|
})]
|
|
7720
|
-
}), [border, fontSize, icon, iconRight, padding, radius, rootTheme, $hasClearButton, $hasPrefix, $hasSuffix]);
|
|
7722
|
+
}), [border, fontSize, icon, iconRight, padding, radius, rootTheme, $hasClearButton, $hasPrefix, $hasSuffix, unstableDisableFocusRing]);
|
|
7721
7723
|
const clearButtonBoxPadding = useMemo(() => padding.map(v => {
|
|
7722
7724
|
if (v === 0) return 0;
|
|
7723
7725
|
if (v === 1) return 1;
|
|
@@ -7981,19 +7983,21 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
|
7981
7983
|
const closeDelayProp = typeof delay === "number" ? delay : (delay == null ? void 0 : delay.close) || 0;
|
|
7982
7984
|
const openDelay = isInsideGroup ? delayGroupContext.openDelay : openDelayProp;
|
|
7983
7985
|
const closeDelay = isInsideGroup ? delayGroupContext.closeDelay : closeDelayProp;
|
|
7984
|
-
const handleIsOpenChange = useCallback(open => {
|
|
7986
|
+
const handleIsOpenChange = useCallback((open, immediate) => {
|
|
7985
7987
|
if (isInsideGroup) {
|
|
7986
7988
|
if (open) {
|
|
7987
|
-
|
|
7988
|
-
delayGroupContext.
|
|
7989
|
+
const groupedOpenDelay = immediate ? 0 : openDelay;
|
|
7990
|
+
delayGroupContext.setIsGroupActive(open, groupedOpenDelay);
|
|
7991
|
+
delayGroupContext.setOpenTooltipId(tooltipId, groupedOpenDelay);
|
|
7989
7992
|
} else {
|
|
7990
7993
|
const minimumGroupDeactivateDelay = 200;
|
|
7991
7994
|
const groupDeactivateDelay = closeDelay > minimumGroupDeactivateDelay ? closeDelay : minimumGroupDeactivateDelay;
|
|
7992
7995
|
delayGroupContext.setIsGroupActive(open, groupDeactivateDelay);
|
|
7993
|
-
delayGroupContext.setOpenTooltipId(null, closeDelay);
|
|
7996
|
+
delayGroupContext.setOpenTooltipId(null, immediate ? 0 : closeDelay);
|
|
7994
7997
|
}
|
|
7995
7998
|
} else {
|
|
7996
|
-
|
|
7999
|
+
const standaloneDelay = immediate ? 0 : open ? openDelay : closeDelay;
|
|
8000
|
+
setIsOpen(open, standaloneDelay);
|
|
7997
8001
|
}
|
|
7998
8002
|
}, [isInsideGroup, delayGroupContext, openDelay, tooltipId, closeDelay, setIsOpen]);
|
|
7999
8003
|
const handleBlur = useCallback(() => handleIsOpenChange(false), [handleIsOpenChange]);
|
|
@@ -8022,6 +8026,18 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
|
8022
8026
|
if (!content) handleIsOpenChange(false);
|
|
8023
8027
|
}, [content, handleIsOpenChange]);
|
|
8024
8028
|
useEffect(() => refs.setReference(referenceElement), [referenceElement, refs]);
|
|
8029
|
+
useEffect(() => {
|
|
8030
|
+
if (!showTooltip) return;
|
|
8031
|
+
function handleWindowKeyDown(event) {
|
|
8032
|
+
if (event.key === "Escape") {
|
|
8033
|
+
handleIsOpenChange(false, true);
|
|
8034
|
+
}
|
|
8035
|
+
}
|
|
8036
|
+
window.addEventListener("keydown", handleWindowKeyDown);
|
|
8037
|
+
return () => {
|
|
8038
|
+
window.removeEventListener("keydown", handleWindowKeyDown);
|
|
8039
|
+
};
|
|
8040
|
+
}, [handleIsOpenChange, showTooltip]);
|
|
8025
8041
|
const setArrow = useCallback(arrowEl => {
|
|
8026
8042
|
arrowRef.current = arrowEl;
|
|
8027
8043
|
update();
|