@sanity/ui 2.3.1 → 2.3.2
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.esm.js +63 -59
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +62 -58
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -59
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/core/components/menu/menuButton.tsx +30 -17
- package/src/core/components/menu/menuGroup.tsx +5 -5
- package/src/core/components/menu/menuItem.tsx +9 -10
- package/src/core/components/tree/treeItem.tsx +9 -6
- package/src/core/hooks/useCustomValidity.ts +1 -3
- package/src/core/hooks/useDelayed.test.ts +1 -0
- package/src/core/primitives/button/button.tsx +10 -10
- package/src/core/primitives/textInput/textInput.tsx +13 -21
- package/src/core/primitives/tooltip/tooltip.tsx +12 -19
package/dist/index.js
CHANGED
|
@@ -627,7 +627,8 @@ function useForwardedRef(ref) {
|
|
|
627
627
|
}
|
|
628
628
|
function useCustomValidity(ref, customValidity) {
|
|
629
629
|
react.useEffect(() => {
|
|
630
|
-
|
|
630
|
+
var _a;
|
|
631
|
+
(_a = ref.current) == null || _a.setCustomValidity(customValidity || "");
|
|
631
632
|
}, [customValidity, ref]);
|
|
632
633
|
}
|
|
633
634
|
function responsiveBorderStyle() {
|
|
@@ -1992,8 +1993,8 @@ const Root$t = styledComponents.styled.button(responsiveRadiusStyle, buttonBaseS
|
|
|
1992
1993
|
children,
|
|
1993
1994
|
disabled,
|
|
1994
1995
|
fontSize: fontSize2 = 1,
|
|
1995
|
-
icon,
|
|
1996
|
-
iconRight,
|
|
1996
|
+
icon: IconComponent,
|
|
1997
|
+
iconRight: IconRightComponent,
|
|
1997
1998
|
justify: justifyProp = "center",
|
|
1998
1999
|
loading,
|
|
1999
2000
|
mode = "default",
|
|
@@ -2043,10 +2044,10 @@ const Root$t = styledComponents.styled.button(responsiveRadiusStyle, buttonBaseS
|
|
|
2043
2044
|
$width: width,
|
|
2044
2045
|
children: [
|
|
2045
2046
|
!!loading && /* @__PURE__ */ jsxRuntime.jsx(LoadingBox, { children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, {}) }),
|
|
2046
|
-
(
|
|
2047
|
-
|
|
2048
|
-
react.isValidElement(
|
|
2049
|
-
ReactIs.isValidElementType(
|
|
2047
|
+
(IconComponent || text || IconRightComponent) && /* @__PURE__ */ jsxRuntime.jsx(Box, { as: "span", ...boxProps, children: /* @__PURE__ */ jsxRuntime.jsxs(Flex, { as: "span", justify, gap: space, children: [
|
|
2048
|
+
IconComponent && /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: fontSize2, children: [
|
|
2049
|
+
react.isValidElement(IconComponent) && IconComponent,
|
|
2050
|
+
ReactIs.isValidElementType(IconComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {})
|
|
2050
2051
|
] }),
|
|
2051
2052
|
text && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2052
2053
|
Text,
|
|
@@ -2059,9 +2060,9 @@ const Root$t = styledComponents.styled.button(responsiveRadiusStyle, buttonBaseS
|
|
|
2059
2060
|
children: text
|
|
2060
2061
|
}
|
|
2061
2062
|
),
|
|
2062
|
-
|
|
2063
|
-
react.isValidElement(
|
|
2064
|
-
ReactIs.isValidElementType(
|
|
2063
|
+
IconRightComponent && /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: fontSize2, children: [
|
|
2064
|
+
react.isValidElement(IconRightComponent) && IconRightComponent,
|
|
2065
|
+
ReactIs.isValidElementType(IconRightComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconRightComponent, {})
|
|
2065
2066
|
] })
|
|
2066
2067
|
] }) }),
|
|
2067
2068
|
children && /* @__PURE__ */ jsxRuntime.jsx(Box, { as: "span", ...boxProps, children })
|
|
@@ -4073,8 +4074,8 @@ const Root$d = styledComponents.styled.span(switchBaseStyles), Input$2 = styledC
|
|
|
4073
4074
|
clearButton,
|
|
4074
4075
|
disabled = !1,
|
|
4075
4076
|
fontSize: fontSizeProp = 2,
|
|
4076
|
-
icon,
|
|
4077
|
-
iconRight,
|
|
4077
|
+
icon: IconComponent,
|
|
4078
|
+
iconRight: IconRightComponent,
|
|
4078
4079
|
onClear,
|
|
4079
4080
|
padding: paddingProp = 3,
|
|
4080
4081
|
prefix,
|
|
@@ -4086,7 +4087,7 @@ const Root$d = styledComponents.styled.span(switchBaseStyles), Input$2 = styledC
|
|
|
4086
4087
|
type = "text",
|
|
4087
4088
|
weight,
|
|
4088
4089
|
...restProps
|
|
4089
|
-
} = props, ref = react.useRef(null), rootTheme = useRootTheme(), fontSize2 = useArrayProp(fontSizeProp), padding = useArrayProp(paddingProp), radius = useArrayProp(radiusProp), space = useArrayProp(spaceProp), $hasClearButton = !!clearButton, $hasIcon = !!
|
|
4090
|
+
} = props, ref = react.useRef(null), rootTheme = useRootTheme(), fontSize2 = useArrayProp(fontSizeProp), padding = useArrayProp(paddingProp), radius = useArrayProp(radiusProp), space = useArrayProp(spaceProp), $hasClearButton = !!clearButton, $hasIcon = !!IconComponent, $hasIconRight = !!IconRightComponent, $hasSuffix = !!suffix, $hasPrefix = !!prefix;
|
|
4090
4091
|
react.useImperativeHandle(
|
|
4091
4092
|
forwardedRef,
|
|
4092
4093
|
() => ref.current
|
|
@@ -4116,13 +4117,13 @@ const Root$d = styledComponents.styled.span(switchBaseStyles), Input$2 = styledC
|
|
|
4116
4117
|
"data-scheme": rootTheme.scheme,
|
|
4117
4118
|
"data-tone": rootTheme.tone,
|
|
4118
4119
|
children: [
|
|
4119
|
-
|
|
4120
|
-
react.isValidElement(
|
|
4121
|
-
ReactIs.isValidElementType(
|
|
4120
|
+
IconComponent && /* @__PURE__ */ jsxRuntime.jsx(LeftBox, { padding, children: /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: fontSize2, children: [
|
|
4121
|
+
react.isValidElement(IconComponent) && IconComponent,
|
|
4122
|
+
ReactIs.isValidElementType(IconComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {})
|
|
4122
4123
|
] }) }),
|
|
4123
|
-
!$hasClearButton &&
|
|
4124
|
-
react.isValidElement(
|
|
4125
|
-
ReactIs.isValidElementType(
|
|
4124
|
+
!$hasClearButton && IconRightComponent && /* @__PURE__ */ jsxRuntime.jsx(RightBox, { padding, children: /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: fontSize2, children: [
|
|
4125
|
+
react.isValidElement(IconRightComponent) && IconRightComponent,
|
|
4126
|
+
ReactIs.isValidElementType(IconRightComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconRightComponent, {})
|
|
4126
4127
|
] }) })
|
|
4127
4128
|
]
|
|
4128
4129
|
}
|
|
@@ -4131,8 +4132,8 @@ const Root$d = styledComponents.styled.span(switchBaseStyles), Input$2 = styledC
|
|
|
4131
4132
|
__unstable_disableFocusRing,
|
|
4132
4133
|
border2,
|
|
4133
4134
|
fontSize2,
|
|
4134
|
-
|
|
4135
|
-
|
|
4135
|
+
IconComponent,
|
|
4136
|
+
IconRightComponent,
|
|
4136
4137
|
padding,
|
|
4137
4138
|
radius,
|
|
4138
4139
|
rootTheme,
|
|
@@ -4471,19 +4472,14 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4471
4472
|
ref.current = node, refs.setFloating(node);
|
|
4472
4473
|
},
|
|
4473
4474
|
[refs]
|
|
4474
|
-
), childRef =
|
|
4475
|
-
(node) => {
|
|
4476
|
-
typeof childRef == "function" ? childRef(node) : childRef && (childRef.current = node), setReferenceElement(node);
|
|
4477
|
-
},
|
|
4478
|
-
[childRef]
|
|
4479
|
-
), child = react.useMemo(() => childProp ? react.cloneElement(childProp, {
|
|
4475
|
+
), childRef = react.useRef(null), child = react.useMemo(() => childProp ? react.cloneElement(childProp, {
|
|
4480
4476
|
onBlur: handleBlur,
|
|
4481
4477
|
onFocus: handleFocus,
|
|
4482
4478
|
onMouseEnter: handleMouseEnter,
|
|
4483
4479
|
onMouseLeave: handleMouseLeave,
|
|
4484
4480
|
onClick: handleClick,
|
|
4485
4481
|
onContextMenu: handleContextMenu,
|
|
4486
|
-
ref:
|
|
4482
|
+
ref: childRef
|
|
4487
4483
|
}) : null, [
|
|
4488
4484
|
childProp,
|
|
4489
4485
|
handleBlur,
|
|
@@ -4491,10 +4487,12 @@ const Root$a = styledComponents.styled(Layer)`
|
|
|
4491
4487
|
handleContextMenu,
|
|
4492
4488
|
handleFocus,
|
|
4493
4489
|
handleMouseEnter,
|
|
4494
|
-
handleMouseLeave
|
|
4495
|
-
setReference
|
|
4490
|
+
handleMouseLeave
|
|
4496
4491
|
]);
|
|
4497
|
-
if (
|
|
4492
|
+
if (react.useEffect(() => {
|
|
4493
|
+
if (child)
|
|
4494
|
+
return setReferenceElement(childRef.current), () => setReferenceElement(null);
|
|
4495
|
+
}, [child]), !child) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
4498
4496
|
if (disabled) return child;
|
|
4499
4497
|
const tooltip = /* @__PURE__ */ jsxRuntime.jsx(
|
|
4500
4498
|
Root$a,
|
|
@@ -5521,7 +5519,7 @@ const Root$5 = styledComponents.styled(Box)`
|
|
|
5521
5519
|
children: /* @__PURE__ */ jsxRuntime.jsx(Stack, { space, children })
|
|
5522
5520
|
}
|
|
5523
5521
|
) });
|
|
5524
|
-
}), MenuButton = react.forwardRef(function(props,
|
|
5522
|
+
}), MenuButton = react.forwardRef(function(props, forwardedRef) {
|
|
5525
5523
|
const {
|
|
5526
5524
|
__unstable_disableRestoreFocusOnClose: disableRestoreFocusOnClose = !1,
|
|
5527
5525
|
boundaryElement: deprecated_boundaryElement,
|
|
@@ -5609,12 +5607,7 @@ const Root$5 = styledComponents.styled(Box)`
|
|
|
5609
5607
|
registerElement,
|
|
5610
5608
|
shouldFocus
|
|
5611
5609
|
]
|
|
5612
|
-
), menu = menuProp && react.cloneElement(menuProp, menuProps),
|
|
5613
|
-
(el) => {
|
|
5614
|
-
typeof ref == "function" ? ref(el) : ref && (ref.current = el), setButtonElement(el);
|
|
5615
|
-
},
|
|
5616
|
-
[ref]
|
|
5617
|
-
), button = react.useMemo(
|
|
5610
|
+
), menu = menuProp && react.cloneElement(menuProp, menuProps), ref = react.useRef(null), button = react.useMemo(
|
|
5618
5611
|
() => buttonProp && react.cloneElement(buttonProp, {
|
|
5619
5612
|
"data-ui": "MenuButton",
|
|
5620
5613
|
id,
|
|
@@ -5623,11 +5616,19 @@ const Root$5 = styledComponents.styled(Box)`
|
|
|
5623
5616
|
onMouseDown: handleMouseDown,
|
|
5624
5617
|
"aria-haspopup": !0,
|
|
5625
5618
|
"aria-expanded": open,
|
|
5626
|
-
ref
|
|
5619
|
+
ref,
|
|
5627
5620
|
selected: open
|
|
5628
5621
|
}),
|
|
5629
|
-
[buttonProp, handleButtonClick, handleButtonKeyDown, handleMouseDown, id, open
|
|
5630
|
-
)
|
|
5622
|
+
[buttonProp, handleButtonClick, handleButtonKeyDown, handleMouseDown, id, open]
|
|
5623
|
+
);
|
|
5624
|
+
react.useImperativeHandle(
|
|
5625
|
+
forwardedRef,
|
|
5626
|
+
() => ref.current
|
|
5627
|
+
), react.useEffect(() => {
|
|
5628
|
+
if (button)
|
|
5629
|
+
return setButtonElement(ref.current), () => setButtonElement(null);
|
|
5630
|
+
}, [button]);
|
|
5631
|
+
const popoverProps = react.useMemo(
|
|
5631
5632
|
() => ({
|
|
5632
5633
|
boundaryElement: deprecated_boundaryElement,
|
|
5633
5634
|
overflow: "auto",
|
|
@@ -5769,7 +5770,7 @@ function MenuGroup(props) {
|
|
|
5769
5770
|
as = "button",
|
|
5770
5771
|
children,
|
|
5771
5772
|
fontSize: fontSize2 = 1,
|
|
5772
|
-
icon,
|
|
5773
|
+
icon: IconComponent,
|
|
5773
5774
|
onClick,
|
|
5774
5775
|
padding = 3,
|
|
5775
5776
|
popover,
|
|
@@ -5854,9 +5855,9 @@ function MenuGroup(props) {
|
|
|
5854
5855
|
tabIndex: -1,
|
|
5855
5856
|
type: as === "button" ? "button" : void 0,
|
|
5856
5857
|
children: /* @__PURE__ */ jsxRuntime.jsxs(Flex, { gap: space, padding, children: [
|
|
5857
|
-
|
|
5858
|
-
react.isValidElement(
|
|
5859
|
-
ReactIs.isValidElementType(
|
|
5858
|
+
IconComponent && /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: fontSize2, children: [
|
|
5859
|
+
react.isValidElement(IconComponent) && IconComponent,
|
|
5860
|
+
ReactIs.isValidElementType(IconComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {})
|
|
5860
5861
|
] }),
|
|
5861
5862
|
/* @__PURE__ */ jsxRuntime.jsx(Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize2, textOverflow: "ellipsis", weight: "medium", children: text }) }),
|
|
5862
5863
|
/* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize2, children: /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronRightIcon, {}) })
|
|
@@ -5871,8 +5872,8 @@ const MenuItem = react.forwardRef(function(props, forwardedRef) {
|
|
|
5871
5872
|
disabled,
|
|
5872
5873
|
fontSize: fontSize2 = 1,
|
|
5873
5874
|
hotkeys,
|
|
5874
|
-
icon,
|
|
5875
|
-
iconRight,
|
|
5875
|
+
icon: IconComponent,
|
|
5876
|
+
iconRight: IconRightComponent,
|
|
5876
5877
|
onClick,
|
|
5877
5878
|
padding = 3,
|
|
5878
5879
|
paddingX,
|
|
@@ -5938,10 +5939,10 @@ const MenuItem = react.forwardRef(function(props, forwardedRef) {
|
|
|
5938
5939
|
tabIndex: -1,
|
|
5939
5940
|
type: as === "button" ? "button" : void 0,
|
|
5940
5941
|
children: [
|
|
5941
|
-
(
|
|
5942
|
-
|
|
5943
|
-
react.isValidElement(
|
|
5944
|
-
ReactIs.isValidElementType(
|
|
5942
|
+
(IconComponent || text || IconRightComponent) && /* @__PURE__ */ jsxRuntime.jsxs(Flex, { as: "span", gap: space, align: "center", ...paddingProps, children: [
|
|
5943
|
+
IconComponent && /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: fontSize2, children: [
|
|
5944
|
+
react.isValidElement(IconComponent) && IconComponent,
|
|
5945
|
+
ReactIs.isValidElementType(IconComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {})
|
|
5945
5946
|
] }),
|
|
5946
5947
|
text && /* @__PURE__ */ jsxRuntime.jsx(Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize2, textOverflow: "ellipsis", weight: "medium", children: text }) }),
|
|
5947
5948
|
hotkeys && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5952,9 +5953,9 @@ const MenuItem = react.forwardRef(function(props, forwardedRef) {
|
|
|
5952
5953
|
style: { marginTop: -4, marginBottom: -4 }
|
|
5953
5954
|
}
|
|
5954
5955
|
),
|
|
5955
|
-
|
|
5956
|
-
react.isValidElement(
|
|
5957
|
-
ReactIs.isValidElementType(
|
|
5956
|
+
IconRightComponent && /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: fontSize2, children: [
|
|
5957
|
+
react.isValidElement(IconRightComponent) && IconRightComponent,
|
|
5958
|
+
ReactIs.isValidElementType(IconRightComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconRightComponent, {})
|
|
5958
5959
|
] })
|
|
5959
5960
|
] }),
|
|
5960
5961
|
children && /* @__PURE__ */ jsxRuntime.jsx(Box, { as: "span", ...paddingProps, children })
|
|
@@ -6603,7 +6604,7 @@ const TreeGroup = react.memo(function(props) {
|
|
|
6603
6604
|
expanded: expandedProp = !1,
|
|
6604
6605
|
fontSize: fontSize2 = 1,
|
|
6605
6606
|
href,
|
|
6606
|
-
icon,
|
|
6607
|
+
icon: IconComponent,
|
|
6607
6608
|
id: idProp,
|
|
6608
6609
|
linkAs,
|
|
6609
6610
|
muted,
|
|
@@ -6642,10 +6643,13 @@ const TreeGroup = react.memo(function(props) {
|
|
|
6642
6643
|
Box,
|
|
6643
6644
|
{
|
|
6644
6645
|
marginRight: space,
|
|
6645
|
-
style: {
|
|
6646
|
+
style: {
|
|
6647
|
+
visibility: IconComponent || children ? "visible" : "hidden",
|
|
6648
|
+
pointerEvents: "none"
|
|
6649
|
+
},
|
|
6646
6650
|
children: [
|
|
6647
|
-
|
|
6648
|
-
!
|
|
6651
|
+
IconComponent && /* @__PURE__ */ jsxRuntime.jsx(Text, { muted, size: fontSize2, weight, children: /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {}) }),
|
|
6652
|
+
!IconComponent && /* @__PURE__ */ jsxRuntime.jsx(ToggleArrowText, { muted, size: fontSize2, weight, children: /* @__PURE__ */ jsxRuntime.jsx(icons.ToggleArrowRightIcon, { style: { transform: expanded ? "rotate(90deg)" : void 0 } }) })
|
|
6649
6653
|
]
|
|
6650
6654
|
}
|
|
6651
6655
|
),
|