@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.
@@ -11,8 +11,15 @@ import { ResizeObserver } from "@juggle/resize-observer";
11
11
  import { createPortal } from "react-dom";
12
12
  import { useEffectEvent } from "use-effect-event";
13
13
  const createColorTheme = createColorTheme$1, hexToRgb = hexToRgb$1, hslToRgb = hslToRgb$1, multiply = multiply$1, parseColor = parseColor$1, rgbToHex = rgbToHex$1, rgbToHsl = rgbToHsl$1, rgba = rgba$1, screen = screen$1, studioTheme = buildTheme(), EMPTY_ARRAY = [], EMPTY_RECORD = {}, POPOVER_MOTION_CONTENT_OPACITY_PROPERTY = "--motion-content-opacity", POPOVER_MOTION_PROPS = {
14
+ /**
15
+ * These variants makes use of special timing, by using a negative opacity as a starting position,
16
+ * as well as double opacity as the end position.
17
+ * The purpose of this is to make the tooltip/popover container appear before the content, and when exiting
18
+ * we want the content to disappear faster than the container.
19
+ */
14
20
  initial: {
15
21
  opacity: 0.5,
22
+ // 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.
16
23
  [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: -1,
17
24
  scale: 0.97,
18
25
  willChange: "transform"
@@ -3489,7 +3496,19 @@ const MotionCard$1 = styled(motion.create(Card)).withConfig({
3489
3496
  ] }), $[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;
3490
3497
  }));
3491
3498
  PopoverCard.displayName = "Memo(ForwardRef(PopoverCard))";
3492
- const Popover = memo(forwardRef(function(props, forwardedRef) {
3499
+ const ViewportOverlay = () => {
3500
+ const $ = c(2), {
3501
+ zIndex
3502
+ } = useLayer();
3503
+ let t0;
3504
+ return $[0] !== zIndex ? (t0 = /* @__PURE__ */ jsx("div", { style: {
3505
+ height: "100vh",
3506
+ inset: 0,
3507
+ position: "fixed",
3508
+ width: "100vw",
3509
+ zIndex
3510
+ } }), $[0] = zIndex, $[1] = t0) : t0 = $[1], t0;
3511
+ }, Popover = memo(forwardRef(function(props, forwardedRef) {
3493
3512
  const {
3494
3513
  container,
3495
3514
  layer
@@ -3505,6 +3524,7 @@ const Popover = memo(forwardRef(function(props, forwardedRef) {
3505
3524
  fallbackPlacements = props.fallbackPlacements ?? DEFAULT_FALLBACK_PLACEMENTS$1[props.placement ?? "bottom"],
3506
3525
  matchReferenceWidth,
3507
3526
  floatingBoundary = props.boundaryElement ?? boundaryElementContext.element,
3527
+ modal,
3508
3528
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
3509
3529
  onActivate,
3510
3530
  open,
@@ -3612,7 +3632,10 @@ const Popover = memo(forwardRef(function(props, forwardedRef) {
3612
3632
  updateRef && (typeof updateRef == "function" ? updateRef(update) : updateRef && (updateRef.current = update));
3613
3633
  }, [update, updateRef]), disabled)
3614
3634
  return childProp || /* @__PURE__ */ jsx(Fragment, {});
3615
- const popover = /* @__PURE__ */ jsx(LayerProvider, { zOffset, children: /* @__PURE__ */ 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__ */ jsx(Portal, { __unstable_name: typeof portal == "string" ? portal : void 0, children: popover }) : popover);
3635
+ const popover = /* @__PURE__ */ jsxs(LayerProvider, { zOffset, children: [
3636
+ modal && /* @__PURE__ */ jsx(ViewportOverlay, {}),
3637
+ /* @__PURE__ */ 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 })
3638
+ ] }), children = open && (portal ? /* @__PURE__ */ jsx(Portal, { __unstable_name: typeof portal == "string" ? portal : void 0, children: popover }) : popover);
3616
3639
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3617
3640
  animate ? /* @__PURE__ */ jsx(AnimatePresence, { children }) : children,
3618
3641
  child