@sanity/ui 1.8.3 → 1.9.1
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 +40 -42
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +39 -41
- package/dist/index.js.map +1 -1
- package/package.json +4 -6
- package/src/primitives/tooltip/__workshop__/index.ts +10 -0
- package/src/primitives/tooltip/__workshop__/overflowingBoundary.tsx +53 -0
- package/src/primitives/tooltip/__workshop__/resizableBoundary.tsx +85 -0
- package/src/primitives/tooltip/constants.ts +1 -0
- package/src/primitives/tooltip/tooltip.test.tsx +67 -0
- package/src/primitives/tooltip/tooltip.tsx +35 -26
package/dist/index.esm.js
CHANGED
|
@@ -5,7 +5,7 @@ import styled, { ThemeProvider as ThemeProvider$1, useTheme as useTheme$1, css,
|
|
|
5
5
|
import { white as white$1, black as black$1, hues } from '@sanity/color';
|
|
6
6
|
import { SpinnerIcon, CheckmarkIcon, RemoveIcon, SelectIcon, CloseIcon, ChevronDownIcon, ChevronRightIcon, ToggleArrowRightIcon } from '@sanity/icons';
|
|
7
7
|
import Refractor from 'react-refractor';
|
|
8
|
-
import { detectOverflow, flip, offset, shift, arrow, hide, useFloating, autoUpdate
|
|
8
|
+
import { detectOverflow, flip, offset, shift, arrow, hide, useFloating, autoUpdate } from '@floating-ui/react-dom';
|
|
9
9
|
import { createPortal } from 'react-dom';
|
|
10
10
|
import { AnimatePresence, motion } from 'framer-motion';
|
|
11
11
|
const EMPTY_ARRAY = [];
|
|
@@ -6847,6 +6847,7 @@ function useDelayedState(initialState) {
|
|
|
6847
6847
|
}, []);
|
|
6848
6848
|
return [state, onStateChange];
|
|
6849
6849
|
}
|
|
6850
|
+
const DEFAULT_TOOLTIP_PADDING = 4;
|
|
6850
6851
|
const DEFAULT_FALLBACK_PLACEMENTS = {
|
|
6851
6852
|
top: ["bottom", "left", "right"],
|
|
6852
6853
|
"top-start": ["bottom-start", "left-start", "right-start"],
|
|
@@ -6930,7 +6931,7 @@ var __template$e = (cooked, raw) => __freeze$e(__defProp$e(cooked, "raw", {
|
|
|
6930
6931
|
value: __freeze$e(raw || cooked.slice())
|
|
6931
6932
|
}));
|
|
6932
6933
|
var _a$e;
|
|
6933
|
-
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 // Note that 100vw doesn't exclude system scrollbars.\n // This should be sufficiently small enough to not trigger overflow-x scrollbars when portalled.\n max-width: calc(100vw - ", "px);\n"])), DEFAULT_TOOLTIP_PADDING * 10);
|
|
6934
6935
|
const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
6935
6936
|
var _a2, _b, _c, _d, _e;
|
|
6936
6937
|
const boundaryElementContext = useBoundaryElement();
|
|
@@ -6958,42 +6959,25 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
|
6958
6959
|
const middleware = useMemo(() => {
|
|
6959
6960
|
const ret = [];
|
|
6960
6961
|
ret.push(flip({
|
|
6961
|
-
boundary: boundaryElement || void 0,
|
|
6962
|
+
boundary: portal ? void 0 : boundaryElement || void 0,
|
|
6962
6963
|
fallbackPlacements,
|
|
6963
|
-
padding:
|
|
6964
|
-
rootBoundary
|
|
6965
|
-
mainAxis: false
|
|
6964
|
+
padding: DEFAULT_TOOLTIP_PADDING,
|
|
6965
|
+
rootBoundary
|
|
6966
6966
|
}));
|
|
6967
6967
|
ret.push(offset({
|
|
6968
6968
|
mainAxis: 3
|
|
6969
6969
|
}));
|
|
6970
|
-
ret.push(size$2({
|
|
6971
|
-
apply(_ref22) {
|
|
6972
|
-
let {
|
|
6973
|
-
availableWidth,
|
|
6974
|
-
availableHeight,
|
|
6975
|
-
elements
|
|
6976
|
-
} = _ref22;
|
|
6977
|
-
Object.assign(elements.floating.style, {
|
|
6978
|
-
maxWidth: "".concat(availableWidth - 4 * 2, "px"),
|
|
6979
|
-
// the padding is `4px`
|
|
6980
|
-
maxHeight: "".concat(availableHeight - 4 * 2, "px")
|
|
6981
|
-
// the padding is `4px`
|
|
6982
|
-
});
|
|
6983
|
-
}
|
|
6984
|
-
}));
|
|
6985
|
-
|
|
6986
6970
|
ret.push(shift({
|
|
6987
|
-
boundary: boundaryElement || void 0,
|
|
6971
|
+
boundary: portal ? void 0 : boundaryElement || void 0,
|
|
6988
6972
|
rootBoundary,
|
|
6989
|
-
padding:
|
|
6973
|
+
padding: DEFAULT_TOOLTIP_PADDING
|
|
6990
6974
|
}));
|
|
6991
6975
|
ret.push(arrow({
|
|
6992
6976
|
element: arrowRef,
|
|
6993
6977
|
padding: 2
|
|
6994
6978
|
}));
|
|
6995
6979
|
return ret;
|
|
6996
|
-
}, [boundaryElement, fallbackPlacements]);
|
|
6980
|
+
}, [boundaryElement, fallbackPlacements, portal]);
|
|
6997
6981
|
const {
|
|
6998
6982
|
floatingStyles,
|
|
6999
6983
|
placement,
|
|
@@ -7027,19 +7011,21 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
|
7027
7011
|
const closeDelayProp = typeof delay === "number" ? delay : (delay == null ? void 0 : delay.close) || 0;
|
|
7028
7012
|
const openDelay = isInsideGroup ? delayGroupContext.openDelay : openDelayProp;
|
|
7029
7013
|
const closeDelay = isInsideGroup ? delayGroupContext.closeDelay : closeDelayProp;
|
|
7030
|
-
const handleIsOpenChange = useCallback(open => {
|
|
7014
|
+
const handleIsOpenChange = useCallback((open, immediate) => {
|
|
7031
7015
|
if (isInsideGroup) {
|
|
7032
7016
|
if (open) {
|
|
7033
|
-
|
|
7034
|
-
delayGroupContext.
|
|
7017
|
+
const groupedOpenDelay = immediate ? 0 : openDelay;
|
|
7018
|
+
delayGroupContext.setIsGroupActive(open, groupedOpenDelay);
|
|
7019
|
+
delayGroupContext.setOpenTooltipId(tooltipId, groupedOpenDelay);
|
|
7035
7020
|
} else {
|
|
7036
7021
|
const minimumGroupDeactivateDelay = 200;
|
|
7037
7022
|
const groupDeactivateDelay = closeDelay > minimumGroupDeactivateDelay ? closeDelay : minimumGroupDeactivateDelay;
|
|
7038
7023
|
delayGroupContext.setIsGroupActive(open, groupDeactivateDelay);
|
|
7039
|
-
delayGroupContext.setOpenTooltipId(null, closeDelay);
|
|
7024
|
+
delayGroupContext.setOpenTooltipId(null, immediate ? 0 : closeDelay);
|
|
7040
7025
|
}
|
|
7041
7026
|
} else {
|
|
7042
|
-
|
|
7027
|
+
const standaloneDelay = immediate ? 0 : open ? openDelay : closeDelay;
|
|
7028
|
+
setIsOpen(open, standaloneDelay);
|
|
7043
7029
|
}
|
|
7044
7030
|
}, [isInsideGroup, delayGroupContext, openDelay, tooltipId, closeDelay, setIsOpen]);
|
|
7045
7031
|
const handleBlur = useCallback(() => handleIsOpenChange(false), [handleIsOpenChange]);
|
|
@@ -7068,6 +7054,18 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
|
|
|
7068
7054
|
if (!content) handleIsOpenChange(false);
|
|
7069
7055
|
}, [content, handleIsOpenChange]);
|
|
7070
7056
|
useEffect(() => refs.setReference(referenceElement), [referenceElement, refs]);
|
|
7057
|
+
useEffect(() => {
|
|
7058
|
+
if (!showTooltip) return;
|
|
7059
|
+
function handleWindowKeyDown(event) {
|
|
7060
|
+
if (event.key === "Escape") {
|
|
7061
|
+
handleIsOpenChange(false, true);
|
|
7062
|
+
}
|
|
7063
|
+
}
|
|
7064
|
+
window.addEventListener("keydown", handleWindowKeyDown);
|
|
7065
|
+
return () => {
|
|
7066
|
+
window.removeEventListener("keydown", handleWindowKeyDown);
|
|
7067
|
+
};
|
|
7068
|
+
}, [handleIsOpenChange, showTooltip]);
|
|
7071
7069
|
const setArrow = useCallback(arrowEl => {
|
|
7072
7070
|
arrowRef.current = arrowEl;
|
|
7073
7071
|
update();
|
|
@@ -7279,10 +7277,10 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete2(props, ref) {
|
|
|
7279
7277
|
query,
|
|
7280
7278
|
value
|
|
7281
7279
|
} = state;
|
|
7282
|
-
const defaultRenderOption = useCallback(
|
|
7280
|
+
const defaultRenderOption = useCallback(_ref22 => {
|
|
7283
7281
|
let {
|
|
7284
7282
|
value: value2
|
|
7285
|
-
} =
|
|
7283
|
+
} = _ref22;
|
|
7286
7284
|
return /* @__PURE__ */jsx(Card, {
|
|
7287
7285
|
"data-as": "button",
|
|
7288
7286
|
padding: paddingProp,
|
|
@@ -7735,10 +7733,10 @@ const Breadcrumbs = forwardRef(function Breadcrumbs2(props, ref) {
|
|
|
7735
7733
|
}, itemIndex))
|
|
7736
7734
|
});
|
|
7737
7735
|
});
|
|
7738
|
-
function dialogStyle(
|
|
7736
|
+
function dialogStyle(_ref23) {
|
|
7739
7737
|
let {
|
|
7740
7738
|
theme
|
|
7741
|
-
} =
|
|
7739
|
+
} = _ref23;
|
|
7742
7740
|
const color = theme.sanity.color.base;
|
|
7743
7741
|
return {
|
|
7744
7742
|
"&:not([hidden])": {
|
|
@@ -8800,15 +8798,15 @@ var __template$6 = (cooked, raw) => __freeze$6(__defProp$6(cooked, "raw", {
|
|
|
8800
8798
|
var _a$6, _b$3, _c$1, _d;
|
|
8801
8799
|
const keyframe = keyframes(_a$6 || (_a$6 = __template$6(["\n 0% {\n background-position: 100%;\n }\n 100% {\n background-position: -100%;\n }\n"])));
|
|
8802
8800
|
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);
|
|
8803
|
-
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"])),
|
|
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"])), _ref24 => {
|
|
8804
8802
|
let {
|
|
8805
8803
|
$visible
|
|
8806
|
-
} =
|
|
8804
|
+
} = _ref24;
|
|
8807
8805
|
return $visible ? 1 : 0;
|
|
8808
|
-
},
|
|
8806
|
+
}, _ref25 => {
|
|
8809
8807
|
let {
|
|
8810
8808
|
$animated
|
|
8811
|
-
} =
|
|
8809
|
+
} = _ref25;
|
|
8812
8810
|
return $animated ? animation : css(_c$1 || (_c$1 = __template$6(["\n background-color: var(--card-skeleton-color-from);\n "])));
|
|
8813
8811
|
});
|
|
8814
8812
|
const Root$4 = styled(Box)(responsiveRadiusStyle, skeletonStyle);
|
|
@@ -8839,12 +8837,12 @@ const Skeleton = forwardRef(function Skeleton2(props, ref) {
|
|
|
8839
8837
|
ref
|
|
8840
8838
|
});
|
|
8841
8839
|
});
|
|
8842
|
-
const Root$3 = styled(Skeleton)(
|
|
8840
|
+
const Root$3 = styled(Skeleton)(_ref26 => {
|
|
8843
8841
|
let {
|
|
8844
8842
|
$size,
|
|
8845
8843
|
$style,
|
|
8846
8844
|
theme
|
|
8847
|
-
} =
|
|
8845
|
+
} = _ref26;
|
|
8848
8846
|
const {
|
|
8849
8847
|
media
|
|
8850
8848
|
} = theme.sanity;
|
|
@@ -9191,12 +9189,12 @@ function ToastProvider(props) {
|
|
|
9191
9189
|
paddingY,
|
|
9192
9190
|
children: /* @__PURE__ */jsx(AnimatePresence, {
|
|
9193
9191
|
initial: false,
|
|
9194
|
-
children: state.map(
|
|
9192
|
+
children: state.map(_ref27 => {
|
|
9195
9193
|
let {
|
|
9196
9194
|
dismiss,
|
|
9197
9195
|
id,
|
|
9198
9196
|
params
|
|
9199
|
-
} =
|
|
9197
|
+
} = _ref27;
|
|
9200
9198
|
return /* @__PURE__ */jsx(motion.div, {
|
|
9201
9199
|
animate: {
|
|
9202
9200
|
opacity: 1,
|