@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.esm.js
CHANGED
|
@@ -6931,9 +6931,14 @@ var __template$e = (cooked, raw) => __freeze$e(__defProp$e(cooked, "raw", {
|
|
|
6931
6931
|
value: __freeze$e(raw || cooked.slice())
|
|
6932
6932
|
}));
|
|
6933
6933
|
var _a$e;
|
|
6934
|
-
const Root$a = styled(Layer)(_a$e || (_a$e = __template$e(["\n pointer-events: none;\n
|
|
6934
|
+
const Root$a = styled(Layer)(_a$e || (_a$e = __template$e(["\n pointer-events: none;\n max-width: ", "px;\n"])), _ref22 => {
|
|
6935
|
+
let {
|
|
6936
|
+
$maxWidth
|
|
6937
|
+
} = _ref22;
|
|
6938
|
+
return $maxWidth;
|
|
6939
|
+
});
|
|
6935
6940
|
const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
6936
|
-
var _a2, _b, _c, _d, _e;
|
|
6941
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
6937
6942
|
const boundaryElementContext = useBoundaryElement();
|
|
6938
6943
|
const theme = useTheme();
|
|
6939
6944
|
const {
|
|
@@ -6944,7 +6949,7 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
|
6944
6949
|
fallbackPlacements: fallbackPlacementsProp = (_b = props.fallbackPlacements) != null ? _b : DEFAULT_FALLBACK_PLACEMENTS[(_a2 = props.placement) != null ? _a2 : "bottom"],
|
|
6945
6950
|
padding,
|
|
6946
6951
|
placement: placementProp = "bottom",
|
|
6947
|
-
portal,
|
|
6952
|
+
portal: portalProp,
|
|
6948
6953
|
scheme,
|
|
6949
6954
|
shadow = 2,
|
|
6950
6955
|
zOffset = (_c = theme.sanity.layer) == null ? void 0 : _c.tooltip.zOffset,
|
|
@@ -6956,10 +6961,16 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
|
6956
6961
|
const [referenceElement, setReferenceElement] = useState(null);
|
|
6957
6962
|
const arrowRef = useRef(null);
|
|
6958
6963
|
const rootBoundary = "viewport";
|
|
6964
|
+
const portal = usePortal();
|
|
6965
|
+
const portalElement = typeof portalProp === "string" ? ((_d = portal.elements) == null ? void 0 : _d[portalProp]) || null : portal.element;
|
|
6966
|
+
const tooltipWidth = useMemo(() => {
|
|
6967
|
+
const availableWidths = [...(boundaryElement ? [boundaryElement.offsetWidth] : []), (portalElement == null ? void 0 : portalElement.offsetWidth) || document.body.offsetWidth];
|
|
6968
|
+
return Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2;
|
|
6969
|
+
}, [boundaryElement, portalElement == null ? void 0 : portalElement.offsetWidth]);
|
|
6959
6970
|
const middleware = useMemo(() => {
|
|
6960
6971
|
const ret = [];
|
|
6961
6972
|
ret.push(flip({
|
|
6962
|
-
boundary:
|
|
6973
|
+
boundary: boundaryElement || void 0,
|
|
6963
6974
|
fallbackPlacements,
|
|
6964
6975
|
padding: DEFAULT_TOOLTIP_PADDING,
|
|
6965
6976
|
rootBoundary
|
|
@@ -6968,7 +6979,7 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
|
6968
6979
|
mainAxis: 3
|
|
6969
6980
|
}));
|
|
6970
6981
|
ret.push(shift({
|
|
6971
|
-
boundary:
|
|
6982
|
+
boundary: boundaryElement || void 0,
|
|
6972
6983
|
rootBoundary,
|
|
6973
6984
|
padding: DEFAULT_TOOLTIP_PADDING
|
|
6974
6985
|
}));
|
|
@@ -6977,7 +6988,7 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
|
6977
6988
|
padding: 2
|
|
6978
6989
|
}));
|
|
6979
6990
|
return ret;
|
|
6980
|
-
}, [boundaryElement, fallbackPlacements
|
|
6991
|
+
}, [boundaryElement, fallbackPlacements]);
|
|
6981
6992
|
const {
|
|
6982
6993
|
floatingStyles,
|
|
6983
6994
|
placement,
|
|
@@ -6990,8 +7001,8 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
|
6990
7001
|
whileElementsMounted: autoUpdate
|
|
6991
7002
|
});
|
|
6992
7003
|
const staticSide = placement && FLOATING_STATIC_SIDES[placement.split("-")[0]];
|
|
6993
|
-
const arrowX = (
|
|
6994
|
-
const arrowY = (
|
|
7004
|
+
const arrowX = (_e = middlewareData.arrow) == null ? void 0 : _e.x;
|
|
7005
|
+
const arrowY = (_f = middlewareData.arrow) == null ? void 0 : _f.y;
|
|
6995
7006
|
const arrowStyle = useMemo(() => {
|
|
6996
7007
|
const style = {
|
|
6997
7008
|
left: arrowX !== null ? arrowX : void 0,
|
|
@@ -7028,10 +7039,36 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
|
7028
7039
|
setIsOpen(open, standaloneDelay);
|
|
7029
7040
|
}
|
|
7030
7041
|
}, [isInsideGroup, delayGroupContext, openDelay, tooltipId, closeDelay, setIsOpen]);
|
|
7031
|
-
const handleBlur = useCallback(
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7042
|
+
const handleBlur = useCallback(e => {
|
|
7043
|
+
var _a3, _b2;
|
|
7044
|
+
handleIsOpenChange(false);
|
|
7045
|
+
(_b2 = (_a3 = childProp == null ? void 0 : childProp.props) == null ? void 0 : _a3.onBlur) == null ? void 0 : _b2.call(_a3, e);
|
|
7046
|
+
}, [childProp == null ? void 0 : childProp.props, handleIsOpenChange]);
|
|
7047
|
+
const handleClick = useCallback(e => {
|
|
7048
|
+
var _a3, _b2;
|
|
7049
|
+
handleIsOpenChange(false, true);
|
|
7050
|
+
(_b2 = childProp == null ? void 0 : (_a3 = childProp.props).onClick) == null ? void 0 : _b2.call(_a3, e);
|
|
7051
|
+
}, [childProp == null ? void 0 : childProp.props, handleIsOpenChange]);
|
|
7052
|
+
const handleContextMenu = useCallback(e => {
|
|
7053
|
+
var _a3, _b2;
|
|
7054
|
+
handleIsOpenChange(false, true);
|
|
7055
|
+
(_b2 = childProp == null ? void 0 : (_a3 = childProp.props).onContextMenu) == null ? void 0 : _b2.call(_a3, e);
|
|
7056
|
+
}, [childProp == null ? void 0 : childProp.props, handleIsOpenChange]);
|
|
7057
|
+
const handleFocus = useCallback(e => {
|
|
7058
|
+
var _a3, _b2;
|
|
7059
|
+
handleIsOpenChange(true);
|
|
7060
|
+
(_b2 = (_a3 = childProp == null ? void 0 : childProp.props) == null ? void 0 : _a3.onFocus) == null ? void 0 : _b2.call(_a3, e);
|
|
7061
|
+
}, [childProp == null ? void 0 : childProp.props, handleIsOpenChange]);
|
|
7062
|
+
const handleMouseEnter = useCallback(e => {
|
|
7063
|
+
var _a3, _b2;
|
|
7064
|
+
handleIsOpenChange(true);
|
|
7065
|
+
(_b2 = (_a3 = childProp == null ? void 0 : childProp.props) == null ? void 0 : _a3.onMouseEnter) == null ? void 0 : _b2.call(_a3, e);
|
|
7066
|
+
}, [childProp == null ? void 0 : childProp.props, handleIsOpenChange]);
|
|
7067
|
+
const handleMouseLeave = useCallback(e => {
|
|
7068
|
+
var _a3, _b2;
|
|
7069
|
+
handleIsOpenChange(false);
|
|
7070
|
+
(_b2 = (_a3 = childProp == null ? void 0 : childProp.props) == null ? void 0 : _a3.onMouseLeave) == null ? void 0 : _b2.call(_a3, e);
|
|
7071
|
+
}, [childProp == null ? void 0 : childProp.props, handleIsOpenChange]);
|
|
7035
7072
|
useEffect(() => {
|
|
7036
7073
|
if (!isOpen) return;
|
|
7037
7074
|
function handleWindowMouseMove(event) {
|
|
@@ -7090,9 +7127,11 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
|
7090
7127
|
onFocus: handleFocus,
|
|
7091
7128
|
onMouseEnter: handleMouseEnter,
|
|
7092
7129
|
onMouseLeave: handleMouseLeave,
|
|
7130
|
+
onClick: handleClick,
|
|
7131
|
+
onContextMenu: handleContextMenu,
|
|
7093
7132
|
ref: setReference
|
|
7094
7133
|
});
|
|
7095
|
-
}, [childProp, handleBlur, handleFocus, handleMouseEnter, handleMouseLeave, setReference]);
|
|
7134
|
+
}, [childProp, handleBlur, handleClick, handleContextMenu, handleFocus, handleMouseEnter, handleMouseLeave, setReference]);
|
|
7096
7135
|
if (!child) return /* @__PURE__ */jsx(Fragment, {});
|
|
7097
7136
|
if (disabled) return child;
|
|
7098
7137
|
const root = /* @__PURE__ */jsx(Root$a, {
|
|
@@ -7101,6 +7140,7 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
|
7101
7140
|
ref: setFloating,
|
|
7102
7141
|
style: floatingStyles,
|
|
7103
7142
|
zOffset,
|
|
7143
|
+
$maxWidth: tooltipWidth,
|
|
7104
7144
|
children: /* @__PURE__ */jsxs(Card, {
|
|
7105
7145
|
"data-ui": "Tooltip__card",
|
|
7106
7146
|
"data-placement": placement,
|
|
@@ -7116,8 +7156,8 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
|
7116
7156
|
});
|
|
7117
7157
|
return /* @__PURE__ */jsxs(Fragment, {
|
|
7118
7158
|
children: [child, showTooltip && /* @__PURE__ */jsx(Fragment, {
|
|
7119
|
-
children:
|
|
7120
|
-
__unstable_name: typeof
|
|
7159
|
+
children: portalProp ? /* @__PURE__ */jsx(Portal, {
|
|
7160
|
+
__unstable_name: typeof portalProp === "string" ? portalProp : void 0,
|
|
7121
7161
|
children: root
|
|
7122
7162
|
}) : root
|
|
7123
7163
|
})]
|
|
@@ -7277,10 +7317,10 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete2(props, ref) {
|
|
|
7277
7317
|
query,
|
|
7278
7318
|
value
|
|
7279
7319
|
} = state;
|
|
7280
|
-
const defaultRenderOption = useCallback(
|
|
7320
|
+
const defaultRenderOption = useCallback(_ref23 => {
|
|
7281
7321
|
let {
|
|
7282
7322
|
value: value2
|
|
7283
|
-
} =
|
|
7323
|
+
} = _ref23;
|
|
7284
7324
|
return /* @__PURE__ */jsx(Card, {
|
|
7285
7325
|
"data-as": "button",
|
|
7286
7326
|
padding: paddingProp,
|
|
@@ -7733,10 +7773,10 @@ const Breadcrumbs = forwardRef(function Breadcrumbs2(props, ref) {
|
|
|
7733
7773
|
}, itemIndex))
|
|
7734
7774
|
});
|
|
7735
7775
|
});
|
|
7736
|
-
function dialogStyle(
|
|
7776
|
+
function dialogStyle(_ref24) {
|
|
7737
7777
|
let {
|
|
7738
7778
|
theme
|
|
7739
|
-
} =
|
|
7779
|
+
} = _ref24;
|
|
7740
7780
|
const color = theme.sanity.color.base;
|
|
7741
7781
|
return {
|
|
7742
7782
|
"&:not([hidden])": {
|
|
@@ -8798,15 +8838,15 @@ var __template$6 = (cooked, raw) => __freeze$6(__defProp$6(cooked, "raw", {
|
|
|
8798
8838
|
var _a$6, _b$3, _c$1, _d;
|
|
8799
8839
|
const keyframe = keyframes(_a$6 || (_a$6 = __template$6(["\n 0% {\n background-position: 100%;\n }\n 100% {\n background-position: -100%;\n }\n"])));
|
|
8800
8840
|
const animation = 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);
|
|
8801
|
-
const skeletonStyle = 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"])),
|
|
8841
|
+
const skeletonStyle = 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 => {
|
|
8802
8842
|
let {
|
|
8803
8843
|
$visible
|
|
8804
|
-
} =
|
|
8844
|
+
} = _ref25;
|
|
8805
8845
|
return $visible ? 1 : 0;
|
|
8806
|
-
},
|
|
8846
|
+
}, _ref26 => {
|
|
8807
8847
|
let {
|
|
8808
8848
|
$animated
|
|
8809
|
-
} =
|
|
8849
|
+
} = _ref26;
|
|
8810
8850
|
return $animated ? animation : css(_c$1 || (_c$1 = __template$6(["\n background-color: var(--card-skeleton-color-from);\n "])));
|
|
8811
8851
|
});
|
|
8812
8852
|
const Root$4 = styled(Box)(responsiveRadiusStyle, skeletonStyle);
|
|
@@ -8837,12 +8877,12 @@ const Skeleton = forwardRef(function Skeleton2(props, ref) {
|
|
|
8837
8877
|
ref
|
|
8838
8878
|
});
|
|
8839
8879
|
});
|
|
8840
|
-
const Root$3 = styled(Skeleton)(
|
|
8880
|
+
const Root$3 = styled(Skeleton)(_ref27 => {
|
|
8841
8881
|
let {
|
|
8842
8882
|
$size,
|
|
8843
8883
|
$style,
|
|
8844
8884
|
theme
|
|
8845
|
-
} =
|
|
8885
|
+
} = _ref27;
|
|
8846
8886
|
const {
|
|
8847
8887
|
media
|
|
8848
8888
|
} = theme.sanity;
|
|
@@ -9189,12 +9229,12 @@ function ToastProvider(props) {
|
|
|
9189
9229
|
paddingY,
|
|
9190
9230
|
children: /* @__PURE__ */jsx(AnimatePresence, {
|
|
9191
9231
|
initial: false,
|
|
9192
|
-
children: state.map(
|
|
9232
|
+
children: state.map(_ref28 => {
|
|
9193
9233
|
let {
|
|
9194
9234
|
dismiss,
|
|
9195
9235
|
id,
|
|
9196
9236
|
params
|
|
9197
|
-
} =
|
|
9237
|
+
} = _ref28;
|
|
9198
9238
|
return /* @__PURE__ */jsx(motion.div, {
|
|
9199
9239
|
animate: {
|
|
9200
9240
|
opacity: 1,
|