@sanity/ui 4.3.3 → 4.4.1

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 (64) hide show
  1. package/dist/{arrow-CZ-Lw1QO.js → arrow-A3jQ7LS0.js} +29 -8
  2. package/dist/arrow-A3jQ7LS0.js.map +1 -0
  3. package/dist/autocomplete.d.ts +1 -1
  4. package/dist/autocomplete.js +12 -19
  5. package/dist/autocomplete.js.map +1 -1
  6. package/dist/breadcrumbs.d.ts.map +1 -1
  7. package/dist/breadcrumbs.js +9 -9
  8. package/dist/breadcrumbs.js.map +1 -1
  9. package/dist/{button-Wii-24Xu.js → button-dhq4ViVg.js} +7 -7
  10. package/dist/button-dhq4ViVg.js.map +1 -0
  11. package/dist/code.js +2 -2
  12. package/dist/{codeFontStyle-84SMhFtI.js → codeFontStyle-B-bhR3hF.js} +2 -2
  13. package/dist/{codeFontStyle-84SMhFtI.js.map → codeFontStyle-B-bhR3hF.js.map} +1 -1
  14. package/dist/elementSizeObserver-pevZfdGa.js +45 -0
  15. package/dist/elementSizeObserver-pevZfdGa.js.map +1 -0
  16. package/dist/{flex-CpiAc-4D.js → flex-BqQXaSxS.js} +5 -12
  17. package/dist/flex-BqQXaSxS.js.map +1 -0
  18. package/dist/{grid-BVZEj_Xe.js → grid-Bpb2bIJ6.js} +5 -15
  19. package/dist/grid-Bpb2bIJ6.js.map +1 -0
  20. package/dist/{helpers-C8xxXAQC.js → helpers-XThPpWje.js} +16 -4
  21. package/dist/helpers-XThPpWje.js.map +1 -0
  22. package/dist/{hotkeys-DEMStMQ5.js → hotkeys-sG9yO97K.js} +4 -4
  23. package/dist/{hotkeys-DEMStMQ5.js.map → hotkeys-sG9yO97K.js.map} +1 -1
  24. package/dist/index.d.ts +3 -0
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +141 -140
  27. package/dist/index.js.map +1 -1
  28. package/dist/{layer-B0tlPeLT.js → layer-AWzYcY_j.js} +3 -3
  29. package/dist/{layer-B0tlPeLT.js.map → layer-AWzYcY_j.js.map} +1 -1
  30. package/dist/menu.d.ts +1 -1
  31. package/dist/menu.js +16 -39
  32. package/dist/menu.js.map +1 -1
  33. package/dist/{popover-DR6UQQvq.js → popover-B0kvwaep.js} +125 -51
  34. package/dist/popover-B0kvwaep.js.map +1 -0
  35. package/dist/{popover-CMlQeKn0.d.ts → popover-HDVgZg5e.d.ts} +22 -1
  36. package/dist/popover-HDVgZg5e.d.ts.map +1 -0
  37. package/dist/popover.d.ts +1 -1
  38. package/dist/popover.js +1 -2
  39. package/dist/{responsiveFont-CilwaORG.js → responsiveFont-B08q0jwm.js} +6 -4
  40. package/dist/responsiveFont-B08q0jwm.js.map +1 -0
  41. package/dist/{stack-SbGBZ0x3.js → stack-Cv-WM-7p.js} +4 -4
  42. package/dist/{stack-SbGBZ0x3.js.map → stack-Cv-WM-7p.js.map} +1 -1
  43. package/dist/{textInput-Yp5lnvZK.js → textInput-Ddxi4mkC.js} +5 -5
  44. package/dist/{textInput-Yp5lnvZK.js.map → textInput-Ddxi4mkC.js.map} +1 -1
  45. package/dist/toast.js +5 -5
  46. package/dist/tooltip.d.ts.map +1 -1
  47. package/dist/tooltip.js +161 -140
  48. package/dist/tooltip.js.map +1 -1
  49. package/dist/{useClickOutsideEvent-wGLGWBZN.js → useClickOutsideEvent-CC1zgOmv.js} +2 -2
  50. package/dist/{useClickOutsideEvent-wGLGWBZN.js.map → useClickOutsideEvent-CC1zgOmv.js.map} +1 -1
  51. package/dist/{useLayer-CUKYjJYq.js → useLayer-B0i19TTM.js} +31 -38
  52. package/dist/useLayer-B0i19TTM.js.map +1 -0
  53. package/package.json +9 -9
  54. package/dist/arrow-CZ-Lw1QO.js.map +0 -1
  55. package/dist/button-Wii-24Xu.js.map +0 -1
  56. package/dist/flex-CpiAc-4D.js.map +0 -1
  57. package/dist/grid-BVZEj_Xe.js.map +0 -1
  58. package/dist/helpers-C8xxXAQC.js.map +0 -1
  59. package/dist/popover-CMlQeKn0.d.ts.map +0 -1
  60. package/dist/popover-DR6UQQvq.js.map +0 -1
  61. package/dist/responsiveFont-CilwaORG.js.map +0 -1
  62. package/dist/useElementSize-BJvbGHq8.js +0 -51
  63. package/dist/useElementSize-BJvbGHq8.js.map +0 -1
  64. 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-A3jQ7LS0.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(129), 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,35 +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 ? (t27 = () => {
280
- setTooltipMaxWidth(measureAvailableWidth(boundaryElement, portalElement) - 8);
281
- }, $[64] = boundaryElement, $[65] = portalElement, $[66] = t27) : t27 = $[66];
282
- let measureTooltipMaxWidth = useEffectEvent(t27), t28;
283
- $[67] !== disabled || $[68] !== measureTooltipMaxWidth || $[69] !== showTooltip ? (t28 = () => {
284
- showTooltip && !disabled && measureTooltipMaxWidth();
285
- }, $[67] = disabled, $[68] = measureTooltipMaxWidth, $[69] = showTooltip, $[70] = t28) : t28 = $[70];
286
- let t29;
287
- $[71] !== disabled || $[72] !== showTooltip ? (t29 = [disabled, showTooltip], $[71] = disabled, $[72] = showTooltip, $[73] = t29) : t29 = $[73], useLayoutEffect(t28, t29);
288
- let t30;
289
- $[74] === update ? t30 = $[75] : (t30 = (arrowEl) => {
274
+ $[69] === update ? t27 = $[70] : (t27 = (arrowEl) => {
290
275
  arrowRef.current = arrowEl, update();
291
- }, $[74] = update, $[75] = t30);
292
- let setArrow = t30, t31;
293
- $[76] === refs ? t31 = $[77] : (t31 = (node) => {
276
+ }, $[69] = update, $[70] = t27);
277
+ let setArrow = t27, t28;
278
+ $[71] === refs ? t28 = $[72] : (t28 = (node) => {
294
279
  ref.current = node, refs.setFloating(node);
295
- }, $[76] = refs, $[77] = t31);
296
- let setFloating = t31, t32;
280
+ }, $[71] = refs, $[72] = t28);
281
+ let setFloating = t28, t29;
297
282
  bb0: {
298
283
  if (!childProp) {
299
- t32 = null;
284
+ t29 = null;
300
285
  break bb0;
301
286
  }
302
- let t33;
303
- $[78] !== childProp || $[79] !== handleBlur || $[80] !== handleClick || $[81] !== handleContextMenu || $[82] !== handleFocus || $[83] !== handleMouseEnter || $[84] !== handleMouseLeave ? (t33 = cloneElement(childProp, {
287
+ let t30;
288
+ $[73] !== childProp || $[74] !== handleBlur || $[75] !== handleClick || $[76] !== handleContextMenu || $[77] !== handleFocus || $[78] !== handleMouseEnter || $[79] !== handleMouseLeave ? (t30 = cloneElement(childProp, {
304
289
  onBlur: handleBlur,
305
290
  onFocus: handleFocus,
306
291
  onMouseEnter: handleMouseEnter,
@@ -308,23 +293,17 @@ function Tooltip(props) {
308
293
  onClick: handleClick,
309
294
  onContextMenu: handleContextMenu,
310
295
  ref: setReferenceElement
311
- }), $[78] = childProp, $[79] = handleBlur, $[80] = handleClick, $[81] = handleContextMenu, $[82] = handleFocus, $[83] = handleMouseEnter, $[84] = handleMouseLeave, $[85] = t33) : t33 = $[85], t32 = t33;
296
+ }), $[73] = childProp, $[74] = handleBlur, $[75] = handleClick, $[76] = handleContextMenu, $[77] = handleFocus, $[78] = handleMouseEnter, $[79] = handleMouseLeave, $[80] = t30) : t30 = $[80], t29 = t30;
312
297
  }
313
- let child = t32, t33;
314
- $[86] === childProp ? t33 = $[87] : (t33 = childProp ? getElementRef(childProp) : null, $[86] = childProp, $[87] = t33);
315
- let t34, t35;
316
- if ($[88] === referenceElement ? (t34 = $[89], t35 = $[90]) : (t34 = () => referenceElement, t35 = [referenceElement], $[88] = referenceElement, $[89] = t34, $[90] = t35), useImperativeHandle(t33, t34, t35), !child) {
317
- let t36;
318
- return $[91] === Symbol.for("react.memo_cache_sentinel") ? (t36 = /* @__PURE__ */ jsx(Fragment$1, {}), $[91] = t36) : t36 = $[91], t36;
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;
319
304
  }
320
- if (disabled) return child;
321
- let T0 = Layer, t37 = clsx(tooltipLayer, restProps.className), t38 = tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : void 0, t39;
322
- $[92] !== floatingStyles || $[93] !== t38 ? (t39 = {
323
- ...floatingStyles,
324
- maxWidth: t38
325
- }, $[92] = floatingStyles, $[93] = t38, $[94] = t39) : t39 = $[94];
326
- let t40;
327
- $[95] !== animate || $[96] !== arrowProp || $[97] !== arrowX || $[98] !== arrowY || $[99] !== content || $[100] !== originX || $[101] !== originY || $[102] !== padding || $[103] !== placement || $[104] !== radius || $[105] !== restProps || $[106] !== scheme || $[107] !== setArrow || $[108] !== setFloating || $[109] !== shadow ? (t40 = /* @__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, {
328
307
  ...restProps,
329
308
  animate,
330
309
  arrow: arrowProp,
@@ -340,74 +319,116 @@ function Tooltip(props) {
340
319
  scheme,
341
320
  shadow,
342
321
  children: content
343
- }), $[95] = animate, $[96] = arrowProp, $[97] = arrowX, $[98] = arrowY, $[99] = content, $[100] = originX, $[101] = originY, $[102] = padding, $[103] = placement, $[104] = radius, $[105] = restProps, $[106] = scheme, $[107] = setArrow, $[108] = setFloating, $[109] = shadow, $[110] = t40) : t40 = $[110];
344
- let t41;
345
- $[111] !== T0 || $[112] !== restProps || $[113] !== setFloating || $[114] !== t37 || $[115] !== t39 || $[116] !== t40 || $[117] !== zOffset ? (t41 = /* @__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, {
346
325
  "data-ui": "Tooltip",
347
326
  ...restProps,
348
- className: t37,
327
+ className: t34,
349
328
  ref: setFloating,
350
- style: t39,
329
+ style: floatingStyles,
351
330
  zOffset,
352
- children: t40
353
- }), $[111] = T0, $[112] = restProps, $[113] = setFloating, $[114] = t37, $[115] = t39, $[116] = t40, $[117] = zOffset, $[118] = t41) : t41 = $[118];
354
- let tooltip = t41, t42;
355
- $[119] !== portalProp || $[120] !== tooltip ? (t42 = portalProp ? /* @__PURE__ */ jsx(Portal, {
356
- __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,
357
336
  children: tooltip
358
- }) : tooltip, $[119] = portalProp, $[120] = tooltip, $[121] = t42) : t42 = $[121];
359
- let tooltipNode = t42, t43;
360
- $[122] !== animate || $[123] !== showTooltip || $[124] !== tooltipNode ? (t43 = 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, {
361
340
  layoutMode: "default",
362
341
  mode: showTooltip ? "visible" : "hidden",
363
342
  children: tooltipNode
364
343
  }) : /* @__PURE__ */ jsx(Activity, {
365
344
  mode: showTooltip ? "visible" : "hidden",
366
345
  children: tooltipNode
367
- }), $[122] = animate, $[123] = showTooltip, $[124] = tooltipNode, $[125] = t43) : t43 = $[125];
368
- let t44;
369
- return $[126] !== child || $[127] !== t43 ? (t44 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t43, child] }), $[126] = child, $[127] = t43, $[128] = t44) : t44 = $[128], t44;
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;
370
359
  }
371
360
  /**
372
- * Tooltip width should never exceed the width of either any supplied boundary or portal element.
373
- * If both portal and boundary elements are provided, use the smaller width of the two.
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.
374
363
  *
375
- * Kept at module scope on purpose: `offsetWidth` forces a synchronous layout, and the React
376
- * Compiler (which the package build runs) lifts a member expression on an element captured by a
377
- * component callback — `portalElement?.offsetWidth` — into a memo dependency evaluated during
378
- * render. A plain function call on the elements gives it nothing to lift.
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.
379
381
  */
380
- function measureAvailableWidth(boundaryElement, portalElement) {
381
- let availableWidths = [...boundaryElement ? [boundaryElement.offsetWidth] : [], portalElement?.offsetWidth || document.body.offsetWidth];
382
- return Math.min(...availableWidths);
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
+ }));
383
400
  }
384
401
  function useMiddleware(t0) {
385
- let $ = c(17), { animate, arrowProp, arrowRef, boundaryElement, fallbackPlacements, rootBoundary } = t0, ret;
386
- 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) {
387
404
  ret = [];
388
- let t1 = boundaryElement || void 0, t2;
389
- $[7] !== fallbackPlacements || $[8] !== rootBoundary || $[9] !== t1 ? (t2 = flip({
390
- boundary: t1,
405
+ let t1;
406
+ $[8] !== boundaryRef || $[9] !== fallbackPlacements || $[10] !== rootBoundary ? (t1 = flip(withBoundary(boundaryRef, {
391
407
  fallbackPlacements,
392
408
  padding: 4,
393
409
  rootBoundary
394
- }), $[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);
395
413
  let t3;
396
- $[11] === Symbol.for("react.memo_cache_sentinel") ? (t3 = offset({ mainAxis: 4 }), $[11] = t3) : t3 = $[11], ret.push(t3);
397
- let t4 = boundaryElement || void 0, t5;
398
- if ($[12] !== rootBoundary || $[13] !== t4 ? (t5 = shift({
399
- boundary: t4,
414
+ $[13] !== boundaryRef || $[14] !== rootBoundary ? (t3 = shift(withBoundary(boundaryRef, {
400
415
  rootBoundary,
401
416
  padding: 4
402
- }), $[12] = rootBoundary, $[13] = t4, $[14] = t5) : t5 = $[14], ret.push(t5), arrowProp) {
403
- let t6;
404
- $[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({
405
426
  element: arrowRef,
406
427
  padding: 4
407
- }), $[15] = arrowRef, $[16] = t6), ret.push(t6);
428
+ }), $[20] = arrowRef, $[21] = t5), ret.push(t5);
408
429
  }
409
- animate && ret.push(origin), $[0] = animate, $[1] = arrowProp, $[2] = arrowRef, $[3] = boundaryElement, $[4] = fallbackPlacements, $[5] = rootBoundary, $[6] = ret;
410
- } 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];
411
432
  return ret;
412
433
  }
413
434
  /**