@sanity/ui 2.8.20 → 2.8.22

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
@@ -1,7 +1,7 @@
1
1
  import { buildTheme, createColorTheme as createColorTheme$1, hexToRgb as hexToRgb$1, hslToRgb as hslToRgb$1, multiply as multiply$1, parseColor as parseColor$1, rgbToHex as rgbToHex$1, rgbToHsl as rgbToHsl$1, rgba as rgba$1, screen as screen$1, getTheme_v2, getScopedTheme } from "@sanity/ui/theme";
2
2
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
3
  import { c } from "react-compiler-runtime";
4
- import { useMemo, useState, useRef, useEffect, useDebugValue, useImperativeHandle, useSyncExternalStore, createContext, useContext, forwardRef, useId, Children, isValidElement, cloneElement, useCallback, Component, memo, useLayoutEffect, useReducer, Fragment as Fragment$1, startTransition } from "react";
4
+ import { useState, useRef, useEffect, useDebugValue, useImperativeHandle, useMemo, useSyncExternalStore, createContext, useContext, forwardRef, useId, Children, isValidElement, cloneElement, Component, memo, useCallback, useLayoutEffect, useReducer, Fragment as Fragment$1, startTransition } from "react";
5
5
  import ReactIs, { isValidElementType } from "react-is";
6
6
  import { ThemeProvider as ThemeProvider$1, useTheme as useTheme$1, css, styled, keyframes } from "styled-components";
7
7
  import { SpinnerIcon, CheckmarkIcon, RemoveIcon, ChevronDownIcon, CloseIcon, ChevronRightIcon, ToggleArrowRightIcon } from "@sanity/icons";
@@ -154,13 +154,11 @@ function responsiveTextFont(props) {
154
154
  return responsiveFont("text", props);
155
155
  }
156
156
  function useArrayProp(val, defaultVal) {
157
- const __perf_hash__ = useMemo(() => JSON.stringify(val ?? defaultVal), [defaultVal, val]);
158
- return useMemo(
159
- () => _getArrayProp(val, defaultVal),
160
- // Improve performance: Keep object identify for a given hash of the value
161
- // eslint-disable-next-line react-hooks/exhaustive-deps
162
- [__perf_hash__]
163
- );
157
+ const $ = c(3);
158
+ let t0;
159
+ $[0] !== val || $[1] !== defaultVal ? (t0 = () => [_getArrayProp(val, defaultVal), JSON.stringify(val ?? defaultVal)], $[0] = val, $[1] = defaultVal, $[2] = t0) : t0 = $[2];
160
+ const [t1, setCache] = useState(t0), [cachedVal, cachedHash] = t1, hash = JSON.stringify(val ?? defaultVal);
161
+ return hash !== cachedHash && setCache([_getArrayProp(val, defaultVal), hash]), cachedVal;
164
162
  }
165
163
  function _getElements(element, elementsArg) {
166
164
  const ret = [element];
@@ -1786,19 +1784,26 @@ function responsiveAvatarStackSizeStyle(props) {
1786
1784
  });
1787
1785
  }
1788
1786
  const Root$z = styled.div(responsiveAvatarStackSizeStyle, avatarStackStyle), AvatarStack = forwardRef(function(props, ref) {
1789
- const {
1787
+ const $ = c(15);
1788
+ let t0, t1, childrenProp, restProps;
1789
+ $[0] !== props ? ({
1790
1790
  children: childrenProp,
1791
- maxLength: maxLengthProp = 4,
1792
- size: sizeProp = 1,
1791
+ maxLength: t0,
1792
+ size: t1,
1793
1793
  ...restProps
1794
- } = props, children = useMemo(() => Children.toArray(childrenProp).filter(isValidElement), [childrenProp]), maxLength = Math.max(maxLengthProp, 0), size2 = useArrayProp(sizeProp), len = children.length, visibleCount = maxLength - 1, extraCount = len - visibleCount, visibleChildren = extraCount > 1 ? children.slice(extraCount, len) : children;
1795
- return /* @__PURE__ */ jsxs(Root$z, { "data-ui": "AvatarStack", ...restProps, ref, $size: size2, children: [
1796
- len === 0 && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(AvatarCounter, { count: len, size: size2 }) }),
1797
- len !== 0 && extraCount > 1 && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(AvatarCounter, { count: extraCount, size: size2 }) }),
1798
- visibleChildren.map((child, childIndex) => /* @__PURE__ */ jsx("div", { children: cloneElement(child, {
1799
- size: size2
1800
- }) }, String(childIndex)))
1801
- ] });
1794
+ } = props, $[0] = props, $[1] = t0, $[2] = t1, $[3] = childrenProp, $[4] = restProps) : (t0 = $[1], t1 = $[2], childrenProp = $[3], restProps = $[4]);
1795
+ const maxLengthProp = t0 === void 0 ? 4 : t0, sizeProp = t1 === void 0 ? 1 : t1, children = Children.toArray(childrenProp).filter(isValidElement), maxLength = Math.max(maxLengthProp, 0), size2 = useArrayProp(sizeProp), len = children.length, visibleCount = maxLength - 1, extraCount = len - visibleCount, visibleChildren = extraCount > 1 ? children.slice(extraCount, len) : children, T0 = Root$z, t2 = "AvatarStack", t3 = len === 0 && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(AvatarCounter, { count: len, size: size2 }) }), t4 = len !== 0 && extraCount > 1 && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(AvatarCounter, { count: extraCount, size: size2 }) });
1796
+ let t5;
1797
+ $[5] !== size2 ? (t5 = (child, childIndex) => /* @__PURE__ */ jsx("div", { children: cloneElement(child, {
1798
+ size: size2
1799
+ }) }, String(childIndex)), $[5] = size2, $[6] = t5) : t5 = $[6];
1800
+ const t6 = visibleChildren.map(t5);
1801
+ let t7;
1802
+ return $[7] !== T0 || $[8] !== restProps || $[9] !== ref || $[10] !== size2 || $[11] !== t3 || $[12] !== t4 || $[13] !== t6 ? (t7 = /* @__PURE__ */ jsxs(T0, { "data-ui": t2, ...restProps, ref, $size: size2, children: [
1803
+ t3,
1804
+ t4,
1805
+ t6
1806
+ ] }), $[7] = T0, $[8] = restProps, $[9] = ref, $[10] = size2, $[11] = t3, $[12] = t4, $[13] = t6, $[14] = t7) : t7 = $[14], t7;
1802
1807
  });
1803
1808
  AvatarStack.displayName = "ForwardRef(AvatarStack)";
1804
1809
  const Root$y = styled.div(boxStyle, flexItemStyle, responsiveBoxStyle, responsiveGridItemStyle, responsiveMarginStyle, responsivePaddingStyle), Box = forwardRef(function(props, ref) {
@@ -3217,16 +3222,37 @@ function findMinBreakpoints(media, width) {
3217
3222
  return ret;
3218
3223
  }
3219
3224
  const ElementQuery = forwardRef(function(props, forwardedRef) {
3220
- const theme = useTheme_v2(), {
3225
+ const $ = c(18), theme = useTheme_v2();
3226
+ let _media, restProps, children;
3227
+ $[0] !== props ? ({
3221
3228
  children,
3222
- media = theme.media,
3229
+ media: _media,
3223
3230
  ...restProps
3224
- } = props, ref = useRef(null), [element, setElement] = useState(null), elementSize = useElementSize(element), width = useMemo(() => elementSize?.border.width ?? window.innerWidth, [elementSize]), max = useMemo(() => findMaxBreakpoints(media, width), [media, width]), min = useMemo(() => findMinBreakpoints(media, width), [media, width]);
3225
- useImperativeHandle(forwardedRef, () => ref.current);
3226
- const setRef = useCallback((el) => {
3227
- ref.current = el, setElement(el);
3228
- }, []);
3229
- return /* @__PURE__ */ jsx("div", { "data-ui": "ElementQuery", ...restProps, "data-eq-max": max.length ? max.join(" ") : void 0, "data-eq-min": min.length ? min.join(" ") : void 0, ref: setRef, children });
3231
+ } = props, $[0] = props, $[1] = _media, $[2] = restProps, $[3] = children) : (_media = $[1], restProps = $[2], children = $[3]);
3232
+ const media = _media ?? theme.media, [element, setElement] = useState(null), elementSize = useElementSize(element);
3233
+ let t0;
3234
+ t0 = elementSize?.border.width ?? window.innerWidth;
3235
+ const width = t0;
3236
+ let t1, t2;
3237
+ if ($[4] !== media || $[5] !== width) {
3238
+ const eq = findMaxBreakpoints(media, width);
3239
+ t2 = eq.length ? eq.join(" ") : void 0, $[4] = media, $[5] = width, $[6] = t2;
3240
+ } else
3241
+ t2 = $[6];
3242
+ t1 = t2;
3243
+ const max = t1;
3244
+ let t3, t4;
3245
+ if ($[7] !== media || $[8] !== width) {
3246
+ const eq_0 = findMinBreakpoints(media, width);
3247
+ t4 = eq_0.length ? eq_0.join(" ") : void 0, $[7] = media, $[8] = width, $[9] = t4;
3248
+ } else
3249
+ t4 = $[9];
3250
+ t3 = t4;
3251
+ const min = t3;
3252
+ let t5, t6;
3253
+ $[10] !== element ? (t5 = () => element, t6 = [element], $[10] = element, $[11] = t5, $[12] = t6) : (t5 = $[11], t6 = $[12]), useImperativeHandle(forwardedRef, t5, t6);
3254
+ let t7;
3255
+ return $[13] !== restProps || $[14] !== max || $[15] !== min || $[16] !== children ? (t7 = /* @__PURE__ */ jsx("div", { "data-ui": "ElementQuery", ...restProps, "data-eq-max": max, "data-eq-min": min, ref: setElement, children }), $[13] = restProps, $[14] = max, $[15] = min, $[16] = children, $[17] = t7) : t7 = $[17], t7;
3230
3256
  });
3231
3257
  ElementQuery.displayName = "ForwardRef(ElementQuery)";
3232
3258
  class ErrorBoundary extends Component {
@@ -3353,10 +3379,18 @@ function _isScrollable(el) {
3353
3379
  return style.overflowX.includes("auto") || style.overflowX.includes("scroll") || style.overflowY.includes("auto") || style.overflowY.includes("scroll");
3354
3380
  }
3355
3381
  function LayerProvider(props) {
3356
- const {
3382
+ const $ = c(19), {
3357
3383
  children,
3358
- zOffset: zOffsetProp = 0
3359
- } = props, parentContextValue = useContext(LayerContext), parent = parentContextValue && getLayerContext(parentContextValue), parentRegisterChild = parent?.registerChild, level = (parent?.level ?? 0) + 1, zOffset = useArrayProp(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((childLevel) => {
3384
+ zOffset: t0
3385
+ } = props, zOffsetProp = t0 === void 0 ? 0 : t0, parentContextValue = useContext(LayerContext);
3386
+ let t1;
3387
+ $[0] !== parentContextValue ? (t1 = parentContextValue && getLayerContext(parentContextValue), $[0] = parentContextValue, $[1] = t1) : t1 = $[1];
3388
+ const parent = t1, parentRegisterChild = parent?.registerChild, level = (parent?.level ?? 0) + 1, zOffset = useArrayProp(zOffsetProp), maxMediaIndex = zOffset.length - 1, mediaIndex = Math.min(useMediaIndex(), maxMediaIndex), zIndex = parent ? parent.zIndex + zOffset[mediaIndex] : zOffset[mediaIndex];
3389
+ let t2;
3390
+ $[2] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {}, $[2] = t2) : t2 = $[2];
3391
+ const [, setChildLayers] = useState(t2), [size2, setSize] = useState(0), isTopLayer = size2 === 0;
3392
+ let t3;
3393
+ $[3] !== parentRegisterChild || $[4] !== setChildLayers ? (t3 = (childLevel) => {
3360
3394
  const parentDispose = parentRegisterChild?.(childLevel);
3361
3395
  return childLevel !== void 0 ? setChildLayers((state) => {
3362
3396
  const prevLen = state[childLevel] ?? 0, nextState = {
@@ -3369,20 +3403,25 @@ function LayerProvider(props) {
3369
3403
  const nextState_0 = {
3370
3404
  ...state_0
3371
3405
  };
3372
- return nextState_0[childLevel] === 1 ? (delete nextState_0[childLevel], setSize(Object.keys(nextState_0).length)) : nextState_0[childLevel] -= 1, nextState_0;
3406
+ return nextState_0[childLevel] === 1 ? (delete nextState_0[childLevel], setSize(Object.keys(nextState_0).length)) : nextState_0[childLevel] = nextState_0[childLevel] - 1, nextState_0;
3373
3407
  }) : setSize((v_0) => v_0 - 1), parentDispose?.();
3374
3408
  };
3375
- }, [parentRegisterChild]);
3376
- useEffect(() => parentRegisterChild?.(level), [level, parentRegisterChild]);
3377
- const value = useMemo(() => ({
3409
+ }, $[3] = parentRegisterChild, $[4] = setChildLayers, $[5] = t3) : t3 = $[5];
3410
+ const registerChild = t3;
3411
+ let t4, t5;
3412
+ $[6] !== parentRegisterChild || $[7] !== level ? (t4 = () => parentRegisterChild?.(level), t5 = [level, parentRegisterChild], $[6] = parentRegisterChild, $[7] = level, $[8] = t4, $[9] = t5) : (t4 = $[8], t5 = $[9]), useEffect(t4, t5);
3413
+ let t6, t7;
3414
+ $[10] !== isTopLayer || $[11] !== level || $[12] !== registerChild || $[13] !== size2 || $[14] !== zIndex ? (t7 = {
3378
3415
  version: 0,
3379
3416
  isTopLayer,
3380
3417
  level,
3381
3418
  registerChild,
3382
3419
  size: size2,
3383
3420
  zIndex
3384
- }), [isTopLayer, level, registerChild, size2, zIndex]);
3385
- return /* @__PURE__ */ jsx(LayerContext.Provider, { value, children });
3421
+ }, $[10] = isTopLayer, $[11] = level, $[12] = registerChild, $[13] = size2, $[14] = zIndex, $[15] = t7) : t7 = $[15], t6 = t7;
3422
+ const value = t6;
3423
+ let t8;
3424
+ return $[16] !== value || $[17] !== children ? (t8 = /* @__PURE__ */ jsx(LayerContext.Provider, { value, children }), $[16] = value, $[17] = children, $[18] = t8) : t8 = $[18], t8;
3386
3425
  }
3387
3426
  LayerProvider.displayName = "LayerProvider";
3388
3427
  const Root$j = styled.div({
@@ -5733,8 +5772,8 @@ const Root$5 = styled(Box)`
5733
5772
  });
5734
5773
  Menu.displayName = "ForwardRef(Menu)";
5735
5774
  const MenuButton = forwardRef(function(props, forwardedRef) {
5736
- const {
5737
- __unstable_disableRestoreFocusOnClose: disableRestoreFocusOnClose = !1,
5775
+ const $ = c(62), {
5776
+ __unstable_disableRestoreFocusOnClose: t0,
5738
5777
  boundaryElement: deprecated_boundaryElement,
5739
5778
  button: buttonProp,
5740
5779
  id,
@@ -5743,23 +5782,38 @@ const MenuButton = forwardRef(function(props, forwardedRef) {
5743
5782
  onOpen,
5744
5783
  placement: deprecated_placement,
5745
5784
  popoverScheme: deprecated_popoverScheme,
5746
- portal: deprecated_portal = !0,
5785
+ portal: t1,
5747
5786
  popover,
5748
5787
  popoverRadius: deprecated_popoverRadius,
5749
5788
  preventOverflow: deprecated_preventOverflow
5750
- } = props, [open, setOpen] = useState(!1), [shouldFocus, setShouldFocus] = useState(null), [buttonElement, setButtonElement] = useState(null), [menuElements, setChildMenuElements] = useState([]), openRef = useRef(open);
5751
- useEffect(() => {
5789
+ } = props, disableRestoreFocusOnClose = t0 === void 0 ? !1 : t0, deprecated_portal = t1 === void 0 ? !0 : t1, [open, setOpen] = useState(!1), [shouldFocus, setShouldFocus] = useState(null), [buttonElement, setButtonElement] = useState(null);
5790
+ let t2;
5791
+ $[0] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[0] = t2) : t2 = $[0];
5792
+ const [menuElements, setChildMenuElements] = useState(t2), openRef = useRef(open);
5793
+ let t3, t4;
5794
+ $[1] !== onOpen || $[2] !== open ? (t3 = () => {
5752
5795
  onOpen && open && !openRef.current && onOpen();
5753
- }, [onOpen, open]), useEffect(() => {
5796
+ }, t4 = [onOpen, open], $[1] = onOpen, $[2] = open, $[3] = t3, $[4] = t4) : (t3 = $[3], t4 = $[4]), useEffect(t3, t4);
5797
+ let t5, t6;
5798
+ $[5] !== onClose || $[6] !== open ? (t5 = () => {
5754
5799
  onClose && !open && openRef.current && onClose();
5755
- }, [onClose, open]), useEffect(() => {
5800
+ }, t6 = [onClose, open], $[5] = onClose, $[6] = open, $[7] = t5, $[8] = t6) : (t5 = $[7], t6 = $[8]), useEffect(t5, t6);
5801
+ let t7, t8;
5802
+ $[9] !== open ? (t7 = () => {
5756
5803
  openRef.current = open;
5757
- }, [open]);
5758
- const handleButtonClick = useCallback(() => {
5804
+ }, t8 = [open], $[9] = open, $[10] = t7, $[11] = t8) : (t7 = $[10], t8 = $[11]), useEffect(t7, t8);
5805
+ let t9;
5806
+ $[12] === Symbol.for("react.memo_cache_sentinel") ? (t9 = () => {
5759
5807
  setOpen((v) => !v), setShouldFocus(null);
5760
- }, []), handleMouseDown = useCallback((event) => {
5808
+ }, $[12] = t9) : t9 = $[12];
5809
+ const handleButtonClick = t9;
5810
+ let t10;
5811
+ $[13] !== open ? (t10 = (event) => {
5761
5812
  open && event.preventDefault();
5762
- }, [open]), handleButtonKeyDown = useCallback((event_0) => {
5813
+ }, $[13] = open, $[14] = t10) : t10 = $[14];
5814
+ const handleMouseDown = t10;
5815
+ let t11;
5816
+ $[15] === Symbol.for("react.memo_cache_sentinel") ? (t11 = (event_0) => {
5763
5817
  if (event_0.key === "ArrowDown" || event_0.key === "Enter" || event_0.key === " ") {
5764
5818
  event_0.preventDefault(), setOpen(!0), setShouldFocus("first");
5765
5819
  return;
@@ -5768,7 +5822,10 @@ const MenuButton = forwardRef(function(props, forwardedRef) {
5768
5822
  event_0.preventDefault(), setOpen(!0), setShouldFocus("last");
5769
5823
  return;
5770
5824
  }
5771
- }, []), handleMenuClickOutside = useCallback((event_1) => {
5825
+ }, $[15] = t11) : t11 = $[15];
5826
+ const handleButtonKeyDown = t11;
5827
+ let t12;
5828
+ $[16] !== buttonElement || $[17] !== menuElements ? (t12 = (event_1) => {
5772
5829
  const target = event_1.target;
5773
5830
  if (target instanceof Node && !(buttonElement && (target === buttonElement || buttonElement.contains(target)))) {
5774
5831
  for (const el of menuElements)
@@ -5776,9 +5833,15 @@ const MenuButton = forwardRef(function(props, forwardedRef) {
5776
5833
  return;
5777
5834
  setOpen(!1);
5778
5835
  }
5779
- }, [buttonElement, menuElements]), handleMenuEscape = useCallback(() => {
5836
+ }, $[16] = buttonElement, $[17] = menuElements, $[18] = t12) : t12 = $[18];
5837
+ const handleMenuClickOutside = t12;
5838
+ let t13;
5839
+ $[19] !== disableRestoreFocusOnClose || $[20] !== buttonElement ? (t13 = () => {
5780
5840
  setOpen(!1), !disableRestoreFocusOnClose && buttonElement && buttonElement.focus();
5781
- }, [buttonElement, disableRestoreFocusOnClose]), handleBlur = useCallback((event_2) => {
5841
+ }, $[19] = disableRestoreFocusOnClose, $[20] = buttonElement, $[21] = t13) : t13 = $[21];
5842
+ const handleMenuEscape = t13;
5843
+ let t14;
5844
+ $[22] !== menuElements ? (t14 = (event_2) => {
5782
5845
  const target_0 = event_2.relatedTarget;
5783
5846
  if (target_0 instanceof Node) {
5784
5847
  for (const el_0 of menuElements)
@@ -5786,9 +5849,18 @@ const MenuButton = forwardRef(function(props, forwardedRef) {
5786
5849
  return;
5787
5850
  setOpen(!1);
5788
5851
  }
5789
- }, [menuElements]), handleItemClick = useCallback(() => {
5852
+ }, $[22] = menuElements, $[23] = t14) : t14 = $[23];
5853
+ const handleBlur = t14;
5854
+ let t15;
5855
+ $[24] !== disableRestoreFocusOnClose || $[25] !== buttonElement ? (t15 = () => {
5790
5856
  setOpen(!1), !disableRestoreFocusOnClose && buttonElement && buttonElement.focus();
5791
- }, [buttonElement, disableRestoreFocusOnClose]), registerElement = useCallback((el_1) => (setChildMenuElements((els) => els.concat([el_1])), () => setChildMenuElements((els_0) => els_0.filter((_el) => _el !== el_1))), []), menuProps = useMemo(() => ({
5857
+ }, $[24] = disableRestoreFocusOnClose, $[25] = buttonElement, $[26] = t15) : t15 = $[26];
5858
+ const handleItemClick = t15;
5859
+ let t16;
5860
+ $[27] === Symbol.for("react.memo_cache_sentinel") ? (t16 = (el_1) => (setChildMenuElements((els) => els.concat([el_1])), () => setChildMenuElements((els_0) => els_0.filter((_el) => _el !== el_1))), $[27] = t16) : t16 = $[27];
5861
+ const registerElement = t16;
5862
+ let t17;
5863
+ $[28] !== id || $[29] !== handleBlur || $[30] !== handleMenuClickOutside || $[31] !== handleMenuEscape || $[32] !== handleItemClick || $[33] !== buttonElement || $[34] !== shouldFocus || $[35] !== menuProp ? (t17 = menuProp && cloneElement(menuProp, {
5792
5864
  "aria-labelledby": id,
5793
5865
  onBlurCapture: handleBlur,
5794
5866
  onClickOutside: handleMenuClickOutside,
@@ -5797,7 +5869,10 @@ const MenuButton = forwardRef(function(props, forwardedRef) {
5797
5869
  originElement: buttonElement,
5798
5870
  registerElement,
5799
5871
  shouldFocus
5800
- }), [buttonElement, handleMenuClickOutside, handleMenuEscape, handleItemClick, id, handleBlur, registerElement, shouldFocus]), menu = menuProp && cloneElement(menuProp, menuProps), ref = useRef(null), button = useMemo(() => buttonProp && cloneElement(buttonProp, {
5872
+ }), $[28] = id, $[29] = handleBlur, $[30] = handleMenuClickOutside, $[31] = handleMenuEscape, $[32] = handleItemClick, $[33] = buttonElement, $[34] = shouldFocus, $[35] = menuProp, $[36] = t17) : t17 = $[36];
5873
+ const menu = t17;
5874
+ let t18, t19;
5875
+ $[37] !== buttonProp || $[38] !== open || $[39] !== id || $[40] !== handleMouseDown ? (t19 = buttonProp && cloneElement(buttonProp, {
5801
5876
  "data-ui": "MenuButton",
5802
5877
  id,
5803
5878
  onClick: handleButtonClick,
@@ -5805,14 +5880,16 @@ const MenuButton = forwardRef(function(props, forwardedRef) {
5805
5880
  onMouseDown: handleMouseDown,
5806
5881
  "aria-haspopup": !0,
5807
5882
  "aria-expanded": open,
5808
- ref,
5883
+ ref: setButtonElement,
5809
5884
  selected: buttonProp.props.selected ?? open
5810
- }), [buttonProp, handleButtonClick, handleButtonKeyDown, handleMouseDown, id, open]);
5811
- useImperativeHandle(forwardedRef, () => ref.current), useEffect(() => {
5812
- if (button)
5813
- return setButtonElement(ref.current), () => setButtonElement(null);
5814
- }, [button]);
5815
- const popoverProps = useMemo(() => ({
5885
+ }), $[37] = buttonProp, $[38] = open, $[39] = id, $[40] = handleMouseDown, $[41] = t19) : t19 = $[41], t18 = t19;
5886
+ const button = t18;
5887
+ let t20, t21;
5888
+ $[42] !== buttonElement ? (t20 = () => buttonElement, t21 = [buttonElement], $[42] = buttonElement, $[43] = t20, $[44] = t21) : (t20 = $[43], t21 = $[44]), useImperativeHandle(forwardedRef, t20, t21);
5889
+ let t22, t23;
5890
+ $[45] !== popover ? (t23 = popover || {}, $[45] = popover, $[46] = t23) : t23 = $[46];
5891
+ let t24;
5892
+ $[47] !== deprecated_boundaryElement || $[48] !== deprecated_placement || $[49] !== deprecated_portal || $[50] !== deprecated_preventOverflow || $[51] !== deprecated_popoverRadius || $[52] !== deprecated_popoverScheme || $[53] !== t23 ? (t24 = {
5816
5893
  boundaryElement: deprecated_boundaryElement,
5817
5894
  overflow: "auto",
5818
5895
  placement: deprecated_placement,
@@ -5820,9 +5897,13 @@ const MenuButton = forwardRef(function(props, forwardedRef) {
5820
5897
  preventOverflow: deprecated_preventOverflow,
5821
5898
  radius: deprecated_popoverRadius,
5822
5899
  scheme: deprecated_popoverScheme,
5823
- ...popover || {}
5824
- }), [deprecated_boundaryElement, deprecated_placement, deprecated_popoverRadius, deprecated_popoverScheme, deprecated_portal, deprecated_preventOverflow, popover]);
5825
- return /* @__PURE__ */ jsx(Popover, { "data-ui": "MenuButton__popover", ...popoverProps, content: menu, open, children: button || /* @__PURE__ */ jsx(Fragment, {}) });
5900
+ ...t23
5901
+ }, $[47] = deprecated_boundaryElement, $[48] = deprecated_placement, $[49] = deprecated_portal, $[50] = deprecated_preventOverflow, $[51] = deprecated_popoverRadius, $[52] = deprecated_popoverScheme, $[53] = t23, $[54] = t24) : t24 = $[54], t22 = t24;
5902
+ const popoverProps = t22;
5903
+ let t25;
5904
+ $[55] !== button ? (t25 = button || /* @__PURE__ */ jsx(Fragment, {}), $[55] = button, $[56] = t25) : t25 = $[56];
5905
+ let t26;
5906
+ return $[57] !== popoverProps || $[58] !== menu || $[59] !== open || $[60] !== t25 ? (t26 = /* @__PURE__ */ jsx(Popover, { "data-ui": "MenuButton__popover", ...popoverProps, content: menu, open, children: t25 }), $[57] = popoverProps, $[58] = menu, $[59] = open, $[60] = t25, $[61] = t26) : t26 = $[61], t26;
5826
5907
  });
5827
5908
  MenuButton.displayName = "ForwardRef(MenuButton)";
5828
5909
  const MenuDivider = styled.hr`
@@ -6460,7 +6541,12 @@ function _temp() {
6460
6541
  return !0;
6461
6542
  }
6462
6543
  const subscribe = () => () => {
6463
- }, ToastContext = createGlobalScopedContext("@sanity/ui/context/toast", null), Root$1 = styled(Layer)`
6544
+ }, ToastContext = createGlobalScopedContext("@sanity/ui/context/toast", null);
6545
+ let toastId = 0;
6546
+ function generateToastId() {
6547
+ return String(toastId++);
6548
+ }
6549
+ const Root$1 = styled(Layer)`
6464
6550
  position: fixed;
6465
6551
  top: 0;
6466
6552
  left: 0;
@@ -6475,31 +6561,44 @@ const subscribe = () => () => {
6475
6561
  max-width: 420px;
6476
6562
  width: 100%;
6477
6563
  `;
6478
- let toastId = 0;
6479
6564
  function ToastProvider(props) {
6480
- const {
6565
+ const $ = c(24), {
6481
6566
  children,
6482
- padding = 4,
6567
+ padding: t0,
6483
6568
  paddingX,
6484
6569
  paddingY,
6485
6570
  zOffset
6486
- } = props, [state, _setState] = useState([]), toastsRef = useRef({}), mounted = useMounted(), prefersReducedMotion = usePrefersReducedMotion(), variants = useMemo(() => ({
6487
- initial: {
6488
- opacity: 0,
6489
- [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: 0,
6490
- y: 32,
6491
- scale: 0.25,
6492
- willChange: "transform"
6493
- },
6494
- animate: {
6495
- opacity: [0, 1, 1],
6496
- [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: [0, 0, 1],
6497
- y: 0,
6498
- scale: 1
6499
- },
6571
+ } = props, padding = t0 === void 0 ? 4 : t0;
6572
+ let t1;
6573
+ $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[0] = t1) : t1 = $[0];
6574
+ const [state, _setState] = useState(t1);
6575
+ let t2;
6576
+ $[1] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {}, $[1] = t2) : t2 = $[1];
6577
+ const toastsRef = useRef(t2), mounted = useMounted(), prefersReducedMotion = usePrefersReducedMotion();
6578
+ let t3, t4, t5;
6579
+ $[2] === Symbol.for("react.memo_cache_sentinel") ? (t4 = {
6580
+ opacity: 0,
6581
+ [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: 0,
6582
+ y: 32,
6583
+ scale: 0.25,
6584
+ willChange: "transform"
6585
+ }, t5 = [0, 1, 1], $[2] = t4, $[3] = t5) : (t4 = $[2], t5 = $[3]);
6586
+ let t6, t7;
6587
+ $[4] === Symbol.for("react.memo_cache_sentinel") ? (t6 = {
6588
+ opacity: t5,
6589
+ [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: [0, 0, 1],
6590
+ y: 0,
6591
+ scale: 1
6592
+ }, t7 = [1, 1, 0], $[4] = t6, $[5] = t7) : (t6 = $[4], t7 = $[5]);
6593
+ let t8;
6594
+ $[6] === Symbol.for("react.memo_cache_sentinel") ? (t8 = [1, 0, 0], $[6] = t8) : t8 = $[6];
6595
+ let t9;
6596
+ $[7] !== prefersReducedMotion ? (t9 = {
6597
+ initial: t4,
6598
+ animate: t6,
6500
6599
  exit: {
6501
- opacity: [1, 1, 0],
6502
- [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: [1, 0, 0],
6600
+ opacity: t7,
6601
+ [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: t8,
6503
6602
  scale: 0.5,
6504
6603
  transition: prefersReducedMotion ? {
6505
6604
  duration: 0
@@ -6507,10 +6606,13 @@ function ToastProvider(props) {
6507
6606
  duration: 0.2
6508
6607
  }
6509
6608
  }
6510
- }), [prefersReducedMotion]), value = useMemo(() => ({
6609
+ }, $[7] = prefersReducedMotion, $[8] = t9) : t9 = $[8], t3 = t9;
6610
+ const variants = t3;
6611
+ let t10, t11;
6612
+ $[9] === Symbol.for("react.memo_cache_sentinel") ? (t11 = {
6511
6613
  version: 0,
6512
6614
  push: (params) => {
6513
- const setState = (state_0) => startTransition(() => _setState(state_0)), id = params.id || String(toastId++), duration = params.duration || 5e3, dismiss = () => {
6615
+ const setState = (state_0) => startTransition(() => _setState(state_0)), id = params.id || generateToastId(), duration = params.duration || 5e3, dismiss = () => {
6514
6616
  const timeoutId = toastsRef.current[id]?.timeoutId;
6515
6617
  setState((prevState) => {
6516
6618
  const idx = prevState.findIndex((t) => t.id === id);
@@ -6532,27 +6634,36 @@ function ToastProvider(props) {
6532
6634
  timeoutId: setTimeout(dismiss, duration)
6533
6635
  }, id;
6534
6636
  }
6535
- }), []);
6536
- return useEffect(() => () => {
6637
+ }, $[9] = t11) : t11 = $[9], t10 = t11;
6638
+ const value = t10;
6639
+ let t12, t13;
6640
+ $[10] === Symbol.for("react.memo_cache_sentinel") ? (t12 = () => () => {
6537
6641
  for (const {
6538
6642
  timeoutId: timeoutId_0
6539
6643
  } of Object.values(toastsRef.current))
6540
6644
  clearTimeout(timeoutId_0);
6541
6645
  toastsRef.current = {};
6542
- }, []), /* @__PURE__ */ jsxs(ToastContext.Provider, { value, children: [
6543
- children,
6544
- mounted && /* @__PURE__ */ jsx(Root$1, { "data-ui": "ToastProvider", zOffset, children: /* @__PURE__ */ jsx(ToastContainer, { children: /* @__PURE__ */ jsx(Box, { padding, paddingX, paddingY, children: /* @__PURE__ */ jsx(AnimatePresence, { initial: !1, children: state.map(({
6646
+ }, t13 = [], $[10] = t12, $[11] = t13) : (t12 = $[10], t13 = $[11]), useEffect(t12, t13);
6647
+ let t14;
6648
+ $[12] !== mounted || $[13] !== variants || $[14] !== prefersReducedMotion || $[15] !== state || $[16] !== padding || $[17] !== paddingX || $[18] !== paddingY || $[19] !== zOffset ? (t14 = mounted && /* @__PURE__ */ jsx(Root$1, { "data-ui": "ToastProvider", zOffset, children: /* @__PURE__ */ jsx(ToastContainer, { children: /* @__PURE__ */ jsx(Box, { padding, paddingX, paddingY, children: /* @__PURE__ */ jsx(AnimatePresence, { initial: !1, children: state.map((t152) => {
6649
+ const {
6545
6650
  dismiss: dismiss_0,
6546
6651
  id: id_0,
6547
6652
  params: params_0
6548
- }) => /* @__PURE__ */ jsx(motion.div, { layout: "position", initial: "initial", animate: "animate", exit: "exit", variants, transition: prefersReducedMotion ? {
6653
+ } = t152;
6654
+ return /* @__PURE__ */ jsx(motion.div, { layout: "position", initial: "initial", animate: "animate", exit: "exit", variants, transition: prefersReducedMotion ? {
6549
6655
  duration: 0
6550
6656
  } : {
6551
6657
  type: "spring",
6552
6658
  damping: 30,
6553
6659
  stiffness: 400
6554
- }, children: /* @__PURE__ */ jsx(Toast, { closable: params_0.closable, description: params_0.description, onClose: dismiss_0, status: params_0.status, title: params_0.title, duration: params_0.duration }) }, id_0)) }) }) }) })
6555
- ] });
6660
+ }, children: /* @__PURE__ */ jsx(Toast, { closable: params_0.closable, description: params_0.description, onClose: dismiss_0, status: params_0.status, title: params_0.title, duration: params_0.duration }) }, id_0);
6661
+ }) }) }) }) }), $[12] = mounted, $[13] = variants, $[14] = prefersReducedMotion, $[15] = state, $[16] = padding, $[17] = paddingX, $[18] = paddingY, $[19] = zOffset, $[20] = t14) : t14 = $[20];
6662
+ let t15;
6663
+ return $[21] !== children || $[22] !== t14 ? (t15 = /* @__PURE__ */ jsxs(ToastContext.Provider, { value, children: [
6664
+ children,
6665
+ t14
6666
+ ] }), $[21] = children, $[22] = t14, $[23] = t15) : t15 = $[23], t15;
6556
6667
  }
6557
6668
  ToastProvider.displayName = "ToastProvider";
6558
6669
  function useToast() {