@sanity/ui 2.15.17 → 2.16.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,7 +5,7 @@ import { useState, useEffect, useDebugValue, useSyncExternalStore, createContext
5
5
  import { ThemeProvider as ThemeProvider$1, useTheme as useTheme$1, css, styled, keyframes } from "styled-components";
6
6
  import ReactIs, { isValidElementType } from "react-is";
7
7
  import { SpinnerIcon, CheckmarkIcon, RemoveIcon, ChevronDownIcon, CloseIcon, ChevronRightIcon } from "@sanity/icons";
8
- import { detectOverflow, flip, offset, shift, arrow, hide, useFloating, autoUpdate } from "@floating-ui/react-dom";
8
+ import { detectOverflow, autoPlacement, flip, offset, shift, arrow, hide, useFloating, autoUpdate } from "@floating-ui/react-dom";
9
9
  import { motion, AnimatePresence } from "framer-motion";
10
10
  import { ResizeObserver } from "@juggle/resize-observer";
11
11
  import { createPortal } from "react-dom";
@@ -2702,7 +2702,7 @@ const StyledInline = /* @__PURE__ */ styled(Box).withConfig({
2702
2702
  displayName: "StyledInline",
2703
2703
  componentId: "sc-1pkiy6j-0"
2704
2704
  })(inlineBaseStyle, inlineSpaceStyle), Inline = forwardRef(function(props, ref) {
2705
- const $ = c(12);
2705
+ const $ = c(13);
2706
2706
  let as, childrenProp, restProps, space;
2707
2707
  $[0] !== props ? ({
2708
2708
  as,
@@ -2712,9 +2712,9 @@ const StyledInline = /* @__PURE__ */ styled(Box).withConfig({
2712
2712
  } = props, $[0] = props, $[1] = as, $[2] = childrenProp, $[3] = restProps, $[4] = space) : (as = $[1], childrenProp = $[2], restProps = $[3], space = $[4]);
2713
2713
  let t0, t1;
2714
2714
  $[5] !== childrenProp ? (t1 = Children.map(childrenProp, _temp$4), $[5] = childrenProp, $[6] = t1) : t1 = $[6], t0 = t1;
2715
- const children = t0, t2 = useArrayProp(space);
2716
- let t3;
2717
- return $[7] !== as || $[8] !== children || $[9] !== restProps || $[10] !== t2 ? (t3 = /* @__PURE__ */ jsx(StyledInline, { "data-ui": "Inline", ...restProps, $space: t2, forwardedAs: as, ref, children }), $[7] = as, $[8] = children, $[9] = restProps, $[10] = t2, $[11] = t3) : t3 = $[11], t3;
2715
+ const children = t0, t2 = useArrayProp(space), t3 = ref;
2716
+ let t4;
2717
+ return $[7] !== as || $[8] !== children || $[9] !== restProps || $[10] !== t2 || $[11] !== t3 ? (t4 = /* @__PURE__ */ jsx(StyledInline, { "data-ui": "Inline", ...restProps, $space: t2, forwardedAs: as, ref: t3, children }), $[7] = as, $[8] = children, $[9] = restProps, $[10] = t2, $[11] = t3, $[12] = t4) : t4 = $[12], t4;
2718
2718
  });
2719
2719
  Inline.displayName = "ForwardRef(Inline)";
2720
2720
  function _temp$4(child) {
@@ -3538,6 +3538,7 @@ const ViewportOverlay = () => {
3538
3538
  overflow = "hidden",
3539
3539
  padding: paddingProp,
3540
3540
  placement: placementProp = "bottom",
3541
+ placementStrategy = "flip",
3541
3542
  portal,
3542
3543
  preventOverflow = !0,
3543
3544
  radius: radiusProp = 3,
@@ -3576,12 +3577,14 @@ const ViewportOverlay = () => {
3576
3577
  }, [width, matchReferenceWidth, maxWidth, open]);
3577
3578
  const middleware = useMemo(() => {
3578
3579
  const ret = [];
3579
- return (constrainSize || preventOverflow) && ret.push(flip({
3580
+ return (constrainSize || preventOverflow) && (placementStrategy === "autoPlacement" ? ret.push(autoPlacement({
3581
+ allowedPlacements: [placementProp].concat(fallbackPlacements)
3582
+ })) : ret.push(flip({
3580
3583
  boundary: floatingBoundary || void 0,
3581
3584
  fallbackPlacements,
3582
3585
  padding: DEFAULT_POPOVER_PADDING,
3583
3586
  rootBoundary
3584
- })), ret.push(offset({
3587
+ }))), ret.push(offset({
3585
3588
  mainAxis: DEFAULT_POPOVER_DISTANCE
3586
3589
  })), (constrainSize || matchReferenceWidth) && ret.push(size({
3587
3590
  apply({
@@ -3609,7 +3612,7 @@ const ViewportOverlay = () => {
3609
3612
  padding: DEFAULT_POPOVER_PADDING,
3610
3613
  strategy: "referenceHidden"
3611
3614
  })), ret;
3612
- }, [animate, arrowProp, constrainSize, fallbackPlacements, floatingBoundary, margins, matchReferenceWidth, preventOverflow, referenceBoundary]), {
3615
+ }, [animate, arrowProp, constrainSize, fallbackPlacements, placementProp, placementStrategy, floatingBoundary, margins, matchReferenceWidth, preventOverflow, referenceBoundary]), {
3613
3616
  x,
3614
3617
  y,
3615
3618
  middlewareData,