@sanity/ui 1.9.1 → 1.9.3
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 +67 -27
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +67 -27
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/primitives/tooltip/__workshop__/customPortal.tsx +99 -0
- package/src/primitives/tooltip/__workshop__/index.ts +5 -0
- package/src/primitives/tooltip/__workshop__/overflowingBoundary.tsx +35 -15
- package/src/primitives/tooltip/tooltip.test.tsx +125 -0
- package/src/primitives/tooltip/tooltip.tsx +80 -16
package/dist/index.js
CHANGED
|
@@ -6944,9 +6944,14 @@ var __template$e = (cooked, raw) => __freeze$e(__defProp$e(cooked, "raw", {
|
|
|
6944
6944
|
value: __freeze$e(raw || cooked.slice())
|
|
6945
6945
|
}));
|
|
6946
6946
|
var _a$e;
|
|
6947
|
-
const Root$a = styled__default.default(Layer)(_a$e || (_a$e = __template$e(["\n pointer-events: none;\n
|
|
6947
|
+
const Root$a = styled__default.default(Layer)(_a$e || (_a$e = __template$e(["\n pointer-events: none;\n max-width: ", "px;\n"])), _ref22 => {
|
|
6948
|
+
let {
|
|
6949
|
+
$maxWidth
|
|
6950
|
+
} = _ref22;
|
|
6951
|
+
return $maxWidth;
|
|
6952
|
+
});
|
|
6948
6953
|
const Tooltip = react.forwardRef(function Tooltip2(props, ref) {
|
|
6949
|
-
var _a2, _b, _c, _d, _e;
|
|
6954
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
6950
6955
|
const boundaryElementContext = useBoundaryElement();
|
|
6951
6956
|
const theme = useTheme();
|
|
6952
6957
|
const {
|
|
@@ -6957,7 +6962,7 @@ const Tooltip = react.forwardRef(function Tooltip2(props, ref) {
|
|
|
6957
6962
|
fallbackPlacements: fallbackPlacementsProp = (_b = props.fallbackPlacements) != null ? _b : DEFAULT_FALLBACK_PLACEMENTS[(_a2 = props.placement) != null ? _a2 : "bottom"],
|
|
6958
6963
|
padding,
|
|
6959
6964
|
placement: placementProp = "bottom",
|
|
6960
|
-
portal,
|
|
6965
|
+
portal: portalProp,
|
|
6961
6966
|
scheme,
|
|
6962
6967
|
shadow = 2,
|
|
6963
6968
|
zOffset = (_c = theme.sanity.layer) == null ? void 0 : _c.tooltip.zOffset,
|
|
@@ -6969,10 +6974,16 @@ const Tooltip = react.forwardRef(function Tooltip2(props, ref) {
|
|
|
6969
6974
|
const [referenceElement, setReferenceElement] = react.useState(null);
|
|
6970
6975
|
const arrowRef = react.useRef(null);
|
|
6971
6976
|
const rootBoundary = "viewport";
|
|
6977
|
+
const portal = usePortal();
|
|
6978
|
+
const portalElement = typeof portalProp === "string" ? ((_d = portal.elements) == null ? void 0 : _d[portalProp]) || null : portal.element;
|
|
6979
|
+
const tooltipWidth = react.useMemo(() => {
|
|
6980
|
+
const availableWidths = [...(boundaryElement ? [boundaryElement.offsetWidth] : []), (portalElement == null ? void 0 : portalElement.offsetWidth) || document.body.offsetWidth];
|
|
6981
|
+
return Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2;
|
|
6982
|
+
}, [boundaryElement, portalElement == null ? void 0 : portalElement.offsetWidth]);
|
|
6972
6983
|
const middleware = react.useMemo(() => {
|
|
6973
6984
|
const ret = [];
|
|
6974
6985
|
ret.push(reactDom$1.flip({
|
|
6975
|
-
boundary:
|
|
6986
|
+
boundary: boundaryElement || void 0,
|
|
6976
6987
|
fallbackPlacements,
|
|
6977
6988
|
padding: DEFAULT_TOOLTIP_PADDING,
|
|
6978
6989
|
rootBoundary
|
|
@@ -6981,7 +6992,7 @@ const Tooltip = react.forwardRef(function Tooltip2(props, ref) {
|
|
|
6981
6992
|
mainAxis: 3
|
|
6982
6993
|
}));
|
|
6983
6994
|
ret.push(reactDom$1.shift({
|
|
6984
|
-
boundary:
|
|
6995
|
+
boundary: boundaryElement || void 0,
|
|
6985
6996
|
rootBoundary,
|
|
6986
6997
|
padding: DEFAULT_TOOLTIP_PADDING
|
|
6987
6998
|
}));
|
|
@@ -6990,7 +7001,7 @@ const Tooltip = react.forwardRef(function Tooltip2(props, ref) {
|
|
|
6990
7001
|
padding: 2
|
|
6991
7002
|
}));
|
|
6992
7003
|
return ret;
|
|
6993
|
-
}, [boundaryElement, fallbackPlacements
|
|
7004
|
+
}, [boundaryElement, fallbackPlacements]);
|
|
6994
7005
|
const {
|
|
6995
7006
|
floatingStyles,
|
|
6996
7007
|
placement,
|
|
@@ -7003,8 +7014,8 @@ const Tooltip = react.forwardRef(function Tooltip2(props, ref) {
|
|
|
7003
7014
|
whileElementsMounted: reactDom$1.autoUpdate
|
|
7004
7015
|
});
|
|
7005
7016
|
const staticSide = placement && FLOATING_STATIC_SIDES[placement.split("-")[0]];
|
|
7006
|
-
const arrowX = (
|
|
7007
|
-
const arrowY = (
|
|
7017
|
+
const arrowX = (_e = middlewareData.arrow) == null ? void 0 : _e.x;
|
|
7018
|
+
const arrowY = (_f = middlewareData.arrow) == null ? void 0 : _f.y;
|
|
7008
7019
|
const arrowStyle = react.useMemo(() => {
|
|
7009
7020
|
const style = {
|
|
7010
7021
|
left: arrowX !== null ? arrowX : void 0,
|
|
@@ -7041,10 +7052,36 @@ const Tooltip = react.forwardRef(function Tooltip2(props, ref) {
|
|
|
7041
7052
|
setIsOpen(open, standaloneDelay);
|
|
7042
7053
|
}
|
|
7043
7054
|
}, [isInsideGroup, delayGroupContext, openDelay, tooltipId, closeDelay, setIsOpen]);
|
|
7044
|
-
const handleBlur = react.useCallback(
|
|
7045
|
-
|
|
7046
|
-
|
|
7047
|
-
|
|
7055
|
+
const handleBlur = react.useCallback(e => {
|
|
7056
|
+
var _a3, _b2;
|
|
7057
|
+
handleIsOpenChange(false);
|
|
7058
|
+
(_b2 = (_a3 = childProp == null ? void 0 : childProp.props) == null ? void 0 : _a3.onBlur) == null ? void 0 : _b2.call(_a3, e);
|
|
7059
|
+
}, [childProp == null ? void 0 : childProp.props, handleIsOpenChange]);
|
|
7060
|
+
const handleClick = react.useCallback(e => {
|
|
7061
|
+
var _a3, _b2;
|
|
7062
|
+
handleIsOpenChange(false, true);
|
|
7063
|
+
(_b2 = childProp == null ? void 0 : (_a3 = childProp.props).onClick) == null ? void 0 : _b2.call(_a3, e);
|
|
7064
|
+
}, [childProp == null ? void 0 : childProp.props, handleIsOpenChange]);
|
|
7065
|
+
const handleContextMenu = react.useCallback(e => {
|
|
7066
|
+
var _a3, _b2;
|
|
7067
|
+
handleIsOpenChange(false, true);
|
|
7068
|
+
(_b2 = childProp == null ? void 0 : (_a3 = childProp.props).onContextMenu) == null ? void 0 : _b2.call(_a3, e);
|
|
7069
|
+
}, [childProp == null ? void 0 : childProp.props, handleIsOpenChange]);
|
|
7070
|
+
const handleFocus = react.useCallback(e => {
|
|
7071
|
+
var _a3, _b2;
|
|
7072
|
+
handleIsOpenChange(true);
|
|
7073
|
+
(_b2 = (_a3 = childProp == null ? void 0 : childProp.props) == null ? void 0 : _a3.onFocus) == null ? void 0 : _b2.call(_a3, e);
|
|
7074
|
+
}, [childProp == null ? void 0 : childProp.props, handleIsOpenChange]);
|
|
7075
|
+
const handleMouseEnter = react.useCallback(e => {
|
|
7076
|
+
var _a3, _b2;
|
|
7077
|
+
handleIsOpenChange(true);
|
|
7078
|
+
(_b2 = (_a3 = childProp == null ? void 0 : childProp.props) == null ? void 0 : _a3.onMouseEnter) == null ? void 0 : _b2.call(_a3, e);
|
|
7079
|
+
}, [childProp == null ? void 0 : childProp.props, handleIsOpenChange]);
|
|
7080
|
+
const handleMouseLeave = react.useCallback(e => {
|
|
7081
|
+
var _a3, _b2;
|
|
7082
|
+
handleIsOpenChange(false);
|
|
7083
|
+
(_b2 = (_a3 = childProp == null ? void 0 : childProp.props) == null ? void 0 : _a3.onMouseLeave) == null ? void 0 : _b2.call(_a3, e);
|
|
7084
|
+
}, [childProp == null ? void 0 : childProp.props, handleIsOpenChange]);
|
|
7048
7085
|
react.useEffect(() => {
|
|
7049
7086
|
if (!isOpen) return;
|
|
7050
7087
|
function handleWindowMouseMove(event) {
|
|
@@ -7103,9 +7140,11 @@ const Tooltip = react.forwardRef(function Tooltip2(props, ref) {
|
|
|
7103
7140
|
onFocus: handleFocus,
|
|
7104
7141
|
onMouseEnter: handleMouseEnter,
|
|
7105
7142
|
onMouseLeave: handleMouseLeave,
|
|
7143
|
+
onClick: handleClick,
|
|
7144
|
+
onContextMenu: handleContextMenu,
|
|
7106
7145
|
ref: setReference
|
|
7107
7146
|
});
|
|
7108
|
-
}, [childProp, handleBlur, handleFocus, handleMouseEnter, handleMouseLeave, setReference]);
|
|
7147
|
+
}, [childProp, handleBlur, handleClick, handleContextMenu, handleFocus, handleMouseEnter, handleMouseLeave, setReference]);
|
|
7109
7148
|
if (!child) return /* @__PURE__ */jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
7110
7149
|
if (disabled) return child;
|
|
7111
7150
|
const root = /* @__PURE__ */jsxRuntime.jsx(Root$a, {
|
|
@@ -7114,6 +7153,7 @@ const Tooltip = react.forwardRef(function Tooltip2(props, ref) {
|
|
|
7114
7153
|
ref: setFloating,
|
|
7115
7154
|
style: floatingStyles,
|
|
7116
7155
|
zOffset,
|
|
7156
|
+
$maxWidth: tooltipWidth,
|
|
7117
7157
|
children: /* @__PURE__ */jsxRuntime.jsxs(Card, {
|
|
7118
7158
|
"data-ui": "Tooltip__card",
|
|
7119
7159
|
"data-placement": placement,
|
|
@@ -7129,8 +7169,8 @@ const Tooltip = react.forwardRef(function Tooltip2(props, ref) {
|
|
|
7129
7169
|
});
|
|
7130
7170
|
return /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
7131
7171
|
children: [child, showTooltip && /* @__PURE__ */jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
7132
|
-
children:
|
|
7133
|
-
__unstable_name: typeof
|
|
7172
|
+
children: portalProp ? /* @__PURE__ */jsxRuntime.jsx(Portal, {
|
|
7173
|
+
__unstable_name: typeof portalProp === "string" ? portalProp : void 0,
|
|
7134
7174
|
children: root
|
|
7135
7175
|
}) : root
|
|
7136
7176
|
})]
|
|
@@ -7290,10 +7330,10 @@ const InnerAutocomplete = react.forwardRef(function InnerAutocomplete2(props, re
|
|
|
7290
7330
|
query,
|
|
7291
7331
|
value
|
|
7292
7332
|
} = state;
|
|
7293
|
-
const defaultRenderOption = react.useCallback(
|
|
7333
|
+
const defaultRenderOption = react.useCallback(_ref23 => {
|
|
7294
7334
|
let {
|
|
7295
7335
|
value: value2
|
|
7296
|
-
} =
|
|
7336
|
+
} = _ref23;
|
|
7297
7337
|
return /* @__PURE__ */jsxRuntime.jsx(Card, {
|
|
7298
7338
|
"data-as": "button",
|
|
7299
7339
|
padding: paddingProp,
|
|
@@ -7746,10 +7786,10 @@ const Breadcrumbs = react.forwardRef(function Breadcrumbs2(props, ref) {
|
|
|
7746
7786
|
}, itemIndex))
|
|
7747
7787
|
});
|
|
7748
7788
|
});
|
|
7749
|
-
function dialogStyle(
|
|
7789
|
+
function dialogStyle(_ref24) {
|
|
7750
7790
|
let {
|
|
7751
7791
|
theme
|
|
7752
|
-
} =
|
|
7792
|
+
} = _ref24;
|
|
7753
7793
|
const color = theme.sanity.color.base;
|
|
7754
7794
|
return {
|
|
7755
7795
|
"&:not([hidden])": {
|
|
@@ -8811,15 +8851,15 @@ var __template$6 = (cooked, raw) => __freeze$6(__defProp$6(cooked, "raw", {
|
|
|
8811
8851
|
var _a$6, _b$3, _c$1, _d;
|
|
8812
8852
|
const keyframe = styled.keyframes(_a$6 || (_a$6 = __template$6(["\n 0% {\n background-position: 100%;\n }\n 100% {\n background-position: -100%;\n }\n"])));
|
|
8813
8853
|
const animation = styled.css(_b$3 || (_b$3 = __template$6(["\n background-image: linear-gradient(\n to right,\n var(--card-skeleton-color-from),\n var(--card-skeleton-color-to),\n var(--card-skeleton-color-from),\n var(--card-skeleton-color-from),\n var(--card-skeleton-color-from)\n );\n background-position: 100%;\n background-size: 200% 100%;\n background-attachment: fixed;\n animation-name: ", ";\n animation-timing-function: ease-in-out;\n animation-iteration-count: infinite;\n animation-duration: 2000ms;\n"])), keyframe);
|
|
8814
|
-
const skeletonStyle = styled.css(_d || (_d = __template$6(["\n opacity: ", ";\n transition: opacity 200ms ease-in;\n\n @media screen and (prefers-reduced-motion: no-preference) {\n ", "\n }\n\n @media screen and (prefers-reduced-motion: reduce) {\n background-color: var(--card-skeleton-color-from);\n }\n"])),
|
|
8854
|
+
const skeletonStyle = styled.css(_d || (_d = __template$6(["\n opacity: ", ";\n transition: opacity 200ms ease-in;\n\n @media screen and (prefers-reduced-motion: no-preference) {\n ", "\n }\n\n @media screen and (prefers-reduced-motion: reduce) {\n background-color: var(--card-skeleton-color-from);\n }\n"])), _ref25 => {
|
|
8815
8855
|
let {
|
|
8816
8856
|
$visible
|
|
8817
|
-
} =
|
|
8857
|
+
} = _ref25;
|
|
8818
8858
|
return $visible ? 1 : 0;
|
|
8819
|
-
},
|
|
8859
|
+
}, _ref26 => {
|
|
8820
8860
|
let {
|
|
8821
8861
|
$animated
|
|
8822
|
-
} =
|
|
8862
|
+
} = _ref26;
|
|
8823
8863
|
return $animated ? animation : styled.css(_c$1 || (_c$1 = __template$6(["\n background-color: var(--card-skeleton-color-from);\n "])));
|
|
8824
8864
|
});
|
|
8825
8865
|
const Root$4 = styled__default.default(Box)(responsiveRadiusStyle, skeletonStyle);
|
|
@@ -8850,12 +8890,12 @@ const Skeleton = react.forwardRef(function Skeleton2(props, ref) {
|
|
|
8850
8890
|
ref
|
|
8851
8891
|
});
|
|
8852
8892
|
});
|
|
8853
|
-
const Root$3 = styled__default.default(Skeleton)(
|
|
8893
|
+
const Root$3 = styled__default.default(Skeleton)(_ref27 => {
|
|
8854
8894
|
let {
|
|
8855
8895
|
$size,
|
|
8856
8896
|
$style,
|
|
8857
8897
|
theme
|
|
8858
|
-
} =
|
|
8898
|
+
} = _ref27;
|
|
8859
8899
|
const {
|
|
8860
8900
|
media
|
|
8861
8901
|
} = theme.sanity;
|
|
@@ -9202,12 +9242,12 @@ function ToastProvider(props) {
|
|
|
9202
9242
|
paddingY,
|
|
9203
9243
|
children: /* @__PURE__ */jsxRuntime.jsx(framerMotion.AnimatePresence, {
|
|
9204
9244
|
initial: false,
|
|
9205
|
-
children: state.map(
|
|
9245
|
+
children: state.map(_ref28 => {
|
|
9206
9246
|
let {
|
|
9207
9247
|
dismiss,
|
|
9208
9248
|
id,
|
|
9209
9249
|
params
|
|
9210
|
-
} =
|
|
9250
|
+
} = _ref28;
|
|
9211
9251
|
return /* @__PURE__ */jsxRuntime.jsx(framerMotion.motion.div, {
|
|
9212
9252
|
animate: {
|
|
9213
9253
|
opacity: 1,
|