@sanity/ui 2.13.4 → 2.14.0

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.
@@ -5,8 +5,15 @@ function _interopDefaultCompat(e) {
5
5
  }
6
6
  var ReactIs__default = /* @__PURE__ */ _interopDefaultCompat(ReactIs);
7
7
  const createColorTheme = theme.createColorTheme, hexToRgb = theme.hexToRgb, hslToRgb = theme.hslToRgb, multiply = theme.multiply, parseColor = theme.parseColor, rgbToHex = theme.rgbToHex, rgbToHsl = theme.rgbToHsl, rgba = theme.rgba, screen = theme.screen, studioTheme = theme.buildTheme(), EMPTY_ARRAY = [], EMPTY_RECORD = {}, POPOVER_MOTION_CONTENT_OPACITY_PROPERTY = "--motion-content-opacity", POPOVER_MOTION_PROPS = {
8
+ /**
9
+ * These variants makes use of special timing, by using a negative opacity as a starting position,
10
+ * as well as double opacity as the end position.
11
+ * The purpose of this is to make the tooltip/popover container appear before the content, and when exiting
12
+ * we want the content to disappear faster than the container.
13
+ */
8
14
  initial: {
9
15
  opacity: 0.5,
16
+ // the nagative opacity here, as well as the double opacity further down, are to make the content appear after the backgdrop, and when exiting the content should disappear first.
10
17
  [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: -1,
11
18
  scale: 0.97,
12
19
  willChange: "transform"
@@ -3485,7 +3492,19 @@ const MotionCard$1 = styledComponents.styled(framerMotion.motion.create(Card)).w
3485
3492
  ] }), $[48] = placement, $[49] = radius, $[50] = ref, $[51] = rootStyle2, $[52] = scheme, $[53] = shadow, $[54] = t11, $[55] = t12, $[56] = t8, $[57] = t9, $[58] = tone, $[59] = t13) : t13 = $[59], t13;
3486
3493
  }));
3487
3494
  PopoverCard.displayName = "Memo(ForwardRef(PopoverCard))";
3488
- const Popover = react.memo(react.forwardRef(function(props, forwardedRef) {
3495
+ const ViewportOverlay = () => {
3496
+ const $ = reactCompilerRuntime.c(2), {
3497
+ zIndex
3498
+ } = useLayer();
3499
+ let t0;
3500
+ return $[0] !== zIndex ? (t0 = /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
3501
+ height: "100vh",
3502
+ inset: 0,
3503
+ position: "fixed",
3504
+ width: "100vw",
3505
+ zIndex
3506
+ } }), $[0] = zIndex, $[1] = t0) : t0 = $[1], t0;
3507
+ }, Popover = react.memo(react.forwardRef(function(props, forwardedRef) {
3489
3508
  const {
3490
3509
  container,
3491
3510
  layer
@@ -3501,6 +3520,7 @@ const Popover = react.memo(react.forwardRef(function(props, forwardedRef) {
3501
3520
  fallbackPlacements = props.fallbackPlacements ?? DEFAULT_FALLBACK_PLACEMENTS$1[props.placement ?? "bottom"],
3502
3521
  matchReferenceWidth,
3503
3522
  floatingBoundary = props.boundaryElement ?? boundaryElementContext.element,
3523
+ modal,
3504
3524
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
3505
3525
  onActivate,
3506
3526
  open,
@@ -3608,7 +3628,10 @@ const Popover = react.memo(react.forwardRef(function(props, forwardedRef) {
3608
3628
  updateRef && (typeof updateRef == "function" ? updateRef(update) : updateRef && (updateRef.current = update));
3609
3629
  }, [update, updateRef]), disabled)
3610
3630
  return childProp || /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
3611
- const popover = /* @__PURE__ */ jsxRuntime.jsx(LayerProvider, { zOffset, children: /* @__PURE__ */ jsxRuntime.jsx(PopoverCard, { ...restProps, __unstable_margins: margins, animate, arrow: arrowProp, arrowRef: setArrow, arrowX, arrowY, hidden: referenceHidden, overflow, padding, placement, radius, ref: setFloating, scheme, shadow, originX, originY, strategy, tone, width: matchReferenceWidth ? referenceWidthRef.current : width, x, y, children: content }) }), children = open && (portal ? /* @__PURE__ */ jsxRuntime.jsx(Portal, { __unstable_name: typeof portal == "string" ? portal : void 0, children: popover }) : popover);
3631
+ const popover = /* @__PURE__ */ jsxRuntime.jsxs(LayerProvider, { zOffset, children: [
3632
+ modal && /* @__PURE__ */ jsxRuntime.jsx(ViewportOverlay, {}),
3633
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverCard, { ...restProps, __unstable_margins: margins, animate, arrow: arrowProp, arrowRef: setArrow, arrowX, arrowY, hidden: referenceHidden, overflow, padding, placement, radius, ref: setFloating, scheme, shadow, originX, originY, strategy, tone, width: matchReferenceWidth ? referenceWidthRef.current : width, x, y, children: content })
3634
+ ] }), children = open && (portal ? /* @__PURE__ */ jsxRuntime.jsx(Portal, { __unstable_name: typeof portal == "string" ? portal : void 0, children: popover }) : popover);
3612
3635
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3613
3636
  animate ? /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children }) : children,
3614
3637
  child