@sanity/ui 2.3.6-canary.2 → 2.3.6-canary.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.d.mts CHANGED
@@ -1258,7 +1258,6 @@ export declare interface LayerContextValue {
1258
1258
  version: 0.0
1259
1259
  isTopLayer: boolean
1260
1260
  level?: number
1261
- registerChild: (childLevel?: number) => () => void
1262
1261
  size: number
1263
1262
  zIndex: number
1264
1263
  }
@@ -1512,6 +1511,7 @@ export declare interface PopoverProps
1512
1511
  arrow?: boolean
1513
1512
  /** @deprecated Use `floatingBoundary` and/or `referenceBoundary` instead */
1514
1513
  boundaryElement?: HTMLElement | null
1514
+ /** @deprecated Use `referenceElement` instead */
1515
1515
  children?: React.ReactElement
1516
1516
  /**
1517
1517
  * When `true`, prevent overflow within the current boundary:
package/dist/index.d.ts CHANGED
@@ -1258,7 +1258,6 @@ export declare interface LayerContextValue {
1258
1258
  version: 0.0
1259
1259
  isTopLayer: boolean
1260
1260
  level?: number
1261
- registerChild: (childLevel?: number) => () => void
1262
1261
  size: number
1263
1262
  zIndex: number
1264
1263
  }
@@ -1512,6 +1511,7 @@ export declare interface PopoverProps
1512
1511
  arrow?: boolean
1513
1512
  /** @deprecated Use `floatingBoundary` and/or `referenceBoundary` instead */
1514
1513
  boundaryElement?: HTMLElement | null
1514
+ /** @deprecated Use `referenceElement` instead */
1515
1515
  children?: React.ReactElement
1516
1516
  /**
1517
1517
  * When `true`, prevent overflow within the current boundary:
package/dist/index.esm.js CHANGED
@@ -937,7 +937,7 @@ const Root$B = styled.div(
937
937
  status = "online",
938
938
  size: sizeProp = 1,
939
939
  ...restProps
940
- } = props, { avatar } = useTheme_v2(), as = isValidElementType(asProp) ? asProp : "div", size2 = useMemo(() => _getArrayProp(sizeProp), [sizeProp]), _sizeRem = (avatar.sizes[size2[0]] || avatar.sizes[0]).size, _radius = _sizeRem / 2, elementId = useId(), [arrowPosition, setArrowPosition] = useState(
940
+ } = props, { avatar } = useTheme_v2(), as = isValidElementType(asProp) ? asProp : "div", size2 = _getArrayProp(sizeProp), _sizeRem = (avatar.sizes[size2[0]] || avatar.sizes[0]).size, _radius = _sizeRem / 2, elementId = useId(), [arrowPosition, setArrowPosition] = useState(
941
941
  animateArrowFrom || arrowPositionProp || "inside"
942
942
  ), [imageFailed, setImageFailed] = useState(!1), imageId = `avatar-image-${elementId}`;
943
943
  useEffect(() => {
@@ -949,10 +949,7 @@ const Root$B = styled.div(
949
949
  }, [src]);
950
950
  const handleImageError = useCallback(() => {
951
951
  setImageFailed(!0), onImageLoadError && onImageLoadError(new Error("Avatar: the image failed to load"));
952
- }, [onImageLoadError]), initialsSize = useMemo(
953
- () => size2.map((s) => s === 1 ? 1 : s === 2 ? 3 : s === 3 ? 5 : 0),
954
- [size2]
955
- );
952
+ }, [onImageLoadError]), initialsSize = size2.map((s) => s === 1 ? 1 : s === 2 ? 3 : s === 3 ? 5 : 0);
956
953
  return /* @__PURE__ */ jsxs(
957
954
  Root$B,
958
955
  {
@@ -1047,11 +1044,8 @@ const Root$A = styled.div(
1047
1044
  _responsiveAvatarCounterSizeStyle,
1048
1045
  _avatarCounterBaseStyle
1049
1046
  ), AvatarCounter = forwardRef(function(props, ref) {
1050
- const { count, size: sizeProp = 1 } = props, size2 = useMemo(() => _getArrayProp(sizeProp), [sizeProp]), fontSize2 = useMemo(
1051
- () => size2.map((s) => s === 1 ? 1 : s === 2 ? 3 : s === 3 ? 5 : 0),
1052
- [size2]
1053
- );
1054
- return /* @__PURE__ */ jsx(Root$A, { $size: size2, "data-ui": "AvatarCounter", ref, children: /* @__PURE__ */ jsx(Label, { as: "span", size: fontSize2, weight: "medium", children: count }) });
1047
+ const { count, size: size2 } = props, $size = _getArrayProp(size2 != null ? size2 : 1), fontSize2 = $size.map((s) => s === 1 ? 1 : s === 2 ? 3 : s === 3 ? 5 : 0);
1048
+ return /* @__PURE__ */ jsx(Root$A, { $size, "data-ui": "AvatarCounter", ref, children: /* @__PURE__ */ jsx(Label, { as: "span", size: fontSize2, weight: "medium", children: count }) });
1055
1049
  }), BASE_STYLES = css`
1056
1050
  white-space: nowrap;
1057
1051
 
@@ -1083,10 +1077,7 @@ const Root$z = styled.div(responsiveAvatarStackSizeStyle, avatarStackStyle), Ava
1083
1077
  maxLength: maxLengthProp = 4,
1084
1078
  size: sizeProp = 1,
1085
1079
  ...restProps
1086
- } = props, children = useMemo(
1087
- () => Children.toArray(childrenProp).filter(isValidElement),
1088
- [childrenProp]
1089
- ), maxLength = Math.max(maxLengthProp, 0), size2 = useMemo(() => _getArrayProp(sizeProp), [sizeProp]), len = children.length, visibleCount = maxLength - 1, extraCount = len - visibleCount, visibleChildren = extraCount > 1 ? children.slice(extraCount, len) : children;
1080
+ } = props, children = Children.toArray(childrenProp).filter(isValidElement), maxLength = Math.max(maxLengthProp, 0), size2 = useMemo(() => _getArrayProp(sizeProp), [sizeProp]), len = children.length, visibleCount = maxLength - 1, extraCount = len - visibleCount, visibleChildren = extraCount > 1 ? children.slice(extraCount, len) : children;
1090
1081
  return /* @__PURE__ */ jsxs(Root$z, { "data-ui": "AvatarStack", ...restProps, ref, $size: size2, children: [
1091
1082
  len === 0 && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(AvatarCounter, { count: len, size: size2 }) }),
1092
1083
  len !== 0 && extraCount > 1 && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(AvatarCounter, { count: extraCount, size: size2 }) }),
@@ -2833,10 +2824,10 @@ function findMinBreakpoints(media, width) {
2833
2824
  return ret;
2834
2825
  }
2835
2826
  const ElementQuery = forwardRef(function(props, forwardedRef) {
2836
- const theme = useTheme_v2(), { children, media = theme.media, ...restProps } = props, ref = useRef(null), [element, setElement] = useState(null), elementSize = useElementSize(element), width = useMemo(() => {
2827
+ const theme = useTheme_v2(), { children, media: _media, ...restProps } = props, media = _media != null ? _media : theme.media, ref = useRef(null), [element, setElement] = useState(null), elementSize = useElementSize(element), width = useMemo(() => {
2837
2828
  var _a;
2838
2829
  return (_a = elementSize == null ? void 0 : elementSize.border.width) != null ? _a : window.innerWidth;
2839
- }, [elementSize]), max = useMemo(() => findMaxBreakpoints(media, width), [media, width]), min = useMemo(() => findMinBreakpoints(media, width), [media, width]);
2830
+ }, [elementSize]), max = findMaxBreakpoints(media, width), min = findMinBreakpoints(media, width);
2840
2831
  useImperativeHandle(forwardedRef, () => ref.current);
2841
2832
  const setRef = useCallback((el) => {
2842
2833
  ref.current = el, setElement(el);
@@ -2970,18 +2961,18 @@ function _isScrollable(el) {
2970
2961
  }
2971
2962
  function LayerProvider(props) {
2972
2963
  var _a;
2973
- const { children, zOffset: zOffsetProp = 0 } = props, parentContextValue = useContext(LayerContext), parent = parentContextValue && getLayerContext(parentContextValue), parentRegisterChild = parent == null ? void 0 : parent.registerChild, level = ((_a = parent == null ? void 0 : parent.level) != null ? _a : 0) + 1, zOffset = useMemo(() => _getArrayProp(zOffsetProp), [zOffsetProp]), maxMediaIndex = zOffset.length - 1, mediaIndex = Math.min(useMediaIndex(), maxMediaIndex), zIndex = parent ? parent.zIndex + zOffset[mediaIndex] : zOffset[mediaIndex], [, setChildLayers] = useState({}), [size2, setSize] = useState(0), isTopLayer = size2 === 0, registerChild = useCallback(
2964
+ const { children, zOffset: zOffsetProp = 0 } = props, parentContextValue = useContext(LayerContext), parentRegisterChild = useContext(LayerContextRegisterChild), parent = parentContextValue && getLayerContext(parentContextValue), level = ((_a = parent == null ? void 0 : parent.level) != null ? _a : 0) + 1, zOffset = useMemo(() => _getArrayProp(zOffsetProp), [zOffsetProp]), maxMediaIndex = zOffset.length - 1, mediaIndex = Math.min(useMediaIndex(), maxMediaIndex), zIndex = parent ? parent.zIndex + zOffset[mediaIndex] : zOffset[mediaIndex], [childLayers, setChildLayers] = useState({}), size2 = useMemo(() => Object.keys(childLayers).length, [childLayers]), isTopLayer = size2 === 0, registerChild = useCallback(
2974
2965
  (childLevel) => {
2975
2966
  const parentDispose = parentRegisterChild == null ? void 0 : parentRegisterChild(childLevel);
2976
- return childLevel !== void 0 ? setChildLayers((state) => {
2967
+ return setChildLayers((state) => {
2977
2968
  var _a2;
2978
- const prevLen = (_a2 = state[childLevel]) != null ? _a2 : 0, nextState = { ...state, [childLevel]: prevLen + 1 };
2979
- return setSize(Object.keys(nextState).length), nextState;
2980
- }) : setSize((v) => v + 1), () => {
2981
- childLevel !== void 0 ? setChildLayers((state) => {
2969
+ const prevLen = (_a2 = state[childLevel]) != null ? _a2 : 0;
2970
+ return { ...state, [childLevel]: prevLen + 1 };
2971
+ }), () => {
2972
+ setChildLayers((state) => {
2982
2973
  const nextState = { ...state };
2983
- return nextState[childLevel] === 1 ? (delete nextState[childLevel], setSize(Object.keys(nextState).length)) : nextState[childLevel] -= 1, nextState;
2984
- }) : setSize((v) => v - 1), parentDispose == null || parentDispose();
2974
+ return nextState[childLevel] === 1 ? delete nextState[childLevel] : nextState[childLevel] -= 1, nextState;
2975
+ }), parentDispose == null || parentDispose();
2985
2976
  };
2986
2977
  },
2987
2978
  [parentRegisterChild]
@@ -2992,15 +2983,14 @@ function LayerProvider(props) {
2992
2983
  version: 0,
2993
2984
  isTopLayer,
2994
2985
  level,
2995
- registerChild,
2996
2986
  size: size2,
2997
2987
  zIndex
2998
2988
  }),
2999
- [isTopLayer, level, registerChild, size2, zIndex]
2989
+ [isTopLayer, level, size2, zIndex]
3000
2990
  );
3001
- return /* @__PURE__ */ jsx(LayerContext.Provider, { value, children });
2991
+ return /* @__PURE__ */ jsx(LayerContext.Provider, { value, children: /* @__PURE__ */ jsx(LayerContextRegisterChild.Provider, { value: registerChild, children }) });
3002
2992
  }
3003
- const Root$j = styled.div({ position: "relative" }), LayerChildren = forwardRef(function(props, forwardedRef) {
2993
+ const LayerContextRegisterChild = createContext(null), Root$j = styled.div({ position: "relative" }), LayerChildren = forwardRef(function(props, forwardedRef) {
3004
2994
  const { children, onActivate, onFocus, style = EMPTY_RECORD, ...restProps } = props, { zIndex, isTopLayer } = useLayer(), lastFocusedRef = useRef(null), ref = useRef(null), isTopLayerRef = useRef(isTopLayer);
3005
2995
  useImperativeHandle(forwardedRef, () => ref.current), useEffect(() => {
3006
2996
  isTopLayerRef.current !== isTopLayer && isTopLayer && (onActivate == null || onActivate({ activeElement: lastFocusedRef.current })), isTopLayerRef.current = isTopLayer;
@@ -3268,19 +3258,19 @@ const MotionCard$1 = styled(motion(Card))`
3268
3258
  PopoverCard.displayName = "PopoverCard";
3269
3259
  const Popover = memo(
3270
3260
  forwardRef(function(props, forwardedRef) {
3271
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
3261
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
3272
3262
  const { container, layer } = useTheme_v2(), boundaryElementContext = useBoundaryElement(), {
3273
3263
  __unstable_margins: margins = DEFAULT_POPOVER_MARGINS,
3274
3264
  animate: _animate = !1,
3275
3265
  arrow: arrowProp = !1,
3276
- boundaryElement = boundaryElementContext.element,
3277
- children: childProp,
3266
+ boundaryElement: _boundaryElement,
3267
+ children,
3278
3268
  constrainSize = !1,
3279
3269
  content,
3280
3270
  disabled,
3281
- fallbackPlacements = (_b = props.fallbackPlacements) != null ? _b : DEFAULT_FALLBACK_PLACEMENTS$1[(_a = props.placement) != null ? _a : "bottom"],
3271
+ fallbackPlacements: _fallbackPlacements,
3282
3272
  matchReferenceWidth,
3283
- floatingBoundary = (_c = props.boundaryElement) != null ? _c : boundaryElementContext.element,
3273
+ floatingBoundary: _floatingBoundary,
3284
3274
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
3285
3275
  onActivate,
3286
3276
  open,
@@ -3290,16 +3280,16 @@ const Popover = memo(
3290
3280
  portal,
3291
3281
  preventOverflow = !0,
3292
3282
  radius: radiusProp = 3,
3293
- referenceBoundary = (_d = props.boundaryElement) != null ? _d : boundaryElementContext.element,
3283
+ referenceBoundary: _referenceBoundary,
3294
3284
  referenceElement,
3295
3285
  scheme,
3296
3286
  shadow: shadowProp = 3,
3297
3287
  tone = "inherit",
3298
3288
  width: widthProp = "auto",
3299
- zOffset: zOffsetProp = layer.popover.zOffset,
3289
+ zOffset: _zOffset,
3300
3290
  updateRef,
3301
3291
  ...restProps
3302
- } = props, animate = usePrefersReducedMotion() ? !1 : _animate, boundarySize = (_e = useElementSize(boundaryElement)) == null ? void 0 : _e.border, padding = useMemo(() => _getArrayProp(paddingProp), [paddingProp]), radius = useMemo(() => _getArrayProp(radiusProp), [radiusProp]), shadow = useMemo(() => _getArrayProp(shadowProp), [shadowProp]), widthArrayProp = useMemo(() => _getArrayProp(widthProp), [widthProp]), zOffset = useMemo(() => _getArrayProp(zOffsetProp), [zOffsetProp]), ref = useRef(null), arrowRef = useRef(null), rootBoundary = "viewport";
3292
+ } = props, boundaryElement = _boundaryElement != null ? _boundaryElement : boundaryElementContext.element, referenceBoundary = (_a = _referenceBoundary != null ? _referenceBoundary : props.boundaryElement) != null ? _a : boundaryElementContext.element, floatingBoundary = (_b = _floatingBoundary != null ? _floatingBoundary : props.boundaryElement) != null ? _b : boundaryElementContext.element, fallbackPlacements = _fallbackPlacements != null ? _fallbackPlacements : DEFAULT_FALLBACK_PLACEMENTS$1[(_c = props.placement) != null ? _c : "bottom"], zOffsetProp = _zOffset != null ? _zOffset : layer.popover.zOffset, animate = usePrefersReducedMotion() ? !1 : _animate, boundarySize = (_d = useElementSize(boundaryElement)) == null ? void 0 : _d.border, padding = useMemo(() => _getArrayProp(paddingProp), [paddingProp]), radius = useMemo(() => _getArrayProp(radiusProp), [radiusProp]), shadow = useMemo(() => _getArrayProp(shadowProp), [shadowProp]), widthArrayProp = _getArrayProp(widthProp), zOffset = useMemo(() => _getArrayProp(zOffsetProp), [zOffsetProp]), ref = useRef(null), arrowRef = useRef(null), rootBoundary = "viewport";
3303
3293
  useImperativeHandle(
3304
3294
  forwardedRef,
3305
3295
  () => ref.current
@@ -3380,27 +3370,18 @@ const Popover = memo(
3380
3370
  middleware,
3381
3371
  placement: placementProp,
3382
3372
  whileElementsMounted: autoUpdate
3383
- }), referenceHidden = (_f = middlewareData.hide) == null ? void 0 : _f.referenceHidden, arrowX = (_g = middlewareData.arrow) == null ? void 0 : _g.x, arrowY = (_h = middlewareData.arrow) == null ? void 0 : _h.y, originX = (_i = middlewareData["@sanity/ui/origin"]) == null ? void 0 : _i.originX, originY = (_j = middlewareData["@sanity/ui/origin"]) == null ? void 0 : _j.originY, setArrow = useCallback((arrowEl) => {
3373
+ }), referenceHidden = (_e = middlewareData.hide) == null ? void 0 : _e.referenceHidden, arrowX = (_f = middlewareData.arrow) == null ? void 0 : _f.x, arrowY = (_g = middlewareData.arrow) == null ? void 0 : _g.y, originX = (_h = middlewareData["@sanity/ui/origin"]) == null ? void 0 : _h.originX, originY = (_i = middlewareData["@sanity/ui/origin"]) == null ? void 0 : _i.originY, setArrow = useCallback((arrowEl) => {
3384
3374
  arrowRef.current = arrowEl;
3385
3375
  }, []), setFloating = useCallback(
3386
3376
  (node) => {
3387
3377
  ref.current = node, refs.setFloating(node);
3388
3378
  },
3389
3379
  [refs]
3390
- ), setReference = useCallback(
3391
- (node) => {
3392
- refs.setReference(node);
3393
- const childRef = childProp == null ? void 0 : childProp.ref;
3394
- typeof childRef == "function" ? childRef(node) : childRef && (childRef.current = node);
3395
- },
3396
- [childProp, refs]
3397
- ), child = useMemo(() => !childProp || referenceElement ? null : cloneElement(childProp, { ref: setReference }), [childProp, referenceElement, setReference]);
3398
- if (useEffect(() => {
3399
- updateRef && (typeof updateRef == "function" ? updateRef(update) : updateRef && (updateRef.current = update));
3400
- }, [update, updateRef]), useEffect(() => {
3401
- child || refs.setReference(referenceElement || null);
3402
- }, [referenceElement, refs, child]), disabled)
3403
- return childProp || /* @__PURE__ */ jsx(Fragment, {});
3380
+ );
3381
+ if (useImperativeHandle(updateRef, () => update, [update]), useEffect(() => {
3382
+ children || refs.setReference(referenceElement || null);
3383
+ }, [children, referenceElement, refs]), disabled)
3384
+ return children || /* @__PURE__ */ jsx(Fragment, {});
3404
3385
  const popover = /* @__PURE__ */ jsx(LayerProvider, { zOffset, children: /* @__PURE__ */ jsx(
3405
3386
  PopoverCard,
3406
3387
  {
@@ -3434,22 +3415,35 @@ const Popover = memo(
3434
3415
  ConditionalWrapper,
3435
3416
  {
3436
3417
  condition: animate,
3437
- wrapper: (children) => /* @__PURE__ */ jsx(AnimatePresence, { children }),
3418
+ wrapper: (children2) => /* @__PURE__ */ jsx(AnimatePresence, { children: children2 }),
3438
3419
  children: open && /* @__PURE__ */ jsx(
3439
3420
  ConditionalWrapper,
3440
3421
  {
3441
3422
  condition: !!portal,
3442
- wrapper: (children) => /* @__PURE__ */ jsx(Portal, { __unstable_name: typeof portal == "string" ? portal : void 0, children }),
3423
+ wrapper: (children2) => /* @__PURE__ */ jsx(Portal, { __unstable_name: typeof portal == "string" ? portal : void 0, children: children2 }),
3443
3424
  children: popover
3444
3425
  }
3445
3426
  )
3446
3427
  }
3447
3428
  ),
3448
- child
3429
+ children && !referenceElement && /* @__PURE__ */ jsx(
3430
+ "div",
3431
+ {
3432
+ ref: (node) => {
3433
+ logDeprecatedWarning(), refs.setReference(node);
3434
+ },
3435
+ style: { display: "contents" },
3436
+ children
3437
+ }
3438
+ )
3449
3439
  ] });
3450
3440
  })
3451
3441
  );
3452
3442
  Popover.displayName = "Popover";
3443
+ let didWarn = !1;
3444
+ function logDeprecatedWarning() {
3445
+ didWarn || (console.warn("Popover: Please use the `referenceElement` prop instead of passing a children."), didWarn = !0);
3446
+ }
3453
3447
  function radioBaseStyle() {
3454
3448
  return css`
3455
3449
  position: relative;
@@ -4322,30 +4316,30 @@ const Root$a = styled(Layer)`
4322
4316
  pointer-events: none;
4323
4317
  max-width: ${({ $maxWidth }) => $maxWidth}px;
4324
4318
  `, Tooltip = forwardRef(function(props, forwardedRef) {
4325
- var _a, _b, _c, _d, _e, _f, _g;
4319
+ var _a, _b, _c, _d, _e, _f;
4326
4320
  const boundaryElementContext = useBoundaryElement(), { layer } = useTheme_v2(), {
4327
4321
  animate: _animate = !1,
4328
4322
  arrow: arrowProp = !1,
4329
- boundaryElement = boundaryElementContext == null ? void 0 : boundaryElementContext.element,
4323
+ boundaryElement: _boundaryElement,
4330
4324
  children: childProp,
4331
4325
  content,
4332
4326
  disabled,
4333
- fallbackPlacements: fallbackPlacementsProp = (_b = props.fallbackPlacements) != null ? _b : DEFAULT_FALLBACK_PLACEMENTS[(_a = props.placement) != null ? _a : "bottom"],
4327
+ fallbackPlacements: _fallbackPlacements,
4334
4328
  padding = 2,
4335
4329
  placement: placementProp = "bottom",
4336
4330
  portal: portalProp,
4337
4331
  radius = 2,
4338
4332
  scheme,
4339
4333
  shadow = 2,
4340
- zOffset = layer.tooltip.zOffset,
4334
+ zOffset: _zOffset,
4341
4335
  delay,
4342
4336
  ...restProps
4343
- } = props, animate = usePrefersReducedMotion() ? !1 : _animate, fallbackPlacements = useMemo(
4337
+ } = props, zOffset = _zOffset != null ? _zOffset : layer.tooltip.zOffset, fallbackPlacementsProp = _fallbackPlacements != null ? _fallbackPlacements : DEFAULT_FALLBACK_PLACEMENTS[(_a = props.placement) != null ? _a : "bottom"], boundaryElement = _boundaryElement != null ? _boundaryElement : boundaryElementContext == null ? void 0 : boundaryElementContext.element, animate = usePrefersReducedMotion() ? !1 : _animate, fallbackPlacements = useMemo(
4344
4338
  () => _getArrayProp(fallbackPlacementsProp),
4345
4339
  [fallbackPlacementsProp]
4346
4340
  ), ref = useRef(null), [referenceElement, setReferenceElement] = useState(null), arrowRef = useRef(null), rootBoundary = "viewport";
4347
4341
  useImperativeHandle(forwardedRef, () => ref.current);
4348
- const portal = usePortal(), portalElement = typeof portalProp == "string" ? ((_c = portal.elements) == null ? void 0 : _c[portalProp]) || null : portal.element, documentBodyOffsetWidth = useSyncExternalStore(
4342
+ const portal = usePortal(), portalElement = typeof portalProp == "string" ? ((_b = portal.elements) == null ? void 0 : _b[portalProp]) || null : portal.element, documentBodyOffsetWidth = useSyncExternalStore(
4349
4343
  emptySubscribe,
4350
4344
  () => document.body.offsetWidth,
4351
4345
  // We don't actually know what the width of the body is during SSR, so we'll just assume it's 800px or larger
@@ -4376,7 +4370,7 @@ const Root$a = styled(Layer)`
4376
4370
  middleware,
4377
4371
  placement: placementProp,
4378
4372
  whileElementsMounted: autoUpdate
4379
- }), arrowX = (_d = middlewareData.arrow) == null ? void 0 : _d.x, arrowY = (_e = middlewareData.arrow) == null ? void 0 : _e.y, originX = (_f = middlewareData["@sanity/ui/origin"]) == null ? void 0 : _f.originX, originY = (_g = middlewareData["@sanity/ui/origin"]) == null ? void 0 : _g.originY, tooltipId = useId(), [isOpen, setIsOpen] = useDelayedState(!1), delayGroupContext = useTooltipDelayGroup(), showTooltip = isOpen || (delayGroupContext == null ? void 0 : delayGroupContext.openTooltipId) === tooltipId, isInsideGroup = delayGroupContext !== null, openDelayProp = typeof delay == "number" ? delay : (delay == null ? void 0 : delay.open) || 0, closeDelayProp = typeof delay == "number" ? delay : (delay == null ? void 0 : delay.close) || 0, openDelay = isInsideGroup ? delayGroupContext.openDelay : openDelayProp, closeDelay = isInsideGroup ? delayGroupContext.closeDelay : closeDelayProp, handleIsOpenChange = useCallback(
4373
+ }), arrowX = (_c = middlewareData.arrow) == null ? void 0 : _c.x, arrowY = (_d = middlewareData.arrow) == null ? void 0 : _d.y, originX = (_e = middlewareData["@sanity/ui/origin"]) == null ? void 0 : _e.originX, originY = (_f = middlewareData["@sanity/ui/origin"]) == null ? void 0 : _f.originY, tooltipId = useId(), [isOpen, setIsOpen] = useDelayedState(!1), delayGroupContext = useTooltipDelayGroup(), showTooltip = isOpen || (delayGroupContext == null ? void 0 : delayGroupContext.openTooltipId) === tooltipId, isInsideGroup = delayGroupContext !== null, openDelayProp = typeof delay == "number" ? delay : (delay == null ? void 0 : delay.open) || 0, closeDelayProp = typeof delay == "number" ? delay : (delay == null ? void 0 : delay.close) || 0, openDelay = isInsideGroup ? delayGroupContext.openDelay : openDelayProp, closeDelay = isInsideGroup ? delayGroupContext.closeDelay : closeDelayProp, handleIsOpenChange = useCallback(
4380
4374
  (open, immediate) => {
4381
4375
  if (isInsideGroup)
4382
4376
  if (open) {
@@ -4429,9 +4423,9 @@ const Root$a = styled(Layer)`
4429
4423
  );
4430
4424
  useEffect(() => {
4431
4425
  if (!showTooltip) return;
4432
- function handleWindowMouseMove(event) {
4426
+ const handleWindowMouseMove = (event) => {
4433
4427
  referenceElement && (referenceElement === event.target || event.target instanceof Node && referenceElement.contains(event.target) || (handleIsOpenChange(!1), window.removeEventListener("mousemove", handleWindowMouseMove)));
4434
- }
4428
+ };
4435
4429
  return window.addEventListener("mousemove", handleWindowMouseMove), () => {
4436
4430
  window.removeEventListener("mousemove", handleWindowMouseMove);
4437
4431
  };
@@ -4632,37 +4626,34 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
4632
4626
  forwardedRef,
4633
4627
  () => inputElementRef.current
4634
4628
  );
4635
- const listBoxId = `${id}-listbox`, options = Array.isArray(optionsProp) ? optionsProp : EMPTY_ARRAY, padding = useMemo(() => _getArrayProp(paddingProp), [paddingProp]), currentOption = useMemo(
4629
+ const listBoxId = `${id}-listbox`, options = Array.isArray(optionsProp) ? optionsProp : EMPTY_ARRAY, padding = _getArrayProp(paddingProp), currentOption = useMemo(
4636
4630
  () => value !== null ? options.find((o) => o.value === value) : void 0,
4637
4631
  [options, value]
4638
4632
  ), filteredOptions = useMemo(
4639
4633
  () => options.filter((option) => query ? filterOption(query, option) : !0),
4640
4634
  [filterOption, options, query]
4641
- ), filteredOptionsLen = filteredOptions.length, activeItemId = activeValue ? `${id}-option-${activeValue}` : void 0, expanded = query !== null && loading || focused && query !== null, handleRootBlur = useCallback(
4642
- (event) => {
4643
- setTimeout(() => {
4644
- if (popoverMouseWithinRef.current)
4645
- return;
4646
- const elements = (relatedElements || []).concat(
4647
- rootElementRef.current ? [rootElementRef.current] : [],
4648
- resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : []
4649
- );
4650
- let focusInside = !1;
4651
- if (document.activeElement) {
4652
- for (const e of elements)
4653
- if (e === document.activeElement || e.contains(document.activeElement)) {
4654
- focusInside = !0;
4655
- break;
4656
- }
4657
- }
4658
- focusInside === !1 && (dispatch({ type: "root/blur" }), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), onBlur && onBlur(event));
4659
- }, 0);
4660
- },
4661
- [onBlur, onQueryChange, relatedElements]
4662
- ), handleRootFocus = useCallback((event) => {
4635
+ ), filteredOptionsLen = filteredOptions.length, activeItemId = activeValue ? `${id}-option-${activeValue}` : void 0, expanded = query !== null && loading || focused && query !== null, handleRootBlur = (event) => {
4636
+ setTimeout(() => {
4637
+ if (popoverMouseWithinRef.current)
4638
+ return;
4639
+ const elements = (relatedElements || []).concat(
4640
+ rootElementRef.current ? [rootElementRef.current] : [],
4641
+ resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : []
4642
+ );
4643
+ let focusInside = !1;
4644
+ if (document.activeElement) {
4645
+ for (const e of elements)
4646
+ if (e === document.activeElement || e.contains(document.activeElement)) {
4647
+ focusInside = !0;
4648
+ break;
4649
+ }
4650
+ }
4651
+ focusInside === !1 && (dispatch({ type: "root/blur" }), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), onBlur && onBlur(event));
4652
+ }, 0);
4653
+ }, handleRootFocus = (event) => {
4663
4654
  const listBoxElement = listBoxElementRef.current, focusedElement = event.target instanceof HTMLElement ? event.target : null, listFocused2 = (listBoxElement == null ? void 0 : listBoxElement.contains(focusedElement)) || !1;
4664
4655
  listFocused2 !== listFocusedRef.current && (listFocusedRef.current = listFocused2, dispatch({ type: "root/setListFocused", listFocused: listFocused2 }));
4665
- }, []), handleOptionSelect = useCallback(
4656
+ }, handleOptionSelect = useCallback(
4666
4657
  (v) => {
4667
4658
  var _a;
4668
4659
  dispatch({ type: "value/change", value: v }), popoverMouseWithinRef.current = !1, onSelect && onSelect(v), valueRef.current = v, onChange && onChange(v), onQueryChange && onQueryChange(null), (_a = inputElementRef.current) == null || _a.focus();
@@ -5152,13 +5143,13 @@ const Root$7 = styled(Layer)(responsivePaddingStyle, dialogStyle, responsiveDial
5152
5143
  onFocus,
5153
5144
  padding: paddingProp = 3,
5154
5145
  portal: portalProp,
5155
- position: positionProp = dialog.position || "fixed",
5146
+ position: _position,
5156
5147
  scheme,
5157
5148
  width: widthProp = 0,
5158
- zOffset: zOffsetProp = dialog.zOffset || layer.dialog.zOffset,
5149
+ zOffset: _zOffset,
5159
5150
  animate: _animate = !1,
5160
5151
  ...restProps
5161
- } = props, animate = usePrefersReducedMotion() ? !1 : _animate, portal = usePortal(), portalElement = portalProp ? ((_a = portal.elements) == null ? void 0 : _a[portalProp]) || null : portal.element, boundaryElement = useBoundaryElement().element, cardRadius = useMemo(() => _getArrayProp(cardRadiusProp), [cardRadiusProp]), padding = useMemo(() => _getArrayProp(paddingProp), [paddingProp]), position = useMemo(() => _getArrayProp(positionProp), [positionProp]), width = useMemo(() => _getArrayProp(widthProp), [widthProp]), zOffset = useMemo(() => _getArrayProp(zOffsetProp), [zOffsetProp]), preDivRef = useRef(null), postDivRef = useRef(null), cardRef = useRef(null), focusedElementRef = useRef(null), handleFocus = useCallback(
5152
+ } = props, positionProp = _position != null ? _position : dialog.position || "fixed", zOffsetProp = _zOffset != null ? _zOffset : dialog.zOffset || layer.dialog.zOffset, animate = usePrefersReducedMotion() ? !1 : _animate, portal = usePortal(), portalElement = portalProp ? ((_a = portal.elements) == null ? void 0 : _a[portalProp]) || null : portal.element, boundaryElement = useBoundaryElement().element, cardRadius = useMemo(() => _getArrayProp(cardRadiusProp), [cardRadiusProp]), padding = useMemo(() => _getArrayProp(paddingProp), [paddingProp]), position = useMemo(() => _getArrayProp(positionProp), [positionProp]), width = useMemo(() => _getArrayProp(widthProp), [widthProp]), zOffset = useMemo(() => _getArrayProp(zOffsetProp), [zOffsetProp]), preDivRef = useRef(null), postDivRef = useRef(null), cardRef = useRef(null), focusedElementRef = useRef(null), handleFocus = useCallback(
5162
5153
  (event) => {
5163
5154
  onFocus == null || onFocus(event);
5164
5155
  const target = event.target, cardElement = cardRef.current;
@@ -5422,10 +5413,10 @@ const Root$5 = styled(Box)`
5422
5413
  originElement,
5423
5414
  padding = 1,
5424
5415
  registerElement,
5425
- shouldFocus = props.focusFirst && "first" || props.focusLast && "last" || null,
5416
+ shouldFocus: _shouldFocus,
5426
5417
  space = 1,
5427
5418
  ...restProps
5428
- } = props, ref = useRef(null);
5419
+ } = props, shouldFocus = _shouldFocus != null ? _shouldFocus : props.focusFirst && "first" || props.focusLast && "last" || null, ref = useRef(null);
5429
5420
  useImperativeHandle(forwardedRef, () => ref.current);
5430
5421
  const { isTopLayer } = useLayer(), {
5431
5422
  activeElement,
@@ -5771,9 +5762,9 @@ function MenuGroup(props) {
5771
5762
  onClickOutside,
5772
5763
  onEscape,
5773
5764
  onItemClick,
5774
- onItemMouseEnter = menu.onMouseEnter,
5765
+ onItemMouseEnter: _onItemMouseEnter,
5775
5766
  registerElement
5776
- } = menu, [rootElement, setRootElement] = useState(null), [open, setOpen] = useState(!1), shouldFocusRef = useRef(null), active = !!activeElement && activeElement === rootElement, [withinMenu, setWithinMenu] = useState(!1), radius = useMemo(() => _getArrayProp(radiusProp), [radiusProp]), handleMouseEnter = useCallback(
5767
+ } = menu, onItemMouseEnter = _onItemMouseEnter != null ? _onItemMouseEnter : menu.onMouseEnter, [rootElement, setRootElement] = useState(null), [open, setOpen] = useState(!1), shouldFocusRef = useRef(null), active = !!activeElement && activeElement === rootElement, [withinMenu, setWithinMenu] = useState(!1), radius = useMemo(() => _getArrayProp(radiusProp), [radiusProp]), handleMouseEnter = useCallback(
5777
5768
  (event) => {
5778
5769
  setWithinMenu(!1), onItemMouseEnter(event), setOpen(!0);
5779
5770
  },
@@ -5879,9 +5870,9 @@ const MenuItem = forwardRef(function(props, forwardedRef) {
5879
5870
  activeElement,
5880
5871
  mount,
5881
5872
  onItemClick,
5882
- onItemMouseEnter = menu.onMouseEnter,
5883
- onItemMouseLeave = menu.onMouseLeave
5884
- } = menu, [rootElement, setRootElement] = useState(null), active = !!activeElement && activeElement === rootElement, ref = useRef(null);
5873
+ onItemMouseEnter: _onItemMouseEnter,
5874
+ onItemMouseLeave: _onItemMouseLeave
5875
+ } = menu, onItemMouseEnter = _onItemMouseEnter != null ? _onItemMouseEnter : menu.onMouseEnter, onItemMouseLeave = _onItemMouseLeave != null ? _onItemMouseLeave : menu.onMouseLeave, [rootElement, setRootElement] = useState(null), active = !!activeElement && activeElement === rootElement, ref = useRef(null);
5885
5876
  useImperativeHandle(forwardedRef, () => ref.current), useEffect(() => mount(rootElement, selectedProp), [mount, rootElement, selectedProp]);
5886
5877
  const handleClick = useCallback(
5887
5878
  (event) => {
@@ -6201,33 +6192,12 @@ const subscribe = () => () => {
6201
6192
  max-width: 420px;
6202
6193
  width: 100%;
6203
6194
  `;
6204
- let toastId = 0;
6205
6195
  function ToastProvider(props) {
6206
6196
  const { children, padding = 4, paddingX, paddingY, zOffset } = props, [state, _setState] = useState([]), toastsRef = useRef({}), mounted = useMounted(), prefersReducedMotion = usePrefersReducedMotion(), variants = useMemo(
6207
- () => ({
6208
- initial: {
6209
- opacity: 0,
6210
- [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: 0,
6211
- y: 32,
6212
- scale: 0.25,
6213
- willChange: "transform"
6214
- },
6215
- animate: {
6216
- opacity: [0, 1, 1],
6217
- [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: [0, 0, 1],
6218
- y: 0,
6219
- scale: 1
6220
- },
6221
- exit: {
6222
- opacity: [1, 1, 0],
6223
- [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: [1, 0, 0],
6224
- scale: 0.5,
6225
- transition: prefersReducedMotion ? { duration: 0 } : { duration: 0.2 }
6226
- }
6227
- }),
6197
+ () => getVariants(prefersReducedMotion),
6228
6198
  [prefersReducedMotion]
6229
6199
  ), value = useMemo(() => ({ version: 0, push: (params) => {
6230
- const setState = (state2) => startTransition(() => _setState(state2)), id = params.id || String(toastId++), duration = params.duration || 5e3, dismiss = () => {
6200
+ const setState = (state2) => startTransition(() => _setState(state2)), id = params.id || crypto.randomUUID(), duration = params.duration || 5e3, dismiss = () => {
6231
6201
  var _a;
6232
6202
  const timeoutId = (_a = toastsRef.current[id]) == null ? void 0 : _a.timeoutId;
6233
6203
  setState((prevState) => {
@@ -6280,6 +6250,29 @@ function ToastProvider(props) {
6280
6250
  )) }) }) }) })
6281
6251
  ] });
6282
6252
  }
6253
+ function getVariants(prefersReducedMotion) {
6254
+ return {
6255
+ initial: {
6256
+ opacity: 0,
6257
+ [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: 0,
6258
+ y: 32,
6259
+ scale: 0.25,
6260
+ willChange: "transform"
6261
+ },
6262
+ animate: {
6263
+ opacity: [0, 1, 1],
6264
+ [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: [0, 0, 1],
6265
+ y: 0,
6266
+ scale: 1
6267
+ },
6268
+ exit: {
6269
+ opacity: [1, 1, 0],
6270
+ [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: [1, 0, 0],
6271
+ scale: 0.5,
6272
+ transition: { duration: prefersReducedMotion ? 0 : 0.2 }
6273
+ }
6274
+ };
6275
+ }
6283
6276
  function useToast() {
6284
6277
  const value = useContext(ToastContext);
6285
6278
  if (!value)
@@ -6466,6 +6459,28 @@ const key = Symbol.for("@sanity/ui/context/tree"), TreeContext = createGlobalSco
6466
6459
  })
6467
6460
  );
6468
6461
  Tree.displayName = "Tree";
6462
+ function useTree() {
6463
+ const tree = useContext(TreeContext);
6464
+ if (!tree)
6465
+ throw new Error("Tree: missing context value");
6466
+ return tree;
6467
+ }
6468
+ const TreeGroup = memo(function(props) {
6469
+ const { children, expanded = !1, ...restProps } = props, tree = useTree();
6470
+ return /* @__PURE__ */ jsx(
6471
+ Stack,
6472
+ {
6473
+ as: "ul",
6474
+ "data-ui": "TreeGroup",
6475
+ ...restProps,
6476
+ hidden: !expanded,
6477
+ marginTop: tree.space,
6478
+ role: "group",
6479
+ space: tree.space,
6480
+ children
6481
+ }
6482
+ );
6483
+ });
6469
6484
  function treeItemRootStyle() {
6470
6485
  return css`
6471
6486
  &[role='none'] > [role='treeitem'] {
@@ -6552,28 +6567,9 @@ function treeItemBoxStyle(props) {
6552
6567
  }
6553
6568
  `;
6554
6569
  }
6555
- function useTree() {
6556
- const tree = useContext(TreeContext);
6557
- if (!tree)
6558
- throw new Error("Tree: missing context value");
6559
- return tree;
6560
- }
6561
- const TreeGroup = memo(function(props) {
6562
- const { children, expanded = !1, ...restProps } = props, tree = useTree();
6563
- return /* @__PURE__ */ jsx(
6564
- Stack,
6565
- {
6566
- as: "ul",
6567
- "data-ui": "TreeGroup",
6568
- ...restProps,
6569
- hidden: !expanded,
6570
- marginTop: tree.space,
6571
- role: "group",
6572
- space: tree.space,
6573
- children
6574
- }
6575
- );
6576
- }), Root = memo(styled.li(treeItemRootStyle, treeItemRootColorStyle)), TreeItemBox = styled(Box).attrs({ forwardedAs: "a" })(treeItemBoxStyle), ToggleArrowText = styled(Text)`
6570
+ const Root = memo(styled.li(treeItemRootStyle, treeItemRootColorStyle)), TreeItemBox = styled(Box).attrs({ forwardedAs: "a" })(
6571
+ treeItemBoxStyle
6572
+ ), ToggleArrowText = styled(Text)`
6577
6573
  & > svg {
6578
6574
  transition: transform 100ms;
6579
6575
  }
@@ -6594,12 +6590,12 @@ const TreeGroup = memo(function(props) {
6594
6590
  text,
6595
6591
  weight,
6596
6592
  ...restProps
6597
- } = props, rootRef = useRef(null), treeitemRef = useRef(null), tree = useTree(), { path, registerItem, setExpanded, setFocusedElement } = tree, _id = useId(), id = idProp || _id, itemPath = useMemo(() => path.concat([id || ""]), [id, path]), itemKey = itemPath.join("/"), itemState = tree.state[itemKey], focused = tree.focusedElement === rootRef.current, expanded = (itemState == null ? void 0 : itemState.expanded) === void 0 ? expandedProp : (itemState == null ? void 0 : itemState.expanded) || !1, tabIndex = tree.focusedElement && tree.focusedElement === rootRef.current ? 0 : -1, contextValue = useMemo(
6593
+ } = props, rootRef = useRef(null), treeitemRef = useRef(null), tree = useTree(), { path, registerItem, setExpanded, setFocusedElement } = tree, _id = useId(), id = idProp || _id, itemPath = useMemo(() => [...path, id || ""], [id, path]), itemKey = itemPath.join("/"), itemState = tree.state[itemKey], focused = tree.focusedElement === rootRef.current, expanded = (itemState == null ? void 0 : itemState.expanded) === void 0 ? expandedProp : (itemState == null ? void 0 : itemState.expanded) || !1, tabIndex = tree.focusedElement && tree.focusedElement === rootRef.current ? 0 : -1, contextValue = useMemo(
6598
6594
  () => ({ ...tree, level: tree.level + 1, path: itemPath }),
6599
6595
  [itemPath, tree]
6600
6596
  ), handleClick = useCallback(
6601
6597
  (event) => {
6602
- onClick && onClick(event);
6598
+ onClick == null || onClick(event);
6603
6599
  const target = event.target;
6604
6600
  target instanceof HTMLElement && (target.getAttribute("data-ui") === "TreeItem" || target.closest('[data-ui="TreeItem__box"]')) && (event.stopPropagation(), setExpanded(itemKey, !expanded), setFocusedElement(rootRef.current));
6605
6601
  },
@@ -6617,23 +6613,26 @@ const TreeGroup = memo(function(props) {
6617
6613
  if (rootRef.current)
6618
6614
  return registerItem(rootRef.current, itemPath.join("/"), expanded, selected);
6619
6615
  }, [expanded, itemPath, registerItem, selected]);
6620
- const content = /* @__PURE__ */ jsxs(Flex, { padding, children: [
6621
- /* @__PURE__ */ jsxs(
6622
- Box,
6623
- {
6624
- marginRight: space,
6625
- style: {
6626
- visibility: IconComponent || children ? "visible" : "hidden",
6627
- pointerEvents: "none"
6628
- },
6629
- children: [
6630
- IconComponent && /* @__PURE__ */ jsx(Text, { muted, size: fontSize2, weight, children: /* @__PURE__ */ jsx(IconComponent, {}) }),
6631
- !IconComponent && /* @__PURE__ */ jsx(ToggleArrowText, { muted, size: fontSize2, weight, children: /* @__PURE__ */ jsx(ToggleArrowRightIcon, { style: { transform: expanded ? "rotate(90deg)" : void 0 } }) })
6632
- ]
6633
- }
6634
- ),
6635
- /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(Text, { muted, size: fontSize2, textOverflow: "ellipsis", weight, children: text }) })
6636
- ] });
6616
+ const content = useMemo(
6617
+ () => /* @__PURE__ */ jsxs(Flex, { padding, children: [
6618
+ /* @__PURE__ */ jsxs(
6619
+ Box,
6620
+ {
6621
+ marginRight: space,
6622
+ style: {
6623
+ visibility: IconComponent || children ? "visible" : "hidden",
6624
+ pointerEvents: "none"
6625
+ },
6626
+ children: [
6627
+ IconComponent && /* @__PURE__ */ jsx(Text, { muted, size: fontSize2, weight, children: /* @__PURE__ */ jsx(IconComponent, {}) }),
6628
+ !IconComponent && /* @__PURE__ */ jsx(ToggleArrowText, { muted, size: fontSize2, weight, children: /* @__PURE__ */ jsx(ToggleArrowRightIcon, { style: { transform: expanded ? "rotate(90deg)" : void 0 } }) })
6629
+ ]
6630
+ }
6631
+ ),
6632
+ /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(Text, { muted, size: fontSize2, textOverflow: "ellipsis", weight, children: text }) })
6633
+ ] }),
6634
+ [IconComponent, children, expanded, fontSize2, muted, padding, space, text, weight]
6635
+ );
6637
6636
  return href ? /* @__PURE__ */ jsxs(
6638
6637
  Root,
6639
6638
  {