@sanity/ui 4.3.2 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/{arrow-CZ-Lw1QO.js → arrow-B8L6YB-v.js} +28 -7
  2. package/dist/arrow-B8L6YB-v.js.map +1 -0
  3. package/dist/autocomplete.d.ts +1 -1
  4. package/dist/autocomplete.js +6 -6
  5. package/dist/breadcrumbs.d.ts.map +1 -1
  6. package/dist/breadcrumbs.js +9 -9
  7. package/dist/breadcrumbs.js.map +1 -1
  8. package/dist/{button-Wii-24Xu.js → button-dhq4ViVg.js} +7 -7
  9. package/dist/button-dhq4ViVg.js.map +1 -0
  10. package/dist/code.js +2 -2
  11. package/dist/{codeFontStyle-84SMhFtI.js → codeFontStyle-B-bhR3hF.js} +2 -2
  12. package/dist/{codeFontStyle-84SMhFtI.js.map → codeFontStyle-B-bhR3hF.js.map} +1 -1
  13. package/dist/elementSizeObserver-pevZfdGa.js +45 -0
  14. package/dist/elementSizeObserver-pevZfdGa.js.map +1 -0
  15. package/dist/{flex-CpiAc-4D.js → flex-BqQXaSxS.js} +5 -12
  16. package/dist/flex-BqQXaSxS.js.map +1 -0
  17. package/dist/{grid-BVZEj_Xe.js → grid-Bpb2bIJ6.js} +5 -15
  18. package/dist/grid-Bpb2bIJ6.js.map +1 -0
  19. package/dist/{helpers-C8xxXAQC.js → helpers-XThPpWje.js} +16 -4
  20. package/dist/helpers-XThPpWje.js.map +1 -0
  21. package/dist/{hotkeys-DEMStMQ5.js → hotkeys-sG9yO97K.js} +4 -4
  22. package/dist/{hotkeys-DEMStMQ5.js.map → hotkeys-sG9yO97K.js.map} +1 -1
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +137 -121
  26. package/dist/index.js.map +1 -1
  27. package/dist/{layer-B0tlPeLT.js → layer-AWzYcY_j.js} +3 -3
  28. package/dist/{layer-B0tlPeLT.js.map → layer-AWzYcY_j.js.map} +1 -1
  29. package/dist/menu.d.ts +1 -1
  30. package/dist/menu.js +7 -7
  31. package/dist/{popover-DR6UQQvq.js → popover-C72hePrK.js} +125 -51
  32. package/dist/popover-C72hePrK.js.map +1 -0
  33. package/dist/{popover-CMlQeKn0.d.ts → popover-HDVgZg5e.d.ts} +22 -1
  34. package/dist/popover-HDVgZg5e.d.ts.map +1 -0
  35. package/dist/popover.d.ts +1 -1
  36. package/dist/popover.js +1 -1
  37. package/dist/{responsiveFont-CilwaORG.js → responsiveFont-B08q0jwm.js} +6 -4
  38. package/dist/responsiveFont-B08q0jwm.js.map +1 -0
  39. package/dist/{stack-SbGBZ0x3.js → stack-Cv-WM-7p.js} +4 -4
  40. package/dist/{stack-SbGBZ0x3.js.map → stack-Cv-WM-7p.js.map} +1 -1
  41. package/dist/{textInput-Yp5lnvZK.js → textInput-Ddxi4mkC.js} +5 -5
  42. package/dist/{textInput-Yp5lnvZK.js.map → textInput-Ddxi4mkC.js.map} +1 -1
  43. package/dist/toast.js +5 -5
  44. package/dist/tooltip.d.ts.map +1 -1
  45. package/dist/tooltip.js +165 -128
  46. package/dist/tooltip.js.map +1 -1
  47. package/dist/{useClickOutsideEvent-wGLGWBZN.js → useClickOutsideEvent-CC1zgOmv.js} +2 -2
  48. package/dist/{useClickOutsideEvent-wGLGWBZN.js.map → useClickOutsideEvent-CC1zgOmv.js.map} +1 -1
  49. package/dist/{useLayer-CUKYjJYq.js → useLayer-B0i19TTM.js} +31 -38
  50. package/dist/useLayer-B0i19TTM.js.map +1 -0
  51. package/package.json +5 -4
  52. package/dist/arrow-CZ-Lw1QO.js.map +0 -1
  53. package/dist/button-Wii-24Xu.js.map +0 -1
  54. package/dist/flex-CpiAc-4D.js.map +0 -1
  55. package/dist/grid-BVZEj_Xe.js.map +0 -1
  56. package/dist/helpers-C8xxXAQC.js.map +0 -1
  57. package/dist/popover-CMlQeKn0.d.ts.map +0 -1
  58. package/dist/popover-DR6UQQvq.js.map +0 -1
  59. package/dist/responsiveFont-CilwaORG.js.map +0 -1
  60. package/dist/useElementSize-BJvbGHq8.js +0 -51
  61. package/dist/useElementSize-BJvbGHq8.js.map +0 -1
  62. package/dist/useLayer-CUKYjJYq.js.map +0 -1
package/dist/tooltip.js CHANGED
@@ -1,14 +1,14 @@
1
1
  "use client";
2
- import { c as POPOVER_MOTION_PROPS, n as _getArrayProp } from "./helpers-C8xxXAQC.js";
3
- import { _ as useTheme_v2, d as createGlobalScopedContext, i as usePrefersReducedMotion, s as Card } from "./useLayer-CUKYjJYq.js";
2
+ import { l as POPOVER_MOTION_PROPS, n as _getArrayProp } from "./helpers-XThPpWje.js";
3
+ import { _ as useTheme_v2, d as createGlobalScopedContext, i as usePrefersReducedMotion, s as Card } from "./useLayer-B0i19TTM.js";
4
4
  import { i as origin, n as AnimateActivity, r as getTransformOrigin, t as getElementRef } from "./getElementRef-Jw7gY0eV.js";
5
- import { a as useBoundaryElement, n as Portal, r as usePortal, t as Arrow } from "./arrow-CZ-Lw1QO.js";
6
- import { t as Layer } from "./layer-B0tlPeLT.js";
5
+ import { a as resolvePortalElement, n as Portal, o as useBoundaryElement, r as usePortal, t as Arrow } from "./arrow-B8L6YB-v.js";
6
+ import { t as Layer } from "./layer-AWzYcY_j.js";
7
7
  import { c } from "react/compiler-runtime";
8
8
  import { clsx } from "clsx/lite";
9
- import { Activity, cloneElement, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
9
+ import { Activity, cloneElement, useContext, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useRef, useState } from "react";
10
10
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
11
- import { arrow, autoUpdate, flip, offset, shift, useFloating } from "@floating-ui/react-dom";
11
+ import { arrow, autoUpdate, detectOverflow, flip, offset, shift, size, useFloating } from "@floating-ui/react-dom";
12
12
  import { motion } from "motion/react";
13
13
  import { useEffectEvent } from "use-effect-event";
14
14
  /**
@@ -181,90 +181,85 @@ function useTooltipDelayGroup() {
181
181
  * @public
182
182
  */
183
183
  function Tooltip(props) {
184
- let $ = c(125), boundaryElementContext = useBoundaryElement(), { layer } = useTheme_v2(), { animate: t0, arrow: t1, boundaryElement: _boundaryElement, children: childProp, content, disabled, fallbackPlacements: _fallbackPlacementsProp, padding: t2, placement: t3, portal: portalProp, radius: t4, ref: forwardedRef, scheme, shadow: t5, zOffset: _zOffset, delay, ...restProps } = props, _animate = t0 !== void 0 && t0, arrowProp = t1 !== void 0 && t1, padding = t2 === void 0 ? 2 : t2, placementProp = t3 === void 0 ? "bottom" : t3, radius = t4 === void 0 ? 2 : t4, shadow = t5 === void 0 ? 2 : t5, boundaryElement = _boundaryElement ?? boundaryElementContext?.element, fallbackPlacementsProp = _fallbackPlacementsProp ?? DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? "bottom"], zOffset = _zOffset ?? layer.tooltip.zOffset, animate = !usePrefersReducedMotion() && _animate, t6;
184
+ let $ = c(122), boundaryElementContext = useBoundaryElement(), { layer } = useTheme_v2(), { animate: t0, arrow: t1, boundaryElement: _boundaryElement, children: childProp, content, disabled, fallbackPlacements: _fallbackPlacementsProp, padding: t2, placement: t3, portal: portalProp, radius: t4, ref: forwardedRef, scheme, shadow: t5, zOffset: _zOffset, delay, ...restProps } = props, _animate = t0 !== void 0 && t0, arrowProp = t1 !== void 0 && t1, padding = t2 === void 0 ? 2 : t2, placementProp = t3 === void 0 ? "bottom" : t3, radius = t4 === void 0 ? 2 : t4, shadow = t5 === void 0 ? 2 : t5, boundaryElement = _boundaryElement ?? boundaryElementContext?.element, fallbackPlacementsProp = _fallbackPlacementsProp ?? DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? "bottom"], zOffset = _zOffset ?? layer.tooltip.zOffset, animate = !usePrefersReducedMotion() && _animate, t6;
185
185
  $[0] === fallbackPlacementsProp ? t6 = $[1] : (t6 = _getArrayProp(fallbackPlacementsProp), $[0] = fallbackPlacementsProp, $[1] = t6);
186
- let fallbackPlacements = t6, ref = useRef(null), [referenceElement, setReferenceElement] = useState(null), arrowRef = useRef(null), [tooltipMaxWidth, setTooltipMaxWidth] = useState(0), t7;
186
+ let fallbackPlacements = t6, ref = useRef(null), [referenceElement, setReferenceElement] = useState(null), arrowRef = useRef(null), t7;
187
187
  $[2] === Symbol.for("react.memo_cache_sentinel") ? (t7 = () => ref.current, $[2] = t7) : t7 = $[2], useImperativeHandle(forwardedRef, t7);
188
- let portal = usePortal(), portalElement = typeof portalProp == "string" ? portal.elements?.[portalProp] || null : portal.element, t8;
189
- $[3] !== animate || $[4] !== arrowProp || $[5] !== boundaryElement || $[6] !== fallbackPlacements ? (t8 = {
188
+ let portal = usePortal(), portalName = typeof portalProp == "string" ? portalProp : void 0, t8;
189
+ $[3] !== portal || $[4] !== portalName ? (t8 = resolvePortalElement(portal, portalName), $[3] = portal, $[4] = portalName, $[5] = t8) : t8 = $[5];
190
+ let portalElement = t8, t9;
191
+ $[6] !== animate || $[7] !== arrowProp || $[8] !== boundaryElement || $[9] !== fallbackPlacements || $[10] !== portalElement ? (t9 = {
190
192
  animate,
191
193
  arrowProp,
192
194
  arrowRef,
193
195
  boundaryElement,
194
196
  fallbackPlacements,
197
+ portalElement,
195
198
  rootBoundary: "viewport"
196
- }, $[3] = animate, $[4] = arrowProp, $[5] = boundaryElement, $[6] = fallbackPlacements, $[7] = t8) : t8 = $[7];
197
- let middleware = useMiddleware(t8), t9;
198
- $[8] === referenceElement ? t9 = $[9] : (t9 = { reference: referenceElement }, $[8] = referenceElement, $[9] = t9);
199
- let t10;
200
- $[10] !== middleware || $[11] !== placementProp || $[12] !== t9 ? (t10 = {
199
+ }, $[6] = animate, $[7] = arrowProp, $[8] = boundaryElement, $[9] = fallbackPlacements, $[10] = portalElement, $[11] = t9) : t9 = $[11];
200
+ let middleware = useMiddleware(t9), t10;
201
+ $[12] === referenceElement ? t10 = $[13] : (t10 = { reference: referenceElement }, $[12] = referenceElement, $[13] = t10);
202
+ let t11;
203
+ $[14] !== middleware || $[15] !== placementProp || $[16] !== t10 ? (t11 = {
201
204
  middleware,
202
205
  placement: placementProp,
203
206
  whileElementsMounted: autoUpdate,
204
- elements: t9
205
- }, $[10] = middleware, $[11] = placementProp, $[12] = t9, $[13] = t10) : t10 = $[13];
206
- let { floatingStyles, placement, middlewareData, refs, update } = useFloating(t10), arrowX = middlewareData.arrow?.x, arrowY = middlewareData.arrow?.y, originX = middlewareData["@sanity/ui/origin"]?.originX, originY = middlewareData["@sanity/ui/origin"]?.originY, tooltipId = useId(), [isOpen, setIsOpen] = useDelayedState(!1), delayGroupContext = useTooltipDelayGroup(), t11;
207
- $[14] === delayGroupContext ? t11 = $[15] : (t11 = delayGroupContext || {}, $[14] = delayGroupContext, $[15] = t11);
208
- let { setIsGroupActive, setOpenTooltipId } = t11, showTooltip = isOpen || delayGroupContext?.openTooltipId === tooltipId, isInsideGroup = delayGroupContext !== null, openDelayProp = typeof delay == "number" ? delay : delay?.open || 0, closeDelayProp = typeof delay == "number" ? delay : delay?.close || 0, openDelay = isInsideGroup ? delayGroupContext.openDelay : openDelayProp, closeDelay = isInsideGroup ? delayGroupContext.closeDelay : closeDelayProp, t12;
209
- $[16] !== closeDelay || $[17] !== isInsideGroup || $[18] !== openDelay || $[19] !== setIsGroupActive || $[20] !== setIsOpen || $[21] !== setOpenTooltipId || $[22] !== tooltipId ? (t12 = (open, immediate) => {
207
+ elements: t10
208
+ }, $[14] = middleware, $[15] = placementProp, $[16] = t10, $[17] = t11) : t11 = $[17];
209
+ let { floatingStyles, placement, middlewareData, refs, update } = useFloating(t11), t12;
210
+ $[18] === update ? t12 = $[19] : (t12 = () => update(), $[18] = update, $[19] = t12);
211
+ let reposition = useEffectEvent(t12), t13;
212
+ $[20] !== boundaryElement || $[21] !== portalElement || $[22] !== reposition ? (t13 = () => {
213
+ (boundaryElement || portalElement) && reposition();
214
+ }, $[20] = boundaryElement, $[21] = portalElement, $[22] = reposition, $[23] = t13) : t13 = $[23];
215
+ let t14;
216
+ $[24] !== boundaryElement || $[25] !== portalElement ? (t14 = [boundaryElement, portalElement], $[24] = boundaryElement, $[25] = portalElement, $[26] = t14) : t14 = $[26], useLayoutEffect(t13, t14);
217
+ let arrowX = middlewareData.arrow?.x, arrowY = middlewareData.arrow?.y, originX = middlewareData["@sanity/ui/origin"]?.originX, originY = middlewareData["@sanity/ui/origin"]?.originY, tooltipId = useId(), [isOpen, setIsOpen] = useDelayedState(!1), delayGroupContext = useTooltipDelayGroup(), t15;
218
+ $[27] === delayGroupContext ? t15 = $[28] : (t15 = delayGroupContext || {}, $[27] = delayGroupContext, $[28] = t15);
219
+ let { setIsGroupActive, setOpenTooltipId } = t15, suppressed = disabled || !content, showTooltip = !suppressed && (isOpen || delayGroupContext?.openTooltipId === tooltipId), isInsideGroup = delayGroupContext !== null, openDelayProp = typeof delay == "number" ? delay : delay?.open || 0, closeDelayProp = typeof delay == "number" ? delay : delay?.close || 0, openDelay = isInsideGroup ? delayGroupContext.openDelay : openDelayProp, closeDelay = isInsideGroup ? delayGroupContext.closeDelay : closeDelayProp, t16;
220
+ $[29] !== closeDelay || $[30] !== isInsideGroup || $[31] !== openDelay || $[32] !== setIsGroupActive || $[33] !== setIsOpen || $[34] !== setOpenTooltipId || $[35] !== tooltipId ? (t16 = (open, immediate) => {
210
221
  if (isInsideGroup) {
211
222
  if (open) {
212
223
  let groupedOpenDelay = immediate ? 0 : openDelay;
213
224
  setIsGroupActive?.(open, groupedOpenDelay), setOpenTooltipId?.(tooltipId, groupedOpenDelay);
214
225
  } else setIsGroupActive?.(open, closeDelay > 200 ? closeDelay : 200), setOpenTooltipId?.(null, immediate ? 0 : closeDelay);
215
226
  } else setIsOpen(open, immediate ? 0 : open ? openDelay : closeDelay);
216
- }, $[16] = closeDelay, $[17] = isInsideGroup, $[18] = openDelay, $[19] = setIsGroupActive, $[20] = setIsOpen, $[21] = setOpenTooltipId, $[22] = tooltipId, $[23] = t12) : t12 = $[23];
217
- let handleIsOpenChange = t12, t13;
218
- $[24] !== childProp?.props || $[25] !== handleIsOpenChange ? (t13 = (e) => {
219
- handleIsOpenChange(!1), childProp?.props?.onBlur?.(e);
220
- }, $[24] = childProp?.props, $[25] = handleIsOpenChange, $[26] = t13) : t13 = $[26], childProp?.props;
221
- let handleBlur = t13, t14;
222
- $[27] !== childProp?.props || $[28] !== handleIsOpenChange ? (t14 = (e_0) => {
227
+ }, $[29] = closeDelay, $[30] = isInsideGroup, $[31] = openDelay, $[32] = setIsGroupActive, $[33] = setIsOpen, $[34] = setOpenTooltipId, $[35] = tooltipId, $[36] = t16) : t16 = $[36];
228
+ let handleIsOpenChange = t16, t17;
229
+ $[37] !== childProp?.props || $[38] !== handleIsOpenChange || $[39] !== suppressed ? (t17 = (e) => {
230
+ handleIsOpenChange(!1, suppressed), childProp?.props?.onBlur?.(e);
231
+ }, $[37] = childProp?.props, $[38] = handleIsOpenChange, $[39] = suppressed, $[40] = t17) : t17 = $[40], childProp?.props;
232
+ let handleBlur = t17, t18;
233
+ $[41] !== childProp?.props || $[42] !== handleIsOpenChange ? (t18 = (e_0) => {
223
234
  handleIsOpenChange(!1, !0), childProp?.props.onClick?.(e_0);
224
- }, $[27] = childProp?.props, $[28] = handleIsOpenChange, $[29] = t14) : t14 = $[29], childProp?.props;
225
- let handleClick = t14, t15;
226
- $[30] !== childProp?.props || $[31] !== handleIsOpenChange ? (t15 = (e_1) => {
235
+ }, $[41] = childProp?.props, $[42] = handleIsOpenChange, $[43] = t18) : t18 = $[43], childProp?.props;
236
+ let handleClick = t18, t19;
237
+ $[44] !== childProp?.props || $[45] !== handleIsOpenChange ? (t19 = (e_1) => {
227
238
  handleIsOpenChange(!1, !0), childProp?.props.onContextMenu?.(e_1);
228
- }, $[30] = childProp?.props, $[31] = handleIsOpenChange, $[32] = t15) : t15 = $[32], childProp?.props;
229
- let handleContextMenu = t15, t16;
230
- $[33] !== childProp?.props || $[34] !== handleIsOpenChange ? (t16 = (e_2) => {
239
+ }, $[44] = childProp?.props, $[45] = handleIsOpenChange, $[46] = t19) : t19 = $[46], childProp?.props;
240
+ let handleContextMenu = t19, t20;
241
+ $[47] !== childProp?.props || $[48] !== handleIsOpenChange ? (t20 = (e_2) => {
231
242
  handleIsOpenChange(!0), childProp?.props?.onFocus?.(e_2);
232
- }, $[33] = childProp?.props, $[34] = handleIsOpenChange, $[35] = t16) : t16 = $[35], childProp?.props;
233
- let handleFocus = t16, t17;
234
- $[36] !== childProp?.props || $[37] !== handleIsOpenChange ? (t17 = (e_3) => {
243
+ }, $[47] = childProp?.props, $[48] = handleIsOpenChange, $[49] = t20) : t20 = $[49], childProp?.props;
244
+ let handleFocus = t20, t21;
245
+ $[50] !== childProp?.props || $[51] !== handleIsOpenChange ? (t21 = (e_3) => {
235
246
  handleIsOpenChange(!0), childProp?.props?.onMouseEnter?.(e_3);
236
- }, $[36] = childProp?.props, $[37] = handleIsOpenChange, $[38] = t17) : t17 = $[38], childProp?.props;
237
- let handleMouseEnter = t17, t18;
238
- $[39] !== childProp?.props || $[40] !== handleIsOpenChange ? (t18 = (e_4) => {
239
- handleIsOpenChange(!1), childProp?.props?.onMouseLeave?.(e_4);
240
- }, $[39] = childProp?.props, $[40] = handleIsOpenChange, $[41] = t18) : t18 = $[41], childProp?.props;
241
- let handleMouseLeave = t18, t19;
242
- $[42] !== handleIsOpenChange || $[43] !== isInsideGroup || $[44] !== referenceElement || $[45] !== showTooltip ? (t19 = {
247
+ }, $[50] = childProp?.props, $[51] = handleIsOpenChange, $[52] = t21) : t21 = $[52], childProp?.props;
248
+ let handleMouseEnter = t21, t22;
249
+ $[53] !== childProp?.props || $[54] !== handleIsOpenChange || $[55] !== suppressed ? (t22 = (e_4) => {
250
+ handleIsOpenChange(!1, suppressed), childProp?.props?.onMouseLeave?.(e_4);
251
+ }, $[53] = childProp?.props, $[54] = handleIsOpenChange, $[55] = suppressed, $[56] = t22) : t22 = $[56], childProp?.props;
252
+ let handleMouseLeave = t22, t23;
253
+ $[57] !== handleIsOpenChange || $[58] !== isInsideGroup || $[59] !== referenceElement || $[60] !== showTooltip ? (t23 = {
243
254
  handleIsOpenChange,
244
255
  referenceElement,
245
256
  showTooltip,
246
257
  isInsideGroup
247
- }, $[42] = handleIsOpenChange, $[43] = isInsideGroup, $[44] = referenceElement, $[45] = showTooltip, $[46] = t19) : t19 = $[46], useCloseOnMouseLeave(t19);
248
- let t20, t21;
249
- $[47] !== disabled || $[48] !== handleIsOpenChange || $[49] !== showTooltip ? (t20 = () => {
250
- disabled && showTooltip && handleIsOpenChange(!1);
251
- }, t21 = [
252
- disabled,
253
- handleIsOpenChange,
254
- showTooltip
255
- ], $[47] = disabled, $[48] = handleIsOpenChange, $[49] = showTooltip, $[50] = t20, $[51] = t21) : (t20 = $[50], t21 = $[51]), useEffect(t20, t21);
256
- let t22, t23;
257
- $[52] !== content || $[53] !== handleIsOpenChange || $[54] !== showTooltip ? (t22 = () => {
258
- !content && showTooltip && handleIsOpenChange(!1);
259
- }, t23 = [
260
- content,
261
- handleIsOpenChange,
262
- showTooltip
263
- ], $[52] = content, $[53] = handleIsOpenChange, $[54] = showTooltip, $[55] = t22, $[56] = t23) : (t22 = $[55], t23 = $[56]), useEffect(t22, t23);
258
+ }, $[57] = handleIsOpenChange, $[58] = isInsideGroup, $[59] = referenceElement, $[60] = showTooltip, $[61] = t23) : t23 = $[61], useCloseOnMouseLeave(t23);
264
259
  let t24;
265
- $[57] === handleIsOpenChange ? t24 = $[58] : (t24 = () => handleIsOpenChange(!1, !0), $[57] = handleIsOpenChange, $[58] = t24);
260
+ $[62] === handleIsOpenChange ? t24 = $[63] : (t24 = () => handleIsOpenChange(!1, !0), $[62] = handleIsOpenChange, $[63] = t24);
266
261
  let onWindowEscape = useEffectEvent(t24), t25;
267
- $[59] !== onWindowEscape || $[60] !== showTooltip ? (t25 = () => {
262
+ $[64] !== onWindowEscape || $[65] !== showTooltip ? (t25 = () => {
268
263
  if (!showTooltip) return;
269
264
  let handleWindowKeyDown = function handleWindowKeyDown(event) {
270
265
  event.key === "Escape" && onWindowEscape();
@@ -272,32 +267,25 @@ function Tooltip(props) {
272
267
  return window.addEventListener("keydown", handleWindowKeyDown), () => {
273
268
  window.removeEventListener("keydown", handleWindowKeyDown);
274
269
  };
275
- }, $[59] = onWindowEscape, $[60] = showTooltip, $[61] = t25) : t25 = $[61];
270
+ }, $[64] = onWindowEscape, $[65] = showTooltip, $[66] = t25) : t25 = $[66];
276
271
  let t26;
277
- $[62] === showTooltip ? t26 = $[63] : (t26 = [showTooltip], $[62] = showTooltip, $[63] = t26), useEffect(t25, t26);
272
+ $[67] === showTooltip ? t26 = $[68] : (t26 = [showTooltip], $[67] = showTooltip, $[68] = t26), useEffect(t25, t26);
278
273
  let t27;
279
- $[64] !== boundaryElement || $[65] !== portalElement?.offsetWidth ? (t27 = () => {
280
- let availableWidths = [...boundaryElement ? [boundaryElement.offsetWidth] : [], portalElement?.offsetWidth || document.body.offsetWidth];
281
- setTooltipMaxWidth(Math.min(...availableWidths) - 8);
282
- }, $[64] = boundaryElement, $[65] = portalElement?.offsetWidth, $[66] = t27) : t27 = $[66];
283
- let t28;
284
- $[67] !== boundaryElement || $[68] !== portalElement ? (t28 = [boundaryElement, portalElement], $[67] = boundaryElement, $[68] = portalElement, $[69] = t28) : t28 = $[69], useLayoutEffect(t27, t28);
285
- let t29;
286
- $[70] === update ? t29 = $[71] : (t29 = (arrowEl) => {
274
+ $[69] === update ? t27 = $[70] : (t27 = (arrowEl) => {
287
275
  arrowRef.current = arrowEl, update();
288
- }, $[70] = update, $[71] = t29);
289
- let setArrow = t29, t30;
290
- $[72] === refs ? t30 = $[73] : (t30 = (node) => {
276
+ }, $[69] = update, $[70] = t27);
277
+ let setArrow = t27, t28;
278
+ $[71] === refs ? t28 = $[72] : (t28 = (node) => {
291
279
  ref.current = node, refs.setFloating(node);
292
- }, $[72] = refs, $[73] = t30);
293
- let setFloating = t30, t31;
280
+ }, $[71] = refs, $[72] = t28);
281
+ let setFloating = t28, t29;
294
282
  bb0: {
295
283
  if (!childProp) {
296
- t31 = null;
284
+ t29 = null;
297
285
  break bb0;
298
286
  }
299
- let t32;
300
- $[74] !== childProp || $[75] !== handleBlur || $[76] !== handleClick || $[77] !== handleContextMenu || $[78] !== handleFocus || $[79] !== handleMouseEnter || $[80] !== handleMouseLeave ? (t32 = cloneElement(childProp, {
287
+ let t30;
288
+ $[73] !== childProp || $[74] !== handleBlur || $[75] !== handleClick || $[76] !== handleContextMenu || $[77] !== handleFocus || $[78] !== handleMouseEnter || $[79] !== handleMouseLeave ? (t30 = cloneElement(childProp, {
301
289
  onBlur: handleBlur,
302
290
  onFocus: handleFocus,
303
291
  onMouseEnter: handleMouseEnter,
@@ -305,23 +293,17 @@ function Tooltip(props) {
305
293
  onClick: handleClick,
306
294
  onContextMenu: handleContextMenu,
307
295
  ref: setReferenceElement
308
- }), $[74] = childProp, $[75] = handleBlur, $[76] = handleClick, $[77] = handleContextMenu, $[78] = handleFocus, $[79] = handleMouseEnter, $[80] = handleMouseLeave, $[81] = t32) : t32 = $[81], t31 = t32;
296
+ }), $[73] = childProp, $[74] = handleBlur, $[75] = handleClick, $[76] = handleContextMenu, $[77] = handleFocus, $[78] = handleMouseEnter, $[79] = handleMouseLeave, $[80] = t30) : t30 = $[80], t29 = t30;
309
297
  }
310
- let child = t31, t32;
311
- $[82] === childProp ? t32 = $[83] : (t32 = childProp ? getElementRef(childProp) : null, $[82] = childProp, $[83] = t32);
312
- let t33, t34;
313
- if ($[84] === referenceElement ? (t33 = $[85], t34 = $[86]) : (t33 = () => referenceElement, t34 = [referenceElement], $[84] = referenceElement, $[85] = t33, $[86] = t34), useImperativeHandle(t32, t33, t34), !child) {
314
- let t35;
315
- return $[87] === Symbol.for("react.memo_cache_sentinel") ? (t35 = /* @__PURE__ */ jsx(Fragment$1, {}), $[87] = t35) : t35 = $[87], t35;
298
+ let child = t29, t30;
299
+ $[81] === childProp ? t30 = $[82] : (t30 = childProp ? getElementRef(childProp) : null, $[81] = childProp, $[82] = t30);
300
+ let t31, t32;
301
+ if ($[83] === referenceElement ? (t31 = $[84], t32 = $[85]) : (t31 = () => referenceElement, t32 = [referenceElement], $[83] = referenceElement, $[84] = t31, $[85] = t32), useImperativeHandle(t30, t31, t32), !child) {
302
+ let t33;
303
+ return $[86] === Symbol.for("react.memo_cache_sentinel") ? (t33 = /* @__PURE__ */ jsx(Fragment$1, {}), $[86] = t33) : t33 = $[86], t33;
316
304
  }
317
- if (disabled) return child;
318
- let T0 = Layer, t36 = clsx(tooltipLayer, restProps.className), t37 = tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : void 0, t38;
319
- $[88] !== floatingStyles || $[89] !== t37 ? (t38 = {
320
- ...floatingStyles,
321
- maxWidth: t37
322
- }, $[88] = floatingStyles, $[89] = t37, $[90] = t38) : t38 = $[90];
323
- let t39;
324
- $[91] !== animate || $[92] !== arrowProp || $[93] !== arrowX || $[94] !== arrowY || $[95] !== content || $[96] !== originX || $[97] !== originY || $[98] !== padding || $[99] !== placement || $[100] !== radius || $[101] !== restProps || $[102] !== scheme || $[103] !== setArrow || $[104] !== setFloating || $[105] !== shadow ? (t39 = /* @__PURE__ */ jsx(TooltipCard, {
305
+ let T0 = Layer, t34 = clsx(tooltipLayer, restProps.className), t35;
306
+ $[87] !== animate || $[88] !== arrowProp || $[89] !== arrowX || $[90] !== arrowY || $[91] !== content || $[92] !== originX || $[93] !== originY || $[94] !== padding || $[95] !== placement || $[96] !== radius || $[97] !== restProps || $[98] !== scheme || $[99] !== setArrow || $[100] !== setFloating || $[101] !== shadow ? (t35 = /* @__PURE__ */ jsx(TooltipCard, {
325
307
  ...restProps,
326
308
  animate,
327
309
  arrow: arrowProp,
@@ -337,61 +319,116 @@ function Tooltip(props) {
337
319
  scheme,
338
320
  shadow,
339
321
  children: content
340
- }), $[91] = animate, $[92] = arrowProp, $[93] = arrowX, $[94] = arrowY, $[95] = content, $[96] = originX, $[97] = originY, $[98] = padding, $[99] = placement, $[100] = radius, $[101] = restProps, $[102] = scheme, $[103] = setArrow, $[104] = setFloating, $[105] = shadow, $[106] = t39) : t39 = $[106];
341
- let t40;
342
- $[107] !== T0 || $[108] !== restProps || $[109] !== setFloating || $[110] !== t36 || $[111] !== t38 || $[112] !== t39 || $[113] !== zOffset ? (t40 = /* @__PURE__ */ jsx(T0, {
322
+ }), $[87] = animate, $[88] = arrowProp, $[89] = arrowX, $[90] = arrowY, $[91] = content, $[92] = originX, $[93] = originY, $[94] = padding, $[95] = placement, $[96] = radius, $[97] = restProps, $[98] = scheme, $[99] = setArrow, $[100] = setFloating, $[101] = shadow, $[102] = t35) : t35 = $[102];
323
+ let t36;
324
+ $[103] !== T0 || $[104] !== floatingStyles || $[105] !== restProps || $[106] !== setFloating || $[107] !== t34 || $[108] !== t35 || $[109] !== zOffset ? (t36 = /* @__PURE__ */ jsx(T0, {
343
325
  "data-ui": "Tooltip",
344
326
  ...restProps,
345
- className: t36,
327
+ className: t34,
346
328
  ref: setFloating,
347
- style: t38,
329
+ style: floatingStyles,
348
330
  zOffset,
349
- children: t39
350
- }), $[107] = T0, $[108] = restProps, $[109] = setFloating, $[110] = t36, $[111] = t38, $[112] = t39, $[113] = zOffset, $[114] = t40) : t40 = $[114];
351
- let tooltip = t40, t41;
352
- $[115] !== portalProp || $[116] !== tooltip ? (t41 = portalProp ? /* @__PURE__ */ jsx(Portal, {
353
- __unstable_name: typeof portalProp == "string" ? portalProp : void 0,
331
+ children: t35
332
+ }), $[103] = T0, $[104] = floatingStyles, $[105] = restProps, $[106] = setFloating, $[107] = t34, $[108] = t35, $[109] = zOffset, $[110] = t36) : t36 = $[110];
333
+ let tooltip = t36, t37;
334
+ $[111] !== portalName || $[112] !== portalProp || $[113] !== tooltip ? (t37 = portalProp ? /* @__PURE__ */ jsx(Portal, {
335
+ __unstable_name: portalName,
354
336
  children: tooltip
355
- }) : tooltip, $[115] = portalProp, $[116] = tooltip, $[117] = t41) : t41 = $[117];
356
- let tooltipNode = t41, t42;
357
- $[118] !== animate || $[119] !== showTooltip || $[120] !== tooltipNode ? (t42 = animate ? /* @__PURE__ */ jsx(AnimateActivity, {
337
+ }) : tooltip, $[111] = portalName, $[112] = portalProp, $[113] = tooltip, $[114] = t37) : t37 = $[114];
338
+ let tooltipNode = t37, t38;
339
+ $[115] !== animate || $[116] !== showTooltip || $[117] !== tooltipNode ? (t38 = animate ? /* @__PURE__ */ jsx(AnimateActivity, {
358
340
  layoutMode: "default",
359
341
  mode: showTooltip ? "visible" : "hidden",
360
342
  children: tooltipNode
361
343
  }) : /* @__PURE__ */ jsx(Activity, {
362
344
  mode: showTooltip ? "visible" : "hidden",
363
345
  children: tooltipNode
364
- }), $[118] = animate, $[119] = showTooltip, $[120] = tooltipNode, $[121] = t42) : t42 = $[121];
365
- let t43;
366
- return $[122] !== child || $[123] !== t42 ? (t43 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t42, child] }), $[122] = child, $[123] = t42, $[124] = t43) : t43 = $[124], t43;
346
+ }), $[115] = animate, $[116] = showTooltip, $[117] = tooltipNode, $[118] = t38) : t38 = $[118];
347
+ let t39 = disabled ? null : t38, t40;
348
+ return $[119] !== child || $[120] !== t39 ? (t40 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t39, child] }), $[119] = child, $[120] = t39, $[121] = t40) : t40 = $[121], t40;
349
+ }
350
+ /**
351
+ * A ref that always holds the latest `value`, updated before any layout effect of the same commit
352
+ * runs (the same mechanism `use-effect-event` uses), for callbacks that run outside render.
353
+ */
354
+ function useLatestRef(value) {
355
+ let $ = c(3), ref = useRef(value), t0, t1;
356
+ return $[0] === value ? (t0 = $[1], t1 = $[2]) : (t0 = () => {
357
+ ref.current = value;
358
+ }, t1 = [value], $[0] = value, $[1] = t0, $[2] = t1), useInsertionEffect(t0, t1), ref;
359
+ }
360
+ /**
361
+ * Derivable middleware options that read the boundary element from a ref. Floating UI evaluates
362
+ * them inside `computePosition`, which is when the ref is read — never during render.
363
+ *
364
+ * Built at module scope, like `sizeMiddleware` below: a `ref.current` read inside a callback
365
+ * created during render makes the React Compiler skip the calling function, since it cannot tell
366
+ * when the callback runs.
367
+ */
368
+ function withBoundary(boundaryRef, options) {
369
+ return () => ({
370
+ ...options,
371
+ boundary: boundaryRef.current || void 0
372
+ });
373
+ }
374
+ /**
375
+ * Caps the tooltip width to the room it is positioned in: the boundary element (or the clipping
376
+ * ancestors when there is none), always within the viewport, and the portal element's width.
377
+ * Floating UI measures inside its own positioning pass — only while the tooltip is shown, never
378
+ * during render or on mount — and the width is written straight to the element, so no state or
379
+ * layout effect is involved. Placed after `shift` so `availableWidth` is the full clipping width
380
+ * for top and bottom placements; for left and right placements it is the room on that side.
381
+ */
382
+ function sizeMiddleware({ boundaryRef, portalRef, rootBoundary }) {
383
+ return size(() => ({
384
+ boundary: boundaryRef.current || void 0,
385
+ rootBoundary,
386
+ padding: 4,
387
+ async apply(state) {
388
+ let { availableWidth, elements } = state, portalElement = portalRef.current, maxWidth = availableWidth;
389
+ if (portalElement) {
390
+ let overflow = await detectOverflow(state, {
391
+ boundary: portalElement,
392
+ rootBoundary,
393
+ padding: 4
394
+ }), portalWidth = state.rects.floating.width - overflow.left - overflow.right;
395
+ portalWidth > 0 && (maxWidth = Math.min(maxWidth, portalWidth));
396
+ }
397
+ elements.floating.style.maxWidth = `${Math.max(0, maxWidth)}px`;
398
+ }
399
+ }));
367
400
  }
368
401
  function useMiddleware(t0) {
369
- let $ = c(17), { animate, arrowProp, arrowRef, boundaryElement, fallbackPlacements, rootBoundary } = t0, ret;
370
- if ($[0] !== animate || $[1] !== arrowProp || $[2] !== arrowRef || $[3] !== boundaryElement || $[4] !== fallbackPlacements || $[5] !== rootBoundary) {
402
+ let $ = c(22), { animate, arrowProp, arrowRef, boundaryElement, fallbackPlacements, portalElement, rootBoundary } = t0, boundaryRef = useLatestRef(boundaryElement), portalRef = useLatestRef(portalElement), ret;
403
+ if ($[0] !== animate || $[1] !== arrowProp || $[2] !== arrowRef || $[3] !== boundaryRef || $[4] !== fallbackPlacements || $[5] !== portalRef || $[6] !== rootBoundary) {
371
404
  ret = [];
372
- let t1 = boundaryElement || void 0, t2;
373
- $[7] !== fallbackPlacements || $[8] !== rootBoundary || $[9] !== t1 ? (t2 = flip({
374
- boundary: t1,
405
+ let t1;
406
+ $[8] !== boundaryRef || $[9] !== fallbackPlacements || $[10] !== rootBoundary ? (t1 = flip(withBoundary(boundaryRef, {
375
407
  fallbackPlacements,
376
408
  padding: 4,
377
409
  rootBoundary
378
- }), $[7] = fallbackPlacements, $[8] = rootBoundary, $[9] = t1, $[10] = t2) : t2 = $[10], ret.push(t2);
410
+ })), $[8] = boundaryRef, $[9] = fallbackPlacements, $[10] = rootBoundary, $[11] = t1) : t1 = $[11], ret.push(t1);
411
+ let t2;
412
+ $[12] === Symbol.for("react.memo_cache_sentinel") ? (t2 = offset({ mainAxis: 4 }), $[12] = t2) : t2 = $[12], ret.push(t2);
379
413
  let t3;
380
- $[11] === Symbol.for("react.memo_cache_sentinel") ? (t3 = offset({ mainAxis: 4 }), $[11] = t3) : t3 = $[11], ret.push(t3);
381
- let t4 = boundaryElement || void 0, t5;
382
- if ($[12] !== rootBoundary || $[13] !== t4 ? (t5 = shift({
383
- boundary: t4,
414
+ $[13] !== boundaryRef || $[14] !== rootBoundary ? (t3 = shift(withBoundary(boundaryRef, {
384
415
  rootBoundary,
385
416
  padding: 4
386
- }), $[12] = rootBoundary, $[13] = t4, $[14] = t5) : t5 = $[14], ret.push(t5), arrowProp) {
387
- let t6;
388
- $[15] === arrowRef ? t6 = $[16] : (t6 = arrow({
417
+ })), $[13] = boundaryRef, $[14] = rootBoundary, $[15] = t3) : t3 = $[15], ret.push(t3);
418
+ let t4;
419
+ if ($[16] !== boundaryRef || $[17] !== portalRef || $[18] !== rootBoundary ? (t4 = sizeMiddleware({
420
+ boundaryRef,
421
+ portalRef,
422
+ rootBoundary
423
+ }), $[16] = boundaryRef, $[17] = portalRef, $[18] = rootBoundary, $[19] = t4) : t4 = $[19], ret.push(t4), arrowProp) {
424
+ let t5;
425
+ $[20] === arrowRef ? t5 = $[21] : (t5 = arrow({
389
426
  element: arrowRef,
390
427
  padding: 4
391
- }), $[15] = arrowRef, $[16] = t6), ret.push(t6);
428
+ }), $[20] = arrowRef, $[21] = t5), ret.push(t5);
392
429
  }
393
- animate && ret.push(origin), $[0] = animate, $[1] = arrowProp, $[2] = arrowRef, $[3] = boundaryElement, $[4] = fallbackPlacements, $[5] = rootBoundary, $[6] = ret;
394
- } else ret = $[6];
430
+ animate && ret.push(origin), $[0] = animate, $[1] = arrowProp, $[2] = arrowRef, $[3] = boundaryRef, $[4] = fallbackPlacements, $[5] = portalRef, $[6] = rootBoundary, $[7] = ret;
431
+ } else ret = $[7];
395
432
  return ret;
396
433
  }
397
434
  /**