@sanity/ui 2.3.6-canary.1 → 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.mjs CHANGED
@@ -134,12 +134,7 @@ function createGlobalScopedContext(key2, defaultValue) {
134
134
  const key$8 = Symbol.for("@sanity/ui/context/theme"), ThemeContext = createGlobalScopedContext(key$8, null);
135
135
  function ThemeProvider(props) {
136
136
  var _a;
137
- const parentTheme = useContext(ThemeContext), {
138
- children,
139
- // scheme = parentTheme?.scheme || 'light',
140
- theme: rootTheme = (parentTheme == null ? void 0 : parentTheme.theme) || null,
141
- tone = (parentTheme == null ? void 0 : parentTheme.tone) || "default"
142
- } = props, scheme = (_a = props.scheme) != null ? _a : (parentTheme == null ? void 0 : parentTheme.scheme) || "light", themeContext = useMemo(() => rootTheme ? {
137
+ const { children } = props, parentTheme = useContext(ThemeContext), scheme = (_a = props.scheme) != null ? _a : (parentTheme == null ? void 0 : parentTheme.scheme) || "light", rootTheme = (parentTheme == null ? void 0 : parentTheme.theme) || null, tone = (parentTheme == null ? void 0 : parentTheme.tone) || "default", themeContext = useMemo(() => rootTheme ? {
143
138
  version: 0,
144
139
  theme: rootTheme,
145
140
  scheme,
@@ -942,7 +937,7 @@ const Root$B = styled.div(
942
937
  status = "online",
943
938
  size: sizeProp = 1,
944
939
  ...restProps
945
- } = 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(
946
941
  animateArrowFrom || arrowPositionProp || "inside"
947
942
  ), [imageFailed, setImageFailed] = useState(!1), imageId = `avatar-image-${elementId}`;
948
943
  useEffect(() => {
@@ -954,10 +949,7 @@ const Root$B = styled.div(
954
949
  }, [src]);
955
950
  const handleImageError = useCallback(() => {
956
951
  setImageFailed(!0), onImageLoadError && onImageLoadError(new Error("Avatar: the image failed to load"));
957
- }, [onImageLoadError]), initialsSize = useMemo(
958
- () => size2.map((s) => s === 1 ? 1 : s === 2 ? 3 : s === 3 ? 5 : 0),
959
- [size2]
960
- );
952
+ }, [onImageLoadError]), initialsSize = size2.map((s) => s === 1 ? 1 : s === 2 ? 3 : s === 3 ? 5 : 0);
961
953
  return /* @__PURE__ */ jsxs(
962
954
  Root$B,
963
955
  {
@@ -1052,11 +1044,8 @@ const Root$A = styled.div(
1052
1044
  _responsiveAvatarCounterSizeStyle,
1053
1045
  _avatarCounterBaseStyle
1054
1046
  ), AvatarCounter = forwardRef(function(props, ref) {
1055
- const { count, size: sizeProp = 1 } = props, size2 = useMemo(() => _getArrayProp(sizeProp), [sizeProp]), fontSize2 = useMemo(
1056
- () => size2.map((s) => s === 1 ? 1 : s === 2 ? 3 : s === 3 ? 5 : 0),
1057
- [size2]
1058
- );
1059
- 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 }) });
1060
1049
  }), BASE_STYLES = css`
1061
1050
  white-space: nowrap;
1062
1051
 
@@ -1088,10 +1077,7 @@ const Root$z = styled.div(responsiveAvatarStackSizeStyle, avatarStackStyle), Ava
1088
1077
  maxLength: maxLengthProp = 4,
1089
1078
  size: sizeProp = 1,
1090
1079
  ...restProps
1091
- } = props, children = useMemo(
1092
- () => Children.toArray(childrenProp).filter(isValidElement),
1093
- [childrenProp]
1094
- ), 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;
1095
1081
  return /* @__PURE__ */ jsxs(Root$z, { "data-ui": "AvatarStack", ...restProps, ref, $size: size2, children: [
1096
1082
  len === 0 && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(AvatarCounter, { count: len, size: size2 }) }),
1097
1083
  len !== 0 && extraCount > 1 && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(AvatarCounter, { count: extraCount, size: size2 }) }),
@@ -2838,10 +2824,10 @@ function findMinBreakpoints(media, width) {
2838
2824
  return ret;
2839
2825
  }
2840
2826
  const ElementQuery = forwardRef(function(props, forwardedRef) {
2841
- 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(() => {
2842
2828
  var _a;
2843
2829
  return (_a = elementSize == null ? void 0 : elementSize.border.width) != null ? _a : window.innerWidth;
2844
- }, [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);
2845
2831
  useImperativeHandle(forwardedRef, () => ref.current);
2846
2832
  const setRef = useCallback((el) => {
2847
2833
  ref.current = el, setElement(el);
@@ -2975,18 +2961,18 @@ function _isScrollable(el) {
2975
2961
  }
2976
2962
  function LayerProvider(props) {
2977
2963
  var _a;
2978
- 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(
2979
2965
  (childLevel) => {
2980
2966
  const parentDispose = parentRegisterChild == null ? void 0 : parentRegisterChild(childLevel);
2981
- return childLevel !== void 0 ? setChildLayers((state) => {
2967
+ return setChildLayers((state) => {
2982
2968
  var _a2;
2983
- const prevLen = (_a2 = state[childLevel]) != null ? _a2 : 0, nextState = { ...state, [childLevel]: prevLen + 1 };
2984
- return setSize(Object.keys(nextState).length), nextState;
2985
- }) : setSize((v) => v + 1), () => {
2986
- childLevel !== void 0 ? setChildLayers((state) => {
2969
+ const prevLen = (_a2 = state[childLevel]) != null ? _a2 : 0;
2970
+ return { ...state, [childLevel]: prevLen + 1 };
2971
+ }), () => {
2972
+ setChildLayers((state) => {
2987
2973
  const nextState = { ...state };
2988
- return nextState[childLevel] === 1 ? (delete nextState[childLevel], setSize(Object.keys(nextState).length)) : nextState[childLevel] -= 1, nextState;
2989
- }) : setSize((v) => v - 1), parentDispose == null || parentDispose();
2974
+ return nextState[childLevel] === 1 ? delete nextState[childLevel] : nextState[childLevel] -= 1, nextState;
2975
+ }), parentDispose == null || parentDispose();
2990
2976
  };
2991
2977
  },
2992
2978
  [parentRegisterChild]
@@ -2997,15 +2983,14 @@ function LayerProvider(props) {
2997
2983
  version: 0,
2998
2984
  isTopLayer,
2999
2985
  level,
3000
- registerChild,
3001
2986
  size: size2,
3002
2987
  zIndex
3003
2988
  }),
3004
- [isTopLayer, level, registerChild, size2, zIndex]
2989
+ [isTopLayer, level, size2, zIndex]
3005
2990
  );
3006
- return /* @__PURE__ */ jsx(LayerContext.Provider, { value, children });
2991
+ return /* @__PURE__ */ jsx(LayerContext.Provider, { value, children: /* @__PURE__ */ jsx(LayerContextRegisterChild.Provider, { value: registerChild, children }) });
3007
2992
  }
3008
- 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) {
3009
2994
  const { children, onActivate, onFocus, style = EMPTY_RECORD, ...restProps } = props, { zIndex, isTopLayer } = useLayer(), lastFocusedRef = useRef(null), ref = useRef(null), isTopLayerRef = useRef(isTopLayer);
3010
2995
  useImperativeHandle(forwardedRef, () => ref.current), useEffect(() => {
3011
2996
  isTopLayerRef.current !== isTopLayer && isTopLayer && (onActivate == null || onActivate({ activeElement: lastFocusedRef.current })), isTopLayerRef.current = isTopLayer;
@@ -3273,19 +3258,19 @@ const MotionCard$1 = styled(motion(Card))`
3273
3258
  PopoverCard.displayName = "PopoverCard";
3274
3259
  const Popover = memo(
3275
3260
  forwardRef(function(props, forwardedRef) {
3276
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
3261
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
3277
3262
  const { container, layer } = useTheme_v2(), boundaryElementContext = useBoundaryElement(), {
3278
3263
  __unstable_margins: margins = DEFAULT_POPOVER_MARGINS,
3279
3264
  animate: _animate = !1,
3280
3265
  arrow: arrowProp = !1,
3281
- boundaryElement = boundaryElementContext.element,
3282
- children: childProp,
3266
+ boundaryElement: _boundaryElement,
3267
+ children,
3283
3268
  constrainSize = !1,
3284
3269
  content,
3285
3270
  disabled,
3286
- fallbackPlacements = (_b = props.fallbackPlacements) != null ? _b : DEFAULT_FALLBACK_PLACEMENTS$1[(_a = props.placement) != null ? _a : "bottom"],
3271
+ fallbackPlacements: _fallbackPlacements,
3287
3272
  matchReferenceWidth,
3288
- floatingBoundary = (_c = props.boundaryElement) != null ? _c : boundaryElementContext.element,
3273
+ floatingBoundary: _floatingBoundary,
3289
3274
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
3290
3275
  onActivate,
3291
3276
  open,
@@ -3295,16 +3280,16 @@ const Popover = memo(
3295
3280
  portal,
3296
3281
  preventOverflow = !0,
3297
3282
  radius: radiusProp = 3,
3298
- referenceBoundary = (_d = props.boundaryElement) != null ? _d : boundaryElementContext.element,
3283
+ referenceBoundary: _referenceBoundary,
3299
3284
  referenceElement,
3300
3285
  scheme,
3301
3286
  shadow: shadowProp = 3,
3302
3287
  tone = "inherit",
3303
3288
  width: widthProp = "auto",
3304
- zOffset: zOffsetProp = layer.popover.zOffset,
3289
+ zOffset: _zOffset,
3305
3290
  updateRef,
3306
3291
  ...restProps
3307
- } = 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";
3308
3293
  useImperativeHandle(
3309
3294
  forwardedRef,
3310
3295
  () => ref.current
@@ -3385,27 +3370,18 @@ const Popover = memo(
3385
3370
  middleware,
3386
3371
  placement: placementProp,
3387
3372
  whileElementsMounted: autoUpdate
3388
- }), 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) => {
3389
3374
  arrowRef.current = arrowEl;
3390
3375
  }, []), setFloating = useCallback(
3391
3376
  (node) => {
3392
3377
  ref.current = node, refs.setFloating(node);
3393
3378
  },
3394
3379
  [refs]
3395
- ), setReference = useCallback(
3396
- (node) => {
3397
- refs.setReference(node);
3398
- const childRef = childProp == null ? void 0 : childProp.ref;
3399
- typeof childRef == "function" ? childRef(node) : childRef && (childRef.current = node);
3400
- },
3401
- [childProp, refs]
3402
- ), child = useMemo(() => !childProp || referenceElement ? null : cloneElement(childProp, { ref: setReference }), [childProp, referenceElement, setReference]);
3403
- if (useEffect(() => {
3404
- updateRef && (typeof updateRef == "function" ? updateRef(update) : updateRef && (updateRef.current = update));
3405
- }, [update, updateRef]), useEffect(() => {
3406
- child || refs.setReference(referenceElement || null);
3407
- }, [referenceElement, refs, child]), disabled)
3408
- 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, {});
3409
3385
  const popover = /* @__PURE__ */ jsx(LayerProvider, { zOffset, children: /* @__PURE__ */ jsx(
3410
3386
  PopoverCard,
3411
3387
  {
@@ -3439,22 +3415,35 @@ const Popover = memo(
3439
3415
  ConditionalWrapper,
3440
3416
  {
3441
3417
  condition: animate,
3442
- wrapper: (children) => /* @__PURE__ */ jsx(AnimatePresence, { children }),
3418
+ wrapper: (children2) => /* @__PURE__ */ jsx(AnimatePresence, { children: children2 }),
3443
3419
  children: open && /* @__PURE__ */ jsx(
3444
3420
  ConditionalWrapper,
3445
3421
  {
3446
3422
  condition: !!portal,
3447
- 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 }),
3448
3424
  children: popover
3449
3425
  }
3450
3426
  )
3451
3427
  }
3452
3428
  ),
3453
- 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
+ )
3454
3439
  ] });
3455
3440
  })
3456
3441
  );
3457
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
+ }
3458
3447
  function radioBaseStyle() {
3459
3448
  return css`
3460
3449
  position: relative;
@@ -4327,30 +4316,30 @@ const Root$a = styled(Layer)`
4327
4316
  pointer-events: none;
4328
4317
  max-width: ${({ $maxWidth }) => $maxWidth}px;
4329
4318
  `, Tooltip = forwardRef(function(props, forwardedRef) {
4330
- var _a, _b, _c, _d, _e, _f, _g;
4319
+ var _a, _b, _c, _d, _e, _f;
4331
4320
  const boundaryElementContext = useBoundaryElement(), { layer } = useTheme_v2(), {
4332
4321
  animate: _animate = !1,
4333
4322
  arrow: arrowProp = !1,
4334
- boundaryElement = boundaryElementContext == null ? void 0 : boundaryElementContext.element,
4323
+ boundaryElement: _boundaryElement,
4335
4324
  children: childProp,
4336
4325
  content,
4337
4326
  disabled,
4338
- fallbackPlacements: fallbackPlacementsProp = (_b = props.fallbackPlacements) != null ? _b : DEFAULT_FALLBACK_PLACEMENTS[(_a = props.placement) != null ? _a : "bottom"],
4327
+ fallbackPlacements: _fallbackPlacements,
4339
4328
  padding = 2,
4340
4329
  placement: placementProp = "bottom",
4341
4330
  portal: portalProp,
4342
4331
  radius = 2,
4343
4332
  scheme,
4344
4333
  shadow = 2,
4345
- zOffset = layer.tooltip.zOffset,
4334
+ zOffset: _zOffset,
4346
4335
  delay,
4347
4336
  ...restProps
4348
- } = 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(
4349
4338
  () => _getArrayProp(fallbackPlacementsProp),
4350
4339
  [fallbackPlacementsProp]
4351
4340
  ), ref = useRef(null), [referenceElement, setReferenceElement] = useState(null), arrowRef = useRef(null), rootBoundary = "viewport";
4352
4341
  useImperativeHandle(forwardedRef, () => ref.current);
4353
- 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(
4354
4343
  emptySubscribe,
4355
4344
  () => document.body.offsetWidth,
4356
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
@@ -4381,7 +4370,7 @@ const Root$a = styled(Layer)`
4381
4370
  middleware,
4382
4371
  placement: placementProp,
4383
4372
  whileElementsMounted: autoUpdate
4384
- }), 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(
4385
4374
  (open, immediate) => {
4386
4375
  if (isInsideGroup)
4387
4376
  if (open) {
@@ -4434,9 +4423,9 @@ const Root$a = styled(Layer)`
4434
4423
  );
4435
4424
  useEffect(() => {
4436
4425
  if (!showTooltip) return;
4437
- function handleWindowMouseMove(event) {
4426
+ const handleWindowMouseMove = (event) => {
4438
4427
  referenceElement && (referenceElement === event.target || event.target instanceof Node && referenceElement.contains(event.target) || (handleIsOpenChange(!1), window.removeEventListener("mousemove", handleWindowMouseMove)));
4439
- }
4428
+ };
4440
4429
  return window.addEventListener("mousemove", handleWindowMouseMove), () => {
4441
4430
  window.removeEventListener("mousemove", handleWindowMouseMove);
4442
4431
  };
@@ -4637,37 +4626,34 @@ const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
4637
4626
  forwardedRef,
4638
4627
  () => inputElementRef.current
4639
4628
  );
4640
- 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(
4641
4630
  () => value !== null ? options.find((o) => o.value === value) : void 0,
4642
4631
  [options, value]
4643
4632
  ), filteredOptions = useMemo(
4644
4633
  () => options.filter((option) => query ? filterOption(query, option) : !0),
4645
4634
  [filterOption, options, query]
4646
- ), filteredOptionsLen = filteredOptions.length, activeItemId = activeValue ? `${id}-option-${activeValue}` : void 0, expanded = query !== null && loading || focused && query !== null, handleRootBlur = useCallback(
4647
- (event) => {
4648
- setTimeout(() => {
4649
- if (popoverMouseWithinRef.current)
4650
- return;
4651
- const elements = (relatedElements || []).concat(
4652
- rootElementRef.current ? [rootElementRef.current] : [],
4653
- resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : []
4654
- );
4655
- let focusInside = !1;
4656
- if (document.activeElement) {
4657
- for (const e of elements)
4658
- if (e === document.activeElement || e.contains(document.activeElement)) {
4659
- focusInside = !0;
4660
- break;
4661
- }
4662
- }
4663
- focusInside === !1 && (dispatch({ type: "root/blur" }), popoverMouseWithinRef.current = !1, onQueryChange && onQueryChange(null), onBlur && onBlur(event));
4664
- }, 0);
4665
- },
4666
- [onBlur, onQueryChange, relatedElements]
4667
- ), 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) => {
4668
4654
  const listBoxElement = listBoxElementRef.current, focusedElement = event.target instanceof HTMLElement ? event.target : null, listFocused2 = (listBoxElement == null ? void 0 : listBoxElement.contains(focusedElement)) || !1;
4669
4655
  listFocused2 !== listFocusedRef.current && (listFocusedRef.current = listFocused2, dispatch({ type: "root/setListFocused", listFocused: listFocused2 }));
4670
- }, []), handleOptionSelect = useCallback(
4656
+ }, handleOptionSelect = useCallback(
4671
4657
  (v) => {
4672
4658
  var _a;
4673
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();
@@ -5157,13 +5143,13 @@ const Root$7 = styled(Layer)(responsivePaddingStyle, dialogStyle, responsiveDial
5157
5143
  onFocus,
5158
5144
  padding: paddingProp = 3,
5159
5145
  portal: portalProp,
5160
- position: positionProp = dialog.position || "fixed",
5146
+ position: _position,
5161
5147
  scheme,
5162
5148
  width: widthProp = 0,
5163
- zOffset: zOffsetProp = dialog.zOffset || layer.dialog.zOffset,
5149
+ zOffset: _zOffset,
5164
5150
  animate: _animate = !1,
5165
5151
  ...restProps
5166
- } = 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(
5167
5153
  (event) => {
5168
5154
  onFocus == null || onFocus(event);
5169
5155
  const target = event.target, cardElement = cardRef.current;
@@ -5427,10 +5413,10 @@ const Root$5 = styled(Box)`
5427
5413
  originElement,
5428
5414
  padding = 1,
5429
5415
  registerElement,
5430
- shouldFocus = props.focusFirst && "first" || props.focusLast && "last" || null,
5416
+ shouldFocus: _shouldFocus,
5431
5417
  space = 1,
5432
5418
  ...restProps
5433
- } = props, ref = useRef(null);
5419
+ } = props, shouldFocus = _shouldFocus != null ? _shouldFocus : props.focusFirst && "first" || props.focusLast && "last" || null, ref = useRef(null);
5434
5420
  useImperativeHandle(forwardedRef, () => ref.current);
5435
5421
  const { isTopLayer } = useLayer(), {
5436
5422
  activeElement,
@@ -5776,9 +5762,9 @@ function MenuGroup(props) {
5776
5762
  onClickOutside,
5777
5763
  onEscape,
5778
5764
  onItemClick,
5779
- onItemMouseEnter = menu.onMouseEnter,
5765
+ onItemMouseEnter: _onItemMouseEnter,
5780
5766
  registerElement
5781
- } = 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(
5782
5768
  (event) => {
5783
5769
  setWithinMenu(!1), onItemMouseEnter(event), setOpen(!0);
5784
5770
  },
@@ -5884,9 +5870,9 @@ const MenuItem = forwardRef(function(props, forwardedRef) {
5884
5870
  activeElement,
5885
5871
  mount,
5886
5872
  onItemClick,
5887
- onItemMouseEnter = menu.onMouseEnter,
5888
- onItemMouseLeave = menu.onMouseLeave
5889
- } = 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);
5890
5876
  useImperativeHandle(forwardedRef, () => ref.current), useEffect(() => mount(rootElement, selectedProp), [mount, rootElement, selectedProp]);
5891
5877
  const handleClick = useCallback(
5892
5878
  (event) => {
@@ -6206,33 +6192,12 @@ const subscribe = () => () => {
6206
6192
  max-width: 420px;
6207
6193
  width: 100%;
6208
6194
  `;
6209
- let toastId = 0;
6210
6195
  function ToastProvider(props) {
6211
6196
  const { children, padding = 4, paddingX, paddingY, zOffset } = props, [state, _setState] = useState([]), toastsRef = useRef({}), mounted = useMounted(), prefersReducedMotion = usePrefersReducedMotion(), variants = useMemo(
6212
- () => ({
6213
- initial: {
6214
- opacity: 0,
6215
- [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: 0,
6216
- y: 32,
6217
- scale: 0.25,
6218
- willChange: "transform"
6219
- },
6220
- animate: {
6221
- opacity: [0, 1, 1],
6222
- [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: [0, 0, 1],
6223
- y: 0,
6224
- scale: 1
6225
- },
6226
- exit: {
6227
- opacity: [1, 1, 0],
6228
- [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: [1, 0, 0],
6229
- scale: 0.5,
6230
- transition: prefersReducedMotion ? { duration: 0 } : { duration: 0.2 }
6231
- }
6232
- }),
6197
+ () => getVariants(prefersReducedMotion),
6233
6198
  [prefersReducedMotion]
6234
6199
  ), value = useMemo(() => ({ version: 0, push: (params) => {
6235
- 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 = () => {
6236
6201
  var _a;
6237
6202
  const timeoutId = (_a = toastsRef.current[id]) == null ? void 0 : _a.timeoutId;
6238
6203
  setState((prevState) => {
@@ -6285,6 +6250,29 @@ function ToastProvider(props) {
6285
6250
  )) }) }) }) })
6286
6251
  ] });
6287
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
+ }
6288
6276
  function useToast() {
6289
6277
  const value = useContext(ToastContext);
6290
6278
  if (!value)
@@ -6471,6 +6459,28 @@ const key = Symbol.for("@sanity/ui/context/tree"), TreeContext = createGlobalSco
6471
6459
  })
6472
6460
  );
6473
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
+ });
6474
6484
  function treeItemRootStyle() {
6475
6485
  return css`
6476
6486
  &[role='none'] > [role='treeitem'] {
@@ -6557,28 +6567,9 @@ function treeItemBoxStyle(props) {
6557
6567
  }
6558
6568
  `;
6559
6569
  }
6560
- function useTree() {
6561
- const tree = useContext(TreeContext);
6562
- if (!tree)
6563
- throw new Error("Tree: missing context value");
6564
- return tree;
6565
- }
6566
- const TreeGroup = memo(function(props) {
6567
- const { children, expanded = !1, ...restProps } = props, tree = useTree();
6568
- return /* @__PURE__ */ jsx(
6569
- Stack,
6570
- {
6571
- as: "ul",
6572
- "data-ui": "TreeGroup",
6573
- ...restProps,
6574
- hidden: !expanded,
6575
- marginTop: tree.space,
6576
- role: "group",
6577
- space: tree.space,
6578
- children
6579
- }
6580
- );
6581
- }), 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)`
6582
6573
  & > svg {
6583
6574
  transition: transform 100ms;
6584
6575
  }
@@ -6599,12 +6590,12 @@ const TreeGroup = memo(function(props) {
6599
6590
  text,
6600
6591
  weight,
6601
6592
  ...restProps
6602
- } = 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(
6603
6594
  () => ({ ...tree, level: tree.level + 1, path: itemPath }),
6604
6595
  [itemPath, tree]
6605
6596
  ), handleClick = useCallback(
6606
6597
  (event) => {
6607
- onClick && onClick(event);
6598
+ onClick == null || onClick(event);
6608
6599
  const target = event.target;
6609
6600
  target instanceof HTMLElement && (target.getAttribute("data-ui") === "TreeItem" || target.closest('[data-ui="TreeItem__box"]')) && (event.stopPropagation(), setExpanded(itemKey, !expanded), setFocusedElement(rootRef.current));
6610
6601
  },
@@ -6622,23 +6613,26 @@ const TreeGroup = memo(function(props) {
6622
6613
  if (rootRef.current)
6623
6614
  return registerItem(rootRef.current, itemPath.join("/"), expanded, selected);
6624
6615
  }, [expanded, itemPath, registerItem, selected]);
6625
- const content = /* @__PURE__ */ jsxs(Flex, { padding, children: [
6626
- /* @__PURE__ */ jsxs(
6627
- Box,
6628
- {
6629
- marginRight: space,
6630
- style: {
6631
- visibility: IconComponent || children ? "visible" : "hidden",
6632
- pointerEvents: "none"
6633
- },
6634
- children: [
6635
- IconComponent && /* @__PURE__ */ jsx(Text, { muted, size: fontSize2, weight, children: /* @__PURE__ */ jsx(IconComponent, {}) }),
6636
- !IconComponent && /* @__PURE__ */ jsx(ToggleArrowText, { muted, size: fontSize2, weight, children: /* @__PURE__ */ jsx(ToggleArrowRightIcon, { style: { transform: expanded ? "rotate(90deg)" : void 0 } }) })
6637
- ]
6638
- }
6639
- ),
6640
- /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(Text, { muted, size: fontSize2, textOverflow: "ellipsis", weight, children: text }) })
6641
- ] });
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
+ );
6642
6636
  return href ? /* @__PURE__ */ jsxs(
6643
6637
  Root,
6644
6638
  {