@sanity/ui 4.0.0-static.43 → 4.0.0-static.45

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.js CHANGED
@@ -1,14 +1,13 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { c } from "react/compiler-runtime";
3
3
  import { SpinnerIcon, CloseIcon, ChevronDownIcon, ChevronRightIcon, ToggleArrowRightIcon, CheckmarkIcon, RemoveIcon } from "@sanity/icons";
4
- import { isValidElement, useDebugValue, useSyncExternalStore, createContext, use, useRef, useImperativeHandle, useEffect, useState, cloneElement, useReducer, Children, Fragment as Fragment$1, startTransition, useId, lazy, Suspense, useLayoutEffect, Component } from "react";
4
+ import { isValidElement, useDebugValue, useSyncExternalStore, useState, Activity, createContext, use, useRef, useImperativeHandle, useEffect, cloneElement, useReducer, useEffectEvent, Children, Fragment as Fragment$1, startTransition, useId, lazy, Suspense, useLayoutEffect, Component } from "react";
5
5
  import { box, text, textOverflow, animatedSpinnerIcon, spinner, button, buttonLoadingBox, _arrow, vars, _arrowSvg, _arrowStrokeMask, _arrowStroke, _arrowShape, card, BREAKPOINTS, popoverCard, popover, _selectable, stack, textInput, textInputPrefix, textInputElement, _inputElement, _inputPresentation, textInputSuffix, breadcrumbs, container as container$1, dialogCard, dialogHeader, dialogContent, dialogScrollerShadowTop, dialogScroller, dialogScrollerShadowBottom, dialogFooter, dialog, dialogContainer, kbd, menu, menuDivider, toast, toastLayer, treeItem, label, avatar, avatarArrow, avatarInitials, avatarImage, avatarImageOutline, avatarCounter, avatarStack, badge, checkbox, checkboxInput, checkboxPresentation, code, heading, radio, radioInput, radioPresentation, select, selectPresentation, skeleton, codeSkeleton, headingSkeleton, labelSkeleton, textSkeleton, srOnly, _switch, _switchElement, _switchPresentation, _switchTrack, _switchThumb, textArea, tooltip, root } from "@sanity/ui/css";
6
6
  import { isValidElementType } from "react-is";
7
7
  import { detectOverflow, useFloating, autoPlacement, flip, offset, shift, arrow, hide, autoUpdate } from "@floating-ui/react-dom";
8
- import { motion, AnimatePresence } from "motion/react";
8
+ import { invariant, PresenceChild, motion, AnimatePresence } from "motion/react";
9
9
  import { createPortal } from "react-dom";
10
10
  import { assignInlineVars } from "@vanilla-extract/dynamic";
11
- import { useEffectEvent } from "use-effect-event";
12
11
  import { ResizeObserver } from "@juggle/resize-observer";
13
12
  const EMPTY_ARRAY = [], EMPTY_RECORD = {}, POPOVER_MOTION_PROPS = {
14
13
  card: {
@@ -470,6 +469,24 @@ const origin = {
470
469
  function clamp(num, min, max) {
471
470
  return Math.min(Math.max(num, min), max);
472
471
  }
472
+ function AnimateActivity(t0) {
473
+ const $ = c(9), {
474
+ mode: modeFromProps,
475
+ layoutMode,
476
+ children
477
+ } = t0, [mode, setMode] = useState(modeFromProps), isPresent = modeFromProps === "visible";
478
+ if (isPresent && mode !== "visible")
479
+ return setMode("visible"), null;
480
+ let t1;
481
+ $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => setMode("hidden"), $[0] = t1) : t1 = $[0];
482
+ const onExitComplete = t1;
483
+ invariant(!!Activity, "Activity component not found - upgrade to React 19.2.0 or higher");
484
+ const t2 = isPresent ? void 0 : onExitComplete, t3 = layoutMode === "pop" ? "popLayout" : "sync", t4 = children;
485
+ let t5;
486
+ $[1] !== isPresent || $[2] !== t2 || $[3] !== t3 || $[4] !== t4 ? (t5 = /* @__PURE__ */ jsx(PresenceChild, { isPresent, onExitComplete: t2, presenceAffectsLayout: !1, mode: t3, children: t4 }), $[1] = isPresent, $[2] = t2, $[3] = t3, $[4] = t4, $[5] = t5) : t5 = $[5];
487
+ let t6;
488
+ return $[6] !== mode || $[7] !== t5 ? (t6 = /* @__PURE__ */ jsx(Activity, { mode, children: t5 }), $[6] = mode, $[7] = t5, $[8] = t6) : t6 = $[8], t6;
489
+ }
473
490
  function getGlobalScope() {
474
491
  if (typeof globalThis < "u") return globalThis;
475
492
  if (typeof window < "u") return window;
@@ -1042,7 +1059,7 @@ function ViewportOverlay() {
1042
1059
  } }), $[0] = zIndex, $[1] = t0) : t0 = $[1], t0;
1043
1060
  }
1044
1061
  function Popover(props) {
1045
- const $ = c(113), t0 = props;
1062
+ const $ = c(114), t0 = props;
1046
1063
  let _fallbackPlacements, _floatingBoundary, _referenceBoundary, childProp, className, content2, disabled, forwardedRef, matchReferenceWidth, modal, open, padding, portal, referenceElement, rest, scheme, t1, t10, t11, t12, t13, t14, t2, t3, t4, t5, t6, t7, t8, t9, updateRef;
1047
1064
  if ($[0] !== t0) {
1048
1065
  const {
@@ -1171,7 +1188,7 @@ function Popover(props) {
1171
1188
  t28
1172
1189
  ] }), $[97] = t26, $[98] = t28, $[99] = t29) : t29 = $[99];
1173
1190
  const node_0 = t29;
1174
- let children = open ? node_0 : null;
1191
+ let children = node_0;
1175
1192
  if (open && portal) {
1176
1193
  let resolvedTone = tone;
1177
1194
  if (tone === "inherit") {
@@ -1185,12 +1202,12 @@ function Popover(props) {
1185
1202
  $[104] !== t302 || $[105] !== t32 ? (t33 = /* @__PURE__ */ jsx(Portal, { __unstable_name: t302, children: t32 }), $[104] = t302, $[105] = t32, $[106] = t33) : t33 = $[106], children = t33;
1186
1203
  }
1187
1204
  let t30;
1188
- $[107] !== animate || $[108] !== children ? (t30 = animate ? /* @__PURE__ */ jsx(AnimatePresence, { children }) : children, $[107] = animate, $[108] = children, $[109] = t30) : t30 = $[109];
1205
+ $[107] !== animate || $[108] !== children || $[109] !== open ? (t30 = animate ? /* @__PURE__ */ jsx(AnimateActivity, { mode: open ? "visible" : "hidden", layoutMode: "default", children }) : /* @__PURE__ */ jsx(Activity, { mode: open ? "visible" : "hidden", children }), $[107] = animate, $[108] = children, $[109] = open, $[110] = t30) : t30 = $[110];
1189
1206
  let t31;
1190
- return $[110] !== child || $[111] !== t30 ? (t31 = /* @__PURE__ */ jsxs(Fragment, { children: [
1207
+ return $[111] !== child || $[112] !== t30 ? (t31 = /* @__PURE__ */ jsxs(Fragment, { children: [
1191
1208
  t30,
1192
1209
  child
1193
- ] }), $[110] = child, $[111] = t30, $[112] = t31) : t31 = $[112], t31;
1210
+ ] }), $[111] = child, $[112] = t30, $[113] = t31) : t31 = $[113], t31;
1194
1211
  }
1195
1212
  function useMiddleware$1(t0) {
1196
1213
  const $ = c(36), {
@@ -4509,7 +4526,7 @@ function TooltipLayer(props) {
4509
4526
  }
4510
4527
  const DEFAULT_TOOLTIP_ELEMENT = "div";
4511
4528
  function Tooltip(props) {
4512
- const $ = c(143), t0 = props;
4529
+ const $ = c(144), t0 = props;
4513
4530
  let _boundaryElement, _fallbackPlacements, childProp, className, content2, delay, disabled, forwardedRef, portalProp, rest, scheme, t1, t2, t3, t4, t5, t6, t7, t8, t9;
4514
4531
  $[0] !== t0 ? ({
4515
4532
  animate: t1,
@@ -4703,7 +4720,7 @@ function Tooltip(props) {
4703
4720
  let t40;
4704
4721
  $[109] !== animate || $[110] !== arrowProp || $[111] !== arrowX || $[112] !== arrowY || $[113] !== as || $[114] !== content2 || $[115] !== originX || $[116] !== originY || $[117] !== padding || $[118] !== placement || $[119] !== radius || $[120] !== rest || $[121] !== scheme || $[122] !== setArrow || $[123] !== setFloating || $[124] !== shadow || $[125] !== t37 || $[126] !== t39 || $[127] !== tone || $[128] !== zOffset ? (t40 = /* @__PURE__ */ jsx(TooltipLayer, { "data-ui": "Tooltip", ...rest, animate, arrow: arrowProp, arrowRef: setArrow, arrowX, arrowY, as, className: t37, originX, originY, padding, placement, radius, ref: setFloating, scheme, shadow, style: t39, tone, zOffset, children: content2 }), $[109] = animate, $[110] = arrowProp, $[111] = arrowX, $[112] = arrowY, $[113] = as, $[114] = content2, $[115] = originX, $[116] = originY, $[117] = padding, $[118] = placement, $[119] = radius, $[120] = rest, $[121] = scheme, $[122] = setArrow, $[123] = setFloating, $[124] = shadow, $[125] = t37, $[126] = t39, $[127] = tone, $[128] = zOffset, $[129] = t40) : t40 = $[129];
4705
4722
  const node_0 = t40;
4706
- let children = showTooltip ? node_0 : null;
4723
+ let children = node_0;
4707
4724
  if (showTooltip && portalProp) {
4708
4725
  let resolvedTone = tone;
4709
4726
  if (tone === "inherit") {
@@ -4717,12 +4734,12 @@ function Tooltip(props) {
4717
4734
  $[134] !== t412 || $[135] !== t43 ? (t44 = /* @__PURE__ */ jsx(Portal, { __unstable_name: t412, children: t43 }), $[134] = t412, $[135] = t43, $[136] = t44) : t44 = $[136], children = t44;
4718
4735
  }
4719
4736
  let t41;
4720
- $[137] !== animate || $[138] !== children ? (t41 = animate ? /* @__PURE__ */ jsx(AnimatePresence, { children }) : children, $[137] = animate, $[138] = children, $[139] = t41) : t41 = $[139];
4737
+ $[137] !== animate || $[138] !== children || $[139] !== showTooltip ? (t41 = animate ? /* @__PURE__ */ jsx(AnimateActivity, { mode: showTooltip ? "visible" : "hidden", layoutMode: "default", children }) : /* @__PURE__ */ jsx(Activity, { mode: showTooltip ? "visible" : "hidden", children }), $[137] = animate, $[138] = children, $[139] = showTooltip, $[140] = t41) : t41 = $[140];
4721
4738
  let t42;
4722
- return $[140] !== child || $[141] !== t41 ? (t42 = /* @__PURE__ */ jsxs(Fragment, { children: [
4739
+ return $[141] !== child || $[142] !== t41 ? (t42 = /* @__PURE__ */ jsxs(Fragment, { children: [
4723
4740
  t41,
4724
4741
  child
4725
- ] }), $[140] = child, $[141] = t41, $[142] = t42) : t42 = $[142], t42;
4742
+ ] }), $[141] = child, $[142] = t41, $[143] = t42) : t42 = $[143], t42;
4726
4743
  }
4727
4744
  function useMiddleware(t0) {
4728
4745
  const $ = c(17), {